From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6891 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: getrandom syscall Date: Wed, 28 Jan 2015 09:49:07 -0500 Message-ID: <20150128144907.GG4574@brightrain.aerifal.cx> References: <20150128090212.GE32318@port70.net> <20150128122640.GF32318@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1422456568 29878 80.91.229.3 (28 Jan 2015 14:49:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Jan 2015 14:49:28 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6904-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jan 28 15:49:27 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1YGTvp-0005P3-E7 for gllmg-musl@m.gmane.org; Wed, 28 Jan 2015 15:49:25 +0100 Original-Received: (qmail 30253 invoked by uid 550); 28 Jan 2015 14:49:20 -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 30226 invoked from network); 28 Jan 2015 14:49:19 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:6891 Archived-At: On Wed, Jan 28, 2015 at 01:42:23PM +0100, Daniel Cegiełka wrote: > 2015-01-28 13:26 GMT+01:00 Szabolcs Nagy : > > * Daniel Cegie??ka [2015-01-28 10:10:53 +0100]: > >> 2015-01-28 10:02 GMT+01:00 Szabolcs Nagy : > >> > > >> > #ifdef SYS_getrandom > > ... > >> > #endif > >> > > >> > eg sh does not have the syscall (linux is not consistent with > >> > syscalls for whatever reason) > >> > >> SYS_getrandom is defined on musl, so #ifdef SYS_getrandom is not a > >> good solution: > >> > >> http://git.musl-libc.org/cgit/musl/tree/arch/x86_64/bits/syscall.h#n657 > >> > >> It's better to return an error. > > > > no > > > > you should return runtime error if the syscall fails > > (eg you are on old kernel that does not support the syscall) > > > > but you cannot use this code if SYS_getrandom is not > > defined (eg. sh arch) because it will be a musl > > compile time failure (sadly linux does not allocate > > syscall numbers on all archs so musl cannot define > > all SYS_ macros consistently on all archs either) > > Indeed. I considered the kernel version check, but it is ugly > approach. #ifdef SYS_getrandom we should add also add to the header > file (stdlib.h?). Is this code will be approved for musl? No, the header can't see the syscalls list. You can prototype the function even if it's not defined; it won't hurt. But rather than leaving it undefined, I think it should just return an error of ENOSYS if the SYS_getrandom macro is not defined. Rich