Commit 60a754c2 authored by Michael Zehrer's avatar Michael Zehrer
Browse files

replace 'fallthrough' attribute with compiler specific ones

parent b06473a7
......@@ -5,6 +5,7 @@ target_sources(${UNIT} PUBLIC
"${CMAKE_CURRENT_LIST_DIR}/api/arctos/hw_interface.h"
"${CMAKE_CURRENT_LIST_DIR}/api/arctos/hw_interface.hpp"
"${CMAKE_CURRENT_LIST_DIR}/api/arctos/scheduler.hpp"
"${CMAKE_CURRENT_LIST_DIR}/api/compiler.h"
"${CMAKE_CURRENT_LIST_DIR}/api/new.hpp"
)
......
/**
* Copyright (c) 2019, Michael Zehrer
* All rights reserved.
*
* @licence BSD
* @brief Commonly used types and macros
* @author Michael Zehrer
*/
#ifndef COMPILER_H
#define COMPILER_H
#ifndef __ASSEMBLY__
/* Define FALL_THROUGH attribute */
#if defined(__cplusplus) && defined(__has_cpp_attribute)
#if __has_cpp_attribute(fallthrough)
#define FALL_THROUGH [[fallthrough]]
#endif
#endif
#ifndef FALL_THROUGH
#if defined(__GNUC__) && __GNUC__ >= 7
#define FALL_THROUGH __attribute__ ((fallthrough))
#else
#define FALL_THROUGH ((void)0)
#endif
#endif /* FALL_THROUGH */
#endif /* __ASSEMBLY__ */
#endif /* COMPILER_H */
......@@ -13,8 +13,9 @@
#include <stdbool.h>
#include <limits.h>
#include <arctos/debug.h>
#include <compiler.h>
#include <arctos/debug.h>
#include <arctos/hw_interface.h>
#ifdef __cplusplus
......@@ -120,7 +121,7 @@ static void printf_impl(const char *fmt, va_list *ap,
return;
case 'c':
c = va_arg(*ap, int);
__attribute__((fallthrough));
FALL_THROUGH;
default:
putc(c);
start = fmt;
......@@ -151,24 +152,24 @@ static void printf_impl(const char *fmt, va_list *ap,
case 'F':
format.attr.specifier_uppercase = 1;
__attribute__((fallthrough));
FALL_THROUGH;
case 'f':
format.attr.is_float = 1;
if (format.attr.precision_set == 0)
precision = 6;
__attribute__((fallthrough));
FALL_THROUGH;
case 'd':
__attribute__((fallthrough));
FALL_THROUGH;
case 'i':
format.attr.is_signed = 1;
__attribute__((fallthrough));
FALL_THROUGH;
case 'u':
format.attr.base = 10;
break;
case 'X':
format.attr.specifier_uppercase = 1;
__attribute__((fallthrough));
FALL_THROUGH;
case 'x':
if (format.attr.flags_hash) {
putc('0');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment