diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2017-07-03 14:39:52 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2017-08-18 10:53:47 -0300 |
commit | c647fb885cb678471f6b6a66f394b4ca5515a016 (patch) | |
tree | 5c6bd65b90aaf1dbe66e1f98df74906fcf275454 /sysdeps | |
parent | a748eb31c137e9b69c3d81765271a544f93f8fe5 (diff) | |
download | glibc-c647fb885cb678471f6b6a66f394b4ca5515a016.tar glibc-c647fb885cb678471f6b6a66f394b4ca5515a016.tar.gz glibc-c647fb885cb678471f6b6a66f394b4ca5515a016.tar.bz2 glibc-c647fb885cb678471f6b6a66f394b4ca5515a016.zip |
Consolidate non cancellable write call
This patch consolidates all the non cancellable write calls to use
the __write_nocancel identifier. For non cancellable targets it will
be just a macro to call the default respective symbol while on Linux
will be a internal one.
Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu.
* sysdeps/generic/not-cancel.h (write_not_cancel): Remove macro.
(__write_nocancel): New macro.
* sysdeps/unix/sysv/linux/not-cancel.h (__write_nocancel):
Rewrite as a function prototype.
(write_not_cancel): Remove macro.
* sysdeps/unix/sysv/linux/write.c (__write_nocancel): New function.
* gmon/gmon.c (ERR): Replace write_not_cancel with __write_nocancel.
(write_gmon): Likewise.
* libio/fileops.c (_IO_new_file_write): Likewise.
* login/utmp_file.c (pututline_file): Likewise.
(updwtmp_file): Likewise.
* stdio-common/psiginfo.c (psiginfo): Likewise.
* sysdeps/posix/spawni.c (__spawni_child): Likewise.
* sysdeps/unix/sysv/linux/gethostid.c (sethostid): Likewise.
* sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps):
Likewise.
* sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np):
Likewise.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/generic/not-cancel.h | 2 | ||||
-rw-r--r-- | sysdeps/posix/spawni.c | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/gethostid.c | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/libc_fatal.c | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/not-cancel.h | 8 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/pthread_setname.c | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/write.c | 12 |
7 files changed, 20 insertions, 12 deletions
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h index 4fada2f8cc..e91cb6cced 100644 --- a/sysdeps/generic/not-cancel.h +++ b/sysdeps/generic/not-cancel.h @@ -36,7 +36,7 @@ (void) __close (fd) #define __read_nocancel(fd, buf, n) \ __read (fd, buf, n) -#define write_not_cancel(fd, buf, n) \ +#define __write_nocancel(fd, buf, n) \ __write (fd, buf, n) #define writev_not_cancel_no_status(fd, iov, n) \ (void) __writev (fd, iov, n) diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c index 823db11ae4..b5732714ae 100644 --- a/sysdeps/posix/spawni.c +++ b/sysdeps/posix/spawni.c @@ -234,7 +234,7 @@ fail: ret = errno ? : ECHILD; if (ret) /* Since sizeof errno < PIPE_BUF, the write is atomic. */ - while (write_not_cancel (args->pipe[1], &ret, sizeof (ret)) < 0); + while (__write_nocancel (args->pipe[1], &ret, sizeof (ret)) < 0); _exit (SPAWN_ERROR); } diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c index 6e19dee30a..11c7e7321b 100644 --- a/sysdeps/unix/sysv/linux/gethostid.c +++ b/sysdeps/unix/sysv/linux/gethostid.c @@ -51,7 +51,7 @@ sethostid (long int id) if (fd < 0) return -1; - written = write_not_cancel (fd, &id32, sizeof (id32)); + written = __write_nocancel (fd, &id32, sizeof (id32)); close_not_cancel_no_status (fd); diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c index ca838a7eca..c7c6a07004 100644 --- a/sysdeps/unix/sysv/linux/libc_fatal.c +++ b/sysdeps/unix/sysv/linux/libc_fatal.c @@ -48,7 +48,7 @@ backtrace_and_maps (int do_abort, bool written, int fd) if (n > 2) { #define strnsize(str) str, strlen (str) -#define writestr(str) write_not_cancel (fd, str) +#define writestr(str) __write_nocancel (fd, str) writestr (strnsize ("======= Backtrace: =========\n")); __backtrace_symbols_fd (addrs + 1, n - 1, fd); @@ -57,7 +57,7 @@ backtrace_and_maps (int do_abort, bool written, int fd) char buf[1024]; ssize_t n2; while ((n2 = __read_nocancel (fd2, buf, sizeof (buf))) > 0) - if (write_not_cancel (fd, buf, n2) != n2) + if (__write_nocancel (fd, buf, n2) != n2) break; close_not_cancel_no_status (fd2); } diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index 3d26075e11..84dc72a1f2 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -39,8 +39,8 @@ __typeof (__read) __read_nocancel; libc_hidden_proto (__read_nocancel) /* Uncancelable write. */ -#define __write_nocancel(fd, buf, len) \ - INLINE_SYSCALL (write, 3, fd, buf, len) +__typeof (__write) __write_nocancel; +libc_hidden_proto (__write_nocancel) /* Uncancelable openat. */ #define openat_not_cancel(fd, fname, oflag, mode) \ @@ -61,10 +61,6 @@ libc_hidden_proto (__read_nocancel) (void) ({ INTERNAL_SYSCALL_DECL (err); \ INTERNAL_SYSCALL (close, err, 1, (fd)); }) -/* Uncancelable write. */ -#define write_not_cancel(fd, buf, n) \ - __write_nocancel (fd, buf, n) - /* Uncancelable writev. */ #define writev_not_cancel_no_status(fd, iov, n) \ (void) ({ INTERNAL_SYSCALL_DECL (err); \ diff --git a/sysdeps/unix/sysv/linux/pthread_setname.c b/sysdeps/unix/sysv/linux/pthread_setname.c index 93f0e9ddde..c5e9a339e8 100644 --- a/sysdeps/unix/sysv/linux/pthread_setname.c +++ b/sysdeps/unix/sysv/linux/pthread_setname.c @@ -51,7 +51,7 @@ pthread_setname_np (pthread_t th, const char *name) return errno; int res = 0; - ssize_t n = TEMP_FAILURE_RETRY (write_not_cancel (fd, name, name_len)); + ssize_t n = TEMP_FAILURE_RETRY (__write_nocancel (fd, name, name_len)); if (n < 0) res = errno; else if (n != name_len) diff --git a/sysdeps/unix/sysv/linux/write.c b/sysdeps/unix/sysv/linux/write.c index d49514502e..f8896eb2e3 100644 --- a/sysdeps/unix/sysv/linux/write.c +++ b/sysdeps/unix/sysv/linux/write.c @@ -18,6 +18,7 @@ #include <unistd.h> #include <sysdep-cancel.h> +#include <not-cancel.h> /* Write NBYTES of BUF to FD. Return the number written, or -1. */ ssize_t @@ -31,3 +32,14 @@ weak_alias (__libc_write, __write) libc_hidden_weak (__write) weak_alias (__libc_write, write) libc_hidden_weak (write) + +#if !IS_IN (rtld) +ssize_t +__write_nocancel (int fd, const void *buf, size_t nbytes) +{ + return INLINE_SYSCALL_CALL (write, fd, buf, nbytes); +} +#else +strong_alias (__libc_write, __write_nocancel) +#endif +libc_hidden_def (__write_nocancel) |