diff libc/spec/posix.td @ 221:79ff65ed7e25

LLVM12 Original
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 15 Jun 2021 19:15:29 +0900
parents 0572611fdcc8
children c4bab56944e8
line wrap: on
line diff
--- a/libc/spec/posix.td	Tue Jun 15 19:13:43 2021 +0900
+++ b/libc/spec/posix.td	Tue Jun 15 19:15:29 2021 +0900
@@ -1,16 +1,22 @@
 def SigSetType : NamedType<"sigset_t">;
 def SigSetPtrType : PtrType<SigSetType>;
 def ConstSigSetPtrType : ConstType<SigSetPtrType>;
-def RestrictSigSetType : RestrictedPtrType<SigSetType>;
-def ConstRestrictSigSetType : ConstType<RestrictSigSetType>;
+def RestrictedSigSetType : RestrictedPtrType<SigSetType>;
+def ConstRestrictedSigSetType : ConstType<RestrictedSigSetType>;
 
 def StructSigaction : NamedType<"struct sigaction">;
 def StructSigactionPtr : PtrType<StructSigaction>;
 def ConstStructSigactionPtr : ConstType<StructSigactionPtr>;
-def RestrictStructSigactionPtr : RestrictedPtrType<StructSigaction>;
-def ConstRestrictStructSigactionPtr : ConstType<RestrictStructSigactionPtr>;
+def RestrictedStructSigactionPtr : RestrictedPtrType<StructSigaction>;
+def ConstRestrictedStructSigactionPtr : ConstType<RestrictedStructSigactionPtr>;
 
 def POSIX : StandardSpec<"POSIX"> {
+  PtrType CharPtr = PtrType<CharType>;
+  RestrictedPtrType RestrictedCharPtr = RestrictedPtrType<CharType>;
+  RestrictedPtrType CharRestrictedDoublePtr = RestrictedPtrType<CharPtr>;
+  ConstType ConstCharPtr = ConstType<CharPtr>;
+  ConstType ConstRestrictedCharPtr = ConstType<RestrictedCharPtr>;
+
   NamedType OffTType = NamedType<"off_t">;
   NamedType SSizeTType = NamedType<"ssize_t">;
 
@@ -154,8 +160,8 @@
           "sigaction",
           RetValSpec<IntType>,
           [ArgSpec<IntType>,
-           ArgSpec<ConstRestrictStructSigactionPtr>,
-           ArgSpec<RestrictStructSigactionPtr>]
+           ArgSpec<ConstRestrictedStructSigactionPtr>,
+           ArgSpec<RestrictedStructSigactionPtr>]
         >,
         FunctionSpec<
           "sigdelset",
@@ -166,7 +172,7 @@
         FunctionSpec<
           "sigprocmask",
           RetValSpec<IntType>,
-          [ArgSpec<IntType>, ArgSpec<ConstRestrictSigSetType>, ArgSpec<RestrictSigSetType>]
+          [ArgSpec<IntType>, ArgSpec<ConstRestrictedSigSetType>, ArgSpec<RestrictedSigSetType>]
         >,
         FunctionSpec<
           "sigemptyset",
@@ -203,11 +209,52 @@
         >,
     ]
   >;
+  
+  HeaderSpec String = HeaderSpec<
+    "string.h",
+    [
+        Macro<"NULL">,
+    ],
+    [
+        SizeTType,
+    ],
+    [], // Enumerations
+    [
+        FunctionSpec<
+            "strnlen",
+             RetValSpec<SizeTType>,
+             [ArgSpec<ConstCharPtr>, ArgSpec<SizeTType>]
+        >,
+        FunctionSpec<
+            "strtok_r",
+            RetValSpec<CharPtr>,
+            [ArgSpec<RestrictedCharPtr>,
+             ArgSpec<ConstRestrictedCharPtr>,
+             ArgSpec<CharRestrictedDoublePtr>]
+        >,
+    ]
+  >;
+
+  HeaderSpec CType = HeaderSpec<
+    "ctype.h",
+    [], // Macros
+    [], // Types
+    [], // Enumerations
+    [
+        FunctionSpec<
+            "isascii",
+            RetValSpec<IntType>,
+            [ArgSpec<IntType>]
+        >,
+    ]
+  >;
 
   let Headers = [
+    CType,
     Errno,
     SysMMan,
     Signal,
     UniStd,
+    String
   ];
 }