diff options
Diffstat (limited to 'rts')
-rw-r--r-- | rts/ProfHeap.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/rts/ProfHeap.c b/rts/ProfHeap.c index 4f82b0ba83..bc439c1678 100644 --- a/rts/ProfHeap.c +++ b/rts/ProfHeap.c @@ -26,8 +26,15 @@ #include <fs_rts.h> #include <string.h> +#if defined(darwin_HOST_OS) +#include <xlocale.h> +#else +#include <locale.h> +#endif + FILE *hp_file; static char *hp_filename; /* heap profile (hp2ps style) log file */ +static locale_t prof_locale = 0, saved_locale = 0; /* ----------------------------------------------------------------------------- * era stores the current time period. It is the same as the @@ -344,6 +351,10 @@ printSample(bool beginSample, StgDouble sampleValue) void freeHeapProfiling (void) { + if (prof_locale) { + freelocale(prof_locale); + prof_locale = 0; + } } /* -------------------------------------------------------------------------- @@ -356,6 +367,15 @@ initHeapProfiling(void) return; } + if (! prof_locale) { + prof_locale = newlocale(LC_NUMERIC_MASK, "POSIX", 0); + if (! prof_locale) { + sysErrorBelch("Couldn't allocate heap profiler locale"); + /* non-fatal: risk using an unknown locale, but won't crash */ + } + } + saved_locale = uselocale(prof_locale); + char *prog; prog = stgMallocBytes(strlen(prog_name) + 1, "initHeapProfiling"); @@ -453,6 +473,8 @@ initHeapProfiling(void) } #endif + uselocale(saved_locale); + traceHeapProfBegin(0); } @@ -465,6 +487,8 @@ endHeapProfiling(void) return; } + saved_locale = uselocale(prof_locale); + #if defined(PROFILING) if (doingRetainerProfiling()) { endRetainerProfiling(); @@ -505,6 +529,8 @@ endHeapProfiling(void) printSample(true, seconds); printSample(false, seconds); fclose(hp_file); + + uselocale(saved_locale); } @@ -759,6 +785,8 @@ dumpCensus( Census *census ) counter *ctr; ssize_t count; + saved_locale = uselocale(prof_locale); + printSample(true, census->time); @@ -887,6 +915,8 @@ dumpCensus( Census *census ) traceHeapProfSampleEnd(era); printSample(false, census->time); + + uselocale(saved_locale); } |