diff options
author | pfg <pfg@FreeBSD.org> | 2016-04-18 16:25:37 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2016-04-18 16:25:37 +0000 |
commit | 3c79e64b06b1f799d35b38b7c9388e19290b9a6f (patch) | |
tree | 20835d4116f3cf009a98539c3ab962edb5c1c7ec | |
parent | 37a227e93c384e41451b1bcdac122febf4e629a2 (diff) | |
download | FreeBSD-src-3c79e64b06b1f799d35b38b7c9388e19290b9a6f.zip FreeBSD-src-3c79e64b06b1f799d35b38b7c9388e19290b9a6f.tar.gz |
Re-use our roundup2() macro instead of reinventing the wheel.
Obtained from: DragonflyBSD
-rw-r--r-- | lib/libc/gen/tls.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c index dd1e7df..6cba47f 100644 --- a/lib/libc/gen/tls.c +++ b/lib/libc/gen/tls.c @@ -33,6 +33,7 @@ */ #include <sys/cdefs.h> +#include <sys/param.h> #include <stdlib.h> #include <string.h> #include <elf.h> @@ -82,9 +83,6 @@ void __libc_free_tls(void *tls, size_t tcbsize, size_t tcbalign); #ifndef PIC -#define round(size, align) \ - (((size) + (align) - 1) & ~((align) - 1)) - static size_t tls_static_space; static size_t tls_init_size; static void *tls_init; @@ -190,7 +188,7 @@ __libc_free_tls(void *tcb, size_t tcbsize __unused, size_t tcbalign) * Figure out the size of the initial TLS block so that we can * find stuff which ___tls_get_addr() allocated dynamically. */ - size = round(tls_static_space, tcbalign); + size = roundup2(tls_static_space, tcbalign); dtv = ((Elf_Addr**)tcb)[1]; tlsend = (Elf_Addr) tcb; @@ -210,7 +208,7 @@ __libc_allocate_tls(void *oldtls, size_t tcbsize, size_t tcbalign) Elf_Addr *dtv; Elf_Addr segbase, oldsegbase; - size = round(tls_static_space, tcbalign); + size = roundup2(tls_static_space, tcbalign); if (tcbsize < 2 * sizeof(Elf_Addr)) tcbsize = 2 * sizeof(Elf_Addr); @@ -307,7 +305,7 @@ _init_tls(void) for (i = 0; (unsigned) i < phnum; i++) { if (phdr[i].p_type == PT_TLS) { - tls_static_space = round(phdr[i].p_memsz, + tls_static_space = roundup2(phdr[i].p_memsz, phdr[i].p_align); tls_init_size = phdr[i].p_filesz; tls_init = (void*) phdr[i].p_vaddr; |