Path: utzoo!mnetor!uunet!husc6!uwvax!astroatc!johnw From: johnw@astroatc.UUCP (John F. Wardale) Newsgroups: comp.arch Subject: Re: RISC data alignment Message-ID: <762@astroatc.UUCP> Date: 29 Jan 88 06:27:12 GMT References: <2635@calmasd.GE.COM> <3195@cbmvax.UUCP> <354@ridge.UUCP> Reply-To: johnw@astroatc.UUCP (John F. Wardale) Organization: Astronautics Technology Cntr, Madison, WI Lines: 46 In article <354@ridge.UUCP> klein@ridge.UUCP (Doug Klein) writes: >FORTRAN example 1) > >Programmer decides he needs a "array copy" routine. For whatever reason >he decides that the fastest way to copy data is to use: > > subroutine copy(a,b,count) > double precision a(1),b(1) > ... > >Now he calls it from somewhere as: > > integer x(100),y(100) > ... > call copy(x,y,100) Not only is this UNDEFINED by the Fortarn standard, the "accepted" assumetime in Fortran is sizeof(double) == 2*sizeof(int) == 2*sizeof(real) So, this will (possibly/probably) copy *TWICE* the span of X !!! The "Proper" way to do this is to have CCOPY, ICOPY, RCOPY, DCOPY, ZCOPY for CHARACTER, INTEGER, REAL, DOUBLEPRECISION, COMPLEX. This is why Ada added Generics and all the "overlaoding" stuff! > a common practice in large C applications >is to malloc a big chunk of space, and then start putting arbitrary >structures in it. .... >The workaround has usually been to put some "aligning" code into >the low-level routines, The BSD 4.3 malloc grabs memory by the page (at least page aligned) and manages pools of bocks for each power of 2 size. Thus these WILL be sufficently aligned!! I claim that any other maolloc where: p = (struct anything)malloc(xxx); or at least: p = (struct anything)malloc(sizeof(struct anything); can cause an error is a *SYSTEM* bug in *MALLOC* !!! -- John Wardale ... {seismo | harvard | ihnp4} ! {uwvax | cs.wisc.edu} ! astroatc!johnw To err is human, to really foul up world news requires the net!