Commit 87114ae1 authored by wereHamster's avatar wereHamster Committed by Ben Gamari

Use stdint types to define SIZEOF and ALIGNMENT of INTx/WORDx

Saves us a CPP #if in MachDeps.h since we now can always rely on a
64-bit type being available.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie, erikd

Differential Revision: https://phabricator.haskell.org/D2099
parent 10d808c5
...@@ -831,6 +831,16 @@ m4_popdef([fp_Cache])[]dnl ...@@ -831,6 +831,16 @@ m4_popdef([fp_Cache])[]dnl
])# FP_CHECK_ALIGNMENT ])# FP_CHECK_ALIGNMENT
# FP_CHECK_SIZEOF_AND_ALIGNMENT(TYPE)
# ------------------------------------------------------------------
# Combines AC_CHECK_SIZEOF and FP_CHECK_ALIGNMENT.
AC_DEFUN([FP_CHECK_SIZEOF_AND_ALIGNMENT],
[AC_CHECK_SIZEOF([$1])
FP_CHECK_ALIGNMENT([$1])
])# FP_CHECK_SIZEOF_AND_ALIGNMENT
# FP_LEADING_UNDERSCORE # FP_LEADING_UNDERSCORE
# --------------------- # ---------------------
# Test for determining whether symbol names have a leading underscore. We assume # Test for determining whether symbol names have a leading underscore. We assume
......
...@@ -796,47 +796,37 @@ dnl ** do we have long longs? ...@@ -796,47 +796,37 @@ dnl ** do we have long longs?
AC_CHECK_TYPES([long long]) AC_CHECK_TYPES([long long])
dnl ** what are the sizes of various types dnl ** what are the sizes of various types
AC_CHECK_SIZEOF(char, 1) FP_CHECK_SIZEOF_AND_ALIGNMENT(char)
AC_CHECK_SIZEOF(double, 8) FP_CHECK_SIZEOF_AND_ALIGNMENT(double)
AC_CHECK_SIZEOF(float, 4) FP_CHECK_SIZEOF_AND_ALIGNMENT(float)
AC_CHECK_SIZEOF(int, 4) FP_CHECK_SIZEOF_AND_ALIGNMENT(int)
AC_CHECK_SIZEOF(long, 4) FP_CHECK_SIZEOF_AND_ALIGNMENT(long)
if test "$ac_cv_type_long_long" = yes; then if test "$ac_cv_type_long_long" = yes; then
AC_CHECK_SIZEOF(long long, 8) FP_CHECK_SIZEOF_AND_ALIGNMENT(long long)
fi fi
AC_CHECK_SIZEOF(short, 2) FP_CHECK_SIZEOF_AND_ALIGNMENT(short)
AC_CHECK_SIZEOF(unsigned char, 1) FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned char)
AC_CHECK_SIZEOF(unsigned int, 4) FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned int)
AC_CHECK_SIZEOF(unsigned long, 4) FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long)
if test "$ac_cv_type_long_long" = yes; then if test "$ac_cv_type_long_long" = yes; then
AC_CHECK_SIZEOF(unsigned long long, 8) FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned long long)
fi fi
AC_CHECK_SIZEOF(unsigned short, 2) FP_CHECK_SIZEOF_AND_ALIGNMENT(unsigned short)
AC_CHECK_SIZEOF(void *, 4) FP_CHECK_SIZEOF_AND_ALIGNMENT(void *)
FP_CHECK_SIZEOF_AND_ALIGNMENT(int8_t)
FP_CHECK_SIZEOF_AND_ALIGNMENT(uint8_t)
FP_CHECK_SIZEOF_AND_ALIGNMENT(int16_t)
FP_CHECK_SIZEOF_AND_ALIGNMENT(uint16_t)
FP_CHECK_SIZEOF_AND_ALIGNMENT(int32_t)
FP_CHECK_SIZEOF_AND_ALIGNMENT(uint32_t)
FP_CHECK_SIZEOF_AND_ALIGNMENT(int64_t)
FP_CHECK_SIZEOF_AND_ALIGNMENT(uint64_t)
dnl for use in settings.in dnl for use in settings.in
WordSize=$ac_cv_sizeof_void_p WordSize=$ac_cv_sizeof_void_p
AC_SUBST(WordSize) AC_SUBST(WordSize)
dnl ** what are alignment constraints on various types
FP_CHECK_ALIGNMENT(char)
FP_CHECK_ALIGNMENT(double)
FP_CHECK_ALIGNMENT(float)
FP_CHECK_ALIGNMENT(int)
FP_CHECK_ALIGNMENT(long)
if test "$ac_cv_type_long_long" = yes; then
FP_CHECK_ALIGNMENT(long long)
fi
FP_CHECK_ALIGNMENT(short)
FP_CHECK_ALIGNMENT(unsigned char)
FP_CHECK_ALIGNMENT(unsigned int)
FP_CHECK_ALIGNMENT(unsigned long)
if test "$ac_cv_type_long_long" = yes; then
FP_CHECK_ALIGNMENT(unsigned long long)
fi
FP_CHECK_ALIGNMENT(unsigned short)
FP_CHECK_ALIGNMENT(void *)
FP_CHECK_FUNC([WinExec], FP_CHECK_FUNC([WinExec],
[@%:@include <windows.h>], [WinExec("",0)]) [@%:@include <windows.h>], [WinExec("",0)])
......
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* *
* (c) The University of Glasgow 2002 * (c) The University of Glasgow 2002
* *
* Definitions that characterise machine specific properties of basic * Definitions that characterise machine specific properties of basic
* types (C & Haskell). * types (C & Haskell).
* *
...@@ -28,19 +28,6 @@ ...@@ -28,19 +28,6 @@
* but it takes up SIZEOF_HSWORD (4 or 8) bytes in the heap. * but it takes up SIZEOF_HSWORD (4 or 8) bytes in the heap.
*/ */
/* First, check some assumptions.. */
#if SIZEOF_CHAR != 1
#error GHC untested on this architecture: sizeof(char) != 1
#endif
#if SIZEOF_SHORT != 2
#error GHC untested on this architecture: sizeof(short) != 2
#endif
#if SIZEOF_UNSIGNED_INT != 4
#error GHC untested on this architecture: sizeof(unsigned int) != 4
#endif
#define SIZEOF_HSCHAR SIZEOF_WORD32 #define SIZEOF_HSCHAR SIZEOF_WORD32
#define ALIGNMENT_HSCHAR ALIGNMENT_WORD32 #define ALIGNMENT_HSCHAR ALIGNMENT_WORD32
...@@ -65,43 +52,35 @@ ...@@ -65,43 +52,35 @@
#define SIZEOF_HSSTABLEPTR SIZEOF_VOID_P #define SIZEOF_HSSTABLEPTR SIZEOF_VOID_P
#define ALIGNMENT_HSSTABLEPTR ALIGNMENT_VOID_P #define ALIGNMENT_HSSTABLEPTR ALIGNMENT_VOID_P
#define SIZEOF_INT8 SIZEOF_CHAR #define SIZEOF_INT8 SIZEOF_INT8_T
#define ALIGNMENT_INT8 ALIGNMENT_CHAR #define ALIGNMENT_INT8 ALIGNMENT_INT8_T
#define SIZEOF_WORD8 SIZEOF_UNSIGNED_CHAR #define SIZEOF_WORD8 SIZEOF_UINT8_T
#define ALIGNMENT_WORD8 ALIGNMENT_UNSIGNED_CHAR #define ALIGNMENT_WORD8 ALIGNMENT_UINT8_T
#define SIZEOF_INT16 SIZEOF_SHORT #define SIZEOF_INT16 SIZEOF_INT16_T
#define ALIGNMENT_INT16 ALIGNMENT_SHORT #define ALIGNMENT_INT16 ALIGNMENT_INT16_T
#define SIZEOF_WORD16 SIZEOF_UNSIGNED_SHORT #define SIZEOF_WORD16 SIZEOF_UINT16_T
#define ALIGNMENT_WORD16 ALIGNMENT_UNSIGNED_SHORT #define ALIGNMENT_WORD16 ALIGNMENT_UINT16_T
#define SIZEOF_INT32 SIZEOF_INT #define SIZEOF_INT32 SIZEOF_INT32_T
#define ALIGNMENT_INT32 ALIGNMENT_INT #define ALIGNMENT_INT32 ALIGNMENT_INT32_T
#define SIZEOF_WORD32 SIZEOF_UNSIGNED_INT #define SIZEOF_WORD32 SIZEOF_UINT32_T
#define ALIGNMENT_WORD32 ALIGNMENT_UNSIGNED_INT #define ALIGNMENT_WORD32 ALIGNMENT_UINT32_T
#if SIZEOF_LONG == 8 #define SIZEOF_INT64 SIZEOF_INT64_T
#define SIZEOF_INT64 SIZEOF_LONG #define ALIGNMENT_INT64 ALIGNMENT_INT64_T
#define ALIGNMENT_INT64 ALIGNMENT_LONG
#define SIZEOF_WORD64 SIZEOF_UNSIGNED_LONG #define SIZEOF_WORD64 SIZEOF_UINT64_T
#define ALIGNMENT_WORD64 ALIGNMENT_UNSIGNED_LONG #define ALIGNMENT_WORD64 ALIGNMENT_UINT64_T
#elif HAVE_LONG_LONG && SIZEOF_LONG_LONG == 8
#define SIZEOF_INT64 SIZEOF_LONG_LONG
#define ALIGNMENT_INT64 ALIGNMENT_LONG_LONG
#define SIZEOF_WORD64 SIZEOF_UNSIGNED_LONG_LONG
#define ALIGNMENT_WORD64 ALIGNMENT_UNSIGNED_LONG_LONG
#else
#error Cannot find a 64bit type.
#endif
#ifndef WORD_SIZE_IN_BITS #ifndef WORD_SIZE_IN_BITS
#if SIZEOF_HSWORD == 4 #if SIZEOF_HSWORD == 4
#define WORD_SIZE_IN_BITS 32 #define WORD_SIZE_IN_BITS 32
#define WORD_SIZE_IN_BITS_FLOAT 32.0 #define WORD_SIZE_IN_BITS_FLOAT 32.0
#else #else
#define WORD_SIZE_IN_BITS 64 #define WORD_SIZE_IN_BITS 64
#define WORD_SIZE_IN_BITS_FLOAT 64.0 #define WORD_SIZE_IN_BITS_FLOAT 64.0
#endif #endif
...@@ -110,7 +89,7 @@ ...@@ -110,7 +89,7 @@
#ifndef TAG_BITS #ifndef TAG_BITS
#if SIZEOF_HSWORD == 4 #if SIZEOF_HSWORD == 4
#define TAG_BITS 2 #define TAG_BITS 2
#else #else
#define TAG_BITS 3 #define TAG_BITS 3
#endif #endif
#endif #endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment