modified: pixi.toml
[GalaxyCodeBases.git] / etc / Windows / vlmcsd_old_vancepym / endian.c
blobe2bb76c5272a1ac77ed789eee8ba91e168524e92
1 #ifndef CONFIG
2 #define CONFIG "config.h"
3 #endif // CONFIG
4 #include CONFIG
6 #include "endian.h"
8 #if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN) \
9 && defined(BS16) && defined(BS32) && defined(BS64)
11 #else // ! defined(__BYTE_ORDER)
13 void PUT_UAA64BE(void *p, unsigned long long v, unsigned int i)
15 unsigned char *_p = (unsigned char *)&((unsigned long long *)p)[i];
16 _p[ 0 ] = v >> 56;
17 _p[ 1 ] = v >> 48;
18 _p[ 2 ] = v >> 40;
19 _p[ 3 ] = v >> 32;
20 _p[ 4 ] = v >> 24;
21 _p[ 5 ] = v >> 16;
22 _p[ 6 ] = v >> 8;
23 _p[ 7 ] = v;
26 void PUT_UAA32BE(void *p, unsigned int v, unsigned int i)
28 unsigned char *_p = (unsigned char *)&((unsigned int *)p)[i];
29 _p[ 0 ] = v >> 24;
30 _p[ 1 ] = v >> 16;
31 _p[ 2 ] = v >> 8;
32 _p[ 3 ] = v;
35 void PUT_UAA16BE(void *p, unsigned short v, unsigned int i)
37 unsigned char *_p = (unsigned char *)&((unsigned short *)p)[i];
38 _p[ 0 ] = v >> 8;
39 _p[ 1 ] = v;
43 void PUT_UAA64LE(void *p, unsigned long long v, unsigned int i)
45 unsigned char *_p = (unsigned char *)&((unsigned long long *)p)[i];
46 _p[ 0 ] = v;
47 _p[ 1 ] = v >> 8;
48 _p[ 2 ] = v >> 16;
49 _p[ 3 ] = v >> 24;
50 _p[ 4 ] = v >> 32;
51 _p[ 5 ] = v >> 40;
52 _p[ 6 ] = v >> 48;
53 _p[ 7 ] = v >> 56;
56 void PUT_UAA32LE(void *p, unsigned int v, unsigned int i)
58 unsigned char *_p = (unsigned char *)&((unsigned int *)p)[i];
59 _p[ 0 ] = v;
60 _p[ 1 ] = v >> 8;
61 _p[ 2 ] = v >> 16;
62 _p[ 3 ] = v >> 24;
65 void PUT_UAA16LE(void *p, unsigned short v, unsigned int i)
67 unsigned char *_p = (unsigned char *)&((unsigned short *)p)[i];
68 _p[ 0 ] = v;
69 _p[ 1 ] = v >> 8;
73 unsigned long long GET_UAA64BE(void *p, unsigned int i)
75 unsigned char *_p = (unsigned char *)&((unsigned long long *)p)[i];
76 return
77 (unsigned long long)_p[ 0 ] << 56 |
78 (unsigned long long)_p[ 1 ] << 48 |
79 (unsigned long long)_p[ 2 ] << 40 |
80 (unsigned long long)_p[ 3 ] << 32 |
81 (unsigned long long)_p[ 4 ] << 24 |
82 (unsigned long long)_p[ 5 ] << 16 |
83 (unsigned long long)_p[ 6 ] << 8 |
84 (unsigned long long)_p[ 7 ];
88 unsigned int GET_UAA32BE(void *p, unsigned int i)
90 unsigned char *_p = (unsigned char *)&((unsigned int *)p)[i];
91 return
92 (unsigned int)_p[ 0 ] << 24 |
93 (unsigned int)_p[ 1 ] << 16 |
94 (unsigned int)_p[ 2 ] << 8 |
95 (unsigned int)_p[ 3 ];
98 unsigned short GET_UAA16BE(void *p, unsigned int i)
100 unsigned char *_p = (unsigned char *)&((unsigned short *)p)[i];
101 return
102 (unsigned short)_p[ 0 ] << 8 |
103 (unsigned short)_p[ 1 ];
107 unsigned long long GET_UAA64LE(void *p, unsigned int i)
109 unsigned char *_p = (unsigned char *)&((unsigned long long *)p)[i];
110 return
111 (unsigned long long)_p[ 0 ] |
112 (unsigned long long)_p[ 1 ] << 8 |
113 (unsigned long long)_p[ 2 ] << 16 |
114 (unsigned long long)_p[ 3 ] << 24 |
115 (unsigned long long)_p[ 4 ] << 32 |
116 (unsigned long long)_p[ 5 ] << 40 |
117 (unsigned long long)_p[ 6 ] << 48 |
118 (unsigned long long)_p[ 7 ] << 56;
122 unsigned int GET_UAA32LE(void *p, unsigned int i)
124 unsigned char *_p = (unsigned char *)&((unsigned int *)p)[i];
125 return
126 (unsigned int)_p[ 0 ] |
127 (unsigned int)_p[ 1 ] << 8 |
128 (unsigned int)_p[ 2 ] << 16 |
129 (unsigned int)_p[ 3 ] << 24;
132 unsigned short GET_UAA16LE(void *p, unsigned int i)
134 unsigned char *_p = (unsigned char *)&((unsigned short *)p)[i];
135 return
136 (unsigned short)_p[ 0 ] |
137 (unsigned short)_p[ 1 ] << 8;
141 unsigned short BE16(unsigned short x)
143 return GET_UAA16BE(&x, 0);
146 unsigned short LE16(unsigned short x)
148 return GET_UAA16LE(&x, 0);
151 unsigned int BE32(unsigned int x)
153 return GET_UAA32BE(&x, 0);
156 unsigned int LE32(unsigned int x)
158 return GET_UAA32LE(&x, 0);
161 unsigned long long BE64(unsigned long long x)
163 return GET_UAA64BE(&x, 0);
166 inline unsigned long long LE64(unsigned long long x)
168 return GET_UAA64LE(&x, 0);
171 #endif // defined(__BYTE_ORDER)