public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Compilation flags with GCC 2.8.1
@ 1999-10-05  2:44 tex_tarro
  1999-10-05 15:32 ` Jeffrey A Law
  1999-10-31 13:57 ` tex_tarro
  0 siblings, 2 replies; 4+ messages in thread
From: tex_tarro @ 1999-10-05  2:44 UTC (permalink / raw)
  To: help-gcc

We developed one application using HP-UX 10.20 proprietary C compiler.
Now we are trying compile it using  GCC 2.8.1 and we found a problem
with
compilation flags.

HP compiler has +u1 flag we didn't find in GCC compiler.
This option is vital for our code. In fact, skipping it cause the core
dump of
our application.

If you would like, try the following example:

1) Use the following file mappa.c

#include <stdio.h>
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>

#define file "systabina.txt"
main()
{
void     *p_map=NULL;
off_t    fsize, pagesize;
int      boot_fd = -1, i;
void     *temp = NULL;
char     *temp_c = NULL;
short    *temp_i = NULL;

if ((boot_fd=open(file, O_RDWR)) < 0)
    printf("Error in file openening\n");

fsize = lseek(boot_fd, 0, SEEK_END);
if(fsize <0)
   printf("ERRORE fsize <0\n");

pagesize = sysconf(_SC_PAGE_SIZE);

p_map = (void *) mmap (NULL,
                      fsize,
                      (PROT_READ|PROT_WRITE),
                      (MAP_FILE|MAP_VARIABLE|MAP_SHARED),
                      boot_fd,0);
if ( p_map == (void *)-1)
   printf("Error in file mapping\n");

  temp_c = ((char *)p_map) + 1;
  printf("char num. 2 = %c\n", *temp_c);

  temp_i = (short *) ((char *) p_map+1);
  printf("short = %hd\n", *temp_i);
}

   This code accesses a txt file, called systabina.txt, one line long
that is:

   Questo file ha lo scopo di determinare eventuali problemi di memory
fault

2) Compile it using HP compiler in this way:
        %> cc +u1 -o mappa mappa.c

3) Run mappa and obtain the following result:
        %> mappa

        char num. 2 = u
        short = 30053

4) Now compile it without +u1 flag and run it
        %> cc -o mappa mappa.c
        %> mappa

        char num. 2 = u
        (Bus error core dumped)

5) If you try with gcc you obtain the same result:
        %> gcc -o mappa mappa.c
        %> mappa

        char num. 2 = u
        (Bus error core dumped)

We would like to find the correspondent flag +u1 for gcc or adding a
define in the code as workaround. We cannot strongly modify the code.
I mean each structure or similar.

Can someone help us?

Thank you


Sent via Deja.com http://www.deja.com/
Before you buy.

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

* Re: Compilation flags with GCC 2.8.1
  1999-10-05  2:44 Compilation flags with GCC 2.8.1 tex_tarro
@ 1999-10-05 15:32 ` Jeffrey A Law
  1999-10-31 13:57   ` Jeffrey A Law
  1999-10-31 13:57 ` tex_tarro
  1 sibling, 1 reply; 4+ messages in thread
From: Jeffrey A Law @ 1999-10-05 15:32 UTC (permalink / raw)
  To: tex_tarro; +Cc: help-gcc

  In message < 7tcgj1$jjl$1@nnrp1.deja.com >you write:
  > HP compiler has +u1 flag we didn't find in GCC compiler.
  > This option is vital for our code. In fact, skipping it cause the core
  > dump of our application.
Your application is in error as it performs an unaligned access.

There is no GCC option which is equivalent to +u1 from the HP compilers.

You might consider using the aligned attribute to declare mis-aligned
data structures.

jeff

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

* Compilation flags with GCC 2.8.1
  1999-10-05  2:44 Compilation flags with GCC 2.8.1 tex_tarro
  1999-10-05 15:32 ` Jeffrey A Law
@ 1999-10-31 13:57 ` tex_tarro
  1 sibling, 0 replies; 4+ messages in thread
From: tex_tarro @ 1999-10-31 13:57 UTC (permalink / raw)
  To: help-gcc

We developed one application using HP-UX 10.20 proprietary C compiler.
Now we are trying compile it using  GCC 2.8.1 and we found a problem
with
compilation flags.

HP compiler has +u1 flag we didn't find in GCC compiler.
This option is vital for our code. In fact, skipping it cause the core
dump of
our application.

If you would like, try the following example:

1) Use the following file mappa.c

#include <stdio.h>
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>

#define file "systabina.txt"
main()
{
void     *p_map=NULL;
off_t    fsize, pagesize;
int      boot_fd = -1, i;
void     *temp = NULL;
char     *temp_c = NULL;
short    *temp_i = NULL;

if ((boot_fd=open(file, O_RDWR)) < 0)
    printf("Error in file openening\n");

fsize = lseek(boot_fd, 0, SEEK_END);
if(fsize <0)
   printf("ERRORE fsize <0\n");

pagesize = sysconf(_SC_PAGE_SIZE);

p_map = (void *) mmap (NULL,
                      fsize,
                      (PROT_READ|PROT_WRITE),
                      (MAP_FILE|MAP_VARIABLE|MAP_SHARED),
                      boot_fd,0);
if ( p_map == (void *)-1)
   printf("Error in file mapping\n");

  temp_c = ((char *)p_map) + 1;
  printf("char num. 2 = %c\n", *temp_c);

  temp_i = (short *) ((char *) p_map+1);
  printf("short = %hd\n", *temp_i);
}

   This code accesses a txt file, called systabina.txt, one line long
that is:

   Questo file ha lo scopo di determinare eventuali problemi di memory
fault

2) Compile it using HP compiler in this way:
        %> cc +u1 -o mappa mappa.c

3) Run mappa and obtain the following result:
        %> mappa

        char num. 2 = u
        short = 30053

4) Now compile it without +u1 flag and run it
        %> cc -o mappa mappa.c
        %> mappa

        char num. 2 = u
        (Bus error core dumped)

5) If you try with gcc you obtain the same result:
        %> gcc -o mappa mappa.c
        %> mappa

        char num. 2 = u
        (Bus error core dumped)

We would like to find the correspondent flag +u1 for gcc or adding a
define in the code as workaround. We cannot strongly modify the code.
I mean each structure or similar.

Can someone help us?

Thank you


Sent via Deja.com http://www.deja.com/
Before you buy.

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

* Re: Compilation flags with GCC 2.8.1
  1999-10-05 15:32 ` Jeffrey A Law
@ 1999-10-31 13:57   ` Jeffrey A Law
  0 siblings, 0 replies; 4+ messages in thread
From: Jeffrey A Law @ 1999-10-31 13:57 UTC (permalink / raw)
  To: tex_tarro; +Cc: help-gcc

  In message < 7tcgj1$jjl$1@nnrp1.deja.com >you write:
  > HP compiler has +u1 flag we didn't find in GCC compiler.
  > This option is vital for our code. In fact, skipping it cause the core
  > dump of our application.
Your application is in error as it performs an unaligned access.

There is no GCC option which is equivalent to +u1 from the HP compilers.

You might consider using the aligned attribute to declare mis-aligned
data structures.

jeff

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

end of thread, other threads:[~1999-10-31 13:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-10-05  2:44 Compilation flags with GCC 2.8.1 tex_tarro
1999-10-05 15:32 ` Jeffrey A Law
1999-10-31 13:57   ` Jeffrey A Law
1999-10-31 13:57 ` tex_tarro

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).