Import Upstream version 20180207
[hcoop/debian/mlton.git] / runtime / platform / freebsd.c
CommitLineData
7f918cf1
CE
1#include "platform.h"
2
3#include "diskBack.unix.c"
4#include "mmap-protect.c"
5#include "nonwin.c"
6#include "sysctl.c"
7#include "use-mmap.c"
8
9void GC_displayMem (void) {
10 static char buffer[256];
11
12 snprintf (buffer, cardof(buffer), "/bin/cat /proc/%d/map\n", (int)getpid ());
13 (void)system (buffer);
14}
15
16static void catcher (__attribute__ ((unused)) int signo,
17 __attribute__ ((unused)) siginfo_t* info,
18 void* context) {
19 ucontext_t* ucp = (ucontext_t*)context;
20#if (defined (__x86_64__))
21 GC_handleSigProf ((code_pointer) ucp->uc_mcontext.mc_rip);
22#elif (defined (__i386__))
23 GC_handleSigProf ((code_pointer) ucp->uc_mcontext.mc_eip);
24#else
25#error Profiling handler is missing for this architecture
26#endif
27}
28
29void GC_setSigProfHandler (struct sigaction *sa) {
30 sa->sa_flags = SA_ONSTACK | SA_RESTART | SA_SIGINFO;
31 sa->sa_sigaction = (void (*)(int, siginfo_t*, void*))catcher;
32}