Skip to content

Commit

Permalink
Fix building bsds
Browse files Browse the repository at this point in the history
  • Loading branch information
Reavershark committed Jan 2, 2025
1 parent 4c56847 commit 44c4b81
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 18 deletions.
6 changes: 6 additions & 0 deletions druntime/dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ copyright "Copyright © 1999-2018, The D Language Foundation"

targetType "library"
targetPath "generated"

#dflags "-target=x86_64-linux"
#dflags "-target=x86_64-freebsd14"
#dflags "-target=x86_64-openbsd"
#dflags "-target=x86_64-dragonfly"
#dflags "-target=x86_64-darwin"
3 changes: 2 additions & 1 deletion druntime/src/core/sync/condition.d
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ else version (Posix)
import core.sync.config;
import core.sys.posix.pthread : pthread_cond_broadcast, pthread_cond_destroy, pthread_cond_init,
pthread_cond_signal, pthread_cond_t, pthread_cond_timedwait, pthread_cond_wait;
import core.sys.posix.time : CLOCK_MONOTONIC, timespec;
import core.sys.posix.time : timespec;
}
else
{
Expand Down Expand Up @@ -133,6 +133,7 @@ class Condition
import core.sys.posix.pthread : pthread_condattr_destroy, pthread_condattr_init,
pthread_condattr_setclock;
import core.sys.posix.sys.types : pthread_condattr_t;
import core.sys.posix.time : CLOCK_MONOTONIC;
() @trusted
{
pthread_condattr_t attr = void;
Expand Down
3 changes: 2 additions & 1 deletion druntime/src/core/sync/config.d
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ module core.sync.config;
version (Posix)
{
import core.sys.posix.sys.time : gettimeofday, timeval;
import core.sys.posix.time : clock_gettime, CLOCK_MONOTONIC, timespec;
import core.sys.posix.time : timespec;
import core.time;


void mktspec( ref timespec t ) nothrow @nogc
{
static if ( is (typeof ( imported!"core.sys.posix.pthread".pthread_condattr_setclock ) ) )
{
import core.sys.posix.time : clock_gettime, CLOCK_MONOTONIC;
clock_gettime( CLOCK_MONOTONIC, &t );
}
else
Expand Down
15 changes: 9 additions & 6 deletions druntime/src/core/thread/osthread.d
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ else version (Posix)
static import core.sys.posix.pthread;
static import core.sys.posix.signal;
import core.stdc.errno;
import core.sys.posix.pthread : pthread_attr_destroy, pthread_attr_getstack, pthread_attr_init,
import core.sys.posix.pthread : pthread_atfork, pthread_attr_destroy, pthread_attr_getstack, pthread_attr_init,
pthread_attr_setstacksize, pthread_create, pthread_detach, pthread_getschedparam, pthread_join, pthread_self,
pthread_setschedparam, sched_get_priority_max, sched_get_priority_min, sched_param, sched_yield;
import core.sys.posix.semaphore : sem_init, sem_post, sem_t, sem_wait;
import core.sys.posix.signal : pthread_kill, sigaction, sigaction_t, sigdelset, sigfillset, SIGRTMAX, SIGRTMIN,
sigset_t, sigsuspend;
import core.sys.posix.signal : pthread_kill, sigaction, sigaction_t, sigdelset, sigfillset, sigset_t, sigsuspend,
SIGUSR1, stack_t;
import core.sys.posix.stdlib : free, malloc, realloc;
import core.sys.posix.sys.types : pthread_attr_t, pthread_key_t, pthread_t;
import core.sys.posix.time : nanosleep, timespec;
Expand Down Expand Up @@ -1906,6 +1906,10 @@ extern (C) void thread_init() @nogc nothrow
enum SIGRTMIN = SIGUSR1;
enum SIGRTMAX = 32;
}
else
{
import core.sys.posix.signal : SIGRTMAX, SIGRTMIN;
}

if ( suspendSignalNumber == 0 )
{
Expand Down Expand Up @@ -2372,10 +2376,9 @@ private
// Note: if the DLL is never unloaded, process termination kills all threads
// and signals their handles before unconditionally calling DllMain(DLL_PROCESS_DETACH).

import core.sys.windows.winbase : FreeLibraryAndExitThread, GetModuleHandleExW,
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT;
import core.sys.windows.windef : HMODULE;
import core.sys.windows.dll : dll_getRefCount;
import core.sys.windows.winbase : FreeLibraryAndExitThread, GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, GetModuleHandleExW;
import core.sys.windows.windef : HMODULE;

version (CRuntime_Microsoft)
extern(C) extern __gshared ubyte msvcUsesUCRT; // from rt/msvc.d
Expand Down
26 changes: 16 additions & 10 deletions druntime/src/core/time.d
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,6 @@ import core.internal.string;
import core.stdc.stdio;
import core.stdc.time;

version (Windows)
{
import core.sys.windows.winbase /+: QueryPerformanceCounter, QueryPerformanceFrequency+/;
}
else version (Posix)
{
import core.sys.posix.sys.time : gettimeofday, timeval;
import core.sys.posix.time : clock_getres, clock_gettime, CLOCK_MONOTONIC, timespec;
}

version (OSX)
version = Darwin;
else version (iOS)
Expand All @@ -89,6 +79,22 @@ else version (TVOS)
else version (WatchOS)
version = Darwin;

version (Windows)
{
import core.sys.windows.winbase /+: QueryPerformanceCounter, QueryPerformanceFrequency+/;
}
else version (Darwin)
{
import core.sys.posix.sys.time : gettimeofday, timeval;
import core.sys.posix.time : timespec;
}
else version (Posix)
{
import core.sys.posix.sys.time : gettimeofday, timeval;
import core.sys.posix.time : clock_getres, clock_gettime, CLOCK_MONOTONIC, timespec;
}


//This probably should be moved somewhere else in druntime which
//is Darwin-specific.
version (Darwin)
Expand Down

0 comments on commit 44c4b81

Please sign in to comment.