* problems with flag -xtaso_short to cc
@ 1996-02-29 5:00 Paul E. Raines
1996-03-14 5:00 ` Christian Koenigseder
0 siblings, 1 reply; 2+ messages in thread
From: Paul E. Raines @ 1996-02-29 5:00 UTC (permalink / raw)
To port some code from AIX, we wish to use 32-bit pointers. The
C compiler appears to provide the -xtaso_short flag for this.
We have found several problems with it. One is that it does not
seem to be consistant. Here is the output of a simple program to
print the size of objects. Note that witht he -xtaso_short flag,
sizeof(int*) is 4 while sizeof(&i) where i is an integer is still 8.
=================================================================
$ cc -g -taso -xtaso_short ptest.c -o ptest
$ ./ptest
Sizeof(int) = 4
Sizeof(int*) = 4
Sizeof(long) = 8
Sizeof(long*) = 4
Sizeof(i) = 4
Sizeof(&i) = 8
Sizeof(l) = 8
Sizeof(&l) = 8
$ cc -g ptest.c -o ptest
$ ./ptest
Sizeof(int) = 4
Sizeof(int*) = 8
Sizeof(long) = 8
Sizeof(long*) = 8
Sizeof(i) = 4
Sizeof(&i) = 8
Sizeof(l) = 8
Sizeof(&l) = 8
$ cat ptest.c
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
int main(int argc, char **argv)
{
int i;
long l;
printf("Sizeof(int) = %d\n", sizeof(int));
printf("Sizeof(int*) = %d\n", sizeof(int*));
printf("Sizeof(long) = %d\n", sizeof(long));
printf("Sizeof(long*) = %d\n", sizeof(long*));
printf("Sizeof(i) = %d\n", sizeof(i));
printf("Sizeof(&i) = %d\n", sizeof(&i));
printf("Sizeof(l) = %d\n", sizeof(l));
printf("Sizeof(&l) = %d\n", sizeof(&l));
exit(0);
}
=================================================================
The other problems is that the argv argument to main is still 64
bytes and if you pass argv to another function as (char **) and
try to access it with string functions, it core dumps. The simple
work around here was to copy the entire argv contents in main to
a local (char **) variable using repeated mallocs.
A similar problem to this is that many functions core-dump in
32-mode. One of these is tolower. The following code coredumps.
=================================================================
$ cat xtest.c
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
void cUtToUpper(const char* is,char* os){
int i, l=strlen(is);
for(i=0; i<l; i++) os[i]=toupper(is[i]);
os[i]=0;
}
main(int argc, char **argv)
{
char s1[100];
strcpy(s1,"event");
cUtToUpper(s1,s1);
printf("%s\n",s1);
}
$ cc -g xtest.c -o xtest
$ ./xtest
EVENT
$ cc -g -taso -xtaso_short xtest.c -o xtest
$ ./xtest
Segmentation fault (core dumped)
$ dbx xtest core
dbx version 3.11.8
Type 'help' for help.
Core file created by program "xtest"
signal Segmentation fault at [cUtToUpper:8 +0x4c,0x12001310] \
for(i=0; i<l; i++) os[i]=toupper(is[i]);
=================================================================
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: problems with flag -xtaso_short to cc
1996-02-29 5:00 problems with flag -xtaso_short to cc Paul E. Raines
@ 1996-03-14 5:00 ` Christian Koenigseder
0 siblings, 0 replies; 2+ messages in thread
From: Christian Koenigseder @ 1996-03-14 5:00 UTC (permalink / raw)
>>> On Thu, 29 Feb 1996 01:53:03 GMT, raines@jupiter.slac.stanford.edu (Paul E. Raines) said:
In article <yfs20ne99ts.fsf@jupiter.SLAC.Stanford.EDU> raines@jupiter.slac.stanford.edu (Paul E. Raines) writes:
>>> To port some code from AIX, we wish to use 32-bit pointers. The
>>> C compiler appears to provide the -xtaso_short flag for this.
>>> We have found several problems with it. One is that it does not
>>> seem to be consistant. Here is the output of a simple program to
>>> print the size of objects. Note that witht he -xtaso_short flag,
>>> sizeof(int*) is 4 while sizeof(&i) where i is an integer is
>>> still 8.
>>>
>>>
>>> $ cc -g -taso -xtaso_short ptest.c -o ptest $ ./ptest
1.) Use following compiler flags:
-taso -xtaso
2.) Remove all occurences of "long" in your Sourcecode
3.) Insert: #pragma pointer_size short
in your source file.
Maybe have a look to the Migration Guide Manual!!!!
--
Christian Koenigseder UNIX-System & Network Manager
Umweltschutzreferat LHM Tel/Fax: +49 89 233-23619/-23442
Bayerstr. 28a E-mail: koenigse@umw.cube.net
80335 Muenchen, Germany Public PGP-Key on request
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1996-03-14 5:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-02-29 5:00 problems with flag -xtaso_short to cc Paul E. Raines
1996-03-14 5:00 ` Christian Koenigseder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox