diff mbox

getentropy for <unistd.h>

Message ID 1dcd01a6-0ad0-94b2-ef9e-28c4c854db44@redhat.com
State New
Headers show

Commit Message

Florian Weimer Dec. 29, 2016, 8:30 a.m. UTC
On 12/28/2016 06:02 PM, Zack Weinberg wrote:
> On Wed, Dec 28, 2016 at 1:50 AM, Florian Weimer <fweimer@redhat.com> wrote:

>> It's not in 4.3BSD either, and if __USE_MISC is intended to be restricted to

>> those definitions (or those of similar vintage), then __USE_MISC would not

>> be correct.

>>

>> If __USE_MISC is free to involve, pretty much like __USE_GNU, then this is

>> not a problem.  But it's not clear to me if this is the intent.

>

> It seems to me that the *useful* distinction between __USE_MISC and

> __USE_GNU nowadays is: __USE_MISC is for non-standardized features

> that are visible by default, __USE_GNU is for non-standardized

> features that are only visible when requested with -D_GNU_SOURCE.

>

> So the decision to make when choosing between the two is "should this

> be visible by default?" I would personally tend to err on the side of

> "no" when adding new things to core headers like unistd.h.


At least we should treat getentropy and explicit_bzero in an identical 
fashion.

What about this patch?

Florian

Comments

Zack Weinberg Dec. 29, 2016, 4:39 p.m. UTC | #1
On Thu, Dec 29, 2016 at 12:30 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 12/28/2016 06:02 PM, Zack Weinberg wrote:

>>

>> So the decision to make when choosing between the two is "should this

>> be visible by default?" I would personally tend to err on the side of

>> "no" when adding new things to core headers like unistd.h.

>

> At least we should treat getentropy and explicit_bzero in an identical

> fashion.

>

> What about this patch?


Fine with me.
diff mbox

Patch

getentropy: Declare it in <unistd.h> for __USE_MISC

2016-12-29  Florian Weimer  <fweimer@redhat.com>

	* posix/unistd.h (getentropy): Declare for __USE_MISC, not just
	__USE_GNU.

diff --git a/posix/unistd.h b/posix/unistd.h
index 70b10c6..a8c9aa9 100644
--- a/posix/unistd.h
+++ b/posix/unistd.h
@@ -1157,7 +1157,7 @@  extern int pthread_atfork (void (*__prepare) (void),
 			   void (*__child) (void)) __THROW;
 #endif
 
-#ifdef __USE_GNU
+#ifdef __USE_MISC
 /* Write LENGTH bytes of randomness starting at BUFFER.  Return 0 on
    success or -1 on error.  */
 int getentropy (void *__buffer, size_t __length) __wur;