*BSD News Article 84434


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.mel.connect.com.au!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!howland.erols.net!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: 7 Dec 1996 12:27:12 GMT
Organization: Technical University of Berlin, Germany
Lines: 33
Distribution: inet
Message-ID: <58bnr0$q9q$1@news.cs.tu-berlin.de>
References: <32986299.AC7@mail.esrin.esa.it> <casper.329d5a07@mail.fwi.uva.nl> <5869r2$175$1@asgard.sprintlink.co.za> <587shd$2sb@anorak.coverform.lan>
NNTP-Posting-Host: 130.149.17.8
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:91713 comp.unix.bsd.misc:1722 comp.unix.internals:11503

In article <587shd$2sb@anorak.coverform.lan>,
Brian Somers <brian%anorak.coverform.lan@awfulhak.demon.co.uk> wrote:
>In article <5869r2$175$1@asgard.sprintlink.co.za>,
>	philips@asiatech.co.za (philip Shearer) writes:
>: I don't see why anyone needs to store pointers as ints or longs
>: store the them as pointers.
>
>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)
You may check this out by replacing the cast to int by a cast to char
in the folloging code.

Joerg

#define ALIGN_DOUBLE    8       /* alignment value for (double *)       */
#define ALIGN_DMASK     7       /* alignment mask  for (double *)       */

#define xaligned(a, s)          ((((int)(a)) & s) == 0 )
#define x2aligned(a, b, s)      (((((int)(a)) | ((int)(b))) & s) == 0 )

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

#define daligned(a)             xaligned(a, ALIGN_DMASK)
#define d2aligned(a, b)         x2aligned(a, b, ALIGN_DMASK)

#define dalign(x)               xalign((x), ALIGN_DOUBLE, ALIGN_DMASK)
-- 
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