New syntax for GADT-style record declarations, and associated refactoring
[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 #include "RtsFlags.h"
8
9 #include "HsFFI.h"
10
11 #include <string.h>
12
13 #ifdef HAVE_UNISTD_H
14 #include <unistd.h>
15 #endif
16
17 /*
18 Calling 'strlen' and 'memcpy' directly gives problems with GCC's inliner,
19 and causes gcc to require too many registers on x84
20 */
21
22 HsInt
23 ghc_strlen( HsAddr a )
24 {
25     return (strlen((char *)a));
26 }
27
28 HsInt
29 ghc_memcmp( HsAddr a1, HsAddr a2, HsInt len )
30 {
31     return (memcmp((char *)a1, a2, len));
32 }
33
34 HsInt
35 ghc_memcmp_off( HsAddr a1, HsInt i, HsAddr a2, HsInt len )
36 {
37     return (memcmp((char *)a1 + i, a2, len));
38 }
39
40 void
41 enableTimingStats( void )       /* called from the driver */
42 {
43     RtsFlags.GcFlags.giveStats = ONELINE_GC_STATS;
44 }
45
46 void
47 setHeapSize( HsInt size )
48 {
49     RtsFlags.GcFlags.heapSizeSuggestion = size / BLOCK_SIZE;
50     if (RtsFlags.GcFlags.maxHeapSize != 0 &&
51         RtsFlags.GcFlags.heapSizeSuggestion > RtsFlags.GcFlags.maxHeapSize) {
52         RtsFlags.GcFlags.maxHeapSize = RtsFlags.GcFlags.heapSizeSuggestion;
53     }
54 }
55
56