commit 7de0cc90a3bd7145a5160729fddc72a9aa46d330
Author: Thomas Schöpping <tschoepp@cit-ec.uni-bielefeld.de>
Date:   Thu Feb 21 18:04:04 2019 +0100

    All preprocessor directives without arguments (e.g. #endif) are now followed by a comment, indicating where it belongs to (e.g. the preceding #if).

diff --git a/core/src/aos_system.c b/core/src/aos_system.c
index a94e367..bfb201f 100644
--- a/core/src/aos_system.c
+++ b/core/src/aos_system.c
@@ -34,7 +34,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #if (AMIROOS_CFG_TESTS_ENABLE == true)
 #include <ch_test.h>
 #include <rt_test_root.h>
-#endif
+#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
 
 /******************************************************************************/
 /* LOCAL DEFINITIONS                                                          */
@@ -90,7 +90,7 @@ static int _shellcmd_infocb(BaseSequentialStream* stream, int argc, char* argv[]
 static int _shellcmd_shutdowncb(BaseSequentialStream* stream, int argc, char* argv[]);
 #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
 static int _shellcmd_kerneltestcb(BaseSequentialStream* stream, int argc, char* argv[]);
-#endif /* AMIROOS_CFG_TESTS_ENABLE == true */
+#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
 #endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */
 
 /**
@@ -168,9 +168,9 @@ static aos_shellcommand_t _shellcmd_config = {
 static aos_shellcommand_t _shellcmd_shutdown = {
 #if (AMIROOS_CFG_SSSP_ENABLE == true)
   /* name     */ "system:shutdown",
-#else
+#else /* (AMIROOS_CFG_SSSP_ENABLE == true) */
   /* name     */ "module:shutdown",
-#endif
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
   /* callback */ _shellcmd_shutdowncb,
   /* next     */ NULL,
 };
@@ -184,7 +184,7 @@ static aos_shellcommand_t _shellcmd_kerneltest = {
   /* callback */ _shellcmd_kerneltestcb,
   /* next     */ NULL,
 };
-#endif /* AMIROOS_CFG_TESTS_ENABLE == true */
+#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
 #endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */
 
 /******************************************************************************/
@@ -263,24 +263,24 @@ static void _printSystemInfo(BaseSequentialStream* stream)
 #if (HAL_USE_RTC == TRUE)
   struct tm dt;
   aosSysGetDateTime(&dt);
-#endif /* HAL_USE_RTC == TRUE */
+#endif /* (HAL_USE_RTC == TRUE) */
 
   // print static information about module and operating system
   _printSystemInfoSeparator(stream, '=', SYSTEM_INFO_WIDTH);
   _printSystemInfoLine(stream, "Module", SYSTEM_INFO_NAMEWIDTH, "%s", BOARD_NAME);
-#ifdef PLATFORM_NAME
+#if defined(PLATFORM_NAME)
   _printSystemInfoLine(stream, "Platform", SYSTEM_INFO_NAMEWIDTH, "%s", PLATFORM_NAME);
-#endif
-#ifdef PORT_CORE_VARIANT_NAME
+#endif /* defined(PLATFORM_NAME) */
+#if defined(PORT_CORE_VARIANT_NAME)
   _printSystemInfoLine(stream, "Core Variant", SYSTEM_INFO_NAMEWIDTH, "%s", PORT_CORE_VARIANT_NAME);
-#endif
+#endif /* defined(PORT_CORE_VARIANT_NAME) */
   _printSystemInfoLine(stream, "Architecture", SYSTEM_INFO_NAMEWIDTH, "%s", PORT_ARCHITECTURE_NAME);
   _printSystemInfoSeparator(stream, '-', SYSTEM_INFO_WIDTH);
 #if (AMIROOS_CFG_SSSP_ENABLE == true)
   _printSystemInfoLine(stream, "AMiRo-OS" , SYSTEM_INFO_NAMEWIDTH, "%u.%u.%u %s (SSSP %u.%u)", AMIROOS_VERSION_MAJOR, AMIROOS_VERSION_MINOR, AMIROOS_VERSION_PATCH, AMIROOS_RELEASE_TYPE, AOS_SYSTEM_SSSP_VERSION_MAJOR, AOS_SYSTEM_SSSP_VERSION_MINOR);
-#else
+#else /* (AMIROOS_CFG_SSSP_ENABLE == true) */
   _printSystemInfoLine(stream, "AMiRo-OS" , SYSTEM_INFO_NAMEWIDTH, "%u.%u.%u %s", AMIROOS_VERSION_MAJOR, AMIROOS_VERSION_MINOR, AMIROOS_VERSION_PATCH, AMIROOS_RELEASE_TYPE);
-#endif
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
   _printSystemInfoLine(stream, "AMiRo-LLD" , SYSTEM_INFO_NAMEWIDTH, "%u.%u.%u %s (periphAL %u.%u)", AMIRO_LLD_VERSION_MAJOR, AMIRO_LLD_VERSION_MINOR, AMIRO_LLD_VERSION_PATCH, AMIRO_LLD_RELEASE_TYPE, PERIPHAL_VERSION_MAJOR, PERIPHAL_VERSION_MINOR);
   _printSystemInfoLine(stream, "ChibiOS/RT" , SYSTEM_INFO_NAMEWIDTH, "%u.%u.%u %s", CH_KERNEL_MAJOR, CH_KERNEL_MINOR, CH_KERNEL_PATCH, (CH_KERNEL_STABLE == 1) ? "stable" : "non-stable");
   _printSystemInfoLine(stream, "ChibiOS/HAL", SYSTEM_INFO_NAMEWIDTH, "%u.%u.%u %s", CH_HAL_MAJOR, CH_HAL_MINOR, CH_HAL_PATCH, (CH_HAL_STABLE == 1) ? "stable" : "non-stable");
@@ -307,7 +307,7 @@ static void _printSystemInfo(BaseSequentialStream* stream)
         aosprintf("WARNING: Bootloader and AMiRo-OS implement incompatible SSSP versions!\n");
       }
     }
-#endif
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
     _printSystemInfoLine(stream, "Compiler", SYSTEM_INFO_NAMEWIDTH, "%s %u.%u.%u", (BL_CALLBACK_TABLE_ADDRESS->vCompiler.identifier == BL_VERSION_ID_GCC) ? "GCC" : "<compiler unknown>", BL_CALLBACK_TABLE_ADDRESS->vCompiler.major, BL_CALLBACK_TABLE_ADDRESS->vCompiler.minor, BL_CALLBACK_TABLE_ADDRESS->vCompiler.patch); // TODO: support other compilers than GCC
   } else {
     if (stream) {
@@ -325,14 +325,14 @@ static void _printSystemInfo(BaseSequentialStream* stream)
   } else {
     _printSystemInfoLine(stream, "Module ID", SYSTEM_INFO_NAMEWIDTH, "not available");
   }
-#endif
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
 #if (HAL_USE_RTC == TRUE)
   _printSystemInfoLine(stream, "Date", SYSTEM_INFO_NAMEWIDTH, "%s %02u-%02u-%04u", (dt.tm_wday == 0) ? "Sunday" : (dt.tm_wday == 1) ? "Monday" : (dt.tm_wday == 2) ? "Tuesday" : (dt.tm_wday == 3) ? "Wednesday" : (dt.tm_wday == 4) ? "Thursday" : (dt.tm_wday == 5) ? "Friday" : "Saturday",
                        dt.tm_mday,
                        dt.tm_mon + 1,
                        dt.tm_year + 1900);
   _printSystemInfoLine(stream, "Time", SYSTEM_INFO_NAMEWIDTH, "%02u:%02u:%02u", dt.tm_hour, dt.tm_min, dt.tm_sec);
-#endif /* HAL_USE_RTC == TRUE */
+#endif /* (HAL_USE_RTC == TRUE) */
 
   _printSystemInfoSeparator(stream, '=', SYSTEM_INFO_WIDTH);
 
@@ -475,7 +475,7 @@ static int _shellcmd_configcb(BaseSequentialStream* stream, int argc, char* argv
 
       retval = AOS_OK;
     }
-#endif /* HAL_USE_RTC == TRUE */
+#endif /* (HAL_USE_RTC == TRUE) */
   }
 
   // print help, if required
@@ -501,7 +501,7 @@ static int _shellcmd_configcb(BaseSequentialStream* stream, int argc, char* argv
     chprintf(stream, "      hour\n");
     chprintf(stream, "      minute\n");
     chprintf(stream, "      second\n");
-#endif /* HAL_USE_RTC == TRUE */
+#endif /* (HAL_USE_RTC == TRUE) */
   }
 
   return (argc > 1 && strcmp(argv[1], "--help") == 0) ? AOS_OK : retval;
@@ -542,7 +542,7 @@ static int _shellcmd_infocb(BaseSequentialStream* stream, int argc, char* argv[]
   chprintf(stream, "%10u microseconds\n", (uint16_t)(uptime % MICROSECONDS_PER_MILLISECOND / MICROSECONDS_PER_MICROSECOND));
 #if (AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_MASTER != true) && (AMIROOS_CFG_PROFILE == true)
   chprintf(stream, "SSSP synchronization offset: %.3fus per %uus\n", _syssyncskew, AMIROOS_CFG_SSSP_SYSSYNCPERIOD);
-#endif /* AMIROOS_CFG_SSSP_MASTER != true && AMIROOS_CFG_PROFILE == true */
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) && (AMIROOS_CFG_SSSP_MASTER != true) && (AMIROOS_CFG_PROFILE == true) */
   _printSystemInfoSeparator(stream, '=', SYSTEM_INFO_WIDTH);
 
   // print shell info
@@ -554,8 +554,8 @@ static int _shellcmd_infocb(BaseSequentialStream* stream, int argc, char* argv[]
   chprintf(stream, "\tthread stack size:      %u bytes\n", aosThdGetStacksize(aos.shell.thread));
 #if (CH_DBG_FILL_THREADS == TRUE)
   chprintf(stream, "\tstack peak utilization: %u bytes (%.2f%%)\n", aosThdGetStackPeakUtilization(aos.shell.thread), (float)aosThdGetStackPeakUtilization(aos.shell.thread) / (float)aosThdGetStacksize(aos.shell.thread) * 100.0f);
-#endif /* CH_DBG_FILL_THREADS == TRUE */
-#endif /* AMIROOS_CFG_DBG == true */
+#endif /* (CH_DBG_FILL_THREADS == TRUE) */
+#endif /* (AMIROOS_CFG_DBG == true) */
   _printSystemInfoSeparator(stream, '=', SYSTEM_INFO_WIDTH);
 
   return AOS_OK;
@@ -624,14 +624,14 @@ static int _shellcmd_shutdowncb(BaseSequentialStream* stream, int argc, char* ar
       return AOS_INVALID_ARGUMENTS;
     }
   }
-#else /* AMIROOS_CFG_SSSP_ENABLE == false */
+#else /* (AMIROOS_CFG_SSSP_ENABLE == true) */
   (void)argv;
   (void)argc;
 
   chEvtBroadcastFlags(&aos.events.os, AOS_SYSTEM_EVENTFLAGS_SHUTDOWN);
   chThdTerminate(chThdGetSelfX());
   return AOS_OK;
-#endif /* AMIROOS_CFG_SSSP_ENABLE */
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
 }
 
 #if (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
@@ -655,7 +655,7 @@ static int _shellcmd_kerneltestcb(BaseSequentialStream* stream, int argc, char*
 
   return retval;
 }
-#endif /* AMIROOS_CFG_TESTS_ENABLE == true */
+#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
 #endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */
 
 // suppress warning in case no interrupt GPIOs are defined
@@ -705,12 +705,12 @@ static void _signalSyncCallback(void *args)
         _uptime -= uptime % AMIROOS_CFG_SSSP_SYSSYNCPERIOD;
 #if (AMIROOS_CFG_PROFILE == true)
         _syssyncskew = ((1.0f - SYSTEM_SYSSYNCSKEW_LPFACTOR) * _syssyncskew) + (SYSTEM_SYSSYNCSKEW_LPFACTOR * (uptime % AMIROOS_CFG_SSSP_SYSSYNCPERIOD));
-#endif
+#endif /* (AMIROOS_CFG_PROFILE == true) */
       } else {
         _uptime += AMIROOS_CFG_SSSP_SYSSYNCPERIOD - (uptime % AMIROOS_CFG_SSSP_SYSSYNCPERIOD);
 #if (AMIROOS_CFG_PROFILE == true)
         _syssyncskew = ((1.0f - SYSTEM_SYSSYNCSKEW_LPFACTOR) * _syssyncskew) - (SYSTEM_SYSSYNCSKEW_LPFACTOR * (AMIROOS_CFG_SSSP_SYSSYNCPERIOD - (uptime % AMIROOS_CFG_SSSP_SYSSYNCPERIOD)));
-#endif
+#endif /* (AMIROOS_CFG_PROFILE == true) */
       }
     }
   }
@@ -792,9 +792,9 @@ static void _sysSyncTimerCallback(void* par)
  */
 #if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) || defined(__DOXYGEN__)
 void aosSysInit(const char* shellPrompt)
-#else
+#else /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */
 void aosSysInit(void)
-#endif
+#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */
 {
   /* set control thread to maximum priority */
   chThdSetPriority(AOS_THD_CTRLPRIO);
@@ -807,24 +807,24 @@ void aosSysInit(void)
 #if (AMIROOS_CFG_SSSP_MASTER == true)
   chVTObjectInit(&_syssynctimer);
   _syssynctime = 0;
-#endif
+#endif /* (AMIROOS_CFG_SSSP_MASTER == true) */
 #if (AMIROOS_CFG_SSSP_MASTER != true) && (AMIROOS_CFG_PROFILE == true)
   _syssyncskew = 0.0f;
-#endif
-#else /* AMIROOS_CFG_SSSP_ENABLE == false */
+#endif /* (AMIROOS_CFG_SSSP_MASTER != true) && (AMIROOS_CFG_PROFILE == true) */
+#else /* (AMIROOS_CFG_SSSP_ENABLE == true) */
   // start the uptime counter
   chSysLock();
   _synctime = chVTGetSystemTimeX();
   _uptime = 0;
   chVTSetI(&_systimer, SYSTIMER_PERIOD, &_uptimeCallback, NULL);
   chSysUnlock();
-#endif /* AMIROOS_CFG_SSSP_ENABLE */
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
 
   /* initialize aos configuration */
 #if (AMIROOS_CFG_SSSP_ENABLE == true)
   aos.sssp.stage = AOS_SSSP_STARTUP_2_1;
   aos.sssp.moduleId = 0;
-#endif
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
   aosIOStreamInit(&aos.iostream);
   chEvtObjectInit(&aos.events.io);
   chEvtObjectInit(&aos.events.os);
@@ -837,25 +837,25 @@ void aosSysInit(void)
   // SYNC signal
 #if (AMIROOS_CFG_SSSP_MASTER == true)
   palSetPadCallback(moduleSsspGpioSync.gpio->port, moduleSsspGpioSync.gpio->pad, _intCallback, &moduleSsspGpioSync.gpio->pad);
-#else
+#else /* (AMIROOS_CFG_SSSP_MASTER == true) */
   palSetPadCallback(moduleSsspGpioSync.gpio->port, moduleSsspGpioSync.gpio->pad, _signalSyncCallback, &moduleSsspGpioSync.gpio->pad);
-#endif
+#endif /* (AMIROOS_CFG_SSSP_MASTER == true) */
   palEnablePadEvent(moduleSsspGpioSync.gpio->port, moduleSsspGpioSync.gpio->pad, APAL2CH_EDGE(moduleSsspGpioSync.meta.edge));
 #if (AMIROOS_CFG_SSSP_STACK_START != true)
   // DN signal
   palSetPadCallback(moduleSsspGpioDn.gpio->port, moduleSsspGpioDn.gpio->pad, _intCallback, &moduleSsspGpioDn.gpio->pad);
   palEnablePadEvent(moduleSsspGpioDn.gpio->port, moduleSsspGpioDn.gpio->pad, APAL2CH_EDGE(moduleSsspGpioDn.meta.edge));
-#endif
+#endif /* (AMIROOS_CFG_SSSP_STACK_START != true) */
 #if (AMIROOS_CFG_SSSP_STACK_END != true)
   // UP signal
   palSetPadCallback(moduleSsspGpioUp.gpio->port, moduleSsspGpioUp.gpio->pad, _intCallback, &moduleSsspGpioUp.gpio->pad);
   palEnablePadEvent(moduleSsspGpioUp.gpio->port, moduleSsspGpioUp.gpio->pad, APAL2CH_EDGE(moduleSsspGpioUp.meta.edge));
-#endif
-#endif /* AMIROOS_CFG_SSSP_ENABLE == true */
-#ifdef MODULE_INIT_INTERRUPTS
+#endif /* (AMIROOS_CFG_SSSP_STACK_END != true) */
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
+#if defined(MODULE_INIT_INTERRUPTS)
   // further interrupt signals
   MODULE_INIT_INTERRUPTS();
-#endif
+#endif /* defined(MODULE_INIT_INTERRUPTS) */
 
 #if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true)
   /* init shell */
@@ -872,7 +872,7 @@ void aosSysInit(void)
   aosShellAddCommand(&aos.shell, &_shellcmd_shutdown);
 #if (AMIROOS_CFG_TESTS_ENABLE == true)
   aosShellAddCommand(&aos.shell, &_shellcmd_kerneltest);
-#endif
+#endif /* (AMIROOS_CFG_TESTS_ENABLE == true) */
 #endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */
 
   return;
@@ -898,8 +898,8 @@ inline void aosSysStart(void)
     chVTSetI(&_syssynctimer, chTimeUS2I((t > (AMIROOS_CFG_SSSP_SYSSYNCPERIOD / 2)) ? (t - (AMIROOS_CFG_SSSP_SYSSYNCPERIOD / 2)) : (t + (AMIROOS_CFG_SSSP_SYSSYNCPERIOD / 2))), _sysSyncTimerCallback, NULL);
     chSysUnlock();
   }
-#endif
-#endif /* AMIROOS_CFG_SSSP_ENABLE == true */
+#endif /* (AMIROOS_CFG_SSSP_MASTER == true) */
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
 
   // print system information;
   _printSystemInfo((BaseSequentialStream*)&aos.iostream);
@@ -909,10 +909,10 @@ inline void aosSysStart(void)
   // start system shell thread
 #if (CH_CFG_USE_THREADHIERARCHY == TRUE)
   aos.shell.thread = chThdCreateStatic(_shell_wa, sizeof(_shell_wa), AMIROOS_CFG_SHELL_THREADPRIO, aosShellThread, &aos.shell, &ch.mainthread);
-#else
+#else /* (CH_CFG_USE_THREADHIERARCHY == TRUE) */
   aos.shell.thread = chThdCreateStatic(_shell_wa, sizeof(_shell_wa), AMIROOS_CFG_SHELL_THREADPRIO, aosShellThread, &aos.shell);
-#endif
-#endif
+#endif /* (CH_CFG_USE_THREADHIERARCHY == TRUE) */
+#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */
 
   return;
 }
@@ -968,7 +968,7 @@ eventmask_t aosSysSsspStartupOsInitSyncCheck(event_listener_t* syncEvtListener)
     return m;
   }
 }
-#endif /* AMIROOS_CFG_SSSP_ENABLE == true */
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
 
 /**
  * @brief   Retrieves the system uptime.
@@ -1018,7 +1018,7 @@ void aosSysSetDateTime(struct tm* dt)
   return;
 }
 
-#endif /* HAL_USE_RTC == TRUE */
+#endif /* (HAL_USE_RTC == TRUE) */
 
 /**
  * @brief   Initializes/Acknowledges a system shutdown/restart request.
@@ -1035,7 +1035,7 @@ void aosSysShutdownInit(aos_shutdown_t shutdown)
 #if (AMIROOS_CFG_SSSP_MASTER == true)
   // deactivate the system synchronization timer
   chVTReset(&_syssynctimer);
-#endif
+#endif /* (AMIROOS_CFG_SSSP_MASTER == true) */
 
   // update the system SSSP stage
   aos.sssp.stage = AOS_SSSP_SHUTDOWN_1_1;
@@ -1048,7 +1048,7 @@ void aosSysShutdownInit(aos_shutdown_t shutdown)
   // activate the SYS_SYNC signal
   apalControlGpioSet(&moduleSsspGpioSync, APAL_GPIO_ON);
   chSysUnlock();
-#endif /* AMIROOS_CFG_SSSP_ENABLE == true */
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
 
   switch (shutdown) {
     case AOS_SHUTDOWN_PASSIVE:
@@ -1080,7 +1080,7 @@ void aosSysShutdownInit(aos_shutdown_t shutdown)
 #if (AMIROOS_CFG_SSSP_ENABLE == true)
   // update the system SSSP stage
   aos.sssp.stage = AOS_SSSP_SHUTDOWN_1_2;
-#endif
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
 
   return;
 }
@@ -1092,7 +1092,7 @@ void aosSysStop(void)
 {
 #if (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true)
   chThdWait(aos.shell.thread);
-#endif
+#endif /* (AMIROOS_CFG_SHELL_ENABLE == true) || (AMIROOS_CFG_TESTS_ENABLE == true) */
 
   return;
 }
@@ -1122,7 +1122,7 @@ void aosSysShutdownFinal(aos_shutdown_t shutdown)
 #if (AMIROOS_CFG_SSSP_ENABLE == true)
   // update the system SSSP stage
   aos.sssp.stage = AOS_SSSP_SHUTDOWN_1_3;
-#endif
+#endif /* (AMIROOS_CFG_SSSP_ENABLE == true) */
 
   // validate bootloader
   if ((BL_CALLBACK_TABLE_ADDRESS->magicNumber == BL_MAGIC_NUMBER) &&
