Refactor types that are '#define'd into proper typedefs

I looked for them with the following grep pipe, and then read through
the output to discern what are actual type definitions, and converted
what I found manually.

    git grep -En -e '#define [a-zA-Z_0-9]+ ' -- '*.h' \
        | sed -e 's|//.*||' -e 's|/\*.*\*/||g' \
        | grep -Ev ' ([0-9]|.*".*|.*\\$)'

Reviewed-by: Paul Yang <paulyang.inf@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29383)
This commit is contained in:
Richard Levitte
2025-12-12 13:56:30 +01:00
committed by Neil Horman
parent 821b265d21
commit a999136e01
14 changed files with 42 additions and 42 deletions

View File

@@ -137,7 +137,7 @@ int ossl_rsa_acvp_test_get_params(RSA *r, OSSL_PARAM params[]);
typedef struct rsa_acvp_test_st RSA_ACVP_TEST;
void ossl_rsa_acvp_test_free(RSA_ACVP_TEST *t);
#else
#define RSA_ACVP_TEST void
typedef void RSA_ACVP_TEST;
#endif
int ossl_rsa_check_factors(RSA *r);

View File

@@ -243,7 +243,7 @@ FILE *__iob_func(void);
#include <sockLib.h>
#include <taskLib.h>
#define TTY_STRUCT int
typedef int TTY_STRUCT;
#define sleep(a) taskDelay((a) * sysClkRateGet())
/*
@@ -339,7 +339,7 @@ inline int nssgetpid(void)
* There is no locale_t on NONSTOP.
*/
#if defined(OPENSSL_SYS_WINDOWS)
#define locale_t _locale_t
typedef _locale_t locale_t;
#define freelocale _free_locale
#define strcasecmp_l _stricmp_l
#define strncasecmp_l _strnicmp_l

View File

@@ -20,7 +20,7 @@
#endif
#define SM3_DIGEST_LENGTH 32
#define SM3_WORD unsigned int
typedef unsigned int SM3_WORD;
#define SM3_CBLOCK 64
#define SM3_LBLOCK (SM3_CBLOCK / 4)

View File

@@ -36,7 +36,7 @@ extern "C" {
* ! BF_LONG has to be at least 32 bits wide. !
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/
#define BF_LONG unsigned int
typedef unsigned int BF_LONG;
#define BF_ROUNDS 16

View File

@@ -34,7 +34,7 @@ extern "C" {
* 64-bit processor with LP64 ABI
*/
#ifdef SIXTY_FOUR_BIT_LONG
#define BN_ULONG unsigned long
typedef unsigned long BN_ULONG;
#define BN_BYTES 8
#endif
@@ -42,12 +42,12 @@ extern "C" {
* 64-bit processor other than LP64 ABI
*/
#ifdef SIXTY_FOUR_BIT
#define BN_ULONG unsigned long long
typedef unsigned long long BN_ULONG;
#define BN_BYTES 8
#endif
#ifdef THIRTY_TWO_BIT
#define BN_ULONG unsigned int
typedef unsigned int BN_ULONG;
#define BN_BYTES 4
#endif

View File

@@ -31,7 +31,7 @@ extern "C" {
#define CAST_ENCRYPT 1
#define CAST_DECRYPT 0
#define CAST_LONG unsigned int
typedef unsigned int CAST_LONG;
typedef struct cast_key_st {
CAST_LONG data[32];

View File

@@ -186,22 +186,22 @@ extern "C" {
#ifdef _WIN32
#ifdef _WIN64
#define ossl_ssize_t __int64
typedef __int64 ossl_ssize_t;
#define OSSL_SSIZE_MAX _I64_MAX
#else
#define ossl_ssize_t int
typedef int ossl_ssize_t;
#define OSSL_SSIZE_MAX INT_MAX
#endif
#endif
#if defined(OPENSSL_SYS_UEFI) && !defined(ossl_ssize_t)
#define ossl_ssize_t INTN
typedef INTN ossl_ssize_t;
#define OSSL_SSIZE_MAX MAX_INTN
#endif
#ifndef ossl_ssize_t
#ifndef OSSL_SSIZE_MAX
#include <sys/types.h>
#define ossl_ssize_t ssize_t
typedef ssize_t ossl_ssize_t;
#if defined(SSIZE_MAX)
#define OSSL_SSIZE_MAX SSIZE_MAX
#elif defined(_POSIX_SSIZE_MAX)

View File

@@ -34,7 +34,7 @@ extern "C" {
* ! MD4_LONG has to be at least 32 bits wide. !
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/
#define MD4_LONG unsigned int
typedef unsigned int MD4_LONG;
#define MD4_CBLOCK 64
#define MD4_LBLOCK (MD4_CBLOCK / 4)

View File

@@ -33,7 +33,7 @@ extern "C" {
* ! MD5_LONG has to be at least 32 bits wide. !
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/
#define MD5_LONG unsigned int
typedef unsigned int MD5_LONG;
#define MD5_CBLOCK 64
#define MD5_LBLOCK (MD5_CBLOCK / 4)

View File

@@ -30,7 +30,7 @@ extern "C" {
#define RC5_ENCRYPT 1
#define RC5_DECRYPT 0
#define RC5_32_INT unsigned int
typedef unsigned int RC5_32_INT;
/*
* This are the only values supported. Tweak the code if you want more The

View File

@@ -29,7 +29,7 @@ extern "C" {
#endif
#if !defined(OPENSSL_NO_DEPRECATED_3_0)
#define RIPEMD160_LONG unsigned int
typedef unsigned int RIPEMD160_LONG;
#define RIPEMD160_CBLOCK 64
#define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK / 4)

View File

@@ -31,7 +31,7 @@ extern "C" {
* ! SHA_LONG has to be at least 32 bits wide. !
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/
#define SHA_LONG unsigned int
typedef unsigned int SHA_LONG;
#define SHA_LBLOCK 16
#define SHA_CBLOCK (SHA_LBLOCK * 4) /* SHA treats input data as a \
@@ -100,11 +100,11 @@ unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md);
*/
#define SHA512_CBLOCK (SHA_LBLOCK * 8)
#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
#define SHA_LONG64 unsigned __int64
typedef unsigned __int64 SHA_LONG64;
#elif defined(__arch64__)
#define SHA_LONG64 unsigned long
typedef unsigned long SHA_LONG64;
#else
#define SHA_LONG64 unsigned long long
typedef unsigned long long SHA_LONG64;
#endif
typedef struct SHA512state_st {

View File

@@ -36,23 +36,23 @@ extern "C" {
typedef struct ossl_provider_st OSSL_PROVIDER; /* Provider Object */
#ifdef NO_ASN1_TYPEDEFS
#define ASN1_INTEGER ASN1_STRING
#define ASN1_ENUMERATED ASN1_STRING
#define ASN1_BIT_STRING ASN1_STRING
#define ASN1_OCTET_STRING ASN1_STRING
#define ASN1_PRINTABLESTRING ASN1_STRING
#define ASN1_T61STRING ASN1_STRING
#define ASN1_IA5STRING ASN1_STRING
#define ASN1_UTCTIME ASN1_STRING
#define ASN1_GENERALIZEDTIME ASN1_STRING
#define ASN1_TIME ASN1_STRING
#define ASN1_GENERALSTRING ASN1_STRING
#define ASN1_UNIVERSALSTRING ASN1_STRING
#define ASN1_BMPSTRING ASN1_STRING
#define ASN1_VISIBLESTRING ASN1_STRING
#define ASN1_UTF8STRING ASN1_STRING
#define ASN1_BOOLEAN int
#define ASN1_NULL int
typedef ASN1_STRING ASN1_INTEGER;
typedef ASN1_STRING ASN1_ENUMERATED;
typedef ASN1_STRING ASN1_BIT_STRING;
typedef ASN1_STRING ASN1_OCTET_STRING;
typedef ASN1_STRING ASN1_PRINTABLESTRING;
typedef ASN1_STRING ASN1_T61STRING;
typedef ASN1_STRING ASN1_IA5STRING;
typedef ASN1_STRING ASN1_UTCTIME;
typedef ASN1_STRING ASN1_GENERALIZEDTIME;
typedef ASN1_STRING ASN1_TIME;
typedef ASN1_STRING ASN1_GENERALSTRING;
typedef ASN1_STRING ASN1_UNIVERSALSTRING;
typedef ASN1_STRING ASN1_BMPSTRING;
typedef ASN1_STRING ASN1_VISIBLESTRING;
typedef ASN1_STRING ASN1_UTF8STRING;
typedef int ASN1_BOOLEAN;
typedef int ASN1_NULL;
#else
typedef struct asn1_string_st ASN1_INTEGER;
typedef struct asn1_string_st ASN1_ENUMERATED;