> # if defined(OPENSSL_SYS_UEFI) && !defined(ssize_t) # define ossl_ssize_t > int # define OSSL_SSIZE_MAX INT_MAX # endif > > It's testing for a #define, not a typedef. > > > Then I suppose this comes down to understanding precisely what the test is > trying to achieve. Do you mean it's explicitly checking for ssize_t being a > macro rather than the usual typedef? Does OpenSSL create it as a macro > somewhere?
If I am parsing things correctly (in the big picture), ossl_ssize_t and OSSL_SSIZE_MAX are trying to bootstrap themselves. If ssize_t and SSIZE_MAX are available, ossl_ssize_t and OSSL_SSIZE_MAX should set themselves to existing types and define. Otherwise, ossl_ssize_t and OSSL_SSIZE_MAX provide their own definition. I think that's what's trying to be achieved. I can kinda understand the "if defined(ossl_ssize_t)". However, the base case - the first time its encountered undefined - may be missing the point. > POSIX requires ssize_t to be a type rather than a macro, defined in > <sys/types.h> among other places. I don't know it there are non-POSIX or > vaguely-similar-to-POSIX environments which define it as a macro. Its those non-Posix environments the pain point is experienced. ANSI is one of them. That's because the bootstrapping isn't quite right. I've also seem some interesting results on Android. The test rig is simple enough. It seems some of the older environments (maybe the newer ones too) don't undef SSIZE_MAX; rather, they set it to 0. Jeff $ cat test.cc #include <stdio.h> #include <limits.h> #include <unistd.h> /* gcc -x c -ansi test.cc -o test.exe */ int main(void) { #if defined(SSIZE_MAX) && (SSIZE_MAX != 0) #define my_ssize_t ssize_t #define MY_SSIZE_MAX SSIZE_MAX printf("SSIZE_MAX is defined, using ssize_t\n"); my_ssize_t t = MY_SSIZE_MAX; #else /* not SSIZE_MAX */ # if (__LP64__) #define my_ssize_t long #define MY_SSIZE_MAX LONG_MAX printf("SSIZE_MAX not defined, typing ssize_t to long\n"); my_ssize_t t = MY_SSIZE_MAX; # else #define my_ssize_t int #define MY_SSIZE_MAX INT_MAX printf("SSIZE_MAX not defined, typing ssize_t to int\n"); my_ssize_t t = MY_SSIZE_MAX; # endif #endif /* SSIZE_MAX */ return 0; } ********** i686 without -ansi: $ ./test.exe SSIZE_MAX is defined, using ssize_t i686 with -ansi: $ ./test.exe SSIZE_MAX not defined, typing ssize_t to int x86_64 without -ansi: $ ./test.exe SSIZE_MAX is defined, using ssize_t x86_64 with -ansi: $ ./test.exe SSIZE_MAX not defined, typing ssize_t to long -- openssl-dev mailing list To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-dev