unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* autconf stdint types checking in guile-core
@ 2003-04-15 19:01 Thamer Al-Harbash
  2003-04-16  5:54 ` Rob Browning
  2003-04-16  6:16 ` Rob Browning
  0 siblings, 2 replies; 7+ messages in thread
From: Thamer Al-Harbash @ 2003-04-15 19:01 UTC (permalink / raw)


Robert Browning was kind enough to point out on the guile user's
mailing list that guile -current recently got support for C99
stdint types.

I looked at the autoconf tests for the types and would like to
point out that they may break on exceptionally exotic
architectures. The problem is, as most probably know, that the C
standard has always defined sizeof(char) to return 1 byte. The
definition of byte though is not necessarily an 8 bit storage
unit. It's whatever CHAR_BIT is set to via limits.h

Something like this:

if test "$ac_cv_sizeof_int" -eq 4; then
  SCM_I_GSC_T_INT32='"int"'
elif test "$ac_cv_sizeof_long" -eq 4; then
...

May break because 4 in this case may mean 64 bits on a machine
with 16-bit "bytes" where CHAR_BIT is 16.

I'd say doing a sizeof(foo) * value of CHAR_BITS would give you
the total bits and be a better indicator of int8_t, int16_t etc.

This may be overzealous. I'd be glad to submit a patch to the
autoconf tests to detect this more robustly.

-- 
Thamer Al-Harbash            http://www.whitefang.com/
	(if (> pressure too-much-pressure)
		'flame 'work)


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: autconf stdint types checking in guile-core
  2003-04-15 19:01 autconf stdint types checking in guile-core Thamer Al-Harbash
@ 2003-04-16  5:54 ` Rob Browning
  2003-04-16  6:16 ` Rob Browning
  1 sibling, 0 replies; 7+ messages in thread
From: Rob Browning @ 2003-04-16  5:54 UTC (permalink / raw)
  Cc: guile-devel

Thamer Al-Harbash <tmh@whitefang.com> writes:

> I looked at the autoconf tests for the types and would like to point
> out that they may break on exceptionally exotic architectures. The
> problem is, as most probably know, that the C standard has always
> defined sizeof(char) to return 1 byte. The definition of byte though
> is not necessarily an 8 bit storage unit. It's whatever CHAR_BIT is
> set to via limits.h

Hmm.  You're right, and that's definitely my fault.  I knew better,
but forgot to go back and fix that up before I committed.  I'll fix it
now.

Thanks

-- 
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592  F9A0 25C8 D377 8C7E 73A4


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: autconf stdint types checking in guile-core
  2003-04-15 19:01 autconf stdint types checking in guile-core Thamer Al-Harbash
  2003-04-16  5:54 ` Rob Browning
@ 2003-04-16  6:16 ` Rob Browning
  2003-04-16  7:28   ` Thamer Al-Harbash
  2003-04-16 12:11   ` Marius Vollmer
  1 sibling, 2 replies; 7+ messages in thread
From: Rob Browning @ 2003-04-16  6:16 UTC (permalink / raw)
  Cc: guile-devel

Thamer Al-Harbash <tmh@whitefang.com> writes:

> if test "$ac_cv_sizeof_int" -eq 4; then
>   SCM_I_GSC_T_INT32='"int"'
> elif test "$ac_cv_sizeof_long" -eq 4; then
> ...

Actually, this may be hard to get right.  I haven't yet figured out a
way to get the value of CHAR_BIT either at configure time, or from the
C compiler at gen-scmconfig time in the cross-compilation case...

-- 
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592  F9A0 25C8 D377 8C7E 73A4


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: autconf stdint types checking in guile-core
  2003-04-16  6:16 ` Rob Browning
@ 2003-04-16  7:28   ` Thamer Al-Harbash
  2003-04-16  8:59     ` tomas
  2003-04-16 12:11   ` Marius Vollmer
  1 sibling, 1 reply; 7+ messages in thread
From: Thamer Al-Harbash @ 2003-04-16  7:28 UTC (permalink / raw)


On Wed, 16 Apr 2003, Rob Browning wrote:

> Actually, this may be hard to get right.  I haven't yet figured out a
> way to get the value of CHAR_BIT either at configure time, or from the
> C compiler at gen-scmconfig time in the cross-compilation case...

Is AC_TRY_RUN at configure time bad for cross compilation? I'm
assuming it is. Otherwise, AC_TRY_RUN a program that includes
limits.h, outputs the number of bits to a temporary file, read it
in and then make sure to put that temporary file in CLEANFILES in
the Makefile.am If CHAR_BITS is not defined put -1 in the file
meaning undefined.

The only other way is to use the preprocessor. I'm fairly certain
using -dM won't be portable everywhere though :|

char_bits=echo "#include <limits.h>" | cpp -dM | awk '/#define.*CHAR_BIT/ { pintf("%s", $3);}'

Using the preprocessor is more friendly to cross compilation
since we'd be, technically, be preprocessing the target hosts
header files.

-- 
Thamer Al-Harbash            http://www.whitefang.com/
	(if (> pressure too-much-pressure)
		'flame 'work)


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: autconf stdint types checking in guile-core
  2003-04-16  7:28   ` Thamer Al-Harbash
@ 2003-04-16  8:59     ` tomas
  0 siblings, 0 replies; 7+ messages in thread
From: tomas @ 2003-04-16  8:59 UTC (permalink / raw)
  Cc: guile-devel

On Wed, Apr 16, 2003 at 03:28:21AM -0400, Thamer Al-Harbash wrote:
> On Wed, 16 Apr 2003, Rob Browning wrote:
> 
> > Actually, this may be hard to get right.  I haven't yet figured out a
> > way to get the value of CHAR_BIT either at configure time, or from the
> > C compiler at gen-scmconfig time in the cross-compilation case...
> 
> Is AC_TRY_RUN at configure time bad for cross compilation? I'm
> assuming it is.

It is. You *get* the characteristics of the machine you are compiling
on [1]. You *want* the characteristics of the machine your compiled stuff
is supposed to be run.

There is no simple solution to this problem, IMHO, short of...
say building a `probe' program you send to the target machine
to collect characteristics and `bring them back' to the compilation
host.

Does auto-* have such a thing?

-------
[1] To be more precise ...the machine you are running configure on.

Regards
-- tomas


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: autconf stdint types checking in guile-core
  2003-04-16  6:16 ` Rob Browning
  2003-04-16  7:28   ` Thamer Al-Harbash
@ 2003-04-16 12:11   ` Marius Vollmer
  2003-04-16 16:22     ` Rob Browning
  1 sibling, 1 reply; 7+ messages in thread
From: Marius Vollmer @ 2003-04-16 12:11 UTC (permalink / raw)
  Cc: guile-devel

Rob Browning <rlb@defaultvalue.org> writes:

> Actually, this may be hard to get right.

Just assuming CHAR_BIT is 8 is good enough, I say.  Machines that
don't have 8 bit bytes, if there still are any, should provide
stdint.h.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: autconf stdint types checking in guile-core
  2003-04-16 12:11   ` Marius Vollmer
@ 2003-04-16 16:22     ` Rob Browning
  0 siblings, 0 replies; 7+ messages in thread
From: Rob Browning @ 2003-04-16 16:22 UTC (permalink / raw)
  Cc: guile-devel

Marius Vollmer <mvo@zagadka.de> writes:

> Just assuming CHAR_BIT is 8 is good enough, I say.  Machines that
> don't have 8 bit bytes, if there still are any, should provide
> stdint.h.

OK.  I've at least fixed our code to use SCM_CHAR_BIT in a few places
where we were using CHAR_BIT or 8.

-- 
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592  F9A0 25C8 D377 8C7E 73A4


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-04-16 16:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-15 19:01 autconf stdint types checking in guile-core Thamer Al-Harbash
2003-04-16  5:54 ` Rob Browning
2003-04-16  6:16 ` Rob Browning
2003-04-16  7:28   ` Thamer Al-Harbash
2003-04-16  8:59     ` tomas
2003-04-16 12:11   ` Marius Vollmer
2003-04-16 16:22     ` Rob Browning

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).