summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/algorithm412
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/algorithm.h65
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/bitset (renamed from src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/bitset.h)71
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/cstdint59
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/functional22
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/functional.h8
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/iterator140
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/iterator.h21
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/limits (renamed from src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/limits.h)72
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/memory51
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/msl_memory.h24
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/new9
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/type_traits90
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/utility (renamed from src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/utility.h)0
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/FILE_POS.h4
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/algorithm220
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/alloc.h3
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/ansi_files.h9
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/ansi_fp.h17
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/arith.h6
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/buffer_io.h4
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cctype183
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cerrno4
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/char_io.h6
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/climits41
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cmath288
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cmath.h16
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/critical_regions.h8
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstdarg11
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstddef33
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstdio47
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstdlib31
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstring55
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstring.h19
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/ctype.h46
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cwchar21
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/direct_io.h4
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/extras.h5
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/file_io.h4
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/float.h142
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/iterator10
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/locale.h114
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/math.h134
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/mbstring.h12
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/mem_funcs.h4
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/new17
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/new.h10
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/printf.h19
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/scanf.h5
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdarg.h14
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stddef.h32
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdint.h16
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdio.h33
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdlib.h28
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/string.h49
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/strtold.h15
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/strtoul.h6
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/va_list.h (renamed from src/PowerPC_EABI_Support/Runtime/Inc/__va_arg.h)26
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wchar.h18
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wchar_io.h2
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wcstoul.h18
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wctype_api.h32
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wmem.h18
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wprintf.h19
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wscanf.h23
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wstring.h22
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/FILE_POS.c59
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/abort_exit.c11
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/alloc.c58
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/ansi_files.c9
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/arith.c8
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/buffer_io.c4
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/char_io.c45
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/ctype.c98
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/direct_io.c32
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/errno.c3
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/extras.c10
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/file_io.c14
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/float.c18
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/locale.c122
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/math_api.c51
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/math_double.c5
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/mbstring.c359
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/mem.c25
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/mem_funcs.c16
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/misc_io.c3
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/printf.c407
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/scanf.c772
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/secure_error.c16
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/signal.c14
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/string.c24
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/strtold.c663
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/strtoul.c147
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wchar_io.c44
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wcstoul.c224
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wctype.c166
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wmem.c19
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wprintf.c1406
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wscanf.c27
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wstring.c44
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_acos.c9
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_asin.c9
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_fmod.c21
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_log.c161
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_log10.c99
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_pow.c619
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_rem_pio2.c242
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_sqrt.c4
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/k_rem_pio2.c2
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/k_tan.c4
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/s_ldexp.c10
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_acos.c3
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_asin.c3
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_atan2.c3
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_exp.c3
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_fmod.c3
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_log10.c28
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_pow.c8
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_sqrt.c3
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Include/fdlibm.h4
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Src/ansi_fp.c178
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Src/math_sun.c13
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/abort_exit_ppc_eabi.c0
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/critical_regions.gamecube.c5
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/math_ppc.c29
-rw-r--r--src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/uart_console_io_gcn.c4
-rw-r--r--src/PowerPC_EABI_Support/MetroTRK/trk.h4
-rw-r--r--src/PowerPC_EABI_Support/Runtime/Inc/CPlusLibPPC.h2
-rw-r--r--src/PowerPC_EABI_Support/Runtime/Inc/MWCPlusLib.h2
-rw-r--r--src/PowerPC_EABI_Support/Runtime/Inc/NMWException.h13
-rw-r--r--src/PowerPC_EABI_Support/Runtime/Inc/__mem.h16
-rw-r--r--src/PowerPC_EABI_Support/Runtime/Inc/ptmf.h14
-rw-r--r--src/PowerPC_EABI_Support/Runtime/Inc/runtime.h2
-rw-r--r--src/PowerPC_EABI_Support/Runtime/Src/CPlusLibPPC.cp3
-rw-r--r--src/PowerPC_EABI_Support/Runtime/Src/GCN_Mem_Alloc.c5
-rw-r--r--src/PowerPC_EABI_Support/Runtime/Src/Gecko_ExceptionPPC.cp5
-rw-r--r--src/PowerPC_EABI_Support/Runtime/Src/__mem.c8
-rw-r--r--src/PowerPC_EABI_Support/Runtime/Src/__va_arg.c6
-rw-r--r--src/PowerPC_EABI_Support/Runtime/Src/global_destructor_chain.c3
-rw-r--r--src/PowerPC_EABI_Support/Runtime/Src/ptmf.c7
-rw-r--r--src/PowerPC_EABI_Support/Runtime/Src/runtime.c35
-rw-r--r--src/REL/d/a/e/d_a_e_sm.cpp2
-rw-r--r--src/d/col/c/c_m3d.cpp1
-rw-r--r--src/d/d_light_env.cpp6
-rw-r--r--src/d/d_message.cpp1
-rw-r--r--src/d/d_pad.cpp2
-rw-r--r--src/d/lyt/d_lyt_deposit.cpp2
-rw-r--r--src/d/lyt/d_lyt_pause_disp_00.cpp2
-rw-r--r--src/d/lyt/d_lyt_shop.cpp2
-rw-r--r--src/egg/gfx/eggDrawGX.cpp1
-rw-r--r--src/egg/gfx/eggPostEffectBase.cpp1
-rw-r--r--src/egg/gfx/eggPostEffectBlur.cpp1
-rw-r--r--src/egg/prim/eggAssert.cpp3
-rw-r--r--src/m/m_angle.cpp2
-rw-r--r--src/nw4r/g3d/g3d_anmchr.cpp2
-rw-r--r--src/nw4r/g3d/g3d_anmtexsrt.cpp2
-rw-r--r--src/nw4r/g3d/res/g3d_restev.cpp1
-rw-r--r--src/nw4r/snd/snd_AnimSound.cpp8
-rw-r--r--src/nw4r/snd/snd_Sound3DCalculator.cpp4
-rw-r--r--src/nw4r/ut/ut_TextWriterBase.cpp3
-rw-r--r--src/s/s_Math.cpp2
-rw-r--r--src/toBeSorted/d_camera_math.cpp2
-rw-r--r--src/toBeSorted/deg_angle_util.cpp5
163 files changed, 7575 insertions, 1962 deletions
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/algorithm b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/algorithm
new file mode 100644
index 00000000..3801f9cb
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/algorithm
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/algorithm.h b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/algorithm.h
deleted file mode 100644
index f4b99f4b..00000000
--- a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/algorithm.h
+++ /dev/null
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/bitset.h b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/bitset
index 5dad5735..e3b01b34 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/bitset.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/bitset
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/cstdint b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/cstdint
new file mode 100644
index 00000000..35428a68
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/cstdint
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/functional b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/functional
new file mode 100644
index 00000000..1c7b8fb4
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/functional
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/functional.h b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/functional.h
deleted file mode 100644
index 405e56f8..00000000
--- a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/functional.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef MSL_FUNCTIONAL_H_
-#define MSL_FUNCTIONAL_H_
-
-namespace std {
-template <class T> struct less {};
-} // namespace std
-
-#endif \ No newline at end of file
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/iterator b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/iterator
new file mode 100644
index 00000000..8093956d
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/iterator
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/iterator.h b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/iterator.h
deleted file mode 100644
index f7d86e37..00000000
--- a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/iterator.h
+++ /dev/null
@@ -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 \ No newline at end of file
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/limits.h b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/limits
index b89fe460..5da476c2 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/limits.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/limits
@@ -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; }
};
-} // namespace std
+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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/memory b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/memory
new file mode 100644
index 00000000..58a22ef4
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/memory
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/msl_memory.h b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/msl_memory.h
deleted file mode 100644
index 9a29cd90..00000000
--- a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/msl_memory.h
+++ /dev/null
@@ -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 \ No newline at end of file
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/new b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/new
new file mode 100644
index 00000000..719c9d0b
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/new
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/type_traits b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/type_traits
new file mode 100644
index 00000000..720115c1
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/type_traits
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/utility.h b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/utility
index 02150279..02150279 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/utility.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include/utility
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/FILE_POS.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/FILE_POS.h
index 2ea0a31a..4eac9e7a 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/FILE_POS.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/FILE_POS.h
@@ -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 */ \ No newline at end of file
+#endif /* _MSL_COMMON_FILE_POS_H */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/algorithm b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/algorithm
deleted file mode 100644
index aa6ec1d2..00000000
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/algorithm
+++ /dev/null
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/alloc.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/alloc.h
index 7a6673a3..1207adcd 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/alloc.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/alloc.h
@@ -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 */ \ No newline at end of file
+#endif /* _MSL_COMMON_ALLOC_H */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/ansi_files.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/ansi_files.h
index 9514154a..fdd13966 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/ansi_files.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/ansi_files.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 {
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/ansi_fp.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/ansi_fp.h
index 1c049229..2fcc788d 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/ansi_fp.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/ansi_fp.h
@@ -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 \ No newline at end of file
+#endif
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/arith.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/arith.h
index ce893446..ee3c8ba0 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/arith.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/arith.h
@@ -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 */ \ No newline at end of file
+#endif /* _MSL_COMMON_ARITH_H */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/buffer_io.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/buffer_io.h
index a764ac29..e9271066 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/buffer_io.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/buffer_io.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 */ \ No newline at end of file
+#endif /* _MSL_COMMON_BUFFER_IO_H */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cctype b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cctype
index a4fa1ede..8448dfe0 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cctype
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cctype
@@ -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
+
+#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>
-namespace std {
-using ::tolower;
-using ::toupper;
-} // namespace std
+
+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 */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cerrno b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cerrno
deleted file mode 100644
index f371e9b9..00000000
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cerrno
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef MSL_CPP_CERRNO_H
-#define MSL_CPP_CERRNO_H
-#include <errno.h>
-#endif \ No newline at end of file
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/char_io.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/char_io.h
index 93b6383f..e4954166 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/char_io.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/char_io.h
@@ -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
}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/climits b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/climits
index 0740fc20..bae33617 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/climits
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/climits
@@ -1,4 +1,37 @@
-#ifndef MSL_CPP_CLIMITS_H
-#define MSL_CPP_CLIMITS_H
-#include <limits.h>
-#endif \ No newline at end of file
+#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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cmath b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cmath
index ee8cd129..8c4b256b 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cmath
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cmath
@@ -1,85 +1,245 @@
-#ifndef MSL_CPP_CMATH_H
-#define MSL_CPP_CMATH_H
-#include <math.h>
+#ifndef MSL_CMATH_H_
+#define MSL_CMATH_H_
+
+#include "common.h"
+
+#include <float.h>
+#include <arith.h>
+
+#define NAN (*(float*) __float_nan)
+#define HUGE_VALF (*(float*) __float_huge)
+
+#if !PLATFORM_GCN
+#define HUGE_VAL (*(double*)__double_huge)
+#endif
+
+#define _HUGE_ENUF 1e+300
+#define INFINITY ((float)(_HUGE_ENUF * _HUGE_ENUF))
+#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
-// Remove C macro
-#undef fabs
+extern double __frsqrte(double);
+extern float __fres(float);
+extern double __fabs(double);
+extern float __fabsf(float);
-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;
-
-inline float ceilf(float x) {
- return ::ceil(x);
-}
-
-inline float floorf(float x) {
- return ::floor(x);
-}
-
-inline float cosf(float x) {
+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);
}
-inline float sinf(float 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);
}
-inline float sqrtf(float 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 acosf(float x) {
- return ::acos(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);
}
-// TODO: Very fake!
-// inline double fabs_wrapper(double x) {
-// return __fabs(x);
-// }
+inline float ceil(float num) {
+ return ::ceilf(num);
+}
-// inline float fabs(float x) {
-// return fabs_wrapper(x);
-// }
+inline float cos(float num) {
+ return ::cosf(num);
+}
-} // namespace std
+inline float floor(float num) {
+ return ::floorf(num);
+}
-#define _HUGE_ENUF 1e+300
-#define INFINITY ((float)(_HUGE_ENUF * _HUGE_ENUF))
-#define HUGE_VAL ((double)INFINITY)
-#define HUGE_VALL ((long double)INFINITY)
+inline float sin(float num) {
+ return ::sinf(num);
+}
-#define DOUBLE_INF HUGE_VAL
+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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cmath.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cmath.h
deleted file mode 100644
index 4ab23c36..00000000
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cmath.h
+++ /dev/null
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/critical_regions.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/critical_regions.h
index a36c75d6..8695086c 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/critical_regions.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/critical_regions.h
@@ -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 \ No newline at end of file
+#endif
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstdarg b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstdarg
index b596d426..5f54f9a6 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstdarg
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstdarg
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstddef b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstddef
index c853dd85..9d171876 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstddef
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstddef
@@ -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
+
+#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
-namespace std {
-using ::intptr_t;
-using ::ptrdiff_t;
-using ::size_t;
-using ::uintptr_t;
-} // namespace std
+typedef unsigned long size_t;
+typedef long ptrdiff_t;
+#ifndef __cplusplus
+typedef unsigned short wchar_t;
#endif
+
+#ifdef __cplusplus
+};
+#endif
+
#endif
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstdio b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstdio
index 4c995a0d..b85d218e 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstdio
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstdio
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstdlib b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstdlib
index 8ee47976..a98bcf8b 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstdlib
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstdlib
@@ -1,17 +1,22 @@
-#ifndef MSL_CPP_CSTDLIB_H
-#define MSL_CPP_CSTDLIB_H
-#include <stdlib.h>
-#ifdef __cplusplus
+#ifndef MSL_CSTDLIB_H_
+#define MSL_CSTDLIB_H_
-// TODO: Fillout impls
-namespace std {
-// using ::abs;
-// using ::atof;
-// using ::mbstowcs;
-// using ::mbtowc;
-// using ::rand;
-// using ::wcstombs;
-} // namespace std
+#include <abort_exit.h>
+#include <arith.h>
+#include <strtoul.h>
+#ifdef __cplusplus
+extern "C" {
+namespace std {
+ using ::strtol;
+ using ::strtoul;
+ using ::div;
+ using ::exit;
+ using ::abort;
+ using ::atoi;
+ using ::atof;
+}
+};
#endif
+
#endif
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstring b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstring
index 8a62a363..0121efe5 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstring
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstring
@@ -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 ::strstr;
using ::strlen;
-using ::strncat;
using ::strncmp;
+using ::strcmp;
+using ::strcat;
using ::strncpy;
-using ::strstr;
+using ::strncat;
+using ::strcpy;
} // namespace std
-
-#endif
#endif
+
+#endif /* _MSL_COMMON_STRING_H */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstring.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstring.h
deleted file mode 100644
index 4b35acdf..00000000
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cstring.h
+++ /dev/null
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/ctype.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/ctype.h
deleted file mode 100644
index 867dc71d..00000000
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/ctype.h
+++ /dev/null
@@ -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 */ \ No newline at end of file
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cwchar b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cwchar
deleted file mode 100644
index 3e2dfba5..00000000
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cwchar
+++ /dev/null
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/direct_io.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/direct_io.h
index 2f293cba..c7f5a1b1 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/direct_io.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/direct_io.h
@@ -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 */ \ No newline at end of file
+#endif /* _MSL_COMMON_DIRECT_IO_H */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/extras.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/extras.h
index e6417f07..f6702aa0 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/extras.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/extras.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 */ \ No newline at end of file
+#endif /* _MSL_COMMON_EXTRAS_H */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/file_io.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/file_io.h
index a71bc423..34cd0ce3 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/file_io.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/file_io.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 */ \ No newline at end of file
+#endif /* _MSL_COMMON_FILE_IO_H */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/float.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/float.h
index 399bcf35..64651e39 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/float.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/float.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 (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;
+ switch (*(int*)&__value & 0x7f800000) {
+ case 0x7f800000:
+ if ((*(int*)&__value & 0x7fffff) != 0) {
+ return FP_QNAN;
+ }
+ return FP_INFINITE;
+
+ 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)
-#define FLT_MIN_10_EXP (-37)
-#define FLT_MAX_EXP 128
-#define FLT_MAX_10_EXP 38
+// Stripped function.
+int __fpclassifyl(long double __value);
-// #define FLT_MAX (*(float*) __float_max)
-// #define FLT_EPSILON (*(float*) __float_epsilon)
+#ifdef __cplusplus
+}; // extern "C"
+#endif
-#define FLT_MAX (3.402823466e+38f)
-#define FLT_EPSILON (1.192092896e-07f)
+#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_10_EXP 38
-#define DBL_MANT_DIG 53
-#define DBL_DIG 15
-#define DBL_MIN_EXP (-1021)
+#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 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 */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/iterator b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/iterator
deleted file mode 100644
index cc303806..00000000
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/iterator
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef MSL_CPP_ITERATOR_H
-#define MSL_CPP_ITERATOR_H
-
-namespace std {
-
-struct random_access_iterator_tag {};
-
-} // namespace std
-
-#endif \ No newline at end of file
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/locale.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/locale.h
new file mode 100644
index 00000000..717d128b
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/locale.h
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/math.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/math.h
deleted file mode 100644
index 0ec47d8b..00000000
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/math.h
+++ /dev/null
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/mbstring.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/mbstring.h
index e4a5fdf2..0fb1d40b 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/mbstring.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/mbstring.h
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/mem_funcs.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/mem_funcs.h
index d9ee49d9..5e9eaee2 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/mem_funcs.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/mem_funcs.h
@@ -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 */ \ No newline at end of file
+#endif /* _MSL_COMMON_MEM_FUNCS_H */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/new b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/new
deleted file mode 100644
index 2372b4b2..00000000
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/new
+++ /dev/null
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/new.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/new.h
deleted file mode 100644
index 66bceb3b..00000000
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/new.h
+++ /dev/null
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/printf.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/printf.h
index 548d8656..f4ed9bb8 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/printf.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/printf.h
@@ -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
}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/scanf.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/scanf.h
index ac28dd8d..434386eb 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/scanf.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/scanf.h
@@ -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 */ \ No newline at end of file
+#endif /* _MSL_COMMON_SCANF_H */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdarg.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdarg.h
new file mode 100644
index 00000000..a6de1c22
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdarg.h
@@ -0,0 +1,14 @@
+#ifndef _MSL_STDARG_H_
+#define _MSL_STDARG_H_
+
+#include <cstdarg>
+
+#ifdef __cplusplus
+
+namespace std {
+ using ::va_list;
+}
+
+#endif
+
+#endif
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stddef.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stddef.h
index 7a6f3f76..b0b97c32 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stddef.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stddef.h
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdint.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdint.h
index 8430cfc8..89ff7339 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdint.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdint.h
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdio.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdio.h
index 00cecd22..f370e38a 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdio.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdio.h
@@ -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"
-
-#define stdin (&__files._stdin)
-#define stdout (&__files._stdout)
-#define stderr (&__files._stderr)
+#include <cstdio>
+#include <stddef.h>
+#include <stdarg.h>
+
+#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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdlib.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdlib.h
index a96b8f17..3d823971 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdlib.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/stdlib.h
@@ -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 \ No newline at end of file
+#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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/string.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/string.h
index db8c619e..102388a2 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/string.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/string.h
@@ -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>
-#ifdef __cplusplus
-extern "C" {
-#endif
+namespace std {
+using ::memcpy;
+using ::memset;
+using ::memcmp;
+using ::memchr;
+using ::memmove;
-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);
+using ::strlen;
+using ::strncmp;
+using ::strcmp;
+using ::strstr;
+using ::strcat;
+using ::strncpy;
+using ::strcpy;
-int atoi(const char *str);
+using ::strnicmp;
+using ::stricmp;
+using ::wcslen;
-#ifdef __cplusplus
-}
-#endif
+}; // namespace std
-#endif /* _MSL_COMMON_STRING_H */
+#endif
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/strtold.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/strtold.h
new file mode 100644
index 00000000..cc73532c
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/strtold.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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/strtoul.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/strtoul.h
index e504b955..a5d93ece 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/strtoul.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/strtoul.h
@@ -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 */ \ No newline at end of file
+#endif /* _MSL_COMMON_STRTOUL_H */
diff --git a/src/PowerPC_EABI_Support/Runtime/Inc/__va_arg.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/va_list.h
index 4b8666c4..12cee6b0 100644
--- a/src/PowerPC_EABI_Support/Runtime/Inc/__va_arg.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/va_list.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 */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wchar.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wchar.h
deleted file mode 100644
index 4e083ae4..00000000
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wchar.h
+++ /dev/null
@@ -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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wchar_io.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wchar_io.h
index a2f546c3..a8437db7 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wchar_io.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wchar_io.h
@@ -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);
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wcstoul.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wcstoul.h
new file mode 100644
index 00000000..c60b21ad
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wcstoul.h
@@ -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 */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wctype_api.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wctype_api.h
new file mode 100644
index 00000000..a08f44ea
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wctype_api.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 */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wmem.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wmem.h
new file mode 100644
index 00000000..4dd71cbd
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wmem.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 */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wprintf.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wprintf.h
index f8026464..69a50f1f 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wprintf.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wprintf.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 */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wscanf.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wscanf.h
new file mode 100644
index 00000000..37a81c6a
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wscanf.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 */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wstring.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wstring.h
index e8a3699e..b78ddf0e 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wstring.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/wstring.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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/FILE_POS.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/FILE_POS.c
index 9aafb8e0..a4edf4c5 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/FILE_POS.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/FILE_POS.c
@@ -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;
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/abort_exit.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/abort_exit.c
index 7d653242..c399b828 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/abort_exit.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/abort_exit.c
@@ -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();
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/alloc.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/alloc.c
index 264edd90..090e24c5 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/alloc.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/alloc.c
@@ -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);
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/ansi_files.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/ansi_files.c
index e8b656c3..c79f4554 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/ansi_files.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/ansi_files.c
@@ -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;
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/arith.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/arith.c
index 7953ff32..ecb47761 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/arith.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/arith.c
@@ -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;
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/buffer_io.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/buffer_io.c
index fda0958d..4cdc54f7 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/buffer_io.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/buffer_io.c
@@ -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;
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/char_io.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/char_io.c
index b2163b72..671b2109 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/char_io.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/char_io.c
@@ -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;
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/ctype.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/ctype.c
index 8d0e5a8f..2c3ece52 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/ctype.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/ctype.c
@@ -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
-}; \ No newline at end of file
+};
+#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
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/direct_io.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/direct_io.c
index a0b35621..7424557a 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/direct_io.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/direct_io.c
@@ -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);
-} \ No newline at end of file
+ #else
+ return bytes_written / size;
+ #endif
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/errno.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/errno.c
index 32c23470..afee599b 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/errno.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/errno.c
@@ -1,4 +1,3 @@
#include "errno.h"
-/* 804519A8-804519B0 000EA8 0004+04 0/0 6/6 0/0 .sbss errno */
-int errno; \ No newline at end of file
+int errno;
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/extras.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/extras.c
index 64629903..1b184d60 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/extras.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/extras.c
@@ -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);
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/file_io.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/file_io.c
index 061977fa..32246fbe 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/file_io.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/file_io.c
@@ -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;
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/float.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/float.c
index c21b5a2b..4f61b495 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/float.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/float.c
@@ -1,13 +1,15 @@
#include "float.h"
-/* 80450AE0-80450AE4 000560 0004+00 0/0 204/204 1060/1060 .sdata __float_nan */
-unsigned long __float_nan[] = {0x7FFFFFFF};
+int __float_nan[] = {0x7FFFFFFF};
-/* 80450AE4-80450AE8 000564 0004+00 0/0 1/1 0/0 .sdata __float_huge */
-unsigned long __float_huge[] = {0x7F800000};
+int __float_huge[] = {0x7F800000};
-/* 80450AE8-80450AEC 000568 0004+00 0/0 18/18 14/14 .sdata __float_max */
-unsigned long __float_max[] = {0x7F7FFFFF};
+#if PLATFORM_GCN
+int __float_max[] = {0x7F7FFFFF};
-/* 80450AEC-80450AF0 00056C 0004+00 0/0 28/28 0/0 .sdata __float_epsilon */
-unsigned long __float_epsilon[] = {0x34000000}; \ No newline at end of file
+int __float_epsilon[] = {0x34000000};
+#endif
+
+#if !PLATFORM_GCN
+int __double_huge[] = {0x7FF00000, 0};
+#endif
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/locale.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/locale.c
new file mode 100644
index 00000000..7fe8104e
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/locale.c
@@ -0,0 +1,122 @@
+#include <locale.h>
+#include <cctype>
+#include <wctype_api.h>
+#include <mbstring.h>
+
+#pragma options align=native
+#pragma warn_padding off
+
+struct lconv __lconv = {
+ ".",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ 0x7F,
+ 0x7F,
+ 0x7F,
+ 0x7F,
+ 0x7F,
+ 0x7F,
+ 0x7F,
+ "",
+ 0x7F,
+ 0x7F,
+ 0x7F,
+ 0x7F,
+ 0x7F,
+ 0x7F,
+ 0x7F
+};
+#pragma warn_padding reset
+#pragma options align=reset
+
+struct _loc_ctype_cmpt _loc_ctyp_C = {
+ "C",
+ &__ctype_mapC[0],
+ &__upper_mapC[0],
+ &__lower_mapC[0],
+ &__wctype_mapC[0],
+ &__wupper_mapC[0],
+ &__wlower_mapC[0],
+ __mbtowc_noconv,
+ __wctomb_noconv
+};
+
+unsigned short char_coll_tableC[] = {
+ 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,
+ 0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x11,0x12,0x13,0x14,0x15,0x16,
+ 0x17,0x2B,0x2D,0x2F,0x31,0x33,0x35,0x37,0x39,0x3B,0x3D,0x3F,0x41,0x43,0x45,0x47,
+ 0x49,0x4B,0x4D,0x4F,0x51,0x53,0x55,0x57,0x59,0x5B,0x5D,0x18,0x19,0x1A,0x1B,0x1C,
+ 0x00,0x2C,0x2E,0x30,0x32,0x34,0x36,0x38,0x3A,0x3C,0x3E,0x40,0x42,0x44,0x46,0x48,
+ 0x4A,0x4C,0x4E,0x50,0x52,0x54,0x56,0x58,0x5A,0x5C,0x5E,0x1D,0x1E,0x1F,0x20,0x00
+};
+
+struct _loc_coll_cmpt _loc_coll_C = {
+ "C",
+ 0x20,
+ 0x6E,
+ 0,
+ char_coll_tableC,
+ NULL
+};
+
+struct _loc_mon_cmpt _loc_mon_C = {
+ "C",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ 0x7F,
+ 0x7F,
+ 0x7F,
+ 0x7F,
+ 0x7F,
+ 0x7F,
+ 0x7F,
+ "",
+ 0x7F,
+ 0x7F,
+ 0x7F,
+ 0x7F,
+ 0x7F,
+ 0x7F,
+ 0x7F
+};
+
+
+struct _loc_num_cmpt _loc_num_C = {
+ "C",
+ ".",
+ "",
+ "",
+};
+
+struct _loc_time_cmpt _loc_tim_C = {
+ "C",
+ "AM|PM",
+ "%a %b %e %T %Y",
+ "%I:%M:%S %p",
+ "%m/%d/%y",
+ "%T",
+ "Sun|Sunday|Mon|Monday|Tue|Tuesday|Wed|Wednesday|Thu|Thursday|Fri|Friday|Sat|Saturday",
+ "Jan|January|Feb|February|Mar|March|Apr|April|May|May|Jun|June|Jul|July|Aug|August|Sep|September|Oct|October|Nov|November|Dec|December",
+ ""
+};
+
+
+struct __locale _current_locale = {
+ NULL,
+ "C",
+ &_loc_coll_C,
+ &_loc_ctyp_C,
+ &_loc_mon_C,
+ &_loc_num_C,
+ &_loc_tim_C
+};
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/math_api.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/math_api.c
new file mode 100644
index 00000000..6c9c5d05
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/math_api.c
@@ -0,0 +1,51 @@
+// I think this TU didn't include the header or used a different header
+// allowing for both the inline definition and these symbols to exist
+
+#define __HI(x) *(int*)&x
+#define __LO(x) *(1 + (int*)&x)
+#define __HIp(x) *(int*)x
+#define __LOp(x) *(1 + (int*)x)
+
+int __fpclassifyf(float x) {
+ switch ((*(long*)&x) & 0x7f800000) {
+ case 0x7f800000: {
+ if ((*(long*)&x) & 0x007fffff)
+ return 1;
+ else
+ return 2;
+ break;
+ }
+ case 0: {
+ if ((*(long*)&x) & 0x007fffff)
+ return 5;
+ else
+ return 3;
+ break;
+ }
+ }
+ return 4;
+}
+
+int __signbitd(double x) {
+ return __HI(x) & 0x80000000;
+}
+
+int __fpclassifyd(double x) {
+ switch (__HI(x) & 0x7ff00000) {
+ case 0x7ff00000: {
+ if ((__HI(x) & 0x000fffff) || (__LO(x) & 0xffffffff))
+ return 1;
+ else
+ return 2;
+ break;
+ }
+ case 0: {
+ if ((__HI(x) & 0x000fffff) || (__LO(x) & 0xffffffff))
+ return 5;
+ else
+ return 3;
+ break;
+ }
+ }
+ return 4;
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/math_double.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/math_double.c
new file mode 100644
index 00000000..f70cbec6
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/math_double.c
@@ -0,0 +1,5 @@
+// necessary to generate symbols in this TU
+#undef MSL_INLINE
+#define MSL_INLINE __declspec(weak)
+
+#include <cmath>
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/mbstring.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/mbstring.c
index ef75e9cc..78bc13df 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/mbstring.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/mbstring.c
@@ -1,65 +1,308 @@
#include "mbstring.h"
-#include "string.h"
+#include <cstring>
+#include <locale.h>
+
+#include "errno.h"
+
+extern void __msl_runtime_constraint_violation_s(const char* msg, void* ptr, int error);
+
+static unsigned int is_utf8_complete(const char* buf, unsigned int len) {
+ char start_byte;
+ int checked_cnt;
+ int conts;
+ int rem_conts;
+
+ if (len == 0) {
+ return -1;
+ }
+ start_byte = buf[0];
+ if (start_byte == 0) {
+ return 0;
+ }
+ if ((start_byte & 0x80) == 0) {
+ return 1;
+ }
+ if ((start_byte & 0xe0) == 0xc0) {
+ conts = 1;
+ } else if ((start_byte & 0xf0) == 0xe0) {
+ conts = 2;
+ } else if ((start_byte & 0xf8) == 0xf0) {
+ conts = 3;
+ } else if ((start_byte & 0xfc) == 0xf8) {
+ conts = 4;
+ } else if ((start_byte & 0xfe) == 0xfc) {
+ conts = 5;
+ } else {
+ return 0xffffffff;
+ }
+ checked_cnt = 0;
+ for (rem_conts = conts; rem_conts > 0; rem_conts--) {
+ if ((buf[checked_cnt + 1] & 0xc0) != 0x80) {
+ return 0xffffffff;
+ }
+ checked_cnt++;
+ }
+ if (len >= checked_cnt + 1U) {
+ return conts + 1;
+ }
+ return 0xfffffffe;
+}
+
+static int __utf8_to_unicode(wchar_t* dst, const char* src, unsigned int len) {
+ short byte_cnt;
+ int remaining;
+ int codepoint;
+
+ codepoint = 0;
+ if (src == NULL) {
+ return 0;
+ }
+
+ if (len == 0) {
+ return -1;
+ }
+
+ byte_cnt = is_utf8_complete(src, len);
+ if (byte_cnt < 0) {
+ return -1;
+ }
+ switch (byte_cnt) {
+ case 6:
+ codepoint = *src & ((1 << 2) - 1);
+ break;
+ case 5:
+ codepoint = *src & ((1 << 3) - 1);
+ break;
+ case 4:
+ codepoint = *src & ((1 << 4) - 1);
+ break;
+ case 3:
+ codepoint = *src & ((1 << 5) - 1);
+ break;
+ case 2:
+ codepoint = *src & ((1 << 6) - 1);
+ break;
+ case 1:
+ codepoint = *src;
+ break;
+ }
+
+ for (remaining = byte_cnt - 1; remaining > 0; remaining--) {
+ codepoint <<= 6;
+ codepoint |= *++src & 0x7f;
+ }
+
+ if (codepoint == 0) {
+ remaining = 0;
+ } else if (codepoint < 0 || codepoint < 0x80) {
+ remaining = 1;
+ } else if (codepoint < 0x800) {
+ remaining = 2;
+ } else if (codepoint < 0x10000) {
+ remaining = 3;
+ } else if (codepoint < 0x200000) {
+ remaining = 4;
+ } else if (codepoint < 0x4000000) {
+ remaining = 5;
+ } else {
+ remaining = 6;
+ }
+
+ if (remaining != byte_cnt) {
+ return -1;
+ }
+
+ if (dst != NULL) {
+ *dst = codepoint;
+ }
+
+ return byte_cnt;
+}
+
+#if !PLATFORM_GCN
+int mbtowc(wchar_t* pwc, const char* s, size_t n) {
+ return _current_locale.ctype_cmpt_ptr->decode_mb(pwc, s, n);
+}
+#endif
inline static int unicode_to_UTF8(char* s, wchar_t wchar) {
- int number_of_bytes;
- wchar_t wide_char;
- char* target_ptr;
- char first_byte_mark[4] = { 0x00, 0x00, 0xc0, 0xe0 };
-
- if (!s)
- return (0);
-
- wide_char = wchar;
- if (wide_char < 0x0080)
- number_of_bytes = 1;
- else if (wide_char < 0x0800)
- number_of_bytes = 2;
- else
- number_of_bytes = 3;
-
- target_ptr = s + number_of_bytes;
-
- switch (number_of_bytes) {
- case 3:
- *--target_ptr = (wide_char & 0x003f) | 0x80;
- wide_char >>= 6;
- case 2:
- *--target_ptr = (wide_char & 0x003f) | 0x80;
- wide_char >>= 6;
- case 1:
- *--target_ptr = wide_char | first_byte_mark[number_of_bytes];
- }
-
- return number_of_bytes;
+ int number_of_bytes;
+ wchar_t wide_char;
+ char* target_ptr;
+ char first_byte_mark[4] = { 0x00, 0x00, 0xc0, 0xe0 };
+
+ if (!s)
+ return (0);
+
+ wide_char = wchar;
+ if (wide_char < 0x0080)
+ number_of_bytes = 1;
+ else if (wide_char < 0x0800)
+ number_of_bytes = 2;
+ else
+ number_of_bytes = 3;
+
+ target_ptr = s + number_of_bytes;
+
+ switch (number_of_bytes) {
+ case 3:
+ *--target_ptr = (wide_char & 0x003f) | 0x80;
+ wide_char >>= 6;
+ case 2:
+ *--target_ptr = (wide_char & 0x003f) | 0x80;
+ wide_char >>= 6;
+ case 1:
+ *--target_ptr = wide_char | first_byte_mark[number_of_bytes];
+ }
+
+ return number_of_bytes;
}
-inline int wctomb(char* s, wchar_t wchar) { return (unicode_to_UTF8(s, wchar)); }
+int __mbtowc_noconv(wchar_t* pwc, const char* s, size_t n) {
+ if (!s)
+ return 0;
+
+ if (!n)
+ return -1;
+
+ if (pwc)
+ *pwc = (unsigned char)*s;
+
+ if (!*s)
+ return(0);
+
+ return 1;
+}
+
+int __wctomb_noconv(char* s, wchar_t wchar) {
+ if (!s)
+ return 0;
+
+ *s = wchar;
+ return 1;
+}
+
+int mbstowcs(wchar_t* param_0, const char* param_1, int param_2) {
+ unsigned int i;
+ int decoded_cnt;
+ int remaining = strlen(param_1);
+ if (param_0 != NULL) {
+ for (i = 0; i < param_2; i++) {
+ if (param_1[0] != '\0') {
+ decoded_cnt =
+ _current_locale.ctype_cmpt_ptr->decode_mb(param_0++, param_1, remaining);
+ if (decoded_cnt > 0) {
+ param_1 += decoded_cnt;
+ remaining -= decoded_cnt;
+ continue;
+ }
+ return -1;
+ }
+ param_0[0] = L'\0';
+ break;
+ }
+ } else {
+ i = 0;
+ }
+
+ return i;
+}
+
+int wctomb(char* s, wchar_t wchar) {
+ #if PLATFORM_GCN
+ return (unicode_to_UTF8(s, wchar));
+ #else
+ return _current_locale.ctype_cmpt_ptr->encode_wc(s, wchar);
+ #endif
+}
-/* 80365F74-8036608C 3608B4 0118+00 0/0 1/1 0/0 .text wcstombs */
size_t wcstombs(char* s, const wchar_t* pwcs, size_t n) {
- int chars_written = 0;
- int result;
- char temp[3];
- wchar_t* source;
-
- if (!s || !pwcs)
- return (0);
-
- source = (wchar_t*)pwcs;
- while (chars_written <= n) {
- if (!*source) {
- *(s + chars_written) = '\0';
- break;
- } else {
- result = wctomb(temp, *source++);
- if ((chars_written + result) <= n) {
- strncpy(s + chars_written, temp, result);
- chars_written += result;
- } else
- break;
- }
- }
-
- return chars_written;
-} \ No newline at end of file
+ int chars_written = 0;
+ int result;
+ char temp[3];
+ wchar_t* source;
+
+ if (!s || !pwcs)
+ return (0);
+
+ source = (wchar_t*)pwcs;
+ while (chars_written <= n) {
+ if (!*source) {
+ *(s + chars_written) = '\0';
+ break;
+ } else {
+ result = wctomb(temp, *source++);
+ if ((chars_written + result) <= n) {
+ strncpy(s + chars_written, temp, result);
+ chars_written += result;
+ } else
+ break;
+ }
+ }
+
+ return chars_written;
+}
+
+int mbsrtowcs_s(size_t* retval, wchar_t* dst, unsigned int dstsz, const char** param_4,
+ size_t len, int param_6) {
+ wchar_t* var_r27;
+ const char* var_r24;
+ unsigned int var_r25;
+ int var_r26;
+ wchar_t sp08[4];
+
+ if (retval == NULL || param_4 == NULL || *param_4 == NULL || param_6 == 0 ||
+ (dst != NULL && (len > 0x7fffffff || dstsz > 0x7fffffff || dstsz < len)))
+ {
+ __msl_runtime_constraint_violation_s(NULL, NULL, 0x22);
+ if (retval != NULL) {
+ *retval = 0xffffffff;
+ }
+ return 0x22;
+ }
+
+ var_r24 = *param_4;
+ var_r26 = strlen(var_r24);
+ for (var_r25 = 0; var_r25 < len; var_r25++) {
+ if (*var_r24 != '\0') {
+ int var_r3_1;
+
+ if (dst == NULL) {
+ var_r27 = sp08;
+ } else {
+ var_r27 = dst++;
+ }
+
+ if (var_r24 != NULL) {
+ var_r3_1 = is_utf8_complete(var_r24, var_r26);
+ if (var_r3_1 < 0xfffffffe) {
+ if (var_r27 != NULL) {
+ var_r3_1 = __utf8_to_unicode(var_r27, var_r24, var_r26);
+ } else if (var_r3_1 == 0xffffffff) {
+ errno = 0x58;
+ }
+ }
+ } else {
+ if (var_r27 != NULL) {
+ *var_r27 = L'\0';
+ }
+ var_r3_1 = 0;
+ }
+
+ if (var_r3_1 <= 0) {
+ break;
+ }
+
+ var_r24 += var_r3_1;
+ var_r26 -= var_r3_1;
+ } else {
+ if (dst != NULL) {
+ *dst = 0;
+ *param_4 = 0;
+ }
+ break;
+ }
+ }
+ *retval = var_r25;
+ return 0;
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/mem.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/mem.c
index 6323fb82..528db092 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/mem.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/mem.c
@@ -1,9 +1,9 @@
-#include "string.h"
+#include "mem_funcs.h"
+#include <cstring>
-/* 80366130-803661FC 360A70 00CC+00 0/0 2/2 0/0 .text memmove */
void* memmove(void* dst, const void* src, size_t n) {
- unsigned char* csrc;
- unsigned char* cdst;
+ const char* csrc;
+ char* cdst;
int reverse = (unsigned int)src < (unsigned int)dst;
@@ -25,19 +25,11 @@ void* memmove(void* dst, const void* src, size_t n) {
return dst;
} else {
if (!reverse) {
- csrc = ((unsigned char*)src) - 1;
- cdst = ((unsigned char*)dst) - 1;
- n++;
-
- while (--n > 0) {
+ for (csrc = (const char*)src - 1, cdst = (char*)dst - 1, n++; --n;){
*++cdst = *++csrc;
}
} else {
- csrc = (unsigned char*)src + n;
- cdst = (unsigned char*)dst + n;
- n++;
-
- while (--n > 0) {
+ for (csrc = (const char*)src + n, cdst = (char*)dst + n, n++; --n;){
*--cdst = *--csrc;
}
}
@@ -46,7 +38,6 @@ void* memmove(void* dst, const void* src, size_t n) {
return dst;
}
-/* 80366104-80366130 360A44 002C+00 0/0 1/1 0/0 .text memchr */
void* memchr(const void* ptr, int ch, size_t count) {
const unsigned char* p;
@@ -59,7 +50,6 @@ void* memchr(const void* ptr, int ch, size_t count) {
return NULL;
}
-/* 803660D8-80366104 360A18 002C+00 0/0 1/1 0/0 .text __memrchr */
void* __memrchr(const void* ptr, int ch, size_t count) {
const unsigned char* p;
@@ -72,7 +62,6 @@ void* __memrchr(const void* ptr, int ch, size_t count) {
return NULL;
}
-/* 8036608C-803660D8 3609CC 004C+00 0/0 19/19 5/5 .text memcmp */
int memcmp(const void* lhs, const void* rhs, size_t count) {
const unsigned char* p1;
const unsigned char* p2;
@@ -82,4 +71,4 @@ int memcmp(const void* lhs, const void* rhs, size_t count) {
return ((*p1 < *p2) ? -1 : +1);
return 0;
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/mem_funcs.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/mem_funcs.c
index bc2eae80..98096e10 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/mem_funcs.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/mem_funcs.c
@@ -6,7 +6,6 @@
#define lpd ((unsigned long*)dst)
#define deref_auto_inc(p) *++(p)
-/* 80366410-803664CC 360D50 00BC+00 0/0 1/1 0/0 .text __copy_longs_aligned */
void __copy_longs_aligned(void* dst, const void* src, size_t n) {
unsigned long i;
@@ -60,7 +59,6 @@ void __copy_longs_aligned(void* dst, const void* src, size_t n) {
return;
}
-/* 80366368-80366410 360CA8 00A8+00 0/0 1/1 0/0 .text __copy_longs_rev_aligned */
void __copy_longs_rev_aligned(void* dst, const void* src, size_t n) {
unsigned long i;
@@ -108,7 +106,6 @@ void __copy_longs_rev_aligned(void* dst, const void* src, size_t n) {
return;
}
-/* 803662A8-80366368 360BE8 00C0+00 0/0 1/1 0/0 .text __copy_longs_unaligned */
void __copy_longs_unaligned(void* dst, const void* src, size_t n) {
unsigned long i, v1, v2;
unsigned int src_offset, left_shift, right_shift;
@@ -167,7 +164,6 @@ void __copy_longs_unaligned(void* dst, const void* src, size_t n) {
return;
}
-/* 803661FC-803662A8 360B3C 00AC+00 0/0 1/1 0/0 .text __copy_longs_rev_unaligned */
void __copy_longs_rev_unaligned(void* dst, const void* src, size_t n) {
unsigned long i, v1, v2;
unsigned int src_offset, left_shift, right_shift;
@@ -192,6 +188,11 @@ void __copy_longs_rev_unaligned(void* dst, const void* src, size_t n) {
cps += 4 - src_offset;
+ #if !PLATFORM_GCN
+ cps = ((unsigned char *) lps);
+ cpd = ((unsigned char *) lpd);
+ #endif
+
i = n >> 3;
v1 = *--lps;
@@ -210,6 +211,11 @@ void __copy_longs_rev_unaligned(void* dst, const void* src, size_t n) {
n &= 3;
+ #if !PLATFORM_GCN
+ cps = ((unsigned char *) lps);
+ cpd = ((unsigned char *) lpd);
+ #endif
+
if (n) {
cps += src_offset;
do
@@ -218,4 +224,4 @@ void __copy_longs_rev_unaligned(void* dst, const void* src, size_t n) {
}
return;
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/misc_io.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/misc_io.c
index d1b7ffdf..61bc2125 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/misc_io.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/misc_io.c
@@ -2,7 +2,6 @@
#include "abort_exit.h"
#include "ansi_files.h"
-/* 803664CC-803664DC 360E0C 0010+00 0/0 2/2 0/0 .text __stdio_atexit */
void __stdio_atexit(void) {
__stdio_exit = __close_all;
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/printf.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/printf.c
index 04423f91..f1b6bd64 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/printf.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/printf.c
@@ -1,11 +1,17 @@
#include "printf.h"
#include "ansi_fp.h"
#include "critical_regions.h"
-#include "ctype.h"
+#include "direct_io.h"
+#include "mbstring.h"
#include "scanf.h"
-#include "stdio.h"
-#include "string.h"
#include "wchar_io.h"
+#include <cctype>
+#include <cmath>
+#include <cstdio>
+#include <cstring>
+#include <cstdint>
+
+#define LDBL_MANT_DIG 53
#define TARGET_FLOAT_BITS 64
#define TARGET_FLOAT_BYTES (TARGET_FLOAT_BITS / 8)
@@ -15,6 +21,8 @@
#define TARGET_FLOAT_MANT_BITS (TARGET_FLOAT_MANT_DIG - TARGET_FLOAT_IMPLICIT_J_BIT)
#define TARGET_FLOAT_EXP_BITS (TARGET_FLOAT_BITS - TARGET_FLOAT_MANT_BITS - 1)
+extern void __msl_runtime_constraint_violation_s(const char* msg, void* ptr, int error);
+
enum justification_options { left_justification, right_justification, zero_fill };
enum sign_options { only_minus, sign_always, space_holder };
@@ -25,8 +33,18 @@ enum argument_options {
short_argument,
long_argument,
long_long_argument,
+ #if PLATFORM_GCN
+ long_double_argument,
+ #endif
+ wchar_argument,
+
+ intmax_argument,
+ size_t_argument,
+ ptrdiff_argument,
+
+ #if !PLATFORM_GCN
long_double_argument,
- wchar_argument
+ #endif
};
typedef struct {
@@ -40,7 +58,6 @@ typedef struct {
int precision;
} print_format;
-/* 80368288-8036878C 362BC8 0504+00 3/1 0/0 0/0 .text parse_format */
static const char* parse_format(const char* format_string, va_list* arg, print_format* format) {
print_format f;
const char* s = format_string;
@@ -152,12 +169,21 @@ static const char* parse_format(const char* format_string, va_list* arg, print_f
f.argument_options = long_long_argument;
c = *++s;
}
-
break;
-
case 'L':
f.argument_options = long_double_argument;
break;
+#if !PLATFORM_GCN
+ case 'j':
+ f.argument_options = intmax_argument;
+ break;
+ case 't':
+ f.argument_options = ptrdiff_argument;
+ break;
+ case 'z':
+ f.argument_options = size_t_argument;
+ break;
+#endif
default:
flag_found = 0;
break;
@@ -190,7 +216,14 @@ static const char* parse_format(const char* format_string, va_list* arg, print_f
case 'f':
case 'F':
- if (f.argument_options == short_argument || f.argument_options == long_long_argument) {
+ if (f.argument_options == short_argument
+ #if !PLATFORM_GCN
+ || f.argument_options == intmax_argument
+ || f.argument_options == size_t_argument
+ || f.argument_options == ptrdiff_argument
+ #endif
+ || f.argument_options == long_long_argument)
+ {
f.conversion_char = 0xFF;
break;
}
@@ -206,8 +239,14 @@ static const char* parse_format(const char* format_string, va_list* arg, print_f
f.precision = 0xD;
}
- if (f.argument_options == short_argument || f.argument_options == long_long_argument ||
- f.argument_options == char_argument)
+ if (f.argument_options == short_argument
+ #if !PLATFORM_GCN
+ || f.argument_options == intmax_argument
+ || f.argument_options == size_t_argument
+ || f.argument_options == ptrdiff_argument
+ #endif
+ || f.argument_options == long_long_argument
+ || f.argument_options == char_argument)
{
f.conversion_char = 0xFF;
}
@@ -222,8 +261,14 @@ static const char* parse_format(const char* format_string, va_list* arg, print_f
case 'e':
case 'E':
- if (f.argument_options == short_argument || f.argument_options == long_long_argument ||
- f.argument_options == char_argument)
+ if (f.argument_options == short_argument
+ #if !PLATFORM_GCN
+ || f.argument_options == intmax_argument
+ || f.argument_options == size_t_argument
+ || f.argument_options == ptrdiff_argument
+ #endif
+ || f.argument_options == long_long_argument
+ || f.argument_options == char_argument)
{
f.conversion_char = 0xFF;
break;
@@ -279,7 +324,6 @@ static const char* parse_format(const char* format_string, va_list* arg, print_f
return ((const char*)s + 1);
}
-/* 80368030-80368288 362970 0258+00 3/2 0/0 0/0 .text long2str */
static char* long2str(signed long num, char* buff, print_format format) {
unsigned long unsigned_num, base;
char* p;
@@ -302,7 +346,11 @@ static char* long2str(signed long num, char* buff, print_format format) {
base = 10;
if (num < 0) {
- unsigned_num = -unsigned_num;
+ #if !PLATFORM_GCN
+ if (num != 0x8000000000000000L)
+ #endif
+ unsigned_num = -unsigned_num;
+
minus = 1;
}
break;
@@ -383,7 +431,6 @@ static char* long2str(signed long num, char* buff, print_format format) {
return p;
}
-/* 80367D1C-80368030 36265C 0314+00 2/1 0/0 0/0 .text longlong2str */
static char* longlong2str(signed long long num, char* pBuf, print_format fmt) {
unsigned long long unsigned_num, base;
char* p;
@@ -405,7 +452,11 @@ static char* longlong2str(signed long long num, char* pBuf, print_format fmt) {
base = 10;
if (num < 0) {
- unsigned_num = -unsigned_num;
+ #if !PLATFORM_GCN
+ if (num != 0x8000000000000000LL)
+ #endif
+ unsigned_num = -unsigned_num;
+
minus = 1;
}
break;
@@ -485,8 +536,8 @@ static char* longlong2str(signed long long num, char* pBuf, print_format fmt) {
return p;
}
-/* 803679E4-80367D1C 362324 0338+00 1/1 0/0 0/0 .text double2hex */
static char* double2hex(long double num, char* buff, print_format format) {
+ #if PLATFORM_GCN
int offset, what_nibble = 0;
char* wrk_byte_ptr;
char *p, *q;
@@ -612,9 +663,177 @@ static char* double2hex(long double num, char* buff, print_format format) {
}
return p;
+#else
+ char *p;
+ unsigned char *q;
+ unsigned char working_byte;
+ long double ld;
+ int expbits, expmask;
+ unsigned snum;
+ long exp;
+ print_format exp_format;
+ int hex_precision;
+ int mantissa_bit;
+ decform form;
+ decimal dec;
+ int radix_marker;
+
+ radix_marker = *(unsigned char *)(__lconv).decimal_point;
+ p = buff;
+ ld = num;
+
+ if (format.precision > 509) {
+ return 0;
+ }
+
+ form.style = (char)0;
+ form.digits = 0x20;
+ __num2dec(&form, num, &dec);
+
+ switch(*dec.sig.text){
+ case '0':
+ dec.exp = 0;
+ break;
+ case 'I':
+ if (dec.sign) {
+ p = buff - 5;
+ if (format.conversion_char == 'A') strcpy(p, "-INF");
+ else strcpy(p, "-inf");
+ }
+ else {
+ p = buff - 4;
+ if (format.conversion_char == 'A') strcpy(p, "INF");
+ else strcpy(p, "inf");
+ }
+
+ return p;
+ case 'N':
+ if (dec.sign) {
+ p = buff - 5;
+ if (format.conversion_char == 'A') strcpy(p, "-NAN");
+ else strcpy(p, "-nan");
+ }
+ else {
+ p = buff - 4;
+ if (format.conversion_char == 'A') strcpy(p, "NAN");
+ else strcpy(p, "nan");
+ }
+
+ return p;
+ }
+
+ exp_format.justification_options = right_justification;
+ exp_format.sign_options = sign_always;
+ exp_format.precision_specified = 0;
+ exp_format.alternate_form = 0;
+ exp_format.argument_options = normal_argument;
+ exp_format.field_width = 0;
+ exp_format.precision = 1;
+ exp_format.conversion_char = 'd';
+
+ expbits = 11;
+ expmask = 0x7FF;
+
+ snum = ((unsigned char *)&num)[0] << 25;
+ if (TARGET_FLOAT_EXP_BITS > 7)
+ snum |= ((unsigned char *)&num)[1] << 17;
+ if (TARGET_FLOAT_EXP_BITS > 15)
+ snum |= ((unsigned char *)&num)[2] << 9;
+ if (TARGET_FLOAT_EXP_BITS > 23)
+ snum |= ((unsigned char *)&num)[3] << 1;
+
+ snum = (snum >> (32 - expbits)) & expmask;
+
+ if(snum != 0)
+ exp = snum - 0x3FF;
+ else
+ exp = 0;
+
+ p = long2str(exp, buff, exp_format);
+ if (format.conversion_char == 'a')
+ *--p = 'p';
+ else
+ *--p = 'P';
+ q = (unsigned char *)&num;
+
+ if (TARGET_FLOAT_IMPLICIT_J_BIT) {
+ mantissa_bit = (1 + expbits + format.precision * 4) - 1;
+ }
+ else {
+ mantissa_bit = (1 + expbits + format.precision * 4) - 4;
+ }
+
+ for (hex_precision = format.precision; hex_precision >= 1; hex_precision--) {
+ if (mantissa_bit < 64) {
+ int mantissa_byte;
+
+ mantissa_byte = mantissa_bit >> 3;
+ working_byte = (*(q + mantissa_byte)) >> (7 - (mantissa_bit & 7));
+
+ if ((mantissa_bit & ~7) != ((mantissa_bit - 4) & ~7)) {
+ working_byte |= (unsigned char)(((*(q + (mantissa_byte - 1))) << 8) >> (7 - ((mantissa_bit) & 7)));
+ }
+
+ if (!TARGET_FLOAT_IMPLICIT_J_BIT) {
+ if (mantissa_bit == 1 + expbits) {
+ *--p = radix_marker;
+ working_byte &= 0x1;
+ }
+ }
+
+ if ((working_byte &= 0xF) < 10) {
+ working_byte += (unsigned char)'0';
+ }
+ else
+ if (format.conversion_char == 'a') {
+ working_byte += (unsigned char)('a' - 10);
+ }
+ else {
+ working_byte += (unsigned char)('A' - 10);
+ }
+ }
+ else {
+ working_byte = '0';
+ }
+
+ *--p = working_byte;
+ mantissa_bit -= 4;
+ }
+
+ if (TARGET_FLOAT_IMPLICIT_J_BIT){
+ if (format.precision || format.alternate_form) {
+ *--p = radix_marker;
+ }
+
+ if(fabsl(ld) != 0.0)
+ *--p = '1';
+ else
+ *--p = '0';
+ }
+
+ if (format.conversion_char == 'a') {
+ *--p = 'x';
+ }
+ else {
+ *--p = 'X';
+ }
+
+ *--p = '0';
+
+ if (dec.sign) {
+ *--p = '-';
+ }
+ else if (format.sign_options == sign_always) {
+ *--p = '+';
+ }
+ else if (format.sign_options == space_holder) {
+ *--p = ' ';
+ }
+
+ return p;
+ #endif
}
-/* 803678B8-803679E4 3621F8 012C+00 1/1 0/0 0/0 .text round_decimal */
static void round_decimal(decimal* dec, int new_length) {
char c;
char* p;
@@ -668,7 +887,6 @@ static void round_decimal(decimal* dec, int new_length) {
dec->sig.length = new_length;
}
-/* 8036719C-803678B8 361ADC 071C+00 1/1 0/0 0/0 .text float2str */
static char* float2str(long double num, char* buff, print_format format) {
decimal dec;
decform form;
@@ -678,7 +896,11 @@ static char* float2str(long double num, char* buff, print_format format) {
int int_digits, frac_digits;
int radix_marker;
+ #if PLATFORM_GCN
radix_marker = '.';
+ #else
+ radix_marker = *(unsigned char*)__lconv.decimal_point;
+ #endif
if (format.precision > 509) {
return 0;
@@ -739,7 +961,12 @@ static char* float2str(long double num, char* buff, print_format format) {
return p;
}
- dec.exp += dec.sig.length - 1;
+ #if PLATFORM_GCN
+ dec.exp += (dec.sig.length - 1);
+ #else
+ dec.exp += (short)(dec.sig.length - 1);
+ #endif
+
p = buff;
*--p = 0;
@@ -890,9 +1117,13 @@ static char* float2str(long double num, char* buff, print_format format) {
return p;
}
-/* 80366A28-8036719C 361368 0774+00 6/6 0/0 0/0 .text __pformatter */
static int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* WriteProcArg,
- const char* format_str, va_list arg) {
+ const char* format_str, va_list arg
+ #if !PLATFORM_GCN
+ ,int is_secure
+ #endif
+ )
+{
int num_chars, chars_written, field_width;
const char* format_ptr;
const char* curr_format;
@@ -937,7 +1168,19 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* Wr
long_num = va_arg(arg, signed long);
} else if (format.argument_options == long_long_argument) {
long_long_num = va_arg(arg, signed long long);
- } else {
+ }
+ #if !PLATFORM_GCN
+ else if (format.argument_options == intmax_argument) {
+ long_long_num = va_arg(arg, intmax_t);
+ }
+ else if (format.argument_options == size_t_argument) {
+ long_num = va_arg(arg, size_t);
+ }
+ else if (format.argument_options == ptrdiff_argument) {
+ long_num = va_arg(arg, ptrdiff_t);
+ }
+ #endif
+ else {
long_num = va_arg(arg, int);
}
@@ -949,7 +1192,12 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* Wr
long_num = (signed char)long_num;
}
- if ((format.argument_options == long_long_argument)) {
+ if ((format.argument_options == long_long_argument)
+ #if !PLATFORM_GCN
+ || format.argument_options == intmax_argument
+ #endif
+ )
+ {
if (!(buff_ptr = longlong2str(long_long_num, buff + 512, format))) {
goto conversion_error;
}
@@ -970,7 +1218,19 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* Wr
long_num = va_arg(arg, unsigned long);
} else if (format.argument_options == long_long_argument) {
long_long_num = va_arg(arg, signed long long);
- } else {
+ }
+ #if !PLATFORM_GCN
+ else if (format.argument_options == intmax_argument) {
+ long_long_num = va_arg(arg, intmax_t);
+ }
+ else if (format.argument_options == size_t_argument) {
+ long_num = va_arg(arg, size_t);
+ }
+ else if (format.argument_options == ptrdiff_argument) {
+ long_num = va_arg(arg, ptrdiff_t);
+ }
+ #endif
+ else {
long_num = va_arg(arg, unsigned int);
}
@@ -982,7 +1242,12 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* Wr
long_num = (unsigned char)long_num;
}
- if ((format.argument_options == long_long_argument)) {
+ if ((format.argument_options == long_long_argument)
+ #if !PLATFORM_GCN
+ || format.argument_options == intmax_argument
+ #endif
+ )
+ {
if (!(buff_ptr = longlong2str(long_long_num, buff + 512, format))) {
goto conversion_error;
}
@@ -1033,6 +1298,13 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* Wr
if (format.argument_options == wchar_argument) {
wchar_t* wcs_ptr = va_arg(arg, wchar_t*);
+ #if !PLATFORM_GCN
+ if (is_secure && wcs_ptr == NULL){
+ __msl_runtime_constraint_violation_s(0,0,-1);
+ return -1;
+ }
+ #endif
+
if (wcs_ptr == NULL) {
wcs_ptr = L"";
}
@@ -1046,6 +1318,13 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* Wr
buff_ptr = va_arg(arg, char*);
}
+ #if !PLATFORM_GCN
+ if (is_secure && buff_ptr == NULL){
+ __msl_runtime_constraint_violation_s(0,0,-1);
+ return -1;
+ }
+ #endif
+
if (buff_ptr == NULL) {
buff_ptr = "";
}
@@ -1071,6 +1350,13 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* Wr
case 'n':
buff_ptr = va_arg(arg, char*);
+ #if !PLATFORM_GCN
+ if (is_secure){
+ __msl_runtime_constraint_violation_s(0,0,-1);
+ return -1;
+ }
+ #endif
+
switch (format.argument_options) {
case normal_argument:
*(int*)buff_ptr = chars_written;
@@ -1081,6 +1367,17 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* Wr
case long_argument:
*(signed long*)buff_ptr = chars_written;
break;
+ #if !PLATFORM_GCN
+ case intmax_argument:
+ *(intmax_t*)buff_ptr = chars_written;
+ break;
+ case size_t_argument:
+ *(size_t*)buff_ptr = chars_written;
+ break;
+ case ptrdiff_argument:
+ *(ptrdiff_t*)buff_ptr = chars_written;
+ break;
+ #endif
case long_long_argument:
*(signed long long*)buff_ptr = chars_written;
break;
@@ -1130,6 +1427,18 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* Wr
num_chars--;
}
+ #if !PLATFORM_GCN
+ if ((format.justification_options == zero_fill) && ((format.conversion_char == 'a') || (format.conversion_char == 'A')))
+ {
+ if (num_chars < 2)
+ return(-1);
+ if ((*WriteProc)(WriteProcArg, buff_ptr, 2) == 0)
+ return(-1);
+ num_chars -= 2;
+ buff_ptr += 2;
+ }
+ #endif
+
while (field_width < format.field_width) {
if ((*WriteProc)(WriteProcArg, &fill_char, 1) == 0) {
return -1;
@@ -1161,12 +1470,14 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t), void* Wr
return chars_written;
}
-/* 803669D0-80366A28 361310 0058+00 3/3 0/0 0/0 .text __FileWrite */
static void* __FileWrite(void* pFile, const char* pBuffer, size_t char_num) {
+ #if PLATFORM_GCN
return (fwrite(pBuffer, 1, char_num, (FILE*)pFile) == char_num ? pFile : 0);
+ #else
+ return (__fwrite(pBuffer, 1, char_num, (FILE*)pFile) == char_num ? pFile : 0);
+ #endif
}
-/* 80366964-803669D0 3612A4 006C+00 3/3 0/0 0/0 .text __StringWrite */
static void* __StringWrite(void* pCtrl, const char* pBuffer, size_t char_num) {
size_t chars;
__OutStrCtrl* ctrl = (__OutStrCtrl*)pCtrl;
@@ -1180,7 +1491,6 @@ static void* __StringWrite(void* pCtrl, const char* pBuffer, size_t char_num) {
return (void*)1;
}
-/* 8036687C-80366964 3611BC 00E8+00 0/0 4/4 0/0 .text printf */
int printf(const char* format, ...) {
int res;
@@ -1192,13 +1502,16 @@ int printf(const char* format, ...) {
{
va_list args;
va_start(args, format);
+ #if PLATFORM_GCN
res = __pformatter(&__FileWrite, (void*)stdout, format, args);
+ #else
+ res = __pformatter(&__FileWrite, (void*)stdout, format, args, 0);
+ #endif
}
__end_critical_region(stdin_access);
return res;
}
-/* 8036679C-8036687C 3610DC 00E0+00 0/0 9/9 0/0 .text fprintf */
int fprintf(FILE* file, const char* format, ...) {
int res;
@@ -1210,13 +1523,16 @@ int fprintf(FILE* file, const char* format, ...) {
{
va_list args;
va_start(args, format);
+ #if PLATFORM_GCN
res = __pformatter(&__FileWrite, (void*)file, format, args);
+ #else
+ res = __pformatter(&__FileWrite, (void*)file, format, args, 0);
+ #endif
}
__end_critical_region(stdin_access);
return res;
}
-/* 80366704-8036679C 361044 0098+00 0/0 2/2 0/0 .text vprintf */
int vprintf(const char* format, va_list arg) {
int ret;
@@ -1225,36 +1541,55 @@ int vprintf(const char* format, va_list arg) {
}
__begin_critical_region(stdin_access);
+ #if PLATFORM_GCN
ret = __pformatter(&__FileWrite, (void*)stdout, format, arg);
+ #else
+ ret = __pformatter(&__FileWrite, (void*)stdout, format, arg, 0);
+ #endif
__end_critical_region(stdin_access);
return ret;
}
-/* 80366690-80366704 360FD0 0074+00 0/0 8/8 0/0 .text vsnprintf */
-int vsnprintf(char* s, size_t n, const char* format, va_list arg) {
+int vsnprintf(char* s, size_t n, const char* fmt, va_list args) {
int end;
__OutStrCtrl osc;
osc.CharStr = s;
osc.MaxCharCount = n;
osc.CharsWritten = 0;
- end = __pformatter(&__StringWrite, &osc, format, arg);
+ #if PLATFORM_GCN
+ end = __pformatter(&__StringWrite, &osc, fmt, args);
+ #else
+ end = __pformatter(&__StringWrite, &osc, fmt, args, 0);
+ #endif
if (s) {
+ #if PLATFORM_GCN
s[(end < n) ? end : n - 1] = '\0';
+ #else
+ if (end < n) {
+ s[end] = '\0';
+ } else {
+ if (n > 0) {
+ s[n - 1] = '\0';
+ }
+ }
+ #endif
}
return end;
}
-/* 803665BC-80366690 360EFC 00D4+00 0/0 19/19 0/0 .text snprintf */
+int vsprintf(char *s, const char *format, va_list arg) {
+ return vsnprintf(s, 0xFFFFFFFF, format, arg);
+}
+
int snprintf(char* s, size_t n, const char* format, ...) {
va_list args;
va_start(args, format);
return vsnprintf(s, n, format, args);
}
-/* 803664DC-803665BC 360E1C 00E0+00 0/0 32/32 14/14 .text sprintf */
int sprintf(char* s, const char* format, ...) {
va_list args;
va_start(args, format);
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/scanf.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/scanf.c
index ca8a17fb..67e392b0 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/scanf.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/scanf.c
@@ -1,6 +1,745 @@
#include "scanf.h"
+#include <cctype>
+#include <cmath>
+#include <cstdio>
+#include <cstdint>
+#include <strtoul.h>
+#include <strtold.h>
+
+enum argument_options {
+ normal_argument,
+ char_argument,
+ short_argument,
+ long_argument,
+ intmax_argument,
+ size_t_argument,
+ ptrdiff_argument,
+ long_long_argument,
+ double_argument,
+ long_double_argument,
+ wchar_argument
+};
+
+typedef unsigned char char_map[32];
+
+typedef struct {
+ unsigned char suppress_assignment;
+ unsigned char field_width_specified;
+ unsigned char argument_options;
+ unsigned char conversion_char;
+ int field_width;
+ char_map char_set;
+} scan_format;
+
+#define set_char_map(map, ch) map[(unsigned char)ch >> 3] |= (1 << (ch & 7))
+#define tst_char_map(map, ch) (map[(unsigned char)ch >> 3] & (1 << (ch & 7)))
+
+static const char* parse_format(const char* format_string, scan_format *format) {
+ const char* s = format_string;
+ int c;
+ int flag_found, invert;
+ scan_format f = { 0, 0, normal_argument, 0, 2147483647, { 0 } };
+
+ if (((c = *++s) == '%')) {
+ f.conversion_char = c;
+ *format = f;
+ return ((const char*)s + 1);
+ }
+
+ if (c == '*') {
+ f.suppress_assignment = 1;
+ c = *++s;
+ }
+
+ if (isdigit(c)) {
+ f.field_width = 0;
+
+ do {
+ f.field_width = (f.field_width * 10) + (c - '0');
+ c = *++s;
+ } while (isdigit(c));
+
+ if (f.field_width == 0) {
+ f.conversion_char = 0xFF;
+ *format = f;
+ return ((const char*)s + 1);
+ }
+
+ f.field_width_specified = 1;
+ }
+
+ flag_found = 1;
+
+ switch (c) {
+ case 'h':
+ f.argument_options = short_argument;
+
+ if (s[1] == 'h') {
+ f.argument_options = char_argument;
+ c = *++s;
+ }
+
+ break;
+ case 'l':
+ f.argument_options = long_argument;
+
+ if (s[1] == 'l') {
+ f.argument_options = long_long_argument;
+ c = *++s;
+ }
+
+ break;
+ case 'L':
+ f.argument_options = long_double_argument;
+ break;
+
+ case 'j':
+ f.argument_options = intmax_argument;
+ break;
+ case 'z':
+ f.argument_options = size_t_argument;
+ break;
+ case 't':
+ f.argument_options = ptrdiff_argument;
+ break;
+ default:
+ flag_found = 0;
+ }
+
+ if (flag_found) {
+ c = *++s;
+ }
+
+ f.conversion_char = c;
+
+ switch (c) {
+ case 'd':
+ case 'i':
+ case 'u':
+ case 'o':
+ case 'x':
+ case 'X':
+ if (f.argument_options == long_double_argument) {
+ f.conversion_char = 0xFF;
+ break;
+ }
+
+ break;
+
+ case 'a':
+ case 'A':
+ case 'f':
+ case 'F':
+ case 'e':
+ case 'E':
+ case 'g':
+ case 'G':
+ if (f.argument_options == char_argument || f.argument_options == short_argument || f.argument_options == intmax_argument || f.argument_options == size_t_argument || f.argument_options == ptrdiff_argument || f.argument_options == long_long_argument) {
+ f.conversion_char = 0xFF;
+ break;
+ }
+
+ if (f.argument_options == long_argument) {
+ f.argument_options = double_argument;
+ }
+
+ break;
+
+ case 'p':
+ f.argument_options = long_argument;
+ f.conversion_char = 'x';
+ break;
+
+ case 'c':
+ if (f.argument_options == long_argument) {
+ f.argument_options = wchar_argument;
+ }
+ else {
+ if (f.argument_options != normal_argument) {
+ f.conversion_char = 0xFF;
+ }
+ }
+
+ break;
+
+ case 's':
+ if (f.argument_options == long_argument) {
+ f.argument_options = wchar_argument;
+ }
+ else {
+ if (f.argument_options != normal_argument) {
+ f.conversion_char = 0xFF;
+ }
+ }
+
+ {
+ int i;
+ unsigned char* p;
+
+ for (i = sizeof(f.char_set), p = f.char_set; i; --i) {
+ *p++ = 0xFF;
+ }
+
+ f.char_set[1] = 0xC1;
+ f.char_set[4] = 0xFE;
+ }
+
+ break;
+
+ case 'n':
+ break;
+
+ case '[':
+ if (f.argument_options == long_argument) {
+ f.argument_options = wchar_argument;
+ }
+ else {
+ if (f.argument_options != normal_argument) {
+ f.conversion_char = 0xFF;
+ }
+ }
+
+ c = *++s;
+ invert = 0;
+
+ if (c == '^') {
+ invert = 1;
+ c = *++s;
+ }
+
+ if (c == ']') {
+ set_char_map(f.char_set, ']');
+ c = *++s;
+ }
+
+ while (c && c != ']') {
+ int d;
+ set_char_map(f.char_set, c);
+
+ if (*(s + 1) == '-' && (d = *(s + 2)) != 0 && d != ']') {
+ while (++c <= d) {
+ set_char_map(f.char_set, c);
+ }
+
+ c = *(s += 3);
+ }
+ else {
+ c = *++s;
+ }
+ }
+
+ if (!c) {
+ f.conversion_char = 0xFF;
+ break;
+ }
+
+ if (invert) {
+ int i;
+ unsigned char* p;
+
+ for (i = sizeof(f.char_set), p = f.char_set; i; --i, ++p) {
+ *p = ~*p;
+ }
+
+ break;
+ }
+
+ break;
+ default:
+ f.conversion_char = 0xFF;
+ break;
+ }
+
+ *format = f;
+ return ((const char*)s + 1);
+}
+
+static int __sformatter(int (*ReadProc)(void *, int, int), void * ReadProcArg, const char * format_str, va_list arg, int is_secure)
+{
+ int num_chars, chars_read, items_assigned, conversions;
+ int base, negative, overflow;
+ int rval;
+ const char* format_ptr;
+ char format_char;
+ char c;
+ scan_format format;
+ long long_num;
+ unsigned long u_long_num;
+ long long long_long_num = 0;
+ unsigned long long u_long_long_num;
+ long double long_double_num;
+ char * arg_ptr;
+ int elem_valid;
+ size_t elem_maxsize;
+ int match_failure = 0;
+ int terminate = 0;
+
+ format_ptr = format_str;
+ chars_read = 0;
+ items_assigned = 0;
+ conversions = 0;
+
+ while (!terminate && (format_char = *format_ptr) != 0)
+ {
+ if (isspace(format_char))
+ {
+ do{
+ format_char = *++format_ptr;
+ } while (isspace(format_char));
+
+ if (!match_failure)
+ {
+ while (isspace(c = (*ReadProc)(ReadProcArg, 0, __GetAChar)))
+ ++chars_read;
+
+ (*ReadProc)(ReadProcArg, c, __UngetAChar);
+ }
+ continue;
+ }
+
+ if ((format_char != '%') && (!match_failure))
+ {
+ if ((c = (*ReadProc)(ReadProcArg, 0, __GetAChar)) != (unsigned char)format_char)
+ {
+ (*ReadProc)(ReadProcArg, c, __UngetAChar);
+ if (!is_secure)
+ goto exit;
+ else
+ {
+ match_failure = 1;
+ ++format_ptr;
+ continue;
+ }
+ }
+
+ chars_read++;
+ format_ptr++;
+
+ continue;
+ }
+
+ format_ptr = parse_format(format_ptr, &format);
+
+ if (!format.suppress_assignment && format.conversion_char != '%')
+ {
+ arg_ptr = va_arg(arg, char *);
+ }
+ else
+ {
+ arg_ptr = 0;
+ }
+
+ if ((format.conversion_char != 'n') && (!match_failure) && (*ReadProc)(ReadProcArg, 0, __TestForError))
+ {
+ if (!is_secure)
+ goto exit;
+ else
+ match_failure = 1;
+ }
+
+ switch (format.conversion_char)
+ {
+ case 'd':
+ base = 10;
+ goto signed_int;
+ case 'i':
+ base = 0;
+ signed_int:
+
+ if (match_failure)
+ {
+ long_num = 0;
+ long_long_num = 0;
+ }
+ else
+ {
+ if ((format.argument_options == long_long_argument) || (format.argument_options == intmax_argument))
+ u_long_long_num = __strtoull(base, format.field_width, ReadProc, ReadProcArg, &num_chars, &negative, &overflow);
+ else
+ u_long_num = __strtoul(base, format.field_width, ReadProc, ReadProcArg, &num_chars, &negative, &overflow);
+
+ if (!num_chars)
+ {
+ if (!is_secure)
+ goto exit;
+ else
+ {
+ match_failure = 1;
+ long_num = 0;
+ long_long_num = 0;
+ goto signed_int_assign;
+ }
+ }
+
+ chars_read += num_chars;
+
+ if ((format.argument_options == long_long_argument) || (format.argument_options == intmax_argument))
+ long_long_num = (negative ? -u_long_long_num : u_long_long_num);
+ else
+ long_num = (negative ? -u_long_num : u_long_num);
+ }
+
+ signed_int_assign:
+
+ if (arg_ptr)
+ {
+ switch (format.argument_options)
+ {
+ case normal_argument: * (int *) arg_ptr = long_num; break;
+ case char_argument: * (signed char *) arg_ptr = long_num; break;
+ case short_argument: * (short *) arg_ptr = long_num; break;
+ case long_argument: * (long *) arg_ptr = long_num; break;
+ case intmax_argument: * (intmax_t *) arg_ptr = long_long_num; break;
+ case size_t_argument: * (size_t *) arg_ptr = long_num; break;
+ case ptrdiff_argument: * (ptrdiff_t *) arg_ptr = long_num; break;
+ case long_long_argument: * (long long *) arg_ptr = long_long_num; break;
+ }
+ if (!match_failure) items_assigned++;
+ }
+
+ conversions++;
+ break;
+ case 'o':
+ base = 8;
+ goto unsigned_int;
+ case 'u':
+ base = 10;
+ goto unsigned_int;
+ case 'x':
+ case 'X':
+ base = 16;
+ unsigned_int:
+
+ if (match_failure)
+ {
+ u_long_num = 0;
+ u_long_long_num = 0;
+ }
+ else
+ {
+ if ((format.argument_options == long_long_argument) || (format.argument_options == intmax_argument))
+ u_long_long_num = __strtoull(base, format.field_width, ReadProc, ReadProcArg, &num_chars, &negative, &overflow);
+ else
+ u_long_num = __strtoul(base, format.field_width, ReadProc, ReadProcArg, &num_chars, &negative, &overflow);
+
+ if (!num_chars)
+ {
+ if (!is_secure)
+ goto exit;
+ else
+ {
+ match_failure = 1;
+ u_long_num = 0;
+ u_long_long_num = 0;
+ goto unsigned_int_assign;
+ }
+ }
+
+ chars_read += num_chars;
+
+ if (negative)
+ if (format.argument_options == long_long_argument)
+ u_long_long_num = -u_long_long_num;
+ else
+ u_long_num = -u_long_num;
+ }
+
+ unsigned_int_assign:
+
+ if (arg_ptr)
+ {
+ switch (format.argument_options)
+ {
+ case normal_argument: * (unsigned int *)arg_ptr = u_long_num; break;
+ case char_argument: * (unsigned char *)arg_ptr = u_long_num; break;
+ case short_argument: * (unsigned short *)arg_ptr = u_long_num; break;
+ case long_argument: * (unsigned long *)arg_ptr = u_long_num; break;
+ case intmax_argument: * (intmax_t *) arg_ptr = u_long_long_num; break;
+ case size_t_argument: * (size_t *) arg_ptr = u_long_num; break;
+ case ptrdiff_argument: * (ptrdiff_t *) arg_ptr = u_long_num; break;
+ case long_long_argument: * (unsigned long long *) arg_ptr = u_long_long_num; break;
+
+
+ }
+
+ if (!match_failure) items_assigned++;
+ }
+
+ conversions++;
+ break;
+ case 'a':
+ case 'A':
+ case 'f':
+ case 'F':
+ case 'e':
+ case 'E':
+ case 'g':
+ case 'G':
+ flt:
+ if (match_failure) long_double_num = NAN;
+ else
+ {
+ long_double_num = __strtold(format.field_width, ReadProc, ReadProcArg, &num_chars, &overflow);
+
+ if (!num_chars)
+ {
+ if (!is_secure)
+ goto exit;
+ else
+ {
+ match_failure = 1;
+ long_double_num = NAN;
+ goto assign_float;
+ }
+ }
+
+ chars_read += num_chars;
+ }
+
+ assign_float:
+
+ if (arg_ptr)
+ {
+ switch (format.argument_options)
+ {
+ case normal_argument: * (float *) arg_ptr = long_double_num; break;
+ case double_argument: * (double *) arg_ptr = long_double_num; break;
+ case long_double_argument: * (long double *) arg_ptr = long_double_num; break;
+ }
+
+ if (!match_failure) items_assigned++;
+ }
+
+ conversions++;
+ break;
+
+ case 'c':
+
+ if (!format.field_width_specified) format.field_width = 1;
+
+ if (arg_ptr)
+ {
+ if (is_secure)
+ {
+ elem_valid = 1;
+ elem_maxsize = va_arg(arg, size_t);
+ }
+
+ num_chars = 0;
+
+ if (match_failure)
+ {
+ if (elem_maxsize > 0)
+ *arg_ptr = 0;
+ continue;
+ }
+ else
+ {
+ char * arg_start = arg_ptr;
+
+ while (format.field_width-- && (!is_secure || ((elem_valid = (elem_maxsize > num_chars)) != 0)) && ((rval = ((*ReadProc)(ReadProcArg, 0, __GetAChar))) != -1))
+ {
+ c = rval;
+
+ if (format.argument_options == wchar_argument)
+ {
+ mbtowc(((wchar_t*)arg_ptr), (char*)(&c), 1);
+ arg_ptr += sizeof(wchar_t);
+ }
+ else
+ *arg_ptr++ = c;
+ num_chars++;
+ }
+
+ c = rval;
+ if (!num_chars || (is_secure && !elem_valid))
+ {
+ if (!is_secure)
+ goto exit;
+ else
+ {
+ match_failure = 1;
+ if (elem_maxsize > 0)
+ *arg_start = 0;
+ continue;
+ }
+ }
+
+ chars_read += num_chars;
+
+ items_assigned++;
+ }
+ }
+ else
+ {
+ num_chars = 0;
+
+ while (format.field_width-- && ((rval = ((*ReadProc)(ReadProcArg, 0, __GetAChar))) != -1))
+ {
+ c = rval;
+ num_chars++;
+ }
+ c = rval;
+ if (!num_chars) goto exit;
+ }
+
+ conversions++;
+ break;
+
+ case '%':
+ if (match_failure)
+ continue;
+ else
+ {
+ while (isspace(c = (*ReadProc)(ReadProcArg, 0, __GetAChar)))
+ chars_read++;
+
+ if (c != '%')
+ {
+ (*ReadProc)(ReadProcArg, c, __UngetAChar);
+ if (!is_secure)
+ goto exit;
+ else
+ {
+ match_failure = 1;
+ continue;
+ }
+ }
+
+ chars_read++;
+ }
+ break;
+
+ case 's':
+ if (!match_failure)
+ {
+ c = (*ReadProc)(ReadProcArg, 0, __GetAChar);
+ while(isspace(c))
+ {
+ chars_read++;
+ c = (*ReadProc)(ReadProcArg, 0, __GetAChar);
+ }
+
+ (*ReadProc)(ReadProcArg, c, __UngetAChar);
+ }
+ case '[':
+ if (arg_ptr)
+ {
+ if (is_secure)
+ {
+ elem_valid = 1;
+ elem_maxsize = va_arg(arg, size_t) - 1;
+ }
+
+ num_chars = 0;
+
+ if (match_failure)
+ {
+ if (elem_maxsize > 0)
+ *arg_ptr = 0;
+ continue;
+ }
+ else
+ {
+ char * arg_start = arg_ptr;
+
+ while (format.field_width-- &&
+ (!is_secure || ((elem_valid = (elem_maxsize >= num_chars)) != 0)) &&
+ ((rval = ((*ReadProc)(ReadProcArg, 0, __GetAChar))) != -1))
+ {
+ c = rval;
+
+ if (!tst_char_map(format.char_set, c))
+ break;
+
+ if (format.argument_options == wchar_argument)
+ {
+ mbtowc(((wchar_t*)arg_ptr), (char*)&c, 1);
+ arg_ptr = (char*)((wchar_t*)arg_ptr + 1);
+ }
+ else
+ *arg_ptr++ = c;
+ num_chars++;
+ }
+ c = rval;
+
+ if (!num_chars || (is_secure && !elem_valid))
+ {
+ (*ReadProc)(ReadProcArg, c, __UngetAChar);
+ if (!is_secure)
+ goto exit;
+ else
+ {
+ match_failure = 1;
+ if (elem_maxsize > 0)
+ *arg_start = 0;
+ continue;
+ }
+ }
+
+ chars_read += num_chars;
+
+ if (format.argument_options == wchar_argument)
+ *(wchar_t*)arg_ptr = L'\0';
+ else
+ *arg_ptr = 0;
+
+ items_assigned++;
+ }
+ }
+ else
+ {
+ num_chars = 0;
+
+ while (format.field_width-- &&
+ ((rval = ((*ReadProc)(ReadProcArg, 0, __GetAChar))) != -1))
+ {
+ c = rval;
+ if (!tst_char_map(format.char_set, c))
+ break;
+
+ num_chars++;
+ }
+ c = rval;
+
+ if (!num_chars)
+ {
+ (*ReadProc)(ReadProcArg, c, __UngetAChar);
+ break;
+ }
+ chars_read += num_chars;
+ }
+
+ if (format.field_width >= 0)
+ (*ReadProc)(ReadProcArg, c, __UngetAChar);
+
+ conversions++;
+ break;
+ case 'n':
+ if (arg_ptr)
+ switch (format.argument_options)
+ {
+ case normal_argument: * (int *) arg_ptr = chars_read; break;
+ case short_argument: * (short *) arg_ptr = chars_read; break;
+ case long_argument: * (long *) arg_ptr = chars_read; break;
+ case char_argument: * (char *) arg_ptr = chars_read; break;
+ case long_long_argument: * (long long *) arg_ptr = chars_read; break;
+ }
+ continue;
+ case 0xFF:
+ default:
+ goto exit;
+ }
+ }
+
+exit:
+
+ if ((*ReadProc)(ReadProcArg, 0, __TestForError) && conversions == 0)
+ return -1;
+
+ return items_assigned;
+}
-/* 8036878C-8036881C 3630CC 0090+00 0/0 2/2 0/0 .text __StringRead */
int __StringRead(void* pPtr, int ch, int act) {
char ret;
__InStrCtrl* Iscp = (__InStrCtrl*)pPtr;
@@ -31,4 +770,33 @@ int __StringRead(void* pPtr, int ch, int act) {
}
return 0;
-} \ No newline at end of file
+}
+
+int isspace_string(const char *s) {
+ int i = 0;
+
+ while(s[i] != '\0'){
+ if(!isspace(s[i++])) return 0;
+ }
+
+ return 1;
+}
+
+int vsscanf(const char *s, const char *format, va_list arg) {
+ __InStrCtrl isc;
+ isc.NextChar = (char*)s;
+
+ if ((s == 0) || (*isc.NextChar == '\0') || isspace_string(s)) {
+ return -1;
+ }
+
+ isc.NullCharDetected = 0;
+ return __sformatter(&__StringRead, (void*)&isc, format, arg, 0);
+}
+
+int sscanf(const char *s, const char *pFormat, ...) {
+ int ret;
+ va_list args;
+ va_start(args, pFormat);
+ return vsscanf(s, pFormat, args);
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/secure_error.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/secure_error.c
new file mode 100644
index 00000000..1cc3d7ee
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/secure_error.c
@@ -0,0 +1,16 @@
+#include <cstdio>
+
+typedef void (*constraint_handler_t)(const char*, void*, int);
+
+static constraint_handler_t __msl_constraint_handler = NULL;
+
+void ignore_handler_s(const char* msg, void* ptr, int error);
+
+void __msl_runtime_constraint_violation_s(const char* msg, void* ptr, int error) {
+ if (__msl_constraint_handler)
+ (*__msl_constraint_handler)(msg, ptr, error);
+ else
+ ignore_handler_s(msg, ptr, error);
+}
+
+void ignore_handler_s(const char* msg, void* ptr, int error) {}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/signal.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/signal.c
index 76042b07..104728a2 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/signal.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/signal.c
@@ -1,16 +1,20 @@
#include "signal.h"
#include "critical_regions.h"
+#if PLATFORM_GCN
+#define SIGNAL_NUM 6
+#else
+#define SIGNAL_NUM 7
+#endif
+
#define __std(ref) ref
-/* 8044D878-8044D890 07A598 0018+00 1/1 0/0 0/0 .bss signal_funcs */
-__signal_func_ptr signal_funcs[6];
+__signal_func_ptr signal_funcs[SIGNAL_NUM];
-/* 8036881C-803688DC 36315C 00C0+00 0/0 1/1 0/0 .text raise */
int raise(int sig) {
__signal_func_ptr signal_func;
- if (sig < 1 || sig > 6) {
+ if (sig < 1 || sig > SIGNAL_NUM) {
return -1;
}
@@ -35,4 +39,4 @@ int raise(int sig) {
(*signal_func)(sig);
return 0;
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/string.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/string.c
index 9afa7acf..dbb1b295 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/string.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/string.c
@@ -1,9 +1,8 @@
-#include "string.h"
+#include <cstring>
#define K1 0x80808080
#define K2 0xFEFEFEFF
-/* 80368BE4-80368C00 363524 001C+00 0/0 28/28 8/8 .text strlen */
size_t strlen(const char* str) {
size_t len = -1;
unsigned char* p = (unsigned char*)str - 1;
@@ -15,7 +14,6 @@ size_t strlen(const char* str) {
return len;
}
-/* 80368B2C-80368BE4 36346C 00B8+00 0/0 131/131 13/13 .text strcpy */
char* strcpy(char* dst, const char* src) {
register unsigned char *destb, *fromb;
register unsigned long w, t, align;
@@ -44,7 +42,9 @@ char* strcpy(char* dst, const char* src) {
w = *((int*)(fromb));
t = w + K2;
-
+ #if !PLATFORM_GCN
+ t &= ~w;
+ #endif
t &= K1;
if (t) {
goto bytecopy;
@@ -56,6 +56,9 @@ char* strcpy(char* dst, const char* src) {
w = *(++((int*)(fromb)));
t = w + K2;
+ #if !PLATFORM_GCN
+ t &= ~w;
+ #endif
t &= K1;
if (t) {
goto adjust;
@@ -79,7 +82,6 @@ bytecopy:
return dst;
}
-/* 80368AE8-80368B2C 363428 0044+00 0/0 9/9 1/1 .text strncpy */
char* strncpy(char* dst, const char* src, size_t n) {
const unsigned char* p = (const unsigned char*)src - 1;
unsigned char* q = (unsigned char*)dst - 1;
@@ -97,7 +99,6 @@ char* strncpy(char* dst, const char* src, size_t n) {
return dst;
}
-/* 80368ABC-80368AE8 3633FC 002C+00 0/0 20/20 8/8 .text strcat */
char* strcat(char* dst, const char* src) {
const unsigned char* p = (unsigned char*)src - 1;
unsigned char* q = (unsigned char*)dst - 1;
@@ -113,7 +114,6 @@ char* strcat(char* dst, const char* src) {
return dst;
}
-/* 80368994-80368ABC 3632D4 0128+00 0/0 155/155 279/279 .text strcmp */
int strcmp(const char* str1, const char* str2) {
register unsigned char* left = (unsigned char*)str1;
register unsigned char* right = (unsigned char*)str2;
@@ -150,6 +150,9 @@ int strcmp(const char* str1, const char* str2) {
l1 = *(int*)left;
r1 = *(int*)right;
x = l1 + K2;
+ #if !PLATFORM_GCN
+ x &= ~l1;
+ #endif
if (x & K1) {
goto adjust;
}
@@ -163,10 +166,12 @@ int strcmp(const char* str1, const char* str2) {
}
}
+#if PLATFORM_GCN
if (l1 > r1) {
return 1;
}
return -1;
+#endif
adjust:
l1 = *left;
@@ -192,7 +197,6 @@ bytecopy:
} while (1);
}
-/* 80368954-80368994 363294 0040+00 0/0 6/6 0/0 .text strncmp */
int strncmp(const char* str1, const char* str2, size_t n) {
const unsigned char* p1 = (unsigned char*)str1 - 1;
const unsigned char* p2 = (unsigned char*)str2 - 1;
@@ -210,7 +214,6 @@ int strncmp(const char* str1, const char* str2, size_t n) {
return 0;
}
-/* 80368924-80368954 363264 0030+00 0/0 3/3 0/0 .text strchr */
char* strchr(const char* str, int c) {
const unsigned char* p = (unsigned char*)str - 1;
unsigned long chr = (c & 0xFF);
@@ -225,7 +228,6 @@ char* strchr(const char* str, int c) {
return chr ? NULL : (char*)p;
}
-/* 803688DC-80368924 36321C 0048+00 0/0 1/1 0/0 .text strrchr */
char* strrchr(const char* str, int c) {
const unsigned char* p = (unsigned char*)str - 1;
const unsigned char* q = NULL;
@@ -243,4 +245,4 @@ char* strrchr(const char* str, int c) {
}
return chr ? NULL : (char*)p;
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/strtold.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/strtold.c
new file mode 100644
index 00000000..d2a8e833
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/strtold.c
@@ -0,0 +1,663 @@
+#include "strtold.h"
+#include <cstdio>
+#include "ansi_fp.h"
+#include <locale.h>
+#include <cctype>
+#include "float.h"
+#include <cmath>
+#include <climits>
+#include <errno.h>
+
+extern double nan(const char*);
+extern double __dec2num(const decimal* d);
+
+#define TARGET_FLOAT_BITS 64
+#define TARGET_FLOAT_BYTES (TARGET_FLOAT_BITS / 8)
+#define TARGET_FLOAT_MAX_EXP LDBL_MAX_EXP
+#define TARGET_FLOAT_MANT_DIG LDBL_MANT_DIG
+#define TARGET_FLOAT_IMPLICIT_J_BIT 1
+#define TARGET_FLOAT_MANT_BITS (TARGET_FLOAT_MANT_DIG - TARGET_FLOAT_IMPLICIT_J_BIT)
+#define TARGET_FLOAT_EXP_BITS (TARGET_FLOAT_BITS - TARGET_FLOAT_MANT_BITS - 1)
+
+enum scan_states {
+ start = 0x0001,
+ sig_start = 0x0002,
+ leading_sig_zeroes = 0x0004,
+ int_digit_loop = 0x0008,
+ frac_start = 0x0010,
+ frac_digit_loop = 0x0020,
+ sig_end = 0x0040,
+ exp_start = 0x0080,
+ leading_exp_digit = 0x0100,
+ leading_exp_zeroes = 0x0200,
+ exp_digit_loop = 0x0400,
+ finished = 0x0800,
+ failure = 0x1000,
+ nan_state = 0x2000,
+ infin_state = 0x4000,
+ hex_state = 0x8000
+};
+
+enum hex_scan_states {
+ not_hex = 0x0000,
+ hex_start = 0x0001,
+ hex_leading_sig_zeroes = 0x0002,
+ hex_int_digit_loop = 0x0004,
+ hex_frac_digit_loop = 0x0008,
+ hex_sig_end = 0x0010,
+ hex_exp_start = 0x0020,
+ hex_leading_exp_digit = 0x0040,
+ hex_leading_exp_zeroes = 0x0080,
+ hex_exp_digit_loop = 0x0100
+};
+
+#define final_state(scan_state) (scan_state & (finished | failure))
+#define success(scan_state) \
+ (scan_state & \
+ (leading_sig_zeroes | int_digit_loop | frac_digit_loop | leading_exp_zeroes | exp_digit_loop | finished))
+#define hex_success(count, scan_state) \
+ (count - 1 > 2 && scan_state & (hex_leading_sig_zeroes | hex_int_digit_loop | hex_frac_digit_loop | \
+ hex_leading_exp_zeroes | hex_exp_digit_loop))
+
+#define fetch() (count++, (*ReadProc)(ReadProcArg, 0, __GetAChar))
+#define unfetch(c) (*ReadProc)(ReadProcArg, c, __UngetAChar)
+
+long double __strtold(int max_width, int (*ReadProc)(void*, int, int), void* ReadProcArg, int* chars_scanned,
+ int* overflow) {
+ int scan_state = start;
+ int hex_scan_state = not_hex;
+ int count = 0;
+ int spaces = 0;
+ int c;
+ decimal d = {0, 0, 0, {0, ""}};
+ int sig_negative = 0;
+ int exp_negative = 0;
+ long exp_value = 0;
+ int exp_adjust = 0;
+ register long double result = 0.0;
+ int sign_detected = 0;
+ int radix_marker = *(unsigned char*)(__lconv).decimal_point;
+
+ unsigned char* chptr;
+ unsigned char mantissa[TARGET_FLOAT_BYTES];
+ unsigned mantissa_digits;
+ unsigned long exponent = 0;
+
+ int ui;
+ unsigned char uch, uch1;
+ int NibbleIndex;
+ int expsign = 0;
+ int exp_digits = 0;
+ unsigned intdigits = 0;
+
+ *overflow = 0;
+ c = fetch();
+
+ while (count <= max_width && c != -1 && !final_state(scan_state)) {
+ switch (scan_state) {
+ case start:
+ if (isspace(c)) {
+ c = fetch();
+ count--;
+ spaces++;
+ break;
+ }
+
+ switch (toupper(c)) {
+ case '-':
+ sig_negative = 1;
+
+ case '+':
+ c = fetch();
+ sign_detected = 1;
+ break;
+ case 'I':
+ c = fetch();
+ scan_state = infin_state;
+ break;
+
+ case 'N':
+ c = fetch();
+ scan_state = nan_state;
+ break;
+
+ default:
+ scan_state = sig_start;
+ break;
+ }
+ break;
+
+ case infin_state: {
+ int i = 1;
+ char model[] = "INFINITY";
+
+ while ((i < 8) && (toupper(c) == model[i])) {
+ i++;
+ c = fetch();
+ }
+
+ if ((i == 3) || (i == 8)) {
+ if (sig_negative) {
+ result = (float)-HUGE_VALF;
+ } else {
+ result = HUGE_VALF;
+ }
+
+ *chars_scanned = spaces + i + sign_detected;
+ return result;
+ } else {
+ scan_state = failure;
+ }
+
+ break;
+ }
+
+ case nan_state: {
+ int i = 1, j = 0;
+ char model[] = "NAN(";
+ char nan_arg[32] = "";
+ while ((i < 4) && (toupper(c) == model[i])) {
+ i++;
+ c = fetch();
+ }
+
+ if ((i == 3) || (i == 4)) {
+ if (i == 4) {
+ while ((j < 32) && (isdigit(c) || isalpha(c) || (c == radix_marker))) {
+ nan_arg[j++] = (char)c;
+ c = fetch();
+ }
+
+ if (c != ')') {
+ scan_state = failure;
+ break;
+ } else {
+ j++;
+ }
+ }
+ nan_arg[j] = '\0';
+
+ if (sig_negative) {
+ result = -nan(nan_arg);
+ } else {
+ result = nan(nan_arg);
+ }
+
+ *chars_scanned = spaces + i + j + sign_detected;
+ return result;
+ } else {
+ scan_state = failure;
+ }
+ break;
+ }
+
+ case sig_start:
+ if (c == radix_marker) {
+ scan_state = frac_start;
+ c = fetch();
+ break;
+ }
+ if (!isdigit(c)) {
+ scan_state = failure;
+ break;
+ }
+
+ if (c == '0') {
+ c = fetch();
+ if (toupper(c) == 'X') {
+ scan_state = hex_state;
+ hex_scan_state = hex_start;
+ } else {
+ scan_state = leading_sig_zeroes;
+ }
+ break;
+ }
+
+ scan_state = int_digit_loop;
+ break;
+
+ case leading_sig_zeroes:
+ if (c == '0') {
+ c = fetch();
+
+ break;
+ }
+ scan_state = int_digit_loop;
+ break;
+
+ case int_digit_loop:
+ if (!isdigit(c)) {
+ if (c == radix_marker) {
+ scan_state = frac_digit_loop;
+ c = fetch();
+ } else {
+ scan_state = sig_end;
+ }
+ break;
+ }
+ if (d.sig.length < 20) {
+ d.sig.text[d.sig.length++] = (unsigned char)c;
+ } else {
+ exp_adjust++;
+ }
+
+ c = fetch();
+ break;
+
+ case frac_start:
+ if (!isdigit(c)) {
+ scan_state = failure;
+ break;
+ }
+
+ scan_state = frac_digit_loop;
+ break;
+
+ case frac_digit_loop:
+ if (!isdigit(c)) {
+ scan_state = sig_end;
+ break;
+ }
+
+ if (d.sig.length < 20) {
+ if (c != '0' || d.sig.length) {
+ d.sig.text[d.sig.length++] = (unsigned char)c;
+ }
+
+ exp_adjust--;
+ }
+ c = fetch();
+ break;
+
+ case sig_end:
+ if (toupper(c) == 'E') {
+ scan_state = exp_start;
+ c = fetch();
+ break;
+ }
+ scan_state = finished;
+ break;
+
+ case exp_start:
+ if (c == '+') {
+ c = fetch();
+ } else if (c == '-') {
+ c = fetch();
+ exp_negative = 1;
+ }
+
+ scan_state = leading_exp_digit;
+ break;
+
+ case leading_exp_digit:
+ if (!isdigit(c)) {
+ scan_state = failure;
+ break;
+ }
+
+ if (c == '0') {
+ scan_state = leading_exp_zeroes;
+ c = fetch();
+ break;
+ }
+
+ scan_state = exp_digit_loop;
+ break;
+
+ case leading_exp_zeroes:
+ if (c == '0') {
+ c = fetch();
+ break;
+ }
+
+ scan_state = exp_digit_loop;
+ break;
+
+ case exp_digit_loop:
+ if (!isdigit(c)) {
+ scan_state = finished;
+ break;
+ }
+
+ exp_value = exp_value * 10 + (c - '0');
+ if (exp_value > DBL_MAX_10_EXP) {
+ *overflow = 1;
+ }
+
+ c = fetch();
+ break;
+
+ case hex_state: {
+ switch (hex_scan_state) {
+ case hex_start:
+ memset(mantissa, 0, sizeof(mantissa));
+ chptr = mantissa;
+ mantissa_digits = (53 + 3) / 4;
+ intdigits = 0;
+ NibbleIndex = 0;
+ hex_scan_state = hex_leading_sig_zeroes;
+ c = fetch();
+ break;
+
+ case hex_leading_sig_zeroes:
+ if (c == '0') {
+ c = fetch();
+ break;
+ }
+
+ hex_scan_state = hex_int_digit_loop;
+ break;
+
+ case hex_int_digit_loop:
+ if (!isxdigit(c)) {
+ if (c == radix_marker) {
+ hex_scan_state = hex_frac_digit_loop;
+ c = fetch();
+ }
+
+ else {
+ hex_scan_state = hex_sig_end;
+ }
+ break;
+ }
+
+ if (intdigits < mantissa_digits) {
+ intdigits++;
+ uch = *(chptr + NibbleIndex / 2);
+
+ ui = toupper(c);
+ if (ui >= 'A') {
+ ui = ui - 'A' + 10;
+ } else {
+ ui -= '0';
+ }
+
+ uch1 = (unsigned char)ui;
+
+ if ((NibbleIndex % 2) != 0) {
+ uch |= uch1;
+ } else {
+ uch |= (unsigned char)(uch1 << 4);
+ }
+
+ *(chptr + NibbleIndex++ / 2) = uch;
+ c = fetch();
+ }
+
+ else {
+ c = fetch();
+ }
+
+ break;
+
+ case hex_frac_digit_loop:
+ if (!isxdigit(c)) {
+ hex_scan_state = hex_sig_end;
+ break;
+ }
+
+ if (intdigits < mantissa_digits) {
+ uch = *(chptr + NibbleIndex / 2);
+ ui = toupper(c);
+
+ if (ui >= 'A') {
+ ui = ui - 'A' + 10;
+ } else {
+ ui -= '0';
+ }
+
+ uch1 = (unsigned char)ui;
+
+ if ((NibbleIndex % 2) != 0) {
+ uch |= uch1;
+ } else {
+ uch |= (unsigned char)(uch1 << 4);
+ }
+
+ *(chptr + NibbleIndex++ / 2) = uch;
+ c = fetch();
+ } else {
+ c = fetch();
+ }
+ break;
+
+ case hex_sig_end:
+ if (toupper(c) == 'P') {
+ hex_scan_state = hex_exp_start;
+ exp_digits++;
+ c = fetch();
+ } else {
+ scan_state = finished;
+ }
+
+ break;
+
+ case hex_exp_start:
+ exp_digits++;
+ if (c == '-') {
+ expsign = 1;
+ } else if (c != '+') {
+ c = unfetch(c);
+ count--;
+ exp_digits--;
+ }
+
+ hex_scan_state = hex_leading_exp_digit;
+ c = fetch();
+ break;
+
+ case hex_leading_exp_digit:
+ if (!isdigit(c)) {
+ scan_state = failure;
+ break;
+ }
+
+ if (c == '0') {
+ exp_digits++;
+ hex_scan_state = hex_leading_exp_zeroes;
+ c = fetch();
+ break;
+ }
+
+ hex_scan_state = hex_exp_digit_loop;
+ break;
+
+ case hex_leading_exp_zeroes:
+ if (c == '0') {
+ c = fetch();
+ break;
+ }
+
+ hex_scan_state = hex_exp_digit_loop;
+ break;
+
+ case hex_exp_digit_loop:
+ if (!isdigit(c)) {
+ scan_state = finished;
+ break;
+ }
+
+ exponent = exponent * 10 + (c - '0');
+
+ if (exp_value > SHRT_MAX) {
+ *overflow = 1;
+ }
+
+ exp_digits++;
+ c = fetch();
+
+ break;
+ }
+ } break;
+ }
+ }
+
+ if (scan_state != 32768 ? !success(scan_state) : !hex_success(count, hex_scan_state)) {
+ count = 0;
+ *chars_scanned = 0;
+ } else {
+ count--;
+ *chars_scanned = count + spaces;
+ }
+
+ unfetch(c);
+
+ if (hex_scan_state == not_hex) {
+ if (exp_negative) {
+ exp_value = -exp_value;
+ }
+
+ {
+ int n = d.sig.length;
+ unsigned char* p = &d.sig.text[n];
+
+ while (n-- && *--p == '0') {
+ exp_adjust++;
+ }
+
+ d.sig.length = (unsigned char)(n + 1);
+
+ if (d.sig.length == 0) {
+ d.sig.text[d.sig.length++] = '0';
+ }
+ }
+
+ if (exp_value < DBL_MIN_10_EXP || exp_value > DBL_MAX_10_EXP) {
+ if (!*overflow && d.sig.text[0] == '0' && d.sig.text[1] == 0) {
+ return 0.0;
+ }
+ *overflow = 1;
+ }
+
+ exp_value += exp_adjust;
+
+ if (*overflow) {
+ if (exp_negative) {
+ return 0.0;
+ } else {
+ return sig_negative ? -HUGE_VAL : HUGE_VAL;
+ }
+ }
+
+ d.exp = (short)exp_value;
+
+ result = __dec2num(&d);
+
+ if (result != 0.0 && result < LDBL_MIN) {
+ *overflow = 1;
+ } else if (result > LDBL_MAX) {
+ *overflow = 1;
+ result = HUGE_VAL;
+ }
+
+ if (sig_negative && success(scan_state)) {
+ result = -result;
+ }
+
+ return result;
+ } else {
+ unsigned mantissa_bit, dbl_bit;
+ unsigned one_bit;
+ long double dbl_bits_storage;
+ unsigned char* dbl_bits = (unsigned char*)&dbl_bits_storage;
+
+ if (expsign) {
+ exponent = -exponent;
+ }
+
+ exponent += intdigits * 4;
+
+ one_bit = 0;
+ while (one_bit < 4 && !(mantissa[0] & (0x80 >> one_bit))) {
+ one_bit++;
+ exponent--;
+ }
+ exponent--;
+
+ if (TARGET_FLOAT_IMPLICIT_J_BIT) {
+ one_bit++;
+ }
+
+ if (one_bit) {
+ unsigned char carry = 0;
+ for (chptr = mantissa + sizeof(mantissa) - 1; chptr >= mantissa; chptr--) {
+ unsigned char a = *chptr;
+ *chptr = (unsigned char)((a << one_bit) | carry);
+ carry = (unsigned char)(a >> (8 - one_bit));
+ }
+ }
+
+ memset(dbl_bits, 0, sizeof(dbl_bits_storage));
+ dbl_bit = (TARGET_FLOAT_BITS - TARGET_FLOAT_MANT_BITS);
+
+ for (mantissa_bit = 0; mantissa_bit < TARGET_FLOAT_MANT_BITS; mantissa_bit += 8) {
+ unsigned char ui = mantissa[mantissa_bit >> 3];
+ int halfbits;
+
+ if (mantissa_bit + 8 > TARGET_FLOAT_MANT_BITS) {
+ ui &= 0xff << (TARGET_FLOAT_MANT_BITS - mantissa_bit);
+ }
+
+ halfbits = (dbl_bit & 7);
+ dbl_bits[dbl_bit >> 3] |= (unsigned char)(ui >> halfbits);
+ dbl_bit += 8;
+ dbl_bits[dbl_bit >> 3] |= (unsigned char)(ui << (8 - halfbits));
+ }
+
+ exponent += (TARGET_FLOAT_MAX_EXP - 1) + exp_value;
+
+ if ((exponent & ~(TARGET_FLOAT_MAX_EXP * 2 - 1))) {
+ *overflow = 1;
+ return 0.0;
+ }
+
+ exponent <<= 32 - TARGET_FLOAT_EXP_BITS;
+
+ dbl_bits[0] |= exponent >> 25;
+
+ if (TARGET_FLOAT_EXP_BITS > 7) {
+ dbl_bits[1] |= exponent >> 17;
+ }
+
+ if (TARGET_FLOAT_EXP_BITS > 15) {
+ dbl_bits[2] |= exponent >> 9;
+ }
+
+ if (TARGET_FLOAT_EXP_BITS > 23) {
+ dbl_bits[3] |= exponent >> 1;
+ }
+
+ if (sig_negative) {
+ dbl_bits[0] |= 0x80;
+ }
+
+ result = *(long double*)dbl_bits;
+
+ return result;
+ }
+}
+
+double strtod(const char* str, char** end) {
+ double value, abs_value;
+ int count, overflow;
+
+ __InStrCtrl isc;
+ isc.NextChar = (char *)str;
+ isc.NullCharDetected = 0;
+
+ value = __strtold(INT_MAX, &__StringRead, (void *)&isc, &count, &overflow);
+
+ if (end)
+ *end = (char*)str + count;
+
+ abs_value = fabs(value);
+
+ if (overflow)
+ errno = ERANGE;
+
+ return value;
+}
+
+double atof(const char* str) {
+ return strtod(str, NULL);
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/strtoul.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/strtoul.c
index 50cb3fe2..d0ed3aee 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/strtoul.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/strtoul.c
@@ -1,7 +1,7 @@
#include "strtoul.h"
-#include "ctype.h"
+#include <cctype>
#include "errno.h"
-#include "limits.h"
+#include <climits>
#include "scanf.h"
enum scan_states {
@@ -19,7 +19,6 @@ enum scan_states {
#define fetch() (count++, (*ReadProc)(ReadProcArg, 0, __GetAChar))
#define unfetch(c) (*ReadProc)(ReadProcArg, c, __UngetAChar)
-/* 80368D9C-80369114 3636DC 0378+00 3/2 0/0 0/0 .text __strtoul */
unsigned long __strtoul(int base, int max_width, int (*ReadProc)(void*, int, int),
void* ReadProcArg, int* chars_scanned, int* negative, int* overflow) {
int scan_state = start;
@@ -73,7 +72,7 @@ unsigned long __strtoul(int base, int max_width, int (*ReadProc)(void*, int, int
scan_state = need_digit;
break;
- case 4:
+ case leading_zero:
if (c == 'X' || c == 'x') {
base = 16;
scan_state = need_digit;
@@ -151,7 +150,138 @@ unsigned long __strtoul(int base, int max_width, int (*ReadProc)(void*, int, int
return value;
}
-/* 80368CF0-80368D9C 363630 00AC+00 0/0 2/2 0/0 .text strtoul */
+unsigned long long __strtoull(int base, int max_width, int (*ReadProc)(void*, int, int), void* ReadProcArg,
+ int* chars_scanned, int* negative, int* overflow) {
+ int scan_state = start;
+ int count = 0;
+ int spaces = 0;
+ unsigned long long value = 0;
+ unsigned long long value_max = 0;
+ unsigned long long ullmax = ULLONG_MAX;
+ int c;
+
+ *negative = *overflow = 0;
+
+ if (base < 0 || base == 1 || base > 36 || max_width < 1) {
+ scan_state = failure;
+ } else {
+ c = fetch();
+ }
+
+ if (base != 0) {
+ value_max = ullmax / base;
+ }
+
+ while (count <= max_width && c != -1 && !final_state(scan_state)) {
+ switch (scan_state) {
+ case start:
+ if (isspace(c)) {
+ c = fetch();
+ count--;
+ spaces++;
+ break;
+ }
+
+ if (c == '+') {
+ c = fetch();
+ } else if (c == '-') {
+ c = fetch();
+ *negative = 1;
+ }
+
+ scan_state = check_for_zero;
+ break;
+
+ case check_for_zero:
+ if (base == 0 || base == 16) {
+ if (c == '0') {
+ scan_state = leading_zero;
+ c = fetch();
+ break;
+ }
+ }
+
+ scan_state = need_digit;
+ break;
+
+ case leading_zero:
+ if (c == 'X' || c == 'x') {
+ base = 16;
+ scan_state = need_digit;
+ c = fetch();
+ break;
+ }
+
+ if (base == 0) {
+ base = 8;
+ }
+
+ scan_state = digit_loop;
+ break;
+
+ case need_digit:
+ case digit_loop:
+ if (base == 0) {
+ base = 10;
+ }
+
+ if (!value_max) {
+ value_max = ullmax / base;
+ }
+
+ if (isdigit(c)) {
+ if ((c -= '0') >= base) {
+ if (scan_state == digit_loop) {
+ scan_state = finished;
+ } else {
+ scan_state = failure;
+ }
+
+ c += '0';
+ break;
+ }
+ } else if (!isalpha(c) || (toupper(c) - 'A' + 10) >= base) {
+ if (scan_state == digit_loop) {
+ scan_state = finished;
+ } else {
+ scan_state = failure;
+ }
+
+ break;
+ } else {
+ c = toupper(c) - 'A' + 10;
+ }
+
+ if (value > value_max) {
+ *overflow = 1;
+ }
+
+ value *= base;
+
+ if (c > (ullmax - value)) {
+ *overflow = 1;
+ }
+
+ value += c;
+ scan_state = digit_loop;
+ c = fetch();
+ break;
+ }
+ }
+
+ if (!success(scan_state)) {
+ count = 0;
+ value = 0;
+ *chars_scanned = 0;
+ } else {
+ count--;
+ *chars_scanned = count + spaces;
+ }
+
+ unfetch(c);
+ return value;
+}
+
unsigned long strtoul(const char* str, char** end, int base) {
unsigned long value;
int count, negative, overflow;
@@ -176,7 +306,6 @@ unsigned long strtoul(const char* str, char** end, int base) {
return value;
}
-/* 80368C00-80368CF0 363540 00F0+00 0/0 3/3 0/0 .text strtol */
long strtol(const char* str, char** end, int base) {
unsigned long uvalue;
long svalue;
@@ -200,4 +329,8 @@ long strtol(const char* str, char** end, int base) {
}
return svalue;
-} \ No newline at end of file
+}
+
+int atoi(const char* str) {
+ return strtol(str, NULL, 10);
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wchar_io.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wchar_io.c
index f54bcc6b..c2f2648d 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wchar_io.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wchar_io.c
@@ -1,22 +1,32 @@
#include "wchar_io.h"
-/* 80369114-8036919C 363A54 0088+00 0/0 5/5 0/0 .text fwide */
-int fwide(FILE* file, int mode) {
- if (file == NULL || file->file_mode.file_kind == __closed_file) {
+int __fwide(FILE* stream, int mode) {
+ return fwide(stream, mode);
+}
+
+int fwide(FILE* stream, int mode) {
+ int orientation;
+ int result;
+
+ if (stream == NULL || stream->file_mode.file_kind == __closed_file)
return 0;
- }
- switch (file->file_mode.file_orientation) {
- case UNORIENTED:
- if (mode > 0) {
- file->file_mode.file_orientation = WIDE_ORIENTED;
- } else if (mode < 0) {
- file->file_mode.file_orientation = CHAR_ORIENTED;
- }
- return mode;
- case WIDE_ORIENTED:
- return 1;
- case CHAR_ORIENTED:
- return -1;
+ orientation = stream->file_mode.file_orientation;
+ switch (orientation) {
+ case __unoriented:
+ if (mode > 0)
+ stream->file_mode.file_orientation = __wide_oriented;
+ else if (mode < 0)
+ stream->file_mode.file_orientation = __char_oriented;
+ result = mode;
+ break;
+ case __wide_oriented:
+ result = 1;
+ break;
+ case __char_oriented:
+ result = -1;
+ break;
}
-} \ No newline at end of file
+
+ return result;
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wcstoul.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wcstoul.c
new file mode 100644
index 00000000..671a284e
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wcstoul.c
@@ -0,0 +1,224 @@
+#include <wcstoul.h>
+
+#include <errno.h>
+#include <wctype_api.h>
+#include <wscanf.h>
+#include <climits>
+#include <locale.h>
+
+enum scan_states {
+ start = 0x01,
+ check_for_zero = 0x02,
+ leading_zero = 0x04,
+ need_digit = 0x08,
+ digit_loop = 0x10,
+ finished = 0x20,
+ failure = 0x40
+};
+
+#define final_state(scan_state) (scan_state & (finished | failure))
+#define success(scan_state) (scan_state & (leading_zero | digit_loop | finished))
+#define fetch() (count++, (*read_proc)(read_proc_arg, 0, 0))
+
+static size_t __wcstoul(int base, int max_width,
+ wchar_t (*read_proc)(wString* src, wchar_t param_1, wchar_t param_2),
+ void* read_proc_arg, int* chars_scanned, int* negative, int* overflow) {
+ int scan_state;
+ int count;
+ int spaces;
+ unsigned int value;
+ unsigned int value_max;
+ wchar_t c;
+
+ count = 0;
+ scan_state = 1;
+ spaces = 0;
+ value = 0;
+ value_max = 0;
+
+ *negative = *overflow = 0;
+
+ if (base < 0 || base == 1 || base > 36 || max_width < 1) {
+ scan_state = failure;
+ } else {
+ c = fetch();
+ }
+
+ if (base != 0) {
+ value_max = ULONG_MAX / base;
+ }
+
+ // NOTE: c is uninitialized if the parameter validation above fails. In practice, this doesn't
+ // matter because the third condition will always fail in this scenario anyway.
+ while (count <= max_width && c != -1 && !final_state(scan_state)) {
+ switch (scan_state) {
+ case start:
+ if (c >= 0x100 ?
+ 0 :
+ _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & wctype_space) {
+ c = read_proc(read_proc_arg, 0, 0);
+ spaces++;
+ } else {
+ if (c == L'+') {
+ c = fetch();
+ } else if (c == L'-') {
+ c = fetch();
+ *negative = 1;
+ }
+ scan_state = check_for_zero;
+ }
+ break;
+ case check_for_zero:
+ if ((base == 0 || base == 16) && c == L'0') {
+ scan_state = leading_zero;
+ c = fetch();
+ } else {
+ scan_state = need_digit;
+ }
+ break;
+ case leading_zero:
+ if (c == L'X' || c == L'x') {
+ base = 16;
+ scan_state = need_digit;
+ c = fetch();
+ } else {
+ if (base == 0) {
+ base = 8;
+ }
+ scan_state = digit_loop;
+ }
+ break;
+ case need_digit:
+ case digit_loop:
+ if (base == 0) {
+ base = 10;
+ }
+
+ if (value_max == 0) {
+ value_max = ULONG_MAX / base;
+ }
+
+ if (c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & wctype_digit) {
+ c -= L'0';
+ if (c >= base) {
+ if (scan_state == digit_loop) {
+ scan_state = finished;
+ } else {
+ scan_state = failure;
+ }
+ c += L'0';
+ break;
+ }
+ } else {
+ int temp;
+ if (!(c >= 0x100 ?
+ 0 :
+ _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & wctype_alpha)) {
+ goto label;
+ }
+
+ temp = 1;
+ if (c <= 0xFF) {
+ temp = 0;
+ }
+ if ((temp ? c :
+ _current_locale.ctype_cmpt_ptr->upper_map_ptr[c]) -
+ 0x37 >=
+ base) {
+ label:
+ if (scan_state == digit_loop) {
+ scan_state = finished;
+ } else {
+ scan_state = failure;
+ }
+ continue;
+ } else {
+ c = (wchar_t)(c >= 0x100 ?
+ c :
+ _current_locale.ctype_cmpt_ptr->wupper_map_ptr[c]) -
+ 0x37;
+ }
+ }
+
+ if (value > value_max) {
+ *overflow = 1;
+ }
+
+ value *= base;
+ if (c > ULONG_MAX - value) {
+ *overflow = 1;
+ }
+
+ scan_state = digit_loop;
+ value += c;
+ c = fetch();
+
+ break;
+ }
+ }
+
+ if (!success(scan_state)) {
+ value = 0;
+ *chars_scanned = 0;
+ } else {
+ *chars_scanned = count + spaces - 1;
+ }
+
+ read_proc(read_proc_arg, c, 1);
+
+ return value;
+}
+
+size_t wcstoul(wchar_t* param_1, wchar_t** param_2, int param_3) {
+ wString sp18;
+ size_t retval;
+ int sp10[2]; // not sure if this should be an array, but the stack doesn't match otherwise
+ int sp0C;
+ int sp08;
+ sp18.buffer = param_1;
+ sp18.field_0x4 = 0;
+
+ retval = __wcstoul(param_3, 0x7fffffff, __wStringRead, &sp18, sp10, &sp0C, &sp08);
+
+ if (param_2 != NULL) {
+ *param_2 = param_1 + sp10[0];
+ }
+
+ if (sp08 != 0) {
+ errno = 0x22;
+ return -1;
+ }
+
+ if (sp0C != 0) {
+ return -retval;
+ } else {
+ return retval;
+ }
+}
+
+size_t wcstol(wchar_t* param_1, wchar_t** param_2, int param_3) {
+ size_t retval;
+ wString sp18;
+ int sp10[2]; // not sure if this should be an array, but the stack doesn't match otherwise
+ int sp0C;
+ int sp08;
+ sp18.buffer = param_1;
+ sp18.field_0x4 = 0;
+
+ retval = __wcstoul(param_3, 0x7fffffff, __wStringRead, &sp18, sp10, &sp0C, &sp08);
+
+ if (param_2 != NULL) {
+ *param_2 = param_1 + sp10[0];
+ }
+
+ if (sp08 != 0 || (sp0C == 0 && retval > 0x7fffffff) || (sp0C != 0 && retval > 0x80000000)) {
+ errno = 0x22;
+ return sp0C != 0 ? 0x80000000 : 0x7fffffff;
+ }
+
+ if (sp0C != 0) {
+ return -retval;
+ } else {
+ return retval;
+ }
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wctype.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wctype.c
new file mode 100644
index 00000000..13356b95
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wctype.c
@@ -0,0 +1,166 @@
+#include <cctype>
+
+const unsigned short __wctype_mapC[256] = {
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_blank | ctype_cntrl | ctype_space,
+ ctype_cntrl | ctype_space,
+ ctype_cntrl | ctype_space,
+ ctype_cntrl | ctype_space,
+ ctype_cntrl | ctype_space,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_cntrl,
+ ctype_blank | ctype_print | ctype_space,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_digit | ctype_graph | ctype_print | ctype_xdigit,
+ ctype_digit | ctype_graph | ctype_print | ctype_xdigit,
+ ctype_digit | ctype_graph | ctype_print | ctype_xdigit,
+ ctype_digit | ctype_graph | ctype_print | ctype_xdigit,
+ ctype_digit | ctype_graph | ctype_print | ctype_xdigit,
+ ctype_digit | ctype_graph | ctype_print | ctype_xdigit,
+ ctype_digit | ctype_graph | ctype_print | ctype_xdigit,
+ ctype_digit | ctype_graph | ctype_print | ctype_xdigit,
+ ctype_digit | ctype_graph | ctype_print | ctype_xdigit,
+ ctype_digit | ctype_graph | ctype_print | ctype_xdigit,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper | ctype_xdigit,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper | ctype_xdigit,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper | ctype_xdigit,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper | ctype_xdigit,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper | ctype_xdigit,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper | ctype_xdigit,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_alpha | ctype_graph | ctype_print | ctype_upper,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower | ctype_xdigit,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower | ctype_xdigit,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower | ctype_xdigit,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower | ctype_xdigit,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower | ctype_xdigit,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower | ctype_xdigit,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_alpha | ctype_graph | ctype_print | ctype_lower,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_graph | ctype_print | ctype_punct,
+ ctype_cntrl,
+};
+
+const wchar_t __wlower_mapC[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, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
+ 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
+ 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B,
+ 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x5B, 0x5C, 0x5D, 0x5E,
+ 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71,
+ 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 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 wchar_t __wupper_mapC[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, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
+ 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
+ 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B,
+ 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E,
+ 0x5F, 0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51,
+ 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x7B, 0x7C, 0x7D, 0x7E, 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,
+};
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wmem.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wmem.c
new file mode 100644
index 00000000..33530863
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wmem.c
@@ -0,0 +1,19 @@
+#include <wmem.h>
+
+#include <cstddef>
+#include <cstring>
+
+void wmemcpy(wchar_t* dst, const wchar_t* src, size_t n) {
+ memcpy(dst, src, n * 2);
+}
+
+const wchar_t* wmemchr(const wchar_t* str, wchar_t needle, int max_len) {
+ int i;
+ for (i = 0; i != max_len; i++) {
+ if (*str == needle) {
+ return str;
+ }
+ str++;
+ }
+ return NULL;
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wprintf.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wprintf.c
new file mode 100644
index 00000000..a47e9c11
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wprintf.c
@@ -0,0 +1,1406 @@
+#include <wprintf.h>
+
+#include <ansi_fp.h>
+#include <mbstring.h>
+#include <wmem.h>
+#include <wscanf.h>
+#include <cmath>
+#include <cstdint>
+#include <cstring>
+#include <locale.h>
+#include <cstdarg>
+#include <cstddef>
+#include <va_list.h>
+
+#define LDBL_MANT_DIG 53
+
+#define TARGET_FLOAT_BITS 64
+#define TARGET_FLOAT_BYTES (TARGET_FLOAT_BITS / 8)
+#define TARGET_FLOAT_MAX_EXP LDBL_MAX_EXP
+#define TARGET_FLOAT_MANT_DIG LDBL_MANT_DIG
+#define TARGET_FLOAT_IMPLICIT_J_BIT 1
+#define TARGET_FLOAT_MANT_BITS (TARGET_FLOAT_MANT_DIG - TARGET_FLOAT_IMPLICIT_J_BIT)
+#define TARGET_FLOAT_EXP_BITS (TARGET_FLOAT_BITS - TARGET_FLOAT_MANT_BITS - 1)
+
+enum justification_options { left_justification, right_justification, zero_fill };
+
+enum sign_options { only_minus, sign_always, space_holder };
+
+enum argument_options {
+ normal_argument,
+ char_argument,
+ short_argument,
+ long_argument,
+ long_long_argument,
+ wchar_argument,
+
+ intmax_argument,
+ size_t_argument,
+ ptrdiff_argument,
+
+ long_double_argument,
+};
+
+typedef struct {
+ unsigned char justification_options;
+ unsigned char sign_options;
+ unsigned char precision_specified;
+ unsigned char alternate_form;
+ unsigned char argument_options;
+ wchar_t conversion_char;
+ int field_width;
+ int precision;
+} print_format;
+
+extern void __msl_runtime_constraint_violation_s(const char* msg, void* ptr, int error);
+
+const wchar_t* parse_format(const wchar_t* format_string, va_list* arg, print_format* format) {
+ print_format f;
+ const wchar_t* s = format_string;
+ wchar_t c;
+ int flag_found;
+ f.justification_options = right_justification;
+ f.sign_options = only_minus;
+ f.precision_specified = 0;
+ f.alternate_form = 0;
+ f.argument_options = normal_argument;
+ f.field_width = 0;
+ f.precision = 0;
+
+ if ((c = *++s) == '%') {
+ f.conversion_char = c;
+ *format = f;
+ return s + 1;
+ }
+
+ while (1) {
+ flag_found = 1;
+
+ switch (c) {
+ case '-':
+ f.justification_options = left_justification;
+ break;
+ case '+':
+ f.sign_options = sign_always;
+ break;
+ case ' ':
+ if (f.sign_options != sign_always) {
+ f.sign_options = space_holder;
+ }
+ break;
+ case '#':
+ f.alternate_form = 1;
+ break;
+ case '0':
+ if (f.justification_options != left_justification) {
+ f.justification_options = zero_fill;
+ }
+ break;
+ default:
+ flag_found = 0;
+ break;
+ }
+
+ if (flag_found) {
+ c = *++s;
+ } else {
+ break;
+ }
+ }
+
+ if (c == '*') {
+ if ((f.field_width = va_arg(*arg, int)) < 0) {
+ f.justification_options = left_justification;
+ f.field_width = -f.field_width;
+ }
+
+ c = *++s;
+ } else {
+ while ((c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & 0x8) != 0) {
+ f.field_width = f.field_width * 10 + (c - '0');
+ c = *++s;
+ }
+ }
+
+ if (f.field_width > 509) {
+ f.conversion_char = 0xFFFF;
+ *format = f;
+ return s + 1;
+ }
+
+ if (c == '.') {
+ f.precision_specified = 1;
+
+ if ((c = *++s) == '*') {
+ if ((f.precision = va_arg(*arg, int)) < 0) {
+ f.precision_specified = 0;
+ }
+
+ c = *++s;
+ } else {
+ while ((c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & 0x8) != 0)
+ {
+ f.precision = f.precision * 10 + (c - '0');
+ c = *++s;
+ }
+ }
+ }
+
+ flag_found = 1;
+
+ switch (c) {
+ case 'h':
+ f.argument_options = short_argument;
+
+ if (s[1] == 'h') {
+ f.argument_options = char_argument;
+ c = *++s;
+ }
+
+ break;
+
+ case 'l':
+ f.argument_options = long_argument;
+
+ if (s[1] == 'l') {
+ f.argument_options = long_long_argument;
+ c = *++s;
+ }
+ break;
+ case 'L':
+ f.argument_options = long_double_argument;
+ break;
+ case 'j':
+ f.argument_options = intmax_argument;
+ break;
+ case 't':
+ f.argument_options = ptrdiff_argument;
+ break;
+ case 'z':
+ f.argument_options = size_t_argument;
+ break;
+ default:
+ flag_found = 0;
+ break;
+ }
+
+ if (flag_found) {
+ c = *++s;
+ }
+
+ switch (f.conversion_char = c) {
+ case 'd':
+ case 'i':
+ case 'u':
+ case 'o':
+ case 'x':
+ case 'X':
+ if (f.argument_options == long_double_argument) {
+ f.argument_options = 4;
+ }
+
+ if (!f.precision_specified) {
+ f.precision = 1;
+ } else if (f.justification_options == zero_fill) {
+ f.justification_options = right_justification;
+ }
+ break;
+
+ case 'f':
+ case 'F':
+ if (f.argument_options == short_argument || f.argument_options == intmax_argument ||
+ f.argument_options == size_t_argument || f.argument_options == ptrdiff_argument ||
+ f.argument_options == long_long_argument)
+ {
+ f.conversion_char = 0xFFFF;
+ break;
+ }
+
+ if (!f.precision_specified) {
+ f.precision = 6;
+ }
+ break;
+
+ case 'a':
+ case 'A':
+ if (!f.precision_specified) {
+ f.precision = 0xD;
+ }
+
+ if (f.argument_options == short_argument || f.argument_options == intmax_argument ||
+ f.argument_options == size_t_argument || f.argument_options == ptrdiff_argument ||
+ f.argument_options == long_long_argument || f.argument_options == char_argument)
+ {
+ f.conversion_char = 0xFFFF;
+ }
+
+ break;
+
+ case 'g':
+ case 'G':
+ if (!f.precision) {
+ f.precision = 1;
+ }
+
+ case 'e':
+ case 'E':
+ if (f.argument_options == short_argument || f.argument_options == intmax_argument ||
+ f.argument_options == size_t_argument || f.argument_options == ptrdiff_argument ||
+ f.argument_options == long_long_argument || f.argument_options == char_argument)
+ {
+ f.conversion_char = 0xFFFF;
+ break;
+ }
+
+ if (!f.precision_specified) {
+ f.precision = 6;
+ }
+ break;
+
+ case 'p':
+ f.argument_options = long_argument;
+ f.alternate_form = 1;
+ f.conversion_char = 'x';
+ f.precision = 8;
+ break;
+
+ case 'c':
+ if (f.argument_options == long_argument) {
+ f.argument_options = wchar_argument;
+ } else {
+ if (f.precision_specified || f.argument_options != normal_argument) {
+ f.conversion_char = 0xFFFF;
+ }
+ }
+
+ break;
+
+ case 's':
+ if (f.argument_options == long_argument) {
+ f.argument_options = wchar_argument;
+ } else {
+ if (f.argument_options != normal_argument) {
+ f.conversion_char = 0xFFFF;
+ }
+ }
+
+ break;
+
+ case 'n':
+ if (f.argument_options == long_double_argument) {
+ f.argument_options = 0x4;
+ }
+
+ break;
+
+ default:
+ f.conversion_char = 0xFFFF;
+ break;
+ }
+
+ *format = f;
+ return s + 1;
+}
+
+wchar_t* long2str(signed long num, wchar_t* buff, print_format format) {
+ unsigned long unsigned_num, base;
+ wchar_t* p;
+ int n, digits;
+ int minus = 0;
+ unsigned_num = num;
+ minus = 0;
+
+ p = buff;
+ *--p = 0;
+ digits = 0;
+
+ if (!num && !format.precision && !(format.alternate_form && format.conversion_char == 'o')) {
+ return p;
+ }
+
+ switch (format.conversion_char) {
+ case 'd':
+ case 'i':
+ base = 10;
+
+ if (num < 0) {
+ if (num != 0x80000000L) {
+ unsigned_num = -unsigned_num;
+ }
+
+ minus = 1;
+ }
+ break;
+
+ case 'o':
+ base = 8;
+ format.sign_options = only_minus;
+ break;
+
+ case 'u':
+ base = 10;
+ format.sign_options = only_minus;
+ break;
+
+ case 'x':
+ case 'X':
+ base = 16;
+ format.sign_options = only_minus;
+ break;
+ }
+
+ do {
+ n = unsigned_num % base;
+ unsigned_num /= base;
+
+ if (n < 10) {
+ n += '0';
+ } else {
+ n -= 10;
+
+ if (format.conversion_char == 'x') {
+ n += 'a';
+ } else {
+ n += 'A';
+ }
+ }
+
+ *--p = n;
+ ++digits;
+ } while (unsigned_num != 0);
+
+ if (base == 8 && format.alternate_form && *p != '0') {
+ *--p = '0';
+ ++digits;
+ }
+
+ if (format.justification_options == zero_fill) {
+ format.precision = format.field_width;
+
+ if (minus || format.sign_options != only_minus)
+ --format.precision;
+
+ if (base == 16 && format.alternate_form)
+ format.precision -= 2;
+ }
+
+ if (buff - p + format.precision > 509)
+ return 0;
+
+ while (digits < format.precision) {
+ *--p = '0';
+ ++digits;
+ }
+
+ if (base == 16 && format.alternate_form) {
+ *--p = format.conversion_char;
+ *--p = '0';
+ }
+
+ if (minus) {
+ *--p = '-';
+ } else if (format.sign_options == sign_always) {
+ *--p = '+';
+ } else if (format.sign_options == space_holder) {
+ *--p = ' ';
+ }
+
+ return p;
+}
+
+wchar_t* longlong2str(signed long long num, wchar_t* pBuf, print_format fmt) {
+ unsigned long long unsigned_num, base;
+ wchar_t* p;
+ int n, digits;
+ int minus = 0;
+ unsigned_num = num;
+ minus = 0;
+ p = pBuf;
+ *--p = 0;
+ digits = 0;
+
+ if (!num && !fmt.precision && !(fmt.alternate_form && fmt.conversion_char == 'o')) {
+ return p;
+ }
+
+ switch (fmt.conversion_char) {
+ case 'd':
+ case 'i':
+ base = 10;
+
+ if (num < 0) {
+ if (num != 0x8000000000000000LL) {
+ unsigned_num = -unsigned_num;
+ }
+
+ minus = 1;
+ }
+ break;
+ case 'o':
+ base = 8;
+ fmt.sign_options = only_minus;
+ break;
+ case 'u':
+ base = 10;
+ fmt.sign_options = only_minus;
+ break;
+ case 'x':
+ case 'X':
+ base = 16;
+ fmt.sign_options = only_minus;
+ break;
+ }
+
+ do {
+ n = unsigned_num % base;
+ unsigned_num /= base;
+
+ if (n < 10) {
+ n += '0';
+ } else {
+ n -= 10;
+ if (fmt.conversion_char == 'x') {
+ n += 'a';
+ } else {
+ n += 'A';
+ }
+ }
+
+ *--p = n;
+ ++digits;
+ } while (unsigned_num != 0);
+
+ if (base == 8 && fmt.alternate_form && *p != '0') {
+ *--p = '0';
+ ++digits;
+ }
+
+ if (fmt.justification_options == zero_fill) {
+ fmt.precision = fmt.field_width;
+
+ if (minus || fmt.sign_options != only_minus) {
+ --fmt.precision;
+ }
+
+ if (base == 16 && fmt.alternate_form) {
+ fmt.precision -= 2;
+ }
+ }
+
+ if (pBuf - p + fmt.precision > 509) {
+ return 0;
+ }
+
+ while (digits < fmt.precision) {
+ *--p = '0';
+ ++digits;
+ }
+
+ if (base == 16 && fmt.alternate_form) {
+ *--p = fmt.conversion_char;
+ *--p = '0';
+ }
+
+ if (minus) {
+ *--p = '-';
+ } else if (fmt.sign_options == sign_always) {
+ *--p = '+';
+ } else if (fmt.sign_options == space_holder) {
+ *--p = ' ';
+ }
+
+ return p;
+}
+
+wchar_t* double2hex(long double num, wchar_t* buff, print_format format) {
+ wchar_t* p;
+ wchar_t* q;
+ unsigned char working_char;
+ long double ld;
+ int expbits, expmask;
+ unsigned snum;
+ long exp;
+ print_format exp_format;
+ int hex_precision;
+ int mantissa_bit;
+ decform form;
+ decimal dec;
+ int radix_marker;
+ double tempF;
+
+ radix_marker = *(unsigned char *)(__lconv).decimal_point;
+ p = buff;
+ ld = num;
+
+ if (format.precision > 509) {
+ return 0;
+ }
+
+ form.style = (char)0;
+ form.digits = 0x20;
+ __num2dec(&form, num, &dec);
+
+ switch (*dec.sig.text) {
+ case '0':
+ dec.exp = 0;
+ if (dec.sign) {
+ p = buff - 5;
+ if (format.conversion_char == 'A') {
+ wcscpy(p, L"-0X0");
+ } else {
+ wcscpy(p, L"-0x0");
+ }
+ } else {
+ p = buff - 4;
+ if (format.conversion_char == 'A') {
+ wcscpy(p, L"0X0");
+ } else {
+ wcscpy(p, L"0x0");
+ }
+ }
+
+ return p;
+ case 'I':
+ if (dec.sign) {
+ p = buff - 5;
+ if (format.conversion_char == 'A') {
+ wcscpy(p, L"-INF");
+ } else {
+ wcscpy(p, L"-inf");
+ }
+ } else {
+ p = buff - 4;
+ if (format.conversion_char == 'A') {
+ wcscpy(p, L"INF");
+ } else {
+ wcscpy(p, L"inf");
+ }
+ }
+
+ return p;
+ case 'N':
+ if (dec.sign) {
+ p = buff - 5;
+ if (format.conversion_char == 'A') {
+ wcscpy(p, L"-NAN");
+ } else {
+ wcscpy(p, L"-nan");
+ }
+ } else {
+ p = buff - 4;
+ if (format.conversion_char == 'A') {
+ wcscpy(p, L"NAN");
+ } else {
+ wcscpy(p, L"nan");
+ }
+ }
+
+ return p;
+ }
+
+ exp_format.justification_options = right_justification;
+ exp_format.sign_options = sign_always;
+ exp_format.precision_specified = 0;
+ exp_format.alternate_form = 0;
+ exp_format.argument_options = normal_argument;
+ exp_format.field_width = 0;
+ exp_format.precision = 1;
+ exp_format.conversion_char = 'd';
+
+ expbits = 11;
+ expmask = 0x7FF;
+
+ snum = ((unsigned char *)&num)[0] << 25;
+ if (TARGET_FLOAT_EXP_BITS > 7) {
+ snum |= ((unsigned char *)&num)[1] << 17;
+ }
+ if (TARGET_FLOAT_EXP_BITS > 15) {
+ snum |= ((unsigned char *)&num)[2] << 9;
+ }
+ if (TARGET_FLOAT_EXP_BITS > 23) {
+ snum |= ((unsigned char *)&num)[3] << 1;
+ }
+
+ snum = (snum >> (32 - expbits)) & expmask;
+
+ if(snum != 0)
+ exp = snum - 0x3FF;
+ else
+ exp = 0;
+
+ p = long2str(exp, buff, exp_format);
+ if (format.conversion_char == 'a') {
+ *--p = 'p';
+ } else {
+ *--p = 'P';
+ }
+ q = (wchar_t*)&num;
+
+ if (TARGET_FLOAT_IMPLICIT_J_BIT) {
+ mantissa_bit = (1 + expbits + format.precision * 4) - 1;
+ } else {
+ mantissa_bit = (1 + expbits + format.precision * 4) - 4;
+ }
+
+ for (hex_precision = format.precision; hex_precision >= 1; hex_precision--) {
+ if (mantissa_bit < 64) {
+ int mantissa_byte;
+
+ mantissa_byte = mantissa_bit >> 3;
+ working_char = (*((unsigned char*)q + mantissa_byte)) >> (0x7 - (mantissa_bit & 0x7));
+
+ if ((mantissa_bit & ~0x7) != ((mantissa_bit - 4) & ~0x7)) {
+ working_char |= (unsigned char)(((*((unsigned char*)q + (mantissa_byte - 1))) << 8) >> (0x7 - ((mantissa_bit) & 0x7)));
+ }
+
+ if (!TARGET_FLOAT_IMPLICIT_J_BIT) {
+ if (mantissa_bit == 1 + expbits) {
+ *--p = radix_marker;
+ working_char &= 0x1;
+ }
+ }
+
+ if ((working_char &= 0xF) < 10) {
+ working_char += (unsigned char)'0';
+ } else {
+ if (format.conversion_char == 'a') {
+ working_char += (unsigned char)('a' - 10);
+ } else {
+ working_char += (unsigned char)('A' - 10);
+ }
+ }
+ }
+ else {
+ working_char = '0';
+ }
+
+ *--p = working_char;
+ mantissa_bit -= 4;
+ }
+
+ if (TARGET_FLOAT_IMPLICIT_J_BIT){
+ if (format.precision || format.alternate_form) {
+ *--p = radix_marker;
+ }
+
+ tempF = __fabs(ld);
+ if (tempF != 0.0) {
+ *--p = '1';
+ } else {
+ *--p = '0';
+ }
+ }
+
+ if (format.conversion_char == 'a') {
+ *--p = 'x';
+ } else {
+ *--p = 'X';
+ }
+
+ *--p = '0';
+
+ if (dec.sign) {
+ *--p = '-';
+ } else if (format.sign_options == sign_always) {
+ *--p = '+';
+ } else if (format.sign_options == space_holder) {
+ *--p = ' ';
+ }
+
+ return p;
+}
+
+void round_decimal(decimal* dec, int new_length) {
+ char c;
+ char* p;
+ int carry;
+
+ if (new_length < 0) {
+ return_zero:
+ dec->exp = 0;
+ dec->sig.length = 1;
+ *dec->sig.text = '0';
+ return;
+ }
+
+ if (new_length >= dec->sig.length) {
+ return;
+ }
+
+ p = (char*)dec->sig.text + new_length + 1;
+ c = *--p - '0';
+
+ if (c == 5) {
+ char* q = &((char*)dec->sig.text)[dec->sig.length];
+
+ while (--q > p && *q == '0')
+ ;
+ carry = q == p ? p[-1] & 1 : 1;
+ } else {
+ carry = c > 5;
+ }
+
+ while (new_length != 0) {
+ c = *--p - '0' + carry;
+
+ if ((carry = (c > 9)) != 0 || c == 0) {
+ --new_length;
+ } else {
+ *p = c + '0';
+ break;
+ }
+ }
+
+ if (carry != 0) {
+ dec->exp += 1;
+ dec->sig.length = 1;
+ *dec->sig.text = '1';
+ return;
+ } else if (new_length == 0) {
+ goto return_zero;
+ }
+
+ dec->sig.length = new_length;
+}
+
+wchar_t* float2str(double num, wchar_t* buff, print_format format) {
+ wchar_t out_buf[0x100];
+ decimal dec;
+ decform form;
+ wchar_t* p;
+ char* p2;
+ wchar_t c;
+ char* p3;
+ unsigned char* q;
+ int n, digits, sign;
+ int int_digits, frac_digits;
+ int radix_marker;
+ int used_bytes;
+
+ radix_marker = *(unsigned char*)__lconv.decimal_point;
+
+ if (format.precision > 509) {
+ return 0;
+ }
+
+ form.style = 0;
+ form.digits = 0x20;
+ __num2dec(&form, num, &dec);
+ p3 = (char*)(dec.sig.text + dec.sig.length);
+
+ while (dec.sig.length > 1 && *--p3 == '0') {
+ --dec.sig.length;
+ ++dec.exp;
+ }
+
+ switch (*dec.sig.text) {
+ case '0':
+ dec.exp = 0;
+ break;
+ case 'I':
+ if (num < 0) {
+ c = format.conversion_char;
+ p = buff - 5;
+
+ if ((c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & 0x200) != 0) {
+ wcscpy(p, L"-INF");
+ } else {
+ wcscpy(p, L"-inf");
+ }
+ } else {
+ c = format.conversion_char;
+ p = buff - 4;
+ if ((c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & 0x200) != 0) {
+ wcscpy(p, L"INF");
+ } else {
+ wcscpy(p, L"inf");
+ }
+ }
+
+ return p;
+
+ case 'N':
+ if (dec.sign) {
+ c = format.conversion_char;
+ p = buff - 5;
+ if ((c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & 0x200) != 0) {
+ wcscpy(p, L"-NAN");
+ } else {
+ wcscpy(p, L"-nan");
+ }
+ } else {
+ c = format.conversion_char;
+ p = buff - 4;
+ if ((c >= 0x100 ? 0 : _current_locale.ctype_cmpt_ptr->wctype_map_ptr[c] & 0x200) != 0) {
+ wcscpy(p, L"NAN");
+ } else {
+ wcscpy(p, L"nan");
+ }
+ }
+
+ return p;
+ }
+
+ dec.exp += (short)(dec.sig.length - 1);
+
+ p2 = (char*)&out_buf + sizeof(out_buf);
+ *--p2 = 0;
+
+ switch (format.conversion_char) {
+ case 'g':
+ case 'G':
+
+ if (dec.sig.length > format.precision) {
+ round_decimal(&dec, format.precision);
+ }
+
+ if (dec.exp < -4 || dec.exp >= format.precision) {
+ if (format.alternate_form) {
+ --format.precision;
+ } else {
+ format.precision = dec.sig.length - 1;
+ }
+
+ if (format.conversion_char == 'g') {
+ format.conversion_char = 'e';
+ } else {
+ format.conversion_char = 'E';
+ }
+
+ goto e_format;
+ }
+
+ if (format.alternate_form) {
+ format.precision -= dec.exp + 1;
+ } else {
+ if ((format.precision = dec.sig.length - (dec.exp + 1)) < 0) {
+ format.precision = 0;
+ }
+ }
+
+ goto f_format;
+
+ case 'e':
+ case 'E':
+ e_format:
+
+ if (dec.sig.length > format.precision + 1) {
+ round_decimal(&dec, format.precision + 1);
+ }
+
+ n = dec.exp;
+ sign = '+';
+
+ if (n < 0) {
+ n = -n;
+ sign = '-';
+ }
+
+ for (digits = 0; n || digits < 2; ++digits) {
+ *--p2 = n % 10 + '0';
+ n /= 10;
+ }
+
+ *--p2 = sign;
+ *--p2 = format.conversion_char;
+
+ used_bytes = (intptr_t)out_buf - (intptr_t)p2;
+ if (used_bytes + format.precision > 0x1FD) {
+ return NULL;
+ }
+
+ if (dec.sig.length < format.precision + 1) {
+ for (n = format.precision + 1 - dec.sig.length + 1; --n;) {
+ *--p2 = '0';
+ }
+ }
+
+ for (n = dec.sig.length, q = (dec.sig.text + dec.sig.length); --n;) {
+ *--p2 = *--q;
+ }
+
+ if (format.precision || format.alternate_form) {
+ *--p2 = radix_marker;
+ }
+
+ *--p2 = *dec.sig.text;
+
+ if (dec.sign)
+ *--p2 = '-';
+ else if (format.sign_options == sign_always)
+ *--p2 = '+';
+ else if (format.sign_options == space_holder)
+ *--p2 = ' ';
+
+ break;
+
+ case 'f':
+ case 'F':
+ f_format:
+
+ if ((frac_digits = -dec.exp + dec.sig.length - 1) < 0)
+ frac_digits = 0;
+
+ if (frac_digits > format.precision) {
+ round_decimal(&dec, dec.sig.length - (frac_digits - format.precision));
+
+ if ((frac_digits = -dec.exp + dec.sig.length - 1) < 0)
+ frac_digits = 0;
+ }
+
+ if ((int_digits = dec.exp + 1) < 0)
+ int_digits = 0;
+
+ if (int_digits + frac_digits > 509)
+ return 0;
+
+ q = dec.sig.text + dec.sig.length;
+
+ for (digits = 0; digits < (format.precision - frac_digits); ++digits)
+ *--p2 = '0';
+
+ for (digits = 0; digits < frac_digits && digits < dec.sig.length; ++digits)
+ *--p2 = *--q;
+
+ for (; digits < frac_digits; ++digits)
+ *--p2 = '0';
+
+ if (format.precision || format.alternate_form)
+ *--p2 = radix_marker;
+
+ if (int_digits) {
+ for (digits = 0; digits < int_digits - dec.sig.length; ++digits) {
+ *--p2 = '0';
+ }
+
+ for (; digits < int_digits; ++digits) {
+ *--p2 = *--q;
+ }
+ } else {
+ *--p2 = '0';
+ }
+
+ if (dec.sign) {
+ *--p2 = '-';
+ } else if (format.sign_options == sign_always) {
+ *--p2 = '+';
+ } else if (format.sign_options == space_holder) {
+ *--p2 = ' ';
+ }
+
+ break;
+ }
+
+ p = buff - strlen((char*)p2) - 1;
+ mbstowcs(p, p2, strlen((char*)p2));
+
+ return p;
+}
+
+int __wpformatter(int (*write_proc)(wString* dst, const void* data, size_t len),
+ void* proc_data, const wchar_t* fmt,
+ va_list args, int is_secure) {
+ int num_chars, chars_written, field_width;
+ const wchar_t* format_ptr;
+ const wchar_t* curr_format;
+ print_format format;
+ signed long long_num;
+ signed long long long_long_num;
+ long double long_double_num;
+ wchar_t buff[512];
+ wchar_t* buff_ptr;
+ const wchar_t* string_end;
+ wchar_t fill_char = ' ';
+
+ format_ptr = fmt;
+ chars_written = 0;
+
+ while (*format_ptr) {
+ if (!(curr_format = wcschr(format_ptr, L'%'))) {
+ num_chars = wcslen(format_ptr);
+ chars_written += num_chars;
+
+ if (num_chars && !(*write_proc)(proc_data, format_ptr, num_chars)) {
+ return -1;
+ }
+
+ break;
+ }
+
+ num_chars = curr_format - format_ptr;
+ chars_written += num_chars;
+
+ if (num_chars && !(*write_proc)(proc_data, format_ptr, num_chars)) {
+ return -1;
+ }
+
+ format_ptr = curr_format;
+ format_ptr = parse_format(format_ptr, (va_list*)args, &format);
+
+ switch (format.conversion_char) {
+ case 'd':
+ case 'i':
+ if (format.argument_options == long_argument) {
+ long_num = va_arg(args, signed long);
+ } else if (format.argument_options == long_long_argument) {
+ long_long_num = va_arg(args, signed long long);
+ } else if (format.argument_options == intmax_argument) {
+ long_long_num = va_arg(args, intmax_t);
+ } else if (format.argument_options == size_t_argument) {
+ long_num = va_arg(args, size_t);
+ } else if (format.argument_options == ptrdiff_argument) {
+ long_num = va_arg(args, ptrdiff_t);
+ } else {
+ long_num = va_arg(args, int);
+ }
+
+ if (format.argument_options == short_argument) {
+ long_num = (signed short)long_num;
+ }
+
+ if (format.argument_options == long_long_argument ||
+ format.argument_options == intmax_argument)
+ {
+ if (!(buff_ptr = longlong2str(long_long_num, buff + 512, format))) {
+ goto conversion_error;
+ }
+ } else {
+ if (!(buff_ptr = long2str(long_num, buff + 512, format))) {
+ goto conversion_error;
+ }
+ }
+
+ num_chars = buff + 512 - 1 - buff_ptr;
+ break;
+
+ case 'o':
+ case 'u':
+ case 'x':
+ case 'X':
+ if (format.argument_options == long_argument) {
+ long_num = va_arg(args, unsigned long);
+ } else if (format.argument_options == long_long_argument) {
+ long_long_num = va_arg(args, signed long long);
+ }
+ else if (format.argument_options == intmax_argument) {
+ long_long_num = va_arg(args, intmax_t);
+ }
+ else if (format.argument_options == size_t_argument) {
+ long_num = va_arg(args, size_t);
+ }
+ else if (format.argument_options == ptrdiff_argument) {
+ long_num = va_arg(args, ptrdiff_t);
+ }
+ else {
+ long_num = va_arg(args, unsigned int);
+ }
+
+ if (format.argument_options == short_argument) {
+ long_num = (unsigned short)long_num;
+ }
+
+ if ((format.argument_options == long_long_argument)
+ || format.argument_options == intmax_argument
+ )
+ {
+ if (!(buff_ptr = longlong2str(long_long_num, buff + 512, format))) {
+ goto conversion_error;
+ }
+ } else {
+ if (!(buff_ptr = long2str(long_num, buff + 512, format))) {
+ goto conversion_error;
+ }
+ }
+
+ num_chars = buff + 512 - 1 - buff_ptr;
+ break;
+
+ case 'f':
+ case 'F':
+ case 'e':
+ case 'E':
+ case 'g':
+ case 'G':
+ if (format.argument_options == long_double_argument) {
+ long_double_num = va_arg(args, long double);
+ } else {
+ long_double_num = va_arg(args, double);
+ }
+
+ if (!(buff_ptr = float2str(long_double_num, buff + 512, format))) {
+ goto conversion_error;
+ }
+
+ num_chars = buff + 512 - 1 - buff_ptr;
+ break;
+
+ case 'a':
+ case 'A':
+ if (format.argument_options == long_double_argument) {
+ long_double_num = va_arg(args, long double);
+ } else {
+ long_double_num = va_arg(args, double);
+ }
+
+ if (!(buff_ptr = double2hex(long_double_num, buff + 512, format))) {
+ goto conversion_error;
+ }
+
+ num_chars = buff + 512 - 1 - buff_ptr;
+ break;
+
+ case 's':
+ if (format.argument_options == wchar_argument) {
+ wchar_t* wcs_ptr = va_arg(args, wchar_t*);
+
+ if (is_secure && wcs_ptr == NULL){
+ __msl_runtime_constraint_violation_s(0,0,-1);
+ return -1;
+ }
+
+ if (wcs_ptr == NULL) {
+ wcs_ptr = L"";
+ }
+
+ if (format.alternate_form) {
+ num_chars = (unsigned char)*wcs_ptr++;
+
+ if (format.precision_specified && num_chars > format.precision) {
+ num_chars = format.precision;
+ }
+ } else if (format.precision_specified) {
+ num_chars = format.precision;
+
+ if ((string_end = wmemchr(wcs_ptr, 0, num_chars)) != 0) {
+ num_chars = string_end - wcs_ptr;
+ }
+
+ } else {
+ num_chars = wcslen(wcs_ptr);
+ }
+
+ buff_ptr = wcs_ptr;
+ break;
+ } else {
+ const char* wcs_ptr = (const char*)va_arg(args, wchar_t*);
+
+ if (is_secure && wcs_ptr == NULL){
+ __msl_runtime_constraint_violation_s(0,0,-1);
+ return -1;
+ }
+
+ if (wcs_ptr == NULL) {
+ wcs_ptr = "";
+ }
+
+ if (format.alternate_form) {
+ num_chars = (unsigned char)*buff_ptr;
+
+ if (format.precision_specified && num_chars > format.precision) {
+ num_chars = format.precision;
+ }
+ } else if (format.precision_specified) {
+ num_chars = format.precision;
+
+ if ((string_end = memchr(wcs_ptr, 0, num_chars)) != 0) {
+ num_chars = (intptr_t)string_end - (intptr_t)wcs_ptr;
+ }
+ } else {
+ num_chars = strlen(wcs_ptr);
+ }
+
+ if ((num_chars = mbstowcs(buff, wcs_ptr, num_chars)) < 0) {
+ goto conversion_error;
+ }
+
+ buff_ptr = buff;
+ }
+
+ break;
+
+ case 'n':
+ if (is_secure) {
+ __msl_runtime_constraint_violation_s(NULL, NULL, -1);
+ return -1;
+ }
+
+ buff_ptr = va_arg(args, wchar_t*);
+
+ switch (format.argument_options) {
+ case normal_argument:
+ *(int*)buff_ptr = chars_written;
+ break;
+ case short_argument:
+ *(signed short*)buff_ptr = chars_written;
+ break;
+ case long_argument:
+ *(signed long*)buff_ptr = chars_written;
+ break;
+ case intmax_argument:
+ *(intmax_t*)buff_ptr = chars_written;
+ break;
+ case size_t_argument:
+ *(size_t*)buff_ptr = chars_written;
+ break;
+ case ptrdiff_argument:
+ *(ptrdiff_t*)buff_ptr = chars_written;
+ break;
+ case long_long_argument:
+ *(signed long long*)buff_ptr = chars_written;
+ break;
+ }
+
+ continue;
+
+ case 'c':
+ buff_ptr = buff;
+ if (format.argument_options == wchar_argument) {
+ *buff_ptr = va_arg(args, long);
+ num_chars = 1;
+ } else {
+ char s;
+ s = va_arg(args, int);
+ num_chars = mbtowc(buff_ptr, &s, 1);
+ }
+ break;
+
+ case '%':
+ buff_ptr = buff;
+ *buff_ptr = '%';
+ num_chars = 1;
+ break;
+
+ case 0xFF:
+ default:
+ conversion_error:
+ num_chars = wcslen(curr_format);
+ chars_written += num_chars;
+
+ if (num_chars && !(*write_proc)(proc_data, curr_format, num_chars)) {
+ return -1;
+ }
+
+ return chars_written;
+ break;
+ }
+
+ field_width = num_chars;
+
+ if (format.justification_options != left_justification) {
+ fill_char = (format.justification_options == zero_fill) ? '0' : ' ';
+
+ if (((*buff_ptr == '+') || (*buff_ptr == '-') || (*buff_ptr == ' ')) &&
+ (fill_char == '0'))
+ {
+ if ((*write_proc)(proc_data, buff_ptr, 1) == 0) {
+ return -1;
+ }
+
+ ++buff_ptr;
+ num_chars--;
+ }
+
+ if ((format.justification_options == zero_fill) &&
+ ((format.conversion_char == 'a') || (format.conversion_char == 'A')))
+ {
+ if (num_chars < 2) {
+ return -1;
+ }
+
+ if ((*write_proc)(proc_data, buff_ptr, 2) == 0) {
+ return -1;
+ }
+
+ num_chars -= 2;
+ buff_ptr += 2;
+ }
+
+ while (field_width < format.field_width) {
+ if ((*write_proc)(proc_data, (wchar_t*)&fill_char, 1) == 0) {
+ return -1;
+ }
+
+ ++field_width;
+ }
+ }
+
+ if (num_chars && !(*write_proc)(proc_data, buff_ptr, num_chars)) {
+ return -1;
+ }
+
+ if (format.justification_options == left_justification) {
+ while (field_width < format.field_width) {
+ wchar_t blank = L' ';
+
+ if ((*write_proc)(proc_data, (wchar_t*)&blank, 1) == 0) {
+ return -1;
+ }
+
+ ++field_width;
+ }
+ }
+
+ chars_written += field_width;
+ }
+
+ return chars_written;
+}
+
+static int __wStringWrite(wString* dst, const void* data, size_t len) {
+ const __OutStrCtrl* osc = data;
+ size_t cur_len = dst->field_0x8;
+ size_t var_r7 = dst->field_0x4;
+ size_t write_cnt = cur_len + len <= var_r7 ? len : var_r7 - cur_len;
+ wmemcpy(dst->buffer + cur_len, (const wchar_t*)osc, write_cnt);
+ dst->field_0x8 += write_cnt;
+}
+
+int swprintf(wchar_t *dst, size_t maxlen, const wchar_t *fmt, ...) {
+ int written;
+ va_list args;
+ __OutStrCtrl ctx;
+
+ ctx.WCharStr = dst;
+
+ va_start(args, fmt);
+ ctx.MaxCharCount = maxlen;
+ ctx.CharsWritten = 0;
+ written = __wpformatter(__wStringWrite, &ctx, fmt, args, 0);
+ va_end(args);
+
+ if (written >= 0) {
+ if ((size_t)written < maxlen) {
+ dst[written] = '\0';
+ return written;
+ }
+ dst[maxlen - 1] = '\0';
+ return -1;
+ }
+}
+
+int vsnwprintf_s(wchar_t* str, size_t n, const wchar_t* fmt, va_list args) {
+ __OutStrCtrl osc;
+ int written_cnt;
+
+ if (str == NULL || fmt == NULL || n == 0 || n > 0x7FFFFFFFU) {
+ __msl_runtime_constraint_violation_s(0, 0, -1);
+ if (str != NULL && n != 0 && n <= 0x7FFFFFFFU) {
+ *str = 0;
+ }
+ return -1;
+ }
+
+ osc.MaxCharCount = n;
+ osc.WCharStr = str;
+ osc.CharsWritten = 0;
+ written_cnt = __wpformatter(__wStringWrite, &osc, fmt, args, 1);
+ if (written_cnt >= 0) {
+ if (written_cnt < n) {
+ str[written_cnt] = '\0';
+ return written_cnt;
+ }
+ str[n - 1] = '\0';
+ return written_cnt;
+ }
+ return written_cnt;
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wscanf.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wscanf.c
new file mode 100644
index 00000000..1906be0b
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wscanf.c
@@ -0,0 +1,27 @@
+#include <wscanf.h>
+#include <wstring.h>
+
+wchar_t __wStringRead(wString* src, wchar_t param_1, wchar_t param_2) {
+ switch (param_2) {
+ case 0:
+ param_2 = *src->buffer;
+ if (param_2 == 0) {
+ src->field_0x4 = 1;
+ return 0xFFFF;
+ } else {
+ src->buffer++;
+ return param_2;
+ }
+ case 1:
+ if (src->field_0x4 == 0) {
+ src->buffer--;
+ } else {
+ src->field_0x4 = 0;
+ }
+ return param_1;
+ case 2:
+ return src->field_0x4;
+ default:
+ return 0;
+ }
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wstring.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wstring.c
new file mode 100644
index 00000000..d1647831
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Src/wstring.c
@@ -0,0 +1,44 @@
+#include "wstring.h"
+
+size_t wcslen(const wchar_t* str) {
+ size_t len = -1;
+ wchar_t* p = (wchar_t*)str - 1;
+
+ do {
+ len++;
+ } while (*++p);
+
+ return len;
+}
+
+wchar_t* wcsncpy(wchar_t* dest, const wchar_t* src, size_t num) {
+ const wchar_t* p = (const wchar_t*)src - 1;
+ wchar_t* q = (wchar_t*)dest - 1;
+ wchar_t zero = 0;
+
+ num++;
+
+ while (--num) {
+ if (!(*++q = *++p)) {
+ while (--num) {
+ *++q = 0;
+ }
+
+ break;
+ }
+ }
+
+ return dest;
+}
+
+int wcscmp(const wchar_t* str1, const wchar_t* str2) {
+ const wchar_t* p1 = (wchar_t*)str1 - 1;
+ const wchar_t* p2 = (wchar_t*)str2 - 1;
+ wchar_t c1, c2;
+
+ while ((c1 = *++p1) == (c2 = *++p2))
+ if (!c1)
+ return 0;
+
+ return c1 - c2;
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_acos.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_acos.c
index d246b33d..e56c8f92 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_acos.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_acos.c
@@ -34,7 +34,7 @@
* Function needed: sqrt
*/
-#include "math.h"
+#include <cmath>
#ifdef __STDC__
static const double
@@ -72,6 +72,11 @@ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
if(hx>0) return 0.0; /* acos(1) = 0 */
else return pi+2.0*pio2_lo; /* acos(-1)= pi */
}
+
+ #if PLATFORM_SHIELD
+ errno = EDOM;
+ #endif
+
return NAN; /* acos(|x|>1) is NaN */
}
if(ix<0x3fe00000) { /* |x| < 0.5 */
@@ -101,4 +106,4 @@ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
w = r*s+c;
return 2.0*(df+w);
}
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_asin.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_asin.c
index 3e73711a..4bbf550c 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_asin.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_asin.c
@@ -40,7 +40,7 @@
*
*/
-#include "math.h"
+#include <cmath>
#ifdef __STDC__
static const double
@@ -78,6 +78,11 @@ double __ieee754_asin(x) double x;
if (((ix - 0x3ff00000) | __LO(x)) == 0)
/* asin(1)=+-pi/2 with inexact */
return x * pio2_hi + x * pio2_lo;
+
+ #if PLATFORM_SHIELD
+ errno = EDOM;
+ #endif
+
return NAN; /* asin(|x|>1) is NaN */
} else if (ix < 0x3fe00000) { /* |x|<0.5 */
if (ix < 0x3e400000) { /* if |x| < 2**-27 */
@@ -112,4 +117,4 @@ double __ieee754_asin(x) double x;
return t;
else
return -t;
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_fmod.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_fmod.c
index 2659d584..260085ba 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_fmod.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_fmod.c
@@ -37,6 +37,9 @@ double __ieee754_fmod(x, y) double x, y;
#endif
{
int n, hx, hy, hz, ix, iy, sx, i;
+ #if !PLATFORM_GCN
+ int diff;
+ #endif
unsigned lx, ly, lz;
hx = __HI(x); /* high word of x */
@@ -110,9 +113,19 @@ double __ieee754_fmod(x, y) double x, y;
/* fix point fmod */
n = ix - iy;
+ #if !PLATFORM_GCN
+ diff = n + 2;
+ #endif
+
while (n--) {
hz = hx - hy;
lz = lx - ly;
+ #if PLATFORM_SHIELD
+ if (!hz)
+ if((lx >> diff) == (ly >> diff))
+ return Zero[(unsigned)sx>>31];
+ #endif
+
if (lx < ly)
hz -= 1;
if (hz < 0) {
@@ -127,6 +140,12 @@ double __ieee754_fmod(x, y) double x, y;
}
hz = hx - hy;
lz = lx - ly;
+ #if PLATFORM_SHIELD
+ if (!hz)
+ if((lx >> diff) == (ly >> diff))
+ return Zero[(unsigned)sx>>31];
+ #endif
+
if (lx < ly)
hz -= 1;
if (hz >= 0) {
@@ -163,4 +182,4 @@ double __ieee754_fmod(x, y) double x, y;
x *= one; /* create necessary signal */
}
return x; /* exact output */
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_log.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_log.c
new file mode 100644
index 00000000..d730d777
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_log.c
@@ -0,0 +1,161 @@
+/* @(#)e_log.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/* __ieee754_log(x)
+ * Return the logrithm of x
+ *
+ * Method :
+ * 1. Argument Reduction: find k and f such that
+ * x = 2^k * (1+f),
+ * where sqrt(2)/2 < 1+f < sqrt(2) .
+ *
+ * 2. Approximation of log(1+f).
+ * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
+ * = 2s + 2/3 s**3 + 2/5 s**5 + .....,
+ * = 2s + s*R
+ * We use a special Reme algorithm on [0,0.1716] to generate
+ * a polynomial of degree 14 to approximate R The maximum error
+ * of this polynomial approximation is bounded by 2**-58.45. In
+ * other words,
+ * 2 4 6 8 10 12 14
+ * R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s
+ * (the values of Lg1 to Lg7 are listed in the program)
+ * and
+ * | 2 14 | -58.45
+ * | Lg1*s +...+Lg7*s - R(z) | <= 2
+ * | |
+ * Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
+ * In order to guarantee error in log below 1ulp, we compute log
+ * by
+ * log(1+f) = f - s*(f - R) (if f is not too large)
+ * log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy)
+ *
+ * 3. Finally, log(x) = k*ln2 + log(1+f).
+ * = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
+ * Here ln2 is split into two floating point number:
+ * ln2_hi + ln2_lo,
+ * where n*ln2_hi is always exact for |n| < 2000.
+ *
+ * Special cases:
+ * log(x) is NaN with signal if x < 0 (including -INF) ;
+ * log(+INF) is +INF; log(0) is -INF with signal;
+ * log(NaN) is that NaN with no signal.
+ *
+ * Accuracy:
+ * according to an error analysis, the error is always less than
+ * 1 ulp (unit in the last place).
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following
+ * constants. The decimal values may be used, provided that the
+ * compiler will convert from decimal to binary accurately enough
+ * to produce the hexadecimal values shown.
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+static const double
+#else
+static double
+#endif
+ ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */
+ ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */
+ two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */
+ Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */
+ Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */
+ Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */
+ Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */
+ Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
+ Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
+ Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
+
+static double zero = 0.0;
+
+#ifdef __STDC__
+double __ieee754_log(double x)
+#else
+double __ieee754_log(x)
+double x;
+#endif
+{
+ double hfsq, f, s, z, R, w, t1, t2, dk;
+ int k, hx, i, j;
+ unsigned lx;
+
+ hx = __HI(x); /* high word of x */
+ lx = __LO(x); /* low word of x */
+
+ k = 0;
+ if (hx < 0x00100000) { /* x < 2**-1022 */
+ if (((hx & 0x7fffffff) | lx) == 0) {
+ return -two54 / zero; /* log(+-0)=-inf */
+ }
+ if (hx < 0) {
+ errno = EDOM;
+ return (x - x) / zero;
+ } /* log(-#) = NaN */
+ k -= 54;
+ x *= two54; /* subnormal number, scale up x */
+ hx = __HI(x); /* high word of x */
+ }
+ if (hx >= 0x7ff00000) {
+ return x + x;
+ }
+ k += (hx >> 20) - 1023;
+ hx &= 0x000fffff;
+ i = (hx + 0x95f64) & 0x100000;
+ __HI(x) = hx | (i ^ 0x3ff00000); /* normalize x or x/2 */
+ k += (i >> 20);
+ f = x - 1.0;
+ if ((0x000fffff & (2 + hx)) < 3) { /* |f| < 2**-20 */
+ if (f == zero) {
+ if (k == 0) {
+ return zero;
+ } else {
+ dk = (double)k;
+ return dk * ln2_hi + dk * ln2_lo;
+ }
+ }
+ R = f * f * (0.5 - 0.33333333333333333 * f);
+ if (k == 0) {
+ return f - R;
+ } else {
+ dk = (double)k;
+ return dk * ln2_hi - ((R - dk * ln2_lo) - f);
+ }
+ }
+ s = f / (2.0 + f);
+ dk = (double)k;
+ z = s * s;
+ i = hx - 0x6147a;
+ w = z * z;
+ j = 0x6b851 - hx;
+ t1 = w * (Lg2 + w * (Lg4 + w * Lg6));
+ t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));
+ i |= j;
+ R = t2 + t1;
+ if (i > 0) {
+ hfsq = 0.5 * f * f;
+ if (k == 0) {
+ return f - (hfsq - s * (hfsq + R));
+ } else {
+ return dk * ln2_hi - ((hfsq - (s * (hfsq + R) + dk * ln2_lo)) - f);
+ }
+ } else {
+ if (k == 0) {
+ return f - s * (f - R);
+ } else {
+ return dk * ln2_hi - ((s * (f - R) - dk * ln2_lo) - f);
+ }
+ }
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_log10.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_log10.c
new file mode 100644
index 00000000..94cdaf20
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_log10.c
@@ -0,0 +1,99 @@
+
+/* @(#)e_log10.c 1.3 95/01/18 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunSoft, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/* __ieee754_log10(x)
+ * Return the base 10 logarithm of x
+ *
+ * Method :
+ * Let log10_2hi = leading 40 bits of log10(2) and
+ * log10_2lo = log10(2) - log10_2hi,
+ * ivln10 = 1/log(10) rounded.
+ * Then
+ * n = ilogb(x),
+ * if(n<0) n = n+1;
+ * x = scalbn(x,-n);
+ * log10(x) := n*log10_2hi + (n*log10_2lo + ivln10*log(x))
+ *
+ * Note 1:
+ * To guarantee log10(10**n)=n, where 10**n is normal, the rounding
+ * mode must set to Round-to-Nearest.
+ * Note 2:
+ * [1/log(10)] rounded to 53 bits has error .198 ulps;
+ * log10 is monotonic at all binary break points.
+ *
+ * Special cases:
+ * log10(x) is NaN with signal if x < 0;
+ * log10(+INF) is +INF with no signal; log10(0) is -INF with signal;
+ * log10(NaN) is that NaN with no signal;
+ * log10(10**N) = N for N=0,1,...,22.
+ *
+ * Constants:
+ * The hexadecimal values are the intended ones for the following constants.
+ * The decimal values may be used, provided that the compiler will convert
+ * from decimal to binary accurately enough to produce the hexadecimal values
+ * shown.
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+static const double
+#else
+static double
+#endif
+ two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
+ ivln10 = 4.34294481903251816668e-01, /* 0x3FDBCB7B, 0x1526E50E */
+ log10_2hi = 3.01029995663611771306e-01, /* 0x3FD34413, 0x509F6000 */
+ log10_2lo = 3.69423907715893078616e-13; /* 0x3D59FEF3, 0x11F12B36 */
+
+static double zero = 0.0;
+
+#ifdef __STDC__
+double __ieee754_log10(double x)
+#else
+double __ieee754_log10(x)
+double x;
+#endif
+{
+ double y, z;
+ int i, k, hx;
+ unsigned lx;
+
+ hx = __HI(x); /* high word of x */
+ lx = __LO(x); /* low word of x */
+
+ k = 0;
+ if (hx < 0x00100000) { /* x < 2**-1022 */
+ if (((hx & 0x7fffffff) | lx) == 0) {
+ errno = EDOM;
+ return -two54 / zero;
+ } /* log(+-0)=-inf */
+ if (hx < 0) {
+ errno = EDOM;
+ return (x - x) / zero;
+ } /* log(-#) = NaN */
+ k -= 54;
+ x *= two54; /* subnormal number, scale up x */
+ hx = __HI(x); /* high word of x */
+ }
+ if (hx >= 0x7ff00000) {
+ return x + x;
+ }
+ k += (hx >> 20) - 1023;
+ i = ((unsigned)k & 0x80000000) >> 31;
+ hx = (hx & 0x000fffff) | ((0x3ff - i) << 20);
+ y = (double)(k + i);
+ __HI(x) = hx;
+ z = y * log10_2lo + ivln10 * __ieee754_log(x);
+ return z + y * log10_2hi;
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_pow.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_pow.c
index ba3a59db..4a72bebf 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_pow.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_pow.c
@@ -1,59 +1,4 @@
-//========================================================================
-//
-// e_pow.c
-//
-// Part of the standard mathematical function library
-//
-//========================================================================
-//####ECOSGPLCOPYRIGHTBEGIN####
-// -------------------------------------------
-// This file is part of eCos, the Embedded Configurable Operating System.
-// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
-//
-// eCos is free software; you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation; either version 2 or (at your option) any later version.
-//
-// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
-// WARRANTY; without even the implied warranty of MERCHANTABILITY or
-// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-// for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with eCos; if not, write to the Free Software Foundation, Inc.,
-// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-//
-// As a special exception, if other files instantiate templates or use macros
-// or inline functions from this file, or you compile this file and link it
-// with other works to produce a work based on this file, this file does not
-// by itself cause the resulting work to be covered by the GNU General Public
-// License. However the source code for this file must still be made available
-// in accordance with section (3) of the GNU General Public License.
-//
-// This exception does not invalidate any other reasons why a work based on
-// this file might be covered by the GNU General Public License.
-//
-// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
-// at http://sources.redhat.com/ecos/ecos-license/
-// -------------------------------------------
-//####ECOSGPLCOPYRIGHTEND####
-//========================================================================
-//#####DESCRIPTIONBEGIN####
-//
-// Author(s): jlarmour
-// Contributors:
-// Date: 2001-07-20
-// Purpose:
-// Description:
-// Usage:
-//
-//####DESCRIPTIONEND####
-//
-//========================================================================
-
-// CONFIGURATION
-
-/* @(#)e_pow.c 5.1 93/09/24 */
+/* @(#)e_pow.c 1.2 95/01/04 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -110,298 +55,322 @@
* to produce the hexadecimal values shown.
*/
-#include "common.h"
#include "errno.h"
-#include "math.h"
-
-#ifndef _DOUBLE_IS_32BITS
+#include <cmath>
#ifdef __STDC__
static const double
#else
static double
#endif
-bp[] = {1.0, 1.5,},
-dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */
-dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */
-zero = 0.0,
-one = 1.0,
-two = 2.0,
-two53 = 9007199254740992.0, /* 0x43400000, 0x00000000 */
-huge = 1.0e300,
-tiny = 1.0e-300,
- /* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
-L1 = 5.99999999999994648725e-01, /* 0x3FE33333, 0x33333303 */
-L2 = 4.28571428578550184252e-01, /* 0x3FDB6DB6, 0xDB6FABFF */
-L3 = 3.33333329818377432918e-01, /* 0x3FD55555, 0x518F264D */
-L4 = 2.72728123808534006489e-01, /* 0x3FD17460, 0xA91D4101 */
-L5 = 2.30660745775561754067e-01, /* 0x3FCD864A, 0x93C9DB65 */
-L6 = 2.06975017800338417784e-01, /* 0x3FCA7E28, 0x4A454EEF */
-P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */
-P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
-P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
-P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
-P5 = 4.13813679705723846039e-08, /* 0x3E663769, 0x72BEA4D0 */
-lg2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */
-lg2_h = 6.93147182464599609375e-01, /* 0x3FE62E43, 0x00000000 */
-lg2_l = -1.90465429995776804525e-09, /* 0xBE205C61, 0x0CA86C39 */
-ovt = 8.0085662595372944372e-0017, /* -(1024-log2(ovfl+.5ulp)) */
-cp = 9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */
-cp_h = 9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */
-cp_l = -7.02846165095275826516e-09, /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/
-ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */
-ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/
-ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
+ bp[] =
+ {
+ 1.0,
+ 1.5,
+},
+ dp_h[] =
+ {
+ 0.0,
+ 5.84962487220764160156e-01,
+}, /* 0x3FE2B803, 0x40000000 */
+ dp_l[] =
+ {
+ 0.0,
+ 1.35003920212974897128e-08,
+}, /* 0x3E4CFDEB, 0x43CFD006 */
+ zero = 0.0, one = 1.0, two = 2.0, two53 = 9007199254740992.0, /* 0x43400000, 0x00000000 */
+ big = 1.0e300, tiny = 1.0e-300,
+ /* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
+ L1 = 5.99999999999994648725e-01, /* 0x3FE33333, 0x33333303 */
+ L2 = 4.28571428578550184252e-01, /* 0x3FDB6DB6, 0xDB6FABFF */
+ L3 = 3.33333329818377432918e-01, /* 0x3FD55555, 0x518F264D */
+ L4 = 2.72728123808534006489e-01, /* 0x3FD17460, 0xA91D4101 */
+ L5 = 2.30660745775561754067e-01, /* 0x3FCD864A, 0x93C9DB65 */
+ L6 = 2.06975017800338417784e-01, /* 0x3FCA7E28, 0x4A454EEF */
+ P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */
+ P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
+ P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
+ P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
+ P5 = 4.13813679705723846039e-08, /* 0x3E663769, 0x72BEA4D0 */
+ lg2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */
+ lg2_h = 6.93147182464599609375e-01, /* 0x3FE62E43, 0x00000000 */
+ lg2_l = -1.90465429995776804525e-09, /* 0xBE205C61, 0x0CA86C39 */
+ ovt = 8.0085662595372944372e-0017, /* -(1024-log2(ovfl+.5ulp)) */
+ cp = 9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */
+ cp_h = 9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */
+ cp_l = -7.02846165095275826516e-09, /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/
+ ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */
+ ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/
+ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
#ifdef __STDC__
double __ieee754_pow(double x, double y)
#else
-double __ieee754_pow(x, y) double x, y;
+double __ieee754_pow(x, y)
+double x, y;
#endif
{
- double z, ax, z_h, z_l, p_h, p_l;
- double y1, t1, t2, r, s, t, u, v, w;
- double qqq; // necessary temp
- int i0, i1, i, j, k, yisint, n;
- int hx, hy, ix, iy;
- u32 lx, ly;
+ double z, ax, z_h, z_l, p_h, p_l;
+ double y1, t1, t2, r, s, t, u, v, w;
+ int i, j, k, yisint, n;
+ int hx, hy, ix, iy;
+ unsigned lx, ly;
- i0 = ((*(int*)&one) >> 29) ^ 1;
- i1 = 1 - i0;
- hx = __HI(x);
- lx = __LO(x);
- hy = __HI(y);
- ly = __LO(y);
- ix = hx & 0x7fffffff;
- iy = hy & 0x7fffffff;
+ hx = __HI(x);
+ lx = __LO(x);
+ hy = __HI(y);
+ ly = __LO(y);
+ ix = hx & 0x7fffffff;
+ iy = hy & 0x7fffffff;
- /* y==zero: x**0 = 1 */
- if ((iy | ly) == 0)
- return one;
+ /* y==zero: x**0 = 1 */
+ if ((iy | ly) == 0) {
+ return one;
+ }
- /* +-NaN return x+y */
- if (ix > 0x7ff00000 || ((ix == 0x7ff00000) && (lx != 0)) || iy > 0x7ff00000 || ((iy == 0x7ff00000) && (ly != 0)))
- return x + y;
+ /* +-NaN return x+y */
+ if (ix > 0x7ff00000 || ((ix == 0x7ff00000) && (lx != 0)) || iy > 0x7ff00000 || ((iy == 0x7ff00000) && (ly != 0))) {
+ return x + y;
+#ifdef __STDC__
+ errno = EDOM; /* mf-- added to conform to old ANSI standard */
+#endif
+ }
- /* determine if y is an odd int when x < 0
- * yisint = 0 ... y is not an integer
- * yisint = 1 ... y is an odd int
- * yisint = 2 ... y is an even int
- */
- yisint = 0;
- if (hx < 0) {
- if (iy >= 0x43400000)
- yisint = 2; /* even integer y */
- else if (iy >= 0x3ff00000) {
- k = (iy >> 20) - 0x3ff; /* exponent */
- if (k > 20) {
- j = ly >> (52 - k);
- if ((j << (52 - k)) == ly)
- yisint = 2 - (j & 1);
- } else if (ly == 0) {
- j = iy >> (20 - k);
- if ((j << (20 - k)) == iy)
- yisint = 2 - (j & 1);
- }
- }
- }
+ /* determine if y is an odd int when x < 0
+ * yisint = 0 ... y is not an integer
+ * yisint = 1 ... y is an odd int
+ * yisint = 2 ... y is an even int
+ */
+ yisint = 0;
+ if (hx < 0) {
+ if (iy >= 0x43400000) {
+ yisint = 2; /* even integer y */
+ } else if (iy >= 0x3ff00000) {
+ k = (iy >> 20) - 0x3ff; /* exponent */
+ if (k > 20) {
+ j = ly >> (52 - k);
+ if ((j << (52 - k)) == ly) {
+ yisint = 2 - (j & 1);
+ }
+ } else if (ly == 0) {
+ j = iy >> (20 - k);
+ if ((j << (20 - k)) == iy) {
+ yisint = 2 - (j & 1);
+ }
+ }
+ }
+ }
- /* special value of y */
- if (ly == 0) {
- if (iy == 0x7ff00000) { /* y is +-inf */
- if (((ix - 0x3ff00000) | lx) == 0)
- return y - y; /* inf**+-1 is NaN */
- else if (ix >= 0x3ff00000) /* (|x|>1)**+-inf = inf,0 */
- return (hy >= 0) ? y : zero;
- else /* (|x|<1)**-,+inf = inf,0 */
- return (hy < 0) ? -y : zero;
- }
- if (iy == 0x3ff00000) { /* y is +-1 */
- if (hy < 0)
- return one / x;
- else
- return x;
- }
- if (hy == 0x40000000)
- return x * x; /* y is 2 */
- if (hy == 0x3fe00000) { /* y is 0.5 */
- if (hx >= 0) /* x >= +0 */
- return sqrt(x);
- }
- }
+ /* special value of y */
+ if (ly == 0) {
+ if (iy == 0x7ff00000) {
- ax = __fabs(x);
- qqq = ax; /*x is +-0,+-inf,+-1*/
- /* special value of x */
- if (lx == 0) {
- if (ix == 0x7ff00000 || ix == 0 || ix == 0x3ff00000) {
- z = qqq; /*x is +-0,+-inf,+-1*/
- if (hy < 0)
- z = one / z; /* z = (1/|x|) */
- if (hx < 0) {
- if (((ix - 0x3ff00000) | yisint) == 0) {
- z = (z - z) / (z - z); /* (-1)**non-int is NaN */
- } else if (yisint == 1)
- z = -z; /* (x<0)**odd = -(|x|**odd) */
- }
- return z;
- }
- }
+ /* y is +-inf */
+ if (((ix - 0x3ff00000) | lx) == 0) {
+ return y - y; /* inf**+-1 is NaN */
+ } else if (ix >= 0x3ff00000) { /* (|x|>1)**+-inf = inf,0 */
+ return (hy >= 0) ? y : zero;
+ } else { /* (|x|<1)**-,+inf = inf,0 */
+ return (hy < 0) ? -y : zero;
+ }
+ }
+ if (iy == 0x3ff00000) {
+ /* y is +-1 */
+ if (hy < 0) {
+ return one / x;
+ } else {
+ return x;
+ }
+ }
+ if (hy == 0x40000000) {
+ return x * x; /* y is 2 */
+ }
+ if (hy == 0x3fe00000) { /* y is 0.5 */
+ if (hx >= 0) { /* x >= +0 */
+ return sqrt(x);
+ }
+ }
+ }
- /* (x<0)**(non-int) is NaN */
- /* CYGNUS LOCAL: This used to be
- if((((hx>>31)+1)|yisint)==0) return (x-x)/(x-x);
- but ANSI C says a right shift of a signed negative quantity is
- implementation defined. */
+ ax = fabs(x);
+ /* special value of x */
+ if (lx == 0) {
+ if (ix == 0x7ff00000 || ix == 0 || ix == 0x3ff00000) {
+ z = ax; /*x is +-0,+-inf,+-1*/
+ if (hy < 0) {
+ z = one / z; /* z = (1/|x|) */
+ }
+ if (hx < 0) {
+ if (((ix - 0x3ff00000) | yisint) == 0) {
+ z = (z - z) / (z - z); /* (-1)**non-int is NaN */
+ } else if (yisint == 1) {
+ z = -z; /* (x<0)**odd = -(|x|**odd) */
+ }
+ }
+ return z;
+ }
+ }
- if (((((int)hx >> 31) + 1) | yisint) == 0) {
- errno = 33;
- return (double)NAN;
- };
+ /* (x<0)**(non-int) is NaN */
+ if ((((hx >> 31) + 1) | yisint) == 0) {
+#ifdef __STDC__
+ errno = EDOM; /* mf-- added to conform to old ANSI standard */
+#endif
+ return NAN;
+ }
- /* |y| is huge */
- if (iy > 0x41e00000) { /* if |y| > 2**31 */
- if (iy > 0x43f00000) { /* if |y| > 2**64, must o/uflow */
- if (ix <= 0x3fefffff)
- return (hy < 0) ? huge * huge : tiny * tiny;
- if (ix >= 0x3ff00000)
- return (hy > 0) ? huge * huge : tiny * tiny;
- }
- /* over/underflow if x is not close to one */
- if (ix < 0x3fefffff)
- return (hy < 0) ? huge * huge : tiny * tiny;
- if (ix > 0x3ff00000)
- return (hy > 0) ? huge * huge : tiny * tiny;
- /* now |1-x| is tiny <= 2**-20, suffice to compute
- log(x) by x-x^2/2+x^3/3-x^4/4 */
- t = x - 1; /* t has 20 trailing zeros */
- w = (t * t) * (0.5 - t * (0.3333333333333333333333 - t * 0.25));
- u = ivln2_h * t; /* ivln2_h has 21 sig. bits */
- v = t * ivln2_l - w * ivln2;
- t1 = u + v;
- __LO(t1) = 0;
- t2 = v - (t1 - u);
- } else {
- double s2, s_h, s_l, t_h, t_l;
- n = 0;
- /* take care subnormal number */
- if (ix < 0x00100000) {
- ax *= two53;
- n -= 53;
- ix = __HI(ax);
- }
- n += ((ix) >> 20) - 0x3ff;
- j = ix & 0x000fffff;
- /* determine interval */
- ix = j | 0x3ff00000; /* normalize ix */
- if (j <= 0x3988E)
- k = 0; /* |x|<sqrt(3/2) */
- else if (j < 0xBB67A)
- k = 1; /* |x|<sqrt(3) */
- else {
- k = 0;
- n += 1;
- ix -= 0x00100000;
- }
- __HI(ax) = ix;
+ /* |y| is big */
+ if (iy > 0x41e00000) { /* if |y| > 2**31 */
+ if (iy > 0x43f00000) { /* if |y| > 2**64, must o/uflow */
+ if (ix <= 0x3fefffff) {
+ return (hy < 0) ? big * big : tiny * tiny;
+ }
+ if (ix >= 0x3ff00000) {
+ return (hy > 0) ? big * big : tiny * tiny;
+ }
+ }
+ /* over/underflow if x is not close to one */
+ if (ix < 0x3fefffff) {
+ return (hy < 0) ? big * big : tiny * tiny;
+ }
+ if (ix > 0x3ff00000) {
+ return (hy > 0) ? big * big : tiny * tiny;
+ }
+ /* now |1-x| is tiny <= 2**-20, suffice to compute
+ log(x) by x-x^2/2+x^3/3-x^4/4 */
+ t = x - 1; /* t has 20 trailing zeros */
+ w = (t * t) * (0.5 - t * (0.3333333333333333333333 - t * 0.25));
+ u = ivln2_h * t; /* ivln2_h has 21 sig. bits */
+ v = t * ivln2_l - w * ivln2;
+ t1 = u + v;
+ __LO(t1) = 0;
+ t2 = v - (t1 - u);
+ } else {
+ double s2, s_h, s_l, t_h, t_l;
+ n = 0;
+ /* take care subnormal number */
+ if (ix < 0x00100000) {
+ ax *= two53;
+ n -= 53;
+ ix = __HI(ax);
+ }
+ n += ((ix) >> 20) - 0x3ff;
+ j = ix & 0x000fffff;
+ /* determine interval */
+ ix = j | 0x3ff00000; /* normalize ix */
+ if (j <= 0x3988E) {
+ k = 0; /* |x|<sqrt(3/2) */
+ } else if (j < 0xBB67A) {
+ k = 1; /* |x|<sqrt(3) */
+ } else {
+ k = 0;
+ n += 1;
+ ix -= 0x00100000;
+ }
+ __HI(ax) = ix;
- /* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
- u = ax - bp[k]; /* bp[0]=1.0, bp[1]=1.5 */
- v = one / (ax + bp[k]);
- s = u * v;
- s_h = s;
- __LO(s_h) = 0;
- /* t_h=ax+bp[k] High */
- t_h = zero;
- __HI(t_h) = ((ix >> 1) | 0x20000000) + 0x00080000 + (k << 18);
- t_l = ax - (t_h - bp[k]);
- s_l = v * ((u - s_h * t_h) - s_h * t_l);
- /* compute log(ax) */
- s2 = s * s;
- r = s2 * s2 * (L1 + s2 * (L2 + s2 * (L3 + s2 * (L4 + s2 * (L5 + s2 * L6)))));
- r += s_l * (s_h + s);
- s2 = s_h * s_h;
- t_h = 3.0 + s2 + r;
- __LO(t_h) = 0;
- t_l = r - ((t_h - 3.0) - s2);
- /* u+v = s*(1+...) */
- u = s_h * t_h;
- v = s_l * t_h + t_l * s;
- /* 2/(3log2)*(s+...) */
- p_h = u + v;
- __LO(p_h) = 0;
- p_l = v - (p_h - u);
- z_h = cp_h * p_h; /* cp_h+cp_l = 2/(3*log2) */
- z_l = cp_l * p_h + p_l * cp + dp_l[k];
- /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */
- t = (double)n;
- t1 = (((z_h + z_l) + dp_h[k]) + t);
- __LO(t1) = 0;
- t2 = z_l - (((t1 - t) - dp_h[k]) - z_h);
- }
+ /* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
+ u = ax - bp[k]; /* bp[0]=1.0, bp[1]=1.5 */
+ v = one / (ax + bp[k]);
+ s = u * v;
+ s_h = s;
+ __LO(s_h) = 0;
+ /* t_h=ax+bp[k] High */
+ t_h = zero;
+ __HI(t_h) = ((ix >> 1) | 0x20000000) + 0x00080000 + (k << 18);
+ t_l = ax - (t_h - bp[k]);
+ s_l = v * ((u - s_h * t_h) - s_h * t_l);
+ /* compute log(ax) */
+ s2 = s * s;
+ r = s2 * s2 * (L1 + s2 * (L2 + s2 * (L3 + s2 * (L4 + s2 * (L5 + s2 * L6)))));
+ r += s_l * (s_h + s);
+ s2 = s_h * s_h;
+ t_h = 3.0 + s2 + r;
+ __LO(t_h) = 0;
+ t_l = r - ((t_h - 3.0) - s2);
+ /* u+v = s*(1+...) */
+ u = s_h * t_h;
+ v = s_l * t_h + t_l * s;
+ /* 2/(3log2)*(s+...) */
+ p_h = u + v;
+ __LO(p_h) = 0;
+ p_l = v - (p_h - u);
+ z_h = cp_h * p_h; /* cp_h+cp_l = 2/(3*log2) */
+ z_l = cp_l * p_h + p_l * cp + dp_l[k];
+ /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */
+ t = (double)n;
+ t1 = (((z_h + z_l) + dp_h[k]) + t);
+ __LO(t1) = 0;
+ t2 = z_l - (((t1 - t) - dp_h[k]) - z_h);
+ }
- s = one; /* s (sign of result -ve**odd) = -1 else = 1 */
- if (((((int)hx >> 31) + 1) | (yisint - 1)) == 0)
- s = -one; /* (-ve)**(odd int) */
+ s = one; /* s (sign of result -ve**odd) = -1 else = 1 */
+ if ((((hx >> 31) + 1) | (yisint - 1)) == 0) {
+ s = -one; /* (-ve)**(odd int) */
+ }
- /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
- y1 = y;
- __LO(y1) = 0;
- p_l = (y - y1) * t1 + y * t2;
- p_h = y1 * t1;
- z = p_l + p_h;
- j = __HI(z);
- i = __LO(z);
- if (j >= 0x40900000) { /* z >= 1024 */
- if (((j - 0x40900000) | i) != 0) /* if z > 1024 */
- return s * huge * huge; /* overflow */
- else {
- if (p_l + ovt > z - p_h)
- return s * huge * huge; /* overflow */
- }
- } else if ((j & 0x7fffffff) >= 0x4090cc00) { /* z <= -1075 */
- if (((j - 0xc090cc00) | i) != 0) /* z < -1075 */
- return s * tiny * tiny; /* underflow */
- else {
- if (p_l <= z - p_h)
- return s * tiny * tiny; /* underflow */
- }
- }
- /*
- * compute 2**(p_h+p_l)
- */
- i = j & 0x7fffffff;
- k = (i >> 20) - 0x3ff;
- n = 0;
- if (i > 0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */
- n = j + (0x00100000 >> (k + 1));
- k = ((n & 0x7fffffff) >> 20) - 0x3ff; /* new k for n */
- t = zero;
- __HI(t) = (n & ~(0x000fffff >> k));
- n = ((n & 0x000fffff) | 0x00100000) >> (20 - k);
- if (j < 0)
- n = -n;
- p_h -= t;
- }
- t = p_l + p_h;
- __LO(t) = 0;
- u = t * lg2_h;
- v = (p_l - (t - p_h)) * lg2 + t * lg2_l;
- z = u + v;
- w = v - (z - u);
- t = z * z;
- t1 = z - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5))));
- r = (z * t1) / (t1 - two) - (w + z * w);
- z = one - (r - z);
- j = __HI(z);
- j += (n << 20);
- if ((j >> 20) <= 0)
- z = ldexp(z, n); /* subnormal output */
- else
- __HI(z) += (n << 20);
- return s * z;
+ /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
+ y1 = y;
+ __LO(y1) = 0;
+ p_l = (y - y1) * t1 + y * t2;
+ p_h = y1 * t1;
+ z = p_l + p_h;
+ j = __HI(z);
+ i = __LO(z);
+ if (j >= 0x40900000) { /* z >= 1024 */
+ if (((j - 0x40900000) | i) != 0) { /* if z > 1024 */
+ return s * big * big; /* overflow */
+ } else {
+ if (p_l + ovt > z - p_h) {
+ return s * big * big; /* overflow */
+ }
+ }
+ } else if ((j & 0x7fffffff) >= 0x4090cc00) { /* z <= -1075 */
+ if (((j - 0xc090cc00) | i) != 0) { /* z < -1075 */
+ return s * tiny * tiny; /* underflow */
+ } else {
+ if (p_l <= z - p_h) {
+ return s * tiny * tiny; /* underflow */
+ }
+ }
+ }
+ /*
+ * compute 2**(p_h+p_l)
+ */
+ i = j & 0x7fffffff;
+ k = (i >> 20) - 0x3ff;
+ n = 0;
+ if (i > 0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */
+ n = j + (0x00100000 >> (k + 1));
+ k = ((n & 0x7fffffff) >> 20) - 0x3ff; /* new k for n */
+ t = zero;
+ __HI(t) = (n & ~(0x000fffff >> k));
+ n = ((n & 0x000fffff) | 0x00100000) >> (20 - k);
+ if (j < 0) {
+ n = -n;
+ }
+ p_h -= t;
+ }
+ t = p_l + p_h;
+ __LO(t) = 0;
+ u = t * lg2_h;
+ v = (p_l - (t - p_h)) * lg2 + t * lg2_l;
+ z = u + v;
+ w = v - (z - u);
+ t = z * z;
+ t1 = z - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5))));
+ r = (z * t1) / (t1 - two) - (w + z * w);
+ z = one - (r - z);
+ j = __HI(z);
+ j += (n << 20);
+ if ((j >> 20) <= 0) {
+ #if PLATFORM_GCN
+ z = ldexp(z, n); /* subnormal output */
+ #else
+ z = scalbn(z, n); /* subnormal output */
+ #endif
+ } else {
+ __HI(z) += (n << 20);
+ }
+ return s * z;
}
-
-#endif /* defined(_DOUBLE_IS_32BITS) */
-
-// EOF e_pow.c
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_rem_pio2.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_rem_pio2.c
index b179a8ee..20b74f00 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_rem_pio2.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_rem_pio2.c
@@ -1,3 +1,4 @@
+
/* @(#)e_rem_pio2.c 1.4 95/01/18 */
/*
* ====================================================
@@ -17,7 +18,7 @@
* use __kernel_rem_pio2()
*/
-#include "math.h"
+#include "fdlibm.h"
/*
* Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
@@ -27,12 +28,12 @@ static const int two_over_pi[] = {
#else
static int two_over_pi[] = {
#endif
- 0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, 0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7,
- 0x246E3A, 0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, 0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C,
- 0x7026B4, 0x5F7E41, 0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, 0x97FFDE, 0x05980F, 0xEF2F11,
- 0x8B5A0A, 0x6D1F6D, 0x367ECF, 0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5, 0xF17B3D, 0x0739F7,
- 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08, 0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, 0x91615E,
- 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880, 0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B,
+ 0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62, 0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7,
+ 0x246E3A, 0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129, 0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C,
+ 0x7026B4, 0x5F7E41, 0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8, 0x97FFDE, 0x05980F, 0xEF2F11,
+ 0x8B5A0A, 0x6D1F6D, 0x367ECF, 0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5, 0xF17B3D, 0x0739F7,
+ 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08, 0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3, 0x91615E,
+ 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880, 0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B,
};
#ifdef __STDC__
@@ -40,9 +41,10 @@ static const int npio2_hw[] = {
#else
static int npio2_hw[] = {
#endif
- 0x3FF921FB, 0x400921FB, 0x4012D97C, 0x401921FB, 0x401F6A7A, 0x4022D97C, 0x4025FDBB, 0x402921FB, 0x402C463A, 0x402F6A7A, 0x4031475C,
- 0x4032D97C, 0x40346B9C, 0x4035FDBB, 0x40378FDB, 0x403921FB, 0x403AB41B, 0x403C463A, 0x403DD85A, 0x403F6A7A, 0x40407E4C, 0x4041475C,
- 0x4042106C, 0x4042D97C, 0x4043A28C, 0x40446B9C, 0x404534AC, 0x4045FDBB, 0x4046C6CB, 0x40478FDB, 0x404858EB, 0x404921FB,
+ 0x3FF921FB, 0x400921FB, 0x4012D97C, 0x401921FB, 0x401F6A7A, 0x4022D97C, 0x4025FDBB, 0x402921FB,
+ 0x402C463A, 0x402F6A7A, 0x4031475C, 0x4032D97C, 0x40346B9C, 0x4035FDBB, 0x40378FDB, 0x403921FB,
+ 0x403AB41B, 0x403C463A, 0x403DD85A, 0x403F6A7A, 0x40407E4C, 0x4041475C, 0x4042106C, 0x4042D97C,
+ 0x4043A28C, 0x40446B9C, 0x404534AC, 0x4045FDBB, 0x4046C6CB, 0x40478FDB, 0x404858EB, 0x404921FB,
};
/*
@@ -60,120 +62,128 @@ static const double
#else
static double
#endif
- zero
- = 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
- half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
- two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
+ zero = 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
+ half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
+ two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
invpio2 = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
- pio2_1 = 1.57079632673412561417e+00, /* 0x3FF921FB, 0x54400000 */
+ pio2_1 = 1.57079632673412561417e+00, /* 0x3FF921FB, 0x54400000 */
pio2_1t = 6.07710050650619224932e-11, /* 0x3DD0B461, 0x1A626331 */
- pio2_2 = 6.07710050630396597660e-11, /* 0x3DD0B461, 0x1A600000 */
+ pio2_2 = 6.07710050630396597660e-11, /* 0x3DD0B461, 0x1A600000 */
pio2_2t = 2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */
- pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */
+ pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */
pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */
#ifdef __STDC__
int __ieee754_rem_pio2(double x, double* y)
#else
-int __ieee754_rem_pio2(x, y) double x, y[];
+int __ieee754_rem_pio2(x, y)
+double x, y[];
#endif
{
- double z, w, t, r, fn;
- double tx[3];
- int e0, i, j, nx, n, ix, hx;
+ double z, w, t, r, fn;
+ double tx[3];
+ int e0, i, j, nx, n, ix, hx;
- hx = __HI(x); /* high word of x */
- ix = hx & 0x7fffffff;
- if (ix <= 0x3fe921fb) /* |x| ~<= pi/4 , no need for reduction */
- {
- y[0] = x;
- y[1] = 0;
- return 0;
- }
- if (ix < 0x4002d97c) { /* |x| < 3pi/4, special case with n=+-1 */
- if (hx > 0) {
- z = x - pio2_1;
- if (ix != 0x3ff921fb) { /* 33+53 bit pi is good enough */
- y[0] = z - pio2_1t;
- y[1] = (z - y[0]) - pio2_1t;
- } else { /* near pi/2, use 33+33+53 bit pi */
- z -= pio2_2;
- y[0] = z - pio2_2t;
- y[1] = (z - y[0]) - pio2_2t;
- }
- return 1;
- } else { /* negative x */
- z = x + pio2_1;
- if (ix != 0x3ff921fb) { /* 33+53 bit pi is good enough */
- y[0] = z + pio2_1t;
- y[1] = (z - y[0]) + pio2_1t;
- } else { /* near pi/2, use 33+33+53 bit pi */
- z += pio2_2;
- y[0] = z + pio2_2t;
- y[1] = (z - y[0]) + pio2_2t;
- }
- return -1;
- }
- }
- if (ix <= 0x413921fb) { /* |x| ~<= 2^19*(pi/2), medium size */
- t = fabs(x);
- n = (int)(t * invpio2 + half);
- fn = (double)n;
- r = t - fn * pio2_1;
- w = fn * pio2_1t; /* 1st round good to 85 bit */
- if (n < 32 && ix != npio2_hw[n - 1]) {
- y[0] = r - w; /* quick check no cancellation */
- } else {
- j = ix >> 20;
- y[0] = r - w;
- i = j - (((__HI(y[0])) >> 20) & 0x7ff);
- if (i > 16) { /* 2nd iteration needed, good to 118 */
- t = r;
- r = t - fn * pio2_2;
- w = fn * pio2_2t - ((t - r) - fn * pio2_2);
- y[0] = r - w;
- i = j - (((__HI(y[0])) >> 20) & 0x7ff);
- if (i > 49) { /* 3rd iteration need, 151 bits acc */
- t = r; /* will cover all possible cases */
- w = fn * pio2_3;
- r = t - w;
- w = fn * pio2_3t - ((t - r) - w);
- y[0] = r - w;
- }
- }
- }
- y[1] = (r - y[0]) - w;
- if (hx < 0) {
- y[0] = -y[0];
- y[1] = -y[1];
- return -n;
- } else
- return n;
- }
- /*
- * all other (large) arguments
- */
- if (ix >= 0x7ff00000) { /* x is inf or NaN */
- y[0] = y[1] = x - x;
- return 0;
- }
- /* set z = scalbn(|x|,ilogb(x)-23) */
- __LO(z) = __LO(x);
- e0 = (ix >> 20) - 1046; /* e0 = ilogb(z)-23; */
- __HI(z) = ix - (e0 << 20);
- for (i = 0; i < 2; i++) {
- tx[i] = (double)((int)(z));
- z = (z - tx[i]) * two24;
- }
- tx[2] = z;
- nx = 3;
- while (tx[nx - 1] == zero)
- nx--; /* skip zero term */
- n = __kernel_rem_pio2(tx, y, e0, nx, 2, two_over_pi);
- if (hx < 0) {
- y[0] = -y[0];
- y[1] = -y[1];
- return -n;
- }
- return n;
-} \ No newline at end of file
+ hx = __HI(x); /* high word of x */
+ ix = hx & 0x7fffffff;
+ if (ix <= 0x3fe921fb) /* |x| ~<= pi/4 , no need for reduction */
+ {
+ y[0] = x;
+ y[1] = 0;
+ return 0;
+ }
+ if (ix < 0x4002d97c) { /* |x| < 3pi/4, special case with n=+-1 */
+ if (hx > 0) {
+ z = x - pio2_1;
+ if (ix != 0x3ff921fb) { /* 33+53 bit pi is good enough */
+ y[0] = z - pio2_1t;
+ y[1] = (z - y[0]) - pio2_1t;
+ } else { /* near pi/2, use 33+33+53 bit pi */
+ z -= pio2_2;
+ y[0] = z - pio2_2t;
+ y[1] = (z - y[0]) - pio2_2t;
+ }
+ return 1;
+ } else { /* negative x */
+ z = x + pio2_1;
+ if (ix != 0x3ff921fb) { /* 33+53 bit pi is good enough */
+ y[0] = z + pio2_1t;
+ y[1] = (z - y[0]) + pio2_1t;
+ } else { /* near pi/2, use 33+33+53 bit pi */
+ z += pio2_2;
+ y[0] = z + pio2_2t;
+ y[1] = (z - y[0]) + pio2_2t;
+ }
+ return -1;
+ }
+ }
+ if (ix <= 0x413921fb) { /* |x| ~<= 2^19*(pi/2), medium size */
+ t = __fabs(x);
+ n = (int)(t * invpio2 + half);
+ fn = (double)n;
+ r = t - fn * pio2_1;
+ w = fn * pio2_1t; /* 1st round good to 85 bit */
+ if (n < 32 && ix != npio2_hw[n - 1]) {
+ y[0] = r - w; /* quick check no cancellation */
+ } else {
+ j = ix >> 20;
+ y[0] = r - w;
+ i = j - (((__HI(y[0])) >> 20) & 0x7ff);
+ if (i > 16) { /* 2nd iteration needed, good to 118 */
+ t = r;
+ #if PLATFORM_WII || PLATFORM_SHIELD
+ w = fn * pio2_2;
+ r = t - w;
+ w = fn * pio2_2t - ((t - r) - w);
+ #else
+ r = t - fn * pio2_2;
+ w = fn * pio2_2t - ((t - r) - fn * pio2_2);
+ #endif
+ y[0] = r - w;
+ i = j - (((__HI(y[0])) >> 20) & 0x7ff);
+ if (i > 49) { /* 3rd iteration need, 151 bits acc */
+ t = r; /* will cover all possible cases */
+ w = fn * pio2_3;
+ r = t - w;
+ w = fn * pio2_3t - ((t - r) - w);
+ y[0] = r - w;
+ }
+ }
+ }
+ y[1] = (r - y[0]) - w;
+ if (hx < 0) {
+ y[0] = -y[0];
+ y[1] = -y[1];
+ return -n;
+ } else {
+ return n;
+ }
+ }
+ /*
+ * all other (large) arguments
+ */
+ if (ix >= 0x7ff00000) { /* x is inf or NaN */
+ y[0] = y[1] = x - x;
+ return 0;
+ }
+ /* set z = scalbn(|x|,ilogb(x)-23) */
+ __LO(z) = __LO(x);
+ e0 = (ix >> 20) - 1046; /* e0 = ilogb(z)-23; */
+ __HI(z) = ix - (e0 << 20);
+ for (i = 0; i < 2; i++) {
+ tx[i] = (double)((int)(z));
+ z = (z - tx[i]) * two24;
+ }
+ tx[2] = z;
+ nx = 3;
+ while (tx[nx - 1] == zero) {
+ nx--; /* skip zero term */
+ }
+ n = __kernel_rem_pio2(tx, y, e0, nx, 2, two_over_pi);
+ if (hx < 0) {
+ y[0] = -y[0];
+ y[1] = -y[1];
+ return -n;
+ }
+ return n;
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_sqrt.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_sqrt.c
index 162bd7c2..19f30a61 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_sqrt.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/e_sqrt.c
@@ -81,7 +81,7 @@
*/
#include "errno.h"
-#include "math.h"
+#include <cmath>
#ifdef __STDC__
static const double one = 1.0, tiny = 1.0e-300;
@@ -458,4 +458,4 @@ B. sqrt(x) by Reciproot Iteration
(4) Special cases (see (4) of Section A).
- */ \ No newline at end of file
+ */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/k_rem_pio2.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/k_rem_pio2.c
index f77b012e..c681f5cc 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/k_rem_pio2.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/k_rem_pio2.c
@@ -349,4 +349,4 @@ recompute:
}
}
return n & 7;
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/k_tan.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/k_tan.c
index e90d19fd..2eff01e5 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/k_tan.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/k_tan.c
@@ -99,7 +99,7 @@
* = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y)))
*/
-#include "math.h"
+#include <cmath>
static const double one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
pio4 = 7.85398163397448278999e-01, /* 0x3FE921FB, 0x54442D18 */
pio4lo = 3.06161699786838301793e-17, /* 0x3C81A626, 0x33145C07 */
@@ -177,4 +177,4 @@ double __kernel_tan(double x, double y, int iy)
}
}
-// EOF k_tan.c \ No newline at end of file
+// EOF k_tan.c
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/s_ldexp.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/s_ldexp.c
index fb238872..098a7d25 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/s_ldexp.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/s_ldexp.c
@@ -11,7 +11,13 @@
* ====================================================
*/
-#include "math.h" /* for isfinite macro */
+#if PLATFORM_GCN
+#include <cmath> /* for isfinite macro */
+#else
+#include <fdlibm.h>
+#define isfinite(x) ((__fpclassifyd(x) > 2))
+#endif
+
static const double
two54
@@ -55,4 +61,4 @@ double ldexp(double x, int n)
k += 54; /* subnormal result */
__HI(x) = (hx & 0x800fffff) | (k << 20);
return x * twom54;
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_acos.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_acos.c
index a6c331a1..64aa5aaf 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_acos.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_acos.c
@@ -1,6 +1,5 @@
#include "fdlibm.h"
-/* 8036C6E0-8036C700 367020 0020+00 0/0 2/2 3/3 .text acos */
double acos(double x) {
return __ieee754_acos(x);
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_asin.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_asin.c
index 779c1e9b..80150cd8 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_asin.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_asin.c
@@ -1,6 +1,5 @@
#include "fdlibm.h"
-/* 8036C700-8036C720 367040 0020+00 0/0 2/2 0/0 .text asin */
double asin(double x) {
return __ieee754_asin(x);
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_atan2.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_atan2.c
index 8a2dd2ec..c329f4b7 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_atan2.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_atan2.c
@@ -1,6 +1,5 @@
#include "fdlibm.h"
-/* 8036C720-8036C740 367060 0020+00 0/0 6/6 0/0 .text atan2 */
double atan2(double x, double y) {
return __ieee754_atan2(x, y);
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_exp.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_exp.c
index d8768d6e..061ce96b 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_exp.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_exp.c
@@ -1,6 +1,5 @@
#include "fdlibm.h"
-/* 8036C740-8036C760 367080 0020+00 0/0 1/1 0/0 .text exp */
double exp(double x) {
return __ieee754_exp(x);
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_fmod.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_fmod.c
index fafd1f90..724c0bd2 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_fmod.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_fmod.c
@@ -1,6 +1,5 @@
#include "fdlibm.h"
-/* 8036C760-8036C780 3670A0 0020+00 0/0 8/8 0/0 .text fmod */
double fmod(double x, double y) {
return __ieee754_fmod(x, y);
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_log10.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_log10.c
new file mode 100644
index 00000000..48b21001
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_log10.c
@@ -0,0 +1,28 @@
+/* @(#)w_log10.c 1.2 95/01/04 */
+/* $Id: w_log10.c,v 1.3 2004/02/26 17:03:30 ceciliar Exp $ */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+/*
+ * wrapper log10(X)
+ */
+
+#include "fdlibm.h"
+
+#ifdef __STDC__
+ double log10(double x) /* wrapper log10 */
+#else
+ double log10(x) /* wrapper log10 */
+ double x;
+#endif
+{
+ return __ieee754_log10(x);
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_pow.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_pow.c
index dc48afa6..95235ed8 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_pow.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_pow.c
@@ -1,6 +1,10 @@
#include "fdlibm.h"
-/* 8036C780-8036C7A0 3670C0 0020+00 0/0 3/3 24/24 .text pow */
double pow(double x, double y) {
return __ieee754_pow(x, y);
-} \ No newline at end of file
+}
+
+float powf(float x, float y) {
+ // FIXME: Is this correct?
+ return __ieee754_pow(x, y);
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_sqrt.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_sqrt.c
index 7469b6ed..cb7a159f 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_sqrt.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Double_precision/w_sqrt.c
@@ -1,6 +1,5 @@
#include "fdlibm.h"
-/* 8036CA54-8036CA74 367394 0020+00 0/0 8/8 1/1 .text sqrt */
double sqrt(double x) {
return __ieee754_sqrt(x);
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Include/fdlibm.h b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Include/fdlibm.h
index 407419ba..e9f774a0 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Include/fdlibm.h
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Include/fdlibm.h
@@ -1,6 +1,8 @@
#ifndef FDLIBM_H
#define FDLIBM_H
+#include <errno.h>
+
/* @(#)fdlibm.h 1.5 04/04/22 */
/*
* ====================================================
@@ -225,4 +227,4 @@ extern int __kernel_rem_pio2 __P((double*, double*, int, int, int, const int*));
};
#endif
-#endif /* FDLIBM_H */ \ No newline at end of file
+#endif /* FDLIBM_H */
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Src/ansi_fp.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Src/ansi_fp.c
index 728100f7..e057f9ef 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Src/ansi_fp.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Src/ansi_fp.c
@@ -1,7 +1,7 @@
#include "ansi_fp.h"
#include "ansi_fp.h"
-#include "limits.h"
-#include "float.h"
+#include <climits>
+#include <cmath>
static int __count_trailing_zerol(unsigned long x) {
int result = 0;
@@ -101,6 +101,7 @@ static void __rounddec(decimal* d, int digits) {
void __ull2dec(decimal* result, unsigned long long val) {
result->sign = 0;
+ #if PLATFORM_GCN
if (val == 0) {
result->exp = 0;
result->sig.length = 1;
@@ -112,6 +113,7 @@ void __ull2dec(decimal* result, unsigned long long val) {
val = -val;
result->sign = 1;
}
+ #endif
result->sig.length = 0;
@@ -133,7 +135,6 @@ void __ull2dec(decimal* result, unsigned long long val) {
result->exp = result->sig.length - 1;
}
-/* 80364E00-80365078 35F740 0278+00 2/2 0/0 0/0 .text __timesdec */
void __timesdec(decimal* result, const decimal* x, const decimal* y) {
unsigned long accumulator = 0;
unsigned char mantissa[SIGDIGLEN * 2];
@@ -235,7 +236,6 @@ void __str2dec(decimal* d, const char* s, short exp) {
static const char* const unused = "179769313486231580793729011405303420";
-/* 8036367C-80364E00 35DFBC 1784+00 2/1 0/0 0/0 .text __two_exp */
void __two_exp(decimal* result, long exp) {
switch (exp) {
case -64:
@@ -347,6 +347,7 @@ int __equals_dec(const decimal* x, const decimal* y) {
}
}
+ #if PLATFORM_GCN
if (l == x->sig.length) {
for (; i < y->sig.length; ++i) {
if (y->sig.text[i] != 0) {
@@ -360,6 +361,17 @@ int __equals_dec(const decimal* x, const decimal* y) {
}
}
}
+ #else
+ if (l == x->sig.length) {
+ x = y;
+ }
+
+ for (; i < x->sig.length; ++i) {
+ if (x->sig.text[i] != 0) {
+ return 0;
+ }
+ }
+ #endif
return 1;
}
@@ -506,7 +518,6 @@ done:
z->sig.length = (unsigned char)(i - ib + 1);
}
-/* 803632C8-8036367C 35DC08 03B4+00 1/1 0/0 0/0 .text __num2dec_internal */
void __num2dec_internal(decimal* d, double x) {
signed char sign = (signed char)(signbit(x) != 0);
@@ -522,7 +533,7 @@ void __num2dec_internal(decimal* d, double x) {
d->sign = sign;
d->exp = 0;
d->sig.length = 1;
- d->sig.text[0] = fpclassify(x) == 1 ? 'N' : 'I';
+ d->sig.text[0] = isnan(x)? 'N' : 'I';
return;
}
@@ -545,7 +556,6 @@ void __num2dec_internal(decimal* d, double x) {
}
}
-/* 80363124-803632C8 35DA64 01A4+00 0/0 2/2 0/0 .text __num2dec */
void __num2dec(const decform* form, double x, decimal* d) {
short digits = form->digits;
int i;
@@ -567,7 +577,157 @@ void __num2dec(const decform* form, double x, decimal* d) {
d->exp -= d->sig.length - 1;
- for (i = 0; i < d->sig.length; i++) {
+ for (i = 0; i < d->sig.length; ++i) {
d->sig.text[i] += '0';
}
-} \ No newline at end of file
+}
+
+#if !PLATFORM_GCN
+double __dec2num(const decimal* d) {
+ if (d->sig.length <= 0) {
+ return copysign(0.0, d->sign == 0 ? 1.0 : -1.0);
+ }
+
+ switch (d->sig.text[0]) {
+ case '0':
+ return copysign(0.0, d->sign == 0 ? 1.0 : -1.0);
+ case 'I':
+ return copysign((double)HUGE_VALF, d->sign == 0 ? 1.0 : -1.0);
+ case 'N': {
+ double result;
+ unsigned long long* ll = (unsigned long long*)&result;
+
+ *ll = 0x7FF0000000000000;
+ if (d->sign)
+ *ll |= 0x8000000000000000;
+ *ll |= 0x8000000000000;
+
+ return result;
+ }
+ }
+
+ {
+ static double pow_10[8] = {1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8};
+
+ decimal dec = *d;
+ unsigned char* i = dec.sig.text;
+ unsigned char* e = i + dec.sig.length;
+ double first_guess;
+ int exponent;
+
+ for (; i < e; ++i)
+ *i -= '0';
+ dec.exp += dec.sig.length - 1;
+ exponent = dec.exp;
+
+ {
+ decimal max;
+
+ __str2dec(&max, "179769313486231580793728714053034151", 308);
+ if (__less_dec(&max, &dec)) {
+ return copysign((double)HUGE_VALF, d->sign == 0 ? 1.0 : -1.0);
+ }
+ }
+
+ i = dec.sig.text;
+ first_guess = *i++;
+
+ while (i < e) {
+ unsigned long ival = 0;
+ int j;
+ double temp1, temp2;
+ int ndig = (int)(e - i) % 8;
+
+ if (ndig == 0)
+ ndig = 8;
+
+ for (j = 0; j < ndig; ++j, ++i) {
+ ival = ival * 10 + *i;
+ }
+
+ temp1 = first_guess * pow_10[ndig - 1];
+ temp2 = temp1 + ival;
+
+ if (ival != 0 && temp1 == temp2)
+ break;
+
+ first_guess = temp2;
+ exponent -= ndig;
+ }
+
+ if (exponent < 0) {
+ first_guess /= pow(5.0, -exponent);
+ } else {
+ first_guess *= pow(5.0, exponent);
+ }
+
+ first_guess = ldexp(first_guess, exponent);
+
+ if (fpclassify(first_guess) == 2) {
+ first_guess = LDBL_MAX;
+ }
+
+ {
+ decimal feedback1, feedback2, difflow, diffhigh;
+ double next_guess;
+ unsigned long long* ull = (unsigned long long*)&next_guess;
+ int guessed_low = 0;
+
+ __num2dec_internal(&feedback1, first_guess);
+
+ if (__equals_dec(&feedback1, &dec)) {
+ goto done;
+ }
+ if (__less_dec(&feedback1, &dec)) {
+ guessed_low = 1;
+ }
+
+ next_guess = first_guess;
+
+ while (1) {
+ if (guessed_low) {
+ ++*ull;
+ if (fpclassify(next_guess) == 2) {
+ goto done;
+ }
+ } else {
+ --*ull;
+ }
+
+ __num2dec_internal(&feedback2, next_guess);
+ if (guessed_low && !__less_dec(&feedback2, &dec)) {
+ break;
+ } else if (!guessed_low && !__less_dec(&dec, &feedback2)) {
+ difflow = feedback1;
+ feedback1 = feedback2;
+ feedback2 = difflow;
+ {
+ double temp = first_guess;
+ first_guess = next_guess;
+ next_guess = temp;
+ }
+ break;
+ }
+ feedback1 = feedback2;
+ first_guess = next_guess;
+ }
+
+ __minus_dec(&difflow, &dec, &feedback1);
+ __minus_dec(&diffhigh, &feedback2, &dec);
+
+ if (__equals_dec(&difflow, &diffhigh)) {
+ if (*(unsigned long long*)&first_guess & 1) {
+ first_guess = next_guess;
+ }
+ } else if (!__less_dec(&difflow, &diffhigh)) {
+ first_guess = next_guess;
+ }
+ }
+ done:
+ if (dec.sign) {
+ first_guess = -first_guess;
+ }
+ return first_guess;
+ }
+}
+#endif
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Src/math_sun.c b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Src/math_sun.c
new file mode 100644
index 00000000..68722043
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Src/math_sun.c
@@ -0,0 +1,13 @@
+#include <cmath>
+
+double scalbn(double x, int n) {
+ double mant;
+ int exp;
+ double result;
+
+ mant = frexp(x, &exp);
+ exp += n;
+ result = ldexp(mant, exp);
+
+ return result;
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/abort_exit_ppc_eabi.c b/src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/abort_exit_ppc_eabi.c
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/abort_exit_ppc_eabi.c
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/critical_regions.gamecube.c b/src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/critical_regions.gamecube.c
index bb9b68f1..63e7894c 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/critical_regions.gamecube.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/critical_regions.gamecube.c
@@ -1,10 +1,7 @@
#include "critical_regions.gamecube.h"
-/* 8036546C-80365470 35FDAC 0004+00 0/0 2/2 0/0 .text __kill_critical_regions */
void __kill_critical_regions() {}
-/* 80365468-8036546C 35FDA8 0004+00 0/0 12/12 0/0 .text __begin_critical_region */
void __begin_critical_region() {}
-/* 80365464-80365468 35FDA4 0004+00 0/0 12/12 0/0 .text __end_critical_region */
-void __end_critical_region() {} \ No newline at end of file
+void __end_critical_region() {}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/math_ppc.c b/src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/math_ppc.c
index db002e0a..05f574a3 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/math_ppc.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/math_ppc.c
@@ -1,22 +1,33 @@
#include "math_ppc.h"
#include "fdlibm.h"
-/* 8036CA30-8036CA54 367370 0024+00 0/0 1/1 0/0 .text acosf */
-__declspec(weak) float acosf(float x) {
+// TODO: where should this go?
+#ifndef DECL_WEAK
+#if defined(__MWERKS__)
+#define DECL_WEAK __declspec(weak)
+#elif defined(__GNUC__)
+#define DECL_WEAK __attribute__((weak))
+#elif defined(_MSC_VER)
+#define DECL_WEAK
+#else
+#error unknown compiler
+#endif
+#endif
+
+double nan(const char* arg) {}
+
+DECL_WEAK float acosf(float x) {
return acos(x);
}
-/* 8036CA0C-8036CA30 36734C 0024+00 0/0 4/4 0/0 .text cosf */
-__declspec(weak) float cosf(float x) {
+DECL_WEAK float cosf(float x) {
return cos(x);
}
-/* 8036C9E8-8036CA0C 367328 0024+00 0/0 4/4 0/0 .text sinf */
-__declspec(weak) float sinf(float x) {
+DECL_WEAK float sinf(float x) {
return sin(x);
}
-/* 8036C9C4-8036C9E8 367304 0024+00 0/0 2/2 0/0 .text tanf */
-__declspec(weak) float tanf(float x) {
+DECL_WEAK float tanf(float x) {
return tan(x);
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/uart_console_io_gcn.c b/src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/uart_console_io_gcn.c
index c6a405ea..825a39b3 100644
--- a/src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/uart_console_io_gcn.c
+++ b/src/PowerPC_EABI_Support/MSL/MSL_C/PPC_EABI/Src/uart_console_io_gcn.c
@@ -1,12 +1,11 @@
#include "uart_console_io_gcn.h"
-#include "rvl/os.h"
+#include <rvl/OS.h>
int InitializeUART(size_t);
int WriteUARTN(unsigned char*, size_t);
int __TRK_write_console(__file_handle handle, unsigned char* buffer, size_t* count,
__idle_proc idle_fn);
-/* 803691A4-80369274 363AE4 00D0+00 0/0 1/0 0/0 .text __write_console */
int __write_console(__file_handle handle, unsigned char* buffer, size_t* count,
__idle_proc idle_fn) {
static int initialized;
@@ -35,7 +34,6 @@ int __write_console(__file_handle handle, unsigned char* buffer, size_t* count,
return 0;
}
-/* 8036919C-803691A4 363ADC 0008+00 0/0 1/0 0/0 .text __close_console */
int __close_console(__file_handle handle) {
return 0;
}
diff --git a/src/PowerPC_EABI_Support/MetroTRK/trk.h b/src/PowerPC_EABI_Support/MetroTRK/trk.h
index d8fb5bc7..a8318922 100644
--- a/src/PowerPC_EABI_Support/MetroTRK/trk.h
+++ b/src/PowerPC_EABI_Support/MetroTRK/trk.h
@@ -1,7 +1,7 @@
#ifndef __METROTRK_TRK_H__
#define __METROTRK_TRK_H__
-#include "dolphin/types.h"
+#include <types.h>
#ifdef __cplusplus
extern "C" {
@@ -375,4 +375,4 @@ void TRKSaveExtended1Block();
}
#endif
-#endif /* __METROTRK_TRK_H__ */ \ No newline at end of file
+#endif /* __METROTRK_TRK_H__ */
diff --git a/src/PowerPC_EABI_Support/Runtime/Inc/CPlusLibPPC.h b/src/PowerPC_EABI_Support/Runtime/Inc/CPlusLibPPC.h
index a4d189fe..28a45130 100644
--- a/src/PowerPC_EABI_Support/Runtime/Inc/CPlusLibPPC.h
+++ b/src/PowerPC_EABI_Support/Runtime/Inc/CPlusLibPPC.h
@@ -1,6 +1,6 @@
#ifndef CPLUSLIBPPC_H
#define CPLUSLIBPPC_H
-#include "common.h"
+#include <types.h>
#endif /* CPLUSLIBPPC_H */
diff --git a/src/PowerPC_EABI_Support/Runtime/Inc/MWCPlusLib.h b/src/PowerPC_EABI_Support/Runtime/Inc/MWCPlusLib.h
index 7ec6b8f7..a5542f9c 100644
--- a/src/PowerPC_EABI_Support/Runtime/Inc/MWCPlusLib.h
+++ b/src/PowerPC_EABI_Support/Runtime/Inc/MWCPlusLib.h
@@ -1,7 +1,7 @@
#ifndef MWCPLUSLIB_H
#define MWCPLUSLIB_H
-#include <stddef.h>
+#include <cstddef>
#ifdef __cplusplus
extern "C" {
diff --git a/src/PowerPC_EABI_Support/Runtime/Inc/NMWException.h b/src/PowerPC_EABI_Support/Runtime/Inc/NMWException.h
index 8f85b527..8ac4c589 100644
--- a/src/PowerPC_EABI_Support/Runtime/Inc/NMWException.h
+++ b/src/PowerPC_EABI_Support/Runtime/Inc/NMWException.h
@@ -7,17 +7,18 @@
extern "C" {
#endif
-#define DTORCALL(dtor, objptr) (((void (*)(void *, int))dtor)(objptr, -1))
+typedef short vbase_ctor_arg_type;
+typedef char local_cond_type;
typedef struct DestructorChain {
- struct DestructorChain *next;
- void *destructor;
- void *object;
+ struct DestructorChain* next;
+ void* destructor;
+ void* object;
} DestructorChain;
void __unregister_fragment(int fragmentID);
-int __register_fragment(struct __eti_init_info *info, char *TOC);
-void *__register_global_object(void *object, void *destructor, void *regmem);
+int __register_fragment(struct __eti_init_info* info, char* TOC);
+void* __register_global_object(void* object, void* destructor, void* regmem);
void __destroy_global_chain(void);
#ifdef __cplusplus
diff --git a/src/PowerPC_EABI_Support/Runtime/Inc/__mem.h b/src/PowerPC_EABI_Support/Runtime/Inc/__mem.h
deleted file mode 100644
index ab53e58f..00000000
--- a/src/PowerPC_EABI_Support/Runtime/Inc/__mem.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef RUNTIME_MEM_H
-#define RUNTIME_MEM_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-__declspec(section ".init") void* memcpy(void* dest, const void* src, size_t n);
-__declspec(section ".init") void __fill_mem(void* dest, int val, size_t count);
-__declspec(section ".init") void* memset(void* dest, int val, size_t count);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* RUNTIME_MEM_H */
diff --git a/src/PowerPC_EABI_Support/Runtime/Inc/ptmf.h b/src/PowerPC_EABI_Support/Runtime/Inc/ptmf.h
index 7ce2ad4c..ef143c94 100644
--- a/src/PowerPC_EABI_Support/Runtime/Inc/ptmf.h
+++ b/src/PowerPC_EABI_Support/Runtime/Inc/ptmf.h
@@ -2,12 +2,12 @@
#define PTMF_H
typedef struct __ptmf {
- long this_delta; // self-explanatory
- long v_offset; // vtable offset
- union {
- void *f_addr; // function address
- long ve_offset; // virtual function entry offset (of vtable)
- } f_data;
+ long this_delta; // self-explanatory
+ long v_offset; // vtable offset
+ union {
+ void* f_addr; // function address
+ long ve_offset; // virtual function entry offset (of vtable)
+ } f_data;
} __ptmf;
-#endif /* PTMF_H */
+#endif /* PTMF_H */ \ No newline at end of file
diff --git a/src/PowerPC_EABI_Support/Runtime/Inc/runtime.h b/src/PowerPC_EABI_Support/Runtime/Inc/runtime.h
index de5b358e..5d2ba1cc 100644
--- a/src/PowerPC_EABI_Support/Runtime/Inc/runtime.h
+++ b/src/PowerPC_EABI_Support/Runtime/Inc/runtime.h
@@ -1,6 +1,6 @@
#ifndef RUNTIME_H
#define RUNTIME_H
-#include "common.h"
+#include <types.h>
#endif /* RUNTIME_H */
diff --git a/src/PowerPC_EABI_Support/Runtime/Src/CPlusLibPPC.cp b/src/PowerPC_EABI_Support/Runtime/Src/CPlusLibPPC.cp
index 0b98e496..d05c8c3b 100644
--- a/src/PowerPC_EABI_Support/Runtime/Src/CPlusLibPPC.cp
+++ b/src/PowerPC_EABI_Support/Runtime/Src/CPlusLibPPC.cp
@@ -1,6 +1,5 @@
#include "CPlusLibPPC.h"
-/* 80361C3C-80361C6C 35C57C 0030+00 0/0 0/0 4/4 .text __copy */
extern "C" void* __copy(char *dest, char *src, size_t size) {
char *p;
@@ -15,4 +14,4 @@ extern "C" void* __copy(char *dest, char *src, size_t size) {
}
return(dest);
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/Runtime/Src/GCN_Mem_Alloc.c b/src/PowerPC_EABI_Support/Runtime/Src/GCN_Mem_Alloc.c
index d4e5ac25..fd8e9ec7 100644
--- a/src/PowerPC_EABI_Support/Runtime/Src/GCN_Mem_Alloc.c
+++ b/src/PowerPC_EABI_Support/Runtime/Src/GCN_Mem_Alloc.c
@@ -1,9 +1,9 @@
/**
- * GCN_Mem_Alloc.c
+ * GCN_mem_alloc.c
* Description:
*/
-#include "RVL/OS.h"
+#include <rvl/OS.h>
inline static void InitDefaultHeap(void) {
void* arenaLo;
@@ -25,7 +25,6 @@ inline static void InitDefaultHeap(void) {
OSSetArenaLo(arenaLo = arenaHi);
}
-/* 80362914-803629CC 35D254 00B8+00 0/0 1/1 0/0 .text __sys_free */
void __sys_free(void* p) {
if (__OSCurrHeap == -1) {
InitDefaultHeap();
diff --git a/src/PowerPC_EABI_Support/Runtime/Src/Gecko_ExceptionPPC.cp b/src/PowerPC_EABI_Support/Runtime/Src/Gecko_ExceptionPPC.cp
index 5e535efe..aaef53c5 100644
--- a/src/PowerPC_EABI_Support/Runtime/Src/Gecko_ExceptionPPC.cp
+++ b/src/PowerPC_EABI_Support/Runtime/Src/Gecko_ExceptionPPC.cp
@@ -11,10 +11,8 @@ typedef struct ProcessInfo {
int active;
} ProcessInfo;
-/* 8044D430-8044D440 07A150 000C+04 2/2 0/0 0/0 .bss fragmentinfo */
static ProcessInfo fragmentinfo[1];
-/* 803628E0-80362914 35D220 0034+00 0/0 1/1 0/0 .text __register_fragment */
int __register_fragment(struct __eti_init_info* info, char* TOC) {
ProcessInfo* f;
int i;
@@ -31,7 +29,6 @@ int __register_fragment(struct __eti_init_info* info, char* TOC) {
return -1;
}
-/* 803628AC-803628E0 35D1EC 0034+00 0/0 1/1 0/0 .text __unregister_fragment */
void __unregister_fragment(int fragmentId) {
ProcessInfo* f;
if (fragmentId >= 0 && fragmentId < 1) {
@@ -40,4 +37,4 @@ void __unregister_fragment(int fragmentId) {
f->TOC = 0;
f->active = 0;
}
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/Runtime/Src/__mem.c b/src/PowerPC_EABI_Support/Runtime/Src/__mem.c
index 4d958060..298a79be 100644
--- a/src/PowerPC_EABI_Support/Runtime/Src/__mem.c
+++ b/src/PowerPC_EABI_Support/Runtime/Src/__mem.c
@@ -1,6 +1,6 @@
-#include "stddef.h"
+#include <stddef.h>
-void* memcpy(void* dst, const void* src, size_t n) {
+__declspec(section ".init") void* memcpy(void* dst, const void* src, size_t n) {
const unsigned char* s;
unsigned char* d;
@@ -20,7 +20,7 @@ void* memcpy(void* dst, const void* src, size_t n) {
return dst;
}
-void __fill_mem(void* dst, int val, size_t n) {
+__declspec(section ".init") void __fill_mem(void* dst, int val, size_t n) {
unsigned long v = (unsigned char)val;
unsigned long i;
@@ -78,7 +78,7 @@ void __fill_mem(void* dst, int val, size_t n) {
return;
}
-void* memset(void* dst, int val, size_t n) {
+__declspec(section ".init") void* memset(void* dst, int val, size_t n) {
__fill_mem(dst, val, n);
return dst;
diff --git a/src/PowerPC_EABI_Support/Runtime/Src/__va_arg.c b/src/PowerPC_EABI_Support/Runtime/Src/__va_arg.c
index fbc9eaaa..4ad6a4e6 100644
--- a/src/PowerPC_EABI_Support/Runtime/Src/__va_arg.c
+++ b/src/PowerPC_EABI_Support/Runtime/Src/__va_arg.c
@@ -1,8 +1,8 @@
-#include "__va_arg.h"
+#include <cstdarg>
+#include <cstdint>
#undef __va_arg
-/* 80361B14-80361BDC 35C454 00C8+00 0/0 3/3 0/0 .text __va_arg */
void* __va_arg(_va_list_struct* list, int type) {
char* addr;
char* reg = &(list->gpr);
@@ -38,7 +38,7 @@ void* __va_arg(_va_list_struct* list, int type) {
} else {
*reg = 8;
addr = list->input_arg_area;
- addr = (char*)(((unsigned int)(addr) + ((size)-1)) & ~((size)-1));
+ addr = (char*)(((uintptr_t)(addr) + ((size)-1)) & ~((size)-1));
list->input_arg_area = addr + size;
}
diff --git a/src/PowerPC_EABI_Support/Runtime/Src/global_destructor_chain.c b/src/PowerPC_EABI_Support/Runtime/Src/global_destructor_chain.c
index 45e5115d..7481b300 100644
--- a/src/PowerPC_EABI_Support/Runtime/Src/global_destructor_chain.c
+++ b/src/PowerPC_EABI_Support/Runtime/Src/global_destructor_chain.c
@@ -1,3 +1,4 @@
+#include "MWCPlusLib.h"
#include "NMWException.h"
DestructorChain *__global_destructor_chain;
@@ -14,7 +15,7 @@ void __destroy_global_chain(void) {
DestructorChain *iter;
while ((iter = __global_destructor_chain) != 0) {
__global_destructor_chain = iter->next;
- DTORCALL(iter->destructor, iter->object);
+ DTORCALL_COMPLETE(iter->destructor, iter->object);
}
}
diff --git a/src/PowerPC_EABI_Support/Runtime/Src/ptmf.c b/src/PowerPC_EABI_Support/Runtime/Src/ptmf.c
index 11d05929..fabb78df 100644
--- a/src/PowerPC_EABI_Support/Runtime/Src/ptmf.c
+++ b/src/PowerPC_EABI_Support/Runtime/Src/ptmf.c
@@ -1,14 +1,11 @@
#include "ptmf.h"
-/* ############################################################################################## */
-/* 803A2180-803A2190 02E7E0 000C+04 0/0 23/23 249/249 .rodata __ptmf_null */
__ptmf const __ptmf_null = {
0,
0,
0,
};
-/* 80362018-80362048 35C958 0030+00 0/0 10/10 345/345 .text __ptmf_test */
asm long __ptmf_test(register __ptmf* ptmf) {
// clang-format off
nofralloc
@@ -28,7 +25,6 @@ asm long __ptmf_test(register __ptmf* ptmf) {
// clang-format on
}
-/* 80362048-80362084 35C988 003C+00 0/0 0/0 217/217 .text __ptmf_cmpr */
asm long __ptmf_cmpr(void) {
// clang-format off
nofralloc
@@ -51,7 +47,6 @@ asm long __ptmf_cmpr(void) {
// clang-format on
}
-/* 80362084-803620AC 35C9C4 0028+00 0/0 125/125 741/741 .text __ptmf_scall */
asm void __ptmf_scall(...) {
// clang-format off
nofralloc
@@ -70,4 +65,4 @@ lbl_803620A4:
mtctr r12
bctr
// clang-format on
-} \ No newline at end of file
+}
diff --git a/src/PowerPC_EABI_Support/Runtime/Src/runtime.c b/src/PowerPC_EABI_Support/Runtime/Src/runtime.c
index a3ba7f1e..5c4c1a33 100644
--- a/src/PowerPC_EABI_Support/Runtime/Src/runtime.c
+++ b/src/PowerPC_EABI_Support/Runtime/Src/runtime.c
@@ -5,14 +5,14 @@ extern "C" {
#endif
/* macros for GPR/FPR resting and saving */
-#define SAVE_FPR(reg) _savefpr_##reg
+#define SAVE_FPR(reg) _savefpr_##reg
#define RESTORE_FPR(reg) _restfpr_##reg
-#define SAVE_GPR(reg) _savegpr_##reg
+#define SAVE_GPR(reg) _savegpr_##reg
#define RESTORE_GPR(reg) _restgpr_##reg
-#define ENTRY_SAVE_FPR(reg) entry SAVE_FPR(reg)
+#define ENTRY_SAVE_FPR(reg) entry SAVE_FPR(reg)
#define ENTRY_RESTORE_FPR(reg) entry RESTORE_FPR(reg)
-#define ENTRY_SAVE_GPR(reg) entry SAVE_GPR(reg)
+#define ENTRY_SAVE_GPR(reg) entry SAVE_GPR(reg)
#define ENTRY_RESTORE_GPR(reg) entry RESTORE_GPR(reg)
#define save_restore_reg r11
@@ -103,11 +103,13 @@ void RESTORE_GPR(30)(void);
void RESTORE_GPR(31)(void);
static const u32 __constants[] = {
- 0x00000000, 0x00000000, 0x41F00000, 0x00000000, 0x41E00000, 0x00000000,
+ 0x00000000, 0x00000000, 0x41F00000, 0x00000000, 0x41E00000, 0x00000000,
};
-/* 803620AC-80362108 35C9EC 005C+00 0/0 42/42 89/89 .text __cvt_fp2unsigned */
-asm u32 __cvt_fp2unsigned(register f64 d) {
+#define __REGISTER register
+
+asm u32 __cvt_fp2unsigned(__REGISTER f64 d)
+{
#ifdef __MWERKS__ // clang-format off
nofralloc
stwu r1,-16(r1)
@@ -137,7 +139,6 @@ asm u32 __cvt_fp2unsigned(register f64 d) {
#endif // clang-format on
}
-/* 80362108-80362134 35CA48 002C+00 0/0 0/0 0/0 .text __save_fpr */
asm static void __save_fpr(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
@@ -181,7 +182,6 @@ asm static void __save_fpr(void) {
#endif // clang-format on
}
-/* 80362154-80362180 35CA94 002C+00 0/0 0/0 0/0 .text __restore_fpr */
asm static void __restore_fpr(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
@@ -225,7 +225,6 @@ asm static void __restore_fpr(void) {
#endif // clang-format on
}
-/* 803621A0-803621A4 35CAE0 0004+00 0/0 22/22 13/13 .text _savegpr_14 */
asm static void __save_gpr(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
@@ -269,7 +268,6 @@ asm static void __save_gpr(void) {
#endif // clang-format on
}
-/* 803621EC-803621F0 35CB2C 0004+00 0/0 22/22 13/13 .text _restgpr_14 */
asm static void __restore_gpr(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
@@ -313,7 +311,6 @@ asm static void __restore_gpr(void) {
#endif // clang-format on
}
-/* 80362238-80362324 35CB78 00EC+00 0/0 2/2 0/0 .text __div2u */
asm void __div2u(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
@@ -388,7 +385,6 @@ lab9:
#endif // clang-format on
}
-/* 80362324-8036245C 35CC64 0138+00 0/0 16/16 1/1 .text __div2i */
asm void __div2i(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
@@ -488,7 +484,6 @@ func_end:
#endif // clang-format on
}
-/* 8036245C-80362540 35CD9C 00E4+00 0/0 2/2 0/0 .text __mod2u */
asm void __mod2u(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
@@ -561,7 +556,6 @@ lab9:
#endif // clang-format on
}
-/* 80362540-8036264C 35CE80 010C+00 0/0 2/2 0/0 .text __mod2i */
asm void __mod2i(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
@@ -648,7 +642,6 @@ no_adjust:
#endif // clang-format on
}
-/* 8036264C-80362670 35CF8C 0024+00 0/0 2/2 0/0 .text __shl2i */
asm void __shl2i(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
@@ -664,7 +657,6 @@ asm void __shl2i(void) {
#endif // clang-format on
}
-/* 80362670-80362694 35CFB0 0024+00 0/0 2/2 0/0 .text __shr2u */
asm void __shr2u(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
@@ -680,7 +672,6 @@ asm void __shr2u(void) {
#endif // clang-format on
}
-/* 80362694-803626BC 35CFD4 0028+00 0/0 3/3 0/0 .text __shr2i */
asm void __shr2i(void) {
#ifdef __MWERKS__ // clang-format off
nofralloc
@@ -698,8 +689,8 @@ around:
#endif // clang-format on
}
-/* 803626BC-80362770 35CFFC 00B4+00 0/0 1/1 0/0 .text __cvt_sll_flt */
-asm void __cvt_sll_flt(void) {
+asm void __cvt_sll_flt(void)
+{
#ifdef __MWERKS__ // clang-format off
nofralloc
stwu r1, -0x10(r1)
@@ -754,8 +745,8 @@ lbl_80362758:
#endif // clang-format on
}
-/* 80362770-8036283C 35D0B0 00CC+00 0/0 2/2 0/0 .text __cvt_dbl_usll */
-asm void __cvt_dbl_usll(void) {
+asm void __cvt_dbl_usll(void)
+{
#ifdef __MWERKS__ // clang-format off
nofralloc
stwu r1,-16(r1)
diff --git a/src/REL/d/a/e/d_a_e_sm.cpp b/src/REL/d/a/e/d_a_e_sm.cpp
index 11c7d558..f63d96b7 100644
--- a/src/REL/d/a/e/d_a_e_sm.cpp
+++ b/src/REL/d/a/e/d_a_e_sm.cpp
@@ -41,7 +41,7 @@
#include "toBeSorted/d_emitter.h"
#include "toBeSorted/time_area_mgr.h"
-#include <cmath.h>
+#include <cmath>
SPECIAL_ACTOR_PROFILE(E_SM, dAcEsm_c, fProfile::E_SM, 0xEB, 0, 4098);
diff --git a/src/d/col/c/c_m3d.cpp b/src/d/col/c/c_m3d.cpp
index f69a11a7..4ac33b5a 100644
--- a/src/d/col/c/c_m3d.cpp
+++ b/src/d/col/c/c_m3d.cpp
@@ -11,7 +11,6 @@
#include "d/col/c/c_m3d_g_unk.h"
#include "egg/math/eggMath.h"
#include "m/m_vec.h"
-#include "math.h"
#include "nw4r/math/math_types.h"
#include "rvl/MTX.h" // IWYU pragma: export
#include "rvl/MTX/vec.h"
diff --git a/src/d/d_light_env.cpp b/src/d/d_light_env.cpp
index ac52b039..025d934f 100644
--- a/src/d/d_light_env.cpp
+++ b/src/d/d_light_env.cpp
@@ -46,9 +46,9 @@ void dLightEnv_c::sphere_to_cartesian(f32 angY, f32 angXZ, mVec3_c *pOut) {
f32 radXZ = angXZ / (180.f / M_PI);
mVec3_c pos;
- pos.x = std::cosf(radY) * std::sinf(radXZ);
- pos.y = std::sinf(radY);
- pos.z = std::cosf(radY) * std::cosf(radXZ);
+ pos.x = std::cos(radY) * std::sin(radXZ);
+ pos.y = std::sin(radY);
+ pos.z = std::cos(radY) * std::cos(radXZ);
pOut->x = pos.x;
pOut->y = pos.y;
diff --git a/src/d/d_message.cpp b/src/d/d_message.cpp
index 5a1e703e..d4b97316 100644
--- a/src/d/d_message.cpp
+++ b/src/d/d_message.cpp
@@ -48,6 +48,7 @@
#include <cstring>
#include <stdio.h>
+#include <stdlib.h>
s32 dFlow_c::sExitId = -1;
diff --git a/src/d/d_pad.cpp b/src/d/d_pad.cpp
index c49a6f0d..58f2113d 100644
--- a/src/d/d_pad.cpp
+++ b/src/d/d_pad.cpp
@@ -850,7 +850,7 @@ void ex_c::acc_c::fn_800576D0(s32 chan) {
f32 f = acc.dot(dir);
if (!cM3d_IsZero(cross.squaredLength())) {
cross.normalize();
- f32 acos = std::acosf(f);
+ f32 acos = std::acos(f);
MTXRotAxisRad(field_0x1098, cross, acos);
// TODO - bad part end
} else {
diff --git a/src/d/lyt/d_lyt_deposit.cpp b/src/d/lyt/d_lyt_deposit.cpp
index 37fbd33b..87996ddc 100644
--- a/src/d/lyt/d_lyt_deposit.cpp
+++ b/src/d/lyt/d_lyt_deposit.cpp
@@ -37,7 +37,7 @@
#include "toBeSorted/arc_managers/layout_arc_manager.h"
#include "toBeSorted/file_manager.h"
-#include <cwchar>
+#include <cstddef>
struct DepositSellValues {
/* 0x00 */ u8 itemId;
diff --git a/src/d/lyt/d_lyt_pause_disp_00.cpp b/src/d/lyt/d_lyt_pause_disp_00.cpp
index 97f09055..bf72820a 100644
--- a/src/d/lyt/d_lyt_pause_disp_00.cpp
+++ b/src/d/lyt/d_lyt_pause_disp_00.cpp
@@ -27,7 +27,7 @@
#include "sized_string.h"
#include "toBeSorted/counters/counter.h"
-#include <limits.h>
+#include <climits>
STATE_DEFINE(dLytPauseDisp00_c, None);
STATE_DEFINE(dLytPauseDisp00_c, In);
diff --git a/src/d/lyt/d_lyt_shop.cpp b/src/d/lyt/d_lyt_shop.cpp
index 01afc3ee..66fd2d67 100644
--- a/src/d/lyt/d_lyt_shop.cpp
+++ b/src/d/lyt/d_lyt_shop.cpp
@@ -32,7 +32,7 @@
#include "toBeSorted/arc_managers/layout_arc_manager.h"
#include "toBeSorted/counters/counter.h"
-#include <cwchar>
+#include <cstddef>
struct ShopUpgradeItemData {
/* 0x0 */ s32 itemId;
diff --git a/src/egg/gfx/eggDrawGX.cpp b/src/egg/gfx/eggDrawGX.cpp
index b0ddc2e5..c428ac4a 100644
--- a/src/egg/gfx/eggDrawGX.cpp
+++ b/src/egg/gfx/eggDrawGX.cpp
@@ -3,7 +3,6 @@
#include "common.h"
#include "egg/gfx/eggGXUtility.h"
#include "egg/gfx/eggStateGX.h"
-#include "math.h"
#include "nw4r/g3d/res/g3d_restex.h"
#include "nw4r/math/math_triangular.h"
#include "nw4r/math/math_types.h"
diff --git a/src/egg/gfx/eggPostEffectBase.cpp b/src/egg/gfx/eggPostEffectBase.cpp
index 4627caad..5d8e1fc9 100644
--- a/src/egg/gfx/eggPostEffectBase.cpp
+++ b/src/egg/gfx/eggPostEffectBase.cpp
@@ -5,7 +5,6 @@
#include "egg/gfx/eggDrawGX.h"
#include "egg/gfx/eggScreen.h"
#include "egg/math/eggVector.h"
-#include "math.h"
#include "nw4r/math/math_triangular.h"
#include "nw4r/math/math_types.h"
#include "rvl/GX/GXBump.h"
diff --git a/src/egg/gfx/eggPostEffectBlur.cpp b/src/egg/gfx/eggPostEffectBlur.cpp
index fb302821..c153122c 100644
--- a/src/egg/gfx/eggPostEffectBlur.cpp
+++ b/src/egg/gfx/eggPostEffectBlur.cpp
@@ -6,7 +6,6 @@
#include "egg/gfx/eggGXUtility.h"
#include "egg/math/eggMath.h"
#include "egg/math/eggVector.h"
-#include "math.h"
#include "nw4r/math/math_triangular.h"
#include "nw4r/math/math_types.h"
#include "rvl/GX/GXAttr.h"
diff --git a/src/egg/prim/eggAssert.cpp b/src/egg/prim/eggAssert.cpp
index 65aa580b..0de499fe 100644
--- a/src/egg/prim/eggAssert.cpp
+++ b/src/egg/prim/eggAssert.cpp
@@ -1,6 +1,7 @@
#include "egg/prim/eggAssert.h"
-#include "__va_arg.h"
+#include <cstdarg>
+
#include "egg/core/eggSystem.h"
#include "egg/core/eggXfbManager.h"
#include "nw4r/db/db_directPrint.h"
diff --git a/src/m/m_angle.cpp b/src/m/m_angle.cpp
index acd5ffe2..043424ab 100644
--- a/src/m/m_angle.cpp
+++ b/src/m/m_angle.cpp
@@ -1,6 +1,6 @@
#include "m/m_angle.h"
-#include "math.h"
+#include <cmath>
mAng3_c mAng3_c::Zero(0, 0, 0);
diff --git a/src/nw4r/g3d/g3d_anmchr.cpp b/src/nw4r/g3d/g3d_anmchr.cpp
index 5541270f..459dc226 100644
--- a/src/nw4r/g3d/g3d_anmchr.cpp
+++ b/src/nw4r/g3d/g3d_anmchr.cpp
@@ -5,7 +5,7 @@
#include "rvl/GX.h" // IWYU pragma: export
-#include <cmath.h>
+#include <cmath>
namespace nw4r {
namespace g3d {
diff --git a/src/nw4r/g3d/g3d_anmtexsrt.cpp b/src/nw4r/g3d/g3d_anmtexsrt.cpp
index 7c479a19..dad02061 100644
--- a/src/nw4r/g3d/g3d_anmtexsrt.cpp
+++ b/src/nw4r/g3d/g3d_anmtexsrt.cpp
@@ -515,7 +515,7 @@ void ApplyTexSrtAnmResult(ResTexSrt srt, ResMatIndMtxAndScale ind, const TexSrtA
maxElem = ut::Max(maxElem, ut::Abs(mtx._13));
scaleExp = static_cast<s8>(math::FGetExpPart(maxElem) + 1);
- f32 invScale = std::ldexp(1.0f, -scaleExp); // TODO ldexpf rename
+ f32 invScale = std::ldexpf(1.0f, -scaleExp);
mtx._00 *= invScale;
mtx._01 *= invScale;
diff --git a/src/nw4r/g3d/res/g3d_restev.cpp b/src/nw4r/g3d/res/g3d_restev.cpp
index 644450ee..2151c9f0 100644
--- a/src/nw4r/g3d/res/g3d_restev.cpp
+++ b/src/nw4r/g3d/res/g3d_restev.cpp
@@ -2,6 +2,7 @@
#include "rvl/BASE.h" // IWYU pragma: export
#include "rvl/GX.h" // IWYU pragma: export
+#include <cstdint>
namespace nw4r {
namespace g3d {
diff --git a/src/nw4r/snd/snd_AnimSound.cpp b/src/nw4r/snd/snd_AnimSound.cpp
index 05ec3ef8..9bcdcf0b 100644
--- a/src/nw4r/snd/snd_AnimSound.cpp
+++ b/src/nw4r/snd/snd_AnimSound.cpp
@@ -90,8 +90,8 @@ void AnimSoundImpl::UpdateFrame(f32 frame, PlayDirection dir) {
}
void AnimSoundImpl::UpdateForward(f32 frame) {
- s32 currFrameFloor = std::floorf(mCurrentFrame);
- s32 targetFrame = std::floorf(frame);
+ s32 currFrameFloor = std::floor(mCurrentFrame);
+ s32 targetFrame = std::floor(frame);
if (mNeedTriggerEventsAtCurrentFrame && mCurrentFrame == currFrameFloor) {
currFrameFloor -= 1;
@@ -118,8 +118,8 @@ void AnimSoundImpl::UpdateForward(f32 frame) {
}
void AnimSoundImpl::UpdateBackward(f32 frame) {
- s32 currFrameCeil = std::ceilf(mCurrentFrame);
- s32 targetFrame = std::ceilf(frame);
+ s32 currFrameCeil = std::ceil(mCurrentFrame);
+ s32 targetFrame = std::ceil(frame);
if (currFrameCeil >= mReader.GetAnimDuration()) {
currFrameCeil -= mReader.GetAnimDuration();
diff --git a/src/nw4r/snd/snd_Sound3DCalculator.cpp b/src/nw4r/snd/snd_Sound3DCalculator.cpp
index 8c1c1b9d..2651724e 100644
--- a/src/nw4r/snd/snd_Sound3DCalculator.cpp
+++ b/src/nw4r/snd/snd_Sound3DCalculator.cpp
@@ -210,9 +210,9 @@ void Sound3DCalculator::CalcPanDpl2(
}
// clang-format on
- f32 cosAvg = (std::cosf(mFrontSpeakerAngleDpl2) + std::cosf(mRearSpeakerAngleDpl2)) / 2.0f;
+ f32 cosAvg = (std::cos(mFrontSpeakerAngleDpl2) + std::cos(mRearSpeakerAngleDpl2)) / 2.0f;
- f32 rearFactor = cosAvg / (cosAvg + -std::cosf(mRearSpeakerAngleDpl2));
+ f32 rearFactor = cosAvg / (cosAvg + -std::cos(mRearSpeakerAngleDpl2));
panLR *= mPanRange;
panFR *= mPanRange;
diff --git a/src/nw4r/ut/ut_TextWriterBase.cpp b/src/nw4r/ut/ut_TextWriterBase.cpp
index af8f085e..570ad621 100644
--- a/src/nw4r/ut/ut_TextWriterBase.cpp
+++ b/src/nw4r/ut/ut_TextWriterBase.cpp
@@ -1,9 +1,10 @@
// Ported from https://github.com/kiwi515/ogws/blob/master/src/nw4r/ut/ut_TextWriterBase.cpp
-#include "__va_arg.h"
#include "nw4r/ut.h"
+#include <cstdarg>
+
namespace nw4r {
namespace ut {
diff --git a/src/s/s_Math.cpp b/src/s/s_Math.cpp
index 605bd9b9..c6a443a0 100644
--- a/src/s/s_Math.cpp
+++ b/src/s/s_Math.cpp
@@ -1,6 +1,6 @@
#include "s/s_Math.h"
-#include "math.h"
+#include <cmath>
namespace sLib {
diff --git a/src/toBeSorted/d_camera_math.cpp b/src/toBeSorted/d_camera_math.cpp
index 9d245e12..7d055219 100644
--- a/src/toBeSorted/d_camera_math.cpp
+++ b/src/toBeSorted/d_camera_math.cpp
@@ -5,7 +5,7 @@
#include "m/m_vec.h"
#include "toBeSorted/deg_angle_util.h"
-#include <math.h>
+#include <cmath>
void d_camera_math_float_order() {
// Maybe more functions here
diff --git a/src/toBeSorted/deg_angle_util.cpp b/src/toBeSorted/deg_angle_util.cpp
index 19be9394..4fb410a5 100644
--- a/src/toBeSorted/deg_angle_util.cpp
+++ b/src/toBeSorted/deg_angle_util.cpp
@@ -4,7 +4,6 @@
#include "common.h"
#include "m/m_angle.h"
#include "m/m_vec.h"
-#include "math.h"
#include <cmath>
@@ -49,11 +48,11 @@ f32 dDegree::abs() const {
}
f32 dDegree::sin() const {
- return std::sinf(toRad());
+ return std::sin(toRad());
}
f32 dDegree::cos() const {
- return std::cosf(toRad());
+ return std::cos(toRad());
}
f32 dDegree::tan() const {