[libc-commits] [libc] 7ab7e7a - [libc][docs] Generate docs for signal.h & optimized is_implemented func (#88028)
via libc-commits
libc-commits at lists.llvm.org
Thu Apr 11 08:50:03 PDT 2024
Author: Xu Zhang
Date: 2024-04-11T08:49:59-07:00
New Revision: 7ab7e7a55f3fce08ccd3cbcae94dabe99dd9e94a
URL: https://github.com/llvm/llvm-project/commit/7ab7e7a55f3fce08ccd3cbcae94dabe99dd9e94a
DIFF: https://github.com/llvm/llvm-project/commit/7ab7e7a55f3fce08ccd3cbcae94dabe99dd9e94a.diff
LOG: [libc][docs] Generate docs for signal.h & optimized is_implemented func (#88028)
Fixes #87835
This patch added the documentation for the POSIX functions according to
[n3096](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf)
Section 7.14, and gives the *docgen.py* script a more elegant *is_implemented*
function.
Added:
libc/docs/signal.rst
libc/utils/docgen/signal.json
Modified:
libc/docs/index.rst
libc/utils/docgen/docgen.py
Removed:
################################################################################
diff --git a/libc/docs/index.rst b/libc/docs/index.rst
index 8470c8d9287c2f..11d5ae197d7189 100644
--- a/libc/docs/index.rst
+++ b/libc/docs/index.rst
@@ -70,6 +70,7 @@ stages there is no ABI stability in any form.
libc_search
c23
ctype
+ signal
.. toctree::
:hidden:
diff --git a/libc/docs/signal.rst b/libc/docs/signal.rst
new file mode 100644
index 00000000000000..7903bb439cb337
--- /dev/null
+++ b/libc/docs/signal.rst
@@ -0,0 +1,43 @@
+.. include:: check.rst
+
+signal.h Functions
+==================
+
+.. list-table::
+ :widths: auto
+ :align: center
+ :header-rows: 1
+
+ * - Function
+ - Implemented
+ - Standard
+ * - kill
+ - |check|
+ -
+ * - raise
+ - |check|
+ - 7.14.2.1
+ * - sigaction
+ - |check|
+ -
+ * - sigaddset
+ - |check|
+ -
+ * - sigaltstack
+ - |check|
+ -
+ * - sigdelset
+ - |check|
+ -
+ * - sigemptyset
+ - |check|
+ -
+ * - sigfillset
+ - |check|
+ -
+ * - signal
+ - |check|
+ - 7.14.1.1
+ * - sigprocmask
+ - |check|
+ -
diff --git a/libc/utils/docgen/docgen.py b/libc/utils/docgen/docgen.py
index 7411b4506f082f..36eb409421b4f5 100755
--- a/libc/utils/docgen/docgen.py
+++ b/libc/utils/docgen/docgen.py
@@ -23,12 +23,17 @@ def load_api(hname: str) -> Dict:
# TODO: we may need to get more sophisticated for less generic implementations.
# Does libc/src/{hname minus .h suffix}/{fname}.cpp exist?
def is_implemented(hname: str, fname: str) -> bool:
- return Path(
+ path = Path(
Path(__file__).parent.parent.parent,
"src",
- hname.rstrip(".h"),
- fname + ".cpp",
- ).exists()
+ hname.rstrip(".h")
+ )
+ # Recursively search for the target source file in the subdirectories under
+ # libc/src/{hname}.
+ for _ in path.glob("**/" + fname + ".cpp"):
+ return True
+
+ return False
def print_functions(header: str, functions: Dict):
diff --git a/libc/utils/docgen/signal.json b/libc/utils/docgen/signal.json
new file mode 100644
index 00000000000000..976021a803a672
--- /dev/null
+++ b/libc/utils/docgen/signal.json
@@ -0,0 +1,29 @@
+{
+ "macros": [
+ "SIG_DFL",
+ "SIG_ERR",
+ "SIG_IGN",
+ "SIGABRT",
+ "SIGFPE",
+ "SIGILL",
+ "SIGINT",
+ "SIGSEGV",
+ "SIGTERM"
+ ],
+ "functions": {
+ "kill": null,
+ "sigaction": null,
+ "sigaddset": null,
+ "sigaltstack": null,
+ "sigdelset": null,
+ "sigemptyset": null,
+ "sigfillset": null,
+ "sigprocmask": null,
+ "signal": {
+ "defined": "7.14.1.1"
+ },
+ "raise": {
+ "defined": "7.14.2.1"
+ }
+ }
+}
More information about the libc-commits
mailing list