Author | Jamozed <[email protected]> |
Date | 2021-12-08 00:58:05 |
Commit | 359885de5b31e33b98e5d73e284ffb8836144966 |
Parent | 1e6cded1c9d82af2053cdcb7c34aa3d92065392f |
util: Add util.h
Diffstat
A | src/util.h | | | 92 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h new file mode 100644 index 0000000..3b3d167 --- /dev/null +++ b/src/util.h @@ -0,0 +1,92 @@ +// util/util.h, version 1.0.0 +// Utility header file from libutil +// Copyright (C) 2021, Jakob Wakeling +// All rights reserved. + +/* +OMKOV Permissive Licence, version 1.0 + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimers. +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimers in the documentation and/or + other materials provided with the distribution. +* Neither the names of the copyright holders, nor the names of its contributors + may be used to endorse or promote products derived from this Software without + specific prior written permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT +HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. +*/ + +#ifndef UTIL_UTIL_H_KP8NS9DC +#define UTIL_UTIL_H_KP8NS9DC + +#include <assert.h> +#include <float.h> +#include <stdbool.h> +#include <stddef.h> +#include <stdint.h> + +/* Type Definitions */ +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; +typedef uintptr_t UINT; + +typedef int8_t s8; +typedef int16_t s16; +typedef int32_t s32; +typedef int64_t s64; +typedef intptr_t sint; + +typedef float f32; +typedef double f64; +typedef long double f128; + +/* Type Limits */ +#define U8_MIN UINT8_MIN +#define U8_MAX UINT8_MAX +#define U16_MIN UINT16_MIN +#define U16_MAX UINT16_MAX +#define U32_MIN UINT32_MIN +#define U32_MAX UINT32_MAX +#define U64_MIN UINT64_MIN +#define U64_MAX UINT64_MAX +#define UINT_MIN UINTPTR_MIN +#define UINT_MAX UINTPTR_MAX + +#define S8_MIN INT8_MIN +#define S8_MAX INT8_MAX +#define S16_MIN INT16_MIN +#define S16_MAX INT16_MAX +#define S32_MIN INT32_MIN +#define S32_MAX INT32_MAX +#define S64_MIN INT64_MIN +#define S64_MAX INT64_MAX +#define SINT_MIN INTPTR_MIN +#define SINT_MAX INTPTR_MAX + +#define F32_MIN FLT_MIN +#define F32_MAX FLT_MAX +#define F64_MIN DBL_MIN +#define F64_MAX DBL_MAX +#define F128_MIN LDBL_MIN +#define F128_MAX LDBL_MAX + +/* Miscellaneous */ +#define BIT(x) (1 << (x)) + +#endif // UTIL_UTIL_H_KP8NS9DC