boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

339-lp64-unsigned-long-constant.c (571B)


      1 /* LP64 integer suffix regression.
      2  *
      3  * tcc 0.9.26 treated one `L` suffix as 64-bit only for x86_64. On
      4  * aarch64/riscv64 that made `-4096UL` become 0x00000000fffff000
      5  * instead of 0xfffffffffffff000, which broke musl's __syscall_ret:
      6  * valid high mmap addresses were classified as syscall errors.
      7  */
      8 
      9 int main(void)
     10 {
     11 	unsigned long u = -12UL;
     12 	unsigned long threshold = -4096UL;
     13 	unsigned long high_user_addr = 0x0000ffff00000000UL;
     14 
     15 	if ((long)u != -12L) return 1;
     16 	if ((long)threshold != -4096L) return 2;
     17 	if (high_user_addr > threshold) return 3;
     18 	return 0;
     19 }