From 6b2d5217d718aa127da8ed23c5d2198199fd9b84 Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Mon, 18 Apr 2016 16:25:37 +0000 Subject: [PATCH] Re-use our roundup2() macro instead of reinventing the wheel. Obtained from: DragonflyBSD --- lib/libc/gen/tls.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c index dd1e7dfac77..6cba47fe3d3 100644 --- a/lib/libc/gen/tls.c +++ b/lib/libc/gen/tls.c @@ -33,6 +33,7 @@ */ #include +#include #include #include #include @@ -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;