zephyr: Make Zephyr int types deprecated by default

As the int types defined in include/zephyr/types.h are typdef's we
utilize a Kconfig option (LEGACY_ZEPHYR_INT_TYPES) to enable/disable
the support for them.  By default to LEGACY_ZEPHYR_INT_TYPES not
being enabled and add an explicit test to ensure the types continue to
function until removed in the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
Kumar Gala 2020-05-27 13:16:44 -05:00 committed by Kumar Gala
commit e353d123fd
6 changed files with 43 additions and 0 deletions

View file

@ -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

View file

@ -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;

View file

@ -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)

View file

@ -0,0 +1 @@
CONFIG_LEGACY_ZEPHYR_INT_TYPES=y

View file

@ -0,0 +1,20 @@
/*
* Copyright (c) 2020 Linaro
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
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");
}

View file

@ -0,0 +1,4 @@
tests:
deprecated.inttypes:
build_only: true
tags: deprecated