Skip to content

test: check that sizeof is constant#5139

Open
vtjnash wants to merge 2 commits into
libuv:v1.xfrom
vtjnash:jn/sizeof-test
Open

test: check that sizeof is constant#5139
vtjnash wants to merge 2 commits into
libuv:v1.xfrom
vtjnash:jn/sizeof-test

Conversation

@vtjnash
Copy link
Copy Markdown
Member

@vtjnash vtjnash commented May 13, 2026

Create a manual database for CI to make sure that folks cannot accidentally change a struct size on a supported platform. Use ./uv_run_tests sizeof sizeof to regenerate the list. Seemed silly to care a lot about making sure this is correct every release, but not have any tests for it.

Create a manual database for CI to make sure that folks cannot
accidentally change a struct size on a supported platform. Use
`./uv_run_tests sizeof sizeof` to regenerate the list.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vtjnash
Copy link
Copy Markdown
Member Author

vtjnash commented May 13, 2026

Claude also gives us a nice little summary of why some arch are different:

 Linux blocks added:
  - aarch64 (64-bit) — sizes differ from x86_64 only in uv_mutex_t (48 vs 40) and consequently uv_loop_t (856 vs 848), due to glibc's larger pthread_mutex_t on aarch64
  - riscv64 (__riscv && __riscv_xlen == 64) — identical sizes to x86_64
  - arm (32-bit armhf) — differs from i386 in uv_loop_t (472 vs 464), uv_fs_t (296 vs 292), and uv_metrics_t (80 vs 76)

Android blocks added:
An `#if defined(__ANDROID__)` block placed before `#elif defined(__linux__)` (since Android defines both), with four architecture sub-blocks, all measured from the Android NDK r24 / API 24 Bionic libc:

  ┌──────────────┬──────────────────────────────────────────────────────────────────────────────────┐
  │ Architecture │                         Key differences from Linux glibc                         │
  ├──────────────┼──────────────────────────────────────────────────────────────────────────────────┤
  │ x86_64       │ uv_tty_t 288 (vs 312), uv_sem_t 16 (vs 32)                                       │
  ├──────────────┼──────────────────────────────────────────────────────────────────────────────────┤
  │ aarch64      │ Same as Android x86_64; uv_mutex_t 40 (vs 48 on glibc aarch64)                   │
  ├──────────────┼──────────────────────────────────────────────────────────────────────────────────┤
  │ arm (armv7a) │ uv_mutex_t/uv_cond_t/uv_sem_t all 4 bytes (Bionic futex-compact), uv_rwlock_t 40 │
  ├──────────────┼──────────────────────────────────────────────────────────────────────────────────┤
  │ i386         │ Same thread-type compaction as arm; uv_timespec64_t/uv_timeval64_t 12 (vs 16)    │
  └──────────────┴──────────────────────────────────────────────────────────────────────────────────┘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant