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

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Mon Apr 8 11:55:34 PDT 2024


================
@@ -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():
----------------
nickdesaulniers wrote:

Elegant.  Last week I was wondering about this since we have some cases where the subdir is a target ISA like x86_64, aarch64, etc. (i.e. `src/math/`, and other cases we have an OS like linux, darwin, windows (i.e. `src/__support/OSUtil`).

I guess src/__support/OSUtil and src/sys are cases where we'd need to recurse deeper.  But for now, I'm happy with this addition. It makes sense to retain the TODO at the top of this function since we'll probably be revisiting this imminently.


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


More information about the libc-commits mailing list