Compare commits

..

8 Commits

718 changed files with 10640 additions and 155819 deletions

View File

@ -1,34 +0,0 @@
AllowAllArgumentsOnNextLine: false
Cpp11BracedListStyle: false
ColumnLimit: 0
BreakBeforeBinaryOperators: NonAssignment
AlignOperands: AlignAfterOperator
IndentPPDirectives: BeforeHash
IndentCaseLabels: true
IndentWidth: 4
TabWidth: 4
UseTab: Never
LineEnding: LF
MaxEmptyLinesToKeep: 1
PointerAlignment: Left
SeparateDefinitionBlocks: Always
SpaceBeforeParens: Never
ReflowComments: false
SortIncludes: false
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterExternBlock: false
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterObjCDeclaration: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BeforeWhile: true
IndentExternBlock: false

22
.gitignore vendored
View File

@ -1,7 +1,6 @@
.DS_Store
*.dSYM
bin/*
build
*.metallib
*.pdb
*.exe
@ -14,30 +13,13 @@ build
*.wasm
*.app
*.dylib
*.a
Debug/*
scripts/__pycache__
src/wasmbind/gles_api.json
src/bindgen_core_api.c
src/bindgen_gles_api.c
src/graphics/glsl_shaders.h
src/io_stubs.c
src/orca_surface.c
src/graphics/orca_gl31.h
sdk/io_stubs.c
sdk/orca_surface.c
*bind_gen.c
*_stubs.c
.vscode/launch.json
.vscode/settings.json
__pycache__
scripts/files
# explicitly abandon old ext dir
/ext
src/ext/angle
sketches/*/bin

4
.gitmodules vendored Normal file
View File

@ -0,0 +1,4 @@
[submodule "milepost"]
path = milepost
url = git@git.handmade.network:MartinFouilleul/milepost.git
branch = main

View File

@ -1,3 +0,0 @@
You are currently at the root of the Orca source. Welcome.
This file exists to signal to the Orca CLI that you are in the Orca source and can do Orca source things. When the CLI detects this file, it will ignore the system Orca installation and use only the contents of this current source checkout.

View File

@ -1,2 +0,0 @@
github: orca-app
custom: "https://orca-app.dev/sponsor.html"

View File

@ -1,207 +0,0 @@
Orca
Copyright (C) 2023 Martin Fouilleul
Orca is distributed under the MIT license or the Apache License version 2.0,
at your option.
-------------------------------------------------------------------------------
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-------------------------------------------------------------------------------
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

View File

@ -1,2 +1,29 @@
**This repository is not used anymore. Development of Orca was moved here: [https://github.com/orca-app/orca](https://github.com/orca-app/orca)**
# Install
Clone the repo with the `--recurse-submodules` option.
Get and build ANGLE (see `milepost/ext/angle_install_notes.md`), and put `libEGL.dylib` and `libGLESv2.dylib` in `milepost/bin`.
Cd to orca and build milepost (the platform layer), wasm3 (the wasm runtime), then orca:
```
cd Orca
./build.sh milepost
./build.sh wasm3
./build.sh orca
```
Build the sample orca app:
```
pushd samples/pong ; ./build.sh ; popd
```
This creates a `Pong.app` bundle in `samples/pong` that you can double click to run.
You can also build milepost example apps like so:
```
cd milepost
pushd examples/canvas ; ./build.sh ; popd
pushd examples/perf_text ; ./build.sh ; popd
pushd examples/tiger ; ./build.sh ; popd
```

62
build.bat Normal file
View File

@ -0,0 +1,62 @@
@echo off
set target=%1%
if "%~1%" == "" set target=orca
if not exist bin mkdir bin
if not exist bin\obj mkdir bin\obj
if %target% == wasm3 (
echo building wasm3
set wasm3_includes=/I .\ext\wasm3\source
set wasm3_sources=/I .\ext\wasm3\source\*.c
for %%f in ( .\ext\wasm3\source\*.c ) do (
cl /nologo /Zi /Zc:preprocessor /O2 /c /Fo:bin\obj\%%~nf.obj %wasm3_includes% %%f
)
lib /nologo /out:bin\wasm3.lib bin\obj\*.obj
)
if %target% == milepost (
echo building milepost
cd milepost
build.bat
cd ..
)
if %target% == orca (
echo building orca
::copy libraries
copy milepost\bin\milepost.dll bin
copy milepost\bin\milepost.dll.lib bin
::generate wasm3 api bindings
python3 scripts\bindgen_bb.py core src\core_api.json^
--wasm3-bindings src\core_api_bind_gen.c
python3 scripts\bindgen_bb.py gles src\gles_api.json^
--wasm3-bindings src\gles_api_bind_gen.c
python3 scripts\bindgen_bb.py canvas src\canvas_api.json^
--guest-stubs sdk\orca_surface.c^
--guest-include graphics.h^
--wasm3-bindings src\canvas_api_bind_gen.c
python3 scripts\bindgen_bb.py clock src\clock_api.json^
--guest-stubs sdk\orca_clock.c^
--guest-include platform_clock.h^
--wasm3-bindings src\clock_api_bind_gen.c
python3 scripts\bindgen_bb.py io^
src\io_api.json^
--guest-stubs sdk\io_stubs.c^
--wasm3-bindings src\io_api_bind_gen.c
::compile orca
set INCLUDES=/I src /I sdk /I ext\bytebox\include /I milepost\src /I milepost\ext
set LIBS=/LIBPATH:bin milepost.dll.lib ext\bytebox\lib\bytebox.lib ntdll.lib
cl /Zi /Zc:preprocessor /std:c11 /experimental:c11atomics %INCLUDES% src\main.c /link %LIBS% /STACK:8388608,8388608 /out:bin\orca.exe
)

97
build.sh Executable file
View File

@ -0,0 +1,97 @@
#!/bin/bash
set -eo pipefail
target="$1"
if [ -z $target ] ; then
target='orca'
fi
target=$(echo $target | tr '[:upper:]' '[:lower:]')
if [ ! \( -e bin \) ] ; then
mkdir ./bin
fi
if [ ! \( -e resources \) ] ; then
mkdir ./resources
fi
if [ $target = milepost ] ; then
echo "building milepost"
pushd milepost > /dev/null
./build.sh lib "$2"
popd > /dev/null
elif [ $target = wasm3 ] ; then
echo "building wasm3"
mkdir ./bin/obj
for file in ./ext/wasm3/source/*.c ; do
name=$(basename $file)
name=${name/.c/.o}
clang -c -g -O2 -foptimize-sibling-calls -Wno-extern-initializer -Dd_m3VerboseErrorMessages -o ./bin/obj/$name -I./ext/wasm3/source $file
done
ar -rcs ./bin/libwasm3.a ./bin/obj/*.o
rm -rf ./bin/obj
elif [ $target = orca ] ; then
echo "building orca"
if [ ! \( -e milepost/bin/libmilepost.dylib \) -o ! \( -e milepost/bin/mtl_renderer.metallib \) ] ; then
./build.sh milepost
fi
if [ ! \( -e ./bin/libwasm3.a \) ] ; then
./build.sh wasm3
fi
# copy libraries
cp milepost/bin/mtl_renderer.metallib bin/
cp milepost/bin/libmilepost.dylib bin/
cp milepost/bin/libGLESv2.dylib bin/
cp milepost/bin/libEGL.dylib bin/
INCLUDES="-Isrc -Isdk -Imilepost/src -Imilepost/src/util -Imilepost/src/platform -Iext/wasm3/source -Imilepost/ext/"
LIBS="-Lbin -lmilepost -lwasm3"
FLAGS="-g -DLOG_COMPILE_DEBUG -mmacos-version-min=10.15.4 -maes"
# generate wasm3 api bindings
python3 ./scripts/bindgen.py core \
src/core_api.json \
--wasm3-bindings ./src/core_api_bind_gen.c
python3 ./scripts/bindgen.py gles \
src/gles_api.json \
--wasm3-bindings ./src/gles_api_bind_gen.c
python3 ./scripts/bindgen.py canvas \
src/canvas_api.json \
--guest-stubs sdk/orca_surface.c \
--guest-include graphics.h \
--wasm3-bindings ./src/canvas_api_bind_gen.c
python3 ./scripts/bindgen.py clock \
src/clock_api.json \
--guest-stubs sdk/orca_clock.c \
--guest-include platform_clock.h \
--wasm3-bindings ./src/clock_api_bind_gen.c
python3 ./scripts/bindgen.py io \
src/io_api.json \
--guest-stubs sdk/io_stubs.c \
--wasm3-bindings ./src/io_api_bind_gen.c
# compile orca
clang $FLAGS $INCLUDES $LIBS -o bin/orca src/main.c
# fix libs imports
install_name_tool -change "./bin/libmilepost.dylib" "@rpath/libmilepost.dylib" bin/orca
install_name_tool -add_rpath "@executable_path/" bin/orca
else
echo "unknown build target $target"
fi

23
cstdlib/include/assert.h Normal file
View File

@ -0,0 +1,23 @@
#include <features.h>
#undef assert
#ifdef NDEBUG
#define assert(x) (void)0
#else
#define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0)))
#endif
#if __STDC_VERSION__ >= 201112L && !defined(__cplusplus)
#define static_assert _Static_assert
#endif
#ifdef __cplusplus
extern "C" {
#endif
_Noreturn void __assert_fail (const char *, const char *, int, const char *);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,134 @@
#define EPERM 1
#define ENOENT 2
#define ESRCH 3
#define EINTR 4
#define EIO 5
#define ENXIO 6
#define E2BIG 7
#define ENOEXEC 8
#define EBADF 9
#define ECHILD 10
#define EAGAIN 11
#define ENOMEM 12
#define EACCES 13
#define EFAULT 14
#define ENOTBLK 15
#define EBUSY 16
#define EEXIST 17
#define EXDEV 18
#define ENODEV 19
#define ENOTDIR 20
#define EISDIR 21
#define EINVAL 22
#define ENFILE 23
#define EMFILE 24
#define ENOTTY 25
#define ETXTBSY 26
#define EFBIG 27
#define ENOSPC 28
#define ESPIPE 29
#define EROFS 30
#define EMLINK 31
#define EPIPE 32
#define EDOM 33
#define ERANGE 34
#define EDEADLK 35
#define ENAMETOOLONG 36
#define ENOLCK 37
#define ENOSYS 38
#define ENOTEMPTY 39
#define ELOOP 40
#define EWOULDBLOCK EAGAIN
#define ENOMSG 42
#define EIDRM 43
#define ECHRNG 44
#define EL2NSYNC 45
#define EL3HLT 46
#define EL3RST 47
#define ELNRNG 48
#define EUNATCH 49
#define ENOCSI 50
#define EL2HLT 51
#define EBADE 52
#define EBADR 53
#define EXFULL 54
#define ENOANO 55
#define EBADRQC 56
#define EBADSLT 57
#define EDEADLOCK EDEADLK
#define EBFONT 59
#define ENOSTR 60
#define ENODATA 61
#define ETIME 62
#define ENOSR 63
#define ENONET 64
#define ENOPKG 65
#define EREMOTE 66
#define ENOLINK 67
#define EADV 68
#define ESRMNT 69
#define ECOMM 70
#define EPROTO 71
#define EMULTIHOP 72
#define EDOTDOT 73
#define EBADMSG 74
#define EOVERFLOW 75
#define ENOTUNIQ 76
#define EBADFD 77
#define EREMCHG 78
#define ELIBACC 79
#define ELIBBAD 80
#define ELIBSCN 81
#define ELIBMAX 82
#define ELIBEXEC 83
#define EILSEQ 84
#define ERESTART 85
#define ESTRPIPE 86
#define EUSERS 87
#define ENOTSOCK 88
#define EDESTADDRREQ 89
#define EMSGSIZE 90
#define EPROTOTYPE 91
#define ENOPROTOOPT 92
#define EPROTONOSUPPORT 93
#define ESOCKTNOSUPPORT 94
#define EOPNOTSUPP 95
#define ENOTSUP EOPNOTSUPP
#define EPFNOSUPPORT 96
#define EAFNOSUPPORT 97
#define EADDRINUSE 98
#define EADDRNOTAVAIL 99
#define ENETDOWN 100
#define ENETUNREACH 101
#define ENETRESET 102
#define ECONNABORTED 103
#define ECONNRESET 104
#define ENOBUFS 105
#define EISCONN 106
#define ENOTCONN 107
#define ESHUTDOWN 108
#define ETOOMANYREFS 109
#define ETIMEDOUT 110
#define ECONNREFUSED 111
#define EHOSTDOWN 112
#define EHOSTUNREACH 113
#define EALREADY 114
#define EINPROGRESS 115
#define ESTALE 116
#define EUCLEAN 117
#define ENOTNAM 118
#define ENAVAIL 119
#define EISNAM 120
#define EREMOTEIO 121
#define EDQUOT 122
#define ENOMEDIUM 123
#define EMEDIUMTYPE 124
#define ECANCELED 125
#define ENOKEY 126
#define EKEYEXPIRED 127
#define EKEYREVOKED 128
#define EKEYREJECTED 129
#define EOWNERDEAD 130
#define ENOTRECOVERABLE 131
#define ERFKILL 132
#define EHWPOISON 133

View File

@ -1,9 +1,8 @@
#ifndef _ERRNO_H
#ifndef _ERRNO_H
#define _ERRNO_H
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
#include <features.h>
@ -11,14 +10,13 @@ extern "C"
#include <bits/errno.h>
#ifdef __GNUC__
__attribute__((const))
__attribute__((const))
#endif
int*
__errno_location(void);
int *__errno_location(void);
#define errno (*__errno_location())
#ifdef _GNU_SOURCE
extern char *program_invocation_short_name, *program_invocation_name;
extern char *program_invocation_short_name, *program_invocation_name;
#endif
#ifdef __cplusplus
@ -26,3 +24,4 @@ extern "C"
#endif
#endif

View File

@ -2,11 +2,10 @@
#define _FLOAT_H
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
int __flt_rounds(void);
int __flt_rounds(void);
#define FLT_ROUNDS (__flt_rounds())
#define FLT_RADIX 2

94
cstdlib/include/math.h Normal file
View File

@ -0,0 +1,94 @@
#ifndef _MATH_H
#define _MATH_H
#ifdef __cplusplus
extern "C" {
#endif
// NOTE(orca): not doing anything fancy for float_t and double_t
typedef float float_t;
typedef double double_t;
#define NAN __builtin_nanf("")
#define INFINITY __builtin_inff()
#define FP_NAN 0
#define FP_INFINITE 1
#define FP_ZERO 2
#define FP_SUBNORMAL 3
#define FP_NORMAL 4
int __fpclassify(double);
int __fpclassifyf(float);
int __fpclassifyl(long double);
static __inline unsigned __FLOAT_BITS(float __f)
{
union {float __f; unsigned __i;} __u;
__u.__f = __f;
return __u.__i;
}
static __inline unsigned long long __DOUBLE_BITS(double __f)
{
union {double __f; unsigned long long __i;} __u;
__u.__f = __f;
return __u.__i;
}
#define fpclassify(x) ( \
sizeof(x) == sizeof(float) ? __fpclassifyf(x) : \
sizeof(x) == sizeof(double) ? __fpclassify(x) : \
__fpclassifyl(x) )
#define isinf(x) ( \
sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) == 0x7f800000 : \
sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) == 0x7ffULL<<52 : \
__fpclassifyl(x) == FP_INFINITE)
#define isnan(x) ( \
sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) > 0x7f800000 : \
sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) > 0x7ffULL<<52 : \
__fpclassifyl(x) == FP_NAN)
double acos(double);
double ceil(double);
double cos(double);
float cosf(float);
double fabs(double);
double floor(double);
double fmod(double, double);
double pow(double, double);
double scalbn(double, int);
double sin(double);
float sinf(float);
double sqrt(double);
float sqrtf(float);
#define M_E 2.7182818284590452354 /* e */
#define M_LOG2E 1.4426950408889634074 /* log_2 e */
#define M_LOG10E 0.43429448190325182765 /* log_10 e */
#define M_LN2 0.69314718055994530942 /* log_e 2 */
#define M_LN10 2.30258509299404568402 /* log_e 10 */
#define M_PI 3.14159265358979323846 /* pi */
#define M_PI_2 1.57079632679489661923 /* pi/2 */
#define M_PI_4 0.78539816339744830962 /* pi/4 */
#define M_1_PI 0.31830988618379067154 /* 1/pi */
#define M_2_PI 0.63661977236758134308 /* 2/pi */
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
#ifdef __cplusplus
}
#endif
#endif

25
cstdlib/include/stdio.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef _STDIO_H
#define _STDIO_H
#ifdef __cplusplus
extern "C" {
#endif
struct _IO_FILE { char __x; };
typedef struct _IO_FILE FILE;
extern FILE *const stdin;
extern FILE *const stdout;
extern FILE *const stderr;
#define stdin (stdin)
#define stdout (stdout)
#define stderr (stderr)
int fprintf(FILE *__restrict, const char *__restrict, ...);
#ifdef __cplusplus
}
#endif
#endif

16
cstdlib/include/stdlib.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef _STDLIB_H
#define _STDLIB_H
#ifdef __cplusplus
extern "C" {
#endif
_Noreturn void abort (void);
int abs (int);
#ifdef __cplusplus
}
#endif
#endif

0
cstdlib/include/string.h Normal file
View File

View File

@ -51,21 +51,21 @@
#include "libm.h"
static const double
C1 = 4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */
C2 = -1.38888888888741095749e-03, /* 0xBF56C16C, 0x16C15177 */
C3 = 2.48015872894767294178e-05, /* 0x3EFA01A0, 0x19CB1590 */
C4 = -2.75573143513906633035e-07, /* 0xBE927E4F, 0x809C52AD */
C5 = 2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */
C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */
C1 = 4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */
C2 = -1.38888888888741095749e-03, /* 0xBF56C16C, 0x16C15177 */
C3 = 2.48015872894767294178e-05, /* 0x3EFA01A0, 0x19CB1590 */
C4 = -2.75573143513906633035e-07, /* 0xBE927E4F, 0x809C52AD */
C5 = 2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */
C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */
double __cos(double x, double y)
{
double_t hz, z, r, w;
double_t hz,z,r,w;
z = x * x;
w = z * z;
r = z * (C1 + z * (C2 + z * C3)) + w * w * (C4 + z * (C5 + z * C6));
hz = 0.5 * z;
w = 1.0 - hz;
return w + (((1.0 - w) - hz) + (z * r - x * y));
z = x*x;
w = z*z;
r = z*(C1+z*(C2+z*C3)) + w*w*(C4+z*(C5+z*C6));
hz = 0.5*z;
w = 1.0-hz;
return w + (((1.0-w)-hz) + (z*r-x*y));
}

View File

@ -18,18 +18,18 @@
/* |cos(x) - c(x)| < 2**-34.1 (~[-5.37e-11, 5.295e-11]). */
static const double
C0 = -0x1ffffffd0c5e81.0p-54, /* -0.499999997251031003120 */
C1 = 0x155553e1053a42.0p-57, /* 0.0416666233237390631894 */
C2 = -0x16c087e80f1e27.0p-62, /* -0.00138867637746099294692 */
C3 = 0x199342e0ee5069.0p-68; /* 0.0000243904487962774090654 */
C0 = -0x1ffffffd0c5e81.0p-54, /* -0.499999997251031003120 */
C1 = 0x155553e1053a42.0p-57, /* 0.0416666233237390631894 */
C2 = -0x16c087e80f1e27.0p-62, /* -0.00138867637746099294692 */
C3 = 0x199342e0ee5069.0p-68; /* 0.0000243904487962774090654 */
float __cosdf(double x)
{
double_t r, w, z;
double_t r, w, z;
/* Try to optimize for parallel evaluation as in __tandf.c. */
z = x * x;
w = z * z;
r = C2 + z * C3;
return ((1.0 + z * C0) + w * C1) + (w * z) * r;
/* Try to optimize for parallel evaluation as in __tandf.c. */
z = x*x;
w = z*z;
r = C2+z*C3;
return ((1.0+z*C0) + w*C1) + (w*z)*r;
}

View File

@ -2,7 +2,7 @@
int errno;
int* __errno_location(void)
int *__errno_location(void)
{
// NOTE(orca): We might need a better solution if we eventually support wasm threads.
return &errno;

View File

@ -2,5 +2,5 @@
double __math_invalid(double x)
{
return (x - x) / (x - x);
return (x - x) / (x - x);
}

View File

@ -2,5 +2,5 @@
float __math_invalidf(float x)
{
return (x - x) / (x - x);
return (x - x) / (x - x);
}

View File

@ -2,5 +2,5 @@
double __math_oflow(uint32_t sign)
{
return __math_xflow(sign, 0x1p769);
return __math_xflow(sign, 0x1p769);
}

View File

@ -2,5 +2,5 @@
double __math_uflow(uint32_t sign)
{
return __math_xflow(sign, 0x1p-767);
return __math_xflow(sign, 0x1p-767);
}

View File

@ -0,0 +1,8 @@
#include "libm.h"
double __math_xflow(uint32_t sign, double y)
{
// NOTE(orca): no fp barriers
// return eval_as_double(fp_barrier(sign ? -y : y) * y);
return eval_as_double((sign ? -y : y) * y);
}

190
cstdlib/src/__rem_pio2.c Normal file
View File

@ -0,0 +1,190 @@
/* origin: FreeBSD /usr/src/lib/msun/src/e_rem_pio2.c */
/*
* ====================================================
* 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.
* ====================================================
*
* Optimized by Bruce D. Evans.
*/
/* __rem_pio2(x,y)
*
* return the remainder of x rem pi/2 in y[0]+y[1]
* use __rem_pio2_large() for large x
*/
#include "libm.h"
#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1
#define EPS DBL_EPSILON
#elif FLT_EVAL_METHOD==2
#define EPS LDBL_EPSILON
#endif
/*
* invpio2: 53 bits of 2/pi
* pio2_1: first 33 bit of pi/2
* pio2_1t: pi/2 - pio2_1
* pio2_2: second 33 bit of pi/2
* pio2_2t: pi/2 - (pio2_1+pio2_2)
* pio2_3: third 33 bit of pi/2
* pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3)
*/
static const double
toint = 1.5/EPS,
pio4 = 0x1.921fb54442d18p-1,
invpio2 = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
pio2_1 = 1.57079632673412561417e+00, /* 0x3FF921FB, 0x54400000 */
pio2_1t = 6.07710050650619224932e-11, /* 0x3DD0B461, 0x1A626331 */
pio2_2 = 6.07710050630396597660e-11, /* 0x3DD0B461, 0x1A600000 */
pio2_2t = 2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */
pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */
pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */
/* caller must handle the case when reduction is not needed: |x| ~<= pi/4 */
int __rem_pio2(double x, double *y)
{
union {double f; uint64_t i;} u = {x};
double_t z,w,t,r,fn;
double tx[3],ty[2];
uint32_t ix;
int sign, n, ex, ey, i;
sign = u.i>>63;
ix = u.i>>32 & 0x7fffffff;
if (ix <= 0x400f6a7a) { /* |x| ~<= 5pi/4 */
if ((ix & 0xfffff) == 0x921fb) /* |x| ~= pi/2 or 2pi/2 */
goto medium; /* cancellation -- use medium case */
if (ix <= 0x4002d97c) { /* |x| ~<= 3pi/4 */
if (!sign) {
z = x - pio2_1; /* one round good to 85 bits */
y[0] = z - pio2_1t;
y[1] = (z-y[0]) - pio2_1t;
return 1;
} else {
z = x + pio2_1;
y[0] = z + pio2_1t;
y[1] = (z-y[0]) + pio2_1t;
return -1;
}
} else {
if (!sign) {
z = x - 2*pio2_1;
y[0] = z - 2*pio2_1t;
y[1] = (z-y[0]) - 2*pio2_1t;
return 2;
} else {
z = x + 2*pio2_1;
y[0] = z + 2*pio2_1t;
y[1] = (z-y[0]) + 2*pio2_1t;
return -2;
}
}
}
if (ix <= 0x401c463b) { /* |x| ~<= 9pi/4 */
if (ix <= 0x4015fdbc) { /* |x| ~<= 7pi/4 */
if (ix == 0x4012d97c) /* |x| ~= 3pi/2 */
goto medium;
if (!sign) {
z = x - 3*pio2_1;
y[0] = z - 3*pio2_1t;
y[1] = (z-y[0]) - 3*pio2_1t;
return 3;
} else {
z = x + 3*pio2_1;
y[0] = z + 3*pio2_1t;
y[1] = (z-y[0]) + 3*pio2_1t;
return -3;
}
} else {
if (ix == 0x401921fb) /* |x| ~= 4pi/2 */
goto medium;
if (!sign) {
z = x - 4*pio2_1;
y[0] = z - 4*pio2_1t;
y[1] = (z-y[0]) - 4*pio2_1t;
return 4;
} else {
z = x + 4*pio2_1;
y[0] = z + 4*pio2_1t;
y[1] = (z-y[0]) + 4*pio2_1t;
return -4;
}
}
}
if (ix < 0x413921fb) { /* |x| ~< 2^20*(pi/2), medium size */
medium:
/* rint(x/(pi/2)) */
fn = (double_t)x*invpio2 + toint - toint;
n = (int32_t)fn;
r = x - fn*pio2_1;
w = fn*pio2_1t; /* 1st round, good to 85 bits */
/* Matters with directed rounding. */
if (predict_false(r - w < -pio4)) {
n--;
fn--;
r = x - fn*pio2_1;
w = fn*pio2_1t;
} else if (predict_false(r - w > pio4)) {
n++;
fn++;
r = x - fn*pio2_1;
w = fn*pio2_1t;
}
y[0] = r - w;
u.f = y[0];
ey = u.i>>52 & 0x7ff;
ex = ix>>20;
if (ex - ey > 16) { /* 2nd round, good to 118 bits */
t = r;
w = fn*pio2_2;
r = t - w;
w = fn*pio2_2t - ((t-r)-w);
y[0] = r - w;
u.f = y[0];
ey = u.i>>52 & 0x7ff;
if (ex - ey > 49) { /* 3rd round, good to 151 bits, covers all cases */
t = r;
w = fn*pio2_3;
r = t - w;
w = fn*pio2_3t - ((t-r)-w);
y[0] = r - w;
}
}
y[1] = (r - y[0]) - w;
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) */
u.f = x;
u.i &= (uint64_t)-1>>12;
u.i |= (uint64_t)(0x3ff + 23)<<52;
z = u.f;
for (i=0; i < 2; i++) {
tx[i] = (double)(int32_t)z;
z = (z-tx[i])*0x1p24;
}
tx[i] = z;
/* skip zero terms, first term is non-zero */
while (tx[i] == 0.0)
i--;
n = __rem_pio2_large(tx,ty,(int)(ix>>20)-(0x3ff+23),i+1,1);
if (sign) {
y[0] = -ty[0];
y[1] = -ty[1];
return -n;
}
y[0] = ty[0];
y[1] = ty[1];
return n;
}

View File

@ -0,0 +1,442 @@
/* origin: FreeBSD /usr/src/lib/msun/src/k_rem_pio2.c */
/*
* ====================================================
* 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.
* ====================================================
*/
/*
* __rem_pio2_large(x,y,e0,nx,prec)
* double x[],y[]; int e0,nx,prec;
*
* __rem_pio2_large return the last three digits of N with
* y = x - N*pi/2
* so that |y| < pi/2.
*
* The method is to compute the integer (mod 8) and fraction parts of
* (2/pi)*x without doing the full multiplication. In general we
* skip the part of the product that are known to be a huge integer (
* more accurately, = 0 mod 8 ). Thus the number of operations are
* independent of the exponent of the input.
*
* (2/pi) is represented by an array of 24-bit integers in ipio2[].
*
* Input parameters:
* x[] The input value (must be positive) is broken into nx
* pieces of 24-bit integers in double precision format.
* x[i] will be the i-th 24 bit of x. The scaled exponent
* of x[0] is given in input parameter e0 (i.e., x[0]*2^e0
* match x's up to 24 bits.
*
* Example of breaking a double positive z into x[0]+x[1]+x[2]:
* e0 = ilogb(z)-23
* z = scalbn(z,-e0)
* for i = 0,1,2
* x[i] = floor(z)
* z = (z-x[i])*2**24
*
*
* y[] ouput result in an array of double precision numbers.
* The dimension of y[] is:
* 24-bit precision 1
* 53-bit precision 2
* 64-bit precision 2
* 113-bit precision 3
* The actual value is the sum of them. Thus for 113-bit
* precison, one may have to do something like:
*
* long double t,w,r_head, r_tail;
* t = (long double)y[2] + (long double)y[1];
* w = (long double)y[0];
* r_head = t+w;
* r_tail = w - (r_head - t);
*
* e0 The exponent of x[0]. Must be <= 16360 or you need to
* expand the ipio2 table.
*
* nx dimension of x[]
*
* prec an integer indicating the precision:
* 0 24 bits (single)
* 1 53 bits (double)
* 2 64 bits (extended)
* 3 113 bits (quad)
*
* External function:
* double scalbn(), floor();
*
*
* Here is the description of some local variables:
*
* jk jk+1 is the initial number of terms of ipio2[] needed
* in the computation. The minimum and recommended value
* for jk is 3,4,4,6 for single, double, extended, and quad.
* jk+1 must be 2 larger than you might expect so that our
* recomputation test works. (Up to 24 bits in the integer
* part (the 24 bits of it that we compute) and 23 bits in
* the fraction part may be lost to cancelation before we
* recompute.)
*
* jz local integer variable indicating the number of
* terms of ipio2[] used.
*
* jx nx - 1
*
* jv index for pointing to the suitable ipio2[] for the
* computation. In general, we want
* ( 2^e0*x[0] * ipio2[jv-1]*2^(-24jv) )/8
* is an integer. Thus
* e0-3-24*jv >= 0 or (e0-3)/24 >= jv
* Hence jv = max(0,(e0-3)/24).
*
* jp jp+1 is the number of terms in PIo2[] needed, jp = jk.
*
* q[] double array with integral value, representing the
* 24-bits chunk of the product of x and 2/pi.
*
* q0 the corresponding exponent of q[0]. Note that the
* exponent for q[i] would be q0-24*i.
*
* PIo2[] double precision array, obtained by cutting pi/2
* into 24 bits chunks.
*
* f[] ipio2[] in floating point
*
* iq[] integer array by breaking up q[] in 24-bits chunk.
*
* fq[] final product of x*(2/pi) in fq[0],..,fq[jk]
*
* ih integer. If >0 it indicates q[] is >= 0.5, hence
* it also indicates the *sign* of the result.
*
*/
/*
* 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 "libm.h"
static const int init_jk[] = {3,4,4,6}; /* initial value for jk */
/*
* Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
*
* integer array, contains the (24*i)-th to (24*i+23)-th
* bit of 2/pi after binary point. The corresponding
* floating value is
*
* ipio2[i] * 2^(-24(i+1)).
*
* NB: This table must have at least (e0-3)/24 + jk terms.
* For quad precision (e0 <= 16360, jk = 6), this is 686.
*/
static const int32_t ipio2[] = {
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,
#if LDBL_MAX_EXP > 1024
0x47C419, 0xC367CD, 0xDCE809, 0x2A8359, 0xC4768B, 0x961CA6,
0xDDAF44, 0xD15719, 0x053EA5, 0xFF0705, 0x3F7E33, 0xE832C2,
0xDE4F98, 0x327DBB, 0xC33D26, 0xEF6B1E, 0x5EF89F, 0x3A1F35,
0xCAF27F, 0x1D87F1, 0x21907C, 0x7C246A, 0xFA6ED5, 0x772D30,
0x433B15, 0xC614B5, 0x9D19C3, 0xC2C4AD, 0x414D2C, 0x5D000C,
0x467D86, 0x2D71E3, 0x9AC69B, 0x006233, 0x7CD2B4, 0x97A7B4,
0xD55537, 0xF63ED7, 0x1810A3, 0xFC764D, 0x2A9D64, 0xABD770,
0xF87C63, 0x57B07A, 0xE71517, 0x5649C0, 0xD9D63B, 0x3884A7,
0xCB2324, 0x778AD6, 0x23545A, 0xB91F00, 0x1B0AF1, 0xDFCE19,
0xFF319F, 0x6A1E66, 0x615799, 0x47FBAC, 0xD87F7E, 0xB76522,
0x89E832, 0x60BFE6, 0xCDC4EF, 0x09366C, 0xD43F5D, 0xD7DE16,
0xDE3B58, 0x929BDE, 0x2822D2, 0xE88628, 0x4D58E2, 0x32CAC6,
0x16E308, 0xCB7DE0, 0x50C017, 0xA71DF3, 0x5BE018, 0x34132E,
0x621283, 0x014883, 0x5B8EF5, 0x7FB0AD, 0xF2E91E, 0x434A48,
0xD36710, 0xD8DDAA, 0x425FAE, 0xCE616A, 0xA4280A, 0xB499D3,
0xF2A606, 0x7F775C, 0x83C2A3, 0x883C61, 0x78738A, 0x5A8CAF,
0xBDD76F, 0x63A62D, 0xCBBFF4, 0xEF818D, 0x67C126, 0x45CA55,
0x36D9CA, 0xD2A828, 0x8D61C2, 0x77C912, 0x142604, 0x9B4612,
0xC459C4, 0x44C5C8, 0x91B24D, 0xF31700, 0xAD43D4, 0xE54929,
0x10D5FD, 0xFCBE00, 0xCC941E, 0xEECE70, 0xF53E13, 0x80F1EC,
0xC3E7B3, 0x28F8C7, 0x940593, 0x3E71C1, 0xB3092E, 0xF3450B,
0x9C1288, 0x7B20AB, 0x9FB52E, 0xC29247, 0x2F327B, 0x6D550C,
0x90A772, 0x1FE76B, 0x96CB31, 0x4A1679, 0xE27941, 0x89DFF4,
0x9794E8, 0x84E6E2, 0x973199, 0x6BED88, 0x365F5F, 0x0EFDBB,
0xB49A48, 0x6CA467, 0x427271, 0x325D8D, 0xB8159F, 0x09E5BC,
0x25318D, 0x3974F7, 0x1C0530, 0x010C0D, 0x68084B, 0x58EE2C,
0x90AA47, 0x02E774, 0x24D6BD, 0xA67DF7, 0x72486E, 0xEF169F,
0xA6948E, 0xF691B4, 0x5153D1, 0xF20ACF, 0x339820, 0x7E4BF5,
0x6863B2, 0x5F3EDD, 0x035D40, 0x7F8985, 0x295255, 0xC06437,
0x10D86D, 0x324832, 0x754C5B, 0xD4714E, 0x6E5445, 0xC1090B,
0x69F52A, 0xD56614, 0x9D0727, 0x50045D, 0xDB3BB4, 0xC576EA,
0x17F987, 0x7D6B49, 0xBA271D, 0x296996, 0xACCCC6, 0x5414AD,
0x6AE290, 0x89D988, 0x50722C, 0xBEA404, 0x940777, 0x7030F3,
0x27FC00, 0xA871EA, 0x49C266, 0x3DE064, 0x83DD97, 0x973FA3,
0xFD9443, 0x8C860D, 0xDE4131, 0x9D3992, 0x8C70DD, 0xE7B717,
0x3BDF08, 0x2B3715, 0xA0805C, 0x93805A, 0x921110, 0xD8E80F,
0xAF806C, 0x4BFFDB, 0x0F9038, 0x761859, 0x15A562, 0xBBCB61,
0xB989C7, 0xBD4010, 0x04F2D2, 0x277549, 0xF6B6EB, 0xBB22DB,
0xAA140A, 0x2F2689, 0x768364, 0x333B09, 0x1A940E, 0xAA3A51,
0xC2A31D, 0xAEEDAF, 0x12265C, 0x4DC26D, 0x9C7A2D, 0x9756C0,
0x833F03, 0xF6F009, 0x8C402B, 0x99316D, 0x07B439, 0x15200C,
0x5BC3D8, 0xC492F5, 0x4BADC6, 0xA5CA4E, 0xCD37A7, 0x36A9E6,
0x9492AB, 0x6842DD, 0xDE6319, 0xEF8C76, 0x528B68, 0x37DBFC,
0xABA1AE, 0x3115DF, 0xA1AE00, 0xDAFB0C, 0x664D64, 0xB705ED,
0x306529, 0xBF5657, 0x3AFF47, 0xB9F96A, 0xF3BE75, 0xDF9328,
0x3080AB, 0xF68C66, 0x15CB04, 0x0622FA, 0x1DE4D9, 0xA4B33D,
0x8F1B57, 0x09CD36, 0xE9424E, 0xA4BE13, 0xB52333, 0x1AAAF0,
0xA8654F, 0xA5C1D2, 0x0F3F0B, 0xCD785B, 0x76F923, 0x048B7B,
0x721789, 0x53A6C6, 0xE26E6F, 0x00EBEF, 0x584A9B, 0xB7DAC4,
0xBA66AA, 0xCFCF76, 0x1D02D1, 0x2DF1B1, 0xC1998C, 0x77ADC3,
0xDA4886, 0xA05DF7, 0xF480C6, 0x2FF0AC, 0x9AECDD, 0xBC5C3F,
0x6DDED0, 0x1FC790, 0xB6DB2A, 0x3A25A3, 0x9AAF00, 0x9353AD,
0x0457B6, 0xB42D29, 0x7E804B, 0xA707DA, 0x0EAA76, 0xA1597B,
0x2A1216, 0x2DB7DC, 0xFDE5FA, 0xFEDB89, 0xFDBE89, 0x6C76E4,
0xFCA906, 0x70803E, 0x156E85, 0xFF87FD, 0x073E28, 0x336761,
0x86182A, 0xEABD4D, 0xAFE7B3, 0x6E6D8F, 0x396795, 0x5BBF31,
0x48D784, 0x16DF30, 0x432DC7, 0x356125, 0xCE70C9, 0xB8CB30,
0xFD6CBF, 0xA200A4, 0xE46C05, 0xA0DD5A, 0x476F21, 0xD21262,
0x845CB9, 0x496170, 0xE0566B, 0x015299, 0x375550, 0xB7D51E,
0xC4F133, 0x5F6E13, 0xE4305D, 0xA92E85, 0xC3B21D, 0x3632A1,
0xA4B708, 0xD4B1EA, 0x21F716, 0xE4698F, 0x77FF27, 0x80030C,
0x2D408D, 0xA0CD4F, 0x99A520, 0xD3A2B3, 0x0A5D2F, 0x42F9B4,
0xCBDA11, 0xD0BE7D, 0xC1DB9B, 0xBD17AB, 0x81A2CA, 0x5C6A08,
0x17552E, 0x550027, 0xF0147F, 0x8607E1, 0x640B14, 0x8D4196,
0xDEBE87, 0x2AFDDA, 0xB6256B, 0x34897B, 0xFEF305, 0x9EBFB9,
0x4F6A68, 0xA82A4A, 0x5AC44F, 0xBCF82D, 0x985AD7, 0x95C7F4,
0x8D4D0D, 0xA63A20, 0x5F57A4, 0xB13F14, 0x953880, 0x0120CC,
0x86DD71, 0xB6DEC9, 0xF560BF, 0x11654D, 0x6B0701, 0xACB08C,
0xD0C0B2, 0x485551, 0x0EFB1E, 0xC37295, 0x3B06A3, 0x3540C0,
0x7BDC06, 0xCC45E0, 0xFA294E, 0xC8CAD6, 0x41F3E8, 0xDE647C,
0xD8649B, 0x31BED9, 0xC397A4, 0xD45877, 0xC5E369, 0x13DAF0,
0x3C3ABA, 0x461846, 0x5F7555, 0xF5BDD2, 0xC6926E, 0x5D2EAC,
0xED440E, 0x423E1C, 0x87C461, 0xE9FD29, 0xF3D6E7, 0xCA7C22,
0x35916F, 0xC5E008, 0x8DD7FF, 0xE26A6E, 0xC6FDB0, 0xC10893,
0x745D7C, 0xB2AD6B, 0x9D6ECD, 0x7B723E, 0x6A11C6, 0xA9CFF7,
0xDF7329, 0xBAC9B5, 0x5100B7, 0x0DB2E2, 0x24BA74, 0x607DE5,
0x8AD874, 0x2C150D, 0x0C1881, 0x94667E, 0x162901, 0x767A9F,
0xBEFDFD, 0xEF4556, 0x367ED9, 0x13D9EC, 0xB9BA8B, 0xFC97C4,
0x27A831, 0xC36EF1, 0x36C594, 0x56A8D8, 0xB5A8B4, 0x0ECCCF,
0x2D8912, 0x34576F, 0x89562C, 0xE3CE99, 0xB920D6, 0xAA5E6B,
0x9C2A3E, 0xCC5F11, 0x4A0BFD, 0xFBF4E1, 0x6D3B8E, 0x2C86E2,
0x84D4E9, 0xA9B4FC, 0xD1EEEF, 0xC9352E, 0x61392F, 0x442138,
0xC8D91B, 0x0AFC81, 0x6A4AFB, 0xD81C2F, 0x84B453, 0x8C994E,
0xCC2254, 0xDC552A, 0xD6C6C0, 0x96190B, 0xB8701A, 0x649569,
0x605A26, 0xEE523F, 0x0F117F, 0x11B5F4, 0xF5CBFC, 0x2DBC34,
0xEEBC34, 0xCC5DE8, 0x605EDD, 0x9B8E67, 0xEF3392, 0xB817C9,
0x9B5861, 0xBC57E1, 0xC68351, 0x103ED8, 0x4871DD, 0xDD1C2D,
0xA118AF, 0x462C21, 0xD7F359, 0x987AD9, 0xC0549E, 0xFA864F,
0xFC0656, 0xAE79E5, 0x362289, 0x22AD38, 0xDC9367, 0xAAE855,
0x382682, 0x9BE7CA, 0xA40D51, 0xB13399, 0x0ED7A9, 0x480569,
0xF0B265, 0xA7887F, 0x974C88, 0x36D1F9, 0xB39221, 0x4A827B,
0x21CF98, 0xDC9F40, 0x5547DC, 0x3A74E1, 0x42EB67, 0xDF9DFE,
0x5FD45E, 0xA4677B, 0x7AACBA, 0xA2F655, 0x23882B, 0x55BA41,
0x086E59, 0x862A21, 0x834739, 0xE6E389, 0xD49EE5, 0x40FB49,
0xE956FF, 0xCA0F1C, 0x8A59C5, 0x2BFA94, 0xC5C1D3, 0xCFC50F,
0xAE5ADB, 0x86C547, 0x624385, 0x3B8621, 0x94792C, 0x876110,
0x7B4C2A, 0x1A2C80, 0x12BF43, 0x902688, 0x893C78, 0xE4C4A8,
0x7BDBE5, 0xC23AC4, 0xEAF426, 0x8A67F7, 0xBF920D, 0x2BA365,
0xB1933D, 0x0B7CBD, 0xDC51A4, 0x63DD27, 0xDDE169, 0x19949A,
0x9529A8, 0x28CE68, 0xB4ED09, 0x209F44, 0xCA984E, 0x638270,
0x237C7E, 0x32B90F, 0x8EF5A7, 0xE75614, 0x08F121, 0x2A9DB5,
0x4D7E6F, 0x5119A5, 0xABF9B5, 0xD6DF82, 0x61DD96, 0x023616,
0x9F3AC4, 0xA1A283, 0x6DED72, 0x7A8D39, 0xA9B882, 0x5C326B,
0x5B2746, 0xED3400, 0x7700D2, 0x55F4FC, 0x4D5901, 0x8071E0,
#endif
};
static const double PIo2[] = {
1.57079625129699707031e+00, /* 0x3FF921FB, 0x40000000 */
7.54978941586159635335e-08, /* 0x3E74442D, 0x00000000 */
5.39030252995776476554e-15, /* 0x3CF84698, 0x80000000 */
3.28200341580791294123e-22, /* 0x3B78CC51, 0x60000000 */
1.27065575308067607349e-29, /* 0x39F01B83, 0x80000000 */
1.22933308981111328932e-36, /* 0x387A2520, 0x40000000 */
2.73370053816464559624e-44, /* 0x36E38222, 0x80000000 */
2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */
};
int __rem_pio2_large(double *x, double *y, int e0, int nx, int prec)
{
int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
double z,fw,f[20],fq[20],q[20];
/* initialize jk*/
jk = init_jk[prec];
jp = jk;
/* determine jx,jv,q0, note that 3>q0 */
jx = nx-1;
jv = (e0-3)/24; if(jv<0) jv=0;
q0 = e0-24*(jv+1);
/* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */
j = jv-jx; m = jx+jk;
for (i=0; i<=m; i++,j++)
f[i] = j<0 ? 0.0 : (double)ipio2[j];
/* compute q[0],q[1],...q[jk] */
for (i=0; i<=jk; i++) {
for (j=0,fw=0.0; j<=jx; j++)
fw += x[j]*f[jx+i-j];
q[i] = fw;
}
jz = jk;
recompute:
/* distill q[] into iq[] reversingly */
for (i=0,j=jz,z=q[jz]; j>0; i++,j--) {
fw = (double)(int32_t)(0x1p-24*z);
iq[i] = (int32_t)(z - 0x1p24*fw);
z = q[j-1]+fw;
}
/* compute n */
z = scalbn(z,q0); /* actual value of z */
z -= 8.0*floor(z*0.125); /* trim off integer >= 8 */
n = (int32_t)z;
z -= (double)n;
ih = 0;
if (q0 > 0) { /* need iq[jz-1] to determine n */
i = iq[jz-1]>>(24-q0); n += i;
iq[jz-1] -= i<<(24-q0);
ih = iq[jz-1]>>(23-q0);
}
else if (q0 == 0) ih = iq[jz-1]>>23;
else if (z >= 0.5) ih = 2;
if (ih > 0) { /* q > 0.5 */
n += 1; carry = 0;
for (i=0; i<jz; i++) { /* compute 1-q */
j = iq[i];
if (carry == 0) {
if (j != 0) {
carry = 1;
iq[i] = 0x1000000 - j;
}
} else
iq[i] = 0xffffff - j;
}
if (q0 > 0) { /* rare case: chance is 1 in 12 */
switch(q0) {
case 1:
iq[jz-1] &= 0x7fffff; break;
case 2:
iq[jz-1] &= 0x3fffff; break;
}
}
if (ih == 2) {
z = 1.0 - z;
if (carry != 0)
z -= scalbn(1.0,q0);
}
}
/* check if recomputation is needed */
if (z == 0.0) {
j = 0;
for (i=jz-1; i>=jk; i--) j |= iq[i];
if (j == 0) { /* need recomputation */
for (k=1; iq[jk-k]==0; k++); /* k = no. of terms needed */
for (i=jz+1; i<=jz+k; i++) { /* add q[jz+1] to q[jz+k] */
f[jx+i] = (double)ipio2[jv+i];
for (j=0,fw=0.0; j<=jx; j++)
fw += x[j]*f[jx+i-j];
q[i] = fw;
}
jz += k;
goto recompute;
}
}
/* chop off zero terms */
if (z == 0.0) {
jz -= 1;
q0 -= 24;
while (iq[jz] == 0) {
jz--;
q0 -= 24;
}
} else { /* break z into 24-bit if necessary */
z = scalbn(z,-q0);
if (z >= 0x1p24) {
fw = (double)(int32_t)(0x1p-24*z);
iq[jz] = (int32_t)(z - 0x1p24*fw);
jz += 1;
q0 += 24;
iq[jz] = (int32_t)fw;
} else
iq[jz] = (int32_t)z;
}
/* convert integer "bit" chunk to floating-point value */
fw = scalbn(1.0,q0);
for (i=jz; i>=0; i--) {
q[i] = fw*(double)iq[i];
fw *= 0x1p-24;
}
/* compute PIo2[0,...,jp]*q[jz,...,0] */
for(i=jz; i>=0; i--) {
for (fw=0.0,k=0; k<=jp && k<=jz-i; k++)
fw += PIo2[k]*q[i+k];
fq[jz-i] = fw;
}
/* compress fq[] into y[] */
switch(prec) {
case 0:
fw = 0.0;
for (i=jz; i>=0; i--)
fw += fq[i];
y[0] = ih==0 ? fw : -fw;
break;
case 1:
case 2:
fw = 0.0;
for (i=jz; i>=0; i--)
fw += fq[i];
// TODO: drop excess precision here once double_t is used
fw = (double)fw;
y[0] = ih==0 ? fw : -fw;
fw = fq[0]-fw;
for (i=1; i<=jz; i++)
fw += fq[i];
y[1] = ih==0 ? fw : -fw;
break;
case 3: /* painful */
for (i=jz; i>0; i--) {
fw = fq[i-1]+fq[i];
fq[i] += fq[i-1]-fw;
fq[i-1] = fw;
}
for (i=jz; i>1; i--) {
fw = fq[i-1]+fq[i];
fq[i] += fq[i-1]-fw;
fq[i-1] = fw;
}
for (fw=0.0,i=jz; i>=2; i--)
fw += fq[i];
if (ih==0) {
y[0] = fq[0]; y[1] = fq[1]; y[2] = fw;
} else {
y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw;
}
}
return n&7;
}

86
cstdlib/src/__rem_pio2f.c Normal file
View File

@ -0,0 +1,86 @@
/* origin: FreeBSD /usr/src/lib/msun/src/e_rem_pio2f.c */
/*
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
* Debugged and optimized by Bruce D. Evans.
*/
/*
* ====================================================
* 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.
* ====================================================
*/
/* __rem_pio2f(x,y)
*
* return the remainder of x rem pi/2 in *y
* use double precision for everything except passing x
* use __rem_pio2_large() for large x
*/
#include "libm.h"
#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1
#define EPS DBL_EPSILON
#elif FLT_EVAL_METHOD==2
#define EPS LDBL_EPSILON
#endif
/*
* invpio2: 53 bits of 2/pi
* pio2_1: first 25 bits of pi/2
* pio2_1t: pi/2 - pio2_1
*/
static const double
toint = 1.5/EPS,
pio4 = 0x1.921fb6p-1,
invpio2 = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
pio2_1 = 1.57079631090164184570e+00, /* 0x3FF921FB, 0x50000000 */
pio2_1t = 1.58932547735281966916e-08; /* 0x3E5110b4, 0x611A6263 */
int __rem_pio2f(float x, double *y)
{
union {float f; uint32_t i;} u = {x};
double tx[1],ty[1];
double_t fn;
uint32_t ix;
int n, sign, e0;
ix = u.i & 0x7fffffff;
/* 25+53 bit pi is good enough for medium size */
if (ix < 0x4dc90fdb) { /* |x| ~< 2^28*(pi/2), medium size */
/* Use a specialized rint() to get fn. */
fn = (double_t)x*invpio2 + toint - toint;
n = (int32_t)fn;
*y = x - fn*pio2_1 - fn*pio2_1t;
/* Matters with directed rounding. */
if (predict_false(*y < -pio4)) {
n--;
fn--;
*y = x - fn*pio2_1 - fn*pio2_1t;
} else if (predict_false(*y > pio4)) {
n++;
fn++;
*y = x - fn*pio2_1 - fn*pio2_1t;
}
return n;
}
if(ix>=0x7f800000) { /* x is inf or NaN */
*y = x-x;
return 0;
}
/* scale x into [2^23, 2^24-1] */
sign = u.i>>31;
e0 = (ix>>23) - (0x7f+23); /* e0 = ilogb(|x|)-23, positive */
u.i = ix - (e0<<23);
tx[0] = u.f;
n = __rem_pio2_large(tx,ty,e0,1,0);
if (sign) {
*y = -ty[0];
return -n;
}
*y = ty[0];
return n;
}

View File

@ -42,23 +42,23 @@
#include "libm.h"
static const double
S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */
S2 = 8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */
S3 = -1.98412698298579493134e-04, /* 0xBF2A01A0, 0x19C161D5 */
S4 = 2.75573137070700676789e-06, /* 0x3EC71DE3, 0x57B1FE7D */
S5 = -2.50507602534068634195e-08, /* 0xBE5AE5E6, 0x8A2B9CEB */
S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */
S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */
S2 = 8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */
S3 = -1.98412698298579493134e-04, /* 0xBF2A01A0, 0x19C161D5 */
S4 = 2.75573137070700676789e-06, /* 0x3EC71DE3, 0x57B1FE7D */
S5 = -2.50507602534068634195e-08, /* 0xBE5AE5E6, 0x8A2B9CEB */
S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */
double __sin(double x, double y, int iy)
{
double_t z, r, v, w;
double_t z,r,v,w;
z = x * x;
w = z * z;
r = S2 + z * (S3 + z * S4) + z * w * (S5 + z * S6);
v = z * x;
if(iy == 0)
return x + v * (S1 + z * r);
else
return x - ((z * (0.5 * y - v * r) - y) - v * S1);
z = x*x;
w = z*z;
r = S2 + z*(S3 + z*S4) + z*w*(S5 + z*S6);
v = z*x;
if (iy == 0)
return x + v*(S1 + z*r);
else
return x - ((z*(0.5*y - v*r) - y) - v*S1);
}

View File

@ -18,19 +18,19 @@
/* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */
static const double
S1 = -0x15555554cbac77.0p-55, /* -0.166666666416265235595 */
S2 = 0x111110896efbb2.0p-59, /* 0.0083333293858894631756 */
S3 = -0x1a00f9e2cae774.0p-65, /* -0.000198393348360966317347 */
S4 = 0x16cd878c3b46a7.0p-71; /* 0.0000027183114939898219064 */
S1 = -0x15555554cbac77.0p-55, /* -0.166666666416265235595 */
S2 = 0x111110896efbb2.0p-59, /* 0.0083333293858894631756 */
S3 = -0x1a00f9e2cae774.0p-65, /* -0.000198393348360966317347 */
S4 = 0x16cd878c3b46a7.0p-71; /* 0.0000027183114939898219064 */
float __sindf(double x)
{
double_t r, s, w, z;
double_t r, s, w, z;
/* Try to optimize for parallel evaluation as in __tandf.c. */
z = x * x;
w = z * z;
r = S3 + z * S4;
s = z * x;
return (x + s * (S1 + z * S2)) + s * w * r;
/* Try to optimize for parallel evaluation as in __tandf.c. */
z = x*x;
w = z*z;
r = S3 + z*S4;
s = z*x;
return (x + s*(S1 + z*S2)) + s*w*r;
}

6
cstdlib/src/abort.c Normal file
View File

@ -0,0 +1,6 @@
// NOTE(orca): This is a clang intrinsic. I hope it generates a wasm unreachable. I have not verified this.
// TODO(orca): Verify this.
_Noreturn void abort(void)
{
__builtin_unreachable();
}

View File

@ -2,5 +2,5 @@
int abs(int a)
{
return a > 0 ? a : -a;
return a>0 ? a : -a;
}

101
cstdlib/src/acos.c Normal file
View File

@ -0,0 +1,101 @@
/* origin: FreeBSD /usr/src/lib/msun/src/e_acos.c */
/*
* ====================================================
* 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.
* ====================================================
*/
/* acos(x)
* Method :
* acos(x) = pi/2 - asin(x)
* acos(-x) = pi/2 + asin(x)
* For |x|<=0.5
* acos(x) = pi/2 - (x + x*x^2*R(x^2)) (see asin.c)
* For x>0.5
* acos(x) = pi/2 - (pi/2 - 2asin(sqrt((1-x)/2)))
* = 2asin(sqrt((1-x)/2))
* = 2s + 2s*z*R(z) ...z=(1-x)/2, s=sqrt(z)
* = 2f + (2c + 2s*z*R(z))
* where f=hi part of s, and c = (z-f*f)/(s+f) is the correction term
* for f so that f+c ~ sqrt(z).
* For x<-0.5
* acos(x) = pi - 2asin(sqrt((1-|x|)/2))
* = pi - 0.5*(s+s*z*R(z)), where z=(1-|x|)/2,s=sqrt(z)
*
* Special cases:
* if x is NaN, return x itself;
* if |x|>1, return NaN with invalid signal.
*
* Function needed: sqrt
*/
#include "libm.h"
static const double
pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */
pio2_lo = 6.12323399573676603587e-17, /* 0x3C91A626, 0x33145C07 */
pS0 = 1.66666666666666657415e-01, /* 0x3FC55555, 0x55555555 */
pS1 = -3.25565818622400915405e-01, /* 0xBFD4D612, 0x03EB6F7D */
pS2 = 2.01212532134862925881e-01, /* 0x3FC9C155, 0x0E884455 */
pS3 = -4.00555345006794114027e-02, /* 0xBFA48228, 0xB5688F3B */
pS4 = 7.91534994289814532176e-04, /* 0x3F49EFE0, 0x7501B288 */
pS5 = 3.47933107596021167570e-05, /* 0x3F023DE1, 0x0DFDF709 */
qS1 = -2.40339491173441421878e+00, /* 0xC0033A27, 0x1C8A2D4B */
qS2 = 2.02094576023350569471e+00, /* 0x40002AE5, 0x9C598AC8 */
qS3 = -6.88283971605453293030e-01, /* 0xBFE6066C, 0x1B8D0159 */
qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
static double R(double z)
{
double_t p, q;
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
q = 1.0+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
return p/q;
}
double acos(double x)
{
double z,w,s,c,df;
uint32_t hx,ix;
GET_HIGH_WORD(hx, x);
ix = hx & 0x7fffffff;
/* |x| >= 1 or nan */
if (ix >= 0x3ff00000) {
uint32_t lx;
GET_LOW_WORD(lx,x);
if ((ix-0x3ff00000 | lx) == 0) {
/* acos(1)=0, acos(-1)=pi */
if (hx >> 31)
return 2*pio2_hi + 0x1p-120f;
return 0;
}
return 0/(x-x);
}
/* |x| < 0.5 */
if (ix < 0x3fe00000) {
if (ix <= 0x3c600000) /* |x| < 2**-57 */
return pio2_hi + 0x1p-120f;
return pio2_hi - (x - (pio2_lo-x*R(x*x)));
}
/* x < -0.5 */
if (hx >> 31) {
z = (1.0+x)*0.5;
s = sqrt(z);
w = R(z)*s-pio2_lo;
return 2*(pio2_hi - (s+w));
}
/* x > 0.5 */
z = (1.0-x)*0.5;
s = sqrt(z);
df = s;
SET_LOW_WORD(df,0);
c = (z-df*df)/(s+df);
w = R(z)*s+c;
return 2*(df+w);
}

9
cstdlib/src/assert.c Normal file
View File

@ -0,0 +1,9 @@
#include <stdio.h>
#include <stdlib.h>
_Noreturn void __assert_fail(const char *expr, const char *file, int line, const char *func)
{
// TODO(orca)
// fprintf(stderr, "Assertion failed: %s (%s: %s: %d)\n", expr, file, func, line);
abort();
}

31
cstdlib/src/ceil.c Normal file
View File

@ -0,0 +1,31 @@
#include "libm.h"
#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1
#define EPS DBL_EPSILON
#elif FLT_EVAL_METHOD==2
#define EPS LDBL_EPSILON
#endif
static const double_t toint = 1/EPS;
double ceil(double x)
{
union {double f; uint64_t i;} u = {x};
int e = u.i >> 52 & 0x7ff;
double_t y;
if (e >= 0x3ff+52 || x == 0)
return x;
/* y = int(x) - x, where int(x) is an integer neighbor of x */
if (u.i >> 63)
y = x - toint + toint - x;
else
y = x + toint - toint - x;
/* special case because of non-nearest rounding modes */
if (e <= 0x3ff-1) {
FORCE_EVAL(y);
return u.i >> 63 ? -0.0 : 1;
}
if (y < 0)
return x + y + 1;
return x + y;
}

View File

@ -1,4 +1,4 @@
/* origin: FreeBSD /usr/src/lib/msun/src/s_tan.c */
/* origin: FreeBSD /usr/src/lib/msun/src/s_cos.c */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@ -9,11 +9,12 @@
* is preserved.
* ====================================================
*/
/* tan(x)
* Return tangent function of x.
/* cos(x)
* Return cosine function of x.
*
* kernel function:
* __tan ... tangent function on [-pi/4,pi/4]
* __sin ... sine function on [-pi/4,pi/4]
* __cos ... cosine function on [-pi/4,pi/4]
* __rem_pio2 ... argument reduction routine
*
* Method.
@ -41,9 +42,7 @@
#include "libm.h"
double __tan(double x, double y, int odd);
double tan(double x)
double cos(double x)
{
double y[2];
uint32_t ix;
@ -54,19 +53,25 @@ double tan(double x)
/* |x| ~< pi/4 */
if (ix <= 0x3fe921fb) {
if (ix < 0x3e400000) { /* |x| < 2**-27 */
/* raise inexact if x!=0 and underflow if subnormal */
FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f);
return x;
if (ix < 0x3e46a09e) { /* |x| < 2**-27 * sqrt(2) */
/* raise inexact if x!=0 */
FORCE_EVAL(x + 0x1p120f);
return 1.0;
}
return __tan(x, 0.0, 0);
return __cos(x, 0);
}
/* tan(Inf or NaN) is NaN */
/* cos(Inf or NaN) is NaN */
if (ix >= 0x7ff00000)
return x - x;
return x-x;
/* argument reduction */
n = __rem_pio2(x, y);
return __tan(y[0], y[1], n&1);
switch (n&3) {
case 0: return __cos(y[0], y[1]);
case 1: return -__sin(y[0], y[1], 1);
case 2: return -__cos(y[0], y[1]);
default:
return __sin(y[0], y[1], 1);
}
}

78
cstdlib/src/cosf.c Normal file
View File

@ -0,0 +1,78 @@
/* origin: FreeBSD /usr/src/lib/msun/src/s_cosf.c */
/*
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
* Optimized by Bruce D. Evans.
*/
/*
* ====================================================
* 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.
* ====================================================
*/
#include "libm.h"
/* Small multiples of pi/2 rounded to double precision. */
static const double
c1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
c2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
c3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
c4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
float cosf(float x)
{
double y;
uint32_t ix;
unsigned n, sign;
GET_FLOAT_WORD(ix, x);
sign = ix >> 31;
ix &= 0x7fffffff;
if (ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
if (ix < 0x39800000) { /* |x| < 2**-12 */
/* raise inexact if x != 0 */
FORCE_EVAL(x + 0x1p120f);
return 1.0f;
}
return __cosdf(x);
}
if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */
if (ix > 0x4016cbe3) /* |x| ~> 3*pi/4 */
return -__cosdf(sign ? x+c2pio2 : x-c2pio2);
else {
if (sign)
return __sindf(x + c1pio2);
else
return __sindf(c1pio2 - x);
}
}
if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */
if (ix > 0x40afeddf) /* |x| ~> 7*pi/4 */
return __cosdf(sign ? x+c4pio2 : x-c4pio2);
else {
if (sign)
return __sindf(-x - c3pio2);
else
return __sindf(x - c3pio2);
}
}
/* cos(Inf or NaN) is NaN */
if (ix >= 0x7f800000)
return x-x;
/* general argument reduction needed */
n = __rem_pio2f(x,&y);
switch (n&3) {
case 0: return __cosdf(y);
case 1: return __sindf(-y);
case 2: return -__cosdf(y);
default:
return __sindf(y);
}
}

View File

@ -12,17 +12,15 @@
#define EXP_POLY_ORDER 5
#define EXP_USE_TOINT_NARROW 0
#define EXP2_POLY_ORDER 5
extern const struct exp_data
{
double invln2N;
double shift;
double negln2hiN;
double negln2loN;
double poly[4]; /* Last four coefficients. */
double exp2_shift;
double exp2_poly[EXP2_POLY_ORDER];
uint64_t tab[2 * (1 << EXP_TABLE_BITS)];
extern const struct exp_data {
double invln2N;
double shift;
double negln2hiN;
double negln2loN;
double poly[4]; /* Last four coefficients. */
double exp2_shift;
double exp2_poly[EXP2_POLY_ORDER];
uint64_t tab[2*(1 << EXP_TABLE_BITS)];
} __exp_data;
#endif

9
cstdlib/src/fabs.c Normal file
View File

@ -0,0 +1,9 @@
#include <math.h>
#include <stdint.h>
double fabs(double x)
{
union {double f; uint64_t i;} u = {x};
u.i &= -1ULL/2;
return u.f;
}

31
cstdlib/src/floor.c Normal file
View File

@ -0,0 +1,31 @@
#include "libm.h"
#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1
#define EPS DBL_EPSILON
#elif FLT_EVAL_METHOD==2
#define EPS LDBL_EPSILON
#endif
static const double_t toint = 1/EPS;
double floor(double x)
{
union {double f; uint64_t i;} u = {x};
int e = u.i >> 52 & 0x7ff;
double_t y;
if (e >= 0x3ff+52 || x == 0)
return x;
/* y = int(x) - x, where int(x) is an integer neighbor of x */
if (u.i >> 63)
y = x - toint + toint - x;
else
y = x + toint - toint - x;
/* special case because of non-nearest rounding modes */
if (e <= 0x3ff-1) {
FORCE_EVAL(y);
return u.i >> 63 ? -1 : 0;
}
if (y > 0)
return x + y - 1;
return x + y;
}

68
cstdlib/src/fmod.c Normal file
View File

@ -0,0 +1,68 @@
#include <math.h>
#include <stdint.h>
double fmod(double x, double y)
{
union {double f; uint64_t i;} ux = {x}, uy = {y};
int ex = ux.i>>52 & 0x7ff;
int ey = uy.i>>52 & 0x7ff;
int sx = ux.i>>63;
uint64_t i;
/* in the followings uxi should be ux.i, but then gcc wrongly adds */
/* float load/store to inner loops ruining performance and code size */
uint64_t uxi = ux.i;
if (uy.i<<1 == 0 || isnan(y) || ex == 0x7ff)
return (x*y)/(x*y);
if (uxi<<1 <= uy.i<<1) {
if (uxi<<1 == uy.i<<1)
return 0*x;
return x;
}
/* normalize x and y */
if (!ex) {
for (i = uxi<<12; i>>63 == 0; ex--, i <<= 1);
uxi <<= -ex + 1;
} else {
uxi &= -1ULL >> 12;
uxi |= 1ULL << 52;
}
if (!ey) {
for (i = uy.i<<12; i>>63 == 0; ey--, i <<= 1);
uy.i <<= -ey + 1;
} else {
uy.i &= -1ULL >> 12;
uy.i |= 1ULL << 52;
}
/* x mod y */
for (; ex > ey; ex--) {
i = uxi - uy.i;
if (i >> 63 == 0) {
if (i == 0)
return 0*x;
uxi = i;
}
uxi <<= 1;
}
i = uxi - uy.i;
if (i >> 63 == 0) {
if (i == 0)
return 0*x;
uxi = i;
}
for (; uxi>>52 == 0; uxi <<= 1, ex--);
/* scale result */
if (ex > 0) {
uxi -= 1ULL << 52;
uxi |= (uint64_t)ex << 52;
} else {
uxi >>= -ex + 1;
}
uxi |= (uint64_t)sx << 63;
ux.i = uxi;
return ux.f;
}

16
cstdlib/src/fprintf.c Normal file
View File

@ -0,0 +1,16 @@
#include <stdio.h>
// #include <stdarg.h>
#include <stdlib.h>
int fprintf(FILE *restrict f, const char *restrict fmt, ...)
{
// TODO(orca)
abort();
// int ret;
// va_list ap;
// va_start(ap, fmt);
// ret = vfprintf(f, fmt, ap);
// va_end(ap);
// return ret;
}

135
cstdlib/src/libm.h Normal file
View File

@ -0,0 +1,135 @@
#include <stdint.h>
#include <float.h>
#include <math.h>
#define WANT_ROUNDING 1
#if WANT_SNAN
#error SNaN is unsupported
#else
#define issignalingf_inline(x) 0
#define issignaling_inline(x) 0
#endif
/* Helps static branch prediction so hot path can be better optimized. */
#ifdef __GNUC__
#define predict_true(x) __builtin_expect(!!(x), 1)
#define predict_false(x) __builtin_expect(x, 0)
#else
#define predict_true(x) (x)
#define predict_false(x) (x)
#endif
static inline float eval_as_float(float x)
{
float y = x;
return y;
}
static inline double eval_as_double(double x)
{
double y = x;
return y;
}
/* fp_force_eval ensures that the input value is computed when that's
otherwise unused. To prevent the constant folding of the input
expression, an additional fp_barrier may be needed or a compilation
mode that does so (e.g. -frounding-math in gcc). Then it can be
used to evaluate an expression for its fenv side-effects only. */
#ifndef fp_force_evalf
#define fp_force_evalf fp_force_evalf
static inline void fp_force_evalf(float x)
{
volatile float y;
y = x;
}
#endif
#ifndef fp_force_eval
#define fp_force_eval fp_force_eval
static inline void fp_force_eval(double x)
{
volatile double y;
y = x;
}
#endif
#ifndef fp_force_evall
#define fp_force_evall fp_force_evall
static inline void fp_force_evall(long double x)
{
volatile long double y;
y = x;
}
#endif
#define FORCE_EVAL(x) do { \
if (sizeof(x) == sizeof(float)) { \
fp_force_evalf(x); \
} else if (sizeof(x) == sizeof(double)) { \
fp_force_eval(x); \
} else { \
fp_force_evall(x); \
} \
} while(0)
#define asuint(f) ((union{float _f; uint32_t _i;}){f})._i
#define asfloat(i) ((union{uint32_t _i; float _f;}){i})._f
#define asuint64(f) ((union{double _f; uint64_t _i;}){f})._i
#define asdouble(i) ((union{uint64_t _i; double _f;}){i})._f
#define EXTRACT_WORDS(hi,lo,d) \
do { \
uint64_t __u = asuint64(d); \
(hi) = __u >> 32; \
(lo) = (uint32_t)__u; \
} while (0)
#define GET_HIGH_WORD(hi,d) \
do { \
(hi) = asuint64(d) >> 32; \
} while (0)
#define GET_LOW_WORD(lo,d) \
do { \
(lo) = (uint32_t)asuint64(d); \
} while (0)
#define INSERT_WORDS(d,hi,lo) \
do { \
(d) = asdouble(((uint64_t)(hi)<<32) | (uint32_t)(lo)); \
} while (0)
#define SET_HIGH_WORD(d,hi) \
INSERT_WORDS(d, hi, (uint32_t)asuint64(d))
#define SET_LOW_WORD(d,lo) \
INSERT_WORDS(d, asuint64(d)>>32, lo)
#define GET_FLOAT_WORD(w,d) \
do { \
(w) = asuint(d); \
} while (0)
#define SET_FLOAT_WORD(d,w) \
do { \
(d) = asfloat(w); \
} while (0)
int __rem_pio2_large(double*,double*,int,int,int);
int __rem_pio2(double,double*);
double __sin(double,double,int);
double __cos(double,double);
int __rem_pio2f(float,double*);
float __sindf(double);
float __cosdf(double);
float __math_invalidf(float);
double __math_xflow(uint32_t, double);
double __math_uflow(uint32_t);
double __math_oflow(uint32_t);
double __math_invalid(double);

346
cstdlib/src/pow.c Normal file
View File

@ -0,0 +1,346 @@
/*
* Double-precision x^y function.
*
* Copyright (c) 2018, Arm Limited.
* SPDX-License-Identifier: MIT
*/
#include <math.h>
#include <stdint.h>
#include "libm.h"
#include "exp_data.h"
#include "pow_data.h"
/*
Worst-case error: 0.54 ULP (~= ulperr_exp + 1024*Ln2*relerr_log*2^53)
relerr_log: 1.3 * 2^-68 (Relative error of log, 1.5 * 2^-68 without fma)
ulperr_exp: 0.509 ULP (ULP error of exp, 0.511 ULP without fma)
*/
#define T __pow_log_data.tab
#define A __pow_log_data.poly
#define Ln2hi __pow_log_data.ln2hi
#define Ln2lo __pow_log_data.ln2lo
#define N (1 << POW_LOG_TABLE_BITS)
#define OFF 0x3fe6955500000000
/* Top 12 bits of a double (sign and exponent bits). */
static inline uint32_t top12(double x)
{
return asuint64(x) >> 52;
}
/* Compute y+TAIL = log(x) where the rounded result is y and TAIL has about
additional 15 bits precision. IX is the bit representation of x, but
normalized in the subnormal range using the sign bit for the exponent. */
static inline double_t log_inline(uint64_t ix, double_t *tail)
{
/* double_t for better performance on targets with FLT_EVAL_METHOD==2. */
double_t z, r, y, invc, logc, logctail, kd, hi, t1, t2, lo, lo1, lo2, p;
uint64_t iz, tmp;
int k, i;
/* x = 2^k z; where z is in range [OFF,2*OFF) and exact.
The range is split into N subintervals.
The ith subinterval contains z and c is near its center. */
tmp = ix - OFF;
i = (tmp >> (52 - POW_LOG_TABLE_BITS)) % N;
k = (int64_t)tmp >> 52; /* arithmetic shift */
iz = ix - (tmp & 0xfffULL << 52);
z = asdouble(iz);
kd = (double_t)k;
/* log(x) = k*Ln2 + log(c) + log1p(z/c-1). */
invc = T[i].invc;
logc = T[i].logc;
logctail = T[i].logctail;
/* Note: 1/c is j/N or j/N/2 where j is an integer in [N,2N) and
|z/c - 1| < 1/N, so r = z/c - 1 is exactly representible. */
#if __FP_FAST_FMA
r = __builtin_fma(z, invc, -1.0);
#else
/* Split z such that rhi, rlo and rhi*rhi are exact and |rlo| <= |r|. */
double_t zhi = asdouble((iz + (1ULL << 31)) & (-1ULL << 32));
double_t zlo = z - zhi;
double_t rhi = zhi * invc - 1.0;
double_t rlo = zlo * invc;
r = rhi + rlo;
#endif
/* k*Ln2 + log(c) + r. */
t1 = kd * Ln2hi + logc;
t2 = t1 + r;
lo1 = kd * Ln2lo + logctail;
lo2 = t1 - t2 + r;
/* Evaluation is optimized assuming superscalar pipelined execution. */
double_t ar, ar2, ar3, lo3, lo4;
ar = A[0] * r; /* A[0] = -0.5. */
ar2 = r * ar;
ar3 = r * ar2;
/* k*Ln2 + log(c) + r + A[0]*r*r. */
#if __FP_FAST_FMA
hi = t2 + ar2;
lo3 = __builtin_fma(ar, r, -ar2);
lo4 = t2 - hi + ar2;
#else
double_t arhi = A[0] * rhi;
double_t arhi2 = rhi * arhi;
hi = t2 + arhi2;
lo3 = rlo * (ar + arhi);
lo4 = t2 - hi + arhi2;
#endif
/* p = log1p(r) - r - A[0]*r*r. */
p = (ar3 * (A[1] + r * A[2] +
ar2 * (A[3] + r * A[4] + ar2 * (A[5] + r * A[6]))));
lo = lo1 + lo2 + lo3 + lo4 + p;
y = hi + lo;
*tail = hi - y + lo;
return y;
}
#undef N
#undef T
#define N (1 << EXP_TABLE_BITS)
#define InvLn2N __exp_data.invln2N
#define NegLn2hiN __exp_data.negln2hiN
#define NegLn2loN __exp_data.negln2loN
#define Shift __exp_data.shift
#define T __exp_data.tab
#define C2 __exp_data.poly[5 - EXP_POLY_ORDER]
#define C3 __exp_data.poly[6 - EXP_POLY_ORDER]
#define C4 __exp_data.poly[7 - EXP_POLY_ORDER]
#define C5 __exp_data.poly[8 - EXP_POLY_ORDER]
#define C6 __exp_data.poly[9 - EXP_POLY_ORDER]
/* Handle cases that may overflow or underflow when computing the result that
is scale*(1+TMP) without intermediate rounding. The bit representation of
scale is in SBITS, however it has a computed exponent that may have
overflown into the sign bit so that needs to be adjusted before using it as
a double. (int32_t)KI is the k used in the argument reduction and exponent
adjustment of scale, positive k here means the result may overflow and
negative k means the result may underflow. */
static inline double specialcase(double_t tmp, uint64_t sbits, uint64_t ki)
{
double_t scale, y;
if ((ki & 0x80000000) == 0) {
/* k > 0, the exponent of scale might have overflowed by <= 460. */
sbits -= 1009ull << 52;
scale = asdouble(sbits);
y = 0x1p1009 * (scale + scale * tmp);
return eval_as_double(y);
}
/* k < 0, need special care in the subnormal range. */
sbits += 1022ull << 52;
/* Note: sbits is signed scale. */
scale = asdouble(sbits);
y = scale + scale * tmp;
if (fabs(y) < 1.0) {
/* Round y to the right precision before scaling it into the subnormal
range to avoid double rounding that can cause 0.5+E/2 ulp error where
E is the worst-case ulp error outside the subnormal range. So this
is only useful if the goal is better than 1 ulp worst-case error. */
double_t hi, lo, one = 1.0;
if (y < 0.0)
one = -1.0;
lo = scale - y + scale * tmp;
hi = one + y;
lo = one - hi + y + lo;
y = eval_as_double(hi + lo) - one;
/* Fix the sign of 0. */
if (y == 0.0)
y = asdouble(sbits & 0x8000000000000000);
/* The underflow exception needs to be signaled explicitly. */
// NOTE(orca): removing special fp functions
// fp_force_eval(fp_barrier(0x1p-1022) * 0x1p-1022);
}
y = 0x1p-1022 * y;
return eval_as_double(y);
}
#define SIGN_BIAS (0x800 << EXP_TABLE_BITS)
/* Computes sign*exp(x+xtail) where |xtail| < 2^-8/N and |xtail| <= |x|.
The sign_bias argument is SIGN_BIAS or 0 and sets the sign to -1 or 1. */
static inline double exp_inline(double_t x, double_t xtail, uint32_t sign_bias)
{
uint32_t abstop;
uint64_t ki, idx, top, sbits;
/* double_t for better performance on targets with FLT_EVAL_METHOD==2. */
double_t kd, z, r, r2, scale, tail, tmp;
abstop = top12(x) & 0x7ff;
if (predict_false(abstop - top12(0x1p-54) >=
top12(512.0) - top12(0x1p-54))) {
if (abstop - top12(0x1p-54) >= 0x80000000) {
/* Avoid spurious underflow for tiny x. */
/* Note: 0 is common input. */
double_t one = WANT_ROUNDING ? 1.0 + x : 1.0;
return sign_bias ? -one : one;
}
if (abstop >= top12(1024.0)) {
/* Note: inf and nan are already handled. */
if (asuint64(x) >> 63)
return __math_uflow(sign_bias);
else
return __math_oflow(sign_bias);
}
/* Large x is special cased below. */
abstop = 0;
}
/* exp(x) = 2^(k/N) * exp(r), with exp(r) in [2^(-1/2N),2^(1/2N)]. */
/* x = ln2/N*k + r, with int k and r in [-ln2/2N, ln2/2N]. */
z = InvLn2N * x;
#if TOINT_INTRINSICS
kd = roundtoint(z);
ki = converttoint(z);
#elif EXP_USE_TOINT_NARROW
/* z - kd is in [-0.5-2^-16, 0.5] in all rounding modes. */
kd = eval_as_double(z + Shift);
ki = asuint64(kd) >> 16;
kd = (double_t)(int32_t)ki;
#else
/* z - kd is in [-1, 1] in non-nearest rounding modes. */
kd = eval_as_double(z + Shift);
ki = asuint64(kd);
kd -= Shift;
#endif
r = x + kd * NegLn2hiN + kd * NegLn2loN;
/* The code assumes 2^-200 < |xtail| < 2^-8/N. */
r += xtail;
/* 2^(k/N) ~= scale * (1 + tail). */
idx = 2 * (ki % N);
top = (ki + sign_bias) << (52 - EXP_TABLE_BITS);
tail = asdouble(T[idx]);
/* This is only a valid scale when -1023*N < k < 1024*N. */
sbits = T[idx + 1] + top;
/* exp(x) = 2^(k/N) * exp(r) ~= scale + scale * (tail + exp(r) - 1). */
/* Evaluation is optimized assuming superscalar pipelined execution. */
r2 = r * r;
/* Without fma the worst case error is 0.25/N ulp larger. */
/* Worst case error is less than 0.5+1.11/N+(abs poly error * 2^53) ulp. */
tmp = tail + r + r2 * (C2 + r * C3) + r2 * r2 * (C4 + r * C5);
if (predict_false(abstop == 0))
return specialcase(tmp, sbits, ki);
scale = asdouble(sbits);
/* Note: tmp == 0 or |tmp| > 2^-200 and scale > 2^-739, so there
is no spurious underflow here even without fma. */
return eval_as_double(scale + scale * tmp);
}
/* Returns 0 if not int, 1 if odd int, 2 if even int. The argument is
the bit representation of a non-zero finite floating-point value. */
static inline int checkint(uint64_t iy)
{
int e = iy >> 52 & 0x7ff;
if (e < 0x3ff)
return 0;
if (e > 0x3ff + 52)
return 2;
if (iy & ((1ULL << (0x3ff + 52 - e)) - 1))
return 0;
if (iy & (1ULL << (0x3ff + 52 - e)))
return 1;
return 2;
}
/* Returns 1 if input is the bit representation of 0, infinity or nan. */
static inline int zeroinfnan(uint64_t i)
{
return 2 * i - 1 >= 2 * asuint64(INFINITY) - 1;
}
double pow(double x, double y)
{
uint32_t sign_bias = 0;
uint64_t ix, iy;
uint32_t topx, topy;
ix = asuint64(x);
iy = asuint64(y);
topx = top12(x);
topy = top12(y);
if (predict_false(topx - 0x001 >= 0x7ff - 0x001 ||
(topy & 0x7ff) - 0x3be >= 0x43e - 0x3be)) {
/* Note: if |y| > 1075 * ln2 * 2^53 ~= 0x1.749p62 then pow(x,y) = inf/0
and if |y| < 2^-54 / 1075 ~= 0x1.e7b6p-65 then pow(x,y) = +-1. */
/* Special cases: (x < 0x1p-126 or inf or nan) or
(|y| < 0x1p-65 or |y| >= 0x1p63 or nan). */
if (predict_false(zeroinfnan(iy))) {
if (2 * iy == 0)
return issignaling_inline(x) ? x + y : 1.0;
if (ix == asuint64(1.0))
return issignaling_inline(y) ? x + y : 1.0;
if (2 * ix > 2 * asuint64(INFINITY) ||
2 * iy > 2 * asuint64(INFINITY))
return x + y;
if (2 * ix == 2 * asuint64(1.0))
return 1.0;
if ((2 * ix < 2 * asuint64(1.0)) == !(iy >> 63))
return 0.0; /* |x|<1 && y==inf or |x|>1 && y==-inf. */
return y * y;
}
if (predict_false(zeroinfnan(ix))) {
double_t x2 = x * x;
if (ix >> 63 && checkint(iy) == 1)
x2 = -x2;
/* Without the barrier some versions of clang hoist the 1/x2 and
thus division by zero exception can be signaled spuriously. */
// NOTE(orca): I hope my version of clang is not affected lol
// return iy >> 63 ? fp_barrier(1 / x2) : x2;
return iy >> 63 ? (1 / x2) : x2;
}
/* Here x and y are non-zero finite. */
if (ix >> 63) {
/* Finite x < 0. */
int yint = checkint(iy);
if (yint == 0)
return __math_invalid(x);
if (yint == 1)
sign_bias = SIGN_BIAS;
ix &= 0x7fffffffffffffff;
topx &= 0x7ff;
}
if ((topy & 0x7ff) - 0x3be >= 0x43e - 0x3be) {
/* Note: sign_bias == 0 here because y is not odd. */
if (ix == asuint64(1.0))
return 1.0;
if ((topy & 0x7ff) < 0x3be) {
/* |y| < 2^-65, x^y ~= 1 + y*log(x). */
if (WANT_ROUNDING)
return ix > asuint64(1.0) ? 1.0 + y :
1.0 - y;
else
return 1.0;
}
return (ix > asuint64(1.0)) == (topy < 0x800) ?
__math_oflow(0) :
__math_uflow(0);
}
if (topx == 0) {
/* Normalize subnormal x so exponent becomes negative. */
ix = asuint64(x * 0x1p52);
ix &= 0x7fffffffffffffff;
ix -= 52ULL << 52;
}
}
double_t lo;
double_t hi = log_inline(ix, &lo);
double_t ehi, elo;
#if __FP_FAST_FMA
ehi = y * hi;
elo = y * lo + __builtin_fma(y, hi, -ehi);
#else
double_t yhi = asdouble(iy & -1ULL << 27);
double_t ylo = y - yhi;
double_t lhi = asdouble(asuint64(hi) & -1ULL << 27);
double_t llo = hi - lhi + lo;
ehi = yhi * lhi;
elo = ylo * lhi + y * llo; /* |elo| < |ehi| * 2^-25. */
#endif
return exp_inline(ehi, elo, sign_bias);
}

22
cstdlib/src/pow_data.h Normal file
View File

@ -0,0 +1,22 @@
/*
* Copyright (c) 2018, Arm Limited.
* SPDX-License-Identifier: MIT
*/
#ifndef _POW_DATA_H
#define _POW_DATA_H
#include <features.h>
#define POW_LOG_TABLE_BITS 7
#define POW_LOG_POLY_ORDER 8
extern const struct pow_log_data {
double ln2hi;
double ln2lo;
double poly[POW_LOG_POLY_ORDER - 1]; /* First coefficient is 1. */
/* Note: the pad field is unused, but allows slightly faster indexing. */
struct {
double invc, pad, logc, logctail;
} tab[1 << POW_LOG_TABLE_BITS];
} __pow_log_data;
#endif

33
cstdlib/src/scalbn.c Normal file
View File

@ -0,0 +1,33 @@
#include <math.h>
#include <stdint.h>
double scalbn(double x, int n)
{
union {double f; uint64_t i;} u;
double_t y = x;
if (n > 1023) {
y *= 0x1p1023;
n -= 1023;
if (n > 1023) {
y *= 0x1p1023;
n -= 1023;
if (n > 1023)
n = 1023;
}
} else if (n < -1022) {
/* make sure final n < -53 to avoid double
rounding in the subnormal range */
y *= 0x1p-1022 * 0x1p53;
n += 1022 - 53;
if (n < -1022) {
y *= 0x1p-1022 * 0x1p53;
n += 1022 - 53;
if (n < -1022)
n = -1022;
}
}
u.i = (uint64_t)(0x3ff+n)<<52;
x = y * u.f;
return x;
}

View File

@ -44,41 +44,35 @@
double sin(double x)
{
double y[2];
uint32_t ix;
unsigned n;
double y[2];
uint32_t ix;
unsigned n;
/* High word of x. */
GET_HIGH_WORD(ix, x);
ix &= 0x7fffffff;
/* High word of x. */
GET_HIGH_WORD(ix, x);
ix &= 0x7fffffff;
/* |x| ~< pi/4 */
if(ix <= 0x3fe921fb)
{
if(ix < 0x3e500000)
{ /* |x| < 2**-26 */
/* raise inexact if x != 0 and underflow if subnormal*/
FORCE_EVAL(ix < 0x00100000 ? x / 0x1p120f : x + 0x1p120f);
return x;
}
return __sin(x, 0.0, 0);
}
/* |x| ~< pi/4 */
if (ix <= 0x3fe921fb) {
if (ix < 0x3e500000) { /* |x| < 2**-26 */
/* raise inexact if x != 0 and underflow if subnormal*/
FORCE_EVAL(ix < 0x00100000 ? x/0x1p120f : x+0x1p120f);
return x;
}
return __sin(x, 0.0, 0);
}
/* sin(Inf or NaN) is NaN */
if(ix >= 0x7ff00000)
return x - x;
/* sin(Inf or NaN) is NaN */
if (ix >= 0x7ff00000)
return x - x;
/* argument reduction needed */
n = __rem_pio2(x, y);
switch(n & 3)
{
case 0:
return __sin(y[0], y[1], 1);
case 1:
return __cos(y[0], y[1]);
case 2:
return -__sin(y[0], y[1], 1);
default:
return -__cos(y[0], y[1]);
}
/* argument reduction needed */
n = __rem_pio2(x, y);
switch (n&3) {
case 0: return __sin(y[0], y[1], 1);
case 1: return __cos(y[0], y[1]);
case 2: return -__sin(y[0], y[1], 1);
default:
return -__cos(y[0], y[1]);
}
}

View File

@ -1,4 +1,4 @@
/* origin: FreeBSD /usr/src/lib/msun/src/s_tanf.c */
/* origin: FreeBSD /usr/src/lib/msun/src/s_sinf.c */
/*
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
* Optimized by Bruce D. Evans.
@ -18,18 +18,16 @@
/* Small multiples of pi/2 rounded to double precision. */
static const double
t1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
t2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
t3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
t4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
s1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
s2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
s3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
s4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
float __tandf(double x, int odd);
float tanf(float x)
float sinf(float x)
{
double y;
uint32_t ix;
unsigned n, sign;
int n, sign;
GET_FLOAT_WORD(ix, x);
sign = ix >> 31;
@ -41,26 +39,38 @@ float tanf(float x)
FORCE_EVAL(ix < 0x00800000 ? x/0x1p120f : x+0x1p120f);
return x;
}
return __tandf(x, 0);
return __sindf(x);
}
if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */
if (ix <= 0x4016cbe3) /* |x| ~<= 3pi/4 */
return __tandf((sign ? x+t1pio2 : x-t1pio2), 1);
else
return __tandf((sign ? x+t2pio2 : x-t2pio2), 0);
if (ix <= 0x4016cbe3) { /* |x| ~<= 3pi/4 */
if (sign)
return -__cosdf(x + s1pio2);
else
return __cosdf(x - s1pio2);
}
return __sindf(sign ? -(x + s2pio2) : -(x - s2pio2));
}
if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */
if (ix <= 0x40afeddf) /* |x| ~<= 7*pi/4 */
return __tandf((sign ? x+t3pio2 : x-t3pio2), 1);
else
return __tandf((sign ? x+t4pio2 : x-t4pio2), 0);
if (ix <= 0x40afeddf) { /* |x| ~<= 7*pi/4 */
if (sign)
return __cosdf(x + s3pio2);
else
return -__cosdf(x - s3pio2);
}
return __sindf(sign ? x + s4pio2 : x - s4pio2);
}
/* tan(Inf or NaN) is NaN */
/* sin(Inf or NaN) is NaN */
if (ix >= 0x7f800000)
return x - x;
/* argument reduction */
/* general argument reduction needed */
n = __rem_pio2f(x, &y);
return __tandf(y, n&1);
switch (n&3) {
case 0: return __sindf(y);
case 1: return __cosdf(y);
case 2: return __sindf(-y);
default:
return -__cosdf(y);
}
}

View File

@ -1,59 +1,57 @@
#include <stdint.h>
#include <math.h>
#include "libm.h"
#include "sqrt_data.h"
#include <math.h>
#include <stdint.h>
#define FENV_SUPPORT 1
/* returns a*b*2^-32 - e, with error 0 <= e < 1. */
static inline uint32_t mul32(uint32_t a, uint32_t b)
{
return (uint64_t)a * b >> 32;
return (uint64_t)a*b >> 32;
}
/* returns a*b*2^-64 - e, with error 0 <= e < 3. */
static inline uint64_t mul64(uint64_t a, uint64_t b)
{
uint64_t ahi = a >> 32;
uint64_t alo = a & 0xffffffff;
uint64_t bhi = b >> 32;
uint64_t blo = b & 0xffffffff;
return ahi * bhi + (ahi * blo >> 32) + (alo * bhi >> 32);
uint64_t ahi = a>>32;
uint64_t alo = a&0xffffffff;
uint64_t bhi = b>>32;
uint64_t blo = b&0xffffffff;
return ahi*bhi + (ahi*blo >> 32) + (alo*bhi >> 32);
}
double sqrt(double x)
{
uint64_t ix, top, m;
uint64_t ix, top, m;
/* special case handling. */
ix = asuint64(x);
top = ix >> 52;
if(predict_false(top - 0x001 >= 0x7ff - 0x001))
{
/* x < 0x1p-1022 or inf or nan. */
if(ix * 2 == 0)
return x;
if(ix == 0x7ff0000000000000)
return x;
if(ix > 0x7ff0000000000000)
return __math_invalid(x);
/* x is subnormal, normalize it. */
ix = asuint64(x * 0x1p52);
top = ix >> 52;
top -= 52;
}
/* special case handling. */
ix = asuint64(x);
top = ix >> 52;
if (predict_false(top - 0x001 >= 0x7ff - 0x001)) {
/* x < 0x1p-1022 or inf or nan. */
if (ix * 2 == 0)
return x;
if (ix == 0x7ff0000000000000)
return x;
if (ix > 0x7ff0000000000000)
return __math_invalid(x);
/* x is subnormal, normalize it. */
ix = asuint64(x * 0x1p52);
top = ix >> 52;
top -= 52;
}
/* argument reduction:
/* argument reduction:
x = 4^e m; with integer e, and m in [1, 4)
m: fixed point representation [2.62]
2^e is the exponent part of the result. */
int even = top & 1;
m = (ix << 11) | 0x8000000000000000;
if(even)
m >>= 1;
top = (top + 0x3ff) >> 1;
int even = top & 1;
m = (ix << 11) | 0x8000000000000000;
if (even) m >>= 1;
top = (top + 0x3ff) >> 1;
/* approximate r ~ 1/sqrt(m) and s ~ sqrt(m) when m in [1,4)
/* approximate r ~ 1/sqrt(m) and s ~ sqrt(m) when m in [1,4)
initial estimate:
7bit table lookup (1bit exponent and 6bit significand).
@ -107,55 +105,54 @@ double sqrt(double x)
and after switching to 64 bit
m: 2.62 r: 0.64, s: 2.62, d: 2.62, u: 2.62, three: 2.62 */
static const uint64_t three = 0xc0000000;
uint64_t r, s, d, u, i;
static const uint64_t three = 0xc0000000;
uint64_t r, s, d, u, i;
i = (ix >> 46) % 128;
r = (uint32_t)__rsqrt_tab[i] << 16;
/* |r sqrt(m) - 1| < 0x1.fdp-9 */
s = mul32(m >> 32, r);
/* |s/sqrt(m) - 1| < 0x1.fdp-9 */
d = mul32(s, r);
u = three - d;
r = mul32(r, u) << 1;
/* |r sqrt(m) - 1| < 0x1.7bp-16 */
s = mul32(s, u) << 1;
/* |s/sqrt(m) - 1| < 0x1.7bp-16 */
d = mul32(s, r);
u = three - d;
r = mul32(r, u) << 1;
/* |r sqrt(m) - 1| < 0x1.3704p-29 (measured worst-case) */
r = r << 32;
s = mul64(m, r);
d = mul64(s, r);
u = (three << 32) - d;
s = mul64(s, u); /* repr: 3.61 */
/* -0x1p-57 < s - sqrt(m) < 0x1.8001p-61 */
s = (s - 2) >> 9; /* repr: 12.52 */
/* -0x1.09p-52 < s - sqrt(m) < -0x1.fffcp-63 */
i = (ix >> 46) % 128;
r = (uint32_t)__rsqrt_tab[i] << 16;
/* |r sqrt(m) - 1| < 0x1.fdp-9 */
s = mul32(m>>32, r);
/* |s/sqrt(m) - 1| < 0x1.fdp-9 */
d = mul32(s, r);
u = three - d;
r = mul32(r, u) << 1;
/* |r sqrt(m) - 1| < 0x1.7bp-16 */
s = mul32(s, u) << 1;
/* |s/sqrt(m) - 1| < 0x1.7bp-16 */
d = mul32(s, r);
u = three - d;
r = mul32(r, u) << 1;
/* |r sqrt(m) - 1| < 0x1.3704p-29 (measured worst-case) */
r = r << 32;
s = mul64(m, r);
d = mul64(s, r);
u = (three<<32) - d;
s = mul64(s, u); /* repr: 3.61 */
/* -0x1p-57 < s - sqrt(m) < 0x1.8001p-61 */
s = (s - 2) >> 9; /* repr: 12.52 */
/* -0x1.09p-52 < s - sqrt(m) < -0x1.fffcp-63 */
/* s < sqrt(m) < s + 0x1.09p-52,
/* s < sqrt(m) < s + 0x1.09p-52,
compute nearest rounded result:
the nearest result to 52 bits is either s or s+0x1p-52,
we can decide by comparing (2^52 s + 0.5)^2 to 2^104 m. */
uint64_t d0, d1, d2;
double y, t;
d0 = (m << 42) - s * s;
d1 = s - d0;
d2 = d1 + s + 1;
s += d1 >> 63;
s &= 0x000fffffffffffff;
s |= top << 52;
y = asdouble(s);
if(FENV_SUPPORT)
{
/* handle rounding modes and inexact exception:
uint64_t d0, d1, d2;
double y, t;
d0 = (m << 42) - s*s;
d1 = s - d0;
d2 = d1 + s + 1;
s += d1 >> 63;
s &= 0x000fffffffffffff;
s |= top << 52;
y = asdouble(s);
if (FENV_SUPPORT) {
/* handle rounding modes and inexact exception:
only (s+1)^2 == 2^42 m case is exact otherwise
add a tiny value to cause the fenv effects. */
uint64_t tiny = predict_false(d2 == 0) ? 0 : 0x0010000000000000;
tiny |= (d1 ^ d2) & 0x8000000000000000;
t = asdouble(tiny);
y = eval_as_double(y + t);
}
return y;
uint64_t tiny = predict_false(d2==0) ? 0 : 0x0010000000000000;
tiny |= (d1^d2) & 0x8000000000000000;
t = asdouble(tiny);
y = eval_as_double(y + t);
}
return y;
}

19
cstdlib/src/sqrt_data.c Normal file
View File

@ -0,0 +1,19 @@
#include "sqrt_data.h"
const uint16_t __rsqrt_tab[128] = {
0xb451,0xb2f0,0xb196,0xb044,0xaef9,0xadb6,0xac79,0xab43,
0xaa14,0xa8eb,0xa7c8,0xa6aa,0xa592,0xa480,0xa373,0xa26b,
0xa168,0xa06a,0x9f70,0x9e7b,0x9d8a,0x9c9d,0x9bb5,0x9ad1,
0x99f0,0x9913,0x983a,0x9765,0x9693,0x95c4,0x94f8,0x9430,
0x936b,0x92a9,0x91ea,0x912e,0x9075,0x8fbe,0x8f0a,0x8e59,
0x8daa,0x8cfe,0x8c54,0x8bac,0x8b07,0x8a64,0x89c4,0x8925,
0x8889,0x87ee,0x8756,0x86c0,0x862b,0x8599,0x8508,0x8479,
0x83ec,0x8361,0x82d8,0x8250,0x81c9,0x8145,0x80c2,0x8040,
0xff02,0xfd0e,0xfb25,0xf947,0xf773,0xf5aa,0xf3ea,0xf234,
0xf087,0xeee3,0xed47,0xebb3,0xea27,0xe8a3,0xe727,0xe5b2,
0xe443,0xe2dc,0xe17a,0xe020,0xdecb,0xdd7d,0xdc34,0xdaf1,
0xd9b3,0xd87b,0xd748,0xd61a,0xd4f1,0xd3cd,0xd2ad,0xd192,
0xd07b,0xcf69,0xce5b,0xcd51,0xcc4a,0xcb48,0xca4a,0xc94f,
0xc858,0xc764,0xc674,0xc587,0xc49d,0xc3b7,0xc2d4,0xc1f4,
0xc116,0xc03c,0xbf65,0xbe90,0xbdbe,0xbcef,0xbc23,0xbb59,
0xba91,0xb9cc,0xb90a,0xb84a,0xb78c,0xb6d0,0xb617,0xb560,
};

83
cstdlib/src/sqrtf.c Normal file
View File

@ -0,0 +1,83 @@
#include <stdint.h>
#include <math.h>
#include "libm.h"
#include "sqrt_data.h"
#define FENV_SUPPORT 1
static inline uint32_t mul32(uint32_t a, uint32_t b)
{
return (uint64_t)a*b >> 32;
}
/* see sqrt.c for more detailed comments. */
float sqrtf(float x)
{
uint32_t ix, m, m1, m0, even, ey;
ix = asuint(x);
if (predict_false(ix - 0x00800000 >= 0x7f800000 - 0x00800000)) {
/* x < 0x1p-126 or inf or nan. */
if (ix * 2 == 0)
return x;
if (ix == 0x7f800000)
return x;
if (ix > 0x7f800000)
return __math_invalidf(x);
/* x is subnormal, normalize it. */
ix = asuint(x * 0x1p23f);
ix -= 23 << 23;
}
/* x = 4^e m; with int e and m in [1, 4). */
even = ix & 0x00800000;
m1 = (ix << 8) | 0x80000000;
m0 = (ix << 7) & 0x7fffffff;
m = even ? m0 : m1;
/* 2^e is the exponent part of the return value. */
ey = ix >> 1;
ey += 0x3f800000 >> 1;
ey &= 0x7f800000;
/* compute r ~ 1/sqrt(m), s ~ sqrt(m) with 2 goldschmidt iterations. */
static const uint32_t three = 0xc0000000;
uint32_t r, s, d, u, i;
i = (ix >> 17) % 128;
r = (uint32_t)__rsqrt_tab[i] << 16;
/* |r*sqrt(m) - 1| < 0x1p-8 */
s = mul32(m, r);
/* |s/sqrt(m) - 1| < 0x1p-8 */
d = mul32(s, r);
u = three - d;
r = mul32(r, u) << 1;
/* |r*sqrt(m) - 1| < 0x1.7bp-16 */
s = mul32(s, u) << 1;
/* |s/sqrt(m) - 1| < 0x1.7bp-16 */
d = mul32(s, r);
u = three - d;
s = mul32(s, u);
/* -0x1.03p-28 < s/sqrt(m) - 1 < 0x1.fp-31 */
s = (s - 1)>>6;
/* s < sqrt(m) < s + 0x1.08p-23 */
/* compute nearest rounded result. */
uint32_t d0, d1, d2;
float y, t;
d0 = (m << 16) - s*s;
d1 = s - d0;
d2 = d1 + s + 1;
s += d1 >> 31;
s &= 0x007fffff;
s |= ey;
y = asfloat(s);
if (FENV_SUPPORT) {
/* handle rounding and inexact exception. */
uint32_t tiny = predict_false(d2==0) ? 0 : 0x01000000;
tiny |= (d1^d2) & 0x80000000;
t = asfloat(tiny);
y = eval_as_float(y + t);
}
return y;
}

View File

@ -1,217 +0,0 @@
--------
**DISCLAIMER: This project is very much a Work In Progress. We're making it accessible in this very early state so that participants to the [Wheel Reinvention Jam 2023](https://handmade.network/jam/2023) can try it out and maybe use it as their jamming platform. Expect bugs, missing and/or incomplete features, unstable APIs, and sparse documentation. Some current issues might be a show stopper for you, so make sure you can build and run the sample apps before jumping in.**
**If you do choose to try out Orca anyway, well thanks! We'll do our best to answer your questions, and we'd really appreciate to hear your feedback!**
--------
# Orca Quick Start Guide
This is a short introduction to developing an application that can be run by the Orca runtime. We'll present the basic structure of an Orca application, and walk through a simple example in C.
## What is an Orca app?
An Orca app is a WebAssembly module designed for the Orca runtime. Your app interacts with the Orca runtime via WebAssembly imports and exports. For example, you can import functions from the Orca runtime to get user input, and export functions to the Orca runtime to draw to the screen.
Orca also ships with a core library, written in C, which facilitates interaction with the Orca runtime and provides features like UI. This library should be compiled along with your app as part of producing your WebAssembly module.
You can, in principle, write an Orca app in any programming language that supports WebAssembly. However, at this early stage, C is the only officially supported language.
![Basic structure of a C app](images/app_c.png)
Once you have compiled your WebAssembly module, you can bundle this module into an executable using the `orca bundle` command. The application bundle can include images, fonts, or any other private data that the app needs in order to function. These files can be read or written from the app without asking the user for permission. The resulting Orca executables are therefore self-contained.
![Example Orca application bundle](images/app_bundle.png)
## Basic structure
Orca exposes a number of types and functions to applications. In order to use them the first thing to do is to include `orca.h`.
```c
#include<orca.h>
```
The Orca runtime manages the application's window and event loop. In order to receive a specific kind of event, you can define an associated _event handler_ and export it to the runtime. For instance, to be notified when your application's window is resized, you should define the `oc_on_resize()` handler:
```c
ORCA_EXPORT void oc_on_resize(u32 width, u32 height)
{
// handle the window resize event
}
```
The `ORCA_EXPORT` macro makes the handler visible to the Orca runtime, which automatically binds it to the window resize event.
Handlers are optional. If you don't care about an event, you can just omit the associated handler. However, you will almost certainly want to define at least two important handlers:
- `oc_on_init()` is called once when your application starts and can be use to initialize your application's resources.
- `oc_on_frame_refresh()` is called when your application needs to render a new frame, typically tied to the refresh rate of the monitor.
For a list of available handlers and their signatures, see the [app cheatsheet](../doc/cheatsheets/cheatsheet_app.h).
## Clock example
Let's look at the [clock example](../samples/clock). This is a simple app that shows an analog clock and showcases a couple of interesting Orca APIs.
Open [`main.c`](../samples/clock/src/main.c) and look at the definition of `oc_on_init()`. This handler is called when the application starts, right after the application window has been created.
The first thing we do here is set the title and dimensions of the window. We then create the graphics resources that we'll use to draw the clock onto the window.
```c
ORCA_EXPORT void oc_on_init(void)
{
oc_window_set_title(OC_STR8("clock"));
oc_window_set_size((oc_vec2){ .x = 400, .y = 400 });
// ...
}
```
### Graphics surfaces
The next line of `oc_on_init()` creates a _graphics surface_. A surface represents a destination you can draw into using a specific API. In this sample, we're going to use a canvas surface, which allows drawing with a 2D vector graphics API. Other samples use a GLES surface to draw with the OpenGL ES API.
Before drawing into it, the surface must be selected as the current surface by calling `oc_surface_select()`. Once all drawing is done you can display the result by calling `oc_surface_present()`.
```c
oc_surface surface = { 0 };
oc_canvas canvas = { 0 };
ORCA_EXPORT void oc_on_init(void)
{
// ...
surface = oc_surface_canvas();
canvas = oc_canvas_create();
// ...
}
```
### Canvas
After creating the surface, we create a _canvas_. A canvas holds some context for drawing commands, like the current color or stroke width, as well as a command buffer that records all drawing commands. All canvas drawing functions use an implicit _current canvas_. You can select a canvas to be the current canvas by calling `oc_canvas_select()`, as seen at the begining of `oc_on_frame_refresh()`.
Canvas drawing functions like `oc_fill()` or `oc_stroke` merely add to the current canvas command buffer. You can later render those commands onto a canvas surface by calling `oc_render()`.
To summarize, the general structure of canvas drawing code is like the following:
```c
ORCA_EXPORT void oc_on_frame_refresh(void)
{
oc_canvas_select(canvas); // make the canvas current
//... add commands to the canvas command buffer using drawing functions
oc_surface_select(surface); // select the canvas surface
oc_render(canvas); // render the canvas commands into it
oc_surface_present(surface); // display the result
}
```
### Drawing
Canvas drawing functions can be roughly divided into three groups:
- Path functions like `oc_line_to()` or `oc_cubic_to()` are used to specify paths using lines and curves.
- Attribute setup functions like `oc_set_color()` or `oc_set_width()` are used to set attributes used by subsequent commands.
- Command functions like `oc_stroke()` and `oc_fill()` encode commands into the canvas command buffer using the current path and attributes.
Some helpers combine a path specification and a command, like `oc_circle_fill()`.
As an example, the back of the clock is drawn using these two calls:
```c
oc_set_color_rgba(1, 1, 1, 1);
oc_circle_fill(centerX, centerY, clockRadius);
```
For a list of canvas drawing functions, see the [graphics API cheatsheet](../doc/cheatsheets/cheatsheet_graphics.h).
#### Transforms
A special case of attribute setting function is the pair `oc_matrix_multiply_push()` and `oc_matrix_pop()`, which are used to manipulate a stack of transform matrices:
- `oc_matrix_multiply_push()` multiplies the matrix currently on top of the stack with its argument, and pushes the result on the stack.
- `oc_matrix_pop()` pops a matrix from the stack.
The matrix on the top of the stack at the time a command is encoded is used to transform the path of that command.
You can see an example of using transform matrices when drawing the clock's hands:
```c
// hour hand
oc_matrix_multiply_push(mat_transform(centerX, centerY, hoursRotation));
{
oc_set_color_rgba(.2, 0.2, 0.2, 1);
oc_rounded_rectangle_fill(0, -7.5 * uiScale, clockRadius * 0.5f, 15 * uiScale, 5 * uiScale);
}
oc_matrix_pop();
```
### Fonts and text
Going back to `oc_init()`, after creating a surface and a canvas, we create a font that we will use to draw the numbers on the clock's face:
```c
oc_unicode_range ranges[5] = {
OC_UNICODE_BASIC_LATIN,
OC_UNICODE_C1_CONTROLS_AND_LATIN_1_SUPPLEMENT,
OC_UNICODE_LATIN_EXTENDED_A,
OC_UNICODE_LATIN_EXTENDED_B,
OC_UNICODE_SPECIALS
};
font = oc_font_create_from_path(OC_STR8("/segoeui.ttf"), 5, ranges);
```
The font is loaded from a font file located in a data folder inside the app bundle. By default, Orca apps use this data folder as their "root" for file operations.
Along with the path of the font file, we pass to the creation function the unicode ranges we want to load.
We then use the font to draw the clock's face:
```c
// clock face
for(int i = 0; i < oc_array_size(clockNumberStrings); ++i)
{
oc_rect textRect = oc_font_text_metrics(font, fontSize, clockNumberStrings[i]).ink;
const f32 angle = i * ((M_PI * 2) / 12.0f) - (M_PI / 2);
oc_mat2x3 transform = mat_transform(centerX - (textRect.w / 2) - textRect.x,
centerY - (textRect.h / 2) - textRect.y,
angle);
oc_vec2 pos = oc_mat2x3_mul(transform, (oc_vec2){ clockRadius * 0.8f, 0 });
oc_set_color_rgba(0.2, 0.2, 0.2, 1);
oc_text_fill(pos.x, pos.y, clockNumberStrings[i]);
}
```
### Logging and asserts
The runtime has a console overlay whose visiblity can be toggled on and off with `⌘ + Shift + D` on macOS, or `Ctrl + Shift + D` on Windows. Your application can log messages, warnings, or errors to that console using the following functions:
```c
void oc_log_info(const char* fmt, ...); // informational messages
void oc_log_warning(const char* fmt, ...); // warnings, displayed in orange.
void oc_log_error(const char* fmt, ...); // errors, displayed in red.
```
If you started the application from a terminal, the log entries are also duplicated there.
You can assert on a condition using `OC_ASSERT(test, fmt, ...)`. If the test fails, the runtime displays a message box and terminates the application.
You can unconditionally abort the application with a message box using `OC_ABORT(fmt, ...)`.
## Where to go next?
For more examples of how to use Orca APIs, you can look at the other [sample apps](../samples):
- [breakout](../samples/breakout) is a mini breakout game making use of the vector graphics API. It demonstrates using input and drawing images.
- [triangle](../samples/triangle) shows how to draw a spining triangle using the GLES API.
- [fluid](../samples/fluid) is a fluid simulation using a more complex GLES setup.
- [ui](../samples/ui) showcases the UI API and Orca's default UI widgets.
For a list of Orca APIs, you can look at the [API cheatsheets](../doc/cheatsheets).
You can also ask questions in the [Handmade Network Discord](https://discord.gg/hmn), in particular in the [#orca](https://discord.com/channels/239737791225790464/1121811864066732082) channel.

View File

@ -1,7 +0,0 @@
# UI Colors
## Dark (default theme)
![Dark theme colors](images/UIDarkPalette.svg)
## Light
![Light theme colors](images/UILightPalette.svg)

View File

@ -1,35 +0,0 @@
/************************************************************/ /**
*
* @file: cheatsheet_app.h
* @author: Martin Fouilleul
* @date: 05/09/2023
*
*****************************************************************/
//----------------------------------------------------------------
// Handlers (can be defined by your app to respond to events)
//----------------------------------------------------------------
void oc_on_init(void);
void oc_on_mouse_down(oc_mouse_button button);
void oc_on_mouse_up(oc_mouse_button button);
void oc_on_mouse_enter(void);
void oc_on_mouse_leave(void);
void oc_on_mouse_move(f32 x, f32 y, f32 deltaX, f32 deltaY);
void oc_on_mouse_wheel(f32 deltaX, f32 deltaY);
void oc_on_key_down(oc_scan_code scan, oc_key_code key);
void oc_on_key_up(oc_scan_code scan, oc_key_code key);
void oc_on_frame_refresh(void);
void oc_on_resize(f32 width, f32 height);
void oc_on_raw_event(oc_event* event);
void oc_on_terminate(void);
//----------------------------------------------------------------
// Window
//----------------------------------------------------------------
void oc_window_set_title(oc_str8 title);
void oc_window_set_size(oc_vec2 size);
//----------------------------------------------------------------
// Quitting
//----------------------------------------------------------------
void oc_request_quit(void)

View File

@ -1,166 +0,0 @@
/************************************************************/ /**
*
* @file: cheatsheet_graphics.h
* @author: Martin Fouilleul
* @date: 05/09/2023
*
*****************************************************************/
//------------------------------------------------------------------------------------------
// graphics surface
//------------------------------------------------------------------------------------------
oc_surface oc_surface_nil(void);
bool oc_surface_is_nil(oc_surface surface);
oc_surface oc_surface_canvas();
oc_surface oc_surface_gles();
void oc_surface_destroy(oc_surface surface);
void oc_surface_select(oc_surface surface);
void oc_surface_deselect(void);
void oc_surface_present(oc_surface surface);
oc_vec2 oc_surface_get_size(oc_surface surface);
oc_vec2 oc_surface_contents_scaling(oc_surface surface);
void oc_surface_bring_to_front(oc_surface surface);
void oc_surface_send_to_back(oc_surface surface);
//------------------------------------------------------------------------------------------
// 2D canvas command buffer
//------------------------------------------------------------------------------------------
oc_canvas oc_canvas_nil(void);
bool oc_canvas_is_nil(oc_canvas canvas);
oc_canvas oc_canvas_create(void);
void oc_canvas_destroy(oc_canvas canvas);
oc_canvas oc_canvas_set_current(oc_canvas canvas);
void oc_render(oc_canvas canvas);
//------------------------------------------------------------------------------------------
// transform and clipping
//------------------------------------------------------------------------------------------
void oc_matrix_push(oc_mat2x3 matrix);
void oc_matrix_multiply_push(oc_mat2x3 matrix);
void oc_matrix_pop(void);
oc_mat2x3 oc_matrix_top();
void oc_clip_push(f32 x, f32 y, f32 w, f32 h);
void oc_clip_pop(void);
oc_rect oc_clip_top();
//------------------------------------------------------------------------------------------
// graphics attributes setting/getting
//------------------------------------------------------------------------------------------
void oc_set_color(oc_color color);
void oc_set_color_rgba(f32 r, f32 g, f32 b, f32 a);
void oc_set_width(f32 width);
void oc_set_tolerance(f32 tolerance);
void oc_set_joint(oc_joint_type joint);
void oc_set_max_joint_excursion(f32 maxJointExcursion);
void oc_set_cap(oc_cap_type cap);
void oc_set_font(oc_font font);
void oc_set_font_size(f32 size);
void oc_set_text_flip(bool flip);
void oc_set_image(oc_image image);
void oc_set_image_source_region(oc_rect region);
oc_color oc_get_color(void);
f32 oc_get_width(void);
f32 oc_get_tolerance(void);
oc_joint_type oc_get_joint(void);
f32 oc_get_max_joint_excursion(void);
oc_cap_type oc_get_cap(void);
oc_font oc_get_font(void);
f32 oc_get_font_size(void);
bool oc_get_text_flip(void);
oc_image oc_get_image();
//------------------------------------------------------------------------------------------
// path construction
//------------------------------------------------------------------------------------------
oc_vec2 oc_get_position(void);
void oc_move_to(f32 x, f32 y);
void oc_line_to(f32 x, f32 y);
void oc_quadratic_to(f32 x1, f32 y1, f32 x2, f32 y2);
void oc_cubic_to(f32 x1, f32 y1, f32 x2, f32 y2, f32 x3, f32 y3);
void oc_close_path(void);
oc_rect oc_glyph_outlines(oc_str32 glyphIndices);
void oc_codepoints_outlines(oc_str32 string);
void oc_text_outlines(oc_str8 string);
//------------------------------------------------------------------------------------------
// clear/fill/stroke
//------------------------------------------------------------------------------------------
void oc_clear(void);
void oc_fill(void);
void oc_stroke(void);
//------------------------------------------------------------------------------------------
// shapes helpers
//------------------------------------------------------------------------------------------
void oc_rectangle_fill(f32 x, f32 y, f32 w, f32 h);
void oc_rectangle_stroke(f32 x, f32 y, f32 w, f32 h);
void oc_rounded_rectangle_fill(f32 x, f32 y, f32 w, f32 h, f32 r);
void oc_rounded_rectangle_stroke(f32 x, f32 y, f32 w, f32 h, f32 r);
void oc_ellipse_fill(f32 x, f32 y, f32 rx, f32 ry);
void oc_ellipse_stroke(f32 x, f32 y, f32 rx, f32 ry);
void oc_circle_fill(f32 x, f32 y, f32 r);
void oc_circle_stroke(f32 x, f32 y, f32 r);
void oc_arc(f32 x, f32 y, f32 r, f32 arcAngle, f32 startAngle);
void oc_image_draw(oc_image image, oc_rect rect);
void oc_image_draw_region(oc_image image, oc_rect srcRegion, oc_rect dstRegion);
//------------------------------------------------------------------------------------------
// fonts
//------------------------------------------------------------------------------------------
oc_font oc_font_nil(void);
bool oc_font_is_nil(oc_font font);
oc_font oc_font_create_from_memory(oc_str8 mem, u32 rangeCount, oc_unicode_range* ranges);
oc_font oc_font_create_from_file(oc_file file, u32 rangeCount, oc_unicode_range* ranges);
oc_font oc_font_create_from_path(oc_str8 path, u32 rangeCount, oc_unicode_range* ranges);
void oc_font_destroy(oc_font font);
oc_str32 oc_font_get_glyph_indices(oc_font font, oc_str32 codePoints, oc_str32 backing);
oc_str32 oc_font_push_glyph_indices(oc_arena* arena, oc_font font, oc_str32 codePoints);
u32 oc_font_get_glyph_index(oc_font font, oc_utf32 codePoint);
oc_font_metrics oc_font_get_metrics(oc_font font, f32 emSize);
oc_font_metrics oc_font_get_metrics_unscaled(oc_font font);
f32 oc_font_get_scale_for_em_pixels(oc_font font, f32 emSize);
oc_text_metrics oc_font_text_metrics_utf32(oc_font font, f32 fontSize, oc_str32 codepoints);
oc_text_metrics oc_font_text_metrics(oc_font font, f32 fontSize, oc_str8 text);
//------------------------------------------------------------------------------------------
// images
//------------------------------------------------------------------------------------------
oc_image oc_image_nil(void);
bool oc_image_is_nil(oc_image a);
oc_image oc_image_create(oc_surface surface, u32 width, u32 height);
oc_image oc_image_create_from_rgba8(oc_surface surface, u32 width, u32 height, u8* pixels);
oc_image oc_image_create_from_memory(oc_surface surface, oc_str8 mem, bool flip);
oc_image oc_image_create_from_file(oc_surface surface, oc_file file, bool flip);
oc_image oc_image_create_from_path(oc_surface surface, oc_str8 path, bool flip);
void oc_image_destroy(oc_image image);
void oc_image_upload_region_rgba8(oc_image image, oc_rect region, u8* pixels);
oc_vec2 oc_image_size(oc_image image);
//------------------------------------------------------------------------------------------
// image atlas
//------------------------------------------------------------------------------------------
oc_rect_atlas* oc_rect_atlas_create(oc_arena* arena, i32 width, i32 height);
oc_rect oc_rect_atlas_alloc(oc_rect_atlas* atlas, i32 width, i32 height);
void oc_rect_atlas_recycle(oc_rect_atlas* atlas, oc_rect rect);
oc_image_region oc_image_atlas_alloc_from_rgba8(oc_rect_atlas* atlas, oc_image backingImage, u32 width, u32 height, u8* pixels);
oc_image_region oc_image_atlas_alloc_from_memory(oc_rect_atlas* atlas, oc_image backingImage, oc_str8 mem, bool flip);
oc_image_region oc_image_atlas_alloc_from_file(oc_rect_atlas* atlas, oc_image backingImage, oc_file file, bool flip);
oc_image_region oc_image_atlas_alloc_from_path(oc_rect_atlas* atlas, oc_image backingImage, oc_str8 path, bool flip);
void oc_image_atlas_recycle(oc_rect_atlas* atlas, oc_image_region imageRgn);

View File

@ -1,39 +0,0 @@
/************************************************************/ /**
*
* @file: cheatsheet_io.h
* @author: Martin Fouilleul
* @date: 05/09/2023
*
*****************************************************************/
//----------------------------------------------------------------
// Low-level File IO API
//----------------------------------------------------------------
oc_io_cmp oc_io_wait_single_req(oc_io_req* req);
//----------------------------------------------------------------
// High-level File IO API
//----------------------------------------------------------------
oc_file oc_file_nil();
bool oc_file_is_nil(oc_file handle);
oc_file oc_file_open(oc_str8 path, oc_file_access rights, oc_file_open_flags flags);
oc_file oc_file_open_at(oc_file dir, oc_str8 path, oc_file_access rights, oc_file_open_flags flags);
void oc_file_close(oc_file file);
oc_io_error oc_file_last_error(oc_file handle);
i64 oc_file_pos(oc_file file);
i64 oc_file_seek(oc_file file, i64 offset, oc_file_whence whence);
u64 oc_file_write(oc_file file, u64 size, char* buffer);
u64 oc_file_read(oc_file file, u64 size, char* buffer);
oc_file_status oc_file_get_status(oc_file file);
u64 oc_file_size(oc_file file);
//----------------------------------------------------------------
// Asking users for file capabilities
//----------------------------------------------------------------
oc_file oc_file_open_with_request(oc_str8 path, oc_file_access rights, oc_file_open_flags flags);
oc_file_open_with_dialog_result oc_file_open_with_dialog(oc_arena* arena, oc_file_access rights, oc_file_open_flags flags, oc_file_dialog_desc* desc);

View File

@ -1,64 +0,0 @@
/************************************************************/ /**
*
* @file: cheatsheet_ui.h
* @author: Martin Fouilleul
* @date: 05/09/2023
*
*****************************************************************/
//----------------------------------------------------------------
// Context and frame lifecycle
//----------------------------------------------------------------
void oc_ui_init(oc_ui_context* context);
oc_ui_context* oc_ui_get_context(void);
void oc_ui_set_context(oc_ui_context* context);
void oc_ui_process_event(oc_event* event);
void oc_ui_begin_frame(oc_vec2 size, oc_ui_style* defaultStyle, oc_ui_style_mask mask);
void oc_ui_end_frame(void);
void oc_ui_draw(void);
#define oc_ui_frame(size, style, mask)
//----------------------------------------------------------------
// Common widget helpers
//----------------------------------------------------------------
oc_ui_sig oc_ui_label(const char* label);
oc_ui_sig oc_ui_label_str8(oc_str8 label);
oc_ui_sig oc_ui_button(const char* label);
oc_ui_sig oc_ui_checkbox(const char* name, bool* checked);
oc_ui_box* oc_ui_slider(const char* label, f32 thumbRatio, f32* scrollValue);
oc_ui_text_box_result oc_ui_text_box(const char* name, oc_arena* arena, oc_str8 text);
oc_ui_select_popup_info oc_ui_select_popup(const char* name, oc_ui_select_popup_info* info);
void oc_ui_panel_begin(const char* name, oc_ui_flags flags);
void oc_ui_panel_end(void);
#define oc_ui_panel(s, f)
void oc_ui_menu_bar_begin(const char* label);
void oc_ui_menu_bar_end(void);
#define oc_ui_menu_bar(name)
void oc_ui_menu_begin(const char* label);
void oc_ui_menu_end(void);
#define oc_ui_menu(name)
oc_ui_sig oc_ui_menu_button(const char* name);
oc_ui_sig oc_ui_tooltip_begin(const char* name);
void oc_ui_tooltip_end(void);
#define oc_ui_tooltip(name)
//-------------------------------------------------------------------------------------
// Styling
//-------------------------------------------------------------------------------------
void oc_ui_style_next(oc_ui_style* style, oc_ui_style_mask mask);
void oc_ui_pattern_push(oc_arena* arena, oc_ui_pattern* pattern, oc_ui_selector selector);
oc_ui_pattern oc_ui_pattern_all(void);
oc_ui_pattern oc_ui_pattern_owner(void);
void oc_ui_style_match_before(oc_ui_pattern pattern, oc_ui_style* style, oc_ui_style_mask mask);
void oc_ui_style_match_after(oc_ui_pattern pattern, oc_ui_style* style, oc_ui_style_mask mask);

View File

@ -1,101 +0,0 @@
/************************************************************/ /**
*
* @file: cheatsheet_util.h
* @author: Martin Fouilleul
* @date: 05/09/2023
*
*****************************************************************/
//----------------------------------------------------------------
// Arenas
//----------------------------------------------------------------
void oc_arena_init(oc_arena* arena);
void oc_arena_init_with_options(oc_arena* arena, oc_arena_options* options);
void oc_arena_cleanup(oc_arena* arena);
void* oc_arena_push(oc_arena* arena, u64 size);
#define oc_arena_push_type(arena, type)
#define oc_arena_push_array(arena, type, count)
void oc_arena_clear(oc_arena* arena);
oc_arena_scope oc_arena_scope_begin(oc_arena* arena);
void oc_arena_scope_end(oc_arena_scope scope);
oc_arena_scope oc_scratch_begin(void);
oc_arena_scope oc_scratch_begin_next(oc_arena* used);
#define oc_scratch_end(scope)
//----------------------------------------------------------------
// Lists
//----------------------------------------------------------------
void oc_list_init(oc_list* list);
bool oc_list_empty(oc_list* list);
oc_list_elt* oc_list_begin(oc_list* list);
oc_list_elt* oc_list_end(oc_list* list);
oc_list_elt* oc_list_last(oc_list* list);
#define oc_list_next(elt)
#define oc_list_prev(elt)
#define oc_list_entry(ptr, type, member)
#define oc_list_next_entry(list, elt, type, member)
#define oc_list_prev_entry(list, elt, type, member)
#define oc_list_first_entry(list, type, member)
#define oc_list_last_entry(list, type, member)
#define oc_list_pop_entry(list, type, member)
void oc_list_insert(oc_list* list, oc_list_elt* afterElt, oc_list_elt* elt);
void oc_list_insert_before(oc_list* list, oc_list_elt* beforeElt, oc_list_elt* elt);
void oc_list_remove(oc_list* list, oc_list_elt* elt);
void oc_list_push(oc_list* list, oc_list_elt* elt);
oc_list_elt* oc_list_pop(oc_list* list);
void oc_list_push_back(oc_list* list, oc_list_elt* elt);
oc_list_elt* oc_list_pop_back(oc_list* list);
#define oc_list_for(list, elt, type, member)
#define oc_list_for_reverse(list, elt, type, member)
#define oc_list_for_safe(list, elt, type, member)
//----------------------------------------------------------------
// Strings / string lists / path strings
//----------------------------------------------------------------
oc_str8 oc_str8_from_buffer(u64 len, char* buffer);
oc_str8 oc_str8_slice(oc_str8 s, u64 start, u64 end);
oc_str8 oc_str8_push_buffer(oc_arena* arena, u64 len, char* buffer);
oc_str8 oc_str8_push_cstring(oc_arena* arena, const char* str);
oc_str8 oc_str8_push_copy(oc_arena* arena, oc_str8 s);
oc_str8 oc_str8_push_slice(oc_arena* arena, oc_str8 s, u64 start, u64 end);
oc_str8 oc_str8_pushfv(oc_arena* arena, const char* format, va_list args);
oc_str8 oc_str8_pushf(oc_arena* arena, const char* format, ...);
int oc_str8_cmp(oc_str8 s1, oc_str8 s2);
char* oc_str8_to_cstring(oc_arena* arena, oc_str8 string);
void oc_str8_list_push(oc_arena* arena, oc_str8_list* list, oc_str8 str);
void oc_str8_list_pushf(oc_arena* arena, oc_str8_list* list, const char* format, ...);
oc_str8 oc_str8_list_collate(oc_arena* arena, oc_str8_list list, oc_str8 prefix, oc_str8 separator, oc_str8 postfix);
oc_str8 oc_str8_list_join(oc_arena* arena, oc_str8_list list);
oc_str8_list oc_str8_split(oc_arena* arena, oc_str8 str, oc_str8_list separators);
oc_str8 oc_path_slice_directory(oc_str8 path);
oc_str8 oc_path_slice_filename(oc_str8 path);
oc_str8_list oc_path_split(oc_arena* arena, oc_str8 path);
oc_str8 oc_path_join(oc_arena* arena, oc_str8_list elements);
oc_str8 oc_path_append(oc_arena* arena, oc_str8 parent, oc_str8 relPath);
bool oc_path_is_absolute(oc_str8 path);
//----------------------------------------------------------------
// Debugging
//----------------------------------------------------------------
#define oc_log_info(message, ...)
#define oc_log_warning(message, ...)
#define oc_log_error(message, ...)
#define OC_ASSERT(test, message, ...)
#define OC_ABORT(message, ...)

View File

@ -1,500 +0,0 @@
<?xml version="1.0"?>
<!-- Generated by SVGo -->
<svg width="1200" height="1050"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<style type="text/css">
<![CDATA[
text {
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"
}
]]>
</style>
<rect x="0" y="0" width="150" height="50" style="fill: #6C090B" />
<text x="5" y="29" style="font-size: 16px; fill: #fff3ef" >red0</text>
<text x="5" y="45" style="font-size: 12px; fill: #fff3ef" >#6C090B</text>
<rect x="0" y="50" width="150" height="50" style="fill: #901110" />
<text x="5" y="79" style="font-size: 16px; fill: #fff3ef" >red1</text>
<text x="5" y="95" style="font-size: 12px; fill: #fff3ef" >#901110</text>
<rect x="0" y="100" width="150" height="50" style="fill: #B42019" />
<text x="5" y="129" style="font-size: 16px; fill: #fff3ef" >red2</text>
<text x="5" y="145" style="font-size: 12px; fill: #fff3ef" >#B42019</text>
<rect x="0" y="150" width="150" height="50" style="fill: #D73324" />
<text x="5" y="179" style="font-size: 16px; fill: #fff3ef" >red3</text>
<text x="5" y="195" style="font-size: 12px; fill: #fff3ef" >#D73324</text>
<rect x="0" y="200" width="150" height="50" style="fill: #FB4932" />
<text x="5" y="229" style="font-size: 16px; fill: #fff3ef" >red4</text>
<text x="5" y="245" style="font-size: 12px; fill: #fff3ef" >#FB4932</text>
<rect x="0" y="250" width="150" height="50" style="fill: #FC725A" />
<text x="5" y="279" style="font-size: 16px; fill: #6c090b" >red5</text>
<text x="5" y="295" style="font-size: 12px; fill: #6c090b" >#FC725A</text>
<rect x="0" y="300" width="150" height="50" style="fill: #FD9983" />
<text x="5" y="329" style="font-size: 16px; fill: #6c090b" >red6</text>
<text x="5" y="345" style="font-size: 12px; fill: #6c090b" >#FD9983</text>
<rect x="0" y="350" width="150" height="50" style="fill: #FDBEAC" />
<text x="5" y="379" style="font-size: 16px; fill: #6c090b" >red7</text>
<text x="5" y="395" style="font-size: 12px; fill: #6c090b" >#FDBEAC</text>
<rect x="0" y="400" width="150" height="50" style="fill: #FEE0D5" />
<text x="5" y="429" style="font-size: 16px; fill: #6c090b" >red8</text>
<text x="5" y="445" style="font-size: 12px; fill: #6c090b" >#FEE0D5</text>
<rect x="0" y="450" width="150" height="50" style="fill: #FFF3EF" />
<text x="5" y="479" style="font-size: 16px; fill: #6c090b" >red9</text>
<text x="5" y="495" style="font-size: 12px; fill: #6c090b" >#FFF3EF</text>
<rect x="150" y="0" width="150" height="50" style="fill: #551F03" />
<text x="155" y="29" style="font-size: 16px; fill: #fff9ed" >orange0</text>
<text x="155" y="45" style="font-size: 12px; fill: #fff9ed" >#551F03</text>
<rect x="150" y="50" width="150" height="50" style="fill: #803506" />
<text x="155" y="79" style="font-size: 16px; fill: #fff9ed" >orange1</text>
<text x="155" y="95" style="font-size: 12px; fill: #fff9ed" >#803506</text>
<rect x="150" y="100" width="150" height="50" style="fill: #AA500A" />
<text x="155" y="129" style="font-size: 16px; fill: #fff9ed" >orange2</text>
<text x="155" y="145" style="font-size: 12px; fill: #fff9ed" >#AA500A</text>
<rect x="150" y="150" width="150" height="50" style="fill: #D56F0F" />
<text x="155" y="179" style="font-size: 16px; fill: #fff9ed" >orange3</text>
<text x="155" y="195" style="font-size: 12px; fill: #fff9ed" >#D56F0F</text>
<rect x="150" y="200" width="150" height="50" style="fill: #FF9214" />
<text x="155" y="229" style="font-size: 16px; fill: #fff9ed" >orange4</text>
<text x="155" y="245" style="font-size: 12px; fill: #fff9ed" >#FF9214</text>
<rect x="150" y="250" width="150" height="50" style="fill: #FFAE43" />
<text x="155" y="279" style="font-size: 16px; fill: #551f03" >orange5</text>
<text x="155" y="295" style="font-size: 12px; fill: #551f03" >#FFAE43</text>
<rect x="150" y="300" width="150" height="50" style="fill: #FFC772" />
<text x="155" y="329" style="font-size: 16px; fill: #551f03" >orange6</text>
<text x="155" y="345" style="font-size: 12px; fill: #551f03" >#FFC772</text>
<rect x="150" y="350" width="150" height="50" style="fill: #FFDDA1" />
<text x="155" y="379" style="font-size: 16px; fill: #551f03" >orange7</text>
<text x="155" y="395" style="font-size: 12px; fill: #551f03" >#FFDDA1</text>
<rect x="150" y="400" width="150" height="50" style="fill: #FFEFD0" />
<text x="155" y="429" style="font-size: 16px; fill: #551f03" >orange8</text>
<text x="155" y="445" style="font-size: 12px; fill: #551f03" >#FFEFD0</text>
<rect x="150" y="450" width="150" height="50" style="fill: #FFF9ED" />
<text x="155" y="479" style="font-size: 16px; fill: #551f03" >orange9</text>
<text x="155" y="495" style="font-size: 12px; fill: #551f03" >#FFF9ED</text>
<rect x="300" y="0" width="150" height="50" style="fill: #512E09" />
<text x="305" y="29" style="font-size: 16px; fill: #fefbed" >amber0</text>
<text x="305" y="45" style="font-size: 12px; fill: #fefbed" >#512E09</text>
<rect x="300" y="50" width="150" height="50" style="fill: #794B0F" />
<text x="305" y="79" style="font-size: 16px; fill: #fefbed" >amber1</text>
<text x="305" y="95" style="font-size: 12px; fill: #fefbed" >#794B0F</text>
<rect x="300" y="100" width="150" height="50" style="fill: #A16B16" />
<text x="305" y="129" style="font-size: 16px; fill: #fefbed" >amber2</text>
<text x="305" y="145" style="font-size: 12px; fill: #fefbed" >#A16B16</text>
<rect x="300" y="150" width="150" height="50" style="fill: #CA8F1E" />
<text x="305" y="179" style="font-size: 16px; fill: #fefbed" >amber3</text>
<text x="305" y="195" style="font-size: 12px; fill: #fefbed" >#CA8F1E</text>
<rect x="300" y="200" width="150" height="50" style="fill: #F2B726" />
<text x="305" y="229" style="font-size: 16px; fill: #fefbed" >amber4</text>
<text x="305" y="245" style="font-size: 12px; fill: #fefbed" >#F2B726</text>
<rect x="300" y="250" width="150" height="50" style="fill: #F5CA50" />
<text x="305" y="279" style="font-size: 16px; fill: #512e09" >amber5</text>
<text x="305" y="295" style="font-size: 12px; fill: #512e09" >#F5CA50</text>
<rect x="300" y="300" width="150" height="50" style="fill: #F7DB7A" />
<text x="305" y="329" style="font-size: 16px; fill: #512e09" >amber6</text>
<text x="305" y="345" style="font-size: 12px; fill: #512e09" >#F7DB7A</text>
<rect x="300" y="350" width="150" height="50" style="fill: #FAEAA6" />
<text x="305" y="379" style="font-size: 16px; fill: #512e09" >amber7</text>
<text x="305" y="395" style="font-size: 12px; fill: #512e09" >#FAEAA6</text>
<rect x="300" y="400" width="150" height="50" style="fill: #FCF6D2" />
<text x="305" y="429" style="font-size: 16px; fill: #512e09" >amber8</text>
<text x="305" y="445" style="font-size: 12px; fill: #512e09" >#FCF6D2</text>
<rect x="300" y="450" width="150" height="50" style="fill: #FEFBED" />
<text x="305" y="479" style="font-size: 16px; fill: #512e09" >amber9</text>
<text x="305" y="495" style="font-size: 12px; fill: #512e09" >#FEFBED</text>
<rect x="450" y="0" width="150" height="50" style="fill: #544903" />
<text x="455" y="29" style="font-size: 16px; fill: #fffeec" >yellow0</text>
<text x="455" y="45" style="font-size: 12px; fill: #fffeec" >#544903</text>
<rect x="450" y="50" width="150" height="50" style="fill: #7E6C06" />
<text x="455" y="79" style="font-size: 16px; fill: #fffeec" >yellow1</text>
<text x="455" y="95" style="font-size: 12px; fill: #fffeec" >#7E6C06</text>
<rect x="450" y="100" width="150" height="50" style="fill: #A88E0A" />
<text x="455" y="129" style="font-size: 16px; fill: #fffeec" >yellow2</text>
<text x="455" y="145" style="font-size: 12px; fill: #fffeec" >#A88E0A</text>
<rect x="450" y="150" width="150" height="50" style="fill: #D2AF0F" />
<text x="455" y="179" style="font-size: 16px; fill: #fffeec" >yellow3</text>
<text x="455" y="195" style="font-size: 12px; fill: #fffeec" >#D2AF0F</text>
<rect x="450" y="200" width="150" height="50" style="fill: #FCCE14" />
<text x="455" y="229" style="font-size: 16px; fill: #fffeec" >yellow4</text>
<text x="455" y="245" style="font-size: 12px; fill: #fffeec" >#FCCE14</text>
<rect x="450" y="250" width="150" height="50" style="fill: #FDDE43" />
<text x="455" y="279" style="font-size: 16px; fill: #544903" >yellow5</text>
<text x="455" y="295" style="font-size: 12px; fill: #544903" >#FDDE43</text>
<rect x="450" y="300" width="150" height="50" style="fill: #FDEB71" />
<text x="455" y="329" style="font-size: 16px; fill: #544903" >yellow6</text>
<text x="455" y="345" style="font-size: 12px; fill: #544903" >#FDEB71</text>
<rect x="450" y="350" width="150" height="50" style="fill: #FEF5A0" />
<text x="455" y="379" style="font-size: 16px; fill: #544903" >yellow7</text>
<text x="455" y="395" style="font-size: 12px; fill: #544903" >#FEF5A0</text>
<rect x="450" y="400" width="150" height="50" style="fill: #FEFBD0" />
<text x="455" y="429" style="font-size: 16px; fill: #544903" >yellow8</text>
<text x="455" y="445" style="font-size: 12px; fill: #544903" >#FEFBD0</text>
<rect x="450" y="450" width="150" height="50" style="fill: #FFFEEC" />
<text x="455" y="479" style="font-size: 16px; fill: #544903" >yellow9</text>
<text x="455" y="495" style="font-size: 12px; fill: #544903" >#FFFEEC</text>
<rect x="600" y="0" width="150" height="50" style="fill: #314603" />
<text x="605" y="29" style="font-size: 16px; fill: #f3fbe9" >lime0</text>
<text x="605" y="45" style="font-size: 12px; fill: #f3fbe9" >#314603</text>
<rect x="600" y="50" width="150" height="50" style="fill: #4B6905" />
<text x="605" y="79" style="font-size: 16px; fill: #f3fbe9" >lime1</text>
<text x="605" y="95" style="font-size: 12px; fill: #f3fbe9" >#4B6905</text>
<rect x="600" y="100" width="150" height="50" style="fill: #678D09" />
<text x="605" y="129" style="font-size: 16px; fill: #f3fbe9" >lime2</text>
<text x="605" y="145" style="font-size: 12px; fill: #f3fbe9" >#678D09</text>
<rect x="600" y="150" width="150" height="50" style="fill: #84B00C" />
<text x="605" y="179" style="font-size: 16px; fill: #f3fbe9" >lime3</text>
<text x="605" y="195" style="font-size: 12px; fill: #f3fbe9" >#84B00C</text>
<rect x="600" y="200" width="150" height="50" style="fill: #A2D311" />
<text x="605" y="229" style="font-size: 16px; fill: #f3fbe9" >lime4</text>
<text x="605" y="245" style="font-size: 12px; fill: #f3fbe9" >#A2D311</text>
<rect x="600" y="250" width="150" height="50" style="fill: #AEDC3A" />
<text x="605" y="279" style="font-size: 16px; fill: #314603" >lime5</text>
<text x="605" y="295" style="font-size: 12px; fill: #314603" >#AEDC3A</text>
<rect x="600" y="300" width="150" height="50" style="fill: #BDE566" />
<text x="605" y="329" style="font-size: 16px; fill: #314603" >lime6</text>
<text x="605" y="345" style="font-size: 12px; fill: #314603" >#BDE566</text>
<rect x="600" y="350" width="150" height="50" style="fill: #CFED96" />
<text x="605" y="379" style="font-size: 16px; fill: #314603" >lime7</text>
<text x="605" y="395" style="font-size: 12px; fill: #314603" >#CFED96</text>
<rect x="600" y="400" width="150" height="50" style="fill: #E5F6C9" />
<text x="605" y="429" style="font-size: 16px; fill: #314603" >lime8</text>
<text x="605" y="445" style="font-size: 12px; fill: #314603" >#E5F6C9</text>
<rect x="600" y="450" width="150" height="50" style="fill: #F3FBE9" />
<text x="605" y="479" style="font-size: 16px; fill: #314603" >lime9</text>
<text x="605" y="495" style="font-size: 12px; fill: #314603" >#F3FBE9</text>
<rect x="750" y="0" width="150" height="50" style="fill: #263D13" />
<text x="755" y="29" style="font-size: 16px; fill: #f3f8ed" >lightGreen0</text>
<text x="755" y="45" style="font-size: 12px; fill: #f3f8ed" >#263D13</text>
<rect x="750" y="50" width="150" height="50" style="fill: #3B5C1D" />
<text x="755" y="79" style="font-size: 16px; fill: #f3f8ed" >lightGreen1</text>
<text x="755" y="95" style="font-size: 12px; fill: #f3f8ed" >#3B5C1D</text>
<rect x="750" y="100" width="150" height="50" style="fill: #517B28" />
<text x="755" y="129" style="font-size: 16px; fill: #f3f8ed" >lightGreen2</text>
<text x="755" y="145" style="font-size: 12px; fill: #f3f8ed" >#517B28</text>
<rect x="750" y="150" width="150" height="50" style="fill: #679934" />
<text x="755" y="179" style="font-size: 16px; fill: #f3f8ed" >lightGreen3</text>
<text x="755" y="195" style="font-size: 12px; fill: #f3f8ed" >#679934</text>
<rect x="750" y="200" width="150" height="50" style="fill: #7FB840" />
<text x="755" y="229" style="font-size: 16px; fill: #f3f8ed" >lightGreen4</text>
<text x="755" y="245" style="font-size: 12px; fill: #f3f8ed" >#7FB840</text>
<rect x="750" y="250" width="150" height="50" style="fill: #97C65F" />
<text x="755" y="279" style="font-size: 16px; fill: #263d13" >lightGreen5</text>
<text x="755" y="295" style="font-size: 12px; fill: #263d13" >#97C65F</text>
<rect x="750" y="300" width="150" height="50" style="fill: #B0D481" />
<text x="755" y="329" style="font-size: 16px; fill: #263d13" >lightGreen6</text>
<text x="755" y="345" style="font-size: 12px; fill: #263d13" >#B0D481</text>
<rect x="750" y="350" width="150" height="50" style="fill: #C9E3A7" />
<text x="755" y="379" style="font-size: 16px; fill: #263d13" >lightGreen7</text>
<text x="755" y="395" style="font-size: 12px; fill: #263d13" >#C9E3A7</text>
<rect x="750" y="400" width="150" height="50" style="fill: #E4F1D1" />
<text x="755" y="429" style="font-size: 16px; fill: #263d13" >lightGreen8</text>
<text x="755" y="445" style="font-size: 12px; fill: #263d13" >#E4F1D1</text>
<rect x="750" y="450" width="150" height="50" style="fill: #F3F8ED" />
<text x="755" y="479" style="font-size: 16px; fill: #263d13" >lightGreen9</text>
<text x="755" y="495" style="font-size: 12px; fill: #263d13" >#F3F8ED</text>
<rect x="900" y="0" width="150" height="50" style="fill: #123C19" />
<text x="905" y="29" style="font-size: 16px; fill: #ecf7ec" >green0</text>
<text x="905" y="45" style="font-size: 12px; fill: #ecf7ec" >#123C19</text>
<rect x="900" y="50" width="150" height="50" style="fill: #1C5A25" />
<text x="905" y="79" style="font-size: 16px; fill: #ecf7ec" >green1</text>
<text x="905" y="95" style="font-size: 12px; fill: #ecf7ec" >#1C5A25</text>
<rect x="900" y="100" width="150" height="50" style="fill: #277731" />
<text x="905" y="129" style="font-size: 16px; fill: #ecf7ec" >green2</text>
<text x="905" y="145" style="font-size: 12px; fill: #ecf7ec" >#277731</text>
<rect x="900" y="150" width="150" height="50" style="fill: #32953D" />
<text x="905" y="179" style="font-size: 16px; fill: #ecf7ec" >green3</text>
<text x="905" y="195" style="font-size: 12px; fill: #ecf7ec" >#32953D</text>
<rect x="900" y="200" width="150" height="50" style="fill: #3EB349" />
<text x="905" y="229" style="font-size: 16px; fill: #ecf7ec" >green4</text>
<text x="905" y="245" style="font-size: 12px; fill: #ecf7ec" >#3EB349</text>
<rect x="900" y="250" width="150" height="50" style="fill: #5DC264" />
<text x="905" y="279" style="font-size: 16px; fill: #123c19" >green5</text>
<text x="905" y="295" style="font-size: 12px; fill: #123c19" >#5DC264</text>
<rect x="900" y="300" width="150" height="50" style="fill: #7FD184" />
<text x="905" y="329" style="font-size: 16px; fill: #123c19" >green6</text>
<text x="905" y="345" style="font-size: 12px; fill: #123c19" >#7FD184</text>
<rect x="900" y="350" width="150" height="50" style="fill: #A6E1A8" />
<text x="905" y="379" style="font-size: 16px; fill: #123c19" >green7</text>
<text x="905" y="395" style="font-size: 12px; fill: #123c19" >#A6E1A8</text>
<rect x="900" y="400" width="150" height="50" style="fill: #D0F0D1" />
<text x="905" y="429" style="font-size: 16px; fill: #123c19" >green8</text>
<text x="905" y="445" style="font-size: 12px; fill: #123c19" >#D0F0D1</text>
<rect x="900" y="450" width="150" height="50" style="fill: #ECF7EC" />
<text x="905" y="479" style="font-size: 16px; fill: #123c19" >green9</text>
<text x="905" y="495" style="font-size: 12px; fill: #123c19" >#ECF7EC</text>
<rect x="1050" y="0" width="150" height="50" style="fill: #023C39" />
<text x="1055" y="29" style="font-size: 16px; fill: #e6f7f4" >teal0</text>
<text x="1055" y="45" style="font-size: 12px; fill: #e6f7f4" >#023C39</text>
<rect x="1050" y="50" width="150" height="50" style="fill: #045A55" />
<text x="1055" y="79" style="font-size: 16px; fill: #e6f7f4" >teal1</text>
<text x="1055" y="95" style="font-size: 12px; fill: #e6f7f4" >#045A55</text>
<rect x="1050" y="100" width="150" height="50" style="fill: #07776F" />
<text x="1055" y="129" style="font-size: 16px; fill: #e6f7f4" >teal2</text>
<text x="1055" y="145" style="font-size: 12px; fill: #e6f7f4" >#07776F</text>
<rect x="1050" y="150" width="150" height="50" style="fill: #0A9588" />
<text x="1055" y="179" style="font-size: 16px; fill: #e6f7f4" >teal3</text>
<text x="1055" y="195" style="font-size: 12px; fill: #e6f7f4" >#0A9588</text>
<rect x="1050" y="200" width="150" height="50" style="fill: #0EB3A1" />
<text x="1055" y="229" style="font-size: 16px; fill: #e6f7f4" >teal4</text>
<text x="1055" y="245" style="font-size: 12px; fill: #e6f7f4" >#0EB3A1</text>
<rect x="1050" y="250" width="150" height="50" style="fill: #33C2B0" />
<text x="1055" y="279" style="font-size: 16px; fill: #023c39" >teal5</text>
<text x="1055" y="295" style="font-size: 12px; fill: #023c39" >#33C2B0</text>
<rect x="1050" y="300" width="150" height="50" style="fill: #5ED1C1" />
<text x="1055" y="329" style="font-size: 16px; fill: #023c39" >teal6</text>
<text x="1055" y="345" style="font-size: 12px; fill: #023c39" >#5ED1C1</text>
<rect x="1050" y="350" width="150" height="50" style="fill: #8EE1D3" />
<text x="1055" y="379" style="font-size: 16px; fill: #023c39" >teal7</text>
<text x="1055" y="395" style="font-size: 12px; fill: #023c39" >#8EE1D3</text>
<rect x="1050" y="400" width="150" height="50" style="fill: #C4F0E8" />
<text x="1055" y="429" style="font-size: 16px; fill: #023c39" >teal8</text>
<text x="1055" y="445" style="font-size: 12px; fill: #023c39" >#C4F0E8</text>
<rect x="1050" y="450" width="150" height="50" style="fill: #E6F7F4" />
<text x="1055" y="479" style="font-size: 16px; fill: #023c39" >teal9</text>
<text x="1055" y="495" style="font-size: 12px; fill: #023c39" >#E6F7F4</text>
<rect x="0" y="500" width="150" height="50" style="fill: #04343D" />
<text x="5" y="529" style="font-size: 16px; fill: #e7f7f8" >cyan0</text>
<text x="5" y="545" style="font-size: 12px; fill: #e7f7f8" >#04343D</text>
<rect x="0" y="550" width="150" height="50" style="fill: #074F5C" />
<text x="5" y="579" style="font-size: 16px; fill: #e7f7f8" >cyan1</text>
<text x="5" y="595" style="font-size: 12px; fill: #e7f7f8" >#074F5C</text>
<rect x="0" y="600" width="150" height="50" style="fill: #0A6C7B" />
<text x="5" y="629" style="font-size: 16px; fill: #e7f7f8" >cyan2</text>
<text x="5" y="645" style="font-size: 12px; fill: #e7f7f8" >#0A6C7B</text>
<rect x="0" y="650" width="150" height="50" style="fill: #0E8999" />
<text x="5" y="679" style="font-size: 16px; fill: #e7f7f8" >cyan3</text>
<text x="5" y="695" style="font-size: 12px; fill: #e7f7f8" >#0E8999</text>
<rect x="0" y="700" width="150" height="50" style="fill: #13A8B8" />
<text x="5" y="729" style="font-size: 16px; fill: #e7f7f8" >cyan4</text>
<text x="5" y="745" style="font-size: 12px; fill: #e7f7f8" >#13A8B8</text>
<rect x="0" y="750" width="150" height="50" style="fill: #38BBC6" />
<text x="5" y="779" style="font-size: 16px; fill: #04343d" >cyan5</text>
<text x="5" y="795" style="font-size: 12px; fill: #04343d" >#38BBC6</text>
<rect x="0" y="800" width="150" height="50" style="fill: #62CDD4" />
<text x="5" y="829" style="font-size: 16px; fill: #04343d" >cyan6</text>
<text x="5" y="845" style="font-size: 12px; fill: #04343d" >#62CDD4</text>
<rect x="0" y="850" width="150" height="50" style="fill: #91DFE3" />
<text x="5" y="879" style="font-size: 16px; fill: #04343d" >cyan7</text>
<text x="5" y="895" style="font-size: 12px; fill: #04343d" >#91DFE3</text>
<rect x="0" y="900" width="150" height="50" style="fill: #C6EFF1" />
<text x="5" y="929" style="font-size: 16px; fill: #04343d" >cyan8</text>
<text x="5" y="945" style="font-size: 12px; fill: #04343d" >#C6EFF1</text>
<rect x="0" y="950" width="150" height="50" style="fill: #E7F7F8" />
<text x="5" y="979" style="font-size: 16px; fill: #04343d" >cyan9</text>
<text x="5" y="995" style="font-size: 12px; fill: #04343d" >#E7F7F8</text>
<rect x="150" y="500" width="150" height="50" style="fill: #003761" />
<text x="155" y="529" style="font-size: 16px; fill: #ebf8fe" >lightBlue0</text>
<text x="155" y="545" style="font-size: 12px; fill: #ebf8fe" >#003761</text>
<rect x="150" y="550" width="150" height="50" style="fill: #004D85" />
<text x="155" y="579" style="font-size: 16px; fill: #ebf8fe" >lightBlue1</text>
<text x="155" y="595" style="font-size: 12px; fill: #ebf8fe" >#004D85</text>
<rect x="150" y="600" width="150" height="50" style="fill: #0366A9" />
<text x="155" y="629" style="font-size: 16px; fill: #ebf8fe" >lightBlue2</text>
<text x="155" y="645" style="font-size: 12px; fill: #ebf8fe" >#0366A9</text>
<rect x="150" y="650" width="150" height="50" style="fill: #0A81CC" />
<text x="155" y="679" style="font-size: 16px; fill: #ebf8fe" >lightBlue3</text>
<text x="155" y="695" style="font-size: 12px; fill: #ebf8fe" >#0A81CC</text>
<rect x="150" y="700" width="150" height="50" style="fill: #139FF0" />
<text x="155" y="729" style="font-size: 16px; fill: #ebf8fe" >lightBlue4</text>
<text x="155" y="745" style="font-size: 12px; fill: #ebf8fe" >#139FF0</text>
<rect x="150" y="750" width="150" height="50" style="fill: #40B4F3" />
<text x="155" y="779" style="font-size: 16px; fill: #003761" >lightBlue5</text>
<text x="155" y="795" style="font-size: 12px; fill: #003761" >#40B4F3</text>
<rect x="150" y="800" width="150" height="50" style="fill: #6EC8F6" />
<text x="155" y="829" style="font-size: 16px; fill: #003761" >lightBlue6</text>
<text x="155" y="845" style="font-size: 12px; fill: #003761" >#6EC8F6</text>
<rect x="150" y="850" width="150" height="50" style="fill: #9DDCF9" />
<text x="155" y="879" style="font-size: 16px; fill: #003761" >lightBlue7</text>
<text x="155" y="895" style="font-size: 12px; fill: #003761" >#9DDCF9</text>
<rect x="150" y="900" width="150" height="50" style="fill: #CEEEFC" />
<text x="155" y="929" style="font-size: 16px; fill: #003761" >lightBlue8</text>
<text x="155" y="945" style="font-size: 12px; fill: #003761" >#CEEEFC</text>
<rect x="150" y="950" width="150" height="50" style="fill: #EBF8FE" />
<text x="155" y="979" style="font-size: 16px; fill: #003761" >lightBlue9</text>
<text x="155" y="995" style="font-size: 12px; fill: #003761" >#EBF8FE</text>
<rect x="300" y="500" width="150" height="50" style="fill: #053170" />
<text x="305" y="529" style="font-size: 16px; fill: #eff8ff" >blue0</text>
<text x="305" y="545" style="font-size: 12px; fill: #eff8ff" >#053170</text>
<rect x="300" y="550" width="150" height="50" style="fill: #0A4694" />
<text x="305" y="579" style="font-size: 16px; fill: #eff8ff" >blue1</text>
<text x="305" y="595" style="font-size: 12px; fill: #eff8ff" >#0A4694</text>
<rect x="300" y="600" width="150" height="50" style="fill: #135CB8" />
<text x="305" y="629" style="font-size: 16px; fill: #eff8ff" >blue2</text>
<text x="305" y="645" style="font-size: 12px; fill: #eff8ff" >#135CB8</text>
<rect x="300" y="650" width="150" height="50" style="fill: #1D75DB" />
<text x="305" y="679" style="font-size: 16px; fill: #eff8ff" >blue3</text>
<text x="305" y="695" style="font-size: 12px; fill: #eff8ff" >#1D75DB</text>
<rect x="300" y="700" width="150" height="50" style="fill: #2990FF" />
<text x="305" y="729" style="font-size: 16px; fill: #eff8ff" >blue4</text>
<text x="305" y="745" style="font-size: 12px; fill: #eff8ff" >#2990FF</text>
<rect x="300" y="750" width="150" height="50" style="fill: #54A9FF" />
<text x="305" y="779" style="font-size: 16px; fill: #053170" >blue5</text>
<text x="305" y="795" style="font-size: 12px; fill: #053170" >#54A9FF</text>
<rect x="300" y="800" width="150" height="50" style="fill: #7FC1FF" />
<text x="305" y="829" style="font-size: 16px; fill: #053170" >blue6</text>
<text x="305" y="845" style="font-size: 12px; fill: #053170" >#7FC1FF</text>
<rect x="300" y="850" width="150" height="50" style="fill: #A9D7FF" />
<text x="305" y="879" style="font-size: 16px; fill: #053170" >blue7</text>
<text x="305" y="895" style="font-size: 12px; fill: #053170" >#A9D7FF</text>
<rect x="300" y="900" width="150" height="50" style="fill: #D4ECFF" />
<text x="305" y="929" style="font-size: 16px; fill: #053170" >blue8</text>
<text x="305" y="945" style="font-size: 12px; fill: #053170" >#D4ECFF</text>
<rect x="300" y="950" width="150" height="50" style="fill: #EFF8FF" />
<text x="305" y="979" style="font-size: 16px; fill: #053170" >blue9</text>
<text x="305" y="995" style="font-size: 12px; fill: #053170" >#EFF8FF</text>
<rect x="450" y="500" width="150" height="50" style="fill: #171E65" />
<text x="455" y="529" style="font-size: 16px; fill: #edeff8" >indigo0</text>
<text x="455" y="545" style="font-size: 12px; fill: #edeff8" >#171E65</text>
<rect x="450" y="550" width="150" height="50" style="fill: #20297A" />
<text x="455" y="579" style="font-size: 16px; fill: #edeff8" >indigo1</text>
<text x="455" y="595" style="font-size: 12px; fill: #edeff8" >#20297A</text>
<rect x="450" y="600" width="150" height="50" style="fill: #29368E" />
<text x="455" y="629" style="font-size: 16px; fill: #edeff8" >indigo2</text>
<text x="455" y="645" style="font-size: 12px; fill: #edeff8" >#29368E</text>
<rect x="450" y="650" width="150" height="50" style="fill: #3444A3" />
<text x="455" y="679" style="font-size: 16px; fill: #edeff8" >indigo3</text>
<text x="455" y="695" style="font-size: 12px; fill: #edeff8" >#3444A3</text>
<rect x="450" y="700" width="150" height="50" style="fill: #4053B7" />
<text x="455" y="729" style="font-size: 16px; fill: #edeff8" >indigo4</text>
<text x="455" y="745" style="font-size: 12px; fill: #edeff8" >#4053B7</text>
<rect x="450" y="750" width="150" height="50" style="fill: #5F71C5" />
<text x="455" y="779" style="font-size: 16px; fill: #171e65" >indigo5</text>
<text x="455" y="795" style="font-size: 12px; fill: #171e65" >#5F71C5</text>
<rect x="450" y="800" width="150" height="50" style="fill: #8191D4" />
<text x="455" y="829" style="font-size: 16px; fill: #171e65" >indigo6</text>
<text x="455" y="845" style="font-size: 12px; fill: #171e65" >#8191D4</text>
<rect x="450" y="850" width="150" height="50" style="fill: #A7B4E2" />
<text x="455" y="879" style="font-size: 16px; fill: #171e65" >indigo7</text>
<text x="455" y="895" style="font-size: 12px; fill: #171e65" >#A7B4E2</text>
<rect x="450" y="900" width="150" height="50" style="fill: #D1D8F1" />
<text x="455" y="929" style="font-size: 16px; fill: #171e65" >indigo8</text>
<text x="455" y="945" style="font-size: 12px; fill: #171e65" >#D1D8F1</text>
<rect x="450" y="950" width="150" height="50" style="fill: #EDEFF8" />
<text x="455" y="979" style="font-size: 16px; fill: #171e65" >indigo9</text>
<text x="455" y="995" style="font-size: 12px; fill: #171e65" >#EDEFF8</text>
<rect x="600" y="500" width="150" height="50" style="fill: #401B77" />
<text x="605" y="529" style="font-size: 16px; fill: #f1eefa" >violet0</text>
<text x="605" y="545" style="font-size: 12px; fill: #f1eefa" >#401B77</text>
<rect x="600" y="550" width="150" height="50" style="fill: #4C248C" />
<text x="605" y="579" style="font-size: 16px; fill: #f1eefa" >violet1</text>
<text x="605" y="595" style="font-size: 12px; fill: #f1eefa" >#4C248C</text>
<rect x="600" y="600" width="150" height="50" style="fill: #582EA0" />
<text x="605" y="629" style="font-size: 16px; fill: #f1eefa" >violet2</text>
<text x="605" y="645" style="font-size: 12px; fill: #f1eefa" >#582EA0</text>
<rect x="600" y="650" width="150" height="50" style="fill: #6439B5" />
<text x="605" y="679" style="font-size: 16px; fill: #f1eefa" >violet3</text>
<text x="605" y="695" style="font-size: 12px; fill: #f1eefa" >#6439B5</text>
<rect x="600" y="700" width="150" height="50" style="fill: #7246C9" />
<text x="605" y="729" style="font-size: 16px; fill: #f1eefa" >violet4</text>
<text x="605" y="745" style="font-size: 12px; fill: #f1eefa" >#7246C9</text>
<rect x="600" y="750" width="150" height="50" style="fill: #8865D4" />
<text x="605" y="779" style="font-size: 16px; fill: #401b77" >violet5</text>
<text x="605" y="795" style="font-size: 12px; fill: #401b77" >#8865D4</text>
<rect x="600" y="800" width="150" height="50" style="fill: #A288DF" />
<text x="605" y="829" style="font-size: 16px; fill: #401b77" >violet6</text>
<text x="605" y="845" style="font-size: 12px; fill: #401b77" >#A288DF</text>
<rect x="600" y="850" width="150" height="50" style="fill: #BEADE9" />
<text x="605" y="879" style="font-size: 16px; fill: #401b77" >violet7</text>
<text x="605" y="895" style="font-size: 12px; fill: #401b77" >#BEADE9</text>
<rect x="600" y="900" width="150" height="50" style="fill: #DDD4F4" />
<text x="605" y="929" style="font-size: 16px; fill: #401b77" >violet8</text>
<text x="605" y="945" style="font-size: 12px; fill: #401b77" >#DDD4F4</text>
<rect x="600" y="950" width="150" height="50" style="fill: #F1EEFA" />
<text x="605" y="979" style="font-size: 16px; fill: #401b77" >violet9</text>
<text x="605" y="995" style="font-size: 12px; fill: #401b77" >#F1EEFA</text>
<rect x="750" y="500" width="150" height="50" style="fill: #4A1061" />
<text x="755" y="529" style="font-size: 16px; fill: #f7ebf7" >purple0</text>
<text x="755" y="545" style="font-size: 12px; fill: #f7ebf7" >#4A1061</text>
<rect x="750" y="550" width="150" height="50" style="fill: #5E1776" />
<text x="755" y="579" style="font-size: 16px; fill: #f7ebf7" >purple1</text>
<text x="755" y="595" style="font-size: 12px; fill: #f7ebf7" >#5E1776</text>
<rect x="750" y="600" width="150" height="50" style="fill: #731F8A" />
<text x="755" y="629" style="font-size: 16px; fill: #f7ebf7" >purple2</text>
<text x="755" y="645" style="font-size: 12px; fill: #f7ebf7" >#731F8A</text>
<rect x="750" y="650" width="150" height="50" style="fill: #89289F" />
<text x="755" y="679" style="font-size: 16px; fill: #f7ebf7" >purple3</text>
<text x="755" y="695" style="font-size: 12px; fill: #f7ebf7" >#89289F</text>
<rect x="750" y="700" width="150" height="50" style="fill: #A033B3" />
<text x="755" y="729" style="font-size: 16px; fill: #f7ebf7" >purple4</text>
<text x="755" y="745" style="font-size: 12px; fill: #f7ebf7" >#A033B3</text>
<rect x="750" y="750" width="150" height="50" style="fill: #B553C2" />
<text x="755" y="779" style="font-size: 16px; fill: #4a1061" >purple5</text>
<text x="755" y="795" style="font-size: 12px; fill: #4a1061" >#B553C2</text>
<rect x="750" y="800" width="150" height="50" style="fill: #CA78D1" />
<text x="755" y="829" style="font-size: 16px; fill: #4a1061" >purple6</text>
<text x="755" y="845" style="font-size: 12px; fill: #4a1061" >#CA78D1</text>
<rect x="750" y="850" width="150" height="50" style="fill: #DDA0E1" />
<text x="755" y="879" style="font-size: 16px; fill: #4a1061" >purple7</text>
<text x="755" y="895" style="font-size: 12px; fill: #4a1061" >#DDA0E1</text>
<rect x="750" y="900" width="150" height="50" style="fill: #EFCEF0" />
<text x="755" y="929" style="font-size: 16px; fill: #4a1061" >purple8</text>
<text x="755" y="945" style="font-size: 12px; fill: #4a1061" >#EFCEF0</text>
<rect x="750" y="950" width="150" height="50" style="fill: #F7EBF7" />
<text x="755" y="979" style="font-size: 16px; fill: #4a1061" >purple9</text>
<text x="755" y="995" style="font-size: 12px; fill: #4a1061" >#F7EBF7</text>
<rect x="900" y="500" width="150" height="50" style="fill: #5C0730" />
<text x="905" y="529" style="font-size: 16px; fill: #fdeef1" >pink0</text>
<text x="905" y="545" style="font-size: 12px; fill: #fdeef1" >#5C0730</text>
<rect x="900" y="550" width="150" height="50" style="fill: #800E41" />
<text x="905" y="579" style="font-size: 16px; fill: #fdeef1" >pink1</text>
<text x="905" y="595" style="font-size: 12px; fill: #fdeef1" >#800E41</text>
<rect x="900" y="600" width="150" height="50" style="fill: #A41751" />
<text x="905" y="629" style="font-size: 16px; fill: #fdeef1" >pink2</text>
<text x="905" y="645" style="font-size: 12px; fill: #fdeef1" >#A41751</text>
<rect x="900" y="650" width="150" height="50" style="fill: #C72261" />
<text x="905" y="679" style="font-size: 16px; fill: #fdeef1" >pink3</text>
<text x="905" y="695" style="font-size: 12px; fill: #fdeef1" >#C72261</text>
<rect x="900" y="700" width="150" height="50" style="fill: #EB2F71" />
<text x="905" y="729" style="font-size: 16px; fill: #fdeef1" >pink4</text>
<text x="905" y="745" style="font-size: 12px; fill: #fdeef1" >#EB2F71</text>
<rect x="900" y="750" width="150" height="50" style="fill: #EF5686" />
<text x="905" y="779" style="font-size: 16px; fill: #5c0730" >pink5</text>
<text x="905" y="795" style="font-size: 12px; fill: #5c0730" >#EF5686</text>
<rect x="900" y="800" width="150" height="50" style="fill: #F37E9F" />
<text x="905" y="829" style="font-size: 16px; fill: #5c0730" >pink6</text>
<text x="905" y="845" style="font-size: 12px; fill: #5c0730" >#F37E9F</text>
<rect x="900" y="850" width="150" height="50" style="fill: #F7A8BC" />
<text x="905" y="879" style="font-size: 16px; fill: #5c0730" >pink7</text>
<text x="905" y="895" style="font-size: 12px; fill: #5c0730" >#F7A8BC</text>
<rect x="900" y="900" width="150" height="50" style="fill: #FBD3DC" />
<text x="905" y="929" style="font-size: 16px; fill: #5c0730" >pink8</text>
<text x="905" y="945" style="font-size: 12px; fill: #5c0730" >#FBD3DC</text>
<rect x="900" y="950" width="150" height="50" style="fill: #FDEEF1" />
<text x="905" y="979" style="font-size: 16px; fill: #5c0730" >pink9</text>
<text x="905" y="995" style="font-size: 12px; fill: #5c0730" >#FDEEF1</text>
<rect x="1050" y="500" width="150" height="50" style="fill: #1C1F23" />
<text x="1055" y="529" style="font-size: 16px; fill: #f9f9f9" >grey0</text>
<text x="1055" y="545" style="font-size: 12px; fill: #f9f9f9" >#1C1F23</text>
<rect x="1050" y="550" width="150" height="50" style="fill: #2E3238" />
<text x="1055" y="579" style="font-size: 16px; fill: #f9f9f9" >grey1</text>
<text x="1055" y="595" style="font-size: 12px; fill: #f9f9f9" >#2E3238</text>
<rect x="1050" y="600" width="150" height="50" style="fill: #41464C" />
<text x="1055" y="629" style="font-size: 16px; fill: #f9f9f9" >grey2</text>
<text x="1055" y="645" style="font-size: 12px; fill: #f9f9f9" >#41464C</text>
<rect x="1050" y="650" width="150" height="50" style="fill: #555B61" />
<text x="1055" y="679" style="font-size: 16px; fill: #f9f9f9" >grey3</text>
<text x="1055" y="695" style="font-size: 12px; fill: #f9f9f9" >#555B61</text>
<rect x="1050" y="700" width="150" height="50" style="fill: #6B7075" />
<text x="1055" y="729" style="font-size: 16px; fill: #f9f9f9" >grey4</text>
<text x="1055" y="745" style="font-size: 12px; fill: #f9f9f9" >#6B7075</text>
<rect x="1050" y="750" width="150" height="50" style="fill: #888D92" />
<text x="1055" y="779" style="font-size: 16px; fill: #1c1f23" >grey5</text>
<text x="1055" y="795" style="font-size: 12px; fill: #1c1f23" >#888D92</text>
<rect x="1050" y="800" width="150" height="50" style="fill: #A7ABB0" />
<text x="1055" y="829" style="font-size: 16px; fill: #1c1f23" >grey6</text>
<text x="1055" y="845" style="font-size: 12px; fill: #1c1f23" >#A7ABB0</text>
<rect x="1050" y="850" width="150" height="50" style="fill: #C6CACD" />
<text x="1055" y="879" style="font-size: 16px; fill: #1c1f23" >grey7</text>
<text x="1055" y="895" style="font-size: 12px; fill: #1c1f23" >#C6CACD</text>
<rect x="1050" y="900" width="150" height="50" style="fill: #E6E8EA" />
<text x="1055" y="929" style="font-size: 16px; fill: #1c1f23" >grey8</text>
<text x="1055" y="945" style="font-size: 12px; fill: #1c1f23" >#E6E8EA</text>
<rect x="1050" y="950" width="150" height="50" style="fill: #F9F9F9" />
<text x="1055" y="979" style="font-size: 16px; fill: #1c1f23" >grey9</text>
<text x="1055" y="995" style="font-size: 12px; fill: #1c1f23" >#F9F9F9</text>
<rect x="0" y="1000" width="600" height="50" style="fill: #FFFFFF" />
<text x="5" y="1029" style="font-size: 16px; fill: #808080" >white</text>
<text x="5" y="1045" style="font-size: 12px; fill: #808080" >#FFFFFF</text>
<rect x="600" y="1000" width="600" height="50" style="fill: #000000" />
<text x="605" y="1029" style="font-size: 16px; fill: #808080" >black</text>
<text x="605" y="1045" style="font-size: 12px; fill: #808080" >#000000</text>
</svg>

Before

Width:  |  Height:  |  Size: 36 KiB

View File

@ -1,500 +0,0 @@
<?xml version="1.0"?>
<!-- Generated by SVGo -->
<svg width="1200" height="1050"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<style type="text/css">
<![CDATA[
text {
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"
}
]]>
</style>
<rect x="0" y="0" width="150" height="50" style="fill: #FEF2ED" />
<text x="5" y="29" style="font-size: 16px; fill: #6a0103" >red0</text>
<text x="5" y="45" style="font-size: 12px; fill: #6a0103" >#FEF2ED</text>
<rect x="0" y="50" width="150" height="50" style="fill: #FEDDD2" />
<text x="5" y="79" style="font-size: 16px; fill: #6a0103" >red1</text>
<text x="5" y="95" style="font-size: 12px; fill: #6a0103" >#FEDDD2</text>
<rect x="0" y="100" width="150" height="50" style="fill: #FDB7A5" />
<text x="5" y="129" style="font-size: 16px; fill: #6a0103" >red2</text>
<text x="5" y="145" style="font-size: 12px; fill: #6a0103" >#FDB7A5</text>
<rect x="0" y="150" width="150" height="50" style="fill: #FB9078" />
<text x="5" y="179" style="font-size: 16px; fill: #6a0103" >red3</text>
<text x="5" y="195" style="font-size: 12px; fill: #6a0103" >#FB9078</text>
<rect x="0" y="200" width="150" height="50" style="fill: #FA664C" />
<text x="5" y="229" style="font-size: 16px; fill: #6a0103" >red4</text>
<text x="5" y="245" style="font-size: 12px; fill: #6a0103" >#FA664C</text>
<rect x="0" y="250" width="150" height="50" style="fill: #F93920" />
<text x="5" y="279" style="font-size: 16px; fill: #fef2ed" >red5</text>
<text x="5" y="295" style="font-size: 12px; fill: #fef2ed" >#F93920</text>
<rect x="0" y="300" width="150" height="50" style="fill: #D52515" />
<text x="5" y="329" style="font-size: 16px; fill: #fef2ed" >red6</text>
<text x="5" y="345" style="font-size: 12px; fill: #fef2ed" >#D52515</text>
<rect x="0" y="350" width="150" height="50" style="fill: #B2140C" />
<text x="5" y="379" style="font-size: 16px; fill: #fef2ed" >red7</text>
<text x="5" y="395" style="font-size: 12px; fill: #fef2ed" >#B2140C</text>
<rect x="0" y="400" width="150" height="50" style="fill: #8E0805" />
<text x="5" y="429" style="font-size: 16px; fill: #fef2ed" >red8</text>
<text x="5" y="445" style="font-size: 12px; fill: #fef2ed" >#8E0805</text>
<rect x="0" y="450" width="150" height="50" style="fill: #6A0103" />
<text x="5" y="479" style="font-size: 16px; fill: #fef2ed" >red9</text>
<text x="5" y="495" style="font-size: 12px; fill: #fef2ed" >#6A0103</text>
<rect x="150" y="0" width="150" height="50" style="fill: #FFF8EA" />
<text x="155" y="29" style="font-size: 16px; fill: #541d00" >orange0</text>
<text x="155" y="45" style="font-size: 12px; fill: #541d00" >#FFF8EA</text>
<rect x="150" y="50" width="150" height="50" style="fill: #FEEECC" />
<text x="155" y="79" style="font-size: 16px; fill: #541d00" >orange1</text>
<text x="155" y="95" style="font-size: 12px; fill: #541d00" >#FEEECC</text>
<rect x="150" y="100" width="150" height="50" style="fill: #FED998" />
<text x="155" y="129" style="font-size: 16px; fill: #541d00" >orange2</text>
<text x="155" y="145" style="font-size: 12px; fill: #541d00" >#FED998</text>
<rect x="150" y="150" width="150" height="50" style="fill: #FDC165" />
<text x="155" y="179" style="font-size: 16px; fill: #541d00" >orange3</text>
<text x="155" y="195" style="font-size: 12px; fill: #541d00" >#FDC165</text>
<rect x="150" y="200" width="150" height="50" style="fill: #FDA633" />
<text x="155" y="229" style="font-size: 16px; fill: #541d00" >orange4</text>
<text x="155" y="245" style="font-size: 12px; fill: #541d00" >#FDA633</text>
<rect x="150" y="250" width="150" height="50" style="fill: #FC8800" />
<text x="155" y="279" style="font-size: 16px; fill: #fff8ea" >orange5</text>
<text x="155" y="295" style="font-size: 12px; fill: #fff8ea" >#FC8800</text>
<rect x="150" y="300" width="150" height="50" style="fill: #D26700" />
<text x="155" y="329" style="font-size: 16px; fill: #fff8ea" >orange6</text>
<text x="155" y="345" style="font-size: 12px; fill: #fff8ea" >#D26700</text>
<rect x="150" y="350" width="150" height="50" style="fill: #A84A00" />
<text x="155" y="379" style="font-size: 16px; fill: #fff8ea" >orange7</text>
<text x="155" y="395" style="font-size: 12px; fill: #fff8ea" >#A84A00</text>
<rect x="150" y="400" width="150" height="50" style="fill: #7E3100" />
<text x="155" y="429" style="font-size: 16px; fill: #fff8ea" >orange8</text>
<text x="155" y="445" style="font-size: 12px; fill: #fff8ea" >#7E3100</text>
<rect x="150" y="450" width="150" height="50" style="fill: #541D00" />
<text x="155" y="479" style="font-size: 16px; fill: #fff8ea" >orange9</text>
<text x="155" y="495" style="font-size: 12px; fill: #fff8ea" >#541D00</text>
<rect x="300" y="0" width="150" height="50" style="fill: #FEFBEB" />
<text x="305" y="29" style="font-size: 16px; fill: #502b03" >amber0</text>
<text x="305" y="45" style="font-size: 12px; fill: #502b03" >#FEFBEB</text>
<rect x="300" y="50" width="150" height="50" style="fill: #FCF5CE" />
<text x="305" y="79" style="font-size: 16px; fill: #502b03" >amber1</text>
<text x="305" y="95" style="font-size: 12px; fill: #502b03" >#FCF5CE</text>
<rect x="300" y="100" width="150" height="50" style="fill: #F9E89E" />
<text x="305" y="129" style="font-size: 16px; fill: #502b03" >amber2</text>
<text x="305" y="145" style="font-size: 12px; fill: #502b03" >#F9E89E</text>
<rect x="300" y="150" width="150" height="50" style="fill: #F6D86F" />
<text x="305" y="179" style="font-size: 16px; fill: #502b03" >amber3</text>
<text x="305" y="195" style="font-size: 12px; fill: #502b03" >#F6D86F</text>
<rect x="300" y="200" width="150" height="50" style="fill: #F3C641" />
<text x="305" y="229" style="font-size: 16px; fill: #502b03" >amber4</text>
<text x="305" y="245" style="font-size: 12px; fill: #502b03" >#F3C641</text>
<rect x="300" y="250" width="150" height="50" style="fill: #F0B114" />
<text x="305" y="279" style="font-size: 16px; fill: #fefbeb" >amber5</text>
<text x="305" y="295" style="font-size: 12px; fill: #fefbeb" >#F0B114</text>
<rect x="300" y="300" width="150" height="50" style="fill: #C88A0F" />
<text x="305" y="329" style="font-size: 16px; fill: #fefbeb" >amber6</text>
<text x="305" y="345" style="font-size: 12px; fill: #fefbeb" >#C88A0F</text>
<rect x="300" y="350" width="150" height="50" style="fill: #A0660A" />
<text x="305" y="379" style="font-size: 16px; fill: #fefbeb" >amber7</text>
<text x="305" y="395" style="font-size: 12px; fill: #fefbeb" >#A0660A</text>
<rect x="300" y="400" width="150" height="50" style="fill: #784606" />
<text x="305" y="429" style="font-size: 16px; fill: #fefbeb" >amber8</text>
<text x="305" y="445" style="font-size: 12px; fill: #fefbeb" >#784606</text>
<rect x="300" y="450" width="150" height="50" style="fill: #502B03" />
<text x="305" y="479" style="font-size: 16px; fill: #fefbeb" >amber9</text>
<text x="305" y="495" style="font-size: 12px; fill: #fefbeb" >#502B03</text>
<rect x="450" y="0" width="150" height="50" style="fill: #FFFDEA" />
<text x="455" y="29" style="font-size: 16px; fill: #534800" >yellow0</text>
<text x="455" y="45" style="font-size: 12px; fill: #534800" >#FFFDEA</text>
<rect x="450" y="50" width="150" height="50" style="fill: #FEFBCB" />
<text x="455" y="79" style="font-size: 16px; fill: #534800" >yellow1</text>
<text x="455" y="95" style="font-size: 12px; fill: #534800" >#FEFBCB</text>
<rect x="450" y="100" width="150" height="50" style="fill: #FDF398" />
<text x="455" y="129" style="font-size: 16px; fill: #534800" >yellow2</text>
<text x="455" y="145" style="font-size: 12px; fill: #534800" >#FDF398</text>
<rect x="450" y="150" width="150" height="50" style="fill: #FCE865" />
<text x="455" y="179" style="font-size: 16px; fill: #534800" >yellow3</text>
<text x="455" y="195" style="font-size: 12px; fill: #534800" >#FCE865</text>
<rect x="450" y="200" width="150" height="50" style="fill: #FBDA32" />
<text x="455" y="229" style="font-size: 16px; fill: #534800" >yellow4</text>
<text x="455" y="245" style="font-size: 12px; fill: #534800" >#FBDA32</text>
<rect x="450" y="250" width="150" height="50" style="fill: #FAC800" />
<text x="455" y="279" style="font-size: 16px; fill: #fffdea" >yellow5</text>
<text x="455" y="295" style="font-size: 12px; fill: #fffdea" >#FAC800</text>
<rect x="450" y="300" width="150" height="50" style="fill: #D0AA00" />
<text x="455" y="329" style="font-size: 16px; fill: #fffdea" >yellow6</text>
<text x="455" y="345" style="font-size: 12px; fill: #fffdea" >#D0AA00</text>
<rect x="450" y="350" width="150" height="50" style="fill: #A78B00" />
<text x="455" y="379" style="font-size: 16px; fill: #fffdea" >yellow7</text>
<text x="455" y="395" style="font-size: 12px; fill: #fffdea" >#A78B00</text>
<rect x="450" y="400" width="150" height="50" style="fill: #7D6A00" />
<text x="455" y="429" style="font-size: 16px; fill: #fffdea" >yellow8</text>
<text x="455" y="445" style="font-size: 12px; fill: #fffdea" >#7D6A00</text>
<rect x="450" y="450" width="150" height="50" style="fill: #534800" />
<text x="455" y="479" style="font-size: 16px; fill: #fffdea" >yellow9</text>
<text x="455" y="495" style="font-size: 12px; fill: #fffdea" >#534800</text>
<rect x="600" y="0" width="150" height="50" style="fill: #F2FAE6" />
<text x="605" y="29" style="font-size: 16px; fill: #2f4600" >lime0</text>
<text x="605" y="45" style="font-size: 12px; fill: #2f4600" >#F2FAE6</text>
<rect x="600" y="50" width="150" height="50" style="fill: #E3F6C5" />
<text x="605" y="79" style="font-size: 16px; fill: #2f4600" >lime1</text>
<text x="605" y="95" style="font-size: 12px; fill: #2f4600" >#E3F6C5</text>
<rect x="600" y="100" width="150" height="50" style="fill: #CBED8E" />
<text x="605" y="129" style="font-size: 16px; fill: #2f4600" >lime2</text>
<text x="605" y="145" style="font-size: 12px; fill: #2f4600" >#CBED8E</text>
<rect x="600" y="150" width="150" height="50" style="fill: #B7E35B" />
<text x="605" y="179" style="font-size: 16px; fill: #2f4600" >lime3</text>
<text x="605" y="195" style="font-size: 12px; fill: #2f4600" >#B7E35B</text>
<rect x="600" y="200" width="150" height="50" style="fill: #A7DA2C" />
<text x="605" y="229" style="font-size: 16px; fill: #2f4600" >lime4</text>
<text x="605" y="245" style="font-size: 12px; fill: #2f4600" >#A7DA2C</text>
<rect x="600" y="250" width="150" height="50" style="fill: #9BD100" />
<text x="605" y="279" style="font-size: 16px; fill: #f2fae6" >lime5</text>
<text x="605" y="295" style="font-size: 12px; fill: #f2fae6" >#9BD100</text>
<rect x="600" y="300" width="150" height="50" style="fill: #7EAE00" />
<text x="605" y="329" style="font-size: 16px; fill: #f2fae6" >lime6</text>
<text x="605" y="345" style="font-size: 12px; fill: #f2fae6" >#7EAE00</text>
<rect x="600" y="350" width="150" height="50" style="fill: #638B00" />
<text x="605" y="379" style="font-size: 16px; fill: #f2fae6" >lime7</text>
<text x="605" y="395" style="font-size: 12px; fill: #f2fae6" >#638B00</text>
<rect x="600" y="400" width="150" height="50" style="fill: #486800" />
<text x="605" y="429" style="font-size: 16px; fill: #f2fae6" >lime8</text>
<text x="605" y="445" style="font-size: 12px; fill: #f2fae6" >#486800</text>
<rect x="600" y="450" width="150" height="50" style="fill: #2F4600" />
<text x="605" y="479" style="font-size: 16px; fill: #f2fae6" >lime9</text>
<text x="605" y="495" style="font-size: 12px; fill: #f2fae6" >#2F4600</text>
<rect x="750" y="0" width="150" height="50" style="fill: #F3F8EC" />
<text x="755" y="29" style="font-size: 16px; fill: #253d12" >lightGreen0</text>
<text x="755" y="45" style="font-size: 12px; fill: #253d12" >#F3F8EC</text>
<rect x="750" y="50" width="150" height="50" style="fill: #E3F0D0" />
<text x="755" y="79" style="font-size: 16px; fill: #253d12" >lightGreen1</text>
<text x="755" y="95" style="font-size: 12px; fill: #253d12" >#E3F0D0</text>
<rect x="750" y="100" width="150" height="50" style="fill: #C8E2A5" />
<text x="755" y="129" style="font-size: 16px; fill: #253d12" >lightGreen2</text>
<text x="755" y="145" style="font-size: 12px; fill: #253d12" >#C8E2A5</text>
<rect x="750" y="150" width="150" height="50" style="fill: #ADD37E" />
<text x="755" y="179" style="font-size: 16px; fill: #253d12" >lightGreen3</text>
<text x="755" y="195" style="font-size: 12px; fill: #253d12" >#ADD37E</text>
<rect x="750" y="200" width="150" height="50" style="fill: #93C55B" />
<text x="755" y="229" style="font-size: 16px; fill: #253d12" >lightGreen4</text>
<text x="755" y="245" style="font-size: 12px; fill: #253d12" >#93C55B</text>
<rect x="750" y="250" width="150" height="50" style="fill: #7BB63C" />
<text x="755" y="279" style="font-size: 16px; fill: #f3f8ec" >lightGreen5</text>
<text x="755" y="295" style="font-size: 12px; fill: #f3f8ec" >#7BB63C</text>
<rect x="750" y="300" width="150" height="50" style="fill: #649830" />
<text x="755" y="329" style="font-size: 16px; fill: #f3f8ec" >lightGreen6</text>
<text x="755" y="345" style="font-size: 12px; fill: #f3f8ec" >#649830</text>
<rect x="750" y="350" width="150" height="50" style="fill: #4E7926" />
<text x="755" y="379" style="font-size: 16px; fill: #f3f8ec" >lightGreen7</text>
<text x="755" y="395" style="font-size: 12px; fill: #f3f8ec" >#4E7926</text>
<rect x="750" y="400" width="150" height="50" style="fill: #395B1B" />
<text x="755" y="429" style="font-size: 16px; fill: #f3f8ec" >lightGreen8</text>
<text x="755" y="445" style="font-size: 12px; fill: #f3f8ec" >#395B1B</text>
<rect x="750" y="450" width="150" height="50" style="fill: #253D12" />
<text x="755" y="479" style="font-size: 16px; fill: #f3f8ec" >lightGreen9</text>
<text x="755" y="495" style="font-size: 12px; fill: #f3f8ec" >#253D12</text>
<rect x="900" y="0" width="150" height="50" style="fill: #ECF7EC" />
<text x="905" y="29" style="font-size: 16px; fill: #113c18" >green0</text>
<text x="905" y="45" style="font-size: 12px; fill: #113c18" >#ECF7EC</text>
<rect x="900" y="50" width="150" height="50" style="fill: #D0F0D1" />
<text x="905" y="79" style="font-size: 16px; fill: #113c18" >green1</text>
<text x="905" y="95" style="font-size: 12px; fill: #113c18" >#D0F0D1</text>
<rect x="900" y="100" width="150" height="50" style="fill: #A4E0A7" />
<text x="905" y="129" style="font-size: 16px; fill: #113c18" >green2</text>
<text x="905" y="145" style="font-size: 12px; fill: #113c18" >#A4E0A7</text>
<rect x="900" y="150" width="150" height="50" style="fill: #7DD182" />
<text x="905" y="179" style="font-size: 16px; fill: #113c18" >green3</text>
<text x="905" y="195" style="font-size: 12px; fill: #113c18" >#7DD182</text>
<rect x="900" y="200" width="150" height="50" style="fill: #5AC262" />
<text x="905" y="229" style="font-size: 16px; fill: #113c18" >green4</text>
<text x="905" y="245" style="font-size: 12px; fill: #113c18" >#5AC262</text>
<rect x="900" y="250" width="150" height="50" style="fill: #3BB346" />
<text x="905" y="279" style="font-size: 16px; fill: #ecf7ec" >green5</text>
<text x="905" y="295" style="font-size: 12px; fill: #ecf7ec" >#3BB346</text>
<rect x="900" y="300" width="150" height="50" style="fill: #30953B" />
<text x="905" y="329" style="font-size: 16px; fill: #ecf7ec" >green6</text>
<text x="905" y="345" style="font-size: 12px; fill: #ecf7ec" >#30953B</text>
<rect x="900" y="350" width="150" height="50" style="fill: #25772F" />
<text x="905" y="379" style="font-size: 16px; fill: #ecf7ec" >green7</text>
<text x="905" y="395" style="font-size: 12px; fill: #ecf7ec" >#25772F</text>
<rect x="900" y="400" width="150" height="50" style="fill: #1B5924" />
<text x="905" y="429" style="font-size: 16px; fill: #ecf7ec" >green8</text>
<text x="905" y="445" style="font-size: 12px; fill: #ecf7ec" >#1B5924</text>
<rect x="900" y="450" width="150" height="50" style="fill: #113C18" />
<text x="905" y="479" style="font-size: 16px; fill: #ecf7ec" >green9</text>
<text x="905" y="495" style="font-size: 12px; fill: #ecf7ec" >#113C18</text>
<rect x="1050" y="0" width="150" height="50" style="fill: #E4F7F4" />
<text x="1055" y="29" style="font-size: 16px; fill: #003c3a" >teal0</text>
<text x="1055" y="45" style="font-size: 12px; fill: #003c3a" >#E4F7F4</text>
<rect x="1050" y="50" width="150" height="50" style="fill: #C0F0E8" />
<text x="1055" y="79" style="font-size: 16px; fill: #003c3a" >teal1</text>
<text x="1055" y="95" style="font-size: 12px; fill: #003c3a" >#C0F0E8</text>
<rect x="1050" y="100" width="150" height="50" style="fill: #87E0D3" />
<text x="1055" y="129" style="font-size: 16px; fill: #003c3a" >teal2</text>
<text x="1055" y="145" style="font-size: 12px; fill: #003c3a" >#87E0D3</text>
<rect x="1050" y="150" width="150" height="50" style="fill: #54D1C1" />
<text x="1055" y="179" style="font-size: 16px; fill: #003c3a" >teal3</text>
<text x="1055" y="195" style="font-size: 12px; fill: #003c3a" >#54D1C1</text>
<rect x="1050" y="200" width="150" height="50" style="fill: #27C2B0" />
<text x="1055" y="229" style="font-size: 16px; fill: #003c3a" >teal4</text>
<text x="1055" y="245" style="font-size: 12px; fill: #003c3a" >#27C2B0</text>
<rect x="1050" y="250" width="150" height="50" style="fill: #00B3A1" />
<text x="1055" y="279" style="font-size: 16px; fill: #e4f7f4" >teal5</text>
<text x="1055" y="295" style="font-size: 12px; fill: #e4f7f4" >#00B3A1</text>
<rect x="1050" y="300" width="150" height="50" style="fill: #009589" />
<text x="1055" y="329" style="font-size: 16px; fill: #e4f7f4" >teal6</text>
<text x="1055" y="345" style="font-size: 12px; fill: #e4f7f4" >#009589</text>
<rect x="1050" y="350" width="150" height="50" style="fill: #00776F" />
<text x="1055" y="379" style="font-size: 16px; fill: #e4f7f4" >teal7</text>
<text x="1055" y="395" style="font-size: 12px; fill: #e4f7f4" >#00776F</text>
<rect x="1050" y="400" width="150" height="50" style="fill: #005955" />
<text x="1055" y="429" style="font-size: 16px; fill: #e4f7f4" >teal8</text>
<text x="1055" y="445" style="font-size: 12px; fill: #e4f7f4" >#005955</text>
<rect x="1050" y="450" width="150" height="50" style="fill: #003C3A" />
<text x="1055" y="479" style="font-size: 16px; fill: #e4f7f4" >teal9</text>
<text x="1055" y="495" style="font-size: 12px; fill: #e4f7f4" >#003C3A</text>
<rect x="0" y="500" width="150" height="50" style="fill: #E5F7F8" />
<text x="5" y="529" style="font-size: 16px; fill: #00323d" >cyan0</text>
<text x="5" y="545" style="font-size: 12px; fill: #00323d" >#E5F7F8</text>
<rect x="0" y="550" width="150" height="50" style="fill: #C2EFF0" />
<text x="5" y="579" style="font-size: 16px; fill: #00323d" >cyan1</text>
<text x="5" y="595" style="font-size: 12px; fill: #00323d" >#C2EFF0</text>
<rect x="0" y="600" width="150" height="50" style="fill: #8ADDE2" />
<text x="5" y="629" style="font-size: 16px; fill: #00323d" >cyan2</text>
<text x="5" y="645" style="font-size: 12px; fill: #00323d" >#8ADDE2</text>
<rect x="0" y="650" width="150" height="50" style="fill: #58CBD3" />
<text x="5" y="679" style="font-size: 16px; fill: #00323d" >cyan3</text>
<text x="5" y="695" style="font-size: 12px; fill: #00323d" >#58CBD3</text>
<rect x="0" y="700" width="150" height="50" style="fill: #2CB8C5" />
<text x="5" y="729" style="font-size: 16px; fill: #00323d" >cyan4</text>
<text x="5" y="745" style="font-size: 12px; fill: #00323d" >#2CB8C5</text>
<rect x="0" y="750" width="150" height="50" style="fill: #05A4B6" />
<text x="5" y="779" style="font-size: 16px; fill: #e5f7f8" >cyan5</text>
<text x="5" y="795" style="font-size: 12px; fill: #e5f7f8" >#05A4B6</text>
<rect x="0" y="800" width="150" height="50" style="fill: #038698" />
<text x="5" y="829" style="font-size: 16px; fill: #e5f7f8" >cyan6</text>
<text x="5" y="845" style="font-size: 12px; fill: #e5f7f8" >#038698</text>
<rect x="0" y="850" width="150" height="50" style="fill: #016979" />
<text x="5" y="879" style="font-size: 16px; fill: #e5f7f8" >cyan7</text>
<text x="5" y="895" style="font-size: 12px; fill: #e5f7f8" >#016979</text>
<rect x="0" y="900" width="150" height="50" style="fill: #004D5B" />
<text x="5" y="929" style="font-size: 16px; fill: #e5f7f8" >cyan8</text>
<text x="5" y="945" style="font-size: 12px; fill: #e5f7f8" >#004D5B</text>
<rect x="0" y="950" width="150" height="50" style="fill: #00323D" />
<text x="5" y="979" style="font-size: 16px; fill: #e5f7f8" >cyan9</text>
<text x="5" y="995" style="font-size: 12px; fill: #e5f7f8" >#00323D</text>
<rect x="150" y="500" width="150" height="50" style="fill: #E9F7FD" />
<text x="155" y="529" style="font-size: 16px; fill: #00355f" >lightBlue0</text>
<text x="155" y="545" style="font-size: 12px; fill: #00355f" >#E9F7FD</text>
<rect x="150" y="550" width="150" height="50" style="fill: #C9ECFC" />
<text x="155" y="579" style="font-size: 16px; fill: #00355f" >lightBlue1</text>
<text x="155" y="595" style="font-size: 12px; fill: #00355f" >#C9ECFC</text>
<rect x="150" y="600" width="150" height="50" style="fill: #95D8F8" />
<text x="155" y="629" style="font-size: 16px; fill: #00355f" >lightBlue2</text>
<text x="155" y="645" style="font-size: 12px; fill: #00355f" >#95D8F8</text>
<rect x="150" y="650" width="150" height="50" style="fill: #62C3F5" />
<text x="155" y="679" style="font-size: 16px; fill: #00355f" >lightBlue3</text>
<text x="155" y="695" style="font-size: 12px; fill: #00355f" >#62C3F5</text>
<rect x="150" y="700" width="150" height="50" style="fill: #30ACF1" />
<text x="155" y="729" style="font-size: 16px; fill: #00355f" >lightBlue4</text>
<text x="155" y="745" style="font-size: 12px; fill: #00355f" >#30ACF1</text>
<rect x="150" y="750" width="150" height="50" style="fill: #0095EE" />
<text x="155" y="779" style="font-size: 16px; fill: #e9f7fd" >lightBlue5</text>
<text x="155" y="795" style="font-size: 12px; fill: #e9f7fd" >#0095EE</text>
<rect x="150" y="800" width="150" height="50" style="fill: #007BCA" />
<text x="155" y="829" style="font-size: 16px; fill: #e9f7fd" >lightBlue6</text>
<text x="155" y="845" style="font-size: 12px; fill: #e9f7fd" >#007BCA</text>
<rect x="150" y="850" width="150" height="50" style="fill: #0063A7" />
<text x="155" y="879" style="font-size: 16px; fill: #e9f7fd" >lightBlue7</text>
<text x="155" y="895" style="font-size: 12px; fill: #e9f7fd" >#0063A7</text>
<rect x="150" y="900" width="150" height="50" style="fill: #004B83" />
<text x="155" y="929" style="font-size: 16px; fill: #e9f7fd" >lightBlue8</text>
<text x="155" y="945" style="font-size: 12px; fill: #e9f7fd" >#004B83</text>
<rect x="150" y="950" width="150" height="50" style="fill: #00355F" />
<text x="155" y="979" style="font-size: 16px; fill: #e9f7fd" >lightBlue9</text>
<text x="155" y="995" style="font-size: 12px; fill: #e9f7fd" >#00355F</text>
<rect x="300" y="500" width="150" height="50" style="fill: #EAF5FF" />
<text x="305" y="529" style="font-size: 16px; fill: #002c6b" >blue0</text>
<text x="305" y="545" style="font-size: 12px; fill: #002c6b" >#EAF5FF</text>
<rect x="300" y="550" width="150" height="50" style="fill: #CBE7FE" />
<text x="305" y="579" style="font-size: 16px; fill: #002c6b" >blue1</text>
<text x="305" y="595" style="font-size: 12px; fill: #002c6b" >#CBE7FE</text>
<rect x="300" y="600" width="150" height="50" style="fill: #98CDFD" />
<text x="305" y="629" style="font-size: 16px; fill: #002c6b" >blue2</text>
<text x="305" y="645" style="font-size: 12px; fill: #002c6b" >#98CDFD</text>
<rect x="300" y="650" width="150" height="50" style="fill: #65B2FC" />
<text x="305" y="679" style="font-size: 16px; fill: #002c6b" >blue3</text>
<text x="305" y="695" style="font-size: 12px; fill: #002c6b" >#65B2FC</text>
<rect x="300" y="700" width="150" height="50" style="fill: #3295FB" />
<text x="305" y="729" style="font-size: 16px; fill: #002c6b" >blue4</text>
<text x="305" y="745" style="font-size: 12px; fill: #002c6b" >#3295FB</text>
<rect x="300" y="750" width="150" height="50" style="fill: #0064FA" />
<text x="305" y="779" style="font-size: 16px; fill: #eaf5ff" >blue5</text>
<text x="305" y="795" style="font-size: 12px; fill: #eaf5ff" >#0064FA</text>
<rect x="300" y="800" width="150" height="50" style="fill: #0062D6" />
<text x="305" y="829" style="font-size: 16px; fill: #eaf5ff" >blue6</text>
<text x="305" y="845" style="font-size: 12px; fill: #eaf5ff" >#0062D6</text>
<rect x="300" y="850" width="150" height="50" style="fill: #004FB3" />
<text x="305" y="879" style="font-size: 16px; fill: #eaf5ff" >blue7</text>
<text x="305" y="895" style="font-size: 12px; fill: #eaf5ff" >#004FB3</text>
<rect x="300" y="900" width="150" height="50" style="fill: #003D8F" />
<text x="305" y="929" style="font-size: 16px; fill: #eaf5ff" >blue8</text>
<text x="305" y="945" style="font-size: 12px; fill: #eaf5ff" >#003D8F</text>
<rect x="300" y="950" width="150" height="50" style="fill: #002C6B" />
<text x="305" y="979" style="font-size: 16px; fill: #eaf5ff" >blue9</text>
<text x="305" y="995" style="font-size: 12px; fill: #eaf5ff" >#002C6B</text>
<rect x="450" y="500" width="150" height="50" style="fill: #ECEFF8" />
<text x="455" y="529" style="font-size: 16px; fill: #171d63" >indigo0</text>
<text x="455" y="545" style="font-size: 12px; fill: #171d63" >#ECEFF8</text>
<rect x="450" y="550" width="150" height="50" style="fill: #D1D8F0" />
<text x="455" y="579" style="font-size: 16px; fill: #171d63" >indigo1</text>
<text x="455" y="595" style="font-size: 12px; fill: #171d63" >#D1D8F0</text>
<rect x="450" y="600" width="150" height="50" style="fill: #A7B3E1" />
<text x="455" y="629" style="font-size: 16px; fill: #171d63" >indigo2</text>
<text x="455" y="645" style="font-size: 12px; fill: #171d63" >#A7B3E1</text>
<rect x="450" y="650" width="150" height="50" style="fill: #8090D3" />
<text x="455" y="679" style="font-size: 16px; fill: #171d63" >indigo3</text>
<text x="455" y="695" style="font-size: 12px; fill: #171d63" >#8090D3</text>
<rect x="450" y="700" width="150" height="50" style="fill: #5E6FC4" />
<text x="455" y="729" style="font-size: 16px; fill: #171d63" >indigo4</text>
<text x="455" y="745" style="font-size: 12px; fill: #171d63" >#5E6FC4</text>
<rect x="450" y="750" width="150" height="50" style="fill: #3F51B5" />
<text x="455" y="779" style="font-size: 16px; fill: #eceff8" >indigo5</text>
<text x="455" y="795" style="font-size: 12px; fill: #eceff8" >#3F51B5</text>
<rect x="450" y="800" width="150" height="50" style="fill: #3342A1" />
<text x="455" y="829" style="font-size: 16px; fill: #eceff8" >indigo6</text>
<text x="455" y="845" style="font-size: 12px; fill: #eceff8" >#3342A1</text>
<rect x="450" y="850" width="150" height="50" style="fill: #28348C" />
<text x="455" y="879" style="font-size: 16px; fill: #eceff8" >indigo7</text>
<text x="455" y="895" style="font-size: 12px; fill: #eceff8" >#28348C</text>
<rect x="450" y="900" width="150" height="50" style="fill: #1F2878" />
<text x="455" y="929" style="font-size: 16px; fill: #eceff8" >indigo8</text>
<text x="455" y="945" style="font-size: 12px; fill: #eceff8" >#1F2878</text>
<rect x="450" y="950" width="150" height="50" style="fill: #171D63" />
<text x="455" y="979" style="font-size: 16px; fill: #eceff8" >indigo9</text>
<text x="455" y="995" style="font-size: 12px; fill: #eceff8" >#171D63</text>
<rect x="600" y="500" width="150" height="50" style="fill: #F3EDF9" />
<text x="605" y="529" style="font-size: 16px; fill: #281475" >violet0</text>
<text x="605" y="545" style="font-size: 12px; fill: #281475" >#F3EDF9</text>
<rect x="600" y="550" width="150" height="50" style="fill: #E2D1F4" />
<text x="605" y="579" style="font-size: 16px; fill: #281475" >violet1</text>
<text x="605" y="595" style="font-size: 12px; fill: #281475" >#E2D1F4</text>
<rect x="600" y="600" width="150" height="50" style="fill: #C4A7E9" />
<text x="605" y="629" style="font-size: 16px; fill: #281475" >violet2</text>
<text x="605" y="645" style="font-size: 12px; fill: #281475" >#C4A7E9</text>
<rect x="600" y="650" width="150" height="50" style="fill: #A67FDD" />
<text x="605" y="679" style="font-size: 16px; fill: #281475" >violet3</text>
<text x="605" y="695" style="font-size: 12px; fill: #281475" >#A67FDD</text>
<rect x="600" y="700" width="150" height="50" style="fill: #885BD2" />
<text x="605" y="729" style="font-size: 16px; fill: #281475" >violet4</text>
<text x="605" y="745" style="font-size: 12px; fill: #281475" >#885BD2</text>
<rect x="600" y="750" width="150" height="50" style="fill: #6A3AC7" />
<text x="605" y="779" style="font-size: 16px; fill: #f3edf9" >violet5</text>
<text x="605" y="795" style="font-size: 12px; fill: #f3edf9" >#6A3AC7</text>
<rect x="600" y="800" width="150" height="50" style="fill: #572FB3" />
<text x="605" y="829" style="font-size: 16px; fill: #f3edf9" >violet6</text>
<text x="605" y="845" style="font-size: 12px; fill: #f3edf9" >#572FB3</text>
<rect x="600" y="850" width="150" height="50" style="fill: #46259E" />
<text x="605" y="879" style="font-size: 16px; fill: #f3edf9" >violet7</text>
<text x="605" y="895" style="font-size: 12px; fill: #f3edf9" >#46259E</text>
<rect x="600" y="900" width="150" height="50" style="fill: #361C8A" />
<text x="605" y="929" style="font-size: 16px; fill: #f3edf9" >violet8</text>
<text x="605" y="945" style="font-size: 12px; fill: #f3edf9" >#361C8A</text>
<rect x="600" y="950" width="150" height="50" style="fill: #281475" />
<text x="605" y="979" style="font-size: 16px; fill: #f3edf9" >violet9</text>
<text x="605" y="995" style="font-size: 12px; fill: #f3edf9" >#281475</text>
<rect x="750" y="500" width="150" height="50" style="fill: #F7E9F7" />
<text x="755" y="529" style="font-size: 16px; fill: #490a61" >purple0</text>
<text x="755" y="545" style="font-size: 12px; fill: #490a61" >#F7E9F7</text>
<rect x="750" y="550" width="150" height="50" style="fill: #EFCAF0" />
<text x="755" y="579" style="font-size: 16px; fill: #490a61" >purple1</text>
<text x="755" y="595" style="font-size: 12px; fill: #490a61" >#EFCAF0</text>
<rect x="750" y="600" width="150" height="50" style="fill: #DD9BE0" />
<text x="755" y="629" style="font-size: 16px; fill: #490a61" >purple2</text>
<text x="755" y="645" style="font-size: 12px; fill: #490a61" >#DD9BE0</text>
<rect x="750" y="650" width="150" height="50" style="fill: #C96FD1" />
<text x="755" y="679" style="font-size: 16px; fill: #490a61" >purple3</text>
<text x="755" y="695" style="font-size: 12px; fill: #490a61" >#C96FD1</text>
<rect x="750" y="700" width="150" height="50" style="fill: #B449C2" />
<text x="755" y="729" style="font-size: 16px; fill: #490a61" >purple4</text>
<text x="755" y="745" style="font-size: 12px; fill: #490a61" >#B449C2</text>
<rect x="750" y="750" width="150" height="50" style="fill: #9E28B3" />
<text x="755" y="779" style="font-size: 16px; fill: #f7e9f7" >purple5</text>
<text x="755" y="795" style="font-size: 12px; fill: #f7e9f7" >#9E28B3</text>
<rect x="750" y="800" width="150" height="50" style="fill: #871E9E" />
<text x="755" y="829" style="font-size: 16px; fill: #f7e9f7" >purple6</text>
<text x="755" y="845" style="font-size: 12px; fill: #f7e9f7" >#871E9E</text>
<rect x="750" y="850" width="150" height="50" style="fill: #71168A" />
<text x="755" y="879" style="font-size: 16px; fill: #f7e9f7" >purple7</text>
<text x="755" y="895" style="font-size: 12px; fill: #f7e9f7" >#71168A</text>
<rect x="750" y="900" width="150" height="50" style="fill: #5C0F75" />
<text x="755" y="929" style="font-size: 16px; fill: #f7e9f7" >purple8</text>
<text x="755" y="945" style="font-size: 12px; fill: #f7e9f7" >#5C0F75</text>
<rect x="750" y="950" width="150" height="50" style="fill: #490A61" />
<text x="755" y="979" style="font-size: 16px; fill: #f7e9f7" >purple9</text>
<text x="755" y="995" style="font-size: 12px; fill: #f7e9f7" >#490A61</text>
<rect x="900" y="500" width="150" height="50" style="fill: #FDECEF" />
<text x="905" y="529" style="font-size: 16px; fill: #5a012b" >pink0</text>
<text x="905" y="545" style="font-size: 12px; fill: #5a012b" >#FDECEF</text>
<rect x="900" y="550" width="150" height="50" style="fill: #FBCFD8" />
<text x="905" y="579" style="font-size: 16px; fill: #5a012b" >pink1</text>
<text x="905" y="595" style="font-size: 12px; fill: #5a012b" >#FBCFD8</text>
<rect x="900" y="600" width="150" height="50" style="fill: #F6A0B5" />
<text x="905" y="629" style="font-size: 16px; fill: #5a012b" >pink2</text>
<text x="905" y="645" style="font-size: 12px; fill: #5a012b" >#F6A0B5</text>
<rect x="900" y="650" width="150" height="50" style="fill: #F27396" />
<text x="905" y="679" style="font-size: 16px; fill: #5a012b" >pink3</text>
<text x="905" y="695" style="font-size: 12px; fill: #5a012b" >#F27396</text>
<rect x="900" y="700" width="150" height="50" style="fill: #ED487B" />
<text x="905" y="729" style="font-size: 16px; fill: #5a012b" >pink4</text>
<text x="905" y="745" style="font-size: 12px; fill: #5a012b" >#ED487B</text>
<rect x="900" y="750" width="150" height="50" style="fill: #E91E63" />
<text x="905" y="779" style="font-size: 16px; fill: #fdecef" >pink5</text>
<text x="905" y="795" style="font-size: 12px; fill: #fdecef" >#E91E63</text>
<rect x="900" y="800" width="150" height="50" style="fill: #C51356" />
<text x="905" y="829" style="font-size: 16px; fill: #fdecef" >pink6</text>
<text x="905" y="845" style="font-size: 12px; fill: #fdecef" >#C51356</text>
<rect x="900" y="850" width="150" height="50" style="fill: #A20B48" />
<text x="905" y="879" style="font-size: 16px; fill: #fdecef" >pink7</text>
<text x="905" y="895" style="font-size: 12px; fill: #fdecef" >#A20B48</text>
<rect x="900" y="900" width="150" height="50" style="fill: #7E053A" />
<text x="905" y="929" style="font-size: 16px; fill: #fdecef" >pink8</text>
<text x="905" y="945" style="font-size: 12px; fill: #fdecef" >#7E053A</text>
<rect x="900" y="950" width="150" height="50" style="fill: #5A012B" />
<text x="905" y="979" style="font-size: 16px; fill: #fdecef" >pink9</text>
<text x="905" y="995" style="font-size: 12px; fill: #fdecef" >#5A012B</text>
<rect x="1050" y="500" width="150" height="50" style="fill: #F9F9F9" />
<text x="1055" y="529" style="font-size: 16px; fill: #1c1f23" >grey0</text>
<text x="1055" y="545" style="font-size: 12px; fill: #1c1f23" >#F9F9F9</text>
<rect x="1050" y="550" width="150" height="50" style="fill: #E6E8EA" />
<text x="1055" y="579" style="font-size: 16px; fill: #1c1f23" >grey1</text>
<text x="1055" y="595" style="font-size: 12px; fill: #1c1f23" >#E6E8EA</text>
<rect x="1050" y="600" width="150" height="50" style="fill: #C6CACD" />
<text x="1055" y="629" style="font-size: 16px; fill: #1c1f23" >grey2</text>
<text x="1055" y="645" style="font-size: 12px; fill: #1c1f23" >#C6CACD</text>
<rect x="1050" y="650" width="150" height="50" style="fill: #A7ABB0" />
<text x="1055" y="679" style="font-size: 16px; fill: #1c1f23" >grey3</text>
<text x="1055" y="695" style="font-size: 12px; fill: #1c1f23" >#A7ABB0</text>
<rect x="1050" y="700" width="150" height="50" style="fill: #888D92" />
<text x="1055" y="729" style="font-size: 16px; fill: #1c1f23" >grey4</text>
<text x="1055" y="745" style="font-size: 12px; fill: #1c1f23" >#888D92</text>
<rect x="1050" y="750" width="150" height="50" style="fill: #6B7075" />
<text x="1055" y="779" style="font-size: 16px; fill: #f9f9f9" >grey5</text>
<text x="1055" y="795" style="font-size: 12px; fill: #f9f9f9" >#6B7075</text>
<rect x="1050" y="800" width="150" height="50" style="fill: #555B61" />
<text x="1055" y="829" style="font-size: 16px; fill: #f9f9f9" >grey6</text>
<text x="1055" y="845" style="font-size: 12px; fill: #f9f9f9" >#555B61</text>
<rect x="1050" y="850" width="150" height="50" style="fill: #41464C" />
<text x="1055" y="879" style="font-size: 16px; fill: #f9f9f9" >grey7</text>
<text x="1055" y="895" style="font-size: 12px; fill: #f9f9f9" >#41464C</text>
<rect x="1050" y="900" width="150" height="50" style="fill: #2E3238" />
<text x="1055" y="929" style="font-size: 16px; fill: #f9f9f9" >grey8</text>
<text x="1055" y="945" style="font-size: 12px; fill: #f9f9f9" >#2E3238</text>
<rect x="1050" y="950" width="150" height="50" style="fill: #1C1F23" />
<text x="1055" y="979" style="font-size: 16px; fill: #f9f9f9" >grey9</text>
<text x="1055" y="995" style="font-size: 12px; fill: #f9f9f9" >#1C1F23</text>
<rect x="0" y="1000" width="600" height="50" style="fill: #FFFFFF" />
<text x="5" y="1029" style="font-size: 16px; fill: #808080" >white</text>
<text x="5" y="1045" style="font-size: 12px; fill: #808080" >#FFFFFF</text>
<rect x="600" y="1000" width="600" height="50" style="fill: #000000" />
<text x="605" y="1029" style="font-size: 16px; fill: #808080" >black</text>
<text x="605" y="1045" style="font-size: 12px; fill: #808080" >#000000</text>
</svg>

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 184 KiB

View File

@ -0,0 +1,170 @@
// C interface for bytebox wasm runtime.
#include <stdint.h>
#include <stdbool.h>
struct bb_slice
{
char* data;
size_t length;
};
typedef struct bb_slice bb_slice;
enum bb_error
{
BB_ERROR_OK,
BB_ERROR_FAILED,
BB_ERROR_OUTOFMEMORY,
BB_ERROR_INVALIDPARAM,
BB_ERROR_UNKNOWNEXPORT,
BB_ERROR_UNKNOWNIMPORT,
BB_ERROR_INCOMPATIBLEIMPORT,
BB_ERROR_TRAP_DEBUG,
BB_ERROR_TRAP_UNREACHABLE,
BB_ERROR_TRAP_INTEGERDIVISIONBYZERO,
BB_ERROR_TRAP_INTEGEROVERFLOW,
BB_ERROR_TRAP_INDIRECTCALLTYPEMISMATCH,
BB_ERROR_TRAP_INVALIDINTEGERCONVERSION,
BB_ERROR_TRAP_OUTOFBOUNDSMEMORYACCESS,
BB_ERROR_TRAP_UNDEFINEDELEMENT,
BB_ERROR_TRAP_UNINITIALIZEDELEMENT,
BB_ERROR_TRAP_OUTOFBOUNDSTABLEACCESS,
BB_ERROR_TRAP_STACKEXHAUSTED,
};
typedef enum bb_error bb_error;
enum bb_valtype
{
BB_VALTYPE_I32,
BB_VALTYPE_I64,
BB_VALTYPE_F32,
BB_VALTYPE_F64,
};
typedef enum bb_valtype bb_valtype;
typedef float bb_v128[4];
union bb_val
{
int32_t i32_val;
int64_t i64_val;
float f32_val;
double f64_val;
bb_v128 v128_val;
uint32_t externref_val;
};
typedef union bb_val bb_val;
struct bb_module_definition_init_opts
{
const char* debug_name;
};
typedef struct bb_module_definition_init_opts bb_module_definition_init_opts;
typedef struct bb_module_definition bb_module_definition;
typedef struct bb_module_instance bb_module_instance;
typedef struct bb_import_package bb_import_package;
typedef void bb_host_function(void* userdata, bb_module_instance* module, const bb_val* params, bb_val* returns);
typedef void* bb_wasm_memory_resize(void* mem, size_t new_size_bytes, size_t old_size_bytes, void* userdata);
typedef void bb_wasm_memory_free(void* mem, size_t size_bytes, void* userdata);
struct bb_module_instance_instantiate_opts
{
bb_import_package** packages;
size_t num_packages;
struct {
bb_wasm_memory_resize* resize_callback;
bb_wasm_memory_free* free_callback;
void* userdata;
} wasm_memory_config;
size_t stack_size;
bool enable_debug;
};
typedef struct bb_module_instance_instantiate_opts bb_module_instance_instantiate_opts;
struct bb_module_instance_invoke_opts
{
bool trap_on_start;
};
typedef struct bb_module_instance_invoke_opts bb_module_instance_invoke_opts;
struct bb_func_handle
{
uint32_t index;
uint32_t type;
};
typedef struct bb_func_handle bb_func_handle;
struct bb_func_info
{
bb_valtype* params;
size_t num_params;
bb_valtype* returns;
size_t num_returns;
};
typedef struct bb_func_info bb_func_info;
enum bb_global_mut
{
BB_GLOBAL_MUT_IMMUTABLE,
BB_GLOBAL_MUT_MUTABLE,
};
typedef enum bb_global_mut bb_global_mut;
struct bb_global
{
bb_val* value;
bb_valtype type;
bb_global_mut mut;
};
typedef struct bb_global bb_global;
enum bb_debug_trace_mode
{
BB_DEBUG_TRACE_NONE,
BB_DEBUG_TRACE_FUNCTION,
BB_DEBUG_TRACE_INSTRUCTION,
};
typedef enum bb_debug_trace_mode bb_debug_trace_mode;
enum bb_debug_trap_mode
{
BB_DEBUG_TRAP_MODE_DISABLED,
BB_DEBUG_TRAP_MODE_ENABLED,
};
typedef enum bb_debug_trap_mode bb_debug_trap_mode;
// typedef void* bb_malloc_func(size_t size, void* userdata);
// typedef void* bb_realloc_func(void* mem, size_t size, void* userdata);
// typedef void bb_free_func(void* mem, void* userdata);
// void bb_set_memory_hooks(bb_alloc_func* alloc_func, bb_realloc_func* realloc_func, bb_free_func);
const char* bb_error_str(bb_error err);
bb_module_definition* bb_module_definition_init(bb_module_definition_init_opts opts);
void bb_module_definition_deinit(bb_module_definition* definition);
bb_error bb_module_definition_decode(bb_module_definition* definition, const char* data, size_t length);
bb_slice bb_module_definition_get_custom_section(const bb_module_definition* definition, const char* name);
bb_import_package* bb_import_package_init(const char* name);
void bb_import_package_deinit(bb_import_package* package); // only deinit when all module_instances using the package have been deinited
bb_error bb_import_package_add_function(bb_import_package* package, bb_host_function* func, const char* export_name, bb_valtype* params, size_t num_params, bb_valtype* returns, size_t num_returns, void* userdata);
void bb_set_debug_trace_mode(bb_debug_trace_mode mode);
bb_module_instance* bb_module_instance_init(bb_module_definition* definition);
void bb_module_instance_deinit(bb_module_instance* instance);
bb_error bb_module_instance_instantiate(bb_module_instance* instance, bb_module_instance_instantiate_opts opts);
bb_error bb_module_instance_find_func(bb_module_instance* instance, const char* func_name, bb_func_handle* out_handle);
bb_func_info bb_module_instance_func_info(bb_module_instance* instance, bb_func_handle handle);
bb_error bb_module_instance_invoke(bb_module_instance* instance, bb_func_handle, const bb_val* params, size_t num_params, bb_val* returns, size_t num_returns, bb_module_instance_invoke_opts opts);
bb_error bb_module_instance_resume(bb_module_instance* instance, bb_val* returns, size_t num_returns);
bb_error bb_module_instance_step(bb_module_instance* instance, bb_val* returns, size_t num_returns);
bb_error bb_module_instance_debug_set_trap(bb_module_instance* instance, uint32_t address, bb_debug_trap_mode trap_mode);
void* bb_module_instance_mem(bb_module_instance* instance, size_t offset, size_t length);
bb_slice bb_module_instance_mem_all(bb_module_instance* instance);
bb_error bb_module_instance_mem_grow(bb_module_instance* instance, size_t num_pages);
bb_global bb_module_instance_find_global(bb_module_instance* instance, const char* global_name);
bool bb_func_handle_isvalid(bb_func_handle handle);

4
ext/bytebox/update.cmd Normal file
View File

@ -0,0 +1,4 @@
@mkdir include 2> nul
@mkdir lib 2> nul
cp E:\Dev\zig_projects\bytebox\zig-out\include\bytebox.h include\bytebox.h
cp E:\Dev\zig_projects\bytebox\zig-out\lib\bytebox.lib lib\bytebox.lib

View File

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

View File

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 86 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

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