summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog19
-rw-r--r--gmon/gmon.c4
-rw-r--r--libio/fileops.c2
-rw-r--r--login/utmp_file.c4
-rw-r--r--stdio-common/psiginfo.c2
-rw-r--r--sysdeps/generic/not-cancel.h2
-rw-r--r--sysdeps/posix/spawni.c2
-rw-r--r--sysdeps/unix/sysv/linux/gethostid.c2
-rw-r--r--sysdeps/unix/sysv/linux/libc_fatal.c4
-rw-r--r--sysdeps/unix/sysv/linux/not-cancel.h8
-rw-r--r--sysdeps/unix/sysv/linux/pthread_setname.c2
-rw-r--r--sysdeps/unix/sysv/linux/write.c12
12 files changed, 45 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 0030e7d32f..4b99033a1d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
2017-08-18 Adhemerval Zanella <adhemerval.zanella@linaro.org>
+ * 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.
+
* sysdeps/generic/not-cancel.h (read_not_cancel): Remove macro.
(__read_nocancel): New macro.
* sysdeps/unix/sysv/linux/Versions (libc) [GLIBC_PRIVATE]: Add
diff --git a/gmon/gmon.c b/gmon/gmon.c
index 87c3c4e01b..e7701b9757 100644
--- a/gmon/gmon.c
+++ b/gmon/gmon.c
@@ -58,7 +58,7 @@ struct gmonparam _gmonparam attribute_hidden = { GMON_PROF_OFF };
static int s_scale;
#define SCALE_1_TO_1 0x10000L
-#define ERR(s) write_not_cancel (STDERR_FILENO, s, sizeof (s) - 1)
+#define ERR(s) __write_nocancel (STDERR_FILENO, s, sizeof (s) - 1)
void moncontrol (int mode);
void __moncontrol (int mode);
@@ -375,7 +375,7 @@ write_gmon (void)
memcpy (&ghdr.cookie[0], GMON_MAGIC, sizeof (ghdr.cookie));
ghdr.version = GMON_VERSION;
memset (ghdr.spare, '\0', sizeof (ghdr.spare));
- write_not_cancel (fd, &ghdr, sizeof (struct gmon_hdr));
+ __write_nocancel (fd, &ghdr, sizeof (struct gmon_hdr));
/* write PC histogram: */
write_hist (fd);
diff --git a/libio/fileops.c b/libio/fileops.c
index 80bd3f5b95..f02517877a 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -1251,7 +1251,7 @@ _IO_new_file_write (_IO_FILE *f, const void *data, _IO_ssize_t n)
{
_IO_ssize_t count = (__builtin_expect (f->_flags2
& _IO_FLAGS2_NOTCANCEL, 0)
- ? write_not_cancel (f->_fileno, data, to_do)
+ ? __write_nocancel (f->_fileno, data, to_do)
: write (f->_fileno, data, to_do));
if (count < 0)
{
diff --git a/login/utmp_file.c b/login/utmp_file.c
index 61d03d60cb..26e3f4bf89 100644
--- a/login/utmp_file.c
+++ b/login/utmp_file.c
@@ -444,7 +444,7 @@ pututline_file (const struct utmp *data)
}
/* Write the new data. */
- if (write_not_cancel (file_fd, data, sizeof (struct utmp))
+ if (__write_nocancel (file_fd, data, sizeof (struct utmp))
!= sizeof (struct utmp))
{
/* If we appended a new record this is only partially written.
@@ -505,7 +505,7 @@ updwtmp_file (const char *file, const struct utmp *utmp)
/* Write the entry. If we can't write all the bytes, reset the file
size back to the original size. That way, no partial entries
will remain. */
- if (write_not_cancel (fd, utmp, sizeof (struct utmp))
+ if (__write_nocancel (fd, utmp, sizeof (struct utmp))
!= sizeof (struct utmp))
{
__ftruncate64 (fd, offset);
diff --git a/stdio-common/psiginfo.c b/stdio-common/psiginfo.c
index 6954a42458..7bf2e2d13f 100644
--- a/stdio-common/psiginfo.c
+++ b/stdio-common/psiginfo.c
@@ -199,5 +199,5 @@ Signal generated by the completion of an I/O request");
fclose (fp);
- write_not_cancel (STDERR_FILENO, buf, strlen (buf));
+ __write_nocancel (STDERR_FILENO, buf, strlen (buf));
}
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)