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

Commit edf321a

Browse files
authored
Merge pull request #2071 from yshui/musl_fixes
Some missing parts for musl merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>
2 parents 7653199 + fdc4779 commit edf321a

File tree

11 files changed

+68
-14
lines changed

11 files changed

+68
-14
lines changed

src/core/stdc/errno.d

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ else version (CRuntime_Glibc)
5151
alias errno = __errno_location;
5252
}
5353
}
54+
else version (CRuntime_Musl)
55+
{
56+
extern (C)
57+
{
58+
ref int __errno_location();
59+
alias errno = __errno_location;
60+
}
61+
}
5462
else version (FreeBSD)
5563
{
5664
extern (C)

src/core/stdc/math.d

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -627,15 +627,17 @@ else version( CRuntime_Musl )
627627
FP_FAST_FMAL = 0,
628628
}
629629

630+
pure {
630631
int __fpclassifyf(float x);
631632
int __fpclassify(double x);
632633
int __fpclassifyl(real x);
633634

634635
int __signbitf(float x);
635636
int __signbit(double x);
636637
int __signbitl(real x);
638+
}
637639

638-
extern (D)
640+
extern (D) pure
639641
{
640642
//int fpclassify(real-floating x);
641643
///
@@ -711,19 +713,19 @@ else version( CRuntime_Musl )
711713

712714
//int isnormal(real-floating x);
713715
///
714-
pure int isnormal(float x) { return fpclassify(x) == FP_NORMAL; }
716+
int isnormal(float x) { return fpclassify(x) == FP_NORMAL; }
715717
///
716-
pure int isnormal(double x) { return fpclassify(x) == FP_NORMAL; }
718+
int isnormal(double x) { return fpclassify(x) == FP_NORMAL; }
717719
///
718-
pure int isnormal(real x) { return fpclassify(x) == FP_NORMAL; }
720+
int isnormal(real x) { return fpclassify(x) == FP_NORMAL; }
719721

720722
//int signbit(real-floating x);
721723
///
722-
pure int signbit(float x) { return __signbitf(x); }
724+
int signbit(float x) { return __signbitf(x); }
723725
///
724-
pure int signbit(double x) { return __signbit(x); }
726+
int signbit(double x) { return __signbit(x); }
725727
///
726-
pure int signbit(real x)
728+
int signbit(real x)
727729
{
728730
return (real.sizeof == double.sizeof)
729731
? __signbit(x)

src/core/sync/mutex.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ unittest
377377
// For example, Bionic doesn't appear to do so, so this test is
378378
// not run on Android.
379379
version (CRuntime_Bionic) {} else
380+
version (CRuntime_Musl) {} else
380381
assert(!mtx.tryLock_nothrow());
381382

382383
free(cast(void*) mtx);

src/core/sys/posix/pthread.d

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,20 @@ else version( CRuntime_Bionic )
383383
}
384384
else version( CRuntime_Musl )
385385
{
386+
enum
387+
{
388+
PTHREAD_CREATE_JOINABLE = 0,
389+
PTHREAD_CREATE_DETACHED = 1
390+
}
391+
392+
enum PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t.init;
393+
enum PTHREAD_ONCE_INIT = pthread_once_t.init;
386394

395+
enum
396+
{
397+
PTHREAD_PROCESS_PRIVATE = 0,
398+
PTHREAD_PROCESS_SHARED = 1
399+
}
387400
}
388401
else
389402
{

src/core/sys/posix/signal.d

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3035,7 +3035,15 @@ else version( CRuntime_Bionic )
30353035
}
30363036
else version( CRuntime_Musl )
30373037
{
3038-
3038+
struct sigevent
3039+
{
3040+
sigval sigev_value;
3041+
int sigev_signo;
3042+
int sigev_notify;
3043+
void function(sigval) sigev_notify_function;
3044+
pthread_attr_t *sigev_notify_attributes;
3045+
char[56 - 3 * long.sizeof] __pad;
3046+
}
30393047
}
30403048
else
30413049
{

src/core/sys/posix/stdlib.d

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ else version( CRuntime_Bionic )
125125
// Added since Lollipop
126126
int posix_memalign(void**, size_t, size_t);
127127
}
128+
else version( CRuntime_Musl )
129+
{
130+
int posix_memalign(void**, size_t, size_t);
131+
}
128132

129133
//
130134
// C Extension (CX)

src/core/sys/posix/sys/stat.d

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,11 +1294,11 @@ else version (CRuntime_Musl)
12941294
timespec st_atim;
12951295
timespec st_mtim;
12961296
timespec st_ctim;
1297-
extern(D)
1297+
extern(D) @safe @property
12981298
{
1299-
@property ref time_t st_atime() return { return st_atim.tv_sec; }
1300-
@property ref time_t st_mtime() return { return st_mtim.tv_sec; }
1301-
@property ref time_t st_ctime() return { return st_ctim.tv_sec; }
1299+
ref time_t st_atime() return { return st_atim.tv_sec; }
1300+
ref time_t st_mtime() return { return st_mtim.tv_sec; }
1301+
ref time_t st_ctime() return { return st_ctim.tv_sec; }
13021302
}
13031303
long[3] __unused;
13041304
}

src/core/sys/posix/sys/time.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ else version( CRuntime_Musl )
9090
suseconds_t tv_usec;
9191
}
9292
int gettimeofday(timeval*, void*);
93+
int utimes(in char*, ref const(timeval)[2]);
9394
}
9495
else version( Darwin )
9596
{

src/core/sys/posix/sys/utsname.d

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,22 @@ else version(CRuntime_Bionic)
134134

135135
int uname(utsname*);
136136
}
137+
else version(CRuntime_Musl)
138+
{
139+
private enum SYS_NMLN = 65;
140+
141+
struct utsname
142+
{
143+
char[SYS_NMLN] sysname;
144+
char[SYS_NMLN] nodename;
145+
char[SYS_NMLN] release;
146+
char[SYS_NMLN] _version;
147+
char[SYS_NMLN] machine;
148+
char[SYS_NMLN] domainname;
149+
}
150+
151+
int uname(utsname*);
152+
}
137153
else
138154
{
139155
static assert(false, "unsupported system");

src/core/sys/posix/time.d

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ else version( CRuntime_Musl )
402402
enum TIMER_ABSTIME = 1;
403403

404404
enum CLOCK_REALTIME = 0;
405-
enum CLOCK_MONOTONIC = 1;
406405
enum CLOCK_PROCESS_CPUTIME_ID = 2;
407406
enum CLOCK_THREAD_CPUTIME_ID = 3;
408407
enum CLOCK_MONOTONIC_RAW = 4;

0 commit comments

Comments
 (0)