Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: srtp/crypto/include/integers.h

Issue 2344973002: Update libsrtp to version 2.0 (Closed)
Patch Set: Add '.' back to include_dirs Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « srtp/crypto/include/hmac.h ('k') | srtp/crypto/include/kernel_compat.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * integers.h
3 *
4 * defines integer types (or refers to their definitions)
5 *
6 * David A. McGrew
7 * Cisco Systems, Inc.
8 */
9
10 /*
11 *
12 * Copyright (c) 2001-2006, Cisco Systems, Inc.
13 * All rights reserved.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 *
19 * Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 *
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.
26 *
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.
30 *
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.
43 *
44 */
45
46
47 #ifndef INTEGERS_H
48 #define INTEGERS_H
49
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 */
58 #ifdef HAVE_STDLIB_H
59 # include <stdlib.h>
60 #endif
61 #ifdef HAVE_STDINT_H
62 # include <stdint.h>
63 #endif
64 #ifdef HAVE_INTTYPES_H
65 # include <inttypes.h>
66 #endif
67 #ifdef HAVE_SYS_TYPES_H
68 # include <sys/types.h>
69 #endif
70 #ifdef HAVE_SYS_INT_TYPES_H
71 # include <sys/int_types.h> /* this exists on Sun OS */
72 #endif
73 #ifdef HAVE_MACHINE_TYPES_H
74 # include <machine/types.h>
75 #endif
76
77 /* Can we do 64 bit integers? */
78 #if !defined(HAVE_UINT64_T)
79 # if SIZEOF_UNSIGNED_LONG == 8
80 typedef unsigned long uint64_t;
81 # elif SIZEOF_UNSIGNED_LONG_LONG == 8
82 typedef unsigned long long uint64_t;
83 # else
84 # define NO_64BIT_MATH 1
85 # endif
86 #endif
87
88 /* Reasonable defaults for 32 bit machines - you may need to
89 * edit these definitions for your own machine. */
90 #ifndef HAVE_UINT8_T
91 typedef unsigned char uint8_t;
92 #endif
93 #ifndef HAVE_UINT16_T
94 typedef unsigned short int uint16_t;
95 #endif
96 #ifndef HAVE_UINT32_T
97 typedef unsigned int uint32_t;
98 #endif
99
100
101 #if defined(NO_64BIT_MATH) && defined(HAVE_CONFIG_H)
102 typedef double uint64_t;
103 /* assert that sizeof(double) == 8 */
104 extern uint64_t make64(uint32_t high, uint32_t low);
105 extern uint32_t high32(uint64_t value);
106 extern uint32_t low32(uint64_t value);
107 #endif
108
109 #endif /* SRTP_KERNEL */
110
111 /* 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
113 loads. */
114 #ifdef ALIGNMENT_32BIT_REQUIRED
115 /* Note that if it's in a variable, you can memcpy it */
116 #ifdef WORDS_BIGENDIAN
117 #define PUT_32(addr,value) \
118 { \
119 ((unsigned char *) (addr))[0] = (value >> 24); \
120 ((unsigned char *) (addr))[1] = (value >> 16) & 0xff; \
121 ((unsigned char *) (addr))[2] = (value >> 8) & 0xff; \
122 ((unsigned char *) (addr))[3] = (value) & 0xff; \
123 }
124 #define GET_32(addr) ((((unsigned char *) (addr))[0] << 24) | \
125 (((unsigned char *) (addr))[1] << 16) | \
126 (((unsigned char *) (addr))[2] << 8) | \
127 (((unsigned char *) (addr))[3]))
128 #else
129 #define PUT_32(addr,value) \
130 { \
131 ((unsigned char *) (addr))[3] = (value >> 24); \
132 ((unsigned char *) (addr))[2] = (value >> 16) & 0xff; \
133 ((unsigned char *) (addr))[1] = (value >> 8) & 0xff; \
134 ((unsigned char *) (addr))[0] = (value) & 0xff; \
135 }
136 #define GET_32(addr) ((((unsigned char *) (addr))[3] << 24) | \
137 (((unsigned char *) (addr))[2] << 16) | \
138 (((unsigned char *) (addr))[1] << 8) | \
139 (((unsigned char *) (addr))[0]))
140 #endif // WORDS_BIGENDIAN
141 #else
142 #define PUT_32(addr,value) *(((uint32_t *) (addr)) = (value)
143 #define GET_32(addr) (*(((uint32_t *) (addr)))
144 #endif
145
146 #endif /* INTEGERS_H */
OLDNEW
« no previous file with comments | « srtp/crypto/include/hmac.h ('k') | srtp/crypto/include/kernel_compat.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698