Merge pull request #325 from robojumper/reimport-msl-c

Re-import MSL_C from TP
This commit is contained in:
robojumper
2026-05-31 18:08:09 +02:00
committed by GitHub
185 changed files with 7617 additions and 1992 deletions
+2
View File
@@ -223,6 +223,7 @@ cflags_base = [
f"-i build/{config.version}/include",
f"-DBUILD_VERSION={version_num}",
f"-DVERSION_{config.version}",
"-DPLATFORM_WII",
"-i src",
"-i src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include",
"-i src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Include",
@@ -256,6 +257,7 @@ cflags_runtime = [
"-common off",
"-inline auto",
"-func_align 4",
"-fp_contract off",
]
# Framework flags
+2 -1
View File
@@ -2,9 +2,10 @@
#define JGEOMETRY_H
#include "common.h"
#include "math.h"
#include "JSystem/JMath/JMath.h"
#include <cmath>
// TODO - a lot of this has been moved to nw4r and egg. Kept for reference for now.
namespace JGeometry {
+1 -1
View File
@@ -3,7 +3,7 @@
#include "common.h"
#include "rvl/MTX.h"
#include "math.h"
#include <cmath>
void JMAMTXApplyScale(const Mtx, Mtx, f32, f32, f32);
void JMAEulerToQuat(s16 param_0, s16 param_1, s16 param_2, Quaternion* param_3);
+2
View File
@@ -12,6 +12,8 @@
#include "egg/math/eggVector.h"
#include "m/m_angle.h"
#include <cstdint>
class JPAResourceManager;
class JPABaseEmitter;
class JPAEmitterManager;
+1 -1
View File
@@ -4,7 +4,7 @@
#include "common.h"
#include "egg/math/eggMath.h"
#include <cmath.h>
#include <cmath>
namespace cM {
s16 atan2s(f32, f32);
+1 -4
View File
@@ -108,8 +108,6 @@
#define DECOMP_DONT_INLINE __attribute__((never_inline))
#endif
#include "stddef.h"
typedef signed char s8;
typedef signed short s16;
typedef signed long s32;
@@ -174,8 +172,7 @@ private:
};
#endif
#define INT32_MAX (0x7fffffff)
#define UINT32_MAX (0xffffffff)
#define MSL_INLINE inline
#define FLOAT_MIN (1.175494351e-38f)
#define FLOAT_MAX (3.40282346638528860e+38f)
+2 -1
View File
@@ -2,11 +2,12 @@
#define C_M3D_H
#include "common.h"
#include "math.h"
#include "nw4r/types_nw4r.h"
#include "nw4r/math.h" // IWYU pragma: export
#include <cmath>
class cM3dGAab;
class cM3dGCps;
class cM3dGCyl;
-1
View File
@@ -2,7 +2,6 @@
#define EGG_MATH_H
#include "common.h"
#include "math.h"
namespace EGG {
+1 -1
View File
@@ -1,8 +1,8 @@
#ifndef EGG_ASSERT_H
#define EGG_ASSERT_H
#include "__va_arg.h"
#include "common.h"
#include <cstdarg>
namespace EGG {
// All this is guess
+2
View File
@@ -3,6 +3,8 @@
#include "common.h"
#include <cstddef>
namespace EGG {
/**
+2
View File
@@ -3,6 +3,8 @@
#include "common.h"
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
+1 -1
View File
@@ -2,7 +2,7 @@
#define LIBMS_MSGFILE_H
#include "common.h"
#include <wchar.h>
#include <cstddef>
#ifdef __cplusplus
extern "C" {
+2 -1
View File
@@ -4,10 +4,11 @@
#include "c/c_math.h"
#include "common.h"
#include "m/m_vec.h"
#include "math.h"
#include "nw4r/math/math_triangular.h"
#include "s/s_Math.h"
#include <cmath>
class mAng {
public:
mAng() {}
+2 -1
View File
@@ -1,11 +1,12 @@
#ifndef NW4R_DB_DIRECT_PRINT_H
#define NW4R_DB_DIRECT_PRINT_H
#include "__va_arg.h"
#include "common.h"
#include "rvl/GX.h" // IWYU pragma: export
#include <cstdarg>
namespace nw4r {
namespace db {
+2 -3
View File
@@ -1,7 +1,6 @@
#ifndef NW4R_MATH_ARITHMETIC_H
#define NW4R_MATH_ARITHMETIC_H
#include "math.h"
#include "nw4r/types_nw4r.h" // IWYU pragma: export
#include "rvl/OS.h" // IWYU pragma: export
@@ -32,7 +31,7 @@ inline f32 FAbs(register f32 x) {
}
inline f32 FCeil(f32 x) {
return std::ceilf(x);
return std::ceil(x);
}
inline f32 FExp(f32 x) {
@@ -40,7 +39,7 @@ inline f32 FExp(f32 x) {
}
inline f32 FFloor(f32 x) {
return std::floorf(x);
return std::floor(x);
}
inline f32 FInv(register f32 x) {
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef NW4R_MATH_TRIANGULAR_H
#define NW4R_MATH_TRIANGULAR_H
#include "math.h"
#include <cmath>
#include "nw4r/math/math_arithmetic.h"
#include "nw4r/types_nw4r.h"
+3
View File
@@ -1,6 +1,9 @@
#ifndef RVL_SDK_AXFX_HOOKS_H
#define RVL_SDK_AXFX_HOOKS_H
#include "common.h"
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
+2
View File
@@ -1,6 +1,8 @@
#ifndef RVL_SDK_OS_ARENA_H
#define RVL_SDK_OS_ARENA_H
#include "common.h"
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
+1 -1
View File
@@ -1,8 +1,8 @@
#ifndef RVL_SDK_OS_ERROR_H
#define RVL_SDK_OS_ERROR_H
#include "__va_arg.h"
#include "common.h"
#include <stdarg.h>
#include "rvl/OS/OSContext.h"
+1 -1
View File
@@ -2,7 +2,7 @@
#define RVL_SDK_OS_UTF_H
#include "common.h"
#include "wchar.h"
#include "stddef.h"
#ifdef __cplusplus
extern "C" {
+1 -1
View File
@@ -12,7 +12,7 @@ DECL_SECTION(".init") void __flush_cache(void *, size_t);
void __init_user(void);
void __init_cpp(void);
void __fini_cpp(void);
DECL_WEAK void exit(void);
DECL_WEAK void exit(int status);
void _ExitProcess(void);
/**
+4 -4
View File
@@ -1,11 +1,11 @@
#ifndef SIZED_STRING_H
#define SIZED_STRING_H
#include "__va_arg.h"
#include "common.h"
#include "string.h"
#include "wstring.h"
#include "printf.h"
#include <stdarg.h>
#include <string.h>
#include <stddef.h>
#include <printf.h>
extern "C" bool strequals(const char *a, const char *b);
@@ -0,0 +1,412 @@
#ifndef MSL_ALGORITHM_H_
#define MSL_ALGORITHM_H_
#include <iterator>
#include <cstring>
#include <functional>
namespace std {
template <class ForwardIterator, class T, typename Predicate>
inline ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, const T& val, Predicate p) {
typedef typename iterator_traits<ForwardIterator>::difference_type difference_type;
difference_type len = std::distance(first, last);
while (len > 0) {
ForwardIterator i = first;
difference_type step = len / 2;
std::advance(i, step);
if (p(*i, val)) {
first = ++i;
len -= step + 1;
} else {
len = step;
}
}
return first;
}
template <class ForwardIterator, class T>
ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, const T& val) {
// For some reason, calling the other lower_bound matches for debug, but not for retail:
#if DEBUG
return lower_bound(first, last, val, std::detail::less<T, T>());
#else
typedef typename iterator_traits<ForwardIterator>::difference_type difference_type;
difference_type len = std::distance(first, last);
while (len > 0) {
ForwardIterator i = first;
difference_type step = len / 2;
std::advance(i, step);
if (*i < val) {
first = ++i;
len -= step + 1;
} else {
len = step;
}
}
return first;
#endif
}
template <class ForwardIterator, class T, class Predicate>
ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, const T& val, Predicate p) {
typedef typename iterator_traits<ForwardIterator>::difference_type difference_type;
difference_type len = std::distance(first, last);
while (len > 0) {
ForwardIterator i = first;
difference_type step = len / 2;
std::advance(i, step);
if (!p(val, *i)) {
first = ++i;
len -= step + 1;
} else {
len = step;
}
}
return first;
}
// should be inline, but breaks JStudio/JStudio/ctb weak function order
template<class InputIt, class UnaryPredicate>
InputIt find_if(InputIt first, InputIt last, UnaryPredicate p) {
while (first != last && !p(*first)) {
++first;
}
return first;
}
// fakematch: val should be a const reference, but that breaks JMessage::TResource::toMessageIndex_messageID
template<class ForwardIterator, class T>
inline ForwardIterator find(ForwardIterator first, ForwardIterator last, T& val) {
while (first != last && !(*first == val)) {
++first;
}
return first;
}
/*
template<class OutputIt, class Size, int A2>
struct __fill_n {
OutputIt fill_n(OutputIt first, Size count, const unsigned long& value);
};
template<>
unsigned long* __fill_n<unsigned long, long, 0>::fill_n(unsigned long* first, long count, const unsigned long& value) {
for (; count > 0; count--) {
*first++ = value;
}
return first;
}
template<class OutputIt, class Size, class T>
OutputIt fill_n(OutputIt first, Size count, const T& value) {
return __fill_n::fill_n(first, count, value);
}
template<class ForwardIt, class T>
void __fill(ForwardIt first, ForwardIt last, const T& value, std::random_access_iterator_tag param_3) {
fill_n(first, last - first, value);
}
*/
template<class ForwardIt, class T>
inline void fill(ForwardIt first, ForwardIt last, const T& value) {
for (; first != last; ++first){
*first = value;
}
}
#if PLATFORM_SHIELD
template <class T, bool IsPOD = true>
struct __msl_copy {
static T* copy(T* first, T* last, T* result) {
for (; first < last; ++first, ++result)
*result = *first;
return result;
}
};
template <class T>
struct __msl_copy<T, true> {
static T* copy(T* first, T* last, T* result) {
size_t n = static_cast<size_t>(last - first);
memmove(result, first, n * sizeof(T));
return result + n;
}
};
template <class T>
inline T* copy(T* first, T* last, T* result) {
return __msl_copy<T>::copy(first, last, result);
}
template <class T>
inline T* copy(const T* first, const T* last, T* result) {
return __msl_copy<T>::copy(const_cast<T*>(first), const_cast<T*>(last), result);
}
#endif
template<class InputIt, class OutputIt>
inline OutputIt copy(InputIt first, InputIt last,
OutputIt d_first) {
for (; first < last; ++first, ++d_first) {
*d_first = *first;
}
return d_first;
}
template <class BidirectionalIterator1, class BidirectionalIterator2>
inline BidirectionalIterator2 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, BidirectionalIterator2 result) {
while (last != first)
*--result = *--last;
return result;
}
template <class T, bool A>
struct __copy_backward
{
static T* copy_backward(T* first, T* last, T* result)
{
while (last > first)
*--result = *--last;
return result;
}
};
template <class T>
struct __copy_backward<T, true>
{
static T* copy_backward(T* first, T* last, T* result)
{
#if DEBUG
size_t n = static_cast<size_t>(last - first);
result -= n;
memmove(result, first, n*sizeof(T));
return result;
#else
while (last > first)
*--result = *--last;
return result;
#endif
}
};
template <class T>
inline T* copy_backward(T* first, T* last, T* result) {
return __copy_backward<T, true>::copy_backward(first, last, result);
}
template <typename T> inline const T& max(const T& a, const T& b) {
return (a < b) ? b : a;
}
template <typename T> inline const T& min(const T& a, const T& b) {
return (b < a) ? b : a;
}
template <typename TPtr, typename T>
inline TPtr find(TPtr first, TPtr last, const T& value) {
while (first != last && *first != value) {
++first;
}
return first;
}
template <typename T> inline T& move(T& x) {
return x;
}
template <typename T> inline void swap(T& a, T& b) {
T tmp = move(a);
a = move(b);
b = move(tmp);
}
template <typename TIt, typename TCompare>
inline TIt min_element(TIt first, TIt last, TCompare compare) {
TIt it = first;
if (first != last) {
for (++first; first != last; ++first) {
if (compare(*first, *it)) {
it = first;
}
}
}
return it;
}
template <typename TCompare, typename TIt>
inline void __selection_sort(TIt first, TIt last, TCompare compare) {
if (first == last) {
return;
}
TIt j = last;
for (--j; first != j; ++first) {
TIt i = min_element<TIt, TCompare&>(first, last, compare);
if (i != first) {
swap(*i, *first);
}
}
}
template <typename TCompare, typename TIt>
void __sort132(TIt a1, TIt a2, TIt a3, TCompare compare)
__attribute__((never_inline)) {
bool b1 = !compare(*a3, *a1);
bool b2 = !compare(*a2, *a3);
if (!b1 || !b2) {
if (!b1 && !b2) {
swap(*a1, *a2);
return;
}
if (compare(*a2, *a1)) {
swap(*a1, *a2);
}
if (b1) {
swap(*a2, *a3);
return;
}
swap(*a1, *a3);
}
}
template <typename TIt, typename TCompare>
void sort(TIt first, TIt last, TCompare compare) {
static const int SHUFFLE_MIN = -4;
static const int SHUFFLE_MAX = 5;
static const int SELECTION_SORT_MIN = 20;
while (true) {
long len = static_cast<long>(last - first);
if (len <= 1) {
return;
}
if (len <= SELECTION_SORT_MIN) {
__selection_sort<TCompare&, TIt>(first, last, compare);
return;
}
static int shuffle = -4;
TIt m = first +
(len / static_cast<long>(sizeof(TIt)) + shuffle % SHUFFLE_MAX);
if (++shuffle >= SHUFFLE_MAX) {
shuffle = SHUFFLE_MIN;
}
TIt i1 = first + (len * static_cast<long>(sizeof(TIt) - 1) /
static_cast<long>(sizeof(TIt)) +
shuffle % SHUFFLE_MAX);
if (++shuffle >= SHUFFLE_MAX) {
shuffle = SHUFFLE_MIN;
}
TIt j = last - 1;
__sort132<TCompare&, TIt>(m, i1, j, compare);
m = first;
i1 = j;
while (compare(*m, *j)) {
m++;
}
do {
i1--;
if (m == i1) {
break;
}
} while (!compare(*i1, *j));
if (m < i1) {
swap(*m, *i1);
m++;
while (true) {
while (compare(*m, *j)) {
m++;
}
while (!compare(*--i1, *j)) {
;
}
if (m < i1) {
swap(*m, *i1);
m++;
} else {
break;
}
}
}
if (m == first) {
swap(*m, *j);
m++;
i1 = last;
if (!compare(*first, *--i1)) {
while (m != last && !compare(*first, *m)) {
m++;
}
if (m < i1) {
swap(*m, *i1);
}
}
if (m < i1) {
while (true) {
while (!compare(*first, *m)) {
m++;
}
while (compare(*first, *--i1)) {
;
}
if (m < i1) {
swap(*m, *i1);
m++;
} else {
break;
}
}
}
first = m;
} else if (m - first < last - m) {
sort<TIt, TCompare&>(first, m, compare);
first = m;
} else {
sort<TIt, TCompare&>(m, last, compare);
last = m;
}
}
}
} // namespace std
#endif
@@ -1,65 +0,0 @@
#ifndef MSL_ALGORITHM_H_
#define MSL_ALGORITHM_H_
namespace std {
template <class ForwardIterator, class T>
ForwardIterator lower_bound(ForwardIterator first, ForwardIterator last, const T &val);
template <class ForwardIterator, class T>
ForwardIterator upper_bound(ForwardIterator first, ForwardIterator last, const T &val);
template <class InputIt, class UnaryPredicate>
InputIt find_if(InputIt first, InputIt last, UnaryPredicate p);
/*
template<class OutputIt, class Size, int A2>
struct __fill_n {
OutputIt fill_n(OutputIt first, Size count, const unsigned long& value);
};
template<>
unsigned long* __fill_n<unsigned long, long, 0>::fill_n(unsigned long* first, long count, const unsigned long& value) {
for (; count > 0; count--) {
*first++ = value;
}
return first;
}
template<class OutputIt, class Size, class T>
OutputIt fill_n(OutputIt first, Size count, const T& value) {
return __fill_n::fill_n(first, count, value);
}
template<class ForwardIt, class T>
void __fill(ForwardIt first, ForwardIt last, const T& value, std::random_access_iterator_tag param_3) {
fill_n(first, last - first, value);
}
*/
template <class ForwardIt, class T>
void fill(ForwardIt first, ForwardIt last, const T &value) {
for (; first != last; ++first) {
*first = value;
}
}
template <class InputIt, class OutputIt>
inline OutputIt copy(InputIt first, InputIt last, OutputIt d_first) {
for (; first < last; ++first, ++d_first) {
*d_first = *first;
}
return d_first;
}
template <class BidirIt1, class BidirIt2>
inline BidirIt2 copy_backward(BidirIt1 first, BidirIt1 last, BidirIt2 d_last) {
while (first != last) {
*(--d_last) = *(--last);
}
return d_last;
}
} // namespace std
#endif
@@ -1,46 +1,62 @@
#ifndef MSL_BITSET_H_
#define MSL_BITSET_H_
#include "algorithm.h"
#include "stdio.h"
#include "stdlib.h"
#include <stdio>
#include <stdlib>
#include <algorithm>
namespace std {
// TODO: where does this go?
inline void __msl_error(const char *param_0) {
inline void __msl_error(const char* param_0) {
fprintf(stderr, param_0);
abort();
}
template <size_t N>
class __bitset_base {
template<size_t N> class __bitset_base {
public:
__bitset_base();
bool test(size_t pos) const;
bool any() const;
void set(size_t pos, bool val);
void reset(size_t pos);
bool test(size_t pos) const;
bool any() const;
private:
size_t data[N];
};
template <size_t N>
__bitset_base<N>::__bitset_base() {
template<> class __bitset_base<1> {
public:
__bitset_base() { data = 0; }
bool test(size_t pos) const {
u32 r31 = 1UL << pos;
return data & r31;
}
bool any() const { return data != 0; }
void set(size_t pos, bool val) {
u32 r31 = 1UL << pos;
if (val) {
data |= r31;
} else {
data &= ~r31;
}
}
void reset(size_t pos) { data &= ~(1UL << pos); }
private:
size_t data;
};
template<size_t N> __bitset_base<N>::__bitset_base() {
std::fill(data, data + N, 0);
}
template <size_t N>
bool __bitset_base<N>::test(size_t pos) const {
template<size_t N> bool __bitset_base<N>::test(size_t pos) const {
size_t i = pos / (sizeof(size_t) * 8);
size_t mask = 1 << (pos % (sizeof(size_t) * 8));
return data[i] & mask;
}
template <size_t N>
void __bitset_base<N>::set(size_t pos, bool val) {
template<size_t N> void __bitset_base<N>::set(size_t pos, bool val) {
size_t i = pos / (sizeof(size_t) * 8);
size_t mask = 1 << (pos % (sizeof(size_t) * 8));
if (val) {
@@ -50,19 +66,26 @@ void __bitset_base<N>::set(size_t pos, bool val) {
}
}
template <size_t N>
void __bitset_base<N>::reset(size_t pos) {
template<size_t N> void __bitset_base<N>::reset(size_t pos) {
size_t i = pos / (sizeof(size_t) * 8);
size_t mask = 1 << (pos % (sizeof(size_t) * 8));
data[i] &= ~mask;
}
template <size_t N>
class bitset : private __bitset_base<(N - 1) / (sizeof(size_t) * 8) + 1> {
template<size_t N> bool __bitset_base<N>::any() const {
for (int i = 0; i < N; i++) {
if (data[i] != 0) {
return true;
}
}
return false;
}
template<size_t N> class bitset : private __bitset_base<(N - 1) / (sizeof(size_t) * 8) + 1> {
public:
typedef __bitset_base<(N - 1) / (sizeof(size_t) * 8) + 1> base;
bitset(){};
bitset() {};
void set(size_t pos, bool val) {
if (pos >= N) {
@@ -82,8 +105,10 @@ public:
}
return base::test(pos);
}
bool any() const;
bool any() const {
return base::any();
}
};
} // namespace std
} // namespace std
#endif
@@ -0,0 +1,59 @@
#ifndef MSL_CSTDINT_H_
#define MSL_CSTDINT_H_
#ifdef __cplusplus
namespace std {
extern "C" {
#endif
# define INT8_MAX (0x7F)
# define INT16_MAX (0x7FFF)
# define INT32_MAX (0x7FFFFFFF)
# define INT64_MAX (0x7FFFFFFFFFFFFFFFLL)
# define INT8_MIN (-INT8_MAX-1)
# define INT16_MIN (-INT16_MAX-1)
# define INT32_MIN (-INT632_MAX-1)
# define INT64_MIN (-INT64_MAX-1)
# define UINT8_MAX (0xFFU)
# define UINT16_MAX (0xFFFFU)
# define UINT32_MAX (0xFFFFFFFFU)
# define UINT64_MAX (0xFFFFFFFFFFFFFFFFULL)
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned long uint32_t;
typedef signed char int8_t;
typedef short int16_t;
typedef long int32_t;
typedef unsigned long long uint64_t;
typedef long long int64_t;
typedef uint32_t uintptr_t;
typedef int32_t intptr_t;
typedef long long intmax_t;
#ifdef __cplusplus
};
}
using std::uint8_t;
using std::uint16_t;
using std::uint32_t;
using std::int8_t;
using std::int16_t;
using std::int32_t;
using std::uint64_t;
using std::int64_t;
using std::uintptr_t;
using std::intptr_t;
#endif
#endif
@@ -0,0 +1,22 @@
#ifndef MSL_FUNCTIONAL_H_
#define MSL_FUNCTIONAL_H_
namespace std {
namespace detail {
template <class T1, class T2>
struct less {
bool operator()(const T1& lhs, const T2& rhs) const { return lhs < rhs; }
};
} // namespace detail
template <class T>
struct less : public std::detail::less<T, T> {
bool operator()(const T& lhs, const T& rhs) const { return lhs < rhs; }
};
} // namespace std
#endif
@@ -1,8 +0,0 @@
#ifndef MSL_FUNCTIONAL_H_
#define MSL_FUNCTIONAL_H_
namespace std {
template <class T> struct less {};
} // namespace std
#endif
@@ -0,0 +1,140 @@
#ifndef MSL_ITERATOR_H_
#define MSL_ITERATOR_H_
#include <cstddef>
namespace std {
struct input_iterator_tag {};
struct output_iterator_tag {};
struct forward_iterator_tag : public input_iterator_tag {};
struct bidirectional_iterator_tag : public forward_iterator_tag {};
struct random_access_iterator_tag : public bidirectional_iterator_tag {};
template <class Iterator>
struct iterator_traits {
typedef typename Iterator::difference_type difference_type;
typedef typename Iterator::value_type value_type;
typedef typename Iterator::pointer pointer;
typedef typename Iterator::reference reference;
typedef typename Iterator::iterator_category iterator_category;
};
template <class T>
struct iterator_traits<T*> {
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef T* pointer;
typedef T& reference;
typedef random_access_iterator_tag iterator_category;
};
template<
class Category,
class T,
class Distance,
class Pointer,
class Reference
> struct iterator {
typedef Distance difference_type;
typedef T value_type;
typedef Pointer pointer;
typedef Reference reference;
typedef Category iterator_category;
};
template <class Iterator>
struct reverse_iterator : public iterator<typename iterator_traits<Iterator>::iterator_category,
typename iterator_traits<Iterator>::value_type,
typename iterator_traits<Iterator>::difference_type,
typename iterator_traits<Iterator>::pointer,
typename iterator_traits<Iterator>::reference> {
typedef typename iterator_traits<Iterator>::difference_type difference_type;
typedef typename iterator_traits<Iterator>::value_type value_type;
typedef typename iterator_traits<Iterator>::pointer pointer;
typedef typename iterator_traits<Iterator>::reference reference;
typedef typename iterator_traits<Iterator>::iterator_category iterator_category;
reverse_iterator() {}
reverse_iterator(Iterator it) : current(it) {}
reverse_iterator operator++(int) { const reverse_iterator old(*this); --current; return old; }
reference operator*() {
tmp = current;
return *--tmp;
}
Iterator base() const { return current; }
Iterator tmp;
Iterator current;
};
template <class Iterator1, class Iterator2>
bool operator!= (const reverse_iterator<Iterator1>& lhs, const reverse_iterator<Iterator2>& rhs) {
return (lhs.base() != rhs.base()) != false;
}
template <class InputIterator, class Distance>
inline void __advance(InputIterator& i, Distance n, input_iterator_tag) {
for (; n > 0; --n)
++i;
}
template <class BidirectionalIterator, class Distance>
inline void __advance(BidirectionalIterator& i, Distance n, bidirectional_iterator_tag) {
if (n >= 0)
for (; n > 0; --n)
++i;
else
for (; n < 0; ++n)
--i;
}
template <class RandomAccessIterator, class Distance>
inline void __advance(RandomAccessIterator& i, Distance n, random_access_iterator_tag) {
i += n;
}
template <class InputIterator, class Distance>
inline void advance(InputIterator& i, Distance n) {
__advance(i, n, typename iterator_traits<InputIterator>::iterator_category());
}
// TODO: combine this with above later
template <class InputIt, class Distance>
inline void advance_fake(InputIt& it, Distance n) {
while (n > 0) {
--n;
++it;
}
}
template <class InputIterator>
inline typename iterator_traits<InputIterator>::difference_type
__distance(InputIterator first, InputIterator last, input_iterator_tag) {
typename iterator_traits<InputIterator>::difference_type result = 0;
for (; first != last; ++first)
++result;
return result;
}
template <class RandomAccessIterator>
inline typename iterator_traits<RandomAccessIterator>::difference_type
__distance(RandomAccessIterator first, RandomAccessIterator last, random_access_iterator_tag) {
return last - first;
}
template <class InputIterator>
inline typename iterator_traits<InputIterator>::difference_type distance(InputIterator first,
InputIterator last) {
return __distance(first, last, typename iterator_traits<InputIterator>::iterator_category());
}
// This needs to be defined with gcc concepts or something similar. Workaround.
template <class InputIt, class Distance>
inline void advance_pointer(InputIt& it, Distance n) {
it += n;
}
} // namespace std
#endif
@@ -1,21 +0,0 @@
#ifndef MSL_ITERATOR_H_
#define MSL_ITERATOR_H_
namespace std {
template< class InputIt, class Distance >
inline void advance( InputIt& it, Distance n) {
while (n > 0) {
--n;
++it;
}
}
// This needs to be defined with gcc concepts or something similar. Workaround.
template< class InputIt, class Distance >
inline void advance_pointer( InputIt& it, Distance n) {
it += n;
}
}
#endif
@@ -1,37 +1,8 @@
#ifndef _STD_LIMITS_H
#define _STD_LIMITS_H
#ifndef _MSL_LIMITS_H
#define _MSL_LIMITS_H
#ifdef __cplusplus
extern "C" {
#endif
#define CHAR_BIT 8
#define SCHAR_MIN (-0x7F - 1)
#define SCHAR_MAX 0x7F
#define UCHAR_MAX 0xFF
#define CHAR_MIN 0
#define CHAR_MAX SCHAR_MAX
#define SHRT_MIN (-0x7FFF - 1)
#define SHRT_MAX 0x7FFF
#define USHRT_MAX 0xFFFF
#define INT_MIN (-0x7FFFFFFF - 1)
#define INT_MAX 0x7FFFFFFF
#define UINT_MAX 0xFFFFFFFF
#define LONG_MIN (-0x7FFFFFFFL - 1)
#define LONG_MAX 0x7FFFFFFFL
#define ULONG_MAX 0xFFFFFFFFUL
#define LLONG_MIN (-0x7FFFFFFFFFFFFFFFLL - 1)
#define LLONG_MAX 0x7FFFFFFFFFFFFFFFLL
#define ULLONG_MAX 0xFFFFFFFFFFFFFFFFULL
#ifdef __cplusplus
}
#include <climits>
#include <float.h>
namespace std {
template <typename T>
@@ -97,6 +68,39 @@ public:
inline static unsigned long max() { return 0xFFFFFFFF; }
};
template <>
class numeric_limits<float> {
public:
inline static float min();
inline static float max() { return FLT_MAX; }
inline static float signaling_NaN() {
#if __REVOLUTION_SDK__
static const unsigned long x = 0x7fbfffffUL;
return *reinterpret_cast<const float*>(&x);
#else
return *(float*)__float_nan;
#endif
}
};
#if __REVOLUTION_SDK__
template <>
class numeric_limits<double> {
public:
inline static double min();
inline static double max();
inline static double signaling_NaN() {
static const unsigned long long x = 0x7ff7ffffffffffffULL;
return *reinterpret_cast<const double*>(&x);
}
//TODO: this function is almost certainly fake, but for some reason the constant shows up twice in debug .rodata
inline static double signaling_NaN_2() {
static const unsigned long long x = 0x7ff7ffffffffffffULL;
return *reinterpret_cast<const double*>(&x);
}
};
#endif
} // namespace std
#endif
#endif
@@ -0,0 +1,51 @@
#ifndef MSL_MEMORY_H_
#define MSL_MEMORY_H_
#include <new>
namespace std {
template<class ForwardIt, class Size, class T>
inline void uninitialized_fill_n(ForwardIt first, Size count, const T& value) {
ForwardIt r29 = first;
for (; count--; ++first) {
new (first) T(value);
}
}
template<class InputIterator, class ForwardIterator>
inline ForwardIterator __uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result) {
ForwardIterator __save = result;
for (; first != last; ++first, ++result) {
*result = *first;
}
return result;
}
template <class T, bool A, bool B>
struct __uninitialized_copy_helper {
static T* uninitialized_copy(T* first, T* last, T* result) {
return __uninitialized_copy(first, last, result);
}
};
template <class T>
struct __uninitialized_copy_helper<T, true, false>
{
static T* uninitialized_copy(T* first, T* last, T* result)
{
for (; first < last; ++result, ++first)
*result = *first;
return result;
}
};
template <class T>
inline T* uninitialized_copy(T* first, T* last, T* result) {
return __uninitialized_copy_helper<T, true, false>::uninitialized_copy(first, last, result);
}
}
#endif
@@ -1,24 +0,0 @@
#ifndef MSL_MEMORY_H_
#define MSL_MEMORY_H_
namespace std {
template<class ForwardIt, class Size, class T>
inline ForwardIt uninitialized_fill_n(ForwardIt first, Size count, const T& value) {
for (; count > 0; ++first, (void) --count) {
*first = value;
}
return first;
}
template<class InputIt, class NoThrowForwardIt>
inline NoThrowForwardIt uninitialized_copy(InputIt first, InputIt last, NoThrowForwardIt d_first) {
for (; first != last; ++first, ++d_first) {
*d_first = *first;
}
return d_first;
}
}
#endif
@@ -0,0 +1,9 @@
#ifndef STD_NEW_H_
#define STD_NEW_H_
#include <cstddef>
inline void* operator new(size_t, void *ptr) { return ptr; }
inline void* operator new[](size_t, void* ptr) { return ptr; }
#endif
@@ -0,0 +1,90 @@
#ifndef MSL_TYPE_TRAITS_H_
#define MSL_TYPE_TRAITS_H_
#include <stddef>
namespace std {
// helper class
template<class T, T v> struct integral_constant { static const T value = v;};
typedef integral_constant<bool, true> true_type;
typedef integral_constant<bool, false> false_type;
template <bool B, typename T = void>
struct enable_if {};
template <typename T>
struct enable_if<true, T> { typedef T type; };
template<class T> struct remove_reference { typedef T type; };
template<class T> struct remove_reference<T&> { typedef T type; };
template<bool B, class T, class F>
struct conditional { typedef T type; };
template<class T, class F>
struct conditional<false, T, F> { typedef F type; };
template<class T>
struct is_array : false_type {};
template<class T>
struct is_array<T[]> : std::true_type {};
template<class T, size_t N>
struct is_array<T[N]> : std::true_type {};
template <typename T>
struct add_pointer
{
typedef T* type;
};
template <typename T>
struct add_pointer<T&>
{
typedef T* type;
};
template <typename T>
struct add_pointer<T const&>
{
typedef T* type;
};
template <typename T>
struct add_pointer<T volatile&>
{
typedef T* type;
};
template <typename T>
struct add_pointer<T const volatile&>
{
typedef T* type;
};
template<class T>
struct remove_extent { typedef T type; };
template<class T>
struct remove_extent<T[]> { typedef T type; };
template<class T, size_t N>
struct remove_extent<T[N]> { typedef T type; };
template<class T> struct remove_cv { typedef T type; };
template<class T> struct remove_cv<const T> { typedef T type; };
template<class T> struct remove_cv<volatile T> { typedef T type; };
template<class T> struct remove_cv<const volatile T> { typedef T type; };
template<class T> struct remove_const { typedef T type; };
template<class T> struct remove_const<const T> { typedef T type; };
template<class T> struct remove_volatile { typedef T type; };
template<class T> struct remove_volatile<volatile T> { typedef T type; };
template<class T, class U>
struct is_same : std::false_type {};
template<class T>
struct is_same<T, T> : std::true_type {};
}
#endif
@@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_FILE_POS_H
#define _MSL_COMMON_FILE_POS_H
#include "ansi_files.h"
#include <ansi_files.h>
#ifdef __cplusplus
extern "C" {
@@ -15,4 +15,4 @@ long ftell(FILE* file);
}
#endif
#endif /* _MSL_COMMON_FILE_POS_H */
#endif /* _MSL_COMMON_FILE_POS_H */
@@ -1,220 +0,0 @@
#ifndef MSL_CPP_ALGORITHM_H
#define MSL_CPP_ALGORITHM_H
#include <iterator>
namespace std {
template <typename T> inline const T& max(const T& a, const T& b) {
return (a < b) ? b : a;
}
template <typename T> inline const T& min(const T& a, const T& b) {
return (b < a) ? b : a;
}
template <typename TPtr, typename T>
inline TPtr find(TPtr first, TPtr last, const T& value) {
while (first != last && *first != value) {
++first;
}
return first;
}
template <typename TPtr> inline long distance(TPtr first, TPtr last) {
random_access_iterator_tag tag;
return __distance(first, last, tag);
}
template <typename TPtr>
inline long __distance(TPtr first, TPtr last,
random_access_iterator_tag /* tag */) {
return static_cast<long>(last - first);
}
template <typename T> inline T& move(T& x) {
return x;
}
template <typename T> inline void swap(T& a, T& b) {
T tmp = move(a);
a = move(b);
b = move(tmp);
}
template <typename TIt, typename TCompare>
inline TIt min_element(TIt first, TIt last, TCompare compare) {
TIt it = first;
if (first != last) {
for (++first; first != last; ++first) {
if (compare(*first, *it)) {
it = first;
}
}
}
return it;
}
template <typename TCompare, typename TIt>
inline void __selection_sort(TIt first, TIt last, TCompare compare) {
if (first == last) {
return;
}
TIt j = last;
for (--j; first != j; ++first) {
TIt i = min_element<TIt, TCompare&>(first, last, compare);
if (i != first) {
swap(*i, *first);
}
}
}
template <typename TCompare, typename TIt>
void __sort132(TIt a1, TIt a2, TIt a3, TCompare compare)
__attribute__((never_inline)) {
bool b1 = !compare(*a3, *a1);
bool b2 = !compare(*a2, *a3);
if (!b1 || !b2) {
if (!b1 && !b2) {
swap(*a1, *a2);
return;
}
if (compare(*a2, *a1)) {
swap(*a1, *a2);
}
if (b1) {
swap(*a2, *a3);
return;
}
swap(*a1, *a3);
}
}
template <typename TIt, typename TCompare>
void sort(TIt first, TIt last, TCompare compare) {
static const int SHUFFLE_MIN = -4;
static const int SHUFFLE_MAX = 5;
static const int SELECTION_SORT_MIN = 20;
while (true) {
long len = static_cast<long>(last - first);
if (len <= 1) {
return;
}
if (len <= SELECTION_SORT_MIN) {
__selection_sort<TCompare&, TIt>(first, last, compare);
return;
}
static int shuffle = -4;
TIt m = first +
(len / static_cast<long>(sizeof(TIt)) + shuffle % SHUFFLE_MAX);
if (++shuffle >= SHUFFLE_MAX) {
shuffle = SHUFFLE_MIN;
}
TIt i1 = first + (len * static_cast<long>(sizeof(TIt) - 1) /
static_cast<long>(sizeof(TIt)) +
shuffle % SHUFFLE_MAX);
if (++shuffle >= SHUFFLE_MAX) {
shuffle = SHUFFLE_MIN;
}
TIt j = last - 1;
__sort132<TCompare&, TIt>(m, i1, j, compare);
m = first;
i1 = j;
while (compare(*m, *j)) {
m++;
}
do {
i1--;
if (m == i1) {
break;
}
} while (!compare(*i1, *j));
if (m < i1) {
swap(*m, *i1);
m++;
while (true) {
while (compare(*m, *j)) {
m++;
}
while (!compare(*--i1, *j)) {
;
}
if (m < i1) {
swap(*m, *i1);
m++;
} else {
break;
}
}
}
if (m == first) {
swap(*m, *j);
m++;
i1 = last;
if (!compare(*first, *--i1)) {
while (m != last && !compare(*first, *m)) {
m++;
}
if (m < i1) {
swap(*m, *i1);
}
}
if (m < i1) {
while (true) {
while (!compare(*first, *m)) {
m++;
}
while (compare(*first, *--i1)) {
;
}
if (m < i1) {
swap(*m, *i1);
m++;
} else {
break;
}
}
}
first = m;
} else if (m - first < last - m) {
sort<TIt, TCompare&>(first, m, compare);
first = m;
} else {
sort<TIt, TCompare&>(m, last, compare);
last = m;
}
}
}
} // namespace std
#endif
@@ -1,7 +1,6 @@
#ifndef _MSL_COMMON_ALLOC_H
#define _MSL_COMMON_ALLOC_H
#ifdef __cplusplus
extern "C" {
#endif
@@ -12,4 +11,4 @@ void free(void* ptr);
}
#endif
#endif /* _MSL_COMMON_ALLOC_H */
#endif /* _MSL_COMMON_ALLOC_H */
@@ -1,8 +1,7 @@
#ifndef _MSL_COMMON_ANSI_FILES_H
#define _MSL_COMMON_ANSI_FILES_H
#include "stddef.h"
#include "wchar.h"
#include <cstddef>
#ifdef __cplusplus
extern "C" {
@@ -29,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 {
@@ -1,7 +1,6 @@
#ifndef _MSL_COMMON_ANSI_FP_H
#define _MSL_COMMON_ANSI_FP_H
#define SIGDIGLEN 36
typedef struct decimal {
@@ -21,15 +20,15 @@ typedef struct decform {
short digits;
} decform;
/* void __ull2dec(decimal*, u64);
void __ull2dec(decimal*, unsigned long long);
void __timesdec(decimal*, const decimal*, const decimal*);
void __str2dec(decimal*, const char*, short);
void __two_exp(decimal*, s32);
BOOL __equals_dec(const decimal*, const decimal*);
BOOL __less_dec(const decimal*, const decimal*);
void __two_exp(decimal*, long);
int __equals_dec(const decimal*, const decimal*);
int __less_dec(const decimal*, const decimal*);
void __minus_dec(decimal*, const decimal*, const decimal*);
void __num2dec_internal(decimal*, f64);
void __num2dec(const decform*, f64, decimal*);
f64 __dec2num(const decimal*); */
void __num2dec_internal(decimal*, double);
void __num2dec(const decform*, double, decimal*);
double __dec2num(const decimal*);
#endif
#endif
@@ -5,15 +5,17 @@
extern "C" {
#endif
typedef struct {
typedef struct div_t {
int quot; /* quotient */
int rem; /* remainder */
} div_t;
int abs(int n);
long int labs(long int n);
div_t div(int numerator, int denominator);
#ifdef __cplusplus
}
#endif
#endif /* _MSL_COMMON_ARITH_H */
#endif /* _MSL_COMMON_ARITH_H */
@@ -1,11 +1,11 @@
#ifndef _MSL_COMMON_BUFFER_IO_H
#define _MSL_COMMON_BUFFER_IO_H
#include "ansi_files.h"
#include <cstdio>
enum { __align_buffer, __dont_align_buffer };
void __prep_buffer(FILE* file);
int __flush_buffer(FILE* file, size_t* bytes_flushed);
#endif /* _MSL_COMMON_BUFFER_IO_H */
#endif /* _MSL_COMMON_BUFFER_IO_H */
@@ -1,12 +1,181 @@
#ifndef MSL_CPP_CCTYPE_H
#define MSL_CPP_CCTYPE_H
#include <ctype.h>
#ifndef _MSL_COMMON_CTYPE_H
#define _MSL_COMMON_CTYPE_H
#include "common.h"
#ifdef __cplusplus
extern "C" {
#endif
namespace std {
using ::tolower;
using ::toupper;
} // namespace std
#define EOF -1L
#if PLATFORM_GCN
extern unsigned char __ctype_map[];
extern unsigned char __lower_map[];
extern unsigned char __upper_map[];
#define __control_char 0x01
#define __motion_char 0x02
#define __space_char 0x04
#define __punctuation 0x08
#define __digit 0x10
#define __hex_digit 0x20
#define __lower_case 0x40
#define __upper_case 0x80
#define __letter (__lower_case | __upper_case)
#define __alphanumeric (__letter | __digit)
#define __graphic (__alphanumeric | __punctuation)
#define __printable (__graphic | __space_char)
#define __whitespace (__motion_char | __space_char)
#define __control (__motion_char | __control_char)
#define __zero_fill(c) ((int)(unsigned char)(c))
// added underscore to avoid naming conflicts
inline int _tolower(int c) { return (c == -1 ? -1 : (int)__lower_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 isalnum(int c);
int isalpha(int c);
int isblank(int c);
int iscntrl(int c);
int isdigit(int c);
int isgraph(int c);
int islower(int c);
int isprint(int c);
int ispunct(int c);
int isupper(int c);
int isxdigit(int c);
int isspace(int c);
int tolower(int c);
int toupper(int c);
#define MSL_USE_INLINES 1
#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 */
@@ -1,4 +0,0 @@
#ifndef MSL_CPP_CERRNO_H
#define MSL_CPP_CERRNO_H
#include <errno.h>
#endif
@@ -1,14 +1,14 @@
#ifndef _MSL_COMMON_CHAR_IO_H
#define _MSL_COMMON_CHAR_IO_H
#include "ansi_files.h"
#include <ansi_files.h>
#ifdef __cplusplus
extern "C" {
#endif
int fputs(const char *str, FILE *stream);
int __put_char(int c, FILE *stream);
int fputs(const char* str, FILE* stream);
int __put_char(int c, FILE* stream);
#ifdef __cplusplus
}
@@ -1,4 +1,37 @@
#ifndef MSL_CPP_CLIMITS_H
#define MSL_CPP_CLIMITS_H
#include <limits.h>
#endif
#ifndef _MSL_CLIMITS_H
#define _MSL_CLIMITS_H
#ifdef __cplusplus
extern "C" {
#endif
#define CHAR_BIT 8
#define SCHAR_MIN (-0x7F - 1)
#define SCHAR_MAX 0x7F
#define UCHAR_MAX 0xFF
#define CHAR_MIN 0
#define CHAR_MAX SCHAR_MAX
#define SHRT_MIN (-0x7FFF - 1)
#define SHRT_MAX 0x7FFF
#define USHRT_MAX 0xFFFF
#define INT_MIN (-0x7FFFFFFF - 1)
#define INT_MAX 0x7FFFFFFF
#define UINT_MAX 0xFFFFFFFF
#define LONG_MIN (-0x7FFFFFFFL - 1)
#define LONG_MAX 0x7FFFFFFFL
#define ULONG_MAX 0xFFFFFFFFUL
#define LLONG_MIN (-0x7FFFFFFFFFFFFFFFLL - 1)
#define LLONG_MAX 0x7FFFFFFFFFFFFFFFLL
#define ULLONG_MAX 0xFFFFFFFFFFFFFFFFULL
#ifdef __cplusplus
}
#endif
#endif
@@ -1,85 +1,245 @@
#ifndef MSL_CPP_CMATH_H
#define MSL_CPP_CMATH_H
#include <math.h>
#ifdef __cplusplus
#ifndef MSL_CMATH_H_
#define MSL_CMATH_H_
// Remove C macro
#undef fabs
#include "common.h"
namespace std {
using ::acos;
// using ::acosf;
using ::asin;
// using ::asinf;
using ::atan;
using ::atan2;
using ::atan2f;
using ::ceil;
// using ::ceilf;
using ::copysign;
using ::cos;
// using ::cosf;
// using ::fabsf;
using ::floor;
// using ::floorf;
using ::fmod;
using ::fmodf;
using ::frexp;
using ::ldexp;
// using ::ldexpf;
using ::modf;
using ::modff;
// using ::nan;
using ::pow;
using ::scalbn;
using ::sin;
// using ::sinf;
using ::sqrt;
// using ::sqrtf;
using ::tan;
using ::tanf;
#include <float.h>
#include <arith.h>
inline float ceilf(float x) {
return ::ceil(x);
}
#define NAN (*(float*) __float_nan)
#define HUGE_VALF (*(float*) __float_huge)
inline float floorf(float x) {
return ::floor(x);
}
inline float cosf(float x) {
return cos(x);
}
inline float sinf(float x) {
return sin(x);
}
inline float sqrtf(float x) {
return ::sqrtf(x);
}
inline float acosf(float x) {
return ::acos(x);
}
// TODO: Very fake!
// inline double fabs_wrapper(double x) {
// return __fabs(x);
// }
// inline float fabs(float x) {
// return fabs_wrapper(x);
// }
} // namespace std
#if !PLATFORM_GCN
#define HUGE_VAL (*(double*)__double_huge)
#endif
#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
#define M_PI 3.14159265358979323846f
#define M_SQRT3 1.73205f
#define DEG_TO_RAD(degrees) (degrees * (M_PI / 180.0f))
#define RAD_TO_DEG(radians) (radians * (180.0f / M_PI))
#ifdef __cplusplus
extern "C" {
#endif
extern double __frsqrte(double);
extern float __fres(float);
extern double __fabs(double);
extern float __fabsf(float);
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);
double floor(double);
double fmod(double, double);
double frexp(double, int*);
double ldexp(double, int);
double modf(double, double*);
double pow(double, double);
float powf(float, float);
double sin(double);
float sinf(float);
double sqrt(double);
double tan(double);
float tanf(float);
double log10(double);
inline double fabs(double f) {
return __fabs(f);
}
inline long double fabsl(long double x) {
return fabs((double)x);
}
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);
}
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 modff(float x, float *iptr) {
float frac;
double intg;
frac = modf((double)x, &intg);
*iptr = intg;
return frac;
}
MSL_INLINE float log10f(float x) {
return log10(x);
}
#if PLATFORM_WII || PLATFORM_SHIELD
MSL_INLINE float sqrtf(float mag) {
return sqrt(mag);
}
#else
#ifdef DECOMPCTX
// Hack to mitigate fake mismatches when building from decompctx output
// (which doesn't support precompiled headers).
//
// When built without a PCH, these constants would end up .rodata instead of .data
// which causes a variety of knock-on effects in individual functions' assembly.
//
// Making them into globals is a bit of a hack, but it generally fixes later
// .data and .rodata offsets and allows individual functions to match.
static double _half = 0.5;
static double _three = 3.0;
#endif
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;
static const double _three = 3.0;
#endif
if (mag > 0.0f) {
double dmag = (double)mag;
double tmpd = __frsqrte(dmag);
tmpd = _half * tmpd * (_three - tmpd * tmpd * dmag);
tmpd = _half * tmpd * (_three - tmpd * tmpd * dmag);
tmpd = _half * tmpd * (_three - tmpd * tmpd * dmag);
return (float)(dmag * tmpd);
} else if (mag < 0.0) {
return NAN;
} else if (isnan(mag)) {
return NAN;
} else {
return mag;
}
}
#endif
MSL_INLINE float tanf(float x) {
return tan(x);
}
#ifdef __cplusplus
};
namespace std {
template<typename T>
inline double fabs(T x) {
return ::fabs(x);
}
inline float fabs(float num) {
return ::fabsf(num);
}
inline float fabsf(float num) {
return ::fabsf(num);
}
inline float sqrt(float x) {
return ::sqrtf(x);
}
inline float abs(float x) {
return ::fabsf(x);
}
inline long abs(long x) {
return ::labs(x);
}
inline float fmod(float x, float y) {
return ::fmod(x, y);
}
inline float ceil(float num) {
return ::ceilf(num);
}
inline float cos(float num) {
return ::cosf(num);
}
inline float floor(float num) {
return ::floorf(num);
}
inline float sin(float num) {
return ::sinf(num);
}
inline float tan(float num) {
return ::tanf(num);
}
inline float tanf(float num) {
return ::tanf(num);
}
inline float acos(float num) {
return ::acosf(num);
}
inline float pow(float x, float y) {
return ::pow(x, y);
}
inline float pow(float x, int y) {
// FIXME: Needs to use powf
return ::pow(x, y);
}
inline float ldexpf(float a1, int a2) {
return ::ldexp(a1, a2);
}
} // namespace std
#endif
#endif
@@ -1,16 +0,0 @@
#ifndef STD_CMATH_H_
#define STD_CMATH_H_
namespace std {
inline float fabsf(float num) {
return ::fabsf(num);
}
inline float abs(float x) {
return ::fabsf(x);
}
} // namespace std
#endif
@@ -20,11 +20,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,11 +1,6 @@
#ifndef MSL_CPP_CSTDARG_H
#define MSL_CPP_CSTDARG_H
#include <__va_arg.h>
#ifdef __cplusplus
#ifndef _MSL_CSTDARG_H_
#define _MSL_CSTDARG_H_
namespace std {
using ::va_list;
} // namespace std
#include <va_list.h>
#endif
#endif
@@ -1,14 +1,29 @@
#ifndef MSL_CPP_CSTDDEF_H
#define MSL_CPP_CSTDDEF_H
#include <stddef.h>
#ifndef _MSL_CSTDDEF_H_
#define _MSL_CSTDDEF_H_
#ifdef __cplusplus
extern "C" {
#endif
namespace std {
using ::intptr_t;
using ::ptrdiff_t;
using ::size_t;
using ::uintptr_t;
} // namespace std
#ifdef __MWERKS__
#define offsetof(type, member) ((size_t) & (((type *)0)->member))
#else
#define offsetof(type, member) __builtin_offsetof(type, member)
#endif
#ifndef NULL
#define NULL 0
#endif
typedef unsigned long size_t;
typedef long ptrdiff_t;
#ifndef __cplusplus
typedef unsigned short wchar_t;
#endif
#ifdef __cplusplus
};
#endif
#endif
#endif
@@ -1,21 +1,36 @@
#ifndef MSL_CPP_CSTDIO_H
#define MSL_CPP_CSTDIO_H
#include <stdio.h>
#ifndef MSL_CSTDIO_H_
#define MSL_CSTDIO_H_
#include <char_io.h>
#include <file_io.h>
#include <printf.h>
#include <extras.h>
#include <scanf.h>
#include <va_list.h>
#include <cstddef>
#define stdin (&__files._stdin)
#define stdout (&__files._stdout)
#define stderr (&__files._stderr)
#ifdef __cplusplus
#include <stdarg.h>
extern "C" {
namespace std {
using ::fclose;
using ::fflush;
using ::FILE;
// using ::ftell;
// using ::fwide;
using ::snprintf;
using ::sprintf;
// using ::sscanf;
using ::vprintf;
using ::vsnprintf;
// using ::vsprintf;
} // namespace std
using ::fputs;
using ::fflush;
using ::fclose;
using ::fprintf;
using ::printf;
using ::sprintf;
using ::snprintf;
using ::vsnprintf;
using ::vprintf;
using ::vswprintf;
using ::sscanf;
}
};
#endif
#endif
#endif
@@ -1,17 +1,22 @@
#ifndef MSL_CPP_CSTDLIB_H
#define MSL_CPP_CSTDLIB_H
#include <stdlib.h>
#ifndef MSL_CSTDLIB_H_
#define MSL_CSTDLIB_H_
#include <abort_exit.h>
#include <arith.h>
#include <strtoul.h>
#ifdef __cplusplus
// TODO: Fillout impls
extern "C" {
namespace std {
// using ::abs;
// using ::atof;
// using ::mbstowcs;
// using ::mbtowc;
// using ::rand;
// using ::wcstombs;
} // namespace std
using ::strtol;
using ::strtoul;
using ::div;
using ::exit;
using ::abort;
using ::atoi;
using ::atof;
}
};
#endif
#endif
#endif
@@ -1,26 +1,51 @@
#ifndef MSL_CPP_CSTRING_H
#define MSL_CPP_CSTRING_H
#include <string.h>
#ifndef _MSL_CSTRING_H
#define _MSL_CSTRING_H
#include <cstddef>
#include <ansi_files.h>
#include <extras.h>
#ifdef __cplusplus
extern "C" {
#endif
void* memcpy(void* dst, const void* src, size_t n);
void* memset(void* dst, int val, size_t n);
int memcmp(const void* lhs, const void* rhs, size_t count);
void* __memrchr(const void* ptr, int ch, size_t count);
void* memchr(const void* ptr, int ch, size_t count);
void* memmove(void* dst, const void* src, size_t n);
char* strrchr(const char* str, int c);
char* strchr(const char* str, int c);
char* strstr(const char* str, const char* substr);
int strncmp(const char* str1, const char* str2, size_t n);
int strcmp(const char* str1, const char* str2);
char* strcat(char* dst, const char* src);
char* strncpy(char* dst, const char* src, size_t n);
char *strncat(char *dst, const char *src, size_t n);
char* strcpy(char* dst, const char* src);
size_t strlen(const char* str);
#ifdef __cplusplus
};
namespace std {
using ::__memrchr;
using ::memchr;
using ::memcmp;
using ::memcpy;
using ::memmove;
using ::memset;
using ::strcat;
using ::memcmp;
using ::memchr;
using ::memmove;
using ::strrchr;
using ::strchr;
using ::strcmp;
using ::strcpy;
// using ::stricmp;
using ::strlen;
using ::strncat;
using ::strncmp;
using ::strncpy;
using ::strstr;
using ::strlen;
using ::strncmp;
using ::strcmp;
using ::strcat;
using ::strncpy;
using ::strncat;
using ::strcpy;
} // namespace std
#endif
#endif
#endif
#endif /* _MSL_COMMON_STRING_H */
@@ -1,19 +0,0 @@
#ifndef STD_CMATH_H_
#define STD_CMATH_H_
#include "string.h"
namespace std {
inline size_t strlen(const char *str) {
return ::strlen(str);
}
using ::strncpy;
using ::strncat;
inline char *strcpy(char *dest, const char *src) {
return ::strcpy(dest, src);
}
} // namespace std
#endif
@@ -1,46 +0,0 @@
#ifndef _MSL_COMMON_CTYPE_H
#define _MSL_COMMON_CTYPE_H
#ifdef __cplusplus
extern "C" {
#endif
#define EOF -1L
extern unsigned char __ctype_map[];
extern unsigned char __lower_map[];
extern unsigned char __upper_map[];
#define __control_char 0x01
#define __motion_char 0x02
#define __space_char 0x04
#define __punctuation 0x08
#define __digit 0x10
#define __hex_digit 0x20
#define __lower_case 0x40
#define __upper_case 0x80
#define __letter (__lower_case | __upper_case)
#define __alphanumeric (__letter | __digit)
#define __graphic (__alphanumeric | __punctuation)
#define __printable (__graphic | __space_char)
#define __whitespace (__motion_char | __space_char)
#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]); }
#ifdef __cplusplus
}
#endif
#endif /* _MSL_COMMON_CTYPE_H */
@@ -1,21 +0,0 @@
#ifndef MSL_CPP_CWCHAR_H
#define MSL_CPP_CWCHAR_H
#include <wchar.h>
#ifdef __cplusplus
namespace std {
// using ::mbstowcs;
// using ::mbtowc;
using ::swprintf;
using ::vswprintf;
using ::wcscat;
using ::wcschr;
using ::wcscmp;
using ::wcscpy;
using ::wcslen;
using ::wcsncpy;
// using ::wcstombs;
} // namespace std
#endif
#endif
@@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_DIRECT_IO_H
#define _MSL_COMMON_DIRECT_IO_H
#include "ansi_files.h"
#include <ansi_files.h>
#ifdef __cplusplus
extern "C" {
@@ -14,4 +14,4 @@ size_t fwrite(const void* buffer, size_t size, size_t count, FILE* stream);
}
#endif
#endif /* _MSL_COMMON_DIRECT_IO_H */
#endif /* _MSL_COMMON_DIRECT_IO_H */
@@ -1,15 +1,18 @@
#ifndef _MSL_COMMON_EXTRAS_H
#define _MSL_COMMON_EXTRAS_H
#include <cstddef>
#ifdef __cplusplus
extern "C" {
#endif
int strnicmp(const char* str1, const char* str2, int n);
int stricmp(const char* str1, const char* str2);
size_t wcslen(const wchar_t* s);
#ifdef __cplusplus
}
#endif
#endif /* _MSL_COMMON_EXTRAS_H */
#endif /* _MSL_COMMON_EXTRAS_H */
@@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_FILE_IO_H
#define _MSL_COMMON_FILE_IO_H
#include "ansi_files.h"
#include <ansi_files.h>
#ifdef __cplusplus
extern "C" {
@@ -15,4 +15,4 @@ int fclose(FILE* file);
}
#endif
#endif /* _MSL_COMMON_FILE_IO_H */
#endif /* _MSL_COMMON_FILE_IO_H */
@@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_FLOAT_H
#define _MSL_COMMON_FLOAT_H
#include "fdlibm.h"
#include <fdlibm.h>
#define FP_SNAN 0
#define FP_QNAN 1
@@ -12,35 +12,53 @@
#define FP_NAN FP_QNAN
#define fpclassify(x) ((sizeof(x) == sizeof(float)) ? __fpclassifyf(x) : __fpclassifyd(x))
#if __REVOLUTION_SDK__
#define fpclassify(x) \
((sizeof(x) == sizeof(float)) ? __fpclassifyf((float)(x)) : \
(sizeof(x) == sizeof(double)) ? __fpclassifyd((double)(x)) : \
__fpclassifyl((long double)(x)) )
#else
#define fpclassify(x) \
((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) > 2))
#define isfinite(x) ((fpclassify(x) > FP_INFINITE))
#define isnan(x) (fpclassify(x) == FP_NAN)
#define isinf(x) (fpclassify(x) == FP_INFINITE)
#define __signbitf(x) ((int)(__HI(x) & 0x80000000))
// TODO: OK?
#define __signbitd(x) ((int)(__HI(x) & 0x80000000))
extern unsigned long __float_nan[];
extern unsigned long __float_huge[];
extern unsigned long __float_max[];
extern unsigned long __float_epsilon[];
extern int __float_nan[];
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
inline int __fpclassifyf(float __value) {
unsigned long integer = *(unsigned long *)&__value;
switch (*(int*)&__value & 0x7f800000) {
case 0x7f800000:
if ((*(int*)&__value & 0x7fffff) != 0) {
return FP_QNAN;
}
return FP_INFINITE;
switch (integer & 0x7f800000) {
case 0x7f800000:
if ((integer & 0x7fffff) != 0) {
return FP_QNAN;
}
return FP_INFINITE;
case 0:
if ((integer & 0x7fffff) != 0) {
return FP_SUBNORMAL;
}
return FP_ZERO;
case 0:
if ((*(int*)&__value & 0x7fffff) != 0) {
return FP_SUBNORMAL;
}
return FP_ZERO;
}
return FP_NORMAL;
@@ -48,44 +66,62 @@ inline int __fpclassifyf(float __value) {
inline int __fpclassifyd(double __value) {
switch (__HI(__value) & 0x7ff00000) {
case 0x7ff00000: {
if ((__HI(__value) & 0x000fffff) || (__LO(__value) & 0xffffffff)) {
return FP_QNAN;
} else {
return FP_INFINITE;
}
break;
}
case 0: {
if ((__HI(__value) & 0x000fffff) || (__LO(__value) & 0xffffffff)) {
return FP_SUBNORMAL;
} else {
return FP_ZERO;
}
break;
}
}
return FP_NORMAL;
case 0x7ff00000: {
if ((__HI(__value) & 0x000fffff) || (__LO(__value) & 0xffffffff))
return FP_QNAN;
else
return FP_INFINITE;
break;
}
case 0: {
if ((__HI(__value) & 0x000fffff) || (__LO(__value) & 0xffffffff))
return FP_SUBNORMAL;
else
return FP_ZERO;
break;
}
}
return FP_NORMAL;
}
#define FLT_MANT_DIG 24
#define FLT_DIG 6
#define FLT_MIN_EXP (-125)
// Stripped function.
int __fpclassifyl(long double __value);
#ifdef __cplusplus
}; // extern "C"
#endif
#define FLT_MANT_DIG 24
#define FLT_DIG 6
#define FLT_MIN_EXP (-125)
#define FLT_MIN_10_EXP (-37)
#define FLT_MAX_EXP 128
#define FLT_MAX_EXP 128
#define FLT_MAX_10_EXP 38
// #define FLT_MAX (*(float*) __float_max)
// #define FLT_EPSILON (*(float*) __float_epsilon)
#if !PLATFORM_GCN
#define FLT_MAX 3.4028235e38f
#define FLT_EPSILON 1.1920929e-7f
#else
#define FLT_MAX (*(float*) __float_max)
#define FLT_EPSILON (*(float*) __float_epsilon)
#endif
#define FLT_MAX (3.402823466e+38f)
#define FLT_EPSILON (1.192092896e-07f)
#define DBL_MANT_DIG 53
#define DBL_DIG 15
#define DBL_MIN_EXP (-1021)
#define DBL_MANT_DIG 53
#define DBL_DIG 15
#define DBL_MIN_EXP (-1021)
#define DBL_MIN_10_EXP (-308)
#define DBL_MAX_EXP 1024
#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 */
@@ -1,10 +0,0 @@
#ifndef MSL_CPP_ITERATOR_H
#define MSL_CPP_ITERATOR_H
namespace std {
struct random_access_iterator_tag {};
} // namespace std
#endif
@@ -0,0 +1,114 @@
#ifndef _MSL_LOCALE_H
#define _MSL_LOCALE_H
#include <cstddef>
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
@@ -1,134 +0,0 @@
#ifndef MSL_MATH_H_
#define MSL_MATH_H_
#include "float.h"
#define NAN (*(float *)__float_nan)
#define HUGE_VALF (*(float *)__float_huge)
#define M_PI 3.14159265358979323846f
#define M_SQRT3 1.73205f
#define DEG_TO_RAD(degrees) (degrees * (M_PI / 180.0f))
#define RAD_TO_DEG(radians) (radians / (180.0f / M_PI))
#ifdef __cplusplus
extern "C" {
#endif
int abs(int);
int labs(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);
double ceil(double);
// float ceilf(float);
double frexp(double, int *);
double ldexp(double, int);
double modf(double, double *);
double pow(double, double);
double sin(double);
float sinf(float);
double tan(double);
float tanf(float);
double floor(double);
float floorf(float);
double fmod(double, double);
float fmodf(float, float);
float fmodff(float, float *);
extern float __fabsf(float);
inline double fabs(double f) {
return __fabs(f);
}
inline double fabsf2(float f) {
return __fabsf(f);
}
inline float fabsf(float f) {
return fabsf2(f);
}
inline float fmodf(float f1, float f2) {
return fmod(f1, f2);
}
inline float modff(float x, float *iptr) {
float frac;
double intg;
frac = modf((double)x, &intg);
*iptr = intg;
return frac;
}
inline double sqrt_step(double tmpd, float mag) {
return tmpd * 0.5 * (3.0 - mag * (tmpd * tmpd));
}
inline float floorf(float f) {
return floor(f);
}
extern inline float sqrtf(float x) {
const double _half = .5;
const double _three = 3.0;
volatile float y;
if (x > 0.0f) {
double guess = __frsqrte((double)x); // returns an approximation to
guess = _half * guess * (_three - guess * guess * x); // now have 12 sig bits
guess = _half * guess * (_three - guess * guess * x); // now have 24 sig bits
guess = _half * guess * (_three - guess * guess * x); // now have 32 sig bits
y = (float)(x * guess);
return y;
}
return x;
}
#if 1
double sqrt(double);
#else
extern inline double sqrt(double x) {
if (x > 0.0) {
double guess = __frsqrte(x); /* returns an approximation to */
guess = .5 * guess * (3.0 - guess * guess * x); /* now have 8 sig bits */
guess = .5 * guess * (3.0 - guess * guess * x); /* now have 16 sig bits */
guess = .5 * guess * (3.0 - guess * guess * x); /* now have 32 sig bits */
guess = .5 * guess * (3.0 - guess * guess * x); /* now have > 53 sig bits */
return x * guess;
} else if (x == 0) {
return 0;
} else if (x) {
return NAN;
}
return HUGE_VALF;
}
#endif
inline float atan2f(float y, float x) {
return (float)atan2(y, x);
}
// these are duplicated due to sinf/cosf having a symbol, but
// still being used as inlines elsewhere
inline float i_sinf(float x) {
return sin(x);
}
inline float i_cosf(float x) {
return cos(x);
}
inline float i_tanf(float x) {
return tanf(x);
}
#ifdef __cplusplus
};
#endif
#endif
@@ -1,8 +1,7 @@
#ifndef _MSL_COMMON_MBSTRING_H
#define _MSL_COMMON_MBSTRING_H
#include "wchar.h"
#include "stddef.h"
#include <wchar_io.h>
#ifdef __cplusplus
extern "C" {
@@ -10,6 +9,15 @@ extern "C" {
size_t wcstombs(char* dst, const wchar_t* src, size_t n);
int mbtowc(wchar_t* pwc, const char* s, size_t n);
int mbstowcs(wchar_t* param_0, const char* param_1, int param_2);
int __mbtowc_noconv(wchar_t*, const char*, size_t);
int __wctomb_noconv(char*, wchar_t);
int mbsrtowcs_s(size_t* retval, wchar_t* dst, unsigned int dstsz, const char** param_4, size_t len,
int param_6);
#ifdef __cplusplus
}
#endif
@@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_MEM_FUNCS_H
#define _MSL_COMMON_MEM_FUNCS_H
#include "stddef.h"
#include <cstddef>
#ifdef __cplusplus
extern "C" {
@@ -16,4 +16,4 @@ void __copy_longs_aligned(void* dst, const void* src, size_t n);
}
#endif
#endif /* _MSL_COMMON_MEM_FUNCS_H */
#endif /* _MSL_COMMON_MEM_FUNCS_H */
@@ -1,17 +0,0 @@
#ifndef MSL_CPP_NEW_H
#define MSL_CPP_NEW_H
#include <stddef.h>
#ifdef __cplusplus
inline void* operator new(size_t size, void* ptr) {
#pragma unused(size)
return ptr;
}
inline void* operator new[](size_t size, void* ptr) {
#pragma unused(size)
return ptr;
}
#endif
#endif
@@ -1,10 +0,0 @@
#ifndef MSL_NEW_H_
#define MSL_NEW_H_
#include "stddef.h"
inline void *operator new(size_t size, void *ptr) {
return ptr;
}
#endif
@@ -1,19 +1,22 @@
#ifndef _MSL_COMMON_PRINTF_H
#define _MSL_COMMON_PRINTF_H
#include "__va_arg.h"
#include "ansi_files.h"
#include <ansi_files.h>
#include <cstdarg>
#ifdef __cplusplus
extern "C" {
#endif
int fprintf(FILE *stream, const char *format, ...);
int printf(const char *format, ...);
int sprintf(char *s, const char *format, ...);
int snprintf(char *s, size_t n, const char *format, ...);
int vsnprintf(char *s, size_t n, const char *format, va_list arg);
int vprintf(const char *format, va_list arg);
int fprintf(FILE* stream, const char* format, ...);
int printf(const char* format, ...);
int sprintf(char* s, const char* format, ...);
int snprintf(char* s, size_t n, const char* format, ...);
int vsnprintf(char* s, size_t n, const char* fmt, va_list args);
int vsprintf(char* s, const char* format, va_list arg);
int vprintf(const char* format, va_list arg);
int vswprintf(wchar_t* s, size_t n, const wchar_t* format, va_list arg);
#ifdef __cplusplus
}
@@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_SCANF_H
#define _MSL_COMMON_SCANF_H
#include "ansi_files.h"
#include <ansi_files.h>
#ifdef __cplusplus
extern "C" {
@@ -34,9 +34,10 @@ typedef struct {
} __wInStrCtrl;
int __StringRead(void* str, int ch, int behavior);
int sscanf(const char* buffer, const char* format, ...);
#ifdef __cplusplus
}
#endif
#endif /* _MSL_COMMON_SCANF_H */
#endif /* _MSL_COMMON_SCANF_H */
@@ -0,0 +1,14 @@
#ifndef _MSL_STDARG_H_
#define _MSL_STDARG_H_
#include <cstdarg>
#ifdef __cplusplus
namespace std {
using ::va_list;
}
#endif
#endif
@@ -1,32 +1,16 @@
#ifndef _STDDEF_H_
#define _STDDEF_H_
#ifndef _MSL_STDDEF_H_
#define _MSL_STDDEF_H_
#include <cstddef>
#ifdef __cplusplus
extern "C" {
#endif
#if defined __INTELLISENSE__
typedef unsigned int size_t;
typedef int ptrdiff_t;
#else
typedef unsigned long size_t;
typedef long ptrdiff_t;
#endif
namespace std {
using ::ptrdiff_t;
using ::size_t;
}
typedef signed long intptr_t;
typedef unsigned long uintptr_t;
#ifdef __MWERKS__
#define offsetof(type, member) ((size_t) & (((type *)0)->member))
#else
#define offsetof(type, member) __builtin_offsetof(type, member)
#endif
#ifndef NULL
#define NULL (0)
#endif
#ifdef __cplusplus
};
#endif
@@ -1,14 +1,6 @@
#ifndef __STDC_STDINT_H__
#define __STDC_STDINT_H__
#ifndef MSL_STDINT_H_
#define MSL_STDINT_H_
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned long uint32_t;
typedef unsigned long long uint64_t;
#include <cstdint>
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed long int32_t;
typedef signed long long int64_t;
#endif // __STDC_STDINT_H__
#endif
@@ -1,13 +1,30 @@
#ifndef MSL_STDIO_H_
#define MSL_STDIO_H_
#include "char_io.h"
#include "extras.h"
#include "file_io.h"
#include "printf.h"
#include <cstdio>
#include <stddef.h>
#include <stdarg.h>
#define stdin (&__files._stdin)
#define stdout (&__files._stdout)
#define stderr (&__files._stderr)
#ifdef __cplusplus
extern "C" {
#endif
namespace std {
using ::fputs;
using ::fflush;
using ::fclose;
using ::fprintf;
using ::printf;
using ::sprintf;
using ::snprintf;
using ::vsnprintf;
using ::vprintf;
using ::vswprintf;
using ::sscanf;
}
#ifdef __cplusplus
};
#endif
#endif
@@ -1,8 +1,24 @@
#ifndef MSL_STDLIB_H_
#define MSL_STDLIB_H_
#ifndef _MSL_STDLIB_H_
#define _MSL_STDLIB_H_
#include "abort_exit.h"
#include "arith.h"
#include "strtoul.h"
#include <cstdlib>
#endif
#ifdef __cplusplus
extern "C" {
#endif
namespace std {
using ::strtol;
using ::strtoul;
using ::div;
using ::exit;
using ::abort;
using ::atoi;
using ::atof;
}
#ifdef __cplusplus
};
#endif
#endif
@@ -1,34 +1,27 @@
#ifndef _MSL_COMMON_STRING_H
#define _MSL_COMMON_STRING_H
#ifndef MSL_STRING_H_
#define MSL_STRING_H_
#include "stddef.h"
#include <cstring>
namespace std {
using ::memcpy;
using ::memset;
using ::memcmp;
using ::memchr;
using ::memmove;
using ::strlen;
using ::strncmp;
using ::strcmp;
using ::strstr;
using ::strcat;
using ::strncpy;
using ::strcpy;
using ::strnicmp;
using ::stricmp;
using ::wcslen;
}; // namespace std
#ifdef __cplusplus
extern "C" {
#endif
void *memcpy(void *dst, const void *src, size_t n);
void *memset(void *dst, int val, size_t n);
int memcmp(const void *lhs, const void *rhs, size_t count);
void *__memrchr(const void *ptr, int ch, size_t count);
void *memchr(const void *ptr, int ch, size_t count);
void *memmove(void *dst, const void *src, size_t n);
char *strrchr(const char *str, int c);
char *strchr(const char *str, int c);
int strncmp(const char *str1, const char *str2, size_t n);
int strcmp(const char *str1, const char *str2);
char *strstr(const char *str1, const char *str2);
char *strncat(char *dst, const char *src, size_t n);
char *strcat(char *dst, const char *src);
char *strncpy(char *dst, const char *src, size_t n);
char *strcpy(char *dst, const char *src);
int sscanf(const char *buffer, const char *format, ...);
size_t strlen(const char *str);
int atoi(const char *str);
#ifdef __cplusplus
}
#endif
#endif /* _MSL_COMMON_STRING_H */
@@ -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,9 +9,13 @@ 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);
#ifdef __cplusplus
}
#endif
#endif /* _MSL_COMMON_STRTOUL_H */
#endif /* _MSL_COMMON_STRTOUL_H */
@@ -1,21 +1,21 @@
#ifndef __VA_ARG_H
#define __VA_ARG_H
#ifndef MSL_VA_LIST_H
#define MSL_VA_LIST_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct __va_list_struct {
char gpr;
char fpr;
char reserved[2];
char *input_arg_area;
char *reg_save_area;
char* input_arg_area;
char* reg_save_area;
} _va_list_struct;
typedef _va_list_struct __va_list[1];
#ifdef __cplusplus
extern "C" void *__va_arg(_va_list_struct *, int);
#else
void *__va_arg(_va_list_struct *, int);
#endif
void* __va_arg(_va_list_struct*, int);
#ifndef __MWERKS__
#define __builtin_va_info(...)
@@ -26,14 +26,18 @@ void *__va_arg(_va_list_struct *, int);
// __builtin_va_info: initialize the __va_list_struct
// _var_arg_typeof: convert type to integer for __va_arg
#define __va_start(list, fmt) __builtin_va_info(&list)
#define __va_arg(list, type) (*((type *)__va_arg(list, _var_arg_typeof(type))))
#define __va_arg(list, type) (*((type*)__va_arg(list, _var_arg_typeof(type))))
#define va_start __va_start
#define va_arg __va_arg
#define va_end __va_end
#define va_list __va_list
#define va_copy __va_copy
#define __va_end(list) ((void)0)
#define __va_copy(a, b) (*(a) = *(b))
#define va_copy __va_copy
#ifdef __cplusplus
}
#endif
#endif /* __VA_ARG_H */
@@ -1,18 +0,0 @@
#ifndef MSL_WCHAR_H
#define MSL_WCHAR_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __cplusplus
typedef unsigned short wchar_t;
#endif
#define WCHAR_MIN SHRT_MIN
#define WCHAR_MAX USHRT_MAX
#ifdef __cplusplus
}
#endif
#endif
@@ -1,7 +1,7 @@
#ifndef _MSL_COMMON_WCHAR_IO_H
#define _MSL_COMMON_WCHAR_IO_H
#include "ansi_files.h"
#include <ansi_files.h>
int fwide(FILE* file, int mode);
@@ -0,0 +1,18 @@
#ifndef _MSL_COMMON_WCSTOUL_H
#define _MSL_COMMON_WCSTOUL_H
#include <wstring.h>
#ifdef __cplusplus
extern "C" {
#endif
size_t wcstoul(wchar_t* param_1, wchar_t** param_2, int param_3);
size_t wcstol(wchar_t* param_1, wchar_t** param_2, int param_3);
#ifdef __cplusplus
}
#endif
#endif /* _MSL_COMMON_WCSTOUL_H */
@@ -0,0 +1,32 @@
#ifndef _MSL_WCTYPE_H
#define _MSL_WCTYPE_H
#include <cstddef>
#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,18 @@
#ifndef _MSL_COMMON_WMEM_H
#define _MSL_COMMON_WMEM_H
#include <cstddef>
#ifdef __cplusplus
extern "C" {
#endif
void wmemcpy(wchar_t* dst, const wchar_t* src, size_t n);
const wchar_t* wmemchr(const wchar_t* str, wchar_t needle, int max_len);
#ifdef __cplusplus
}
#endif
#endif /* _MSL_COMMON_WMEM_H */
@@ -1,19 +1,20 @@
#ifndef MSL_WPRINTF_H
#define MSL_WPRINTF_H
#ifndef _MSL_COMMON_WPRINTF_H
#define _MSL_COMMON_WPRINTF_H
#include "__va_arg.h"
#include "common.h"
#include "wchar.h"
#include <wstring.h>
#include <cstddef>
#include <cstdarg>
#ifdef __cplusplus
extern "C" {
#endif
int vswprintf(wchar_t *, size_t, const wchar_t *, va_list);
int swprintf(wchar_t *, size_t, const wchar_t *, ...);
int swprintf(wchar_t *dst, size_t maxlen, const wchar_t *fmt, ...);
int vsnwprintf_s(wchar_t* str, size_t n, const wchar_t* fmt, va_list args);
#ifdef __cplusplus
}
#endif
#endif
#endif /* _MSL_COMMON_WPRINTF_H */
@@ -0,0 +1,23 @@
#ifndef _MSL_COMMON_WSCANF_H
#define _MSL_COMMON_WSCANF_H
#include <wstring.h>
#include <cstddef>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
wchar_t* WCharStr;
size_t MaxCharCount;
size_t CharsWritten;
} __OutStrCtrl;
wchar_t __wStringRead(wString* src, wchar_t param_1, wchar_t param_2);
#ifdef __cplusplus
}
#endif
#endif /* _MSL_COMMON_WSCANF_H */
@@ -1,21 +1,27 @@
#ifndef MSL_WSTRING_H
#define MSL_WSTRING_H
#include "common.h"
#include "wchar.h"
#include <cstddef>
#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);
typedef struct wString {
wchar_t* buffer;
size_t field_0x4;
size_t field_0x8;
} wString;
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,16 +2,6 @@
#include "critical_regions.h"
#include "errno.h"
/* 80365E90-80365F74 3607D0 00E4+00 0/0 2/2 0/0 .text ftell */
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;
@@ -44,13 +34,18 @@ int _ftell(FILE* file) {
return (position);
}
/* 80365C20-80365E90 360560 0270+00 1/1 0/0 0/0 .text _fseek */
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;
@@ -70,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;
}
@@ -137,11 +101,10 @@ int _fseek(FILE* file, unsigned long offset, int whence) {
return 0;
}
/* 80365BB4-80365C20 3604F4 006C+00 0/0 2/2 0/0 .text fseek */
int fseek(FILE* stream, unsigned long offset, int whence) {
int code;
__begin_critical_region(stdin_access);
code = _fseek(stream, offset, whence); // 0 if successful, -1 if error
__end_critical_region(stdin_access);
return code;
}
}
@@ -1,25 +1,19 @@
#include "abort_exit.h"
#include "critical_regions.h"
#include "stddef.h"
#include <cstddef>
extern void (*_dtors[])(void);
/* 8044D440-8044D540 07A160 0100+00 2/2 0/0 0/0 .bss __atexit_funcs */
static void (*__atexit_funcs[64])(void);
/* 8045199C-804519A0 000E9C 0004+00 2/2 0/0 0/0 .sbss __console_exit */
static void (*__console_exit)(void);
/* 80451998-8045199C 000E98 0004+00 1/1 1/1 0/0 .sbss __stdio_exit */
void (*__stdio_exit)(void);
/* 80451994-80451998 000E94 0004+00 2/2 0/0 0/0 .sbss __atexit_curr_func */
static int __atexit_curr_func;
/* 80451990-80451994 000E90 0004+00 2/2 0/0 0/0 .sbss __aborting */
static int __aborting;
/* 80362ABC-80362B58 35D3FC 009C+00 0/0 9/9 0/0 .text abort */
void abort(void) {
raise(1);
__aborting = 1;
@@ -39,7 +33,6 @@ void abort(void) {
_ExitProcess();
}
/* 803629CC-80362ABC 35D30C 00F0+00 0/0 2/2 0/0 .text exit */
void exit(int status) {
int i;
void (**dtor)(void);
@@ -74,4 +67,4 @@ void exit(int status) {
}
_ExitProcess();
}
}
@@ -1,5 +1,6 @@
#include "alloc.h"
#include "critical_regions.h"
#include <cstring>
typedef struct Block {
struct Block* prev;
@@ -82,7 +83,6 @@ typedef struct mem_pool_obj {
} mem_pool_obj;
mem_pool_obj __malloc_pool;
static int initialized = 0;
static SubBlock* SubBlock_merge_prev(SubBlock*, SubBlock**);
static void SubBlock_merge_next(SubBlock*, SubBlock**);
@@ -124,7 +124,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 +166,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 +201,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;
@@ -221,7 +221,6 @@ static inline Block* __unlink(__mem_pool_obj* pool_obj, Block* bp) {
return result;
}
/* 80362D78-8036300C 35D6B8 0294+00 2/2 0/0 0/0 .text deallocate_from_var_pools */
static void deallocate_from_var_pools(__mem_pool_obj* pool_obj, void* ptr) {
SubBlock* sb = SubBlock_from_pointer(ptr);
SubBlock* _sb;
@@ -250,7 +249,6 @@ static inline __mem_pool* get_malloc_pool(void) {
return &protopool;
}
/* 80362C20-80362D78 35D560 0158+00 1/1 0/0 0/0 .text deallocate_from_fixed_pools */
void deallocate_from_fixed_pools(__mem_pool_obj* pool_obj, void* ptr, unsigned long size) {
unsigned long i = 0;
FixSubBlock* p;
@@ -307,7 +305,6 @@ void deallocate_from_fixed_pools(__mem_pool_obj* pool_obj, void* ptr, unsigned l
}
}
/* 80362BC8-80362C20 35D508 0058+00 1/1 0/0 0/0 .text __pool_free */
void __pool_free(__mem_pool* pool, void* ptr) {
__mem_pool_obj* pool_obj;
unsigned long size;
@@ -326,9 +323,8 @@ void __pool_free(__mem_pool* pool, void* ptr) {
}
}
/* 80362B58-80362BC8 35D498 0070+00 0/0 2/2 0/0 .text free */
void free(void* ptr) {
__begin_critical_region(malloc_pool_access);
__pool_free(get_malloc_pool(), ptr);
__end_critical_region(malloc_pool_access);
}
}
@@ -1,16 +1,13 @@
#include "alloc.h"
#include "ansi_files.h"
#include "critical_regions.h"
/* 8044D778-8044D878 07A498 0100+00 1/0 0/0 0/0 .bss stdin_buff */
static unsigned char stdin_buff[0x100];
/* 8044D678-8044D778 07A398 0100+00 1/0 0/0 0/0 .bss stdout_buff */
static unsigned char stdout_buff[0x100];
/* 8044D578-8044D678 07A298 0100+00 1/0 0/0 0/0 .bss stderr_buff */
static unsigned char stderr_buff[0x100];
/* 803D29B0-803D2AF0 -00001 0140+00 3/2 15/15 0/0 .data __files */
extern files __files = {
{
0,
@@ -114,7 +111,6 @@ extern files __files = {
},
};
/* 8036307C-80363124 35D9BC 00A8+00 0/0 1/1 0/0 .text __close_all */
void __close_all(void) {
FILE* file = &__files._stdin;
FILE* last_file;
@@ -142,7 +138,6 @@ void __close_all(void) {
__end_critical_region(stdin_access);
}
/* 8036300C-8036307C 35D94C 0070+00 0/0 2/2 0/0 .text __flush_all */
unsigned int __flush_all(void) {
unsigned int ret = 0;
FILE* file = &__files._stdin;
@@ -155,4 +150,4 @@ unsigned int __flush_all(void) {
}
return ret;
}
}
@@ -1,6 +1,5 @@
#include "arith.h"
/* 803650D0-803650E0 35FA10 0010+00 0/0 66/66 225/225 .text abs */
int abs(int n) {
if (n < 0)
return (-n);
@@ -8,7 +7,10 @@ int abs(int n) {
return (n);
}
/* 80365078-803650D0 35F9B8 0058+00 0/0 1/1 0/0 .text div */
long labs(long __x) {
return __x > 0 ? __x : -__x;
}
div_t div(int numerator, int denominator) {
div_t ret;
int i = 1;
@@ -27,4 +29,4 @@ div_t div(int numerator, int denominator) {
ret.quot = (numerator / denominator) * (i * j);
ret.rem = numerator * i - j * (ret.quot * denominator);
return ret;
}
}
@@ -4,7 +4,6 @@ void __convert_from_newlines(unsigned char* buf, size_t* n) {}
void __convert_to_newlines(unsigned char* buf, size_t* n) {}
/* 803651A4-803651D8 35FAE4 0034+00 0/0 2/2 0/0 .text __prep_buffer */
void __prep_buffer(FILE* file) {
file->buffer_ptr = file->buffer;
file->buffer_length = file->buffer_size;
@@ -12,7 +11,6 @@ void __prep_buffer(FILE* file) {
file->buffer_position = file->position;
}
/* 803650E0-803651A4 35FA20 00C4+00 0/0 5/5 0/0 .text __flush_buffer */
int __flush_buffer(FILE* file, size_t* bytes_flushed) {
size_t buffer_len;
int ioresult;
@@ -40,4 +38,4 @@ int __flush_buffer(FILE* file, size_t* bytes_flushed) {
__prep_buffer(file);
return 0;
}
}
@@ -1,9 +1,10 @@
#include "buffer_io.h"
#include "char_io.h"
#include "critical_regions.h"
#include "FILE_POS.h"
#include "misc_io.h"
#include "wchar_io.h"
/* 803652AC-80365464 35FBEC 01B8+00 1/1 0/0 0/0 .text __put_char */
int __put_char(int c, FILE* stream) {
int ret;
@@ -19,8 +20,15 @@ int __put_char(int c, FILE* stream) {
}
if (stream->file_state.io_state == __neutral && (stream->file_mode.io_mode & __write)) {
if ((stream->file_mode.io_mode & __append) && fseek(stream, 0, 2) != 0) {
return 0;
if ((stream->file_mode.io_mode & __append)) {
#if PLATFORM_GCN
if (fseek(stream, 0, 2) != 0)
#else
if (_fseek(stream, 0, 2) != 0)
#endif
{
return 0;
}
}
stream->file_state.io_state = __writing;
@@ -62,32 +70,21 @@ exit:
return ret;
}
/* 803651D8-803652AC 35FB18 00D4+00 0/0 1/1 0/0 .text fputs */
#if PLATFORM_GCN
#define __putc(c, file) \
((fwide(file, -1) >= 0) ? -1 : (file)->buffer_length-- ? (int) (*(file)->buffer_ptr++ = (unsigned char)(c)) : __put_char(c, file))
#else
#define __putc(c, file) \
((__fwide(file, -1) >= 0) ? -1 : (file)->buffer_length-- ? (int) (*(file)->buffer_ptr++ = (unsigned char)(c)) : __put_char(c, file))
#endif
int fputs(const char* s, FILE* stream) {
char c;
int var_r3;
unsigned long len;
int ret = 0;
__begin_critical_region(stdin_access);
while (c = *s++, c != 0) {
if (fwide(stream, -1) >= 0) {
var_r3 = -1;
} else {
len = stream->buffer_length;
stream->buffer_length = len - 1;
if (len != 0) {
char* buf = (char*)stream->buffer_ptr;
stream->buffer_ptr++;
*buf = var_r3 = c & 0xFF;
} else {
var_r3 = __put_char(c, stream);
}
}
if (var_r3 == -1) {
if (__putc(c, stream) == -1) {
ret = -1;
break;
}
@@ -95,4 +92,4 @@ int fputs(const char* s, FILE* stream) {
__end_critical_region(stdin_access);
return ret;
}
}
@@ -1,5 +1,15 @@
#include "ctype.h"
#include "common.h"
#include <locale.h>
// necessary to generate symbols in this TU
#undef MSL_INLINE
#define MSL_INLINE __declspec(weak)
#include <cctype>
#if PLATFORM_GCN
#define ctrl __control_char
#define motn __motion_char
#define spac __space_char
@@ -12,7 +22,6 @@
#define uhex (hexd | uppc)
#define lhex (hexd | lowc)
/* 803D2C18-803D2D18 02FD38 0100+00 0/0 3/3 0/0 .data __ctype_map */
unsigned char __ctype_map[256] = {
// clang-format off
ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, ctrl, motn, motn, motn, motn, motn, ctrl, ctrl,
@@ -26,7 +35,6 @@ unsigned char __ctype_map[256] = {
// clang-format on
};
/* 803D2D18-803D2E18 02FE38 0100+00 1/1 3/3 0/0 .data __lower_map */
unsigned char __lower_map[256] = {
// clang-format off
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
@@ -48,19 +56,6 @@ unsigned char __lower_map[256] = {
// clang-format on
};
/* 80365470-80365494 35FDB0 0024+00 0/0 4/4 0/0 .text tolower */
int tolower(int __c) {
{
if (__c == -1) {
return 0xffffffff;
}
return (unsigned int)__lower_map[__c & 0xff];
}
}
/* ############################################################################################## */
/* 803D2E18-803D2F18 02FF38 0100+00 0/0 1/1 0/0 .data __upper_map */
unsigned char __upper_map[256] = {
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,
@@ -79,4 +74,73 @@ unsigned char __upper_map[256] = {
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
};
};
#else
#define alph ctype_alpha
#define blnk ctype_blank
#define cntl ctype_cntrl
#define digi ctype_digit | ctype_graph | ctype_print
#define grph ctype_graph
#define lowc ctype_lower | ctype_alpha | ctype_graph | ctype_print
#define prnt ctype_print
#define punc ctype_punct | ctype_graph | ctype_print
#define spac ctype_space
#define uppc ctype_upper | ctype_alpha | ctype_graph | ctype_print
#define hexd ctype_xdigit
#define dhex hexd | digi
#define uhex hexd | uppc
#define lhex hexd | lowc
#define ctbl cntl | blnk
#define ctsp cntl | spac
#define sblp spac | blnk | prnt
#define csbl cntl | spac | blnk
const unsigned short __ctype_mapC[256] = {
cntl, cntl, cntl, cntl, cntl, cntl, cntl, cntl, cntl, csbl, ctsp, ctsp, ctsp, ctsp, cntl, cntl,
cntl, cntl, cntl, cntl, cntl, cntl, cntl, cntl, cntl, cntl, cntl, cntl, cntl, cntl, cntl, cntl,
sblp, 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, cntl
};
const unsigned char __lower_mapC[0x100] = {
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
};
const unsigned char __upper_mapC[0x100] = {
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
};
#endif
@@ -1,8 +1,11 @@
#include "direct_io.h"
#include "buffer_io.h"
#include "critical_regions.h"
#include "direct_io.h"
#include "FILE_POS.h"
#include "misc_io.h"
#include "wchar_io.h"
#include <cstring>
/* 80365494-803657A0 35FDD4 030C+00 1/1 0/0 0/0 .text __fwrite */
size_t fwrite(const void* buffer, size_t size, size_t count, FILE* stream) {
size_t retval;
@@ -13,7 +16,6 @@ size_t fwrite(const void* buffer, size_t size, size_t count, FILE* stream) {
return (retval);
}
/* 803657A0-8036581C 3600E0 007C+00 0/0 1/1 0/0 .text fwrite */
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;
@@ -38,7 +40,11 @@ size_t __fwrite(const void* buffer, size_t size, size_t count, FILE* stream) {
if (stream->file_state.io_state == __neutral) {
if (stream->file_mode.io_mode & __write) {
if (stream->file_mode.io_mode & __append) {
#if PLATFORM_GCN
if (fseek(stream, 0, SEEK_END))
#else
if (_fseek(stream, 0, SEEK_END))
#endif
return 0;
}
stream->file_state.io_state = __writing;
@@ -65,6 +71,7 @@ size_t __fwrite(const void* buffer, size_t size, size_t count, FILE* stream) {
if (num_bytes > bytes_to_go)
num_bytes = bytes_to_go;
if (stream->file_mode.buffer_mode == _IOLBF && num_bytes)
if ((newline = (unsigned char*)__memrchr(write_ptr, '\n', num_bytes)) != NULL)
num_bytes = newline + 1 - write_ptr;
@@ -73,12 +80,15 @@ size_t __fwrite(const void* buffer, size_t size, size_t count, FILE* stream) {
memcpy(stream->buffer_ptr, write_ptr, num_bytes);
write_ptr += num_bytes;
#if PLATFORM_GCN
bytes_written += num_bytes;
#endif
bytes_to_go -= num_bytes;
stream->buffer_ptr += num_bytes;
stream->buffer_length -= num_bytes;
}
if (!stream->buffer_length || newline != NULL ||
(stream->file_mode.buffer_mode == _IONBF))
{
@@ -90,6 +100,9 @@ size_t __fwrite(const void* buffer, size_t size, size_t count, FILE* stream) {
break;
}
}
#if !PLATFORM_GCN
bytes_written += num_bytes;
#endif
} while (bytes_to_go && always_buffer);
}
@@ -101,10 +114,17 @@ size_t __fwrite(const void* buffer, size_t size, size_t count, FILE* stream) {
stream->buffer_size = bytes_to_go;
stream->buffer_ptr = write_ptr + bytes_to_go;
#if PLATFORM_GCN
if (__flush_buffer(stream, &num_bytes) != __no_io_error)
set_error(stream);
bytes_written += num_bytes;
#else
if (__flush_buffer(stream, &num_bytes) != __no_io_error)
set_error(stream);
else
bytes_written += num_bytes;
#endif
stream->buffer = save_buffer;
stream->buffer_size = save_size;
@@ -117,5 +137,9 @@ size_t __fwrite(const void* buffer, size_t size, size_t count, FILE* stream) {
if (stream->file_mode.buffer_mode != _IOFBF)
stream->buffer_length = 0;
#if PLATFORM_GCN
return ((bytes_written + size - 1) / size);
}
#else
return bytes_written / size;
#endif
}
@@ -1,4 +1,3 @@
#include "errno.h"
/* 804519A8-804519B0 000EA8 0004+04 0/0 6/6 0/0 .sbss errno */
int errno;
int errno;
@@ -1,14 +1,13 @@
#include "extras.h"
#include "ctype.h"
#include <cctype>
/* 8036CA94-8036CB20 3673D4 008C+00 0/0 1/1 0/0 .text stricmp */
int stricmp(const char* str1, const char* str2) {
char a_var;
char b_var;
do {
b_var = _tolower(*str1++);
a_var = _tolower(*str2++);
b_var = tolower(*str1++);
a_var = tolower(*str2++);
if (b_var < a_var) {
return -1;
@@ -21,7 +20,6 @@ int stricmp(const char* str1, const char* str2) {
return 0;
}
/* 8036CA74-8036CA94 3673B4 0020+00 0/0 1/1 0/0 .text strnicmp */
int strnicmp(const char* str1, const char* str2, int n) {
return __msl_strnicmp(str1, str2, n);
}
}
@@ -1,7 +1,9 @@
#include "alloc.h"
#include "buffer_io.h"
#include "file_io.h"
#include "ctype.h"
#include "FILE_POS.h"
#include <cctype>
/* 803659F8-80365BB4 360338 01BC+00 0/0 1/1 0/0 .text fclose */
int fclose(FILE* file) {
int flush_result, close_result;
@@ -22,7 +24,6 @@ int fclose(FILE* file) {
return ((flush_result || close_result) ? -1 : 0);
}
/* 803658C0-803659F8 360200 0138+00 0/0 4/4 0/0 .text fflush */
int fflush(FILE* file) {
int pos;
@@ -69,14 +70,13 @@ int fflush(FILE* file) {
return 0;
}
/* 8036581C-803658C0 36015C 00A4+00 0/0 1/1 0/0 .text __msl_strnicmp */
int __msl_strnicmp(const char* str1, const char* str2, int n) {
int i;
char c1, c2;
for (i = 0; i < n; i++) {
c1 = _tolower(*str1++);
c2 = _tolower(*str2++);
c1 = tolower(*str1++);
c2 = tolower(*str2++);
if (c1 < c2) {
return -1;
@@ -92,4 +92,4 @@ int __msl_strnicmp(const char* str1, const char* str2, int n) {
}
return 0;
}
}

Some files were not shown because too many files have changed in this diff Show More