termios: Replace rtems_termios_isig_status_code

Merge the rtems_termios_isig_status_code and
rtems_termios_iproc_status_code enums into a single
rtems_termios_iproc_status_code which is now a part of the API.

Simplify rtems_termios_posix_isig_handler() to avoid unreachable code.

Close #3800.
This commit is contained in:
Sebastian Huber
2020-05-07 08:45:29 +02:00
parent ef9517b7d5
commit 153b26699e
3 changed files with 40 additions and 59 deletions

View File

@@ -1904,28 +1904,37 @@ rtems_status_code rtems_termios_bufsize (
); );
/** /**
* @brief Type returned by all input processing (isig) methods * @brief The status code returned by all Termios input processing (iproc)
* functions and input signal (isig) handlers.
*/ */
typedef enum { typedef enum {
/** /**
* This indicates that the input character was processed * @brief This status indicates that the input processing can continue.
* and possibly placed into the buffer. *
* Input signal handlers shall return this status if no signal was raised and
* the input processing can continue.
*/ */
RTEMS_TERMIOS_ISIG_WAS_PROCESSED, RTEMS_TERMIOS_IPROC_CONTINUE,
/** /**
* This indicates that the input character was not processed and * @brief This status indicates that the input processing should stop due to
* subsequent processing is required. * a signal.
*
* This indicates that the character was processed and determined to be one
* that requires a signal to be raised (e.g. VINTR or VKILL). The tty must
* be in the right Termios mode for this to occur. There is no further
* processing of this character required and the pending read() operation
* should be interrupted.
*/ */
RTEMS_TERMIOS_ISIG_WAS_NOT_PROCESSED, RTEMS_TERMIOS_IPROC_INTERRUPT,
/** /**
* This indicates that the character was processed and determined * @brief This status indicates that the input processing is done.
* to be one that requires a signal to be raised (e.g. VINTR or *
* VKILL). The tty must be in the right termios mode for this to * This status shall not be returned by input processing signal handlers.
* occur. There is no further processing of this character required and
* the pending read() operation should be interrupted.
*/ */
RTEMS_TERMIOS_ISIG_INTERRUPT_READ RTEMS_TERMIOS_IPROC_DONE
} rtems_termios_isig_status_code; } rtems_termios_iproc_status_code;
/** /**
* @brief Type for ISIG (VINTR/VKILL) handler * @brief Type for ISIG (VINTR/VKILL) handler
@@ -1941,9 +1950,9 @@ typedef enum {
* @param tty termios structure pointer for this input tty * @param tty termios structure pointer for this input tty
* *
* @return The value returned is according to that documented * @return The value returned is according to that documented
* for @ref rtems_termios_isig_status_code. * for @ref rtems_termios_iproc_status_code.
*/ */
typedef rtems_termios_isig_status_code (*rtems_termios_isig_handler)( typedef rtems_termios_iproc_status_code (*rtems_termios_isig_handler)(
unsigned char c, unsigned char c,
struct rtems_termios_tty *tty struct rtems_termios_tty *tty
); );
@@ -1966,7 +1975,7 @@ typedef rtems_termios_isig_status_code (*rtems_termios_isig_handler)(
* @return The value returned is according to that documented * @return The value returned is according to that documented
* for all methods adhering to @ref rtems_termios_isig_handler. * for all methods adhering to @ref rtems_termios_isig_handler.
*/ */
rtems_termios_isig_status_code rtems_termios_default_isig_handler( rtems_termios_iproc_status_code rtems_termios_default_isig_handler(
unsigned char c, unsigned char c,
struct rtems_termios_tty *tty struct rtems_termios_tty *tty
); );
@@ -1984,7 +1993,7 @@ rtems_termios_isig_status_code rtems_termios_default_isig_handler(
* @return The value returned is according to that documented * @return The value returned is according to that documented
* for all methods adhering to @ref rtems_termios_isig_handler. * for all methods adhering to @ref rtems_termios_isig_handler.
*/ */
rtems_termios_isig_status_code rtems_termios_posix_isig_handler( rtems_termios_iproc_status_code rtems_termios_posix_isig_handler(
unsigned char c, unsigned char c,
struct rtems_termios_tty *tty struct rtems_termios_tty *tty
); );

View File

@@ -1311,12 +1311,12 @@ static rtems_termios_isig_handler termios_isig_handler =
* This is the default method to process VKILL or VQUIT characters if * This is the default method to process VKILL or VQUIT characters if
* ISIG processing is enabled. Note that it does nothing. * ISIG processing is enabled. Note that it does nothing.
*/ */
rtems_termios_isig_status_code rtems_termios_default_isig_handler( rtems_termios_iproc_status_code rtems_termios_default_isig_handler(
unsigned char c, unsigned char c,
struct rtems_termios_tty *tty struct rtems_termios_tty *tty
) )
{ {
return RTEMS_TERMIOS_ISIG_WAS_NOT_PROCESSED; return RTEMS_TERMIOS_IPROC_CONTINUE;
} }
/* /*
@@ -1335,28 +1335,6 @@ rtems_status_code rtems_termios_register_isig_handler(
return RTEMS_SUCCESSFUL; return RTEMS_SUCCESSFUL;
} }
/**
* @brief Type returned by all input processing (iproc) methods
*/
typedef enum {
/**
* This indicates that the input processing can continue.
*/
RTEMS_TERMIOS_IPROC_CONTINUE,
/**
* This indicates that the input processing is done.
*/
RTEMS_TERMIOS_IPROC_DONE,
/**
* This indicates that the character was processed and determined
* to be one that requires a signal to be raised (e.g. VINTR or
* VKILL). The tty must be in the right termios mode for this to
* occur. There is no further processing of this character required and
* the pending read() operation should be interrupted.
*/
RTEMS_TERMIOS_IPROC_INTERRUPT
} rtems_termios_iproc_status_code;
/* /*
* Process a single input character * Process a single input character
*/ */
@@ -1369,13 +1347,7 @@ iproc (unsigned char c, struct rtems_termios_tty *tty)
*/ */
if ((tty->termios.c_lflag & ISIG)) { if ((tty->termios.c_lflag & ISIG)) {
if ((c == tty->termios.c_cc[VINTR]) || (c == tty->termios.c_cc[VQUIT])) { if ((c == tty->termios.c_cc[VINTR]) || (c == tty->termios.c_cc[VQUIT])) {
rtems_termios_isig_status_code rc; return (*termios_isig_handler)(c, tty);
rc = (*termios_isig_handler)(c, tty);
if (rc == RTEMS_TERMIOS_ISIG_INTERRUPT_READ) {
return RTEMS_TERMIOS_IPROC_INTERRUPT;
}
return RTEMS_TERMIOS_IPROC_CONTINUE;
} }
} }

View File

@@ -20,20 +20,20 @@
#include <signal.h> #include <signal.h>
rtems_termios_isig_status_code rtems_termios_posix_isig_handler( rtems_termios_iproc_status_code rtems_termios_posix_isig_handler(
unsigned char c, unsigned char c,
struct rtems_termios_tty *tty struct rtems_termios_tty *tty
) )
{ {
if (c == tty->termios.c_cc[VINTR]) { int sig;
raise(SIGINT);
return RTEMS_TERMIOS_ISIG_INTERRUPT_READ; if ( c == tty->termios.c_cc[ VQUIT ] ) {
sig = SIGQUIT;
} else {
sig = SIGINT;
} }
if (c == tty->termios.c_cc[VQUIT]) { (void) raise( sig );
raise(SIGQUIT);
return RTEMS_TERMIOS_ISIG_INTERRUPT_READ;
}
return RTEMS_TERMIOS_ISIG_WAS_NOT_PROCESSED; return RTEMS_TERMIOS_IPROC_INTERRUPT;
} }