├── .gitignore ├── .gitlab-ci.yml ├── .travis.yml ├── LICENSE ├── Makefile ├── Makefile.libretro ├── build ├── Makefile.android_arm64-v8a ├── Makefile.android_armeabi ├── Makefile.android_armeabi-v7a ├── Makefile.android_mips ├── Makefile.android_mips64 ├── Makefile.android_x86 ├── Makefile.android_x86_64 ├── Makefile.common ├── Makefile.linux-portable_x86 ├── Makefile.linux-portable_x86_64 ├── Makefile.linux_x86 ├── Makefile.linux_x86_64 ├── Makefile.mingw_x86 ├── Makefile.mingw_x86_64 ├── Makefile.osx_x86 ├── Makefile.osx_x86_64 ├── Makefile.rules ├── Makefile.vita_arm ├── Makefile.wii_ppc ├── Makefile.windows_msvc2005_x86 ├── Makefile.windows_msvc2010_x64 ├── Makefile.windows_msvc2010_x86 ├── Makefile.windows_msvc2017_desktop_arm ├── Makefile.windows_msvc2017_desktop_x64 ├── Makefile.windows_msvc2017_desktop_x86 ├── Makefile.windows_x86 ├── Makefile.windows_x86_64 └── link.T ├── libretro-common ├── compat │ ├── compat_posix_string.c │ ├── compat_snprintf.c │ ├── compat_strcasestr.c │ ├── compat_strl.c │ └── fopen_utf8.c ├── encodings │ └── encoding_utf.c ├── file │ ├── file_path.c │ └── file_path_io.c ├── include │ ├── boolean.h │ ├── compat │ │ ├── apple_compat.h │ │ ├── fnmatch.h │ │ ├── fopen_utf8.h │ │ ├── getopt.h │ │ ├── ifaddrs.h │ │ ├── intrinsics.h │ │ ├── msvc.h │ │ ├── msvc │ │ │ └── stdint.h │ │ ├── posix_string.h │ │ ├── strcasestr.h │ │ ├── strl.h │ │ ├── zlib.h │ │ └── zutil.h │ ├── encodings │ │ └── utf.h │ ├── file │ │ └── file_path.h │ ├── libretro.h │ ├── memalign.h │ ├── retro_assert.h │ ├── retro_common.h │ ├── retro_common_api.h │ ├── retro_environment.h │ ├── retro_inline.h │ ├── retro_miscellaneous.h │ ├── rthreads │ │ ├── rsemaphore.h │ │ └── rthreads.h │ ├── streams │ │ └── file_stream.h │ ├── string │ │ └── stdstring.h │ ├── time │ │ └── rtime.h │ └── vfs │ │ ├── vfs.h │ │ └── vfs_implementation.h ├── memalign.c ├── rthreads │ ├── gx_pthread.h │ ├── psp_pthread.h │ ├── rsemaphore.c │ ├── rthreads.c │ └── xenon_sdl_threads.c ├── streams │ ├── file_stream.c │ └── file_stream_transforms.c ├── string │ └── stdstring.c ├── time │ └── rtime.c └── vfs │ └── vfs_implementation.c ├── libretro ├── gbaconv │ └── gbaconv.c ├── jni │ ├── Android.mk │ └── Application.mk ├── libretro.cpp ├── libretro_core_options.h ├── libretro_core_options_intl.h └── link.T └── src ├── GBACheats.h ├── gba.cpp ├── gba.h ├── globals.h ├── memory.cpp ├── memory.h ├── neon.h ├── neon_memcpy.S ├── port.h ├── sound.cpp ├── sound.h ├── sound_blargg.h ├── system.cpp ├── system.h ├── thread.c ├── thread.h └── types.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.so 2 | *.o 3 | *.elf 4 | EBOOT.BIN 5 | /libretro/obj/ 6 | 7 | /libretro/msvc/msvc-2010/Debug/ 8 | /libretro/msvc/msvc-2010/Release/ 9 | *.suo 10 | *.sdf 11 | *.bc 12 | *.js 13 | *.dll 14 | *.dylib 15 | package.json 16 | .npmignore 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: generic 2 | os: linux 3 | dist: trusty 4 | sudo: required 5 | addons: 6 | apt: 7 | packages: 8 | - g++-7 9 | sources: 10 | - ubuntu-toolchain-r-test 11 | env: 12 | global: 13 | - CORE=vba_next 14 | - COMPILER_NAME=gcc CXX=g++-7 CC=gcc-7 15 | matrix: 16 | - PLATFORM=linux_x64 17 | - PLATFORM=ngc 18 | - PLATFORM=wii 19 | - PLATFORM=wiiu 20 | before_script: 21 | - pwd 22 | - mkdir -p ~/bin 23 | - ln -s /usr/bin/gcc-7 ~/bin/gcc 24 | - ln -s /usr/bin/g++-7 ~/bin/g++ 25 | - ln -s /usr/bin/cpp-7 ~/bin/cpp 26 | - export PATH=~/bin:$PATH 27 | - ls -l ~/bin 28 | - echo $PATH 29 | - g++-7 --version 30 | - g++ --version 31 | script: 32 | - cd ~/ 33 | - git clone --depth=50 https://github.com/libretro/libretro-super 34 | - cd libretro-super/travis 35 | - ./build.sh 36 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.libretro 2 | -------------------------------------------------------------------------------- /build/Makefile.android_arm64-v8a: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Linux, Windows and Darwin 3 | # Download the Android NDK, unpack somewhere, and set NDK_ROOT_DIR to it 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = android_arm64-v8a 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = $(NDK_ROOT_DIR)/toolchains/aarch64-linux-android-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/aarch64-linux-android-gcc 28 | CXX = $(NDK_ROOT_DIR)/toolchains/aarch64-linux-android-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/aarch64-linux-android-g++ 29 | AS = $(NDK_ROOT_DIR)/toolchains/aarch64-linux-android-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/aarch64-linux-android-as 30 | AR = $(NDK_ROOT_DIR)/toolchains/aarch64-linux-android-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/aarch64-linux-android-ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .android_arm64-v8a.o 36 | SOEXT = .android_arm64-v8a.so 37 | LIBEXT = .android_arm64-v8a.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 0 43 | platform = android 44 | PLATDEFS = -DANDROID -DINLINE=inline -DHAVE_STDINT_H -DBSPF_UNIX -DHAVE_INTTYPES -DLSB_FIRST 45 | PLATCFLAGS = -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -Wa,--noexecstack -Wformat -Werror=format-security 46 | PLATCXXFLAGS = -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti 47 | PLATLDFLAGS = -shared --sysroot=$(NDK_ROOT_DIR)/platforms/android-21/arch-arm64 -lgcc -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -lc -lm 48 | PLATLDXFLAGS = -shared --sysroot=$(NDK_ROOT_DIR)/platforms/android-21/arch-arm64 -lgcc -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -lc -lm $(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/libgnustl_static.a 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = -I$(NDK_ROOT_DIR)/platforms/android-21/arch-arm64/usr/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/Makefile.android_armeabi: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Linux, Windows and Darwin 3 | # Download the Android NDK, unpack somewhere, and set NDK_ROOT_DIR to it 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = android_armeabi 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = $(NDK_ROOT_DIR)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/arm-linux-androideabi-gcc 28 | CXX = $(NDK_ROOT_DIR)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/arm-linux-androideabi-g++ 29 | AS = $(NDK_ROOT_DIR)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/arm-linux-androideabi-as 30 | AR = $(NDK_ROOT_DIR)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/arm-linux-androideabi-ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .android_armeabi.o 36 | SOEXT = .android_armeabi.so 37 | LIBEXT = .android_armeabi.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 0 43 | platform = android 44 | PLATDEFS = -DANDROID -DINLINE=inline -DHAVE_STDINT_H -DBSPF_UNIX -DHAVE_INTTYPES -DLSB_FIRST 45 | PLATCFLAGS = -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -Wa,--noexecstack -Wformat -Werror=format-security 46 | PLATCXXFLAGS = -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti 47 | PLATLDFLAGS = -shared --sysroot=$(NDK_ROOT_DIR)/platforms/android-9/arch-arm -lgcc -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -lc -lm 48 | PLATLDXFLAGS = -shared --sysroot=$(NDK_ROOT_DIR)/platforms/android-9/arch-arm -lgcc -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -lc -lm $(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/libgnustl_static.a 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = -I$(NDK_ROOT_DIR)/platforms/android-9/arch-arm/usr/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/Makefile.android_armeabi-v7a: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Linux, Windows and Darwin 3 | # Download the Android NDK, unpack somewhere, and set NDK_ROOT_DIR to it 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = android_armeabi-v7a 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = $(NDK_ROOT_DIR)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/arm-linux-androideabi-gcc 28 | CXX = $(NDK_ROOT_DIR)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/arm-linux-androideabi-g++ 29 | AS = $(NDK_ROOT_DIR)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/arm-linux-androideabi-as 30 | AR = $(NDK_ROOT_DIR)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/arm-linux-androideabi-ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .android_armeabi-v7a.o 36 | SOEXT = .android_armeabi-v7a.so 37 | LIBEXT = .android_armeabi-v7a.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 0 43 | platform = android 44 | PLATDEFS = -DANDROID -DINLINE=inline -DHAVE_STDINT_H -DBSPF_UNIX -DHAVE_INTTYPES -DLSB_FIRST 45 | PLATCFLAGS = -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -Wa,--noexecstack -Wformat -Werror=format-security 46 | PLATCXXFLAGS = -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti 47 | PLATLDFLAGS = -shared --sysroot=$(NDK_ROOT_DIR)/platforms/android-21/arch-arm -lgcc -no-canonical-prefixes -march=armv7-a -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -lc -lm 48 | PLATLDXFLAGS = -shared --sysroot=$(NDK_ROOT_DIR)/platforms/android-21/arch-arm -lgcc -no-canonical-prefixes -march=armv7-a -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -lc -lm $(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_static.a 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = -I$(NDK_ROOT_DIR)/platforms/android-21/arch-arm/usr/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/Makefile.android_mips: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Linux, Windows and Darwin 3 | # Download the Android NDK, unpack somewhere, and set NDK_ROOT_DIR to it 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = android_mips 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = $(NDK_ROOT_DIR)/toolchains/mipsel-linux-android-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/mipsel-linux-android-gcc 28 | CXX = $(NDK_ROOT_DIR)/toolchains/mipsel-linux-android-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/mipsel-linux-android-g++ 29 | AS = $(NDK_ROOT_DIR)/toolchains/mipsel-linux-android-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/mipsel-linux-android-as 30 | AR = $(NDK_ROOT_DIR)/toolchains/mipsel-linux-android-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/mipsel-linux-android-ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .android_mips.o 36 | SOEXT = .android_mips.so 37 | LIBEXT = .android_mips.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 0 43 | platform = android 44 | PLATDEFS = -DANDROID -DINLINE=inline -DHAVE_STDINT_H -DBSPF_UNIX -DHAVE_INTTYPES -DLSB_FIRST 45 | PLATCFLAGS = -fpic -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -no-canonical-prefixes -fomit-frame-pointer -funswitch-loops -finline-limit=300 -Wa,--noexecstack -Wformat -Werror=format-security 46 | PLATCXXFLAGS = -fpic -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -no-canonical-prefixes -fomit-frame-pointer -funswitch-loops -finline-limit=300 -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti 47 | PLATLDFLAGS = -shared --sysroot=$(NDK_ROOT_DIR)/platforms/android-9/arch-mips -lgcc -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -lc -lm 48 | PLATLDXFLAGS = -shared --sysroot=$(NDK_ROOT_DIR)/platforms/android-9/arch-mips -lgcc -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -lc -lm $(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips/libgnustl_static.a 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = -I$(NDK_ROOT_DIR)/platforms/android-9/arch-mips/usr/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/Makefile.android_mips64: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Linux, Windows and Darwin 3 | # Download the Android NDK, unpack somewhere, and set NDK_ROOT_DIR to it 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = android_mips64 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = $(NDK_ROOT_DIR)/toolchains/mips64el-linux-android-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/mips64el-linux-android-gcc 28 | CXX = $(NDK_ROOT_DIR)/toolchains/mips64el-linux-android-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/mips64el-linux-android-g++ 29 | AS = $(NDK_ROOT_DIR)/toolchains/mips64el-linux-android-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/mips64el-linux-android-as 30 | AR = $(NDK_ROOT_DIR)/toolchains/mips64el-linux-android-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/mips64el-linux-android-ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .android_mips64.o 36 | SOEXT = .android_mips64.so 37 | LIBEXT = .android_mips64.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 0 43 | platform = android 44 | PLATDEFS = -DANDROID -DINLINE=inline -DHAVE_STDINT_H -DBSPF_UNIX -DHAVE_INTTYPES -DLSB_FIRST 45 | PLATCFLAGS = -fpic -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -no-canonical-prefixes -fomit-frame-pointer -funswitch-loops -finline-limit=300 -Wa,--noexecstack -Wformat -Werror=format-security 46 | PLATCXXFLAGS = -fpic -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -no-canonical-prefixes -fomit-frame-pointer -funswitch-loops -finline-limit=300 -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti 47 | PLATLDFLAGS = -shared --sysroot=$(NDK_ROOT_DIR)/platforms/android-21/arch-mips64 -lgcc -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -lc -lm 48 | PLATLDXFLAGS = -shared --sysroot=$(NDK_ROOT_DIR)/platforms/android-21/arch-mips64 -lgcc -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -lc -lm $(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips64/libgnustl_static.a 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = -I$(NDK_ROOT_DIR)/platforms/android-21/arch-mips64/usr/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/libs/mips64/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/Makefile.android_x86: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Linux, Windows and Darwin 3 | # Download the Android NDK, unpack somewhere, and set NDK_ROOT_DIR to it 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = android_x86 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = $(NDK_ROOT_DIR)/toolchains/x86-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/i686-linux-android-gcc 28 | CXX = $(NDK_ROOT_DIR)/toolchains/x86-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/i686-linux-android-g++ 29 | AS = $(NDK_ROOT_DIR)/toolchains/x86-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/i686-linux-android-as 30 | AR = $(NDK_ROOT_DIR)/toolchains/x86-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/i686-linux-android-ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .android_x86.o 36 | SOEXT = .android_x86.so 37 | LIBEXT = .android_x86.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 0 43 | platform = android 44 | PLATDEFS = -DANDROID -DINLINE=inline -DHAVE_STDINT_H -DBSPF_UNIX -DHAVE_INTTYPES -DLSB_FIRST 45 | PLATCFLAGS = -ffunction-sections -funwind-tables -no-canonical-prefixes -fstack-protector -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -Wa,--noexecstack -Wformat -Werror=format-security 46 | PLATCXXFLAGS = -ffunction-sections -funwind-tables -no-canonical-prefixes -fstack-protector -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti 47 | PLATLDFLAGS = -shared --sysroot=$(NDK_ROOT_DIR)/platforms/android-9/arch-x86 -lgcc -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -lc -lm 48 | PLATLDXFLAGS = -shared --sysroot=$(NDK_ROOT_DIR)/platforms/android-9/arch-x86 -lgcc -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -lc -lm $(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/libgnustl_static.a 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = -I$(NDK_ROOT_DIR)/platforms/android-9/arch-x86/usr/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/Makefile.android_x86_64: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Linux, Windows and Darwin 3 | # Download the Android NDK, unpack somewhere, and set NDK_ROOT_DIR to it 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = android_x86_64 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = $(NDK_ROOT_DIR)/toolchains/x86_64-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/x86_64-linux-android-gcc 28 | CXX = $(NDK_ROOT_DIR)/toolchains/x86_64-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/x86_64-linux-android-g++ 29 | AS = $(NDK_ROOT_DIR)/toolchains/x86_64-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/x86_64-linux-android-as 30 | AR = $(NDK_ROOT_DIR)/toolchains/x86_64-4.9/prebuilt/$(HOST_PLATFORM)-x86_64/bin/x86_64-linux-android-ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .android_x86_64.o 36 | SOEXT = .android_x86_64.so 37 | LIBEXT = .android_x86_64.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 0 43 | platform = android 44 | PLATDEFS = -DANDROID -DINLINE=inline -DHAVE_STDINT_H -DBSPF_UNIX -DHAVE_INTTYPES -DLSB_FIRST 45 | PLATCFLAGS = -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -Wa,--noexecstack -Wformat -Werror=format-security 46 | PLATCXXFLAGS = -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti 47 | PLATLDFLAGS = -shared --sysroot=$(NDK_ROOT_DIR)/platforms/android-21/arch-x86_64 -lgcc -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -lc -lm 48 | PLATLDXFLAGS = -shared --sysroot=$(NDK_ROOT_DIR)/platforms/android-21/arch-x86_64 -lgcc -no-canonical-prefixes -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -lc -lm $(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86_64/libgnustl_static.a 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = -I$(NDK_ROOT_DIR)/platforms/android-21/arch-x86_64/usr/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86_64/include -I$(NDK_ROOT_DIR)/sources/cxx-stl/gnu-libstdc++/4.9/include/backward 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/Makefile.common: -------------------------------------------------------------------------------- 1 | LIBRETRO_COMM_DIR := $(CORE_DIR)/libretro-common 2 | INCFLAGS := -I$(CORE_DIR) -I$(LIBRETRO_COMM_DIR)/include 3 | COREDEFINES = -D__LIBRETRO__ -DHAVE_HLE_BIOS 4 | OBJECTS_COND := 5 | 6 | ifneq (,$(findstring msvc,$(platform))) 7 | COREDEFINES += -DINLINE=_inline 8 | else 9 | COREDEFINES += -DINLINE=inline 10 | endif 11 | 12 | ifneq (,$(findstring msvc2003,$(platform))) 13 | INCFLAGS += -I$(LIBRETRO_COMM_DIR)/include/compat/msvc 14 | endif 15 | 16 | ifeq ($(FRONTEND_SUPPORTS_RGB565), 1) 17 | COREDEFINES += -DFRONTEND_SUPPORTS_RGB565 18 | endif 19 | 20 | ifeq ($(USE_CHEATS), 1) 21 | COREDEFINES += -DUSE_CHEATS 22 | endif 23 | 24 | ifeq ($(USE_TWEAKS), 1) 25 | COREDEFINES += -DUSE_TWEAKS 26 | endif 27 | 28 | ifeq ($(LOAD_FROM_MEMORY),1) 29 | COREDEFINES += -DLOAD_FROM_MEMORY 30 | endif 31 | 32 | ifeq ($(USE_THREADED_RENDERER), 1) 33 | COREDEFINES += -DTHREADED_RENDERER 34 | endif 35 | 36 | ifeq ($(USE_MOTION_SENSOR), 1) 37 | COREDEFINES += -DUSE_MOTION_SENSOR 38 | endif 39 | 40 | ifeq ($(USE_FRAME_SKIP), 1) 41 | COREDEFINES += -DUSE_FRAME_SKIP 42 | endif 43 | 44 | ifeq ($(TILED_RENDERING), 1) 45 | COREDEFINES += -DTILED_RENDERING 46 | endif 47 | 48 | SOURCES_CXX := \ 49 | $(CORE_DIR)/src/sound.cpp \ 50 | $(CORE_DIR)/src/memory.cpp \ 51 | $(CORE_DIR)/src/gba.cpp \ 52 | $(CORE_DIR)/src/system.cpp \ 53 | $(CORE_DIR)/libretro/libretro.cpp 54 | SOURCES_C := 55 | 56 | ifneq ($(STATIC_LINKING),1) 57 | SOURCES_C += $(LIBRETRO_COMM_DIR)/memalign.c 58 | OBJECTS_COND += $(LIBRETRO_COMM_DIR)/memalign.o 59 | 60 | SOURCES_C += \ 61 | $(LIBRETRO_COMM_DIR)/compat/compat_posix_string.c \ 62 | $(LIBRETRO_COMM_DIR)/compat/compat_strcasestr.c \ 63 | $(LIBRETRO_COMM_DIR)/compat/compat_snprintf.c \ 64 | $(LIBRETRO_COMM_DIR)/compat/compat_strl.c \ 65 | $(LIBRETRO_COMM_DIR)/compat/fopen_utf8.c \ 66 | $(LIBRETRO_COMM_DIR)/encodings/encoding_utf.c \ 67 | $(LIBRETRO_COMM_DIR)/file/file_path.c \ 68 | $(LIBRETRO_COMM_DIR)/file/file_path_io.c \ 69 | $(LIBRETRO_COMM_DIR)/streams/file_stream.c \ 70 | $(LIBRETRO_COMM_DIR)/string/stdstring.c \ 71 | $(LIBRETRO_COMM_DIR)/time/rtime.c \ 72 | $(LIBRETRO_COMM_DIR)/vfs/vfs_implementation.c 73 | OBJECTS_COND += \ 74 | $(LIBRETRO_COMM_DIR)/compat/compat_posix_string.o \ 75 | $(LIBRETRO_COMM_DIR)/compat/compat_strcasestr.o \ 76 | $(LIBRETRO_COMM_DIR)/compat/compat_snprintf.o \ 77 | $(LIBRETRO_COMM_DIR)/compat/compat_strl.o \ 78 | $(LIBRETRO_COMM_DIR)/compat/fopen_utf8.o \ 79 | $(LIBRETRO_COMM_DIR)/encodings/encoding_utf.o \ 80 | $(LIBRETRO_COMM_DIR)/file/file_path.o \ 81 | $(LIBRETRO_COMM_DIR)/file/file_path_io.o \ 82 | $(LIBRETRO_COMM_DIR)/streams/file_stream.o \ 83 | $(LIBRETRO_COMM_DIR)/string/stdstring.o \ 84 | $(LIBRETRO_COMM_DIR)/time/rtime.o \ 85 | $(LIBRETRO_COMM_DIR)/vfs/vfs_implementation.o 86 | endif 87 | 88 | ifeq ($(USE_THREADED_RENDERER), 1) 89 | ifneq ($(platform), vita) 90 | SOURCES_C += $(LIBRETRO_COMM_DIR)/rthreads/rthreads.c 91 | endif 92 | SOURCES_C += $(CORE_DIR)/src/thread.c 93 | endif 94 | OBJECTS_COND += $(LIBRETRO_COMM_DIR)/rthreads/rthreads.o 95 | OBJECTS_COND += $(CORE_DIR)/src/thread.o 96 | 97 | 98 | ifeq ($(HAVE_NEON), 1) 99 | SOURCES_ASM += $(CORE_DIR)/src/neon_memcpy.S 100 | endif 101 | OBJECTS_COND += $(CORE_DIR)/src/neon_memcpy.o 102 | -------------------------------------------------------------------------------- /build/Makefile.linux-portable_x86: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Linux 3 | # apt-get install g++-multilib libc6-dev-i386 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = linux-portable_x86 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = gcc 28 | CXX = g++ 29 | AS = as 30 | AR = ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .linux-portable_x86.o 36 | SOEXT = .linux-portable_x86.so 37 | LIBEXT = .linux-portable_x86.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 0 43 | platform = unix 44 | PLATDEFS = 45 | PLATCFLAGS = -m32 -fpic -fstrict-aliasing 46 | PLATCXXFLAGS = -m32 -fpic -fstrict-aliasing 47 | PLATLDFLAGS = -m32 -shared -lm -Wl,-version-script=$(BUILD_DIR)/link.T 48 | PLATLDXFLAGS = -m32 -shared -lm -Wl,-version-script=$(BUILD_DIR)/link.T 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/Makefile.linux-portable_x86_64: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Linux 3 | # 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = linux-portable_x86_64 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = gcc 28 | CXX = g++ 29 | AS = as 30 | AR = ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .linux-portable_x86_64.o 36 | SOEXT = .linux-portable_x86_64.so 37 | LIBEXT = .linux-portable_x86_64.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 0 43 | platform = unix 44 | PLATDEFS = 45 | PLATCFLAGS = -m64 -fpic -fstrict-aliasing 46 | PLATCXXFLAGS = -m64 -fpic -fstrict-aliasing 47 | PLATLDFLAGS = -m64 -shared -lm -Wl,-version-script=$(BUILD_DIR)/link.T 48 | PLATLDXFLAGS = -m64 -shared -lm -Wl,-version-script=$(BUILD_DIR)/link.T 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/Makefile.linux_x86: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Linux 3 | # apt-get install g++-multilib libc6-dev-i386 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = linux_x86 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = gcc 28 | CXX = g++ 29 | AS = as 30 | AR = ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .linux_x86.o 36 | SOEXT = .linux_x86.so 37 | LIBEXT = .linux_x86.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 0 43 | platform = unix 44 | PLATDEFS = 45 | PLATCFLAGS = -m32 -fpic -fstrict-aliasing 46 | PLATCXXFLAGS = -m32 -fpic -fstrict-aliasing 47 | PLATLDFLAGS = -m32 -shared -lm -Wl,-version-script=$(BUILD_DIR)/link.T -Wl,-no-undefined 48 | PLATLDXFLAGS = -m32 -shared -lm -Wl,-version-script=$(BUILD_DIR)/link.T -Wl,-no-undefined 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/Makefile.linux_x86_64: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Linux 3 | # 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = linux_x86_64 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = gcc 28 | CXX = g++ 29 | AS = as 30 | AR = ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .linux_x86_64.o 36 | SOEXT = .linux_x86_64.so 37 | LIBEXT = .linux_x86_64.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 0 43 | platform = unix 44 | PLATDEFS = 45 | PLATCFLAGS = -m64 -fpic -fstrict-aliasing 46 | PLATCXXFLAGS = -m64 -fpic -fstrict-aliasing 47 | PLATLDFLAGS = -m64 -shared -lm -Wl,-version-script=$(BUILD_DIR)/link.T -Wl,-no-undefined 48 | PLATLDXFLAGS = -m64 -shared -lm -Wl,-version-script=$(BUILD_DIR)/link.T -Wl,-no-undefined 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/Makefile.mingw_x86: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Windows 3 | # Install MSYS2 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = mingw_x86 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = gcc 28 | CXX = g++ 29 | AS = as 30 | AR = ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .mingw_x86.o 36 | SOEXT = .mingw_x86.dll 37 | LIBEXT = .mingw_x86.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 0 43 | platform = win 44 | PLATDEFS = 45 | PLATCFLAGS = -m32 -fpic -fstrict-aliasing 46 | PLATCXXFLAGS = -m32 -fpic -fstrict-aliasing 47 | PLATLDFLAGS = -m32 -shared -lm 48 | PLATLDXFLAGS = -m32 -shared -lm 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/Makefile.mingw_x86_64: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Windows 3 | # Install MSYS2 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = mingw_x86_64 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = gcc 28 | CXX = g++ 29 | AS = as 30 | AR = ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .mingw_x86_64.o 36 | SOEXT = .mingw_x86_64.dll 37 | LIBEXT = .mingw_x86_64.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 0 43 | platform = win 44 | PLATDEFS = 45 | PLATCFLAGS = -m64 -fpic -fstrict-aliasing 46 | PLATCXXFLAGS = -m64 -fpic -fstrict-aliasing 47 | PLATLDFLAGS = -m64 -shared -lm 48 | PLATLDXFLAGS = -m64 -shared -lm 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/Makefile.osx_x86: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Linux 3 | # Compile and install OSXCROSS: https://github.com/tpoechtrager/osxcross 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = osx_x86 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = $(OSXCROSS_ROOT_DIR)/target/bin/i386-apple-darwin13-cc 28 | CXX = $(OSXCROSS_ROOT_DIR)/target/bin/i386-apple-darwin13-c++ 29 | AS = $(OSXCROSS_ROOT_DIR)/target/bin/i386-apple-darwin13-as 30 | AR = $(OSXCROSS_ROOT_DIR)/target/bin/i386-apple-darwin13-ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .osx_x86.o 36 | SOEXT = .osx_x86.dylib 37 | LIBEXT = .osx_x86.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 0 43 | platform = osx 44 | PLATDEFS = 45 | PLATCFLAGS = -fstrict-aliasing 46 | PLATCXXFLAGS = -fstrict-aliasing 47 | PLATLDFLAGS = -shared -lm 48 | PLATLDXFLAGS = -shared -lm 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/Makefile.osx_x86_64: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Linux 3 | # Compile and install OSXCROSS: https://github.com/tpoechtrager/osxcross 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = osx_x86_64 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = $(OSXCROSS_ROOT_DIR)/target/bin/x86_64-apple-darwin13-cc 28 | CXX = $(OSXCROSS_ROOT_DIR)/target/bin/x86_64-apple-darwin13-c++ 29 | AS = $(OSXCROSS_ROOT_DIR)/target/bin/x86_64-apple-darwin13-as 30 | AR = $(OSXCROSS_ROOT_DIR)/target/bin/x86_64-apple-darwin13-ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .osx_x86_64.o 36 | SOEXT = .osx_x86_64.dylib 37 | LIBEXT = .osx_x86_64.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 0 43 | platform = osx 44 | PLATDEFS = 45 | PLATCFLAGS = -fpic -fstrict-aliasing 46 | PLATCXXFLAGS = -fpic -fstrict-aliasing 47 | PLATLDFLAGS = -shared -lm 48 | PLATLDXFLAGS = -shared -lm 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/Makefile.rules: -------------------------------------------------------------------------------- 1 | TARGET_NAME ?= vba_next 2 | 3 | ifeq ($(STATIC_LINKING), 1) 4 | TARGET = $(TARGET_NAME)_libretro_$(platform).a 5 | else 6 | TARGET = $(TARGET_NAME)_libretro$(SOEXT) 7 | endif 8 | 9 | DEFINES += 10 | CFLAGS += -Wall 11 | CXXFLAGS += -Wall 12 | LDFLAGS += 13 | OBJOUT = -o 14 | LINKOUT = -o 15 | 16 | OBJS = $(SOURCES_C:.c=$(OBJEXT)) $(SOURCES_CXX:.cpp=$(OBJEXT)) 17 | 18 | ifneq (,$(findstring msvc,$(platform))) 19 | OBJOUT = -Fo 20 | LINKOUT = -out: 21 | LD = link.exe 22 | else 23 | LD = $(CC) 24 | endif 25 | 26 | %$(OBJEXT): %.cpp 27 | $(CXX) -c $(OBJOUT)$@ $< $(INCFLAGS) $(CXXFLAGS) 28 | 29 | %$(OBJEXT): %.c 30 | $(CC) -c $(OBJOUT)$@ $< $(INCFLAGS) $(CFLAGS) 31 | 32 | %$(OBJEXT): %.S 33 | $(CC_AS) -c $(OBJOUT)$@ $< $(CFLAGS) 34 | 35 | all: $(TARGET) 36 | 37 | $(TARGET): $(HEADERS) $(OBJS) 38 | ifeq ($(STATIC_LINKING), 1) 39 | $(AR) rcs $@ $(OBJS) 40 | else 41 | $(LD) $(LINKOUT)$@ $(OBJS) $(LDFLAGS) 42 | endif 43 | 44 | clean-objs: 45 | rm -f $(OBJS) 46 | 47 | clean: clean-objs 48 | rm -f $(TARGET) 49 | 50 | .PHONY: clean-objs clean dist-clean FORCE 51 | -------------------------------------------------------------------------------- /build/Makefile.vita_arm: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Linux 3 | # Install vitasdk 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = vita_arm 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = $(VITASDK)/bin/arm-vita-eabi-gcc 28 | CXX = $(VITASDK)/bin/arm-vita-eabi-g++ 29 | AS = $(VITASDK)/bin/arm-vita-eabi-as 30 | AR = $(VITASDK)/bin/arm-vita-eabi-ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .vita_arm.o 36 | SOEXT = .vita_arm.so 37 | LIBEXT = .vita_arm.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 1 43 | platform = vita 44 | PLATDEFS = -DVITA 45 | PLATCFLAGS = -ftree-vectorize -mfloat-abi=hard -ffast-math -fsingle-precision-constant -funroll-loops -fno-short-enums 46 | PLATCXXFLAGS = -ftree-vectorize -mfloat-abi=hard -ffast-math -fsingle-precision-constant -funroll-loops -fno-short-enums 47 | PLATLDFLAGS = -shared -lm -mthumb -mcpu=cortex-a9 -mfloat-abi=hard 48 | PLATLDXFLAGS = -shared -lm -mthumb -mcpu=cortex-a9 -mfloat-abi=hard 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/Makefile.wii_ppc: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Linux 3 | # Install devkitppc 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = wii_ppc 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = $(DEVKITPPC_ROOT_DIR)/bin/powerpc-eabi-gcc 28 | CXX = $(DEVKITPPC_ROOT_DIR)/bin/powerpc-eabi-g++ 29 | AS = $(DEVKITPPC_ROOT_DIR)/bin/powerpc-eabi-as 30 | AR = $(DEVKITPPC_ROOT_DIR)/bin/powerpc-eabi-ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .wii_ppc.o 36 | SOEXT = .wii_ppc.so 37 | LIBEXT = .wii_ppc.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 1 43 | platform = wii 44 | PLATDEFS = -DGEKKO -DHW_RVL 45 | PLATCFLAGS = -m32 -fstrict-aliasing -mrvl -mcpu=750 -meabi -mhard-float 46 | PLATCXXFLAGS = -m32 -fstrict-aliasing -mrvl -mcpu=750 -meabi -mhard-float 47 | PLATLDFLAGS = -shared -lm 48 | PLATLDXFLAGS = -shared -lm 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/Makefile.windows_msvc2005_x86: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Linux 3 | # apt-get install mingw-w64 4 | 5 | ########################## 6 | # Checks the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | 20 | #################################### 21 | # Variable setup for Makefile.common 22 | 23 | CORE_DIR ?= .. 24 | BUILD_DIR ?= . 25 | INCLUDES = 26 | 27 | include $(BUILD_DIR)/Makefile.common 28 | 29 | ################# 30 | # Toolchain setup 31 | 32 | CC = cl.exe 33 | CXX = cl.exe 34 | 35 | PATH := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/bin"):$(PATH) 36 | PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../IDE") 37 | INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/include") 38 | LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS80COMNTOOLS)../../VC/lib") 39 | 40 | #WindowsSdkDir := $(shell reg query "HKLM\SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs\8F9E5EF3-A9A5-491B-A889-C58EFFECE8B3" -v "Install Dir" | grep -o '[A-Z]:\\.*') 41 | WindowsSdkDir := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*') 42 | WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*') 43 | 44 | WindowsSDKIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include") 45 | WindowsSDKAtlIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\atl") 46 | WindowsSDKCrtIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\crt") 47 | WindowsSDKGlIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\gl") 48 | WindowsSDKMfcIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\mfc") 49 | WindowsSDKLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib") 50 | 51 | export INCLUDE := $(INCLUDE);$(WindowsSDKIncludeDir);$(WindowsSDKAtlIncludeDir);$(WindowsSDKCrtIncludeDir);$(WindowsSDKGlIncludeDir);$(WindowsSDKMfcIncludeDir);libretro-common/include/compat/msvc 52 | export LIB := $(LIB);$(WindowsSDKLibDir) 53 | 54 | ############ 55 | # Extensions 56 | 57 | OBJEXT = .obj 58 | SOEXT = .dll 59 | 60 | ################ 61 | # Platform setup 62 | 63 | STATIC_LINKING = 0 64 | PLATDEFS = 65 | PLATCFLAGS = -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 -DWIN32 -D_WINDOWS -D_USRDLL -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -DFRONTEND_SUPPORTS_RGB565 -DGIT_VERSION=\"$(GIT_VERSION)\" 66 | PLATCXXFLAGS = $(PLATCFLAGS) 67 | #PLATLDFLAGS = -shared -lm 68 | #PLATLDXFLAGS = -shared -lm 69 | 70 | ################ 71 | # libretro setup 72 | 73 | RETRODEFS = -D__LIBRETRO__ -DHAVE_NO_LANGEXTRA -wd4710 -wd4711 -wd4127 -wd4204 -wd4242 -wd4244 -wd4820 -wd4214 -wd4100 -wd4738 -wd4706 -wd4668 -wd4245 -wd4255 -wd4389 -wd4305 -wd4113 74 | RETROCFLAGS = 75 | RETROCXXFLAGS = 76 | RETROLDFLAGS = 77 | RETROLDXFLAGS = 78 | 79 | ################# 80 | # Final variables 81 | 82 | DEFINES = $(PLATDEFS) $(COREDEFINES) $(RETRODEFS) 83 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 84 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 85 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 86 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 87 | 88 | ######## 89 | # Tuning 90 | 91 | ifeq ($(DEBUG),1) 92 | CFLAGS += -Od -Zi -D_DEBUG 93 | CXXFLAGS += -Od -Zi -D_DEBUG 94 | CFLAGS += -MTd 95 | CXXFLAGS += -MTd 96 | LDFLAGS += -DEBUG -DLL 97 | else 98 | CFLAGS += -O2 -DNDEBUG 99 | CXXFLAGS += -O2 -DNDEBUG 100 | CFLAGS += -MT 101 | CXXFLAGS += -MT 102 | LDFLAGS += -DLL 103 | endif 104 | 105 | ifneq ($(LOG_PERFORMANCE),) 106 | CFLAGS += -DLOG_PERFORMANCE 107 | CXXFLAGS += -DLOG_PERFORMANCE 108 | endif 109 | 110 | ############### 111 | # Include rules 112 | 113 | include $(BUILD_DIR)/Makefile.rules 114 | -------------------------------------------------------------------------------- /build/Makefile.windows_msvc2010_x64: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Windows (x64) 3 | # Download Visual Studio 2010 4 | 5 | ########################## 6 | # Checks the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | #################################### 20 | # Core-specific switches 21 | 22 | FRONTEND_SUPPORTS_RGB565=1 23 | 24 | #################################### 25 | # Variable setup for Makefile.common 26 | 27 | CORE_DIR ?= .. 28 | BUILD_DIR ?= . 29 | INCLUDES = 30 | 31 | include $(BUILD_DIR)/Makefile.common 32 | 33 | ################# 34 | # Github version 35 | 36 | GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)" 37 | ifneq ($(GIT_VERSION)," unknown") 38 | COREDEFINES += -DGIT_VERSION=\"$(GIT_VERSION)\" 39 | endif 40 | 41 | ################# 42 | # Toolchain setup 43 | 44 | CC = cl.exe 45 | CXX = cl.exe 46 | 47 | PATH := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/bin/amd64"):$(PATH) 48 | PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../IDE") 49 | INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/include") 50 | LIB := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/lib/amd64") 51 | 52 | WindowsSdkDir := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*') 53 | WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*') 54 | 55 | WindowsSDKIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include") 56 | WindowsSDKGlIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\gl") 57 | WindowsSDKLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\x64") 58 | 59 | INCFLAGS_PLATFORM = -I"$(WindowsSdkDirInc)" 60 | export INCLUDE := $(INCLUDE);$(WindowsSDKIncludeDir);$(WindowsSDKGlIncludeDir) 61 | export LIB := $(LIB);$(WindowsSDKLibDir) 62 | 63 | ############ 64 | # Extensions 65 | 66 | OBJEXT = .obj 67 | SOEXT = .dll 68 | 69 | ################ 70 | # Platform setup 71 | 72 | STATIC_LINKING = 0 73 | PLATDEFS = 74 | PLATCFLAGS = $(COREDEFINES) -DWIN32 -D_WINDOWS -D_USRDLL -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -DMSVC2010_EXPORTS 75 | PLATCXXFLAGS = $(PLATCFLAGS) 76 | #PLATLDFLAGS = -shared -lm 77 | #PLATLDXFLAGS = -shared -lm 78 | 79 | ################ 80 | # libretro setup 81 | 82 | RETRODEFS = -D__LIBRETRO__ 83 | RETROCFLAGS = 84 | RETROCXXFLAGS = 85 | RETROLDFLAGS = 86 | RETROLDXFLAGS = 87 | 88 | ################# 89 | # Final variables 90 | 91 | DEFINES = $(PLATDEFS) $(COREDEFINES) $(RETRODEFS) 92 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 93 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 94 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 95 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 96 | 97 | ######## 98 | # Tuning 99 | 100 | ifeq ($(DEBUG),1) 101 | CFLAGS += -Od -Zi -D_DEBUG 102 | CXXFLAGS += -Od -Zi -D_DEBUG 103 | CFLAGS += -MTd 104 | CXXFLAGS += -MTd 105 | LDFLAGS += -DEBUG -DLL 106 | else 107 | CFLAGS += -O2 -DNDEBUG 108 | CXXFLAGS += -O2 -DNDEBUG 109 | CFLAGS += -MT 110 | CXXFLAGS += -MT 111 | LDFLAGS += -DLL 112 | endif 113 | 114 | ifneq ($(LOG_PERFORMANCE),) 115 | CFLAGS += -DLOG_PERFORMANCE 116 | CXXFLAGS += -DLOG_PERFORMANCE 117 | endif 118 | 119 | ############### 120 | # Include rules 121 | 122 | include $(BUILD_DIR)/Makefile.rules 123 | 124 | print-%: 125 | @echo '$*=$($*)' 126 | -------------------------------------------------------------------------------- /build/Makefile.windows_msvc2010_x86: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Windows (x64) 3 | # Download Visual Studio 2010 4 | 5 | ########################## 6 | # Checks the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | #################################### 20 | # Core-specific switches 21 | 22 | FRONTEND_SUPPORTS_RGB565=1 23 | 24 | #################################### 25 | # Variable setup for Makefile.common 26 | 27 | CORE_DIR ?= .. 28 | BUILD_DIR ?= . 29 | INCLUDES = 30 | 31 | include $(BUILD_DIR)/Makefile.common 32 | 33 | ################# 34 | # Toolchain setup 35 | 36 | CC = cl.exe 37 | CXX = cl.exe 38 | 39 | PATH := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/bin"):$(PATH) 40 | PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../IDE") 41 | INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../../VC/include") 42 | LIB := $(shell IFS=$$'\n'; cygpath -w "$(VS100COMNTOOLS)../../VC/lib") 43 | 44 | WindowsSdkDir := $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*') 45 | WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*') 46 | 47 | WindowsSDKIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include") 48 | WindowsSDKGlIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\gl") 49 | WindowsSDKLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib") 50 | 51 | INCFLAGS_PLATFORM = -I"$(WindowsSdkDirInc)" 52 | export INCLUDE := $(INCLUDE);$(WindowsSDKIncludeDir);$(WindowsSDKGlIncludeDir) 53 | export LIB := $(LIB);$(WindowsSDKLibDir) 54 | 55 | ############ 56 | # Extensions 57 | 58 | OBJEXT = .obj 59 | SOEXT = .dll 60 | 61 | ################ 62 | # Platform setup 63 | 64 | STATIC_LINKING = 0 65 | PLATDEFS = 66 | PLATCFLAGS = $(COREDEFINES) -DWIN32 -D_WINDOWS -D_USRDLL -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -DMSVC2010_EXPORTS 67 | PLATCXXFLAGS = $(PLATCFLAGS) 68 | #PLATLDFLAGS = -shared -lm 69 | #PLATLDXFLAGS = -shared -lm 70 | 71 | ################ 72 | # libretro setup 73 | 74 | RETRODEFS = -D__LIBRETRO__ -wd4710 -wd4711 -wd4127 -wd4204 -wd4242 -wd4244 -wd4820 -wd4214 -wd4100 -wd4738 -wd4706 -wd4668 -wd4245 -wd4255 -wd4389 -wd4305 -wd4113 75 | RETROCFLAGS = 76 | RETROCXXFLAGS = 77 | RETROLDFLAGS = 78 | RETROLDXFLAGS = 79 | 80 | ################# 81 | # Final variables 82 | 83 | DEFINES = $(PLATDEFS) $(COREDEFINES) $(RETRODEFS) 84 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 85 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 86 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 87 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 88 | 89 | ######## 90 | # Tuning 91 | 92 | ifeq ($(DEBUG),1) 93 | CFLAGS += -Od -Zi -D_DEBUG 94 | CXXFLAGS += -Od -Zi -D_DEBUG 95 | CFLAGS += -MTd 96 | CXXFLAGS += -MTd 97 | LDFLAGS += -DEBUG -DLL 98 | else 99 | CFLAGS += -O2 -DNDEBUG 100 | CXXFLAGS += -O2 -DNDEBUG 101 | CFLAGS += -MT 102 | CXXFLAGS += -MT 103 | LDFLAGS += -DLL 104 | endif 105 | 106 | ifneq ($(LOG_PERFORMANCE),) 107 | CFLAGS += -DLOG_PERFORMANCE 108 | CXXFLAGS += -DLOG_PERFORMANCE 109 | endif 110 | 111 | ############### 112 | # Include rules 113 | 114 | include $(BUILD_DIR)/Makefile.rules 115 | -------------------------------------------------------------------------------- /build/Makefile.windows_x86: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Linux 3 | # apt-get install mingw-w64 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = windows_x86 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = i686-w64-mingw32-gcc 28 | CXX = i686-w64-mingw32-g++ 29 | AS = i686-w64-mingw32-as 30 | AR = i686-w64-mingw32-ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .windows_x86.o 36 | SOEXT = .windows_x86.dll 37 | LIBEXT = .windows_x86.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 0 43 | platform = win 44 | PLATDEFS = 45 | PLATCFLAGS = -fstrict-aliasing 46 | PLATCXXFLAGS = -fstrict-aliasing 47 | PLATLDFLAGS = -shared -lm 48 | PLATLDXFLAGS = -shared -lm 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/Makefile.windows_x86_64: -------------------------------------------------------------------------------- 1 | ############## 2 | # Works on hosts Linux 3 | # apt-get install mingw-w64 4 | 5 | ######################### 6 | # Check the host platform 7 | 8 | HOST_PLATFORM = linux 9 | ifeq ($(shell uname -a),) 10 | HOST_PLATFORM = windows 11 | else ifneq ($(findstring MINGW,$(shell uname -a)),) 12 | HOST_PLATFORM = windows 13 | else ifneq ($(findstring Darwin,$(shell uname -a)),) 14 | HOST_PLATFORM = darwin 15 | else ifneq ($(findstring win,$(shell uname -a)),) 16 | HOST_PLATFORM = windows 17 | endif 18 | 19 | ######################### 20 | # Set the target platform 21 | 22 | TARGET_PLATFORM = windows_x86_64 23 | 24 | ################# 25 | # Toolchain setup 26 | 27 | CC = x86_64-w64-mingw32-gcc 28 | CXX = x86_64-w64-mingw32-g++ 29 | AS = x86_64-w64-mingw32-as 30 | AR = x86_64-w64-mingw32-ar 31 | 32 | ############ 33 | # Extensions 34 | 35 | OBJEXT = .windows_x86_64.o 36 | SOEXT = .windows_x86_64.dll 37 | LIBEXT = .windows_x86_64.a 38 | 39 | ################ 40 | # Platform setup 41 | 42 | STATIC_LINKING = 0 43 | platform = win 44 | PLATDEFS = 45 | PLATCFLAGS = -fpic -fstrict-aliasing 46 | PLATCXXFLAGS = -fpic -fstrict-aliasing 47 | PLATLDFLAGS = -shared -lm 48 | PLATLDXFLAGS = -shared -lm 49 | 50 | ################ 51 | # libretro setup 52 | 53 | RETRODEFS = -D__LIBRETRO__ 54 | RETROCFLAGS = 55 | RETROCXXFLAGS = 56 | RETROLDFLAGS = 57 | RETROLDXFLAGS = 58 | 59 | ################# 60 | # Final variables 61 | 62 | DEFINES = $(PLATDEFS) $(RETRODEFS) 63 | CFLAGS = $(PLATCFLAGS) $(RETROCFLAGS) $(DEFINES) $(INCLUDES) 64 | CXXFLAGS = $(PLATCXXFLAGS) $(RETROCXXFLAGS) $(DEFINES) $(INCLUDES) 65 | LDFLAGS = $(PLATLDFLAGS) $(RETROLDFLAGS) 66 | LDXFLAGS = $(PLATLDXFLAGS) $(RETROLDXFLAGS) 67 | 68 | ######## 69 | # Tuning 70 | 71 | ifneq ($(DEBUG),) 72 | CFLAGS += -O0 -g 73 | CXXFLAGS += -O0 -g 74 | else 75 | CFLAGS += -O3 -DNDEBUG 76 | CXXFLAGS += -O3 -DNDEBUG 77 | endif 78 | 79 | ifneq ($(LOG_PERFORMANCE),) 80 | CFLAGS += -DLOG_PERFORMANCE 81 | CXXFLAGS += -DLOG_PERFORMANCE 82 | endif 83 | 84 | #################################### 85 | # Variable setup for Makefile.common 86 | 87 | CORE_DIR ?= .. 88 | BUILD_DIR ?= . 89 | INCLUDES = 90 | 91 | include $(BUILD_DIR)/Makefile.common 92 | 93 | ############### 94 | # Include rules 95 | 96 | include $(BUILD_DIR)/Makefile.rules 97 | -------------------------------------------------------------------------------- /build/link.T: -------------------------------------------------------------------------------- 1 | { 2 | global: retro_*; 3 | local: *; 4 | }; 5 | 6 | -------------------------------------------------------------------------------- /libretro-common/compat/compat_posix_string.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (compat_posix_string.c). 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 | #include 24 | 25 | #include 26 | 27 | #ifdef _WIN32 28 | 29 | #undef strcasecmp 30 | #undef strdup 31 | #undef isblank 32 | #undef strtok_r 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include 39 | 40 | int retro_strcasecmp__(const char *a, const char *b) 41 | { 42 | while (*a && *b) 43 | { 44 | int a_ = tolower(*a); 45 | int b_ = tolower(*b); 46 | 47 | if (a_ != b_) 48 | return a_ - b_; 49 | 50 | a++; 51 | b++; 52 | } 53 | 54 | return tolower(*a) - tolower(*b); 55 | } 56 | 57 | char *retro_strdup__(const char *orig) 58 | { 59 | size_t len = strlen(orig) + 1; 60 | char *ret = (char*)malloc(len); 61 | if (!ret) 62 | return NULL; 63 | 64 | strlcpy(ret, orig, len); 65 | return ret; 66 | } 67 | 68 | int retro_isblank__(int c) 69 | { 70 | return (c == ' ') || (c == '\t'); 71 | } 72 | 73 | char *retro_strtok_r__(char *str, const char *delim, char **saveptr) 74 | { 75 | char *first = NULL; 76 | if (!saveptr || !delim) 77 | return NULL; 78 | 79 | if (str) 80 | *saveptr = str; 81 | 82 | do 83 | { 84 | char *ptr = NULL; 85 | first = *saveptr; 86 | while (*first && strchr(delim, *first)) 87 | *first++ = '\0'; 88 | 89 | if (*first == '\0') 90 | return NULL; 91 | 92 | ptr = first + 1; 93 | 94 | while (*ptr && !strchr(delim, *ptr)) 95 | ptr++; 96 | 97 | *saveptr = ptr + (*ptr ? 1 : 0); 98 | *ptr = '\0'; 99 | } while (strlen(first) == 0); 100 | 101 | return first; 102 | } 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /libretro-common/compat/compat_snprintf.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (compat_snprintf.c). 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 | /* THIS FILE HAS NOT BEEN VALIDATED ON PLATFORMS BESIDES MSVC */ 24 | #ifdef _MSC_VER 25 | 26 | #include 27 | #include 28 | 29 | #if _MSC_VER < 1800 30 | #define va_copy(dst, src) ((dst) = (src)) 31 | #endif 32 | 33 | #if _MSC_VER < 1300 34 | #define _vscprintf c89_vscprintf_retro__ 35 | 36 | static int c89_vscprintf_retro__(const char *fmt, va_list pargs) 37 | { 38 | int retval; 39 | va_list argcopy; 40 | va_copy(argcopy, pargs); 41 | retval = vsnprintf(NULL, 0, fmt, argcopy); 42 | va_end(argcopy); 43 | return retval; 44 | } 45 | #endif 46 | 47 | /* http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010 */ 48 | 49 | int c99_vsnprintf_retro__(char *s, size_t len, const char *fmt, va_list ap) 50 | { 51 | int count = -1; 52 | 53 | if (len != 0) 54 | { 55 | #if (_MSC_VER <= 1310) 56 | count = _vsnprintf(s, len - 1, fmt, ap); 57 | #else 58 | count = _vsnprintf_s(s, len, len - 1, fmt, ap); 59 | #endif 60 | } 61 | 62 | if (count == -1) 63 | count = _vscprintf(fmt, ap); 64 | 65 | /* there was no room for a NULL, so truncate the last character */ 66 | if (count == len && len) 67 | s[len - 1] = '\0'; 68 | 69 | return count; 70 | } 71 | 72 | int c99_snprintf_retro__(char *s, size_t len, const char *fmt, ...) 73 | { 74 | int count; 75 | va_list ap; 76 | 77 | va_start(ap, fmt); 78 | count = c99_vsnprintf_retro__(s, len, fmt, ap); 79 | va_end(ap); 80 | 81 | return count; 82 | } 83 | #endif 84 | -------------------------------------------------------------------------------- /libretro-common/compat/compat_strcasestr.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (compat_strcasestr.c). 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 | #include 24 | 25 | #include 26 | 27 | /* Pretty much strncasecmp. */ 28 | static int casencmp(const char *a, const char *b, size_t n) 29 | { 30 | size_t i; 31 | 32 | for (i = 0; i < n; i++) 33 | { 34 | int a_lower = tolower(a[i]); 35 | int b_lower = tolower(b[i]); 36 | if (a_lower != b_lower) 37 | return a_lower - b_lower; 38 | } 39 | 40 | return 0; 41 | } 42 | 43 | char *strcasestr_retro__(const char *haystack, const char *needle) 44 | { 45 | size_t i, search_off; 46 | size_t hay_len = strlen(haystack); 47 | size_t needle_len = strlen(needle); 48 | 49 | if (needle_len > hay_len) 50 | return NULL; 51 | 52 | search_off = hay_len - needle_len; 53 | for (i = 0; i <= search_off; i++) 54 | if (!casencmp(haystack + i, needle, needle_len)) 55 | return (char*)haystack + i; 56 | 57 | return NULL; 58 | } 59 | -------------------------------------------------------------------------------- /libretro-common/compat/compat_strl.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (compat_strl.c). 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 | #include 24 | #include 25 | 26 | #include 27 | 28 | /* Implementation of strlcpy()/strlcat() based on OpenBSD. */ 29 | 30 | #ifndef __MACH__ 31 | 32 | size_t strlcpy(char *dest, const char *source, size_t size) 33 | { 34 | size_t src_size = 0; 35 | size_t n = size; 36 | 37 | if (n) 38 | while (--n && (*dest++ = *source++)) src_size++; 39 | 40 | if (!n) 41 | { 42 | if (size) *dest = '\0'; 43 | while (*source++) src_size++; 44 | } 45 | 46 | return src_size; 47 | } 48 | 49 | size_t strlcat(char *dest, const char *source, size_t size) 50 | { 51 | size_t len = strlen(dest); 52 | 53 | dest += len; 54 | 55 | if (len > size) 56 | size = 0; 57 | else 58 | size -= len; 59 | 60 | return len + strlcpy(dest, source, size); 61 | } 62 | #endif 63 | -------------------------------------------------------------------------------- /libretro-common/compat/fopen_utf8.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (fopen_utf8.c). 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 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0500 || defined(_XBOX) 29 | #ifndef LEGACY_WIN32 30 | #define LEGACY_WIN32 31 | #endif 32 | #endif 33 | 34 | #ifdef _WIN32 35 | #undef fopen 36 | 37 | void *fopen_utf8(const char * filename, const char * mode) 38 | { 39 | #if defined(LEGACY_WIN32) 40 | char * filename_local = utf8_to_local_string_alloc(filename); 41 | if (filename_local) 42 | { 43 | FILE *ret = fopen(filename_local, mode); 44 | free(filename_local); 45 | return ret; 46 | } 47 | #else 48 | wchar_t * filename_w = utf8_to_utf16_string_alloc(filename); 49 | if (filename_w) 50 | { 51 | FILE *ret = NULL; 52 | wchar_t *mode_w = utf8_to_utf16_string_alloc(mode); 53 | if (mode_w) 54 | { 55 | ret = _wfopen(filename_w, mode_w); 56 | free(mode_w); 57 | } 58 | free(filename_w); 59 | return ret; 60 | } 61 | #endif 62 | return NULL; 63 | } 64 | #endif 65 | -------------------------------------------------------------------------------- /libretro-common/file/file_path_io.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (file_path_io.c). 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 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #define VFS_FRONTEND 37 | #include 38 | 39 | #ifdef _WIN32 40 | #include 41 | #else 42 | #include /* stat() is defined here */ 43 | #endif 44 | 45 | /* TODO/FIXME - globals */ 46 | static retro_vfs_stat_t path_stat_cb = retro_vfs_stat_impl; 47 | static retro_vfs_mkdir_t path_mkdir_cb = retro_vfs_mkdir_impl; 48 | 49 | void path_vfs_init(const struct retro_vfs_interface_info* vfs_info) 50 | { 51 | const struct retro_vfs_interface* 52 | vfs_iface = vfs_info->iface; 53 | 54 | path_stat_cb = retro_vfs_stat_impl; 55 | path_mkdir_cb = retro_vfs_mkdir_impl; 56 | 57 | if (vfs_info->required_interface_version < PATH_REQUIRED_VFS_VERSION || !vfs_iface) 58 | return; 59 | 60 | path_stat_cb = vfs_iface->stat; 61 | path_mkdir_cb = vfs_iface->mkdir; 62 | } 63 | 64 | int path_stat(const char *path) 65 | { 66 | return path_stat_cb(path, NULL); 67 | } 68 | 69 | /** 70 | * path_is_directory: 71 | * @path : path 72 | * 73 | * Checks if path is a directory. 74 | * 75 | * @return true if path is a directory, otherwise false. 76 | */ 77 | bool path_is_directory(const char *path) 78 | { 79 | return (path_stat_cb(path, NULL) & RETRO_VFS_STAT_IS_DIRECTORY) != 0; 80 | } 81 | 82 | bool path_is_character_special(const char *path) 83 | { 84 | return (path_stat_cb(path, NULL) & RETRO_VFS_STAT_IS_CHARACTER_SPECIAL) != 0; 85 | } 86 | 87 | bool path_is_valid(const char *path) 88 | { 89 | return (path_stat_cb(path, NULL) & RETRO_VFS_STAT_IS_VALID) != 0; 90 | } 91 | 92 | int32_t path_get_size(const char *path) 93 | { 94 | int32_t filesize = 0; 95 | if (path_stat_cb(path, &filesize) != 0) 96 | return filesize; 97 | 98 | return -1; 99 | } 100 | 101 | /** 102 | * path_mkdir: 103 | * @dir : directory 104 | * 105 | * Create directory on filesystem. 106 | * 107 | * Recursive function. 108 | * 109 | * @return true if directory could be created, otherwise false. 110 | **/ 111 | bool path_mkdir(const char *dir) 112 | { 113 | bool norecurse = false; 114 | char *basedir = NULL; 115 | 116 | if (!(dir && *dir)) 117 | return false; 118 | 119 | /* Use heap. Real chance of stack 120 | * overflow if we recurse too hard. */ 121 | if (!(basedir = strdup(dir))) 122 | return false; 123 | 124 | path_parent_dir(basedir, strlen(basedir)); 125 | 126 | if (!*basedir || !strcmp(basedir, dir)) 127 | { 128 | free(basedir); 129 | return false; 130 | } 131 | 132 | if ( path_is_directory(basedir) 133 | || path_mkdir(basedir)) 134 | norecurse = true; 135 | 136 | free(basedir); 137 | 138 | if (norecurse) 139 | { 140 | int ret = path_mkdir_cb(dir); 141 | 142 | /* Don't treat this as an error. */ 143 | if (ret == -2 && path_is_directory(dir)) 144 | return true; 145 | else if (ret == 0) 146 | return true; 147 | } 148 | return false; 149 | } 150 | -------------------------------------------------------------------------------- /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/apple_compat.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (apple_compat.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 __APPLE_COMPAT_H 24 | #define __APPLE_COMPAT_H 25 | 26 | #ifdef __APPLE__ 27 | #include 28 | #endif 29 | 30 | #ifdef __OBJC__ 31 | 32 | #if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4) 33 | typedef int NSInteger; 34 | typedef unsigned NSUInteger; 35 | typedef float CGFloat; 36 | #endif 37 | 38 | #ifndef __has_feature 39 | /* Compatibility with non-Clang compilers. */ 40 | #define __has_feature(x) 0 41 | #endif 42 | 43 | #ifndef CF_RETURNS_RETAINED 44 | #if __has_feature(attribute_cf_returns_retained) 45 | #define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) 46 | #else 47 | #define CF_RETURNS_RETAINED 48 | #endif 49 | #endif 50 | 51 | #ifndef NS_INLINE 52 | #define NS_INLINE inline 53 | #endif 54 | 55 | NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetainCompat(id X) 56 | { 57 | #if __has_feature(objc_arc) 58 | return (__bridge_retained CFTypeRef)X; 59 | #else 60 | return X; 61 | #endif 62 | } 63 | 64 | #endif 65 | 66 | #ifdef IOS 67 | #ifndef __IPHONE_5_0 68 | #warning "This project uses features only available in iOS SDK 5.0 and later." 69 | #endif 70 | 71 | #ifdef __OBJC__ 72 | #import 73 | #import 74 | #import 75 | #endif 76 | 77 | #else 78 | 79 | #ifdef __OBJC__ 80 | #include 81 | #endif 82 | #endif 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /libretro-common/include/compat/fnmatch.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (fnmatch.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_FNMATCH_H__ 24 | #define __LIBRETRO_SDK_COMPAT_FNMATCH_H__ 25 | 26 | #define FNM_NOMATCH 1 27 | 28 | int rl_fnmatch(const char *pattern, const char *string, int flags); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /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/getopt.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (getopt.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_GETOPT_H 24 | #define __LIBRETRO_SDK_COMPAT_GETOPT_H 25 | 26 | #if defined(RARCH_INTERNAL) && defined(HAVE_CONFIG_H) 27 | #include "../../../config.h" 28 | #endif 29 | 30 | /* Custom implementation of the GNU getopt_long for portability. 31 | * Not designed to be fully compatible, but compatible with 32 | * the features RetroArch uses. */ 33 | 34 | #ifdef HAVE_GETOPT_LONG 35 | #include 36 | #else 37 | /* Avoid possible naming collisions during link since we 38 | * prefer to use the actual name. */ 39 | #define getopt_long(argc, argv, optstring, longopts, longindex) __getopt_long_retro(argc, argv, optstring, longopts, longindex) 40 | 41 | #include 42 | 43 | RETRO_BEGIN_DECLS 44 | 45 | struct option 46 | { 47 | const char *name; 48 | int has_arg; 49 | int *flag; 50 | int val; 51 | }; 52 | 53 | /* argv[] is declared with char * const argv[] in GNU, 54 | * but this makes no sense, as non-POSIX getopt_long 55 | * mutates argv (non-opts are moved to the end). */ 56 | int getopt_long(int argc, char *argv[], 57 | const char *optstring, const struct option *longopts, int *longindex); 58 | extern char *optarg; 59 | extern int optind, opterr, optopt; 60 | 61 | RETRO_END_DECLS 62 | 63 | /* If these are variously #defined, then we have bigger problems */ 64 | #ifndef no_argument 65 | #define no_argument 0 66 | #define required_argument 1 67 | #define optional_argument 2 68 | #endif 69 | 70 | /* HAVE_GETOPT_LONG */ 71 | #endif 72 | 73 | /* pragma once */ 74 | #endif 75 | -------------------------------------------------------------------------------- /libretro-common/include/compat/ifaddrs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1995, 1999 3 | * Berkeley Software Design, Inc. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND 12 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 13 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 14 | * ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE 15 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 16 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 17 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 18 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 19 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 20 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 21 | * SUCH DAMAGE. 22 | * 23 | * BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp 24 | */ 25 | 26 | #ifndef _IFADDRS_H_ 27 | #define _IFADDRS_H_ 28 | 29 | struct ifaddrs 30 | { 31 | struct ifaddrs *ifa_next; 32 | char *ifa_name; 33 | unsigned int ifa_flags; 34 | struct sockaddr *ifa_addr; 35 | struct sockaddr *ifa_netmask; 36 | struct sockaddr *ifa_dstaddr; 37 | void *ifa_data; 38 | }; 39 | 40 | /* 41 | * This may have been defined in . Note that if is 42 | * to be included it must be included before this header file. 43 | */ 44 | #ifndef ifa_broadaddr 45 | #define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ 46 | #endif 47 | 48 | #include 49 | 50 | extern int getifaddrs(struct ifaddrs **ifap); 51 | extern void freeifaddrs(struct ifaddrs *ifa); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /libretro-common/include/compat/intrinsics.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (intrinsics.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_INTRINSICS_H 24 | #define __LIBRETRO_SDK_COMPAT_INTRINSICS_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | 33 | #if defined(_MSC_VER) && !defined(_XBOX) 34 | #if (_MSC_VER > 1310) 35 | #include 36 | #endif 37 | #endif 38 | 39 | RETRO_BEGIN_DECLS 40 | 41 | /* Count Leading Zero, unsigned 16bit input value */ 42 | static INLINE unsigned compat_clz_u16(uint16_t val) 43 | { 44 | #if defined(__GNUC__) 45 | return __builtin_clz(val << 16 | 0x8000); 46 | #else 47 | unsigned ret = 0; 48 | 49 | while(!(val & 0x8000) && ret < 16) 50 | { 51 | val <<= 1; 52 | ret++; 53 | } 54 | 55 | return ret; 56 | #endif 57 | } 58 | 59 | /* Count Trailing Zero */ 60 | static INLINE int compat_ctz(unsigned x) 61 | { 62 | #if defined(__GNUC__) && !defined(RARCH_CONSOLE) 63 | return __builtin_ctz(x); 64 | #elif _MSC_VER >= 1400 && !defined(_XBOX) && !defined(__WINRT__) 65 | unsigned long r = 0; 66 | _BitScanForward((unsigned long*)&r, x); 67 | return (int)r; 68 | #else 69 | int count = 0; 70 | if (!(x & 0xffff)) 71 | { 72 | x >>= 16; 73 | count |= 16; 74 | } 75 | if (!(x & 0xff)) 76 | { 77 | x >>= 8; 78 | count |= 8; 79 | } 80 | if (!(x & 0xf)) 81 | { 82 | x >>= 4; 83 | count |= 4; 84 | } 85 | if (!(x & 0x3)) 86 | { 87 | x >>= 2; 88 | count |= 2; 89 | } 90 | if (!(x & 0x1)) 91 | count |= 1; 92 | 93 | return count; 94 | #endif 95 | } 96 | 97 | RETRO_END_DECLS 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /libretro-common/include/compat/msvc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (msvc.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_MSVC_H 24 | #define __LIBRETRO_SDK_COMPAT_MSVC_H 25 | 26 | #ifdef _MSC_VER 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | /* Pre-MSVC 2015 compilers don't implement snprintf, vsnprintf in a cross-platform manner. */ 33 | #if _MSC_VER < 1900 34 | #include 35 | #include 36 | #include 37 | 38 | #ifndef snprintf 39 | #define snprintf c99_snprintf_retro__ 40 | #endif 41 | int c99_snprintf_retro__(char *outBuf, size_t size, const char *format, ...); 42 | 43 | #ifndef vsnprintf 44 | #define vsnprintf c99_vsnprintf_retro__ 45 | #endif 46 | int c99_vsnprintf_retro__(char *outBuf, size_t size, const char *format, va_list ap); 47 | #endif 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #undef UNICODE /* Do not bother with UNICODE at this time. */ 54 | #include 55 | #include 56 | 57 | #define _USE_MATH_DEFINES 58 | #include 59 | 60 | /* Python headers defines ssize_t and sets HAVE_SSIZE_T. 61 | * Cannot duplicate these efforts. 62 | */ 63 | #ifndef HAVE_SSIZE_T 64 | #if defined(_WIN64) 65 | typedef __int64 ssize_t; 66 | #elif defined(_WIN32) 67 | typedef int ssize_t; 68 | #endif 69 | #endif 70 | 71 | #define mkdir(dirname, unused) _mkdir(dirname) 72 | #define strtoull _strtoui64 73 | #undef strcasecmp 74 | #define strcasecmp _stricmp 75 | #undef strncasecmp 76 | #define strncasecmp _strnicmp 77 | 78 | /* Disable some of the annoying warnings. */ 79 | #pragma warning(disable : 4800) 80 | #pragma warning(disable : 4805) 81 | #pragma warning(disable : 4244) 82 | #pragma warning(disable : 4305) 83 | #pragma warning(disable : 4146) 84 | #pragma warning(disable : 4267) 85 | #pragma warning(disable : 4723) 86 | #pragma warning(disable : 4996) 87 | 88 | /* roundf and va_copy is available since MSVC 2013 */ 89 | #if _MSC_VER < 1800 90 | #define roundf(in) (in >= 0.0f ? floorf(in + 0.5f) : ceilf(in - 0.5f)) 91 | #define va_copy(x, y) ((x) = (y)) 92 | #endif 93 | 94 | #if _MSC_VER <= 1310 95 | #ifndef __cplusplus 96 | /* VC6 math.h doesn't define some functions when in C mode. 97 | * Trying to define a prototype gives "undefined reference". 98 | * But providing an implementation then gives "function already has body". 99 | * So the equivalent of the implementations from math.h are used as 100 | * defines here instead, and it seems to work. 101 | */ 102 | #define cosf(x) ((float)cos((double)x)) 103 | #define powf(x, y) ((float)pow((double)x, (double)y)) 104 | #define sinf(x) ((float)sin((double)x)) 105 | #define ceilf(x) ((float)ceil((double)x)) 106 | #define floorf(x) ((float)floor((double)x)) 107 | #define sqrtf(x) ((float)sqrt((double)x)) 108 | #define fabsf(x) ((float)fabs((double)(x))) 109 | #endif 110 | 111 | #ifndef _strtoui64 112 | #define _strtoui64(x, y, z) (_atoi64(x)) 113 | #endif 114 | 115 | #endif 116 | 117 | #ifndef PATH_MAX 118 | #define PATH_MAX _MAX_PATH 119 | #endif 120 | 121 | #ifndef SIZE_MAX 122 | #define SIZE_MAX _UI32_MAX 123 | #endif 124 | 125 | #endif 126 | #endif 127 | -------------------------------------------------------------------------------- /libretro-common/include/compat/posix_string.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (posix_string.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_POSIX_STRING_H 24 | #define __LIBRETRO_SDK_COMPAT_POSIX_STRING_H 25 | 26 | #include 27 | 28 | #ifdef _MSC_VER 29 | #include 30 | #endif 31 | 32 | RETRO_BEGIN_DECLS 33 | 34 | #ifdef _WIN32 35 | #undef strtok_r 36 | #define strtok_r(str, delim, saveptr) retro_strtok_r__(str, delim, saveptr) 37 | 38 | char *strtok_r(char *str, const char *delim, char **saveptr); 39 | #endif 40 | 41 | #ifdef _MSC_VER 42 | #undef strcasecmp 43 | #undef strdup 44 | #define strcasecmp(a, b) retro_strcasecmp__(a, b) 45 | #define strdup(orig) retro_strdup__(orig) 46 | int strcasecmp(const char *a, const char *b); 47 | char *strdup(const char *orig); 48 | 49 | /* isblank is available since MSVC 2013 */ 50 | #if _MSC_VER < 1800 51 | #undef isblank 52 | #define isblank(c) retro_isblank__(c) 53 | int isblank(int c); 54 | #endif 55 | 56 | #endif 57 | 58 | RETRO_END_DECLS 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /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/compat/strl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (strl.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_STRL_H 24 | #define __LIBRETRO_SDK_COMPAT_STRL_H 25 | 26 | #include 27 | #include 28 | 29 | #if defined(RARCH_INTERNAL) && defined(HAVE_CONFIG_H) 30 | #include "../../../config.h" 31 | #endif 32 | 33 | #include 34 | 35 | RETRO_BEGIN_DECLS 36 | 37 | #ifdef __MACH__ 38 | #ifndef HAVE_STRL 39 | #define HAVE_STRL 40 | #endif 41 | #endif 42 | 43 | #ifndef HAVE_STRL 44 | /* Avoid possible naming collisions during link since 45 | * we prefer to use the actual name. */ 46 | #define strlcpy(dst, src, size) strlcpy_retro__(dst, src, size) 47 | 48 | #define strlcat(dst, src, size) strlcat_retro__(dst, src, size) 49 | 50 | size_t strlcpy(char *dest, const char *source, size_t size); 51 | size_t strlcat(char *dest, const char *source, size_t size); 52 | 53 | #endif 54 | 55 | char *strldup(const char *s, size_t n); 56 | 57 | RETRO_END_DECLS 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /libretro-common/include/encodings/utf.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (utf.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_UTF_H 24 | #define _LIBRETRO_ENCODINGS_UTF_H 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | #include 32 | 33 | RETRO_BEGIN_DECLS 34 | 35 | enum CodePage 36 | { 37 | CODEPAGE_LOCAL = 0, /* CP_ACP */ 38 | CODEPAGE_UTF8 = 65001 /* CP_UTF8 */ 39 | }; 40 | 41 | /** 42 | * utf8_conv_utf32: 43 | * 44 | * Simple implementation. Assumes the sequence is 45 | * properly synchronized and terminated. 46 | **/ 47 | size_t utf8_conv_utf32(uint32_t *out, size_t out_chars, 48 | const char *in, size_t in_size); 49 | 50 | /** 51 | * utf16_conv_utf8: 52 | * 53 | * Leaf function. 54 | **/ 55 | bool utf16_conv_utf8(uint8_t *out, size_t *out_chars, 56 | const uint16_t *in, size_t in_size); 57 | 58 | /** 59 | * utf8len: 60 | * 61 | * Leaf function. 62 | **/ 63 | size_t utf8len(const char *string); 64 | 65 | /** 66 | * utf8cpy: 67 | * 68 | * Acts mostly like strlcpy. 69 | * 70 | * Copies the given number of UTF-8 characters, 71 | * but at most @d_len bytes. 72 | * 73 | * Always NULL terminates. Does not copy half a character. 74 | * @s is assumed valid UTF-8. 75 | * Use only if @chars is considerably less than @d_len. 76 | * 77 | * Hidden non-leaf function cost: 78 | * - Calls memcpy 79 | * 80 | * @return Number of bytes. 81 | **/ 82 | size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars); 83 | 84 | /** 85 | * utf8skip: 86 | * 87 | * Leaf function 88 | **/ 89 | const char *utf8skip(const char *str, size_t chars); 90 | 91 | /** 92 | * utf8_walk: 93 | * 94 | * Does not validate the input. 95 | * 96 | * Leaf function. 97 | * 98 | * @return Returns garbage if it's not UTF-8. 99 | **/ 100 | uint32_t utf8_walk(const char **string); 101 | 102 | /** 103 | * utf16_to_char_string: 104 | **/ 105 | bool utf16_to_char_string(const uint16_t *in, char *s, size_t len); 106 | 107 | /** 108 | * utf8_to_local_string_alloc: 109 | * 110 | * @return Returned pointer MUST be freed by the caller if non-NULL. 111 | **/ 112 | char *utf8_to_local_string_alloc(const char *str); 113 | 114 | /** 115 | * local_to_utf8_string_alloc: 116 | * 117 | * @return Returned pointer MUST be freed by the caller if non-NULL. 118 | **/ 119 | char *local_to_utf8_string_alloc(const char *str); 120 | 121 | /** 122 | * utf8_to_utf16_string_alloc: 123 | * 124 | * @return Returned pointer MUST be freed by the caller if non-NULL. 125 | **/ 126 | wchar_t *utf8_to_utf16_string_alloc(const char *str); 127 | 128 | /** 129 | * utf16_to_utf8_string_alloc: 130 | * 131 | * @return Returned pointer MUST be freed by the caller if non-NULL. 132 | **/ 133 | char *utf16_to_utf8_string_alloc(const wchar_t *str); 134 | 135 | RETRO_END_DECLS 136 | 137 | #endif 138 | -------------------------------------------------------------------------------- /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_common_api.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (retro_common_api.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_API_H 24 | #define _LIBRETRO_COMMON_RETRO_COMMON_API_H 25 | 26 | /* 27 | This file is designed to normalize the libretro-common compiling environment 28 | for public API headers. This should be leaner than a normal compiling environment, 29 | since it gets #included into other project's sources. 30 | */ 31 | 32 | /* ------------------------------------ */ 33 | 34 | /* 35 | Ordinarily we want to put #ifdef __cplusplus extern "C" in C library 36 | headers to enable them to get used by c++ sources. 37 | However, we want to support building this library as C++ as well, so a 38 | special technique is called for. 39 | */ 40 | 41 | #define RETRO_BEGIN_DECLS 42 | #define RETRO_END_DECLS 43 | 44 | #ifdef __cplusplus 45 | 46 | #ifdef CXX_BUILD 47 | /* build wants everything to be built as c++, so no extern "C" */ 48 | #else 49 | #undef RETRO_BEGIN_DECLS 50 | #undef RETRO_END_DECLS 51 | #define RETRO_BEGIN_DECLS extern "C" { 52 | #define RETRO_END_DECLS } 53 | #endif 54 | 55 | #else 56 | 57 | /* header is included by a C source file, so no extern "C" */ 58 | 59 | #endif 60 | 61 | /* 62 | IMO, this non-standard ssize_t should not be used. 63 | However, it's a good example of how to handle something like this. 64 | */ 65 | #ifdef _MSC_VER 66 | #ifndef HAVE_SSIZE_T 67 | #define HAVE_SSIZE_T 68 | #if defined(_WIN64) 69 | typedef __int64 ssize_t; 70 | #elif defined(_WIN32) 71 | typedef int ssize_t; 72 | #endif 73 | #endif 74 | #elif defined(__MACH__) 75 | #include 76 | #endif 77 | 78 | #ifdef _MSC_VER 79 | #if _MSC_VER >= 1800 80 | #include 81 | #else 82 | #ifndef PRId64 83 | #define PRId64 "I64d" 84 | #define PRIu64 "I64u" 85 | #define PRIuPTR "Iu" 86 | #endif 87 | #endif 88 | #else 89 | /* C++11 says this one isn't needed, but apparently (some versions of) mingw require it anyways */ 90 | /* https://stackoverflow.com/questions/8132399/how-to-printf-uint64-t-fails-with-spurious-trailing-in-format */ 91 | /* https://github.com/libretro/RetroArch/issues/6009 */ 92 | #ifndef __STDC_FORMAT_MACROS 93 | #define __STDC_FORMAT_MACROS 1 94 | #endif 95 | #include 96 | #endif 97 | #ifndef PRId64 98 | #error "inttypes.h is being screwy" 99 | #endif 100 | #define STRING_REP_INT64 "%" PRId64 101 | #define STRING_REP_UINT64 "%" PRIu64 102 | #define STRING_REP_USIZE "%" PRIuPTR 103 | 104 | /* Wrap a declaration in RETRO_DEPRECATED() to produce a compiler warning when 105 | it's used. This is intended for developer machines, so it won't work on ancient 106 | or obscure compilers */ 107 | #if defined(_MSC_VER) 108 | #if _MSC_VER >= 1400 /* Visual C 2005 or later */ 109 | #define RETRO_DEPRECATED(decl) __declspec(deprecated) decl 110 | #endif 111 | #elif defined(__GNUC__) 112 | #if __GNUC__ >= 3 /* GCC 3 or later */ 113 | #define RETRO_DEPRECATED(decl) decl __attribute__((deprecated)) 114 | #endif 115 | #elif defined(__clang__) 116 | #if __clang_major__ >= 3 /* clang 3 or later */ 117 | #define RETRO_DEPRECATED(decl) decl __attribute__((deprecated)) 118 | #endif 119 | #endif 120 | #ifndef RETRO_DEPRECATED /* Unsupported compilers */ 121 | #define RETRO_DEPRECATED(decl) decl 122 | #endif 123 | 124 | /* 125 | I would like to see retro_inline.h moved in here; possibly boolean too. 126 | 127 | rationale: these are used in public APIs, and it is easier to find problems 128 | and write code that works the first time portably when theyre included uniformly 129 | than to do the analysis from scratch each time you think you need it, for each feature. 130 | 131 | Moreover it helps force you to make hard decisions: if you EVER bring in boolean.h, 132 | then you should pay the price everywhere, so you can see how much grief it will cause. 133 | 134 | Of course, another school of thought is that you should do as little damage as possible 135 | in as few places as possible... 136 | */ 137 | 138 | /* _LIBRETRO_COMMON_RETRO_COMMON_API_H */ 139 | #endif 140 | -------------------------------------------------------------------------------- /libretro-common/include/retro_environment.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (retro_environment.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_ENVIRONMENT_H 24 | #define __LIBRETRO_SDK_ENVIRONMENT_H 25 | 26 | /* 27 | This file is designed to create a normalized environment for compiling 28 | libretro-common's private implementations, or any other sources which might 29 | enjoy use of it's environment (RetroArch for instance). 30 | This should be an elaborately crafted environment so that sources don't 31 | need to be full of platform-specific workarounds. 32 | */ 33 | 34 | #if defined (__cplusplus) 35 | #if 0 36 | printf("This is C++, version %d.\n", __cplusplus); 37 | #endif 38 | /* The expected values would be 39 | * 199711L, for ISO/IEC 14882:1998 or 14882:2003 40 | */ 41 | 42 | #elif defined(__STDC__) 43 | /* This is standard C. */ 44 | 45 | #if (__STDC__ == 1) 46 | /* The implementation is ISO-conforming. */ 47 | #define __STDC_ISO__ 48 | #else 49 | /* The implementation is not ISO-conforming. */ 50 | #endif 51 | 52 | #if defined(__STDC_VERSION__) 53 | #if (__STDC_VERSION__ >= 201112L) 54 | /* This is C11. */ 55 | #define __STDC_C11__ 56 | #elif (__STDC_VERSION__ >= 199901L) 57 | /* This is C99. */ 58 | #define __STDC_C99__ 59 | #elif (__STDC_VERSION__ >= 199409L) 60 | /* This is C89 with amendment 1. */ 61 | #define __STDC_C89__ 62 | #define __STDC_C89_AMENDMENT_1__ 63 | #else 64 | /* This is C89 without amendment 1. */ 65 | #define __STDC_C89__ 66 | #endif 67 | #else /* !defined(__STDC_VERSION__) */ 68 | /* This is C89. __STDC_VERSION__ is not defined. */ 69 | #define __STDC_C89__ 70 | #endif 71 | 72 | #else /* !defined(__STDC__) */ 73 | /* This is not standard C. __STDC__ is not defined. */ 74 | #endif 75 | 76 | #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) 77 | /* Try to find out if we're compiling for WinRT or non-WinRT */ 78 | #if defined(_MSC_VER) && defined(__has_include) 79 | #if __has_include() 80 | #define HAVE_WINAPIFAMILY_H 1 81 | #else 82 | #define HAVE_WINAPIFAMILY_H 0 83 | #endif 84 | 85 | /* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */ 86 | #elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_) /* _MSC_VER == 1700 for Visual Studio 2012 */ 87 | #define HAVE_WINAPIFAMILY_H 1 88 | #else 89 | #define HAVE_WINAPIFAMILY_H 0 90 | #endif 91 | 92 | #if HAVE_WINAPIFAMILY_H 93 | #include 94 | #define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)) 95 | #else 96 | #define WINAPI_FAMILY_WINRT 0 97 | #endif /* HAVE_WINAPIFAMILY_H */ 98 | 99 | #if WINAPI_FAMILY_WINRT 100 | #undef __WINRT__ 101 | #define __WINRT__ 1 102 | #endif 103 | 104 | /* MSVC obviously has to have some non-standard constants... */ 105 | #if _M_IX86_FP == 1 106 | #define __SSE__ 1 107 | #elif _M_IX86_FP == 2 || (defined(_M_AMD64) || defined(_M_X64)) 108 | #define __SSE__ 1 109 | #define __SSE2__ 1 110 | #endif 111 | 112 | #endif 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /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/rthreads/rsemaphore.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2015 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (rsemaphore.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_SEMAPHORE_H 24 | #define __LIBRETRO_SDK_SEMAPHORE_H 25 | 26 | #include 27 | 28 | RETRO_BEGIN_DECLS 29 | 30 | typedef struct ssem ssem_t; 31 | 32 | /** 33 | * ssem_create: 34 | * @value : initial value for the semaphore 35 | * 36 | * Create a new semaphore. 37 | * 38 | * Returns: pointer to new semaphore if successful, otherwise NULL. 39 | */ 40 | ssem_t *ssem_new(int value); 41 | 42 | void ssem_free(ssem_t *semaphore); 43 | 44 | int ssem_get(ssem_t *semaphore); 45 | 46 | void ssem_wait(ssem_t *semaphore); 47 | 48 | void ssem_signal(ssem_t *semaphore); 49 | 50 | RETRO_END_DECLS 51 | 52 | #endif /* __LIBRETRO_SDK_SEMAPHORE_H */ 53 | -------------------------------------------------------------------------------- /libretro-common/include/streams/file_stream.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (file_stream.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_FILE_STREAM_H 24 | #define __LIBRETRO_SDK_FILE_STREAM_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include 39 | #include 40 | 41 | #define FILESTREAM_REQUIRED_VFS_VERSION 2 42 | 43 | RETRO_BEGIN_DECLS 44 | 45 | typedef struct RFILE RFILE; 46 | 47 | #define FILESTREAM_REQUIRED_VFS_VERSION 2 48 | 49 | void filestream_vfs_init(const struct retro_vfs_interface_info* vfs_info); 50 | 51 | int64_t filestream_get_size(RFILE *stream); 52 | 53 | int64_t filestream_truncate(RFILE *stream, int64_t length); 54 | 55 | /** 56 | * filestream_open: 57 | * @path : path to file 58 | * @mode : file mode to use when opening (read/write) 59 | * @bufsize : optional buffer size (-1 or 0 to use default) 60 | * 61 | * Opens a file for reading or writing, depending on the requested mode. 62 | * @return A pointer to an RFILE if opened successfully, otherwise NULL. 63 | **/ 64 | RFILE* filestream_open(const char *path, unsigned mode, unsigned hints); 65 | 66 | int64_t filestream_seek(RFILE *stream, int64_t offset, int seek_position); 67 | 68 | int64_t filestream_read(RFILE *stream, void *data, int64_t len); 69 | 70 | int64_t filestream_write(RFILE *stream, const void *data, int64_t len); 71 | 72 | int64_t filestream_tell(RFILE *stream); 73 | 74 | void filestream_rewind(RFILE *stream); 75 | 76 | int filestream_close(RFILE *stream); 77 | 78 | /** 79 | * filestream_read_file: 80 | * @path : path to file. 81 | * @buf : buffer to allocate and read the contents of the 82 | * file into. Needs to be freed manually. 83 | * @len : optional output integer containing bytes read. 84 | * 85 | * Read the contents of a file into @buf. 86 | * 87 | * @return Non-zero on success. 88 | */ 89 | int64_t filestream_read_file(const char *path, void **buf, int64_t *len); 90 | 91 | char* filestream_gets(RFILE *stream, char *s, size_t len); 92 | 93 | int filestream_getc(RFILE *stream); 94 | 95 | int filestream_vscanf(RFILE *stream, const char* format, va_list *args); 96 | 97 | int filestream_scanf(RFILE *stream, const char* format, ...); 98 | 99 | int filestream_eof(RFILE *stream); 100 | 101 | /** 102 | * filestream_write_file: 103 | * @path : path to file. 104 | * @data : contents to write to the file. 105 | * @size : size of the contents. 106 | * 107 | * Writes data to a file. 108 | * 109 | * @return true on success, otherwise false. 110 | **/ 111 | bool filestream_write_file(const char *path, const void *data, int64_t size); 112 | 113 | int filestream_putc(RFILE *stream, int c); 114 | 115 | int filestream_vprintf(RFILE *stream, const char* format, va_list args); 116 | 117 | int filestream_printf(RFILE *stream, const char* format, ...); 118 | 119 | int filestream_error(RFILE *stream); 120 | 121 | int filestream_flush(RFILE *stream); 122 | 123 | int filestream_delete(const char *path); 124 | 125 | int filestream_rename(const char *old_path, const char *new_path); 126 | 127 | const char* filestream_get_path(RFILE *stream); 128 | 129 | bool filestream_exists(const char *path); 130 | 131 | /** 132 | * filestream_getline: 133 | * 134 | * Returned pointer must be freed by the caller. 135 | **/ 136 | char* filestream_getline(RFILE *stream); 137 | 138 | libretro_vfs_implementation_file* filestream_get_vfs_handle(RFILE *stream); 139 | 140 | RETRO_END_DECLS 141 | 142 | #endif 143 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /libretro-common/include/vfs/vfs.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (vfs_implementation.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_VFS_H 24 | #define __LIBRETRO_SDK_VFS_H 25 | 26 | #include 27 | #include 28 | 29 | #ifdef RARCH_INTERNAL 30 | #ifndef VFS_FRONTEND 31 | #define VFS_FRONTEND 32 | #endif 33 | #endif 34 | 35 | RETRO_BEGIN_DECLS 36 | 37 | #ifdef _WIN32 38 | typedef void* HANDLE; 39 | #endif 40 | 41 | #ifdef HAVE_CDROM 42 | typedef struct 43 | { 44 | int64_t byte_pos; 45 | char *cue_buf; 46 | size_t cue_len; 47 | unsigned cur_lba; 48 | unsigned last_frame_lba; 49 | unsigned char cur_min; 50 | unsigned char cur_sec; 51 | unsigned char cur_frame; 52 | unsigned char cur_track; 53 | unsigned char last_frame[2352]; 54 | char drive; 55 | bool last_frame_valid; 56 | } vfs_cdrom_t; 57 | #endif 58 | 59 | enum vfs_scheme 60 | { 61 | VFS_SCHEME_NONE = 0, 62 | VFS_SCHEME_CDROM 63 | }; 64 | 65 | #if !(defined(__WINRT__) && defined(__cplusplus_winrt)) 66 | #ifdef VFS_FRONTEND 67 | struct retro_vfs_file_handle 68 | #else 69 | struct libretro_vfs_implementation_file 70 | #endif 71 | { 72 | #ifdef HAVE_CDROM 73 | vfs_cdrom_t cdrom; /* int64_t alignment */ 74 | #endif 75 | int64_t size; 76 | uint64_t mappos; 77 | uint64_t mapsize; 78 | FILE *fp; 79 | #ifdef _WIN32 80 | HANDLE fh; 81 | #endif 82 | char *buf; 83 | char* orig_path; 84 | uint8_t *mapped; 85 | int fd; 86 | unsigned hints; 87 | enum vfs_scheme scheme; 88 | }; 89 | #endif 90 | 91 | /* Replace the following symbol with something appropriate 92 | * to signify the file is being compiled for a front end instead of a core. 93 | * This allows the same code to act as reference implementation 94 | * for VFS and as fallbacks for when the front end does not provide VFS functionality. 95 | */ 96 | 97 | #ifdef VFS_FRONTEND 98 | typedef struct retro_vfs_file_handle libretro_vfs_implementation_file; 99 | #else 100 | typedef struct libretro_vfs_implementation_file libretro_vfs_implementation_file; 101 | #endif 102 | 103 | #ifdef VFS_FRONTEND 104 | typedef struct retro_vfs_dir_handle libretro_vfs_implementation_dir; 105 | #else 106 | typedef struct libretro_vfs_implementation_dir libretro_vfs_implementation_dir; 107 | #endif 108 | 109 | RETRO_END_DECLS 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /libretro-common/include/vfs/vfs_implementation.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (vfs_implementation.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_VFS_IMPLEMENTATION_H 24 | #define __LIBRETRO_SDK_VFS_IMPLEMENTATION_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | RETRO_BEGIN_DECLS 33 | 34 | libretro_vfs_implementation_file *retro_vfs_file_open_impl(const char *path, unsigned mode, unsigned hints); 35 | 36 | int retro_vfs_file_close_impl(libretro_vfs_implementation_file *stream); 37 | 38 | int retro_vfs_file_error_impl(libretro_vfs_implementation_file *stream); 39 | 40 | int64_t retro_vfs_file_size_impl(libretro_vfs_implementation_file *stream); 41 | 42 | int64_t retro_vfs_file_truncate_impl(libretro_vfs_implementation_file *stream, int64_t length); 43 | 44 | int64_t retro_vfs_file_tell_impl(libretro_vfs_implementation_file *stream); 45 | 46 | int64_t retro_vfs_file_seek_impl(libretro_vfs_implementation_file *stream, int64_t offset, int seek_position); 47 | 48 | int64_t retro_vfs_file_read_impl(libretro_vfs_implementation_file *stream, void *s, uint64_t len); 49 | 50 | int64_t retro_vfs_file_write_impl(libretro_vfs_implementation_file *stream, const void *s, uint64_t len); 51 | 52 | int retro_vfs_file_flush_impl(libretro_vfs_implementation_file *stream); 53 | 54 | int retro_vfs_file_remove_impl(const char *path); 55 | 56 | int retro_vfs_file_rename_impl(const char *old_path, const char *new_path); 57 | 58 | const char *retro_vfs_file_get_path_impl(libretro_vfs_implementation_file *stream); 59 | 60 | int retro_vfs_stat_impl(const char *path, int32_t *size); 61 | 62 | int retro_vfs_mkdir_impl(const char *dir); 63 | 64 | libretro_vfs_implementation_dir *retro_vfs_opendir_impl(const char *dir, bool include_hidden); 65 | 66 | bool retro_vfs_readdir_impl(libretro_vfs_implementation_dir *dirstream); 67 | 68 | const char *retro_vfs_dirent_get_name_impl(libretro_vfs_implementation_dir *dirstream); 69 | 70 | bool retro_vfs_dirent_is_dir_impl(libretro_vfs_implementation_dir *dirstream); 71 | 72 | int retro_vfs_closedir_impl(libretro_vfs_implementation_dir *dirstream); 73 | 74 | #ifdef __WINRT__ 75 | 76 | void uwp_set_acl(const wchar_t* path, const wchar_t* AccessString); 77 | 78 | #endif 79 | 80 | RETRO_END_DECLS 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /libretro-common/memalign.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2015 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (memalign.c). 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 | #include 24 | #include 25 | 26 | #include 27 | 28 | 29 | void *memalign_alloc(size_t boundary, size_t size) 30 | { 31 | void **place = NULL; 32 | uintptr_t addr = 0; 33 | void *ptr = (void*)malloc(boundary + size + sizeof(uintptr_t)); 34 | if (!ptr) 35 | return NULL; 36 | 37 | addr = ((uintptr_t)ptr + sizeof(uintptr_t) + boundary) 38 | & ~(boundary - 1); 39 | place = (void**)addr; 40 | place[-1] = ptr; 41 | 42 | return (void*)addr; 43 | } 44 | 45 | void memalign_free(void *ptr) 46 | { 47 | void **p = NULL; 48 | if (!ptr) 49 | return; 50 | 51 | p = (void**)ptr; 52 | free(p[-1]); 53 | } 54 | 55 | void *memalign_alloc_aligned(size_t size) 56 | { 57 | #if defined(__x86_64__) || defined(__LP64) || defined(__IA64__) || defined(_M_X64) || defined(_WIN64) 58 | return memalign_alloc(64, size); 59 | #elif defined(__i386__) || defined(__i486__) || defined(__i686__) || defined(GEKKO) 60 | return memalign_alloc(32, size); 61 | #else 62 | return memalign_alloc(32, size); 63 | #endif 64 | } 65 | -------------------------------------------------------------------------------- /libretro-common/rthreads/gx_pthread.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (gx_pthread.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 _GX_PTHREAD_WRAP_GX_ 24 | #define _GX_PTHREAD_WRAP_GX_ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #ifndef OSThread 32 | #define OSThread lwp_t 33 | #endif 34 | 35 | #ifndef OSCond 36 | #define OSCond lwpq_t 37 | #endif 38 | 39 | #ifndef OSThreadQueue 40 | #define OSThreadQueue lwpq_t 41 | #endif 42 | 43 | #ifndef OSInitMutex 44 | #define OSInitMutex(mutex) LWP_MutexInit(mutex, 0) 45 | #endif 46 | 47 | #ifndef OSLockMutex 48 | #define OSLockMutex(mutex) LWP_MutexLock(mutex) 49 | #endif 50 | 51 | #ifndef OSUnlockMutex 52 | #define OSUnlockMutex(mutex) LWP_MutexUnlock(mutex) 53 | #endif 54 | 55 | #ifndef OSTryLockMutex 56 | #define OSTryLockMutex(mutex) LWP_MutexTryLock(mutex) 57 | #endif 58 | 59 | #ifndef OSInitCond 60 | #define OSInitCond(cond) LWP_CondInit(cond) 61 | #endif 62 | 63 | #ifndef OSWaitCond 64 | #define OSWaitCond(cond, mutex) LWP_CondWait(cond, mutex) 65 | #endif 66 | 67 | #ifndef OSInitThreadQueue 68 | #define OSInitThreadQueue(queue) LWP_InitQueue(queue) 69 | #endif 70 | 71 | #ifndef OSSleepThread 72 | #define OSSleepThread(queue) LWP_ThreadSleep(queue) 73 | #endif 74 | 75 | #ifndef OSJoinThread 76 | #define OSJoinThread(thread, val) LWP_JoinThread(thread, val) 77 | #endif 78 | 79 | #ifndef OSCreateThread 80 | #define OSCreateThread(thread, func, intarg, ptrarg, stackbase, stacksize, priority, attrs) LWP_CreateThread(thread, func, ptrarg, stackbase, stacksize, priority) 81 | #endif 82 | 83 | #define STACKSIZE (8 * 1024) 84 | 85 | typedef OSThread pthread_t; 86 | typedef mutex_t pthread_mutex_t; 87 | typedef OSCond pthread_cond_t; 88 | 89 | #if defined(GX_PTHREAD_LEGACY) 90 | typedef void* pthread_mutexattr_t; 91 | typedef int pthread_attr_t; 92 | typedef OSCond pthread_condattr_t; 93 | #endif 94 | 95 | static INLINE int pthread_create(pthread_t *thread, 96 | const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg) 97 | { 98 | *thread = 0; 99 | return OSCreateThread(thread, start_routine, 0 /* unused */, arg, 100 | 0, STACKSIZE, 64, 0 /* unused */); 101 | } 102 | 103 | static INLINE pthread_t pthread_self(void) 104 | { 105 | /* zero 20-mar-2016: untested */ 106 | return LWP_GetSelf(); 107 | } 108 | 109 | static INLINE int pthread_mutex_init(pthread_mutex_t *mutex, 110 | const pthread_mutexattr_t *attr) 111 | { 112 | return OSInitMutex(mutex); 113 | } 114 | 115 | static INLINE int pthread_mutex_destroy(pthread_mutex_t *mutex) 116 | { 117 | return LWP_MutexDestroy(*mutex); 118 | } 119 | 120 | static INLINE int pthread_mutex_lock(pthread_mutex_t *mutex) 121 | { 122 | return OSLockMutex(*mutex); 123 | } 124 | 125 | static INLINE int pthread_mutex_unlock(pthread_mutex_t *mutex) 126 | { 127 | return OSUnlockMutex(*mutex); 128 | } 129 | 130 | static INLINE void pthread_exit(void *retval) 131 | { 132 | /* FIXME: No LWP equivalent for this? */ 133 | (void)retval; 134 | } 135 | 136 | static INLINE int pthread_detach(pthread_t thread) 137 | { 138 | /* FIXME: pthread_detach equivalent missing? */ 139 | (void)thread; 140 | return 0; 141 | } 142 | 143 | static INLINE int pthread_join(pthread_t thread, void **retval) 144 | { 145 | return OSJoinThread(thread, retval); 146 | } 147 | 148 | static INLINE int pthread_mutex_trylock(pthread_mutex_t *mutex) 149 | { 150 | return OSTryLockMutex(*mutex); 151 | } 152 | 153 | static INLINE int pthread_cond_wait(pthread_cond_t *cond, 154 | pthread_mutex_t *mutex) 155 | { 156 | return OSWaitCond(*cond, *mutex); 157 | } 158 | 159 | static INLINE int pthread_cond_timedwait(pthread_cond_t *cond, 160 | pthread_mutex_t *mutex, const struct timespec *abstime) 161 | { 162 | return LWP_CondTimedWait(*cond, *mutex, abstime); 163 | } 164 | 165 | static INLINE int pthread_cond_init(pthread_cond_t *cond, 166 | const pthread_condattr_t *attr) 167 | { 168 | return OSInitCond(cond); 169 | } 170 | 171 | static INLINE int pthread_cond_signal(pthread_cond_t *cond) 172 | { 173 | return LWP_CondSignal(*cond); 174 | } 175 | 176 | static INLINE int pthread_cond_broadcast(pthread_cond_t *cond) 177 | { 178 | return LWP_CondBroadcast(*cond); 179 | } 180 | 181 | static INLINE int pthread_cond_destroy(pthread_cond_t *cond) 182 | { 183 | return LWP_CondDestroy(*cond); 184 | } 185 | 186 | #endif 187 | -------------------------------------------------------------------------------- /libretro-common/rthreads/rsemaphore.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2016 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (rsemaphore.c). 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 | #ifdef __unix__ 24 | #define _POSIX_C_SOURCE 199309 25 | #endif 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | struct ssem 33 | { 34 | int value; 35 | int wakeups; 36 | slock_t *mutex; 37 | scond_t *cond; 38 | }; 39 | 40 | ssem_t *ssem_new(int value) 41 | { 42 | ssem_t *semaphore = (ssem_t*)calloc(1, sizeof(*semaphore)); 43 | 44 | if (!semaphore) 45 | goto error; 46 | 47 | semaphore->value = value; 48 | semaphore->wakeups = 0; 49 | semaphore->mutex = slock_new(); 50 | 51 | if (!semaphore->mutex) 52 | goto error; 53 | 54 | semaphore->cond = scond_new(); 55 | 56 | if (!semaphore->cond) 57 | goto error; 58 | 59 | return semaphore; 60 | 61 | error: 62 | if (semaphore) 63 | { 64 | if (semaphore->mutex) 65 | slock_free(semaphore->mutex); 66 | semaphore->mutex = NULL; 67 | free((void*)semaphore); 68 | } 69 | return NULL; 70 | } 71 | 72 | void ssem_free(ssem_t *semaphore) 73 | { 74 | if (!semaphore) 75 | return; 76 | 77 | scond_free(semaphore->cond); 78 | slock_free(semaphore->mutex); 79 | free((void*)semaphore); 80 | } 81 | 82 | int ssem_get(ssem_t *semaphore) 83 | { 84 | int val = 0; 85 | if (!semaphore) 86 | return 0; 87 | 88 | slock_lock(semaphore->mutex); 89 | 90 | val = semaphore->value; 91 | 92 | slock_unlock(semaphore->mutex); 93 | 94 | return val; 95 | } 96 | 97 | void ssem_wait(ssem_t *semaphore) 98 | { 99 | if (!semaphore) 100 | return; 101 | 102 | slock_lock(semaphore->mutex); 103 | semaphore->value--; 104 | 105 | if (semaphore->value < 0) 106 | { 107 | do 108 | { 109 | scond_wait(semaphore->cond, semaphore->mutex); 110 | }while (semaphore->wakeups < 1); 111 | 112 | semaphore->wakeups--; 113 | } 114 | 115 | slock_unlock(semaphore->mutex); 116 | } 117 | 118 | void ssem_signal(ssem_t *semaphore) 119 | { 120 | if (!semaphore) 121 | return; 122 | 123 | slock_lock(semaphore->mutex); 124 | semaphore->value++; 125 | 126 | if (semaphore->value <= 0) 127 | { 128 | semaphore->wakeups++; 129 | scond_signal(semaphore->cond); 130 | } 131 | 132 | slock_unlock(semaphore->mutex); 133 | } 134 | -------------------------------------------------------------------------------- /libretro-common/rthreads/xenon_sdl_threads.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (xenon_sdl_threads.c). 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 | /* libSDLxenon doesn't implement this yet :[. Implement it very stupidly for now. ;) */ 24 | 25 | #include "SDL_thread.h" 26 | #include "SDL_mutex.h" 27 | #include 28 | #include 29 | 30 | SDL_cond *SDL_CreateCond(void) 31 | { 32 | bool *sleeping = calloc(1, sizeof(*sleeping)); 33 | return (SDL_cond*)sleeping; 34 | } 35 | 36 | void SDL_DestroyCond(SDL_cond *sleeping) 37 | { 38 | free(sleeping); 39 | } 40 | 41 | int SDL_CondWait(SDL_cond *cond, SDL_mutex *lock) 42 | { 43 | (void)lock; 44 | volatile bool *sleeping = (volatile bool*)cond; 45 | 46 | SDL_mutexV(lock); 47 | *sleeping = true; 48 | while (*sleeping); /* Yeah, we all love busyloops don't we? ._. */ 49 | SDL_mutexP(lock); 50 | 51 | return 0; 52 | } 53 | 54 | int SDL_CondSignal(SDL_cond *cond) 55 | { 56 | *(volatile bool*)cond = false; 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /libretro-common/streams/file_stream_transforms.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (file_stream_transforms.c). 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 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | RFILE* rfopen(const char *path, const char *mode) 30 | { 31 | RFILE *output = NULL; 32 | unsigned int retro_mode = RETRO_VFS_FILE_ACCESS_READ; 33 | bool position_to_end = false; 34 | 35 | if (strstr(mode, "r")) 36 | { 37 | retro_mode = RETRO_VFS_FILE_ACCESS_READ; 38 | if (strstr(mode, "+")) 39 | { 40 | retro_mode = RETRO_VFS_FILE_ACCESS_READ_WRITE | 41 | RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING; 42 | } 43 | } 44 | else if (strstr(mode, "w")) 45 | { 46 | retro_mode = RETRO_VFS_FILE_ACCESS_WRITE; 47 | if (strstr(mode, "+")) 48 | retro_mode = RETRO_VFS_FILE_ACCESS_READ_WRITE; 49 | } 50 | else if (strstr(mode, "a")) 51 | { 52 | retro_mode = RETRO_VFS_FILE_ACCESS_WRITE | 53 | RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING; 54 | position_to_end = true; 55 | if (strstr(mode, "+")) 56 | { 57 | retro_mode = RETRO_VFS_FILE_ACCESS_READ_WRITE | 58 | RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING; 59 | } 60 | } 61 | 62 | output = filestream_open(path, retro_mode, 63 | RETRO_VFS_FILE_ACCESS_HINT_NONE); 64 | if (output && position_to_end) 65 | filestream_seek(output, 0, RETRO_VFS_SEEK_POSITION_END); 66 | 67 | return output; 68 | } 69 | 70 | int rfclose(RFILE* stream) 71 | { 72 | if (!stream) 73 | return EOF; 74 | 75 | return filestream_close(stream); 76 | } 77 | 78 | int64_t rftell(RFILE* stream) 79 | { 80 | if (!stream) 81 | return -1; 82 | 83 | return filestream_tell(stream); 84 | } 85 | 86 | int64_t rfseek(RFILE* stream, int64_t offset, int origin) 87 | { 88 | int seek_position = -1; 89 | 90 | if (!stream) 91 | return -1; 92 | 93 | switch (origin) 94 | { 95 | case SEEK_SET: 96 | seek_position = RETRO_VFS_SEEK_POSITION_START; 97 | break; 98 | case SEEK_CUR: 99 | seek_position = RETRO_VFS_SEEK_POSITION_CURRENT; 100 | break; 101 | case SEEK_END: 102 | seek_position = RETRO_VFS_SEEK_POSITION_END; 103 | break; 104 | } 105 | 106 | return filestream_seek(stream, offset, seek_position); 107 | } 108 | 109 | int64_t rfread(void* buffer, 110 | size_t elem_size, size_t elem_count, RFILE* stream) 111 | { 112 | if (!stream || (elem_size == 0) || (elem_count == 0)) 113 | return 0; 114 | 115 | return (filestream_read(stream, buffer, elem_size * elem_count) / elem_size); 116 | } 117 | 118 | char *rfgets(char *buffer, int maxCount, RFILE* stream) 119 | { 120 | if (!stream) 121 | return NULL; 122 | 123 | return filestream_gets(stream, buffer, maxCount); 124 | } 125 | 126 | int rfgetc(RFILE* stream) 127 | { 128 | if (!stream) 129 | return EOF; 130 | 131 | return filestream_getc(stream); 132 | } 133 | 134 | int64_t rfwrite(void const* buffer, 135 | size_t elem_size, size_t elem_count, RFILE* stream) 136 | { 137 | if (!stream || (elem_size == 0) || (elem_count == 0)) 138 | return 0; 139 | 140 | return (filestream_write(stream, buffer, elem_size * elem_count) / elem_size); 141 | } 142 | 143 | int rfputc(int character, RFILE * stream) 144 | { 145 | if (!stream) 146 | return EOF; 147 | 148 | return filestream_putc(stream, character); 149 | } 150 | 151 | int64_t rfflush(RFILE * stream) 152 | { 153 | if (!stream) 154 | return EOF; 155 | 156 | return filestream_flush(stream); 157 | } 158 | 159 | int rfprintf(RFILE * stream, const char * format, ...) 160 | { 161 | int result; 162 | va_list vl; 163 | 164 | if (!stream) 165 | return -1; 166 | 167 | va_start(vl, format); 168 | result = filestream_vprintf(stream, format, vl); 169 | va_end(vl); 170 | return result; 171 | } 172 | 173 | int rferror(RFILE* stream) 174 | { 175 | return filestream_error(stream); 176 | } 177 | 178 | int rfeof(RFILE* stream) 179 | { 180 | return filestream_eof(stream); 181 | } 182 | 183 | int rfscanf(RFILE * stream, const char * format, ...) 184 | { 185 | int result; 186 | va_list vl; 187 | 188 | if (!stream) 189 | return 0; 190 | 191 | va_start(vl, format); 192 | result = filestream_vscanf(stream, format, &vl); 193 | va_end(vl); 194 | return result; 195 | } 196 | -------------------------------------------------------------------------------- /libretro-common/time/rtime.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2020 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (rtime.c). 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 | #ifdef HAVE_THREADS 24 | #include 25 | #include 26 | #endif 27 | 28 | #include 29 | #include