Fix the ticky ticky build
[ghc-hetmet.git] / includes / Stg.h
index a63b7ec..7f37783 100644 (file)
 #include "ghcconfig.h"
 #include "RtsConfig.h"
 
+/* The code generator calls the math functions directly in .hc code.
+   NB. after configuration stuff above, because this sets #defines
+   that depend on config info, such as __USE_FILE_OFFSET64 */
+#include <math.h>
+
 /* -----------------------------------------------------------------------------
    Useful definitions
    -------------------------------------------------------------------------- */
@@ -66,7 +71,9 @@
 #define BITS_IN(x) (BITS_PER_BYTE * sizeof(x))
 
 /*
- * 'Portable' inlining
+ * 'Portable' inlining:
+ * INLINE_HEADER is for inline functions in header files
+ * STATIC_INLINE is for inline functions in source files
  */
 #if defined(__GNUC__) || defined( __INTEL_COMPILER)
 # define INLINE_HEADER static inline
@@ -127,8 +134,8 @@ typedef StgWord64       LW_;
 #define EF_(f)         extern F_ f(void)
 
 typedef StgWord StgWordArray[];
-#define EI_             extern StgWordArray
-#define II_             static StgWordArray
+#define EI_(X)          extern StgWordArray (X) GNU_ATTRIBUTE(aligned (8))
+#define II_(X)          static StgWordArray (X) GNU_ATTRIBUTE(aligned (8))
 
 /* -----------------------------------------------------------------------------
    Tail calls
@@ -146,7 +153,10 @@ typedef StgWord StgWordArray[];
 #include "StgDLL.h"
 #include "MachRegs.h"
 #include "Regs.h"
-#include "StgProf.h"  /* ToDo: separate out RTS-only stuff from here */
+
+#ifdef TICKY_TICKY
+#include "TickyCounters.h"
+#endif
 
 #if IN_STG_CODE
 /*
@@ -156,8 +166,7 @@ typedef StgWord StgWordArray[];
 #include "StgMiscClosures.h"
 #endif
 
-/* RTS external interface */
-#include "RtsExternal.h"
+#include "SMP.h" // write_barrier() inline is required 
 
 /* -----------------------------------------------------------------------------
    Moving Floats and Doubles
@@ -442,7 +451,9 @@ typedef union {
 
 /* Approximate version when we don't have long arithmetic (on 64-bit archs) */
 
-#define HALF_POS_INT  (((I_)1) << (BITS_IN (I_) / 2))
+/* If we have n-bit words then we have n-1 bits after accounting for the
+ * sign bit, so we can fit the result of multiplying 2 (n-1)/2-bit numbers */
+#define HALF_POS_INT  (((I_)1) << ((BITS_IN (I_) - 1) / 2))
 #define HALF_NEG_INT  (-HALF_POS_INT)
 
 #define mulIntMayOflo(a,b)                     \