[tile] support openat() in not-cancel.h
Chris Metcalf
cmetcalf@tilera.com
Wed Jan 25 21:48:00 GMT 2012
On 11/11/2011 5:15 PM, Roland McGrath wrote:
>> I think there are two choices. We can duplicate the dozen-odd files
>> that use not-cancel.h in that directory into sysdeps/unix/sys/linux/generic,
>> or we can apply just one #ifdef to handle the case where we need
>> to use __NR_openat instead of __NR_open. I suspect the patch to
>> not-cancel.h is small enough that it's worth not duplicating the
>> dozen-odd C files (about 2,700 lines total).
> IMHO that change is fine enough. But I'd like it better if it used
> #elif defined (__NR_openat)
> #else
> # error "neither __NR_open nor __NR_openat available"
>
> for robustness.
Here's the revised version. Thanks.
2012-01-25 Chris Metcalf <cmetcalf@tilera.com>
* sysdeps/unix/sysv/linux/not-cancel.h (open_not_cancel,
open_not_cancel2): Use__NR_openat if __NR_open is not present.
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 80d33be..631de1f 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,24 @@
#include <sys/types.h>
#include <sysdep.h>
+#ifndef __NR_open
+# include <fcntl.h>
+#endif
/* Uncancelable 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))
+#if defined (__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))
+#elif defined (__NR_openat)
+# 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))
+#else
+# error "Neither __NR_open nor __NR_openat available."
+#endif
/* Uncancelable openat. */
#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
--
Chris Metcalf, Tilera Corp.
http://www.tilera.com
More information about the Libc-alpha
mailing list