about summary refs log tree commit diff
path: root/sysdeps/x86_64
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2021-07-08 20:48:14 -0700
committerH.J. Lu <hjl.tools@gmail.com>2021-07-09 06:39:30 -0700
commitdc76a059fded7a203c82dbb91d4fc1f43d3250db (patch)
treed77c68f593de7ebea9d5202aba84a57554a53355 /sysdeps/x86_64
parent0ec97597c859ac6a69733cf70c6bd6fc809dcc4b (diff)
downloadglibc-dc76a059fded7a203c82dbb91d4fc1f43d3250db.tar.gz
glibc-dc76a059fded7a203c82dbb91d4fc1f43d3250db.tar.xz
glibc-dc76a059fded7a203c82dbb91d4fc1f43d3250db.zip
Add a generic malloc test for MALLOC_ALIGNMENT
1. Add sysdeps/generic/malloc-size.h to define size related macros for
malloc.
2. Move x86_64/tst-mallocalign1.c to malloc and replace ALIGN_MASK with
MALLOC_ALIGN_MASK.
3. Add tst-mallocalign1 to tests-exclude-mcheck for i386 and x32 since
mcheck doesn't honor MALLOC_ALIGNMENT.
Diffstat (limited to 'sysdeps/x86_64')
-rw-r--r--sysdeps/x86_64/Makefile4
-rw-r--r--sysdeps/x86_64/tst-mallocalign1.c72
-rw-r--r--sysdeps/x86_64/x32/Makefile4
3 files changed, 4 insertions, 76 deletions
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