diff options
author | David Benjamin <davidben@chromium.org> | 2014-08-15 21:49:12 +0400 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2014-08-18 21:55:05 +0400 |
commit | 6f2600199c82330240de9a7f65a801b6f606b7b3 (patch) | |
tree | 4bac211624f6854a0294d89d9ce6ca640fe3742e /crypto/stack | |
parent | fb4ea28bb84875a844cd65a9e4a2167ec884cd48 (diff) |
Mark all SSL_CIPHERs as const.
This lets us put the SSL_CIPHER table in the data section. For type-checking,
make STACK_OF(SSL_CIPHER) cast everything to const SSL_CIPHER*.
Note that this will require some changes in consumers which weren't using a
const SSL_CIPHER *.
Change-Id: Iff734ac0e36f9e5c4a0f3c8411c7f727b820469c
Reviewed-on: https://boringssl-review.googlesource.com/1541
Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/stack')
-rw-r--r-- | crypto/stack/make_macros.sh | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/crypto/stack/make_macros.sh b/crypto/stack/make_macros.sh index 84ca478b..f72aa334 100644 --- a/crypto/stack/make_macros.sh +++ b/crypto/stack/make_macros.sh @@ -1,6 +1,8 @@ #!/bin/sh -cat > stack_macros.h << EOF +include_dir=../../include/openssl + +cat > "${include_dir}/stack_macros.h" << EOF /* Copyright (c) 2014, Google Inc. * * Permission to use, copy, modify, and/or distribute this software for any @@ -23,12 +25,12 @@ EOF output_stack () { type=$1 - star=$2 + ptrtype=$2 - cat >> stack_macros.h << EOF + cat >> "${include_dir}/stack_macros.h" << EOF /* ${type} */ #define sk_${type}_new(comp)\\ - ((STACK_OF(${type})*) sk_new(CHECKED_CAST(stack_cmp_func, int (*) (const ${type} *${star}a, const ${type} *${star}b), comp))) + ((STACK_OF(${type})*) sk_new(CHECKED_CAST(stack_cmp_func, int (*) (const ${ptrtype} *a, const ${ptrtype} *b), comp))) #define sk_${type}_new_null()\\ ((STACK_OF(${type})*) sk_new_null()) @@ -40,37 +42,37 @@ output_stack () { sk_zero(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk)); #define sk_${type}_value(sk, i)\\ - ((${type}${star}) sk_value(CHECKED_CAST(_STACK*, const STACK_OF(${type})*, sk), (i))) + ((${ptrtype}) sk_value(CHECKED_CAST(_STACK*, const STACK_OF(${type})*, sk), (i))) #define sk_${type}_set(sk, i, p)\\ - ((${type}${star}) sk_set(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), (i), CHECKED_CAST(void*, ${type}${star}, p))) + ((${ptrtype}) sk_set(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), (i), CHECKED_CAST(void*, ${ptrtype}, p))) #define sk_${type}_free(sk)\\ sk_free(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk)) #define sk_${type}_pop_free(sk, free_func)\\ - sk_pop_free(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), CHECKED_CAST(void (*) (void*), void (*) (${type}${star}), free_func)) + sk_pop_free(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), CHECKED_CAST(void (*) (void*), void (*) (${ptrtype}), free_func)) #define sk_${type}_insert(sk, p, where)\\ - sk_insert(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), CHECKED_CAST(void*, ${type}${star}, p), (where)) + sk_insert(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), CHECKED_CAST(void*, ${ptrtype}, p), (where)) #define sk_${type}_delete(sk, where)\\ - ((${type}${star}) sk_delete(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), (where))) + ((${ptrtype}) sk_delete(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), (where))) #define sk_${type}_delete_ptr(sk, p)\\ - ((${type}${star}) sk_delete_ptr(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), CHECKED_CAST(void*, ${type}${star}, p))) + ((${ptrtype}) sk_delete_ptr(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), CHECKED_CAST(void*, ${ptrtype}, p))) #define sk_${type}_find(sk, out_index, p)\\ - sk_find(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), (out_index), CHECKED_CAST(void*, ${type}${star}, p)) + sk_find(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), (out_index), CHECKED_CAST(void*, ${ptrtype}, p)) #define sk_${type}_shift(sk)\\ - ((${type}${star}) sk_shift(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk))) + ((${ptrtype}) sk_shift(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk))) #define sk_${type}_push(sk, p)\\ - sk_push(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), CHECKED_CAST(void*, ${type}${star}, p)) + sk_push(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk), CHECKED_CAST(void*, ${ptrtype}, p)) #define sk_${type}_pop(sk)\\ - ((${type}${star}) sk_pop(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk))) + ((${ptrtype}) sk_pop(CHECKED_CAST(_STACK*, STACK_OF(${type})*, sk))) #define sk_${type}_dup(sk)\\ ((STACK_OF(${type})*) sk_dup(CHECKED_CAST(_STACK*, const STACK_OF(${type})*, sk))) @@ -88,17 +90,23 @@ output_stack () { EOF } -stack_types=$(cat stack.h | grep '^ \* STACK_OF:' | sed -e 's/.*STACK_OF://' -e 's/ .*//') -special_stack_types=$(cat stack.h | grep '^ \* SPECIAL_STACK_OF:' | sed -e 's/.*SPECIAL_STACK_OF://' -e 's/ .*//') +stack_types=$(cat "${include_dir}/stack.h" | grep '^ \* STACK_OF:' | sed -e 's/.*STACK_OF://' -e 's/ .*//') +const_stack_types=$(cat "${include_dir}/stack.h" | grep '^ \* CONST_STACK_OF:' | sed -e 's/.*CONST_STACK_OF://' -e 's/ .*//') +special_stack_types=$(cat "${include_dir}/stack.h" | grep '^ \* SPECIAL_STACK_OF:' | sed -e 's/.*SPECIAL_STACK_OF://' -e 's/ .*//') for type in $stack_types; do echo Stack of ${type} - output_stack "${type}" "*" + output_stack "${type}" "${type} *" +done + +for type in $const_stack_types; do + echo Stack of ${type} + output_stack "${type}" "const ${type} *" done for type in $special_stack_types; do echo Stack of ${type} - output_stack "${type}" "" + output_stack "${type}" "${type}" done -clang-format -i stack_macros.h +clang-format -i "${include_dir}/stack_macros.h" |