Differences From Artifact [c89d0aa05c]:
- File src/macros.h — part of check-in [255fd75828] at 2012-10-13 19:30:49 on branch trunk — of_endianess_t -> of_byte_order_t. (user: js, size: 9211) [annotate] [blame] [check-ins using]
To Artifact [1ed7809f51]:
- File
src/macros.h
— part of check-in
[1cb8fee5c3]
at
2012-10-13 21:06:59
on branch trunk
— of_bswap* -> OF_BSWAP*.
This makes it clear that multiple evaluation of parameters is possible. (user: js, size: 8945) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
135 136 137 138 139 140 141 | #define OF_IVAR_OFFSET(ivar) ((intptr_t)&ivar - (intptr_t)self) #define OF_GETTER(ivar, atomic) \ return objc_getProperty(self, _cmd, OF_IVAR_OFFSET(ivar), atomic); #define OF_SETTER(ivar, value, atomic, copy) \ objc_setProperty(self, _cmd, OF_IVAR_OFFSET(ivar), value, atomic, copy); static OF_INLINE uint16_t OF_CONST_FUNC | | | | | | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | #define OF_IVAR_OFFSET(ivar) ((intptr_t)&ivar - (intptr_t)self) #define OF_GETTER(ivar, atomic) \ return objc_getProperty(self, _cmd, OF_IVAR_OFFSET(ivar), atomic); #define OF_SETTER(ivar, value, atomic, copy) \ objc_setProperty(self, _cmd, OF_IVAR_OFFSET(ivar), value, atomic, copy); static OF_INLINE uint16_t OF_CONST_FUNC OF_BSWAP16_CONST(uint16_t i) { return (i & UINT16_C(0xFF00)) >> 8 | (i & UINT16_C(0x00FF)) << 8; } static OF_INLINE uint32_t OF_CONST_FUNC OF_BSWAP32_CONST(uint32_t i) { return (i & UINT32_C(0xFF000000)) >> 24 | (i & UINT32_C(0x00FF0000)) >> 8 | (i & UINT32_C(0x0000FF00)) << 8 | (i & UINT32_C(0x000000FF)) << 24; } static OF_INLINE uint64_t OF_CONST_FUNC OF_BSWAP64_CONST(uint64_t i) { return (i & UINT64_C(0xFF00000000000000)) >> 56 | (i & UINT64_C(0x00FF000000000000)) >> 40 | (i & UINT64_C(0x0000FF0000000000)) >> 24 | (i & UINT64_C(0x000000FF00000000)) >> 8 | (i & UINT64_C(0x00000000FF000000)) << 8 | (i & UINT64_C(0x0000000000FF0000)) << 24 | (i & UINT64_C(0x000000000000FF00)) << 40 | (i & UINT64_C(0x00000000000000FF)) << 56; } static OF_INLINE uint16_t OF_CONST_FUNC OF_BSWAP16_NONCONST(uint16_t i) { #if defined(OF_X86_ASM) || defined(OF_AMD64_ASM) __asm__ ( "xchgb %h0, %b0" : "=Q"(i) : "0"(i) ); |
︙ | ︙ | |||
192 193 194 195 196 197 198 | i = (i & UINT16_C(0xFF00)) >> 8 | (i & UINT16_C(0x00FF)) << 8; #endif return i; } static OF_INLINE uint32_t OF_CONST_FUNC | | | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | i = (i & UINT16_C(0xFF00)) >> 8 | (i & UINT16_C(0x00FF)) << 8; #endif return i; } static OF_INLINE uint32_t OF_CONST_FUNC OF_BSWAP32_NONCONST(uint32_t i) { #if defined(OF_X86_ASM) || defined(OF_AMD64_ASM) __asm__ ( "bswap %0" : "=q"(i) : "0"(i) ); |
︙ | ︙ | |||
222 223 224 225 226 227 228 | (i & UINT32_C(0x0000FF00)) << 8 | (i & UINT32_C(0x000000FF)) << 24; #endif return i; } static OF_INLINE uint64_t OF_CONST_FUNC | | | | | | | | | | | | | | | | | < < < < < < < < < | | | | | | < | | | | | | < | | | | | | | | | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | (i & UINT32_C(0x0000FF00)) << 8 | (i & UINT32_C(0x000000FF)) << 24; #endif return i; } static OF_INLINE uint64_t OF_CONST_FUNC OF_BSWAP64_NONCONST(uint64_t i) { #if defined(OF_AMD64_ASM) __asm__ ( "bswap %0" : "=r"(i) : "0"(i) ); #elif defined(OF_X86_ASM) __asm__ ( "bswap %%eax\n\t" "bswap %%edx\n\t" "xchgl %%eax, %%edx" : "=A"(i) : "0"(i) ); #else i = (uint64_t)OF_BSWAP32_NONCONST((uint32_t)(i & 0xFFFFFFFF)) << 32 | OF_BSWAP32_NONCONST((uint32_t)(i >> 32)); #endif return i; } #ifdef __GNUC__ # define OF_BSWAP16(i) \ (__builtin_constant_p(i) ? OF_BSWAP16_CONST(i) : OF_BSWAP16_NONCONST(i)) # define OF_BSWAP32(i) \ (__builtin_constant_p(i) ? OF_BSWAP32_CONST(i) : OF_BSWAP32_NONCONST(i)) # define OF_BSWAP64(i) \ (__builtin_constant_p(i) ? OF_BSWAP64_CONST(i) : OF_BSWAP64_NONCONST(i)) #else # define OF_BSWAP16(i) OF_BSWAP16_CONST(i) # define OF_BSWAP32(i) OF_BSWAP32_CONST(i) # define OF_BSWAP64(i) OF_BSWAP64_CONST(i) #endif static OF_INLINE float OF_CONST_FUNC OF_BSWAP_FLOAT(float f) { union { float f; uint32_t i; } u; u.f = f; u.i = OF_BSWAP32(u.i); return u.f; } static OF_INLINE double OF_CONST_FUNC OF_BSWAP_DOUBLE(double d) { union { double d; uint64_t i; } u; u.d = d; u.i = OF_BSWAP64(u.i); return u.d; } #ifdef OF_BIG_ENDIAN # define OF_BSWAP16_IF_BE(i) OF_BSWAP16(i) # define OF_BSWAP32_IF_BE(i) OF_BSWAP32(i) # define OF_BSWAP64_IF_BE(i) OF_BSWAP64(i) # define OF_BSWAP16_IF_LE(i) (i) # define OF_BSWAP32_IF_LE(i) (i) # define OF_BSWAP64_IF_LE(i) (i) #else # define OF_BSWAP16_IF_BE(i) (i) # define OF_BSWAP32_IF_BE(i) (i) # define OF_BSWAP64_IF_BE(i) (i) # define OF_BSWAP16_IF_LE(i) OF_BSWAP16(i) # define OF_BSWAP32_IF_LE(i) OF_BSWAP32(i) # define OF_BSWAP64_IF_LE(i) OF_BSWAP64(i) #endif #ifdef OF_FLOAT_BIG_ENDIAN # define OF_BSWAP_FLOAT_IF_BE(i) OF_BSWAP_FLOAT(i) # define OF_BSWAP_DOUBLE_IF_BE(i) OF_BSWAP_DOUBLE(i) # define OF_BSWAP_FLOAT_IF_LE(i) (i) # define OF_BSWAP_DOUBLE_IF_LE(i) (i) #else # define OF_BSWAP_FLOAT_IF_BE(i) (i) # define OF_BSWAP_DOUBLE_IF_BE(i) (i) # define OF_BSWAP_FLOAT_IF_LE(i) OF_BSWAP_FLOAT(i) # define OF_BSWAP_DOUBLE_IF_LE(i) OF_BSWAP_DOUBLE(i) #endif /* * We define it here and not in objfw-defs.h, as it would be theoretically * possible to build a universal binary for Mac OS X and iOS. */ #if defined(__MACH__) && defined(__arm__) |
︙ | ︙ |