guile-devel
[Top][All Lists]
Advanced

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

Re: scm_bits_t / scm_ubits_t


From: Jacques A. Vidrine
Subject: Re: scm_bits_t / scm_ubits_t
Date: Sat, 26 May 2001 12:08:12 -0500
User-agent: Mutt/1.2.5i

On Sat, May 26, 2001 at 01:13:18PM +0200, Marius Vollmer wrote:
> Michael Livshin <address@hidden> writes:
> 
> > Marius Vollmer <address@hidden> writes:
> > 
> > > Moreover, I think I want to reserve judgment about the whole change.
> > 
> > FWIW, I'll revert the controversial changes within the next two days.
> > sorry about the whole thing.
> 
> Hmm, yes, if that is easy to do for you, please do so.  However, it is
> probably also OK just to fix a few things about that change, without
> reverting it completely.
> 
> It's good that you did that work.
> 
> The main thing to fix as far as I can see it, is that you use
> scm_bits_t (scm_ubits_t) as a numerical type.  We should probably just
> define a new type that is as large as scm_bits_t and make a signed and
> a unsigned variant of it so that it can be used as a numerical type
> (or just say that one can stick "unsigned" in front of it).  That type
> will be large enough to enumerate all objects that can be represented
> by a (packed) scm_bits_t, that is, it is large enough to hold the
> length of all possible lists, of all possible vectors, etc.  What
> about naming that type scm_length_t?  (And scm_ulength_t).
> 
> > the whole mess was motivated by me reading the latest (well, draft)
> > ANSI C standard and noticing that `long' is no longer required to be
> > the widest integral type...
> 
> How do we get at the integral type that is guaranteed to hold all
> pointers?

intptr_t/uintptr_t.  These are defined  by ISO/IEC 9899:1999 (aka C99)
(and are included in POSIX 1003.1-2000 draft 6).  They are supposed to
be defined in <stdint.h>.

Unfortunately,  they are  not yet  widely implemented.   GCC does  not
provide <stdint.h> at all.  Sometimes  the definition will be found in
a non-standard  place.  For  example, on  FreeBSD, Solaris,  and IRIX,
these are defined by including <sys/types.h>.

I  guess I  would  recommend  groping for  a  uintptr_t definition  in
<stdint.h>  and <sys/types.h>,  and  using  some reasonable  fallbacks
(possibly dependent  on the operating  system).  Use uintptr_t  in the
source.  Typedef it  to `unsigned long' (or  possibly other, depending
on platform) if it isn't defined by the system.

By the way, as an aside, technically all type names ending in `_t' are
reserved by POSIX and shouldn't  be defined by applications.  At least
Guile uses an `scm_' prefix, which reduces the chances of a conflict.

Cheers,
-- 
Jacques Vidrine / address@hidden / address@hidden / address@hidden



reply via email to

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