* Re: ppc32: semctl fails
[not found] <1512581010.8313.153.camel__41464.7176782184$1512581316$gmane$org@infinera.com>
@ 2017-12-06 22:56 ` Andreas Schwab
2017-12-06 23:53 ` Joakim Tjernlund
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2017-12-06 22:56 UTC (permalink / raw)
To: Joakim Tjernlund; +Cc: linuxppc-dev
On Dez 06 2017, Joakim Tjernlund <Joakim.Tjernlund@infinera.com> 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."
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: ppc32: semctl fails
2017-12-06 22:56 ` ppc32: semctl fails Andreas Schwab
@ 2017-12-06 23:53 ` Joakim Tjernlund
0 siblings, 0 replies; 3+ messages in thread
From: Joakim Tjernlund @ 2017-12-06 23:53 UTC (permalink / raw)
To: schwab; +Cc: linuxppc-dev
On Wed, 2017-12-06 at 23:56 +0100, Andreas Schwab wrote:
>=20
> On Dez 06 2017, Joakim Tjernlund <Joakim.Tjernlund@infinera.com> wrote:
>=20
> > 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=
^ permalink raw reply [flat|nested] 3+ messages in thread
* ppc32: semctl fails
@ 2017-12-06 17:23 Joakim Tjernlund
0 siblings, 0 replies; 3+ messages in thread
From: Joakim Tjernlund @ 2017-12-06 17:23 UTC (permalink / raw)
To: linuxppc-dev
This test, taken from perl Configure, fails on my ppc32, should it?
semctl IPC_STAT failed: errno =3D Bad Address=20
is what I get, kernel is 4.1.43
-----------------
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/stat.h>
#ifndef S_IRUSR
# ifdef S_IREAD
#define S_IRUSR S_IREAD
#define S_IWUSR S_IWRITE
#define S_IXUSR S_IEXEC
# else
#define S_IRUSR 0400
#define S_IWUSR 0200
#define S_IXUSR 0100
# endif
# define S_IRGRP (S_IRUSR>>3)
# define S_IWGRP (S_IWUSR>>3)
# define S_IXGRP (S_IXUSR>>3)
# define S_IROTH (S_IRUSR>>6)
# define S_IWOTH (S_IWUSR>>6)
# define S_IXOTH (S_IXUSR>>6)
#endif
#ifndef S_IRWXU
# define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
# define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
# define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
#endif
#include <string.h>
#include <stdio.h>
#include <errno.h>
#ifndef errno
extern int errno;
#endif
int main() {
int sem, st;
struct semid_ds 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, &arg);
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, &arg) !=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;
}=
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-06 23:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1512581010.8313.153.camel__41464.7176782184$1512581316$gmane$org@infinera.com>
2017-12-06 22:56 ` ppc32: semctl fails Andreas Schwab
2017-12-06 23:53 ` Joakim Tjernlund
2017-12-06 17:23 Joakim Tjernlund
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).