You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Rob Hartill <ro...@imdb.com> on 1997/01/24 17:39:40 UTC

Apache: Pointer <-> integer conversion annoyance on 64bit machines (fwd)

---------- Forwarded message ----------
Date: Fri, 24 Jan 1997 09:16:36 +0100
From: Kristian Nielsen <kr...@risoe.dk>
To: apache-bugs@mail.apache.org
Subject: Apache: Pointer <-> integer conversion annoyance on 64bit machines

Hi,

I just installed Apache 1.2b4 on a Digital Alpha machine running OSF1
v3.2. So far I am very satisfied with it.

I did experience a minor annoyance compiling Apache on the Alpha caused
by the 64-bit architecture of the Alpha. On the Alpha, "int" is 32bit
while all pointers are 64bit. In a few places in the source (see below),
conversion takes place between integers and pointers. This causes
compiler warnings, and also causes Apache not to conform to ANSI C as
claimed in the documentation (though this is probably not a problem in
itself).

After checking the source, it seems to me that the pointer <-> integer
conversion only takes place to pass integers to functions disguised as
generic void * / char * data arguments. Thus the only conversion is

	int -> void * -> int

which is "probably" safe as long as pointers use at least as many bits
as integers (true on current Unix architectures). Nevertheless, since it
occurs in only relatively few places (11) in the source, I think it
should be corrected, to spare me and others from going through the
source to check that everything is ok. It should be real easy to fix:
just pass a pointer to the integer instead of casting the integer itself
to a pointer. If this is impossible because of memory management
problems (eg. the integer values cannot be statically or malloc()
allocated), maybe you could put a note in the readme explaining these
compiler warnings and why they are not a problem.

	- Kristian.

-- 
Kristian Nielsen
Risø National Laboratory, Engineering and Computer Department.



These are the warnings caused by compiling the source from the archive
apache_1.2b4.tar.gz on an Alpha workstation:

gcc -c   -O2 -DOSF1 -g  alloc.c
alloc.c: In function `fd_cleanup':
alloc.c:731: warning: cast from pointer to integer of different size
alloc.c: In function `note_cleanups_for_fd':
alloc.c:734: warning: cast to pointer from integer of different size
alloc.c: In function `kill_cleanups_for_fd':
alloc.c:739: warning: cast to pointer from integer of different size
alloc.c: In function `pclosef':
alloc.c:759: warning: cast to pointer from integer of different size
gcc -c   -O2 -DOSF1 -g  http_core.c
http_core.c: In function `set_server_string_slot':
http_core.c:814: warning: cast from pointer to integer of different size
gcc -c   -O2 -DOSF1 -g  http_config.c
http_config.c: In function `set_string_slot':
http_config.c:695: warning: cast from pointer to integer of different size
http_config.c: In function `set_flag_slot':
http_config.c:704: warning: cast from pointer to integer of different size
gcc -c   -O2 -DOSF1 -g  mod_dir.c
mod_dir.c: In function `add_opts_int':
mod_dir.c:178: warning: cast to pointer from integer of different size
mod_dir.c: In function `find_opts':
mod_dir.c:395: warning: cast from pointer to integer of different size
gcc -c   -O2 -DOSF1 -g  mod_alias.c
mod_alias.c: In function `add_redirect':
mod_alias.c:140: warning: cast from pointer to integer of different size
gcc -c   -O2 -DOSF1 -g  mod_browser.c
mod_browser.c: In function `add_browser':
mod_browser.c:101: warning: cast from pointer to integer of different size




Re: Apache: Pointer <-> integer conversion annoyance on 64bit machines (fwd)

Posted by Dean Gaudet <dg...@arctic.org>.
On Fri, 24 Jan 1997, Rob Hartill wrote:
> ---------- Forwarded message ----------
> On the Alpha, "int" is 32bit
> while all pointers are 64bit.

Ah, this is what I thought but wasn't sure.  I think it was Mark wondering
about sprintf( "%u", (int)-1 ) printing 2^32-1 vs. 2^64-1 on 64-bit
machines.  This answers that question.  2^32-1 is the correct answer.

Dean