1 | /* lzo_ptr.h -- low-level pointer constructs |
---|
2 | |
---|
3 | This file is part of the LZO real-time data compression library. |
---|
4 | |
---|
5 | Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer |
---|
6 | All Rights Reserved. |
---|
7 | |
---|
8 | The LZO library is free software; you can redistribute it and/or |
---|
9 | modify it under the terms of the GNU General Public License as |
---|
10 | published by the Free Software Foundation; either version 2 of |
---|
11 | the License, or (at your option) any later version. |
---|
12 | |
---|
13 | The LZO library is distributed in the hope that it will be useful, |
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | GNU General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with the LZO library; see the file COPYING. |
---|
20 | If not, write to the Free Software Foundation, Inc., |
---|
21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
22 | |
---|
23 | Markus F.X.J. Oberhumer |
---|
24 | <markus@oberhumer.com> |
---|
25 | http://www.oberhumer.com/opensource/lzo/ |
---|
26 | */ |
---|
27 | |
---|
28 | |
---|
29 | /* WARNING: this file should *not* be used by applications. It is |
---|
30 | part of the implementation of the library and is subject |
---|
31 | to change. |
---|
32 | */ |
---|
33 | |
---|
34 | |
---|
35 | #ifndef __LZO_PTR_H |
---|
36 | #define __LZO_PTR_H 1 |
---|
37 | |
---|
38 | #ifdef __cplusplus |
---|
39 | extern "C" { |
---|
40 | #endif |
---|
41 | |
---|
42 | |
---|
43 | /*********************************************************************** |
---|
44 | // |
---|
45 | ************************************************************************/ |
---|
46 | |
---|
47 | /* Always use the safe (=integral) version for pointer-comparisons. |
---|
48 | * The compiler should optimize away the additional casts anyway. |
---|
49 | * |
---|
50 | * Note that this only works if the representation and ordering |
---|
51 | * of the pointer and the integral is the same (at bit level). |
---|
52 | */ |
---|
53 | |
---|
54 | #if (LZO_ARCH_I086) |
---|
55 | #error "LZO_ARCH_I086 is unsupported" |
---|
56 | #elif (LZO_MM_PVP) |
---|
57 | #error "LZO_MM_PVP is unsupported" |
---|
58 | #else |
---|
59 | #define PTR(a) ((lzo_uintptr_t) (a)) |
---|
60 | #define PTR_LINEAR(a) PTR(a) |
---|
61 | #define PTR_ALIGNED_4(a) ((PTR_LINEAR(a) & 3) == 0) |
---|
62 | #define PTR_ALIGNED_8(a) ((PTR_LINEAR(a) & 7) == 0) |
---|
63 | #define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0) |
---|
64 | #define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0) |
---|
65 | #endif |
---|
66 | |
---|
67 | #define PTR_LT(a,b) (PTR(a) < PTR(b)) |
---|
68 | #define PTR_GE(a,b) (PTR(a) >= PTR(b)) |
---|
69 | #define PTR_DIFF(a,b) (PTR(a) - PTR(b)) |
---|
70 | #define pd(a,b) ((lzo_uint) ((a)-(b))) |
---|
71 | |
---|
72 | |
---|
73 | LZO_EXTERN(lzo_uintptr_t) |
---|
74 | __lzo_ptr_linear(const lzo_voidp ptr); |
---|
75 | |
---|
76 | |
---|
77 | typedef union |
---|
78 | { |
---|
79 | char a_char; |
---|
80 | unsigned char a_uchar; |
---|
81 | short a_short; |
---|
82 | unsigned short a_ushort; |
---|
83 | int a_int; |
---|
84 | unsigned int a_uint; |
---|
85 | long a_long; |
---|
86 | unsigned long a_ulong; |
---|
87 | lzo_int a_lzo_int; |
---|
88 | lzo_uint a_lzo_uint; |
---|
89 | lzo_xint a_lzo_xint; |
---|
90 | lzo_int16_t a_lzo_int16_t; |
---|
91 | lzo_uint16_t a_lzo_uint16_t; |
---|
92 | lzo_int32_t a_lzo_int32_t; |
---|
93 | lzo_uint32_t a_lzo_uint32_t; |
---|
94 | #if defined(lzo_uint64_t) |
---|
95 | lzo_int64_t a_lzo_int64_t; |
---|
96 | lzo_uint64_t a_lzo_uint64_t; |
---|
97 | #endif |
---|
98 | size_t a_size_t; |
---|
99 | ptrdiff_t a_ptrdiff_t; |
---|
100 | lzo_uintptr_t a_lzo_uintptr_t; |
---|
101 | void * a_void_p; |
---|
102 | char * a_char_p; |
---|
103 | unsigned char * a_uchar_p; |
---|
104 | const void * a_c_void_p; |
---|
105 | const char * a_c_char_p; |
---|
106 | const unsigned char * a_c_uchar_p; |
---|
107 | lzo_voidp a_lzo_voidp; |
---|
108 | lzo_bytep a_lzo_bytep; |
---|
109 | const lzo_voidp a_c_lzo_voidp; |
---|
110 | const lzo_bytep a_c_lzo_bytep; |
---|
111 | } |
---|
112 | lzo_full_align_t; |
---|
113 | |
---|
114 | |
---|
115 | |
---|
116 | #ifdef __cplusplus |
---|
117 | } /* extern "C" */ |
---|
118 | #endif |
---|
119 | |
---|
120 | #endif /* already included */ |
---|
121 | |
---|
122 | /* |
---|
123 | vi:ts=4:et |
---|
124 | */ |
---|
125 | |
---|