about summary refs log tree commit diff
path: root/support
Commit message (Collapse)AuthorAgeFilesLines
* support: Include <limits.h> for NAME_MAX use in temp_file.cFlorian Weimer2024-06-171-0/+1
|
* support: Include <stdlib.h> for atoi use in support_wait_for_thread_exitFlorian Weimer2024-06-171-0/+1
|
* support: Fix typo in xgetsockname error messageAvinal Kumar2024-06-051-1/+2
| | | | | | | | | The error message in xgetsockname was incorrectly referring to a different function. This commit fixes that. Suggested-by: Arjun Shankar <arjun@redhat.com> Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* support: Add envp argument to support_capture_subprogramAdhemerval Zanella2024-05-075-12/+16
| | | | | So tests can specify a list of environment variables. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* libsupport: Add xgetpeernameSergey Kolosov2024-04-103-0/+32
| | | | | | The patch adds redirections for getpeername. Reviewed-by: Arjun Shankar <arjun@redhat.com>
* Always define __USE_TIME_BITS64 when 64 bit time_t is usedAdhemerval Zanella2024-04-023-3/+3
| | | | | | | | | | | | | | | | | | | | It was raised on libc-help [1] that some Linux kernel interfaces expect the libc to define __USE_TIME_BITS64 to indicate the time_t size for the kABI. Different than defined by the initial y2038 design document [2], the __USE_TIME_BITS64 is only defined for ABIs that support more than one time_t size (by defining the _TIME_BITS for each module). The 64 bit time_t redirects are now enabled using a different internal define (__USE_TIME64_REDIRECTS). There is no expected change in semantic or code generation. Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu, and arm-linux-gnueabi [1] https://sourceware.org/pipermail/libc-help/2024-January/006557.html [2] https://sourceware.org/glibc/wiki/Y2038ProofnessDesign Reviewed-by: DJ Delorie <dj@redhat.com>
* tests: gracefully handle AppArmor userns containmentSimon Chopin2024-02-231-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Recent AppArmor containment allows restricting unprivileged user namespaces, which is enabled by default on recent Ubuntu systems. When this happens, as is common with Linux Security Modules, the syscall will fail with -EACCESS. When that happens, the affected tests will now be considered unsupported rather than simply failing. Further information: * https://gitlab.com/apparmor/apparmor/-/wikis/unprivileged_userns_restriction * https://ubuntu.com/blog/ubuntu-23-10-restricted-unprivileged-user-namespaces * https://manpages.ubuntu.com/manpages/jammy/man5/apparmor.d.5.html (for the return code) V2: * Fix duplicated line in check_unshare_hints * Also handle similar failure in tst-pidfd_getpid V3: * Comment formatting * Aded some more documentation on syscall return value Signed-off-by: Simon Chopin <simon.chopin@canonical.com>
* Remove ia64-linux-gnuAdhemerval Zanella2024-01-081-9/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Linux 6.7 removed ia64 from the official tree [1], following the general principle that a glibc port needs upstream support for the architecture in all the components it depends on (binutils, GCC, and the Linux kernel). Apart from the removal of sysdeps/ia64 and sysdeps/unix/sysv/linux/ia64, there are updates to various comments referencing ia64 for which removal of those references seemed appropriate. The configuration is removed from README and build-many-glibcs.py. The CONTRIBUTED-BY, elf/elf.h, manual/contrib.texi (the porting mention), *.po files, config.guess, and longlong.h are not changed. For Linux it allows cleanup some clone2 support on multiple files. The following bug can be closed as WONTFIX: BZ 22634 [2], BZ 14250 [3], BZ 21634 [4], BZ 10163 [5], BZ 16401 [6], and BZ 11585 [7]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=43ff221426d33db909f7159fdf620c3b052e2d1c [2] https://sourceware.org/bugzilla/show_bug.cgi?id=22634 [3] https://sourceware.org/bugzilla/show_bug.cgi?id=14250 [4] https://sourceware.org/bugzilla/show_bug.cgi?id=21634 [5] https://sourceware.org/bugzilla/show_bug.cgi?id=10163 [6] https://sourceware.org/bugzilla/show_bug.cgi?id=16401 [7] https://sourceware.org/bugzilla/show_bug.cgi?id=11585 Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Update copyright dates with scripts/update-copyrightsPaul Eggert2024-01-01252-252/+252
|
* support: Add support_set_vma_nameAdhemerval Zanella2023-11-073-0/+54
| | | | | Check if kernel supports prctl (PR_SET_VMA, PR_SET_VMA_ANON_NAME, ...). Reviewed-by: DJ Delorie <dj@redhat.com>
* Fix WAIT_FOR_DEBUGGER for container tests.Stefan Liebler2023-10-161-8/+6
| | | | | | | | | | | | | | | | For container tests, gdb needs to set the sysroot to the corresponding testroot.root directory. The assumption was that PIDs < 3 means that we are running within a container. Starting with commit 2fe64148a81f0d78050c302f34a6853d21f7cae4 "Allow for unpriviledged nested containers", the default is to use the PID namespace of the parent. Thus support_test_main.c does not recognize our container anymore. This patch now assumes that we are running inside a container if test-container.c has set PID_OUTSIDE_CONTAINER and always uses this PID independent of having a new PID namespace or not. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* test-container: Use nftw instead of rm -rfAdhemerval Zanella2023-09-281-23/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the binary to run is 'env', test-containers skips it and adds any required environment variable on the process envs variables. This simplifies the required code to spawn new process (no need to build an env-like program). However, this is an issue for recursive_remove if there is any LD_PRELOAD, since test-container will not prepend the loader command along with required paths. If the required preloaded library can not be loaded by the system glibc, the 'post-clean rsync' will eventually fail. One example is if system glibc does not support DT_RELR and the built glibc does, the nss/tst-nss-gai-hv2-canonname test fails with: ../scripts/evaluate-test.sh nss/tst-nss-gai-hv2-canonname $? false false 86_64-linux-gnu/nss/tst-nss-gai-hv2-canonname.test-result rm: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_ABI_DT_RELR' not found (required by x86_64-linux-gnu/malloc/libc_malloc_debug.so) Instead trying to figure out the required loader arguments on how to spawn the 'rm -rf', replace the command with a nftw call. Checked on x86_64-linux-gnu. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Stefan Liebler <stli@linux.ibm.com>
* support: Build with exceptions and asynchronous unwind tables [BZ #30587]John David Anglin2023-07-011-0/+3
| | | | | | | | | Changing tst-cleanup4.c to use xread instead of read caused the nptl/tst-cleanupx4 test to fail. The routines in libsupport.a need to be built with exception handling and asynchronous unwind table support. v2: Use "CFLAGS-.oS" instead of "override CFLAGS".
* tests: replace system by xsystemFrédéric Bérat2023-06-193-0/+69
| | | | | | With fortification enabled, system calls return result needs to be checked, has it gets the __wur macro enabled. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* tests: replace read by xreadFrédéric Bérat2023-06-194-1/+42
| | | | | | | | | | | | | | | With fortification enabled, read calls return result needs to be checked, has it gets the __wur macro enabled. Note on read call removal from sysdeps/pthread/tst-cancel20.c and sysdeps/pthread/tst-cancel21.c: It is assumed that this second read call was there to overcome the race condition between pipe closure and thread cancellation that could happen in the original code. Since this race condition got fixed by d0e3ffb7a58854248f1d5e737610d50cd0a60f46 the second call seems superfluous. Hence, instead of checking for the return value of read, it looks reasonable to simply remove it. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* tests: replace fgets by xfgetsFrederic Berat2023-06-133-0/+34
| | | | | | With fortification enabled, fgets calls return result needs to be checked, has it gets the __wur macro enabled. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* tests: replace fread by xfreadFrederic Berat2023-06-133-0/+41
| | | | | | With fortification enabled, fread calls return result needs to be checked, has it gets the __wur macro enabled. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* support: Add delayed__exit (with two underscores)Florian Weimer2023-06-062-11/+39
| | | | It calls _exit instead of exit once the timeout expires.
* Fix all the remaining misspellings -- BZ 25337Paul Pluzhnikov2023-06-0210-26/+26
|
* tests: fix warn unused resultsFrédéric Bérat2023-06-011-2/+2
| | | | | | With fortification enabled, few function calls return result need to be checked, has they get the __wur macro enabled. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* tests: replace write by xwriteFrédéric Bérat2023-06-011-4/+4
| | | | | | | Using write without cheks leads to warn unused result when __wur is enabled. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* support: Don't fail on fchown when spawning sgid processesSiddhesh Poyarekar2023-06-011-2/+13
| | | | | | | | | | | | In some cases (e.g. when podman creates user containers), the only other group assigned to the executing user is nobody and fchown fails with it because the group is not mapped. Do not fail the test in this case, instead exit as unsupported. Reported-by: Frédéric Bérat <fberat@redhat.com> Tested-by: Frédéric Bérat <fberat@redhat.com> Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* support: Reformat Makefile.Carlos O'Donell2023-05-231-14/+24
| | | | | | | | Add list end markers. Sort text using scripts/sort-makefile-lines.py. No code generation changes observed in non-test binary artifacts. No regressions on x86_64 and i686.
* system: Add "--" after "-c" for sh (BZ #28519)Joe Simmons-Talbott2023-03-281-1/+6
| | | | | | | | | | | Prevent sh from interpreting a user string as shell options if it starts with '-' or '+'. Since the version of /bin/sh used for testing system() is different from the full-fledged system /bin/sh add support to it for handling "--" after "-c". Add a testcase to ensure the expected behavior. Signed-off-by: Joe Simmons-Talbott <josimmon@redhat.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* support: introduce support_sysconfdir_prefixRomain Geissler2023-03-273-1/+11
| | | | Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* posix: Fix system blocks SIGCHLD erroneously [BZ #30163]Adam Yi2023-03-075-0/+111
| | | | | | | | | | | | | | | | | | | | | Fix bug that SIGCHLD is erroneously blocked forever in the following scenario: 1. Thread A calls system but hasn't returned yet 2. Thread B calls another system but returns SIGCHLD would be blocked forever in thread B after its system() returns, even after the system() in thread A returns. Although POSIX does not require, glibc system implementation aims to be thread and cancellation safe. This bug was introduced in 5fb7fc96350575c9adb1316833e48ca11553be49 when we moved reverting signal mask to happen when the last concurrently running system returns, despite that signal mask is per thread. This commit reverts this logic and adds a test. Signed-off-by: Adam Yi <ayi@janestreet.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* C2x scanf binary constant handlingJoseph Myers2023-03-023-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | C2x adds binary integer constants starting with 0b or 0B, and supports those constants for the %i scanf format (in addition to the %b format, which isn't yet implemented for scanf in glibc). Implement that scanf support for glibc. As with the strtol support, this is incompatible with previous C standard versions, in that such an input string starting with 0b or 0B was previously required to be parsed as 0 (with the rest of the input potentially matching subsequent parts of the scanf format string). Thus this patch adds 12 new __isoc23_* functions per long double format (12, 24 or 36 depending on how many long double formats the glibc configuration supports), with appropriate header redirection support (generally very closely following that for the __isoc99_* scanf functions - note that __GLIBC_USE (DEPRECATED_SCANF) takes precedence over __GLIBC_USE (C2X_STRTOL), so the case of GNU extensions to C89 continues to get old-style GNU %a and does not get this new feature). The function names would remain as __isoc23_* even if C2x ends up published in 2024 rather than 2023. When scanf %b support is added, I think it will be appropriate for all versions of scanf to follow C2x rules for inputs to the %b format (given that there are no compatibility concerns for a new format). Tested for x86_64 (full glibc testsuite). The first version was also tested for powerpc (32-bit) and powerpc64le (stdio-common/ and wcsmbs/ tests), and with build-many-glibcs.py.
* support: use 64-bit time_t (bug 30111)Andreas Schwab2023-03-026-8/+22
| | | | Ensure to use 64-bit time_t in the test infrastructure.
* Update copyright dates with scripts/update-copyrightsJoseph Myers2023-01-06243-243/+243
|
* scripts: Add "|" operator support to glibcpp's parsingShahab Vahedi2022-11-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | From the tests point of view, this is a necessary step for another patch [1] and allows parsing macros such as "#define A | B". Without it, a few tests [2] choke when the other patch [1] is applied: /src/glibc/scripts/../elf/elf.h:4167: error: uninterpretable macro token sequence: ( EF_ARC_MACH_MSK | EF_ARC_OSABI_MSK ) Traceback (most recent call last): File "/src/glibc/elf/tst-glibcelf.py", line 23, in <module> import glibcelf File "/src/glibc/scripts/glibcelf.py", line 226, in <module> _elf_h = _parse_elf_h() ^^^^^^^^^^^^^^ File "/src/glibc/scripts/glibcelf.py", line 223, in _parse_elf_h raise IOError('parse error in elf.h') OSError: parse error in elf.h [1] ARC: update definitions in elf/elf.h https://sourceware.org/pipermail/libc-alpha/2022-November/143503.html [2] tst-glibcelf, tst-relro-ldso, and tst-relro-libc Reviewed-by: Florian Weimer <fweimer@redhat.com> Signed-off-by: Shahab Vahedi <shahab@synopsys.com>
* support: Add xpthread_cond_signal wrapperYu Chien Peter Lin2022-10-033-0/+28
| | | | | Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* scripts: Enhance glibcpp to do basic macro processingFlorian Weimer2022-09-222-2/+225
| | | | Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* test-container: return UNSUPPORTED for ENOSPC on clone()Xi Ruoyao2022-07-051-31/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | Since Linux 4.9, the kernel provides /proc/sys/user/max_{mnt,pid,user}_namespace as a limitation of number of namespaces. Some distros (for example, Slint Linux 14.2.1) set them (or only max_user_namespace) to zero as a "security policy" for disabling namespaces. The clone() call will set errno to ENOSPC under such a limitation. We didn't check ENOSPC in the code so the test will FAIL, and report: unable to unshare user/fs: No space left on device This message is, unfortunately, very unhelpful. It leads people to check the memory or disk space, instead of finding the real issue. To improve the situation, we should check for ENOSPC and return UNSUPPORTED as the test result. Also refactor check_for_unshare_hints() to emit a proper message telling people how to make the test work, if they really need to run the namespaced tests. Reported-by: Philippe Delavalade <philippe.delavalade@orange.fr> URL: https://lists.linuxfromscratch.org/sympa/arc/lfs-support/2022-06/msg00022.html Signed-off-by: Xi Ruoyao <xry111@xry111.site> Reviewed-by: DJ Delorie <dj@redhat.com>
* support: Change non-address output format of support_format_dns_packetFlorian Weimer2022-06-242-9/+17
| | | | | | | It makes sense to include the owner name (LHS) and record type in the output, so that they can be checked for correctness. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* support: Add xmkfifoAdhemerval Zanella2022-04-153-0/+31
| | | | Wrapper support mkfifo.
* test-container: Fix "unused code" warnings on HURDDJ Delorie2022-04-121-0/+6
| | | | | | | | | Comment out bits of code that are only used when we *have* pid namespaces, to avoid "unused code" warnings. Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Message-Id: <xno817tnds.fsf@greed.delorie.com>
* Allow for unpriviledged nested containersDJ Delorie2022-04-044-35/+147
| | | | | | | | | | | | | | | | | If the build itself is run in a container, we may not be able to fully set up a nested container for test-container testing. Notably is the mounting of /proc, since it's critical that it be mounted from within the same PID namespace as its users, and thus cannot be bind mounted from outside the container like other mounts. This patch defaults to using the parent's PID namespace instead of creating a new one, as this is more likely to be allowed. If the test needs an isolated PID namespace, it should add the "pidns" command to its init script. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* support: Fix support_process_state_wait path size calculationAdhemerval Zanella2022-03-231-1/+2
| | | | | | | Use INT_STRLEN_BOUND to proper get the maximum pid_t size. Also fix the wrong calculation (the 3 should multiply the sizeof (pid_t)). Checked on x86_64-linux-gnu.
* support: Remove unused extract_8 functionAdhemerval Zanella2022-03-231-11/+0
|
* support: Add support_socket_so_timestamp_time64Adhemerval Zanella2022-01-283-0/+53
| | | | | | | | Check if the socket support 64-bit network packages timestamps (SO_TIMESTAMP and SO_TIMESTAMPNS). This will be used on recvmsg and recvmmsg tests to check if the timestamp should be generated. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* Avoid -Wuse-after-free in tests [BZ #26779].Martin Sebor2022-01-261-1/+2
| | | | Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* support: Add helpers to create paths longer than PATH_MAXSiddhesh Poyarekar2022-01-212-9/+159
| | | | | | | | | Add new helpers support_create_and_chdir_toolong_temp_directory and support_chdir_toolong_temp_directory to create and descend into directory trees longer than PATH_MAX. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* debug: Synchronize feature guards in fortified functions [BZ #28746]Siddhesh Poyarekar2022-01-121-0/+2
| | | | | | | | | | | | | | | | | | Some functions (e.g. stpcpy, pread64, etc.) had moved to POSIX in the main headers as they got incorporated into the standard, but their fortified variants remained under __USE_GNU. As a result, these functions did not get fortified when _GNU_SOURCE was not defined. Add test wrappers that check all functions tested in tst-chk0 at all levels with _GNU_SOURCE undefined and then use the failures to (1) exclude checks for _GNU_SOURCE functions in these tests and (2) Fix feature macro guards in the fortified function headers so that they're the same as the ones in the main headers. This fixes BZ #28746. Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Revert "support: Add support_socket_so_timestamp_time64"Adhemerval Zanella2022-01-123-61/+0
| | | | This reverts commit a4cf12360fb7a8eae4fa4923763309b7f10797c3.
* support: Add support_socket_so_timestamp_time64Adhemerval Zanella2022-01-123-0/+61
| | | | | | Check if the socket support 64-bit network packages timestamps (SO_TIMESTAMP and SO_TIMESTAMPNS). This will be used on recvmsg and recvmmsg tests to check if the timestamp should be generated.
* Update copyright dates with scripts/update-copyrightsPaul Eggert2022-01-01238-239/+239
| | | | | | | | | | | | | | | | | | | | | | | I used these shell commands: ../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright (cd ../glibc && git commit -am"[this commit message]") and then ignored the output, which consisted lines saying "FOO: warning: copyright statement not found" for each of 7061 files FOO. I then removed trailing white space from math/tgmath.h, support/tst-support-open-dev-null-range.c, and sysdeps/x86_64/multiarch/strlen-vec.S, to work around the following obscure pre-commit check failure diagnostics from Savannah. I don't know why I run into these diagnostics whereas others evidently do not. remote: *** 912-#endif remote: *** 913: remote: *** 914- remote: *** error: lines with trailing whitespace found ... remote: *** error: sysdeps/unix/sysv/linux/statx_cp.c: trailing lines
* Add --with-timeoutfactor=NUM to specify TIMEOUTFACTORH.J. Lu2021-12-041-1/+1
| | | | | | | | | On Ice Lake and Tiger Lake laptops, some test programs timeout when there are 3 "make check -j8" runs in parallel. Add --with-timeoutfactor=NUM to specify an integer to scale the timeout of test programs, which can be overriden by TIMEOUTFACTOR environment variable. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* elf: Testing infrastructure for ld.so DSO sorting (BZ #17645)Chung-Lin Tang2021-10-216-1/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the first of a 2-part patch set that fixes slow DSO sorting behavior in the dynamic loader, as reported in BZ #17645. In order to facilitate such a large modification to the dynamic loader, this first patch implements a testing framework for validating shared object sorting behavior, to enable comparison between old/new sorting algorithms, and any later enhancements. This testing infrastructure consists of a Python script scripts/dso-ordering-test.py' which takes in a description language, consisting of strings that describe a set of link dependency relations between DSOs, and generates testcase programs and Makefile fragments to automatically test the described situation, for example: a->b->c->d # four objects linked one after another a->[bc]->d;b->c # a depends on b and c, which both depend on d, # b depends on c (b,c linked to object a in fixed order) a->b->c;{+a;%a;-a} # a, b, c serially dependent, main program uses # dlopen/dlsym/dlclose on object a a->b->c;{}!->[abc] # a, b, c serially dependent; multiple tests generated # to test all permutations of a, b, c ordering linked # to main program (Above is just a short description of what the script can do, more documentation is in the script comments.) Two files containing several new tests, elf/dso-sort-tests-[12].def are added, including test scenarios for BZ #15311 and Redhat issue #1162810 [1]. Due to the nature of dynamic loader tests, where the sorting behavior and test output occurs before/after main(), generating testcases to use support/test-driver.c does not suffice to control meaningful timeout for ld.so. Therefore a new utility program 'support/test-run-command', based on test-driver.c/support_test_main.c has been added. This does the same testcase control, but for a program specified through a command-line rather than at the source code level. This utility is used to run the dynamic loader testcases generated by dso-ordering-test.py. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1162810 Signed-off-by: Chung-Lin Tang <cltang@codesourcery.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Add alloc_align attribute to memalign et alJonathan Wakely2021-10-211-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC 4.9.0 added the alloc_align attribute to say that a function argument specifies the alignment of the returned pointer. Clang supports the attribute too. Using the attribute can allow a compiler to generate better code if it knows the returned pointer has a minimum alignment. See https://gcc.gnu.org/PR60092 for more details. GCC implicitly knows the semantics of aligned_alloc and posix_memalign, but not the obsolete memalign. As a result, GCC generates worse code when memalign is used, compared to aligned_alloc. Clang knows about aligned_alloc and memalign, but not posix_memalign. This change adds a new __attribute_alloc_align__ macro to <sys/cdefs.h> and then uses it on memalign (where it helps GCC) and aligned_alloc (where GCC and Clang already know the semantics, but it doesn't hurt) and xposix_memalign. It can't be used on posix_memalign because that doesn't return a pointer (the allocated pointer is returned via a void** parameter instead). Unlike the alloc_size attribute, alloc_align only allows a single argument. That means the new __attribute_alloc_align__ macro doesn't really need to be used with double parentheses to protect a comma between its arguments. For consistency with __attribute_alloc_size__ this patch defines it the same way, so that double parentheses are required. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* Add TEST_COMPARE_STRING_WIDE to support/check.hJoseph Myers2021-10-1211-138/+448
| | | | | | | | | | | | | | | | | | | | | | | I'd like to be able to test narrow and wide string interfaces, with the narrow string tests using TEST_COMPARE_STRING and the wide string tests using something analogous (possibly generated using macros from a common test template for both the narrow and wide string tests where appropriate). Add such a TEST_COMPARE_STRING_WIDE, along with functions support_quote_blob_wide and support_test_compare_string_wide that it builds on. Those functions are built using macros from common templates shared by the narrow and wide string implementations, though I didn't do that for the tests of test functions. In support_quote_blob_wide, I chose to use the \x{} delimited escape sequence syntax proposed for C2X in N2785, rather than e.g. trying to generate the end of a string and the start of a new string when ambiguity would result from undelimited \x (when the next character after such an escape sequence is valid hex) or forcing an escape sequence to be used for the next character in the case of such ambiguity. Tested for x86_64.