endian.h (ced8176236b80fbd15a5e9389fe4205a6ad097c7) | endian.h (63d094a7e2f19c1e048de624ef028d2a3851b124) |
---|---|
1/*- 2 * Copyright (c) 1987, 1991 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 57 unchanged lines hidden (view full) --- 66#define __bswap16_gen(x) (__uint16_t)((x) << 8 | (x) >> 8) 67#define __bswap32_gen(x) \ 68 (((__uint32_t)__bswap16(x) << 16) | __bswap16((x) >> 16)) 69#define __bswap64_gen(x) \ 70 (((__uint64_t)__bswap32(x) << 32) | __bswap32((x) >> 32)) 71 72#ifdef __GNUCLIKE_BUILTIN_CONSTANT_P 73#define __bswap16(x) \ | 1/*- 2 * Copyright (c) 1987, 1991 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 57 unchanged lines hidden (view full) --- 66#define __bswap16_gen(x) (__uint16_t)((x) << 8 | (x) >> 8) 67#define __bswap32_gen(x) \ 68 (((__uint32_t)__bswap16(x) << 16) | __bswap16((x) >> 16)) 69#define __bswap64_gen(x) \ 70 (((__uint64_t)__bswap32(x) << 32) | __bswap32((x) >> 32)) 71 72#ifdef __GNUCLIKE_BUILTIN_CONSTANT_P 73#define __bswap16(x) \ |
74 (__uint16_t)(__builtin_constant_p(x) ? \ 75 __bswap16_gen((__uint16_t)(x)) : __bswap16_var(x)) | 74 ((__uint16_t)(__builtin_constant_p(x) ? \ 75 __bswap16_gen((__uint16_t)(x)) : __bswap16_var(x))) |
76#define __bswap32(x) \ 77 (__builtin_constant_p(x) ? \ 78 __bswap32_gen((__uint32_t)(x)) : __bswap32_var(x)) 79#define __bswap64(x) \ 80 (__builtin_constant_p(x) ? \ 81 __bswap64_gen((__uint64_t)(x)) : __bswap64_var(x)) 82#else 83/* XXX these are broken for use in static initializers. */ --- 48 unchanged lines hidden --- | 76#define __bswap32(x) \ 77 (__builtin_constant_p(x) ? \ 78 __bswap32_gen((__uint32_t)(x)) : __bswap32_var(x)) 79#define __bswap64(x) \ 80 (__builtin_constant_p(x) ? \ 81 __bswap64_gen((__uint64_t)(x)) : __bswap64_var(x)) 82#else 83/* XXX these are broken for use in static initializers. */ --- 48 unchanged lines hidden --- |