Merge branch 'mariopartyrd:main' into main
This commit is contained in:
commit
92464a27e1
5 changed files with 134 additions and 222 deletions
|
|
@ -688,7 +688,7 @@ config.libs = [
|
|||
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/ansi_fp.c"),
|
||||
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/arith.c"),
|
||||
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/buffer_io.c"),
|
||||
Object(NonMatching, "MSL_C.PPCEABI.bare.H/ctype.c"),
|
||||
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/ctype.c"),
|
||||
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/direct_io.c"),
|
||||
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/file_io.c"),
|
||||
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/FILE_POS.c"),
|
||||
|
|
@ -696,7 +696,7 @@ config.libs = [
|
|||
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/mem.c"),
|
||||
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/mem_funcs.c"),
|
||||
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/misc_io.c"),
|
||||
Object(NonMatching, "MSL_C.PPCEABI.bare.H/printf.c"),
|
||||
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/printf.c"),
|
||||
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/float.c"),
|
||||
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/signal.c"),
|
||||
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/string.c"),
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ extern "C" {
|
|||
|
||||
#define EOF -1L
|
||||
|
||||
extern const unsigned char __ctype_map[];
|
||||
extern const unsigned char __lower_map[];
|
||||
extern const unsigned char __upper_map[];
|
||||
extern unsigned char __ctype_map[];
|
||||
extern unsigned char __lower_map[];
|
||||
extern unsigned char __upper_map[];
|
||||
|
||||
#define __control_char 0x01
|
||||
#define __motion_char 0x02
|
||||
|
|
@ -31,7 +31,7 @@ extern const unsigned char __upper_map[];
|
|||
int tolower(int c);
|
||||
int toupper(int c);
|
||||
|
||||
inline int isalpha(int c)
|
||||
inline int _isalpha(int c)
|
||||
{
|
||||
return (int)(__ctype_map[(unsigned char)c] & __letter);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#define uhex (hexd | uppc)
|
||||
#define lhex (hexd | lowc)
|
||||
|
||||
const unsigned char __ctype_map[256] = {
|
||||
unsigned char __ctype_map[256] = {
|
||||
// clang-format off
|
||||
ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, motn, motn, motn, motn, motn, ctrl, ctrl,
|
||||
ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl,
|
||||
|
|
@ -25,7 +25,7 @@ const unsigned char __ctype_map[256] = {
|
|||
// clang-format on
|
||||
};
|
||||
|
||||
const unsigned char __lower_map[256] = {
|
||||
unsigned char __lower_map[256] = {
|
||||
// clang-format off
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
|
||||
|
|
@ -46,7 +46,7 @@ const unsigned char __lower_map[256] = {
|
|||
// clang-format on
|
||||
};
|
||||
|
||||
const unsigned char __upper_map[256] = {
|
||||
unsigned char __upper_map[256] = {
|
||||
// clang-format off
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
|
||||
|
|
@ -67,19 +67,12 @@ const unsigned char __upper_map[256] = {
|
|||
// clang-format on
|
||||
};
|
||||
|
||||
int isalpha(int __c)
|
||||
{
|
||||
return __ctype_map[(unsigned char)__c] & __letter;
|
||||
}
|
||||
|
||||
int tolower(int __c)
|
||||
{
|
||||
if (__c == -1)
|
||||
return -1;
|
||||
|
||||
return __lower_map[__c & 0xff];
|
||||
}
|
||||
|
||||
int toupper(int __c)
|
||||
{
|
||||
|
||||
if (__c == -1)
|
||||
return -1;
|
||||
|
||||
return __upper_map[__c & 0xff];
|
||||
return __c == -1 ? -1 : __lower_map[(unsigned char)__c];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -497,7 +497,125 @@ static char* longlong2str(long long num, char* pBuf, print_format fmt)
|
|||
return p;
|
||||
}
|
||||
|
||||
static char * double2hex(long double num, char * buff, print_format format);
|
||||
static char * double2hex(long double num, char * buff, print_format format) {
|
||||
char *p;
|
||||
unsigned char *q;
|
||||
unsigned char temp_r7;
|
||||
char working_byte;
|
||||
long double ld;
|
||||
long exp;
|
||||
print_format exp_format;
|
||||
int hex_precision;
|
||||
decform form;
|
||||
decimal dec;
|
||||
|
||||
p = buff;
|
||||
ld = num;
|
||||
|
||||
if (format.precision > 509) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
form.style = (char) 0;
|
||||
form.digits = 0x20;
|
||||
__num2dec(&form, num, &dec);
|
||||
|
||||
if (*dec.sig.text == 'I') {
|
||||
if (*(short*) &ld & 0x8000) {
|
||||
p = buff - 5;
|
||||
if (format.conversion_char == 'A') strcpy(p, "-INF");
|
||||
else strcpy(p, "-inf");
|
||||
}
|
||||
else {
|
||||
p = buff - 4;
|
||||
if (format.conversion_char == 'A') strcpy(p, "INF");
|
||||
else strcpy(p, "inf");
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
if (*dec.sig.text == 'N') {
|
||||
if (*(unsigned char*) &num & 0x80) {
|
||||
p = buff - 5;
|
||||
if (format.conversion_char == 'A') strcpy(p, "-NAN");
|
||||
else strcpy(p, "-nan");
|
||||
}
|
||||
else {
|
||||
p = buff - 4;
|
||||
if (format.conversion_char == 'A') strcpy(p, "NAN");
|
||||
else strcpy(p, "nan");
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
exp_format.justification_options = right_justification;
|
||||
exp_format.sign_options = sign_always;
|
||||
exp_format.precision_specified = 0;
|
||||
exp_format.alternate_form = 0;
|
||||
exp_format.argument_options = normal_argument;
|
||||
exp_format.field_width = 0;
|
||||
exp_format.precision = 1;
|
||||
exp_format.conversion_char = 'd';
|
||||
|
||||
exp = (short) ((*(short*) &ld & 0x7FFF) >> 4) - 0x3FF;
|
||||
p = long2str(exp, buff, exp_format);
|
||||
if (format.conversion_char == 'a')
|
||||
*--p = 'p';
|
||||
else
|
||||
*--p = 'P';
|
||||
q = (unsigned char*) #
|
||||
|
||||
for (hex_precision = format.precision; hex_precision >= 1; hex_precision--) {
|
||||
temp_r7 = *(q + (hex_precision / 2 + 1));
|
||||
if (hex_precision % 2) {
|
||||
working_byte = temp_r7 & 0xF;
|
||||
} else {
|
||||
working_byte = (temp_r7 >> 4);
|
||||
}
|
||||
|
||||
if (working_byte < 10) {
|
||||
working_byte += '0';
|
||||
}
|
||||
else
|
||||
if (format.conversion_char == 'a') {
|
||||
working_byte += 'a' - 10;
|
||||
}
|
||||
else {
|
||||
working_byte += 'A' - 10;
|
||||
}
|
||||
|
||||
*--p = working_byte;
|
||||
}
|
||||
|
||||
if (TARGET_FLOAT_IMPLICIT_J_BIT){
|
||||
if (format.precision || format.alternate_form) {
|
||||
*--p = '.';
|
||||
}
|
||||
*--p = '1';
|
||||
}
|
||||
|
||||
if (format.conversion_char == 'a') {
|
||||
*--p = 'x';
|
||||
}
|
||||
else {
|
||||
*--p = 'X';
|
||||
}
|
||||
|
||||
*--p = '0';
|
||||
|
||||
if (*((short*) &ld) & 0x8000) {
|
||||
*--p = '-';
|
||||
}
|
||||
else if (format.sign_options == sign_always) {
|
||||
*--p = '+';
|
||||
}
|
||||
else if (format.sign_options == space_holder) {
|
||||
*--p = ' ';
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
static void round_decimal(decimal* dec, int new_length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,199 +0,0 @@
|
|||
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/strtoul.h"
|
||||
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ctype.h"
|
||||
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/errno.h"
|
||||
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/limits.h"
|
||||
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/scanf.h"
|
||||
|
||||
enum scan_states {
|
||||
start = 0x01,
|
||||
check_for_zero = 0x02,
|
||||
leading_zero = 0x04,
|
||||
need_digit = 0x08,
|
||||
digit_loop = 0x10,
|
||||
finished = 0x20,
|
||||
failure = 0x40
|
||||
};
|
||||
|
||||
#define final_state(scan_state) (scan_state & (finished | failure))
|
||||
#define success(scan_state) \
|
||||
(scan_state & (leading_zero | digit_loop | finished))
|
||||
#define fetch() (count++, (*ReadProc)(ReadProcArg, 0, __GetAChar))
|
||||
#define unfetch(c) (*ReadProc)(ReadProcArg, c, __UngetAChar)
|
||||
|
||||
unsigned long __strtoul(int base, int max_width,
|
||||
int (*ReadProc)(void*, int, int), void* ReadProcArg,
|
||||
int* chars_scanned, int* negative, int* overflow)
|
||||
{
|
||||
int scan_state = start;
|
||||
int count = 0;
|
||||
unsigned long value = 0;
|
||||
unsigned long value_max = 0;
|
||||
int c;
|
||||
|
||||
*negative = *overflow = 0;
|
||||
|
||||
if (base < 0 || base == 1 || base > 36 || max_width < 1) {
|
||||
scan_state = failure;
|
||||
} else {
|
||||
c = fetch();
|
||||
}
|
||||
|
||||
if (base != 0)
|
||||
value_max = ULONG_MAX / base;
|
||||
|
||||
while (count <= max_width && c != -1 && !final_state(scan_state)) {
|
||||
switch (scan_state) {
|
||||
case start:
|
||||
if (isspace(c)) {
|
||||
c = fetch();
|
||||
break;
|
||||
}
|
||||
|
||||
if (c == '+') {
|
||||
c = fetch();
|
||||
} else if (c == '-') {
|
||||
c = fetch();
|
||||
*negative = 1;
|
||||
}
|
||||
|
||||
scan_state = check_for_zero;
|
||||
break;
|
||||
|
||||
case check_for_zero:
|
||||
if (base == 0 || base == 16) {
|
||||
if (c == '0') {
|
||||
scan_state = leading_zero;
|
||||
c = fetch();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
scan_state = need_digit;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (c == 'X' || c == 'x') {
|
||||
base = 16;
|
||||
scan_state = need_digit;
|
||||
c = fetch();
|
||||
break;
|
||||
}
|
||||
|
||||
if (base == 0)
|
||||
base = 8;
|
||||
|
||||
scan_state = digit_loop;
|
||||
break;
|
||||
|
||||
case need_digit:
|
||||
case digit_loop:
|
||||
if (base == 0)
|
||||
base = 10;
|
||||
|
||||
if (!value_max) {
|
||||
value_max = ULONG_MAX / base;
|
||||
}
|
||||
|
||||
if (isdigit(c)) {
|
||||
if ((c -= '0') >= base) {
|
||||
if (scan_state == digit_loop)
|
||||
scan_state = finished;
|
||||
else
|
||||
scan_state = failure;
|
||||
|
||||
c += '0';
|
||||
break;
|
||||
}
|
||||
} else if (!isalpha(c) || (toupper(c) - 'A' + 10) >= base) {
|
||||
if (scan_state == digit_loop)
|
||||
scan_state = finished;
|
||||
else
|
||||
scan_state = failure;
|
||||
|
||||
break;
|
||||
} else {
|
||||
c = toupper(c) - 'A' + 10;
|
||||
}
|
||||
|
||||
if (value > value_max)
|
||||
*overflow = 1;
|
||||
|
||||
value *= base;
|
||||
|
||||
if (c > (ULONG_MAX - value))
|
||||
*overflow = 1;
|
||||
|
||||
value += c;
|
||||
scan_state = digit_loop;
|
||||
c = fetch();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!success(scan_state)) {
|
||||
value = 0;
|
||||
count = 0;
|
||||
} else {
|
||||
count--;
|
||||
}
|
||||
|
||||
*chars_scanned = count;
|
||||
|
||||
unfetch(c);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
unsigned long strtoul(const char* str, char** end, int base)
|
||||
{
|
||||
unsigned long value;
|
||||
int count, negative, overflow;
|
||||
|
||||
__InStrCtrl isc;
|
||||
isc.NextChar = (char*)str;
|
||||
isc.NullCharDetected = 0;
|
||||
|
||||
value = __strtoul(base, 0x7FFFFFFF, &__StringRead, (void*)&isc, &count,
|
||||
&negative, &overflow);
|
||||
|
||||
if (end) {
|
||||
*end = (char*)str + count;
|
||||
}
|
||||
|
||||
if (overflow) {
|
||||
value = ULONG_MAX;
|
||||
errno = 0x22;
|
||||
} else if (negative) {
|
||||
value = -value;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
long strtol(const char* str, char** end, int base)
|
||||
{
|
||||
unsigned long uvalue;
|
||||
long svalue;
|
||||
int count, negative, overflow;
|
||||
|
||||
__InStrCtrl isc;
|
||||
isc.NextChar = (char*)str;
|
||||
isc.NullCharDetected = 0;
|
||||
|
||||
uvalue = __strtoul(base, 0x7FFFFFFF, &__StringRead, (void*)&isc, &count,
|
||||
&negative, &overflow);
|
||||
|
||||
if (end) {
|
||||
*end = (char*)str + count;
|
||||
}
|
||||
|
||||
if (overflow || (!negative && uvalue > LONG_MAX)
|
||||
|| (negative && uvalue > -LONG_MIN)) {
|
||||
svalue = (negative ? -LONG_MIN : LONG_MAX);
|
||||
errno = ERANGE;
|
||||
} else {
|
||||
svalue = (negative ? (long)-uvalue : (long)uvalue);
|
||||
}
|
||||
|
||||
return svalue;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue