Changeset 522


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

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

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/config.h.in

    r511 r522  
    934934/* Define to 1 if you have the `uname' function. */
    935935#undef HAVE_UNAME
     936
     937/* union semun already defined in sys/ipc.h or sys/sem.h */
     938#undef HAVE_UNION_SEMUN
    936939
    937940/* Define to 1 if you have the <unistd.h> header file. */
  • trunk/configure.ac

    r521 r522  
    672672fi
    673673
     674AC_MSG_CHECKING(for union semun)
     675AC_TRY_COMPILE([#include <sys/types.h>
     676#include <sys/ipc.h>
     677#include <sys/sem.h>],[union semun foo;], [sh_have_semun=yes], [sh_have_semun=no])
     678AC_MSG_RESULT($sh_have_semun)
     679if test x$sh_have_semun = xyes
     680then
     681  AC_DEFINE(HAVE_UNION_SEMUN, 1, [union semun already defined in sys/ipc.h or sys/sem.h])
     682fi
    674683
    675684dnl *****************************************
  • trunk/docs/Changelog

    r521 r522  
    114.2.1:
     2        * fix alignment problem with semget() (reported by Rolf)
    23        * fix dependency on chkconfig package on Redhat/CentOS: search
    34        /etc/init.d/functions also under /etc/rc.d/init.d/functions
  • 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.