guile-devel
[Top][All Lists]
Advanced

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

Re: [BDW-GC] Static cell/string/symbol allocation


From: Ludovic Courtès
Subject: Re: [BDW-GC] Static cell/string/symbol allocation
Date: Tue, 13 Jan 2009 01:04:05 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux)

Hi Ken,

Thanks for your reply.

Ken Raeburn <address@hidden> writes:

> There's no portable way, but it might be a bit more likely to happen
> if you try something like:
>
> union {
>   scm_t_cell cell[2];
>   double d_for_alignment;
>   long long ll_for_alignment;
> }

The issue with this is that there's nothing telling us how compilers
should behave when encountering this.  Even if the underlying hardware
has a preferred alignment for these types, the compiler doesn't have to
honor it (on some RISC architectures the alignment can be mandated, and
failing to honor them would lead to SIGBUS).  So that appears to be
quite unreliable.

> It's still no guarantee, but I think most systems will align either
> double or long long strictly enough.  And you could use __aligned__
> conditionally, too, for more than just GCC.  There are alignment
> pragma directives available in a number of compilers, but using them
> with macros may not be practical.  (Unfortunately for installed
> headers you should probably use compiler predefined macro tests rather
> than autoconf tests, since two compilers could be used on one system.)

Exactly.  I'm currently opting for something along the lines of:

  #if (defined __GNUC__)
  # define SCM_ALIGNED(x)  __attribute__ ((aligned (x)))
  #elif (defined __INTEL_COMPILER)
  # define SCM_ALIGNED(x)  __declspec (align (x))
  #else
  /* Don't know how to align things.  */
  # undef SCM_ALIGNED
  #endif

... with code that just keeps using dynamic allocation when
`SCM_ALIGNED' is undefined.

Thanks,
Ludo'.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]