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