4
* defines integer types (or refers to their definitions)
12
* Copyright (c) 2001-2006, Cisco Systems, Inc.
13
* All rights reserved.
15
* Redistribution and use in source and binary forms, with or without
16
* modification, are permitted provided that the following conditions
19
* Redistributions of source code must retain the above copyright
20
* notice, this list of conditions and the following disclaimer.
22
* Redistributions in binary form must reproduce the above
23
* copyright notice, this list of conditions and the following
24
* disclaimer in the documentation and/or other materials provided
25
* with the distribution.
27
* Neither the name of the Cisco Systems, Inc. nor the names of its
28
* contributors may be used to endorse or promote products derived
29
* from this software without specific prior written permission.
31
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
34
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
35
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
36
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
38
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
41
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
42
* OF THE POSSIBILITY OF SUCH DAMAGE.
50
#include "srtp_config.h" /* configuration file, using autoconf */
54
#include "kernel_compat.h"
56
#else /* SRTP_KERNEL */
58
/* use standard integer definitions, if they're available */
65
#ifdef HAVE_INTTYPES_H
66
# include <inttypes.h>
68
#ifdef HAVE_SYS_TYPES_H
69
# include <sys/types.h>
71
#ifdef HAVE_SYS_INT_TYPES_H
72
# include <sys/int_types.h> /* this exists on Sun OS */
74
#ifdef HAVE_MACHINE_TYPES_H
75
# include <machine/types.h>
78
/* Can we do 64 bit integers? */
80
# if SIZEOF_UNSIGNED_LONG == 8
81
typedef unsigned long uint64_t;
82
# elif SIZEOF_UNSIGNED_LONG_LONG == 8
83
typedef unsigned long long uint64_t;
85
# define NO_64BIT_MATH 1
89
/* Reasonable defaults for 32 bit machines - you may need to
90
* edit these definitions for your own machine. */
92
typedef unsigned char uint8_t;
95
typedef unsigned short int uint16_t;
98
typedef unsigned int uint32_t;
103
typedef double uint64_t;
104
/* assert that sizeof(double) == 8 */
105
extern uint64_t make64(uint32_t high, uint32_t low);
106
extern uint32_t high32(uint64_t value);
107
extern uint32_t low32(uint64_t value);
110
#endif /* SRTP_KERNEL */
112
/* These macros are to load and store 32-bit values from un-aligned
113
addresses. This is required for processors that do not allow unaligned
115
#ifdef ALIGNMENT_32BIT_REQUIRED
116
/* Note that if it's in a variable, you can memcpy it */
117
#ifdef WORDS_BIGENDIAN
118
#define PUT_32(addr,value) \
120
((unsigned char *) (addr))[0] = (value >> 24); \
121
((unsigned char *) (addr))[1] = (value >> 16) & 0xff; \
122
((unsigned char *) (addr))[2] = (value >> 8) & 0xff; \
123
((unsigned char *) (addr))[3] = (value) & 0xff; \
125
#define GET_32(addr) ((((unsigned char *) (addr))[0] << 24) | \
126
(((unsigned char *) (addr))[1] << 16) | \
127
(((unsigned char *) (addr))[2] << 8) | \
128
(((unsigned char *) (addr))[3]))
130
#define PUT_32(addr,value) \
132
((unsigned char *) (addr))[3] = (value >> 24); \
133
((unsigned char *) (addr))[2] = (value >> 16) & 0xff; \
134
((unsigned char *) (addr))[1] = (value >> 8) & 0xff; \
135
((unsigned char *) (addr))[0] = (value) & 0xff; \
137
#define GET_32(addr) ((((unsigned char *) (addr))[3] << 24) | \
138
(((unsigned char *) (addr))[2] << 16) | \
139
(((unsigned char *) (addr))[1] << 8) | \
140
(((unsigned char *) (addr))[0]))
141
#endif // WORDS_BIGENDIAN
143
#define PUT_32(addr,value) *(((uint32_t *) (addr)) = (value)
144
#define GET_32(addr) (*(((uint32_t *) (addr)))
147
#endif /* INTEGERS_H */