svn commit: r298215 - head/lib/libc/gen

Pedro F. Giffuni pfg at FreeBSD.org
Mon Apr 18 16:25:39 UTC 2016


Author: pfg
Date: Mon Apr 18 16:25:37 2016
New Revision: 298215
URL: https://svnweb.freebsd.org/changeset/base/298215

Log:
  Re-use our roundup2() macro instead of reinventing the wheel.
  
  Obtained from:	DragonflyBSD

Modified:
  head/lib/libc/gen/tls.c

Modified: head/lib/libc/gen/tls.c
==============================================================================
--- head/lib/libc/gen/tls.c	Mon Apr 18 15:08:31 2016	(r298214)
+++ head/lib/libc/gen/tls.c	Mon Apr 18 16:25:37 2016	(r298215)
@@ -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 t
 
 #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 tcbsiz
 	 * 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
 	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;


More information about the svn-src-head mailing list