<div dir="ltr">This looks OK. Everything is still public enough where a user application can register their own <ctl>-C catching function at that level.<div><br></div><div>Thanks for doing this. </div><div><br></div><div>--joel</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 7, 2020 at 1:52 AM Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de">sebastian.huber@embedded-brains.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Merge the rtems_termios_isig_status_code and<br>
rtems_termios_iproc_status_code enums into a single<br>
rtems_termios_iproc_status_code which is now a part of the API.<br>
<br>
Simplify rtems_termios_posix_isig_handler() to avoid unreachable code.<br>
<br>
Close #3800.<br>
---<br>
cpukit/include/rtems/libio.h | 47 +++++++++++++---------<br>
cpukit/libcsupport/src/termios.c | 34 ++--------------<br>
.../libcsupport/src/termios_posix_isig_handler.c | 18 ++++-----<br>
3 files changed, 40 insertions(+), 59 deletions(-)<br>
<br>
diff --git a/cpukit/include/rtems/libio.h b/cpukit/include/rtems/libio.h<br>
index b3c0e975cd..f1c9eea51b 100644<br>
--- a/cpukit/include/rtems/libio.h<br>
+++ b/cpukit/include/rtems/libio.h<br>
@@ -1904,28 +1904,37 @@ rtems_status_code rtems_termios_bufsize (<br>
);<br>
<br>
/**<br>
- * @brief Type returned by all input processing (isig) methods<br>
- */ <br>
+ * @brief The status code returned by all Termios input processing (iproc)<br>
+ * functions and input signal (isig) handlers.<br>
+ */<br>
typedef enum {<br>
/**<br>
- * This indicates that the input character was processed<br>
- * and possibly placed into the buffer.<br>
+ * @brief This status indicates that the input processing can continue.<br>
+ *<br>
+ * Input signal handlers shall return this status if no signal was raised and<br>
+ * the input processing can continue.<br>
*/<br>
- RTEMS_TERMIOS_ISIG_WAS_PROCESSED,<br>
+ RTEMS_TERMIOS_IPROC_CONTINUE,<br>
+<br>
/**<br>
- * This indicates that the input character was not processed and<br>
- * subsequent processing is required.<br>
+ * @brief This status indicates that the input processing should stop due to<br>
+ * a signal.<br>
+ *<br>
+ * This indicates that the character was processed and determined to be one<br>
+ * that requires a signal to be raised (e.g. VINTR or VKILL). The tty must<br>
+ * be in the right Termios mode for this to occur. There is no further<br>
+ * processing of this character required and the pending read() operation<br>
+ * should be interrupted.<br>
*/<br>
- RTEMS_TERMIOS_ISIG_WAS_NOT_PROCESSED,<br>
+ RTEMS_TERMIOS_IPROC_INTERRUPT,<br>
+<br>
/**<br>
- * This indicates that the character was processed and determined<br>
- * to be one that requires a signal to be raised (e.g. VINTR or<br>
- * VKILL). The tty must be in the right termios mode for this to<br>
- * occur. There is no further processing of this character required and<br>
- * the pending read() operation should be interrupted.<br>
+ * @brief This status indicates that the input processing is done.<br>
+ *<br>
+ * This status shall not be returned by input processing signal handlers.<br>
*/<br>
- RTEMS_TERMIOS_ISIG_INTERRUPT_READ<br>
-} rtems_termios_isig_status_code;<br>
+ RTEMS_TERMIOS_IPROC_DONE<br>
+} rtems_termios_iproc_status_code;<br>
<br>
/**<br>
* @brief Type for ISIG (VINTR/VKILL) handler<br>
@@ -1941,9 +1950,9 @@ typedef enum {<br>
* @param tty termios structure pointer for this input tty<br>
*<br>
* @return The value returned is according to that documented<br>
- * for @ref rtems_termios_isig_status_code.<br>
+ * for @ref rtems_termios_iproc_status_code.<br>
*/<br>
-typedef rtems_termios_isig_status_code (*rtems_termios_isig_handler)(<br>
+typedef rtems_termios_iproc_status_code (*rtems_termios_isig_handler)(<br>
unsigned char c,<br>
struct rtems_termios_tty *tty<br>
);<br>
@@ -1966,7 +1975,7 @@ typedef rtems_termios_isig_status_code (*rtems_termios_isig_handler)(<br>
* @return The value returned is according to that documented<br>
* for all methods adhering to @ref rtems_termios_isig_handler.<br>
*/<br>
-rtems_termios_isig_status_code rtems_termios_default_isig_handler(<br>
+rtems_termios_iproc_status_code rtems_termios_default_isig_handler(<br>
unsigned char c,<br>
struct rtems_termios_tty *tty<br>
);<br>
@@ -1984,7 +1993,7 @@ rtems_termios_isig_status_code rtems_termios_default_isig_handler(<br>
* @return The value returned is according to that documented<br>
* for all methods adhering to @ref rtems_termios_isig_handler.<br>
*/<br>
-rtems_termios_isig_status_code rtems_termios_posix_isig_handler(<br>
+rtems_termios_iproc_status_code rtems_termios_posix_isig_handler(<br>
unsigned char c,<br>
struct rtems_termios_tty *tty<br>
);<br>
diff --git a/cpukit/libcsupport/src/termios.c b/cpukit/libcsupport/src/termios.c<br>
index 3690ee3fc3..75925cf8ec 100644<br>
--- a/cpukit/libcsupport/src/termios.c<br>
+++ b/cpukit/libcsupport/src/termios.c<br>
@@ -1311,12 +1311,12 @@ static rtems_termios_isig_handler termios_isig_handler =<br>
* This is the default method to process VKILL or VQUIT characters if<br>
* ISIG processing is enabled. Note that it does nothing.<br>
*/<br>
-rtems_termios_isig_status_code rtems_termios_default_isig_handler(<br>
+rtems_termios_iproc_status_code rtems_termios_default_isig_handler(<br>
unsigned char c,<br>
struct rtems_termios_tty *tty<br>
)<br>
{<br>
- return RTEMS_TERMIOS_ISIG_WAS_NOT_PROCESSED;<br>
+ return RTEMS_TERMIOS_IPROC_CONTINUE;<br>
}<br>
<br>
/*<br>
@@ -1335,28 +1335,6 @@ rtems_status_code rtems_termios_register_isig_handler(<br>
return RTEMS_SUCCESSFUL;<br>
}<br>
<br>
-/**<br>
- * @brief Type returned by all input processing (iproc) methods<br>
- */<br>
-typedef enum {<br>
- /**<br>
- * This indicates that the input processing can continue.<br>
- */<br>
- RTEMS_TERMIOS_IPROC_CONTINUE,<br>
- /**<br>
- * This indicates that the input processing is done.<br>
- */<br>
- RTEMS_TERMIOS_IPROC_DONE,<br>
- /**<br>
- * This indicates that the character was processed and determined<br>
- * to be one that requires a signal to be raised (e.g. VINTR or<br>
- * VKILL). The tty must be in the right termios mode for this to<br>
- * occur. There is no further processing of this character required and<br>
- * the pending read() operation should be interrupted.<br>
- */<br>
- RTEMS_TERMIOS_IPROC_INTERRUPT<br>
-} rtems_termios_iproc_status_code;<br>
-<br>
/*<br>
* Process a single input character<br>
*/<br>
@@ -1369,13 +1347,7 @@ iproc (unsigned char c, struct rtems_termios_tty *tty)<br>
*/<br>
if ((tty->termios.c_lflag & ISIG)) {<br>
if ((c == tty->termios.c_cc[VINTR]) || (c == tty->termios.c_cc[VQUIT])) {<br>
- rtems_termios_isig_status_code rc;<br>
- rc = (*termios_isig_handler)(c, tty);<br>
- if (rc == RTEMS_TERMIOS_ISIG_INTERRUPT_READ) {<br>
- return RTEMS_TERMIOS_IPROC_INTERRUPT;<br>
- }<br>
-<br>
- return RTEMS_TERMIOS_IPROC_CONTINUE;<br>
+ return (*termios_isig_handler)(c, tty);<br>
}<br>
}<br>
<br>
diff --git a/cpukit/libcsupport/src/termios_posix_isig_handler.c b/cpukit/libcsupport/src/termios_posix_isig_handler.c<br>
index 5be2d10aa2..5f505fecb4 100644<br>
--- a/cpukit/libcsupport/src/termios_posix_isig_handler.c<br>
+++ b/cpukit/libcsupport/src/termios_posix_isig_handler.c<br>
@@ -20,20 +20,20 @@<br>
<br>
#include <signal.h><br>
<br>
-rtems_termios_isig_status_code rtems_termios_posix_isig_handler(<br>
+rtems_termios_iproc_status_code rtems_termios_posix_isig_handler(<br>
unsigned char c,<br>
struct rtems_termios_tty *tty<br>
)<br>
{<br>
- if (c == tty->termios.c_cc[VINTR]) {<br>
- raise(SIGINT);<br>
- return RTEMS_TERMIOS_ISIG_INTERRUPT_READ;<br>
- }<br>
+ int sig;<br>
<br>
- if (c == tty->termios.c_cc[VQUIT]) {<br>
- raise(SIGQUIT);<br>
- return RTEMS_TERMIOS_ISIG_INTERRUPT_READ;<br>
+ if ( c == tty->termios.c_cc[ VQUIT ] ) {<br>
+ sig = SIGQUIT;<br>
+ } else {<br>
+ sig = SIGINT;<br>
}<br>
<br>
- return RTEMS_TERMIOS_ISIG_WAS_NOT_PROCESSED;<br>
+ (void) raise( sig );<br>
+<br>
+ return RTEMS_TERMIOS_IPROC_INTERRUPT;<br>
}<br>
-- <br>
2.16.4<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div>