Use a macro WUT_LIB_HEADER_{START,END}...

So we don't have to extern C and pragma pack in every header file.
This commit is contained in:
James Benton 2016-01-07 05:02:17 -08:00
parent f3241113f5
commit 2e776838ff
22 changed files with 65 additions and 126 deletions

View File

@ -4,9 +4,7 @@
#include "threadqueue.h"
#include "time.h"
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
typedef struct OSAlarm OSAlarm;
typedef struct OSAlarmLink OSAlarmLink;
@ -127,6 +125,4 @@ OSSetAlarmUserData(OSAlarm *alarm,
BOOL
OSWaitAlarm(OSAlarm *alarm);
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -1,9 +1,7 @@
#pragma once
#include <wut.h>
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
uint64_t
OSGetAtomic64(uint64_t *ptr);
@ -51,6 +49,4 @@ BOOL
OSTestAndSetAtomic64(uint64_t *ptr,
uint32_t bit);
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -1,9 +1,7 @@
#pragma once
#include <wut.h>
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
void
DCInvalidateRange(void *addr,
@ -33,6 +31,4 @@ void
DCTouchRange(void *addr,
uint32_t size);
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -2,9 +2,7 @@
#include <wut.h>
#include "threadqueue.h"
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
typedef struct OSCondition OSCondition;
typedef struct OSMutex OSMutex;
@ -43,6 +41,4 @@ OSWaitCond(OSCondition *condition,
void
OSSignalCond(OSCondition *condition);
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -1,9 +1,7 @@
#pragma once
#include <wut.h>
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
uint32_t
OSGetCoreCount();
@ -17,6 +15,4 @@ OSGetMainCoreId();
BOOL
OSIsMainCore();
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -1,9 +1,7 @@
#pragma once
#include <wut.h>
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
void
OSConsoleWrite(const char *msg,
@ -20,6 +18,4 @@ OSPanic(const char *file,
void
OSFatal(const char *msg);
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -3,9 +3,7 @@
#include "thread.h"
#include "time.h"
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
typedef void *OSDynLoadModule;
@ -33,6 +31,4 @@ OSDynLoad_FindExport(OSDynLoadModule module,
void
OSDynLoad_Release(OSDynLoadModule module);
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -3,9 +3,7 @@
#include "thread.h"
#include "threadqueue.h"
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
typedef struct OSEvent OSEvent;
typedef uint32_t OSEventMode;
@ -63,6 +61,4 @@ BOOL
OSWaitEventWithTimeout(OSEvent *event,
OSTime timeout);
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -1,9 +1,7 @@
#pragma once
#include <wut.h>
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
typedef uint32_t OSExceptionType;
typedef BOOL (*OSExceptionCallbackFn)(OSContext *context);
@ -36,6 +34,4 @@ OSSetExceptionCallbackEx(UNKNOWN_ARG,
OSExceptionType exceptionType,
OSExceptionCallbackFn callback);
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -1,9 +1,7 @@
#pragma once
#include <wut.h>
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
void
exit(int code);
@ -11,6 +9,4 @@ exit(int code);
void
_Exit();
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -2,9 +2,7 @@
#include <wut.h>
#include "threadqueue.h"
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
typedef struct OSFastCondition OSFastCondition;
typedef struct OSFastMutex OSFastMutex;
@ -34,6 +32,4 @@ OSFastCond_Wait(OSFastCondition *condition,
void
OSFastCond_Signal(OSFastCondition *condition);
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -2,9 +2,7 @@
#include <wut.h>
#include "threadqueue.h"
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
typedef struct OSFastMutex OSFastMutex;
typedef struct OSFastMutexLink OSFastMutexLink;
@ -48,6 +46,4 @@ OSFastMutex_Unlock(OSFastMutex *mutex);
BOOL
OSFastMutex_TryLock(OSFastMutex *mutex);
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -1,9 +1,7 @@
#pragma once
#include <wut.h>
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
typedef struct MEMExpandedHeap MEMExpandedHeap;
@ -84,6 +82,4 @@ MEMGetGroupIDForMBlockExpHeap(uint8_t *addr);
MEMExpHeapDirection
MEMGetAllocDirForMBlockExpHeap(uint8_t *addr);
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -2,9 +2,7 @@
#include <wut.h>
#include "threadqueue.h"
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
typedef struct OSThread;
@ -68,6 +66,4 @@ OSUnlockMutex(OSMutex *mutex);
BOOL
OSTryLockMutex(OSMutex *mutex);
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -1,9 +1,7 @@
#pragma once
#include <wut.h>
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
typedef struct OSRendezvous OSRendezvous;
@ -29,6 +27,4 @@ OSWaitRendezvousWithTimeout(OSRendezvous *rendezvous,
uint32_t coreMask,
OSTime timeout);
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -2,9 +2,7 @@
#include <wut.h>
#include "threadqueue.h"
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
typedef struct OSSemaphore OSSemaphore;
@ -45,6 +43,4 @@ OSWaitSemaphore(OSSemaphore *semaphore);
int32_t
OSTryWaitSemaphore(OSSemaphore *semaphore);
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -2,9 +2,7 @@
#include <wut.h>
#include "time.h"
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
typedef struct OSSpinLock OSSpinLock;
@ -50,6 +48,4 @@ OSUninterruptibleSpinLock_TryAcquireWithTimeout(OSSpinLock *spinlock,
BOOL
OSUninterruptibleSpinLock_Release(OSSpinLock *spinlock);
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -3,9 +3,7 @@
#include "time.h"
#include "threadqueue.h"
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
typedef struct OSContext OSContext;
typedef struct OSFastMutex OSFastMutex;
@ -321,6 +319,4 @@ OSWakeupThread(OSThreadQueue *queue);
void
OSYieldThread();
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -1,9 +1,7 @@
#pragma once
#include <wut.h>
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
typedef struct OSThread OSThread;
@ -48,6 +46,4 @@ void
OSInitThreadQueueEx(OSThreadQueue *queue,
void *parent);
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -1,9 +1,7 @@
#pragma once
#include <wut.h>
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
typedef struct OSCalendarTime OSCalendarTime;
@ -46,6 +44,4 @@ void
OSTicksToCalendarTime(OSTime time,
OSCalendarTime *calendarTime);
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -1,8 +1,9 @@
#pragma once
#include <wut.h>
#ifdef __cplusplus
extern "C" {
#endif
WUT_LIB_HEADER_START
typedef uint32_t GX2InitAttributes;
enum GX2InitAttributes
{
@ -19,6 +20,4 @@ GX2Init(uint32_t *attributes);
void
GX2Shutdown();
#ifdef __cplusplus
}
#endif
WUT_LIB_HEADER_END

View File

@ -1,3 +1,23 @@
#pragma once
#include "wut_structsize.h"
#include "wut_types.h"
#ifdef __cplusplus
#define WUT_LIB_HEADER_START \
extern "C" { \
_Pragma("pack(push, 1)")
#define WUT_LIB_HEADER_END \
_Pragma("pack(pop)") \
}
#else
#define WUT_LIB_HEADER_START \
_Pragma("pack(push, 1)")
#define WUT_LIB_HEADER_END \
_Pragma("pack(pop)")
#endif