OLD | NEW |
1 /* | 1 /* |
2 * integers.h | 2 * integers.h |
3 * | 3 * |
4 * defines integer types (or refers to their definitions) | 4 * defines integer types (or refers to their definitions) |
5 * | 5 * |
6 * David A. McGrew | 6 * David A. McGrew |
7 * Cisco Systems, Inc. | 7 * Cisco Systems, Inc. |
8 */ | 8 */ |
9 | 9 |
10 /* | 10 /* |
(...skipping 29 matching lines...) Expand all Loading... |
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
41 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 41 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
42 * OF THE POSSIBILITY OF SUCH DAMAGE. | 42 * OF THE POSSIBILITY OF SUCH DAMAGE. |
43 * | 43 * |
44 */ | 44 */ |
45 | 45 |
46 | 46 |
47 #ifndef INTEGERS_H | 47 #ifndef INTEGERS_H |
48 #define INTEGERS_H | 48 #define INTEGERS_H |
49 | 49 |
50 #include "config.h" /* configuration file, using autoconf */ | |
51 | 50 |
52 #ifdef SRTP_KERNEL | 51 #ifdef SRTP_KERNEL |
53 | 52 |
54 #include "kernel_compat.h" | 53 #include "kernel_compat.h" |
55 | 54 |
56 #else /* SRTP_KERNEL */ | 55 #else /* SRTP_KERNEL */ |
57 | 56 |
58 /* use standard integer definitions, if they're available */ | 57 /* use standard integer definitions, if they're available */ |
59 #ifdef HAVE_STDLIB_H | 58 #ifdef HAVE_STDLIB_H |
60 # include <stdlib.h> | 59 # include <stdlib.h> |
61 #endif | 60 #endif |
62 #ifdef HAVE_STDINT_H | 61 #ifdef HAVE_STDINT_H |
63 # include <stdint.h> | 62 # include <stdint.h> |
64 #endif | 63 #endif |
65 #ifdef HAVE_INTTYPES_H | 64 #ifdef HAVE_INTTYPES_H |
66 # include <inttypes.h> | 65 # include <inttypes.h> |
67 #endif | 66 #endif |
68 #ifdef HAVE_SYS_TYPES_H | 67 #ifdef HAVE_SYS_TYPES_H |
69 # include <sys/types.h> | 68 # include <sys/types.h> |
70 #endif | 69 #endif |
71 #ifdef HAVE_SYS_INT_TYPES_H | 70 #ifdef HAVE_SYS_INT_TYPES_H |
72 # include <sys/int_types.h> /* this exists on Sun OS */ | 71 # include <sys/int_types.h> /* this exists on Sun OS */ |
73 #endif | 72 #endif |
74 #ifdef HAVE_MACHINE_TYPES_H | 73 #ifdef HAVE_MACHINE_TYPES_H |
75 # include <machine/types.h> | 74 # include <machine/types.h> |
76 #endif | 75 #endif |
77 | 76 |
78 /* Can we do 64 bit integers? */ | 77 /* Can we do 64 bit integers? */ |
79 #ifndef HAVE_UINT64_T | 78 #if !defined(HAVE_UINT64_T) |
80 # if SIZEOF_UNSIGNED_LONG == 8 | 79 # if SIZEOF_UNSIGNED_LONG == 8 |
81 typedef unsigned long uint64_t; | 80 typedef unsigned long uint64_t; |
82 # elif SIZEOF_UNSIGNED_LONG_LONG == 8 | 81 # elif SIZEOF_UNSIGNED_LONG_LONG == 8 |
83 typedef unsigned long long uint64_t; | 82 typedef unsigned long long uint64_t; |
84 # else | 83 # else |
85 # define NO_64BIT_MATH 1 | 84 # define NO_64BIT_MATH 1 |
86 # endif | 85 # endif |
87 #endif | 86 #endif |
88 | 87 |
89 /* Reasonable defaults for 32 bit machines - you may need to | 88 /* Reasonable defaults for 32 bit machines - you may need to |
90 * edit these definitions for your own machine. */ | 89 * edit these definitions for your own machine. */ |
91 #ifndef HAVE_UINT8_T | 90 #ifndef HAVE_UINT8_T |
92 typedef unsigned char uint8_t; | 91 typedef unsigned char uint8_t; |
93 #endif | 92 #endif |
94 #ifndef HAVE_UINT16_T | 93 #ifndef HAVE_UINT16_T |
95 typedef unsigned short int uint16_t; | 94 typedef unsigned short int uint16_t; |
96 #endif | 95 #endif |
97 #ifndef HAVE_UINT32_T | 96 #ifndef HAVE_UINT32_T |
98 typedef unsigned int uint32_t; | 97 typedef unsigned int uint32_t; |
99 #endif | 98 #endif |
100 | 99 |
101 | 100 |
102 #ifdef NO_64BIT_MATH | 101 #if defined(NO_64BIT_MATH) && defined(HAVE_CONFIG_H) |
103 typedef double uint64_t; | 102 typedef double uint64_t; |
104 /* assert that sizeof(double) == 8 */ | 103 /* assert that sizeof(double) == 8 */ |
105 extern uint64_t make64(uint32_t high, uint32_t low); | 104 extern uint64_t make64(uint32_t high, uint32_t low); |
106 extern uint32_t high32(uint64_t value); | 105 extern uint32_t high32(uint64_t value); |
107 extern uint32_t low32(uint64_t value); | 106 extern uint32_t low32(uint64_t value); |
108 #endif | 107 #endif |
109 | 108 |
110 #endif /* SRTP_KERNEL */ | 109 #endif /* SRTP_KERNEL */ |
111 | 110 |
112 /* These macros are to load and store 32-bit values from un-aligned | 111 /* These macros are to load and store 32-bit values from un-aligned |
(...skipping 25 matching lines...) Expand all Loading... |
138 (((unsigned char *) (addr))[2] << 16) | \ | 137 (((unsigned char *) (addr))[2] << 16) | \ |
139 (((unsigned char *) (addr))[1] << 8) | \ | 138 (((unsigned char *) (addr))[1] << 8) | \ |
140 (((unsigned char *) (addr))[0])) | 139 (((unsigned char *) (addr))[0])) |
141 #endif // WORDS_BIGENDIAN | 140 #endif // WORDS_BIGENDIAN |
142 #else | 141 #else |
143 #define PUT_32(addr,value) *(((uint32_t *) (addr)) = (value) | 142 #define PUT_32(addr,value) *(((uint32_t *) (addr)) = (value) |
144 #define GET_32(addr) (*(((uint32_t *) (addr))) | 143 #define GET_32(addr) (*(((uint32_t *) (addr))) |
145 #endif | 144 #endif |
146 | 145 |
147 #endif /* INTEGERS_H */ | 146 #endif /* INTEGERS_H */ |
OLD | NEW |