|
Packit Service |
88c9d3 |
/* Implementation of the _dl_write function. Generic version.
|
|
Packit Service |
88c9d3 |
Copyright (C) 2020 Free Software Foundation, Inc.
|
|
Packit Service |
88c9d3 |
This file is part of the GNU C Library.
|
|
Packit Service |
88c9d3 |
|
|
Packit Service |
88c9d3 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
88c9d3 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
88c9d3 |
License as published by the Free Software Foundation; either
|
|
Packit Service |
88c9d3 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
88c9d3 |
|
|
Packit Service |
88c9d3 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
88c9d3 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
88c9d3 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
88c9d3 |
Lesser General Public License for more details.
|
|
Packit Service |
88c9d3 |
|
|
Packit Service |
88c9d3 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
88c9d3 |
License along with the GNU C Library; if not, see
|
|
Packit Service |
88c9d3 |
<https://www.gnu.org/licenses/>. */
|
|
Packit Service |
88c9d3 |
|
|
Packit Service |
88c9d3 |
#include <errno.h>
|
|
Packit Service |
88c9d3 |
#include <ldsodefs.h>
|
|
Packit Service |
88c9d3 |
#include <libc-lock.h>
|
|
Packit Service |
88c9d3 |
#include <sys/uio.h>
|
|
Packit Service |
88c9d3 |
|
|
Packit Service |
88c9d3 |
ssize_t
|
|
Packit Service |
88c9d3 |
_dl_write (int fd, const void *buffer, size_t length)
|
|
Packit Service |
88c9d3 |
{
|
|
Packit Service |
88c9d3 |
struct iovec iov = { .iov_base = (void *) buffer, .iov_len = length };
|
|
Packit Service |
88c9d3 |
ssize_t ret;
|
|
Packit Service |
88c9d3 |
|
|
Packit Service |
88c9d3 |
#if RTLD_PRIVATE_ERRNO
|
|
Packit Service |
88c9d3 |
/* We have to take this lock just to be sure we don't clobber the private
|
|
Packit Service |
88c9d3 |
errno when it's being used by another thread that cares about it.
|
|
Packit Service |
88c9d3 |
Yet we must be sure not to try calling the lock functions before
|
|
Packit Service |
88c9d3 |
the thread library is fully initialized. */
|
|
Packit Service |
88c9d3 |
if (__glibc_unlikely (_dl_starting_up))
|
|
Packit Service |
88c9d3 |
{
|
|
Packit Service |
88c9d3 |
ret = __writev (fd, &iov, 1);
|
|
Packit Service |
88c9d3 |
if (ret < 0)
|
|
Packit Service |
88c9d3 |
ret = -errno;
|
|
Packit Service |
88c9d3 |
}
|
|
Packit Service |
88c9d3 |
else
|
|
Packit Service |
88c9d3 |
{
|
|
Packit Service |
88c9d3 |
__rtld_lock_lock_recursive (GL(dl_load_lock));
|
|
Packit Service |
88c9d3 |
__writev (fd, &iov, 1);
|
|
Packit Service |
88c9d3 |
if (ret < 0)
|
|
Packit Service |
88c9d3 |
ret = -errno;
|
|
Packit Service |
88c9d3 |
__rtld_lock_unlock_recursive (GL(dl_load_lock));
|
|
Packit Service |
88c9d3 |
}
|
|
Packit Service |
88c9d3 |
#else
|
|
Packit Service |
88c9d3 |
ret = __writev (fd, &iov, 1);
|
|
Packit Service |
88c9d3 |
if (ret < 0)
|
|
Packit Service |
88c9d3 |
ret = -errno;
|
|
Packit Service |
88c9d3 |
#endif
|
|
Packit Service |
88c9d3 |
|
|
Packit Service |
88c9d3 |
return ret;
|
|
Packit Service |
88c9d3 |
}
|