[libc-commits] [libc] [libc][docs] Generate docs for signal.h & optimized is_implemented func (PR #88028)

via libc-commits libc-commits at lists.llvm.org
Mon Apr 8 11:26:43 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Xu Zhang (simonzgx)

<details>
<summary>Changes</summary>

Fixes #<!-- -->87835 

---
Full diff: https://github.com/llvm/llvm-project/pull/88028.diff


3 Files Affected:

- (added) libc/docs/signal.rst (+41) 
- (modified) libc/utils/docgen/docgen.py (+13-4) 
- (added) libc/utils/docgen/signal.json (+21) 


``````````diff
diff --git a/libc/docs/signal.rst b/libc/docs/signal.rst
new file mode 100644
index 00000000000000..a994645ce3c260
--- /dev/null
+++ b/libc/docs/signal.rst
@@ -0,0 +1,41 @@
+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..213ed7e6cc5ec8 100755
--- a/libc/utils/docgen/docgen.py
+++ b/libc/utils/docgen/docgen.py
@@ -23,12 +23,21 @@ 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")
+    )
+    source_file_name = fname + ".cpp"
+    if path.joinpath(source_file_name).exists():
+        return True
+    
+    # Attempt to search in the subfolders with 1-depth.
+    for sub_dir in path.iterdir():
+        if (sub_dir.joinpath(source_file_name)).exists():
+            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..366fb87d0a293a
--- /dev/null
+++ b/libc/utils/docgen/signal.json
@@ -0,0 +1,21 @@
+{
+  "macros": [
+    "__STDC_VERSION_FENV_H__"
+  ],
+  "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"
+    }
+  }
+}
\ No newline at end of file

``````````

</details>


https://github.com/llvm/llvm-project/pull/88028


More information about the libc-commits mailing list