diff --git a/Kconfig.zephyr b/Kconfig.zephyr index 4043e771104..9821e2067d9 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -363,6 +363,12 @@ config LEGACY_DEVICETREE_MACROS Zephyr 2.2 and previous versions, rather than the devicetree.h API introduced during the Zephyr 2.3 development cycle. +config LEGACY_ZEPHYR_INT_TYPES + bool "Allow the use of the legacy zephyr integer types" + help + Allows the use of the legacy Zephyr integer typedefs defined in + Zephyr 2.3 and previous versions. + endmenu endmenu diff --git a/include/zephyr/types.h b/include/zephyr/types.h index e875a351800..bd97c8e9387 100644 --- a/include/zephyr/types.h +++ b/include/zephyr/types.h @@ -13,6 +13,8 @@ extern "C" { #endif +#ifdef CONFIG_LEGACY_ZEPHYR_INT_TYPES + typedef signed char s8_t; typedef signed short s16_t; typedef signed int s32_t; @@ -23,6 +25,8 @@ typedef unsigned short u16_t; typedef unsigned int u32_t; typedef unsigned long long u64_t; +#endif + /* 32 bits on ILP32 builds, 64 bits on LP64 builts */ typedef unsigned long ulong_t; diff --git a/tests/deprecated/inttype/CMakeLists.txt b/tests/deprecated/inttype/CMakeLists.txt new file mode 100644 index 00000000000..30b8735806e --- /dev/null +++ b/tests/deprecated/inttype/CMakeLists.txt @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 + +cmake_minimum_required(VERSION 3.13.1) + +find_package(Zephyr HINTS $ENV{ZEPHYR_BASE}) +project(test_inttypes) + +target_sources(app PRIVATE src/main.c) diff --git a/tests/deprecated/inttype/prj.conf b/tests/deprecated/inttype/prj.conf new file mode 100644 index 00000000000..b230bb0ce6e --- /dev/null +++ b/tests/deprecated/inttype/prj.conf @@ -0,0 +1 @@ +CONFIG_LEGACY_ZEPHYR_INT_TYPES=y diff --git a/tests/deprecated/inttype/src/main.c b/tests/deprecated/inttype/src/main.c new file mode 100644 index 00000000000..74bc769ede6 --- /dev/null +++ b/tests/deprecated/inttype/src/main.c @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2020 Linaro + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +void main(void) +{ + BUILD_ASSERT(sizeof(u8_t) == 1, "sizeof u8_t mismatch"); + BUILD_ASSERT(sizeof(u16_t) == 2, "sizeof u16_t mismatch"); + BUILD_ASSERT(sizeof(u32_t) == 4, "sizeof u32_t mismatch"); + BUILD_ASSERT(sizeof(u64_t) == 8, "sizeof u64_t mismatch"); + + BUILD_ASSERT(sizeof(s8_t) == 1, "sizeof s8_t mismatch"); + BUILD_ASSERT(sizeof(s16_t) == 2, "sizeof s16_t mismatch"); + BUILD_ASSERT(sizeof(s32_t) == 4, "sizeof s32_t mismatch"); + BUILD_ASSERT(sizeof(s64_t) == 8, "sizeof s64_t mismatch"); +} diff --git a/tests/deprecated/inttype/testcase.yaml b/tests/deprecated/inttype/testcase.yaml new file mode 100644 index 00000000000..707f79127b3 --- /dev/null +++ b/tests/deprecated/inttype/testcase.yaml @@ -0,0 +1,4 @@ +tests: + deprecated.inttypes: + build_only: true + tags: deprecated