Add big integer implementation

This commit is contained in:
2024-06-16 12:29:48 +03:00
parent 9642630dd1
commit 4c77ce8fe3
6 changed files with 2165 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
#ifndef BH_INTERNAL_BIGINT_H
#define BH_INTERNAL_BIGINT_H
#include "bh.h"
#include <bh/bigint.h>
#if defined(BH_BIGINT_LONG)
#define BH_BIGINT_BITS 31
#define BH_BIGINT_MASK 0x7FFFFFFF
#define BH_BIGINT_TYPE bh_uint32_t
#define BH_BIGINT_TMP bh_uint64_t
#else
#define BH_BIGINT_BITS 15
#define BH_BIGINT_MASK 0x7FFF
#define BH_BIGINT_TYPE bh_uint16_t
#define BH_BIGINT_TMP bh_uint32_t
#endif
struct bh_bigint_s
{
BH_BIGINT_TYPE *data;
size_t size;
size_t capacity;
int type;
int error;
};
void bh_bigint_init(bh_bigint_t *bigint);
void bh_bigint_destroy(bh_bigint_t *bigint);
#endif /* BH_INTERNAL_BIGINT_H */

View File

@@ -1,6 +1,7 @@
#ifndef BH_INTERNAL_CONFIG_H
#define BH_INTERNAL_CONFIG_H
#cmakedefine BH_BIGINT_LONG
#cmakedefine BH_THREADS_WINXP
#endif /* BH_INTERNAL_CONFIG_H */