Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc] Include time.h in baremetal targets #85026

Merged
merged 1 commit into from
Mar 16, 2024

Conversation

petrhosek
Copy link
Member

@petrhosek petrhosek commented Mar 13, 2024

These types and conversion functions are used in embedded development.

Note that we cannot yet include other entrypoints such as asctime because src/time/time_utils.h unconditionally uses EOVERFLOW, which is only defined in POSIX and not in C standard. This issue is tracked by #85556.

These types and conversion functions are used in embedded development.

Note that we cannot include other entrypoints such such asctime because
it unconditionally uses `EOVERFLOW` which is only defined in POSIX and
not in C standard. This will need to be addressed first.
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 13, 2024

@llvm/pr-subscribers-libc

Author: Petr Hosek (petrhosek)

Changes

These types and conversion functions are used in embedded development.

Note that we cannot include other entrypoints such such asctime because it unconditionally uses EOVERFLOW which is only defined in POSIX and not in C standard. This will need to be addressed first.


Full diff: https://github.com/llvm/llvm-project/pull/85026.diff

5 Files Affected:

  • (modified) libc/config/baremetal/api.td (+9)
  • (modified) libc/config/baremetal/arm/entrypoints.txt (+3)
  • (modified) libc/config/baremetal/arm/headers.txt (+1)
  • (modified) libc/config/baremetal/riscv/entrypoints.txt (+3)
  • (modified) libc/config/baremetal/riscv/headers.txt (+1)
diff --git a/libc/config/baremetal/api.td b/libc/config/baremetal/api.td
index 80d0e0ba22ca51..e153c52a7b98cb 100644
--- a/libc/config/baremetal/api.td
+++ b/libc/config/baremetal/api.td
@@ -68,6 +68,15 @@ def StringAPI : PublicAPI<"string.h"> {
   let Types = ["size_t"];
 }
 
+def TimeAPI : PublicAPI<"time.h"> {
+  let Types = [
+    "clock_t",
+    "time_t",
+    "struct tm",
+    "struct timespec",
+  ];
+}
+
 def UCharAPI : PublicAPI<"uchar.h"> {
   let Types = ["mbstate_t"];
 }
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 589ec5237e98da..fa5d12412ced28 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -180,6 +180,9 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.stdlib.strtoll
     libc.src.stdlib.strtoul
     libc.src.stdlib.strtoull
+
+    # time.h entrypoints
+    libc.src.time.difftime
 )
 
 set(TARGET_LIBM_ENTRYPOINTS
diff --git a/libc/config/baremetal/arm/headers.txt b/libc/config/baremetal/arm/headers.txt
index 962981f8a2087d..3608364e45bdeb 100644
--- a/libc/config/baremetal/arm/headers.txt
+++ b/libc/config/baremetal/arm/headers.txt
@@ -13,5 +13,6 @@ set(TARGET_PUBLIC_HEADERS
     libc.include.string
     libc.include.strings
     libc.include.sys_queue
+    libc.include.time
     libc.include.uchar
 )
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 09de1b416e0e94..58624e8b250987 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -180,6 +180,9 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.stdlib.strtoll
     libc.src.stdlib.strtoul
     libc.src.stdlib.strtoull
+
+    # time.h entrypoints
+    libc.src.time.difftime
 )
 
 set(TARGET_LIBM_ENTRYPOINTS
diff --git a/libc/config/baremetal/riscv/headers.txt b/libc/config/baremetal/riscv/headers.txt
index 962981f8a2087d..3608364e45bdeb 100644
--- a/libc/config/baremetal/riscv/headers.txt
+++ b/libc/config/baremetal/riscv/headers.txt
@@ -13,5 +13,6 @@ set(TARGET_PUBLIC_HEADERS
     libc.include.string
     libc.include.strings
     libc.include.sys_queue
+    libc.include.time
     libc.include.uchar
 )

@nickdesaulniers
Copy link
Member

Note that we cannot include other entrypoints such such asctime because it unconditionally uses EOVERFLOW which is only defined in POSIX and not in C standard. This will need to be addressed first.

Please file a bug.

@petrhosek
Copy link
Member Author

Note that we cannot include other entrypoints such such asctime because it unconditionally uses EOVERFLOW which is only defined in POSIX and not in C standard. This will need to be addressed first.

Please file a bug.

Filed #85556.

@petrhosek petrhosek merged commit 8f878c5 into llvm:main Mar 16, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants