Index: /trunk/config.h.in
===================================================================
--- /trunk/config.h.in	(revision 521)
+++ /trunk/config.h.in	(revision 522)
@@ -934,4 +934,7 @@
 /* Define to 1 if you have the `uname' function. */
 #undef HAVE_UNAME
+
+/* union semun already defined in sys/ipc.h or sys/sem.h */
+#undef HAVE_UNION_SEMUN
 
 /* Define to 1 if you have the <unistd.h> header file. */
Index: /trunk/configure.ac
===================================================================
--- /trunk/configure.ac	(revision 521)
+++ /trunk/configure.ac	(revision 522)
@@ -672,4 +672,13 @@
 fi
 
+AC_MSG_CHECKING(for union semun)
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/sem.h>],[union semun foo;], [sh_have_semun=yes], [sh_have_semun=no])
+AC_MSG_RESULT($sh_have_semun)
+if test x$sh_have_semun = xyes
+then
+  AC_DEFINE(HAVE_UNION_SEMUN, 1, [union semun already defined in sys/ipc.h or sys/sem.h])
+fi
 
 dnl *****************************************
Index: /trunk/docs/Changelog
===================================================================
--- /trunk/docs/Changelog	(revision 521)
+++ /trunk/docs/Changelog	(revision 522)
@@ -1,3 +1,4 @@
 4.2.1:
+	* fix alignment problem with semget() (reported by Rolf)
 	* fix dependency on chkconfig package on Redhat/CentOS: search
 	/etc/init.d/functions also under /etc/rc.d/init.d/functions
Index: /trunk/src/sh_sem.c
===================================================================
--- /trunk/src/sh_sem.c	(revision 521)
+++ /trunk/src/sh_sem.c	(revision 522)
@@ -44,9 +44,10 @@
 } sh_estat;
 
-#if 0
+
 /* FreeBSD 6.1 defines this in <sys/sem.h> too...     */
 #if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
 /* union semun is defined by including <sys/sem.h>    */
 #else
+#if !defined(HAVE_UNION_SEMUN)
 /* according to X/OPEN we have to define it ourselves */
 union semun {
@@ -58,4 +59,5 @@
 #endif
 
+
 #define SH_SEMVMX 32767
 
@@ -75,6 +77,10 @@
 static void sem_purge(int sem_id)
 {
+  union semun tmp;
+
+  tmp.val = 0;
+  
   if (sem_id != -1)
-    semctl(sem_id, 0, IPC_RMID, (int)0);
+    semctl(sem_id, 0, IPC_RMID, tmp);
   return;
 }
@@ -103,4 +109,5 @@
   int    semid;
   int    errnum;
+  union semun tmp;
   key_t  key = ftok(DEFAULT_DATAROOT, '#');
 
@@ -112,9 +119,11 @@
   errnum = errno;
   umask(mask);
+  
+  tmp.val = 1;
 
   if (semid < 0)
     return report_err(errnum, FIL__, __LINE__, _("semget"));
   for (i=0; i<nsems; ++i)
-    if (semctl (semid, i, SETVAL, (int) 1) == -1)
+    if (semctl (semid, i, SETVAL, tmp) == -1)
       return report_err(errnum, FIL__, __LINE__, _("semclt"));
   return semid;
@@ -124,7 +133,11 @@
 static int sem_set(int semid, int sem_no, int val)
 {
+  union semun tmp;
+
+  tmp.val = val;
+  
   if (semid < 0)
     return -1;
-  if (semctl (semid, sem_no, SETVAL, val) == -1)
+  if (semctl (semid, sem_no, SETVAL, tmp) == -1)
     return -1;
   return 0;
@@ -133,7 +146,9 @@
 static int sem_get(int semid, int sem_no)
 {
+  union semun tmp;
   if (semid < 0)
     return -1;
-  return semctl (semid, sem_no, GETVAL, (int) 0);
+  tmp.val = 0;
+  return semctl (semid, sem_no, GETVAL, tmp);
 }
 
