bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] hurd: Implement close_range and closefrom


From: Adhemerval Zanella
Subject: Re: [PATCH] hurd: Implement close_range and closefrom
Date: Sun, 7 Nov 2021 15:41:34 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1


On 07/11/2021 12:17, Samuel Thibault via Libc-alpha wrote:
> Hello,
> 
> Applied, thanks!
> 
> (I have just fixed the symbol version: glibc 2.34 is already out, we are
> preparing glibc 2.35).

We are trying to avoid it by asking the sender to send a fully working
change (so git-pw can be applied and pushed without modification).

>> diff --git a/sysdeps/mach/hurd/closefrom.c b/sysdeps/mach/hurd/closefrom.c
>> new file mode 100644
>> index 0000000000..5d667cf6c4
>> --- /dev/null
>> +++ b/sysdeps/mach/hurd/closefrom.c
>> @@ -0,0 +1,29 @@
>> +/* Close a range of file descriptors.  Hurd version.
>> +   Copyright (C) 2021 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 <unistd.h>
>> +#include <sys/param.h>
>> +
>> +void
>> +__closefrom (int lowfd)
>> +{
>> +  int l = MAX (0, lowfd);
>> +
>> +  (void) __close_range (l, ~0U, 0);
>> +}

Since hurd is now also mimicking Linuxism, I think we should move close_range()
to be a default exported symbol (based on default closefrom implementation
that calls __getdtablesize() plus __close_nocancel_nostatus()) and
make closefrom() calls it.  We can refactor __closefrom_fallback() to
be empty static inline for hurd (so it would be optimized away).

I really want to avoid to keep adding system specific implementation that
is just similar to generic code. 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]