From fa40bf8acd97a7d5c012d6a468c00f28221ef41d Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Mon, 3 Mar 2025 17:11:34 -0800 Subject: [PATCH] Revert "Use C to force the POSIX (not GNU) overload of strerror_r to be selected" This reverts commit baa8180c29a85535a0510b8c69fd433a27872c4b. --- Sources/TSCBasic/CMakeLists.txt | 2 ++ Sources/TSCBasic/misc.swift | 3 +-- Sources/TSCclibc/CMakeLists.txt | 2 +- Sources/TSCclibc/include/module.modulemap | 1 - Sources/TSCclibc/include/strerror.h | 5 ----- Sources/TSCclibc/strerror.c | 9 --------- 6 files changed, 4 insertions(+), 18 deletions(-) delete mode 100644 Sources/TSCclibc/include/strerror.h delete mode 100644 Sources/TSCclibc/strerror.c diff --git a/Sources/TSCBasic/CMakeLists.txt b/Sources/TSCBasic/CMakeLists.txt index d8b85eaa..a1f5bcc2 100644 --- a/Sources/TSCBasic/CMakeLists.txt +++ b/Sources/TSCBasic/CMakeLists.txt @@ -52,6 +52,8 @@ add_library(TSCBasic misc.swift) target_compile_options(TSCBasic PUBLIC + # Don't use GNU strerror_r on Android. + "$<$:SHELL:-Xcc -U_GNU_SOURCE>" # Ignore secure function warnings on Windows. "$<$:SHELL:-Xcc -D_CRT_SECURE_NO_WARNINGS>") target_link_libraries(TSCBasic PRIVATE diff --git a/Sources/TSCBasic/misc.swift b/Sources/TSCBasic/misc.swift index d85dd096..58a302de 100644 --- a/Sources/TSCBasic/misc.swift +++ b/Sources/TSCBasic/misc.swift @@ -8,7 +8,6 @@ See http://swift.org/CONTRIBUTORS.txt for Swift project authors */ -@_implementationOnly import TSCclibc import TSCLibc import Foundation #if os(Windows) @@ -328,7 +327,7 @@ extension SystemError: CustomStringConvertible { var cap = 64 while cap <= 16 * 1024 { var buf = [Int8](repeating: 0, count: cap) - let err = TSCclibc.tsc_strerror_r(errno, &buf, buf.count) + let err = TSCLibc.strerror_r(errno, &buf, buf.count) if err == EINVAL { return "Unknown error \(errno)" } diff --git a/Sources/TSCclibc/CMakeLists.txt b/Sources/TSCclibc/CMakeLists.txt index d3c1e78e..bbeb1911 100644 --- a/Sources/TSCclibc/CMakeLists.txt +++ b/Sources/TSCclibc/CMakeLists.txt @@ -7,7 +7,7 @@ # See http://swift.org/CONTRIBUTORS.txt for Swift project authors add_library(TSCclibc STATIC - libc.c process.c strerror.c) + libc.c process.c) target_include_directories(TSCclibc PUBLIC include) target_compile_definitions(TSCclibc PRIVATE diff --git a/Sources/TSCclibc/include/module.modulemap b/Sources/TSCclibc/include/module.modulemap index e3ee9bc8..82bddc8e 100644 --- a/Sources/TSCclibc/include/module.modulemap +++ b/Sources/TSCclibc/include/module.modulemap @@ -2,6 +2,5 @@ module TSCclibc { header "TSCclibc.h" header "indexstore_functions.h" header "process.h" - header "strerror.h" export * } diff --git a/Sources/TSCclibc/include/strerror.h b/Sources/TSCclibc/include/strerror.h deleted file mode 100644 index ca03e2c5..00000000 --- a/Sources/TSCclibc/include/strerror.h +++ /dev/null @@ -1,5 +0,0 @@ -#include - -#ifndef _WIN32 -extern int tsc_strerror_r(int errnum, char *buf, size_t buflen); -#endif diff --git a/Sources/TSCclibc/strerror.c b/Sources/TSCclibc/strerror.c deleted file mode 100644 index 9dc082ad..00000000 --- a/Sources/TSCclibc/strerror.c +++ /dev/null @@ -1,9 +0,0 @@ -#undef _GNU_SOURCE -#include "strerror.h" -#include - -#ifndef _WIN32 -int tsc_strerror_r(int errnum, char *buf, size_t buflen) { - return strerror_r(errnum, buf, buflen); -} -#endif