[libc-commits] [libc] 284cd69 - [libc] Move the remaining public types to their own type headers.

Siva Chandra Reddy via libc-commits libc-commits at lists.llvm.org
Thu Jan 20 15:04:48 PST 2022


Author: Siva Chandra Reddy
Date: 2022-01-20T23:04:26Z
New Revision: 284cd693f1c695a4ae9c8de7e3ada645eb19d22b

URL: https://github.com/llvm/llvm-project/commit/284cd693f1c695a4ae9c8de7e3ada645eb19d22b
DIFF: https://github.com/llvm/llvm-project/commit/284cd693f1c695a4ae9c8de7e3ada645eb19d22b.diff

LOG: [libc] Move the remaining public types to their own type headers.

Reviewed By: michaelrj

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

Added: 
    libc/include/llvm-libc-types/FILE.h
    libc/include/llvm-libc-types/__bsearchcompare_t.h
    libc/include/llvm-libc-types/__call_once_func_t.h
    libc/include/llvm-libc-types/__qsortcompare_t.h
    libc/include/llvm-libc-types/__sigaction.h
    libc/include/llvm-libc-types/__sighandler_t.h
    libc/include/llvm-libc-types/cnd_t.h
    libc/include/llvm-libc-types/div_t.h
    libc/include/llvm-libc-types/fenv_t.h
    libc/include/llvm-libc-types/fexcept_t.h
    libc/include/llvm-libc-types/imaxdiv_t.h
    libc/include/llvm-libc-types/ldiv_t.h
    libc/include/llvm-libc-types/lldiv_t.h
    libc/include/llvm-libc-types/mtx_t.h
    libc/include/llvm-libc-types/once_flag.h
    libc/include/llvm-libc-types/thrd_start_t.h
    libc/include/llvm-libc-types/thrd_t.h
    libc/include/llvm-libc-types/time_t.h
    libc/include/llvm-libc-types/tm.h

Modified: 
    libc/config/linux/api.td
    libc/include/CMakeLists.txt
    libc/include/llvm-libc-types/CMakeLists.txt
    libc/include/threads.h.def

Removed: 
    libc/config/linux/threads.h.in


################################################################################
diff  --git a/libc/config/linux/api.td b/libc/config/linux/api.td
index 8201edb76682b..f882ec304f192 100644
--- a/libc/config/linux/api.td
+++ b/libc/config/linux/api.td
@@ -24,23 +24,13 @@ def SSizeT : TypeDecl<"ssize_t"> {
 
 def StructTm: TypeDecl<"struct tm"> {
   let Decl = [{
-    struct tm {
-      int tm_sec; // seconds after the minute
-      int tm_min; // minutes after the hour
-      int tm_hour; // hours since midnight
-      int tm_mday; // day of the month
-      int tm_mon; // months since January
-      int tm_year; // years since 1900
-      int tm_wday; // days since Sunday
-      int tm_yday; // days since January
-      int tm_isdst; // Daylight Saving Time flag
-    };
+    #include <llvm-libc-types/tm.h>
   }];
 }
 
 def TimeT: TypeDecl<"time_t"> {
-   let Decl = [{
-   typedef long time_t;
+  let Decl = [{
+    #include <llvm-libc-types/time_t.h>
   }];
 }
 
@@ -52,7 +42,7 @@ def OffT : TypeDecl<"off_t"> {
 
 def FILE : TypeDecl<"FILE"> {
   let Decl = [{
-    typedef struct FILE FILE;
+    #include <llvm-libc-types/FILE.h>
   }];
 }
 
@@ -114,10 +104,7 @@ def CTypeAPI : PublicAPI<"ctype.h"> {
 
 def IMaxDivT : TypeDecl<"imaxdiv_t"> {
   let Decl = [{
-    typedef struct {
-      intmax_t quot;
-      intmax_t rem;
-    } imaxdiv_t;
+    #include <llvm-libc-types/imaxdiv_t.h>
   }];
 }
 
@@ -195,24 +182,13 @@ def MathAPI : PublicAPI<"math.h"> {
 
 def FEnvT : TypeDecl<"fenv_t"> {
   let Decl = [{
-    #ifdef __aarch64__
-    typedef struct {
-      unsigned char __control_word[4];
-      unsigned char __status_word[4];
-    } fenv_t;
-    #endif
-    #ifdef __x86_64__
-    typedef struct {
-      unsigned char __x86_status[28];
-      unsigned char __mxcsr[4];
-    } fenv_t;
-    #endif
+    #include <llvm-libc-types/fenv_t.h>
   }];
 }
 
 def FExceptT : TypeDecl<"fexcept_t"> {
   let Decl = [{
-    typedef int fexcept_t;
+    #include <llvm-libc-types/fexcept_t.h>
   }];
 }
 
@@ -257,40 +233,31 @@ def StdIOAPI : PublicAPI<"stdio.h"> {
 
 def DivT : TypeDecl<"div_t"> {
   let Decl = [{
-    typedef struct {
-      int quot;
-      int rem;
-    } div_t;
+    #include <llvm-libc-types/div_t.h>
   }];
 }
 
 def LDivT : TypeDecl<"ldiv_t"> {
   let Decl = [{
-    typedef struct {
-      long quot;
-      long rem;
-    } ldiv_t;
+    #include <llvm-libc-types/ldiv_t.h>
   }];
 }
 
 def LLDivT : TypeDecl<"lldiv_t"> {
   let Decl = [{
-    typedef struct {
-      long long quot;
-      long long rem;
-    } lldiv_t;
+    #include <llvm-libc-types/lldiv_t.h>
   }];
 }
 
 def BSearchCompareTDefn : TypeDecl<"__bsearchcompare_t"> {
   let Decl = [{
-    typedef int(*__bsearchcompare_t)(const void *, const void *);
+    #include <llvm-libc-types/__bsearchcompare_t.h>
   }];
 }
 
 def QSortCompareTDefn : TypeDecl<"__qsortcompare_t"> {
   let Decl = [{
-    typedef int(*__qsortcompare_t)(const void *, const void *);
+    #include <llvm-libc-types/__qsortcompare_t.h>
   }];
 }
 
@@ -367,21 +334,13 @@ def SysMManAPI : PublicAPI<"sys/mman.h"> {
 
 def StructSigactionDefn : TypeDecl<"struct sigaction"> {
   let Decl = [{
-    struct __sigaction {
-      union {
-        void (*sa_handler)(int);
-        void (*sa_action)(int, siginfo_t *, void *);
-      };
-      sigset_t sa_mask;
-      int sa_flags;
-      void (*sa_restorer)(void);
-    };
+    #include <llvm-libc-types/__sigaction.h>
   }];
 }
 
 def SighandlerTDefn : TypeDecl<"__sighandler_t"> {
   let Decl = [{
-    typedef void(*__sighandler_t)(int);
+    #include <llvm-libc-types/__sighandler_t.h>
   }];
 }
 
@@ -394,39 +353,37 @@ def SignalAPI : PublicAPI<"signal.h"> {
 
 def OnceFlag : TypeDecl<"once_flag"> {
   let Decl = [{
-    typedef unsigned int once_flag;
+    #include <llvm-libc-types/once_flag.h>
   }];
 }
 
 def MtxT : TypeDecl<"mtx_t"> {
   let Decl = [{
-    typedef struct {
-      unsigned char __internal_data[4];
-      int __mtx_type;
-    } mtx_t;
+    #include <llvm-libc-types/mtx_t.h>
   }];
 }
 
 def CndT : TypeDecl<"cnd_t"> {
   let Decl = [{
-    typedef struct {
-      void *__qfront;
-      void *__qback;
-      struct {
-        unsigned char __w[4];
-        int __t;
-      } __qmtx;
-    } cnd_t;
+    #include <llvm-libc-types/cnd_t.h>
+  }];
+}
+
+def ThrdT : TypeDecl<"thrd_t"> {
+  let Decl = [{
+    #include <llvm-libc-types/thrd_t.h>
   }];
 }
 
 def ThreadStartT : TypeDecl<"thrd_start_t"> {
-  let Decl = "typedef int (*thrd_start_t)(void *);";
+  let Decl = [{
+    #include <llvm-libc-types/thrd_start_t.h>
+  }];
 }
 
 def CallOnceFuncT : TypeDecl<"__call_once_func_t"> {
   let Decl = [{
-    typedef void(*__call_once_func_t)(void);
+    #include <llvm-libc-types/__call_once_func_t.h>
   }];
 }
 
@@ -440,6 +397,7 @@ def ThreadsAPI : PublicAPI<"threads.h"> {
     CallOnceFuncT,
     MtxT,
     CndT,
+    ThrdT,
     ThreadStartT,
   ];
 

diff  --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index ba6b47c3d1859..0b62563f3170a 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -20,6 +20,8 @@ add_gen_header(
   GEN_HDR fenv.h
   DEPENDS
     .llvm_libc_common_h
+    .llvm-libc-types.fenv_t
+    .llvm-libc-types.fexcept_t
 )
 
 add_gen_header(
@@ -28,6 +30,7 @@ add_gen_header(
   GEN_HDR inttypes.h
   DEPENDS
     .llvm_libc_common_h
+    .llvm-libc-types.imaxdiv_t
 )
 
 add_gen_header(
@@ -54,6 +57,7 @@ add_gen_header(
   GEN_HDR string.h
   DEPENDS
     .llvm_libc_common_h
+    .llvm-libc-types.size_t
 )
 
 add_gen_header(
@@ -62,18 +66,22 @@ add_gen_header(
   GEN_HDR time.h
   DEPENDS
     .llvm_libc_common_h
+    .llvm-libc-types.time_t
+    .llvm-libc-types.tm
 )
 
 add_gen_header(
   threads
   DEF_FILE threads.h.def
   GEN_HDR threads.h
-  PARAMS
-    platform_threads=../config/${LIBC_TARGET_OS}/threads.h.in
   DEPENDS
     .llvm_libc_common_h
-  DATA_FILES
-    ../config/${LIBC_TARGET_OS}/threads.h.in
+    .llvm-libc-types.__call_once_func_t
+    .llvm-libc-types.cnd_t
+    .llvm-libc-types.mtx_t
+    .llvm-libc-types.once_flag
+    .llvm-libc-types.thrd_start_t
+    .llvm-libc-types.thrd_t
 )
 
 add_gen_header(
@@ -94,6 +102,9 @@ add_gen_header(
   GEN_HDR signal.h
   DATA_FILES
     ../config/${LIBC_TARGET_OS}/signal.h.in
+  DEPENDS
+    .llvm-libc-types.__sigaction
+    .llvm-libc-types.__sighandler_t
 )
 
 add_gen_header(
@@ -102,6 +113,8 @@ add_gen_header(
   GEN_HDR stdio.h
   DEPENDS
     .llvm_libc_common_h
+    .llvm-libc-types.FILE
+    .llvm-libc-types.size_t
 )
 
 add_gen_header(
@@ -110,6 +123,12 @@ add_gen_header(
   GEN_HDR stdlib.h
   DEPENDS
     .llvm_libc_common_h
+    .llvm-libc-types.__bsearchcompare_t
+    .llvm-libc-types.__qsortcompare_t
+    .llvm-libc-types.div_t
+    .llvm-libc-types.ldiv_t
+    .llvm-libc-types.lldiv_t
+    .llvm-libc-types.size_t
 )
 
 add_gen_header(

diff  --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index ced6a38a2de3f..73c295843e2a4 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -1,5 +1,24 @@
+add_header(__bsearchcompare_t HDR __bsearchcompare_t.h)
+add_header(__call_once_func_t HDR __call_once_func_t.h)
+add_header(__qsortcompare_t HDR __qsortcompare_t.h)
+add_header(__sigaction HDR __sigaction.h)
+add_header(__sighandler_t HDR __sighandler_t.h)
+add_header(cnd_t HDR cnd_t.h)
 add_header(double_t HDR double_t.h)
+add_header(div_t HDR div_t.h)
+add_header(ldiv_t HDR ldiv_t.h)
+add_header(lldiv_t HDR lldiv_t.h)
+add_header(FILE HDR FILE.h)
+add_header(fenv_t HDR fenv_t.h)
+add_header(fexcept_t HDR fexcept_t.h)
 add_header(float_t HDR float_t.h)
+add_header(imaxdiv_t HDR imaxdiv_t.h)
+add_header(mtx_t HDR mtx_t.h)
 add_header(off_t HDR off_t.h)
+add_header(once_flag HDR once_flag.h)
 add_header(size_t HDR size_t.h)
 add_header(ssize_t HDR ssize_t.h)
+add_header(thrd_start_t HDR thrd_start_t.h)
+add_header(thrd_t HDR thrd_t.h)
+add_header(time_t HDR time_t.h)
+add_header(tm HDR tm.h)

diff  --git a/libc/include/llvm-libc-types/FILE.h b/libc/include/llvm-libc-types/FILE.h
new file mode 100644
index 0000000000000..1c1ff97ec86a5
--- /dev/null
+++ b/libc/include/llvm-libc-types/FILE.h
@@ -0,0 +1,14 @@
+//===-- Definition of the type FILE ---------------------------------------===//
+//
+// 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_TYPES_FILE_H__
+#define __LLVM_LIBC_TYPES_FILE_H__
+
+typedef struct FILE FILE;
+
+#endif // __LLVM_LIBC_TYPES_FILE_H__

diff  --git a/libc/include/llvm-libc-types/__bsearchcompare_t.h b/libc/include/llvm-libc-types/__bsearchcompare_t.h
new file mode 100644
index 0000000000000..40ebc7f356688
--- /dev/null
+++ b/libc/include/llvm-libc-types/__bsearchcompare_t.h
@@ -0,0 +1,14 @@
+//===-- Definition of type __bsearchcompare_t -----------------------------===//
+//
+// 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_TYPES_BSEARCHCOMPARE_T_H__
+#define __LLVM_LIBC_TYPES_BSEARCHCOMPARE_T_H__
+
+typedef int (*__bsearchcompare_t)(const void *, const void *);
+
+#endif // __LLVM_LIBC_TYPES_BSEARCHCOMPARE_T_H__

diff  --git a/libc/include/llvm-libc-types/__call_once_func_t.h b/libc/include/llvm-libc-types/__call_once_func_t.h
new file mode 100644
index 0000000000000..bc8ed8331bd80
--- /dev/null
+++ b/libc/include/llvm-libc-types/__call_once_func_t.h
@@ -0,0 +1,14 @@
+//===-- Definition of __call_once_func_t type -----------------------------===//
+//
+// 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_TYPES_CALL_ONCE_FUNC_T_H__
+#define __LLVM_LIBC_TYPES_CALL_ONCE_FUNC_T_H__
+
+typedef void (*__call_once_func_t)(void);
+
+#endif // __LLVM_LIBC_TYPES_CALL_ONCE_FUNC_T_H__

diff  --git a/libc/include/llvm-libc-types/__qsortcompare_t.h b/libc/include/llvm-libc-types/__qsortcompare_t.h
new file mode 100644
index 0000000000000..82bd4cc1fcd03
--- /dev/null
+++ b/libc/include/llvm-libc-types/__qsortcompare_t.h
@@ -0,0 +1,14 @@
+//===-- Definition of type __qsortcompare_t -------------------------------===//
+//
+// 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_TYPES_QSORTCOMPARE_T_H__
+#define __LLVM_LIBC_TYPES_QSORTCOMPARE_T_H__
+
+typedef int (*__qsortcompare_t)(const void *, const void *);
+
+#endif // __LLVM_LIBC_TYPES_QSORTCOMPARE_T_H__

diff  --git a/libc/include/llvm-libc-types/__sigaction.h b/libc/include/llvm-libc-types/__sigaction.h
new file mode 100644
index 0000000000000..1c7243c0e921f
--- /dev/null
+++ b/libc/include/llvm-libc-types/__sigaction.h
@@ -0,0 +1,22 @@
+//===-- Definition of struct __sigaction ----------------------------------===//
+//
+// 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_TYPES_SIGACTION_H__
+#define __LLVM_LIBC_TYPES_SIGACTION_H__
+
+struct __sigaction {
+  union {
+    void (*sa_handler)(int);
+    void (*sa_action)(int, siginfo_t *, void *);
+  };
+  sigset_t sa_mask;
+  int sa_flags;
+  void (*sa_restorer)(void);
+};
+
+#endif // __LLVM_LIBC_TYPES_SIGACTION_H__

diff  --git a/libc/include/llvm-libc-types/__sighandler_t.h b/libc/include/llvm-libc-types/__sighandler_t.h
new file mode 100644
index 0000000000000..bd0ad98d85295
--- /dev/null
+++ b/libc/include/llvm-libc-types/__sighandler_t.h
@@ -0,0 +1,14 @@
+//===-- Definition of struct __sighandler_t -------------------------------===//
+//
+// 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_TYPES_SIGHANDLER_T_H__
+#define __LLVM_LIBC_TYPES_SIGHANDLER_T_H__
+
+typedef void (*__sighandler_t)(int);
+
+#endif // __LLVM_LIBC_TYPES_SIGHANDLER_T_H__

diff  --git a/libc/include/llvm-libc-types/cnd_t.h b/libc/include/llvm-libc-types/cnd_t.h
new file mode 100644
index 0000000000000..62f0636fc7bcf
--- /dev/null
+++ b/libc/include/llvm-libc-types/cnd_t.h
@@ -0,0 +1,21 @@
+//===-- Definition of cnd_t type ------------------------------------------===//
+//
+// 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_TYPES_CND_T_H__
+#define __LLVM_LIBC_TYPES_CND_T_H__
+
+typedef struct {
+  void *__qfront;
+  void *__qback;
+  struct {
+    unsigned char __w[4];
+    int __t;
+  } __qmtx;
+} cnd_t;
+
+#endif // __LLVM_LIBC_TYPES_CND_T_H__

diff  --git a/libc/include/llvm-libc-types/div_t.h b/libc/include/llvm-libc-types/div_t.h
new file mode 100644
index 0000000000000..e495a1c3f9dcc
--- /dev/null
+++ b/libc/include/llvm-libc-types/div_t.h
@@ -0,0 +1,17 @@
+//===-- Definition of type div_t ------------------------------------------===//
+//
+// 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_TYPES_DIV_T_H__
+#define __LLVM_LIBC_TYPES_DIV_T_H__
+
+typedef struct {
+  int quot;
+  int rem;
+} div_t;
+
+#endif // __LLVM_LIBC_TYPES_DIV_T_H__

diff  --git a/libc/include/llvm-libc-types/fenv_t.h b/libc/include/llvm-libc-types/fenv_t.h
new file mode 100644
index 0000000000000..a95e08179cceb
--- /dev/null
+++ b/libc/include/llvm-libc-types/fenv_t.h
@@ -0,0 +1,25 @@
+//===-- Definition of type fenv_t -----------------------------------------===//
+//
+// 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_TYPES_FENV_T_H__
+#define __LLVM_LIBC_TYPES_FENV_T_H__
+
+#ifdef __aarch64__
+typedef struct {
+  unsigned char __control_word[4];
+  unsigned char __status_word[4];
+} fenv_t;
+#endif
+#ifdef __x86_64__
+typedef struct {
+  unsigned char __x86_status[28];
+  unsigned char __mxcsr[4];
+} fenv_t;
+#endif
+
+#endif // __LLVM_LIBC_TYPES_FENV_T_H__

diff  --git a/libc/include/llvm-libc-types/fexcept_t.h b/libc/include/llvm-libc-types/fexcept_t.h
new file mode 100644
index 0000000000000..6e7969c1be0a8
--- /dev/null
+++ b/libc/include/llvm-libc-types/fexcept_t.h
@@ -0,0 +1,14 @@
+//===-- Definition of fexcept_t type --------------------------------------===//
+//
+// 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_TYPES_FEXCEPT_T_H__
+#define __LLVM_LIBC_TYPES_FEXCEPT_T_H__
+
+typedef int fexcept_t;
+
+#endif // __LLVM_LIBC_TYPES_FEXCEPT_T_H__

diff  --git a/libc/include/llvm-libc-types/imaxdiv_t.h b/libc/include/llvm-libc-types/imaxdiv_t.h
new file mode 100644
index 0000000000000..5062b643065a7
--- /dev/null
+++ b/libc/include/llvm-libc-types/imaxdiv_t.h
@@ -0,0 +1,17 @@
+//===-- Definition of type imaxdiv_t --------------------------------------===//
+//
+// 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_TYPES_IMAXDIV_T_H__
+#define __LLVM_LIBC_TYPES_IMAXDIV_T_H__
+
+typedef struct {
+  intmax_t quot;
+  intmax_t rem;
+} imaxdiv_t;
+
+#endif // __LLVM_LIBC_TYPES_IMAXDIV_T_H__

diff  --git a/libc/include/llvm-libc-types/ldiv_t.h b/libc/include/llvm-libc-types/ldiv_t.h
new file mode 100644
index 0000000000000..9bd8d253330a0
--- /dev/null
+++ b/libc/include/llvm-libc-types/ldiv_t.h
@@ -0,0 +1,17 @@
+//===-- Definition of type ldiv_t -----------------------------------------===//
+//
+// 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_TYPES_LDIV_T_H__
+#define __LLVM_LIBC_TYPES_LDIV_T_H__
+
+typedef struct {
+  long quot;
+  long rem;
+} ldiv_t;
+
+#endif // __LLVM_LIBC_TYPES_LDIV_T_H__

diff  --git a/libc/include/llvm-libc-types/lldiv_t.h b/libc/include/llvm-libc-types/lldiv_t.h
new file mode 100644
index 0000000000000..109304d120787
--- /dev/null
+++ b/libc/include/llvm-libc-types/lldiv_t.h
@@ -0,0 +1,17 @@
+//===-- Definition of type lldiv_t ----------------------------------------===//
+//
+// 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_TYPES_LLDIV_T_H__
+#define __LLVM_LIBC_TYPES_LLDIV_T_H__
+
+typedef struct {
+  long long quot;
+  long long rem;
+} lldiv_t;
+
+#endif // __LLVM_LIBC_TYPES_LLDIV_T_H__

diff  --git a/libc/include/llvm-libc-types/mtx_t.h b/libc/include/llvm-libc-types/mtx_t.h
new file mode 100644
index 0000000000000..42f27297bd0af
--- /dev/null
+++ b/libc/include/llvm-libc-types/mtx_t.h
@@ -0,0 +1,17 @@
+//===-- Definition of mtx_t type ------------------------------------------===//
+//
+// 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_TYPES_MTX_T_H__
+#define __LLVM_LIBC_TYPES_MTX_T_H__
+
+typedef struct {
+  unsigned char __internal_data[4];
+  int __mtx_type;
+} mtx_t;
+
+#endif // __LLVM_LIBC_TYPES_MTX_T_H__

diff  --git a/libc/include/llvm-libc-types/once_flag.h b/libc/include/llvm-libc-types/once_flag.h
new file mode 100644
index 0000000000000..4987bda38bbe4
--- /dev/null
+++ b/libc/include/llvm-libc-types/once_flag.h
@@ -0,0 +1,14 @@
+//===-- Definition of once_flag type --------------------------------------===//
+//
+// 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_TYPES_ONCE_FLAG_H__
+#define __LLVM_LIBC_TYPES_ONCE_FLAG_H__
+
+typedef unsigned int once_flag;
+
+#endif // __LLVM_LIBC_TYPES_ONCE_FLAg_H__

diff  --git a/libc/include/llvm-libc-types/thrd_start_t.h b/libc/include/llvm-libc-types/thrd_start_t.h
new file mode 100644
index 0000000000000..83fc32cbd1f87
--- /dev/null
+++ b/libc/include/llvm-libc-types/thrd_start_t.h
@@ -0,0 +1,14 @@
+//===-- Definition of thrd_start_t type -----------------------------------===//
+//
+// 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_TYPES_THRD_START_T_H__
+#define __LLVM_LIBC_TYPES_THRD_START_T_H__
+
+typedef int (*thrd_start_t)(void *);
+
+#endif // __LLVM_LIBC_TYPES_THRD_START_T_H__

diff  --git a/libc/config/linux/threads.h.in b/libc/include/llvm-libc-types/thrd_t.h
similarity index 70%
rename from libc/config/linux/threads.h.in
rename to libc/include/llvm-libc-types/thrd_t.h
index cd45ebfec9bc1..ebbf9b0a36506 100644
--- a/libc/config/linux/threads.h.in
+++ b/libc/include/llvm-libc-types/thrd_t.h
@@ -1,4 +1,4 @@
-//===-- Linux specific definitions of types from threads.h ----------------===//
+//===-- Definition of thrd_t type -----------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-%%begin()
+#ifndef __LLVM_LIBC_TYPES_THRD_T_H__
+#define __LLVM_LIBC_TYPES_THRD_T_H__
 
 typedef struct {
   unsigned char __clear_tid[4];
@@ -15,3 +16,5 @@ typedef struct {
   int __stack_size;
   int __retval;
 } thrd_t;
+
+#endif // __LLVM_LIBC_TYPES_THRD_T_H__

diff  --git a/libc/include/llvm-libc-types/time_t.h b/libc/include/llvm-libc-types/time_t.h
new file mode 100644
index 0000000000000..13c33b07c2238
--- /dev/null
+++ b/libc/include/llvm-libc-types/time_t.h
@@ -0,0 +1,14 @@
+//===-- Definition of the type time_t -------------------------------------===//
+//
+// 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_TYPES_TIME_T_H__
+#define __LLVM_LIBC_TYPES_TIME_T_H__
+
+typedef long time_t;
+
+#endif // __LLVM_LIBC_TYPES_TIME_T_H__

diff  --git a/libc/include/llvm-libc-types/tm.h b/libc/include/llvm-libc-types/tm.h
new file mode 100644
index 0000000000000..953e12e819c3a
--- /dev/null
+++ b/libc/include/llvm-libc-types/tm.h
@@ -0,0 +1,24 @@
+//===-- Definition of struct tm -------------------------------------------===//
+//
+// 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_TYPES_TM_H__
+#define __LLVM_LIBC_TYPES_TM_H__
+
+struct tm {
+  int tm_sec;   // seconds after the minute
+  int tm_min;   // minutes after the hour
+  int tm_hour;  // hours since midnight
+  int tm_mday;  // day of the month
+  int tm_mon;   // months since January
+  int tm_year;  // years since 1900
+  int tm_wday;  // days since Sunday
+  int tm_yday;  // days since January
+  int tm_isdst; // Daylight Saving Time flag
+};
+
+#endif // __LLVM_LIBC_TYPES_TM_H__

diff  --git a/libc/include/threads.h.def b/libc/include/threads.h.def
index c8a24e0979db9..93541b8d3bac4 100644
--- a/libc/include/threads.h.def
+++ b/libc/include/threads.h.def
@@ -11,8 +11,6 @@
 
 #include <__llvm-libc-common.h>
 
-%%include_file(${platform_threads})
-
 %%public_api()
 
 #endif // LLVM_LIBC_THREADS_H


        


More information about the libc-commits mailing list