[v2] Remove strdup inlines

Message ID d2478592-595d-d530-f39a-b38c33199f87@linaro.org
State Dropped
Headers

Commit Message

Adhemerval Zanella Netto Feb. 9, 2017, 10:42 p.m. UTC
  On 09/02/2017 19:57, Joseph Myers wrote:
> On Thu, 9 Feb 2017, Adhemerval Zanella wrote:
> 
>> Also for strdup I think __USE_XOPEN2K8 is not required, accordingly to manual
>> it is defined for
>>
>>  _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
> 
> strdup was XSI-shaded in the 2001 edition of POSIX but moved to CX-shaded 
> in the 2008 edition.  That is, it should be declared for 
> _POSIX_C_SOURCE=200809L.  That is, the existing __USE_XOPEN2K8 condition 
> (which means non-XSI 2008 edition of POSIX) is right.

Indeed, I was in fact confused my documentation and the manpages confirmed that
it is true for glibc 2.12 and forward.  In any case, I think both these
macros should be removed [2].

[2] https://sourceware.org/ml/libc-alpha/2017-02/msg00201.html

> 
>> And __USE_XOPEN_EXTENDED will be set for _XOPEN_SOURCE >= 500 or if
>> _XOPEN_SOURCE_EXTENDED is defined.  At least all required defined are
>> suffice on conform testcases for just 
> 
> This indicates you've found a bug in the conform/ expectations - strdup 
> should be required there for POSIX2008.
> 

Right, so if I think the condition on conform/data/string.h-data should be:
  

Comments

Joseph Myers Feb. 9, 2017, 10:45 p.m. UTC | #1
On Thu, 9 Feb 2017, Adhemerval Zanella wrote:

> Right, so if I think the condition on conform/data/string.h-data should be:
> 
> diff --git a/conform/data/string.h-data b/conform/data/string.h-data
> index 39fa76c..b7c2784 100644
> --- a/conform/data/string.h-data
> +++ b/conform/data/string.h-data
> @@ -27,7 +27,7 @@ function int strcoll_l (const char*, const char*, locale_t)
>  #endif
>  function {char*} strcpy (char*, const char*)
>  function size_t strcspn (const char*, const char*)
> -#if !defined ISO && !defined ISO99 & !defined ISO11 && !defined XPG3 && !defined POSIX && !defined POSIX2008
> +#if !defined ISO && !defined ISO99 & !defined ISO11 && !defined XPG3 && !defined POSIX && defined POSIX2008

No, just remove the && !defined POSIX2008.  Exactly one of the macros for 
individual standards will always be defined when processing the conform/ 
data.
  
Adhemerval Zanella Netto Feb. 9, 2017, 10:48 p.m. UTC | #2
On 09/02/2017 20:45, Joseph Myers wrote:
> On Thu, 9 Feb 2017, Adhemerval Zanella wrote:
> 
>> Right, so if I think the condition on conform/data/string.h-data should be:
>>
>> diff --git a/conform/data/string.h-data b/conform/data/string.h-data
>> index 39fa76c..b7c2784 100644
>> --- a/conform/data/string.h-data
>> +++ b/conform/data/string.h-data
>> @@ -27,7 +27,7 @@ function int strcoll_l (const char*, const char*, locale_t)
>>  #endif
>>  function {char*} strcpy (char*, const char*)
>>  function size_t strcspn (const char*, const char*)
>> -#if !defined ISO && !defined ISO99 & !defined ISO11 && !defined XPG3 && !defined POSIX && !defined POSIX2008
>> +#if !defined ISO && !defined ISO99 & !defined ISO11 && !defined XPG3 && !defined POSIX && defined POSIX2008
> 
> No, just remove the && !defined POSIX2008.  Exactly one of the macros for 
> individual standards will always be defined when processing the conform/ 
> data.
> 

Right, I will prepare the patch.
  

Patch

diff --git a/conform/data/string.h-data b/conform/data/string.h-data
index 39fa76c..b7c2784 100644
--- a/conform/data/string.h-data
+++ b/conform/data/string.h-data
@@ -27,7 +27,7 @@  function int strcoll_l (const char*, const char*, locale_t)
 #endif
 function {char*} strcpy (char*, const char*)
 function size_t strcspn (const char*, const char*)
-#if !defined ISO && !defined ISO99 & !defined ISO11 && !defined XPG3 && !defined POSIX && !defined POSIX2008
+#if !defined ISO && !defined ISO99 & !defined ISO11 && !defined XPG3 && !defined POSIX && defined POSIX2008
 function {char*} strdup (const char*)
 #endif
 function {char*} strerror (int)