Patchwork Definition of __USE_MISC?

login
register
mail settings
Submitter Florian Weimer
Date Oct. 5, 2017, 9:50 a.m.
Message ID <24683c8c-e21c-7b7f-8525-0cb847b6cd81@redhat.com>
Download mbox | patch
Permalink /patch/23337/
State New
Headers show

Comments

Florian Weimer - Oct. 5, 2017, 9:50 a.m.
On 10/05/2017 08:07 AM, Sebastian Huber wrote:
> Hello,
> 
> according to the comment in features.h we have:
> 
> __USE_MISC        Define things from 4.3BSD or System V Unix.
> 
> What about interfaces that are present on newer BSD systems by default, 
> e.g. we have in glibc strings.h:
> 
> /* The following two functions are non-standard but necessary for non-32 
> bit
>     platforms.  */
> # ifdef    __USE_GNU
> extern int ffsl (long int __l) __THROW __attribute_const__;
> __extension__ extern int ffsll (long long int __ll)
>       __THROW __attribute_const__;
> # endif
> 
> In FreeBSD strings.h we have:
> 
> #if __BSD_VISIBLE
> int     ffsl(long) __pure2;
> int     ffsll(long long) __pure2;
> int     fls(int) __pure2;
> int     flsl(long) __pure2;
> int     flsll(long long) __pure2;
> #endif
> 
> Would it be possible to change the guard in glibc to __USE_MISC?

Yes, it should be a simple change.  I was worried about the long long 
part initially, but we have precedent for using long long under 
__USE_MISC (strtouq in <stdlib.h>).

Patch attached.

Thanks,
Florian
Sebastian Huber - Oct. 10, 2017, 5:41 a.m.
On 05/10/17 11:50, Florian Weimer wrote:

> On 10/05/2017 08:07 AM, Sebastian Huber wrote:
>> Hello,
>>
>> according to the comment in features.h we have:
>>
>> __USE_MISC        Define things from 4.3BSD or System V Unix.
>>
>> What about interfaces that are present on newer BSD systems by 
>> default, e.g. we have in glibc strings.h:
>>
>> /* The following two functions are non-standard but necessary for 
>> non-32 bit
>>     platforms.  */
>> # ifdef    __USE_GNU
>> extern int ffsl (long int __l) __THROW __attribute_const__;
>> __extension__ extern int ffsll (long long int __ll)
>>       __THROW __attribute_const__;
>> # endif
>>
>> In FreeBSD strings.h we have:
>>
>> #if __BSD_VISIBLE
>> int     ffsl(long) __pure2;
>> int     ffsll(long long) __pure2;
>> int     fls(int) __pure2;
>> int     flsl(long) __pure2;
>> int     flsll(long long) __pure2;
>> #endif
>>
>> Would it be possible to change the guard in glibc to __USE_MISC?
>
> Yes, it should be a simple change.  I was worried about the long long 
> part initially, but we have precedent for using long long under 
> __USE_MISC (strtouq in <stdlib.h>).
>
> Patch attached. 

What are the opinions with respect to this patch? The ffsl() and ffsll() 
are BSD visible in FreeBSD,  DragonFlyBSD, some Mac OS X and musl. They 
are not available in OpenBSD and NetBSD.
Florian Weimer - Oct. 17, 2017, 12:01 p.m.
On 10/10/2017 07:41 AM, Sebastian Huber wrote:
> On 05/10/17 11:50, Florian Weimer wrote:
> 
>> On 10/05/2017 08:07 AM, Sebastian Huber wrote:
>>> Hello,
>>>
>>> according to the comment in features.h we have:
>>>
>>> __USE_MISC        Define things from 4.3BSD or System V Unix.
>>>
>>> What about interfaces that are present on newer BSD systems by 
>>> default, e.g. we have in glibc strings.h:
>>>
>>> /* The following two functions are non-standard but necessary for 
>>> non-32 bit
>>>     platforms.  */
>>> # ifdef    __USE_GNU
>>> extern int ffsl (long int __l) __THROW __attribute_const__;
>>> __extension__ extern int ffsll (long long int __ll)
>>>       __THROW __attribute_const__;
>>> # endif
>>>
>>> In FreeBSD strings.h we have:
>>>
>>> #if __BSD_VISIBLE
>>> int     ffsl(long) __pure2;
>>> int     ffsll(long long) __pure2;
>>> int     fls(int) __pure2;
>>> int     flsl(long) __pure2;
>>> int     flsll(long long) __pure2;
>>> #endif
>>>
>>> Would it be possible to change the guard in glibc to __USE_MISC?
>>
>> Yes, it should be a simple change.  I was worried about the long long 
>> part initially, but we have precedent for using long long under 
>> __USE_MISC (strtouq in <stdlib.h>).
>>
>> Patch attached. 
> 
> What are the opinions with respect to this patch? The ffsl() and ffsll() 
> are BSD visible in FreeBSD,  DragonFlyBSD, some Mac OS X and musl. They 
> are not available in OpenBSD and NetBSD.

Unless there are objects, I'm going to check this in later this week.

Thanks,
Florian

Patch


Recent BSDs declare these functions, too.

2017-10-05  Florian Weimer  <fweimer@redhat.com>

	* string/strings.h (ffsl, ffsll): Declare under __USE_MISC, not
	just __USE_GNU.

diff --git a/string/strings.h b/string/strings.h
index 630b3adc23..27508e31b8 100644
--- a/string/strings.h
+++ b/string/strings.h
@@ -106,7 +106,7 @@  extern int ffs (int __i) __THROW __attribute_const__;
 
 /* The following two functions are non-standard but necessary for non-32 bit
    platforms.  */
-# ifdef	__USE_GNU
+# ifdef	__USE_MISC
 extern int ffsl (long int __l) __THROW __attribute_const__;
 __extension__ extern int ffsll (long long int __ll)
      __THROW __attribute_const__;