Skip to content

Commit

Permalink
Move new System.Native shim methods out of pal_environment (#1769)
Browse files Browse the repository at this point in the history
pal_environment should only contain methods related to env variables to make the iOS specific variant work well.
  • Loading branch information
jkotas authored Dec 7, 2021
1 parent 26997d7 commit 8ca8878
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 31 deletions.
1 change: 0 additions & 1 deletion src/native/libs/System.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 0 additions & 24 deletions src/native/libs/System.Native/pal_environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
#if HAVE_NSGETENVIRON
#include <crt_externs.h>
#endif
#if HAVE_SCHED_GETCPU
#include <sched.h>
#endif

char* SystemNative_GetEnv(const char* variable)
{
Expand All @@ -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();
}
6 changes: 0 additions & 6 deletions src/native/libs/System.Native/pal_environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

24 changes: 24 additions & 0 deletions src/native/libs/System.Native/pal_threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#include <errno.h>
#include <time.h>
#include <sys/time.h>
#if HAVE_SCHED_GETCPU
#include <sched.h>
#endif

#if defined(TARGET_OSX)
// So we can use the declaration of pthread_cond_timedwait_relative_np
Expand Down Expand Up @@ -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();
}
6 changes: 6 additions & 0 deletions src/native/libs/System.Native/pal_threading.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 8ca8878

Please sign in to comment.