muteki
Loading...
Searching...
No Matches
common.h File Reference

Common include file for all muteki-shims headers. More...

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <sys/types.h>

Go to the source code of this file.

Macros

#define UTF16   __BESTA_UTF_TYPE
 "Portable" Besta UTF-16 type used by other headers.
 
#define _BUL(x)   __BESTA_UTF_LITERAL(x)
 Besta UTF-16 string literal.
 
#define __SYS_DWORD   __attribute__((packed, aligned(4)))
 
#define __SYS_ALIGN(n)   __attribute__((aligned(n)))
 
#define __SYS_IS_PRINTF(arg_index_str, arg_index_fmt)   __attribute__((format(printf, arg_index_str, arg_index_fmt)))
 
#define SYS_DWORD   __SYS_DWORD
 Attribute for structure fields that are DWORD (64-bit), that are used by system calls.
 
#define SYS_ALIGN(n)   __SYS_ALIGN(n)
 Attribute for forcing alignment.
 
#define SYS_IS_PRINTF(arg_index_str, arg_index_fmt)   __SYS_IS_PRINTF(arg_index_str, arg_index_fmt)
 Attribute for opting a function in for printf static checking.
 

Detailed Description

Common include file for all muteki-shims headers.

Includes several headers that provide standard C features used by each header (e.g. stdint.h for ?int*_t and stdbool.h for bool type).

Macro Definition Documentation

◆ _BUL

#define _BUL (   x)    __BESTA_UTF_LITERAL(x)

Besta UTF-16 string literal.

This will map to either u string or L string depending on availability of compiler support for char16_t and wchar_t's size.

◆ SYS_ALIGN

#define SYS_ALIGN (   n)    __SYS_ALIGN(n)

Attribute for forcing alignment.

Todo:
MSVC support

◆ SYS_DWORD

#define SYS_DWORD   __SYS_DWORD

Attribute for structure fields that are DWORD (64-bit), that are used by system calls.

This will align the struct fields to 4 bytes so ldr/str can still work as normal while all 64-bit values are retrieved with 2 ldr/str instructions instead of 1 ldrd/strd instruction (when compiling the program for armv5 and up) or emulated counterpart (when compiling the program for armv4). This is needed because Besta RTOS uses 4-byte alignment for 64-bit fields by default and ldrd/strd will not work on those fields.

For single variable this is not necessary since 8-byte aligned variables can be understood by code that uses 4-byte alignment.

Todo:
MSVC support (is it possible?)

◆ SYS_IS_PRINTF

#define SYS_IS_PRINTF (   arg_index_str,
  arg_index_fmt 
)    __SYS_IS_PRINTF(arg_index_str, arg_index_fmt)

Attribute for opting a function in for printf static checking.

Todo:
MSVC support (or simply bypass it).

◆ UTF16

#define UTF16   __BESTA_UTF_TYPE

"Portable" Besta UTF-16 type used by other headers.

This is guaranteed to be 16-bit wide, unlike wchar_t (normally 32-bit wide) or char16_t (new C11 addition, can be >16-bit depending on the toolchain).