diff --git a/glibc-upstream-2.39-1.patch b/glibc-upstream-2.39-1.patch new file mode 100644 index 0000000..487c192 --- /dev/null +++ b/glibc-upstream-2.39-1.patch @@ -0,0 +1,264 @@ +commit 6d1e3fb07b45e2e31e469b16cf21b24bccf8914c +Author: Andreas K. Hüttel +Date: Wed Jan 31 02:12:43 2024 +0100 + + Replace advisories directory + + Signed-off-by: Andreas K. Hüttel + +diff --git a/ADVISORIES b/ADVISORIES +new file mode 100644 +index 0000000000000000..d4e33f2df3d74cd8 +--- /dev/null ++++ b/ADVISORIES +@@ -0,0 +1,2 @@ ++For the GNU C Library Security Advisories, see the git master branch: ++https://sourceware.org/git/?p=glibc.git;a=tree;f=advisories;hb=HEAD +diff --git a/advisories/GLIBC-SA-2023-0001 b/advisories/GLIBC-SA-2023-0001 +deleted file mode 100644 +index 3d19c91b6a676ffd..0000000000000000 +--- a/advisories/GLIBC-SA-2023-0001 ++++ /dev/null +@@ -1,14 +0,0 @@ +-printf: incorrect output for integers with thousands separator and width field +- +-When the printf family of functions is called with a format specifier +-that uses an (enable grouping) and a minimum width +-specifier, the resulting output could be larger than reasonably expected +-by a caller that computed a tight bound on the buffer size. The +-resulting larger than expected output could result in a buffer overflow +-in the printf family of functions. +- +-CVE-Id: CVE-2023-25139 +-Public-Date: 2023-02-02 +-Vulnerable-Commit: e88b9f0e5cc50cab57a299dc7efe1a4eb385161d (2.37) +-Fix-Commit: c980549cc6a1c03c23cc2fe3e7b0fe626a0364b0 (2.38) +-Fix-Commit: 07b9521fc6369d000216b96562ff7c0ed32a16c4 (2.37-4) +diff --git a/advisories/GLIBC-SA-2023-0002 b/advisories/GLIBC-SA-2023-0002 +deleted file mode 100644 +index 5122669a6451f803..0000000000000000 +--- a/advisories/GLIBC-SA-2023-0002 ++++ /dev/null +@@ -1,15 +0,0 @@ +-getaddrinfo: Stack read overflow in no-aaaa mode +- +-If the system is configured in no-aaaa mode via /etc/resolv.conf, +-getaddrinfo is called for the AF_UNSPEC address family, and a DNS +-response is received over TCP that is larger than 2048 bytes, +-getaddrinfo may potentially disclose stack contents via the returned +-address data, or crash. +- +-CVE-Id: CVE-2023-4527 +-Public-Date: 2023-09-12 +-Vulnerable-Commit: f282cdbe7f436c75864e5640a409a10485e9abb2 (2.36) +-Fix-Commit: bd77dd7e73e3530203be1c52c8a29d08270cb25d (2.39) +-Fix-Commit: 4ea972b7edd7e36610e8cde18bf7a8149d7bac4f (2.36-113) +-Fix-Commit: b7529346025a130fee483d42178b5c118da971bb (2.37-38) +-Fix-Commit: b25508dd774b617f99419bdc3cf2ace4560cd2d6 (2.38-19) +diff --git a/advisories/GLIBC-SA-2023-0003 b/advisories/GLIBC-SA-2023-0003 +deleted file mode 100644 +index d3aef803480bc298..0000000000000000 +--- a/advisories/GLIBC-SA-2023-0003 ++++ /dev/null +@@ -1,15 +0,0 @@ +-getaddrinfo: Potential use-after-free +- +-When an NSS plugin only implements the _gethostbyname2_r and +-_getcanonname_r callbacks, getaddrinfo could use memory that was freed +-during buffer resizing, potentially causing a crash or read or write to +-arbitrary memory. +- +-CVE-Id: CVE-2023-4806 +-Public-Date: 2023-09-12 +-Fix-Commit: 973fe93a5675c42798b2161c6f29c01b0e243994 (2.39) +-Fix-Commit: e09ee267c03e3150c2c9ba28625ab130705a485e (2.34-420) +-Fix-Commit: e3ccb230a961b4797510e6a1f5f21fd9021853e7 (2.35-270) +-Fix-Commit: a9728f798ec7f05454c95637ee6581afaa9b487d (2.36-115) +-Fix-Commit: 6529a7466c935f36e9006b854d6f4e1d4876f942 (2.37-39) +-Fix-Commit: 00ae4f10b504bc4564e9f22f00907093f1ab9338 (2.38-20) +diff --git a/advisories/GLIBC-SA-2023-0004 b/advisories/GLIBC-SA-2023-0004 +deleted file mode 100644 +index 5286a7aa545cd942..0000000000000000 +--- a/advisories/GLIBC-SA-2023-0004 ++++ /dev/null +@@ -1,16 +0,0 @@ +-tunables: local privilege escalation through buffer overflow +- +-If a tunable of the form NAME=NAME=VAL is passed in the environment of a +-setuid program and NAME is valid, it may result in a buffer overflow, +-which could be exploited to achieve escalated privileges. This flaw was +-introduced in glibc 2.34. +- +-CVE-Id: CVE-2023-4911 +-Public-Date: 2023-10-03 +-Vulnerable-Commit: 2ed18c5b534d9e92fc006202a5af0df6b72e7aca (2.34) +-Fix-Commit: 1056e5b4c3f2d90ed2b4a55f96add28da2f4c8fa (2.39) +-Fix-Commit: dcc367f148bc92e7f3778a125f7a416b093964d9 (2.34-423) +-Fix-Commit: c84018a05aec80f5ee6f682db0da1130b0196aef (2.35-274) +-Fix-Commit: 22955ad85186ee05834e47e665056148ca07699c (2.36-118) +-Fix-Commit: b4e23c75aea756b4bddc4abcf27a1c6dca8b6bd3 (2.37-45) +-Fix-Commit: 750a45a783906a19591fb8ff6b7841470f1f5701 (2.38-27) +diff --git a/advisories/GLIBC-SA-2023-0005 b/advisories/GLIBC-SA-2023-0005 +deleted file mode 100644 +index cc4eb90b8283dc14..0000000000000000 +--- a/advisories/GLIBC-SA-2023-0005 ++++ /dev/null +@@ -1,18 +0,0 @@ +-getaddrinfo: DoS due to memory leak +- +-The fix for CVE-2023-4806 introduced a memory leak when an application +-calls getaddrinfo for AF_INET6 with AI_CANONNAME, AI_ALL and AI_V4MAPPED +-flags set. +- +-CVE-Id: CVE-2023-5156 +-Public-Date: 2023-09-25 +-Vulnerable-Commit: e09ee267c03e3150c2c9ba28625ab130705a485e (2.34-420) +-Vulnerable-Commit: e3ccb230a961b4797510e6a1f5f21fd9021853e7 (2.35-270) +-Vulnerable-Commit: a9728f798ec7f05454c95637ee6581afaa9b487d (2.36-115) +-Vulnerable-Commit: 6529a7466c935f36e9006b854d6f4e1d4876f942 (2.37-39) +-Vulnerable-Commit: 00ae4f10b504bc4564e9f22f00907093f1ab9338 (2.38-20) +-Fix-Commit: 8006457ab7e1cd556b919f477348a96fe88f2e49 (2.34-421) +-Fix-Commit: 17092c0311f954e6f3c010f73ce3a78c24ac279a (2.35-272) +-Fix-Commit: 856bac55f98dc840e7c27cfa82262b933385de90 (2.36-116) +-Fix-Commit: 4473d1b87d04b25cdd0e0354814eeaa421328268 (2.37-42) +-Fix-Commit: 5ee59ca371b99984232d7584fe2b1a758b4421d3 (2.38-24) +diff --git a/advisories/GLIBC-SA-2024-0001 b/advisories/GLIBC-SA-2024-0001 +deleted file mode 100644 +index 28931c75ae018cc3..0000000000000000 +--- a/advisories/GLIBC-SA-2024-0001 ++++ /dev/null +@@ -1,15 +0,0 @@ +-syslog: Heap buffer overflow in __vsyslog_internal +- +-__vsyslog_internal did not handle a case where printing a SYSLOG_HEADER +-containing a long program name failed to update the required buffer +-size, leading to the allocation and overflow of a too-small buffer on +-the heap. +- +-CVE-Id: CVE-2023-6246 +-Public-Date: 2024-01-30 +-Vulnerable-Commit: 52a5be0df411ef3ff45c10c7c308cb92993d15b1 (2.37) +-Fix-Commit: 6bd0e4efcc78f3c0115e5ea9739a1642807450da (2.39) +-Fix-Commit: 23514c72b780f3da097ecf33a793b7ba9c2070d2 (2.38-42) +-Fix-Commit: 97a4292aa4a2642e251472b878d0ec4c46a0e59a (2.37-57) +-Vulnerable-Commit: b0e7888d1fa2dbd2d9e1645ec8c796abf78880b9 (2.36-16) +-Fix-Commit: d1a83b6767f68b3cb5b4b4ea2617254acd040c82 (2.36-126) +diff --git a/advisories/GLIBC-SA-2024-0002 b/advisories/GLIBC-SA-2024-0002 +deleted file mode 100644 +index 940bfcf2fcb76050..0000000000000000 +--- a/advisories/GLIBC-SA-2024-0002 ++++ /dev/null +@@ -1,15 +0,0 @@ +-syslog: Heap buffer overflow in __vsyslog_internal +- +-__vsyslog_internal used the return value of snprintf/vsnprintf to +-calculate buffer sizes for memory allocation. If these functions (for +-any reason) failed and returned -1, the resulting buffer would be too +-small to hold output. +- +-CVE-Id: CVE-2023-6779 +-Public-Date: 2024-01-30 +-Vulnerable-Commit: 52a5be0df411ef3ff45c10c7c308cb92993d15b1 (2.37) +-Fix-Commit: 7e5a0c286da33159d47d0122007aac016f3e02cd (2.39) +-Fix-Commit: d0338312aace5bbfef85e03055e1212dd0e49578 (2.38-43) +-Fix-Commit: 67062eccd9a65d7fda9976a56aeaaf6c25a80214 (2.37-58) +-Vulnerable-Commit: b0e7888d1fa2dbd2d9e1645ec8c796abf78880b9 (2.36-16) +-Fix-Commit: 2bc9d7c002bdac38b5c2a3f11b78e309d7765b83 (2.36-127) +diff --git a/advisories/GLIBC-SA-2024-0003 b/advisories/GLIBC-SA-2024-0003 +deleted file mode 100644 +index b43a5150ab1b0cc4..0000000000000000 +--- a/advisories/GLIBC-SA-2024-0003 ++++ /dev/null +@@ -1,13 +0,0 @@ +-syslog: Integer overflow in __vsyslog_internal +- +-__vsyslog_internal calculated a buffer size by adding two integers, but +-did not first check if the addition would overflow. +- +-CVE-Id: CVE-2023-6780 +-Public-Date: 2024-01-30 +-Vulnerable-Commit: 52a5be0df411ef3ff45c10c7c308cb92993d15b1 (2.37) +-Fix-Commit: ddf542da94caf97ff43cc2875c88749880b7259b (2.39) +-Fix-Commit: d37c2b20a4787463d192b32041c3406c2bd91de0 (2.38-44) +-Fix-Commit: 2b58cba076e912961ceaa5fa58588e4b10f791c0 (2.37-59) +-Vulnerable-Commit: b0e7888d1fa2dbd2d9e1645ec8c796abf78880b9 (2.36-16) +-Fix-Commit: b9b7d6a27aa0632f334352fa400771115b3c69b7 (2.36-128) +diff --git a/advisories/README b/advisories/README +deleted file mode 100644 +index 94e68b1350bbad0e..0000000000000000 +--- a/advisories/README ++++ /dev/null +@@ -1,73 +0,0 @@ +-GNU C Library Security Advisory Format +-====================================== +- +-Security advisories in this directory follow a simple git commit log +-format, with a heading and free-format description augmented with tags +-to allow parsing key information. References to code changes are +-specific to the glibc repository and follow a specific format: +- +- Tag-name: (release-version) +- +-The indicates a specific commit in the repository. The +-release-version indicates the publicly consumable release in which this +-commit is known to exist. The release-version is derived from the +-git-describe format, (i.e. stripped out from glibc-2.34.NNN-gxxxx) and +-is of the form 2.34-NNN. If the -NNN suffix is absent, it means that +-the change is in that release tarball, otherwise the change is on the +-release/2.YY/master branch and not in any released tarball. +- +-The following tags are currently being used: +- +-CVE-Id: +-This is the CVE-Id assigned under the CVE Program +-(https://www.cve.org/). +- +-Public-Date: +-The date this issue became publicly known. +- +-Vulnerable-Commit: +-The commit that introduced this vulnerability. There could be multiple +-entries, one for each release branch in the glibc repository; the +-release-version portion of this tag should tell you which branch this is +-on. +- +-Fix-Commit: +-The commit that fixed this vulnerability. There could be multiple +-entries for each release branch in the glibc repository, indicating that +-all of those commits contributed to fixing that issue in each of those +-branches. +- +-Adding an Advisory +------------------- +- +-An advisory for a CVE needs to be added on the master branch in two steps: +- +-1. Add the text of the advisory without any Fix-Commit tags along with +- the fix for the CVE. Add the Vulnerable-Commit tag, if applicable. +- The advisories directory does not exist in release branches, so keep +- the advisory text commit distinct from the code changes, to ease +- backports. Ask for the GLIBC-SA advisory number from the security +- team. +- +-2. Finish all backports on release branches and then back on the msater +- branch, add all commit refs to the advisory using the Fix-Commit +- tags. Don't bother adding the release-version subscript since the +- next step will overwrite it. +- +-3. Run the process-advisories.sh script in the scripts directory on the +- advisory: +- +- scripts/process-advisories.sh update GLIBC-SA-YYYY-NNNN +- +- (replace YYYY-NNNN with the actual advisory number). +- +-4. Verify the updated advisory and push the result. +- +-Getting a NEWS snippet from advisories +--------------------------------------- +- +-Run: +- +- scripts/process-advisories.sh news +- +-and copy the content into the NEWS file. diff --git a/glibc-upstream-2.39-2.patch b/glibc-upstream-2.39-2.patch new file mode 100644 index 0000000..77deb04 --- /dev/null +++ b/glibc-upstream-2.39-2.patch @@ -0,0 +1,35 @@ +commit 63295e4fda1f6dab4bf7442706fe303bf283036c +Author: Adhemerval Zanella +Date: Mon Feb 5 16:10:24 2024 +0000 + + arm: Remove wrong ldr from _dl_start_user (BZ 31339) + + The commit 49d877a80b29d3002887b084eec6676d9f5fec18 (arm: Remove + _dl_skip_args usage) removed the _SKIP_ARGS literal, which was + previously loader to r4 on loader _start. However, the cleanup did not + remove the following 'ldr r4, [sl, r4]' on _dl_start_user, used to check + to skip the arguments after ld self-relocations. + + In my testing, the kernel initially set r4 to 0, which makes the + ldr instruction just read the _GLOBAL_OFFSET_TABLE_. However, since r4 + is a callee-saved register; a different runtime might not zero + initialize it and thus trigger an invalid memory access. + + Checked on arm-linux-gnu. + + Reported-by: Adrian Ratiu + Reviewed-by: Szabolcs Nagy + (cherry picked from commit 1e25112dc0cb2515d27d8d178b1ecce778a9d37a) + +diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h +index b857bbc868ea2ce4..dd1a0f6b6e7a5ea8 100644 +--- a/sysdeps/arm/dl-machine.h ++++ b/sysdeps/arm/dl-machine.h +@@ -139,7 +139,6 @@ _start:\n\ + _dl_start_user:\n\ + adr r6, .L_GET_GOT\n\ + add sl, sl, r6\n\ +- ldr r4, [sl, r4]\n\ + @ save the entry point in another register\n\ + mov r6, r0\n\ + @ get the original arg count\n\ diff --git a/glibc-upstream-2.39-3.patch b/glibc-upstream-2.39-3.patch new file mode 100644 index 0000000..c98c21c --- /dev/null +++ b/glibc-upstream-2.39-3.patch @@ -0,0 +1,78 @@ +commit 312e159626b67fe11f39e83e222cf4348a3962f3 +Author: Adhemerval Zanella +Date: Thu Feb 1 14:29:53 2024 -0300 + + mips: FIx clone3 implementation (BZ 31325) + + For o32 we need to setup a minimal stack frame to allow cprestore + on __thread_start_clone3 (which instruct the linker to save the + gp for PIC). Also, there is no guarantee by kABI that $8 will be + preserved after syscall execution, so we need to save it on the + provided stack. + + Checked on mipsel-linux-gnu. + + Reported-by: Khem Raj + Tested-by: Khem Raj + (cherry picked from commit bbd248ac0d75efdef8fe61ea69b1fb25fb95b6e7) + +diff --git a/sysdeps/unix/sysv/linux/mips/clone3.S b/sysdeps/unix/sysv/linux/mips/clone3.S +index e9fec2fa471b99ba..481b8ae96366fc70 100644 +--- a/sysdeps/unix/sysv/linux/mips/clone3.S ++++ b/sysdeps/unix/sysv/linux/mips/clone3.S +@@ -37,11 +37,6 @@ + + .text + .set nomips16 +-#if _MIPS_SIM == _ABIO32 +-# define EXTRA_LOCALS 1 +-#else +-# define EXTRA_LOCALS 0 +-#endif + #define FRAMESZ ((NARGSAVE*SZREG)+ALSZ)&ALMASK + GPOFF= FRAMESZ-(1*SZREG) + NESTED(__clone3, SZREG, sp) +@@ -68,8 +63,31 @@ NESTED(__clone3, SZREG, sp) + beqz a0, L(error) /* No NULL cl_args pointer. */ + beqz a2, L(error) /* No NULL function pointer. */ + ++#if _MIPS_SIM == _ABIO32 ++ /* Both stack and stack_size on clone_args are defined as uint64_t, and ++ there is no need to handle values larger than to 32 bits for o32. */ ++# if __BYTE_ORDER == __BIG_ENDIAN ++# define CL_STACKPOINTER_OFFSET 44 ++# define CL_STACKSIZE_OFFSET 52 ++# else ++# define CL_STACKPOINTER_OFFSET 40 ++# define CL_STACKSIZE_OFFSET 48 ++# endif ++ ++ /* For o32 we need to setup a minimal stack frame to allow cprestore ++ on __thread_start_clone3. Also there is no guarantee by kABI that ++ $8 will be preserved after syscall execution (so we need to save it ++ on the provided stack). */ ++ lw t0, CL_STACKPOINTER_OFFSET(a0) /* Load the stack pointer. */ ++ lw t1, CL_STACKSIZE_OFFSET(a0) /* Load the stack_size. */ ++ addiu t1, -32 /* Update the stack size. */ ++ addu t2, t1, t0 /* Calculate the thread stack. */ ++ sw a3, 0(t2) /* Save argument pointer. */ ++ sw t1, CL_STACKSIZE_OFFSET(a0) /* Save the new stack size. */ ++#else + move $8, a3 /* a3 is set to 0/1 for syscall success/error + while a4/$8 is returned unmodified. */ ++#endif + + /* Do the system call, the kernel expects: + v0: system call number +@@ -125,7 +143,11 @@ L(thread_start_clone3): + + /* Restore the arg for user's function. */ + move t9, a2 /* Function pointer. */ ++#if _MIPS_SIM == _ABIO32 ++ PTR_L a0, 0(sp) ++#else + move a0, $8 /* Argument pointer. */ ++#endif + + /* Call the user's function. */ + jal t9 diff --git a/glibc-upstream-2.39-4.patch b/glibc-upstream-2.39-4.patch new file mode 100644 index 0000000..cc3350f --- /dev/null +++ b/glibc-upstream-2.39-4.patch @@ -0,0 +1,42 @@ +commit d0724994de40934c552f1f68de89053848a44927 +Author: Xi Ruoyao +Date: Thu Feb 22 21:26:55 2024 +0100 + + math: Update mips64 ulps + + Signed-off-by: Andreas K. Hüttel + (cherry picked from commit e2a65ecc4b30a797df7dc6529f09b712aa256029) + +diff --git a/sysdeps/mips/mips64/libm-test-ulps b/sysdeps/mips/mips64/libm-test-ulps +index 78969745b245d094..933aba47350b777d 100644 +--- a/sysdeps/mips/mips64/libm-test-ulps ++++ b/sysdeps/mips/mips64/libm-test-ulps +@@ -1066,17 +1066,17 @@ double: 1 + ldouble: 1 + + Function: "j0": +-double: 2 ++double: 3 + float: 9 + ldouble: 2 + + Function: "j0_downward": +-double: 5 ++double: 6 + float: 9 + ldouble: 9 + + Function: "j0_towardzero": +-double: 6 ++double: 7 + float: 9 + ldouble: 9 + +@@ -1146,6 +1146,7 @@ float: 6 + ldouble: 8 + + Function: "log": ++double: 1 + float: 1 + ldouble: 1 + diff --git a/glibc-upstream-2.39-5.patch b/glibc-upstream-2.39-5.patch new file mode 100644 index 0000000..92661f6 --- /dev/null +++ b/glibc-upstream-2.39-5.patch @@ -0,0 +1,143 @@ +commit e0910f1d3278f05439fb434ee528fc9be1b6bd5e +Author: Stefan Liebler +Date: Thu Feb 22 15:03:27 2024 +0100 + + S390: Do not clobber r7 in clone [BZ #31402] + + Starting with commit e57d8fc97b90127de4ed3e3a9cdf663667580935 + "S390: Always use svc 0" + clone clobbers the call-saved register r7 in error case: + function or stack is NULL. + + This patch restores the saved registers also in the error case. + Furthermore the existing test misc/tst-clone is extended to check + all error cases and that clone does not clobber registers in this + error case. + + (cherry picked from commit 02782fd12849b6673cb5c2728cb750e8ec295aa3) + +diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/clone.S b/sysdeps/unix/sysv/linux/s390/s390-32/clone.S +index 4c882ef2ee3f5b81..a7a863242c4ebd84 100644 +--- a/sysdeps/unix/sysv/linux/s390/s390-32/clone.S ++++ b/sysdeps/unix/sysv/linux/s390/s390-32/clone.S +@@ -53,6 +53,7 @@ ENTRY(__clone) + br %r14 + error: + lhi %r2,-EINVAL ++ lm %r6,%r7,24(%r15) /* Load registers. */ + j SYSCALL_ERROR_LABEL + PSEUDO_END (__clone) + +diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/clone.S b/sysdeps/unix/sysv/linux/s390/s390-64/clone.S +index 4eb104be71ee565a..c552a6b8decb63de 100644 +--- a/sysdeps/unix/sysv/linux/s390/s390-64/clone.S ++++ b/sysdeps/unix/sysv/linux/s390/s390-64/clone.S +@@ -54,6 +54,7 @@ ENTRY(__clone) + br %r14 + error: + lghi %r2,-EINVAL ++ lmg %r6,%r7,48(%r15) /* Restore registers. */ + jg SYSCALL_ERROR_LABEL + PSEUDO_END (__clone) + +diff --git a/sysdeps/unix/sysv/linux/tst-clone.c b/sysdeps/unix/sysv/linux/tst-clone.c +index 470676ab2bb3fc31..2bc71249837fbb66 100644 +--- a/sysdeps/unix/sysv/linux/tst-clone.c ++++ b/sysdeps/unix/sysv/linux/tst-clone.c +@@ -16,12 +16,16 @@ + License along with the GNU C Library; if not, see + . */ + +-/* BZ #2386 */ ++/* BZ #2386, BZ #31402 */ + #include + #include + #include + #include + #include ++#include /* For _STACK_GROWS_{UP,DOWN}. */ ++#include ++ ++volatile unsigned v = 0xdeadbeef; + + int child_fn(void *arg) + { +@@ -30,22 +34,67 @@ int child_fn(void *arg) + } + + static int +-do_test (void) ++__attribute__((noinline)) ++do_clone (int (*fn)(void *), void *stack) + { + int result; ++ unsigned int a = v; ++ unsigned int b = v; ++ unsigned int c = v; ++ unsigned int d = v; ++ unsigned int e = v; ++ unsigned int f = v; ++ unsigned int g = v; ++ unsigned int h = v; ++ unsigned int i = v; ++ unsigned int j = v; ++ unsigned int k = v; ++ unsigned int l = v; ++ unsigned int m = v; ++ unsigned int n = v; ++ unsigned int o = v; ++ ++ result = clone (fn, stack, 0, NULL); ++ ++ /* Check that clone does not clobber call-saved registers. */ ++ TEST_VERIFY (a == v && b == v && c == v && d == v && e == v && f == v ++ && g == v && h == v && i == v && j == v && k == v && l == v ++ && m == v && n == v && o == v); ++ ++ return result; ++} ++ ++static void ++__attribute__((noinline)) ++do_test_single (int (*fn)(void *), void *stack) ++{ ++ printf ("%s (fn=%p, stack=%p)\n", __FUNCTION__, fn, stack); ++ errno = 0; ++ ++ int result = do_clone (fn, stack); ++ ++ TEST_COMPARE (errno, EINVAL); ++ TEST_COMPARE (result, -1); ++} + +- result = clone (child_fn, NULL, 0, NULL); ++static int ++do_test (void) ++{ ++ char st[128 * 1024] __attribute__ ((aligned)); ++ void *stack = NULL; ++#if _STACK_GROWS_DOWN ++ stack = st + sizeof (st); ++#elif _STACK_GROWS_UP ++ stack = st; ++#else ++# error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP" ++#endif + +- if (errno != EINVAL || result != -1) +- { +- printf ("FAIL: clone()=%d (wanted -1) errno=%d (wanted %d)\n", +- result, errno, EINVAL); +- return 1; +- } ++ do_test_single (child_fn, NULL); ++ do_test_single (NULL, stack); ++ do_test_single (NULL, NULL); + +- puts ("All OK"); + return 0; + } + +-#define TEST_FUNCTION do_test () +-#include "../test-skeleton.c" ++#include diff --git a/glibc-upstream-2.39-6.patch b/glibc-upstream-2.39-6.patch new file mode 100644 index 0000000..61f4133 --- /dev/null +++ b/glibc-upstream-2.39-6.patch @@ -0,0 +1,1052 @@ +commit 1b9c1a0047fb26a65a9b2a7b8cd977243f7d353c +Author: Jakub Jelinek +Date: Wed Jan 31 19:17:27 2024 +0100 + + Use gcc __builtin_stdc_* builtins in stdbit.h if possible + + The following patch uses the GCC 14 __builtin_stdc_* builtins in stdbit.h + for the type-generic macros, so that when compiled with GCC 14 or later, + it supports not just 8/16/32/64-bit unsigned integers, but also 128-bit + (if target supports them) and unsigned _BitInt (any supported precision). + And so that the macros don't expand arguments multiple times and can be + evaluated in constant expressions. + + The new testcase is gcc's gcc/testsuite/gcc.dg/builtin-stdc-bit-1.c + adjusted to test stdbit.h and the type-generic macros in there instead + of the builtins and adjusted to use glibc test framework rather than + gcc style tests with __builtin_abort (). + + Signed-off-by: Jakub Jelinek + Reviewed-by: Joseph Myers + (cherry picked from commit da89496337b97e6a2aaf1e81d55cf998f6db1070) + +diff --git a/manual/stdbit.texi b/manual/stdbit.texi +index fe41c671d8f8f7d9..6c75ed9a20444132 100644 +--- a/manual/stdbit.texi ++++ b/manual/stdbit.texi +@@ -32,7 +32,13 @@ and @code{unsigned long long int}. In addition, there is a + corresponding type-generic macro (not listed below), named the same as + the functions but without any suffix such as @samp{_uc}. The + type-generic macro can only be used with an argument of an unsigned +-integer type with a width of 8, 16, 32 or 64 bits. ++integer type with a width of 8, 16, 32 or 64 bits, or when using ++a compiler with support for ++@uref{https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html,@code{__builtin_stdc_bit_ceil}}, ++etc.@:, built-in functions such as GCC 14.1 or later ++any unsigned integer type those built-in functions support. ++In GCC 14.1 that includes support for @code{unsigned __int128} and ++@code{unsigned _BitInt(@var{n})} if supported by the target. + + @deftypefun {unsigned int} stdc_leading_zeros_uc (unsigned char @var{x}) + @deftypefunx {unsigned int} stdc_leading_zeros_us (unsigned short @var{x}) +diff --git a/stdlib/Makefile b/stdlib/Makefile +index d587f054d198a173..9898cc5d8a560625 100644 +--- a/stdlib/Makefile ++++ b/stdlib/Makefile +@@ -308,6 +308,7 @@ tests := \ + tst-setcontext10 \ + tst-setcontext11 \ + tst-stdbit-Wconversion \ ++ tst-stdbit-builtins \ + tst-stdc_bit_ceil \ + tst-stdc_bit_floor \ + tst-stdc_bit_width \ +diff --git a/stdlib/stdbit.h b/stdlib/stdbit.h +index f334eb174d209c82..2801590c63006ad2 100644 +--- a/stdlib/stdbit.h ++++ b/stdlib/stdbit.h +@@ -64,9 +64,13 @@ extern unsigned int stdc_leading_zeros_ul (unsigned long int __x) + __extension__ + extern unsigned int stdc_leading_zeros_ull (unsigned long long int __x) + __THROW __attribute_const__; +-#define stdc_leading_zeros(x) \ ++#if __glibc_has_builtin (__builtin_stdc_leading_zeros) ++# define stdc_leading_zeros(x) (__builtin_stdc_leading_zeros (x)) ++#else ++# define stdc_leading_zeros(x) \ + (stdc_leading_zeros_ull (x) \ + - (unsigned int) (8 * (sizeof (0ULL) - sizeof (x)))) ++#endif + + #if __GNUC_PREREQ (3, 4) || __glibc_has_builtin (__builtin_clzll) + static __always_inline unsigned int +@@ -116,9 +120,13 @@ extern unsigned int stdc_leading_ones_ul (unsigned long int __x) + __extension__ + extern unsigned int stdc_leading_ones_ull (unsigned long long int __x) + __THROW __attribute_const__; +-#define stdc_leading_ones(x) \ ++#if __glibc_has_builtin (__builtin_stdc_leading_ones) ++# define stdc_leading_ones(x) (__builtin_stdc_leading_ones (x)) ++#else ++# define stdc_leading_ones(x) \ + (stdc_leading_ones_ull ((unsigned long long int) (x) \ + << 8 * (sizeof (0ULL) - sizeof (x)))) ++#endif + + #if __GNUC_PREREQ (3, 4) || __glibc_has_builtin (__builtin_clzll) + static __always_inline unsigned int +@@ -168,11 +176,15 @@ extern unsigned int stdc_trailing_zeros_ul (unsigned long int __x) + __extension__ + extern unsigned int stdc_trailing_zeros_ull (unsigned long long int __x) + __THROW __attribute_const__; +-#define stdc_trailing_zeros(x) \ ++#if __glibc_has_builtin (__builtin_stdc_trailing_zeros) ++# define stdc_trailing_zeros(x) (__builtin_stdc_trailing_zeros (x)) ++#else ++# define stdc_trailing_zeros(x) \ + (sizeof (x) == 8 ? stdc_trailing_zeros_ull (x) \ + : sizeof (x) == 4 ? stdc_trailing_zeros_ui (x) \ + : sizeof (x) == 2 ? stdc_trailing_zeros_us (__pacify_uint16 (x)) \ + : stdc_trailing_zeros_uc (__pacify_uint8 (x))) ++#endif + + #if __GNUC_PREREQ (3, 4) || __glibc_has_builtin (__builtin_ctzll) + static __always_inline unsigned int +@@ -222,7 +234,11 @@ extern unsigned int stdc_trailing_ones_ul (unsigned long int __x) + __extension__ + extern unsigned int stdc_trailing_ones_ull (unsigned long long int __x) + __THROW __attribute_const__; +-#define stdc_trailing_ones(x) (stdc_trailing_ones_ull (x)) ++#if __glibc_has_builtin (__builtin_stdc_trailing_ones) ++# define stdc_trailing_ones(x) (__builtin_stdc_trailing_ones (x)) ++#else ++# define stdc_trailing_ones(x) (stdc_trailing_ones_ull (x)) ++#endif + + #if __GNUC_PREREQ (3, 4) || __glibc_has_builtin (__builtin_ctzll) + static __always_inline unsigned int +@@ -272,11 +288,15 @@ extern unsigned int stdc_first_leading_zero_ul (unsigned long int __x) + __extension__ + extern unsigned int stdc_first_leading_zero_ull (unsigned long long int __x) + __THROW __attribute_const__; +-#define stdc_first_leading_zero(x) \ ++#if __glibc_has_builtin (__builtin_stdc_first_leading_zero) ++# define stdc_first_leading_zero(x) (__builtin_stdc_first_leading_zero (x)) ++#else ++# define stdc_first_leading_zero(x) \ + (sizeof (x) == 8 ? stdc_first_leading_zero_ull (x) \ + : sizeof (x) == 4 ? stdc_first_leading_zero_ui (x) \ + : sizeof (x) == 2 ? stdc_first_leading_zero_us (__pacify_uint16 (x)) \ + : stdc_first_leading_zero_uc (__pacify_uint8 (x))) ++#endif + + #if __GNUC_PREREQ (3, 4) || __glibc_has_builtin (__builtin_clzll) + static __always_inline unsigned int +@@ -326,11 +346,15 @@ extern unsigned int stdc_first_leading_one_ul (unsigned long int __x) + __extension__ + extern unsigned int stdc_first_leading_one_ull (unsigned long long int __x) + __THROW __attribute_const__; +-#define stdc_first_leading_one(x) \ ++#if __glibc_has_builtin (__builtin_stdc_first_leading_one) ++# define stdc_first_leading_one(x) (__builtin_stdc_first_leading_one (x)) ++#else ++# define stdc_first_leading_one(x) \ + (sizeof (x) == 8 ? stdc_first_leading_one_ull (x) \ + : sizeof (x) == 4 ? stdc_first_leading_one_ui (x) \ + : sizeof (x) == 2 ? stdc_first_leading_one_us (__pacify_uint16 (x)) \ + : stdc_first_leading_one_uc (__pacify_uint8 (x))) ++#endif + + #if __GNUC_PREREQ (3, 4) || __glibc_has_builtin (__builtin_clzll) + static __always_inline unsigned int +@@ -380,11 +404,15 @@ extern unsigned int stdc_first_trailing_zero_ul (unsigned long int __x) + __extension__ + extern unsigned int stdc_first_trailing_zero_ull (unsigned long long int __x) + __THROW __attribute_const__; +-#define stdc_first_trailing_zero(x) \ ++#if __glibc_has_builtin (__builtin_stdc_first_trailing_zero) ++# define stdc_first_trailing_zero(x) (__builtin_stdc_first_trailing_zero (x)) ++#else ++# define stdc_first_trailing_zero(x) \ + (sizeof (x) == 8 ? stdc_first_trailing_zero_ull (x) \ + : sizeof (x) == 4 ? stdc_first_trailing_zero_ui (x) \ + : sizeof (x) == 2 ? stdc_first_trailing_zero_us (__pacify_uint16 (x)) \ + : stdc_first_trailing_zero_uc (__pacify_uint8 (x))) ++#endif + + #if __GNUC_PREREQ (3, 4) || __glibc_has_builtin (__builtin_ctzll) + static __always_inline unsigned int +@@ -434,11 +462,15 @@ extern unsigned int stdc_first_trailing_one_ul (unsigned long int __x) + __extension__ + extern unsigned int stdc_first_trailing_one_ull (unsigned long long int __x) + __THROW __attribute_const__; +-#define stdc_first_trailing_one(x) \ ++#if __glibc_has_builtin (__builtin_stdc_first_trailing_one) ++# define stdc_first_trailing_one(x) (__builtin_stdc_first_trailing_one (x)) ++#else ++# define stdc_first_trailing_one(x) \ + (sizeof (x) == 8 ? stdc_first_trailing_one_ull (x) \ + : sizeof (x) == 4 ? stdc_first_trailing_one_ui (x) \ + : sizeof (x) == 2 ? stdc_first_trailing_one_us (__pacify_uint16 (x)) \ + : stdc_first_trailing_one_uc (__pacify_uint8 (x))) ++#endif + + #if __GNUC_PREREQ (3, 4) || __glibc_has_builtin (__builtin_ctzll) + static __always_inline unsigned int +@@ -488,9 +520,13 @@ extern unsigned int stdc_count_zeros_ul (unsigned long int __x) + __extension__ + extern unsigned int stdc_count_zeros_ull (unsigned long long int __x) + __THROW __attribute_const__; +-#define stdc_count_zeros(x) \ ++#if __glibc_has_builtin (__builtin_stdc_count_zeros) ++# define stdc_count_zeros(x) (__builtin_stdc_count_zeros (x)) ++#else ++# define stdc_count_zeros(x) \ + (stdc_count_zeros_ull (x) \ + - (unsigned int) (8 * (sizeof (0ULL) - sizeof (x)))) ++#endif + + #if __GNUC_PREREQ (3, 4) || __glibc_has_builtin (__builtin_popcountll) + static __always_inline unsigned int +@@ -540,7 +576,11 @@ extern unsigned int stdc_count_ones_ul (unsigned long int __x) + __extension__ + extern unsigned int stdc_count_ones_ull (unsigned long long int __x) + __THROW __attribute_const__; +-#define stdc_count_ones(x) (stdc_count_ones_ull (x)) ++#if __glibc_has_builtin (__builtin_stdc_count_ones) ++# define stdc_count_ones(x) (__builtin_stdc_count_ones (x)) ++#else ++# define stdc_count_ones(x) (stdc_count_ones_ull (x)) ++#endif + + #if __GNUC_PREREQ (3, 4) || __glibc_has_builtin (__builtin_popcountll) + static __always_inline unsigned int +@@ -590,10 +630,14 @@ extern bool stdc_has_single_bit_ul (unsigned long int __x) + __extension__ + extern bool stdc_has_single_bit_ull (unsigned long long int __x) + __THROW __attribute_const__; +-#define stdc_has_single_bit(x) \ ++#if __glibc_has_builtin (__builtin_stdc_has_single_bit) ++# define stdc_has_single_bit(x) (__builtin_stdc_has_single_bit (x)) ++#else ++# define stdc_has_single_bit(x) \ + ((bool) (sizeof (x) <= sizeof (unsigned int) \ + ? stdc_has_single_bit_ui (x) \ + : stdc_has_single_bit_ull (x))) ++#endif + + static __always_inline bool + __hsb64_inline (uint64_t __x) +@@ -641,7 +685,11 @@ extern unsigned int stdc_bit_width_ul (unsigned long int __x) + __extension__ + extern unsigned int stdc_bit_width_ull (unsigned long long int __x) + __THROW __attribute_const__; +-#define stdc_bit_width(x) (stdc_bit_width_ull (x)) ++#if __glibc_has_builtin (__builtin_stdc_bit_width) ++# define stdc_bit_width(x) (__builtin_stdc_bit_width (x)) ++#else ++# define stdc_bit_width(x) (stdc_bit_width_ull (x)) ++#endif + + #if __GNUC_PREREQ (3, 4) || __glibc_has_builtin (__builtin_clzll) + static __always_inline unsigned int +@@ -691,7 +739,11 @@ extern unsigned long int stdc_bit_floor_ul (unsigned long int __x) + __extension__ + extern unsigned long long int stdc_bit_floor_ull (unsigned long long int __x) + __THROW __attribute_const__; +-#define stdc_bit_floor(x) ((__typeof (x)) stdc_bit_floor_ull (x)) ++#if __glibc_has_builtin (__builtin_stdc_bit_floor) ++# define stdc_bit_floor(x) (__builtin_stdc_bit_floor (x)) ++#else ++# define stdc_bit_floor(x) ((__typeof (x)) stdc_bit_floor_ull (x)) ++#endif + + #if __GNUC_PREREQ (3, 4) || __glibc_has_builtin (__builtin_clzll) + static __always_inline uint64_t +@@ -743,7 +795,11 @@ extern unsigned long int stdc_bit_ceil_ul (unsigned long int __x) + __extension__ + extern unsigned long long int stdc_bit_ceil_ull (unsigned long long int __x) + __THROW __attribute_const__; +-#define stdc_bit_ceil(x) ((__typeof (x)) stdc_bit_ceil_ull (x)) ++#if __glibc_has_builtin (__builtin_stdc_bit_ceil) ++# define stdc_bit_ceil(x) (__builtin_stdc_bit_ceil (x)) ++#else ++# define stdc_bit_ceil(x) ((__typeof (x)) stdc_bit_ceil_ull (x)) ++#endif + + #if __GNUC_PREREQ (3, 4) || __glibc_has_builtin (__builtin_clzll) + static __always_inline uint64_t +diff --git a/stdlib/tst-stdbit-builtins.c b/stdlib/tst-stdbit-builtins.c +new file mode 100644 +index 0000000000000000..536841ca8ac3425b +--- /dev/null ++++ b/stdlib/tst-stdbit-builtins.c +@@ -0,0 +1,778 @@ ++/* Test type-generic macros with compiler __builtin_stdc_* support. ++ Copyright (C) 2024 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, see ++ . */ ++ ++#include ++#include ++#include ++ ++#if __glibc_has_builtin (__builtin_stdc_leading_zeros) \ ++ && __glibc_has_builtin (__builtin_stdc_leading_ones) \ ++ && __glibc_has_builtin (__builtin_stdc_trailing_zeros) \ ++ && __glibc_has_builtin (__builtin_stdc_trailing_ones) \ ++ && __glibc_has_builtin (__builtin_stdc_first_leading_zero) \ ++ && __glibc_has_builtin (__builtin_stdc_first_leading_one) \ ++ && __glibc_has_builtin (__builtin_stdc_first_trailing_zero) \ ++ && __glibc_has_builtin (__builtin_stdc_first_trailing_one) \ ++ && __glibc_has_builtin (__builtin_stdc_count_zeros) \ ++ && __glibc_has_builtin (__builtin_stdc_count_ones) \ ++ && __glibc_has_builtin (__builtin_stdc_has_single_bit) \ ++ && __glibc_has_builtin (__builtin_stdc_bit_width) \ ++ && __glibc_has_builtin (__builtin_stdc_bit_floor) \ ++ && __glibc_has_builtin (__builtin_stdc_bit_ceil) ++ ++# if !defined (BITINT_MAXWIDTH) && defined (__BITINT_MAXWIDTH__) ++# define BITINT_MAXWIDTH __BITINT_MAXWIDTH__ ++# endif ++ ++typedef unsigned char uc; ++typedef unsigned short us; ++typedef unsigned int ui; ++typedef unsigned long int ul; ++typedef unsigned long long int ull; ++ ++# define expr_has_type(e, t) _Generic (e, default : 0, t : 1) ++ ++static int ++do_test (void) ++{ ++ TEST_COMPARE (stdc_leading_zeros ((uc) 0), CHAR_BIT); ++ TEST_COMPARE (expr_has_type (stdc_leading_zeros ((uc) 0), ui), 1); ++ TEST_COMPARE (stdc_leading_zeros ((us) 0), sizeof (short) * CHAR_BIT); ++ TEST_COMPARE (expr_has_type (stdc_leading_zeros ((us) 0), ui), 1); ++ TEST_COMPARE (stdc_leading_zeros (0U), sizeof (int) * CHAR_BIT); ++ TEST_COMPARE (expr_has_type (stdc_leading_zeros (0U), ui), 1); ++ TEST_COMPARE (stdc_leading_zeros (0UL), sizeof (long int) * CHAR_BIT); ++ TEST_COMPARE (expr_has_type (stdc_leading_zeros (0UL), ui), 1); ++ TEST_COMPARE (stdc_leading_zeros (0ULL), sizeof (long long int) * CHAR_BIT); ++ TEST_COMPARE (expr_has_type (stdc_leading_zeros (0ULL), ui), 1); ++ TEST_COMPARE (stdc_leading_zeros ((uc) ~0U), 0); ++ TEST_COMPARE (stdc_leading_zeros ((us) ~0U), 0); ++ TEST_COMPARE (stdc_leading_zeros (~0U), 0); ++ TEST_COMPARE (stdc_leading_zeros (~0UL), 0); ++ TEST_COMPARE (stdc_leading_zeros (~0ULL), 0); ++ TEST_COMPARE (stdc_leading_zeros ((uc) 3), CHAR_BIT - 2); ++ TEST_COMPARE (stdc_leading_zeros ((us) 9), sizeof (short) * CHAR_BIT - 4); ++ TEST_COMPARE (stdc_leading_zeros (34U), sizeof (int) * CHAR_BIT - 6); ++ TEST_COMPARE (stdc_leading_zeros (130UL), sizeof (long int) * CHAR_BIT - 8); ++ TEST_COMPARE (stdc_leading_zeros (512ULL), ++ sizeof (long long int) * CHAR_BIT - 10); ++ TEST_COMPARE (stdc_leading_ones ((uc) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_leading_ones ((uc) 0), ui), 1); ++ TEST_COMPARE (stdc_leading_ones ((us) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_leading_ones ((us) 0), ui), 1); ++ TEST_COMPARE (stdc_leading_ones (0U), 0); ++ TEST_COMPARE (expr_has_type (stdc_leading_ones (0U), ui), 1); ++ TEST_COMPARE (stdc_leading_ones (0UL), 0); ++ TEST_COMPARE (expr_has_type (stdc_leading_ones (0UL), ui), 1); ++ TEST_COMPARE (stdc_leading_ones (0ULL), 0); ++ TEST_COMPARE (expr_has_type (stdc_leading_ones (0ULL), ui), 1); ++ TEST_COMPARE (stdc_leading_ones ((uc) ~0U), CHAR_BIT); ++ TEST_COMPARE (stdc_leading_ones ((us) ~0U), sizeof (short) * CHAR_BIT); ++ TEST_COMPARE (stdc_leading_ones (~0U), sizeof (int) * CHAR_BIT); ++ TEST_COMPARE (stdc_leading_ones (~0UL), sizeof (long int) * CHAR_BIT); ++ TEST_COMPARE (stdc_leading_ones (~0ULL), sizeof (long long int) * CHAR_BIT); ++ TEST_COMPARE (stdc_leading_ones ((uc) ~3), CHAR_BIT - 2); ++ TEST_COMPARE (stdc_leading_ones ((us) ~9), sizeof (short) * CHAR_BIT - 4); ++ TEST_COMPARE (stdc_leading_ones (~34U), sizeof (int) * CHAR_BIT - 6); ++ TEST_COMPARE (stdc_leading_ones (~130UL), sizeof (long int) * CHAR_BIT - 8); ++ TEST_COMPARE (stdc_leading_ones (~512ULL), ++ sizeof (long long int) * CHAR_BIT - 10); ++ TEST_COMPARE (stdc_trailing_zeros ((uc) 0), CHAR_BIT); ++ TEST_COMPARE (expr_has_type (stdc_trailing_zeros ((uc) 0), ui), 1); ++ TEST_COMPARE (stdc_trailing_zeros ((us) 0), sizeof (short) * CHAR_BIT); ++ TEST_COMPARE (expr_has_type (stdc_trailing_zeros ((us) 0), ui), 1); ++ TEST_COMPARE (stdc_trailing_zeros (0U), sizeof (int) * CHAR_BIT); ++ TEST_COMPARE (expr_has_type (stdc_trailing_zeros (0U), ui), 1); ++ TEST_COMPARE (stdc_trailing_zeros (0UL), sizeof (long int) * CHAR_BIT); ++ TEST_COMPARE (expr_has_type (stdc_trailing_zeros (0UL), ui), 1); ++ TEST_COMPARE (stdc_trailing_zeros (0ULL), sizeof (long long int) * CHAR_BIT); ++ TEST_COMPARE (expr_has_type (stdc_trailing_zeros (0ULL), ui), 1); ++ TEST_COMPARE (stdc_trailing_zeros ((uc) ~0U), 0); ++ TEST_COMPARE (stdc_trailing_zeros ((us) ~0U), 0); ++ TEST_COMPARE (stdc_trailing_zeros (~0U), 0); ++ TEST_COMPARE (stdc_trailing_zeros (~0UL), 0); ++ TEST_COMPARE (stdc_trailing_zeros (~0ULL), 0); ++ TEST_COMPARE (stdc_trailing_zeros ((uc) 2), 1); ++ TEST_COMPARE (stdc_trailing_zeros ((us) 24), 3); ++ TEST_COMPARE (stdc_trailing_zeros (32U), 5); ++ TEST_COMPARE (stdc_trailing_zeros (128UL), 7); ++ TEST_COMPARE (stdc_trailing_zeros (512ULL), 9); ++ TEST_COMPARE (stdc_trailing_ones ((uc) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_trailing_ones ((uc) 0), ui), 1); ++ TEST_COMPARE (stdc_trailing_ones ((us) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_trailing_ones ((us) 0), ui), 1); ++ TEST_COMPARE (stdc_trailing_ones (0U), 0); ++ TEST_COMPARE (expr_has_type (stdc_trailing_ones (0U), ui), 1); ++ TEST_COMPARE (stdc_trailing_ones (0UL), 0); ++ TEST_COMPARE (expr_has_type (stdc_trailing_ones (0UL), ui), 1); ++ TEST_COMPARE (stdc_trailing_ones (0ULL), 0); ++ TEST_COMPARE (expr_has_type (stdc_trailing_ones (0ULL), ui), 1); ++ TEST_COMPARE (stdc_trailing_ones ((uc) ~0U), CHAR_BIT); ++ TEST_COMPARE (stdc_trailing_ones ((us) ~0U), sizeof (short) * CHAR_BIT); ++ TEST_COMPARE (stdc_trailing_ones (~0U), sizeof (int) * CHAR_BIT); ++ TEST_COMPARE (stdc_trailing_ones (~0UL), sizeof (long int) * CHAR_BIT); ++ TEST_COMPARE (stdc_trailing_ones (~0ULL), sizeof (long long int) * CHAR_BIT); ++ TEST_COMPARE (stdc_trailing_ones ((uc) 5), 1); ++ TEST_COMPARE (stdc_trailing_ones ((us) 15), 4); ++ TEST_COMPARE (stdc_trailing_ones (127U), 7); ++ TEST_COMPARE (stdc_trailing_ones (511UL), 9); ++ TEST_COMPARE (stdc_trailing_ones (~0ULL >> 2), ++ sizeof (long long int) * CHAR_BIT - 2); ++ TEST_COMPARE (stdc_first_leading_zero ((uc) 0), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_zero ((uc) 0), ui), 1); ++ TEST_COMPARE (stdc_first_leading_zero ((us) 0), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_zero ((us) 0), ui), 1); ++ TEST_COMPARE (stdc_first_leading_zero (0U), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_zero (0U), ui), 1); ++ TEST_COMPARE (stdc_first_leading_zero (0UL), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_zero (0UL), ui), 1); ++ TEST_COMPARE (stdc_first_leading_zero (0ULL), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_zero (0ULL), ui), 1); ++ TEST_COMPARE (stdc_first_leading_zero ((uc) ~0U), 0); ++ TEST_COMPARE (stdc_first_leading_zero ((us) ~0U), 0); ++ TEST_COMPARE (stdc_first_leading_zero (~0U), 0); ++ TEST_COMPARE (stdc_first_leading_zero (~0UL), 0); ++ TEST_COMPARE (stdc_first_leading_zero (~0ULL), 0); ++ TEST_COMPARE (stdc_first_leading_zero ((uc) ~3U), CHAR_BIT - 1); ++ TEST_COMPARE (stdc_first_leading_zero ((us) ~15U), ++ sizeof (short) * CHAR_BIT - 3); ++ TEST_COMPARE (stdc_first_leading_zero (~63U), sizeof (int) * CHAR_BIT - 5); ++ TEST_COMPARE (stdc_first_leading_zero (~255UL), ++ sizeof (long int) * CHAR_BIT - 7); ++ TEST_COMPARE (stdc_first_leading_zero (~1023ULL), ++ sizeof (long long int) * CHAR_BIT - 9); ++ TEST_COMPARE (stdc_first_leading_one ((uc) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_one ((uc) 0), ui), 1); ++ TEST_COMPARE (stdc_first_leading_one ((us) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_one ((us) 0), ui), 1); ++ TEST_COMPARE (stdc_first_leading_one (0U), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_one (0U), ui), 1); ++ TEST_COMPARE (stdc_first_leading_one (0UL), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_one (0UL), ui), 1); ++ TEST_COMPARE (stdc_first_leading_one (0ULL), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_one (0ULL), ui), 1); ++ TEST_COMPARE (stdc_first_leading_one ((uc) ~0U), 1); ++ TEST_COMPARE (stdc_first_leading_one ((us) ~0U), 1); ++ TEST_COMPARE (stdc_first_leading_one (~0U), 1); ++ TEST_COMPARE (stdc_first_leading_one (~0UL), 1); ++ TEST_COMPARE (stdc_first_leading_one (~0ULL), 1); ++ TEST_COMPARE (stdc_first_leading_one ((uc) 3), CHAR_BIT - 1); ++ TEST_COMPARE (stdc_first_leading_one ((us) 9), ++ sizeof (short) * CHAR_BIT - 3); ++ TEST_COMPARE (stdc_first_leading_one (34U), sizeof (int) * CHAR_BIT - 5); ++ TEST_COMPARE (stdc_first_leading_one (130UL), ++ sizeof (long int) * CHAR_BIT - 7); ++ TEST_COMPARE (stdc_first_leading_one (512ULL), ++ sizeof (long long int) * CHAR_BIT - 9); ++ TEST_COMPARE (stdc_first_trailing_zero ((uc) 0), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_zero ((uc) 0), ui), 1); ++ TEST_COMPARE (stdc_first_trailing_zero ((us) 0), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_zero ((us) 0), ui), 1); ++ TEST_COMPARE (stdc_first_trailing_zero (0U), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_zero (0U), ui), 1); ++ TEST_COMPARE (stdc_first_trailing_zero (0UL), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_zero (0UL), ui), 1); ++ TEST_COMPARE (stdc_first_trailing_zero (0ULL), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_zero (0ULL), ui), 1); ++ TEST_COMPARE (stdc_first_trailing_zero ((uc) ~0U), 0); ++ TEST_COMPARE (stdc_first_trailing_zero ((us) ~0U), 0); ++ TEST_COMPARE (stdc_first_trailing_zero (~0U), 0); ++ TEST_COMPARE (stdc_first_trailing_zero (~0UL), 0); ++ TEST_COMPARE (stdc_first_trailing_zero (~0ULL), 0); ++ TEST_COMPARE (stdc_first_trailing_zero ((uc) 2), 1); ++ TEST_COMPARE (stdc_first_trailing_zero ((us) 15), 5); ++ TEST_COMPARE (stdc_first_trailing_zero (63U), 7); ++ TEST_COMPARE (stdc_first_trailing_zero (128UL), 1); ++ TEST_COMPARE (stdc_first_trailing_zero (511ULL), 10); ++ TEST_COMPARE (stdc_first_trailing_one ((uc) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_one ((uc) 0), ui), 1); ++ TEST_COMPARE (stdc_first_trailing_one ((us) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_one ((us) 0), ui), 1); ++ TEST_COMPARE (stdc_first_trailing_one (0U), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_one (0U), ui), 1); ++ TEST_COMPARE (stdc_first_trailing_one (0UL), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_one (0UL), ui), 1); ++ TEST_COMPARE (stdc_first_trailing_one (0ULL), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_one (0ULL), ui), 1); ++ TEST_COMPARE (stdc_first_trailing_one ((uc) ~0U), 1); ++ TEST_COMPARE (stdc_first_trailing_one ((us) ~0U), 1); ++ TEST_COMPARE (stdc_first_trailing_one (~0U), 1); ++ TEST_COMPARE (stdc_first_trailing_one (~0UL), 1); ++ TEST_COMPARE (stdc_first_trailing_one (~0ULL), 1); ++ TEST_COMPARE (stdc_first_trailing_one ((uc) 4), 3); ++ TEST_COMPARE (stdc_first_trailing_one ((us) 96), 6); ++ TEST_COMPARE (stdc_first_trailing_one (127U), 1); ++ TEST_COMPARE (stdc_first_trailing_one (511UL), 1); ++ TEST_COMPARE (stdc_first_trailing_one (~0ULL << 12), 13); ++ TEST_COMPARE (stdc_count_zeros ((uc) 0), CHAR_BIT); ++ TEST_COMPARE (expr_has_type (stdc_count_zeros ((uc) 0), ui), 1); ++ TEST_COMPARE (stdc_count_zeros ((us) 0), sizeof (short) * CHAR_BIT); ++ TEST_COMPARE (expr_has_type (stdc_count_zeros ((us) 0), ui), 1); ++ TEST_COMPARE (stdc_count_zeros (0U), sizeof (int) * CHAR_BIT); ++ TEST_COMPARE (expr_has_type (stdc_count_zeros (0U), ui), 1); ++ TEST_COMPARE (stdc_count_zeros (0UL), sizeof (long int) * CHAR_BIT); ++ TEST_COMPARE (expr_has_type (stdc_count_zeros (0UL), ui), 1); ++ TEST_COMPARE (stdc_count_zeros (0ULL), sizeof (long long int) * CHAR_BIT); ++ TEST_COMPARE (expr_has_type (stdc_count_zeros (0ULL), ui), 1); ++ TEST_COMPARE (stdc_count_zeros ((uc) ~0U), 0); ++ TEST_COMPARE (stdc_count_zeros ((us) ~0U), 0); ++ TEST_COMPARE (stdc_count_zeros (~0U), 0); ++ TEST_COMPARE (stdc_count_zeros (~0UL), 0); ++ TEST_COMPARE (stdc_count_zeros (~0ULL), 0); ++ TEST_COMPARE (stdc_count_zeros ((uc) 1U), CHAR_BIT - 1); ++ TEST_COMPARE (stdc_count_zeros ((us) 42), sizeof (short) * CHAR_BIT - 3); ++ TEST_COMPARE (stdc_count_zeros (291U), sizeof (int) * CHAR_BIT - 4); ++ TEST_COMPARE (stdc_count_zeros (~1315UL), 5); ++ TEST_COMPARE (stdc_count_zeros (3363ULL), ++ sizeof (long long int) * CHAR_BIT - 6); ++ TEST_COMPARE (stdc_count_ones ((uc) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_count_ones ((uc) 0), ui), 1); ++ TEST_COMPARE (stdc_count_ones ((us) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_count_ones ((us) 0), ui), 1); ++ TEST_COMPARE (stdc_count_ones (0U), 0); ++ TEST_COMPARE (expr_has_type (stdc_count_ones (0U), ui), 1); ++ TEST_COMPARE (stdc_count_ones (0UL), 0); ++ TEST_COMPARE (expr_has_type (stdc_count_ones (0UL), ui), 1); ++ TEST_COMPARE (stdc_count_ones (0ULL), 0); ++ TEST_COMPARE (expr_has_type (stdc_count_ones (0ULL), ui), 1); ++ TEST_COMPARE (stdc_count_ones ((uc) ~0U), CHAR_BIT); ++ TEST_COMPARE (stdc_count_ones ((us) ~0U), sizeof (short) * CHAR_BIT); ++ TEST_COMPARE (stdc_count_ones (~0U), sizeof (int) * CHAR_BIT); ++ TEST_COMPARE (stdc_count_ones (~0UL), sizeof (long int) * CHAR_BIT); ++ TEST_COMPARE (stdc_count_ones (~0ULL), sizeof (long long int) * CHAR_BIT); ++ TEST_COMPARE (stdc_count_ones ((uc) ~1U), CHAR_BIT - 1); ++ TEST_COMPARE (stdc_count_ones ((us) ~42), sizeof (short) * CHAR_BIT - 3); ++ TEST_COMPARE (stdc_count_ones (~291U), sizeof (int) * CHAR_BIT - 4); ++ TEST_COMPARE (stdc_count_ones (1315UL), 5); ++ TEST_COMPARE (stdc_count_ones (~3363ULL), ++ sizeof (long long int) * CHAR_BIT - 6); ++ TEST_COMPARE (stdc_has_single_bit ((uc) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_has_single_bit ((uc) 0), _Bool), 1); ++ TEST_COMPARE (stdc_has_single_bit ((us) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_has_single_bit ((us) 0), _Bool), 1); ++ TEST_COMPARE (stdc_has_single_bit (0U), 0); ++ TEST_COMPARE (expr_has_type (stdc_has_single_bit (0U), _Bool), 1); ++ TEST_COMPARE (stdc_has_single_bit (0UL), 0); ++ TEST_COMPARE (expr_has_type (stdc_has_single_bit (0UL), _Bool), 1); ++ TEST_COMPARE (stdc_has_single_bit (0ULL), 0); ++ TEST_COMPARE (expr_has_type (stdc_has_single_bit (0ULL), _Bool), 1); ++ TEST_COMPARE (stdc_has_single_bit ((uc) 2), 1); ++ TEST_COMPARE (stdc_has_single_bit ((us) 8), 1); ++ TEST_COMPARE (stdc_has_single_bit (32U), 1); ++ TEST_COMPARE (stdc_has_single_bit (128UL), 1); ++ TEST_COMPARE (stdc_has_single_bit (512ULL), 1); ++ TEST_COMPARE (stdc_has_single_bit ((uc) 7), 0); ++ TEST_COMPARE (stdc_has_single_bit ((us) 96), 0); ++ TEST_COMPARE (stdc_has_single_bit (513U), 0); ++ TEST_COMPARE (stdc_has_single_bit (1022UL), 0); ++ TEST_COMPARE (stdc_has_single_bit (12ULL), 0); ++ TEST_COMPARE (stdc_bit_width ((uc) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_bit_width ((uc) 0), ui), 1); ++ TEST_COMPARE (stdc_bit_width ((us) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_bit_width ((us) 0), ui), 1); ++ TEST_COMPARE (stdc_bit_width (0U), 0); ++ TEST_COMPARE (expr_has_type (stdc_bit_width (0U), ui), 1); ++ TEST_COMPARE (stdc_bit_width (0UL), 0); ++ TEST_COMPARE (expr_has_type (stdc_bit_width (0UL), ui), 1); ++ TEST_COMPARE (stdc_bit_width (0ULL), 0); ++ TEST_COMPARE (expr_has_type (stdc_bit_width (0ULL), ui), 1); ++ TEST_COMPARE (stdc_bit_width ((uc) ~0U), CHAR_BIT); ++ TEST_COMPARE (stdc_bit_width ((us) ~0U), sizeof (short) * CHAR_BIT); ++ TEST_COMPARE (stdc_bit_width (~0U), sizeof (int) * CHAR_BIT); ++ TEST_COMPARE (stdc_bit_width (~0UL), sizeof (long int) * CHAR_BIT); ++ TEST_COMPARE (stdc_bit_width (~0ULL), sizeof (long long int) * CHAR_BIT); ++ TEST_COMPARE (stdc_bit_width ((uc) ((uc) ~0U >> 1)), CHAR_BIT - 1); ++ TEST_COMPARE (stdc_bit_width ((uc) 6), 3); ++ TEST_COMPARE (stdc_bit_width ((us) 12U), 4); ++ TEST_COMPARE (stdc_bit_width ((us) ((us) ~0U >> 5)), ++ sizeof (short) * CHAR_BIT - 5); ++ TEST_COMPARE (stdc_bit_width (137U), 8); ++ TEST_COMPARE (stdc_bit_width (269U), 9); ++ TEST_COMPARE (stdc_bit_width (39UL), 6); ++ TEST_COMPARE (stdc_bit_width (~0UL >> 2), sizeof (long int) * CHAR_BIT - 2); ++ TEST_COMPARE (stdc_bit_width (1023ULL), 10); ++ TEST_COMPARE (stdc_bit_width (1024ULL), 11); ++ TEST_COMPARE (stdc_bit_floor ((uc) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_bit_floor ((uc) 0), uc), 1); ++ TEST_COMPARE (stdc_bit_floor ((us) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_bit_floor ((us) 0), us), 1); ++ TEST_COMPARE (stdc_bit_floor (0U), 0U); ++ TEST_COMPARE (expr_has_type (stdc_bit_floor (0U), ui), 1); ++ TEST_COMPARE (stdc_bit_floor (0UL), 0UL); ++ TEST_COMPARE (expr_has_type (stdc_bit_floor (0UL), ul), 1); ++ TEST_COMPARE (stdc_bit_floor (0ULL), 0ULL); ++ TEST_COMPARE (expr_has_type (stdc_bit_floor (0ULL), ull), 1); ++ TEST_COMPARE (stdc_bit_floor ((uc) ~0U), (1U << (CHAR_BIT - 1))); ++ TEST_COMPARE (stdc_bit_floor ((us) ~0U), ++ (1U << (sizeof (short) * CHAR_BIT - 1))); ++ TEST_COMPARE (stdc_bit_floor (~0U), (1U << (sizeof (int) * CHAR_BIT - 1))); ++ TEST_COMPARE (stdc_bit_floor (~0UL), ++ (1UL << (sizeof (long int) * CHAR_BIT - 1))); ++ TEST_COMPARE (stdc_bit_floor (~0ULL), ++ (1ULL << (sizeof (long long int) * CHAR_BIT - 1))); ++ TEST_COMPARE (stdc_bit_floor ((uc) 4), 4); ++ TEST_COMPARE (stdc_bit_floor ((uc) 7), 4); ++ TEST_COMPARE (stdc_bit_floor ((us) 8U), 8); ++ TEST_COMPARE (stdc_bit_floor ((us) 31U), 16); ++ TEST_COMPARE (stdc_bit_floor (137U), 128U); ++ TEST_COMPARE (stdc_bit_floor (269U), 256U); ++ TEST_COMPARE (stdc_bit_floor (511UL), 256UL); ++ TEST_COMPARE (stdc_bit_floor (512UL), 512UL); ++ TEST_COMPARE (stdc_bit_floor (513UL), 512ULL); ++ TEST_COMPARE (stdc_bit_floor (1024ULL), 1024ULL); ++ TEST_COMPARE (stdc_bit_ceil ((uc) 0), 1); ++ TEST_COMPARE (expr_has_type (stdc_bit_ceil ((uc) 0), uc), 1); ++ TEST_COMPARE (stdc_bit_ceil ((us) 0), 1); ++ TEST_COMPARE (expr_has_type (stdc_bit_ceil ((us) 0), us), 1); ++ TEST_COMPARE (stdc_bit_ceil (0U), 1U); ++ TEST_COMPARE (expr_has_type (stdc_bit_ceil (0U), ui), 1); ++ TEST_COMPARE (stdc_bit_ceil (0UL), 1UL); ++ TEST_COMPARE (expr_has_type (stdc_bit_ceil (0UL), ul), 1); ++ TEST_COMPARE (stdc_bit_ceil (0ULL), 1ULL); ++ TEST_COMPARE (expr_has_type (stdc_bit_ceil (0ULL), ull), 1); ++ TEST_COMPARE (stdc_bit_ceil ((uc) ~0U), 0); ++ TEST_COMPARE (stdc_bit_ceil ((us) ~0U), 0); ++ TEST_COMPARE (stdc_bit_ceil (~0U), 0U); ++ TEST_COMPARE (stdc_bit_ceil (~0UL), 0UL); ++ TEST_COMPARE (stdc_bit_ceil (~0ULL), 0ULL); ++ TEST_COMPARE (stdc_bit_ceil ((uc) ((uc) ~0U >> 1)), (1U << (CHAR_BIT - 1))); ++ TEST_COMPARE (stdc_bit_ceil ((uc) ((uc) ~0U >> 1)), (1U << (CHAR_BIT - 1))); ++ TEST_COMPARE (stdc_bit_ceil ((us) ((us) ~0U >> 1)), ++ (1U << (sizeof (short) * CHAR_BIT - 1))); ++ TEST_COMPARE (stdc_bit_ceil ((us) ((us) ~0U >> 1)), ++ (1U << (sizeof (short) * CHAR_BIT - 1))); ++ TEST_COMPARE (stdc_bit_ceil (~0U >> 1), ++ (1U << (sizeof (int) * CHAR_BIT - 1))); ++ TEST_COMPARE (stdc_bit_ceil (1U << (sizeof (int) * CHAR_BIT - 1)), ++ (1U << (sizeof (int) * CHAR_BIT - 1))); ++ TEST_COMPARE (stdc_bit_ceil (~0UL >> 1), ++ (1UL << (sizeof (long int) * CHAR_BIT - 1))); ++ TEST_COMPARE (stdc_bit_ceil (~0UL >> 1), ++ (1UL << (sizeof (long int) * CHAR_BIT - 1))); ++ TEST_COMPARE (stdc_bit_ceil (1ULL ++ << (sizeof (long long int) * CHAR_BIT - 1)), ++ (1ULL << (sizeof (long long int) * CHAR_BIT - 1))); ++ TEST_COMPARE (stdc_bit_ceil (~0ULL >> 1), ++ (1ULL << (sizeof (long long int) * CHAR_BIT - 1))); ++ TEST_COMPARE (stdc_bit_ceil ((uc) 1), 1); ++ TEST_COMPARE (stdc_bit_ceil ((uc) 2), 2); ++ TEST_COMPARE (stdc_bit_ceil ((us) 3U), 4); ++ TEST_COMPARE (stdc_bit_ceil ((us) 4U), 4); ++ TEST_COMPARE (stdc_bit_ceil (5U), 8U); ++ TEST_COMPARE (stdc_bit_ceil (269U), 512U); ++ TEST_COMPARE (stdc_bit_ceil (511UL), 512UL); ++ TEST_COMPARE (stdc_bit_ceil (512UL), 512UL); ++ TEST_COMPARE (stdc_bit_ceil (513ULL), 1024ULL); ++ TEST_COMPARE (stdc_bit_ceil (1025ULL), 2048ULL); ++# ifdef __SIZEOF_INT128__ ++ TEST_COMPARE (stdc_leading_zeros ((unsigned __int128) 0), ++ sizeof (__int128) * CHAR_BIT); ++ TEST_COMPARE (expr_has_type (stdc_leading_zeros ((unsigned __int128) 0), ui), ++ 1); ++ TEST_COMPARE (stdc_leading_zeros (~(unsigned __int128) 0), 0); ++ TEST_COMPARE (stdc_leading_ones ((unsigned __int128) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_leading_ones ((unsigned __int128) 0), ui), ++ 1); ++ TEST_COMPARE (stdc_leading_ones (~(unsigned __int128) 0), ++ sizeof (__int128) * CHAR_BIT); ++ TEST_COMPARE (stdc_trailing_zeros ((unsigned __int128) 0), ++ sizeof (__int128) * CHAR_BIT); ++ TEST_COMPARE (expr_has_type (stdc_trailing_zeros ((unsigned __int128) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_trailing_zeros (~(unsigned __int128) 0), 0); ++ TEST_COMPARE (stdc_trailing_ones ((unsigned __int128) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_trailing_ones ((unsigned __int128) 0), ui), ++ 1); ++ TEST_COMPARE (stdc_trailing_ones (~(unsigned __int128) 0), ++ sizeof (__int128) * CHAR_BIT); ++ TEST_COMPARE (stdc_first_leading_zero ((unsigned __int128) 0), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_zero ((unsigned __int128) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_first_leading_zero (~(unsigned __int128) 0), 0); ++ TEST_COMPARE (stdc_first_leading_one ((unsigned __int128) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_one ((unsigned __int128) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_first_leading_one (~(unsigned __int128) 0), 1); ++ TEST_COMPARE (stdc_first_trailing_zero ((unsigned __int128) 0), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_zero ((unsigned __int128) ++ 0), ui), 1); ++ TEST_COMPARE (stdc_first_trailing_zero (~(unsigned __int128) 0), 0); ++ TEST_COMPARE (stdc_first_trailing_one ((unsigned __int128) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_one ((unsigned __int128) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_first_trailing_one (~(unsigned __int128) 0), 1); ++ TEST_COMPARE (stdc_count_zeros ((unsigned __int128) 0), ++ sizeof (__int128) * CHAR_BIT); ++ TEST_COMPARE (expr_has_type (stdc_count_zeros ((unsigned __int128) 0), ui), ++ 1); ++ TEST_COMPARE (stdc_count_zeros (~(unsigned __int128) 0), 0); ++ TEST_COMPARE (stdc_count_ones ((unsigned __int128) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_count_ones ((unsigned __int128) 0), ui), ++ 1); ++ TEST_COMPARE (stdc_count_ones (~(unsigned __int128) 0), ++ sizeof (__int128) * CHAR_BIT); ++ TEST_COMPARE (stdc_has_single_bit ((unsigned __int128) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_has_single_bit ((unsigned __int128) 0), ++ _Bool), 1); ++ TEST_COMPARE (stdc_has_single_bit (~(unsigned __int128) 0), 0); ++ TEST_COMPARE (stdc_bit_width ((unsigned __int128) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_bit_width ((unsigned __int128) 0), ui), 1); ++ TEST_COMPARE (stdc_bit_width (~(unsigned __int128) 0), ++ sizeof (__int128) * CHAR_BIT); ++ TEST_COMPARE (stdc_bit_floor ((unsigned __int128) 0) != 0, 0); ++ TEST_COMPARE (expr_has_type (stdc_bit_floor ((unsigned __int128) 0), ++ unsigned __int128), 1); ++ TEST_COMPARE (stdc_bit_floor (~(unsigned __int128) 0) ++ != ((unsigned __int128) 1) << (sizeof (__int128) ++ * CHAR_BIT - 1), 0); ++ TEST_COMPARE (stdc_bit_ceil ((unsigned __int128) 0) != 1, 0); ++ TEST_COMPARE (expr_has_type (stdc_bit_ceil ((unsigned __int128) 0), ++ unsigned __int128), 1); ++ TEST_COMPARE (stdc_bit_ceil ((unsigned __int128) 1) != 1, 0); ++ TEST_COMPARE (stdc_bit_ceil ((~(unsigned __int128) 0) >> 1) ++ != ((unsigned __int128) 1) << (sizeof (__int128) ++ * CHAR_BIT - 1), 0); ++ TEST_COMPARE (stdc_bit_ceil (~(unsigned __int128) 0) != 0, 0); ++# endif ++ uc a = 0; ++ TEST_COMPARE (stdc_bit_width (a++), 0); ++ TEST_COMPARE (a, 1); ++ ull b = 0; ++ TEST_COMPARE (stdc_bit_width (b++), 0); ++ TEST_COMPARE (b, 1); ++ TEST_COMPARE (stdc_bit_floor (a++), 1); ++ TEST_COMPARE (a, 2); ++ TEST_COMPARE (stdc_bit_floor (b++), 1); ++ TEST_COMPARE (b, 2); ++ TEST_COMPARE (stdc_bit_ceil (a++), 2); ++ TEST_COMPARE (a, 3); ++ TEST_COMPARE (stdc_bit_ceil (b++), 2); ++ TEST_COMPARE (b, 3); ++ TEST_COMPARE (stdc_leading_zeros (a++), CHAR_BIT - 2); ++ TEST_COMPARE (a, 4); ++ TEST_COMPARE (stdc_leading_zeros (b++), ++ sizeof (long long int) * CHAR_BIT - 2); ++ TEST_COMPARE (b, 4); ++ TEST_COMPARE (stdc_leading_ones (a++), 0); ++ TEST_COMPARE (a, 5); ++ TEST_COMPARE (stdc_leading_ones (b++), 0); ++ TEST_COMPARE (b, 5); ++ TEST_COMPARE (stdc_trailing_zeros (a++), 0); ++ TEST_COMPARE (a, 6); ++ TEST_COMPARE (stdc_trailing_zeros (b++), 0); ++ TEST_COMPARE (b, 6); ++ TEST_COMPARE (stdc_trailing_ones (a++), 0); ++ TEST_COMPARE (a, 7); ++ TEST_COMPARE (stdc_trailing_ones (b++), 0); ++ TEST_COMPARE (b, 7); ++ TEST_COMPARE (stdc_first_leading_zero (a++), 1); ++ TEST_COMPARE (a, 8); ++ TEST_COMPARE (stdc_first_leading_zero (b++), 1); ++ TEST_COMPARE (b, 8); ++ TEST_COMPARE (stdc_first_leading_one (a++), CHAR_BIT - 3); ++ TEST_COMPARE (a, 9); ++ TEST_COMPARE (stdc_first_leading_one (b++), ++ sizeof (long long int) * CHAR_BIT - 3); ++ TEST_COMPARE (b, 9); ++ TEST_COMPARE (stdc_first_trailing_zero (a++), 2); ++ TEST_COMPARE (a, 10); ++ TEST_COMPARE (stdc_first_trailing_zero (b++), 2); ++ TEST_COMPARE (b, 10); ++ TEST_COMPARE (stdc_first_trailing_one (a++), 2); ++ TEST_COMPARE (a, 11); ++ TEST_COMPARE (stdc_first_trailing_one (b++), 2); ++ TEST_COMPARE (b, 11); ++ TEST_COMPARE (stdc_count_zeros (a++), CHAR_BIT - 3); ++ TEST_COMPARE (a, 12); ++ TEST_COMPARE (stdc_count_zeros (b++), ++ sizeof (long long int) * CHAR_BIT - 3); ++ TEST_COMPARE (b, 12); ++ TEST_COMPARE (stdc_count_ones (a++), 2); ++ TEST_COMPARE (a, 13); ++ TEST_COMPARE (stdc_count_ones (b++), 2); ++ TEST_COMPARE (b, 13); ++ TEST_COMPARE (stdc_has_single_bit (a++), 0); ++ TEST_COMPARE (a, 14); ++ TEST_COMPARE (stdc_has_single_bit (b++), 0); ++ TEST_COMPARE (b, 14); ++# ifdef BITINT_MAXWIDTH ++# if BITINT_MAXWIDTH >= 64 ++ TEST_COMPARE (stdc_leading_zeros (0uwb), 1); ++ TEST_COMPARE (expr_has_type (stdc_leading_zeros (0uwb), ui), 1); ++ TEST_COMPARE (stdc_leading_zeros (1uwb), 0); ++ TEST_COMPARE (expr_has_type (stdc_leading_zeros (1uwb), ui), 1); ++ TEST_COMPARE (stdc_leading_ones (0uwb), 0); ++ TEST_COMPARE (expr_has_type (stdc_leading_ones (0uwb), ui), 1); ++ TEST_COMPARE (stdc_leading_ones (1uwb), 1); ++ TEST_COMPARE (expr_has_type (stdc_leading_ones (1uwb), ui), 1); ++ TEST_COMPARE (stdc_trailing_zeros (0uwb), 1); ++ TEST_COMPARE (expr_has_type (stdc_trailing_zeros (0uwb), ui), 1); ++ TEST_COMPARE (stdc_trailing_zeros (1uwb), 0); ++ TEST_COMPARE (expr_has_type (stdc_trailing_zeros (1uwb), ui), 1); ++ TEST_COMPARE (stdc_trailing_ones (0uwb), 0); ++ TEST_COMPARE (expr_has_type (stdc_trailing_ones (0uwb), ui), 1); ++ TEST_COMPARE (stdc_trailing_ones (1uwb), 1); ++ TEST_COMPARE (expr_has_type (stdc_trailing_ones (1uwb), ui), 1); ++ TEST_COMPARE (stdc_first_leading_zero (0uwb), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_zero (0uwb), ui), 1); ++ TEST_COMPARE (stdc_first_leading_zero (1uwb), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_zero (1uwb), ui), 1); ++ TEST_COMPARE (stdc_first_leading_one (0uwb), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_one (0uwb), ui), 1); ++ TEST_COMPARE (stdc_first_leading_one (1uwb), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_one (1uwb), ui), 1); ++ TEST_COMPARE (stdc_first_trailing_zero (0uwb), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_zero (0uwb), ui), 1); ++ TEST_COMPARE (stdc_first_trailing_zero (1uwb), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_zero (1uwb), ui), 1); ++ TEST_COMPARE (stdc_first_trailing_one (0uwb), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_one (0uwb), ui), 1); ++ TEST_COMPARE (stdc_first_trailing_one (1uwb), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_one (1uwb), ui), 1); ++ TEST_COMPARE (stdc_count_zeros (0uwb), 1); ++ TEST_COMPARE (expr_has_type (stdc_count_zeros (0uwb), ui), 1); ++ TEST_COMPARE (stdc_count_zeros (1uwb), 0); ++ TEST_COMPARE (expr_has_type (stdc_count_zeros (1uwb), ui), 1); ++ TEST_COMPARE (stdc_count_ones (0uwb), 0); ++ TEST_COMPARE (expr_has_type (stdc_count_ones (0uwb), ui), 1); ++ TEST_COMPARE (stdc_count_ones (1uwb), 1); ++ TEST_COMPARE (expr_has_type (stdc_count_ones (1uwb), ui), 1); ++ TEST_COMPARE (stdc_has_single_bit (0uwb), 0); ++ TEST_COMPARE (expr_has_type (stdc_has_single_bit (0uwb), _Bool), 1); ++ TEST_COMPARE (stdc_has_single_bit (1uwb), 1); ++ TEST_COMPARE (expr_has_type (stdc_has_single_bit (1uwb), _Bool), 1); ++ TEST_COMPARE (stdc_bit_width (0uwb), 0); ++ TEST_COMPARE (expr_has_type (stdc_bit_width (0uwb), ui), 1); ++ TEST_COMPARE (stdc_bit_width (1uwb), 1); ++ TEST_COMPARE (expr_has_type (stdc_bit_width (1uwb), ui), 1); ++ TEST_COMPARE (stdc_bit_floor (0uwb), 0); ++ TEST_COMPARE (expr_has_type (stdc_bit_floor (0uwb), unsigned _BitInt(1)), 1); ++ TEST_COMPARE (stdc_bit_floor (1uwb), 1); ++ TEST_COMPARE (expr_has_type (stdc_bit_floor (1uwb), unsigned _BitInt(1)), 1); ++ TEST_COMPARE (stdc_bit_ceil (0uwb), 1); ++ TEST_COMPARE (expr_has_type (stdc_bit_ceil (0uwb), unsigned _BitInt(1)), 1); ++ TEST_COMPARE (stdc_bit_ceil (1uwb), 1); ++ TEST_COMPARE (expr_has_type (stdc_bit_ceil (1uwb), unsigned _BitInt(1)), 1); ++ unsigned _BitInt(1) c = 0; ++ TEST_COMPARE (stdc_bit_floor (c++), 0); ++ TEST_COMPARE (c, 1); ++ TEST_COMPARE (stdc_bit_floor (c++), 1); ++ TEST_COMPARE (c, 0); ++ TEST_COMPARE (stdc_bit_ceil (c++), 1); ++ TEST_COMPARE (c, 1); ++ TEST_COMPARE (stdc_bit_ceil (c++), 1); ++ TEST_COMPARE (c, 0); ++# endif ++# if BITINT_MAXWIDTH >= 512 ++ TEST_COMPARE (stdc_leading_zeros ((unsigned _BitInt(512)) 0), 512); ++ TEST_COMPARE (expr_has_type (stdc_leading_zeros ((unsigned _BitInt(512)) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_leading_zeros ((unsigned _BitInt(373)) 0), 373); ++ TEST_COMPARE (expr_has_type (stdc_leading_zeros ((unsigned _BitInt(373)) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_leading_zeros (~(unsigned _BitInt(512)) 0), 0); ++ TEST_COMPARE (stdc_leading_zeros (~(unsigned _BitInt(373)) 0), 0); ++ TEST_COMPARE (stdc_leading_zeros ((unsigned _BitInt(512)) 275), 512 - 9); ++ TEST_COMPARE (stdc_leading_zeros ((unsigned _BitInt(373)) 512), 373 - 10); ++ TEST_COMPARE (stdc_leading_ones ((unsigned _BitInt(512)) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_leading_ones ((unsigned _BitInt(512)) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_leading_ones ((unsigned _BitInt(373)) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_leading_ones ((unsigned _BitInt(373)) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_leading_ones (~(unsigned _BitInt(512)) 0), 512); ++ TEST_COMPARE (stdc_leading_ones (~(unsigned _BitInt(373)) 0), 373); ++ TEST_COMPARE (stdc_leading_ones (~(unsigned _BitInt(512)) 275), 512 - 9); ++ TEST_COMPARE (stdc_leading_ones (~(unsigned _BitInt(373)) 512), 373 - 10); ++ TEST_COMPARE (stdc_trailing_zeros ((unsigned _BitInt(512)) 0), 512); ++ TEST_COMPARE (expr_has_type (stdc_trailing_zeros ((unsigned _BitInt(512)) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_trailing_zeros ((unsigned _BitInt(373)) 0), 373); ++ TEST_COMPARE (expr_has_type (stdc_trailing_zeros ((unsigned _BitInt(373)) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_trailing_zeros (~(unsigned _BitInt(512)) 0), 0); ++ TEST_COMPARE (stdc_trailing_zeros (~(unsigned _BitInt(373)) 0), 0); ++ TEST_COMPARE (stdc_trailing_zeros ((unsigned _BitInt(512)) 256), 8); ++ TEST_COMPARE (stdc_trailing_zeros ((unsigned _BitInt(373)) 512), 9); ++ TEST_COMPARE (stdc_trailing_ones ((unsigned _BitInt(512)) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_trailing_ones ((unsigned _BitInt(512)) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_trailing_ones ((unsigned _BitInt(373)) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_trailing_ones ((unsigned _BitInt(373)) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_trailing_ones (~(unsigned _BitInt(512)) 0), 512); ++ TEST_COMPARE (stdc_trailing_ones (~(unsigned _BitInt(373)) 0), 373); ++ TEST_COMPARE (stdc_trailing_ones ((unsigned _BitInt(512)) 255), 8); ++ TEST_COMPARE (stdc_trailing_ones ((~(unsigned _BitInt(373)) 0) >> 2), ++ 373 - 2); ++ TEST_COMPARE (stdc_first_leading_zero ((unsigned _BitInt(512)) 0), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_zero ((unsigned _BitInt(512)) ++ 0), ui), 1); ++ TEST_COMPARE (stdc_first_leading_zero ((unsigned _BitInt(373)) 0), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_zero ((unsigned _BitInt(373)) ++ 0), ui), 1); ++ TEST_COMPARE (stdc_first_leading_zero (~(unsigned _BitInt(512)) 0), 0); ++ TEST_COMPARE (stdc_first_leading_zero (~(unsigned _BitInt(373)) 0), 0); ++ TEST_COMPARE (stdc_first_leading_zero (~(unsigned _BitInt(512)) 511), ++ 512 - 8); ++ TEST_COMPARE (stdc_first_leading_zero (~(unsigned _BitInt(373)) 1023), ++ 373 - 9); ++ TEST_COMPARE (stdc_first_leading_one ((unsigned _BitInt(512)) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_one ((unsigned _BitInt(512)) ++ 0), ui), 1); ++ TEST_COMPARE (stdc_first_leading_one ((unsigned _BitInt(373)) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_leading_one ((unsigned _BitInt(373)) ++ 0), ui), 1); ++ TEST_COMPARE (stdc_first_leading_one (~(unsigned _BitInt(512)) 0), 1); ++ TEST_COMPARE (stdc_first_leading_one (~(unsigned _BitInt(373)) 0), 1); ++ TEST_COMPARE (stdc_first_leading_one ((unsigned _BitInt(512)) 275), 512 - 8); ++ TEST_COMPARE (stdc_first_leading_one ((unsigned _BitInt(373)) 512), 373 - 9); ++ TEST_COMPARE (stdc_first_trailing_zero ((unsigned _BitInt(512)) 0), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_zero ((unsigned ++ _BitInt(512)) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_first_trailing_zero ((unsigned _BitInt(373)) 0), 1); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_zero ((unsigned ++ _BitInt(373)) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_first_trailing_zero (~(unsigned _BitInt(512)) 0), 0); ++ TEST_COMPARE (stdc_first_trailing_zero (~(unsigned _BitInt(373)) 0), 0); ++ TEST_COMPARE (stdc_first_trailing_zero ((unsigned _BitInt(512)) 255), 9); ++ TEST_COMPARE (stdc_first_trailing_zero ((unsigned _BitInt(373)) 511), 10); ++ TEST_COMPARE (stdc_first_trailing_one ((unsigned _BitInt(512)) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_one ((unsigned _BitInt(512)) ++ 0), ui), 1); ++ TEST_COMPARE (stdc_first_trailing_one ((unsigned _BitInt(373)) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_first_trailing_one ((unsigned _BitInt(373)) ++ 0), ui), 1); ++ TEST_COMPARE (stdc_first_trailing_one (~(unsigned _BitInt(512)) 0), 1); ++ TEST_COMPARE (stdc_first_trailing_one (~(unsigned _BitInt(373)) 0), 1); ++ TEST_COMPARE (stdc_first_trailing_one (((unsigned _BitInt(512)) 255) << 175), ++ 176); ++ TEST_COMPARE (stdc_first_trailing_one ((~(unsigned _BitInt(373)) 0) << 311), ++ 312); ++ TEST_COMPARE (stdc_count_zeros ((unsigned _BitInt(512)) 0), 512); ++ TEST_COMPARE (expr_has_type (stdc_count_zeros ((unsigned _BitInt(512)) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_count_zeros ((unsigned _BitInt(373)) 0), 373); ++ TEST_COMPARE (expr_has_type (stdc_count_zeros ((unsigned _BitInt(373)) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_count_zeros (~(unsigned _BitInt(512)) 0), 0); ++ TEST_COMPARE (stdc_count_zeros (~(unsigned _BitInt(373)) 0), 0); ++ TEST_COMPARE (stdc_count_zeros ((unsigned _BitInt(512)) 1315), 512 - 5); ++ TEST_COMPARE (stdc_count_zeros ((unsigned _BitInt(373)) 3363), 373 - 6); ++ TEST_COMPARE (stdc_count_ones ((unsigned _BitInt(512)) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_count_ones ((unsigned _BitInt(512)) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_count_ones ((unsigned _BitInt(373)) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_count_ones ((unsigned _BitInt(373)) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_count_ones (~(unsigned _BitInt(512)) 0), 512); ++ TEST_COMPARE (stdc_count_ones (~(unsigned _BitInt(373)) 0), 373); ++ TEST_COMPARE (stdc_count_ones (~(unsigned _BitInt(512)) 1315), 512 - 5); ++ TEST_COMPARE (stdc_count_ones (~(unsigned _BitInt(373)) 3363), 373 - 6); ++ TEST_COMPARE (stdc_has_single_bit ((unsigned _BitInt(512)) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_has_single_bit ((unsigned _BitInt(512)) 0), ++ _Bool), 1); ++ TEST_COMPARE (stdc_has_single_bit ((unsigned _BitInt(373)) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_has_single_bit ((unsigned _BitInt(373)) 0), ++ _Bool), 1); ++ TEST_COMPARE (stdc_has_single_bit (~(unsigned _BitInt(512)) 0), 0); ++ TEST_COMPARE (stdc_has_single_bit (~(unsigned _BitInt(373)) 0), 0); ++ TEST_COMPARE (stdc_has_single_bit (((unsigned _BitInt(512)) 1022) << 279), ++ 0); ++ TEST_COMPARE (stdc_has_single_bit (((unsigned _BitInt(373)) 12) << 305), 0); ++ TEST_COMPARE (stdc_bit_width ((unsigned _BitInt(512)) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_bit_width ((unsigned _BitInt(512)) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_bit_width ((unsigned _BitInt(373)) 0), 0); ++ TEST_COMPARE (expr_has_type (stdc_bit_width ((unsigned _BitInt(373)) 0), ++ ui), 1); ++ TEST_COMPARE (stdc_bit_width (~(unsigned _BitInt(512)) 0), 512); ++ TEST_COMPARE (stdc_bit_width (~(unsigned _BitInt(373)) 0), 373); ++ TEST_COMPARE (stdc_bit_width (((unsigned _BitInt(512)) 1023) << 405), ++ 405 + 10); ++ TEST_COMPARE (stdc_bit_width (((unsigned _BitInt(373)) 1024) << 242), ++ 242 + 11); ++ TEST_COMPARE (stdc_bit_floor ((unsigned _BitInt(512)) 0) != 0, 0); ++ TEST_COMPARE (expr_has_type (stdc_bit_floor ((unsigned _BitInt(512)) 0), ++ unsigned _BitInt(512)), 1); ++ TEST_COMPARE (stdc_bit_floor ((unsigned _BitInt(373)) 0) != 0, 0); ++ TEST_COMPARE (expr_has_type (stdc_bit_floor ((unsigned _BitInt(373)) 0), ++ unsigned _BitInt(373)), 1); ++ TEST_COMPARE (stdc_bit_floor (~(unsigned _BitInt(512)) 0) ++ != ((unsigned _BitInt(512)) 1) << (512 - 1), 0); ++ TEST_COMPARE (stdc_bit_floor (~(unsigned _BitInt(373)) 0) ++ != ((unsigned _BitInt(373)) 1) << (373 - 1), 0); ++ TEST_COMPARE (stdc_bit_floor (((unsigned _BitInt(512)) 511) << 405) ++ != (((unsigned _BitInt(512)) 256) << 405), 0); ++ TEST_COMPARE (stdc_bit_floor (((unsigned _BitInt(373)) 512) << 242) ++ != (((unsigned _BitInt(512)) 512) << 242), 0); ++ TEST_COMPARE (stdc_bit_ceil ((unsigned _BitInt(512)) 0) != 1, 0); ++ TEST_COMPARE (expr_has_type (stdc_bit_ceil ((unsigned _BitInt(512)) 0), ++ unsigned _BitInt(512)), 1); ++ TEST_COMPARE (stdc_bit_ceil ((unsigned _BitInt(373)) 0) != 1, 0); ++ TEST_COMPARE (expr_has_type (stdc_bit_ceil ((unsigned _BitInt(373)) 0), ++ unsigned _BitInt(373)), 1); ++ TEST_COMPARE (stdc_bit_ceil (~(unsigned _BitInt(512)) 0) != 0, 0); ++ TEST_COMPARE (stdc_bit_ceil (~(unsigned _BitInt(373)) 0) != 0, 0); ++ TEST_COMPARE (stdc_bit_ceil (((unsigned _BitInt(512)) 1) << (512 - 1)) ++ != ((unsigned _BitInt(512)) 1) << (512 - 1), 0); ++ TEST_COMPARE (stdc_bit_ceil ((~(unsigned _BitInt(373)) 0) >> 1) ++ != ((unsigned _BitInt(373)) 1) << (373 - 1), 0); ++ TEST_COMPARE (stdc_bit_ceil (((unsigned _BitInt(512)) 512) << 405) ++ != (((unsigned _BitInt(512)) 512) << 405), 0); ++ TEST_COMPARE (stdc_bit_ceil (((unsigned _BitInt(373)) 513) << 242) ++ != (((unsigned _BitInt(512)) 1024) << 242), 0); ++ TEST_COMPARE (stdc_bit_floor ((unsigned _BitInt(BITINT_MAXWIDTH)) 0) != 0, ++ 0); ++ TEST_COMPARE (stdc_bit_floor (~(unsigned _BitInt(BITINT_MAXWIDTH)) 0) ++ != ((unsigned _BitInt(BITINT_MAXWIDTH)) 1) << (BITINT_MAXWIDTH ++ - 1), 0); ++ TEST_COMPARE (stdc_bit_floor (((unsigned _BitInt(BITINT_MAXWIDTH)) 511) ++ << 405) ++ != (((unsigned _BitInt(BITINT_MAXWIDTH)) 256) << 405), 0); ++ TEST_COMPARE (stdc_bit_floor (((unsigned _BitInt(BITINT_MAXWIDTH)) 512) ++ << 405) ++ != (((unsigned _BitInt(BITINT_MAXWIDTH)) 512) << 405), 0); ++ TEST_COMPARE (stdc_bit_ceil ((unsigned _BitInt(BITINT_MAXWIDTH)) 0) != 1, 0); ++ TEST_COMPARE (stdc_bit_ceil (~(unsigned _BitInt(BITINT_MAXWIDTH)) 0) != 0, ++ 0); ++ TEST_COMPARE (stdc_bit_ceil (((unsigned _BitInt(BITINT_MAXWIDTH)) 1) ++ << (BITINT_MAXWIDTH - 1)) ++ != ((unsigned _BitInt(BITINT_MAXWIDTH)) 1) << (BITINT_MAXWIDTH ++ - 1), 0); ++ TEST_COMPARE (stdc_bit_ceil (((unsigned _BitInt(BITINT_MAXWIDTH)) 512) ++ << 405) ++ != (((unsigned _BitInt(BITINT_MAXWIDTH)) 512) << 405), 0); ++ TEST_COMPARE (stdc_bit_ceil (((unsigned _BitInt(BITINT_MAXWIDTH)) 513) ++ << 405) ++ != (((unsigned _BitInt(BITINT_MAXWIDTH)) 1024) << 405), 0); ++# endif ++# endif ++ return 0; ++} ++#else ++static int ++do_test (void) ++{ ++ return 0; ++} ++#endif ++ ++#include diff --git a/glibc-upstream-2.39-7.patch b/glibc-upstream-2.39-7.patch new file mode 100644 index 0000000..5932145 --- /dev/null +++ b/glibc-upstream-2.39-7.patch @@ -0,0 +1,46 @@ +commit 71fcdba577884627c3ee4e43beb915da752efb1f +Author: Florian Weimer +Date: Fri Mar 15 19:08:24 2024 +0100 + + linux: Use rseq area unconditionally in sched_getcpu (bug 31479) + + Originally, nptl/descr.h included , but we removed that + in commit 2c6b4b272e6b4d07303af25709051c3e96288f2d ("nptl: + Unconditionally use a 32-byte rseq area"). After that, it was + not ensured that the RSEQ_SIG macro was defined during sched_getcpu.c + compilation that provided a definition. This commit always checks + the rseq area for CPU number information before using the other + approaches. + + This adds an unnecessary (but well-predictable) branch on + architectures which do not define RSEQ_SIG, but its cost is small + compared to the system call. Most architectures that have vDSO + acceleration for getcpu also have rseq support. + + Fixes: 2c6b4b272e6b4d07303af25709051c3e96288f2d + Fixes: 1d350aa06091211863e41169729cee1bca39f72f + Reviewed-by: Arjun Shankar + (cherry picked from commit 7a76f218677d149d8b7875b336722108239f7ee9) + +diff --git a/sysdeps/unix/sysv/linux/sched_getcpu.c b/sysdeps/unix/sysv/linux/sched_getcpu.c +index dfb884568d154537..72a3360550b8667a 100644 +--- a/sysdeps/unix/sysv/linux/sched_getcpu.c ++++ b/sysdeps/unix/sysv/linux/sched_getcpu.c +@@ -33,17 +33,9 @@ vsyscall_sched_getcpu (void) + return r == -1 ? r : cpu; + } + +-#ifdef RSEQ_SIG + int + sched_getcpu (void) + { + int cpu_id = THREAD_GETMEM_VOLATILE (THREAD_SELF, rseq_area.cpu_id); + return __glibc_likely (cpu_id >= 0) ? cpu_id : vsyscall_sched_getcpu (); + } +-#else /* RSEQ_SIG */ +-int +-sched_getcpu (void) +-{ +- return vsyscall_sched_getcpu (); +-} +-#endif /* RSEQ_SIG */ diff --git a/glibc.spec b/glibc.spec index bd120b2..2be35da 100644 --- a/glibc.spec +++ b/glibc.spec @@ -171,7 +171,7 @@ Version: %{glibcversion} # - It allows using the Release number without the %%dist tag in the dependency # generator to make the generated requires interchangeable between Rawhide # and ELN (.elnYY < .fcXX). -%global baserelease 3 +%global baserelease 4 Release: %{baserelease}%{?dist} # Licenses: @@ -281,6 +281,13 @@ Patch9: glibc-rh827510.patch Patch13: glibc-fedora-localedata-rh61908.patch Patch17: glibc-cs-path.patch Patch23: glibc-python3.patch +Patch24: glibc-upstream-2.39-1.patch +Patch25: glibc-upstream-2.39-2.patch +Patch26: glibc-upstream-2.39-3.patch +Patch27: glibc-upstream-2.39-4.patch +Patch28: glibc-upstream-2.39-5.patch +Patch29: glibc-upstream-2.39-6.patch +Patch30: glibc-upstream-2.39-7.patch ############################################################################## # Continued list of core "glibc" package information: @@ -2338,6 +2345,17 @@ update_gconv_modules_cache () %endif %changelog +* Tue Mar 19 2024 Arjun Shankar - 2.39-4 +- Sync with upstream branch release/2.39/master, + commit: 71fcdba577884627c3ee4e43beb915da752efb1f: +- linux: Use rseq area unconditionally in sched_getcpu (bug 31479) +- Use gcc __builtin_stdc_* builtins in stdbit.h if possible +- S390: Do not clobber r7 in clone [BZ #31402] +- math: Update mips64 ulps +- mips: FIx clone3 implementation (BZ 31325) +- arm: Remove wrong ldr from _dl_start_user (BZ 31339) +- Replace advisories directory + * Wed Feb 28 2024 Arjun Shankar - 2.39-3 - Analyse glibc-2.39 sources for license information - Migrate License field to SPDX identifiers for