logi loader fork from jpiat
Fork of mbed-src by
api/mbed_debug.h@25:002053b42e66, 2013-09-18 (annotated)
- Committer:
- mbed_official
- Date:
- Wed Sep 18 11:15:05 2013 +0100
- Revision:
- 25:002053b42e66
- Parent:
- 13:0645d8841f51
Synchronized with git revision c02372f88391a385415bca24ffaa1f0be34aab66
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 13:0645d8841f51 | 1 | /* mbed Microcontroller Library |
bogdanm | 13:0645d8841f51 | 2 | * Copyright (c) 2006-2013 ARM Limited |
bogdanm | 13:0645d8841f51 | 3 | * |
bogdanm | 13:0645d8841f51 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
bogdanm | 13:0645d8841f51 | 5 | * you may not use this file except in compliance with the License. |
bogdanm | 13:0645d8841f51 | 6 | * You may obtain a copy of the License at |
bogdanm | 13:0645d8841f51 | 7 | * |
bogdanm | 13:0645d8841f51 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
bogdanm | 13:0645d8841f51 | 9 | * |
bogdanm | 13:0645d8841f51 | 10 | * Unless required by applicable law or agreed to in writing, software |
bogdanm | 13:0645d8841f51 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
bogdanm | 13:0645d8841f51 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
bogdanm | 13:0645d8841f51 | 13 | * See the License for the specific language governing permissions and |
bogdanm | 13:0645d8841f51 | 14 | * limitations under the License. |
bogdanm | 13:0645d8841f51 | 15 | */ |
bogdanm | 13:0645d8841f51 | 16 | #ifndef MBED_DEBUG_H |
bogdanm | 13:0645d8841f51 | 17 | #define MBED_DEBUG_H |
bogdanm | 13:0645d8841f51 | 18 | #include "device.h" |
bogdanm | 13:0645d8841f51 | 19 | |
bogdanm | 13:0645d8841f51 | 20 | #ifdef __cplusplus |
bogdanm | 13:0645d8841f51 | 21 | extern "C" { |
bogdanm | 13:0645d8841f51 | 22 | #endif |
bogdanm | 13:0645d8841f51 | 23 | |
mbed_official | 25:002053b42e66 | 24 | #if DEVICE_STDIO_MESSAGES |
bogdanm | 13:0645d8841f51 | 25 | #include <stdio.h> |
bogdanm | 13:0645d8841f51 | 26 | #include <stdarg.h> |
bogdanm | 13:0645d8841f51 | 27 | |
bogdanm | 13:0645d8841f51 | 28 | /** Output a debug message |
bogdanm | 13:0645d8841f51 | 29 | * |
bogdanm | 13:0645d8841f51 | 30 | * @param format printf-style format string, followed by variables |
bogdanm | 13:0645d8841f51 | 31 | */ |
bogdanm | 13:0645d8841f51 | 32 | static inline void debug(const char *format, ...) { |
bogdanm | 13:0645d8841f51 | 33 | va_list args; |
bogdanm | 13:0645d8841f51 | 34 | va_start(args, format); |
bogdanm | 13:0645d8841f51 | 35 | vfprintf(stderr, format, args); |
bogdanm | 13:0645d8841f51 | 36 | va_end(args); |
bogdanm | 13:0645d8841f51 | 37 | } |
bogdanm | 13:0645d8841f51 | 38 | |
bogdanm | 13:0645d8841f51 | 39 | /** Conditionally output a debug message |
bogdanm | 13:0645d8841f51 | 40 | * |
bogdanm | 13:0645d8841f51 | 41 | * NOTE: If the condition is constant false (!= 1) and the compiler optimization |
bogdanm | 13:0645d8841f51 | 42 | * level is greater than 0, then the whole function will be compiled away. |
bogdanm | 13:0645d8841f51 | 43 | * |
bogdanm | 13:0645d8841f51 | 44 | * @param condition output only if condition is true (== 1) |
bogdanm | 13:0645d8841f51 | 45 | * @param format printf-style format string, followed by variables |
bogdanm | 13:0645d8841f51 | 46 | */ |
bogdanm | 13:0645d8841f51 | 47 | static inline void debug_if(int condition, const char *format, ...) { |
bogdanm | 13:0645d8841f51 | 48 | if (condition == 1) { |
bogdanm | 13:0645d8841f51 | 49 | va_list args; |
bogdanm | 13:0645d8841f51 | 50 | va_start(args, format); |
bogdanm | 13:0645d8841f51 | 51 | vfprintf(stderr, format, args); |
bogdanm | 13:0645d8841f51 | 52 | va_end(args); |
bogdanm | 13:0645d8841f51 | 53 | } |
bogdanm | 13:0645d8841f51 | 54 | } |
bogdanm | 13:0645d8841f51 | 55 | |
bogdanm | 13:0645d8841f51 | 56 | #else |
bogdanm | 13:0645d8841f51 | 57 | static inline void debug(const char *format, ...) {} |
bogdanm | 13:0645d8841f51 | 58 | static inline void debug_if(int condition, const char *format, ...) {} |
bogdanm | 13:0645d8841f51 | 59 | |
bogdanm | 13:0645d8841f51 | 60 | #endif |
bogdanm | 13:0645d8841f51 | 61 | |
bogdanm | 13:0645d8841f51 | 62 | #ifdef __cplusplus |
bogdanm | 13:0645d8841f51 | 63 | } |
bogdanm | 13:0645d8841f51 | 64 | #endif |
bogdanm | 13:0645d8841f51 | 65 | |
bogdanm | 13:0645d8841f51 | 66 | #endif |