similarity index 80%
rename from elf/dl-writev.h
rename to sysdeps/generic/dl-writev.h
@@ -20,37 +20,35 @@
#include <ldsodefs.h>
#include <libc-lock.h>
-/* This is used from only one place: dl-misc.c:_dl_debug_vdprintf.
- Hence it's in a header with the expectation it will be inlined.
-
- This is writev, but with a constraint added and others loosened:
+/* This is writev, but with a constraint added and others loosened:
1. Under RTLD_PRIVATE_ERRNO, it must not clobber the private errno
when another thread holds the dl_load_lock.
- 2. It is not obliged to detect and report errors at all.
- 3. It's not really obliged to deliver a single atomic write
+ 2. It's not really obliged to deliver a single atomic write
(though it may be preferable). */
-static inline void
+static inline ssize_t
_dl_writev (int fd, const struct iovec *iov, size_t niov)
{
/* Note that if __writev is an implementation that calls malloc,
this will cause linking problems building the dynamic linker. */
+ ssize_t r;
#if RTLD_PRIVATE_ERRNO
/* We have to take this lock just to be sure we don't clobber the private
errno when it's being used by another thread that cares about it.
Yet we must be sure not to try calling the lock functions before
the thread library is fully initialized. */
if (__glibc_unlikely (_dl_starting_up))
- __writev (fd, iov, niov);
+ _r = _writev (fd, iov, niov);
else
{
__rtld_lock_lock_recursive (GL(dl_load_lock));
- __writev (fd, iov, niov);
+ r = __writev (fd, iov, niov);
__rtld_lock_unlock_recursive (GL(dl_load_lock));
}
#else
- __writev (fd, iov, niov);
+ r = __writev (fd, iov, niov);
#endif
+ return r == -1 ? -errno : r;
}
@@ -16,6 +16,7 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
+#include <dl-writev.h>
#include <assert.h>
#include <ldsodefs.h>
#include <setvmaname.h>
@@ -28,14 +29,14 @@
#include FATAL_PREPARE_INCLUDE
#endif
-#ifndef WRITEV_FOR_FATAL
-# define WRITEV_FOR_FATAL writev_for_fatal
-static bool
-writev_for_fatal (int fd, const struct iovec *iov, size_t niov, size_t total)
+static void
+writev_for_fatal (int fd, const struct iovec *iov, size_t niov)
{
- return TEMP_FAILURE_RETRY (__writev (fd, iov, niov)) == total;
+ ssize_t cnt;
+ do
+ cnt = _dl_writev (fd, iov, niov);
+ while (cnt == -EINTR);
}
-#endif
/* At most a substring before each conversion specification and the
trailing substring (the plus one). */
@@ -108,7 +109,7 @@ __libc_message_impl (const char *vma_name, const char *fmt, ...)
if (iovcnt > 0)
{
- WRITEV_FOR_FATAL (fd, iov, iovcnt, total);
+ writev_for_fatal (fd, iov, iovcnt);
total = ALIGN_UP (total + sizeof (struct abort_msg_s) + 1,
GLRO(dl_pagesize));
@@ -19,19 +19,15 @@
#include <sys/uio.h>
#include <sysdep.h>
-/* This is used from only one place: dl-misc.c:_dl_debug_vdprintf.
- Hence it's in a header with the expectation it will be inlined.
-
- This is writev, but with a constraint added and others loosened:
+/* This is writev, but with a constraint added and others loosened:
1. Under RTLD_PRIVATE_ERRNO, it must not clobber the private errno
when another thread holds the dl_load_lock.
- 2. It is not obliged to detect and report errors at all.
- 3. It's not really obliged to deliver a single atomic write
+ 2. It's not really obliged to deliver a single atomic write
(though it may be preferable). */
-static inline void
+static inline ssize_t
_dl_writev (int fd, const struct iovec *iov, size_t niov)
{
- INTERNAL_SYSCALL_CALL (writev, fd, iov, niov);
+ return INTERNAL_SYSCALL_CALL (writev, fd, iov, niov);
}
deleted file mode 100644
@@ -1,36 +0,0 @@
-/* Catastrophic failure reports. Linux version.
- Copyright (C) 1993-2026 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
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <https://www.gnu.org/licenses/>. */
-
-#include <errno.h>
-#include <sys/uio.h>
-#include <stdbool.h>
-#include <sysdep.h>
-
-static bool
-writev_for_fatal (int fd, const struct iovec *iov, size_t niov, size_t total)
-{
- ssize_t cnt;
- do
- cnt = INTERNAL_SYSCALL_CALL (writev, fd, iov, niov);
- while (INTERNAL_SYSCALL_ERROR_P (cnt)
- && INTERNAL_SYSCALL_ERRNO (cnt) == EINTR);
- return cnt == total;
-}
-#define WRITEV_FOR_FATAL writev_for_fatal
-
-#include <sysdeps/posix/libc_fatal.c>