public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Use __BSD_VISIBLE for RTEMS <sys/_termios.h>
@ 2017-05-23  8:23 Sebastian Huber
  2017-05-23 15:16 ` Craig Howland
  0 siblings, 1 reply; 6+ messages in thread
From: Sebastian Huber @ 2017-05-23  8:23 UTC (permalink / raw)
  To: newlib

The Termios header <sys/_termios.h> used _POSIX_SOURCE directly to
determine if a thing should be exposed to the user.  This circumvented
the feature mechanisms of <sys/cdefs.h>.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
 newlib/libc/sys/rtems/include/sys/_termios.h | 46 ++++++++++++++--------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/newlib/libc/sys/rtems/include/sys/_termios.h b/newlib/libc/sys/rtems/include/sys/_termios.h
index c8fe054da..2e7cc36c2 100644
--- a/newlib/libc/sys/rtems/include/sys/_termios.h
+++ b/newlib/libc/sys/rtems/include/sys/_termios.h
@@ -42,15 +42,15 @@
  */
 #define	VEOF		0	/* ICANON */
 #define	VEOL		1	/* ICANON */
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE
 #define	VEOL2		2	/* ICANON together with IEXTEN */
 #endif
 #define	VERASE		3	/* ICANON */
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE
 #define	VWERASE 	4	/* ICANON together with IEXTEN */
 #endif
 #define	VKILL		5	/* ICANON */
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE
 #define	VREPRINT 	6	/* ICANON together with IEXTEN */
 #define	VERASE2 	7	/* ICANON */
 #endif
@@ -58,18 +58,18 @@
 #define	VINTR		8	/* ISIG */
 #define	VQUIT		9	/* ISIG */
 #define	VSUSP		10	/* ISIG */
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE
 #define	VDSUSP		11	/* ISIG together with IEXTEN */
 #endif
 #define	VSTART		12	/* IXON, IXOFF */
 #define	VSTOP		13	/* IXON, IXOFF */
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE
 #define	VLNEXT		14	/* IEXTEN */
 #define	VDISCARD	15	/* IEXTEN */
 #endif
 #define	VMIN		16	/* !ICANON */
 #define	VTIME		17	/* !ICANON */
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE
 #define	VSTATUS		18	/* ICANON together with IEXTEN */
 /*			19	   spare 2 */
 #endif
@@ -91,16 +91,16 @@
 #define	ICRNL		0x00000100	/* map CR to NL (ala CRMOD) */
 #define	IXON		0x00000200	/* enable output flow control */
 #define	IXOFF		0x00000400	/* enable input flow control */
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE
 #define	IXANY		0x00000800	/* any char will restart after stop */
 #define	IMAXBEL		0x00002000	/* ring bell on input queue full */
-#endif  /*_POSIX_SOURCE */
+#endif
 
 /*
  * Output flags - software output processing
  */
 #define	OPOST		0x00000001	/* enable following output processing */
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE
 #define	ONLCR		0x00000002	/* map NL to CR-NL (ala CRMOD) */
 #define	TABDLY		0x00000004	/* tab delay mask */
 #define	    TAB0	    0x00000000	    /* no tab delay and expansion */
@@ -109,12 +109,12 @@
 #define	OCRNL		0x00000010	/* map CR to NL on output */
 #define	ONOCR		0x00000020	/* no CR output at column 0 */
 #define	ONLRET		0x00000040	/* NL performs CR function */
-#endif  /*_POSIX_SOURCE */
+#endif /* __BSD_VISIBLE */
 
 /*
  * Control flags - hardware control of terminal
  */
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE
 #define	CIGNORE		0x00000001	/* ignore control flags */
 #endif
 #define	CSIZE		0x00000300	/* character size mask */
@@ -128,14 +128,14 @@
 #define	PARODD		0x00002000	/* odd parity, else even */
 #define	HUPCL		0x00004000	/* hang up on last close */
 #define	CLOCAL		0x00008000	/* ignore modem status lines */
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE
 #define	CCTS_OFLOW	0x00010000	/* CTS flow control of output */
 #define	CRTSCTS		(CCTS_OFLOW | CRTS_IFLOW)
 #define	CRTS_IFLOW	0x00020000	/* RTS flow control of input */
 #define	CDTR_IFLOW	0x00040000	/* DTR flow control of input */
 #define	CDSR_OFLOW	0x00080000	/* DSR flow control of output */
 #define	CCAR_OFLOW	0x00100000	/* DCD flow control of output */
-#endif
+#endif /* __BSD_VISIBLE */
 
 
 /*
@@ -146,30 +146,30 @@
  * input flag.
  */
 
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE
 #define	ECHOKE		0x00000001	/* visual erase for line kill */
-#endif  /*_POSIX_SOURCE */
+#endif
 #define	ECHOE		0x00000002	/* visually erase chars */
 #define	ECHOK		0x00000004	/* echo NL after line kill */
 #define	ECHO		0x00000008	/* enable echoing */
 #define	ECHONL		0x00000010	/* echo NL even if ECHO is off */
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE
 #define	ECHOPRT		0x00000020	/* visual erase mode for hardcopy */
 #define	ECHOCTL  	0x00000040	/* echo control chars as ^(Char) */
-#endif  /*_POSIX_SOURCE */
+#endif
 #define	ISIG		0x00000080	/* enable signals INTR, QUIT, [D]SUSP */
 #define	ICANON		0x00000100	/* canonicalize input lines */
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE
 #define	ALTWERASE	0x00000200	/* use alternate WERASE algorithm */
-#endif  /*_POSIX_SOURCE */
+#endif
 #define	IEXTEN		0x00000400	/* enable DISCARD and LNEXT */
 #define	EXTPROC         0x00000800      /* external processing */
 #define	TOSTOP		0x00400000	/* stop background jobs from output */
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE
 #define	FLUSHO		0x00800000	/* output being flushed (state) */
 #define	NOKERNINFO	0x02000000	/* no kernel output from VSTATUS */
 #define	PENDIN		0x20000000	/* XXX retype pending input (state) */
-#endif  /*_POSIX_SOURCE */
+#endif
 #define	NOFLSH		0x80000000	/* don't flush after interrupt */
 
 /*
@@ -191,7 +191,7 @@
 #define	B9600	9600
 #define	B19200	19200
 #define	B38400	38400
-#ifndef _POSIX_SOURCE
+#if __BSD_VISIBLE
 #define	B7200	7200
 #define	B14400	14400
 #define	B28800	28800
@@ -203,7 +203,7 @@
 #define	B921600	921600
 #define	EXTA	19200
 #define	EXTB	38400
-#endif  /* !_POSIX_SOURCE */
+#endif /* __BSD_VISIBLE */
 
 typedef unsigned int	tcflag_t;
 typedef unsigned char	cc_t;
-- 
2.12.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Use __BSD_VISIBLE for RTEMS <sys/_termios.h>
  2017-05-23  8:23 [PATCH] Use __BSD_VISIBLE for RTEMS <sys/_termios.h> Sebastian Huber
@ 2017-05-23 15:16 ` Craig Howland
  2017-05-23 21:20   ` Yaakov Selkowitz
  2017-05-24  5:42   ` Sebastian Huber
  0 siblings, 2 replies; 6+ messages in thread
From: Craig Howland @ 2017-05-23 15:16 UTC (permalink / raw)
  To: newlib

On 05/23/2017 04:23 AM, Sebastian Huber wrote:
> The Termios header <sys/_termios.h> used _POSIX_SOURCE directly to
> determine if a thing should be exposed to the user.  This circumvented
> the feature mechanisms of <sys/cdefs.h>.
Would you please explain why !_POSIX_SOURCE being replaced with __BSD_VISIBLE 
rather than, for example, !__POSIX_VISIBLE?  That is, you seem to not only be 
updating to sys/features.h macro names, but also shifting exactly how the gate 
is done.  (I'm not saying it is necessarily incorrect, just that the explanation 
does not mention the logic change.  The two are not logical opposites, so an 
implication is that the original gate of POSIX is not really the right one.)
Craig

>
> Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
> ---
>   newlib/libc/sys/rtems/include/sys/_termios.h | 46 ++++++++++++++--------------
>   1 file changed, 23 insertions(+), 23 deletions(-)
>
> diff --git a/newlib/libc/sys/rtems/include/sys/_termios.h b/newlib/libc/sys/rtems/include/sys/_termios.h
> index c8fe054da..2e7cc36c2 100644
> --- a/newlib/libc/sys/rtems/include/sys/_termios.h
> +++ b/newlib/libc/sys/rtems/include/sys/_termios.h
> @@ -42,15 +42,15 @@
>    */
>   #define	VEOF		0	/* ICANON */
>   #define	VEOL		1	/* ICANON */
> -#ifndef _POSIX_SOURCE
> +#if __BSD_VISIBLE ...

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Use __BSD_VISIBLE for RTEMS <sys/_termios.h>
  2017-05-23 15:16 ` Craig Howland
@ 2017-05-23 21:20   ` Yaakov Selkowitz
  2017-05-24  5:42   ` Sebastian Huber
  1 sibling, 0 replies; 6+ messages in thread
From: Yaakov Selkowitz @ 2017-05-23 21:20 UTC (permalink / raw)
  To: newlib

On 2017-05-23 10:16, Craig Howland wrote:
> On 05/23/2017 04:23 AM, Sebastian Huber wrote:
>> The Termios header <sys/_termios.h> used _POSIX_SOURCE directly to
>> determine if a thing should be exposed to the user.  This circumvented
>> the feature mechanisms of <sys/cdefs.h>.
> Would you please explain why !_POSIX_SOURCE being replaced with
> __BSD_VISIBLE rather than, for example, !__POSIX_VISIBLE?  That is, you
> seem to not only be updating to sys/features.h macro names, but also
> shifting exactly how the gate is done.  (I'm not saying it is
> necessarily incorrect, just that the explanation does not mention the
> logic change.  The two are not logical opposites, so an implication is
> that the original gate of POSIX is not really the right one.)

LGTM.  This goes along with last year's feature test macros overhaul. 
Feature test macros are meant to be inclusive, not exclusive (with a few 
exceptions not relevant here), and so the original guards weren't really 
correct to start with.

-- 
Yaakov

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Use __BSD_VISIBLE for RTEMS <sys/_termios.h>
  2017-05-23 15:16 ` Craig Howland
  2017-05-23 21:20   ` Yaakov Selkowitz
@ 2017-05-24  5:42   ` Sebastian Huber
  2017-05-24  9:29     ` Sebastian Huber
  1 sibling, 1 reply; 6+ messages in thread
From: Sebastian Huber @ 2017-05-24  5:42 UTC (permalink / raw)
  To: Craig Howland, newlib



On 23/05/17 17:16, Craig Howland wrote:
> On 05/23/2017 04:23 AM, Sebastian Huber wrote:
>> The Termios header <sys/_termios.h> used _POSIX_SOURCE directly to
>> determine if a thing should be exposed to the user.  This circumvented
>> the feature mechanisms of <sys/cdefs.h>.
> Would you please explain why !_POSIX_SOURCE being replaced with 
> __BSD_VISIBLE rather than, for example, !__POSIX_VISIBLE?

A negation of visibility define makes no sense.

> That is, you seem to not only be updating to sys/features.h macro 
> names, but also shifting exactly how the gate is done.  (I'm not 
> saying it is necessarily incorrect, just that the explanation does not 
> mention the logic change.  The two are not logical opposites, so an 
> implication is that the original gate of POSIX is not really the right 
> one.) 

This is an import from FreeBSD. To me this looks like FreeBSD forgot to 
update the Termios headers to use the visibility defines.

https://lists.freebsd.org/pipermail/freebsd-hackers/2017-May/051069.html

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Use __BSD_VISIBLE for RTEMS <sys/_termios.h>
  2017-05-24  5:42   ` Sebastian Huber
@ 2017-05-24  9:29     ` Sebastian Huber
  2017-05-24 14:51       ` Craig Howland
  0 siblings, 1 reply; 6+ messages in thread
From: Sebastian Huber @ 2017-05-24  9:29 UTC (permalink / raw)
  To: Craig Howland, newlib

On 24/05/17 07:42, Sebastian Huber wrote:

>
>
> On 23/05/17 17:16, Craig Howland wrote:
>> On 05/23/2017 04:23 AM, Sebastian Huber wrote:
>>> The Termios header <sys/_termios.h> used _POSIX_SOURCE directly to
>>> determine if a thing should be exposed to the user.  This circumvented
>>> the feature mechanisms of <sys/cdefs.h>.
>> Would you please explain why !_POSIX_SOURCE being replaced with 
>> __BSD_VISIBLE rather than, for example, !__POSIX_VISIBLE?
>
> A negation of visibility define makes no sense.
>
>> That is, you seem to not only be updating to sys/features.h macro 
>> names, but also shifting exactly how the gate is done.  (I'm not 
>> saying it is necessarily incorrect, just that the explanation does 
>> not mention the logic change.  The two are not logical opposites, so 
>> an implication is that the original gate of POSIX is not really the 
>> right one.) 
>
> This is an import from FreeBSD. To me this looks like FreeBSD forgot 
> to update the Termios headers to use the visibility defines.
>
> https://lists.freebsd.org/pipermail/freebsd-hackers/2017-May/051069.html
>

I changed this in FreeBSD:

https://svnweb.freebsd.org/base?view=revision&revision=318780

I will send a v2 of the patch set for Newlib.

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Use __BSD_VISIBLE for RTEMS <sys/_termios.h>
  2017-05-24  9:29     ` Sebastian Huber
@ 2017-05-24 14:51       ` Craig Howland
  0 siblings, 0 replies; 6+ messages in thread
From: Craig Howland @ 2017-05-24 14:51 UTC (permalink / raw)
  To: Sebastian Huber, newlib

On 05/24/2017 05:29 AM, Sebastian Huber wrote:
> On 24/05/17 07:42, Sebastian Huber wrote:
>
>> On 23/05/17 17:16, Craig Howland wrote:
>>> On 05/23/2017 04:23 AM, Sebastian Huber wrote:
>>>> The Termios header <sys/_termios.h> used _POSIX_SOURCE directly to
>>>> determine if a thing should be exposed to the user.  This circumvented
>>>> the feature mechanisms of <sys/cdefs.h>.
>>> Would you please explain why !_POSIX_SOURCE being replaced with 
>>> __BSD_VISIBLE rather than, for example, !__POSIX_VISIBLE?
>>
>> A negation of visibility define makes no sense.
>>
>>> That is, you seem to not only be updating to sys/features.h macro names, but 
>>> also shifting exactly how the gate is done.  (I'm not saying it is 
>>> necessarily incorrect, just that the explanation does not mention the logic 
>>> change.  The two are not logical opposites, so an implication is that the 
>>> original gate of POSIX is not really the right one.) 
>>
>> This is an import from FreeBSD. To me this looks like FreeBSD forgot to 
>> update the Termios headers to use the visibility defines.
>>
>> https://lists.freebsd.org/pipermail/freebsd-hackers/2017-May/051069.html
>>
>
> I changed this in FreeBSD:
>
> https://svnweb.freebsd.org/base?view=revision&revision=318780
>
> I will send a v2 of the patch set for Newlib.
>
Yaakov agreed with BSD as the gate, and I also independently found a source 
which says VEOL2, VWERASE, etc. are BSD extensions; __BSD_VISIBLE is good.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-05-24 14:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-23  8:23 [PATCH] Use __BSD_VISIBLE for RTEMS <sys/_termios.h> Sebastian Huber
2017-05-23 15:16 ` Craig Howland
2017-05-23 21:20   ` Yaakov Selkowitz
2017-05-24  5:42   ` Sebastian Huber
2017-05-24  9:29     ` Sebastian Huber
2017-05-24 14:51       ` Craig Howland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).