MapServer on Alpha
Paul G. Allen
pgallen at randomlogic.com
Sun Nov 28 11:14:18 PST 1999
Well, I'd like to say that it works under Alpha Linux, but it doesn't seem to.
I've compiled MapServer, PROJ.4, and libtiff on my Alpha under Red Hat Linux
6.0. During the compile I noticed many "cast from pointer to integer of
different size" and "cast to pointer from integer of different size" warnings. I
ignored them in the hopes that it would work anyway.
When I run my MapServer Demo pages under Apache on the Alpha, I get "premature
end of script" errors in the log files and "Internal Server Error" in the
browser. I believe this indicates a problem with the mapserv CGI, probably due
to unaligned pointers.
I have looked at part of the code and the warnings, and have found that some of
the warnings deal with malloc(), realloc(), and calloc() function calls where an
int type is used as an argument. Alpha pointers are 64 bits in size and an
integer can not be used as a pointer unless it is type cast first. The same
holds true when casting a pointer to an integer, except that you only lose bits
doing this, instead of causing a core dump.
I have begun "fixing" these problems by adding a preprocessor directive and a
macro as follows:
/* File shapefil.h */
#ifdef __alpha__
#define POINTER (long)
#else
#define POINTER (int)
#endif
/* end shapefil.h */
This macro is used wherever a type mismatch as defined above occurs. For
example:
return ((void *) malloc(nNewSize));
becomes
return ((void *)POINTER malloc(nNewSize));
which, after preprocessing, looks like
return ((void *)(long) malloc(nNewSize)); // For Alpha processors
return ((void *)(int) malloc(nNewSize)); // For all other processors
By doing this, the 32-bit value returned by malloc is cast to a 64-bit pointer
if the processor type is __alpha__, and it remains 32-bit for anything else. So
far I have not gotten far enough to test the code, but it does compile without
the pointer cast warnings.
I am also seeing warnings about type mismatches with functions memcpy(),
strcpy(), etc. I don't know what this is about yet.
PGA
More information about the MapServer-users
mailing list