delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2023/01/25/16:48:51

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112;
h=content-transfer-encoding:in-reply-to:from:to:references
:content-language:subject:user-agent:mime-version:date:message-id
:from:to:cc:subject:date:message-id:reply-to;
bh=c249pQ8U5utkdMXdEyU9NEHx8/0YarrPwNwOwqoNxts=;
b=pNE4inbw2pnqYknEVHPlto8TVMNT8TqqEl8rQa4ULye9taT+j8osnQAjxmy0t3NEpW
LoVYTkDCdaZCdvzj1QeG1gEJKtywAOD9B3XpRAIswwqMLjQ5UOhVGZGZzBQuJ9y6rsMF
F4ZqiQ4/d0k6er706bqFwOW1cc9og4Ue9JvhqJVoY+mZatZUUIY7vDU8IGMFNCNkAP7a
Ej63WrA+QWHuKpaVwwUSwwBGvDZwCgwqfHztoqbD9wTE2N57hDANriFp/c1oZG/LxVpO
FCfuxP9r6avXRv9PvPHbr1wVp1L9tqUGPh8b/g6IncKhQkZYvMWghexJrEf9wAq9uS2L
MZoQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=content-transfer-encoding:in-reply-to:from:to:references
:content-language:subject:user-agent:mime-version:date:message-id
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=c249pQ8U5utkdMXdEyU9NEHx8/0YarrPwNwOwqoNxts=;
b=63et/PuBNPxNiRIAoZU5VfszkaDUd8RvVRz/qacruBUM2dYZ+XRYFmqGMhgtvLV1RM
SoD3uhaYEW/1+zjg+zphJG3sj5QMlDL/v/pOZuz3ayUPcJX5agSn2RdpICP5tj1kSZsQ
rhxhMliQ+QUWyUB+ZTOljxL8qpss636K7p1u4twjUscmC4yAOjZMb8IhTsOAB0Ag/2JT
MACfNVRvAdhuHhCWVlkZJ8EVI/ilORdy05M9SNioy8lKDBzQQBNrO3EF3wXognhr19Zy
uevuiagPg5FNjnDYjfoH1tZxuuuPojr7hkuRs50OT5A2roIhDPcnA0SDgJFazWHgGAum
dRMg==
X-Gm-Message-State: AFqh2krUqW484+xQH43r1xU/NYPkaYihyBfFBvvyDX858Yg/32rOjflc
/PEAokA1YGvTBrxtfbcLXz9Nnkg+SGcDwQ==
X-Google-Smtp-Source: AMrXdXs6CDXwPLm7iLhdvbksrcMFo8jCrRNk/lPRvG0sOh2VPlnf233TcMsPAg97rs1jNrYQF/23bA==
X-Received: by 2002:a17:907:8dca:b0:85f:5d72:1841 with SMTP id tg10-20020a1709078dca00b0085f5d721841mr38116656ejc.39.1674683125966;
Wed, 25 Jan 2023 13:45:25 -0800 (PST)
Message-ID: <fc07cacc-a161-fec8-4f4d-8885e0d4ed6b@gmail.com>
Date: Wed, 25 Jan 2023 22:45:24 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Subject: [PING][PATCH] increase stack and malloc alignment to 16 bytes
References: <20211125151322 DOT 439824-1-jwjagersma AT gmail DOT com>
To: djgpp AT delorie DOT com
From: "J.W. Jagersma (jwjagersma AT gmail DOT com) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
In-Reply-To: <20211125151322.439824-1-jwjagersma@gmail.com>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Pinging another patch that I think is important, particularly for -msse users.

Note that gcc / libstdc++ also expect 16-byte alignment, as evidenced by
alignof(std::max_align_t) == 16, the macro __STDCPP_DEFAULT_NEW_ALIGNMENT__
(defined to 16), and the fact that it always bumps the stack pointer by
multiples of 16.


On 2021-11-25 16:13, J.W. Jagersma wrote:
> The section alignment patch I posted here earlier has been accepted in binutils,
> so that will be available in the next release.
> 
> Now in libc only these two lines need to be adjusted, and then all code, data,
> stack and heap will be aligned to 16 byte boundaries.
> 
> Should be good for SSE, hopefully it will help resolve the gcc 11 Ada issue too.
> 
> ---
>  src/libc/ansi/stdlib/nmalcdef.h | 2 +-
>  src/libc/crt0/crt0.S            | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libc/ansi/stdlib/nmalcdef.h b/src/libc/ansi/stdlib/nmalcdef.h
> index cb41f619..495c63a6 100644
> --- a/src/libc/ansi/stdlib/nmalcdef.h
> +++ b/src/libc/ansi/stdlib/nmalcdef.h
> @@ -188,7 +188,7 @@ typedef struct memblock {
>  /* conversion and access macros */
>  #define MEMBLKp(p) (memblockp)((byte*)(p) - DATAOFFSET)
>  #define PTR(m)     (void*)((byte*)(m) + DATAOFFSET)
> -#define ALIGN 8
> +#define ALIGN 16
>  
>  #define ALIGNMASK (ALIGN-1)
>  
> diff --git a/src/libc/crt0/crt0.S b/src/libc/crt0/crt0.S
> index 446a989b..226f0cb9 100644
> --- a/src/libc/crt0/crt0.S
> +++ b/src/libc/crt0/crt0.S
> @@ -315,7 +315,7 @@ use_stubinfo_stack_size:
>  	addl	__stklen, %eax
>  	movw	%ds, %dx		/* set stack */
>  	movw	%dx, %ss
> -	andb	$0xf8, %al		/* align to 8-byte boundary */
> +	andb	$0xf0, %al		/* align to 16-byte boundary */
>  	movl	%eax, %esp
>  	movl	%eax, ___djgpp_stack_top	/* Top of stack */
>  	subl	___djgpp_stack_limit, %eax

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019