Deriving Functor-like classes should unify kind variables
[ghc.git] / includes / Rts.h
index cb23fd1..6f4f33e 100644 (file)
@@ -6,7 +6,7 @@
  * exposes externally.
  *
  * To understand the structure of the RTS headers, see the wiki:
- *   http://hackage.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
+ *   http://ghc.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
  *
  * ---------------------------------------------------------------------------*/
 
@@ -99,16 +99,16 @@ extern "C" {
 void _assertFail(const char *filename, unsigned int linenum)
    GNUC3_ATTRIBUTE(__noreturn__);
 
-#define CHECK(predicate)                       \
-       if (predicate)                          \
-           /*null*/;                           \
-       else                                    \
-           _assertFail(__FILE__, __LINE__)
+#define CHECK(predicate)                        \
+        if (predicate)                          \
+            /*null*/;                           \
+        else                                    \
+            _assertFail(__FILE__, __LINE__)
 
 #define CHECKM(predicate, msg, ...)             \
-       if (predicate)                          \
-           /*null*/;                           \
-       else                                    \
+        if (predicate)                          \
+            /*null*/;                           \
+        else                                    \
             barf(msg, ##__VA_ARGS__)
 
 #ifndef DEBUG
@@ -119,7 +119,7 @@ void _assertFail(const char *filename, unsigned int linenum)
 #define ASSERTM(predicate,msg,...) CHECKM(predicate,msg,##__VA_ARGS__)
 #endif /* DEBUG */
 
-/* 
+/*
  * Use this on the RHS of macros which expand to nothing
  * to make sure that the macro can be used in a context which
  * demands a non-empty statement.
@@ -143,23 +143,8 @@ void _assertFail(const char *filename, unsigned int linenum)
 #define USED_IF_NOT_THREADS
 #endif
 
-/*
- * Getting printf formats right for platform-dependent typedefs
- */
-#if SIZEOF_LONG == 8
-#define FMT_Word64 "lu"
-#define FMT_Int64  "ld"
-#else
-#if defined(mingw32_HOST_OS)
-/* mingw doesn't understand %llu/%lld - it treats them as 32-bit
-   rather than 64-bit */
-#define FMT_Word64 "I64u"
-#define FMT_Int64  "I64d"
-#else
-#define FMT_Word64 "llu"
-#define FMT_Int64  "lld"
-#endif
-#endif
+#define FMT_SizeT    "zu"
+#define FMT_HexSizeT "zx"
 
 /* -----------------------------------------------------------------------------
    Time values in the RTS
@@ -171,6 +156,8 @@ void _assertFail(const char *filename, unsigned int linenum)
 #define TIME_RESOLUTION 1000000000
 typedef StgInt64 Time;
 
+#define TIME_MAX HS_INT64_MAX
+
 #if TIME_RESOLUTION == 1000000000
 // I'm being lazy, but it's awkward to define fully general versions of these
 #define TimeToUS(t)      ((t) / 1000)
@@ -195,7 +182,7 @@ INLINE_HEADER Time fsecondsToTime (double t)
    Include everything STG-ish
    -------------------------------------------------------------------------- */
 
-/* System headers: stdlib.h is eeded so that we can use NULL.  It must
+/* System headers: stdlib.h is needed so that we can use NULL.  It must
  * come after MachRegs.h, because stdlib.h might define some inline
  * functions which may only be defined after register variables have
  * been declared.
@@ -204,7 +191,7 @@ INLINE_HEADER Time fsecondsToTime (double t)
 
 #include "rts/Config.h"
 
-/* Global constaints */
+/* Global constraints */
 #include "rts/Constants.h"
 
 /* Profiling information */
@@ -216,12 +203,12 @@ INLINE_HEADER Time fsecondsToTime (double t)
 #include "rts/SpinLock.h"
 
 #include "rts/Messages.h"
+#include "rts/Threads.h"
 
 /* Storage format definitions */
 #include "rts/storage/FunTypes.h"
 #include "rts/storage/InfoTables.h"
 #include "rts/storage/Closures.h"
-#include "rts/storage/Liveness.h"
 #include "rts/storage/ClosureTypes.h"
 #include "rts/storage/TSO.h"
 #include "stg/MiscClosures.h" /* InfoTables, closures etc. defined in the RTS */
@@ -233,17 +220,16 @@ INLINE_HEADER Time fsecondsToTime (double t)
 
 /* Other RTS external APIs */
 #include "rts/Parallel.h"
-#include "rts/Hooks.h"
 #include "rts/Signals.h"
 #include "rts/BlockSignals.h"
 #include "rts/Hpc.h"
 #include "rts/Flags.h"
 #include "rts/Adjustor.h"
 #include "rts/FileLock.h"
+#include "rts/GetTime.h"
 #include "rts/Globals.h"
 #include "rts/IOManager.h"
 #include "rts/Linker.h"
-#include "rts/Threads.h"
 #include "rts/Ticky.h"
 #include "rts/Timer.h"
 #include "rts/Stable.h"
@@ -251,9 +237,12 @@ INLINE_HEADER Time fsecondsToTime (double t)
 #include "rts/Utils.h"
 #include "rts/PrimFloat.h"
 #include "rts/Main.h"
+#include "rts/StaticPtrTable.h"
+#include "rts/Libdw.h"
+#include "rts/LibdwPool.h"
 
 /* Misc stuff without a home */
-DLL_IMPORT_RTS extern char **prog_argv;        /* so we can get at these from Haskell */
+DLL_IMPORT_RTS extern char **prog_argv; /* so we can get at these from Haskell */
 DLL_IMPORT_RTS extern int    prog_argc;
 DLL_IMPORT_RTS extern char  *prog_name;
 
@@ -263,7 +252,7 @@ void getWin32ProgArgv(int *argc, wchar_t **argv[]);
 void setWin32ProgArgv(int argc, wchar_t *argv[]);
 #endif
 
-void stackOverflow(void);
+void stackOverflow(StgTSO* tso);
 
 void stg_exit(int n) GNU_ATTRIBUTE(__noreturn__);
 
@@ -272,6 +261,16 @@ int stg_sig_install (int, int, void *);
 #endif
 
 /* -----------------------------------------------------------------------------
+   Ways
+   -------------------------------------------------------------------------- */
+
+// Returns non-zero if the RTS is a profiling version
+int rts_isProfiled(void);
+
+// Returns non-zero if the RTS is a dynamically-linked version
+int rts_isDynamic(void);
+
+/* -----------------------------------------------------------------------------
    RTS Exit codes
    -------------------------------------------------------------------------- */
 
@@ -320,6 +319,12 @@ TICK_VAR(2)
 #define DEBUG_ONLY(s) doNothing()
 #endif
 
+#ifdef DEBUG
+#define DEBUG_IS_ON   1
+#else
+#define DEBUG_IS_ON   0
+#endif
+
 /* -----------------------------------------------------------------------------
    Useful macros and inline functions
    -------------------------------------------------------------------------- */