/usr/include/hfsplus/swab.h is in libhfsp-dev 1.0.4-13.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | /*
* libhfs - library for reading and writing Macintosh HFS volumes
*
* Copyright (C) 2000 Klaus Halfmann <klaus.halfmann@feri.de>
* Original work 1996-1998 Robert Leslie <rob@mars.org>
*
* This file defines some byte swapping function. I did not find this
* in any standard or linux way.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: swab.h,v 1.1.1.1 2002/03/05 19:50:29 klaus Exp $
*/
#include <endian.h>
#include <byteswap.h>
/* basic fuction:
value = swab_inc(ptr);
ptr is afterwards incremented by sizeof(value)
*/
#if BYTE_ORDER == LITTLE_ENDIAN
#define bswabU16(val) bswap_16(val)
#define bswabU16_inc(ptr) bswap_16(*((UInt16*) (ptr))); ptr = (UInt16*)ptr + 1
#define bswabU32_inc(ptr) bswap_32(*((UInt32*) (ptr))); ptr = (UInt32*)ptr + 1
#define bswabU64_inc(ptr) bswap_64(*((UInt64*) (ptr))); ptr = (UInt64*)ptr + 1
#define bstoreU16_inc(ptr, val) *((UInt16*) (ptr)) = bswap_16(val); ptr = (UInt16*)ptr + 1
#define bstoreU32_inc(ptr, val) *((UInt32*) (ptr)) = bswap_32(val); ptr = (UInt32*)ptr + 1;
#define bstoreU64_inc(ptr, val) *((UInt64*) (ptr)) = bswap_64(val); ptr = (UInt32*)ptr + 1;
#else // BYTE_ORDER == BIG_ENDIAN
#define bswabU16(val) val
#define bswabU16_inc(ptr) *((UInt16*) (ptr)); ptr = (UInt16*)ptr + 1
/* Only available as a GCC extension, but required on sparc due to
alignment issues in some of the on-disk structs */
#if defined(__GNUC__) && defined(__sparc__)
#define bswabU32_inc(ptr) ({ \
unsigned char *c = (char*)ptr; \
ptr = ((UInt32 *)ptr) + 1; \
((c[0] << 24)+(c[1] << 16)+(c[2] << 8)+c[3]);})
#define bswabU64_inc(ptr) ({ \
unsigned char *c = (char*)ptr; \
UInt64 val = 0; \
int i = 0; \
ptr = ((UInt64 *)ptr) + 1; \
while (i < 8) \
val += (c[i] << (8*(7-i++))); \
val;})
#else
#define bswabU32_inc(ptr) *((UInt32*) (ptr)); ptr = (UInt32*)ptr + 1
#define bswabU64_inc(ptr) *((UInt64*) (ptr)); ptr = (UInt64*)ptr + 1
#endif
#define bstoreU16_inc(ptr, val) *((UInt16*) (ptr)) = val; ptr = (UInt16*)ptr + 1
#define bstoreU32_inc(ptr, val) *((UInt32*) (ptr)) = val; ptr = (UInt32*)ptr + 1
#define bstoreU64_inc(ptr, val) *((UInt64*) (ptr)) = val; ptr = (UInt64*)ptr + 1
#endif
/* for the sake of compleetness and readability */
#define bswabU8_inc(ptr) *((UInt8*) (ptr)); ptr = (UInt8*)ptr + 1
#define bstoreU8_inc(ptr,val) *((UInt8*) (ptr)) = val; ptr = (UInt8*)ptr + 1
|