cross compile on UNIX with open watcom, and cleanup watdpmi
[dos_imgv] / imago / src / byteord.h
1 /*
2 libimago - a multi-format image file input/output library.
3 Copyright (C) 2010-2017 John Tsiombikas <nuclear@member.fsf.org>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published
7 by the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef IMAGO_BYTEORD_H_
19 #define IMAGO_BYTEORD_H_
20
21 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199900) || (defined(_MSC_VER) && _MSC_VER >= 1600)
22 #include <stdint.h>
23 #else
24 #include <sys/types.h>
25 #endif
26
27 #if defined(__WATCOMC__) && __WATCOMC__ < 1200
28 typedef signed char int8_t;
29 typedef unsigned char uint8_t;
30 typedef short int16_t;
31 typedef unsigned short uint16_t;
32 typedef long int32_t;
33 typedef unsigned long uint32_t;
34 #endif
35
36 #include "imago2.h"
37
38 #if  defined(__i386__) || defined(__ia64__) || defined(WIN32) || \
39     (defined(__alpha__) || defined(__alpha)) || \
40      defined(__arm__) || \
41     (defined(__mips__) && defined(__MIPSEL__)) || \
42      defined(__SYMBIAN32__) || \
43      defined(__x86_64__) || \
44      defined(__LITTLE_ENDIAN__)
45 /* little endian */
46 #define IMAGO_LITTLE_ENDIAN
47
48 #define img_read_int16_le(f)            img_read_int16(f)
49 #define img_write_int16_le(f, v)        img_write_int16(f, v)
50 #define img_read_int16_be(f)            img_read_int16_inv(f)
51 #define img_write_int16_be(f, v)        img_write_int16_inv(f, v)
52 #define img_read_uint16_le(f)           img_read_uint16(f)
53 #define img_write_uint16_le(f, v)       img_write_uint16(f, v)
54 #define img_read_uint16_be(f)           img_read_uint16_inv(f)
55 #define img_write_uint16_be(f, v)       img_write_uint16_inv(f, v)
56
57 #define img_read_uint32_be(f)           img_read_uint32_inv(f)
58 #else
59 /* big endian */
60 #define IMAGO_BIG_ENDIAN
61
62 #define img_read_int16_le(f)            img_read_int16_inv(f)
63 #define img_write_int16_le(f, v)        img_write_int16_inv(f, v)
64 #define img_read_int16_be(f)            img_read_int16(f)
65 #define img_write_int16_be(f, v)        img_write_int16(f, v)
66 #define img_read_uint16_le(f)           img_read_uint16_inv(f)
67 #define img_write_uint16_le(f, v)       img_write_uint16_inv(f, v)
68 #define img_read_uint16_be(f)           img_read_uint16(f)
69 #define img_write_uint16_be(f, v)       img_write_uint16(f, v)
70
71 #define img_read_uint32_be(f)           img_read_uint32(f)
72 #endif  /* endian check */
73
74 int16_t img_read_int16(struct img_io *io);
75 int16_t img_read_int16_inv(struct img_io *io);
76 uint16_t img_read_uint16(struct img_io *io);
77 uint16_t img_read_uint16_inv(struct img_io *io);
78
79 void img_write_int16(struct img_io *io, int16_t val);
80 void img_write_int16_inv(struct img_io *io, int16_t val);
81 void img_write_uint16(struct img_io *io, uint16_t val);
82 void img_write_uint16_inv(struct img_io *io, uint16_t val);
83
84 uint32_t img_read_uint32(struct img_io *io);
85 uint32_t img_read_uint32_inv(struct img_io *io);
86
87
88 #endif  /* IMAGO_BYTEORD_H_ */