X-Git-Url: http://git.maemo.org/git/?p=dh-make-perl;a=blobdiff_plain;f=dev%2Farm%2Flibnet-ssleay-perl%2Flibnet-ssleay-perl-1.35%2Ft%2Flocal%2Fptr_cast_test.c;fp=dev%2Farm%2Flibnet-ssleay-perl%2Flibnet-ssleay-perl-1.35%2Ft%2Flocal%2Fptr_cast_test.c;h=430118cf2f190f5723a097413b0d1cfa8622fad9;hp=0000000000000000000000000000000000000000;hb=f477fa73365d491991707e7ed9217b48d6994551;hpb=da95c414033799c3a62606f299c3c00b5c77ca11 diff --git a/dev/arm/libnet-ssleay-perl/libnet-ssleay-perl-1.35/t/local/ptr_cast_test.c b/dev/arm/libnet-ssleay-perl/libnet-ssleay-perl-1.35/t/local/ptr_cast_test.c new file mode 100644 index 0000000..430118c --- /dev/null +++ b/dev/arm/libnet-ssleay-perl/libnet-ssleay-perl-1.35/t/local/ptr_cast_test.c @@ -0,0 +1,43 @@ +#include +#include + +/* test if a pointer can be cast to an unsigned long int and back + (aspa@hip.fi) + + tested on: HP-UX B.10.20, AIX 4.3, IRIX 5.3, OSF1 v4.0B and SunOS 5.6 + with both gcc and native compilers, and linux/gcc (i686) + + linux/gcc (alpha). + +*/ + +#define FROMTYPE void * +#define FROMTYPESTR "void *" +#define TOTYPE unsigned long int +#define TOTYPESTR "unsigned long int" + +int main(argc, argv) + int argc; /* e.g. HP-UX cc doesn't support ISO C by default */ + char *argv[]; +{ + /* heap should be near the end of process's address space */ + FROMTYPE bufptr = (FROMTYPE) malloc(500); + volatile TOTYPE i; /* prevent optimization */ + + printf("# %s: '%s' len: %d, '%s' len: %d.\n", argv[0], FROMTYPESTR, + sizeof(TOTYPE), TOTYPESTR, sizeof(char *)); + + i = (TOTYPE)bufptr; + if( ((FROMTYPE)i) != bufptr ) { + printf("# %s: failed: (%p != %p).\n", argv[0], (FROMTYPE)i, bufptr); + printf("# ERROR: a '%s' can't be cast to a '%s' and back \n", + FROMTYPESTR, TOTYPESTR); + printf("# ERROR: without loss of information on this architecture.\n"); + exit(1); + } else { + printf("# ptr_cast_test: ok (%p == %p).\n", (FROMTYPE)i, bufptr); + exit(0); + } + + exit(1); +} +