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

Commit b4d6a58

Browse files
ibuclawdlang-bot
authored andcommitted
fix Issue 22822 - core.sys.posix.sys.stat: PPC stat_t bindings corrupt
1 parent 9d205bc commit b4d6a58

File tree

1 file changed

+64
-21
lines changed

1 file changed

+64
-21
lines changed

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

Lines changed: 64 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -388,50 +388,93 @@ version (linux)
388388
{
389389
struct stat_t
390390
{
391-
c_ulong st_dev;
392-
ino_t st_ino;
391+
dev_t st_dev;
392+
static if (!__USE_FILE_OFFSET64)
393+
{
394+
ushort __pad1;
395+
ino_t st_ino;
396+
}
397+
else
398+
ino_t st_ino;
393399
mode_t st_mode;
394400
nlink_t st_nlink;
395401
uid_t st_uid;
396402
gid_t st_gid;
397-
c_ulong st_rdev;
403+
dev_t st_rdev;
404+
ushort __pad2;
398405
off_t st_size;
399-
c_ulong st_blksize;
400-
c_ulong st_blocks;
401-
c_ulong st_atime;
402-
c_ulong st_atime_nsec;
403-
c_ulong st_mtime;
404-
c_ulong st_mtime_nsec;
405-
c_ulong st_ctime;
406-
c_ulong st_ctime_nsec;
406+
blksize_t st_blksize;
407+
blkcnt_t st_blocks;
408+
static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700)
409+
{
410+
timespec st_atim;
411+
timespec st_mtim;
412+
timespec st_ctim;
413+
extern(D) @safe @property inout pure nothrow
414+
{
415+
ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
416+
ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
417+
ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
418+
}
419+
}
420+
else
421+
{
422+
time_t st_atime;
423+
c_ulong st_atimensec;
424+
time_t st_mtime;
425+
c_ulong st_mtimensec;
426+
time_t st_ctime;
427+
c_ulong st_ctimensec;
428+
}
407429
c_ulong __unused4;
408430
c_ulong __unused5;
409431
}
432+
static if (__USE_FILE_OFFSET64)
433+
static assert(stat_t.sizeof == 104);
434+
else
435+
static assert(stat_t.sizeof == 88);
410436
}
411437
else version (PPC64)
412438
{
413439
struct stat_t
414440
{
415-
c_ulong st_dev;
441+
dev_t st_dev;
416442
ino_t st_ino;
417443
nlink_t st_nlink;
418444
mode_t st_mode;
419445
uid_t st_uid;
420446
gid_t st_gid;
421-
c_ulong st_rdev;
447+
int __pad2;
448+
dev_t st_rdev;
422449
off_t st_size;
423-
c_ulong st_blksize;
424-
c_ulong st_blocks;
425-
c_ulong st_atime;
426-
c_ulong st_atime_nsec;
427-
c_ulong st_mtime;
428-
c_ulong st_mtime_nsec;
429-
c_ulong st_ctime;
430-
c_ulong st_ctime_nsec;
450+
blksize_t st_blksize;
451+
blkcnt_t st_blocks;
452+
static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700)
453+
{
454+
timespec st_atim;
455+
timespec st_mtim;
456+
timespec st_ctim;
457+
extern(D) @safe @property inout pure nothrow
458+
{
459+
ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
460+
ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
461+
ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
462+
}
463+
}
464+
else
465+
{
466+
time_t st_atime;
467+
c_ulong st_atimensec;
468+
time_t st_mtime;
469+
c_ulong st_mtimensec;
470+
time_t st_ctime;
471+
c_ulong st_ctimensec;
472+
}
431473
c_ulong __unused4;
432474
c_ulong __unused5;
433475
c_ulong __unused6;
434476
}
477+
static assert(stat_t.sizeof == 144);
435478
}
436479
else version (RISCV_Any)
437480
{

0 commit comments

Comments
 (0)