This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: typedef void * SCM


On Fri, 18 Feb 2000, Han-Wen Nienhuys wrote:

> OK, read the thread. One thing that bugs me is the fact that
> 
>     ((long)ptr) |= 3;
> 
> might be optimized away by a compiler that knows about aligned
> pointers.  Would it help against this if I used inline functions
> instead?

Hmmm... you would most probably get the same effect then, because using
inline functions is exactly to allow all kinds of optimizations to
happen.  If the compiler would normally optimize this code, but
would not if if was done using inline functions, you would think of
the compiler as being broken.  (Inline functions can basically be seen as
a type and sideeffect safe macro replacement.)

However, what I learn from your example is, that we may have to provide a
fallback 'typedef long SCM' mode for some compilers.  Thus, for a solution
that adds up all ideas up to now (as I would suggest it) we end up with
the following choices, which should be tested in the given order:


* are efficient transparent unions available?  (Ken Raeburn was looking
  at providing these for gcc.  I don't exactly know what their current
  semantics are, but from the discussion I assume they will provide the
  desired type safety.)

  --> typedef union { long n; } __attribute__ ((transparent_union)) SCM;

* compile time debug mode?  (There are some of us who would like and
  use this feature, at least from time to time.)

  --> typedef union { long n; } SCM;

* can void ptrs safely be used?

  --> typedef void * SCM;

* fallback

  --> typedef long SCM;


Best regards
Dirk Herrmann







Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]