Import MSL headers and files

This commit is contained in:
dbalatoni13 2025-01-12 09:47:25 +01:00
parent 0de51f3ffa
commit b0ed90ff26
40 changed files with 2736 additions and 29 deletions

View file

@ -682,7 +682,7 @@ config.libs = [
"objects": [ "objects": [
Object(NonMatching, "MSL_C.PPCEABI.bare.H/abort_exit.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/abort_exit.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/alloc.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/alloc.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/errno.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/errno.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/ansi_files.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/ansi_files.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/ansi_fp.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/ansi_fp.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/arith.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/arith.c"),
@ -696,7 +696,7 @@ config.libs = [
Object(NonMatching, "MSL_C.PPCEABI.bare.H/mem_funcs.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/mem_funcs.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/misc_io.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/misc_io.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/printf.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/printf.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/float.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/float.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/signal.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/signal.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/string.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/string.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/uart_console_io.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/uart_console_io.c"),
@ -715,14 +715,14 @@ config.libs = [
Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_copysign.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_copysign.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_cos.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_cos.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_floor.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_floor.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_frexp.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_frexp.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_ldexp.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_ldexp.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_modf.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_modf.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_sin.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_sin.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_tan.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_tan.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/w_acos.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/w_acos.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/w_asin.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/w_asin.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/w_atan2.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/w_atan2.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/w_fmod.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/w_fmod.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/w_pow.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/w_pow.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/math_ppc.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/math_ppc.c"),

View file

@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_FILE_POS_H #ifndef _MSL_COMMON_FILE_POS_H
#define _MSL_COMMON_FILE_POS_H #define _MSL_COMMON_FILE_POS_H
#include "ansi_files.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_files.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_ALLOC_H #ifndef _MSL_COMMON_ALLOC_H
#define _MSL_COMMON_ALLOC_H #define _MSL_COMMON_ALLOC_H
#include "ansi_files.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_files.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_ANSI_FILES_H #ifndef _MSL_COMMON_ANSI_FILES_H
#define _MSL_COMMON_ANSI_FILES_H #define _MSL_COMMON_ANSI_FILES_H
#include "stddef.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/stddef.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_ANSI_FP_H #ifndef _MSL_COMMON_ANSI_FP_H
#define _MSL_COMMON_ANSI_FP_H #define _MSL_COMMON_ANSI_FP_H
#include "float.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/float.h"
#define SIGDIGLEN 36 #define SIGDIGLEN 36

View file

@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_BUFFER_IO_H #ifndef _MSL_COMMON_BUFFER_IO_H
#define _MSL_COMMON_BUFFER_IO_H #define _MSL_COMMON_BUFFER_IO_H
#include "ansi_files.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_files.h"
enum { __align_buffer, __dont_align_buffer }; enum { __align_buffer, __dont_align_buffer };

View file

@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_CHAR_IO_H #ifndef _MSL_COMMON_CHAR_IO_H
#define _MSL_COMMON_CHAR_IO_H #define _MSL_COMMON_CHAR_IO_H
#include "ansi_files.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_files.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_DIRECT_IO_H #ifndef _MSL_COMMON_DIRECT_IO_H
#define _MSL_COMMON_DIRECT_IO_H #define _MSL_COMMON_DIRECT_IO_H
#include "ansi_files.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_files.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_FILE_IO_H #ifndef _MSL_COMMON_FILE_IO_H
#define _MSL_COMMON_FILE_IO_H #define _MSL_COMMON_FILE_IO_H
#include "ansi_files.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_files.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -1,7 +1,7 @@
#ifndef MSL_MATH_H_ #ifndef MSL_MATH_H_
#define MSL_MATH_H_ #define MSL_MATH_H_
#include "float.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/float.h"
#define NAN (*(float*)__float_nan) #define NAN (*(float*)__float_nan)
#define HUGE_VALF (*(float*)__float_huge) #define HUGE_VALF (*(float*)__float_huge)

View file

@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_MBSTRING_H #ifndef _MSL_COMMON_MBSTRING_H
#define _MSL_COMMON_MBSTRING_H #define _MSL_COMMON_MBSTRING_H
#include "wchar_io.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/wchar_io.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_MEM_FUNCS_H #ifndef _MSL_COMMON_MEM_FUNCS_H
#define _MSL_COMMON_MEM_FUNCS_H #define _MSL_COMMON_MEM_FUNCS_H
#include "stddef.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/stddef.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -1,8 +1,8 @@
#ifndef _MSL_COMMON_PRINTF_H #ifndef _MSL_COMMON_PRINTF_H
#define _MSL_COMMON_PRINTF_H #define _MSL_COMMON_PRINTF_H
#include "ansi_files.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_files.h"
#include "stdarg.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/stdarg.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -1,8 +1,8 @@
#ifndef _MSL_COMMON_SCANF_H #ifndef _MSL_COMMON_SCANF_H
#define _MSL_COMMON_SCANF_H #define _MSL_COMMON_SCANF_H
#include "stddef.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/stddef.h"
#include "ansi_files.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_files.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -1,10 +1,10 @@
#ifndef MSL_STDIO_H_ #ifndef MSL_STDIO_H_
#define MSL_STDIO_H_ #define MSL_STDIO_H_
#include "char_io.h" // IWYU pragma: export #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/char_io.h" // IWYU pragma: export
#include "file_io.h" // IWYU pragma: export #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/file_io.h" // IWYU pragma: export
#include "printf.h" // IWYU pragma: export #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/printf.h" // IWYU pragma: export
#include "extras.h" // IWYU pragma: export #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/extras.h" // IWYU pragma: export
#define stdin (&__files._stdin) #define stdin (&__files._stdin)
#define stdout (&__files._stdout) #define stdout (&__files._stdout)

View file

@ -1,9 +1,9 @@
#ifndef MSL_STDLIB_H_ #ifndef MSL_STDLIB_H_
#define MSL_STDLIB_H_ #define MSL_STDLIB_H_
#include "abort_exit.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/abort_exit.h"
#include "arith.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/arith.h"
#include "mbstring.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/mbstring.h"
#include "strtoul.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/strtoul.h"
#endif #endif

View file

@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_STRING_H #ifndef _MSL_COMMON_STRING_H
#define _MSL_COMMON_STRING_H #define _MSL_COMMON_STRING_H
#include "stddef.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/stddef.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_WCHAR_IO_H #ifndef _MSL_COMMON_WCHAR_IO_H
#define _MSL_COMMON_WCHAR_IO_H #define _MSL_COMMON_WCHAR_IO_H
#include "ansi_files.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_files.h"
#ifndef __cplusplus #ifndef __cplusplus
typedef unsigned short wchar_t; typedef unsigned short wchar_t;

View file

@ -0,0 +1,55 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/abort_exit.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/critical_regions.h"
#include "stddef.h"
#include "PowerPC_EABI_Support/Runtime/NMWException.h"
void _ExitProcess();
extern void (*_dtors[])(void);
int __aborting = 0;
static void (*atexit_funcs[64])(void);
static int atexit_curr_func = 0;
static void (*__atexit_funcs[64])(void);
static int __atexit_curr_func = 0;
void (*__stdio_exit)(void) = 0;
void (*__console_exit)(void) = 0;
void abort(void)
{
// TODO
}
void exit(int status)
{
int i;
void (**dtor)(void);
if (!__aborting) {
__destroy_global_chain();
dtor = _dtors;
while (*dtor != NULL) {
(*dtor)();
dtor++;
}
if (__stdio_exit != NULL) {
__stdio_exit();
__stdio_exit = NULL;
}
}
while (__atexit_curr_func > 0)
__atexit_funcs[--__atexit_curr_func]();
if (__console_exit != NULL) {
__console_exit();
__console_exit = NULL;
}
_ExitProcess();
}

View file

@ -0,0 +1,95 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_files.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/file_io.h"
extern files __files = {
{
0,
0,
1,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
{ 0, 0 },
{ 0, 0 },
0,
(unsigned char*)&__files._stdin.char_buffer,
1,
(unsigned char*)&__files._stdin.char_buffer,
0,
0,
0,
0,
NULL,
__read_console,
__write_console,
__close_console,
NULL,
},
{
0,
0,
2,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
{ 0, 0 },
{ 0, 0 },
0,
(unsigned char*)&__files._stdout.char_buffer,
1,
(unsigned char*)&__files._stdout.char_buffer,
0,
0,
0,
0,
NULL,
__read_console,
__write_console,
__close_console,
NULL,
},
{
0,
0,
2,
0,
2,
0,
0,
0,
0,
0,
0,
0,
0,
{ 0, 0 },
{ 0, 0 },
0,
(unsigned char*)&__files._stderr.char_buffer,
1,
(unsigned char*)&__files._stderr.char_buffer,
0,
0,
0,
0,
NULL,
__read_console,
__write_console,
__close_console,
NULL,
},
};

View file

@ -0,0 +1,41 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_files.h"
void __prep_buffer(FILE* file)
{
file->buffer_ptr = file->buffer;
file->buffer_length = file->buffer_size;
file->buffer_length -= file->position & file->buffer_alignment;
file->buffer_position = file->position;
}
void __convert_from_newlines(unsigned char* p, size_t* n) { }
int __flush_buffer(FILE* file, size_t* bytes_flushed)
{
size_t buffer_len;
int ioresult;
buffer_len = file->buffer_ptr - file->buffer;
if (buffer_len) {
file->buffer_length = buffer_len;
if (!file->file_mode.binary_io)
__convert_from_newlines(file->buffer, &file->buffer_length);
ioresult = (*file->write_fn)(file->handle, file->buffer,
&file->buffer_length, file->idle_fn);
if (bytes_flushed)
*bytes_flushed = file->buffer_length;
if (ioresult)
return ioresult;
file->position += file->buffer_length;
}
__prep_buffer(file);
return __no_io_error;
}

View file

@ -0,0 +1,85 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ctype.h"
#define ctrl __control_char
#define motn __motion_char
#define spac __space_char
#define punc __punctuation
#define digi __digit
#define hexd __hex_digit
#define lowc __lower_case
#define uppc __upper_case
#define dhex (hexd | digi)
#define uhex (hexd | uppc)
#define lhex (hexd | lowc)
const 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,
spac, punc, punc, punc, punc, punc, punc, punc, punc, punc, punc, punc, punc, punc, punc, punc,
dhex, dhex, dhex, dhex, dhex, dhex, dhex, dhex, dhex, dhex, punc, punc, punc, punc, punc, punc,
punc, uhex, uhex, uhex, uhex, uhex, uhex, uppc, uppc, uppc, uppc, uppc, uppc, uppc, uppc, uppc,
uppc, uppc, uppc, uppc, uppc, uppc, uppc, uppc, uppc, uppc, uppc, punc, punc, punc, punc, punc,
punc, lhex, lhex, lhex, lhex, lhex, lhex, lowc, lowc, lowc, lowc, lowc, lowc, lowc, lowc, lowc,
lowc, lowc, lowc, lowc, lowc, lowc, lowc, lowc, lowc, lowc, lowc, punc, punc, punc, punc, ctrl,
// clang-format on
};
const 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,
' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',
'@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '[', '\\', ']', '^', '_',
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', 0x7F,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
// clang-format on
};
const 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,
' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?',
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
'`', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', 0x7F,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,
0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,
0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,
0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF,
// clang-format on
};
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];
}

View file

@ -0,0 +1,114 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/direct_io.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/buffer_io.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/misc_io.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/string.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/wchar_io.h"
size_t fwrite(const void* buffer, size_t size, size_t count, FILE* stream)
{
unsigned char* write_ptr;
size_t num_bytes, bytes_to_go, bytes_written;
int ioresult, always_buffer;
if (fwide(stream, 0) == 0)
fwide(stream, -1);
bytes_to_go = size * count;
if (!bytes_to_go || stream->file_state.error
|| stream->file_mode.file_kind == __closed_file)
return 0;
if ((int)stream->file_mode.file_kind == __console_file)
__stdio_atexit();
always_buffer = !stream->file_mode.binary_io
|| (int)stream->file_mode.file_kind == __string_file
|| stream->file_mode.buffer_mode == _IOFBF
|| stream->file_mode.buffer_mode == _IOLBF;
if (stream->file_state.io_state == __neutral) {
if (stream->file_mode.io_mode & __write) {
stream->file_state.io_state = __writing;
__prep_buffer(stream);
}
}
if (stream->file_state.io_state != __writing) {
set_error(stream);
return 0;
}
write_ptr = (unsigned char*)buffer;
bytes_written = 0;
if (bytes_to_go
&& (stream->buffer_ptr != stream->buffer || always_buffer)) {
stream->buffer_length
= stream->buffer_size - (stream->buffer_ptr - stream->buffer);
do {
unsigned char* newline = NULL;
num_bytes = stream->buffer_length;
if (num_bytes > bytes_to_go)
num_bytes = bytes_to_go;
if (num_bytes) {
memcpy(stream->buffer_ptr, write_ptr, num_bytes);
write_ptr += num_bytes;
bytes_written += num_bytes;
bytes_to_go -= num_bytes;
stream->buffer_ptr += num_bytes;
stream->buffer_length -= num_bytes;
}
if (!stream->buffer_length
&& (int)stream->file_mode.file_kind == __string_file) {
bytes_written += bytes_to_go;
break;
}
if (!stream->buffer_length || newline != NULL
|| (stream->file_mode.buffer_mode == _IONBF)) {
ioresult = __flush_buffer(stream, NULL);
if (ioresult) {
set_error(stream);
bytes_to_go = 0;
break;
}
}
} while (bytes_to_go && always_buffer);
}
if (bytes_to_go && !always_buffer) {
unsigned char* save_buffer = stream->buffer;
size_t save_size = stream->buffer_size;
stream->buffer = write_ptr;
stream->buffer_size = bytes_to_go;
stream->buffer_ptr = write_ptr + bytes_to_go;
if (__flush_buffer(stream, &num_bytes) != __no_io_error)
set_error(stream);
bytes_written += num_bytes;
stream->buffer = save_buffer;
stream->buffer_size = save_size;
__prep_buffer(stream);
stream->buffer_length = 0;
}
if (stream->file_mode.buffer_mode != _IOFBF)
stream->buffer_length = 0;
return ((bytes_written + size - 1) / size);
}

View file

@ -0,0 +1,3 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h"
double fabs__Fd(double v) { return __fabs(v); }

View file

@ -0,0 +1,145 @@
/* @(#)e_atan2.c 1.3 95/01/18 */
/**
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*
*/
/* __ieee754_atan2(y,x)
* Method :
* 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x).
* 2. Reduce x to positive by (if x and y are unexceptional):
* ARG (x+iy) = arctan(y/x) ... if x > 0,
* ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0,
*
* Special cases:
*
* ATAN2((anything), NaN ) is NaN;
* ATAN2(NAN , (anything) ) is NaN;
* ATAN2(+-0, +(anything but NaN)) is +-0 ;
* ATAN2(+-0, -(anything but NaN)) is +-pi ;
* ATAN2(+-(anything but 0 and NaN), 0) is +-pi/2;
* ATAN2(+-(anything but INF and NaN), +INF) is +-0 ;
* ATAN2(+-(anything but INF and NaN), -INF) is +-pi;
* ATAN2(+-INF,+INF ) is +-pi/4 ;
* ATAN2(+-INF,-INF ) is +-3pi/4;
* ATAN2(+-INF, (anything but,0,NaN, and INF)) is +-pi/2;
*
* Constants:
* The hexadecimal values are the intended ones for the following
* constants. The decimal values may be used, provided that the
* compiler will convert from decimal to binary accurately enough
* to produce the hexadecimal values shown.
*/
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h"
#ifdef __STDC__
static const double
#else
static double
#endif
tiny
= 1.0e-300,
zero = 0.0, pi_o_4 = 7.8539816339744827900E-01, /* 0x3FE921FB, 0x54442D18 */
pi_o_2 = 1.5707963267948965580E+00, /* 0x3FF921FB, 0x54442D18 */
pi = 3.1415926535897931160E+00, /* 0x400921FB, 0x54442D18 */
pi_lo = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */
#ifdef __STDC__
double __ieee754_atan2(double y, double x)
#else
double __ieee754_atan2(y, x)
double y, x;
#endif
{
double z;
int k, m, hx, hy, ix, iy;
unsigned lx, ly;
hx = __HI(x);
ix = hx & 0x7fffffff;
lx = __LO(x);
hy = __HI(y);
iy = hy & 0x7fffffff;
ly = __LO(y);
if (((ix | ((lx | -lx) >> 31)) > 0x7ff00000)
|| ((iy | ((ly | -ly) >> 31)) > 0x7ff00000)) /* x or y is NaN */
return x + y;
if ((hx - 0x3ff00000 | lx) == 0)
return atan(y); /* x=1.0 */
m = ((hy >> 31) & 1) | ((hx >> 30) & 2); /* 2*sign(x)+sign(y) */
/* when y = 0 */
if ((iy | ly) == 0) {
switch (m) {
case 0:
case 1:
return y; /* atan(+-0,+anything)=+-0 */
case 2:
return pi + tiny; /* atan(+0,-anything) = pi */
case 3:
return -pi - tiny; /* atan(-0,-anything) =-pi */
}
}
/* when x = 0 */
if ((ix | lx) == 0)
return (hy < 0) ? -pi_o_2 - tiny : pi_o_2 + tiny;
/* when x is INF */
if (ix == 0x7ff00000) {
if (iy == 0x7ff00000) {
switch (m) {
case 0:
return pi_o_4 + tiny; /* atan(+INF,+INF) */
case 1:
return -pi_o_4 - tiny; /* atan(-INF,+INF) */
case 2:
return 3.0 * pi_o_4 + tiny; /*atan(+INF,-INF)*/
case 3:
return -3.0 * pi_o_4 - tiny; /*atan(-INF,-INF)*/
}
} else {
switch (m) {
case 0:
return zero; /* atan(+...,+INF) */
case 1:
return -zero; /* atan(-...,+INF) */
case 2:
return pi + tiny; /* atan(+...,-INF) */
case 3:
return -pi - tiny; /* atan(-...,-INF) */
}
}
}
/* when y is INF */
if (iy == 0x7ff00000)
return (hy < 0) ? -pi_o_2 - tiny : pi_o_2 + tiny;
/* compute y/x */
k = (iy - ix) >> 20;
if (k > 60)
z = pi_o_2 + 0.5 * pi_lo; /* |y/x| > 2**60 */
else if (hx < 0 && k < -60)
z = 0.0; /* |y|/x < -2**60 */
else
z = atan(fabs__Fd(y / x)); /* safe to do y/x */
switch (m) {
case 0:
return z; /* atan(+,+) */
case 1:
__HI(z) ^= 0x80000000;
return z; /* atan(-,+) */
case 2:
return pi - (z - pi_lo); /* atan(+,-) */
default: /* case 3 */
return (z - pi_lo) - pi; /* atan(-,-) */
}
}

View file

@ -0,0 +1,3 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/errno.h"
int errno;

View file

@ -0,0 +1,5 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/float.h"
unsigned long __float_nan[] = { 0x7FFFFFFF };
unsigned long __float_huge[] = { 0x7F800000 };

View file

@ -0,0 +1,18 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/mbstring.h"
size_t wcstombs(char* s, const wchar_t* pwcs, size_t n)
{
wchar_t next;
size_t chars_written;
int i;
chars_written = 0;
for (i = 0; i < n; ++i) {
next = *pwcs++;
*s++ = (char)next;
if ((char)next == '\0')
break;
++chars_written;
}
return chars_written;
}

View file

@ -0,0 +1,75 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/string.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/mem_funcs.h"
void* memmove(void* dst, const void* src, size_t n)
{
unsigned char* csrc;
unsigned char* cdst;
int reverse = (unsigned int)src < (unsigned int)dst;
if (n >= 32) {
if (((unsigned int)dst ^ (unsigned int)src) & 3) {
if (!reverse) {
__copy_longs_unaligned(dst, src, n);
} else {
__copy_longs_rev_unaligned(dst, src, n);
}
} else {
if (!reverse) {
__copy_longs_aligned(dst, src, n);
} else {
__copy_longs_rev_aligned(dst, src, n);
}
}
return dst;
} else {
if (!reverse) {
csrc = ((unsigned char*)src) - 1;
cdst = ((unsigned char*)dst) - 1;
n++;
while (--n > 0) {
*++cdst = *++csrc;
}
} else {
csrc = (unsigned char*)src + n;
cdst = (unsigned char*)dst + n;
n++;
while (--n > 0) {
*--cdst = *--csrc;
}
}
}
return dst;
}
void* memchr(const void* ptr, int ch, size_t count)
{
const unsigned char* p;
unsigned long v = (ch & 0xff);
for (p = (unsigned char*)ptr - 1, count++; --count;)
if ((*++p & 0xff) == v)
return (void*)p;
return NULL;
}
int memcmp(const void* lhs, const void* rhs, size_t count)
{
const unsigned char* p1;
const unsigned char* p2;
for (p1 = (const unsigned char*)lhs - 1, p2 = (const unsigned char*)rhs - 1,
count++;
--count;)
if (*++p1 != *++p2)
return ((*p1 < *p2) ? -1 : +1);
return 0;
}

View file

@ -0,0 +1,221 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/mem_funcs.h"
#define cps ((unsigned char*)src)
#define cpd ((unsigned char*)dst)
#define lps ((unsigned long*)src)
#define lpd ((unsigned long*)dst)
#define deref_auto_inc(p) *++(p)
void __copy_longs_aligned(void* dst, const void* src, size_t n)
{
unsigned long i;
i = (-(unsigned long)dst) & 3;
cps = ((unsigned char*)src) - 1;
cpd = ((unsigned char*)dst) - 1;
if (i) {
n -= i;
do
deref_auto_inc(cpd) = deref_auto_inc(cps);
while (--i);
}
lps = ((unsigned long*)(cps + 1)) - 1;
lpd = ((unsigned long*)(cpd + 1)) - 1;
i = n >> 5;
if (i)
do {
deref_auto_inc(lpd) = deref_auto_inc(lps);
deref_auto_inc(lpd) = deref_auto_inc(lps);
deref_auto_inc(lpd) = deref_auto_inc(lps);
deref_auto_inc(lpd) = deref_auto_inc(lps);
deref_auto_inc(lpd) = deref_auto_inc(lps);
deref_auto_inc(lpd) = deref_auto_inc(lps);
deref_auto_inc(lpd) = deref_auto_inc(lps);
deref_auto_inc(lpd) = deref_auto_inc(lps);
} while (--i);
i = (n & 31) >> 2;
if (i)
do
deref_auto_inc(lpd) = deref_auto_inc(lps);
while (--i);
cps = ((unsigned char*)(lps + 1)) - 1;
cpd = ((unsigned char*)(lpd + 1)) - 1;
n &= 3;
if (n)
do
deref_auto_inc(cpd) = deref_auto_inc(cps);
while (--n);
return;
}
void __copy_longs_rev_aligned(void* dst, const void* src, size_t n)
{
unsigned long i;
cps = ((unsigned char*)src) + n;
cpd = ((unsigned char*)dst) + n;
i = ((unsigned long)cpd) & 3;
if (i) {
n -= i;
do
*--cpd = *--cps;
while (--i);
}
i = n >> 5;
if (i)
do {
*--lpd = *--lps;
*--lpd = *--lps;
*--lpd = *--lps;
*--lpd = *--lps;
*--lpd = *--lps;
*--lpd = *--lps;
*--lpd = *--lps;
*--lpd = *--lps;
} while (--i);
i = (n & 31) >> 2;
if (i)
do
*--lpd = *--lps;
while (--i);
n &= 3;
if (n)
do
*--cpd = *--cps;
while (--n);
return;
}
void __copy_longs_unaligned(void* dst, const void* src, size_t n)
{
unsigned long i, v1, v2;
unsigned int src_offset, left_shift, right_shift;
i = (-(unsigned long)dst) & 3;
cps = ((unsigned char*)src) - 1;
cpd = ((unsigned char*)dst) - 1;
if (i) {
n -= i;
do
deref_auto_inc(cpd) = deref_auto_inc(cps);
while (--i);
}
src_offset = ((unsigned int)(cps + 1)) & 3;
left_shift = src_offset << 3;
right_shift = 32 - left_shift;
cps -= src_offset;
lps = ((unsigned long*)(cps + 1)) - 1;
lpd = ((unsigned long*)(cpd + 1)) - 1;
i = n >> 3;
v1 = deref_auto_inc(lps);
do {
v2 = deref_auto_inc(lps);
deref_auto_inc(lpd) = (v1 << left_shift) | (v2 >> right_shift);
v1 = deref_auto_inc(lps);
deref_auto_inc(lpd) = (v2 << left_shift) | (v1 >> right_shift);
} while (--i);
if (n & 4) {
v2 = deref_auto_inc(lps);
deref_auto_inc(lpd) = (v1 << left_shift) | (v2 >> right_shift);
}
cps = ((unsigned char*)(lps + 1)) - 1;
cpd = ((unsigned char*)(lpd + 1)) - 1;
n &= 3;
if (n) {
cps -= 4 - src_offset;
do
deref_auto_inc(cpd) = deref_auto_inc(cps);
while (--n);
}
return;
}
void __copy_longs_rev_unaligned(void* dst, const void* src, size_t n)
{
unsigned long i, v1, v2;
unsigned int src_offset, left_shift, right_shift;
cps = ((unsigned char*)src) + n;
cpd = ((unsigned char*)dst) + n;
i = ((unsigned long)cpd) & 3;
if (i) {
n -= i;
do
*--cpd = *--cps;
while (--i);
}
src_offset = ((unsigned int)cps) & 3;
left_shift = src_offset << 3;
right_shift = 32 - left_shift;
cps += 4 - src_offset;
i = n >> 3;
v1 = *--lps;
do {
v2 = *--lps;
*--lpd = (v2 << left_shift) | (v1 >> right_shift);
v1 = *--lps;
*--lpd = (v1 << left_shift) | (v2 >> right_shift);
} while (--i);
if (n & 4) {
v2 = *--lps;
*--lpd = (v2 << left_shift) | (v1 >> right_shift);
}
n &= 3;
if (n) {
cps += src_offset;
do
*--cpd = *--cps;
while (--n);
}
return;
}

View file

@ -0,0 +1 @@
void __stdio_atexit(void) { }

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,13 @@
#include "dolphin.h"
// rand.c from Runtime library
u32 next = 1;
u32 rand(void)
{
next = 0x41C64E6D * next + 12345;
return (next >> 16) & 0x7FFF;
}
void srand(u32 seed) { next = seed; }

View file

@ -0,0 +1,148 @@
/* @(#)s_atan.c 1.3 95/01/18 */
/**
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*
*/
/* atan(x)
* Method
* 1. Reduce x to positive by atan(x) = -atan(-x).
* 2. According to the integer k=4t+0.25 chopped, t=x, the argument
* is further reduced to one of the following intervals and the
* arctangent of t is evaluated by the corresponding formula:
*
* [0,7/16] atan(x) = t-t^3*(a1+t^2*(a2+...(a10+t^2*a11)...)
* [7/16,11/16] atan(x) = atan(1/2) + atan( (t-0.5)/(1+t/2) )
* [11/16.19/16] atan(x) = atan( 1 ) + atan( (t-1)/(1+t) )
* [19/16,39/16] atan(x) = atan(3/2) + atan( (t-1.5)/(1+1.5t) )
* [39/16,INF] atan(x) = atan(INF) + atan( -1/t )
*
* Constants:
* The hexadecimal values are the intended ones for the following
* constants. The decimal values may be used, provided that the
* compiler will convert from decimal to binary accurately enough
* to produce the hexadecimal values shown.
*/
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h"
#ifdef __STDC__
static const double atanhi[] = {
#else
static double atanhi[] = {
#endif
4.63647609000806093515e-01, /* atan(0.5)hi 0x3FDDAC67, 0x0561BB4F */
7.85398163397448278999e-01, /* atan(1.0)hi 0x3FE921FB, 0x54442D18 */
9.82793723247329054082e-01, /* atan(1.5)hi 0x3FEF730B, 0xD281F69B */
1.57079632679489655800e+00, /* atan(inf)hi 0x3FF921FB, 0x54442D18 */
};
#ifdef __STDC__
static const double atanlo[] = {
#else
static double atanlo[] = {
#endif
2.26987774529616870924e-17, /* atan(0.5)lo 0x3C7A2B7F, 0x222F65E2 */
3.06161699786838301793e-17, /* atan(1.0)lo 0x3C81A626, 0x33145C07 */
1.39033110312309984516e-17, /* atan(1.5)lo 0x3C700788, 0x7AF0CBBD */
6.12323399573676603587e-17, /* atan(inf)lo 0x3C91A626, 0x33145C07 */
};
#ifdef __STDC__
static const double aT[] = {
#else
static double aT[] = {
#endif
3.33333333333329318027e-01, /* 0x3FD55555, 0x5555550D */
-1.99999999998764832476e-01, /* 0xBFC99999, 0x9998EBC4 */
1.42857142725034663711e-01, /* 0x3FC24924, 0x920083FF */
-1.11111104054623557880e-01, /* 0xBFBC71C6, 0xFE231671 */
9.09088713343650656196e-02, /* 0x3FB745CD, 0xC54C206E */
-7.69187620504482999495e-02, /* 0xBFB3B0F2, 0xAF749A6D */
6.66107313738753120669e-02, /* 0x3FB10D66, 0xA0D03D51 */
-5.83357013379057348645e-02, /* 0xBFADDE2D, 0x52DEFD9A */
4.97687799461593236017e-02, /* 0x3FA97B4B, 0x24760DEB */
-3.65315727442169155270e-02, /* 0xBFA2B444, 0x2C6A6C2F */
1.62858201153657823623e-02, /* 0x3F90AD3A, 0xE322DA11 */
};
#ifdef __STDC__
static const double
#else
static double
#endif
one
= 1.0,
huge = 1.0e300;
#ifdef __STDC__
double atan(double x)
#else
double atan(x)
double x;
#endif
{
double w, s1, s2, z;
int ix, hx, id;
hx = __HI(x);
ix = hx & 0x7fffffff;
if (ix >= 0x44100000) { /* if |x| >= 2^66 */
if (ix > 0x7ff00000 || (ix == 0x7ff00000 && (__LO(x) != 0)))
return x + x; /* NaN */
if (hx > 0)
return atanhi[3] + atanlo[3];
else
return -atanhi[3] - atanlo[3];
}
if (ix < 0x3fdc0000) { /* |x| < 0.4375 */
if (ix < 0x3e200000) { /* |x| < 2^-29 */
if (huge + x > one)
return x; /* raise inexact */
}
id = -1;
} else {
x = fabs__Fd(x);
if (ix < 0x3ff30000) { /* |x| < 1.1875 */
if (ix < 0x3fe60000) { /* 7/16 <=|x|<11/16 */
id = 0;
x = (2.0 * x - one) / (2.0 + x);
} else { /* 11/16<=|x|< 19/16 */
id = 1;
x = (x - one) / (x + one);
}
} else {
if (ix < 0x40038000) { /* |x| < 2.4375 */
id = 2;
x = (x - 1.5) / (one + 1.5 * x);
} else { /* 2.4375 <= |x| < 2^66 */
id = 3;
x = -1.0 / x;
}
}
}
/* end of argument reduction */
z = x * x;
w = z * z;
/* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */
s1 = z
* (aT[0]
+ w
* (aT[2]
+ w * (aT[4] + w * (aT[6] + w * (aT[8] + w * aT[10])))));
s2 = w * (aT[1] + w * (aT[3] + w * (aT[5] + w * (aT[7] + w * aT[9]))));
if (id < 0)
return x - x * (s1 + s2);
else {
z = atanhi[id] - ((x * (s1 + s2) - atanlo[id]) - x);
return (hx < 0) ? -z : z;
}
}

View file

@ -0,0 +1,58 @@
/* @(#)s_frexp.c 1.4 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
/*
* for non-zero x
* x = frexp(arg,&exp);
* return a double fp quantity x such that 0.5 <= |x| <1.0
* and the corresponding binary exponent "exp". That is
* arg = x*2^exp.
* If arg is inf, 0.0, or NaN, then frexp(arg,&exp) returns arg
* with *exp=0.
*/
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h"
#ifdef __STDC__
static const double
#else
static double
#endif
two54
= 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */
#ifdef __STDC__
double frexp(double x, int* eptr)
#else
double frexp(x, eptr)
double x;
int* eptr;
#endif
{
int hx, ix, lx;
hx = __HI(x);
ix = 0x7fffffff & hx;
lx = __LO(x);
*eptr = 0;
if (ix >= 0x7ff00000 || ((ix | lx) == 0))
return x; /* 0,inf,nan */
if (ix < 0x00100000) { /* subnormal */
x *= two54;
hx = __HI(x);
ix = hx & 0x7fffffff;
*eptr = -54;
}
*eptr += (ix >> 20) - 1022;
hx = (hx & 0x800fffff) | 0x3fe00000;
__HI(x) = hx;
return x;
}

View file

@ -0,0 +1,34 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/scanf.h"
int __StringRead(void* pPtr, int ch, int act)
{
char ret;
__InStrCtrl* Iscp = (__InStrCtrl*)pPtr;
switch (act) {
case __GetAChar:
ret = *(Iscp->NextChar);
if (ret == '\0') {
Iscp->NullCharDetected = 1;
return -1;
} else {
Iscp->NextChar++;
return ret;
}
case __UngetAChar:
if (Iscp->NullCharDetected == 0) {
Iscp->NextChar--;
} else {
Iscp->NullCharDetected = 0;
}
return ch;
case __TestForError:
return Iscp->NullCharDetected;
}
return 0;
}

View file

@ -0,0 +1,257 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/string.h"
static int K1 = 0x80808080;
static int K2 = 0xFEFEFEFF;
size_t strlen(const char* str)
{
size_t len = -1;
unsigned char* p = (unsigned char*)str - 1;
do {
len++;
} while (*++p);
return len;
}
char* strcpy(char* dst, const char* src)
{
register unsigned char *destb, *fromb;
register unsigned long w, t, align;
register unsigned int k1;
register unsigned int k2;
fromb = (unsigned char*)src;
destb = (unsigned char*)dst;
if ((align = ((int)fromb & 3)) != ((int)destb & 3)) {
goto bytecopy;
}
if (align) {
if ((*destb = *fromb) == 0) {
return dst;
}
for (align = 3 - align; align; align--) {
if ((*(++destb) = *(++fromb)) == 0) {
return dst;
}
}
++destb;
++fromb;
}
k1 = K1;
k2 = K2;
w = *((int*)(fromb));
t = w + k2;
t &= k1;
if (t) {
goto bytecopy;
}
--((int*)(destb));
do {
*(++((int*)(destb))) = w;
w = *(++((int*)(fromb)));
t = w + k2;
t &= k1;
if (t) {
goto adjust;
}
} while (1);
adjust:
++((int*)(destb));
bytecopy:
if ((*destb = *fromb) == 0) {
return dst;
}
do {
if ((*(++destb) = *(++fromb)) == 0) {
return dst;
}
} while (1);
return dst;
}
char* strncpy(char* dst, const char* src, size_t n)
{
const unsigned char* p = (const unsigned char*)src - 1;
unsigned char* q = (unsigned char*)dst - 1;
n++;
while (--n) {
if (!(*++q = *++p)) {
while (--n) {
*++q = 0;
}
break;
}
}
return dst;
}
char* strcat(char* dst, const char* src)
{
const unsigned char* p = (unsigned char*)src - 1;
unsigned char* q = (unsigned char*)dst - 1;
while (*++q) { }
q--;
while (*++q = *++p) { }
return dst;
}
int strcmp(const char* str1, const char* str2)
{
register unsigned char* left = (unsigned char*)str1;
register unsigned char* right = (unsigned char*)str2;
unsigned long align, l1, r1, x;
l1 = *left;
r1 = *right;
if (l1 - r1) {
return l1 - r1;
}
if ((align = ((int)left & 3)) != ((int)right & 3)) {
goto bytecopy;
}
if (align) {
if (l1 == 0) {
return 0;
}
for (align = 3 - align; align; align--) {
l1 = *(++left);
r1 = *(++right);
if (l1 - r1) {
return l1 - r1;
}
if (l1 == 0) {
return 0;
}
}
left++;
right++;
}
l1 = *(int*)left;
r1 = *(int*)right;
x = l1 + K2;
if (x & K1) {
goto adjust;
}
while (l1 == r1) {
l1 = *(++((int*)(left)));
r1 = *(++((int*)(right)));
x = l1 + K2;
if (x & K1) {
goto adjust;
}
}
if (l1 > r1) {
return 1;
}
return -1;
adjust:
l1 = *left;
r1 = *right;
if (l1 - r1) {
return l1 - r1;
}
bytecopy:
if (l1 == 0) {
return 0;
}
do {
l1 = *(++left);
r1 = *(++right);
if (l1 - r1) {
return l1 - r1;
}
if (l1 == 0) {
return 0;
}
} while (1);
}
char* strchr(const char* str, int c)
{
const unsigned char* p = (unsigned char*)str - 1;
unsigned long chr = (c & 0xFF);
unsigned long ch;
while (ch = *++p) {
if (ch == chr) {
return (char*)p;
}
}
return chr ? NULL : (char*)p;
}
char* strrchr(const char* str, int c)
{
const unsigned char* p = (unsigned char*)str - 1;
const unsigned char* q = NULL;
unsigned long chr = (c & 0xFF);
unsigned long ch;
while (ch = *++p) {
if (ch == chr) {
q = p;
}
}
if (q != NULL) {
return (char*)q;
}
return chr ? NULL : (char*)p;
}
char* strstr(const char* str, const char* pat)
{
const unsigned char* s1 = (const unsigned char*)str - 1;
const unsigned char* p1 = (const unsigned char*)pat - 1;
unsigned long firstc, c1, c2;
if ((pat == 0) || (!(firstc = *++p1))) {
return (char*)str;
}
while (c1 = *++s1) {
if (c1 == firstc) {
const unsigned char* s2 = s1 - 1;
const unsigned char* p2 = p1 - 1;
while ((c1 = *++s2) == (c2 = *++p2) && c1)
;
if (!c2)
return (char*)s1;
}
}
return NULL;
}

View file

@ -0,0 +1,199 @@
#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;
}

View file

@ -0,0 +1,39 @@
/* @(#)w_atan2.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*
*/
/*
* wrapper atan2(y,x)
*/
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h"
#ifdef __STDC__
double atan2(double y, double x) /* wrapper atan2 */
#else
double atan2(y, x) /* wrapper atan2 */
double y, x;
#endif
{
#ifdef _IEEE_LIBM
return __ieee754_atan2(y, x);
#else
double z;
z = __ieee754_atan2(y, x);
if (_LIB_VERSION == _IEEE_ || isnan(x) || isnan(y))
return z;
if (x == 0.0 && y == 0.0) {
return __kernel_standard(y, x, 3); /* atan2(+-0,+-0) */
} else
return z;
#endif
}

View file

@ -0,0 +1,22 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/wchar_io.h"
int fwide(FILE* file, int mode)
{
if (file->file_mode.file_kind == __closed_file) {
return 0;
}
switch (file->file_mode.file_orientation) {
case UNORIENTED:
if (mode > 0) {
file->file_mode.file_orientation = WIDE_ORIENTED;
} else if (mode < 0) {
file->file_mode.file_orientation = CHAR_ORIENTED;
}
return mode;
case WIDE_ORIENTED:
return 1;
case CHAR_ORIENTED:
return -1;
}
}