Use alignof and not size_t for platforms with non-natural base

alignments.
This commit is contained in:
joerg 2019-11-05 22:22:42 +00:00
parent 19dbe0f014
commit 336e4f812b
2 changed files with 8 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: tls.c,v 1.10 2019/11/04 12:45:10 joerg Exp $ */
/* $NetBSD: tls.c,v 1.11 2019/11/05 22:22:42 joerg Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: tls.c,v 1.10 2019/11/04 12:45:10 joerg Exp $");
__RCSID("$NetBSD: tls.c,v 1.11 2019/11/05 22:22:42 joerg Exp $");
#include "namespace.h"
@ -46,6 +46,7 @@ __RCSID("$NetBSD: tls.c,v 1.10 2019/11/04 12:45:10 joerg Exp $");
#include <link_elf.h>
#include <lwp.h>
#include <stdbool.h>
#include <stdalign.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
@ -85,7 +86,7 @@ _rtld_tls_allocate(void)
if (initial_thread_tcb == NULL) {
#ifdef __HAVE_TLS_VARIANT_II
tls_size = roundup2(tls_size, sizeof(max_align_t));
tls_size = roundup2(tls_size, alignof(max_align_t));
#endif
tls_allocation = tls_size + sizeof(*tcb);

View File

@ -1,4 +1,4 @@
/* $NetBSD: tls.c,v 1.13 2019/11/04 12:45:10 joerg Exp $ */
/* $NetBSD: tls.c,v 1.14 2019/11/05 22:22:42 joerg Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
* All rights reserved.
@ -29,11 +29,12 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: tls.c,v 1.13 2019/11/04 12:45:10 joerg Exp $");
__RCSID("$NetBSD: tls.c,v 1.14 2019/11/05 22:22:42 joerg Exp $");
#include <sys/param.h>
#include <sys/ucontext.h>
#include <lwp.h>
#include <stdalign.h>
#include <stddef.h>
#include <string.h>
#include "debug.h"
@ -100,7 +101,7 @@ _rtld_tls_initial_allocation(void)
#ifndef __HAVE_TLS_VARIANT_I
_rtld_tls_static_space = roundup2(_rtld_tls_static_space,
sizeof(max_align_t));
alignof(max_align_t));
#endif
dbg(("_rtld_tls_static_space %zu", _rtld_tls_static_space));