From 2bf851de6dd3a64f91a72a9afba2b3637dbbe154 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 4 Dec 2025 19:25:47 +0100 Subject: First commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libj2.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 libj2.h (limited to 'libj2.h') diff --git a/libj2.h b/libj2.h new file mode 100644 index 0000000..0c3d882 --- /dev/null +++ b/libj2.h @@ -0,0 +1,62 @@ +/* See LICENSE file for copyright and license details. */ +#ifndef LIBJ2_H +#define LIBJ2_H + +#include +#include +#include + +#if 1 +# if defined(__GNUC__) +# define LIBJ2_USE_GCC_INTRINSIC_FUNCTIONS_ +# endif +#endif + + +/** + * The number of bits in an `uintmax_t` + */ +#define LIBJ2_JU_BIT ((unsigned)CHAR_BIT * (unsigned)sizeof(uintmax_t)) + +/** + * The number of bits in an `struct libj2_j2u` + */ +#define LIBJ2_J2U_BIT (2U * LIBJ2_JU_BIT) + + +/** + * Unsigned double-maximum precision integer + * + * If `uintmax_t` is a 64-bit type, this `struct` is a 128-bit type + */ +struct libj2_j2u { + /** + * Most significant half + */ + uintmax_t high; + + /** + * Least significant half + */ + uintmax_t low; +}; + + +#include "libj2/constants.h" +#include "libj2/signum.h" +#include "libj2/constructors.h" +#include "libj2/unsigned-comparsion.h" +#include "libj2/bitwise-logic.h" +#include "libj2/bit-shifting.h" +#include "libj2/sign-shifting.h" +#include "libj2/addition.h" +#include "libj2/subtraction.h" +#include "libj2/multiplication.h" +#include "libj2/division.h" + + +#if defined(LIBJ2_USE_GCC_INTRINSIC_FUNCTIONS_) +# undef LIBJ2_USE_GCC_INTRINSIC_FUNCTIONS_ +#endif + +#endif -- cgit v1.2.3-70-g09d2