Fully matched MSL files (#555)
This commit is contained in:
parent
a8d7f5e16d
commit
74cae4f16e
4 changed files with 14 additions and 220 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/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/arith.c"),
|
||||||
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/buffer_io.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/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_io.c"),
|
||||||
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/FILE_POS.c"),
|
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/FILE_POS.c"),
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ extern "C" {
|
||||||
|
|
||||||
#define EOF -1L
|
#define EOF -1L
|
||||||
|
|
||||||
extern const unsigned char __ctype_map[];
|
extern unsigned char __ctype_map[];
|
||||||
extern const unsigned char __lower_map[];
|
extern unsigned char __lower_map[];
|
||||||
extern const unsigned char __upper_map[];
|
extern unsigned char __upper_map[];
|
||||||
|
|
||||||
#define __control_char 0x01
|
#define __control_char 0x01
|
||||||
#define __motion_char 0x02
|
#define __motion_char 0x02
|
||||||
|
|
@ -31,7 +31,7 @@ extern const unsigned char __upper_map[];
|
||||||
int tolower(int c);
|
int tolower(int c);
|
||||||
int toupper(int c);
|
int toupper(int c);
|
||||||
|
|
||||||
inline int isalpha(int c)
|
inline int _isalpha(int c)
|
||||||
{
|
{
|
||||||
return (int)(__ctype_map[(unsigned char)c] & __letter);
|
return (int)(__ctype_map[(unsigned char)c] & __letter);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
#define uhex (hexd | uppc)
|
#define uhex (hexd | uppc)
|
||||||
#define lhex (hexd | lowc)
|
#define lhex (hexd | lowc)
|
||||||
|
|
||||||
const unsigned char __ctype_map[256] = {
|
unsigned char __ctype_map[256] = {
|
||||||
// clang-format off
|
// 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, motn, motn, motn, motn, motn, ctrl, ctrl,
|
||||||
ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, 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
|
// clang-format on
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned char __lower_map[256] = {
|
unsigned char __lower_map[256] = {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
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,
|
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
|
// clang-format on
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned char __upper_map[256] = {
|
unsigned char __upper_map[256] = {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
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,
|
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
|
// clang-format on
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int isalpha(int __c)
|
||||||
|
{
|
||||||
|
return __ctype_map[(unsigned char)__c] & __letter;
|
||||||
|
}
|
||||||
|
|
||||||
int tolower(int __c)
|
int tolower(int __c)
|
||||||
{
|
{
|
||||||
if (__c == -1)
|
return __c == -1 ? -1 : __lower_map[(unsigned char)__c];
|
||||||
return -1;
|
|
||||||
|
|
||||||
return __lower_map[__c & 0xff];
|
|
||||||
}
|
|
||||||
|
|
||||||
int toupper(int __c)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (__c == -1)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return __upper_map[__c & 0xff];
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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