From 8ca887895eec4b7dc590bf098722fbc0939f65b1 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Mon, 6 Dec 2021 23:13:54 -0800 Subject: [PATCH] Move new System.Native shim methods out of pal_environment (#1769) pal_environment should only contain methods related to env variables to make the iOS specific variant work well. --- src/native/libs/System.Native/CMakeLists.txt | 1 - .../libs/System.Native/pal_environment.c | 24 ------------------- .../libs/System.Native/pal_environment.h | 6 ----- src/native/libs/System.Native/pal_threading.c | 24 +++++++++++++++++++ src/native/libs/System.Native/pal_threading.h | 6 +++++ 5 files changed, 30 insertions(+), 31 deletions(-) diff --git a/src/native/libs/System.Native/CMakeLists.txt b/src/native/libs/System.Native/CMakeLists.txt index c07669ae36e2..60780bf85c70 100644 --- a/src/native/libs/System.Native/CMakeLists.txt +++ b/src/native/libs/System.Native/CMakeLists.txt @@ -15,7 +15,6 @@ if (CLR_CMAKE_TARGET_OSX) endif () set(NATIVE_SOURCES - pal_environment.c pal_dynamicload.c pal_errno.c pal_interfaceaddresses.c diff --git a/src/native/libs/System.Native/pal_environment.c b/src/native/libs/System.Native/pal_environment.c index 601f532cc4fc..fd9e68f02302 100644 --- a/src/native/libs/System.Native/pal_environment.c +++ b/src/native/libs/System.Native/pal_environment.c @@ -9,9 +9,6 @@ #if HAVE_NSGETENVIRON #include #endif -#if HAVE_SCHED_GETCPU -#include -#endif char* SystemNative_GetEnv(const char* variable) { @@ -33,24 +30,3 @@ void SystemNative_FreeEnviron(char** environ) // no op (void)environ; } - -int32_t SystemNative_SchedGetCpu() -{ -#if HAVE_SCHED_GETCPU - return sched_getcpu(); -#else - return -1; -#endif -} - -__attribute__((noreturn)) -void SystemNative_Exit(int32_t exitCode) -{ - exit(exitCode); -} - -__attribute__((noreturn)) -void SystemNative_Abort() -{ - abort(); -} diff --git a/src/native/libs/System.Native/pal_environment.h b/src/native/libs/System.Native/pal_environment.h index 544834bfcb20..96f6c43986be 100644 --- a/src/native/libs/System.Native/pal_environment.h +++ b/src/native/libs/System.Native/pal_environment.h @@ -12,9 +12,3 @@ PALEXPORT char** SystemNative_GetEnviron(void); PALEXPORT void SystemNative_FreeEnviron(char** environ); -PALEXPORT int32_t SystemNative_SchedGetCpu(void); - -PALEXPORT __attribute__((noreturn)) void SystemNative_Exit(int32_t exitCode); - -PALEXPORT __attribute__((noreturn)) void SystemNative_Abort(void); - diff --git a/src/native/libs/System.Native/pal_threading.c b/src/native/libs/System.Native/pal_threading.c index 62ca6591ff14..2aa6790d4bcf 100644 --- a/src/native/libs/System.Native/pal_threading.c +++ b/src/native/libs/System.Native/pal_threading.c @@ -12,6 +12,9 @@ #include #include #include +#if HAVE_SCHED_GETCPU +#include +#endif #if defined(TARGET_OSX) // So we can use the declaration of pthread_cond_timedwait_relative_np @@ -261,3 +264,24 @@ int32_t SystemNative_RuntimeThread_CreateThread(uintptr_t stackSize, void *(*sta return result; } + +int32_t SystemNative_SchedGetCpu() +{ +#if HAVE_SCHED_GETCPU + return sched_getcpu(); +#else + return -1; +#endif +} + +__attribute__((noreturn)) +void SystemNative_Exit(int32_t exitCode) +{ + exit(exitCode); +} + +__attribute__((noreturn)) +void SystemNative_Abort() +{ + abort(); +} diff --git a/src/native/libs/System.Native/pal_threading.h b/src/native/libs/System.Native/pal_threading.h index 8ff8e5757087..ab59c7ddb83a 100644 --- a/src/native/libs/System.Native/pal_threading.h +++ b/src/native/libs/System.Native/pal_threading.h @@ -23,3 +23,9 @@ PALEXPORT int32_t SystemNative_LowLevelMonitor_TimedWait(LowLevelMonitor *monito PALEXPORT void SystemNative_LowLevelMonitor_Signal_Release(LowLevelMonitor* monitor); PALEXPORT int32_t SystemNative_RuntimeThread_CreateThread(uintptr_t stackSize, void *(*startAddress)(void*), void *parameter); + +PALEXPORT int32_t SystemNative_SchedGetCpu(void); + +PALEXPORT __attribute__((noreturn)) void SystemNative_Exit(int32_t exitCode); + +PALEXPORT __attribute__((noreturn)) void SystemNative_Abort(void);