[klibc] [PATCH 2/3] syscalls: Add syscalls needed by arm64

Steve Capper steve.capper at linaro.org
Mon Nov 11 06:54:40 PST 2013


On Fri, Nov 08, 2013 at 11:46:21AM -0800, H. Peter Anvin wrote:
> On 11/08/2013 09:12 AM, Steve Capper wrote:
> > diff --git a/usr/klibc/open64.c b/usr/klibc/open64.c
> > new file mode 100644
> > index 0000000..6ca603e
> > --- /dev/null
> > +++ b/usr/klibc/open64.c
> > @@ -0,0 +1,22 @@
> > +/*
> > + * open64.c
> > + *
> > + * For 64 bit systems without the open syscall, pass straight
> > + * through into openat.
> > + */
> > +
> > +#define _KLIBC_IN_OPEN_C
> > +#include <unistd.h>
> > +#include <fcntl.h>
> > +#include <sys/syscall.h>
> > +
> > +#if !defined(__NR_open) && _BITSIZE == 64
> > +
> > +__extern int openat(int, const char *, int, ...);
> > +
> > +int open(const char *pathname, int flags, mode_t mode)
> > +{
> > +	return openat(AT_FDCWD, pathname, flags, mode);
> > +}
> > +
> > +#endif
> 
> This applies equally to a 32-bit platform that doesn't define __NR_open,
> except there we need to add O_LARGEFILE to the flags and call __openat
> in order to not have to pull in openat.c as well.
> 
> I suggest merging this into open.c and making it look something like:
> 
> #ifndef __NR_open
> 
> # if __BITSIZE == 32
> 
> extern int __openat(int, const char *, int, mode_t);
> 
> int open(const char *pathname, int flags, mode_t mode)
> {
> 	return __openat(AT_FDCWD, pathname, flags | O_LARGEFILE, mode);
> }
> 
> # else
> 
> extern int openat(int, const char *, int, ...);
> 
> int open(const char *pathname, int flags, mode_t mode)
> {
> 	return openat(AT_FDCWD, pathname, flags, mode);
> }
> 
> # endif
> 
> #elif _BITSIZE == 32 && !defined(__i386__) && !defined(__m68k__)
> 
> ... the rest of the current file ...
> 

Yeah, I was in two minds about merging and this has tipped me over to
merging :-).

I've got a V2 patch set almost ready, I'm running it through some tests
and sanity checking it some more.

Thanks for the feedback,
-- 
Steve


More information about the klibc mailing list