[libc-commits] [libc] [libc][docs] split "String Functions" into string.h, strings.h, stdlib.h, and inttypes.h (PR #118860)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Thu Dec 5 11:29:37 PST 2024
https://github.com/nickdesaulniers created https://github.com/llvm/llvm-project/pull/118860
bcmp, bcopy, and bzero should be moved from libc/src/string/ to
lib/src/strings/ in order for docgen to use existing conventions to find
whether we implement a function or not.
We should add support to docgen for mentioning glibc extensions (mempcpy) or
extensions from other libcs.
>From 14590c83dd672f699642292cfbe44e54144b49c6 Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Thu, 5 Dec 2024 09:12:54 -0800
Subject: [PATCH 1/3] [libc][docs] reorganize documentation
This commit does a few things:
* creates libc/docs/headers/ and moves all user API related headers under it.
* updates paths and docgen
* updates the top level index to put these headers under a new "Implementation
Status" tab.
* rename some of the files to be foo.rst for foo.h (except strings, which is
currently a mix of string.h and stdlib.h)
* update the heading of some files to be in the form foo.h.
---
libc/docs/{ => headers}/complex.rst | 2 +-
libc/docs/{ => headers}/ctype.rst | 2 +-
libc/docs/{ => headers}/fenv.rst | 2 +-
libc/docs/headers/index.rst | 18 ++++++++++++++++++
libc/docs/{ => headers}/math/index.rst | 8 ++++----
libc/docs/{ => headers}/math/log.rst | 0
libc/docs/{ => headers}/math/stdfix.rst | 2 +-
.../{libc_search.rst => headers/search.rst} | 8 ++++----
libc/docs/{ => headers}/setjmp.rst | 2 +-
libc/docs/{ => headers}/signal.rst | 2 +-
libc/docs/{ => headers}/stdbit.rst | 2 +-
libc/docs/{ => headers}/stdio.rst | 8 ++++----
libc/docs/{ => headers}/strings.rst | 2 +-
libc/docs/{ => headers}/threads.rst | 2 +-
.../{date_and_time.rst => headers/time.rst} | 8 ++++----
libc/docs/index.rst | 13 +------------
libc/utils/docgen/docgen.py | 2 +-
17 files changed, 45 insertions(+), 38 deletions(-)
rename libc/docs/{ => headers}/complex.rst (99%)
rename libc/docs/{ => headers}/ctype.rst (97%)
rename libc/docs/{ => headers}/fenv.rst (98%)
create mode 100644 libc/docs/headers/index.rst
rename libc/docs/{ => headers}/math/index.rst (99%)
rename libc/docs/{ => headers}/math/log.rst (100%)
rename libc/docs/{ => headers}/math/stdfix.rst (99%)
rename libc/docs/{libc_search.rst => headers/search.rst} (95%)
rename libc/docs/{ => headers}/setjmp.rst (95%)
rename libc/docs/{ => headers}/signal.rst (99%)
rename libc/docs/{ => headers}/stdbit.rst (99%)
rename libc/docs/{ => headers}/stdio.rst (96%)
rename libc/docs/{ => headers}/strings.rst (99%)
rename libc/docs/{ => headers}/threads.rst (98%)
rename libc/docs/{date_and_time.rst => headers/time.rst} (99%)
diff --git a/libc/docs/complex.rst b/libc/docs/headers/complex.rst
similarity index 99%
rename from libc/docs/complex.rst
rename to libc/docs/headers/complex.rst
index 1e74f16b60e660..2e81aba97b0ef6 100644
--- a/libc/docs/complex.rst
+++ b/libc/docs/headers/complex.rst
@@ -1,4 +1,4 @@
-.. include:: check.rst
+.. include:: ../check.rst
=========
complex.h
diff --git a/libc/docs/ctype.rst b/libc/docs/headers/ctype.rst
similarity index 97%
rename from libc/docs/ctype.rst
rename to libc/docs/headers/ctype.rst
index 66e6f12b87818c..e506830809f795 100644
--- a/libc/docs/ctype.rst
+++ b/libc/docs/headers/ctype.rst
@@ -1,4 +1,4 @@
-.. include:: check.rst
+.. include:: ../check.rst
=======
ctype.h
diff --git a/libc/docs/fenv.rst b/libc/docs/headers/fenv.rst
similarity index 98%
rename from libc/docs/fenv.rst
rename to libc/docs/headers/fenv.rst
index d910ba8852f68c..374b46ef57be0a 100644
--- a/libc/docs/fenv.rst
+++ b/libc/docs/headers/fenv.rst
@@ -1,4 +1,4 @@
-.. include:: check.rst
+.. include:: ../check.rst
======
fenv.h
diff --git a/libc/docs/headers/index.rst b/libc/docs/headers/index.rst
new file mode 100644
index 00000000000000..2a7bf59e0b56db
--- /dev/null
+++ b/libc/docs/headers/index.rst
@@ -0,0 +1,18 @@
+Implementation Status
+=====================
+
+.. toctree::
+ :maxdepth: 1
+
+ complex
+ ctype
+ fenv
+ math/index.rst
+ search
+ setjmp
+ signal
+ stdbit
+ stdio
+ strings
+ threads
+ time
diff --git a/libc/docs/math/index.rst b/libc/docs/headers/math/index.rst
similarity index 99%
rename from libc/docs/math/index.rst
rename to libc/docs/headers/math/index.rst
index 4934e93ccb1645..adc0afa080ec2a 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/headers/math/index.rst
@@ -1,10 +1,10 @@
.. _math:
-==============
-Math Functions
-==============
+======
+math.h
+======
-.. include:: ../check.rst
+.. include:: ../../check.rst
.. raw:: html
diff --git a/libc/docs/math/log.rst b/libc/docs/headers/math/log.rst
similarity index 100%
rename from libc/docs/math/log.rst
rename to libc/docs/headers/math/log.rst
diff --git a/libc/docs/math/stdfix.rst b/libc/docs/headers/math/stdfix.rst
similarity index 99%
rename from libc/docs/math/stdfix.rst
rename to libc/docs/headers/math/stdfix.rst
index d8dcb0cfa4c521..58052f000995cd 100644
--- a/libc/docs/math/stdfix.rst
+++ b/libc/docs/headers/math/stdfix.rst
@@ -2,7 +2,7 @@
StdFix Functions
================
-.. include:: ../check.rst
+.. include:: ../../check.rst
Standards and Goals
-------------------
diff --git a/libc/docs/libc_search.rst b/libc/docs/headers/search.rst
similarity index 95%
rename from libc/docs/libc_search.rst
rename to libc/docs/headers/search.rst
index 774622d1e66c3f..51832e9bdc2ed4 100644
--- a/libc/docs/libc_search.rst
+++ b/libc/docs/headers/search.rst
@@ -1,8 +1,8 @@
-=============
-Search Tables
-=============
+========
+search.h
+========
-.. include:: check.rst
+.. include:: ../check.rst
---------------
Source Location
diff --git a/libc/docs/setjmp.rst b/libc/docs/headers/setjmp.rst
similarity index 95%
rename from libc/docs/setjmp.rst
rename to libc/docs/headers/setjmp.rst
index 3739e73685b4bb..b0091134f1a6b2 100644
--- a/libc/docs/setjmp.rst
+++ b/libc/docs/headers/setjmp.rst
@@ -1,4 +1,4 @@
-.. include:: check.rst
+.. include:: ../check.rst
========
setjmp.h
diff --git a/libc/docs/signal.rst b/libc/docs/headers/signal.rst
similarity index 99%
rename from libc/docs/signal.rst
rename to libc/docs/headers/signal.rst
index 172dd4a048ae9a..b59ae093423574 100644
--- a/libc/docs/signal.rst
+++ b/libc/docs/headers/signal.rst
@@ -1,4 +1,4 @@
-.. include:: check.rst
+.. include:: ../check.rst
========
signal.h
diff --git a/libc/docs/stdbit.rst b/libc/docs/headers/stdbit.rst
similarity index 99%
rename from libc/docs/stdbit.rst
rename to libc/docs/headers/stdbit.rst
index 3718ff8dc0df26..0484d951e19c6b 100644
--- a/libc/docs/stdbit.rst
+++ b/libc/docs/headers/stdbit.rst
@@ -1,4 +1,4 @@
-.. include:: check.rst
+.. include:: ../check.rst
========
stdbit.h
diff --git a/libc/docs/stdio.rst b/libc/docs/headers/stdio.rst
similarity index 96%
rename from libc/docs/stdio.rst
rename to libc/docs/headers/stdio.rst
index d17821562c2556..3cd355529d4005 100644
--- a/libc/docs/stdio.rst
+++ b/libc/docs/headers/stdio.rst
@@ -1,8 +1,8 @@
-===============
-StdIO Functions
-===============
+=======
+stdio.h
+=======
-.. include:: check.rst
+.. include:: ../check.rst
---------------
Source location
diff --git a/libc/docs/strings.rst b/libc/docs/headers/strings.rst
similarity index 99%
rename from libc/docs/strings.rst
rename to libc/docs/headers/strings.rst
index 427644c407ae83..949c53bfa4f740 100644
--- a/libc/docs/strings.rst
+++ b/libc/docs/headers/strings.rst
@@ -2,7 +2,7 @@
String Functions
================
-.. include:: check.rst
+.. include:: ../check.rst
---------------
Source location
diff --git a/libc/docs/threads.rst b/libc/docs/headers/threads.rst
similarity index 98%
rename from libc/docs/threads.rst
rename to libc/docs/headers/threads.rst
index db2d6630a238c0..39ee049eb1f8f5 100644
--- a/libc/docs/threads.rst
+++ b/libc/docs/headers/threads.rst
@@ -1,4 +1,4 @@
-.. include:: check.rst
+.. include:: ../check.rst
=========
threads.h
diff --git a/libc/docs/date_and_time.rst b/libc/docs/headers/time.rst
similarity index 99%
rename from libc/docs/date_and_time.rst
rename to libc/docs/headers/time.rst
index b745a3b416f802..de82d80a2bec48 100644
--- a/libc/docs/date_and_time.rst
+++ b/libc/docs/headers/time.rst
@@ -1,8 +1,8 @@
-=======================
-Date and Time Functions
-=======================
+======
+time.h
+======
-.. include:: check.rst
+.. include:: ../check.rst
---------------
Source location
diff --git a/libc/docs/index.rst b/libc/docs/index.rst
index 6f759aa215b62c..01f36709dfa549 100644
--- a/libc/docs/index.rst
+++ b/libc/docs/index.rst
@@ -64,19 +64,8 @@ stages there is no ABI stability in any form.
:caption: Status
compiler_support
- date_and_time
- math/index.rst
- strings
- stdio
- stdbit
- fenv
- libc_search
+ headers/index.rst
c23
- ctype
- complex
- signal
- threads
- setjmp
.. toctree::
:hidden:
diff --git a/libc/utils/docgen/docgen.py b/libc/utils/docgen/docgen.py
index 016a3dae9aaa0f..aa30a6e51ef870 100755
--- a/libc/utils/docgen/docgen.py
+++ b/libc/utils/docgen/docgen.py
@@ -161,7 +161,7 @@ def print_macros_rst(header: Header, macros: Dict):
def print_impl_status_rst(header: Header, api: Dict):
- print(".. include:: check.rst\n")
+ print(".. include:: ../check.rst\n")
print("=" * len(header.name))
print(header.name)
>From fdb8898406582f867bd84415d1ac830454b85237 Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Thu, 5 Dec 2024 10:11:28 -0800
Subject: [PATCH 2/3] [libc][docs] stub out assert, errno, and locale
These were the remaining c89 library headers (besides string.h and stdlib.h; I
will split strings.rst in a follow up commit).
The macro support detection in docgen doesn't quite work for some of these
headers. Add the stubs for these headers for now, and fix up docgen later.
See the "NIST publication":
Link: https://www.open-std.org/jtc1/sc22/wg14/www/projects.html
---
libc/docs/headers/assert.rst | 27 +++++++++++++++
libc/docs/headers/errno.rst | 35 +++++++++++++++++++
libc/docs/headers/index.rst | 3 ++
libc/docs/headers/locale.rst | 63 +++++++++++++++++++++++++++++++++++
libc/utils/docgen/assert.json | 10 ++++++
libc/utils/docgen/errno.json | 16 +++++++++
libc/utils/docgen/locale.json | 30 +++++++++++++++++
7 files changed, 184 insertions(+)
create mode 100644 libc/docs/headers/assert.rst
create mode 100644 libc/docs/headers/errno.rst
create mode 100644 libc/docs/headers/locale.rst
create mode 100644 libc/utils/docgen/assert.json
create mode 100644 libc/utils/docgen/errno.json
create mode 100644 libc/utils/docgen/locale.json
diff --git a/libc/docs/headers/assert.rst b/libc/docs/headers/assert.rst
new file mode 100644
index 00000000000000..06ea27966de1ae
--- /dev/null
+++ b/libc/docs/headers/assert.rst
@@ -0,0 +1,27 @@
+.. include:: ../check.rst
+
+========
+assert.h
+========
+
+Macros
+======
+
+.. list-table::
+ :widths: auto
+ :align: center
+ :header-rows: 1
+
+ * - Macro
+ - Implemented
+ - C23 Standard Section
+ - POSIX.1-2024 Standard Section
+ * - __STDC_VERSION_ASSERT_H__
+ - |check|
+ - 7.2.1
+ -
+ * - assert
+ -
+ - 7.2.1
+ -
+
diff --git a/libc/docs/headers/errno.rst b/libc/docs/headers/errno.rst
new file mode 100644
index 00000000000000..f25aae4f23b2c7
--- /dev/null
+++ b/libc/docs/headers/errno.rst
@@ -0,0 +1,35 @@
+.. include:: ../check.rst
+
+=======
+errno.h
+=======
+
+Macros
+======
+
+.. list-table::
+ :widths: auto
+ :align: center
+ :header-rows: 1
+
+ * - Macro
+ - Implemented
+ - C23 Standard Section
+ - POSIX.1-2024 Standard Section
+ * - EDOM
+ -
+ - 7.5
+ -
+ * - EILSEQ
+ -
+ - 7.5
+ -
+ * - ERANGE
+ -
+ - 7.5
+ -
+ * - errno
+ -
+ - 7.5
+ -
+
diff --git a/libc/docs/headers/index.rst b/libc/docs/headers/index.rst
index 2a7bf59e0b56db..7a9186a7c66e86 100644
--- a/libc/docs/headers/index.rst
+++ b/libc/docs/headers/index.rst
@@ -4,9 +4,12 @@ Implementation Status
.. toctree::
:maxdepth: 1
+ assert
complex
ctype
+ errno
fenv
+ locale
math/index.rst
search
setjmp
diff --git a/libc/docs/headers/locale.rst b/libc/docs/headers/locale.rst
new file mode 100644
index 00000000000000..2d5525bd3f2f9a
--- /dev/null
+++ b/libc/docs/headers/locale.rst
@@ -0,0 +1,63 @@
+.. include:: ../check.rst
+
+========
+locale.h
+========
+
+Macros
+======
+
+.. list-table::
+ :widths: auto
+ :align: center
+ :header-rows: 1
+
+ * - Macro
+ - Implemented
+ - C23 Standard Section
+ - POSIX.1-2024 Standard Section
+ * - LC_ALL
+ - |check|
+ - 7.11
+ -
+ * - LC_COLLATE
+ - |check|
+ - 7.11
+ -
+ * - LC_CTYPE
+ - |check|
+ - 7.11
+ -
+ * - LC_MONETARY
+ - |check|
+ - 7.11
+ -
+ * - LC_NUMERIC
+ - |check|
+ - 7.11
+ -
+ * - LC_TIME
+ - |check|
+ - 7.11
+ -
+
+Functions
+=========
+
+.. list-table::
+ :widths: auto
+ :align: center
+ :header-rows: 1
+
+ * - Function
+ - Implemented
+ - C23 Standard Section
+ - POSIX.1-2024 Standard Section
+ * - localeconv
+ - |check|
+ - 7.11.2.1
+ -
+ * - setlocale
+ - |check|
+ - 7.11.1.1
+ -
diff --git a/libc/utils/docgen/assert.json b/libc/utils/docgen/assert.json
new file mode 100644
index 00000000000000..28ec12028ef675
--- /dev/null
+++ b/libc/utils/docgen/assert.json
@@ -0,0 +1,10 @@
+{
+ "macros": {
+ "__STDC_VERSION_ASSERT_H__": {
+ "c-definition": "7.2.1"
+ },
+ "assert": {
+ "c-definition": "7.2.1"
+ }
+ }
+}
diff --git a/libc/utils/docgen/errno.json b/libc/utils/docgen/errno.json
new file mode 100644
index 00000000000000..aface8e42b495f
--- /dev/null
+++ b/libc/utils/docgen/errno.json
@@ -0,0 +1,16 @@
+{
+ "macros": {
+ "EDOM": {
+ "c-definition": "7.5"
+ },
+ "EILSEQ": {
+ "c-definition": "7.5"
+ },
+ "ERANGE": {
+ "c-definition": "7.5"
+ },
+ "errno": {
+ "c-definition": "7.5"
+ }
+ }
+}
diff --git a/libc/utils/docgen/locale.json b/libc/utils/docgen/locale.json
new file mode 100644
index 00000000000000..89329f9aae5b0f
--- /dev/null
+++ b/libc/utils/docgen/locale.json
@@ -0,0 +1,30 @@
+{
+ "macros": {
+ "LC_ALL": {
+ "c-definition": "7.11"
+ },
+ "LC_COLLATE": {
+ "c-definition": "7.11"
+ },
+ "LC_CTYPE": {
+ "c-definition": "7.11"
+ },
+ "LC_MONETARY": {
+ "c-definition": "7.11"
+ },
+ "LC_NUMERIC": {
+ "c-definition": "7.11"
+ },
+ "LC_TIME": {
+ "c-definition": "7.11"
+ }
+ },
+ "functions": {
+ "setlocale": {
+ "c-definition": "7.11.1.1"
+ },
+ "localeconv": {
+ "c-definition": "7.11.2.1"
+ }
+ }
+}
>From 39fcbdf3bb93bfbcf9499f69a32c971a3e6e9bd0 Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Thu, 5 Dec 2024 11:20:08 -0800
Subject: [PATCH 3/3] [libc][docs] split "String Functions" into string.h,
strings.h, stdlib.h, and inttypes.h
bcmp, bcopy, and bzero should be moved from libc/src/string/ to
lib/src/strings/ in order for docgen to use existing conventions to find
whether we implement a function or not.
We should add support to docgen for mentioning glibc extensions (mempcpy) or
extensions from other libcs.
---
libc/docs/headers/index.rst | 3 +
libc/docs/headers/inttypes.rst | 42 ++++++
libc/docs/headers/stdlib.rst | 255 ++++++++++++++++++++++++++++++++
libc/docs/headers/string.rst | 155 +++++++++++++++++++
libc/docs/headers/strings.rst | 192 ++++--------------------
libc/utils/docgen/inttypes.json | 22 +++
libc/utils/docgen/stdlib.json | 174 ++++++++++++++++++++++
libc/utils/docgen/string.json | 99 +++++++++++++
libc/utils/docgen/strings.json | 13 ++
9 files changed, 791 insertions(+), 164 deletions(-)
create mode 100644 libc/docs/headers/inttypes.rst
create mode 100644 libc/docs/headers/stdlib.rst
create mode 100644 libc/docs/headers/string.rst
create mode 100644 libc/utils/docgen/inttypes.json
create mode 100644 libc/utils/docgen/stdlib.json
create mode 100644 libc/utils/docgen/string.json
create mode 100644 libc/utils/docgen/strings.json
diff --git a/libc/docs/headers/index.rst b/libc/docs/headers/index.rst
index 7a9186a7c66e86..4d220d9da63071 100644
--- a/libc/docs/headers/index.rst
+++ b/libc/docs/headers/index.rst
@@ -9,6 +9,7 @@ Implementation Status
ctype
errno
fenv
+ inttypes
locale
math/index.rst
search
@@ -16,6 +17,8 @@ Implementation Status
signal
stdbit
stdio
+ stdlib
+ string
strings
threads
time
diff --git a/libc/docs/headers/inttypes.rst b/libc/docs/headers/inttypes.rst
new file mode 100644
index 00000000000000..f43c80f095c6a8
--- /dev/null
+++ b/libc/docs/headers/inttypes.rst
@@ -0,0 +1,42 @@
+.. include:: ../check.rst
+
+==========
+inttypes.h
+==========
+
+Functions
+=========
+
+.. list-table::
+ :widths: auto
+ :align: center
+ :header-rows: 1
+
+ * - Function
+ - Implemented
+ - C23 Standard Section
+ - POSIX.1-2024 Standard Section
+ * - imaxabs
+ - |check|
+ - 7.8.2.1
+ -
+ * - imaxdiv
+ - |check|
+ - 7.8.2.2
+ -
+ * - strtoimax
+ - |check|
+ - 7.8.2.3
+ -
+ * - strtoumax
+ - |check|
+ - 7.8.2.3
+ -
+ * - wcstoimax
+ -
+ - 7.8.2.4
+ -
+ * - wcstoumax
+ -
+ - 7.8.2.4
+ -
diff --git a/libc/docs/headers/stdlib.rst b/libc/docs/headers/stdlib.rst
new file mode 100644
index 00000000000000..139d9b4a922281
--- /dev/null
+++ b/libc/docs/headers/stdlib.rst
@@ -0,0 +1,255 @@
+.. include:: ../check.rst
+
+========
+stdlib.h
+========
+
+Macros
+======
+
+.. list-table::
+ :widths: auto
+ :align: center
+ :header-rows: 1
+
+ * - Macro
+ - Implemented
+ - C23 Standard Section
+ - POSIX.1-2024 Standard Section
+ * - EXIT_FAILURE
+ - |check|
+ - 7.24
+ -
+ * - EXIT_SUCCESS
+ - |check|
+ - 7.24
+ -
+ * - MB_CUR_MAX
+ - |check|
+ - 7.24
+ -
+ * - RAND_MAX
+ - |check|
+ - 7.24
+ -
+ * - __STDC_VERSION_STDLIB_H__
+ -
+ - 7.24
+ -
+
+Functions
+=========
+
+.. list-table::
+ :widths: auto
+ :align: center
+ :header-rows: 1
+
+ * - Function
+ - Implemented
+ - C23 Standard Section
+ - POSIX.1-2024 Standard Section
+ * - _Exit
+ - |check|
+ - 7.24.4.5
+ -
+ * - abort
+ - |check|
+ - 7.24.4.1
+ -
+ * - abs
+ - |check|
+ - 7.24.6.1
+ -
+ * - aligned_alloc
+ - |check|
+ - 7.24.3.1
+ -
+ * - at_quick_exit
+ - |check|
+ - 7.24.4.3
+ -
+ * - atexit
+ - |check|
+ - 7.24.4.2
+ -
+ * - atof
+ - |check|
+ - 7.24.1.1
+ -
+ * - atoi
+ - |check|
+ - 7.24.1.2
+ -
+ * - atol
+ - |check|
+ - 7.24.1.2
+ -
+ * - atoll
+ - |check|
+ - 7.24.1.2
+ -
+ * - bsearch
+ - |check|
+ - 7.24.5.1
+ -
+ * - calloc
+ - |check|
+ - 7.24.3.2
+ -
+ * - div
+ - |check|
+ - 7.24.6.2
+ -
+ * - exit
+ - |check|
+ - 7.24.4.4
+ -
+ * - free
+ - |check|
+ - 7.24.3.3
+ -
+ * - free_aligned_sized
+ -
+ - 7.24.3.5
+ -
+ * - free_sized
+ -
+ - 7.24.3.4
+ -
+ * - getenv
+ - |check|
+ - 7.24.4.6
+ -
+ * - labs
+ - |check|
+ - 7.24.6.1
+ -
+ * - ldiv
+ - |check|
+ - 7.24.6.2
+ -
+ * - llabs
+ - |check|
+ - 7.24.6.1
+ -
+ * - lldiv
+ - |check|
+ - 7.24.6.2
+ -
+ * - malloc
+ - |check|
+ - 7.24.3.6
+ -
+ * - mblen
+ -
+ - 7.24.7.1
+ -
+ * - mbstowcs
+ -
+ - 7.24.8.1
+ -
+ * - mbtowc
+ -
+ - 7.24.7.2
+ -
+ * - memalignment
+ -
+ - 7.24.9.1
+ -
+ * - qsort
+ - |check|
+ - 7.24.5.2
+ -
+ * - quick_exit
+ - |check|
+ - 7.24.4.7
+ -
+ * - rand
+ - |check|
+ - 7.24.2.1
+ -
+ * - realloc
+ - |check|
+ - 7.24.3.7
+ -
+ * - srand
+ - |check|
+ - 7.24.2.2
+ -
+ * - strfromd
+ - |check|
+ - 7.24.1.3
+ -
+ * - strfromd128
+ -
+ - 7.24.1.4
+ -
+ * - strfromd32
+ -
+ - 7.24.1.4
+ -
+ * - strfromd64
+ -
+ - 7.24.1.4
+ -
+ * - strfromf
+ - |check|
+ - 7.24.1.3
+ -
+ * - strfroml
+ - |check|
+ - 7.24.1.3
+ -
+ * - strtod
+ - |check|
+ - 7.24.1.5
+ -
+ * - strtod128
+ -
+ - 7.24.1.6
+ -
+ * - strtod32
+ -
+ - 7.24.1.6
+ -
+ * - strtod64
+ -
+ - 7.24.1.6
+ -
+ * - strtof
+ - |check|
+ - 7.24.1.5
+ -
+ * - strtol
+ - |check|
+ - 7.24.1.7
+ -
+ * - strtold
+ - |check|
+ - 7.24.1.5
+ -
+ * - strtoll
+ - |check|
+ - 7.24.1.7
+ -
+ * - strtoul
+ - |check|
+ - 7.24.1.7
+ -
+ * - strtoull
+ - |check|
+ - 7.24.1.7
+ -
+ * - system
+ - |check|
+ - 7.24.4.8
+ -
+ * - wcstombs
+ -
+ - 7.24.8.2
+ -
+ * - wctomb
+ -
+ - 7.24.7.3
+ -
diff --git a/libc/docs/headers/string.rst b/libc/docs/headers/string.rst
new file mode 100644
index 00000000000000..55f779c830ea87
--- /dev/null
+++ b/libc/docs/headers/string.rst
@@ -0,0 +1,155 @@
+.. include:: ../check.rst
+
+========
+string.h
+========
+
+Macros
+======
+
+.. list-table::
+ :widths: auto
+ :align: center
+ :header-rows: 1
+
+ * - Macro
+ - Implemented
+ - C23 Standard Section
+ - POSIX.1-2024 Standard Section
+ * - __STDC_VERSION_STRING_H__
+ -
+ - 7.26.1
+ -
+
+Functions
+=========
+
+.. list-table::
+ :widths: auto
+ :align: center
+ :header-rows: 1
+
+ * - Function
+ - Implemented
+ - C23 Standard Section
+ - POSIX.1-2024 Standard Section
+ * - memccpy
+ - |check|
+ - 7.26.2.2
+ -
+ * - memchr
+ - |check|
+ - 7.26.5.2
+ -
+ * - memcmp
+ - |check|
+ - 7.26.4.1
+ -
+ * - memcpy
+ - |check|
+ - 7.26.2.1
+ -
+ * - memmove
+ - |check|
+ - 7.26.2.3
+ -
+ * - mempcpy
+ - |check|
+ - TODO: glibc extension
+ -
+ * - memset
+ - |check|
+ - 7.26.6.1
+ -
+ * - memset_explicit
+ - |check|
+ - 7.26.6.2
+ -
+ * - stpcpy
+ - |check|
+ -
+ - https://pubs.opengroup.org/onlinepubs/9799919799/functions/stpcpy.html
+ * - stpncpy
+ - |check|
+ -
+ - https://pubs.opengroup.org/onlinepubs/9799919799/functions/stpncpy.html
+ * - strcat
+ - |check|
+ - 7.26.3.1
+ -
+ * - strchr
+ - |check|
+ - 7.26.5.3
+ -
+ * - strcmp
+ - |check|
+ - 7.26.4.2
+ -
+ * - strcoll
+ - |check|
+ - 7.26.4.3
+ -
+ * - strcpy
+ - |check|
+ - 7.26.2.4
+ -
+ * - strcspn
+ - |check|
+ - 7.26.5.4
+ -
+ * - strdup
+ - |check|
+ - 7.26.2.6
+ -
+ * - strerror
+ - |check|
+ - 7.26.6.3
+ -
+ * - strlen
+ - |check|
+ - 7.26.6.4
+ -
+ * - strncat
+ - |check|
+ - 7.26.3.2
+ -
+ * - strncmp
+ - |check|
+ - 7.26.4.4
+ -
+ * - strncpy
+ - |check|
+ - 7.26.2.5
+ -
+ * - strndup
+ - |check|
+ - 7.26.2.7
+ -
+ * - strpbrk
+ - |check|
+ - 7.26.5.5
+ -
+ * - strrchr
+ - |check|
+ - 7.26.5.6
+ -
+ * - strspn
+ - |check|
+ - 7.26.5.7
+ -
+ * - strstr
+ - |check|
+ - 7.26.5.8
+ -
+ * - strtok
+ - |check|
+ - 7.26.5.9
+ -
+ * - strtok_r
+ - |check|
+ -
+ - https://pubs.opengroup.org/onlinepubs/9799919799/functions/strtok_r.html
+ * - strxfrm
+ - |check|
+ - 7.26.4.5
+ -
diff --git a/libc/docs/headers/strings.rst b/libc/docs/headers/strings.rst
index 949c53bfa4f740..689077a655e619 100644
--- a/libc/docs/headers/strings.rst
+++ b/libc/docs/headers/strings.rst
@@ -1,166 +1,30 @@
-================
-String Functions
-================
-
.. include:: ../check.rst
----------------
-Source location
----------------
-
-- The main source for string functions is located at:
- ``libc/src/string``.
-
-- The source for string conversion functions is located at:
- ``libc/src/stdlib`` and
- ``libc/src/__support``.
-
-- The tests are located at:
- ``libc/test/src/string``,
- ``libc/test/src/stdlib``, and
- ``libc/test/src/__support``
- respectively.
-
----------------------
-Implementation Status
----------------------
-
-Primary memory functions
-========================
-
-.. TODO(gchatelet): add details about the memory functions.
-
-
-============= =========
-Function Name Available
-============= =========
-bzero |check|
-bcmp |check|
-bcopy |check|
-memcpy |check|
-memset |check|
-memcmp |check|
-memmove |check|
-============= =========
-
-
-Other Raw Memory Functions
-==========================
-
-============= =========
-Function Name Available
-============= =========
-memchr |check|
-memrchr |check|
-memccpy |check|
-mempcpy |check|
-============= =========
-
-String Memory Functions
-=======================
-
-============= =========
-Function Name Available
-============= =========
-stpcpy |check|
-stpncpy |check|
-strcpy |check|
-strncpy |check|
-strcat |check|
-strncat |check|
-strdup |check|
-strndup |check|
-============= =========
-
-String Examination Functions
-============================
-
-============= =========
-Function Name Available
-============= =========
-strlen |check|
-strnlen |check|
-strcmp |check|
-strncmp |check|
-strchr |check|
-strrchr |check|
-strspn |check|
-strcspn |check|
-strpbrk |check|
-strstr |check|
-strtok |check|
-strtok_r |check|
-============= =========
-
-String Conversion Functions
-============================
-
-These functions are not in strings.h, but are still primarily string
-functions, and are therefore tracked along with the rest of the string
-functions.
-
-The String to float functions were implemented using the Eisel-Lemire algorithm
-(read more about the algorithm here: `The Eisel-Lemire ParseNumberF64 Algorithm
-<https://nigeltao.github.io/blog/2020/eisel-lemire.html>`_). This improved
-the performance of string to float and double, and allowed it to complete this
-comprehensive test 15% faster than glibc: `Parse Number FXX Test Data
-<https://github.com/nigeltao/parse-number-fxx-test-data>`_. The test was done
-with LLVM-libc built on 2022-04-14 and Debian GLibc version 2.33-6. The targets
-``libc_str_to_float_comparison_test`` and
-``libc_system_str_to_float_comparison_test`` were built and run on the test data
-10 times each, skipping the first run since it was an outlier.
-
-
-============= =========
-Function Name Available
-============= =========
-atof |check|
-atoi |check|
-atol |check|
-atoll |check|
-strtol |check|
-strtoll |check|
-strtoul |check|
-strtoull |check|
-strtof |check|
-strtod |check|
-strtold |check|
-strtoimax |check|
-strtoumax |check|
-============= =========
-
-String Error Functions
-======================
-
-============= =========
-Function Name Available
-============= =========
-strerror |check|
-strerror_r |check|
-============= =========
-
-Localized String Functions
-==========================
-
-These functions require locale.h, and will be finished when locale support is
-implemented in LLVM-libc.
-
-============= =========
-Function Name Available
-============= =========
-strcoll Partially
-strxfrm Partially
-============= =========
-
----------------------------
-\<name\>_s String Functions
----------------------------
-
-Many String functions have an equivalent _s version, which is intended to be
-more secure and safe than the previous standard. These functions add runtime
-error detection and overflow protection. While they can be seen as an
-improvement, adoption remains relatively low among users. In addition, they are
-being considered for removal, see
-`Field Experience With Annex K — Bounds Checking Interfaces
-<http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1967.htm>`_. For these reasons,
-there is no ongoing work to implement them.
+=========
+strings.h
+=========
+
+Functions
+=========
+
+.. list-table::
+ :widths: auto
+ :align: center
+ :header-rows: 1
+
+ * - Function
+ - Implemented
+ - C23 Standard Section
+ - POSIX.1-2024 Standard Section
+ * - bcmp
+ -
+ -
+ - removed in POSIX.1-2008
+ * - bcopy
+ -
+ -
+ - removed in POSIX.1-2008
+ * - bzero
+ -
+ -
+ - removed in POSIX.1-2008
diff --git a/libc/utils/docgen/inttypes.json b/libc/utils/docgen/inttypes.json
new file mode 100644
index 00000000000000..001f15f27e6382
--- /dev/null
+++ b/libc/utils/docgen/inttypes.json
@@ -0,0 +1,22 @@
+{
+ "functions": {
+ "imaxabs": {
+ "c-definition": "7.8.2.1"
+ },
+ "imaxdiv": {
+ "c-definition": "7.8.2.2"
+ },
+ "strtoimax": {
+ "c-definition": "7.8.2.3"
+ },
+ "strtoumax": {
+ "c-definition": "7.8.2.3"
+ },
+ "wcstoimax": {
+ "c-definition": "7.8.2.4"
+ },
+ "wcstoumax": {
+ "c-definition": "7.8.2.4"
+ }
+ }
+}
diff --git a/libc/utils/docgen/stdlib.json b/libc/utils/docgen/stdlib.json
new file mode 100644
index 00000000000000..0ca508110c0f18
--- /dev/null
+++ b/libc/utils/docgen/stdlib.json
@@ -0,0 +1,174 @@
+{
+ "macros": {
+ "__STDC_VERSION_STDLIB_H__": {
+ "c-definition": "7.24"
+ },
+ "EXIT_FAILURE": {
+ "c-definition": "7.24"
+ },
+ "EXIT_SUCCESS": {
+ "c-definition": "7.24"
+ },
+ "RAND_MAX": {
+ "c-definition": "7.24"
+ },
+ "MB_CUR_MAX": {
+ "c-definition": "7.24"
+ }
+ },
+ "functions": {
+ "atof": {
+ "c-definition": "7.24.1.1"
+ },
+ "atoi": {
+ "c-definition": "7.24.1.2"
+ },
+ "atol": {
+ "c-definition": "7.24.1.2"
+ },
+ "atoll": {
+ "c-definition": "7.24.1.2"
+ },
+ "strfromd": {
+ "c-definition": "7.24.1.3"
+ },
+ "strfromf": {
+ "c-definition": "7.24.1.3"
+ },
+ "strfroml": {
+ "c-definition": "7.24.1.3"
+ },
+ "strfromd32": {
+ "c-definition": "7.24.1.4"
+ },
+ "strfromd64": {
+ "c-definition": "7.24.1.4"
+ },
+ "strfromd128": {
+ "c-definition": "7.24.1.4"
+ },
+ "strtod": {
+ "c-definition": "7.24.1.5"
+ },
+ "strtof": {
+ "c-definition": "7.24.1.5"
+ },
+ "strtold": {
+ "c-definition": "7.24.1.5"
+ },
+ "strtod32": {
+ "c-definition": "7.24.1.6"
+ },
+ "strtod64": {
+ "c-definition": "7.24.1.6"
+ },
+ "strtod128": {
+ "c-definition": "7.24.1.6"
+ },
+ "strtol": {
+ "c-definition": "7.24.1.7"
+ },
+ "strtoll": {
+ "c-definition": "7.24.1.7"
+ },
+ "strtoul": {
+ "c-definition": "7.24.1.7"
+ },
+ "strtoull": {
+ "c-definition": "7.24.1.7"
+ },
+ "rand": {
+ "c-definition": "7.24.2.1"
+ },
+ "srand": {
+ "c-definition": "7.24.2.2"
+ },
+ "aligned_alloc": {
+ "c-definition": "7.24.3.1"
+ },
+ "calloc": {
+ "c-definition": "7.24.3.2"
+ },
+ "free": {
+ "c-definition": "7.24.3.3"
+ },
+ "free_sized": {
+ "c-definition": "7.24.3.4"
+ },
+ "free_aligned_sized": {
+ "c-definition": "7.24.3.5"
+ },
+ "malloc": {
+ "c-definition": "7.24.3.6"
+ },
+ "realloc": {
+ "c-definition": "7.24.3.7"
+ },
+ "abort": {
+ "c-definition": "7.24.4.1"
+ },
+ "atexit": {
+ "c-definition": "7.24.4.2"
+ },
+ "at_quick_exit": {
+ "c-definition": "7.24.4.3"
+ },
+ "exit": {
+ "c-definition": "7.24.4.4"
+ },
+ "_Exit": {
+ "c-definition": "7.24.4.5"
+ },
+ "getenv": {
+ "c-definition": "7.24.4.6"
+ },
+ "quick_exit": {
+ "c-definition": "7.24.4.7"
+ },
+ "system": {
+ "c-definition": "7.24.4.8"
+ },
+ "bsearch": {
+ "c-definition": "7.24.5.1"
+ },
+ "qsort": {
+ "c-definition": "7.24.5.2"
+ },
+ "abs": {
+ "c-definition": "7.24.6.1"
+ },
+ "labs": {
+ "c-definition": "7.24.6.1"
+ },
+ "llabs": {
+ "c-definition": "7.24.6.1"
+ },
+ "div": {
+ "c-definition": "7.24.6.2"
+ },
+ "ldiv": {
+ "c-definition": "7.24.6.2"
+ },
+ "lldiv": {
+ "c-definition": "7.24.6.2"
+ },
+ "mblen": {
+ "c-definition": "7.24.7.1"
+ },
+ "mbtowc": {
+ "c-definition": "7.24.7.2"
+ },
+ "wctomb": {
+ "c-definition": "7.24.7.3"
+ },
+ "mbstowcs": {
+ "c-definition": "7.24.8.1"
+ },
+ "wcstombs": {
+ "c-definition": "7.24.8.2"
+ },
+ "memalignment": {
+ "c-definition": "7.24.9.1"
+ }
+ }
+}
diff --git a/libc/utils/docgen/string.json b/libc/utils/docgen/string.json
new file mode 100644
index 00000000000000..d3fd9daf186a1d
--- /dev/null
+++ b/libc/utils/docgen/string.json
@@ -0,0 +1,99 @@
+{
+ "macros": {
+ "__STDC_VERSION_STRING_H__": {
+ "c-definition": "7.26.1"
+ }
+ },
+ "functions": {
+ "memcpy": {
+ "c-definition": "7.26.2.1"
+ },
+ "memccpy": {
+ "c-definition": "7.26.2.2"
+ },
+ "mempcpy": {
+ "c-definition": "TODO: glibc extension"
+ },
+ "memmove": {
+ "c-definition": "7.26.2.3"
+ },
+ "strcpy": {
+ "c-definition": "7.26.2.4"
+ },
+ "strncpy": {
+ "c-definition": "7.26.2.5"
+ },
+ "stpcpy": {
+ "posix-definition": "https://pubs.opengroup.org/onlinepubs/9799919799/functions/stpcpy.html"
+ },
+ "stpncpy": {
+ "posix-definition": "https://pubs.opengroup.org/onlinepubs/9799919799/functions/stpncpy.html"
+ },
+ "strdup": {
+ "c-definition": "7.26.2.6"
+ },
+ "strndup": {
+ "c-definition": "7.26.2.7"
+ },
+ "strcat": {
+ "c-definition": "7.26.3.1"
+ },
+ "strncat": {
+ "c-definition": "7.26.3.2"
+ },
+ "memcmp": {
+ "c-definition": "7.26.4.1"
+ },
+ "strcmp": {
+ "c-definition": "7.26.4.2"
+ },
+ "strcoll": {
+ "c-definition": "7.26.4.3"
+ },
+ "strncmp": {
+ "c-definition": "7.26.4.4"
+ },
+ "strxfrm": {
+ "c-definition": "7.26.4.5"
+ },
+ "memchr": {
+ "c-definition": "7.26.5.2"
+ },
+ "strchr": {
+ "c-definition": "7.26.5.3"
+ },
+ "strcspn": {
+ "c-definition": "7.26.5.4"
+ },
+ "strpbrk": {
+ "c-definition": "7.26.5.5"
+ },
+ "strrchr": {
+ "c-definition": "7.26.5.6"
+ },
+ "strspn": {
+ "c-definition": "7.26.5.7"
+ },
+ "strstr": {
+ "c-definition": "7.26.5.8"
+ },
+ "strtok": {
+ "c-definition": "7.26.5.9"
+ },
+ "strtok_r": {
+ "posix-definition": "https://pubs.opengroup.org/onlinepubs/9799919799/functions/strtok_r.html"
+ },
+ "memset": {
+ "c-definition": "7.26.6.1"
+ },
+ "memset_explicit": {
+ "c-definition": "7.26.6.2"
+ },
+ "strerror": {
+ "c-definition": "7.26.6.3"
+ },
+ "strlen": {
+ "c-definition": "7.26.6.4"
+ }
+ }
+}
diff --git a/libc/utils/docgen/strings.json b/libc/utils/docgen/strings.json
new file mode 100644
index 00000000000000..7acc0f8dddcd1e
--- /dev/null
+++ b/libc/utils/docgen/strings.json
@@ -0,0 +1,13 @@
+{
+ "functions": {
+ "bzero": {
+ "posix-definition": "removed in POSIX.1-2008"
+ },
+ "bcmp": {
+ "posix-definition": "removed in POSIX.1-2008"
+ },
+ "bcopy": {
+ "posix-definition": "removed in POSIX.1-2008"
+ }
+ }
+}
More information about the libc-commits
mailing list