Introduce new sized integer typedefs
This is a start to move away from the C99 {u}int{8,16,32,64}_t types to
Zephyr defined u{8,16,32,64}_t and s{8,16,32,64}_t. This allows Zephyr
to define the sized types in a consistent manor across all the
architectures we support and not conflict with what various compilers
and libc might do with regards to the C99 types.
We introduce <zephyr/types.h> as part of this and have it include
<stdint.h> for now until we transition all the code away from the C99
types.
We go with u{8,16,32,64}_t and s{8,16,32,64}_t as there are some
existing variables defined u8 & u16 as well as to be consistent with
Zephyr naming conventions.
Jira: ZEP-2051
Change-Id: I451fed0623b029d65866622e478225dfab2c0ca8
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
diff --git a/include/adc.h b/include/adc.h
index 9ad567e..44aeeae 100644
--- a/include/adc.h
+++ b/include/adc.h
@@ -12,7 +12,7 @@
#ifndef __INCLUDE_ADC_H__
#define __INCLUDE_ADC_H__
-#include <stdint.h>
+#include <zephyr/types.h>
#include <device.h>
#ifdef __cplusplus
diff --git a/include/arch/arc/v2/asm_inline_gcc.h b/include/arch/arc/v2/asm_inline_gcc.h
index 73e906b..4945b7f 100644
--- a/include/arch/arc/v2/asm_inline_gcc.h
+++ b/include/arch/arc/v2/asm_inline_gcc.h
@@ -18,7 +18,7 @@
#include <sys_io.h>
#include <arch/arc/v2/aux_regs.h>
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stddef.h>
/**
diff --git a/include/arch/arc/v2/aux_regs.h b/include/arch/arc/v2/aux_regs.h
index 7343c86..a249110 100644
--- a/include/arch/arc/v2/aux_regs.h
+++ b/include/arch/arc/v2/aux_regs.h
@@ -112,7 +112,7 @@
#ifndef _ASMLANGUAGE
#if defined(__GNUC__)
-#include <stdint.h>
+#include <zephyr/types.h>
#define _arc_v2_aux_reg_read(reg) __builtin_arc_lr((volatile uint32_t)reg)
#define _arc_v2_aux_reg_write(reg, val) __builtin_arc_sr((unsigned int)val, (volatile uint32_t)reg)
diff --git a/include/arch/arc/v2/ffs.h b/include/arch/arc/v2/ffs.h
index fc75f67..8f40eb2 100644
--- a/include/arch/arc/v2/ffs.h
+++ b/include/arch/arc/v2/ffs.h
@@ -20,7 +20,7 @@
#ifndef _ASMLANGUAGE
-#include <stdint.h>
+#include <zephyr/types.h>
/**
*
diff --git a/include/arch/arm/cortex_m/asm_inline_gcc.h b/include/arch/arm/cortex_m/asm_inline_gcc.h
index 71790bd..69ee883 100644
--- a/include/arch/arm/cortex_m/asm_inline_gcc.h
+++ b/include/arch/arm/cortex_m/asm_inline_gcc.h
@@ -29,7 +29,7 @@
#define _SCS_ICSR_RETTOBASE (1 << 11)
#else /* !_ASMLANGUAGE */
-#include <stdint.h>
+#include <zephyr/types.h>
#include <arch/arm/cortex_m/exc.h>
#include <irq.h>
diff --git a/include/arch/arm/cortex_m/exc.h b/include/arch/arm/cortex_m/exc.h
index 00642fc..5dabb17 100644
--- a/include/arch/arm/cortex_m/exc.h
+++ b/include/arch/arm/cortex_m/exc.h
@@ -43,7 +43,7 @@
#ifdef _ASMLANGUAGE
GTEXT(_ExcExit);
#else
-#include <stdint.h>
+#include <zephyr/types.h>
struct __esf {
sys_define_gpr_with_alias(a1, r0);
diff --git a/include/arch/nios2/arch.h b/include/arch/nios2/arch.h
index 7a1e55e..fd148a5 100644
--- a/include/arch/nios2/arch.h
+++ b/include/arch/nios2/arch.h
@@ -36,7 +36,7 @@
#define SIZEOFUNIT_TO_OCTET(X) (X)
#ifndef _ASMLANGUAGE
-#include <stdint.h>
+#include <zephyr/types.h>
#include <irq.h>
#include <sw_isr_table.h>
diff --git a/include/arch/nios2/nios2.h b/include/arch/nios2/nios2.h
index a71cf32..ae8f320 100644
--- a/include/arch/nios2/nios2.h
+++ b/include/arch/nios2/nios2.h
@@ -51,7 +51,7 @@
#ifndef _ASMLANGUAGE
-#include <stdint.h>
+#include <zephyr/types.h>
#include <arch/cpu.h>
#include <sys_io.h>
diff --git a/include/arch/riscv32/exp.h b/include/arch/riscv32/exp.h
index de1afd2..649c244 100644
--- a/include/arch/riscv32/exp.h
+++ b/include/arch/riscv32/exp.h
@@ -19,7 +19,7 @@
#endif
#ifndef _ASMLANGUAGE
-#include <stdint.h>
+#include <zephyr/types.h>
#include <toolchain.h>
struct __esf {
diff --git a/include/arch/x86/asm_inline_gcc.h b/include/arch/x86/asm_inline_gcc.h
index bc88564..b170835 100644
--- a/include/arch/x86/asm_inline_gcc.h
+++ b/include/arch/x86/asm_inline_gcc.h
@@ -23,7 +23,7 @@
#endif
#ifndef _ASMLANGUAGE
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stddef.h>
/**
diff --git a/include/arch/x86/segmentation.h b/include/arch/x86/segmentation.h
index b67d327..e348c6f 100644
--- a/include/arch/x86/segmentation.h
+++ b/include/arch/x86/segmentation.h
@@ -7,7 +7,7 @@
#ifndef _SEGMENTATION_H
#define _SEGMENTATION_H
-#include <stdint.h>
+#include <zephyr/types.h>
/* Host gen_idt uses this header as well, don't depend on toolchain.h */
#ifndef __packed
diff --git a/include/arch/xtensa/arch.h b/include/arch/xtensa/arch.h
index 6a60fe0..8ff69f2 100644
--- a/include/arch/xtensa/arch.h
+++ b/include/arch/xtensa/arch.h
@@ -21,7 +21,7 @@
#if !defined(_ASMLANGUAGE) && !defined(__ASSEMBLER__)
#include "sys_io.h" /* Include from the very same folder of this file */
-#include <stdint.h>
+#include <zephyr/types.h>
#include <sw_isr_table.h>
#include <arch/xtensa/xtensa_irq.h>
#include <xtensa/config/core.h>
diff --git a/include/bluetooth/buf.h b/include/bluetooth/buf.h
index 899c3a6..1485b87 100644
--- a/include/bluetooth/buf.h
+++ b/include/bluetooth/buf.h
@@ -18,7 +18,7 @@
* @{
*/
-#include <stdint.h>
+#include <zephyr/types.h>
#include <net/buf.h>
#include <bluetooth/hci.h>
diff --git a/include/bluetooth/hci.h b/include/bluetooth/hci.h
index 304d99f..ff8828a 100644
--- a/include/bluetooth/hci.h
+++ b/include/bluetooth/hci.h
@@ -9,7 +9,7 @@
#define __BT_HCI_H
#include <toolchain.h>
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stdbool.h>
#include <string.h>
#include <misc/util.h>
diff --git a/include/clock_control.h b/include/clock_control.h
index 5c78f30..af9e9c7 100644
--- a/include/clock_control.h
+++ b/include/clock_control.h
@@ -9,7 +9,7 @@
#ifndef __CLOCK_CONTROL_H__
#define __CLOCK_CONTROL_H__
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stddef.h>
#include <device.h>
#include <misc/__assert.h>
diff --git a/include/counter.h b/include/counter.h
index 818b46f..2b486ea 100644
--- a/include/counter.h
+++ b/include/counter.h
@@ -19,7 +19,7 @@
* @{
*/
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stddef.h>
#include <device.h>
diff --git a/include/crc16.h b/include/crc16.h
index cd29b13..860a292 100644
--- a/include/crc16.h
+++ b/include/crc16.h
@@ -11,7 +11,7 @@
#ifndef __CRC16_H
#define __CRC16_H
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stddef.h>
/**
diff --git a/include/device.h b/include/device.h
index 6881c9e..0bc4b7e 100644
--- a/include/device.h
+++ b/include/device.h
@@ -22,7 +22,7 @@
* @{
*/
-#include <stdint.h>
+#include <zephyr/types.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/disk_access.h b/include/disk_access.h
index 92a3408..6a4029f 100644
--- a/include/disk_access.h
+++ b/include/disk_access.h
@@ -17,7 +17,7 @@
#ifndef _DISK_ACCESS_H_
#define _DISK_ACCESS_H_
-#include <stdint.h>
+#include <zephyr/types.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/display/mb_display.h b/include/display/mb_display.h
index f6cc1bc..f82ce8c 100644
--- a/include/display/mb_display.h
+++ b/include/display/mb_display.h
@@ -18,7 +18,7 @@
*/
#include <stdio.h>
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stdbool.h>
#include <misc/util.h>
#include <toolchain.h>
diff --git a/include/drivers/gpio/gpio_mmio32.h b/include/drivers/gpio/gpio_mmio32.h
index c2f4027..3323158 100644
--- a/include/drivers/gpio/gpio_mmio32.h
+++ b/include/drivers/gpio/gpio_mmio32.h
@@ -9,7 +9,7 @@
#include <device.h>
#include <gpio.h>
-#include <stdint.h>
+#include <zephyr/types.h>
struct gpio_mmio32_config {
volatile uint32_t *reg;
diff --git a/include/drivers/k20_sim.h b/include/drivers/k20_sim.h
index c7520d7..8bf7f0a 100644
--- a/include/drivers/k20_sim.h
+++ b/include/drivers/k20_sim.h
@@ -16,7 +16,7 @@
#ifndef _K20SIM_H_
#define _K20SIM_H_
-#include <stdint.h>
+#include <zephyr/types.h>
#include <misc/__assert.h>
#ifdef __cplusplus
diff --git a/include/drivers/mvic.h b/include/drivers/mvic.h
index 313b484..41fded0 100644
--- a/include/drivers/mvic.h
+++ b/include/drivers/mvic.h
@@ -47,7 +47,7 @@
*/
#ifndef _ASMLANGUAGE
-#include <stdint.h>
+#include <zephyr/types.h>
/* Implementation of irq_controller.h interface */
diff --git a/include/drivers/rand32.h b/include/drivers/rand32.h
index 99afe16..d9b29b9 100644
--- a/include/drivers/rand32.h
+++ b/include/drivers/rand32.h
@@ -20,7 +20,7 @@
#ifndef __INCrand32h
#define __INCrand32h
-#include <stdint.h>
+#include <zephyr/types.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/flash.h b/include/flash.h
index 1d90a22..3e89f41 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -19,7 +19,7 @@
* @{
*/
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stddef.h>
#include <sys/types.h>
#include <device.h>
diff --git a/include/gpio.h b/include/gpio.h
index eb26849..052146e 100644
--- a/include/gpio.h
+++ b/include/gpio.h
@@ -16,7 +16,7 @@
#include <misc/__assert.h>
#include <misc/slist.h>
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stddef.h>
#include <device.h>
diff --git a/include/i2c.h b/include/i2c.h
index 58240e5..3acda7a 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -23,7 +23,7 @@
extern "C" {
#endif
-#include <stdint.h>
+#include <zephyr/types.h>
#include <device.h>
/*
diff --git a/include/kernel.h b/include/kernel.h
index a263d0a..dbee429 100644
--- a/include/kernel.h
+++ b/include/kernel.h
@@ -15,8 +15,7 @@
#if !defined(_ASMLANGUAGE)
#include <stddef.h>
-#include <stdint.h>
-#include <inttypes.h>
+#include <zephyr/types.h>
#include <limits.h>
#include <toolchain.h>
#include <sections.h>
diff --git a/include/linker-defs.h b/include/linker-defs.h
index 418025f..7acf308 100644
--- a/include/linker-defs.h
+++ b/include/linker-defs.h
@@ -135,7 +135,7 @@
#else /* ! _ASMLANGUAGE */
-#include <stdint.h>
+#include <zephyr/types.h>
extern char __bss_start[];
extern char __bss_end[];
#ifdef CONFIG_XIP
diff --git a/include/misc/byteorder.h b/include/misc/byteorder.h
index a853146..848dc9d 100644
--- a/include/misc/byteorder.h
+++ b/include/misc/byteorder.h
@@ -11,7 +11,7 @@
#ifndef __BYTEORDER_H__
#define __BYTEORDER_H__
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stddef.h>
#include <misc/__assert.h>
diff --git a/include/misc/util.h b/include/misc/util.h
index 6d35bba..1f78859 100644
--- a/include/misc/util.h
+++ b/include/misc/util.h
@@ -20,7 +20,7 @@
#ifndef _ASMLANGUAGE
-#include <stdint.h>
+#include <zephyr/types.h>
/* Helper to pass a int as a pointer or vice-versa.
* Those are available for 32 bits architectures:
diff --git a/include/net/buf.h b/include/net/buf.h
index 14a6b35..8a15e6f 100644
--- a/include/net/buf.h
+++ b/include/net/buf.h
@@ -11,7 +11,7 @@
#define __NET_BUF_H
#include <stddef.h>
-#include <stdint.h>
+#include <zephyr/types.h>
#include <misc/util.h>
#include <zephyr.h>
diff --git a/include/net/dhcpv4.h b/include/net/dhcpv4.h
index 0f4b150..900283b 100644
--- a/include/net/dhcpv4.h
+++ b/include/net/dhcpv4.h
@@ -18,7 +18,7 @@
*/
#include <misc/slist.h>
-#include <stdint.h>
+#include <zephyr/types.h>
/** Current state of DHCPv4 client address negotiation.
*
diff --git a/include/net/ethernet.h b/include/net/ethernet.h
index fcddd97..82b990c 100644
--- a/include/net/ethernet.h
+++ b/include/net/ethernet.h
@@ -13,7 +13,7 @@
#ifndef __ETHERNET_H
#define __ETHERNET_H
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stdbool.h>
#include <net/net_ip.h>
diff --git a/include/net/http_parser.h b/include/net/http_parser.h
index 7c921b6..b53c241 100644
--- a/include/net/http_parser.h
+++ b/include/net/http_parser.h
@@ -43,7 +43,7 @@
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stddef.h>
#endif
diff --git a/include/net/mqtt_types.h b/include/net/mqtt_types.h
index adc9885..0de0300 100644
--- a/include/net/mqtt_types.h
+++ b/include/net/mqtt_types.h
@@ -7,7 +7,7 @@
#ifndef _MQTT_TYPES_H_
#define _MQTT_TYPES_H_
-#include <stdint.h>
+#include <zephyr/types.h>
/**
* @brief MQTT library
diff --git a/include/net/nbuf.h b/include/net/nbuf.h
index c479276..b3c3303 100644
--- a/include/net/nbuf.h
+++ b/include/net/nbuf.h
@@ -16,7 +16,7 @@
#ifndef __NBUF_H
#define __NBUF_H
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stdbool.h>
#include <net/buf.h>
diff --git a/include/net/net_ip.h b/include/net/net_ip.h
index 295eff1..e78e12f 100644
--- a/include/net/net_ip.h
+++ b/include/net/net_ip.h
@@ -20,7 +20,7 @@
*/
#include <string.h>
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stdbool.h>
#include <misc/byteorder.h>
#include <toolchain.h>
diff --git a/include/net/net_linkaddr.h b/include/net/net_linkaddr.h
index 70af69b..9ea76aa 100644
--- a/include/net/net_linkaddr.h
+++ b/include/net/net_linkaddr.h
@@ -12,7 +12,7 @@
#ifndef __NET_LINKADDR_H__
#define __NET_LINKADDR_H__
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stdbool.h>
#include <errno.h>
diff --git a/include/net/net_stats.h b/include/net/net_stats.h
index f8a16bd..ca26a91 100644
--- a/include/net/net_stats.h
+++ b/include/net/net_stats.h
@@ -14,7 +14,7 @@
#ifndef __NET_STATS_H
#define __NET_STATS_H
-#include <stdint.h>
+#include <zephyr/types.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/net/trickle.h b/include/net/trickle.h
index 27b6e8d..d72bf5c 100644
--- a/include/net/trickle.h
+++ b/include/net/trickle.h
@@ -14,7 +14,7 @@
#define __TRICKLE_H
#include <stdbool.h>
-#include <stdint.h>
+#include <zephyr/types.h>
#include <kernel.h>
#include <net/net_core.h>
diff --git a/include/net/zoap.h b/include/net/zoap.h
index 6084ab5..8ccba5b 100644
--- a/include/net/zoap.h
+++ b/include/net/zoap.h
@@ -13,7 +13,7 @@
#ifndef __ZOAP_H__
#define __ZOAP_H__
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stddef.h>
#include <stdbool.h>
diff --git a/include/pinmux.h b/include/pinmux.h
index 80fb567..1bc6955 100644
--- a/include/pinmux.h
+++ b/include/pinmux.h
@@ -19,7 +19,7 @@
* @{
*/
-#include <stdint.h>
+#include <zephyr/types.h>
#include <device.h>
#ifdef __cplusplus
diff --git a/include/pwm.h b/include/pwm.h
index 84b4494..b4dfdb9 100644
--- a/include/pwm.h
+++ b/include/pwm.h
@@ -27,7 +27,7 @@
#define PWM_ACCESS_ALL 1
#include <errno.h>
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stddef.h>
#include <device.h>
diff --git a/include/random.h b/include/random.h
index f354d2e..62f17bf 100644
--- a/include/random.h
+++ b/include/random.h
@@ -23,7 +23,7 @@
extern "C" {
#endif
-#include <stdint.h>
+#include <zephyr/types.h>
#include <device.h>
/**
diff --git a/include/rtc.h b/include/rtc.h
index 40c24c5..74ef214 100644
--- a/include/rtc.h
+++ b/include/rtc.h
@@ -6,7 +6,7 @@
#ifndef _RTC_H_
#define _RTC_H_
-#include <stdint.h>
+#include <zephyr/types.h>
#include <device.h>
#include <misc/util.h>
diff --git a/include/sensor.h b/include/sensor.h
index bbc1830..32d3c4b 100644
--- a/include/sensor.h
+++ b/include/sensor.h
@@ -23,7 +23,7 @@
extern "C" {
#endif
-#include <stdint.h>
+#include <zephyr/types.h>
#include <device.h>
#include <errno.h>
diff --git a/include/spi.h b/include/spi.h
index c068bf4..3a15423 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -19,7 +19,7 @@
* @{
*/
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stddef.h>
#include <device.h>
diff --git a/include/sw_isr_table.h b/include/sw_isr_table.h
index 1740339..bf91db8 100644
--- a/include/sw_isr_table.h
+++ b/include/sw_isr_table.h
@@ -21,7 +21,7 @@
#endif
#if !defined(_ASMLANGUAGE)
-#include <stdint.h>
+#include <zephyr/types.h>
#include <toolchain.h>
/*
diff --git a/include/sys_clock.h b/include/sys_clock.h
index a83a657..2e15e9a 100644
--- a/include/sys_clock.h
+++ b/include/sys_clock.h
@@ -21,7 +21,7 @@
#endif
#ifndef _ASMLANGUAGE
-#include <stdint.h>
+#include <zephyr/types.h>
#if defined(CONFIG_SYS_CLOCK_EXISTS) && \
(CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC == 0)
diff --git a/include/sys_io.h b/include/sys_io.h
index 96685d0..bfb6f36 100644
--- a/include/sys_io.h
+++ b/include/sys_io.h
@@ -14,7 +14,7 @@
#endif
#include <kernel.h>
-#include <stdint.h>
+#include <zephyr/types.h>
#include <stddef.h>
typedef uint32_t io_port_t;
diff --git a/include/watchdog.h b/include/watchdog.h
index e62753c..8cc717e 100644
--- a/include/watchdog.h
+++ b/include/watchdog.h
@@ -7,7 +7,7 @@
#ifndef _WDT_H_
#define _WDT_H_
-#include <stdint.h>
+#include <zephyr/types.h>
#include <device.h>
#include <misc/util.h>
diff --git a/include/zephyr/types.h b/include/zephyr/types.h
new file mode 100644
index 0000000..5ae80b0
--- /dev/null
+++ b/include/zephyr/types.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017 Linaro Limited
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef __Z_TYPES_H__
+#define __Z_TYPES_H__
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef signed char s8_t;
+typedef signed short s16_t;
+typedef signed int s32_t;
+typedef signed long long s64_t;
+
+typedef unsigned char u8_t;
+typedef unsigned short u16_t;
+typedef unsigned int u32_t;
+typedef unsigned long long u64_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __Z_TYPES_H__ */