Skip to content

Commit 7ab7e7a

Browse files
authored
[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.
1 parent ffb5bea commit 7ab7e7a

File tree

4 files changed

+82
-4
lines changed

4 files changed

+82
-4
lines changed

libc/docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ stages there is no ABI stability in any form.
7070
libc_search
7171
c23
7272
ctype
73+
signal
7374

7475
.. toctree::
7576
:hidden:

libc/docs/signal.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.. include:: check.rst
2+
3+
signal.h Functions
4+
==================
5+
6+
.. list-table::
7+
:widths: auto
8+
:align: center
9+
:header-rows: 1
10+
11+
* - Function
12+
- Implemented
13+
- Standard
14+
* - kill
15+
- |check|
16+
-
17+
* - raise
18+
- |check|
19+
- 7.14.2.1
20+
* - sigaction
21+
- |check|
22+
-
23+
* - sigaddset
24+
- |check|
25+
-
26+
* - sigaltstack
27+
- |check|
28+
-
29+
* - sigdelset
30+
- |check|
31+
-
32+
* - sigemptyset
33+
- |check|
34+
-
35+
* - sigfillset
36+
- |check|
37+
-
38+
* - signal
39+
- |check|
40+
- 7.14.1.1
41+
* - sigprocmask
42+
- |check|
43+
-

libc/utils/docgen/docgen.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@ def load_api(hname: str) -> Dict:
2323
# TODO: we may need to get more sophisticated for less generic implementations.
2424
# Does libc/src/{hname minus .h suffix}/{fname}.cpp exist?
2525
def is_implemented(hname: str, fname: str) -> bool:
26-
return Path(
26+
path = Path(
2727
Path(__file__).parent.parent.parent,
2828
"src",
29-
hname.rstrip(".h"),
30-
fname + ".cpp",
31-
).exists()
29+
hname.rstrip(".h")
30+
)
31+
# Recursively search for the target source file in the subdirectories under
32+
# libc/src/{hname}.
33+
for _ in path.glob("**/" + fname + ".cpp"):
34+
return True
35+
36+
return False
3237

3338

3439
def print_functions(header: str, functions: Dict):

libc/utils/docgen/signal.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"macros": [
3+
"SIG_DFL",
4+
"SIG_ERR",
5+
"SIG_IGN",
6+
"SIGABRT",
7+
"SIGFPE",
8+
"SIGILL",
9+
"SIGINT",
10+
"SIGSEGV",
11+
"SIGTERM"
12+
],
13+
"functions": {
14+
"kill": null,
15+
"sigaction": null,
16+
"sigaddset": null,
17+
"sigaltstack": null,
18+
"sigdelset": null,
19+
"sigemptyset": null,
20+
"sigfillset": null,
21+
"sigprocmask": null,
22+
"signal": {
23+
"defined": "7.14.1.1"
24+
},
25+
"raise": {
26+
"defined": "7.14.2.1"
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)