/* Pull in whatever this particular arch's kernel thinks the kernel version of
* struct stat should look like. It turns out that each arch has a different
* opinion on the subject, and different kernel revs use different names... */
-#if defined(__sparc_v9__) && (__WORDSIZE == 64)
+#if !defined __NR_stat || (defined(__sparc_v9__) && (__WORDSIZE == 64))
#define kernel_stat64 stat
#else
#define kernel_stat stat
#define __NR__dl_close __NR_close
static __always_inline _syscall1(int, _dl_close, int, fd)
-#define __NR__dl_open __NR_open
+#if defined __NR_openat && !defined __NR_open
+static __always_inline int _dl_open(const char *fn,
+ int flags, __kernel_mode_t mode)
+{
+ return INLINE_SYSCALL(openat, 4, AT_FDCWD, fn, flags, mode);
+}
+
+#elif defined __NR_open
+# define __NR__dl_open __NR_open
static __always_inline _syscall3(int, _dl_open, const char *, fn, int, flags,
__kernel_mode_t, mode)
+#endif
#define __NR__dl_write __NR_write
static __always_inline _syscall3(unsigned long, _dl_write, int, fd,
static __always_inline _syscall3(int, _dl_mprotect, const void *, addr,
unsigned long, len, int, prot)
-#define __NR__dl_stat __NR_stat
+#if defined __NR_fstatat64 && !defined __NR_stat
+# define __NR__dl_fstatat64 __NR_fstatat64
+static __always_inline _syscall4(int, _dl_fstatat64, int, fd, const char *,
+ fn, struct stat *, stat, int, flags)
+
+static __always_inline int _dl_stat(const char *file_name,
+ struct stat *buf)
+{
+ return _dl_fstatat64(AT_FDCWD, file_name, buf, 0);
+}
+#elif defined __NR_stat
+# define __NR__dl_stat __NR_stat
static __always_inline _syscall2(int, _dl_stat, const char *, file_name,
struct stat *, buf)
+#endif
-#define __NR__dl_fstat __NR_fstat
+#if defined __NR_fstat64 && !defined __NR_fstat
+# define __NR__dl_fstat __NR_fstat64
+#elif defined __NR_fstat
+# define __NR__dl_fstat __NR_fstat
+#endif
static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf)
#define __NR__dl_munmap __NR_munmap
#define __NR__dl_getpid __NR_getpid
static __always_inline _syscall0(gid_t, _dl_getpid)
-#define __NR__dl_readlink __NR_readlink
+#if defined __NR_readlinkat && !defined __NR_readlink
+# define __NR__dl_readlink __NR_readlinkat
+static __always_inline _syscall4(int, _dl_readlink, int, id, const char *, path,
+ char *, buf, size_t, bufsiz)
+#elif defined __NR_readlink
+# define __NR__dl_readlink __NR_readlink
static __always_inline _syscall3(int, _dl_readlink, const char *, path, char *, buf,
size_t, bufsiz)
+#endif
#ifdef __NR_pread64
#define __NR___syscall_pread __NR_pread64