about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/not-cancel.h4
-rw-r--r--sysdeps/posix/closedir.c2
-rw-r--r--sysdeps/posix/getaddrinfo.c4
-rw-r--r--sysdeps/posix/getcwd.c4
-rw-r--r--sysdeps/posix/opendir.c6
-rw-r--r--sysdeps/posix/spawni.c6
-rw-r--r--sysdeps/unix/sysv/linux/Versions1
-rw-r--r--sysdeps/unix/sysv/linux/check_native.c2
-rw-r--r--sysdeps/unix/sysv/linux/check_pf.c2
-rw-r--r--sysdeps/unix/sysv/linux/close.c12
-rw-r--r--sysdeps/unix/sysv/linux/fips-private.h2
-rw-r--r--sysdeps/unix/sysv/linux/gethostid.c4
-rw-r--r--sysdeps/unix/sysv/linux/getloadavg.c2
-rw-r--r--sysdeps/unix/sysv/linux/getlogin_r.c2
-rw-r--r--sysdeps/unix/sysv/linux/getsysstats.c6
-rw-r--r--sysdeps/unix/sysv/linux/grantpt.c2
-rw-r--r--sysdeps/unix/sysv/linux/i386/smp.h2
-rw-r--r--sysdeps/unix/sysv/linux/ia64/has_cpuclock.c2
-rw-r--r--sysdeps/unix/sysv/linux/if_index.c6
-rw-r--r--sysdeps/unix/sysv/linux/libc_fatal.c2
-rw-r--r--sysdeps/unix/sysv/linux/malloc-sysdep.h2
-rw-r--r--sysdeps/unix/sysv/linux/mq_notify.c2
-rw-r--r--sysdeps/unix/sysv/linux/not-cancel.h17
-rw-r--r--sysdeps/unix/sysv/linux/pthread_getname.c2
-rw-r--r--sysdeps/unix/sysv/linux/pthread_setname.c2
-rw-r--r--sysdeps/unix/sysv/linux/spawni.c6
-rw-r--r--sysdeps/unix/sysv/linux/sysconf.c2
27 files changed, 61 insertions, 45 deletions
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
index df9aea640b..ee9988a990 100644
--- a/sysdeps/generic/not-cancel.h
+++ b/sysdeps/generic/not-cancel.h
@@ -26,9 +26,9 @@
   __openat (__VA_ARGS__)
 #define __openat64_nocancel(...) \
   __openat64 (__VA_ARGS__)
-#define close_not_cancel(fd) \
+#define __close_nocancel(fd) \
   __close (fd)
-#define close_not_cancel_no_status(fd) \
+#define __close_nocancel_nostatus(fd) \
   (void) __close (fd)
 #define __read_nocancel(fd, buf, n) \
   __read (fd, buf, n)
diff --git a/sysdeps/posix/closedir.c b/sysdeps/posix/closedir.c
index e7b7d77fde..dbde65f5dc 100644
--- a/sysdeps/posix/closedir.c
+++ b/sysdeps/posix/closedir.c
@@ -49,6 +49,6 @@ __closedir (DIR *dirp)
 
   free ((void *) dirp);
 
-  return close_not_cancel (fd);
+  return __close_nocancel (fd);
 }
 weak_alias (__closedir, closedir)
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 09f85fc472..f02bbbe533 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -2399,7 +2399,7 @@ getaddrinfo (const char *name, const char *service,
 		{
 		  if (fd != -1)
 		  close_retry:
-		    close_not_cancel_no_status (fd);
+		    __close_nocancel_nostatus (fd);
 		  af = q->ai_family;
 		  fd = __socket (af, SOCK_DGRAM | SOCK_CLOEXEC, IPPROTO_IP);
 		}
@@ -2502,7 +2502,7 @@ getaddrinfo (const char *name, const char *service,
 	}
 
       if (fd != -1)
-	close_not_cancel_no_status (fd);
+	__close_nocancel_nostatus (fd);
 
       /* We got all the source addresses we can get, now sort using
 	 the information.  */
diff --git a/sysdeps/posix/getcwd.c b/sysdeps/posix/getcwd.c
index caa352732a..702a052306 100644
--- a/sysdeps/posix/getcwd.c
+++ b/sysdeps/posix/getcwd.c
@@ -176,7 +176,7 @@ extern char *alloca ();
 # include <kernel-features.h>
 #else
 # define __openat64_nocancel(dfd, name, mode) openat64 (dfd, name, mode)
-# define close_not_cancel_no_status(fd) close (fd)
+# define __close_nocancel_nostatus(fd) close (fd)
 #endif
 
 #ifndef PATH_MAX
@@ -521,7 +521,7 @@ __getcwd (char *buf, size_t size)
   if (dirstream != NULL)
     __closedir (dirstream);
   if (fd_needs_closing)
-    close_not_cancel_no_status (fd);
+    __close_nocancel_nostatus (fd);
 #ifndef NO_ALLOCATION
   if (buf == NULL)
     free (path);
diff --git a/sysdeps/posix/opendir.c b/sysdeps/posix/opendir.c
index 51a92e853c..880ebc904c 100644
--- a/sysdeps/posix/opendir.c
+++ b/sysdeps/posix/opendir.c
@@ -65,7 +65,7 @@ tryopen_o_directory (void)
 
   if (x >= 0)
     {
-      close_not_cancel_no_status (x);
+      __close_nocancel_nostatus (x);
       o_directory_works = -1;
     }
   else if (errno != ENOTDIR)
@@ -129,7 +129,7 @@ opendir_tail (int fd)
     {
       __set_errno (ENOTDIR);
     lose:
-      close_not_cancel_no_status (fd);
+      __close_nocancel_nostatus (fd);
       return NULL;
     }
 
@@ -227,7 +227,7 @@ __alloc_dir (int fd, bool close_fd, int flags, const struct stat64 *statp)
 	  if (close_fd)
 	    {
 	      int save_errno = errno;
-	      close_not_cancel_no_status (fd);
+	      __close_nocancel_nostatus (fd);
 	      __set_errno (save_errno);
 	    }
 	  return NULL;
diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c
index b5732714ae..0605562ef3 100644
--- a/sysdeps/posix/spawni.c
+++ b/sysdeps/posix/spawni.c
@@ -157,7 +157,7 @@ __spawni_child (void *arguments)
 	  switch (action->tag)
 	    {
 	    case spawn_do_close:
-	      if (close_not_cancel (action->action.close_action.fd) != 0)
+	      if (__close_nocancel (action->action.close_action.fd) != 0)
 		{
 		  if (have_fdlimit == 0)
 		    {
@@ -180,7 +180,7 @@ __spawni_child (void *arguments)
 		   with the process already at maximum number of file descriptor
 		   opened and also for multiple actions on single-open special
 		   paths (like /dev/watchdog).  */
-		close_not_cancel (action->action.open_action.fd);
+		__close_nocancel (action->action.open_action.fd);
 
 		int new_fd = __open_nocancel (action->action.open_action.path,
 					      action->action.open_action.oflag
@@ -197,7 +197,7 @@ __spawni_child (void *arguments)
 			!= action->action.open_action.fd)
 		      goto fail;
 
-		    if (close_not_cancel (new_fd) != 0)
+		    if (__close_nocancel (new_fd) != 0)
 		      goto fail;
 		  }
 	      }
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index b553514c27..6c9e06f4f9 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -171,6 +171,7 @@ libc {
     __syscall_rt_sigqueueinfo;
     __open_nocancel;
     __read_nocancel;
+    __close_nocancel;
     # functions used by nscd
     __netlink_assert_response;
   }
diff --git a/sysdeps/unix/sysv/linux/check_native.c b/sysdeps/unix/sysv/linux/check_native.c
index 7e5a7c9be3..dc2da83552 100644
--- a/sysdeps/unix/sysv/linux/check_native.c
+++ b/sysdeps/unix/sysv/linux/check_native.c
@@ -167,7 +167,7 @@ __check_native (uint32_t a1_index, int *a1_native,
   while (! done);
 
  out:
-  close_not_cancel_no_status (fd);
+  __close_nocancel_nostatus (fd);
 
   return;
 
diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c
index 3bf221a177..4dd0275144 100644
--- a/sysdeps/unix/sysv/linux/check_pf.c
+++ b/sysdeps/unix/sysv/linux/check_pf.c
@@ -328,7 +328,7 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6,
 				&addr_len) == 0)
 	    data = make_request (fd, nladdr.nl_pid);
 
-	  close_not_cancel_no_status (fd);
+	  __close_nocancel_nostatus (fd);
 	}
 
       if (data != NULL)
diff --git a/sysdeps/unix/sysv/linux/close.c b/sysdeps/unix/sysv/linux/close.c
index 1ac71ce980..dd21d8d5fb 100644
--- a/sysdeps/unix/sysv/linux/close.c
+++ b/sysdeps/unix/sysv/linux/close.c
@@ -18,6 +18,7 @@
 
 #include <unistd.h>
 #include <sysdep-cancel.h>
+#include <not-cancel.h>
 
 /* Close the file descriptor FD.  */
 int
@@ -28,3 +29,14 @@ __close (int fd)
 libc_hidden_def (__close)
 strong_alias (__close, __libc_close)
 weak_alias (__close, close)
+
+# if !IS_IN (rtld)
+int
+__close_nocancel (int fd)
+{
+  return INLINE_SYSCALL_CALL (close, fd);
+}
+#else
+strong_alias (__libc_close, __close_nocancel)
+#endif
+libc_hidden_def (__close_nocancel)
diff --git a/sysdeps/unix/sysv/linux/fips-private.h b/sysdeps/unix/sysv/linux/fips-private.h
index 775f2c2b50..23833f03fb 100644
--- a/sysdeps/unix/sysv/linux/fips-private.h
+++ b/sysdeps/unix/sysv/linux/fips-private.h
@@ -50,7 +50,7 @@ fips_enabled_p (void)
 	  char buf[32];
 	  ssize_t n;
 	  n = TEMP_FAILURE_RETRY (__read_nocancel (fd, buf, sizeof (buf) - 1));
-	  close_not_cancel_no_status (fd);
+	  __close_nocancel_nostatus (fd);
 
 	  if (n > 0)
 	    {
diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c
index 11c7e7321b..ca03877238 100644
--- a/sysdeps/unix/sysv/linux/gethostid.c
+++ b/sysdeps/unix/sysv/linux/gethostid.c
@@ -53,7 +53,7 @@ sethostid (long int id)
 
   written = __write_nocancel (fd, &id32, sizeof (id32));
 
-  close_not_cancel_no_status (fd);
+  __close_nocancel_nostatus (fd);
 
   return written != sizeof (id32) ? -1 : 0;
 }
@@ -82,7 +82,7 @@ gethostid (void)
     {
       ssize_t n = __read_nocancel (fd, &id, sizeof (id));
 
-      close_not_cancel_no_status (fd);
+      __close_nocancel_nostatus (fd);
 
       if (n == sizeof (id))
 	return id;
diff --git a/sysdeps/unix/sysv/linux/getloadavg.c b/sysdeps/unix/sysv/linux/getloadavg.c
index 64bad17046..4b75741809 100644
--- a/sysdeps/unix/sysv/linux/getloadavg.c
+++ b/sysdeps/unix/sysv/linux/getloadavg.c
@@ -43,7 +43,7 @@ getloadavg (double loadavg[], int nelem)
       int i;
 
       nread = __read_nocancel (fd, buf, sizeof buf - 1);
-      close_not_cancel_no_status (fd);
+      __close_nocancel_nostatus (fd);
       if (nread <= 0)
 	return -1;
       buf[nread - 1] = '\0';
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 1de746b3d3..45c468f5a1 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -43,7 +43,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
   char uidbuf[12];
   ssize_t n = TEMP_FAILURE_RETRY (__read_nocancel (fd, uidbuf,
 						   sizeof (uidbuf)));
-  close_not_cancel_no_status (fd);
+  __close_nocancel_nostatus (fd);
 
   uid_t uid;
   char *endp;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index d1400d6cc6..d02c86d739 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -180,7 +180,7 @@ __get_nprocs (void)
 	  }
 	while (l < re);
 
-      close_not_cancel_no_status (fd);
+      __close_nocancel_nostatus (fd);
 
       if (result > 0)
 	goto out;
@@ -207,7 +207,7 @@ __get_nprocs (void)
 	else if (isdigit (l[3]))
 	  ++result;
 
-      close_not_cancel_no_status (fd);
+      __close_nocancel_nostatus (fd);
     }
   else
     {
@@ -215,7 +215,7 @@ __get_nprocs (void)
       if (fd != -1)
 	{
 	  GET_NPROCS_PARSER (fd, buffer, cp, re, buffer_end, result);
-	  close_not_cancel_no_status (fd);
+	  __close_nocancel_nostatus (fd);
 	}
     }
 
diff --git a/sysdeps/unix/sysv/linux/grantpt.c b/sysdeps/unix/sysv/linux/grantpt.c
index 97c6ba7997..2030e07fa6 100644
--- a/sysdeps/unix/sysv/linux/grantpt.c
+++ b/sysdeps/unix/sysv/linux/grantpt.c
@@ -26,7 +26,7 @@ close_all_fds (void)
 	    char *endp;
 	    long int fd = strtol (d->d_name, &endp, 10);
 	    if (*endp == '\0' && fd != PTY_FILENO && fd != dirfd (dir))
-	      close_not_cancel_no_status (fd);
+	      __close_nocancel_nostatus (fd);
 	  }
 
       __closedir (dir);
diff --git a/sysdeps/unix/sysv/linux/i386/smp.h b/sysdeps/unix/sysv/linux/i386/smp.h
index eb1ac5ddea..320958ae98 100644
--- a/sysdeps/unix/sysv/linux/i386/smp.h
+++ b/sysdeps/unix/sysv/linux/i386/smp.h
@@ -47,7 +47,7 @@ is_smp_system (void)
 	/* This also didn't work.  We give up and say it's a UP machine.  */
 	u.buf[0] = '\0';
 
-      close_not_cancel_no_status (fd);
+      __close_nocancel_nostatus (fd);
       cp = u.buf;
     }
 
diff --git a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
index 6aab1e87a6..79c95b4bd9 100644
--- a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
+++ b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
@@ -41,7 +41,7 @@ has_cpuclock (void)
 	      || buf[0] != '0' || buf[1] != '\n')
 	    newval = -1;
 
-	  close_not_cancel_no_status (fd);
+	  __close_nocancel_nostatus (fd);
 	}
 
       itc_usable = newval;
diff --git a/sysdeps/unix/sysv/linux/if_index.c b/sysdeps/unix/sysv/linux/if_index.c
index 8ba5eae781..56f3f136cb 100644
--- a/sysdeps/unix/sysv/linux/if_index.c
+++ b/sysdeps/unix/sysv/linux/if_index.c
@@ -47,12 +47,12 @@ __if_nametoindex (const char *ifname)
   if (__ioctl (fd, SIOCGIFINDEX, &ifr) < 0)
     {
       int saved_errno = errno;
-      close_not_cancel_no_status (fd);
+      __close_nocancel_nostatus (fd);
       if (saved_errno == EINVAL)
 	__set_errno (ENOSYS);
       return 0;
     }
-  close_not_cancel_no_status (fd);
+  __close_nocancel_nostatus (fd);
   return ifr.ifr_ifindex;
 #endif
 }
@@ -224,7 +224,7 @@ __if_indextoname (unsigned int ifindex, char *ifname)
   ifr.ifr_ifindex = ifindex;
   status = __ioctl (fd, SIOCGIFNAME, &ifr);
 
-  close_not_cancel_no_status (fd);
+  __close_nocancel_nostatus (fd);
 
   if (status  < 0)
     {
diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c
index c7c6a07004..4bc152145c 100644
--- a/sysdeps/unix/sysv/linux/libc_fatal.c
+++ b/sysdeps/unix/sysv/linux/libc_fatal.c
@@ -59,7 +59,7 @@ backtrace_and_maps (int do_abort, bool written, int fd)
           while ((n2 = __read_nocancel (fd2, buf, sizeof (buf))) > 0)
             if (__write_nocancel (fd, buf, n2) != n2)
               break;
-          close_not_cancel_no_status (fd2);
+          __close_nocancel_nostatus (fd2);
         }
     }
 }
diff --git a/sysdeps/unix/sysv/linux/malloc-sysdep.h b/sysdeps/unix/sysv/linux/malloc-sysdep.h
index 7a7acbadb8..4bb7bc0a1d 100644
--- a/sysdeps/unix/sysv/linux/malloc-sysdep.h
+++ b/sysdeps/unix/sysv/linux/malloc-sysdep.h
@@ -49,7 +49,7 @@ check_may_shrink_heap (void)
 	  char val;
 	  ssize_t n = __read_nocancel (fd, &val, 1);
 	  may_shrink_heap = n > 0 && val == '2';
-	  close_not_cancel_no_status (fd);
+	  __close_nocancel_nostatus (fd);
 	}
     }
 
diff --git a/sysdeps/unix/sysv/linux/mq_notify.c b/sysdeps/unix/sysv/linux/mq_notify.c
index 626430ccc7..f12e6f52c1 100644
--- a/sysdeps/unix/sysv/linux/mq_notify.c
+++ b/sysdeps/unix/sysv/linux/mq_notify.c
@@ -209,7 +209,7 @@ init_mq_netlink (void)
 
   if (err != 0)
     {
-      close_not_cancel_no_status (netlink_socket);
+      __close_nocancel_nostatus (netlink_socket);
       netlink_socket = -1;
     }
 }
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 08ad773486..51824515da 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -51,13 +51,16 @@ __typeof (__write) __write_nocancel;
 libc_hidden_proto (__write_nocancel)
 
 /* Uncancelable close.  */
-#define __close_nocancel(fd) \
-  INLINE_SYSCALL (close, 1, fd)
-#define close_not_cancel(fd) \
-  __close_nocancel (fd)
-#define close_not_cancel_no_status(fd) \
-  (void) ({ INTERNAL_SYSCALL_DECL (err);				      \
-	    INTERNAL_SYSCALL (close, err, 1, (fd)); })
+__typeof (__close) __close_nocancel;
+libc_hidden_proto (__close_nocancel)
+
+/* Non cancellable close syscall that does not also set errno in case of
+   failure.  */
+static inline void
+__close_nocancel_nostatus (int fd)
+{
+  __close_nocancel (fd);
+}
 
 /* Uncancelable writev.  */
 #define writev_not_cancel_no_status(fd, iov, n) \
diff --git a/sysdeps/unix/sysv/linux/pthread_getname.c b/sysdeps/unix/sysv/linux/pthread_getname.c
index 93c1dfd729..d3dfee03a4 100644
--- a/sysdeps/unix/sysv/linux/pthread_getname.c
+++ b/sysdeps/unix/sysv/linux/pthread_getname.c
@@ -63,7 +63,7 @@ pthread_getname_np (pthread_t th, char *buf, size_t len)
 	buf[n] = '\0';
     }
 
-  close_not_cancel_no_status (fd);
+  __close_nocancel_nostatus (fd);
 
   return res;
 }
diff --git a/sysdeps/unix/sysv/linux/pthread_setname.c b/sysdeps/unix/sysv/linux/pthread_setname.c
index c5e9a339e8..2f68086822 100644
--- a/sysdeps/unix/sysv/linux/pthread_setname.c
+++ b/sysdeps/unix/sysv/linux/pthread_setname.c
@@ -57,7 +57,7 @@ pthread_setname_np (pthread_t th, const char *name)
   else if (n != name_len)
     res = EIO;
 
-  close_not_cancel_no_status (fd);
+  __close_nocancel_nostatus (fd);
 
   return res;
 }
diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
index 4994a07491..dea1650d08 100644
--- a/sysdeps/unix/sysv/linux/spawni.c
+++ b/sysdeps/unix/sysv/linux/spawni.c
@@ -205,7 +205,7 @@ __spawni_child (void *arguments)
 	  switch (action->tag)
 	    {
 	    case spawn_do_close:
-	      if (close_not_cancel (action->action.close_action.fd) != 0)
+	      if (__close_nocancel (action->action.close_action.fd) != 0)
 		{
 		  if (!have_fdlimit)
 		    {
@@ -228,7 +228,7 @@ __spawni_child (void *arguments)
 		   with the process already at maximum number of file descriptor
 		   opened and also for multiple actions on single-open special
 		   paths (like /dev/watchdog).  */
-		close_not_cancel (action->action.open_action.fd);
+		__close_nocancel (action->action.open_action.fd);
 
 		int ret = __open_nocancel (action->action.open_action.path,
 					   action->action.
@@ -247,7 +247,7 @@ __spawni_child (void *arguments)
 			!= action->action.open_action.fd)
 		      goto fail;
 
-		    if (close_not_cancel (new_fd) != 0)
+		    if (__close_nocancel (new_fd) != 0)
 		      goto fail;
 		  }
 	      }
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index f9becfbb33..773a6acfd4 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -122,7 +122,7 @@ __sysconf (int name)
 	  char buf[32];
 	  ssize_t n;
 	  n = TEMP_FAILURE_RETRY (__read_nocancel (fd, buf, sizeof (buf) - 1));
-	  close_not_cancel_no_status (fd);
+	  __close_nocancel_nostatus (fd);
 
 	  if (n > 0)
 	    {