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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,3 +1,23 @@
#pragma once #pragma once
#include "wut_structsize.h" #include "wut_structsize.h"
#include "wut_types.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