|
1 |
| -/* Copyright (c) (2010-2012,2014-2021) Apple Inc. All rights reserved. |
| 1 | +/* Copyright (c) (2010-2012,2014-2022) Apple Inc. All rights reserved. |
2 | 2 | *
|
3 | 3 | * corecrypto is licensed under Apple Inc.’s Internal Use License Agreement (which
|
4 | 4 | * is contained in the License.txt file distributed with corecrypto) and only to
|
|
19 | 19 | #include <string.h>
|
20 | 20 | #include <stdint.h>
|
21 | 21 | #include <stdbool.h>
|
| 22 | +#include <stddef.h> |
| 23 | +#include <stdarg.h> |
22 | 24 |
|
23 | 25 | CC_PTRCHECK_CAPABLE_HEADER()
|
24 | 26 |
|
@@ -82,13 +84,13 @@ __attribute__((availability(bridgeos,unavailable)))
|
82 | 84 | #include <assert.h>
|
83 | 85 | #endif
|
84 | 86 |
|
85 |
| -/* Provide a static assert that can be used to create compile-type failures, |
86 |
| - except on GCC which does not support the function when "e" comes from a |
87 |
| - const value. */ |
88 |
| -#ifndef __GNUC__ |
89 |
| -#define cc_static_assert(e, m) enum { cc_concat(static_assert_, __COUNTER__) = 1 / (int)(!!(e)) } |
| 87 | +/* Provide a static assert that can be used to create compile-type failures. */ |
| 88 | +#if __has_feature(c_static_assert) || __has_extension(c_static_assert) |
| 89 | + #define cc_static_assert(e, m) _Static_assert(e, m) |
| 90 | +#elif !defined(__GNUC__) |
| 91 | + #define cc_static_assert(e, m) enum { cc_concat(static_assert_, __COUNTER__) = 1 / (int)(!!(e)) } |
90 | 92 | #else
|
91 |
| -#define cc_static_assert(e, m) |
| 93 | + #define cc_static_assert(e, m) |
92 | 94 | #endif
|
93 | 95 |
|
94 | 96 | /* Declare a struct element with a guarenteed alignment of _alignment_.
|
@@ -179,17 +181,9 @@ uint8_t b[_alignment_]; \
|
179 | 181 | CC_NONNULL((2))
|
180 | 182 | void cc_clear(size_t len, void *cc_sized_by(len) dst);
|
181 | 183 |
|
182 |
| -// cc_zero is deprecated, please use cc_clear instead. |
183 |
| -cc_deprecate_with_replacement("cc_clear", 13.0, 10.15, 13.0, 6.0, 4.0) |
184 |
| -CC_NONNULL_ALL CC_INLINE |
185 |
| -void cc_zero(size_t len, void *cc_sized_by(len) dst) |
186 |
| -{ |
187 |
| - cc_clear(len, dst); |
188 |
| -} |
189 |
| - |
190 | 184 | #define cc_copy(_size_, _dst_, _src_) memcpy(_dst_, _src_, _size_)
|
191 | 185 |
|
192 |
| -CC_INLINE CC_NONNULL((2, 3, 4)) |
| 186 | +CC_INLINE CC_NONNULL((2)) |
193 | 187 | void cc_xor(size_t size, void *cc_sized_by(size) r, const void *cc_sized_by(size) s, const void *cc_sized_by(size) t) {
|
194 | 188 | uint8_t *_r=(uint8_t *)r;
|
195 | 189 | const uint8_t *_s=(const uint8_t *)s;
|
@@ -242,4 +236,11 @@ int cc_cmp_safe (size_t num, const void * cc_sized_by(num) ptr1, const void * cc
|
242 | 236 | #define CC_SPTR(_sn_, _n_) _n_
|
243 | 237 | #endif
|
244 | 238 |
|
| 239 | +// Similar to the iovec type used in scatter-gather APIs like readv() |
| 240 | +// and writev(). |
| 241 | +typedef struct cc_iovec { |
| 242 | + const void *base; |
| 243 | + size_t nbytes; |
| 244 | +} cc_iovec_t; |
| 245 | + |
245 | 246 | #endif /* _CORECRYPTO_CC_H_ */
|
0 commit comments