cutils.c 906 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/*
These utility routines are used various
places in the GHC library.
*/

#include "Rts.h"

#include "HsFFI.h"

#include <string.h>

Ben Gamari's avatar
Ben Gamari committed
12
#if defined(HAVE_UNISTD_H)
13 14 15 16 17 18 19 20 21
#include <unistd.h>
#endif

/*
Calling 'strlen' and 'memcpy' directly gives problems with GCC's inliner,
and causes gcc to require too many registers on x84
*/

HsInt
Simon Marlow's avatar
Simon Marlow committed
22
ghc_strlen( HsPtr a )
23 24 25 26 27
{
    return (strlen((char *)a));
}

HsInt
Simon Marlow's avatar
Simon Marlow committed
28
ghc_memcmp( HsPtr a1, HsPtr a2, HsInt len )
29 30 31 32 33
{
    return (memcmp((char *)a1, a2, len));
}

void
34
enableTimingStats( void )       /* called from the driver */
35 36 37 38 39 40 41 42 43
{
    RtsFlags.GcFlags.giveStats = ONELINE_GC_STATS;
}

void
setHeapSize( HsInt size )
{
    RtsFlags.GcFlags.heapSizeSuggestion = size / BLOCK_SIZE;
    if (RtsFlags.GcFlags.maxHeapSize != 0 &&
44 45
        RtsFlags.GcFlags.heapSizeSuggestion > RtsFlags.GcFlags.maxHeapSize) {
        RtsFlags.GcFlags.maxHeapSize = RtsFlags.GcFlags.heapSizeSuggestion;
46 47
    }
}