File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed
src/glibc/target/include/bits/types
tests/unit-tests/file_tests/deterministic Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change 3232
3333struct timespec
3434{
35- __time64_t tv_sec ; /* Seconds. */
36- long int tv_nsec ; /* Nanoseconds. */
35+ time_t tv_sec ; /* Seconds. */
3736 __int32_t __padding ; /* Padding. */
37+ long int tv_nsec ; /* Nanoseconds. */
38+ __int32_t __padding2 ; /* Padding. */
3839};
3940
4041#endif
Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+ #include <stdlib.h>
3+ #include <time.h>
4+ #include <sys/stat.h>
5+ #include <assert.h>
6+
7+ int main () {
8+ /* Verify struct timespec.tv_sec is time_t (POSIX requirement).
9+ This was broken when the installed header used __time64_t
10+ instead of time_t for tv_sec on wasm32. */
11+
12+ /* 1. sizeof check: tv_sec must be the same size as time_t */
13+ struct timespec ts ;
14+ assert (sizeof (ts .tv_sec ) == sizeof (time_t ));
15+
16+ /* 2. Type compatibility: &ts.tv_sec must be assignable to time_t* */
17+ time_t * tp = & ts .tv_sec ;
18+ (void )tp ;
19+
20+ /* 3. The actual use case that broke: stat + localtime */
21+ struct stat st ;
22+ int ret = stat ("/" , & st );
23+ assert (ret == 0 );
24+
25+ struct tm * tm = localtime (& st .st_mtime );
26+ assert (tm != NULL );
27+
28+ printf ("timespec_time_t_compat: all checks passed\n" );
29+ return 0 ;
30+ }
You can’t perform that action at this time.
0 commit comments