public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* R: ALIGNMENT / going crazy with gcc-2.7.2-sparc-sun-sunos-4.1.3
       [not found] <199912172346.PAA00844@java.agames.com>
@ 1999-12-18  7:23 ` cris
  1999-12-31 22:24   ` cris
  0 siblings, 1 reply; 2+ messages in thread
From: cris @ 1999-12-18  7:23 UTC (permalink / raw)
  To: help-gcc

mike, thanks for your reply.

the reason for wanting this system to work is simple: i've a project written
in ansi c that must run on a lot of machines, and i don't want to change a
line of code, except for some "#ifdef" to add.
the programs run on dec unix, hpux, aix, winnt, macos, irix and linux, and
i've not that kind of problem. when i had it, i solved with compiler
switches: for example, on hpux i used "cc +u1", and the problem disappeared.
on sunos, i could use "cc -misalign", but unfortunately i can't use sunos cc
because it's not fully ansi-compliant, and the only alternative compiler
allowed to use is gcc (because it's free).

i work for a firm that deals with satellite images, and there are a lot of
computations to do on a lot of data, so the first target is: "make the
fastest code, or lose the challenge".

i've an array of data composed by an odd number (17, obviously!) of header
bytes, and then the radiometry values.
i need to access the radiometry as an array to pass to math library
routines, and sincerely the last thing i would do is copying them in a
separate array: this would solve the problems, but performance would
suddenly tumble down. moreover, that machine is already slow... this loss of
speed would make it unusable.
finally, if i change the code this way, i would make modifications about
everywhere in the project files, and then i would have to test the whole
project on ALL the platforms that i wrote above.

i think that there's a way to do it with gcc: native cc compiler does it,
the same gcc has a "-m" switch for IBM platforms, there MUST be a way to do
it on sunos 4!

please help me, and reply in mailbox too.

have a wonderful week-end.

---
work like you don't need money
love like you've never been hurt
and dance like no one's watching


original question was:

> : how can i tell gcc to compile my programs using strict-alignment for
data
> : types?
> : if i write smth like this:
> :     void *full_array = malloc(50);
> :     short *short_p = &(( (char*) full_array)[ N ]);
> :     printf("%hd\n",*short_p);
> : if N is odd, i get a core dump!
> : i'm using gcc 2.7.2 on an old sparc2 with SunOs 4.1.3, no way to upgrade
the
> : os or to get a newer build of gcc.
> : i've searched in the doc., i've found -m switches regarding alignment
for
> : ibm machines, but none for sparc ones!
> : i've also seen a SHORT_ALIGNMENT macro to be defined (gcc-info, "You can
> : control compilation driver"), but i don't know WHERE to define it!








^ permalink raw reply	[flat|nested] 2+ messages in thread

* R: ALIGNMENT / going crazy with gcc-2.7.2-sparc-sun-sunos-4.1.3
  1999-12-18  7:23 ` R: ALIGNMENT / going crazy with gcc-2.7.2-sparc-sun-sunos-4.1.3 cris
@ 1999-12-31 22:24   ` cris
  0 siblings, 0 replies; 2+ messages in thread
From: cris @ 1999-12-31 22:24 UTC (permalink / raw)
  To: help-gcc

mike, thanks for your reply.

the reason for wanting this system to work is simple: i've a project written
in ansi c that must run on a lot of machines, and i don't want to change a
line of code, except for some "#ifdef" to add.
the programs run on dec unix, hpux, aix, winnt, macos, irix and linux, and
i've not that kind of problem. when i had it, i solved with compiler
switches: for example, on hpux i used "cc +u1", and the problem disappeared.
on sunos, i could use "cc -misalign", but unfortunately i can't use sunos cc
because it's not fully ansi-compliant, and the only alternative compiler
allowed to use is gcc (because it's free).

i work for a firm that deals with satellite images, and there are a lot of
computations to do on a lot of data, so the first target is: "make the
fastest code, or lose the challenge".

i've an array of data composed by an odd number (17, obviously!) of header
bytes, and then the radiometry values.
i need to access the radiometry as an array to pass to math library
routines, and sincerely the last thing i would do is copying them in a
separate array: this would solve the problems, but performance would
suddenly tumble down. moreover, that machine is already slow... this loss of
speed would make it unusable.
finally, if i change the code this way, i would make modifications about
everywhere in the project files, and then i would have to test the whole
project on ALL the platforms that i wrote above.

i think that there's a way to do it with gcc: native cc compiler does it,
the same gcc has a "-m" switch for IBM platforms, there MUST be a way to do
it on sunos 4!

please help me, and reply in mailbox too.

have a wonderful week-end.

---
work like you don't need money
love like you've never been hurt
and dance like no one's watching


original question was:

> : how can i tell gcc to compile my programs using strict-alignment for
data
> : types?
> : if i write smth like this:
> :     void *full_array = malloc(50);
> :     short *short_p = &(( (char*) full_array)[ N ]);
> :     printf("%hd\n",*short_p);
> : if N is odd, i get a core dump!
> : i'm using gcc 2.7.2 on an old sparc2 with SunOs 4.1.3, no way to upgrade
the
> : os or to get a newer build of gcc.
> : i've searched in the doc., i've found -m switches regarding alignment
for
> : ibm machines, but none for sparc ones!
> : i've also seen a SHORT_ALIGNMENT macro to be defined (gcc-info, "You can
> : control compilation driver"), but i don't know WHERE to define it!








^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-12-31 22:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <199912172346.PAA00844@java.agames.com>
1999-12-18  7:23 ` R: ALIGNMENT / going crazy with gcc-2.7.2-sparc-sun-sunos-4.1.3 cris
1999-12-31 22:24   ` cris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).