Changeset 522 for trunk/src/sh_sem.c


Ignore:
Timestamp:
Apr 5, 2017, 9:51:43 PM (8 years ago)
Author:
katerina
Message:

Fix for ticket #417 (bus error on Solaris/SPARC).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_sem.c

    r481 r522  
    4444} sh_estat;
    4545
    46 #if 0
     46
    4747/* FreeBSD 6.1 defines this in <sys/sem.h> too...     */
    4848#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
    4949/* union semun is defined by including <sys/sem.h>    */
    5050#else
     51#if !defined(HAVE_UNION_SEMUN)
    5152/* according to X/OPEN we have to define it ourselves */
    5253union semun {
     
    5859#endif
    5960
     61
    6062#define SH_SEMVMX 32767
    6163
     
    7577static void sem_purge(int sem_id)
    7678{
     79  union semun tmp;
     80
     81  tmp.val = 0;
     82 
    7783  if (sem_id != -1)
    78     semctl(sem_id, 0, IPC_RMID, (int)0);
     84    semctl(sem_id, 0, IPC_RMID, tmp);
    7985  return;
    8086}
     
    103109  int    semid;
    104110  int    errnum;
     111  union semun tmp;
    105112  key_t  key = ftok(DEFAULT_DATAROOT, '#');
    106113
     
    112119  errnum = errno;
    113120  umask(mask);
     121 
     122  tmp.val = 1;
    114123
    115124  if (semid < 0)
    116125    return report_err(errnum, FIL__, __LINE__, _("semget"));
    117126  for (i=0; i<nsems; ++i)
    118     if (semctl (semid, i, SETVAL, (int) 1) == -1)
     127    if (semctl (semid, i, SETVAL, tmp) == -1)
    119128      return report_err(errnum, FIL__, __LINE__, _("semclt"));
    120129  return semid;
     
    124133static int sem_set(int semid, int sem_no, int val)
    125134{
     135  union semun tmp;
     136
     137  tmp.val = val;
     138 
    126139  if (semid < 0)
    127140    return -1;
    128   if (semctl (semid, sem_no, SETVAL, val) == -1)
     141  if (semctl (semid, sem_no, SETVAL, tmp) == -1)
    129142    return -1;
    130143  return 0;
     
    133146static int sem_get(int semid, int sem_no)
    134147{
     148  union semun tmp;
    135149  if (semid < 0)
    136150    return -1;
    137   return semctl (semid, sem_no, GETVAL, (int) 0);
     151  tmp.val = 0;
     152  return semctl (semid, sem_no, GETVAL, tmp);
    138153}
    139154
Note: See TracChangeset for help on using the changeset viewer.