Add HsCoreTy to HsType
[ghc-hetmet.git] / compiler / parser / cutils.c
1 /*
2 These utility routines are used various
3 places in the GHC library.
4 */
5
6 #include "Rts.h"
7 #if __GLASGOW_HASKELL__ <= 610
8 #include "RtsFlags.h"
9 #endif
10
11 #include "HsFFI.h"
12
13 #include <string.h>
14
15 #ifdef HAVE_UNISTD_H
16 #include <unistd.h>
17 #endif
18
19 /*
20 Calling 'strlen' and 'memcpy' directly gives problems with GCC's inliner,
21 and causes gcc to require too many registers on x84
22 */
23
24 HsInt
25 ghc_strlen( HsPtr a )
26 {
27     return (strlen((char *)a));
28 }
29
30 HsInt
31 ghc_memcmp( HsPtr a1, HsPtr a2, HsInt len )
32 {
33     return (memcmp((char *)a1, a2, len));
34 }
35
36 HsInt
37 ghc_memcmp_off( HsPtr a1, HsInt i, HsPtr a2, HsInt len )
38 {
39     return (memcmp((char *)a1 + i, a2, len));
40 }
41
42 void
43 enableTimingStats( void )       /* called from the driver */
44 {
45     RtsFlags.GcFlags.giveStats = ONELINE_GC_STATS;
46 }
47
48 void
49 setHeapSize( HsInt size )
50 {
51     RtsFlags.GcFlags.heapSizeSuggestion = size / BLOCK_SIZE;
52     if (RtsFlags.GcFlags.maxHeapSize != 0 &&
53         RtsFlags.GcFlags.heapSizeSuggestion > RtsFlags.GcFlags.maxHeapSize) {
54         RtsFlags.GcFlags.maxHeapSize = RtsFlags.GcFlags.heapSizeSuggestion;
55     }
56 }
57
58