Re: ppc32: semctl fails

2 messages, 2 authors, 2017-12-06 · open the first message on its own page

Re: ppc32: semctl fails

From: Andreas Schwab <hidden>
Date: 2017-12-06 23:03:07

On Dez 06 2017, Joakim Tjernlund [off-list ref] wrote:
    st = semctl(sem, 0, IPC_STAT, &arg);
This is not a valid use of IPC_STAT.  The fourth argument must be a
object of type union semun (not a pointer), with the .buf member
pointing to the struct semid_ds object.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

Re: ppc32: semctl fails

From: Joakim Tjernlund <hidden>
Date: 2017-12-06 23:53:39

On Wed, 2017-12-06 at 23:56 +0100, Andreas Schwab wrote:
=20
On Dez 06 2017, Joakim Tjernlund [off-list ref] wrote:
=20
quoted
    st =3D semctl(sem, 0, IPC_STAT, &arg);
=20
This is not a valid use of IPC_STAT.  The fourth argument must be a
object of type union semun (not a pointer), with the .buf member
pointing to the struct semid_ds object.
Ahh, so perl had it wrong (Any perl guys here?). This is what I came up wit=
h and it works:

struct semid_ds arg;
  union semun {
    int              val;    /* Value for SETVAL */
    struct semid_ds *buf;    /* Buffer for IPC_STAT, IPC_SET */
    unsigned short  *array;  /* Array for GETALL, SETALL */
    struct seminfo  *__buf;  /* Buffer for IPC_INFO                        =
                                                               =20
                                (Linux-specific) */
  } semopts =3D {0};
  semopts.buf =3D &arg;

#if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) &&  define=
d(S_IRWXO) && defined(IPC_CREAT)
  sem =3D semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
  if (sem > -1) {
    #ifdef IPC_STAT
    st =3D semctl(sem, 0, IPC_STAT, semopts);
    if (st =3D=3D 0)
      printf("semid_ds\n");
    else
#endif /* IPC_STAT */
      printf("semctl IPC_STAT failed: errno =3D %s\n", strerror(errno));
    #ifdef IPC_RMID
    if (semctl(sem, 0, IPC_RMID, semopts) !=3D 0)
#endif /* IPC_RMID */
      printf("semctl IPC_RMID failed: errno =3D %d\n", errno);
  } else
#endif /* IPC_PRIVATE && ... */
    printf("semget failed: errno =3D %d\n", errno);
  return 0;

 Jocke=
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help