[klibc] [PATCH 2/3] syscalls: Add syscalls needed by arm64
H. Peter Anvin
hpa at zytor.com
Fri Nov 8 11:46:21 PST 2013
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 ...
More information about the klibc
mailing list