Nasty problem with egcs-1.0.1 on Irix 6.4

Hugh Emberson hugh_emberson@yahoo.com
Fri Jan 16 23:06:00 GMT 1998


[ I sent this message earlier today, but it got truncated by Yahoos
  mailer.  Hope it works this time. ]

Hi,

I compiled and installed egcs-1.0.1 on Irix 6.4 last weekend. 
Everything appeared to go fine, it bootstrapped itself OK and ran the
GCC testsuite OK except for 4 failures which appear to be well know
problems (see #1).  

I tried compiling some of my employers code, but I ran into problems
using System V semaphores.  The code, which I have included below,
creates a semaphore (or attaches to an existing one), initializes the
semaphore and then reads the semaphores value.  

If I compile this code with gcc -mabi=n32 it gets 0 when it reads the
value back, but if I compile it with gcc -mabi=64 it works fine.  If I
compile it with the system cc using -32, -n32 or -64 it works. 

I think the problem must either lie with linking or with structure
packing and I am going to do some further investigation.

Thanks,
       Hugh


SYSTEM INFO:
~/semtest 89$ gcc -v  
Reading specs from
/usr/local/lib/gcc-lib/mips-sgi-irix6.4/egcs-2.90.23/specs
gcc version egcs-2.90.23 980102 (egcs-1.0.1 release)

~/semtest 88$ uname -a
IRIX64 build0 6.4 02121744 IP27

~/semtest 101$ cc -version
Mongoose Compilers: Version 7.10

FOOTNOTES:

#1: The gcc testsuite failed 4 time on
gcc.c-torture/execute/complex-5.c but this appears to be a known
problem.  It appears to be confused about how to pass complex floats.

RUNNING THE CODE:

~/semtest 102$ gcc -mabi=n32 -o semtest-gcc-n32 semtest.c
~/semtest 102$ ./semtest-gcc-n32
Creating semaphore ...
Attaching to existing semaphore ...
Semaphore id: 480
Initializing semaphore value to: 42 ...
Getting semaphore value ...
Got semaphore value: 0          -- FAILED



~/semtest 102$ gcc -mabi=64 -o semtest-gcc-64 semtest.c
~/semtest 103$ ./semtest-gcc-64
Creating semaphore ...
Attaching to existing semaphore ...
Semaphore id: 480
Initializing semaphore value to: 42 ...
Getting semaphore value ...
Got semaphore value: 42         -- OK

~/semtest 106$ cc -n32 -o semtest-cc-n32 semtest.c
~/semtest 107$ ./semtest-cc-n32
Creating semaphore ...
Attaching to existing semaphore ...
Semaphore id: 480
Initializing semaphore value to: 42 ...
Getting semaphore value ...
Got semaphore value: 42         -- OK


THE CODE: semtest.c

#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>

#define KEY 4242
#define NSEMS 1

#define TEST_VAL 42

int main(int argc, char *argv[]) {
  int semid;
  extern int errno;
  extern char *sys_errlist[];
  union semun arg;
  int val;

  printf("Creating semaphore ...\n");

  semid = semget(KEY, NSEMS, IPC_CREAT | IPC_EXCL | 0666);

  if(semid == -1 && errno == EEXIST) {
    printf("Attaching to existing semaphore ...\n");

    semid = semget(KEY, NSEMS, 0);
  }
  
  if(semid == -1) {
    fprintf(stderr, "Can't create semaphore: %s\n", sys_errlist[errno]);
    exit(1);
  }

  printf("Semaphore id: %d\n", semid);

  
  arg.val = TEST_VAL;

  printf("Initializing semaphore value to: %d ...\n", arg.val);
  
  if(semctl(semid, 0, SETVAL, arg) == -1)  {
    fprintf(stderr, "Can't initialize semaphore: %s\n",
sys_errlist[errno]);
    exit(1);
  }

  printf("Getting semaphore value ...\n");

  if((val = semctl(semid, 0, GETVAL)) == -1) {
    fprintf(stderr, "Can't get value of semaphore: %s\n",
sys_errlist[errno]);
    exit(1);
  }

  printf("Got semaphore value: %d\n", val);

  if(val != TEST_VAL)
    return 1;

  return 0;
}






_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com




More information about the Gcc-bugs mailing list