Commit f13eebcc authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari

cpp: Use #pragma once instead of #ifndef guards

This both says what we mean and silences a bunch of spurious CPP linting
warnings. This pragma is supported by all CPP implementations which we
support.

Reviewers: austin, erikd, simonmar, hvr

Reviewed By: simonmar

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3482
parent 87fbf39a
#ifndef HSVERSIONS_H
#define HSVERSIONS_H
#pragma once
#if 0
......@@ -64,6 +63,3 @@ foreign import ccall unsafe saccessor \
#define ASSERTM(e) do { bool <- e; MASSERT(bool) }
#define ASSERTM2(e,msg) do { bool <- e; MASSERT2(bool,msg) }
#define WARNM2(e,msg) do { bool <- e; WARN(bool, msg) return () }
#endif /* HsVersions.h */
......@@ -6,9 +6,6 @@
-------------------------------------------------------------------------- */
#ifndef NCG_H
#define NCG_H
#pragma once
#include "ghc_boot_platform.h"
#endif
/* MD5 message digest */
#ifndef _MD5_H
#define _MD5_H
#pragma once
#include "HsFFI.h"
......@@ -17,8 +16,3 @@ void MD5Init(struct MD5Context *context);
void MD5Update(struct MD5Context *context, byte const *buf, int len);
void MD5Final(byte digest[16], struct MD5Context *context);
void MD5Transform(word32 buf[4], word32 const in[16]);
#endif /* _MD5_H */
#ifndef ISMINTTY_H
#define ISMINTTY_H
#pragma once
#include <stdbool.h>
bool isMinTTY();
#endif /* ISMINTTY_H */
......@@ -25,8 +25,7 @@
*
* -------------------------------------------------------------------------- */
#ifndef CMM_H
#define CMM_H
#pragma once
/*
* In files that are included into both C and C-- (and perhaps
......@@ -942,5 +941,3 @@
} \
\
return (dst);
#endif /* CMM_H */
......@@ -9,8 +9,7 @@
*
* ---------------------------------------------------------------------------*/
#ifndef HSFFI_H
#define HSFFI_H
#pragma once
#ifdef __cplusplus
extern "C" {
......@@ -122,5 +121,3 @@ extern void hs_try_putmvar (int capability, HsStablePtr sp);
#ifdef __cplusplus
}
#endif
#endif /* HSFFI_H */
......@@ -13,8 +13,7 @@
*
* ---------------------------------------------------------------------------*/
#ifndef MACHDEPS_H
#define MACHDEPS_H
#pragma once
/* Don't allow stage1 (cross-)compiler embed assumptions about target
* platform. When ghc-stage1 is being built by ghc-stage0 is should not
......@@ -122,5 +121,3 @@
#define TAG_MASK ((1 << TAG_BITS) - 1)
#endif /* !defined(STAGE) || STAGE >= 2 */
#endif /* MACHDEPS_H */
......@@ -10,8 +10,7 @@
*
* ---------------------------------------------------------------------------*/
#ifndef RTS_H
#define RTS_H
#pragma once
#ifdef __cplusplus
extern "C" {
......@@ -313,5 +312,3 @@ TICK_VAR(2)
#ifdef __cplusplus
}
#endif
#endif /* RTS_H */
......@@ -9,8 +9,7 @@
*
* --------------------------------------------------------------------------*/
#ifndef RTSAPI_H
#define RTSAPI_H
#pragma once
#ifdef __cplusplus
extern "C" {
......@@ -445,5 +444,3 @@ extern StgWord base_GHCziTopHandler_runNonIO_closure[];
#ifdef __cplusplus
}
#endif
#endif /* RTSAPI_H */
......@@ -23,8 +23,7 @@
*
* ---------------------------------------------------------------------------*/
#ifndef STG_H
#define STG_H
#pragma once
#if !(__STDC_VERSION__ >= 199901L)
# error __STDC_VERSION__ does not advertise C99 or later
......@@ -567,5 +566,3 @@ typedef union {
c; \
})
#endif
#endif /* STG_H */
#ifndef __GHCCONFIG_H__
#define __GHCCONFIG_H__
#pragma once
#include "ghcautoconf.h"
#include "ghcplatform.h"
#endif
......@@ -11,8 +11,7 @@
*
* -------------------------------------------------------------------------- */
#ifndef RTS_ADJUSTOR_H
#define RTS_ADJUSTOR_H
#pragma once
/* Creating and destroying an adjustor thunk */
void* createAdjustor (int cconv,
......@@ -21,5 +20,3 @@ void* createAdjustor (int cconv,
char *typeString);
void freeHaskellFunctionPtr (void* ptr);
#endif /* RTS_ADJUSTOR_H */
......@@ -11,8 +11,7 @@
*
* ---------------------------------------------------------------------------*/
#ifndef RTS_BLOCKSIGNALS_H
#define RTS_BLOCKSIGNALS_H
#pragma once
/* Used by runProcess() in the process package
*/
......@@ -33,5 +32,3 @@ void blockUserSignals(void);
* The inverse of blockUserSignals(); re-enable the deliver of console events.
*/
void unblockUserSignals(void);
#endif /* RTS_BLOCKSIGNALS_H */
......@@ -13,8 +13,7 @@
*
* ---------------------------------------------------------------------------*/
#ifndef RTS_CONFIG_H
#define RTS_CONFIG_H
#pragma once
#if defined(TICKY_TICKY) && defined(THREADED_RTS)
#error TICKY_TICKY is incompatible with THREADED_RTS
......@@ -47,5 +46,3 @@
/* Profile spin locks */
#define PROF_SPIN
#endif /* RTS_CONFIG_H */
......@@ -17,8 +17,7 @@
*
* -------------------------------------------------------------------------- */
#ifndef RTS_CONSTANTS_H
#define RTS_CONSTANTS_H
#pragma once
/* -----------------------------------------------------------------------------
Minimum closure sizes
......@@ -314,5 +313,3 @@
* we can have static arrays of this size in the RTS for speed.
*/
#define MAX_NUMA_NODES 16
#endif /* RTS_CONSTANTS_H */
......@@ -73,8 +73,7 @@
*
* -------------------------------------------------------------------------- */
#ifndef RTS_EVENTLOGFORMAT_H
#define RTS_EVENTLOGFORMAT_H
#pragma once
/*
* Markers for begin/end of the Header.
......@@ -245,5 +244,3 @@ typedef StgWord64 EventTaskId; /* for EVENT_TASK_* */
typedef StgWord64 EventKernelThreadId; /* for EVENT_TASK_CREATE */
#endif
#endif /* RTS_EVENTLOGFORMAT_H */
......@@ -6,8 +6,7 @@
*
* ---------------------------------------------------------------------------*/
#ifndef EVENTLOG_WRITER_H
#define EVENTLOG_WRITER_H
#pragma once
#include <stddef.h>
#include <stdbool.h>
......@@ -36,5 +35,3 @@ typedef struct {
* a file `program.eventlog`.
*/
extern const EventLogWriter FileEventLogWriter;
#endif /* EVENTLOG_WRITER_H */
......@@ -11,12 +11,9 @@
*
* ---------------------------------------------------------------------------*/
#ifndef RTS_FILELOCK_H
#define RTS_FILELOCK_H
#pragma once
#include "Stg.h"
int lockFile(int fd, StgWord64 dev, StgWord64 ino, int for_writing);
int unlockFile(int fd);
#endif /* RTS_FILELOCK_H */
......@@ -11,8 +11,7 @@
*
* ---------------------------------------------------------------------------*/
#ifndef RTS_FLAGS_H
#define RTS_FLAGS_H
#pragma once
#include <stdio.h>
#include <stdint.h>
......@@ -282,5 +281,3 @@ extern char **prog_argv;
*/
extern int rts_argc; /* ditto */
extern char **rts_argv;
#endif /* RTS_FLAGS_H */
......@@ -11,9 +11,6 @@
*
* ---------------------------------------------------------------------------*/
#ifndef RTS_GETTIME_H
#define RTS_GETTIME_H
#pragma once
StgWord64 getMonotonicNSec (void);
#endif /* RTS_GETTIME_H */
......@@ -14,8 +14,7 @@
*
* ---------------------------------------------------------------------------*/
#ifndef RTS_GLOBALS_H
#define RTS_GLOBALS_H
#pragma once
#define mkStoreAccessorPrototype(name) \
StgStablePtr \
......@@ -35,5 +34,3 @@ mkStoreAccessorPrototype(LibHSghcInitLinkerDone)
mkStoreAccessorPrototype(LibHSghcGlobalDynFlags)
mkStoreAccessorPrototype(LibHSghcStaticOptions)
mkStoreAccessorPrototype(LibHSghcStaticOptionsReady)
#endif /* RTS_GLOBALS_H */
......@@ -11,8 +11,7 @@
*
* -------------------------------------------------------------------------- */
#ifndef RTS_HPC_H
#define RTS_HPC_H
#pragma once
// Simple linked list of modules
typedef struct _HpcModuleInfo {
......@@ -33,5 +32,3 @@ HpcModuleInfo * hs_hpc_rootModule (void);
void startupHpc(void);
void exitHpc(void);
#endif /* RTS_HPC_H */
......@@ -11,8 +11,7 @@
*
* -------------------------------------------------------------------------- */
#ifndef RTS_IOMANAGER_H
#define RTS_IOMANAGER_H
#pragma once
#if defined(mingw32_HOST_OS)
......@@ -42,5 +41,3 @@ void ioManagerWakeup (void);
void ioManagerDie (void);
void ioManagerStart (void);
#endif
#endif /* RTS_IOMANAGER_H */
......@@ -6,10 +6,7 @@
*
* --------------------------------------------------------------------------*/
#include "Rts.h"
#ifndef RTS_LIBDW_H
#define RTS_LIBDW_H
#pragma once
// Chunk capacity
// This is rather arbitrary
......@@ -92,5 +89,3 @@ Backtrace *libdwGetBacktrace(LibdwSession *session);
/* Lookup Location information for the given address.
* Returns 0 if successful, 1 if address could not be found. */
int libdwLookupLocation(LibdwSession *session, Location *loc, StgPtr pc);
#endif /* RTS_LIBDW_H */
......@@ -6,8 +6,7 @@
*
* --------------------------------------------------------------------------*/
#ifndef RTS_LIBDW_POOL_H
#define RTS_LIBDW_POOL_H
#pragma once
/* Claim a session from the pool */
LibdwSession *libdwPoolTake(void);
......@@ -18,5 +17,3 @@ void libdwPoolRelease(LibdwSession *sess);
/* Free any sessions in the pool forcing a reload of any loaded debug
* information */
void libdwPoolClear(void);
#endif /* RTS_LIBDW_POOL_H */
......@@ -11,8 +11,7 @@
*
* ---------------------------------------------------------------------------*/
#ifndef RTS_LINKER_H
#define RTS_LINKER_H
#pragma once
#if defined(mingw32_HOST_OS)
typedef wchar_t pathchar;
......@@ -86,5 +85,3 @@ pathchar* findSystemLibrary(pathchar* dll_name);
/* called by the initialization code for a module, not a user API */
StgStablePtr foreignExportStablePtr (StgPtr p);
#endif /* RTS_LINKER_H */
......@@ -6,8 +6,7 @@
*
* ---------------------------------------------------------------------------*/
#ifndef RTSMAIN_H
#define RTSMAIN_H
#pragma once
/* -----------------------------------------------------------------------------
* The entry point for Haskell programs that use a Haskell main function
......@@ -17,5 +16,3 @@ int hs_main (int argc, char *argv[], // program args
StgClosure *main_closure, // closure for Main.main
RtsConfig rts_config) // RTS configuration
GNUC3_ATTRIBUTE(__noreturn__);
#endif /* RTSMAIN_H */
......@@ -14,8 +14,7 @@
*
* ---------------------------------------------------------------------------*/
#ifndef RTS_MESSAGES_H
#define RTS_MESSAGES_H
#pragma once
#include <stdarg.h>
......@@ -102,5 +101,3 @@ extern RtsMsgFunction rtsFatalInternalErrorFn;
extern RtsMsgFunction rtsDebugMsgFn;
extern RtsMsgFunction rtsErrorMsgFn;
extern RtsMsgFunction rtsSysErrorMsgFn;
#endif /* RTS_MESSAGES_H */
......@@ -12,8 +12,7 @@
*
* --------------------------------------------------------------------------*/
#ifndef RTS_OSTHREADS_H
#define RTS_OSTHREADS_H
#pragma once
#if defined(HAVE_PTHREAD_H) && !defined(mingw32_HOST_OS)
......@@ -257,5 +256,3 @@ typedef StgWord64 KernelThreadId;
KernelThreadId kernelThreadId (void);
#endif /* CMINUSMINUS */
#endif /* RTS_OSTHREADS_H */
......@@ -11,9 +11,6 @@
*
* -------------------------------------------------------------------------- */
#ifndef RTS_PARALLEL_H
#define RTS_PARALLEL_H
#pragma once
StgInt newSpark (StgRegTable *reg, StgClosure *p);
#endif /* RTS_PARALLEL_H */
......@@ -9,12 +9,9 @@
*
* ---------------------------------------------------------------------------*/
#ifndef RTS_PRIMFLOAT_H
#define RTS_PRIMFLOAT_H
#pragma once
StgDouble __int_encodeDouble (I_ j, I_ e);
StgFloat __int_encodeFloat (I_ j, I_ e);
StgDouble __word_encodeDouble (W_ j, I_ e);
StgFloat __word_encodeFloat (W_ j, I_ e);
#endif /* RTS_PRIMFLOAT_H */
......@@ -11,8 +11,7 @@
*
* ---------------------------------------------------------------------------*/
#ifndef RTS_SIGNALS_H
#define RTS_SIGNALS_H
#pragma once
/* NB. #included in Haskell code, no prototypes in here. */
......@@ -22,5 +21,3 @@
#define STG_SIG_ERR (-3)
#define STG_SIG_HAN (-4)
#define STG_SIG_RST (-5)
#endif /* RTS_SIGNALS_H */
......@@ -19,9 +19,8 @@
*
* -------------------------------------------------------------------------- */
#ifndef RTS_SPINLOCK_H
#define RTS_SPINLOCK_H
#pragma once
#if defined(THREADED_RTS)
#if defined(PROF_SPIN)
......@@ -112,6 +111,3 @@ INLINE_HEADER void initSpinLock(void * p STG_UNUSED)
{ /* nothing */ }
#endif /* THREADED_RTS */
#endif /* RTS_SPINLOCK_H */
......@@ -11,8 +11,7 @@
*
* ---------------------------------------------------------------------------*/
#ifndef RTS_STABLE_H
#define RTS_STABLE_H
#pragma once
EXTERN_INLINE StgPtr deRefStablePtr (StgStablePtr stable_ptr);
StgStablePtr getStablePtr (StgPtr p);
......@@ -39,5 +38,3 @@ StgPtr deRefStablePtr(StgStablePtr sp)
{
return stable_ptr_table[(StgWord)sp].addr;
}
#endif /* RTS_STABLE_H */
......@@ -11,8 +11,7 @@
*
* -------------------------------------------------------------------------- */
#ifndef RTS_STATICPTRTABLE_H
#define RTS_STATICPTRTABLE_H
#pragma once
/** Inserts an entry in the Static Pointer Table.
*
......@@ -43,5 +42,3 @@ void hs_spt_insert_stableptr(StgWord64 key[2], StgStablePtr *entry);
*
* */
void hs_spt_remove (StgWord64 key[2]);
#endif /* RTS_STATICPTRTABLE_H */
......@@ -11,10 +11,7 @@
*
* -------------------------------------------------------------------------- */
#ifndef RTS_TTY_H
#define RTS_TTY_H
#pragma once
void* __hscore_get_saved_termios(int fd);
void __hscore_set_saved_termios(int fd, void* ts);
#endif /* RTS_TTY_H */
......@@ -12,8 +12,7 @@
*
* ---------------------------------------------------------------------------*/
#ifndef RTS_THREADS_H
#define RTS_THREADS_H
#pragma once
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
......@@ -75,5 +74,3 @@ extern Capability MainCapability;
// current value at the moment).
//
extern void setNumCapabilities (uint32_t new_);
#endif /* RTS_THREADS_H */
......@@ -11,8 +11,7 @@
*
* ---------------------------------------------------------------------------*/
#ifndef RTS_TICKY_H
#define RTS_TICKY_H
#pragma once
/* -----------------------------------------------------------------------------
The StgEntCounter type - needed regardless of TICKY_TICKY
......@@ -31,5 +30,3 @@ typedef struct _StgEntCounter {
StgInt allocs; /* number of allocations by this fun */
struct _StgEntCounter *link;/* link to chain them all together */
} StgEntCounter;
#endif /* RTS_TICKY_H */
......@@ -9,8 +9,7 @@
*
* --------------------------------------------------------------------------*/
#ifndef RTSTIME_H
#define RTSTIME_H
#pragma once
// For most time values in the RTS we use a fixed resolution of nanoseconds,
// normalising the time we get from platform-dependent APIs to this
......@@ -39,5 +38,3 @@ INLINE_HEADER Time fsecondsToTime (double t)
{
return (Time)(t * TIME_RESOLUTION);
}
#endif // RTSTIME_H
......@@ -11,11 +11,8 @@
*
* ---------------------------------------------------------------------------*/
#ifndef RTS_TIMER_H
#define RTS_TIMER_H
#pragma once
void startTimer (void);
void stopTimer (void);
int rtsTimerSignal (void);
#endif /* RTS_TIMER_H */
......@@ -11,8 +11,7 @@
*
* ---------------------------------------------------------------------------*/
#ifndef RTS_TYPES_H
#define RTS_TYPES_H
#pragma once
#include <stddef.h>
#include <stdbool.h>
......@@ -30,5 +29,3 @@ typedef unsigned int nat __attribute__((deprecated)); /* uint32_t */