From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/1978 Path: news.gmane.org!not-for-mail From: Jens Newsgroups: gmane.linux.lib.musl.general Subject: Re: semtcl for x86_64 Date: Sat, 22 Sep 2012 14:14:48 +0200 (CEST) Message-ID: References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Trace: ger.gmane.org 1348316100 1973 80.91.229.3 (22 Sep 2012 12:15:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 22 Sep 2012 12:15:00 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-1979-gllmg-musl=m.gmane.org@lists.openwall.com Sat Sep 22 14:15:05 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1TFObx-0007xF-Bs for gllmg-musl@plane.gmane.org; Sat, 22 Sep 2012 14:15:05 +0200 Original-Received: (qmail 7379 invoked by uid 550); 22 Sep 2012 12:15:00 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 7371 invoked from network); 22 Sep 2012 12:15:00 -0000 In-Reply-To: User-Agent: Alpine 2.02 (LNX 1266 2009-07-14) Xref: news.gmane.org gmane.linux.lib.musl.general:1978 Archived-At: This is dependent on kernel config option ARCH_WANT_IPC_PARSE_VERSION. Looks like it is not set for x86_64. select ARCH_WANT_IPC_PARSE_VERSION if X86_32 Looking at the code: #ifndef CONFIG_ARCH_WANT_IPC_PARSE_VERSION /* On IA-64, we always use the "64-bit version" of the IPC structures. */ # define ipc_parse_version(cmd) IPC_64 #else int ipc_parse_version (int *cmd); #endif SYSCALL_DEFINE(semctl)(int semid, int semnum, int cmd, union semun arg) { int err = -EINVAL; int version; struct ipc_namespace *ns; if (semid < 0) return -EINVAL; version = ipc_parse_version(&cmd); ... switch(cmd) { ... case SETVAL: case SETALL: err = semctl_main(ns,semid,semnum,cmd,version,arg); return err; ... default: return -EINVAL; } } So IPC_64 will not be cleared from cmd since parse_version do not remove the bit since its only a macro that returns IPC_64. Hence EINVAL. Regards, Jens On Sat, 22 Sep 2012, Jens wrote: > > Hello I have some trouble getting semctl working: > > Tried in both musl and uclibc to compare. > See below. > > The only difference I can see is the IPC_64 flag. > > (I haven't tried 32-bit). > > Regards, > Jens > > program: > bash-4.1# cat t.c > #include > #include > #include > > main() { > int sem; > // semget(IPC_PRIVATE, 1, IPC_CREAT|0600) = 131076 > sem = semget(IPC_PRIVATE, 1, IPC_CREAT); > semctl(sem, 0, SETVAL, 0x1); > > } > > musl: > > bash-4.1# /bin64/strace ./m > execve("./m", ["./m"], [/* 19 vars */]) = 0 > semget(IPC_PRIVATE, 1, IPC_CREAT|0) = 327688 > semctl(327688, 0, IPC_64|SETVAL, 0x1) = -1 EINVAL (Invalid argument) > exit_group(-1) = ? > bash-4.1# > > > uclibc: > > semget(IPC_PRIVATE, 1, IPC_CREAT|0) = 262150 > semctl(262150, 0, SETVAL, 0x1) = 0 > _exit(0) = ? > bash-4.1# >