This repository was archived by the owner on Oct 12, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +73
-9
lines changed
Expand file tree Collapse file tree 4 files changed +73
-9
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,27 @@ extern(C):
1313@nogc :
1414nothrow :
1515
16+ version (CRuntime_Musl )
17+ private enum Use_Time64_Values = (time_t .sizeof > c_long.sizeof);
18+ else
19+ private enum Use_Time64_Values = false ;
20+
21+ static if (Use_Time64_Values)
22+ {
23+ // SO_TIMESTAMP_OLD & friends
24+ // https://www.kernel.org/doc/Documentation/networking/timestamping.txt
25+ enum SO_TIMESTAMP = 29 ;
26+ enum SO_TIMESTAMPNS = 35 ;
27+ enum SO_TIMESTAMPING = 37 ;
28+
29+ }
30+ else
31+ {
32+ enum SO_TIMESTAMP = 63 ;
33+ enum SO_TIMESTAMPNS = 64 ;
34+ enum SO_TIMESTAMPING = 65 ;
35+ }
36+
1637enum
1738{
1839 // Protocol families.
@@ -123,14 +144,14 @@ enum
123144 SO_GET_FILTER = SO_ATTACH_FILTER ,
124145
125146 SO_PEERNAME = 28 ,
126- SO_TIMESTAMP = 29 ,
147+ // SO_TIMESTAMP See above
127148 SCM_TIMESTAMP = SO_TIMESTAMP ,
128149
129150 SO_PASSSEC = 34 ,
130- SO_TIMESTAMPNS = 35 ,
151+ // SO_TIMESTAMPNS See above
131152 SCM_TIMESTAMPNS = SO_TIMESTAMPNS ,
132153 SO_MARK = 36 ,
133- SO_TIMESTAMPING = 37 ,
154+ // SO_TIMESTAMPING See above
134155 SCM_TIMESTAMPING = SO_TIMESTAMPING ,
135156 SO_RXQ_OVFL = 40 ,
136157 SO_WIFI_STATUS = 41 ,
Original file line number Diff line number Diff line change @@ -3427,7 +3427,28 @@ struct timespec
34273427}
34283428*/
34293429
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 )
34313452{
34323453 struct timespec
34333454 {
Original file line number Diff line number Diff line change @@ -1706,6 +1706,10 @@ else version (CRuntime_Bionic)
17061706}
17071707else version (CRuntime_Musl )
17081708{
1709+ // version (CRuntime_Musl_Pre_Time64)
1710+ // private enum CRuntime_Musl_Use_Old_Layout = 1;
1711+ // else
1712+
17091713 alias __mode_t = uint ;
17101714 enum {
17111715 S_IRUSR = 0x100 , // octal 0400
@@ -1745,10 +1749,26 @@ else version (CRuntime_Musl)
17451749 blksize_t st_blksize;
17461750 blkcnt_t st_blocks;
17471751
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+ }
17521772
17531773 extern (D ) @safe @property inout pure nothrow
17541774 {
Original file line number Diff line number Diff line change @@ -509,8 +509,10 @@ else version (CRuntime_Musl)
509509 alias uint id_t ;
510510 version (D_X32 )
511511 alias long susseconds_t;
512- else
512+ else version (CRuntime_Musl_Pre_Time64)
513513 alias c_long suseconds_t ;
514+ else
515+ alias long suseconds_t ;
514516}
515517else version (CRuntime_UClibc )
516518{
You can’t perform that action at this time.
0 commit comments