summaryrefslogtreecommitdiff
path: root/rts/posix
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2017-04-21 09:16:48 -0400
committerBen Gamari <ben@smart-cactus.org>2017-04-28 22:35:04 -0400
commit945c45ad50ed31e3acb96fdaafb21640c4669f12 (patch)
treeae2e59ba8d3a49bbd3c3dcece39d53aef691ed44 /rts/posix
parente5b3492f23c2296d0d8221e1787ee585331f726e (diff)
downloadhaskell-945c45ad50ed31e3acb96fdaafb21640c4669f12.tar.gz
Prefer #if defined to #ifdef
Our new CPP linter enforces this.
Diffstat (limited to 'rts/posix')
-rw-r--r--rts/posix/Clock.h10
-rw-r--r--rts/posix/GetTime.c4
-rw-r--r--rts/posix/OSMem.c26
-rw-r--r--rts/posix/OSThreads.c8
-rw-r--r--rts/posix/Signals.c22
-rw-r--r--rts/posix/Signals.h2
-rw-r--r--rts/posix/TTY.c4
-rw-r--r--rts/posix/itimer/Pthread.c12
-rw-r--r--rts/posix/itimer/Setitimer.c6
-rw-r--r--rts/posix/itimer/TimerCreate.c2
10 files changed, 48 insertions, 48 deletions
diff --git a/rts/posix/Clock.h b/rts/posix/Clock.h
index d027351d31..92d0581877 100644
--- a/rts/posix/Clock.h
+++ b/rts/posix/Clock.h
@@ -8,20 +8,20 @@
#pragma once
-#ifdef HAVE_UNISTD_H
+#if defined(HAVE_UNISTD_H)
# include <unistd.h>
#endif
-#ifdef HAVE_TIME_H
+#if defined(HAVE_TIME_H)
# include <time.h>
#endif
-#ifdef HAVE_SYS_TIME_H
+#if defined(HAVE_SYS_TIME_H)
# include <sys/time.h>
#endif
-#ifdef HAVE_CLOCK_GETTIME
-# ifdef _POSIX_MONOTONIC_CLOCK
+#if defined(HAVE_CLOCK_GETTIME)
+# if defined(_POSIX_MONOTONIC_CLOCK)
# define CLOCK_ID CLOCK_MONOTONIC
# else
# define CLOCK_ID CLOCK_REALTIME
diff --git a/rts/posix/GetTime.c b/rts/posix/GetTime.c
index 5be9c8e350..8d20d18bfb 100644
--- a/rts/posix/GetTime.c
+++ b/rts/posix/GetTime.c
@@ -13,11 +13,11 @@
#include "GetTime.h"
#include "Clock.h"
-#if HAVE_SYS_RESOURCE_H
+#if defined(HAVE_SYS_RESOURCE_H)
# include <sys/resource.h>
#endif
-#ifdef HAVE_SYS_TIMES_H
+#if defined(HAVE_SYS_TIMES_H)
# include <sys/times.h>
#endif
diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c
index 48b154fa11..330da21e1f 100644
--- a/rts/posix/OSMem.c
+++ b/rts/posix/OSMem.c
@@ -15,25 +15,25 @@
#include "sm/OSMem.h"
#include "sm/HeapAlloc.h"
-#ifdef HAVE_UNISTD_H
+#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
-#ifdef HAVE_SYS_TYPES_H
+#if defined(HAVE_SYS_TYPES_H)
#include <sys/types.h>
#endif
-#ifdef HAVE_SYS_MMAN_H
+#if defined(HAVE_SYS_MMAN_H)
#include <sys/mman.h>
#endif
-#ifdef HAVE_STRING_H
+#if defined(HAVE_STRING_H)
#include <string.h>
#endif
-#ifdef HAVE_FCNTL_H
+#if defined(HAVE_FCNTL_H)
#include <fcntl.h>
#endif
-#ifdef HAVE_NUMA_H
+#if defined(HAVE_NUMA_H)
#include <numa.h>
#endif
-#ifdef HAVE_NUMAIF_H
+#if defined(HAVE_NUMAIF_H)
#include <numaif.h>
#endif
@@ -114,7 +114,7 @@ my_mmap (void *addr, W_ size, int operation)
{
void *ret;
-#ifdef darwin_HOST_OS
+#if defined(darwin_HOST_OS)
// Without MAP_FIXED, Apple's mmap ignores addr.
// With MAP_FIXED, it overwrites already mapped regions, whic
// mmap(0, ... MAP_FIXED ...) is worst of all: It unmaps the program text
@@ -160,7 +160,7 @@ my_mmap (void *addr, W_ size, int operation)
# if defined(MAP_NORESERVE)
flags = MAP_NORESERVE;
# else
-# ifdef USE_LARGE_ADDRESS_SPACE
+# if defined(USE_LARGE_ADDRESS_SPACE)
# error USE_LARGE_ADDRESS_SPACE needs MAP_NORESERVE
# endif
errorBelch("my_mmap(,,MEM_RESERVE) not supported on this platform");
@@ -170,7 +170,7 @@ my_mmap (void *addr, W_ size, int operation)
else
flags = 0;
-#ifdef hpux_HOST_OS
+#if defined(hpux_HOST_OS)
ret = mmap(addr, size, prot, flags | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
#elif defined(linux_HOST_OS)
ret = mmap(addr, size, prot, flags | MAP_ANON | MAP_PRIVATE, -1, 0);
@@ -414,7 +414,7 @@ void setExecutable (void *p, W_ len, bool exec)
}
}
-#ifdef USE_LARGE_ADDRESS_SPACE
+#if defined(USE_LARGE_ADDRESS_SPACE)
static void *
osTryReserveHeapMemory (W_ len, void *hint)
@@ -533,13 +533,13 @@ void osDecommitMemory(void *at, W_ size)
// We only do this in DEBUG because it forces the OS to remove
// all MMU entries for this page range, and there is no reason
// to do so unless there is memory pressure
-#ifdef DEBUG
+#if defined(DEBUG)
r = mprotect(at, size, PROT_NONE);
if(r < 0)
sysErrorBelch("unable to make released memory unaccessible");
#endif
-#ifdef MADV_FREE
+#if defined(MADV_FREE)
// Try MADV_FREE first, FreeBSD has both and MADV_DONTNEED
// just swaps memory out. Linux >= 4.5 has both DONTNEED and FREE; either
// will work as they both allow the system to free anonymous pages.
diff --git a/rts/posix/OSThreads.c b/rts/posix/OSThreads.c
index 43d2cc9b62..e2471a223c 100644
--- a/rts/posix/OSThreads.c
+++ b/rts/posix/OSThreads.c
@@ -62,7 +62,7 @@
#include <sys/cpuset.h>
#endif
-#ifdef HAVE_UNISTD_H
+#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
@@ -70,11 +70,11 @@
#include <mach/mach.h>
#endif
-#ifdef HAVE_SIGNAL_H
+#if defined(HAVE_SIGNAL_H)
# include <signal.h>
#endif
-#ifdef HAVE_NUMA_H
+#if defined(HAVE_NUMA_H)
#include <numa.h>
#endif
@@ -137,7 +137,7 @@ createOSThread (OSThreadId* pId, char *name STG_UNUSED,
int result = pthread_create(pId, NULL, (void *(*)(void *))startProc, param);
if (!result) {
pthread_detach(*pId);
-#ifdef HAVE_PTHREAD_SETNAME_NP
+#if defined(HAVE_PTHREAD_SETNAME_NP)
pthread_setname_np(*pId, name);
#endif
}
diff --git a/rts/posix/Signals.c b/rts/posix/Signals.c
index 80909f113f..7471948cc0 100644
--- a/rts/posix/Signals.c
+++ b/rts/posix/Signals.c
@@ -18,7 +18,7 @@
#include "Stable.h"
#include "Libdw.h"
-#ifdef alpha_HOST_ARCH
+#if defined(alpha_HOST_ARCH)
# if defined(linux_HOST_OS)
# include <asm/fpu.h>
# else
@@ -26,23 +26,23 @@
# endif
#endif
-#ifdef HAVE_UNISTD_H
+#if defined(HAVE_UNISTD_H)
# include <unistd.h>
#endif
-#ifdef HAVE_SIGNAL_H
+#if defined(HAVE_SIGNAL_H)
# include <signal.h>
#endif
-#ifdef HAVE_ERRNO_H
+#if defined(HAVE_ERRNO_H)
# include <errno.h>
#endif
-#ifdef HAVE_EVENTFD_H
+#if defined(HAVE_EVENTFD_H)
# include <sys/eventfd.h>
#endif
-#ifdef HAVE_TERMIOS_H
+#if defined(HAVE_TERMIOS_H)
#include <termios.h>
#endif
@@ -70,7 +70,7 @@ static uint32_t n_haskell_handlers = 0;
static sigset_t userSignals;
static sigset_t savedSignals;
-#ifdef THREADED_RTS
+#if defined(THREADED_RTS)
static Mutex sig_mutex; // protects signal_handlers, nHandlers
#endif
@@ -82,7 +82,7 @@ void
initUserSignals(void)
{
sigemptyset(&userSignals);
-#ifdef THREADED_RTS
+#if defined(THREADED_RTS)
initMutex(&sig_mutex);
#endif
}
@@ -95,7 +95,7 @@ freeSignalHandlers(void) {
nHandlers = 0;
n_haskell_handlers = 0;
}
-#ifdef THREADED_RTS
+#if defined(THREADED_RTS)
closeMutex(&sig_mutex);
#endif
}
@@ -637,7 +637,7 @@ install_vtalrm_handler(int sig, TickProc handle_tick)
sigemptyset(&action.sa_mask);
-#ifdef SA_RESTART
+#if defined(SA_RESTART)
// specify SA_RESTART. One consequence if we don't do this is
// that readline gets confused by the -threaded RTS. It seems
// that if a SIGALRM handler is installed without SA_RESTART,
@@ -706,7 +706,7 @@ initDefaultHandlers(void)
}
#endif
-#ifdef alpha_HOST_ARCH
+#if defined(alpha_HOST_ARCH)
ieee_set_fp_control(0);
#endif
diff --git a/rts/posix/Signals.h b/rts/posix/Signals.h
index 0fe8c486a7..208c773a04 100644
--- a/rts/posix/Signals.h
+++ b/rts/posix/Signals.h
@@ -8,7 +8,7 @@
#pragma once
-#ifdef HAVE_SIGNAL_H
+#if defined(HAVE_SIGNAL_H)
# include <signal.h>
#endif
diff --git a/rts/posix/TTY.c b/rts/posix/TTY.c
index 2ce822a99a..88fca28306 100644
--- a/rts/posix/TTY.c
+++ b/rts/posix/TTY.c
@@ -12,10 +12,10 @@
#include "RtsUtils.h" // __hscore_get/set prototypes
#include "TTY.h"
-#ifdef HAVE_TERMIOS_H
+#if defined(HAVE_TERMIOS_H)
#include <termios.h>
#endif
-#ifdef HAVE_SIGNAL_H
+#if defined(HAVE_SIGNAL_H)
#include <signal.h>
#endif
diff --git a/rts/posix/itimer/Pthread.c b/rts/posix/itimer/Pthread.c
index 5c708ecf4d..a4f55527dd 100644
--- a/rts/posix/itimer/Pthread.c
+++ b/rts/posix/itimer/Pthread.c
@@ -44,18 +44,18 @@
#include "posix/Clock.h"
/* As recommended in the autoconf manual */
-# ifdef TIME_WITH_SYS_TIME
+# if defined(TIME_WITH_SYS_TIME)
# include <sys/time.h>
# include <time.h>
# else
-# ifdef HAVE_SYS_TIME_H
+# if defined(HAVE_SYS_TIME_H)
# include <sys/time.h>
# else
# include <time.h>
# endif
# endif
-#ifdef HAVE_SIGNAL_H
+#if defined(HAVE_SIGNAL_H)
# include <signal.h>
#endif
@@ -65,7 +65,7 @@
#include <unistd.h>
#include <fcntl.h>
-#ifdef HAVE_SYS_TIMERFD_H
+#if defined(HAVE_SYS_TIMERFD_H)
#include <sys/timerfd.h>
#define USE_TIMERFD_FOR_ITIMER 1
#else
@@ -76,7 +76,7 @@
* TFD_CLOEXEC has been added in Linux 2.6.26.
* If it is not available, we use fcntl(F_SETFD).
*/
-#ifndef TFD_CLOEXEC
+#if !defined(TFD_CLOEXEC)
#define TFD_CLOEXEC 0
#endif
@@ -169,7 +169,7 @@ initTicker (Time interval, TickProc handle_tick)
* to the thread we create so we can later join to it if requested
*/
if (! pthread_create(&thread, NULL, itimer_thread_func, (void*)handle_tick)) {
-#ifdef HAVE_PTHREAD_SETNAME_NP
+#if defined(HAVE_PTHREAD_SETNAME_NP)
pthread_setname_np(thread, "ghc_ticker");
#endif
} else {
diff --git a/rts/posix/itimer/Setitimer.c b/rts/posix/itimer/Setitimer.c
index bdf537d478..1221a72a83 100644
--- a/rts/posix/itimer/Setitimer.c
+++ b/rts/posix/itimer/Setitimer.c
@@ -16,18 +16,18 @@
#include "posix/Signals.h"
/* As recommended in the autoconf manual */
-# ifdef TIME_WITH_SYS_TIME
+# if defined(TIME_WITH_SYS_TIME)
# include <sys/time.h>
# include <time.h>
# else
-# ifdef HAVE_SYS_TIME_H
+# if defined(HAVE_SYS_TIME_H)
# include <sys/time.h>
# else
# include <time.h>
# endif
# endif
-#ifdef HAVE_SIGNAL_H
+#if defined(HAVE_SIGNAL_H)
# include <signal.h>
#endif
diff --git a/rts/posix/itimer/TimerCreate.c b/rts/posix/itimer/TimerCreate.c
index bee3108d38..43081d8a30 100644
--- a/rts/posix/itimer/TimerCreate.c
+++ b/rts/posix/itimer/TimerCreate.c
@@ -15,7 +15,7 @@
#include "posix/Clock.h"
#include "posix/Signals.h"
-#ifdef HAVE_SIGNAL_H
+#if defined(HAVE_SIGNAL_H)
# include <signal.h>
#endif