diff options
author | Pauli <pauli@openssl.org> | 2022-05-19 12:23:55 +1000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2022-05-23 09:52:54 +1000 |
commit | 27e8f212d8383e78e698d7049c210b13a0cc8889 (patch) | |
tree | 347a0c3f47f669b3f6a1ba85b301a6804d5129ab /include/crypto | |
parent | ff3e71b33c3f0f2da189b102afe13e074c85646a (diff) |
tolower: refine the tolower code to avoid a memory access
This improves the performance of this function and the ones that rely on it
(ossl_lh_strcasehash primarily).
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/18344)
(cherry picked from commit 286053fc8f78e34828a576830ef879c021640aee)
Diffstat (limited to 'include/crypto')
-rw-r--r-- | include/crypto/ctype.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/include/crypto/ctype.h b/include/crypto/ctype.h index 6deee3b947..22f6922183 100644 --- a/include/crypto/ctype.h +++ b/include/crypto/ctype.h @@ -22,6 +22,8 @@ # define OSSL_CRYPTO_CTYPE_H # pragma once +# include <openssl/e_os2.h> + # define CTYPE_MASK_lower 0x1 # define CTYPE_MASK_upper 0x2 # define CTYPE_MASK_digit 0x4 @@ -55,10 +57,15 @@ int ossl_fromascii(int c); # define ossl_fromascii(c) (c) # endif int ossl_ctype_check(int c, unsigned int mask); + int ossl_tolower(int c); int ossl_toupper(int c); -int ossl_ascii_isdigit(const char inchar); +int ossl_isdigit(int c); +int ossl_islower(int c); +int ossl_isupper(int c); + +int ossl_ascii_isdigit(int c); # define ossl_isalnum(c) (ossl_ctype_check((c), CTYPE_MASK_alnum)) # define ossl_isalpha(c) (ossl_ctype_check((c), CTYPE_MASK_alpha)) @@ -69,13 +76,10 @@ int ossl_ascii_isdigit(const char inchar); # endif # define ossl_isblank(c) (ossl_ctype_check((c), CTYPE_MASK_blank)) # define ossl_iscntrl(c) (ossl_ctype_check((c), CTYPE_MASK_cntrl)) -# define ossl_isdigit(c) (ossl_ctype_check((c), CTYPE_MASK_digit)) # define ossl_isgraph(c) (ossl_ctype_check((c), CTYPE_MASK_graph)) -# define ossl_islower(c) (ossl_ctype_check((c), CTYPE_MASK_lower)) # define ossl_isprint(c) (ossl_ctype_check((c), CTYPE_MASK_print)) # define ossl_ispunct(c) (ossl_ctype_check((c), CTYPE_MASK_punct)) # define ossl_isspace(c) (ossl_ctype_check((c), CTYPE_MASK_space)) -# define ossl_isupper(c) (ossl_ctype_check((c), CTYPE_MASK_upper)) # define ossl_isxdigit(c) (ossl_ctype_check((c), CTYPE_MASK_xdigit)) # define ossl_isbase64(c) (ossl_ctype_check((c), CTYPE_MASK_base64)) # define ossl_isasn1print(c) (ossl_ctype_check((c), CTYPE_MASK_asn1print)) |