X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fendianness.h;h=ba66b27a27f5c64b6b77b0496a348594b48375f6;hb=81be60d782a4b4b8ae2e40141fc42b6e0e2d2706;hp=43eace2415b5b731aebcfd176cd3dadd58a201e8;hpb=885632f08c75c1d7bb5d25436231c78f6ad7e0c0;p=wimlib diff --git a/src/endianness.h b/src/endianness.h index 43eace24..ba66b27a 100644 --- a/src/endianness.h +++ b/src/endianness.h @@ -1,24 +1,3 @@ -/* - * endianness.h - * - * Copyright (C) 2012 Eric Biggers - * - * wimlib - Library for working with WIM files - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) any - * later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along - * with this library; if not, write to the Free Software Foundation, Inc., 59 - * Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - #ifndef _WIMLIB_ENDIANNESS_H #define _WIMLIB_ENDIANNESS_H @@ -29,7 +8,7 @@ /* Changes the endianness of a 32-bit value. */ static inline uint32_t bswap32(uint32_t n) { -#ifdef __GNUC__ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) return __builtin_bswap32(n); #else return (n << 24) | ((n & 0xff00) << 8) | ((n & 0xff0000) >> 8) | @@ -70,9 +49,9 @@ static inline uint64_t bswap64(uint64_t n) #define to_be64(n) (n) /* In place */ -#define TO_LE16(n) (n = to_le16(n)) -#define TO_LE32(n) (n = to_le32(n)) -#define TO_LE64(n) (n = to_le64(n)) +#define TO_LE16(n) ((n) = to_le16(n)) +#define TO_LE32(n) ((n) = to_le32(n)) +#define TO_LE64(n) ((n) = to_le64(n)) static inline void array_to_le16(uint16_t *p, uint64_t n) {