allow coexistance of N build and AC build.
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / scripts / squashfs / read_fs.h
blob1b35aed2bc98c43bf7e5f576912bc5d825223d3c
1 /*
2 * macros to convert each packed bitfield structure from little endian to big
3 * endian and vice versa. These are needed when creating a filesystem on a
4 * machine with different byte ordering to the target architecture.
6 * Copyright (c) 2002, 2003, 2004, 2005, 2006
7 * Phillip Lougher <phillip@lougher.org.uk>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2,
12 * or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * mksquashfs.h
28 * macros used to swap each structure entry, taking into account
29 * bitfields and different bitfield placing conventions on differing architectures
31 #if __BYTE_ORDER == __BIG_ENDIAN
32 /* convert from big endian to little endian */
33 #define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, tbits, b_pos)
34 #else
35 /* convert from little endian to big endian */
36 #define SQUASHFS_SWAP(value, p, pos, tbits) _SQUASHFS_SWAP(value, p, pos, tbits, 64 - tbits - b_pos)
37 #endif
39 #define _SQUASHFS_SWAP(value, p, pos, tbits, SHIFT) {\
40 int bits;\
41 int b_pos = pos % 8;\
42 unsigned long long val = 0;\
43 unsigned char *s = (unsigned char *)p + (pos / 8);\
44 unsigned char *d = ((unsigned char *) &val) + 7;\
45 for(bits = 0; bits < (tbits + b_pos); bits += 8) \
46 *d-- = *s++;\
47 value = (val >> (SHIFT))/* & ((1 << tbits) - 1)*/;\
49 #define SQUASHFS_MEMSET(s, d, n) memset(s, 0, n);