This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 8/9] Tilera (and Linux asm-generic) support for glibc
- From: Chris Metcalf <cmetcalf at tilera dot com>
- To: libc-alpha at sourceware dot org
- Cc: Arnd Bergmann <arnd at arndb dot de>, Linas Vepstas <linas at codeaurora dot org>, Guan Xuetao <gxt at mprc dot pku dot edu dot cn>, Jonas Bonn <jonas at southpole dot se>, Chen Liqin <liqin dot chen at gmail dot com>
- Date: Thu, 3 Nov 2011 16:01:57 -0400
- Subject: [PATCH 8/9] Tilera (and Linux asm-generic) support for glibc
- References: <201111031955.pA3Jt3sC024069@farm-0002.internal.tilera.com>
This patch adds #ifdefs to provide alternatives to syscalls whose
presence is assumed in sysdeps/unix/sys/linux, but which are not in
fact available on every Linux platform (open, getdents, futimesat).
2011-11-03 Chris Metcalf <cmetcalf@tilera.com>
* sysdeps/unix/sysv/linux/futimesat.c (futimesat): Support Linux
systems that supply __NR_utimensat but not __NR_futimesat.
* sysdeps/unix/sysv/linux/getdents.c (__GETDENTS): Don't try to
fall back to __NR_getdents if we are assuming we always have
__NR_getdents64, since __NR_getdents may not be present.
* sysdeps/unix/sysv/linux/not-cancel.h (open_not_cancel): Use
__NR_openat if __NR_open is not present.
diff --git a/sysdeps/unix/sysv/linux/futimesat.c b/sysdeps/unix/sysv/linux/futimesat.c
index bb83e74..3ff961d 100644
--- a/sysdeps/unix/sysv/linux/futimesat.c
+++ b/sysdeps/unix/sysv/linux/futimesat.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -53,6 +53,34 @@ futimesat (fd, file, tvp)
# endif
return result;
}
+#elif defined __NR_utimensat
+# ifndef __ASSUME_ATFCTS
+ if (__have_atfcts >= 0)
+# endif
+ {
+ struct timespec tsp[2];
+
+ if (tvp)
+ {
+ if (tvp[0].tv_usec >= 1000000 || tvp[0].tv_usec < 0 ||
+ tvp[1].tv_usec >= 1000000 || tvp[1].tv_usec < 0)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+ tsp[0].tv_sec = tvp[0].tv_sec;
+ tsp[0].tv_nsec = 1000 * tvp[0].tv_usec;
+ tsp[1].tv_sec = tvp[1].tv_sec;
+ tsp[1].tv_nsec = 1000 * tvp[1].tv_usec;
+ }
+ result = INLINE_SYSCALL (utimensat, 4, fd, file, tvp ? tsp : NULL, 0);
+# ifndef __ASSUME_ATFCTS
+ if (result == -1 && errno == ENOSYS)
+ __have_atfcts = -1;
+ else
+# endif
+ return result;
+ }
#endif
#ifndef __ASSUME_ATFCTS
diff --git a/sysdeps/unix/sysv/linux/getdents.c b/sysdeps/unix/sysv/linux/getdents.c
index 0aa9186..df1cfbd 100644
--- a/sysdeps/unix/sysv/linux/getdents.c
+++ b/sysdeps/unix/sysv/linux/getdents.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995-2004, 2006, 2007, 2010
+/* Copyright (C) 1993, 1995-2004, 2006, 2007, 2010, 2011
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -236,6 +236,7 @@ __GETDENTS (int fd, char *buf, size_t nbytes)
# endif
}
#endif
+#if !defined __NR_getdents64 || !defined __ASSUME_GETDENTS64_SYSCALL
{
size_t red_nbytes;
struct kernel_dirent *skdp, *kdp;
@@ -299,4 +300,5 @@ __GETDENTS (int fd, char *buf, size_t nbytes)
return (char *) dp - buf;
}
+#endif
}
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 80d33be..b8feb71 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -1,5 +1,5 @@
/* Uncancelable versions of cancelable interfaces. Linux version.
- Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2006, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
@@ -20,12 +20,22 @@
#include <sys/types.h>
#include <sysdep.h>
+#ifndef __NR_open
+#include <fcntl.h>
+#endif
/* Uncancelable open. */
+#ifdef __NR_open
#define open_not_cancel(name, flags, mode) \
INLINE_SYSCALL (open, 3, (const char *) (name), (flags), (mode))
#define open_not_cancel_2(name, flags) \
INLINE_SYSCALL (open, 2, (const char *) (name), (flags))
+#else
+#define open_not_cancel(name, flags, mode) \
+ INLINE_SYSCALL (openat, 4, AT_FDCWD, (const char *) (name), (flags), (mode))
+#define open_not_cancel_2(name, flags) \
+ INLINE_SYSCALL (openat, 3, AT_FDCWD, (const char *) (name), (flags))
+#endif
/* Uncancelable openat. */
#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt