[llvm-branch-commits] [libc] 4076c30 - [libc] more fix

2024-06-13 Thread Schrodinger ZHU Yifan via llvm-branch-commits

Author: Schrodinger ZHU Yifan
Date: 2024-06-13T20:22:21-07:00
New Revision: 4076c3004f09e95d1fcd299452843f99235ff422

URL: 
https://github.com/llvm/llvm-project/commit/4076c3004f09e95d1fcd299452843f99235ff422
DIFF: 
https://github.com/llvm/llvm-project/commit/4076c3004f09e95d1fcd299452843f99235ff422.diff

LOG: [libc] more fix

Added: 


Modified: 
libc/cmake/modules/LLVMLibCTestRules.cmake
libc/test/IntegrationTest/CMakeLists.txt
libc/test/IntegrationTest/test.cpp
libc/test/UnitTest/CMakeLists.txt
libc/test/UnitTest/HermeticTestUtils.cpp

Removed: 




diff  --git a/libc/cmake/modules/LLVMLibCTestRules.cmake 
b/libc/cmake/modules/LLVMLibCTestRules.cmake
index eb6be91b55e26..c8d7c8a2b1c7c 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -686,6 +686,15 @@ function(add_libc_hermetic_test test_name)
LibcTest.hermetic
libc.test.UnitTest.ErrnoSetterMatcher
${fq_deps_list})
+  # TODO: currently the dependency chain is broken such that getauxval cannot 
properly
+  # propagate to hermetic tests. This is a temporary workaround.
+  if (LIBC_TARGET_ARCHITECTURE_IS_AARCH64)
+target_link_libraries(
+  ${fq_build_target_name}
+  PRIVATE
+libc.src.sys.auxv.getauxval
+)
+  endif()
 
   # Tests on the GPU require an external loader utility to launch the kernel.
   if(TARGET libc.utils.gpu.loader)

diff  --git a/libc/test/IntegrationTest/CMakeLists.txt 
b/libc/test/IntegrationTest/CMakeLists.txt
index 4f31f10b29f0b..4a999407d48d7 100644
--- a/libc/test/IntegrationTest/CMakeLists.txt
+++ b/libc/test/IntegrationTest/CMakeLists.txt
@@ -1,3 +1,7 @@
+set(arch_specific_deps)
+if(LIBC_TARGET_ARCHITECTURE_IS_AARCH64)
+  set(arch_specific_deps libc.src.sys.auxv.getauxval)
+endif()
 add_object_library(
   test
   SRCS
@@ -8,4 +12,5 @@ add_object_library(
 test.h
   DEPENDS
 libc.src.__support.OSUtil.osutil
+${arch_specific_deps}
 )

diff  --git a/libc/test/IntegrationTest/test.cpp 
b/libc/test/IntegrationTest/test.cpp
index 27e7f29efa0f1..a8b2f2911fd8e 100644
--- a/libc/test/IntegrationTest/test.cpp
+++ b/libc/test/IntegrationTest/test.cpp
@@ -6,6 +6,8 @@
 //
 
//===--===//
 
+#include "src/__support/common.h"
+#include "src/sys/auxv/getauxval.h"
 #include 
 #include 
 
@@ -80,9 +82,11 @@ void *realloc(void *ptr, size_t s) {
 // __dso_handle when -nostdlib is used.
 void *__dso_handle = nullptr;
 
-// On some platform (aarch64 fedora tested) full build integration test
-// objects need to link against libgcc, which may expect a __getauxval
-// function. For now, it is fine to provide a weak definition that always
-// returns false.
-[[gnu::weak]] bool __getauxval(uint64_t, uint64_t *) { return false; }
+#ifdef LIBC_TARGET_ARCH_IS_AARCH64
+// Due to historical reasons, libgcc on aarch64 may expect __getauxval to be
+// defined. See also 
https://gcc.gnu.org/pipermail/gcc-cvs/2020-June/300635.html
+unsigned long __getauxval(unsigned long id) {
+  return LIBC_NAMESPACE::getauxval(id);
+}
+#endif
 } // extern "C"

diff  --git a/libc/test/UnitTest/CMakeLists.txt 
b/libc/test/UnitTest/CMakeLists.txt
index 302af3044ca3d..4adc2f5c725f7 100644
--- a/libc/test/UnitTest/CMakeLists.txt
+++ b/libc/test/UnitTest/CMakeLists.txt
@@ -41,7 +41,7 @@ function(add_unittest_framework_library name)
   target_compile_options(${name}.hermetic PRIVATE ${compile_options})
 
   if(TEST_LIB_DEPENDS)
-foreach(dep IN LISTS ${TEST_LIB_DEPENDS})
+foreach(dep IN ITEMS ${TEST_LIB_DEPENDS})
   if(TARGET ${dep}.unit)
 add_dependencies(${name}.unit ${dep}.unit)
   else()

diff  --git a/libc/test/UnitTest/HermeticTestUtils.cpp 
b/libc/test/UnitTest/HermeticTestUtils.cpp
index 349c182ff2379..6e815e6c8aab0 100644
--- a/libc/test/UnitTest/HermeticTestUtils.cpp
+++ b/libc/test/UnitTest/HermeticTestUtils.cpp
@@ -6,6 +6,8 @@
 //
 
//===--===//
 
+#include "src/__support/common.h"
+#include "src/sys/auxv/getauxval.h"
 #include 
 #include 
 
@@ -19,6 +21,12 @@ void *memmove(void *dst, const void *src, size_t count);
 void *memset(void *ptr, int value, size_t count);
 int atexit(void (*func)(void));
 
+// TODO: It seems that some old test frameworks does not use
+// add_libc_hermetic_test properly. Such that they won't get correct linkage
+// against the object containing this function. We create a dummy function that
+// always returns 0 to indicate a failure.
+[[gnu::weak]] unsigned long getauxval(unsigned long id) { return 0; }
+
 } // namespace LIBC_NAMESPACE
 
 namespace {
@@ -102,6 +110,14 @@ void __cxa_pure_virtual() {
 // __dso_handle when -nostdlib is used.
 void *__dso_handle = nullptr;
 
+#ifdef LIBC_TARGET_ARCH_IS_AARCH64
+// Due to historical reasons, 

[llvm-branch-commits] [libc] 52ea296 - [libc] fix config syntax error

2024-07-20 Thread Schrodinger ZHU Yifan via llvm-branch-commits

Author: Schrodinger ZHU Yifan
Date: 2024-07-20T08:09:24-07:00
New Revision: 52ea2963b4ae0de27816e7f1b3be45f4f021999a

URL: 
https://github.com/llvm/llvm-project/commit/52ea2963b4ae0de27816e7f1b3be45f4f021999a
DIFF: 
https://github.com/llvm/llvm-project/commit/52ea2963b4ae0de27816e7f1b3be45f4f021999a.diff

LOG: [libc] fix config syntax error

Added: 


Modified: 
libc/config/config.json

Removed: 




diff  --git a/libc/config/config.json b/libc/config/config.json
index 0fc88e2b8dbd5..92e1c956652ad 100644
--- a/libc/config/config.json
+++ b/libc/config/config.json
@@ -75,7 +75,7 @@
 "LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE": {
   "value": 1073741824,
   "doc": "Default size for the constinit freelist buffer used for the 
freelist malloc implementation (default 1o 1GB)."
-},
+}
   },
   "unistd": {
 "LIBC_CONF_ENABLE_TID_CACHE": {
@@ -99,4 +99,4 @@
   "doc": "Configures sorting algorithm for qsort and qsort_r. Values 
accepted are LIBC_QSORT_QUICK_SORT, LIBC_QSORT_HEAP_SORT."
 }
   }
-}
+}
\ No newline at end of file



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] 4502f83 - [libc] fix config syntax error

2024-07-20 Thread Schrodinger ZHU Yifan via llvm-branch-commits

Author: Schrodinger ZHU Yifan
Date: 2024-07-20T08:11:31-07:00
New Revision: 4502f83ed026030e6886cdd3aac18e2f392d4877

URL: 
https://github.com/llvm/llvm-project/commit/4502f83ed026030e6886cdd3aac18e2f392d4877
DIFF: 
https://github.com/llvm/llvm-project/commit/4502f83ed026030e6886cdd3aac18e2f392d4877.diff

LOG: [libc] fix config syntax error

Added: 


Modified: 
libc/config/config.json

Removed: 




diff  --git a/libc/config/config.json b/libc/config/config.json
index 0fc88e2b8dbd5..2005f4297bfc1 100644
--- a/libc/config/config.json
+++ b/libc/config/config.json
@@ -75,7 +75,7 @@
 "LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE": {
   "value": 1073741824,
   "doc": "Default size for the constinit freelist buffer used for the 
freelist malloc implementation (default 1o 1GB)."
-},
+}
   },
   "unistd": {
 "LIBC_CONF_ENABLE_TID_CACHE": {



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] Use UMAXV.4S to reduce bcmp result. (PR #99260)

2024-08-02 Thread Schrodinger ZHU Yifan via llvm-branch-commits

SchrodingerZhu wrote:

Hi, 

Thank you for the patch. Unfortunately, I think the proposed change is causing 
failures in tests:

```
Ran 5 tests.  PASS: 5  FAIL: 0
[4171/5229] Running unit test libc.test.src.stdio.snprintf_test.__unit__
FAILED: 
libc/test/src/stdio/CMakeFiles/libc.test.src.stdio.snprintf_test.__unit__ 
/home/schrodinger/development/llvm-project/build/libc/test/src/stdio/CMakeFiles/libc.test.src.stdio.snprintf_test.__unit__
 
cd /home/schrodinger/development/llvm-project/build/libc/test/src/stdio && 
/home/schrodinger/development/llvm-project/build/libc/test/src/stdio/libc.test.src.stdio.snprintf_test.__unit__.__build__
[==] Running 2 tests from 1 test suite.
[ RUN  ] LlvmLibcSNPrintfTest.CutOff
/home/schrodinger/development/llvm-project/libc/test/src/stdio/snprintf_test.cpp:23:
 FAILURE
  Expected: buff
  Which is: 
To be equal to: "A simple string"
  Which is: A simple string
[  FAILED  ] LlvmLibcSNPrintfTest.CutOff
[ RUN  ] LlvmLibcSNPrintfTest.NoCutOff
/home/schrodinger/development/llvm-project/libc/test/src/stdio/snprintf_test.cpp:53:
 FAILURE
  Expected: buff
  Which is: 
To be equal to: "A simple string with no conversions."
  Which is: A simple string with no conversions.
[  FAILED  ] LlvmLibcSNPrintfTest.NoCutOff
Ran 2 tests.  PASS: 0  FAIL: 2
[4172/5229] Running unit test libc.test.src.stdio.vsnprintf_test.__unit__
FAILED: 
libc/test/src/stdio/CMakeFiles/libc.test.src.stdio.vsnprintf_test.__unit__ 
/home/schrodinger/development/llvm-project/build/libc/test/src/stdio/CMakeFiles/libc.test.src.stdio.vsnprintf_test.__unit__
 
cd /home/schrodinger/development/llvm-project/build/libc/test/src/stdio && 
/home/schrodinger/development/llvm-project/build/libc/test/src/stdio/libc.test.src.stdio.vsnprintf_test.__unit__.__build__
[==] Running 2 tests from 1 test suite.
[ RUN  ] LlvmLibcVSNPrintfTest.CutOff
/home/schrodinger/development/llvm-project/libc/test/src/stdio/vsnprintf_test.cpp:35:
 FAILURE
  Expected: buff
  Which is: 
To be equal to: "A simple string"
  Which is: A simple string
[  FAILED  ] LlvmLibcVSNPrintfTest.CutOff
[ RUN  ] LlvmLibcVSNPrintfTest.NoCutOff
/home/schrodinger/development/llvm-project/libc/test/src/stdio/vsnprintf_test.cpp:64:
 FAILURE
  Expected: buff
  Which is: 
To be equal to: "A simple string with no conversions."
  Which is: A simple string with no conversions.
[  FAILED  ] LlvmLibcVSNPrintfTest.NoCutOff
Ran 2 tests.  PASS: 0  FAIL: 2
[4173/5229] Running unit test libc.test.src.stdio.fprintf_test.__unit__
FAILED: 
libc/test/src/stdio/CMakeFiles/libc.test.src.stdio.fprintf_test.__unit__ 
/home/schrodinger/development/llvm-project/build/libc/test/src/stdio/CMakeFiles/libc.test.src.stdio.fprintf_test.__unit__
 
cd /home/schrodinger/development/llvm-project/build/libc/test/src/stdio && 
/home/schrodinger/development/llvm-project/build/libc/test/src/stdio/libc.test.src.stdio.fprintf_test.__unit__.__build__
[==] Running 1 test from 1 test suite.
[ RUN  ] LlvmLibcFPrintfTest.WriteToFile
/home/schrodinger/development/llvm-project/libc/test/src/stdio/fprintf_test.cpp:65:
 FAILURE
  Expected: printf_test::fread(data, 1, sizeof(simple) - 1, file)
  Which is: 0
To be equal to: sizeof(simple) - 1
  Which is: 37
[  FAILED  ] LlvmLibcFPrintfTest.WriteToFile
Ran 1 tests.  PASS: 0  FAIL: 1
[4184/5229] Linking CXX executable 
libc/test/src/stdio/libc.test.src.stdio.remove_test.__hermetic__.__build__
ninja: build stopped: subcommand failed.
```

https://github.com/llvm/llvm-project/pull/99260
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] Use UMAXV.4S to reduce bcmp result. (PR #99260)

2024-08-02 Thread Schrodinger ZHU Yifan via llvm-branch-commits

https://github.com/SchrodingerZhu requested changes to this pull request.

See previous comment

https://github.com/llvm/llvm-project/pull/99260
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] c8d3f1c - fix

2024-05-09 Thread Schrodinger ZHU Yifan via llvm-branch-commits

Author: Schrodinger ZHU Yifan
Date: 2024-05-09T21:20:40-04:00
New Revision: c8d3f1c80b8b1d2caf53174539c0f17f24a80bef

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

LOG: fix

Added: 
libc/src/__support/time/linux/clock_gettime.h

Modified: 
libc/src/__support/time/CMakeLists.txt
libc/src/__support/time/clock_gettime.h
libc/src/__support/time/linux/CMakeLists.txt
libc/src/__support/time/linux/clock_gettime.cpp

Removed: 




diff  --git a/libc/src/__support/time/CMakeLists.txt 
b/libc/src/__support/time/CMakeLists.txt
index 36ce4f9dadb2c..e934ef7b9224a 100644
--- a/libc/src/__support/time/CMakeLists.txt
+++ b/libc/src/__support/time/CMakeLists.txt
@@ -2,9 +2,10 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
   add_subdirectory(${LIBC_TARGET_OS})
 endif()
 
-add_object_library(
+add_header_library(
   clock_gettime
-  ALIAS
+  HDRS
+clock_gettime.h
   DEPENDS
 .${LIBC_TARGET_OS}.clock_gettime
 )

diff  --git a/libc/src/__support/time/clock_gettime.h 
b/libc/src/__support/time/clock_gettime.h
index 0655ccdc0028b..ef99339a4805e 100644
--- a/libc/src/__support/time/clock_gettime.h
+++ b/libc/src/__support/time/clock_gettime.h
@@ -8,16 +8,11 @@
 
 #ifndef LLVM_LIBC_SRC___SUPPORT_TIME_CLOCK_GETTIME_H
 #define LLVM_LIBC_SRC___SUPPORT_TIME_CLOCK_GETTIME_H
-#include "hdr/types/clockid_t.h"
-#include "hdr/types/struct_timespec.h"
-#include "src/__support/common.h"
 
-#include "src/__support/error_or.h"
-
-namespace LIBC_NAMESPACE {
-namespace internal {
-ErrorOr clock_gettime(clockid_t clockid, timespec *ts);
-}
-} // namespace LIBC_NAMESPACE
+#ifdef __linux__
+#include "src/__support/time/linux/clock_gettime.h"
+#else
+#error "clock_gettime is not supported on this platform"
+#endif
 
 #endif // LLVM_LIBC_SRC___SUPPORT_TIME_CLOCK_GETTIME_H

diff  --git a/libc/src/__support/time/linux/CMakeLists.txt 
b/libc/src/__support/time/linux/CMakeLists.txt
index 034fa317ff6df..f04d550555e19 100644
--- a/libc/src/__support/time/linux/CMakeLists.txt
+++ b/libc/src/__support/time/linux/CMakeLists.txt
@@ -1,7 +1,7 @@
 add_object_library(
   clock_gettime
   HDRS
-../clock_gettime.h
+clock_gettime.h
   SRCS
 clock_gettime.cpp
   DEPENDS

diff  --git a/libc/src/__support/time/linux/clock_gettime.cpp 
b/libc/src/__support/time/linux/clock_gettime.cpp
index 6a131df9ba593..7f266b282a391 100644
--- a/libc/src/__support/time/linux/clock_gettime.cpp
+++ b/libc/src/__support/time/linux/clock_gettime.cpp
@@ -6,9 +6,7 @@
 //
 
//===--===//
 
-#ifndef LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
-#define LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
-#include "src/__support/time/clock_gettime.h"
+#include "src/__support/time/linux/clock_gettime.h"
 #include "src/__support/OSUtil/syscall.h"
 #include 
 namespace LIBC_NAMESPACE {
@@ -35,5 +33,3 @@ ErrorOr clock_gettime(clockid_t clockid, timespec *ts) {
 
 } // namespace internal
 } // namespace LIBC_NAMESPACE
-
-#endif // LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H

diff  --git a/libc/src/__support/time/linux/clock_gettime.h 
b/libc/src/__support/time/linux/clock_gettime.h
new file mode 100644
index 0..b1572726f6301
--- /dev/null
+++ b/libc/src/__support/time/linux/clock_gettime.h
@@ -0,0 +1,23 @@
+//===--- clock_gettime linux implementation -*- C++ 
-*-===//
+//
+// 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_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
+#define LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
+#include "hdr/types/clockid_t.h"
+#include "hdr/types/struct_timespec.h"
+#include "src/__support/common.h"
+
+#include "src/__support/error_or.h"
+
+namespace LIBC_NAMESPACE {
+namespace internal {
+ErrorOr clock_gettime(clockid_t clockid, timespec *ts);
+}
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] 43d2554 - fix

2024-05-09 Thread Schrodinger ZHU Yifan via llvm-branch-commits

Author: Schrodinger ZHU Yifan
Date: 2024-05-09T21:40:00-04:00
New Revision: 43d25545abc2a5feef7b7d7ec8918059042ab3ba

URL: 
https://github.com/llvm/llvm-project/commit/43d25545abc2a5feef7b7d7ec8918059042ab3ba
DIFF: 
https://github.com/llvm/llvm-project/commit/43d25545abc2a5feef7b7d7ec8918059042ab3ba.diff

LOG: fix

Added: 


Modified: 
libc/src/time/gpu/CMakeLists.txt
libc/src/time/gpu/clock.cpp
libc/src/time/gpu/time_utils.h

Removed: 




diff  --git a/libc/src/time/gpu/CMakeLists.txt 
b/libc/src/time/gpu/CMakeLists.txt
index bb79d92399b37..beaf3427504a5 100644
--- a/libc/src/time/gpu/CMakeLists.txt
+++ b/libc/src/time/gpu/CMakeLists.txt
@@ -4,6 +4,8 @@ add_object_library(
 time_utils.cpp
   HDRS
 time_utils.h
+  DEPENDS
+libc.hdr.types.clock_t
 )
 
 add_entrypoint_object(

diff  --git a/libc/src/time/gpu/clock.cpp b/libc/src/time/gpu/clock.cpp
index 86cc97e2a3bfb..8ddfc27975bba 100644
--- a/libc/src/time/gpu/clock.cpp
+++ b/libc/src/time/gpu/clock.cpp
@@ -6,9 +6,8 @@
 //
 
//===--===//
 
-#include "time_utils.h"
-
 #include "src/time/clock.h"
+#include "src/time/gpu/time_utils.h"
 
 namespace LIBC_NAMESPACE {
 

diff  --git a/libc/src/time/gpu/time_utils.h b/libc/src/time/gpu/time_utils.h
index 8a9a5f0f65b89..3f1fd11c1791c 100644
--- a/libc/src/time/gpu/time_utils.h
+++ b/libc/src/time/gpu/time_utils.h
@@ -9,8 +9,9 @@
 #ifndef LLVM_LIBC_SRC_TIME_GPU_TIME_UTILS_H
 #define LLVM_LIBC_SRC_TIME_GPU_TIME_UTILS_H
 
+#include "hdr/time_macros.h"
+#include "hdr/types/clock_t.h"
 #include "src/__support/GPU/utils.h"
-
 namespace LIBC_NAMESPACE {
 
 #if defined(LIBC_TARGET_ARCH_IS_AMDGPU)



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] b331275 - one more fix

2024-05-09 Thread Schrodinger ZHU Yifan via llvm-branch-commits

Author: Schrodinger ZHU Yifan
Date: 2024-05-09T21:41:58-04:00
New Revision: b331275547c807418cdf07a8950e6dc31bff530d

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

LOG: one more fix

Added: 


Modified: 
libc/src/time/gpu/CMakeLists.txt

Removed: 




diff  --git a/libc/src/time/gpu/CMakeLists.txt 
b/libc/src/time/gpu/CMakeLists.txt
index beaf3427504a5..088271d881911 100644
--- a/libc/src/time/gpu/CMakeLists.txt
+++ b/libc/src/time/gpu/CMakeLists.txt
@@ -6,6 +6,7 @@ add_object_library(
 time_utils.h
   DEPENDS
 libc.hdr.types.clock_t
+libc.hdr.time_macros
 )
 
 add_entrypoint_object(



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] ad34b79 - fix

2024-05-09 Thread Schrodinger ZHU Yifan via llvm-branch-commits

Author: Schrodinger ZHU Yifan
Date: 2024-05-09T21:42:30-04:00
New Revision: ad34b7954b7e1ca82660108709c793b251785728

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

LOG: fix

Added: 
libc/src/__support/time/linux/clock_gettime.h

Modified: 
libc/src/__support/time/CMakeLists.txt
libc/src/__support/time/clock_gettime.h
libc/src/__support/time/linux/CMakeLists.txt
libc/src/__support/time/linux/clock_gettime.cpp
libc/src/time/gpu/CMakeLists.txt
libc/src/time/gpu/clock.cpp
libc/src/time/gpu/time_utils.h

Removed: 




diff  --git a/libc/src/__support/time/CMakeLists.txt 
b/libc/src/__support/time/CMakeLists.txt
index 36ce4f9dadb2c..e934ef7b9224a 100644
--- a/libc/src/__support/time/CMakeLists.txt
+++ b/libc/src/__support/time/CMakeLists.txt
@@ -2,9 +2,10 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
   add_subdirectory(${LIBC_TARGET_OS})
 endif()
 
-add_object_library(
+add_header_library(
   clock_gettime
-  ALIAS
+  HDRS
+clock_gettime.h
   DEPENDS
 .${LIBC_TARGET_OS}.clock_gettime
 )

diff  --git a/libc/src/__support/time/clock_gettime.h 
b/libc/src/__support/time/clock_gettime.h
index 0655ccdc0028b..ef99339a4805e 100644
--- a/libc/src/__support/time/clock_gettime.h
+++ b/libc/src/__support/time/clock_gettime.h
@@ -8,16 +8,11 @@
 
 #ifndef LLVM_LIBC_SRC___SUPPORT_TIME_CLOCK_GETTIME_H
 #define LLVM_LIBC_SRC___SUPPORT_TIME_CLOCK_GETTIME_H
-#include "hdr/types/clockid_t.h"
-#include "hdr/types/struct_timespec.h"
-#include "src/__support/common.h"
 
-#include "src/__support/error_or.h"
-
-namespace LIBC_NAMESPACE {
-namespace internal {
-ErrorOr clock_gettime(clockid_t clockid, timespec *ts);
-}
-} // namespace LIBC_NAMESPACE
+#ifdef __linux__
+#include "src/__support/time/linux/clock_gettime.h"
+#else
+#error "clock_gettime is not supported on this platform"
+#endif
 
 #endif // LLVM_LIBC_SRC___SUPPORT_TIME_CLOCK_GETTIME_H

diff  --git a/libc/src/__support/time/linux/CMakeLists.txt 
b/libc/src/__support/time/linux/CMakeLists.txt
index 034fa317ff6df..f04d550555e19 100644
--- a/libc/src/__support/time/linux/CMakeLists.txt
+++ b/libc/src/__support/time/linux/CMakeLists.txt
@@ -1,7 +1,7 @@
 add_object_library(
   clock_gettime
   HDRS
-../clock_gettime.h
+clock_gettime.h
   SRCS
 clock_gettime.cpp
   DEPENDS

diff  --git a/libc/src/__support/time/linux/clock_gettime.cpp 
b/libc/src/__support/time/linux/clock_gettime.cpp
index 6a131df9ba593..7f266b282a391 100644
--- a/libc/src/__support/time/linux/clock_gettime.cpp
+++ b/libc/src/__support/time/linux/clock_gettime.cpp
@@ -6,9 +6,7 @@
 //
 
//===--===//
 
-#ifndef LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
-#define LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
-#include "src/__support/time/clock_gettime.h"
+#include "src/__support/time/linux/clock_gettime.h"
 #include "src/__support/OSUtil/syscall.h"
 #include 
 namespace LIBC_NAMESPACE {
@@ -35,5 +33,3 @@ ErrorOr clock_gettime(clockid_t clockid, timespec *ts) {
 
 } // namespace internal
 } // namespace LIBC_NAMESPACE
-
-#endif // LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H

diff  --git a/libc/src/__support/time/linux/clock_gettime.h 
b/libc/src/__support/time/linux/clock_gettime.h
new file mode 100644
index 0..b1572726f6301
--- /dev/null
+++ b/libc/src/__support/time/linux/clock_gettime.h
@@ -0,0 +1,23 @@
+//===--- clock_gettime linux implementation -*- C++ 
-*-===//
+//
+// 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_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
+#define LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
+#include "hdr/types/clockid_t.h"
+#include "hdr/types/struct_timespec.h"
+#include "src/__support/common.h"
+
+#include "src/__support/error_or.h"
+
+namespace LIBC_NAMESPACE {
+namespace internal {
+ErrorOr clock_gettime(clockid_t clockid, timespec *ts);
+}
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H

diff  --git a/libc/src/time/gpu/CMakeLists.txt 
b/libc/src/time/gpu/CMakeLists.txt
index bb79d92399b37..088271d881911 100644
--- a/libc/src/time/gpu/CMakeLists.txt
+++ b/libc/src/time/gpu/CMakeLists.txt
@@ -4,6 +4,9 @@ add_object_library(
 time_utils.cpp
   HDRS
 time_utils.h
+  DEPENDS
+libc.hdr.types.clock_t
+libc.hdr.time_macros
 )
 
 add_entrypoint_object(

diff  --git a/libc/src/time/gpu/clock.cpp b/libc/src/time/gpu/clock.cpp
index 86cc97e2a3bfb..8ddfc27975bba 100644

[llvm-branch-commits] [libc] f22c705 - address CR

2024-05-10 Thread Schrodinger ZHU Yifan via llvm-branch-commits

Author: Schrodinger ZHU Yifan
Date: 2024-05-10T14:00:06-04:00
New Revision: f22c705484a0c4af5810803ee62b47beb44dc73c

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

LOG: address CR

Added: 


Modified: 
libc/src/__support/time/CMakeLists.txt
libc/src/time/linux/CMakeLists.txt
libc/src/time/linux/clock.cpp
libc/src/time/linux/clock_gettime.cpp
libc/src/time/linux/gettimeofday.cpp
libc/src/time/linux/time.cpp

Removed: 
libc/src/__support/time/clock_gettime.h



diff  --git a/libc/src/__support/time/CMakeLists.txt 
b/libc/src/__support/time/CMakeLists.txt
index e934ef7b9224a..89ddffb099388 100644
--- a/libc/src/__support/time/CMakeLists.txt
+++ b/libc/src/__support/time/CMakeLists.txt
@@ -2,14 +2,6 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
   add_subdirectory(${LIBC_TARGET_OS})
 endif()
 
-add_header_library(
-  clock_gettime
-  HDRS
-clock_gettime.h
-  DEPENDS
-.${LIBC_TARGET_OS}.clock_gettime
-)
-
 add_header_library(
   units
   HDRS

diff  --git a/libc/src/__support/time/clock_gettime.h 
b/libc/src/__support/time/clock_gettime.h
deleted file mode 100644
index ef99339a4805e..0
--- a/libc/src/__support/time/clock_gettime.h
+++ /dev/null
@@ -1,18 +0,0 @@
-//===--- clock_gettime internal implementation --*- C++ 
-*-===//
-//
-// 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_SRC___SUPPORT_TIME_CLOCK_GETTIME_H
-#define LLVM_LIBC_SRC___SUPPORT_TIME_CLOCK_GETTIME_H
-
-#ifdef __linux__
-#include "src/__support/time/linux/clock_gettime.h"
-#else
-#error "clock_gettime is not supported on this platform"
-#endif
-
-#endif // LLVM_LIBC_SRC___SUPPORT_TIME_CLOCK_GETTIME_H

diff  --git a/libc/src/time/linux/CMakeLists.txt 
b/libc/src/time/linux/CMakeLists.txt
index 8a0e6b04b66e6..c15fb44ad5d12 100644
--- a/libc/src/time/linux/CMakeLists.txt
+++ b/libc/src/time/linux/CMakeLists.txt
@@ -7,7 +7,7 @@ add_entrypoint_object(
   DEPENDS
 libc.hdr.time_macros
 libc.hdr.types.time_t
-libc.src.__support.time.clock_gettime
+libc.src.__support.time.linux.clock_gettime
 libc.src.errno.errno
 )
 
@@ -21,7 +21,7 @@ add_entrypoint_object(
 libc.hdr.time_macros
 libc.hdr.types.clock_t
 libc.src.__support.time.units
-libc.src.__support.time.clock_gettime
+libc.src.__support.time.linux.clock_gettime
 libc.src.__support.CPP.limits
 libc.src.errno.errno
 )
@@ -49,7 +49,7 @@ add_entrypoint_object(
   DEPENDS
 libc.hdr.types.clockid_t
 libc.hdr.types.struct_timespec
-libc.src.__support.time.clock_gettime
+libc.src.__support.time.linux.clock_gettime
 libc.src.errno.errno
 )
 
@@ -62,7 +62,7 @@ add_entrypoint_object(
   DEPENDS
 libc.hdr.time_macros
 libc.hdr.types.suseconds_t
-libc.src.__support.time.clock_gettime
+libc.src.__support.time.linux.clock_gettime
 libc.src.__support.time.units
 libc.src.errno.errno
 )

diff  --git a/libc/src/time/linux/clock.cpp b/libc/src/time/linux/clock.cpp
index fc48e2792747d..2c1eee8e5d60a 100644
--- a/libc/src/time/linux/clock.cpp
+++ b/libc/src/time/linux/clock.cpp
@@ -10,7 +10,7 @@
 #include "hdr/time_macros.h"
 #include "src/__support/CPP/limits.h"
 #include "src/__support/common.h"
-#include "src/__support/time/clock_gettime.h"
+#include "src/__support/time/linux/clock_gettime.h"
 #include "src/__support/time/units.h"
 #include "src/errno/libc_errno.h"
 

diff  --git a/libc/src/time/linux/clock_gettime.cpp 
b/libc/src/time/linux/clock_gettime.cpp
index 920363e85e06c..d7b8cfd245bc4 100644
--- a/libc/src/time/linux/clock_gettime.cpp
+++ b/libc/src/time/linux/clock_gettime.cpp
@@ -8,7 +8,7 @@
 
 #include "src/time/clock_gettime.h"
 #include "src/__support/common.h"
-#include "src/__support/time/clock_gettime.h"
+#include "src/__support/time/linux/clock_gettime.h"
 #include "src/errno/libc_errno.h"
 
 namespace LIBC_NAMESPACE {

diff  --git a/libc/src/time/linux/gettimeofday.cpp 
b/libc/src/time/linux/gettimeofday.cpp
index c7bcd45e01fa9..f868f5ff4d4b3 100644
--- a/libc/src/time/linux/gettimeofday.cpp
+++ b/libc/src/time/linux/gettimeofday.cpp
@@ -10,7 +10,7 @@
 #include "hdr/time_macros.h"
 #include "hdr/types/suseconds_t.h"
 #include "src/__support/common.h"
-#include "src/__support/time/clock_gettime.h"
+#include "src/__support/time/linux/clock_gettime.h"
 #include "src/__support/time/units.h"
 #include "src/errno/libc_errno.h"
 

diff  --git a/libc/src/time/linux/time.cpp b/libc/src/time/linux/time.cpp
index 93d5d73627642..32f531efb6d15 100644
--- a/libc/

[llvm-branch-commits] [libc] [libc][math][c23] Add sqrtf16 C23 math function (PR #106102)

2024-09-17 Thread Schrodinger ZHU Yifan via llvm-branch-commits

SchrodingerZhu wrote:

merge based on previous approval

https://github.com/llvm/llvm-project/pull/106102
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] [libc][math][c23] Add sqrtf16 C23 math function (PR #106102)

2024-09-17 Thread Schrodinger ZHU Yifan via llvm-branch-commits

https://github.com/SchrodingerZhu closed 
https://github.com/llvm/llvm-project/pull/106102
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] [libc][math][c23] Add log10f16 C23 math function (PR #106091)

2024-09-17 Thread Schrodinger ZHU Yifan via llvm-branch-commits

https://github.com/SchrodingerZhu updated 
https://github.com/llvm/llvm-project/pull/106091

>From 57972717618c3d4ccc836c81fdbf3a66c6da53fa Mon Sep 17 00:00:00 2001
From: OverMighty 
Date: Mon, 26 Aug 2024 17:23:01 +0200
Subject: [PATCH 1/2] [libc][math][c23] Add log10f16 C23 math function

Part of #95250.
---
 libc/config/gpu/entrypoints.txt|   1 +
 libc/config/linux/x86_64/entrypoints.txt   |   1 +
 libc/docs/math/index.rst   |   2 +-
 libc/spec/stdc.td  |   1 +
 libc/src/math/CMakeLists.txt   |   1 +
 libc/src/math/generic/CMakeLists.txt   |  21 +++
 libc/src/math/generic/expxf16.h|  14 ++
 libc/src/math/generic/log10f16.cpp | 163 +
 libc/src/math/log10f16.h   |  21 +++
 libc/test/src/math/CMakeLists.txt  |  11 ++
 libc/test/src/math/log10f16_test.cpp   |  40 +
 libc/test/src/math/smoke/CMakeLists.txt|  12 ++
 libc/test/src/math/smoke/log10f16_test.cpp |  47 ++
 13 files changed, 334 insertions(+), 1 deletion(-)
 create mode 100644 libc/src/math/generic/log10f16.cpp
 create mode 100644 libc/src/math/log10f16.h
 create mode 100644 libc/test/src/math/log10f16_test.cpp
 create mode 100644 libc/test/src/math/smoke/log10f16_test.cpp

diff --git a/libc/config/gpu/entrypoints.txt b/libc/config/gpu/entrypoints.txt
index 279e397287d8e3..7faad9fbb8a9d1 100644
--- a/libc/config/gpu/entrypoints.txt
+++ b/libc/config/gpu/entrypoints.txt
@@ -531,6 +531,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llogbf16
 libc.src.math.llrintf16
 libc.src.math.llroundf16
+libc.src.math.log10f16
 libc.src.math.log2f16
 libc.src.math.logbf16
 libc.src.math.logf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt 
b/libc/config/linux/x86_64/entrypoints.txt
index 3fd279071ccb1d..785cbc4ce62a9e 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -642,6 +642,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
 libc.src.math.llogbf16
 libc.src.math.llrintf16
 libc.src.math.llroundf16
+libc.src.math.log10f16
 libc.src.math.log2f16
 libc.src.math.logbf16
 libc.src.math.logf16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index 6b30cac1366d6b..c4723893455333 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -308,7 +308,7 @@ Higher Math Functions
 
+---+--+-++--++++
 | log   | |check|  | |check| || 
|check|  || 7.12.6.11  | 
F.10.3.11  |
 
+---+--+-++--++++
-| log10 | |check|  | |check| ||
  || 7.12.6.12  | F.10.3.12 
 |
+| log10 | |check|  | |check| || 
|check|  || 7.12.6.12  | 
F.10.3.12  |
 
+---+--+-++--++++
 | log10p1   |  | ||
  || 7.12.6.13  | F.10.3.13 
 |
 
+---+--+-++--++++
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index de4b8f85e94d11..fe6ee9ad683a47 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -556,6 +556,7 @@ def StdC : StandardSpec<"stdc"> {
 
   FunctionSpec<"log10", RetValSpec, [ArgSpec]>,
   FunctionSpec<"log10f", RetValSpec, [ArgSpec]>,
+  GuardedFunctionSpec<"log10f16", RetValSpec, 
[ArgSpec], "LIBC_TYPES_HAS_FLOAT16">,
 
   FunctionSpec<"log1p", RetValSpec, [ArgSpec]>,
   FunctionSpec<"log1pf", RetValSpec, [ArgSpec]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 23c35828b576f4..994daf8db742ab 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -322,6 +322,7 @@ add_math_entrypoint_object(ldexpf128)
 
 add_math_entrypoint_object(log10)
 add_math_entrypoint_object(log10f)
+add_math_entrypoint_object(log10f16)
 
 add_math_entrypoint_object(log1p)
 add_math_entrypoint_object(log1pf)
diff --git a/libc/src/math/generic/CMakeLists.txt 
b/libc/src/math/generic/CMakeLists.txt
index 0af3d2ad24e0a3..18d520deb2832a 100644
--- a/libc/src/math/generic/CMakeLis

[llvm-branch-commits] [libc] 2304226 - fix build again

2025-04-24 Thread Schrodinger ZHU Yifan via llvm-branch-commits

Author: Schrodinger ZHU Yifan
Date: 2025-04-24T13:15:42-04:00
New Revision: 230422621aeb97c4839ba133c75c33496aa5a75a

URL: 
https://github.com/llvm/llvm-project/commit/230422621aeb97c4839ba133c75c33496aa5a75a
DIFF: 
https://github.com/llvm/llvm-project/commit/230422621aeb97c4839ba133c75c33496aa5a75a.diff

LOG: fix build again

Added: 


Modified: 
libc/src/setjmp/CMakeLists.txt
libc/src/setjmp/x86_64/CMakeLists.txt

Removed: 




diff  --git a/libc/src/setjmp/CMakeLists.txt b/libc/src/setjmp/CMakeLists.txt
index 2591319f15240..239254fa57dc6 100644
--- a/libc/src/setjmp/CMakeLists.txt
+++ b/libc/src/setjmp/CMakeLists.txt
@@ -26,19 +26,21 @@ add_entrypoint_object(
 .${LIBC_TARGET_ARCHITECTURE}.longjmp
 )
 
-add_entrypoint_object(
-  siglongjmp
-  SRCS
-siglongjmp.cpp
-  HDRS
-siglongjmp.h
-  DEPENDS
-.longjmp
-)
+if (TARGET libc.src.setjmp.sigsetjmp_epilogue)
+  add_entrypoint_object(
+siglongjmp
+SRCS
+  siglongjmp.cpp
+HDRS
+  siglongjmp.h
+DEPENDS
+  .longjmp
+  )
 
-add_entrypoint_object(
-  sigsetjmp
-  ALIAS
-  DEPENDS
-.${LIBC_TARGET_ARCHITECTURE}.sigsetjmp
-)
+  add_entrypoint_object(
+sigsetjmp
+ALIAS
+DEPENDS
+  .${LIBC_TARGET_ARCHITECTURE}.sigsetjmp
+  )
+endif()

diff  --git a/libc/src/setjmp/x86_64/CMakeLists.txt 
b/libc/src/setjmp/x86_64/CMakeLists.txt
index 0090e81655662..03ed5fb647084 100644
--- a/libc/src/setjmp/x86_64/CMakeLists.txt
+++ b/libc/src/setjmp/x86_64/CMakeLists.txt
@@ -8,20 +8,21 @@ add_entrypoint_object(
 libc.hdr.offsetof_macros
 libc.hdr.types.jmp_buf
 )
-
-add_entrypoint_object(
-  sigsetjmp
-  SRCS
-sigsetjmp.cpp
-  HDRS
-../sigsetjmp.h
-  DEPENDS
-libc.hdr.types.jmp_buf
-libc.hdr.types.sigset_t
-libc.hdr.offsetof_macros
-libc.src.setjmp.sigsetjmp_epilogue
-libc.src.setjmp.setjmp
-)
+if (TARGET libc.src.setjmp.sigsetjmp_epilogue)
+  add_entrypoint_object(
+sigsetjmp
+SRCS
+  sigsetjmp.cpp
+HDRS
+  ../sigsetjmp.h
+DEPENDS
+  libc.hdr.types.jmp_buf
+  libc.hdr.types.sigset_t
+  libc.hdr.offsetof_macros
+  libc.src.setjmp.sigsetjmp_epilogue
+  libc.src.setjmp.setjmp
+  )
+endif()
 
 add_entrypoint_object(
   longjmp



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [libc] 3591028 - [libc] more amendments

2025-04-24 Thread Schrodinger ZHU Yifan via llvm-branch-commits

Author: Schrodinger ZHU Yifan
Date: 2025-04-24T16:21:47-04:00
New Revision: 3591028462d189befbe038e7a87bd9a08da7b26e

URL: 
https://github.com/llvm/llvm-project/commit/3591028462d189befbe038e7a87bd9a08da7b26e
DIFF: 
https://github.com/llvm/llvm-project/commit/3591028462d189befbe038e7a87bd9a08da7b26e.diff

LOG: [libc] more amendments

Added: 


Modified: 
libc/include/llvm-libc-types/jmp_buf.h

Removed: 




diff  --git a/libc/include/llvm-libc-types/jmp_buf.h 
b/libc/include/llvm-libc-types/jmp_buf.h
index 1e7791610857d..a6638b222138a 100644
--- a/libc/include/llvm-libc-types/jmp_buf.h
+++ b/libc/include/llvm-libc-types/jmp_buf.h
@@ -9,7 +9,9 @@
 #ifndef LLVM_LIBC_TYPES_JMP_BUF_H
 #define LLVM_LIBC_TYPES_JMP_BUF_H
 
+#if defined(__i386__) || defined(__x86_64__)
 #include "sigset_t.h"
+#endif
 
 typedef struct {
 #ifdef __x86_64__



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits