From a9e49239bb90fdd03a1c785d210421a6df804825 Mon Sep 17 00:00:00 2001 From: capitalistspz Date: Mon, 18 Aug 2025 14:22:46 +0100 Subject: [PATCH 1/3] Add `WUT_ACCESS` and `WUT_ACCESS_SIZED` attribute macros --- include/wut.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/wut.h b/include/wut.h index c280cc11..8544a1ec 100644 --- a/include/wut.h +++ b/include/wut.h @@ -10,12 +10,14 @@ #define WUT_DEPRECATED(reason) __attribute__((__deprecated__(reason))) #define WUT_FORMAT_PRINTF(fmt, args) __attribute__((__format__(__printf__, fmt, args))) - +#define WUT_ACCESS(access_type, ptr_index) __attribute__ ((__access__(access_type, ptr_index))) +#define WUT_ACCESS_SIZED(access_type, ptr_index, size_index) __attribute__ ((__access__(access_type, ptr_index, size_index))) #else // not __GNUC__ and not __clang__ #define WUT_DEPRECATED(reason) #define WUT_FORMAT_PRINTF(fmt, args) - +#define WUT_ACCESS(access_type, ptr_index) +#define WUT_ACCESS_SIZED(access_type, ptr_index, size_index) #endif //__GNUC__ or __clang__ #ifdef DEBUG From 71371d3fbbaaabbc6d72495a3ae8f3d4a13c78e5 Mon Sep 17 00:00:00 2001 From: capitalistspz Date: Thu, 4 Sep 2025 16:41:11 +0100 Subject: [PATCH 2/3] Remove `WUT_ACCESS`, rename `WUT_ACCESS_SIZED` to `WUT_SIZED_ACCESS`. `WUT_ACCESS` was of limited usefulness --- include/wut.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/wut.h b/include/wut.h index 8544a1ec..674faa12 100644 --- a/include/wut.h +++ b/include/wut.h @@ -10,14 +10,12 @@ #define WUT_DEPRECATED(reason) __attribute__((__deprecated__(reason))) #define WUT_FORMAT_PRINTF(fmt, args) __attribute__((__format__(__printf__, fmt, args))) -#define WUT_ACCESS(access_type, ptr_index) __attribute__ ((__access__(access_type, ptr_index))) -#define WUT_ACCESS_SIZED(access_type, ptr_index, size_index) __attribute__ ((__access__(access_type, ptr_index, size_index))) +#define WUT_SIZED_ACCESS(access_type, ptr_index, size_index) __attribute__ ((__access__(access_type, ptr_index, size_index))) #else // not __GNUC__ and not __clang__ #define WUT_DEPRECATED(reason) #define WUT_FORMAT_PRINTF(fmt, args) -#define WUT_ACCESS(access_type, ptr_index) -#define WUT_ACCESS_SIZED(access_type, ptr_index, size_index) +#define WUT_SIZED_ACCESS(access_type, ptr_index, size_index) #endif //__GNUC__ or __clang__ #ifdef DEBUG From 5f7ff6ae20037b3ad8af859f47f799f6d883fa61 Mon Sep 17 00:00:00 2001 From: capitalistspz Date: Thu, 4 Sep 2025 16:53:23 +0100 Subject: [PATCH 3/3] Apply `WUT_SIZED_ACCESS` to wpad.h --- include/padscore/wpad.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/include/padscore/wpad.h b/include/padscore/wpad.h index 31263b9b..4633a9ab 100644 --- a/include/padscore/wpad.h +++ b/include/padscore/wpad.h @@ -903,7 +903,7 @@ WPADCanSendStreamData(WPADChan channel); WPADError WPADSendStreamData(WPADChan channel, const void *data, - uint32_t size); + uint32_t size) WUT_SIZED_ACCESS(read_only, 2, 3); /** * Encode 16-bit LPCM as 4-bit Yamaha ADPCM @@ -921,7 +921,7 @@ WENCGetEncodeData(WENCParams *params, BOOL continuing, const int16_t *samples, uint32_t sampleCount, - uint8_t *outEncodedData); + uint8_t *outEncodedData) WUT_SIZED_ACCESS(read_only, 3, 4); /** * Returns the global Wii Remote speaker volume @@ -989,7 +989,7 @@ WPADReadMemoryAsync(WPADChan channel, void *destination, uint16_t size, uint32_t address, - WPADCallback callback); + WPADCallback callback) WUT_SIZED_ACCESS(write_only, 2, 3); /** * Writes to the device's memory @@ -1005,10 +1005,10 @@ WPADReadMemoryAsync(WPADChan channel, */ WPADError WPADWriteMemoryAsync(WPADChan channel, - void *source, + const void *source, uint32_t size, uint32_t address, - WPADCallback callback); + WPADCallback callback) WUT_SIZED_ACCESS(read_only, 2, 3); /** * Reads from the registers of the Wii Remote's peripherals @@ -1023,7 +1023,7 @@ WPADReadExtReg(WPADChan channel, uint16_t size, WPADPeripheralSpace peripheral, uint32_t address, - WPADCallback callback); + WPADCallback callback) WUT_SIZED_ACCESS(write_only, 2, 3); /** * Writes to the registers of the Wii Remote's peripherals @@ -1046,7 +1046,7 @@ WPADWriteExtReg(WPADChan channel, uint32_t size, WPADPeripheralSpace peripheral, uint32_t address, - WPADCallback callback); + WPADCallback callback) WUT_SIZED_ACCESS(read_only, 2, 3); /** * Read Balance Board calibration. @@ -1059,7 +1059,7 @@ WPADGetBLCalibration(WPADChan channel, void *destination, uint32_t address, uint32_t size, - WPADCallback callback); + WPADCallback callback) WUT_SIZED_ACCESS(write_only, 2, 4); /** * Sets power save mode, this makes the controller only report input data @@ -1324,8 +1324,8 @@ WPADiSendMuteSpeaker(WPADiQueue *cmdQueue, */ BOOL WPADiSendStreamData(WPADiQueue *cmdQueue, - void *source, - uint32_t size); + const void *source, + uint32_t size) WUT_SIZED_ACCESS(read_only, 2, 3); /** * Queues HID Report for a single-byte memory write @@ -1344,10 +1344,10 @@ WPADiSendWriteDataCmd(WPADiQueue *cmdQueue, */ BOOL WPADiSendWriteData(WPADiQueue *cmdQueue, - void *source, + const void *source, uint32_t size, uint32_t address, - WPADCallback callback); + WPADCallback callback) WUT_SIZED_ACCESS(read_only, 2, 3); /** * Queues HID Report for a memory read @@ -1359,7 +1359,7 @@ WPADiSendReadData(WPADiQueue *cmdQueue, void *destination, uint16_t size, uint32_t address, - WPADCallback callback); + WPADCallback callback) WUT_SIZED_ACCESS(write_only, 2, 3); /** * Game code (identifier), which may be saved to the EEPROM of connected controllers @@ -1428,7 +1428,7 @@ WPADiWriteGameData(WPADChan channel, const void *source, uint16_t size, uint32_t offset, - WPADCallback callback); + WPADCallback callback) WUT_SIZED_ACCESS(read_only, 2, 3); /** * Read custom game data from the controller's EEPROM @@ -1446,7 +1446,7 @@ WPADiReadGameData(WPADChan channel, void *destination, uint16_t size, uint32_t offset, - WPADCallback callback); + WPADCallback callback) WUT_SIZED_ACCESS(read_only, 2, 3); /** * Get MotionPlus mode