Skip to content

Commit f14cb82

Browse files
denizzzkathewilsonator
authored andcommitted
osthread: removed code what had already been moved into Thread.afterDeploy()
1 parent c844d73 commit f14cb82

1 file changed

Lines changed: 0 additions & 108 deletions

File tree

druntime/src/core/thread/osthread.d

Lines changed: 0 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,114 +1253,6 @@ extern (C) void thread_init() @nogc nothrow
12531253
Thread.initLocks();
12541254
Thread.afterDeploy();
12551255

1256-
version (Windows)
1257-
{
1258-
}
1259-
else version (Darwin)
1260-
{
1261-
// thread id different in forked child process
1262-
static extern(C) void initChildAfterFork()
1263-
{
1264-
auto thisThread = Thread.getThis();
1265-
if (!thisThread)
1266-
{
1267-
// It is possible that runtime was not properly initialized in the current process or thread -
1268-
// it may happen after `fork` call when using a dynamically loaded shared library written in D from a multithreaded non-D program.
1269-
// In such case getThis will return null.
1270-
return;
1271-
}
1272-
thisThread.m_tdescr.tid = pthread_self();
1273-
assert( thisThread.m_tdescr.tid != thisThread.m_tdescr.tid.init );
1274-
thisThread.m_tdescr.tmach = pthread_mach_thread_np( thisThread.m_tdescr.tid );
1275-
assert( thisThread.m_tdescr.tmach != thisThread.m_tdescr.tmach.init );
1276-
}
1277-
pthread_atfork(null, null, &initChildAfterFork);
1278-
}
1279-
else version (Solaris)
1280-
{
1281-
}
1282-
else version (WASI)
1283-
{
1284-
}
1285-
else version (Posix)
1286-
{
1287-
version (OpenBSD)
1288-
{
1289-
// OpenBSD does not support SIGRTMIN or SIGRTMAX
1290-
// Use SIGUSR1 for SIGRTMIN, SIGUSR2 for SIGRTMIN + 1
1291-
// And use 32 for SIGRTMAX (32 is the max signal number on OpenBSD)
1292-
enum SIGRTMIN = SIGUSR1;
1293-
enum SIGRTMAX = 32;
1294-
}
1295-
else version (Hurd)
1296-
{
1297-
// Hurd does not support SIGRTMIN or SIGRTMAX
1298-
// Use SIGUSR1 for SIGRTMIN, SIGUSR2 for SIGRTMIN + 1
1299-
// And use 32 for SIGRTMAX (32 is the max signal number on Hurd)
1300-
enum SIGRTMIN = SIGUSR1;
1301-
enum SIGRTMAX = 32;
1302-
}
1303-
else
1304-
{
1305-
import core.sys.posix.signal : SIGRTMAX, SIGRTMIN;
1306-
}
1307-
1308-
if ( suspendSignalNumber == 0 )
1309-
{
1310-
suspendSignalNumber = SIGRTMIN;
1311-
}
1312-
1313-
if ( resumeSignalNumber == 0 )
1314-
{
1315-
resumeSignalNumber = SIGRTMIN + 1;
1316-
assert(resumeSignalNumber <= SIGRTMAX);
1317-
}
1318-
int status;
1319-
sigaction_t suspend = void;
1320-
sigaction_t resume = void;
1321-
1322-
// This is a quick way to zero-initialize the structs without using
1323-
// memset or creating a link dependency on their static initializer.
1324-
(cast(byte*) &suspend)[0 .. sigaction_t.sizeof] = 0;
1325-
(cast(byte*) &resume)[0 .. sigaction_t.sizeof] = 0;
1326-
1327-
// NOTE: SA_RESTART indicates that system calls should restart if they
1328-
// are interrupted by a signal, but this is not available on all
1329-
// Posix systems, even those that support multithreading.
1330-
static if (__traits(compiles, core.sys.posix.signal.SA_RESTART))
1331-
{
1332-
import core.sys.posix.signal : SA_RESTART;
1333-
1334-
suspend.sa_flags = SA_RESTART;
1335-
}
1336-
1337-
suspend.sa_handler = &thread_suspendHandler;
1338-
// NOTE: We want to ignore all signals while in this handler, so fill
1339-
// sa_mask to indicate this.
1340-
status = sigfillset( &suspend.sa_mask );
1341-
assert( status == 0 );
1342-
1343-
// NOTE: Since resumeSignalNumber should only be issued for threads within the
1344-
// suspend handler, we don't want this signal to trigger a
1345-
// restart.
1346-
resume.sa_flags = 0;
1347-
resume.sa_handler = &thread_resumeHandler;
1348-
// NOTE: We want to ignore all signals while in this handler, so fill
1349-
// sa_mask to indicate this.
1350-
status = sigfillset( &resume.sa_mask );
1351-
assert( status == 0 );
1352-
1353-
status = sigaction( suspendSignalNumber, &suspend, null );
1354-
assert( status == 0 );
1355-
1356-
status = sigaction( resumeSignalNumber, &resume, null );
1357-
assert( status == 0 );
1358-
1359-
status = sem_init( &suspendCount, 0, 0 );
1360-
assert( status == 0 );
1361-
}
1362-
else
1363-
static assert(0, "unsupported os");
13641256
_mainThreadStore[] = cast(void[]) __traits(initSymbol, Thread)[];
13651257
Thread.sm_main = attachThread((cast(Thread)_mainThreadStore.ptr).__ctor());
13661258
}

0 commit comments

Comments
 (0)