├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── cmake └── Utility.cmake ├── deps ├── bx │ ├── .appveyor.yml │ ├── .editorconfig │ ├── .gitattributes │ ├── .gitignore │ ├── .travis.yml │ ├── 3rdparty │ │ └── catch │ │ │ └── catch.hpp │ ├── CMakeLists.txt │ ├── LICENSE │ ├── README.md │ ├── include │ │ ├── bx │ │ │ ├── allocator.h │ │ │ ├── bx.h │ │ │ ├── cl.h │ │ │ ├── commandline.h │ │ │ ├── config.h │ │ │ ├── cpu.h │ │ │ ├── crtimpl.h │ │ │ ├── debug.h │ │ │ ├── endian.h │ │ │ ├── error.h │ │ │ ├── float4_langext.h │ │ │ ├── float4_neon.h │ │ │ ├── float4_ni.h │ │ │ ├── float4_ref.h │ │ │ ├── float4_sse.h │ │ │ ├── float4_swizzle.inl │ │ │ ├── float4_t.h │ │ │ ├── float4x4_t.h │ │ │ ├── foreach.h │ │ │ ├── fpumath.h │ │ │ ├── handlealloc.h │ │ │ ├── hash.h │ │ │ ├── macros.h │ │ │ ├── maputil.h │ │ │ ├── mpscqueue.h │ │ │ ├── mutex.h │ │ │ ├── os.h │ │ │ ├── platform.h │ │ │ ├── process.h │ │ │ ├── radixsort.h │ │ │ ├── readerwriter.h │ │ │ ├── ringbuffer.h │ │ │ ├── rng.h │ │ │ ├── sem.h │ │ │ ├── simd128_langext.inl │ │ │ ├── simd128_neon.inl │ │ │ ├── simd128_ref.inl │ │ │ ├── simd128_sse.inl │ │ │ ├── simd128_swizzle.inl │ │ │ ├── simd256_avx.inl │ │ │ ├── simd256_ref.inl │ │ │ ├── simd_ni.inl │ │ │ ├── simd_t.h │ │ │ ├── spscqueue.h │ │ │ ├── string.h │ │ │ ├── thread.h │ │ │ ├── timer.h │ │ │ ├── tokenizecmd.h │ │ │ └── uint32_t.h │ │ ├── bxx │ │ │ ├── array.h │ │ │ ├── bitmask_operators.hpp │ │ │ ├── coro.h │ │ │ ├── hash_table.h │ │ │ ├── indexed_pool.h │ │ │ ├── inifile.h │ │ │ ├── json.h │ │ │ ├── leakcheck_allocator.h │ │ │ ├── linear_allocator.h │ │ │ ├── linked_list.h │ │ │ ├── lock.h │ │ │ ├── logger.h │ │ │ ├── path.h │ │ │ ├── pool.h │ │ │ ├── proxy_allocator.h │ │ │ ├── queue.h │ │ │ ├── random.h │ │ │ ├── sockets.h │ │ │ ├── stack.h │ │ │ ├── string.h │ │ │ ├── terminal_colors.h │ │ │ ├── timer.h │ │ │ └── uuid.h │ │ ├── compat │ │ │ ├── freebsd │ │ │ │ ├── alloca.h │ │ │ │ ├── malloc.h │ │ │ │ └── signal.h │ │ │ ├── ios │ │ │ │ └── malloc.h │ │ │ ├── mingw │ │ │ │ ├── alloca.h │ │ │ │ ├── dirent.h │ │ │ │ ├── dxsdk.patch │ │ │ │ ├── sal.h │ │ │ │ ├── specstrings_strict.h │ │ │ │ └── specstrings_undef.h │ │ │ ├── msvc │ │ │ │ ├── alloca.h │ │ │ │ ├── dirent.h │ │ │ │ ├── inttypes.h │ │ │ │ ├── pre1600 │ │ │ │ │ └── stdint.h │ │ │ │ └── stdbool.h │ │ │ ├── nacl │ │ │ │ └── memory.h │ │ │ ├── osx │ │ │ │ └── malloc.h │ │ │ └── posix │ │ │ │ └── conio.h │ │ └── tinystl │ │ │ ├── LICENSE │ │ │ ├── allocator.h │ │ │ ├── buffer.h │ │ │ ├── hash.h │ │ │ ├── hash_base.h │ │ │ ├── new.h │ │ │ ├── stddef.h │ │ │ ├── string.h │ │ │ ├── traits.h │ │ │ ├── unordered_map.h │ │ │ ├── unordered_set.h │ │ │ └── vector.h │ ├── makefile │ ├── scripts │ │ ├── bin2c.lua │ │ ├── bx.lua │ │ ├── genie.lua │ │ ├── toolchain.lua │ │ ├── uncrustify.cfg │ │ └── unittest++.lua │ ├── tests │ │ ├── dbg.cpp │ │ ├── dbg.h │ │ ├── float4_t.cpp │ │ ├── fpumath.cpp │ │ ├── handle.cpp │ │ ├── macros.cpp │ │ ├── main.cpp │ │ ├── misc.cpp │ │ ├── simd_t.cpp │ │ ├── test.h │ │ ├── thread.cpp │ │ ├── tokenizecmd.cpp │ │ ├── uint32_t.cpp │ │ ├── unordered_map_nonpod.cpp │ │ ├── unordered_set_copyctor.cpp │ │ ├── unordered_set_pod.cpp │ │ ├── vector_complex.cpp │ │ ├── vector_header.cpp │ │ ├── vector_nocopy.cpp │ │ ├── vector_nodefault.cpp │ │ ├── vector_primitive.cpp │ │ └── vector_shrinktofit.cpp │ └── tools │ │ ├── bin │ │ ├── darwin │ │ │ ├── bin2c │ │ │ ├── genie │ │ │ └── ninja │ │ ├── linux │ │ │ ├── bin2c │ │ │ ├── genie │ │ │ └── ninja │ │ └── windows │ │ │ ├── bin2c.exe │ │ │ ├── genie.exe │ │ │ └── ninja.exe │ │ └── bin2c │ │ └── bin2c.cpp └── deboost.context │ ├── .gitignore │ ├── 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_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_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_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 │ ├── cmake │ ├── AndroidNdkGdb.cmake │ ├── AndroidNdkModules.cmake │ └── android.toolchain.cmake │ ├── include │ └── fcontext │ │ └── fcontext.h │ ├── source │ └── stack.cpp │ └── test │ └── test_fcontext.cpp ├── termite_jobs.cpp └── termite_jobs.h /.gitignore: -------------------------------------------------------------------------------- 1 | # External junk 2 | .DS_Store 3 | _ReSharper* 4 | *.opensdf 5 | *.sdf 6 | *.dir 7 | *.suo 8 | *.user 9 | Win32 10 | Win64 11 | Debug 12 | Release 13 | Profile 14 | Development 15 | Obj 16 | Bin 17 | Lib 18 | .tags 19 | .tags_sorted_by_file 20 | *.lnk 21 | ipch 22 | __pycache__ 23 | Thumbs.db 24 | 25 | # Generated files 26 | docs/Doxyfile 27 | docs/html 28 | docs/warnings.txt 29 | out 30 | 31 | # Compiled binaries 32 | *.so 33 | *.dylib 34 | *.dll 35 | *.a 36 | *.lib 37 | *.exe 38 | .build 39 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.3) 2 | project(termite-jobs) 3 | 4 | set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/install CACHE PATH "Install path" FORCE) 5 | 6 | # Default output directories for runtime and libraries 7 | if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) 8 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/out) 9 | endif() 10 | if (NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) 11 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/out) 12 | endif() 13 | 14 | if (NOT EXISTS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) 15 | file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) 16 | endif() 17 | 18 | if (CMAKE_CONFIGURATION_TYPES) 19 | set(CMAKE_CONFIGURATION_TYPES "Debug;Release;" CACHE STRING "" FORCE) 20 | endif() 21 | 22 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 23 | 24 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") 25 | include(Utility) 26 | 27 | # Check dependencies 28 | # Compilation flags 29 | if(MSVC) 30 | add_definitions(-D_ITERATOR_DEBUG_LEVEL=0) 31 | add_definitions(-D_HAS_EXCEPTIONS=0) 32 | add_definitions(-D_HAS_ITERATOR_DEBUGGING=0) 33 | add_definitions(-D_SCL_SECURE=0) 34 | add_definitions(-D_SECURE_SCL=0) 35 | add_definitions(-D_SCL_SECURE_NO_WARNINGS) 36 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) 37 | 38 | remove_cxx_flag("/EHsc") 39 | remove_cxx_flag("/GR") 40 | add_compile_options(/GR-) 41 | else() 42 | add_compile_options(-std=c++11 -fPIC -fno-rtti -fno-exceptions -Wno-switch) 43 | endif() 44 | 45 | # http://stackoverflow.com/questions/33829152/for-cmake-can-you-modify-the-release-debug-compiler-flags-with-add-compiler-fl 46 | set(DEBUG_COMPILE_OPTIONS "-DBX_CONFIG_ALLOCATOR_DEBUG") 47 | add_compile_options("$<$:${DEBUG_COMPILE_OPTIONS}>") 48 | 49 | # Sub projects 50 | # dependencies 51 | add_subdirectory(deps/deboost.context) 52 | add_subdirectory(deps/bx) 53 | set_target_properties(fcontext PROPERTIES FOLDER Deps) 54 | 55 | add_library(termite-jobs STATIC 56 | "termite_jobs.cpp" 57 | "termite_jobs.h") 58 | 59 | target_link_libraries(termite-jobs PRIVATE fcontext bx) 60 | target_include_directories(termite-jobs INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) 61 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Sepehr Taghdisian 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NOTE 2 | *This library is obsolete and may contain bugs. For maintained version checkout [sx](https://github.com/septag/sx) library.* until I rip it from there and make a proper single-header termite-jobs library 3 | 4 | # termite-jobs 5 | Fast, multiplatform fiber based job dispatcher based on Naughty Dogs' GDC2015 talk. 6 | 7 | ## Features 8 | - Lightweight, lib size is 39kb 9 | - Fast, uses [libdeboost-context](https://github.com/septag/deboost.context) as it's fiber backend which is the fastest multiplatform co-routine implementation 10 | - Multiplatform 11 | 12 | ## Build 13 | Uses _cmake_ as it's build system, all you need is install _cmake_ and run the command : 14 | ``` 15 | cd termite-jobs 16 | mkdir .build 17 | cd .build 18 | cmake .. 19 | ``` 20 | 21 | Use specific cmake flags for your compiler/build tools 22 | -------------------------------------------------------------------------------- /cmake/Utility.cmake: -------------------------------------------------------------------------------- 1 | ######################################################## 2 | # Get dependency dirs 3 | function(get_cpu_arch RESULT) 4 | if (CMAKE_SIZEOF_VOID_P EQUAL 8) 5 | set(${RESULT} "x64" PARENT_SCOPE) 6 | else() 7 | set(${RESULT} "x86" PARENT_SCOPE) 8 | endif() 9 | endfunction() 10 | 11 | function(get_dep_dirs LIBNAME RESULT_LIB RESULT_INCLUDE) 12 | get_cpu_arch(SUFFIX) 13 | set(${RESULT_INCLUDE} ${DEP_ROOT_DIR}/${LIBNAME}/include PARENT_SCOPE) 14 | set(${RESULT_LIB} ${DEP_ROOT_DIR}/${LIBNAME}/lib/${SUFFIX} PARENT_SCOPE) 15 | endfunction() 16 | 17 | function(join_array VALUES GLUE OUTPUT) 18 | string (REGEX REPLACE "([^\\]|^);" "\\1${GLUE}" _TMP_STR "${VALUES}") 19 | string (REGEX REPLACE "[\\](.)" "\\1" _TMP_STR "${_TMP_STR}") #fixes escaping 20 | set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE) 21 | endfunction() 22 | 23 | ############################################## 24 | # remove CXX flags 25 | macro(remove_cxx_flag flag) 26 | string(REPLACE "${flag}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 27 | endmacro() 28 | 29 | # build compile flags 30 | function(copy_build_flags BUILD_TYPE) 31 | set(CMAKE_CXX_FLAGS_${BUILD_TYPE} ${CMAKE_CXX_FLAGS_RELEASE} PARENT_SCOPE) 32 | set(CMAKE_SHARED_LINKER_FLAGS_${BUILD_TYPE} ${CMAKE_SHARED_LINKER_FLAGS_RELEASE} PARENT_SCOPE) 33 | set(CMAKE_CXX_FLAGS_${BUILD_TYPE} ${CMAKE_SHARED_LINKER_FLAGS_RELEASE} PARENT_SCOPE) 34 | set(CMAKE_SHARED_LINKER_FLAGS_${BUILD_TYPE} ${CMAKE_SHARED_LINKER_FLAGS_RELEASE} PARENT_SCOPE) 35 | set(CMAKE_CXX_FLAGS_${BUILD_TYPE} ${CMAKE_CXX_FLAGS_RELEASE} PARENT_SCOPE) 36 | set(CMAKE_SHARED_LINKER_FLAGS_${BUILD_TYPE} ${CMAKE_CXX_FLAGS_RELEASE} PARENT_SCOPE) 37 | set(CMAKE_MODULE_LINKER_FLAGS_${BUILD_TYPE} ${CMAKE_CXX_FLAGS_RELEASE} PARENT_SCOPE) 38 | set(CMAKE_EXE_LINKER_FLAGS_${BUILD_TYPE} ${CMAKE_CXX_FLAGS_RELEASE} PARENT_SCOPE) 39 | set(CMAKE_STATIC_LINKER_FLAGS_${BUILD_TYPE} ${CMAKE_CXX_FLAGS_RELEASE} PARENT_SCOPE) 40 | endfunction() -------------------------------------------------------------------------------- /deps/bx/.appveyor.yml: -------------------------------------------------------------------------------- 1 | shallow_clone: true 2 | 3 | os: 4 | - Visual Studio 2015 5 | 6 | environment: 7 | matrix: 8 | - TOOLSET: vs2010 9 | - TOOLSET: vs2012 10 | - TOOLSET: vs2013 11 | - TOOLSET: vs2015 12 | 13 | configuration: 14 | - Debug 15 | - Release 16 | 17 | install: 18 | tools\bin\windows\genie %TOOLSET% 19 | 20 | build: 21 | project: .build/projects/$(TOOLSET)/bx.sln 22 | -------------------------------------------------------------------------------- /deps/bx/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | indent_size = 4 6 | end_of_line = lf 7 | max_line_length = 100 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | max_line_length = 80 14 | -------------------------------------------------------------------------------- /deps/bx/.gitattributes: -------------------------------------------------------------------------------- 1 | *.c eol=lf 2 | *.cpp eol=lf 3 | *.h eol=lf 4 | *.sc eol=lf 5 | *.sh eol=lf 6 | *.m eol=lf 7 | *.mm eol=lf 8 | *.md eol=lf 9 | *.lua eol=lf 10 | *.mk eol=lf 11 | makefile eol=lf 12 | -------------------------------------------------------------------------------- /deps/bx/.gitignore: -------------------------------------------------------------------------------- 1 | .git 2 | .build 3 | .debug 4 | .svn 5 | tags 6 | .DS_Store 7 | -------------------------------------------------------------------------------- /deps/bx/.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | matrix: 3 | include: 4 | - compiler: gcc 5 | os: linux 6 | - compiler: clang 7 | os: osx 8 | 9 | script: 10 | make test 11 | 12 | branches: 13 | only: 14 | - master 15 | 16 | notifications: 17 | email: false 18 | 19 | osx_image: 20 | xcode61 21 | -------------------------------------------------------------------------------- /deps/bx/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | project(bx) 3 | 4 | add_library(bx INTERFACE) 5 | 6 | set(BX_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/deps/bx/include) 7 | if (MSVC) 8 | set(COMPAT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include/compat/msvc) 9 | elseif(APPLE) 10 | set(COMPAT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include/compat/osx) 11 | endif() 12 | 13 | if(UNIX) 14 | set(COMPAT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include/compat/posix) 15 | endif() 16 | 17 | target_include_directories(bx INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include ${COMPAT_DIR}) 18 | -------------------------------------------------------------------------------- /deps/bx/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2010-2016 Branimir Karadzic. All rights reserved. 2 | 3 | https://github.com/bkaradzic/bx 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 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR 16 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 18 | SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 23 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 24 | OF THE POSSIBILITY OF SUCH DAMAGE. 25 | 26 | https://github.com/bkaradzic/bx/blob/master/LICENSE 27 | -------------------------------------------------------------------------------- /deps/bx/README.md: -------------------------------------------------------------------------------- 1 | bx 2 | == 3 | 4 | Base library. 5 | 6 | [![Build Status](https://travis-ci.org/bkaradzic/bx.svg?branch=master)](https://travis-ci.org/bkaradzic/bx) 7 | [![Build status](https://ci.appveyor.com/api/projects/status/edras3mltmoy31g5?svg=true)](https://ci.appveyor.com/project/bkaradzic/bx) 8 | [![License](https://img.shields.io/badge/license-BSD--2%20clause-blue.svg)](https://bkaradzic.github.io/bgfx/license.html) 9 | [![Join the chat at https://gitter.im/bkaradzic/bgfx](https://badges.gitter.im/bkaradzic/bgfx.svg)](https://gitter.im/bkaradzic/bgfx) 10 | 11 | Contact 12 | ------- 13 | 14 | [@bkaradzic](https://twitter.com/bkaradzic) 15 | 16 | Project page 17 | https://github.com/bkaradzic/bx 18 | 19 | [License (BSD 2-clause)](https://github.com/bkaradzic/bx/blob/master/LICENSE) 20 | ----------------------------------------------------------------------------- 21 | 22 | Copyright 2010-2016 Branimir Karadzic. All rights reserved. 23 | 24 | https://github.com/bkaradzic/bx 25 | 26 | Redistribution and use in source and binary forms, with or without 27 | modification, are permitted provided that the following conditions are met: 28 | 29 | 1. Redistributions of source code must retain the above copyright notice, 30 | this list of conditions and the following disclaimer. 31 | 32 | 2. Redistributions in binary form must reproduce the above copyright notice, 33 | this list of conditions and the following disclaimer in the documentation 34 | and/or other materials provided with the distribution. 35 | 36 | THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR 37 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 38 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 39 | EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 40 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 41 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 42 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 43 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 44 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 45 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 46 | -------------------------------------------------------------------------------- /deps/bx/include/bx/bx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #ifndef BX_H_HEADER_GUARD 7 | #define BX_H_HEADER_GUARD 8 | 9 | #include // uint32_t 10 | #include // size_t 11 | #include // memcpy 12 | 13 | #include "config.h" 14 | #include "macros.h" 15 | 16 | namespace bx 17 | { 18 | // http://cnicholson.net/2011/01/stupid-c-tricks-a-better-sizeof_array/ 19 | template char (&COUNTOF_REQUIRES_ARRAY_ARGUMENT(const T(&)[N]) )[N]; 20 | #define BX_COUNTOF(_x) sizeof(bx::COUNTOF_REQUIRES_ARRAY_ARGUMENT(_x) ) 21 | 22 | // Template for avoiding MSVC: C4127: conditional expression is constant 23 | template 24 | inline bool isEnabled() 25 | { 26 | return true; 27 | } 28 | 29 | template<> 30 | inline bool isEnabled() 31 | { 32 | return false; 33 | } 34 | #define BX_ENABLED(_x) bx::isEnabled() 35 | 36 | inline bool ignoreC4127(bool _x) 37 | { 38 | return _x; 39 | } 40 | #define BX_IGNORE_C4127(_x) bx::ignoreC4127(!!(_x) ) 41 | 42 | template 43 | inline void xchg(Ty& _a, Ty& _b) 44 | { 45 | Ty tmp = _a; _a = _b; _b = tmp; 46 | } 47 | 48 | /// Check if pointer is aligned. _align must be power of two. 49 | inline bool isPtrAligned(const void* _ptr, size_t _align) 50 | { 51 | union { const void* ptr; size_t addr; } un; 52 | un.ptr = _ptr; 53 | return 0 == (un.addr & (_align-1) ); 54 | } 55 | 56 | /// Scatter/gather memcpy. 57 | inline void memCopy(void* _dst, const void* _src, uint32_t _size, uint32_t _num, uint32_t _srcPitch, uint32_t _dstPitch) 58 | { 59 | const uint8_t* src = (const uint8_t*)_src; 60 | uint8_t* dst = (uint8_t*)_dst; 61 | 62 | for (uint32_t ii = 0; ii < _num; ++ii) 63 | { 64 | memcpy(dst, src, _size); 65 | src += _srcPitch; 66 | dst += _dstPitch; 67 | } 68 | } 69 | 70 | /// 71 | inline void gather(void* _dst, const void* _src, uint32_t _size, uint32_t _num, uint32_t _srcPitch) 72 | { 73 | memCopy(_dst, _src, _size, _num, _srcPitch, _size); 74 | } 75 | 76 | /// 77 | inline void scatter(void* _dst, const void* _src, uint32_t _size, uint32_t _num, uint32_t _dstPitch) 78 | { 79 | memCopy(_dst, _src, _size, _num, _size, _dstPitch); 80 | } 81 | 82 | } // namespace bx 83 | 84 | // Annoying C++0x stuff.. 85 | namespace std { namespace tr1 {}; using namespace tr1; } 86 | 87 | #endif // BX_H_HEADER_GUARD 88 | -------------------------------------------------------------------------------- /deps/bx/include/bx/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #ifndef BX_CONFIG_H_HEADER_GUARD 7 | #define BX_CONFIG_H_HEADER_GUARD 8 | 9 | #include "platform.h" 10 | 11 | #ifndef BX_CONFIG_ALLOCATOR_DEBUG 12 | # define BX_CONFIG_ALLOCATOR_DEBUG 0 13 | #endif // BX_CONFIG_DEBUG_ALLOC 14 | 15 | #ifndef BX_CONFIG_ALLOCATOR_CRT 16 | # define BX_CONFIG_ALLOCATOR_CRT 1 17 | #endif // BX_CONFIG_ALLOCATOR_CRT 18 | 19 | #ifndef BX_CONFIG_SPSCQUEUE_USE_MUTEX 20 | # define BX_CONFIG_SPSCQUEUE_USE_MUTEX 0 21 | #endif // BX_CONFIG_SPSCQUEUE_USE_MUTEX 22 | 23 | #ifndef BX_CONFIG_CRT_FILE_READER_WRITER 24 | # define BX_CONFIG_CRT_FILE_READER_WRITER !(BX_PLATFORM_NACL) 25 | #endif // BX_CONFIG_CRT_FILE_READER_WRITER 26 | 27 | #ifndef BX_CONFIG_CRT_PROCESS 28 | # define BX_CONFIG_CRT_PROCESS !(0 \ 29 | || BX_PLATFORM_EMSCRIPTEN \ 30 | || BX_PLATFORM_NACL \ 31 | || BX_PLATFORM_WINRT \ 32 | || BX_PLATFORM_XBOXONE \ 33 | ) 34 | #endif // BX_CONFIG_CRT_PROCESS 35 | 36 | #ifndef BX_CONFIG_SEMAPHORE_PTHREAD 37 | # define BX_CONFIG_SEMAPHORE_PTHREAD (BX_PLATFORM_OSX || BX_PLATFORM_IOS) 38 | #endif // BX_CONFIG_SEMAPHORE_PTHREAD 39 | 40 | #ifndef BX_CONFIG_SUPPORTS_THREADING 41 | # define BX_CONFIG_SUPPORTS_THREADING !(BX_PLATFORM_EMSCRIPTEN) 42 | #endif // BX_CONFIG_SUPPORTS_THREADING 43 | 44 | #endif // BX_CONFIG_H_HEADER_GUARD 45 | -------------------------------------------------------------------------------- /deps/bx/include/bx/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #ifndef BX_DEBUG_H_HEADER_GUARD 7 | #define BX_DEBUG_H_HEADER_GUARD 8 | 9 | #include "bx.h" 10 | 11 | #if BX_PLATFORM_ANDROID 12 | # include 13 | #elif BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE 14 | extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char* _str); 15 | #elif BX_PLATFORM_IOS || BX_PLATFORM_OSX 16 | # if defined(__OBJC__) 17 | # import 18 | # else 19 | # include 20 | extern "C" void NSLog(CFStringRef _format, ...); 21 | # endif // defined(__OBJC__) 22 | #elif 0 // BX_PLATFORM_EMSCRIPTEN 23 | # include 24 | #else 25 | # include 26 | #endif // BX_PLATFORM_WINDOWS 27 | 28 | namespace bx 29 | { 30 | #if BX_COMPILER_CLANG_ANALYZER 31 | inline __attribute__((analyzer_noreturn)) void debugBreak(); 32 | #endif // BX_COMPILER_CLANG_ANALYZER 33 | 34 | inline void debugBreak() 35 | { 36 | #if BX_COMPILER_MSVC 37 | __debugbreak(); 38 | #elif BX_CPU_ARM 39 | __builtin_trap(); 40 | // asm("bkpt 0"); 41 | #elif !BX_PLATFORM_NACL && BX_CPU_X86 && (BX_COMPILER_GCC || BX_COMPILER_CLANG) 42 | // NaCl doesn't like int 3: 43 | // NativeClient: NaCl module load failed: Validation failure. File violates Native Client safety rules. 44 | __asm__ ("int $3"); 45 | #else // cross platform implementation 46 | int* int3 = (int*)3L; 47 | *int3 = 3; 48 | #endif // BX 49 | } 50 | 51 | inline void debugOutput(const char* _out) 52 | { 53 | #if BX_PLATFORM_ANDROID 54 | # ifndef BX_ANDROID_LOG_TAG 55 | # define BX_ANDROID_LOG_TAG "" 56 | # endif // BX_ANDROID_LOG_TAG 57 | __android_log_write(ANDROID_LOG_DEBUG, BX_ANDROID_LOG_TAG, _out); 58 | #elif BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE 59 | OutputDebugStringA(_out); 60 | #elif BX_PLATFORM_IOS || BX_PLATFORM_OSX 61 | # if defined(__OBJC__) 62 | NSLog(@"%s", _out); 63 | # else 64 | NSLog(__CFStringMakeConstantString("%s"), _out); 65 | # endif // defined(__OBJC__) 66 | #elif 0 // BX_PLATFORM_EMSCRIPTEN 67 | emscripten_log(EM_LOG_CONSOLE, "%s", _out); 68 | #else 69 | fputs(_out, stdout); 70 | fflush(stdout); 71 | #endif // BX_PLATFORM_ 72 | } 73 | 74 | } // namespace bx 75 | 76 | #endif // BX_DEBUG_H_HEADER_GUARD 77 | -------------------------------------------------------------------------------- /deps/bx/include/bx/endian.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #ifndef BX_ENDIAN_H_HEADER_GUARD 7 | #define BX_ENDIAN_H_HEADER_GUARD 8 | 9 | #include "bx.h" 10 | 11 | namespace bx 12 | { 13 | inline uint16_t endianSwap(uint16_t _in) 14 | { 15 | return (_in>>8) | (_in<<8); 16 | } 17 | 18 | inline uint32_t endianSwap(uint32_t _in) 19 | { 20 | return (_in>>24) | (_in<<24) 21 | | ( (_in&0x00ff0000)>>8) | ( (_in&0x0000ff00)<<8) 22 | ; 23 | } 24 | 25 | inline uint64_t endianSwap(uint64_t _in) 26 | { 27 | return (_in>>56) | (_in<<56) 28 | | ( (_in&UINT64_C(0x00ff000000000000) )>>40) | ( (_in&UINT64_C(0x000000000000ff00) )<<40) 29 | | ( (_in&UINT64_C(0x0000ff0000000000) )>>24) | ( (_in&UINT64_C(0x0000000000ff0000) )<<24) 30 | | ( (_in&UINT64_C(0x000000ff00000000) )>>8) | ( (_in&UINT64_C(0x00000000ff000000) )<<8) 31 | ; 32 | } 33 | 34 | inline int16_t endianSwap(int16_t _in) 35 | { 36 | return (int16_t)endianSwap( (uint16_t)_in); 37 | } 38 | 39 | inline int32_t endianSwap(int32_t _in) 40 | { 41 | return (int32_t)endianSwap( (uint32_t)_in); 42 | } 43 | 44 | inline int64_t endianSwap(int64_t _in) 45 | { 46 | return (int64_t)endianSwap( (uint64_t)_in); 47 | } 48 | 49 | /// Input argument is encoded as little endian, convert it if neccessary 50 | /// depending on host CPU endianess. 51 | template 52 | inline Ty toLittleEndian(const Ty _in) 53 | { 54 | #if BX_CPU_ENDIAN_BIG 55 | return endianSwap(_in); 56 | #else 57 | return _in; 58 | #endif // BX_CPU_ENDIAN_BIG 59 | } 60 | 61 | /// Input argument is encoded as big endian, convert it if neccessary 62 | /// depending on host CPU endianess. 63 | template 64 | inline Ty toBigEndian(const Ty _in) 65 | { 66 | #if BX_CPU_ENDIAN_LITTLE 67 | return endianSwap(_in); 68 | #else 69 | return _in; 70 | #endif // BX_CPU_ENDIAN_LITTLE 71 | } 72 | 73 | /// If _littleEndian is true, converts input argument to from little endian 74 | /// to host CPU endiness. 75 | template 76 | inline Ty toHostEndian(const Ty _in, bool _fromLittleEndian) 77 | { 78 | #if BX_CPU_ENDIAN_LITTLE 79 | return _fromLittleEndian ? _in : endianSwap(_in); 80 | #else 81 | return _fromLittleEndian ? endianSwap(_in) : _in; 82 | #endif // BX_CPU_ENDIAN_LITTLE 83 | } 84 | 85 | } // namespace bx 86 | 87 | #endif // BX_ENDIAN_H_HEADER_GUARD 88 | -------------------------------------------------------------------------------- /deps/bx/include/bx/error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #ifndef BX_ERROR_H_HEADER_GUARD 7 | #define BX_ERROR_H_HEADER_GUARD 8 | 9 | #include "bx.h" 10 | 11 | #define BX_ERROR_SET(_ptr, _result, _msg) \ 12 | BX_MACRO_BLOCK_BEGIN \ 13 | BX_TRACE("Error %d: %s", _result.code, "" _msg); \ 14 | _ptr->setError(_result, "" _msg); \ 15 | BX_MACRO_BLOCK_END 16 | 17 | #define BX_ERROR_USE_TEMP_WHEN_NULL(_ptr) \ 18 | const bx::Error tmpError; /* It should not be used directly! */ \ 19 | _ptr = NULL == _ptr ? const_cast(&tmpError) : _ptr 20 | 21 | #define BX_ERROR_SCOPE(_ptr) \ 22 | BX_ERROR_USE_TEMP_WHEN_NULL(_ptr); \ 23 | bx::ErrorScope bxErrorScope(const_cast(&tmpError) ) 24 | 25 | #define BX_ERROR_RESULT(_err, _code) \ 26 | BX_STATIC_ASSERT(_code != 0, "ErrorCode 0 is reserved!"); \ 27 | static const bx::ErrorResult _err = { _code } 28 | 29 | namespace bx 30 | { 31 | /// 32 | struct ErrorResult 33 | { 34 | uint32_t code; 35 | }; 36 | 37 | /// 38 | class Error 39 | { 40 | BX_CLASS(Error 41 | , NO_COPY 42 | , NO_ASSIGNMENT 43 | ); 44 | 45 | public: 46 | Error() 47 | : m_code(0) 48 | { 49 | } 50 | 51 | void setError(ErrorResult _errorResult, const char* _msg) 52 | { 53 | BX_CHECK(0 != _errorResult.code, "Invalid ErrorResult passed to setError!"); 54 | 55 | if (!isOk() ) 56 | { 57 | return; 58 | } 59 | 60 | m_code = _errorResult.code; 61 | m_msg = _msg; 62 | } 63 | 64 | bool isOk() const 65 | { 66 | return 0 == m_code; 67 | } 68 | 69 | ErrorResult get() const 70 | { 71 | ErrorResult result = { m_code }; 72 | return result; 73 | } 74 | 75 | bool operator==(ErrorResult _rhs) const 76 | { 77 | return _rhs.code == m_code; 78 | } 79 | 80 | private: 81 | const char* m_msg; 82 | uint32_t m_code; 83 | }; 84 | 85 | /// 86 | class ErrorScope 87 | { 88 | BX_CLASS(ErrorScope 89 | , NO_COPY 90 | , NO_ASSIGNMENT 91 | ); 92 | 93 | public: 94 | ErrorScope(Error* _err) 95 | : m_err(_err) 96 | { 97 | BX_CHECK(NULL != _err, "_err can't be NULL"); 98 | } 99 | 100 | ~ErrorScope() 101 | { 102 | BX_CHECK(m_err->isOk(), "Error: %d", m_err->get().code); 103 | } 104 | 105 | private: 106 | Error* m_err; 107 | }; 108 | 109 | } // namespace bx 110 | 111 | #endif // BX_ERROR_H_HEADER_GUARD 112 | -------------------------------------------------------------------------------- /deps/bx/include/bx/float4_t.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #ifndef BX_FLOAT4_T_H_HEADER_GUARD 7 | #define BX_FLOAT4_T_H_HEADER_GUARD 8 | 9 | #include "bx.h" 10 | 11 | #define BX_FLOAT4_FORCE_INLINE BX_FORCE_INLINE 12 | #define BX_FLOAT4_INLINE static inline 13 | 14 | #if defined(__SSE2__) || (BX_COMPILER_MSVC && (BX_ARCH_64BIT || _M_IX86_FP >= 2) ) 15 | # include "float4_sse.h" 16 | #elif defined(__ARM_NEON__) && !BX_COMPILER_CLANG 17 | # include "float4_neon.h" 18 | #elif BX_COMPILER_CLANG \ 19 | && !BX_PLATFORM_EMSCRIPTEN \ 20 | && !BX_PLATFORM_IOS \ 21 | && BX_CLANG_HAS_EXTENSION(attribute_ext_vector_type) 22 | # include "float4_langext.h" 23 | #else 24 | # ifndef BX_FLOAT4_WARN_REFERENCE_IMPL 25 | # define BX_FLOAT4_WARN_REFERENCE_IMPL 0 26 | # endif // BX_FLOAT4_WARN_REFERENCE_IMPL 27 | 28 | # if BX_FLOAT4_WARN_REFERENCE_IMPL 29 | # pragma message("************************************\nUsing SIMD reference implementation!\n************************************") 30 | # endif // BX_FLOAT4_WARN_REFERENCE_IMPL 31 | 32 | # include "float4_ref.h" 33 | #endif // 34 | 35 | #endif // BX_FLOAT4_T_H_HEADER_GUARD 36 | -------------------------------------------------------------------------------- /deps/bx/include/bx/foreach.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #ifndef BX_FOREACH_H_HEADER_GUARD 7 | #define BX_FOREACH_H_HEADER_GUARD 8 | 9 | #include "bx.h" 10 | 11 | namespace bx 12 | { 13 | namespace foreach_ns 14 | { 15 | struct ContainerBase 16 | { 17 | }; 18 | 19 | template 20 | class Container : public ContainerBase 21 | { 22 | public: 23 | inline Container(const Ty& _container) 24 | : m_container(_container) 25 | , m_break(0) 26 | , m_it( _container.begin() ) 27 | , m_itEnd( _container.end() ) 28 | { 29 | } 30 | 31 | inline bool condition() const 32 | { 33 | return (!m_break++ && m_it != m_itEnd); 34 | } 35 | 36 | const Ty& m_container; 37 | mutable int m_break; 38 | mutable typename Ty::const_iterator m_it; 39 | mutable typename Ty::const_iterator m_itEnd; 40 | }; 41 | 42 | template 43 | inline Ty* pointer(const Ty&) 44 | { 45 | return 0; 46 | } 47 | 48 | template 49 | inline Container containerNew(const Ty& _container) 50 | { 51 | return Container(_container); 52 | } 53 | 54 | template 55 | inline const Container* container(const ContainerBase* _base, const Ty*) 56 | { 57 | return static_cast*>(_base); 58 | } 59 | } // namespace foreach_ns 60 | 61 | #define foreach(_variable, _container) \ 62 | for (const bx::foreach_ns::ContainerBase &__temp_container__ = bx::foreach_ns::containerNew(_container); \ 63 | bx::foreach_ns::container(&__temp_container__, true ? 0 : bx::foreach_ns::pointer(_container) )->condition(); \ 64 | ++bx::foreach_ns::container(&__temp_container__, true ? 0 : bx::foreach_ns::pointer(_container) )->m_it) \ 65 | for (_variable = *container(&__temp_container__, true ? 0 : bx::foreach_ns::pointer(_container) )->m_it; \ 66 | bx::foreach_ns::container(&__temp_container__, true ? 0 : bx::foreach_ns::pointer(_container) )->m_break; \ 67 | --bx::foreach_ns::container(&__temp_container__, true ? 0 : bx::foreach_ns::pointer(_container) )->m_break) 68 | 69 | } // namespace bx 70 | 71 | #endif // BX_FOREACH_H_HEADER_GUARD 72 | -------------------------------------------------------------------------------- /deps/bx/include/bx/maputil.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #ifndef BX_MAPUTIL_H_HEADER_GUARD 7 | #define BX_MAPUTIL_H_HEADER_GUARD 8 | 9 | #include "bx.h" 10 | 11 | namespace bx 12 | { 13 | template 14 | typename MapType::iterator mapInsertOrUpdate(MapType& _map, const typename MapType::key_type& _key, const typename MapType::mapped_type& _value) 15 | { 16 | typename MapType::iterator it = _map.lower_bound(_key); 17 | if (it != _map.end() 18 | && !_map.key_comp()(_key, it->first) ) 19 | { 20 | it->second = _value; 21 | return it; 22 | } 23 | 24 | typename MapType::value_type pair(_key, _value); 25 | return _map.insert(it, pair); 26 | } 27 | 28 | template 29 | bool mapRemove(MapType& _map, const typename MapType::value_type::first_type& _first) 30 | { 31 | typename MapType::const_iterator it = _map.find(_first); 32 | if (it != _map.end() ) 33 | { 34 | _map.erase(it); 35 | return true; 36 | } 37 | 38 | return false; 39 | } 40 | 41 | template 42 | bool mapRemove(MapType& _map, const typename MapType::value_type::second_type& _second) 43 | { 44 | for (typename MapType::const_iterator it = _map.begin(), itEnd = _map.end(); it != itEnd; ++it) 45 | { 46 | if (it->second == _second) 47 | { 48 | _map.erase(it); 49 | return true; 50 | } 51 | } 52 | 53 | return false; 54 | } 55 | 56 | } // namespace bx 57 | 58 | #endif // BX_MAPUTIL_H_HEADER_GUARD 59 | -------------------------------------------------------------------------------- /deps/bx/include/bx/mpscqueue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #ifndef BX_MPSCQUEUE_H_HEADER_GUARD 7 | #define BX_MPSCQUEUE_H_HEADER_GUARD 8 | 9 | #include "spscqueue.h" 10 | 11 | namespace bx 12 | { 13 | template 14 | class MpScUnboundedQueue 15 | { 16 | BX_CLASS(MpScUnboundedQueue 17 | , NO_COPY 18 | , NO_ASSIGNMENT 19 | ); 20 | 21 | public: 22 | MpScUnboundedQueue() 23 | { 24 | } 25 | 26 | ~MpScUnboundedQueue() 27 | { 28 | } 29 | 30 | void push(Ty* _ptr) // producer only 31 | { 32 | LwMutexScope lock(m_write); 33 | m_queue.push(_ptr); 34 | } 35 | 36 | Ty* peek() // consumer only 37 | { 38 | return m_queue.peek(); 39 | } 40 | 41 | Ty* pop() // consumer only 42 | { 43 | return m_queue.pop(); 44 | } 45 | 46 | private: 47 | LwMutex m_write; 48 | SpScUnboundedQueue m_queue; 49 | }; 50 | 51 | template 52 | class MpScUnboundedBlockingQueue 53 | { 54 | BX_CLASS(MpScUnboundedBlockingQueue 55 | , NO_COPY 56 | , NO_ASSIGNMENT 57 | ); 58 | 59 | public: 60 | MpScUnboundedBlockingQueue() 61 | { 62 | } 63 | 64 | ~MpScUnboundedBlockingQueue() 65 | { 66 | } 67 | 68 | void push(Ty* _ptr) // producer only 69 | { 70 | m_queue.push(_ptr); 71 | m_sem.post(); 72 | } 73 | 74 | Ty* pop() // consumer only 75 | { 76 | m_sem.wait(); 77 | return m_queue.pop(); 78 | } 79 | 80 | private: 81 | MpScUnboundedQueue m_queue; 82 | Semaphore m_sem; 83 | }; 84 | 85 | } // namespace bx 86 | 87 | #endif // BX_MPSCQUEUE_H_HEADER_GUARD 88 | -------------------------------------------------------------------------------- /deps/bx/include/bx/process.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #ifndef BX_PROCESS_H_HEADER_GUARD 7 | #define BX_PROCESS_H_HEADER_GUARD 8 | 9 | #include "string.h" 10 | #include "uint32_t.h" 11 | 12 | #if BX_PLATFORM_LINUX || BX_PLATFORM_HURD 13 | # include 14 | #endif // BX_PLATFORM_LINUX || BX_PLATFORM_HURD 15 | 16 | namespace bx 17 | { 18 | /// 19 | inline void* exec(const char* const* _argv) 20 | { 21 | #if BX_PLATFORM_LINUX || BX_PLATFORM_HURD 22 | pid_t pid = fork(); 23 | 24 | if (0 == pid) 25 | { 26 | int result = execvp(_argv[0], const_cast(&_argv[1]) ); 27 | BX_UNUSED(result); 28 | return NULL; 29 | } 30 | 31 | return (void*)uintptr_t(pid); 32 | #elif BX_PLATFORM_WINDOWS 33 | STARTUPINFO si; 34 | memset(&si, 0, sizeof(STARTUPINFO) ); 35 | si.cb = sizeof(STARTUPINFO); 36 | 37 | PROCESS_INFORMATION pi; 38 | memset(&pi, 0, sizeof(PROCESS_INFORMATION) ); 39 | 40 | int32_t total = 0; 41 | for (uint32_t ii = 0; NULL != _argv[ii]; ++ii) 42 | { 43 | total += (int32_t)strlen(_argv[ii]) + 1; 44 | } 45 | 46 | char* temp = (char*)alloca(total); 47 | int32_t len = 0; 48 | for(uint32_t ii = 0; NULL != _argv[ii]; ++ii) 49 | { 50 | len += snprintf(&temp[len], bx::uint32_imax(0, total-len) 51 | , "%s " 52 | , _argv[ii] 53 | ); 54 | } 55 | 56 | bool ok = CreateProcessA(_argv[0] 57 | , temp 58 | , NULL 59 | , NULL 60 | , false 61 | , 0 62 | , NULL 63 | , NULL 64 | , &si 65 | , &pi 66 | ); 67 | if (ok) 68 | { 69 | return pi.hProcess; 70 | } 71 | 72 | return NULL; 73 | #else 74 | return NULL; 75 | #endif // BX_PLATFORM_LINUX || BX_PLATFORM_HURD 76 | } 77 | 78 | } // namespace bx 79 | 80 | #endif // BX_PROCESS_H_HEADER_GUARD 81 | -------------------------------------------------------------------------------- /deps/bx/include/bx/simd256_avx.inl: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #ifndef BX_SIMD256_AVX_H_HEADER_GUARD 7 | #define BX_SIMD256_AVX_H_HEADER_GUARD 8 | 9 | #endif // BX_SIMD256_AVX_H_HEADER_GUARD 10 | -------------------------------------------------------------------------------- /deps/bx/include/bx/simd256_ref.inl: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #ifndef BX_SIMD256_REF_H_HEADER_GUARD 7 | #define BX_SIMD256_REF_H_HEADER_GUARD 8 | 9 | #endif // BX_SIMD256_REF_H_HEADER_GUARD 10 | -------------------------------------------------------------------------------- /deps/bx/include/bx/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #ifndef BX_TIMER_H_HEADER_GUARD 7 | #define BX_TIMER_H_HEADER_GUARD 8 | 9 | #include "bx.h" 10 | 11 | #if BX_PLATFORM_ANDROID || BX_PLATFORM_LINUX 12 | # include // clock, clock_gettime 13 | #elif BX_PLATFORM_EMSCRIPTEN 14 | # include 15 | #elif BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT 16 | # define WIN32_LEAN_AND_MEAN 17 | # include 18 | # undef WIN32_LEAN_AND_MEAN 19 | #elif BX_PLATFORM_OSX || BX_PLATFORM_IOS 20 | # include 21 | #else 22 | # include // gettimeofday 23 | #endif // BX_PLATFORM_ 24 | 25 | namespace bx 26 | { 27 | inline int64_t getHPCounter() 28 | { 29 | #if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT 30 | LARGE_INTEGER li; 31 | // Performance counter value may unexpectedly leap forward 32 | // http://support.microsoft.com/kb/274323 33 | QueryPerformanceCounter(&li); 34 | return li.QuadPart; 35 | #elif BX_PLATFORM_ANDROID || BX_PLATFORM_LINUX 36 | struct timespec now; 37 | clock_gettime(CLOCK_MONOTONIC, &now); 38 | int64_t i64 = now.tv_sec*INT64_C(1000000000) + now.tv_nsec; 39 | return i64; 40 | #elif BX_PLATFORM_OSX || BX_PLATFORM_IOS 41 | return mach_absolute_time(); 42 | #elif BX_PLATFORM_EMSCRIPTEN 43 | return int64_t(1000.0f * emscripten_get_now() ); 44 | #else 45 | struct timeval now; 46 | gettimeofday(&now, 0); 47 | int64_t i64 = now.tv_sec*INT64_C(1000000) + now.tv_usec; 48 | return i64; 49 | #endif // BX_PLATFORM_ 50 | } 51 | 52 | inline double getHPFrequency() 53 | { 54 | #if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT 55 | LARGE_INTEGER li; 56 | QueryPerformanceFrequency(&li); 57 | return (double)li.QuadPart; 58 | #elif BX_PLATFORM_ANDROID || BX_PLATFORM_LINUX 59 | timespec res; 60 | clock_getres(CLOCK_MONOTONIC, &res); 61 | return (double)res.tv_nsec * 1e9; 62 | #elif BX_PLATFORM_OSX || BX_PLATFORM_IOS 63 | struct mach_timebase_info tmbase; 64 | mach_timebase_info(&tmbase); 65 | return ((double)tmbase.numer / (double)tmbase.denom)*1e9; 66 | #elif BX_PLATFORM_EMSCRIPTEN 67 | return INT64_C(1000000); 68 | #else 69 | return INT64_C(1000000); 70 | #endif // BX_PLATFORM_ 71 | } 72 | 73 | } // namespace bx 74 | 75 | #endif // BX_TIMER_H_HEADER_GUARD 76 | -------------------------------------------------------------------------------- /deps/bx/include/bx/tokenizecmd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #ifndef BX_TOKENIZE_CMD_H_HEADER_GUARD 7 | #define BX_TOKENIZE_CMD_H_HEADER_GUARD 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace bx 14 | { 15 | // Reference: 16 | // http://msdn.microsoft.com/en-us/library/a1y7w461.aspx 17 | static inline const char* tokenizeCommandLine(const char* _commandLine, char* _buffer, uint32_t& _bufferSize, int& _argc, char* _argv[], int _maxArgvs, char _term = '\0') 18 | { 19 | int argc = 0; 20 | const char* curr = _commandLine; 21 | char* currOut = _buffer; 22 | char term = ' '; 23 | bool sub = false; 24 | 25 | enum ParserState 26 | { 27 | SkipWhitespace, 28 | SetTerm, 29 | Copy, 30 | Escape, 31 | End, 32 | }; 33 | 34 | ParserState state = SkipWhitespace; 35 | 36 | while ('\0' != *curr 37 | && _term != *curr 38 | && argc < _maxArgvs) 39 | { 40 | switch (state) 41 | { 42 | case SkipWhitespace: 43 | for (; isspace(*curr); ++curr) {}; // skip whitespace 44 | state = SetTerm; 45 | break; 46 | 47 | case SetTerm: 48 | if ('"' == *curr) 49 | { 50 | term = '"'; 51 | ++curr; // skip begining quote 52 | } 53 | else 54 | { 55 | term = ' '; 56 | } 57 | 58 | _argv[argc] = currOut; 59 | ++argc; 60 | 61 | state = Copy; 62 | break; 63 | 64 | case Copy: 65 | if ('\\' == *curr) 66 | { 67 | state = Escape; 68 | } 69 | else if ('"' == *curr 70 | && '"' != term) 71 | { 72 | sub = !sub; 73 | } 74 | else if (isspace(*curr) && !sub) 75 | { 76 | state = End; 77 | } 78 | else if (term != *curr || sub) 79 | { 80 | *currOut = *curr; 81 | ++currOut; 82 | } 83 | else 84 | { 85 | state = End; 86 | } 87 | ++curr; 88 | break; 89 | 90 | case Escape: 91 | { 92 | const char* start = --curr; 93 | for (; '\\' == *curr; ++curr) {}; 94 | 95 | if ('"' != *curr) 96 | { 97 | int count = (int)(curr-start); 98 | 99 | curr = start; 100 | for (int ii = 0; ii < count; ++ii) 101 | { 102 | *currOut = *curr; 103 | ++currOut; 104 | ++curr; 105 | } 106 | } 107 | else 108 | { 109 | curr = start+1; 110 | *currOut = *curr; 111 | ++currOut; 112 | ++curr; 113 | } 114 | } 115 | state = Copy; 116 | break; 117 | 118 | case End: 119 | *currOut = '\0'; 120 | ++currOut; 121 | state = SkipWhitespace; 122 | break; 123 | } 124 | } 125 | 126 | *currOut = '\0'; 127 | if (0 < argc 128 | && '\0' == _argv[argc-1][0]) 129 | { 130 | --argc; 131 | } 132 | 133 | _bufferSize = (uint32_t)(currOut - _buffer); 134 | _argc = argc; 135 | 136 | if ('\0' != *curr) 137 | { 138 | ++curr; 139 | } 140 | 141 | return curr; 142 | } 143 | 144 | } // namespace bx 145 | 146 | #endif // TOKENIZE_CMD_H_HEADER_GUARD 147 | -------------------------------------------------------------------------------- /deps/bx/include/bxx/inifile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "bx/crtimpl.h" 4 | #include "bx/string.h" 5 | 6 | namespace bx 7 | { 8 | typedef void (*PfnIniKeyValueCallback)(const char* key, const char* value, void* userParam); 9 | 10 | static bool parseIniFile(const char* iniFilepath, PfnIniKeyValueCallback callback, void* userParam, 11 | bx::AllocatorI* alloc) 12 | { 13 | assert(alloc); 14 | 15 | bx::CrtFileReader reader; 16 | bx::Error err; 17 | if (!reader.open(iniFilepath, &err)) 18 | return false; 19 | 20 | int32_t size = (int32_t)reader.seek(0, bx::Whence::End); 21 | char* contents = (char*)BX_ALLOC(alloc, size + 1); 22 | if (!contents) { 23 | reader.close(); 24 | return false; 25 | } 26 | 27 | reader.seek(0, bx::Whence::Begin); 28 | reader.read(contents, size, &err); 29 | contents[size] = 0; 30 | reader.close(); 31 | 32 | char line[256]; 33 | const char* lineBegin = contents; 34 | while (true) { 35 | const char* lineEnd = bx::streol(lineBegin); 36 | size_t lineSize = (size_t)(lineEnd - lineBegin); 37 | char* equal; 38 | const char* nextLine; 39 | 40 | if (lineSize != 0) { 41 | bx::strlcpy(line, lineBegin, bx::uint32_min((uint32_t)lineSize+1, sizeof(line) - 1)); 42 | } else { 43 | bx::strlcpy(line, lineBegin, sizeof(line)); 44 | } 45 | 46 | if (line[0] == '#') { 47 | goto skipToNextLine; 48 | } 49 | 50 | equal = strchr(line, '='); 51 | if (equal) { 52 | char key[256]; 53 | char value[256]; 54 | 55 | *equal = 0; 56 | bx::strlcpy(key, line, sizeof(key)); 57 | bx::strlcpy(value, equal + 1, sizeof(value)); 58 | 59 | callback(bx::strws(key), bx::strws(value), userParam); 60 | } 61 | 62 | skipToNextLine: 63 | nextLine = bx::strnl(lineBegin); // Proceed to next line 64 | if (nextLine == lineBegin) 65 | break; 66 | lineBegin = nextLine; 67 | } 68 | 69 | BX_FREE(alloc, contents); 70 | 71 | return true; 72 | } 73 | 74 | } // namespace: bx -------------------------------------------------------------------------------- /deps/bx/include/bxx/linear_allocator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../bx/allocator.h" 4 | 5 | namespace bx 6 | { 7 | class LinearAllocator : public AllocatorI 8 | { 9 | BX_CLASS(LinearAllocator 10 | , NO_COPY 11 | , NO_ASSIGNMENT 12 | ); 13 | public: 14 | LinearAllocator(void* _ptr, size_t _size) 15 | { 16 | m_offset = 0; 17 | m_size = _size; 18 | m_ptr = (uint8_t*)_ptr; 19 | } 20 | 21 | void init(void* _ptr, size_t _size) 22 | { 23 | m_offset = 0; 24 | m_size = _size; 25 | m_ptr = (uint8_t*)_ptr; 26 | } 27 | 28 | virtual ~LinearAllocator() 29 | { 30 | } 31 | 32 | virtual void* realloc(void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line) BX_OVERRIDE 33 | { 34 | if (_size) { 35 | if (m_offset + _size > m_size) 36 | return nullptr; 37 | 38 | void* p = m_ptr + m_offset; 39 | m_offset += _size; 40 | return p; 41 | } 42 | return nullptr; 43 | } 44 | 45 | private: 46 | size_t m_offset; 47 | size_t m_size; 48 | uint8_t* m_ptr; 49 | }; 50 | } -------------------------------------------------------------------------------- /deps/bx/include/bxx/linked_list.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace bx 4 | { 5 | template 6 | struct ListNode 7 | { 8 | ListNode* next; 9 | ListNode* prev; 10 | Ty data; 11 | 12 | ListNode() 13 | { 14 | next = prev = nullptr; 15 | } 16 | }; 17 | 18 | template 19 | void addListNode(ListNode** _ref, ListNode* _node, const Ty& _data) 20 | { 21 | _node->next = *_ref; 22 | _node->prev = nullptr; 23 | if (*_ref) 24 | (*_ref)->prev = _node; 25 | *_ref = _node; 26 | _node->data = _data; 27 | } 28 | 29 | template 30 | void addListNodeToEnd(ListNode** _ref, ListNode* _node, const Ty& _data) 31 | { 32 | if (*_ref) { 33 | // Move to last node 34 | ListNode* last = *_ref; 35 | while (last->next) 36 | last = last->next; 37 | last->next = _node; 38 | _node->prev = last; 39 | _node->next = nullptr; 40 | } else { 41 | *_ref = _node; 42 | _node->prev = _node->next = nullptr; 43 | } 44 | 45 | _node->data = _data; 46 | } 47 | 48 | template 49 | void removeListNode(ListNode** _ref, ListNode* _node) 50 | { 51 | if (_node->next) 52 | _node->next->prev = _node->prev; 53 | if (_node->prev) 54 | _node->prev->next = _node->next; 55 | if (*_ref == _node) 56 | *_ref = _node->next; 57 | _node->next = _node->prev = nullptr; 58 | } 59 | 60 | template 61 | void insertListNode(ListNode* _insertAfter, ListNode* _node, const Ty& _data) 62 | { 63 | if (_insertAfter->next) 64 | _insertAfter->next->prev = _node; 65 | _node->prev = _insertAfter; 66 | _node->next = _insertAfter->next; 67 | _insertAfter->next = _node; 68 | _node->data = _data; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /deps/bx/include/bxx/proxy_allocator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../bx/allocator.h" 4 | #include "../bx/platform.h" 5 | #include "../bx/cpu.h" 6 | 7 | namespace bx 8 | { 9 | // Proxy allocator routes all allocations to other allocators 10 | // Saves an Id and sizes per allocation 11 | class ProxyAllocator : public AllocatorI 12 | { 13 | BX_CLASS(ProxyAllocator 14 | , NO_COPY 15 | , NO_ASSIGNMENT 16 | ); 17 | private: 18 | uint32_t m_id; 19 | AllocatorI* m_alloc; 20 | volatile uintptr_t m_size; 21 | 22 | public: 23 | ProxyAllocator(AllocatorI* _alloc, uint32_t _id) 24 | { 25 | m_id = _id; 26 | m_size = 0; 27 | m_alloc = _alloc; 28 | } 29 | 30 | virtual ~ProxyAllocator() 31 | { 32 | } 33 | 34 | uint32_t getId() const 35 | { 36 | return m_id; 37 | } 38 | 39 | size_t getAllocatedSize() const 40 | { 41 | return m_size; 42 | } 43 | 44 | virtual void* realloc(void* _ptr, size_t _size, size_t _align, const char* _file, uint32_t _line) BX_OVERRIDE 45 | { 46 | if (_size == 0) { 47 | // free 48 | uint8_t* ptr = (uint8_t*)_ptr - sizeof(size_t); 49 | size_t curSize = *((size_t*)ptr); 50 | bx::atomicFetchAndSub(&m_size, curSize); 51 | m_alloc->realloc(ptr, 0, _align, _file, _line); 52 | return NULL; 53 | } else if (_ptr == NULL) { 54 | // malloc 55 | uint8_t* p = (uint8_t*)m_alloc->realloc(NULL, _size + sizeof(size_t), _align, _file, _line); 56 | if (p) { 57 | *((size_t*)p) = _size; // save size 58 | bx::atomicAddAndFetch(&m_size, _size); 59 | return p + sizeof(size_t); 60 | } else { 61 | return NULL; 62 | } 63 | } else { 64 | // realloc 65 | uint8_t* ptr = (uint8_t*)_ptr - sizeof(size_t); 66 | size_t curSize = *((size_t*)ptr); 67 | bx::atomicFetchAndSub(&m_size, curSize); 68 | uint8_t* newp = (uint8_t*)m_alloc->realloc(ptr, _size + sizeof(size_t), _align, _file, _line); 69 | if (newp) { 70 | *((size_t*)newp) = _size; // save size 71 | bx::atomicAddAndFetch(&m_size, _size); 72 | return newp + sizeof(size_t); 73 | } else { 74 | return NULL; 75 | } 76 | } 77 | } 78 | }; 79 | } // namespace bx -------------------------------------------------------------------------------- /deps/bx/include/bxx/random.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace bx 7 | { 8 | inline void randomSeed() 9 | { 10 | srand((uint32_t)time(nullptr)); 11 | } 12 | 13 | inline int randomInt(int _min, int _max) 14 | { 15 | int r = rand(); 16 | return ((r % (_max - _min + 1)) + _min); 17 | } 18 | 19 | inline double randomFloat(double _min, double _max) 20 | { 21 | double r = (double)rand() / RAND_MAX; 22 | return r*(_max - _min) + _min; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /deps/bx/include/bxx/stack.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "bx/allocator.h" 4 | 5 | namespace bx 6 | { 7 | template 8 | struct StackNode 9 | { 10 | StackNode* down; 11 | Ty data; 12 | 13 | StackNode() 14 | { 15 | down = nullptr; 16 | } 17 | }; 18 | 19 | template 20 | void pushStackNode(StackNode** _ref, StackNode* _node, const Ty& _data) 21 | { 22 | _node->down = *_ref; 23 | *_ref = _node; 24 | _node->data = _data; 25 | } 26 | 27 | template 28 | Ty popStack(StackNode** _ref) 29 | { 30 | StackNode* node = *_ref; 31 | if (node) { 32 | *_ref = node->down; 33 | node->down = nullptr; 34 | } 35 | return node->data; 36 | } 37 | 38 | template 39 | Ty peekStack(StackNode* _ref) 40 | { 41 | return _ref->data; 42 | } 43 | } // namespace bx -------------------------------------------------------------------------------- /deps/bx/include/bxx/terminal_colors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef _WIN32 4 | # define TERM_RESET "" 5 | # define TERM_RED "" 6 | # define TERM_YELLOW "" 7 | # define TERM_CYAN "" 8 | # define TERM_RED_BOLD "" 9 | # define TERM_YELLOW_BOLD "" 10 | # define TERM_CYAN_BOLD "" 11 | # define TERM_DIM "" 12 | # define TERM_GREEN "" 13 | # define TERM_GREEN_BOLD "" 14 | # define TERM_MAGENTA "" 15 | # define TERM_WHITE "" 16 | # define TERM_BLACK "" 17 | #else 18 | # define TERM_RESET "\033[0m" 19 | # define TERM_RED "\033[31m" 20 | # define TERM_YELLOW "\033[33m" 21 | # define TERM_CYAN "\033[36m" 22 | # define TERM_GREEN "\033[32m" 23 | # define TERM_RED_BOLD "\033[1m\033[31m" 24 | # define TERM_YELLOW_BOLD "\033[1m\033[33m" 25 | # define TERM_CYAN_BOLD "\033[1m\033[36m" 26 | # define TERM_GREEN_BOLD "\033[1m\033[32m" 27 | # define TERM_DIM "\033[2m" 28 | # define TERM_MAGENTA "\033[35m" 29 | # define TERM_WHITE "\033[37m" 30 | # define TERM_BLACK "\033[30m" 31 | #endif 32 | -------------------------------------------------------------------------------- /deps/bx/include/bxx/timer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../bx/timer.h" 4 | 5 | namespace bx 6 | { 7 | class Timer 8 | { 9 | public: 10 | Timer(); 11 | 12 | void start(); 13 | double read(); 14 | double readDelta(); 15 | 16 | private: 17 | int64_t m_freq; 18 | int64_t m_last; 19 | int64_t m_start; 20 | double m_toMs; 21 | }; 22 | 23 | // 24 | inline Timer::Timer() 25 | { 26 | m_freq = bx::getHPFrequency(); 27 | m_toMs = 1000.0/(double)m_freq; 28 | m_last = 0; 29 | m_start = 0; 30 | } 31 | 32 | inline void Timer::start() 33 | { 34 | m_start = bx::getHPCounter(); 35 | m_last = m_start; 36 | } 37 | 38 | inline double Timer::read() 39 | { 40 | int64_t now = bx::getHPCounter(); 41 | return double(now - m_start)*m_toMs; 42 | } 43 | 44 | inline double Timer::readDelta() 45 | { 46 | int64_t now = bx::getHPCounter(); 47 | double d = double(now - m_last)*m_toMs; 48 | m_last = now; 49 | return d; 50 | } 51 | } -------------------------------------------------------------------------------- /deps/bx/include/bxx/uuid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "bx/platform.h" 4 | #include 5 | 6 | namespace bx 7 | { 8 | 9 | #if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_WINRT || BX_PLATFORM_XBOXONE 10 | # include 11 | static void generateUUID(char uuidStr[37]) 12 | { 13 | UUID guid; 14 | UuidCreate(&guid); 15 | 16 | bx::snprintf(uuidStr, 37, "%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX", 17 | guid.Data1, guid.Data2, guid.Data3, 18 | guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], 19 | guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]); 20 | } 21 | #elif BX_PLATFORM_OSX || BX_PLATFORM_IOS 22 | # include 23 | static void generateUUID(char uuidStr[37]) 24 | { 25 | auto guid = CFUUIDCreate(nullptr); 26 | auto bytes = CFUUIDGetUUIDBytes(guid); 27 | CFRelease(guid); 28 | 29 | bx::snprintf(uuidStr, 37, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", 30 | bytes.byte0, bytes.byte1, bytes.byte2, bytes.byte3, bytes.byte4, bytes.byte5, bytes.byte6, 31 | bytes.byte7, bytes.byte8, bytes.byte9, bytes.byte10, bytes.byte11, bytes.byte12, bytes.byte13, 32 | bytes.byte14, bytes.byte15); 33 | } 34 | #elif BX_PLATFORM_LINUX 35 | # include 36 | static void generateUUID(char uuidStr[37]) 37 | { 38 | uuid_t uid; 39 | uuid_generate(uid); 40 | uuid_unparse(uid, uuidStr); 41 | } 42 | #else 43 | # error "Not Implemented" 44 | #endif 45 | 46 | } // namespace: bx 47 | -------------------------------------------------------------------------------- /deps/bx/include/compat/freebsd/alloca.h: -------------------------------------------------------------------------------- 1 | #if defined(__GLIBC__) 2 | # include_next 3 | #else 4 | # include 5 | #endif 6 | -------------------------------------------------------------------------------- /deps/bx/include/compat/freebsd/malloc.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /deps/bx/include/compat/freebsd/signal.h: -------------------------------------------------------------------------------- 1 | #if defined(__GLIBC__) 2 | # include_next 3 | #else 4 | # include 5 | #endif 6 | -------------------------------------------------------------------------------- /deps/bx/include/compat/ios/malloc.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /deps/bx/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 | -------------------------------------------------------------------------------- /deps/bx/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 | -------------------------------------------------------------------------------- /deps/bx/include/compat/mingw/specstrings_strict.h: -------------------------------------------------------------------------------- 1 | #define __reserved 2 | -------------------------------------------------------------------------------- /deps/bx/include/compat/mingw/specstrings_undef.h: -------------------------------------------------------------------------------- 1 | #undef __reserved 2 | 3 | -------------------------------------------------------------------------------- /deps/bx/include/compat/msvc/alloca.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /deps/bx/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 | -------------------------------------------------------------------------------- /deps/bx/include/compat/nacl/memory.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /deps/bx/include/compat/osx/malloc.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | -------------------------------------------------------------------------------- /deps/bx/include/compat/posix/conio.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | inline int _kbhit() 9 | { 10 | static const int STDIN = 0; 11 | static bool initialized = false; 12 | 13 | if (!initialized) { 14 | // Use termios to turn off line buffering 15 | termios term; 16 | tcgetattr(STDIN, &term); 17 | term.c_lflag &= ~ICANON; 18 | tcsetattr(STDIN, TCSANOW, &term); 19 | setbuf(stdin, NULL); 20 | initialized = true; 21 | } 22 | 23 | int bytesWaiting; 24 | ioctl(STDIN, FIONREAD, &bytesWaiting); 25 | return bytesWaiting; 26 | } 27 | 28 | inline char _getch() 29 | { 30 | static termios told, tnew; 31 | 32 | tcgetattr(0, &told); /* grab old terminal i/o settings */ 33 | tnew = told; /* make new settings same as old settings */ 34 | tnew.c_lflag &= ~ICANON; /* disable buffered i/o */ 35 | tnew.c_lflag &= ~ECHO; /* set echo mode */ 36 | tcsetattr(0, TCSANOW, &tnew); /* use these new terminal i/o settings now */ 37 | 38 | char ch = getchar(); 39 | 40 | tcsetattr(0, TCSANOW, &told); 41 | 42 | return ch; 43 | } 44 | -------------------------------------------------------------------------------- /deps/bx/include/tinystl/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2012 Matthew Endsley 2 | All rights reserved 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted providing that the following conditions 6 | are met: 7 | 1. Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 17 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 21 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 22 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 23 | POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /deps/bx/include/tinystl/allocator.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2012 Matthew Endsley 3 | * All rights reserved 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted providing that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 22 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 23 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef TINYSTL_ALLOCATOR_H 28 | #define TINYSTL_ALLOCATOR_H 29 | 30 | #include "stddef.h" 31 | 32 | #ifndef TINYSTL_ALLOCATOR 33 | 34 | namespace tinystl { 35 | 36 | struct allocator { 37 | static void* static_allocate(size_t bytes) { 38 | return operator new(bytes); 39 | } 40 | 41 | static void static_deallocate(void* ptr, size_t /*bytes*/) { 42 | operator delete(ptr); 43 | } 44 | }; 45 | } 46 | 47 | # define TINYSTL_ALLOCATOR ::tinystl::allocator 48 | #endif // TINYSTL_ALLOCATOR 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /deps/bx/include/tinystl/hash.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2012 Matthew Endsley 3 | * All rights reserved 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted providing that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 22 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 23 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef TINYSTL_STRINGHASH_H 28 | #define TINYSTL_STRINGHASH_H 29 | 30 | #include "stddef.h" 31 | 32 | namespace tinystl { 33 | 34 | static inline size_t hash_string(const char* str, size_t len) { 35 | // Implementation of sdbm a public domain string hash from Ozan Yigit 36 | // see: http://www.eecs.harvard.edu/margo/papers/usenix91/paper.ps 37 | 38 | size_t hash = 0; 39 | typedef const char* pointer; 40 | for (pointer it = str, end = str + len; it != end; ++it) 41 | hash = *it + (hash << 6) + (hash << 16) - hash; 42 | 43 | return hash; 44 | } 45 | 46 | template 47 | inline size_t hash(const T& value) { 48 | const size_t asint = (size_t)value; 49 | return hash_string((const char*)&asint, sizeof(asint)); 50 | } 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /deps/bx/include/tinystl/new.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2012 Matthew Endsley 3 | * All rights reserved 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted providing that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 22 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 23 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef TINYSTL_NEW_H 28 | #define TINYSTL_NEW_H 29 | 30 | #include "stddef.h" 31 | 32 | namespace tinystl { 33 | 34 | struct placeholder {}; 35 | } 36 | 37 | inline void* operator new(size_t, tinystl::placeholder, void* ptr) { 38 | return ptr; 39 | } 40 | 41 | inline void operator delete(void*, tinystl::placeholder, void*) throw() {} 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /deps/bx/include/tinystl/stddef.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2012 Matthew Endsley 3 | * All rights reserved 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted providing that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 22 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 23 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef TINYSTL_STDDEF_H 28 | #define TINYSTL_STDDEF_H 29 | 30 | #if defined(_WIN64) 31 | typedef long long unsigned int size_t; 32 | #elif defined(_WIN32) 33 | typedef unsigned int size_t; 34 | #elif defined (__linux__) && defined(__SIZE_TYPE__) 35 | typedef __SIZE_TYPE__ size_t; 36 | #else 37 | # include 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /deps/bx/include/tinystl/traits.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2012 Matthew Endsley 3 | * All rights reserved 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted providing that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 22 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 23 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef TINYSTL_TRAITS_H 28 | #define TINYSTL_TRAITS_H 29 | 30 | #include "new.h" 31 | 32 | #if defined(__GNUC__) && defined(__is_pod) 33 | # define TINYSTL_TRY_POD_OPTIMIZATION(t) __is_pod(t) 34 | #elif defined(_MSC_VER) 35 | # define TINYSTL_TRY_POD_OPTIMIZATION(t) (!__is_class(t) || __is_pod(t)) 36 | #else 37 | # define TINYSTL_TRY_POD_OPTIMIZATION(t) false 38 | #endif 39 | 40 | namespace tinystl { 41 | template struct pod_traits {}; 42 | 43 | template struct swap_holder; 44 | 45 | template 46 | static inline void move_impl(T& a, T& b, ...) { 47 | a = b; 48 | } 49 | 50 | template 51 | static inline void move_impl(T& a, T& b, T*, swap_holder* = 0) { 52 | a.swap(b); 53 | } 54 | 55 | template 56 | static inline void move(T& a, T&b) { 57 | move_impl(a, b, (T*)0); 58 | } 59 | 60 | template 61 | static inline void move_construct_impl(T* a, T& b, ...) { 62 | new(placeholder(), a) T(b); 63 | } 64 | 65 | template 66 | static inline void move_construct_impl(T* a, T& b, void*, swap_holder* = 0) { 67 | // If your type T does not have a default constructor, simply insert: 68 | // struct tinystl_nomove_construct; 69 | // in the class definition 70 | new(placeholder(), a) T; 71 | a->swap(b); 72 | } 73 | 74 | template 75 | static inline void move_construct_impl(T* a, T& b, T*, typename T::tinystl_nomove_construct* = 0) { 76 | new(placeholder(), a) T(b); 77 | } 78 | 79 | template 80 | static inline void move_construct(T* a, T& b) { 81 | move_construct_impl(a, b, (T*)0); 82 | } 83 | } 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /deps/bx/scripts/bin2c.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | -- 5 | 6 | project "bin2c" 7 | uuid "60eaa654-7d06-11e4-be8e-880965202986" 8 | kind "ConsoleApp" 9 | 10 | includedirs { 11 | "../include", 12 | } 13 | 14 | files { 15 | "../tools/bin2c/**.cpp", 16 | "../tools/bin2c/**.h", 17 | } 18 | 19 | configuration {} 20 | -------------------------------------------------------------------------------- /deps/bx/scripts/bx.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | -- 5 | 6 | project "bx" 7 | uuid "4db0b09e-d6df-11e1-a0ec-65ccdd6a022f" 8 | kind "StaticLib" 9 | 10 | configuration { "osx or ios" } 11 | -- OSX ar doesn't like creating archive without object files 12 | -- here is object file... 13 | prebuildcommands { 14 | "@echo \"void dummy() {}\" > /tmp/dummy.cpp", 15 | } 16 | files { 17 | "/tmp/dummy.cpp", 18 | } 19 | 20 | configuration {} 21 | 22 | files { 23 | "../include/**.h", 24 | "../include/**.inl", 25 | } 26 | -------------------------------------------------------------------------------- /deps/bx/scripts/genie.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | -- 5 | 6 | solution "bx" 7 | configurations { 8 | "Debug", 9 | "Release", 10 | } 11 | 12 | platforms { 13 | "x32", 14 | "x64", 15 | "Native", -- for targets where bitness is not specified 16 | } 17 | 18 | language "C++" 19 | 20 | BX_DIR = path.getabsolute("..") 21 | local BX_BUILD_DIR = path.join(BX_DIR, ".build") 22 | local BX_THIRD_PARTY_DIR = path.join(BX_DIR, "3rdparty") 23 | 24 | defines { 25 | "BX_CONFIG_ENABLE_MSVC_LEVEL4_WARNINGS=1" 26 | } 27 | 28 | dofile "toolchain.lua" 29 | toolchain(BX_BUILD_DIR, BX_THIRD_PARTY_DIR) 30 | 31 | function copyLib() 32 | end 33 | 34 | dofile "bx.lua" 35 | dofile "unittest++.lua" 36 | dofile "bin2c.lua" 37 | 38 | project "bx.test" 39 | kind "ConsoleApp" 40 | 41 | debugdir (path.join(BX_DIR, "tests")) 42 | 43 | removeflags { 44 | "NoExceptions", 45 | } 46 | 47 | includedirs { 48 | path.join(BX_DIR, "include"), 49 | path.join(BX_THIRD_PARTY_DIR, "UnitTest++/src"), 50 | } 51 | 52 | links { 53 | "UnitTest++", 54 | } 55 | 56 | files { 57 | path.join(BX_DIR, "tests/**.cpp"), 58 | path.join(BX_DIR, "tests/**.H"), 59 | } 60 | 61 | configuration { "vs* or mingw*" } 62 | links { 63 | "psapi", 64 | } 65 | 66 | configuration { "android*" } 67 | targetextension ".so" 68 | linkoptions { 69 | "-shared", 70 | } 71 | 72 | configuration { "nacl or nacl-arm" } 73 | targetextension ".nexe" 74 | links { 75 | "ppapi", 76 | "pthread", 77 | } 78 | 79 | configuration { "pnacl" } 80 | targetextension ".pexe" 81 | links { 82 | "ppapi", 83 | "pthread", 84 | } 85 | 86 | configuration { "linux-*" } 87 | links { 88 | "pthread", 89 | } 90 | 91 | configuration { "osx" } 92 | links { 93 | "Cocoa.framework", 94 | } 95 | 96 | configuration {} 97 | 98 | strip() 99 | -------------------------------------------------------------------------------- /deps/bx/scripts/unittest++.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | -- 5 | 6 | project "UnitTest++" 7 | kind "StaticLib" 8 | 9 | removeflags { 10 | "NoExceptions", 11 | } 12 | 13 | files { 14 | "../3rdparty/UnitTest++/src/*.cpp", 15 | "../3rdparty/UnitTest++/src/*.h", 16 | } 17 | 18 | configuration { "linux or osx or android-* or *nacl* or ps4 or rpi or riscv" } 19 | files { 20 | "../3rdparty/UnitTest++/src/Posix/**.cpp", 21 | "../3rdparty/UnitTest++/src/Posix/**.h", 22 | } 23 | 24 | configuration { "mingw* or vs*" } 25 | files { 26 | "../3rdparty/UnitTest++/src/Win32/**.cpp", 27 | "../3rdparty/UnitTest++/src/Win32/**.h", 28 | } 29 | 30 | configuration {} 31 | -------------------------------------------------------------------------------- /deps/bx/tests/dbg.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include // isprint 10 | 11 | #include "dbg.h" 12 | #include 13 | #include 14 | 15 | void dbgPrintfVargs(const char* _format, va_list _argList) 16 | { 17 | char temp[8192]; 18 | char* out = temp; 19 | int32_t len = bx::vsnprintf(out, sizeof(temp), _format, _argList); 20 | if ( (int32_t)sizeof(temp) < len) 21 | { 22 | out = (char*)alloca(len+1); 23 | len = bx::vsnprintf(out, len, _format, _argList); 24 | } 25 | out[len] = '\0'; 26 | bx::debugOutput(out); 27 | } 28 | 29 | void dbgPrintf(const char* _format, ...) 30 | { 31 | va_list argList; 32 | va_start(argList, _format); 33 | dbgPrintfVargs(_format, argList); 34 | va_end(argList); 35 | } 36 | 37 | #define DBG_ADDRESS "%" PRIxPTR 38 | 39 | void dbgPrintfData(const void* _data, uint32_t _size, const char* _format, ...) 40 | { 41 | #define HEX_DUMP_WIDTH 16 42 | #define HEX_DUMP_SPACE_WIDTH 48 43 | #define HEX_DUMP_FORMAT "%-" DBG_STRINGIZE(HEX_DUMP_SPACE_WIDTH) "." DBG_STRINGIZE(HEX_DUMP_SPACE_WIDTH) "s" 44 | 45 | va_list argList; 46 | va_start(argList, _format); 47 | dbgPrintfVargs(_format, argList); 48 | va_end(argList); 49 | 50 | dbgPrintf("\ndata: " DBG_ADDRESS ", size: %d\n", _data, _size); 51 | 52 | if (NULL != _data) 53 | { 54 | const uint8_t* data = reinterpret_cast(_data); 55 | char hex[HEX_DUMP_WIDTH*3+1]; 56 | char ascii[HEX_DUMP_WIDTH+1]; 57 | uint32_t hexPos = 0; 58 | uint32_t asciiPos = 0; 59 | for (uint32_t ii = 0; ii < _size; ++ii) 60 | { 61 | bx::snprintf(&hex[hexPos], sizeof(hex)-hexPos, "%02x ", data[asciiPos]); 62 | hexPos += 3; 63 | 64 | ascii[asciiPos] = isprint(data[asciiPos]) ? data[asciiPos] : '.'; 65 | asciiPos++; 66 | 67 | if (HEX_DUMP_WIDTH == asciiPos) 68 | { 69 | ascii[asciiPos] = '\0'; 70 | dbgPrintf("\t" DBG_ADDRESS "\t" HEX_DUMP_FORMAT "\t%s\n", data, hex, ascii); 71 | data += asciiPos; 72 | hexPos = 0; 73 | asciiPos = 0; 74 | } 75 | } 76 | 77 | if (0 != asciiPos) 78 | { 79 | ascii[asciiPos] = '\0'; 80 | dbgPrintf("\t" DBG_ADDRESS "\t" HEX_DUMP_FORMAT "\t%s\n", data, hex, ascii); 81 | } 82 | } 83 | 84 | #undef HEX_DUMP_WIDTH 85 | #undef HEX_DUMP_SPACE_WIDTH 86 | #undef HEX_DUMP_FORMAT 87 | } 88 | -------------------------------------------------------------------------------- /deps/bx/tests/dbg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #ifndef DBG_H_HEADER_GUARD 7 | #define DBG_H_HEADER_GUARD 8 | 9 | #include // va_list 10 | #include 11 | 12 | #define DBG_STRINGIZE(_x) DBG_STRINGIZE_(_x) 13 | #define DBG_STRINGIZE_(_x) #_x 14 | #define DBG_FILE_LINE_LITERAL "" __FILE__ "(" DBG_STRINGIZE(__LINE__) "): " 15 | #define DBG(_format, ...) dbgPrintf(DBG_FILE_LINE_LITERAL "" _format "\n", ##__VA_ARGS__) 16 | 17 | extern void dbgPrintfVargs(const char* _format, va_list _argList); 18 | extern void dbgPrintf(const char* _format, ...); 19 | extern void dbgPrintfData(const void* _data, uint32_t _size, const char* _format, ...); 20 | 21 | #endif // DBG_H_HEADER_GUARD 22 | -------------------------------------------------------------------------------- /deps/bx/tests/fpumath.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #include "test.h" 7 | #include 8 | 9 | void mtxCheck(const float* _a, const float* _b) 10 | { 11 | if (!bx::fequal(_a, _b, 16, 0.01f) ) 12 | { 13 | DBG("\n" 14 | "A:\n" 15 | "%10.4f %10.4f %10.4f %10.4f\n" 16 | "%10.4f %10.4f %10.4f %10.4f\n" 17 | "%10.4f %10.4f %10.4f %10.4f\n" 18 | "%10.4f %10.4f %10.4f %10.4f\n" 19 | "B:\n" 20 | "%10.4f %10.4f %10.4f %10.4f\n" 21 | "%10.4f %10.4f %10.4f %10.4f\n" 22 | "%10.4f %10.4f %10.4f %10.4f\n" 23 | "%10.4f %10.4f %10.4f %10.4f\n" 24 | , _a[ 0], _a[ 1], _a[ 2], _a[ 3] 25 | , _a[ 4], _a[ 5], _a[ 6], _a[ 7] 26 | , _a[ 8], _a[ 9], _a[10], _a[11] 27 | , _a[12], _a[13], _a[14], _a[15] 28 | , _b[ 0], _b[ 1], _b[ 2], _b[ 3] 29 | , _b[ 4], _b[ 5], _b[ 6], _b[ 7] 30 | , _b[ 8], _b[ 9], _b[10], _b[11] 31 | , _b[12], _b[13], _b[14], _b[15] 32 | ); 33 | 34 | CHECK(false); 35 | } 36 | } 37 | 38 | TEST(Quaternion) 39 | { 40 | float mtxQ[16]; 41 | float mtx[16]; 42 | 43 | float quat[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; 44 | bx::mtxQuat(mtxQ, quat); 45 | bx::mtxIdentity(mtx); 46 | mtxCheck(mtxQ, mtx); 47 | 48 | float ax = bx::pi/27.0f; 49 | float ay = bx::pi/13.0f; 50 | float az = bx::pi/7.0f; 51 | 52 | bx::quatRotateX(quat, ax); 53 | bx::mtxQuat(mtxQ, quat); 54 | bx::mtxRotateX(mtx, ax); 55 | mtxCheck(mtxQ, mtx); 56 | 57 | float euler[3]; 58 | bx::quatToEuler(euler, quat); 59 | CHECK(bx::fequal(euler[0], ax, 0.001f) ); 60 | 61 | bx::quatRotateY(quat, ay); 62 | bx::mtxQuat(mtxQ, quat); 63 | bx::mtxRotateY(mtx, ay); 64 | mtxCheck(mtxQ, mtx); 65 | 66 | bx::quatToEuler(euler, quat); 67 | CHECK(bx::fequal(euler[1], ay, 0.001f) ); 68 | 69 | bx::quatRotateZ(quat, az); 70 | bx::mtxQuat(mtxQ, quat); 71 | bx::mtxRotateZ(mtx, az); 72 | mtxCheck(mtxQ, mtx); 73 | 74 | bx::quatToEuler(euler, quat); 75 | CHECK(bx::fequal(euler[2], az, 0.001f) ); 76 | } 77 | -------------------------------------------------------------------------------- /deps/bx/tests/handle.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #include "test.h" 7 | #include 8 | 9 | TEST(HandleListT) 10 | { 11 | bx::HandleListT<32> list; 12 | 13 | list.pushBack(16); 14 | CHECK(list.getFront() == 16); 15 | CHECK(list.getBack() == 16); 16 | 17 | list.pushFront(7); 18 | CHECK(list.getFront() == 7); 19 | CHECK(list.getBack() == 16); 20 | 21 | uint16_t expected0[] = { 15, 31, 7, 16, 17, 11, 13 }; 22 | list.pushBack(17); 23 | list.pushBack(11); 24 | list.pushBack(13); 25 | list.pushFront(31); 26 | list.pushFront(15); 27 | uint16_t count = 0; 28 | for (uint16_t it = list.getFront(); it != UINT16_MAX; it = list.getNext(it), ++count) 29 | { 30 | CHECK(it == expected0[count]); 31 | } 32 | CHECK(count == BX_COUNTOF(expected0) ); 33 | 34 | list.remove(17); 35 | list.remove(31); 36 | list.remove(16); 37 | list.pushBack(16); 38 | uint16_t expected1[] = { 15, 7, 11, 13, 16 }; 39 | count = 0; 40 | for (uint16_t it = list.getFront(); it != UINT16_MAX; it = list.getNext(it), ++count) 41 | { 42 | CHECK(it == expected1[count]); 43 | } 44 | CHECK(count == BX_COUNTOF(expected1) ); 45 | 46 | list.popBack(); 47 | list.popFront(); 48 | list.popBack(); 49 | list.popBack(); 50 | 51 | CHECK(list.getFront() == 7); 52 | CHECK(list.getBack() == 7); 53 | 54 | list.popBack(); 55 | CHECK(list.getFront() == UINT16_MAX); 56 | CHECK(list.getBack() == UINT16_MAX); 57 | } 58 | 59 | TEST(HandleAllocLruT) 60 | { 61 | bx::HandleAllocLruT<16> lru; 62 | 63 | uint16_t handle[4] = 64 | { 65 | lru.alloc(), 66 | lru.alloc(), 67 | lru.alloc(), 68 | lru.alloc(), 69 | }; 70 | 71 | lru.touch(handle[1]); 72 | 73 | uint16_t expected0[] = { handle[1], handle[3], handle[2], handle[0] }; 74 | uint16_t count = 0; 75 | for (uint16_t it = lru.getFront(); it != UINT16_MAX; it = lru.getNext(it), ++count) 76 | { 77 | CHECK(it == expected0[count]); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /deps/bx/tests/macros.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #include "test.h" 7 | #include 8 | #include 9 | 10 | BX_STATIC_ASSERT(1 == BX_VA_ARGS_COUNT(1) ); 11 | BX_STATIC_ASSERT(2 == BX_VA_ARGS_COUNT(1, 2) ); 12 | BX_STATIC_ASSERT(3 == BX_VA_ARGS_COUNT(1, 2, 3) ); 13 | BX_STATIC_ASSERT(4 == BX_VA_ARGS_COUNT(1, 2, 3, 4) ); 14 | BX_STATIC_ASSERT(5 == BX_VA_ARGS_COUNT(1, 2, 3, 4, 5) ); 15 | BX_STATIC_ASSERT(6 == BX_VA_ARGS_COUNT(1, 2, 3, 4, 5, 6) ); 16 | 17 | BX_STATIC_ASSERT( 0 == BX_ALIGN_16( 0) ); 18 | BX_STATIC_ASSERT( 16 == BX_ALIGN_16( 1) ); 19 | BX_STATIC_ASSERT( 16 == BX_ALIGN_16( 15) ); 20 | BX_STATIC_ASSERT( 16 == BX_ALIGN_16( 16) ); 21 | BX_STATIC_ASSERT(256 == BX_ALIGN_16(255) ); 22 | 23 | BX_STATIC_ASSERT( 0 == BX_ALIGN_256( 0) ); 24 | BX_STATIC_ASSERT(256 == BX_ALIGN_256( 1) ); 25 | BX_STATIC_ASSERT(256 == BX_ALIGN_256( 15) ); 26 | BX_STATIC_ASSERT(256 == BX_ALIGN_256(255) ); 27 | BX_STATIC_ASSERT(256 == BX_ALIGN_256(256) ); 28 | BX_STATIC_ASSERT(256 == BX_ALIGN_256(256) ); 29 | BX_STATIC_ASSERT(512 == BX_ALIGN_256(511) ); 30 | 31 | BX_NO_INLINE void unusedFunction() 32 | { 33 | CHECK(false); 34 | } 35 | 36 | TEST(macros) 37 | { 38 | uint32_t unused0; 39 | BX_UNUSED(unused0); 40 | 41 | uint32_t unused1; 42 | BX_UNUSED(unused0, unused1); 43 | 44 | uint32_t unused2; 45 | BX_UNUSED(unused0, unused1, unused2, unusedFunction() ); 46 | 47 | CHECK_EQUAL(1, BX_VA_ARGS_COUNT(1) ); 48 | CHECK_EQUAL(2, BX_VA_ARGS_COUNT(1, 2) ); 49 | CHECK_EQUAL(3, BX_VA_ARGS_COUNT(1, 2, 3) ); 50 | CHECK_EQUAL(4, BX_VA_ARGS_COUNT(1, 2, 3, 4) ); 51 | CHECK_EQUAL(5, BX_VA_ARGS_COUNT(1, 2, 3, 4, 5) ); 52 | CHECK_EQUAL(6, BX_VA_ARGS_COUNT(1, 2, 3, 4, 5, 6) ); 53 | 54 | CHECK_EQUAL(0, strcmp(BX_STRINGIZE(TEST 1234 %^&*), "TEST 1234 %^&*") ); 55 | } 56 | -------------------------------------------------------------------------------- /deps/bx/tests/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | /* 7 | * Copyright 2012 Matthew Endsley 8 | * All rights reserved 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted providing that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 23 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 27 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 28 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 | * POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include "test.h" 33 | 34 | int runAllTests() 35 | { 36 | DBG(BX_COMPILER_NAME " / " BX_CPU_NAME " / " BX_ARCH_NAME " / " BX_PLATFORM_NAME); 37 | return UnitTest::RunAllTests(); 38 | } 39 | 40 | #if BX_PLATFORM_ANDROID 41 | # include 42 | 43 | void ANativeActivity_onCreate(ANativeActivity*, void*, size_t) 44 | { 45 | exit(runAllTests() ); 46 | } 47 | #elif BX_PLATFORM_NACL 48 | # include 49 | # include 50 | 51 | PP_EXPORT const void* PPP_GetInterface(const char* /*_name*/) 52 | { 53 | return NULL; 54 | } 55 | 56 | PP_EXPORT int32_t PPP_InitializeModule(PP_Module /*_module*/, PPB_GetInterface /*_interface*/) 57 | { 58 | DBG("PPAPI version: %d", PPAPI_RELEASE); 59 | runAllTests(); 60 | return PP_ERROR_NOINTERFACE; 61 | } 62 | 63 | PP_EXPORT void PPP_ShutdownModule() 64 | { 65 | } 66 | #else 67 | int main() 68 | { 69 | return runAllTests(); 70 | } 71 | #endif // BX_PLATFORM 72 | -------------------------------------------------------------------------------- /deps/bx/tests/misc.cpp: -------------------------------------------------------------------------------- 1 | #include "test.h" 2 | #include 3 | 4 | TEST(getProcessMemoryUsed) 5 | { 6 | CHECK(0 != bx::getProcessMemoryUsed() ); 7 | // DBG("bx::getProcessMemoryUsed %d", bx::getProcessMemoryUsed() ); 8 | } 9 | -------------------------------------------------------------------------------- /deps/bx/tests/test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #ifndef __TEST_H__ 7 | #define __TEST_H__ 8 | 9 | #include 10 | #include 11 | #include "dbg.h" 12 | 13 | #if !BX_COMPILER_MSVC 14 | # define _strdup strdup 15 | #endif // !BX_COMPILER_MSVC 16 | 17 | #endif // __TEST_H__ 18 | -------------------------------------------------------------------------------- /deps/bx/tests/thread.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #include "test.h" 7 | #include 8 | 9 | int32_t threadExit0(void*) 10 | { 11 | return 0; 12 | } 13 | 14 | int32_t threadExit1(void*) 15 | { 16 | return 1; 17 | } 18 | 19 | TEST(thread) 20 | { 21 | bx::Thread th; 22 | 23 | CHECK_EQUAL(th.isRunning(), false); 24 | 25 | th.init(threadExit0); 26 | CHECK_EQUAL(th.isRunning(), true); 27 | th.shutdown(); 28 | 29 | CHECK_EQUAL(th.isRunning(), false); 30 | CHECK_EQUAL(th.getExitCode(), 0); 31 | 32 | th.init(threadExit1); 33 | CHECK_EQUAL(th.isRunning(), true); 34 | th.shutdown(); 35 | 36 | CHECK_EQUAL(th.isRunning(), false); 37 | CHECK_EQUAL(th.getExitCode(), 1); 38 | } 39 | -------------------------------------------------------------------------------- /deps/bx/tests/tokenizecmd.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #include "test.h" 7 | #include 8 | #include 9 | #include 10 | 11 | TEST(commandLine) 12 | { 13 | const char* args[] = 14 | { 15 | "-s", 16 | "--long", 17 | }; 18 | 19 | bx::CommandLine cmdLine(BX_COUNTOF(args), args); 20 | 21 | CHECK(cmdLine.hasArg("long") ); 22 | CHECK(cmdLine.hasArg('s') ); 23 | 24 | // non-existing argument 25 | CHECK(!cmdLine.hasArg('x') ); 26 | } 27 | 28 | TEST(tokenizeCommandLine) 29 | { 30 | #if 0 31 | const char* input[] = 32 | { 33 | " ", 34 | "\\", 35 | // "\"a b c\" d e", 36 | "\"ab\\\"c\" \"\\\\\" d", 37 | "a\\\\\\b d\"e f\"g h", 38 | "a\\\\\\\"b c d", 39 | "a\\\\\\\\\"b c\" d e", 40 | }; 41 | 42 | const int expected_argc[] = 43 | { 44 | 0, 45 | 0, 46 | // 3, 47 | 3, 48 | 3, 49 | 3, 50 | 3 51 | }; 52 | 53 | const char* expected_results[] = 54 | { 55 | "a b c", "d", "e", 56 | "ab\"c", "\\", "d", 57 | "a\\\\\\b", "de fg", "h", 58 | "a\\\"b", "c", "d", 59 | "a\\\\b c", "d", "e", 60 | }; 61 | 62 | const char** expected_argv[] = 63 | { 64 | NULL, 65 | NULL, 66 | // &expected_results[0], 67 | &expected_results[3], 68 | &expected_results[6], 69 | &expected_results[9], 70 | &expected_results[12], 71 | }; 72 | 73 | for (uint32_t ii = 0; ii < BX_COUNTOF(exptected_argv); ++ii) 74 | { 75 | printf("x\n"); 76 | char commandLine[1024]; 77 | uint32_t size = BX_COUNTOF(commandLine); 78 | char* argv[50]; 79 | int32_t argc; 80 | bx::tokenizeCommandLine(input[ii], commandLine, size, argc, argv, BX_COUNTOF(argv) ); 81 | printf("\n%d (%d): %s %s\n", ii, argc, input[ii], expected_argc[ii] == argc ? "" : "FAILED!"); 82 | for (uint32_t jj = 0; jj < argc; ++jj) 83 | { 84 | printf("\t%d: {%s} %s\n" 85 | , jj 86 | , argv[jj] 87 | , jj < argc ? (0==strcmp(argv[jj], expected_argv[ii][jj]) ? "" : "FAILED!") : "FAILED!" 88 | ); 89 | } 90 | } 91 | #endif // 0 92 | } 93 | -------------------------------------------------------------------------------- /deps/bx/tests/uint32_t.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2016 Branimir Karadzic. All rights reserved. 3 | * License: https://github.com/bkaradzic/bx#license-bsd-2-clause 4 | */ 5 | 6 | #include "test.h" 7 | #include 8 | 9 | TEST(StrideAlign) 10 | { 11 | CHECK(0 == bx::strideAlign(0, 12) ); 12 | for (uint32_t ii = 0; ii < 12; ++ii) 13 | { 14 | CHECK(12 == bx::strideAlign(ii+1, 12) ); 15 | } 16 | 17 | CHECK(0 == bx::strideAlign16(0, 12) ); 18 | for (uint32_t ii = 0; ii < 12; ++ii) 19 | { 20 | CHECK(48 == bx::strideAlign16(ii+1, 12) ); 21 | } 22 | } 23 | 24 | TEST(uint32_cnt) 25 | { 26 | CHECK( 0 == bx::uint32_cnttz(UINT32_C(1) ) ); 27 | CHECK( 0 == bx::uint32_cnttz_ref(UINT32_C(1) ) ); 28 | 29 | CHECK(31 == bx::uint32_cntlz(UINT32_C(1) ) ); 30 | CHECK(31 == bx::uint32_cntlz_ref(UINT32_C(1) ) ); 31 | 32 | CHECK( 0 == bx::uint64_cnttz(UINT64_C(1) ) ); 33 | CHECK( 0 == bx::uint64_cnttz_ref(UINT64_C(1) ) ); 34 | 35 | CHECK(63 == bx::uint64_cntlz(UINT64_C(1) ) ); 36 | CHECK(63 == bx::uint64_cntlz_ref(UINT64_C(1) ) ); 37 | 38 | CHECK( 1 == bx::uint32_cntbits(1) ); 39 | CHECK( 1 == bx::uint32_cntbits_ref(1) ); 40 | 41 | CHECK(16 == bx::uint32_cntbits(UINT16_MAX) ); 42 | CHECK(16 == bx::uint32_cntbits_ref(UINT16_MAX) ); 43 | 44 | CHECK(32 == bx::uint32_cntbits(UINT32_MAX) ); 45 | CHECK(32 == bx::uint32_cntbits_ref(UINT32_MAX) ); 46 | } 47 | 48 | TEST(uint32_part) 49 | { 50 | CHECK(UINT32_C(0x55555555) == bx::uint32_part1by1(UINT16_MAX) ); 51 | CHECK(UINT32_C(0x09249249) == bx::uint32_part1by2(0x3ff) ); 52 | } 53 | -------------------------------------------------------------------------------- /deps/bx/tests/unordered_map_nonpod.cpp: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2012-2015 Matthew Endsley 3 | * All rights reserved 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted providing that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 22 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 23 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include "test.h" 28 | 29 | #include 30 | #include 31 | 32 | namespace { 33 | struct Foo { int bar; }; 34 | } 35 | 36 | TEST(uomap_nonpod_compiles) { 37 | 38 | // verify this compiles 39 | typedef tinystl::unordered_map map; 40 | map m; 41 | } 42 | -------------------------------------------------------------------------------- /deps/bx/tests/unordered_set_copyctor.cpp: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2012-2015 Matthew Endsley 3 | * All rights reserved 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted providing that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 22 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 23 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include "test.h" 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | TEST(uoset_copyctor) { 34 | 35 | // verify this compiles 36 | typedef tinystl::unordered_set set; 37 | set s; 38 | s.insert(32); 39 | set other = s; 40 | CHECK(other.find(32) != other.end()); 41 | other.clear(); 42 | CHECK(other.empty()); 43 | } 44 | -------------------------------------------------------------------------------- /deps/bx/tests/unordered_set_pod.cpp: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2012-2015 Matthew Endsley 3 | * All rights reserved 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted providing that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 22 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 23 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include "test.h" 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | TEST(uoset_pod_compiles) { 34 | 35 | // verify this compiles 36 | tinystl::unordered_set s; 37 | s.insert(32); 38 | s.clear(); 39 | } 40 | -------------------------------------------------------------------------------- /deps/bx/tests/vector_header.cpp: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2012-1015 Matthew Endsley 3 | * All rights reserved 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted providing that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 22 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 23 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | // Test that header is standalone 28 | #include 29 | #include 30 | -------------------------------------------------------------------------------- /deps/bx/tests/vector_shrinktofit.cpp: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright 2012-2014 Matthew Endsley 3 | * All rights reserved 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted providing that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 22 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 23 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include "test.h" 28 | 29 | #include 30 | #include 31 | 32 | TEST(vector_shrinktofit) { 33 | typedef tinystl::vector vector; 34 | 35 | { 36 | vector v; 37 | CHECK(v.capacity() == 0); 38 | v.clear(); 39 | v.shrink_to_fit(); 40 | CHECK(v.capacity() == 0); 41 | } 42 | 43 | { 44 | vector v(10, 0); 45 | CHECK(v.capacity() >= 10); 46 | v.shrink_to_fit(); 47 | CHECK(v.capacity() == 10); 48 | } 49 | 50 | { 51 | vector v(10, 0); 52 | CHECK(v.capacity() >= 10); 53 | v.erase(v.end() - 1, v.end()); 54 | CHECK(v.size() == 9); 55 | CHECK(v.capacity() >= 10); 56 | v.shrink_to_fit(); 57 | CHECK(v.capacity() == 9); 58 | } 59 | 60 | { 61 | vector v(10, 0); 62 | CHECK(v.capacity() >= 10); 63 | const int* ptr = v.data(); 64 | v.shrink_to_fit(); 65 | CHECK(v.capacity() >= 10); 66 | CHECK(v.data() == ptr); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /deps/bx/tools/bin/darwin/bin2c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/septag/termite-jobs/06b00c4b52de39f61dd505f280a35eb65bfbea18/deps/bx/tools/bin/darwin/bin2c -------------------------------------------------------------------------------- /deps/bx/tools/bin/darwin/genie: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/septag/termite-jobs/06b00c4b52de39f61dd505f280a35eb65bfbea18/deps/bx/tools/bin/darwin/genie -------------------------------------------------------------------------------- /deps/bx/tools/bin/darwin/ninja: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/septag/termite-jobs/06b00c4b52de39f61dd505f280a35eb65bfbea18/deps/bx/tools/bin/darwin/ninja -------------------------------------------------------------------------------- /deps/bx/tools/bin/linux/bin2c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/septag/termite-jobs/06b00c4b52de39f61dd505f280a35eb65bfbea18/deps/bx/tools/bin/linux/bin2c -------------------------------------------------------------------------------- /deps/bx/tools/bin/linux/genie: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/septag/termite-jobs/06b00c4b52de39f61dd505f280a35eb65bfbea18/deps/bx/tools/bin/linux/genie -------------------------------------------------------------------------------- /deps/bx/tools/bin/linux/ninja: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/septag/termite-jobs/06b00c4b52de39f61dd505f280a35eb65bfbea18/deps/bx/tools/bin/linux/ninja -------------------------------------------------------------------------------- /deps/bx/tools/bin/windows/bin2c.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/septag/termite-jobs/06b00c4b52de39f61dd505f280a35eb65bfbea18/deps/bx/tools/bin/windows/bin2c.exe -------------------------------------------------------------------------------- /deps/bx/tools/bin/windows/genie.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/septag/termite-jobs/06b00c4b52de39f61dd505f280a35eb65bfbea18/deps/bx/tools/bin/windows/genie.exe -------------------------------------------------------------------------------- /deps/bx/tools/bin/windows/ninja.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/septag/termite-jobs/06b00c4b52de39f61dd505f280a35eb65bfbea18/deps/bx/tools/bin/windows/ninja.exe -------------------------------------------------------------------------------- /deps/deboost.context/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # PROJECT: fcontext 2 | cmake_minimum_required(VERSION 3.0) 3 | project(fcontext) 4 | 5 | if (NOT CMAKE_MODULE_PATH) 6 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") 7 | endif() 8 | 9 | #option(ANDROID_ARM_BUILD "Crosscompile for Android ARM" OFF) 10 | 11 | if (MSVC) 12 | enable_language(CXX ASM_MASM) 13 | else() 14 | enable_language(CXX ASM) 15 | endif() 16 | 17 | if(MSVC) 18 | add_definitions(-D_ITERATOR_DEBUG_LEVEL=0) 19 | add_definitions(-D_HAS_EXCEPTIONS=0) 20 | endif() 21 | add_definitions(-DBOOST_CONTEXT_EXPORT=) 22 | 23 | set(HEADER "include/fcontext/fcontext.h") 24 | set(SOURCES "source/stack.cpp") 25 | 26 | # Currently no cross-compiling or ARM configs are supported 27 | 28 | # OS 29 | if (UNIX) 30 | if (ANDROID) 31 | # Android 32 | if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm") 33 | set(CPU_ARCH "arm") 34 | set(ASM_EXT "aapcs_elf_gas.S") 35 | elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") 36 | set(CPU_ARCH "arm64") 37 | set(ASM_EXT "aapcs_elf_gas.S") 38 | elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "i686") 39 | set(CPU_ARCH "i386") 40 | set(ASM_EXT "sysv_elf_gas.S") 41 | elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") 42 | set(CPU_ARCH "x86_64") 43 | set(ASM_EXT "sysv_elf_gas.S") 44 | endif() 45 | else() 46 | # PC (x86/x64) 47 | if (CMAKE_SIZEOF_VOID_P EQUAL 8) 48 | set(CPU_ARCH "x86_64") 49 | else() 50 | set(CPU_ARCH "i386") 51 | endif() 52 | if (APPLE) 53 | set(ASM_EXT "sysv_macho_gas.S") # OSX 54 | else() 55 | set(ASM_EXT "sysv_elf_gas.S") # Linux/Unix 56 | endif() 57 | endif() 58 | elseif(WIN32) 59 | # Windows PC 60 | if (CMAKE_SIZEOF_VOID_P EQUAL 8) 61 | set(CPU_ARCH "x86_64") 62 | else() 63 | set(CPU_ARCH "i386") 64 | endif() 65 | set(ASM_EXT "ms_pe_masm.asm") 66 | endif() 67 | 68 | set(ASM_SOURCES "asm/make_${CPU_ARCH}_${ASM_EXT}" 69 | "asm/jump_${CPU_ARCH}_${ASM_EXT}" 70 | "asm/ontop_${CPU_ARCH}_${ASM_EXT}") 71 | 72 | add_library(fcontext STATIC ${SOURCES} ${ASM_SOURCES}) 73 | target_include_directories(fcontext 74 | PRIVATE include/fcontext 75 | INTERFACE include) 76 | 77 | message(${CMAKE_CXX_FLAGS}) 78 | 79 | #install(TARGETS fcontext DESTINATION lib) 80 | #install(FILES ${HEADER} DESTINATION include/fcontext) -------------------------------------------------------------------------------- /deps/deboost.context/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Sepehr Taghdisian 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /deps/deboost.context/README.md: -------------------------------------------------------------------------------- 1 | ## deboost.context 2 | "Deboostified" version of boost.context (coroutines), Plain and simple C API for context switching. Easy build on multiple platforms. 3 | 4 | ### Build 5 | #### Currently supported platforms 6 | - Windows (x86_64, Win32) 7 | - Linux (x86_64/x86) 8 | - OSX (x86_64/x86) 9 | - Android (ARM/x86/ARM64/x86_64) 10 | - More will be added soon ... 11 | 12 | #### Linux/Unix/Mac 13 | ``` 14 | cd deboost.context 15 | mkdir .build 16 | cd .build 17 | cmake .. 18 | make 19 | make install 20 | ``` 21 | 22 | #### Windows 23 | Assuming you have visual studio installed on your system 24 | ``` 25 | cd deboost.context 26 | mkdir .build 27 | cd .build 28 | cmake .. -G "Visual Studio 14 2015 Win64" 29 | ``` 30 | Now open the generated solution file and build 31 | 32 | #### Android 33 | Uses [android-cmake](https://github.com/taka-no-me/android-cmake) for Android builds. visit the page for help on command line options. 34 | It requres android NDK to build. extract the android NDK and set _ANDROID_NDK_ environment variable to the NDK root path. 35 | As an example if you want to build for Android ARMv7(Neon) 36 | ``` 37 | cd deboost.context 38 | mkdir .build 39 | cd .build 40 | cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/android.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="armeabi-v7a with NEON" -DANDROID_STL="stlport_static" -DANDROID_NATIVE_API_LEVEL=android-19 41 | ``` 42 | On Windows, This command tries to make Visual Studio sln files. Which requires you to install [Nsight Visual Studio Edition](https://developer.nvidia.com/nsight-visual-studio-edition-downloads) 43 | If you wish to install without visual studio and Nsight on windows. You have to install [Ninja](https://ninja-build.org/) and Add it to your PATH. Then add ```-GNinja``` to your cmake command line. 44 | 45 | 46 | ### Usage 47 | Link your program with fcontext.lib/libfcontext.a and include the file _fcontext.h_. 48 | See _include/fcontext/fcontext.h_ for API usage. 49 | More info is available at: [boost.context](http://www.boost.org/doc/libs/1_60_0/libs/context/doc/html/index.html) 50 | 51 | ### Credits 52 | - Boost.context: This library uses the code from boost.context [github](https://github.com/boostorg/context) 53 | 54 | ### Acknowledgements 55 | - Ali Salehi (nysalehi@gmail.com) 56 | 57 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/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 | -------------------------------------------------------------------------------- /deps/deboost.context/cmake/AndroidNdkModules.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014, Pavel Rojtberg 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # 7 | # 1. Redistributions of source code must retain the above copyright notice, 8 | # this list of conditions and the following disclaimer. 9 | # 10 | # 2. Redistributions in binary form must reproduce the above copyright notice, 11 | # this list of conditions and the following disclaimer in the documentation 12 | # and/or other materials provided with the distribution. 13 | # 14 | # 3. Neither the name of the copyright holder nor the names of its 15 | # contributors may be used to endorse or promote products derived from this 16 | # software without specific prior written permission. 17 | # 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 | # POSSIBILITY OF SUCH DAMAGE. 29 | 30 | macro(android_ndk_import_module_cpufeatures) 31 | if(ANDROID) 32 | include_directories(${ANDROID_NDK}/sources/android/cpufeatures) 33 | add_library(cpufeatures ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c) 34 | target_link_libraries(cpufeatures dl) 35 | endif() 36 | endmacro() 37 | 38 | macro(android_ndk_import_module_native_app_glue) 39 | if(ANDROID) 40 | include_directories(${ANDROID_NDK}/sources/android/native_app_glue) 41 | add_library(native_app_glue ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) 42 | target_link_libraries(native_app_glue log) 43 | endif() 44 | endmacro() 45 | 46 | macro(android_ndk_import_module_ndk_helper) 47 | if(ANDROID) 48 | android_ndk_import_module_cpufeatures() 49 | android_ndk_import_module_native_app_glue() 50 | 51 | include_directories(${ANDROID_NDK}/sources/android/ndk_helper) 52 | file(GLOB _NDK_HELPER_SRCS ${ANDROID_NDK}/sources/android/ndk_helper/*.cpp ${ANDROID_NDK}/sources/android/ndk_helper/gl3stub.c) 53 | add_library(ndk_helper ${_NDK_HELPER_SRCS}) 54 | target_link_libraries(ndk_helper log android EGL GLESv2 cpufeatures native_app_glue) 55 | 56 | unset(_NDK_HELPER_SRCS) 57 | endif() 58 | endmacro() -------------------------------------------------------------------------------- /deps/deboost.context/include/fcontext/fcontext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | typedef void* fcontext_t; 10 | 11 | struct fcontext_transfer_t 12 | { 13 | fcontext_t ctx; 14 | void* data; 15 | }; 16 | 17 | struct fcontext_stack_t 18 | { 19 | void* sptr; 20 | size_t ssize; 21 | }; 22 | 23 | /** 24 | * Callback definition for context (coroutine) 25 | */ 26 | typedef void (*pfn_fcontext)(fcontext_transfer_t); 27 | 28 | /** 29 | * Switches to another context 30 | * @param to Target context to switch to 31 | * @param vp Custom user pointer to pass to new context 32 | */ 33 | fcontext_transfer_t jump_fcontext(fcontext_t const to, void * vp); 34 | 35 | /** 36 | * Make a new context 37 | * @param sp Pointer to allocated stack memory 38 | * @param size Stack memory size 39 | * @param corofn Callback function for context (coroutine) 40 | */ 41 | fcontext_t make_fcontext(void * sp, size_t size, pfn_fcontext corofn); 42 | 43 | fcontext_transfer_t ontop_fcontext(fcontext_t const to, void * vp, fcontext_transfer_t(*fn)(fcontext_transfer_t)); 44 | 45 | fcontext_stack_t create_fcontext_stack(size_t size = 0); 46 | void destroy_fcontext_stack(fcontext_stack_t* s); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif -------------------------------------------------------------------------------- /deps/deboost.context/test/test_fcontext.cpp: -------------------------------------------------------------------------------- 1 | #ifdef _WIN32 2 | # define WIN32_LEAN_AND_MEAN 3 | # include 4 | #else 5 | # include 6 | #endif 7 | 8 | #include 9 | 10 | #include "fcontext/fcontext.h" 11 | 12 | fcontext_t ctx; 13 | fcontext_t ctx2; 14 | 15 | inline void sleep(uint32_t _ms) 16 | { 17 | #ifdef _WIN32 18 | Sleep(_ms); 19 | #else 20 | timespec req = { (time_t)_ms / 1000, (long)((_ms % 1000) * 1000000) }; 21 | timespec rem = { 0, 0 }; 22 | nanosleep(&req, &rem); 23 | #endif 24 | } 25 | 26 | static void doo(fcontext_transfer_t t) 27 | { 28 | puts("DOO"); 29 | sleep(1000); 30 | jump_fcontext(t.ctx, NULL); 31 | } 32 | 33 | static void foo(fcontext_transfer_t t) 34 | { 35 | puts("FOO"); 36 | sleep(1000); 37 | jump_fcontext(ctx2, NULL); 38 | puts("FOO 2"); 39 | sleep(1000); 40 | jump_fcontext(t.ctx, NULL); 41 | } 42 | 43 | int main() 44 | { 45 | fcontext_stack_t s = create_fcontext_stack(16 * 1024); 46 | fcontext_stack_t s2 = create_fcontext_stack(); 47 | 48 | ctx = make_fcontext(s.sptr, s.ssize, foo); 49 | ctx2 = make_fcontext(s2.sptr, s2.ssize, doo); 50 | 51 | jump_fcontext(ctx, NULL); 52 | puts("END"); 53 | 54 | destroy_fcontext_stack(&s); 55 | destroy_fcontext_stack(&s2); 56 | return 0; 57 | } -------------------------------------------------------------------------------- /termite_jobs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace termite 6 | { 7 | /// Job Callback function 8 | /// @param jobIndex if you dispatch N jobs, this parameter will be between (0 ~ N-1) 9 | /// @param userParam user data that is passed to dispatch 10 | typedef void(*JobCallback)(int jobIndex, void* userParam); 11 | 12 | struct JobPriority 13 | { 14 | enum Enum 15 | { 16 | High = 0, 17 | Normal, 18 | Low, 19 | Count 20 | }; 21 | }; 22 | 23 | struct JobDesc 24 | { 25 | JobCallback callback; /// Job Callback function, any work should be done in this function 26 | JobPriority::Enum priority; /// Job Priority, Higher priority jobs gets done sooner 27 | void* userParam; /// User data, user should keep the data valid until job is complete 28 | 29 | JobDesc() 30 | { 31 | callback = nullptr; 32 | priority = JobPriority::Normal; 33 | userParam = nullptr; 34 | } 35 | 36 | explicit JobDesc(JobCallback _callback, void* _userParam = nullptr, JobPriority::Enum _priority = JobPriority::Normal) 37 | { 38 | callback = _callback; 39 | userParam = _userParam; 40 | priority = _priority; 41 | } 42 | }; 43 | 44 | typedef volatile int32_t JobCounter; 45 | typedef JobCounter* JobHandle; 46 | 47 | /// Initialize job dispatcher, must call this function before any dispatch 48 | /// @param maxSmallFibers Sets the maximum number of small-stack fibers (workers) that can be queued, default is 128 49 | /// @param smallFiberStackSize Small fibers stack size in bytes, default is 64kb 50 | /// @param maxBigFibers Sets the maximum number of small-stack fibers (workers) that can be queued, default is 32 51 | /// @param smallFiberStackSize Big fibers stack size in bytes, default is 512kb 52 | /// @param numWorkerThreads Number of worker threads in thread-pool, if you provide UINT8_MAX, the job system will initialize (NumCpuCores-1) threads 53 | /// @param lockThreadsToCores Locks initialized thread pool to each core, Not available on all platforms. this option is not recommended unless you are on a console 54 | bool initJobDispatcher(uint16_t maxSmallFibers = 0, uint32_t smallFiberStackSize = 0, 55 | uint16_t maxBigFibers = 0, uint32_t bigFiberStackSize = 0, 56 | uint8_t numWorkerThreads = UINT8_MAX, bool lockThreadsToCores = false); 57 | 58 | /// Shuts down job dispatcher 59 | void shutdownJobDispatcher(); 60 | 61 | /// Dispatch Small stack jobs, your stack size should not exceed 'smallFiberStackSize' 62 | /// @return handle to created jobs that you can wait on later calls 63 | JobHandle dispatchSmallJobs(const JobDesc* jobs, uint16_t numJobs); 64 | 65 | /// Dispatch Big stack jobs 66 | /// @return handle to created jobs that you can wait on later calls 67 | JobHandle dispatchBigJobs(const JobDesc* jobs, uint16_t numJobs); 68 | 69 | /// Wait on dispatched jobs until they are complete 70 | void waitJobs(JobHandle handle); 71 | 72 | /// Returns number of worker threads in the thread pool 73 | uint8_t getNumWorkerThreads(); 74 | } // namespace termite 75 | 76 | 77 | --------------------------------------------------------------------------------