Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stat_t has wrong size for Android armv7a #4677

Closed
tim-dlang opened this issue Jun 2, 2024 · 2 comments
Closed

stat_t has wrong size for Android armv7a #4677

tim-dlang opened this issue Jun 2, 2024 · 2 comments

Comments

@tim-dlang
Copy link
Contributor

struct stat has size 104 for Android armv7a in C, but struct core.sys.posix.sys.stat.stat_t in D has size 88.

File testc.c:

#include <stdio.h>
#include <sys/stat.h>

int main()
{
    printf("sizeof(stat_t): %zd\n", sizeof(struct stat));
    return 0;
}

Running ~/Android/Sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi30-clang -g -Wall testc.c -Xclang -fdump-record-layouts prints the layout of struct stat:

*** Dumping AST Record Layout
         0 | struct timespec
         0 |   time_t tv_sec
         4 |   long tv_nsec
           | [sizeof=8, align=4]

*** Dumping AST Record Layout
         0 | struct stat
         0 |   unsigned long long st_dev
         8 |   unsigned char[4] __pad0
        12 |   unsigned long __st_ino
        16 |   unsigned int st_mode
        20 |   nlink_t st_nlink
        24 |   uid_t st_uid
        28 |   gid_t st_gid
        32 |   unsigned long long st_rdev
        40 |   unsigned char[4] __pad3
        48 |   long long st_size
        56 |   unsigned long st_blksize
        64 |   unsigned long long st_blocks
        72 |   struct timespec st_atim
        72 |     time_t tv_sec
        76 |     long tv_nsec
        80 |   struct timespec st_mtim
        80 |     time_t tv_sec
        84 |     long tv_nsec
        88 |   struct timespec st_ctim
        88 |     time_t tv_sec
        92 |     long tv_nsec
        96 |   unsigned long long st_ino
           | [sizeof=104, align=8]

File test.d:

import core.sys.posix.sys.stat;
pragma(msg, "stat_t.sizeof: ", stat_t.sizeof);
static foreach(i; 0 .. stat_t.init.tupleof.length)
{
    pragma(msg, "  ",  stat_t.init.tupleof[i].offsetof, " | ", __traits(identifier, stat_t.tupleof[i]), " size=", stat_t.init.tupleof[i].sizeof);
}

Running ldc2 -c -mtriple=armv7a--linux-android30 test.d prints:

stat_t.sizeof: 88u
  0u | st_dev size=8u
  8u | __pad1 size=2u
  12u | st_ino size=4u
  16u | st_mode size=4u
  20u | st_nlink size=4u
  24u | st_uid size=4u
  28u | st_gid size=4u
  32u | st_rdev size=8u
  40u | __pad2 size=2u
  44u | st_size size=4u
  48u | st_blksize size=4u
  52u | st_blocks size=4u
  56u | st_atime size=4u
  60u | st_atimensec size=4u
  64u | st_mtime size=4u
  68u | st_mtimensec size=4u
  72u | st_ctime size=4u
  76u | st_ctimensec size=4u
  80u | __unused4 size=4u
  84u | __unused5 size=4u
@kinke
Copy link
Member

kinke commented Jun 2, 2024

Please file it upstream.

@tim-dlang
Copy link
Contributor Author

Done: https://issues.dlang.org/show_bug.cgi?id=24579

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants