Use inline syscalls for non-cancellable versions
This patch uses inline calls (through INLINE_SYSCALL macro) to define the non-cancellable functions macros to avoid use of the syscall_nocancel entrypoint.
This commit is contained in:
parent
b634486d57
commit
34caaafd1a
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
||||||
|
2015-06-04 Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
||||||
|
|
||||||
|
* sysdeps/unix/sysv/linux/not-cancel.h (open_not_cancel): Rewrite to
|
||||||
|
be an inline implementation regardless of library is built within.
|
||||||
|
(open_not_cancel_2): Likewise.
|
||||||
|
(__read_nocancel): Likewise.
|
||||||
|
(__write_nocancel): Likewise.
|
||||||
|
(openat_not_cancel): Likewise.
|
||||||
|
(openat_not_cancel_3): Likewise.
|
||||||
|
(openat64_not_cancel): Likewise.
|
||||||
|
(openat64_not_cancel_3): Likewise.
|
||||||
|
(__close_nocancel): Likewise.
|
||||||
|
(pause_not_cancel): Likewise.
|
||||||
|
(nanosleep_not_cancel): Likewise.
|
||||||
|
(sigsuspend_not_cancel): Likewise.
|
||||||
|
|
||||||
2015-06-04 Torvald Riegel <triegel@redhat.com>
|
2015-06-04 Torvald Riegel <triegel@redhat.com>
|
||||||
|
|
||||||
[BZ #14958]
|
[BZ #14958]
|
||||||
|
|
|
@ -17,48 +17,48 @@
|
||||||
License along with the GNU C Library; if not, see
|
License along with the GNU C Library; if not, see
|
||||||
<http://www.gnu.org/licenses/>. */
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#include <sysdep.h>
|
#ifndef NOT_CANCEL_H
|
||||||
|
# define NOT_CANCEL_H
|
||||||
|
|
||||||
#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
|
#include <sysdep.h>
|
||||||
extern int __open_nocancel (const char *, int, ...) attribute_hidden;
|
#include <errno.h>
|
||||||
extern int __close_nocancel (int) attribute_hidden;
|
#include <unistd.h>
|
||||||
extern int __read_nocancel (int, void *, size_t) attribute_hidden;
|
#include <sys/syscall.h>
|
||||||
extern int __write_nocancel (int, const void *, size_t) attribute_hidden;
|
|
||||||
extern pid_t __waitpid_nocancel (pid_t, int *, int) attribute_hidden;
|
|
||||||
extern int __openat_nocancel (int fd, const char *fname, int oflag,
|
|
||||||
mode_t mode) attribute_hidden;
|
|
||||||
extern int __openat64_nocancel (int fd, const char *fname, int oflag,
|
|
||||||
mode_t mode) attribute_hidden;
|
|
||||||
#else
|
|
||||||
# define __open_nocancel(name, ...) __open (name, __VA_ARGS__)
|
|
||||||
# define __close_nocancel(fd) __close (fd)
|
|
||||||
# define __read_nocancel(fd, buf, len) __read (fd, buf, len)
|
|
||||||
# define __write_nocancel(fd, buf, len) __write (fd, buf, len)
|
|
||||||
# define __waitpid_nocancel(pid, stat_loc, options) \
|
|
||||||
__waitpid (pid, stat_loc, options)
|
|
||||||
# define __openat_nocancel(fd, fname, oflag, mode) \
|
|
||||||
openat (fd, fname, oflag, mode)
|
|
||||||
# define __openat64_nocancel(fd, fname, oflag, mode) \
|
|
||||||
openat64 (fd, fname, oflag, mode)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Uncancelable open. */
|
/* Uncancelable open. */
|
||||||
#define open_not_cancel(name, flags, mode) \
|
#ifdef __NR_open
|
||||||
__open_nocancel (name, flags, mode)
|
# define open_not_cancel(name, flags, mode) \
|
||||||
#define open_not_cancel_2(name, flags) \
|
INLINE_SYSCALL (open, 3, name, flags, mode)
|
||||||
__open_nocancel (name, flags)
|
# define open_not_cancel_2(name, flags) \
|
||||||
|
INLINE_SYSCALL (open, 2, name, flags)
|
||||||
|
#else
|
||||||
|
# define open_not_cancel(name, flags, mode) \
|
||||||
|
INLINE_SYSCALL (openat, 4, AT_FDCWD, name, flags, mode)
|
||||||
|
# define open_not_cancel_2(name, flags) \
|
||||||
|
INLINE_SYSCALL (openat, 3, AT_FDCWD, name, flags)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Uncancelable read. */
|
||||||
|
#define __read_nocancel(fd, buf, len) \
|
||||||
|
INLINE_SYSCALL (read, 3, fd, buf, len)
|
||||||
|
|
||||||
|
/* Uncancelable write. */
|
||||||
|
#define __write_nocancel(fd, buf, len) \
|
||||||
|
INLINE_SYSCALL (write, 3, fd, buf, len)
|
||||||
|
|
||||||
/* Uncancelable openat. */
|
/* Uncancelable openat. */
|
||||||
#define openat_not_cancel(fd, fname, oflag, mode) \
|
#define openat_not_cancel(fd, fname, oflag, mode) \
|
||||||
__openat_nocancel (fd, fname, oflag, mode)
|
INLINE_SYSCALL (openat, 4, fd, fname, oflag, mode)
|
||||||
#define openat_not_cancel_3(fd, fname, oflag) \
|
#define openat_not_cancel_3(fd, fname, oflag) \
|
||||||
__openat_nocancel (fd, fname, oflag, 0)
|
INLINE_SYSCALL (openat, 3, fd, fname, oflag)
|
||||||
#define openat64_not_cancel(fd, fname, oflag, mode) \
|
#define openat64_not_cancel(fd, fname, oflag, mode) \
|
||||||
__openat64_nocancel (fd, fname, oflag, mode)
|
INLINE_SYSCALL (openat, 4, fd, fname, oflag | O_LARGEFILE, mode)
|
||||||
#define openat64_not_cancel_3(fd, fname, oflag) \
|
#define openat64_not_cancel_3(fd, fname, oflag) \
|
||||||
__openat64_nocancel (fd, fname, oflag, 0)
|
INLINE_SYSCALL (openat, 3, fd, fname, oflag | O_LARGEFILE)
|
||||||
|
|
||||||
/* Uncancelable close. */
|
/* Uncancelable close. */
|
||||||
|
#define __close_nocancel(fd) \
|
||||||
|
INLINE_SYSCALL (close, 1, fd)
|
||||||
#define close_not_cancel(fd) \
|
#define close_not_cancel(fd) \
|
||||||
__close_nocancel (fd)
|
__close_nocancel (fd)
|
||||||
#define close_not_cancel_no_status(fd) \
|
#define close_not_cancel_no_status(fd) \
|
||||||
|
@ -83,17 +83,27 @@ extern int __openat64_nocancel (int fd, const char *fname, int oflag,
|
||||||
__fcntl_nocancel (fd, cmd, val)
|
__fcntl_nocancel (fd, cmd, val)
|
||||||
|
|
||||||
/* Uncancelable waitpid. */
|
/* Uncancelable waitpid. */
|
||||||
#define waitpid_not_cancel(pid, stat_loc, options) \
|
#define __waitpid_nocancel(pid, stat_loc, options) \
|
||||||
INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
|
INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
|
||||||
|
#define waitpid_not_cancel(pid, stat_loc, options) \
|
||||||
|
__waitpid_nocancel(pid, stat_loc, options)
|
||||||
|
|
||||||
/* Uncancelable pause. */
|
/* Uncancelable pause. */
|
||||||
#define pause_not_cancel() \
|
#define pause_not_cancel() \
|
||||||
__pause_nocancel ()
|
({ sigset_t set; \
|
||||||
|
int __rc = INLINE_SYSCALL (rt_sigprocmask, 4, SIG_BLOCK, NULL, &set, \
|
||||||
|
_NSIG / 8); \
|
||||||
|
if (__rc == 0) \
|
||||||
|
__rc = INLINE_SYSCALL (rt_sigsuspend, 2, &set, _NSIG / 8); \
|
||||||
|
__rc; \
|
||||||
|
})
|
||||||
|
|
||||||
/* Uncancelable nanosleep. */
|
/* Uncancelable nanosleep. */
|
||||||
#define nanosleep_not_cancel(requested_time, remaining) \
|
#define nanosleep_not_cancel(requested_time, remaining) \
|
||||||
__nanosleep_nocancel (requested_time, remaining)
|
INLINE_SYSCALL (nanosleep, 2, requested_time, remaining)
|
||||||
|
|
||||||
/* Uncancelable sigsuspend. */
|
/* Uncancelable sigsuspend. */
|
||||||
#define sigsuspend_not_cancel(set) \
|
#define sigsuspend_not_cancel(set) \
|
||||||
__sigsuspend_nocancel (set)
|
INLINE_SYSCALL (rt_sigsuspend, 2, set, _NSIG / 8)
|
||||||
|
|
||||||
|
#endif /* NOT_CANCEL_H */
|
||||||
|
|
|
@ -41,7 +41,7 @@ __get_clockfreq (void)
|
||||||
contains at least one line like:
|
contains at least one line like:
|
||||||
timebase : 33333333
|
timebase : 33333333
|
||||||
We search for this line and convert the number into an integer. */
|
We search for this line and convert the number into an integer. */
|
||||||
int fd = __open_nocancel ("/proc/cpuinfo", O_RDONLY);
|
int fd = open_not_cancel_2 ("/proc/cpuinfo", O_RDONLY);
|
||||||
if (__glibc_likely (fd != -1))
|
if (__glibc_likely (fd != -1))
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue