*BSD News Article 84575


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!news.wildstar.net!news.ececs.uc.edu!news.kei.com!news.mathworks.com!www.nntp.primenet.com!nntp.primenet.com!nntp.uio.no!news.apfel.de!nntp.zit.th-darmstadt.de!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: 9 Dec 1996 16:54:32 GMT
Organization: Technical University of Berlin, Germany
Lines: 37
Distribution: inet
Message-ID: <58hg88$1gn$1@news.cs.tu-berlin.de>
References: <32986299.AC7@mail.esrin.esa.it> <587shd$2sb@anorak.coverform.lan> <58bnr0$q9q$1@news.cs.tu-berlin.de> <58cp11$jkq@cynic.portal.ca>
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:91873 comp.unix.bsd.misc:1737 comp.unix.internals:11528

In article <58cp11$jkq@cynic.portal.ca>,
Curt Sampson <cjs@cynic.portal.ca> wrote:
>In article <58bnr0$q9q$1@news.cs.tu-berlin.de>,
>Joerg Schilling <js@cs.tu-berlin.de> wrote:
>:In article <587shd$2sb@anorak.coverform.lan>,
>:Brian Somers <brian%anorak.coverform.lan@awfulhak.demon.co.uk> wrote:
>:>
>:>How do you align a pointer if you can't cast it to some kind of number ?
>:
>:On any two's complement machine this can easily be done, if
>:sizeof (alignement type) < sizeof (int)
>:...
>:#define xalign(x, a, m)         ( ((char *)(x)) + ( (a) - (((int)(x))&(m))) )
>
>You've just gone and cast the pointer to a type of number (int, in
>this case). The question was how you do this alignment *without*
>the cast.

If I remember right, the question was how to align a pointer
without having an int that has the same size as the pointer.

You can modify my example to:

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

and it still works if the the alignment you want is smaller than
2 ** 15 - 1 = 32767

so printf is the only *big* problem for going to 64 bit.
(see my posting related to printf in the same thread)

Joerg
-- 
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