├── .clang-format ├── .gitignore ├── .travis.yml ├── .vscode └── settings.json ├── 3rdparty ├── delaunay │ ├── CMakeLists.txt │ ├── LICENSE │ ├── README.md │ ├── delaunay.c │ └── delaunay.h ├── sjson │ ├── LICENSE │ ├── README.md │ └── sjson.h ├── sproutline │ ├── README.md │ └── sproutline.h ├── stb │ ├── README.md │ ├── stb_image.h │ ├── stb_image_resize.h │ ├── stb_image_write.h │ └── stb_rect_pack.h └── sx │ ├── 3rdparty │ ├── getopt │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── appveyor.yml │ │ ├── bam.lua │ │ ├── example │ │ │ └── example.cpp │ │ ├── include │ │ │ └── getopt │ │ │ │ └── getopt.h │ │ ├── src │ │ │ └── getopt.c │ │ └── test │ │ │ ├── getopt_tests.cpp │ │ │ └── greatest.h │ ├── mattias │ │ ├── README.md │ │ ├── ini.h │ │ ├── ini.md │ │ └── strpool.h │ ├── sokol │ │ ├── LICENSE │ │ ├── README.md │ │ └── sokol_time.h │ ├── stb │ │ └── stb_printf.h │ ├── tlsf │ │ ├── README.md │ │ ├── tlsf.c │ │ └── tlsf.h │ └── xxhash │ │ ├── LICENSE │ │ ├── README.md │ │ ├── xxhash.c │ │ ├── xxhash.h │ │ └── xxhash_spec.md │ ├── CMakeLists.txt │ ├── LICENSE │ ├── README.md │ ├── asm │ ├── jump_arm64_aapcs_elf_gas.S │ ├── jump_arm64_aapcs_macho_gas.S │ ├── jump_arm_aapcs_elf_gas.S │ ├── jump_arm_aapcs_macho_gas.S │ ├── jump_arm_aapcs_pe_armasm.asm │ ├── jump_combined_all_macho_gas.S │ ├── jump_combined_sysv_macho_gas.S │ ├── jump_i386_ms_pe_gas.asm │ ├── jump_i386_ms_pe_masm.asm │ ├── jump_i386_sysv_elf_gas.S │ ├── jump_i386_sysv_macho_gas.S │ ├── jump_i386_x86_64_sysv_macho_gas.S │ ├── jump_mips32_o32_elf_gas.S │ ├── jump_ppc32_ppc64_sysv_macho_gas.S │ ├── jump_ppc32_sysv_elf_gas.S │ ├── jump_ppc32_sysv_macho_gas.S │ ├── jump_ppc32_sysv_xcoff_gas.S │ ├── jump_ppc64_sysv_elf_gas.S │ ├── jump_ppc64_sysv_macho_gas.S │ ├── jump_ppc64_sysv_xcoff_gas.S │ ├── jump_x86_64_ms_pe_gas.asm │ ├── jump_x86_64_ms_pe_masm.asm │ ├── jump_x86_64_sysv_elf_gas.S │ ├── jump_x86_64_sysv_macho_gas.S │ ├── make_arm64_aapcs_elf_gas.S │ ├── make_arm64_aapcs_macho_gas.S │ ├── make_arm_aapcs_elf_gas.S │ ├── make_arm_aapcs_macho_gas.S │ ├── make_arm_aapcs_pe_armasm.asm │ ├── make_combined_all_macho_gas.S │ ├── make_combined_sysv_macho_gas.S │ ├── make_i386_ms_pe_gas.asm │ ├── make_i386_ms_pe_masm.asm │ ├── make_i386_sysv_elf_gas.S │ ├── make_i386_sysv_macho_gas.S │ ├── make_i386_x86_64_sysv_macho_gas.S │ ├── make_mips32_o32_elf_gas.S │ ├── make_ppc32_ppc64_sysv_macho_gas.S │ ├── make_ppc32_sysv_elf_gas.S │ ├── make_ppc32_sysv_macho_gas.S │ ├── make_ppc32_sysv_xcoff_gas.S │ ├── make_ppc64_sysv_elf_gas.S │ ├── make_ppc64_sysv_macho_gas.S │ ├── make_ppc64_sysv_xcoff_gas.S │ ├── make_x86_64_ms_pe_gas.asm │ ├── make_x86_64_ms_pe_masm.asm │ ├── make_x86_64_sysv_elf_gas.S │ ├── make_x86_64_sysv_macho_gas.S │ ├── ontop_arm64_aapcs_elf_gas.S │ ├── ontop_arm64_aapcs_macho_gas.S │ ├── ontop_arm_aapcs_elf_gas.S │ ├── ontop_arm_aapcs_macho_gas.S │ ├── ontop_arm_aapcs_pe_armasm.asm │ ├── ontop_combined_all_macho_gas.S │ ├── ontop_combined_sysv_macho_gas.S │ ├── ontop_i386_ms_pe_gas.asm │ ├── ontop_i386_ms_pe_masm.asm │ ├── ontop_i386_sysv_elf_gas.S │ ├── ontop_i386_sysv_macho_gas.S │ ├── ontop_i386_x86_64_sysv_macho_gas.S │ ├── ontop_mips32_o32_elf_gas.S │ ├── ontop_ppc32_ppc64_sysv_macho_gas.S │ ├── ontop_ppc32_sysv_elf_gas.S │ ├── ontop_ppc32_sysv_macho_gas.S │ ├── ontop_ppc32_sysv_xcoff_gas.S │ ├── ontop_ppc64_sysv_elf_gas.S │ ├── ontop_ppc64_sysv_macho_gas.S │ ├── ontop_ppc64_sysv_xcoff_gas.S │ ├── ontop_x86_64_ms_pe_gas.asm │ ├── ontop_x86_64_ms_pe_masm.asm │ ├── ontop_x86_64_sysv_elf_gas.S │ └── ontop_x86_64_sysv_macho_gas.S │ ├── include │ ├── compat │ │ ├── freebsd │ │ │ ├── alloca.h │ │ │ ├── dirent.h │ │ │ ├── malloc.h │ │ │ └── signal.h │ │ ├── ios │ │ │ └── malloc.h │ │ ├── mingw │ │ │ ├── alloca.h │ │ │ ├── dirent.h │ │ │ ├── sal.h │ │ │ ├── salieri.h │ │ │ ├── specstrings_strict.h │ │ │ └── specstrings_undef.h │ │ ├── msvc │ │ │ ├── alloca.h │ │ │ ├── dirent.h │ │ │ ├── inttypes.h │ │ │ ├── pre1600 │ │ │ │ └── stdint.h │ │ │ └── stdbool.h │ │ └── osx │ │ │ └── malloc.h │ └── sx │ │ ├── _simd.h │ │ ├── allocator.h │ │ ├── array.h │ │ ├── atomic.h │ │ ├── bheap.h │ │ ├── cmdline.h │ │ ├── config.h │ │ ├── fiber.h │ │ ├── handle.h │ │ ├── hash.h │ │ ├── ini.h │ │ ├── io.h │ │ ├── jobs.h │ │ ├── lin-alloc.h │ │ ├── macros.h │ │ ├── math.h │ │ ├── os.h │ │ ├── platform.h │ │ ├── pool.h │ │ ├── rng.h │ │ ├── simd.h │ │ ├── stack-alloc.h │ │ ├── string.h │ │ ├── sx.h │ │ ├── threads.h │ │ ├── timer.h │ │ ├── tlsf-alloc.h │ │ └── virtual-alloc.h │ └── src │ ├── allocator.c │ ├── bheap.c │ ├── cmdline.c │ ├── fiber.c │ ├── handle.c │ ├── hash.c │ ├── ini.c │ ├── io.c │ ├── jobs.c │ ├── lin-alloc.c │ ├── math.c │ ├── os.c │ ├── rng.c │ ├── stack-alloc.c │ ├── string.c │ ├── sx.c │ ├── threads.c │ ├── timer.c │ ├── tlsf-alloc.c │ └── virtual-alloc.c ├── CMakeLists.txt ├── LICENSE ├── README.md ├── img └── drawsprite-wire.png ├── include └── atlasc.h └── src └── atlasc.c /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | AlignAfterOpenBracket: Align 3 | AlignConsecutiveAssignments: 'false' 4 | AlignConsecutiveDeclarations: 'false' 5 | AlignEscapedNewlines: Left 6 | AlignTrailingComments: 'true' 7 | AllowAllParametersOfDeclarationOnNextLine: 'true' 8 | AllowShortBlocksOnASingleLine: 'false' 9 | AllowShortCaseLabelsOnASingleLine: 'false' 10 | AllowShortFunctionsOnASingleLine: Inline 11 | AllowShortIfStatementsOnASingleLine: 'false' 12 | AllowShortLoopsOnASingleLine: 'false' 13 | AlwaysBreakBeforeMultilineStrings: 'true' 14 | AlwaysBreakTemplateDeclarations: 'true' 15 | BreakBeforeBinaryOperators: None 16 | BreakBeforeBraces: Linux 17 | ColumnLimit: '100' 18 | Cpp11BracedListStyle: 'false' 19 | IncludeBlocks: Preserve 20 | IndentCaseLabels: 'false' 21 | IndentPPDirectives: AfterHash 22 | IndentWidth: '4' 23 | IndentWrappedFunctionNames: 'true' 24 | Language: Cpp 25 | MaxEmptyLinesToKeep: '2' 26 | NamespaceIndentation: Inner 27 | PointerAlignment: Left 28 | SpaceBeforeAssignmentOperators: 'true' 29 | SpaceBeforeParens: ControlStatements 30 | SpaceInEmptyParentheses: 'false' 31 | SpacesBeforeTrailingComments: '4' 32 | SpacesInCStyleCastParentheses: 'false' 33 | SpacesInContainerLiterals: 'false' 34 | SpacesInParentheses: 'false' 35 | Standard: Cpp11 36 | TabWidth: '4' 37 | UseTab: Never 38 | 39 | ... 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # External junk 2 | .DS_Store 3 | _ReSharper* 4 | *.opensdf 5 | *.sdf 6 | *.dir 7 | *.suo 8 | *.user 9 | *.bak 10 | Win32 11 | Win64 12 | Debug 13 | Release 14 | Profile 15 | Development 16 | Obj 17 | Bin 18 | Lib 19 | .tags 20 | .tags_sorted_by_file 21 | *.lnk 22 | ipch 23 | __pycache__ 24 | Thumbs.db 25 | .build* 26 | 27 | # Gradle 28 | .gradle 29 | /local.properties 30 | /.idea/workspace.xml 31 | /.idea/libraries 32 | /build 33 | /build-* 34 | /captures 35 | 36 | # assets 37 | assets/shaders/* 38 | 39 | # Generated files 40 | bin 41 | docs/Doxyfile 42 | docs/html 43 | docs/warnings.txt 44 | imgui.ini 45 | install 46 | *.log 47 | .vscode/launch.json 48 | .vscode/c_cpp_properties.json 49 | shaders_h 50 | src/rizz/plugin_bundle.h 51 | src/rizz/plugin_bundle_native.h 52 | android 53 | assets-db.json 54 | 55 | # temp 56 | scripts/generators/fake_libc_include 57 | temp 58 | 59 | # Compiled binaries 60 | *.so 61 | *.dylib 62 | *.dll 63 | *.a 64 | *.lib 65 | *.exe 66 | .build 67 | *.fso 68 | *.vso 69 | *.pyc 70 | *.obj 71 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: sh 2 | os: 3 | - linux 4 | - osx 5 | - windows 6 | 7 | addons: 8 | apt: 9 | packages: 10 | - gcc 11 | - cmake 12 | 13 | before_script: 14 | - mkdir build 15 | - cd build 16 | 17 | script: 18 | - if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then cmake .. -DCMAKE_BUILD_TYPE=Release; fi 19 | - if [[ "$TRAVIS_OS_NAME" != "windows" ]]; then make; fi 20 | - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then PATH=$PATH:/c/Program\ Files/CMake/bin; fi 21 | - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then cmake .. -G "Visual Studio 15 2017 Win64"; fi 22 | - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then cmake --build . --config Release --target ALL_BUILD -- -verbosity:m; fi 23 | 24 | branches: 25 | only: 26 | - master 27 | 28 | notifications: 29 | email: false -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "config.h": "c", 4 | "sokol_gfx.h": "c", 5 | "efsw.h": "c", 6 | "threads.h": "c", 7 | "array": "cpp", 8 | "string_view": "cpp", 9 | "memory": "c", 10 | "thread": "cpp", 11 | "initializer_list": "c", 12 | "utility": "c", 13 | "font-roboto.h": "c", 14 | "types.h": "c", 15 | "system_error": "c", 16 | "stc-parse.h": "c", 17 | "gfx-types.h": "c", 18 | "gfx.h": "c", 19 | "string.h": "c", 20 | "stb_image.h": "c", 21 | "dds-ktx.h": "c", 22 | "fcntl.h": "c", 23 | "sort.h": "c", 24 | "os.h": "c", 25 | "asset.h": "c", 26 | "sendfile.h": "c", 27 | "sysctl.h": "c", 28 | "profiler.h": "c", 29 | "remotery.h": "c", 30 | "typeinfo": "c", 31 | "core.h": "c", 32 | "reflect.h": "c", 33 | "app.h": "c", 34 | "graphics.h": "c", 35 | "_sg-types.h": "c", 36 | "cmath": "cpp", 37 | "jobs.h": "c", 38 | "atomic.h": "c", 39 | "stb_printf.h": "c", 40 | "fiber.h": "c", 41 | "sokol_app.h": "c", 42 | "ratio": "c", 43 | "type_traits": "c", 44 | "features.h": "c", 45 | "wordsize.h": "c", 46 | "allocator.h": "c", 47 | "macros.h": "c", 48 | "bheap.h": "c", 49 | "sokol_time.h": "c", 50 | "imgui.frag.h": "c", 51 | "math.h": "c", 52 | "gl.h": "c", 53 | "glew.h": "c", 54 | "glext.h": "c", 55 | "sproutline.h": "c", 56 | "stb_image_write.h": "c", 57 | "sjson.h": "c" 58 | }, 59 | "files.exclude": { 60 | "**/.git": true, 61 | "**/.svn": true, 62 | "**/.hg": true, 63 | "**/CVS": true, 64 | "**/.DS_Store": true, 65 | ".vscode/ipch/**": true, 66 | "bin/**": true, 67 | "build/**": true, 68 | "scripts/generators/fake_libc_include*": true, 69 | "misc/**": true 70 | }, 71 | "C_Cpp.configurationWarnings": "Disabled", 72 | "C_Cpp.clang_format_style": "file" 73 | } -------------------------------------------------------------------------------- /3rdparty/delaunay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8 FATAL_ERROR) 2 | 3 | project(delaunay C) 4 | 5 | set(CMAKE_SKIP_RULE_DEPENDENCY TRUE) 6 | 7 | add_library( 8 | delaunay 9 | STATIC 10 | delaunay.c 11 | delaunay.h 12 | ) 13 | -------------------------------------------------------------------------------- /3rdparty/delaunay/README.md: -------------------------------------------------------------------------------- 1 | # Relatively Robust Divide and Conquer 2D Delaunay Construction Algorithm 2 | 3 | Copyright 2005-2017 (c) Wael El Oraiby, All rights reserved. 4 | 5 | ### Introduction 6 | 7 | This is a library that builds a 2D Delaunay Construction using a divide and conquer algorithm very similar to the one by Guibas and Stolfi. 8 | 9 | Given a set of inputs points, the program will output Delaunay faces (not necessarily triangles, as long as the points are circumscribed to a circle). 10 | 11 | ### Contributors 12 | * Raja Lehtihet (bug fixes and suggestions) 13 | * Radovan Bast (CMake build system) 14 | 15 | Thanks to: 16 | * Dominique Schmitt and Jean-Claude Spehner for their valuable help and support. 17 | * Jonathan Richard Shewchuk for the robust computational geometry predicates. 18 | 19 | 20 | ### Configuration and compilation using CMake and Make 21 | 22 | ``` 23 | $ mkdir build 24 | $ cd build 25 | $ cmake .. 26 | $ make 27 | ``` 28 | 29 | 30 | ### Usage 31 | 32 | The algorithm builds the 2D Delaunay triangulation given a set of points of at least 33 | 3 points using: 34 | 35 | delaunay2d_t* delaunay2d_from(del_point2d_t *points, unsigned int num_points); 36 | 37 | - `points` : point set given as a sequence of tuple x0, y0, x1, y1, .... 38 | - `num_points` : number of given point 39 | - `pred` : the incircle predicate. 40 | - `return value` : the created topology 41 | 42 | the returned `delaunay2d_t` structures contains: 43 | - `num_points` : the input point count 44 | - `points` : a copy of the input points 45 | - `num_faces` : the output face count 46 | - `faces` : the output faces indices (faces are not necessarily triangles). The first face is the external face. 47 | 48 | You have to release the structure by calling `delaunay2d_release`. 49 | 50 | See the provided example if you want more information. The example requires Qt 5 however. 51 | 52 | ### Triangulated Output 53 | A new feature is the ability to triangulate the output of the `delaunay2d` function. The function for doing so is: 54 | 55 | tri_delaunay2d_t* tri_delaunay2d_from(delaunay2d_t *orig); 56 | 57 | This will create a new structure that has the following fields: 58 | 59 | - `num_points` : input points count 60 | - `points` : a copy of the input points (from orig) 61 | - `num_triangles` : number of triangles 62 | - `tris` : the triangles indices v0,v1,v2, v0,v1,v2 .... 63 | 64 | Release the `tri_delaunay2d_t` structure by calling `tri_delaunay2d_release`. 65 | 66 | ### Robustness 67 | Currently robustness is achieved by using 64 bits precision inputs and computation using 80 bits. It's possible to achieve the maximum fast robustness using __float128 for computation (without using a slow BigFloat library). This however is not supported with ARM. 68 | 69 | Historical Note: Previous version of delaunay used the Predicates from Jonathan Richard Shewchuk. The code is however unstable when compiled with gcc with -m32 and run on x64 machines. As such the code was removed. 70 | 71 | ### Examples 72 | ![random](https://github.com/eloraiby/delaunay/raw/master/images/random.png) 73 | ![grid](https://github.com/eloraiby/delaunay/raw/master/images/grid.png) 74 | ![vertical and horizontal lines](https://github.com/eloraiby/delaunay/raw/master/images/vertical_horizontal.png) 75 | ![circles](https://github.com/eloraiby/delaunay/raw/master/images/circles.png) 76 | 77 | ### Notes 78 | 79 | The implementation is relatively robust (take a look at the pictures above, some of these cases will crash most freely available implementations), in case of input or predicate floating point rounding errors, it will assert. Note that while the robustness is more than enough for most application, there is still room for improvement. 80 | 81 | ### License 82 | 83 | The delaunay.c source code is licensed under Affero GPL version 3.0 or later. While I think this license is the best for OSS, you can obtain a more permissive license suitable for closed source programs for a modest fee. You can contact me for that [contact me](https://github.com/eloraiby/eloraiby.github.com/raw/master/email.svg). 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /3rdparty/delaunay/delaunay.h: -------------------------------------------------------------------------------- 1 | #ifndef DELAUNAY_H 2 | #define DELAUNAY_H 3 | 4 | /* 5 | ** delaunay.c : compute 2D delaunay triangulation in the plane. 6 | ** Copyright (C) 2005 Wael El Oraiby 7 | ** 8 | ** 9 | ** This program is free software: you can redistribute it and/or modify 10 | ** it under the terms of the GNU Affero General Public License as 11 | ** published by the Free Software Foundation, either version 3 of the 12 | ** License, or (at your option) any later version. 13 | ** 14 | ** This program is distributed in the hope that it will be useful, 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | ** GNU Affero General Public License for more details. 18 | ** 19 | ** You should have received a copy of the GNU Affero General Public License 20 | ** along with this program. If not, see . 21 | */ 22 | 23 | 24 | 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | typedef double real; 31 | 32 | typedef struct { 33 | real x, y; 34 | } del_point2d_t; 35 | 36 | typedef struct { 37 | /** input points count */ 38 | unsigned int num_points; 39 | 40 | /** the input points */ 41 | del_point2d_t* points; 42 | 43 | /** number of returned faces */ 44 | unsigned int num_faces; 45 | 46 | /** the faces are given as a sequence: num verts, verts indices, num verts, verts indices... 47 | * the first face is the external face */ 48 | unsigned int* faces; 49 | } delaunay2d_t; 50 | 51 | /* 52 | * build the 2D Delaunay triangulation given a set of points of at least 3 points 53 | * 54 | * @points: point set given as a sequence of tuple x0, y0, x1, y1, .... 55 | * @num_points: number of given point 56 | * @preds: the incircle predicate 57 | * @faces: the triangles given as a sequence: num verts, verts indices, num verts, verts indices. 58 | * Note that the first face is the external face 59 | * @return: the created topology 60 | */ 61 | delaunay2d_t* delaunay2d_from(del_point2d_t *points, unsigned int num_points); 62 | 63 | /* 64 | * release a delaunay2d object 65 | */ 66 | void delaunay2d_release(delaunay2d_t* del); 67 | 68 | 69 | typedef struct { 70 | /** input points count */ 71 | unsigned int num_points; 72 | 73 | /** input points */ 74 | del_point2d_t* points; 75 | 76 | /** number of triangles */ 77 | unsigned int num_triangles; 78 | 79 | /** the triangles indices v0,v1,v2, v0,v1,v2 .... */ 80 | unsigned int* tris; 81 | } tri_delaunay2d_t; 82 | 83 | /** 84 | * build a tri_delaunay2d_t out of a delaunay2d_t object 85 | */ 86 | tri_delaunay2d_t* tri_delaunay2d_from(delaunay2d_t* del); 87 | 88 | /** 89 | * release a tri_delaunay2d_t object 90 | */ 91 | void tri_delaunay2d_release(tri_delaunay2d_t* tdel); 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif // DELAUNAY_H 98 | -------------------------------------------------------------------------------- /3rdparty/sjson/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2018, Sepehr Taghdisian 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /3rdparty/sjson/README.md: -------------------------------------------------------------------------------- 1 | ## sjson: Fast and portable C single header json Encoder/Decoder 2 | [@septag](https://twitter.com/septagh) 3 | 4 | This is actually a fork of Joseph's awesome Json encoder/decoder code from his [repo](https://github.com/rustyrussell/ccan/tree/master/ccan/json). 5 | If you want to see the performance and analysis of the original encoder/decoder (which is _ccan/json_) visit [here](https://github.com/miloyip/nativejson-benchmark). 6 | The encoder/decoder code is almost the same. What I did was adding object pools and string pages (sjson_context) 7 | that eliminates many micro memory allocations, which should improve encode/decode speed and data access performance. 8 | I also added malloc/free and libc API overrides, and made the library single header, so it makes it very easy to integrate it into other programs 9 | 10 | ### Features 11 | 12 | - Single header C-file 13 | - UTF8 support 14 | - Fast with minimal allocations (Internal Object pool, String pool, ..) 15 | - Overriable libc functions like malloc/free/memcpy/.. 16 | - Supports both Json encoding and decoding 17 | - Encoder supports prettify 18 | - No dependencies 19 | - Simple and easy to use C-API 20 | 21 | ### Usage 22 | 23 | ```c 24 | #define SJSON_IMPLEMENTATION 25 | #include "sjson.h" 26 | ``` 27 | 28 | For more information, check out the header file itself. 29 | 30 | [License (BSD 2-clause)](https://github.com/septag/sjson/blob/master/LICENSE) 31 | -------------------------------------------------------------------------- 32 | 33 | 34 | 35 | 36 | 37 | Copyright 2018 Sepehr Taghdisian. All rights reserved. 38 | 39 | https://github.com/septag/sjson 40 | 41 | Redistribution and use in source and binary forms, with or without 42 | modification, are permitted provided that the following conditions are met: 43 | 44 | 1. Redistributions of source code must retain the above copyright notice, 45 | this list of conditions and the following disclaimer. 46 | 47 | 2. Redistributions in binary form must reproduce the above copyright notice, 48 | this list of conditions and the following disclaimer in the documentation 49 | and/or other materials provided with the distribution. 50 | 51 | THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR 52 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 53 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 54 | EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 55 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 56 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 57 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 58 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 59 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 60 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 61 | 62 | -------------------------------------------------------------------------------- /3rdparty/sproutline/README.md: -------------------------------------------------------------------------------- 1 | # Sproutline 2 | 3 | A small single-file library for sprite outline extraction and simplification for C/C++. 4 | 5 | **Input:** Sprite with an alpha channel. 6 | 7 | **Output:** All the outline paths (simplified, if necessary) for objects in the sprite image. 8 | 9 | *'sproutline.h'* is the whole library. 10 | It follows the stb philosophy. 11 | Everything else here is example code, an example image and this readme. 12 | 13 | # Pipeline 14 | ![Sproutline pipeline](https://github.com/ands/sproutline/raw/master/README_pipeline.png) -------------------------------------------------------------------------------- /3rdparty/sx/3rdparty/getopt/.gitignore: -------------------------------------------------------------------------------- 1 | .bam 2 | .cproject 3 | .project 4 | local 5 | 6 | -------------------------------------------------------------------------------- /3rdparty/sx/3rdparty/getopt/.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | compiler: 3 | - gcc 4 | - clang 5 | 6 | install: 7 | - git clone https://github.com/matricks/bam.git 8 | - cd bam 9 | - ./make_unix.sh 10 | - cd .. 11 | 12 | script: 13 | - bam/bam compiler=$CC config=debug 14 | - bam/bam compiler=$CC config=release 15 | - ./local/linux_x86_64/debug/getopt_tests 16 | - ./local/linux_x86_64/release/getopt_tests 17 | -------------------------------------------------------------------------------- /3rdparty/sx/3rdparty/getopt/LICENSE: -------------------------------------------------------------------------------- 1 | a getopt. 2 | 3 | version 0.1, march, 2012 4 | 5 | Copyright (C) 2012- Fredrik Kihlander 6 | 7 | https://github.com/wc-duck/getopt 8 | 9 | This software is provided 'as-is', without any express or implied 10 | warranty. In no event will the authors be held liable for any damages 11 | arising from the use of this software. 12 | 13 | Permission is granted to anyone to use this software for any purpose, 14 | including commercial applications, and to alter it and redistribute it 15 | freely, subject to the following restrictions: 16 | 17 | 1. The origin of this software must not be misrepresented; you must not 18 | claim that you wrote the original software. If you use this software 19 | in a product, an acknowledgment in the product documentation would be 20 | appreciated but is not required. 21 | 2. Altered source versions must be plainly marked as such, and must not be 22 | misrepresented as being the original software. 23 | 3. This notice may not be removed or altered from any source distribution. 24 | 25 | Fredrik Kihlander 26 | -------------------------------------------------------------------------------- /3rdparty/sx/3rdparty/getopt/README.md: -------------------------------------------------------------------------------- 1 | # getopt - command line options parser in c 2 | 3 | [![Build Status](https://travis-ci.org/wc-duck/getopt.svg?branch=master)](https://travis-ci.org/wc-duck/getopt) 4 | [![Build status](https://ci.appveyor.com/api/projects/status/4twbkbyhj7h7i689)](https://ci.appveyor.com/project/wc-duck/getopt) 5 | 6 | ## About: 7 | This module aims to be a simple drop-in argc/argv-parser for c/cpp-code. getopt support 8 | short ( -s ) and long ( --long ) options, flags and help-generation. 9 | 10 | ## Example: 11 | This is a simple example showing of most of the features: 12 | 13 | ```c 14 | #include 15 | #include 16 | 17 | int verbose = 0; // verbose flag 18 | 19 | static const getopt_option_t option_list[] = 20 | { 21 | { "help", 'h', GETOPT_OPTION_TYPE_NO_ARG, 0x0, 'h', "print this help text", 0x0 }, 22 | { "verbose", 'v', GETOPT_OPTION_TYPE_FLAG_SET, &verbose, 1, "verbose logging enabled", 0x0 }, 23 | { "input", 'i', GETOPT_OPTION_TYPE_REQUIRED, 0x0, 'i', "an input file", "FILE" }, 24 | GETOPT_OPTIONS_END 25 | }; 26 | 27 | static void print_help_string( getopt_context_t ctx ) 28 | { 29 | char buffer[2048]; 30 | printf( "%s\n", getopt_create_help_string( &ctx, buffer, sizeof( buffer ) ) ); 31 | } 32 | 33 | int main( int argc, const char** argv ) 34 | { 35 | getopt_context_t ctx; 36 | if( getopt_create_context( &ctx, argc, argv, option_list ) < 0 ) 37 | { 38 | printf( "error while creating getopt ctx, bad options-list?" ); 39 | return 1; 40 | } 41 | 42 | int opt; 43 | 44 | while( ( opt = getopt_next( &ctx ) ) != -1 ) 45 | { 46 | switch( opt ) 47 | { 48 | case '+': printf( "got argument without flag: %s\n", ctx.current_opt_arg ); break; 49 | case '?': printf( "unknown flag %s\n", ctx.current_opt_arg ); break; 50 | case '!': printf( "invalid use of flag %s\n", ctx.current_opt_arg ); break; 51 | case 'i': printf( "got -i or --input with value %s\n", ctx.current_opt_arg ); break; 52 | case 0: printf( "flag was set!\n"); break; 53 | case 'h': print_help_string( ctx ); break; 54 | default: break; 55 | } 56 | } 57 | 58 | if( verbose > 0 ) 59 | printf( "verbose flag was set!" ); 60 | } 61 | 62 | 63 | ``` 64 | 65 | -------------------------------------------------------------------------------- /3rdparty/sx/3rdparty/getopt/appveyor.yml: -------------------------------------------------------------------------------- 1 | platform: 2 | - x86 3 | 4 | install: 5 | - c:\"Program Files (x86)"\"Microsoft Visual Studio 12.0"\VC\vcvarsall.bat 6 | - git clone https://github.com/matricks/bam.git 7 | - cd bam 8 | - make_win64_msvc.bat 9 | - cd .. 10 | - bam\bam.exe config=debug 11 | - bam\bam.exe config=release 12 | - local\winx64\debug\getopt_tests.exe 13 | - local\winx64\release\getopt_tests.exe 14 | 15 | build: off 16 | 17 | -------------------------------------------------------------------------------- /3rdparty/sx/3rdparty/getopt/bam.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | a getopt. 3 | version 0.1, march, 2012 4 | 5 | Copyright (C) 2012- Fredrik Kihlander 6 | 7 | This software is provided 'as-is', without any express or implied 8 | warranty. In no event will the authors be held liable for any damages 9 | arising from the use of this software. 10 | 11 | Permission is granted to anyone to use this software for any purpose, 12 | including commercial applications, and to alter it and redistribute it 13 | freely, subject to the following restrictions: 14 | 15 | 1. The origin of this software must not be misrepresented; you must not 16 | claim that you wrote the original software. If you use this software 17 | in a product, an acknowledgment in the product documentation would be 18 | appreciated but is not required. 19 | 2. Altered source versions must be plainly marked as such, and must not be 20 | misrepresented as being the original software. 21 | 3. This notice may not be removed or altered from any source distribution. 22 | 23 | Fredrik Kihlander 24 | --]] 25 | 26 | BUILD_PATH = "local" 27 | 28 | function get_config() 29 | local config = ScriptArgs["config"] 30 | if config == nil then 31 | return "debug" 32 | end 33 | return config 34 | end 35 | 36 | function get_platform() 37 | local platform = ScriptArgs["platform"] 38 | if platform == nil then 39 | if family == "windows" then 40 | platform = "winx64" 41 | else 42 | platform = "linux_x86_64" 43 | end 44 | end 45 | return platform 46 | end 47 | 48 | function get_base_settings() 49 | local settings = {} 50 | 51 | settings._is_settingsobject = true 52 | settings.invoke_count = 0 53 | settings.debug = 0 54 | settings.optimize = 0 55 | SetCommonSettings(settings) 56 | 57 | -- add all tools 58 | for _, tool in pairs(_bam_tools) do 59 | tool(settings) 60 | end 61 | 62 | return settings 63 | end 64 | 65 | function set_compiler( settings, config ) 66 | if family == "windows" then 67 | compiler = "msvc" 68 | else 69 | compiler = ScriptArgs["compiler"] 70 | if compiler == nil then 71 | compiler = "gcc" 72 | end 73 | end 74 | 75 | InitCommonCCompiler(settings) 76 | if compiler == "msvc" then 77 | SetDriversCL( settings ) 78 | if config == "release" then 79 | settings.cc.flags:Add( "/Ox" ) 80 | settings.cc.flags:Add( "/TP" ) -- forcing c++ compile on windows =/ 81 | end 82 | elseif compiler == "gcc" then 83 | SetDriversGCC( settings ) 84 | settings.cc.flags:Add( "-Wconversion", "-Wextra", "-Wall", "-Werror", "-Wstrict-aliasing=2" ) 85 | if config == "release" then 86 | settings.cc.flags:Add( "-O2" ) 87 | end 88 | elseif compiler == "clang" then 89 | SetDriversClang( settings ) 90 | settings.cc.flags:Add( "-Wconversion", "-Wextra", "-Wall", "-Werror", "-Wstrict-aliasing=2" ) 91 | if config == "release" then 92 | settings.cc.flags:Add( "-O2" ) 93 | end 94 | end 95 | end 96 | 97 | config = get_config() 98 | platform = get_platform() 99 | settings = get_base_settings() 100 | set_compiler( settings, config ) 101 | TableLock( settings ) 102 | 103 | local output_path = PathJoin( BUILD_PATH, PathJoin( platform, config ) ) 104 | local output_func = function(settings, path) return PathJoin(output_path, PathFilename(PathBase(path)) .. settings.config_ext) end 105 | settings.cc.Output = output_func 106 | settings.lib.Output = output_func 107 | settings.link.Output = output_func 108 | 109 | settings.cc.includes:Add( 'include' ) 110 | 111 | local objs = Compile( settings, 'src/getopt.c' ) 112 | local lib = StaticLibrary( settings, 'getopt', objs ) 113 | 114 | local example = Link( settings, 'example', Compile( settings, 'example/example.cpp' ), lib ) 115 | 116 | local test_objs = Compile( settings, 'test/getopt_tests.cpp' ) 117 | local tests = Link( settings, 'getopt_tests', test_objs, lib ) 118 | -------------------------------------------------------------------------------- /3rdparty/sx/3rdparty/getopt/example/example.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int verbose = 0; // verbose flag 5 | 6 | static const getopt_option_t option_list[] = 7 | { 8 | { "help", 'h', GETOPT_OPTION_TYPE_NO_ARG, 0x0, 'h', "print this help text", 0x0 }, 9 | { "verbose", 'v', GETOPT_OPTION_TYPE_FLAG_SET, &verbose, 1, "verbose logging enabled", 0x0 }, 10 | { "input", 'i', GETOPT_OPTION_TYPE_REQUIRED, 0x0, 'i', "an input file", "FILE" }, 11 | GETOPT_OPTIONS_END 12 | }; 13 | 14 | static void print_help_string( getopt_context_t ctx ) 15 | { 16 | char buffer[2048]; 17 | printf( "%s\n", getopt_create_help_string( &ctx, buffer, sizeof( buffer ) ) ); 18 | } 19 | 20 | int main( int argc, const char** argv ) 21 | { 22 | getopt_context_t ctx; 23 | if( getopt_create_context( &ctx, argc, argv, option_list ) < 0 ) 24 | { 25 | printf( "error while creating getopt ctx, bad options-list?" ); 26 | return 1; 27 | } 28 | 29 | int opt; 30 | 31 | while( ( opt = getopt_next( &ctx ) ) != -1 ) 32 | { 33 | switch( opt ) 34 | { 35 | case '+': printf( "got argument without flag: %s\n", ctx.current_opt_arg ); break; 36 | case '?': printf( "unknown flag %s\n", ctx.current_opt_arg ); break; 37 | case '!': printf( "invalid use of flag %s\n", ctx.current_opt_arg ); break; 38 | case 'i': printf( "got -i or --input with value %s\n", ctx.current_opt_arg ); break; 39 | case 0: printf( "flag was set!\n"); break; 40 | case 'h': print_help_string( ctx ); break; 41 | default: break; 42 | } 43 | } 44 | 45 | if( verbose > 0 ) 46 | printf( "verbose flag was set!" ); 47 | } 48 | -------------------------------------------------------------------------------- /3rdparty/sx/3rdparty/mattias/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/mattiasgustavsson/libs/ 2 | -------------------------------------------------------------------------------- /3rdparty/sx/3rdparty/sokol/LICENSE: -------------------------------------------------------------------------------- 1 | zlib/libpng license 2 | 3 | Copyright (c) 2018 Andre Weissflog 4 | 5 | This software is provided 'as-is', without any express or implied warranty. 6 | In no event will the authors be held liable for any damages arising from the 7 | use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software in a 15 | product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 18 | 2. Altered source versions must be plainly marked as such, and must not 19 | be misrepresented as being the original software. 20 | 21 | 3. This notice may not be removed or altered from any source 22 | distribution. 23 | -------------------------------------------------------------------------------- /3rdparty/sx/3rdparty/tlsf/README.md: -------------------------------------------------------------------------------- 1 | # tlsf 2 | Two-Level Segregated Fit memory allocator implementation. 3 | Written by Matthew Conte (matt@baisoku.org). 4 | Released under the BSD license. 5 | 6 | Features 7 | -------- 8 | * O(1) cost for malloc, free, realloc, memalign 9 | * Extremely low overhead per allocation (4 bytes) 10 | * Low overhead per TLSF management of pools (~3kB) 11 | * Low fragmentation 12 | * Compiles to only a few kB of code and data 13 | * Support for adding and removing memory pool regions on the fly 14 | 15 | Caveats 16 | ------- 17 | * Currently, assumes architecture can make 4-byte aligned accesses 18 | * Not designed to be thread safe; the user must provide this 19 | 20 | Notes 21 | ----- 22 | This code was based on the TLSF 1.4 spec and documentation found at: 23 | 24 | http://www.gii.upv.es/tlsf/main/docs 25 | 26 | It also leverages the TLSF 2.0 improvement to shrink the per-block overhead from 8 to 4 bytes. 27 | 28 | History 29 | ------- 30 | 2016/04/10 - v3.1 31 | * Code moved to github 32 | * tlsfbits.h rolled into tlsf.c 33 | * License changed to BSD 34 | 35 | 2014/02/08 - v3.0 36 | * This version is based on improvements from 3DInteractive GmbH 37 | * Interface changed to allow more than one memory pool 38 | * Separated pool handling from control structure (adding, removing, debugging) 39 | * Control structure and pools can still be constructed in the same memory block 40 | * Memory blocks for control structure and pools are checked for alignment 41 | * Added functions to retrieve control structure size, alignment size, min and max block size, overhead of pool structure, and overhead of a single allocation 42 | * Minimal Pool size is tlsf_block_size_min() + tlsf_pool_overhead() 43 | * Pool must be empty when it is removed, in order to allow O(1) removal 44 | 45 | 2011/10/20 - v2.0 46 | * 64-bit support 47 | * More compiler intrinsics for ffs/fls 48 | * ffs/fls verification during TLSF creation in debug builds 49 | 50 | 2008/04/04 - v1.9 51 | * Add tlsf_heap_check, a heap integrity check 52 | * Support a predefined tlsf_assert macro 53 | * Fix realloc case where block should shrink; if adjacent block is in use, execution would go down the slow path 54 | 55 | 2007/02/08 - v1.8 56 | * Fix for unnecessary reallocation in tlsf_realloc 57 | 58 | 2007/02/03 - v1.7 59 | * tlsf_heap_walk takes a callback 60 | * tlsf_realloc now returns NULL on failure 61 | * tlsf_memalign optimization for 4-byte alignment 62 | * Usage of size_t where appropriate 63 | 64 | 2006/11/21 - v1.6 65 | * ffs/fls broken out into tlsfbits.h 66 | * tlsf_overhead queries per-pool overhead 67 | 68 | 2006/11/07 - v1.5 69 | * Smart realloc implementation 70 | * Smart memalign implementation 71 | 72 | 2006/10/11 - v1.4 73 | * Add some ffs/fls implementations 74 | * Minor code footprint reduction 75 | 76 | 2006/09/14 - v1.3 77 | * Profiling indicates heavy use of blocks of size 1-128, so implement small block handling 78 | * Reduce pool overhead by about 1kb 79 | * Reduce minimum block size from 32 to 12 bytes 80 | * Realloc bug fix 81 | 82 | 2006/09/09 - v1.2 83 | * Add tlsf_block_size 84 | * Static assertion mechanism for invariants 85 | * Minor bugfixes 86 | 87 | 2006/09/01 - v1.1 88 | * Add tlsf_realloc 89 | * Add tlsf_walk_heap 90 | 91 | 2006/08/25 - v1.0 92 | * First release 93 | -------------------------------------------------------------------------------- /3rdparty/sx/3rdparty/xxhash/LICENSE: -------------------------------------------------------------------------------- 1 | xxHash Library 2 | Copyright (c) 2012-2014, Yann Collet 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, this 12 | list of conditions and the following disclaimer in the documentation and/or 13 | other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 19 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /3rdparty/sx/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2018, Sepehr Taghdisian 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/jump_arm64_aapcs_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Edward Nevill + Oliver Kowalke 2015 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | /******************************************************* 8 | * * 9 | * ------------------------------------------------- * 10 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 11 | * ------------------------------------------------- * 12 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 13 | * ------------------------------------------------- * 14 | * | x19 | x20 | x21 | x22 | * 15 | * ------------------------------------------------- * 16 | * ------------------------------------------------- * 17 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 18 | * ------------------------------------------------- * 19 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 20 | * ------------------------------------------------- * 21 | * | x23 | x24 | x25 | x26 | * 22 | * ------------------------------------------------- * 23 | * ------------------------------------------------- * 24 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 25 | * ------------------------------------------------- * 26 | * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * 27 | * ------------------------------------------------- * 28 | * | x27 | x28 | FP | LR | * 29 | * ------------------------------------------------- * 30 | * ------------------------------------------------- * 31 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 32 | * ------------------------------------------------- * 33 | * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * 34 | * ------------------------------------------------- * 35 | * | PC | align | | | * 36 | * ------------------------------------------------- * 37 | * * 38 | *******************************************************/ 39 | 40 | .cpu generic+fp+simd 41 | .text 42 | .align 2 43 | .global jump_fcontext 44 | .type jump_fcontext, %function 45 | jump_fcontext: 46 | # prepare stack for GP + FPU 47 | sub sp, sp, #0x70 48 | 49 | # save x19-x30 50 | stp x19, x20, [sp, #0x00] 51 | stp x21, x22, [sp, #0x10] 52 | stp x23, x24, [sp, #0x20] 53 | stp x25, x26, [sp, #0x30] 54 | stp x27, x28, [sp, #0x40] 55 | stp x29, x30, [sp, #0x50] 56 | 57 | # save LR as PC 58 | str x30, [sp, #0x60] 59 | 60 | # store RSP (pointing to context-data) in X0 61 | mov x4, sp 62 | 63 | # restore RSP (pointing to context-data) from X1 64 | mov sp, x0 65 | 66 | # load x19-x30 67 | ldp x19, x20, [sp, #0x00] 68 | ldp x21, x22, [sp, #0x10] 69 | ldp x23, x24, [sp, #0x20] 70 | ldp x25, x26, [sp, #0x30] 71 | ldp x27, x28, [sp, #0x40] 72 | ldp x29, x30, [sp, #0x50] 73 | 74 | # return transfer_t from jump 75 | # pass transfer_t as first arg in context function 76 | # X0 == FCTX, X1 == DATA 77 | mov x0, x4 78 | 79 | # load pc 80 | ldr x4, [sp, #0x60] 81 | 82 | # restore stack from GP + FPU 83 | add sp, sp, #0x70 84 | 85 | ret x4 86 | .size jump_fcontext,.-jump_fcontext 87 | # Mark that we don't need executable stack. 88 | .section .note.GNU-stack,"",%progbits 89 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/jump_arm64_aapcs_macho_gas.S: -------------------------------------------------------------------------------- 1 | /******************************************************* 2 | * * 3 | * ------------------------------------------------- * 4 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 5 | * ------------------------------------------------- * 6 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 7 | * ------------------------------------------------- * 8 | * | x19 | x20 | x21 | x22 | * 9 | * ------------------------------------------------- * 10 | * ------------------------------------------------- * 11 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 12 | * ------------------------------------------------- * 13 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 14 | * ------------------------------------------------- * 15 | * | x23 | x24 | x25 | x26 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 19 | * ------------------------------------------------- * 20 | * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * 21 | * ------------------------------------------------- * 22 | * | x27 | x28 | FP | LR | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 26 | * ------------------------------------------------- * 27 | * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * 28 | * ------------------------------------------------- * 29 | * | PC | align | | | * 30 | * ------------------------------------------------- * 31 | * * 32 | *******************************************************/ 33 | 34 | .text 35 | .globl _jump_fcontext 36 | .balign 16 37 | _jump_fcontext: 38 | ; prepare stack for GP + FPU 39 | sub sp, sp, #0x70 40 | 41 | ; save x19-x30 42 | stp x19, x20, [sp, #0x00] 43 | stp x21, x22, [sp, #0x10] 44 | stp x23, x24, [sp, #0x20] 45 | stp x25, x26, [sp, #0x30] 46 | stp x27, x28, [sp, #0x40] 47 | stp fp, lr, [sp, #0x50] 48 | 49 | ; save LR as PC 50 | str lr, [sp, #0x60] 51 | 52 | ; store RSP (pointing to context-data) in X0 53 | mov x4, sp 54 | 55 | ; restore RSP (pointing to context-data) from X1 56 | mov sp, x0 57 | 58 | ; load x19-x30 59 | ldp x19, x20, [sp, #0x00] 60 | ldp x21, x22, [sp, #0x10] 61 | ldp x23, x24, [sp, #0x20] 62 | ldp x25, x26, [sp, #0x30] 63 | ldp x27, x28, [sp, #0x40] 64 | ldp fp, lr, [sp, #0x50] 65 | 66 | ; return transfer_t from jump 67 | ; pass transfer_t as first arg in context function 68 | ; X0 == FCTX, X1 == DATA 69 | mov x0, x4 70 | 71 | ; load pc 72 | ldr x4, [sp, #0x60] 73 | 74 | ; restore stack from GP + FPU 75 | add sp, sp, #0x70 76 | 77 | ret x4 78 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/jump_arm_aapcs_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 14 | * ------------------------------------------------- * 15 | * |hiddn| v1 | v2 | v3 | v4 | v5 | v6 | v7 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 21 | * ------------------------------------------------- * 22 | * | v8 | lr | pc | FCTX| DATA| | * 23 | * ------------------------------------------------- * 24 | * * 25 | *******************************************************/ 26 | 27 | .text 28 | .globl jump_fcontext 29 | .align 2 30 | .type jump_fcontext,%function 31 | jump_fcontext: 32 | @ save LR as PC 33 | push {lr} 34 | @ save hidden,V1-V8,LR 35 | push {a1,v1-v8,lr} 36 | 37 | @ store RSP (pointing to context-data) in A1 38 | mov a1, sp 39 | 40 | @ restore RSP (pointing to context-data) from A2 41 | mov sp, a2 42 | 43 | @ restore hidden,V1-V8,LR 44 | pop {a4,v1-v8,lr} 45 | 46 | @ return transfer_t from jump 47 | str a1, [a4, #0] 48 | str a3, [a4, #4] 49 | @ pass transfer_t as first arg in context function 50 | @ A1 == FCTX, A2 == DATA 51 | mov a2, a3 52 | 53 | @ restore PC 54 | pop {pc} 55 | .size jump_fcontext,.-jump_fcontext 56 | 57 | @ Mark that we don't need executable stack. 58 | .section .note.GNU-stack,"",%progbits 59 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/jump_arm_aapcs_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 14 | * ------------------------------------------------- * 15 | * | sjlj|hiddn| v1 | v2 | v3 | v4 | v5 | v6 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 21 | * ------------------------------------------------- * 22 | * | v7 | v8 | lr | pc | FCTX| DATA| | * 23 | * ------------------------------------------------- * 24 | * * 25 | *******************************************************/ 26 | 27 | .text 28 | .globl _jump_fcontext 29 | .align 2 30 | _jump_fcontext: 31 | @ save LR as PC 32 | push {lr} 33 | @ save hidden,V1-V8,LR 34 | push {a1,v1-v8,lr} 35 | 36 | @ locate TLS to save/restore SjLj handler 37 | mrc p15, 0, v2, c13, c0, #3 38 | bic v2, v2, #3 39 | 40 | @ load TLS[__PTK_LIBC_DYLD_Unwind_SjLj_Key] 41 | ldr v1, [v2, #8] 42 | @ save SjLj handler 43 | push {v1} 44 | 45 | @ store RSP (pointing to context-data) in A1 46 | mov a1, sp 47 | 48 | @ restore RSP (pointing to context-data) from A2 49 | mov sp, a2 50 | 51 | @ r#estore SjLj handler 52 | pop {v1} 53 | @ store SjLj handler in TLS 54 | str v1, [v2, #8] 55 | 56 | @ restore hidden,V1-V8,LR 57 | pop {a4,v1-v8,lr} 58 | 59 | @ return transfer_t from jump 60 | str a1, [a4, #0] 61 | str a3, [a4, #4] 62 | @ pass transfer_t as first arg in context function 63 | @ A1 == FCTX, A2 == DATA 64 | mov a2, a3 65 | 66 | @ restore PC 67 | pop {pc} 68 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/jump_arm_aapcs_pe_armasm.asm: -------------------------------------------------------------------------------- 1 | ;/* 2 | ; Copyright Oliver Kowalke 2009. 3 | ; Distributed under the Boost Software License, Version 1.0. 4 | ; (See accompanying file LICENSE_1_0.txt or copy at 5 | ; http://www.boost.org/LICENSE_1_0.txt) 6 | ;*/ 7 | 8 | ; ******************************************************* 9 | ; * * 10 | ; * ------------------------------------------------- * 11 | ; * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | ; * ------------------------------------------------- * 13 | ; * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 14 | ; * ------------------------------------------------- * 15 | ; * |deall|limit| base|hiddn| v1 | v2 | v3 | v4 | * 16 | ; * ------------------------------------------------- * 17 | ; * ------------------------------------------------- * 18 | ; * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | ; * ------------------------------------------------- * 20 | ; * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 21 | ; * ------------------------------------------------- * 22 | ; * | v5 | v6 | v7 | v8 | lr | pc | FCTX| DATA| * 23 | ; * ------------------------------------------------- * 24 | ; * * 25 | ; ******************************************************* 26 | 27 | AREA |.text|, CODE 28 | ALIGN 4 29 | EXPORT jump_fcontext 30 | 31 | jump_fcontext PROC 32 | ; save LR as PC 33 | push {lr} 34 | ; save hidden,V1-V8,LR 35 | push {a1,v1-v8,lr} 36 | 37 | ; load TIB to save/restore thread size and limit. 38 | ; we do not need preserve CPU flag and can use it's arg register 39 | mrc p15, #0, v1, c13, c0, #2 40 | 41 | ; save current stack base 42 | ldr a5, [v1, #0x04] 43 | push {a5} 44 | ; save current stack limit 45 | ldr a5, [v1, #0x08] 46 | push {a5} 47 | ; save current deallocation stack 48 | ldr a5, [v1, #0xe0c] 49 | push {a5} 50 | 51 | ; store RSP (pointing to context-data) in A1 52 | mov a1, sp 53 | 54 | ; restore RSP (pointing to context-data) from A2 55 | mov sp, a2 56 | 57 | ; restore deallocation stack 58 | pop {a5} 59 | str a5, [v1, #0xe0c] 60 | ; restore stack limit 61 | pop {a5} 62 | str a5, [v1, #0x08] 63 | ; restore stack base 64 | pop {a5} 65 | str a5, [v1, #0x04] 66 | 67 | ; restore hidden,V1-V8,LR 68 | pop {a4,v1-v8,lr} 69 | 70 | ; return transfer_t from jump 71 | str a1, [a4, #0] 72 | str a3, [a4, #4] 73 | ; pass transfer_t as first arg in context function 74 | ; A1 == FCTX, A2 == DATA 75 | mov a2, a3 76 | 77 | ; restore PC 78 | pop {pc} 79 | 80 | ENDP 81 | END 82 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/jump_combined_all_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) 11 | #if defined(__aarch64__) 12 | #include "jump_arm64_aapcs_macho_gas.S" 13 | #else 14 | #include "jump_arm_aapcs_macho_gas.S" 15 | #endif 16 | #else 17 | #if defined(__i386__) 18 | #include "jump_i386_sysv_macho_gas.S" 19 | #elif defined(__x86_64__) 20 | #include "jump_x86_64_sysv_macho_gas.S" 21 | #elif defined(__ppc__) 22 | #include "jump_ppc32_sysv_macho_gas.S" 23 | #elif defined(__ppc64__) 24 | #include "jump_ppc64_sysv_macho_gas.S" 25 | #else 26 | #error "No arch's" 27 | #endif 28 | #endif -------------------------------------------------------------------------------- /3rdparty/sx/asm/jump_combined_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__i386__) 11 | #include "jump_i386_sysv_macho_gas.S" 12 | #elif defined(__x86_64__) 13 | #include "jump_x86_64_sysv_macho_gas.S" 14 | #elif defined(__ppc__) 15 | #include "jump_ppc32_sysv_macho_gas.S" 16 | #elif defined(__ppc64__) 17 | #include "jump_ppc64_sysv_macho_gas.S" 18 | #else 19 | #error "No arch's" 20 | #endif 21 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/jump_i386_ms_pe_gas.asm: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Copyright Thomas Sailer 2013. 4 | Distributed under the Boost Software License, Version 1.0. 5 | (See accompanying file LICENSE_1_0.txt or copy at 6 | http://www.boost.org/LICENSE_1_0.txt) 7 | */ 8 | 9 | /************************************************************************************* 10 | * --------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * --------------------------------------------------------------------------------- * 13 | * | 0h | 04h | 08h | 0ch | 010h | 014h | 018h | 01ch | * 14 | * --------------------------------------------------------------------------------- * 15 | * | fc_strg |fc_deallo| limit | base | fc_seh | EDI | ESI | EBX | * 16 | * --------------------------------------------------------------------------------- * 17 | * --------------------------------------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * --------------------------------------------------------------------------------- * 20 | * | 020h | 024h | 028h | 02ch | 030h | 034h | 038h | 03ch | * 21 | * --------------------------------------------------------------------------------- * 22 | * | EBP | EIP | to | data | | EH NXT |SEH HNDLR| | * 23 | * --------------------------------------------------------------------------------- * 24 | *************************************************************************************/ 25 | 26 | .file "jump_i386_ms_pe_gas.asm" 27 | .text 28 | .p2align 4,,15 29 | .globl _jump_fcontext 30 | .def _jump_fcontext; .scl 2; .type 32; .endef 31 | _jump_fcontext: 32 | pushl %ebp /* save EBP */ 33 | pushl %ebx /* save EBX */ 34 | pushl %esi /* save ESI */ 35 | pushl %edi /* save EDI */ 36 | 37 | /* load NT_TIB */ 38 | movl %fs:(0x18), %edx 39 | 40 | /* load current SEH exception list */ 41 | movl (%edx), %eax 42 | push %eax 43 | 44 | /* load current stack base */ 45 | movl 0x04(%edx), %eax 46 | push %eax 47 | 48 | /* load current stack limit */ 49 | movl 0x08(%edx), %eax 50 | push %eax 51 | 52 | /* load current dealloction stack */ 53 | movl 0xe0c(%edx), %eax 54 | push %eax 55 | 56 | /* load fiber local storage */ 57 | movl 0x10(%edx), %eax 58 | push %eax 59 | 60 | /* store ESP (pointing to context-data) in EAX */ 61 | movl %esp, %eax 62 | 63 | /* first arg of jump_fcontext() == fcontext to jump to */ 64 | movl 0x28(%esp), %ecx 65 | 66 | /* restore ESP (pointing to context-data) from EDX */ 67 | movl %ecx, %esp 68 | 69 | /* load NT_TIB into ECX */ 70 | movl %fs:(0x18), %edx 71 | 72 | /* restore fiber local storage */ 73 | popl %ecx 74 | movl %ecx, 0x10(%edx) 75 | 76 | /* restore current deallocation stack */ 77 | popl %ecx 78 | movl %ecx, 0xe0c(%edx) 79 | 80 | /* restore current stack limit */ 81 | popl %ecx 82 | movl %ecx, 0x08(%edx) 83 | 84 | /* restore current stack base */ 85 | popl %ecx 86 | movl %ecx, 0x04(%edx) 87 | 88 | /* restore current SEH exception list */ 89 | popl %ecx 90 | movl %ecx, (%edx) 91 | 92 | popl %edi /* save EDI */ 93 | popl %esi /* save ESI */ 94 | popl %ebx /* save EBX */ 95 | popl %ebp /* save EBP */ 96 | 97 | /* return transfer_t */ 98 | /* FCTX == EAX, DATA == EDX */ 99 | movl 0x2c(%eax), %edx 100 | 101 | /* jump to context */ 102 | ret 103 | 104 | .section .drectve 105 | .ascii " -export:\"jump_fcontext\"" 106 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/jump_i386_ms_pe_masm.asm: -------------------------------------------------------------------------------- 1 | 2 | ; Copyright Oliver Kowalke 2009. 3 | ; Distributed under the Boost Software License, Version 1.0. 4 | ; (See accompanying file LICENSE_1_0.txt or copy at 5 | ; http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | ; --------------------------------------------------------------------------------- 8 | ; | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | ; --------------------------------------------------------------------------------- 10 | ; | 0h | 04h | 08h | 0ch | 010h | 014h | 018h | 01ch | 11 | ; --------------------------------------------------------------------------------- 12 | ; | fc_strg |fc_deallo| limit | base | fc_seh | EDI | ESI | EBX | 13 | ; --------------------------------------------------------------------------------- 14 | ; --------------------------------------------------------------------------------- 15 | ; | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | ; --------------------------------------------------------------------------------- 17 | ; | 020h | 024h | 028h | 02ch | 030h | 034h | 038h | 03ch | 18 | ; --------------------------------------------------------------------------------- 19 | ; | EBP | EIP | to | data | | EH NXT |SEH HNDLR| | 20 | ; --------------------------------------------------------------------------------- 21 | 22 | .386 23 | .XMM 24 | .model flat, c 25 | .code 26 | 27 | jump_fcontext PROC BOOST_CONTEXT_EXPORT 28 | push ebp ; save EBP 29 | push ebx ; save EBX 30 | push esi ; save ESI 31 | push edi ; save EDI 32 | 33 | assume fs:nothing 34 | ; load NT_TIB into ECX 35 | mov edx, fs:[018h] 36 | assume fs:error 37 | 38 | ; load current SEH exception list 39 | mov eax, [edx] 40 | push eax 41 | 42 | ; load current stack base 43 | mov eax, [edx+04h] 44 | push eax 45 | 46 | ; load current stack limit 47 | mov eax, [edx+08h] 48 | push eax 49 | 50 | ; load current deallocation stack 51 | mov eax, [edx+0e0ch] 52 | push eax 53 | 54 | ; load fiber local storage 55 | mov eax, [edx+010h] 56 | push eax 57 | 58 | ; store ESP (pointing to context-data) in EAX 59 | mov eax, esp 60 | 61 | ; firstarg of jump_fcontext() == fcontext to jump to 62 | mov ecx, [esp+028h] 63 | 64 | ; restore ESP (pointing to context-data) from EAX 65 | mov esp, ecx 66 | 67 | assume fs:nothing 68 | ; load NT_TIB into EDX 69 | mov edx, fs:[018h] 70 | assume fs:error 71 | 72 | ; restore fiber local storage 73 | pop ecx 74 | mov [edx+010h], ecx 75 | 76 | ; restore current deallocation stack 77 | pop ecx 78 | mov [edx+0e0ch], ecx 79 | 80 | ; restore current stack limit 81 | pop ecx 82 | mov [edx+08h], ecx 83 | 84 | ; restore current stack base 85 | pop ecx 86 | mov [edx+04h], ecx 87 | 88 | ; restore current SEH exception list 89 | pop ecx 90 | mov [edx], ecx 91 | 92 | pop edi ; save EDI 93 | pop esi ; save ESI 94 | pop ebx ; save EBX 95 | pop ebp ; save EBP 96 | 97 | ; return transfer_t 98 | ; FCTX == EAX, DATA == EDX 99 | mov edx, [eax+02ch] 100 | 101 | ; jump to context 102 | ret 103 | jump_fcontext ENDP 104 | END 105 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/jump_i386_sysv_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /***************************************************************************************** 9 | * * 10 | * ----------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ----------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ----------------------------------------------------------------------------------- * 15 | * | EDI | ESI | EBX | EBP | EIP | hidden | to | data | * 16 | * ----------------------------------------------------------------------------------- * 17 | * * 18 | *****************************************************************************************/ 19 | 20 | .text 21 | .globl jump_fcontext 22 | .align 2 23 | .type jump_fcontext,@function 24 | jump_fcontext: 25 | pushl %ebp /* save EBP */ 26 | pushl %ebx /* save EBX */ 27 | pushl %esi /* save ESI */ 28 | pushl %edi /* save EDI */ 29 | 30 | /* store fcontext_t in ECX */ 31 | movl %esp, %ecx 32 | 33 | /* first arg of jump_fcontext() == fcontext to jump to */ 34 | movl 0x18(%esp), %eax 35 | 36 | /* second arg of jump_fcontext() == data to be transferred */ 37 | movl 0x1c(%esp), %edx 38 | 39 | /* restore ESP (pointing to context-data) from EAX */ 40 | movl %eax, %esp 41 | 42 | /* address of returned transport_t */ 43 | movl 0x14(%esp), %eax 44 | /* return parent fcontext_t */ 45 | movl %ecx, (%eax) 46 | /* return data */ 47 | movl %edx, 0x4(%eax) 48 | 49 | popl %edi /* restore EDI */ 50 | popl %esi /* restore ESI */ 51 | popl %ebx /* restore EBX */ 52 | popl %ebp /* restore EBP */ 53 | 54 | /* jump to context */ 55 | ret $4 56 | .size jump_fcontext,.-jump_fcontext 57 | 58 | /* Mark that we don't need executable stack. */ 59 | .section .note.GNU-stack,"",%progbits 60 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/jump_i386_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /***************************************************************************************** 9 | * * 10 | * ----------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ----------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ----------------------------------------------------------------------------------- * 15 | * | EDI | ESI | EBX | EBP | EIP | hidden | to | data | * 16 | * ----------------------------------------------------------------------------------- * 17 | * * 18 | *****************************************************************************************/ 19 | 20 | .text 21 | .globl _jump_fcontext 22 | .align 2 23 | _jump_fcontext: 24 | pushl %ebp /* save EBP */ 25 | pushl %ebx /* save EBX */ 26 | pushl %esi /* save ESI */ 27 | pushl %edi /* save EDI */ 28 | 29 | /* store fcontext_t in ECX */ 30 | movl %esp, %ecx 31 | 32 | /* first arg of jump_fcontext() == context jumping to */ 33 | movl 0x18(%esp), %eax 34 | 35 | /* second arg of jump_fcontext() == data to be transferred */ 36 | movl 0x1c(%esp), %edx 37 | 38 | /* restore ESP (pointing to context-data) from EAX */ 39 | movl %eax, %esp 40 | 41 | /* address of returned transport_t */ 42 | movl 0x14(%esp), %eax 43 | /* return parent fcontext_t */ 44 | movl %ecx, (%eax) 45 | /* return data */ 46 | movl %edx, 0x4(%eax) 47 | 48 | popl %edi /* restore EDI */ 49 | popl %esi /* restore ESI */ 50 | popl %ebx /* restore EBX */ 51 | popl %ebp /* restore EBP */ 52 | 53 | /* jump to context */ 54 | ret $4 55 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/jump_i386_x86_64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__i386__) 11 | #include "jump_i386_sysv_macho_gas.S" 12 | #elif defined(__x86_64__) 13 | #include "jump_x86_64_sysv_macho_gas.S" 14 | #else 15 | #error "No arch's" 16 | #endif 17 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/jump_mips32_o32_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 14 | * ------------------------------------------------- * 15 | * | S0 | S1 | S2 | S3 | S4 | S5 | S6 | S7 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 21 | * ------------------------------------------------- * 22 | * | FP |hiddn| RA | PC | GP | FCTX| DATA| | * 23 | * ------------------------------------------------- * 24 | * * 25 | * *****************************************************/ 26 | 27 | .text 28 | .globl jump_fcontext 29 | .align 2 30 | .type jump_fcontext,@function 31 | .ent jump_fcontext 32 | jump_fcontext: 33 | # reserve space on stack 34 | addiu $sp, $sp, -112 35 | 36 | sw $s0, ($sp) # save S0 37 | sw $s1, 4($sp) # save S1 38 | sw $s2, 8($sp) # save S2 39 | sw $s3, 12($sp) # save S3 40 | sw $s4, 16($sp) # save S4 41 | sw $s5, 20($sp) # save S5 42 | sw $s6, 24($sp) # save S6 43 | sw $s7, 28($sp) # save S7 44 | sw $fp, 32($sp) # save FP 45 | sw $a0, 36($sp) # save hidden, address of returned transfer_t 46 | sw $ra, 40($sp) # save RA 47 | sw $ra, 44($sp) # save RA as PC 48 | 49 | # store SP (pointing to context-data) in A0 50 | move $a0, $sp 51 | 52 | # restore SP (pointing to context-data) from A1 53 | move $sp, $a1 54 | 55 | lw $s0, ($sp) # restore S0 56 | lw $s1, 4($sp) # restore S1 57 | lw $s2, 8($sp) # restore S2 58 | lw $s3, 12($sp) # restore S3 59 | lw $s4, 16($sp) # restore S4 60 | lw $s5, 20($sp) # restore S5 61 | lw $s6, 24($sp) # restore S6 62 | lw $s7, 28($sp) # restore S7 63 | lw $fp, 32($sp) # restore FP 64 | lw $t0, 36($sp) # restore hidden, address of returned transfer_t 65 | lw $ra, 40($sp) # restore RA 66 | 67 | # load PC 68 | lw $t9, 44($sp) 69 | 70 | # adjust stack 71 | addiu $sp, $sp, 112 72 | 73 | # return transfer_t from jump 74 | sw $a0, ($t0) # fctx of transfer_t 75 | sw $a1, 4($t0) # data of transfer_t 76 | # pass transfer_t as first arg in context function 77 | # A0 == fctx, A1 == data 78 | move $a1, $a2 79 | 80 | # jump to context 81 | jr $t9 82 | .end jump_fcontext 83 | .size jump_fcontext, .-jump_fcontext 84 | 85 | /* Mark that we don't need executable stack. */ 86 | .section .note.GNU-stack,"",%progbits 87 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/jump_ppc32_ppc64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__ppc__) 11 | #include "jump_ppc32_sysv_macho_gas.S" 12 | #elif defined(__ppc64__) 13 | #include "jump_ppc64_sysv_macho_gas.S" 14 | #else 15 | #error "No arch's" 16 | #endif 17 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/jump_ppc32_sysv_xcoff_gas.S: -------------------------------------------------------------------------------- 1 | .globl .jump_fcontext 2 | .globl jump_fcontext[DS] 3 | .align 2 4 | .csect jump_fcontext[DS] 5 | jump_fcontext: 6 | .long .jump_fcontext 7 | .jump_fcontext: 8 | # reserve space on stack 9 | subi 1, 1, 92 10 | 11 | stw 13, 0(1) # save R13 12 | stw 14, 4(1) # save R14 13 | stw 15, 8(1) # save R15 14 | stw 16, 12(1) # save R16 15 | stw 17, 16(1) # save R17 16 | stw 18, 20(1) # save R18 17 | stw 19, 24(1) # save R19 18 | stw 20, 28(1) # save R20 19 | stw 21, 32(1) # save R21 20 | stw 22, 36(1) # save R22 21 | stw 23, 40(1) # save R23 22 | stw 24, 44(1) # save R24 23 | stw 25, 48(1) # save R25 24 | stw 26, 52(1) # save R26 25 | stw 27, 56(1) # save R27 26 | stw 28, 60(1) # save R28 27 | stw 29, 64(1) # save R29 28 | stw 30, 68(1) # save R30 29 | stw 31, 72(1) # save R31 30 | stw 3, 76(1) # save hidden 31 | 32 | # save CR 33 | mfcr 0 34 | stw 0, 80(1) 35 | # save LR 36 | mflr 0 37 | stw 0, 84(1) 38 | # save LR as PC 39 | stw 0, 88(1) 40 | 41 | # store RSP (pointing to context-data) in R6 42 | mr 6, 1 43 | 44 | # restore RSP (pointing to context-data) from R4 45 | mr 1, 4 46 | 47 | lwz 13, 0(1) # restore R13 48 | lwz 14, 4(1) # restore R14 49 | lwz 15, 8(1) # restore R15 50 | lwz 16, 12(1) # restore R16 51 | lwz 17, 16(1) # restore R17 52 | lwz 18, 20(1) # restore R18 53 | lwz 19, 24(1) # restore R19 54 | lwz 20, 28(1) # restore R20 55 | lwz 21, 32(1) # restore R21 56 | lwz 22, 36(1) # restore R22 57 | lwz 23, 40(1) # restore R23 58 | lwz 24, 44(1) # restore R24 59 | lwz 25, 48(1) # restore R25 60 | lwz 26, 52(1) # restore R26 61 | lwz 27, 56(1) # restore R27 62 | lwz 28, 60(1) # restore R28 63 | lwz 29, 64(1) # restore R29 64 | lwz 30, 68(1) # restore R30 65 | lwz 31, 72(1) # restore R31 66 | lwz 3, 76(1) # restore hidden 67 | 68 | # restore CR 69 | lwz 0, 80(1) 70 | mtcr 0 71 | # restore LR 72 | lwz 0, 84(1) 73 | mtlr 0 74 | 75 | # load PC 76 | lwz 0, 88(1) 77 | # restore CTR 78 | mtctr 0 79 | 80 | # adjust stack 81 | addi 1, 1, 92 82 | 83 | # return transfer_t 84 | stw 6, 0(3) 85 | stw 5, 4(3) 86 | 87 | # jump to context 88 | bctr 89 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/jump_ppc64_sysv_xcoff_gas.S: -------------------------------------------------------------------------------- 1 | .align 2 2 | .globl .jump_fcontext 3 | .jump_fcontext: 4 | # reserve space on stack 5 | subi 1, 1, 184 6 | 7 | std 13, 0(1) # save R13 8 | std 14, 8(1) # save R14 9 | std 15, 16(1) # save R15 10 | std 16, 24(1) # save R16 11 | std 17, 32(1) # save R17 12 | std 18, 40(1) # save R18 13 | std 19, 48(1) # save R19 14 | std 20, 56(1) # save R20 15 | std 21, 64(1) # save R21 16 | std 22, 72(1) # save R22 17 | std 23, 80(1) # save R23 18 | std 24, 88(1) # save R24 19 | std 25, 96(1) # save R25 20 | std 26, 104(1) # save R26 21 | std 27, 112(1) # save R27 22 | std 29, 120(1) # save R28 23 | std 29, 128(1) # save R29 24 | std 30, 136(1) # save R30 25 | std 31, 144(1) # save R31 26 | std 3, 152(1) # save hidden 27 | 28 | # save CR 29 | mfcr 0 30 | std 0, 160(1) 31 | # save LR 32 | mflr 0 33 | std 0, 168(1) 34 | # save LR as PC 35 | std 0, 176(1) 36 | 37 | # store RSP (pointing to context-data) in R6 38 | mr 6, 1 39 | 40 | # restore RSP (pointing to context-data) from R4 41 | mr 1, 4 42 | 43 | ld 13, 0(1) # restore R13 44 | ld 14, 8(1) # restore R14 45 | ld 15, 16(1) # restore R15 46 | ld 16, 24(1) # restore R16 47 | ld 17, 32(1) # restore R17 48 | ld 18, 40(1) # restore R18 49 | ld 19, 48(1) # restore R19 50 | ld 20, 56(1) # restore R20 51 | ld 21, 64(1) # restore R21 52 | ld 22, 72(1) # restore R22 53 | ld 23, 80(1) # restore R23 54 | ld 24, 88(1) # restore R24 55 | ld 25, 96(1) # restore R25 56 | ld 26, 104(1) # restore R26 57 | ld 27, 112(1) # restore R27 58 | ld 28, 120(1) # restore R28 59 | ld 29, 128(1) # restore R29 60 | ld 30, 136(1) # restore R30 61 | ld 31, 144(1) # restore R31 62 | ld 3, 152(1) # restore hidden 63 | 64 | # restore CR 65 | ld 0, 160(1) 66 | mtcr 0 67 | # restore LR 68 | ld 0, 168(1) 69 | mtlr 0 70 | 71 | # load PC 72 | ld 0, 176(1) 73 | # restore CTR 74 | mtctr 0 75 | 76 | # adjust stack 77 | addi 1, 1, 184 78 | 79 | # return transfer_t 80 | std 6, 0(3) 81 | std 5, 8(3) 82 | 83 | # jump to context 84 | bctr 85 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/jump_x86_64_sysv_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /**************************************************************************************** 9 | * * 10 | * ---------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ---------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ---------------------------------------------------------------------------------- * 15 | * | R12 | R13 | R14 | R15 | * 16 | * ---------------------------------------------------------------------------------- * 17 | * ---------------------------------------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ---------------------------------------------------------------------------------- * 20 | * | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | * 21 | * ---------------------------------------------------------------------------------- * 22 | * | RBX | RBP | RIP | EXIT | * 23 | * ---------------------------------------------------------------------------------- * 24 | * * 25 | ****************************************************************************************/ 26 | 27 | .text 28 | .globl jump_fcontext 29 | .type jump_fcontext,@function 30 | .align 16 31 | jump_fcontext: 32 | pushq %rbp /* save RBP */ 33 | pushq %rbx /* save RBX */ 34 | pushq %r15 /* save R15 */ 35 | pushq %r14 /* save R14 */ 36 | pushq %r13 /* save R13 */ 37 | pushq %r12 /* save R12 */ 38 | 39 | /* store RSP (pointing to context-data) in RAX */ 40 | movq %rsp, %rax 41 | 42 | /* restore RSP (pointing to context-data) from RDI */ 43 | movq %rdi, %rsp 44 | 45 | popq %r12 /* restrore R12 */ 46 | popq %r13 /* restrore R13 */ 47 | popq %r14 /* restrore R14 */ 48 | popq %r15 /* restrore R15 */ 49 | popq %rbx /* restrore RBX */ 50 | popq %rbp /* restrore RBP */ 51 | 52 | /* restore return-address */ 53 | popq %r8 54 | 55 | /* return transfer_t from jump */ 56 | /* RAX == fctx, RDX == data */ 57 | movq %rsi, %rdx 58 | /* pass transfer_t as first arg in context function */ 59 | /* RDI == fctx, RSI == data */ 60 | movq %rax, %rdi 61 | 62 | /* indirect jump to context */ 63 | jmp *%r8 64 | .size jump_fcontext,.-jump_fcontext 65 | 66 | /* Mark that we don't need executable stack. */ 67 | .section .note.GNU-stack,"",%progbits 68 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/jump_x86_64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /**************************************************************************************** 9 | * * 10 | * ---------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ---------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ---------------------------------------------------------------------------------- * 15 | * | R12 | R13 | R14 | R15 | * 16 | * ---------------------------------------------------------------------------------- * 17 | * ---------------------------------------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ---------------------------------------------------------------------------------- * 20 | * | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | * 21 | * ---------------------------------------------------------------------------------- * 22 | * | RBX | RBP | RIP | EXIT | * 23 | * ---------------------------------------------------------------------------------- * 24 | * * 25 | ****************************************************************************************/ 26 | 27 | .text 28 | .globl _jump_fcontext 29 | .align 8 30 | _jump_fcontext: 31 | pushq %rbp /* save RBP */ 32 | pushq %rbx /* save RBX */ 33 | pushq %r15 /* save R15 */ 34 | pushq %r14 /* save R14 */ 35 | pushq %r13 /* save R13 */ 36 | pushq %r12 /* save R12 */ 37 | 38 | /* store RSP (pointing to context-data) in RAX */ 39 | movq %rsp, %rax 40 | 41 | /* restore RSP (pointing to context-data) from RDI */ 42 | movq %rdi, %rsp 43 | 44 | popq %r12 /* restrore R12 */ 45 | popq %r13 /* restrore R13 */ 46 | popq %r14 /* restrore R14 */ 47 | popq %r15 /* restrore R15 */ 48 | popq %rbx /* restrore RBX */ 49 | popq %rbp /* restrore RBP */ 50 | 51 | /* restore return-address */ 52 | popq %r8 53 | 54 | /* return transfer_t from jump */ 55 | /* RAX == fctx, RDX == data */ 56 | movq %rsi, %rdx 57 | /* pass transfer_t as first arg in context function */ 58 | /* RDI == fctx, RSI == data */ 59 | movq %rax, %rdi 60 | 61 | /* indirect jump to context */ 62 | jmp *%r8 63 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/make_arm64_aapcs_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Edward Nevill + Oliver Kowalke 2015 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | /******************************************************* 8 | * * 9 | * ------------------------------------------------- * 10 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 11 | * ------------------------------------------------- * 12 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 13 | * ------------------------------------------------- * 14 | * | x19 | x20 | x21 | x22 | * 15 | * ------------------------------------------------- * 16 | * ------------------------------------------------- * 17 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 18 | * ------------------------------------------------- * 19 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 20 | * ------------------------------------------------- * 21 | * | x23 | x24 | x25 | x26 | * 22 | * ------------------------------------------------- * 23 | * ------------------------------------------------- * 24 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 25 | * ------------------------------------------------- * 26 | * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * 27 | * ------------------------------------------------- * 28 | * | x27 | x28 | FP | LR | * 29 | * ------------------------------------------------- * 30 | * ------------------------------------------------- * 31 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 32 | * ------------------------------------------------- * 33 | * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * 34 | * ------------------------------------------------- * 35 | * | PC | align | | | * 36 | * ------------------------------------------------- * 37 | * * 38 | *******************************************************/ 39 | 40 | .cpu generic+fp+simd 41 | .text 42 | .align 2 43 | .global make_fcontext 44 | .type make_fcontext, %function 45 | make_fcontext: 46 | # shift address in x0 (allocated stack) to lower 16 byte boundary 47 | and x0, x0, ~0xF 48 | 49 | # reserve space for context-data on context-stack 50 | sub x0, x0, #0x70 51 | 52 | # third arg of make_fcontext() == address of context-function 53 | # store address as a PC to jump in 54 | str x2, [x0, #0x60] 55 | 56 | # save address of finish as return-address for context-function 57 | # will be entered after context-function returns (LR register) 58 | adr x1, finish 59 | str x1, [x0, #0x58] 60 | 61 | ret x30 // return pointer to context-data (x0) 62 | 63 | finish: 64 | # exit code is zero 65 | mov x0, #0 66 | # exit application 67 | bl _exit 68 | 69 | .size make_fcontext,.-make_fcontext 70 | # Mark that we don't need executable stack. 71 | .section .note.GNU-stack,"",%progbits 72 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/make_arm64_aapcs_macho_gas.S: -------------------------------------------------------------------------------- 1 | /******************************************************* 2 | * * 3 | * ------------------------------------------------- * 4 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 5 | * ------------------------------------------------- * 6 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 7 | * ------------------------------------------------- * 8 | * | x19 | x20 | x21 | x22 | * 9 | * ------------------------------------------------- * 10 | * ------------------------------------------------- * 11 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 12 | * ------------------------------------------------- * 13 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 14 | * ------------------------------------------------- * 15 | * | x23 | x24 | x25 | x26 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 19 | * ------------------------------------------------- * 20 | * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * 21 | * ------------------------------------------------- * 22 | * | x27 | x28 | FP | LR | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 26 | * ------------------------------------------------- * 27 | * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * 28 | * ------------------------------------------------- * 29 | * | PC | align | | | * 30 | * ------------------------------------------------- * 31 | * * 32 | *******************************************************/ 33 | 34 | .text 35 | .globl _make_fcontext 36 | .balign 16 37 | 38 | _make_fcontext: 39 | ; shift address in x0 (allocated stack) to lower 16 byte boundary 40 | and x0, x0, ~0xF 41 | 42 | ; reserve space for context-data on context-stack 43 | sub x0, x0, #0x70 44 | 45 | ; third arg of make_fcontext() == address of context-function 46 | ; store address as a PC to jump in 47 | str x2, [x0, #0x60] 48 | 49 | ; compute abs address of label finish 50 | ; 0x0c = 3 instructions * size (4) before label 'finish' 51 | 52 | ; TODO: Numeric offset since llvm still does not support labels in ADR. Fix: 53 | ; http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140407/212336.html 54 | adr x1, 0x0c 55 | 56 | ; save address of finish as return-address for context-function 57 | ; will be entered after context-function returns (LR register) 58 | str x1, [x0, #0x58] 59 | 60 | ret lr ; return pointer to context-data (x0) 61 | 62 | finish: 63 | ; exit code is zero 64 | mov x0, #0 65 | ; exit application 66 | bl __exit 67 | 68 | 69 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/make_arm_aapcs_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 14 | * ------------------------------------------------- * 15 | * |hiddn| v1 | v2 | v3 | v4 | v5 | v6 | v7 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 21 | * ------------------------------------------------- * 22 | * | v8 | lr | pc | FCTX| DATA| | * 23 | * ------------------------------------------------- * 24 | * * 25 | *******************************************************/ 26 | 27 | .text 28 | .globl make_fcontext 29 | .align 2 30 | .type make_fcontext,%function 31 | make_fcontext: 32 | @ shift address in A1 to lower 16 byte boundary 33 | bic a1, a1, #15 34 | 35 | @ reserve space for context-data on context-stack 36 | sub a1, a1, #60 37 | 38 | @ third arg of make_fcontext() == address of context-function 39 | str a3, [a1, #40] 40 | 41 | @ compute address of returned transfer_t 42 | add a2, a1, #44 43 | mov a3, a2 44 | str a3, [a1, #0] 45 | 46 | @ compute abs address of label finish 47 | adr a2, finish 48 | @ save address of finish as return-address for context-function 49 | @ will be entered after context-function returns 50 | str a2, [a1, #36] 51 | 52 | bx lr @ return pointer to context-data 53 | 54 | finish: 55 | @ exit code is zero 56 | mov a1, #0 57 | @ exit application 58 | bl _exit@PLT 59 | .size make_fcontext,.-make_fcontext 60 | 61 | @ Mark that we don't need executable stack. 62 | .section .note.GNU-stack,"",%progbits 63 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/make_arm_aapcs_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 14 | * ------------------------------------------------- * 15 | * | sjlj|hiddn| v1 | v2 | v3 | v4 | v5 | v6 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 21 | * ------------------------------------------------- * 22 | * | v7 | v8 | lr | pc | FCTX| DATA| | * 23 | * ------------------------------------------------- * 24 | * * 25 | *******************************************************/ 26 | 27 | .text 28 | .globl _make_fcontext 29 | .align 2 30 | _make_fcontext: 31 | @ shift address in A1 to lower 16 byte boundary 32 | bic a1, a1, #15 33 | 34 | @ reserve space for context-data on context-stack 35 | sub a1, a1, #64 36 | 37 | @ third arg of make_fcontext() == address of context-function 38 | str a3, [a1, #44] 39 | 40 | @ compute address of returned transfer_t 41 | add a2, a1, #48 42 | mov a3, a2 43 | str a3, [a1, #4] 44 | 45 | @ compute abs address of label finish 46 | adr a2, finish 47 | @ save address of finish as return-address for context-function 48 | @ will be entered after context-function returns 49 | str a2, [a1, #40] 50 | 51 | bx lr @ return pointer to context-data 52 | 53 | finish: 54 | @ exit code is zero 55 | mov a1, #0 56 | @ exit application 57 | bl __exit 58 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/make_arm_aapcs_pe_armasm.asm: -------------------------------------------------------------------------------- 1 | ;/* 2 | ; Copyright Oliver Kowalke 2009. 3 | ; Distributed under the Boost Software License, Version 1.0. 4 | ; (See accompanying file LICENSE_1_0.txt or copy at 5 | ; http://www.boost.org/LICENSE_1_0.txt) 6 | ;*/ 7 | 8 | ; ******************************************************* 9 | ; * * 10 | ; * ------------------------------------------------- * 11 | ; * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | ; * ------------------------------------------------- * 13 | ; * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 14 | ; * ------------------------------------------------- * 15 | ; * |deall|limit| base|hiddn| v1 | v2 | v3 | v4 | * 16 | ; * ------------------------------------------------- * 17 | ; * ------------------------------------------------- * 18 | ; * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | ; * ------------------------------------------------- * 20 | ; * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 21 | ; * ------------------------------------------------- * 22 | ; * | v5 | v6 | v7 | v8 | lr | pc | FCTX| DATA| * 23 | ; * ------------------------------------------------- * 24 | ; * * 25 | ; ******************************************************* 26 | 27 | 28 | AREA |.text|, CODE 29 | ALIGN 4 30 | EXPORT make_fcontext 31 | IMPORT _exit 32 | 33 | make_fcontext PROC 34 | ; first arg of make_fcontext() == top of context-stack 35 | ; save top of context-stack (base) A4 36 | mov a4, a1 37 | 38 | ; shift address in A1 to lower 16 byte boundary 39 | bic a1, a1, #0x0f 40 | 41 | ; reserve space for context-data on context-stack 42 | sub a1, a1, #0x48 43 | 44 | ; save top address of context_stack as 'base' 45 | str a4, [a1, #0x8] 46 | ; second arg of make_fcontext() == size of context-stack 47 | ; compute bottom address of context-stack (limit) 48 | sub a4, a4, a2 49 | ; save bottom address of context-stack as 'limit' 50 | str a4, [a1, #0x4] 51 | ; save bottom address of context-stack as 'dealloction stack' 52 | str a4, [a1, #0x0] 53 | 54 | ; third arg of make_fcontext() == address of context-function 55 | str a3, [a1, #0x34] 56 | 57 | ; compute address of returned transfer_t 58 | add a2, a1, #0x38 59 | mov a3, a2 60 | str a3, [a1, #0xc] 61 | 62 | ; compute abs address of label finish 63 | adr a2, finish 64 | ; save address of finish as return-address for context-function 65 | ; will be entered after context-function returns 66 | str a2, [a1, #0x30] 67 | 68 | bx lr ; return pointer to context-data 69 | 70 | finish 71 | ; exit code is zero 72 | mov a1, #0 73 | ; exit application 74 | bl _exit 75 | 76 | ENDP 77 | END 78 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/make_combined_all_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) 11 | #if defined(__aarch64__) 12 | #include "make_arm64_aapcs_macho_gas.S" 13 | #else 14 | #include "make_arm_aapcs_macho_gas.S" 15 | #endif 16 | #else 17 | #if defined(__i386__) 18 | #include "make_i386_sysv_macho_gas.S" 19 | #elif defined(__x86_64__) 20 | #include "make_x86_64_sysv_macho_gas.S" 21 | #elif defined(__ppc__) 22 | #include "make_ppc32_sysv_macho_gas.S" 23 | #elif defined(__ppc64__) 24 | #include "make_ppc64_sysv_macho_gas.S" 25 | #else 26 | #error "No arch's" 27 | #endif 28 | #endif 29 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/make_combined_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__i386__) 11 | #include "make_i386_sysv_macho_gas.S" 12 | #elif defined(__x86_64__) 13 | #include "make_x86_64_sysv_macho_gas.S" 14 | #elif defined(__ppc__) 15 | #include "make_ppc32_sysv_macho_gas.S" 16 | #elif defined(__ppc64__) 17 | #include "make_ppc64_sysv_macho_gas.S" 18 | #else 19 | #error "No arch's" 20 | #endif 21 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/make_i386_sysv_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /***************************************************************************************** 9 | * * 10 | * ----------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ----------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ----------------------------------------------------------------------------------- * 15 | * | EDI | ESI | EBX | EBP | EIP | hidden | to | data | * 16 | * ----------------------------------------------------------------------------------- * 17 | * * 18 | *****************************************************************************************/ 19 | 20 | .text 21 | .globl make_fcontext 22 | .align 2 23 | .type make_fcontext,@function 24 | make_fcontext: 25 | /* first arg of make_fcontext() == top of context-stack */ 26 | movl 0x4(%esp), %eax 27 | 28 | /* reserve space for first argument of context-function 29 | rax might already point to a 16byte border */ 30 | leal -0x8(%eax), %eax 31 | 32 | /* shift address in EAX to lower 16 byte boundary */ 33 | andl $-16, %eax 34 | 35 | /* reserve space for context-data on context-stack */ 36 | leal -0x28(%eax), %eax 37 | 38 | /* third arg of make_fcontext() == address of context-function */ 39 | /* stored in EBX */ 40 | movl 0xc(%esp), %ecx 41 | movl %ecx, 0x8(%eax) 42 | 43 | /* return transport_t */ 44 | /* FCTX == EDI, DATA == ESI */ 45 | leal (%eax), %ecx 46 | movl %ecx, 0x14(%eax) 47 | 48 | /* compute abs address of label trampoline */ 49 | call 1f 50 | /* address of trampoline 1 */ 51 | 1: popl %ecx 52 | /* compute abs address of label trampoline */ 53 | addl $trampoline-1b, %ecx 54 | /* save address of trampoline as return address */ 55 | /* will be entered after calling jump_fcontext() first time */ 56 | movl %ecx, 0x10(%eax) 57 | 58 | /* compute abs address of label finish */ 59 | call 2f 60 | /* address of label 2 */ 61 | 2: popl %ecx 62 | /* compute abs address of label finish */ 63 | addl $finish-2b, %ecx 64 | /* save address of finish as return-address for context-function */ 65 | /* will be entered after context-function returns */ 66 | movl %ecx, 0xc(%eax) 67 | 68 | ret /* return pointer to context-data */ 69 | 70 | trampoline: 71 | /* move transport_t for entering context-function */ 72 | movl %edi, (%esp) 73 | movl %esi, 0x4(%esp) 74 | pushl %ebp 75 | /* jump to context-function */ 76 | jmp *%ebx 77 | 78 | finish: 79 | call 3f 80 | /* address of label 3 */ 81 | 3: popl %ebx 82 | /* compute address of GOT and store it in EBX */ 83 | addl $_GLOBAL_OFFSET_TABLE_+[.-3b], %ebx 84 | 85 | /* exit code is zero */ 86 | xorl %eax, %eax 87 | movl %eax, (%esp) 88 | /* exit application */ 89 | call _exit@PLT 90 | hlt 91 | .size make_fcontext,.-make_fcontext 92 | 93 | /* Mark that we don't need executable stack. */ 94 | .section .note.GNU-stack,"",%progbits 95 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/make_i386_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /***************************************************************************************** 9 | * * 10 | * ----------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ----------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ----------------------------------------------------------------------------------- * 15 | * | EDI | ESI | EBX | EBP | EIP | hidden | to | data | * 16 | * ----------------------------------------------------------------------------------- * 17 | * * 18 | *****************************************************************************************/ 19 | 20 | .text 21 | .globl _make_fcontext 22 | .align 2 23 | _make_fcontext: 24 | /* first arg of make_fcontext() == top of context-stack */ 25 | movl 0x4(%esp), %eax 26 | 27 | /* reserve space for first argument of context-function 28 | rax might already point to a 16byte border */ 29 | leal -0x8(%eax), %eax 30 | 31 | /* shift address in EAX to lower 16 byte boundary */ 32 | andl $-16, %eax 33 | 34 | /* reserve space for context-data on context-stack */ 35 | leal -0x28(%eax), %eax 36 | 37 | /* thrid arg of make_fcontext() == address of context-function */ 38 | /* stored in EBX */ 39 | movl 0xc(%esp), %edx 40 | movl %edx, 0x8(%eax) 41 | 42 | /* return transport_t */ 43 | /* FCTX == EDI, DATA == ESI */ 44 | leal (%eax), %ecx 45 | movl %ecx, 0x14(%eax) 46 | 47 | /* compute abs address of label trampoline */ 48 | call 1f 49 | /* address of trampoline 1 */ 50 | 1: popl %ecx 51 | /* compute abs address of label trampoline */ 52 | addl $trampoline-1b, %ecx 53 | /* save address of trampoline as return address */ 54 | /* will be entered after calling jump_fcontext() first time */ 55 | movl %ecx, 0x10(%eax) 56 | 57 | /* compute abs address of label finish */ 58 | call 2f 59 | /* address of label 2 */ 60 | 2: popl %ecx 61 | /* compute abs address of label finish */ 62 | addl $finish-2b, %ecx 63 | /* save address of finish as return-address for context-function */ 64 | /* will be entered after context-function returns */ 65 | movl %ecx, 0xc(%eax) 66 | 67 | ret /* return pointer to context-data */ 68 | 69 | trampoline: 70 | /* move transport_t for entering context-function */ 71 | movl %edi, (%esp) 72 | movl %esi, 0x4(%esp) 73 | pushl %ebp 74 | /* jump to context-function */ 75 | jmp *%ebx 76 | 77 | finish: 78 | /* exit code is zero */ 79 | xorl %eax, %eax 80 | movl %eax, (%esp) 81 | /* exit application */ 82 | call __exit 83 | hlt 84 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/make_i386_x86_64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__i386__) 11 | #include "make_i386_sysv_macho_gas.S" 12 | #elif defined(__x86_64__) 13 | #include "make_x86_64_sysv_macho_gas.S" 14 | #else 15 | #error "No arch's" 16 | #endif 17 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/make_mips32_o32_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 14 | * ------------------------------------------------- * 15 | * | S0 | S1 | S2 | S3 | S4 | S5 | S6 | S7 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 21 | * ------------------------------------------------- * 22 | * | FP |hiddn| RA | PC | GP | FCTX| DATA| | * 23 | * ------------------------------------------------- * 24 | * * 25 | * *****************************************************/ 26 | 27 | .text 28 | .globl make_fcontext 29 | .align 2 30 | .type make_fcontext,@function 31 | .ent make_fcontext 32 | make_fcontext: 33 | #ifdef __PIC__ 34 | .set noreorder 35 | .cpload $t9 36 | .set reorder 37 | #endif 38 | # first arg of make_fcontext() == top address of context-stack 39 | move $v0, $a0 40 | 41 | # shift address in A0 to lower 16 byte boundary 42 | move $v1, $v0 43 | li $v0, -16 # 0xfffffffffffffff0 44 | and $v0, $v1, $v0 45 | 46 | # reserve space for context-data on context-stack 47 | # including 48 byte of shadow space (sp % 16 == 0) 48 | addiu $v0, $v0, -112 49 | 50 | # third arg of make_fcontext() == address of context-function 51 | sw $a2, 44($v0) 52 | # save global pointer in context-data 53 | sw $gp, 48($v0) 54 | 55 | # compute address of returned transfer_t 56 | addiu $t0, $v0, 52 57 | sw $t0, 36($v0) 58 | 59 | # compute abs address of label finish 60 | la $t9, finish 61 | # save address of finish as return-address for context-function 62 | # will be entered after context-function returns 63 | sw $t9, 40($v0) 64 | 65 | jr $ra # return pointer to context-data 66 | 67 | finish: 68 | lw $gp, 0($sp) 69 | # allocate stack space (contains shadow space for subroutines) 70 | addiu $sp, $sp, -32 71 | # save return address 72 | sw $ra, 28($sp) 73 | 74 | # restore GP (global pointer) 75 | # move $gp, $s1 76 | # exit code is zero 77 | move $a0, $zero 78 | # address of exit 79 | lw $t9, %call16(_exit)($gp) 80 | # exit application 81 | jalr $t9 82 | .end make_fcontext 83 | .size make_fcontext, .-make_fcontext 84 | 85 | /* Mark that we don't need executable stack. */ 86 | .section .note.GNU-stack,"",%progbits 87 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/make_ppc32_ppc64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__ppc__) 11 | #include "make_ppc32_sysv_macho_gas.S" 12 | #elif defined(__ppc64__) 13 | #include "make_ppc64_sysv_macho_gas.S" 14 | #else 15 | #error "No arch's" 16 | #endif 17 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/make_ppc32_sysv_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /****************************************************** 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 14 | * ------------------------------------------------- * 15 | * | R13 | R14 | R15 | R16 | R17 | R18 | R19 | R20 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 21 | * ------------------------------------------------- * 22 | * | R21 | R22 | R23 | R24 | R25 | R26 | R27 | R28 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | * 28 | * ------------------------------------------------- * 29 | * | R29 | R30 | R31 |hiddn| CR | LR | PC |bchai| * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 33 | * ------------------------------------------------- * 34 | * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * 35 | * ------------------------------------------------- * 36 | * |linkr| FCTX| DATA| | * 37 | * ------------------------------------------------- * 38 | * * 39 | *******************************************************/ 40 | 41 | .text 42 | .globl make_fcontext 43 | .align 2 44 | .type make_fcontext,@function 45 | make_fcontext: 46 | # save return address into R6 47 | mflr %r6 48 | 49 | # first arg of make_fcontext() == top address of context-function 50 | # shift address in R3 to lower 16 byte boundary 51 | clrrwi %r3, %r3, 4 52 | 53 | # reserve space for context-data on context-stack 54 | # including 64 byte of linkage + parameter area (R1 % 16 == 0) 55 | subi %r3, %r3, 172 56 | 57 | # third arg of make_fcontext() == address of context-function 58 | stw %r5, 88(%r3) 59 | 60 | # set back-chain to zero 61 | li %r0, 0 62 | stw %r0, 92(%r3) 63 | 64 | # compute address of returned transfer_t 65 | addi %r0, %r3, 100 66 | mr %r4, %r0 67 | stw %r4, 76(%r3) 68 | 69 | # load LR 70 | mflr %r0 71 | # jump to label 1 72 | bl 1f 73 | 1: 74 | # load LR into R4 75 | mflr %r4 76 | # compute abs address of label finish 77 | addi %r4, %r4, finish - 1b 78 | # restore LR 79 | mtlr %r0 80 | # save address of finish as return-address for context-function 81 | # will be entered after context-function returns 82 | stw %r4, 84(%r3) 83 | 84 | # restore return address from R6 85 | mtlr %r6 86 | 87 | blr # return pointer to context-data 88 | 89 | finish: 90 | # save return address into R0 91 | mflr %r0 92 | # save return address on stack, set up stack frame 93 | stw %r0, 4(%r1) 94 | # allocate stack space, R1 % 16 == 0 95 | stwu %r1, -16(%r1) 96 | 97 | # exit code is zero 98 | li %r3, 0 99 | # exit application 100 | bl _exit@plt 101 | .size make_fcontext, .-make_fcontext 102 | 103 | /* Mark that we don't need executable stack. */ 104 | .section .note.GNU-stack,"",%progbits 105 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/make_ppc32_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /****************************************************** 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 14 | * ------------------------------------------------- * 15 | * | R13 | R14 | R15 | R16 | R17 | R18 | R19 | R20 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 21 | * ------------------------------------------------- * 22 | * | R21 | R22 | R23 | R24 | R25 | R26 | R27 | R28 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | * 28 | * ------------------------------------------------- * 29 | * | R29 | R30 | R31 |hiddn| CR | LR | PC |bchai| * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 33 | * ------------------------------------------------- * 34 | * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * 35 | * ------------------------------------------------- * 36 | * |linkr| FCTX| DATA| | * 37 | * ------------------------------------------------- * 38 | * * 39 | *******************************************************/ 40 | 41 | .text 42 | .globl _make_fcontext 43 | .align 2 44 | _make_fcontext: 45 | ; save return address into R6 46 | mflr r6 47 | 48 | ; first arg of make_fcontext() == top address of context-function 49 | ; shift address in R3 to lower 16 byte boundary 50 | clrrwi r3, r3, 4 51 | 52 | ; reserve space for context-data on context-stack 53 | ; including 64 byte of linkage + parameter area (R1 % 16 == 0) 54 | subi r3, r3, 172 55 | 56 | ; third arg of make_fcontext() == address of context-function 57 | stw r5, 88(r3) 58 | 59 | ; set back-chain to zero 60 | li r0, 0 61 | stw r0, 92(r3) 62 | 63 | ; compute address of returned transfer_t 64 | addi r0, r3, 100 65 | mr r4, r0 66 | stw r4, 76(r3) 67 | 68 | ; load LR 69 | mflr r0 70 | ; jump to label 1 71 | bl l1 72 | l1: 73 | ; load LR into R4 74 | mflr r4 75 | ; compute abs address of label finish 76 | addi r4, r4, lo16((finish - .)+4) 77 | # restore LR 78 | mtlr r0 79 | ; save address of finish as return-address for context-function 80 | ; will be entered after context-function returns 81 | stw r4, 84(r3) 82 | 83 | ; restore return address from R6 84 | mtlr r6 85 | 86 | blr ; return pointer to context-data 87 | 88 | finish: 89 | ; save return address into R0 90 | mflr r0 91 | ; save return address on stack, set up stack frame 92 | stw r0, 4(r1) 93 | ; allocate stack space, R1 % 16 == 0 94 | stwu r1, -16(r1) 95 | 96 | ; exit code is zero 97 | li r3, 0 98 | ; exit application 99 | bl __exit 100 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/make_ppc32_sysv_xcoff_gas.S: -------------------------------------------------------------------------------- 1 | .globl make_fcontext[DS] 2 | .globl .make_fcontext[PR] 3 | .align 2 4 | .csect make_fcontext[DS] 5 | make_fcontext: 6 | .long .make_fcontext[PR] 7 | .csect .make_fcontext[PR], 3 8 | #.make_fcontext: 9 | # save return address into R6 10 | mflr 6 11 | 12 | # first arg of make_fcontext() == top address of context-function 13 | # shift address in R3 to lower 16 byte boundary 14 | clrrwi 3, 3, 4 15 | 16 | # reserve space for context-data on context-stack 17 | # including 64 byte of linkage + parameter area (R1 % 16 == 0) 18 | subi 3, 3, 172 19 | 20 | # third arg of make_fcontext() == address of context-function 21 | stw 5, 88(3) 22 | 23 | # set back-chain to zero 24 | li 0, 0 25 | stw 0, 92(3) 26 | 27 | # compute address of returned transfer_t 28 | addi 0, 3, 100 29 | mr 4, 0 30 | stw 4, 76(3) 31 | 32 | # load LR 33 | mflr 0 34 | # jump to label 1 35 | bl .Label 36 | .Label: 37 | # load LR into R4 38 | mflr 4 39 | # compute abs address of label .L_finish 40 | addi 4, 4, .L_finish - .Label 41 | # restore LR 42 | mtlr 0 43 | # save address of finish as return-address for context-function 44 | # will be entered after context-function returns 45 | stw 4, 84(3) 46 | 47 | # restore return address from R6 48 | mtlr 6 49 | 50 | blr # return pointer to context-data 51 | 52 | .L_finish: 53 | # save return address into R0 54 | mflr 0 55 | # save return address on stack, set up stack frame 56 | stw 0, 4(1) 57 | # allocate stack space, R1 % 16 == 0 58 | stwu 1, -16(1) 59 | 60 | # exit code is zero 61 | li 3, 0 62 | # exit application 63 | bl ._exit 64 | nop 65 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/make_ppc64_sysv_xcoff_gas.S: -------------------------------------------------------------------------------- 1 | .globl make_fcontext[DS] 2 | .globl .make_fcontext[PR] 3 | .align 2 4 | .csect .make_fcontext[PR], 3 5 | .globl _make_fcontext 6 | #._make_fcontext: 7 | # save return address into R6 8 | mflr 6 9 | 10 | # first arg of make_fcontext() == top address of context-function 11 | # shift address in R3 to lower 16 byte boundary 12 | clrrwi 3, 3, 4 13 | 14 | # reserve space for context-data on context-stack 15 | # including 64 byte of linkage + parameter area (R1 % 16 == 0) 16 | subi 3, 3, 248 17 | 18 | # third arg of make_fcontext() == address of context-function 19 | stw 5, 176(3) 20 | 21 | # set back-chain to zero 22 | li 0, 0 23 | std 0, 184(3) 24 | 25 | # compute address of returned transfer_t 26 | addi 0, 3, 232 27 | mr 4, 0 28 | std 4, 152(3) 29 | 30 | # load LR 31 | mflr 0 32 | # jump to label 1 33 | bl .Label 34 | .Label: 35 | # load LR into R4 36 | mflr 4 37 | # compute abs address of label .L_finish 38 | addi 4, 4, .L_finish - .Label 39 | # restore LR 40 | mtlr 0 41 | # save address of finish as return-address for context-function 42 | # will be entered after context-function returns 43 | stw 4, 168(3) 44 | 45 | # restore return address from R6 46 | mtlr 6 47 | 48 | blr # return pointer to context-data 49 | 50 | .L_finish: 51 | # save return address into R0 52 | mflr 0 53 | # save return address on stack, set up stack frame 54 | stw 0, 8(1) 55 | # allocate stack space, R1 % 16 == 0 56 | stwu 1, -32(1) 57 | 58 | # exit code is zero 59 | li 3, 0 60 | # exit application 61 | bl ._exit 62 | nop 63 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/make_x86_64_sysv_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /**************************************************************************************** 9 | * * 10 | * ---------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ---------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ---------------------------------------------------------------------------------- * 15 | * | R12 | R13 | R14 | R15 | * 16 | * ---------------------------------------------------------------------------------- * 17 | * ---------------------------------------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ---------------------------------------------------------------------------------- * 20 | * | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | * 21 | * ---------------------------------------------------------------------------------- * 22 | * | RBX | RBP | RIP | EXIT | * 23 | * ---------------------------------------------------------------------------------- * 24 | * * 25 | ****************************************************************************************/ 26 | 27 | .text 28 | .globl make_fcontext 29 | .type make_fcontext,@function 30 | .align 16 31 | make_fcontext: 32 | /* first arg of make_fcontext() == top of context-stack */ 33 | movq %rdi, %rax 34 | 35 | /* shift address in RAX to lower 16 byte boundary */ 36 | andq $-16, %rax 37 | 38 | /* reserve space for context-data on context-stack */ 39 | /* on context-function entry: (RSP -0x8) % 16 == 0 */ 40 | leaq -0x40(%rax), %rax 41 | 42 | /* third arg of make_fcontext() == address of context-function */ 43 | movq %rdx, 0x30(%rax) 44 | 45 | /* compute abs address of label finish */ 46 | leaq finish(%rip), %rcx 47 | /* save address of finish as return-address for context-function */ 48 | /* will be entered after context-function returns */ 49 | movq %rcx, 0x38(%rax) 50 | 51 | ret /* return pointer to context-data */ 52 | 53 | finish: 54 | /* exit code is zero */ 55 | xorq %rdi, %rdi 56 | /* exit application */ 57 | call _exit@PLT 58 | hlt 59 | .size make_fcontext,.-make_fcontext 60 | 61 | /* Mark that we don't need executable stack. */ 62 | .section .note.GNU-stack,"",%progbits 63 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/make_x86_64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /**************************************************************************************** 9 | * * 10 | * ---------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ---------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ---------------------------------------------------------------------------------- * 15 | * | R12 | R13 | R14 | R15 | * 16 | * ---------------------------------------------------------------------------------- * 17 | * ---------------------------------------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ---------------------------------------------------------------------------------- * 20 | * | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | * 21 | * ---------------------------------------------------------------------------------- * 22 | * | RBX | RBP | RIP | EXIT | * 23 | * ---------------------------------------------------------------------------------- * 24 | * * 25 | ****************************************************************************************/ 26 | 27 | .text 28 | .globl _make_fcontext 29 | .align 8 30 | _make_fcontext: 31 | /* first arg of make_fcontext() == top of context-stack */ 32 | movq %rdi, %rax 33 | 34 | /* shift address in RAX to lower 16 byte boundary */ 35 | movabs $-16, %r8 36 | andq %r8, %rax 37 | 38 | /* reserve space for context-data on context-stack */ 39 | /* on context-function entry: (RSP -0x8) % 16 == 0 */ 40 | leaq -0x40(%rax), %rax 41 | 42 | /* third arg of make_fcontext() == address of context-function */ 43 | movq %rdx, 0x30(%rax) 44 | 45 | /* compute abs address of label finish */ 46 | leaq finish(%rip), %rcx 47 | /* save address of finish as return-address for context-function */ 48 | /* will be entered after context-function returns */ 49 | movq %rcx, 0x38(%rax) 50 | 51 | ret /* return pointer to context-data */ 52 | 53 | finish: 54 | /* exit code is zero */ 55 | xorq %rdi, %rdi 56 | /* exit application */ 57 | call __exit 58 | hlt 59 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/ontop_arm64_aapcs_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Edward Nevill + Oliver Kowalke 2015 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | /******************************************************* 8 | * * 9 | * ------------------------------------------------- * 10 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 11 | * ------------------------------------------------- * 12 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 13 | * ------------------------------------------------- * 14 | * | x19 | x20 | x21 | x22 | * 15 | * ------------------------------------------------- * 16 | * ------------------------------------------------- * 17 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 18 | * ------------------------------------------------- * 19 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 20 | * ------------------------------------------------- * 21 | * | x23 | x24 | x25 | x26 | * 22 | * ------------------------------------------------- * 23 | * ------------------------------------------------- * 24 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 25 | * ------------------------------------------------- * 26 | * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * 27 | * ------------------------------------------------- * 28 | * | x27 | x28 | FP | LR | * 29 | * ------------------------------------------------- * 30 | * ------------------------------------------------- * 31 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 32 | * ------------------------------------------------- * 33 | * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * 34 | * ------------------------------------------------- * 35 | * | PC | align | | | * 36 | * ------------------------------------------------- * 37 | * * 38 | *******************************************************/ 39 | 40 | .cpu generic+fp+simd 41 | .text 42 | .align 2 43 | .global ontop_fcontext 44 | .type ontop_fcontext, %function 45 | ontop_fcontext: 46 | # prepare stack for GP + FPU 47 | sub sp, sp, #0x70 48 | 49 | # save x19-x30 50 | stp x19, x20, [sp, #0x00] 51 | stp x21, x22, [sp, #0x10] 52 | stp x23, x24, [sp, #0x20] 53 | stp x25, x26, [sp, #0x30] 54 | stp x27, x28, [sp, #0x40] 55 | stp x29, x30, [sp, #0x50] 56 | 57 | # save LR as PC 58 | str x30, [sp, #0x60] 59 | 60 | # store RSP (pointing to context-data) in X5 61 | mov x4, sp 62 | 63 | # restore RSP (pointing to context-data) from X1 64 | mov sp, x0 65 | 66 | # load x19-x30 67 | ldp x19, x20, [sp, #0x00] 68 | ldp x21, x22, [sp, #0x10] 69 | ldp x23, x24, [sp, #0x20] 70 | ldp x25, x26, [sp, #0x30] 71 | ldp x27, x28, [sp, #0x40] 72 | ldp x29, x30, [sp, #0x50] 73 | 74 | # return transfer_t from jump 75 | # pass transfer_t as first arg in context function 76 | # X0 == FCTX, X1 == DATA 77 | mov x0, x4 78 | 79 | # skip pc 80 | # restore stack from GP + FPU 81 | add sp, sp, #0x70 82 | 83 | # jump to ontop-function 84 | ret x2 85 | .size ontop_fcontext,.-ontop_fcontext 86 | # Mark that we don't need executable stack. 87 | .section .note.GNU-stack,"",%progbits 88 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/ontop_arm64_aapcs_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Edward Nevill + Oliver Kowalke 2015 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | /******************************************************* 8 | * * 9 | * ------------------------------------------------- * 10 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 11 | * ------------------------------------------------- * 12 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 13 | * ------------------------------------------------- * 14 | * | x19 | x20 | x21 | x22 | * 15 | * ------------------------------------------------- * 16 | * ------------------------------------------------- * 17 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 18 | * ------------------------------------------------- * 19 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 20 | * ------------------------------------------------- * 21 | * | x23 | x24 | x25 | x26 | * 22 | * ------------------------------------------------- * 23 | * ------------------------------------------------- * 24 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 25 | * ------------------------------------------------- * 26 | * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * 27 | * ------------------------------------------------- * 28 | * | x27 | x28 | FP | LR | * 29 | * ------------------------------------------------- * 30 | * ------------------------------------------------- * 31 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 32 | * ------------------------------------------------- * 33 | * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * 34 | * ------------------------------------------------- * 35 | * | PC | align | | | * 36 | * ------------------------------------------------- * 37 | * * 38 | *******************************************************/ 39 | 40 | .text 41 | .global _ontop_fcontext 42 | .balign 16 43 | _ontop_fcontext: 44 | # prepare stack for GP + FPU 45 | sub sp, sp, #0x70 46 | 47 | # save x19-x30 48 | stp x19, x20, [sp, #0x00] 49 | stp x21, x22, [sp, #0x10] 50 | stp x23, x24, [sp, #0x20] 51 | stp x25, x26, [sp, #0x30] 52 | stp x27, x28, [sp, #0x40] 53 | stp x29, x30, [sp, #0x50] 54 | 55 | # save LR as PC 56 | str x30, [sp, #0x60] 57 | 58 | # store RSP (pointing to context-data) in X5 59 | mov x4, sp 60 | 61 | # restore RSP (pointing to context-data) from X1 62 | mov sp, x0 63 | 64 | # load x19-x30 65 | ldp x19, x20, [sp, #0x00] 66 | ldp x21, x22, [sp, #0x10] 67 | ldp x23, x24, [sp, #0x20] 68 | ldp x25, x26, [sp, #0x30] 69 | ldp x27, x28, [sp, #0x40] 70 | ldp x29, x30, [sp, #0x50] 71 | 72 | # return transfer_t from jump 73 | # pass transfer_t as first arg in context function 74 | # X0 == FCTX, X1 == DATA 75 | mov x0, x4 76 | 77 | # skip pc 78 | # restore stack from GP + FPU 79 | add sp, sp, #0x70 80 | 81 | # jump to ontop-function 82 | ret x2 83 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/ontop_arm_aapcs_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 14 | * ------------------------------------------------- * 15 | * |hiddn| v1 | v2 | v3 | v4 | v5 | v6 | v7 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 21 | * ------------------------------------------------- * 22 | * | v8 | lr | pc | FCTX| DATA| | * 23 | * ------------------------------------------------- * 24 | * * 25 | *******************************************************/ 26 | 27 | .text 28 | .globl ontop_fcontext 29 | .align 2 30 | .type ontop_fcontext,%function 31 | ontop_fcontext: 32 | @ save LR as PC 33 | push {lr} 34 | @ save hidden,V1-V8,LR 35 | push {a1,v1-v8,lr} 36 | 37 | @ store RSP (pointing to context-data) in A1 38 | mov a1, sp 39 | 40 | @ restore RSP (pointing to context-data) from A2 41 | mov sp, a2 42 | 43 | @ store parent context in A2 44 | mov a2, a1 45 | 46 | @ restore hidden,V1-V8,LR 47 | pop {a1,v1-v8,lr} 48 | 49 | @ return transfer_t from jump 50 | str a2, [a1, #0] 51 | str a3, [a1, #4] 52 | @ pass transfer_t as first arg in context function 53 | @ A1 == hidden, A2 == FCTX, A3 == DATA 54 | 55 | @ skip PC 56 | add sp, sp, #4 57 | 58 | @ jump to ontop-function 59 | bx a4 60 | .size ontop_fcontext,.-ontop_fcontext 61 | 62 | @ Mark that we don't need executable stack. 63 | .section .note.GNU-stack,"",%progbits 64 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/ontop_arm_aapcs_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 14 | * ------------------------------------------------- * 15 | * | sjlj|hiddn| v1 | v2 | v3 | v4 | v5 | v6 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 21 | * ------------------------------------------------- * 22 | * | v7 | v8 | lr | pc | FCTX| DATA| | * 23 | * ------------------------------------------------- * 24 | * * 25 | *******************************************************/ 26 | 27 | .text 28 | .globl _ontop_fcontext 29 | .align 2 30 | _ontop_fcontext: 31 | @ save LR as PC 32 | push {lr} 33 | @ save hidden,V1-V8,LR 34 | push {a1,v1-v8,lr} 35 | 36 | @ locate TLS to save/restore SjLj handler 37 | mrc p15, 0, v2, c13, c0, #3 38 | bic v2, v2, #3 39 | 40 | @ load TLS[__PTK_LIBC_DYLD_Unwind_SjLj_Key] 41 | ldr v1, [v2, #8] 42 | @ save SjLj handler 43 | push {v1} 44 | 45 | @ store RSP (pointing to context-data) in A1 46 | mov a1, sp 47 | 48 | @ restore RSP (pointing to context-data) from A2 49 | mov sp, a2 50 | 51 | @ restore SjLj handler 52 | pop {v1} 53 | @ store SjLj handler in TLS 54 | str v1, [v2, #8] 55 | 56 | @ store parent context in A2 57 | mov a2, a1 58 | 59 | @ restore hidden,V1-V8,LR 60 | pop {a1,v1-v8,lr} 61 | 62 | @ return transfer_t from jump 63 | str a2, [a1, #0] 64 | str a3, [a1, #4] 65 | @ pass transfer_t as first arg in context function 66 | @ A1 == hidden, A2 == FCTX, A3 == DATA 67 | 68 | @ skip PC 69 | add sp, sp, #4 70 | 71 | @ jump to ontop-function 72 | bx a4 73 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/ontop_arm_aapcs_pe_armasm.asm: -------------------------------------------------------------------------------- 1 | ;/* 2 | ; Copyright Oliver Kowalke 2009. 3 | ; Distributed under the Boost Software License, Version 1.0. 4 | ; (See accompanying file LICENSE_1_0.txt or copy at 5 | ; http://www.boost.org/LICENSE_1_0.txt) 6 | ;*/ 7 | 8 | ; ******************************************************* 9 | ; * * 10 | ; * ------------------------------------------------- * 11 | ; * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | ; * ------------------------------------------------- * 13 | ; * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 14 | ; * ------------------------------------------------- * 15 | ; * |deall|limit| base|hiddn| v1 | v2 | v3 | v4 | * 16 | ; * ------------------------------------------------- * 17 | ; * ------------------------------------------------- * 18 | ; * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | ; * ------------------------------------------------- * 20 | ; * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 21 | ; * ------------------------------------------------- * 22 | ; * | v5 | v6 | v7 | v8 | lr | pc | FCTX| DATA| * 23 | ; * ------------------------------------------------- * 24 | ; * * 25 | ; ******************************************************* 26 | 27 | AREA |.text|, CODE 28 | ALIGN 4 29 | EXPORT ontop_fcontext 30 | 31 | ontop_fcontext PROC 32 | ; save LR as PC 33 | push {lr} 34 | ; save hidden,V1-V8,LR 35 | push {a1,v1-v8,lr} 36 | 37 | ; load TIB to save/restore thread size and limit. 38 | ; we do not need preserve CPU flag and can use it's arg register 39 | mrc p15, #0, v1, c13, c0, #2 40 | 41 | ; save current stack base 42 | ldr a1, [v1, #0x04] 43 | push {a1} 44 | ; save current stack limit 45 | ldr a1, [v1, #0x08] 46 | push {a1} 47 | ; save current deallocation stack 48 | ldr a1, [v1, #0xe0c] 49 | push {a1} 50 | 51 | ; store RSP (pointing to context-data) in A1 52 | mov a1, sp 53 | 54 | ; restore RSP (pointing to context-data) from A2 55 | mov sp, a2 56 | 57 | ; restore stack base 58 | pop {a1} 59 | str a1, [v1, #0x04] 60 | ; restore stack limit 61 | pop {a1} 62 | str a1, [v1, #0x08] 63 | ; restore deallocation stack 64 | pop {a1} 65 | str a1, [v1, #0xe0c] 66 | 67 | ; store parent context in A2 68 | mov a2, a1 69 | 70 | ; restore hidden,V1-V8,LR 71 | pop {a1,v1-v8,lr} 72 | 73 | ; return transfer_t from jump 74 | str a2, [a1, #0] 75 | str a3, [a1, #4] 76 | ; pass transfer_t as first arg in context function 77 | ; A1 == hidden, A2 == FCTX, A3 == DATA 78 | 79 | ; skip PC 80 | add sp, sp, #4 81 | 82 | ; jump to ontop-function 83 | bx a4 84 | 85 | ENDP 86 | END 87 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/ontop_combined_all_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) 11 | #if defined(__aarch64__) 12 | #include "make_arm64_aapcs_macho_gas.S" 13 | #else 14 | #include "make_arm_aapcs_macho_gas.S" 15 | #endif 16 | #else 17 | #if defined(__i386__) 18 | #include "ontop_i386_sysv_macho_gas.S" 19 | #elif defined(__x86_64__) 20 | #include "ontop_x86_64_sysv_macho_gas.S" 21 | #elif defined(__ppc__) 22 | #include "ontop_ppc32_sysv_macho_gas.S" 23 | #elif defined(__ppc64__) 24 | #include "ontop_ppc64_sysv_macho_gas.S" 25 | #else 26 | #error "No arch's" 27 | #endif 28 | #endif 29 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/ontop_combined_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__i386__) 11 | #include "ontop_i386_sysv_macho_gas.S" 12 | #elif defined(__x86_64__) 13 | #include "ontop_x86_64_sysv_macho_gas.S" 14 | #elif defined(__ppc__) 15 | #include "ontop_ppc32_sysv_macho_gas.S" 16 | #elif defined(__ppc64__) 17 | #include "ontop_ppc64_sysv_macho_gas.S" 18 | #else 19 | #error "No arch's" 20 | #endif 21 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/ontop_i386_ms_pe_gas.asm: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Copyright Thomas Sailer 2013. 4 | Distributed under the Boost Software License, Version 1.0. 5 | (See accompanying file LICENSE_1_0.txt or copy at 6 | http://www.boost.org/LICENSE_1_0.txt) 7 | */ 8 | 9 | /************************************************************************************* 10 | * --------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * --------------------------------------------------------------------------------- * 13 | * | 0h | 04h | 08h | 0ch | 010h | 014h | 018h | 01ch | * 14 | * --------------------------------------------------------------------------------- * 15 | * | fc_strg |fc_deallo| limit | base | fc_seh | EDI | ESI | EBX | * 16 | * --------------------------------------------------------------------------------- * 17 | * --------------------------------------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * --------------------------------------------------------------------------------- * 20 | * | 020h | 024h | 028h | 02ch | 030h | 034h | 038h | 03ch | * 21 | * --------------------------------------------------------------------------------- * 22 | * | EBP | EIP | to | data | | EH NXT |SEH HNDLR| | * 23 | * --------------------------------------------------------------------------------- * 24 | *************************************************************************************/ 25 | 26 | .file "ontop_i386_ms_pe_gas.asm" 27 | .text 28 | .p2align 4,,15 29 | .globl _ontop_fcontext 30 | .def _ontop_fcontext; .scl 2; .type 32; .endef 31 | _ontop_fcontext: 32 | pushl %ebp /* save EBP */ 33 | pushl %ebx /* save EBX */ 34 | pushl %esi /* save ESI */ 35 | pushl %edi /* save EDI */ 36 | 37 | /* load NT_TIB */ 38 | movl %fs:(0x18), %edx 39 | 40 | /* load current SEH exception list */ 41 | movl (%edx), %eax 42 | push %eax 43 | 44 | /* load current stack base */ 45 | movl 0x04(%edx), %eax 46 | push %eax 47 | 48 | /* load current stack limit */ 49 | movl 0x08(%edx), %eax 50 | push %eax 51 | 52 | /* load current dealloction stack */ 53 | movl 0xe0c(%edx), %eax 54 | push %eax 55 | 56 | /* load fiber local storage */ 57 | movl 0x10(%edx), %eax 58 | push %eax 59 | 60 | /* store ESP (pointing to context-data) in EAX */ 61 | movl %esp, %ecx 62 | 63 | /* first arg of ontop_fcontext() == fcontext to jump to */ 64 | movl 0x28(%esp), %eax 65 | 66 | /* pass parent fcontext_t */ 67 | movl %ecx, 0x28(%eax) 68 | 69 | /* second arg of ontop_fcontext() == data to be transferred */ 70 | movl 0x2c(%esp), %ecx 71 | 72 | /* pass data */ 73 | movl %ecx, 0x2c(%eax) 74 | 75 | /* third arg of ontop_fcontext() == ontop-function */ 76 | movl 0x30(%esp), %ecx 77 | 78 | /* restore ESP (pointing to context-data) from EDX */ 79 | movl %eax, %esp 80 | 81 | /* load NT_TIB into ECX */ 82 | movl %fs:(0x18), %edx 83 | 84 | /* restore fiber local storage */ 85 | popl %eax 86 | movl %eax, 0x10(%edx) 87 | 88 | /* restore current deallocation stack */ 89 | popl %eax 90 | movl %eax, 0xe0c(%edx) 91 | 92 | /* restore current stack limit */ 93 | popl %eax 94 | movl %eax, 0x08(%edx) 95 | 96 | /* restore current stack base */ 97 | popl %eax 98 | movl %eax, 0x04(%edx) 99 | 100 | /* restore current SEH exception list */ 101 | popl %eax 102 | movl %eax, (%edx) 103 | 104 | popl %edi /* save EDI */ 105 | popl %esi /* save ESI */ 106 | popl %ebx /* save EBX */ 107 | popl %ebp /* save EBP */ 108 | 109 | /* jump to context */ 110 | jmp *%ecx 111 | 112 | .section .drectve 113 | .ascii " -export:\"ontop_fcontext\"" 114 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/ontop_i386_ms_pe_masm.asm: -------------------------------------------------------------------------------- 1 | 2 | ; Copyright Oliver Kowalke 2009. 3 | ; Distributed under the Boost Software License, Version 1.0. 4 | ; (See accompanying file LICENSE_1_0.txt or copy at 5 | ; http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | ; --------------------------------------------------------------------------------- 8 | ; | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | ; --------------------------------------------------------------------------------- 10 | ; | 0h | 04h | 08h | 0ch | 010h | 014h | 018h | 01ch | 11 | ; --------------------------------------------------------------------------------- 12 | ; | fc_strg |fc_deallo| limit | base | fc_seh | EDI | ESI | EBX | 13 | ; --------------------------------------------------------------------------------- 14 | ; --------------------------------------------------------------------------------- 15 | ; | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | ; --------------------------------------------------------------------------------- 17 | ; | 020h | 024h | 028h | 02ch | 030h | 034h | 038h | 03ch | 18 | ; --------------------------------------------------------------------------------- 19 | ; | EBP | EIP | to | data | | EH NXT |SEH HNDLR| | 20 | ; --------------------------------------------------------------------------------- 21 | 22 | .386 23 | .XMM 24 | .model flat, c 25 | .code 26 | 27 | ontop_fcontext PROC BOOST_CONTEXT_EXPORT 28 | push ebp ; save EBP 29 | push ebx ; save EBX 30 | push esi ; save ESI 31 | push edi ; save EDI 32 | 33 | assume fs:nothing 34 | ; load NT_TIB into EDX 35 | mov edx, fs:[018h] 36 | assume fs:error 37 | 38 | ; load current SEH exception list 39 | mov eax, [edx] 40 | push eax 41 | 42 | ; load current stack base 43 | mov eax, [edx+04h] 44 | push eax 45 | 46 | ; load current stack limit 47 | mov eax, [edx+08h] 48 | push eax 49 | 50 | ; load current deallocation stack 51 | mov eax, [edx+0e0ch] 52 | push eax 53 | 54 | ; load fiber local storage 55 | mov eax, [edx+010h] 56 | push eax 57 | 58 | ; store ESP (pointing to context-data) in ECX 59 | mov ecx, esp 60 | 61 | ; first arg of ontop_fcontext() == fcontext to jump to 62 | mov eax, [esp+028h] 63 | 64 | ; pass parent fcontext_t 65 | mov [eax+028h], ecx 66 | 67 | ; second arg of ontop_fcontext() == data to be transferred 68 | mov ecx, [esp+02ch] 69 | 70 | ; pass data 71 | mov [eax+02ch], ecx 72 | 73 | ; third arg of ontop_fcontext() == ontop-function 74 | mov ecx, [esp+030h] 75 | 76 | ; restore ESP (pointing to context-data) from EAX 77 | mov esp, eax 78 | 79 | assume fs:nothing 80 | ; load NT_TIB into EDX 81 | mov edx, fs:[018h] 82 | assume fs:error 83 | 84 | ; restore fiber local storage 85 | pop eax 86 | mov [edx+010h], eax 87 | 88 | ; restore current deallocation stack 89 | pop eax 90 | mov [edx+0e0ch], eax 91 | 92 | ; restore current stack limit 93 | pop eax 94 | mov [edx+08h], eax 95 | 96 | ; restore current stack base 97 | pop eax 98 | mov [edx+04h], eax 99 | 100 | ; restore current SEH exception list 101 | pop eax 102 | mov [edx], eax 103 | 104 | pop edi ; save EDI 105 | pop esi ; save ESI 106 | pop ebx ; save EBX 107 | pop ebp ; save EBP 108 | 109 | ; jump to context 110 | jmp ecx 111 | ontop_fcontext ENDP 112 | END 113 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/ontop_i386_sysv_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /***************************************************************************************** 9 | * * 10 | * ----------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ----------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ----------------------------------------------------------------------------------- * 15 | * | EDI | ESI | EBX | EBP | EIP | hidden | to | data | * 16 | * ----------------------------------------------------------------------------------- * 17 | * * 18 | *****************************************************************************************/ 19 | 20 | .text 21 | .globl ontop_fcontext 22 | .align 2 23 | .type ontop_fcontext,@function 24 | ontop_fcontext: 25 | pushl %ebp /* save EBP */ 26 | pushl %ebx /* save EBX */ 27 | pushl %esi /* save ESI */ 28 | pushl %edi /* save EDI */ 29 | 30 | /* store fcontext_t in ECX */ 31 | movl %esp, %ecx 32 | 33 | /* first arg of ontop_fcontext() == fcontext to jump to */ 34 | movl 0x18(%esp), %eax 35 | 36 | /* pass parent fcontext_t */ 37 | movl %ecx, 0x18(%eax) 38 | 39 | /* second arg of ontop_fcontext() == data to be transferred */ 40 | movl 0x1c(%esp), %ecx 41 | 42 | /* pass data */ 43 | movl %ecx, 0x1c(%eax) 44 | 45 | /* third arg of ontop_fcontext() == ontop-function */ 46 | movl 0x20(%esp), %ecx 47 | 48 | /* restore ESP (pointing to context-data) from EDX */ 49 | movl %eax, %esp 50 | 51 | popl %edi /* restore EDI */ 52 | popl %esi /* restore ESI */ 53 | popl %ebx /* restore EBX */ 54 | popl %ebp /* restore EBP */ 55 | 56 | /* jump to context */ 57 | jmp *%ecx 58 | .size ontop_fcontext,.-ontop_fcontext 59 | 60 | /* Mark that we don't need executable stack. */ 61 | .section .note.GNU-stack,"",%progbits 62 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/ontop_i386_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /***************************************************************************************** 9 | * * 10 | * ----------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ----------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ----------------------------------------------------------------------------------- * 15 | * | EDI | ESI | EBX | EBP | EIP | hidden | to | data | * 16 | * ----------------------------------------------------------------------------------- * 17 | * * 18 | *****************************************************************************************/ 19 | 20 | .text 21 | .globl _ontop_fcontext 22 | .align 2 23 | _ontop_fcontext: 24 | pushl %ebp /* save EBP */ 25 | pushl %ebx /* save EBX */ 26 | pushl %esi /* save ESI */ 27 | pushl %edi /* save EDI */ 28 | 29 | /* store fcontext_t in ECX */ 30 | movl %esp, %ecx 31 | 32 | /* first arg of ontop_fcontext() == fcontext to jump to */ 33 | movl 0x18(%esp), %eax 34 | 35 | /* pass parent fcontext_t */ 36 | movl %ecx, 0x18(%eax) 37 | 38 | /* second arg of ontop_fcontext() == data to be transferred */ 39 | movl 0x1c(%esp), %ecx 40 | 41 | /* pass data */ 42 | movl %ecx, 0x1c(%eax) 43 | 44 | /* third arg of ontop_fcontext() == ontop-function */ 45 | movl 0x20(%esp), %ecx 46 | 47 | /* restore ESP (pointing to context-data) from EDX */ 48 | movl %eax, %esp 49 | 50 | popl %edi /* restore EDI */ 51 | popl %esi /* restore ESI */ 52 | popl %ebx /* restore EBX */ 53 | popl %ebp /* restore EBP */ 54 | 55 | /* jump to context */ 56 | jmp *%ecx 57 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/ontop_i386_x86_64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__i386__) 11 | #include "ontop_i386_sysv_macho_gas.S" 12 | #elif defined(__x86_64__) 13 | #include "ontop_x86_64_sysv_macho_gas.S" 14 | #else 15 | #error "No arch's" 16 | #endif 17 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/ontop_mips32_o32_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 14 | * ------------------------------------------------- * 15 | * | S0 | S1 | S2 | S3 | S4 | S5 | S6 | S7 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 21 | * ------------------------------------------------- * 22 | * | FP |hiddn| RA | PC | GP | FCTX| DATA| | * 23 | * ------------------------------------------------- * 24 | * * 25 | * *****************************************************/ 26 | 27 | .text 28 | .globl ontop_fcontext 29 | .align 2 30 | .type ontop_fcontext,@function 31 | .ent ontop_fcontext 32 | ontop_fcontext: 33 | # reserve space on stack 34 | addiu $sp, $sp, -112 35 | 36 | sw $s0, ($sp) # save S0 37 | sw $s1, 4($sp) # save S1 38 | sw $s2, 8($sp) # save S2 39 | sw $s3, 12($sp) # save S3 40 | sw $s4, 16($sp) # save S4 41 | sw $s5, 20($sp) # save S5 42 | sw $s6, 24($sp) # save S6 43 | sw $s7, 28($sp) # save S7 44 | sw $fp, 32($sp) # save FP 45 | sw $a0, 36($sp) # save hidden, address of returned transfer_t 46 | sw $ra, 40($sp) # save RA 47 | sw $ra, 44($sp) # save RA as PC 48 | 49 | # store SP (pointing to context-data) in A0 50 | move $a0, $sp 51 | 52 | # restore SP (pointing to context-data) from A1 53 | move $sp, $a1 54 | 55 | lw $s0, ($sp) # restore S0 56 | lw $s1, 4($sp) # restore S1 57 | lw $s2, 8($sp) # restore S2 58 | lw $s3, 12($sp) # restore S3 59 | lw $s4, 16($sp) # restore S4 60 | lw $s5, 20($sp) # restore S5 61 | lw $s6, 24($sp) # restore S6 62 | lw $s7, 28($sp) # restore S7 63 | lw $fp, 32($sp) # restore FP 64 | lw $t0, 36($sp) # restore hidden, address of returned transfer_t 65 | lw $ra, 40($sp) # restore RA 66 | 67 | # load PC 68 | lw $t9, 44($sp) 69 | 70 | # adjust stack 71 | addiu $sp, $sp, 112 72 | 73 | # return transfer_t from jump 74 | sw $a0, ($t0) # fctx of transfer_t 75 | sw $a2, 4($t0) # data of transfer_t 76 | # pass transfer_t as first arg in context function 77 | # A0 == hidden, A1 == fctx, A2 == data 78 | move $a1, $a0 79 | move $a0, $t0 80 | 81 | # jump to context 82 | jr $a3 83 | .end ontop_fcontext 84 | .size ontop_fcontext, .-ontop_fcontext 85 | 86 | /* Mark that we don't need executable stack. */ 87 | .section .note.GNU-stack,"",%progbits 88 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/ontop_ppc32_ppc64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__ppc__) 11 | #include "ontop_ppc32_sysv_macho_gas.S" 12 | #elif defined(__ppc64__) 13 | #include "ontop_ppc64_sysv_macho_gas.S" 14 | #else 15 | #error "No arch's" 16 | #endif 17 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/ontop_ppc32_sysv_xcoff_gas.S: -------------------------------------------------------------------------------- 1 | .globl .ontop_fcontext 2 | .globl ontop_fcontext[DS] 3 | .align 2 4 | .csect ontop_fcontext[DS] 5 | ontop_fcontext: 6 | .long .ontop_fcontext 7 | .ontop_fcontext: 8 | # reserve space on stack 9 | subi 1, 1, 92 10 | 11 | stw 13, 0(1) # save R13 12 | stw 14, 4(1) # save R14 13 | stw 15, 8(1) # save R15 14 | stw 16, 12(1) # save R16 15 | stw 17, 16(1) # save R17 16 | stw 18, 20(1) # save R18 17 | stw 19, 24(1) # save R19 18 | stw 20, 28(1) # save R20 19 | stw 21, 32(1) # save R21 20 | stw 22, 36(1) # save R22 21 | stw 23, 40(1) # save R23 22 | stw 24, 44(1) # save R24 23 | stw 25, 48(1) # save R25 24 | stw 26, 52(1) # save R26 25 | stw 27, 56(1) # save R27 26 | stw 28, 60(1) # save R28 27 | stw 29, 64(1) # save R29 28 | stw 30, 68(1) # save R30 29 | stw 31, 72(1) # save R31 30 | stw 3, 76(1) # save hidden 31 | 32 | # save CR 33 | mfcr 0 34 | stw 0, 80(1) 35 | # save LR 36 | mflr 0 37 | stw 0, 84(1) 38 | # save LR as PC 39 | stw 0, 88(1) 40 | 41 | # store RSP (pointing to context-data) in R6 42 | mr 7, 1 43 | 44 | # restore RSP (pointing to context-data) from R4 45 | mr 1, 4 46 | 47 | lwz 13, 0(1) # restore R13 48 | lwz 14, 4(1) # restore R14 49 | lwz 15, 8(1) # restore R15 50 | lwz 16, 12(1) # restore R16 51 | lwz 17, 16(1) # restore R17 52 | lwz 18, 20(1) # restore R18 53 | lwz 19, 24(1) # restore R19 54 | lwz 20, 28(1) # restore R20 55 | lwz 21, 32(1) # restore R21 56 | lwz 22, 36(1) # restore R22 57 | lwz 23, 40(1) # restore R23 58 | lwz 24, 44(1) # restore R24 59 | lwz 25, 48(1) # restore R25 60 | lwz 26, 52(1) # restore R26 61 | lwz 27, 56(1) # restore R27 62 | lwz 28, 60(1) # restore R28 63 | lwz 29, 64(1) # restore R29 64 | lwz 30, 68(1) # restore R30 65 | lwz 31, 72(1) # restore R31 66 | lwz 4, 76(1) # restore hidden 67 | 68 | # restore CR 69 | lwz 0, 80(1) 70 | mtcr 0 71 | # restore LR 72 | lwz 0, 84(1) 73 | mtlr 0 74 | # ignore PC 75 | 76 | # adjust stack 77 | addi 1, 1, 92 78 | 79 | # return transfer_t 80 | stw 7, 0(3) 81 | stw 5, 4(3) 82 | 83 | # restore CTR 84 | mtctr 6 85 | 86 | # jump to context 87 | bctr 88 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/ontop_ppc64_sysv_xcoff_gas.S: -------------------------------------------------------------------------------- 1 | .align 2 2 | .globl .jump_fcontext 3 | .jump_fcontext: 4 | # reserve space on stack 5 | subi 1, 1, 184 6 | 7 | std 13, 0(1) # save R13 8 | std 14, 8(1) # save R14 9 | std 15, 16(1) # save R15 10 | std 16, 24(1) # save R16 11 | std 17, 32(1) # save R17 12 | std 18, 40(1) # save R18 13 | std 19, 48(1) # save R19 14 | std 20, 56(1) # save R20 15 | std 21, 64(1) # save R21 16 | std 22, 72(1) # save R22 17 | std 23, 80(1) # save R23 18 | std 24, 88(1) # save R24 19 | std 25, 96(1) # save R25 20 | std 26, 104(1) # save R26 21 | std 27, 112(1) # save R27 22 | std 29, 120(1) # save R28 23 | std 29, 128(1) # save R29 24 | std 30, 136(1) # save R30 25 | std 31, 144(1) # save R31 26 | std 3, 152(1) # save hidden 27 | 28 | # save CR 29 | mfcr 0 30 | std 0, 160(1) 31 | # save LR 32 | mflr 0 33 | std 0, 168(1) 34 | # save LR as PC 35 | std 0, 176(1) 36 | 37 | # store RSP (pointing to context-data) in R7 38 | mr 7, 1 39 | 40 | # restore RSP (pointing to context-data) from R4 41 | mr 1, 4 42 | 43 | ld 13, 0(1) # restore R13 44 | ld 14, 8(1) # restore R14 45 | ld 15, 16(1) # restore R15 46 | ld 16, 24(1) # restore R16 47 | ld 17, 32(1) # restore R17 48 | ld 18, 40(1) # restore R18 49 | ld 19, 48(1) # restore R19 50 | ld 20, 56(1) # restore R20 51 | ld 21, 64(1) # restore R21 52 | ld 22, 72(1) # restore R22 53 | ld 23, 80(1) # restore R23 54 | ld 24, 88(1) # restore R24 55 | ld 25, 96(1) # restore R25 56 | ld 26, 104(1) # restore R26 57 | ld 27, 112(1) # restore R27 58 | ld 28, 120(1) # restore R28 59 | ld 29, 128(1) # restore R29 60 | ld 30, 136(1) # restore R30 61 | ld 31, 144(1) # restore R31 62 | ld 4, 152(1) # restore hidden 63 | 64 | # restore CR 65 | ld 0, 160(1) 66 | mtcr 0 67 | # restore LR 68 | ld 0, 168(1) 69 | mtlr 0 70 | # ignore PC 71 | 72 | # adjust stack 73 | addi 1, 1, 184 74 | 75 | # return transfer_t 76 | std 7, 0(4) 77 | std 5, 8(4) 78 | 79 | # restore CTR 80 | mtctr 6 81 | 82 | # jump to context 83 | bctr 84 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/ontop_x86_64_sysv_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /**************************************************************************************** 9 | * * 10 | * ---------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ---------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ---------------------------------------------------------------------------------- * 15 | * | R12 | R13 | R14 | R15 | * 16 | * ---------------------------------------------------------------------------------- * 17 | * ---------------------------------------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ---------------------------------------------------------------------------------- * 20 | * | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | * 21 | * ---------------------------------------------------------------------------------- * 22 | * | RBX | RBP | RIP | EXIT | * 23 | * ---------------------------------------------------------------------------------- * 24 | * * 25 | ****************************************************************************************/ 26 | 27 | .text 28 | .globl ontop_fcontext 29 | .type ontop_fcontext,@function 30 | .align 16 31 | ontop_fcontext: 32 | pushq %rbp /* save RBP */ 33 | pushq %rbx /* save RBX */ 34 | pushq %r15 /* save R15 */ 35 | pushq %r14 /* save R14 */ 36 | pushq %r13 /* save R13 */ 37 | pushq %r12 /* save R12 */ 38 | 39 | /* store RSP (pointing to context-data) in RAX */ 40 | movq %rsp, %rax 41 | 42 | /* restore RSP (pointing to context-data) from RDI */ 43 | movq %rdi, %rsp 44 | 45 | popq %r12 /* restrore R12 */ 46 | popq %r13 /* restrore R13 */ 47 | popq %r14 /* restrore R14 */ 48 | popq %r15 /* restrore R15 */ 49 | popq %rbx /* restrore RBX */ 50 | popq %rbp /* restrore RBP */ 51 | 52 | /* preserve ontop-function in R8 */ 53 | movq %rdx, %r8 54 | 55 | /* return transfer_t from jump */ 56 | /* RAX == fctx, RDX == data */ 57 | movq %rsi, %rdx 58 | /* pass transfer_t as first arg in context function */ 59 | /* RDI == fctx, RSI == data */ 60 | movq %rax, %rdi 61 | 62 | /* keep return-address on stack */ 63 | 64 | /* indirect jump to context */ 65 | jmp *%r8 66 | .size ontop_fcontext,.-ontop_fcontext 67 | 68 | /* Mark that we don't need executable stack. */ 69 | .section .note.GNU-stack,"",%progbits 70 | -------------------------------------------------------------------------------- /3rdparty/sx/asm/ontop_x86_64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /**************************************************************************************** 9 | * * 10 | * ---------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ---------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ---------------------------------------------------------------------------------- * 15 | * | R12 | R13 | R14 | R15 | * 16 | * ---------------------------------------------------------------------------------- * 17 | * ---------------------------------------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ---------------------------------------------------------------------------------- * 20 | * | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | * 21 | * ---------------------------------------------------------------------------------- * 22 | * | RBX | RBP | RIP | EXIT | * 23 | * ---------------------------------------------------------------------------------- * 24 | * * 25 | ****************************************************************************************/ 26 | 27 | .text 28 | .globl _ontop_fcontext 29 | .align 8 30 | _ontop_fcontext: 31 | pushq %rbp /* save RBP */ 32 | pushq %rbx /* save RBX */ 33 | pushq %r15 /* save R15 */ 34 | pushq %r14 /* save R14 */ 35 | pushq %r13 /* save R13 */ 36 | pushq %r12 /* save R12 */ 37 | 38 | /* store RSP (pointing to context-data) in RAX */ 39 | movq %rsp, %rax 40 | 41 | /* restore RSP (pointing to context-data) from RDI */ 42 | movq %rdi, %rsp 43 | 44 | popq %r12 /* restrore R12 */ 45 | popq %r13 /* restrore R13 */ 46 | popq %r14 /* restrore R14 */ 47 | popq %r15 /* restrore R15 */ 48 | popq %rbx /* restrore RBX */ 49 | popq %rbp /* restrore RBP */ 50 | 51 | /* preserve ontop-function in R8 */ 52 | movq %rdx, %r8 53 | 54 | /* return transfer_t from jump */ 55 | /* RAX == fctx, RDX == data */ 56 | movq %rsi, %rdx 57 | /* pass transfer_t as first arg in context function */ 58 | /* RDI == fctx, RSI == data */ 59 | movq %rax, %rdi 60 | 61 | /* keep return-address on stack */ 62 | 63 | /* indirect jump to context */ 64 | jmp *%r8 65 | -------------------------------------------------------------------------------- /3rdparty/sx/include/compat/freebsd/alloca.h: -------------------------------------------------------------------------------- 1 | #if defined(__GLIBC__) 2 | # include_next 3 | #else 4 | # include 5 | #endif 6 | -------------------------------------------------------------------------------- /3rdparty/sx/include/compat/freebsd/dirent.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /3rdparty/sx/include/compat/freebsd/malloc.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /3rdparty/sx/include/compat/freebsd/signal.h: -------------------------------------------------------------------------------- 1 | #if defined(__GLIBC__) 2 | # include_next 3 | #else 4 | # include 5 | #endif 6 | -------------------------------------------------------------------------------- /3rdparty/sx/include/compat/ios/malloc.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /3rdparty/sx/include/compat/mingw/alloca.h: -------------------------------------------------------------------------------- 1 | #ifndef MINGW32_ALLOCA_H_HEADER_GUARD 2 | #define MINGW32_ALLOCA_H_HEADER_GUARD 3 | 4 | #include 5 | 6 | #endif // MINGW32_ALLOCA_H_HEADER_GUARD 7 | -------------------------------------------------------------------------------- /3rdparty/sx/include/compat/mingw/dirent.h: -------------------------------------------------------------------------------- 1 | // BK - MinGW dirent is super broken, using MSVC compatibility one... 2 | #ifndef _DIRENT_H_ 3 | # define _DIRENT_H_ 4 | # include "../msvc/dirent.h" 5 | #endif // _DIRENT_H_ 6 | -------------------------------------------------------------------------------- /3rdparty/sx/include/compat/mingw/sal.h: -------------------------------------------------------------------------------- 1 | #include "salieri.h" 2 | -------------------------------------------------------------------------------- /3rdparty/sx/include/compat/mingw/specstrings_strict.h: -------------------------------------------------------------------------------- 1 | #define __reserved 2 | -------------------------------------------------------------------------------- /3rdparty/sx/include/compat/mingw/specstrings_undef.h: -------------------------------------------------------------------------------- 1 | #undef __reserved 2 | 3 | -------------------------------------------------------------------------------- /3rdparty/sx/include/compat/msvc/alloca.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /3rdparty/sx/include/compat/msvc/stdbool.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * 3 | * Copyright 2007-2010 VMware, Inc. 4 | * All Rights Reserved. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sub license, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 17 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 18 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 20 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | * 22 | * The above copyright notice and this permission notice (including the 23 | * next paragraph) shall be included in all copies or substantial portions 24 | * of the Software. 25 | * 26 | **************************************************************************/ 27 | 28 | #ifndef _STDBOOL_H_ 29 | #define _STDBOOL_H_ 30 | 31 | #ifndef __cplusplus 32 | 33 | #define false 0 34 | #define true 1 35 | #define bool _Bool 36 | 37 | /* For compilers that don't have the builtin _Bool type. */ 38 | #if ((defined(_MSC_VER) && _MSC_VER < 1800) || \ 39 | (defined __GNUC__&& __STDC_VERSION__ < 199901L && __GNUC__ < 3)) && !defined(_lint) 40 | typedef unsigned char _Bool; 41 | #endif 42 | 43 | #endif /* !__cplusplus */ 44 | 45 | #define __bool_true_false_are_defined 1 46 | 47 | #endif /* !_STDBOOL_H_ */ 48 | -------------------------------------------------------------------------------- /3rdparty/sx/include/compat/osx/malloc.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | -------------------------------------------------------------------------------- /3rdparty/sx/include/sx/bheap.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/sx#license-bsd-2-clause 4 | // 5 | // bheap.h - v1.0 - Binary heap implmenetation 6 | // I discovered this algorithm when reading Randy Paul's 7 | // [blog](http://www.randygaul.net/) Which is a partially sorted binary tree and is 8 | // used for pulling up minimum or maximum values at a time 9 | // Reference: https://en.wikipedia.org/wiki/Binary_heap 10 | // 11 | // API: 12 | // sx_bheap_create create binary heap object with a fixed capacity 13 | // sx_bheap_destroy destroy binary heap object 14 | // sx_bheap_push_min Push MIN value to binary heap, 'user' is a user-defined pointer 15 | // sx_bheap_push_max Push MAX value to binary heap 16 | // sx_bheap_pop_min Pop MIN value from binary heap 17 | // sx_bheap_pop_max Pop MAX value from binary heap 18 | // sx_bheap_clear Clears the binary heap 19 | // sx_bheap_empty Returns true if binary heap is empty 20 | // 21 | // NOTE: Only use either XXX_min or XXX_max APIs for a binary heap, don't mix them 22 | // use sx_bheap_push_max with sx_bheap_pop_max, or sx_bheap_push_min with sx_bheap_pop_max 23 | // 24 | #pragma once 25 | 26 | #include 27 | #include "macros.h" 28 | 29 | typedef struct sx_alloc sx_alloc; 30 | 31 | typedef struct sx_bheap_item { 32 | int key; 33 | void* user; 34 | } sx_bheap_item; 35 | 36 | typedef struct sx_bheap { 37 | sx_bheap_item* items; 38 | int count; 39 | int capacity; 40 | } sx_bheap; 41 | 42 | SX_API sx_bheap* sx_bheap_create(const sx_alloc* alloc, int capacity); 43 | SX_API void sx_bheap_destroy(sx_bheap* bh, const sx_alloc* alloc); 44 | 45 | SX_API void sx_bheap_push_min(sx_bheap* bh, int key, void* user); 46 | SX_API sx_bheap_item sx_bheap_pop_min(sx_bheap* bh); 47 | 48 | SX_API void sx_bheap_push_max(sx_bheap* bh, int key, void* user); 49 | SX_API sx_bheap_item sx_bheap_pop_max(sx_bheap* bh); 50 | 51 | SX_API void sx_bheap_clear(sx_bheap* bh); 52 | SX_API bool sx_bheap_empty(sx_bheap* bh); 53 | 54 | -------------------------------------------------------------------------------- /3rdparty/sx/include/sx/cmdline.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/sx#license-bsd-2-clause 4 | // 5 | // cmdline.h - Command line parser 6 | // This is actually a very thin wrapper around getopt 7 | // Source: https://github.com/wc-duck/getopt 8 | // Example: https://github.com/wc-duck/getopt/blob/master/example/example.cpp 9 | // 10 | #pragma once 11 | 12 | #include "macros.h" 13 | typedef struct sx_alloc sx_alloc; 14 | 15 | /* 16 | Enum: sx_cmdline_optype 17 | Types of supported options by system. 18 | 19 | SX_CMDLINE_OPTYPE_NO_ARG - The option can have no argument 20 | SX_CMDLINE_OPTYPE_REQUIRED - The option requires an argument (--option=arg, -o arg) 21 | SX_CMDLINE_OPTYPE_OPTIONAL - The option-argument is optional 22 | 23 | SX_CMDLINE_OPTYPE_FLAG_SET - The option is a flag and value will be set to flag 24 | SX_CMDLINE_OPTYPE_FLAG_AND - The option is a flag and value will be and:ed with flag 25 | SX_CMDLINE_OPTYPE_FLAG_OR - The option is a flag and value will be or:ed with flag 26 | */ 27 | typedef enum sx_cmdline_optype { 28 | SX_CMDLINE_OPTYPE_NO_ARG, 29 | SX_CMDLINE_OPTYPE_REQUIRED, 30 | SX_CMDLINE_OPTYPE_OPTIONAL, 31 | SX_CMDLINE_OPTYPE_FLAG_SET, 32 | SX_CMDLINE_OPTYPE_FLAG_AND, 33 | SX_CMDLINE_OPTYPE_FLAG_OR 34 | } sx_cmdline_optype; 35 | 36 | #define SX_CMDLINE_OPT_END \ 37 | { 0, 0, SX_CMDLINE_OPTYPE_NO_ARG, 0, 0, 0, 0 } 38 | 39 | /* 40 | Struct: sx_cmdline_opt 41 | Option in system. 42 | 43 | Members: 44 | name - Long name of argument, set to NULL if only short name is valid. 45 | name_short - Short name of argument, set to 0 if only long name is valid. 46 | type - Type of option, see . 47 | flag - Pointer to flag to set if option is of flag-type, set to null NULL if option is 48 | not of flag-type. value - If option is of flag-type, this value will be set/and:ed/or:ed to 49 | the flag, else it will be returned from GetOpt when option is found. desc - Description of 50 | option. value_desc - Short description of valid values to the option, will only be used when 51 | generating help-text. example: "--my_option=" 52 | */ 53 | typedef struct sx_cmdline_opt_s { 54 | const char* name; 55 | int name_short; 56 | sx_cmdline_optype type; 57 | int* flag; 58 | int value; 59 | const char* desc; 60 | const char* value_desc; 61 | } sx_cmdline_opt; 62 | 63 | typedef struct getopt_context sx_cmdline_context; 64 | 65 | SX_API sx_cmdline_context* sx_cmdline_create_context(const sx_alloc* alloc, int argc, 66 | const char** argv, const sx_cmdline_opt* opts); 67 | SX_API void sx_cmdline_destroy_context(sx_cmdline_context* ctx, const sx_alloc* alloc); 68 | SX_API int sx_cmdline_next(sx_cmdline_context* ctx, int* index, const char** arg); 69 | SX_API const char* sx_cmdline_create_help_string(sx_cmdline_context* ctx, char* buffer, 70 | unsigned int buffer_size); 71 | -------------------------------------------------------------------------------- /3rdparty/sx/include/sx/ini.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/sx#license-bsd-2-clause 4 | // 5 | // 6 | // ini.h - v1.0 - Ini file parser/writer by Mattias Gustavsson 7 | // Reference: https://github.com/mattiasgustavsson/libs/blob/master/ini.h 8 | // 9 | #pragma once 10 | 11 | #include "macros.h" 12 | 13 | typedef struct sx_alloc sx_alloc; 14 | typedef struct ini_t sx_ini; 15 | 16 | SX_API sx_ini* sx_ini_create(const sx_alloc* alloc); 17 | SX_API sx_ini* sx_ini_load(const char* data, const sx_alloc* alloc); 18 | SX_API int sx_ini_save(sx_ini const* ini, char* data, int size); 19 | SX_API void sx_ini_destroy(sx_ini* ini); 20 | 21 | SX_API int sx_ini_section_count(sx_ini const* ini); 22 | SX_API char const* sx_ini_section_name(sx_ini const* ini, int section); 23 | 24 | SX_API int sx_ini_property_count(sx_ini const* ini, int section); 25 | SX_API char const* sx_ini_property_name(sx_ini const* ini, int section, int property); 26 | SX_API char const* sx_ini_property_value(sx_ini const* ini, int section, int property); 27 | 28 | SX_API int sx_ini_find_section(sx_ini const* ini, char const* name, int name_length); 29 | SX_API int sx_ini_find_property(sx_ini const* ini, int section, char const* name, int name_length); 30 | 31 | SX_API int sx_ini_section_add(sx_ini* ini, char const* name, int length); 32 | SX_API void sx_ini_property_add(sx_ini* ini, int section, char const* name, int name_length, 33 | char const* value, int value_length); 34 | SX_API void sx_ini_section_remove(sx_ini* ini, int section); 35 | SX_API void sx_ini_property_remove(sx_ini* ini, int section, int property); 36 | 37 | SX_API void sx_ini_section_name_set(sx_ini* ini, int section, char const* name, int length); 38 | SX_API void sx_ini_property_name_set(sx_ini* ini, int section, int property, char const* name, 39 | int length); 40 | SX_API void sx_ini_property_value_set(sx_ini* ini, int section, int property, char const* value, 41 | int length); 42 | -------------------------------------------------------------------------------- /3rdparty/sx/include/sx/lin-alloc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/sx#license-bsd-2-clause 4 | // 5 | // lin-alloc.h - v1.0 - Generic linear allocator 6 | // 7 | // sx_linalloc allocates memory from a pre-allocated buffer in a linear fashion 8 | // Pros: Fastest allocator, very low fragmentation 9 | // Cons: Does not have Free operation, only grows 10 | // 11 | // Usage: 12 | // struct sx_linalloc alloc; 13 | // sx_linalloc_init(&alloc, preallocated_mem, preallocated_mem_size); 14 | // ... 15 | // Pass 'alloc.alloc' to anywhere you want and use sx_alloc macros 16 | // sx_linalloc_reset(&alloc); // resets the buffer to zero 17 | // alloc.peak -> check the maximum growed size 18 | // 19 | // NOTE: realloc functionally of this allocator is stack based 20 | // so when we do 'realloc' on the same pointer sequentially, the buffer will just grow and no 21 | // new allocations is made 22 | // NOTE: there is a point here for alignment, you should not realloc the same pointer with 23 | // different alignments on each call 24 | // 25 | #pragma once 26 | 27 | #include "allocator.h" 28 | 29 | typedef struct sx_linalloc { 30 | sx_alloc alloc; 31 | uint8_t* ptr; 32 | int last_ptr_offset; 33 | int offset; 34 | int size; 35 | int peak; 36 | } sx_linalloc; 37 | 38 | SX_API void sx_linalloc_init(sx_linalloc* linalloc, void* ptr, int size); 39 | SX_API void sx_linalloc_reset(sx_linalloc* linalloc); 40 | 41 | #define sx_define_linalloc_onstack(_name, _size) \ 42 | uint8_t _name##_buff_[(_size)]; \ 43 | sx_linalloc _name; \ 44 | sx_linalloc_init(&(_name), _name##_buff_, (_size)) 45 | -------------------------------------------------------------------------------- /3rdparty/sx/include/sx/os.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/sx#license-bsd-2-clause 4 | // 5 | // os.h - v1.1.0 - Common portable OS related functions 6 | // 7 | #pragma once 8 | 9 | #include "sx.h" 10 | 11 | #if SX_PLATFORM_OSX 12 | # define SX_DLL_EXT ".dylib" 13 | #elif SX_PLATFORM_WINDOWS 14 | # define SX_DLL_EXT ".dll" 15 | #else 16 | # define SX_DLL_EXT ".so" 17 | #endif 18 | 19 | typedef enum sx_file_type { 20 | SX_FILE_TYPE_INVALID = 0, 21 | SX_FILE_TYPE_REGULAR, 22 | SX_FILE_TYPE_DIRECTORY 23 | } sx_file_type; 24 | 25 | typedef struct sx_file_info { 26 | sx_file_type type; 27 | uint64_t size; 28 | uint64_t last_modified; // time_t 29 | } sx_file_info; 30 | 31 | typedef struct sx_pinfo { 32 | union { 33 | uintptr_t linux_pid; 34 | void* win_process_handle; 35 | }; 36 | void* win_thread_handle; 37 | } sx_pinfo; 38 | 39 | SX_API int sx_os_minstacksz(); 40 | SX_API int sx_os_maxstacksz(); 41 | SX_API int sx_os_pagesz(); 42 | SX_API size_t sx_os_align_pagesz(size_t size); 43 | SX_API char sx_os_getch(); 44 | SX_API size_t sx_os_processmem(); 45 | SX_API void* sx_os_dlopen(const char* filepath); 46 | SX_API void sx_os_dlclose(void* handle); 47 | SX_API void* sx_os_dlsym(void* handle, const char* symbol); 48 | SX_API const char* sx_os_dlerr(); 49 | SX_API int sx_os_chdir(const char* path); 50 | SX_API void sx_os_sleep(int ms); 51 | SX_API sx_pinfo sx_os_exec(const char* const* argv); 52 | SX_API bool sx_os_copy(const char* src, const char* dest); 53 | SX_API bool sx_os_rename(const char* src, const char* dest); 54 | SX_API bool sx_os_del(const char* path, sx_file_type type); 55 | SX_API bool sx_os_mkdir(const char* path); 56 | 57 | SX_API char* sx_os_path_pwd(char* dst, int size); 58 | SX_API char* sx_os_path_abspath(char* dst, int size, const char* path); 59 | SX_API char* sx_os_path_unixpath(char* dst, int size, const char* path); 60 | SX_API char* sx_os_path_winpath(char* dst, int size, const char* path); 61 | SX_API char* sx_os_path_basename(char* dst, int size, const char* path); 62 | SX_API char* sx_os_path_dirname(char* dst, int size, const char* path); 63 | SX_API char* sx_os_path_splitext(char* ext, int ext_size, char* basename, int basename_size, 64 | const char* path); 65 | SX_API char* sx_os_path_ext(char* dst, int size, const char* path); 66 | SX_API char* sx_os_path_join(char* dst, int size, const char* path_a, const char* path_b); 67 | SX_API char* sx_os_path_normcase(char* dst, int size, const char* path); 68 | SX_API char* sx_os_path_normpath(char* dst, int size, const char* path); 69 | SX_API char* sx_os_path_relpath(char* dst, int size, const char* path, 70 | const char* start sx_default(NULL)); 71 | SX_API bool sx_os_path_exists(const char* path); 72 | SX_API bool sx_os_path_isfile(const char* path); 73 | SX_API bool sx_os_path_isdir(const char* path); 74 | SX_API char* sx_os_path_exepath(char* dst, int size); 75 | 76 | SX_API sx_file_info sx_os_stat(const char* filepath); 77 | 78 | SX_API int sx_os_numcores(); 79 | -------------------------------------------------------------------------------- /3rdparty/sx/include/sx/rng.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/sx#license-bsd-2-clause 4 | // 5 | // rng.h - v1.0 - Random number generator 6 | // Currently has PCG implementation 7 | // Source: http://www.pcg-random.org 8 | // 9 | // sx_rng_seed initialize and seed hash state 10 | // sx_rng_gen generates an integer number (0~UINT32_MAX) 11 | // sx_rng_gen_f generates an float number between 0 and 1 12 | // sx_rng_gen_irange generates an integer between the specified range 13 | // 14 | #pragma once 15 | 16 | #include 17 | #include "macros.h" 18 | 19 | typedef struct sx_rng { 20 | uint64_t state[2]; 21 | } sx_rng; 22 | 23 | SX_API void sx_rng_seed(sx_rng* rng, uint32_t seed); 24 | SX_API uint32_t sx_rng_gen(sx_rng* rng); 25 | SX_API float sx_rng_gen_f(sx_rng* rng); 26 | SX_API int sx_rng_gen_irange(sx_rng* rng, int _min, int _max); 27 | 28 | -------------------------------------------------------------------------------- /3rdparty/sx/include/sx/stack-alloc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/sx#license-bsd-2-clause 4 | // 5 | // stack-alloc: Generic stack allocator 6 | // 7 | // sx_stackalloc allocates memory from a pre-allocated buffer in a linear fashion 8 | // The difference between stack-alloc and lin-alloc is that stack-alloc have free operation but 9 | // with limitations (see below) 10 | // Suitable for operations that needs loading/unloading of temp memory blocks 11 | // 12 | // Pros: Very Fast allocator, very low fragmentation 13 | // Cons: You have to 'free' in the reverse order of your 'alloc' calls, to properly free the memory 14 | // limitation and will corrupt memory if not done properly. 15 | // 16 | // Usage: 17 | // struct sx_stackalloc salloc; 18 | // sx_stackalloc_init(&salloc, preallocated_mem, preallocated_mem_size); 19 | // ... 20 | // void* p1 = sx_malloc(&salloc.alloc, 18); 21 | // void* p2 = sx_malloc(&salloc.alloc, 18); 22 | // ... 23 | // sx_free(&salloc.alloc, p2); 24 | // sx_free(&salloc.alloc, p1); 25 | // alloc.peak -> check the maximum growed size 26 | // 27 | // NOTE: realloc functionally of this allocator is stack based 28 | // so when we do 'realloc' on the same pointer sequentially, the buffer will just grow and no 29 | // new allocations is made 30 | // BUT there is a point here for alignment, you should not realloc the same pointer with 31 | // different alignments on each call 32 | // 33 | 34 | #pragma once 35 | 36 | #include "allocator.h" 37 | 38 | typedef struct sx_stackalloc { 39 | sx_alloc alloc; 40 | uint8_t* ptr; 41 | int last_ptr_offset; 42 | int offset; 43 | int size; 44 | int peak; 45 | } sx_stackalloc; 46 | 47 | SX_API void sx_stackalloc_init(sx_stackalloc* stackalloc, void* ptr, int size); 48 | SX_API void sx_stackalloc_reset(sx_stackalloc* stackalloc); 49 | 50 | #define sx_define_stackalloc_onstack(_name, _size) \ 51 | uint8_t _name##_buff_[(_size)]; \ 52 | sx_stackalloc _name; \ 53 | sx_stackalloc_init(&(_name), _name##_buff_, (_size)) 54 | -------------------------------------------------------------------------------- /3rdparty/sx/include/sx/threads.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/sx#license-bsd-2-clause 4 | // 5 | // threads.h - v1.0 - Common portable multi-threading primitives 6 | // 7 | // sx_thread Portable thread 8 | // sx_tls Portable thread-local-storage which you can store a user_data per Tls 9 | // sx_mutex Portable OS mutex, use for long-time data locks, for short-time locks use 10 | // sx_lock_t in atomics.h 11 | // sx_sem Portable OS semaphore. 'post' increases the count. 'wait' waits on semaphore 12 | // if count is zero, 13 | // else decreases the count and continue 14 | // sx_signal Portable OS signals/events. simplified version of the semaphore, 15 | // where you 'wait' for signal to be triggered, then in another thread you 16 | // 'raise' it and 'wait' will continue 17 | // sx_queue_spsc Single producer/Single consumer self contained queue 18 | // 19 | #pragma once 20 | 21 | #include "sx.h" 22 | 23 | typedef struct sx_alloc sx_alloc; 24 | 25 | // Thread 26 | typedef struct sx__thread_s sx_thread; 27 | 28 | // Thread callback function 29 | typedef int(sx_thread_cb)(void* user_data1, void* user_data2); 30 | 31 | SX_API sx_thread* sx_thread_create(const sx_alloc* alloc, sx_thread_cb* callback, 32 | void* user_data1 sx_default(NULL), int stack_sz sx_default(0), 33 | const char* name sx_default(NULL), 34 | void* user_data2 sx_default(NULL)); 35 | SX_API int sx_thread_destroy(sx_thread* thrd, const sx_alloc* alloc); 36 | SX_API bool sx_thread_running(sx_thread* thrd); 37 | SX_API void sx_thread_setname(sx_thread* thrd, const char* name); 38 | SX_API void sx_thread_yield(); 39 | SX_API uint32_t sx_thread_tid(); 40 | 41 | // Tls data 42 | typedef void* sx_tls; 43 | 44 | SX_API sx_tls sx_tls_create(); 45 | SX_API void sx_tls_destroy(sx_tls tls); 46 | SX_API void sx_tls_set(sx_tls tls, void* data); 47 | SX_API void* sx_tls_get(sx_tls tls); 48 | 49 | // Mutex 50 | typedef struct sx_mutex_s { 51 | sx_align_decl(16, uint8_t) data[64]; 52 | } sx_mutex; 53 | 54 | SX_API void sx_mutex_init(sx_mutex* mutex); 55 | SX_API void sx_mutex_release(sx_mutex* mutex); 56 | SX_API void sx_mutex_lock(sx_mutex* mutex); 57 | SX_API void sx_mutex_unlock(sx_mutex* mutex); 58 | SX_API bool sx_mutex_trylock(sx_mutex* mutex); 59 | 60 | // Semaphore 61 | typedef struct sx_sem_s { 62 | sx_align_decl(16, uint8_t) data[128]; 63 | } sx_sem; 64 | 65 | SX_API void sx_semaphore_init(sx_sem* sem); 66 | SX_API void sx_semaphore_release(sx_sem* sem); 67 | SX_API void sx_semaphore_post(sx_sem* sem, int count sx_default(1)); 68 | SX_API bool sx_semaphore_wait(sx_sem* sem, int msecs sx_default(-1)); 69 | 70 | // Signal 71 | typedef struct sx_signal_s { 72 | sx_align_decl(16, uint8_t) data[128]; 73 | } sx_signal; 74 | 75 | SX_API void sx_signal_init(sx_signal* sig); 76 | SX_API void sx_signal_release(sx_signal* sig); 77 | SX_API void sx_signal_raise(sx_signal* sig); 78 | SX_API bool sx_signal_wait(sx_signal* sig, int msecs sx_default(-1)); 79 | 80 | // Lock-Free single-producer/single-consumer self-contained-data queue 81 | typedef struct sx_queue_spsc sx_queue_spsc; 82 | SX_API sx_queue_spsc* sx_queue_spsc_create(const sx_alloc* alloc, int item_sz, int capacity); 83 | SX_API void sx_queue_spsc_destroy(sx_queue_spsc* queue, const sx_alloc* alloc); 84 | SX_API bool sx_queue_spsc_produce(sx_queue_spsc* queue, const void* data); 85 | SX_API bool sx_queue_spsc_consume(sx_queue_spsc* queue, void* data); 86 | SX_API bool sx_queue_spsc_grow(sx_queue_spsc* queue, const sx_alloc* alloc); 87 | SX_API bool sx_queue_spsc_full(const sx_queue_spsc* queue); 88 | 89 | #define sx_queue_spsc_produce_and_grow(_queue, _data, _alloc) \ 90 | if (!sx_queue_spsc_produce((_queue), (_data))) { \ 91 | if (sx_queue_spsc_grow((_queue), (_alloc))) \ 92 | sx_queue_spsc_produce((_queue), (_data)); \ 93 | } 94 | -------------------------------------------------------------------------------- /3rdparty/sx/include/sx/timer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/sx#license-bsd-2-clause 4 | // 5 | // timer.h - v1.1 - portable high resolution timer 6 | // Implementation is sokol_time, just a thin wrapper 7 | // 8 | // void sx_tm_now(); 9 | // Call once before any other functions to initialize sokol_time 10 | // (this calls for instance QueryPerformanceFrequency on Windows) 11 | // 12 | // uint64_t sx_tm_now(); 13 | // Get current point in time in unspecified 'ticks'. The value that 14 | // is returned has no relation to the 'wall-clock' time and is 15 | // not in a specific time unit, it is only useful to compute 16 | // time differences. 17 | // 18 | // uint64_t sx_tm_diff(uint64_t new, uint64_t old); 19 | // Computes the time difference between new and old. This will always 20 | // return a positive, non-zero value. 21 | // 22 | // uint64_t sx_tm_since(uint64_t start); 23 | // Takes the current time, and returns the elapsed time since start 24 | // (this is a shortcut for "sx_tm_diff(sx_tm_now(), start)") 25 | // 26 | // uint64_t sx_tm_laptime(uint64_t* last_time); 27 | // This is useful for measuring frame time and other recurring 28 | // events. It takes the current time, returns the time difference 29 | // to the value in last_time, and stores the current time in 30 | // last_time for the next call. If the value in last_time is 0, 31 | // the return value will be zero (this usually happens on the 32 | // very first call). 33 | // 34 | // Use the following functions to convert a duration in ticks into 35 | // useful time units: 36 | 37 | // double sx_tm_sec(uint64_t ticks); 38 | // double sx_tm_ms(uint64_t ticks); 39 | // double sx_tm_us(uint64_t ticks); 40 | // double sx_tm_ns(uint64_t ticks); 41 | // Converts a tick value into seconds, milliseconds, microseconds 42 | // or nanoseconds. Note that not all platforms will have nanosecond 43 | // or even microsecond precision. 44 | // 45 | // For more information and examples: https://github.com/floooh/sokol 46 | // 47 | #pragma once 48 | 49 | #include "macros.h" 50 | #include 51 | 52 | SX_API void sx_tm_init(); 53 | SX_API uint64_t sx_tm_now(); 54 | SX_API uint64_t sx_tm_diff(uint64_t new_ticks, uint64_t old_ticks); 55 | SX_API uint64_t sx_tm_since(uint64_t start_ticks); 56 | SX_API uint64_t sx_tm_laptime(uint64_t* last_ticks); 57 | 58 | SX_API double sx_tm_sec(uint64_t ticks); 59 | SX_API double sx_tm_ms(uint64_t ticks); 60 | SX_API double sx_tm_us(uint64_t ticks); 61 | SX_API double sx_tm_ns(uint64_t ticks); 62 | 63 | 64 | // Version history 65 | // 1.0 initial release 66 | // 1.1 renamed sx_tm_init to sx_tm_now 67 | // moved sokol_time.h to the .C file and wraped the functions 68 | // -------------------------------------------------------------------------------- /3rdparty/sx/include/sx/tlsf-alloc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/sx#license-bsd-2-clause 4 | // 5 | // tlsf-alloc.h - v1.0 - Two-Level Segregated Fit memory allocator implementation 6 | // Reference: http://www.gii.upv.es/tlsf/main/docs 7 | // Implementation by Matthew Conte: https://github.com/mattconte/tlsf 8 | // 9 | // generic allocator suitable for allocating/deallocating memory blocks in various sizes, 10 | // with constant time malloc and free O(1) 11 | // This is a wrapper for tlsf implementation around sx_alloc object 12 | // sx_alloc::user_data is actually tlsf_t handle 13 | // 14 | // Usage: 15 | // sx_alloc tlsf; 16 | // char buff[64*1024]; 17 | // sx_tlsfalloc_init(&tlsf, buff, sizeof(buff)); // Create with one 64k pool on stack 18 | // do_something_with_alloc(&tlsf); 19 | // sx_tlsfalloc_release(&tlsf); 20 | // 21 | #pragma once 22 | 23 | #include "sx.h" 24 | 25 | typedef struct sx_alloc sx_alloc; 26 | typedef void* sx_tlsf_pool_t; 27 | 28 | SX_API bool sx_tlsfalloc_init(sx_alloc* tlsf, void* mem, int size); 29 | SX_API void sx_tlsfalloc_release(sx_alloc* tlsf); 30 | 31 | // Pool management, additional pools 32 | SX_API sx_tlsf_pool_t sx_tlsfalloc_add_pool(sx_alloc* tlsf, void* mem, int size); 33 | SX_API void sx_tlsfalloc_remove_pool(sx_alloc* tlsf, sx_tlsf_pool_t pool); 34 | SX_API sx_tlsf_pool_t sx_tlsfalloc_get_pool(sx_alloc* tlsf); 35 | 36 | // Debug 37 | typedef void(sx_tlsfalloc_walk_cb)(void* ptr, size_t size, int used, void* user); 38 | SX_API void sx_tlsfalloc_walk_pool(sx_tlsf_pool_t pool, sx_tlsfalloc_walk_cb* walker, void* user); 39 | SX_API bool sx_tlsfalloc_check(sx_alloc* tlsf); 40 | SX_API bool sx_tlsfalloc_check_pool(sx_tlsf_pool_t pool); 41 | -------------------------------------------------------------------------------- /3rdparty/sx/include/sx/virtual-alloc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/sx#license-bsd-2-clause 4 | // 5 | // virtual-alloc.h - v1.0 - Virtual memory allocator 6 | // 7 | // Uses OS specific virtual memory functions 8 | // 9 | // virtualalloc: standard sequential virtual memory allocator 10 | // Virtual memory can be reserved in large sizes and commited later on demand 11 | // Very useful for large buffer allocations, instead of allocating directly from heap 12 | // Memory is only allocate sequentially and will not be reused 13 | // so the limitation is not to hit the 'reserve_sz' max 14 | // 15 | // sx_virtualalloc_init Initialize and reserves virtual memory for the allocator 16 | // Reserved size will not be commited until it's alloacated and 17 | // touched 'reserved_sz' value will grow to OS-specific aligned 18 | // page size 19 | // 20 | // sx_virtualalloc_release Releases memory commited and reserved by virtual-allocator 21 | // 22 | // NOTE: When you use the sx_alloc object for allocating, the memory will be commited and you will 23 | // get a valid pointer. But still the memory is not allocated from heap until you touch the 24 | // contents of the memory block. 25 | // Also the allocation sizes will grow to OS-specific aligned page size (for example 4k), 26 | // .. so try to allocate in larger chunks from this type of allocator 27 | // 28 | #pragma once 29 | 30 | #include "allocator.h" 31 | 32 | typedef struct sx_virtualalloc { 33 | sx_alloc alloc; 34 | uint8_t* ptr; // Pointer to reserved memory address 35 | size_t offset; 36 | size_t reserved_sz; // Total memory that is reserved (mapped) on init 37 | } sx_virtualalloc; 38 | 39 | SX_API bool sx_virtualalloc_init(sx_virtualalloc* valloc, size_t reserve_sz); 40 | SX_API void sx_virtualalloc_release(sx_virtualalloc* valloc); 41 | 42 | // low-level virtual memory api 43 | SX_API void* sx_virtual_reserve(size_t reserve_sz); 44 | SX_API void sx_virtual_release(void* ptr, size_t sz); 45 | SX_API void sx_virtual_protect(void* ptr, size_t sz); 46 | SX_API void* sx_virtual_commit(void* addr, size_t sz); 47 | SX_API void sx_virtual_decommit(void* addr, size_t sz); 48 | 49 | -------------------------------------------------------------------------------- /3rdparty/sx/src/cmdline.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/sx#license-bsd-2-clause 4 | // 5 | #include "sx/cmdline.h" 6 | #include "sx/allocator.h" 7 | 8 | #define GETOPT_PRIVATE_API 9 | #include "../3rdparty/getopt/include/getopt/getopt.h" 10 | 11 | sx_cmdline_context* sx_cmdline_create_context(const sx_alloc* alloc, int argc, const char** argv, 12 | const sx_cmdline_opt* opts) { 13 | sx_cmdline_context* ctx = (sx_cmdline_context*)sx_malloc(alloc, sizeof(sx_cmdline_context)); 14 | if (!ctx) 15 | sx_out_of_memory(); 16 | 17 | int r = getopt_create_context(ctx, argc, argv, (const getopt_option_t*)opts); 18 | if (r < 0) { 19 | sx_free(alloc, ctx); 20 | return NULL; 21 | } 22 | 23 | return ctx; 24 | } 25 | 26 | void sx_cmdline_destroy_context(sx_cmdline_context* ctx, const sx_alloc* alloc) { 27 | sx_assert(ctx); 28 | sx_free(alloc, ctx); 29 | } 30 | 31 | int sx_cmdline_next(sx_cmdline_context* ctx, int* index, const char** arg) { 32 | int r = getopt_next(ctx); 33 | if (r != -1) { 34 | if (index) 35 | *index = ((getopt_context_t*)ctx)->current_index; 36 | if (arg) 37 | *arg = ((getopt_context_t*)ctx)->current_opt_arg; 38 | } 39 | return r; 40 | } 41 | 42 | const char* sx_cmdline_create_help_string(sx_cmdline_context* ctx, char* buffer, 43 | unsigned int buffer_size) { 44 | return getopt_create_help_string(ctx, buffer, buffer_size); 45 | } 46 | -------------------------------------------------------------------------------- /3rdparty/sx/src/handle.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/sx#license-bsd-2-clause 4 | // 5 | #include "sx/handle.h" 6 | #include "sx/allocator.h" 7 | 8 | const uint32_t k__handle_index_mask = (1 << (32 - SX_CONFIG_HANDLE_GEN_BITS)) - 1; 9 | const uint32_t k__handle_gen_mask = ((1 << SX_CONFIG_HANDLE_GEN_BITS) - 1); 10 | const uint32_t k__handle_gen_shift = (32 - SX_CONFIG_HANDLE_GEN_BITS); 11 | 12 | sx_handle_pool* sx_handle_create_pool(const sx_alloc* alloc, int capacity) { 13 | sx_assert(capacity < UINT16_MAX && "capacity is too high"); 14 | 15 | // Align count to 16, for a better aligned internal memory 16 | int maxsz = sx_align_mask(capacity, 15); 17 | 18 | uint8_t* buff = 19 | (uint8_t*)sx_malloc(alloc, sizeof(sx_handle_pool) + (sizeof(sx_handle_t) + sizeof(int)) * maxsz); 20 | if (!buff) { 21 | sx_out_of_memory(); 22 | return NULL; 23 | } 24 | 25 | sx_handle_pool* pool = (sx_handle_pool*)buff; 26 | buff += sizeof(sx_handle_pool); 27 | pool->dense = (sx_handle_t*)buff; 28 | buff += sizeof(sx_handle_t) * maxsz; 29 | pool->sparse = (int*)buff; 30 | pool->capacity = capacity; 31 | sx_handle_reset_pool(pool); 32 | 33 | return pool; 34 | } 35 | 36 | void sx_handle_destroy_pool(sx_handle_pool* pool, const sx_alloc* alloc) { 37 | if (pool) { 38 | sx_free(alloc, pool); 39 | } 40 | } 41 | 42 | bool sx_handle_grow_pool(sx_handle_pool** ppool, const sx_alloc* alloc) { 43 | sx_handle_pool* pool = *ppool; 44 | int new_cap = pool->capacity << 1; 45 | 46 | sx_handle_pool* new_pool = sx_handle_create_pool(alloc, new_cap); 47 | if (!new_pool) 48 | return false; 49 | new_pool->count = pool->count; 50 | sx_memcpy(new_pool->dense, pool->dense, sizeof(sx_handle_t) * pool->capacity); 51 | sx_memcpy(new_pool->sparse, pool->sparse, sizeof(int) * pool->capacity); 52 | 53 | sx_handle_destroy_pool(pool, alloc); 54 | *ppool = new_pool; 55 | return true; 56 | } 57 | -------------------------------------------------------------------------------- /3rdparty/sx/src/ini.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/sx#license-bsd-2-clause 4 | // 5 | #include "sx/ini.h" 6 | #include "sx/allocator.h" 7 | #include "sx/string.h" 8 | 9 | #define INI_IMPLEMENTATION 10 | #define INI_MALLOC(ctx, size) (sx_malloc((const sx_alloc*)ctx, size)) 11 | #define INI_FREE(ctx, ptr) (sx_free((const sx_alloc*)ctx, ptr)) 12 | #define INI_MEMCPY(dst, src, cnt) (sx_memcpy(dst, src, cnt)) 13 | #define INI_STRLEN(s) (sx_strlen(s)) 14 | // TODO: #define INI_STRNICMP( s1, s2, cnt ) ( my_strnicmp_func( s1, s2, cnt ) ) 15 | SX_PRAGMA_DIAGNOSTIC_PUSH() 16 | SX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wsign-compare") 17 | #include "../3rdparty/mattias/ini.h" 18 | SX_PRAGMA_DIAGNOSTIC_POP() 19 | 20 | sx_ini* sx_ini_create(const sx_alloc* alloc) { 21 | return (sx_ini*)ini_create((void*)alloc); 22 | } 23 | 24 | sx_ini* sx_ini_load(const char* data, const sx_alloc* alloc) { 25 | return (sx_ini*)ini_load(data, (void*)alloc); 26 | } 27 | 28 | int sx_ini_save(sx_ini const* ini, char* data, int size) { 29 | return ini_save(ini, data, size); 30 | } 31 | 32 | void sx_ini_destroy(sx_ini* ini) { 33 | ini_destroy(ini); 34 | } 35 | 36 | int sx_ini_section_count(sx_ini const* ini) { 37 | return ini_section_count(ini); 38 | } 39 | 40 | char const* sx_ini_section_name(sx_ini const* ini, int section) { 41 | return ini_section_name(ini, section); 42 | } 43 | 44 | int sx_ini_property_count(sx_ini const* ini, int section) { 45 | return ini_property_count(ini, section); 46 | } 47 | 48 | char const* sx_ini_property_name(sx_ini const* ini, int section, int property) { 49 | return ini_property_name(ini, section, property); 50 | } 51 | 52 | char const* sx_ini_property_value(sx_ini const* ini, int section, int property) { 53 | return ini_property_value(ini, section, property); 54 | } 55 | 56 | int sx_ini_find_section(sx_ini const* ini, char const* name, int name_length) { 57 | return ini_find_section(ini, name, name_length); 58 | } 59 | 60 | int sx_ini_find_property(sx_ini const* ini, int section, char const* name, int name_length) { 61 | return ini_find_property(ini, section, name, name_length); 62 | } 63 | 64 | int sx_ini_section_add(sx_ini* ini, char const* name, int length) { 65 | return ini_section_add(ini, name, length); 66 | } 67 | 68 | void sx_ini_property_add(sx_ini* ini, int section, char const* name, int name_length, 69 | char const* value, int value_length) { 70 | ini_property_add(ini, section, name, name_length, value, value_length); 71 | } 72 | 73 | void sx_ini_section_remove(sx_ini* ini, int section) { 74 | ini_section_remove(ini, section); 75 | } 76 | 77 | void sx_ini_property_remove(sx_ini* ini, int section, int property) { 78 | ini_property_remove(ini, section, property); 79 | } 80 | 81 | void sx_ini_section_name_set(sx_ini* ini, int section, char const* name, int length) { 82 | ini_section_name_set(ini, section, name, length); 83 | } 84 | 85 | void sx_ini_property_name_set(sx_ini* ini, int section, int property, char const* name, 86 | int length) { 87 | ini_property_name_set(ini, section, property, name, length); 88 | } 89 | 90 | void sx_ini_property_value_set(sx_ini* ini, int section, int property, char const* value, 91 | int length) { 92 | ini_property_value_set(ini, section, property, value, length); 93 | } 94 | -------------------------------------------------------------------------------- /3rdparty/sx/src/lin-alloc.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/sx#license-bsd-2-clause 4 | // 5 | #include "sx/lin-alloc.h" 6 | 7 | typedef struct sx__linalloc_hdr_s { 8 | int size; // size of buffer that requested upon allocation 9 | int padding; // number of bytes that is padded before the pointer 10 | } sx__linalloc_hdr; 11 | 12 | static void* sx__linalloc_malloc(sx_linalloc* alloc, size_t size, uint32_t align) { 13 | align = sx_max((int)align, SX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT); 14 | size_t total = size + sizeof(sx__linalloc_hdr) + align; 15 | if ((alloc->offset + total) > (size_t)alloc->size) { 16 | sx_out_of_memory(); 17 | return NULL; 18 | } 19 | 20 | uint8_t* ptr = alloc->ptr + alloc->offset; 21 | uint8_t* aligned = (uint8_t*)sx_align_ptr(ptr, sizeof(sx__linalloc_hdr), align); 22 | 23 | // Fill header info 24 | sx__linalloc_hdr* hdr = (sx__linalloc_hdr*)aligned - 1; 25 | hdr->size = (int)size; 26 | hdr->padding = (int)(aligned - ptr); 27 | 28 | alloc->offset += (int)total; 29 | alloc->peak = sx_max(alloc->peak, alloc->offset); 30 | 31 | return aligned; 32 | } 33 | 34 | static void* sx__linalloc_cb(void* ptr, size_t size, uint32_t align, const char* file, 35 | const char* func, uint32_t line, void* user_data) { 36 | sx_unused(file); 37 | sx_unused(func); 38 | sx_unused(line); 39 | 40 | 41 | sx_linalloc* linalloc = (sx_linalloc*)user_data; 42 | void* last_ptr = linalloc->ptr + linalloc->last_ptr_offset; 43 | if (size > 0) { 44 | if (ptr == NULL) { 45 | // malloc 46 | void* new_ptr = sx__linalloc_malloc(linalloc, size, align); 47 | linalloc->last_ptr_offset = (int)(intptr_t)((uint8_t*)new_ptr - linalloc->ptr); 48 | return new_ptr; 49 | } else if (ptr == last_ptr) { 50 | // Realloc: special case, the memory is continous so we can just grow the buffer without 51 | // any new allocation 52 | // TODO: put some control in alignment checking, so alignment stay constant 53 | // between reallocs 54 | if ((linalloc->offset + size) > (size_t)linalloc->size) { 55 | sx_out_of_memory(); 56 | return NULL; 57 | } 58 | linalloc->offset += (int)size; 59 | return ptr; // Input pointer does not change 60 | } else { 61 | // Realloc: generic, create new allocation and sx_memcpy the previous data into the 62 | // beginning 63 | void* new_ptr = sx__linalloc_malloc(linalloc, size, align); 64 | if (new_ptr) { 65 | sx__linalloc_hdr* hdr = (sx__linalloc_hdr*)ptr - 1; 66 | sx_memcpy(new_ptr, ptr, sx_min((int)size, hdr->size)); 67 | linalloc->last_ptr_offset = (int)(intptr_t)((uint8_t*)new_ptr - linalloc->ptr); 68 | } 69 | return new_ptr; 70 | } 71 | } 72 | 73 | // Note: we have no Free operation for linear allocator 74 | return NULL; 75 | } 76 | 77 | void sx_linalloc_init(sx_linalloc* linalloc, void* ptr, int size) { 78 | sx_assert(linalloc); 79 | sx_assert(ptr); 80 | sx_assert(size); 81 | 82 | linalloc->alloc.alloc_cb = sx__linalloc_cb; 83 | linalloc->alloc.user_data = linalloc; 84 | linalloc->ptr = (uint8_t*)ptr; 85 | linalloc->last_ptr_offset = 0; 86 | linalloc->size = size; 87 | linalloc->offset = linalloc->peak = 0; 88 | } 89 | 90 | void sx_linalloc_reset(sx_linalloc* linalloc) { 91 | linalloc->last_ptr_offset = 0; 92 | linalloc->offset = 0; 93 | } -------------------------------------------------------------------------------- /3rdparty/sx/src/rng.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/sx#license-bsd-2-clause 4 | // 5 | #include "sx/rng.h" 6 | #include "sx/sx.h" 7 | 8 | // This implementation is taken from: https://github.com/mattiasgustavsson/libs/blob/master/rnd.h 9 | // With a minor optimization in sx_rng_gen_irange 10 | 11 | // Convert a randomized uint32_t value to a float value x in the range 0.0f <= x < 1.0f. Contributed 12 | // by Jonatan Hedborg 13 | SX_PRAGMA_DIAGNOSTIC_PUSH() 14 | SX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wstrict-aliasing") 15 | static inline float sx__rng_float_normalized(uint32_t value) { 16 | uint32_t exponent = 127; 17 | uint32_t mantissa = value >> 9; 18 | uint32_t result = (exponent << 23) | mantissa; 19 | float fresult = *(float*)(&result); 20 | return fresult - 1.0f; 21 | } 22 | SX_PRAGMA_DIAGNOSTIC_POP() 23 | 24 | static inline uint64_t sx__rng_avalanche64(uint64_t h) { 25 | h ^= h >> 33; 26 | h *= 0xff51afd7ed558ccd; 27 | h ^= h >> 33; 28 | h *= 0xc4ceb9fe1a85ec53; 29 | h ^= h >> 33; 30 | return h; 31 | } 32 | 33 | void sx_rng_seed(sx_rng* rng, uint32_t seed) { 34 | uint64_t value = (((uint64_t)seed) << 1ull) | 1ull; // make it odd 35 | value = sx__rng_avalanche64(value); 36 | rng->state[0] = 0ull; 37 | rng->state[1] = (value << 1ull) | 1ull; 38 | sx_rng_gen(rng); 39 | rng->state[0] += sx__rng_avalanche64(value); 40 | sx_rng_gen(rng); 41 | } 42 | 43 | uint32_t sx_rng_gen(sx_rng* rng) { 44 | uint64_t oldstate = rng->state[0]; 45 | rng->state[0] = oldstate * 0x5851f42d4c957f2dull + rng->state[1]; 46 | uint32_t xorshifted = (uint32_t)(((oldstate >> 18ull) ^ oldstate) >> 27ull); 47 | uint32_t rot = (uint32_t)(oldstate >> 59ull); 48 | return (xorshifted >> rot) | (xorshifted << ((-(int)rot) & 31)); 49 | } 50 | 51 | float sx_rng_gen_f(sx_rng* rng) { 52 | return sx__rng_float_normalized(sx_rng_gen(rng)); 53 | } 54 | 55 | int sx_rng_gen_irange(sx_rng* rng, int _min, int _max) { 56 | sx_assert(_min <= _max); 57 | 58 | const uint32_t range = (uint32_t)(_max - _min) + 1; 59 | return (int)(sx_rng_gen(rng) % range) + _min; 60 | } 61 | -------------------------------------------------------------------------------- /3rdparty/sx/src/sx.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/sx#license-bsd-2-clause 4 | // 5 | #include "sx/sx.h" 6 | 7 | #if SX_PLATFORM_ANDROID 8 | # include 9 | #elif SX_PLATFORM_WINDOWS 10 | __declspec(dllimport) void __stdcall OutputDebugStringA(const char* _str); 11 | #else 12 | # include // fputs, fflush 13 | #endif 14 | 15 | // CRT symbol workaround 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | int _fltused = 0; 20 | 21 | void sx__break_program(const char* text) { 22 | // print 23 | #if SX_PLATFORM_ANDROID 24 | __android_log_write(ANDROID_LOG_DEBUG, "", text); 25 | #elif SX_PLATFORM_WINDOWS 26 | OutputDebugStringA(text); 27 | #else 28 | fputs(text, stderr); 29 | fflush(stderr); 30 | #endif 31 | 32 | // break 33 | #if SX_COMPILER_MSVC 34 | __debugbreak(); 35 | #elif SX_CPU_ARM 36 | __builtin_trap(); 37 | #elif SX_CPU_X86 && (SX_COMPILER_GCC || SX_COMPILER_CLANG) 38 | __asm__("int $3"); 39 | #else 40 | int* int3 = (int*)3L; 41 | *int3 = 3; 42 | #endif 43 | } 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | -------------------------------------------------------------------------------- /3rdparty/sx/src/timer.c: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2018 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/sx#license-bsd-2-clause 4 | // 5 | 6 | #define SOKOL_IMPL 7 | #define SOKOL_API_DECL static inline 8 | #define SOKOL_API_IMPL static inline 9 | #include "../3rdparty/sokol/sokol_time.h" 10 | 11 | #include "sx/timer.h" 12 | 13 | void sx_tm_init() { 14 | stm_setup(); 15 | } 16 | 17 | uint64_t sx_tm_now() { 18 | return stm_now(); 19 | } 20 | 21 | uint64_t sx_tm_diff(uint64_t new_ticks, uint64_t old_ticks) { 22 | return stm_diff(new_ticks, old_ticks); 23 | } 24 | 25 | uint64_t sx_tm_since(uint64_t start_ticks) { 26 | return stm_since(start_ticks); 27 | } 28 | 29 | uint64_t sx_tm_laptime(uint64_t* last_ticks) { 30 | return stm_laptime(last_ticks); 31 | } 32 | 33 | double sx_tm_sec(uint64_t ticks) { 34 | return stm_sec(ticks); 35 | } 36 | 37 | double sx_tm_ms(uint64_t ticks) { 38 | return stm_ms(ticks); 39 | } 40 | 41 | double sx_tm_us(uint64_t ticks) { 42 | return stm_us(ticks); 43 | } 44 | 45 | double sx_tm_ns(uint64_t ticks) { 46 | return stm_ns(ticks); 47 | } 48 | -------------------------------------------------------------------------------- /3rdparty/sx/src/tlsf-alloc.c: -------------------------------------------------------------------------------- 1 | #include "sx/tlsf-alloc.h" 2 | #include "sx/allocator.h" 3 | 4 | #define TLSF_PRIVATE_API 5 | #define tlsf_assert sx_assert 6 | SX_PRAGMA_DIAGNOSTIC_PUSH(); 7 | SX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wunknown-pragmas") 8 | #include "../3rdparty/tlsf/tlsf.h" 9 | SX_PRAGMA_DIAGNOSTIC_POP(); 10 | 11 | static void* sx__tlsfalloc_cb(void* ptr, size_t size, uint32_t align, const char* file, 12 | const char* func, uint32_t line, void* user_data) { 13 | sx_unused(file); 14 | sx_unused(func); 15 | sx_unused(line); 16 | 17 | tlsf_t tlsf = (tlsf_t)user_data; 18 | if (size == 0) { 19 | tlsf_free(tlsf, ptr); 20 | return NULL; 21 | } else if (ptr == NULL) { 22 | if (align <= SX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT) 23 | return tlsf_malloc(tlsf, size); 24 | 25 | return tlsf_memalign(tlsf, align, size); 26 | } else { 27 | if (align <= SX_CONFIG_ALLOCATOR_NATURAL_ALIGNMENT) 28 | return tlsf_realloc(tlsf, ptr, size); 29 | 30 | tlsf_free(tlsf, ptr); 31 | return tlsf_memalign(tlsf, align, size); 32 | } 33 | } 34 | 35 | bool sx_tlsfalloc_init(sx_alloc* tlsf, void* mem, int size) { 36 | tlsf->alloc_cb = sx__tlsfalloc_cb; 37 | tlsf->user_data = tlsf_create_with_pool(mem, size); 38 | if (!tlsf->user_data) 39 | return false; 40 | 41 | return true; 42 | } 43 | 44 | void sx_tlsfalloc_release(sx_alloc* tlsf) { 45 | tlsf_destroy((tlsf_t)tlsf->user_data); 46 | tlsf->user_data = NULL; 47 | tlsf->alloc_cb = NULL; 48 | } 49 | 50 | sx_tlsf_pool_t sx_tlsfalloc_add_pool(sx_alloc* tlsf, void* mem, int size) { 51 | return tlsf_add_pool((tlsf_t)tlsf->user_data, mem, size); 52 | } 53 | 54 | void sx_tlsfalloc_remove_pool(sx_alloc* tlsf, sx_tlsf_pool_t pool) { 55 | tlsf_remove_pool((tlsf_t)tlsf->user_data, pool); 56 | } 57 | 58 | sx_tlsf_pool_t sx_tlsfalloc_get_pool(sx_alloc* tlsf) { 59 | return tlsf_get_pool((tlsf_t)tlsf->user_data); 60 | } 61 | 62 | void sx_tlsfalloc_walk_pool(sx_tlsf_pool_t pool, sx_tlsfalloc_walk_cb* walker, void* user) { 63 | tlsf_walk_pool((pool_t)pool, (tlsf_walker)walker, user); 64 | } 65 | 66 | bool sx_tlsfalloc_check(sx_alloc* tlsf) { 67 | return tlsf_check((tlsf_t)tlsf->user_data) == 0; 68 | } 69 | 70 | bool sx_tlsfalloc_check_pool(sx_tlsf_pool_t pool) { 71 | return tlsf_check_pool((pool_t)pool) == 0; 72 | } 73 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(atlasc) 3 | 4 | option(STATIC_LIB "Build atlasc as static-library instead of command-line tool" OFF) 5 | 6 | function(remove_compile_options DEST_VAR COMPILER_FLAGS FLAGS) 7 | separate_arguments(FLAGS) 8 | foreach(FLAG ${FLAGS}) 9 | string(REPLACE "${FLAG}" "" COMPILER_FLAGS "${COMPILER_FLAGS}") 10 | endforeach() 11 | set(${DEST_VAR} ${COMPILER_FLAGS} PARENT_SCOPE) 12 | endfunction() 13 | 14 | add_definitions(-D__STDC_LIMIT_MACROS) 15 | add_definitions(-D__STDC_FORMAT_MACROS) 16 | add_definitions(-D__STDC_CONSTANT_MACROS) 17 | if(MSVC) 18 | add_definitions(-D_ITERATOR_DEBUG_LEVEL=0) 19 | add_definitions(-D_HAS_EXCEPTIONS=0) 20 | add_definitions(-D_CRT_SECURE_NO_WARNINGS=0) 21 | 22 | remove_compile_options(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" "/MD") 23 | remove_compile_options(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" "/MD") 24 | set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") 25 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT") 26 | else() 27 | add_compile_options(-std=gnu11) 28 | endif() 29 | if (RPI) 30 | add_definitions(-D__RPI__) 31 | endif() 32 | 33 | add_subdirectory(3rdparty/sx) 34 | add_subdirectory(3rdparty/delaunay) 35 | 36 | if (NOT STATIC_LIB) 37 | add_executable(atlasc src/atlasc.c) 38 | else() 39 | add_library(atlasc STATIC src/atlasc) 40 | target_compile_definitions(atlasc PRIVATE -DATLASC_STATIC_LIB) 41 | endif() 42 | 43 | target_link_libraries(atlasc PRIVATE sx delaunay) 44 | target_include_directories(atlasc PRIVATE 3rdparty) 45 | 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2019, Sepehr Taghdisian (septag@protonmail.com) 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /img/drawsprite-wire.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/septag/atlasc/8a30478e7491ed4781805e696af078943e8c5756/img/drawsprite-wire.png -------------------------------------------------------------------------------- /include/atlasc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2019 Sepehr Taghdisian (septag@github). All rights reserved. 3 | // License: https://github.com/septag/atlasc#license-bsd-2-clause 4 | // 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #include "sx/math.h" 12 | 13 | typedef struct atlasc_args { 14 | int alpha_threshold; 15 | float dist_threshold; 16 | int max_width; 17 | int max_height; 18 | int border; 19 | int pot; 20 | int padding; 21 | int mesh; 22 | int max_verts_per_mesh; 23 | float scale; 24 | } atlasc_args; 25 | 26 | typedef struct atlasc_image_data { 27 | uint8_t* pixels; // only supports 32bpp RGBA format 28 | int width; 29 | int height; 30 | } atlasc_image_data; 31 | 32 | typedef struct atlasc_args_frommem { 33 | atlasc_args common; 34 | const atlasc_image_data* images; 35 | int num_images; 36 | } atlasc_args_frommem; 37 | 38 | typedef struct atlasc_args_files { 39 | atlasc_args common; 40 | char** in_filepaths; 41 | int num_files; 42 | const char* out_filepath; // not required for `atlasc_make_in_memory` 43 | } atlasc_args_files; 44 | 45 | typedef struct atlasc_sprite { 46 | uint8_t* src_image; // RGBA image buffer (32bpp) 47 | sx_ivec2 src_size; // widthxheight 48 | sx_irect sprite_rect; // cropped rectangle relative to sprite's source image (pixels) 49 | sx_irect sheet_rect; // rectangle in final sheet (pixels) 50 | 51 | // sprite-mesh data (if flag is set. see atlas_args) 52 | uint16_t num_tris; 53 | int num_points; 54 | sx_ivec2* pts; 55 | sx_ivec2* uvs; 56 | uint16_t* tris; 57 | } atlasc_sprite; 58 | 59 | typedef struct atlasc_atlas_data { 60 | atlasc_sprite* sprites; 61 | int num_sprites; 62 | atlasc_image_data atlas_image; 63 | } atlasc_atlas_data; 64 | 65 | #ifndef ATLASC__HIDE_API 66 | #ifdef __cplusplus 67 | extern "C" { 68 | #endif 69 | 70 | // set allocation callbacks 71 | // uses malloc/free/realloc by default 72 | void atlasc_set_alloc_callbacks(void* (*malloc_fn)(size_t size, void* ctx), 73 | void (*free_fn)(void* ptr, void* ctx), 74 | void* (*realloc_fn)(void* ptr, size_t size, void* ctx), void* ctx); 75 | 76 | // receives arguments (input filepaths) and writes 32bpp PNG to out_filepath 77 | bool atlasc_make(const atlasc_args_files* args); 78 | 79 | // receives arguemnts (out_filepath is not required) and returns atlas_data 80 | // you have to free the data after use with `atlasc_free` 81 | atlasc_atlas_data* atlasc_make_inmem(const atlasc_args_files* args); 82 | 83 | // recevies input image buffers and common arguments 84 | // you have to free the data after use with `atlasc_free` 85 | atlasc_atlas_data* atlasc_make_inmem_frommem(const atlasc_args_frommem* args); 86 | 87 | // frees atlasc_atlas_data memory 88 | void atlasc_free(atlasc_atlas_data* atlas); 89 | 90 | // returns the last error string 91 | const char* atlasc_error_string(); 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif // ATLASC__HIDE_API --------------------------------------------------------------------------------