Re: [patch] ORBit2 allocator problem



On Thu, Dec 19, 2002 at 05:13:20PM +0000, Michael Meeks wrote:
> Hi Richard,
> 
> On Wed, 2002-12-18 at 21:55, Richard Zidlicky wrote:
> > Afaics only the lowest bit of the pointer is (ab)used so an alignment
> > of 2 should be still sufficient - if not then we have a problem.
> 
> 	Ah - ok, so we always assume that we'll get memory back from malloc
> that is aligned to at least 2 byte boundaries - and for GIOP marshalling
> we need it aligned to 8 byte boundaries. The string code uses the bottom
> bit of the pointer to flag allocated strings to save a potentially large
> header block.

so you need 8 bytes alignment? glibc won't guarantee that I think.

malloc should return at least 2 byte alignment. If more alignment 
is neded then further work is required, this is a summary of issues 
I got with various lisp/gc systems on m68k:
	- align address returned by malloc. Possibly glibc might 
	  do some alignment but it is always good to make that 
	  explicit.
	- ensure natural alignment of objects in structs, can 
          be achieved by explicit padding or better by ordering 
          struct members by alignment requirements (biggest 
	  alignment first). Also elements in arrays may need 
	  explicit padding.

> 	Possibly you're falling foul of that somehow;
> 
> >  	/* the allocation code uses the bottom bit of any pointer */
> > -	g_assert (ORBIT_ALIGNOF_CORBA_DOUBLE > 2);
> > +	g_assert (ORBIT_ALIGNOF_CORBA_DOUBLE >= 2);
> >  
> >  	ORBit_option_parse (argc, argv, orbit_supported_options);
> 
> 	What libc are you using ?

glibc-2.2.90

Richard



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]