diff options
author | Ash Wolf <ninji@wuffs.org> | 2022-10-25 20:30:28 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2022-10-25 20:30:28 +0100 |
commit | d0b9848c54e6f85ab713f059dcd1ddef7e57caa6 (patch) | |
tree | 5bdb9dbf6c853780bc444dc92bf6f9fa3a95742a /includes/compiler/CInt64.h | |
parent | 685f22a6a0a5403c76316a2390c021a7b0f7597d (diff) | |
download | MWCC-d0b9848c54e6f85ab713f059dcd1ddef7e57caa6.tar.gz MWCC-d0b9848c54e6f85ab713f059dcd1ddef7e57caa6.zip |
a bunch of compiler stuff
Diffstat (limited to '')
-rw-r--r-- | includes/compiler/CInt64.h (renamed from CInt64.h) | 69 |
1 files changed, 36 insertions, 33 deletions
diff --git a/CInt64.h b/includes/compiler/CInt64.h index 37030f9..455bf3f 100644 --- a/CInt64.h +++ b/includes/compiler/CInt64.h @@ -1,9 +1,7 @@ -#pragma once +#ifndef COMPILER_CINT64_H +#define COMPILER_CINT64_H -typedef struct _CInt64 { - long a; - unsigned long b; -} CInt64; +#include "compiler/common.h" // make sure this is in the right place extern const CInt64 cint64_negone; @@ -13,23 +11,26 @@ extern const CInt64 cint64_max; extern const CInt64 cint64_min; inline int CInt64_IsNegative(const CInt64 *n) { - return (n->a & 0x80000000) != 0; + return (n->hi & 0x80000000) != 0; } -inline void CInt64_SetLong(CInt64 *pN, long n) { - pN->b = n; - pN->a = (n < 0) ? 0xFFFFFFFF : 0; +inline void CInt64_SetLong(CInt64 *pN, SInt32 n) { + pN->lo = n; + pN->hi = (n < 0) ? 0xFFFFFFFF : 0; } -inline void CInt64_SetULong(CInt64 *pN, unsigned long n) { - pN->b = n; - pN->a = 0; +inline void CInt64_SetULong(CInt64 *pN, UInt32 n) { + pN->lo = n; + pN->hi = 0; } -// i don't think this one is real lol inline int CInt64_IsZero(CInt64 *n) { - return n->a == 0 && n->b == 0; + //if (n->hi == 0 && n->lo == 0) + // return 1; + //else + // return 0; + return n->hi == 0 && n->lo == 0; } inline void CInt64_Extend32(CInt64 *n) { // assumed name - n->a = (n->b >> 31) ? 0xFFFFFFFF : 0; + n->hi = (n->lo >> 31) ? 0xFFFFFFFF : 0; } extern void CInt64_Init(); @@ -50,18 +51,18 @@ extern CInt64 CInt64_Shr(CInt64 lhs, CInt64 rhs); extern CInt64 CInt64_ShrU(CInt64 lhs, CInt64 rhs); extern int CInt64_UnsignedCompare(const CInt64 *lhs, const CInt64 *rhs); extern int CInt64_SignedCompare(const CInt64 *lhs, const CInt64 *rhs); -extern unsigned char CInt64_Less(CInt64 lhs, CInt64 rhs); -extern unsigned char CInt64_LessU(CInt64 lhs, CInt64 rhs); -extern unsigned char CInt64_Greater(CInt64 lhs, CInt64 rhs); -extern unsigned char CInt64_GreaterU(CInt64 lhs, CInt64 rhs); -extern unsigned char CInt64_LessEqual(CInt64 lhs, CInt64 rhs); -extern unsigned char CInt64_LessEqualU(CInt64 lhs, CInt64 rhs); -extern unsigned char CInt64_GreaterEqual(CInt64 lhs, CInt64 rhs); -extern unsigned char CInt64_GreaterEqualU(CInt64 lhs, CInt64 rhs); -extern unsigned char CInt64_Equal(CInt64 lhs, CInt64 rhs); -extern unsigned char CInt64_NotEqual(CInt64 lhs, CInt64 rhs); -extern unsigned char CInt64_IsInRange(CInt64 value, short len); -extern unsigned char CInt64_IsInURange(CInt64 value, short len); +extern Boolean CInt64_Less(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_LessU(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_Greater(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_GreaterU(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_LessEqual(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_LessEqualU(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_GreaterEqual(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_GreaterEqualU(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_Equal(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_NotEqual(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_IsInRange(CInt64 value, short len); +extern Boolean CInt64_IsInURange(CInt64 value, short len); extern CInt64 CInt64_And(CInt64 lhs, CInt64 rhs); extern CInt64 CInt64_Xor(CInt64 lhs, CInt64 rhs); extern CInt64 CInt64_Or(CInt64 lhs, CInt64 rhs); @@ -75,11 +76,13 @@ extern void CInt64_ConvertUFromLongDouble(CInt64 *pResult, double value); extern void CInt64_ConvertFromLongDouble(CInt64 *pResult, double value); extern double CInt64_ConvertUToLongDouble(const CInt64 *value); extern double CInt64_ConvertToLongDouble(const CInt64 *value); -extern char *CInt64_ScanOctString(CInt64 *pResult, char *str, unsigned char *pFail); -extern char *CInt64_ScanDecString(CInt64 *pResult, char *str, unsigned char *pFail); -extern char *CInt64_ScanHexString(CInt64 *pResult, char *str, unsigned char *pFail); -extern char *CInt64_ScanBinString(CInt64 *pResult, char *str, unsigned char *pFail); -extern char *CInt64_ScanAsmNumber(CInt64 *pResult, char *str, unsigned char *pFail); +extern char *CInt64_ScanOctString(CInt64 *pResult, char *str, Boolean *pFail); +extern char *CInt64_ScanDecString(CInt64 *pResult, char *str, Boolean *pFail); +extern char *CInt64_ScanHexString(CInt64 *pResult, char *str, Boolean *pFail); +extern char *CInt64_ScanBinString(CInt64 *pResult, char *str, Boolean *pFail); +extern char *CInt64_ScanAsmNumber(CInt64 *pResult, char *str, Boolean *pFail); extern int CInt64_PrintDec(char *output, CInt64 value); extern int CInt64_PrintHex(char *output, CInt64 value); -extern int CInt64_PrintBin(char *output, CInt64 value);
\ No newline at end of file +extern int CInt64_PrintBin(char *output, CInt64 value); + +#endif |