cm0002@lemmy.world to Programmer Humor@programming.dev · 1 day agoTell me the truth ...piefed.jeena.netimagemessage-square108linkfedilinkarrow-up11.02Karrow-down115
arrow-up11Karrow-down1imageTell me the truth ...piefed.jeena.netcm0002@lemmy.world to Programmer Humor@programming.dev · 1 day agomessage-square108linkfedilink
minus-squareskisnow@lemmy.calinkfedilinkEnglisharrow-up47·21 hours agoBack in the day when it mattered, we did it like #define BV00 (1 << 0) #define BV01 (1 << 1) #define BV02 (1 << 2) #define BV03 (1 << 3) ...etc #define IS_SET(flag, bit) ((flag) & (bit)) #define SET_BIT(var, bit) ((var) |= (bit)) #define REMOVE_BIT(var, bit) ((var) &= ~(bit)) #define TOGGLE_BIT(var, bit) ((var) ^= (bit)) ....then... #define MY_FIRST_BOOLEAN BV00 SET_BIT(myFlags, MY_FIRST_BOOLEAN)
minus-squareethancedwards8@programming.devlinkfedilinkEnglisharrow-up1·3 hours agoOkay. Gen z programmer here. Can you explain this black magic? I see it all the time in kernel code but I have no idea what it means.
minus-squareQuatlicopatlix@feddit.orglinkfedilinkarrow-up8·12 hours agoWith embedded stuff its still done like that. And if you go from the arduino functionss to writing the registers directly its a hell of a lot faster.
Back in the day when it mattered, we did it like
#define BV00 (1 << 0) #define BV01 (1 << 1) #define BV02 (1 << 2) #define BV03 (1 << 3) ...etc #define IS_SET(flag, bit) ((flag) & (bit)) #define SET_BIT(var, bit) ((var) |= (bit)) #define REMOVE_BIT(var, bit) ((var) &= ~(bit)) #define TOGGLE_BIT(var, bit) ((var) ^= (bit)) ....then... #define MY_FIRST_BOOLEAN BV00 SET_BIT(myFlags, MY_FIRST_BOOLEAN)
Okay. Gen z programmer here. Can you explain this black magic? I see it all the time in kernel code but I have no idea what it means.
Which part?
With embedded stuff its still done like that. And if you go from the arduino functionss to writing the registers directly its a hell of a lot faster.