apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davi Arnaut <d...@haxent.com.br>
Subject apr_ssize_t and APR_SSIZE_T_FMT
Date Sun, 08 Jul 2007 03:38:33 GMT
Hi,

While updating apr (trunk) on one of my firewalls (OpenBSD 3.9) I found
out that OpenBSD is yet another system where apr mis-detect apr_size_t
and apr_ssize_t (printf) formats:

#define APR_SSIZE_T_FMT "d"
#define APR_SIZE_T_FMT "d"

I think we could improve the (autoconf) format detection by:

1) Using __builtin_types_compatible_p (available since gcc-3.1)

This gcc built-in can be used to determine if two types are the same,
and it ignores top level qualifiers (volatile, const, etc).

	if (__builtin_types_compatible_p(ssize_t, int))
		puts("int - %d");
	else if (__builtin_types_compatible_p(ssize_t, long))
		puts("long - %ld");

2) First checking if the ssize_t type size is equal to long size, which
seems true on most systems.

-if test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_int"; then
+if test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_long"; then
+    ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
+elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_int"; then
     ssize_t_fmt='#define APR_SSIZE_T_FMT "d"'
-elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_long"; then
-    ssize_t_fmt='#define APR_SSIZE_T_FMT "ld"'
 else
     ssize_t_fmt='#error Can not determine the proper size for ssize_t'
 fi

Comments?

--
Davi Arnaut

Mime
View raw message