mirror of
https://github.com/encounter/tp.git
synced 2026-07-11 06:18:46 -07:00
msl_c mostly matching for wii/shield (#2994)
This commit is contained in:
@@ -4609,7 +4609,7 @@ PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/printf.c:
|
||||
.sdata2 start:0x80752ED0 end:0x80752ED8
|
||||
|
||||
PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/float.c:
|
||||
.sdata start:0x8074C238 end:0x8074C24C
|
||||
.sdata start:0x8074C238 end:0x8074C248
|
||||
|
||||
PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/scanf.c:
|
||||
.text start:0x80621C6C end:0x80623150
|
||||
@@ -4890,6 +4890,7 @@ TRK_MINNOW_DOLPHIN/debugger/embedded/MetroTRK/Os/dolphin/target_options.c:
|
||||
|
||||
NdevExi2AD/DebuggerDriver.c:
|
||||
.text start:0x8062ECBC end:0x8062F1EC
|
||||
.sdata start:0x8074C248 end:0x8074C24C
|
||||
.sbss start:0x8074D728 end:0x8074D73C
|
||||
|
||||
NdevExi2AD/exi2.c:
|
||||
|
||||
+5
-2
@@ -306,10 +306,13 @@ cflags_runtime = [
|
||||
"-str reuse,pool,readonly",
|
||||
"-common off",
|
||||
"-char signed",
|
||||
# "-inline deferred,auto"
|
||||
"-func_align 4",
|
||||
"-DMSL_USE_INLINES=1",
|
||||
]
|
||||
|
||||
if config.version not in ["ShieldD", "Shield"]:
|
||||
if config.version in ["RZDE01_00", "RZDE01_02", "RZDP01", "RZDJ01", "ShieldD", "Shield"]:
|
||||
cflags_runtime.extend(["-ipa file", "-fp_contract off"])
|
||||
else:
|
||||
cflags_runtime.extend(["-inline deferred,auto"])
|
||||
|
||||
cflags_trk = [
|
||||
|
||||
+2
-5
@@ -31,6 +31,8 @@
|
||||
#define DEBUG 0
|
||||
#endif
|
||||
|
||||
#define MSL_INLINE inline
|
||||
|
||||
#define ARRAY_SIZE(o) (s32)(sizeof(o) / sizeof(o[0]))
|
||||
#define ARRAY_SIZEU(o) (sizeof(o) / sizeof(o[0]))
|
||||
|
||||
@@ -87,11 +89,6 @@ void* __memcpy(void*, const void*, int);
|
||||
#define POINTER_ADD(ptr_, offset_) POINTER_ADD_TYPE(__typeof__(ptr_), ptr_, offset_)
|
||||
|
||||
// floating-point constants
|
||||
#define _HUGE_ENUF 1e+300
|
||||
#define INFINITY ((float)(_HUGE_ENUF * _HUGE_ENUF))
|
||||
#define HUGE_VAL ((double)INFINITY)
|
||||
#define HUGE_VALL ((long double)INFINITY)
|
||||
#define DOUBLE_INF HUGE_VAL
|
||||
static const float INF = 2000000000.0f;
|
||||
|
||||
// hack to make strings with no references compile properly
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JKernel/JKRFileLoader.h"
|
||||
|
||||
#define MSL_USE_INLINES 1 // needed to inline tolower call. not inlined elsewhere in the repo
|
||||
|
||||
#include "string.h"
|
||||
#include "ctype.h"
|
||||
#include "global.h"
|
||||
@@ -122,15 +125,7 @@ const char* JKRFileLoader::fetchVolumeName(char* buffer, s32 bufferSize, const c
|
||||
path++;
|
||||
while (*path != 0 && *path != '/') {
|
||||
if (1 < bufferSize) {
|
||||
int lower_char;
|
||||
int ch = (int)*path;
|
||||
if (ch == -1) {
|
||||
lower_char = -1;
|
||||
} else {
|
||||
lower_char = __lower_map[ch & 0xFF];
|
||||
}
|
||||
|
||||
*buffer = lower_char;
|
||||
*buffer = tolower(*path);
|
||||
buffer++;
|
||||
bufferSize--;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ typedef long long int64_t;
|
||||
typedef uint32_t uintptr_t;
|
||||
typedef int32_t intptr_t;
|
||||
|
||||
typedef long long intmax_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ enum __file_kinds {
|
||||
};
|
||||
|
||||
enum __file_orientation {
|
||||
/* 0x0 */ UNORIENTED,
|
||||
/* 0x1 */ CHAR_ORIENTED,
|
||||
/* 0x2 */ WIDE_ORIENTED,
|
||||
__unoriented,
|
||||
__char_oriented,
|
||||
__wide_oriented
|
||||
};
|
||||
|
||||
typedef struct _file_modes {
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
#define NAN (*(float*) __float_nan)
|
||||
#define HUGE_VALF (*(float*) __float_huge)
|
||||
|
||||
#if !PLATFORM_GCN
|
||||
#define HUGE_VAL (*(double*)__double_huge)
|
||||
#endif
|
||||
|
||||
#define M_PI 3.14159265358979323846f
|
||||
#define M_SQRT3 1.73205f
|
||||
|
||||
@@ -44,34 +48,65 @@ float sinf(float);
|
||||
double sqrt(double);
|
||||
double tan(double);
|
||||
float tanf(float);
|
||||
|
||||
inline float expf(float x) {
|
||||
return exp(x);
|
||||
}
|
||||
|
||||
inline float ceilf(float num) {
|
||||
return ceil(num);
|
||||
}
|
||||
double log10(double);
|
||||
|
||||
inline double fabs(double f) {
|
||||
return __fabs(f);
|
||||
}
|
||||
|
||||
inline float fabsf(float f) {
|
||||
return (float)fabs((double)f);
|
||||
inline long double fabsl(long double x) {
|
||||
return fabs((double)x);
|
||||
}
|
||||
|
||||
inline float floorf(float num) {
|
||||
|
||||
|
||||
MSL_INLINE float acosf(float x) {
|
||||
return acos(x);
|
||||
}
|
||||
|
||||
MSL_INLINE float atan2f(float y, float x) {
|
||||
return (float)atan2(y, x);
|
||||
}
|
||||
|
||||
MSL_INLINE float ceilf(float num) {
|
||||
return ceil(num);
|
||||
}
|
||||
|
||||
MSL_INLINE float cosf(float x) {
|
||||
return cos(x);
|
||||
}
|
||||
|
||||
MSL_INLINE float expf(float x) {
|
||||
return exp(x);
|
||||
}
|
||||
|
||||
MSL_INLINE float floorf(float num) {
|
||||
return floor(num);
|
||||
}
|
||||
|
||||
inline float fmodf(float f1, float f2) {
|
||||
MSL_INLINE float powf(float x, float y) {
|
||||
return pow(x, y);
|
||||
}
|
||||
|
||||
MSL_INLINE float sinf(float x) {
|
||||
return sin(x);
|
||||
}
|
||||
|
||||
MSL_INLINE float fabsf(float f) {
|
||||
return (float)fabs((double)f);
|
||||
}
|
||||
|
||||
MSL_INLINE float fmodf(float f1, float f2) {
|
||||
return fmod(f1, f2);
|
||||
}
|
||||
|
||||
MSL_INLINE float log10f(float x) {
|
||||
return log10(x);
|
||||
}
|
||||
|
||||
#include "global.h"
|
||||
#if PLATFORM_WII || PLATFORM_SHIELD
|
||||
inline float sqrtf(float mag) {
|
||||
MSL_INLINE float sqrtf(float mag) {
|
||||
return sqrt(mag);
|
||||
}
|
||||
#else
|
||||
@@ -87,7 +122,7 @@ inline float sqrtf(float mag) {
|
||||
static double _half = 0.5;
|
||||
static double _three = 3.0;
|
||||
#endif
|
||||
inline float sqrtf(float mag) {
|
||||
MSL_INLINE float sqrtf(float mag) {
|
||||
#ifndef DECOMPCTX
|
||||
// part of the same hack, these are defined outside of the function when using decompctx
|
||||
static const double _half = 0.5;
|
||||
@@ -110,15 +145,10 @@ inline float sqrtf(float mag) {
|
||||
}
|
||||
#endif
|
||||
|
||||
inline float atan2f(float y, float x) {
|
||||
return (float)atan2(y, x);
|
||||
MSL_INLINE float tanf(float x) {
|
||||
return tan(x);
|
||||
}
|
||||
|
||||
inline float sinf(float x) { return sin(x); }
|
||||
inline float cosf(float x) { return cos(x); }
|
||||
inline float tanf(float x) { return tan(x); }
|
||||
inline float acosf(float x) { return acos(x); }
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef _MSL_COMMON_CRITICAL_REGIONS_H
|
||||
#define _MSL_COMMON_CRITICAL_REGIONS_H
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -20,11 +22,17 @@ enum critical_regions {
|
||||
|
||||
void __init_critical_regions(void);
|
||||
void __kill_critical_regions(void);
|
||||
|
||||
#if PLATFORM_GCN
|
||||
void __begin_critical_region(int region);
|
||||
void __end_critical_region(int region);
|
||||
#else
|
||||
#define __begin_critical_region(region)
|
||||
#define __end_critical_region(region)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
#ifndef _MSL_COMMON_CTYPE_H
|
||||
#define _MSL_COMMON_CTYPE_H
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define EOF -1L
|
||||
|
||||
#if PLATFORM_GCN
|
||||
extern unsigned char __ctype_map[];
|
||||
extern unsigned char __lower_map[];
|
||||
extern unsigned char __upper_map[];
|
||||
@@ -28,19 +31,135 @@ extern unsigned char __upper_map[];
|
||||
#define __control (__motion_char | __control_char)
|
||||
#define __zero_fill(c) ((int)(unsigned char)(c))
|
||||
|
||||
int tolower(int);
|
||||
|
||||
inline int isalpha(int c) { return (int)(__ctype_map[(unsigned char)c] & __letter); }
|
||||
inline int isdigit(int c) { return (int)(__ctype_map[(unsigned char)c] & __digit); }
|
||||
inline int isspace(int c) { return (int)(__ctype_map[(unsigned char)c] & __whitespace); }
|
||||
inline int isupper(int c) { return (int)(__ctype_map[(unsigned char)c] & __upper_case); }
|
||||
inline int isxdigit(int c) { return (int)(__ctype_map[(unsigned char)c] & __hex_digit); }
|
||||
// added underscore to avoid naming conflicts
|
||||
inline int _tolower(int c) { return (c == -1 ? -1 : (int)__lower_map[(unsigned char)c]); }
|
||||
inline int toupper(int c) { return (c == -1 ? -1 : (int)__upper_map[(unsigned char)c]); }
|
||||
#else
|
||||
#include <locale.h>
|
||||
|
||||
extern const unsigned char __lower_mapC[0x100];
|
||||
extern const unsigned char __upper_mapC[0x100];
|
||||
extern const unsigned short __ctype_mapC[0x100];
|
||||
|
||||
#define ctype_alpha 0x0001
|
||||
#define ctype_blank 0x0002
|
||||
#define ctype_cntrl 0x0004
|
||||
#define ctype_digit 0x0008
|
||||
#define ctype_graph 0x0010
|
||||
#define ctype_lower 0x0020
|
||||
#define ctype_print 0x0040
|
||||
#define ctype_punct 0x0080
|
||||
#define ctype_space 0x0100
|
||||
#define ctype_upper 0x0200
|
||||
#define ctype_xdigit 0x0400
|
||||
|
||||
#define ctype_alnum (ctype_alpha | ctype_digit)
|
||||
|
||||
#endif
|
||||
|
||||
int tolower(int);
|
||||
|
||||
#if MSL_USE_INLINES
|
||||
MSL_INLINE int isalnum(int c) {
|
||||
#if !PLATFORM_GCN
|
||||
return (c < 0 || c >= 256) ? 0 : (int)(_current_locale.ctype_cmpt_ptr->ctype_map_ptr[c] & ctype_alnum);
|
||||
#endif
|
||||
}
|
||||
|
||||
MSL_INLINE int isalpha(int c) {
|
||||
#if PLATFORM_GCN
|
||||
return (int)(__ctype_map[(unsigned char)c] & __letter);
|
||||
#else
|
||||
return (c < 0 || c >= 256) ? 0 : (int)(_current_locale.ctype_cmpt_ptr->ctype_map_ptr[c] & ctype_alpha);
|
||||
#endif
|
||||
}
|
||||
|
||||
MSL_INLINE int isblank(int c) {
|
||||
#if !PLATFORM_GCN
|
||||
return (c < 0 || c >= 256) ? 0 : (int)(_current_locale.ctype_cmpt_ptr->ctype_map_ptr[c] & ctype_blank);
|
||||
#endif
|
||||
}
|
||||
|
||||
MSL_INLINE int iscntrl(int c) {
|
||||
#if !PLATFORM_GCN
|
||||
return (c < 0 || c >= 256) ? 0 : (int)(_current_locale.ctype_cmpt_ptr->ctype_map_ptr[c] & ctype_cntrl);
|
||||
#endif
|
||||
}
|
||||
|
||||
MSL_INLINE int isdigit(int c) {
|
||||
#if PLATFORM_GCN
|
||||
return (int)(__ctype_map[(unsigned char)c] & __digit);
|
||||
#else
|
||||
return (c < 0 || c >= 256) ? 0 : (int)(_current_locale.ctype_cmpt_ptr->ctype_map_ptr[c] & ctype_digit);
|
||||
#endif
|
||||
}
|
||||
|
||||
MSL_INLINE int isgraph(int c) {
|
||||
#if !PLATFORM_GCN
|
||||
return (c < 0 || c >= 256) ? 0 : (int)(_current_locale.ctype_cmpt_ptr->ctype_map_ptr[c] & ctype_graph);
|
||||
#endif
|
||||
}
|
||||
|
||||
MSL_INLINE int islower(int c) {
|
||||
#if !PLATFORM_GCN
|
||||
return (c < 0 || c >= 256) ? 0 : (int)(_current_locale.ctype_cmpt_ptr->ctype_map_ptr[c] & ctype_lower);
|
||||
#endif
|
||||
}
|
||||
|
||||
MSL_INLINE int isprint(int c) {
|
||||
#if !PLATFORM_GCN
|
||||
return (c < 0 || c >= 256) ? 0 : (int)(_current_locale.ctype_cmpt_ptr->ctype_map_ptr[c] & ctype_print);
|
||||
#endif
|
||||
}
|
||||
|
||||
MSL_INLINE int ispunct(int c) {
|
||||
#if !PLATFORM_GCN
|
||||
return (c < 0 || c >= 256) ? 0 : (int)(_current_locale.ctype_cmpt_ptr->ctype_map_ptr[c] & ctype_punct);
|
||||
#endif
|
||||
}
|
||||
|
||||
MSL_INLINE int isupper(int c) {
|
||||
#if PLATFORM_GCN
|
||||
return (int)(__ctype_map[(unsigned char)c] & __upper_case);
|
||||
#else
|
||||
return (c < 0 || c >= 256) ? 0 : (int)(_current_locale.ctype_cmpt_ptr->ctype_map_ptr[c] & ctype_upper);
|
||||
#endif
|
||||
}
|
||||
|
||||
MSL_INLINE int isxdigit(int c) {
|
||||
#if PLATFORM_GCN
|
||||
return (int)(__ctype_map[(unsigned char)c] & __hex_digit);
|
||||
#else
|
||||
return (c < 0 || c >= 256) ? 0 : (int)(_current_locale.ctype_cmpt_ptr->ctype_map_ptr[c] & ctype_xdigit);
|
||||
#endif
|
||||
}
|
||||
|
||||
MSL_INLINE int isspace(int c) {
|
||||
#if PLATFORM_GCN
|
||||
return (int)(__ctype_map[(unsigned char)c] & __whitespace);
|
||||
#else
|
||||
return (c < 0 || c >= 256) ? 0 : (int)(_current_locale.ctype_cmpt_ptr->ctype_map_ptr[c] & ctype_space);
|
||||
#endif
|
||||
}
|
||||
|
||||
MSL_INLINE int tolower(int c) {
|
||||
#if PLATFORM_GCN
|
||||
return (c == -1) ? -1 : (int) (__lower_map[(unsigned char)c]);
|
||||
#else
|
||||
return ((c < 0) || (c >= 0x100)) ? c : (int) (_current_locale.ctype_cmpt_ptr->lower_map_ptr[c]);
|
||||
#endif
|
||||
}
|
||||
|
||||
MSL_INLINE int toupper(int c) {
|
||||
#if PLATFORM_GCN
|
||||
return (c == -1 ? -1 : (int)__upper_map[(unsigned char)c]);
|
||||
#else
|
||||
return (c < 0 || c >= 256) ? c : (int)(&_current_locale)->ctype_cmpt_ptr->upper_map_ptr[c];
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _MSL_COMMON_CTYPE_H */
|
||||
#endif /* _MSL_COMMON_CTYPE_H */
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef MSL_COMMON_SRC_ERRNO_H
|
||||
#define MSL_COMMON_SRC_ERRNO_H
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define _MSL_COMMON_FLOAT_H
|
||||
|
||||
#include <fdlibm.h>
|
||||
#include "global.h"
|
||||
|
||||
#define FP_SNAN 0
|
||||
#define FP_QNAN 1
|
||||
@@ -22,6 +23,7 @@
|
||||
((sizeof(x) == sizeof(float)) ? __fpclassifyf((float)(x)) : \
|
||||
__fpclassifyd((double)(x)) )
|
||||
#endif
|
||||
|
||||
#define signbit(x) ((sizeof(x) == sizeof(float)) ? __signbitf(x) : __signbitd(x))
|
||||
#define isfinite(x) ((fpclassify(x) > FP_INFINITE))
|
||||
#define isnan(x) (fpclassify(x) == FP_NAN)
|
||||
@@ -37,6 +39,10 @@ extern int __float_huge[];
|
||||
extern int __float_max[];
|
||||
extern int __float_epsilon[];
|
||||
|
||||
#if !PLATFORM_GCN
|
||||
extern int __double_huge[];
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -108,4 +114,15 @@ int __fpclassifyl(long double __value);
|
||||
#define DBL_MAX_EXP 1024
|
||||
#define DBL_MAX_10_EXP 308
|
||||
|
||||
#define LDBL_MANT_DIG 53
|
||||
#define LDBL_DIG 15
|
||||
#define LDBL_MIN_EXP (-1021)
|
||||
#define LDBL_MIN_10_EXP (-308)
|
||||
#define LDBL_MAX_EXP 1024
|
||||
#define LDBL_MAX_10_EXP 308
|
||||
|
||||
#define LDBL_MAX 0x1.fffffffffffffP1023L
|
||||
#define LDBL_EPSILON 0x1.0000000000000P-52L
|
||||
#define LDBL_MIN 0x1.0000000000000P-1022L
|
||||
|
||||
#endif /* _MSL_COMMON_FLOAT_H */
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
#ifndef _MSL_LOCALE_H
|
||||
#define _MSL_LOCALE_H
|
||||
|
||||
#include <cstddef.h>
|
||||
|
||||
typedef int (*__decode_mbyte) (wchar_t*, const char*, size_t);
|
||||
typedef int (*__encode_mbyte) (char*, wchar_t);
|
||||
|
||||
struct lconv {
|
||||
char* decimal_point;
|
||||
char* thousands_sep;
|
||||
char* grouping;
|
||||
char* mon_decimal_point;
|
||||
char* mon_thousands_sep;
|
||||
char* mon_grouping;
|
||||
char* positive_sign;
|
||||
char* negative_sign;
|
||||
char* currency_symbol;
|
||||
char frac_digits;
|
||||
char p_cs_precedes;
|
||||
char n_cs_precedes;
|
||||
char p_sep_by_space;
|
||||
char n_sep_by_space;
|
||||
char p_sign_posn;
|
||||
char n_sign_posn;
|
||||
char* int_curr_symbol;
|
||||
char int_frac_digits;
|
||||
char int_p_cs_precedes;
|
||||
char int_n_cs_precedes;
|
||||
char int_p_sep_by_space;
|
||||
char int_n_sep_by_space;
|
||||
char int_p_sign_posn;
|
||||
char int_n_sign_posn;
|
||||
};
|
||||
|
||||
struct _loc_mon_cmpt {
|
||||
char CmptName[8];
|
||||
char* mon_decimal_point;
|
||||
char* mon_thousands_sep;
|
||||
char* mon_grouping;
|
||||
char* positive_sign;
|
||||
char* negative_sign;
|
||||
char* currency_symbol;
|
||||
char frac_digits;
|
||||
char p_cs_precedes;
|
||||
char n_cs_precedes;
|
||||
char p_sep_by_space;
|
||||
char n_sep_by_space;
|
||||
char p_sign_posn;
|
||||
char n_sign_posn;
|
||||
char* int_curr_symbol;
|
||||
char int_frac_digits;
|
||||
char int_p_cs_precedes;
|
||||
char int_n_cs_precedes;
|
||||
char int_p_sep_by_space;
|
||||
char int_n_sep_by_space;
|
||||
char int_p_sign_posn;
|
||||
char int_n_sign_posn;
|
||||
};
|
||||
|
||||
struct _loc_num_cmpt {
|
||||
char CmptName[8];
|
||||
char* decimal_point;
|
||||
char* thousands_sep;
|
||||
char* grouping;
|
||||
};
|
||||
|
||||
struct _loc_time_cmpt {
|
||||
char CmptName[8];
|
||||
const char* am_pm;
|
||||
const char* DateTime_Format;
|
||||
const char* Twelve_hr_format;
|
||||
const char* Date_Format;
|
||||
const char* Time_Format;
|
||||
const char* Day_Names;
|
||||
const char* MonthNames;
|
||||
char* TimeZone;
|
||||
};
|
||||
|
||||
struct _loc_coll_cmpt {
|
||||
char name[8];
|
||||
int char_start;
|
||||
int char_coll_tab_size;
|
||||
short char_spec;
|
||||
unsigned short* char_coll_table_ptr;
|
||||
unsigned short* wchar_coll_seq_ptr;
|
||||
};
|
||||
|
||||
struct _loc_ctype_cmpt {
|
||||
char name[8]; // 0x0
|
||||
const unsigned short* ctype_map_ptr; // 0x8
|
||||
const unsigned char* upper_map_ptr; // 0xC
|
||||
const unsigned char* lower_map_ptr; // 0x10
|
||||
const unsigned short* wctype_map_ptr; // 0x14
|
||||
const wchar_t* wupper_map_ptr; // 0x18
|
||||
const wchar_t* wlower_map_ptr; // 0x1C
|
||||
__decode_mbyte decode_mb;
|
||||
__encode_mbyte encode_wc;
|
||||
};
|
||||
|
||||
struct __locale {
|
||||
struct __locale* next_locale; // 0x0
|
||||
char name[0x30]; // 0x4
|
||||
struct _loc_coll_cmpt* coll_cmpt_ptr; // 0x34
|
||||
struct _loc_ctype_cmpt* ctype_cmpt_ptr; // 0x38
|
||||
struct _loc_mon_cmpt* mon_cmpt_ptr; // 0x3C
|
||||
struct _loc_num_cmpt* num_cmpt_ptr; // 0x40
|
||||
struct _loc_time_cmpt* time_cmpt_ptr; // 0x44
|
||||
};
|
||||
|
||||
extern struct __locale _current_locale;
|
||||
extern struct lconv __lconv;
|
||||
|
||||
#endif
|
||||
@@ -9,6 +9,9 @@ extern "C" {
|
||||
|
||||
size_t wcstombs(char* dst, const wchar_t* src, size_t n);
|
||||
|
||||
int __mbtowc_noconv(wchar_t*, const char*, size_t);
|
||||
int __wctomb_noconv(char*, wchar_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef MSL_STRTOLD_H
|
||||
#define MSL_STRTOLD_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
long double __strtold(int max_width, int (*ReadProc)(void*, int, int), void* ReadProcArg, int* chars_scanned,
|
||||
int* overflow);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -9,6 +9,8 @@ long strtol(const char* str, char** end, int base);
|
||||
unsigned long strtoul(const char* str, char** end, int base);
|
||||
unsigned long __strtoul(int base, int max_width, int (*ReadProc)(void*, int, int), void* ReadProcArg, int* chars_scanned, int* negative,
|
||||
int* overflow);
|
||||
unsigned long long __strtoull(int base, int max_width, int (*ReadProc)(void*, int, int), void* ReadProcArg,
|
||||
int* chars_scanned, int* negative, int* overflow);
|
||||
int atoi(const char* str);
|
||||
float atof(const char* str);
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef _MSL_WCTYPE_H
|
||||
#define _MSL_WCTYPE_H
|
||||
|
||||
#include <cstddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define wctype_alpha 0x0001
|
||||
#define wctype_blank 0x0002
|
||||
#define wctype_cntrl 0x0004
|
||||
#define wctype_digit 0x0008
|
||||
#define wctype_graph 0x0010
|
||||
#define wctype_lower 0x0020
|
||||
#define wctype_print 0x0040
|
||||
#define wctype_punct 0x0080
|
||||
#define wctype_space 0x0100
|
||||
#define wctype_upper 0x0200
|
||||
#define wctype_xdigit 0x0400
|
||||
|
||||
#define wctype_alnum (wctype_alpha | wctype_digit)
|
||||
|
||||
extern const unsigned short __wctype_mapC[256];
|
||||
extern const wchar_t __wlower_mapC[256];
|
||||
extern const wchar_t __wupper_mapC[256];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _MSL_COMMON_CTYPE_H */
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef MSL_WSTRING_H
|
||||
#define MSL_WSTRING_H
|
||||
|
||||
#include <cstddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
size_t wcslen(const wchar_t*);
|
||||
wchar_t* wcscpy(wchar_t*, const wchar_t*);
|
||||
wchar_t* wcsncpy(wchar_t*, const wchar_t*, size_t);
|
||||
wchar_t* wcscat(wchar_t*, const wchar_t*);
|
||||
int wcscmp(const wchar_t*, const wchar_t*);
|
||||
wchar_t* wcschr(const wchar_t*, wchar_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -2,15 +2,6 @@
|
||||
#include "critical_regions.h"
|
||||
#include "errno.h"
|
||||
|
||||
long ftell(FILE* stream) {
|
||||
int retval;
|
||||
|
||||
__begin_critical_region(stdin_access);
|
||||
retval = (long)_ftell(stream);
|
||||
__end_critical_region(stdin_access);
|
||||
return retval;
|
||||
}
|
||||
|
||||
int _ftell(FILE* file) {
|
||||
int charsInUndoBuffer = 0;
|
||||
int position;
|
||||
@@ -43,12 +34,18 @@ int _ftell(FILE* file) {
|
||||
return (position);
|
||||
}
|
||||
|
||||
long ftell(FILE* stream) {
|
||||
int retval;
|
||||
|
||||
__begin_critical_region(stdin_access);
|
||||
retval = (long)_ftell(stream);
|
||||
__end_critical_region(stdin_access);
|
||||
return retval;
|
||||
}
|
||||
|
||||
int _fseek(FILE* file, unsigned long offset, int whence) {
|
||||
int bufferCode;
|
||||
int pos;
|
||||
int adjust;
|
||||
unsigned long state;
|
||||
int buffLen;
|
||||
|
||||
unsigned char* ptr;
|
||||
|
||||
@@ -68,38 +65,7 @@ int _fseek(FILE* file, unsigned long offset, int whence) {
|
||||
|
||||
if (whence == SEEK_CUR) {
|
||||
whence = SEEK_SET;
|
||||
adjust = 0;
|
||||
if ((file->file_mode.file_kind != 1 && file->file_mode.file_kind != 2) ||
|
||||
file->file_state.error != 0)
|
||||
{
|
||||
errno = 0x28;
|
||||
pos = -1;
|
||||
} else {
|
||||
state = file->file_state.io_state;
|
||||
if (state == 0) {
|
||||
pos = file->position;
|
||||
} else {
|
||||
pos = file->buffer_position;
|
||||
ptr = file->buffer;
|
||||
buffLen = (file->buffer_ptr - ptr);
|
||||
pos += buffLen;
|
||||
if ((state >= 3)) {
|
||||
adjust = (state - 2);
|
||||
pos -= adjust;
|
||||
}
|
||||
|
||||
if (file->file_mode.binary_io == 0) {
|
||||
int i;
|
||||
for (i = (buffLen - adjust); i != 0; i--) {
|
||||
unsigned char c = *ptr;
|
||||
ptr++;
|
||||
if (c == 10) {
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pos = _ftell(file);
|
||||
offset += pos;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "critical_regions.h"
|
||||
#include <cstring.h>
|
||||
|
||||
#include "global.h"
|
||||
|
||||
typedef struct Block {
|
||||
struct Block* prev;
|
||||
struct Block* next;
|
||||
@@ -124,7 +126,29 @@ static const unsigned long fix_pool_sizes[] = {4, 12, 20, 36, 52, 68};
|
||||
|
||||
void __sys_free();
|
||||
|
||||
static inline SubBlock* SubBlock_merge_prev(SubBlock* ths, SubBlock** start) {
|
||||
void Block_link(Block* ths, SubBlock* sb) {
|
||||
SubBlock** st;
|
||||
SubBlock_set_free(sb);
|
||||
st = &Block_start(ths);
|
||||
|
||||
if (*st != 0) {
|
||||
sb->prev = (*st)->prev;
|
||||
sb->prev->next = sb;
|
||||
sb->next = *st;
|
||||
(*st)->prev = sb;
|
||||
*st = sb;
|
||||
*st = SubBlock_merge_prev(*st, st);
|
||||
SubBlock_merge_next(*st, st);
|
||||
} else {
|
||||
*st = sb;
|
||||
sb->prev = sb;
|
||||
sb->next = sb;
|
||||
}
|
||||
if (ths->max_size < SubBlock_size(*st))
|
||||
ths->max_size = SubBlock_size(*st);
|
||||
}
|
||||
|
||||
static SubBlock* SubBlock_merge_prev(SubBlock* ths, SubBlock** start) {
|
||||
unsigned long prevsz;
|
||||
SubBlock* p;
|
||||
|
||||
@@ -144,7 +168,7 @@ static inline SubBlock* SubBlock_merge_prev(SubBlock* ths, SubBlock** start) {
|
||||
return ths;
|
||||
}
|
||||
|
||||
static inline void SubBlock_merge_next(SubBlock* pBlock, SubBlock** pStart) {
|
||||
static void SubBlock_merge_next(SubBlock* pBlock, SubBlock** pStart) {
|
||||
SubBlock* next_sub_block;
|
||||
unsigned long this_cur_size;
|
||||
|
||||
@@ -179,29 +203,7 @@ static inline void SubBlock_merge_next(SubBlock* pBlock, SubBlock** pStart) {
|
||||
}
|
||||
}
|
||||
|
||||
inline void Block_link(Block* ths, SubBlock* sb) {
|
||||
SubBlock** st;
|
||||
SubBlock_set_free(sb);
|
||||
st = &Block_start(ths);
|
||||
|
||||
if (*st != 0) {
|
||||
sb->prev = (*st)->prev;
|
||||
sb->prev->next = sb;
|
||||
sb->next = *st;
|
||||
(*st)->prev = sb;
|
||||
*st = sb;
|
||||
*st = SubBlock_merge_prev(*st, st);
|
||||
SubBlock_merge_next(*st, st);
|
||||
} else {
|
||||
*st = sb;
|
||||
sb->prev = sb;
|
||||
sb->next = sb;
|
||||
}
|
||||
if (ths->max_size < SubBlock_size(*st))
|
||||
ths->max_size = SubBlock_size(*st);
|
||||
}
|
||||
|
||||
static inline Block* __unlink(__mem_pool_obj* pool_obj, Block* bp) {
|
||||
static Block* __unlink(__mem_pool_obj* pool_obj, Block* bp) {
|
||||
Block* result = bp->next;
|
||||
if (result == bp) {
|
||||
result = 0;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "ansi_files.h"
|
||||
#include "critical_regions.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
static unsigned char stdin_buff[0x100];
|
||||
|
||||
static unsigned char stdout_buff[0x100];
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user