mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-26 04:31:03 +00:00
5a82c74822
Also, change sources.redhat.com to sourceware.org. This patch was automatically generated by running the following shell script, which uses GNU sed, and which avoids modifying files imported from upstream: sed -ri ' s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g ' \ $(find $(git ls-files) -prune -type f \ ! -name '*.po' \ ! -name 'ChangeLog*' \ ! -path COPYING ! -path COPYING.LIB \ ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \ ! -path manual/texinfo.tex ! -path scripts/config.guess \ ! -path scripts/config.sub ! -path scripts/install-sh \ ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \ ! -path INSTALL ! -path locale/programs/charmap-kw.h \ ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \ ! '(' -name configure \ -execdir test -f configure.ac -o -f configure.in ';' ')' \ ! '(' -name preconfigure \ -execdir test -f preconfigure.ac ';' ')' \ -print) and then by running 'make dist-prepare' to regenerate files built from the altered files, and then executing the following to cleanup: chmod a+x sysdeps/unix/sysv/linux/riscv/configure # Omit irrelevant whitespace and comment-only changes, # perhaps from a slightly-different Autoconf version. git checkout -f \ sysdeps/csky/configure \ sysdeps/hppa/configure \ sysdeps/riscv/configure \ sysdeps/unix/sysv/linux/csky/configure # Omit changes that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines git checkout -f \ sysdeps/powerpc/powerpc64/ppc-mcount.S \ sysdeps/unix/sysv/linux/s390/s390-64/syscall.S # Omit change that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
120 lines
3.1 KiB
C
120 lines
3.1 KiB
C
/* Copyright (C) 2003-2019 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
|
|
|
|
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/>. */
|
|
|
|
/* Check alignment, overlapping and layout of TLS variables. */
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <pthread.h>
|
|
#include <pthreadP.h>
|
|
#include <sys/param.h>
|
|
|
|
#include "tst-tls5.h"
|
|
|
|
#ifdef TLS_REGISTER
|
|
|
|
struct tls_obj tls_registry[64];
|
|
|
|
static int
|
|
tls_addr_cmp (const void *a, const void *b)
|
|
{
|
|
if (((struct tls_obj *)a)->addr < ((struct tls_obj *)b)->addr)
|
|
return -1;
|
|
if (((struct tls_obj *)a)->addr > ((struct tls_obj *)b)->addr)
|
|
return 1;
|
|
return 0;
|
|
}
|
|
|
|
static int
|
|
do_test (void)
|
|
{
|
|
size_t cnt, i;
|
|
int res = 0;
|
|
uintptr_t min_addr = ~(uintptr_t) 0, max_addr = 0;
|
|
|
|
for (cnt = 0; tls_registry[cnt].name; ++cnt);
|
|
tls_registry[cnt].name = NULL;
|
|
tls_registry[cnt].addr = (uintptr_t) pthread_self ();
|
|
tls_registry[cnt].size = sizeof (struct pthread);
|
|
tls_registry[cnt++].align = __alignof__ (struct pthread);
|
|
|
|
qsort (tls_registry, cnt, sizeof (struct tls_obj), tls_addr_cmp);
|
|
|
|
for (i = 0; i < cnt; ++i)
|
|
{
|
|
printf ("%s%s = %p, size %zd, align %zd",
|
|
tls_registry[i].name ? "&" : "",
|
|
tls_registry[i].name ?: "pthread_self ()",
|
|
(void *) tls_registry[i].addr,
|
|
tls_registry[i].size, tls_registry[i].align);
|
|
if (tls_registry[i].addr & (tls_registry[i].align - 1))
|
|
{
|
|
fputs (", WRONG ALIGNMENT", stdout);
|
|
res = 1;
|
|
}
|
|
if (i > 0
|
|
&& (tls_registry[i - 1].addr + tls_registry[i - 1].size
|
|
> tls_registry[i].addr))
|
|
{
|
|
fputs (", ADDRESS OVERLAP", stdout);
|
|
res = 1;
|
|
}
|
|
puts ("");
|
|
if (tls_registry[i].name)
|
|
{
|
|
min_addr = MIN (tls_registry[i].addr, min_addr);
|
|
max_addr = MAX (tls_registry[i].addr + tls_registry[i].size,
|
|
max_addr);
|
|
}
|
|
}
|
|
|
|
if (cnt > 1)
|
|
{
|
|
#if TLS_TCB_AT_TP
|
|
if (tls_registry[cnt - 1].name)
|
|
{
|
|
puts ("pthread_self () not larger than all TLS addresses");
|
|
res = 1;
|
|
}
|
|
else
|
|
max_addr = MAX (tls_registry[cnt - 1].addr, max_addr);
|
|
#elif TLS_DTV_AT_TP
|
|
if (tls_registry[0].name)
|
|
{
|
|
puts ("pthread_self () not smaller than all TLS addresses");
|
|
res = 1;
|
|
}
|
|
#else
|
|
abort ();
|
|
#endif
|
|
printf ("Initial TLS used block size %zd\n",
|
|
(size_t) (max_addr - min_addr));
|
|
}
|
|
return res;
|
|
}
|
|
|
|
#define TEST_FUNCTION do_test ()
|
|
|
|
#else
|
|
|
|
#define TEST_FUNCTION 0
|
|
|
|
#endif
|
|
|
|
#include "../test-skeleton.c"
|