зеркало из https://github.com/mozilla/pjs.git
Bug 269538 - use stdint types instead of jscpucfg types, now that we have them auto-configured
* Various code inside and outside of JS uses JS_BYTES_PER_WORD, so I added it to js-config.h * Existing code uses JS_BYTES_PER_DOUBLE, JS_BITS_PER_WORD_LOG2, and JS_ALIGN_OF_POINTER so I've added autoconf tests for those r=crowder r=jimb
This commit is contained in:
Родитель
79983342a3
Коммит
c8c3695739
|
@ -35,15 +35,15 @@ dnl the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
dnl
|
dnl
|
||||||
dnl ***** END LICENSE BLOCK *****
|
dnl ***** END LICENSE BLOCK *****
|
||||||
|
|
||||||
dnl MOZ_N_BYTE_TYPE(TYPENAME, SIZE, POSSIBLE-TYPES)
|
dnl MOZ_N_BYTE_TYPE(VARIABLE, SIZE, POSSIBLE-TYPES)
|
||||||
dnl
|
dnl
|
||||||
dnl Check to see which of POSSIBLE-TYPES has a size of SIZE. If we
|
dnl Check to see which of POSSIBLE-TYPES has a size of SIZE. If we
|
||||||
dnl find one, define TYPENAME to be the size-BYTE type. If no type
|
dnl find one, define VARIABLE to be the size-BYTE type. If no type
|
||||||
dnl matches, exit the configure script with an error message. Types
|
dnl matches, exit the configure script with an error message. Types
|
||||||
dnl whose written form contains spaces should appear in POSSIBLE-TYPES
|
dnl whose written form contains spaces should appear in POSSIBLE-TYPES
|
||||||
dnl enclosed by shell quotes.
|
dnl enclosed by shell quotes.
|
||||||
dnl
|
dnl
|
||||||
dnl The cache variable moz_cv_n_byte_type_TYPENAME gets set to the
|
dnl The cache variable moz_cv_n_byte_type_VARIABLE gets set to the
|
||||||
dnl type, if found.
|
dnl type, if found.
|
||||||
dnl
|
dnl
|
||||||
dnl for example:
|
dnl for example:
|
||||||
|
@ -71,3 +71,66 @@ AC_CACHE_CHECK([for a $2-byte type], moz_cv_n_byte_type_$1, [
|
||||||
AC_DEFINE_UNQUOTED($1, [$moz_cv_n_byte_type_$1],
|
AC_DEFINE_UNQUOTED($1, [$moz_cv_n_byte_type_$1],
|
||||||
[a $2-byte type on the target machine])
|
[a $2-byte type on the target machine])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
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])
|
||||||
|
AC_DEFUN(MOZ_SIZE_OF_TYPE,
|
||||||
|
[
|
||||||
|
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];
|
||||||
|
return;
|
||||||
|
],
|
||||||
|
[moz_cv_size_of_$1=$size; break], [])
|
||||||
|
done
|
||||||
|
if ! test "$moz_cv_size_of_$1"; then
|
||||||
|
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)
|
||||||
|
AC_DEFUN(MOZ_ALIGN_OF_TYPE,
|
||||||
|
[
|
||||||
|
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];
|
||||||
|
return;
|
||||||
|
],
|
||||||
|
[moz_cv_align_of_$1=$align; break], [])
|
||||||
|
done
|
||||||
|
if ! test "$moz_cv_align_of_$1"; then
|
||||||
|
AC_MSG_ERROR([No alignment found for $2])
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
AC_DEFINE_UNQUOTED($1, [$moz_cv_align_of_$1])
|
||||||
|
])
|
||||||
|
|
|
@ -130,7 +130,6 @@ CPPSRCS = \
|
||||||
jsiter.cpp \
|
jsiter.cpp \
|
||||||
jslock.cpp \
|
jslock.cpp \
|
||||||
jslog2.cpp \
|
jslog2.cpp \
|
||||||
jslong.cpp \
|
|
||||||
jsmath.cpp \
|
jsmath.cpp \
|
||||||
jsnum.cpp \
|
jsnum.cpp \
|
||||||
jsobj.cpp \
|
jsobj.cpp \
|
||||||
|
|
|
@ -35,15 +35,15 @@ dnl the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
dnl
|
dnl
|
||||||
dnl ***** END LICENSE BLOCK *****
|
dnl ***** END LICENSE BLOCK *****
|
||||||
|
|
||||||
dnl MOZ_N_BYTE_TYPE(TYPENAME, SIZE, POSSIBLE-TYPES)
|
dnl MOZ_N_BYTE_TYPE(VARIABLE, SIZE, POSSIBLE-TYPES)
|
||||||
dnl
|
dnl
|
||||||
dnl Check to see which of POSSIBLE-TYPES has a size of SIZE. If we
|
dnl Check to see which of POSSIBLE-TYPES has a size of SIZE. If we
|
||||||
dnl find one, define TYPENAME to be the size-BYTE type. If no type
|
dnl find one, define VARIABLE to be the size-BYTE type. If no type
|
||||||
dnl matches, exit the configure script with an error message. Types
|
dnl matches, exit the configure script with an error message. Types
|
||||||
dnl whose written form contains spaces should appear in POSSIBLE-TYPES
|
dnl whose written form contains spaces should appear in POSSIBLE-TYPES
|
||||||
dnl enclosed by shell quotes.
|
dnl enclosed by shell quotes.
|
||||||
dnl
|
dnl
|
||||||
dnl The cache variable moz_cv_n_byte_type_TYPENAME gets set to the
|
dnl The cache variable moz_cv_n_byte_type_VARIABLE gets set to the
|
||||||
dnl type, if found.
|
dnl type, if found.
|
||||||
dnl
|
dnl
|
||||||
dnl for example:
|
dnl for example:
|
||||||
|
@ -71,3 +71,66 @@ AC_CACHE_CHECK([for a $2-byte type], moz_cv_n_byte_type_$1, [
|
||||||
AC_DEFINE_UNQUOTED($1, [$moz_cv_n_byte_type_$1],
|
AC_DEFINE_UNQUOTED($1, [$moz_cv_n_byte_type_$1],
|
||||||
[a $2-byte type on the target machine])
|
[a $2-byte type on the target machine])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
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])
|
||||||
|
AC_DEFUN(MOZ_SIZE_OF_TYPE,
|
||||||
|
[
|
||||||
|
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];
|
||||||
|
return;
|
||||||
|
],
|
||||||
|
[moz_cv_size_of_$1=$size; break], [])
|
||||||
|
done
|
||||||
|
if ! test "$moz_cv_size_of_$1"; then
|
||||||
|
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)
|
||||||
|
AC_DEFUN(MOZ_ALIGN_OF_TYPE,
|
||||||
|
[
|
||||||
|
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];
|
||||||
|
return;
|
||||||
|
],
|
||||||
|
[moz_cv_align_of_$1=$align; break], [])
|
||||||
|
done
|
||||||
|
if ! test "$moz_cv_align_of_$1"; then
|
||||||
|
AC_MSG_ERROR([No alignment found for $2])
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
AC_DEFINE_UNQUOTED($1, [$moz_cv_align_of_$1])
|
||||||
|
])
|
||||||
|
|
|
@ -2553,6 +2553,18 @@ else
|
||||||
[int long 'long long' short])
|
[int long 'long long' short])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
MOZ_SIZE_OF_TYPE(JS_BYTES_PER_WORD, void*, 4 8)
|
||||||
|
if test "$moz_cv_size_of_JS_BYTES_PER_WORD" -eq "4"; then
|
||||||
|
AC_DEFINE(JS_BITS_PER_WORD_LOG2, 5)
|
||||||
|
elif test "$moz_cv_size_of_JS_BYTES_PER_WORD" -eq "8"; then
|
||||||
|
AC_DEFINE(JS_BITS_PER_WORD_LOG2, 6)
|
||||||
|
else
|
||||||
|
AC_MSG_ERROR([Unexpected JS_BYTES_PER_WORD])
|
||||||
|
fi
|
||||||
|
|
||||||
|
MOZ_ALIGN_OF_TYPE(JS_ALIGN_OF_POINTER, void*, 2 4 8 16)
|
||||||
|
MOZ_SIZE_OF_TYPE(JS_BYTES_PER_DOUBLE, double, 6 8 10 12 14)
|
||||||
|
|
||||||
dnl Check for int16_t, int32_t, int64_t, int64, uint, uint_t, and uint16_t.
|
dnl Check for int16_t, int32_t, int64_t, int64, uint, uint_t, and uint16_t.
|
||||||
dnl ========================================================
|
dnl ========================================================
|
||||||
AC_MSG_CHECKING(for int16_t)
|
AC_MSG_CHECKING(for int16_t)
|
||||||
|
|
|
@ -77,5 +77,6 @@
|
||||||
#undef JS_INT32_TYPE
|
#undef JS_INT32_TYPE
|
||||||
#undef JS_INT64_TYPE
|
#undef JS_INT64_TYPE
|
||||||
#undef JS_INTPTR_TYPE
|
#undef JS_INTPTR_TYPE
|
||||||
|
#undef JS_BYTES_PER_WORD
|
||||||
|
|
||||||
#endif /* js_config_h___ */
|
#endif /* js_config_h___ */
|
||||||
|
|
|
@ -46,33 +46,10 @@
|
||||||
|
|
||||||
#ifdef CROSS_COMPILE
|
#ifdef CROSS_COMPILE
|
||||||
#include <prtypes.h>
|
#include <prtypes.h>
|
||||||
#define INT64 PRInt64
|
#endif
|
||||||
#else
|
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
/* Generate cpucfg.h */
|
|
||||||
|
|
||||||
#if defined(XP_WIN) || defined(XP_OS2)
|
|
||||||
#ifdef WIN32
|
|
||||||
#if defined(__GNUC__)
|
|
||||||
#define INT64 long long
|
|
||||||
#else
|
|
||||||
#define INT64 _int64
|
|
||||||
#endif /* __GNUC__ */
|
|
||||||
#else
|
|
||||||
#define INT64 long
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#if defined(HPUX) || defined(__QNX__)
|
|
||||||
#define INT64 long
|
|
||||||
#else
|
|
||||||
#define INT64 long long
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* CROSS_COMPILE */
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#define NS_NEVER_INLINE __attribute__((noinline))
|
#define NS_NEVER_INLINE __attribute__((noinline))
|
||||||
#else
|
#else
|
||||||
|
@ -84,81 +61,6 @@ static int StackGrowthDirection(int *dummy1addr);
|
||||||
#pragma no_inline(StackGrowthDirection)
|
#pragma no_inline(StackGrowthDirection)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef void *prword;
|
|
||||||
|
|
||||||
struct align_short {
|
|
||||||
char c;
|
|
||||||
short a;
|
|
||||||
};
|
|
||||||
struct align_int {
|
|
||||||
char c;
|
|
||||||
int a;
|
|
||||||
};
|
|
||||||
struct align_long {
|
|
||||||
char c;
|
|
||||||
long a;
|
|
||||||
};
|
|
||||||
struct align_int64 {
|
|
||||||
char c;
|
|
||||||
INT64 a;
|
|
||||||
};
|
|
||||||
struct align_fakelonglong {
|
|
||||||
char c;
|
|
||||||
struct {
|
|
||||||
long hi, lo;
|
|
||||||
} a;
|
|
||||||
};
|
|
||||||
struct align_float {
|
|
||||||
char c;
|
|
||||||
float a;
|
|
||||||
};
|
|
||||||
struct align_double {
|
|
||||||
char c;
|
|
||||||
double a;
|
|
||||||
};
|
|
||||||
struct align_pointer {
|
|
||||||
char c;
|
|
||||||
void *a;
|
|
||||||
};
|
|
||||||
struct align_prword {
|
|
||||||
char c;
|
|
||||||
prword a;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define ALIGN_OF(type) \
|
|
||||||
(((char*)&(((struct align_##type *)0)->a)) - ((char*)0))
|
|
||||||
|
|
||||||
unsigned int bpb;
|
|
||||||
|
|
||||||
static int Log2(unsigned int n)
|
|
||||||
{
|
|
||||||
int log2 = 0;
|
|
||||||
|
|
||||||
if (n & (n-1))
|
|
||||||
log2++;
|
|
||||||
if (n >> 16)
|
|
||||||
log2 += 16, n >>= 16;
|
|
||||||
if (n >> 8)
|
|
||||||
log2 += 8, n >>= 8;
|
|
||||||
if (n >> 4)
|
|
||||||
log2 += 4, n >>= 4;
|
|
||||||
if (n >> 2)
|
|
||||||
log2 += 2, n >>= 2;
|
|
||||||
if (n >> 1)
|
|
||||||
log2++;
|
|
||||||
return log2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Conceivably this could actually be used, but there is lots of code out
|
|
||||||
* there with ands and shifts in it that assumes a byte is exactly 8 bits,
|
|
||||||
* so forget about porting THIS code to all those non 8 bit byte machines.
|
|
||||||
*/
|
|
||||||
static void BitsPerByte(void)
|
|
||||||
{
|
|
||||||
bpb = 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int NS_NEVER_INLINE StackGrowthDirection(int *dummy1addr)
|
static int NS_NEVER_INLINE StackGrowthDirection(int *dummy1addr)
|
||||||
{
|
{
|
||||||
int dummy2;
|
int dummy2;
|
||||||
|
@ -168,15 +70,8 @@ static int NS_NEVER_INLINE StackGrowthDirection(int *dummy1addr)
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int sizeof_char, sizeof_short, sizeof_int, sizeof_int64, sizeof_long,
|
|
||||||
sizeof_float, sizeof_double, sizeof_word, sizeof_dword;
|
|
||||||
int bits_per_int64_log2, align_of_short, align_of_int, align_of_long,
|
|
||||||
align_of_int64, align_of_float, align_of_double, align_of_pointer,
|
|
||||||
align_of_word;
|
|
||||||
int dummy1;
|
int dummy1;
|
||||||
|
|
||||||
BitsPerByte();
|
|
||||||
|
|
||||||
printf("#ifndef js_cpucfg___\n");
|
printf("#ifndef js_cpucfg___\n");
|
||||||
printf("#define js_cpucfg___\n\n");
|
printf("#define js_cpucfg___\n\n");
|
||||||
|
|
||||||
|
@ -206,28 +101,7 @@ int main(int argc, char **argv)
|
||||||
#error "Endianess not defined."
|
#error "Endianess not defined."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sizeof_char = PR_BYTES_PER_BYTE;
|
#else
|
||||||
sizeof_short = PR_BYTES_PER_SHORT;
|
|
||||||
sizeof_int = PR_BYTES_PER_INT;
|
|
||||||
sizeof_int64 = PR_BYTES_PER_INT64;
|
|
||||||
sizeof_long = PR_BYTES_PER_LONG;
|
|
||||||
sizeof_float = PR_BYTES_PER_FLOAT;
|
|
||||||
sizeof_double = PR_BYTES_PER_DOUBLE;
|
|
||||||
sizeof_word = PR_BYTES_PER_WORD;
|
|
||||||
sizeof_dword = PR_BYTES_PER_DWORD;
|
|
||||||
|
|
||||||
bits_per_int64_log2 = PR_BITS_PER_INT64_LOG2;
|
|
||||||
|
|
||||||
align_of_short = PR_ALIGN_OF_SHORT;
|
|
||||||
align_of_int = PR_ALIGN_OF_INT;
|
|
||||||
align_of_long = PR_ALIGN_OF_LONG;
|
|
||||||
align_of_int64 = PR_ALIGN_OF_INT64;
|
|
||||||
align_of_float = PR_ALIGN_OF_FLOAT;
|
|
||||||
align_of_double = PR_ALIGN_OF_DOUBLE;
|
|
||||||
align_of_pointer = PR_ALIGN_OF_POINTER;
|
|
||||||
align_of_word = PR_ALIGN_OF_WORD;
|
|
||||||
|
|
||||||
#else /* !CROSS_COMPILE */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We don't handle PDP-endian or similar orders: if a short is big-endian,
|
* We don't handle PDP-endian or similar orders: if a short is big-endian,
|
||||||
|
@ -309,91 +183,10 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sizeof_char = sizeof(char);
|
printf("#define JS_STACK_GROWTH_DIRECTION (%d)\n", StackGrowthDirection(&dummy1));
|
||||||
sizeof_short = sizeof(short);
|
|
||||||
sizeof_int = sizeof(int);
|
|
||||||
sizeof_int64 = 8;
|
|
||||||
sizeof_long = sizeof(long);
|
|
||||||
sizeof_float = sizeof(float);
|
|
||||||
sizeof_double = sizeof(double);
|
|
||||||
sizeof_word = sizeof(prword);
|
|
||||||
sizeof_dword = 8;
|
|
||||||
|
|
||||||
bits_per_int64_log2 = 6;
|
|
||||||
|
|
||||||
align_of_short = ALIGN_OF(short);
|
|
||||||
align_of_int = ALIGN_OF(int);
|
|
||||||
align_of_long = ALIGN_OF(long);
|
|
||||||
if (sizeof(INT64) < 8) {
|
|
||||||
/* this machine doesn't actually support int64's */
|
|
||||||
align_of_int64 = ALIGN_OF(fakelonglong);
|
|
||||||
} else {
|
|
||||||
align_of_int64 = ALIGN_OF(int64);
|
|
||||||
}
|
|
||||||
align_of_float = ALIGN_OF(float);
|
|
||||||
align_of_double = ALIGN_OF(double);
|
|
||||||
align_of_pointer = ALIGN_OF(pointer);
|
|
||||||
align_of_word = ALIGN_OF(prword);
|
|
||||||
|
|
||||||
#endif /* CROSS_COMPILE */
|
#endif /* CROSS_COMPILE */
|
||||||
|
|
||||||
printf("#define JS_BYTES_PER_BYTE %dL\n", sizeof_char);
|
|
||||||
printf("#define JS_BYTES_PER_SHORT %dL\n", sizeof_short);
|
|
||||||
printf("#define JS_BYTES_PER_INT %dL\n", sizeof_int);
|
|
||||||
printf("#define JS_BYTES_PER_INT64 %dL\n", sizeof_int64);
|
|
||||||
printf("#define JS_BYTES_PER_LONG %dL\n", sizeof_long);
|
|
||||||
printf("#define JS_BYTES_PER_FLOAT %dL\n", sizeof_float);
|
|
||||||
printf("#define JS_BYTES_PER_DOUBLE %dL\n", sizeof_double);
|
|
||||||
printf("#define JS_BYTES_PER_WORD %dL\n", sizeof_word);
|
|
||||||
printf("#define JS_BYTES_PER_DWORD %dL\n", sizeof_dword);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf("#define JS_BITS_PER_BYTE %dL\n", bpb);
|
|
||||||
printf("#define JS_BITS_PER_SHORT %dL\n", bpb * sizeof_short);
|
|
||||||
printf("#define JS_BITS_PER_INT %dL\n", bpb * sizeof_int);
|
|
||||||
printf("#define JS_BITS_PER_INT64 %dL\n", bpb * sizeof_int64);
|
|
||||||
printf("#define JS_BITS_PER_LONG %dL\n", bpb * sizeof_long);
|
|
||||||
printf("#define JS_BITS_PER_FLOAT %dL\n", bpb * sizeof_float);
|
|
||||||
printf("#define JS_BITS_PER_DOUBLE %dL\n", bpb * sizeof_double);
|
|
||||||
printf("#define JS_BITS_PER_WORD %dL\n", bpb * sizeof_word);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf("#define JS_BITS_PER_BYTE_LOG2 %dL\n", Log2(bpb));
|
|
||||||
printf("#define JS_BITS_PER_SHORT_LOG2 %dL\n", Log2(bpb * sizeof_short));
|
|
||||||
printf("#define JS_BITS_PER_INT_LOG2 %dL\n", Log2(bpb * sizeof_int));
|
|
||||||
printf("#define JS_BITS_PER_INT64_LOG2 %dL\n", bits_per_int64_log2);
|
|
||||||
printf("#define JS_BITS_PER_LONG_LOG2 %dL\n", Log2(bpb * sizeof_long));
|
|
||||||
printf("#define JS_BITS_PER_FLOAT_LOG2 %dL\n", Log2(bpb * sizeof_float));
|
|
||||||
printf("#define JS_BITS_PER_DOUBLE_LOG2 %dL\n", Log2(bpb * sizeof_double));
|
|
||||||
printf("#define JS_BITS_PER_WORD_LOG2 %dL\n", Log2(bpb * sizeof_word));
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf("#define JS_ALIGN_OF_SHORT %dL\n", align_of_short);
|
|
||||||
printf("#define JS_ALIGN_OF_INT %dL\n", align_of_int);
|
|
||||||
printf("#define JS_ALIGN_OF_LONG %dL\n", align_of_long);
|
|
||||||
printf("#define JS_ALIGN_OF_INT64 %dL\n", align_of_int64);
|
|
||||||
printf("#define JS_ALIGN_OF_FLOAT %dL\n", align_of_float);
|
|
||||||
printf("#define JS_ALIGN_OF_DOUBLE %dL\n", align_of_double);
|
|
||||||
printf("#define JS_ALIGN_OF_POINTER %dL\n", align_of_pointer);
|
|
||||||
printf("#define JS_ALIGN_OF_WORD %dL\n", align_of_word);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf("#define JS_BYTES_PER_WORD_LOG2 %dL\n", Log2(sizeof_word));
|
|
||||||
printf("#define JS_BYTES_PER_DWORD_LOG2 %dL\n", Log2(sizeof_dword));
|
|
||||||
printf("#define JS_WORDS_PER_DWORD_LOG2 %dL\n", Log2(sizeof_dword/sizeof_word));
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf("#define JS_STACK_GROWTH_DIRECTION (%d)\n", StackGrowthDirection(&dummy1));
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf("#define JS_HAVE_LONG_LONG\n");
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
#if defined __GNUC__ && defined __x86_64__
|
|
||||||
printf("#define HAVE_VA_LIST_AS_ARRAY 1\n");
|
|
||||||
printf("\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
printf("#endif /* js_cpucfg___ */\n");
|
printf("#endif /* js_cpucfg___ */\n");
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
|
@ -49,47 +49,10 @@
|
||||||
#if defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)
|
#if defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)
|
||||||
#define IS_LITTLE_ENDIAN 1
|
#define IS_LITTLE_ENDIAN 1
|
||||||
#undef IS_BIG_ENDIAN
|
#undef IS_BIG_ENDIAN
|
||||||
|
|
||||||
#define JS_BYTES_PER_BYTE 1L
|
|
||||||
#define JS_BYTES_PER_SHORT 2L
|
|
||||||
#define JS_BYTES_PER_INT 4L
|
|
||||||
#define JS_BYTES_PER_INT64 8L
|
|
||||||
#define JS_BYTES_PER_LONG 4L
|
|
||||||
#define JS_BYTES_PER_FLOAT 4L
|
|
||||||
#define JS_BYTES_PER_DOUBLE 8L
|
#define JS_BYTES_PER_DOUBLE 8L
|
||||||
#define JS_BYTES_PER_WORD 8L
|
#define JS_BYTES_PER_WORD 8L
|
||||||
#define JS_BYTES_PER_DWORD 8L
|
#define JS_BITS_PER_WORD_LOG2 6
|
||||||
|
|
||||||
#define JS_BITS_PER_BYTE 8L
|
|
||||||
#define JS_BITS_PER_SHORT 16L
|
|
||||||
#define JS_BITS_PER_INT 32L
|
|
||||||
#define JS_BITS_PER_INT64 64L
|
|
||||||
#define JS_BITS_PER_LONG 32L
|
|
||||||
#define JS_BITS_PER_FLOAT 32L
|
|
||||||
#define JS_BITS_PER_DOUBLE 64L
|
|
||||||
#define JS_BITS_PER_WORD 64L
|
|
||||||
|
|
||||||
#define JS_BITS_PER_BYTE_LOG2 3L
|
|
||||||
#define JS_BITS_PER_SHORT_LOG2 4L
|
|
||||||
#define JS_BITS_PER_INT_LOG2 5L
|
|
||||||
#define JS_BITS_PER_INT64_LOG2 6L
|
|
||||||
#define JS_BITS_PER_LONG_LOG2 5L
|
|
||||||
#define JS_BITS_PER_FLOAT_LOG2 5L
|
|
||||||
#define JS_BITS_PER_DOUBLE_LOG2 6L
|
|
||||||
#define JS_BITS_PER_WORD_LOG2 6L
|
|
||||||
|
|
||||||
#define JS_ALIGN_OF_SHORT 2L
|
|
||||||
#define JS_ALIGN_OF_INT 4L
|
|
||||||
#define JS_ALIGN_OF_LONG 4L
|
|
||||||
#define JS_ALIGN_OF_INT64 8L
|
|
||||||
#define JS_ALIGN_OF_FLOAT 4L
|
|
||||||
#define JS_ALIGN_OF_DOUBLE 8L
|
|
||||||
#define JS_ALIGN_OF_POINTER 8L
|
#define JS_ALIGN_OF_POINTER 8L
|
||||||
#define JS_ALIGN_OF_WORD 8L
|
|
||||||
|
|
||||||
#define JS_BYTES_PER_WORD_LOG2 3L
|
|
||||||
#define JS_BYTES_PER_DWORD_LOG2 3L
|
|
||||||
#define PR_WORDS_PER_DWORD_LOG2 0L
|
|
||||||
#else /* !(defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)) */
|
#else /* !(defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)) */
|
||||||
#error "CPU type is unknown"
|
#error "CPU type is unknown"
|
||||||
#endif /* !(defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)) */
|
#endif /* !(defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)) */
|
||||||
|
@ -102,97 +65,13 @@
|
||||||
|
|
||||||
#define IS_LITTLE_ENDIAN 1
|
#define IS_LITTLE_ENDIAN 1
|
||||||
#undef IS_BIG_ENDIAN
|
#undef IS_BIG_ENDIAN
|
||||||
|
|
||||||
#define JS_BYTES_PER_BYTE 1L
|
|
||||||
#define JS_BYTES_PER_SHORT 2L
|
|
||||||
#define JS_BYTES_PER_INT 4L
|
|
||||||
#define JS_BYTES_PER_INT64 8L
|
|
||||||
#define JS_BYTES_PER_LONG 4L
|
|
||||||
#define JS_BYTES_PER_FLOAT 4L
|
|
||||||
#define JS_BYTES_PER_DOUBLE 8L
|
#define JS_BYTES_PER_DOUBLE 8L
|
||||||
#define JS_BYTES_PER_WORD 4L
|
#define JS_BYTES_PER_WORD 4L
|
||||||
#define JS_BYTES_PER_DWORD 8L
|
#define JS_BITS_PER_WORD_LOG2 5
|
||||||
|
|
||||||
#define JS_BITS_PER_BYTE 8L
|
|
||||||
#define JS_BITS_PER_SHORT 16L
|
|
||||||
#define JS_BITS_PER_INT 32L
|
|
||||||
#define JS_BITS_PER_INT64 64L
|
|
||||||
#define JS_BITS_PER_LONG 32L
|
|
||||||
#define JS_BITS_PER_FLOAT 32L
|
|
||||||
#define JS_BITS_PER_DOUBLE 64L
|
|
||||||
#define JS_BITS_PER_WORD 32L
|
|
||||||
|
|
||||||
#define JS_BITS_PER_BYTE_LOG2 3L
|
|
||||||
#define JS_BITS_PER_SHORT_LOG2 4L
|
|
||||||
#define JS_BITS_PER_INT_LOG2 5L
|
|
||||||
#define JS_BITS_PER_INT64_LOG2 6L
|
|
||||||
#define JS_BITS_PER_LONG_LOG2 5L
|
|
||||||
#define JS_BITS_PER_FLOAT_LOG2 5L
|
|
||||||
#define JS_BITS_PER_DOUBLE_LOG2 6L
|
|
||||||
#define JS_BITS_PER_WORD_LOG2 5L
|
|
||||||
|
|
||||||
#define JS_ALIGN_OF_SHORT 2L
|
|
||||||
#define JS_ALIGN_OF_INT 4L
|
|
||||||
#define JS_ALIGN_OF_LONG 4L
|
|
||||||
#define JS_ALIGN_OF_INT64 8L
|
|
||||||
#define JS_ALIGN_OF_FLOAT 4L
|
|
||||||
#define JS_ALIGN_OF_DOUBLE 4L
|
|
||||||
#define JS_ALIGN_OF_POINTER 4L
|
#define JS_ALIGN_OF_POINTER 4L
|
||||||
#define JS_ALIGN_OF_WORD 4L
|
|
||||||
|
|
||||||
#define JS_BYTES_PER_WORD_LOG2 2L
|
|
||||||
#define JS_BYTES_PER_DWORD_LOG2 3L
|
|
||||||
#define PR_WORDS_PER_DWORD_LOG2 1L
|
|
||||||
#endif /* _WIN32 || XP_OS2 || WINCE*/
|
#endif /* _WIN32 || XP_OS2 || WINCE*/
|
||||||
|
|
||||||
#if defined(_WINDOWS) && !defined(_WIN32) /* WIN16 */
|
|
||||||
|
|
||||||
#define IS_LITTLE_ENDIAN 1
|
|
||||||
#undef IS_BIG_ENDIAN
|
|
||||||
|
|
||||||
#define JS_BYTES_PER_BYTE 1L
|
|
||||||
#define JS_BYTES_PER_SHORT 2L
|
|
||||||
#define JS_BYTES_PER_INT 2L
|
|
||||||
#define JS_BYTES_PER_INT64 8L
|
|
||||||
#define JS_BYTES_PER_LONG 4L
|
|
||||||
#define JS_BYTES_PER_FLOAT 4L
|
|
||||||
#define JS_BYTES_PER_DOUBLE 8L
|
|
||||||
#define JS_BYTES_PER_WORD 4L
|
|
||||||
#define JS_BYTES_PER_DWORD 8L
|
|
||||||
|
|
||||||
#define JS_BITS_PER_BYTE 8L
|
|
||||||
#define JS_BITS_PER_SHORT 16L
|
|
||||||
#define JS_BITS_PER_INT 16L
|
|
||||||
#define JS_BITS_PER_INT64 64L
|
|
||||||
#define JS_BITS_PER_LONG 32L
|
|
||||||
#define JS_BITS_PER_FLOAT 32L
|
|
||||||
#define JS_BITS_PER_DOUBLE 64L
|
|
||||||
#define JS_BITS_PER_WORD 32L
|
|
||||||
|
|
||||||
#define JS_BITS_PER_BYTE_LOG2 3L
|
|
||||||
#define JS_BITS_PER_SHORT_LOG2 4L
|
|
||||||
#define JS_BITS_PER_INT_LOG2 4L
|
|
||||||
#define JS_BITS_PER_INT64_LOG2 6L
|
|
||||||
#define JS_BITS_PER_LONG_LOG2 5L
|
|
||||||
#define JS_BITS_PER_FLOAT_LOG2 5L
|
|
||||||
#define JS_BITS_PER_DOUBLE_LOG2 6L
|
|
||||||
#define JS_BITS_PER_WORD_LOG2 5L
|
|
||||||
|
|
||||||
#define JS_ALIGN_OF_SHORT 2L
|
|
||||||
#define JS_ALIGN_OF_INT 2L
|
|
||||||
#define JS_ALIGN_OF_LONG 2L
|
|
||||||
#define JS_ALIGN_OF_INT64 2L
|
|
||||||
#define JS_ALIGN_OF_FLOAT 2L
|
|
||||||
#define JS_ALIGN_OF_DOUBLE 2L
|
|
||||||
#define JS_ALIGN_OF_POINTER 2L
|
|
||||||
#define JS_ALIGN_OF_WORD 2L
|
|
||||||
|
|
||||||
#define JS_BYTES_PER_WORD_LOG2 2L
|
|
||||||
#define JS_BYTES_PER_DWORD_LOG2 3L
|
|
||||||
#define PR_WORDS_PER_DWORD_LOG2 1L
|
|
||||||
|
|
||||||
#endif /* defined(_WINDOWS) && !defined(_WIN32) */
|
|
||||||
|
|
||||||
#elif defined(XP_UNIX) || defined(XP_BEOS)
|
#elif defined(XP_UNIX) || defined(XP_BEOS)
|
||||||
|
|
||||||
#error "This file is supposed to be auto-generated on UNIX platforms, but the"
|
#error "This file is supposed to be auto-generated on UNIX platforms, but the"
|
||||||
|
|
|
@ -69,10 +69,12 @@ _InterlockedCompareExchange(long *volatile dest, long exchange, long comp);
|
||||||
JS_END_EXTERN_C
|
JS_END_EXTERN_C
|
||||||
#pragma intrinsic(_InterlockedCompareExchange)
|
#pragma intrinsic(_InterlockedCompareExchange)
|
||||||
|
|
||||||
|
JS_STATIC_ASSERT(sizeof(jsword) == sizeof(long));
|
||||||
|
|
||||||
static JS_ALWAYS_INLINE int
|
static JS_ALWAYS_INLINE int
|
||||||
NativeCompareAndSwapHelper(jsword *w, jsword ov, jsword nv)
|
NativeCompareAndSwapHelper(jsword *w, jsword ov, jsword nv)
|
||||||
{
|
{
|
||||||
_InterlockedCompareExchange(w, nv, ov);
|
_InterlockedCompareExchange((long*) w, nv, ov);
|
||||||
__asm {
|
__asm {
|
||||||
sete al
|
sete al
|
||||||
}
|
}
|
||||||
|
@ -92,11 +94,7 @@ static JS_ALWAYS_INLINE int
|
||||||
NativeCompareAndSwap(jsword *w, jsword ov, jsword nv)
|
NativeCompareAndSwap(jsword *w, jsword ov, jsword nv)
|
||||||
{
|
{
|
||||||
/* Details on these functions available in the manpage for atomic */
|
/* Details on these functions available in the manpage for atomic */
|
||||||
#if JS_BYTES_PER_WORD == 8 && JS_BYTES_PER_LONG != 8
|
return OSAtomicCompareAndSwapPtrBarrier(ov, nv, w);
|
||||||
return OSAtomicCompareAndSwap64Barrier(ov, nv, (int64_t*) w);
|
|
||||||
#else
|
|
||||||
return OSAtomicCompareAndSwap32Barrier(ov, nv, (int32_t*) w);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(__GNUC__) && defined(__i386__)
|
#elif defined(__GNUC__) && defined(__i386__)
|
||||||
|
|
|
@ -1,264 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the Mozilla Public License Version
|
|
||||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
* http://www.mozilla.org/MPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
||||||
* for the specific language governing rights and limitations under the
|
|
||||||
* License.
|
|
||||||
*
|
|
||||||
* The Original Code is Mozilla Communicator client code, released
|
|
||||||
* March 31, 1998.
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is
|
|
||||||
* Netscape Communications Corporation.
|
|
||||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
*
|
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
|
||||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
||||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
||||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
||||||
* of those above. If you wish to allow use of your version of this file only
|
|
||||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
||||||
* use your version of this file under the terms of the MPL, indicate your
|
|
||||||
* decision by deleting the provisions above and replace them with the notice
|
|
||||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
||||||
* the provisions above, a recipient may use your version of this file under
|
|
||||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
#include "jsstddef.h"
|
|
||||||
#include "jstypes.h"
|
|
||||||
#include "jslong.h"
|
|
||||||
|
|
||||||
#ifndef JS_HAVE_LONG_LONG
|
|
||||||
/*
|
|
||||||
** Divide 64-bit a by 32-bit b, which must be normalized so its high bit is 1.
|
|
||||||
*/
|
|
||||||
static void norm_udivmod32(JSUint32 *qp, JSUint32 *rp, JSUint64 a, JSUint32 b)
|
|
||||||
{
|
|
||||||
JSUint32 d1, d0, q1, q0;
|
|
||||||
JSUint32 r1, r0, m;
|
|
||||||
|
|
||||||
d1 = jshi16(b);
|
|
||||||
d0 = jslo16(b);
|
|
||||||
r1 = a.hi % d1;
|
|
||||||
q1 = a.hi / d1;
|
|
||||||
m = q1 * d0;
|
|
||||||
r1 = (r1 << 16) | jshi16(a.lo);
|
|
||||||
if (r1 < m) {
|
|
||||||
q1--, r1 += b;
|
|
||||||
if (r1 >= b /* i.e., we didn't get a carry when adding to r1 */
|
|
||||||
&& r1 < m) {
|
|
||||||
q1--, r1 += b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
r1 -= m;
|
|
||||||
r0 = r1 % d1;
|
|
||||||
q0 = r1 / d1;
|
|
||||||
m = q0 * d0;
|
|
||||||
r0 = (r0 << 16) | jslo16(a.lo);
|
|
||||||
if (r0 < m) {
|
|
||||||
q0--, r0 += b;
|
|
||||||
if (r0 >= b
|
|
||||||
&& r0 < m) {
|
|
||||||
q0--, r0 += b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*qp = (q1 << 16) | q0;
|
|
||||||
*rp = r0 - m;
|
|
||||||
}
|
|
||||||
|
|
||||||
static JSUint32 CountLeadingZeros(JSUint32 a)
|
|
||||||
{
|
|
||||||
JSUint32 t;
|
|
||||||
JSUint32 r = 32;
|
|
||||||
|
|
||||||
if ((t = a >> 16) != 0)
|
|
||||||
r -= 16, a = t;
|
|
||||||
if ((t = a >> 8) != 0)
|
|
||||||
r -= 8, a = t;
|
|
||||||
if ((t = a >> 4) != 0)
|
|
||||||
r -= 4, a = t;
|
|
||||||
if ((t = a >> 2) != 0)
|
|
||||||
r -= 2, a = t;
|
|
||||||
if ((t = a >> 1) != 0)
|
|
||||||
r -= 1, a = t;
|
|
||||||
if (a & 1)
|
|
||||||
r--;
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
JS_PUBLIC_API(void) jsll_udivmod(JSUint64 *qp, JSUint64 *rp, JSUint64 a, JSUint64 b)
|
|
||||||
{
|
|
||||||
JSUint32 n0, n1, n2;
|
|
||||||
JSUint32 q0, q1;
|
|
||||||
JSUint32 rsh, lsh;
|
|
||||||
|
|
||||||
n0 = a.lo;
|
|
||||||
n1 = a.hi;
|
|
||||||
|
|
||||||
if (b.hi == 0) {
|
|
||||||
if (b.lo > n1) {
|
|
||||||
/* (0 q0) = (n1 n0) / (0 D0) */
|
|
||||||
|
|
||||||
lsh = CountLeadingZeros(b.lo);
|
|
||||||
|
|
||||||
if (lsh) {
|
|
||||||
/*
|
|
||||||
* Normalize, i.e. make the most significant bit of the
|
|
||||||
* denominator be set.
|
|
||||||
*/
|
|
||||||
b.lo = b.lo << lsh;
|
|
||||||
n1 = (n1 << lsh) | (n0 >> (32 - lsh));
|
|
||||||
n0 = n0 << lsh;
|
|
||||||
}
|
|
||||||
|
|
||||||
a.lo = n0, a.hi = n1;
|
|
||||||
norm_udivmod32(&q0, &n0, a, b.lo);
|
|
||||||
q1 = 0;
|
|
||||||
|
|
||||||
/* remainder is in n0 >> lsh */
|
|
||||||
} else {
|
|
||||||
/* (q1 q0) = (n1 n0) / (0 d0) */
|
|
||||||
|
|
||||||
if (b.lo == 0) /* user wants to divide by zero! */
|
|
||||||
b.lo = 1 / b.lo; /* so go ahead and crash */
|
|
||||||
|
|
||||||
lsh = CountLeadingZeros(b.lo);
|
|
||||||
|
|
||||||
if (lsh == 0) {
|
|
||||||
/*
|
|
||||||
* From (n1 >= b.lo)
|
|
||||||
* && (the most significant bit of b.lo is set),
|
|
||||||
* conclude that
|
|
||||||
* (the most significant bit of n1 is set)
|
|
||||||
* && (the leading quotient digit q1 = 1).
|
|
||||||
*
|
|
||||||
* This special case is necessary, not an optimization
|
|
||||||
* (Shifts counts of 32 are undefined).
|
|
||||||
*/
|
|
||||||
n1 -= b.lo;
|
|
||||||
q1 = 1;
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* Normalize.
|
|
||||||
*/
|
|
||||||
rsh = 32 - lsh;
|
|
||||||
|
|
||||||
b.lo = b.lo << lsh;
|
|
||||||
n2 = n1 >> rsh;
|
|
||||||
n1 = (n1 << lsh) | (n0 >> rsh);
|
|
||||||
n0 = n0 << lsh;
|
|
||||||
|
|
||||||
a.lo = n1, a.hi = n2;
|
|
||||||
norm_udivmod32(&q1, &n1, a, b.lo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* n1 != b.lo... */
|
|
||||||
|
|
||||||
a.lo = n0, a.hi = n1;
|
|
||||||
norm_udivmod32(&q0, &n0, a, b.lo);
|
|
||||||
|
|
||||||
/* remainder in n0 >> lsh */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rp) {
|
|
||||||
rp->lo = n0 >> lsh;
|
|
||||||
rp->hi = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (b.hi > n1) {
|
|
||||||
/* (0 0) = (n1 n0) / (D1 d0) */
|
|
||||||
|
|
||||||
q0 = 0;
|
|
||||||
q1 = 0;
|
|
||||||
|
|
||||||
/* remainder in (n1 n0) */
|
|
||||||
if (rp) {
|
|
||||||
rp->lo = n0;
|
|
||||||
rp->hi = n1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* (0 q0) = (n1 n0) / (d1 d0) */
|
|
||||||
|
|
||||||
lsh = CountLeadingZeros(b.hi);
|
|
||||||
if (lsh == 0) {
|
|
||||||
/*
|
|
||||||
* From (n1 >= b.hi)
|
|
||||||
* && (the most significant bit of b.hi is set),
|
|
||||||
* conclude that
|
|
||||||
* (the most significant bit of n1 is set)
|
|
||||||
* && (the quotient digit q0 = 0 or 1).
|
|
||||||
*
|
|
||||||
* This special case is necessary, not an optimization.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The condition on the next line takes advantage of that
|
|
||||||
* n1 >= b.hi (true due to control flow).
|
|
||||||
*/
|
|
||||||
if (n1 > b.hi || n0 >= b.lo) {
|
|
||||||
q0 = 1;
|
|
||||||
a.lo = n0, a.hi = n1;
|
|
||||||
JSLL_SUB(a, a, b);
|
|
||||||
} else {
|
|
||||||
q0 = 0;
|
|
||||||
}
|
|
||||||
q1 = 0;
|
|
||||||
|
|
||||||
if (rp) {
|
|
||||||
rp->lo = n0;
|
|
||||||
rp->hi = n1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
JSInt64 m;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Normalize.
|
|
||||||
*/
|
|
||||||
rsh = 32 - lsh;
|
|
||||||
|
|
||||||
b.hi = (b.hi << lsh) | (b.lo >> rsh);
|
|
||||||
b.lo = b.lo << lsh;
|
|
||||||
n2 = n1 >> rsh;
|
|
||||||
n1 = (n1 << lsh) | (n0 >> rsh);
|
|
||||||
n0 = n0 << lsh;
|
|
||||||
|
|
||||||
a.lo = n1, a.hi = n2;
|
|
||||||
norm_udivmod32(&q0, &n1, a, b.hi);
|
|
||||||
JSLL_MUL32(m, q0, b.lo);
|
|
||||||
|
|
||||||
if ((m.hi > n1) || ((m.hi == n1) && (m.lo > n0))) {
|
|
||||||
q0--;
|
|
||||||
JSLL_SUB(m, m, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
q1 = 0;
|
|
||||||
|
|
||||||
/* Remainder is ((n1 n0) - (m1 m0)) >> lsh */
|
|
||||||
if (rp) {
|
|
||||||
a.lo = n0, a.hi = n1;
|
|
||||||
JSLL_SUB(a, a, m);
|
|
||||||
rp->lo = (a.hi << rsh) | (a.lo >> lsh);
|
|
||||||
rp->hi = a.hi >> lsh;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qp) {
|
|
||||||
qp->lo = q0;
|
|
||||||
qp->hi = q1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* !JS_HAVE_LONG_LONG */
|
|
245
js/src/jslong.h
245
js/src/jslong.h
|
@ -51,15 +51,7 @@
|
||||||
|
|
||||||
JS_BEGIN_EXTERN_C
|
JS_BEGIN_EXTERN_C
|
||||||
|
|
||||||
#ifdef JS_HAVE_LONG_LONG
|
|
||||||
|
|
||||||
#if JS_BYTES_PER_LONG == 8
|
|
||||||
#define JSLL_INIT(hi, lo) ((hi ## L << 32) + lo ## L)
|
#define JSLL_INIT(hi, lo) ((hi ## L << 32) + lo ## L)
|
||||||
#elif (defined(WIN32) || defined(WIN16)) && !defined(__GNUC__)
|
|
||||||
#define JSLL_INIT(hi, lo) ((hi ## i64 << 32) + lo ## i64)
|
|
||||||
#else
|
|
||||||
#define JSLL_INIT(hi, lo) ((hi ## LL << 32) + lo ## LL)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
** MACROS: JSLL_*
|
** MACROS: JSLL_*
|
||||||
|
@ -170,243 +162,6 @@ JS_BEGIN_EXTERN_C
|
||||||
(*(qp) = ((JSUint64)(a) / (b)), \
|
(*(qp) = ((JSUint64)(a) / (b)), \
|
||||||
*(rp) = ((JSUint64)(a) % (b)))
|
*(rp) = ((JSUint64)(a) % (b)))
|
||||||
|
|
||||||
#else /* !JS_HAVE_LONG_LONG */
|
|
||||||
|
|
||||||
#ifdef IS_LITTLE_ENDIAN
|
|
||||||
#define JSLL_INIT(hi, lo) {JS_INT32(lo), JS_INT32(hi)}
|
|
||||||
#else
|
|
||||||
#define JSLL_INIT(hi, lo) {JS_INT32(hi), JS_INT32(lo)}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define JSLL_IS_ZERO(a) (((a).hi == 0) && ((a).lo == 0))
|
|
||||||
#define JSLL_EQ(a, b) (((a).hi == (b).hi) && ((a).lo == (b).lo))
|
|
||||||
#define JSLL_NE(a, b) (((a).hi != (b).hi) || ((a).lo != (b).lo))
|
|
||||||
#define JSLL_GE_ZERO(a) (((a).hi >> 31) == 0)
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
#define JSLL_CMP(a, op, b) (JS_ASSERT((#op)[1] != '='), JSLL_REAL_CMP(a, op, b))
|
|
||||||
#define JSLL_UCMP(a, op, b) (JS_ASSERT((#op)[1] != '='), JSLL_REAL_UCMP(a, op, b))
|
|
||||||
#else
|
|
||||||
#define JSLL_CMP(a, op, b) JSLL_REAL_CMP(a, op, b)
|
|
||||||
#define JSLL_UCMP(a, op, b) JSLL_REAL_UCMP(a, op, b)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define JSLL_REAL_CMP(a,op,b) (((JSInt32)(a).hi op (JSInt32)(b).hi) || \
|
|
||||||
(((a).hi == (b).hi) && ((a).lo op (b).lo)))
|
|
||||||
#define JSLL_REAL_UCMP(a,op,b) (((a).hi op (b).hi) || \
|
|
||||||
(((a).hi == (b).hi) && ((a).lo op (b).lo)))
|
|
||||||
|
|
||||||
#define JSLL_AND(r, a, b) ((r).lo = (a).lo & (b).lo, \
|
|
||||||
(r).hi = (a).hi & (b).hi)
|
|
||||||
#define JSLL_OR(r, a, b) ((r).lo = (a).lo | (b).lo, \
|
|
||||||
(r).hi = (a).hi | (b).hi)
|
|
||||||
#define JSLL_XOR(r, a, b) ((r).lo = (a).lo ^ (b).lo, \
|
|
||||||
(r).hi = (a).hi ^ (b).hi)
|
|
||||||
#define JSLL_OR2(r, a) ((r).lo = (r).lo | (a).lo, \
|
|
||||||
(r).hi = (r).hi | (a).hi)
|
|
||||||
#define JSLL_NOT(r, a) ((r).lo = ~(a).lo, \
|
|
||||||
(r).hi = ~(a).hi)
|
|
||||||
|
|
||||||
#define JSLL_NEG(r, a) ((r).lo = -(JSInt32)(a).lo, \
|
|
||||||
(r).hi = -(JSInt32)(a).hi - ((r).lo != 0))
|
|
||||||
#define JSLL_ADD(r, a, b) { \
|
|
||||||
JSInt64 _a, _b; \
|
|
||||||
_a = a; _b = b; \
|
|
||||||
(r).lo = _a.lo + _b.lo; \
|
|
||||||
(r).hi = _a.hi + _b.hi + ((r).lo < _b.lo); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define JSLL_SUB(r, a, b) { \
|
|
||||||
JSInt64 _a, _b; \
|
|
||||||
_a = a; _b = b; \
|
|
||||||
(r).lo = _a.lo - _b.lo; \
|
|
||||||
(r).hi = _a.hi - _b.hi - (_a.lo < _b.lo); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define JSLL_MUL(r, a, b) { \
|
|
||||||
JSInt64 _a, _b; \
|
|
||||||
_a = a; _b = b; \
|
|
||||||
JSLL_MUL32(r, _a.lo, _b.lo); \
|
|
||||||
(r).hi += _a.hi * _b.lo + _a.lo * _b.hi; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define jslo16(a) ((a) & JS_BITMASK(16))
|
|
||||||
#define jshi16(a) ((a) >> 16)
|
|
||||||
|
|
||||||
#define JSLL_MUL32(r, a, b) { \
|
|
||||||
JSUint32 _a1, _a0, _b1, _b0, _y0, _y1, _y2, _y3; \
|
|
||||||
_a1 = jshi16(a), _a0 = jslo16(a); \
|
|
||||||
_b1 = jshi16(b), _b0 = jslo16(b); \
|
|
||||||
_y0 = _a0 * _b0; \
|
|
||||||
_y1 = _a0 * _b1; \
|
|
||||||
_y2 = _a1 * _b0; \
|
|
||||||
_y3 = _a1 * _b1; \
|
|
||||||
_y1 += jshi16(_y0); /* can't carry */ \
|
|
||||||
_y1 += _y2; /* might carry */ \
|
|
||||||
if (_y1 < _y2) \
|
|
||||||
_y3 += (JSUint32)(JS_BIT(16)); /* propagate */ \
|
|
||||||
(r).lo = (jslo16(_y1) << 16) + jslo16(_y0); \
|
|
||||||
(r).hi = _y3 + jshi16(_y1); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define JSLL_UDIVMOD(qp, rp, a, b) jsll_udivmod(qp, rp, a, b)
|
|
||||||
|
|
||||||
extern JS_PUBLIC_API(void) jsll_udivmod(JSUint64 *qp, JSUint64 *rp, JSUint64 a, JSUint64 b);
|
|
||||||
|
|
||||||
#define JSLL_DIV(r, a, b) { \
|
|
||||||
JSInt64 _a, _b; \
|
|
||||||
JSUint32 _negative = (JSInt32)(a).hi < 0; \
|
|
||||||
if (_negative) { \
|
|
||||||
JSLL_NEG(_a, a); \
|
|
||||||
} else { \
|
|
||||||
_a = a; \
|
|
||||||
} \
|
|
||||||
if ((JSInt32)(b).hi < 0) { \
|
|
||||||
_negative ^= 1; \
|
|
||||||
JSLL_NEG(_b, b); \
|
|
||||||
} else { \
|
|
||||||
_b = b; \
|
|
||||||
} \
|
|
||||||
JSLL_UDIVMOD(&(r), 0, _a, _b); \
|
|
||||||
if (_negative) \
|
|
||||||
JSLL_NEG(r, r); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define JSLL_MOD(r, a, b) { \
|
|
||||||
JSInt64 _a, _b; \
|
|
||||||
JSUint32 _negative = (JSInt32)(a).hi < 0; \
|
|
||||||
if (_negative) { \
|
|
||||||
JSLL_NEG(_a, a); \
|
|
||||||
} else { \
|
|
||||||
_a = a; \
|
|
||||||
} \
|
|
||||||
if ((JSInt32)(b).hi < 0) { \
|
|
||||||
JSLL_NEG(_b, b); \
|
|
||||||
} else { \
|
|
||||||
_b = b; \
|
|
||||||
} \
|
|
||||||
JSLL_UDIVMOD(0, &(r), _a, _b); \
|
|
||||||
if (_negative) \
|
|
||||||
JSLL_NEG(r, r); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define JSLL_SHL(r, a, b) { \
|
|
||||||
if (b) { \
|
|
||||||
JSInt64 _a; \
|
|
||||||
_a = a; \
|
|
||||||
if ((b) < 32) { \
|
|
||||||
(r).lo = _a.lo << ((b) & 31); \
|
|
||||||
(r).hi = (_a.hi << ((b) & 31)) | (_a.lo >> (32 - (b))); \
|
|
||||||
} else { \
|
|
||||||
(r).lo = 0; \
|
|
||||||
(r).hi = _a.lo << ((b) & 31); \
|
|
||||||
} \
|
|
||||||
} else { \
|
|
||||||
(r) = (a); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* a is an JSInt32, b is JSInt32, r is JSInt64 */
|
|
||||||
#define JSLL_ISHL(r, a, b) { \
|
|
||||||
if (b) { \
|
|
||||||
JSInt64 _a; \
|
|
||||||
_a.lo = (a); \
|
|
||||||
_a.hi = 0; \
|
|
||||||
if ((b) < 32) { \
|
|
||||||
(r).lo = (a) << ((b) & 31); \
|
|
||||||
(r).hi = ((a) >> (32 - (b))); \
|
|
||||||
} else { \
|
|
||||||
(r).lo = 0; \
|
|
||||||
(r).hi = (a) << ((b) & 31); \
|
|
||||||
} \
|
|
||||||
} else { \
|
|
||||||
(r).lo = (a); \
|
|
||||||
(r).hi = 0; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define JSLL_SHR(r, a, b) { \
|
|
||||||
if (b) { \
|
|
||||||
JSInt64 _a; \
|
|
||||||
_a = a; \
|
|
||||||
if ((b) < 32) { \
|
|
||||||
(r).lo = (_a.hi << (32 - (b))) | (_a.lo >> ((b) & 31)); \
|
|
||||||
(r).hi = (JSInt32)_a.hi >> ((b) & 31); \
|
|
||||||
} else { \
|
|
||||||
(r).lo = (JSInt32)_a.hi >> ((b) & 31); \
|
|
||||||
(r).hi = (JSInt32)_a.hi >> 31; \
|
|
||||||
} \
|
|
||||||
} else { \
|
|
||||||
(r) = (a); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define JSLL_USHR(r, a, b) { \
|
|
||||||
if (b) { \
|
|
||||||
JSInt64 _a; \
|
|
||||||
_a = a; \
|
|
||||||
if ((b) < 32) { \
|
|
||||||
(r).lo = (_a.hi << (32 - (b))) | (_a.lo >> ((b) & 31)); \
|
|
||||||
(r).hi = _a.hi >> ((b) & 31); \
|
|
||||||
} else { \
|
|
||||||
(r).lo = _a.hi >> ((b) & 31); \
|
|
||||||
(r).hi = 0; \
|
|
||||||
} \
|
|
||||||
} else { \
|
|
||||||
(r) = (a); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define JSLL_L2I(i, l) ((i) = (l).lo)
|
|
||||||
#define JSLL_L2UI(ui, l) ((ui) = (l).lo)
|
|
||||||
#define JSLL_L2F(f, l) { double _d; JSLL_L2D(_d, l); (f) = (JSFloat64)_d; }
|
|
||||||
|
|
||||||
#define JSLL_L2D(d, l) { \
|
|
||||||
int _negative; \
|
|
||||||
JSInt64 _absval; \
|
|
||||||
\
|
|
||||||
_negative = (l).hi >> 31; \
|
|
||||||
if (_negative) { \
|
|
||||||
JSLL_NEG(_absval, l); \
|
|
||||||
} else { \
|
|
||||||
_absval = l; \
|
|
||||||
} \
|
|
||||||
(d) = (double)_absval.hi * 4.294967296e9 + _absval.lo; \
|
|
||||||
if (_negative) \
|
|
||||||
(d) = -(d); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define JSLL_I2L(l, i) { JSInt32 _i = (i) >> 31; (l).lo = (i); (l).hi = _i; }
|
|
||||||
#define JSLL_UI2L(l, ui) ((l).lo = (ui), (l).hi = 0)
|
|
||||||
#define JSLL_F2L(l, f) { double _d = (double)f; JSLL_D2L(l, _d); }
|
|
||||||
|
|
||||||
#define JSLL_D2L(l, d) { \
|
|
||||||
int _negative; \
|
|
||||||
double _absval, _d_hi; \
|
|
||||||
JSInt64 _lo_d; \
|
|
||||||
\
|
|
||||||
_negative = ((d) < 0); \
|
|
||||||
_absval = _negative ? -(d) : (d); \
|
|
||||||
\
|
|
||||||
(l).hi = _absval / 4.294967296e9; \
|
|
||||||
(l).lo = 0; \
|
|
||||||
JSLL_L2D(_d_hi, l); \
|
|
||||||
_absval -= _d_hi; \
|
|
||||||
_lo_d.hi = 0; \
|
|
||||||
if (_absval < 0) { \
|
|
||||||
_lo_d.lo = -_absval; \
|
|
||||||
JSLL_SUB(l, l, _lo_d); \
|
|
||||||
} else { \
|
|
||||||
_lo_d.lo = _absval; \
|
|
||||||
JSLL_ADD(l, l, _lo_d); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
if (_negative) \
|
|
||||||
JSLL_NEG(l, l); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* !JS_HAVE_LONG_LONG */
|
|
||||||
|
|
||||||
JS_END_EXTERN_C
|
JS_END_EXTERN_C
|
||||||
|
|
||||||
#endif /* jslong_h___ */
|
#endif /* jslong_h___ */
|
||||||
|
|
|
@ -290,12 +290,9 @@ JS_BEGIN_EXTERN_C
|
||||||
** The int8 types are known to be 8 bits each. There is no type that
|
** The int8 types are known to be 8 bits each. There is no type that
|
||||||
** is equivalent to a plain "char".
|
** is equivalent to a plain "char".
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
#if JS_BYTES_PER_BYTE == 1
|
|
||||||
typedef unsigned char JSUint8;
|
typedef uint8_t JSUint8;
|
||||||
typedef signed char JSInt8;
|
typedef int8_t JSInt8;
|
||||||
#else
|
|
||||||
# error No suitable type for JSInt8/JSUint8
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
** TYPES: JSUint16
|
** TYPES: JSUint16
|
||||||
|
@ -303,12 +300,9 @@ typedef signed char JSInt8;
|
||||||
** DESCRIPTION:
|
** DESCRIPTION:
|
||||||
** The int16 types are known to be 16 bits each.
|
** The int16 types are known to be 16 bits each.
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
#if JS_BYTES_PER_SHORT == 2
|
|
||||||
typedef unsigned short JSUint16;
|
typedef uint16_t JSUint16;
|
||||||
typedef short JSInt16;
|
typedef int16_t JSInt16;
|
||||||
#else
|
|
||||||
# error No suitable type for JSInt16/JSUint16
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
** TYPES: JSUint32
|
** TYPES: JSUint32
|
||||||
|
@ -316,19 +310,9 @@ typedef short JSInt16;
|
||||||
** DESCRIPTION:
|
** DESCRIPTION:
|
||||||
** The int32 types are known to be 32 bits each.
|
** The int32 types are known to be 32 bits each.
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
#if JS_BYTES_PER_INT == 4
|
|
||||||
typedef unsigned int JSUint32;
|
typedef uint32_t JSUint32;
|
||||||
typedef int JSInt32;
|
typedef int32_t JSInt32;
|
||||||
# define JS_INT32(x) x
|
|
||||||
# define JS_UINT32(x) x ## U
|
|
||||||
#elif JS_BYTES_PER_LONG == 4
|
|
||||||
typedef unsigned long JSUint32;
|
|
||||||
typedef long JSInt32;
|
|
||||||
# define JS_INT32(x) x ## L
|
|
||||||
# define JS_UINT32(x) x ## UL
|
|
||||||
#else
|
|
||||||
# error No suitable type for JSInt32/JSUint32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
** TYPES: JSUint64
|
** TYPES: JSUint64
|
||||||
|
@ -340,34 +324,9 @@ typedef long JSInt32;
|
||||||
** 64 bit values. The only guaranteed portability requires the use of
|
** 64 bit values. The only guaranteed portability requires the use of
|
||||||
** the JSLL_ macros (see jslong.h).
|
** the JSLL_ macros (see jslong.h).
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
#ifdef JS_HAVE_LONG_LONG
|
|
||||||
|
|
||||||
# if JS_BYTES_PER_LONG == 8
|
typedef uint64_t JSUint64;
|
||||||
typedef long JSInt64;
|
typedef int64_t JSInt64;
|
||||||
typedef unsigned long JSUint64;
|
|
||||||
# elif defined(WIN16)
|
|
||||||
typedef __int64 JSInt64;
|
|
||||||
typedef unsigned __int64 JSUint64;
|
|
||||||
# elif defined(WIN32) && !defined(__GNUC__)
|
|
||||||
typedef __int64 JSInt64;
|
|
||||||
typedef unsigned __int64 JSUint64;
|
|
||||||
# else
|
|
||||||
typedef long long JSInt64;
|
|
||||||
typedef unsigned long long JSUint64;
|
|
||||||
# endif /* JS_BYTES_PER_LONG == 8 */
|
|
||||||
|
|
||||||
#else /* !JS_HAVE_LONG_LONG */
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
# ifdef IS_LITTLE_ENDIAN
|
|
||||||
JSUint32 lo, hi;
|
|
||||||
# else
|
|
||||||
JSUint32 hi, lo;
|
|
||||||
#endif
|
|
||||||
} JSInt64;
|
|
||||||
typedef JSInt64 JSUint64;
|
|
||||||
|
|
||||||
#endif /* !JS_HAVE_LONG_LONG */
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
** TYPES: JSUintn
|
** TYPES: JSUintn
|
||||||
|
@ -378,12 +337,9 @@ typedef JSInt64 JSUint64;
|
||||||
** define them to be wider (e.g., 32 or even 64 bits). These types are
|
** define them to be wider (e.g., 32 or even 64 bits). These types are
|
||||||
** never valid for fields of a structure.
|
** never valid for fields of a structure.
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
#if JS_BYTES_PER_INT >= 2
|
|
||||||
typedef int JSIntn;
|
typedef int JSIntn;
|
||||||
typedef unsigned int JSUintn;
|
typedef unsigned int JSUintn;
|
||||||
#else
|
|
||||||
# error 'sizeof(int)' not sufficient for platform use
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
** TYPES: JSFloat64
|
** TYPES: JSFloat64
|
||||||
|
@ -413,11 +369,7 @@ typedef ptrdiff_t JSPtrdiff;
|
||||||
** A type for pointer difference. Variables of this type are suitable
|
** A type for pointer difference. Variables of this type are suitable
|
||||||
** for storing a pointer or pointer sutraction.
|
** for storing a pointer or pointer sutraction.
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
#if JS_BYTES_PER_WORD == 8 && JS_BYTES_PER_LONG != 8
|
typedef uintptr_t JSUptrdiff;
|
||||||
typedef JSUint64 JSUptrdiff;
|
|
||||||
#else
|
|
||||||
typedef unsigned long JSUptrdiff;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
** TYPES: JSBool
|
** TYPES: JSBool
|
||||||
|
@ -442,13 +394,8 @@ typedef JSUint8 JSPackedBool;
|
||||||
/*
|
/*
|
||||||
** A JSWord is an integer that is the same size as a void*
|
** A JSWord is an integer that is the same size as a void*
|
||||||
*/
|
*/
|
||||||
#if JS_BYTES_PER_WORD == 8 && JS_BYTES_PER_LONG != 8
|
typedef intptr_t JSWord;
|
||||||
typedef JSInt64 JSWord;
|
typedef uintptr_t JSUword;
|
||||||
typedef JSUint64 JSUword;
|
|
||||||
#else
|
|
||||||
typedef long JSWord;
|
|
||||||
typedef unsigned long JSUword;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "jsotypes.h"
|
#include "jsotypes.h"
|
||||||
|
|
||||||
|
@ -500,6 +447,12 @@ typedef unsigned long JSUword;
|
||||||
#define JS_ARRAY_LENGTH(array) (sizeof (array) / sizeof (array)[0])
|
#define JS_ARRAY_LENGTH(array) (sizeof (array) / sizeof (array)[0])
|
||||||
#define JS_ARRAY_END(array) ((array) + JS_ARRAY_LENGTH(array))
|
#define JS_ARRAY_END(array) ((array) + JS_ARRAY_LENGTH(array))
|
||||||
|
|
||||||
|
#define JS_BITS_PER_BYTE 8
|
||||||
|
#define JS_BITS_PER_BYTE_LOG2 3
|
||||||
|
|
||||||
|
#define JS_BITS_PER_WORD (JS_BITS_PER_BYTE * JS_BYTES_PER_WORD)
|
||||||
|
#define JS_BITS_PER_DOUBLE (JS_BITS_PER_BYTE * JS_BYTES_PER_DOUBLE)
|
||||||
|
|
||||||
JS_END_EXTERN_C
|
JS_END_EXTERN_C
|
||||||
|
|
||||||
#endif /* jstypes_h___ */
|
#endif /* jstypes_h___ */
|
||||||
|
|
|
@ -139,12 +139,8 @@ PRMJ_ToExtendedTime(JSInt32 base_time)
|
||||||
|
|
||||||
JSLL_UI2L(g1970GMTMicroSeconds,G1970GMTMICROHI);
|
JSLL_UI2L(g1970GMTMicroSeconds,G1970GMTMICROHI);
|
||||||
JSLL_UI2L(low,G1970GMTMICROLOW);
|
JSLL_UI2L(low,G1970GMTMICROLOW);
|
||||||
#ifndef JS_HAVE_LONG_LONG
|
|
||||||
JSLL_SHL(g1970GMTMicroSeconds,g1970GMTMicroSeconds,16);
|
JSLL_SHL(g1970GMTMicroSeconds,g1970GMTMicroSeconds,16);
|
||||||
JSLL_SHL(g1970GMTMicroSeconds,g1970GMTMicroSeconds,16);
|
JSLL_SHL(g1970GMTMicroSeconds,g1970GMTMicroSeconds,16);
|
||||||
#else
|
|
||||||
JSLL_SHL(g1970GMTMicroSeconds,g1970GMTMicroSeconds,32);
|
|
||||||
#endif
|
|
||||||
JSLL_ADD(g1970GMTMicroSeconds,g1970GMTMicroSeconds,low);
|
JSLL_ADD(g1970GMTMicroSeconds,g1970GMTMicroSeconds,low);
|
||||||
|
|
||||||
JSLL_I2L(exttime,base_time);
|
JSLL_I2L(exttime,base_time);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче