1 |
/* |
2 |
* HT Editor |
3 |
* endianess.h |
4 |
* |
5 |
* Copyright (C) 1999-2002 Stefan Weyergraf |
6 |
* |
7 |
* This program is free software; you can redistribute it and/or modify |
8 |
* it under the terms of the GNU General Public License version 2 as |
9 |
* published by the Free Software Foundation. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 |
*/ |
20 |
|
21 |
#ifndef __ENDIANESS_H__ |
22 |
#define __ENDIANESS_H__ |
23 |
|
24 |
#include "system/types.h" |
25 |
|
26 |
// This is _NOT_ a bitmask! |
27 |
#define STRUCT_ENDIAN_8 1 |
28 |
#define STRUCT_ENDIAN_16 2 |
29 |
#define STRUCT_ENDIAN_32 4 |
30 |
#define STRUCT_ENDIAN_64 8 |
31 |
|
32 |
// This is a bitmask. |
33 |
#define STRUCT_ENDIAN_HOST 128 |
34 |
|
35 |
typedef enum { |
36 |
big_endian, |
37 |
little_endian |
38 |
} Endianess; |
39 |
|
40 |
#ifdef __cplusplus |
41 |
extern "C" { |
42 |
#endif |
43 |
|
44 |
void createForeignInt(void *buf, int i, int size, Endianess to_endianess); |
45 |
void createForeignInt64(void *buf, uint64 i, int size, Endianess to_endianess); |
46 |
int createHostInt(const void *buf, int size, Endianess from_endianess); |
47 |
uint64 createHostInt64(const void *buf, int size, Endianess from_endianess); |
48 |
void createHostStructx(void *buf, uint bufsize, const uint8 *table, Endianess from_endianess); |
49 |
|
50 |
#ifdef __cplusplus |
51 |
} |
52 |
#endif |
53 |
|
54 |
#endif /* __ENDIANESS_H__ */ |