diff options
| author | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2022-04-24 04:02:50 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-24 13:02:50 +0200 |
| commit | 589cc12296ae7253c62655859a5eef92ee42dbaf (patch) | |
| tree | dd8556994b43ed23dff2aed6bb4c019e5c0d7ec9 /include | |
| parent | a1099217d65362f16dd90284670a7dd37702a3ca (diff) | |
some MSL_C work (#192)
* wip
* bunch of MSL_C files
thanks to pikmin2 decomp for their work
* format / asm
* progress
* fix
* fix remove-asm to work with C files
* init / start
Diffstat (limited to 'include')
| -rw-r--r-- | include/DynamicLink.h | 4 | ||||
| -rw-r--r-- | include/JSystem/J2DGraph/J2DMatBlock.h | 25 | ||||
| -rw-r--r-- | include/JSystem/J2DGraph/J2DMaterial.h | 1 | ||||
| -rw-r--r-- | include/JSystem/J2DGraph/J2DScreen.h | 4 | ||||
| -rw-r--r-- | include/JSystem/JKernel/JKRArchive.h | 2 | ||||
| -rw-r--r-- | include/JSystem/JKernel/JKRFileLoader.h | 2 | ||||
| -rw-r--r-- | include/JSystem/JSupport/JSUMemoryStream.h | 4 | ||||
| -rw-r--r-- | include/MSL_C/MSL_Common/Src/ansi_files.h | 65 | ||||
| -rw-r--r-- | include/MSL_C/MSL_Common/Src/char_io.h | 10 | ||||
| -rw-r--r-- | include/MSL_C/MSL_Common/Src/ctype.h | 8 | ||||
| -rw-r--r-- | include/MSL_C/MSL_Common/Src/float.h | 1 | ||||
| -rw-r--r-- | include/MSL_C/MSL_Common/Src/mem.h | 10 | ||||
| -rw-r--r-- | include/MSL_C/MSL_Common/Src/printf.h | 18 | ||||
| -rw-r--r-- | include/MSL_C/MSL_Common/Src/string.h | 10 | ||||
| -rw-r--r-- | include/MSL_C/math.h | 74 | ||||
| -rw-r--r-- | include/Runtime.PPCEABI.H/__va_arg.h | 16 | ||||
| -rw-r--r-- | include/dol2asm.h | 25 | ||||
| -rw-r--r-- | include/errno.h (renamed from include/MSL_C/MSL_Common/Src/errno.h) | 2 | ||||
| -rw-r--r-- | include/fdlibm.h | 228 |
19 files changed, 412 insertions, 97 deletions
diff --git a/include/DynamicLink.h b/include/DynamicLink.h index a8905be76d..42c86a1e7c 100644 --- a/include/DynamicLink.h +++ b/include/DynamicLink.h @@ -14,7 +14,7 @@ struct DynamicModuleControlBase { /* 0x0C */ /*vtable*/ /* 802621CC */ virtual ~DynamicModuleControlBase(); - /* 800188DC */ virtual const char* getModuleName() const {return NULL;}; + /* 800188DC */ virtual const char* getModuleName() const { return NULL; }; /* 80263210 */ virtual int getModuleSize() const; /* 80263200 */ virtual const char* getModuleTypeString() const; /* 80262470 */ virtual void dump(); @@ -43,7 +43,7 @@ struct DynamicModuleControl : DynamicModuleControlBase { /* 80263218 */ virtual const char* getModuleName() const; /* 80263000 */ virtual int getModuleSize() const; /* 80263070 */ virtual const char* getModuleTypeString() const; - //virtual void dump(); + // virtual void dump(); /* 80262C0C */ virtual void dump2(); /* 802627E8 */ virtual bool do_load(); /* 80262AFC */ virtual BOOL do_load_async(); diff --git a/include/JSystem/J2DGraph/J2DMatBlock.h b/include/JSystem/J2DGraph/J2DMatBlock.h index 5b80a90f18..f2e20854d8 100644 --- a/include/JSystem/J2DGraph/J2DMatBlock.h +++ b/include/JSystem/J2DGraph/J2DMatBlock.h @@ -422,21 +422,18 @@ struct J2DBlendInfo { mType = other.mType; mSrcFactor = other.mSrcFactor; mDstFactor = other.mDstFactor; - //mOp = other.mOp; + // mOp = other.mOp; } /* 0x0 */ u8 mType; /* 0x1 */ u8 mSrcFactor; /* 0x2 */ u8 mDstFactor; - }; extern J2DBlendInfo j2dDefaultBlendInfo; struct J2DBlend { - J2DBlend() { - mBlendInfo = j2dDefaultBlendInfo; - } + J2DBlend() { mBlendInfo = j2dDefaultBlendInfo; } /* 0x0 */ J2DBlendInfo mBlendInfo; /* 0x3 */ u8 mOp; @@ -444,9 +441,7 @@ struct J2DBlend { class J2DPEBlock { public: - J2DPEBlock() { - initialize(); - } + J2DPEBlock() { initialize(); } /* 802F17FC */ void initialize(); /* 802F1840 */ void setGX(); @@ -475,10 +470,8 @@ public: class J2DIndBlockFull : public J2DIndBlock { public: - J2DIndBlockFull() { - initialize(); - } - + J2DIndBlockFull() { initialize(); } + /* 802F1664 */ virtual void initialize(); /* 802F1730 */ virtual void setGX(); /* 802F1B94 */ virtual void getType(); @@ -515,9 +508,7 @@ private: /* 0x24 */ J2DTexMtx* mTexMtx[8]; public: - J2DTexGenBlock() { - initialize(); - } + J2DTexGenBlock() { initialize(); } /* 802EB510 */ void initialize(); /* 802EB570 */ void setGX(); @@ -547,9 +538,7 @@ private: /* 0x12 */ u8 mCullMode; public: - J2DColorBlock() { - initialize(); - } + J2DColorBlock() { initialize(); } /* 802EB394 */ void initialize(); /* 802EB424 */ void setGX(); diff --git a/include/JSystem/J2DGraph/J2DMaterial.h b/include/JSystem/J2DGraph/J2DMaterial.h index fbf30353d0..ebea34bec8 100644 --- a/include/JSystem/J2DGraph/J2DMaterial.h +++ b/include/JSystem/J2DGraph/J2DMaterial.h @@ -42,7 +42,6 @@ public: J2DTevBlock* getTevBlock() { return mTevBlock; } J2DIndBlock* getIndBlock() { return mIndBlock; } - private: /* 0x04 */ int field_0x4; /* 0x08 */ int field_0x8; diff --git a/include/JSystem/J2DGraph/J2DScreen.h b/include/JSystem/J2DGraph/J2DScreen.h index 3ba1f4499c..a878d07f57 100644 --- a/include/JSystem/J2DGraph/J2DScreen.h +++ b/include/JSystem/J2DGraph/J2DScreen.h @@ -50,9 +50,9 @@ public: /* 802F9A74 */ virtual void setAnimationVF(J2DAnmVisibilityFull*); /* 802F9A78 */ virtual void setAnimationVC(J2DAnmVtxColor*); /* 802F99E8 */ virtual J2DPane* createPane(J2DScrnBlockHeader const&, JSURandomInputStream*, - J2DPane*, u32); + J2DPane*, u32); /* 802F8B98 */ virtual J2DPane* createPane(J2DScrnBlockHeader const&, JSURandomInputStream*, - J2DPane*, u32, JKRArchive*); + J2DPane*, u32, JKRArchive*); /* 802F8498 */ J2DScreen(); /* 802F85A8 */ void clean(); diff --git a/include/JSystem/JKernel/JKRArchive.h b/include/JSystem/JKernel/JKRArchive.h index edd694ea7e..47a8c1bc25 100644 --- a/include/JSystem/JKernel/JKRArchive.h +++ b/include/JSystem/JKernel/JKRArchive.h @@ -219,7 +219,7 @@ inline JKRCompression JKRConvertAttrToCompressionType(u32 attr) { } inline void* JKRGetResource(u32 node, const char* path, JKRArchive* archive) { - return JKRArchive::getGlbResource(node,path,archive); + return JKRArchive::getGlbResource(node, path, archive); } inline void* JKRGetTypeResource(u32 tag, const char* name, JKRArchive* arc) { diff --git a/include/JSystem/JKernel/JKRFileLoader.h b/include/JSystem/JKernel/JKRFileLoader.h index 42752bc241..b0e3250c03 100644 --- a/include/JSystem/JKernel/JKRFileLoader.h +++ b/include/JSystem/JKernel/JKRFileLoader.h @@ -55,7 +55,7 @@ public: }; inline bool JKRDetachResource(void* resource, JKRFileLoader* fileLoader) { - return JKRFileLoader::detachResource(resource,fileLoader); + return JKRFileLoader::detachResource(resource, fileLoader); } inline void* JKRGetNameResource(const char* name, JKRFileLoader* loader) { diff --git a/include/JSystem/JSupport/JSUMemoryStream.h b/include/JSystem/JSupport/JSUMemoryStream.h index ca69f91472..aa8c84480f 100644 --- a/include/JSystem/JSupport/JSUMemoryStream.h +++ b/include/JSystem/JSupport/JSUMemoryStream.h @@ -6,9 +6,7 @@ class JSUMemoryInputStream : JSURandomInputStream { public: - JSUMemoryInputStream(const void* res, u32 size) { - setBuffer(res, size); - } + JSUMemoryInputStream(const void* res, u32 size) { setBuffer(res, size); } /* 802552B8 */ ~JSUMemoryInputStream() {} /* 802DC520 */ void setBuffer(void const*, s32); diff --git a/include/MSL_C/MSL_Common/Src/ansi_files.h b/include/MSL_C/MSL_Common/Src/ansi_files.h index 684a827853..b16eccd5ef 100644 --- a/include/MSL_C/MSL_Common/Src/ansi_files.h +++ b/include/MSL_C/MSL_Common/Src/ansi_files.h @@ -1,39 +1,66 @@ #ifndef MSL_COMMON_SRC_ANSI_FILES_H #define MSL_COMMON_SRC_ANSI_FILES_H -#include "dolphin/types.h" +enum __file_kinds { + /* 0x0 */ CLOSED_FILE, + /* 0x1 */ DISK_FILE, + /* 0x2 */ CONSOLE_FILE, + /* 0x3 */ UNAVAILABLE_FILE, +}; + +enum __file_orientation { + /* 0x0 */ UNORIENTED, + /* 0x1 */ CHAR_ORIENTED, + /* 0x2 */ WIDE_ORIENTED, +}; + +typedef struct _file_modes { + unsigned int open_mode : 2; + unsigned int io_mode : 3; + unsigned int buffer_mode : 2; + unsigned int file_kind : 3; + unsigned int file_orientation : 2; + unsigned int binary_io : 1; +} file_modes; -struct FILE { - /* 0x00 */ u32 handle; - /* 0x04 */ u32 file_mode; - /* 0x08 */ u32 file_state; - /* 0x0C */ u8 flag; +typedef struct _file_states { + unsigned int io_state : 3; + unsigned int free_buffer : 1; + unsigned char eof; + unsigned char error; +} file_states; + +typedef struct _FILE { + /* 0x00 */ unsigned int handle; + /* 0x04 */ file_modes file_mode; + /* 0x08 */ file_states file_state; + /* 0x0C */ unsigned char flag; /* 0x0D */ char char_buffer; /* 0x0E */ char char_buffer_2; /* 0x0F */ char ungetc_buffer[2]; - /* 0x12 */ u16 ungetc_wide_buffer[2]; - /* 0x18 */ u32 position; - /* 0x1C */ u8* buffer; - /* 0x20 */ u32 buffer_size; - /* 0x24 */ u8* buffer_ptr; - /* 0x28 */ u32 buffer_length; - /* 0x2C */ u32 buffer_alignment; - /* 0x30 */ u32 buffer_length2; - /* 0x34 */ u32 buffer_position; + /* 0x12 */ unsigned short ungetc_wide_buffer[2]; + /* 0x18 */ unsigned int position; + /* 0x1C */ unsigned char* buffer; + /* 0x20 */ unsigned int buffer_size; + /* 0x24 */ unsigned char* buffer_ptr; + /* 0x28 */ unsigned int buffer_length; + /* 0x2C */ unsigned int buffer_alignment; + /* 0x30 */ unsigned int buffer_length2; + /* 0x34 */ unsigned int buffer_position; /* 0x38 */ void* position_fn; /* 0x3C */ void* read_fn; /* 0x40 */ void* write_fn; /* 0x44 */ void* close_fn; /* 0x48 */ void* unknown; - /* 0x4C */ struct FILE* next_file; -}; + /* 0x4C */ struct _FILE* next_file; +} FILE; -struct files { +typedef struct _files { FILE stdin; FILE stdout; FILE stderr; FILE empty; -}; +} files; extern files __files; diff --git a/include/MSL_C/MSL_Common/Src/char_io.h b/include/MSL_C/MSL_Common/Src/char_io.h index 7363bc22cd..4a6e04cce9 100644 --- a/include/MSL_C/MSL_Common/Src/char_io.h +++ b/include/MSL_C/MSL_Common/Src/char_io.h @@ -4,6 +4,14 @@ #include "MSL_C/MSL_Common/Src/ansi_files.h" #include "dolphin/types.h" -extern "C" int fputs(const char*, FILE*); +#ifdef __cplusplus +extern "C" { +#endif + +int fputs(const char*, FILE*); + +#ifdef __cplusplus +} +#endif #endif /* MSL_COMMON_SRC_CHAR_IO_H */ diff --git a/include/MSL_C/MSL_Common/Src/ctype.h b/include/MSL_C/MSL_Common/Src/ctype.h index f59c75d820..100460e708 100644 --- a/include/MSL_C/MSL_Common/Src/ctype.h +++ b/include/MSL_C/MSL_Common/Src/ctype.h @@ -3,8 +3,14 @@ #include "dolphin/types.h" +#ifdef __cplusplus extern "C" { +#endif + int tolower(int); -}; + +#ifdef __cplusplus +} +#endif #endif /* MSL_COMMON_SRC_CTYPE_H */ diff --git a/include/MSL_C/MSL_Common/Src/float.h b/include/MSL_C/MSL_Common/Src/float.h index 9a39ae5743..a41c15e2f3 100644 --- a/include/MSL_C/MSL_Common/Src/float.h +++ b/include/MSL_C/MSL_Common/Src/float.h @@ -14,6 +14,7 @@ #define fpclassify(x) ((sizeof(x) == sizeof(float)) ? __fpclassifyf(x) : __fpclassifyd(x)) #define signbit(x) ((sizeof(x) == sizeof(float)) ? __signbitf(x) : __signbitd(x)) +#define isfinite(x) ((fpclassify(x) > 2)) #define __signbitf(x) ((*(u8*)&(x)) & 0x80) diff --git a/include/MSL_C/MSL_Common/Src/mem.h b/include/MSL_C/MSL_Common/Src/mem.h index e47536e0b7..73edb308ee 100644 --- a/include/MSL_C/MSL_Common/Src/mem.h +++ b/include/MSL_C/MSL_Common/Src/mem.h @@ -3,6 +3,14 @@ #include "dolphin/types.h" -extern "C" int memcmp(const void*, const void*, size_t); +#ifdef __cplusplus +extern "C" { +#endif + +int memcmp(const void*, const void*, size_t); + +#ifdef __cplusplus +} +#endif #endif /* MSL_COMMON_SRC_MEM_H */ diff --git a/include/MSL_C/MSL_Common/Src/printf.h b/include/MSL_C/MSL_Common/Src/printf.h index 206517c803..e8cfdf2814 100644 --- a/include/MSL_C/MSL_Common/Src/printf.h +++ b/include/MSL_C/MSL_Common/Src/printf.h @@ -4,10 +4,18 @@ #include "Runtime.PPCEABI.H/__va_arg.h" #include "dolphin/types.h" -extern "C" size_t sprintf(const char*, const char*, ...); -extern "C" size_t snprintf(const char*, size_t, const char*, ...); -extern "C" size_t vsnprintf(char*, size_t, const char*, va_list); -extern "C" size_t vprintf(const char*, va_list); -extern "C" size_t printf(const char*, ...); +#ifdef __cplusplus +extern "C" { +#endif + +size_t sprintf(const char*, const char*, ...); +size_t snprintf(const char*, size_t, const char*, ...); +size_t vsnprintf(char*, size_t, const char*, va_list); +size_t vprintf(const char*, va_list); +size_t printf(const char*, ...); + +#ifdef __cplusplus +} +#endif #endif /* MSL_COMMON_SRC_PRINTF_H */ diff --git a/include/MSL_C/MSL_Common/Src/string.h b/include/MSL_C/MSL_Common/Src/string.h index 38c7f3e7ea..c70f319597 100644 --- a/include/MSL_C/MSL_Common/Src/string.h +++ b/include/MSL_C/MSL_Common/Src/string.h @@ -3,8 +3,11 @@ #include "dolphin/types.h" +#ifdef __cplusplus extern "C" { -void* memcpy(void*, const void*, s32); +#endif + +void* memcpy(void*, const void*, size_t); void* memset(void*, int, u32); char* strrchr(const char*, int); char* strchr(const char*, int); @@ -16,6 +19,9 @@ char* strcpy(char*, const char*); u32 strlen(const char*); int stricmp(const char*, const char*); -}; + +#ifdef __cplusplus +} +#endif #endif /* MSL_COMMON_SRC_STRING_H */ diff --git a/include/MSL_C/math.h b/include/MSL_C/math.h index 0de55c166d..478829c1f5 100644 --- a/include/MSL_C/math.h +++ b/include/MSL_C/math.h @@ -4,57 +4,60 @@ #include "MSL_C/MSL_Common/Src/float.h" #include "dolphin/types.h" +#ifdef __cplusplus extern "C" { -s32 abs(s32); -f64 acos(f64); -f32 acosf(f32); -f64 asin(f64); -f64 atan(f64); -f64 atan2(f64); -f64 ceil(f64); -f64 copysign(f64, f64); -f64 cos(f64); -f32 cosf(f32); -f64 exp(f64); +#endif + +int abs(int); +double acos(double); +float acosf(float); +double asin(double); +double atan(double); +double atan2(double, double); +double ceil(double); +double copysign(double, double); +double cos(double); +float cosf(float); +double exp(double); -extern f32 __fabsf(f32); -inline f64 fabs(f64 f) { +extern float __fabsf(float); +inline double fabs(double f) { return __fabsf(f); } -inline f64 fabsf2(f32 f) { +inline double fabsf2(float f) { return __fabsf(f); } -inline f32 fabsf(f32 f) { +inline float fabsf(float f) { return fabsf2(f); } -f64 floor(f64); -f64 fmod(f64, f64); -inline f32 fmodf(f32 f1, f32 f2) { +double floor(double); +double fmod(double, double); +inline float fmodf(float f1, float f2) { return fmod(f1, f2); } -f64 frexp(f64, s32*); -f64 ldexp(f64, s32); -f64 modf(f64, f64*); -f64 pow(f64, f64); -f64 sin(f64); -f32 sinf(f32); -f64 sqrt(f64); -f64 tan(f64); -f32 tanf(f32); +double frexp(double, int*); +double ldexp(double, int); +double modf(double, double*); +double pow(double, double); +double sin(double); +float sinf(float); +double sqrt(double); +double tan(double); +float tanf(float); -extern f32 __float_nan[4]; -extern f32 __float_epsilon[4]; -extern f32 __float_max[4]; +extern float __float_nan[4]; +extern float __float_epsilon[4]; +extern float __float_max[4]; -inline f64 sqrt_step(f64 tmpd, f32 mag) { +inline double sqrt_step(double tmpd, float mag) { return tmpd * 0.5 * (3.0 - mag * (tmpd * tmpd)); } -inline f32 sqrtf(f32 mag) { +inline float sqrtf(float mag) { if (mag > 0.0f) { - f64 tmpd = __frsqrte(mag); + double tmpd = __frsqrte(mag); tmpd = sqrt_step(tmpd, mag); tmpd = sqrt_step(tmpd, mag); tmpd = sqrt_step(tmpd, mag); @@ -67,6 +70,9 @@ inline f32 sqrtf(f32 mag) { return mag; } } -} + +#ifdef __cplusplus +}; +#endif #endif diff --git a/include/Runtime.PPCEABI.H/__va_arg.h b/include/Runtime.PPCEABI.H/__va_arg.h index 2091ed6fb8..f4ff105d98 100644 --- a/include/Runtime.PPCEABI.H/__va_arg.h +++ b/include/Runtime.PPCEABI.H/__va_arg.h @@ -3,15 +3,21 @@ #include "dolphin/types.h" -// not sure what the members are. -// OK when the struct is 12 bytes. typedef struct __va_list_struct { - u8 data[12]; -}; + char gpr; + char fpr; + char reserved[2]; + char* input_arg_area; + char* reg_save_area; +} _va_list_struct; -typedef __va_list_struct __va_list[1]; +typedef _va_list_struct __va_list[1]; +#ifdef __cplusplus extern "C" void __va_arg(void*, int); +#else +void __va_arg(void*, int); +#endif #if IN_VSCODE_EDITOR #define __builtin_va_info(...) diff --git a/include/dol2asm.h b/include/dol2asm.h index 928a022448..039cf0054c 100644 --- a/include/dol2asm.h +++ b/include/dol2asm.h @@ -3,6 +3,8 @@ // this helps remove useless error from the linter when using vscode. #ifndef IN_VSCODE_EDITOR + +#ifdef __cplusplus #define SECTION_INIT extern "C" __declspec(section ".init") #define SECTION_RODATA __declspec(section ".rodata") #define SECTION_DATA __declspec(section ".data") @@ -24,6 +26,29 @@ #define ALIGN_DECL(ALIGNMENT) __attribute__((aligned(ALIGNMENT))) #define REGISTER_CTORS(ADDR, FUNCTION) SECTION_CTORS void* const _ctors_##ADDR = (void*)(FUNCTION); #else +#define SECTION_INIT __declspec(section ".init") +#define SECTION_RODATA __declspec(section ".rodata") +#define SECTION_DATA __declspec(section ".data") +#define SECTION_SDATA __declspec(section ".sdata") +#define SECTION_SDATA2 __declspec(section ".sdata2") +#define SECTION_BSS __declspec(section ".data") +#define SECTION_SBSS __declspec(section ".sdata") +#define SECTION_SBSS2 __declspec(section ".sdata2") +#define SECTION_CTORS __declspec(section ".ctors") +#define SECTION_DTORS __declspec(section ".dtors") +#define SECTION_EXTAB __declspec(section "extab_") +#define SECTION_EXTABINDEX __declspec(section "extabindex_") +#define SECTION_DEAD __declspec(section ".dead") +#define SECTION_CTORS10 __declspec(section ".ctors$10") +#define SECTION_CTORS15 __declspec(section ".ctors$15") +#define SECTION_DTORS10 __declspec(section ".dtors$10") +#define SECTION_DTORS15 __declspec(section ".dtors$15") +#define COMPILER_STRIP_GATE(NAME, VALUE) SECTION_DEAD void* const cg_##NAME = (void*)(VALUE) +#define ALIGN_DECL(ALIGNMENT) __attribute__((aligned(ALIGNMENT))) +#define REGISTER_CTORS(ADDR, FUNCTION) SECTION_CTORS void* const _ctors_##ADDR = (void*)(FUNCTION); +#endif + +#else #define SECTION_INIT #define SECTION_RODATA #define SECTION_DATA diff --git a/include/MSL_C/MSL_Common/Src/errno.h b/include/errno.h index 4e3eb9a430..c7569bf20d 100644 --- a/include/MSL_C/MSL_Common/Src/errno.h +++ b/include/errno.h @@ -1,6 +1,6 @@ #ifndef MSL_COMMON_SRC_ERRNO_H #define MSL_COMMON_SRC_ERRNO_H -#include "dolphin/types.h" +extern int errno; #endif /* MSL_COMMON_SRC_ERRNO_H */ diff --git a/include/fdlibm.h b/include/fdlibm.h new file mode 100644 index 0000000000..9ad06deb19 --- /dev/null +++ b/include/fdlibm.h @@ -0,0 +1,228 @@ +#ifndef FDLIBM_H +#define FDLIBM_H + +/* @(#)fdlibm.h 1.5 04/04/22 */ +/* + * ==================================================== + * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. + * + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Sometimes it's necessary to define __LITTLE_ENDIAN explicitly + but these catch some common cases. */ + +#if defined(i386) || defined(i486) || defined(intel) || defined(x86) || defined(i86pc) || \ + defined(__alpha) || defined(__osf__) +#define __LITTLE_ENDIAN +#endif + +#ifdef __LITTLE_ENDIAN +#define __HI(x) *(1 + (int*)&x) +#define __LO(x) *(int*)&x +#define __HIp(x) *(1 + (int*)x) +#define __LOp(x) *(int*)x +#else +#define __HI(x) *(int*)&x +#define __LO(x) *(1 + (int*)&x) +#define __HIp(x) *(int*)x +#define __LOp(x) *(1 + (int*)x) +#endif + +// TODO: should __STDC__ actually be defined? +//#ifdef __STDC__ +#define __P(p) p +//#else +//#define __P(p) () +//#endif + +/* + * ANSI/POSIX + */ + +extern int signgam; + +#define MAXFLOAT ((float)3.40282346638528860e+38) + +enum fdversion { fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix }; + +#define _LIB_VERSION_TYPE enum fdversion +#define _LIB_VERSION _fdlib_version + +/* if global variable _LIB_VERSION is not desirable, one may + * change the following to be a constant by: + * #define _LIB_VERSION_TYPE const enum version + * In that case, after one initializes the value _LIB_VERSION (see + * s_lib_version.c) during compile time, it cannot be modified + * in the middle of a program + */ +extern _LIB_VERSION_TYPE _LIB_VERSION; + +#define _IEEE_ fdlibm_ieee +#define _SVID_ fdlibm_svid +#define _XOPEN_ fdlibm_xopen +#define _POSIX_ fdlibm_posix + +struct exception { + int type; + char* name; + double arg1; + double arg2; + double retval; +}; + +#define HUGE MAXFLOAT + +/* + * set X_TLOSS = pi*2**52, which is possibly defined in <values.h> + * (one may replace the following line by "#include <values.h>") + */ + +#define X_TLOSS 1.41484755040568800000e+16 + +#define DOMAIN 1 +#define SING 2 +#define OVERFLOW 3 +#define UNDERFLOW 4 +#define TLOSS 5 +#define PLOSS 6 + +/* + * ANSI/POSIX + */ +extern double acos __P((double)); +extern double asin __P((double)); +extern double atan __P((double)); +extern double atan2 __P((double, double)); +extern double cos __P((double)); +extern double sin __P((double)); +extern double tan __P((double)); + +extern double cosh __P((double)); +extern double sinh __P((double)); +extern double tanh __P((double)); + +extern double exp __P((double)); +extern double frexp __P((double, int*)); +extern double ldexp __P((double, int)); +extern double log __P((double)); +extern double log10 __P((double)); +extern double modf __P((double, double*)); + +extern double pow __P((double, double)); +extern double sqrt __P((double)); + +extern double ceil __P((double)); +extern double fabs __P((double)); +extern double floor __P((double)); +extern double fmod __P((double, double)); + +extern double erf __P((double)); +extern double erfc __P((double)); +extern double gamma __P((double)); +extern double hypot __P((double, double)); +extern int isnan __P((double)); +extern int finite __P((double)); +extern double j0 __P((double)); +extern double j1 __P((double)); +extern double jn __P((int, double)); +extern double lgamma __P((double)); +extern double y0 __P((double)); +extern double y1 __P((double)); +extern double yn __P((int, double)); + +extern double acosh __P((double)); +extern double asinh __P((double)); +extern double atanh __P((double)); +extern double cbrt __P((double)); +extern double logb __P((double)); +extern double nextafter __P((double, double)); +extern double remainder __P((double, double)); +#ifdef _SCALB_INT +extern double scalb __P((double, int)); +#else +extern double scalb __P((double, double)); +#endif + +extern int matherr __P((struct exception*)); + +/* + * IEEE Test Vector + */ +extern double significand __P((double)); + +/* + * Functions callable from C, intended to support IEEE arithmetic. + */ +extern double copysign __P((double, double)); +extern int ilogb __P((double)); +extern double rint __P((double)); +extern double scalbn __P((double, int)); + +/* + * BSD math library entry points + */ +extern double expm1 __P((double)); +extern double log1p __P((double)); + +/* + * Reentrant version of gamma & lgamma; passes signgam back by reference + * as the second argument; user must allocate space for signgam. + */ +#ifdef _REENTRANT +extern double gamma_r __P((double, int*)); +extern double lgamma_r __P((double, int*)); +#endif /* _REENTRANT */ + +/* ieee style elementary functions */ +extern double __ieee754_sqrt __P((double)); +extern double __ieee754_acos __P((double)); +extern double __ieee754_acosh __P((double)); +extern double __ieee754_log __P((double)); +extern double __ieee754_atanh __P((double)); +extern double __ieee754_asin __P((double)); +extern double __ieee754_atan2 __P((double, double)); +extern double __ieee754_exp __P((double)); +extern double __ieee754_cosh __P((double)); +extern double __ieee754_fmod __P((double, double)); +extern double __ieee754_pow __P((double, double)); +extern double __ieee754_lgamma_r __P((double, int*)); +extern double __ieee754_gamma_r __P((double, int*)); +extern double __ieee754_lgamma __P((double)); +extern double __ieee754_gamma __P((double)); +extern double __ieee754_log10 __P((double)); +extern double __ieee754_sinh __P((double)); +extern double __ieee754_hypot __P((double, double)); +extern double __ieee754_j0 __P((double)); +extern double __ieee754_j1 __P((double)); +extern double __ieee754_y0 __P((double)); +extern double __ieee754_y1 __P((double)); +extern double __ieee754_jn __P((int, double)); +extern double __ieee754_yn __P((int, double)); +extern double __ieee754_remainder __P((double, double)); +extern int __ieee754_rem_pio2 __P((double, double*)); +#ifdef _SCALB_INT +extern double __ieee754_scalb __P((double, int)); +#else +extern double __ieee754_scalb __P((double, double)); +#endif + +/* fdlibm kernel function */ +extern double __kernel_standard __P((double, double, int)); +extern double __kernel_sin __P((double, double, int)); +extern double __kernel_cos __P((double, double)); +extern double __kernel_tan __P((double, double, int)); +extern int __kernel_rem_pio2 __P((double*, double*, int, int, int, const int*)); + +#ifdef __cplusplus +}; +#endif + +#endif /* FDLIBM_H */
\ No newline at end of file |
