patch zlib check
[platform/upstream/cdrkit.git] / genisoimage / bswap.h
1 /*
2  * This file has been modified for the cdrkit suite.
3  *
4  * The behaviour and appearence of the program code below can differ to a major
5  * extent from the version distributed by the original author(s).
6  *
7  * For details, see Changelog file distributed with the cdrkit package. If you
8  * received this file from another source then ask the distributing person for
9  * a log of modifications.
10  *
11  */
12
13 /* @(#)bswap.h  1.2 03/03/25 Copyright 2002 J. Schilling */
14 #ifndef _BSWAP_H
15 #define _BSWAP_H
16
17 /*
18  *      Allow to use B2N_* macros found in libdvdread in a portable way.
19  *      These macros should better be avoided as in place conversion in
20  *      general only works on processors like Motorola 68000 and Intel x86.
21  *      Modern processors usually have alignement restrictions that may
22  *      cause problems. The stripped down libdvdread for genisoimage is known
23  *      not to have these alignement problems, so we may use the macros
24  *      as they have been introduced by the authors of libdvdread.
25  *
26  *      Copyright (c) 2002 J. Schilling
27  */
28 /*
29  * This program is free software; you can redistribute it and/or modify
30  * it under the terms of the GNU General Public License version 2
31  * as published by the Free Software Foundation.
32  *
33  * This program is distributed in the hope that it will be useful,
34  * but WITHOUT ANY WARRANTY; without even the implied warranty of
35  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
36  * GNU General Public License for more details.
37  *
38  * You should have received a copy of the GNU General Public License along with
39  * this program; see the file COPYING.  If not, write to the Free Software
40  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
41  */
42
43 #include <mconfig.h>
44 #include <btorder.h>
45 #include <intcvt.h>
46
47 #if defined(WORDS_BIGENDIAN)
48
49 /* All bigendian systems are fine, just ignore the swaps. */
50 #define B2N_16(x) (void)(x)
51 #define B2N_32(x) (void)(x)
52 #define B2N_64(x) (void)(x)
53
54 #else
55
56 /*
57  * It is a bad idea to convert numbers in place.
58  * In protocols, there is usually the additional problem that the
59  * data is not properly aligned.
60  */
61 #define B2N_16(x) (x) = a_to_u_2_byte(&(x))
62 #define B2N_32(x) (x) = a_to_u_4_byte(&(x))
63 #define B2N_64(x) (x) = a_to_u_8_byte(&(x))
64
65 #endif
66
67 #endif /* _BSWAP_H */