Compare commits

...
Author SHA1 Message Date
twinaphex 7b6e564ba3 (Mac) Make separate default core dirs based on architecture - note -
we will also have to write to a separate config file per architecture -
that will have to come next
2021-08-28 14:32:17 +02:00
twinaphex b574780d99 (UWP) Updated icons courtesy of Danp142 2021-08-27 20:17:22 +02:00
Autechre 1a2ee91117 Merge pull request #12895 from jdgleaver/overlay-adc-fix
Fix overlay input when analog to digital mapping is enabled
2021-08-27 17:21:10 +02:00
jdgleaver bc6fec6e0c Fix overlay input when analog to digital mapping is enabled 2021-08-27 16:16:31 +01:00
Autechre ec06ab0941 Merge pull request #12890 from jdgleaver/custom-viewport-keyboard-entry
Allow 'Custom Aspect Ratio (X Position)/(Y Position)/(Width)/(Height)' to be entered manually via keyboard
2021-08-27 15:08:05 +02:00
jdgleaver 32e2aacd3c Allow 'Custom Aspect Ratio (X Position)/(Y Position)/(Width)/(Height)' to be entered manually via keyboard 2021-08-27 11:21:29 +01:00
twinaphex 7f08729a5e Revert "(gfx_display) Make gfx_display_set_fb_size - get rid of the small"
This reverts commit 618cfacd59.
2021-08-26 18:42:43 +02:00
twinaphex ea6139b234 Revert "(GX) Buildfix"
This reverts commit 96d87802cd.
2021-08-26 18:42:34 +02:00
twinaphex 96d87802cd (GX) Buildfix 2021-08-26 18:31:32 +02:00
twinaphex 618cfacd59 (gfx_display) Make gfx_display_set_fb_size - get rid of the small
getter/setter functions - also finally take this opportunity to stop
setting framebuffer width/height/pitch for menu drivers that don't
use a framebuffer texture at all
2021-08-26 18:26:44 +02:00
Autechre 6d9ee4c161 Merge pull request #12875 from libretro/coc-update
Add Code of Conduct
2021-08-26 15:37:14 +02:00
Stephanie Gawroriski 46b9432fb8 Include subject line inclusion. 2021-08-26 09:34:40 -04:00
Autechre c66bcc05cf Merge pull request #12878 from libretro/input-get-rid-of-getters-setters
Get rid of getters/setters in big driver files from now
2021-08-26 14:58:33 +02:00
Autechre 00b15c4e79 Merge pull request #12877 from jdgleaver/core-options-flush
Add option to (force-)write current core options to disk
2021-08-26 14:11:05 +02:00
twinaphex 597dbfdf9a Address issues pointed out 2021-08-26 14:01:37 +02:00
twinaphex af6b09d950 Fix some of the indenting; add NULL checks 2021-08-26 13:49:06 +02:00
twinaphex 0194ce91bf Get rid of getters/setters in big driver files from now 2021-08-26 13:27:44 +02:00
jdgleaver a6901dc85e Add option to (force-)write current core options to disk 2021-08-26 11:42:46 +01:00
Stephanie Gawroriski 8850a4984b Remove Discord and Twitter 2021-08-25 19:03:08 -04:00
Stephanie Gawroriski daef26f951 Create CODE_OF_CONDUCT.md 2021-08-25 18:55:32 -04:00
Autechre 5ca99fdb51 Merge pull request #12874 from libretro/social-update
Contributing guidelines update.
2021-08-25 21:16:48 +02:00
Autechre 23a06ef1a1 Merge pull request #12863 from sonninnos/config-ar
Default aspect ratio + sublabel correction
2021-08-25 17:29:25 +02:00
Stephanie Gawroriski cd3e818210 Add coding standards. 2021-08-25 10:54:04 -04:00
Twinaphex 619df7e11b remove HAVE_DISCORD from OSX OpenGL solution (RetroArch.xcodeproj) - we
cannot assume C++11 support here for backwards compatibility purposes
2021-08-25 13:03:19 +02:00
twinaphex df98bca9ae (Mac) Add Discord RPC support - untested 2021-08-25 09:56:00 +02:00
Autechre 10e1f5d72a Merge pull request #12871 from sonninnos/msvc-buildfix
MSVC buildfix
2021-08-25 00:37:40 +02:00
Autechre aac207b455 Merge pull request #12872 from sonninnos/c89-buildfix
C89 buildfix
2021-08-25 00:37:31 +02:00
sonninnos ca311246b1 C89 buildfix 2021-08-24 22:32:47 +03:00
sonninnos 22de07a662 MSVC buildfix 2021-08-24 22:28:13 +03:00
Autechre 2329a36f54 Merge pull request #12866 from sonninnos/resolution-list
Screen Resolution list sanitizing
2021-08-24 20:21:48 +02:00
Autechre ab3385c73d Merge pull request #12870 from sonninnos/menu-sound-sublabel
Add sublabel for 'Menu Sounds'
2021-08-24 20:18:34 +02:00
sonninnos f21f113678 Add sublabel for 'Menu Sounds' 2021-08-24 21:05:21 +03:00
sonninnos d5b1c3092f Screen Resolution list sanitizing 2021-08-24 20:01:19 +03:00
twinaphex d401816f41 Silence warnings 2021-08-24 18:47:29 +02:00
Autechre dbb74ba5ab Merge pull request #12823 from markwkidd/input-drivers
input_driver refactor
2021-08-24 18:45:20 +02:00
Autechre 4e188c0f26 Merge pull request #12830 from icculus/udev_keyboard_detect_fix
udev_input.c: Look for "ID_INPUT_KEY", not "ID_INPUT_KEYBOARD"
2021-08-24 18:42:38 +02:00
Autechre 376f06c993 Merge pull request #12841 from libretro/resampler-neon
(sinc) Add non-ASM ARM NEON intrinsics codepath for Sinc resampler
2021-08-24 17:52:34 +02:00
Autechre 1bd188c5a7 Merge pull request #12867 from jdgleaver/shader-parameter-check-fix
Highlight currently selected value in Shader Parameter drop-down lists
2021-08-24 16:49:51 +02:00
Autechre d3813dddb1 Merge pull request #12868 from sonninnos/winraw-overlay-fix
(WINRAW) Fix crash when overlay is enabled
2021-08-24 16:49:30 +02:00
sonninnos 957b71cfdc (WINRAW) Fix crash when overlay is enabled 2021-08-24 17:03:28 +03:00
jdgleaver d35200aa56 Highlight currently selected value in Shader Parameter drop-down lists 2021-08-24 14:45:57 +01:00
Autechre 919954c5be Merge pull request #12864 from sonninnos/rate-set-prefix
Print video-prefix in refresh rate set to log only
2021-08-24 11:28:24 +02:00
Autechre cc7247aecf Merge pull request #12855 from jdgleaver/core-info-cache-path
Remove core path from core info cache
2021-08-24 11:27:31 +02:00
Autechre 024dbb5008 Merge pull request #12862 from sonninnos/video-sublabels
Add missing sublabels for video options
2021-08-24 11:26:40 +02:00
Autechre 41afbc30ef Merge pull request #12859 from jdgleaver/refresh-rate-entry
Allow 'Vertical Refresh Rate' to be entered manually via keyboard
2021-08-24 11:26:24 +02:00
sonninnos 8d513f8199 Print video-prefix in refresh rate set to log only 2021-08-23 18:32:10 +03:00
sonninnos eb49458284 Default aspect ratio + sublabel correction 2021-08-23 18:13:46 +03:00
Autechre b2c87baa87 Merge pull request #12861 from jdgleaver/audio-menu-fix
Fix segfault when accessing 'Audio' menu on platforms without mixer support
2021-08-23 16:44:47 +02:00
sonninnos 71ca56e0fb Add missing sublabels for video options 2021-08-23 17:44:02 +03:00
jdgleaver f505d625a3 Fix segfault when accessing 'Audio' menu on platforms without mixer support 2021-08-23 15:37:29 +01:00
jdgleaver 6855b7f2b1 Allow 'Vertical Refresh Rate' to be entered manually via keyboard 2021-08-23 13:55:19 +01:00
Autechre 1ad0251da9 Merge pull request #12856 from jdgleaver/gfx-display-unused-vars
(gfx_display.c) Remove unused variables
2021-08-23 14:06:57 +02:00
Autechre e5d6d411be Merge pull request #12857 from jdgleaver/qt-video-settings-fix
(Qt) Fix segfault when accessing Video Options menu on non-Windows platforms
2021-08-23 13:56:33 +02:00
jdgleaver b0c5362da6 (Qt) Fix segfault when accessing Video Options menu on non-Windows platforms 2021-08-23 12:40:46 +01:00
jdgleaver 67bc91c1d0 (gfx_display.c) Remove unused variables 2021-08-23 12:11:00 +01:00
jdgleaver f0a510c8a6 Remove core path from core info cache 2021-08-23 11:47:08 +01:00
Autechre f2d574fd87 Merge pull request #12853 from nbarkhina/master
Fixed web player bug with filesystem and runtime
2021-08-23 11:00:10 +02:00
Neil Barkhina 8590e0e3fe Fixed web player bug with filesystem and runtime 2021-08-22 20:08:05 -04:00
Stephanie Gawroriski d44f3e1239 Update CONTRIBUTING.md 2021-08-22 19:24:14 -04:00
Stephanie Gawroriski 1855ce5fc7 Update CONTRIBUTING.md 2021-08-22 19:18:00 -04:00
Autechre fa5ec2d4b1 Update CHANGES.md 2021-08-22 18:18:55 +02:00
twinaphex bea512b70b Get rid of gfx_display_draw_texture - use gfx_display_draw_quad instead 2021-08-22 17:57:21 +02:00
twinaphex 54ae219302 Fix gfx_display_draw_texture - fixes D3D11/D3D12/D3D10 OSK issues 2021-08-22 17:17:09 +02:00
Stephanie Gawroriski 5ac7d89e36 Part 1 rework of contributing. 2021-08-21 20:28:12 -04:00
Autechre 755789f825 Merge pull request #12845 from sonninnos/winraw-analog-keybinds
(WINRAW) Add missing analog keybinds
2021-08-22 01:02:02 +02:00
Autechre 5f3cb1fae2 Merge pull request #12846 from sonninnos/sdl2-keycodes
(WINSDL2) Fix keyboard event keycodes
2021-08-22 01:01:40 +02:00
Autechre 9bd6051581 Merge pull request #12847 from Jamiras/cheevos_http_neg1
(cheevos) automatically retry 'http error code -1'
2021-08-22 01:01:15 +02:00
Jamiras df5a2c5160 automatically retry 'http error code -1' 2021-08-21 13:54:39 -06:00
sonninnos 2482a6f42a (WINSDL2) Fix keycodes 2021-08-21 22:27:08 +03:00
sonninnos 26d6c8243a (WINRAW) Add missing analog keybinds 2021-08-21 22:01:12 +03:00
twinaphex 4fae4ead73 Add workaround for MSVC 2021-08-21 20:05:44 +02:00
twinaphex 0f3ae9b03d Try lroundf instead 2021-08-21 19:54:39 +02:00
Autechre 5a65773b81 Merge pull request #12842 from sonninnos/playlist-manage
Relocate 'Manage Playlists' to top
2021-08-21 19:25:58 +02:00
sonninnos 559a173e8b Relocate 'Manage Playlists' to top 2021-08-21 20:18:12 +03:00
twinaphex 9a97eb47ad Fix typos 2021-08-21 19:11:21 +02:00
Autechre ac539f6316 Merge pull request #12840 from sonninnos/video-rate-59hz
Fix refresh rate 59Hz rounding
2021-08-21 18:54:43 +02:00
twinaphex ca26e50050 (sinc) Add non-ASM ARM NEON intrinsics codepath for Sinc resampler 2021-08-21 18:52:20 +02:00
twinaphex b620325714 Rename HAVE_ARM_NEON_OPTIMIZATIOn to HAVE_ARM_NEON_ASM_OPTIMIZATIONS,
rename DONT_WANT_ARM_OPTIMIZATIONS to DONT_WANT_ARM_NEON_OPTIMIZATIONS
2021-08-21 18:00:59 +02:00
sonninnos 1e4557c09a Fix refresh rate 59Hz rounding 2021-08-21 18:20:15 +03:00
Autechre 11d5d3170d Merge pull request #12833 from IlDucci/translationsupdatewithscript0
Fetch translations from Crowdin 20-Aug-2021
2021-08-21 14:35:57 +02:00
Autechre 21d3c13ed3 Merge pull request #12837 from sonninnos/ozone-check
(Ozone) Ensure the existence of values used in selection calculation
2021-08-21 14:33:14 +02:00
Autechre 393343c03c Merge pull request #12839 from sonninnos/refresh-rate-notifications
Fix double notifications with refresh rate settings
2021-08-21 14:32:55 +02:00
sonninnos 4f57b6f6fa Fix double notifications with refresh rate settings 2021-08-21 15:09:19 +03:00
sonninnos 7a6434ecb2 (Ozone) Ensure the existence of values used in selection calculation 2021-08-21 13:10:59 +03:00
Autechre b02ef55a92 Merge pull request #12836 from libretro/displayserver-refactors
Simplify win32_get_metrics
2021-08-21 03:07:42 +02:00
twinaphex 462137305b Simplify win32_get_metrics 2021-08-21 02:24:32 +02:00
twinaphex eb50d7dbb4 (UWP) Push temporary fixes for issue that happens when resizing on UWP
with latest Xbox Series dashboard; DXGIResizeBuffers passing 0, 0 as
width/height is apparently problematic as it changes 0, 0 to 8,8
instead,
breaking the program
2021-08-20 23:16:01 +02:00
twinaphex 77a17b213d Fullscreen resolution width/height settings no longer require
'advanced settings'
2021-08-20 15:18:03 +02:00
IlDucci ddd75d3bb9 Fetch translations from Crowdin 20-Aug-2021 2021-08-20 11:17:16 +02:00
twinaphex ffb59e5261 (UWP) Turn this back on again - seems to work fine on Xbox 2021-08-20 10:07:29 +02:00
Mark W. Kidd 5f834a8cb3 input_driver refactor 2021-08-19 20:02:39 -04:00
Ryan C. Gordon 9a6faa3ddd udev_input.c: Look for "ID_INPUT_KEY", not "ID_INPUT_KEYBOARD"
This fixes programs using /dev/uinput to create a virtual keyboard failing
to be detected on startup. Usual symptom is some sort of GPIO-based
controller that looks like a keyboard to the OS and can control
EmulationStation, but fails to work in-game unless you restart the program
while the game is running (in which case udev_input.c's hotplug code, which
was using the correct key, would pick it up).
2021-08-19 16:00:57 -04:00
Autechre 0c0de9f0ad Merge pull request #12828 from jdgleaver/ff-override-runahead-fix
Fix RETRO_ENVIRONMENT_SET_FASTFORWARDING_OVERRIDE callback when runahead is enabled
2021-08-19 17:17:13 +02:00
jdgleaver bbc121cd74 Fix RETRO_ENVIRONMENT_SET_FASTFORWARDING_OVERRIDE callback when runahead is enabled 2021-08-19 14:49:49 +01:00
Autechre 48bb705b03 Update CHANGES.md 2021-08-19 14:28:56 +02:00
twinaphex 78431d0700 (MSVC2017/2019 UWP) Define HAVE_TRANSLATE 2021-08-19 14:25:55 +02:00
Autechre 97144833cb Merge pull request #12819 from libretro/revert-12703-input-drivers
Revert "input refactoring: create input_driver.c"
2021-08-18 18:46:03 +02:00
Autechre ae327a769b Revert "input refactoring: create input_driver.c" 2021-08-18 18:45:53 +02:00
Autechre a66b1b3e48 Merge pull request #12703 from markwkidd/input-drivers
input refactoring: create input_driver.c
2021-08-18 18:17:43 +02:00
Autechre 5e879fa201 Merge pull request #12794 from DisasterMo/master
Add core options v1 to v2 conversion script
2021-08-18 18:17:26 +02:00
Autechre 80136dd3ec Merge pull request #12663 from Nargash/log_early
Starting logging and verbose mode before first config load
2021-08-18 18:17:03 +02:00
Autechre 2e82db6447 Merge pull request #12818 from mahoneyt944/patch-1
Allow mobile touch screen devices to use emscripten.
2021-08-18 17:49:56 +02:00
mahoneyt944 2802817239 Update config.def.h 2021-08-18 11:41:53 -04:00
Autechre 9750ebcf71 Merge pull request #12817 from jdgleaver/core-option-visibility-callback
Add environment callback for enabling core option menu visibility updates without toggling Quick Menu
2021-08-18 17:31:06 +02:00
jdgleaver 0e98b4ddea Add environment callback for enabling core option menu visibility updates without toggling Quick Menu 2021-08-18 16:08:26 +01:00
twinaphex 97b9a79fc0 Reproduced crash occurring on OSX upon entering 'Load Content'
menu, this fixes it
2021-08-18 16:10:19 +02:00
Autechre 3963039102 Update CONTRIBUTING.md 2021-08-18 02:45:48 +02:00
Autechre 4f26860bb4 Update CONTRIBUTING.md 2021-08-18 02:44:48 +02:00
Autechre 47b6d4a99d Update CONTRIBUTING.md 2021-08-18 02:44:21 +02:00
Autechre 52db47d0fd Update CHANGES.md 2021-08-17 20:24:23 +02:00
Autechre 92b330f2aa Merge pull request #12809 from Tatsuya79/patch-1
QT: windowed settings update
2021-08-17 19:19:50 +02:00
Tatsuya79 bf8f527143 QT: windowed settings update 2021-08-17 15:41:49 +02:00
Mark W. Kidd 5a8920c862 input_driver refactor 2021-08-17 08:56:29 -04:00
twinaphex dfea030f5b Revert "Update libretro.h header file"
This reverts commit f3458fb943.
2021-08-17 10:38:14 +02:00
Autechre e68e3e9bb3 Merge pull request #12806 from jdgleaver/window-size-cap
Add facility to cap maximum window size in windowed mode
2021-08-17 01:07:00 +02:00
twinaphex f3458fb943 Update libretro.h header file 2021-08-16 23:53:50 +02:00
Autechre d369e06a67 Merge pull request #12804 from tunip3/patch-1
add fix for beetle cores to change log
2021-08-16 19:21:07 +02:00
jdgleaver fa7dd0f6d9 Add facility to cap maximum window size in windowed mode 2021-08-16 17:49:11 +01:00
jdgleaver 0f142d531a Revert "Add extra video logs so we can see what goes on"
This reverts commit 6780f58444.
2021-08-16 17:49:11 +01:00
jdgleaver 6e7e8a7680 Revert "video_driver_init_internal - add more logs"
This reverts commit d0a08ce959.
2021-08-16 17:49:11 +01:00
jdgleaver c2b3ba907c Revert "video_driver_init_internal - refactor"
This reverts commit bba924e8d2.
2021-08-16 17:49:11 +01:00
tunip3 ece8ff8ad8 add fix for beetle cores to change log 2021-08-16 15:11:26 +01:00
Autechre 89f984400b Merge pull request #12803 from fjtrujy/ps2/FlickeringIssues
Solve flickering issues in cores with Frame Skip
2021-08-16 14:07:14 +02:00
Francisco Javier Trujillo Mata a442c5b14f Simplify logic for transparencies 2021-08-16 13:12:06 +02:00
twinaphex 6223ba47fd Bring back these tiny optimizations from foobar2k 2021-08-15 22:54:21 +02:00
twinaphex 1906a741c2 Rollback sinc resampler changes - themaister wasn't sure if these were
actual optimizations
2021-08-15 22:45:59 +02:00
twinaphex bba924e8d2 video_driver_init_internal - refactor 2021-08-15 21:57:44 +02:00
Autechre a6f44ab642 Merge pull request #12801 from fjtrujy/ps2/HDD_startup
Avoid to start HDD if user boot from different unit
2021-08-15 17:21:35 +02:00
Francisco Javier Trujillo Mata e999c65037 Avoid to start HDD if user boot from different unit 2021-08-15 17:04:52 +02:00
Michael Burgardt 2d934f4d53 Add core options v1 to v2 conversion script 2021-08-15 13:07:31 +02:00
twinaphex f5564120a4 Remove math-neon on frangarcj's recommendation - not used 2021-08-15 09:47:31 +02:00
Autechre b0ac722366 Update CHANGES.md 2021-08-14 21:04:29 +02:00
Autechre 757ce5e572 Update CHANGES.md 2021-08-14 20:58:23 +02:00
Autechre def35ebe8e Merge pull request #12799 from Jamiras/cheevos_inf_regions
(cheevos) support for more than 64 memory regions
2021-08-14 20:57:24 +02:00
Jamiras a0f3bf7432 support for more than 64 memory regions 2021-08-14 12:47:42 -06:00
twinaphex b837e053e9 (cheevos) Silence warning signed/unsigned mismatch 2021-08-14 19:17:23 +02:00
Autechre c8e183fb3c Merge pull request #12797 from QuarkTheAwesome/load-without-core-info
(WiiU) Add option for running without core info (emscripten-style)
2021-08-14 17:03:38 +02:00
Autechre 29510df156 Merge pull request #12798 from QuarkTheAwesome/wiiu-128k-slowpath
(WiiU) Slight filesystem optimisation
2021-08-14 17:03:10 +02:00
Ash Logan d9157c5dc7 (WiiU) Read up to 128k on the no-CFW unaligned slowpath
it may be the slowpath, but 16k is a bit rich
2021-08-14 20:29:24 +10:00
Ash Logan 692f4443f4 (WiiU) Add option for running without core info (emscripten-style)
Very useful when wiiloading a test binary or running in emulation
2021-08-14 20:26:14 +10:00
twinaphex d0a08ce959 video_driver_init_internal - add more logs 2021-08-14 08:36:47 +02:00
twinaphex 6780f58444 Add extra video logs so we can see what goes on 2021-08-14 08:11:17 +02:00
twinaphex a489f1275a (Ozone) Casting to unsigned caused an integer overflow and after float
promotion would lead to 'x' being a garbage value, leading to problems
when this value was passed to vkCmdSetViewport. This stops Vulkan
validation layers from complaining about it
2021-08-14 02:20:56 +02:00
Autechre 84f5ab96ea Merge pull request #12792 from IlDucci/translationsupdatewithscript
Fetch translations from Crowdin 13-Aug-2021
2021-08-13 23:22:09 +02:00
Autechre fe10d285ec Merge pull request #12793 from Xbox-Homebrew/master
fix loading arcade dat files
2021-08-13 22:07:59 +02:00
IlDucci 9ad6ebc879 Fetch translations from Crowdin 13-Aug-2021 2021-08-13 21:35:50 +02:00
Tunip3 4116cb6fa5 fix issue where filesizes where not returned properly, this fixes loading arcade dat files 2021-08-13 20:33:27 +01:00
twinaphex 14e974ea07 Silence warning on WiiU - unused variable 2021-08-13 18:17:22 +02:00
Autechre a6b0efa4f0 Merge pull request #12790 from jdgleaver/core-option-category-disable
Add option to disable core option categories
2021-08-13 17:58:29 +02:00
jdgleaver c4880ca840 Add option to disable core option categories 2021-08-13 16:18:02 +01:00
Autechre 1c4895b8bf Merge pull request #12789 from Xbox-Homebrew/master
Fix beetle cores on UWP and clean up the method in which drives are listed
2021-08-13 15:54:18 +02:00
twinaphex 1ca1d362bf Ifdef this for HAVE_NETWORKING - should fix Emscripten 2021-08-13 07:57:18 +02:00
Autechre beabcebe9d Merge pull request #12788 from Jamiras/cheevos_abr
(cheevos) prevent read past end of buffer
2021-08-13 01:09:10 +02:00
Jamiras 1e4af83e2a prevent read past end of buffer 2021-08-12 16:28:51 -06:00
Autechre 9e84c5c2c8 Merge pull request #12787 from sonninnos/win32-orig-refresh
(WIN32) Remember original refresh rate
2021-08-12 19:24:01 +02:00
Autechre 1c82fd29ef Merge pull request #12786 from sonninnos/resolution-dropdown
Resolution dropdown pop
2021-08-12 19:23:39 +02:00
Autechre f0bd4e9172 Merge pull request #12785 from sonninnos/win32-vulkan-cleanup
(WIN32/Vulkan) Refresh rate fixes + cleanups
2021-08-12 19:23:29 +02:00
twinaphex 05bf208f7d Was missing a header include for switch_performance_profiles.h 2021-08-12 19:03:42 +02:00
twinaphex e9e6607fc9 (libz) Clang does not like this at all - warning: possible misuse of comma operator here [-Wcomma] 2021-08-12 19:00:59 +02:00
twinaphex 5b3942eae7 * (PSP/Vita) Remove unused variables
* (Switch/libnx) remove dead code
* (Lakka/Switch/libnx) It was a mistake to include
  switch_performance_profiles.h inside lakka.h, it was creating warnings
for nearly every file. Instead, it gets optionally included for the
files that need it
2021-08-12 18:51:33 +02:00
twinaphex 148a489af5 Add TODO/FIXME note and exclude ifdef for now 2021-08-12 18:28:03 +02:00
twinaphex d28402b87d Current label and value seems too big for strings being spoken,
reduce them by half
2021-08-12 18:24:35 +02:00
twinaphex a736dd27d2 (platform_switch) arg_data/args don't seem used anywhere
(switch_thread_audio) Pass correct type to function
2021-08-12 18:22:09 +02:00
twinaphex ccb8ecec4d Simplify command_event_save_current_config 2021-08-12 18:16:50 +02:00
sonninnos f1c276b751 (WIN32) Remember original refresh rate 2021-08-12 19:15:55 +03:00
sonninnos ef31302bd5 Pop out of Screen Resolution option after selecting 2021-08-12 19:09:51 +03:00
twinaphex 28417a02b7 Reduce size of path_config_append_file - too big - see warning
configuration.c:3710:10: note: 'snprintf' output 2 or more bytes (assuming 4097) into a destination of size 4096
2021-08-12 17:39:27 +02:00
twinaphex cd69803427 Silence warnings on tvOS 2021-08-12 17:35:37 +02:00
sonninnos 11b0667e72 (WIN32/Vulkan) Refresh rate fixes + cleanups 2021-08-12 18:33:58 +03:00
twinaphex d4c62a177a Lower subsystem_path to 256 - hopefully gets rid of the warnings on Wii 2021-08-12 17:29:35 +02:00
Autechre 7c9817b582 Merge pull request #12784 from fjtrujy/ps2/HDDSupport
Add support of HDD for PS2
2021-08-12 17:17:30 +02:00
twinaphex 3ce8d14c2e More HAVE_NETWORKING buildfixes for Dingux 2021-08-12 17:14:08 +02:00
Twinaphex 57054a075d (macOS) Fix remaining build errors with netplay discovery ifdefs 2021-08-12 17:11:31 +02:00
twinaphex 027bbe0755 Forgot some more HAVE_NETWORKING ifdefs 2021-08-12 17:03:59 +02:00
twinaphex ac4adabeb9 Silence some unused variable warnings 2021-08-12 17:00:24 +02:00
twinaphex c76cb77202 Further buildfixes for platforms that don't support
HAVE_NETPLAYDISCOVERY
2021-08-12 16:52:43 +02:00
twinaphex d07e0da412 Improve HAVE_NETWORKING and HAVE_NETPLAYDISCOVERY ifdefs; remove
unused netplay lan scan rooms function
2021-08-12 16:44:07 +02:00
twinaphex 43b72ea23c Silence some warnings (unused variables) when HAVE_NETPLAYDISCOVERY
is not defined
2021-08-12 16:11:29 +02:00
twinaphex fbeb157bba Raise limit on stk_ident to avoid warning on Vita 2021-08-12 16:01:48 +02:00
Francisco Javier Trujillo Mata df89a6b604 Add support of HDD for PS2 2021-08-12 14:07:14 +02:00
twinaphex 8d7e8bb574 (Wii) Disable RSound support - will only cost RAM and is probably
not in use
2021-08-11 22:13:47 +02:00
twinaphex 20ef0667b0 Add initial webOS port courtesy of informatic/webosbrew/mariotaku 2021-08-11 20:04:11 +02:00
twinaphex c34982d695 Update CHANGES.md 2021-08-11 19:20:21 +02:00
Autechre 0c806447b5 Merge pull request #12780 from jdgleaver/database-crc-fix
(Database) Fix heap-buffer-overflow when fetching CRC values
2021-08-11 19:19:30 +02:00
twinaphex b375e08c67 (libretro-common) fill_pathname_abbreviated_or_relative - fix warning -
variable is uninitialized
2021-08-11 18:50:03 +02:00
jdgleaver b2a4620f3b (Database) Fix heap-buffer-overflow when fetching CRC values 2021-08-11 17:32:45 +01:00
twinaphex 013dd30bde We have to uniquely name pointer_status struct for both dinput
and winraw because otherwise Griffin builds will fail
2021-08-11 03:44:34 +02:00
Autechre 7e08c019bc Update CHANGES.md 2021-08-11 03:40:45 +02:00
Autechre 8dfaee370a Merge pull request #12779 from sonninnos/wasapi-nonblock
(WASAPI) Stop deactivating audio on fast forward
2021-08-11 03:37:20 +02:00
sonninnos c737947d74 (WASAPI) Stop deactivating audio on fast forward 2021-08-11 04:21:52 +03:00
Autechre 9a4597d7ba Merge pull request #12776 from fjtrujy/ps2_aspect_ratio
PS2 aspect ratio
2021-08-10 18:58:59 +02:00
Autechre 82e53d3db8 Merge pull request #12777 from jdgleaver/core-option-hash
Optimise core option/core option category look-ups using hash tables
2021-08-10 18:58:49 +02:00
Tunip3 59e36c51a3 simplify getting root drives 2021-08-10 17:31:59 +01:00
Tunip3 a4017e69e4 fix cd based beetle cores 2021-08-10 17:24:31 +01:00
Francisco Javier Trujillo Mata 8b1fa3bb59 Fixing missing deinit libraries in cores 2021-08-10 18:15:36 +02:00
Francisco Javier Trujillo Mata 2aeb0b079e Implement aspect_ratio and scaling integer to PS2 2021-08-10 18:14:02 +02:00
jdgleaver 2d9a1d2270 Optimise core option/core option category look-ups using hash tables 2021-08-10 16:14:23 +01:00
Tunip3 075783d4f7 Merge branch 'master' of https://github.com/Xbox-Homebrew/RetroArch 2021-08-10 15:45:25 +01:00
Tunip3 a2c378c594 add entry to git ignore 2021-08-10 15:45:14 +01:00
Autechre 9cd5e66b21 Merge pull request #12774 from jdgleaver/nested-list-fix
(nested_list) Fix heap-use-after-free errors due to pointer invalidation when resizing internal RBUF arrays
2021-08-10 00:31:40 +02:00
jdgleaver f58c7f69d9 (nested_list) Fix heap-use-after-free errors due to pointer invalidation when resizing internal RBUF arrays 2021-08-09 23:08:17 +01:00
twinaphex 406c8bee7b Silenc some warnings 2021-08-09 21:24:03 +02:00
twinaphex 13a2d2419f (PSL1GHT) Fix function prototype for 'button' pad driver
(Task save) Fix warning in platform port
2021-08-09 20:25:27 +02:00
Autechre c6e86caeed Merge pull request #12771 from jdgleaver/core-options-sample-unused-var
Remove unused variable in core options v2 sample template file
2021-08-09 18:08:12 +02:00
jdgleaver e42a1895af Remove unused variable in core options v2 sample template file 2021-08-09 17:02:11 +01:00
Autechre efffa2a76e Merge pull request #12769 from fjtrujy/DEBUG_SCREEN
Use printf_screen for make easier the debugging
2021-08-09 14:23:21 +02:00
Autechre 5b801bab46 Update CHANGES.md 2021-08-09 14:22:59 +02:00
Francisco Javier Trujillo Mata 187a73d93a Use printf_screen for make easier the debugging 2021-08-09 14:19:51 +02:00
Autechre ef3dbc8378 Merge pull request #12749 from jdgleaver/core-option-category
Add core option category support
2021-08-09 14:19:00 +02:00
Autechre 7e1fdafa47 Merge pull request #12767 from GiantEnemyCrab/linux-add-StartupWMClass-to-desktop-file
Add StartupWMClass to retroarch.desktop file
2021-08-09 14:18:40 +02:00
Autechre 92efe48db2 Merge pull request #12768 from Jamiras/cheevos_ctype_uchar
(cheevos) explicitly cast to unsigned char for ctype functions
2021-08-09 14:18:20 +02:00
jdgleaver 1f7532bf52 Add core options v2 template in 'libretro-common/samples/core_options/example_categories' 2021-08-09 12:23:43 +01:00
Brian Weiss 0e3fddf448 explicitly cast to unsigned char for ctype functions 2021-08-08 21:56:26 -06:00
GiantEnemyCrab 0515377d63 Add StartupWMClass to retroarch.desktop file 2021-08-08 23:14:56 -04:00
twinaphex 93e5fc60af Silence some warnings 2021-08-08 22:14:50 +02:00
twinaphex bb30dc3dee After gblues' change, the rest of the button function callbacks
for the other joypad drivers still had int16_t as the return type
instead of int32_t - fix this
2021-08-08 21:48:19 +02:00
Autechre 70ca111a53 Update CHANGES.md 2021-08-08 12:46:19 +02:00
Autechre 80225daee0 Merge pull request #12764 from gblues/gblues/fix-missing-buttons
WIIU: Fix L3/R3 buttons
2021-08-08 12:45:57 +02:00
Nathan Strong feb4f266fa WIIU: Fix L3/R3 buttons
== DETAILS
After a bisect, the culprit was changing the gamepad interface from
returing a single button (bool) to multiple (int16).

The issue is that the Wii U gamepad (and presumably the Pro controller too)
have more than 16 buttons, which means some buttons get lost. Notably, L3 (18)
and R3 (17).

The solution: use int32 instead of int16.

I did a test build and confirmed that this change restores L3/R3 functionality
with the gamepad. Don't have a pro controller to test, but it should work too.
2021-08-07 23:23:33 -07:00
Autechre 34758d15ef Update CHANGES.md 2021-08-08 00:49:23 +02:00
twinaphex 6fe45a451d (Metal raster font) Fix severe font driver leaks 2021-08-08 00:42:56 +02:00
twinaphex f7ad73b494 No more leak in CFSearchPathForDirectoriesInDomains 2021-08-07 21:25:18 +02:00
twinaphex 8e46e46a40 Simplify CFSearchpathForDirectoriesInDomains - one less leak - not
out of the woods yet though
2021-08-07 21:14:38 +02:00
twinaphex 722e36001f Simplify CFSearchPathForDirectoriesInDomains 2021-08-07 21:05:22 +02:00
twinaphex 8a037a3091 Cleanup CFSearchPathForDirectoriesInDomains 2021-08-07 20:35:27 +02:00
Autechre f129a55a8a Update CHANGES.md 2021-08-07 20:26:24 +02:00
Autechre 390f914357 Merge pull request #12573 from markwkidd/wayland-input
wayland input driver multimouse/multigun fixup
2021-08-07 20:25:23 +02:00
Autechre 980647c9b8 Update CHANGES.md 2021-08-07 19:43:56 +02:00
Autechre 87c1800cb8 Update CHANGES.md 2021-08-07 19:35:14 +02:00
Autechre 4c227afb0d Merge pull request #12757 from ComradeEcho/bugfix/controller-duplication-bug
macOS controller duplication bug
2021-08-07 19:34:09 +02:00
ComradeEcho 35c2ec993b Remove code that duplicates controllers 2021-08-07 11:43:50 -05:00
ComradeEcho 86b297e0fd Merge branch 'libretro:master' into bugfix/controller-duplication-bug 2021-08-07 11:31:50 -05:00
twinaphex b513a3d166 (OSX) Prevent crash on startup on OSX Platforms with no ARC
enabled - CFSearchPathForDirectoriesInDomains - CFTypeRef
returned by NSSearchPathForDIrectoriesInDomains should not
be freed
2021-08-07 18:24:46 +02:00
Autechre c19c6a3ca8 Update CHANGES.md 2021-08-07 16:20:07 +02:00
Autechre a40d1ce8b6 Merge pull request #12759 from fjtrujy/ps2_gfx_alpha
Implement Alpha for the PS2_GFX driver
2021-08-07 16:14:49 +02:00
Autechre d9312d09a8 Merge pull request #12758 from QuarkTheAwesome/wiiu-ic-invalidaterange
(WiiU) Add ICInvalidateRange
2021-08-07 12:38:01 +02:00
Ash Logan 97db0291d2 (WiiU) Add ICInvalidateRange 2021-08-07 15:42:12 +10:00
Adie ce4fce12c0 Implement changes to fix macOS controller duplication bug 2021-08-06 22:02:43 -05:00
Autechre 1661d4e969 Merge pull request #12756 from sonninnos/winraw-alt-sticky
(WINRAW) Alt sticky fix
2021-08-07 03:54:43 +02:00
twinaphex f459472f6d Fix leaks - we were not honoring the ownership policy/create rule
for various CoreFoundation functions with 'Copy' or 'Create' in the title
2021-08-07 03:46:08 +02:00
sonninnos 6170fc45ae (WINRAW) Cleanups 2021-08-07 04:31:32 +03:00
twinaphex c1ed271a12 (Mac/IOHIDManager) Fix leak of elements_raw and elements in iohidmanager_hid_device_add_device 2021-08-07 03:30:17 +02:00
twinaphex 84a83ef43c (7zip) Use int64_t 2021-08-07 03:26:08 +02:00
sonninnos 079070daf7 (WINRAW) Prevent Alt getting stuck when Alt-Tabbing 2021-08-07 04:24:20 +03:00
Autechre 110882903c Merge pull request #12755 from Jamiras/cheevos_no_signed_char
(cheevos) address warning when using -fno-signed-char
2021-08-07 02:59:34 +02:00
Brian Weiss a5f8053533 address warning when using -fno-signed-char 2021-08-06 18:33:31 -06:00
Autechre b0e7a4db6a Merge pull request #12754 from libretro/remove-7zip-typedef
(7zip) Use normal stdint.h types that don't conflict with PowerPC Mac's OSTypes.h
2021-08-07 02:17:35 +02:00
twinaphex 9700a009c5 (7zip) Use normal stdint.h types that don't conflict with PowerPC
Mac's OSTypes.h
2021-08-07 01:43:08 +02:00
Autechre 64244cd73f Merge pull request #12753 from sonninnos/winraw-pointer
(WINRAW) Add pointer status
2021-08-06 23:09:31 +02:00
sonninnos 2178f9d36f (WINRAW) Add pointer status 2021-08-06 23:12:38 +03:00
Autechre 26c2259b11 Merge pull request #12748 from sonninnos/default-mouse-index
Change default mouse index to port index
2021-08-06 18:17:14 +02:00
sonninnos 60e25c5e3b Change default mouse index to port index 2021-08-06 17:42:39 +03:00
jdgleaver fe1f311a35 Add core option category support 2021-08-06 15:33:47 +01:00
Francisco Javier Trujillo Mata 885f9bbcc3 Implement Alpha for the PS2_GFX driver 2021-08-06 14:29:37 +02:00
Autechre 7a0dc3c4ca Merge pull request #12746 from ComradeEcho/bugfix/fix-debug-logging
Fix debug-level logging output.
2021-08-06 13:10:08 +02:00
ComradeEcho a803f652ab Merge branch 'libretro:master' into bugfix/fix-debug-logging 2021-08-06 03:09:42 -05:00
Autechre a2fb0847ae Merge pull request #12743 from sonninnos/mouse-display-name
Friendly names for mice where available
2021-08-06 00:12:04 +02:00
sonninnos bd3533f05d Friendly names for mice where available 2021-08-06 00:21:17 +03:00
Autechre 5dcec3819e Merge pull request #12742 from sonninnos/content-info
Show content info label+path rows always
2021-08-05 22:48:23 +02:00
sonninnos a58676709a Show content info label+path rows always 2021-08-05 21:28:08 +03:00
Autechre c6af4089b4 Merge pull request #12740 from sonninnos/winraw-alt-fix
(WINRAW) Alt key fix
2021-08-05 15:08:54 +02:00
sonninnos 4e90b731d3 (WINRAW) Alt key fix 2021-08-05 15:24:41 +03:00
twinaphex 5dd06ccfcd Get rid of duplicate input_keyboard_line_complete occurrences 2021-08-04 21:33:17 +02:00
Autechre 7b75dc4f9b Merge pull request #12737 from sonninnos/winraw-oem-keys
(WINRAW) Change legacy virtual keys to scan codes
2021-08-04 20:14:37 +02:00
sonninnos 2c47d94bf5 (WINRAW) Change legacy virtual keys to scan codes 2021-08-04 19:23:56 +03:00
Autechre e5dc368e20 Merge pull request #12735 from schellingb/rmsgpack_fixwrapintwrite
libretro-db fix writing of numerical values
2021-08-04 15:08:14 +02:00
Autechre 49632bbde9 Merge pull request #12733 from schellingb/explore_fixcrc32read
Fix CRC32 reading in explore menu
2021-08-03 19:53:01 +02:00
Autechre e58b2c9b6b Merge pull request #12734 from schellingb/rmsgpack_fixreadbigendian
Fix libretro-db loading on big endian platforms
2021-08-03 19:30:40 +02:00
Bernhard Schelling 9956ff041e Fix libretro-db loading on big endian platforms
Wrong casting did read garbage data for numerical values on big endian platforms.
Numerical values are used for array/map lengths so this could easily cause random crashes during parsing but also later while using the data.
Use union to avoid strict aliasing warnings.
2021-08-04 01:20:25 +09:00
Bernhard Schelling 2d1a657ba8 libretro-db fix writing of numerical values
Correctly write map lengths between 16 and 65535 to just 2 bytes and not 4.
Fix writing of numerical values between -31 and -1.
Fix writing of numerical values less than 256 on big endian platforms.
2021-08-04 01:15:21 +09:00
Bernhard Schelling 39275e8ce3 Fix CRC32 reading in explore
If CRC32 contained a zero byte strlen doesn't work
2021-08-03 23:38:37 +09:00
twinaphex bdba803909 wnd_proc_common_internal - move out code that was only relevant for
Winraw and put it into the Winraw specialized function callback, delay
initialization of mod variable until we use it
2021-08-03 13:46:58 +02:00
Adie 327f220857 Fix debug-level logging definitions
Both INFO and DEBUGGING log functions were outputting [INFO] logs.
I switched the debug log function to output debug logs instead of info logs, and changed the output of debug logs from [VERBOSE] to [DEBUG]
2021-08-02 22:58:39 -05:00
Nargash c844705665 Enable verbosity and logging before initial config file load 2021-08-02 20:31:48 -05:00
Mark W. Kidd 109f4fafec wayland input driver fixups 2021-08-02 18:05:24 -04:00
Autechre 0527d77de1 Merge pull request #12729 from libretro/revert-12420-Ocean_Blue_Ozone_Colour_theme
Revert "I have added a new theme for Ozone (Ocean Blue)"
2021-08-02 17:14:55 +02:00
Autechre f9c0cb198c Revert "I have added a new theme for Ozone (Ocean Blue)" 2021-08-02 17:14:45 +02:00
twinaphex e596bf7925 Buildfix for previous commit 2021-08-02 16:19:26 +02:00
twinaphex 2af9441d35 Create separate wnd_proc functions for winraw 2021-08-02 16:14:58 +02:00
Autechre f4b79ad13d Merge pull request #12727 from Jamiras/reset_challenge
(cheevos) hide challenge indicators when resetting
2021-08-02 15:47:41 +02:00
Autechre 0c7650c525 Merge pull request #12728 from amtz/udev-input
Limit udev device scan to subsystem 'input'
2021-08-02 15:47:23 +02:00
amtz d0612f906d Limit udev device scan to subsystem 'input'
This change makes the call to 'udev_enumerate_scan_devices' much faster.
In particular, for some bluetooth devices, this function may implicitly
read its battery's virtual file 'uevent', e.g.

/sys/devices/*/usb1/1-1/*/bluetooth/hci0/*/power_supply/hid-*-battery/uevent

Reading this file may (for unknown reasons) block up to 10 seconds.
Since udev_enumerate_scan_devices is called 4 times (for keyboard,
mouse, touchpad, and joypad) during startup this may cause a
considerable delay.

Limiting the scan to subsystem 'input' yields the same devices but makes
the scan faster and does not read 'uevent' of the input controller's
power_supply.
2021-08-02 13:17:00 +02:00
Brian Weiss 05b36ec374 hide challenge indicators when resetting 2021-08-01 19:54:51 -06:00
Autechre 1df4fa70e8 Update CHANGES.md 2021-08-01 22:38:06 +02:00
twinaphex 9dd06996c5 Skip state_manager_event_{deinit/init} when core type is dummy 2021-08-01 22:31:44 +02:00
Autechre c427e9d9ba Merge pull request #12420 from SecularSteve/Ocean_Blue_Ozone_Colour_theme
I have added a new theme for Ozone (Ocean Blue)
2021-08-01 22:22:26 +02:00
Autechre 18cc6b4bd9 Merge pull request #12545 from DisasterMo/testing
Move MENU_ENUM_LABEL_VALUE_ACHIEVEMENT_PAUSE_MENU to lbl.h
2021-08-01 22:17:06 +02:00
Autechre 2aee034a24 Update CHANGES.md 2021-08-01 22:15:08 +02:00
Autechre 10d7e4c643 Merge pull request #12724 from sonninnos/winraw-devicechange
(WINRAW) Trigger joypad driver reinit on DEVICECHANGE
2021-08-01 22:14:08 +02:00
sonninnos 2962707d5f (WINRAW) Trigger joypad driver reinit on DEVICECHANGE 2021-08-01 22:35:27 +03:00
Autechre 15d28fe2eb Merge pull request #12723 from QuarkTheAwesome/wiiu-salamander-ci-img 2021-08-01 06:19:06 +02:00
Ash Logan fe694b8f96 (WiiU) Use -wiiu build image rather than -devkitpro for salamander
A modern devkitPPC causes broken binaries at the moment, and recent 
changes to the wiiu image (wiiurpxtool) are missing
2021-08-01 14:14:57 +10:00
Autechre 8b1e816f77 Merge pull request #12721 from Xbox-Homebrew/master
replace win32 functions with UWP safe variants in UWP vfs driver
2021-07-31 21:01:46 +02:00
tunip3 9224329450 restore publisher name to libretro in identity element 2021-07-31 20:00:41 +01:00
Autechre 984d8e2584 Merge pull request #12717 from IlDucci/translationsupdatewithscript
Fetch translations from Crowdin 30-Jul-2021
2021-07-31 19:58:16 +02:00
Autechre 87f7a7f94d Merge pull request #12718 from Jamiras/cheevos_none
(cheevos) add messages for unknown game and network error
2021-07-31 19:58:09 +02:00
Autechre 85c73d523c Merge pull request #12720 from QuarkTheAwesome/wiiu-compression
(WiiU) Add RPX compression
2021-07-31 19:57:52 +02:00
Tunip3 be1a768bca improve uwp fileio by using from app variants whereever possible 2021-07-31 04:36:08 +01:00
Ash Logan 93649d9147 (WiiU) Compress RPX files w/ wiiurpxtool
Should be available on the buildbot now
2021-07-31 10:26:37 +10:00
Ash Logan 902c115d48 (WiiU) Add elf2rpl to clean target 2021-07-31 10:26:37 +10:00
Jamiras bb6911077a add messages for unknown game and network error 2021-07-30 11:16:12 -06:00
IlDucci 33ac1856f2 Fetch translations from Crowdin 30-Jul-2021 2021-07-30 17:06:13 +02:00
twinaphex 78341e5824 (D3D12) Fix some header includes 2021-07-30 15:18:56 +02:00
twinaphex ab9a4a95b1 (D3D12) Fix some header includes - probably a mistake that wiiu_dbg.h
was added to the d3d12.c driver
2021-07-30 15:16:14 +02:00
twinaphex b3aafd2f86 This makes the Explore tab show up again 2021-07-30 14:17:03 +02:00
Autechre b4ccf23701 Merge pull request #12708 from sonninnos/auto-mouse-grab
'Automatic Mouse Grab' option
2021-07-30 13:44:01 +02:00
Autechre 742e195172 Merge pull request #12700 from Jamiras/rapi_client
(cheevos) move client code into separate file
2021-07-30 13:11:08 +02:00
Autechre f831fe9ad0 Merge pull request #12712 from jdgleaver/gitlab-retrofw
(.gitlab-ci.yml) Add RetroFW target
2021-07-29 14:44:46 +02:00
jdgleaver e90f352c2f (.gitlab-ci.yml) Add RetroFW target 2021-07-29 13:18:52 +01:00
Autechre 0c2299396c Merge pull request #12711 from Poligraf/retrofw
Add retrofw port
2021-07-29 13:41:13 +02:00
Poligraf 9000e81498 Add retrofw port 2021-07-29 22:16:59 +12:00
Autechre 4714af546b Merge pull request #12710 from R-YaTian/master
libnx: Fix split joycons mode
2021-07-29 07:22:42 +02:00
twinaphex a40edc40e9 Bump version to 1.9.8 2021-07-29 06:22:58 +02:00
R-YaTian 1d988d374a libnx: Fix split joycons 2021-07-29 12:18:11 +08:00
Autechre d53ff1cc9b Update CHANGES.md 2021-07-29 06:13:33 +02:00
sonninnos 149beaf061 'Automatic Mouse Grab' option 2021-07-29 02:16:43 +03:00
Autechre 910d729d50 Merge pull request #12661 from markwkidd/menu-input
consolidate menu_input.h declarations
2021-07-29 01:14:06 +02:00
p-sam 0f5f8798ea libnx: input fixes
- fix poll missing for controller 2-8
- fix layout not applied correctly and hangs when splitting joycons
2021-07-28 21:49:09 +02:00
twinaphex 09d496b534 Rewrite DISPLAYLIST_AUDIO_SETTINGS_LIST 2021-07-28 17:36:35 +02:00
Jamiras 5ac432026a add helper function for accessing connection method 2021-07-27 21:02:14 -06:00
Autechre 8e9587f451 Merge pull request #12698 from Xbox-Homebrew/master
turn off core info cache by default on UWP
2021-07-26 21:22:16 +02:00
tunip3 9de0cc1ffe turn off core info cache by default on UWP 2021-07-26 20:17:35 +01:00
Autechre 0faddc91f7 Merge pull request #12696 from jdgleaver/override-fix
Ensure that config overrides and remaps are unloaded upon core initialisation failure and when core calls RETRO_ENVIRONMENT_SHUTDOWN
2021-07-26 19:12:27 +02:00
jdgleaver d2f8af553d Ensure that config overrides and remaps are unloaded upon core initialisation failure and when core calls RETRO_ENVIRONMENT_SHUTDOWN 2021-07-26 16:14:35 +01:00
Autechre 5c2f79aa29 Merge pull request #12694 from Xbox-Homebrew/master
Workaround Explore tab crash
2021-07-25 16:43:36 +02:00
twinaphex 9e1ad64e89 (winraw_input.c) Fixed some typos and style nits 2021-07-25 16:36:48 +02:00
Autechre 0d36cf2a4a Merge pull request #12692 from alphanu1/master
Fixed absolute co-ords for CRT and non CRT users
2021-07-25 16:34:30 +02:00
tunip3 61aeb982fd make it so that the explore tab is disabled by default on winrt devices 2021-07-25 14:35:02 +01:00
Ben Templeman 48e4b02fad Fixed absolute co-ords for CRT and non crt users
Fixed typo

added delay between winraw rect change to fix roslution changing issues.

added more comments

added delay reset

Fixed typo

updated comments

added RECT size to log

updated logging
2021-07-25 11:06:34 +01:00
Jamiras c9ca0489ed allow concurrent POST requests to same URL 2021-07-23 22:04:42 -06:00
Jamiras bb2cf59a12 Merge branch 'master' into rapi_client 2021-07-23 19:41:37 -06:00
Mark W. Kidd e3d2a9b614 Merge branch 'master' of http://github.com/markwkidd/retroarch into menu-input 2021-07-23 10:27:49 -04:00
Jamiras da8f257323 log retry delay when automatically retrying network failure 2021-07-18 09:49:30 -06:00
Mark W. Kidd 64672b4b63 consolidate menu_input.h declarations 2021-07-15 14:19:38 -04:00
Jamiras 41e25902a1 use non-HTTPS until everything is converted 2021-07-08 00:57:35 -06:00
Jamiras bc4a9a3696 separate ping task handler from retry task handler 2021-07-08 00:52:19 -06:00
Jamiras 46ffe5f4b2 use case-corrected username for server calls 2021-07-08 00:33:45 -06:00
Jamiras 7aca71e625 convert to rapi 2021-07-07 23:51:45 -06:00
Jamiras f556eba0a3 move async API code to cheevos_client.c 2021-07-07 19:59:57 -06:00
Michael Burgardt 1657d67182 Move MENU_ENUM_LABEL_VALUE_ACHIEVEMENT_PAUSE_MENU to lbl.h 2021-06-20 22:15:31 +02:00
SecularSteve c424315510 Made the text, icons and borders darker, fixed the sidebar gradient. 2021-05-23 22:44:42 +02:00
SecularSteve d75e53a11a Added new "Ocean Blue" theme for Ozone 2021-05-23 13:47:46 +02:00
SecularSteve d1300dbdb3 small fixes 2021-05-20 14:46:39 +02:00
SecularSteve b355217e6d small fixes 2021-05-20 14:45:21 +02:00
SecularSteve a6f8355c6f small fixes 2021-05-20 14:41:45 +02:00
SecularSteve ce474040af Added new "Ocean Blue" Ozone theme 2021-05-20 14:15:10 +02:00
SecularSteve 32f68e81d6 Added new "Ocean Blue" theme 2021-05-20 14:13:58 +02:00
SecularSteve 0bd49c59c6 Added new "Ocean Blue" theme 2021-05-20 14:11:00 +02:00
SecularSteve a1ff509276 Added new "Ocean Blue" theme (along with a small tutorial)
I also sorted all of floats of the other themes in order.
2021-05-20 14:10:13 +02:00
SecularSteve 8346c4eeff Added English hash for "Ocean Blue" 2021-05-20 14:00:17 +02:00
424 changed files with 14413 additions and 10908 deletions

No files matched your search

+2
View File
@@ -223,3 +223,5 @@ param.sfo
*.elf
*.self
*.vpk
/.vs
/deps/SPIRV-Cross/out/build/x64-Debug
+23 -1
View File
@@ -448,6 +448,28 @@ build-retroarch-rs90-odbeta-mips32:
- "cp -f libretro-common/audio/dsp_filters/*.dsp ${MEDIA_PATH}/${CI_PROJECT_NAME}/filters/audio"
- "cp -f gfx/video_filters/*.filt ${MEDIA_PATH}/${CI_PROJECT_NAME}/filters/video"
build-retroarch-retrofw-mips32:
image: $CI_SERVER_HOST:5050/libretro-infrastructure/libretro-build-dingux:odbeta
stage: build
variables:
MEDIA_PATH: .media
STRIP_BIN: 1
before_script:
- export NUMPROC=$(($(nproc)/3))
artifacts:
paths:
- retroarch
- retroarch_retrofw.opk
- ${MEDIA_PATH}
expire_in: 10 min
dependencies: []
script:
- "make -j$NUMPROC -f Makefile.retrofw"
- "mkdir -p ${MEDIA_PATH}/${CI_PROJECT_NAME}/filters/audio"
- "mkdir -p ${MEDIA_PATH}/${CI_PROJECT_NAME}/filters/video"
- "cp -f libretro-common/audio/dsp_filters/*.dsp ${MEDIA_PATH}/${CI_PROJECT_NAME}/filters/audio"
- "cp -f gfx/video_filters/*.filt ${MEDIA_PATH}/${CI_PROJECT_NAME}/filters/video"
build-retroarch-android-normal:
image: $CI_SERVER_HOST:5050/libretro-infrastructure/libretro-build-android:latest
stage: build
@@ -761,7 +783,7 @@ build-static-retroarch-wiiu:
- "mv .retroarch-precompiled/ retroarch-precompiled/"
build-static-retroarch-dummy-wiiu:
image: $CI_SERVER_HOST:5050/libretro-infrastructure/libretro-build-devkitpro:latest
image: $CI_SERVER_HOST:5050/libretro-infrastructure/libretro-build-wiiu:latest
stage: build
variables:
MEDIA_PATH: .media
+59
View File
@@ -1,5 +1,64 @@
# Future
# 1.9.8
- AUDIO/WINDOWS/WASAPI: Stop deactivating audio on fast forward
- CHEEVOS: Hide challenge indicators when resetting
- CHEEVOS: Support for more than 64 memory regions
- CHEEVOS: Automatically retry 'http error code -1'
- CONTENT INFORMATION: Show content info label+path rows always
- CORE OPTIONS: Core option categories implemented
- CORE OPTIONS: Add option to disable core option categories
- D3D10/11/12: Fix gfx_display_draw_texture - fixes OSK (On-Screen Keyboard) issues
- DATABASE: Fix heap-buffer-overflow when fetching CRC values
- DATABASE/EXPLORE: Fix CRC32 reading in explore menu
- DATABASE/LIBRETRODB: Fix writing of numerical values
- DATABASE/LIBRETRODB: Fix libretro-db loading on big endian platforms
- DUMMY CORE: Skip state_manager_event_{deinit/init} when core type is dummy, should skip warning spam 'Implementation uses threaded audio. Cannot use rewind..' when using rewind
- INPUT/UDEV: Limit udev device scan to subsystem 'input'
- INPUT/SDL2/WINDOWS: Fix keyboard event keycodes
- INPUT/WAYLAND: Fixes a bug where the first player's mouse, pointer, and lightgun are echoed to the other ports. Now, those other ports correctly report zero. In the future support for multiple mouselike devices will need to be added, which is a bigger project
- INPUT/WAYLAND: The driver now respects keyboard_mapping_blocked
- INPUT/WAYLAND: When possible, deprecated lightgun defines are replaced with the new ones. The coordinates are still using the old relative callbacks
- INPUT/WINRAW: Trigger joypad driver reinit on DEVICECHANGE - avoids fullscreen toggle
- INPUT/WINRAW: Alt sticky fix
- INPUT/WINRAW: Prevent Alt getting stuck when Alt-Tabbing
- INPUT/WINRAW: Add pointer status
- INPUT/WINRAW: Add missing analog keybinds
- LIBNX/SWITCH: Fix poll missing for controller 2-8
- LIBNX/SWITCH: Fix layout not applied correctly and hangs when splitting joycons
- LIBRETRO: Core options category API implemented
- LIBRETRO: Fix RETRO_ENVIRONMENT_SET_FASTFORWARDING_OVERRIDE callback when runahead is enabled
- LIBRETRO: Add environment callback for enabling core option menu visibility updates without toggling Quick Menu
- LOGGING: Starting logging and verbose mode before first config load
- LINUX: In some Linux Desktop Environments, like Budgie, task bar feature is unable to pin applications. With StartupWMClass= present in .desktop file, it is possible to pin the application
- LOCALIZATION: Fetch translations from Crowdin
- MENU: Relocate 'Manage Playlists' to top
- MENU: Fullscreen resolution width/height settings no longer require 'advanced settings'
- MENU/REFRESH RATE: Fix double notifications with refresh rate settings
- MENU/OZONE: Ensure the existence of values used in selection calculation
- MENU/OZONE/VULKAN: Casting to unsigned caused an integer overflow and after float promotion would lead to 'x' being a garbage value, leading to problems when this value was passed to vkCmdSetViewport. This stops Vulkan validation layers from complaining about it
- METAL: Fixed font driver memory leaks
- MOUSE: Change default mouse index to port index
- MOUSE: Friendly names for mice where available
- OSX: Fix some memory leaks
- OSX: Fix controller duplication bug
- PS2: Implement alpha for the video driver
- PS2: Aspect ratio handling
- RETROFW: Initial port
- UWP/XBOX: Enable Explore tab by default - seems to work fine
- UWP/XBOX: Fix startup issues with latest Xbox Dashboard updates - ANGLE cores still show up wrong
- UWP/XBOX: fix issue where files where opened as OPENALWAYS instead of OPENEXISTING this fixes beetle cores
- UWP/XBOX: fix issue where filesizes where not returned properly, this fixes loading arcade dat files
- UWP/TRANSLATION: Enabled translation services for both UWP MSVC2017 and 2019. No TTS speech yet.
- VIDEO: Fix refresh rate 59Hz rounding
- WINDOWS: Remember original refresh rate
- WINDOWS/VULKAN: Refresh rate fixes + cleanups
- WIIU: Fix L3/R3 buttons
- WIIU: Compress RPX libretro cores
- WIIU: Add ICInvalidateRange (necessary for JITs)
- WIIU: Slight filesystem optimisation
- WIIU: Add option for running without core info (emscripten-style)
# 1.9.7
- 3DS: Add unique ID's
- CRT/SWITCHRES: Fixed some Monitor index bugs ad updated to the latest SR2
+135
View File
@@ -0,0 +1,135 @@
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual identity
and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at:
* Via E-Mail to <libretro@gmail.com>, please include in the subject line
`RETROARCH COC` so that your e-mail may reach the correct party.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
at [https://www.contributor-covenant.org/translations][translations].
[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
+79 -44
View File
@@ -1,58 +1,93 @@
# Contributing to RetroArch
If you are a developer and want to contribute to the development of RetroArch, please read this.
If you have found a bug and want to submit a minor patch or a bug report, please read this as well.
If you are a developer who wishes to contribute to the development of _RetroArch_; or if you have
found a bug and wish to submit a minor patch and/or bug report, please read this document.
# Submitting a bug report
When submitting a bug report, make sure that the bug is local to RetroArch.
A bug in a libretro core or something deemed to be external is likely to be closed very fast.
If you still suspect a bug in RetroArch, make sure to test with several cores to make sure.
Active discussions happen on our [Discord](https://discordapp.com/invite/27Xxm2h), mostly within
the _Programming_ channel category. We value discussions that happen in real time around
these contributions.
If you have troubles building RetroArch on Linux/BSD/OSX, make sure to paste shell output of ./configure,
as well as config.log and shell output of make. If building on Windows, just paste shell output of make.
Please do note that contributors to _RetroArch_ do such contributions within their spare time.
We do prefer to keep a professional and non-aggressive atmosphere around the project, along
with any disagreements to be settled professionally without insults, name calling, or otherwise.
If there are any issues, we are willing to have discussions about it.
If the issue occurs during runtime, make sure to paste RetroArch's verbose log.
If using Phoenix frontend, you can find log in (File -> Show Log) after running.
In console, make sure to run with verbose (-v) flag.
## Submitting Bug Reports
# Pull Requests
Outside contributions are generally only accepted in the form of a pull request. The process is very simple.
Fork RetroArch, make your changes, and issue a pull request on GitHub. This can all be done within the browser.
The changes are reviewed, and might be merged in. If the pull request isn't acceptable at the time,
note that it's possible to continue pushing up commits to your branch.
Bug reports in _RetroArch_ may fall into one of two categories:
If you want to develop a larger feature,
we'd like to discuss this first (ideally on IRC) so that you don't risk developing something
that won't be merged. A pull request with a proof-of-concept is fine, but please indicate so.
* _RetroArch_ itself, the user interface and API around all of the various cores.
* Individual _Core_, of which interact with _RetroArch_.
When submitting a bug report, ensure that the report is submitted to the correct repository.
For _RetroArch_ itself, it is done by reporting a bug within the
[RetroArch](https://github.com/libretro/RetroArch) repository. For other cores, please use
the search function within the [libretro Organization](https://github.com/libretro) on
GitHub. Issues that are specific to a core and not _RetroArch_ are likely to be closed very
quickly. If an issue is suspected with _RetroArch_, please make sure to test with multiple
cores to be sure that is is not isolated.
If the issue occurs during runtime, please paste the verbose log output:
* If using the _Pheonix_ interface, the log will be in _File_ -> _Show Log_.
* If using the main interface, enable verbose logging with _Settings_ -> _Logging_ ->
_Logging Verbosity_. Ensure both _Log to File_ and _Timestamp log Files_ is enabled.
* Otherwise, run _RetroArch_ with the verbose (`-v`) flag.
If the error happens during compilation and/or building, paste the output of `./configure`
and `make` accordingly. If using an IDE, please paste any of the errors and log output.
## Submitting Pull Requests
Any and all contributions should be submitted through Pull Requests on
[GitHub](https://github.com/libretro/RetroArch/pulls). The process requires that you fork the
repository, make the appropriate changes, and then open a pull request on _GitHub_. If your
pull request is for a proof-of-concept then please indicate as such.
Your pull request will then be reviewed. There may be comments and requests for additional
changes to be made. It may also be possible that the changes will not be accepted. Otherwise, it
may be merged in when it is fully approved. The final approval of merge requests is at the
discretion of the project.
If you want to develop a larger feature or make broad changes, please do join our
[Discord](https://discordapp.com/invite/27Xxm2h) server to discuss. The discussion is
necessary to prevent the possibility of major work being done which will not be accepted at all.
## libretro API
If you wish to add functionality to libretro's API, it can take some time to merge in, because changes
to libretro API will affect other projects as well, and we highly value API/ABI stability.
Features will only be added when deemed *necessary* for a concrete libretro core to function properly.
Features will not be added on basis of hypothetical libretro implementations.
# Coding style
Having a consistent code style throughout the code base is highly valued.
Please look through the code to get a feel for the coding style.
A pull request may be asked to fix the coding style before submission.
In other cases, a pull request may be followed up with a "style nit commit".
If you wish to contribute additional functionality to _libretro_'s API, there are considerations
that must be accepted. Please note that because this API affects multiple different projects, we
highly value and require API and ABI stability and backwards-compatibility. Due to this
requirement, there will be additional scrutiny in reviews for this added functionality.
## Non-obvious things:
- Code should be both C89 and ISO C++ compatible. This dual requirement is for XBox360 and MSVC in general. Think of it as a C++ compatible subset of C99.
- Warnings are not allowed (-Wall). Make sure your code is warning-free. Note that warning sensitivity differs a bit across compiler versions.
- Using deprecated APIs is discouraged.
Any and all features will be added only when **necessary** for an existing _libretro_ core to
properly function. Hypothetical implementations of _libretro_ are not considered.
# Copyright Headers and AUTHORS
If you have contributed to a part of a source file (a chunk of code that's written by you),
you should add yourself to the copyright header in that file.
If you have contributed significantly
(a feature, a contribution you can "name", e.g. "Added audio driver foo"), you should add yourself to AUTHORS file.
We'd like your full name and email, and which features you have been part of.
## Coding style
# IRC
Active development happens on IRC. (#retroarch @ irc.freenode.org)
We value discussing things in "real-time".
We highly value a consistent code style throughout the entire code base, please make sure you look
through the existing code to get a feel for the coding style. When submitting a pull request, it may
be asked to fix any coding style issues before submission. In other cases, there may be a follow-up
pull request making the code style consistent.
# Commit Access
Contributors who show a track record of making good pull requests over time will eventually get commit access to the repo.
This typically happens when the "overhead" of looking through pull requests over time becomes a burden.
For full guidelines please see the [Coding Standards](https://docs.libretro.com/development/coding-standards/).
Some non-obvious things to be aware of:
- Code should be both C89 and ISO C++ compatible. This is a requirement for XBox 360 and MSVC to
properly build. Think of it as a C++ compatible subset of C99.
- There must be no warnings in your code (enabled by `-Wall` for GCC compilers), do also note that
different compilers may produce different warnings.
- Avoid using deprecated APIs, these will be removed in the future at some point.
## Copyright Headers and AUTHORS
If you have contributed a chunk of source code that is written to you, you should add yourself to
the copyright header in the file. If you have made a significant contribution you should add
yourself to the `AUTHORS` file, adding your full name, e-mail, and the feature you worked on.
## Commit Access
Contributors who show a good track record of pull requests over time may eventually
get commit access to the repository. This may happen when looking through pull requests
over long amounts of time becomes a burden.
+13 -9
View File
@@ -134,7 +134,7 @@ ifneq ($(findstring Darwin,$(OS)),)
MINVERFLAGS=
ifeq ($(shell uname -p),arm)
MINVERFLAGS = -mmacosx-version-min=10.15 -stdlib=libc++ # macOS (Metal, ARM 64bit)
MINVERFLAGS += -DDONT_WANT_ARM_OPTIMIZATIONS
MINVERFLAGS += -DDONT_WANT_ARM_ASM_OPTIMIZATIONS
else ifeq ($(HAVE_METAL),1)
MINVERFLAGS = -mmacosx-version-min=10.13 -stdlib=libc++ # macOS (Metal, x86 64bit)
else ifeq ($(shell uname -p),powerpc)
@@ -148,7 +148,7 @@ ifneq ($(findstring Darwin,$(OS)),)
# Build for a specific architecture when ARCH is defined as a switch
ifeq ($(ARCH),arm64)
MINVERFLAGS = -mmacosx-version-min=10.15 -stdlib=libc++ # macOS (Metal, ARM 64bit)
MINVERFLAGS += -DDONT_WANT_ARM_OPTIMIZATIONS
MINVERFLAGS += -DDONT_WANT_ARM_ASM_OPTIMIZATIONS
ARCHFLAGS = -arch arm64
else ifeq ($(ARCH),x86_64)
ifeq ($(HAVE_METAL),1)
@@ -277,6 +277,7 @@ OBJ += \
OBJ += \
$(LIBRETRO_COMM_DIR)/lists/linked_list.o \
$(LIBRETRO_COMM_DIR)/lists/nested_list.o \
$(LIBRETRO_COMM_DIR)/queues/generic_queue.o
ifneq ($(findstring Linux,$(OS)),)
@@ -301,6 +302,7 @@ OBJ += \
$(LIBRETRO_COMM_DIR)/file/file_path_io.o \
file_path_special.o \
$(LIBRETRO_COMM_DIR)/hash/lrc_hash.o \
input/input_driver.o \
input/common/input_hid_common.o \
led/led_driver.o \
gfx/video_coord_array.o \
@@ -336,6 +338,7 @@ endif
OBJ += \
core_info.o \
core_backup.o \
core_option_manager.o \
$(LIBRETRO_COMM_DIR)/file/config_file.o \
$(LIBRETRO_COMM_DIR)/file/config_file_userdata.o \
runtime_file.o \
@@ -2119,6 +2122,7 @@ ifeq ($(HAVE_NETWORKING), 1)
INCLUDE_DIRS += -Ideps/rcheevos/include
OBJ += cheevos/cheevos.o \
cheevos/cheevos_client.o \
cheevos/cheevos_menu.o \
cheevos/cheevos_parser.o \
$(LIBRETRO_COMM_DIR)/formats/cdfs/cdfs.o \
@@ -2138,6 +2142,9 @@ ifeq ($(HAVE_NETWORKING), 1)
deps/rcheevos/src/rcheevos/trigger.o \
deps/rcheevos/src/rcheevos/value.o \
deps/rcheevos/src/rhash/hash.o \
deps/rcheevos/src/rapi/rc_api_common.o \
deps/rcheevos/src/rapi/rc_api_runtime.o \
deps/rcheevos/src/rapi/rc_api_user.o \
deps/rcheevos/src/rurl/url.o
ifeq ($(HAVE_LUA), 1)
@@ -2417,13 +2424,6 @@ ifneq ($(findstring Win32,$(OS)),)
OBJ += led/drivers/led_win32_keyboard.o
endif
ifeq ($(HAVE_MATH_NEON), 1)
DEFINES += -DHAVE_MATH_NEON
INCLUDE_DIRS += -I$(DEPS_DIR)/math-neon/source
SOURCES := $(DEPS_DIR)/math-neon/source
OBJ += $(patsubst %.c,%.o,$(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c)))
endif
ifeq ($(HAVE_VITAGLES), 1)
DEFINES += -DHAVE_VITAGLES
INCLUDE_DIRS += -I$(DEPS_DIR)/Pigs-In-A-Blanket/include
@@ -2431,6 +2431,10 @@ ifeq ($(HAVE_VITAGLES), 1)
OBJ += $(patsubst %.c,%.o,$(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c)))
endif
ifeq ($(HAVE_WEBOS), 1)
DEFINES += -DWEBOS
endif
#####################################
### Android Play Feature Delivery ###
### (Play Store build core ###
+10 -3
View File
@@ -1,5 +1,6 @@
BUILD_FOR_PCSX2 = 0
DEBUG = 0
SCREEN_DEBUG = 0
HAVE_THREADS = 0
MUTE_WARNINGS = 1
PS2_IP = 192.168.1.10
@@ -27,14 +28,19 @@ INCDIR += -Ips2/include -Ilibretro-common/include -Ideps -Ideps/stb -Ideps/7zip
CFLAGS = $(OPTIMIZE_LV) $(DISABLE_WARNINGS) -ffast-math -fsingle-precision-constant
ASFLAGS = $(CFLAGS)
RARCH_DEFINES += -DPS2 -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DHAVE_SCREENSHOTS -DHAVE_REWIND -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_PATCH -DHAVE_CHEATS -DHAVE_RGUI
RARCH_DEFINES += -DPS2 -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DHAVE_SCREENSHOTS -DHAVE_REWIND -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_PATCH -DHAVE_CHEATS
RARCH_DEFINES += -DHAVE_ZLIB -DHAVE_NO_BUILTINZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_FILTERS_BUILTIN -DHAVE_7ZIP -D_7ZIP_ST -DHAVE_CC_RESAMPLER -DHAVE_AUDIOMIXER
RARCH_DEFINES += -DHAVE_VIDEO_FILTER -DHAVE_RGUI
RARCH_DEFINES += -DHAVE_DSP_FILTER
RARCH_DEFINES += -DHAVE_VIDEO_FILTER
LDFLAGS += -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ports/lib -L.
# Lib cdvd is needed to get proper time
LIBS += -lretro_ps2 -lpatches -lgskit -ldmakit -laudsrv -lmtap -lpadx -lz -lcdvd -lelf-loader
LIBS += -lretro_ps2 -lpatches -lgskit -ldmakit -laudsrv -lmtap -lpadx -lz -lcdvd -lelf-loader -lfileXio -lpoweroff
ifeq ($(SCREEN_DEBUG), 1)
LIBS += -ldebug
RARCH_DEFINES += -DSCREEN_DEBUG
endif
ifeq ($(BUILD_FOR_PCSX2), 1)
RARCH_DEFINES += -DBUILD_FOR_PCSX2
@@ -52,6 +58,7 @@ EE_OBJS += $(IRX_DIR)/mcman_irx.o $(IRX_DIR)/mcserv_irx.o
EE_OBJS += $(IRX_DIR)/usbd_irx.o $(IRX_DIR)/bdm_irx.o $(IRX_DIR)/bdmfs_vfat_irx.o $(IRX_DIR)/usbmass_bd_irx.o
EE_OBJS += $(IRX_DIR)/libsd_irx.o $(IRX_DIR)/audsrv_irx.o
EE_OBJS += $(IRX_DIR)/cdfs_irx.o
EE_OBJS += $(IRX_DIR)/ps2dev9_irx.o $(IRX_DIR)/ps2atad_irx.o $(IRX_DIR)/ps2hdd_irx.o $(IRX_DIR)/ps2fs_irx.o $(IRX_DIR)/poweroff_irx.o
EE_OBJS += $(IRX_DIR)/mtapman_irx.o $(IRX_DIR)/padman_irx.o
# Missing objecst on the PS2SDK
+8 -1
View File
@@ -1,5 +1,6 @@
BUILD_FOR_PCSX2 = 0
DEBUG = 0
SCREEN_DEBUG = 0
MUTE_WARNINGS = 1
PS2_IP = 192.168.1.150
@@ -30,7 +31,12 @@ RARCH_DEFINES += -DPS2 -DIS_SALAMANDER -DRARCH_CONSOLE
LIBDIR =
LDFLAGS =
LIBS = -lelf-loader -lpatches
LIBS = -lelf-loader -lpatches -lfileXio -lpoweroff
ifeq ($(SCREEN_DEBUG), 1)
LIBS += -ldebug
RARCH_DEFINES += -DSCREEN_DEBUG
endif
ifeq ($(BUILD_FOR_PCSX2), 1)
RARCH_DEFINES += -DBUILD_FOR_PCSX2
@@ -64,6 +70,7 @@ EE_OBJS += $(IRX_DIR)/sio2man_irx.o $ $(IRX_DIR)/iomanX_irx.o $(IRX_DIR)/fileXio
EE_OBJS += $(IRX_DIR)/mcman_irx.o $(IRX_DIR)/mcserv_irx.o
EE_OBJS += $(IRX_DIR)/usbd_irx.o $(IRX_DIR)/bdm_irx.o $(IRX_DIR)/bdmfs_vfat_irx.o $(IRX_DIR)/usbmass_bd_irx.o
EE_OBJS += $(IRX_DIR)/cdfs_irx.o
EE_OBJS += $(IRX_DIR)/ps2dev9_irx.o $(IRX_DIR)/ps2atad_irx.o $(IRX_DIR)/ps2hdd_irx.o $(IRX_DIR)/ps2fs_irx.o $(IRX_DIR)/poweroff_irx.o
EE_CFLAGS = $(CFLAGS)
EE_CXXFLAGS = $(CFLAGS)
+237
View File
@@ -0,0 +1,237 @@
#########################
## Toolchain variables ##
#########################
# Default toolchain directory
TOOLCHAIN_DIR=/opt/retrofw-toolchain
# All toolchain-related variables may be
# overridden via the command line
ifdef RETROFW_CC
CC = $(GCW0_CC)
else
CC = $(TOOLCHAIN_DIR)/usr/bin/mipsel-linux-gcc
endif
ifdef RETROFW_CXX
CXX = $(GCW0_CXX)
else
CXX = $(TOOLCHAIN_DIR)/usr/bin/mipsel-linux-g++
endif
ifdef RETROFW_STRIP
STRIP = $(GCW0_STRIP)
else
STRIP = $(TOOLCHAIN_DIR)/usr/bin/mipsel-linux-strip
endif
GCW0_SDL_CONFIG ?= $(TOOLCHAIN_DIR)/usr/mipsel-buildroot-linux-uclibc/sysroot/usr/bin/sdl-config
GCW0_FREETYPE_CONFIG ?= $(TOOLCHAIN_DIR)/usr/mipsel-buildroot-linux-uclibc/sysroot/usr/bin/freetype-config
#GCW0_MK_SQUASH_FS ?= $(TOOLCHAIN_DIR)/usr/bin/mksquashfs
GCW0_MK_SQUASH_FS ?= mksquashfs
GCW0_INC_DIR ?= $(TOOLCHAIN_DIR)/usr/mipsel-buildroot-linux-uclibc/sysroot/usr/include
GCW0_LIB_DIR ?= $(TOOLCHAIN_DIR)/usr/mipsel-buildroot-linux-uclibc/sysroot/usr/lib
#########################
#########################
PACKAGE_NAME = retroarch
RETROFW = 1
DEBUG ?= 0
DINGUX = 1
HAVE_SCREENSHOTS = 0
HAVE_REWIND = 1
HAVE_7ZIP = 1
HAVE_AL = 0
# ALSA freezes when switching back from menu
HAVE_ALSA = 0
HAVE_DSP_FILTER = 1
HAVE_VIDEO_FILTER = 1
HAVE_STATIC_VIDEO_FILTERS = 1
HAVE_STATIC_AUDIO_FILTERS = 1
HAVE_FILTERS_BUILTIN = 1
HAVE_BUILTINMBEDTLS = 0
HAVE_BUILTINZLIB = 1
HAVE_C99 = 1
HAVE_CC = 1
HAVE_CC_RESAMPLER = 1
HAVE_CHD = 1
HAVE_COMMAND = 0
HAVE_CXX = 1
HAVE_DR_MP3 = 1
HAVE_DYNAMIC = 1
HAVE_EGL = 0
HAVE_FREETYPE = 0
HAVE_GDI = 1
HAVE_GETADDRINFO = 0
HAVE_GETOPT_LONG = 1
HAVE_GLSL = 0
HAVE_HID = 1
HAVE_IBXM = 1
HAVE_IMAGEVIEWER = 1
HAVE_LANGEXTRA = 0
HAVE_LIBRETRODB = 1
HAVE_MENU = 1
HAVE_MENU_COMMON = 1
HAVE_GFX_WIDGETS = 0
HAVE_MMAP = 1
HAVE_OPENDINGUX_FBDEV = 0
HAVE_OPENGL = 0
HAVE_OPENGL1 = 0
HAVE_OPENGLES = 0
HAVE_OPENGLES3 = 0
HAVE_OPENGL_CORE = 0
HAVE_OPENSSL = 1
HAVE_OVERLAY = 0
HAVE_RBMP = 1
HAVE_RJPEG = 1
HAVE_RPILED = 0
HAVE_RPNG = 1
HAVE_RUNAHEAD = 0
HAVE_SDL_DINGUX = 1
HAVE_SHADERPIPELINE = 0
HAVE_STB_FONT = 0
HAVE_STB_IMAGE = 1
HAVE_STB_VORBIS = 1
HAVE_STDIN_CMD = 0
HAVE_STRCASESTR = 1
HAVE_THREADS = 1
HAVE_UDEV = 0
HAVE_RGUI = 1
HAVE_MATERIALUI = 0
HAVE_XMB = 0
HAVE_OZONE = 0
HAVE_ZLIB = 1
HAVE_CONFIGFILE = 1
HAVE_PATCH = 1
HAVE_CHEATS = 1
HAVE_CHEEVOS = 0
HAVE_LIBSHAKE = 0
#comment out for now not working
#HAVE_OSS =1
#HAVE_OSS_LIB =1
OS = Linux
TARGET = retroarch
OPK_NAME = retroarch_retrofw.opk
OBJ :=
LINK := $(CXX)
DEF_FLAGS := -march=mips32 -mtune=mips32 -mhard-float -ffast-math -fomit-frame-pointer
DEF_FLAGS += -mplt -mno-shared
DEF_FLAGS += -ffunction-sections -fdata-sections
DEF_FLAGS += -I. -Ideps -Ideps/stb -DDINGUX=1 -DRETROFW=1 -MMD
DEF_FLAGS += -Wall -Wno-unused-variable -flto
DEF_FLAGS += -std=gnu99 -D_GNU_SOURCE
LIBS := -ldl -lz -lrt -pthread
CFLAGS :=
CXXFLAGS := -fno-exceptions -fno-rtti -std=c++11 -D__STDC_CONSTANT_MACROS
ASFLAGS :=
LDFLAGS := -Wl,--gc-sections
INCLUDE_DIRS = -I$(GCW0_INC_DIR)
LIBRARY_DIRS = -L$(GCW0_LIB_DIR)
DEFINES := -DRARCH_INTERNAL -D_FILE_OFFSET_BITS=64 -UHAVE_STATIC_DUMMY
DEFINES += -DHAVE_C99=1 -DHAVE_CXX=1
DEFINES += -DHAVE_GETOPT_LONG=1 -DHAVE_STRCASESTR=1 -DHAVE_DYNAMIC=1
DEFINES += -DHAVE_FILTERS_BUILTIN
SDL_DINGUX_CFLAGS := $(shell $(GCW0_SDL_CONFIG) --cflags)
SDL_DINGUX_LIBS := $(shell $(GCW0_SDL_CONFIG) --libs)
FREETYPE_CFLAGS := $(shell $(GCW0_FREETYPE_CONFIG) --cflags)
FREETYPE_LIBS := $(shell $(GCW0_FREETYPE_CONFIG) --libs)
MMAP_LIBS = -lc
OBJDIR_BASE := obj-unix
ifeq ($(DEBUG), 1)
OBJDIR := $(OBJDIR_BASE)/debug
DEF_FLAGS += -O0 -g -DDEBUG -D_DEBUG
else
OBJDIR := $(OBJDIR_BASE)/release
DEF_FLAGS += -O2 -DNDEBUG
endif
include Makefile.common
DEF_FLAGS += $(INCLUDE_DIRS)
LDFLAGS += $(CFLAGS) $(CXXFLAGS) $(DEF_FLAGS)
CFLAGS += $(DEF_FLAGS)
CXXFLAGS += $(DEF_FLAGS)
HEADERS = $(wildcard */*/*.h) $(wildcard */*.h) $(wildcard *.h)
Q := @
RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ))
define DESKTOP_ENTRY
[Desktop Entry]
Name=RetroArch
Comment=Frontend for emulators, game engines
Exec=retroarch
Terminal=false
Type=Application
StartupNotify=true
Icon=retroarch
Categories=emulators;
X-OD-NeedsDownscaling=true
endef
export DESKTOP_ENTRY
all: $(TARGET) opk
-include $(RARCH_OBJ:.o=.d)
SYMBOL_MAP := -Wl,-Map=output.map
$(TARGET): $(RARCH_OBJ)
@$(if $(Q), $(shell echo echo LD $@),)
$(Q)$(LINK) -o $@ $(RARCH_OBJ) $(LIBS) $(LDFLAGS) $(LIBRARY_DIRS)
$(OBJDIR)/%.o: %.c
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CC $<),)
$(Q)$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c -o $@ $<
$(OBJDIR)/%.o: %.cpp
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CXX $<),)
$(Q)$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.m
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo OBJC $<),)
$(Q)$(CXX) $(OBJCFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.S $(HEADERS)
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo AS $<),)
$(Q)$(CC) $(CFLAGS) $(ASFLAGS) $(DEFINES) -c -o $@ $<
clean:
rm -rf $(OBJDIR_BASE)
rm -f $(TARGET)
rm -f *.d
rm -rf $(OPK_NAME)
opk: $(TARGET)
echo "$$DESKTOP_ENTRY" > default.retrofw.desktop
rm -f $(OPK_NAME)
cp media/ico_src/icon32.png retroarch.png
chmod +x retroarch
chmod 777 retroarch
ifeq ($(STRIP_BIN),1)
$(STRIP) --strip-unneeded retroarch
endif
$(GCW0_MK_SQUASH_FS) retroarch default.retrofw.desktop retroarch.png $(OPK_NAME) -all-root -no-xattrs -noappend -no-exports
rm -f default.retrofw.desktop retroarch.png
.PHONY: all clean opk
print-%:
@echo '$*=$($*)'
-1
View File
@@ -31,7 +31,6 @@ else
HAVE_UPDATE_ASSETS := 1
HAVE_ONLINE_UPDATER := 1
HAVE_NEON := 1
HAVE_MATH_NEON := 1
HAVE_DSP_FILTER := 1
HAVE_VIDEO_FILTER := 1
HAVE_SCREENSHOTS := 1
+242
View File
@@ -0,0 +1,242 @@
include version.all
$(call assert,$(call seq,$(TARGET_PREFIX),arm-webos-linux-gnueabi-),webOS SDK isn't setup properly. See https://github.com/webosbrew/meta-lg-webos-ndk#compile-program-by-command-line)
WEBOS_FREETYPE_CONFIG ?= $(SDKTARGETSYSROOT)/usr/bin/freetype-config
WEBOS_INC_DIR ?= $(SDKTARGETSYSROOT)/usr/include
WEBOS_LIB_DIR ?= $(SDKTARGETSYSROOT)/usr/lib
#########################
#########################
PACKAGE_NAME = com.retroarch
PACKAGE_VERSION := $(patsubst "%",%,$(RARCH_VERSION))
DEBUG ?= 0
HAVE_SCREENSHOTS = 0
HAVE_REWIND = 1
HAVE_7ZIP = 1
HAVE_ACCESSIBILITY = 1
HAVE_AL = 0
# ALSA freezes when switching back from menu
HAVE_ALSA = 0
HAVE_ANGLE = 0
HAVE_AUDIOIO = 0
HAVE_AUDIOMIXER = 1
HAVE_BLISSBOX = 0
HAVE_BSV_MOVIE = 1
HAVE_BUILTINBEARSSL = 0
HAVE_BUILTINFLAC = 1
HAVE_DSP_FILTER = 1
HAVE_VIDEO_FILTER = 1
HAVE_STATIC_VIDEO_FILTERS = 1
HAVE_STATIC_AUDIO_FILTERS = 1
HAVE_FILTERS_BUILTIN = 1
HAVE_BUILTINMBEDTLS = 1
HAVE_BUILTINZLIB = 1
HAVE_C99 = 1
HAVE_CC = 1
HAVE_CC_RESAMPLER = 1
HAVE_NEAREST_RESAMPLER = 1
HAVE_CHD = 1
HAVE_COMMAND = 1
HAVE_CXX = 1
HAVE_DR_MP3 = 1
HAVE_DYNAMIC = 1
HAVE_DYLIB = 1
HAVE_EGL = 0
HAVE_FREETYPE = 0
HAVE_GDI = 1
HAVE_GETADDRINFO = 1
HAVE_GETOPT_LONG = 1
HAVE_GLSL = 1
HAVE_GLSLANG = 0
HAVE_GLSLANG_HLSL = 0
HAVE_GLSLANG_OGLCOMPILER = 0
HAVE_GLSLANG_OSDEPENDENT = 0
HAVE_GLSLANG_SPIRV = 0
HAVE_GLSLANG_SPIRV_TOOLS = 0
HAVE_GLSLANG_SPIRV_TOOLS_OPT = 0
HAVE_HID = 1
HAVE_IBXM = 1
HAVE_IMAGEVIEWER = 1
HAVE_LANGEXTRA = 1
HAVE_LIBRETRODB = 1
HAVE_MENU = 1
HAVE_MENU_COMMON = 1
HAVE_NEON = 1
HAVE_NETPLAYDISCOVERY = 1
HAVE_NETPLAYDISCOVERY = 1
HAVE_NETWORK_CMD = 1
HAVE_NETWORKGAMEPAD = 1
HAVE_NETWORKING = 1
HAVE_GFX_WIDGETS = 1
HAVE_MMAP = 1
HAVE_ONLINE_UPDATER = 1
HAVE_OPENDINGUX_FBDEV = 0
HAVE_OPENGL = 0
HAVE_OPENGL1 = 0
HAVE_OPENGL_CORE = 0
HAVE_OPENGLES = 1
HAVE_OPENGLES3 = 0
HAVE_OPENGLES3_1 = 0
HAVE_OPENGLES3_2 = 0
HAVE_OPENSSL = 0
HAVE_OVERLAY = 1
HAVE_PULSE = 1
HAVE_RBMP = 1
HAVE_RJPEG = 1
HAVE_RPILED = 0
HAVE_RPNG = 1
HAVE_RUNAHEAD = 1
HAVE_SDL = 0
HAVE_SDL2 = 1
HAVE_SHADERPIPELINE = 1
HAVE_STB_FONT = 1
HAVE_STB_IMAGE = 1
HAVE_STB_VORBIS = 1
HAVE_STDIN_CMD = 0
HAVE_STRCASESTR = 1
HAVE_THREADS = 1
HAVE_UDEV = 0
HAVE_RGUI = 1
HAVE_MATERIALUI = 0
HAVE_XMB = 1
HAVE_OZONE = 1
HAVE_ZLIB = 1
HAVE_CONFIGFILE = 1
HAVE_PATCH = 1
HAVE_CHEATS = 1
HAVE_CHEEVOS = 1
HAVE_LIBSHAKE = 1
HAVE_UPDATE_ASSETS = 1
HAVE_UPDATE_CORES = 1
OS = Linux
TARGET = retroarch
OBJ :=
LINK := $(CXX)
DEF_FLAGS += -ffunction-sections -fdata-sections
DEF_FLAGS += -I. -Ideps -Ideps/stb -DWEBOS=1 -MMD
DEF_FLAGS += -Wall -Wno-unused-variable
LIBS := -ldl -lz -lrt -pthread
CFLAGS :=
CXXFLAGS := -fno-exceptions -fno-rtti -std=c++11 -D__STDC_CONSTANT_MACROS
ASFLAGS :=
LDFLAGS := -Wl,--gc-sections
INCLUDE_DIRS = -I$(WEBOS_INC_DIR)
LIBRARY_DIRS = -L$(WEBOS_LIB_DIR)
DEFINES := -DRARCH_INTERNAL -D_FILE_OFFSET_BITS=64 -UHAVE_STATIC_DUMMY
DEFINES += -DHAVE_C99=1 -DHAVE_CXX=1 -D_GNU_SOURCE
DEFINES += -DHAVE_GETOPT_LONG=1 -DHAVE_STRCASESTR=1 -DHAVE_DYNAMIC=1
DEFINES += -DHAVE_FILTERS_BUILTIN
DEFINES += -DHAVE_SDL2
DEFINES += -DHAVE_PULSE
DEFINES += -DHAVE_NETWORKING -DHAVE_ONLINE_UPDATER -DHAVE_UPDATE_ASSETS -DHAVE_UPDATE_CORES
SDL2_CFLAGS := $(shell pkg-config --cflags sdl2)
SDL2_LIBS := $(shell pkg-config --libs sdl2)
OPENGLES_LIBS = -lGLESv2
PULSE_LIBS = $(shell pkg-config --libs libpulse)
MMAP_LIBS = -lc
NEON_CFLAGS = -mfpu=neon
NEON_ASFLAGS = -mfpu=neon
NETWORKING_LIBS = -lc
OBJDIR_BASE := obj-unix
ifeq ($(DEBUG), 1)
OBJDIR := $(OBJDIR_BASE)/debug
DEF_FLAGS += -O0 -g -DDEBUG -D_DEBUG
else
OBJDIR := $(OBJDIR_BASE)/release
DEF_FLAGS += -O2 -DNDEBUG
endif
include Makefile.common
DEF_FLAGS += $(INCLUDE_DIRS)
LDFLAGS += $(CFLAGS) $(CXXFLAGS) $(DEF_FLAGS)
CFLAGS += $(DEF_FLAGS)
CXXFLAGS += $(DEF_FLAGS)
HEADERS = $(wildcard */*/*.h) $(wildcard */*.h) $(wildcard *.h)
Q := @
RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ))
define APPINFO
{
"id": "$(PACKAGE_NAME)",
"version": "$(PACKAGE_VERSION)",
"vendor": "webosbrew.org",
"title": "RetroArch",
"icon": "icon160.png",
"main": "retroarch",
"iconColor": "#333333",
"type": "native",
"appDescription": "Emulation frontend"
}
endef
export APPINFO
all: $(TARGET) ipk
-include $(RARCH_OBJ:.o=.d)
SYMBOL_MAP := -Wl,-Map=output.map
$(TARGET): $(RARCH_OBJ)
@$(if $(Q), $(shell echo echo LD $@),)
$(Q)$(LINK) -o $@ $(RARCH_OBJ) $(LIBS) $(LDFLAGS) $(LIBRARY_DIRS)
$(OBJDIR)/%.o: %.c
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CC $<),)
$(Q)$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c -o $@ $<
$(OBJDIR)/%.o: %.cpp
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CXX $<),)
$(Q)$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.m
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo OBJC $<),)
$(Q)$(CXX) $(OBJCFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.S $(HEADERS)
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo AS $<),)
$(Q)$(CC) $(CFLAGS) $(ASFLAGS) $(DEFINES) -c -o $@ $<
clean:
rm -rf $(OBJDIR_BASE)
rm -f $(TARGET)
rm -f *.d
rm -rf webos/*.ipk
rm -rf webos/dist
ipk: $(TARGET)
rm -rf webos/dist
mkdir -p webos/dist/lib
echo "$$APPINFO" > webos/dist/appinfo.json
cp -t webos/dist -vf $(TARGET) webos/icon160.png
cp -t webos/dist/lib -vf $(WEBOS_LIB_DIR)/libstdc++.so.6
$(STRIP) webos/dist/$(TARGET)
cd webos && ares-package dist
install: ipk
ares-install webos/$(PACKAGE_NAME)_$(PACKAGE_VERSION)_$(ARCH).ipk
launch: install
ares-launch com.retroarch
.PHONY: all clean ipk
print-%:
@echo '$*=$($*)'
+1 -1
View File
@@ -131,7 +131,7 @@ RARCH_CONSOLE = 1
#HAVE_LANGEXTRA := 1
HAVE_WIIUSB_HID := 1
HAVE_RARCH_EXEC := 1
HAVE_RSOUND := 1
HAVE_RSOUND := 0
APP_BOOTER_DIR = wii/app_booter
PLATOBJS := $(APP_BOOTER_DIR)/app_booter.binobj
+14 -4
View File
@@ -11,6 +11,7 @@ HAVE_RUNAHEAD = 1
WIIU_LOG_RPX = 0
BUILD_DIR = objs/wiiu
PC_DEVELOPMENT_TCP_PORT ?=
LOAD_WITHOUT_CORE_INFO ?= 0
ifeq ($(SALAMANDER_BUILD),1)
BUILD_DIR := $(BUILD_DIR)-salamander
@@ -85,6 +86,9 @@ else
ifeq ($(HAVE_RUNAHEAD),1)
DEFINES += -DHAVE_RUNAHEAD
endif
ifeq ($(LOAD_WITHOUT_CORE_INFO),1)
DEFINES += -DLOAD_WITHOUT_CORE_INFO
endif
OBJ += wiiu/shader_utils.o
OBJ += gfx/drivers/gx2_shaders/tex.o
@@ -327,17 +331,23 @@ $(BUILD_DIR)/$(TARGET).rpx.elf: $(OBJ) $(RPX_OBJ) libretro_wiiu.a wiiu/link_elf.
@$(if $(Q), echo LD $@,)
$(Q)$(LD) $(OBJ) $(RPX_OBJ) $(LDFLAGS) $(RPX_LDFLAGS) $(LIBDIRS) $(LIBS) -o $@
$(BUILD_DIR)/$(TARGET).rpx: $(BUILD_DIR)/$(TARGET).rpx.elf $(ELF2RPL) .$(TARGET).rpx.last
$(BUILD_DIR)/$(TARGET).large.rpx: $(BUILD_DIR)/$(TARGET).rpx.elf $(ELF2RPL) .$(TARGET).rpx.large.last
@$(if $(Q), echo ELF2RPL $@,)
@touch .$(TARGET).rpx.last
@touch .$(TARGET).rpx.large.last
$(Q)-$(ELF2RPL) $< $@
$(BUILD_DIR)/$(TARGET).rpx: $(BUILD_DIR)/$(TARGET).large.rpx .$(TARGET).rpx.last
@$(if $(Q), echo COMPRESS $@,)
@touch .$(TARGET).rpx.large.last
$(Q)wiiurpxtool -c $< $@
clean:
@$(if $(Q), echo $@,)
$(Q)rm -f $(OBJ) $(RPX_OBJ) $(HBL_ELF_OBJ) $(TARGET).elf $(TARGET).rpx.elf $(TARGET).rpx
$(Q)rm -f $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).rpx.elf $(BUILD_DIR)/$(TARGET).rpx
$(Q)rm -f .$(TARGET).elf.last .$(TARGET).rpx.elf.last .$(TARGET).rpx.last
$(Q)rm -f $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).rpx.elf $(BUILD_DIR)/$(TARGET).large.rpx $(BUILD_DIR)/$(TARGET).rpx
$(Q)rm -f .$(TARGET).elf.last .$(TARGET).rpx.elf.last .$(TARGET).rpx.large.last .$(TARGET).rpx.last
$(Q)rm -f $(OBJ:.o=.depend) $(RPX_OBJ:.o=.depend) $(HBL_ELF_OBJ:.o=.depend)
$(Q)$(MAKE) -C wiiu/wut/elf2rpl/ clean
.PHONY: clean all
.PRECIOUS: %.depend %.last
+1 -1
View File
@@ -49,7 +49,7 @@ static void *rwebaudio_init(const char *device, unsigned rate, unsigned latency,
rweb_audio_t *rwebaudio = (rweb_audio_t*)calloc(1, sizeof(rweb_audio_t));
if (!rwebaudio)
return NULL;
if (RWebAudioInit(latency) == 1)
if (RWebAudioInit(latency))
*new_rate = RWebAudioSampleRate();
return rwebaudio;
}
+1 -1
View File
@@ -141,7 +141,7 @@ static void *switch_thread_audio_init(const char *device, unsigned rate, unsigne
{
Result rc;
unsigned i;
uint32_t prio;
int32_t prio;
#ifndef HAVE_LIBNX
char names[8][0x20];
uint32_t num_names = 0;
+1 -1
View File
@@ -736,7 +736,7 @@ static ssize_t wasapi_write_ex(wasapi_t *w, const void * data, size_t size, DWOR
if (!write_avail)
{
if (WaitForSingleObject(w->write_event, ms) != WAIT_OBJECT_0)
return -1;
return 0;
if (!wasapi_flush_buffer(w, w->engine_buffer_size))
return -1;
+4 -4
View File
@@ -29,9 +29,9 @@
#include <audio/audio_resampler.h>
#if (defined(__ARM_NEON__) && !defined(DONT_WANT_ARM_OPTIMIZATIONS)) || defined(HAVE_NEON)
#ifndef HAVE_ARM_NEON_OPTIMIZATIONS
#define HAVE_ARM_NEON_OPTIMIZATIONS
#if (defined(__ARM_NEON__) && !defined(DONT_WANT_ARM_ASM_OPTIMIZATIONS)) || defined(HAVE_NEON)
#ifndef HAVE_ARM_NEON_ASM_OPTIMIZATIONS
#define HAVE_ARM_NEON_ASM_OPTIMIZATIONS
#endif
#endif
@@ -350,7 +350,7 @@ static void resampler_CC_upsample(void *re_, struct resampler_data *data)
data->output_frames = outp - (audio_frame_float_t*)data->data_out;
}
#elif defined(HAVE_ARM_NEON_OPTIMIZATIONS)
#elif defined(HAVE_ARM_NEON_ASM_OPTIMIZATIONS)
#define CC_RESAMPLER_IDENT "NEON"
+6 -6
View File
@@ -1341,8 +1341,8 @@ void cheat_manager_apply_rumble(struct item_cheat *cheat, unsigned int curr_valu
{
cheat->rumble_primary_end_time = current_time + (cheat->rumble_primary_duration * 1000);
cheat->rumble_secondary_end_time = current_time + (cheat->rumble_secondary_duration * 1000);
input_driver_set_rumble_state(cheat->rumble_port, RETRO_RUMBLE_STRONG, cheat->rumble_primary_strength);
input_driver_set_rumble_state(cheat->rumble_port, RETRO_RUMBLE_WEAK, cheat->rumble_secondary_strength);
input_set_rumble_state(cheat->rumble_port, RETRO_RUMBLE_STRONG, cheat->rumble_primary_strength);
input_set_rumble_state(cheat->rumble_port, RETRO_RUMBLE_WEAK, cheat->rumble_secondary_strength);
}
}
else
@@ -1354,24 +1354,24 @@ void cheat_manager_apply_rumble(struct item_cheat *cheat, unsigned int curr_valu
if (cheat->rumble_primary_end_time <= current_time)
{
if (cheat->rumble_primary_end_time != 0)
input_driver_set_rumble_state(cheat->rumble_port,
input_set_rumble_state(cheat->rumble_port,
RETRO_RUMBLE_STRONG, 0);
cheat->rumble_primary_end_time = 0;
}
else
{
input_driver_set_rumble_state(cheat->rumble_port,
input_set_rumble_state(cheat->rumble_port,
RETRO_RUMBLE_STRONG, cheat->rumble_primary_strength);
}
if (cheat->rumble_secondary_end_time <= current_time)
{
if (cheat->rumble_secondary_end_time != 0)
input_driver_set_rumble_state(cheat->rumble_port, RETRO_RUMBLE_WEAK, 0);
input_set_rumble_state(cheat->rumble_port, RETRO_RUMBLE_WEAK, 0);
cheat->rumble_secondary_end_time = 0;
}
else
input_driver_set_rumble_state(cheat->rumble_port, RETRO_RUMBLE_WEAK, cheat->rumble_secondary_strength);
input_set_rumble_state(cheat->rumble_port, RETRO_RUMBLE_WEAK, cheat->rumble_secondary_strength);
}
void cheat_manager_apply_retro_cheats(void)
+89 -517
View File
@@ -41,10 +41,6 @@
#include <rthreads/rthreads.h>
#endif
#ifdef HAVE_DISCORD
#include "../network/discord.h"
#endif
#ifdef HAVE_CHEATS
#include "../cheat_manager.h"
#endif
@@ -54,23 +50,20 @@
#endif
#include "cheevos.h"
#include "cheevos_client.h"
#include "cheevos_locals.h"
#include "cheevos_parser.h"
#include "../file_path_special.h"
#include "../paths.h"
#include "../command.h"
#include "../dynamic.h"
#include "../configuration.h"
#include "../performance_counters.h"
#include "../msg_hash.h"
#include "../retroarch.h"
#include "../core.h"
#include "../core_option_manager.h"
#include "../version.h"
#include "../frontend/frontend_driver.h"
#include "../network/net_http_special.h"
#include "../tasks/tasks_internal.h"
#include "../deps/rcheevos/include/rc_runtime.h"
@@ -89,42 +82,12 @@
* that name. */
#undef CHEEVOS_SAVE_JSON
/* Define this macro to log URLs. */
#undef CHEEVOS_LOG_URLS
/* Define this macro to have the password and token logged. THIS WILL DISCLOSE
* THE USER'S PASSWORD, TAKE CARE! */
#undef CHEEVOS_LOG_PASSWORD
/* Define this macro to log downloaded badge images. */
#undef CHEEVOS_LOG_BADGES
/* Define this macro to capture how long it takes to generate a hash */
#undef CHEEVOS_TIME_HASH
/* Number of usecs to wait between posting rich presence to the site. */
/* Keep consistent with SERVER_PING_FREQUENCY from RAIntegration. */
#define CHEEVOS_PING_FREQUENCY 2 * 60 * 1000000
enum rcheevos_async_io_type
{
CHEEVOS_ASYNC_RICHPRESENCE = 0,
CHEEVOS_ASYNC_AWARD_ACHIEVEMENT,
CHEEVOS_ASYNC_SUBMIT_LBOARD
};
typedef struct rcheevos_async_io_request
{
const char* success_message;
const char* failure_message;
int id;
int value;
int attempt_count;
char user_agent[256];
char type;
char hardcore;
} rcheevos_async_io_request;
static rcheevos_locals_t rcheevos_locals =
{
{0}, /* runtime */
@@ -135,9 +98,11 @@ static rcheevos_locals_t rcheevos_locals =
NULL, /* task_lock */
CMD_EVENT_NONE, /* queued_command */
#endif
{0}, /* token */
"", /* username */
"", /* token */
"N/A",/* hash */
"", /* user_agent_prefix */
"", /* user_agent_core */
#ifdef HAVE_MENU
NULL, /* menuitems */
0, /* menuitem_capacity */
@@ -146,6 +111,7 @@ static rcheevos_locals_t rcheevos_locals =
false,/* hardcore_active */
false,/* loaded */
true, /* core_supports */
false,/* network_error */
false,/* leaderboards_enabled */
false,/* leaderboard_notifications */
false /* leaderboard_trackers */
@@ -167,10 +133,6 @@ rcheevos_locals_t* get_rcheevos_locals(void)
#define CHEEVOS_MB(x) ((x) * 1024 * 1024)
/* Forward declaration */
static void rcheevos_async_task_callback(
retro_task_t* task, void* task_data, void* user_data, const char* error);
static void rcheevos_async_submit_lboard(rcheevos_locals_t *locals,
rcheevos_async_io_request* request);
static void rcheevos_validate_memrefs(rcheevos_locals_t* locals);
/*****************************************************************************
@@ -184,173 +146,6 @@ void rcheevos_log(const char *fmt, ...)
}
#endif
static int append_no_spaces(char* buffer, char* stop, const char* text)
{
char* ptr = buffer;
while (ptr < stop && *text)
{
if (*text == ' ')
{
*ptr++ = '_';
++text;
}
else
{
*ptr++ = *text++;
}
}
*ptr = '\0';
return (ptr - buffer);
}
static void rcheevos_get_user_agent(
rcheevos_locals_t *locals,
char *buffer, size_t len)
{
struct retro_system_info *system = runloop_get_libretro_system_info();
char* ptr;
/* if we haven't calculated the non-changing portion yet, do so now [retroarch version + os version] */
if (!locals->user_agent_prefix[0])
{
const frontend_ctx_driver_t *frontend = frontend_get_ptr();
int major, minor;
char tmp[64];
if (frontend && frontend->get_os)
{
frontend->get_os(tmp, sizeof(tmp), &major, &minor);
snprintf(locals->user_agent_prefix, sizeof(locals->user_agent_prefix),
"RetroArch/%s (%s %d.%d)", PACKAGE_VERSION, tmp, major, minor);
}
else
{
snprintf(locals->user_agent_prefix, sizeof(locals->user_agent_prefix),
"RetroArch/%s", PACKAGE_VERSION);
}
}
/* append the non-changing portion */
ptr = buffer + strlcpy(buffer, locals->user_agent_prefix, len);
/* if a core is loaded, append its information */
if (system && !string_is_empty(system->library_name))
{
char* stop = buffer + len - 1;
const char* path = path_get(RARCH_PATH_CORE);
*ptr++ = ' ';
if (!string_is_empty(path))
{
append_no_spaces(ptr, stop, path_basename(path));
path_remove_extension(ptr);
ptr += strlen(ptr);
}
else
{
ptr += append_no_spaces(ptr, stop, system->library_name);
}
if (system->library_version)
{
*ptr++ = '/';
ptr += append_no_spaces(ptr, stop, system->library_version);
}
}
*ptr = '\0';
}
#ifdef CHEEVOS_LOG_URLS
static void rcheevos_filter_url_param(char* url, char* param)
{
char *next;
size_t param_len = strlen(param);
char *start = strchr(url, '?');
if (!start)
start = url;
else
++start;
do
{
next = strchr(start, '&');
if (start[param_len] == '=' && memcmp(start, param, param_len) == 0)
{
if (next)
strcpy_literal(start, next + 1);
else if (start > url)
start[-1] = '\0';
else
*start = '\0';
return;
}
if (!next)
return;
start = next + 1;
} while (1);
}
#endif
static void rcheevos_log_url(const char* api, const char* url)
{
#ifdef CHEEVOS_LOG_URLS
#ifdef CHEEVOS_LOG_PASSWORD
CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s\n", api, url);
#else
char copy[256];
strlcpy(copy, url, sizeof(copy));
rcheevos_filter_url_param(copy, "p");
rcheevos_filter_url_param(copy, "t");
CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s\n", api, copy);
#endif
#else
(void)api;
(void)url;
#endif
}
static void rcheevos_log_post_url(
const char* api,
const char* url,
const char* post)
{
#ifdef CHEEVOS_LOG_URLS
#ifdef CHEEVOS_LOG_PASSWORD
if (post && post[0])
CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s&%s\n", api, url, post);
else
CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s\n", api, url);
#else
if (post && post[0])
{
char post_copy[2048];
strlcpy(post_copy, post, sizeof(post_copy));
rcheevos_filter_url_param(post_copy, "p");
rcheevos_filter_url_param(post_copy, "t");
if (post_copy[0])
CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s&%s\n", api, url, post_copy);
else
CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s\n", api, url);
}
else
{
CHEEVOS_LOG(RCHEEVOS_TAG "%s: %s\n", api, url);
}
#endif
#else
(void)api;
(void)url;
(void)post;
#endif
}
static void rcheevos_achievement_disabled(rcheevos_racheevo_t* cheevo, unsigned address)
{
@@ -402,22 +197,28 @@ static int rcheevos_init_memory(rcheevos_locals_t* locals)
{
rarch_system_info_t* system = runloop_get_system_info();
rarch_memory_map_t* mmaps = &system->mmaps;
struct retro_memory_descriptor descriptors[64];
struct retro_memory_descriptor* descriptors;
struct retro_memory_map mmap;
unsigned i;
int result;
descriptors = (struct retro_memory_descriptor*)malloc(mmaps->num_descriptors * sizeof(*descriptors));
if (!descriptors)
return 0;
mmap.descriptors = &descriptors[0];
mmap.num_descriptors = sizeof(descriptors) / sizeof(descriptors[0]);
if (mmaps->num_descriptors < mmap.num_descriptors)
mmap.num_descriptors = mmaps->num_descriptors;
mmap.num_descriptors = mmaps->num_descriptors;
/* RetroArch wraps the retro_memory_descriptor's in rarch_memory_descriptor_t's, pull them back out */
for (i = 0; i < mmap.num_descriptors; ++i)
memcpy(&descriptors[i], &mmaps->descriptors[i].core, sizeof(descriptors[0]));
rc_libretro_init_verbose_message_callback(rcheevos_handle_log_message);
return rc_libretro_memory_init(&locals->memory, &mmap,
result = rc_libretro_memory_init(&locals->memory, &mmap,
rcheevos_get_core_memory_info, locals->patchdata.console_id);
free(descriptors);
return result;
}
uint8_t* rcheevos_patch_address(unsigned address)
@@ -453,208 +254,6 @@ static unsigned rcheevos_peek(unsigned address, unsigned num_bytes, void* ud)
return 0;
}
static void rcheevos_async_award_achievement(
rcheevos_locals_t *locals,
rcheevos_async_io_request* request)
{
char buffer[256];
settings_t *settings = config_get_ptr();
int ret = rc_url_award_cheevo(buffer, sizeof(buffer),
settings->arrays.cheevos_username,
locals->token,
request->id,
request->hardcore,
locals->hash);
if (ret != 0)
{
CHEEVOS_ERR(RCHEEVOS_TAG "Buffer too small to create URL\n");
free(request);
return;
}
rcheevos_log_url("rc_url_award_cheevo", buffer);
task_push_http_transfer_with_user_agent(buffer, true, NULL,
request->user_agent, rcheevos_async_task_callback, request);
#ifdef HAVE_AUDIOMIXER
if (settings->bools.cheevos_unlock_sound_enable)
audio_driver_mixer_play_menu_sound(
AUDIO_MIXER_SYSTEM_SLOT_ACHIEVEMENT_UNLOCK);
#endif
}
static retro_time_t rcheevos_async_send_rich_presence(
rcheevos_locals_t *locals,
rcheevos_async_io_request* request)
{
char url[256], post_data[1024];
char buffer[256] = "";
const settings_t *settings = config_get_ptr();
const char *cheevos_username = settings->arrays.cheevos_username;
const bool cheevos_richpresence_enable = settings->bools.cheevos_richpresence_enable;
int ret;
if (cheevos_richpresence_enable)
rcheevos_get_richpresence(buffer, sizeof(buffer));
ret = rc_url_ping(url, sizeof(url), post_data, sizeof(post_data),
cheevos_username, locals->token, locals->patchdata.game_id, buffer);
if (ret < 0)
{
CHEEVOS_ERR(RCHEEVOS_TAG "buffer too small to create URL\n");
}
else
{
rcheevos_log_post_url("rc_url_ping", url, post_data);
rcheevos_get_user_agent(locals,
request->user_agent, sizeof(request->user_agent));
task_push_http_post_transfer_with_user_agent(url, post_data, true, "POST", request->user_agent, NULL, NULL);
}
#ifdef HAVE_DISCORD
if (settings->bools.discord_enable && discord_is_ready())
discord_update(DISCORD_PRESENCE_RETROACHIEVEMENTS);
#endif
/* Update rich presence every two minutes */
if (cheevos_richpresence_enable)
return cpu_features_get_time_usec() + CHEEVOS_PING_FREQUENCY;
/* Send ping every four minutes */
return cpu_features_get_time_usec() + CHEEVOS_PING_FREQUENCY * 2;
}
static void rcheevos_async_task_handler(retro_task_t* task)
{
rcheevos_async_io_request* request = (rcheevos_async_io_request*)
task->user_data;
switch (request->type)
{
case CHEEVOS_ASYNC_RICHPRESENCE:
/* update the task to fire again in two minutes */
if (request->id == (int)rcheevos_locals.patchdata.game_id)
task->when = rcheevos_async_send_rich_presence(&rcheevos_locals,
request);
else
{
/* game changed; stop the recurring task - a new one will
* be scheduled for the next game */
task_set_finished(task, 1);
free(request);
}
break;
case CHEEVOS_ASYNC_AWARD_ACHIEVEMENT:
rcheevos_async_award_achievement(&rcheevos_locals, request);
task_set_finished(task, 1);
break;
case CHEEVOS_ASYNC_SUBMIT_LBOARD:
rcheevos_async_submit_lboard(&rcheevos_locals, request);
task_set_finished(task, 1);
break;
}
}
static void rcheevos_async_schedule(
rcheevos_async_io_request* request, retro_time_t delay)
{
retro_task_t* task = task_init();
task->when = cpu_features_get_time_usec() + delay;
task->handler = rcheevos_async_task_handler;
task->user_data = request;
task->progress = -1;
task_queue_push(task);
}
static void rcheevos_async_task_callback(
retro_task_t* task, void* task_data, void* user_data, const char* error)
{
rcheevos_async_io_request *request = (rcheevos_async_io_request*)user_data;
http_transfer_data_t *data = (http_transfer_data_t*)task_data;
if (!error)
{
char buffer[224] = "";
/* Server did not return HTTP headers */
if (!data)
snprintf(buffer, sizeof(buffer), "Server communication error");
else if (data->status != 200)
{
/* Server returned an error via status code.
* Check to see if it also returned a JSON error */
if (!data->data || rcheevos_get_json_error(data->data, buffer, sizeof(buffer)) != RC_OK)
snprintf(buffer, sizeof(buffer), "HTTP error code: %d",
data->status);
}
else if (!data->data || !data->len)
{
/* Server sent an empty response without an error status code */
snprintf(buffer, sizeof(buffer), "No response from server");
}
else
{
/* Server sent a message - assume it's JSON
* and check for a JSON error */
rcheevos_get_json_error(data->data, buffer, sizeof(buffer));
}
if (buffer[0])
{
char errbuf[256];
snprintf(errbuf, sizeof(errbuf), "%s %u: %s",
request->failure_message, request->id, buffer);
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", errbuf);
switch (request->type)
{
case CHEEVOS_ASYNC_RICHPRESENCE:
/* Don't bother informing user when
* rich presence update fails */
break;
case CHEEVOS_ASYNC_AWARD_ACHIEVEMENT:
/* ignore already unlocked */
if (string_starts_with_size(buffer, "User already has ",
STRLEN_CONST("User already has ")))
break;
/* fallthrough to default */
default:
runloop_msg_queue_push(errbuf, 0, 5 * 60, false, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_ERROR);
break;
}
}
else
{
CHEEVOS_LOG(RCHEEVOS_TAG "%s %u\n", request->success_message, request->id);
}
free(request);
}
else
{
/* Double the wait between each attempt until we hit
* a maximum delay of two minutes.
* 250ms -> 500ms -> 1s -> 2s -> 4s -> 8s -> 16s -> 32s -> 64s -> 120s -> 120s... */
retro_time_t retry_delay =
(request->attempt_count > 8)
? (120 * 1000 * 1000)
: ((250 * 1000) << request->attempt_count);
request->attempt_count++;
rcheevos_async_schedule(request, retry_delay);
CHEEVOS_ERR(RCHEEVOS_TAG "%s %u: %s\n", request->failure_message,
request->id, error);
}
}
static void rcheevos_activate_achievements(rcheevos_locals_t *locals,
rcheevos_racheevo_t* cheevo, unsigned count, unsigned flags)
{
@@ -815,14 +414,7 @@ static int rcheevos_parse(rcheevos_locals_t *locals, const char* json)
}
}
/* schedule the first rich presence call in 30 seconds */
{
rcheevos_async_io_request* request = (rcheevos_async_io_request*)
calloc(1, sizeof(rcheevos_async_io_request));
request->id = locals->patchdata.game_id;
request->type = CHEEVOS_ASYNC_RICHPRESENCE;
rcheevos_async_schedule(request, CHEEVOS_PING_FREQUENCY / 4);
}
rcheevos_client_start_session(locals->patchdata.game_id);
/* validate the memrefs */
if (rcheevos_locals.memory.count != 0)
@@ -858,10 +450,10 @@ static rcheevos_racheevo_t* rcheevos_find_cheevo(unsigned id)
return NULL;
}
static void rcheevos_award_achievement(rcheevos_locals_t *locals,
void rcheevos_award_achievement(rcheevos_locals_t* locals,
rcheevos_racheevo_t* cheevo, bool widgets_ready)
{
char buffer[256] = "";
const settings_t *settings = config_get_ptr();
if (!cheevo)
return;
@@ -869,7 +461,7 @@ static void rcheevos_award_achievement(rcheevos_locals_t *locals,
CHEEVOS_LOG(RCHEEVOS_TAG "Awarding achievement %u: %s (%s)\n",
cheevo->id, cheevo->title, cheevo->description);
/* Deactivates the cheevo. */
/* Deactivates the acheivement. */
rc_runtime_deactivate_achievement(&locals->runtime, cheevo->id);
cheevo->active &= ~RCHEEVOS_ACTIVE_SOFTCORE;
@@ -878,49 +470,44 @@ static void rcheevos_award_achievement(rcheevos_locals_t *locals,
cheevo->unlock_time = cpu_features_get_time_usec();
/* Show the OSD message. */
{
/* Show the on screen message. */
#if defined(HAVE_GFX_WIDGETS)
if (widgets_ready)
gfx_widgets_push_achievement(cheevo->title, cheevo->badge);
else
if (widgets_ready)
{
gfx_widgets_push_achievement(cheevo->title, cheevo->badge);
}
else
#endif
{
snprintf(buffer, sizeof(buffer),
"Achievement Unlocked: %s", cheevo->title);
runloop_msg_queue_push(buffer, 0, 2 * 60, false, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
runloop_msg_queue_push(cheevo->description, 0, 3 * 60, false, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
}
{
char buffer[256];
snprintf(buffer, sizeof(buffer), "%s: %s",
msg_hash_to_str(MSG_ACHIEVEMENT_UNLOCKED), cheevo->title);
runloop_msg_queue_push(buffer, 0, 2 * 60, false, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
runloop_msg_queue_push(cheevo->description, 0, 3 * 60, false, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
}
/* Start the award task (unofficial achievement unlocks are not submitted). */
if (!(cheevo->active & RCHEEVOS_ACTIVE_UNOFFICIAL))
{
rcheevos_async_io_request *request = (rcheevos_async_io_request*)calloc(1, sizeof(rcheevos_async_io_request));
request->type = CHEEVOS_ASYNC_AWARD_ACHIEVEMENT;
request->id = cheevo->id;
request->hardcore = locals->hardcore_active ? 1 : 0;
request->success_message = "Awarded achievement";
request->failure_message = "Error awarding achievement";
rcheevos_get_user_agent(locals,
request->user_agent, sizeof(request->user_agent));
rcheevos_async_award_achievement(locals, request);
}
rcheevos_client_award_achievement(cheevo->id);
/* play the unlock sound */
#ifdef HAVE_AUDIOMIXER
if (settings->bools.cheevos_unlock_sound_enable)
audio_driver_mixer_play_menu_sound(
AUDIO_MIXER_SYSTEM_SLOT_ACHIEVEMENT_UNLOCK);
#endif
/* Take a screenshot of the achievement. */
#ifdef HAVE_SCREENSHOTS
if (settings->bools.cheevos_auto_screenshot)
{
settings_t *settings = config_get_ptr();
/* Take a screenshot of the achievement. */
if (settings && settings->bools.cheevos_auto_screenshot)
size_t shotname_len = sizeof(char) * 8192;
char *shotname = (char*)malloc(shotname_len);
if (shotname)
{
size_t shotname_len = sizeof(char) * 8192;
char *shotname = (char*)malloc(shotname_len);
if (!shotname)
return;
snprintf(shotname, shotname_len, "%s/%s-cheevo-%u",
settings->paths.directory_screenshot,
path_basename(path_get(RARCH_PATH_BASENAME)),
@@ -931,40 +518,18 @@ static void rcheevos_award_achievement(rcheevos_locals_t *locals,
shotname, true,
video_driver_cached_frame_has_valid_framebuffer(),
false, true))
CHEEVOS_LOG(
RCHEEVOS_TAG "Captured screenshot for achievement %u\n",
CHEEVOS_LOG(RCHEEVOS_TAG "Captured screenshot for achievement %u\n",
cheevo->id);
else
CHEEVOS_LOG(
RCHEEVOS_TAG "Failed to capture screenshot for achievement %u\n",
CHEEVOS_LOG(RCHEEVOS_TAG "Failed to capture screenshot for achievement %u\n",
cheevo->id);
free(shotname);
}
}
#endif
}
static void rcheevos_async_submit_lboard(rcheevos_locals_t *locals,
rcheevos_async_io_request* request)
{
char buffer[256];
settings_t *settings = config_get_ptr();
int ret = rc_url_submit_lboard(buffer, sizeof(buffer),
settings->arrays.cheevos_username,
locals->token, request->id, request->value);
if (ret != 0)
{
CHEEVOS_ERR(RCHEEVOS_TAG "Buffer too small to create URL\n");
free(request);
return;
}
rcheevos_log_url("rc_url_submit_lboard", buffer);
task_push_http_transfer_with_user_agent(buffer, true, NULL,
request->user_agent, rcheevos_async_task_callback, request);
}
static rcheevos_ralboard_t* rcheevos_find_lboard(unsigned id)
{
rcheevos_ralboard_t* lboard = rcheevos_locals.patchdata.lboards;
@@ -979,44 +544,31 @@ static rcheevos_ralboard_t* rcheevos_find_lboard(unsigned id)
return NULL;
}
static void rcheevos_lboard_submit(rcheevos_locals_t *locals,
static void rcheevos_lboard_submit(rcheevos_locals_t* locals,
rcheevos_ralboard_t* lboard, int value, bool widgets_ready)
{
char buffer[256];
char formatted_value[16];
/* Show the OSD message (regardless of notifications setting). */
rc_runtime_format_lboard_value(formatted_value, sizeof(formatted_value),
value, lboard->format);
CHEEVOS_LOG(RCHEEVOS_TAG "Submitting %s for leaderboard %u\n",
formatted_value, lboard->id);
/* Show the on-screen message (regardless of notifications setting). */
snprintf(buffer, sizeof(buffer), "Submitted %s for %s",
formatted_value, lboard->title);
formatted_value, lboard->title);
runloop_msg_queue_push(buffer, 0, 2 * 60, false, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
#if defined(HAVE_GFX_WIDGETS)
/* Hide the tracker */
if (widgets_ready)
if (gfx_widgets_ready())
gfx_widgets_set_leaderboard_display(lboard->id, NULL);
#endif
/* Start the submit task. */
{
rcheevos_async_io_request
*request = (rcheevos_async_io_request*)
calloc(1, sizeof(rcheevos_async_io_request));
request->type = CHEEVOS_ASYNC_SUBMIT_LBOARD;
request->id = lboard->id;
request->value = value;
request->success_message = "Submitted leaderboard";
request->failure_message = "Error submitting leaderboard";
rcheevos_get_user_agent(locals,
request->user_agent, sizeof(request->user_agent));
rcheevos_async_submit_lboard(locals, request);
}
/* Start the submit task */
rcheevos_client_submit_lboard_entry(lboard->id, value);
}
static void rcheevos_lboard_canceled(rcheevos_ralboard_t * lboard,
@@ -1125,11 +677,21 @@ void rcheevos_reset_game(bool widgets_ready)
/* Hide any visible trackers */
if (widgets_ready)
{
rcheevos_ralboard_t* lboard = rcheevos_locals.patchdata.lboards;
rcheevos_ralboard_t* lboard;
rcheevos_racheevo_t* cheevo;
unsigned i;
lboard = rcheevos_locals.patchdata.lboards;
for (i = 0; i < rcheevos_locals.patchdata.lboard_count; ++i, ++lboard)
gfx_widgets_set_leaderboard_display(lboard->id, NULL);
cheevo = rcheevos_locals.patchdata.core;
for (i = 0; i < rcheevos_locals.patchdata.core_count; ++i, ++cheevo)
gfx_widgets_set_challenge_display(cheevo->id, NULL);
cheevo = rcheevos_locals.patchdata.unofficial;
for (i = 0; i < rcheevos_locals.patchdata.unofficial_count; ++i, ++cheevo)
gfx_widgets_set_challenge_display(cheevo->id, NULL);
}
#endif
@@ -1448,21 +1010,20 @@ void rcheevos_hardcore_enabled_changed(void)
void rcheevos_validate_config_settings(void)
{
const rc_disallowed_setting_t* disallowed_settings;
core_option_manager_t* coreopts = NULL;
core_option_manager_t* coreopts = NULL;
struct retro_system_info* system = runloop_get_libretro_system_info();
int i;
if (!system->library_name || !rcheevos_locals.hardcore_active)
return;
disallowed_settings = rc_libretro_get_disallowed_settings(system->library_name);
if (disallowed_settings == NULL)
if (!(disallowed_settings = rc_libretro_get_disallowed_settings(system->library_name)))
return;
if (!rarch_ctl(RARCH_CTL_CORE_OPTIONS_LIST_GET, &coreopts))
return;
for (i = 0; i < coreopts->size; i++)
for (i = 0; i < (int)coreopts->size; i++)
{
const char* key = coreopts->opts[i].key;
const char* val = core_option_manager_get_val(coreopts, i);
@@ -1726,6 +1287,11 @@ static int rcheevos_iterate(rcheevos_coro_t* coro)
if (!coro->settings->bools.cheevos_enable)
CORO_STOP();
/* reset the network error flag */
rcheevos_locals.network_error = false;
/* reset the identified game id */
rcheevos_locals.patchdata.game_id = 0;
/* iterate over the possible hashes for the file being loaded */
rc_hash_initialize_iterator(&coro->iterator, coro->path, (uint8_t*)coro->data, coro->len);
#ifdef CHEEVOS_TIME_HASH
@@ -1755,6 +1321,9 @@ static int rcheevos_iterate(rcheevos_coro_t* coro)
CORO_STOP();
}
/* capture the identified game id in case we bail before fetching the patch data (not logged in) */
rcheevos_locals.patchdata.game_id = coro->gameid;
#ifdef CHEEVOS_JSON_OVERRIDE
{
size_t size = 0;
@@ -1988,7 +1557,7 @@ static int rcheevos_iterate(rcheevos_coro_t* coro)
CORO_GOSUB(RCHEEVOS_LOGIN);
ret = rc_url_get_patch(coro->url, sizeof(coro->url), coro->settings->arrays.cheevos_username, rcheevos_locals.token, coro->gameid);
ret = rc_url_get_patch(coro->url, sizeof(coro->url), rcheevos_locals.username, rcheevos_locals.token, coro->gameid);
if (ret < 0)
{
@@ -2206,7 +1775,9 @@ static int rcheevos_iterate(rcheevos_coro_t* coro)
CORO_STOP();
}
ret = rcheevos_get_token(coro->json, tok, sizeof(tok));
ret = rcheevos_get_token(coro->json,
rcheevos_locals.username, sizeof(rcheevos_locals.username),
tok, sizeof(tok));
if (ret != 0)
{
@@ -2229,12 +1800,12 @@ static int rcheevos_iterate(rcheevos_coro_t* coro)
char msg[256];
snprintf(msg, sizeof(msg),
"RetroAchievements: Logged in as \"%s\".",
coro->settings->arrays.cheevos_username);
rcheevos_locals.username);
msg[sizeof(msg) - 1] = 0;
runloop_msg_queue_push(msg, 0, 2 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
}
CHEEVOS_LOG(RCHEEVOS_TAG "logged in successfully\n");
CHEEVOS_LOG(RCHEEVOS_TAG "%s logged in successfully\n", rcheevos_locals.username);
strlcpy(rcheevos_locals.token, tok,
sizeof(rcheevos_locals.token));
@@ -2343,6 +1914,7 @@ static int rcheevos_iterate(rcheevos_coro_t* coro)
}
CHEEVOS_LOG(RCHEEVOS_TAG "Couldn't connect to server after 5 tries\n");
rcheevos_locals.network_error = true;
CORO_RET();
@@ -2362,7 +1934,7 @@ static int rcheevos_iterate(rcheevos_coro_t* coro)
for (coro->i = 0; coro->i < 2; coro->i++)
{
ret = rc_url_get_unlock_list(coro->url, sizeof(coro->url),
coro->settings->arrays.cheevos_username,
rcheevos_locals.username,
rcheevos_locals.token, coro->gameid, coro->i);
if (ret < 0)
@@ -2397,7 +1969,7 @@ static int rcheevos_iterate(rcheevos_coro_t* coro)
{
int ret = rc_url_post_playing(coro->url, sizeof(coro->url),
coro->settings->arrays.cheevos_username,
rcheevos_locals.username,
rcheevos_locals.token, coro->gameid);
if (ret < 0)
+675
View File
@@ -0,0 +1,675 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2019-2021 - Brian Weiss
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "cheevos_client.h"
#include "cheevos.h"
#include "../configuration.h"
#include "../paths.h"
#include "../version.h"
#include <string/stdstring.h>
#include <features/features_cpu.h>
#include "../frontend/frontend_driver.h"
#include "../network/net_http_special.h"
#include "../tasks/tasks_internal.h"
#ifdef HAVE_DISCORD
#include "../network/discord.h"
#endif
#include "../deps/rcheevos/include/rc_api_runtime.h"
/* Define this macro to log URLs. */
#undef CHEEVOS_LOG_URLS
/* Define this macro to have the password and token logged.
* THIS WILL DISCLOSE THE USER'S PASSWORD, TAKE CARE! */
#undef CHEEVOS_LOG_PASSWORD
/* Number of usecs to wait between posting rich presence to the site. */
/* Keep consistent with SERVER_PING_FREQUENCY from RAIntegration. */
#define CHEEVOS_PING_FREQUENCY 2 * 60 * 1000000
/****************************
* data types *
****************************/
enum rcheevos_async_io_type
{
CHEEVOS_ASYNC_RICHPRESENCE = 0,
CHEEVOS_ASYNC_AWARD_ACHIEVEMENT,
CHEEVOS_ASYNC_SUBMIT_LBOARD
};
typedef void (*rcheevos_async_handler)(int id,
http_transfer_data_t *data, char buffer[], size_t buffer_size);
typedef struct rcheevos_async_io_request
{
rc_api_request_t request;
rcheevos_async_handler handler;
int id;
int attempt_count;
const char* success_message;
const char* failure_message;
const char* user_agent;
char type;
} rcheevos_async_io_request;
/****************************
* forward declarations *
****************************/
static retro_time_t rcheevos_client_prepare_ping(rcheevos_async_io_request* request);
static void rcheevos_async_http_task_callback(
retro_task_t* task, void* task_data, void* user_data, const char* error);
/****************************
* user agent construction *
****************************/
static int append_no_spaces(char* buffer, char* stop, const char* text)
{
char* ptr = buffer;
while (ptr < stop && *text)
{
if (*text == ' ')
{
*ptr++ = '_';
++text;
}
else
{
*ptr++ = *text++;
}
}
*ptr = '\0';
return (int)(ptr - buffer);
}
void rcheevos_get_user_agent(rcheevos_locals_t *locals,
char *buffer, size_t len)
{
struct retro_system_info *system = runloop_get_libretro_system_info();
char* ptr;
/* if we haven't calculated the non-changing portion yet, do so now
* [retroarch version + os version] */
if (!locals->user_agent_prefix[0])
{
const frontend_ctx_driver_t *frontend = frontend_get_ptr();
int major, minor;
char tmp[64];
if (frontend && frontend->get_os)
{
frontend->get_os(tmp, sizeof(tmp), &major, &minor);
snprintf(locals->user_agent_prefix, sizeof(locals->user_agent_prefix),
"RetroArch/%s (%s %d.%d)", PACKAGE_VERSION, tmp, major, minor);
}
else
{
snprintf(locals->user_agent_prefix, sizeof(locals->user_agent_prefix),
"RetroArch/%s", PACKAGE_VERSION);
}
}
/* append the non-changing portion */
ptr = buffer + strlcpy(buffer, locals->user_agent_prefix, len);
/* if a core is loaded, append its information */
if (system && !string_is_empty(system->library_name))
{
char* stop = buffer + len - 1;
const char* path = path_get(RARCH_PATH_CORE);
*ptr++ = ' ';
if (!string_is_empty(path))
{
append_no_spaces(ptr, stop, path_basename(path));
path_remove_extension(ptr);
ptr += strlen(ptr);
}
else
{
ptr += append_no_spaces(ptr, stop, system->library_name);
}
if (system->library_version)
{
*ptr++ = '/';
ptr += append_no_spaces(ptr, stop, system->library_version);
}
}
*ptr = '\0';
}
#ifdef CHEEVOS_LOG_URLS
#ifndef CHEEVOS_LOG_PASSWORD
static void rcheevos_filter_url_param(char* url, char* param)
{
char *next;
size_t param_len = strlen(param);
char *start = strchr(url, '?');
if (!start)
start = url;
else
++start;
do
{
next = strchr(start, '&');
if (start[param_len] == '=' && memcmp(start, param, param_len) == 0)
{
if (next)
strcpy_literal(start, next + 1);
else if (start > url)
start[-1] = '\0';
else
*start = '\0';
return;
}
if (!next)
return;
start = next + 1;
} while (1);
}
#endif
#endif
void rcheevos_log_url(const char* api, const char* url)
{
#ifdef CHEEVOS_LOG_URLS
#ifdef CHEEVOS_LOG_PASSWORD
CHEEVOS_LOG(RCHEEVOS_TAG "GET %s\n", url);
#else
char copy[256];
strlcpy(copy, url, sizeof(copy));
rcheevos_filter_url_param(copy, "p");
rcheevos_filter_url_param(copy, "t");
CHEEVOS_LOG(RCHEEVOS_TAG "GET %s\n", copy);
#endif
#else
(void)api;
(void)url;
#endif
}
static void rcheevos_log_post_url(const char* url, const char* post)
{
#ifdef CHEEVOS_LOG_URLS
#ifdef CHEEVOS_LOG_PASSWORD
if (post && post[0])
CHEEVOS_LOG(RCHEEVOS_TAG "POST %s %s\n", url, post);
else
CHEEVOS_LOG(RCHEEVOS_TAG "POST %s\n", url);
#else
if (post && post[0])
{
char post_copy[2048];
strlcpy(post_copy, post, sizeof(post_copy));
rcheevos_filter_url_param(post_copy, "p");
rcheevos_filter_url_param(post_copy, "t");
if (post_copy[0])
CHEEVOS_LOG(RCHEEVOS_TAG "POST %s %s\n", url, post_copy);
else
CHEEVOS_LOG(RCHEEVOS_TAG "POST %s\n", url);
}
else
{
CHEEVOS_LOG(RCHEEVOS_TAG "POST %s\n", url);
}
#endif
#else
(void)url;
(void)post;
#endif
}
/****************************
* dispatch *
****************************/
static void rcheevos_async_retry_request(retro_task_t* task)
{
rcheevos_async_io_request* request = (rcheevos_async_io_request*)
task->user_data;
/* the timer task has done its job. let it dispose itself */
task_set_finished(task, 1);
/* start a new task for the HTTP call */
task_push_http_post_transfer_with_user_agent(request->request.url,
request->request.post_data, true, "POST", request->user_agent,
rcheevos_async_http_task_callback, request);
}
static void rcheevos_async_retry_request_after_delay(rcheevos_async_io_request* request, const char* error)
{
retro_task_t* task = task_init();
/* Double the wait between each attempt until we hit
* a maximum delay of two minutes.
* 250ms -> 500ms -> 1s -> 2s -> 4s -> 8s -> 16s -> 32s -> 64s -> 120s -> 120s... */
retro_time_t retry_delay = (request->attempt_count > 8)
? (120 * 1000 * 1000)
: ((250 * 1000) << request->attempt_count);
CHEEVOS_ERR(RCHEEVOS_TAG "%s %u: %s (automatic retry in %dms)\n", request->failure_message,
request->id, error, (int)retry_delay / 1000);
task->when = cpu_features_get_time_usec() + retry_delay;
task->handler = rcheevos_async_retry_request;
task->user_data = request;
task->progress = -1;
++request->attempt_count;
task_queue_push(task);
}
static void rcheevos_async_request_failed(rcheevos_async_io_request* request, const char* error)
{
if (request->type == CHEEVOS_ASYNC_RICHPRESENCE && request->attempt_count > 0)
{
/* only retry the ping once (in case of network hiccup), otherwise let
* the timer handle it after the normal ping period has elapsed */
CHEEVOS_ERR(RCHEEVOS_TAG "%s %u: %s\n", request->failure_message,
request->id, error);
}
else
{
/* automatically retry the request */
rcheevos_async_retry_request_after_delay(request, error);
}
}
static void rcheevos_async_http_task_callback(
retro_task_t* task, void* task_data, void* user_data, const char* error)
{
rcheevos_async_io_request *request = (rcheevos_async_io_request*)user_data;
http_transfer_data_t *data = (http_transfer_data_t*)task_data;
char buffer[224];
if (error)
{
/* there was a communication error */
rcheevos_async_request_failed(request, error);
return;
}
if (!data)
{
/* Server did not return HTTP headers */
strlcpy(buffer, "Server communication error", sizeof(buffer));
}
else if (!data->data || !data->len)
{
if (data->status <= 0)
{
/* something occurred which prevented the response from being processed.
* assume the server request hasn't happened and try again. */
snprintf(buffer, sizeof(buffer), "task status code %d", data->status);
rcheevos_async_request_failed(request, buffer);
return;
}
if (data->status != 200)
{
/* Server returned an error via status code. */
snprintf(buffer, sizeof(buffer), "HTTP error code %d", data->status);
}
else
{
/* Server sent an empty response without an error status code */
strlcpy(buffer, "No response from server", sizeof(buffer));
}
}
else
{
buffer[0] = '\0'; /* indicate success unless handler provides error */
/* Call appropriate handler to process the response */
if (request->handler)
{
/* NOTE: data->data is not null-terminated. Most handlers assume the
* response is properly formatted or will encounter a parse failure
* before reading past the end of the data */
request->handler(request->id, data, buffer, sizeof(buffer));
}
}
if (!buffer[0])
{
/* success */
if (request->success_message)
{
CHEEVOS_LOG(RCHEEVOS_TAG "%s %u\n", request->success_message, request->id);
}
}
else
{
/* encountered an error */
char errbuf[256];
snprintf(errbuf, sizeof(errbuf), "%s %u: %s",
request->failure_message, request->id, buffer);
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", errbuf);
switch (request->type)
{
case CHEEVOS_ASYNC_RICHPRESENCE:
/* Don't bother informing user when
* rich presence update fails */
break;
default:
runloop_msg_queue_push(errbuf, 0, 5 * 60, false, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_ERROR);
break;
}
}
rc_api_destroy_request(&request->request);
/* rich presence request will be reused on next ping - reset the attempt
* counter. for all other request types, free the request object */
if (request->type == CHEEVOS_ASYNC_RICHPRESENCE)
request->attempt_count = 0;
else
free(request);
}
static void rcheevos_async_begin_request(rcheevos_async_io_request* request,
rcheevos_async_handler handler, char type, int id,
const char* success_message, const char* failure_message)
{
request->handler = handler;
request->type = type;
request->id = id;
request->success_message = success_message;
request->failure_message = failure_message;
request->attempt_count = 0;
if (!request->user_agent)
request->user_agent = get_rcheevos_locals()->user_agent_core;
rcheevos_log_post_url(request->request.url, request->request.post_data);
task_push_http_post_transfer_with_user_agent(request->request.url,
request->request.post_data, true, "POST", request->user_agent,
rcheevos_async_http_task_callback, request);
}
static bool rcheevos_async_succeeded(int result,
const rc_api_response_t* response, char buffer[], size_t buffer_size)
{
if (result != RC_OK)
{
strlcpy(buffer, rc_error_str(result), buffer_size);
return false;
}
if (!response->succeeded)
{
strlcpy(buffer, response->error_message, buffer_size);
return false;
}
return true;
}
/****************************
* ping *
****************************/
static retro_time_t rcheevos_client_prepare_ping(rcheevos_async_io_request* request)
{
const rcheevos_locals_t* rcheevos_locals = get_rcheevos_locals();
const settings_t *settings = config_get_ptr();
const bool cheevos_richpresence_enable =
settings->bools.cheevos_richpresence_enable;
rc_api_ping_request_t api_params;
char buffer[256] = "";
memset(&api_params, 0, sizeof(api_params));
api_params.username = rcheevos_locals->username;
api_params.api_token = rcheevos_locals->token;
api_params.game_id = request->id;
if (cheevos_richpresence_enable)
{
rcheevos_get_richpresence(buffer, sizeof(buffer));
api_params.rich_presence = buffer;
}
rc_api_init_ping_request(&request->request, &api_params);
rcheevos_log_post_url(request->request.url, request->request.post_data);
#ifdef HAVE_DISCORD
if (settings->bools.discord_enable && discord_is_ready())
discord_update(DISCORD_PRESENCE_RETROACHIEVEMENTS);
#endif
/* Update rich presence every two minutes */
if (cheevos_richpresence_enable)
return cpu_features_get_time_usec() + CHEEVOS_PING_FREQUENCY;
/* Send ping every four minutes */
return cpu_features_get_time_usec() + CHEEVOS_PING_FREQUENCY * 2;
}
static void rcheevos_async_ping_handler(retro_task_t* task)
{
rcheevos_async_io_request* request = (rcheevos_async_io_request*)
task->user_data;
const rcheevos_locals_t* rcheevos_locals = get_rcheevos_locals();
if (request->id != (int)rcheevos_locals->patchdata.game_id)
{
/* game changed; stop the recurring task - a new one will
* be scheduled if a new game is loaded */
task_set_finished(task, 1);
/* request->request was destroyed in rcheevos_async_http_task_callback */
free(request);
return;
}
/* update the request and set the task to fire again in
* two minutes */
task->when = rcheevos_client_prepare_ping(request);
/* start the HTTP request */
task_push_http_post_transfer_with_user_agent(request->request.url,
request->request.post_data, true, "POST", request->user_agent,
rcheevos_async_http_task_callback, request);
}
/****************************
* start session *
****************************/
void rcheevos_client_start_session(unsigned game_id)
{
rcheevos_locals_t* rcheevos_locals = get_rcheevos_locals();
/* the core won't change while a session is active, so only
* calculate the user agent once */
rcheevos_get_user_agent(rcheevos_locals,
rcheevos_locals->user_agent_core,
sizeof(rcheevos_locals->user_agent_core));
/* force non-HTTPS until everything uses RAPI */
rc_api_set_host("http://retroachievements.org");
/* schedule the first rich presence call in 30 seconds */
{
rcheevos_async_io_request *request = (rcheevos_async_io_request*)
calloc(1, sizeof(rcheevos_async_io_request));
if (!request)
{
CHEEVOS_LOG(RCHEEVOS_TAG "Failed to allocate rich presence request\n");
}
else
{
retro_task_t* task = task_init();
request->id = game_id;
request->type = CHEEVOS_ASYNC_RICHPRESENCE;
request->user_agent = rcheevos_locals->user_agent_core;
request->failure_message = "Error sending ping";
task->handler = rcheevos_async_ping_handler;
task->user_data = request;
task->progress = -1;
task->when = cpu_features_get_time_usec() +
CHEEVOS_PING_FREQUENCY / 4;
task_queue_push(task);
}
}
}
/****************************
* award achievement *
****************************/
static void rcheevos_async_award_achievement_callback(int id,
http_transfer_data_t *data, char buffer[], size_t buffer_size)
{
rc_api_award_achievement_response_t api_response;
int result = rc_api_process_award_achievement_response(&api_response, data->data);
if (rcheevos_async_succeeded(result, &api_response.response, buffer, buffer_size))
{
if (api_response.awarded_achievement_id != id)
{
snprintf(buffer, buffer_size, "Achievement %u awarded instead",
api_response.awarded_achievement_id);
}
else if (api_response.response.error_message)
{
/* previously unlocked achievements are returned as a "successful" error */
CHEEVOS_LOG(RCHEEVOS_TAG "Achievement %u: %s\n",
id, api_response.response.error_message);
}
}
rc_api_destroy_award_achievement_response(&api_response);
}
void rcheevos_client_award_achievement(unsigned achievement_id)
{
rcheevos_async_io_request *request = (rcheevos_async_io_request*)
calloc(1, sizeof(rcheevos_async_io_request));
if (!request)
{
CHEEVOS_LOG(RCHEEVOS_TAG "Failed to allocate unlock request for achievement %u\n",
achievement_id);
}
else
{
const rcheevos_locals_t* rcheevos_locals = get_rcheevos_locals();
rc_api_award_achievement_request_t api_params;
memset(&api_params, 0, sizeof(api_params));
api_params.username = rcheevos_locals->username;
api_params.api_token = rcheevos_locals->token;
api_params.achievement_id = achievement_id;
api_params.hardcore = rcheevos_locals->hardcore_active ? 1 : 0;
api_params.game_hash = rcheevos_locals->hash;
rc_api_init_award_achievement_request(&request->request, &api_params);
rcheevos_async_begin_request(request,
rcheevos_async_award_achievement_callback,
CHEEVOS_ASYNC_AWARD_ACHIEVEMENT, achievement_id,
"Awarded achievement",
"Error awarding achievement");
}
}
/****************************
* submit leaderboard *
****************************/
static void rcheevos_async_submit_lboard_entry_callback(int id,
http_transfer_data_t* data, char buffer[], size_t buffer_size)
{
rc_api_submit_lboard_entry_response_t api_response;
int result = rc_api_process_submit_lboard_entry_response(&api_response, data->data);
if (rcheevos_async_succeeded(result, &api_response.response, buffer, buffer_size))
{
/* not currently doing anything with the response */
}
rc_api_destroy_submit_lboard_entry_response(&api_response);
}
void rcheevos_client_submit_lboard_entry(unsigned leaderboard_id, int value)
{
rcheevos_async_io_request *request = (rcheevos_async_io_request*)
calloc(1, sizeof(rcheevos_async_io_request));
if (!request)
{
CHEEVOS_LOG(RCHEEVOS_TAG "Failed to allocate request for lboard %u submit\n",
leaderboard_id);
}
else
{
const rcheevos_locals_t* rcheevos_locals = get_rcheevos_locals();
rc_api_submit_lboard_entry_request_t api_params;
memset(&api_params, 0, sizeof(api_params));
api_params.username = rcheevos_locals->username;
api_params.api_token = rcheevos_locals->token;
api_params.leaderboard_id = leaderboard_id;
api_params.score = value;
api_params.game_hash = rcheevos_locals->hash;
rc_api_init_submit_lboard_entry_request(&request->request, &api_params);
rcheevos_async_begin_request(request,
rcheevos_async_submit_lboard_entry_callback,
CHEEVOS_ASYNC_SUBMIT_LBOARD, leaderboard_id,
"Submitted leaderboard",
"Error submitting leaderboard");
}
}
+32
View File
@@ -0,0 +1,32 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2019-2021 - Brian Weiss
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __RARCH_CHEEVOS_CLIENT_H
#define __RARCH_CHEEVOS_CLIENT_H
#include "cheevos_locals.h"
RETRO_BEGIN_DECLS
void rcheevos_client_start_session(unsigned game_id);
void rcheevos_client_award_achievement(unsigned achievement_id);
void rcheevos_client_submit_lboard_entry(unsigned leaderboard_id, int value);
void rcheevos_log_url(const char* api, const char* url);
void rcheevos_get_user_agent(rcheevos_locals_t *locals, char *buffer, size_t len);
RETRO_END_DECLS
#endif /* __RARCH_CHEEVOS_MENU_H */
+3
View File
@@ -133,9 +133,11 @@ typedef struct rcheevos_locals_t
enum event_command queued_command; /* action queued by background thread to be run on main thread */
#endif
char username[32]; /* case-corrected username */
char token[32]; /* user's session token */
char hash[33]; /* retroachievements hash for current content */
char user_agent_prefix[128]; /* RetroArch/OS version information */
char user_agent_core[256]; /* RetroArch/OS/Core version information */
#ifdef HAVE_MENU
rcheevos_menuitem_t* menuitems; /* array of items for the achievements quick menu */
@@ -146,6 +148,7 @@ typedef struct rcheevos_locals_t
bool hardcore_active; /* hardcore functionality is active */
bool loaded; /* load task has completed */
bool core_supports; /* false if core explicitly disables achievements */
bool network_error; /* hash lookup or login failed with network error */
bool leaderboards_enabled; /* leaderboards are enabled */
bool leaderboard_notifications; /* leaderboard notifications are enabled */
bool leaderboard_trackers; /* leaderboard trackers are enabled */
+16
View File
@@ -662,6 +662,22 @@ void rcheevos_menu_populate(void* data)
MENU_ENUM_LABEL_CANNOT_ACTIVATE_ACHIEVEMENTS_WITH_THIS_CORE,
FILE_TYPE_NONE, 0, 0);
}
else if (rcheevos_locals->network_error)
{
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETWORK_ERROR),
msg_hash_to_str(MENU_ENUM_LABEL_NETWORK_ERROR),
MENU_ENUM_LABEL_NETWORK_ERROR,
FILE_TYPE_NONE, 0, 0);
}
else if (!rcheevos_locals->patchdata.game_id)
{
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_UNKNOWN_GAME),
msg_hash_to_str(MENU_ENUM_LABEL_UNKNOWN_GAME),
MENU_ENUM_LABEL_UNKNOWN_GAME,
FILE_TYPE_NONE, 0, 0);
}
else if (!rcheevos_locals->token[0])
{
menu_entries_append_enum(info->list,
+5 -2
View File
@@ -23,6 +23,7 @@
#define CHEEVOS_JSON_KEY_BADGENAME 0x887685d9U
#define CHEEVOS_JSON_KEY_CONSOLE_ID 0x071656e5U
#define CHEEVOS_JSON_KEY_TOKEN 0x0e2dbd26U
#define CHEEVOS_JSON_KEY_USERNAME 0x7c8da264U
#define CHEEVOS_JSON_KEY_FLAGS 0x0d2e96b2U
#define CHEEVOS_JSON_KEY_LEADERBOARDS 0xf1247d2dU
#define CHEEVOS_JSON_KEY_RICHPRESENCE 0xf18dd230U
@@ -149,14 +150,16 @@ static int rcheevos_get_value(const char* json, unsigned key_hash,
Returns the token or the error message
*****************************************************************************/
int rcheevos_get_token(const char* json, char* token, size_t length)
int rcheevos_get_token(const char* json, char* username, size_t username_length,
char* token, size_t length)
{
rcheevos_get_value(json, CHEEVOS_JSON_KEY_ERROR, token, length);
if (!string_is_empty(token))
return -1;
return rcheevos_get_value(json, CHEEVOS_JSON_KEY_TOKEN, token, length);
return rcheevos_get_value(json, CHEEVOS_JSON_KEY_TOKEN, token, length) +
rcheevos_get_value(json, CHEEVOS_JSON_KEY_USERNAME, username, username_length);
}
int rcheevos_get_json_error(const char* json, char* token, size_t length)
+3 -1
View File
@@ -23,7 +23,9 @@ RETRO_BEGIN_DECLS
typedef void (*rcheevos_unlock_cb_t)(unsigned id, void* userdata);
int rcheevos_get_json_error(const char* json, char* token, size_t length);
int rcheevos_get_token(const char* json, char* token, size_t length);
int rcheevos_get_token(const char* json, char* username, size_t username_length,
char* token, size_t length);
int rcheevos_get_patchdata(const char* json, rcheevos_rapatchdata_t* patchdata);
void rcheevos_free_patchdata(rcheevos_rapatchdata_t* patchdata);
+69 -21
View File
@@ -66,7 +66,7 @@
#elif defined(_XBOX1) || defined(GEKKO) || defined(ANDROID)
#define DEFAULT_ASPECT_RATIO 1.3333f
#else
#define DEFAULT_ASPECT_RATIO -1.0f
#define DEFAULT_ASPECT_RATIO 1.3333f
#endif
#if defined(GEKKO)
@@ -75,7 +75,7 @@
#define DEFAULT_TOUCH_SCALE 1
#if defined(RARCH_MOBILE) || defined(HAVE_LIBNX) || defined(__WINRT__)
#if defined(RARCH_MOBILE) || defined(HAVE_LIBNX) || defined(__WINRT__) || defined(EMSCRIPTEN)
#define DEFAULT_POINTER_ENABLE true
#else
#define DEFAULT_POINTER_ENABLE false
@@ -222,10 +222,50 @@
#define DEFAULT_MONITOR_INDEX 0
/* Window */
/* Window size. A value of 0 uses window scale
* multiplied by the core framebuffer size. */
#define DEFAULT_WINDOW_WIDTH 1280
/* DEFAULT_WINDOW_DECORATIONS:
Whether to show the usual window decorations like border, titlebar etc. */
#ifdef WEBOS
#define DEFAULT_WINDOW_DECORATIONS false
#else
#define DEFAULT_WINDOW_DECORATIONS true
#endif
/* Amount of transparency to use for the main window.
* 1 is the most transparent while 100 is opaque. */
#define DEFAULT_WINDOW_OPACITY 100
/* DEFAULT_WINDOW_SAVE_POSITIONS:
* Whether to remember window positions
* NOTE: Only enabled for desktop Windows
* at present. */
#define DEFAULT_WINDOW_SAVE_POSITIONS false
/* Whether to use custom (fixed size)
* window dimensions in windowed mode. */
#ifdef WEBOS
#define DEFAULT_WINDOW_CUSTOM_SIZE_ENABLE true
#else
#define DEFAULT_WINDOW_CUSTOM_SIZE_ENABLE false
#endif
/* Window dimensions when using a fixed size
* window. A value of 0 disables fixed size
* windows, using nominal dimensions of
* window scale multiplied by the core
* framebuffer size. */
#if defined(WEBOS)
#define DEFAULT_WINDOW_WIDTH 1920
#define DEFAULT_WINDOW_HEIGHT 1080
#else
#define DEFAULT_WINDOW_WIDTH 1280
#define DEFAULT_WINDOW_HEIGHT 720
#endif
/* Maximum auto-set window dimensions
* when not using a fixed size window */
#define DEFAULT_WINDOW_AUTO_WIDTH_MAX 1920
#define DEFAULT_WINDOW_AUTO_HEIGHT_MAX 1080
/* Fullscreen resolution. A value of 0 uses the desktop
* resolution. */
@@ -240,20 +280,9 @@
#define DEFAULT_FULLSCREEN_Y 0
#endif
/* Force 4k resolution */
#define DEFAULT_FORCE_RESOLUTION false
/* Number of threads to use for video recording */
#define DEFAULT_VIDEO_RECORD_THREADS 2
/* Amount of transparency to use for the main window.
* 1 is the most transparent while 100 is opaque.
*/
#define DEFAULT_WINDOW_OPACITY 100
/* Whether to show the usual window decorations like border, titlebar etc. */
#define DEFAULT_WINDOW_DECORATIONS true
#if defined(RARCH_CONSOLE) || defined(__APPLE__)
#define DEFAULT_LOAD_DUMMY_ON_CORE_SHUTDOWN false
#else
@@ -261,6 +290,10 @@
#endif
#define DEFAULT_CHECK_FIRMWARE_BEFORE_LOADING false
/* Specifies whether cores are allowed to
* present core options in category submenus */
#define DEFAULT_CORE_OPTION_CATEGORY_ENABLE true
/* Specifies whether to cache core info
* into a single (compressed) file for improved
* load times on platforms with slow IO */
@@ -414,7 +447,12 @@
#define DEFAULT_DINGUX_IPU_KEEP_ASPECT true
/* Sets image filtering method when using the
* IPU hardware scaler in Dingux devices */
#if defined(RETROFW)
#define DEFAULT_DINGUX_IPU_FILTER_TYPE DINGUX_IPU_FILTER_NEAREST
#else
#define DEFAULT_DINGUX_IPU_FILTER_TYPE DINGUX_IPU_FILTER_BICUBIC
#endif
#if defined(DINGUX_BETA)
/* Sets refresh rate of integral LCD panel
* in Dingux devices */
@@ -558,6 +596,9 @@ static const bool quick_menu_show_start_streaming = true;
static const bool quick_menu_show_set_core_association = true;
static const bool quick_menu_show_reset_core_association = true;
static const bool quick_menu_show_options = true;
#define DEFAULT_QUICK_MENU_SHOW_CORE_OPTIONS_FLUSH false
static const bool quick_menu_show_controls = true;
static const bool quick_menu_show_cheats = true;
static const bool quick_menu_show_shaders = true;
@@ -744,7 +785,7 @@ static const bool default_savefiles_in_content_dir = false;
static const bool default_systemfiles_in_content_dir = false;
static const bool default_screenshots_in_content_dir = false;
#if defined(RS90)
#if defined(RS90) || defined(RETROFW)
#define DEFAULT_MENU_TOGGLE_GAMEPAD_COMBO INPUT_TOGGLE_START_SELECT
#elif defined(_XBOX1) || defined(__PS3__) || defined(_XBOX360) || defined(DINGUX)
#define DEFAULT_MENU_TOGGLE_GAMEPAD_COMBO INPUT_TOGGLE_L3_R3
@@ -954,7 +995,7 @@ static const bool audio_enable_menu_bgm = false;
/* Output samplerate. */
#ifdef GEKKO
#define DEFAULT_OUTPUT_RATE 32000
#elif defined(_3DS)
#elif defined(_3DS) || defined(RETROFW)
#define DEFAULT_OUTPUT_RATE 32730
#else
#define DEFAULT_OUTPUT_RATE 48000
@@ -965,7 +1006,7 @@ static const bool audio_enable_menu_bgm = false;
/* Desired audio latency in milliseconds. Might not be honored
* if driver can't provide given latency. */
#if defined(ANDROID) || defined(EMSCRIPTEN)
#if defined(ANDROID) || defined(EMSCRIPTEN) || defined(RETROFW)
/* For most Android devices, 64ms is way too low. */
#define DEFAULT_OUT_LATENCY 128
#else
@@ -1038,6 +1079,13 @@ static const bool audio_enable_menu_bgm = false;
/* When set, all enabled cheats are auto-applied when a game is loaded. */
#define DEFAULT_APPLY_CHEATS_AFTER_LOAD false
#if defined(RETROFW)
/*RETROFW jz4760 has signficant slowdown with default settings */
#define DEFAULT_REWIND_BUFFER_SIZE (1 << 20)
#define DEFAULT_REWIND_BUFFER_SIZE_STEP 1
#define DEFAULT_REWIND_GRANULARITY 6
#else
/* The buffer size for the rewind buffer. This needs to be about
* 15-20MB per minute. Very game dependant. */
#define DEFAULT_REWIND_BUFFER_SIZE (20 << 20) /* 20MiB */
@@ -1047,9 +1095,9 @@ static const bool audio_enable_menu_bgm = false;
/* How many frames to rewind at a time. */
#define DEFAULT_REWIND_GRANULARITY 1
#endif
/* Pause gameplay when gameplay loses focus. */
#ifdef EMSCRIPTEN
#if defined(EMSCRIPTEN) || defined(WEBOS)
#define DEFAULT_PAUSE_NONACTIVE false
#else
#define DEFAULT_PAUSE_NONACTIVE true
+45 -16
View File
@@ -45,7 +45,6 @@
#include "paths.h"
#include "retroarch.h"
#include "verbosity.h"
#include "lakka.h"
#include "gfx/gfx_animation.h"
@@ -58,6 +57,12 @@
#include "uwp/uwp_func.h"
#endif
#include "lakka.h"
#if defined(HAVE_LAKKA) || defined(HAVE_LIBNX)
#include "switch_performance_profiles.h"
#endif
enum video_driver_enum
{
VIDEO_GL = 0,
@@ -427,6 +432,8 @@ static const enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_XINPUT;
static const enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_ANDROID;
#elif defined(EMSCRIPTEN) && defined(HAVE_SDL2)
static const enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_SDL2;
#elif defined(WEBOS) && defined(HAVE_SDL2)
static const enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_SDL2;
#elif defined(EMSCRIPTEN)
static const enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_RWEBINPUT;
#elif defined(_WIN32) && defined(HAVE_DINPUT)
@@ -479,6 +486,8 @@ static const enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_XINPUT;
static const enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_GX;
#elif defined(WIIU)
static const enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_WIIU;
#elif defined(WEBOS)
static const enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_SDL;
#elif defined(_XBOX)
static const enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_XDK;
#elif defined(PS2)
@@ -1514,7 +1523,12 @@ static struct config_bool_setting *populate_settings_bool(
SETTING_BOOL("input_descriptor_hide_unbound", &settings->bools.input_descriptor_hide_unbound, true, input_descriptor_hide_unbound, false);
SETTING_BOOL("load_dummy_on_core_shutdown", &settings->bools.load_dummy_on_core_shutdown, true, DEFAULT_LOAD_DUMMY_ON_CORE_SHUTDOWN, false);
SETTING_BOOL("check_firmware_before_loading", &settings->bools.check_firmware_before_loading, true, DEFAULT_CHECK_FIRMWARE_BEFORE_LOADING, false);
SETTING_BOOL("core_option_category_enable", &settings->bools.core_option_category_enable, true, DEFAULT_CORE_OPTION_CATEGORY_ENABLE, false);
#if defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
SETTING_BOOL("core_info_cache_enable", &settings->bools.core_info_cache_enable, false, DEFAULT_CORE_INFO_CACHE_ENABLE, false);
#else
SETTING_BOOL("core_info_cache_enable", &settings->bools.core_info_cache_enable, true, DEFAULT_CORE_INFO_CACHE_ENABLE, false);
#endif
#ifndef HAVE_DYNAMIC
SETTING_BOOL("always_reload_core_on_run_content", &settings->bools.always_reload_core_on_run_content, true, DEFAULT_ALWAYS_RELOAD_CORE_ON_RUN_CONTENT, false);
#endif
@@ -1558,9 +1572,6 @@ static struct config_bool_setting *populate_settings_bool(
SETTING_BOOL("auto_screenshot_filename", &settings->bools.auto_screenshot_filename, true, DEFAULT_AUTO_SCREENSHOT_FILENAME, false);
SETTING_BOOL("video_force_srgb_disable", &settings->bools.video_force_srgb_disable, true, false, false);
SETTING_BOOL("video_fullscreen", &settings->bools.video_fullscreen, true, DEFAULT_FULLSCREEN, false);
#ifdef __WINRT__
SETTING_BOOL("video_force_resolution", &settings->bools.video_force_resolution, true, DEFAULT_FORCE_RESOLUTION, false);
#endif
SETTING_BOOL("bundle_assets_extract_enable", &settings->bools.bundle_assets_extract_enable, true, DEFAULT_BUNDLE_ASSETS_EXTRACT_ENABLE, false);
SETTING_BOOL("video_vsync", &settings->bools.video_vsync, true, DEFAULT_VSYNC, false);
SETTING_BOOL("video_adaptive_vsync", &settings->bools.video_adaptive_vsync, true, DEFAULT_ADAPTIVE_VSYNC, false);
@@ -1672,6 +1683,7 @@ static struct config_bool_setting *populate_settings_bool(
SETTING_BOOL("quick_menu_show_set_core_association", &settings->bools.quick_menu_show_set_core_association, true, quick_menu_show_set_core_association, false);
SETTING_BOOL("quick_menu_show_reset_core_association", &settings->bools.quick_menu_show_reset_core_association, true, quick_menu_show_reset_core_association, false);
SETTING_BOOL("quick_menu_show_options", &settings->bools.quick_menu_show_options, true, quick_menu_show_options, false);
SETTING_BOOL("quick_menu_show_core_options_flush", &settings->bools.quick_menu_show_core_options_flush, true, DEFAULT_QUICK_MENU_SHOW_CORE_OPTIONS_FLUSH, false);
SETTING_BOOL("quick_menu_show_controls", &settings->bools.quick_menu_show_controls, true, quick_menu_show_controls, false);
SETTING_BOOL("quick_menu_show_cheats", &settings->bools.quick_menu_show_cheats, true, quick_menu_show_cheats, false);
SETTING_BOOL("quick_menu_show_shaders", &settings->bools.quick_menu_show_shaders, true, quick_menu_show_shaders, false);
@@ -1814,6 +1826,7 @@ static struct config_bool_setting *populate_settings_bool(
SETTING_BOOL("show_hidden_files", &settings->bools.show_hidden_files, true, DEFAULT_SHOW_HIDDEN_FILES, false);
SETTING_BOOL("use_last_start_directory", &settings->bools.use_last_start_directory, true, DEFAULT_USE_LAST_START_DIRECTORY, false);
SETTING_BOOL("input_autodetect_enable", &settings->bools.input_autodetect_enable, true, input_autodetect_enable, false);
SETTING_BOOL("input_auto_mouse_grab", &settings->bools.input_auto_mouse_grab, true, false, false);
#if defined(HAVE_DINPUT) || defined(HAVE_WINRAWINPUT)
SETTING_BOOL("input_nowinkey_enable", &settings->bools.input_nowinkey_enable, true, false, false);
#endif
@@ -1831,7 +1844,8 @@ static struct config_bool_setting *populate_settings_bool(
SETTING_BOOL("video_msg_bgcolor_enable", &settings->bools.video_msg_bgcolor_enable, true, message_bgcolor_enable, false);
SETTING_BOOL("video_window_show_decorations", &settings->bools.video_window_show_decorations, true, DEFAULT_WINDOW_DECORATIONS, false);
SETTING_BOOL("video_window_save_positions", &settings->bools.video_window_save_positions, true, false, false);
SETTING_BOOL("video_window_save_positions", &settings->bools.video_window_save_positions, true, DEFAULT_WINDOW_SAVE_POSITIONS, false);
SETTING_BOOL("video_window_custom_size_enable", &settings->bools.video_window_custom_size_enable, true, DEFAULT_WINDOW_CUSTOM_SIZE_ENABLE, false);
SETTING_BOOL("sustained_performance_mode", &settings->bools.sustained_performance_mode, true, sustained_performance_mode, false);
@@ -1926,7 +1940,7 @@ static struct config_float_setting *populate_settings_float(
SETTING_FLOAT("video_font_size", &settings->floats.video_font_size, true, DEFAULT_FONT_SIZE, false);
SETTING_FLOAT("fastforward_ratio", &settings->floats.fastforward_ratio, true, DEFAULT_FASTFORWARD_RATIO, false);
SETTING_FLOAT("slowmotion_ratio", &settings->floats.slowmotion_ratio, true, DEFAULT_SLOWMOTION_RATIO, false);
SETTING_FLOAT("input_axis_threshold", input_driver_get_float(INPUT_ACTION_AXIS_THRESHOLD), true, DEFAULT_AXIS_THRESHOLD, false);
SETTING_FLOAT("input_axis_threshold", &settings->floats.input_axis_threshold, true, DEFAULT_AXIS_THRESHOLD, false);
SETTING_FLOAT("input_analog_deadzone", &settings->floats.input_analog_deadzone, true, DEFAULT_ANALOG_DEADZONE, false);
SETTING_FLOAT("input_analog_sensitivity", &settings->floats.input_analog_sensitivity, true, DEFAULT_ANALOG_SENSITIVITY, false);
SETTING_FLOAT("video_msg_bgcolor_opacity", &settings->floats.video_msg_bgcolor_opacity, true, message_bgcolor_opacity, false);
@@ -1957,7 +1971,7 @@ static struct config_uint_setting *populate_settings_uint(
SETTING_UINT("input_duty_cycle", &settings->uints.input_turbo_duty_cycle, true, turbo_duty_cycle, false);
SETTING_UINT("input_turbo_mode", &settings->uints.input_turbo_mode, true, turbo_mode, false);
SETTING_UINT("input_turbo_default_button", &settings->uints.input_turbo_default_button, true, turbo_default_btn, false);
SETTING_UINT("input_max_users", input_driver_get_uint(INPUT_ACTION_MAX_USERS), true, input_max_users, false);
SETTING_UINT("input_max_users", &settings->uints.input_max_users, true, input_max_users, false);
SETTING_UINT("fps_update_interval", &settings->uints.fps_update_interval, true, DEFAULT_FPS_UPDATE_INTERVAL, false);
SETTING_UINT("memory_update_interval", &settings->uints.memory_update_interval, true, DEFAULT_MEMORY_UPDATE_INTERVAL, false);
SETTING_UINT("input_menu_toggle_gamepad_combo", &settings->uints.input_menu_toggle_gamepad_combo, true, DEFAULT_MENU_TOGGLE_GAMEPAD_COMBO, false);
@@ -2116,8 +2130,10 @@ static struct config_uint_setting *populate_settings_uint(
SETTING_UINT("video_stream_scale_factor", &settings->uints.video_stream_scale_factor, true, 1, false);
SETTING_UINT("video_windowed_position_x", &settings->uints.window_position_x, true, 0, false);
SETTING_UINT("video_windowed_position_y", &settings->uints.window_position_y, true, 0, false);
SETTING_UINT("video_windowed_position_width", &settings->uints.window_position_width, true, DEFAULT_WINDOW_WIDTH, false);
SETTING_UINT("video_windowed_position_height", &settings->uints.window_position_height, true, DEFAULT_WINDOW_HEIGHT, false);
SETTING_UINT("video_windowed_position_width", &settings->uints.window_position_width, true, DEFAULT_WINDOW_WIDTH, false);
SETTING_UINT("video_windowed_position_height", &settings->uints.window_position_height, true, DEFAULT_WINDOW_HEIGHT, false);
SETTING_UINT("video_window_auto_width_max", &settings->uints.window_auto_width_max, true, DEFAULT_WINDOW_AUTO_WIDTH_MAX, false);
SETTING_UINT("video_window_auto_height_max", &settings->uints.window_auto_height_max, true, DEFAULT_WINDOW_AUTO_HEIGHT_MAX, false);
SETTING_UINT("ai_service_mode", &settings->uints.ai_service_mode, true, DEFAULT_AI_SERVICE_MODE, false);
SETTING_UINT("ai_service_target_lang", &settings->uints.ai_service_target_lang, true, 0, false);
SETTING_UINT("ai_service_source_lang", &settings->uints.ai_service_source_lang, true, 0, false);
@@ -2486,7 +2502,7 @@ void config_set_defaults(void *data)
settings->uints.input_analog_dpad_mode[i] = ANALOG_DPAD_NONE;
#endif
input_config_set_device(i, RETRO_DEVICE_JOYPAD);
settings->uints.input_mouse_index[i] = 0;
settings->uints.input_mouse_index[i] = i;
}
video_driver_reset_custom_viewport();
@@ -3070,6 +3086,7 @@ static bool config_load_file(global_t *global,
bool ret = false;
unsigned tmp_uint = 0;
bool tmp_bool = false;
static bool first_load = true;
unsigned msg_color = 0;
char *save = NULL;
char *override_username = NULL;
@@ -3161,13 +3178,24 @@ static bool config_load_file(global_t *global,
settings->bools.network_remote_enable_user[i], tmp_bool);
}
#endif
if (config_get_bool(conf, "log_verbosity", &tmp_bool))
/* Set verbosity according to config only if the 'v' command line argument was not used
* or if it is not the first config load. */
if (config_get_bool(conf, "log_verbosity", &tmp_bool) &&
(!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_VERBOSITY, NULL) ||
!first_load))
{
if (tmp_bool)
verbosity_enable();
else
verbosity_disable();
}
/* On first config load, make sure log_to_file is true if 'log-file' command line
* argument was used. */
if (retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_LOG_TO_FILE, NULL) &&
first_load)
{
configuration_set_bool(settings,settings->bools.log_to_file,true);
}
if (config_get_uint(conf, "frontend_log_level", &tmp_uint))
{
verbosity_set_log_level(tmp_uint);
@@ -3598,6 +3626,7 @@ end:
free(path_settings);
if (size_settings)
free(size_settings);
first_load = false;
return ret;
}
@@ -3944,15 +3973,15 @@ success:
*/
static void config_parse_file(global_t *global)
{
const char *config_path = path_get(RARCH_PATH_CONFIG);
if (path_is_empty(RARCH_PATH_CONFIG))
{
RARCH_LOG("[Config]: Loading default config.\n");
}
else
RARCH_LOG("[Config]: Loading config from: \"%s\".\n", config_path);
{
const char *config_path = path_get(RARCH_PATH_CONFIG);
RARCH_LOG("[Config]: Loading config from: \"%s\".\n", config_path);
if (!config_load_file(global, config_path, config_get_ptr()))
{
RARCH_ERR("[Config]: Couldn't find config at path: \"%s\".\n",
@@ -4676,7 +4705,7 @@ bool input_remapping_load_file(void *data, const char *path)
}
else
{
char stk_ident[128];
char stk_ident[256];
char key_ident[128];
int stk_remap = -1;
int key_remap = -1;
@@ -4752,8 +4781,8 @@ bool input_remapping_save_file(const char *path)
"a", "x", "l", "r", "l2", "r2",
"l3", "r3", "l_x+", "l_x-", "l_y+", "l_y-", "r_x+", "r_x-", "r_y+", "r_y-" };
config_file_t *conf = NULL;
unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS));
settings_t *settings = config_get_ptr();
unsigned max_users = settings->uints.input_max_users;
const char *dir_input_remapping = settings->paths.directory_input_remapping;
remap_file[0] = '\0';
+8 -1
View File
@@ -165,6 +165,7 @@ typedef struct settings
unsigned input_poll_type_behavior;
unsigned input_dingux_rumble_gain;
unsigned input_auto_game_focus;
unsigned input_max_users;
unsigned netplay_port;
unsigned netplay_input_latency_frames_min;
@@ -282,6 +283,8 @@ typedef struct settings
unsigned window_position_y;
unsigned window_position_width;
unsigned window_position_height;
unsigned window_auto_width_max;
unsigned window_auto_height_max;
unsigned video_record_threads;
@@ -350,6 +353,7 @@ typedef struct settings
float slowmotion_ratio;
float fastforward_ratio;
float input_analog_deadzone;
float input_axis_threshold;
float input_analog_sensitivity;
} floats;
@@ -522,7 +526,6 @@ typedef struct settings
#ifdef HAVE_VIDEO_LAYOUT
bool video_layout_enable;
#endif
bool video_force_resolution;
/* Accessibility */
bool accessibility_enable;
@@ -558,6 +561,7 @@ typedef struct settings
bool input_backtouch_toggle;
bool input_small_keyboard_enable;
bool input_keyboard_gamepad_enable;
bool input_auto_mouse_grab;
#if defined(HAVE_DINPUT) || defined(HAVE_WINRAWINPUT)
bool input_nowinkey_enable;
#endif
@@ -689,6 +693,7 @@ typedef struct settings
bool quick_menu_show_set_core_association;
bool quick_menu_show_reset_core_association;
bool quick_menu_show_options;
bool quick_menu_show_core_options_flush;
bool quick_menu_show_controls;
bool quick_menu_show_cheats;
bool quick_menu_show_shaders;
@@ -793,6 +798,7 @@ typedef struct settings
bool network_remote_enable_user[MAX_USERS];
bool load_dummy_on_core_shutdown;
bool check_firmware_before_loading;
bool core_option_category_enable;
bool core_info_cache_enable;
#ifndef HAVE_DYNAMIC
bool always_reload_core_on_run_content;
@@ -824,6 +830,7 @@ typedef struct settings
bool video_window_show_decorations;
bool video_window_save_positions;
bool video_window_custom_size_enable;
bool sustained_performance_mode;
bool playlist_use_old_format;
+8 -17
View File
@@ -159,9 +159,7 @@ static bool CCJSONObjectMemberHandler(void *context, const char *pValue, size_t
}
break;
case 'p':
if (string_is_equal(pValue, "path"))
pCtx->current_string_val = &pCtx->core_info->path;
else if (string_is_equal(pValue, "permissions"))
if (string_is_equal(pValue, "permissions"))
{
pCtx->current_string_val = &pCtx->core_info->permissions;
pCtx->current_string_list_val = &pCtx->core_info->permissions_list;
@@ -815,14 +813,6 @@ static bool core_info_cache_write(core_info_cache_list_t *list, const char *info
rjsonwriter_add_start_object(writer);
rjsonwriter_add_newline(writer);
rjsonwriter_add_spaces(writer, 6);
rjsonwriter_add_string(writer, "path");
rjsonwriter_add_colon(writer);
rjsonwriter_add_space(writer);
rjsonwriter_add_string(writer, info->path);
rjsonwriter_add_comma(writer);
rjsonwriter_add_newline(writer);
rjsonwriter_add_spaces(writer, 6);
rjsonwriter_add_string(writer, "display_name");
rjsonwriter_add_colon(writer);
@@ -1813,18 +1803,13 @@ static core_info_list_t *core_info_list_new(const char *path,
core_info_list->list = core_info;
core_info_list->count = path_list->core_list->size;
#if !defined(IOS)
/* Read core info cache, if enabled
* > This functionality is hard disabled on iOS/tvOS,
* where core path changes on every install
* (invalidating any cached parameters) */
/* Read core info cache, if enabled */
if (enable_cache)
{
core_info_cache_list = core_info_cache_read(info_dir);
if (!core_info_cache_list)
goto error;
}
#endif
for (i = 0; i < path_list->core_list->size; i++)
{
@@ -1851,6 +1836,12 @@ static core_info_list_t *core_info_list_new(const char *path,
if (info_cache)
{
core_info_copy(info_cache, info);
/* Core path is 'dynamic', and cannot
* be cached (i.e. core directory may
* change between runs) */
if (info->path)
free(info->path);
info->path = strdup(base_path);
/* Core lock status is 'dynamic', and
* cannot be cached */
info->is_locked = core_info_path_is_locked(path_list->lock_list,
File diff suppressed because it is too large. Load diff
+374 -29
View File
@@ -22,6 +22,7 @@
#include <boolean.h>
#include <retro_common_api.h>
#include <lists/string_list.h>
#include <lists/nested_list.h>
#include "retroarch.h"
@@ -30,99 +31,443 @@ RETRO_BEGIN_DECLS
struct core_option
{
char *desc;
char *desc_categorized;
char *info;
char *info_categorized;
char *key;
char *category_key;
struct string_list *vals;
struct string_list *val_labels;
/* opt_idx: option index, used for internal
* bookkeeping */
size_t opt_idx;
/* default_index, index: correspond to
* option *value* indices */
size_t default_index;
size_t index;
uint32_t key_hash;
bool visible;
};
struct core_catagory
{
char *key;
char *desc;
char *info;
uint32_t key_hash;
};
/* TODO/FIXME: This struct should be made
* 'private', with restricted access to its
* members via interface functions. This
* requires significant refactoring... */
struct core_option_manager
{
config_file_t *conf;
char conf_path[PATH_MAX_LENGTH];
struct core_catagory *cats;
struct core_option *opts;
nested_list_t *option_map;
size_t cats_size;
size_t size;
bool updated;
};
typedef struct core_option_manager core_option_manager_t;
/*********************/
/* Option Conversion */
/*********************/
/**
* core_option_manager_set_default:
* @opt : pointer to core option manager object.
* @idx : index of core option to be reset to defaults.
* core_option_manager_convert_v1:
*
* Reset core option specified by @idx and sets default value for option.
* @options_v1 : an array of retro_core_option_definition
* structs
*
* Converts an array of core option v1 definitions into
* a v2 core options struct. Returned pointer must be
* freed using core_option_manager_free_converted().
*
* Returns: Valid pointer to a new v2 core options struct
* if successful, otherwise NULL.
**/
void core_option_manager_set_default(core_option_manager_t *opt, size_t idx);
struct retro_core_options_v2 *core_option_manager_convert_v1(
const struct retro_core_option_definition *options_v1);
/**
* core_option_manager_convert_v1_intl:
*
* @options_v1_intl : pointer to a retro_core_options_intl
* struct
*
* Converts a v1 'international' core options definition
* struct into a v2 core options struct. Returned pointer
* must be freed using core_option_manager_free_converted().
*
* Returns: Valid pointer to a new v2 core options struct
* if successful, otherwise NULL.
**/
struct retro_core_options_v2 *core_option_manager_convert_v1_intl(
const struct retro_core_options_intl *options_v1_intl);
/**
* core_option_manager_convert_v2_intl:
*
* @options_v2_intl : pointer to a retro_core_options_v2_intl
* struct
*
* Converts a v2 'international' core options struct
* into a regular v2 core options struct. Returned pointer
* must be freed using core_option_manager_free_converted().
*
* Returns: Valid pointer to a new v2 core options struct
* if successful, otherwise NULL.
**/
struct retro_core_options_v2 *core_option_manager_convert_v2_intl(
const struct retro_core_options_v2_intl *options_v2_intl);
/**
* core_option_manager_free_converted:
*
* @options_v2 : pointer to a retro_core_options_v2
* struct
*
* Frees the pointer returned by any
* core_option_manager_convert_*() function.
**/
void core_option_manager_free_converted(
struct retro_core_options_v2 *options_v2);
/**************************************/
/* Initialisation / De-Initialisation */
/**************************************/
/**
* core_option_manager_new_vars:
*
* @conf_path : Filesystem path to write core option
* config file to
* @src_conf_path : Filesystem path from which to load
* initial config settings.
* @vars : Pointer to core option variable array
* handle
*
* Legacy version of core_option_manager_new().
* Creates and initializes a core manager handle.
*
* Returns: handle to new core manager handle if successful,
* otherwise NULL.
**/
core_option_manager_t *core_option_manager_new_vars(
const char *conf_path, const char *src_conf_path,
const struct retro_variable *vars);
/**
* core_option_manager_new:
*
* @conf_path : Filesystem path to write core option
* config file to
* @src_conf_path : Filesystem path from which to load
* initial config settings.
* @options_v2 : Pointer to retro_core_options_v2 struct
* @categorized : Flag specifying whether core option
* category information should be read
* from @options_v2
*
* Creates and initializes a core manager handle. Parses
* information from a retro_core_options_v2 struct.
* If @categorized is false, all option category
* assignments will be ignored.
*
* Returns: handle to new core manager handle if successful,
* otherwise NULL.
**/
core_option_manager_t *core_option_manager_new(
const char *conf_path, const char *src_conf_path,
const struct retro_core_options_v2 *options_v2,
bool categorized);
/**
* core_option_manager_free:
*
* @opt : options manager handle
*
* Frees specified core options manager handle.
**/
void core_option_manager_free(core_option_manager_t *opt);
/********************/
/* Category Getters */
/********************/
/**
* core_option_manager_get_category_desc:
*
* @opt : options manager handle
* @key : core option category id string
*
* Fetches the 'description' text of the core option
* category identified by @key (used as the
* category label in the menu).
*
* Returns: description string (menu label) of the
* specified option category if successful,
* otherwise NULL.
**/
const char *core_option_manager_get_category_desc(core_option_manager_t *opt,
const char *key);
/**
* core_option_manager_get_category_info:
*
* @opt : options manager handle
* @key : core option category id string
*
* Fetches the 'info' text of the core option
* category identified by @key (used as the category
* sublabel in the menu).
*
* Returns: information string (menu sublabel) of
* the specified option category if successful,
* otherwise NULL.
**/
const char *core_option_manager_get_category_info(core_option_manager_t *opt,
const char *key);
/**
* core_option_manager_get_category_visible:
*
* @opt : options manager handle
* @key : core option category id string
*
* Queries whether the core option category
* identified by @key should be displayed in
* the frontend menu. (A category is deemed to
* be visible if at least one of the options
* in the category is visible)
*
* Returns: true if option category should be
* displayed by the frontend, otherwise false.
**/
bool core_option_manager_get_category_visible(core_option_manager_t *opt,
const char *key);
/******************/
/* Option Getters */
/******************/
/**
* core_option_manager_get_idx:
*
* @opt : options manager handle
* @key : core option key string (variable to query
* in RETRO_ENVIRONMENT_GET_VARIABLE)
* @idx : index of core option corresponding
* to @key
*
* Fetches the index of the core option identified
* by the specified @key.
*
* Returns: true if option matching the specified
* key was found, otherwise false.
**/
bool core_option_manager_get_idx(core_option_manager_t *opt,
const char *key, size_t *idx);
/**
* core_option_manager_get_desc:
* @opt : options manager handle
* @idx : idx identifier of the option
*
* Gets description for an option.
* @opt : options manager handle
* @idx : core option index
* @categorized : flag specifying whether to
* fetch the categorised description
* or the legacy fallback
*
* Returns: Description for an option.
* Fetches the 'description' of the core option at
* index @idx (used as the option label in the menu).
* If menu has option category support, @categorized
* should be true. (At present, only the Qt interface
* requires @categorized to be false)
*
* Returns: description string (menu label) of the
* specified option if successful, otherwise NULL.
**/
const char *core_option_manager_get_desc(core_option_manager_t *opt,
size_t idx);
size_t idx, bool categorized);
/**
* core_option_manager_get_info:
* @opt : options manager handle
* @idx : idx identifier of the option
*
* Gets information text for an option.
* @opt : options manager handle
* @idx : core option index
* @categorized : flag specifying whether to
* fetch the categorised information
* or the legacy fallback
*
* Returns: Information text for an option.
* Fetches the 'info' text of the core option at
* index @idx (used as the option sublabel in the
* menu). If menu has option category support,
* @categorized should be true. (At present, only
* the Qt interface requires @categorized to be false)
*
* Returns: information string (menu sublabel) of the
* specified option if successful, otherwise NULL.
**/
const char *core_option_manager_get_info(core_option_manager_t *opt,
size_t idx);
size_t idx, bool categorized);
/**
* core_option_manager_get_val:
* @opt : options manager handle
* @idx : idx identifier of the option
*
* Gets value for an option.
* @opt : options manager handle
* @idx : core option index
*
* Returns: Value for an option.
* Fetches the string representation of the current
* value of the core option at index @idx.
*
* Returns: core option value string if successful,
* otherwise NULL.
**/
const char *core_option_manager_get_val(core_option_manager_t *opt,
size_t idx);
/**
* core_option_manager_get_val_label:
* @opt : options manager handle
* @idx : idx identifier of the option
*
* Gets value label for an option.
* @opt : options manager handle
* @idx : core option index
*
* Returns: Value label for an option.
* Fetches the 'label' text (used for display purposes
* in the menu) for the current value of the core
* option at index @idx.
*
* Returns: core option value label string if
* successful, otherwise NULL.
**/
const char *core_option_manager_get_val_label(core_option_manager_t *opt,
size_t idx);
/**
* core_option_manager_get_visible:
* @opt : options manager handle
* @idx : idx identifier of the option
*
* Gets whether option should be visible when displaying
* core options in the frontend
* @opt : options manager handle
* @idx : core option index
*
* Returns: 'true' if option should be displayed by the frontend.
* Queries whether the core option at index @idx
* should be displayed in the frontend menu.
*
* Returns: true if option should be displayed by
* the frontend, otherwise false.
**/
bool core_option_manager_get_visible(core_option_manager_t *opt,
size_t idx);
/******************/
/* Option Setters */
/******************/
/**
* core_option_manager_set_val:
*
* @opt : options manager handle
* @idx : core option index
* @val_idx : index of the value to set
* @refresh_menu : flag specifying whether menu
* should be refreshed if changes
* to option visibility are detected
*
* Sets the core option at index @idx to the
* option value corresponding to @val_idx.
* After setting the option value, a request
* will be made for the core to update the
* in-menu visibility of all options; if
* visibility changes are detected and
* @refresh_menu is true, the menu will be
* redrawn.
**/
void core_option_manager_set_val(core_option_manager_t *opt,
size_t idx, size_t val_idx);
size_t idx, size_t val_idx, bool refresh_menu);
/**
* core_option_manager_adjust_val:
*
* @opt : options manager handle
* @idx : core option index
* @adjustment : offset to apply from current
* value index
* @refresh_menu : flag specifying whether menu
* should be refreshed if changes
* to option visibility are detected
*
* Modifies the value of the core option at
* index @idx by incrementing the current option
* value index by @adjustment.
* After setting the option value, a request
* will be made for the core to update the
* in-menu visibility of all options; if
* visibility changes are detected and
* @refresh_menu is true, the menu will be
* redrawn.
**/
void core_option_manager_adjust_val(core_option_manager_t* opt,
size_t idx, int adjustment, bool refresh_menu);
/**
* core_option_manager_set_default:
*
* @opt : options manager handle
* @idx : core option index
* @refresh_menu : flag specifying whether menu
* should be refreshed if changes
* to option visibility are detected
*
* Resets the core option at index @idx to
* its default value.
* After setting the option value, a request
* will be made for the core to update the
* in-menu visibility of all options; if
* visibility changes are detected and
* @refresh_menu is true, the menu will be
* redrawn.
**/
void core_option_manager_set_default(core_option_manager_t *opt,
size_t idx, bool refresh_menu);
/**
* core_option_manager_set_visible:
*
* @opt : options manager handle
* @key : core option key string (variable to query
* in RETRO_ENVIRONMENT_GET_VARIABLE)
* @visible : flag specifying whether option should
* be shown in the menu
*
* Sets the in-menu visibility of the core option
* identified by the specified @key.
**/
void core_option_manager_set_visible(core_option_manager_t *opt,
const char *key, bool visible);
/**********************/
/* Configuration File */
/**********************/
/**
* core_option_manager_flush:
*
* @opt : options manager handle
* @conf : configuration file handle
*
* Writes all core option key-pair values from the
* specified core option manager handle to the
* specified configuration file struct.
**/
void core_option_manager_flush(core_option_manager_t *opt,
config_file_t *conf);
RETRO_END_DECLS
+17 -2
View File
@@ -281,8 +281,23 @@ static int database_cursor_iterate(libretrodb_cursor_t *cur,
else if (string_is_equal(str, "size"))
db_info->size = (unsigned)val->val.uint_;
else if (string_is_equal(str, "crc"))
db_info->crc32 = swap_if_little32(
*(uint32_t*)val->val.binary.buff);
{
switch (val->val.binary.len)
{
case 1:
db_info->crc32 = *(uint8_t*)val->val.binary.buff;
break;
case 2:
db_info->crc32 = swap_if_little16(*(uint16_t*)val->val.binary.buff);
break;
case 4:
db_info->crc32 = swap_if_little32(*(uint32_t*)val->val.binary.buff);
break;
default:
db_info->crc32 = 0;
break;
}
}
else if (string_is_equal(str, "sha1"))
db_info->sha1 = bin_to_hex_alloc(
(uint8_t*)val->val.binary.buff, val->val.binary.len);
+33 -33
View File
@@ -24,15 +24,15 @@ typedef struct
typedef struct
{
size_t PropsOffset;
UInt32 MethodID;
uint32_t MethodID;
Byte NumStreams;
Byte PropsSize;
} CSzCoderInfo;
typedef struct
{
UInt32 InIndex;
UInt32 OutIndex;
uint32_t InIndex;
uint32_t OutIndex;
} CSzBond;
#define SZ_NUM_CODERS_IN_FOLDER_MAX 4
@@ -41,11 +41,11 @@ typedef struct
typedef struct
{
UInt32 NumCoders;
UInt32 NumBonds;
UInt32 NumPackStreams;
UInt32 UnpackStream;
UInt32 PackStreams[SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX];
uint32_t NumCoders;
uint32_t NumBonds;
uint32_t NumPackStreams;
uint32_t UnpackStream;
uint32_t PackStreams[SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX];
CSzBond Bonds[SZ_NUM_BONDS_IN_FOLDER_MAX];
CSzCoderInfo Coders[SZ_NUM_CODERS_IN_FOLDER_MAX];
} CSzFolder;
@@ -55,20 +55,20 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd);
typedef struct
{
UInt32 Low;
UInt32 High;
uint32_t Low;
uint32_t High;
} CNtfsFileTime;
typedef struct
{
Byte *Defs; /* MSB 0 bit numbering */
UInt32 *Vals;
uint32_t *Vals;
} CSzBitUi32s;
typedef struct
{
Byte *Defs; /* MSB 0 bit numbering */
/* UInt64 *Vals; */
/* uint64_t *Vals; */
CNtfsFileTime *Vals;
} CSzBitUi64s;
@@ -78,25 +78,25 @@ typedef struct
typedef struct
{
UInt32 NumPackStreams;
UInt32 NumFolders;
uint32_t NumPackStreams;
uint32_t NumFolders;
UInt64 *PackPositions; /* NumPackStreams + 1 */
uint64_t *PackPositions; /* NumPackStreams + 1 */
CSzBitUi32s FolderCRCs; /* NumFolders */
size_t *FoCodersOffsets; /* NumFolders + 1 */
UInt32 *FoStartPackStreamIndex; /* NumFolders + 1 */
UInt32 *FoToCoderUnpackSizes; /* NumFolders + 1 */
uint32_t *FoStartPackStreamIndex; /* NumFolders + 1 */
uint32_t *FoToCoderUnpackSizes; /* NumFolders + 1 */
Byte *FoToMainUnpackSizeIndex; /* NumFolders */
UInt64 *CoderUnpackSizes; /* for all coders in all folders */
uint64_t *CoderUnpackSizes; /* for all coders in all folders */
Byte *CodersData;
} CSzAr;
UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex);
uint64_t SzAr_GetFolderUnpackSize(const CSzAr *p, uint32_t folderIndex);
SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex,
ILookInStream *stream, UInt64 startPos,
SRes SzAr_DecodeFolder(const CSzAr *p, uint32_t folderIndex,
ILookInStream *stream, uint64_t startPos,
Byte *outBuffer, size_t outSize,
ISzAllocPtr allocMain);
@@ -104,12 +104,12 @@ typedef struct
{
CSzAr db;
UInt64 startPosAfterHeader;
UInt64 dataPos;
uint64_t startPosAfterHeader;
uint64_t dataPos;
UInt32 NumFiles;
uint32_t NumFiles;
UInt64 *UnpackPositions; /* NumFiles + 1 */
uint64_t *UnpackPositions; /* NumFiles + 1 */
/* Byte *IsEmptyFiles; */
Byte *IsDirs;
CSzBitUi32s CRCs;
@@ -119,8 +119,8 @@ typedef struct
CSzBitUi64s MTime;
CSzBitUi64s CTime;
UInt32 *FolderToFile; /* NumFolders + 1 */
UInt32 *FileToFolder; /* NumFiles */
uint32_t *FolderToFile; /* NumFolders + 1 */
uint32_t *FileToFolder; /* NumFiles */
size_t *FileNameOffsets; /* in 2-byte steps */
Byte *FileNames; /* UTF-16-LE */
@@ -132,8 +132,8 @@ typedef struct
void SzArEx_Init(CSzArEx *p);
void SzArEx_Free(CSzArEx *p, ISzAllocPtr alloc);
UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder);
int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize);
uint64_t SzArEx_GetFolderStreamPos(const CSzArEx *p, uint32_t folderIndex, uint32_t indexInFolder);
int SzArEx_GetFolderFullPackSize(const CSzArEx *p, uint32_t folderIndex, uint64_t *resSize);
/*
if dest == NULL, the return value specifies the required size of the buffer,
@@ -141,11 +141,11 @@ if dest == NULL, the return value specifies the required size of the buffer,
if dest != NULL, the return value specifies the number of 16-bit characters that
are written to the dest, including the null-terminating character. */
size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest);
size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, uint16_t *dest);
/*
size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex);
UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest);
uint16_t *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, uint16_t *dest);
*/
@@ -173,8 +173,8 @@ UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16
SRes SzArEx_Extract(
const CSzArEx *db,
ILookInStream *inStream,
UInt32 fileIndex, /* index of file */
UInt32 *blockIndex, /* index of solid block */
uint32_t fileIndex, /* index of file */
uint32_t *blockIndex, /* index of solid block */
Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */
size_t *outBufferSize, /* buffer size for output buffer */
size_t *offset, /* offset of stream for required file in *outBuffer */
+142 -142
View File
@@ -70,7 +70,7 @@ static SRes SzBitUi32s_Alloc(CSzBitUi32s *p, size_t num, ISzAllocPtr alloc)
else
{
MY_ALLOC(Byte, p->Defs, (num + 7) >> 3, alloc);
MY_ALLOC(UInt32, p->Vals, num, alloc);
MY_ALLOC(uint32_t, p->Vals, num, alloc);
}
return SZ_OK;
}
@@ -190,11 +190,11 @@ static int TestSignatureCandidate(const Byte *testBytes)
#define SZ_READ_32(dest) if (sd.Size < 4) return SZ_ERROR_ARCHIVE; \
dest = GetUi32(sd.Data); SKIP_DATA2(sd, 4);
static MY_NO_INLINE SRes ReadNumber(CSzData *sd, UInt64 *value)
static MY_NO_INLINE SRes ReadNumber(CSzData *sd, uint64_t *value)
{
Byte firstByte, mask;
unsigned i;
UInt32 v;
uint32_t v;
SZ_READ_BYTE(firstByte);
if ((firstByte & 0x80) == 0)
@@ -205,33 +205,33 @@ static MY_NO_INLINE SRes ReadNumber(CSzData *sd, UInt64 *value)
SZ_READ_BYTE(v);
if ((firstByte & 0x40) == 0)
{
*value = (((UInt32)firstByte & 0x3F) << 8) | v;
*value = (((uint32_t)firstByte & 0x3F) << 8) | v;
return SZ_OK;
}
SZ_READ_BYTE(mask);
*value = v | ((UInt32)mask << 8);
*value = v | ((uint32_t)mask << 8);
mask = 0x20;
for (i = 2; i < 8; i++)
{
Byte b;
if ((firstByte & mask) == 0)
{
UInt64 highPart = (unsigned)firstByte & (unsigned)(mask - 1);
uint64_t highPart = (unsigned)firstByte & (unsigned)(mask - 1);
*value |= (highPart << (8 * i));
return SZ_OK;
}
SZ_READ_BYTE(b);
*value |= ((UInt64)b << (8 * i));
*value |= ((uint64_t)b << (8 * i));
mask >>= 1;
}
return SZ_OK;
}
static MY_NO_INLINE SRes SzReadNumber32(CSzData *sd, UInt32 *value)
static MY_NO_INLINE SRes SzReadNumber32(CSzData *sd, uint32_t *value)
{
Byte firstByte;
UInt64 value64;
uint64_t value64;
if (sd->Size == 0)
return SZ_ERROR_ARCHIVE;
firstByte = *sd->Data;
@@ -243,11 +243,11 @@ static MY_NO_INLINE SRes SzReadNumber32(CSzData *sd, UInt32 *value)
return SZ_OK;
}
RINOK(ReadNumber(sd, &value64));
if (value64 >= (UInt32)0x80000000 - 1)
if (value64 >= (uint32_t)0x80000000 - 1)
return SZ_ERROR_UNSUPPORTED;
if (value64 >= ((UInt64)(1) << ((sizeof(size_t) - 1) * 8 + 4)))
if (value64 >= ((uint64_t)(1) << ((sizeof(size_t) - 1) * 8 + 4)))
return SZ_ERROR_UNSUPPORTED;
*value = (UInt32)value64;
*value = (uint32_t)value64;
return SZ_OK;
}
@@ -255,7 +255,7 @@ static MY_NO_INLINE SRes SzReadNumber32(CSzData *sd, UInt32 *value)
static SRes SkipData(CSzData *sd)
{
UInt64 size;
uint64_t size;
RINOK(ReadNumber(sd, &size));
if (size > sd->Size)
return SZ_ERROR_ARCHIVE;
@@ -263,11 +263,11 @@ static SRes SkipData(CSzData *sd)
return SZ_OK;
}
static SRes WaitId(CSzData *sd, UInt32 id)
static SRes WaitId(CSzData *sd, uint32_t id)
{
for (;;)
{
UInt64 type;
uint64_t type;
RINOK(ReadID(sd, &type));
if (type == id)
return SZ_OK;
@@ -277,9 +277,9 @@ static SRes WaitId(CSzData *sd, UInt32 id)
}
}
static SRes RememberBitVector(CSzData *sd, UInt32 numItems, const Byte **v)
static SRes RememberBitVector(CSzData *sd, uint32_t numItems, const Byte **v)
{
UInt32 numBytes = (numItems + 7) >> 3;
uint32_t numBytes = (numItems + 7) >> 3;
if (numBytes > sd->Size)
return SZ_ERROR_ARCHIVE;
*v = sd->Data;
@@ -287,11 +287,11 @@ static SRes RememberBitVector(CSzData *sd, UInt32 numItems, const Byte **v)
return SZ_OK;
}
static UInt32 CountDefinedBits(const Byte *bits, UInt32 numItems)
static uint32_t CountDefinedBits(const Byte *bits, uint32_t numItems)
{
Byte b = 0;
unsigned m = 0;
UInt32 sum = 0;
uint32_t sum = 0;
for (; numItems != 0; numItems--)
{
if (m == 0)
@@ -305,11 +305,11 @@ static UInt32 CountDefinedBits(const Byte *bits, UInt32 numItems)
return sum;
}
static MY_NO_INLINE SRes ReadBitVector(CSzData *sd, UInt32 numItems, Byte **v, ISzAllocPtr alloc)
static MY_NO_INLINE SRes ReadBitVector(CSzData *sd, uint32_t numItems, Byte **v, ISzAllocPtr alloc)
{
Byte allAreDefined;
Byte *v2;
UInt32 numBytes = (numItems + 7) >> 3;
uint32_t numBytes = (numItems + 7) >> 3;
*v = NULL;
SZ_READ_BYTE(allAreDefined);
if (numBytes == 0)
@@ -328,18 +328,18 @@ static MY_NO_INLINE SRes ReadBitVector(CSzData *sd, UInt32 numItems, Byte **v, I
{
unsigned numBits = (unsigned)numItems & 7;
if (numBits != 0)
v2[(size_t)numBytes - 1] = (Byte)((((UInt32)1 << numBits) - 1) << (8 - numBits));
v2[(size_t)numBytes - 1] = (Byte)((((uint32_t)1 << numBits) - 1) << (8 - numBits));
}
return SZ_OK;
}
static MY_NO_INLINE SRes ReadUi32s(CSzData *sd2, UInt32 numItems, CSzBitUi32s *crcs, ISzAllocPtr alloc)
static MY_NO_INLINE SRes ReadUi32s(CSzData *sd2, uint32_t numItems, CSzBitUi32s *crcs, ISzAllocPtr alloc)
{
UInt32 i;
uint32_t i;
CSzData sd;
UInt32 *vals;
uint32_t *vals;
const Byte *defs;
MY_ALLOC_ZE(UInt32, crcs->Vals, numItems, alloc);
MY_ALLOC_ZE(uint32_t, crcs->Vals, numItems, alloc);
sd = *sd2;
defs = crcs->Defs;
vals = crcs->Vals;
@@ -354,17 +354,17 @@ static MY_NO_INLINE SRes ReadUi32s(CSzData *sd2, UInt32 numItems, CSzBitUi32s *c
return SZ_OK;
}
static SRes ReadBitUi32s(CSzData *sd, UInt32 numItems, CSzBitUi32s *crcs, ISzAllocPtr alloc)
static SRes ReadBitUi32s(CSzData *sd, uint32_t numItems, CSzBitUi32s *crcs, ISzAllocPtr alloc)
{
SzBitUi32s_Free(crcs, alloc);
RINOK(ReadBitVector(sd, numItems, &crcs->Defs, alloc));
return ReadUi32s(sd, numItems, crcs, alloc);
}
static SRes SkipBitUi32s(CSzData *sd, UInt32 numItems)
static SRes SkipBitUi32s(CSzData *sd, uint32_t numItems)
{
Byte allAreDefined;
UInt32 numDefined = numItems;
uint32_t numDefined = numItems;
SZ_READ_BYTE(allAreDefined);
if (!allAreDefined)
{
@@ -385,14 +385,14 @@ static SRes ReadPackInfo(CSzAr *p, CSzData *sd, ISzAllocPtr alloc)
RINOK(SzReadNumber32(sd, &p->NumPackStreams));
RINOK(WaitId(sd, k7zIdSize));
MY_ALLOC(UInt64, p->PackPositions, (size_t)p->NumPackStreams + 1, alloc);
MY_ALLOC(uint64_t, p->PackPositions, (size_t)p->NumPackStreams + 1, alloc);
{
UInt64 sum = 0;
UInt32 i;
UInt32 numPackStreams = p->NumPackStreams;
uint64_t sum = 0;
uint32_t i;
uint32_t numPackStreams = p->NumPackStreams;
for (i = 0; i < numPackStreams; i++)
{
UInt64 packSize;
uint64_t packSize;
p->PackPositions[i] = sum;
RINOK(ReadNumber(sd, &packSize));
sum += packSize;
@@ -404,7 +404,7 @@ static SRes ReadPackInfo(CSzAr *p, CSzData *sd, ISzAllocPtr alloc)
for (;;)
{
UInt64 type;
uint64_t type;
RINOK(ReadID(sd, &type));
if (type == k7zIdEnd)
return SZ_OK;
@@ -431,8 +431,8 @@ static SRes SzReadSwitch(CSzData *sd)
SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd)
{
UInt32 numCoders, i;
UInt32 numInStreams = 0;
uint32_t numCoders, i;
uint32_t numInStreams = 0;
const Byte *dataStart = sd->Data;
f->NumCoders = 0;
@@ -449,7 +449,7 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd)
Byte mainByte;
CSzCoderInfo *coder = f->Coders + i;
unsigned idSize, j;
UInt64 id;
uint64_t id;
SZ_READ_BYTE(mainByte);
if ((mainByte & 0xC0) != 0)
@@ -467,9 +467,9 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd)
sd->Data++;
sd->Size--;
}
if (id > (UInt32)0xFFFFFFFF)
if (id > (uint32_t)0xFFFFFFFF)
return SZ_ERROR_UNSUPPORTED;
coder->MethodID = (UInt32)id;
coder->MethodID = (uint32_t)id;
coder->NumStreams = 1;
coder->PropsOffset = 0;
@@ -477,7 +477,7 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd)
if ((mainByte & 0x10) != 0)
{
UInt32 numStreams;
uint32_t numStreams;
RINOK(SzReadNumber32(sd, &numStreams));
if (numStreams > k_NumCodersStreams_in_Folder_MAX)
@@ -496,7 +496,7 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd)
if ((mainByte & 0x20) != 0)
{
UInt32 propsSize = 0;
uint32_t propsSize = 0;
RINOK(SzReadNumber32(sd, &propsSize));
if (propsSize > sd->Size)
return SZ_ERROR_ARCHIVE;
@@ -519,7 +519,7 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd)
*/
{
Byte streamUsed[k_NumCodersStreams_in_Folder_MAX];
UInt32 numBonds, numPackStreams;
uint32_t numBonds, numPackStreams;
numBonds = numCoders - 1;
if (numInStreams < numBonds)
@@ -581,7 +581,7 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd)
else
for (i = 0; i < numPackStreams; i++)
{
UInt32 index;
uint32_t index;
RINOK(SzReadNumber32(sd, &index));
if (index >= numInStreams || streamUsed[index])
return SZ_ERROR_ARCHIVE;
@@ -596,7 +596,7 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd)
}
static MY_NO_INLINE SRes SkipNumbers(CSzData *sd2, UInt32 num)
static MY_NO_INLINE SRes SkipNumbers(CSzData *sd2, uint32_t num)
{
CSzData sd;
sd = *sd2;
@@ -633,13 +633,13 @@ static MY_NO_INLINE SRes SkipNumbers(CSzData *sd2, UInt32 num)
static SRes ReadUnpackInfo(CSzAr *p,
CSzData *sd2,
UInt32 numFoldersMax,
const CBuf *tempBufs, UInt32 numTempBufs,
uint32_t numFoldersMax,
const CBuf *tempBufs, uint32_t numTempBufs,
ISzAllocPtr alloc)
{
CSzData sd;
UInt32 fo, numFolders, numCodersOutStreams, packStreamIndex;
uint32_t fo, numFolders, numCodersOutStreams, packStreamIndex;
const Byte *startBufPtr;
Byte external;
@@ -655,7 +655,7 @@ static SRes ReadUnpackInfo(CSzAr *p,
sd = *sd2;
else
{
UInt32 index;
uint32_t index;
RINOK(SzReadNumber32(sd2, &index));
if (index >= numTempBufs)
return SZ_ERROR_ARCHIVE;
@@ -664,8 +664,8 @@ static SRes ReadUnpackInfo(CSzAr *p,
}
MY_ALLOC(size_t, p->FoCodersOffsets, (size_t)numFolders + 1, alloc);
MY_ALLOC(UInt32, p->FoStartPackStreamIndex, (size_t)numFolders + 1, alloc);
MY_ALLOC(UInt32, p->FoToCoderUnpackSizes, (size_t)numFolders + 1, alloc);
MY_ALLOC(uint32_t, p->FoStartPackStreamIndex, (size_t)numFolders + 1, alloc);
MY_ALLOC(uint32_t, p->FoToCoderUnpackSizes, (size_t)numFolders + 1, alloc);
MY_ALLOC_ZE(Byte, p->FoToMainUnpackSizeIndex, (size_t)numFolders, alloc);
startBufPtr = sd.Data;
@@ -675,7 +675,7 @@ static SRes ReadUnpackInfo(CSzAr *p,
for (fo = 0; fo < numFolders; fo++)
{
UInt32 numCoders, ci, numInStreams = 0;
uint32_t numCoders, ci, numInStreams = 0;
p->FoCodersOffsets[fo] = sd.Data - startBufPtr;
@@ -687,7 +687,7 @@ static SRes ReadUnpackInfo(CSzAr *p,
{
Byte mainByte;
unsigned idSize;
UInt32 coderInStreams;
uint32_t coderInStreams;
SZ_READ_BYTE_2(mainByte);
if ((mainByte & 0xC0) != 0)
@@ -703,7 +703,7 @@ static SRes ReadUnpackInfo(CSzAr *p,
if ((mainByte & 0x10) != 0)
{
UInt32 coderOutStreams;
uint32_t coderOutStreams;
RINOK(SzReadNumber32(&sd, &coderInStreams));
RINOK(SzReadNumber32(&sd, &coderOutStreams));
if (coderInStreams > k_Scan_NumCodersStreams_in_Folder_MAX || coderOutStreams != 1)
@@ -714,7 +714,7 @@ static SRes ReadUnpackInfo(CSzAr *p,
if ((mainByte & 0x20) != 0)
{
UInt32 propsSize;
uint32_t propsSize;
RINOK(SzReadNumber32(&sd, &propsSize));
if (propsSize > sd.Size)
return SZ_ERROR_ARCHIVE;
@@ -723,16 +723,16 @@ static SRes ReadUnpackInfo(CSzAr *p,
}
{
UInt32 indexOfMainStream = 0;
UInt32 numPackStreams = 1;
uint32_t indexOfMainStream = 0;
uint32_t numPackStreams = 1;
if (numCoders != 1 || numInStreams != 1)
{
Byte streamUsed[k_Scan_NumCodersStreams_in_Folder_MAX];
Byte coderUsed[k_Scan_NumCoders_MAX];
UInt32 i;
UInt32 numBonds = numCoders - 1;
uint32_t i;
uint32_t numBonds = numCoders - 1;
if (numInStreams < numBonds)
return SZ_ERROR_ARCHIVE;
@@ -746,7 +746,7 @@ static SRes ReadUnpackInfo(CSzAr *p,
for (i = 0; i < numBonds; i++)
{
UInt32 index;
uint32_t index;
RINOK(SzReadNumber32(&sd, &index));
if (index >= numInStreams || streamUsed[index])
@@ -764,7 +764,7 @@ static SRes ReadUnpackInfo(CSzAr *p,
if (numPackStreams != 1)
for (i = 0; i < numPackStreams; i++)
{
UInt32 index;
uint32_t index;
RINOK(SzReadNumber32(&sd, &index));
if (index >= numInStreams || streamUsed[index])
return SZ_ERROR_ARCHIVE;
@@ -812,9 +812,9 @@ static SRes ReadUnpackInfo(CSzAr *p,
RINOK(WaitId(&sd, k7zIdCodersUnpackSize));
MY_ALLOC_ZE(UInt64, p->CoderUnpackSizes, (size_t)numCodersOutStreams, alloc);
MY_ALLOC_ZE(uint64_t, p->CoderUnpackSizes, (size_t)numCodersOutStreams, alloc);
{
UInt32 i;
uint32_t i;
for (i = 0; i < numCodersOutStreams; i++)
{
RINOK(ReadNumber(&sd, p->CoderUnpackSizes + i));
@@ -823,7 +823,7 @@ static SRes ReadUnpackInfo(CSzAr *p,
for (;;)
{
UInt64 type;
uint64_t type;
RINOK(ReadID(&sd, &type));
if (type == k7zIdEnd)
{
@@ -840,7 +840,7 @@ static SRes ReadUnpackInfo(CSzAr *p,
}
UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex)
uint64_t SzAr_GetFolderUnpackSize(const CSzAr *p, uint32_t folderIndex)
{
return p->CoderUnpackSizes[p->FoToCoderUnpackSizes[folderIndex] + p->FoToMainUnpackSizeIndex[folderIndex]];
}
@@ -848,8 +848,8 @@ UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex)
typedef struct
{
UInt32 NumTotalSubStreams;
UInt32 NumSubDigests;
uint32_t NumTotalSubStreams;
uint32_t NumSubDigests;
CSzData sdNumSubStreams;
CSzData sdSizes;
CSzData sdCRCs;
@@ -858,24 +858,24 @@ typedef struct
static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi)
{
UInt64 type = 0;
UInt32 numSubDigests = 0;
UInt32 numFolders = p->NumFolders;
UInt32 numUnpackStreams = numFolders;
UInt32 numUnpackSizesInData = 0;
uint64_t type = 0;
uint32_t numSubDigests = 0;
uint32_t numFolders = p->NumFolders;
uint32_t numUnpackStreams = numFolders;
uint32_t numUnpackSizesInData = 0;
for (;;)
{
RINOK(ReadID(sd, &type));
if (type == k7zIdNumUnpackStream)
{
UInt32 i;
uint32_t i;
ssi->sdNumSubStreams.Data = sd->Data;
numUnpackStreams = 0;
numSubDigests = 0;
for (i = 0; i < numFolders; i++)
{
UInt32 numStreams;
uint32_t numStreams;
RINOK(SzReadNumber32(sd, &numStreams));
if (numUnpackStreams > numUnpackStreams + numStreams)
return SZ_ERROR_UNSUPPORTED;
@@ -931,12 +931,12 @@ static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi)
static SRes SzReadStreamsInfo(CSzAr *p,
CSzData *sd,
UInt32 numFoldersMax, const CBuf *tempBufs, UInt32 numTempBufs,
UInt64 *dataOffset,
uint32_t numFoldersMax, const CBuf *tempBufs, uint32_t numTempBufs,
uint64_t *dataOffset,
CSubStreamInfo *ssi,
ISzAllocPtr alloc)
{
UInt64 type;
uint64_t type;
SzData_Clear(&ssi->sdSizes);
SzData_Clear(&ssi->sdCRCs);
@@ -973,13 +973,13 @@ static SRes SzReadAndDecodePackedStreams(
ILookInStream *inStream,
CSzData *sd,
CBuf *tempBufs,
UInt32 numFoldersMax,
UInt64 baseOffset,
uint32_t numFoldersMax,
uint64_t baseOffset,
CSzAr *p,
ISzAllocPtr allocTemp)
{
UInt64 dataStartPos;
UInt32 fo;
uint64_t dataStartPos;
uint32_t fo;
CSubStreamInfo ssi;
RINOK(SzReadStreamsInfo(p, sd, numFoldersMax, NULL, 0, &dataStartPos, &ssi, allocTemp));
@@ -994,7 +994,7 @@ static SRes SzReadAndDecodePackedStreams(
for (fo = 0; fo < p->NumFolders; fo++)
{
CBuf *tempBuf = tempBufs + fo;
UInt64 unpackSize = SzAr_GetFolderUnpackSize(p, fo);
uint64_t unpackSize = SzAr_GetFolderUnpackSize(p, fo);
if ((size_t)unpackSize != unpackSize)
return SZ_ERROR_MEM;
if (!Buf_Create(tempBuf, (size_t)unpackSize, allocTemp))
@@ -1011,7 +1011,7 @@ static SRes SzReadAndDecodePackedStreams(
return SZ_OK;
}
static SRes SzReadFileNames(const Byte *data, size_t size, UInt32 numFiles, size_t *offsets)
static SRes SzReadFileNames(const Byte *data, size_t size, uint32_t numFiles, size_t *offsets)
{
size_t pos = 0;
*offsets++ = 0;
@@ -1028,7 +1028,7 @@ static SRes SzReadFileNames(const Byte *data, size_t size, UInt32 numFiles, size
return SZ_ERROR_ARCHIVE;
for (p = data + pos;
#ifdef _WIN32
*(const UInt16 *)p != 0
*(const uint16_t *)p != 0
#else
p[0] != 0 || p[1] != 0
#endif
@@ -1040,13 +1040,13 @@ static SRes SzReadFileNames(const Byte *data, size_t size, UInt32 numFiles, size
return (pos == size) ? SZ_OK : SZ_ERROR_ARCHIVE;
}
static MY_NO_INLINE SRes ReadTime(CSzBitUi64s *p, UInt32 num,
static MY_NO_INLINE SRes ReadTime(CSzBitUi64s *p, uint32_t num,
CSzData *sd2,
const CBuf *tempBufs, UInt32 numTempBufs,
const CBuf *tempBufs, uint32_t numTempBufs,
ISzAllocPtr alloc)
{
CSzData sd;
UInt32 i;
uint32_t i;
CNtfsFileTime *vals;
Byte *defs;
Byte external;
@@ -1058,7 +1058,7 @@ static MY_NO_INLINE SRes ReadTime(CSzBitUi64s *p, UInt32 num,
sd = *sd2;
else
{
UInt32 index;
uint32_t index;
RINOK(SzReadNumber32(sd2, &index));
if (index >= numTempBufs)
return SZ_ERROR_ARCHIVE;
@@ -1095,7 +1095,7 @@ static SRes SzReadHeader2(
CSzArEx *p, /* allocMain */
CSzData *sd,
ILookInStream *inStream,
CBuf *tempBufs, UInt32 *numTempBufs,
CBuf *tempBufs, uint32_t *numTempBufs,
ISzAllocPtr allocMain,
ISzAllocPtr allocTemp
)
@@ -1103,7 +1103,7 @@ static SRes SzReadHeader2(
CSubStreamInfo ssi;
{
UInt64 type;
uint64_t type;
SzData_Clear(&ssi.sdSizes);
SzData_Clear(&ssi.sdCRCs);
@@ -1118,7 +1118,7 @@ static SRes SzReadHeader2(
{
for (;;)
{
UInt64 type2;
uint64_t type2;
RINOK(ReadID(sd, &type2));
if (type2 == k7zIdEnd)
break;
@@ -1145,7 +1145,7 @@ static SRes SzReadHeader2(
if (type == k7zIdMainStreamsInfo)
{
RINOK(SzReadStreamsInfo(&p->db, sd, (UInt32)1 << 30, tempBufs, *numTempBufs,
RINOK(SzReadStreamsInfo(&p->db, sd, (uint32_t)1 << 30, tempBufs, *numTempBufs,
&p->dataPos, &ssi, allocMain));
p->dataPos += p->startPosAfterHeader;
RINOK(ReadID(sd, &type));
@@ -1161,8 +1161,8 @@ static SRes SzReadHeader2(
}
{
UInt32 numFiles = 0;
UInt32 numEmptyStreams = 0;
uint32_t numFiles = 0;
uint32_t numEmptyStreams = 0;
const Byte *emptyStreams = NULL;
const Byte *emptyFiles = NULL;
@@ -1171,8 +1171,8 @@ static SRes SzReadHeader2(
for (;;)
{
UInt64 type;
UInt64 size;
uint64_t type;
uint64_t size;
RINOK(ReadID(sd, &type));
if (type == k7zIdEnd)
break;
@@ -1180,7 +1180,7 @@ static SRes SzReadHeader2(
if (size > sd->Size)
return SZ_ERROR_ARCHIVE;
if (type >= ((UInt32)1 << 8))
if (type >= ((uint32_t)1 << 8))
{
SKIP_DATA(sd, size);
}
@@ -1200,7 +1200,7 @@ static SRes SzReadHeader2(
}
else
{
UInt32 index;
uint32_t index;
RINOK(SzReadNumber32(sd, &index));
if (index >= *numTempBufs)
return SZ_ERROR_ARCHIVE;
@@ -1244,7 +1244,7 @@ static SRes SzReadHeader2(
sdPtr = sd;
else
{
UInt32 index;
uint32_t index;
RINOK(SzReadNumber32(sd, &index));
if (index >= *numTempBufs)
return SZ_ERROR_ARCHIVE;
@@ -1279,7 +1279,7 @@ static SRes SzReadHeader2(
for (;;)
{
UInt64 type;
uint64_t type;
RINOK(ReadID(sd, &type));
if (type == k7zIdEnd)
break;
@@ -1287,24 +1287,24 @@ static SRes SzReadHeader2(
}
{
UInt32 i;
UInt32 emptyFileIndex = 0;
UInt32 folderIndex = 0;
UInt32 remSubStreams = 0;
UInt32 numSubStreams = 0;
UInt64 unpackPos = 0;
uint32_t i;
uint32_t emptyFileIndex = 0;
uint32_t folderIndex = 0;
uint32_t remSubStreams = 0;
uint32_t numSubStreams = 0;
uint64_t unpackPos = 0;
const Byte *digestsDefs = NULL;
const Byte *digestsVals = NULL;
UInt32 digestsValsIndex = 0;
UInt32 digestIndex;
uint32_t digestsValsIndex = 0;
uint32_t digestIndex;
Byte allDigestsDefined = 0;
Byte isDirMask = 0;
Byte crcMask = 0;
Byte mask = 0x80;
MY_ALLOC(UInt32, p->FolderToFile, p->db.NumFolders + 1, allocMain);
MY_ALLOC_ZE(UInt32, p->FileToFolder, p->NumFiles, allocMain);
MY_ALLOC(UInt64, p->UnpackPositions, p->NumFiles + 1, allocMain);
MY_ALLOC(uint32_t, p->FolderToFile, p->db.NumFolders + 1, allocMain);
MY_ALLOC_ZE(uint32_t, p->FileToFolder, p->NumFiles, allocMain);
MY_ALLOC(uint64_t, p->UnpackPositions, p->NumFiles + 1, allocMain);
MY_ALLOC_ZE(Byte, p->IsDirs, (p->NumFiles + 7) >> 3, allocMain);
RINOK(SzBitUi32s_Alloc(&p->CRCs, p->NumFiles, allocMain));
@@ -1328,7 +1328,7 @@ static SRes SzReadHeader2(
{
if (mask == 0)
{
UInt32 byteIndex = (i - 1) >> 3;
uint32_t byteIndex = (i - 1) >> 3;
p->IsDirs[byteIndex] = isDirMask;
p->CRCs.Defs[byteIndex] = crcMask;
isDirMask = 0;
@@ -1351,7 +1351,7 @@ static SRes SzReadHeader2(
isDirMask |= mask;
if (remSubStreams == 0)
{
p->FileToFolder[i] = (UInt32)-1;
p->FileToFolder[i] = (uint32_t)-1;
continue;
}
}
@@ -1372,7 +1372,7 @@ static SRes SzReadHeader2(
if (numSubStreams != 0)
break;
{
UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex);
uint64_t folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex);
unpackPos += folderUnpackSize;
if (unpackPos < folderUnpackSize)
return SZ_ERROR_ARCHIVE;
@@ -1389,8 +1389,8 @@ static SRes SzReadHeader2(
if (--remSubStreams == 0)
{
UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex);
UInt64 startFolderUnpackPos = p->UnpackPositions[p->FolderToFile[folderIndex]];
uint64_t folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex);
uint64_t startFolderUnpackPos = p->UnpackPositions[p->FolderToFile[folderIndex]];
if (folderUnpackSize < unpackPos - startFolderUnpackPos)
return SZ_ERROR_ARCHIVE;
unpackPos = startFolderUnpackPos + folderUnpackSize;
@@ -1413,7 +1413,7 @@ static SRes SzReadHeader2(
}
else
{
UInt64 v;
uint64_t v;
RINOK(ReadNumber(&ssi.sdSizes, &v));
unpackPos += v;
if (unpackPos < v)
@@ -1429,7 +1429,7 @@ static SRes SzReadHeader2(
if (mask != 0x80)
{
UInt32 byteIndex = (i - 1) >> 3;
uint32_t byteIndex = (i - 1) >> 3;
p->IsDirs[byteIndex] = isDirMask;
p->CRCs.Defs[byteIndex] = crcMask;
}
@@ -1451,7 +1451,7 @@ static SRes SzReadHeader2(
return SZ_ERROR_ARCHIVE;
/*
{
UInt64 folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex);
uint64_t folderUnpackSize = SzAr_GetFolderUnpackSize(&p->db, folderIndex);
unpackPos += folderUnpackSize;
if (unpackPos < folderUnpackSize)
return SZ_ERROR_ARCHIVE;
@@ -1475,8 +1475,8 @@ static SRes SzReadHeader(
ISzAllocPtr allocMain,
ISzAllocPtr allocTemp)
{
UInt32 i;
UInt32 numTempBufs = 0;
uint32_t i;
uint32_t numTempBufs = 0;
SRes res;
CBuf tempBufs[NUM_ADDITIONAL_STREAMS_MAX];
@@ -1505,10 +1505,10 @@ static SRes SzArEx_Open2(
ISzAllocPtr allocTemp)
{
Byte header[k7zStartHeaderSize];
Int64 startArcPos;
UInt64 nextHeaderOffset, nextHeaderSize;
int64_t startArcPos;
uint64_t nextHeaderOffset, nextHeaderSize;
size_t nextHeaderSizeT;
UInt32 nextHeaderCRC;
uint32_t nextHeaderCRC;
CBuf buf;
SRes res;
@@ -1541,11 +1541,11 @@ static SRes SzArEx_Open2(
return SZ_ERROR_NO_ARCHIVE;
{
Int64 pos = 0;
int64_t pos = 0;
RINOK(ILookInStream_Seek(inStream, &pos, SZ_SEEK_END));
if ((UInt64)pos < startArcPos + nextHeaderOffset ||
(UInt64)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset ||
(UInt64)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize)
if ((uint64_t)pos < startArcPos + nextHeaderOffset ||
(uint64_t)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset ||
(uint64_t)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize)
return SZ_ERROR_INPUT_EOF;
}
@@ -1562,7 +1562,7 @@ static SRes SzArEx_Open2(
if (CrcCalc(buf.data, nextHeaderSizeT) == nextHeaderCRC)
{
CSzData sd;
UInt64 type;
uint64_t type;
sd.Data = buf.data;
sd.Size = buf.size;
@@ -1635,8 +1635,8 @@ SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream,
SRes SzArEx_Extract(
const CSzArEx *p,
ILookInStream *inStream,
UInt32 fileIndex,
UInt32 *blockIndex,
uint32_t fileIndex,
uint32_t *blockIndex,
Byte **tempBuf,
size_t *outBufferSize,
size_t *offset,
@@ -1644,13 +1644,13 @@ SRes SzArEx_Extract(
ISzAllocPtr allocMain,
ISzAllocPtr allocTemp)
{
UInt32 folderIndex = p->FileToFolder[fileIndex];
uint32_t folderIndex = p->FileToFolder[fileIndex];
SRes res = SZ_OK;
*offset = 0;
*outSizeProcessed = 0;
if (folderIndex == (UInt32)-1)
if (folderIndex == (uint32_t)-1)
{
ISzAlloc_Free(allocMain, *tempBuf);
*blockIndex = folderIndex;
@@ -1661,9 +1661,9 @@ SRes SzArEx_Extract(
if (*tempBuf == NULL || *blockIndex != folderIndex)
{
UInt64 unpackSizeSpec = SzAr_GetFolderUnpackSize(&p->db, folderIndex);
uint64_t unpackSizeSpec = SzAr_GetFolderUnpackSize(&p->db, folderIndex);
/*
UInt64 unpackSizeSpec =
uint64_t unpackSizeSpec =
p->UnpackPositions[p->FolderToFile[(size_t)folderIndex + 1]] -
p->UnpackPositions[p->FolderToFile[folderIndex]];
*/
@@ -1695,7 +1695,7 @@ SRes SzArEx_Extract(
if (res == SZ_OK)
{
UInt64 unpackPos = p->UnpackPositions[fileIndex];
uint64_t unpackPos = p->UnpackPositions[fileIndex];
*offset = (size_t)(unpackPos - p->UnpackPositions[p->FolderToFile[folderIndex]]);
*outSizeProcessed = (size_t)(p->UnpackPositions[(size_t)fileIndex + 1] - unpackPos);
if (*offset + *outSizeProcessed > *outBufferSize)
@@ -1709,7 +1709,7 @@ SRes SzArEx_Extract(
}
size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest)
size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, uint16_t *dest)
{
size_t offs = p->FileNameOffsets[fileIndex];
size_t len = p->FileNameOffsets[fileIndex + 1] - offs;
@@ -1732,17 +1732,17 @@ size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex)
len = 0;
for (;;)
{
UInt32 parent = (UInt32)(Int32)-1;
uint32_t parent = (uint32_t)(Int32)-1;
len += p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex];
if SzBitWithVals_Check(&p->Parents, fileIndex)
parent = p->Parents.Vals[fileIndex];
if (parent == (UInt32)(Int32)-1)
if (parent == (uint32_t)(Int32)-1)
return len;
fileIndex = parent;
}
}
UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest)
uint16_t *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, uint16_t *dest)
{
BoolInt needSlash;
if (!p->FileNameOffsets)
@@ -1753,7 +1753,7 @@ UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16
needSlash = False;
for (;;)
{
UInt32 parent = (UInt32)(Int32)-1;
uint32_t parent = (uint32_t)(Int32)-1;
size_t curLen = p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex];
SzArEx_GetFileNameUtf16(p, fileIndex, dest - curLen);
if (needSlash)
@@ -1763,7 +1763,7 @@ UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16
if SzBitWithVals_Check(&p->Parents, fileIndex)
parent = p->Parents.Vals[fileIndex];
if (parent == (UInt32)(Int32)-1)
if (parent == (uint32_t)(Int32)-1)
return dest;
fileIndex = parent;
}
+15 -15
View File
@@ -15,36 +15,36 @@
#define CRC_UINT32_SWAP(v) ((v >> 24) | ((v >> 8) & 0xFF00) | ((v << 8) & 0xFF0000) | (v << 24))
UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, const UInt32 *table);
UInt32 MY_FAST_CALL CrcUpdateT1_BeT8(UInt32 v, const void *data, size_t size, const UInt32 *table);
uint32_t MY_FAST_CALL CrcUpdateT1_BeT4(uint32_t v, const void *data, size_t size, const uint32_t *table);
uint32_t MY_FAST_CALL CrcUpdateT1_BeT8(uint32_t v, const void *data, size_t size, const uint32_t *table);
#endif
#ifndef MY_CPU_BE
UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table);
UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table);
uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table);
uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table);
#endif
typedef UInt32 (MY_FAST_CALL *CRC_FUNC)(UInt32 v, const void *data, size_t size, const UInt32 *table);
typedef uint32_t (MY_FAST_CALL *CRC_FUNC)(uint32_t v, const void *data, size_t size, const uint32_t *table);
CRC_FUNC g_CrcUpdateT4;
CRC_FUNC g_CrcUpdateT8;
CRC_FUNC g_CrcUpdate;
UInt32 g_CrcTable[256 * CRC_NUM_TABLES];
uint32_t g_CrcTable[256 * CRC_NUM_TABLES];
UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size)
uint32_t MY_FAST_CALL CrcUpdate(uint32_t v, const void *data, size_t size)
{
return g_CrcUpdate(v, data, size, g_CrcTable);
}
UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size)
uint32_t MY_FAST_CALL CrcCalc(const void *data, size_t size)
{
return g_CrcUpdate(CRC_INIT_VAL, data, size, g_CrcTable) ^ CRC_INIT_VAL;
}
#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void *data, size_t size, const UInt32 *table)
uint32_t MY_FAST_CALL CrcUpdateT1(uint32_t v, const void *data, size_t size, const uint32_t *table)
{
const Byte *p = (const Byte *)data;
const Byte *pEnd = p + size;
@@ -55,18 +55,18 @@ UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void *data, size_t size, const U
void MY_FAST_CALL CrcGenerateTable()
{
UInt32 i;
uint32_t i;
for (i = 0; i < 256; i++)
{
UInt32 r = i;
uint32_t r = i;
unsigned j;
for (j = 0; j < 8; j++)
r = (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1)));
r = (r >> 1) ^ (kCrcPoly & ((uint32_t)0 - (r & 1)));
g_CrcTable[i] = r;
}
for (i = 256; i < 256 * CRC_NUM_TABLES; i++)
{
UInt32 r = g_CrcTable[(size_t)i - 256];
uint32_t r = g_CrcTable[(size_t)i - 256];
g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8);
}
@@ -93,7 +93,7 @@ void MY_FAST_CALL CrcGenerateTable()
#else
{
#ifndef MY_CPU_BE
UInt32 k = 0x01020304;
uint32_t k = 0x01020304;
const Byte *p = (const Byte *)&k;
if (p[0] == 4 && p[1] == 3)
{
@@ -111,7 +111,7 @@ void MY_FAST_CALL CrcGenerateTable()
{
for (i = 256 * CRC_NUM_TABLES - 1; i >= 256; i--)
{
UInt32 x = g_CrcTable[(size_t)i - 256];
uint32_t x = g_CrcTable[(size_t)i - 256];
g_CrcTable[i] = CRC_UINT32_SWAP(x);
}
g_CrcUpdateT4 = CrcUpdateT1_BeT4;
+3 -3
View File
@@ -8,7 +8,7 @@
EXTERN_C_BEGIN
extern UInt32 g_CrcTable[];
extern uint32_t g_CrcTable[];
/* Call CrcGenerateTable one time before other CRC functions */
void MY_FAST_CALL CrcGenerateTable(void);
@@ -17,8 +17,8 @@ void MY_FAST_CALL CrcGenerateTable(void);
#define CRC_GET_DIGEST(crc) ((crc) ^ CRC_INIT_VAL)
#define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
UInt32 MY_FAST_CALL CrcUpdate(UInt32 crc, const void *data, size_t size);
UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size);
uint32_t MY_FAST_CALL CrcUpdate(uint32_t crc, const void *data, size_t size);
uint32_t MY_FAST_CALL CrcCalc(const void *data, size_t size);
EXTERN_C_END
+12 -12
View File
@@ -9,14 +9,14 @@
#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table)
uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table)
{
const Byte *p = (const Byte *)data;
for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++)
v = CRC_UPDATE_BYTE_2(v, *p);
for (; size >= 4; size -= 4, p += 4)
{
v ^= *(const UInt32 *)p;
v ^= *(const uint32_t *)p;
v =
(table + 0x300)[((v ) & 0xFF)]
^ (table + 0x200)[((v >> 8) & 0xFF)]
@@ -28,21 +28,21 @@ UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const U
return v;
}
UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table)
uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table)
{
const Byte *p = (const Byte *)data;
for (; size > 0 && ((unsigned)(ptrdiff_t)p & 7) != 0; size--, p++)
v = CRC_UPDATE_BYTE_2(v, *p);
for (; size >= 8; size -= 8, p += 8)
{
UInt32 d;
v ^= *(const UInt32 *)p;
uint32_t d;
v ^= *(const uint32_t *)p;
v =
(table + 0x700)[((v ) & 0xFF)]
^ (table + 0x600)[((v >> 8) & 0xFF)]
^ (table + 0x500)[((v >> 16) & 0xFF)]
^ (table + 0x400)[((v >> 24))];
d = *((const UInt32 *)p + 1);
d = *((const uint32_t *)p + 1);
v ^=
(table + 0x300)[((d ) & 0xFF)]
^ (table + 0x200)[((d >> 8) & 0xFF)]
@@ -63,7 +63,7 @@ UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const U
#define CRC_UPDATE_BYTE_2_BE(crc, b) (table[(((crc) >> 24) ^ (b))] ^ ((crc) << 8))
UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, const UInt32 *table)
uint32_t MY_FAST_CALL CrcUpdateT1_BeT4(uint32_t v, const void *data, size_t size, const uint32_t *table)
{
const Byte *p = (const Byte *)data;
table += 0x100;
@@ -72,7 +72,7 @@ UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, co
v = CRC_UPDATE_BYTE_2_BE(v, *p);
for (; size >= 4; size -= 4, p += 4)
{
v ^= *(const UInt32 *)p;
v ^= *(const uint32_t *)p;
v =
(table + 0x000)[((v ) & 0xFF)]
^ (table + 0x100)[((v >> 8) & 0xFF)]
@@ -84,7 +84,7 @@ UInt32 MY_FAST_CALL CrcUpdateT1_BeT4(UInt32 v, const void *data, size_t size, co
return CRC_UINT32_SWAP(v);
}
UInt32 MY_FAST_CALL CrcUpdateT1_BeT8(UInt32 v, const void *data, size_t size, const UInt32 *table)
uint32_t MY_FAST_CALL CrcUpdateT1_BeT8(uint32_t v, const void *data, size_t size, const uint32_t *table)
{
const Byte *p = (const Byte *)data;
table += 0x100;
@@ -93,14 +93,14 @@ UInt32 MY_FAST_CALL CrcUpdateT1_BeT8(UInt32 v, const void *data, size_t size, co
v = CRC_UPDATE_BYTE_2_BE(v, *p);
for (; size >= 8; size -= 8, p += 8)
{
UInt32 d;
v ^= *(const UInt32 *)p;
uint32_t d;
v ^= *(const uint32_t *)p;
v =
(table + 0x400)[((v ) & 0xFF)]
^ (table + 0x500)[((v >> 8) & 0xFF)]
^ (table + 0x600)[((v >> 16) & 0xFF)]
^ (table + 0x700)[((v >> 24))];
d = *((const UInt32 *)p + 1);
d = *((const uint32_t *)p + 1);
v ^=
(table + 0x000)[((d ) & 0xFF)]
^ (table + 0x100)[((d >> 8) & 0xFF)]
+26 -26
View File
@@ -43,7 +43,7 @@ typedef struct
const Byte *cur;
const Byte *end;
const Byte *begin;
UInt64 processed;
uint64_t processed;
BoolInt extra;
SRes res;
const ILookInStream *inStream;
@@ -70,7 +70,7 @@ static Byte ReadByte(const IByteIn *pp)
return 0;
}
static SRes SzDecodePpmd(const Byte *props, unsigned propsSize, UInt64 inSize, const ILookInStream *inStream,
static SRes SzDecodePpmd(const Byte *props, unsigned propsSize, uint64_t inSize, const ILookInStream *inStream,
Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain)
{
CPpmd7 ppmd;
@@ -89,7 +89,7 @@ static SRes SzDecodePpmd(const Byte *props, unsigned propsSize, UInt64 inSize, c
{
unsigned order = props[0];
UInt32 memSize = GetUi32(props + 1);
uint32_t memSize = GetUi32(props + 1);
if (order < PPMD7_MIN_ORDER ||
order > PPMD7_MAX_ORDER ||
memSize < PPMD7_MIN_MEM_SIZE ||
@@ -131,7 +131,7 @@ static SRes SzDecodePpmd(const Byte *props, unsigned propsSize, UInt64 inSize, c
#endif
static SRes SzDecodeLzma(const Byte *props, unsigned propsSize, UInt64 inSize, ILookInStream *inStream,
static SRes SzDecodeLzma(const Byte *props, unsigned propsSize, uint64_t inSize, ILookInStream *inStream,
Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain)
{
CLzmaDec state;
@@ -191,7 +191,7 @@ static SRes SzDecodeLzma(const Byte *props, unsigned propsSize, UInt64 inSize, I
#ifndef _7Z_NO_METHOD_LZMA2
static SRes SzDecodeLzma2(const Byte *props, unsigned propsSize, UInt64 inSize, ILookInStream *inStream,
static SRes SzDecodeLzma2(const Byte *props, unsigned propsSize, uint64_t inSize, ILookInStream *inStream,
Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain)
{
CLzma2Dec state;
@@ -250,7 +250,7 @@ static SRes SzDecodeLzma2(const Byte *props, unsigned propsSize, UInt64 inSize,
#endif
static SRes SzDecodeCopy(UInt64 inSize, ILookInStream *inStream, Byte *outBuffer)
static SRes SzDecodeCopy(uint64_t inSize, ILookInStream *inStream, Byte *outBuffer)
{
while (inSize > 0)
{
@@ -269,7 +269,7 @@ static SRes SzDecodeCopy(UInt64 inSize, ILookInStream *inStream, Byte *outBuffer
return SZ_OK;
}
static BoolInt IS_MAIN_METHOD(UInt32 m)
static BoolInt IS_MAIN_METHOD(uint32_t m)
{
switch (m)
{
@@ -290,8 +290,8 @@ static BoolInt IS_SUPPORTED_CODER(const CSzCoderInfo *c)
{
return
c->NumStreams == 1
/* && c->MethodID <= (UInt32)0xFFFFFFFF */
&& IS_MAIN_METHOD((UInt32)c->MethodID);
/* && c->MethodID <= (uint32_t)0xFFFFFFFF */
&& IS_MAIN_METHOD((uint32_t)c->MethodID);
}
#define IS_BCJ2(c) ((c)->MethodID == k_BCJ2 && (c)->NumStreams == 4)
@@ -316,7 +316,7 @@ static SRes CheckSupportedFolder(const CSzFolder *f)
{
const CSzCoderInfo *c = &f->Coders[1];
if (
/* c->MethodID > (UInt32)0xFFFFFFFF || */
/* c->MethodID > (uint32_t)0xFFFFFFFF || */
c->NumStreams != 1
|| f->NumPackStreams != 1
|| f->PackStreams[0] != 0
@@ -324,7 +324,7 @@ static SRes CheckSupportedFolder(const CSzFolder *f)
|| f->Bonds[0].InIndex != 1
|| f->Bonds[0].OutIndex != 0)
return SZ_ERROR_UNSUPPORTED;
switch ((UInt32)c->MethodID)
switch ((uint32_t)c->MethodID)
{
case k_Delta:
case k_BCJ:
@@ -369,13 +369,13 @@ static SRes CheckSupportedFolder(const CSzFolder *f)
static SRes SzFolder_Decode2(const CSzFolder *folder,
const Byte *propsData,
const UInt64 *unpackSizes,
const UInt64 *packPositions,
ILookInStream *inStream, UInt64 startPos,
const uint64_t *unpackSizes,
const uint64_t *packPositions,
ILookInStream *inStream, uint64_t startPos,
Byte *outBuffer, SizeT outSize, ISzAllocPtr allocMain,
Byte *tempBuf[])
{
UInt32 ci;
uint32_t ci;
SizeT tempSizes[3] = { 0, 0, 0};
SizeT tempSize3 = 0;
Byte *tempBuf3 = 0;
@@ -386,17 +386,17 @@ static SRes SzFolder_Decode2(const CSzFolder *folder,
{
const CSzCoderInfo *coder = &folder->Coders[ci];
if (IS_MAIN_METHOD((UInt32)coder->MethodID))
if (IS_MAIN_METHOD((uint32_t)coder->MethodID))
{
UInt32 si = 0;
UInt64 offset;
UInt64 inSize;
uint32_t si = 0;
uint64_t offset;
uint64_t inSize;
Byte *outBufCur = outBuffer;
SizeT outSizeCur = outSize;
if (folder->NumCoders == 4)
{
UInt32 indices[] = { 3, 2, 0 };
UInt64 unpackSize = unpackSizes[ci];
uint32_t indices[] = { 3, 2, 0 };
uint64_t unpackSize = unpackSizes[ci];
si = indices[ci];
if (ci < 2)
{
@@ -451,8 +451,8 @@ static SRes SzFolder_Decode2(const CSzFolder *folder,
}
else if (coder->MethodID == k_BCJ2)
{
UInt64 offset = packPositions[1];
UInt64 s3Size = packPositions[2] - offset;
uint64_t offset = packPositions[1];
uint64_t s3Size = packPositions[2] - offset;
if (ci != 3)
return SZ_ERROR_UNSUPPORTED;
@@ -522,7 +522,7 @@ static SRes SzFolder_Decode2(const CSzFolder *folder,
{
case k_BCJ:
{
UInt32 state;
uint32_t state;
x86_Convert_Init(state);
x86_Convert(outBuffer, outSize, 0, &state, 0);
break;
@@ -546,8 +546,8 @@ static SRes SzFolder_Decode2(const CSzFolder *folder,
}
SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex,
ILookInStream *inStream, UInt64 startPos,
SRes SzAr_DecodeFolder(const CSzAr *p, uint32_t folderIndex,
ILookInStream *inStream, uint64_t startPos,
Byte *outBuffer, size_t outSize,
ISzAllocPtr allocMain)
{
+6 -6
View File
@@ -166,14 +166,14 @@ WRes File_Write(CSzFile *p, const void *data, size_t *size)
#endif
}
WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin)
WRes File_Seek(CSzFile *p, int64_t *pos, ESzSeek origin)
{
#ifdef USE_WINDOWS_FILE
LARGE_INTEGER value;
DWORD moveMethod;
value.LowPart = (DWORD)*pos;
value.HighPart = (LONG)((UInt64)*pos >> 16 >> 16); /* for case when UInt64 is 32-bit only */
value.HighPart = (LONG)((uint64_t)*pos >> 16 >> 16); /* for case when uint64_t is 32-bit only */
switch (origin)
{
case SZ_SEEK_SET: moveMethod = FILE_BEGIN; break;
@@ -188,7 +188,7 @@ WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin)
if (res != NO_ERROR)
return res;
}
*pos = ((Int64)value.HighPart << 32) | value.LowPart;
*pos = ((int64_t)value.HighPart << 32) | value.LowPart;
return 0;
#else
@@ -209,7 +209,7 @@ WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin)
#endif
}
WRes File_GetLength(CSzFile *p, UInt64 *length)
WRes File_GetLength(CSzFile *p, uint64_t *length)
{
#ifdef USE_WINDOWS_FILE
@@ -221,7 +221,7 @@ WRes File_GetLength(CSzFile *p, UInt64 *length)
if (res != NO_ERROR)
return res;
}
*length = (((UInt64)sizeHigh) << 32) + sizeLow;
*length = (((uint64_t)sizeHigh) << 32) + sizeLow;
return 0;
#else
@@ -258,7 +258,7 @@ static SRes FileInStream_Read(const ISeekInStream *pp, void *buf, size_t *size)
return (File_Read(&p->file, buf, size) == 0) ? SZ_OK : SZ_ERROR_READ;
}
static SRes FileInStream_Seek(const ISeekInStream *pp, Int64 *pos, ESzSeek origin)
static SRes FileInStream_Seek(const ISeekInStream *pp, int64_t *pos, ESzSeek origin)
{
CFileInStream *p = CONTAINER_FROM_VTBL(pp, CFileInStream, vt);
return File_Seek(&p->file, pos, origin);
+2 -2
View File
@@ -46,8 +46,8 @@ WRes File_Read(CSzFile *p, void *data, size_t *size);
/* writes *size bytes */
WRes File_Write(CSzFile *p, const void *data, size_t *size);
WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin);
WRes File_GetLength(CSzFile *p, UInt64 *length);
WRes File_Seek(CSzFile *p, int64_t *pos, ESzSeek origin);
WRes File_GetLength(CSzFile *p, uint64_t *length);
/* ---------- FileInStream ---------- */
+3 -3
View File
@@ -35,9 +35,9 @@ SRes SeqInStream_ReadByte(const ISeqInStream *stream, Byte *buf)
SRes LookInStream_SeekTo(const ILookInStream *stream, UInt64 offset)
SRes LookInStream_SeekTo(const ILookInStream *stream, uint64_t offset)
{
Int64 t = offset;
int64_t t = offset;
return ILookInStream_Seek(stream, &t, SZ_SEEK_SET);
}
@@ -134,7 +134,7 @@ static SRes LookToRead2_Read(const ILookInStream *pp, void *buf, size_t *size)
return SZ_OK;
}
static SRes LookToRead2_Seek(const ILookInStream *pp, Int64 *pos, ESzSeek origin)
static SRes LookToRead2_Seek(const ILookInStream *pp, int64_t *pos, ESzSeek origin)
{
GET_LookToRead2
p->pos = p->size = 0;
+7 -23
View File
@@ -4,11 +4,8 @@
#ifndef __7Z_TYPES_H
#define __7Z_TYPES_H
#ifdef _WIN32
/* #include <windows.h> */
#endif
#include <stddef.h>
#include <stdint.h>
#ifndef EXTERN_C_BEGIN
#ifdef __cplusplus
@@ -67,15 +64,6 @@ typedef int WRes;
typedef unsigned char Byte;
#endif
typedef short Int16;
typedef unsigned short UInt16;
#if defined(_LZMA_UINT32_IS_ULONG) && !defined(__LP64__)
typedef long Int32;
typedef unsigned long UInt32;
#else
typedef int Int32;
typedef unsigned int UInt32;
#endif
#ifdef _SZ_NO_INT_64
@@ -83,24 +71,20 @@ typedef unsigned int UInt32;
NOTES: Some code will work incorrectly in that case! */
typedef long Int64;
typedef unsigned long UInt64;
#else
#if defined(_MSC_VER) || defined(__BORLANDC__)
typedef __int64 Int64;
typedef unsigned __int64 UInt64;
#define UINT64_CONST(n) n
#else
typedef long long int Int64;
typedef unsigned long long int UInt64;
#define UINT64_CONST(n) n ## ULL
#endif
#endif
#ifdef _LZMA_NO_SYSTEM_SIZE_T
typedef UInt32 SizeT;
typedef uint32_t SizeT;
#else
typedef size_t SizeT;
#endif
@@ -204,7 +188,7 @@ typedef struct ISeekInStream ISeekInStream;
struct ISeekInStream
{
SRes (*Read)(const ISeekInStream *p, void *buf, size_t *size); /* same as ISeqInStream::Read */
SRes (*Seek)(const ISeekInStream *p, Int64 *pos, ESzSeek origin);
SRes (*Seek)(const ISeekInStream *p, int64_t *pos, ESzSeek origin);
};
#define ISeekInStream_Read(p, buf, size) (p)->Read(p, buf, size)
#define ISeekInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin)
@@ -222,7 +206,7 @@ struct ILookInStream
SRes (*Read)(const ILookInStream *p, void *buf, size_t *size);
/* reads directly (without buffer). It's same as ISeqInStream::Read */
SRes (*Seek)(const ILookInStream *p, Int64 *pos, ESzSeek origin);
SRes (*Seek)(const ILookInStream *p, int64_t *pos, ESzSeek origin);
};
#define ILookInStream_Look(p, buf, size) (p)->Look(p, buf, size)
@@ -232,7 +216,7 @@ struct ILookInStream
SRes LookInStream_LookRead(const ILookInStream *stream, void *buf, size_t *size);
SRes LookInStream_SeekTo(const ILookInStream *stream, UInt64 offset);
SRes LookInStream_SeekTo(const ILookInStream *stream, uint64_t offset);
/* reads via ILookInStream::Read */
SRes LookInStream_Read2(const ILookInStream *stream, void *buf, size_t size, SRes errorType);
@@ -281,9 +265,9 @@ typedef struct ICompressProgress ICompressProgress;
struct ICompressProgress
{
SRes (*Progress)(const ICompressProgress *p, UInt64 inSize, UInt64 outSize);
SRes (*Progress)(const ICompressProgress *p, uint64_t inSize, uint64_t outSize);
/* Returns: result. (result != SZ_OK) means break.
Value (UInt64)(Int64)-1 for size means unknown value. */
Value (uint64_t)(int64_t)-1 for size means unknown value. */
};
#define ICompressProgress_Progress(p, inSize, outSize) (p)->Progress(p, inSize, outSize)
+7 -7
View File
@@ -6,10 +6,10 @@
#include "Bcj2.h"
#include "CpuArch.h"
#define CProb UInt16
#define CProb uint16_t
#undef kTopValue
#define kTopValue ((UInt32)1 << 24)
#define kTopValue ((uint32_t)1 << 24)
#define kNumModelBits 11
#undef kBitModelTotal
#define kBitModelTotal (1 << kNumModelBits)
@@ -78,7 +78,7 @@ SRes Bcj2Dec_Decode(CBcj2Dec *p)
p->bufs[p->state] = cur + 4;
{
UInt32 val;
uint32_t val;
Byte *dest;
SizeT rem;
@@ -176,7 +176,7 @@ SRes Bcj2Dec_Decode(CBcj2Dec *p)
{
p->temp[3] = src[-1];
p->bufs[BCJ2_STREAM_MAIN] = src;
p->ip += (UInt32)num;
p->ip += (uint32_t)num;
p->dest += num;
p->state =
p->bufs[BCJ2_STREAM_MAIN] ==
@@ -187,7 +187,7 @@ SRes Bcj2Dec_Decode(CBcj2Dec *p)
}
{
UInt32 bound, ttt;
uint32_t bound, ttt;
CProb *prob;
Byte b = src[0];
Byte prev = (Byte)(num == 0 ? p->temp[3] : src[-1]);
@@ -195,7 +195,7 @@ SRes Bcj2Dec_Decode(CBcj2Dec *p)
p->temp[3] = b;
p->bufs[BCJ2_STREAM_MAIN] = src + 1;
num++;
p->ip += (UInt32)num;
p->ip += (uint32_t)num;
p->dest += num;
prob = p->probs + (unsigned)(b == 0xE8 ? 2 + (unsigned)prev : (b == 0xE9 ? 1 : 0));
@@ -212,7 +212,7 @@ SRes Bcj2Dec_Decode(CBcj2Dec *p)
}
{
UInt32 val;
uint32_t val;
unsigned cj = (p->temp[3] == 0xE8) ? BCJ2_STREAM_CALL : BCJ2_STREAM_JUMP;
const Byte *cur = p->bufs[cj];
Byte *dest;
+15 -15
View File
@@ -68,11 +68,11 @@ typedef struct
unsigned state; /* BCJ2_STREAM_MAIN has more priority than BCJ2_STATE_ORIG */
UInt32 ip;
uint32_t ip;
Byte temp[4];
UInt32 range;
UInt32 code;
UInt16 probs[2 + 256];
uint32_t range;
uint32_t code;
uint16_t probs[2 + 256];
} CBcj2Dec;
void Bcj2Dec_Init(CBcj2Dec *p);
@@ -104,28 +104,28 @@ typedef struct
Byte prevByte;
Byte cache;
UInt32 range;
UInt64 low;
UInt64 cacheSize;
uint32_t range;
uint64_t low;
uint64_t cacheSize;
UInt32 ip;
uint32_t ip;
/* 32-bit ralative offset in JUMP/CALL commands is
- (mod 4 GB) in 32-bit mode
- signed Int32 in 64-bit mode
We use (mod 4 GB) check for fileSize.
Use fileSize up to 2 GB, if you want to support 32-bit and 64-bit code conversion. */
UInt32 fileIp;
UInt32 fileSize; /* (fileSize <= ((UInt32)1 << 31)), 0 means no_limit */
UInt32 relatLimit; /* (relatLimit <= ((UInt32)1 << 31)), 0 means desable_conversion */
uint32_t fileIp;
uint32_t fileSize; /* (fileSize <= ((uint32_t)1 << 31)), 0 means no_limit */
uint32_t relatLimit; /* (relatLimit <= ((uint32_t)1 << 31)), 0 means desable_conversion */
UInt32 tempTarget;
uint32_t tempTarget;
unsigned tempPos;
Byte temp[4 * 2];
unsigned flushPos;
UInt16 probs[2 + 256];
uint16_t probs[2 + 256];
} CBcj2Enc;
void Bcj2Enc_Init(CBcj2Enc *p);
@@ -136,10 +136,10 @@ void Bcj2Enc_Encode(CBcj2Enc *p);
#define BCJ2_RELAT_LIMIT_NUM_BITS 26
#define BCJ2_RELAT_LIMIT ((UInt32)1 << BCJ2_RELAT_LIMIT_NUM_BITS)
#define BCJ2_RELAT_LIMIT ((uint32_t)1 << BCJ2_RELAT_LIMIT_NUM_BITS)
/* limit for CBcj2Enc::fileSize variable */
#define BCJ2_FileSize_MAX ((UInt32)1 << 31)
#define BCJ2_FileSize_MAX ((uint32_t)1 << 31)
EXTERN_C_END
+35 -35
View File
@@ -6,7 +6,7 @@
#include "CpuArch.h"
#include "Bra.h"
SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
SizeT ARM_Convert(Byte *data, SizeT size, uint32_t ip, int encoding)
{
Byte *p;
const Byte *lim;
@@ -28,9 +28,9 @@ SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
break;
}
{
UInt32 v = GetUi32(p - 4);
uint32_t v = GetUi32(p - 4);
v <<= 2;
v += ip + (UInt32)(p - data);
v += ip + (uint32_t)(p - data);
v >>= 2;
v &= 0x00FFFFFF;
v |= 0xEB000000;
@@ -49,9 +49,9 @@ SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
break;
}
{
UInt32 v = GetUi32(p - 4);
uint32_t v = GetUi32(p - 4);
v <<= 2;
v -= ip + (UInt32)(p - data);
v -= ip + (uint32_t)(p - data);
v >>= 2;
v &= 0x00FFFFFF;
v |= 0xEB000000;
@@ -61,7 +61,7 @@ SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
}
SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
SizeT ARMT_Convert(Byte *data, SizeT size, uint32_t ip, int encoding)
{
Byte *p;
const Byte *lim;
@@ -73,10 +73,10 @@ SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
for (;;)
{
UInt32 b1;
uint32_t b1;
for (;;)
{
UInt32 b3;
uint32_t b3;
if (p > lim)
return p - data;
b1 = p[1];
@@ -87,15 +87,15 @@ SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
break;
}
{
UInt32 v =
((UInt32)b1 << 19)
+ (((UInt32)p[1] & 0x7) << 8)
+ (((UInt32)p[-2] << 11))
uint32_t v =
((uint32_t)b1 << 19)
+ (((uint32_t)p[1] & 0x7) << 8)
+ (((uint32_t)p[-2] << 11))
+ (p[0]);
p += 2;
{
UInt32 cur = (ip + (UInt32)(p - data)) >> 1;
uint32_t cur = (ip + (uint32_t)(p - data)) >> 1;
v += cur;
}
@@ -108,10 +108,10 @@ SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
for (;;)
{
UInt32 b1;
uint32_t b1;
for (;;)
{
UInt32 b3;
uint32_t b3;
if (p > lim)
return p - data;
b1 = p[1];
@@ -122,21 +122,21 @@ SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
break;
}
{
UInt32 v =
((UInt32)b1 << 19)
+ (((UInt32)p[1] & 0x7) << 8)
+ (((UInt32)p[-2] << 11))
uint32_t v =
((uint32_t)b1 << 19)
+ (((uint32_t)p[1] & 0x7) << 8)
+ (((uint32_t)p[-2] << 11))
+ (p[0]);
p += 2;
{
UInt32 cur = (ip + (UInt32)(p - data)) >> 1;
uint32_t cur = (ip + (uint32_t)(p - data)) >> 1;
v -= cur;
}
/*
SetUi16(p - 4, (UInt16)(((v >> 11) & 0x7FF) | 0xF000));
SetUi16(p - 2, (UInt16)(v | 0xF800));
SetUi16(p - 4, (uint16_t)(((v >> 11) & 0x7FF) | 0xF000));
SetUi16(p - 2, (uint16_t)(v | 0xF800));
*/
p[-4] = (Byte)(v >> 11);
@@ -148,7 +148,7 @@ SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
}
SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
SizeT PPC_Convert(Byte *data, SizeT size, uint32_t ip, int encoding)
{
Byte *p;
const Byte *lim;
@@ -169,11 +169,11 @@ SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
break;
}
{
UInt32 v = GetBe32(p - 4);
uint32_t v = GetBe32(p - 4);
if (encoding)
v += ip + (UInt32)(p - data);
v += ip + (uint32_t)(p - data);
else
v -= ip + (UInt32)(p - data);
v -= ip + (uint32_t)(p - data);
v &= 0x03FFFFFF;
v |= 0x48000000;
SetBe32(p - 4, v);
@@ -182,7 +182,7 @@ SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
}
SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
SizeT SPARC_Convert(Byte *data, SizeT size, uint32_t ip, int encoding)
{
Byte *p;
const Byte *lim;
@@ -200,10 +200,10 @@ SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
/*
v = GetBe32(p);
p += 4;
m = v + ((UInt32)5 << 29);
m ^= (UInt32)7 << 29;
m += (UInt32)1 << 22;
if ((m & ((UInt32)0x1FF << 23)) == 0)
m = v + ((uint32_t)5 << 29);
m ^= (uint32_t)7 << 29;
m += (uint32_t)1 << 22;
if ((m & ((uint32_t)0x1FF << 23)) == 0)
break;
*/
p += 4;
@@ -212,15 +212,15 @@ SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
break;
}
{
UInt32 v = GetBe32(p - 4);
uint32_t v = GetBe32(p - 4);
v <<= 2;
if (encoding)
v += ip + (UInt32)(p - data);
v += ip + (uint32_t)(p - data);
else
v -= ip + (UInt32)(p - data);
v -= ip + (uint32_t)(p - data);
v &= 0x01FFFFFF;
v -= (UInt32)1 << 24;
v -= (uint32_t)1 << 24;
v ^= 0xFF000000;
v >>= 2;
v |= 0x40000000;
+7 -7
View File
@@ -40,7 +40,7 @@ in CALL instructions to increase the compression ratio.
Example:
UInt32 ip = 0;
uint32_t ip = 0;
for ()
{
; size must be >= Alignment + LookAhead, if it's not last block
@@ -52,12 +52,12 @@ in CALL instructions to increase the compression ratio.
*/
#define x86_Convert_Init(state) { state = 0; }
SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding);
SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
SizeT x86_Convert(Byte *data, SizeT size, uint32_t ip, uint32_t *state, int encoding);
SizeT ARM_Convert(Byte *data, SizeT size, uint32_t ip, int encoding);
SizeT ARMT_Convert(Byte *data, SizeT size, uint32_t ip, int encoding);
SizeT PPC_Convert(Byte *data, SizeT size, uint32_t ip, int encoding);
SizeT SPARC_Convert(Byte *data, SizeT size, uint32_t ip, int encoding);
SizeT IA64_Convert(Byte *data, SizeT size, uint32_t ip, int encoding);
EXTERN_C_END
+5 -5
View File
@@ -7,10 +7,10 @@
#define Test86MSByte(b) ((((b) + 1) & 0xFE) == 0)
SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding)
SizeT x86_Convert(Byte *data, SizeT size, uint32_t ip, uint32_t *state, int encoding)
{
SizeT pos = 0;
UInt32 mask = *state & 7;
uint32_t mask = *state & 7;
if (size < 5)
return 0;
size -= 4;
@@ -48,8 +48,8 @@ SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding
if (Test86MSByte(p[4]))
{
UInt32 v = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]);
UInt32 cur = ip + (UInt32)pos;
uint32_t v = ((uint32_t)p[4] << 24) | ((uint32_t)p[3] << 16) | ((uint32_t)p[2] << 8) | ((uint32_t)p[1]);
uint32_t cur = ip + (uint32_t)pos;
pos += 5;
if (encoding)
v += cur;
@@ -60,7 +60,7 @@ SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding
unsigned sh = (mask & 6) << 2;
if (Test86MSByte((Byte)(v >> sh)))
{
v ^= (((UInt32)0x100 << sh) - 1);
v ^= (((uint32_t)0x100 << sh) - 1);
if (encoding)
v += cur;
else
+6 -6
View File
@@ -6,7 +6,7 @@
#include "CpuArch.h"
#include "Bra.h"
SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
SizeT IA64_Convert(Byte *data, SizeT size, uint32_t ip, int encoding)
{
SizeT i;
if (size < 16)
@@ -15,7 +15,7 @@ SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
i = 0;
do
{
unsigned m = ((UInt32)0x334B0000 >> (data[i] & 0x1E)) & 3;
unsigned m = ((uint32_t)0x334B0000 >> (data[i] & 0x1E)) & 3;
if (m)
{
m++;
@@ -23,7 +23,7 @@ SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
{
Byte *p = data + (i + (size_t)m * 5 - 8);
if (((p[3] >> m) & 15) == 5
&& (((p[-1] | ((UInt32)p[0] << 8)) >> m) & 0x70) == 0)
&& (((p[-1] | ((uint32_t)p[0] << 8)) >> m) & 0x70) == 0)
{
unsigned raw = GetUi32(p);
unsigned v = raw >> m;
@@ -31,15 +31,15 @@ SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
v <<= 4;
if (encoding)
v += ip + (UInt32)i;
v += ip + (uint32_t)i;
else
v -= ip + (UInt32)i;
v -= ip + (uint32_t)i;
v >>= 4;
v &= 0x1FFFFF;
v += 0x700000;
v &= 0x8FFFFF;
raw &= ~((UInt32)0x8FFFFF << m);
raw &= ~((uint32_t)0x8FFFFF << m);
raw |= (v << m);
SetUi32(p, raw);
}
+8 -8
View File
@@ -16,7 +16,7 @@
#endif
#if defined(USE_ASM) && !defined(MY_CPU_AMD64)
static UInt32 CheckFlag(UInt32 flag)
static uint32_t CheckFlag(uint32_t flag)
{
#ifdef _MSC_VER
__asm pushfd;
@@ -55,13 +55,13 @@ static UInt32 CheckFlag(UInt32 flag)
#define CHECK_CPUID_IS_SUPPORTED
#endif
void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d)
void MyCPUID(uint32_t function, uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d)
{
#ifdef USE_ASM
#ifdef _MSC_VER
UInt32 a2, b2, c2, d2;
uint32_t a2, b2, c2, d2;
__asm xor EBX, EBX;
__asm xor ECX, ECX;
__asm xor EDX, EDX;
@@ -123,7 +123,7 @@ BoolInt x86cpuid_CheckAndRead(Cx86cpuid *p)
return True;
}
static const UInt32 kVendors[][3] =
static const uint32_t kVendors[][3] =
{
{ 0x756E6547, 0x49656E69, 0x6C65746E},
{ 0x68747541, 0x69746E65, 0x444D4163},
@@ -135,7 +135,7 @@ int x86cpuid_GetFirm(const Cx86cpuid *p)
unsigned i;
for (i = 0; i < sizeof(kVendors) / sizeof(kVendors[i]); i++)
{
const UInt32 *v = kVendors[i];
const uint32_t *v = kVendors[i];
if (v[0] == p->vendor[0] &&
v[1] == p->vendor[1] &&
v[2] == p->vendor[2])
@@ -148,7 +148,7 @@ BoolInt CPU_Is_InOrder(void)
{
Cx86cpuid p;
int firm;
UInt32 family, model;
uint32_t family, model;
if (!x86cpuid_CheckAndRead(&p))
return True;
@@ -203,13 +203,13 @@ BoolInt CPU_IsSupported_PageGB(void)
if (!x86cpuid_CheckAndRead(&cpuid))
return False;
{
UInt32 d[4] = { 0 };
uint32_t d[4] = { 0 };
MyCPUID(0x80000000, &d[0], &d[1], &d[2], &d[3]);
if (d[0] < 0x80000001)
return False;
}
{
UInt32 d[4] = { 0 };
uint32_t d[4] = { 0 };
MyCPUID(0x80000001, &d[0], &d[1], &d[2], &d[3]);
return (d[3] >> 26) & 1;
}
+39 -39
View File
@@ -198,41 +198,41 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem
#ifdef MY_CPU_LE_UNALIGN
#define GetUi16(p) (*(const UInt16 *)(const void *)(p))
#define GetUi32(p) (*(const UInt32 *)(const void *)(p))
#define GetUi64(p) (*(const UInt64 *)(const void *)(p))
#define GetUi16(p) (*(const uint16_t *)(const void *)(p))
#define GetUi32(p) (*(const uint32_t *)(const void *)(p))
#define GetUi64(p) (*(const uint64_t *)(const void *)(p))
#define SetUi16(p, v) { *(UInt16 *)(p) = (v); }
#define SetUi32(p, v) { *(UInt32 *)(p) = (v); }
#define SetUi64(p, v) { *(UInt64 *)(p) = (v); }
#define SetUi16(p, v) { *(uint16_t *)(p) = (v); }
#define SetUi32(p, v) { *(uint32_t *)(p) = (v); }
#define SetUi64(p, v) { *(uint64_t *)(p) = (v); }
#else
#define GetUi16(p) ( (UInt16) ( \
#define GetUi16(p) ( (uint16_t) ( \
((const Byte *)(p))[0] | \
((UInt16)((const Byte *)(p))[1] << 8) ))
((uint16_t)((const Byte *)(p))[1] << 8) ))
#define GetUi32(p) ( \
((const Byte *)(p))[0] | \
((UInt32)((const Byte *)(p))[1] << 8) | \
((UInt32)((const Byte *)(p))[2] << 16) | \
((UInt32)((const Byte *)(p))[3] << 24))
((uint32_t)((const Byte *)(p))[1] << 8) | \
((uint32_t)((const Byte *)(p))[2] << 16) | \
((uint32_t)((const Byte *)(p))[3] << 24))
#define GetUi64(p) (GetUi32(p) | ((UInt64)GetUi32(((const Byte *)(p)) + 4) << 32))
#define GetUi64(p) (GetUi32(p) | ((uint64_t)GetUi32(((const Byte *)(p)) + 4) << 32))
#define SetUi16(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \
#define SetUi16(p, v) { Byte *_ppp_ = (Byte *)(p); uint32_t _vvv_ = (v); \
_ppp_[0] = (Byte)_vvv_; \
_ppp_[1] = (Byte)(_vvv_ >> 8); }
#define SetUi32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \
#define SetUi32(p, v) { Byte *_ppp_ = (Byte *)(p); uint32_t _vvv_ = (v); \
_ppp_[0] = (Byte)_vvv_; \
_ppp_[1] = (Byte)(_vvv_ >> 8); \
_ppp_[2] = (Byte)(_vvv_ >> 16); \
_ppp_[3] = (Byte)(_vvv_ >> 24); }
#define SetUi64(p, v) { Byte *_ppp2_ = (Byte *)(p); UInt64 _vvv2_ = (v); \
SetUi32(_ppp2_ , (UInt32)_vvv2_); \
SetUi32(_ppp2_ + 4, (UInt32)(_vvv2_ >> 32)); }
#define SetUi64(p, v) { Byte *_ppp2_ = (Byte *)(p); uint64_t _vvv2_ = (v); \
SetUi32(_ppp2_ , (uint32_t)_vvv2_); \
SetUi32(_ppp2_ + 4, (uint32_t)(_vvv2_ >> 32)); }
#endif
@@ -252,33 +252,33 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem
#pragma intrinsic(_byteswap_ulong)
#pragma intrinsic(_byteswap_uint64)
/* #define GetBe16(p) _byteswap_ushort(*(const UInt16 *)(const Byte *)(p)) */
#define GetBe32(p) _byteswap_ulong(*(const UInt32 *)(const Byte *)(p))
#define GetBe64(p) _byteswap_uint64(*(const UInt64 *)(const Byte *)(p))
/* #define GetBe16(p) _byteswap_ushort(*(const uint16_t *)(const Byte *)(p)) */
#define GetBe32(p) _byteswap_ulong(*(const uint32_t *)(const Byte *)(p))
#define GetBe64(p) _byteswap_uint64(*(const uint64_t *)(const Byte *)(p))
#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = _byteswap_ulong(v)
#define SetBe32(p, v) (*(uint32_t *)(void *)(p)) = _byteswap_ulong(v)
#elif defined(MY_CPU_LE_UNALIGN) && ( \
(defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) \
|| (defined(__clang__) && MY__has_builtin(__builtin_bswap16)) )
/* #define GetBe16(p) __builtin_bswap16(*(const UInt16 *)(const Byte *)(p)) */
#define GetBe32(p) __builtin_bswap32(*(const UInt32 *)(const Byte *)(p))
#define GetBe64(p) __builtin_bswap64(*(const UInt64 *)(const Byte *)(p))
/* #define GetBe16(p) __builtin_bswap16(*(const uint16_t *)(const Byte *)(p)) */
#define GetBe32(p) __builtin_bswap32(*(const uint32_t *)(const Byte *)(p))
#define GetBe64(p) __builtin_bswap64(*(const uint64_t *)(const Byte *)(p))
#define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = __builtin_bswap32(v)
#define SetBe32(p, v) (*(uint32_t *)(void *)(p)) = __builtin_bswap32(v)
#else
#define GetBe32(p) ( \
((UInt32)((const Byte *)(p))[0] << 24) | \
((UInt32)((const Byte *)(p))[1] << 16) | \
((UInt32)((const Byte *)(p))[2] << 8) | \
((uint32_t)((const Byte *)(p))[0] << 24) | \
((uint32_t)((const Byte *)(p))[1] << 16) | \
((uint32_t)((const Byte *)(p))[2] << 8) | \
((const Byte *)(p))[3] )
#define GetBe64(p) (((UInt64)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4))
#define GetBe64(p) (((uint64_t)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4))
#define SetBe32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \
#define SetBe32(p, v) { Byte *_ppp_ = (Byte *)(p); uint32_t _vvv_ = (v); \
_ppp_[0] = (Byte)(_vvv_ >> 24); \
_ppp_[1] = (Byte)(_vvv_ >> 16); \
_ppp_[2] = (Byte)(_vvv_ >> 8); \
@@ -289,8 +289,8 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem
#ifndef GetBe16
#define GetBe16(p) ( (UInt16) ( \
((UInt16)((const Byte *)(p))[0] << 8) | \
#define GetBe16(p) ( (uint16_t) ( \
((uint16_t)((const Byte *)(p))[0] << 8) | \
((const Byte *)(p))[1] ))
#endif
@@ -301,12 +301,12 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem
typedef struct
{
UInt32 maxFunc;
UInt32 vendor[3];
UInt32 ver;
UInt32 b;
UInt32 c;
UInt32 d;
uint32_t maxFunc;
uint32_t vendor[3];
uint32_t ver;
uint32_t b;
uint32_t c;
uint32_t d;
} Cx86cpuid;
enum
@@ -316,7 +316,7 @@ enum
CPU_FIRM_VIA
};
void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d);
void MyCPUID(uint32_t function, uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d);
BoolInt x86cpuid_CheckAndRead(Cx86cpuid *p);
int x86cpuid_GetFirm(const Cx86cpuid *p);
+93 -93
View File
@@ -9,10 +9,10 @@
#include "LzHash.h"
#define kEmptyHashValue 0
#define kMaxValForNormalize ((UInt32)0xFFFFFFFF)
#define kMaxValForNormalize ((uint32_t)0xFFFFFFFF)
#define kNormalizeStepMin (1 << 10) /* it must be power of 2 */
#define kNormalizeMask (~(UInt32)(kNormalizeStepMin - 1))
#define kMaxHistorySize ((UInt32)7 << 29)
#define kNormalizeMask (~(uint32_t)(kNormalizeStepMin - 1))
#define kMaxHistorySize ((uint32_t)7 << 29)
#define kStartMaxLen 3
@@ -27,9 +27,9 @@ static void LzInWindow_Free(CMatchFinder *p, ISzAllocPtr alloc)
/* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */
static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAllocPtr alloc)
static int LzInWindow_Create(CMatchFinder *p, uint32_t keepSizeReserv, ISzAllocPtr alloc)
{
UInt32 blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;
uint32_t blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;
if (p->directInput)
{
p->blockSize = blockSize;
@@ -46,9 +46,9 @@ static int LzInWindow_Create(CMatchFinder *p, UInt32 keepSizeReserv, ISzAllocPtr
Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
uint32_t MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
void MatchFinder_ReduceOffsets(CMatchFinder *p, uint32_t subValue)
{
p->posLimit -= subValue;
p->pos -= subValue;
@@ -64,9 +64,9 @@ static void MatchFinder_ReadBlock(CMatchFinder *p)
if (p->directInput)
{
UInt32 curSize = 0xFFFFFFFF - (p->streamPos - p->pos);
uint32_t curSize = 0xFFFFFFFF - (p->streamPos - p->pos);
if (curSize > p->directInputRem)
curSize = (UInt32)p->directInputRem;
curSize = (uint32_t)p->directInputRem;
p->directInputRem -= curSize;
p->streamPos += curSize;
if (p->directInputRem == 0)
@@ -89,7 +89,7 @@ static void MatchFinder_ReadBlock(CMatchFinder *p)
p->streamEndWasReached = 1;
return;
}
p->streamPos += (UInt32)size;
p->streamPos += (uint32_t)size;
if (p->streamPos - p->pos > p->keepSizeAfter)
return;
}
@@ -142,15 +142,15 @@ void MatchFinder_Construct(CMatchFinder *p)
p->bufferBase = NULL;
p->directInput = 0;
p->hash = NULL;
p->expectedDataSize = (UInt64)(Int64)-1;
p->expectedDataSize = (uint64_t)(int64_t)-1;
MatchFinder_SetDefaultSettings(p);
for (i = 0; i < 256; i++)
{
UInt32 r = (UInt32)i;
uint32_t r = (uint32_t)i;
unsigned j;
for (j = 0; j < 8; j++)
r = (r >> 1) ^ (kCrcPoly & ((UInt32)0 - (r & 1)));
r = (r >> 1) ^ (kCrcPoly & ((uint32_t)0 - (r & 1)));
p->crc[i] = r;
}
}
@@ -175,11 +175,11 @@ static CLzRef* AllocRefs(size_t num, ISzAllocPtr alloc)
return (CLzRef *)ISzAlloc_Alloc(alloc, sizeInBytes);
}
int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
int MatchFinder_Create(CMatchFinder *p, uint32_t historySize,
uint32_t keepAddBufferBefore, uint32_t matchMaxLen, uint32_t keepAddBufferAfter,
ISzAllocPtr alloc)
{
UInt32 sizeReserv;
uint32_t sizeReserv;
if (historySize > kMaxHistorySize)
{
@@ -188,8 +188,8 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
}
sizeReserv = historySize >> 1;
if (historySize >= ((UInt32)3 << 30)) sizeReserv = historySize >> 3;
else if (historySize >= ((UInt32)2 << 30)) sizeReserv = historySize >> 2;
if (historySize >= ((uint32_t)3 << 30)) sizeReserv = historySize >> 3;
else if (historySize >= ((uint32_t)2 << 30)) sizeReserv = historySize >> 2;
sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19);
@@ -200,8 +200,8 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
if (LzInWindow_Create(p, sizeReserv, alloc))
{
UInt32 newCyclicBufferSize = historySize + 1;
UInt32 hs;
uint32_t newCyclicBufferSize = historySize + 1;
uint32_t hs;
p->matchMaxLen = matchMaxLen;
{
p->fixedHashSize = 0;
@@ -211,7 +211,7 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
{
hs = historySize;
if (hs > p->expectedDataSize)
hs = (UInt32)p->expectedDataSize;
hs = (uint32_t)p->expectedDataSize;
if (hs != 0)
hs--;
hs |= (hs >> 1);
@@ -270,8 +270,8 @@ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
static void MatchFinder_SetLimits(CMatchFinder *p)
{
UInt32 limit = kMaxValForNormalize - p->pos;
UInt32 limit2 = p->cyclicBufferSize - p->cyclicBufferPos;
uint32_t limit = kMaxValForNormalize - p->pos;
uint32_t limit2 = p->cyclicBufferSize - p->cyclicBufferPos;
if (limit2 < limit)
limit = limit2;
@@ -289,7 +289,7 @@ static void MatchFinder_SetLimits(CMatchFinder *p)
limit = limit2;
{
UInt32 lenLimit = p->streamPos - p->pos;
uint32_t lenLimit = p->streamPos - p->pos;
if (lenLimit > p->matchMaxLen)
lenLimit = p->matchMaxLen;
p->lenLimit = lenLimit;
@@ -342,17 +342,17 @@ void MatchFinder_Init(CMatchFinder *p)
}
static UInt32 MatchFinder_GetSubValue(CMatchFinder *p)
static uint32_t MatchFinder_GetSubValue(CMatchFinder *p)
{
return (p->pos - p->historySize - 1) & kNormalizeMask;
}
void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems)
void MatchFinder_Normalize3(uint32_t subValue, CLzRef *items, size_t numItems)
{
size_t i;
for (i = 0; i < numItems; i++)
{
UInt32 value = items[i];
uint32_t value = items[i];
if (value <= subValue)
value = kEmptyHashValue;
else
@@ -363,7 +363,7 @@ void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems)
static void MatchFinder_Normalize(CMatchFinder *p)
{
UInt32 subValue = MatchFinder_GetSubValue(p);
uint32_t subValue = MatchFinder_GetSubValue(p);
MatchFinder_Normalize3(subValue, p->hash, p->numRefs);
MatchFinder_ReduceOffsets(p, subValue);
}
@@ -386,15 +386,15 @@ static void MatchFinder_CheckLimits(CMatchFinder *p)
(lenLimit > maxLen)
*/
MY_FORCE_INLINE
static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
UInt32 *distances, unsigned maxLen)
static uint32_t * Hc_GetMatchesSpec(unsigned lenLimit, uint32_t curMatch, uint32_t pos, const Byte *cur, CLzRef *son,
uint32_t _cyclicBufferPos, uint32_t _cyclicBufferSize, uint32_t cutValue,
uint32_t *distances, unsigned maxLen)
{
/*
son[_cyclicBufferPos] = curMatch;
for (;;)
{
UInt32 delta = pos - curMatch;
uint32_t delta = pos - curMatch;
if (cutValue-- == 0 || delta >= _cyclicBufferSize)
return distances;
{
@@ -402,7 +402,7 @@ static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt32 pos
curMatch = son[_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)];
if (pb[maxLen] == cur[maxLen] && *pb == *cur)
{
UInt32 len = 0;
uint32_t len = 0;
while (++len != lenLimit)
if (pb[len] != cur[len])
break;
@@ -423,7 +423,7 @@ static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt32 pos
son[_cyclicBufferPos] = curMatch;
do
{
UInt32 delta = pos - curMatch;
uint32_t delta = pos - curMatch;
if (delta >= _cyclicBufferSize)
break;
{
@@ -437,7 +437,7 @@ static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt32 pos
{
if (++c == lim)
{
distances[0] = (UInt32)(lim - cur);
distances[0] = (uint32_t)(lim - cur);
distances[1] = delta - 1;
return distances + 2;
}
@@ -447,7 +447,7 @@ static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt32 pos
if (maxLen < len)
{
maxLen = len;
distances[0] = (UInt32)len;
distances[0] = (uint32_t)len;
distances[1] = delta - 1;
distances += 2;
}
@@ -462,16 +462,16 @@ static UInt32 * Hc_GetMatchesSpec(unsigned lenLimit, UInt32 curMatch, UInt32 pos
MY_FORCE_INLINE
UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue,
UInt32 *distances, UInt32 maxLen)
uint32_t * GetMatchesSpec1(uint32_t lenLimit, uint32_t curMatch, uint32_t pos, const Byte *cur, CLzRef *son,
uint32_t _cyclicBufferPos, uint32_t _cyclicBufferSize, uint32_t cutValue,
uint32_t *distances, uint32_t maxLen)
{
CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1;
CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1);
unsigned len0 = 0, len1 = 0;
for (;;)
{
UInt32 delta = pos - curMatch;
uint32_t delta = pos - curMatch;
if (cutValue-- == 0 || delta >= _cyclicBufferSize)
{
*ptr0 = *ptr1 = kEmptyHashValue;
@@ -481,7 +481,7 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt
CLzRef *pair = son + ((size_t)(_cyclicBufferPos - delta + ((delta > _cyclicBufferPos) ? _cyclicBufferSize : 0)) << 1);
const Byte *pb = cur - delta;
unsigned len = (len0 < len1 ? len0 : len1);
UInt32 pair0 = pair[0];
uint32_t pair0 = pair[0];
if (pb[len] == cur[len])
{
if (++len != lenLimit && pb[len] == cur[len])
@@ -490,8 +490,8 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt
break;
if (maxLen < len)
{
maxLen = (UInt32)len;
*distances++ = (UInt32)len;
maxLen = (uint32_t)len;
*distances++ = (uint32_t)len;
*distances++ = delta - 1;
if (len == lenLimit)
{
@@ -519,15 +519,15 @@ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byt
}
}
static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *cur, CLzRef *son,
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 cutValue)
static void SkipMatchesSpec(uint32_t lenLimit, uint32_t curMatch, uint32_t pos, const Byte *cur, CLzRef *son,
uint32_t _cyclicBufferPos, uint32_t _cyclicBufferSize, uint32_t cutValue)
{
CLzRef *ptr0 = son + ((size_t)_cyclicBufferPos << 1) + 1;
CLzRef *ptr1 = son + ((size_t)_cyclicBufferPos << 1);
unsigned len0 = 0, len1 = 0;
for (;;)
{
UInt32 delta = pos - curMatch;
uint32_t delta = pos - curMatch;
if (cutValue-- == 0 || delta >= _cyclicBufferSize)
{
*ptr0 = *ptr1 = kEmptyHashValue;
@@ -574,12 +574,12 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const
p->buffer++; \
if (++p->pos == p->posLimit) MatchFinder_CheckLimits(p);
#define MOVE_POS_RET MOVE_POS return (UInt32)offset;
#define MOVE_POS_RET MOVE_POS return (uint32_t)offset;
static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
#define GET_MATCHES_HEADER2(minLen, ret_op) \
unsigned lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; \
unsigned lenLimit; uint32_t hv; const Byte *cur; uint32_t curMatch; \
lenLimit = (unsigned)p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
cur = p->buffer;
@@ -589,11 +589,11 @@ static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
#define MF_PARAMS(p) p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue
#define GET_MATCHES_FOOTER(offset, maxLen) \
offset = (unsigned)(GetMatchesSpec1((UInt32)lenLimit, curMatch, MF_PARAMS(p), \
distances + offset, (UInt32)maxLen) - distances); MOVE_POS_RET;
offset = (unsigned)(GetMatchesSpec1((uint32_t)lenLimit, curMatch, MF_PARAMS(p), \
distances + offset, (uint32_t)maxLen) - distances); MOVE_POS_RET;
#define SKIP_FOOTER \
SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
SkipMatchesSpec((uint32_t)lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
#define UPDATE_maxLen { \
ptrdiff_t diff = (ptrdiff_t)0 - d2; \
@@ -602,7 +602,7 @@ static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
for (; c != lim; c++) if (*(c + diff) != *c) break; \
maxLen = (unsigned)(c - cur); }
static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
static uint32_t Bt2_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
{
unsigned offset;
GET_MATCHES_HEADER(2)
@@ -613,7 +613,7 @@ static UInt32 Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
GET_MATCHES_FOOTER(offset, 1)
}
UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
uint32_t Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
{
unsigned offset;
GET_MATCHES_HEADER(3)
@@ -624,11 +624,11 @@ UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
GET_MATCHES_FOOTER(offset, 2)
}
static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
static uint32_t Bt3_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
{
UInt32 h2, d2, pos;
uint32_t h2, d2, pos;
unsigned maxLen, offset;
UInt32 *hash;
uint32_t *hash;
GET_MATCHES_HEADER(3)
HASH3_CALC;
@@ -649,12 +649,12 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur)
{
UPDATE_maxLen
distances[0] = (UInt32)maxLen;
distances[0] = (uint32_t)maxLen;
distances[1] = d2 - 1;
offset = 2;
if (maxLen == lenLimit)
{
SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p));
SkipMatchesSpec((uint32_t)lenLimit, curMatch, MF_PARAMS(p));
MOVE_POS_RET;
}
}
@@ -662,11 +662,11 @@ static UInt32 Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
GET_MATCHES_FOOTER(offset, maxLen)
}
static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
static uint32_t Bt4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
{
UInt32 h2, h3, d2, d3, pos;
uint32_t h2, h3, d2, d3, pos;
unsigned maxLen, offset;
UInt32 *hash;
uint32_t *hash;
GET_MATCHES_HEADER(4)
HASH4_CALC;
@@ -705,10 +705,10 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
if (offset != 0)
{
UPDATE_maxLen
distances[(size_t)offset - 2] = (UInt32)maxLen;
distances[(size_t)offset - 2] = (uint32_t)maxLen;
if (maxLen == lenLimit)
{
SkipMatchesSpec((UInt32)lenLimit, curMatch, MF_PARAMS(p));
SkipMatchesSpec((uint32_t)lenLimit, curMatch, MF_PARAMS(p));
MOVE_POS_RET;
}
}
@@ -720,10 +720,10 @@ static UInt32 Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
}
/*
static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
static uint32_t Bt5_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
{
UInt32 h2, h3, h4, d2, d3, d4, maxLen, offset, pos;
UInt32 *hash;
uint32_t h2, h3, h4, d2, d3, d4, maxLen, offset, pos;
uint32_t *hash;
GET_MATCHES_HEADER(5)
HASH5_CALC;
@@ -796,11 +796,11 @@ static UInt32 Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
}
*/
static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
static uint32_t Hc4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
{
UInt32 h2, h3, d2, d3, pos;
uint32_t h2, h3, d2, d3, pos;
unsigned maxLen, offset;
UInt32 *hash;
uint32_t *hash;
GET_MATCHES_HEADER(4)
HASH4_CALC;
@@ -838,7 +838,7 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
if (offset != 0)
{
UPDATE_maxLen
distances[(size_t)offset - 2] = (UInt32)maxLen;
distances[(size_t)offset - 2] = (uint32_t)maxLen;
if (maxLen == lenLimit)
{
p->son[p->cyclicBufferPos] = curMatch;
@@ -855,10 +855,10 @@ static UInt32 Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
}
/*
static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
static uint32_t Hc5_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
{
UInt32 h2, h3, h4, d2, d3, d4, maxLen, offset, pos
UInt32 *hash;
uint32_t h2, h3, h4, d2, d3, d4, maxLen, offset, pos
uint32_t *hash;
GET_MATCHES_HEADER(5)
HASH5_CALC;
@@ -927,13 +927,13 @@ static UInt32 Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
if (maxLen < 4)
maxLen = 4;
offset = (UInt32)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
offset = (uint32_t)(Hc_GetMatchesSpec(lenLimit, curMatch, MF_PARAMS(p),
distances + offset, maxLen) - (distances));
MOVE_POS_RET
}
*/
UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
uint32_t Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
{
unsigned offset;
GET_MATCHES_HEADER(3)
@@ -945,7 +945,7 @@ UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
MOVE_POS_RET
}
static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
static void Bt2_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
{
do
{
@@ -958,7 +958,7 @@ static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
while (--num != 0);
}
void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
{
do
{
@@ -971,12 +971,12 @@ void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
while (--num != 0);
}
static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
static void Bt3_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
{
do
{
UInt32 h2;
UInt32 *hash;
uint32_t h2;
uint32_t *hash;
SKIP_HEADER(3)
HASH3_CALC;
hash = p->hash;
@@ -988,12 +988,12 @@ static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
while (--num != 0);
}
static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
static void Bt4_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
{
do
{
UInt32 h2, h3;
UInt32 *hash;
uint32_t h2, h3;
uint32_t *hash;
SKIP_HEADER(4)
HASH4_CALC;
hash = p->hash;
@@ -1007,12 +1007,12 @@ static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
}
/*
static void Bt5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
static void Bt5_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
{
do
{
UInt32 h2, h3, h4;
UInt32 *hash;
uint32_t h2, h3, h4;
uint32_t *hash;
SKIP_HEADER(5)
HASH5_CALC;
hash = p->hash;
@@ -1027,12 +1027,12 @@ static void Bt5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
}
*/
static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
static void Hc4_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
{
do
{
UInt32 h2, h3;
UInt32 *hash;
uint32_t h2, h3;
uint32_t *hash;
SKIP_HEADER(4)
HASH4_CALC;
hash = p->hash;
@@ -1047,12 +1047,12 @@ static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
}
/*
static void Hc5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
static void Hc5_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
{
do
{
UInt32 h2, h3, h4;
UInt32 *hash;
uint32_t h2, h3, h4;
uint32_t *hash;
SKIP_HEADER(5)
HASH5_CALC;
hash = p->hash;
@@ -1068,7 +1068,7 @@ static void Hc5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
}
*/
void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
{
do
{
+33 -33
View File
@@ -8,47 +8,47 @@
EXTERN_C_BEGIN
typedef UInt32 CLzRef;
typedef uint32_t CLzRef;
typedef struct _CMatchFinder
{
Byte *buffer;
UInt32 pos;
UInt32 posLimit;
UInt32 streamPos;
UInt32 lenLimit;
uint32_t pos;
uint32_t posLimit;
uint32_t streamPos;
uint32_t lenLimit;
UInt32 cyclicBufferPos;
UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */
uint32_t cyclicBufferPos;
uint32_t cyclicBufferSize; /* it must be = (historySize + 1) */
Byte streamEndWasReached;
Byte btMode;
Byte bigHash;
Byte directInput;
UInt32 matchMaxLen;
uint32_t matchMaxLen;
CLzRef *hash;
CLzRef *son;
UInt32 hashMask;
UInt32 cutValue;
uint32_t hashMask;
uint32_t cutValue;
Byte *bufferBase;
ISeqInStream *stream;
UInt32 blockSize;
UInt32 keepSizeBefore;
UInt32 keepSizeAfter;
uint32_t blockSize;
uint32_t keepSizeBefore;
uint32_t keepSizeAfter;
UInt32 numHashBytes;
uint32_t numHashBytes;
size_t directInputRem;
UInt32 historySize;
UInt32 fixedHashSize;
UInt32 hashSizeSum;
uint32_t historySize;
uint32_t fixedHashSize;
uint32_t hashSizeSum;
SRes result;
UInt32 crc[256];
uint32_t crc[256];
size_t numRefs;
UInt64 expectedDataSize;
uint64_t expectedDataSize;
} CMatchFinder;
#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
@@ -71,16 +71,16 @@ void MatchFinder_Construct(CMatchFinder *p);
historySize <= 3 GB
keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
*/
int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
int MatchFinder_Create(CMatchFinder *p, uint32_t historySize,
uint32_t keepAddBufferBefore, uint32_t matchMaxLen, uint32_t keepAddBufferAfter,
ISzAllocPtr alloc);
void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc);
void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems);
void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
void MatchFinder_Normalize3(uint32_t subValue, CLzRef *items, size_t numItems);
void MatchFinder_ReduceOffsets(CMatchFinder *p, uint32_t subValue);
UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
UInt32 *distances, UInt32 maxLen);
uint32_t * GetMatchesSpec1(uint32_t lenLimit, uint32_t curMatch, uint32_t pos, const Byte *buffer, CLzRef *son,
uint32_t _cyclicBufferPos, uint32_t _cyclicBufferSize, uint32_t _cutValue,
uint32_t *distances, uint32_t maxLen);
/*
Conditions:
@@ -89,10 +89,10 @@ Conditions:
*/
typedef void (*Mf_Init_Func)(void *object);
typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);
typedef uint32_t (*Mf_GetNumAvailableBytes_Func)(void *object);
typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);
typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);
typedef void (*Mf_Skip_Func)(void *object, UInt32);
typedef uint32_t (*Mf_GetMatches_Func)(void *object, uint32_t *distances);
typedef void (*Mf_Skip_Func)(void *object, uint32_t);
typedef struct _IMatchFinder
{
@@ -110,11 +110,11 @@ void MatchFinder_Init_HighHash(CMatchFinder *p);
void MatchFinder_Init_3(CMatchFinder *p, int readData);
void MatchFinder_Init(CMatchFinder *p);
UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
uint32_t Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances);
uint32_t Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances);
void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num);
void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num);
EXTERN_C_END
+13 -13
View File
@@ -12,45 +12,45 @@
#define kFix4HashSize (kHash2Size + kHash3Size)
#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size)
#define HASH2_CALC hv = cur[0] | ((UInt32)cur[1] << 8);
#define HASH2_CALC hv = cur[0] | ((uint32_t)cur[1] << 8);
#define HASH3_CALC { \
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
uint32_t temp = p->crc[cur[0]] ^ cur[1]; \
h2 = temp & (kHash2Size - 1); \
hv = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; }
hv = (temp ^ ((uint32_t)cur[2] << 8)) & p->hashMask; }
#define HASH4_CALC { \
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
uint32_t temp = p->crc[cur[0]] ^ cur[1]; \
h2 = temp & (kHash2Size - 1); \
temp ^= ((UInt32)cur[2] << 8); \
temp ^= ((uint32_t)cur[2] << 8); \
h3 = temp & (kHash3Size - 1); \
hv = (temp ^ (p->crc[cur[3]] << 5)) & p->hashMask; }
#define HASH5_CALC { \
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
uint32_t temp = p->crc[cur[0]] ^ cur[1]; \
h2 = temp & (kHash2Size - 1); \
temp ^= ((UInt32)cur[2] << 8); \
temp ^= ((uint32_t)cur[2] << 8); \
h3 = temp & (kHash3Size - 1); \
temp ^= (p->crc[cur[3]] << 5); \
h4 = temp & (kHash4Size - 1); \
hv = (temp ^ (p->crc[cur[4]] << 3)) & p->hashMask; }
/* #define HASH_ZIP_CALC hv = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */
#define HASH_ZIP_CALC hv = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF;
/* #define HASH_ZIP_CALC hv = ((cur[0] | ((uint32_t)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */
#define HASH_ZIP_CALC hv = ((cur[2] | ((uint32_t)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF;
#define MT_HASH2_CALC \
h2 = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1);
#define MT_HASH3_CALC { \
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
uint32_t temp = p->crc[cur[0]] ^ cur[1]; \
h2 = temp & (kHash2Size - 1); \
h3 = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); }
h3 = (temp ^ ((uint32_t)cur[2] << 8)) & (kHash3Size - 1); }
#define MT_HASH4_CALC { \
UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
uint32_t temp = p->crc[cur[0]] ^ cur[1]; \
h2 = temp & (kHash2Size - 1); \
temp ^= ((UInt32)cur[2] << 8); \
temp ^= ((uint32_t)cur[2] << 8); \
h3 = temp & (kHash3Size - 1); \
h4 = (temp ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); }
+14 -14
View File
@@ -32,7 +32,7 @@
#define LZMA2_IS_UNCOMPRESSED_STATE(p) (((p)->control & (1 << 7)) == 0)
#define LZMA2_LCLP_MAX 4
#define LZMA2_DIC_SIZE_FROM_PROP(p) (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11))
#define LZMA2_DIC_SIZE_FROM_PROP(p) (((uint32_t)2 | ((p) & 1)) << ((p) / 2 + 11))
#ifdef SHOW_DEBUG_INFO
#define PRF(x) x
@@ -56,7 +56,7 @@ typedef enum
static SRes Lzma2Dec_GetOldProps(Byte prop, Byte *props)
{
UInt32 dicSize;
uint32_t dicSize;
if (prop > 40)
return SZ_ERROR_UNSUPPORTED;
dicSize = (prop == 40) ? 0xFFFFFFFF : LZMA2_DIC_SIZE_FROM_PROP(prop);
@@ -116,26 +116,26 @@ static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b)
if (b < p->needInitLevel)
return LZMA2_STATE_ERROR;
p->needInitLevel = 0;
p->unpackSize = (UInt32)(b & 0x1F) << 16;
p->unpackSize = (uint32_t)(b & 0x1F) << 16;
}
return LZMA2_STATE_UNPACK0;
case LZMA2_STATE_UNPACK0:
p->unpackSize |= (UInt32)b << 8;
p->unpackSize |= (uint32_t)b << 8;
return LZMA2_STATE_UNPACK1;
case LZMA2_STATE_UNPACK1:
p->unpackSize |= (UInt32)b;
p->unpackSize |= (uint32_t)b;
p->unpackSize++;
PRF(printf(" %7u", (unsigned)p->unpackSize));
return LZMA2_IS_UNCOMPRESSED_STATE(p) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0;
case LZMA2_STATE_PACK0:
p->packSize = (UInt32)b << 8;
p->packSize = (uint32_t)b << 8;
return LZMA2_STATE_PACK1;
case LZMA2_STATE_PACK1:
p->packSize |= (UInt32)b;
p->packSize |= (uint32_t)b;
p->packSize++;
/* if (p->packSize < 5) return LZMA2_STATE_ERROR; */
PRF(printf(" %5u", (unsigned)p->packSize));
@@ -166,7 +166,7 @@ static void LzmaDec_UpdateWithUncompressed(CLzmaDec *p, const Byte *src, SizeT s
p->dicPos += size;
if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= size)
p->checkDicSize = p->prop.dicSize;
p->processedPos += (UInt32)size;
p->processedPos += (uint32_t)size;
}
void LzmaDec_InitDicAndState(CLzmaDec *p, BoolInt initDic, BoolInt initState);
@@ -245,7 +245,7 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
src += inCur;
*srcLen += inCur;
p->unpackSize -= (UInt32)inCur;
p->unpackSize -= (uint32_t)inCur;
p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT;
}
else
@@ -267,9 +267,9 @@ SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit,
src += inCur;
*srcLen += inCur;
p->packSize -= (UInt32)inCur;
p->packSize -= (uint32_t)inCur;
outCur = p->decoder.dicPos - dicPos;
p->unpackSize -= (UInt32)outCur;
p->unpackSize -= (uint32_t)outCur;
if (res != 0)
break;
@@ -371,7 +371,7 @@ ELzma2ParseStatus Lzma2Dec_Parse(CLzma2Dec *p,
src += inCur;
*srcLen += inCur;
outSize -= inCur;
p->unpackSize -= (UInt32)inCur;
p->unpackSize -= (uint32_t)inCur;
p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT;
}
else
@@ -400,7 +400,7 @@ ELzma2ParseStatus Lzma2Dec_Parse(CLzma2Dec *p,
src += inCur;
*srcLen += inCur;
p->packSize -= (UInt32)inCur;
p->packSize -= (uint32_t)inCur;
if (p->packSize == 0)
{
@@ -408,7 +408,7 @@ ELzma2ParseStatus Lzma2Dec_Parse(CLzma2Dec *p,
if (rem > p->unpackSize)
rem = p->unpackSize;
p->decoder.dicPos += rem;
p->unpackSize -= (UInt32)rem;
p->unpackSize -= (uint32_t)rem;
outSize -= rem;
if (p->unpackSize == 0)
p->state = LZMA2_STATE_CONTROL;
+2 -2
View File
@@ -17,8 +17,8 @@ typedef struct
Byte needInitLevel;
Byte isExtraMode;
Byte _pad_;
UInt32 packSize;
UInt32 unpackSize;
uint32_t packSize;
uint32_t unpackSize;
CLzmaDec decoder;
} CLzma2Dec;
+38 -38
View File
@@ -9,7 +9,7 @@
#include "LzmaDec.h"
#define kNumTopBits 24
#define kTopValue ((UInt32)1 << kNumTopBits)
#define kTopValue ((uint32_t)1 << kNumTopBits)
#define kNumBitModelTotalBits 11
#define kBitModelTotal (1 << kNumBitModelTotalBits)
@@ -19,7 +19,7 @@
#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); }
#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound)
#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * (uint32_t)ttt; if (code < bound)
#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits));
#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits));
#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \
@@ -66,7 +66,7 @@
#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); }
#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * (UInt32)ttt; if (code < bound)
#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * (uint32_t)ttt; if (code < bound)
#define UPDATE_0_CHECK range = bound;
#define UPDATE_1_CHECK range -= bound; code -= bound;
#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \
@@ -155,7 +155,7 @@
#define LZMA_LIT_SIZE 0x300
#define LzmaProps_GetNumProbs(p) (NUM_BASE_PROBS + ((UInt32)LZMA_LIT_SIZE << ((p)->lc + (p)->lp)))
#define LzmaProps_GetNumProbs(p) (NUM_BASE_PROBS + ((uint32_t)LZMA_LIT_SIZE << ((p)->lc + (p)->lp)))
#define CALC_POS_STATE(processedPos, pbMask) (((processedPos) & (pbMask)) << 4)
@@ -219,7 +219,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit
{
CLzmaProb *probs = GET_PROBS;
unsigned state = (unsigned)p->state;
UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3];
uint32_t rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3];
unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1;
unsigned lc = p->prop.lc;
unsigned lpMask = ((unsigned)0x100 << p->prop.lp) - ((unsigned)0x100 >> lc);
@@ -228,18 +228,18 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit
SizeT dicBufSize = p->dicBufSize;
SizeT dicPos = p->dicPos;
UInt32 processedPos = p->processedPos;
UInt32 checkDicSize = p->checkDicSize;
uint32_t processedPos = p->processedPos;
uint32_t checkDicSize = p->checkDicSize;
unsigned len = 0;
const Byte *buf = p->buf;
UInt32 range = p->range;
UInt32 code = p->code;
uint32_t range = p->range;
uint32_t code = p->code;
do
{
CLzmaProb *prob;
UInt32 bound;
uint32_t bound;
unsigned ttt;
unsigned posState = CALC_POS_STATE(processedPos, pbMask);
@@ -250,7 +250,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit
UPDATE_0(prob);
prob = probs + Literal;
if (processedPos != 0 || checkDicSize != 0)
prob += (UInt32)3 * ((((processedPos << 8) + dic[(dicPos == 0 ? dicBufSize : dicPos) - 1]) & lpMask) << lc);
prob += (uint32_t)3 * ((((processedPos << 8) + dic[(dicPos == 0 ? dicBufSize : dicPos) - 1]) & lpMask) << lc);
processedPos++;
if (state < kNumLitStates)
@@ -339,7 +339,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit
}
else
{
UInt32 distance;
uint32_t distance;
UPDATE_1(prob);
prob = probs + IsRepG1 + state;
IF_BIT_0(prob)
@@ -443,7 +443,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit
if (state >= kNumStates)
{
UInt32 distance;
uint32_t distance;
prob = probs + PosSlot +
((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits);
TREE_6_DECODE(prob, distance);
@@ -457,7 +457,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit
distance <<= numDirectBits;
prob = probs + SpecPos;
{
UInt32 m = 1;
uint32_t m = 1;
distance++;
do
{
@@ -476,9 +476,9 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit
range >>= 1;
{
UInt32 t;
uint32_t t;
code -= range;
t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */
t = (0 - ((uint32_t)code >> 31)); /* (uint32_t)((Int32)code >> 31) */
distance = (distance << 1) + (t + 1);
code += range & t;
}
@@ -502,7 +502,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit
REV_BIT_LAST (prob, i, 8);
distance |= i;
}
if (distance == (UInt32)0xFFFFFFFF)
if (distance == (uint32_t)0xFFFFFFFF)
{
len = kMatchSpecLenStart;
state -= kNumStates;
@@ -539,7 +539,7 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit
curLen = ((rem < len) ? (unsigned)rem : len);
pos = dicPos - rep0 + (dicPos < rep0 ? dicBufSize : 0);
processedPos += (UInt32)curLen;
processedPos += (uint32_t)curLen;
len -= curLen;
if (curLen <= dicBufSize - pos)
@@ -572,14 +572,14 @@ int MY_FAST_CALL LZMA_DECODE_REAL(CLzmaDec *p, SizeT limit, const Byte *bufLimit
p->buf = buf;
p->range = range;
p->code = code;
p->remainLen = (UInt32)len;
p->remainLen = (uint32_t)len;
p->dicPos = dicPos;
p->processedPos = processedPos;
p->reps[0] = rep0;
p->reps[1] = rep1;
p->reps[2] = rep2;
p->reps[3] = rep3;
p->state = (UInt32)state;
p->state = (uint32_t)state;
return SZ_OK;
}
@@ -601,8 +601,8 @@ static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit)
if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len)
p->checkDicSize = p->prop.dicSize;
p->processedPos += (UInt32)len;
p->remainLen -= (UInt32)len;
p->processedPos += (uint32_t)len;
p->remainLen -= (uint32_t)len;
while (len != 0)
{
len--;
@@ -628,7 +628,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte
SizeT limit2 = limit;
if (p->checkDicSize == 0)
{
UInt32 rem = p->prop.dicSize - p->processedPos;
uint32_t rem = p->prop.dicSize - p->processedPos;
if (limit - p->dicPos > rem)
limit2 = p->dicPos + rem;
@@ -659,8 +659,8 @@ typedef enum
static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize)
{
UInt32 range = p->range;
UInt32 code = p->code;
uint32_t range = p->range;
uint32_t code = p->code;
const Byte *bufLimit = buf + inSize;
const CLzmaProb *probs = GET_PROBS;
unsigned state = (unsigned)p->state;
@@ -668,7 +668,7 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
{
const CLzmaProb *prob;
UInt32 bound;
uint32_t bound;
unsigned ttt;
unsigned posState = CALC_POS_STATE(p->processedPos, (1 << p->prop.pb) - 1);
@@ -681,7 +681,7 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inS
prob = probs + Literal;
if (p->checkDicSize != 0 || p->processedPos != 0)
prob += ((UInt32)LZMA_LIT_SIZE *
prob += ((uint32_t)LZMA_LIT_SIZE *
((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) +
(p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc))));
@@ -892,10 +892,10 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *sr
return SZ_OK;
}
p->code =
((UInt32)p->tempBuf[1] << 24)
| ((UInt32)p->tempBuf[2] << 16)
| ((UInt32)p->tempBuf[3] << 8)
| ((UInt32)p->tempBuf[4]);
((uint32_t)p->tempBuf[1] << 24)
| ((uint32_t)p->tempBuf[2] << 16)
| ((uint32_t)p->tempBuf[3] << 8)
| ((uint32_t)p->tempBuf[4]);
p->range = 0xFFFFFFFF;
p->tempBufSize = 0;
@@ -1079,13 +1079,13 @@ void LzmaDec_Free(CLzmaDec *p, ISzAllocPtr alloc)
SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
{
UInt32 dicSize;
uint32_t dicSize;
Byte d;
if (size < LZMA_PROPS_SIZE)
return SZ_ERROR_UNSUPPORTED;
else
dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24);
dicSize = data[1] | ((uint32_t)data[2] << 8) | ((uint32_t)data[3] << 16) | ((uint32_t)data[4] << 24);
if (dicSize < LZMA_DIC_MIN)
dicSize = LZMA_DIC_MIN;
@@ -1105,7 +1105,7 @@ SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size)
static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAllocPtr alloc)
{
UInt32 numProbs = LzmaProps_GetNumProbs(propNew);
uint32_t numProbs = LzmaProps_GetNumProbs(propNew);
if (!p->probs || numProbs != p->numProbs)
{
LzmaDec_FreeProbs(p, alloc);
@@ -1135,10 +1135,10 @@ SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAll
RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
{
UInt32 dictSize = propNew.dicSize;
SizeT mask = ((UInt32)1 << 12) - 1;
if (dictSize >= ((UInt32)1 << 30)) mask = ((UInt32)1 << 22) - 1;
else if (dictSize >= ((UInt32)1 << 22)) mask = ((UInt32)1 << 20) - 1;;
uint32_t dictSize = propNew.dicSize;
SizeT mask = ((uint32_t)1 << 12) - 1;
if (dictSize >= ((uint32_t)1 << 30)) mask = ((uint32_t)1 << 22) - 1;
else if (dictSize >= ((uint32_t)1 << 22)) mask = ((uint32_t)1 << 20) - 1;;
dicBufSize = ((SizeT)dictSize + mask) & ~mask;
if (dicBufSize < dictSize)
dicBufSize = dictSize;
+11 -11
View File
@@ -14,9 +14,9 @@ EXTERN_C_BEGIN
typedef
#ifdef _LZMA_PROB32
UInt32
uint32_t
#else
UInt16
uint16_t
#endif
CLzmaProb;
@@ -31,7 +31,7 @@ typedef struct _CLzmaProps
Byte lp;
Byte pb;
Byte _pad_;
UInt32 dicSize;
uint32_t dicSize;
} CLzmaProps;
/* LzmaProps_Decode - decodes properties
@@ -60,15 +60,15 @@ typedef struct
SizeT dicBufSize;
SizeT dicPos;
const Byte *buf;
UInt32 range;
UInt32 code;
UInt32 processedPos;
UInt32 checkDicSize;
UInt32 reps[4];
UInt32 state;
UInt32 remainLen;
uint32_t range;
uint32_t code;
uint32_t processedPos;
uint32_t checkDicSize;
uint32_t reps[4];
uint32_t state;
uint32_t remainLen;
UInt32 numProbs;
uint32_t numProbs;
unsigned tempBufSize;
Byte tempBuf[LZMA_REQUIRED_INPUT_MAX];
} CLzmaDec;
+184 -184
View File
File diff suppressed because it is too large. Load diff
+5 -5
View File
@@ -13,7 +13,7 @@ EXTERN_C_BEGIN
typedef struct _CLzmaEncProps
{
int level; /* 0 <= level <= 9 */
UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
uint32_t dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
(1 << 12) <= dictSize <= (3 << 29) for 64-bit version
default = (1 << 24) */
int lc; /* 0 <= lc <= 8, default = 3 */
@@ -23,17 +23,17 @@ typedef struct _CLzmaEncProps
int fb; /* 5 <= fb <= 273, default = 32 */
int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */
int numHashBytes; /* 2, 3 or 4, default = 4 */
UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */
uint32_t mc; /* 1 <= mc <= (1 << 30), default = 32 */
unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
int numThreads; /* 1 or 2, default = 2 */
UInt64 reduceSize; /* estimated size of data that will be compressed. default = (UInt64)(Int64)-1.
uint64_t reduceSize; /* estimated size of data that will be compressed. default = (uint64_t)(int64_t)-1.
Encoder uses this value to reduce dictionary size */
} CLzmaEncProps;
void LzmaEncProps_Init(CLzmaEncProps *p);
void LzmaEncProps_Normalize(CLzmaEncProps *p);
UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
uint32_t LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
/* ---------- CLzmaEncHandle Interface ---------- */
@@ -55,7 +55,7 @@ CLzmaEncHandle LzmaEnc_Create(ISzAllocPtr alloc);
void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAllocPtr alloc, ISzAllocPtr allocBig);
SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
void LzmaEnc_SetDataSize(CLzmaEncHandle p, UInt64 expectedDataSiize);
void LzmaEnc_SetDataSize(CLzmaEncHandle p, uint64_t expectedDataSiize);
SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
unsigned LzmaEnc_IsWriteEndMark(CLzmaEncHandle p);
+2 -2
View File
@@ -13,7 +13,7 @@ struct BaseConnectionUnix : public BaseConnection {
int sock{-1};
};
static BaseConnectionUnix Connection;
static BaseConnectionUnix ConnectionUnix;
static sockaddr_un PipeAddr{};
#ifdef MSG_NOSIGNAL
static int MsgFlags = MSG_NOSIGNAL;
@@ -34,7 +34,7 @@ static const char* GetTempPath(void)
/*static*/ BaseConnection* BaseConnection::Create()
{
PipeAddr.sun_family = AF_UNIX;
return &Connection;
return &ConnectionUnix;
}
/*static*/ void BaseConnection::Destroy(BaseConnection*& c)
+4 -2
View File
@@ -1511,7 +1511,8 @@ static uInt longest_match(deflate_state *s, IPos cur_match)
* are always equal when the other bytes match, given that
* the hash keys are equal and that HASH_BITS >= 8.
*/
scan += 2, match++;
scan += 2;
match++;
Assert(*scan == *match, "match[2]?");
/* We check for insufficient lookahead only every 8th comparison;
@@ -1585,7 +1586,8 @@ static uInt longest_match(s, cur_match)
* are always equal when the other bytes match, given that
* the hash keys are equal and that HASH_BITS >= 8.
*/
scan += 2, match += 2;
scan += 2;
match += 2;
Assert(*scan == *match, "match[2]?");
/* We check for insufficient lookahead only every 8th comparison;
+31 -11
View File
@@ -262,7 +262,11 @@ static void gen_bitlen(deflate_state *s, tree_desc *desc)
for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
n = s->heap[h];
bits = tree[tree[n].Dad].Len + 1;
if (bits > max_length) bits = max_length, overflow++;
if (bits > max_length)
{
bits = max_length;
overflow++;
}
tree[n].Len = (ush)bits;
/* We overwrite tree[n].Dad which is no longer needed */
@@ -373,7 +377,8 @@ static void build_tree(deflate_state *s, tree_desc *desc)
* heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
* heap[0] is not used.
*/
s->heap_len = 0, s->heap_max = HEAP_SIZE;
s->heap_len = 0;
s->heap_max = HEAP_SIZE;
for (n = 0; n < elems; n++) {
if (tree[n].Freq != 0) {
@@ -456,7 +461,11 @@ static void scan_tree (deflate_state *s, ct_data *tree, int max_code)
int max_count = 7; /* max repeat count */
int min_count = 4; /* min repeat count */
if (nextlen == 0) max_count = 138, min_count = 3;
if (nextlen == 0)
{
max_count = 138;
min_count = 3;
}
tree[max_code+1].Len = (ush)0xffff; /* guard */
for (n = 0; n <= max_code; n++) {
@@ -475,11 +484,14 @@ static void scan_tree (deflate_state *s, ct_data *tree, int max_code)
}
count = 0; prevlen = curlen;
if (nextlen == 0) {
max_count = 138, min_count = 3;
max_count = 138;
min_count = 3;
} else if (curlen == nextlen) {
max_count = 6, min_count = 3;
max_count = 6;
min_count = 3;
} else {
max_count = 7, min_count = 4;
max_count = 7;
min_count = 4;
}
}
}
@@ -499,7 +511,11 @@ static void send_tree (deflate_state *s, ct_data *tree, int max_code)
int min_count = 4; /* min repeat count */
/* tree[max_code+1].Len = -1; */ /* guard already set */
if (nextlen == 0) max_count = 138, min_count = 3;
if (nextlen == 0)
{
max_count = 138;
min_count = 3;
}
for (n = 0; n <= max_code; n++) {
curlen = nextlen; nextlen = tree[n+1].Len;
@@ -523,11 +539,14 @@ static void send_tree (deflate_state *s, ct_data *tree, int max_code)
}
count = 0; prevlen = curlen;
if (nextlen == 0) {
max_count = 138, min_count = 3;
max_count = 138;
min_count = 3;
} else if (curlen == nextlen) {
max_count = 6, min_count = 3;
max_count = 6;
min_count = 3;
} else {
max_count = 7, min_count = 4;
max_count = 7;
min_count = 4;
}
}
}
@@ -842,7 +861,8 @@ void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, ulg stored_len,
register unsigned res = 0;
do {
res |= codes & 1;
codes >>= 1, res <<= 1;
codes >>= 1;
res <<= 1;
} while (--len > 0);
return res >> 1;
}
-17
View File
@@ -1,17 +0,0 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
-26
View File
@@ -1,26 +0,0 @@
*.o
*.a
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
# =========================
# Operating System Files
# =========================
-29
View File
@@ -1,29 +0,0 @@
TARGET := libmathneon
SOURCES := source
LIBS = -lc -lm -lSceGxm_stub -lSceDisplay_stub
CFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c))
CGFILES := $(foreach dir,$(SHADERS), $(wildcard $(dir)/*.cg))
HEADERS := $(CGFILES:.cg=.h)
OBJS := $(CFILES:.c=.o)
PREFIX = arm-vita-eabi
CC = $(PREFIX)-gcc
AR = $(PREFIX)-gcc-ar
CFLAGS = -g -Wl,-q -O2 -ffast-math -mtune=cortex-a9 -mfpu=neon -flto -ftree-vectorize
ASFLAGS = $(CFLAGS)
all: $(TARGET).a
$(TARGET).a: $(OBJS)
$(AR) -rc $@ $^
clean:
@rm -rf $(TARGET).a $(TARGET).elf $(OBJS)
install: $(TARGET).a
@mkdir -p $(VITASDK)/$(PREFIX)/lib/
cp $(TARGET).a $(VITASDK)/$(PREFIX)/lib/
@mkdir -p $(VITASDK)/$(PREFIX)/include/
cp source/math_neon.h $(VITASDK)/$(PREFIX)/include/
-168
View File
@@ -1,168 +0,0 @@
Library: MATH-NEON
By: Lachlan Tychsen-Smith
Licence: MIT (expat)
=======================================================================================
This project implements the cmath functions and some optimised matrix functions
with the aim of increasing the floating point performance of ARM Cortex A-8
based platforms. As well as implementing the functions in ARM NEON assembly,
they sacrifice error checking and some accuracy to achieve better performance.
Function Errors:
=======================================================================================
The measurement and characterisations of the inaccuracies present within these
functions is really a field within itself. For the benchmark i provide the
maximum absolute, maximum relative and root mean squared error compared to the
cmath implementations over the specified range. However these values can be
misleading, especially for functions which quickly go to infinity. So its always a
good idea to test it within your actual program. In general, this library will not
be as accurate as cmath, however for many functions it is close enough to be
negilible.
Notes:
=======================================================================================
- The *_c functions are c implementations of the *_neon code.
- Like cmath, The errors present in the functions are very dependent on the
range which your operating in. So you should test them first.
- Look in the "math_neon.h" file for discriptions of the functions. In some
function files there are also notes on the specific implementation.
- The *_neon functions make certain assumptions about the location of arguments
that is incompatible with inlining.
Contact:
=======================================================================================
Name: Lachlan Tychsen-Smith
Email: [email protected]
PSVITA performances test results:
RUNFAST: Disabled
------------------------------------------------------------------------------------------------------
MATRIX FUNCTION TESTS
------------------------------------------------------------------------------------------------------
matmul2_c =
|-14.56, 5.96|
|-15.35, 10.50|
matmul2_neon =
|-14.56, 5.96|
|-15.35, 10.50|
matmul2: c=174924 neon=64490 rate=2.71
matvec2_c = |-14.56, -15.35|
matvec2_neon = |-14.56, -15.35|
matvec2: c=88957 neon=58337 rate=1.52
matmul3_c =
|-21.39, -4.68, -1.74|
|-8.66, -8.97, 1.83|
|15.88, 0.30, -2.23|
matmul3_neon =
|-21.39, -4.68, -1.74|
|-8.66, -8.97, 1.83|
|15.88, 0.30, -2.23|
matmul3: c=552486 neon=297268 rate=1.86
matvec3_c = |-21.39, -8.66, 15.88|
matvec3_neon = |-21.39, -8.66, 15.88|
matvec3: c=184104 neon=128780 rate=1.43
matmul4_c =
|-13.65, -1.80, -12.92, 6.56|
|-10.21, 9.47, 2.73, 14.79|
|0.97, 11.69, -0.64, -12.87|
|20.06, 6.77, 35.61, -0.02|
matmul4_neon =
|-13.65, -1.80, -12.92, 6.56|
|-10.21, 9.47, 2.73, 14.79|
|0.97, 11.69, -0.64, -12.87|
|20.06, 6.77, 35.61, -0.02|
matmul4: c=1315568 neon=254227 rate=5.17
matvec4_c = |-13.65, -10.21, 0.97, 20.058556|
matvec4_neon = |-13.65, -10.21, 0.97, 20.058556|
matvec4: c=331712 neon=147196 rate=2.25
dot2_c = -10.903330
dot2_neon = -10.903330
dot2: c=230295 neon=168799 rate=1.36
normalize2_c = [-0.74, 0.67]
normalize2_neon = [-0.74, 0.67]
normalize2: c=950716 neon=965780 rate=0.98
dot3_c = -4.226746
dot3_neon = -4.226746
dot3: c=306957 neon=337316 rate=0.91
normalize3_c = [-0.69, 0.62, -0.38]
normalize3_neon = [-0.69, 0.62, -0.38]
normalize3: c=1180950 neon=1134557 rate=1.04
cross3_c = [-9.67, -19.39, -14.24]
cross3_neon = [-9.67, -19.39, -14.24]
cross3: c=659558 neon=766896 rate=0.86
dot4_c = 2.782796
dot4_neon = 2.782796
dot4: c=414233 neon=276068 rate=1.50
normalize4_c = [-0.59, 0.53, -0.32, -0.52]
normalize4_neon = [-0.59, 0.53, -0.32, -0.52]
normalize4: c=1364294 neon=1103327 rate=1.24
------------------------------------------------------------------------------------------------------
CMATH FUNCTION TESTS
------------------------------------------------------------------------------------------------------
Function Range Number ABS Max Error REL Max Error RMS Error Time Rate
------------------------------------------------------------------------------------------------------
sinf [-3.14, 3.14] 500000 0.00e+00 0.00e+00% 0.00e+00 1394459996 x1.00
sinf_c [-3.14, 3.14] 500000 7.75e-07 1.00e+02% 4.09e-07 1395128226 x1.00
sinf_neon [-3.14, 3.14] 500000 8.34e-07 1.00e+02% 4.09e-07 1395853554 x1.00
cosf [-3.14, 3.14] 500000 0.00e+00 0.00e+00% 0.00e+00 1396644271 x1.00
cosf_c [-3.14, 3.14] 500000 7.75e-07 6.74e-01% 4.15e-07 1397360321 x1.00
cosf_neon [-3.14, 3.14] 500000 8.34e-07 6.74e-01% 4.16e-07 1398126872 x1.00
tanf [-0.79, 0.79] 500000 0.00e+00 0.00e+00% 0.00e+00 1398889596 x1.00
tanf_c [-0.79, 0.79] 500000 2.98e-06 7.94e-04% 1.31e-06 1399704712 x1.00
tanf_neon [-0.79, 0.79] 500000 1.91e-06 3.62e-04% 6.66e-07 1400612899 x1.00
asinf [-1.00, 1.00] 500000 0.00e+00 0.00e+00% 0.00e+00 1401838993 x1.00
asinf_c [-1.00, 1.00] 500000 5.54e-05 1.06e-02% nan 1402745512 x1.00
asinf_neon [-1.00, 1.00] 500000 4.66e-05 8.90e-03% nan 1403967661 x1.00
acosf [-1.00, 1.00] 500000 0.00e+00 0.00e+00% 0.00e+00 1405317842 x1.00
acosf_c [-1.00, 1.00] 500000 5.56e-05 6.46e-03% nan 1406294753 x1.00
acosf_neon [-1.00, 1.00] 500000 4.67e-05 6.35e-03% nan 1407598039 x1.00
atanf [-1.00, 1.00] 500000 0.00e+00 0.00e+00% 0.00e+00 1408314869 x1.00
atanf_c [-1.00, 1.00] 500000 1.67e-04 2.12e-02% 7.40e-05 1408872421 x1.00
atanf_neon [-1.00, 1.00] 500000 1.67e-04 2.12e-02% 7.40e-05 1409736652 x1.00
sinhf [-3.14, 3.14] 500000 0.00e+00 0.00e+00% 0.00e+00 1411101066 x1.00
sinhf_c [-3.14, 3.14] 500000 1.91e-06 1.52e-01% 1.85e-07 1412173492 x1.00
sinhf_neon [-3.14, 3.14] 500000 1.91e-06 1.52e-01% 1.90e-07 1413205410 x1.00
coshf [-3.14, 3.14] 500000 0.00e+00 0.00e+00% 0.00e+00 1414417802 x1.00
coshf_c [-3.14, 3.14] 500000 9.54e-07 2.38e-05% 1.64e-07 1415426083 x1.00
coshf_neon [-3.14, 3.14] 500000 1.91e-06 2.22e-05% 1.68e-07 1416412636 x1.00
tanhf [-3.14, 3.14] 500000 0.00e+00 0.00e+00% 0.00e+00 1417684273 x1.00
tanhf_c [-3.14, 3.14] 500000 1.20e-05 2.48e-01% 5.48e-06 1418659628 x1.00
tanhf_neon [-3.14, 3.14] 500000 2.38e-07 2.47e-01% 5.40e-08 1419650721 x1.00
expf [0.00, 10.00] 500000 0.00e+00 0.00e+00% 0.00e+00 1420706074 x1.00
expf_c [0.00, 10.00] 500000 9.77e-03 6.15e-05% 1.64e-03 1421444150 x1.00
expf_neon [0.00, 10.00] 500000 9.77e-03 6.58e-05% 1.64e-03 1422203499 x1.00
logf [1.00, 1000.00] 500000 0.00e+00 0.00e+00% 0.00e+00 1423106698 x1.00
logf_c [1.00, 1000.00] 500000 6.20e-06 1.62e-02% 9.83e-07 1423735174 x1.00
logf_neon [1.00, 1000.00] 500000 7.63e-06 1.03e-02% 1.07e-06 1424434406 x1.00
log10f [1.00, 1000.00] 500000 0.00e+00 0.00e+00% 0.00e+00 1425516892 x1.00
log10f_c [1.00, 1000.00] 500000 2.86e-06 6.68e-03% 4.79e-07 1426200368 x1.00
log10f_neon [1.00, 1000.00] 500000 3.34e-06 6.68e-03% 4.84e-07 1426966844 x1.00
floorf [1.00, 1000.00] 5000000 0.00e+00 0.00e+00% 0.00e+00 1429081993 x1.00
floorf_c [1.00, 1000.00] 5000000 0.00e+00 0.00e+00% 0.00e+00 1430839273 x1.00
floorf_neon [1.00, 1000.00] 5000000 0.00e+00 0.00e+00% 0.00e+00 1433474766 x1.00
ceilf [1.00, 1000.00] 5000000 0.00e+00 0.00e+00% 0.00e+00 1435602956 x1.00
ceilf_c [1.00, 1000.00] 5000000 0.00e+00 0.00e+00% 0.00e+00 1437403711 x1.00
ceilf_neon [1.00, 1000.00] 5000000 0.00e+00 0.00e+00% 0.00e+00 1440044970 x1.00
fabsf [1.00, 1000.00] 5000000 0.00e+00 0.00e+00% 0.00e+00 1441265630 x1.00
fabsf_c [1.00, 1000.00] 5000000 0.00e+00 0.00e+00% 0.00e+00 1442491716 x1.00
fabsf_neon [1.00, 1000.00] 5000000 0.00e+00 0.00e+00% 0.00e+00 1443680744 x1.00
sqrtf [1.00, 1000.00] 500000 0.00e+00 0.00e+00% 0.00e+00 1444844144 x1.00
sqrtf_c [1.00, 1000.00] 500000 2.33e-04 1.06e-03% 8.69e-05 1445710342 x1.00
sqrtf_neon [1.00, 1000.00] 500000 7.63e-06 2.91e-05% 1.60e-06 1446544637 x1.00
invsqrtf [1.00, 1000.00] 500000 0.00e+00 0.00e+00% 0.00e+00 1446995307 x1.00
invsqrtf_c [1.00, 1000.00] 500000 4.35e-06 4.78e-04% 2.00e-07 1447471977 x1.00
invsqrtf_neon [1.00, 1000.00] 500000 1.19e-07 2.12e-05% 4.81e-09 1447987675 x1.00
atan2f [0.10, 10.00] 10000 0.00e+00 0.00e+00% 0.00e+00 1449713108 x1.00
atan2f_c [0.10, 10.00] 10000 1.73e-04 2.23e-02% 0.00e+00 1451276575 x1.00
atan2f_neon [0.10, 10.00] 10000 1.67e-04 2.12e-02% 0.00e+00 1453093260 x1.00
powf [1.00, 10.00] 10000 0.00e+00 0.00e+00% 0.00e+00 1458606663 x1.00
powf_c [1.00, 10.00] 10000 1.08e+05 4.37e-03% 0.00e+00 1461584933 x1.00
powf_neon [1.00, 10.00] 10000 1.36e+05 5.88e-03% 0.00e+00 1464702743 x1.00
fmodf [1.00, 10.00] 10000 0.00e+00 0.00e+00% 0.00e+00 1466022029 x1.00
fmodf_c [1.00, 10.00] 10000 9.90e+00 8.06e-02% 0.00e+00 1467403015 x1.00
fmodf_neon [1.00, 10.00] 10000 9.97e+00 8.06e-02% 0.00e+00 1468767755 x1.00
-689
View File
@@ -1,689 +0,0 @@
/*
Math-NEON: Neon Optimised Math Library based on cmath
Contact: lachlan.ts@gmail.com
Copyright (C) 2009 Lachlan Tychsen - Smith aka Adventus
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <math_neon.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>
#ifdef WIN32
#include <time.h>
#else
#include <sys/time.h>
#include <sys/resource.h>
#endif
#define randf() (rand() / (RAND_MAX + 1.0f))
void LOG(const char *format, ...) {
__gnuc_va_list arg;
va_start(arg, format);
char msg[512];
vsprintf(msg, format, arg);
va_end(arg);
FILE *log = fopen("ux0:/data/mathneon.log", "a+");
if (log != NULL) {
fwrite(msg, 1, strlen(msg), log);
fclose(log);
}
}
struct test1_s {
const char* name;
float (*func)(float); //the function
float (*bench)(float); //the function to benchmark against.
float rng0, rng1;
int num;
float emaxabs;
float xmaxabs;
float emaxrel;
float xmaxrel;
float erms;
int time; //time to execute num functions;
};
struct test2_s {
const char* name;
float (*func)(float, float); //the function
float (*bench)(float, float); //the function to benchmark against.
float rng0, rng1;
int num;
float emaxabs;
float xmaxabs;
float emaxrel;
float xmaxrel;
float erms;
int time; //time to execute num functions;
};
float invsqrtf(float x){
return (1.0f / sqrtf(x));
}
typedef struct test1_s test1_t;
typedef struct test2_s test2_t;
test1_t test1[51] =
{
{"sinf ", sinf, sinf, -M_PI, M_PI, 500000},
{"sinf_c ", sinf_c, sinf, -M_PI, M_PI, 500000},
{"sinf_neon ", sinf_neon, sinf, -M_PI, M_PI, 500000},
{"cosf ", cosf, cosf, -M_PI, M_PI, 500000},
{"cosf_c ", cosf_c, cosf, -M_PI, M_PI, 500000},
{"cosf_neon ", cosf_neon, cosf, -M_PI, M_PI, 500000},
{"tanf ", tanf, tanf, -M_PI_4, M_PI_4, 500000, 0, 0, 0},
{"tanf_c ", tanf_c, tanf, -M_PI_4, M_PI_4, 500000, 0, 0, 0},
{"tanf_neon ", tanf_neon, tanf, -M_PI_4, M_PI_4, 500000, 0, 0, 0},
{"asinf ", asinf, asinf, -1, 1, 500000, 0, 0, 0},
{"asinf_c ", asinf_c, asinf, -1, 1, 500000, 0, 0, 0},
{"asinf_neon ", asinf_neon, asinf, -1, 1, 500000, 0, 0, 0},
{"acosf ", acosf, acosf, -1, 1, 500000, 0, 0, 0},
{"acosf_c ", acosf_c, acosf, -1, 1, 500000, 0, 0, 0},
{"acosf_neon ", acosf_neon, acosf, -1, 1, 500000, 0, 0, 0},
{"atanf ", atanf, atanf, -1, 1, 500000, 0, 0, 0},
{"atanf_c ", atanf_c, atanf, -1, 1, 500000, 0, 0, 0},
{"atanf_neon ", atanf_neon, atanf, -1, 1, 500000, 0, 0, 0},
{"sinhf ", sinhf, sinhf, -M_PI, M_PI, 500000, 0, 0, 0},
{"sinhf_c ", sinhf_c, sinhf, -M_PI, M_PI, 500000, 0, 0, 0},
{"sinhf_neon ", sinhf_neon, sinhf, -M_PI, M_PI, 500000, 0, 0, 0},
{"coshf ", coshf, coshf, -M_PI, M_PI, 500000, 0, 0, 0},
{"coshf_c ", coshf_c, coshf, -M_PI, M_PI, 500000, 0, 0, 0},
{"coshf_neon ", coshf_neon, coshf, -M_PI, M_PI, 500000, 0, 0, 0},
{"tanhf ", tanhf, tanhf, -M_PI, M_PI, 500000, 0, 0, 0},
{"tanhf_c ", tanhf_c, tanhf, -M_PI, M_PI, 500000, 0, 0, 0},
{"tanhf_neon ", tanhf_neon, tanhf, -M_PI, M_PI, 500000, 0, 0, 0},
{"expf ", expf, expf, 0, 10, 500000, 0, 0, 0},
{"expf_c ", expf_c, expf, 0, 10, 500000, 0, 0, 0},
{"expf_neon ", expf_neon, expf, 0, 10, 500000, 0, 0, 0},
{"logf ", logf, logf, 1, 1000, 500000, 0, 0, 0},
{"logf_c ", logf_c, logf, 1, 1000, 500000, 0, 0, 0},
{"logf_neon ", logf_neon, logf, 1, 1000, 500000, 0, 0, 0},
{"log10f ", log10f, log10f, 1, 1000, 500000, 0, 0, 0},
{"log10f_c ", log10f_c, log10f, 1, 1000, 500000, 0, 0, 0},
{"log10f_neon ", log10f_neon,log10f, 1, 1000, 500000, 0, 0, 0},
{"floorf ", floorf, floorf, 1, 1000, 5000000, 0, 0, 0},
{"floorf_c ", floorf_c, floorf, 1, 1000, 5000000, 0, 0, 0},
{"floorf_neon", floorf_neon,floorf, 1, 1000, 5000000, 0, 0, 0},
{"ceilf ", ceilf, ceilf, 1, 1000, 5000000, 0, 0, 0},
{"ceilf_c ", ceilf_c, ceilf, 1, 1000, 5000000, 0, 0, 0},
{"ceilf_neon", ceilf_neon, ceilf, 1, 1000, 5000000, 0, 0, 0},
{"fabsf ", fabsf, fabsf, 1, 1000, 5000000, 0, 0, 0},
{"fabsf_c ", fabsf_c, fabsf, 1, 1000, 5000000, 0, 0, 0},
{"fabsf_neon", fabsf_neon, fabsf, 1, 1000, 5000000, 0, 0, 0},
{"sqrtf ", sqrtf, sqrtf, 1, 1000, 500000, 0, 0, 0},
{"sqrtf_c ", sqrtf_c, sqrtf, 1, 1000, 500000, 0, 0, 0},
{"sqrtf_neon ", sqrtf_neon, sqrtf, 1, 1000, 500000, 0, 0, 0},
{"invsqrtf ", invsqrtf, invsqrtf, 1, 1000, 500000, 0, 0, 0},
{"invsqrtf_c ", invsqrtf_c, invsqrtf, 1, 1000, 500000, 0, 0, 0},
{"invsqrtf_neon ", invsqrtf_neon, invsqrtf, 1, 1000, 500000, 0, 0, 0},
};
test2_t test2[9] =
{
{"atan2f ", atan2f, atan2f, 0.1, 10, 10000, 0, 0, 0},
{"atan2f_c ", atan2f_c, atan2f, 0.1, 10, 10000, 0, 0, 0},
{"atan2f_neon ", atan2f_neon,atan2f, 0.1, 10, 10000, 0, 0, 0},
{"powf ", powf, powf, 1, 10, 10000, 0, 0, 0},
{"powf_c ", powf_c, powf, 1, 10, 10000, 0, 0, 0},
{"powf_neon ", powf_neon, powf, 1, 10, 10000, 0, 0, 0},
{"fmodf ", fmodf, fmodf, 1, 10, 10000, 0, 0, 0},
{"fmodf_c ", fmodf_c, fmodf, 1, 10, 10000, 0, 0, 0},
{"fmodf_neon ", fmodf_neon, fmodf, 1, 10, 10000, 0, 0, 0},
};
void
test_mathfunc1(test1_t *tst)
{
float x;
float dx = (tst->rng1 - tst->rng0) / ((float)tst->num);
#ifndef WIN32
struct rusage ru;
#endif
tst->emaxabs = tst->xmaxabs = 0;
tst->emaxrel = tst->xmaxrel = 0;
tst->erms = 0;
for(x = tst->rng0; x < tst->rng1 ; x += dx){
float r = (tst->func)((float)x);
float rr = (tst->bench)((float)x);
float dr = fabs(r - rr);
float drr = dr * (100.0f / rr);
tst->erms += dr*dr;
if (dr > tst->emaxabs){
tst->emaxabs = dr;
tst->xmaxabs = x;
}
if (drr > tst->emaxrel){
tst->emaxrel = drr;
tst->xmaxrel = x;
}
}
tst->erms = sqrt(tst->erms / ((float) tst->num));
#ifdef WIN32
tst->time = (1000 * clock()) / (CLOCKS_PER_SEC / 1000);
#else
tst->time = sceKernelGetSystemTimeWide();
#endif
for(x = tst->rng0; x < tst->rng1 ; x += dx){
(tst->func)((float)x);
}
#ifdef WIN32
tst->time = (1000 * clock()) / (CLOCKS_PER_SEC / 1000) - tst->time;
#else
tst->time = sceKernelGetSystemTimeWide();
#endif
}
void
test_mathfunc2(test2_t *tst)
{
float x, y;
float rng = tst->rng1 - tst->rng0;
float d = (rng * rng) / ((float) tst->num);
#ifndef WIN32
struct rusage ru;
#endif
tst->emaxabs = tst->xmaxabs = 0;
tst->emaxrel = tst->xmaxrel = 0;
for(y = (tst->rng0); y < (tst->rng1) ; y += d){
for(x = (tst->rng0); x < (tst->rng1); x += d){
float r = (tst->func)((float)x, y);
float rr = (tst->bench)((float)x, y);
float dr = fabs(r - rr);
float drr = dr * (100.0f / rr);
if (dr > tst->emaxabs){
tst->emaxabs = dr;
tst->xmaxabs = x;
}
if (drr > tst->emaxrel && fabsf(rr) > 0.0001){
tst->emaxrel = drr;
tst->xmaxrel = x;
}
}
}
#ifdef WIN32
tst->time = (1000 * clock()) / (CLOCKS_PER_SEC / 1000) ;
#else
tst->time = sceKernelGetSystemTimeWide();
#endif
for(y = tst->rng0; y < tst->rng1 ; y += d){
for(x = tst->rng0; x < tst->rng1 ; x += d){
(tst->func)((float)x, (float)y);
}
}
#ifdef WIN32
tst->time = (1000 * clock()) / (CLOCKS_PER_SEC / 1000) - tst->time;
#else
tst->time = sceKernelGetSystemTimeWide();
#endif
}
void test_vectorfunc()
{
float v0[4], v1[4], d[4];
for(int i=0;i<4;i++)
{
v0[i] = 10*randf() - 5;
v1[i] = 10*randf() - 5;
d[i] = 10*randf() - 5;
}
int testnum = 5000000;
struct rusage ru;
int v2t[3], v3t[3], v4t[3];
float r;
LOG("\n");
//dot 2
v2t[0] = sceKernelGetSystemTimeWide();
for(int i=0;i < testnum; i++)
{
r = dot2_c(v0, v1);
};
v2t[1] = sceKernelGetSystemTimeWide();
for(int i=0;i < testnum; i++)
{
r = dot2_neon(v0, v1);
};
v2t[2] = sceKernelGetSystemTimeWide();
r = dot2_c(v0, v1);
LOG("dot2_c = %f\n", r);
r = dot2_neon(v0, v1);
LOG("dot2_neon = %f\n", r);
LOG("dot2: c=%i \t neon=%i \t rate=%.2f \n", v2t[1] - v2t[0], v2t[2] - v2t[1],
(float)(v2t[1] - v2t[0]) / (float)(v2t[2] - v2t[1]));
//normalize 2
v2t[0] = sceKernelGetSystemTimeWide();
for(int i=0;i < testnum; i++)
{
normalize2_c(v0, d);
};
v2t[1] = sceKernelGetSystemTimeWide();
for(int i=0;i < testnum; i++)
{
normalize2_neon(v0, d);
};
v2t[2] = sceKernelGetSystemTimeWide();
normalize2_c(v0, d);
LOG("normalize2_c = [%.2f, %.2f]\n", d[0], d[1]);
normalize2_neon(v0, d);
LOG("normalize2_neon = [%.2f, %.2f]\n", d[0], d[1]);
LOG("normalize2: c=%i \t neon=%i \t rate=%.2f \n", v2t[1] - v2t[0], v2t[2] - v2t[1],
(float)(v2t[1] - v2t[0]) / (float)(v2t[2] - v2t[1]));
LOG("\n");
//dot 3
v3t[0] = sceKernelGetSystemTimeWide();
for(int i=0;i < testnum; i++)
{
r = dot3_c(v0, v1);
};
v3t[1] = sceKernelGetSystemTimeWide();
for(int i=0;i < testnum; i++)
{
r = dot3_neon(v0, v1);
};
v3t[2] = sceKernelGetSystemTimeWide();
r = dot3_c(v0, v1);
LOG("dot3_c = %f\n", r);
r = dot3_neon(v0, v1);
LOG("dot3_neon = %f\n", r);
LOG("dot3: c=%i \t neon=%i \t rate=%.2f \n", v3t[1] - v3t[0], v3t[2] - v3t[1],
(float)(v3t[1] - v3t[0]) / (float)(v3t[2] - v3t[1]));
//normalize 3
v3t[0] = sceKernelGetSystemTimeWide();
for(int i=0;i < testnum; i++)
{
normalize3_c(v0, d);
};
v3t[1] = sceKernelGetSystemTimeWide();
for(int i=0;i < testnum; i++)
{
normalize3_neon(v0, d);
};
v3t[2] = sceKernelGetSystemTimeWide();
normalize3_c(v0, d);
LOG("normalize3_c = [%.2f, %.2f, %.2f]\n", d[0], d[1], d[2]);
normalize3_neon(v0, d);
LOG("normalize3_neon = [%.2f, %.2f, %.2f]\n", d[0], d[1], d[2]);
LOG("normalize3: c=%i \t neon=%i \t rate=%.2f \n", v3t[1] - v3t[0], v3t[2] - v3t[1],
(float)(v3t[1] - v3t[0]) / (float)(v3t[2] - v3t[1]));
//cross 3
v3t[0] = sceKernelGetSystemTimeWide();
for(int i=0;i < testnum; i++)
{
cross3_c(v0, v1, d);
};
v3t[1] = sceKernelGetSystemTimeWide();
for(int i=0;i < testnum; i++)
{
cross3_neon(v0, v1, d);
};
v3t[2] = sceKernelGetSystemTimeWide();
cross3_c(v0, v1, d);
LOG("cross3_c = [%.2f, %.2f, %.2f]\n", d[0], d[1], d[2]);
cross3_neon(v0, v1, d);
LOG("cross3_neon = [%.2f, %.2f, %.2f]\n", d[0], d[1], d[2]);
LOG("cross3: c=%i \t neon=%i \t rate=%.2f \n", v3t[1] - v3t[0], v3t[2] - v3t[1],
(float)(v3t[1] - v3t[0]) / (float)(v3t[2] - v3t[1]));
LOG("\n");
//dot 4
v4t[0] = sceKernelGetSystemTimeWide();
for(int i=0;i < testnum; i++)
{
r = dot4_c(v0, v1);
};
v4t[1] = sceKernelGetSystemTimeWide();
for(int i=0;i < testnum; i++)
{
r = dot4_neon(v0, v1);
};
v4t[2] = sceKernelGetSystemTimeWide();
r = dot4_c(v0, v1);
LOG("dot4_c = %f\n", r);
r = dot4_neon(v0, v1);
LOG("dot4_neon = %f\n", r);
LOG("dot4: c=%i \t neon=%i \t rate=%.2f \n", v4t[1] - v4t[0], v4t[2] - v4t[1],
(float)(v4t[1] - v4t[0]) / (float)(v4t[2] - v4t[1]));
//normalize 4
v4t[0] = sceKernelGetSystemTimeWide();
for(int i=0;i < testnum; i++)
{
normalize4_c(v0, d);
};
v4t[1] = sceKernelGetSystemTimeWide();
for(int i=0;i < testnum; i++)
{
normalize4_neon(v0, d);
};
v4t[2] = sceKernelGetSystemTimeWide();
normalize4_c(v0, d);
LOG("normalize4_c = [%.2f, %.2f, %.2f, %.2f]\n", d[0], d[1], d[2], d[3]);
normalize4_neon(v0, d);
LOG("normalize4_neon = [%.2f, %.2f, %.2f, %.2f]\n", d[0], d[1], d[2], d[3]);
LOG("normalize4: c=%i \t neon=%i \t rate=%.2f \n", v4t[1] - v4t[0], v4t[2] - v4t[1],
(float)(v4t[1] - v4t[0]) / (float)(v4t[2] - v4t[1]));
LOG("\n");
}
void test_matrixfunc()
{
float m0[16], m1[16], m2[16];
int m2t[3], m3t[3], m4t[3];
int i;
int testnum = 1000000;
struct rusage ru;
for(int i=0;i<16;i++)
{
m0[i] = 10.0f * randf() - 5.0f;
m1[i] = 10.0f * randf() - 5.0f;
m2[i] = 10.0f * randf() - 5.0f;
}
//matmul2
m2t[0] = sceKernelGetSystemTimeWide();
for(i = 0; i < testnum; i++){
matmul2_c(m0, m1, m2);
}
m2t[1] = sceKernelGetSystemTimeWide();
for(i = 0; i < testnum; i++){
matmul2_neon(m0, m1, m2);
}
m2t[2] = sceKernelGetSystemTimeWide();
matmul2_c(m0, m1, m2);
LOG("matmul2_c = \n");
LOG("\t\t\t|%.2f, %.2f|\n", m2[0], m2[2]);
LOG("\t\t\t|%.2f, %.2f|\n", m2[1], m2[3]);
matmul2_neon(m0, m1, m2);
LOG("matmul2_neon = \n");
LOG("\t\t\t|%.2f, %.2f|\n", m2[0], m2[2]);
LOG("\t\t\t|%.2f, %.2f|\n", m2[1], m2[3]);
LOG("matmul2: c=%i \t neon=%i \t rate=%.2f \n", m2t[1] - m2t[0], m2t[2] - m2t[1],
(float)(m2t[1] - m2t[0]) / (float)(m2t[2] - m2t[1]));
//matvec2
m2t[0] = sceKernelGetSystemTimeWide();
for(i = 0; i < testnum; i++){
matvec2_c(m0, m1, m2);
}
m2t[1] = sceKernelGetSystemTimeWide();
for(i = 0; i < testnum; i++){
matvec2_neon(m0, m1, m2);
}
m2t[2] = sceKernelGetSystemTimeWide();
memset(m2, 0, 4*sizeof(float));
matvec2_c(m0, m1, m2);
LOG("matvec2_c = |%.2f, %.2f|\n", m2[0], m2[1]);
memset(m2, 0, 4*sizeof(float));
matvec2_neon(m0, m1, m2);
LOG("matvec2_neon = |%.2f, %.2f|\n", m2[0], m2[1]);
LOG("matvec2: c=%i \t neon=%i \t rate=%.2f \n", m2t[1] - m2t[0], m2t[2] - m2t[1],
(float)(m2t[1] - m2t[0]) / (float)(m2t[2] - m2t[1]));
//MAT3
m3t[0] = sceKernelGetSystemTimeWide();
for(i = 0; i < testnum; i++){
matmul3_c(m0, m1, m2);
}
m3t[1] = sceKernelGetSystemTimeWide();
for(i = 0; i < testnum; i++){
matmul3_neon(m0, m1, m2);
}
m3t[2] = sceKernelGetSystemTimeWide();
memset(m2, 0, 9*sizeof(float));
matmul3_c(m0, m1, m2);
LOG("matmul3_c =\n");
LOG("\t\t\t|%.2f, %.2f, %.2f|\n", m2[0], m2[3], m2[6]);
LOG("\t\t\t|%.2f, %.2f, %.2f|\n", m2[1], m2[4], m2[7]);
LOG("\t\t\t|%.2f, %.2f, %.2f|\n", m2[2], m2[5], m2[8]);
memset(m2, 0, 9*sizeof(float));
matmul3_neon(m0, m1, m2);
LOG("matmul3_neon =\n");
LOG("\t\t\t|%.2f, %.2f, %.2f|\n", m2[0], m2[3], m2[6]);
LOG("\t\t\t|%.2f, %.2f, %.2f|\n", m2[1], m2[4], m2[7]);
LOG("\t\t\t|%.2f, %.2f, %.2f|\n", m2[2], m2[5], m2[8]);
LOG("matmul3: c=%i \t neon=%i \t rate=%.2f \n", m3t[1] - m3t[0], m3t[2] - m3t[1],
(float)(m3t[1] - m3t[0]) / (float)(m3t[2] - m3t[1]));
//matvec3
m3t[0] = sceKernelGetSystemTimeWide();
for(i = 0; i < testnum; i++){
matvec3_c(m0, m1, m2);
}
m3t[1] = sceKernelGetSystemTimeWide();
for(i = 0; i < testnum; i++){
matvec3_neon(m0, m1, m2);
}
m3t[2] = sceKernelGetSystemTimeWide();
memset(m2, 0, 4*sizeof(float));
matvec3_c(m0, m1, m2);
LOG("matvec3_c = |%.2f, %.2f, %.2f|\n", m2[0], m2[1], m2[2]);
memset(m2, 0, 4*sizeof(float));
matvec3_neon(m0, m1, m2);
LOG("matvec3_neon = |%.2f, %.2f, %.2f|\n", m2[0], m2[1], m2[2]);
LOG("matvec3: c=%i \t neon=%i \t rate=%.2f \n", m3t[1] - m3t[0], m3t[2] - m3t[1],
(float)(m3t[1] - m3t[0]) / (float)(m3t[2] - m3t[1]));
//MAT4
m4t[0] = sceKernelGetSystemTimeWide();
for(i = 0; i < testnum; i++){
matmul4_c(m0, m1, m2);
}
m4t[1] = sceKernelGetSystemTimeWide();
for(i = 0; i < testnum; i++){
matmul4_neon(m0, m1, m2);
}
m4t[2] = sceKernelGetSystemTimeWide();
memset(m2, 0, 16*sizeof(float));
matmul4_c(m0, m1, m2);
LOG("matmul4_c =\n");
LOG("\t\t\t|%.2f, %.2f, %.2f, %.2f|\n", m2[0], m2[4], m2[8], m2[12]);
LOG("\t\t\t|%.2f, %.2f, %.2f, %.2f|\n", m2[1], m2[5], m2[9], m2[13]);
LOG("\t\t\t|%.2f, %.2f, %.2f, %.2f|\n", m2[2], m2[6], m2[10], m2[14]);
LOG("\t\t\t|%.2f, %.2f, %.2f, %.2f|\n", m2[3], m2[7], m2[11], m2[15]);
memset(m2, 0, 16*sizeof(float));
matmul4_neon(m0, m1, m2);
LOG("matmul4_neon =\n");
LOG("\t\t\t|%.2f, %.2f, %.2f, %.2f|\n", m2[0], m2[4], m2[8], m2[12]);
LOG("\t\t\t|%.2f, %.2f, %.2f, %.2f|\n", m2[1], m2[5], m2[9], m2[13]);
LOG("\t\t\t|%.2f, %.2f, %.2f, %.2f|\n", m2[2], m2[6], m2[10], m2[14]);
LOG("\t\t\t|%.2f, %.2f, %.2f, %.2f|\n", m2[3], m2[7], m2[11], m2[15]);
LOG("matmul4: c=%i \t neon=%i \t rate=%.2f \n", m4t[1] - m4t[0], m4t[2] - m4t[1],
(float)(m4t[1] - m4t[0]) / (float)(m4t[2] - m4t[1]));
//matvec4
m4t[0] = sceKernelGetSystemTimeWide();
for(i = 0; i < testnum; i++){
matvec4_c(m0, m1, m2);
}
m4t[1] = sceKernelGetSystemTimeWide();
for(i = 0; i < testnum; i++){
matvec4_neon(m0, m1, m2);
}
m4t[2] = sceKernelGetSystemTimeWide();
memset(m2, 0, 4*sizeof(float));
matvec4_c(m0, m1, m2);
LOG("matvec4_c = |%.2f, %.2f, %.2f, %f|\n", m2[0], m2[1], m2[2], m2[3]);
memset(m2, 0, 4*sizeof(float));
matvec4_neon(m0, m1, m2);
LOG("matvec4_neon = |%.2f, %.2f, %.2f, %f|\n", m2[0], m2[1], m2[2], m2[3]);
LOG("matvec4: c=%i \t neon=%i \t rate=%.2f \n", m4t[1] - m4t[0], m4t[2] - m4t[1],
(float)(m4t[1] - m4t[0]) / (float)(m4t[2] - m4t[1]));
}
int main(int argc, char** argv)
{
int i, ii;
#if 1
LOG("RUNFAST: Disabled \n");
#else
LOG("RUNFAST: Enabled \n");
enable_runfast();
#endif
srand(time(NULL));
#if 1
//test single argument functions:
LOG("------------------------------------------------------------------------------------------------------\n");
LOG("MATRIX FUNCTION TESTS \n");
LOG("------------------------------------------------------------------------------------------------------\n");
test_matrixfunc();
test_vectorfunc();
LOG("------------------------------------------------------------------------------------------------------\n");
LOG("CMATH FUNCTION TESTS \n");
LOG("------------------------------------------------------------------------------------------------------\n");
LOG("Function\tRange\t\tNumber\tABS Max Error\tREL Max Error\tRMS Error\tTime\tRate\n");
LOG("------------------------------------------------------------------------------------------------------\n");
for(i = 0; i < 51; i++){
test_mathfunc1(&test1[i]);
ii = i - (i % 3);
LOG("%s\t", test1[i].name);
LOG("[%.2f, %.2f]\t", test1[i].rng0, test1[i].rng1);
LOG("%i\t", test1[i].num);
LOG("%.2e\t", test1[i].emaxabs);
LOG("%.2e%%\t", test1[i].emaxrel);
LOG("%.2e\t", test1[i].erms);
LOG("%i\t", test1[i].time);
LOG("x%.2f\t", (float)test1[ii].time / test1[i].time);
LOG("\n");
}
for(i = 0; i < 9; i++){
test_mathfunc2(&test2[i]);
ii = i - (i % 3);
LOG("%s\t", test2[i].name);
LOG("[%.2f, %.2f]\t", test2[i].rng0, test2[i].rng1);
LOG("%i\t", test2[i].num);
LOG("%.2e\t", test2[i].emaxabs);
LOG("%.2e%%\t", test2[i].emaxrel);
LOG("%.2e\t", test2[i].erms);
LOG("%i\t", test2[i].time);
LOG("x%.2f\t", (float)test2[ii].time / test2[i].time);
LOG("\n");
}
#else
float x = 0;
for(x = -M_PI_2; x < M_PI_2; x+= 0.01)
{
LOG("x=%.2f\t in=%.2f\t c=%.2f\t neon=%.2f \n", x, sinhf(x), sinhf_c(x), sinhf_neon(x));
}
#endif
return 0;
}
-67
View File
@@ -1,67 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "math.h"
#include "math_neon.h"
/*
Test func : acosf(x)
Test Range: -1.0 < x < 1.0
Peak Error: ~0.005%
RMS Error: ~0.001%
*/
const float __acosf_pi_2 = M_PI_2;
float acosf_c(float x)
{
return __acosf_pi_2 - asinf_c(x);
}
float acosf_neon_hfp(float x)
{
#ifdef __MATH_NEON
asinf_neon_hfp(x);
asm volatile (
"vdup.f32 d1, %0 \n\t" //d1 = {pi/2, pi/2};
"vsub.f32 d0, d1, d0 \n\t" //d0 = d1 - d0;
::"r"(__acosf_pi_2):
);
#endif
}
float acosf_neon_sfp(float x)
{
#ifdef __MATH_NEON
asm volatile ("vmov.f32 s0, r0 \n\t");
acosf_neon_hfp(x);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return acosf_c(x);
#endif
}
-183
View File
@@ -1,183 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "math.h"
#include "math_neon.h"
/*
Test func : asinf(x)
Test Range: -1.0 < x < 1.0
Peak Error: ~0.005%
RMS Error: ~0.001%
*/
const float __asinf_lut[4] = {
0.105312459675071, //p7
0.169303418571894, //p3
0.051599985887214, //p5
0.999954835104825 //p1
};
const float __asinf_pi_2 = M_PI_2;
float asinf_c(float x)
{
float a, b, c, d, r, ax;
int m;
union {
float f;
int i;
} xx;
ax = fabs(x);
d = 0.5;
d = d - ax*0.5;
//fast invsqrt approx
xx.f = d;
xx.i = 0x5F3759DF - (xx.i >> 1); //VRSQRTE
c = d * xx.f;
b = (3.0f - c * xx.f) * 0.5; //VRSQRTS
xx.f = xx.f * b;
c = d * xx.f;
b = (3.0f - c * xx.f) * 0.5;
xx.f = xx.f * b;
//fast inverse approx
d = xx.f;
m = 0x3F800000 - (xx.i & 0x7F800000);
xx.i = xx.i + m;
xx.f = 1.41176471f - 0.47058824f * xx.f;
xx.i = xx.i + m;
b = 2.0 - xx.f * d;
xx.f = xx.f * b;
b = 2.0 - xx.f * d;
xx.f = xx.f * b;
//if |x|>0.5 -> x = sqrt((1-x)/2)
xx.f = xx.f - ax;
a = (ax > 0.5f);
d = __asinf_pi_2 * a;
c = 1.0f - 3.0f * a;
ax = ax + xx.f * a;
//polynomial evaluation
xx.f = ax * ax;
a = (__asinf_lut[0] * ax) * xx.f + (__asinf_lut[2] * ax);
b = (__asinf_lut[1] * ax) * xx.f + (__asinf_lut[3] * ax);
xx.f = xx.f * xx.f;
r = b + a * xx.f;
r = d + c * r;
a = r + r;
b = (x < 0.0f);
r = r - a * b;
return r;
}
float asinf_neon_hfp(float x)
{
#ifdef __MATH_NEON
asm volatile (
"vdup.f32 d0, d0[0] \n\t" //d0 = {x, x};
"vdup.f32 d4, %1 \n\t" //d4 = {pi/2, pi/2};
"vmov.f32 d6, d0 \n\t" //d6 = d0;
"vabs.f32 d0, d0 \n\t" //d0 = fabs(d0) ;
"vmov.f32 d5, #0.5 \n\t" //d5 = 0.5;
"vmls.f32 d5, d0, d5 \n\t" //d5 = d5 - d0*d5;
//fast invsqrt approx
"vmov.f32 d1, d5 \n\t" //d1 = d5
"vrsqrte.f32 d5, d5 \n\t" //d5 = ~ 1.0 / sqrt(d5)
"vmul.f32 d2, d5, d1 \n\t" //d2 = d5 * d1
"vrsqrts.f32 d3, d2, d5 \n\t" //d3 = (3 - d5 * d2) / 2
"vmul.f32 d5, d5, d3 \n\t" //d5 = d5 * d3
"vmul.f32 d2, d5, d1 \n\t" //d2 = d5 * d1
"vrsqrts.f32 d3, d2, d5 \n\t" //d3 = (3 - d5 * d3) / 2
"vmul.f32 d5, d5, d3 \n\t" //d5 = d5 * d3
//fast reciporical approximation
"vrecpe.f32 d1, d5 \n\t" //d1 = ~ 1 / d5;
"vrecps.f32 d2, d1, d5 \n\t" //d2 = 2.0 - d1 * d5;
"vmul.f32 d1, d1, d2 \n\t" //d1 = d1 * d2;
"vrecps.f32 d2, d1, d5 \n\t" //d2 = 2.0 - d1 * d5;
"vmul.f32 d5, d1, d2 \n\t" //d5 = d1 * d2;
//if |x| > 0.5 -> ax = sqrt((1-ax)/2), r = pi/2
"vsub.f32 d5, d0, d5 \n\t" //d5 = d0 - d5;
"vmov.f32 d2, #0.5 \n\t" //d2 = 0.5;
"vcgt.f32 d3, d0, d2 \n\t" //d3 = (d0 > d2);
"vmov.f32 d1, #3.0 \n\t" //d5 = 3.0;
"vshr.u32 d3, #31 \n\t" //d3 = d3 >> 31;
"vmov.f32 d16, #1.0 \n\t" //d16 = 1.0;
"vcvt.f32.u32 d3, d3 \n\t" //d3 = (float) d3;
"vmls.f32 d0, d5, d3[0] \n\t" //d0 = d0 - d5 * d3[0];
"vmul.f32 d7, d4, d3[0] \n\t" //d7 = d5 * d4;
"vmls.f32 d16, d1, d3[0] \n\t" //d16 = d16 - d1 * d3;
//polynomial:
"vmul.f32 d2, d0, d0 \n\t" //d2 = d0*d0 = {ax^2, ax^2}
"vld1.32 {d4, d5}, [%0] \n\t" //d4 = {p7, p3}, d5 = {p5, p1}
"vmul.f32 d3, d2, d2 \n\t" //d3 = d2*d2 = {x^4, x^4}
"vmul.f32 q0, q2, d0[0] \n\t" //q0 = q2 * d0[0] = {p7x, p3x, p5x, p1x}
"vmla.f32 d1, d0, d2[0] \n\t" //d1 = d1 + d0*d2[0] = {p5x + p7x^3, p1x + p3x^3}
"vmla.f32 d1, d3, d1[0] \n\t" //d1 = d1 + d3*d1[0] = {..., p1x + p3x^3 + p5x^5 + p7x^7}
"vmla.f32 d7, d1, d16 \n\t" //d7 = d7 + d1*d16
"vadd.f32 d2, d7, d7 \n\t" //d2 = d7 + d7
"vclt.f32 d3, d6, #0 \n\t" //d3 = (d6 < 0)
"vshr.u32 d3, #31 \n\t" //d3 = d3 >> 31;
"vcvt.f32.u32 d3, d3 \n\t" //d3 = (float) d3
"vmls.f32 d7, d2, d3[0] \n\t" //d7 = d7 - d2 * d3[0];
"vmov.f32 s0, s15 \n\t" //s0 = s3
:: "r"(__asinf_lut), "r"(__asinf_pi_2)
: "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7"
);
#endif
}
float asinf_neon_sfp(float x)
{
#ifdef __MATH_NEON
asm volatile ("vmov.f32 s0, r0 \n\t");
asinf_neon_hfp(x);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return asinf_c(x);
#endif
}
-170
View File
@@ -1,170 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "math.h"
#include "math_neon.h"
const float __atan2f_lut[4] = {
-0.0443265554792128, //p7
-0.3258083974640975, //p3
+0.1555786518463281, //p5
+0.9997878412794807 //p1
};
const float __atan2f_pi_2 = M_PI_2;
float atan2f_c(float y, float x)
{
float a, b, c, r, xx;
int m;
union {
float f;
int i;
} xinv;
//fast inverse approximation (2x newton)
xx = fabs(x);
xinv.f = xx;
m = 0x3F800000 - (xinv.i & 0x7F800000);
xinv.i = xinv.i + m;
xinv.f = 1.41176471f - 0.47058824f * xinv.f;
xinv.i = xinv.i + m;
b = 2.0 - xinv.f * xx;
xinv.f = xinv.f * b;
b = 2.0 - xinv.f * xx;
xinv.f = xinv.f * b;
c = fabs(y * xinv.f);
//fast inverse approximation (2x newton)
xinv.f = c;
m = 0x3F800000 - (xinv.i & 0x7F800000);
xinv.i = xinv.i + m;
xinv.f = 1.41176471f - 0.47058824f * xinv.f;
xinv.i = xinv.i + m;
b = 2.0 - xinv.f * c;
xinv.f = xinv.f * b;
b = 2.0 - xinv.f * c;
xinv.f = xinv.f * b;
//if |x| > 1.0 -> ax = -1/ax, r = pi/2
xinv.f = xinv.f + c;
a = (c > 1.0f);
c = c - a * xinv.f;
r = a * __atan2f_pi_2;
//polynomial evaluation
xx = c * c;
a = (__atan2f_lut[0] * c) * xx + (__atan2f_lut[2] * c);
b = (__atan2f_lut[1] * c) * xx + (__atan2f_lut[3] * c);
xx = xx * xx;
r = r + a * xx;
r = r + b;
//determine quadrant and test for small x.
b = M_PI;
b = b - 2.0f * r;
r = r + (x < 0.0f) * b;
b = (fabs(x) < 0.000001f);
c = !b;
r = c * r;
r = r + __atan2f_pi_2 * b;
b = r + r;
r = r - (y < 0.0f) * b;
return r;
}
float atan2f_neon_hfp(float y, float x)
{
#ifdef __MATH_NEON
asm volatile (
"vdup.f32 d17, d0[1] \n\t" //d17 = {x, x};
"vdup.f32 d16, d0[0] \n\t" //d16 = {y, y};
//1.0 / x
"vrecpe.f32 d18, d17 \n\t" //d16 = ~ 1 / d1;
"vrecps.f32 d19, d18, d17 \n\t" //d17 = 2.0 - d16 * d1;
"vmul.f32 d18, d18, d19 \n\t" //d16 = d16 * d17;
"vrecps.f32 d19, d18, d17 \n\t" //d17 = 2.0 - d16 * d1;
"vmul.f32 d18, d18, d19 \n\t" //d16 = d16 * d17;
//y * (1.0 /x)
"vmul.f32 d0, d16, d18 \n\t" //d0 = d16 * d18;
"vdup.f32 d4, %1 \n\t" //d4 = {pi/2, pi/2};
"vmov.f32 d6, d0 \n\t" //d6 = d0;
"vabs.f32 d0, d0 \n\t" //d0 = fabs(d0) ;
//fast reciporical approximation
"vrecpe.f32 d1, d0 \n\t" //d1 = ~ 1 / d0;
"vrecps.f32 d2, d1, d0 \n\t" //d2 = 2.0 - d1 * d0;
"vmul.f32 d1, d1, d2 \n\t" //d1 = d1 * d2;
"vrecps.f32 d2, d1, d0 \n\t" //d2 = 2.0 - d1 * d0;
"vmul.f32 d1, d1, d2 \n\t" //d1 = d1 * d2;
//if |x| > 1.0 -> ax = 1/ax, r = pi/2
"vadd.f32 d1, d1, d0 \n\t" //d1 = d1 + d0;
"vmov.f32 d2, #1.0 \n\t" //d2 = 1.0;
"vcgt.f32 d3, d0, d2 \n\t" //d3 = (d0 > d2);
"vcvt.f32.u32 d3, d3 \n\t" //d3 = (float) d3;
"vmls.f32 d0, d1, d3 \n\t" //d0 = d0 - d1 * d3;
"vmul.f32 d7, d3, d4 \n\t" //d7 = d3 * d4;
//polynomial:
"vmul.f32 d2, d0, d0 \n\t" //d2 = d0*d0 = {ax^2, ax^2}
"vld1.32 {d4, d5}, [%0] \n\t" //d4 = {p7, p3}, d5 = {p5, p1}
"vmul.f32 d3, d2, d2 \n\t" //d3 = d2*d2 = {x^4, x^4}
"vmul.f32 q0, q2, d0[0] \n\t" //q0 = q2 * d0[0] = {p7x, p3x, p5x, p1x}
"vmla.f32 d1, d0, d2[0] \n\t" //d1 = d1 + d0*d2[0] = {p5x + p7x^3, p1x + p3x^3}
"vmla.f32 d1, d3, d1[0] \n\t" //d1 = d1 + d3*d1[0] = {..., p1x + p3x^3 + p5x^5 + p7x^7}
"vadd.f32 d1, d1, d7 \n\t" //d1 = d1 + d7
"vadd.f32 d2, d1, d1 \n\t" //d2 = d1 + d1
"vclt.f32 d3, d6, #0 \n\t" //d3 = (d6 < 0)
"vcvt.f32.u32 d3, d3 \n\t" //d3 = (float) d3
"vmls.f32 d1, d3, d2 \n\t" //d1 = d1 - d2 * d3;
"vmov.f32 s0, s3 \n\t" //s0 = s3
:: "r"(__atan2f_lut), "r"(__atan2f_pi_2)
: "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7"
);
#endif
}
float atan2f_neon_sfp(float x, float y)
{
#ifdef __MATH_NEON
asm volatile ("vmov.f32 s0, r0 \n\t");
asm volatile ("vmov.f32 s1, r1 \n\t");
atan2f_neon_hfp(x, y);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return atan2f_c(y, x);
#endif
};
-149
View File
@@ -1,149 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "math.h"
#include "math_neon.h"
const float __atanf_lut[4] = {
-0.0443265554792128, //p7
-0.3258083974640975, //p3
+0.1555786518463281, //p5
+0.9997878412794807 //p1
};
const float __atanf_pi_2 = M_PI_2;
float atanf_c(float x)
{
float a, b, r, xx;
int m;
union {
float f;
int i;
} xinv, ax;
ax.f = fabs(x);
//fast inverse approximation (2x newton)
xinv.f = ax.f;
m = 0x3F800000 - (xinv.i & 0x7F800000);
xinv.i = xinv.i + m;
xinv.f = 1.41176471f - 0.47058824f * xinv.f;
xinv.i = xinv.i + m;
b = 2.0 - xinv.f * ax.f;
xinv.f = xinv.f * b;
b = 2.0 - xinv.f * ax.f;
xinv.f = xinv.f * b;
//if |x| > 1.0 -> ax = -1/ax, r = pi/2
xinv.f = xinv.f + ax.f;
a = (ax.f > 1.0f);
ax.f = ax.f - a * xinv.f;
r = a * __atanf_pi_2;
//polynomial evaluation
xx = ax.f * ax.f;
a = (__atanf_lut[0] * ax.f) * xx + (__atanf_lut[2] * ax.f);
b = (__atanf_lut[1] * ax.f) * xx + (__atanf_lut[3] * ax.f);
xx = xx * xx;
b = b + a * xx;
r = r + b;
//if x < 0 -> r = -r
a = 2 * r;
b = (x < 0.0f);
r = r - a * b;
return r;
}
float atanf_neon_hfp(float x)
{
#ifdef __MATH_NEON
asm volatile (
"vdup.f32 d0, d0[0] \n\t" //d0 = {x, x};
"vdup.f32 d4, %1 \n\t" //d4 = {pi/2, pi/2};
"vmov.f32 d6, d0 \n\t" //d6 = d0;
"vabs.f32 d0, d0 \n\t" //d0 = fabs(d0) ;
//fast reciporical approximation
"vrecpe.f32 d1, d0 \n\t" //d1 = ~ 1 / d0;
"vrecps.f32 d2, d1, d0 \n\t" //d2 = 2.0 - d1 * d0;
"vmul.f32 d1, d1, d2 \n\t" //d1 = d1 * d2;
"vrecps.f32 d2, d1, d0 \n\t" //d2 = 2.0 - d1 * d0;
"vmul.f32 d1, d1, d2 \n\t" //d1 = d1 * d2;
//if |x| > 1.0 -> ax = -1/ax, r = pi/2
"vadd.f32 d1, d1, d0 \n\t" //d1 = d1 + d0;
"vmov.f32 d2, #1.0 \n\t" //d2 = 1.0;
"vcgt.f32 d3, d0, d2 \n\t" //d3 = (d0 > d2);
"vshr.u32 d3, #31 \n\t" //d3 = (d0 > d2);
"vcvt.f32.u32 d3, d3 \n\t" //d5 = (float) d3;
"vmls.f32 d0, d1, d3[0] \n\t" //d0 = d0 - d1 * d3[0];
"vmul.f32 d7, d4, d3[0] \n\t" //d7 = d5 * d4;
//polynomial:
"vmul.f32 d2, d0, d0 \n\t" //d2 = d0*d0 = {ax^2, ax^2}
"vld1.32 {d4, d5}, [%0] \n\t" //d4 = {p7, p3}, d5 = {p5, p1}
"vmul.f32 d3, d2, d2 \n\t" //d3 = d2*d2 = {x^4, x^4}
"vmul.f32 q0, q2, d0[0] \n\t" //q0 = q2 * d0[0] = {p7x, p3x, p5x, p1x}
"vmla.f32 d1, d0, d2[0] \n\t" //d1 = d1 + d0*d2[0] = {p5x + p7x^3, p1x + p3x^3}
"vmla.f32 d1, d3, d1[0] \n\t" //d1 = d1 + d3*d1[0] = {..., p1x + p3x^3 + p5x^5 + p7x^7}
"vadd.f32 d1, d1, d7 \n\t" //d1 = d1 + d7
"vadd.f32 d2, d1, d1 \n\t" //d2 = d1 + d1
"vclt.f32 d3, d6, #0 \n\t" //d3 = (d6 < 0)
"vshr.u32 d3, #31 \n\t" //d3 = (d0 > d2);
"vcvt.f32.u32 d3, d3 \n\t" //d3 = (float) d3
"vmls.f32 d1, d3, d2 \n\t" //d1 = d1 - d2 * d3;
"vmov.f32 s0, s3 \n\t" //s0 = s3
:: "r"(__atanf_lut), "r"(__atanf_pi_2)
: "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7"
);
#endif
}
float atanf_neon_sfp(float x)
{
#ifdef __MATH_NEON
asm volatile ("vdup.f32 d0, r0 \n\t");
atanf_neon_hfp(x);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return atanf_c(x);
#endif
};
-71
View File
@@ -1,71 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Assumes the floating point value |x| < 2147483648
*/
#include "math.h"
#include "math_neon.h"
float ceilf_c(float x)
{
int n;
float r;
n = (int) x;
r = (float) n;
r = r + (x > r);
return r;
}
float ceilf_neon_hfp(float x)
{
#ifdef __MATH_NEON
asm volatile (
"vcvt.s32.f32 d1, d0 \n\t" //d1 = (int) d0;
"vcvt.f32.s32 d1, d1 \n\t" //d1 = (float) d1;
"vcgt.f32 d0, d0, d1 \n\t" //d0 = (d0 > d1);
"vshr.u32 d0, #31 \n\t" //d0 = d0 >> 31;
"vcvt.f32.u32 d0, d0 \n\t" //d0 = (float) d0;
"vadd.f32 d0, d1, d0 \n\t" //d0 = d1 + d0;
::: "d0", "d1"
);
#endif
}
float ceilf_neon_sfp(float x)
{
#ifdef __MATH_NEON
asm volatile ("vmov.f32 s0, r0 \n\t");
ceilf_neon_hfp(x);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return ceilf_c(x);
#endif
};
-50
View File
@@ -1,50 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "math_neon.h"
float cosf_c(float x)
{
return sinf_c(x + M_PI_2);
}
float cosf_neon_hfp(float x)
{
#ifdef __MATH_NEON
float xx = x + M_PI_2;
return sinf_neon_hfp(xx);
#endif
}
float cosf_neon_sfp(float x)
{
#ifdef __MATH_NEON
asm volatile ("vdup.f32 d0, r0 \n\t");
cosf_neon_hfp(x);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return cosf_c(x);
#endif
};
-120
View File
@@ -1,120 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "math.h"
#include "math_neon.h"
const float __coshf_rng[2] = {
1.442695041f,
0.693147180f
};
const float __coshf_lut[16] = {
0.00019578093328483123, //p7
0.00019578093328483123, //p7
0.0014122663401803872, //p6
0.0014122663401803872, //p6
0.008336936973260111, //p5
0.008336936973260111, //p5
0.04165989275009526, //p4
0.04165989275009526, //p4
0.16666570253074878, //p3
0.16666570253074878, //p3
0.5000006143673624, //p2
0.5000006143673624, //p2
1.000000059694879, //p1
1.000000059694879, //p1
0.9999999916728642, //p0
0.9999999916728642 //p0
};
float coshf_c(float x)
{
float a, b, xx;
xx = -x;
a = expf_c(x);
b = expf_c(xx);
a = a * 0.5f;
a = a + 0.5f * b;
return a;
}
float coshf_neon_hfp(float x)
{
#ifdef __MATH_NEON
asm volatile (
"vdup.f32 d0, d0[0] \n\t" //d0 = {x, x}
"fnegs s1, s1 \n\t" //s1 = -s1
//Range Reduction:
"vld1.32 d2, [%0] \n\t" //d2 = {invrange, range}
"vld1.32 {d16, d17}, [%1]! \n\t"
"vmul.f32 d6, d0, d2[0] \n\t" //d6 = d0 * d2[0]
"vcvt.s32.f32 d6, d6 \n\t" //d6 = (int) d6
"vld1.32 {d18}, [%1]! \n\t"
"vcvt.f32.s32 d1, d6 \n\t" //d1 = (float) d6
"vld1.32 {d19}, [%1]! \n\t"
"vmls.f32 d0, d1, d2[1] \n\t" //d0 = d0 - d1 * d2[1]
"vld1.32 {d20}, [%1]! \n\t"
//polynomial:
"vmla.f32 d17, d16, d0 \n\t" //d17 = d17 + d16 * d0;
"vld1.32 {d21}, [%1]! \n\t"
"vmla.f32 d18, d17, d0 \n\t" //d18 = d18 + d17 * d0;
"vld1.32 {d22}, [%1]! \n\t"
"vmla.f32 d19, d18, d0 \n\t" //d19 = d19 + d18 * d0;
"vld1.32 {d23}, [%1]! \n\t"
"vmla.f32 d20, d19, d0 \n\t" //d20 = d20 + d19 * d0;
"vmla.f32 d21, d20, d0 \n\t" //d21 = d21 + d20 * d0;
"vmla.f32 d22, d21, d0 \n\t" //d22 = d22 + d21 * d0;
"vmla.f32 d23, d22, d0 \n\t" //d23 = d23 + d22 * d0;
//multiply by 2 ^ m
"vshl.i32 d6, d6, #23 \n\t" //d6 = d6 << 23
"vadd.i32 d0, d23, d6 \n\t" //d0 = d22 + d6
"vdup.f32 d2, d0[1] \n\t" //d2 = s1
"vmov.f32 d1, #0.5 \n\t" //d1 = 0.5
"vadd.f32 d0, d0, d2 \n\t" //d0 = d0 + d2
"vmul.f32 d0, d1 \n\t" //d0 = d0 * d1
:: "r"(__coshf_rng), "r"(__coshf_lut)
: "d0", "d1", "q1", "q2", "d6"
);
#endif
}
float coshf_neon_sfp(float x)
{
#ifdef __MATH_NEON
asm volatile ("vmov.f32 s0, r0 \n\t");
coshf_neon_hfp(x);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return coshf_c(x);
#endif
}
-135
View File
@@ -1,135 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Based on:
e ^ x = (1+m) * (2^n)
x = log(1+m) + n * log(2)
n = (int) (x * 1.0 / log(2))
(1+m) = e ^ (x - n * log(2))
(1+m) = Poly(x - n * log(2))
where Poly(x) is the Minimax approximation of e ^ x over the
range [-Log(2), Log(2)]
Test func : expf(x)
Test Range: 0 < x < 50
Peak Error: ~0.00024%
RMS Error: ~0.00007%
*/
#include "math.h"
#include "math_neon.h"
const float __expf_rng[2] = {
1.442695041f,
0.693147180f
};
const float __expf_lut[8] = {
0.9999999916728642, //p0
0.04165989275009526, //p4
0.5000006143673624, //p2
0.0014122663401803872, //p6
1.000000059694879, //p1
0.008336936973260111, //p5
0.16666570253074878, //p3
0.00019578093328483123 //p7
};
float expf_c(float x)
{
float a, b, c, d, xx;
int m;
union {
float f;
int i;
} r;
//Range Reduction:
m = (int) (x * __expf_rng[0]);
x = x - ((float) m) * __expf_rng[1];
//Taylor Polynomial (Estrins)
a = (__expf_lut[4] * x) + (__expf_lut[0]);
b = (__expf_lut[6] * x) + (__expf_lut[2]);
c = (__expf_lut[5] * x) + (__expf_lut[1]);
d = (__expf_lut[7] * x) + (__expf_lut[3]);
xx = x * x;
a = a + b * xx;
c = c + d * xx;
xx = xx* xx;
r.f = a + c * xx;
//multiply by 2 ^ m
m = m << 23;
r.i = r.i + m;
return r.f;
}
float expf_neon_hfp(float x)
{
#ifdef __MATH_NEON
asm volatile (
"vdup.f32 d0, d0[0] \n\t" //d0 = {x, x}
//Range Reduction:
"vld1.32 d2, [%0] \n\t" //d2 = {invrange, range}
"vmul.f32 d6, d0, d2[0] \n\t" //d6 = d0 * d2[0]
"vcvt.s32.f32 d6, d6 \n\t" //d6 = (int) d6
"vcvt.f32.s32 d1, d6 \n\t" //d1 = (float) d6
"vmls.f32 d0, d1, d2[1] \n\t" //d0 = d0 - d1 * d2[1]
//polynomial:
"vmul.f32 d1, d0, d0 \n\t" //d1 = d0*d0 = {x^2, x^2}
"vld1.32 {d2, d3, d4, d5}, [%1] \n\t" //q1 = {p0, p4, p2, p6}, q2 = {p1, p5, p3, p7} ;
"vmla.f32 q1, q2, d0[0] \n\t" //q1 = q1 + q2 * d0[0]
"vmla.f32 d2, d3, d1[0] \n\t" //d2 = d2 + d3 * d1[0]
"vmul.f32 d1, d1, d1 \n\t" //d1 = d1 * d1 = {x^4, x^4}
"vmla.f32 d2, d1, d2[1] \n\t" //d2 = d2 + d1 * d2[1]
//multiply by 2 ^ m
"vshl.i32 d6, d6, #23 \n\t" //d6 = d6 << 23
"vadd.i32 d0, d2, d6 \n\t" //d0 = d2 + d6
:: "r"(__expf_rng), "r"(__expf_lut)
: "d0", "d1", "q1", "q2", "d6"
);
#endif
}
float expf_neon_sfp(float x)
{
#ifdef __MATH_NEON
asm volatile ("vmov.f32 s0, r0 \n\t");
expf_neon_hfp(x);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return expf_c(x);
#endif
};
-58
View File
@@ -1,58 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "math_neon.h"
float fabsf_c(float x)
{
union {
int i;
float f;
} xx;
xx.f = x;
xx.i = xx.i & 0x7FFFFFFF;
return xx.f;
}
float fabsf_neon_hfp(float x)
{
#ifdef __MATH_NEON
asm volatile (
"fabss s0, s0 \n\t" //s0 = fabs(s0)
);
#endif
}
float fabsf_neon_sfp(float x)
{
#ifdef __MATH_NEON
asm volatile (
"bic r0, r0, #0x80000000 \n\t" //r0 = r0 & ~(1 << 31)
);
#else
return fabsf_c(x);
#endif
}
-66
View File
@@ -1,66 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Assumes the floating point value |x| < 2147483648
*/
#include "math.h"
#include "math_neon.h"
float floorf_c(float x)
{
int n;
float r;
n = (int) x;
r = (float) n;
r = r - (r > x);
return r;
}
float floorf_neon_hfp(float x)
{
#ifdef __MATH_NEON
asm volatile (
"vcvt.s32.f32 d1, d0 \n\t" //d1 = (int) d0;
"vcvt.f32.s32 d1, d1 \n\t" //d1 = (float) d1;
"vcgt.f32 d0, d1, d0 \n\t" //d0 = (d1 > d0);
"vshr.u32 d0, #31 \n\t" //d0 = d0 >> 31;
"vcvt.f32.u32 d0, d0 \n\t" //d0 = (float) d0;
"vsub.f32 d0, d1, d0 \n\t" //d0 = d1 - d0;
::: "d0", "d1"
);
#endif
}
float floorf_neon_sfp(float x)
{
#ifdef __MATH_NEON
asm volatile ("vmov.f32 s0, r0 \n\t");
floorf_neon_hfp(x);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return floorf_c(x);
#endif
};
-100
View File
@@ -1,100 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Assumes the floating point value |x / y| < 2,147,483,648
*/
#include "math_neon.h"
float fmodf_c(float x, float y)
{
int n;
union {
float f;
int i;
} yinv;
float a;
//fast reciporical approximation (4x Newton)
yinv.f = y;
n = 0x3F800000 - (yinv.i & 0x7F800000);
yinv.i = yinv.i + n;
yinv.f = 1.41176471f - 0.47058824f * yinv.f;
yinv.i = yinv.i + n;
a = 2.0 - yinv.f * y;
yinv.f = yinv.f * a;
a = 2.0 - yinv.f * y;
yinv.f = yinv.f * a;
a = 2.0 - yinv.f * y;
yinv.f = yinv.f * a;
a = 2.0 - yinv.f * y;
yinv.f = yinv.f * a;
n = (int)(x * yinv.f);
x = x - ((float)n) * y;
return x;
}
float fmodf_neon_hfp(float x, float y)
{
#ifdef __MATH_NEON
asm volatile (
"vdup.f32 d1, d0[1] \n\t" //d1[0] = y
"vdup.f32 d0, d0[0] \n\t" //d1[0] = y
//fast reciporical approximation
"vrecpe.f32 d2, d1 \n\t" //d2 = ~1.0 / d1
"vrecps.f32 d3, d2, d1 \n\t" //d3 = 2.0 - d2 * d1;
"vmul.f32 d2, d2, d3 \n\t" //d2 = d2 * d3;
"vrecps.f32 d3, d2, d1 \n\t" //d3 = 2.0 - d2 * d1;
"vmul.f32 d2, d2, d3 \n\t" //d2 = d2 * d3;
"vrecps.f32 d3, d2, d1 \n\t" //d3 = 2.0 - d2 * d1;
"vmul.f32 d2, d2, d3 \n\t" //d2 = d2 * d3;
"vrecps.f32 d3, d2, d1 \n\t" //d3 = 2.0 - d2 * d1;
"vmul.f32 d2, d2, d3 \n\t" //d2 = d2 * d3;
"vmul.f32 d2, d2, d0 \n\t" //d2 = d2 * d0;
"vcvt.s32.f32 d2, d2 \n\t" //d2 = (int) d2;
"vcvt.f32.s32 d2, d2 \n\t" //d2 = (float) d2;
"vmls.f32 d0, d1, d2 \n\t" //d0 = d0 - d1 * d2;
::: "d0", "d1", "d2", "d3"
);
#endif
}
float fmodf_neon_sfp(float x, float y)
{
#ifdef __MATH_NEON
asm volatile ("vmov.f32 s0, r0 \n\t");
asm volatile ("vmov.f32 s1, r1 \n\t");
fmodf_neon_hfp(x, y);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return fmodf_c(x,y);
#endif
};
-79
View File
@@ -1,79 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "math.h"
#include "math_neon.h"
float invsqrtf_c(float x)
{
float b, c;
union {
float f;
int i;
} a;
//fast invsqrt approx
a.f = x;
a.i = 0x5F3759DF - (a.i >> 1); //VRSQRTE
c = x * a.f;
b = (3.0f - c * a.f) * 0.5; //VRSQRTS
a.f = a.f * b;
c = x * a.f;
b = (3.0f - c * a.f) * 0.5;
a.f = a.f * b;
return a.f;
}
float invsqrtf_neon_hfp(float x)
{
#ifdef __MATH_NEON
asm volatile (
"vmov.f32 d1, d0 \n\t" //d1 = d0
"vrsqrte.f32 d0, d0 \n\t" //d0 = ~ 1.0 / sqrt(d0)
"vmul.f32 d2, d0, d1 \n\t" //d2 = d0 * d1
"vrsqrts.f32 d3, d2, d0 \n\t" //d3 = (3 - d0 * d2) / 2
"vmul.f32 d0, d0, d3 \n\t" //d0 = d0 * d3
"vmul.f32 d2, d0, d1 \n\t" //d2 = d0 * d1
"vrsqrts.f32 d3, d2, d0 \n\t" //d4 = (3 - d0 * d3) / 2
"vmul.f32 d0, d0, d3 \n\t" //d0 = d0 * d4
::: "d0", "d1", "d2", "d3"
);
#endif
}
float invsqrtf_neon_sfp(float x)
{
#ifdef __MATH_NEON
asm volatile ("vmov.f32 s0, r0 \n\t");
invsqrtf_neon_hfp(x);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return invsqrtf_c(x);
#endif
};
-67
View File
@@ -1,67 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "math.h"
#include "math_neon.h"
float ldexpf_c(float m, int e)
{
union {
float f;
int i;
} r;
r.f = m;
r.i += (e << 23);
return r.f;
}
float ldexpf_neon_hfp(float m, int e)
{
#ifdef __MATH_NEON
float r;
asm volatile (
"lsl r0, r0, #23 \n\t" //r0 = r0 << 23
"vdup.i32 d1, r0 \n\t" //d1 = {r0, r0}
"vadd.i32 d0, d0, d1 \n\t" //d0 = d0 + d1
::: "d0", "d1"
);
#endif
}
float ldexpf_neon_sfp(float m, int e)
{
#ifdef __MATH_NEON
float r;
asm volatile (
"lsl r1, r1, #23 \n\t" //r1 = r1 << 23
"vdup.f32 d0, r0 \n\t" //d0 = {r0, r0}
"vdup.i32 d1, r1 \n\t" //d1 = {r1, r1}
"vadd.i32 d0, d0, d1 \n\t" //d0 = d0 + d1
"vmov.f32 r0, s0 \n\t" //r0 = s0
::: "d0", "d1"
);
#else
return ldexpf_c(m,e);
#endif
}
-135
View File
@@ -1,135 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Based on:
log10(x) = log10((1+m) * (2^n))
log(x) = n * log10(2) + log10(1 + m)
log(1+m) = Poly(1+m)
where Poly(x) is the Minimax approximation of log10(x) over the
range [1, 2]
Test func : log10f(x)
Test Range: 1 < x < 10000
Peak Error: ~0.000040%
RMS Error: ~0.000008%
*/
#include "math.h"
#include "math_neon.h"
const float __log10f_rng = 0.3010299957f;
const float __log10f_lut[8] = {
-0.99697286229624, //p0
-1.07301643912502, //p4
-2.46980061535534, //p2
-0.07176870463131, //p6
2.247870219989470, //p1
0.366547581117400, //p5
1.991005185100089, //p3
0.006135635201050, //p7
};
float log10f_c(float x)
{
float a, b, c, d, xx;
int m;
union {
float f;
int i;
} r;
//extract exponent
r.f = x;
m = (r.i >> 23);
m = m - 127;
r.i = r.i - (m << 23);
//Taylor Polynomial (Estrins)
xx = r.f * r.f;
a = (__log10f_lut[4] * r.f) + (__log10f_lut[0]);
b = (__log10f_lut[6] * r.f) + (__log10f_lut[2]);
c = (__log10f_lut[5] * r.f) + (__log10f_lut[1]);
d = (__log10f_lut[7] * r.f) + (__log10f_lut[3]);
a = a + b * xx;
c = c + d * xx;
xx = xx * xx;
r.f = a + c * xx;
//add exponent
r.f = r.f + ((float) m) * __log10f_rng;
return r.f;
}
float log10f_neon_hfp(float x)
{
#ifdef __MATH_NEON
asm volatile (
"vdup.f32 d0, d0[0] \n\t" //d0 = {x,x};
//extract exponent
"vmov.i32 d2, #127 \n\t" //d2 = 127;
"vshr.u32 d6, d0, #23 \n\t" //d6 = d0 >> 23;
"vsub.i32 d6, d6, d2 \n\t" //d6 = d6 - d2;
"vshl.u32 d1, d6, #23 \n\t" //d1 = d6 << 23;
"vsub.i32 d0, d0, d1 \n\t" //d0 = d0 + d1;
//polynomial:
"vmul.f32 d1, d0, d0 \n\t" //d1 = d0*d0 = {x^2, x^2}
"vld1.32 {d2, d3, d4, d5}, [%1] \n\t" //q1 = {p0, p4, p2, p6}, q2 = {p1, p5, p3, p7} ;
"vmla.f32 q1, q2, d0[0] \n\t" //q1 = q1 + q2 * d0[0]
"vmla.f32 d2, d3, d1[0] \n\t" //d2 = d2 + d3 * d1[0]
"vmul.f32 d1, d1, d1 \n\t" //d1 = d1 * d1 = {x^4, x^4}
"vmla.f32 d2, d1, d2[1] \n\t" //d2 = d2 + d1 * d2[1]
//add exponent
"vdup.32 d7, %0 \n\t" //d7 = {rng, rng}
"vcvt.f32.s32 d6, d6 \n\t" //d6 = (float) d6
"vmla.f32 d2, d6, d7 \n\t" //d2 = d2 + d6 * d7
"vmov.f32 s0, s4 \n\t" //s0 = s4
:: "r"(__log10f_rng), "r"(__log10f_lut)
: "d0", "d1", "q1", "q2", "d6", "d7"
);
#endif
}
float log10f_neon_sfp(float x)
{
#ifdef __MATH_NEON
asm volatile ("vmov.f32 s0, r0 \n\t");
log10f_neon_hfp(x);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return log10f_c(x);
#endif
};
-135
View File
@@ -1,135 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Based on:
log(x) = log((1+m) * (2^n))
log(x) = n * log(2) + log(1 + m)
log(1+m) = Poly(1+m)
where Poly(x) is the Minimax approximation of log(x) over the
range [1, 2]
Test func : logf(x)
Test Range: 1 < x < 10000
Peak Error: ~0.000601%
RMS Error: ~0.000005%
*/
#include "math.h"
#include "math_neon.h"
const float __logf_rng = 0.693147180f;
const float __logf_lut[8] = {
-2.295614848256274, //p0
-2.470711633419806, //p4
-5.686926051100417, //p2
-0.165253547131978, //p6
+5.175912446351073, //p1
+0.844006986174912, //p5
+4.584458825456749, //p3
+0.014127821926000 //p7
};
float logf_c(float x)
{
float a, b, c, d, xx;
int m;
union {
float f;
int i;
} r;
//extract exponent
r.f = x;
m = (r.i >> 23);
m = m - 127;
r.i = r.i - (m << 23);
//Taylor Polynomial (Estrins)
xx = r.f * r.f;
a = (__logf_lut[4] * r.f) + (__logf_lut[0]);
b = (__logf_lut[6] * r.f) + (__logf_lut[2]);
c = (__logf_lut[5] * r.f) + (__logf_lut[1]);
d = (__logf_lut[7] * r.f) + (__logf_lut[3]);
a = a + b * xx;
c = c + d * xx;
xx = xx * xx;
r.f = a + c * xx;
//add exponent
r.f = r.f + ((float) m) * __logf_rng;
return r.f;
}
float logf_neon_hfp(float x)
{
#ifdef __MATH_NEON
asm volatile (
"vdup.f32 d0, d0[0] \n\t" //d0 = {x,x};
//extract exponent
"vmov.i32 d2, #127 \n\t" //d2 = 127;
"vshr.u32 d6, d0, #23 \n\t" //d6 = d0 >> 23;
"vsub.i32 d6, d6, d2 \n\t" //d6 = d6 - d2;
"vshl.u32 d1, d6, #23 \n\t" //d1 = d6 << 23;
"vsub.i32 d0, d0, d1 \n\t" //d0 = d0 + d1;
//polynomial:
"vmul.f32 d1, d0, d0 \n\t" //d1 = d0*d0 = {x^2, x^2}
"vld1.32 {d2, d3, d4, d5}, [%1] \n\t" //q1 = {p0, p4, p2, p6}, q2 = {p1, p5, p3, p7} ;
"vmla.f32 q1, q2, d0[0] \n\t" //q1 = q1 + q2 * d0[0]
"vmla.f32 d2, d3, d1[0] \n\t" //d2 = d2 + d3 * d1[0]
"vmul.f32 d1, d1, d1 \n\t" //d1 = d1 * d1 = {x^4, x^4}
"vmla.f32 d2, d1, d2[1] \n\t" //d2 = d2 + d1 * d2[1]
//add exponent
"vdup.32 d7, %0 \n\t" //d7 = {rng, rng}
"vcvt.f32.s32 d6, d6 \n\t" //d6 = (float) d6
"vmla.f32 d2, d6, d7 \n\t" //d2 = d2 + d6 * d7
"vmov.f32 s0, s4 \n\t" //s0 = s4
:: "r"(__logf_rng), "r"(__logf_lut)
: "d0", "d1", "q1", "q2", "d6", "d7"
);
#endif
}
float logf_neon_sfp(float x)
{
#ifdef __MATH_NEON
asm volatile ("vmov.f32 s0, r0 \n\t");
logf_neon_hfp(x);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return logf_c(x);
#endif
};
-95
View File
@@ -1,95 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Matrices are specified in column major format:
| a c |
| b d |
therefore m[2] = c
*/
#include "math_neon.h"
//matrix matrix multipication. d = m0 * m1;
void
matmul2_c(float m0[4], float m1[4], float d[4])
{
d[0] = m0[0]*m1[0] + m0[2]*m1[1];
d[1] = m0[1]*m1[0] + m0[3]*m1[1];
d[2] = m0[0]*m1[2] + m0[2]*m1[3];
d[3] = m0[1]*m1[2] + m0[3]*m1[3];
}
void
matmul2_neon(float m0[4], float m1[4], float d[4])
{
#ifdef __MATH_NEON
asm volatile (
"vld1.32 {d0, d1}, [%0] \n\t" //Q1 = m0
"vld1.32 {d2, d3}, [%1] \n\t" //Q2 = m1
"vmul.f32 d4, d0, d2[0] \n\t" //D4 = D0*D2[0]
"vmul.f32 d5, d0, d3[0] \n\t" //D5 = D0*D3[0]
"vmla.f32 d4, d1, d2[1] \n\t" //D4 += D1*D2[1]
"vmla.f32 d5, d1, d3[1] \n\t" //D5 += D1*D3[1]
"vst1.32 {d4, d5}, [%2] \n\t" //Q4 = m+12
:: "r"(m0), "r"(m1), "r"(d)
: "q0", "q1", "q2", "memory"
);
#else
matmul2_c(m0, m1, d);
#endif
}
//matrix vector multiplication. d = m * v
void
matvec2_c(float m[4], float v[2], float d[2])
{
d[0] = m[0]*v[0] + m[2]*v[1];
d[1] = m[1]*v[0] + m[3]*v[1];
}
void
matvec2_neon(float m[4], float v[2], float d[2])
{
#ifdef __MATH_NEON
asm volatile (
"vld1.32 d0, [%1] \n\t" //d0 = v
"vld1.32 {d1, d2}, [%0] \n\t" //Q1 = m
"vmul.f32 d3, d1, d0[0] \n\t" //Q5 = Q1*d0[0]
"vmla.f32 d3, d2, d0[1] \n\t" //Q5 += Q1*d0[1]
"vst1.32 d3, [%2] \n\t" //Q4 = m+12
:: "r"(m), "r"(v), "r"(d)
: "d0", "d1", "d2","d3", "memory"
);
#else
matvec2_c(m, v, d);
#endif
}
-131
View File
@@ -1,131 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Matrices are specified in row major format:
| x0 x2 |
| x1 x3 |
therefore m[2] = x2
*/
#include "math_neon.h"
//matrix matrix multipication. d = m0 * m1;
void
matmul3_c(float m0[9], float m1[9], float d[9])
{
d[0] = m0[0]*m1[0] + m0[3]*m1[1] + m0[6]*m1[2];
d[1] = m0[1]*m1[0] + m0[4]*m1[1] + m0[7]*m1[2];
d[2] = m0[2]*m1[0] + m0[5]*m1[1] + m0[8]*m1[2];
d[3] = m0[0]*m1[3] + m0[3]*m1[4] + m0[6]*m1[5];
d[4] = m0[1]*m1[3] + m0[4]*m1[4] + m0[7]*m1[5];
d[5] = m0[2]*m1[3] + m0[5]*m1[4] + m0[8]*m1[5];
d[6] = m0[0]*m1[6] + m0[3]*m1[7] + m0[6]*m1[8];
d[7] = m0[1]*m1[6] + m0[4]*m1[7] + m0[7]*m1[8];
d[8] = m0[2]*m1[6] + m0[5]*m1[7] + m0[8]*m1[8];
}
void
matmul3_neon(float m0[9], float m1[9], float d[9])
{
#ifdef __MATH_NEON
asm volatile (
"vld1.32 {d0, d1}, [%1]! \n\t" //q0 = m1
"vld1.32 {d2, d3}, [%1]! \n\t" //q1 = m1+4
"flds s8, [%1] \n\t" //q2 = m1+8
"vld1.32 {d6, d7}, [%0] \n\t" //q3[0] = m0
"add %0, %0, #12 \n\t" //q3[0] = m0
"vld1.32 {d8, d9}, [%0] \n\t" //q4[0] = m0+12
"add %0, %0, #12 \n\t" //q3[0] = m0
"vld1.32 {d10}, [%0] \n\t" //q5[0] = m0+24
"add %0, %0, #8 \n\t" //q3[0] = m0
"flds s22, [%0] \n\t" //q2 = m1+8
"vmul.f32 q6, q3, d0[0] \n\t" //q12 = q3 * d0[0]
"vmul.f32 q7, q3, d1[1] \n\t" //q13 = q3 * d2[0]
"vmul.f32 q8, q3, d3[0] \n\t" //q14 = q3 * d4[0]
"vmla.f32 q6, q4, d0[1] \n\t" //q12 = q9 * d0[1]
"vmla.f32 q7, q4, d2[0] \n\t" //q13 = q9 * d2[1]
"vmla.f32 q8, q4, d3[1] \n\t" //q14 = q9 * d4[1]
"vmla.f32 q6, q5, d1[0] \n\t" //q12 = q10 * d0[0]
"vmla.f32 q7, q5, d2[1] \n\t" //q13 = q10 * d2[0]
"vmla.f32 q8, q5, d4[0] \n\t" //q14 = q10 * d4[0]
"vmov.f32 q0, q8 \n\t" //q14 = q10 * d4[0]
"vst1.32 {d12, d13}, [%2] \n\t" //d = q12
"add %2, %2, #12 \n\t" //q3[0] = m0
"vst1.32 {d14, d15}, [%2] \n\t" //d+4 = q13
"add %2, %2, #12 \n\t" //q3[0] = m0
"vst1.32 {d0}, [%2] \n\t" //d+8 = q14
"add %2, %2, #8 \n\t" //q3[0] = m0
"fsts s2, [%2] \n\t" //d = q12
: "+r"(m0), "+r"(m1), "+r"(d):
: "d8", "d9", "d10", "d11", "d12", "d13", "d14", "d15", "memory"
);
#else
matmul3_c(m0, m1, d);
#endif
};
//matrix vector multiplication. d = m * v
void
matvec3_c(float m[9], float v[3], float d[3])
{
d[0] = m[0]*v[0] + m[3]*v[1] + m[6]*v[2];
d[1] = m[1]*v[0] + m[4]*v[1] + m[7]*v[2];
d[2] = m[2]*v[0] + m[5]*v[1] + m[8]*v[2];
}
void
matvec3_neon(float m[9], float v[3], float d[3])
{
#ifdef __MATH_NEON
int tmp = 0;
asm volatile (
"mov %3, #12 \n\t" //r3 = 12
"vld1.32 {d0, d1}, [%1] \n\t" //Q0 = v
"vld1.32 {d2, d3}, [%0], %3 \n\t" //Q1 = m
"vld1.32 {d4, d5}, [%0], %3 \n\t" //Q2 = m+12
"vld1.32 {d6, d7}, [%0], %3 \n\t" //Q3 = m+24
"vmul.f32 q9, q1, d0[0] \n\t" //Q9 = Q1*Q0[0]
"vmla.f32 q9, q2, d0[1] \n\t" //Q9 += Q2*Q0[1]
"vmla.f32 q9, q3, d1[0] \n\t" //Q9 += Q3*Q0[2]
"vmov.f32 q0, q9 \n\t" //Q0 = q9
"vst1.32 d0, [%2]! \n\t" //r2 = D24
"fsts s2, [%2] \n\t" //r2 = D25[0]
: "+r"(m), "+r"(v), "+r"(d), "+r"(tmp):
: "q0", "q9", "q10","q11", "q12", "q13", "memory"
);
#else
matvec3_c(m, v, d);
#endif
}
-144
View File
@@ -1,144 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Matrices are specified in row major format:
| x0 x2 |
| x1 x3 |
therefore m[2] = x2
*/
#include "math_neon.h"
//matrix matrix multipication. d = m0 * m1;
void
matmul4_c(float m0[16], float m1[16], float d[16])
{
d[0] = m0[0]*m1[0] + m0[4]*m1[1] + m0[8]*m1[2] + m0[12]*m1[3];
d[1] = m0[1]*m1[0] + m0[5]*m1[1] + m0[9]*m1[2] + m0[13]*m1[3];
d[2] = m0[2]*m1[0] + m0[6]*m1[1] + m0[10]*m1[2] + m0[14]*m1[3];
d[3] = m0[3]*m1[0] + m0[7]*m1[1] + m0[11]*m1[2] + m0[15]*m1[3];
d[4] = m0[0]*m1[4] + m0[4]*m1[5] + m0[8]*m1[6] + m0[12]*m1[7];
d[5] = m0[1]*m1[4] + m0[5]*m1[5] + m0[9]*m1[6] + m0[13]*m1[7];
d[6] = m0[2]*m1[4] + m0[6]*m1[5] + m0[10]*m1[6] + m0[14]*m1[7];
d[7] = m0[3]*m1[4] + m0[7]*m1[5] + m0[11]*m1[6] + m0[15]*m1[7];
d[8] = m0[0]*m1[8] + m0[4]*m1[9] + m0[8]*m1[10] + m0[12]*m1[11];
d[9] = m0[1]*m1[8] + m0[5]*m1[9] + m0[9]*m1[10] + m0[13]*m1[11];
d[10] = m0[2]*m1[8] + m0[6]*m1[9] + m0[10]*m1[10] + m0[14]*m1[11];
d[11] = m0[3]*m1[8] + m0[7]*m1[9] + m0[11]*m1[10] + m0[15]*m1[11];
d[12] = m0[0]*m1[12] + m0[4]*m1[13] + m0[8]*m1[14] + m0[12]*m1[15];
d[13] = m0[1]*m1[12] + m0[5]*m1[13] + m0[9]*m1[14] + m0[13]*m1[15];
d[14] = m0[2]*m1[12] + m0[6]*m1[13] + m0[10]*m1[14] + m0[14]*m1[15];
d[15] = m0[3]*m1[12] + m0[7]*m1[13] + m0[11]*m1[14] + m0[15]*m1[15];
}
void
matmul4_neon(float m0[16], float m1[16], float d[16])
{
#ifdef __MATH_NEON
asm volatile (
"vld1.32 {d0, d1}, [%1]! \n\t" //q0 = m1
"vld1.32 {d2, d3}, [%1]! \n\t" //q1 = m1+4
"vld1.32 {d4, d5}, [%1]! \n\t" //q2 = m1+8
"vld1.32 {d6, d7}, [%1] \n\t" //q3 = m1+12
"vld1.32 {d16, d17}, [%0]! \n\t" //q8 = m0
"vld1.32 {d18, d19}, [%0]! \n\t" //q9 = m0+4
"vld1.32 {d20, d21}, [%0]! \n\t" //q10 = m0+8
"vld1.32 {d22, d23}, [%0] \n\t" //q11 = m0+12
"vmul.f32 q12, q8, d0[0] \n\t" //q12 = q8 * d0[0]
"vmul.f32 q13, q8, d2[0] \n\t" //q13 = q8 * d2[0]
"vmul.f32 q14, q8, d4[0] \n\t" //q14 = q8 * d4[0]
"vmul.f32 q15, q8, d6[0] \n\t" //q15 = q8 * d6[0]
"vmla.f32 q12, q9, d0[1] \n\t" //q12 = q9 * d0[1]
"vmla.f32 q13, q9, d2[1] \n\t" //q13 = q9 * d2[1]
"vmla.f32 q14, q9, d4[1] \n\t" //q14 = q9 * d4[1]
"vmla.f32 q15, q9, d6[1] \n\t" //q15 = q9 * d6[1]
"vmla.f32 q12, q10, d1[0] \n\t" //q12 = q10 * d0[0]
"vmla.f32 q13, q10, d3[0] \n\t" //q13 = q10 * d2[0]
"vmla.f32 q14, q10, d5[0] \n\t" //q14 = q10 * d4[0]
"vmla.f32 q15, q10, d7[0] \n\t" //q15 = q10 * d6[0]
"vmla.f32 q12, q11, d1[1] \n\t" //q12 = q11 * d0[1]
"vmla.f32 q13, q11, d3[1] \n\t" //q13 = q11 * d2[1]
"vmla.f32 q14, q11, d5[1] \n\t" //q14 = q11 * d4[1]
"vmla.f32 q15, q11, d7[1] \n\t" //q15 = q11 * d6[1]
"vst1.32 {d24, d25}, [%2]! \n\t" //d = q12
"vst1.32 {d26, d27}, [%2]! \n\t" //d+4 = q13
"vst1.32 {d28, d29}, [%2]! \n\t" //d+8 = q14
"vst1.32 {d30, d31}, [%2] \n\t" //d+12 = q15
: "+r"(m0), "+r"(m1), "+r"(d) :
: "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15",
"memory"
);
#else
matmul4_c(m0, m1, d);
#endif
}
//matrix vector multiplication. d = m * v
void
matvec4_c(float m[16], float v[4], float d[4])
{
d[0] = m[0]*v[0] + m[4]*v[1] + m[8]*v[2] + m[12]*v[3];
d[1] = m[1]*v[0] + m[5]*v[1] + m[9]*v[2] + m[13]*v[3];
d[2] = m[2]*v[0] + m[6]*v[1] + m[10]*v[2] + m[14]*v[3];
d[3] = m[3]*v[0] + m[7]*v[1] + m[11]*v[2] + m[15]*v[3];
}
void
matvec4_neon(float m[16], float v[4], float d[4])
{
#ifdef __MATH_NEON
asm volatile (
"vld1.32 {d0, d1}, [%1] \n\t" //Q0 = v
"vld1.32 {d18, d19}, [%0]! \n\t" //Q1 = m
"vld1.32 {d20, d21}, [%0]! \n\t" //Q2 = m+4
"vld1.32 {d22, d23}, [%0]! \n\t" //Q3 = m+8
"vld1.32 {d24, d25}, [%0]! \n\t" //Q4 = m+12
"vmul.f32 q13, q9, d0[0] \n\t" //Q5 = Q1*Q0[0]
"vmla.f32 q13, q10, d0[1] \n\t" //Q5 += Q1*Q0[1]
"vmla.f32 q13, q11, d1[0] \n\t" //Q5 += Q2*Q0[2]
"vmla.f32 q13, q12, d1[1] \n\t" //Q5 += Q3*Q0[3]
"vst1.32 {d26, d27}, [%2] \n\t" //Q4 = m+12
:
: "r"(m), "r"(v), "r"(d)
: "q0", "q9", "q10","q11", "q12", "q13", "memory"
);
#else
matvec4_c(m, v, d);
#endif
}
-71
View File
@@ -1,71 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Assumes the floating point value |x| < 2,147,483,648
*/
#include "math_neon.h"
float modf_c(float x, int *i)
{
int n;
n = (int)x;
*i = n;
x = x - (float)n;
return x;
}
float modf_neon_hfp(float x, int *i)
{
#ifdef __MATH_NEON
asm volatile (
"vcvt.s32.f32 d1, d0 \n\t" //d1 = (int) d0;
"vcvt.f32.s32 d2, d1 \n\t" //d2 = (float) d1;
"vsub.f32 d0, d0, d2 \n\t" //d0 = d0 - d2;
"vstr.i32 s2, [r0] \n\t" //[r0] = d1[0]
::: "d0", "d1", "d2"
);
#endif
}
float modf_neon_sfp(float x, int *i)
{
#ifdef __MATH_NEON
asm volatile (
"vdup.f32 d0, r0 \n\t" //d0 = {x, x}
"vcvt.s32.f32 d1, d0 \n\t" //d1 = (int) d0;
"vcvt.f32.s32 d2, d1 \n\t" //d2 = (float) d1;
"vsub.f32 d0, d0, d2 \n\t" //d0 = d0 - d2;
"vstr.i32 s2, [r1] \n\t" //[r0] = d1[0]
"vmov.f32 r0, s0 \n\t" //r0 = d0[0];
::: "d0", "d1", "d2"
);
#else
return modf_c(x, i);
#endif
}
-439
View File
@@ -1,439 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef __MATH_NEON_H__
#define __MATH_NEON_H__
#if !defined(__i386__) && defined(__arm__)
//if defined neon ASM routines are used, otherwise all calls to *_neon
//functions are rerouted to their equivalent *_c function.
#define __MATH_NEON
//Default Floating Point value ABI: 0=softfp, 1=hardfp. Only effects *_neon routines.
//You can access the hardfp versions directly via the *_hard suffix.
//You can access the softfp versions directly via the *_soft suffix.
#define __MATH_FPABI 1
#endif
#ifdef GCC
#define ALIGN(A) __attribute__ ((aligned (A))
#else
#define ALIGN(A)
#endif
#ifndef _MATH_H
#define M_PI 3.14159265358979323846 /* pi */
#define M_PI_2 1.57079632679489661923 /* pi/2 */
#define M_PI_4 0.78539816339744830962 /* pi/4 */
#define M_E 2.7182818284590452354 /* e */
#define M_LOG2E 1.4426950408889634074 /* log_2 e */
#define M_LOG10E 0.43429448190325182765 /* log_10 e */
#define M_LN2 0.69314718055994530942 /* log_e 2 */
#define M_LN10 2.30258509299404568402 /* log_e 10 */
#define M_1_PI 0.31830988618379067154 /* 1/pi */
#define M_2_PI 0.63661977236758134308 /* 2/pi */
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
#endif
#if __MATH_FPABI == 1
#define sinf_neon sinf_neon_hfp
#define cosf_neon cosf_neon_hfp
#define sincosf_neon sincosf_neon_hfp
#define tanf_neon tanf_neon_hfp
#define atanf_neon atanf_neon_hfp
#define atan2f_neon atan2f_neon_hfp
#define asinf_neon asinf_neon_hfp
#define acosf_neon acosf_neon_hfp
#define sinhf_neon sinhf_neon_hfp
#define coshf_neon coshf_neon_hfp
#define tanhf_neon tanhf_neon_hfp
#define expf_neon expf_neon_hfp
#define logf_neon logf_neon_hfp
#define log10f_neon log10f_neon_hfp
#define powf_neon powf_neon_hfp
#define floorf_neon floorf_neon_hfp
#define ceilf_neon ceilf_neon_hfp
#define fabsf_neon fabsf_neon_hfp
#define ldexpf_neon ldexpf_neon_hfp
#define frexpf_neon frexpf_neon_hfp
#define fmodf_neon fmodf_neon_hfp
#define modf_neon modf_neon_hfp
#define sqrtf_neon sqrtf_neon_hfp
#define invsqrtf_neon invsqrtf_neon_hfp
#define dot2_neon dot2_neon_hfp
#define dot3_neon dot3_neon_hfp
#define dot4_neon dot4_neon_hfp
#else
#define sinf_neon sinf_neon_sfp
#define cosf_neon cosf_neon_sfp
#define sincosf_neon sincosf_neon_sfp
#define tanf_neon tanf_neon_sfp
#define atanf_neon atanf_neon_sfp
#define atan2f_neon atan2f_neon_sfp
#define asinf_neon asinf_neon_sfp
#define acosf_neon acosf_neon_sfp
#define sinhf_neon sinhf_neon_sfp
#define coshf_neon coshf_neon_sfp
#define tanhf_neon tanhf_neon_sfp
#define expf_neon expf_neon_sfp
#define logf_neon logf_neon_sfp
#define log10f_neon log10f_neon_sfp
#define powf_neon powf_neon_sfp
#define floorf_neon floorf_neon_sfp
#define ceilf_neon ceilf_neon_sfp
#define fabsf_neon fabsf_neon_sfp
#define ldexpf_neon ldexpf_neon_sfp
#define frexpf_neon frexpf_neon_sfp
#define fmodf_neon fmodf_neon_sfp
#define modf_neon modf_neon_sfp
#define sqrtf_neon sqrtf_neon_sfp
#define invsqrtf_neon invsqrtf_neon_sfp
#define dot2_neon dot2_neon_sfp
#define dot3_neon dot3_neon_sfp
#define dot4_neon dot4_neon_sfp
#endif
/*
function: enable_runfast
this function enables the floating point runfast mode on the
ARM Cortex A8.
*/
void enable_runfast();
float dot2_c(float v0[2], float v1[2]);
float dot2_neon(float v0[2], float v1[2]);
float dot3_c(float v0[3], float v1[3]);
float dot3_neon(float v0[3], float v1[3]);
float dot4_c(float v0[4], float v1[4]);
float dot4_neon(float v0[4], float v1[4]);
void cross3_c(float v0[3], float v1[3], float d[3]);
void cross3_neon(float v0[3], float v1[3], float d[3]);
void normalize2_c(float v[2], float d[2]);
void normalize2_neon(float v[2], float d[2]);
void normalize3_c(float v[3], float d[3]);
void normalize3_neon(float v[3], float d[3]);
void normalize4_c(float v[4], float d[4]);
void normalize4_neon(float v[4], float d[4]);
/*
function: matmul2
arguments: m0 2x2 matrix, m1 2x2 matrix
return: d 2x2 matrix
expression: d = m0 * m1
*/
void matmul2_c(float m0[4], float m1[4], float d[4]);
void matmul2_neon(float m0[4], float m1[4], float d[4]);
/*
function: matmul3
arguments: m0 3x3 matrix, m1 3x3 matrix
return: d 3x3 matrix
expression: d = m0 * m1
*/
void matmul3_c(float m0[9], float m1[9], float d[9]);
void matmul3_neon(float m0[9], float m1[9], float d[9]);
/*
function: matmul4
arguments: m0 4x4 matrix, m1 4x4 matrix
return: d 4x4 matrix
expression: d = m0 * m1
*/
void matmul4_c(float m0[16], float m1[16], float d[16]);
void matmul4_neon(float m0[16], float m1[16], float d[16]);
/*
function: matvec2
arguments: m 2x2 matrix, v 2 element vector
return: d 2x2 matrix
expression: d = m * v
*/
void matvec2_c(float m[4], float v[2], float d[2]);
void matvec2_neon(float m[4], float v[2], float d[2]);
/*
function: matvec3
arguments: m 3x3 matrix, v 3 element vector
return: d 3x3 matrix
expression: d = m * v
*/
void matvec3_c(float m[9], float v[3], float d[3]);
void matvec3_neon(float m[9], float v[3], float d[3]);
/*
function: matvec4
arguments: m 4x4 matrix, v 4 element vector
return: d 4x4 matrix
expression: d = m * v
*/
void matvec4_c(float m[16], float v[4], float d[4]);
void matvec4_neon(float m[16], float v[4], float d[4]);
/*
function: sinf
arguments: x radians
return: the sine function evaluated at x radians.
expression: r = sin(x)
*/
float sinf_c(float x);
float sinf_neon_hfp(float x);
float sinf_neon_sfp(float x);
/*
function: cosf
arguments: x radians
return: the cosine function evaluated at x radians.
expression: r = cos(x)
notes: computed using cos(x) = sin(x + pi/2)
*/
float cosf_c(float x);
float cosf_neon_hfp(float x);
float cosf_neon_sfp(float x);
/*
function: sincosf
arguments: x radians, r[2] result array.
return: both the sine and the cosine evaluated at x radians.
expression: r = {sin(x), cos(x)}
notes: faster than evaluating seperately.
*/
void sincosf_c(float x, float r[2]);
void sincosf_neon_hfp(float x, float r[2]);
void sincosf_neon_sfp(float x, float r[2]);
/*
function: sinfv
return: the sine function evaluated at x[i] radians
expression: r[i] = sin(x[i])
notes: faster than evaluating individually.
r and x can be the same memory location.
*/
void sinfv_c(float *x, int n, float *r);
void sinfv_neon(float *x, int n, float *r);
/*
function: tanf
return: the tangent evaluated at x radians.
expression: r = tan(x)
notes: computed using tan(x) = sin(x) / cos(x)
*/
float tanf_c(float x);
float tanf_neon_hfp(float x);
float tanf_neon_sfp(float x);
/*
function: atanf
return: the arctangent evaluated at x.
expression: r = atan(x)
*/
float atanf_c(float x);
float atanf_neon_hfp(float x);
float atanf_neon_sfp(float x);
/*
function: atanf
return: the arctangent evaluated at x.
expression: r = atan(x)
*/
float atan2f_c(float y, float x);
float atan2f_neon_hfp(float y, float x);
float atan2f_neon_sfp(float y, float x);
/*
function: asinf
return: the arcsine evaluated at x.
expression: r = asin(x)
*/
float asinf_c(float x);
float asinf_neon_hfp(float x);
float asinf_neon_sfp(float x);
/*
function: acosf
return: the arcsine evaluated at x.
expression: r = asin(x)
*/
float acosf_c(float x);
float acosf_neon_hfp(float x);
float acosf_neon_sfp(float x);
/*
function: sinhf
return: the arcsine evaluated at x.
expression: r = asin(x)
*/
float sinhf_c(float x);
float sinhf_neon_hfp(float x);
float sinhf_neon_sfp(float x);
/*
function: coshf
return: the arcsine evaluated at x.
expression: r = asin(x)
*/
float coshf_c(float x);
float coshf_neon_hfp(float x);
float coshf_neon_sfp(float x);
/*
function: tanhf
return: the arcsine evaluated at x.
expression: r = asin(x)
*/
float tanhf_c(float x);
float tanhf_neon_hfp(float x);
float tanhf_neon_sfp(float x);
/*
function: expf
return: the natural exponential evaluated at x.
expression: r = e ** x
*/
float expf_c(float x);
float expf_neon_hfp(float x);
float expf_neon_sfp(float x);
/*
function: logf
return: the value of the natural logarithm of x.
expression: r = ln(x)
notes: assumes x > 0
*/
float logf_c(float x);
float logf_neon_hfp(float x);
float logf_neon_sfp(float x);
/*
function: log10f
return: the value of the power 10 logarithm of x.
expression: r = log10(x)
notes: assumes x > 0
*/
float log10f_c(float x);
float log10f_neon_hfp(float x);
float log10f_neon_sfp(float x);
/*
function: powf
return: x raised to the power of n, x ** n.
expression: r = x ** y
notes: computed using e ** (y * ln(x))
*/
float powf_c(float x, float n);
float powf_neon_sfp(float x, float n);
float powf_neon_hfp(float x, float n);
/*
function: floorf
return: x rounded down (towards negative infinity) to its nearest
integer value.
notes: assumes |x| < 2 ** 31
*/
float floorf_c(float x);
float floorf_neon_sfp(float x);
float floorf_neon_hfp(float x);
/*
function: ceilf
return: x rounded up (towards positive infinity) to its nearest
integer value.
notes: assumes |x| < 2 ** 31
*/
float ceilf_c(float x);
float ceilf_neon_hfp(float x);
float ceilf_neon_sfp(float x);
/*
function: fabsf
return: absolute vvalue of x
notes: assumes |x| < 2 ** 31
*/
float fabsf_c(float x);
float fabsf_neon_hfp(float x);
float fabsf_neon_sfp(float x);
/*
function: ldexpf
return: the value of m multiplied by 2 to the power of e.
expression: r = m * (2 ** e)
*/
float ldexpf_c(float m, int e);
float ldexpf_neon_hfp(float m, int e);
float ldexpf_neon_sfp(float m, int e);
/*
function: frexpf
return: the exponent and mantissa of x
*/
float frexpf_c(float x, int *e);
float frexpf_neon_hfp(float x, int *e);
float frexpf_neon_sfp(float x, int *e);
/*
function: fmodf
return: the remainder of x divided by y, x % y
expression: r = x - floor(x / y) * y;
notes: assumes that |x / y| < 2 ** 31
*/
float fmodf_c(float x, float y);
float fmodf_neon_hfp(float x, float y);
float fmodf_neon_sfp(float x, float y);
/*
function: modf
return: breaks x into the integer (i) and fractional part (return)
notes: assumes that |x| < 2 ** 31
*/
float modf_c(float x, int *i);
float modf_neon_hfp(float x, int *i);
float modf_neon_sfp(float x, int *i);
/*
function: sqrtf
return: (x^0.5)
notes:
*/
float sqrtf_c(float x);
float sqrtf_neon_hfp(float x);
float sqrtf_neon_sfp(float x);
/*
function: invsqrtf
return: 1.0f / (x^0.5)
notes:
*/
float invsqrtf_c(float x);
float invsqrtf_neon_hfp(float x);
float invsqrtf_neon_sfp(float x);
#endif
-182
View File
@@ -1,182 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Based on x ^ n = exp(n * log(x))
Test func : powf(x, n)
Test Range: (1,1) < (x, n) < (10, 10)
Peak Error: ~0.0010%
RMS Error: ~0.0002%
*/
#include "math.h"
#include "math_neon.h"
const float __powf_rng[2] = {
1.442695041f,
0.693147180f
};
const float __powf_lut[16] = {
-2.295614848256274, //p0 log
-2.470711633419806, //p4
-5.686926051100417, //p2
-0.165253547131978, //p6
+5.175912446351073, //p1
+0.844006986174912, //p5
+4.584458825456749, //p3
+0.014127821926000, //p7
0.9999999916728642, //p0 exp
0.04165989275009526, //p4
0.5000006143673624, //p2
0.0014122663401803872, //p6
1.000000059694879, //p1
0.008336936973260111, //p5
0.16666570253074878, //p3
0.00019578093328483123 //p7
};
float powf_c(float x, float n)
{
float a, b, c, d, xx;
int m;
union {
float f;
int i;
} r;
//extract exponent
r.f = x;
m = (r.i >> 23);
m = m - 127;
r.i = r.i - (m << 23);
//Taylor Polynomial (Estrins)
xx = r.f * r.f;
a = (__powf_lut[4] * r.f) + (__powf_lut[0]);
b = (__powf_lut[6] * r.f) + (__powf_lut[2]);
c = (__powf_lut[5] * r.f) + (__powf_lut[1]);
d = (__powf_lut[7] * r.f) + (__powf_lut[3]);
a = a + b * xx;
c = c + d * xx;
xx = xx * xx;
r.f = a + c * xx;
//add exponent
r.f = r.f + ((float) m) * __powf_rng[1];
r.f = r.f * n;
//Range Reduction:
m = (int) (r.f * __powf_rng[0]);
r.f = r.f - ((float) m) * __powf_rng[1];
//Taylor Polynomial (Estrins)
a = (__powf_lut[12] * r.f) + (__powf_lut[8]);
b = (__powf_lut[14] * r.f) + (__powf_lut[10]);
c = (__powf_lut[13] * r.f) + (__powf_lut[9]);
d = (__powf_lut[15] * r.f) + (__powf_lut[11]);
xx = r.f * r.f;
a = a + b * xx;
c = c + d * xx;
xx = xx* xx;
r.f = a + c * xx;
//multiply by 2 ^ m
m = m << 23;
r.i = r.i + m;
return r.f;
}
float powf_neon_hfp(float x, float n)
{
#ifdef __MATH_NEON
asm volatile (
"vdup.f32 d16, d0[1] \n\t" //d16 = {y,y};
"vdup.f32 d0, d0[0] \n\t" //d0 = {x,x};
//extract exponent
"vmov.i32 d2, #127 \n\t" //d2 = 127;
"vshr.u32 d6, d0, #23 \n\t" //d6 = d0 >> 23;
"vsub.i32 d6, d6, d2 \n\t" //d6 = d6 - d2;
"vshl.u32 d1, d6, #23 \n\t" //d1 = d6 << 23;
"vsub.i32 d0, d0, d1 \n\t" //d0 = d0 + d1;
//polynomial:
"vmul.f32 d1, d0, d0 \n\t" //d1 = d0*d0 = {x^2, x^2}
"vld1.32 {d2, d3, d4, d5}, [%1]! \n\t" //q1 = {p0, p4, p2, p6}, q2 = {p1, p5, p3, p7} ;
"vmla.f32 q1, q2, d0[0] \n\t" //q1 = q1 + q2 * d0[0]
"vmla.f32 d2, d3, d1[0] \n\t" //d2 = d2 + d3 * d1[0]
"vmul.f32 d1, d1, d1 \n\t" //d1 = d1 * d1 = {x^4, x^4}
"vmla.f32 d2, d1, d2[1] \n\t" //d2 = d2 + d1 * d2[1]
//add exponent
"vld1.32 d7, [%0] \n\t" //d7 = {invrange, range}
"vcvt.f32.s32 d6, d6 \n\t" //d6 = (float) d6
"vmla.f32 d2, d6, d7[1] \n\t" //d2 = d2 + d6 * d7[1]
"vdup.f32 d0, d2[0] \n\t" //d0 = d2[0]
"vmul.f32 d0, d0, d16 \n\t" //d0 = d0 * d16
//Range Reduction:
"vmul.f32 d6, d0, d7[0] \n\t" //d6 = d0 * d7[0]
"vcvt.u32.f32 d6, d6 \n\t" //d6 = (int) d6
"vcvt.f32.u32 d1, d6 \n\t" //d1 = (float) d6
"vmls.f32 d0, d1, d7[1] \n\t" //d0 = d0 - d1 * d7[1]
//polynomial:
"vmul.f32 d1, d0, d0 \n\t" //d1 = d0*d0 = {x^2, x^2}
"vld1.32 {d2, d3, d4, d5}, [%1] \n\t" //q1 = {p0, p4, p2, p6}, q2 = {p1, p5, p3, p7} ;
"vmla.f32 q1, q2, d0[0] \n\t" //q1 = q1 + q2 * d0[0]
"vmla.f32 d2, d3, d1[0] \n\t" //d2 = d2 + d3 * d1[0]
"vmul.f32 d1, d1, d1 \n\t" //d1 = d1 * d1 = {x^4, x^4}
"vmla.f32 d2, d1, d2[1] \n\t" //d2 = d2 + d1 * d2[1]
//multiply by 2 ^ m
"vshl.i32 d6, d6, #23 \n\t" //d6 = d6 << 23
"vadd.i32 d0, d2, d6 \n\t" //d0 = d2 + d6
:: "r"(__powf_rng), "r"(__powf_lut)
: "d0", "d1", "d2","d3", "d4", "d5", "d6", "d7"
);
#endif
}
float powf_neon_sfp(float x, float n)
{
#ifdef __MATH_NEON
asm volatile ("vmov.f32 s0, r0 \n\t");
asm volatile ("vmov.f32 s1, r1 \n\t");
powf_neon_hfp(x, n);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return powf_c(x, n);
#endif
};
-42
View File
@@ -1,42 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
void
enable_runfast()
{
#ifdef __arm__
static const unsigned int x = 0x04086060;
static const unsigned int y = 0x03000000;
int r;
asm volatile (
"fmrx %0, fpscr \n\t" //r0 = FPSCR
"and %0, %0, %1 \n\t" //r0 = r0 & 0x04086060
"orr %0, %0, %2 \n\t" //r0 = r0 | 0x03000000
"fmxr fpscr, %0 \n\t" //FPSCR = r0
: "=r"(r)
: "r"(x), "r"(y)
);
#endif
}
-163
View File
@@ -1,163 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "math.h"
#include "math_neon.h"
const float __sincosf_rng[2] = {
2.0 / M_PI,
M_PI / 2.0
};
const float __sincosf_lut[8] = {
-0.00018365f, //p7
-0.00018365f, //p7
+0.00830636f, //p5
+0.00830636f, //p5
-0.16664831f, //p3
-0.16664831f, //p3
+0.99999661f, //p1
+0.99999661f, //p1
};
void sincosf_c( float x, float r[2])
{
union {
float f;
int i;
} ax, bx;
float xx, yy;
int m, n, o, p;
float y = x + __sincosf_rng[1];
ax.f = fabsf(x);
bx.f = fabsf(y);
//Range Reduction:
m = (int) (ax.f * __sincosf_rng[0]);
o = (int) (bx.f * __sincosf_rng[0]);
ax.f = ax.f - (((float)m) * __sincosf_rng[1]);
bx.f = bx.f - (((float)o) * __sincosf_rng[1]);
//Test Quadrant
n = m & 1;
p = o & 1;
ax.f = ax.f - n * __sincosf_rng[1];
bx.f = bx.f - p * __sincosf_rng[1];
m = m >> 1;
o = o >> 1;
n = n ^ m;
p = p ^ o;
m = (x < 0.0);
o = (y < 0.0);
n = n ^ m;
p = p ^ o;
n = n << 31;
p = p << 31;
ax.i = ax.i ^ n;
bx.i = bx.i ^ p;
//Taylor Polynomial
xx = ax.f * ax.f;
yy = bx.f * bx.f;
r[0] = __sincosf_lut[0];
r[1] = __sincosf_lut[1];
r[0] = r[0] * xx + __sincosf_lut[2];
r[1] = r[1] * yy + __sincosf_lut[3];
r[0] = r[0] * xx + __sincosf_lut[4];
r[1] = r[1] * yy + __sincosf_lut[5];
r[0] = r[0] * xx + __sincosf_lut[6];
r[1] = r[1] * yy + __sincosf_lut[7];
r[0] = r[0] * ax.f;
r[1] = r[1] * bx.f;
}
void sincosf_neon_hfp(float x, float r[2])
{
//HACK: Assumes for softfp that r1 = x, and for hardfp that s0 = x.
#ifdef __MATH_NEON
asm volatile (
//{x, y} = {x, x + pi/2}
"vdup.f32 d1, d0[0] \n\t" //d1 = {x, x}
"vld1.32 d3, [%1] \n\t" //d3 = {invrange, range}
"vadd.f32 d0, d1, d3 \n\t" //d0 = d1 + d3
"vmov.f32 s0, s2 \n\t" //d0[0] = d1[0]
"vabs.f32 d1, d0 \n\t" //d1 = {abs(x), abs(y)}
//Range Reduction:
"vmul.f32 d2, d1, d3[0] \n\t" //d2 = d1 * d3[0]
"vcvt.u32.f32 d2, d2 \n\t" //d2 = (int) d2
"vcvt.f32.u32 d4, d2 \n\t" //d4 = (float) d2
"vmls.f32 d1, d4, d3[1] \n\t" //d1 = d1 - d4 * d3[1]
//Checking Quadrant:
//ax = ax - (k&1) * M_PI_2
"vmov.i32 d4, #1 \n\t" //d4 = 1
"vand.i32 d4, d4, d2 \n\t" //d4 = d4 & d2
"vcvt.f32.u32 d5, d4 \n\t" //d5 = (float) d4
"vmls.f32 d1, d5, d3[1] \n\t" //d1 = d1 - d5 * d3[1]
//ax = ax ^ ((k & 1) ^ (k >> 1) ^ (x < 0) << 31)
"vshr.u32 d3, d2, #1 \n\t" //d3 = d2 >> 1
"veor.i32 d4, d4, d3 \n\t" //d4 = d4 ^ d3
"vclt.f32 d3, d0, #0 \n\t" //d3 = (d0 < 0.0)
"veor.i32 d4, d4, d3 \n\t" //d4 = d4 ^ d3
"vshl.i32 d4, d4, #31 \n\t" //d4 = d4 << 31
"veor.i32 d0, d1, d4 \n\t" //d0 = d1 ^ d4
//polynomial:
"vldm %2!, {d2, d3} \n\t" //d2 = {p7, p7}, d3 = {p5, p5}, r3 += 4;
"vmul.f32 d1, d0, d0 \n\t" //d1 = d0 * d0 = {x^2, y^2}
"vldm %2!, {d4} \n\t" //d4 = {p3, p3}, r3 += 2;
"vmla.f32 d3, d2, d1 \n\t" //d3 = d3 + d2 * d1;
"vldm %2!, {d5} \n\t" //d5 = {p1, p1}, r3 += 2;
"vmla.f32 d4, d3, d1 \n\t" //d4 = d4 + d3 * d1;
"vmla.f32 d5, d4, d1 \n\t" //d5 = d5 + d4 * d1;
"vmul.f32 d5, d5, d0 \n\t" //d5 = d5 * d0;
"vstm.f32 %0, {d5} \n\t" //r[0] = d5[0], r[1]=d5[1];
: "+r"(r)
: "r"(__sincosf_rng), "r"(__sincosf_lut)
: "d0", "d1", "d2", "d3", "d4", "d5"
);
#else
sincosf_c(x, r);
#endif
}
void sincosf_neon_sfp(float x, float r[2])
{
#ifdef __MATH_NEON
asm volatile ("vdup.f32 d0, r0 \n\t");
sincosf_neon_hfp(x, r);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
sincosf_c(x, r);
#endif
};
-128
View File
@@ -1,128 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <math.h>
#include "math_neon.h"
static const float __sinf_rng[2] = {
2.0 / M_PI,
M_PI / 2.0
} ALIGN(16);
static const float __sinf_lut[4] = {
-0.00018365f, //p7
-0.16664831f, //p3
+0.00830636f, //p5
+0.99999661f, //p1
} ALIGN(16);
float sinf_c(float x)
{
union {
float f;
int i;
} ax;
float r, a, b, xx;
int m, n;
ax.f = fabsf(x);
//Range Reduction:
m = (int) (ax.f * __sinf_rng[0]);
ax.f = ax.f - (((float)m) * __sinf_rng[1]);
//Test Quadrant
n = m & 1;
ax.f = ax.f - n * __sinf_rng[1];
m = m >> 1;
n = n ^ m;
m = (x < 0.0);
n = n ^ m;
n = n << 31;
ax.i = ax.i ^ n;
//Taylor Polynomial (Estrins)
xx = ax.f * ax.f;
a = (__sinf_lut[0] * ax.f) * xx + (__sinf_lut[2] * ax.f);
b = (__sinf_lut[1] * ax.f) * xx + (__sinf_lut[3] * ax.f);
xx = xx * xx;
r = b + a * xx;
return r;
}
float sinf_neon_hfp(float x)
{
#ifdef __MATH_NEON
asm volatile (
"vld1.32 d3, [%0] \n\t" //d3 = {invrange, range}
"vdup.f32 d0, d0[0] \n\t" //d0 = {x, x}
"vabs.f32 d1, d0 \n\t" //d1 = {ax, ax}
"vmul.f32 d2, d1, d3[0] \n\t" //d2 = d1 * d3[0]
"vcvt.u32.f32 d2, d2 \n\t" //d2 = (int) d2
"vmov.i32 d5, #1 \n\t" //d5 = 1
"vcvt.f32.u32 d4, d2 \n\t" //d4 = (float) d2
"vshr.u32 d7, d2, #1 \n\t" //d7 = d2 >> 1
"vmls.f32 d1, d4, d3[1] \n\t" //d1 = d1 - d4 * d3[1]
"vand.i32 d5, d2, d5 \n\t" //d5 = d2 & d5
"vclt.f32 d18, d0, #0 \n\t" //d18 = (d0 < 0.0)
"vcvt.f32.u32 d6, d5 \n\t" //d6 = (float) d5
"vmls.f32 d1, d6, d3[1] \n\t" //d1 = d1 - d6 * d3[1]
"veor.i32 d5, d5, d7 \n\t" //d5 = d5 ^ d7
"vmul.f32 d2, d1, d1 \n\t" //d2 = d1*d1 = {x^2, x^2}
"vld1.32 {d16, d17}, [%1] \n\t" //q8 = {p7, p3, p5, p1}
"veor.i32 d5, d5, d18 \n\t" //d5 = d5 ^ d18
"vshl.i32 d5, d5, #31 \n\t" //d5 = d5 << 31
"veor.i32 d1, d1, d5 \n\t" //d1 = d1 ^ d5
"vmul.f32 d3, d2, d2 \n\t" //d3 = d2*d2 = {x^4, x^4}
"vmul.f32 q0, q8, d1[0] \n\t" //q0 = q8 * d1[0] = {p7x, p3x, p5x, p1x}
"vmla.f32 d1, d0, d2[0] \n\t" //d1 = d1 + d0*d2 = {p5x + p7x^3, p1x + p3x^3}
"vmla.f32 d1, d3, d1[0] \n\t" //d1 = d1 + d3*d0 = {...., p1x + p3x^3 + p5x^5 + p7x^7}
"vmov.f32 s0, s3 \n\t" //s0 = s3
:
: "r"(__sinf_rng), "r"(__sinf_lut)
: "q0", "q1", "q2", "q3", "q8", "q9"
);
#endif
}
float sinf_neon_sfp(float x)
{
#ifdef __MATH_NEON
asm volatile ("vdup.f32 d0, r0 \n\t");
sinf_neon_hfp(x);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return sinf_c(x);
#endif
};
-110
View File
@@ -1,110 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "math.h"
#include "math_neon.h"
const float __sinfv_rng[2] = {
2.0 / M_PI,
M_PI / 2.0,
};
const float __sinfv_lut[4] = {
-0.00018365f, //p7
-0.16664831f, //p3
+0.00830636f, //p5
+0.99999661f, //p1
};
void sinfv_c(float *x, int n, float *r)
{
union {
float f;
int i;
} ax, bx;
float aa, ab, ba, bb, axx, bxx;
int am, bm, an, bn;
if (n & 0x1) {
*r++ = sinf_c(*x++);
n--;
}
float rng0 = __sinfv_rng[0];
float rng1 = __sinfv_rng[1];
while(n > 0){
float x0 = *x++;
float x1 = *x++;
ax.f = fabsf(x0);
bx.f = fabsf(x1);
//Range Reduction:
am = (int) (ax.f * rng0);
bm = (int) (bx.f * rng0);
ax.f = ax.f - (((float)am) * rng1);
bx.f = bx.f - (((float)bm) * rng1);
//Test Quadrant
an = am & 1;
bn = bm & 1;
ax.f = ax.f - an * rng1;
bx.f = bx.f - bn * rng1;
am = (am & 2) >> 1;
bm = (bm & 2) >> 1;
ax.i = ax.i ^ ((an ^ am ^ (x0 < 0)) << 31);
bx.i = bx.i ^ ((bn ^ bm ^ (x1 < 0)) << 31);
//Taylor Polynomial (Estrins)
axx = ax.f * ax.f;
bxx = bx.f * bx.f;
aa = (__sinfv_lut[0] * ax.f) * axx + (__sinfv_lut[2] * ax.f);
ba = (__sinfv_lut[0] * bx.f) * bxx + (__sinfv_lut[2] * bx.f);
ab = (__sinfv_lut[1] * ax.f) * axx + (__sinfv_lut[3] * ax.f);
bb = (__sinfv_lut[1] * bx.f) * bxx + (__sinfv_lut[3] * bx.f);
axx = axx * axx;
bxx = bxx * bxx;
*r++ = ab + aa * axx;
*r++ = bb + ba * bxx;
n -= 2;
}
}
void sinfv_neon(float *x, int n, float *r)
{
#ifdef __MATH_NEON
asm volatile (""
:
:"r"(x), "r"(n)
);
#else
sinfv_c(x, n, r);
#endif
}
-120
View File
@@ -1,120 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "math.h"
#include "math_neon.h"
const float __sinhf_rng[2] = {
1.442695041f,
0.693147180f
};
const float __sinhf_lut[16] = {
0.00019578093328483123, //p7
0.00019578093328483123, //p7
0.0014122663401803872, //p6
0.0014122663401803872, //p6
0.008336936973260111, //p5
0.008336936973260111, //p5
0.04165989275009526, //p4
0.04165989275009526, //p4
0.16666570253074878, //p3
0.16666570253074878, //p3
0.5000006143673624, //p2
0.5000006143673624, //p2
1.000000059694879, //p1
1.000000059694879, //p1
0.9999999916728642, //p0
0.9999999916728642 //p0
};
float sinhf_c(float x)
{
float a, b, xx;
xx = -x;
a = expf_c(x);
b = expf_c(xx);
a = a - b;
a = a * 0.5f;
return a;
}
float sinhf_neon_hfp(float x)
{
#ifdef __MATH_NEON
asm volatile (
"vdup.f32 d0, d0[0] \n\t" //d0 = {x, x}
"fnegs s1, s1 \n\t" //s1 = -s1
//Range Reduction:
"vld1.32 d2, [%0] \n\t" //d2 = {invrange, range}
"vld1.32 {d16, d17}, [%1]! \n\t"
"vmul.f32 d6, d0, d2[0] \n\t" //d6 = d0 * d2[0]
"vcvt.s32.f32 d6, d6 \n\t" //d6 = (int) d6
"vld1.32 {d18}, [%1]! \n\t"
"vcvt.f32.s32 d1, d6 \n\t" //d1 = (float) d6
"vld1.32 {d19}, [%1]! \n\t"
"vmls.f32 d0, d1, d2[1] \n\t" //d0 = d0 - d1 * d2[1]
"vld1.32 {d20}, [%1]! \n\t"
//polynomial:
"vmla.f32 d17, d16, d0 \n\t" //d17 = d17 + d16 * d0;
"vld1.32 {d21}, [%1]! \n\t"
"vmla.f32 d18, d17, d0 \n\t" //d18 = d18 + d17 * d0;
"vld1.32 {d22}, [%1]! \n\t"
"vmla.f32 d19, d18, d0 \n\t" //d19 = d19 + d18 * d0;
"vld1.32 {d23}, [%1]! \n\t"
"vmla.f32 d20, d19, d0 \n\t" //d20 = d20 + d19 * d0;
"vmla.f32 d21, d20, d0 \n\t" //d21 = d21 + d20 * d0;
"vmla.f32 d22, d21, d0 \n\t" //d22 = d22 + d21 * d0;
"vmla.f32 d23, d22, d0 \n\t" //d23 = d23 + d22 * d0;
//multiply by 2 ^ m
"vshl.i32 d6, d6, #23 \n\t" //d6 = d6 << 23
"vadd.i32 d0, d23, d6 \n\t" //d0 = d22 + d6
"vdup.f32 d2, d0[1] \n\t" //d2 = s1
"vmov.f32 d1, #0.5 \n\t" //d1 = 0.5
"vsub.f32 d0, d0, d2 \n\t" //d0 = d0 - d2
"vmul.f32 d0, d1 \n\t" //d0 = d0 * d1
:: "r"(__sinhf_rng), "r"(__sinhf_lut)
: "d0", "d1", "q1", "q2", "d6"
);
#endif
}
float sinhf_neon_sfp(float x)
{
#ifdef __MATH_NEON
asm volatile ("vmov.f32 s0, r0 \n\t");
sinhf_neon_hfp(x);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return sinhf_c(x);
#endif
};
-105
View File
@@ -1,105 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Test func : sqrtf(x)
Test Range: 0 < x < 1,000,000,000
Peak Error: ~0.0010%
RMS Error: ~0.0005%
*/
#include "math.h"
#include "math_neon.h"
float sqrtf_c(float x)
{
float b, c;
int m;
union {
float f;
int i;
} a;
//fast invsqrt approx
a.f = x;
a.i = 0x5F3759DF - (a.i >> 1); //VRSQRTE
c = x * a.f;
b = (3.0f - c * a.f) * 0.5; //VRSQRTS
a.f = a.f * b;
c = x * a.f;
b = (3.0f - c * a.f) * 0.5;
a.f = a.f * b;
//fast inverse approx
x = a.f;
m = 0x3F800000 - (a.i & 0x7F800000);
a.i = a.i + m;
a.f = 1.41176471f - 0.47058824f * a.f;
a.i = a.i + m;
b = 2.0 - a.f * x;
a.f = a.f * b;
b = 2.0 - a.f * x;
a.f = a.f * b;
return a.f;
}
float sqrtf_neon_hfp(float x)
{
#ifdef __MATH_NEON
asm volatile (
//fast invsqrt approx
"vmov.f32 d1, d0 \n\t" //d1 = d0
"vrsqrte.f32 d0, d0 \n\t" //d0 = ~ 1.0 / sqrt(d0)
"vmul.f32 d2, d0, d1 \n\t" //d2 = d0 * d1
"vrsqrts.f32 d3, d2, d0 \n\t" //d3 = (3 - d0 * d2) / 2
"vmul.f32 d0, d0, d3 \n\t" //d0 = d0 * d3
"vmul.f32 d2, d0, d1 \n\t" //d2 = d0 * d1
"vrsqrts.f32 d3, d2, d0 \n\t" //d4 = (3 - d0 * d3) / 2
"vmul.f32 d0, d0, d3 \n\t" //d0 = d0 * d3
//fast reciporical approximation
"vrecpe.f32 d1, d0 \n\t" //d1 = ~ 1 / d0;
"vrecps.f32 d2, d1, d0 \n\t" //d2 = 2.0 - d1 * d0;
"vmul.f32 d1, d1, d2 \n\t" //d1 = d1 * d2;
"vrecps.f32 d2, d1, d0 \n\t" //d2 = 2.0 - d1 * d0;
"vmul.f32 d0, d1, d2 \n\t" //d0 = d1 * d2;
::: "d0", "d1", "d2", "d3"
);
#endif
}
float sqrtf_neon_sfp(float x)
{
#ifdef __MATH_NEON
asm volatile ("vmov.f32 s0, r0 \n\t");
sqrtf_neon_hfp(x);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return sqrtf_c(x);
#endif
}
-147
View File
@@ -1,147 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Test func : sqrtf(x)
Test Range: 0 < x < 1,000,000,000
Peak Error: ~0.0010%
RMS Error: ~0.0005%
*/
#include "math.h"
#include "math_neon.h"
void sqrtfv_c(float *x, int n, float *r)
{
float x0, x1;
float b0, b1, c0, c1;
int m0, m1;
union {
float f;
int i;
} a0, a1;
if (n & 0x1){
*r++ = sqrtf_c(*x++);
n--;
}
while(n > 0){
x0 = *x++;
x1 = *x++;
//fast invsqrt approx
a0.f = x0;
a1.f = x1;
a0.i = 0x5F3759DF - (a0.i >> 1); //VRSQRTE
a1.i = 0x5F3759DF - (a1.i >> 1); //VRSQRTE
c0 = x0 * a0.f;
c1 = x1 * a1.f;
b0 = (3.0f - c0 * a0.f) * 0.5; //VRSQRTS
b1 = (3.0f - c1 * a1.f) * 0.5; //VRSQRTS
a0.f = a0.f * b0;
a1.f = a1.f * b1;
c0 = x0 * a0.f;
c1 = x1 * a1.f;
b0 = (3.0f - c0 * a0.f) * 0.5; //VRSQRTS
b1 = (3.0f - c1 * a1.f) * 0.5; //VRSQRTS
a0.f = a0.f * b0;
a1.f = a1.f * b1;
//fast inverse approx
c0 = a0.f;
c0 = a1.f;
m0 = 0x3F800000 - (a0.i & 0x7F800000);
m1 = 0x3F800000 - (a1.i & 0x7F800000);
a0.i = a0.i + m0;
a1.i = a1.i + m1;
a0.f = 1.41176471f - 0.47058824f * a0.f;
a1.f = 1.41176471f - 0.47058824f * a1.f;
a0.i = a0.i + m0;
a1.i = a1.i + m1;
b0 = 2.0 - a0.f * c0;
b1 = 2.0 - a1.f * c1;
a0.f = a0.f * b0;
a1.f = a1.f * b1;
b0 = 2.0 - a0.f * c0;
b1 = 2.0 - a1.f * c1;
a0.f = a0.f * b0;
a1.f = a1.f * b1;
*r++ = a0.f;
*r++ = a1.f;
n -= 2;
}
}
void sqrtfv_neon(float *x, int n, float *r)
{
#if 0
asm volatile (
"tst r1, #1 \n\t" //r1 & 1
"beq 1f \n\t" //
"vld1.32 d0[0], [r0]! \n\t" //s0 = *x++
"mov ip, lr \n\t" //ip = lr
//"bl sqrtf_neon_hfp \n\t" //sqrtf_neon
"mov lr, ip \n\t" //lr = ip
"vst1.32 d0[0], [r2]! \n\t" //*r++ = r0
"subs r1, r1, #1 \n\t" //r1 = r1 - 1;
"bxeq lr \n\t" //
"1: \n\t" //
"vld1.32 d0, [r0]! \n\t" //d0 = (*x[0], *x[1]), x+=2;
//fast invsqrt approx
"vmov.f32 d1, d0 \n\t" //d1 = d0
"vrsqrte.f32 d0, d0 \n\t" //d0 = ~ 1.0 / sqrt(d0)
"vmul.f32 d2, d0, d1 \n\t" //d3 = d0 * d2
"vrsqrts.f32 d3, d2, d0 \n\t" //d4 = (3 - d0 * d3) / 2
"vmul.f32 d0, d0, d3 \n\t" //d0 = d0 * d4
"vmul.f32 d2, d0, d1 \n\t" //d3 = d0 * d2
"vrsqrts.f32 d3, d2, d0 \n\t" //d4 = (3 - d0 * d3) / 2
"vmul.f32 d0, d0, d3 \n\t" //d0 = d0 * d4
//fast reciporical approximation
"vrecpe.f32 d1, d0 \n\t" //d1 = ~ 1 / d0;
"vrecps.f32 d2, d1, d0 \n\t" //d2 = 2.0 - d1 * d0;
"vmul.f32 d1, d1, d2 \n\t" //d1 = d1 * d2;
"vrecps.f32 d2, d1, d0 \n\t" //d2 = 2.0 - d1 * d0;
"vmul.f32 d0, d1, d2 \n\t" //d0 = d1 * d2;
"vst1.64 d0, [r2]! \n\t" //*r++ = d0;
"subs r1, r1, #2 \n\t" //n = n - 2; update flags
"bgt 1b \n\t" //
::: "d0", "d1", "d2", "d3"
);
#else
sqrtfv_c(x, n, r);
#endif
}
-156
View File
@@ -1,156 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "math.h"
#include "math_neon.h"
const float __tanf_rng[2] = {
2.0 / M_PI,
M_PI / 2.0
};
const float __tanf_lut[4] = {
-0.00018365f, //p7
-0.16664831f, //p3
+0.00830636f, //p5
+0.99999661f, //p1
};
float tanf_c(float x){
union {
float f;
int i;
} ax, c;
float r, a, b, xx, cc, cx;
int m;
ax.f = fabsf(x);
//Range Reduction:
m = (int) (ax.f * __tanf_rng[0]);
ax.f = ax.f - (((float)m) * __tanf_rng[1]);
//Test Quadrant
ax.f = ax.f - (m & 1) * __tanf_rng[1];
ax.i = ax.i ^ ((*(int*)&x) & 0x80000000);
//Taylor Polynomial (Estrins)
xx = ax.f * ax.f;
a = (__tanf_lut[0] * ax.f) * xx + (__tanf_lut[2] * ax.f);
b = (__tanf_lut[1] * ax.f) * xx + (__tanf_lut[3] * ax.f);
xx = xx * xx;
r = b + a * xx;
//cosine
c.f = 1.0 - r * r;
//fast invsqrt approximation (2x newton iterations)
cc = c.f;
c.i = 0x5F3759DF - (c.i >> 1); //VRSQRTE
cx = cc * c.f;
a = (3.0f - cx * c.f) / 2; //VRSQRTS
c.f = c.f * a;
cx = cc * c.f;
a = (3.0f - cx * c.f) / 2;
c.f = c.f * a;
r = r * c.f;
return r;
}
float tanf_neon_hfp(float x)
{
#ifdef __MATH_NEON
asm volatile (
"vdup.f32 d0, d0[0] \n\t" //d0 = {x, x}
"vabs.f32 d1, d0 \n\t" //d1 = {ax, ax}
//Range Reduction:
"vld1.32 d3, [%0] \n\t" //d3 = {invrange, range}
"vmul.f32 d2, d1, d3[0] \n\t" //d2 = d1 * d3[0]
"vcvt.u32.f32 d2, d2 \n\t" //d2 = (int) d2
"vcvt.f32.u32 d4, d2 \n\t" //d4 = (float) d2
"vmls.f32 d1, d4, d3[1] \n\t" //d1 = d1 - d4 * d3[1]
//Checking Quadrant:
//ax = ax - (k&1) * M_PI_2
"vmov.i32 d4, #1 \n\t" //d4 = 1
"vand.i32 d2, d2, d4 \n\t" //d2 = d2 & d4
"vcvt.f32.u32 d2, d2 \n\t" //d2 = (float) d2
"vmls.f32 d1, d2, d3[1] \n\t" //d1 = d1 - d2 * d3[1]
//ax = ax ^ ( x.i & 0x800000000)
"vmov.i32 d4, #0x80000000 \n\t" //d4 = 0x80000000
"vand.i32 d0, d0, d4 \n\t" //d0 = d0 & d4
"veor.i32 d1, d1, d0 \n\t" //d1 = d1 ^ d0
//polynomial:
"vmul.f32 d2, d1, d1 \n\t" //d2 = d1*d1 = {x^2, x^2}
"vld1.32 {d4, d5}, [%1] \n\t" //d4 = {p7, p3}, d5 = {p5, p1}
"vmul.f32 d3, d2, d2 \n\t" //d3 = d2*d2 = {x^4, x^4}
"vmul.f32 q0, q2, d1[0] \n\t" //q0 = q2 * d1[0] = {p7x, p3x, p5x, p1x}
"vmla.f32 d1, d0, d2[0] \n\t" //d1 = d1 + d0*d2 = {p5x + p7x^3, p1x + p3x^3}
"vmla.f32 d1, d3, d1[0] \n\t" //d1 = d1 + d3*d0 = {..., p1x + p3x^3 + p5x^5 + p7x^7}
//cosine
"vmov.f32 s1, #1.0 \n\t" //d0[1] = 1.0
"vmls.f32 d0, d1, d1 \n\t" //d0 = {..., 1.0 - sx*sx}
//invsqrt approx
"vmov.f32 d2, d0 \n\t" //d2 = d0
"vrsqrte.f32 d0, d0 \n\t" //d0 = ~ 1.0 / sqrt(d0)
"vmul.f32 d3, d0, d2 \n\t" //d3 = d0 * d2
"vrsqrts.f32 d4, d3, d0 \n\t" //d4 = (3 - d0 * d3) / 2
"vmul.f32 d0, d0, d4 \n\t" //d0 = d0 * d4
"vmul.f32 d3, d0, d2 \n\t" //d3 = d0 * d2
"vrsqrts.f32 d4, d3, d0 \n\t" //d4 = (3 - d0 * d3) / 2
"vmul.f32 d0, d0, d4 \n\t" //d0 = d0 * d4
"vmul.f32 d0, d0, d1 \n\t" //d0 = d0 * d1
"vmov.f32 s0, s1 \n\t" //s0 = s1
:: "r"(__tanf_rng), "r"(__tanf_lut)
: "d0", "d1", "d2", "d3", "d4", "d5"
);
#endif
}
float tanf_neon_sfp(float x)
{
#ifdef __MATH_NEON
asm volatile ("vdup.f32 d0, r0 \n\t");
tanf_neon_hfp(x);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return tanf_c(x);
#endif
};
-95
View File
@@ -1,95 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "math.h"
#include "math_neon.h"
/*
TanH = (e^x - e^-x) / (e^x + e^-x)
TanH = (e^x - e^-x)(e^x) / (e^x + e^-x)(e^x)
TanH = (e^2x - 1) / (e^2x + 1)
*/
float tanhf_c(float x)
{
float a, b, c;
int m;
union{
float f;
int i;
} xx;
x = 2.0f * x;
a = expf_c(x);
c = a + 1.0f;
//reciporical approx.
xx.f = c;
m = 0x3F800000 - (xx.i & 0x7F800000);
xx.i = xx.i + m;
xx.f = 1.41176471f - 0.47058824f * xx.f;
xx.i = xx.i + m;
b = 2.0 - xx.f * c;
xx.f = xx.f * b;
b = 2.0 - xx.f * c;
xx.f = xx.f * b;
c = a - 1.0;
xx.f *= c;
return xx.f;
}
float tanhf_neon_hfp(float x)
{
#ifdef __MATH_NEON
asm volatile ("vadd.f32 d0, d0, d0 \n\t");
expf_neon_hfp(x);
asm volatile (
"vmov.f32 d2, #1.0 \n\t"
"vsub.f32 d3, d0, d2 \n\t"
"vadd.f32 d0, d0, d2 \n\t"
"vrecpe.f32 d1, d0 \n\t" //d1 = ~ 1 / d0;
"vrecps.f32 d2, d1, d0 \n\t" //d2 = 2.0 - d1 * d0;
"vmul.f32 d1, d1, d2 \n\t" //d1 = d1 * d2;
"vrecps.f32 d2, d1, d0 \n\t" //d2 = 2.0 - d1 * d0;
"vmul.f32 d0, d1, d2 \n\t" //d0 = d1 * d2;
"vmul.f32 d0, d0, d3 \n\t" //d0 = d0 * d3;
::: "d0", "d1", "d2", "d3"
);
#endif
}
float tanhf_neon_sfp(float x)
{
#ifdef __MATH_NEON
asm volatile ("vmov.f32 s0, r0 \n\t");
tanhf_neon_hfp(x);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return tanhf_c(x);
#endif
};
-118
View File
@@ -1,118 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "math_neon.h"
//vec2 scalar product
float
dot2_c(float v0[2], float v1[2])
{
float r;
r = v0[0]*v1[0];
r += v0[1]*v1[1];
return r;
}
void
normalize2_c(float v[2], float d[2])
{
float b, c, x;
union {
float f;
int i;
} a;
x = v[0]*v[0];
x += v[1]*v[1];
//fast invsqrt approx
a.f = x;
a.i = 0x5F3759DF - (a.i >> 1); //VRSQRTE
c = x * a.f;
b = (3.0f - c * a.f) * 0.5; //VRSQRTS
a.f = a.f * b;
c = x * a.f;
b = (3.0f - c * a.f) * 0.5;
a.f = a.f * b;
d[0] = v[0]*a.f;
d[1] = v[1]*a.f;
}
float
dot2_neon_hfp(float v0[2], float v1[2])
{
#ifdef __MATH_NEON
asm volatile (
"vld1.32 {d2}, [%0] \n\t" //d2={x0,y0}
"vld1.32 {d4}, [%1] \n\t" //d4={x1,y1}
"vmul.f32 d0, d2, d4 \n\t" //d0 = d2*d4
"vpadd.f32 d0, d0, d0 \n\t" //d0 = d[0] + d[1]
:: "r"(v0), "r"(v1)
:
);
#endif
}
float
dot2_neon_sfp(float v0[2], float v1[2])
{
#ifdef __MATH_NEON
dot2_neon_hfp(v0, v1);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return dot2_c(v0, v1);
#endif
};
void
normalize2_neon(float v[2], float d[2])
{
#ifdef __MATH_NEON
asm volatile (
"vld1.32 d4, [%0] \n\t" //d4 = {x0,y0}
"vmul.f32 d0, d4, d4 \n\t" //d0 = d2*d2
"vpadd.f32 d0, d0 \n\t" //d0 = d[0] + d[1]
"vmov.f32 d1, d0 \n\t" //d1 = d0
"vrsqrte.f32 d0, d0 \n\t" //d0 = ~ 1.0 / sqrt(d0)
"vmul.f32 d2, d0, d1 \n\t" //d2 = d0 * d1
"vrsqrts.f32 d3, d2, d0 \n\t" //d3 = (3 - d0 * d2) / 2
"vmul.f32 d0, d0, d3 \n\t" //d0 = d0 * d3
"vmul.f32 d2, d0, d1 \n\t" //d2 = d0 * d1
"vrsqrts.f32 d3, d2, d0 \n\t" //d3 = (3 - d0 * d2) / 2
"vmul.f32 d0, d0, d3 \n\t" //d0 = d0 * d3
"vmul.f32 d4, d4, d0[0] \n\t" //d4 = d4*d0[0]
"vst1.32 d4, [%1] \n\t" //
:: "r"(v), "r"(d)
: "d0", "d1", "d2", "d3", "d4", "memory"
);
#else
normalize2_c(v, d);
#endif
}
-172
View File
@@ -1,172 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "math_neon.h"
//vec4 scalar product
float
dot3_c(float v0[3], float v1[3])
{
float r;
r = v0[0]*v1[0];
r += v0[1]*v1[1];
r += v0[2]*v1[2];
return r;
}
void
cross3_c(float v0[3], float v1[3], float d[3])
{
d[0] = v0[1]*v1[2] - v0[2]*v1[1];
d[1] = v0[2]*v1[0] - v0[0]*v1[2];
d[2] = v0[0]*v1[1] - v0[1]*v1[0];
}
void
normalize3_c(float v[3], float d[3])
{
float b, c, x;
union {
float f;
int i;
} a;
x = v[0]*v[0];
x += v[1]*v[1];
x += v[2]*v[2];
//fast invsqrt approx
a.f = x;
a.i = 0x5F3759DF - (a.i >> 1); //VRSQRTE
c = x * a.f;
b = (3.0f - c * a.f) * 0.5; //VRSQRTS
a.f = a.f * b;
c = x * a.f;
b = (3.0f - c * a.f) * 0.5;
a.f = a.f * b;
d[0] = v[0]*a.f;
d[1] = v[1]*a.f;
d[2] = v[2]*a.f;
}
float
dot3_neon_hfp(float v0[3], float v1[3])
{
#ifdef __MATH_NEON
asm volatile (
"vld1.32 {d2}, [%0] \n\t" //d2={x0,y0}
"flds s6, [%0, #8] \n\t" //d3[0]={z0}
"vld1.32 {d4}, [%1] \n\t" //d4={x1,y1}
"flds s10, [%1, #8] \n\t" //d5[0]={z1}
"vmul.f32 d0, d2, d4 \n\t" //d0= d2*d4
"vpadd.f32 d0, d0, d0 \n\t" //d0 = d[0] + d[1]
"vmla.f32 d0, d3, d5 \n\t" //d0 = d0 + d3*d5
:: "r"(v0), "r"(v1)
: "d0","d1","d2","d3","d4","d5"
);
#endif
}
float
dot3_neon_sfp(float v0[3], float v1[3])
{
#ifdef __MATH_NEON
dot3_neon_hfp(v0, v1);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return dot3_c(v0, v1);
#endif
};
void cross3_neon(float v0[3], float v1[3], float d[3])
{
#ifdef __MATH_NEON
asm volatile (
"flds s3, [%0] \n\t" //d1[1]={x0}
"add %0, %0, #4 \n\t" //
"vld1.32 {d0}, [%0] \n\t" //d0={y0,z0}
"vmov.f32 s2, s1 \n\t" //d1[0]={z0}
"flds s5, [%1] \n\t" //d2[1]={x1}
"add %1, %1, #4 \n\t" //
"vld1.32 {d3}, [%1] \n\t" //d3={y1,z1}
"vmov.f32 s4, s7 \n\t" //d2[0]=d3[1]
"vmul.f32 d4, d0, d2 \n\t" //d4=d0*d2
"vmls.f32 d4, d1, d3 \n\t" //d4-=d1*d3
"vmul.f32 d5, d3, d1[1] \n\t" //d5=d3*d1[1]
"vmls.f32 d5, d0, d2[1] \n\t" //d5-=d0*d2[1]
"vst1.32 d4, [%2] \n\t" //
"add %2, %2, #8 \n\t" //
"fsts s10, [%2] \n\t" //
: "+r"(v0), "+r"(v1), "+r"(d):
: "d0", "d1", "d2", "d3", "d4", "d5", "memory"
);
#else
cross3_c(v0,v1,d);
#endif
}
void
normalize3_neon(float v[3], float d[3])
{
#ifdef __MATH_NEON
asm volatile (
"vld1.32 {d4}, [%0] \n\t" //d4={x0,y0}
"flds s10, [%0, #8] \n\t" //d5[0]={z0}
"vmul.f32 d0, d4, d4 \n\t" //d0= d4*d4
"vpadd.f32 d0, d0 \n\t" //d0 = d[0] + d[1]
"vmla.f32 d0, d5, d5 \n\t" //d0 = d0 + d5*d5
"vmov.f32 d1, d0 \n\t" //d1 = d0
"vrsqrte.f32 d0, d0 \n\t" //d0 = ~ 1.0 / sqrt(d0)
"vmul.f32 d2, d0, d1 \n\t" //d2 = d0 * d1
"vrsqrts.f32 d3, d2, d0 \n\t" //d3 = (3 - d0 * d2) / 2
"vmul.f32 d0, d0, d3 \n\t" //d0 = d0 * d3
"vmul.f32 d2, d0, d1 \n\t" //d2 = d0 * d1
"vrsqrts.f32 d3, d2, d0 \n\t" //d4 = (3 - d0 * d3) / 2
"vmul.f32 d0, d0, d3 \n\t" //d0 = d0 * d4
"vmul.f32 q2, q2, d0[0] \n\t" //d0= d2*d4
"vst1.32 {d4}, [%1] \n\t" //
"fsts s10, [%1, #8] \n\t" //
:: "r"(v), "r"(d)
: "d0", "d1", "d2", "d3", "d4", "d5", "memory"
);
#else
normalize3_c(v, d);
#endif
}
-126
View File
@@ -1,126 +0,0 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Lachlan Tychsen-Smith (lachlan.ts@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "math_neon.h"
#ifdef __MATH_NEON
#include "arm_neon.h"
#endif
//vec4 scalar product
float dot4_c(float v0[4], float v1[4])
{
float r;
r = v0[0]*v1[0];
r += v0[1]*v1[1];
r += v0[2]*v1[2];
r += v0[3]*v1[3];
return r;
}
void normalize4_c(float v[4], float d[4])
{
float b, c, x;
union {
float f;
int i;
} a;
x = v[0]*v[0];
x += v[1]*v[1];
x += v[2]*v[2];
x += v[3]*v[3];
//fast invsqrt approx
a.f = x;
a.i = 0x5F3759DF - (a.i >> 1); //VRSQRTE
c = x * a.f;
b = (3.0f - c * a.f) * 0.5; //VRSQRTS
a.f = a.f * b;
c = x * a.f;
b = (3.0f - c * a.f) * 0.5;
a.f = a.f * b;
d[0] = v[0]*a.f;
d[1] = v[1]*a.f;
d[2] = v[2]*a.f;
d[3] = v[3]*a.f;
}
void normalize4_neon(float v[4], float d[4])
{
#ifdef __MATH_NEON
asm volatile (
"vld1.32 {d4, d5}, [%0] \n\t" //d2={x0,y0}, d3={z0, w0}
"vmul.f32 d0, d4, d4 \n\t" //d0= d4*d4
"vmla.f32 d0, d5, d5 \n\t" //d0 = d0 + d5*d5
"vpadd.f32 d0, d0 \n\t" //d0 = d[0] + d[1]
"vmov.f32 d1, d0 \n\t" //d1 = d0
"vrsqrte.f32 d0, d0 \n\t" //d0 = ~ 1.0 / sqrt(d0)
"vmul.f32 d2, d0, d1 \n\t" //d2 = d0 * d1
"vrsqrts.f32 d3, d2, d0 \n\t" //d3 = (3 - d0 * d2) / 2
"vmul.f32 d0, d0, d3 \n\t" //d0 = d0 * d3
"vmul.f32 d2, d0, d1 \n\t" //d2 = d0 * d1
"vrsqrts.f32 d3, d2, d0 \n\t" //d4 = (3 - d0 * d3) / 2
"vmul.f32 d0, d0, d3 \n\t" //d0 = d0 * d4
"vmul.f32 q2, q2, d0[0] \n\t" //d0= d2*d4
"vst1.32 {d4, d5}, [%1] \n\t" //d2={x0,y0}, d3={z0, w0}
:: "r"(v), "r"(d)
: "d0", "d1", "d2", "d3", "d4", "d5", "memory"
);
#else
normalize4_c(v, d);
#endif
}
float dot4_neon_hfp(float v0[4], float v1[4])
{
#ifdef __MATH_NEON
asm volatile (
"vld1.32 {d2, d3}, [%0] \n\t" //d2={x0,y0}, d3={z0, w0}
"vld1.32 {d4, d5}, [%1] \n\t" //d4={x1,y1}, d5={z1, w1}
"vmul.f32 d0, d2, d4 \n\t" //d0= d2*d4
"vmla.f32 d0, d3, d5 \n\t" //d0 = d0 + d3*d5
"vpadd.f32 d0, d0 \n\t" //d0 = d[0] + d[1]
:: "r"(v0), "r"(v1) :
);
#endif
}
float dot4_neon_sfp(float v0[4], float v1[4])
{
#ifdef __MATH_NEON
dot4_neon_hfp(v0, v1);
asm volatile ("vmov.f32 r0, s0 \n\t");
#else
return dot4_c(v0, v1);
#endif
};
Loaded 100 of 424 files, more files were not shown because too many files have changed in this diff. Show more