[libc] Add the header sys/types.h.
authorSiva Chandra Reddy <sivachandra@google.com>
Mon, 24 Oct 2022 22:18:58 +0000 (22:18 +0000)
committerSiva Chandra Reddy <sivachandra@google.com>
Tue, 25 Oct 2022 00:24:49 +0000 (00:24 +0000)
Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D136642

libc/config/linux/api.td
libc/config/linux/x86_64/headers.txt
libc/include/CMakeLists.txt
libc/include/sys/types.h.def [new file with mode: 0644]
libc/spec/posix.td

index abccc0f..dfd2b9a 100644 (file)
@@ -296,6 +296,13 @@ def SysSendfileAPI : PublicAPI<"sys/sendfile.h"> {
   let Types = ["off_t", "size_t", "ssize_t"];
 }
 
+def SysTypesAPI : PublicAPI<"sys/types.h"> {
+  let Types = ["blkcnt_t", "blksize_t", "clockid_t", "dev_t", "gid_t", "ino_t",
+               "mode_t", "nlink_t", "off_t", "pid_t", "pthread_attr_t", "pthread_key_t",
+               "pthread_mutex_t", "pthread_mutexattr_t", "pthread_once_t", "pthread_t",
+               "size_t", "ssize_t", "suseconds_t", "time_t", "uid_t"];
+}
+
 def SysUtsNameAPI : PublicAPI<"sys/utsname.h"> {
   let Types = ["struct utsname"];
 }
index a44ea88..123fc7e 100644 (file)
@@ -29,6 +29,7 @@ set(TARGET_PUBLIC_HEADERS
     libc.include.sys_stat
     libc.include.sys_syscall
     libc.include.sys_time
+    libc.include.sys_types
     libc.include.sys_utsname
     libc.include.sys_wait
 )
index cd00565..135e659 100644 (file)
@@ -348,6 +348,35 @@ add_gen_header(
 )
 
 add_gen_header(
+  sys_types
+  DEF_FILE sys/types.h.def
+  GEN_HDR sys/types.h
+  DEPENDS
+    .llvm_libc_common_h
+    .llvm-libc-types.blkcnt_t
+    .llvm-libc-types.blksize_t
+    .llvm-libc-types.clockid_t
+    .llvm-libc-types.dev_t
+    .llvm-libc-types.gid_t
+    .llvm-libc-types.ino_t
+    .llvm-libc-types.mode_t
+    .llvm-libc-types.nlink_t
+    .llvm-libc-types.off_t
+    .llvm-libc-types.pid_t
+    .llvm-libc-types.pthread_attr_t
+    .llvm-libc-types.pthread_key_t
+    .llvm-libc-types.pthread_mutex_t
+    .llvm-libc-types.pthread_mutexattr_t
+    .llvm-libc-types.pthread_once_t
+    .llvm-libc-types.pthread_t
+    .llvm-libc-types.size_t
+    .llvm-libc-types.ssize_t
+    .llvm-libc-types.suseconds_t
+    .llvm-libc-types.time_t
+    .llvm-libc-types.uid_t
+)
+
+add_gen_header(
   sys_utsname
   DEF_FILE sys/utsname.h.def
   GEN_HDR sys/utsname.h
diff --git a/libc/include/sys/types.h.def b/libc/include/sys/types.h.def
new file mode 100644 (file)
index 0000000..6894829
--- /dev/null
@@ -0,0 +1,16 @@
+//===-- Header for sys/types.h --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SYS_TYPES_H
+#define LLVM_LIBC_SYS_TYPES_H
+
+#include <__llvm-libc-common.h>
+
+%%public_api()
+
+#endif // LLVM_LIBC_SYS_TYPES_H
index 32e4113..e54b488 100644 (file)
@@ -1205,6 +1205,16 @@ def POSIX : StandardSpec<"POSIX"> {
     ]
   >;
 
+  HeaderSpec SysTypes = HeaderSpec<
+    "sys/types.h",
+    [], // Macros
+    [BlkCntT, BlkSizeT, ClockIdT, DevT, GidT, InoT, ModeTType, NLinkT, OffTType, PidT,
+     PThreadAttrTType, PThreadKeyT, PThreadMutexTType, PThreadMutexAttrTType, PThreadOnceT, PThreadTType,
+     SizeTType, SSizeTType, SuSecondsT, TimeTType, UidT],
+    [], // Enumerations
+    []  // Functions
+  >;
+
   let Headers = [
     CType,
     Dirent,
@@ -1220,6 +1230,7 @@ def POSIX : StandardSpec<"POSIX"> {
     SysResource,
     SysSelect,
     SysStat,
+    SysTypes,
     SysUtsName,
     SysWait,
     Time,