You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by co...@apache.org on 2005/10/04 18:18:29 UTC

svn commit: r294809 - in /httpd/httpd/trunk: acinclude.m4 configure.in

Author: colm
Date: Tue Oct  4 09:18:24 2005
New Revision: 294809

URL: http://svn.apache.org/viewcvs?rev=294809&view=rev
Log:
One way or another, whether we leave the casts in or out, right now we are
using "void *" containers to store long integers; Add a configure-time check to
ensure that it is valid to assume that a "void *" container is large enough to
store a long int. See <20...@devsys.jaguNET.com> and
ensuing discussion on httpd-dev. 

Modified:
    httpd/httpd/trunk/acinclude.m4
    httpd/httpd/trunk/configure.in

Modified: httpd/httpd/trunk/acinclude.m4
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/acinclude.m4?rev=294809&r1=294808&r2=294809&view=diff
==============================================================================
--- httpd/httpd/trunk/acinclude.m4 (original)
+++ httpd/httpd/trunk/acinclude.m4 Tue Oct  4 09:18:24 2005
@@ -570,3 +570,24 @@
 undefine([ap_ckver_cvar])
 undefine([ap_ckver_name])
 ])
+
+dnl
+dnl APACHE_CHECK_VOID_PTR_LEN
+dnl
+dnl Checks if the size of a void pointer is at least as big as a "long" 
+dnl integer type.
+dnl
+AC_DEFUN([APACHE_CHECK_VOID_PTR_LEN], [
+
+AC_CACHE_CHECK([for void pointer length], [ap_void_ptr_lt_long],
+[AC_TRY_RUN([
+int main(void)
+{
+    return sizeof(void *) < sizeof(long); 
+}], [ap_void_ptr_lt_long=yes], [ap_void_ptr_lt_long=no], 
+    [ap_void_ptr_lt_long=no])])
+
+if test "$ap_void_ptr_lt_long" = "no"; then
+    AC_MSG_ERROR([Size of "void *" is less than size of "long"])
+fi
+])

Modified: httpd/httpd/trunk/configure.in
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/configure.in?rev=294809&r1=294808&r2=294809&view=diff
==============================================================================
--- httpd/httpd/trunk/configure.in (original)
+++ httpd/httpd/trunk/configure.in Tue Oct  4 09:18:24 2005
@@ -32,6 +32,9 @@
 dnl export expanded and relative configure argument variables
 APACHE_EXPORT_ARGUMENTS
 
+dnl confirm that a void pointer is large enough to store a long integer
+APACHE_CHECK_VOID_PTR_LEN
+
 dnl Save user-defined environment settings for later restoration
 dnl
 APR_SAVE_THE_ENVIRONMENT(CPPFLAGS)



Re: svn commit: r294809 - in /httpd/httpd/trunk: acinclude.m4 configure.in

Posted by Colm MacCarthaigh <co...@stdlib.net>.
On Tue, Oct 04, 2005 at 02:16:16PM -0500, William A. Rowe, Jr. wrote:
> Actually I'm also confused, not by the fact that we resolve this test,
> but exactly what it nets us.

It makes sure that a void * container can store the largest of the types
we ocasionally place in such a container. It validates the assumption
made by code which is in httpd right now.

It should be taken out if/when the code making those assumptions are
removed. 

In the meantime; if someone somehow managed to wheel out a rusty copy of
TurboC for Dos, with the forever-brilliant "near", "far" and "huge"
pointer-model, and then somehow again managed to get a configure script
to use this compiler, it would fail here (a 16-bit pointer would be less
than the 32-bit long) instead of probably about 20 lines further along
the configure script ;)

> Much more useful would be, as I mentioned before, a test with results
> if sizeof int == sizeof void*  then typedef ap_intptr_t int,
> if sizeof long == sizeof void* then typedef ap_intptr_t long,
> and we could have unsigned (ap_uintptr_t) of the same if anyone
> supposes that's useful.

This would be much better, though it's not just longs that we place in
these pointer types, chars and ints get placed in them too. It's just
all a lot more work, tracking down all of the instances, and adding new
conditional typedef's for each one.

Adreas' original patch just fixed the compiler warnings, these
assignments have been in quite a while, and there are more to be found, no
doubt. Does anyone have a tool which will

But it is an utterly tedious near-pointless task, so it's kind of hard to
be motivated to do it ;) 

-- 
Colm MacCárthaigh                        Public Key: colm+pgp@stdlib.net

Re: svn commit: r294809 - in /httpd/httpd/trunk: acinclude.m4 configure.in

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Rüdiger Plüm wrote:
> 
> On 10/04/2005 06:18 PM, colm@apache.org wrote:
> 
>>Author: colm
>>Date: Tue Oct  4 09:18:24 2005
>>New Revision: 294809
> 
> 
>>+AC_CACHE_CHECK([for void pointer length], [ap_void_ptr_lt_long],
> 
> Sorry for being confused by this, but I read your variable name
> ap_void_ptr_lt_long as "(size of) void ptr is less than (size of) long",
> but the assignment of "yes" and "no" is exactly the opposite. What about
> 
> AC_CACHE_CHECK([for void pointer length], [ap_void_ptr_lt_long],

Actually I'm also confused, not by the fact that we resolve this test,
but exactly what it nets us.

Much more useful would be, as I mentioned before, a test with results
if sizeof int == sizeof void*  then typedef ap_intptr_t int,
if sizeof long == sizeof void* then typedef ap_intptr_t long,
and we could have unsigned (ap_uintptr_t) of the same if anyone
supposes that's useful.




Re: svn commit: r294809 - in /httpd/httpd/trunk: acinclude.m4 configure.in

Posted by Rüdiger Plüm <r....@gmx.de>.

On 10/04/2005 06:18 PM, colm@apache.org wrote:
> Author: colm
> Date: Tue Oct  4 09:18:24 2005
> New Revision: 294809

[..cut..]

> 
> +
> +AC_CACHE_CHECK([for void pointer length], [ap_void_ptr_lt_long],
> +[AC_TRY_RUN([
> +int main(void)
> +{
> +    return sizeof(void *) < sizeof(long); 
> +}], [ap_void_ptr_lt_long=yes], [ap_void_ptr_lt_long=no], 
> +    [ap_void_ptr_lt_long=no])])
> +
> +if test "$ap_void_ptr_lt_long" = "no"; then
> +    AC_MSG_ERROR([Size of "void *" is less than size of "long"])
> +fi
> +])
> 

[..cut..]

Sorry for being confused by this, but I read your variable name
ap_void_ptr_lt_long as "(size of) void ptr is less than (size of) long",
but the assignment of "yes" and "no" is exactly the opposite. What about

AC_CACHE_CHECK([for void pointer length], [ap_void_ptr_lt_long],
[AC_TRY_RUN([
int main(void)
{
    return sizeof(void *) < sizeof(long);
}], [ap_void_ptr_lt_long=no], [ap_void_ptr_lt_long=yes],
    [ap_void_ptr_lt_long=yes])])

if test "$ap_void_ptr_lt_long" = "yes"; then
    AC_MSG_ERROR([Size of "void *" is less than size of "long"])
fi
])

No functional change, but seems clearer to me.

Regards

Rüdiger