From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7800) id 18F3E386100C; Tue, 7 Jul 2020 22:03:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 18F3E386100C Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Vineet Gupta To: glibc-cvs@sourceware.org Subject: [glibc/vineet/arc-port-latest] hurd: make close a cancellation point X-Act-Checkin: glibc X-Git-Author: Samuel Thibault X-Git-Refname: refs/heads/vineet/arc-port-latest X-Git-Oldrev: 4cafcd839f8c002c290ec96c64b6d85e87e270e8 X-Git-Newrev: fd3df63fb6649720098597ced59eaa3969bbe067 Message-Id: <20200707220345.18F3E386100C@sourceware.org> Date: Tue, 7 Jul 2020 22:03:45 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Jul 2020 22:03:45 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=fd3df63fb6649720098597ced59eaa3969bbe067 commit fd3df63fb6649720098597ced59eaa3969bbe067 Author: Samuel Thibault Date: Sun Jun 28 15:51:40 2020 +0000 hurd: make close a cancellation point and add _nocancel variant. * sysdeps/mach/hurd/Makefile [io] (sysdep_routines): Add close_nocancel. * sysdeps/mach/hurd/Versions (libc.GLIBC_PRIVATE, ld.GLIBC_PRIVATE): Add __close_nocancel. * sysdeps/mach/hurd/i386/localplt.data (__close_nocancel): Allow PLT. * sysdeps/mach/hurd/close.c: Include (__libc_close): Surround _hurd_fd_close with enabling async cancel. * sysdeps/mach/hurd/close_nocancel.c: New file. * sysdeps/mach/hurd/not-cancel.h (__close_nocancel): Replace macro with declaration with hidden proto. Diff: --- sysdeps/mach/hurd/Makefile | 2 +- sysdeps/mach/hurd/Versions | 2 ++ sysdeps/mach/hurd/close.c | 4 ++++ sysdeps/mach/hurd/close_nocancel.c | 34 ++++++++++++++++++++++++++++++++++ sysdeps/mach/hurd/dl-sysdep.c | 2 ++ sysdeps/mach/hurd/i386/localplt.data | 3 ++- sysdeps/mach/hurd/not-cancel.h | 9 +++++---- 7 files changed, 50 insertions(+), 6 deletions(-) diff --git a/sysdeps/mach/hurd/Makefile b/sysdeps/mach/hurd/Makefile index a58e8c1c3d..4bfd290c09 100644 --- a/sysdeps/mach/hurd/Makefile +++ b/sysdeps/mach/hurd/Makefile @@ -196,7 +196,7 @@ sysdep_routines += cthreads endif ifeq (io, $(subdir)) -sysdep_routines += f_setlk close_nocancel_nostatus \ +sysdep_routines += f_setlk close_nocancel close_nocancel_nostatus \ open_nocancel openat_nocancel read_nocancel \ pread64_nocancel write_nocancel pwrite64_nocancel endif diff --git a/sysdeps/mach/hurd/Versions b/sysdeps/mach/hurd/Versions index 67594d8c08..c456f472c4 100644 --- a/sysdeps/mach/hurd/Versions +++ b/sysdeps/mach/hurd/Versions @@ -13,6 +13,7 @@ libc { GLIBC_PRIVATE { # Functions shared with the dynamic linker __access; __access_noerrno; __libc_read; __libc_write; __libc_lseek64; + __close_nocancel; __open_nocancel; __read_nocancel; __pread64_nocancel; __write_nocancel; @@ -55,6 +56,7 @@ ld { # functions that must be shared with libc __access; __access_noerrno; __libc_read; __libc_write; __libc_lseek64; + __close_nocancel; __open_nocancel; __read_nocancel; __pread64_nocancel; __write_nocancel; diff --git a/sysdeps/mach/hurd/close.c b/sysdeps/mach/hurd/close.c index 4b1e203084..b461087447 100644 --- a/sysdeps/mach/hurd/close.c +++ b/sysdeps/mach/hurd/close.c @@ -19,14 +19,18 @@ #include #include #include +#include /* Close the file descriptor FD. */ int __close (int fd) { error_t err; + int cancel_oldtype; + cancel_oldtype = LIBC_CANCEL_ASYNC(); err = HURD_FD_USE (fd, _hurd_fd_close (descriptor)); + LIBC_CANCEL_RESET (cancel_oldtype); return err ? __hurd_fail (err) : 0; } diff --git a/sysdeps/mach/hurd/close_nocancel.c b/sysdeps/mach/hurd/close_nocancel.c new file mode 100644 index 0000000000..3411e321ab --- /dev/null +++ b/sysdeps/mach/hurd/close_nocancel.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1991-2020 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 + . */ + +#include +#include +#include +#include +#include + +/* Close the file descriptor FD. */ +int +__close_nocancel (int fd) +{ + error_t err; + + err = HURD_FD_USE (fd, _hurd_fd_close (descriptor)); + + return err ? __hurd_fail (err) : 0; +} +libc_hidden_def (__close_nocancel) diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c index 8a87b9b0f2..2a9a6d12bc 100644 --- a/sysdeps/mach/hurd/dl-sysdep.c +++ b/sysdeps/mach/hurd/dl-sysdep.c @@ -353,6 +353,7 @@ weak_alias (__open, __open64) weak_alias (__open, __open_nocancel) check_no_hidden(__close); +check_no_hidden(__close_nocancel); int weak_function __close (int fd) { @@ -360,6 +361,7 @@ __close (int fd) __mach_port_deallocate (__mach_task_self (), (mach_port_t) fd); return 0; } +weak_alias (__close, __close_nocancel) check_no_hidden(__pread64); check_no_hidden(__pread64_nocancel); diff --git a/sysdeps/mach/hurd/i386/localplt.data b/sysdeps/mach/hurd/i386/localplt.data index 66e9c4f253..b199e14e7f 100644 --- a/sysdeps/mach/hurd/i386/localplt.data +++ b/sysdeps/mach/hurd/i386/localplt.data @@ -19,7 +19,8 @@ ld.so: _dl_catch_exception + REL R_386_GLOB_DAT ld.so: __open ? ld.so: __open64 ? ld.so: __open_nocancel -ld.so: __close +ld.so: __close ? +ld.so: __close_nocancel ld.so: __read ? ld.so: __read_nocancel ld.so: __pread64 diff --git a/sysdeps/mach/hurd/not-cancel.h b/sysdeps/mach/hurd/not-cancel.h index c627ec7bde..7e824c5f11 100644 --- a/sysdeps/mach/hurd/not-cancel.h +++ b/sysdeps/mach/hurd/not-cancel.h @@ -28,9 +28,8 @@ #include #include -/* For now we have none. Map the name to the normal functions. */ -#define __close_nocancel(fd) \ - __close (fd) +/* Non cancellable close syscall. */ +__typeof (__close) __close_nocancel; void __close_nocancel_nostatus (int fd); @@ -64,12 +63,15 @@ __typeof (__writev) __writev_nocancel; /* Non cancellable writev syscall with no status. */ void __writev_nocancel_nostatus (int fd, const struct iovec *vector, int count); +/* For now we have none. Map the name to the normal functions. */ # define __waitpid_nocancel(pid, stat_loc, options) \ __waitpid (pid, stat_loc, options) #define __fcntl64_nocancel(fd, cmd, ...) \ __fcntl64 (fd, cmd, __VA_ARGS__) #if IS_IN (libc) +hidden_proto (__close_nocancel) +hidden_proto (__close_nocancel_nostatus) hidden_proto (__open_nocancel) hidden_proto (__openat_nocancel) hidden_proto (__read_nocancel) @@ -78,7 +80,6 @@ hidden_proto (__write_nocancel) hidden_proto (__pwrite64_nocancel) hidden_proto (__writev_nocancel) hidden_proto (__writev_nocancel_nostatus) -hidden_proto (__close_nocancel_nostatus) #endif #endif /* NOT_CANCEL_H */