diff --git a/libctru/Doxyfile b/libctru/Doxyfile index c686766..197fb4c 100644 --- a/libctru/Doxyfile +++ b/libctru/Doxyfile @@ -2023,7 +2023,7 @@ INCLUDE_FILE_PATTERNS = # recursively expanded use the := operator instead of the = operator. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. -PREDEFINED = PACKED +PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The diff --git a/libctru/include/3ds/allocator/vram.h b/libctru/include/3ds/allocator/vram.h index a1e593a..c649280 100644 --- a/libctru/include/3ds/allocator/vram.h +++ b/libctru/include/3ds/allocator/vram.h @@ -6,8 +6,8 @@ typedef enum vramAllocPos { - VRAM_ALLOC_A = BIT(0), - VRAM_ALLOC_B = BIT(1), + VRAM_ALLOC_A = 1U << 0, + VRAM_ALLOC_B = 1U << 1, VRAM_ALLOC_ANY = VRAM_ALLOC_A | VRAM_ALLOC_B, } vramAllocPos; diff --git a/libctru/include/3ds/applets/miiselector.h b/libctru/include/3ds/applets/miiselector.h index 438465e..05a2c98 100644 --- a/libctru/include/3ds/applets/miiselector.h +++ b/libctru/include/3ds/applets/miiselector.h @@ -73,10 +73,10 @@ typedef struct /// AppletEd options enum { - MIISELECTOR_CANCEL = BIT(0), ///< Show the cancel button - MIISELECTOR_GUESTS = BIT(1), ///< Make Guets Miis selectable - MIISELECTOR_TOP = BIT(2), ///< Show AppletEd on top screen - MIISELECTOR_GUESTSTART = BIT(3), ///< Start on guest page + MIISELECTOR_CANCEL = 1U << 0, ///< Show the cancel button + MIISELECTOR_GUESTS = 1U << 1, ///< Make Guets Miis selectable + MIISELECTOR_TOP = 1U << 2, ///< Show AppletEd on top screen + MIISELECTOR_GUESTSTART = 1U << 3, ///< Start on guest page }; /** diff --git a/libctru/include/3ds/applets/swkbd.h b/libctru/include/3ds/applets/swkbd.h index 1b205a9..aef869e 100644 --- a/libctru/include/3ds/applets/swkbd.h +++ b/libctru/include/3ds/applets/swkbd.h @@ -46,26 +46,26 @@ typedef enum /// Keyboard input filtering flags. enum { - SWKBD_FILTER_DIGITS = BIT(0), ///< Disallow the use of more than a certain number of digits (0 or more) - SWKBD_FILTER_AT = BIT(1), ///< Disallow the use of the @ sign. - SWKBD_FILTER_PERCENT = BIT(2), ///< Disallow the use of the % sign. - SWKBD_FILTER_BACKSLASH = BIT(3), ///< Disallow the use of the \ sign. - SWKBD_FILTER_PROFANITY = BIT(4), ///< Disallow profanity using Nintendo's profanity filter. - SWKBD_FILTER_CALLBACK = BIT(5), ///< Use a callback in order to check the input. + SWKBD_FILTER_DIGITS = 1U << 0, ///< Disallow the use of more than a certain number of digits (0 or more) + SWKBD_FILTER_AT = 1U << 1, ///< Disallow the use of the @ sign. + SWKBD_FILTER_PERCENT = 1U << 2, ///< Disallow the use of the % sign. + SWKBD_FILTER_BACKSLASH = 1U << 3, ///< Disallow the use of the \ sign. + SWKBD_FILTER_PROFANITY = 1U << 4, ///< Disallow profanity using Nintendo's profanity filter. + SWKBD_FILTER_CALLBACK = 1U << 5, ///< Use a callback in order to check the input. }; /// Keyboard features. enum { - SWKBD_PARENTAL = BIT(0), ///< Parental PIN mode. - SWKBD_DARKEN_TOP_SCREEN = BIT(1), ///< Darken the top screen when the keyboard is shown. - SWKBD_PREDICTIVE_INPUT = BIT(2), ///< Enable predictive input (necessary for Kanji input in JPN systems). - SWKBD_MULTILINE = BIT(3), ///< Enable multiline input. - SWKBD_FIXED_WIDTH = BIT(4), ///< Enable fixed-width mode. - SWKBD_ALLOW_HOME = BIT(5), ///< Allow the usage of the HOME button. - SWKBD_ALLOW_RESET = BIT(6), ///< Allow the usage of a software-reset combination. - SWKBD_ALLOW_POWER = BIT(7), ///< Allow the usage of the POWER button. - SWKBD_DEFAULT_QWERTY = BIT(9), ///< Default to the QWERTY page when the keyboard is shown. + SWKBD_PARENTAL = 1U << 0, ///< Parental PIN mode. + SWKBD_DARKEN_TOP_SCREEN = 1U << 1, ///< Darken the top screen when the keyboard is shown. + SWKBD_PREDICTIVE_INPUT = 1U << 2, ///< Enable predictive input (necessary for Kanji input in JPN systems). + SWKBD_MULTILINE = 1U << 3, ///< Enable multiline input. + SWKBD_FIXED_WIDTH = 1U << 4, ///< Enable fixed-width mode. + SWKBD_ALLOW_HOME = 1U << 5, ///< Allow the usage of the HOME button. + SWKBD_ALLOW_RESET = 1U << 6, ///< Allow the usage of a software-reset combination. + SWKBD_ALLOW_POWER = 1U << 7, ///< Allow the usage of the POWER button. + SWKBD_DEFAULT_QWERTY = 1U << 9, ///< Default to the QWERTY page when the keyboard is shown. }; /// Keyboard filter callback return values. diff --git a/libctru/include/3ds/env.h b/libctru/include/3ds/env.h index cdd9eb8..60dd6b8 100644 --- a/libctru/include/3ds/env.h +++ b/libctru/include/3ds/env.h @@ -6,9 +6,9 @@ /// System run-flags. enum { - RUNFLAG_APTWORKAROUND = BIT(0), ///< Use APT workaround. - RUNFLAG_APTREINIT = BIT(1), ///< Reinitialize APT. - RUNFLAG_APTCHAINLOAD = BIT(2), ///< Chainload APT on return. + RUNFLAG_APTWORKAROUND = 1U << 0, ///< Use APT workaround. + RUNFLAG_APTREINIT = 1U << 1, ///< Reinitialize APT. + RUNFLAG_APTCHAINLOAD = 1U << 2, ///< Chainload APT on return. }; /** diff --git a/libctru/include/3ds/exheader.h b/libctru/include/3ds/exheader.h index 9fd2baa..d7a052a 100644 --- a/libctru/include/3ds/exheader.h +++ b/libctru/include/3ds/exheader.h @@ -9,43 +9,43 @@ /// ARM9 descriptor flags enum { - ARM9DESC_MOUNT_NAND = BIT(0), ///< Mount "nand:/" - ARM9DESC_MOUNT_NANDRO_RW = BIT(1), ///< Mount nand:/ro/ as read-write - ARM9DESC_MOUNT_TWLN = BIT(2), ///< Mount "twln:/" - ARM9DESC_MOUNT_WNAND = BIT(3), ///< Mount "wnand:/" - ARM9DESC_MOUNT_CARDSPI = BIT(4), ///< Mount "cardspi:/" - ARM9DESC_USE_SDIF3 = BIT(5), ///< Use SDIF3 - ARM9DESC_CREATE_SEED = BIT(6), ///< Create seed (movable.sed) - ARM9DESC_USE_CARD_SPI = BIT(7), ///< Use card SPI, required by multiple pxi:dev commands - ARM9DESC_SD_APPLICATION = BIT(8), ///< SD application (not checked) - ARM9DESC_MOUNT_SDMC_RW = BIT(9), ///< Mount "sdmc:/" as read-write + ARM9DESC_MOUNT_NAND = 1U << 0, ///< Mount "nand:/" + ARM9DESC_MOUNT_NANDRO_RW = 1U << 1, ///< Mount nand:/ro/ as read-write + ARM9DESC_MOUNT_TWLN = 1U << 2, ///< Mount "twln:/" + ARM9DESC_MOUNT_WNAND = 1U << 3, ///< Mount "wnand:/" + ARM9DESC_MOUNT_CARDSPI = 1U << 4, ///< Mount "cardspi:/" + ARM9DESC_USE_SDIF3 = 1U << 5, ///< Use SDIF3 + ARM9DESC_CREATE_SEED = 1U << 6, ///< Create seed (movable.sed) + ARM9DESC_USE_CARD_SPI = 1U << 7, ///< Use card SPI, required by multiple pxi:dev commands + ARM9DESC_SD_APPLICATION = 1U << 8, ///< SD application (not checked) + ARM9DESC_MOUNT_SDMC_RW = 1U << 9, ///< Mount "sdmc:/" as read-write }; /// Filesystem access flags enum { - FSACCESS_CATEGORY_SYSTEM_APPLICATION = BIT(0), ///< Category "system application" - FSACCESS_CATEGORY_HARDWARE_CHECK = BIT(1), ///< Category "hardware check" - FSACCESS_CATEGORY_FILESYSTEM_TOOL = BIT(2), ///< Category "filesystem tool" - FSACCESS_DEBUG = BIT(3), ///< Debug - FSACCESS_TWLCARD_BACKUP = BIT(4), ///< TWLCARD backup - FSACCESS_TWLNAND_DATA = BIT(5), ///< TWLNAND data - FSACCESS_BOSS = BIT(6), ///< BOSS (SpotPass) - FSACCESS_SDMC_RW = BIT(7), ///< SDMC (read-write) - FSACCESS_CORE = BIT(8), ///< Core - FSACCESS_NANDRO_RO = BIT(9), ///< nand:/ro/ (read-only) - FSACCESS_NANDRW = BIT(10), ///< nand:/rw/ - FSACCESS_NANDRO_RW = BIT(11), ///< nand:/ro/ (read-write) - FSACCESS_CATEGORY_SYSTEM_SETTINGS = BIT(12), ///< Category "System Settings" - FSACCESS_CARDBOARD = BIT(13), ///< Cardboard (System Transfer) - FSACCESS_EXPORT_IMPORT_IVS = BIT(14), ///< Export/Import IVs (movable.sed) - FSACCESS_SDMC_WO = BIT(15), ///< SDMC (write-only) - FSACCESS_SWITCH_CLEANUP = BIT(16), ///< "Switch cleanup" (3.0+) - FSACCESS_SAVEDATA_MOVE = BIT(17), ///< Savedata move (5.0+) - FSACCESS_SHOP = BIT(18), ///< Shop (5.0+) - FSACCESS_SHELL = BIT(19), ///< Shop (5.0+) - FSACCESS_CATEGORY_HOME_MENU = BIT(20), ///< Category "Home Menu" (6.0+) - FSACCESS_SEEDDB = BIT(21), ///< Seed DB (9.6+) + FSACCESS_CATEGORY_SYSTEM_APPLICATION = 1U << 0, ///< Category "system application" + FSACCESS_CATEGORY_HARDWARE_CHECK = 1U << 1, ///< Category "hardware check" + FSACCESS_CATEGORY_FILESYSTEM_TOOL = 1U << 2, ///< Category "filesystem tool" + FSACCESS_DEBUG = 1U << 3, ///< Debug + FSACCESS_TWLCARD_BACKUP = 1U << 4, ///< TWLCARD backup + FSACCESS_TWLNAND_DATA = 1U << 5, ///< TWLNAND data + FSACCESS_BOSS = 1U << 6, ///< BOSS (SpotPass) + FSACCESS_SDMC_RW = 1U << 7, ///< SDMC (read-write) + FSACCESS_CORE = 1U << 8, ///< Core + FSACCESS_NANDRO_RO = 1U << 9, ///< nand:/ro/ (read-only) + FSACCESS_NANDRW = 1U << 10, ///< nand:/rw/ + FSACCESS_NANDRO_RW = 1U << 11, ///< nand:/ro/ (read-write) + FSACCESS_CATEGORY_SYSTEM_SETTINGS = 1U << 12, ///< Category "System Settings" + FSACCESS_CARDBOARD = 1U << 13, ///< Cardboard (System Transfer) + FSACCESS_EXPORT_IMPORT_IVS = 1U << 14, ///< Export/Import IVs (movable.sed) + FSACCESS_SDMC_WO = 1U << 15, ///< SDMC (write-only) + FSACCESS_SWITCH_CLEANUP = 1U << 16, ///< "Switch cleanup" (3.0+) + FSACCESS_SAVEDATA_MOVE = 1U << 17, ///< Savedata move (5.0+) + FSACCESS_SHOP = 1U << 18, ///< Shop (5.0+) + FSACCESS_SHELL = 1U << 19, ///< Shop (5.0+) + FSACCESS_CATEGORY_HOME_MENU = 1U << 20, ///< Category "Home Menu" (6.0+) + FSACCESS_SEEDDB = 1U << 21, ///< Seed DB (9.6+) }; /// The resource limit category of a title diff --git a/libctru/include/3ds/font.h b/libctru/include/3ds/font.h index a60fbad..b0abb1d 100644 --- a/libctru/include/3ds/font.h +++ b/libctru/include/3ds/font.h @@ -144,9 +144,9 @@ typedef struct /// Flags for use with fontCalcGlyphPos. enum { - GLYPH_POS_CALC_VTXCOORD = BIT(0), ///< Calculates vertex coordinates in addition to texture coordinates. - GLYPH_POS_AT_BASELINE = BIT(1), ///< Position the glyph at the baseline instead of at the top-left corner. - GLYPH_POS_Y_POINTS_UP = BIT(2), ///< Indicates that the Y axis points up instead of down. + GLYPH_POS_CALC_VTXCOORD = 1U << 0, ///< Calculates vertex coordinates in addition to texture coordinates. + GLYPH_POS_AT_BASELINE = 1U << 1, ///< Position the glyph at the baseline instead of at the top-left corner. + GLYPH_POS_Y_POINTS_UP = 1U << 2, ///< Indicates that the Y axis points up instead of down. }; ///@} diff --git a/libctru/include/3ds/gfx.h b/libctru/include/3ds/gfx.h index 9d65b05..91b8485 100644 --- a/libctru/include/3ds/gfx.h +++ b/libctru/include/3ds/gfx.h @@ -166,7 +166,7 @@ void gfxScreenSwapBuffers(gfxScreen_t scr, bool hasStereo); * @param immediate This parameter no longer has any effect and is thus ignored. * @deprecated This function has been superseded by \ref gfxScreenSwapBuffers, please use that instead. */ -DEPRECATED void gfxConfigScreen(gfxScreen_t scr, bool immediate); +LIBCTRU_DEPRECATED void gfxConfigScreen(gfxScreen_t scr, bool immediate); /** * @brief Updates the configuration of both screens. diff --git a/libctru/include/3ds/gpu/enums.h b/libctru/include/3ds/gpu/enums.h index 45f8177..3671a65 100644 --- a/libctru/include/3ds/gpu/enums.h +++ b/libctru/include/3ds/gpu/enums.h @@ -17,9 +17,9 @@ /// Creates a texture mode parameter from a @ref GPU_TEXTURE_MODE_PARAM #define GPU_TEXTURE_MODE(v) (((v)&0x7)<<28) /// Texture parameter indicating ETC1 texture. -#define GPU_TEXTURE_ETC1_PARAM BIT(5) +#define GPU_TEXTURE_ETC1_PARAM (1U << 5) /// Texture parameter indicating shadow texture. -#define GPU_TEXTURE_SHADOW_PARAM BIT(20) +#define GPU_TEXTURE_SHADOW_PARAM (1U << 20) /// Creates a combiner buffer write configuration. #define GPU_TEV_BUFFER_WRITE_CONFIG(stage0, stage1, stage2, stage3) ((stage0) | ((stage1) << 1) | ((stage2) << 2) | ((stage3) << 3)) diff --git a/libctru/include/3ds/gpu/gx.h b/libctru/include/3ds/gpu/gx.h index da32c98..429a102 100644 --- a/libctru/include/3ds/gpu/gx.h +++ b/libctru/include/3ds/gpu/gx.h @@ -61,9 +61,9 @@ typedef enum #define GX_TRANSFER_SCALING(x) ((x)<<24) /// Updates gas additive blend results. -#define GX_CMDLIST_UPDATE_GAS_ACC BIT(0) +#define GX_CMDLIST_UPDATE_GAS_ACC (1U << 0) /// Flushes the command list. -#define GX_CMDLIST_FLUSH BIT(1) +#define GX_CMDLIST_FLUSH (1U << 1) /// GX command entry typedef union diff --git a/libctru/include/3ds/ipc.h b/libctru/include/3ds/ipc.h index e3a44b4..53b9c41 100644 --- a/libctru/include/3ds/ipc.h +++ b/libctru/include/3ds/ipc.h @@ -9,8 +9,8 @@ /// IPC buffer access rights. typedef enum { - IPC_BUFFER_R = BIT(1), ///< Readable - IPC_BUFFER_W = BIT(2), ///< Writable + IPC_BUFFER_R = 1U << 1, ///< Readable + IPC_BUFFER_W = 1U << 2, ///< Writable IPC_BUFFER_RW = IPC_BUFFER_R | IPC_BUFFER_W ///< Readable and Writable } IPC_BufferRights; @@ -70,7 +70,7 @@ static inline u32 IPC_Desc_CurProcessId(void) return 0x20; } -static inline DEPRECATED u32 IPC_Desc_CurProcessHandle(void) +static inline LIBCTRU_DEPRECATED u32 IPC_Desc_CurProcessHandle(void) { return IPC_Desc_CurProcessId(); } diff --git a/libctru/include/3ds/mii.h b/libctru/include/3ds/mii.h index 692cecc..7741256 100644 --- a/libctru/include/3ds/mii.h +++ b/libctru/include/3ds/mii.h @@ -156,4 +156,4 @@ typedef struct } mole_details; u16 author_name[10]; ///< Name of Mii's author (Encoded using UTF16) -} PACKED MiiData; +} __attribute__((packed)) MiiData; diff --git a/libctru/include/3ds/ndsp/channel.h b/libctru/include/3ds/ndsp/channel.h index b233594..cab143f 100644 --- a/libctru/include/3ds/ndsp/channel.h +++ b/libctru/include/3ds/ndsp/channel.h @@ -33,8 +33,8 @@ enum NDSP_FORMAT_ADPCM = NDSP_FORMAT_MONO_ADPCM, ///< (Alias) Buffer contains Mono ADPCM. // Flags - NDSP_FRONT_BYPASS = BIT(4), ///< Front bypass. - NDSP_3D_SURROUND_PREPROCESSED = BIT(6), ///< (?) Unknown, under research + NDSP_FRONT_BYPASS = 1U << 4, ///< Front bypass. + NDSP_3D_SURROUND_PREPROCESSED = 1U << 6, ///< (?) Unknown, under research }; /// Interpolation types. diff --git a/libctru/include/3ds/services/ac.h b/libctru/include/3ds/services/ac.h index bc1ad79..340cd47 100644 --- a/libctru/include/3ds/services/ac.h +++ b/libctru/include/3ds/services/ac.h @@ -112,7 +112,7 @@ Result ACU_SetNetworkArea(acuConfig* config, u8 area); /** * @brief Sets the slot to use when connecting. * @param config Pointer to an acuConfig struct used with ACU_CreateDefaultConfig previously. - * @param type Allowed slots flag. BIT(0) for slot 1, BIT(1) for slot 2, BIT(2) for slot 3. + * @param type Allowed slots flag. (1U << 0) for slot 1, (1U << 1) for slot 2, (1U << 2) for slot 3. */ Result ACU_SetAllowApType(acuConfig* config, u8 type); diff --git a/libctru/include/3ds/services/am.h b/libctru/include/3ds/services/am.h index 1d83942..5cac7e9 100644 --- a/libctru/include/3ds/services/am.h +++ b/libctru/include/3ds/services/am.h @@ -18,8 +18,8 @@ typedef struct /// Pending title status mask values. enum { - AM_STATUS_MASK_INSTALLING = BIT(0), ///< Titles currently installing. - AM_STATUS_MASK_AWAITING_FINALIZATION = BIT(1) ///< Titles awaiting finalization. + AM_STATUS_MASK_INSTALLING = 1U << 0, ///< Titles currently installing. + AM_STATUS_MASK_AWAITING_FINALIZATION = (1U << 1) ///< Titles awaiting finalization. }; /// Pending title status values. @@ -44,8 +44,8 @@ typedef struct /// Pending title deletion flags. enum { - AM_DELETE_PENDING_NON_SYSTEM = BIT(0), ///< Non-system titles. - AM_DELETE_PENDING_SYSTEM = BIT(1) ///< System titles. + AM_DELETE_PENDING_NON_SYSTEM = 1U << 0, ///< Non-system titles. + AM_DELETE_PENDING_SYSTEM = (1U << 1) ///< System titles. }; /// Information about the TWL NAND partition. @@ -69,8 +69,8 @@ typedef struct { /// Title ContentInfo flags. typedef enum { - AM_CONTENT_DOWNLOADED = BIT(0), ///< ? - AM_CONTENT_OWNED = BIT(1) ///< ? + AM_CONTENT_DOWNLOADED = 1U << 0, ///< ? + AM_CONTENT_OWNED = (1U << 1) ///< ? } AM_ContentInfoFlags; /// Initializes AM. This doesn't initialize with "am:app", see amAppInit(). diff --git a/libctru/include/3ds/services/apt.h b/libctru/include/3ds/services/apt.h index ff4bb57..a5e82c6 100644 --- a/libctru/include/3ds/services/apt.h +++ b/libctru/include/3ds/services/apt.h @@ -50,7 +50,7 @@ struct PtmWakeEvents; /// Create an APT_AppletAttr bitfield from its components. static inline APT_AppletAttr aptMakeAppletAttr(APT_AppletPos pos, bool manualGpuRights, bool manualDspRights) { - return (pos&7) | (manualGpuRights ? BIT(3) : 0) | (manualDspRights ? BIT(4) : 0); + return (pos&7) | (manualGpuRights ? (1U << 3) : 0) | (manualDspRights ? (1U << 4) : 0); } /// APT query reply. @@ -176,7 +176,7 @@ bool aptShouldJumpToHome(void); bool aptCheckHomePressRejected(void); /// \deprecated Alias for \ref aptCheckHomePressRejected. -static inline DEPRECATED bool aptIsHomePressed(void) +static inline LIBCTRU_DEPRECATED bool aptIsHomePressed(void) { return aptCheckHomePressRejected(); } diff --git a/libctru/include/3ds/services/cam.h b/libctru/include/3ds/services/cam.h index 5015339..e6c5ae9 100644 --- a/libctru/include/3ds/services/cam.h +++ b/libctru/include/3ds/services/cam.h @@ -10,8 +10,8 @@ /// Camera connection target ports. enum { PORT_NONE = 0x0, ///< No port. - PORT_CAM1 = BIT(0), ///< CAM1 port. - PORT_CAM2 = BIT(1), ///< CAM2 port. + PORT_CAM1 = 1U << 0, ///< CAM1 port. + PORT_CAM2 = 1U << 1, ///< CAM2 port. // Port combinations. PORT_BOTH = PORT_CAM1 | PORT_CAM2, ///< Both ports. @@ -20,9 +20,9 @@ enum { /// Camera combinations. enum { SELECT_NONE = 0x0, ///< No camera. - SELECT_OUT1 = BIT(0), ///< Outer camera 1. - SELECT_IN1 = BIT(1), ///< Inner camera 1. - SELECT_OUT2 = BIT(2), ///< Outer camera 2. + SELECT_OUT1 = 1U << 0, ///< Outer camera 1. + SELECT_IN1 = 1U << 1, ///< Inner camera 1. + SELECT_OUT2 = 1U << 2, ///< Outer camera 2. // Camera combinations. SELECT_IN1_OUT1 = SELECT_OUT1 | SELECT_IN1, ///< Outer camera 1 and inner camera 1. @@ -34,8 +34,8 @@ enum { /// Camera contexts. typedef enum { CONTEXT_NONE = 0x0, ///< No context. - CONTEXT_A = BIT(0), ///< Context A. - CONTEXT_B = BIT(1), ///< Context B. + CONTEXT_A = 1U << 0, ///< Context A. + CONTEXT_B = 1U << 1, ///< Context B. // Context combinations. CONTEXT_BOTH = CONTEXT_A | CONTEXT_B, ///< Both contexts. diff --git a/libctru/include/3ds/services/csnd.h b/libctru/include/3ds/services/csnd.h index 1f8cf37..17cf0a3 100644 --- a/libctru/include/3ds/services/csnd.h +++ b/libctru/include/3ds/services/csnd.h @@ -65,24 +65,24 @@ enum /// Sound flags. enum { - SOUND_LINEAR_INTERP = BIT(6), ///< Linear interpolation. + SOUND_LINEAR_INTERP = 1U << 6, ///< Linear interpolation. SOUND_REPEAT = SOUND_LOOPMODE(CSND_LOOPMODE_NORMAL), ///< Repeat the sound. SOUND_ONE_SHOT = SOUND_LOOPMODE(CSND_LOOPMODE_ONESHOT), ///< Play the sound once. SOUND_FORMAT_8BIT = SOUND_FORMAT(CSND_ENCODING_PCM8), ///< PCM8 SOUND_FORMAT_16BIT = SOUND_FORMAT(CSND_ENCODING_PCM16), ///< PCM16 SOUND_FORMAT_ADPCM = SOUND_FORMAT(CSND_ENCODING_ADPCM), ///< ADPCM SOUND_FORMAT_PSG = SOUND_FORMAT(CSND_ENCODING_PSG), ///< PSG - SOUND_ENABLE = BIT(14), ///< Enable sound. + SOUND_ENABLE = 1U << 14, ///< Enable sound. }; /// Capture modes. enum { CAPTURE_REPEAT = 0, ///< Repeat capture. - CAPTURE_ONE_SHOT = BIT(0), ///< Capture once. + CAPTURE_ONE_SHOT = 1U << 0, ///< Capture once. CAPTURE_FORMAT_16BIT = 0, ///< PCM16 - CAPTURE_FORMAT_8BIT = BIT(1), ///< PCM8 - CAPTURE_ENABLE = BIT(15), ///< Enable capture. + CAPTURE_FORMAT_8BIT = 1U << 1, ///< PCM8 + CAPTURE_ENABLE = 1U << 15, ///< Enable capture. }; /// Duty cycles for a PSG channel. diff --git a/libctru/include/3ds/services/fs.h b/libctru/include/3ds/services/fs.h index 5a3956d..86c0db7 100644 --- a/libctru/include/3ds/services/fs.h +++ b/libctru/include/3ds/services/fs.h @@ -9,25 +9,25 @@ /// Open flags. enum { - FS_OPEN_READ = BIT(0), ///< Open for reading. - FS_OPEN_WRITE = BIT(1), ///< Open for writing. - FS_OPEN_CREATE = BIT(2), ///< Create file. + FS_OPEN_READ = 1U << 0, ///< Open for reading. + FS_OPEN_WRITE = 1U << 1, ///< Open for writing. + FS_OPEN_CREATE = 1U << 2, ///< Create file. }; /// Write flags. enum { - FS_WRITE_FLUSH = BIT(0), ///< Flush. - FS_WRITE_UPDATE_TIME = BIT(8), ///< Update file timestamp. + FS_WRITE_FLUSH = 1U << 0, ///< Flush. + FS_WRITE_UPDATE_TIME = 1U << 8, ///< Update file timestamp. }; /// Attribute flags. enum { - FS_ATTRIBUTE_DIRECTORY = BIT(0), ///< Directory. - FS_ATTRIBUTE_HIDDEN = BIT(8), ///< Hidden. - FS_ATTRIBUTE_ARCHIVE = BIT(16), ///< Archive. - FS_ATTRIBUTE_READ_ONLY = BIT(24), ///< Read-only. + FS_ATTRIBUTE_DIRECTORY = 1U << 0, ///< Directory. + FS_ATTRIBUTE_HIDDEN = 1U << 8, ///< Hidden. + FS_ATTRIBUTE_ARCHIVE = 1U << 16, ///< Archive. + FS_ATTRIBUTE_READ_ONLY = 1U << 24, ///< Read-only. }; /// Media types. @@ -202,7 +202,7 @@ typedef struct } FS_IntegrityVerificationSeed; /// Ext save data information. -typedef struct PACKED +typedef struct __attribute__((packed)) { FS_MediaType mediaType : 8; ///< Media type. u8 unknown; ///< Unknown. diff --git a/libctru/include/3ds/services/hid.h b/libctru/include/3ds/services/hid.h index 34510c0..14a7afb 100644 --- a/libctru/include/3ds/services/hid.h +++ b/libctru/include/3ds/services/hid.h @@ -9,29 +9,29 @@ /// Key values. enum { - KEY_A = BIT(0), ///< A - KEY_B = BIT(1), ///< B - KEY_SELECT = BIT(2), ///< Select - KEY_START = BIT(3), ///< Start - KEY_DRIGHT = BIT(4), ///< D-Pad Right - KEY_DLEFT = BIT(5), ///< D-Pad Left - KEY_DUP = BIT(6), ///< D-Pad Up - KEY_DDOWN = BIT(7), ///< D-Pad Down - KEY_R = BIT(8), ///< R - KEY_L = BIT(9), ///< L - KEY_X = BIT(10), ///< X - KEY_Y = BIT(11), ///< Y - KEY_ZL = BIT(14), ///< ZL (New 3DS only) - KEY_ZR = BIT(15), ///< ZR (New 3DS only) - KEY_TOUCH = BIT(20), ///< Touch (Not actually provided by HID) - KEY_CSTICK_RIGHT = BIT(24), ///< C-Stick Right (New 3DS only) - KEY_CSTICK_LEFT = BIT(25), ///< C-Stick Left (New 3DS only) - KEY_CSTICK_UP = BIT(26), ///< C-Stick Up (New 3DS only) - KEY_CSTICK_DOWN = BIT(27), ///< C-Stick Down (New 3DS only) - KEY_CPAD_RIGHT = BIT(28), ///< Circle Pad Right - KEY_CPAD_LEFT = BIT(29), ///< Circle Pad Left - KEY_CPAD_UP = BIT(30), ///< Circle Pad Up - KEY_CPAD_DOWN = BIT(31), ///< Circle Pad Down + KEY_A = 1U << 0, ///< A + KEY_B = 1U << 1, ///< B + KEY_SELECT = 1U << 2, ///< Select + KEY_START = 1U << 3, ///< Start + KEY_DRIGHT = 1U << 4, ///< D-Pad Right + KEY_DLEFT = 1U << 5, ///< D-Pad Left + KEY_DUP = 1U << 6, ///< D-Pad Up + KEY_DDOWN = 1U << 7, ///< D-Pad Down + KEY_R = 1U << 8, ///< R + KEY_L = 1U << 9, ///< L + KEY_X = 1U << 10, ///< X + KEY_Y = 1U << 11, ///< Y + KEY_ZL = 1U << 14, ///< ZL (New 3DS only) + KEY_ZR = 1U << 15, ///< ZR (New 3DS only) + KEY_TOUCH = 1U << 20, ///< Touch (Not actually provided by HID) + KEY_CSTICK_RIGHT = 1U << 24, ///< C-Stick Right (New 3DS only) + KEY_CSTICK_LEFT = 1U << 25, ///< C-Stick Left (New 3DS only) + KEY_CSTICK_UP = 1U << 26, ///< C-Stick Up (New 3DS only) + KEY_CSTICK_DOWN = 1U << 27, ///< C-Stick Down (New 3DS only) + KEY_CPAD_RIGHT = 1U << 28, ///< Circle Pad Right + KEY_CPAD_LEFT = 1U << 29, ///< Circle Pad Left + KEY_CPAD_UP = 1U << 30, ///< Circle Pad Up + KEY_CPAD_DOWN = 1U << 31, ///< Circle Pad Down // Generic catch-all directions KEY_UP = KEY_DUP | KEY_CPAD_UP, ///< D-Pad Up or Circle Pad Up diff --git a/libctru/include/3ds/services/nfc.h b/libctru/include/3ds/services/nfc.h index 8fa9bf2..195da02 100644 --- a/libctru/include/3ds/services/nfc.h +++ b/libctru/include/3ds/services/nfc.h @@ -43,8 +43,8 @@ typedef enum { /// Bit4-7 are always clear with nfcGetAmiiboSettings() due to "& 0xF". enum { - NFC_amiiboFlag_Setup = BIT(4), /// This indicates that the amiibo was setup with amiibo Settings. nfcGetAmiiboSettings() will return an all-zero struct when this is not set. - NFC_amiiboFlag_AppDataSetup = BIT(5) /// This indicates that the AppData was previously initialized via nfcInitializeWriteAppData(), that function can't be used again with this flag already set. + NFC_amiiboFlag_Setup = 1U << 4, /// This indicates that the amiibo was setup with amiibo Settings. nfcGetAmiiboSettings() will return an all-zero struct when this is not set. + NFC_amiiboFlag_AppDataSetup = (1U << 5) /// This indicates that the AppData was previously initialized via nfcInitializeWriteAppData(), that function can't be used again with this flag already set. }; typedef struct { diff --git a/libctru/include/3ds/services/pmapp.h b/libctru/include/3ds/services/pmapp.h index 12ae8bf..8d89f7c 100644 --- a/libctru/include/3ds/services/pmapp.h +++ b/libctru/include/3ds/services/pmapp.h @@ -9,14 +9,14 @@ /// Launch flags for PM launch commands. enum { - PMLAUNCHFLAG_NORMAL_APPLICATION = BIT(0), - PMLAUNCHFLAG_LOAD_DEPENDENCIES = BIT(1), - PMLAUNCHFLAG_NOTIFY_TERMINATION = BIT(2), - PMLAUNCHFLAG_QUEUE_DEBUG_APPLICATION = BIT(3), + PMLAUNCHFLAG_NORMAL_APPLICATION = 1U << 0, + PMLAUNCHFLAG_LOAD_DEPENDENCIES = 1U << 1, + PMLAUNCHFLAG_NOTIFY_TERMINATION = 1U << 2, + PMLAUNCHFLAG_QUEUE_DEBUG_APPLICATION = 1U << 3, PMLAUNCHFLAG_TERMINATION_NOTIFICATION_MASK = 0xF0, - PMLAUNCHFLAG_FORCE_USE_O3DS_APP_MEM = BIT(8), ///< Forces the usage of the O3DS system mode app memory setting even if N3DS system mode is not "Legacy". Dev4 and Dev5 not supported. N3DS only. - PMLAUNCHFLAG_FORCE_USE_O3DS_MAX_APP_MEM = BIT(9), ///< In conjunction with the above, forces the 96MB app memory setting. N3DS only. - PMLAUNCHFLAG_USE_UPDATE_TITLE = BIT(16), + PMLAUNCHFLAG_FORCE_USE_O3DS_APP_MEM = 1U << 8, ///< Forces the usage of the O3DS system mode app memory setting even if N3DS system mode is not "Legacy". Dev4 and Dev5 not supported. N3DS only. + PMLAUNCHFLAG_FORCE_USE_O3DS_MAX_APP_MEM = 1U << 9, ///< In conjunction with the above, forces the 96MB app memory setting. N3DS only. + PMLAUNCHFLAG_USE_UPDATE_TITLE = 1U << 16, }; /// Initializes pm:app. diff --git a/libctru/include/3ds/services/sslc.h b/libctru/include/3ds/services/sslc.h index 9a86f2a..d1ce403 100644 --- a/libctru/include/3ds/services/sslc.h +++ b/libctru/include/3ds/services/sslc.h @@ -32,8 +32,8 @@ typedef enum { /// sslc options. https://www.3dbrew.org/wiki/SSL_Services#SSLOpt enum { SSLCOPT_Default = 0, - SSLCOPT_DisableVerify = BIT(9), // "Disables server cert verification when set." - SSLCOPT_TLSv10 = BIT(11) // "Use TLSv1.0." + SSLCOPT_DisableVerify = 1U << 9, // "Disables server cert verification when set." + SSLCOPT_TLSv10 = (1U << 11) // "Use TLSv1.0." }; /// Initializes SSLC. Normally session_handle should be 0. When non-zero this will use the specified handle for the main-service-session without using the Initialize command, instead of using srvGetServiceHandle. diff --git a/libctru/include/3ds/services/uds.h b/libctru/include/3ds/services/uds.h index a2ecc17..032a825 100644 --- a/libctru/include/3ds/services/uds.h +++ b/libctru/include/3ds/services/uds.h @@ -138,15 +138,15 @@ typedef struct { } udsNetworkScanInfo; enum { - UDSNETATTR_DisableConnectSpectators = BIT(0), //When set new Spectators are not allowed to connect. - UDSNETATTR_DisableConnectClients = BIT(1), //When set new Clients are not allowed to connect. - UDSNETATTR_x4 = BIT(2), //Unknown what this bit is for. - UDSNETATTR_Default = BIT(15), //Unknown what this bit is for. + UDSNETATTR_DisableConnectSpectators = 1U << 0, //When set new Spectators are not allowed to connect. + UDSNETATTR_DisableConnectClients = 1U << 1, //When set new Clients are not allowed to connect. + UDSNETATTR_x4 = 1U << 2, //Unknown what this bit is for. + UDSNETATTR_Default = 1U << 15, //Unknown what this bit is for. }; enum { - UDS_SENDFLAG_Default = BIT(0), //Unknown what this bit is for. - UDS_SENDFLAG_Broadcast = BIT(1) //When set, broadcast the data frame via the destination MAC address even when UDS_BROADCAST_NETWORKNODEID isn't used. + UDS_SENDFLAG_Default = 1U << 0, //Unknown what this bit is for. + UDS_SENDFLAG_Broadcast = (1U << 1) //When set, broadcast the data frame via the destination MAC address even when UDS_BROADCAST_NETWORKNODEID isn't used. }; typedef enum { diff --git a/libctru/include/3ds/svc.h b/libctru/include/3ds/svc.h index 6827600..cda8a43 100644 --- a/libctru/include/3ds/svc.h +++ b/libctru/include/3ds/svc.h @@ -126,7 +126,7 @@ typedef enum { RESLIMIT_ADDRESSARBITER = 8, ///< Number of address arbiters RESLIMIT_CPUTIME = 9, ///< CPU time. Value expressed in percentage regular until it reaches 90. - RESLIMIT_BIT = BIT(31), ///< Forces enum size to be 32 bits + RESLIMIT_BIT = 1U << 31, ///< Forces enum size to be 32 bits } ResourceLimitType; /// Pseudo handle for the current thread @@ -148,18 +148,18 @@ typedef enum { /// Configuration flags for \ref DmaConfig. enum { - DMACFG_SRC_IS_DEVICE = BIT(0), ///< DMA source is a device/peripheral. Address will not auto-increment. - DMACFG_DST_IS_DEVICE = BIT(1), ///< DMA destination is a device/peripheral. Address will not auto-increment. - DMACFG_WAIT_AVAILABLE = BIT(2), ///< Make \ref svcStartInterProcessDma wait for the channel to be unlocked. - DMACFG_KEEP_LOCKED = BIT(3), ///< Keep the channel locked after the transfer. Required for \ref svcRestartDma. - DMACFG_USE_SRC_CONFIG = BIT(6), ///< Use the provided source device configuration even if the DMA source is not a device. - DMACFG_USE_DST_CONFIG = BIT(7), ///< Use the provided destination device configuration even if the DMA destination is not a device. + DMACFG_SRC_IS_DEVICE = 1U << 0, ///< DMA source is a device/peripheral. Address will not auto-increment. + DMACFG_DST_IS_DEVICE = 1U << 1, ///< DMA destination is a device/peripheral. Address will not auto-increment. + DMACFG_WAIT_AVAILABLE = 1U << 2, ///< Make \ref svcStartInterProcessDma wait for the channel to be unlocked. + DMACFG_KEEP_LOCKED = 1U << 3, ///< Keep the channel locked after the transfer. Required for \ref svcRestartDma. + DMACFG_USE_SRC_CONFIG = 1U << 6, ///< Use the provided source device configuration even if the DMA source is not a device. + DMACFG_USE_DST_CONFIG = 1U << 7, ///< Use the provided destination device configuration even if the DMA destination is not a device. }; /// Configuration flags for \ref svcRestartDma. enum { - DMARST_UNLOCK = BIT(0), ///< Unlock the channel after transfer. - DMARST_RESUME_DEVICE = BIT(1), ///< Replace DMAFLUSHP instructions by NOP (they may not be regenerated even if this flag is not set). + DMARST_UNLOCK = 1U << 0, ///< Unlock the channel after transfer. + DMARST_RESUME_DEVICE = 1U << 1, ///< Replace DMAFLUSHP instructions by NOP (they may not be regenerated even if this flag is not set). }; /** @@ -456,11 +456,11 @@ typedef struct { /// Debug flags for an attached process, set by @ref svcContinueDebugEvent typedef enum { - DBG_INHIBIT_USER_CPU_EXCEPTION_HANDLERS = BIT(0), ///< Inhibit user-defined CPU exception handlers (including watchpoints and breakpoints, regardless of any @ref svcKernelSetState call). - DBG_SIGNAL_FAULT_EXCEPTION_EVENTS = BIT(1), ///< Signal fault exception events. See @ref FaultExceptionEvent. - DBG_SIGNAL_SCHEDULE_EVENTS = BIT(2), ///< Signal schedule in/out events. See @ref ScheduleInOutEvent. - DBG_SIGNAL_SYSCALL_EVENTS = BIT(3), ///< Signal syscall in/out events. See @ref SyscallInOutEvent. - DBG_SIGNAL_MAP_EVENTS = BIT(4), ///< Signal map events. See @ref MapEvent. + DBG_INHIBIT_USER_CPU_EXCEPTION_HANDLERS = 1U << 0, ///< Inhibit user-defined CPU exception handlers (including watchpoints and breakpoints, regardless of any @ref svcKernelSetState call). + DBG_SIGNAL_FAULT_EXCEPTION_EVENTS = 1U << 1, ///< Signal fault exception events. See @ref FaultExceptionEvent. + DBG_SIGNAL_SCHEDULE_EVENTS = 1U << 2, ///< Signal schedule in/out events. See @ref ScheduleInOutEvent. + DBG_SIGNAL_SYSCALL_EVENTS = 1U << 3, ///< Signal syscall in/out events. See @ref SyscallInOutEvent. + DBG_SIGNAL_MAP_EVENTS = 1U << 4, ///< Signal map events. See @ref MapEvent. } DebugFlags; typedef struct { @@ -470,15 +470,15 @@ typedef struct { /// Control flags for @ref svcGetDebugThreadContext and @ref svcSetDebugThreadContext typedef enum { - THREADCONTEXT_CONTROL_CPU_GPRS = BIT(0), ///< Control r0-r12. - THREADCONTEXT_CONTROL_CPU_SPRS = BIT(1), ///< Control sp, lr, pc, cpsr. - THREADCONTEXT_CONTROL_FPU_GPRS = BIT(2), ///< Control d0-d15 (or s0-s31). - THREADCONTEXT_CONTROL_FPU_SPRS = BIT(3), ///< Control fpscr, fpexc. + THREADCONTEXT_CONTROL_CPU_GPRS = 1U << 0, ///< Control r0-r12. + THREADCONTEXT_CONTROL_CPU_SPRS = 1U << 1, ///< Control sp, lr, pc, cpsr. + THREADCONTEXT_CONTROL_FPU_GPRS = 1U << 2, ///< Control d0-d15 (or s0-s31). + THREADCONTEXT_CONTROL_FPU_SPRS = 1U << 3, ///< Control fpscr, fpexc. - THREADCONTEXT_CONTROL_CPU_REGS = BIT(0) | BIT(1), ///< Control r0-r12, sp, lr, pc, cpsr. - THREADCONTEXT_CONTROL_FPU_REGS = BIT(2) | BIT(3), ///< Control d0-d15, fpscr, fpexc. + THREADCONTEXT_CONTROL_CPU_REGS = (1U << 0) | (1U << 1), ///< Control r0-r12, sp, lr, pc, cpsr. + THREADCONTEXT_CONTROL_FPU_REGS = (1U << 2) | (1U << 3), ///< Control d0-d15, fpscr, fpexc. - THREADCONTEXT_CONTROL_ALL = BIT(0) | BIT(1) | BIT(2) | BIT(3), ///< Control all of the above. + THREADCONTEXT_CONTROL_ALL = (1U << 0) | (1U << 1) | (1U << 2) | (1U << 3), ///< Control all of the above. } ThreadContextControlFlags; /// Thread parameter field for @ref svcGetDebugThreadParameter diff --git a/libctru/include/3ds/types.h b/libctru/include/3ds/types.h index eed876a..9798b54 100644 --- a/libctru/include/3ds/types.h +++ b/libctru/include/3ds/types.h @@ -43,20 +43,12 @@ typedef s32 Result; ///< Function result. typedef void (*ThreadFunc)(void *); ///< Thread entrypoint function. typedef void (*voidfn)(void); -/// Creates a bitmask from a bit number. -#define BIT(n) (1U<<(n)) - -/// Aligns a struct (and other types?) to m, making sure that the size of the struct is a multiple of m. -#define ALIGN(m) __attribute__((aligned(m))) -/// Packs a struct (and other types?) so it won't include padding bytes. -#define PACKED __attribute__((packed)) - #ifndef LIBCTRU_NO_DEPRECATION /// Flags a function as deprecated. -#define DEPRECATED __attribute__ ((deprecated)) +#define LIBCTRU_DEPRECATED __attribute__ ((deprecated)) #else /// Flags a function as deprecated. -#define DEPRECATED +#define LIBCTRU_DEPRECATED #endif /// Structure representing CPU registers @@ -71,7 +63,7 @@ typedef struct { /// Structure representing FPU registers typedef struct { union { - struct PACKED { double d[16]; }; ///< d0-d15. + struct __attribute__((packed)) { double d[16]; }; ///< d0-d15. float s[32]; ///< s0-s31. }; u32 fpscr; ///< fpscr. diff --git a/libctru/source/applets/swkbd.c b/libctru/source/applets/swkbd.c index d743ca2..2334890 100644 --- a/libctru/source/applets/swkbd.c +++ b/libctru/source/applets/swkbd.c @@ -123,16 +123,16 @@ void swkbdSetStatusData(SwkbdState* swkbd, SwkbdStatusData* data, bool in, bool { swkbd->extra.status_data = data; swkbd->initial_status_offset = (data&&in) ? 0 : -1; - if (data&&out) swkbd->save_state_flags |= BIT(0); - else swkbd->save_state_flags &= ~BIT(0); + if (data&&out) swkbd->save_state_flags |= (1U << 0); + else swkbd->save_state_flags &= ~(1U << 0); } void swkbdSetLearningData(SwkbdState* swkbd, SwkbdLearningData* data, bool in, bool out) { swkbd->extra.learning_data = data; swkbd->initial_learning_offset = (data&&in) ? 0 : -1; - if (data&&out) swkbd->save_state_flags |= BIT(1); - else swkbd->save_state_flags &= ~BIT(1); + if (data&&out) swkbd->save_state_flags |= (1U << 1); + else swkbd->save_state_flags &= ~(1U << 1); } void swkbdSetFilterCallback(SwkbdState* swkbd, SwkbdCallbackFn callback, void* user) @@ -180,12 +180,12 @@ SwkbdButton swkbdInputText(SwkbdState* swkbd, char* buf, size_t bufsize) sharedMemSize += swkbd->initial_status_offset >= 0 ? sizeof(SwkbdStatusData) : 0; size_t learningOff = sharedMemSize; sharedMemSize += swkbd->initial_learning_offset >= 0 ? sizeof(SwkbdLearningData) : 0; - if (swkbd->save_state_flags & BIT(0)) + if (swkbd->save_state_flags & (1U << 0)) { swkbd->status_offset = sharedMemSize; sharedMemSize += sizeof(SwkbdStatusData); } - if (swkbd->save_state_flags & BIT(1)) + if (swkbd->save_state_flags & (1U << 1)) { swkbd->learning_offset = sharedMemSize; sharedMemSize += sizeof(SwkbdLearningData); @@ -264,8 +264,8 @@ SwkbdButton swkbdInputText(SwkbdState* swkbd, char* buf, size_t bufsize) u16* text16 = (u16*)(swkbdSharedMem+swkbd->text_offset); text16[swkbd->text_length] = 0; swkbdConvertToUTF8(buf, text16, bufsize-1); - if (swkbd->save_state_flags & BIT(0)) memcpy(extra.status_data, swkbdSharedMem+swkbd->status_offset, sizeof(SwkbdStatusData)); - if (swkbd->save_state_flags & BIT(1)) memcpy(extra.learning_data, swkbdSharedMem+swkbd->learning_offset, sizeof(SwkbdLearningData)); + if (swkbd->save_state_flags & (1U << 0)) memcpy(extra.status_data, swkbdSharedMem+swkbd->status_offset, sizeof(SwkbdStatusData)); + if (swkbd->save_state_flags & (1U << 1)) memcpy(extra.learning_data, swkbdSharedMem+swkbd->learning_offset, sizeof(SwkbdLearningData)); free(swkbdSharedMem); return button; diff --git a/libctru/source/gdbhio.c b/libctru/source/gdbhio.c index 7143f85..48b8a26 100644 --- a/libctru/source/gdbhio.c +++ b/libctru/source/gdbhio.c @@ -205,7 +205,7 @@ static int _gdbExportSeekFlag(int flag) // https://sourceware.org/gdb/onlinedocs/gdb/struct-stat.html#struct-stat typedef u32 gdbhio_time_t; -struct PACKED ALIGN(4) gdbhio_stat { +struct __attribute__((packed)) __attribute__((aligned(4))) gdbhio_stat { u32 gst_dev; /* device */ u32 gst_ino; /* inode */ gdbhio_mode_t gst_mode; /* protection */ diff --git a/libctru/source/gfx.c b/libctru/source/gfx.c index 6ace71c..b824f5d 100644 --- a/libctru/source/gfx.c +++ b/libctru/source/gfx.c @@ -96,11 +96,11 @@ static void gfxPresentFramebuffer(gfxScreen_t screen, u8 id, bool hasStereo) { default: case MODE_2D: - mode |= BIT(6); + mode |= (1U << 6); fb_b = fb_a; break; case MODE_3D: - mode |= BIT(5); + mode |= (1U << 5); fb_b = hasStereo ? (fb_a + gfxTopFramebufferMaxSize/2) : fb_a; break; case MODE_WIDE: diff --git a/libctru/source/gpu/gpu.c b/libctru/source/gpu/gpu.c index 02cea77..2104c89 100644 --- a/libctru/source/gpu/gpu.c +++ b/libctru/source/gpu/gpu.c @@ -54,7 +54,7 @@ void GPUCMD_Add(u32 header, const u32* param, u32 paramlength) GPUCMD_AddInternal(header, param, remaining); param += remaining; paramlength -= remaining; - if(header & BIT(31)) header += remaining; + if(header & (1U << 31)) header += remaining; } } diff --git a/libctru/source/gpu/shbin.c b/libctru/source/gpu/shbin.c index 8647a8e..919d071 100644 --- a/libctru/source/gpu/shbin.c +++ b/libctru/source/gpu/shbin.c @@ -125,13 +125,13 @@ void DVLE_GenerateOutmap(DVLE_s* dvle) switch (type) { case RESULT_POSITION: sem = 0x00; num = 4; break; - case RESULT_NORMALQUAT: sem = 0x04; num = 4; dvle->outmapClock |= BIT(24); break; - case RESULT_COLOR: sem = 0x08; num = 4; dvle->outmapClock |= BIT(1); break; - case RESULT_TEXCOORD0: sem = 0x0C; num = 2; dvle->outmapClock |= BIT(8); dvle->outmapMode = 1; break; - case RESULT_TEXCOORD0W: sem = 0x10; num = 1; dvle->outmapClock |= BIT(16); dvle->outmapMode = 1; break; - case RESULT_TEXCOORD1: sem = 0x0E; num = 2; dvle->outmapClock |= BIT(9); dvle->outmapMode = 1; break; - case RESULT_TEXCOORD2: sem = 0x16; num = 2; dvle->outmapClock |= BIT(10); dvle->outmapMode = 1; break; - case RESULT_VIEW: sem = 0x12; num = 3; dvle->outmapClock |= BIT(24); break; + case RESULT_NORMALQUAT: sem = 0x04; num = 4; dvle->outmapClock |= (1U << 24); break; + case RESULT_COLOR: sem = 0x08; num = 4; dvle->outmapClock |= (1U << 1); break; + case RESULT_TEXCOORD0: sem = 0x0C; num = 2; dvle->outmapClock |= (1U << 8); dvle->outmapMode = 1; break; + case RESULT_TEXCOORD0W: sem = 0x10; num = 1; dvle->outmapClock |= (1U << 16); dvle->outmapMode = 1; break; + case RESULT_TEXCOORD1: sem = 0x0E; num = 2; dvle->outmapClock |= (1U << 9); dvle->outmapMode = 1; break; + case RESULT_TEXCOORD2: sem = 0x16; num = 2; dvle->outmapClock |= (1U << 10); dvle->outmapMode = 1; break; + case RESULT_VIEW: sem = 0x12; num = 3; dvle->outmapClock |= (1U << 24); break; default: continue; } @@ -143,7 +143,7 @@ void DVLE_GenerateOutmap(DVLE_s* dvle) *out |= (sem++) << (j*8); k ++; if (type==RESULT_POSITION && k==3) - dvle->outmapClock |= BIT(0); + dvle->outmapClock |= (1U << 0); } } } diff --git a/libctru/source/ndsp/ndsp-channel.c b/libctru/source/ndsp/ndsp-channel.c index c95a8c3..2c91d1c 100644 --- a/libctru/source/ndsp/ndsp-channel.c +++ b/libctru/source/ndsp/ndsp-channel.c @@ -3,16 +3,16 @@ enum { - CFLAG_INITPARAMS = BIT(0), - CFLAG_SYNCCOUNT = BIT(1), - CFLAG_PLAYSTATUS = BIT(2), - CFLAG_INTERPTYPE = BIT(3), - CFLAG_IIRFILTERTYPE = BIT(4), - CFLAG_RATE = BIT(5), - CFLAG_MIX = BIT(6), - CFLAG_ADPCMCOEFS = BIT(7), - CFLAG_IIRMONO = BIT(8), - CFLAG_IIRBIQUAD = BIT(9), + CFLAG_INITPARAMS = 1U << 0, + CFLAG_SYNCCOUNT = 1U << 1, + CFLAG_PLAYSTATUS = 1U << 2, + CFLAG_INTERPTYPE = 1U << 3, + CFLAG_IIRFILTERTYPE = 1U << 4, + CFLAG_RATE = 1U << 5, + CFLAG_MIX = 1U << 6, + CFLAG_ADPCMCOEFS = 1U << 7, + CFLAG_IIRMONO = 1U << 8, + CFLAG_IIRBIQUAD = 1U << 9, }; typedef struct @@ -224,8 +224,8 @@ void ndspChnIirMonoSetEnable(int id, bool enable) { ndspChnSt* chn = &ndspChn[id]; LightLock_Lock(&chn->lock); - u16 f = chn->iirFilterType &~ BIT(0); - if (enable) f |= BIT(0); + u16 f = chn->iirFilterType &~ (1U << 0); + if (enable) f |= (1U << 0); chn->iirFilterType = f; chn->flags |= CFLAG_IIRFILTERTYPE; LightLock_Unlock(&chn->lock); @@ -235,8 +235,8 @@ void ndspChnIirBiquadSetEnable(int id, bool enable) { ndspChnSt* chn = &ndspChn[id]; LightLock_Lock(&chn->lock); - u16 f = chn->iirFilterType &~ BIT(1); - if (enable) f |= BIT(1); + u16 f = chn->iirFilterType &~ (1U << 1); + if (enable) f |= (1U << 1); chn->iirFilterType = f; chn->flags |= CFLAG_IIRFILTERTYPE; LightLock_Unlock(&chn->lock); @@ -270,7 +270,7 @@ bool ndspChnIirMonoSetParamsCustomFilter(int id, float a0, float a1, float b0) LightLock_Lock(&chn->lock); memcpy(chn->iirMono, params, sizeof(chn->iirMono)); - chn->iirFilterType |= BIT(0); + chn->iirFilterType |= (1U << 0); chn->flags |= CFLAG_IIRMONO | CFLAG_IIRFILTERTYPE; @@ -293,7 +293,7 @@ bool ndspChnIirBiquadSetParamsCustomFilter(int id, float a0, float a1, float a2, LightLock_Lock(&chn->lock); memcpy(chn->iirBiquad, params, sizeof(chn->iirBiquad)); - chn->iirFilterType |= BIT(1); + chn->iirFilterType |= (1U << 1); chn->flags |= CFLAG_IIRBIQUAD | CFLAG_IIRFILTERTYPE; @@ -418,7 +418,7 @@ void ndspiUpdateChn(void) st->sampleCount = ndspiRotateVal(wb->nsamples); st->paddr = ndspiRotateVal(osConvertVirtToPhys(wb->data_vaddr)); st->cntFlags = chn->format; - st->moreFlags = (st->moreFlags &~ BIT(1)) | (wb->looping ? BIT(1) : 0); + st->moreFlags = (st->moreFlags &~ (1U << 1)) | (wb->looping ? (1U << 1) : 0); st->unknown = 0; if ((chn->format & NDSP_ENCODING(3)) == NDSP_ENCODING(NDSP_ENCODING_ADPCM)) { @@ -427,9 +427,9 @@ void ndspiUpdateChn(void) st->adpcmData.index = wb->adpcm_data->index; st->adpcmData.history0 = wb->adpcm_data->history0; st->adpcmData.history1 = wb->adpcm_data->history1; - st->moreFlags |= BIT(0); + st->moreFlags |= (1U << 0); } else - st->moreFlags &= ~BIT(0); + st->moreFlags &= ~(1U << 0); } stflags |= 0x10 | 0x40200000; } else diff --git a/libctru/source/ndsp/ndsp.c b/libctru/source/ndsp/ndsp.c index c1b9de4..05607ed 100644 --- a/libctru/source/ndsp/ndsp.c +++ b/libctru/source/ndsp/ndsp.c @@ -67,14 +67,14 @@ static inline int ndspGetCounter(int a) enum { - MFLAG_MASTERVOL = BIT(0), - MFLAG_OUTPUTMODE = BIT(1), - MFLAG_CLIPPINGMODE = BIT(2), - MFLAG_OUTPUTCOUNT = BIT(3), - MFLAG_SYNCMODE = BIT(4), - MFLAG_SURR_DEPTH = BIT(5), - MFLAG_SURR_POS = BIT(6), - MFLAG_SURR_RRATIO = BIT(7), + MFLAG_MASTERVOL = 1U << 0, + MFLAG_OUTPUTMODE = 1U << 1, + MFLAG_CLIPPINGMODE = 1U << 2, + MFLAG_OUTPUTCOUNT = 1U << 3, + MFLAG_SYNCMODE = 1U << 4, + MFLAG_SURR_DEPTH = 1U << 5, + MFLAG_SURR_POS = 1U << 6, + MFLAG_SURR_RRATIO = 1U << 7, #define MFLAG_AUX_ENABLE(i) BIT(8+(i)) #define MFLAG_AUX_BYPASS(i) BIT(10+(i)) diff --git a/libctru/source/services/apt.c b/libctru/source/services/apt.c index 93743de..55b8799 100644 --- a/libctru/source/services/apt.c +++ b/libctru/source/services/apt.c @@ -34,30 +34,30 @@ static void* aptMessageFuncData; enum { // Current applet state - FLAG_ACTIVE = BIT(0), - FLAG_SLEEPING = BIT(1), + FLAG_ACTIVE = 1U << 0, + FLAG_SLEEPING = 1U << 1, // Sleep handling flags - FLAG_ALLOWSLEEP = BIT(2), - FLAG_SHOULDSLEEP = BIT(3), + FLAG_ALLOWSLEEP = 1U << 2, + FLAG_SHOULDSLEEP = 1U << 3, // Home button flags - FLAG_ALLOWHOME = BIT(4), - FLAG_SHOULDHOME = BIT(5), - FLAG_HOMEREJECTED = BIT(6), + FLAG_ALLOWHOME = 1U << 4, + FLAG_SHOULDHOME = 1U << 5, + FLAG_HOMEREJECTED = 1U << 6, // Power button flags - FLAG_POWERBUTTON = BIT(7), - FLAG_SHUTDOWN = BIT(8), + FLAG_POWERBUTTON = 1U << 7, + FLAG_SHUTDOWN = 1U << 8, // Close handling flags - FLAG_ORDERTOCLOSE = BIT(9), - FLAG_CANCELLED = BIT(10), + FLAG_ORDERTOCLOSE = 1U << 9, + FLAG_CANCELLED = 1U << 10, // Miscellaneous - FLAG_DSPWAKEUP = BIT(29), - FLAG_CHAINLOAD = BIT(30), - FLAG_SPURIOUS = BIT(31), + FLAG_DSPWAKEUP = 1U << 29, + FLAG_CHAINLOAD = 1U << 30, + FLAG_SPURIOUS = 1U << 31, }; static u8 aptHomeButtonState; @@ -616,7 +616,7 @@ void aptEventHandler(void *arg) // its purpose is unclear. For completeness' sake, we'll do it as well. static const struct PtmWakeEvents s_sleepWakeEvents = { .pdn_wake_events = 0, - .mcu_interupt_mask = BIT(6), + .mcu_interupt_mask = 1U << 6, }; APT_SleepSystem(&s_sleepWakeEvents); break; diff --git a/libctru/source/services/soc/soc_inet_pton.c b/libctru/source/services/soc/soc_inet_pton.c index ebdc9f7..16bf072 100644 --- a/libctru/source/services/soc/soc_inet_pton.c +++ b/libctru/source/services/soc/soc_inet_pton.c @@ -6,7 +6,7 @@ static int inet_pton4(const char *restrict src, void *restrict dst) { - u8 ip[4] ALIGN(4); + u8 ip[4] __attribute__((aligned(4))); if(sscanf(src,"%hhu.%hhu.%hhu.%hhu",&ip[0], &ip[1], &ip[2], &ip[3]) != 4) return 0; memcpy(dst,ip,4); diff --git a/libctru/source/system/syscalls.c b/libctru/source/system/syscalls.c index 80ada5c..dddc903 100644 --- a/libctru/source/system/syscalls.c +++ b/libctru/source/system/syscalls.c @@ -251,7 +251,7 @@ void initThreadVars(struct Thread_tag *thread) // All flags clear, all interrupts disabled, all instruction scalar. // As for the 3 below fields: default NaN mode, flush-to-zero both enabled & round to nearest. - __builtin_arm_set_fpscr(BIT(25) | BIT(24) | (0u << 22)); + __builtin_arm_set_fpscr((1U << 25) | (1U << 24) | (0u << 22)); } void __system_initSyscalls(void)