diff --git a/include/coreinit/alarm.h b/include/coreinit/alarm.h index efdeaa8..cd600bc 100644 --- a/include/coreinit/alarm.h +++ b/include/coreinit/alarm.h @@ -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 diff --git a/include/coreinit/atomic64.h b/include/coreinit/atomic64.h index 47c8ef4..2eccbc6 100644 --- a/include/coreinit/atomic64.h +++ b/include/coreinit/atomic64.h @@ -1,9 +1,7 @@ #pragma once #include -#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 diff --git a/include/coreinit/cache.h b/include/coreinit/cache.h index 032d768..ff660e0 100644 --- a/include/coreinit/cache.h +++ b/include/coreinit/cache.h @@ -1,9 +1,7 @@ #pragma once #include -#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 diff --git a/include/coreinit/condition.h b/include/coreinit/condition.h index 482e23f..9783ce3 100644 --- a/include/coreinit/condition.h +++ b/include/coreinit/condition.h @@ -2,9 +2,7 @@ #include #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 diff --git a/include/coreinit/core.h b/include/coreinit/core.h index 7dae283..0de551d 100644 --- a/include/coreinit/core.h +++ b/include/coreinit/core.h @@ -1,9 +1,7 @@ #pragma once #include -#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 diff --git a/include/coreinit/debug.h b/include/coreinit/debug.h index ddab4a7..acb6e51 100644 --- a/include/coreinit/debug.h +++ b/include/coreinit/debug.h @@ -1,9 +1,7 @@ #pragma once #include -#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 diff --git a/include/coreinit/dynload.h b/include/coreinit/dynload.h index 6021a6b..8dba5bf 100644 --- a/include/coreinit/dynload.h +++ b/include/coreinit/dynload.h @@ -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 diff --git a/include/coreinit/event.h b/include/coreinit/event.h index b435c62..c7b491d 100644 --- a/include/coreinit/event.h +++ b/include/coreinit/event.h @@ -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 diff --git a/include/coreinit/exception.h b/include/coreinit/exception.h index 21900c6..0fdc758 100644 --- a/include/coreinit/exception.h +++ b/include/coreinit/exception.h @@ -1,9 +1,7 @@ #pragma once #include -#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 diff --git a/include/coreinit/exit.h b/include/coreinit/exit.h index 71c8cd4..67e3bf2 100644 --- a/include/coreinit/exit.h +++ b/include/coreinit/exit.h @@ -1,9 +1,7 @@ #pragma once #include -#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 diff --git a/include/coreinit/fastcondition.h b/include/coreinit/fastcondition.h index b5404ac..b342b95 100644 --- a/include/coreinit/fastcondition.h +++ b/include/coreinit/fastcondition.h @@ -2,9 +2,7 @@ #include #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 diff --git a/include/coreinit/fastmutex.h b/include/coreinit/fastmutex.h index 0fe309a..b866954 100644 --- a/include/coreinit/fastmutex.h +++ b/include/coreinit/fastmutex.h @@ -2,9 +2,7 @@ #include #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 diff --git a/include/coreinit/memexpandedheap.h b/include/coreinit/memexpandedheap.h index 305074d..9c6d47d 100644 --- a/include/coreinit/memexpandedheap.h +++ b/include/coreinit/memexpandedheap.h @@ -1,9 +1,7 @@ #pragma once #include -#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 diff --git a/include/coreinit/mutex.h b/include/coreinit/mutex.h index 5792195..b76f3d3 100644 --- a/include/coreinit/mutex.h +++ b/include/coreinit/mutex.h @@ -2,9 +2,7 @@ #include #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 diff --git a/include/coreinit/rendezvous.h b/include/coreinit/rendezvous.h index 8398aaf..c350309 100644 --- a/include/coreinit/rendezvous.h +++ b/include/coreinit/rendezvous.h @@ -1,9 +1,7 @@ #pragma once #include -#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 diff --git a/include/coreinit/semaphore.h b/include/coreinit/semaphore.h index 10b648a..90323f1 100644 --- a/include/coreinit/semaphore.h +++ b/include/coreinit/semaphore.h @@ -2,9 +2,7 @@ #include #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 diff --git a/include/coreinit/spinlock.h b/include/coreinit/spinlock.h index 051f777..cdcbdd4 100644 --- a/include/coreinit/spinlock.h +++ b/include/coreinit/spinlock.h @@ -2,9 +2,7 @@ #include #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 diff --git a/include/coreinit/thread.h b/include/coreinit/thread.h index fe426b2..6f3632e 100644 --- a/include/coreinit/thread.h +++ b/include/coreinit/thread.h @@ -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 diff --git a/include/coreinit/threadqueue.h b/include/coreinit/threadqueue.h index 02e7053..4db4c29 100644 --- a/include/coreinit/threadqueue.h +++ b/include/coreinit/threadqueue.h @@ -1,9 +1,7 @@ #pragma once #include -#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 diff --git a/include/coreinit/time.h b/include/coreinit/time.h index f906dfa..cc91ec3 100644 --- a/include/coreinit/time.h +++ b/include/coreinit/time.h @@ -1,9 +1,7 @@ #pragma once #include -#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 diff --git a/include/gx2/state.h b/include/gx2/state.h index 6e3047a..58db096 100644 --- a/include/gx2/state.h +++ b/include/gx2/state.h @@ -1,8 +1,9 @@ #pragma once +#include -#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 diff --git a/include/wut.h b/include/wut.h index 7414e25..a56d0fa 100644 --- a/include/wut.h +++ b/include/wut.h @@ -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