usr: Add global system headers

Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
2026-04-16 19:20:28 -04:00
parent 53466e332e
commit a8c0cdd06c
7 changed files with 262 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2026, Mirocom Laboratories
* All rights reserved.
*
* The following sources are CONFIDENTIAL and PROPRIETARY
* property of Mirocom Laboratories. Unauthorized copying,
* use, distribution or modification of this file, in whole
* and in part, is strictly prohibited without the prior written
* consent from Mirocom Laboratories.
*/
#ifndef _SYS_STDARG_H_
#define _SYS_STDARG_H_ 1
#ifndef __GNUC_VA_LIST
#define __GNUC_VA_LIST
typedef __builtin_va_list __gnuc_va_list;
#endif /* __GNUC_VA_LIST */
typedef __gnuc_va_list va_list;
#define va_start(ap, last) __builtin_va_start((ap), last)
#define va_end(ap) __builtin_va_end((ap))
#define va_arg(ap, type) __builtin_va_arg((ap), type)
#endif /* !_SYS_STDARG_H_ */
+28
View File
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2026, Mirocom Laboratories
* All rights reserved.
*
* The following sources are CONFIDENTIAL and PROPRIETARY
* property of Mirocom Laboratories. Unauthorized copying,
* use, distribution or modification of this file, in whole
* and in part, is strictly prohibited without the prior written
* consent from Mirocom Laboratories.
*/
#ifndef _STDBOOL_H_ 1
#define _STDBOOL_H_ 1
#ifndef _HAVE_bool
#define _HAVE_bool
typedef _Bool bool;
#ifndef true
#define true 1
#endif /* !true */
#ifndef false
#define false 0
#endif /* !false */
#endif /* !_HAVE_bool */
#endif /* !_STDBOOL_H_ */
+25
View File
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2026, Mirocom Laboratories
* All rights reserved.
*
* The following sources are CONFIDENTIAL and PROPRIETARY
* property of Mirocom Laboratories. Unauthorized copying,
* use, distribution or modification of this file, in whole
* and in part, is strictly prohibited without the prior written
* consent from Mirocom Laboratories.
*/
#ifndef _SYS__NULL_H_
#define _SYS__NULL_H_ 1
#if !defined(__cplusplus)
#define NULL ((void *)0)
#else
#if __cplusplus >= 201103L
#define NULL nullptr
#else
#define NULL ((void *)0)
#endif /* __cplusplus >= 201103L */
#endif /* __cplusplus */
#endif /* !_SYS_NULL_H_ */
+24
View File
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2026, Mirocom Laboratories
* All rights reserved.
*
* The following sources are CONFIDENTIAL and PROPRIETARY
* property of Mirocom Laboratories. Unauthorized copying,
* use, distribution or modification of this file, in whole
* and in part, is strictly prohibited without the prior written
* consent from Mirocom Laboratories.
*/
#ifndef _SYS_CDEFS_H_
#define _SYS_CDEFS_H_ 1
#define __asmv __asm__ __volatile__
#define __attr(x) __attribute__((x))
#define __section(x) __attr(section((x)))
#define __align(n) __attr(aligned((n)))
#define __packed __attr(packed)
#define __no_return __attr(noreturn)
#define __always_inline __attr(always_inline)
#define __barrier() __asmv("" ::: "memory")
#endif /* !_SYS_CDEFS_H_ */
+39
View File
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2026, Mirocom Laboratories
* All rights reserved.
*
* The following sources are CONFIDENTIAL and PROPRIETARY
* property of Mirocom Laboratories. Unauthorized copying,
* use, distribution or modification of this file, in whole
* and in part, is strictly prohibited without the prior written
* consent from Mirocom Laboratories.
*/
#ifndef _SYS_PARAM_H_
#define _SYS_PARAM_H_ 1
/* Pointer offset macros */
#define PTR_OFFSET(p, off) ((void *)(char *)(p) + (off))
#define PTR_NOFFSET(p, off) ((void *)(char *)(p) - (off))
/* Bit related macros */
#define BIT(n) (1 << (n))
#define ISSET(v, f) ((v) & (f))
/* Align up/down a value */
#define ALIGN_DOWN(value, align) ((value) & ~((align)-1))
#define ALIGN_UP(value, align) (((value) + (align)-1) & ~((align)-1))
/* Bitmap helper macros */
#define SETBIT(a, b) ((a)[(b) >> 3] |= BIT(b % 8))
#define CLRBIT(a, b) ((a)[(b) >> 3] &= ~BIT(b % 8))
#define TESTBIT(a, b) (ISSET((a)[(b) >> 3], BIT(b % 8)))
/* Min/max macros */
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
/* Get number of array elements */
#define NELEM(a) (sizeof(a) / sizeof(a[0]))
#endif /* !_SYS_PARAM_H_ */
+101
View File
@@ -0,0 +1,101 @@
/*
* Copyright (c) 2026, Mirocom Laboratories
* All rights reserved.
*
* The following sources are CONFIDENTIAL and PROPRIETARY
* property of Mirocom Laboratories. Unauthorized copying,
* use, distribution or modification of this file, in whole
* and in part, is strictly prohibited without the prior written
* consent from Mirocom Laboratories.
*/
#ifndef _SYS_TYPES_H_
#define _SYS_TYPES_H_ 1
#if defined(_KERNEL) || defined(_SP1_SOURCE)
#include <sys/_null.h>
#ifndef bool
typedef _Bool bool;
#endif /* !bool */
#ifndef true
#define true 1
#endif /* !true */
#ifndef false
#define false 0
#endif /* !false */
#endif /* !_KERNEL || SP1_SOURCE */
/* Unsigned types */
typedef unsigned char __uint8_t;
typedef unsigned short __uint16_t;
typedef unsigned int __uint32_t;
typedef unsigned long long __uint64_t;
typedef __uint64_t __size_t;
typedef __uint64_t __uintptr_t;
/* Signed types */
typedef int __int8_t;
typedef short __int16_t;
typedef int __int32_t;
typedef long long __int64_t;
typedef __int64_t __ssize_t;
typedef __ssize_t __off_t;
#if defined(_KERNEL) || defined(SP1_SOURCE)
#ifndef uint8_t
typedef __uint8_t uint8_t;
#endif /* !uint8_t */
#ifndef uint16_t
typedef __uint16_t uint16_t;
#endif /* !uint16_t */
#ifndef uint32_t
typedef __uint32_t uint32_t;
#endif /* !uint32_t */
#ifndef uint64_t
typedef __uint64_t uint64_t;
#endif /* !uint64_t */
#ifndef uintptr_t
typedef __uint64_t uintptr_t;
#endif /* !uintptr_t */
#ifndef size_t
typedef __size_t size_t;
#endif /* !size_t */
#ifndef int8_t
typedef __int8_t int8_t;
#endif /* !int8_t */
#ifndef int16_t
typedef __int16_t int16_t;
#endif /* !int16_t */
#ifndef int16_t
typedef __int32_t int32_t;
#endif /* !int32_t */
#ifndef int64_t
typedef __int64_t int64_t;
#endif /* !int64_t */
#ifndef ssize_t
typedef __ssize_t ssize_t;
#endif /* !ssize_t */
#ifndef intmax_t
typedef __ssize_t intmax_t;
#endif /* !intmax_t */
#endif /* !_KERNEL || _SP1_SOURCE */
typedef int pid_t;
#endif /* !_SYS_TYPES_H_ */
+19
View File
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2026, Mirocom Laboratories
* All rights reserved.
*
* The following sources are CONFIDENTIAL and PROPRIETARY
* property of Mirocom Laboratories. Unauthorized copying,
* use, distribution or modification of this file, in whole
* and in part, is strictly prohibited without the prior written
* consent from Mirocom Laboratories.
*/
#ifndef _SYS_UNITS_H_
#define _SYS_UNITS_H_ 1
/* Storage size units */
#define UNIT_GIB 0x40000000
#define UNIT_MIB 0x100000
#endif /* !_SYS_UNITS_H_ */