├── .editorconfig ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .gitlab-ci.yml ├── AUTHORS ├── LICENSE ├── Makefile ├── Makefile.common ├── README.md ├── audio.c ├── audio.h ├── audio_mixer.h ├── decoder.c ├── decoder.h ├── deps ├── lua │ ├── Makefile │ ├── README │ ├── doc │ │ ├── contents.html │ │ ├── logo.gif │ │ ├── lua.1 │ │ ├── lua.css │ │ ├── luac.1 │ │ ├── manual.css │ │ ├── manual.html │ │ └── readme.html │ └── src │ │ ├── Makefile │ │ ├── lapi.c │ │ ├── lapi.h │ │ ├── lauxlib.c │ │ ├── lauxlib.h │ │ ├── lbaselib.c │ │ ├── lcode.c │ │ ├── lcode.h │ │ ├── ldblib.c │ │ ├── ldebug.c │ │ ├── ldebug.h │ │ ├── ldo.c │ │ ├── ldo.h │ │ ├── ldump.c │ │ ├── lfunc.c │ │ ├── lfunc.h │ │ ├── lgc.c │ │ ├── lgc.h │ │ ├── linit.c │ │ ├── liolib.c │ │ ├── llex.c │ │ ├── llex.h │ │ ├── llimits.h │ │ ├── lmathlib.c │ │ ├── lmem.c │ │ ├── lmem.h │ │ ├── loadlib.c │ │ ├── lobject.c │ │ ├── lobject.h │ │ ├── lopcodes.c │ │ ├── lopcodes.h │ │ ├── loslib.c │ │ ├── lparser.c │ │ ├── lparser.h │ │ ├── lstate.c │ │ ├── lstate.h │ │ ├── lstring.c │ │ ├── lstring.h │ │ ├── lstrlib.c │ │ ├── ltable.c │ │ ├── ltable.h │ │ ├── ltablib.c │ │ ├── ltm.c │ │ ├── ltm.h │ │ ├── lua.c │ │ ├── lua.h │ │ ├── luac.c │ │ ├── luaconf.h │ │ ├── lualib.h │ │ ├── lundump.c │ │ ├── lundump.h │ │ ├── lvm.c │ │ ├── lvm.h │ │ ├── lzio.c │ │ ├── lzio.h │ │ └── print.c ├── luajit │ ├── .gitignore │ ├── COPYRIGHT │ ├── Makefile │ ├── README │ ├── doc │ │ ├── bluequad-print.css │ │ ├── bluequad.css │ │ ├── contact.html │ │ ├── ext_buffer.html │ │ ├── ext_c_api.html │ │ ├── ext_ffi.html │ │ ├── ext_ffi_api.html │ │ ├── ext_ffi_semantics.html │ │ ├── ext_ffi_tutorial.html │ │ ├── ext_jit.html │ │ ├── ext_profiler.html │ │ ├── extensions.html │ │ ├── faq.html │ │ ├── img │ │ │ └── contact.png │ │ ├── install.html │ │ ├── luajit.html │ │ ├── running.html │ │ └── status.html │ ├── dynasm │ │ ├── dasm_arm.h │ │ ├── dasm_arm.lua │ │ ├── dasm_arm64.h │ │ ├── dasm_arm64.lua │ │ ├── dasm_mips.h │ │ ├── dasm_mips.lua │ │ ├── dasm_mips64.lua │ │ ├── dasm_ppc.h │ │ ├── dasm_ppc.lua │ │ ├── dasm_proto.h │ │ ├── dasm_x64.lua │ │ ├── dasm_x86.h │ │ ├── dasm_x86.lua │ │ └── dynasm.lua │ ├── etc │ │ ├── luajit.1 │ │ └── luajit.pc │ └── src │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── Makefile.dep │ │ ├── host │ │ ├── .gitignore │ │ ├── README │ │ ├── buildvm.c │ │ ├── buildvm.h │ │ ├── buildvm_asm.c │ │ ├── buildvm_fold.c │ │ ├── buildvm_lib.c │ │ ├── buildvm_libbc.h │ │ ├── buildvm_peobj.c │ │ ├── genlibbc.lua │ │ ├── genminilua.lua │ │ └── minilua.c │ │ ├── jit │ │ ├── .gitignore │ │ ├── bc.lua │ │ ├── bcsave.lua │ │ ├── dis_arm.lua │ │ ├── dis_arm64.lua │ │ ├── dis_arm64be.lua │ │ ├── dis_mips.lua │ │ ├── dis_mips64.lua │ │ ├── dis_mips64el.lua │ │ ├── dis_mips64r6.lua │ │ ├── dis_mips64r6el.lua │ │ ├── dis_mipsel.lua │ │ ├── dis_ppc.lua │ │ ├── dis_x64.lua │ │ ├── dis_x86.lua │ │ ├── dump.lua │ │ ├── p.lua │ │ ├── v.lua │ │ └── zone.lua │ │ ├── lauxlib.h │ │ ├── lib_aux.c │ │ ├── lib_base.c │ │ ├── lib_bit.c │ │ ├── lib_buffer.c │ │ ├── lib_debug.c │ │ ├── lib_ffi.c │ │ ├── lib_init.c │ │ ├── lib_io.c │ │ ├── lib_jit.c │ │ ├── lib_math.c │ │ ├── lib_os.c │ │ ├── lib_package.c │ │ ├── lib_string.c │ │ ├── lib_table.c │ │ ├── lj_alloc.c │ │ ├── lj_alloc.h │ │ ├── lj_api.c │ │ ├── lj_arch.h │ │ ├── lj_asm.c │ │ ├── lj_asm.h │ │ ├── lj_asm_arm.h │ │ ├── lj_asm_arm64.h │ │ ├── lj_asm_mips.h │ │ ├── lj_asm_ppc.h │ │ ├── lj_asm_x86.h │ │ ├── lj_assert.c │ │ ├── lj_bc.c │ │ ├── lj_bc.h │ │ ├── lj_bcdump.h │ │ ├── lj_bcread.c │ │ ├── lj_bcwrite.c │ │ ├── lj_buf.c │ │ ├── lj_buf.h │ │ ├── lj_carith.c │ │ ├── lj_carith.h │ │ ├── lj_ccall.c │ │ ├── lj_ccall.h │ │ ├── lj_ccallback.c │ │ ├── lj_ccallback.h │ │ ├── lj_cconv.c │ │ ├── lj_cconv.h │ │ ├── lj_cdata.c │ │ ├── lj_cdata.h │ │ ├── lj_char.c │ │ ├── lj_char.h │ │ ├── lj_clib.c │ │ ├── lj_clib.h │ │ ├── lj_cparse.c │ │ ├── lj_cparse.h │ │ ├── lj_crecord.c │ │ ├── lj_crecord.h │ │ ├── lj_ctype.c │ │ ├── lj_ctype.h │ │ ├── lj_debug.c │ │ ├── lj_debug.h │ │ ├── lj_def.h │ │ ├── lj_dispatch.c │ │ ├── lj_dispatch.h │ │ ├── lj_emit_arm.h │ │ ├── lj_emit_arm64.h │ │ ├── lj_emit_mips.h │ │ ├── lj_emit_ppc.h │ │ ├── lj_emit_x86.h │ │ ├── lj_err.c │ │ ├── lj_err.h │ │ ├── lj_errmsg.h │ │ ├── lj_ff.h │ │ ├── lj_ffrecord.c │ │ ├── lj_ffrecord.h │ │ ├── lj_frame.h │ │ ├── lj_func.c │ │ ├── lj_func.h │ │ ├── lj_gc.c │ │ ├── lj_gc.h │ │ ├── lj_gdbjit.c │ │ ├── lj_gdbjit.h │ │ ├── lj_ir.c │ │ ├── lj_ir.h │ │ ├── lj_ircall.h │ │ ├── lj_iropt.h │ │ ├── lj_jit.h │ │ ├── lj_lex.c │ │ ├── lj_lex.h │ │ ├── lj_lib.c │ │ ├── lj_lib.h │ │ ├── lj_load.c │ │ ├── lj_mcode.c │ │ ├── lj_mcode.h │ │ ├── lj_meta.c │ │ ├── lj_meta.h │ │ ├── lj_obj.c │ │ ├── lj_obj.h │ │ ├── lj_opt_dce.c │ │ ├── lj_opt_fold.c │ │ ├── lj_opt_loop.c │ │ ├── lj_opt_mem.c │ │ ├── lj_opt_narrow.c │ │ ├── lj_opt_sink.c │ │ ├── lj_opt_split.c │ │ ├── lj_parse.c │ │ ├── lj_parse.h │ │ ├── lj_prng.c │ │ ├── lj_prng.h │ │ ├── lj_profile.c │ │ ├── lj_profile.h │ │ ├── lj_record.c │ │ ├── lj_record.h │ │ ├── lj_serialize.c │ │ ├── lj_serialize.h │ │ ├── lj_snap.c │ │ ├── lj_snap.h │ │ ├── lj_state.c │ │ ├── lj_state.h │ │ ├── lj_str.c │ │ ├── lj_str.h │ │ ├── lj_strfmt.c │ │ ├── lj_strfmt.h │ │ ├── lj_strfmt_num.c │ │ ├── lj_strscan.c │ │ ├── lj_strscan.h │ │ ├── lj_tab.c │ │ ├── lj_tab.h │ │ ├── lj_target.h │ │ ├── lj_target_arm.h │ │ ├── lj_target_arm64.h │ │ ├── lj_target_mips.h │ │ ├── lj_target_ppc.h │ │ ├── lj_target_x86.h │ │ ├── lj_trace.c │ │ ├── lj_trace.h │ │ ├── lj_traceerr.h │ │ ├── lj_udata.c │ │ ├── lj_udata.h │ │ ├── lj_vm.h │ │ ├── lj_vmevent.c │ │ ├── lj_vmevent.h │ │ ├── lj_vmmath.c │ │ ├── ljamalg.c │ │ ├── lua.h │ │ ├── lua.hpp │ │ ├── luaconf.h │ │ ├── luajit.c │ │ ├── luajit.h │ │ ├── lualib.h │ │ ├── msvcbuild.bat │ │ ├── nxbuild.bat │ │ ├── ps4build.bat │ │ ├── ps5build.bat │ │ ├── psvitabuild.bat │ │ ├── vm_arm.dasc │ │ ├── vm_arm64.dasc │ │ ├── vm_mips.dasc │ │ ├── vm_mips64.dasc │ │ ├── vm_ppc.dasc │ │ ├── vm_x64.dasc │ │ ├── vm_x86.dasc │ │ ├── xb1build.bat │ │ └── xedkbuild.bat ├── luasocket │ ├── libluasocket │ │ ├── auxiliar.c │ │ ├── auxiliar.h │ │ ├── buffer.c │ │ ├── buffer.h │ │ ├── except.c │ │ ├── except.h │ │ ├── ftp.lua │ │ ├── ftp.lua.h │ │ ├── http.lua │ │ ├── http.lua.h │ │ ├── inet.c │ │ ├── inet.h │ │ ├── io.c │ │ ├── io.h │ │ ├── ltn12.lua │ │ ├── ltn12.lua.h │ │ ├── lua.h │ │ ├── luasocket.c │ │ ├── luasocket.h │ │ ├── mime.c │ │ ├── mime.h │ │ ├── mime.lua │ │ ├── mime.lua.h │ │ ├── options.c │ │ ├── options.h │ │ ├── pre.lua │ │ ├── select.c │ │ ├── select.h │ │ ├── smtp.lua │ │ ├── smtp.lua.h │ │ ├── socket.h │ │ ├── socket.lua │ │ ├── socket.lua.h │ │ ├── tcp.c │ │ ├── tcp.h │ │ ├── timeout.c │ │ ├── timeout.h │ │ ├── tp.lua │ │ ├── tp.lua.h │ │ ├── udp.c │ │ ├── udp.h │ │ ├── unix.c │ │ ├── unix.h │ │ ├── url.lua │ │ ├── url.lua.h │ │ ├── usocket.c │ │ ├── usocket.h │ │ ├── wsocket.c │ │ └── wsocket.h │ ├── luasocket.c │ └── luasocket.h ├── luautf8 │ ├── lprefix.h │ ├── lutf8lib.c │ └── lutf8lib.h ├── ogg │ ├── bitwise.c │ ├── config_types.h │ ├── framing.c │ ├── ogg.h │ └── os_types.h ├── physfs │ ├── LICENSE.txt │ ├── README.txt │ ├── physfs.c │ ├── physfs.h │ ├── physfs_archiver_7z.c │ ├── physfs_archiver_dir.c │ ├── physfs_archiver_grp.c │ ├── physfs_archiver_hog.c │ ├── physfs_archiver_iso9660.c │ ├── physfs_archiver_mvl.c │ ├── physfs_archiver_qpak.c │ ├── physfs_archiver_slb.c │ ├── physfs_archiver_unpacked.c │ ├── physfs_archiver_vdf.c │ ├── physfs_archiver_wad.c │ ├── physfs_archiver_zip.c │ ├── physfs_byteorder.c │ ├── physfs_casefolding.h │ ├── physfs_internal.h │ ├── physfs_lzmasdk.h │ ├── physfs_miniz.h │ ├── physfs_platform_apple.m │ ├── physfs_platform_haiku.cpp │ ├── physfs_platform_os2.c │ ├── physfs_platform_posix.c │ ├── physfs_platform_qnx.c │ ├── physfs_platform_unix.c │ ├── physfs_platform_windows.c │ ├── physfs_platform_winrt.cpp │ ├── physfs_platforms.h │ └── physfs_unicode.c ├── stb │ ├── LICENSE │ ├── README.md │ └── stb_image.h ├── utf8 │ ├── utf8.h │ └── utf8 │ │ ├── checked.h │ │ ├── core.h │ │ └── unchecked.h ├── vorbis │ ├── analysis.c │ ├── backends.h │ ├── barkmel.c │ ├── bitrate.c │ ├── bitrate.h │ ├── block.c │ ├── books │ │ ├── coupled │ │ │ ├── res_books_51.h │ │ │ └── res_books_stereo.h │ │ ├── floor │ │ │ └── floor_books.h │ │ └── uncoupled │ │ │ └── res_books_uncoupled.h │ ├── codebook.c │ ├── codebook.h │ ├── codec.h │ ├── codec_internal.h │ ├── envelope.c │ ├── envelope.h │ ├── floor0.c │ ├── floor1.c │ ├── highlevel.h │ ├── info.c │ ├── lookup.c │ ├── lookup.h │ ├── lookup_data.h │ ├── lookups.pl │ ├── lpc.c │ ├── lpc.h │ ├── lsp.c │ ├── lsp.h │ ├── mapping0.c │ ├── masking.h │ ├── mdct.c │ ├── mdct.h │ ├── misc.h │ ├── modes │ │ ├── floor_all.h │ │ ├── psych_11.h │ │ ├── psych_16.h │ │ ├── psych_44.h │ │ ├── psych_8.h │ │ ├── residue_16.h │ │ ├── residue_44.h │ │ ├── residue_44p51.h │ │ ├── residue_44u.h │ │ ├── residue_8.h │ │ ├── setup_11.h │ │ ├── setup_16.h │ │ ├── setup_22.h │ │ ├── setup_32.h │ │ ├── setup_44.h │ │ ├── setup_44p51.h │ │ ├── setup_44u.h │ │ ├── setup_8.h │ │ └── setup_X.h │ ├── os.h │ ├── psy.c │ ├── psy.h │ ├── registry.c │ ├── registry.h │ ├── res0.c │ ├── scales.h │ ├── sharedbook.c │ ├── smallft.c │ ├── smallft.h │ ├── synthesis.c │ ├── vorbisenc.c │ ├── vorbisenc.h │ ├── vorbisfile.c │ ├── vorbisfile.h │ ├── window.c │ └── window.h └── zlib │ ├── adler32.c │ ├── compress.c │ ├── crc32.c │ ├── deflate.c │ ├── deflate.h │ ├── gzclose.c │ ├── gzfile.h │ ├── gzguts.h │ ├── gzlib.c │ ├── gzread.c │ ├── gzwrite.c │ ├── infback.c │ ├── inffast.c │ ├── inffast.h │ ├── inffixed.h │ ├── inflate.c │ ├── inflate.h │ ├── inftrees.c │ ├── inftrees.h │ ├── ioapi.c │ ├── ioapi.h │ ├── trees.c │ ├── trees.h │ ├── uncompr.c │ ├── unzip.c │ ├── unzip.h │ ├── zconf.h │ ├── zconf.h.in │ ├── zlib.h │ ├── zutil.c │ └── zutil.h ├── event.c ├── event.h ├── examples ├── benchmark │ ├── conf.lua │ ├── font.png │ ├── logo.png │ └── main.lua └── serialization │ ├── foo.png │ ├── global.lua │ ├── json.lua │ └── main.lua ├── filesystem.c ├── filesystem.h ├── graphics.c ├── graphics.h ├── image.c ├── image.h ├── input.c ├── input.h ├── jni ├── Android.mk └── Application.mk ├── joystick.c ├── joystick.h ├── keyboard.c ├── keyboard.h ├── libretro-common ├── audio │ ├── audio_mix.c │ └── conversion │ │ ├── float_to_s16.c │ │ ├── float_to_s16_neon.S │ │ ├── float_to_s16_neon.c │ │ ├── s16_to_float.c │ │ ├── s16_to_float_neon.S │ │ └── s16_to_float_neon.c ├── compat │ ├── compat_posix_string.c │ ├── compat_strcasestr.c │ ├── compat_strl.c │ └── fopen_utf8.c ├── encodings │ ├── encoding_crc32.c │ └── encoding_utf.c ├── features │ └── features_cpu.c ├── file │ ├── file_path.c │ └── file_path_io.c ├── formats │ └── wav │ │ └── rwav.c ├── include │ ├── audio │ │ ├── audio_mix.h │ │ ├── audio_resampler.h │ │ └── conversion │ │ │ ├── float_to_s16.h │ │ │ └── s16_to_float.h │ ├── boolean.h │ ├── clamping.h │ ├── compat │ │ ├── apple_compat.h │ │ ├── fopen_utf8.h │ │ ├── msvc.h │ │ ├── msvc │ │ │ └── stdint.h │ │ ├── posix_string.h │ │ ├── strcasestr.h │ │ └── strl.h │ ├── encodings │ │ ├── crc32.h │ │ └── utf.h │ ├── features │ │ └── features_cpu.h │ ├── file │ │ └── file_path.h │ ├── filters.h │ ├── formats │ │ └── rwav.h │ ├── libco.h │ ├── libretro.h │ ├── memalign.h │ ├── memmap.h │ ├── retro_assert.h │ ├── retro_common.h │ ├── retro_common_api.h │ ├── retro_endianness.h │ ├── retro_environment.h │ ├── retro_inline.h │ ├── retro_math.h │ ├── retro_miscellaneous.h │ ├── retro_timers.h │ ├── streams │ │ ├── file_stream.h │ │ ├── interface_stream.h │ │ ├── memory_stream.h │ │ └── trans_stream.h │ ├── string │ │ └── stdstring.h │ ├── time │ │ └── rtime.h │ └── vfs │ │ ├── vfs.h │ │ └── vfs_implementation.h ├── memmap │ ├── memalign.c │ └── memmap.c ├── streams │ ├── file_stream.c │ ├── interface_stream.c │ ├── memory_stream.c │ ├── trans_stream.c │ └── trans_stream_pipe.c ├── string │ └── stdstring.c ├── time │ └── rtime.c └── vfs │ └── vfs_implementation.c ├── libretro.c ├── link.T ├── live.c ├── live.h ├── lutro.c ├── lutro.h ├── lutro.sln ├── lutro_assert.h ├── lutro_math.c ├── lutro_math.h ├── lutro_stb_image.c ├── lutro_stb_image.h ├── lutro_window.c ├── lutro_window.h ├── mouse.c ├── mouse.h ├── msbuild ├── .editorconfig ├── .gitignore ├── fi-msw-buildconf.h ├── fi-printf-redirect.h ├── lua.vcxproj ├── lutro.vcxproj ├── lutro.vcxproj.filters ├── lutro_build.props ├── lutro_sources.props ├── msw-printf-stdout.cpp └── vorbis.vcxproj ├── painter.c ├── painter.h ├── runtime.c ├── runtime.h ├── sound.c ├── sound.h ├── system.c ├── system.h ├── test ├── audio │ ├── play.lua │ └── test.wav ├── conf.lua ├── graphics │ ├── base_transform.lua │ ├── font.png │ ├── grid-transform-128px.png │ ├── grid-transform-256px.png │ ├── grid-transform-32px.png │ ├── grid-transform-64px.png │ ├── line.lua │ ├── print.lua │ ├── rectangle.lua │ └── scale.lua ├── joystick │ ├── getJoystickCount.lua │ └── isDown.lua ├── main.lua ├── unit │ ├── luaunit │ │ ├── LICENSE.txt │ │ └── luaunit.lua │ ├── main.lua │ ├── modules │ │ ├── featureflags.lua │ │ ├── filesystem.lua │ │ ├── graphics.lua │ │ ├── keyboard.lua │ │ ├── math.lua │ │ ├── system.lua │ │ ├── timer.lua │ │ └── window.lua │ └── tests.lua └── window │ └── close.lua ├── tests └── audio │ ├── conf.lua │ ├── font.png │ ├── logo.png │ ├── main.lua │ ├── test_float32_mono.wav │ ├── test_ogg_mono.ogg │ └── test_s16_mono.wav ├── timer.c └── timer.h /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | 6 | [*.go] 7 | indent_style = tab 8 | indent_size = 3 9 | insert_final_newline = true 10 | 11 | # c/cpp/h rules match libretro 12 | [*.{c,cpp,h,inl}] 13 | indent_style = space 14 | insert_final_newline = true 15 | indent_size = 3 16 | 17 | [*.{txt,md}] 18 | indent_style = space 19 | indent_size = 4 20 | 21 | [*,{html,xml,cs}] 22 | indent_style = space 23 | indent_size = 2 24 | 25 | [*,{csproj,vcxproj,sln}] 26 | indent_style = tab 27 | indent_size = 4 28 | end_of_line = crlf 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Editor workspaces 2 | .vs/ 3 | .vscode/ 4 | *.user 5 | 6 | # Object files 7 | *.o 8 | *.ko 9 | *.obj 10 | *.elf 11 | /obj 12 | 13 | # Precompiled Headers vand other Build Artifacts 14 | *.gch 15 | *.pch 16 | *.ilk 17 | 18 | # Libraries 19 | *.lib 20 | *.a 21 | *.la 22 | *.lo 23 | 24 | # Shared objects (inc. Windows DLLs) 25 | *.dll 26 | *.so 27 | *.so.* 28 | *.dylib 29 | 30 | # Executables 31 | *.exe 32 | *.pdb 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Compiled files 40 | deps/luajit/src/host/buildvm 41 | deps/luajit/src/host/buildvm_arch.h 42 | deps/luajit/src/host/minilua 43 | deps/luajit/src/jit/vmdef.lua 44 | deps/luajit/src/lj_bcdef.h 45 | deps/luajit/src/lj_ffdef.h 46 | deps/luajit/src/lj_folddef.h 47 | deps/luajit/src/lj_libdef.h 48 | deps/luajit/src/lj_recdef.h 49 | deps/luajit/src/lj_vm.s 50 | deps/luajit/src/luajit 51 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Higor Eurípedes - 2 | - Main code 3 | 4 | Jean-André Santoni - 5 | - Love2d compatibility 6 | 7 | Rob Loach - 8 | - Love2d compatibility 9 | 10 | Bob Paradiso - 11 | - Ogg vorbis support 12 | 13 | Daniel de Matteis - 14 | - Makefile 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2015 Higor Eurípedes 4 | Copyright (c) 2015 Jean-André Santoni 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Lutro 2 | 3 | Experimental [Lua](http://lua.org) game framework for [libretro](http://libretro.com), following the [LÖVE](http://love2d.org) API. 4 | 5 | [Lutro](https://github.com/libretro/libretro-lutro) is software rendered and implements only a [subset of the LÖVE API](https://github.com/libretro/lutro-status). It targets portability though the libretro API and backed in dependancies. 6 | 7 | ## Sample Games 8 | 9 | * https://github.com/kivutar/onion-kidd 10 | * https://github.com/kivutar/love-vespa 11 | * https://github.com/kivutar/lutro-spaceship 12 | * https://github.com/libretro/lutro-platformer 13 | * https://github.com/libretro/lutro-game-of-life 14 | * https://github.com/libretro/lutro-snake 15 | * https://github.com/libretro/lutro-tetris 16 | * https://github.com/libretro/lutro-iyfct 17 | * https://github.com/libretro/lutro-sienna 18 | * https://github.com/libretro/lutro-pong 19 | 20 | ## Usage 21 | 22 | Through RetroArch, use the Lutro core to load the game's source directory: 23 | 24 | retroarch -L libretro_lutro.so path/to/gamedir/ 25 | 26 | Alternatively, you can load a compressed `.lutro` file: 27 | 28 | retroarch -L libretro_lutro.so game.lutro 29 | 30 | ## Build 31 | 32 | Compile Lutro by [installing the RetroArch dependencies](https://github.com/libretro/retroarch#dependencies-pc), and running: 33 | 34 | make 35 | 36 | There are a few optional defines you can use to change how Lutro behaves. 37 | 38 | - `make WANT_COMPOSITION=1` Enables alpha-blending. 39 | - `make WANT_TRANSFORM=1` Enables scaling 40 | - `make TRACE_ALLOCATION=1` Enables memory allocation tracing 41 | 42 | ## Test 43 | 44 | Run the Lutro testing suite by executing: 45 | 46 | make test 47 | 48 | To run tests manually, run: 49 | 50 | retroarch -L path/to/lutro_libretro.so test 51 | -------------------------------------------------------------------------------- /audio.h: -------------------------------------------------------------------------------- 1 | #ifndef AUDIO_H 2 | #define AUDIO_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "runtime.h" 9 | #include "sound.h" 10 | #include "decoder.h" 11 | #include "audio_mixer.h" 12 | 13 | typedef enum 14 | { 15 | AUDIO_STOPPED = 0, 16 | AUDIO_PAUSED, 17 | AUDIO_PLAYING 18 | } audio_source_state; 19 | 20 | typedef struct 21 | { 22 | // only one of these should be non-null for a given source. 23 | 24 | dec_WavData* wavData; // streaming from wav 25 | dec_OggData* oggData; // streaming from ogg 26 | 27 | snd_SoundData* sndta; // pre-decoded sound 28 | int lua_ref_sndta; // (REGISTRY) ref to sndta is held as long as this object isn't disposed/__gc'd 29 | 30 | intmax_t sndpos; // readpos in samples for pre-decoded sound only 31 | 32 | bool loop; 33 | float volume; 34 | float pitch; 35 | audio_source_state state; 36 | } audio_Source; 37 | 38 | void lutro_audio_init(lua_State* L); 39 | void lutro_audio_deinit(void); 40 | void lutro_audio_stop_all(lua_State* L); 41 | int lutro_audio_preload(lua_State *L); 42 | void lutro_mixer_render(int16_t* buffer); 43 | 44 | void mixer_render(lua_State* L, int16_t *buffer); 45 | void mixer_unref_stopped_sounds(lua_State* L); 46 | 47 | int audio_newSource(lua_State *L); 48 | int audio_setVolume(lua_State *L); 49 | int audio_getVolume(lua_State *L); 50 | int audio_play(lua_State *L); 51 | int audio_stop(lua_State *L); 52 | int audio_pause(lua_State *L); 53 | int audio_getActiveSources(lua_State *L); 54 | int audio_getActiveSourceCount(lua_State *L); 55 | 56 | int source_pause(lua_State *L); 57 | int source_setLooping(lua_State *L); 58 | int source_isLooping(lua_State *L); 59 | int source_isStopped(lua_State *L); 60 | int source_isPaused(lua_State *L); 61 | int source_isPlaying(lua_State *L); 62 | int source_getVolume(lua_State *L); 63 | int source_setVolume(lua_State *L); 64 | int source_tell(lua_State *L); 65 | int source_seek(lua_State *L); 66 | int source_getPitch(lua_State *L); 67 | int source_setPitch(lua_State *L); 68 | 69 | int source_gc(lua_State *L); 70 | 71 | 72 | #endif // AUDIO_H 73 | -------------------------------------------------------------------------------- /decoder.h: -------------------------------------------------------------------------------- 1 | #ifndef DECODER_H 2 | #define DECODER_H 3 | 4 | #include 5 | #include "audio_mixer.h" 6 | 7 | #define WAV_HEADER_CHUNK1_SIZE 36 // minimum size. the chunk can be larger. See Subchunk1Size. 8 | #define WAV_HEADER_CHUNK2_SIZE 8 9 | 10 | typedef struct 11 | { 12 | char ChunkID[4]; 13 | uint32_t ChunkSize; 14 | char Format[4]; 15 | char Subchunk1ID[4]; 16 | uint32_t Subchunk1Size; 17 | uint16_t AudioFormat; 18 | uint16_t NumChannels; 19 | uint32_t SampleRate; 20 | uint32_t ByteRate; 21 | uint16_t BlockAlign; 22 | uint16_t BitsPerSample; 23 | } wavhead_t; 24 | 25 | typedef struct 26 | { 27 | char Subchunk2ID[4]; 28 | uint32_t Subchunk2Size; 29 | } wav_subchunk2_t; 30 | 31 | typedef struct 32 | { 33 | OggVorbis_File vf; 34 | vorbis_info* info; 35 | } dec_OggData; 36 | 37 | typedef struct 38 | { 39 | void* fp; 40 | intmax_t pos; 41 | wavhead_t headc1; // RIFF header and Chunk 1 42 | wav_subchunk2_t headc2; // data chunk header (other headers are not tracked) 43 | intmax_t seekPosSubChunk2; // data subchunk could be anywhere in this evil file format. 44 | } dec_WavData; 45 | 46 | bool decWav_init(dec_WavData *data, const char *filename); 47 | void decWav_destroy(dec_WavData *data); 48 | bool decWav_seek(dec_WavData *data, intmax_t pos); 49 | intmax_t decWav_sampleTell(dec_WavData *data); 50 | bool decWav_decode(dec_WavData *data, presaturate_buffer_desc *buffer, float volume, bool loop); 51 | 52 | bool decOgg_init(dec_OggData *data, const char *filename); 53 | void decOgg_destroy(dec_OggData *data); 54 | bool decOgg_seek(dec_OggData *data, intmax_t pos); 55 | intmax_t decOgg_sampleTell(dec_OggData *data); 56 | intmax_t decOgg_sampleLength(dec_OggData *data); 57 | bool decOgg_decode(dec_OggData *data, presaturate_buffer_desc *buffer, float volume, bool loop); 58 | 59 | #endif // DECODER_H 60 | -------------------------------------------------------------------------------- /deps/lua/README: -------------------------------------------------------------------------------- 1 | README for Lua 5.1 2 | 3 | See INSTALL for installation instructions. 4 | See HISTORY for a summary of changes since the last released version. 5 | 6 | * What is Lua? 7 | ------------ 8 | Lua is a powerful, light-weight programming language designed for extending 9 | applications. Lua is also frequently used as a general-purpose, stand-alone 10 | language. Lua is free software. 11 | 12 | For complete information, visit Lua's web site at http://www.lua.org/ . 13 | For an executive summary, see http://www.lua.org/about.html . 14 | 15 | Lua has been used in many different projects around the world. 16 | For a short list, see http://www.lua.org/uses.html . 17 | 18 | * Availability 19 | ------------ 20 | Lua is freely available for both academic and commercial purposes. 21 | See COPYRIGHT and http://www.lua.org/license.html for details. 22 | Lua can be downloaded at http://www.lua.org/download.html . 23 | 24 | * Installation 25 | ------------ 26 | Lua is implemented in pure ANSI C, and compiles unmodified in all known 27 | platforms that have an ANSI C compiler. In most Unix-like platforms, simply 28 | do "make" with a suitable target. See INSTALL for detailed instructions. 29 | 30 | * Origin 31 | ------ 32 | Lua is developed at Lua.org, a laboratory of the Department of Computer 33 | Science of PUC-Rio (the Pontifical Catholic University of Rio de Janeiro 34 | in Brazil). 35 | For more information about the authors, see http://www.lua.org/authors.html . 36 | 37 | (end of README) 38 | -------------------------------------------------------------------------------- /deps/lua/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/libretro-lutro/469ddf0e236a2db15bd63b5d8c8daf5cdaa5a588/deps/lua/doc/logo.gif -------------------------------------------------------------------------------- /deps/lua/doc/lua.css: -------------------------------------------------------------------------------- 1 | body { 2 | color: #000000 ; 3 | background-color: #FFFFFF ; 4 | font-family: Helvetica, Arial, sans-serif ; 5 | text-align: justify ; 6 | margin-right: 30px ; 7 | margin-left: 30px ; 8 | } 9 | 10 | h1, h2, h3, h4 { 11 | font-family: Verdana, Geneva, sans-serif ; 12 | font-weight: normal ; 13 | font-style: italic ; 14 | } 15 | 16 | h2 { 17 | padding-top: 0.4em ; 18 | padding-bottom: 0.4em ; 19 | padding-left: 30px ; 20 | padding-right: 30px ; 21 | margin-left: -30px ; 22 | background-color: #E0E0FF ; 23 | } 24 | 25 | h3 { 26 | padding-left: 0.5em ; 27 | border-left: solid #E0E0FF 1em ; 28 | } 29 | 30 | table h3 { 31 | padding-left: 0px ; 32 | border-left: none ; 33 | } 34 | 35 | a:link { 36 | color: #000080 ; 37 | background-color: inherit ; 38 | text-decoration: none ; 39 | } 40 | 41 | a:visited { 42 | background-color: inherit ; 43 | text-decoration: none ; 44 | } 45 | 46 | a:link:hover, a:visited:hover { 47 | color: #000080 ; 48 | background-color: #E0E0FF ; 49 | } 50 | 51 | a:link:active, a:visited:active { 52 | color: #FF0000 ; 53 | } 54 | 55 | hr { 56 | border: 0 ; 57 | height: 1px ; 58 | color: #a0a0a0 ; 59 | background-color: #a0a0a0 ; 60 | } 61 | 62 | :target { 63 | background-color: #F8F8F8 ; 64 | padding: 8px ; 65 | border: solid #a0a0a0 2px ; 66 | } 67 | 68 | .footer { 69 | color: gray ; 70 | font-size: small ; 71 | } 72 | 73 | input[type=text] { 74 | border: solid #a0a0a0 2px ; 75 | border-radius: 2em ; 76 | -moz-border-radius: 2em ; 77 | background-image: url('images/search.png') ; 78 | background-repeat: no-repeat; 79 | background-position: 4px center ; 80 | padding-left: 20px ; 81 | height: 2em ; 82 | } 83 | 84 | -------------------------------------------------------------------------------- /deps/lua/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | float: right ; 12 | font-family: inherit ; 13 | font-style: normal ; 14 | font-size: small ; 15 | color: gray ; 16 | } 17 | 18 | p+h1, ul+h1 { 19 | padding-top: 0.4em ; 20 | padding-bottom: 0.4em ; 21 | padding-left: 30px ; 22 | margin-left: -30px ; 23 | background-color: #E0E0FF ; 24 | } 25 | -------------------------------------------------------------------------------- /deps/lua/doc/readme.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Lua documentation 4 | 5 | 6 | 7 | 8 | 9 |
10 |

11 | Lua 12 | Documentation 13 |

14 | 15 | This is the documentation included in the source distribution of Lua 5.1.5. 16 | 17 | 25 | 26 | Lua's 27 | official web site 28 | contains updated documentation, 29 | especially the 30 | reference manual. 31 |

32 | 33 |


34 | 35 | Last update: 36 | Fri Feb 3 09:44:42 BRST 2012 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /deps/lua/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | LUAI_FUNC void luaA_pushobject (lua_State *L, const TValue *o); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /deps/lua/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | 21 | LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, 22 | const char *opname); 23 | LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2); 24 | LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, 25 | const TValue *p2); 26 | LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, 27 | const TValue *p2); 28 | LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...); 29 | LUAI_FUNC void luaG_errormsg (lua_State *L); 30 | LUAI_FUNC int luaG_checkcode (const Proto *pt); 31 | LUAI_FUNC int luaG_checkopenop (Instruction i); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /deps/lua/src/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Stack and Call structure of Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldo_h 8 | #define ldo_h 9 | 10 | 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | #include "lzio.h" 14 | 15 | 16 | #define luaD_checkstack(L,n) \ 17 | if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \ 18 | luaD_growstack(L, n); \ 19 | else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); 20 | 21 | 22 | #define incr_top(L) {luaD_checkstack(L,1); L->top++;} 23 | 24 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 25 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 26 | 27 | #define saveci(L,p) ((char *)(p) - (char *)L->base_ci) 28 | #define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n))) 29 | 30 | 31 | /* results from luaD_precall */ 32 | #define PCRLUA 0 /* initiated a call to a Lua function */ 33 | #define PCRC 1 /* did a call to a C function */ 34 | #define PCRYIELD 2 /* C funtion yielded */ 35 | 36 | 37 | /* type of protected functions, to be ran by `runprotected' */ 38 | typedef void (*Pfunc) (lua_State *L, void *ud); 39 | 40 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name); 41 | LUAI_FUNC void luaD_callhook (lua_State *L, int event, int line); 42 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); 43 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); 44 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 45 | ptrdiff_t oldtop, ptrdiff_t ef); 46 | LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); 47 | LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); 48 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); 49 | LUAI_FUNC void luaD_growstack (lua_State *L, int n); 50 | 51 | LUAI_FUNC void luaD_throw (lua_State *L, int errcode); 52 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 53 | 54 | LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /deps/lua/src/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ 15 | cast(int, sizeof(TValue)*((n)-1))) 16 | 17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ 18 | cast(int, sizeof(TValue *)*((n)-1))) 19 | 20 | 21 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 22 | LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); 23 | LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); 24 | LUAI_FUNC UpVal *luaF_newupval (lua_State *L); 25 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 26 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 27 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 28 | LUAI_FUNC void luaF_freeclosure (lua_State *L, Closure *c); 29 | LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); 30 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 31 | int pc); 32 | 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /deps/lua/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Initialization of libraries for lua.c 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | #include "lua.h" 12 | 13 | #include "lualib.h" 14 | #include "lauxlib.h" 15 | 16 | 17 | static const luaL_Reg lualibs[] = { 18 | {"", luaopen_base}, 19 | {LUA_LOADLIBNAME, luaopen_package}, 20 | {LUA_TABLIBNAME, luaopen_table}, 21 | {LUA_IOLIBNAME, luaopen_io}, 22 | {LUA_OSLIBNAME, luaopen_os}, 23 | {LUA_STRLIBNAME, luaopen_string}, 24 | {LUA_MATHLIBNAME, luaopen_math}, 25 | {LUA_DBLIBNAME, luaopen_debug}, 26 | {NULL, NULL} 27 | }; 28 | 29 | 30 | LUALIB_API void luaL_openlibs (lua_State *L) { 31 | const luaL_Reg *lib = lualibs; 32 | for (; lib->func; lib++) { 33 | lua_pushcfunction(L, lib->func); 34 | lua_pushstring(L, lib->name); 35 | lua_call(L, 1, 0); 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /deps/lua/src/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lmem_h 8 | #define lmem_h 9 | 10 | 11 | #include 12 | 13 | #include "llimits.h" 14 | #include "lua.h" 15 | 16 | #define MEMERRMSG "not enough memory" 17 | 18 | 19 | #define luaM_reallocv(L,b,on,n,e) \ 20 | ((cast(size_t, (n)+1) <= MAX_SIZET/(e)) ? /* +1 to avoid warnings */ \ 21 | luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \ 22 | luaM_toobig(L)) 23 | 24 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 25 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 26 | #define luaM_freearray(L, b, n, t) luaM_reallocv(L, (b), n, 0, sizeof(t)) 27 | 28 | #define luaM_malloc(L,t) luaM_realloc_(L, NULL, 0, (t)) 29 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 30 | #define luaM_newvector(L,n,t) \ 31 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 32 | 33 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 34 | if ((nelems)+1 > (size)) \ 35 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 36 | 37 | #define luaM_reallocvector(L, v,oldn,n,t) \ 38 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 39 | 40 | 41 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 42 | size_t size); 43 | LUAI_FUNC void *luaM_toobig (lua_State *L); 44 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 45 | size_t size_elem, int limit, 46 | const char *errormsg); 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /deps/lua/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | 11 | #include "lgc.h" 12 | #include "lobject.h" 13 | #include "lstate.h" 14 | 15 | 16 | #define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) 17 | 18 | #define sizeudata(u) (sizeof(union Udata)+(u)->len) 19 | 20 | #define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) 21 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 22 | (sizeof(s)/sizeof(char))-1)) 23 | 24 | #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) 25 | 26 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 27 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); 28 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /deps/lua/src/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gkey(n) (&(n)->i_key.nk) 15 | #define gval(n) (&(n)->i_val) 16 | #define gnext(n) ((n)->i_key.nk.next) 17 | 18 | #define key2tval(n) (&(n)->i_key.tvk) 19 | 20 | 21 | LUAI_FUNC const TValue *luaH_getnum (Table *t, int key); 22 | LUAI_FUNC TValue *luaH_setnum (lua_State *L, Table *t, int key); 23 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 24 | LUAI_FUNC TValue *luaH_setstr (lua_State *L, Table *t, TString *key); 25 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 26 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 27 | LUAI_FUNC Table *luaH_new (lua_State *L, int narray, int lnhash); 28 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); 29 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 30 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 31 | LUAI_FUNC int luaH_getn (Table *t); 32 | 33 | 34 | #if defined(LUA_DEBUG) 35 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 36 | LUAI_FUNC int luaH_isdummy (Node *n); 37 | #endif 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /deps/lua/src/ltm.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define ltm_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "lobject.h" 16 | #include "lstate.h" 17 | #include "lstring.h" 18 | #include "ltable.h" 19 | #include "ltm.h" 20 | 21 | 22 | 23 | const char *const luaT_typenames[] = { 24 | "nil", "boolean", "userdata", "number", 25 | "string", "table", "function", "userdata", "thread", 26 | "proto", "upval" 27 | }; 28 | 29 | 30 | void luaT_init (lua_State *L) { 31 | static const char *const luaT_eventname[] = { /* ORDER TM */ 32 | "__index", "__newindex", 33 | "__gc", "__mode", "__eq", 34 | "__add", "__sub", "__mul", "__div", "__mod", 35 | "__pow", "__unm", "__len", "__lt", "__le", 36 | "__concat", "__call" 37 | }; 38 | int i; 39 | for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]); 41 | luaS_fix(G(L)->tmname[i]); /* never collect these names */ 42 | } 43 | } 44 | 45 | 46 | /* 47 | ** function to be used with macro "fasttm": optimized for absence of 48 | ** tag methods 49 | */ 50 | const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { 51 | const TValue *tm = luaH_getstr(events, ename); 52 | lua_assert(event <= TM_EQ); 53 | if (ttisnil(tm)) { /* no tag method? */ 54 | events->flags |= cast_byte(1u<metatable; 66 | break; 67 | case LUA_TUSERDATA: 68 | mt = uvalue(o)->metatable; 69 | break; 70 | default: 71 | mt = G(L)->mt[ttype(o)]; 72 | } 73 | return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); 74 | } 75 | 76 | -------------------------------------------------------------------------------- /deps/lua/src/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltm_h 8 | #define ltm_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | * WARNING: if you change the order of this enumeration, 16 | * grep "ORDER TM" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_EQ, /* last tag method with `fast' access */ 24 | TM_ADD, 25 | TM_SUB, 26 | TM_MUL, 27 | TM_DIV, 28 | TM_MOD, 29 | TM_POW, 30 | TM_UNM, 31 | TM_LEN, 32 | TM_LT, 33 | TM_LE, 34 | TM_CONCAT, 35 | TM_CALL, 36 | TM_N /* number of elements in the enum */ 37 | } TMS; 38 | 39 | 40 | 41 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 42 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 43 | 44 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 45 | 46 | LUAI_DATA const char *const luaT_typenames[]; 47 | 48 | 49 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 50 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 51 | TMS event); 52 | LUAI_FUNC void luaT_init (lua_State *L); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /deps/lua/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | /* Key to file-handle type */ 15 | #define LUA_FILEHANDLE "FILE*" 16 | 17 | 18 | #define LUA_COLIBNAME "coroutine" 19 | LUALIB_API int (luaopen_base) (lua_State *L); 20 | 21 | #define LUA_TABLIBNAME "table" 22 | LUALIB_API int (luaopen_table) (lua_State *L); 23 | 24 | #define LUA_IOLIBNAME "io" 25 | LUALIB_API int (luaopen_io) (lua_State *L); 26 | 27 | #define LUA_OSLIBNAME "os" 28 | LUALIB_API int (luaopen_os) (lua_State *L); 29 | 30 | #define LUA_STRLIBNAME "string" 31 | LUALIB_API int (luaopen_string) (lua_State *L); 32 | 33 | #define LUA_MATHLIBNAME "math" 34 | LUALIB_API int (luaopen_math) (lua_State *L); 35 | 36 | #define LUA_DBLIBNAME "debug" 37 | LUALIB_API int (luaopen_debug) (lua_State *L); 38 | 39 | #define LUA_LOADLIBNAME "package" 40 | LUALIB_API int (luaopen_package) (lua_State *L); 41 | 42 | 43 | /* open all previous libraries */ 44 | LUALIB_API void (luaL_openlibs) (lua_State *L); 45 | 46 | 47 | 48 | #ifndef lua_assert 49 | #define lua_assert(x) ((void)0) 50 | #endif 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /deps/lua/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | /* load one chunk; from lundump.c */ 14 | LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); 15 | 16 | /* make header; from lundump.c */ 17 | LUAI_FUNC void luaU_header (char* h); 18 | 19 | /* dump one chunk; from ldump.c */ 20 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); 21 | 22 | #ifdef luac_c 23 | /* print one chunk; from print.c */ 24 | LUAI_FUNC void luaU_print (const Proto* f, int full); 25 | #endif 26 | 27 | /* for header of binary files -- this is Lua 5.1 */ 28 | #define LUAC_VERSION 0x51 29 | 30 | /* for header of binary files -- this is the official format */ 31 | #define LUAC_FORMAT 0 32 | 33 | /* size of header of binary files */ 34 | #define LUAC_HEADERSIZE 12 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /deps/lua/src/lvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lvm_h 8 | #define lvm_h 9 | 10 | 11 | #include "ldo.h" 12 | #include "lobject.h" 13 | #include "ltm.h" 14 | 15 | 16 | #define tostring(L,o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) 17 | 18 | #define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \ 19 | (((o) = luaV_tonumber(o,n)) != NULL)) 20 | 21 | #define equalobj(L,o1,o2) \ 22 | (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) 23 | 24 | 25 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 26 | LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); 27 | LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); 28 | LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); 29 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, 30 | StkId val); 31 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, 32 | StkId val); 33 | LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); 34 | LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /deps/lua/src/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** a generic input stream interface 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define lzio_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "llimits.h" 16 | #include "lmem.h" 17 | #include "lstate.h" 18 | #include "lzio.h" 19 | 20 | 21 | int luaZ_fill (ZIO *z) { 22 | size_t size; 23 | lua_State *L = z->L; 24 | const char *buff; 25 | lua_unlock(L); 26 | buff = z->reader(L, z->data, &size); 27 | lua_lock(L); 28 | if (buff == NULL || size == 0) return EOZ; 29 | z->n = size - 1; 30 | z->p = buff; 31 | return char2int(*(z->p++)); 32 | } 33 | 34 | 35 | int luaZ_lookahead (ZIO *z) { 36 | if (z->n == 0) { 37 | if (luaZ_fill(z) == EOZ) 38 | return EOZ; 39 | else { 40 | z->n++; /* luaZ_fill removed first byte; put back it */ 41 | z->p--; 42 | } 43 | } 44 | return char2int(*z->p); 45 | } 46 | 47 | 48 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 49 | z->L = L; 50 | z->reader = reader; 51 | z->data = data; 52 | z->n = 0; 53 | z->p = NULL; 54 | } 55 | 56 | 57 | /* --------------------------------------------------------------- read --- */ 58 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 59 | while (n) { 60 | size_t m; 61 | if (luaZ_lookahead(z) == EOZ) 62 | return n; /* return number of missing bytes */ 63 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 64 | memcpy(b, z->p, m); 65 | z->n -= m; 66 | z->p += m; 67 | b = (char *)b + m; 68 | n -= m; 69 | } 70 | return 0; 71 | } 72 | 73 | /* ------------------------------------------------------------------------ */ 74 | char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { 75 | if (n > buff->buffsize) { 76 | if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; 77 | luaZ_resizebuffer(L, buff, n); 78 | } 79 | return buff->buffer; 80 | } 81 | 82 | 83 | -------------------------------------------------------------------------------- /deps/lua/src/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define char2int(c) cast(int, cast(unsigned char, (c))) 21 | 22 | #define zgetc(z) (((z)->n--)>0 ? char2int(*(z)->p++) : luaZ_fill(z)) 23 | 24 | typedef struct Mbuffer { 25 | char *buffer; 26 | size_t n; 27 | size_t buffsize; 28 | } Mbuffer; 29 | 30 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 31 | 32 | #define luaZ_buffer(buff) ((buff)->buffer) 33 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 34 | #define luaZ_bufflen(buff) ((buff)->n) 35 | 36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 37 | 38 | 39 | #define luaZ_resizebuffer(L, buff, size) \ 40 | (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ 41 | (buff)->buffsize = size) 42 | 43 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 44 | 45 | 46 | LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); 47 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 48 | void *data); 49 | LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ 50 | LUAI_FUNC int luaZ_lookahead (ZIO *z); 51 | 52 | 53 | 54 | /* --------- Private Part ------------------ */ 55 | 56 | struct Zio { 57 | size_t n; /* bytes still unread */ 58 | const char *p; /* current position in buffer */ 59 | lua_Reader reader; 60 | void* data; /* additional data */ 61 | lua_State *L; /* Lua state (for reader) */ 62 | }; 63 | 64 | 65 | LUAI_FUNC int luaZ_fill (ZIO *z); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /deps/luajit/.gitignore: -------------------------------------------------------------------------------- 1 | *.[oa] 2 | *.so 3 | *.obj 4 | *.lib 5 | *.exp 6 | *.dll 7 | *.exe 8 | *.manifest 9 | *.dmp 10 | *.swp 11 | .tags 12 | -------------------------------------------------------------------------------- /deps/luajit/README: -------------------------------------------------------------------------------- 1 | README for LuaJIT 2.1.0-beta3 2 | ----------------------------- 3 | 4 | LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language. 5 | 6 | Project Homepage: https://luajit.org/ 7 | 8 | LuaJIT is Copyright (C) 2005-2022 Mike Pall. 9 | LuaJIT is free software, released under the MIT license. 10 | See full Copyright Notice in the COPYRIGHT file or in luajit.h. 11 | 12 | Documentation for LuaJIT is available in HTML format. 13 | Please point your favorite browser to: 14 | 15 | doc/luajit.html 16 | 17 | -------------------------------------------------------------------------------- /deps/luajit/doc/img/contact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/libretro-lutro/469ddf0e236a2db15bd63b5d8c8daf5cdaa5a588/deps/luajit/doc/img/contact.png -------------------------------------------------------------------------------- /deps/luajit/dynasm/dasm_mips64.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- DynASM MIPS64 module. 3 | -- 4 | -- Copyright (C) 2005-2022 Mike Pall. All rights reserved. 5 | -- See dynasm.lua for full copyright notice. 6 | ------------------------------------------------------------------------------ 7 | -- This module just sets 64 bit mode for the combined MIPS/MIPS64 module. 8 | -- All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | mips64 = true -- Using a global is an ugly, but effective solution. 12 | return require("dasm_mips") 13 | -------------------------------------------------------------------------------- /deps/luajit/dynasm/dasm_x64.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- DynASM x64 module. 3 | -- 4 | -- Copyright (C) 2005-2022 Mike Pall. All rights reserved. 5 | -- See dynasm.lua for full copyright notice. 6 | ------------------------------------------------------------------------------ 7 | -- This module just sets 64 bit mode for the combined x86/x64 module. 8 | -- All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | x64 = true -- Using a global is an ugly, but effective solution. 12 | return require("dasm_x86") 13 | -------------------------------------------------------------------------------- /deps/luajit/etc/luajit.pc: -------------------------------------------------------------------------------- 1 | # Package information for LuaJIT to be used by pkg-config. 2 | majver=2 3 | minver=1 4 | relver=0 5 | version=${majver}.${minver}.${relver}-beta3 6 | abiver=5.1 7 | 8 | prefix=/usr/local 9 | multilib=lib 10 | exec_prefix=${prefix} 11 | libdir=${exec_prefix}/${multilib} 12 | libname=luajit-${abiver} 13 | includedir=${prefix}/include/luajit-${majver}.${minver} 14 | 15 | INSTALL_LMOD=${prefix}/share/lua/${abiver} 16 | INSTALL_CMOD=${prefix}/${multilib}/lua/${abiver} 17 | 18 | Name: LuaJIT 19 | Description: Just-in-time compiler for Lua 20 | URL: https://luajit.org 21 | Version: ${version} 22 | Requires: 23 | Libs: -L${libdir} -l${libname} 24 | Libs.private: -Wl,-E -lm -ldl 25 | Cflags: -I${includedir} 26 | -------------------------------------------------------------------------------- /deps/luajit/src/.gitignore: -------------------------------------------------------------------------------- 1 | luajit 2 | lj_bcdef.h 3 | lj_ffdef.h 4 | lj_libdef.h 5 | lj_recdef.h 6 | lj_folddef.h 7 | lj_vm.[sS] 8 | -------------------------------------------------------------------------------- /deps/luajit/src/host/.gitignore: -------------------------------------------------------------------------------- 1 | minilua 2 | buildvm 3 | buildvm_arch.h 4 | -------------------------------------------------------------------------------- /deps/luajit/src/host/README: -------------------------------------------------------------------------------- 1 | The files in this directory are only used during the build process of LuaJIT. 2 | For cross-compilation, they must be executed on the host, not on the target. 3 | 4 | These files should NOT be installed! 5 | -------------------------------------------------------------------------------- /deps/luajit/src/jit/.gitignore: -------------------------------------------------------------------------------- 1 | vmdef.lua 2 | -------------------------------------------------------------------------------- /deps/luajit/src/jit/dis_arm64be.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT ARM64BE disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2022 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- ARM64 instructions are always little-endian. So just forward to the 8 | -- common ARM64 disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | return require((string.match(..., ".*%.") or "").."dis_arm64") 12 | 13 | -------------------------------------------------------------------------------- /deps/luajit/src/jit/dis_mips64.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT MIPS64 disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2022 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the big-endian functions from the 8 | -- MIPS disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips") 12 | return { 13 | create = dis_mips.create, 14 | disass = dis_mips.disass, 15 | regname = dis_mips.regname 16 | } 17 | 18 | -------------------------------------------------------------------------------- /deps/luajit/src/jit/dis_mips64el.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT MIPS64EL disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2022 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the little-endian functions from the 8 | -- MIPS disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips") 12 | return { 13 | create = dis_mips.create_el, 14 | disass = dis_mips.disass_el, 15 | regname = dis_mips.regname 16 | } 17 | 18 | -------------------------------------------------------------------------------- /deps/luajit/src/jit/dis_mips64r6.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT MIPS64R6 disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2022 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the r6 big-endian functions from the 8 | -- MIPS disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips") 12 | return { 13 | create = dis_mips.create_r6, 14 | disass = dis_mips.disass_r6, 15 | regname = dis_mips.regname 16 | } 17 | 18 | -------------------------------------------------------------------------------- /deps/luajit/src/jit/dis_mips64r6el.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT MIPS64R6EL disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2022 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the r6 little-endian functions from the 8 | -- MIPS disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips") 12 | return { 13 | create = dis_mips.create_r6_el, 14 | disass = dis_mips.disass_r6_el, 15 | regname = dis_mips.regname 16 | } 17 | 18 | -------------------------------------------------------------------------------- /deps/luajit/src/jit/dis_mipsel.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT MIPSEL disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2022 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the little-endian functions from the 8 | -- MIPS disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local dis_mips = require((string.match(..., ".*%.") or "").."dis_mips") 12 | return { 13 | create = dis_mips.create_el, 14 | disass = dis_mips.disass_el, 15 | regname = dis_mips.regname 16 | } 17 | 18 | -------------------------------------------------------------------------------- /deps/luajit/src/jit/dis_x64.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT x64 disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2022 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the 64 bit functions from the combined 8 | -- x86/x64 disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local dis_x86 = require((string.match(..., ".*%.") or "").."dis_x86") 12 | return { 13 | create = dis_x86.create64, 14 | disass = dis_x86.disass64, 15 | regname = dis_x86.regname64 16 | } 17 | 18 | -------------------------------------------------------------------------------- /deps/luajit/src/jit/zone.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT profiler zones. 3 | -- 4 | -- Copyright (C) 2005-2022 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- 8 | -- This module implements a simple hierarchical zone model. 9 | -- 10 | -- Example usage: 11 | -- 12 | -- local zone = require("jit.zone") 13 | -- zone("AI") 14 | -- ... 15 | -- zone("A*") 16 | -- ... 17 | -- print(zone:get()) --> "A*" 18 | -- ... 19 | -- zone() 20 | -- ... 21 | -- print(zone:get()) --> "AI" 22 | -- ... 23 | -- zone() 24 | -- 25 | ---------------------------------------------------------------------------- 26 | 27 | local remove = table.remove 28 | 29 | return setmetatable({ 30 | flush = function(t) 31 | for i=#t,1,-1 do t[i] = nil end 32 | end, 33 | get = function(t) 34 | return t[#t] 35 | end 36 | }, { 37 | __call = function(t, zone) 38 | if zone then 39 | t[#t+1] = zone 40 | else 41 | return (assert(remove(t), "empty zone stack")) 42 | end 43 | end 44 | }) 45 | 46 | -------------------------------------------------------------------------------- /deps/luajit/src/lib_init.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Library initialization. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | ** 5 | ** Major parts taken verbatim from the Lua interpreter. 6 | ** Copyright (C) 1994-2008 Lua.org, PUC-Rio. See Copyright Notice in lua.h 7 | */ 8 | 9 | #define lib_init_c 10 | #define LUA_LIB 11 | 12 | #include "lua.h" 13 | #include "lauxlib.h" 14 | #include "lualib.h" 15 | 16 | #include "lj_arch.h" 17 | 18 | static const luaL_Reg lj_lib_load[] = { 19 | { "", luaopen_base }, 20 | { LUA_LOADLIBNAME, luaopen_package }, 21 | { LUA_TABLIBNAME, luaopen_table }, 22 | { LUA_IOLIBNAME, luaopen_io }, 23 | { LUA_OSLIBNAME, luaopen_os }, 24 | { LUA_STRLIBNAME, luaopen_string }, 25 | { LUA_MATHLIBNAME, luaopen_math }, 26 | { LUA_DBLIBNAME, luaopen_debug }, 27 | { LUA_BITLIBNAME, luaopen_bit }, 28 | { LUA_JITLIBNAME, luaopen_jit }, 29 | { NULL, NULL } 30 | }; 31 | 32 | static const luaL_Reg lj_lib_preload[] = { 33 | #if LJ_HASFFI 34 | { LUA_FFILIBNAME, luaopen_ffi }, 35 | #endif 36 | { NULL, NULL } 37 | }; 38 | 39 | LUALIB_API void luaL_openlibs(lua_State *L) 40 | { 41 | const luaL_Reg *lib; 42 | for (lib = lj_lib_load; lib->func; lib++) { 43 | lua_pushcfunction(L, lib->func); 44 | lua_pushstring(L, lib->name); 45 | lua_call(L, 1, 0); 46 | } 47 | luaL_findtable(L, LUA_REGISTRYINDEX, "_PRELOAD", 48 | sizeof(lj_lib_preload)/sizeof(lj_lib_preload[0])-1); 49 | for (lib = lj_lib_preload; lib->func; lib++) { 50 | lua_pushcfunction(L, lib->func); 51 | lua_setfield(L, -2, lib->name); 52 | } 53 | lua_pop(L, 1); 54 | } 55 | 56 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Bundled memory allocator. 3 | ** Donated to the public domain. 4 | */ 5 | 6 | #ifndef _LJ_ALLOC_H 7 | #define _LJ_ALLOC_H 8 | 9 | #include "lj_def.h" 10 | 11 | #ifndef LUAJIT_USE_SYSMALLOC 12 | LJ_FUNC void *lj_alloc_create(PRNGState *rs); 13 | LJ_FUNC void lj_alloc_setprng(void *msp, PRNGState *rs); 14 | LJ_FUNC void lj_alloc_destroy(void *msp); 15 | LJ_FUNC void *lj_alloc_f(void *msp, void *ptr, size_t osize, size_t nsize); 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_asm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** IR assembler (SSA IR -> machine code). 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_ASM_H 7 | #define _LJ_ASM_H 8 | 9 | #include "lj_jit.h" 10 | 11 | #if LJ_HASJIT 12 | LJ_FUNC void lj_asm_trace(jit_State *J, GCtrace *T); 13 | LJ_FUNC void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, 14 | MCode *target); 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_assert.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Internal assertions. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_assert_c 7 | #define LUA_CORE 8 | 9 | #if defined(LUA_USE_ASSERT) || defined(LUA_USE_APICHECK) 10 | 11 | #include 12 | 13 | #include "lj_obj.h" 14 | 15 | void lj_assert_fail(global_State *g, const char *file, int line, 16 | const char *func, const char *fmt, ...) 17 | { 18 | va_list argp; 19 | va_start(argp, fmt); 20 | fprintf(stderr, "LuaJIT ASSERT %s:%d: %s: ", file, line, func); 21 | vfprintf(stderr, fmt, argp); 22 | fputc('\n', stderr); 23 | va_end(argp); 24 | UNUSED(g); /* May be NULL. TODO: optionally dump state. */ 25 | abort(); 26 | } 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_bc.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Bytecode instruction modes. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_bc_c 7 | #define LUA_CORE 8 | 9 | #include "lj_obj.h" 10 | #include "lj_bc.h" 11 | 12 | /* Bytecode offsets and bytecode instruction modes. */ 13 | #include "lj_bcdef.h" 14 | 15 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_bcdump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Bytecode dump definitions. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_BCDUMP_H 7 | #define _LJ_BCDUMP_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_lex.h" 11 | 12 | /* -- Bytecode dump format ------------------------------------------------ */ 13 | 14 | /* 15 | ** dump = header proto+ 0U 16 | ** header = ESC 'L' 'J' versionB flagsU [namelenU nameB*] 17 | ** proto = lengthU pdata 18 | ** pdata = phead bcinsW* uvdataH* kgc* knum* [debugB*] 19 | ** phead = flagsB numparamsB framesizeB numuvB numkgcU numknU numbcU 20 | ** [debuglenU [firstlineU numlineU]] 21 | ** kgc = kgctypeU { ktab | (loU hiU) | (rloU rhiU iloU ihiU) | strB* } 22 | ** knum = intU0 | (loU1 hiU) 23 | ** ktab = narrayU nhashU karray* khash* 24 | ** karray = ktabk 25 | ** khash = ktabk ktabk 26 | ** ktabk = ktabtypeU { intU | (loU hiU) | strB* } 27 | ** 28 | ** B = 8 bit, H = 16 bit, W = 32 bit, U = ULEB128 of W, U0/U1 = ULEB128 of W+1 29 | */ 30 | 31 | /* Bytecode dump header. */ 32 | #define BCDUMP_HEAD1 0x1b 33 | #define BCDUMP_HEAD2 0x4c 34 | #define BCDUMP_HEAD3 0x4a 35 | 36 | /* If you perform *any* kind of private modifications to the bytecode itself 37 | ** or to the dump format, you *must* set BCDUMP_VERSION to 0x80 or higher. 38 | */ 39 | #define BCDUMP_VERSION 2 40 | 41 | /* Compatibility flags. */ 42 | #define BCDUMP_F_BE 0x01 43 | #define BCDUMP_F_STRIP 0x02 44 | #define BCDUMP_F_FFI 0x04 45 | #define BCDUMP_F_FR2 0x08 46 | 47 | #define BCDUMP_F_KNOWN (BCDUMP_F_FR2*2-1) 48 | 49 | /* Type codes for the GC constants of a prototype. Plus length for strings. */ 50 | enum { 51 | BCDUMP_KGC_CHILD, BCDUMP_KGC_TAB, BCDUMP_KGC_I64, BCDUMP_KGC_U64, 52 | BCDUMP_KGC_COMPLEX, BCDUMP_KGC_STR 53 | }; 54 | 55 | /* Type codes for the keys/values of a constant table. */ 56 | enum { 57 | BCDUMP_KTAB_NIL, BCDUMP_KTAB_FALSE, BCDUMP_KTAB_TRUE, 58 | BCDUMP_KTAB_INT, BCDUMP_KTAB_NUM, BCDUMP_KTAB_STR 59 | }; 60 | 61 | /* -- Bytecode reader/writer ---------------------------------------------- */ 62 | 63 | LJ_FUNC int lj_bcwrite(lua_State *L, GCproto *pt, lua_Writer writer, 64 | void *data, int strip); 65 | LJ_FUNC GCproto *lj_bcread_proto(LexState *ls); 66 | LJ_FUNC GCproto *lj_bcread(LexState *ls); 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_carith.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** C data arithmetic. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CARITH_H 7 | #define _LJ_CARITH_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASFFI 12 | 13 | LJ_FUNC int lj_carith_op(lua_State *L, MMS mm); 14 | 15 | #if LJ_32 16 | LJ_FUNC uint64_t lj_carith_shl64(uint64_t x, int32_t sh); 17 | LJ_FUNC uint64_t lj_carith_shr64(uint64_t x, int32_t sh); 18 | LJ_FUNC uint64_t lj_carith_sar64(uint64_t x, int32_t sh); 19 | LJ_FUNC uint64_t lj_carith_rol64(uint64_t x, int32_t sh); 20 | LJ_FUNC uint64_t lj_carith_ror64(uint64_t x, int32_t sh); 21 | #endif 22 | LJ_FUNC uint64_t lj_carith_shift64(uint64_t x, int32_t sh, int op); 23 | LJ_FUNC uint64_t lj_carith_check64(lua_State *L, int narg, CTypeID *id); 24 | 25 | #if LJ_32 && LJ_HASJIT 26 | LJ_FUNC int64_t lj_carith_mul64(int64_t x, int64_t k); 27 | #endif 28 | LJ_FUNC uint64_t lj_carith_divu64(uint64_t a, uint64_t b); 29 | LJ_FUNC int64_t lj_carith_divi64(int64_t a, int64_t b); 30 | LJ_FUNC uint64_t lj_carith_modu64(uint64_t a, uint64_t b); 31 | LJ_FUNC int64_t lj_carith_modi64(int64_t a, int64_t b); 32 | LJ_FUNC uint64_t lj_carith_powu64(uint64_t x, uint64_t k); 33 | LJ_FUNC int64_t lj_carith_powi64(int64_t x, int64_t k); 34 | 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_ccallback.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FFI C callback handling. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CCALLBACK_H 7 | #define _LJ_CCALLBACK_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_ctype.h" 11 | 12 | #if LJ_HASFFI 13 | 14 | /* Really belongs to lj_vm.h. */ 15 | LJ_ASMF void lj_vm_ffi_callback(void); 16 | 17 | LJ_FUNC MSize lj_ccallback_ptr2slot(CTState *cts, void *p); 18 | LJ_FUNCA lua_State * LJ_FASTCALL lj_ccallback_enter(CTState *cts, void *cf); 19 | LJ_FUNCA void LJ_FASTCALL lj_ccallback_leave(CTState *cts, TValue *o); 20 | LJ_FUNC void *lj_ccallback_new(CTState *cts, CType *ct, GCfunc *fn); 21 | LJ_FUNC void lj_ccallback_mcode_free(CTState *cts); 22 | 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_char.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Character types. 3 | ** Donated to the public domain. 4 | ** 5 | ** This is intended to replace the problematic libc single-byte NLS functions. 6 | ** These just don't make sense anymore with UTF-8 locales becoming the norm 7 | ** on POSIX systems. It never worked too well on Windows systems since hardly 8 | ** anyone bothered to call setlocale(). 9 | ** 10 | ** This table is hardcoded for ASCII. Identifiers include the characters 11 | ** 128-255, too. This allows for the use of all non-ASCII chars as identifiers 12 | ** in the lexer. This is a broad definition, but works well in practice 13 | ** for both UTF-8 locales and most single-byte locales (such as ISO-8859-*). 14 | ** 15 | ** If you really need proper character types for UTF-8 strings, please use 16 | ** an add-on library such as slnunicode: http://luaforge.net/projects/sln/ 17 | */ 18 | 19 | #define lj_char_c 20 | #define LUA_CORE 21 | 22 | #include "lj_char.h" 23 | 24 | LJ_DATADEF const uint8_t lj_char_bits[257] = { 25 | 0, 26 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 1, 1, 27 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 28 | 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29 | 152,152,152,152,152,152,152,152,152,152, 4, 4, 4, 4, 4, 4, 30 | 4,176,176,176,176,176,176,160,160,160,160,160,160,160,160,160, 31 | 160,160,160,160,160,160,160,160,160,160,160, 4, 4, 4, 4,132, 32 | 4,208,208,208,208,208,208,192,192,192,192,192,192,192,192,192, 33 | 192,192,192,192,192,192,192,192,192,192,192, 4, 4, 4, 4, 1, 34 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 35 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 36 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 37 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 38 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 39 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 40 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 41 | 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128 42 | }; 43 | 44 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_char.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Character types. 3 | ** Donated to the public domain. 4 | */ 5 | 6 | #ifndef _LJ_CHAR_H 7 | #define _LJ_CHAR_H 8 | 9 | #include "lj_def.h" 10 | 11 | #define LJ_CHAR_CNTRL 0x01 12 | #define LJ_CHAR_SPACE 0x02 13 | #define LJ_CHAR_PUNCT 0x04 14 | #define LJ_CHAR_DIGIT 0x08 15 | #define LJ_CHAR_XDIGIT 0x10 16 | #define LJ_CHAR_UPPER 0x20 17 | #define LJ_CHAR_LOWER 0x40 18 | #define LJ_CHAR_IDENT 0x80 19 | #define LJ_CHAR_ALPHA (LJ_CHAR_LOWER|LJ_CHAR_UPPER) 20 | #define LJ_CHAR_ALNUM (LJ_CHAR_ALPHA|LJ_CHAR_DIGIT) 21 | #define LJ_CHAR_GRAPH (LJ_CHAR_ALNUM|LJ_CHAR_PUNCT) 22 | 23 | /* Only pass -1 or 0..255 to these macros. Never pass a signed char! */ 24 | #define lj_char_isa(c, t) ((lj_char_bits+1)[(c)] & t) 25 | #define lj_char_iscntrl(c) lj_char_isa((c), LJ_CHAR_CNTRL) 26 | #define lj_char_isspace(c) lj_char_isa((c), LJ_CHAR_SPACE) 27 | #define lj_char_ispunct(c) lj_char_isa((c), LJ_CHAR_PUNCT) 28 | #define lj_char_isdigit(c) lj_char_isa((c), LJ_CHAR_DIGIT) 29 | #define lj_char_isxdigit(c) lj_char_isa((c), LJ_CHAR_XDIGIT) 30 | #define lj_char_isupper(c) lj_char_isa((c), LJ_CHAR_UPPER) 31 | #define lj_char_islower(c) lj_char_isa((c), LJ_CHAR_LOWER) 32 | #define lj_char_isident(c) lj_char_isa((c), LJ_CHAR_IDENT) 33 | #define lj_char_isalpha(c) lj_char_isa((c), LJ_CHAR_ALPHA) 34 | #define lj_char_isalnum(c) lj_char_isa((c), LJ_CHAR_ALNUM) 35 | #define lj_char_isgraph(c) lj_char_isa((c), LJ_CHAR_GRAPH) 36 | 37 | #define lj_char_toupper(c) ((c) - (lj_char_islower(c) >> 1)) 38 | #define lj_char_tolower(c) ((c) + lj_char_isupper(c)) 39 | 40 | LJ_DATA const uint8_t lj_char_bits[257]; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_clib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FFI C library loader. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CLIB_H 7 | #define _LJ_CLIB_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASFFI 12 | 13 | /* Namespace for C library indexing. */ 14 | #define CLNS_INDEX ((1u<env. */ 20 | } CLibrary; 21 | 22 | LJ_FUNC TValue *lj_clib_index(lua_State *L, CLibrary *cl, GCstr *name); 23 | LJ_FUNC void lj_clib_load(lua_State *L, GCtab *mt, GCstr *name, int global); 24 | LJ_FUNC void lj_clib_unload(CLibrary *cl); 25 | LJ_FUNC void lj_clib_default(lua_State *L, GCtab *mt); 26 | 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_crecord.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Trace recorder for C data operations. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CRECORD_H 7 | #define _LJ_CRECORD_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | #include "lj_ffrecord.h" 12 | 13 | #if LJ_HASJIT && LJ_HASFFI 14 | LJ_FUNC void LJ_FASTCALL recff_cdata_index(jit_State *J, RecordFFData *rd); 15 | LJ_FUNC void LJ_FASTCALL recff_cdata_call(jit_State *J, RecordFFData *rd); 16 | LJ_FUNC void LJ_FASTCALL recff_cdata_arith(jit_State *J, RecordFFData *rd); 17 | LJ_FUNC void LJ_FASTCALL recff_clib_index(jit_State *J, RecordFFData *rd); 18 | LJ_FUNC void LJ_FASTCALL recff_ffi_new(jit_State *J, RecordFFData *rd); 19 | LJ_FUNC void LJ_FASTCALL recff_ffi_errno(jit_State *J, RecordFFData *rd); 20 | LJ_FUNC void LJ_FASTCALL recff_ffi_string(jit_State *J, RecordFFData *rd); 21 | LJ_FUNC void LJ_FASTCALL recff_ffi_copy(jit_State *J, RecordFFData *rd); 22 | LJ_FUNC void LJ_FASTCALL recff_ffi_fill(jit_State *J, RecordFFData *rd); 23 | LJ_FUNC void LJ_FASTCALL recff_ffi_typeof(jit_State *J, RecordFFData *rd); 24 | LJ_FUNC void LJ_FASTCALL recff_ffi_istype(jit_State *J, RecordFFData *rd); 25 | LJ_FUNC void LJ_FASTCALL recff_ffi_abi(jit_State *J, RecordFFData *rd); 26 | LJ_FUNC void LJ_FASTCALL recff_ffi_xof(jit_State *J, RecordFFData *rd); 27 | LJ_FUNC void LJ_FASTCALL recff_ffi_gc(jit_State *J, RecordFFData *rd); 28 | 29 | LJ_FUNC void LJ_FASTCALL recff_bit64_tobit(jit_State *J, RecordFFData *rd); 30 | LJ_FUNC int LJ_FASTCALL recff_bit64_unary(jit_State *J, RecordFFData *rd); 31 | LJ_FUNC int LJ_FASTCALL recff_bit64_nary(jit_State *J, RecordFFData *rd); 32 | LJ_FUNC int LJ_FASTCALL recff_bit64_shift(jit_State *J, RecordFFData *rd); 33 | LJ_FUNC TRef recff_bit64_tohex(jit_State *J, RecordFFData *rd, TRef hdr); 34 | 35 | LJ_FUNC void LJ_FASTCALL lj_crecord_tonumber(jit_State *J, RecordFFData *rd); 36 | LJ_FUNC TRef lj_crecord_loadiu64(jit_State *J, TRef tr, cTValue *o); 37 | #if LJ_HASBUFFER 38 | LJ_FUNC TRef lj_crecord_topcvoid(jit_State *J, TRef tr, cTValue *o); 39 | LJ_FUNC TRef lj_crecord_topuint8(jit_State *J, TRef tr); 40 | #endif 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Debugging and introspection. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_DEBUG_H 7 | #define _LJ_DEBUG_H 8 | 9 | #include "lj_obj.h" 10 | 11 | typedef struct lj_Debug { 12 | /* Common fields. Must be in the same order as in lua.h. */ 13 | int event; 14 | const char *name; 15 | const char *namewhat; 16 | const char *what; 17 | const char *source; 18 | int currentline; 19 | int nups; 20 | int linedefined; 21 | int lastlinedefined; 22 | char short_src[LUA_IDSIZE]; 23 | int i_ci; 24 | /* Extended fields. Only valid if lj_debug_getinfo() is called with ext = 1.*/ 25 | int nparams; 26 | int isvararg; 27 | } lj_Debug; 28 | 29 | LJ_FUNC cTValue *lj_debug_frame(lua_State *L, int level, int *size); 30 | LJ_FUNC BCLine LJ_FASTCALL lj_debug_line(GCproto *pt, BCPos pc); 31 | LJ_FUNC const char *lj_debug_uvname(GCproto *pt, uint32_t idx); 32 | LJ_FUNC const char *lj_debug_uvnamev(cTValue *o, uint32_t idx, TValue **tvp, 33 | GCobj **op); 34 | LJ_FUNC const char *lj_debug_slotname(GCproto *pt, const BCIns *pc, 35 | BCReg slot, const char **name); 36 | LJ_FUNC const char *lj_debug_funcname(lua_State *L, cTValue *frame, 37 | const char **name); 38 | LJ_FUNC void lj_debug_shortname(char *out, GCstr *str, BCLine line); 39 | LJ_FUNC void lj_debug_addloc(lua_State *L, const char *msg, 40 | cTValue *frame, cTValue *nextframe); 41 | LJ_FUNC void lj_debug_pushloc(lua_State *L, GCproto *pt, BCPos pc); 42 | LJ_FUNC int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar, 43 | int ext); 44 | #if LJ_HASPROFILE 45 | LJ_FUNC void lj_debug_dumpstack(lua_State *L, SBuf *sb, const char *fmt, 46 | int depth); 47 | #endif 48 | 49 | /* Fixed internal variable names. */ 50 | #define VARNAMEDEF(_) \ 51 | _(FOR_IDX, "(for index)") \ 52 | _(FOR_STOP, "(for limit)") \ 53 | _(FOR_STEP, "(for step)") \ 54 | _(FOR_GEN, "(for generator)") \ 55 | _(FOR_STATE, "(for state)") \ 56 | _(FOR_CTL, "(for control)") 57 | 58 | enum { 59 | VARNAME_END, 60 | #define VARNAMEENUM(name, str) VARNAME_##name, 61 | VARNAMEDEF(VARNAMEENUM) 62 | #undef VARNAMEENUM 63 | VARNAME__MAX 64 | }; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_err.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Error handling. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_ERR_H 7 | #define _LJ_ERR_H 8 | 9 | #include 10 | 11 | #include "lj_obj.h" 12 | 13 | typedef enum { 14 | #define ERRDEF(name, msg) \ 15 | LJ_ERR_##name, LJ_ERR_##name##_ = LJ_ERR_##name + sizeof(msg)-1, 16 | #include "lj_errmsg.h" 17 | LJ_ERR__MAX 18 | } ErrMsg; 19 | 20 | LJ_DATA const char *lj_err_allmsg; 21 | #define err2msg(em) (lj_err_allmsg+(int)(em)) 22 | 23 | LJ_FUNC GCstr *lj_err_str(lua_State *L, ErrMsg em); 24 | LJ_FUNCA_NORET void LJ_FASTCALL lj_err_throw(lua_State *L, int errcode); 25 | LJ_FUNC_NORET void lj_err_mem(lua_State *L); 26 | LJ_FUNC_NORET void LJ_FASTCALL lj_err_run(lua_State *L); 27 | #if LJ_HASJIT 28 | LJ_FUNCA_NORET void LJ_FASTCALL lj_err_trace(lua_State *L, int errcode); 29 | #endif 30 | LJ_FUNC_NORET void lj_err_msg(lua_State *L, ErrMsg em); 31 | LJ_FUNC_NORET void lj_err_lex(lua_State *L, GCstr *src, const char *tok, 32 | BCLine line, ErrMsg em, va_list argp); 33 | LJ_FUNC_NORET void lj_err_optype(lua_State *L, cTValue *o, ErrMsg opm); 34 | LJ_FUNC_NORET void lj_err_comp(lua_State *L, cTValue *o1, cTValue *o2); 35 | LJ_FUNC_NORET void lj_err_optype_call(lua_State *L, TValue *o); 36 | LJ_FUNC_NORET void lj_err_callermsg(lua_State *L, const char *msg); 37 | LJ_FUNC_NORET void lj_err_callerv(lua_State *L, ErrMsg em, ...); 38 | LJ_FUNC_NORET void lj_err_caller(lua_State *L, ErrMsg em); 39 | LJ_FUNC_NORET void lj_err_arg(lua_State *L, int narg, ErrMsg em); 40 | LJ_FUNC_NORET void lj_err_argv(lua_State *L, int narg, ErrMsg em, ...); 41 | LJ_FUNC_NORET void lj_err_argtype(lua_State *L, int narg, const char *xname); 42 | LJ_FUNC_NORET void lj_err_argt(lua_State *L, int narg, int tt); 43 | 44 | #if LJ_UNWIND_JIT && !LJ_ABI_WIN 45 | LJ_FUNC uint8_t *lj_err_register_mcode(void *base, size_t sz, uint8_t *info); 46 | LJ_FUNC void lj_err_deregister_mcode(void *base, size_t sz, uint8_t *info); 47 | #else 48 | #define lj_err_register_mcode(base, sz, info) (info) 49 | #define lj_err_deregister_mcode(base, sz, info) UNUSED(base) 50 | #endif 51 | 52 | #if LJ_UNWIND_EXT && !LJ_ABI_WIN && defined(LUA_USE_ASSERT) 53 | LJ_FUNC void lj_err_verify(void); 54 | #else 55 | #define lj_err_verify() ((void)0) 56 | #endif 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_ff.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Fast function IDs. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_FF_H 7 | #define _LJ_FF_H 8 | 9 | /* Fast function ID. */ 10 | typedef enum { 11 | FF_LUA_ = FF_LUA, /* Lua function (must be 0). */ 12 | FF_C_ = FF_C, /* Regular C function (must be 1). */ 13 | #define FFDEF(name) FF_##name, 14 | #include "lj_ffdef.h" 15 | FF__MAX 16 | } FastFunc; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_ffrecord.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Fast function call recorder. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_FFRECORD_H 7 | #define _LJ_FFRECORD_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | 12 | #if LJ_HASJIT 13 | /* Data used by handlers to record a fast function. */ 14 | typedef struct RecordFFData { 15 | TValue *argv; /* Runtime argument values. */ 16 | ptrdiff_t nres; /* Number of returned results (defaults to 1). */ 17 | uint32_t data; /* Per-ffid auxiliary data (opcode, literal etc.). */ 18 | } RecordFFData; 19 | 20 | LJ_FUNC int32_t lj_ffrecord_select_mode(jit_State *J, TRef tr, TValue *tv); 21 | LJ_FUNC void lj_ffrecord_func(jit_State *J); 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_func.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Function handling (prototypes, functions and upvalues). 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_FUNC_H 7 | #define _LJ_FUNC_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Prototypes. */ 12 | LJ_FUNC void LJ_FASTCALL lj_func_freeproto(global_State *g, GCproto *pt); 13 | 14 | /* Upvalues. */ 15 | LJ_FUNCA void LJ_FASTCALL lj_func_closeuv(lua_State *L, TValue *level); 16 | LJ_FUNC void LJ_FASTCALL lj_func_freeuv(global_State *g, GCupval *uv); 17 | 18 | /* Functions (closures). */ 19 | LJ_FUNC GCfunc *lj_func_newC(lua_State *L, MSize nelems, GCtab *env); 20 | LJ_FUNC GCfunc *lj_func_newL_empty(lua_State *L, GCproto *pt, GCtab *env); 21 | LJ_FUNCA GCfunc *lj_func_newL_gc(lua_State *L, GCproto *pt, GCfuncL *parent); 22 | LJ_FUNC void LJ_FASTCALL lj_func_free(global_State *g, GCfunc *c); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_gdbjit.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Client for the GDB JIT API. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_GDBJIT_H 7 | #define _LJ_GDBJIT_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | 12 | #if LJ_HASJIT && defined(LUAJIT_USE_GDBJIT) 13 | 14 | LJ_FUNC void lj_gdbjit_addtrace(jit_State *J, GCtrace *T); 15 | LJ_FUNC void lj_gdbjit_deltrace(jit_State *J, GCtrace *T); 16 | 17 | #else 18 | #define lj_gdbjit_addtrace(J, T) UNUSED(T) 19 | #define lj_gdbjit_deltrace(J, T) UNUSED(T) 20 | #endif 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_mcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Machine code management. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_MCODE_H 7 | #define _LJ_MCODE_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASJIT || LJ_HASFFI 12 | LJ_FUNC void lj_mcode_sync(void *start, void *end); 13 | #endif 14 | 15 | #if LJ_HASJIT 16 | 17 | #include "lj_jit.h" 18 | 19 | LJ_FUNC void lj_mcode_free(jit_State *J); 20 | LJ_FUNC MCode *lj_mcode_reserve(jit_State *J, MCode **lim); 21 | LJ_FUNC void lj_mcode_commit(jit_State *J, MCode *m); 22 | LJ_FUNC void lj_mcode_abort(jit_State *J); 23 | LJ_FUNC MCode *lj_mcode_patch(jit_State *J, MCode *ptr, int finish); 24 | LJ_FUNC_NORET void lj_mcode_limiterr(jit_State *J, size_t need); 25 | 26 | #define lj_mcode_commitbot(J, m) (J->mcbot = (m)) 27 | 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_meta.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Metamethod handling. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_META_H 7 | #define _LJ_META_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Metamethod handling */ 12 | LJ_FUNC void lj_meta_init(lua_State *L); 13 | LJ_FUNC cTValue *lj_meta_cache(GCtab *mt, MMS mm, GCstr *name); 14 | LJ_FUNC cTValue *lj_meta_lookup(lua_State *L, cTValue *o, MMS mm); 15 | #if LJ_HASFFI 16 | LJ_FUNC int lj_meta_tailcall(lua_State *L, cTValue *tv); 17 | #endif 18 | 19 | #define lj_meta_fastg(g, mt, mm) \ 20 | ((mt) == NULL ? NULL : ((mt)->nomm & (1u<<(mm))) ? NULL : \ 21 | lj_meta_cache(mt, mm, mmname_str(g, mm))) 22 | #define lj_meta_fast(L, mt, mm) lj_meta_fastg(G(L), mt, mm) 23 | 24 | /* C helpers for some instructions, called from assembler VM. */ 25 | LJ_FUNCA cTValue *lj_meta_tget(lua_State *L, cTValue *o, cTValue *k); 26 | LJ_FUNCA TValue *lj_meta_tset(lua_State *L, cTValue *o, cTValue *k); 27 | LJ_FUNCA TValue *lj_meta_arith(lua_State *L, TValue *ra, cTValue *rb, 28 | cTValue *rc, BCReg op); 29 | LJ_FUNCA TValue *lj_meta_cat(lua_State *L, TValue *top, int left); 30 | LJ_FUNCA TValue * LJ_FASTCALL lj_meta_len(lua_State *L, cTValue *o); 31 | LJ_FUNCA TValue *lj_meta_equal(lua_State *L, GCobj *o1, GCobj *o2, int ne); 32 | LJ_FUNCA TValue * LJ_FASTCALL lj_meta_equal_cd(lua_State *L, BCIns ins); 33 | LJ_FUNCA TValue *lj_meta_comp(lua_State *L, cTValue *o1, cTValue *o2, int op); 34 | LJ_FUNCA void lj_meta_istype(lua_State *L, BCReg ra, BCReg tp); 35 | LJ_FUNCA void lj_meta_call(lua_State *L, TValue *func, TValue *top); 36 | LJ_FUNCA void LJ_FASTCALL lj_meta_for(lua_State *L, TValue *o); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_obj.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Miscellaneous object handling. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_obj_c 7 | #define LUA_CORE 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Object type names. */ 12 | LJ_DATADEF const char *const lj_obj_typename[] = { /* ORDER LUA_T */ 13 | "no value", "nil", "boolean", "userdata", "number", "string", 14 | "table", "function", "userdata", "thread", "proto", "cdata" 15 | }; 16 | 17 | LJ_DATADEF const char *const lj_obj_itypename[] = { /* ORDER LJ_T */ 18 | "nil", "boolean", "boolean", "userdata", "string", "upval", "thread", 19 | "proto", "function", "trace", "cdata", "table", "userdata", "number" 20 | }; 21 | 22 | /* Compare two objects without calling metamethods. */ 23 | int LJ_FASTCALL lj_obj_equal(cTValue *o1, cTValue *o2) 24 | { 25 | if (itype(o1) == itype(o2)) { 26 | if (tvispri(o1)) 27 | return 1; 28 | if (!tvisnum(o1)) 29 | return gcrefeq(o1->gcr, o2->gcr); 30 | } else if (!tvisnumber(o1) || !tvisnumber(o2)) { 31 | return 0; 32 | } 33 | return numberVnum(o1) == numberVnum(o2); 34 | } 35 | 36 | /* Return pointer to object or its object data. */ 37 | const void * LJ_FASTCALL lj_obj_ptr(global_State *g, cTValue *o) 38 | { 39 | UNUSED(g); 40 | if (tvisudata(o)) 41 | return uddata(udataV(o)); 42 | else if (tvislightud(o)) 43 | return lightudV(g, o); 44 | else if (LJ_HASFFI && tviscdata(o)) 45 | return cdataptr(cdataV(o)); 46 | else if (tvisgcv(o)) 47 | return gcV(o); 48 | else 49 | return NULL; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_opt_dce.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** DCE: Dead Code Elimination. Pre-LOOP only -- ASM already performs DCE. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_opt_dce_c 7 | #define LUA_CORE 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASJIT 12 | 13 | #include "lj_ir.h" 14 | #include "lj_jit.h" 15 | #include "lj_iropt.h" 16 | 17 | /* Some local macros to save typing. Undef'd at the end. */ 18 | #define IR(ref) (&J->cur.ir[(ref)]) 19 | 20 | /* Scan through all snapshots and mark all referenced instructions. */ 21 | static void dce_marksnap(jit_State *J) 22 | { 23 | SnapNo i, nsnap = J->cur.nsnap; 24 | for (i = 0; i < nsnap; i++) { 25 | SnapShot *snap = &J->cur.snap[i]; 26 | SnapEntry *map = &J->cur.snapmap[snap->mapofs]; 27 | MSize n, nent = snap->nent; 28 | for (n = 0; n < nent; n++) { 29 | IRRef ref = snap_ref(map[n]); 30 | if (ref >= REF_FIRST) 31 | irt_setmark(IR(ref)->t); 32 | } 33 | } 34 | } 35 | 36 | /* Backwards propagate marks. Replace unused instructions with NOPs. */ 37 | static void dce_propagate(jit_State *J) 38 | { 39 | IRRef1 *pchain[IR__MAX]; 40 | IRRef ins; 41 | uint32_t i; 42 | for (i = 0; i < IR__MAX; i++) pchain[i] = &J->chain[i]; 43 | for (ins = J->cur.nins-1; ins >= REF_FIRST; ins--) { 44 | IRIns *ir = IR(ins); 45 | if (irt_ismarked(ir->t)) { 46 | irt_clearmark(ir->t); 47 | pchain[ir->o] = &ir->prev; 48 | } else if (!ir_sideeff(ir)) { 49 | *pchain[ir->o] = ir->prev; /* Reroute original instruction chain. */ 50 | lj_ir_nop(ir); 51 | continue; 52 | } 53 | if (ir->op1 >= REF_FIRST) irt_setmark(IR(ir->op1)->t); 54 | if (ir->op2 >= REF_FIRST) irt_setmark(IR(ir->op2)->t); 55 | } 56 | } 57 | 58 | /* Dead Code Elimination. 59 | ** 60 | ** First backpropagate marks for all used instructions. Then replace 61 | ** the unused ones with a NOP. Note that compressing the IR to eliminate 62 | ** the NOPs does not pay off. 63 | */ 64 | void lj_opt_dce(jit_State *J) 65 | { 66 | if ((J->flags & JIT_F_OPT_DCE)) { 67 | dce_marksnap(J); 68 | dce_propagate(J); 69 | memset(J->bpropcache, 0, sizeof(J->bpropcache)); /* Invalidate cache. */ 70 | } 71 | } 72 | 73 | #undef IR 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_parse.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Lua parser (source code -> bytecode). 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_PARSE_H 7 | #define _LJ_PARSE_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_lex.h" 11 | 12 | LJ_FUNC GCproto *lj_parse(LexState *ls); 13 | LJ_FUNC GCstr *lj_parse_keepstr(LexState *ls, const char *str, size_t l); 14 | #if LJ_HASFFI 15 | LJ_FUNC void lj_parse_keepcdata(LexState *ls, TValue *tv, GCcdata *cd); 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_prng.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Pseudo-random number generation. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_PRNG_H 7 | #define _LJ_PRNG_H 8 | 9 | #include "lj_def.h" 10 | 11 | LJ_FUNC int LJ_FASTCALL lj_prng_seed_secure(PRNGState *rs); 12 | LJ_FUNC uint64_t LJ_FASTCALL lj_prng_u64(PRNGState *rs); 13 | LJ_FUNC uint64_t LJ_FASTCALL lj_prng_u64d(PRNGState *rs); 14 | 15 | /* This is just the precomputed result of lib_math.c:random_seed(rs, 0.0). */ 16 | static LJ_AINLINE void lj_prng_seed_fixed(PRNGState *rs) 17 | { 18 | rs->u[0] = U64x(a0d27757,0a345b8c); 19 | rs->u[1] = U64x(764a296c,5d4aa64f); 20 | rs->u[2] = U64x(51220704,070adeaa); 21 | rs->u[3] = U64x(2a2717b5,a7b7b927); 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_profile.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Low-overhead profiling. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_PROFILE_H 7 | #define _LJ_PROFILE_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASPROFILE 12 | 13 | LJ_FUNC void LJ_FASTCALL lj_profile_interpreter(lua_State *L); 14 | #if !LJ_PROFILE_SIGPROF 15 | LJ_FUNC void LJ_FASTCALL lj_profile_hook_enter(global_State *g); 16 | LJ_FUNC void LJ_FASTCALL lj_profile_hook_leave(global_State *g); 17 | #endif 18 | 19 | #endif 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_record.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Trace recorder (bytecode -> SSA IR). 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_RECORD_H 7 | #define _LJ_RECORD_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | 12 | #if LJ_HASJIT 13 | /* Context for recording an indexed load/store. */ 14 | typedef struct RecordIndex { 15 | TValue tabv; /* Runtime value of table (or indexed object). */ 16 | TValue keyv; /* Runtime value of key. */ 17 | TValue valv; /* Runtime value of stored value. */ 18 | TValue mobjv; /* Runtime value of metamethod object. */ 19 | GCtab *mtv; /* Runtime value of metatable object. */ 20 | cTValue *oldv; /* Runtime value of previously stored value. */ 21 | TRef tab; /* Table (or indexed object) reference. */ 22 | TRef key; /* Key reference. */ 23 | TRef val; /* Value reference for a store or 0 for a load. */ 24 | TRef mt; /* Metatable reference. */ 25 | TRef mobj; /* Metamethod object reference. */ 26 | int idxchain; /* Index indirections left or 0 for raw lookup. */ 27 | } RecordIndex; 28 | 29 | LJ_FUNC int lj_record_objcmp(jit_State *J, TRef a, TRef b, 30 | cTValue *av, cTValue *bv); 31 | LJ_FUNC void lj_record_stop(jit_State *J, TraceLink linktype, TraceNo lnk); 32 | LJ_FUNC TRef lj_record_constify(jit_State *J, cTValue *o); 33 | LJ_FUNC TRef lj_record_vload(jit_State *J, TRef ref, MSize idx, IRType t); 34 | 35 | LJ_FUNC void lj_record_call(jit_State *J, BCReg func, ptrdiff_t nargs); 36 | LJ_FUNC void lj_record_tailcall(jit_State *J, BCReg func, ptrdiff_t nargs); 37 | LJ_FUNC void lj_record_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults); 38 | 39 | LJ_FUNC int lj_record_mm_lookup(jit_State *J, RecordIndex *ix, MMS mm); 40 | LJ_FUNC TRef lj_record_idx(jit_State *J, RecordIndex *ix); 41 | LJ_FUNC int lj_record_next(jit_State *J, RecordIndex *ix); 42 | 43 | LJ_FUNC void lj_record_ins(jit_State *J); 44 | LJ_FUNC void lj_record_setup(jit_State *J); 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_serialize.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Object de/serialization. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_SERIALIZE_H 7 | #define _LJ_SERIALIZE_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_buf.h" 11 | 12 | #if LJ_HASBUFFER 13 | 14 | #define LJ_SERIALIZE_DEPTH 100 /* Default depth. */ 15 | 16 | LJ_FUNC void LJ_FASTCALL lj_serialize_dict_prep_str(lua_State *L, GCtab *dict); 17 | LJ_FUNC void LJ_FASTCALL lj_serialize_dict_prep_mt(lua_State *L, GCtab *dict); 18 | LJ_FUNC SBufExt * LJ_FASTCALL lj_serialize_put(SBufExt *sbx, cTValue *o); 19 | LJ_FUNC char * LJ_FASTCALL lj_serialize_get(SBufExt *sbx, TValue *o); 20 | LJ_FUNC GCstr * LJ_FASTCALL lj_serialize_encode(lua_State *L, cTValue *o); 21 | LJ_FUNC void lj_serialize_decode(lua_State *L, TValue *o, GCstr *str); 22 | #if LJ_HASJIT 23 | LJ_FUNC MSize LJ_FASTCALL lj_serialize_peektype(SBufExt *sbx); 24 | #endif 25 | 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_snap.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Snapshot handling. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_SNAP_H 7 | #define _LJ_SNAP_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | 12 | #if LJ_HASJIT 13 | LJ_FUNC void lj_snap_add(jit_State *J); 14 | LJ_FUNC void lj_snap_purge(jit_State *J); 15 | LJ_FUNC void lj_snap_shrink(jit_State *J); 16 | LJ_FUNC IRIns *lj_snap_regspmap(jit_State *J, GCtrace *T, SnapNo snapno, 17 | IRIns *ir); 18 | LJ_FUNC void lj_snap_replay(jit_State *J, GCtrace *T); 19 | LJ_FUNC const BCIns *lj_snap_restore(jit_State *J, void *exptr); 20 | LJ_FUNC void lj_snap_grow_buf_(jit_State *J, MSize need); 21 | LJ_FUNC void lj_snap_grow_map_(jit_State *J, MSize need); 22 | 23 | static LJ_AINLINE void lj_snap_grow_buf(jit_State *J, MSize need) 24 | { 25 | if (LJ_UNLIKELY(need > J->sizesnap)) lj_snap_grow_buf_(J, need); 26 | } 27 | 28 | static LJ_AINLINE void lj_snap_grow_map(jit_State *J, MSize need) 29 | { 30 | if (LJ_UNLIKELY(need > J->sizesnapmap)) lj_snap_grow_map_(J, need); 31 | } 32 | 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_state.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** State and stack handling. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_STATE_H 7 | #define _LJ_STATE_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #define incr_top(L) \ 12 | (++L->top >= tvref(L->maxstack) && (lj_state_growstack1(L), 0)) 13 | 14 | #define savestack(L, p) ((char *)(p) - mref(L->stack, char)) 15 | #define restorestack(L, n) ((TValue *)(mref(L->stack, char) + (n))) 16 | 17 | LJ_FUNC void lj_state_relimitstack(lua_State *L); 18 | LJ_FUNC void lj_state_shrinkstack(lua_State *L, MSize used); 19 | LJ_FUNCA void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need); 20 | LJ_FUNC void LJ_FASTCALL lj_state_growstack1(lua_State *L); 21 | 22 | static LJ_AINLINE void lj_state_checkstack(lua_State *L, MSize need) 23 | { 24 | if ((mref(L->maxstack, char) - (char *)L->top) <= 25 | (ptrdiff_t)need*(ptrdiff_t)sizeof(TValue)) 26 | lj_state_growstack(L, need); 27 | } 28 | 29 | LJ_FUNC lua_State *lj_state_new(lua_State *L); 30 | LJ_FUNC void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L); 31 | #if LJ_64 && !LJ_GC64 && !(defined(LUAJIT_USE_VALGRIND) && defined(LUAJIT_USE_SYSMALLOC)) 32 | LJ_FUNC lua_State *lj_state_newstate(lua_Alloc f, void *ud); 33 | #endif 34 | 35 | #define LJ_ALLOCF_INTERNAL ((lua_Alloc)(void *)(uintptr_t)(1237<<4)) 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_str.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** String handling. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_STR_H 7 | #define _LJ_STR_H 8 | 9 | #include 10 | 11 | #include "lj_obj.h" 12 | 13 | /* String helpers. */ 14 | LJ_FUNC int32_t LJ_FASTCALL lj_str_cmp(GCstr *a, GCstr *b); 15 | LJ_FUNC const char *lj_str_find(const char *s, const char *f, 16 | MSize slen, MSize flen); 17 | LJ_FUNC int lj_str_haspattern(GCstr *s); 18 | 19 | /* String interning. */ 20 | LJ_FUNC void lj_str_resize(lua_State *L, MSize newmask); 21 | LJ_FUNCA GCstr *lj_str_new(lua_State *L, const char *str, size_t len); 22 | LJ_FUNC void LJ_FASTCALL lj_str_free(global_State *g, GCstr *s); 23 | LJ_FUNC void LJ_FASTCALL lj_str_init(lua_State *L); 24 | #define lj_str_freetab(g) \ 25 | (lj_mem_freevec(g, g->str.tab, g->str.mask+1, GCRef)) 26 | 27 | #define lj_str_newz(L, s) (lj_str_new(L, s, strlen(s))) 28 | #define lj_str_newlit(L, s) (lj_str_new(L, "" s, sizeof(s)-1)) 29 | #define lj_str_size(len) (sizeof(GCstr) + (((len)+4) & ~(MSize)3)) 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_strscan.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** String scanning. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_STRSCAN_H 7 | #define _LJ_STRSCAN_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Options for accepted/returned formats. */ 12 | #define STRSCAN_OPT_TOINT 0x01 /* Convert to int32_t, if possible. */ 13 | #define STRSCAN_OPT_TONUM 0x02 /* Always convert to double. */ 14 | #define STRSCAN_OPT_IMAG 0x04 15 | #define STRSCAN_OPT_LL 0x08 16 | #define STRSCAN_OPT_C 0x10 17 | 18 | /* Returned format. */ 19 | typedef enum { 20 | STRSCAN_ERROR, 21 | STRSCAN_NUM, STRSCAN_IMAG, 22 | STRSCAN_INT, STRSCAN_U32, STRSCAN_I64, STRSCAN_U64, 23 | } StrScanFmt; 24 | 25 | LJ_FUNC StrScanFmt lj_strscan_scan(const uint8_t *p, MSize len, TValue *o, 26 | uint32_t opt); 27 | LJ_FUNC int LJ_FASTCALL lj_strscan_num(GCstr *str, TValue *o); 28 | #if LJ_DUALNUM 29 | LJ_FUNC int LJ_FASTCALL lj_strscan_number(GCstr *str, TValue *o); 30 | #else 31 | #define lj_strscan_number(s, o) lj_strscan_num((s), (o)) 32 | #endif 33 | 34 | /* Check for number or convert string to number/int in-place (!). */ 35 | static LJ_AINLINE int lj_strscan_numberobj(TValue *o) 36 | { 37 | return tvisnumber(o) || (tvisstr(o) && lj_strscan_number(strV(o), o)); 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_trace.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Trace management. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_TRACE_H 7 | #define _LJ_TRACE_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASJIT 12 | #include "lj_jit.h" 13 | #include "lj_dispatch.h" 14 | 15 | /* Trace errors. */ 16 | typedef enum { 17 | #define TREDEF(name, msg) LJ_TRERR_##name, 18 | #include "lj_traceerr.h" 19 | LJ_TRERR__MAX 20 | } TraceError; 21 | 22 | LJ_FUNC_NORET void lj_trace_err(jit_State *J, TraceError e); 23 | LJ_FUNC_NORET void lj_trace_err_info(jit_State *J, TraceError e); 24 | 25 | /* Trace management. */ 26 | LJ_FUNC GCtrace * LJ_FASTCALL lj_trace_alloc(lua_State *L, GCtrace *T); 27 | LJ_FUNC void LJ_FASTCALL lj_trace_free(global_State *g, GCtrace *T); 28 | LJ_FUNC void lj_trace_reenableproto(GCproto *pt); 29 | LJ_FUNC void lj_trace_flushproto(global_State *g, GCproto *pt); 30 | LJ_FUNC void lj_trace_flush(jit_State *J, TraceNo traceno); 31 | LJ_FUNC int lj_trace_flushall(lua_State *L); 32 | LJ_FUNC void lj_trace_initstate(global_State *g); 33 | LJ_FUNC void lj_trace_freestate(global_State *g); 34 | 35 | /* Event handling. */ 36 | LJ_FUNC void lj_trace_ins(jit_State *J, const BCIns *pc); 37 | LJ_FUNCA void LJ_FASTCALL lj_trace_hot(jit_State *J, const BCIns *pc); 38 | LJ_FUNCA void LJ_FASTCALL lj_trace_stitch(jit_State *J, const BCIns *pc); 39 | LJ_FUNCA int LJ_FASTCALL lj_trace_exit(jit_State *J, void *exptr); 40 | #if LJ_UNWIND_EXT 41 | LJ_FUNC uintptr_t LJ_FASTCALL lj_trace_unwind(jit_State *J, uintptr_t addr, ExitNo *ep); 42 | #endif 43 | 44 | /* Signal asynchronous abort of trace or end of trace. */ 45 | #define lj_trace_abort(g) (G2J(g)->state &= ~LJ_TRACE_ACTIVE) 46 | #define lj_trace_end(J) (J->state = LJ_TRACE_END) 47 | 48 | #else 49 | 50 | #define lj_trace_flushall(L) (UNUSED(L), 0) 51 | #define lj_trace_initstate(g) UNUSED(g) 52 | #define lj_trace_freestate(g) UNUSED(g) 53 | #define lj_trace_abort(g) UNUSED(g) 54 | #define lj_trace_end(J) UNUSED(J) 55 | 56 | #endif 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_traceerr.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Trace compiler error messages. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | /* This file may be included multiple times with different TREDEF macros. */ 7 | 8 | /* Recording. */ 9 | TREDEF(RECERR, "error thrown or hook called during recording") 10 | TREDEF(TRACEUV, "trace too short") 11 | TREDEF(TRACEOV, "trace too long") 12 | TREDEF(STACKOV, "trace too deep") 13 | TREDEF(SNAPOV, "too many snapshots") 14 | TREDEF(BLACKL, "blacklisted") 15 | TREDEF(RETRY, "retry recording") 16 | TREDEF(NYIBC, "NYI: bytecode %d") 17 | 18 | /* Recording loop ops. */ 19 | TREDEF(LLEAVE, "leaving loop in root trace") 20 | TREDEF(LINNER, "inner loop in root trace") 21 | TREDEF(LUNROLL, "loop unroll limit reached") 22 | 23 | /* Recording calls/returns. */ 24 | TREDEF(BADTYPE, "bad argument type") 25 | TREDEF(CJITOFF, "JIT compilation disabled for function") 26 | TREDEF(CUNROLL, "call unroll limit reached") 27 | TREDEF(DOWNREC, "down-recursion, restarting") 28 | TREDEF(NYIFFU, "NYI: unsupported variant of FastFunc %s") 29 | TREDEF(NYIRETL, "NYI: return to lower frame") 30 | 31 | /* Recording indexed load/store. */ 32 | TREDEF(STORENN, "store with nil or NaN key") 33 | TREDEF(NOMM, "missing metamethod") 34 | TREDEF(IDXLOOP, "looping index lookup") 35 | TREDEF(NYITMIX, "NYI: mixed sparse/dense table") 36 | 37 | /* Recording C data operations. */ 38 | TREDEF(NOCACHE, "symbol not in cache") 39 | TREDEF(NYICONV, "NYI: unsupported C type conversion") 40 | TREDEF(NYICALL, "NYI: unsupported C function type") 41 | 42 | /* Optimizations. */ 43 | TREDEF(GFAIL, "guard would always fail") 44 | TREDEF(PHIOV, "too many PHIs") 45 | TREDEF(TYPEINS, "persistent type instability") 46 | 47 | /* Assembler. */ 48 | TREDEF(MCODEAL, "failed to allocate mcode memory") 49 | TREDEF(MCODEOV, "machine code too long") 50 | TREDEF(MCODELM, "hit mcode limit (retrying)") 51 | TREDEF(SPILLOV, "too many spill slots") 52 | TREDEF(BADRA, "inconsistent register allocation") 53 | TREDEF(NYIIR, "NYI: cannot assemble IR instruction %d") 54 | TREDEF(NYIPHI, "NYI: PHI shuffling too complex") 55 | TREDEF(NYICOAL, "NYI: register coalescing too complex") 56 | 57 | #undef TREDEF 58 | 59 | /* Detecting unused error messages: 60 | awk -F, '/^TREDEF/ { gsub(/TREDEF./, ""); printf "grep -q LJ_TRERR_%s *.[ch] || echo %s\n", $1, $1}' lj_traceerr.h | sh 61 | */ 62 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_udata.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Userdata handling. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_udata_c 7 | #define LUA_CORE 8 | 9 | #include "lj_obj.h" 10 | #include "lj_gc.h" 11 | #include "lj_err.h" 12 | #include "lj_udata.h" 13 | 14 | GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env) 15 | { 16 | GCudata *ud = lj_mem_newt(L, sizeof(GCudata) + sz, GCudata); 17 | global_State *g = G(L); 18 | newwhite(g, ud); /* Not finalized. */ 19 | ud->gct = ~LJ_TUDATA; 20 | ud->udtype = UDTYPE_USERDATA; 21 | ud->len = sz; 22 | /* NOBARRIER: The GCudata is new (marked white). */ 23 | setgcrefnull(ud->metatable); 24 | setgcref(ud->env, obj2gco(env)); 25 | /* Chain to userdata list (after main thread). */ 26 | setgcrefr(ud->nextgc, mainthread(g)->nextgc); 27 | setgcref(mainthread(g)->nextgc, obj2gco(ud)); 28 | return ud; 29 | } 30 | 31 | void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud) 32 | { 33 | lj_mem_free(g, ud, sizeudata(ud)); 34 | } 35 | 36 | #if LJ_64 37 | void *lj_lightud_intern(lua_State *L, void *p) 38 | { 39 | global_State *g = G(L); 40 | uint64_t u = (uint64_t)p; 41 | uint32_t up = lightudup(u); 42 | uint32_t *segmap = mref(g->gc.lightudseg, uint32_t); 43 | MSize segnum = g->gc.lightudnum; 44 | if (segmap) { 45 | MSize seg; 46 | for (seg = 0; seg <= segnum; seg++) 47 | if (segmap[seg] == up) /* Fast path. */ 48 | return (void *)(((uint64_t)seg << LJ_LIGHTUD_BITS_LO) | lightudlo(u)); 49 | segnum++; 50 | /* Leave last segment unused to avoid clash with ITERN key. */ 51 | if (segnum >= (1 << LJ_LIGHTUD_BITS_SEG)-1) lj_err_msg(L, LJ_ERR_BADLU); 52 | } 53 | if (!((segnum-1) & segnum) && segnum != 1) { 54 | lj_mem_reallocvec(L, segmap, segnum, segnum ? 2*segnum : 2u, uint32_t); 55 | setmref(g->gc.lightudseg, segmap); 56 | } 57 | g->gc.lightudnum = segnum; 58 | segmap[segnum] = up; 59 | return (void *)(((uint64_t)segnum << LJ_LIGHTUD_BITS_LO) | lightudlo(u)); 60 | } 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_udata.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Userdata handling. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_UDATA_H 7 | #define _LJ_UDATA_H 8 | 9 | #include "lj_obj.h" 10 | 11 | LJ_FUNC GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env); 12 | LJ_FUNC void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud); 13 | #if LJ_64 14 | LJ_FUNC void * LJ_FASTCALL lj_lightud_intern(lua_State *L, void *p); 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_vmevent.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** VM event handling. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #include 7 | 8 | #define lj_vmevent_c 9 | #define LUA_CORE 10 | 11 | #include "lj_obj.h" 12 | #include "lj_str.h" 13 | #include "lj_tab.h" 14 | #include "lj_state.h" 15 | #include "lj_dispatch.h" 16 | #include "lj_vm.h" 17 | #include "lj_vmevent.h" 18 | 19 | ptrdiff_t lj_vmevent_prepare(lua_State *L, VMEvent ev) 20 | { 21 | global_State *g = G(L); 22 | GCstr *s = lj_str_newlit(L, LJ_VMEVENTS_REGKEY); 23 | cTValue *tv = lj_tab_getstr(tabV(registry(L)), s); 24 | if (tvistab(tv)) { 25 | int hash = VMEVENT_HASH(ev); 26 | tv = lj_tab_getint(tabV(tv), hash); 27 | if (tv && tvisfunc(tv)) { 28 | lj_state_checkstack(L, LUA_MINSTACK); 29 | setfuncV(L, L->top++, funcV(tv)); 30 | if (LJ_FR2) setnilV(L->top++); 31 | return savestack(L, L->top); 32 | } 33 | } 34 | g->vmevmask &= ~VMEVENT_MASK(ev); /* No handler: cache this fact. */ 35 | return 0; 36 | } 37 | 38 | void lj_vmevent_call(lua_State *L, ptrdiff_t argbase) 39 | { 40 | global_State *g = G(L); 41 | uint8_t oldmask = g->vmevmask; 42 | uint8_t oldh = hook_save(g); 43 | int status; 44 | g->vmevmask = 0; /* Disable all events. */ 45 | hook_vmevent(g); 46 | status = lj_vm_pcall(L, restorestack(L, argbase), 0+1, 0); 47 | if (LJ_UNLIKELY(status)) { 48 | /* Really shouldn't use stderr here, but where else to complain? */ 49 | L->top--; 50 | fputs("VM handler failed: ", stderr); 51 | fputs(tvisstr(L->top) ? strVdata(L->top) : "?", stderr); 52 | fputc('\n', stderr); 53 | } 54 | hook_restore(g, oldh); 55 | if (g->vmevmask != VMEVENT_NOCACHE) 56 | g->vmevmask = oldmask; /* Restore event mask, but not if not modified. */ 57 | } 58 | 59 | -------------------------------------------------------------------------------- /deps/luajit/src/lj_vmevent.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** VM event handling. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_VMEVENT_H 7 | #define _LJ_VMEVENT_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Registry key for VM event handler table. */ 12 | #define LJ_VMEVENTS_REGKEY "_VMEVENTS" 13 | #define LJ_VMEVENTS_HSIZE 4 14 | 15 | #define VMEVENT_MASK(ev) ((uint8_t)1 << ((int)(ev) & 7)) 16 | #define VMEVENT_HASH(ev) ((int)(ev) & ~7) 17 | #define VMEVENT_HASHIDX(h) ((int)(h) << 3) 18 | #define VMEVENT_NOCACHE 255 19 | 20 | #define VMEVENT_DEF(name, hash) \ 21 | LJ_VMEVENT_##name##_, \ 22 | LJ_VMEVENT_##name = ((LJ_VMEVENT_##name##_) & 7)|((hash) << 3) 23 | 24 | /* VM event IDs. */ 25 | typedef enum { 26 | VMEVENT_DEF(BC, 0x00003883), 27 | VMEVENT_DEF(TRACE, 0xb2d91467), 28 | VMEVENT_DEF(RECORD, 0x9284bf4f), 29 | VMEVENT_DEF(TEXIT, 0xb29df2b0), 30 | LJ_VMEVENT__MAX 31 | } VMEvent; 32 | 33 | #ifdef LUAJIT_DISABLE_VMEVENT 34 | #define lj_vmevent_send(L, ev, args) UNUSED(L) 35 | #define lj_vmevent_send_(L, ev, args, post) UNUSED(L) 36 | #else 37 | #define lj_vmevent_send(L, ev, args) \ 38 | if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \ 39 | ptrdiff_t argbase = lj_vmevent_prepare(L, LJ_VMEVENT_##ev); \ 40 | if (argbase) { \ 41 | args \ 42 | lj_vmevent_call(L, argbase); \ 43 | } \ 44 | } 45 | #define lj_vmevent_send_(L, ev, args, post) \ 46 | if (G(L)->vmevmask & VMEVENT_MASK(LJ_VMEVENT_##ev)) { \ 47 | ptrdiff_t argbase = lj_vmevent_prepare(L, LJ_VMEVENT_##ev); \ 48 | if (argbase) { \ 49 | args \ 50 | lj_vmevent_call(L, argbase); \ 51 | post \ 52 | } \ 53 | } 54 | 55 | LJ_FUNC ptrdiff_t lj_vmevent_prepare(lua_State *L, VMEvent ev); 56 | LJ_FUNC void lj_vmevent_call(lua_State *L, ptrdiff_t argbase); 57 | #endif 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /deps/luajit/src/ljamalg.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** LuaJIT core and libraries amalgamation. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define ljamalg_c 7 | #define LUA_CORE 8 | 9 | /* To get the mremap prototype. Must be defined before any system includes. */ 10 | #if defined(__linux__) && !defined(_GNU_SOURCE) 11 | #define _GNU_SOURCE 12 | #endif 13 | 14 | #ifndef WINVER 15 | #define WINVER 0x0501 16 | #endif 17 | 18 | #include "lua.h" 19 | #include "lauxlib.h" 20 | 21 | #include "lj_assert.c" 22 | #include "lj_gc.c" 23 | #include "lj_err.c" 24 | #include "lj_char.c" 25 | #include "lj_bc.c" 26 | #include "lj_obj.c" 27 | #include "lj_buf.c" 28 | #include "lj_str.c" 29 | #include "lj_tab.c" 30 | #include "lj_func.c" 31 | #include "lj_udata.c" 32 | #include "lj_meta.c" 33 | #include "lj_debug.c" 34 | #include "lj_prng.c" 35 | #include "lj_state.c" 36 | #include "lj_dispatch.c" 37 | #include "lj_vmevent.c" 38 | #include "lj_vmmath.c" 39 | #include "lj_strscan.c" 40 | #include "lj_strfmt.c" 41 | #include "lj_strfmt_num.c" 42 | #include "lj_serialize.c" 43 | #include "lj_api.c" 44 | #include "lj_profile.c" 45 | #include "lj_lex.c" 46 | #include "lj_parse.c" 47 | #include "lj_bcread.c" 48 | #include "lj_bcwrite.c" 49 | #include "lj_load.c" 50 | #include "lj_ctype.c" 51 | #include "lj_cdata.c" 52 | #include "lj_cconv.c" 53 | #include "lj_ccall.c" 54 | #include "lj_ccallback.c" 55 | #include "lj_carith.c" 56 | #include "lj_clib.c" 57 | #include "lj_cparse.c" 58 | #include "lj_lib.c" 59 | #include "lj_ir.c" 60 | #include "lj_opt_mem.c" 61 | #include "lj_opt_fold.c" 62 | #include "lj_opt_narrow.c" 63 | #include "lj_opt_dce.c" 64 | #include "lj_opt_loop.c" 65 | #include "lj_opt_split.c" 66 | #include "lj_opt_sink.c" 67 | #include "lj_mcode.c" 68 | #include "lj_snap.c" 69 | #include "lj_record.c" 70 | #include "lj_crecord.c" 71 | #include "lj_ffrecord.c" 72 | #include "lj_asm.c" 73 | #include "lj_trace.c" 74 | #include "lj_gdbjit.c" 75 | #include "lj_alloc.c" 76 | 77 | #include "lib_aux.c" 78 | #include "lib_base.c" 79 | #include "lib_math.c" 80 | #include "lib_string.c" 81 | #include "lib_table.c" 82 | #include "lib_io.c" 83 | #include "lib_os.c" 84 | #include "lib_package.c" 85 | #include "lib_debug.c" 86 | #include "lib_bit.c" 87 | #include "lib_jit.c" 88 | #include "lib_ffi.c" 89 | #include "lib_buffer.c" 90 | #include "lib_init.c" 91 | 92 | -------------------------------------------------------------------------------- /deps/luajit/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // C++ wrapper for LuaJIT header files. 2 | 3 | extern "C" { 4 | #include "lua.h" 5 | #include "lauxlib.h" 6 | #include "lualib.h" 7 | #include "luajit.h" 8 | } 9 | 10 | -------------------------------------------------------------------------------- /deps/luajit/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Standard library header. 3 | ** Copyright (C) 2005-2022 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LUALIB_H 7 | #define _LUALIB_H 8 | 9 | #include "lua.h" 10 | 11 | #define LUA_FILEHANDLE "FILE*" 12 | 13 | #define LUA_COLIBNAME "coroutine" 14 | #define LUA_MATHLIBNAME "math" 15 | #define LUA_STRLIBNAME "string" 16 | #define LUA_TABLIBNAME "table" 17 | #define LUA_IOLIBNAME "io" 18 | #define LUA_OSLIBNAME "os" 19 | #define LUA_LOADLIBNAME "package" 20 | #define LUA_DBLIBNAME "debug" 21 | #define LUA_BITLIBNAME "bit" 22 | #define LUA_JITLIBNAME "jit" 23 | #define LUA_FFILIBNAME "ffi" 24 | 25 | LUALIB_API int luaopen_base(lua_State *L); 26 | LUALIB_API int luaopen_math(lua_State *L); 27 | LUALIB_API int luaopen_string(lua_State *L); 28 | LUALIB_API int luaopen_table(lua_State *L); 29 | LUALIB_API int luaopen_io(lua_State *L); 30 | LUALIB_API int luaopen_os(lua_State *L); 31 | LUALIB_API int luaopen_package(lua_State *L); 32 | LUALIB_API int luaopen_debug(lua_State *L); 33 | LUALIB_API int luaopen_bit(lua_State *L); 34 | LUALIB_API int luaopen_jit(lua_State *L); 35 | LUALIB_API int luaopen_ffi(lua_State *L); 36 | LUALIB_API int luaopen_string_buffer(lua_State *L); 37 | 38 | LUALIB_API void luaL_openlibs(lua_State *L); 39 | 40 | #ifndef lua_assert 41 | #define lua_assert(x) ((void)0) 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /deps/luasocket/libluasocket/buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef BUF_H 2 | #define BUF_H 3 | /*=========================================================================*\ 4 | * Input/Output interface for Lua programs 5 | * LuaSocket toolkit 6 | * 7 | * Line patterns require buffering. Reading one character at a time involves 8 | * too many system calls and is very slow. This module implements the 9 | * LuaSocket interface for input/output on connected objects, as seen by 10 | * Lua programs. 11 | * 12 | * Input is buffered. Output is *not* buffered because there was no simple 13 | * way of making sure the buffered output data would ever be sent. 14 | * 15 | * The module is built on top of the I/O abstraction defined in io.h and the 16 | * timeout management is done with the timeout.h interface. 17 | * 18 | * RCS ID: $Id: buffer.h,v 1.12 2005/10/07 04:40:59 diego Exp $ 19 | \*=========================================================================*/ 20 | #include "lua.h" 21 | 22 | #include "io.h" 23 | #include "timeout.h" 24 | 25 | /* buffer size in bytes */ 26 | #define BUF_SIZE 8192 27 | 28 | /* buffer control structure */ 29 | typedef struct t_buffer_ { 30 | double birthday; /* throttle support info: creation time, */ 31 | size_t sent, received; /* bytes sent, and bytes received */ 32 | p_io io; /* IO driver used for this buffer */ 33 | p_timeout tm; /* timeout management for this buffer */ 34 | size_t first, last; /* index of first and last bytes of stored data */ 35 | char data[BUF_SIZE]; /* storage space for buffer data */ 36 | } t_buffer; 37 | typedef t_buffer *p_buffer; 38 | 39 | int buffer_open(lua_State *L); 40 | void buffer_init(p_buffer buf, p_io io, p_timeout tm); 41 | int buffer_meth_send(lua_State *L, p_buffer buf); 42 | int buffer_meth_receive(lua_State *L, p_buffer buf); 43 | int buffer_meth_getstats(lua_State *L, p_buffer buf); 44 | int buffer_meth_setstats(lua_State *L, p_buffer buf); 45 | int buffer_isempty(p_buffer buf); 46 | 47 | #endif /* BUF_H */ 48 | -------------------------------------------------------------------------------- /deps/luasocket/libluasocket/except.h: -------------------------------------------------------------------------------- 1 | #ifndef EXCEPT_H 2 | #define EXCEPT_H 3 | /*=========================================================================*\ 4 | * Exception control 5 | * LuaSocket toolkit (but completely independent from other modules) 6 | * 7 | * This provides support for simple exceptions in Lua. During the 8 | * development of the HTTP/FTP/SMTP support, it became aparent that 9 | * error checking was taking a substantial amount of the coding. These 10 | * function greatly simplify the task of checking errors. 11 | * 12 | * The main idea is that functions should return nil as its first return 13 | * value when it finds an error, and return an error message (or value) 14 | * following nil. In case of success, as long as the first value is not nil, 15 | * the other values don't matter. 16 | * 17 | * The idea is to nest function calls with the "try" function. This function 18 | * checks the first value, and calls "error" on the second if the first is 19 | * nil. Otherwise, it returns all values it received. 20 | * 21 | * The protect function returns a new function that behaves exactly like the 22 | * function it receives, but the new function doesn't throw exceptions: it 23 | * returns nil followed by the error message instead. 24 | * 25 | * With these two function, it's easy to write functions that throw 26 | * exceptions on error, but that don't interrupt the user script. 27 | * 28 | * RCS ID: $Id: except.h,v 1.2 2005/09/29 06:11:41 diego Exp $ 29 | \*=========================================================================*/ 30 | 31 | #include "lua.h" 32 | 33 | int except_open(lua_State *L); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /deps/luasocket/libluasocket/inet.h: -------------------------------------------------------------------------------- 1 | #ifndef INET_H 2 | #define INET_H 3 | /*=========================================================================*\ 4 | * Internet domain functions 5 | * LuaSocket toolkit 6 | * 7 | * This module implements the creation and connection of internet domain 8 | * sockets, on top of the socket.h interface, and the interface of with the 9 | * resolver. 10 | * 11 | * The function inet_aton is provided for the platforms where it is not 12 | * available. The module also implements the interface of the internet 13 | * getpeername and getsockname functions as seen by Lua programs. 14 | * 15 | * The Lua functions toip and tohostname are also implemented here. 16 | * 17 | * RCS ID: $Id: inet.h,v 1.16 2005/10/07 04:40:59 diego Exp $ 18 | \*=========================================================================*/ 19 | #include "lua.h" 20 | #include "socket.h" 21 | #include "timeout.h" 22 | 23 | #ifdef _WIN32 24 | #define INET_ATON 25 | #endif 26 | 27 | int inet_open(lua_State *L); 28 | 29 | const char *inet_trycreate(p_socket ps, int type); 30 | const char *inet_tryconnect(p_socket ps, const char *address, 31 | unsigned short port, p_timeout tm); 32 | const char *inet_trybind(p_socket ps, const char *address, 33 | unsigned short port); 34 | 35 | int inet_meth_getpeername(lua_State *L, p_socket ps); 36 | int inet_meth_getsockname(lua_State *L, p_socket ps); 37 | 38 | #ifdef INET_ATON 39 | int inet_aton(const char *cp, struct in_addr *inp); 40 | #endif 41 | 42 | #endif /* INET_H */ 43 | -------------------------------------------------------------------------------- /deps/luasocket/libluasocket/io.c: -------------------------------------------------------------------------------- 1 | /*=========================================================================*\ 2 | * Input/Output abstraction 3 | * LuaSocket toolkit 4 | * 5 | * RCS ID: $Id: io.c,v 1.6 2005/09/29 06:11:41 diego Exp $ 6 | \*=========================================================================*/ 7 | #include "io.h" 8 | 9 | /*=========================================================================*\ 10 | * Exported functions 11 | \*=========================================================================*/ 12 | /*-------------------------------------------------------------------------*\ 13 | * Initializes C structure 14 | \*-------------------------------------------------------------------------*/ 15 | void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx) { 16 | io->send = send; 17 | io->recv = recv; 18 | io->error = error; 19 | io->ctx = ctx; 20 | } 21 | 22 | /*-------------------------------------------------------------------------*\ 23 | * I/O error strings 24 | \*-------------------------------------------------------------------------*/ 25 | const char *io_strerror(int err) { 26 | switch (err) { 27 | case IO_DONE: return NULL; 28 | case IO_CLOSED: return "closed"; 29 | case IO_TIMEOUT: return "timeout"; 30 | default: return "unknown error"; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /deps/luasocket/libluasocket/lua.h: -------------------------------------------------------------------------------- 1 | #ifndef LUA_WRAP_H 2 | #define LUA_WRAP_H 3 | 4 | #define LUA_COMPAT_ALL 5 | #include 6 | #include 7 | #include 8 | 9 | #if LUA_VERSION_NUM > 501 10 | # define luaL_reg luaL_Reg 11 | # define luaL_putchar(B, c) luaL_addchar(B, c) 12 | # define luaL_typerror(L, n, t) luax_typerror(L, n, t) 13 | 14 | extern int luax_typerror(lua_State *L, int narg, const char *type); 15 | #endif 16 | 17 | #endif // LUA_WRAP_H 18 | -------------------------------------------------------------------------------- /deps/luasocket/libluasocket/luasocket.h: -------------------------------------------------------------------------------- 1 | #ifndef LUASOCKET_H 2 | #define LUASOCKET_H 3 | /*=========================================================================*\ 4 | * LuaSocket toolkit 5 | * Networking support for the Lua language 6 | * Diego Nehab 7 | * 9/11/1999 8 | * 9 | * RCS ID: $Id: luasocket.h,v 1.25 2007/06/11 23:44:54 diego Exp $ 10 | \*=========================================================================*/ 11 | #include "lua.h" 12 | 13 | /*-------------------------------------------------------------------------*\ 14 | * Current socket library version 15 | \*-------------------------------------------------------------------------*/ 16 | #define LUASOCKET_VERSION "LuaSocket 2.0.2" 17 | #define LUASOCKET_COPYRIGHT "Copyright (C) 2004-2007 Diego Nehab" 18 | #define LUASOCKET_AUTHORS "Diego Nehab" 19 | 20 | /*-------------------------------------------------------------------------*\ 21 | * This macro prefixes all exported API functions 22 | \*-------------------------------------------------------------------------*/ 23 | #ifndef LUASOCKET_API 24 | #define LUASOCKET_API extern 25 | #endif 26 | 27 | /*-------------------------------------------------------------------------*\ 28 | * Initializes the library. 29 | \*-------------------------------------------------------------------------*/ 30 | LUASOCKET_API int luaopen_socket_core(lua_State *L); 31 | 32 | #endif /* LUASOCKET_H */ 33 | -------------------------------------------------------------------------------- /deps/luasocket/libluasocket/mime.h: -------------------------------------------------------------------------------- 1 | #ifndef MIME_H 2 | #define MIME_H 3 | /*=========================================================================*\ 4 | * Core MIME support 5 | * LuaSocket toolkit 6 | * 7 | * This module provides functions to implement transfer content encodings 8 | * and formatting conforming to RFC 2045. It is used by mime.lua, which 9 | * provide a higher level interface to this functionality. 10 | * 11 | * RCS ID: $Id: mime.h,v 1.15 2007/06/11 23:44:54 diego Exp $ 12 | \*=========================================================================*/ 13 | #include "lua.h" 14 | 15 | /*-------------------------------------------------------------------------*\ 16 | * Current MIME library version 17 | \*-------------------------------------------------------------------------*/ 18 | #define MIME_VERSION "MIME 1.0.2" 19 | #define MIME_COPYRIGHT "Copyright (C) 2004-2007 Diego Nehab" 20 | #define MIME_AUTHORS "Diego Nehab" 21 | 22 | /*-------------------------------------------------------------------------*\ 23 | * This macro prefixes all exported API functions 24 | \*-------------------------------------------------------------------------*/ 25 | #ifndef MIME_API 26 | #define MIME_API extern 27 | #endif 28 | 29 | MIME_API int luaopen_mime_core(lua_State *L); 30 | 31 | #endif /* MIME_H */ 32 | -------------------------------------------------------------------------------- /deps/luasocket/libluasocket/options.h: -------------------------------------------------------------------------------- 1 | #ifndef OPTIONS_H 2 | #define OPTIONS_H 3 | /*=========================================================================*\ 4 | * Common option interface 5 | * LuaSocket toolkit 6 | * 7 | * This module provides a common interface to socket options, used mainly by 8 | * modules UDP and TCP. 9 | * 10 | * RCS ID: $Id: options.h,v 1.4 2005/10/07 04:40:59 diego Exp $ 11 | \*=========================================================================*/ 12 | 13 | #include "lua.h" 14 | #include "socket.h" 15 | 16 | /* option registry */ 17 | typedef struct t_opt { 18 | const char *name; 19 | int (*func)(lua_State *L, p_socket ps); 20 | } t_opt; 21 | typedef t_opt *p_opt; 22 | 23 | /* supported options */ 24 | int opt_dontroute(lua_State *L, p_socket ps); 25 | int opt_broadcast(lua_State *L, p_socket ps); 26 | int opt_reuseaddr(lua_State *L, p_socket ps); 27 | int opt_tcp_nodelay(lua_State *L, p_socket ps); 28 | int opt_keepalive(lua_State *L, p_socket ps); 29 | int opt_linger(lua_State *L, p_socket ps); 30 | int opt_reuseaddr(lua_State *L, p_socket ps); 31 | int opt_ip_multicast_ttl(lua_State *L, p_socket ps); 32 | int opt_ip_multicast_loop(lua_State *L, p_socket ps); 33 | int opt_ip_add_membership(lua_State *L, p_socket ps); 34 | int opt_ip_drop_membersip(lua_State *L, p_socket ps); 35 | 36 | /* invokes the appropriate option handler */ 37 | int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /deps/luasocket/libluasocket/pre.lua: -------------------------------------------------------------------------------- 1 | if not socket then error("No socket.") end 2 | -------------------------------------------------------------------------------- /deps/luasocket/libluasocket/select.h: -------------------------------------------------------------------------------- 1 | #ifndef SELECT_H 2 | #define SELECT_H 3 | /*=========================================================================*\ 4 | * Select implementation 5 | * LuaSocket toolkit 6 | * 7 | * Each object that can be passed to the select function has to export 8 | * method getfd() which returns the descriptor to be passed to the 9 | * underlying select function. Another method, dirty(), should return 10 | * true if there is data ready for reading (required for buffered input). 11 | * 12 | * RCS ID: $Id: select.h,v 1.7 2004/06/16 01:02:07 diego Exp $ 13 | \*=========================================================================*/ 14 | 15 | int select_open(lua_State *L); 16 | 17 | #endif /* SELECT_H */ 18 | -------------------------------------------------------------------------------- /deps/luasocket/libluasocket/tcp.h: -------------------------------------------------------------------------------- 1 | #ifndef TCP_H 2 | #define TCP_H 3 | /*=========================================================================*\ 4 | * TCP object 5 | * LuaSocket toolkit 6 | * 7 | * The tcp.h module is basicly a glue that puts together modules buffer.h, 8 | * timeout.h socket.h and inet.h to provide the LuaSocket TCP (AF_INET, 9 | * SOCK_STREAM) support. 10 | * 11 | * Three classes are defined: master, client and server. The master class is 12 | * a newly created tcp object, that has not been bound or connected. Server 13 | * objects are tcp objects bound to some local address. Client objects are 14 | * tcp objects either connected to some address or returned by the accept 15 | * method of a server object. 16 | * 17 | * RCS ID: $Id: tcp.h,v 1.7 2005/10/07 04:40:59 diego Exp $ 18 | \*=========================================================================*/ 19 | #include "lua.h" 20 | 21 | #include "buffer.h" 22 | #include "timeout.h" 23 | #include "socket.h" 24 | 25 | typedef struct t_tcp_ { 26 | t_socket sock; 27 | t_io io; 28 | t_buffer buf; 29 | t_timeout tm; 30 | } t_tcp; 31 | 32 | typedef t_tcp *p_tcp; 33 | 34 | int tcp_open(lua_State *L); 35 | 36 | #endif /* TCP_H */ 37 | -------------------------------------------------------------------------------- /deps/luasocket/libluasocket/timeout.h: -------------------------------------------------------------------------------- 1 | #ifndef TIMEOUT_H 2 | #define TIMEOUT_H 3 | /*=========================================================================*\ 4 | * Timeout management functions 5 | * LuaSocket toolkit 6 | * 7 | * RCS ID: $Id: timeout.h,v 1.14 2005/10/07 04:40:59 diego Exp $ 8 | \*=========================================================================*/ 9 | #include "lua.h" 10 | 11 | /* timeout control structure */ 12 | typedef struct t_timeout_ { 13 | double block; /* maximum time for blocking calls */ 14 | double total; /* total number of miliseconds for operation */ 15 | double start; /* time of start of operation */ 16 | } t_timeout; 17 | typedef t_timeout *p_timeout; 18 | 19 | int timeout_open(lua_State *L); 20 | void timeout_init(p_timeout tm, double block, double total); 21 | double timeout_get(p_timeout tm); 22 | double timeout_getretry(p_timeout tm); 23 | p_timeout timeout_markstart(p_timeout tm); 24 | double timeout_getstart(p_timeout tm); 25 | double timeout_gettime(void); 26 | int timeout_meth_settimeout(lua_State *L, p_timeout tm); 27 | 28 | #define timeout_iszero(tm) ((tm)->block == 0.0) 29 | 30 | #endif /* TIMEOUT_H */ 31 | -------------------------------------------------------------------------------- /deps/luasocket/libluasocket/udp.h: -------------------------------------------------------------------------------- 1 | #ifndef UDP_H 2 | #define UDP_H 3 | /*=========================================================================*\ 4 | * UDP object 5 | * LuaSocket toolkit 6 | * 7 | * The udp.h module provides LuaSocket with support for UDP protocol 8 | * (AF_INET, SOCK_DGRAM). 9 | * 10 | * Two classes are defined: connected and unconnected. UDP objects are 11 | * originally unconnected. They can be "connected" to a given address 12 | * with a call to the setpeername function. The same function can be used to 13 | * break the connection. 14 | * 15 | * RCS ID: $Id: udp.h,v 1.10 2005/10/07 04:40:59 diego Exp $ 16 | \*=========================================================================*/ 17 | #include "lua.h" 18 | 19 | #include "timeout.h" 20 | #include "socket.h" 21 | 22 | /* can't be larger than wsocket.c MAXCHUNK!!! */ 23 | #define UDP_DATAGRAMSIZE 8192 24 | 25 | typedef struct t_udp_ { 26 | t_socket sock; 27 | t_timeout tm; 28 | } t_udp; 29 | typedef t_udp *p_udp; 30 | 31 | int udp_open(lua_State *L); 32 | 33 | #endif /* UDP_H */ 34 | -------------------------------------------------------------------------------- /deps/luasocket/libluasocket/unix.h: -------------------------------------------------------------------------------- 1 | #ifndef UNIX_H 2 | #define UNIX_H 3 | /*=========================================================================*\ 4 | * Unix domain object 5 | * LuaSocket toolkit 6 | * 7 | * This module is just an example of how to extend LuaSocket with a new 8 | * domain. 9 | * 10 | * RCS ID: $Id: unix.h,v 1.9 2006/03/13 07:16:39 diego Exp $ 11 | \*=========================================================================*/ 12 | #include "lua.h" 13 | 14 | #include "buffer.h" 15 | #include "timeout.h" 16 | #include "socket.h" 17 | 18 | typedef struct t_unix_ { 19 | t_socket sock; 20 | t_io io; 21 | t_buffer buf; 22 | t_timeout tm; 23 | } t_unix; 24 | typedef t_unix *p_unix; 25 | 26 | int luaopen_socket_unix(lua_State *L); 27 | 28 | #endif /* UNIX_H */ 29 | -------------------------------------------------------------------------------- /deps/luasocket/libluasocket/usocket.h: -------------------------------------------------------------------------------- 1 | #ifndef USOCKET_H 2 | #define USOCKET_H 3 | /*=========================================================================*\ 4 | * Socket compatibilization module for Unix 5 | * LuaSocket toolkit 6 | * 7 | * RCS ID: $Id: usocket.h,v 1.7 2005/10/07 04:40:59 diego Exp $ 8 | \*=========================================================================*/ 9 | 10 | /*=========================================================================*\ 11 | * BSD include files 12 | \*=========================================================================*/ 13 | /* error codes */ 14 | #include 15 | /* close function */ 16 | #include 17 | /* fnctnl function and associated constants */ 18 | #include 19 | /* struct sockaddr */ 20 | #include 21 | /* socket function */ 22 | #include 23 | /* struct timeval */ 24 | #include 25 | /* gethostbyname and gethostbyaddr functions */ 26 | #include 27 | /* sigpipe handling */ 28 | #include 29 | /* IP stuff*/ 30 | #include 31 | #include 32 | /* TCP options (nagle algorithm disable) */ 33 | #include 34 | 35 | typedef int t_socket; 36 | typedef t_socket *p_socket; 37 | 38 | #define SOCKET_INVALID (-1) 39 | 40 | #endif /* USOCKET_H */ 41 | -------------------------------------------------------------------------------- /deps/luasocket/libluasocket/wsocket.h: -------------------------------------------------------------------------------- 1 | #ifndef WSOCKET_H 2 | #define WSOCKET_H 3 | /*=========================================================================*\ 4 | * Socket compatibilization module for Win32 5 | * LuaSocket toolkit 6 | * 7 | * RCS ID: $Id: wsocket.h,v 1.4 2005/10/07 04:40:59 diego Exp $ 8 | \*=========================================================================*/ 9 | 10 | /*=========================================================================*\ 11 | * WinSock include files 12 | \*=========================================================================*/ 13 | #include 14 | 15 | typedef int socklen_t; 16 | typedef SOCKET t_socket; 17 | typedef t_socket *p_socket; 18 | 19 | #define SOCKET_INVALID (INVALID_SOCKET) 20 | 21 | #endif /* WSOCKET_H */ 22 | -------------------------------------------------------------------------------- /deps/luasocket/luasocket.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2006-2016 LOVE Development Team 3 | * 4 | * This software is provided 'as-is', without any express or implied 5 | * warranty. In no event will the authors be held liable for any damages 6 | * arising from the use of this software. 7 | * 8 | * Permission is granted to anyone to use this software for any purpose, 9 | * including commercial applications, and to alter it and redistribute it 10 | * freely, subject to the following restrictions: 11 | * 12 | * 1. The origin of this software must not be misrepresented; you must not 13 | * claim that you wrote the original software. If you use this software 14 | * in a product, an acknowledgment in the product documentation would be 15 | * appreciated but is not required. 16 | * 2. Altered source versions must be plainly marked as such, and must not be 17 | * misrepresented as being the original software. 18 | * 3. This notice may not be removed or altered from any source distribution. 19 | **/ 20 | 21 | #ifndef LOVE_LUASOCKET_LUASOCKET_H 22 | #define LOVE_LUASOCKET_LUASOCKET_H 23 | 24 | // LOVE 25 | #include "runtime.h" 26 | 27 | //namespace love 28 | //{ 29 | //namespace luasocket 30 | //{ 31 | 32 | int _o_open(lua_State * L); 33 | 34 | // Loaders for all lua files. We want to be able 35 | // to load these dynamically. (Identical in the LuaSocket 36 | // documentation. These functions wrap the parsing of code, etc). 37 | int __open_luasocket_socket(lua_State * L); 38 | int __open_luasocket_ftp(lua_State * L); 39 | int __open_luasocket_http(lua_State * L); 40 | int __open_luasocket_ltn12(lua_State * L); 41 | int __open_luasocket_mime(lua_State * L); 42 | int __open_luasocket_smtp(lua_State * L); 43 | int __open_luasocket_tp(lua_State * L); 44 | int __open_luasocket_url(lua_State * L); 45 | 46 | //} // luasocket 47 | //} // love 48 | 49 | #endif // LOVE_LUASOCKET_LUASOCKET_H 50 | -------------------------------------------------------------------------------- /deps/luautf8/lprefix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lprefix.h,v 1.2 2014/12/29 16:54:13 roberto Exp $ 3 | ** Definitions for Lua code that must come before any other header file 4 | ** See Copyright Notice in lutf8lib.c 5 | */ 6 | 7 | #ifndef lprefix_h 8 | #define lprefix_h 9 | 10 | 11 | /* 12 | ** Allows POSIX/XSI stuff 13 | */ 14 | #if !defined(LUA_USE_C89) /* { */ 15 | 16 | #if !defined(_XOPEN_SOURCE) 17 | #define _XOPEN_SOURCE 600 18 | #elif _XOPEN_SOURCE == 0 19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ 20 | #endif 21 | 22 | /* 23 | ** Allows manipulation of large files in gcc and some other compilers 24 | */ 25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) 26 | #define _LARGEFILE_SOURCE 1 27 | #define _FILE_OFFSET_BITS 64 28 | #endif 29 | 30 | #endif /* } */ 31 | 32 | 33 | /* 34 | ** Windows stuff 35 | */ 36 | #if defined(_WIN32) /* { */ 37 | 38 | #if !defined(_CRT_SECURE_NO_WARNINGS) 39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ 40 | #endif 41 | 42 | #endif /* } */ 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /deps/luautf8/lutf8lib.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef LUAUTF8_LUTF8LIB_H 3 | #define LUAUTF8_LUTF8LIB_H 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | #include "lua.h" 10 | 11 | LUALIB_API int luaopen_luautf8(lua_State *L); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif /* LOVE_LUAUTF8_LUTF8LIB_H */ 18 | -------------------------------------------------------------------------------- /deps/ogg/config_types.h: -------------------------------------------------------------------------------- 1 | #ifndef __CONFIG_TYPES_H__ 2 | #define __CONFIG_TYPES_H__ 3 | 4 | /* these are filled in by configure */ 5 | #define INCLUDE_INTTYPES_H 1 6 | #define INCLUDE_STDINT_H 1 7 | #define INCLUDE_SYS_TYPES_H 1 8 | 9 | #if INCLUDE_INTTYPES_H 10 | # include 11 | #endif 12 | #if INCLUDE_STDINT_H 13 | # include 14 | #endif 15 | #if INCLUDE_SYS_TYPES_H 16 | # include 17 | #endif 18 | 19 | typedef int16_t ogg_int16_t; 20 | typedef uint16_t ogg_uint16_t; 21 | typedef int32_t ogg_int32_t; 22 | typedef uint32_t ogg_uint32_t; 23 | typedef int64_t ogg_int64_t; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /deps/physfs/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2001-2017 Ryan C. Gordon and others. 3 | 4 | This software is provided 'as-is', without any express or implied warranty. 5 | In no event will the authors be held liable for any damages arising from 6 | the use of this software. 7 | 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software in a 14 | product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 20 | 3. This notice may not be removed or altered from any source distribution. 21 | 22 | Ryan C. Gordon 23 | 24 | -------------------------------------------------------------------------------- /deps/physfs/README.txt: -------------------------------------------------------------------------------- 1 | 2 | PhysicsFS; a portable, flexible file i/o abstraction. 3 | 4 | https://icculus.org/physfs/ 5 | 6 | Please see the docs directory for documentation. 7 | 8 | Please see LICENSE.txt for licensing information. 9 | 10 | -------------------------------------------------------------------------------- /deps/physfs/physfs_platform_winrt.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Windows Runtime (WinRT) support routines for PhysicsFS. 3 | * 4 | * Please see the file LICENSE.txt in the source's root directory. 5 | * 6 | * This file originally written by Martin "T-Bone" Ahrnbom, but was mostly 7 | * merged into physfs_platform_windows.c by Ryan C. Gordon (so please harass 8 | * Ryan about bugs and not Martin). 9 | */ 10 | 11 | /* (There used to be instructions on how to make a WinRT project, but at 12 | this point, either CMake will do it for you or you should just drop 13 | PhysicsFS's sources into your existing project. --ryan.) */ 14 | 15 | #define __PHYSICSFS_INTERNAL__ 16 | #include "physfs_platforms.h" 17 | 18 | #ifdef PHYSFS_PLATFORM_WINRT 19 | 20 | #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) 21 | #define _CRT_SECURE_NO_WARNINGS 1 22 | #endif 23 | #include 24 | 25 | #include "physfs_internal.h" 26 | 27 | const void *__PHYSFS_winrtCalcBaseDir(void) 28 | { 29 | return Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data(); 30 | } /* __PHYSFS_winrtCalcBaseDir */ 31 | 32 | const void *__PHYSFS_winrtCalcPrefDir(void) 33 | { 34 | return Windows::Storage::ApplicationData::Current->LocalFolder->Path->Data(); 35 | } /* __PHYSFS_winrtCalcBaseDir */ 36 | 37 | 38 | #endif /* PHYSFS_PLATFORM_WINRT */ 39 | 40 | /* end of physfs_platform_winrt.cpp ... */ 41 | 42 | -------------------------------------------------------------------------------- /deps/utf8/utf8.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Nemanja Trifunovic 2 | 3 | /* 4 | Permission is hereby granted, free of charge, to any person or organization 5 | obtaining a copy of the software and accompanying documentation covered by 6 | this license (the "Software") to use, reproduce, display, distribute, 7 | execute, and transmit the Software, and to prepare derivative works of the 8 | Software, and to permit third-parties to whom the Software is furnished to 9 | do so, all subject to the following: 10 | 11 | The copyright notices in the Software and this entire statement, including 12 | the above license grant, this restriction and the following disclaimer, 13 | must be included in all copies of the Software, in whole or in part, and 14 | all derivative works of the Software, unless such copies or derivative 15 | works are solely in the form of machine-executable object code generated by 16 | a source language processor. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 21 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 22 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 23 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | 28 | #ifndef UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731 29 | #define UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731 30 | 31 | #include "utf8/checked.h" 32 | #include "utf8/unchecked.h" 33 | 34 | #endif // header guard 35 | -------------------------------------------------------------------------------- /deps/vorbis/bitrate.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: bitrate tracking and management 14 | last mod: $Id: bitrate.h 13293 2007-07-24 00:09:47Z xiphmont $ 15 | 16 | ********************************************************************/ 17 | 18 | #ifndef _V_BITRATE_H_ 19 | #define _V_BITRATE_H_ 20 | 21 | #include "vorbis/codec.h" 22 | #include "codec_internal.h" 23 | #include "os.h" 24 | 25 | /* encode side bitrate tracking */ 26 | typedef struct bitrate_manager_state { 27 | int managed; 28 | 29 | long avg_reservoir; 30 | long minmax_reservoir; 31 | long avg_bitsper; 32 | long min_bitsper; 33 | long max_bitsper; 34 | 35 | long short_per_long; 36 | double avgfloat; 37 | 38 | vorbis_block *vb; 39 | int choice; 40 | } bitrate_manager_state; 41 | 42 | typedef struct bitrate_manager_info{ 43 | long avg_rate; 44 | long min_rate; 45 | long max_rate; 46 | long reservoir_bits; 47 | double reservoir_bias; 48 | 49 | double slew_damp; 50 | 51 | } bitrate_manager_info; 52 | 53 | extern void vorbis_bitrate_init(vorbis_info *vi,bitrate_manager_state *bs); 54 | extern void vorbis_bitrate_clear(bitrate_manager_state *bs); 55 | extern int vorbis_bitrate_managed(vorbis_block *vb); 56 | extern int vorbis_bitrate_addblock(vorbis_block *vb); 57 | extern int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd, ogg_packet *op); 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /deps/vorbis/highlevel.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: highlevel encoder setup struct separated out for vorbisenc clarity 14 | last mod: $Id: highlevel.h 17195 2010-05-05 21:49:51Z giles $ 15 | 16 | ********************************************************************/ 17 | 18 | typedef struct highlevel_byblocktype { 19 | double tone_mask_setting; 20 | double tone_peaklimit_setting; 21 | double noise_bias_setting; 22 | double noise_compand_setting; 23 | } highlevel_byblocktype; 24 | 25 | typedef struct highlevel_encode_setup { 26 | int set_in_stone; 27 | const void *setup; 28 | double base_setting; 29 | 30 | double impulse_noisetune; 31 | 32 | /* bitrate management below all settable */ 33 | float req; 34 | int managed; 35 | long bitrate_min; 36 | long bitrate_av; 37 | double bitrate_av_damp; 38 | long bitrate_max; 39 | long bitrate_reservoir; 40 | double bitrate_reservoir_bias; 41 | 42 | int impulse_block_p; 43 | int noise_normalize_p; 44 | int coupling_p; 45 | 46 | double stereo_point_setting; 47 | double lowpass_kHz; 48 | int lowpass_altered; 49 | 50 | double ath_floating_dB; 51 | double ath_absolute_dB; 52 | 53 | double amplitude_track_dBpersec; 54 | double trigger_setting; 55 | 56 | highlevel_byblocktype block[4]; /* padding, impulse, transition, long */ 57 | 58 | } highlevel_encode_setup; 59 | -------------------------------------------------------------------------------- /deps/vorbis/lookup.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: lookup based functions 14 | last mod: $Id: lookup.h 16227 2009-07-08 06:58:46Z xiphmont $ 15 | 16 | ********************************************************************/ 17 | 18 | #ifndef _V_LOOKUP_H_ 19 | 20 | #ifdef FLOAT_LOOKUP 21 | extern float vorbis_coslook(float a); 22 | extern float vorbis_invsqlook(float a); 23 | extern float vorbis_invsq2explook(int a); 24 | extern float vorbis_fromdBlook(float a); 25 | #endif 26 | #ifdef INT_LOOKUP 27 | extern long vorbis_invsqlook_i(long a,long e); 28 | extern long vorbis_coslook_i(long a); 29 | extern float vorbis_fromdBlook_i(long a); 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /deps/vorbis/lpc.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: LPC low level routines 14 | last mod: $Id: lpc.h 16037 2009-05-26 21:10:58Z xiphmont $ 15 | 16 | ********************************************************************/ 17 | 18 | #ifndef _V_LPC_H_ 19 | #define _V_LPC_H_ 20 | 21 | #include "vorbis/codec.h" 22 | 23 | /* simple linear scale LPC code */ 24 | extern float vorbis_lpc_from_data(float *data,float *lpc,int n,int m); 25 | 26 | extern void vorbis_lpc_predict(float *coeff,float *prime,int m, 27 | float *data,long n); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /deps/vorbis/lsp.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: LSP (also called LSF) conversion routines 14 | last mod: $Id: lsp.h 16227 2009-07-08 06:58:46Z xiphmont $ 15 | 16 | ********************************************************************/ 17 | 18 | 19 | #ifndef _V_LSP_H_ 20 | #define _V_LSP_H_ 21 | 22 | extern int vorbis_lpc_to_lsp(float *lpc,float *lsp,int m); 23 | 24 | extern void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln, 25 | float *lsp,int m, 26 | float amp,float ampoffset); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /deps/vorbis/mdct.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: modified discrete cosine transform prototypes 14 | last mod: $Id: mdct.h 16227 2009-07-08 06:58:46Z xiphmont $ 15 | 16 | ********************************************************************/ 17 | 18 | #ifndef _OGG_mdct_H_ 19 | #define _OGG_mdct_H_ 20 | 21 | #include "vorbis/codec.h" 22 | 23 | 24 | 25 | 26 | 27 | /*#define MDCT_INTEGERIZED <- be warned there could be some hurt left here*/ 28 | #ifdef MDCT_INTEGERIZED 29 | 30 | #define DATA_TYPE int 31 | #define REG_TYPE register int 32 | #define TRIGBITS 14 33 | #define cPI3_8 6270 34 | #define cPI2_8 11585 35 | #define cPI1_8 15137 36 | 37 | #define FLOAT_CONV(x) ((int)((x)*(1<>TRIGBITS) 39 | #define HALVE(x) ((x)>>1) 40 | 41 | #else 42 | 43 | #define DATA_TYPE float 44 | #define REG_TYPE float 45 | #define cPI3_8 .38268343236508977175F 46 | #define cPI2_8 .70710678118654752441F 47 | #define cPI1_8 .92387953251128675613F 48 | 49 | #define FLOAT_CONV(x) (x) 50 | #define MULT_NORM(x) (x) 51 | #define HALVE(x) ((x)*.5f) 52 | 53 | #endif 54 | 55 | 56 | typedef struct { 57 | int n; 58 | int log2n; 59 | 60 | DATA_TYPE *trig; 61 | int *bitrev; 62 | 63 | DATA_TYPE scale; 64 | } mdct_lookup; 65 | 66 | extern void mdct_init(mdct_lookup *lookup,int n); 67 | extern void mdct_clear(mdct_lookup *l); 68 | extern void mdct_forward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out); 69 | extern void mdct_backward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out); 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /deps/vorbis/misc.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: miscellaneous prototypes 14 | last mod: $Id: misc.h 16227 2009-07-08 06:58:46Z xiphmont $ 15 | 16 | ********************************************************************/ 17 | 18 | #ifndef _V_RANDOM_H_ 19 | #define _V_RANDOM_H_ 20 | #include "vorbis/codec.h" 21 | 22 | extern void *_vorbis_block_alloc(vorbis_block *vb,long bytes); 23 | extern void _vorbis_block_ripcord(vorbis_block *vb); 24 | 25 | #ifdef ANALYSIS 26 | extern int analysis_noisy; 27 | extern void _analysis_output(char *base,int i,float *v,int n,int bark,int dB, 28 | ogg_int64_t off); 29 | extern void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB, 30 | ogg_int64_t off); 31 | #endif 32 | 33 | #ifdef DEBUG_MALLOC 34 | 35 | #define _VDBG_GRAPHFILE "malloc.m" 36 | #undef _VDBG_GRAPHFILE 37 | extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line); 38 | extern void _VDBG_free(void *ptr,char *file,long line); 39 | 40 | #ifndef MISC_C 41 | #undef _ogg_malloc 42 | #undef _ogg_calloc 43 | #undef _ogg_realloc 44 | #undef _ogg_free 45 | 46 | #define _ogg_malloc(x) _VDBG_malloc(NULL,(x),__FILE__,__LINE__) 47 | #define _ogg_calloc(x,y) _VDBG_malloc(NULL,(x)*(y),__FILE__,__LINE__) 48 | #define _ogg_realloc(x,y) _VDBG_malloc((x),(y),__FILE__,__LINE__) 49 | #define _ogg_free(x) _VDBG_free((x),__FILE__,__LINE__) 50 | #endif 51 | #endif 52 | 53 | #endif 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /deps/vorbis/modes/setup_44p51.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: toplevel settings for 44.1/48kHz 5.1 surround modes 14 | last mod: $Id$ 15 | 16 | ********************************************************************/ 17 | 18 | #include "modes/residue_44p51.h" 19 | 20 | static const double rate_mapping_44p51[12]={ 21 | 14000.,20000.,28000.,38000.,46000.,54000., 22 | 75000.,96000.,120000.,140000.,180000.,240001. 23 | }; 24 | 25 | static const ve_setup_data_template ve_setup_44_51={ 26 | 11, 27 | rate_mapping_44p51, 28 | quality_mapping_44, 29 | 6, 30 | 40000, 31 | 70000, 32 | 33 | blocksize_short_44, 34 | blocksize_long_44, 35 | 36 | _psy_tone_masteratt_44, 37 | _psy_tone_0dB, 38 | _psy_tone_suppress, 39 | 40 | _vp_tonemask_adj_otherblock, 41 | _vp_tonemask_adj_longblock, 42 | _vp_tonemask_adj_otherblock, 43 | 44 | _psy_noiseguards_44, 45 | _psy_noisebias_impulse, 46 | _psy_noisebias_padding, 47 | _psy_noisebias_trans, 48 | _psy_noisebias_long, 49 | _psy_noise_suppress, 50 | 51 | _psy_compand_44, 52 | _psy_compand_short_mapping, 53 | _psy_compand_long_mapping, 54 | 55 | {_noise_start_short_44,_noise_start_long_44}, 56 | {_noise_part_short_44,_noise_part_long_44}, 57 | _noise_thresh_44, 58 | 59 | _psy_ath_floater, 60 | _psy_ath_abs, 61 | 62 | _psy_lowpass_44, 63 | 64 | _psy_global_44, 65 | _global_mapping_44, 66 | _psy_stereo_modes_44, 67 | 68 | _floor_books, 69 | _floor, 70 | 3, 71 | _floor_mapping_44, 72 | 73 | _mapres_template_44_51 74 | }; 75 | -------------------------------------------------------------------------------- /deps/vorbis/modes/setup_44u.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: toplevel settings for 44.1/48kHz uncoupled modes 14 | last mod: $Id: setup_44u.h 16962 2010-03-11 07:30:34Z xiphmont $ 15 | 16 | ********************************************************************/ 17 | 18 | #include "modes/residue_44u.h" 19 | 20 | static const double rate_mapping_44_un[12]={ 21 | 32000.,48000.,60000.,70000.,80000.,86000., 22 | 96000.,110000.,120000.,140000.,160000.,240001. 23 | }; 24 | 25 | static const ve_setup_data_template ve_setup_44_uncoupled={ 26 | 11, 27 | rate_mapping_44_un, 28 | quality_mapping_44, 29 | -1, 30 | 40000, 31 | 50000, 32 | 33 | blocksize_short_44, 34 | blocksize_long_44, 35 | 36 | _psy_tone_masteratt_44, 37 | _psy_tone_0dB, 38 | _psy_tone_suppress, 39 | 40 | _vp_tonemask_adj_otherblock, 41 | _vp_tonemask_adj_longblock, 42 | _vp_tonemask_adj_otherblock, 43 | 44 | _psy_noiseguards_44, 45 | _psy_noisebias_impulse, 46 | _psy_noisebias_padding, 47 | _psy_noisebias_trans, 48 | _psy_noisebias_long, 49 | _psy_noise_suppress, 50 | 51 | _psy_compand_44, 52 | _psy_compand_short_mapping, 53 | _psy_compand_long_mapping, 54 | 55 | {_noise_start_short_44,_noise_start_long_44}, 56 | {_noise_part_short_44,_noise_part_long_44}, 57 | _noise_thresh_44, 58 | 59 | _psy_ath_floater, 60 | _psy_ath_abs, 61 | 62 | _psy_lowpass_44, 63 | 64 | _psy_global_44, 65 | _global_mapping_44, 66 | _psy_stereo_modes_44, 67 | 68 | _floor_books, 69 | _floor, 70 | 2, 71 | _floor_mapping_44, 72 | 73 | _mapres_template_44_uncoupled 74 | }; 75 | -------------------------------------------------------------------------------- /deps/vorbis/registry.c: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: registry for time, floor, res backends and channel mappings 14 | last mod: $Id: registry.c 16227 2009-07-08 06:58:46Z xiphmont $ 15 | 16 | ********************************************************************/ 17 | 18 | #include "vorbis/codec.h" 19 | #include "codec_internal.h" 20 | #include "registry.h" 21 | #include "misc.h" 22 | /* seems like major overkill now; the backend numbers will grow into 23 | the infrastructure soon enough */ 24 | 25 | extern const vorbis_func_floor floor0_exportbundle; 26 | extern const vorbis_func_floor floor1_exportbundle; 27 | extern const vorbis_func_residue residue0_exportbundle; 28 | extern const vorbis_func_residue residue1_exportbundle; 29 | extern const vorbis_func_residue residue2_exportbundle; 30 | extern const vorbis_func_mapping mapping0_exportbundle; 31 | 32 | const vorbis_func_floor *const _floor_P[]={ 33 | &floor0_exportbundle, 34 | &floor1_exportbundle, 35 | }; 36 | 37 | const vorbis_func_residue *const _residue_P[]={ 38 | &residue0_exportbundle, 39 | &residue1_exportbundle, 40 | &residue2_exportbundle, 41 | }; 42 | 43 | const vorbis_func_mapping *const _mapping_P[]={ 44 | &mapping0_exportbundle, 45 | }; 46 | -------------------------------------------------------------------------------- /deps/vorbis/registry.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: registry for time, floor, res backends and channel mappings 14 | last mod: $Id: registry.h 15531 2008-11-24 23:50:06Z xiphmont $ 15 | 16 | ********************************************************************/ 17 | 18 | #ifndef _V_REG_H_ 19 | #define _V_REG_H_ 20 | 21 | #define VI_TRANSFORMB 1 22 | #define VI_WINDOWB 1 23 | #define VI_TIMEB 1 24 | #define VI_FLOORB 2 25 | #define VI_RESB 3 26 | #define VI_MAPB 1 27 | 28 | extern const vorbis_func_floor *const _floor_P[]; 29 | extern const vorbis_func_residue *const _residue_P[]; 30 | extern const vorbis_func_mapping *const _mapping_P[]; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /deps/vorbis/smallft.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: fft transform 14 | last mod: $Id: smallft.h 13293 2007-07-24 00:09:47Z xiphmont $ 15 | 16 | ********************************************************************/ 17 | 18 | #ifndef _V_SMFT_H_ 19 | #define _V_SMFT_H_ 20 | 21 | #include "vorbis/codec.h" 22 | 23 | typedef struct { 24 | int n; 25 | float *trigcache; 26 | int *splitcache; 27 | } drft_lookup; 28 | 29 | extern void drft_forward(drft_lookup *l,float *data); 30 | extern void drft_backward(drft_lookup *l,float *data); 31 | extern void drft_init(drft_lookup *l,int n); 32 | extern void drft_clear(drft_lookup *l); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /deps/vorbis/window.h: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | * * 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 7 | * * 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * 9 | * by the Xiph.Org Foundation http://www.xiph.org/ * 10 | * * 11 | ******************************************************************** 12 | 13 | function: window functions 14 | last mod: $Id: window.h 13293 2007-07-24 00:09:47Z xiphmont $ 15 | 16 | ********************************************************************/ 17 | 18 | #ifndef _V_WINDOW_ 19 | #define _V_WINDOW_ 20 | 21 | extern float *_vorbis_window_get(int n); 22 | extern void _vorbis_apply_window(float *d,int *winno,long *blocksizes, 23 | int lW,int W,int nW); 24 | 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /deps/zlib/gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | extern int gzclose_w(gzFile file); 9 | extern int gzclose_r(gzFile file); 10 | 11 | /* gzclose() is in a separate file so that it is linked in only if it is used. 12 | That way the other gzclose functions can be used instead to avoid linking in 13 | unneeded compression or decompression routines. */ 14 | int gzclose(gzFile file) 15 | { 16 | #ifndef NO_GZCOMPRESS 17 | gz_statep state; 18 | 19 | if (file == NULL) 20 | return Z_STREAM_ERROR; 21 | state = (gz_statep)file; 22 | 23 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 24 | #else 25 | return gzclose_r(file); 26 | #endif 27 | } 28 | -------------------------------------------------------------------------------- /deps/zlib/gzfile.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _GZFILE_H 3 | #define _GZFILE_H 4 | 5 | struct gzFile_s 6 | { 7 | unsigned have; 8 | unsigned char *next; 9 | z_off64_t pos; 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /deps/zlib/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | #ifndef _INFFAST_H 11 | #define _INFFAST_H 12 | 13 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /deps/zlib/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003, 2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Decompresses the source buffer into the destination buffer. sourceLen is 13 | the byte length of the source buffer. Upon entry, destLen is the total 14 | size of the destination buffer, which must be large enough to hold the 15 | entire uncompressed data. (The size of the uncompressed data must have 16 | been saved previously by the compressor and transmitted to the decompressor 17 | by some mechanism outside the scope of this compression library.) 18 | Upon exit, destLen is the actual size of the compressed buffer. 19 | 20 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 21 | enough memory, Z_BUF_ERROR if there was not enough room in the output 22 | buffer, or Z_DATA_ERROR if the input data was corrupted. 23 | */ 24 | int ZEXPORT uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) 25 | { 26 | z_stream stream; 27 | int err; 28 | 29 | stream.next_in = (Bytef *)source; 30 | stream.avail_in = (uInt)sourceLen; 31 | /* Check for source > 64K on 16-bit machine: */ 32 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 33 | 34 | stream.next_out = dest; 35 | stream.avail_out = (uInt)*destLen; 36 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 37 | 38 | stream.zalloc = Z_NULL; 39 | stream.zfree = Z_NULL; 40 | 41 | err = inflateInit(&stream); 42 | if (err != Z_OK) return err; 43 | 44 | err = inflate(&stream, Z_FINISH); 45 | if (err != Z_STREAM_END) { 46 | inflateEnd(&stream); 47 | if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 48 | return Z_DATA_ERROR; 49 | return err; 50 | } 51 | *destLen = stream.total_out; 52 | 53 | err = inflateEnd(&stream); 54 | return err; 55 | } 56 | -------------------------------------------------------------------------------- /event.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include "event.h" 7 | #include "lutro.h" 8 | 9 | int lutro_event_preload(lua_State *L) 10 | { 11 | static const luaL_Reg event_funcs[] = { 12 | { "quit", event_quit }, 13 | {NULL, NULL} 14 | }; 15 | 16 | lutro_newlib(L, event_funcs, "event"); 17 | 18 | return 1; 19 | } 20 | 21 | void lutro_event_init(void) 22 | { 23 | } 24 | 25 | /** 26 | * lutro.event.quit() 27 | * 28 | * https://love2d.org/wiki/love.event.quit 29 | */ 30 | int event_quit(lua_State *L) 31 | { 32 | int n = lua_gettop(L); 33 | if (n > 1) { 34 | return luaL_error(L, "lutro.event.quit requires 0 or 1 arguments, %d given.", n); 35 | } 36 | 37 | // Quit, ignoring the exit status. 38 | lutro_shutdown_game(); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /event.h: -------------------------------------------------------------------------------- 1 | #ifndef EVENT_H 2 | #define EVENT_H 3 | 4 | #include 5 | #include 6 | 7 | #include "runtime.h" 8 | 9 | int lutro_event_preload(lua_State *L); 10 | void lutro_event_init(void); 11 | int event_quit(lua_State *L); 12 | 13 | #endif // EVENT_H 14 | -------------------------------------------------------------------------------- /examples/benchmark/conf.lua: -------------------------------------------------------------------------------- 1 | function lutro.conf(t) 2 | t.width = 800 3 | t.height = 600 4 | end 5 | -------------------------------------------------------------------------------- /examples/benchmark/font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/libretro-lutro/469ddf0e236a2db15bd63b5d8c8daf5cdaa5a588/examples/benchmark/font.png -------------------------------------------------------------------------------- /examples/benchmark/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/libretro-lutro/469ddf0e236a2db15bd63b5d8c8daf5cdaa5a588/examples/benchmark/logo.png -------------------------------------------------------------------------------- /examples/serialization/foo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/libretro-lutro/469ddf0e236a2db15bd63b5d8c8daf5cdaa5a588/examples/serialization/foo.png -------------------------------------------------------------------------------- /examples/serialization/global.lua: -------------------------------------------------------------------------------- 1 | SCREEN_WIDTH = 320 2 | SCREEN_HEIGHT = 240 3 | 4 | RETRO_DEVICE_ID_JOYPAD_B = 1 5 | RETRO_DEVICE_ID_JOYPAD_Y = 2 6 | RETRO_DEVICE_ID_JOYPAD_SELECT = 3 7 | RETRO_DEVICE_ID_JOYPAD_START = 4 8 | RETRO_DEVICE_ID_JOYPAD_UP = 5 9 | RETRO_DEVICE_ID_JOYPAD_DOWN = 6 10 | RETRO_DEVICE_ID_JOYPAD_LEFT = 7 11 | RETRO_DEVICE_ID_JOYPAD_RIGHT = 8 12 | RETRO_DEVICE_ID_JOYPAD_A = 9 13 | RETRO_DEVICE_ID_JOYPAD_X = 10 14 | RETRO_DEVICE_ID_JOYPAD_L = 11 15 | RETRO_DEVICE_ID_JOYPAD_R = 12 16 | RETRO_DEVICE_ID_JOYPAD_L2 = 13 17 | RETRO_DEVICE_ID_JOYPAD_R2 = 14 18 | RETRO_DEVICE_ID_JOYPAD_L3 = 15 19 | RETRO_DEVICE_ID_JOYPAD_R3 = 16 20 | -------------------------------------------------------------------------------- /examples/serialization/json.lua: -------------------------------------------------------------------------------- 1 | -- json parsing 2 | function json_decode(msg) 3 | local js = {} 4 | for k,v in string.gmatch(msg,'"(%w+)":"(%w+)",') do 5 | js[k] = v; 6 | end 7 | for k,v in string.gmatch(msg,'"(%w+)":"(%w+)"}') do 8 | js[k] = v; 9 | end 10 | return js 11 | end 12 | 13 | function json_encode(map) 14 | local msg = "{" 15 | for k,v in pairs(map) do 16 | msg = msg..'"'..k..'":"'..v..'",' 17 | end 18 | return string.sub(msg,0,-2)..'}' 19 | end -------------------------------------------------------------------------------- /examples/serialization/main.lua: -------------------------------------------------------------------------------- 1 | require "global" 2 | require "json" 3 | 4 | function love.conf(t) 5 | t.width = SCREEN_WIDTH 6 | t.height = SCREEN_HEIGHT 7 | end 8 | 9 | State = { 10 | x = 50, 11 | y = 50 12 | } 13 | 14 | function love.load() 15 | love.graphics.setBackgroundColor(0, 0, 0) 16 | love.graphics.setDefaultFilter("nearest", "nearest") 17 | 18 | IMG_foo = love.graphics.newImage("foo.png") 19 | end 20 | 21 | function love.update(dt) 22 | State.x = State.x + 1 23 | if State.x > SCREEN_WIDTH then State.x = 0 end 24 | end 25 | 26 | function love.draw() 27 | love.graphics.draw(IMG_foo, State.x, State.y) 28 | end 29 | 30 | function love.reset() 31 | print("reset from lua") 32 | 33 | State = { 34 | x = 50, 35 | y = 50 36 | } 37 | 38 | love.load() 39 | end 40 | 41 | function love.serializeSize() 42 | print("serializeSize") 43 | return 1024 44 | end 45 | 46 | function love.serialize(size) 47 | print("serialize", size) 48 | return json_encode(State) 49 | end 50 | 51 | function love.unserialize(data, size) 52 | print("unserialize", data, size) 53 | State = json_decode(data) 54 | end 55 | -------------------------------------------------------------------------------- /filesystem.h: -------------------------------------------------------------------------------- 1 | #ifndef FILESYSTEM_H 2 | #define FILESYSTEM_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "runtime.h" 9 | 10 | void lutro_filesystem_init(void); 11 | void lutro_filesystem_deinit(void); 12 | int lutro_filesystem_preload(lua_State *L); 13 | 14 | int fs_read(lua_State *L); 15 | int fs_write(lua_State *L); 16 | int fs_load(lua_State *L); 17 | int fs_getRequirePath(lua_State *L); 18 | int fs_setRequirePath(lua_State *L); 19 | int fs_exists(lua_State *L); 20 | int fs_setIdentity(lua_State *L); 21 | int fs_isFile(lua_State *L); 22 | int fs_isDirectory(lua_State *L); 23 | int fs_createDirectory(lua_State *L); 24 | int fs_getAppdataDirectory(lua_State *L); 25 | int fs_getWorkingDirectory(lua_State *L); 26 | int fs_getDirectoryItems(lua_State *L); 27 | 28 | #endif // FILESYSTEM_H 29 | -------------------------------------------------------------------------------- /graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef GRAPHICS_H 2 | #define GRAPHICS_H 3 | 4 | #include 5 | #include "runtime.h" 6 | #include "painter.h" 7 | 8 | typedef struct 9 | { 10 | bitmap_t* data; 11 | int ref; 12 | } gfx_Image; 13 | 14 | typedef struct 15 | { 16 | unsigned x; 17 | unsigned y; 18 | unsigned w; 19 | unsigned h; 20 | unsigned sw; 21 | unsigned sh; 22 | } gfx_Quad; 23 | 24 | typedef struct 25 | { 26 | int r; 27 | int g; 28 | int b; 29 | int a; 30 | } gfx_Color; 31 | 32 | typedef painter_t gfx_Canvas; 33 | 34 | void lutro_graphics_init(lua_State* L); 35 | int lutro_graphics_preload(lua_State *L); 36 | 37 | void lutro_graphics_reinit(lua_State *L); 38 | void lutro_graphics_begin_frame(lua_State *L); 39 | void lutro_graphics_end_frame(lua_State *L); 40 | 41 | #endif // GRAPHICS_H 42 | -------------------------------------------------------------------------------- /image.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGE_H 2 | #define IMAGE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "runtime.h" 9 | 10 | #if defined(ABGR) 11 | #define ALPHA_SHIFT 24 12 | #define RED_SHIFT 0 13 | #define GREEN_SHIFT 8 14 | #define BLUE_SHIFT 16 15 | 16 | #define ALPHA_MASK 0xFF000000 17 | #define RED_MASK 0x000000FF 18 | #define GREEN_MASK 0x0000FF00 19 | #define BLUE_MASK 0x00FF0000 20 | #else 21 | #define ALPHA_SHIFT 24 22 | #define RED_SHIFT 16 23 | #define GREEN_SHIFT 8 24 | #define BLUE_SHIFT 0 25 | 26 | #define ALPHA_MASK 0xFF000000 27 | #define RED_MASK 0x00FF0000 28 | #define GREEN_MASK 0x0000FF00 29 | #define BLUE_MASK 0x000000FF 30 | #endif 31 | 32 | void lutro_image_init(void); 33 | int lutro_image_preload(lua_State *L); 34 | 35 | void *image_data_create_from_path(lua_State *L, const char *path); 36 | 37 | #endif // IMAGE_H 38 | -------------------------------------------------------------------------------- /input.h: -------------------------------------------------------------------------------- 1 | #ifndef INPUT_H 2 | #define INPUT_H 3 | 4 | #include "runtime.h" 5 | 6 | extern const struct int_const_map { 7 | long value; 8 | const char *name; 9 | } joystick_enum[17]; 10 | 11 | int lutro_input_preload(lua_State *L); 12 | int input_joypad(lua_State *L); 13 | const char* input_find_name(const struct int_const_map*, unsigned); 14 | 15 | #endif // INPUT_H 16 | -------------------------------------------------------------------------------- /jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | CORE_DIR := $(LOCAL_PATH)/.. 4 | WANT_UNZIP := 1 5 | WANT_LUALIB := 1 6 | 7 | include $(CORE_DIR)/Makefile.common 8 | 9 | COREFLAGS := -ffast-math -funroll-loops -DINLINE=inline -D__LIBRETRO__ -DFRONTEND_SUPPORTS_RGB565 -DLUA_USE_POSIX $(INCFLAGS) -DDONT_WANT_ARM_OPTIMIZATIONS 10 | 11 | GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)" 12 | ifneq ($(GIT_VERSION)," unknown") 13 | COREFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\" 14 | endif 15 | 16 | include $(CLEAR_VARS) 17 | LOCAL_MODULE := retro 18 | LOCAL_SRC_FILES := $(SOURCES_C) $(VORBIS_SOURCES_C) 19 | LOCAL_CFLAGS := $(COREFLAGS) -std=gnu99 20 | LOCAL_CXXFLAGS := $(COREFLAGS) 21 | LOCAL_LDFLAGS := -Wl,-version-script=$(CORE_DIR)/link.T 22 | LOCAL_LDLIBS := -lz 23 | 24 | ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) 25 | LOCAL_ARM_NEON := true 26 | endif 27 | 28 | include $(BUILD_SHARED_LIBRARY) 29 | -------------------------------------------------------------------------------- /jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := all 2 | -------------------------------------------------------------------------------- /joystick.h: -------------------------------------------------------------------------------- 1 | #ifndef JOYSTICK_H 2 | #define JOYSTICK_H 3 | 4 | #include 5 | #include 6 | 7 | #include "runtime.h" 8 | 9 | #define NB_JOYSTICKS 8 10 | #define NB_BUTTONS 16 11 | 12 | extern const struct joystick_int_const_map { 13 | long value; 14 | const char *name; 15 | } joystick_key_enum[NB_BUTTONS+1]; 16 | 17 | int lutro_joystick_preload(lua_State *L); 18 | void lutro_joystick_init(void); 19 | void lutro_joystickevent(lua_State* L); 20 | int joystick_getJoystickCount(lua_State *L); 21 | int joystick_isDown(lua_State *L); 22 | int joystick_getAxis(lua_State *L); 23 | const char* joystick_retroToJoystick(unsigned joystickKey); 24 | int joystick_joystickToRetro(const char* retroKey); 25 | void lutro_joystickInvokeJoystickEvent(lua_State* L, char* eventName, int joystick, int button); 26 | int joystick_find_value(const struct joystick_int_const_map *map, const char *name, unsigned *value); 27 | const char* joystick_find_name(const struct joystick_int_const_map *map, unsigned value); 28 | 29 | #endif // JOYSTICK_H 30 | -------------------------------------------------------------------------------- /keyboard.h: -------------------------------------------------------------------------------- 1 | #ifndef KEYBOARD_H 2 | #define KEYBOARD_H 3 | 4 | #include 5 | #include 6 | 7 | #include "runtime.h" 8 | 9 | extern const struct key_int_const_map { 10 | long value; 11 | const char *name; 12 | } keyboard_enum[RETROK_LAST]; 13 | 14 | int lutro_keyboard_preload(lua_State *L); 15 | void lutro_keyboard_init(void); 16 | void lutro_keyboardevent(lua_State* L); 17 | int keyboard_isDown(lua_State *L); 18 | int keyboard_getKeyFromScancode(lua_State *L); 19 | int keyboard_getScancodeFromKey(lua_State *L); 20 | int keyboard_string_to_libretro(const char* key); 21 | int keyboard_find_value(const struct key_int_const_map *map, const char *name, unsigned *value); 22 | const char* keyboard_find_name(const struct key_int_const_map *map, unsigned value); 23 | 24 | #endif // KEYBOARD_H 25 | -------------------------------------------------------------------------------- /libretro-common/include/audio/conversion/float_to_s16.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2021 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (float_to_s16.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * 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 SOFTWARE. 21 | */ 22 | 23 | #ifndef __LIBRETRO_SDK_CONVERSION_FLOAT_TO_S16_H__ 24 | #define __LIBRETRO_SDK_CONVERSION_FLOAT_TO_S16_H__ 25 | 26 | #include 27 | 28 | RETRO_BEGIN_DECLS 29 | 30 | #include 31 | #include 32 | 33 | /** 34 | * convert_float_to_s16: 35 | * @out : output buffer 36 | * @in : input buffer 37 | * @samples : size of samples to be converted 38 | * 39 | * Converts floating point 40 | * to signed integer 16-bit. 41 | **/ 42 | void convert_float_to_s16(int16_t *out, 43 | const float *in, size_t samples); 44 | 45 | /** 46 | * convert_float_to_s16_init_simd: 47 | * 48 | * Sets up function pointers for conversion 49 | * functions based on CPU features. 50 | **/ 51 | void convert_float_to_s16_init_simd(void); 52 | 53 | RETRO_END_DECLS 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /libretro-common/include/boolean.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (boolean.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * 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 SOFTWARE. 21 | */ 22 | 23 | #ifndef __LIBRETRO_SDK_BOOLEAN_H 24 | #define __LIBRETRO_SDK_BOOLEAN_H 25 | 26 | #ifndef __cplusplus 27 | 28 | #if defined(_MSC_VER) && _MSC_VER < 1800 && !defined(SN_TARGET_PS3) 29 | /* Hack applied for MSVC when compiling in C89 mode as it isn't C99 compliant. */ 30 | #define bool unsigned char 31 | #define true 1 32 | #define false 0 33 | #else 34 | #include 35 | #endif 36 | 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /libretro-common/include/compat/fopen_utf8.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (fopen_utf8.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * 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 SOFTWARE. 21 | */ 22 | 23 | #ifndef __LIBRETRO_SDK_COMPAT_FOPEN_UTF8_H 24 | #define __LIBRETRO_SDK_COMPAT_FOPEN_UTF8_H 25 | 26 | #ifdef _WIN32 27 | /* Defined to error rather than fopen_utf8, to make it clear to everyone reading the code that not worrying about utf16 is fine */ 28 | /* TODO: enable */ 29 | /* #define fopen (use fopen_utf8 instead) */ 30 | void *fopen_utf8(const char * filename, const char * mode); 31 | #else 32 | #define fopen_utf8 fopen 33 | #endif 34 | #endif 35 | -------------------------------------------------------------------------------- /libretro-common/include/compat/strcasestr.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (strcasestr.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * 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 SOFTWARE. 21 | */ 22 | 23 | #ifndef __LIBRETRO_SDK_COMPAT_STRCASESTR_H 24 | #define __LIBRETRO_SDK_COMPAT_STRCASESTR_H 25 | 26 | #include 27 | 28 | #if defined(RARCH_INTERNAL) && defined(HAVE_CONFIG_H) 29 | #include "../../../config.h" 30 | #endif 31 | 32 | #ifndef HAVE_STRCASESTR 33 | 34 | #include 35 | 36 | RETRO_BEGIN_DECLS 37 | 38 | /* Avoid possible naming collisions during link 39 | * since we prefer to use the actual name. */ 40 | #define strcasestr(haystack, needle) strcasestr_retro__(haystack, needle) 41 | 42 | char *strcasestr(const char *haystack, const char *needle); 43 | 44 | RETRO_END_DECLS 45 | 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /libretro-common/include/encodings/crc32.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (crc32.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * 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 SOFTWARE. 21 | */ 22 | 23 | #ifndef _LIBRETRO_ENCODINGS_CRC32_H 24 | #define _LIBRETRO_ENCODINGS_CRC32_H 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | RETRO_BEGIN_DECLS 32 | 33 | uint32_t encoding_crc32(uint32_t crc, const uint8_t *buf, size_t len); 34 | uint32_t file_crc32(uint32_t crc, const char *path); 35 | 36 | RETRO_END_DECLS 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /libretro-common/include/memalign.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (memalign.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * 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 SOFTWARE. 21 | */ 22 | 23 | #ifndef _LIBRETRO_MEMALIGN_H 24 | #define _LIBRETRO_MEMALIGN_H 25 | 26 | #include 27 | 28 | #include 29 | 30 | RETRO_BEGIN_DECLS 31 | 32 | void *memalign_alloc(size_t boundary, size_t size); 33 | 34 | void *memalign_alloc_aligned(size_t size); 35 | 36 | void memalign_free(void *ptr); 37 | 38 | RETRO_END_DECLS 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /libretro-common/include/retro_assert.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (retro_assert.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * 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 SOFTWARE. 21 | */ 22 | 23 | #ifndef __RETRO_ASSERT_H 24 | #define __RETRO_ASSERT_H 25 | 26 | #include 27 | 28 | #ifdef RARCH_INTERNAL 29 | #include 30 | #define retro_assert(cond) ((void)( (cond) || (printf("Assertion failed at %s:%d.\n", __FILE__, __LINE__), abort(), 0) )) 31 | #else 32 | #define retro_assert(cond) assert(cond) 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libretro-common/include/retro_common.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (retro_common.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * 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 SOFTWARE. 21 | */ 22 | 23 | #ifndef _LIBRETRO_COMMON_RETRO_COMMON_H 24 | #define _LIBRETRO_COMMON_RETRO_COMMON_H 25 | 26 | /* 27 | This file is designed to normalize the libretro-common compiling environment. 28 | It is not to be used in public API headers, as they should be designed as leanly as possible. 29 | Nonetheless.. in the meantime, if you do something like use ssize_t, which is not fully portable, 30 | in a public API, you may need this. 31 | */ 32 | 33 | /* conditional compilation is handled inside here */ 34 | #include 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /libretro-common/include/retro_inline.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (retro_inline.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * 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 SOFTWARE. 21 | */ 22 | 23 | #ifndef __LIBRETRO_SDK_INLINE_H 24 | #define __LIBRETRO_SDK_INLINE_H 25 | 26 | #ifndef INLINE 27 | 28 | #if defined(_WIN32) || defined(__INTEL_COMPILER) 29 | #define INLINE __inline 30 | #elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L 31 | #define INLINE inline 32 | #elif defined(__GNUC__) 33 | #define INLINE __inline__ 34 | #else 35 | #define INLINE 36 | #endif 37 | 38 | #endif 39 | #endif 40 | -------------------------------------------------------------------------------- /libretro-common/include/time/rtime.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (rtime.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * 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 SOFTWARE. 21 | */ 22 | 23 | #ifndef __LIBRETRO_SDK_RTIME_H__ 24 | #define __LIBRETRO_SDK_RTIME_H__ 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | RETRO_BEGIN_DECLS 33 | 34 | /* TODO/FIXME: Move all generic time handling functions 35 | * to this file */ 36 | 37 | /* Must be called before using rtime_localtime() */ 38 | void rtime_init(void); 39 | 40 | /* Must be called upon program termination */ 41 | void rtime_deinit(void); 42 | 43 | /* Thread-safe wrapper for localtime() */ 44 | struct tm *rtime_localtime(const time_t *timep, struct tm *result); 45 | 46 | RETRO_END_DECLS 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /link.T: -------------------------------------------------------------------------------- 1 | { 2 | global: retro_*; 3 | local: *; 4 | }; 5 | 6 | -------------------------------------------------------------------------------- /live.h: -------------------------------------------------------------------------------- 1 | #ifndef LIVE_H 2 | #define LIVE_H 3 | 4 | #include "runtime.h" 5 | 6 | int lutro_live_preload(lua_State *L); 7 | void lutro_live_init(); 8 | void lutro_live_deinit(); 9 | void lutro_live_update(lua_State *L); 10 | void lutro_live_draw(); 11 | 12 | #endif // LIVE_H 13 | -------------------------------------------------------------------------------- /lutro_math.h: -------------------------------------------------------------------------------- 1 | #ifndef LUTRO_MATH_H 2 | #define LUTRO_MATH_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "runtime.h" 9 | 10 | void lutro_math_init(void); 11 | int lutro_math_preload(lua_State *L); 12 | int lutro_math_random(lua_State *L); 13 | int lutro_math_setRandomSeed(lua_State *L); 14 | 15 | #endif // LUTRO_MATH_H 16 | -------------------------------------------------------------------------------- /lutro_stb_image.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "lutro_stb_image.h" 3 | #include "streams/file_stream.h" 4 | 5 | #define STB_IMAGE_IMPLEMENTATION 6 | #define STBI_ONLY_PNG 7 | #define STBI_NO_STDIO 8 | #define STBI_NO_LINEAR 9 | #define STBI_NO_HDR 10 | #define STBI_NO_THREAD_LOCALS 11 | #include "lutro.h" 12 | #include "stb/stb_image.h" 13 | 14 | /** 15 | * Load the given image into the data buffer. 16 | * 17 | * @return 1 on success, 0 on error. 18 | */ 19 | int lutro_stb_image_load(const char* filename, uint32_t** data, unsigned int* width, unsigned int* height) { 20 | void* buf; 21 | int64_t len; 22 | int x, y, channels_in_file; 23 | int channels = 4; 24 | 25 | // Load the file data. 26 | if (filestream_read_file(filename, &buf, &len) <= 0) { 27 | fprintf(stderr, "failed to read file %s\n", filename); 28 | *data = NULL; // Put a null pointer, in case caller doesn't check the return value 29 | return 0; 30 | } 31 | 32 | // Load the data as an image. 33 | stbi_uc* output = stbi_load_from_memory((stbi_uc const*)buf, (int)len, &x, &y, &channels_in_file, channels); 34 | *width = x; 35 | *height = y; 36 | free(buf); // Allocated in libretro:filestream_read_file, don't trace it on ludo 37 | 38 | // Ensure the image loaded successfully. 39 | if (output == NULL) { 40 | fprintf(stderr, "failed to load data from %s\n", filename); 41 | *data = NULL; // Put a null pointer, in case caller doesn't check the return value 42 | return 0; 43 | } 44 | 45 | // Flip the bits to have them in the format Lutro uses. 46 | { 47 | int rValue = 0; 48 | int bValue = 2; 49 | for (int xIndex = 0; xIndex < x; xIndex++) { 50 | for (int yIndex = 0; yIndex < y; yIndex++) { 51 | int index = xIndex + x * yIndex; 52 | stbi_uc tmp; 53 | tmp = output[index * channels + rValue]; 54 | output[index * channels + rValue] = output[index * channels + bValue]; 55 | output[index * channels + bValue] = tmp; 56 | } 57 | } 58 | } 59 | 60 | // Return the output as a success. 61 | *data = (uint32_t*)output; 62 | 63 | return 1; 64 | } 65 | -------------------------------------------------------------------------------- /lutro_stb_image.h: -------------------------------------------------------------------------------- 1 | #ifndef LUTRO_STB_IMAGE 2 | #define LUTRO_STB_IMAGE 3 | 4 | #include 5 | 6 | int lutro_stb_image_load(const char* filename, uint32_t** data, unsigned int* width, unsigned int* height); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /lutro_window.h: -------------------------------------------------------------------------------- 1 | #ifndef WINDOW_H 2 | #define WINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "runtime.h" 9 | 10 | void lutro_window_init(void); 11 | int lutro_window_preload(lua_State *L); 12 | 13 | int win_close(lua_State *L); 14 | int win_setTitle(lua_State *L); 15 | int win_setIcon(lua_State *L); 16 | int win_setMode(lua_State *L); 17 | int win_isCreated(lua_State *L); 18 | int win_maximize(lua_State *L); 19 | int win_minimize(lua_State *L); 20 | int win_getTitle(lua_State *L); 21 | int win_setPosition(lua_State *L); 22 | int win_getPosition(lua_State *L); 23 | int win_requestAttention(lua_State *L); 24 | int win_getDisplayName(lua_State *L); 25 | int win_setDisplaySleepEnabled(lua_State *L); 26 | int win_isDisplaySleepEnabled(lua_State *L); 27 | int win_showMessageBox(lua_State *L); 28 | 29 | #endif // WINDOW_H 30 | -------------------------------------------------------------------------------- /mouse.h: -------------------------------------------------------------------------------- 1 | #ifndef MOUSE_H 2 | #define MOUSE_H 3 | 4 | #include 5 | #include 6 | #include "runtime.h" 7 | 8 | int lutro_mouse_preload(lua_State *L); 9 | void lutro_mouse_init(void); 10 | void lutro_mouseevent(lua_State* L); 11 | int mouse_isDown(lua_State *L); 12 | int mouse_getX(lua_State *L); 13 | int mouse_getY(lua_State *L); 14 | int mouse_getPosition(lua_State *L); 15 | 16 | #endif // MOUSE_H 17 | -------------------------------------------------------------------------------- /msbuild/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | # custom rule to match icystdlib and gists from github.com/jstine35 3 | [*.{c,cpp,h,inl}] 4 | indent_style = tab 5 | insert_final_newline = true 6 | indent_size = 4 7 | -------------------------------------------------------------------------------- /msbuild/.gitignore: -------------------------------------------------------------------------------- 1 | *_sources.props 2 | lib/ 3 | obj/ -------------------------------------------------------------------------------- /msbuild/fi-msw-buildconf.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define PLATFORM_MSW 1 4 | 5 | #if defined(_MSC_VER) && !defined(_ITERATOR_DEBUG_LEVEL) 6 | # define _ITERATOR_DEBUG_LEVEL 0 7 | #endif 8 | 9 | #if defined(_MSC_VER) 10 | #define _CRT_NONSTDC_NO_WARNINGS 1 11 | #endif 12 | 13 | // putting some clangcl specific warning controls here rather than fi-warnings since they're exclusively clangcl (msbuild). 14 | #if defined(__clang__) 15 | # pragma GCC diagnostic ignored "-Wmicrosoft-include" 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /msbuild/fi-printf-redirect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if !defined(REDEFINE_PRINTF) 4 | # if defined(_MSC_VER) 5 | # define REDEFINE_PRINTF 1 6 | # endif 7 | #endif 8 | 9 | #if !defined(__verify_fmt) 10 | # if defined(_MSC_VER) 11 | # define __verify_fmt(fmtpos, vapos) 12 | # else 13 | # define __verify_fmt(fmtpos, vapos) __attribute__ ((format (printf, fmtpos, vapos))) 14 | # endif 15 | #endif 16 | 17 | // On Windows it's handy to have printf() automatically redirect itself into the Visual Studio Output window 18 | // and the only sane way to accomplish that seems to be by replacing printf() with a macro. 19 | #if REDEFINE_PRINTF 20 | #include // must include before macro definition 21 | #if defined(__cplusplus) 22 | # include 23 | # define _extern_c extern "C" 24 | #else 25 | # include 26 | # define _extern_c 27 | #endif 28 | _extern_c int _fi_redirect_printf (const char* fmt, ...) __verify_fmt(1,2); 29 | _extern_c int _fi_redirect_vfprintf (FILE* handle, const char* fmt, va_list args) __verify_fmt(2,3); 30 | _extern_c int _fi_redirect_fprintf (FILE* handle, const char* fmt, ...); 31 | _extern_c int _fi_redirect_puts (char const* _Buffer); 32 | _extern_c int _fi_redirect_fputs (char const* _Buffer, FILE* _Stream); 33 | _extern_c intmax_t _fi_redirect_fwrite(void const* src, size_t, size_t, FILE* fp); 34 | 35 | #define printf(fmt, ...) _fi_redirect_printf (fmt, ## __VA_ARGS__) 36 | #define fprintf(fp, fmt, ...) _fi_redirect_fprintf (fp, fmt, ## __VA_ARGS__) 37 | #define vfprintf(fp, fmt, args) _fi_redirect_vfprintf(fp, fmt, args) 38 | #define puts(msg) _fi_redirect_puts (msg) 39 | #define fputs(msg, fp) _fi_redirect_fputs (msg, fp) 40 | #define fwrite(buf, sz, nx, fp) _fi_redirect_fwrite (buf, sz, nx, fp) 41 | #undef _extern_c 42 | #endif 43 | -------------------------------------------------------------------------------- /sound.h: -------------------------------------------------------------------------------- 1 | #ifndef SOUND_H 2 | #define SOUND_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "runtime.h" 9 | 10 | #include "audio_mixer.h" 11 | 12 | // pre-decoded soundData. 13 | // 14 | // it is always matching our internal mixer_presaturate_t type, so there's no 15 | // need to track bytes per sample. 16 | typedef struct 17 | { 18 | int numChannels; 19 | intmax_t numSamples; 20 | mixer_presaturate_t* data; 21 | } snd_SoundData; 22 | 23 | void lutro_sound_init(void); 24 | int lutro_sound_preload(lua_State *L); 25 | 26 | int snd_newSoundData(lua_State *L); 27 | 28 | int sndta_type(lua_State *L); 29 | int sndta_gc(lua_State *L); 30 | 31 | #endif // SOUND_H 32 | -------------------------------------------------------------------------------- /system.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSTEM_H 2 | #define SYSTEM_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "runtime.h" 9 | 10 | void lutro_system_init(void); 11 | int lutro_system_preload(lua_State *L); 12 | 13 | int sys_getOS(lua_State *L); 14 | int sys_getProcessorCount(lua_State *L); 15 | int sys_getClipboardText(lua_State *L); 16 | int sys_setClipboardText(lua_State *L); 17 | int sys_getPowerInfo(lua_State *L); 18 | int sys_openURL(lua_State *L); 19 | int sys_vibrate(lua_State *L); 20 | 21 | #endif // SYSTEM_H 22 | -------------------------------------------------------------------------------- /test/audio/play.lua: -------------------------------------------------------------------------------- 1 | local audio = "audio/test.wav" 2 | local playTime = 0.75 3 | local timer = 0 4 | 5 | return { 6 | load = function() 7 | audio = lutro.audio.newSource(audio) 8 | end, 9 | 10 | update = function(dt) 11 | timer = timer + dt 12 | if timer > playTime then 13 | lutro.audio.play(audio) 14 | timer = 0 15 | end 16 | end 17 | } 18 | -------------------------------------------------------------------------------- /test/audio/test.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/libretro-lutro/469ddf0e236a2db15bd63b5d8c8daf5cdaa5a588/test/audio/test.wav -------------------------------------------------------------------------------- /test/conf.lua: -------------------------------------------------------------------------------- 1 | function lutro.conf(t) 2 | t.width = 640 3 | t.height = 480 4 | end 5 | -------------------------------------------------------------------------------- /test/graphics/base_transform.lua: -------------------------------------------------------------------------------- 1 | 2 | local tiles = {} 3 | local quads = {} 4 | 5 | function load_transform_tiles() 6 | local tile_sizes = { 32, 64, 128, 256 } 7 | for _, tsz in ipairs(tile_sizes) do 8 | if tiles[tsz] == nil then 9 | tiles[tsz] = lutro.graphics.newImage(("graphics/grid-transform-%dpx.png"):format(tsz)) 10 | quads[tsz] = lutro.graphics.newQuad(0, 0, tsz, tsz, tsz, tsz) 11 | end 12 | end 13 | end 14 | 15 | function draw_transform_tiles(params) 16 | lutro.graphics.setColor(255, 255, 255) 17 | 18 | local scalex = params.scalex or 1 19 | local scaley = params.scaley or 1 20 | 21 | -- draw multiple fixed scales of the quad onscreen at once. 22 | -- avoid use of animation since it complicates automated verification 23 | -- display multiple screens of tiled tests instead. 24 | -- Include scales that converge toward zero to ensure safety of maths (DivZero, etc) 25 | -- use the first tile of the 2nd column to display scale=0 to ensure it's handled correctly (DivZero) 26 | 27 | local xpos = 10 28 | local ypos = 40 29 | 30 | local xscales = { 31 | 1.00, 1.00, 1.00, 1.00, 1.00, 32 | 0.00, 0.70, 0.50, 0.30, 0.001 33 | } 34 | 35 | local yscales = { 36 | 1.00, 0.70, 0.50, 0.30, 0.001, 37 | 0.00, 1.00, 1.00, 1.00, 1.00, 38 | } 39 | 40 | local tsz = 128 41 | local adv_y = tsz + 4 42 | 43 | for i = 1, 10 do 44 | if i == 6 then 45 | xpos = 10 46 | ypos = ypos + adv_y + 15 47 | end 48 | local orig = tsz / 2 49 | lutro.graphics.draw( 50 | tiles[tsz], quads[tsz], 51 | xpos + orig, ypos + orig, 52 | rotation, 53 | xscales[i] * scalex, yscales[i] * scaley, 54 | orig, orig 55 | ) 56 | lutro.graphics.print(("%.1f x %.1f"):format(xscales[i] * scalex, yscales[i] * scaley), xpos + 32, ypos - 15) 57 | xpos = xpos + tsz + 5 58 | end 59 | end -------------------------------------------------------------------------------- /test/graphics/font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/libretro-lutro/469ddf0e236a2db15bd63b5d8c8daf5cdaa5a588/test/graphics/font.png -------------------------------------------------------------------------------- /test/graphics/grid-transform-128px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/libretro-lutro/469ddf0e236a2db15bd63b5d8c8daf5cdaa5a588/test/graphics/grid-transform-128px.png -------------------------------------------------------------------------------- /test/graphics/grid-transform-256px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/libretro-lutro/469ddf0e236a2db15bd63b5d8c8daf5cdaa5a588/test/graphics/grid-transform-256px.png -------------------------------------------------------------------------------- /test/graphics/grid-transform-32px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/libretro-lutro/469ddf0e236a2db15bd63b5d8c8daf5cdaa5a588/test/graphics/grid-transform-32px.png -------------------------------------------------------------------------------- /test/graphics/grid-transform-64px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/libretro-lutro/469ddf0e236a2db15bd63b5d8c8daf5cdaa5a588/test/graphics/grid-transform-64px.png -------------------------------------------------------------------------------- /test/graphics/line.lua: -------------------------------------------------------------------------------- 1 | return { 2 | draw = function() 3 | lutro.graphics.setColor(255, 255, 255) 4 | lutro.graphics.line(100, 100, 640 - 100, 480 - 100) 5 | end 6 | } 7 | -------------------------------------------------------------------------------- /test/graphics/print.lua: -------------------------------------------------------------------------------- 1 | return { 2 | load = function() 3 | end, 4 | 5 | draw = function() 6 | -- Show mouse information. 7 | if lutro.mouse.isDown(1, 2) then 8 | local x, y = lutro.mouse.getPosition() 9 | lutro.graphics.print("Mouse " .. lutro.mouse.getX() .. "-" .. lutro.mouse.getY(), x, y) 10 | end 11 | if lutro.keyboard.isDown('space', 'a') then 12 | lutro.graphics.print("Space or A key is down!", 200, 200) 13 | end 14 | end 15 | } 16 | -------------------------------------------------------------------------------- /test/graphics/rectangle.lua: -------------------------------------------------------------------------------- 1 | local x = 0 2 | local xspeed = 40 3 | 4 | return { 5 | draw = function() 6 | lutro.graphics.setColor(255, 0, 0) 7 | lutro.graphics.rectangle("fill", x, 100, 100, 80) 8 | end, 9 | 10 | update = function(dt) 11 | x = x + xspeed * dt 12 | if x + 100 > 640 then 13 | xspeed = -40 14 | elseif x < 0 then 15 | xspeed = 40 16 | end 17 | end 18 | } 19 | -------------------------------------------------------------------------------- /test/graphics/scale.lua: -------------------------------------------------------------------------------- 1 | 2 | require("graphics/base_transform") 3 | 4 | local rotation = 0 5 | local xflip = 1 6 | local yflip = 1 7 | local time = 0 8 | 9 | return { 10 | intervalTime = 12, 11 | 12 | load = function() 13 | load_transform_tiles() 14 | end, 15 | 16 | draw = function() 17 | draw_transform_tiles{ scalex = xflip, scaley = yflip } 18 | end, 19 | 20 | update = function(dt) 21 | time = time + dt 22 | 23 | local lutx = { 1, 1, -1, -1 } 24 | local luty = { 1, -1, 1, -1 } 25 | 26 | local ix = math.min(math.floor(time / 3) + 1, 4) 27 | local iy = math.min(math.floor(time / 3) + 1, 4) 28 | xflip = lutx[ix] 29 | yflip = luty[iy] 30 | end 31 | } 32 | -------------------------------------------------------------------------------- /test/joystick/getJoystickCount.lua: -------------------------------------------------------------------------------- 1 | return { 2 | load = function() 3 | count = lutro.joystick.getJoystickCount() 4 | end, 5 | draw = function() 6 | lutro.graphics.print(tostring(count), 30, 100) 7 | end 8 | } 9 | -------------------------------------------------------------------------------- /test/joystick/isDown.lua: -------------------------------------------------------------------------------- 1 | return { 2 | draw = function() 3 | lutro.graphics.print("1: " .. tostring(lutro.joystick.isDown(1, 1)), 30, 100) 4 | lutro.graphics.print("2: " .. tostring(lutro.joystick.isDown(1, 2)), 100, 100) 5 | lutro.graphics.print("3: " .. tostring(lutro.joystick.isDown(1, 3)), 200, 100) 6 | lutro.graphics.print("4: " .. tostring(lutro.joystick.isDown(1, 4)), 30, 200) 7 | lutro.graphics.print("5: " .. tostring(lutro.joystick.isDown(1, 5)), 100, 200) 8 | lutro.graphics.print("6: " .. tostring(lutro.joystick.isDown(1, 6)), 200, 200) 9 | lutro.graphics.print("7: " .. tostring(lutro.joystick.isDown(1, 7)), 30, 300) 10 | lutro.graphics.print("8: " .. tostring(lutro.joystick.isDown(1, 8)), 100, 300) 11 | lutro.graphics.print("9: " .. tostring(lutro.joystick.isDown(1, 9)), 200, 300) 12 | end 13 | } 14 | -------------------------------------------------------------------------------- /test/unit/luaunit/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software is distributed under the BSD License. 2 | 3 | Copyright (c) 2005-2018, Philippe Fremy 4 | 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 8 | 9 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 10 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /test/unit/main.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Lutro Unit Tests 3 | 4 | These are run through the Lutro testing suite, but you 5 | can run the unit tests individually by executing: 6 | 7 | retroarch -L path/to/lutro_libretro.so test/unit 8 | ]]-- 9 | 10 | -- Dependency paths. 11 | package.path = package.path .. './test/?.lua;./test/unit/?.lua;./test/unit/luaunit/?.lua;./luaunit/?.lua' 12 | 13 | -- Load the unit tests. 14 | require 'tests' 15 | 16 | -- Set up Lutro to run the tests at load. 17 | function lutro.load() 18 | runTests() 19 | io.write("Lutro unit test run complete\n") 20 | lutro.event.quit() 21 | end 22 | -------------------------------------------------------------------------------- /test/unit/modules/featureflags.lua: -------------------------------------------------------------------------------- 1 | 2 | local function printBuildFlags() 3 | -- Step 1: duplicate the table 4 | -- Step 2: Sort the array alphabetically 5 | -- Step 3: Iterate over the sorted array 6 | 7 | local copy = {} 8 | for k in pairs(lutro.featureflags) do 9 | table.insert(copy, k) 10 | end 11 | 12 | table.sort(copy, function(a, b) 13 | return a:lower() < b:lower() 14 | end) 15 | 16 | -- named prefixed with _ are for internal lutro use. 17 | for _, key in ipairs(copy) do 18 | if not key:find("^_") then 19 | print( ("lutro.featureflags.%s = %s"):format(key, tostring(lutro.featureflags[key])) ) 20 | end 21 | end 22 | end 23 | 24 | local function verify_as_truefalse() 25 | unit.assertEquals(lutro.featureflags._VERIFY_AS_TRUE, true) 26 | unit.assertEquals(lutro.featureflags._VERIFY_AS_FALSE, false) 27 | end 28 | 29 | local function verify_as_undefined() 30 | unit.assertEquals(lutro.featureflags._VERIFY_AS_UNDEFINED, false) 31 | end 32 | 33 | return { 34 | printBuildFlags, 35 | verify_as_truefalse, 36 | verify_as_undefined, 37 | } 38 | -------------------------------------------------------------------------------- /test/unit/modules/graphics.lua: -------------------------------------------------------------------------------- 1 | function lutro.graphics.setBackgroundColorTest() 2 | red = 115 3 | green = 27 4 | blue = 135 5 | alpha = 50 6 | color = { red, green, blue, alpha } 7 | lutro.graphics.setBackgroundColor(color) 8 | lutro.graphics.setBackgroundColor(red, green, blue, alpha) 9 | end 10 | 11 | function lutro.graphics.getBackgroundColorTest() 12 | r, g, b, a = lutro.graphics.getBackgroundColor() 13 | unit.assertEquals(r, 115) 14 | unit.assertEquals(g, 27) 15 | unit.assertEquals(b, 135) 16 | unit.assertEquals(a, 50) 17 | end 18 | 19 | return { 20 | lutro.graphics.setBackgroundColorTest, 21 | lutro.graphics.getBackgroundColorTest 22 | } -------------------------------------------------------------------------------- /test/unit/modules/keyboard.lua: -------------------------------------------------------------------------------- 1 | function lutro.keyboard.getScancodeFromKeyTest() 2 | local scancode = lutro.keyboard.getScancodeFromKey('f') 3 | unit.assertIsNumber(scancode) 4 | unit.assertEquals(scancode, 102) 5 | end 6 | 7 | function lutro.keyboard.getKeyFromScancodeTest() 8 | local key = lutro.keyboard.getKeyFromScancode(102) 9 | unit.assertIsString(key) 10 | unit.assertEquals(key, 'f') 11 | end 12 | 13 | return { 14 | lutro.keyboard.getScancodeFromKeyTest, 15 | lutro.keyboard.getKeyFromScancodeTest 16 | } -------------------------------------------------------------------------------- /test/unit/modules/math.lua: -------------------------------------------------------------------------------- 1 | function lutro.math.setRandomSeedTest() 2 | lutro.math.setRandomSeed(3) 3 | lutro.math.setRandomSeed(3, 10) 4 | end 5 | 6 | function lutro.math.randomTest() 7 | for i = 1, 1000, 1 do 8 | actual = lutro.math.random(10, 20) 9 | unit.assertTrue(actual >= 10 and actual <= 20) 10 | end 11 | 12 | for i = 1, 1000, 1 do 13 | actual = lutro.math.random(10) 14 | unit.assertTrue(actual >= 0 and actual <= 10) 15 | end 16 | 17 | for i = 1, 1000, 1 do 18 | actual = lutro.math.random() 19 | unit.assertTrue(actual >= 0 and actual <= 1) 20 | end 21 | end 22 | 23 | return { 24 | lutro.math.setRandomSeedTest, 25 | lutro.math.randomTest 26 | } -------------------------------------------------------------------------------- /test/unit/modules/system.lua: -------------------------------------------------------------------------------- 1 | --http = require 'socket.http' 2 | 3 | function UTF8Test() 4 | local utf8 = require("utf8") 5 | local actual = utf8.len("Hello World!") 6 | unit.assertEquals(actual, 12) 7 | end 8 | 9 | -- function http.requestTest() 10 | -- local http = require('socket.http') 11 | -- local result = http.request('http://buildbot.libretro.com/assets/frontend/info/lutro_libretro.info') 12 | -- unit.assertStrContains(result, 'display_name = "LUA Engine (Lutro)"') 13 | --end 14 | 15 | function lutro.getVersionTest() 16 | local major, minor, revision, codename = lutro.getVersion() 17 | unit.assertIsNumber(major) 18 | unit.assertIsNumber(minor) 19 | unit.assertIsNumber(revision) 20 | unit.assertEquals(codename, 'Lutro') 21 | end 22 | 23 | function lutro.system.getPowerInfoTest() 24 | local state, percent, seconds = lutro.system.getPowerInfo() 25 | unit.assertIsString(state) 26 | unit.assertEquals(state, 'unknown') 27 | unit.assertIsNil(percent) 28 | unit.assertIsNil(seconds) 29 | end 30 | 31 | function lutro.system.openURLTest() 32 | local success = lutro.system.openURL('http://libretro.com') 33 | unit.assertIsBoolean(success) 34 | unit.assertEquals(success, false) 35 | end 36 | 37 | function lutro.system.vibrateTest() 38 | local output = lutro.system.vibrate() 39 | unit.assertIsNil(output) 40 | lutro.system.vibrate(0.5) 41 | end 42 | 43 | function lutro.system.getProcessorCountTest() 44 | local count = lutro.system.getProcessorCount() 45 | unit.assertIsNumber(count) 46 | unit.assertEquals(count, 1) 47 | end 48 | 49 | function lutro.system.getClipboardTextTest() 50 | local clipboard = lutro.system.getClipboardText() 51 | unit.assertIsString(clipboard) 52 | unit.assertEquals(clipboard, "") 53 | end 54 | 55 | function lutro.system.setClipboardTextTest() 56 | local clipboard = "Hello, World!" 57 | lutro.system.setClipboardText(clipboard) 58 | 59 | clipboard = "Goodbye, World!" 60 | clipboard = lutro.system.getClipboardText() 61 | unit.assertEquals(clipboard, "Hello, World!") 62 | end 63 | 64 | return { 65 | UTF8Test, 66 | -- http.requestTest, 67 | lutro.getVersionTest, 68 | lutro.system.getPowerInfoTest, 69 | lutro.system.openURLTest, 70 | lutro.system.vibrateTest, 71 | lutro.system.getProcessorCountTest, 72 | lutro.system.getClipboardTextTest, 73 | lutro.system.setClipboardTextTest 74 | } -------------------------------------------------------------------------------- /test/unit/modules/timer.lua: -------------------------------------------------------------------------------- 1 | function lutro.timer.getDeltaTest() 2 | local delta = lutro.timer.getDelta() 3 | unit.assertIsNumber(delta) 4 | end 5 | 6 | return { 7 | lutro.timer.getDeltaTest 8 | } -------------------------------------------------------------------------------- /test/unit/tests.lua: -------------------------------------------------------------------------------- 1 | -- Add all available include paths. 2 | package.path = package.path .. './test/?.lua;./test/unit/?.lua;./test/unit/luaunit/?.lua;./luaunit/?.lua' 3 | 4 | -- Dependencies 5 | unit = require 'luaunit' 6 | 7 | -- Runs all tests. 8 | function runTests() 9 | local moduleTests = { 10 | require 'modules/featureflags', 11 | require 'modules/filesystem', 12 | require 'modules/graphics', 13 | require 'modules/keyboard', 14 | require 'modules/math', 15 | require 'modules/system', 16 | require 'modules/timer', 17 | require 'modules/window' 18 | } 19 | for i, moduleTests in ipairs(moduleTests) do 20 | for i, functionTest in ipairs(moduleTests) do 21 | functionTest() 22 | end 23 | end 24 | end 25 | 26 | -- Return a load and draw function for running the unit 27 | -- tests in the Lutro testing suite. 28 | return { 29 | intervalTime = 2, 30 | 31 | load = function() 32 | runTests() 33 | end, 34 | 35 | draw = function() 36 | lutro.graphics.print('Unit tests have been run.', 30, 100) 37 | end 38 | } 39 | -------------------------------------------------------------------------------- /test/window/close.lua: -------------------------------------------------------------------------------- 1 | local m_is_unattended = false 2 | 3 | return { 4 | load = function() 5 | -- When deciding to terminate the process, check for "UNATTENDED" env var. This is preferred over 6 | -- "CI" as the name is more explicit. "CI" is short and likely to have other meanings in casual 7 | -- user/developer environments and should be avoided when making potentially surprising actions 8 | -- like sudden process termination. 9 | local env_ci = os.getenv("UNATTENDED") 10 | if env_ci then 11 | print ("env: UNATTENDED=" .. env_ci) 12 | env_ci = env_ci:lower() 13 | -- consider any value other than something specifically "false" as a truthy value. 14 | if env_ci ~= "false" and env_ci ~= "0" and env_ci ~= "no" then 15 | m_is_unattended = true 16 | end 17 | end 18 | end, 19 | 20 | draw = function() 21 | -- test that window.close() operates normally, but also terminate the process via lua to 22 | -- force stop the test even if the libretro frontend is designed or configured to be persistent. 23 | -- This allows using the tests via some automatic PR sweeps. 24 | 25 | print ("All Tests Complete. Closing libretro frontend window...") 26 | lutro.window.close() 27 | 28 | if m_is_unattended then 29 | print (" > Exiting process due to env UNATTENDED=" .. os.getenv("UNATTENDED")) 30 | os.exit() 31 | else 32 | print ("Note: Libretro frontend may continue running depending on mode/settings.") 33 | print (" > Set UNATTENDED=1 in the process environment to exit the libretro frontend immediately.") 34 | end 35 | end 36 | } 37 | -------------------------------------------------------------------------------- /tests/audio/conf.lua: -------------------------------------------------------------------------------- 1 | function lutro.conf(t) 2 | t.width = 640 3 | t.height = 480 4 | end 5 | -------------------------------------------------------------------------------- /tests/audio/font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/libretro-lutro/469ddf0e236a2db15bd63b5d8c8daf5cdaa5a588/tests/audio/font.png -------------------------------------------------------------------------------- /tests/audio/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/libretro-lutro/469ddf0e236a2db15bd63b5d8c8daf5cdaa5a588/tests/audio/logo.png -------------------------------------------------------------------------------- /tests/audio/test_float32_mono.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/libretro-lutro/469ddf0e236a2db15bd63b5d8c8daf5cdaa5a588/tests/audio/test_float32_mono.wav -------------------------------------------------------------------------------- /tests/audio/test_ogg_mono.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/libretro-lutro/469ddf0e236a2db15bd63b5d8c8daf5cdaa5a588/tests/audio/test_ogg_mono.ogg -------------------------------------------------------------------------------- /tests/audio/test_s16_mono.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/libretro-lutro/469ddf0e236a2db15bd63b5d8c8daf5cdaa5a588/tests/audio/test_s16_mono.wav -------------------------------------------------------------------------------- /timer.c: -------------------------------------------------------------------------------- 1 | #include "timer.h" 2 | #include "lutro.h" 3 | 4 | #include 5 | #include 6 | 7 | int lutro_timer_preload(lua_State *L) 8 | { 9 | static const luaL_Reg timer_funcs[] = { 10 | { "getTime", timer_getTime }, 11 | { "getDelta", timer_getDelta }, 12 | { "getFPS", timer_getFPS }, 13 | {NULL, NULL} 14 | }; 15 | 16 | lutro_newlib(L, timer_funcs, "timer"); 17 | 18 | return 1; 19 | } 20 | 21 | void lutro_timer_init(void) 22 | { 23 | } 24 | 25 | int timer_getTime(lua_State *L) 26 | { 27 | lua_pushnumber(L, perf_cb.get_time_usec() / 1000000.0); 28 | 29 | return 1; 30 | } 31 | 32 | /** 33 | * lutro.timer.getDelta() 34 | * 35 | * @see https://love2d.org/wiki/love.timer.getDelta 36 | */ 37 | int timer_getDelta(lua_State *L) 38 | { 39 | lua_pushnumber(L, settings.delta); 40 | 41 | return 1; 42 | } 43 | 44 | /** 45 | * lutro.timer.getFPS() 46 | * 47 | * @see https://love2d.org/wiki/love.timer.getFPS 48 | */ 49 | int timer_getFPS(lua_State *L) 50 | { 51 | lua_pushnumber(L, settings.fps); 52 | 53 | return 1; 54 | } 55 | -------------------------------------------------------------------------------- /timer.h: -------------------------------------------------------------------------------- 1 | #ifndef TIMER_H 2 | #define TIMER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "runtime.h" 9 | 10 | void lutro_timer_init(void); 11 | int lutro_timer_preload(lua_State *L); 12 | 13 | int timer_getTime(lua_State *L); 14 | int timer_getDelta(lua_State *L); 15 | int timer_getFPS(lua_State *L); 16 | 17 | #endif // TIMER_H 18 | --------------------------------------------------------------------------------