Skip to content

Commit

Permalink
[Y2K38] Support 64-bit time_t as a multilib in headers and libraries
Browse files Browse the repository at this point in the history
The header definition of time_t changes depending on whether
__nanomips_64bit_time_t__ is defined. The compiler is expected
to define this macro when compiling for 64-bit time_t.

Change-Id: I8358cd9666071fac46b6e396b14ec9bd7d3d9eb7
  • Loading branch information
farazs-github committed Aug 13, 2024
1 parent b0f8b83 commit 1972341
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
17 changes: 15 additions & 2 deletions libgloss/mips/uhi/uhi_fstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ fstat (int file, struct stat *sbuf)
__check (__LINE__, offsetof (struct stat, st_blocks) == 80);
__check (__LINE__, offsetof (struct stat, st_spare4) == 88);
#else
__check (__LINE__, sizeof (struct stat) == 60);
__check (__LINE__, offsetof (struct stat, st_dev) == 0);
__check (__LINE__, offsetof (struct stat, st_ino) == 2);
__check (__LINE__, offsetof (struct stat, st_mode) == 4);
__check (__LINE__, offsetof (struct stat, st_nlink) == 8);
__check (__LINE__, offsetof (struct stat, st_uid) == 10);
__check (__LINE__, offsetof (struct stat, st_gid) == 12);
__check (__LINE__, offsetof (struct stat, st_rdev) == 14);
__check (__LINE__, offsetof (struct stat, st_size) == 16);
#ifdef _USE_LONG_TIME_T
__check (__LINE__, sizeof (struct stat) == 60);
__check (__LINE__, offsetof (struct stat, st_atim) == 20);
// __check (__LINE__, offsetof (struct stat, st_spare1) == 24);
__check (__LINE__, offsetof (struct stat, st_mtim) == 28);
Expand All @@ -115,6 +115,19 @@ fstat (int file, struct stat *sbuf)
__check (__LINE__, offsetof (struct stat, st_blksize) == 44);
__check (__LINE__, offsetof (struct stat, st_blocks) == 48);
__check (__LINE__, offsetof (struct stat, st_spare4) == 52);
#else // Using 64-bit time_t
__check (__LINE__, sizeof (struct stat) == 88);
__check (__LINE__, offsetof (struct stat, st_size) == 16);
__check (__LINE__, offsetof (struct stat, st_atim) == 24);
// __check (__LINE__, offsetof (struct stat, st_spare1) == 32);
__check (__LINE__, offsetof (struct stat, st_mtim) == 40);
//__check (__LINE__, offsetof (struct stat, st_spare2) == 48);
__check (__LINE__, offsetof (struct stat, st_ctim) == 56);
//__check (__LINE__, offsetof (struct stat, st_spare3) == 64);
__check (__LINE__, offsetof (struct stat, st_blksize) == 72);
__check (__LINE__, offsetof (struct stat, st_blocks) == 76);
__check (__LINE__, offsetof (struct stat, st_spare4) == 80);
#endif
#endif

__asm__ __volatile__ (" # %0,%1 = fstat(%2, %3) op=%4\n"
Expand Down
19 changes: 16 additions & 3 deletions libgloss/mips/uhi/yamon_fstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,37 @@ fstat (int file, struct stat *sbuf)
__check (__LINE__, offsetof (struct stat, st_blocks) == 80);
__check (__LINE__, offsetof (struct stat, st_spare4) == 88);
#else
__check (__LINE__, sizeof (struct stat) == 60);
__check (__LINE__, offsetof (struct stat, st_dev) == 0);
__check (__LINE__, offsetof (struct stat, st_ino) == 2);
__check (__LINE__, offsetof (struct stat, st_mode) == 4);
__check (__LINE__, offsetof (struct stat, st_nlink) == 8);
__check (__LINE__, offsetof (struct stat, st_uid) == 10);
__check (__LINE__, offsetof (struct stat, st_gid) == 12);
__check (__LINE__, offsetof (struct stat, st_rdev) == 14);
__check (__LINE__, offsetof (struct stat, st_size) == 16);
#ifdef _USE_LONG_TIME_T
__check (__LINE__, sizeof (struct stat) == 60);
__check (__LINE__, offsetof (struct stat, st_atim) == 20);
//__check (__LINE__, offsetof (struct stat, st_spare1) == 24);
// __check (__LINE__, offsetof (struct stat, st_spare1) == 24);
__check (__LINE__, offsetof (struct stat, st_mtim) == 28);
//__check (__LINE__, offsetof (struct stat, st_spare2) == 32);
__check (__LINE__, offsetof (struct stat, st_ctim) == 36);
//__check (__LINE__, offsetof (struct stat, st_spare3) == 40);
__check (__LINE__, offsetof (struct stat, st_blksize) == 44);
__check (__LINE__, offsetof (struct stat, st_blocks) == 48);
__check (__LINE__, offsetof (struct stat, st_spare4) == 52);
#else // Using 64-bit time_t
__check (__LINE__, sizeof (struct stat) == 88);
__check (__LINE__, offsetof (struct stat, st_size) == 16);
__check (__LINE__, offsetof (struct stat, st_atim) == 24);
// __check (__LINE__, offsetof (struct stat, st_spare1) == 32);
__check (__LINE__, offsetof (struct stat, st_mtim) == 40);
//__check (__LINE__, offsetof (struct stat, st_spare2) == 48);
__check (__LINE__, offsetof (struct stat, st_ctim) == 56);
//__check (__LINE__, offsetof (struct stat, st_spare3) == 64);
__check (__LINE__, offsetof (struct stat, st_blksize) == 72);
__check (__LINE__, offsetof (struct stat, st_blocks) == 76);
__check (__LINE__, offsetof (struct stat, st_spare4) == 80);
#endif
#endif

if (file == 0 || file == 1 || file == 2)
Expand Down
3 changes: 3 additions & 0 deletions newlib/libc/include/sys/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@
#endif
#endif

#if defined(__nanomips_64bit_time_t__)
#undef _WANT_USE_LONG_TIME_T
#endif
#ifdef _WANT_USE_LONG_TIME_T
#ifndef _USE_LONG_TIME_T
#define _USE_LONG_TIME_T
Expand Down

0 comments on commit 1972341

Please sign in to comment.