*BSD News Article 83841


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!spool.mu.edu!uwm.edu!math.ohio-state.edu!howland.erols.net!news.mathworks.com!fu-berlin.de!cs.tu-berlin.de!js
From: js@cs.tu-berlin.de (Joerg Schilling)
Newsgroups: comp.unix.solaris,comp.unix.bsd.misc,comp.unix.internals
Subject: Re: Solaris 2.6
Date: 28 Nov 1996 21:31:46 GMT
Organization: Technical University of Berlin, Germany
Lines: 53
Message-ID: <57l0c2$m9n$1@news.cs.tu-berlin.de>
References: <32986299.AC7@mail.esrin.esa.it> <casper.329abb76@mail.fwi.uva.nl> <x7917mx5gx.fsf@dumbcat.codewright.com> <slrn59q566.3s2.dave@pc-damir.srce.hr>
NNTP-Posting-Host: 130.149.25.72
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Xref: euryale.cc.adfa.oz.au comp.unix.solaris:90821 comp.unix.bsd.misc:1623 comp.unix.internals:11365

How about

#define ALIGN_DOUBLE    4       /* alignement value for (double *)      */
#define ALIGN_DMASK     3       /* alignement mask  for (double *)      */

define xalign(x, a, m)         ( ((char *)(x)) + ( (a) - (((int)(x))&(m))) )

#define dalign(x)               xalign((x), ALIGN_DOUBLE, ALIGN_DMASK)

It will only do relative arithmetik and runs on any two's complement machine.


Joerg

N.B. These are extracts from a file align.h that is generated
from a c-program  

In article <slrn59q566.3s2.dave@pc-damir.srce.hr>,
Drazen Kacar <dave@fly.cc.fer.hr> wrote:
>In article <x7917mx5gx.fsf@dumbcat.codewright.com>, Marco S Hyman wrote:
>>eggert@twinsun.com (Paul Eggert) writes:
>>
>>> While we're on the subject, when will Solaris migrate to the right way
>>> of doing things: int = 32 bits, long = 64?  Perhaps this will be
>>> another set of ifdefs in the Solaris 2.7 include files (:-)?
>>
>>Wellllll, I'll let you in on the secret ..... its a two stage process.
>>
>>Stage 1:
>>Keep long 32 bits but now with 64 bit pointers so you can catch every
>>program that assumes a pointer can be stored in a long or int.
>
>How can I portably manipulate bits in pointers? Sometimes I need to
>find the page boundary, eg.
>
>char *p;
>
>p = (char *)((long)p & -getpagesize());
>
>If long can't hold the pointer, I can change it to long long, but it
>will break on compilers that don't suport it.
>
>And sometimes I need to align the structure, eg.
>
>p = (struct foo *)(((long)p+sizeof(double)-1) & -sizeof(double));
>
>How should I do it?

-- 
EMail:	joerg@schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin
	js@cs.tu-berlin.de		  (uni)  If you don't have iso-8859-1
	jes@fokus.gmd.de		  (work) chars my name is
URL:	http://www.fokus.gmd.de/usr/schilling    J"org Schilling