Skip to content

Commit

Permalink
[arch] inbond stdinc
Browse files Browse the repository at this point in the history
  • Loading branch information
YuzukiTsuru committed Feb 3, 2024
1 parent f6ed056 commit f2e4883
Show file tree
Hide file tree
Showing 27 changed files with 202 additions and 47 deletions.
2 changes: 1 addition & 1 deletion cmake/board/100ask-ros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ set(CROSS_COMPILE ${CROSS_COMPILE} CACHE STRING "CROSS_COMPILE Toolchain")
set(CMAKE_C_COMPILER "${CROSS_COMPILE}gcc")
set(CMAKE_CXX_COMPILER "${CROSS_COMPILE}g++")

set(CMAKE_COMMON_FLAGS "-nostdlib -Os -mcpu=cortex-a53 -mno-unaligned-access")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -Os -mcpu=cortex-a53 -mno-unaligned-access")

# Disable specific warning flags for C and C++ compilers
set(CMAKE_C_DISABLE_WARN_FLAGS "-Wno-int-to-pointer-cast -Wno-discarded-qualifiers -Wno-implicit-function-declaration")
Expand Down
4 changes: 2 additions & 2 deletions cmake/board/100ask-t113i.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ set(CMAKE_CXX_COMPILER "${CROSS_COMPILE}g++")

# Configure compiler flags based on ENABLE_HARDFP option
if(ENABLE_HARDFP)
set(CMAKE_COMMON_FLAGS "-nostdlib -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=hard")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=hard")
else()
set(CMAKE_COMMON_FLAGS "-nostdlib -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=softfp")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=softfp")
endif()

# Disable specific warning flags for C and C++ compilers
Expand Down
4 changes: 2 additions & 2 deletions cmake/board/100ask-t113s3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ set(CMAKE_CXX_COMPILER "${CROSS_COMPILE}g++")

# Configure compiler flags based on ENABLE_HARDFP option
if(ENABLE_HARDFP)
set(CMAKE_COMMON_FLAGS "-nostdlib -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=hard")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=hard")
else()
set(CMAKE_COMMON_FLAGS "-nostdlib -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=softfp")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=softfp")
endif()

# Disable specific warning flags for C and C++ compilers
Expand Down
4 changes: 2 additions & 2 deletions cmake/board/bingpi-m1.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ set(CMAKE_CXX_COMPILER "${CROSS_COMPILE}g++")

# Configure compiler flags based on ENABLE_HARDFP option
if(ENABLE_HARDFP)
set(CMAKE_COMMON_FLAGS "-nostdlib -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=hard")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=hard")
else()
set(CMAKE_COMMON_FLAGS "-nostdlib -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=softfp")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=softfp")
endif()

# Disable specific warning flags for C and C++ compilers
Expand Down
4 changes: 2 additions & 2 deletions cmake/board/dongshanpi-aict.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ set(CMAKE_CXX_COMPILER "${CROSS_COMPILE}g++")

# Configure compiler flags based on ENABLE_HARDFP option
if(ENABLE_HARDFP)
set(CMAKE_COMMON_FLAGS "-nostdlib -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=hard")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=hard")
else()
set(CMAKE_COMMON_FLAGS "-nostdlib -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=softfp")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=softfp")
endif()

# Disable specific warning flags for C and C++ compilers
Expand Down
2 changes: 1 addition & 1 deletion cmake/board/longanpi-3h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ set(CROSS_COMPILE ${CROSS_COMPILE} CACHE STRING "CROSS_COMPILE Toolchain")
set(CMAKE_C_COMPILER "${CROSS_COMPILE}gcc")
set(CMAKE_CXX_COMPILER "${CROSS_COMPILE}g++")

set(CMAKE_COMMON_FLAGS "-nostdlib -Os -mcpu=cortex-a53 -mno-unaligned-access")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -Os -mcpu=cortex-a53 -mno-unaligned-access")

# Disable specific warning flags for C and C++ compilers
set(CMAKE_C_DISABLE_WARN_FLAGS "-Wno-int-to-pointer-cast -Wno-discarded-qualifiers -Wno-implicit-function-declaration")
Expand Down
2 changes: 1 addition & 1 deletion cmake/board/longanpi-4b.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ set(CROSS_COMPILE ${CROSS_COMPILE} CACHE STRING "CROSS_COMPILE Toolchain")
set(CMAKE_C_COMPILER "${CROSS_COMPILE}gcc")
set(CMAKE_CXX_COMPILER "${CROSS_COMPILE}g++")

set(CMAKE_COMMON_FLAGS "-nostdlib -Os -mcpu=cortex-a55")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -Os -mcpu=cortex-a55")

# Disable specific warning flags for C and C++ compilers
set(CMAKE_C_DISABLE_WARN_FLAGS "-Wno-int-to-pointer-cast -Wno-implicit-function-declaration -Wno-discarded-qualifiers")
Expand Down
2 changes: 1 addition & 1 deletion cmake/board/lt527x.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ set(CROSS_COMPILE ${CROSS_COMPILE} CACHE STRING "CROSS_COMPILE Toolchain")
set(CMAKE_C_COMPILER "${CROSS_COMPILE}gcc")
set(CMAKE_CXX_COMPILER "${CROSS_COMPILE}g++")

set(CMAKE_COMMON_FLAGS "-nostdlib -Os -mcpu=cortex-a55")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -Os -mcpu=cortex-a55")

# Disable specific warning flags for C and C++ compilers
set(CMAKE_C_DISABLE_WARN_FLAGS "-Wno-int-to-pointer-cast -Wno-implicit-function-declaration -Wno-discarded-qualifiers")
Expand Down
4 changes: 2 additions & 2 deletions cmake/board/project-yosemite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ set(CMAKE_CXX_COMPILER "${CROSS_COMPILE}g++")

# Configure compiler flags based on ENABLE_HARDFP option
if(ENABLE_HARDFP)
set(CMAKE_COMMON_FLAGS "-nostdlib -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=hard")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=hard")
else()
set(CMAKE_COMMON_FLAGS "-nostdlib -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=softfp")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=softfp")
endif()

# Disable specific warning flags for C and C++ compilers
Expand Down
4 changes: 2 additions & 2 deletions cmake/board/tinyvision.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ set(CMAKE_CXX_COMPILER "${CROSS_COMPILE}g++")

# Configure compiler flags based on ENABLE_HARDFP option
if(ENABLE_HARDFP)
set(CMAKE_COMMON_FLAGS "-nostdlib -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=hard")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=hard")
else()
set(CMAKE_COMMON_FLAGS "-nostdlib -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=softfp")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=softfp")
endif()

# Disable specific warning flags for C and C++ compilers
Expand Down
2 changes: 1 addition & 1 deletion cmake/board/yuzukicivi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ set(CROSS_COMPILE ${CROSS_COMPILE} CACHE STRING "CROSS_COMPILE Toolchain")
set(CMAKE_C_COMPILER "${CROSS_COMPILE}gcc")
set(CMAKE_CXX_COMPILER "${CROSS_COMPILE}g++")

set(CMAKE_COMMON_FLAGS "-nostdlib -Os -mcpu=cortex-a53 -mno-unaligned-access")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -Os -mcpu=cortex-a53 -mno-unaligned-access")

# Disable specific warning flags for C and C++ compilers
set(CMAKE_C_DISABLE_WARN_FLAGS "-Wno-int-to-pointer-cast -Wno-discarded-qualifiers -Wno-implicit-function-declaration")
Expand Down
4 changes: 2 additions & 2 deletions cmake/board/yuzukilizard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ set(CMAKE_CXX_COMPILER "${CROSS_COMPILE}g++")

# Configure compiler flags based on ENABLE_HARDFP option
if(ENABLE_HARDFP)
set(CMAKE_COMMON_FLAGS "-nostdlib -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=hard")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=hard")
else()
set(CMAKE_COMMON_FLAGS "-nostdlib -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=softfp")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=softfp")
endif()

# Disable specific warning flags for C and C++ compilers
Expand Down
4 changes: 2 additions & 2 deletions cmake/lib/generic_sun8iw21.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ set(CMAKE_CXX_COMPILER "${CROSS_COMPILE}g++")

# Configure compiler flags based on ENABLE_HARDFP option
if(ENABLE_HARDFP)
set(CMAKE_COMMON_FLAGS "-nostdlib -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=hard")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=hard")
else()
set(CMAKE_COMMON_FLAGS "-nostdlib -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=softfp")
set(CMAKE_COMMON_FLAGS "-nostdlib -nostdinc -g -ggdb -O3 -mcpu=cortex-a7 -mthumb-interwork -mthumb -mno-unaligned-access -mfpu=neon-vfpv4 -mfloat-abi=softfp")
endif()

# Disable specific warning flags for C and C++ compilers
Expand Down
2 changes: 1 addition & 1 deletion include/arch/arm32/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef __IO_H__
#define __IO_H__

#include "types.h"
#include <stdint.h>

#define BIT(x) (1 << x)
#define clrsetbits_le32(addr, clear, set) \
Expand Down
29 changes: 29 additions & 0 deletions include/arch/arm32/limits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef __LIMITS_H__
#define __LIMITS_H__

#ifdef __cplusplus
extern "C" {
#endif

#define INT8_MIN (-1 - 0x7f)
#define INT16_MIN (-1 - 0x7fff)
#define INT32_MIN (-1 - 0x7fffffff)
#define INT64_MIN (-1 - 0x7fffffffffffffff)

#define INT8_MAX (0x7f)
#define INT16_MAX (0x7fff)
#define INT32_MAX (0x7fffffff)
#define INT64_MAX (0x7fffffffffffffff)

#define INT_MAX (0x7fffffff)

#define UINT8_MAX (0xff)
#define UINT16_MAX (0xffff)
#define UINT32_MAX (0xffffffffU)
#define UINT64_MAX (0xffffffffffffffffU)

#ifdef __cplusplus
}
#endif

#endif// __LIMITS_H__
2 changes: 1 addition & 1 deletion include/arch/arm32/mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
extern "C" {
#endif

#include <stdint.h>


#include "timer.h"

Expand Down
34 changes: 34 additions & 0 deletions include/arch/arm32/stdarg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef __STDARG_H__
#define __STDARG_H__

#ifdef __cplusplus
extern "C" {
#endif

typedef __builtin_va_list va_list;

/*
* prepare to access variable args
*/
#define va_start(v, l) __builtin_va_start(v, l)

/*
* the caller will get the value of current argument
*/
#define va_arg(v, l) __builtin_va_arg(v, l)

/*
* end for variable args
*/
#define va_end(v) __builtin_va_end(v)

/*
* copy variable args
*/
#define va_copy(d, s) __builtin_va_copy(d, s)

#ifdef __cplusplus
}
#endif

#endif /* __STDARG_H__ */
21 changes: 21 additions & 0 deletions include/arch/arm32/stdbool.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef __STDBOOL_H__
#define __STDBOOL_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

enum {
false = 0,
true = 1,
};

typedef uint8_t bool;

#ifdef __cplusplus
}
#endif

#endif // __STDBOOL_H__
43 changes: 43 additions & 0 deletions include/arch/arm32/stddef.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#ifndef __STDDEF_H__
#define __STDDEF_H__

#ifdef __cplusplus
extern "C" {
#endif

#if defined(__cplusplus)
#define NULL (0)
#else
#define NULL ((void *) 0)
#endif

#if (defined(__GNUC__) && (__GNUC__ >= 4))
#define offsetof(type, member) __builtin_offsetof(type, member)
#else
#define offsetof(type, field) ((size_t) (&((type *) 0)->field))
#endif
#define container_of(ptr, type, member) ({const typeof(((type *)0)->member) *__mptr = (ptr); (type *)((char *)__mptr - offsetof(type,member)); })

#if (defined(__GNUC__) && (__GNUC__ >= 3))
#define likely(expr) (__builtin_expect(!!(expr), 1))
#define unlikely(expr) (__builtin_expect(!!(expr), 0))
#else
#define likely(expr) (!!(expr))
#define unlikely(expr) (!!(expr))
#endif

#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))

#define clamp(v, a, b) min(max(a, v), b)

#define ifloor(x) ((x) > 0 ? (int) (x) : (int) ((x) -0.9999999999))
#define iround(x) ((x) > 0 ? (int) ((x) + 0.5) : (int) ((x) -0.5))
#define iceil(x) ((x) > 0 ? (int) ((x) + 0.9999999999) : (int) (x))
#define idiv255(x) ((((int) (x) + 1) * 257) >> 16)

#ifdef __cplusplus
}
#endif

#endif /* __STDDEF_H__ */
45 changes: 45 additions & 0 deletions include/arch/arm32/stdint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#ifndef __STDINT_H__
#define __STDINT_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <types.h>

typedef signed char s8_t;
typedef unsigned char u8_t;

typedef signed short s16_t;
typedef unsigned short u16_t;

typedef signed int s32_t;
typedef unsigned int u32_t;

typedef signed long long s64_t;
typedef unsigned long long u64_t;

typedef signed long long intmax_t;
typedef unsigned long long uintmax_t;

typedef signed long long ptrdiff_t;
typedef signed long long intptr_t;
typedef unsigned long int uintptr_t;

typedef s8_t int8_t;
typedef u8_t uint8_t;

typedef s16_t int16_t;
typedef u16_t uint16_t;

typedef s32_t int32_t;
typedef u32_t uint32_t;

typedef s64_t int64_t;
typedef u64_t uint64_t;

#ifdef __cplusplus
}
#endif

#endif /* __STDINT_H__ */
Empty file added include/arch/arm32/stdlib.h
Empty file.
2 changes: 1 addition & 1 deletion include/arch/arm32/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

#include <types.h>

#include "log.h"
Expand Down
13 changes: 1 addition & 12 deletions include/arch/arm32/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define __ASM_ARM_TYPES_H

typedef unsigned short umode_t;
typedef unsigned long size_t;

/*
* __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
Expand Down Expand Up @@ -43,18 +44,6 @@ typedef unsigned long long u64;
typedef float f32;
typedef double f64;

typedef signed char int8_t;
typedef unsigned char uint8_t;

typedef signed short int16_t;
typedef unsigned short uint16_t;

typedef signed int int32_t;
typedef unsigned int uint32_t;

typedef signed long long int64_t;
typedef unsigned long long uint64_t;

#ifdef CONFIG_ARM64
#define BITS_PER_LONG 64
#else /* CONFIG_ARM64 */
Expand Down
2 changes: 1 addition & 1 deletion include/arch/riscv64/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef __IO_H__
#define __IO_H__

#include <inttypes.h>


#define BIT(x) (1 << x)
#define clrsetbits_le32(addr, clear, set) \
Expand Down
Loading

0 comments on commit f2e4883

Please sign in to comment.