This repository was archived by the owner on Oct 12, 2022. It is now read-only.
File tree 4 files changed +76
-9
lines changed
4 files changed +76
-9
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,30 @@ extern(C):
13
13
@nogc :
14
14
nothrow :
15
15
16
+ version (CRuntime_Musl )
17
+ {
18
+ import core.stdc.config : c_long;
19
+ private enum Use_Time64_Values = (time_t .sizeof > c_long.sizeof);
20
+ }
21
+ else
22
+ private enum Use_Time64_Values = false ;
23
+
24
+ static if (Use_Time64_Values)
25
+ {
26
+ // SO_TIMESTAMP_OLD & friends
27
+ // https://www.kernel.org/doc/Documentation/networking/timestamping.txt
28
+ enum SO_TIMESTAMP = 29 ;
29
+ enum SO_TIMESTAMPNS = 35 ;
30
+ enum SO_TIMESTAMPING = 37 ;
31
+
32
+ }
33
+ else
34
+ {
35
+ enum SO_TIMESTAMP = 63 ;
36
+ enum SO_TIMESTAMPNS = 64 ;
37
+ enum SO_TIMESTAMPING = 65 ;
38
+ }
39
+
16
40
enum
17
41
{
18
42
// Protocol families.
@@ -123,14 +147,14 @@ enum
123
147
SO_GET_FILTER = SO_ATTACH_FILTER ,
124
148
125
149
SO_PEERNAME = 28 ,
126
- SO_TIMESTAMP = 29 ,
150
+ // SO_TIMESTAMP See above
127
151
SCM_TIMESTAMP = SO_TIMESTAMP ,
128
152
129
153
SO_PASSSEC = 34 ,
130
- SO_TIMESTAMPNS = 35 ,
154
+ // SO_TIMESTAMPNS See above
131
155
SCM_TIMESTAMPNS = SO_TIMESTAMPNS ,
132
156
SO_MARK = 36 ,
133
- SO_TIMESTAMPING = 37 ,
157
+ // SO_TIMESTAMPING See above
134
158
SCM_TIMESTAMPING = SO_TIMESTAMPING ,
135
159
SO_RXQ_OVFL = 40 ,
136
160
SO_WIFI_STATUS = 41 ,
Original file line number Diff line number Diff line change @@ -3427,7 +3427,28 @@ struct timespec
3427
3427
}
3428
3428
*/
3429
3429
3430
- version (linux )
3430
+ version (CRuntime_Musl )
3431
+ {
3432
+ // Musl on 32 bits use 64 bits time_t (time64)
3433
+ // See https://git.musl-libc.org/cgit/musl/commit/?id=9b2921bea1d5017832e1b45d1fd64220047a9802
3434
+ struct timespec
3435
+ {
3436
+ time_t tv_sec;
3437
+ // 32 bits of padding on 32 bits, or in C:
3438
+ // int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER==4321);
3439
+ version (BigEndian )
3440
+ static if (time_t .sizeof > c_long.sizeof)
3441
+ int __padding;
3442
+ c_long tv_nsec;
3443
+ // Another 32 bits of padding on 32 bits:
3444
+ // int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER!=4321);
3445
+ version (LittleEndian )
3446
+ static if (time_t .sizeof > c_long.sizeof)
3447
+ int __padding;
3448
+ };
3449
+
3450
+ }
3451
+ else version (linux )
3431
3452
{
3432
3453
struct timespec
3433
3454
{
Original file line number Diff line number Diff line change @@ -1706,6 +1706,10 @@ else version (CRuntime_Bionic)
1706
1706
}
1707
1707
else version (CRuntime_Musl )
1708
1708
{
1709
+ // version (CRuntime_Musl_Pre_Time64)
1710
+ // private enum CRuntime_Musl_Use_Old_Layout = 1;
1711
+ // else
1712
+
1709
1713
alias __mode_t = uint ;
1710
1714
enum {
1711
1715
S_IRUSR = 0x100 , // octal 0400
@@ -1745,10 +1749,26 @@ else version (CRuntime_Musl)
1745
1749
blksize_t st_blksize;
1746
1750
blkcnt_t st_blocks;
1747
1751
1748
- timespec st_atim;
1749
- timespec st_mtim;
1750
- timespec st_ctim;
1751
- ino_t st_ino;
1752
+ // Time64 on 32 bits
1753
+ // See https://git.musl-libc.org/cgit/musl/commit/?id=38143339646a4ccce8afe298c34467767c899f51
1754
+ static if (time_t .sizeof > c_long.sizeof)
1755
+ {
1756
+ private struct old_timespec {
1757
+ long tv_sec;
1758
+ long tv_nsec;
1759
+ }
1760
+
1761
+ old_timespec __st_atim32;
1762
+ old_timespec __st_mtim32;
1763
+ old_timespec __st_ctim32;
1764
+ }
1765
+ else // Probably 64 bits or before v1.2.0
1766
+ {
1767
+ timespec st_atim;
1768
+ timespec st_mtim;
1769
+ timespec st_ctim;
1770
+ ino_t st_ino;
1771
+ }
1752
1772
1753
1773
extern (D ) @safe @property inout pure nothrow
1754
1774
{
Original file line number Diff line number Diff line change @@ -509,8 +509,10 @@ else version (CRuntime_Musl)
509
509
alias uint id_t ;
510
510
version (D_X32 )
511
511
alias long susseconds_t;
512
- else
512
+ else version (CRuntime_Musl_Pre_Time64)
513
513
alias c_long suseconds_t ;
514
+ else
515
+ alias long suseconds_t ;
514
516
}
515
517
else version (CRuntime_UClibc )
516
518
{
You can’t perform that action at this time.
0 commit comments