#endif
#include <signal.h>
+
+#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
+#endif
/* This is deprecated on glibc but is still used by FreeBSD */
#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
} PA_ONCE_END;
}
-pa_bool_t pa_memtrap_is_good(pa_memtrap *m) {
+bool pa_memtrap_is_good(pa_memtrap *m) {
pa_assert(m);
return !pa_atomic_load(&m->bad);
}
+#ifdef HAVE_SIGACTION
static void sigsafe_error(const char *s) {
- (void) write(STDERR_FILENO, s, strlen(s));
+ size_t ret PA_GCC_UNUSED;
+ ret = write(STDERR_FILENO, s, strlen(s));
}
static void signal_handler(int sig, siginfo_t* si, void *data) {
sigsafe_error("Failed to handle SIGBUS.\n");
abort();
}
+#endif
static void memtrap_link(pa_memtrap *m, unsigned j) {
pa_assert(m);
allocate_aupdate();
- mx = pa_static_mutex_get(&mutex, FALSE, TRUE);
+ mx = pa_static_mutex_get(&mutex, false, true);
pa_mutex_lock(mx);
j = pa_aupdate_write_begin(aupdate);
allocate_aupdate();
- mx = pa_static_mutex_get(&mutex, FALSE, TRUE);
+ mx = pa_static_mutex_get(&mutex, false, true);
pa_mutex_lock(mx);
j = pa_aupdate_write_begin(aupdate);
allocate_aupdate();
- mx = pa_static_mutex_get(&mutex, FALSE, TRUE);
+ mx = pa_static_mutex_get(&mutex, false, true);
pa_mutex_lock(mx);
j = pa_aupdate_write_begin(aupdate);
}
void pa_memtrap_install(void) {
+#ifdef HAVE_SIGACTION
struct sigaction sa;
allocate_aupdate();
sa.sa_flags = SA_RESTART|SA_SIGINFO;
pa_assert_se(sigaction(SIGBUS, &sa, NULL) == 0);
+#endif
}