test
platform/mbed_error.c@1:8a094db1347f, 2020-11-09 (annotated)
- Committer:
- elijahsj
- Date:
- Mon Nov 09 00:02:47 2020 -0500
- Revision:
- 1:8a094db1347f
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
elijahsj | 1:8a094db1347f | 1 | /* mbed Microcontroller Library |
elijahsj | 1:8a094db1347f | 2 | * Copyright (c) 2006-2013 ARM Limited |
elijahsj | 1:8a094db1347f | 3 | * |
elijahsj | 1:8a094db1347f | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
elijahsj | 1:8a094db1347f | 5 | * you may not use this file except in compliance with the License. |
elijahsj | 1:8a094db1347f | 6 | * You may obtain a copy of the License at |
elijahsj | 1:8a094db1347f | 7 | * |
elijahsj | 1:8a094db1347f | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
elijahsj | 1:8a094db1347f | 9 | * |
elijahsj | 1:8a094db1347f | 10 | * Unless required by applicable law or agreed to in writing, software |
elijahsj | 1:8a094db1347f | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
elijahsj | 1:8a094db1347f | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
elijahsj | 1:8a094db1347f | 13 | * See the License for the specific language governing permissions and |
elijahsj | 1:8a094db1347f | 14 | * limitations under the License. |
elijahsj | 1:8a094db1347f | 15 | */ |
elijahsj | 1:8a094db1347f | 16 | #include <stdlib.h> |
elijahsj | 1:8a094db1347f | 17 | #include <stdarg.h> |
elijahsj | 1:8a094db1347f | 18 | #include "device.h" |
elijahsj | 1:8a094db1347f | 19 | #include "platform/mbed_toolchain.h" |
elijahsj | 1:8a094db1347f | 20 | #include "platform/mbed_error.h" |
elijahsj | 1:8a094db1347f | 21 | #include "platform/mbed_interface.h" |
elijahsj | 1:8a094db1347f | 22 | #if DEVICE_STDIO_MESSAGES |
elijahsj | 1:8a094db1347f | 23 | #include <stdio.h> |
elijahsj | 1:8a094db1347f | 24 | #endif |
elijahsj | 1:8a094db1347f | 25 | |
elijahsj | 1:8a094db1347f | 26 | static uint8_t error_in_progress = 0; |
elijahsj | 1:8a094db1347f | 27 | |
elijahsj | 1:8a094db1347f | 28 | WEAK void error(const char* format, ...) { |
elijahsj | 1:8a094db1347f | 29 | |
elijahsj | 1:8a094db1347f | 30 | // Prevent recursion if error is called again |
elijahsj | 1:8a094db1347f | 31 | if (error_in_progress) { |
elijahsj | 1:8a094db1347f | 32 | return; |
elijahsj | 1:8a094db1347f | 33 | } |
elijahsj | 1:8a094db1347f | 34 | error_in_progress = 1; |
elijahsj | 1:8a094db1347f | 35 | |
elijahsj | 1:8a094db1347f | 36 | #ifndef NDEBUG |
elijahsj | 1:8a094db1347f | 37 | va_list arg; |
elijahsj | 1:8a094db1347f | 38 | va_start(arg, format); |
elijahsj | 1:8a094db1347f | 39 | mbed_error_vfprintf(format, arg); |
elijahsj | 1:8a094db1347f | 40 | va_end(arg); |
elijahsj | 1:8a094db1347f | 41 | #endif |
elijahsj | 1:8a094db1347f | 42 | exit(1); |
elijahsj | 1:8a094db1347f | 43 | } |