AST_Day_Contest / Mbed 2 deprecated 53L0A1_HandGestureRecognition

Dependencies:   X_NUCLEO_53L0A1 mbed

Fork of 53L0A1_HandGestureRecognition by ST

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Trace.h Source File

Trace.h

00001 //
00002 // This file is part of the µOS++ III distribution.
00003 // Copyright (c) 2014 Liviu Ionescu.
00004 //
00005 
00006 #ifndef DIAG_TRACE_H_
00007 #define DIAG_TRACE_H_
00008 
00009 // ----------------------------------------------------------------------------
00010 
00011 //#include <unistd.h>
00012 typedef int ssize_t;
00013 
00014 // ----------------------------------------------------------------------------
00015 
00016 // The trace device is an independent output channel, intended for debug
00017 // purposes.
00018 //
00019 // The API is simple, and mimics the standard output calls:
00020 // - trace_printf()
00021 // - trace_puts()
00022 // - trace_putchar();
00023 //
00024 // The implementation is done in
00025 // - trace_write()
00026 //
00027 // Trace support is enabled by adding the TRACE definition.
00028 // By default the trace messages are forwarded to the ITM output,
00029 // but can be rerouted via any device or completely suppressed by
00030 // changing the definitions required in system/src/diag/trace_impl.c
00031 // (currently OS_USE_TRACE_ITM, OS_USE_TRACE_SEMIHOSTING_DEBUG/_STDOUT).
00032 //
00033 // When TRACE is not defined, all functions are inlined to empty bodies.
00034 // This has the advantage that the trace call do not need to be conditionally
00035 // compiled with #ifdef TRACE/#endif
00036 
00037 
00038 #if defined(TRACE)
00039 
00040 #if defined(__cplusplus)
00041 extern "C"
00042 {
00043 #endif
00044 
00045   void
00046   trace_initialize(void);
00047 
00048   // Implementation dependent
00049   ssize_t
00050   trace_write(const char* buf, size_t nbyte);
00051 
00052   // ----- Portable -----
00053 
00054   int
00055   trace_printf(const char* format, ...);
00056 
00057   int
00058   trace_puts(const char *s);
00059 
00060   int
00061   trace_putchar(int c);
00062 
00063   void
00064   trace_dump_args(int argc, char* argv[]);
00065 
00066 #if defined(__cplusplus)
00067 }
00068 #endif
00069 
00070 #else // !defined(TRACE)
00071 
00072 #if defined(__cplusplus)
00073 extern "C"
00074 {
00075 #endif
00076 
00077   inline void
00078   trace_initialize(void);
00079 
00080   // Implementation dependent
00081   inline ssize_t
00082   trace_write(const char* buf, size_t nbyte);
00083 
00084   inline int
00085   trace_printf(const char* format, ...);
00086 
00087   inline int
00088   trace_puts(const char *s);
00089 
00090   inline int
00091   trace_putchar(int c);
00092 
00093   inline void
00094   trace_dump_args(int argc, char* argv[]);
00095 
00096 #if defined(__cplusplus)
00097 }
00098 #endif
00099 
00100 inline void
00101 __attribute__((always_inline))
00102 trace_initialize(void)
00103 {
00104 }
00105 
00106 // Empty definitions when trace is not defined
00107 inline ssize_t
00108 __attribute__((always_inline))
00109 trace_write(const char* buf __attribute__((unused)),
00110     size_t nbyte __attribute__((unused)))
00111 {
00112   return 0;
00113 }
00114 
00115 inline int
00116 __attribute__((always_inline))
00117 trace_printf(const char* format __attribute__((unused)), ...)
00118   {
00119     return 0;
00120   }
00121 
00122 inline int
00123 __attribute__((always_inline))
00124 trace_puts(const char *s __attribute__((unused)))
00125 {
00126   return 0;
00127 }
00128 
00129 inline int
00130 __attribute__((always_inline))
00131 trace_putchar(int c)
00132 {
00133   return c;
00134 }
00135 
00136 inline void
00137 __attribute__((always_inline))
00138 trace_dump_args(int argc __attribute__((unused)),
00139     char* argv[] __attribute__((unused)))
00140 {
00141 }
00142 
00143 #endif // defined(TRACE)
00144 
00145 // ----------------------------------------------------------------------------
00146 
00147 #endif // DIAG_TRACE_H_
00148