diff options
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/generic/malloc-machine.h | 1 | ||||
-rw-r--r-- | sysdeps/generic/malloc-size.h | 64 | ||||
-rw-r--r-- | sysdeps/i386/Makefile | 4 | ||||
-rw-r--r-- | sysdeps/x86_64/Makefile | 4 | ||||
-rw-r--r-- | sysdeps/x86_64/tst-mallocalign1.c | 72 | ||||
-rw-r--r-- | sysdeps/x86_64/x32/Makefile | 4 |
6 files changed, 72 insertions, 77 deletions
diff --git a/sysdeps/generic/malloc-machine.h b/sysdeps/generic/malloc-machine.h index a71f2361f5..121d8ad0c9 100644 --- a/sysdeps/generic/malloc-machine.h +++ b/sysdeps/generic/malloc-machine.h @@ -21,7 +21,6 @@ #define _GENERIC_MALLOC_MACHINE_H #include <atomic.h> -#include <malloc-alignment.h> #ifndef atomic_full_barrier # define atomic_full_barrier() __asm ("" ::: "memory") diff --git a/sysdeps/generic/malloc-size.h b/sysdeps/generic/malloc-size.h new file mode 100644 index 0000000000..41901b9a44 --- /dev/null +++ b/sysdeps/generic/malloc-size.h @@ -0,0 +1,64 @@ +/* Define INTERNAL_SIZE_T, SIZE_SZ, MALLOC_ALIGNMENT and MALLOC_ALIGN_MASK + for malloc. + Copyright (C) 2021 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 + <https://www.gnu.org/licenses/>. */ + +#ifndef _GENERIC_MALLOC_SIZE_H +#define _GENERIC_MALLOC_SIZE_H + +/* INTERNAL_SIZE_T is the word-size used for internal bookkeeping of + chunk sizes. + + The default version is the same as size_t. + + While not strictly necessary, it is best to define this as an + unsigned type, even if size_t is a signed type. This may avoid some + artificial size limitations on some systems. + + On a 64-bit machine, you may be able to reduce malloc overhead by + defining INTERNAL_SIZE_T to be a 32 bit `unsigned int' at the + expense of not being able to handle more than 2^32 of malloced + space. If this limitation is acceptable, you are encouraged to set + this unless you are on a platform requiring 16byte alignments. In + this case the alignment requirements turn out to negate any + potential advantages of decreasing size_t word size. + + Implementors: Beware of the possible combinations of: + - INTERNAL_SIZE_T might be signed or unsigned, might be 32 or 64 bits, + and might be the same width as int or as long + - size_t might have different width and signedness as INTERNAL_SIZE_T + - int and long might be 32 or 64 bits, and might be the same width + + To deal with this, most comparisons and difference computations + among INTERNAL_SIZE_Ts should cast them to unsigned long, being + aware of the fact that casting an unsigned int to a wider long does + not sign-extend. (This also makes checking for negative numbers + awkward.) Some of these casts result in harmless compiler warnings + on some systems. */ +#ifndef INTERNAL_SIZE_T +# define INTERNAL_SIZE_T size_t +#endif + +/* The corresponding word size. */ +#define SIZE_SZ (sizeof (INTERNAL_SIZE_T)) + +#include <malloc-alignment.h> + +/* The corresponding bit mask value. */ +#define MALLOC_ALIGN_MASK (MALLOC_ALIGNMENT - 1) + +#endif /* _GENERIC_MALLOC_SIZE_H */ diff --git a/sysdeps/i386/Makefile b/sysdeps/i386/Makefile index a2e8c0b128..8fb65c0f17 100644 --- a/sysdeps/i386/Makefile +++ b/sysdeps/i386/Makefile @@ -5,6 +5,10 @@ asm-CPPFLAGS += -DGAS_SYNTAX # The i386 `long double' is a distinct type we support. long-double-fcts = yes +ifeq ($(subdir),malloc) +tests-exclude-mcheck += tst-mallocalign1 +endif + ifeq ($(subdir),math) # These functions change the rounding mode internally and need to # update both the SSE2 rounding mode and the 387 rounding mode. See diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile index 3fc03f4a19..22c5b63ab5 100644 --- a/sysdeps/x86_64/Makefile +++ b/sysdeps/x86_64/Makefile @@ -13,10 +13,6 @@ sysdep_routines += _mcount sysdep_noprof += _mcount endif -ifeq ($(subdir),malloc) -tests += tst-mallocalign1 -endif - ifeq ($(subdir),string) sysdep_routines += strcasecmp_l-nonascii strncase_l-nonascii gen-as-const-headers += locale-defines.sym diff --git a/sysdeps/x86_64/tst-mallocalign1.c b/sysdeps/x86_64/tst-mallocalign1.c deleted file mode 100644 index 33a6375777..0000000000 --- a/sysdeps/x86_64/tst-mallocalign1.c +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright (C) 2012-2021 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 - <https://www.gnu.org/licenses/>. */ - -#include <stdio.h> -#include <stdlib.h> - -/* Specified by x86-64 psABI. */ -#define ALIGN_MASK (16 - 1) - -void * -test (size_t s) -{ - void *p = malloc (s); - - printf ("malloc: %ld, %p: %ld\n", (unsigned long) s, p, - ((unsigned long) p) & ALIGN_MASK); - return p; -} - -static int -do_test (void) -{ - void *p; - int ret = 0; - - p = test (2); - ret |= (unsigned long) p & ALIGN_MASK; - free (p); - - p = test (8); - ret |= (unsigned long) p & ALIGN_MASK; - free (p); - - p = test (13); - ret |= (unsigned long) p & ALIGN_MASK; - free (p); - - p = test (16); - ret |= (unsigned long) p & ALIGN_MASK; - free (p); - - p = test (23); - ret |= (unsigned long) p & ALIGN_MASK; - free (p); - - p = test (43); - ret |= (unsigned long) p & ALIGN_MASK; - free (p); - - p = test (123); - ret |= (unsigned long) p & ALIGN_MASK; - free (p); - - return ret; -} - -#define TEST_FUNCTION do_test () -#include "../test-skeleton.c" diff --git a/sysdeps/x86_64/x32/Makefile b/sysdeps/x86_64/x32/Makefile index 8748956563..62919c79f1 100644 --- a/sysdeps/x86_64/x32/Makefile +++ b/sysdeps/x86_64/x32/Makefile @@ -1,3 +1,7 @@ +ifeq ($(subdir),malloc) +tests-exclude-mcheck += tst-mallocalign1 +endif + ifeq ($(subdir),math) # Since x32 returns 32-bit long int and 64-bit long long int in the # same 64-bit register, we make the 32b-bit lround an alias of the |