| 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 30 matching lines...) Expand all Loading... |
| 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 | 50 |
| 51 #ifdef SRTP_KERNEL | |
| 52 | |
| 53 #include "kernel_compat.h" | |
| 54 | |
| 55 #else /* SRTP_KERNEL */ | |
| 56 | |
| 57 /* use standard integer definitions, if they're available */ | 51 /* use standard integer definitions, if they're available */ |
| 58 #ifdef HAVE_STDLIB_H | 52 #ifdef HAVE_STDLIB_H |
| 59 # include <stdlib.h> | 53 # include <stdlib.h> |
| 60 #endif | 54 #endif |
| 61 #ifdef HAVE_STDINT_H | 55 #ifdef HAVE_STDINT_H |
| 62 # include <stdint.h> | 56 # include <stdint.h> |
| 63 #endif | 57 #endif |
| 64 #ifdef HAVE_INTTYPES_H | 58 #ifdef HAVE_INTTYPES_H |
| 65 # include <inttypes.h> | 59 # include <inttypes.h> |
| 66 #endif | 60 #endif |
| 67 #ifdef HAVE_SYS_TYPES_H | 61 #ifdef HAVE_SYS_TYPES_H |
| 68 # include <sys/types.h> | 62 # include <sys/types.h> |
| 69 #endif | 63 #endif |
| 70 #ifdef HAVE_SYS_INT_TYPES_H | 64 #ifdef HAVE_SYS_INT_TYPES_H |
| 71 # include <sys/int_types.h> /* this exists on Sun OS */ | 65 # include <sys/int_types.h> /* this exists on Sun OS */ |
| 72 #endif | 66 #endif |
| 73 #ifdef HAVE_MACHINE_TYPES_H | 67 #ifdef HAVE_MACHINE_TYPES_H |
| 74 # include <machine/types.h> | 68 # include <machine/types.h> |
| 75 #endif | 69 #endif |
| 76 | 70 |
| 71 #ifdef __cplusplus |
| 72 extern "C" { |
| 73 #endif |
| 74 |
| 77 /* Can we do 64 bit integers? */ | 75 /* Can we do 64 bit integers? */ |
| 78 #if !defined(HAVE_UINT64_T) | 76 #if !defined(HAVE_UINT64_T) |
| 79 # if SIZEOF_UNSIGNED_LONG == 8 | 77 # if SIZEOF_UNSIGNED_LONG == 8 |
| 80 typedef unsigned long uint64_t; | 78 typedef unsigned long uint64_t; |
| 81 # elif SIZEOF_UNSIGNED_LONG_LONG == 8 | 79 # elif SIZEOF_UNSIGNED_LONG_LONG == 8 |
| 82 typedef unsigned long long uint64_t; | 80 typedef unsigned long long uint64_t; |
| 83 # else | 81 # else |
| 84 # define NO_64BIT_MATH 1 | 82 # define NO_64BIT_MATH 1 |
| 85 # endif | 83 # endif |
| 86 #endif | 84 #endif |
| (...skipping 12 matching lines...) Expand all Loading... |
| 99 | 97 |
| 100 | 98 |
| 101 #if defined(NO_64BIT_MATH) && defined(HAVE_CONFIG_H) | 99 #if defined(NO_64BIT_MATH) && defined(HAVE_CONFIG_H) |
| 102 typedef double uint64_t; | 100 typedef double uint64_t; |
| 103 /* assert that sizeof(double) == 8 */ | 101 /* assert that sizeof(double) == 8 */ |
| 104 extern uint64_t make64(uint32_t high, uint32_t low); | 102 extern uint64_t make64(uint32_t high, uint32_t low); |
| 105 extern uint32_t high32(uint64_t value); | 103 extern uint32_t high32(uint64_t value); |
| 106 extern uint32_t low32(uint64_t value); | 104 extern uint32_t low32(uint64_t value); |
| 107 #endif | 105 #endif |
| 108 | 106 |
| 109 #endif /* SRTP_KERNEL */ | |
| 110 | 107 |
| 111 /* These macros are to load and store 32-bit values from un-aligned | 108 /* These macros are to load and store 32-bit values from un-aligned |
| 112 addresses. This is required for processors that do not allow unaligned | 109 addresses. This is required for processors that do not allow unaligned |
| 113 loads. */ | 110 loads. */ |
| 114 #ifdef ALIGNMENT_32BIT_REQUIRED | 111 #ifdef ALIGNMENT_32BIT_REQUIRED |
| 115 /* Note that if it's in a variable, you can memcpy it */ | 112 /* Note that if it's in a variable, you can memcpy it */ |
| 116 #ifdef WORDS_BIGENDIAN | 113 #ifdef WORDS_BIGENDIAN |
| 117 #define PUT_32(addr,value) \ | 114 #define PUT_32(addr,value) \ |
| 118 { \ | 115 { \ |
| 119 ((unsigned char *) (addr))[0] = (value >> 24); \ | 116 ((unsigned char *) (addr))[0] = (value >> 24); \ |
| (...skipping 16 matching lines...) Expand all Loading... |
| 136 #define GET_32(addr) ((((unsigned char *) (addr))[3] << 24) | \ | 133 #define GET_32(addr) ((((unsigned char *) (addr))[3] << 24) | \ |
| 137 (((unsigned char *) (addr))[2] << 16) | \ | 134 (((unsigned char *) (addr))[2] << 16) | \ |
| 138 (((unsigned char *) (addr))[1] << 8) | \ | 135 (((unsigned char *) (addr))[1] << 8) | \ |
| 139 (((unsigned char *) (addr))[0])) | 136 (((unsigned char *) (addr))[0])) |
| 140 #endif // WORDS_BIGENDIAN | 137 #endif // WORDS_BIGENDIAN |
| 141 #else | 138 #else |
| 142 #define PUT_32(addr,value) *(((uint32_t *) (addr)) = (value) | 139 #define PUT_32(addr,value) *(((uint32_t *) (addr)) = (value) |
| 143 #define GET_32(addr) (*(((uint32_t *) (addr))) | 140 #define GET_32(addr) (*(((uint32_t *) (addr))) |
| 144 #endif | 141 #endif |
| 145 | 142 |
| 143 #ifdef __cplusplus |
| 144 } |
| 145 #endif |
| 146 |
| 146 #endif /* INTEGERS_H */ | 147 #endif /* INTEGERS_H */ |
| OLD | NEW |