aboutsummaryrefslogtreecommitdiffstats
path: root/main/gcc/400-dlang-phobos.patch
blob: 7e434e785841d63c6b408a9403f9d0291e075bba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
diff -Nurp a/libphobos/libdruntime/core/stdc/fenv.d b/libphobos/libdruntime/core/stdc/fenv.d
--- a/libphobos/libdruntime/core/stdc/fenv.d	2019-10-28 06:37:30.000000000 +0900
+++ b/libphobos/libdruntime/core/stdc/fenv.d	2019-10-28 08:08:09.000000000 +0900
@@ -375,7 +375,44 @@ else version (Solaris)
 }
 else version (CRuntime_Musl)
 {
-    version (X86_64)
+    version (AArch64)
+    {
+        struct fenv_t
+        {
+            uint __fpcr;
+            uint __fpsr;
+        }
+        alias uint fexcept_t;
+    }
+    else version (ARM)
+    {
+        import core.stdc.config : c_ulong;
+
+        struct fenv_t
+        {
+            c_ulong __cw;
+        }
+        alias c_ulong fexcept_t;
+    }
+    else version (IBMZ_Any)
+    {
+        alias uint fenv_t;
+        alias uint fexcept_t;
+    }
+    else version (MIPS_Any)
+    {
+        struct fenv_t
+        {
+            uint __cw;
+        }
+        alias ushort fexcept_t;
+    }
+    else version (PPC_Any)
+    {
+        alias double fenv_t;
+        alias uint fexcept_t;
+    }
+    else version (X86_Any)
     {
         struct fenv_t
         {
@@ -391,7 +428,8 @@ else version (CRuntime_Musl)
             uint   __data_offset;
             ushort __data_selector;
             ushort __unused5;
-            uint   __mxcsr;
+            version (X86_64)
+                uint __mxcsr;
         }
         alias ushort fexcept_t;
     }
diff -Nurp a/libphobos/libdruntime/core/sys/posix/dirent.d b/libphobos/libdruntime/core/sys/posix/dirent.d
--- a/libphobos/libdruntime/core/sys/posix/dirent.d	2019-10-28 06:37:30.000000000 +0900
+++ b/libphobos/libdruntime/core/sys/posix/dirent.d	2019-10-28 08:08:09.000000000 +0900
@@ -506,7 +506,7 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
-
+    int readdir_r(DIR*, dirent*, dirent**);
 }
 else version (CRuntime_UClibc)
 {
@@ -591,6 +591,8 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
+    void   seekdir(DIR*, c_long);
+    c_long telldir(DIR*);
 }
 else version (CRuntime_UClibc)
 {
diff -Nurp a/libphobos/libdruntime/core/sys/posix/pthread.d b/libphobos/libdruntime/core/sys/posix/pthread.d
--- a/libphobos/libdruntime/core/sys/posix/pthread.d	2019-10-28 06:37:30.000000000 +0900
+++ b/libphobos/libdruntime/core/sys/posix/pthread.d	2019-10-28 08:08:09.000000000 +0900
@@ -854,7 +854,15 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
+    enum PTHREAD_BARRIER_SERIAL_THREAD = -1;

+    int pthread_barrier_destroy(pthread_barrier_t*);
+    int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint);
+    int pthread_barrier_wait(pthread_barrier_t*);
+    int pthread_barrierattr_destroy(pthread_barrierattr_t*);
+    int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*);
+    int pthread_barrierattr_init(pthread_barrierattr_t*);
+    int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
 }
 else version (CRuntime_UClibc)
 {
@@ -880,6 +888,55 @@ else
 int pthread_condattr_getclock(in pthread_condattr_t*, clockid_t*);
 int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
 */
+version (CRuntime_Glibc)
+{
+    int pthread_condattr_getclock(in pthread_condattr_t*, clockid_t*);
+    int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
+}
+else version (FreeBSD)
+{
+    int pthread_condattr_getclock(in pthread_condattr_t*, clockid_t*);
+    int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
+}
+else version (DragonFlyBSD)
+{
+    int pthread_condattr_getclock(in pthread_condattr_t*, clockid_t*);
+    int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
+}
+else version (NetBSD)
+{
+    int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
+}
+else version (OpenBSD)
+{
+    int pthread_condattr_getclock(in pthread_condattr_t*, clockid_t*);
+    int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
+}
+else version (Darwin)
+{
+}
+else version (Solaris)
+{
+    int pthread_condattr_getclock(in pthread_condattr_t*, clockid_t*);
+    int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
+}
+else version (CRuntime_Bionic)
+{
+}
+else version (CRuntime_Musl)
+{
+    int pthread_condattr_getclock(in pthread_condattr_t*, clockid_t*);
+    int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
+}
+else version (CRuntime_UClibc)
+{
+    int pthread_condattr_getclock(in pthread_condattr_t*, clockid_t*);
+    int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
+}
+else
+{
+    static assert(false, "Unsupported platform");
+}

 //
 // Spinlock (SPI)
@@ -948,7 +1005,11 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
-
+    int pthread_spin_destroy(pthread_spinlock_t*);
+    int pthread_spin_init(pthread_spinlock_t*, int);
+    int pthread_spin_lock(pthread_spinlock_t*);
+    int pthread_spin_trylock(pthread_spinlock_t*);
+    int pthread_spin_unlock(pthread_spinlock_t*);
 }
 else version (CRuntime_UClibc)
 {
@@ -1187,7 +1248,7 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
-
+    int pthread_getcpuclockid(pthread_t, clockid_t*);
 }
 else version (CRuntime_UClibc)
 {
@@ -1256,7 +1317,9 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
-
+    int pthread_mutex_timedlock(pthread_mutex_t*, in timespec*);
+    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
+    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
 }
 else version (CRuntime_UClibc)
 {
@@ -1693,7 +1756,12 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
-
+    int pthread_condattr_getpshared(pthread_condattr_t*, int*);
+    int pthread_condattr_setpshared(pthread_condattr_t*, int);
+    int pthread_mutexattr_getpshared(pthread_mutexattr_t*, int*);
+    int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
+    int pthread_rwlockattr_getpshared(pthread_rwlockattr_t*, int*);
+    int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
 }
 else version (CRuntime_UClibc)
 {
diff -Nurp a/libphobos/libdruntime/core/sys/posix/pwd.d b/libphobos/libdruntime/core/sys/posix/pwd.d
--- a/libphobos/libdruntime/core/sys/posix/pwd.d	2019-10-28 06:37:30.000000000 +0900
+++ b/libphobos/libdruntime/core/sys/posix/pwd.d	2019-10-28 08:08:09.000000000 +0900
@@ -172,7 +172,8 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
-    struct passwd {
+    struct passwd
+    {
         char *pw_name;
         char *pw_passwd;
         uid_t pw_uid;
@@ -257,6 +258,8 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
+    int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
+    int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
 }
 else version (CRuntime_UClibc)
 {
@@ -325,8 +328,9 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
-    int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
-    int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
+    void    endpwent();
+    passwd* getpwent();
+    void    setpwent();
 }
 else version (CRuntime_UClibc)
 {
diff -Nurp a/libphobos/libdruntime/core/sys/posix/signal.d b/libphobos/libdruntime/core/sys/posix/signal.d
--- a/libphobos/libdruntime/core/sys/posix/signal.d	2019-10-28 07:12:22.000000000 +0900
+++ b/libphobos/libdruntime/core/sys/posix/signal.d	2019-10-28 08:08:09.000000000 +0900
@@ -1136,55 +1136,57 @@ else version (NetBSD)
     enum SIG_UNBLOCK = 2;
     enum SIG_SETMASK = 3;

-    union sigval_t {
-        int     sival_int;
-        void    *sival_ptr;
-    };
-    struct _rt{
-        pid_t   _pid;
-        uid_t   _uid;
-        sigval_t        _value;
-    };
-    struct _child{
-        pid_t   _pid;
-        uid_t   _uid;
-        int     _status;
-        clock_t _utime;
-        clock_t _stime;
-    };
-   struct _fault{
-        void   *_addr;
-        int     _trap;
-        int     _trap2;
-        int     _trap3;
-    };
-    struct _poll{
-        long    _band;
-        int     _fd;
-    };
-    union _reason{
-        _rt rt;
-        _child child;
-        _fault fault;
-        _poll poll;
-    };
-    struct _ksiginfo {
+    union sigval_t
+    {
+        int   sival_int;
+        void* sival_ptr;
+    }
+
+    struct _ksiginfo
+    {
         int     _signo;
         int     _code;
         int     _errno;
-/+#ifdef _LP64
-        /* In _LP64 the union starts on an 8-byte boundary. */
-        int     _pad;
-#endif+/
-        _reason reason;
-    };
+        version (D_LP64)
+            int _pad;

+        union reason_t
+        {
+            struct rt_t
+            {
+                pid_t    _pid;
+                uid_t    _uid;
+                sigval_t _value;
+            } rt_t _rt;
+            struct child_t
+            {
+                pid_t   _pid;
+                uid_t   _uid;
+                int     _status;
+                clock_t _utime;
+                clock_t _stime;
+            } child_t _child;
+            struct fault_t
+            {
+                void* _addr;
+                int   _trap;
+                int   _trap2;
+                int   _trap3;
+            } fault_t fault;
+            struct poll_t
+            {
+                c_long _band;
+                int  _fd;
+            } poll_t _poll;
+        }
+        reason_t _reason;
+    }

     union siginfo_t
     {
-        ubyte[128] si_pad;/* Total size; for future expansion */
+        ubyte[128] si_pad;
         _ksiginfo _info;
-        @property ref c_long si_band() return { return _info.reason.poll._band; }
+        @property ref c_long si_band() return { return _info._reason._poll._band; }
     }

     enum SI_USER    = 0;
@@ -1589,27 +1591,53 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
-    struct sigset_t {
-        ulong[128/long.sizeof] __bits;
+    struct sigset_t
+    {
+        c_ulong[128/c_long.sizeof] __bits;
     }

-    enum SIG_BLOCK      = 0;
-    enum SIG_UNBLOCK    = 1;
-    enum SIG_SETMASK    = 2;
+    version (MIPS_Any)
+    {
+        enum SIG_BLOCK      = 1;
+        enum SIG_UNBLOCK    = 2;
+        enum SIG_SETMASK    = 3;
+    }
+    else
+    {
+        enum SIG_BLOCK      = 0;
+        enum SIG_UNBLOCK    = 1;
+        enum SIG_SETMASK    = 2;
+    }

-    struct siginfo_t {
-        int si_signo, si_errno, si_code;
-        union __si_fields_t {
-            char[128 - 2*int.sizeof - long.sizeof] __pad = 0;
-            struct __si_common_t {
-                union __first_t {
-                    struct __piduid_t {
+    struct siginfo_t
+    {
+        int si_signo;
+        version (MIPS_Any)  // __SI_SWAP_ERRNO_CODE
+        {
+            int si_code;
+            int si_errno;
+        }
+        else
+        {
+            int si_errno;
+            int si_code;
+        }
+        union __si_fields_t
+        {
+            char[128 - 2*int.sizeof - c_long.sizeof] __pad = 0;
+            struct __si_common_t
+            {
+                union __first_t
+                {
+                    struct __piduid_t
+                    {
                         pid_t si_pid;
                         uid_t si_uid;
                     }
                     __piduid_t __piduid;

-                    struct __timer_t {
+                    struct __timer_t
+                    {
                         int si_timerid;
                         int si_overrun;
                     }
@@ -1617,11 +1645,14 @@ else version (CRuntime_Musl)
                 }
                 __first_t __first;

-                union __second_t {
+                union __second_t
+                {
                     sigval si_value;
-                    struct __sigchld_t {
+                    struct __sigchld_t
+                    {
                         int si_status;
-                        clock_t si_utime, si_stime;
+                        clock_t si_utime;
+                        clock_t si_stime;
                     }
                     __sigchld_t __sigchld;
                 }
@@ -1629,11 +1660,14 @@ else version (CRuntime_Musl)
             }
             __si_common_t __si_common;

-            struct __sigfault_t {
+            struct __sigfault_t
+            {
                 void *si_addr;
                 short si_addr_lsb;
-                union __first_t {
-                    struct __addr_bnd_t {
+                union __first_t
+                {
+                    struct __addr_bnd_t
+                    {
                         void *si_lower;
                         void *si_upper;
                     }
@@ -1644,13 +1678,15 @@ else version (CRuntime_Musl)
             }
             __sigfault_t __sigfault;

-            struct __sigpoll_t {
-                long si_band;
+            struct __sigpoll_t
+            {
+                c_long si_band;
                 int si_fd;
             }
             __sigpoll_t __sigpoll;

-            struct __sigsys_t {
+            struct __sigsys_t
+            {
                 void *si_call_addr;
                 int si_syscall;
                 uint si_arch;
@@ -3030,7 +3066,177 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
-    enum SA_RESTART     = 0x10000000;
+    version (MIPS_Any)
+    {
+        enum SIGPOLL   = 22;
+        enum SIGPROF   = 29;
+        enum SIGSYS    = 12;
+        enum SIGTRAP   = 5;
+        enum SIGVTALRM = 28;
+        enum SIGXCPU   = 30;
+        enum SIGXFSZ   = 31;
+
+        enum SA_ONSTACK   = 0x08000000;
+        enum SA_RESETHAND = 0x80000000;
+        enum SA_RESTART   = 0x10000000;
+        enum SA_SIGINFO   = 8;
+        enum SA_NOCLDWAIT = 0x10000;
+        enum SA_NODEFER   = 0x40000000;
+    }
+    else
+    {
+        enum SIGPOLL   = 29;
+        enum SIGPROF   = 27;
+        enum SIGSYS    = 31;
+        enum SIGTRAP   = 5;
+        enum SIGVTALRM = 26;
+        enum SIGXCPU   = 24;
+        enum SIGXFSZ   = 25;
+
+        enum SA_ONSTACK   = 0x08000000;
+        enum SA_RESETHAND = 0x80000000;
+        enum SA_RESTART   = 0x10000000;
+        enum SA_SIGINFO   = 4;
+        enum SA_NOCLDWAIT = 2;
+        enum SA_NODEFER   = 0x40000000;
+    }
+
+    enum SS_ONSTACK = 1;
+    enum SS_DISABLE = 2;
+
+    version (ARM)
+    {
+        enum MINSIGSTKSZ = 2048;
+        enum SIGSTKSZ    = 8192;
+    }
+    else version (AArch64)
+    {
+        enum MINSIGSTKSZ = 6144;
+        enum SIGSTKSZ    = 12288;
+    }
+    else version (IBMZ_Any)
+    {
+        enum MINSIGSTKSZ = 4096;
+        enum SIGSTKSZ    = 10240;
+    }
+    else version (MIPS_Any)
+    {
+        enum MINSIGSTKSZ = 2048;
+        enum SIGSTKSZ    = 8192;
+    }
+    else version (PPC_Any)
+    {
+        enum MINSIGSTKSZ = 4096;
+        enum SIGSTKSZ    = 10240;
+    }
+    else version (X86_Any)
+    {
+        enum MINSIGSTKSZ = 2048;
+        enum SIGSTKSZ    = 8192;
+    }
+    else
+        static assert(0, "unimplemented");
+
+    //ucontext_t (defined in core.sys.posix.ucontext)
+    //mcontext_t (defined in core.sys.posix.ucontext)
+
+    version (MIPS_Any)
+    {
+        struct stack_t
+        {
+            void*  ss_sp;
+            size_t ss_size;
+            int    ss_flags;
+        }
+    }
+    else
+    {
+        struct stack_t
+        {
+            void*  ss_sp;
+            int    ss_flags;
+            size_t ss_size;
+        }
+    }
+
+    enum
+    {
+        ILL_ILLOPC = 1,
+        ILL_ILLOPN,
+        ILL_ILLADR,
+        ILL_ILLTRP,
+        ILL_PRVOPC,
+        ILL_PRVREG,
+        ILL_COPROC,
+        ILL_BADSTK
+    }
+
+    enum
+    {
+        FPE_INTDIV = 1,
+        FPE_INTOVF,
+        FPE_FLTDIV,
+        FPE_FLTOVF,
+        FPE_FLTUND,
+        FPE_FLTRES,
+        FPE_FLTINV,
+        FPE_FLTSUB
+    }
+
+    enum
+    {
+        SEGV_MAPERR = 1,
+        SEGV_ACCERR
+    }
+
+    enum
+    {
+        BUS_ADRALN = 1,
+        BUS_ADRERR,
+        BUS_OBJERR
+    }
+
+    enum
+    {
+        TRAP_BRKPT = 1,
+        TRAP_TRACE
+    }
+
+    enum
+    {
+        CLD_EXITED = 1,
+        CLD_KILLED,
+        CLD_DUMPED,
+        CLD_TRAPPED,
+        CLD_STOPPED,
+        CLD_CONTINUED
+    }
+
+    enum
+    {
+        POLL_IN = 1,
+        POLL_OUT,
+        POLL_MSG,
+        POLL_ERR,
+        POLL_PRI,
+        POLL_HUP
+    }
+
+    sigfn_t bsd_signal(int sig, sigfn_t func);
+    sigfn_t sigset(int sig, sigfn_t func);
+
+  nothrow:
+  @nogc:
+    sigfn_t2 bsd_signal(int sig, sigfn_t2 func);
+    sigfn_t2 sigset(int sig, sigfn_t2 func);
+
+    int killpg(pid_t, int);
+    int sigaltstack(const scope stack_t*, stack_t*);
+    int sighold(int);
+    int sigignore(int);
+    int siginterrupt(int, int);
+    int sigpause(int);
+    int sigrelse(int);
 }
 else version (CRuntime_UClibc)
 {
@@ -3483,7 +3689,7 @@ else version (CRuntime_Musl)
         int sigev_notify;
         void function(sigval) sigev_notify_function;
         pthread_attr_t *sigev_notify_attributes;
-        char[56 - 3 * long.sizeof] __pad = void;
+        char[56 - 3 * c_long.sizeof] __pad = void;
     }
 }
 else version (CRuntime_UClibc)
diff -Nurp a/libphobos/libdruntime/core/sys/posix/sys/mman.d b/libphobos/libdruntime/core/sys/posix/sys/mman.d
--- a/libphobos/libdruntime/core/sys/posix/sys/mman.d	2019-10-28 07:12:22.000000000 +0900
+++ b/libphobos/libdruntime/core/sys/posix/sys/mman.d	2019-10-28 08:08:09.000000000 +0900
@@ -128,6 +128,15 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
+    enum
+    {
+        POSIX_MADV_NORMAL = 0,
+        POSIX_MADV_RANDOM = 1,
+        POSIX_MADV_SEQUENTIAL = 2,
+        POSIX_MADV_WILLNEED = 3,
+        POSIX_MADV_DONTNEED = 4,
+    }
+    int posix_madvise(void *, size_t, int);
 }
 else version (CRuntime_UClibc)
 {
@@ -611,6 +620,14 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
+    enum
+    {
+        MCL_CURRENT = 1,
+        MCL_FUTURE = 2,
+    }
+
+    int mlockall(int);
+    int munlockall();
 }
 else version (CRuntime_UClibc)
 {
@@ -674,6 +691,8 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
+    int mlock(in void*, size_t);
+    int munlock(in void*, size_t);
 }
 else version (CRuntime_UClibc)
 {
@@ -776,6 +795,8 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
+    int shm_open(in char*, int, mode_t);
+    int shm_unlink(in char*);
 }
 else version (CRuntime_UClibc)
 {
diff -Nurp a/libphobos/libdruntime/core/sys/posix/sys/socket.d b/libphobos/libdruntime/core/sys/posix/sys/socket.d
--- a/libphobos/libdruntime/core/sys/posix/sys/socket.d	2019-10-28 07:12:22.000000000 +0900
+++ b/libphobos/libdruntime/core/sys/posix/sys/socket.d	2019-10-28 08:08:09.000000000 +0900
@@ -1755,10 +1755,10 @@ else version (CRuntime_Musl)
         c_ulong     __ss_align;
     }

-    enum {
+    enum
+    {
         SOCK_STREAM = 1,
         SOCK_DGRAM = 2,
-        SOCK_RAW = 3,
         SOCK_RDM = 4,
         SOCK_SEQPACKET = 5,
         SOCK_DCCP = 6,
@@ -2187,6 +2187,10 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
+    enum
+    {
+        SOCK_RAW    = 3
+    }
 }
 else version (CRuntime_UClibc)
 {
diff -Nurp a/libphobos/libdruntime/core/sys/posix/sys/types.d b/libphobos/libdruntime/core/sys/posix/sys/types.d
--- a/libphobos/libdruntime/core/sys/posix/sys/types.d	2019-10-28 07:12:22.000000000 +0900
+++ b/libphobos/libdruntime/core/sys/posix/sys/types.d	2019-10-28 08:07:51.000000000 +0900
@@ -112,20 +112,25 @@ version (CRuntime_Glibc)
 }
 else version (CRuntime_Musl)
 {
-    alias long      blksize_t;
-    alias ulong     nlink_t;
-    alias long      dev_t;
-    alias long      blkcnt_t;
-    alias ulong     ino_t;
-    alias long      off_t;
-    alias long      _Addr;
-    alias int       pid_t;
-    alias uint      uid_t;
-    alias uint      gid_t;
-    alias long      time_t;
-    alias long      clock_t;
-    alias ulong     pthread_t;
-    alias _Addr     ssize_t;
+    alias c_long     blksize_t;
+    alias c_ulong    nlink_t;
+    alias long       dev_t;
+    alias long       blkcnt_t;
+    alias ulong      ino_t;
+    alias long       off_t;
+    alias int        pid_t;
+    alias uint       uid_t;
+    alias uint       gid_t;
+    version (D_X32)
+        alias long   time_t;
+    else
+        alias c_long time_t;
+    alias c_long     clock_t;
+    alias c_ulong    pthread_t;
+    version (D_LP64)
+        alias c_long ssize_t;
+    else
+        alias int    ssize_t;
 }
 else version (Darwin)
 {
@@ -420,7 +425,10 @@ else version (CRuntime_Musl)
   }
     alias uint mode_t;
     alias uint id_t;
-    alias long suseconds_t;
+    version (D_X32)
+        alias long susseconds_t;
+    else
+        alias c_long suseconds_t;
 }
 else version (CRuntime_UClibc)
 {
@@ -723,40 +746,77 @@ version (CRuntime_Glibc)
 }
 else version (CRuntime_Musl)
 {
-    version (X86_64) {
+    version (D_LP64)
+    {
         union pthread_attr_t
         {
             int[14] __i;
             ulong[7] __s;
         }
+
         union pthread_cond_t
         {
             int[12] __i;
             void*[6] __p;
         }
+
         union pthread_mutex_t
         {
             int[10] __i;
             void*[5] __p;
         }
+
         union pthread_rwlock_t
         {
             int[14] __i;
             void*[7] __p;
         }
-        struct pthread_rwlockattr_t
+    }
+    else
+    {
+        union pthread_attr_t
+        {
+            int[9] __i;
+            uint[9] __s;
+        }
+
+        union pthread_cond_t
+        {
+            int[12] __i;
+            void*[12] __p;
+        }
+
+        union pthread_mutex_t
         {
-            uint[2] __attr;
+            int[6] __i;
+            void*[6] __p;
+        }
+
+        union pthread_rwlock_t
+        {
+            int[8] __i;
+            void*[8] __p;
         }
-        alias uint pthread_key_t;
-        alias uint pthread_condattr_t;
-        alias uint pthread_mutexattr_t;
-        alias int pthread_once_t;
     }
-    else
+
+    struct pthread_rwlockattr_t
     {
-        static assert (false, "Architecture unsupported");
+        uint[2] __attr;
     }
+
+    alias uint pthread_key_t;
+
+    struct pthread_condattr_t
+    {
+        uint __attr;
+    }
+
+    struct pthread_mutexattr_t
+    {
+        uint __attr;
+    }
+
+    alias int pthread_once_t;
 }
 else version (Darwin)
 {
@@ -1300,6 +1360,27 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
+    version (D_LP64)
+    {
+        union pthread_barrier_t
+        {
+            int[8] __i;
+            void*[4] __p;
+        }
+    }
+    else
+    {
+        union pthread_barrier_t
+        {
+            int[5] __i;
+            void*[5] __p;
+        }
+    }
+
+    struct pthread_barrierattr_t
+    {
+        uint __attr;
+    }
 }
 else version (CRuntime_UClibc)
 {
@@ -1351,6 +1432,10 @@ else version (CRuntime_UClibc)
 {
     alias int pthread_spinlock_t; // volatile
 }
+else version (CRuntime_Musl)
+{
+    alias int pthread_spinlock_t;
+}

 //
 // Timer (TMR)
diff -Nurp a/libphobos/libdruntime/core/sys/posix/sys/wait.d b/libphobos/libdruntime/core/sys/posix/sys/wait.d
--- a/libphobos/libdruntime/core/sys/posix/sys/wait.d	2019-10-28 07:12:22.000000000 +0900
+++ b/libphobos/libdruntime/core/sys/posix/sys/wait.d	2019-10-28 08:08:09.000000000 +0900
@@ -362,6 +362,19 @@ else version (CRuntime_Bionic)
 }
 else version (CRuntime_Musl)
 {
+    enum WEXITED    = 4;
+    enum WSTOPPED   = 2;
+    enum WCONTINUED = 8;
+    enum WNOWAIT    = 0x01000000;
+
+    enum idtype_t
+    {
+        P_ALL,
+        P_PID,
+        P_PGID
+    }
+
+    int waitid(idtype_t, id_t, siginfo_t*, int);
 }
 else version (CRuntime_UClibc)
 {
diff -Nurp a/libphobos/libdruntime/core/sys/posix/ucontext.d b/libphobos/libdruntime/core/sys/posix/ucontext.d
--- a/libphobos/libdruntime/core/sys/posix/ucontext.d	2019-10-28 07:12:22.000000000 +0900
+++ b/libphobos/libdruntime/core/sys/posix/ucontext.d	2019-10-28 08:08:09.000000000 +0900
@@ -23,6 +23,10 @@ extern (C):
 nothrow:
 @nogc:

+version (MIPS32)  version = MIPS_Any;
+version (MIPS64)  version = MIPS_Any;
+version (PPC)     version = PPC_Any;
+version (PPC64)   version = PPC_Any;
 version (RISCV32) version = RISCV_Any;
 version (RISCV64) version = RISCV_Any;
 version (S390)    version = IBMZ_Any;
@@ -770,6 +774,139 @@ version (CRuntime_Glibc)
     else
         static assert(0, "unimplemented");
 }
+else version (CRuntime_Musl)
+{
+    version (AArch64)
+    {
+        struct mcontext_t
+        {
+            real[18+256] __regs;
+        }
+
+        struct ucontext_t
+        {
+            c_ulong     uc_flags;
+            ucontext_t* uc_link;
+            stack_t     uc_stack;
+            sigset_t    uc_sigmask;
+            mcontext_t  uc_mcontext;
+        }
+    }
+    else version (ARM)
+    {
+        struct mcontext_t
+        {
+            c_ulong[21] __regs;
+        }
+
+        struct ucontext_t
+        {
+            c_ulong     uc_flags;
+            ucontext_t* uc_link;
+            stack_t     uc_stack;
+            mcontext_t  uc_mcontext;
+            sigset_t    uc_sigmask;
+            ulong[64]   uc_regspace;
+        }
+    }
+    else version (IBMZ_Any)
+    {
+        struct mcontext_t
+        {
+            c_ulong[18] __regs1;
+            uint[18]    __regs2;
+            double[16]  __regs3;
+        }
+
+        struct ucontext_t
+        {
+            c_ulong     uc_flags;
+            ucontext_t* uc_link;
+            stack_t     uc_stack;
+            mcontext_t  uc_mcontext;
+            sigset_t    uc_sigmask;
+        }
+    }
+    else version (MIPS_Any)
+    {
+        version (MIPS_N32)
+        {
+            struct mcontext_t
+            {
+                ulong[32]  __mc1;
+                double[32] __mc2;
+                ulong[9]   __mc3;
+                uint[4]    __mc4;
+            }
+        }
+        else version (MIPS64)
+        {
+            struct mcontext_t
+            {
+                ulong[32]  __mc1;
+                double[32] __mc2;
+                ulong[9]   __mc3;
+                uint[4]    __mc4;
+            }
+        }
+        else
+        {
+            struct mcontext_t
+            {
+                uint[2]    __mc1;
+                ulong[65]  __mc2;
+                uint[5]    __mc3;
+                ulong[2]   __mc4;
+                uint[6]    __mc5;
+            }
+        }
+
+        struct ucontext_t
+        {
+            c_ulong     uc_flags;
+            ucontext_t* uc_link;
+            stack_t     uc_stack;
+            mcontext_t  uc_mcontext;
+            sigset_t    uc_sigmask;
+        }
+    }
+    else version (X86)
+    {
+        struct mcontext_t
+        {
+            uint[22] __space;
+        }
+
+        struct ucontext_t
+        {
+            c_ulong     uc_flags;
+            ucontext_t* uc_link;
+            stack_t     uc_stack;
+            mcontext_t  uc_mcontext;
+            sigset_t    uc_sigmask;
+            c_ulong[28] __fpregs_mem;
+        }
+    }
+    else version (X86_64)
+    {
+        struct mcontext_t
+        {
+            ulong[32] __space;
+        }
+
+        struct ucontext_t
+        {
+            c_ulong     uc_flags;
+            ucontext_t* uc_link;
+            stack_t     uc_stack;
+            mcontext_t  uc_mcontext;
+            sigset_t    uc_sigmask;
+            ulong[64]   __fpregs_mem;
+        }
+    }
+    else
+        static assert(0, "unimplemented");
+}
 else version (FreeBSD)
 {
     // <machine/ucontext.h>
diff -Nurp a/libphobos/src/std/experimental/allocator/building_blocks/region.d b/libphobos/src/std/experimental/allocator/building_blocks/region.d
--- a/libphobos/src/std/experimental/allocator/building_blocks/region.d	2019-10-28 07:23:27.000000000 +0900
+++ b/libphobos/src/std/experimental/allocator/building_blocks/region.d	2019-10-28 08:08:09.000000000 +0900
@@ -580,6 +580,12 @@ struct InSituRegion(size_t size, size_t
     assert(a.length == 2001);
 }

+version(CRuntime_Musl)
+{
+    // sbrk and brk are disabled in Musl:
+    // https://git.musl-libc.org/cgit/musl/commit/?id=7a995fe706e519a4f55399776ef0df9596101f93
+    // https://git.musl-libc.org/cgit/musl/commit/?id=863d628d93ea341b6a32661a1654320ce69f6a07
+} else:
 private extern(C) void* sbrk(long);
 private extern(C) int brk(shared void*);

diff -Nurp a/libphobos/src/std/socket.d b/libphobos/src/std/socket.d
--- a/libphobos/src/std/socket.d	2019-10-28 07:23:27.000000000 +0900
+++ b/libphobos/src/std/socket.d	2019-10-28 08:08:09.000000000 +0900
@@ -163,47 +163,7 @@ string formatSocketError(int err) @trust
         {
             cs = strerror_r(err, buf.ptr, buf.length);
         }
-        else version (OSX)
-        {
-            auto errs = strerror_r(err, buf.ptr, buf.length);
-            if (errs == 0)
-                cs = buf.ptr;
-            else
-                return "Socket error " ~ to!string(err);
-        }
-        else version (FreeBSD)
-        {
-            auto errs = strerror_r(err, buf.ptr, buf.length);
-            if (errs == 0)
-                cs = buf.ptr;
-            else
-                return "Socket error " ~ to!string(err);
-        }
-        else version (NetBSD)
-        {
-            auto errs = strerror_r(err, buf.ptr, buf.length);
-            if (errs == 0)
-                cs = buf.ptr;
-            else
-                return "Socket error " ~ to!string(err);
-        }
-        else version (DragonFlyBSD)
-        {
-            auto errs = strerror_r(err, buf.ptr, buf.length);
-            if (errs == 0)
-                cs = buf.ptr;
-            else
-                return "Socket error " ~ to!string(err);
-        }
-        else version (Solaris)
-        {
-            auto errs = strerror_r(err, buf.ptr, buf.length);
-            if (errs == 0)
-                cs = buf.ptr;
-            else
-                return "Socket error " ~ to!string(err);
-        }
-        else version (CRuntime_Bionic)
+        else
         {
             auto errs = strerror_r(err, buf.ptr, buf.length);
             if (errs == 0)
@@ -211,8 +171,6 @@ string formatSocketError(int err) @trust
             else
                 return "Socket error " ~ to!string(err);
         }
-        else
-            static assert(0);

         auto len = strlen(cs);

diff -Nurp a/libphobos/src/std/stdio.d b/libphobos/src/std/stdio.d
--- a/libphobos/src/std/stdio.d	2019-10-28 07:23:27.000000000 +0900
+++ b/libphobos/src/std/stdio.d	2019-10-28 08:08:09.000000000 +0900
@@ -44,38 +44,38 @@ version (CRuntime_Glibc)
     version = GCC_IO;
     version = HAS_GETDELIM;
 }
-
-version (OSX)
+else version (CRuntime_Bionic)
 {
     version = GENERIC_IO;
     version = HAS_GETDELIM;
 }
-
-version (FreeBSD)
+else version (CRuntime_Musl)
 {
     version = GENERIC_IO;
     version = HAS_GETDELIM;
 }

-version (NetBSD)
+version (OSX)
 {
     version = GENERIC_IO;
     version = HAS_GETDELIM;
 }
-
-version (DragonFlyBSD)
+else version (FreeBSD)
 {
     version = GENERIC_IO;
     version = HAS_GETDELIM;
 }
-
-version (Solaris)
+else version (NetBSD)
 {
     version = GENERIC_IO;
-    version = NO_GETDELIM;
+    version = HAS_GETDELIM;
 }
-
-version (CRuntime_Bionic)
+else version (DragonFlyBSD)
+{
+    version = GENERIC_IO;
+    version = HAS_GETDELIM;
+}
+else version (Solaris)
 {
     version = GENERIC_IO;
     version = NO_GETDELIM;