2012-05-21 04:12:37 -07:00
|
|
|
dnl This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
dnl License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
Bug 465640: Use autoconf to declare stdint types on platforms that don't have stdint.h r=bsmedberg
At configure time, check for <stdint.h>. If we don't have it, find
integer types of various sizes. On Windows, where we can't run
compilation tests in configure, hard-code definitions suggesting the
use of the built-in __intN types for the exact-size types, and
<stddef.h> for the pointer-sized types.
Use namespace-clean names for the preprocessor macros we define.
Since these types are used in the public JavaScript API, the configure
script needs to place the definitions it finds in js-config.h, the
installed configure-generated header, so it can be used by jsapi.h and
that gang.
New header js/src/jsstdint.h does what it takes to get definitions for
the exact-size and pointer-size integral types. It includes
<stdint.h> when available, uses the types found by configure.in to
define the {,u}int{8,16,32,64,ptr}_t types itself, or uses the __intN
types and the <stddef.h> header.
Remove now-unnecessary and possibly conflicting definitions of intN_t
types from js/src/nanojit/avmplus.h.
2009-01-13 10:50:24 -08:00
|
|
|
|
2009-01-14 12:56:30 -08:00
|
|
|
dnl MOZ_N_BYTE_TYPE(VARIABLE, SIZE, POSSIBLE-TYPES)
|
Bug 465640: Use autoconf to declare stdint types on platforms that don't have stdint.h r=bsmedberg
At configure time, check for <stdint.h>. If we don't have it, find
integer types of various sizes. On Windows, where we can't run
compilation tests in configure, hard-code definitions suggesting the
use of the built-in __intN types for the exact-size types, and
<stddef.h> for the pointer-sized types.
Use namespace-clean names for the preprocessor macros we define.
Since these types are used in the public JavaScript API, the configure
script needs to place the definitions it finds in js-config.h, the
installed configure-generated header, so it can be used by jsapi.h and
that gang.
New header js/src/jsstdint.h does what it takes to get definitions for
the exact-size and pointer-size integral types. It includes
<stdint.h> when available, uses the types found by configure.in to
define the {,u}int{8,16,32,64,ptr}_t types itself, or uses the __intN
types and the <stddef.h> header.
Remove now-unnecessary and possibly conflicting definitions of intN_t
types from js/src/nanojit/avmplus.h.
2009-01-13 10:50:24 -08:00
|
|
|
dnl
|
|
|
|
dnl Check to see which of POSSIBLE-TYPES has a size of SIZE. If we
|
2009-01-14 12:56:30 -08:00
|
|
|
dnl find one, define VARIABLE to be the size-BYTE type. If no type
|
Bug 465640: Use autoconf to declare stdint types on platforms that don't have stdint.h r=bsmedberg
At configure time, check for <stdint.h>. If we don't have it, find
integer types of various sizes. On Windows, where we can't run
compilation tests in configure, hard-code definitions suggesting the
use of the built-in __intN types for the exact-size types, and
<stddef.h> for the pointer-sized types.
Use namespace-clean names for the preprocessor macros we define.
Since these types are used in the public JavaScript API, the configure
script needs to place the definitions it finds in js-config.h, the
installed configure-generated header, so it can be used by jsapi.h and
that gang.
New header js/src/jsstdint.h does what it takes to get definitions for
the exact-size and pointer-size integral types. It includes
<stdint.h> when available, uses the types found by configure.in to
define the {,u}int{8,16,32,64,ptr}_t types itself, or uses the __intN
types and the <stddef.h> header.
Remove now-unnecessary and possibly conflicting definitions of intN_t
types from js/src/nanojit/avmplus.h.
2009-01-13 10:50:24 -08:00
|
|
|
dnl matches, exit the configure script with an error message. Types
|
|
|
|
dnl whose written form contains spaces should appear in POSSIBLE-TYPES
|
|
|
|
dnl enclosed by shell quotes.
|
|
|
|
dnl
|
2009-01-14 12:56:30 -08:00
|
|
|
dnl The cache variable moz_cv_n_byte_type_VARIABLE gets set to the
|
Bug 465640: Use autoconf to declare stdint types on platforms that don't have stdint.h r=bsmedberg
At configure time, check for <stdint.h>. If we don't have it, find
integer types of various sizes. On Windows, where we can't run
compilation tests in configure, hard-code definitions suggesting the
use of the built-in __intN types for the exact-size types, and
<stddef.h> for the pointer-sized types.
Use namespace-clean names for the preprocessor macros we define.
Since these types are used in the public JavaScript API, the configure
script needs to place the definitions it finds in js-config.h, the
installed configure-generated header, so it can be used by jsapi.h and
that gang.
New header js/src/jsstdint.h does what it takes to get definitions for
the exact-size and pointer-size integral types. It includes
<stdint.h> when available, uses the types found by configure.in to
define the {,u}int{8,16,32,64,ptr}_t types itself, or uses the __intN
types and the <stddef.h> header.
Remove now-unnecessary and possibly conflicting definitions of intN_t
types from js/src/nanojit/avmplus.h.
2009-01-13 10:50:24 -08:00
|
|
|
dnl type, if found.
|
|
|
|
dnl
|
|
|
|
dnl for example:
|
|
|
|
dnl MOZ_N_BYTE_TYPE([JS_INT32_T], [4], [int long 'long long' short])
|
|
|
|
dnl
|
2011-08-09 11:27:00 -07:00
|
|
|
AC_DEFUN([MOZ_N_BYTE_TYPE],
|
Bug 465640: Use autoconf to declare stdint types on platforms that don't have stdint.h r=bsmedberg
At configure time, check for <stdint.h>. If we don't have it, find
integer types of various sizes. On Windows, where we can't run
compilation tests in configure, hard-code definitions suggesting the
use of the built-in __intN types for the exact-size types, and
<stddef.h> for the pointer-sized types.
Use namespace-clean names for the preprocessor macros we define.
Since these types are used in the public JavaScript API, the configure
script needs to place the definitions it finds in js-config.h, the
installed configure-generated header, so it can be used by jsapi.h and
that gang.
New header js/src/jsstdint.h does what it takes to get definitions for
the exact-size and pointer-size integral types. It includes
<stdint.h> when available, uses the types found by configure.in to
define the {,u}int{8,16,32,64,ptr}_t types itself, or uses the __intN
types and the <stddef.h> header.
Remove now-unnecessary and possibly conflicting definitions of intN_t
types from js/src/nanojit/avmplus.h.
2009-01-13 10:50:24 -08:00
|
|
|
[
|
|
|
|
dnl The simplest approach would simply be to run a program that says
|
|
|
|
dnl printf ("%d\n", sizeof ($type));
|
|
|
|
dnl But that won't work when cross-compiling; this will.
|
|
|
|
AC_CACHE_CHECK([for a $2-byte type], moz_cv_n_byte_type_$1, [
|
|
|
|
moz_cv_n_byte_type_$1=
|
|
|
|
for type in $3; do
|
|
|
|
AC_TRY_COMPILE([],
|
|
|
|
[
|
|
|
|
int a[sizeof ($type) == $2 ? 1 : -1];
|
2010-07-18 02:19:48 -07:00
|
|
|
return 0;
|
Bug 465640: Use autoconf to declare stdint types on platforms that don't have stdint.h r=bsmedberg
At configure time, check for <stdint.h>. If we don't have it, find
integer types of various sizes. On Windows, where we can't run
compilation tests in configure, hard-code definitions suggesting the
use of the built-in __intN types for the exact-size types, and
<stddef.h> for the pointer-sized types.
Use namespace-clean names for the preprocessor macros we define.
Since these types are used in the public JavaScript API, the configure
script needs to place the definitions it finds in js-config.h, the
installed configure-generated header, so it can be used by jsapi.h and
that gang.
New header js/src/jsstdint.h does what it takes to get definitions for
the exact-size and pointer-size integral types. It includes
<stdint.h> when available, uses the types found by configure.in to
define the {,u}int{8,16,32,64,ptr}_t types itself, or uses the __intN
types and the <stddef.h> header.
Remove now-unnecessary and possibly conflicting definitions of intN_t
types from js/src/nanojit/avmplus.h.
2009-01-13 10:50:24 -08:00
|
|
|
],
|
|
|
|
[moz_cv_n_byte_type_$1=$type; break], [])
|
|
|
|
done
|
2009-01-28 09:01:40 -08:00
|
|
|
if test ! "$moz_cv_n_byte_type_$1"; then
|
Bug 465640: Use autoconf to declare stdint types on platforms that don't have stdint.h r=bsmedberg
At configure time, check for <stdint.h>. If we don't have it, find
integer types of various sizes. On Windows, where we can't run
compilation tests in configure, hard-code definitions suggesting the
use of the built-in __intN types for the exact-size types, and
<stddef.h> for the pointer-sized types.
Use namespace-clean names for the preprocessor macros we define.
Since these types are used in the public JavaScript API, the configure
script needs to place the definitions it finds in js-config.h, the
installed configure-generated header, so it can be used by jsapi.h and
that gang.
New header js/src/jsstdint.h does what it takes to get definitions for
the exact-size and pointer-size integral types. It includes
<stdint.h> when available, uses the types found by configure.in to
define the {,u}int{8,16,32,64,ptr}_t types itself, or uses the __intN
types and the <stddef.h> header.
Remove now-unnecessary and possibly conflicting definitions of intN_t
types from js/src/nanojit/avmplus.h.
2009-01-13 10:50:24 -08:00
|
|
|
AC_MSG_ERROR([Couldn't find a $2-byte type])
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
AC_DEFINE_UNQUOTED($1, [$moz_cv_n_byte_type_$1],
|
|
|
|
[a $2-byte type on the target machine])
|
|
|
|
])
|
2009-01-14 12:56:30 -08:00
|
|
|
|
|
|
|
dnl MOZ_SIZE_OF_TYPE(VARIABLE, TYPE, POSSIBLE-SIZES)
|
|
|
|
dnl
|
|
|
|
dnl Check to see which of POSSIBLE-SIZES is the sizeof(TYPE). If we find one,
|
|
|
|
dnl define VARIABLE SIZE. If no size matches, exit the configure script with
|
|
|
|
dnl an error message.
|
|
|
|
dnl
|
|
|
|
dnl The cache variable moz_cv_size_of_VARIABLE gets set to the size, if
|
|
|
|
dnl found.
|
|
|
|
dnl
|
|
|
|
dnl for example:
|
|
|
|
dnl MOZ_SIZE_OF_TYPE([JS_BYTES_PER_WORD], [void*], [4 8])
|
2011-08-09 11:27:00 -07:00
|
|
|
AC_DEFUN([MOZ_SIZE_OF_TYPE],
|
2009-01-14 12:56:30 -08:00
|
|
|
[
|
|
|
|
AC_CACHE_CHECK([for the size of $2], moz_cv_size_of_$1, [
|
|
|
|
moz_cv_size_of_$1=
|
|
|
|
for size in $3; do
|
|
|
|
AC_TRY_COMPILE([],
|
|
|
|
[
|
|
|
|
int a[sizeof ($2) == $size ? 1 : -1];
|
2010-07-18 02:19:48 -07:00
|
|
|
return 0;
|
2009-01-14 12:56:30 -08:00
|
|
|
],
|
|
|
|
[moz_cv_size_of_$1=$size; break], [])
|
|
|
|
done
|
2009-01-28 09:01:40 -08:00
|
|
|
if test ! "$moz_cv_size_of_$1"; then
|
2009-01-14 12:56:30 -08:00
|
|
|
AC_MSG_ERROR([No size found for $2])
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
AC_DEFINE_UNQUOTED($1, [$moz_cv_size_of_$1])
|
|
|
|
])
|
|
|
|
|
|
|
|
dnl MOZ_ALIGN_OF_TYPE(VARIABLE, TYPE, POSSIBLE-ALIGNS)
|
|
|
|
dnl
|
|
|
|
dnl Check to see which of POSSIBLE-ALIGNS is the necessary alignment of TYPE.
|
|
|
|
dnl If we find one, define VARIABLE ALIGNMENT. If no alignment matches, exit
|
|
|
|
dnl the configure script with an error message.
|
|
|
|
dnl
|
|
|
|
dnl The cache variable moz_cv_align_of_VARIABLE gets set to the size, if
|
|
|
|
dnl found.
|
|
|
|
dnl
|
|
|
|
dnl for example:
|
|
|
|
dnl MOZ_ALIGN_OF_TYPE(JS_ALIGN_OF_POINTER, void*, 2 4 8 16)
|
2011-08-09 11:27:00 -07:00
|
|
|
AC_DEFUN([MOZ_ALIGN_OF_TYPE],
|
2009-01-14 12:56:30 -08:00
|
|
|
[
|
|
|
|
AC_CACHE_CHECK([for the alignment of $2], moz_cv_align_of_$1, [
|
|
|
|
moz_cv_align_of_$1=
|
|
|
|
for align in $3; do
|
|
|
|
AC_TRY_COMPILE([
|
|
|
|
#include <stddef.h>
|
|
|
|
struct aligner { char c; $2 a; };
|
|
|
|
],
|
|
|
|
[
|
|
|
|
int a[offsetof(struct aligner, a) == $align ? 1 : -1];
|
2010-07-18 02:19:48 -07:00
|
|
|
return 0;
|
2009-01-14 12:56:30 -08:00
|
|
|
],
|
|
|
|
[moz_cv_align_of_$1=$align; break], [])
|
|
|
|
done
|
2009-01-28 09:01:40 -08:00
|
|
|
if test ! "$moz_cv_align_of_$1"; then
|
2009-01-14 12:56:30 -08:00
|
|
|
AC_MSG_ERROR([No alignment found for $2])
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
AC_DEFINE_UNQUOTED($1, [$moz_cv_align_of_$1])
|
|
|
|
])
|