Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive

Commit aeecc90

Browse files
committed
Clean up unnecessary or catch-all version(Posix) blocks and version statements with catch-all else blocks that can be defined more narrowly
1 parent 0dde0ab commit aeecc90

File tree

22 files changed

+233
-186
lines changed

22 files changed

+233
-186
lines changed

src/core/cpuid.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ bool hasCPUID()
843843
{
844844
version(D_InlineAsm_X86_64)
845845
return true;
846-
else
846+
else version(D_InlineAsm_X86)
847847
{
848848
uint flags;
849849
asm nothrow @nogc {

src/core/runtime.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ Throwable.TraceInfo defaultTraceHandler( void* ptr = null )
493493
// mangled function names.
494494
static enum FIRSTFRAME = 5;
495495
}
496-
else
496+
else version( Windows )
497497
{
498498
// NOTE: On Windows, the number of frames to exclude is based on
499499
// whether the exception is user or system-generated, so
@@ -646,7 +646,7 @@ Throwable.TraceInfo defaultTraceHandler( void* ptr = null )
646646
{
647647
static enum FIRSTFRAME = 4;
648648
}
649-
else
649+
else version (Win32)
650650
{
651651
static enum FIRSTFRAME = 0;
652652
}

src/core/stdc/config.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ version( Windows )
5353
alias int c_long;
5454
alias uint c_ulong;
5555
}
56-
else
56+
else version( Posix )
5757
{
5858
static if( (void*).sizeof > int.sizeof )
5959
{

src/core/stdc/signal.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ version( Posix )
4848
///
4949
enum SIGTERM = 15; // Termination
5050
}
51-
else
51+
else version( Windows )
5252
{
5353
///
5454
enum SIG_ERR = cast(sigfn_t) -1;

src/core/stdc/stddef.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ version( Windows )
2626
///
2727
alias wchar wchar_t;
2828
}
29-
else
29+
else version( Posix )
3030
{
3131
///
3232
alias dchar wchar_t;

src/core/stdc/string.d

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,20 @@ pure char* strstr(in char* s1, in char* s2);
6969
char* strtok(char* s1, in char* s2);
7070
///
7171
char* strerror(int errnum);
72-
version (linux)
72+
version (CRuntime_Glibc)
7373
{
7474
///
7575
const(char)* strerror_r(int errnum, char* buf, size_t buflen);
7676
}
77-
else version (Posix)
77+
else version (OSX)
78+
{
79+
int strerror_r(int errnum, char* buf, size_t buflen);
80+
}
81+
else version (FreeBSD)
82+
{
83+
int strerror_r(int errnum, char* buf, size_t buflen);
84+
}
85+
else version (CRuntime_Bionic)
7886
{
7987
///
8088
int strerror_r(int errnum, char* buf, size_t buflen);

src/core/stdc/time.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ version( Windows )
3939
int tm_isdst; /// Daylight Saving Time flag
4040
}
4141
}
42-
else
42+
else version( Posix )
4343
{
4444
///
4545
struct tm
@@ -62,7 +62,7 @@ version ( Posix )
6262
{
6363
public import core.sys.posix.sys.types : time_t, clock_t;
6464
}
65-
else
65+
else version ( Windows )
6666
{
6767
///
6868
alias c_long time_t;

src/core/sync/barrier.d

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ public import core.sync.exception;
2020
private import core.sync.condition;
2121
private import core.sync.mutex;
2222

23-
version( Win32 )
24-
{
25-
private import core.sys.windows.windows;
26-
}
27-
else version( Posix )
23+
version( Posix )
2824
{
2925
private import core.stdc.errno;
3026
private import core.sys.posix.pthread;

src/core/sync/rwmutex.d

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ private import core.sync.condition;
2121
private import core.sync.mutex;
2222
private import core.memory;
2323

24-
version( Win32 )
25-
{
26-
private import core.sys.windows.windows;
27-
}
28-
else version( Posix )
24+
version( Posix )
2925
{
3026
private import core.sys.posix.pthread;
3127
}

src/core/sys/posix/pthread.d

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -261,17 +261,14 @@ else
261261
static assert(false, "Unsupported platform");
262262
}
263263

264-
version( Posix )
265-
{
266-
int pthread_atfork(void function(), void function(), void function());
267-
int pthread_attr_destroy(pthread_attr_t*);
268-
int pthread_attr_getdetachstate(in pthread_attr_t*, int*);
269-
int pthread_attr_getschedparam(in pthread_attr_t*, sched_param*);
270-
int pthread_attr_init(pthread_attr_t*);
271-
int pthread_attr_setdetachstate(pthread_attr_t*, int);
272-
int pthread_attr_setschedparam(in pthread_attr_t*, sched_param*);
273-
int pthread_cancel(pthread_t);
274-
}
264+
int pthread_atfork(void function(), void function(), void function());
265+
int pthread_attr_destroy(pthread_attr_t*);
266+
int pthread_attr_getdetachstate(in pthread_attr_t*, int*);
267+
int pthread_attr_getschedparam(in pthread_attr_t*, sched_param*);
268+
int pthread_attr_init(pthread_attr_t*);
269+
int pthread_attr_setdetachstate(pthread_attr_t*, int);
270+
int pthread_attr_setschedparam(in pthread_attr_t*, sched_param*);
271+
int pthread_cancel(pthread_t);
275272

276273
version( linux )
277274
{
@@ -424,15 +421,13 @@ else version( Android )
424421
}
425422
}
426423
}
427-
else version( Posix )
424+
else
428425
{
429-
void pthread_cleanup_push(void function(void*), void*);
430-
void pthread_cleanup_pop(int);
426+
static assert(false, "Unsupported platform");
431427
}
432428

433-
version( Posix )
429+
@nogc
434430
{
435-
@nogc:
436431
int pthread_cond_broadcast(pthread_cond_t*);
437432
int pthread_cond_destroy(pthread_cond_t*);
438433
int pthread_cond_init(in pthread_cond_t*, pthread_condattr_t*) @trusted;

0 commit comments

Comments
 (0)