From 07ef3fe0185408f098fe0df93b23ccc130b591cc Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 21 Aug 2018 15:27:37 -0600 Subject: [PATCH] Another update to the coding standard; Add some comments detailing the POSIX non-compliance in include/signal.h --- Documentation/NuttXCCodingStandard.html | 53 ++++++++++++++++++++++- include/signal.h | 56 +++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 2 deletions(-) diff --git a/Documentation/NuttXCCodingStandard.html b/Documentation/NuttXCCodingStandard.html index 9f1778231d..56db45c4e4 100644 --- a/Documentation/NuttXCCodingStandard.html +++ b/Documentation/NuttXCCodingStandard.html @@ -2022,8 +2022,11 @@ ptr = (FAR struct somestruct_s *)value;
  • Local variables first. - Because NuttX conforms to the older C89 standard, all variables that have scope over the entire compound statement must be defined at the beginning of the compound statement. - A single blank line must follow the local variable definitions. + Because NuttX conforms to the older C89 standard, all variables that have scope over the compound statement must be defined at the beginning of the compound statement prior to any executable statements. + Local variable definitions intermixed within the following sequence of executable statements are forbidden. + A single blank line must follow the local variable definitions separating the local variable definitions from the following executable statements. + NOTE that a function body consists of a compound statement, but typically so does the statement following if, else, for, while, do. + Local variable definitions are also acceptable at the beginning of these compound statements as with any other.
  • Long functions are discouraged. @@ -2035,6 +2038,52 @@ ptr = (FAR struct somestruct_s *)value;
  • +
    + + +
    +

    Incorrect

    +
      +  int myfunction(int a, int b)
      +    {
      +      int c, d;
      +      c = a
      +      d = b;
      +
      +      int e = c + d;
      +
      +      for (int i = 0; i < b; i++)
      +        {
      +          e += d;
      +        }
      +
      +      return e / a;
      +    }
      +
    +
    +

    Correct

    +
      +  int myfunction(int a, int b)
      +    {
      +      int c;
      +      int d;
      +      int e;
      +      int i;
      +
      +      c = a
      +      d = b;
      +      e = c + d;
      +
      +      for (i = 0; i < b; i++)
      +        {
      +          e += d;
      +        }
      +
      +      return e / a;
      +    }
      +
    +
    +

    Returned Values

    diff --git a/include/signal.h b/include/signal.h index b790c8dc16..d54ded2fea 100644 --- a/include/signal.h +++ b/include/signal.h @@ -68,6 +68,62 @@ #define SIGRTMIN MIN_SIGNO /* First real time signal */ #define SIGRTMAX MAX_SIGNO /* Last real time signal */ +/* NuttX does not support standard signal actions. NuttX supports only what + * are referred to as "real time" signals. The default action of all NuttX + * signals is to simply ignore the signal. + * + * This is not POSIX compliant. Per OpenGroup.org: The following signals + * and default signal action s must be supported on all implementations: + * + * ---------- ------- ---------------------------------------------------- + * Signal Default Description + * Name Action + * ---------- ------- ---------------------------------------------------- + * SIGABRT A Process abort signal + * SIGALRM T Alarm clock + * SIGBUS A Access to an undefined portion of a memory object + * SIGCHLD I Child process terminated, stopped + * (or continued XSI extension) + * SIGCONT C Continue executing, if stopped + * SIGFPE A Erroneous arithmetic operation + * SIGHUP T Hangup + * SIGILL A Illegal instruction + * SIGINT T Terminal interrupt signal + * SIGKILL T Kill (cannot be caught or ignored) + * SIGPIPE T Write on a pipe with no one to read it + * SIGQUIT A Terminal quit signal + * SIGSEGV A Invalid memory reference + * SIGSTOP S Stop executing (cannot be caught or ignored) + * SIGTERM T Termination signal + * SIGTSTP S Terminal stop signal + * SIGTTIN S Background process attempting read + * SIGTTOU S Background process attempting write + * SIGUSR1 T User-defined signal 1 + * SIGUSR2 T User-defined signal 2 + * SIGPOLL T Poll-able event (XSI extension) + * SIGPROF T Profiling timer expired (XSI extension) + * SIGSYS A Bad system call (XSI extension) + * SIGTRAP A Trace/breakpoint trap (XSI extension) + * SIGURG I High bandwidth data is available at a socket + * SIGVTALRM T Virtual timer expired (XSI extension) + * SIGXCPU A CPU time limit exceeded (XSI extension) + * SIGXFSZ A File size limit exceeded (XSI extension) + * ---------- ------- ---------------------------------------------------- + * + * Where default action codes are: + * + * T Abnormal termination of the process. The process is terminated with + * all the consequences of _exit() except that the status made available + * to wait() and waitpid() indicates abnormal termination by the + * specified signal. + * A Abnormal termination of the process. Additionally ith the XSI + * extension, implementation-defined abnormal termination actions, such + * as creation of a core file, may occur. + * I Ignore the signal. + * S Stop the process. + * C Continue the process, if it is stopped; otherwise, ignore the signal. + */ + /* A few of the real time signals are used within the OS. They have * default values that can be overridden from the configuration file. The * rest are all user signals.