Re: 16 bit platform bug and binary compatibility issues

From: Daniel A. Koepke (dkoepke@circlemud.org)
Date: 06/02/01


On Sat, 2 Jun 2001, George Greer wrote:

> Actually, we can't do it because it would break 64-bit platforms.

We can add an int32_t typedef/macro and have configure determine the size
of a 32-bit integer on the given platform.

  dnl Find what int32_t should be, regardless of whether or not the
  dnl system already defines it (we'll find that out later).  This way
  dnl we can use AC_CHECK_TYPE.  Hopefully this will work with C99's
  dnl <inttypes.h> header, otherwise we'll have to do more.

  AC_CHECK_CACHE([for sizeof(long)], ac_sizeof_long,
    AC_TRY_RUN([int main() { return (sizeof(long)); }], ,
               ac_cv_sizeof_long=$?)])

  if test ac_cv_sizeof_long = 4; then
    AC_CHECK_TYPE(int32_t, long)
  else
    AC_CHECK_TYPE(int32_t, int)
  fi

General idea being if the system doesn't define the int32_t where
AC_CHECK_TYPE looks for it, we find out if 'long' is the 32-bit integer
type (4 bytes) and define int32_t as such if it is; otherwise, we define
'int' to be int32_t.  So

  Platform     int32_t

  16-bit       long
  32-bit       long
  64-bit       int

I'd imagine that more recent versions of autoconf check <inttypes.h>, or
that the ISO standard specifies mandatory inclusion of <inttypes.h>
through <sys/types.h> or similar.  I also imagine that by the time we get
around to anything beyond 64-bit architectures, compilers will be in
compliance with the standard and thus define int32_t for us.

Any thoughts?


-dak

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/05/01 PST