www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/06/00:39:58

From: j DOT aldrich6 AT genie DOT com
Message-Id: <199606060420.AA118684823@relay1.geis.com>
Date: Thu, 6 Jun 96 04:19:00 UTC 0000
To: djgpp AT delorie DOT com
Mime-Version: 1.0
Subject: Re: [?] aligning value returne

Reply to message 1939282    from KAGEL AT DG1 DOT BLO on 06/05/96  9:15AM


>MYTYPE *aligned, *unaligned;   /* Or some reasonable typedef. */
>
>aligned = (MYTYPE *)((unsigned)un_aligned
>		          +(unsigned)alignment  /*Advance pointer alignment */
>/*Backup by #misaligned bytes*/ -((unsigned)un_aligned %
(unsigned)alignment));
>
>You want to advance the pointer to the next higher aligned address.  This
>simple code, as suggested by John Aldrich with correction, is clearer than the
>'&~' code M. Latorre came up with and  the optimizer should do a good job at
>making it efficient.

Ah, I see what my mistake was.  Thanks for the correction.  :)

John

- Raw text -


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