The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sysdata.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * sysdata.h - definitions that help SWORD work the same on different systems
4  *
5  * $Id: sysdata.h 3789 2020-09-11 15:24:25Z scribe $
6  *
7  * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
8  * CrossWire Bible Society
9  * P. O. Box 2528
10  * Tempe, AZ 85280-2528
11  *
12  * This program is free software; you can redistribute it and/or modify it
13  * under the terms of the GNU General Public License as published by the
14  * Free Software Foundation version 2.
15  *
16  * This program is distributed in the hope that it will be useful, but
17  * WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * General Public License for more details.
20  *
21  */
22 
23 #ifndef SIZEDTYPES_H
24 #define SIZEDTYPES_H
25 /*
26  * __xx is apparently not ok: it does pollute the POSIX namespace, changed to SW_xx. Use these in the
27  * header files exported to user space
28  */
29 #ifdef USE_AUTOTOOLS
30 #include "config.h"
31 #endif
32 
33 
34 typedef signed char SW_s8;
35 typedef unsigned char SW_u8;
36 
37 typedef signed short SW_s16;
38 typedef unsigned short SW_u16;
39 
40 typedef signed int SW_s32;
41 typedef unsigned int SW_u32;
42 
43 #ifdef OS_ANDROID
44 __extension__ typedef __signed__ long long SW_s64;
45 __extension__ typedef unsigned long long SW_u64;
46 //typedef __s64 SW_s64;
47 //typedef __u64 SW_u64;
48 #elif defined(__GNUC__)
49 __extension__ typedef __signed__ long long SW_s64;
50 __extension__ typedef unsigned long long SW_u64;
51 #elif defined(__BORLANDC__)
52 typedef signed __int64 SW_s64;
53 typedef unsigned __int64 SW_u64;
54 #else
55 typedef signed long long SW_s64;
56 typedef unsigned long long SW_u64;
57 #endif
58 
59 #undef __swswap16
60 #undef __swswap32
61 #undef __swswap64
62 
63 #define __swswap16(x) \
64  ((SW_u16)( \
65  (((SW_u16)(x) & (SW_u16)0x00ffU) << 8) | \
66  (((SW_u16)(x) & (SW_u16)0xff00U) >> 8) ))
67 
68 
69 #define __swswap32(x) \
70  ((SW_u32)( \
71  (((SW_u32)(x) & (SW_u32)0x000000ffUL) << 24) | \
72  (((SW_u32)(x) & (SW_u32)0x0000ff00UL) << 8) | \
73  (((SW_u32)(x) & (SW_u32)0x00ff0000UL) >> 8) | \
74  (((SW_u32)(x) & (SW_u32)0xff000000UL) >> 24) ))
75 
76 
77 #define __swswap64(x) \
78  ((SW_u64)( \
79  (SW_u64)(((SW_u64)(x) & (SW_u64)0x00000000000000ffULL) << 56) | \
80  (SW_u64)(((SW_u64)(x) & (SW_u64)0x000000000000ff00ULL) << 40) | \
81  (SW_u64)(((SW_u64)(x) & (SW_u64)0x0000000000ff0000ULL) << 24) | \
82  (SW_u64)(((SW_u64)(x) & (SW_u64)0x00000000ff000000ULL) << 8) | \
83  (SW_u64)(((SW_u64)(x) & (SW_u64)0x000000ff00000000ULL) >> 8) | \
84  (SW_u64)(((SW_u64)(x) & (SW_u64)0x0000ff0000000000ULL) >> 24) | \
85  (SW_u64)(((SW_u64)(x) & (SW_u64)0x00ff000000000000ULL) >> 40) | \
86  (SW_u64)(((SW_u64)(x) & (SW_u64)0xff00000000000000ULL) >> 56) ))
87 
88 
89 
90 
91 #ifndef WORDS_BIGENDIAN
92 
93 #define swordtoarch16(x) (x)
94 #define swordtoarch32(x) (x)
95 #define swordtoarch64(x) (x)
96 #define archtosword16(x) (x)
97 #define archtosword32(x) (x)
98 #define archtosword64(x) (x)
99 
100 #else
101 
102 #define swordtoarch16(x) __swswap16(x)
103 #define swordtoarch32(x) __swswap32(x)
104 #define swordtoarch64(x) __swswap64(x)
105 #define archtosword16(x) __swswap16(x)
106 #define archtosword32(x) __swswap32(x)
107 #define archtosword64(x) __swswap64(x)
108 
109 
110 #endif
111 
112 
113 #endif
signed int SW_s32
Definition: sysdata.h:40
unsigned char SW_u8
Definition: sysdata.h:35
unsigned short SW_u16
Definition: sysdata.h:38
signed long long SW_s64
Definition: sysdata.h:55
unsigned long long SW_u64
Definition: sysdata.h:56
unsigned int SW_u32
Definition: sysdata.h:41
signed char SW_s8
Definition: sysdata.h:34
signed short SW_s16
Definition: sysdata.h:37