From 3b0e40f17ec7f52bec0f8b709e0779ad39b8887d Mon Sep 17 00:00:00 2001 From: Madhura Jayaraman Date: Thu, 5 Sep 2024 12:48:07 -0700 Subject: [PATCH] Remove SB versions 16 and lower (#4051) b/362374622 --- .github/config/evergreen-arm-hardfp.json | 20 - .github/config/evergreen-arm-softfp.json | 20 - .github/config/evergreen-arm64.json | 20 - .github/config/evergreen-x64.json | 18 - .github/config/linux.json | 14 - .github/config/raspi-2.json | 18 - base/synchronization/condition_variable.h | 9 - .../condition_variable_starboard.cc | 32 - base/synchronization/lock_impl.h | 19 - base/synchronization/lock_impl_starboard.cc | 19 - base/threading/platform_thread.h | 4 - base/threading/platform_thread_ref.h | 4 - base/threading/platform_thread_starboard.cc | 16 - cobalt/browser/application.cc | 12 - cobalt/browser/switches.cc | 11 - cobalt/browser/switches.h | 4 - cobalt/browser/user_agent_platform_info.cc | 56 - cobalt/browser/user_agent_platform_info.h | 11 +- cobalt/browser/web_module.cc | 4 - .../dom/captions/system_caption_settings.cc | 4 - cobalt/dom/captions/system_caption_settings.h | 4 - cobalt/dom/html_media_element.cc | 4 - cobalt/dom/keyboard_event.cc | 2 - cobalt/dom/keyboard_event_test.cc | 2 - cobalt/dom/keycode.h | 2 - cobalt/h5vcc/h5vcc_accessibility.cc | 4 - cobalt/media/base/sbplayer_bridge.cc | 44 - cobalt/media/base/sbplayer_bridge.h | 2 - cobalt/media/base/sbplayer_interface.cc | 19 - cobalt/media/base/sbplayer_interface.h | 13 +- cobalt/media/decoder_buffer_allocator.cc | 8 +- cobalt/media/media_module.cc | 7 +- cobalt/media/media_module.h | 2 - cobalt/ui_navigation/interface.cc | 26 - cobalt/ui_navigation/interface.h | 4 - .../testing/mock_user_agent_platform_info.h | 5 - cobalt/web/user_agent_platform_info.h | 3 - media/base/starboard_utils.cc | 7 - starboard/BUILD.gn | 7 - starboard/accessibility.h | 214 ---- starboard/android/shared/BUILD.gn | 92 -- .../android/shared/configuration_constants.cc | 5 - .../android/shared/configuration_public.h | 26 - starboard/android/shared/directory_close.cc | 33 - .../android/shared/directory_get_next.cc | 42 - starboard/android/shared/directory_internal.h | 37 - starboard/android/shared/directory_open.cc | 44 - starboard/android/shared/file_can_open.cc | 48 - starboard/android/shared/file_close.cc | 34 - starboard/android/shared/file_delete.cc | 26 - starboard/android/shared/file_exists.cc | 23 - starboard/android/shared/file_flush.cc | 26 - starboard/android/shared/file_get_info.cc | 38 - .../android/shared/file_get_path_info.cc | 55 - starboard/android/shared/file_open.cc | 110 -- starboard/android/shared/file_read.cc | 36 - starboard/android/shared/file_seek.cc | 32 - starboard/android/shared/file_truncate.cc | 26 - starboard/android/shared/file_write.cc | 26 - starboard/android/shared/posix_emu/dirent.cc | 1 - starboard/android/shared/posix_emu/stat.cc | 1 - .../android/shared/system_get_device_type.cc | 23 - starboard/android/shared/thread_create.cc | 151 --- starboard/android/shared/thread_get_name.cc | 24 - starboard/atomic.h | 6 - starboard/byte_swap.h | 68 -- starboard/common/condition_variable.cc | 25 - starboard/common/condition_variable.h | 4 - starboard/common/memory.h | 4 - starboard/common/mutex.cc | 24 - starboard/common/mutex.h | 9 - starboard/common/storage.cc | 36 +- starboard/common/storage.h | 11 - starboard/configuration.h | 30 +- starboard/configuration_constants.h | 5 - starboard/directory.h | 60 -- starboard/elf_loader/exported_symbols.cc | 176 ---- starboard/event.h | 12 - .../arm/hardfp/configuration_public.h | 26 - .../arm/softfp/configuration_public.h | 26 - .../evergreen/arm64/configuration_public.h | 26 - .../evergreen/x64/configuration_public.h | 26 - starboard/file.h | 218 +--- starboard/image.h | 57 -- starboard/linux/shared/BUILD.gn | 84 -- .../linux/shared/configuration_constants.cc | 5 - starboard/linux/shared/configuration_public.h | 26 - .../linux/shared/system_get_device_type.cc | 23 - .../linux/shared/system_get_extensions.cc | 5 - starboard/linux/x64x11/shared/BUILD.gn | 2 - .../linux/x64x11/system_get_property_impl.cc | 8 - starboard/log.h | 5 - starboard/media.h | 26 - starboard/memory.h | 193 ---- starboard/nplb/BUILD.gn | 63 -- starboard/nplb/accessibility_test.cc | 158 --- starboard/nplb/byte_swap_test.cc | 80 -- .../nplb/condition_variable_broadcast_test.cc | 40 - .../nplb/condition_variable_create_test.cc | 89 -- .../nplb/condition_variable_destroy_test.cc | 42 - .../nplb/condition_variable_signal_test.cc | 40 - .../nplb/condition_variable_wait_test.cc | 94 -- .../condition_variable_wait_timed_test.cc | 176 ---- starboard/nplb/directory_can_open_test.cc | 68 -- starboard/nplb/directory_close_test.cc | 32 - starboard/nplb/directory_create_test.cc | 115 --- starboard/nplb/directory_get_next_test.cc | 213 ---- starboard/nplb/directory_open_test.cc | 156 --- starboard/nplb/extern_c_test.cc | 16 - starboard/nplb/file_can_open_test.cc | 76 -- starboard/nplb/file_close_test.cc | 35 - starboard/nplb/file_delete_test.cc | 69 -- starboard/nplb/file_flush_test.cc | 36 - starboard/nplb/file_get_info_test.cc | 93 -- starboard/nplb/file_get_path_info_test.cc | 120 --- .../nplb/file_mode_string_to_flags_test.cc | 65 -- starboard/nplb/file_open_test.cc | 171 ---- starboard/nplb/file_read_test.cc | 300 ------ starboard/nplb/file_read_write_all_test.cc | 69 -- starboard/nplb/file_seek_test.cc | 241 ----- starboard/nplb/file_truncate_test.cc | 121 --- starboard/nplb/file_write_test.cc | 173 ---- starboard/nplb/image_test.cc | 56 - starboard/nplb/include_all.c | 16 - starboard/nplb/log_is_tty_test.cc | 35 - starboard/nplb/media_buffer_test.cc | 58 -- .../nplb/memory_allocate_aligned_test.cc | 74 -- starboard/nplb/memory_allocate_test.cc | 66 -- .../nplb/memory_deallocate_aligned_test.cc | 43 - starboard/nplb/memory_deallocate_test.cc | 40 - starboard/nplb/memory_map_test.cc | 300 ------ starboard/nplb/memory_reallocate_test.cc | 150 --- starboard/nplb/mutex_acquire_test.cc | 109 -- starboard/nplb/mutex_acquire_try_test.cc | 88 -- starboard/nplb/mutex_create_test.cc | 70 -- starboard/nplb/mutex_destroy_test.cc | 42 - .../nplb_evergreen_compat_tests/sabi_test.cc | 115 --- starboard/nplb/once_test.cc | 169 --- .../posix_compliance/posix_memory_map_test.cc | 7 - starboard/nplb/storage_helpers.h | 16 - .../nplb/string_compare_no_case_n_test.cc | 63 -- starboard/nplb/string_compare_no_case_test.cc | 43 - starboard/nplb/string_duplicate_test.cc | 45 - starboard/nplb/string_format_test.cc | 50 - starboard/nplb/string_format_wide_test.cc | 53 - starboard/nplb/string_scan_test.cc | 99 -- starboard/nplb/system_get_property_test.cc | 28 - starboard/nplb/thread_create_test.cc | 175 ---- starboard/nplb/thread_detach_test.cc | 46 - starboard/nplb/thread_get_current_test.cc | 51 - starboard/nplb/thread_get_name_test.cc | 50 - starboard/nplb/thread_helpers.cc | 97 -- starboard/nplb/thread_helpers.h | 183 +--- starboard/nplb/thread_is_equal_test.cc | 43 - starboard/nplb/thread_join_test.cc | 77 -- starboard/nplb/thread_local_value_test.cc | 195 ---- starboard/nplb/thread_sampler_test.cc | 13 - starboard/nplb/thread_set_name_test.cc | 65 -- starboard/nplb/thread_sleep_test.cc | 63 -- starboard/nplb/thread_yield_test.cc | 124 --- starboard/nplb/time_constants.h | 49 +- starboard/nplb/time_get_monotonic_now_test.cc | 56 - starboard/nplb/time_get_now_test.cc | 64 -- starboard/nplb/time_narrow_test.cc | 43 - starboard/nplb/ui_navigation_test.cc | 9 - starboard/nplb/user_get_current_test.cc | 41 - starboard/nplb/user_get_property_test.cc | 86 -- starboard/nplb/user_get_signed_in_test.cc | 63 -- starboard/once.h | 77 +- starboard/raspi/shared/BUILD.gn | 81 -- .../raspi/shared/configuration_constants.cc | 5 - starboard/raspi/shared/configuration_public.h | 26 - .../raspi/shared/open_max/image_decode.cc | 47 - .../open_max/image_is_decode_supported.cc | 45 - .../raspi/shared/system_get_device_type.cc | 23 - starboard/shared/iso/directory_close.cc | 22 - starboard/shared/iso/directory_get_next.cc | 25 - starboard/shared/iso/directory_internal.h | 29 - starboard/shared/iso/directory_open.cc | 22 - starboard/shared/iso/impl/directory_close.h | 49 - .../shared/iso/impl/directory_get_next.h | 63 -- starboard/shared/iso/impl/directory_impl.h | 28 - starboard/shared/iso/impl/directory_open.h | 92 -- starboard/shared/iso/string_scan.cc | 26 - starboard/shared/libjpeg/image_decode.cc | 34 - .../libjpeg/image_is_decode_supported.cc | 40 - starboard/shared/linux/byte_swap.cc | 48 - starboard/shared/linux/thread_get_name.cc | 25 - starboard/shared/linux/thread_set_name.cc | 47 - starboard/shared/nouser/user_get_current.cc | 27 - starboard/shared/nouser/user_get_property.cc | 65 -- starboard/shared/nouser/user_get_signed_in.cc | 31 - starboard/shared/nouser/user_internal.cc | 33 - starboard/shared/nouser/user_internal.h | 41 - starboard/shared/opus/opus_audio_decoder.cc | 12 - starboard/shared/posix/directory_create.cc | 77 -- starboard/shared/posix/file_can_open.cc | 25 - starboard/shared/posix/file_close.cc | 25 - starboard/shared/posix/file_delete.cc | 25 - starboard/shared/posix/file_exists.cc | 25 - starboard/shared/posix/file_flush.cc | 25 - starboard/shared/posix/file_get_info.cc | 25 - starboard/shared/posix/file_get_path_info.cc | 25 - starboard/shared/posix/file_open.cc | 29 - starboard/shared/posix/file_read.cc | 25 - starboard/shared/posix/file_seek.cc | 25 - starboard/shared/posix/file_truncate.cc | 25 - starboard/shared/posix/file_write.cc | 25 - .../shared/posix/impl/file_get_path_info.h | 38 +- starboard/shared/posix/log_is_tty.cc | 23 - starboard/shared/posix/memory_flush.cc | 50 - starboard/shared/posix/memory_map.cc | 25 - starboard/shared/posix/memory_protect.cc | 25 - starboard/shared/posix/memory_unmap.cc | 24 - starboard/shared/posix/page_internal.cc | 54 - starboard/shared/posix/page_internal.h | 26 - .../shared/posix/string_compare_no_case.cc | 24 - .../shared/posix/string_compare_no_case_n.cc | 26 - starboard/shared/posix/string_format.cc | 27 - starboard/shared/posix/string_format_wide.cc | 28 - .../shared/posix/time_get_monotonic_now.cc | 34 - .../posix/time_get_monotonic_thread_now.cc | 34 - starboard/shared/posix/time_get_now.cc | 34 - starboard/shared/posix/time_internal.h | 42 +- .../time_is_time_thread_now_supported.cc | 23 - .../pthread/condition_variable_broadcast.cc | 43 - .../pthread/condition_variable_create.cc | 91 -- .../pthread/condition_variable_destroy.cc | 43 - .../pthread/condition_variable_signal.cc | 43 - .../shared/pthread/condition_variable_wait.cc | 51 - .../pthread/condition_variable_wait_timed.cc | 83 -- starboard/shared/pthread/mutex_acquire.cc | 53 - starboard/shared/pthread/mutex_acquire_try.cc | 46 - starboard/shared/pthread/mutex_create.cc | 39 - starboard/shared/pthread/mutex_destroy.cc | 44 - starboard/shared/pthread/mutex_release.cc | 38 - starboard/shared/pthread/once.cc | 47 - starboard/shared/pthread/thread_create.cc | 133 --- .../shared/pthread/thread_create_local_key.cc | 32 - .../pthread/thread_destroy_local_key.cc | 32 - starboard/shared/pthread/thread_detach.cc | 31 - .../shared/pthread/thread_get_current.cc | 26 - .../shared/pthread/thread_get_local_value.cc | 31 - starboard/shared/pthread/thread_is_equal.cc | 28 - starboard/shared/pthread/thread_join.cc | 42 - .../pthread/thread_local_key_internal.h | 14 +- .../shared/pthread/thread_sampler_create.cc | 9 - .../shared/pthread/thread_sampler_internal.cc | 4 - .../shared/pthread/thread_sampler_internal.h | 12 - .../shared/pthread/thread_set_local_value.cc | 35 - .../shared/starboard/directory_can_open.cc | 33 - .../starboard/file_mode_string_to_flags.cc | 70 -- .../file_storage/storage_delete_record.cc | 5 - .../file_storage/storage_open_record.cc | 5 - .../media/media_get_buffer_storage_type.cc | 21 - .../shared/starboard/media/media_util.cc | 10 - starboard/shared/starboard/memory.cc | 119 --- .../shared/starboard/string_duplicate.cc | 32 - .../accessibility_get_caption_settings.cc | 33 - .../accessibility_get_display_settings.cc | 32 - ...cessibility_get_text_to_speech_settings.cc | 32 - .../accessibility_set_captions_enabled.cc | 24 - starboard/shared/stub/byte_swap.cc | 46 - .../stub/condition_variable_broadcast.cc | 22 - .../shared/stub/condition_variable_create.cc | 22 - .../shared/stub/condition_variable_destroy.cc | 22 - .../shared/stub/condition_variable_signal.cc | 22 - .../shared/stub/condition_variable_wait.cc | 24 - .../stub/condition_variable_wait_timed.cc | 25 - starboard/shared/stub/directory_can_open.cc | 21 - starboard/shared/stub/directory_close.cc | 20 - starboard/shared/stub/directory_create.cc | 23 - starboard/shared/stub/directory_get_next.cc | 22 - starboard/shared/stub/directory_open.cc | 20 - starboard/shared/stub/file_can_open.cc | 23 - starboard/shared/stub/file_close.cc | 23 - starboard/shared/stub/file_delete.cc | 23 - starboard/shared/stub/file_exists.cc | 23 - starboard/shared/stub/file_flush.cc | 23 - starboard/shared/stub/file_get_info.cc | 23 - starboard/shared/stub/file_get_path_info.cc | 23 - starboard/shared/stub/file_open.cc | 26 - starboard/shared/stub/file_read.cc | 23 - starboard/shared/stub/file_seek.cc | 23 - starboard/shared/stub/file_truncate.cc | 23 - starboard/shared/stub/file_write.cc | 23 - starboard/shared/stub/image_decode.cc | 28 - .../shared/stub/image_is_decode_supported.cc | 25 - .../stub/media_get_buffer_storage_type.cc | 21 - starboard/shared/stub/mutex_acquire.cc | 22 - starboard/shared/stub/mutex_acquire_try.cc | 22 - starboard/shared/stub/mutex_create.cc | 22 - starboard/shared/stub/mutex_destroy.cc | 22 - starboard/shared/stub/mutex_release.cc | 22 - starboard/shared/stub/once.cc | 23 - .../shared/stub/storage_delete_record.cc | 4 - starboard/shared/stub/storage_open_record.cc | 4 - .../shared/stub/string_compare_no_case.cc | 21 - .../shared/stub/string_compare_no_case_n.cc | 23 - starboard/shared/stub/string_duplicate.cc | 23 - starboard/shared/stub/string_format.cc | 24 - starboard/shared/stub/string_format_wide.cc | 24 - starboard/shared/stub/string_scan.cc | 23 - .../shared/stub/system_get_device_type.cc | 23 - starboard/shared/stub/thread_create.cc | 28 - .../shared/stub/thread_create_local_key.cc | 23 - .../shared/stub/thread_destroy_local_key.cc | 21 - starboard/shared/stub/thread_detach.cc | 19 - starboard/shared/stub/thread_get_current.cc | 23 - .../shared/stub/thread_get_local_value.cc | 23 - starboard/shared/stub/thread_get_name.cc | 21 - starboard/shared/stub/thread_is_equal.cc | 23 - starboard/shared/stub/thread_join.cc | 22 - .../shared/stub/thread_sampler_create.cc | 4 - .../shared/stub/thread_set_local_value.cc | 23 - starboard/shared/stub/thread_set_name.cc | 21 - .../shared/stub/time_get_monotonic_now.cc | 23 - .../stub/time_get_monotonic_thread_now.cc | 23 - starboard/shared/stub/time_get_now.cc | 23 - .../stub/time_is_time_thread_now_supported.cc | 23 - starboard/shared/stub/ui_nav_get_interface.cc | 23 - starboard/shared/stub/user_get_current.cc | 23 - starboard/shared/stub/user_get_property.cc | 30 - starboard/shared/stub/user_get_signed_in.cc | 23 - .../stub/window_blur_on_screen_keyboard.cc | 21 - .../stub/window_focus_on_screen_keyboard.cc | 21 - ...ow_get_on_screen_keyboard_bounding_rect.cc | 24 - .../stub/window_hide_on_screen_keyboard.cc | 21 - .../window_is_on_screen_keyboard_shown.cc | 23 - .../window_on_screen_keyboard_is_supported.cc | 23 - ...n_screen_keyboard_suggestions_supported.cc | 23 - ...indow_set_on_screen_keyboard_keep_focus.cc | 21 - .../stub/window_show_on_screen_keyboard.cc | 23 - ...w_update_on_screen_keyboard_suggestions.cc | 24 - starboard/storage.h | 34 - starboard/stub/BUILD.gn | 75 -- starboard/stub/configuration_constants.cc | 5 - starboard/stub/configuration_public.h | 8 - starboard/system.h | 40 - starboard/thread.h | 178 +--- starboard/time.h | 92 -- starboard/ui_navigation.h | 277 ----- starboard/user.h | 94 -- starboard/window.h | 88 -- .../include/gtest/internal/gtest-port.h | 5 - third_party/musl/BUILD.gn | 17 - third_party/musl/src/starboard/dirent.c | 67 -- .../src/starboard/errno/__errno_location.c | 48 - .../musl/src/starboard/malloc/malloc.c | 27 - .../src/starboard/malloc/posix_memalign.c | 22 - third_party/musl/src/starboard/mman/mman.c | 61 -- .../musl/src/starboard/network/socket.c | 959 ------------------ .../musl/src/starboard/pthread/pthread.c | 262 ----- third_party/musl/src/starboard/sched/sched.c | 25 - .../musl/src/starboard/stdio/vsnprintf.c | 10 - .../musl/src/starboard/stdio/vsscanf.c | 10 - .../musl/src/starboard/stdio/vswprintf.c | 10 - third_party/musl/src/starboard/sys/stat.c | 56 - .../src/starboard/sys/time/gettimeofday.c | 22 - .../musl/src/starboard/time/clock_gettime.c | 39 - .../musl/src/starboard/time/gmtime_r.c | 28 - third_party/musl/src/starboard/time/time.c | 18 - .../musl/src/starboard/unistd/unistd.c | 44 - v8/src/base/platform/condition-variable.cc | 28 - v8/src/base/platform/condition-variable.h | 8 - v8/src/base/platform/mutex.cc | 16 - v8/src/base/platform/mutex.h | 4 - v8/src/libsampler/sampler.cc | 8 - 368 files changed, 18 insertions(+), 16982 deletions(-) delete mode 100644 starboard/android/shared/directory_close.cc delete mode 100644 starboard/android/shared/directory_get_next.cc delete mode 100644 starboard/android/shared/directory_internal.h delete mode 100644 starboard/android/shared/directory_open.cc delete mode 100644 starboard/android/shared/file_can_open.cc delete mode 100644 starboard/android/shared/file_close.cc delete mode 100644 starboard/android/shared/file_delete.cc delete mode 100644 starboard/android/shared/file_exists.cc delete mode 100644 starboard/android/shared/file_flush.cc delete mode 100644 starboard/android/shared/file_get_info.cc delete mode 100644 starboard/android/shared/file_get_path_info.cc delete mode 100644 starboard/android/shared/file_open.cc delete mode 100644 starboard/android/shared/file_read.cc delete mode 100644 starboard/android/shared/file_seek.cc delete mode 100644 starboard/android/shared/file_truncate.cc delete mode 100644 starboard/android/shared/file_write.cc delete mode 100644 starboard/android/shared/system_get_device_type.cc delete mode 100644 starboard/android/shared/thread_create.cc delete mode 100644 starboard/android/shared/thread_get_name.cc delete mode 100644 starboard/linux/shared/system_get_device_type.cc delete mode 100644 starboard/nplb/accessibility_test.cc delete mode 100644 starboard/nplb/byte_swap_test.cc delete mode 100644 starboard/nplb/condition_variable_broadcast_test.cc delete mode 100644 starboard/nplb/condition_variable_create_test.cc delete mode 100644 starboard/nplb/condition_variable_destroy_test.cc delete mode 100644 starboard/nplb/condition_variable_signal_test.cc delete mode 100644 starboard/nplb/condition_variable_wait_test.cc delete mode 100644 starboard/nplb/condition_variable_wait_timed_test.cc delete mode 100644 starboard/nplb/directory_can_open_test.cc delete mode 100644 starboard/nplb/directory_close_test.cc delete mode 100644 starboard/nplb/directory_create_test.cc delete mode 100644 starboard/nplb/directory_get_next_test.cc delete mode 100644 starboard/nplb/directory_open_test.cc delete mode 100644 starboard/nplb/file_can_open_test.cc delete mode 100644 starboard/nplb/file_close_test.cc delete mode 100644 starboard/nplb/file_delete_test.cc delete mode 100644 starboard/nplb/file_flush_test.cc delete mode 100644 starboard/nplb/file_get_info_test.cc delete mode 100644 starboard/nplb/file_get_path_info_test.cc delete mode 100644 starboard/nplb/file_mode_string_to_flags_test.cc delete mode 100644 starboard/nplb/file_open_test.cc delete mode 100644 starboard/nplb/file_read_test.cc delete mode 100644 starboard/nplb/file_read_write_all_test.cc delete mode 100644 starboard/nplb/file_seek_test.cc delete mode 100644 starboard/nplb/file_truncate_test.cc delete mode 100644 starboard/nplb/file_write_test.cc delete mode 100644 starboard/nplb/image_test.cc delete mode 100644 starboard/nplb/log_is_tty_test.cc delete mode 100644 starboard/nplb/memory_allocate_aligned_test.cc delete mode 100644 starboard/nplb/memory_allocate_test.cc delete mode 100644 starboard/nplb/memory_deallocate_aligned_test.cc delete mode 100644 starboard/nplb/memory_deallocate_test.cc delete mode 100644 starboard/nplb/memory_map_test.cc delete mode 100644 starboard/nplb/memory_reallocate_test.cc delete mode 100644 starboard/nplb/mutex_acquire_test.cc delete mode 100644 starboard/nplb/mutex_acquire_try_test.cc delete mode 100644 starboard/nplb/mutex_create_test.cc delete mode 100644 starboard/nplb/mutex_destroy_test.cc delete mode 100644 starboard/nplb/once_test.cc delete mode 100644 starboard/nplb/string_compare_no_case_n_test.cc delete mode 100644 starboard/nplb/string_compare_no_case_test.cc delete mode 100644 starboard/nplb/string_duplicate_test.cc delete mode 100644 starboard/nplb/string_format_test.cc delete mode 100644 starboard/nplb/string_format_wide_test.cc delete mode 100644 starboard/nplb/string_scan_test.cc delete mode 100644 starboard/nplb/thread_create_test.cc delete mode 100644 starboard/nplb/thread_detach_test.cc delete mode 100644 starboard/nplb/thread_get_current_test.cc delete mode 100644 starboard/nplb/thread_get_name_test.cc delete mode 100644 starboard/nplb/thread_helpers.cc delete mode 100644 starboard/nplb/thread_is_equal_test.cc delete mode 100644 starboard/nplb/thread_join_test.cc delete mode 100644 starboard/nplb/thread_local_value_test.cc delete mode 100644 starboard/nplb/thread_set_name_test.cc delete mode 100644 starboard/nplb/thread_sleep_test.cc delete mode 100644 starboard/nplb/thread_yield_test.cc delete mode 100644 starboard/nplb/time_get_monotonic_now_test.cc delete mode 100644 starboard/nplb/time_get_now_test.cc delete mode 100644 starboard/nplb/time_narrow_test.cc delete mode 100644 starboard/nplb/user_get_current_test.cc delete mode 100644 starboard/nplb/user_get_property_test.cc delete mode 100644 starboard/nplb/user_get_signed_in_test.cc delete mode 100644 starboard/raspi/shared/open_max/image_decode.cc delete mode 100644 starboard/raspi/shared/open_max/image_is_decode_supported.cc delete mode 100644 starboard/raspi/shared/system_get_device_type.cc delete mode 100644 starboard/shared/iso/directory_close.cc delete mode 100644 starboard/shared/iso/directory_get_next.cc delete mode 100644 starboard/shared/iso/directory_internal.h delete mode 100644 starboard/shared/iso/directory_open.cc delete mode 100644 starboard/shared/iso/impl/directory_close.h delete mode 100644 starboard/shared/iso/impl/directory_get_next.h delete mode 100644 starboard/shared/iso/impl/directory_impl.h delete mode 100644 starboard/shared/iso/impl/directory_open.h delete mode 100644 starboard/shared/iso/string_scan.cc delete mode 100644 starboard/shared/libjpeg/image_decode.cc delete mode 100644 starboard/shared/libjpeg/image_is_decode_supported.cc delete mode 100644 starboard/shared/linux/byte_swap.cc delete mode 100644 starboard/shared/linux/thread_get_name.cc delete mode 100644 starboard/shared/linux/thread_set_name.cc delete mode 100644 starboard/shared/nouser/user_get_current.cc delete mode 100644 starboard/shared/nouser/user_get_property.cc delete mode 100644 starboard/shared/nouser/user_get_signed_in.cc delete mode 100644 starboard/shared/nouser/user_internal.cc delete mode 100644 starboard/shared/nouser/user_internal.h delete mode 100644 starboard/shared/posix/directory_create.cc delete mode 100644 starboard/shared/posix/file_can_open.cc delete mode 100644 starboard/shared/posix/file_close.cc delete mode 100644 starboard/shared/posix/file_delete.cc delete mode 100644 starboard/shared/posix/file_exists.cc delete mode 100644 starboard/shared/posix/file_flush.cc delete mode 100644 starboard/shared/posix/file_get_info.cc delete mode 100644 starboard/shared/posix/file_get_path_info.cc delete mode 100644 starboard/shared/posix/file_open.cc delete mode 100644 starboard/shared/posix/file_read.cc delete mode 100644 starboard/shared/posix/file_seek.cc delete mode 100644 starboard/shared/posix/file_truncate.cc delete mode 100644 starboard/shared/posix/file_write.cc delete mode 100644 starboard/shared/posix/log_is_tty.cc delete mode 100644 starboard/shared/posix/memory_flush.cc delete mode 100644 starboard/shared/posix/memory_map.cc delete mode 100644 starboard/shared/posix/memory_protect.cc delete mode 100644 starboard/shared/posix/memory_unmap.cc delete mode 100644 starboard/shared/posix/string_compare_no_case.cc delete mode 100644 starboard/shared/posix/string_compare_no_case_n.cc delete mode 100644 starboard/shared/posix/string_format.cc delete mode 100644 starboard/shared/posix/string_format_wide.cc delete mode 100644 starboard/shared/posix/time_get_monotonic_now.cc delete mode 100644 starboard/shared/posix/time_get_monotonic_thread_now.cc delete mode 100644 starboard/shared/posix/time_get_now.cc delete mode 100644 starboard/shared/posix/time_is_time_thread_now_supported.cc delete mode 100644 starboard/shared/pthread/condition_variable_broadcast.cc delete mode 100644 starboard/shared/pthread/condition_variable_create.cc delete mode 100644 starboard/shared/pthread/condition_variable_destroy.cc delete mode 100644 starboard/shared/pthread/condition_variable_signal.cc delete mode 100644 starboard/shared/pthread/condition_variable_wait.cc delete mode 100644 starboard/shared/pthread/condition_variable_wait_timed.cc delete mode 100644 starboard/shared/pthread/mutex_acquire.cc delete mode 100644 starboard/shared/pthread/mutex_acquire_try.cc delete mode 100644 starboard/shared/pthread/mutex_create.cc delete mode 100644 starboard/shared/pthread/mutex_destroy.cc delete mode 100644 starboard/shared/pthread/mutex_release.cc delete mode 100644 starboard/shared/pthread/once.cc delete mode 100644 starboard/shared/pthread/thread_create.cc delete mode 100644 starboard/shared/pthread/thread_create_local_key.cc delete mode 100644 starboard/shared/pthread/thread_destroy_local_key.cc delete mode 100644 starboard/shared/pthread/thread_detach.cc delete mode 100644 starboard/shared/pthread/thread_get_current.cc delete mode 100644 starboard/shared/pthread/thread_get_local_value.cc delete mode 100644 starboard/shared/pthread/thread_is_equal.cc delete mode 100644 starboard/shared/pthread/thread_join.cc delete mode 100644 starboard/shared/pthread/thread_set_local_value.cc delete mode 100644 starboard/shared/starboard/directory_can_open.cc delete mode 100644 starboard/shared/starboard/file_mode_string_to_flags.cc delete mode 100644 starboard/shared/starboard/media/media_get_buffer_storage_type.cc delete mode 100644 starboard/shared/starboard/memory.cc delete mode 100644 starboard/shared/starboard/string_duplicate.cc delete mode 100644 starboard/shared/stub/accessibility_get_caption_settings.cc delete mode 100644 starboard/shared/stub/accessibility_get_display_settings.cc delete mode 100644 starboard/shared/stub/accessibility_get_text_to_speech_settings.cc delete mode 100644 starboard/shared/stub/accessibility_set_captions_enabled.cc delete mode 100644 starboard/shared/stub/byte_swap.cc delete mode 100644 starboard/shared/stub/condition_variable_broadcast.cc delete mode 100644 starboard/shared/stub/condition_variable_create.cc delete mode 100644 starboard/shared/stub/condition_variable_destroy.cc delete mode 100644 starboard/shared/stub/condition_variable_signal.cc delete mode 100644 starboard/shared/stub/condition_variable_wait.cc delete mode 100644 starboard/shared/stub/condition_variable_wait_timed.cc delete mode 100644 starboard/shared/stub/directory_can_open.cc delete mode 100644 starboard/shared/stub/directory_close.cc delete mode 100644 starboard/shared/stub/directory_create.cc delete mode 100644 starboard/shared/stub/directory_get_next.cc delete mode 100644 starboard/shared/stub/directory_open.cc delete mode 100644 starboard/shared/stub/file_can_open.cc delete mode 100644 starboard/shared/stub/file_close.cc delete mode 100644 starboard/shared/stub/file_delete.cc delete mode 100644 starboard/shared/stub/file_exists.cc delete mode 100644 starboard/shared/stub/file_flush.cc delete mode 100644 starboard/shared/stub/file_get_info.cc delete mode 100644 starboard/shared/stub/file_get_path_info.cc delete mode 100644 starboard/shared/stub/file_open.cc delete mode 100644 starboard/shared/stub/file_read.cc delete mode 100644 starboard/shared/stub/file_seek.cc delete mode 100644 starboard/shared/stub/file_truncate.cc delete mode 100644 starboard/shared/stub/file_write.cc delete mode 100644 starboard/shared/stub/image_decode.cc delete mode 100644 starboard/shared/stub/image_is_decode_supported.cc delete mode 100644 starboard/shared/stub/media_get_buffer_storage_type.cc delete mode 100644 starboard/shared/stub/mutex_acquire.cc delete mode 100644 starboard/shared/stub/mutex_acquire_try.cc delete mode 100644 starboard/shared/stub/mutex_create.cc delete mode 100644 starboard/shared/stub/mutex_destroy.cc delete mode 100644 starboard/shared/stub/mutex_release.cc delete mode 100644 starboard/shared/stub/once.cc delete mode 100644 starboard/shared/stub/string_compare_no_case.cc delete mode 100644 starboard/shared/stub/string_compare_no_case_n.cc delete mode 100644 starboard/shared/stub/string_duplicate.cc delete mode 100644 starboard/shared/stub/string_format.cc delete mode 100644 starboard/shared/stub/string_format_wide.cc delete mode 100644 starboard/shared/stub/string_scan.cc delete mode 100644 starboard/shared/stub/system_get_device_type.cc delete mode 100644 starboard/shared/stub/thread_create.cc delete mode 100644 starboard/shared/stub/thread_create_local_key.cc delete mode 100644 starboard/shared/stub/thread_destroy_local_key.cc delete mode 100644 starboard/shared/stub/thread_detach.cc delete mode 100644 starboard/shared/stub/thread_get_current.cc delete mode 100644 starboard/shared/stub/thread_get_local_value.cc delete mode 100644 starboard/shared/stub/thread_get_name.cc delete mode 100644 starboard/shared/stub/thread_is_equal.cc delete mode 100644 starboard/shared/stub/thread_join.cc delete mode 100644 starboard/shared/stub/thread_set_local_value.cc delete mode 100644 starboard/shared/stub/thread_set_name.cc delete mode 100644 starboard/shared/stub/time_get_monotonic_now.cc delete mode 100644 starboard/shared/stub/time_get_monotonic_thread_now.cc delete mode 100644 starboard/shared/stub/time_get_now.cc delete mode 100644 starboard/shared/stub/time_is_time_thread_now_supported.cc delete mode 100644 starboard/shared/stub/ui_nav_get_interface.cc delete mode 100644 starboard/shared/stub/user_get_current.cc delete mode 100644 starboard/shared/stub/user_get_property.cc delete mode 100644 starboard/shared/stub/user_get_signed_in.cc delete mode 100644 starboard/shared/stub/window_blur_on_screen_keyboard.cc delete mode 100644 starboard/shared/stub/window_focus_on_screen_keyboard.cc delete mode 100644 starboard/shared/stub/window_get_on_screen_keyboard_bounding_rect.cc delete mode 100644 starboard/shared/stub/window_hide_on_screen_keyboard.cc delete mode 100644 starboard/shared/stub/window_is_on_screen_keyboard_shown.cc delete mode 100644 starboard/shared/stub/window_on_screen_keyboard_is_supported.cc delete mode 100644 starboard/shared/stub/window_on_screen_keyboard_suggestions_supported.cc delete mode 100644 starboard/shared/stub/window_set_on_screen_keyboard_keep_focus.cc delete mode 100644 starboard/shared/stub/window_show_on_screen_keyboard.cc delete mode 100644 starboard/shared/stub/window_update_on_screen_keyboard_suggestions.cc delete mode 100644 third_party/musl/src/starboard/dirent.c delete mode 100644 third_party/musl/src/starboard/errno/__errno_location.c delete mode 100644 third_party/musl/src/starboard/malloc/malloc.c delete mode 100644 third_party/musl/src/starboard/malloc/posix_memalign.c delete mode 100644 third_party/musl/src/starboard/mman/mman.c delete mode 100644 third_party/musl/src/starboard/network/socket.c delete mode 100644 third_party/musl/src/starboard/pthread/pthread.c delete mode 100644 third_party/musl/src/starboard/sched/sched.c delete mode 100644 third_party/musl/src/starboard/stdio/vsnprintf.c delete mode 100644 third_party/musl/src/starboard/stdio/vsscanf.c delete mode 100644 third_party/musl/src/starboard/stdio/vswprintf.c delete mode 100644 third_party/musl/src/starboard/sys/stat.c delete mode 100644 third_party/musl/src/starboard/sys/time/gettimeofday.c delete mode 100644 third_party/musl/src/starboard/time/clock_gettime.c delete mode 100644 third_party/musl/src/starboard/time/gmtime_r.c delete mode 100644 third_party/musl/src/starboard/time/time.c delete mode 100644 third_party/musl/src/starboard/unistd/unistd.c diff --git a/.github/config/evergreen-arm-hardfp.json b/.github/config/evergreen-arm-hardfp.json index 113fd11ab46f..1be38f06260d 100644 --- a/.github/config/evergreen-arm-hardfp.json +++ b/.github/config/evergreen-arm-hardfp.json @@ -13,8 +13,6 @@ }, "platforms": [ "evergreen-arm-hardfp", - "evergreen-arm-hardfp-sbversion-15", - "evergreen-arm-hardfp-sbversion-16", "evergreen-arm-hardfp-sbversion-17" ], "includes": [ @@ -27,24 +25,6 @@ "evergreen_loader_extra_gn_arguments": "use_asan=false is_clang=false", "dimension": "release_version=regex:10.*" }, - { - "name":"sbversion-15", - "platform":"evergreen-arm-hardfp-sbversion-15", - "target_platform":"evergreen-arm-hardfp", - "target_cpu":"target_cpu=\\\"arm\\\"", - "extra_gn_arguments":"use_asan=false", - "evergreen_loader_extra_gn_arguments":"use_asan=false is_clang=false", - "sb_api_version": "15" - }, - { - "name":"sbversion-16", - "platform":"evergreen-arm-hardfp-sbversion-16", - "target_platform":"evergreen-arm-hardfp", - "target_cpu":"target_cpu=\\\"arm\\\"", - "extra_gn_arguments":"use_asan=false", - "evergreen_loader_extra_gn_arguments":"use_asan=false is_clang=false", - "sb_api_version": "16" - }, { "name":"sbversion-17", "platform":"evergreen-arm-hardfp-sbversion-17", diff --git a/.github/config/evergreen-arm-softfp.json b/.github/config/evergreen-arm-softfp.json index 0594f2d36bf9..104809b19832 100644 --- a/.github/config/evergreen-arm-softfp.json +++ b/.github/config/evergreen-arm-softfp.json @@ -13,8 +13,6 @@ }, "platforms": [ "evergreen-arm-softfp", - "evergreen-arm-softfp-sbversion-15", - "evergreen-arm-softfp-sbversion-16", "evergreen-arm-softfp-sbversion-17" ], "includes": [ @@ -26,24 +24,6 @@ "extra_gn_arguments":"use_asan=false", "evergreen_loader_extra_gn_arguments": "target_os=\\\"android\\\" sb_is_evergreen_compatible=true" }, - { - "name":"sbversion-15", - "platform":"evergreen-arm-softfp-sbversion-15", - "target_platform":"evergreen-arm-softfp", - "target_cpu":"target_cpu=\\\"arm\\\"", - "extra_gn_arguments":"use_asan=false", - "sb_api_version":"15", - "evergreen_loader_extra_gn_arguments": "target_os=\\\"android\\\" sb_is_evergreen_compatible=true" - }, - { - "name":"sbversion-16", - "platform":"evergreen-arm-softfp-sbversion-16", - "target_platform":"evergreen-arm-softfp", - "target_cpu":"target_cpu=\\\"arm\\\"", - "extra_gn_arguments":"use_asan=false", - "sb_api_version":"16", - "evergreen_loader_extra_gn_arguments": "target_os=\\\"android\\\" sb_is_evergreen_compatible=true" - }, { "name":"sbversion-17", "platform":"evergreen-arm-softfp-sbversion-17", diff --git a/.github/config/evergreen-arm64.json b/.github/config/evergreen-arm64.json index 981f77a45a68..e11fb6f41055 100644 --- a/.github/config/evergreen-arm64.json +++ b/.github/config/evergreen-arm64.json @@ -3,8 +3,6 @@ "evergreen_loader": "android-arm64", "platforms": [ "evergreen-arm64", - "evergreen-arm64-sbversion-15", - "evergreen-arm64-sbversion-16", "evergreen-arm64-sbversion-17" ], "includes": [ @@ -16,24 +14,6 @@ "extra_gn_arguments":"use_asan=false", "evergreen_loader_extra_gn_arguments": "target_os=\\\"android\\\" sb_is_evergreen_compatible=true" }, - { - "name":"sbversion-15", - "platform":"evergreen-arm64-sbversion-15", - "target_platform":"evergreen-arm64", - "target_cpu":"target_cpu=\\\"arm64\\\"", - "extra_gn_arguments":"use_asan=false", - "sb_api_version":"15", - "evergreen_loader_extra_gn_arguments": "target_os=\\\"android\\\" sb_is_evergreen_compatible=true" - }, - { - "name":"sbversion-16", - "platform":"evergreen-arm64-sbversion-16", - "target_platform":"evergreen-arm64", - "target_cpu":"target_cpu=\\\"arm64\\\"", - "extra_gn_arguments":"use_asan=false", - "sb_api_version":"16", - "evergreen_loader_extra_gn_arguments": "target_os=\\\"android\\\" sb_is_evergreen_compatible=true" - }, { "name":"sbversion-17", "platform":"evergreen-arm64-sbversion-17", diff --git a/.github/config/evergreen-x64.json b/.github/config/evergreen-x64.json index 21bc0e713971..e8b3bb2bc392 100644 --- a/.github/config/evergreen-x64.json +++ b/.github/config/evergreen-x64.json @@ -5,8 +5,6 @@ "on_host_test_shards": ["0", "1", "2", "3", "blackbox", "wpt", "evergreen"], "platforms": [ "evergreen-x64", - "evergreen-x64-sbversion-15", - "evergreen-x64-sbversion-16", "evergreen-x64-sbversion-17" ], "includes": [ @@ -17,22 +15,6 @@ "target_cpu":"target_cpu=\\\"x64\\\"", "extra_gn_arguments":"use_asan=false" }, - { - "name":"sbversion-15", - "platform":"evergreen-x64-sbversion-15", - "target_platform":"evergreen-x64", - "target_cpu":"target_cpu=\\\"x64\\\"", - "extra_gn_arguments":"use_asan=false", - "sb_api_version":"15" - }, - { - "name":"sbversion-16", - "platform":"evergreen-x64-sbversion-16", - "target_platform":"evergreen-x64", - "target_cpu":"target_cpu=\\\"x64\\\"", - "extra_gn_arguments":"use_asan=false", - "sb_api_version":"16" - }, { "name":"sbversion-17", "platform":"evergreen-x64-sbversion-17", diff --git a/.github/config/linux.json b/.github/config/linux.json index 4f591b034796..3c2b325eaa46 100644 --- a/.github/config/linux.json +++ b/.github/config/linux.json @@ -7,8 +7,6 @@ "linux-x64x11", "linux-x64x11-egl", "linux-x64x11-skia", - "linux-x64x11-sbversion-15", - "linux-x64x11-sbversion-16", "linux-x64x11-sbversion-17" ], "includes": [ @@ -27,18 +25,6 @@ "platform":"linux-x64x11-skia", "target_platform":"linux-x64x11-skia" }, - { - "name":"sbversion-15", - "platform":"linux-x64x11-sbversion-15", - "target_platform":"linux-x64x11", - "sb_api_version":"15" - }, - { - "name":"sbversion-16", - "platform":"linux-x64x11-sbversion-16", - "target_platform":"linux-x64x11", - "sb_api_version":"16" - }, { "name":"sbversion-17", "platform":"linux-x64x11-sbversion-17", diff --git a/.github/config/raspi-2.json b/.github/config/raspi-2.json index 1df9213251b9..f5b897329872 100644 --- a/.github/config/raspi-2.json +++ b/.github/config/raspi-2.json @@ -13,8 +13,6 @@ }, "platforms": [ "raspi-2", - "raspi-2-sbversion-15", - "raspi-2-sbversion-16", "raspi-2-sbversion-17" ], "includes": [ @@ -25,22 +23,6 @@ "target_cpu":"target_cpu=\\\"arm\\\"", "extra_gn_arguments": "build_with_separate_cobalt_toolchain=true use_asan=false" }, - { - "name":"sbversion-15", - "platform":"raspi-2-sbversion-15", - "target_platform":"raspi-2", - "target_cpu":"target_cpu=\\\"arm\\\"", - "extra_gn_arguments": "build_with_separate_cobalt_toolchain=true use_asan=false", - "sb_api_version": "15" - }, - { - "name":"sbversion-16", - "platform":"raspi-2-sbversion-16", - "target_platform":"raspi-2", - "target_cpu":"target_cpu=\\\"arm\\\"", - "extra_gn_arguments": "build_with_separate_cobalt_toolchain=true use_asan=false", - "sb_api_version": "16" - }, { "name":"sbversion-17", "platform":"raspi-2-sbversion-17", diff --git a/base/synchronization/condition_variable.h b/base/synchronization/condition_variable.h index 4c84bc200b25..6491e357e216 100644 --- a/base/synchronization/condition_variable.h +++ b/base/synchronization/condition_variable.h @@ -70,11 +70,7 @@ #include "base/synchronization/lock.h" #if defined(STARBOARD) -#if SB_API_VERSION < 16 -#include "starboard/condition_variable.h" -#else #include -#endif // SB_API_VERSION < 16 #else #if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) #include @@ -122,13 +118,8 @@ class BASE_EXPORT ConditionVariable { private: #if defined(STARBOARD) -#if SB_API_VERSION < 16 - SbConditionVariable condition_; - SbMutex* user_mutex_; -#else pthread_cond_t condition_; pthread_mutex_t* user_mutex_; -#endif // SB_API_VERSION < 16 #elif BUILDFLAG(IS_WIN) CHROME_CONDITION_VARIABLE cv_; const raw_ptr srwlock_; diff --git a/base/synchronization/condition_variable_starboard.cc b/base/synchronization/condition_variable_starboard.cc index c46217e0490d..9c4bffae13df 100644 --- a/base/synchronization/condition_variable_starboard.cc +++ b/base/synchronization/condition_variable_starboard.cc @@ -30,10 +30,6 @@ ConditionVariable::ConditionVariable(Lock* user_lock) user_lock_(user_lock) #endif { -#if SB_API_VERSION < 16 - bool result = SbConditionVariableCreate(&condition_, user_mutex_); - DCHECK(result); -#else #if !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) pthread_condattr_t attribute; pthread_condattr_init(&attribute); @@ -47,17 +43,11 @@ ConditionVariable::ConditionVariable(Lock* user_lock) int result = pthread_cond_init(&condition_, nullptr); DCHECK(result == 0); #endif // !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) -#endif // SB_API_VERSION < 16 } ConditionVariable::~ConditionVariable() { -#if SB_API_VERSION < 16 - bool result = SbConditionVariableDestroy(&condition_); - DCHECK(result); -#else int result = pthread_cond_destroy(&condition_); DCHECK(result == 0); -#endif // SB_API_VERSION < 16 } void ConditionVariable::Wait() { @@ -69,14 +59,8 @@ void ConditionVariable::Wait() { #if DCHECK_IS_ON() user_lock_->CheckHeldAndUnmark(); #endif -#if SB_API_VERSION < 16 - SbConditionVariableResult result = - SbConditionVariableWait(&condition_, user_mutex_); - DCHECK(SbConditionVariableIsSignaled(result)); -#else int result = pthread_cond_wait(&condition_, user_mutex_); DCHECK(result == 0); -#endif // SB_API_VERSION < 16 #if DCHECK_IS_ON() user_lock_->CheckUnheldAndMark(); #endif @@ -92,11 +76,6 @@ void ConditionVariable::TimedWait(const TimeDelta& max_time) { #if DCHECK_IS_ON() user_lock_->CheckHeldAndUnmark(); #endif -#if SB_API_VERSION < 16 - SbConditionVariableResult result = - SbConditionVariableWaitTimed(&condition_, user_mutex_, duration); - DCHECK_NE(kSbConditionVariableFailed, result); -#else #if !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) int64_t timeout_time_usec = starboard::CurrentMonotonicTime(); #else @@ -110,30 +89,19 @@ void ConditionVariable::TimedWait(const TimeDelta& max_time) { int result = pthread_cond_timedwait(&condition_, user_mutex_, &timeout); DCHECK(result == 0 || result == ETIMEDOUT); -#endif #if DCHECK_IS_ON() user_lock_->CheckUnheldAndMark(); #endif } void ConditionVariable::Broadcast() { -#if SB_API_VERSION < 16 - bool result = SbConditionVariableBroadcast(&condition_); - DCHECK(result); -#else int result = pthread_cond_broadcast(&condition_); DCHECK(result == 0); -#endif // SB_API_VERSION < 16 } void ConditionVariable::Signal() { -#if SB_API_VERSION < 16 - bool result = SbConditionVariableSignal(&condition_); - DCHECK(result); -#else int result = pthread_cond_signal(&condition_); DCHECK(result == 0); -#endif // SB_API_VERSION < 16 } } // namespace base diff --git a/base/synchronization/lock_impl.h b/base/synchronization/lock_impl.h index 76b692a80d4c..39d7d471b9d1 100644 --- a/base/synchronization/lock_impl.h +++ b/base/synchronization/lock_impl.h @@ -12,11 +12,7 @@ #include "build/build_config.h" #if defined(STARBOARD) -#if SB_API_VERSION < 16 -#include "starboard/common/mutex.h" -#else #include -#endif #include "base/check_op.h" #elif BUILDFLAG(IS_WIN) #include "base/win/windows_types.h" @@ -53,11 +49,7 @@ class BASE_EXPORT LockImpl { friend class base::win::internal::ScopedHandleVerifier; #if defined(STARBOARD) -#if SB_API_VERSION < 16 - using NativeHandle = SbMutex; -#else using NativeHandle = pthread_mutex_t; -#endif // SB_API_VERSION < 16 #elif BUILDFLAG(IS_WIN) using NativeHandle = CHROME_SRWLOCK; #elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) @@ -108,24 +100,13 @@ void LockImpl::Lock() { #if defined(STARBOARD) bool LockImpl::Try() { -#if SB_API_VERSION < 16 - SbMutexResult result = SbMutexAcquireTry(&native_handle_); - DCHECK_NE(kSbMutexDestroyed, result); - return SbMutexIsSuccess(result); -#else int result = pthread_mutex_trylock(&native_handle_); return result == 0; -#endif // SB_API_VERSION < 16 } void LockImpl::Unlock() { -#if SB_API_VERSION < 16 - bool result = SbMutexRelease(&native_handle_); - DCHECK(result); -#else int result = pthread_mutex_unlock(&native_handle_); DCHECK(result == 0); -#endif //SB_API_VERSION < 16 } #elif BUILDFLAG(IS_WIN) bool LockImpl::Try() { diff --git a/base/synchronization/lock_impl_starboard.cc b/base/synchronization/lock_impl_starboard.cc index 545ba4c9646b..7b25b0042c01 100644 --- a/base/synchronization/lock_impl_starboard.cc +++ b/base/synchronization/lock_impl_starboard.cc @@ -16,41 +16,22 @@ #include "base/check_op.h" -#if SB_API_VERSION < 16 -#include "starboard/mutex.h" -#endif // SB_API_VERSION < 16 - namespace base { namespace internal { LockImpl::LockImpl() { -#if SB_API_VERSION < 16 - bool result = SbMutexCreate(&native_handle_); - DCHECK(result); -#else int result = pthread_mutex_init(&native_handle_, nullptr); DCHECK_EQ(result, 0); -#endif // SB_API_VERSION < 16 } LockImpl::~LockImpl() { -#if SB_API_VERSION < 16 - bool result = SbMutexDestroy(&native_handle_); - DCHECK(result); -#else int result = pthread_mutex_destroy(&native_handle_); DCHECK_EQ(result, 0); -#endif // SB_API_VERSION < 16 } void LockImpl::LockInternal() { -#if SB_API_VERSION < 16 - SbMutexResult result = SbMutexAcquire(&native_handle_); - DCHECK_NE(kSbMutexDestroyed, result); -#else int result = pthread_mutex_lock(&native_handle_); DCHECK_EQ(result, 0); -#endif // SB_API_VERSION < 16 } } // namespace internal diff --git a/base/threading/platform_thread.h b/base/threading/platform_thread.h index 0623f595f790..edcf0af6c5b5 100644 --- a/base/threading/platform_thread.h +++ b/base/threading/platform_thread.h @@ -55,11 +55,7 @@ static_assert(std::is_integral_v, "Always an integer value."); class PlatformThreadHandle { public: #if defined(STARBOARD) -#if SB_API_VERSION < 16 - typedef SbThread Handle; -#else typedef pthread_t Handle; -#endif #elif BUILDFLAG(IS_WIN) typedef void* Handle; #elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) diff --git a/base/threading/platform_thread_ref.h b/base/threading/platform_thread_ref.h index 04142c433765..b87cf099aa0c 100644 --- a/base/threading/platform_thread_ref.h +++ b/base/threading/platform_thread_ref.h @@ -37,11 +37,7 @@ namespace base { class PlatformThreadRef { public: #if defined(STARBOARD) -#if SB_API_VERSION < 16 - typedef SbThread RefType; -#else using RefType = pthread_t; -#endif #elif BUILDFLAG(IS_WIN) using RefType = DWORD; #elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) diff --git a/base/threading/platform_thread_starboard.cc b/base/threading/platform_thread_starboard.cc index 594ede6c08f1..3a7513fdf8a0 100644 --- a/base/threading/platform_thread_starboard.cc +++ b/base/threading/platform_thread_starboard.cc @@ -159,21 +159,13 @@ PlatformThreadId PlatformThread::CurrentId() { // static PlatformThreadRef PlatformThread::CurrentRef() { -#if SB_API_VERSION < 16 - return PlatformThreadRef(SbThreadGetCurrent()); -#else return PlatformThreadRef(pthread_self()); -#endif // SB_API_VERSION < 16 } // static PlatformThreadHandle PlatformThread::CurrentHandle() { -#if SB_API_VERSION < 16 - return PlatformThreadHandle(SbThreadGetCurrent()); -#else return PlatformThreadHandle(pthread_self()); -#endif // SB_API_VERSION < 16 } // static @@ -225,19 +217,11 @@ void PlatformThread::Join(PlatformThreadHandle thread_handle) { // the thread referred to by |thread_handle| may still be running long-lived / // blocking tasks. internal::AssertBlockingAllowed(); -#if SB_API_VERSION < 16 - SbThreadJoin(thread_handle.platform_handle(), NULL); -#else pthread_join(thread_handle.platform_handle(), NULL); -#endif // SB_API_VERSION < 16 } void PlatformThread::Detach(PlatformThreadHandle thread_handle) { -#if SB_API_VERSION < 16 - SbThreadDetach(thread_handle.platform_handle()); -#else pthread_detach(thread_handle.platform_handle()); -#endif // SB_API_VERSION < 16 } void internal::SetCurrentThreadTypeImpl(ThreadType /* thread_type */, MessagePumpType /*pump_type_hint*/) { diff --git a/cobalt/browser/application.cc b/cobalt/browser/application.cc index 7b852d31905d..8649c57d7f29 100644 --- a/cobalt/browser/application.cc +++ b/cobalt/browser/application.cc @@ -127,17 +127,10 @@ std::string GetDevServersListenIp() { // Default to INADDR_ANY std::string listen_ip(ip_v6 ? "::" : "0.0.0.0"); -#if SB_API_VERSION < 15 - // Desktop PCs default to loopback. - if (SbSystemGetDeviceType() == kSbSystemDeviceTypeDesktopPC) { - listen_ip = ip_v6 ? "::1" : "127.0.0.1"; - } -#else if (starboard::GetSystemPropertyString(kSbSystemPropertyDeviceType) == starboard::kSystemDeviceTypeDesktopPC) { listen_ip = ip_v6 ? "::1" : "127.0.0.1"; } -#endif #if defined(ENABLE_DEBUG_COMMAND_LINE_SWITCHES) base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); @@ -901,12 +894,7 @@ Application::Application(const base::Closure& quit_closure, bool should_preload, AddCrashHandlerAnnotations(platform_info); #if SB_IS(EVERGREEN) -#if SB_API_VERSION < 16 - if (SbSystemGetExtension(kCobaltExtensionInstallationManagerName) && - !command_line->HasSwitch(switches::kDisableUpdaterModule)) { -#else if (SbSystemGetExtension(kCobaltExtensionInstallationManagerName)) { -#endif uint64_t update_check_delay_sec = cobalt::updater::kDefaultUpdateCheckDelaySeconds; if (command_line->HasSwitch(browser::switches::kUpdateCheckDelaySeconds)) { diff --git a/cobalt/browser/switches.cc b/cobalt/browser/switches.cc index 7a3b5026324e..6e569a59e042 100644 --- a/cobalt/browser/switches.cc +++ b/cobalt/browser/switches.cc @@ -243,14 +243,6 @@ const char kDisableTimerResolutionLimitHelp[] = "removed and the resolution will be 1us (or larger depending on the " "platform."; -#if SB_API_VERSION < 16 -const char kDisableUpdaterModule[] = "disable_updater_module"; -const char kDisableUpdaterModuleHelp[] = - "Disables the Cobalt Evergreen UpdaterModule which is responsible for " - "downloading and installing new Cobalt updates. Passing the flag is " - "equivalent to opting out from further updates."; -#endif - const char kEnableSkiaRasterizer[] = "enable_skia_rasterizer"; const char kEnableSkiaRasterizerHelp[] = "Enables/disables the skia rendering engine. If it's disabled, direct-gles" @@ -487,9 +479,6 @@ std::string HelpMessage() { {kDisableJavaScriptJit, kDisableJavaScriptJitHelp}, {kDisableMapToMesh, kDisableMapToMeshHelp}, {kDisableTimerResolutionLimit, kDisableTimerResolutionLimitHelp}, -#if SB_API_VERSION < 16 - {kDisableUpdaterModule, kDisableUpdaterModuleHelp}, -#endif {kEnableSkiaRasterizer, kEnableSkiaRasterizerHelp}, {kEncodedImageCacheSizeInBytes, kEncodedImageCacheSizeInBytesHelp}, {kForceMigrationForStoragePartitioning, diff --git a/cobalt/browser/switches.h b/cobalt/browser/switches.h index 982389104553..faab46122d04 100644 --- a/cobalt/browser/switches.h +++ b/cobalt/browser/switches.h @@ -98,10 +98,6 @@ extern const char kDisableMapToMesh[]; extern const char kDisableMapToMeshHelp[]; extern const char kDisableTimerResolutionLimit[]; extern const char kDisableTimerResolutionLimitHelp[]; -#if SB_API_VERSION < 16 -extern const char kDisableUpdaterModule[]; -extern const char kDisableUpdaterModuleHelp[]; -#endif extern const char kEnableSkiaRasterizer[]; extern const char kEnableSkiaRasterizerHelp[]; extern const char kEncodedImageCacheSizeInBytes[]; diff --git a/cobalt/browser/user_agent_platform_info.cc b/cobalt/browser/user_agent_platform_info.cc index 5c0d65895531..a6563bf9b43d 100644 --- a/cobalt/browser/user_agent_platform_info.cc +++ b/cobalt/browser/user_agent_platform_info.cc @@ -110,47 +110,6 @@ void GetUserAgentInputMap( namespace { -#if SB_API_VERSION < 15 - -struct DeviceTypeName { - SbSystemDeviceType device_type; - char device_type_string[10]; -}; - -const DeviceTypeName kDeviceTypeStrings[] = { - {kSbSystemDeviceTypeBlueRayDiskPlayer, "BDP"}, - {kSbSystemDeviceTypeGameConsole, "GAME"}, - {kSbSystemDeviceTypeOverTheTopBox, "OTT"}, - {kSbSystemDeviceTypeSetTopBox, "STB"}, - {kSbSystemDeviceTypeTV, "TV"}, - {kSbSystemDeviceTypeAndroidTV, "ATV"}, - {kSbSystemDeviceTypeDesktopPC, "DESKTOP"}, - {kSbSystemDeviceTypeVideoProjector, "PROJECTOR"}, - {kSbSystemDeviceTypeUnknown, "UNKNOWN"}}; - -std::string CreateDeviceTypeString(SbSystemDeviceType device_type) { - for (auto& map : kDeviceTypeStrings) { - if (map.device_type == device_type) { - return std::string(map.device_type_string); - } - } - NOTREACHED(); - return "UNKNOWN"; -} - -#if !defined(COBALT_BUILD_TYPE_GOLD) -SbSystemDeviceType GetDeviceType(std::string device_type_string) { - for (auto& map : kDeviceTypeStrings) { - if (!SbStringCompareNoCase(map.device_type_string, - device_type_string.c_str())) { - return map.device_type; - } - } - return kSbSystemDeviceTypeUnknown; -} -#endif -#endif // SB_API_VERSION < 15 - static bool isAsciiAlphaDigit(int c) { return base::IsAsciiAlpha(c) || base::IsAsciiDigit(c); } @@ -320,15 +279,10 @@ void InitializeUserAgentPlatformInfoFields(UserAgentPlatformInfo& info) { info.set_aux_field(value); } -#if SB_API_VERSION >= 15 result = SbSystemGetProperty(kSbSystemPropertyDeviceType, value, kSystemPropertyMaxLength); SB_DCHECK(result); info.set_device_type(value); -#else - // Fill platform info if it is a hardware TV device. - info.set_device_type(SbSystemGetDeviceType()); -#endif // Chipset model number result = SbSystemGetProperty(kSbSystemPropertyChipsetModelNumber, value, @@ -395,11 +349,7 @@ void InitializeUserAgentPlatformInfoFields(UserAgentPlatformInfo& info) { info.set_original_design_manufacturer(input.second); LOG(INFO) << "Set original design manufacturer to " << input.second; } else if (!input.first.compare("device_type")) { -#if SB_API_VERSION < 15 - info.set_device_type(GetDeviceType(input.second)); -#else info.set_device_type(input.second); -#endif LOG(INFO) << "Set device type to " << input.second; } else if (!input.first.compare("chipset_model_number")) { info.set_chipset_model_number(input.second); @@ -485,12 +435,6 @@ void UserAgentPlatformInfo::set_original_design_manufacturer( } } -#if SB_API_VERSION < 15 -void UserAgentPlatformInfo::set_device_type(SbSystemDeviceType device_type) { - device_type_ = device_type; - device_type_string_ = CreateDeviceTypeString(device_type_); -} -#endif void UserAgentPlatformInfo::set_device_type(const std::string& device_type) { device_type_string_ = device_type; } diff --git a/cobalt/browser/user_agent_platform_info.h b/cobalt/browser/user_agent_platform_info.h index f9267345dff2..d0a5cd1f5e23 100644 --- a/cobalt/browser/user_agent_platform_info.h +++ b/cobalt/browser/user_agent_platform_info.h @@ -44,10 +44,6 @@ class UserAgentPlatformInfo : public web::UserAgentPlatformInfo { return original_design_manufacturer_; } -#if SB_API_VERSION < 15 - SbSystemDeviceType device_type() const override { return device_type_; } -#endif - const std::string& device_type_string() const override { return device_type_string_; } @@ -101,9 +97,6 @@ class UserAgentPlatformInfo : public web::UserAgentPlatformInfo { void set_os_name_and_version(const std::string& os_name_and_version); void set_original_design_manufacturer( base::Optional original_design_manufacturer); -#if SB_API_VERSION < 15 - void set_device_type(SbSystemDeviceType device_type); -#endif void set_device_type(const std::string& device_type); void set_chipset_model_number( base::Optional chipset_model_number); @@ -132,9 +125,7 @@ class UserAgentPlatformInfo : public web::UserAgentPlatformInfo { std::string starboard_version_; std::string os_name_and_version_; base::Optional original_design_manufacturer_; -#if SB_API_VERSION < 15 - SbSystemDeviceType device_type_ = kSbSystemDeviceTypeUnknown; -#endif + std::string device_type_string_; base::Optional chipset_model_number_; base::Optional model_year_; diff --git a/cobalt/browser/web_module.cc b/cobalt/browser/web_module.cc index 09b65e0f372c..5b32ed451141 100644 --- a/cobalt/browser/web_module.cc +++ b/cobalt/browser/web_module.cc @@ -79,11 +79,7 @@ #include "cobalt/web/environment_settings.h" #include "cobalt/web/event.h" #include "cobalt/web/url.h" -#if SB_API_VERSION < 16 -#include "starboard/accessibility.h" -#else // SB_API_VERSION < 16 #include "starboard/extension/accessibility.h" -#endif // SB_API_VERSION < 16 #include "starboard/gles.h" #if defined(ENABLE_DEBUGGER) diff --git a/cobalt/dom/captions/system_caption_settings.cc b/cobalt/dom/captions/system_caption_settings.cc index 222d9d5168ec..b0f978f631ff 100644 --- a/cobalt/dom/captions/system_caption_settings.cc +++ b/cobalt/dom/captions/system_caption_settings.cc @@ -27,11 +27,7 @@ #include "cobalt/dom/captions/caption_opacity_percentage.h" #include "cobalt/dom/captions/caption_state.h" #include "cobalt/web/event_target.h" -#if SB_API_VERSION < 16 -#include "starboard/accessibility.h" -#else // SB_API_VERSION < 16 #include "starboard/extension/accessibility.h" -#endif // SB_API_VERSION < 16 #include "starboard/memory.h" namespace cobalt { diff --git a/cobalt/dom/captions/system_caption_settings.h b/cobalt/dom/captions/system_caption_settings.h index 1446fa77fdc6..359689ff969f 100644 --- a/cobalt/dom/captions/system_caption_settings.h +++ b/cobalt/dom/captions/system_caption_settings.h @@ -28,11 +28,7 @@ #include "cobalt/dom/captions/caption_state.h" #include "cobalt/script/environment_settings.h" #include "cobalt/web/event_target.h" -#if SB_API_VERSION < 16 -#include "starboard/accessibility.h" -#else // SB_API_VERSION < 16 #include "starboard/extension/accessibility.h" -#endif // SB_API_VERSION < 16 namespace cobalt { namespace dom { diff --git a/cobalt/dom/html_media_element.cc b/cobalt/dom/html_media_element.cc index 6aa4a1713616..e811bfcd6440 100644 --- a/cobalt/dom/html_media_element.cc +++ b/cobalt/dom/html_media_element.cc @@ -706,16 +706,12 @@ void HTMLMediaElement::ScheduleEvent(const scoped_refptr& event) { } std::string HTMLMediaElement::h5vcc_audio_connectors() const { -#if SB_API_VERSION >= 15 if (!player_) { return ""; } std::vector configs = player_->GetAudioConnectors(); return base::JoinString(configs, ";"); -#else // SB_API_VERSION >= 15 - return ""; -#endif // SB_API_VERSION >= 15 } void HTMLMediaElement::CreateMediaPlayer() { diff --git a/cobalt/dom/keyboard_event.cc b/cobalt/dom/keyboard_event.cc index ad854118b1db..37cda49e9a7d 100644 --- a/cobalt/dom/keyboard_event.cc +++ b/cobalt/dom/keyboard_event.cc @@ -337,10 +337,8 @@ std::string KeyboardEvent::NonPrintableKey(int32_t key_code) const { return "MediaStop"; case keycode::kMediaPlayPause: return "MediaPlayPause"; -#if SB_API_VERSION >= 15 case keycode::kMediaRecord: return "MediaRecord"; -#endif case keycode::kMediaLaunchMail: return "LaunchMail"; case keycode::kMediaLaunchMediaSelect: diff --git a/cobalt/dom/keyboard_event_test.cc b/cobalt/dom/keyboard_event_test.cc index 0f9843e72881..c189ccc1ddc4 100644 --- a/cobalt/dom/keyboard_event_test.cc +++ b/cobalt/dom/keyboard_event_test.cc @@ -135,14 +135,12 @@ TEST_F(KeyboardEventTest, CanGetKeyIdentifierAndKeyAndCode) { EXPECT_EQ(keyboard_event_space->key(), " "); EXPECT_EQ(keyboard_event_space->code(), "Space"); -#if SB_API_VERSION >= 15 init.set_key_code(keycode::kMediaRecord); scoped_refptr keyboard_event_record = new KeyboardEvent("keydown", init); EXPECT_EQ(keyboard_event_record->key_identifier(), "MediaRecord"); EXPECT_EQ(keyboard_event_record->key(), "MediaRecord"); EXPECT_EQ(keyboard_event_record->code(), "MediaRecord"); -#endif } TEST_F(KeyboardEventTest, CanGetAltKey) { diff --git a/cobalt/dom/keycode.h b/cobalt/dom/keycode.h index afda18fa6df4..5623e52f745b 100644 --- a/cobalt/dom/keycode.h +++ b/cobalt/dom/keycode.h @@ -200,9 +200,7 @@ enum { // Not present in Windows virtual key codes, but would be used by the client. kMediaRewind = 0xE3, kMediaFastForward = 0xE4, -#if SB_API_VERSION >= 15 kMediaRecord = 0x1A0, -#endif }; } // namespace keycode diff --git a/cobalt/h5vcc/h5vcc_accessibility.cc b/cobalt/h5vcc/h5vcc_accessibility.cc index a57f0ff98144..70b09024293d 100644 --- a/cobalt/h5vcc/h5vcc_accessibility.cc +++ b/cobalt/h5vcc/h5vcc_accessibility.cc @@ -20,11 +20,7 @@ #include "cobalt/base/accessibility_settings_changed_event.h" #include "cobalt/base/accessibility_text_to_speech_settings_changed_event.h" #include "cobalt/browser/switches.h" -#if SB_API_VERSION < 16 -#include "starboard/accessibility.h" -#else // SB_API_VERSION < 16 #include "starboard/extension/accessibility.h" -#endif // SB_API_VERSION < 16 #include "starboard/memory.h" namespace cobalt { diff --git a/cobalt/media/base/sbplayer_bridge.cc b/cobalt/media/base/sbplayer_bridge.cc index 3d0305fb7fff..e9a7cad71ccd 100644 --- a/cobalt/media/base/sbplayer_bridge.cc +++ b/cobalt/media/base/sbplayer_bridge.cc @@ -73,11 +73,7 @@ void SetStreamInfo(const SbMediaAudioStreamInfo& stream_info, SbMediaAudioSampleInfo* sample_info) { DCHECK(sample_info); -#if SB_API_VERSION >= 15 sample_info->stream_info = stream_info; -#else // SB_API_VERSION >= 15 - *sample_info = stream_info; -#endif // SB_API_VERSION >= 15} } void SetStreamInfo( @@ -96,12 +92,7 @@ void SetStreamInfo( void SetStreamInfo(const SbMediaVideoStreamInfo& stream_info, SbMediaVideoSampleInfo* sample_info) { DCHECK(sample_info); - -#if SB_API_VERSION >= 15 sample_info->stream_info = stream_info; -#else // SB_API_VERSION >= 15 - *sample_info = stream_info; -#endif // SB_API_VERSION >= 15} } void SetDiscardPadding( @@ -120,12 +111,10 @@ void SetDiscardPadding( SbMediaAudioSampleInfo* sample_info) { DCHECK(sample_info); -#if SB_API_VERSION >= 15 sample_info->discarded_duration_from_front = discard_padding.first.InMicroseconds(); sample_info->discarded_duration_from_back = discard_padding.second.InMicroseconds(); -#endif // SB_API_VERSION >= 15} } } // namespace @@ -467,7 +456,6 @@ void SbPlayerBridge::GetInfo(uint32* video_frames_decoded, GetInfo_Locked(video_frames_decoded, video_frames_dropped, media_time); } -#if SB_API_VERSION >= 15 std::vector SbPlayerBridge::GetAudioConfigurations() { base::AutoLock auto_lock(lock_); @@ -496,7 +484,6 @@ SbPlayerBridge::GetAudioConfigurations() { return configurations; } -#endif // SB_API_VERSION >= 15 #if SB_HAS(PLAYER_WITH_URL) void SbPlayerBridge::GetUrlPlayerBufferedTimeRanges( @@ -538,11 +525,7 @@ void SbPlayerBridge::GetVideoResolution(int* frame_width, int* frame_height) { DCHECK(SbPlayerIsValid(player_)); -#if SB_API_VERSION >= 15 SbPlayerInfo out_player_info; -#else // SB_API_VERSION >= 15 - SbPlayerInfo2 out_player_info; -#endif // SB_API_VERSION >= 15 sbplayer_interface_->GetInfo(player_, &out_player_info); video_stream_info_.frame_width = out_player_info.frame_width; @@ -561,11 +544,7 @@ TimeDelta SbPlayerBridge::GetDuration() { DCHECK(SbPlayerIsValid(player_)); -#if SB_API_VERSION >= 15 SbPlayerInfo info; -#else // SB_API_VERSION >= 15 - SbPlayerInfo2 info; -#endif // SB_API_VERSION >= 15 sbplayer_interface_->GetInfo(player_, &info); if (info.duration == SB_PLAYER_NO_DURATION) { // URL-based player may not have loaded asset yet, so map no duration to 0. @@ -583,11 +562,7 @@ TimeDelta SbPlayerBridge::GetStartDate() { DCHECK(SbPlayerIsValid(player_)); -#if SB_API_VERSION >= 15 SbPlayerInfo info; -#else // SB_API_VERSION >= 15 - SbPlayerInfo2 info; -#endif // SB_API_VERSION >= 15 sbplayer_interface_->GetInfo(player_, &info); return TimeDelta::FromMicroseconds(info.start_date); } @@ -760,22 +735,13 @@ void SbPlayerBridge::CreatePlayer() { SbPlayerCreationParam creation_param = {}; creation_param.drm_system = drm_system_; -#if SB_API_VERSION >= 15 creation_param.audio_stream_info = audio_stream_info_; creation_param.video_stream_info = video_stream_info_; -#else // SB_API_VERSION >= 15 - creation_param.audio_sample_info = audio_stream_info_; - creation_param.video_sample_info = video_stream_info_; -#endif // SB_API_VERSION >= 15 // TODO: This is temporary for supporting background media playback. // Need to be removed with media refactor. if (!is_visible) { -#if SB_API_VERSION >= 15 creation_param.video_stream_info.codec = kSbMediaVideoCodecNone; -#else // SB_API_VERSION >= 15 - creation_param.video_sample_info.codec = kSbMediaVideoCodecNone; -#endif // SB_API_VERSION >= 15 } creation_param.output_mode = output_mode_; DCHECK_EQ(sbplayer_interface_->GetPreferredOutputMode(&creation_param), @@ -1010,11 +976,7 @@ void SbPlayerBridge::GetInfo_Locked(uint32* video_frames_decoded, DCHECK(SbPlayerIsValid(player_)); -#if SB_API_VERSION >= 15 SbPlayerInfo info; -#else // SB_API_VERSION >= 15 - SbPlayerInfo2 info; -#endif // SB_API_VERSION >= 15 sbplayer_interface_->GetInfo(player_, &info); if (media_time) { @@ -1259,14 +1221,8 @@ SbPlayerOutputMode SbPlayerBridge::ComputeSbPlayerOutputMode( SbPlayerOutputMode default_output_mode) const { SbPlayerCreationParam creation_param = {}; creation_param.drm_system = drm_system_; - -#if SB_API_VERSION >= 15 creation_param.audio_stream_info = audio_stream_info_; creation_param.video_stream_info = video_stream_info_; -#else // SB_API_VERSION >= 15 - creation_param.audio_sample_info = audio_stream_info_; - creation_param.video_sample_info = video_stream_info_; -#endif // SB_API_VERSION >= 15 if (default_output_mode != kSbPlayerOutputModeDecodeToTexture && video_stream_info_.codec != kSbMediaVideoCodecNone) { diff --git a/cobalt/media/base/sbplayer_bridge.h b/cobalt/media/base/sbplayer_bridge.h index f6cc6879c12b..98ab7fdf4ba8 100644 --- a/cobalt/media/base/sbplayer_bridge.h +++ b/cobalt/media/base/sbplayer_bridge.h @@ -118,9 +118,7 @@ class SbPlayerBridge { void SetPlaybackRate(double playback_rate); void GetInfo(uint32* video_frames_decoded, uint32* video_frames_dropped, base::TimeDelta* media_time); -#if SB_API_VERSION >= 15 std::vector GetAudioConfigurations(); -#endif // SB_API_VERSION >= 15 #if SB_HAS(PLAYER_WITH_URL) void GetUrlPlayerBufferedTimeRanges(base::TimeDelta* buffer_start_time, diff --git a/cobalt/media/base/sbplayer_interface.cc b/cobalt/media/base/sbplayer_interface.cc index 6b367d4c15ef..37de8f32b5ce 100644 --- a/cobalt/media/base/sbplayer_interface.cc +++ b/cobalt/media/base/sbplayer_interface.cc @@ -97,11 +97,7 @@ void DefaultSbPlayerInterface::Seek(SbPlayer player, base::TimeDelta seek_to_timestamp, int ticket) { media_metrics_provider_.StartTrackingAction(MediaAction::SBPLAYER_SEEK); -#if SB_API_VERSION >= 15 SbPlayerSeek(player, seek_to_timestamp.InMicroseconds(), ticket); -#else // SB_API_VERSION >= 15 - SbPlayerSeek2(player, seek_to_timestamp.InMicroseconds(), ticket); -#endif // SB_API_VERSION >= 15 media_metrics_provider_.EndTrackingAction(MediaAction::SBPLAYER_SEEK); } @@ -113,13 +109,8 @@ void DefaultSbPlayerInterface::WriteSamples( SbPlayer player, SbMediaType sample_type, const SbPlayerSampleInfo* sample_infos, int number_of_sample_infos) { DCHECK(!IsEnhancedAudioExtensionEnabled()); -#if SB_API_VERSION >= 15 SbPlayerWriteSamples(player, sample_type, sample_infos, number_of_sample_infos); -#else // SB_API_VERSION >= 15 - SbPlayerWriteSample2(player, sample_type, sample_infos, - number_of_sample_infos); -#endif // SB_API_VERSION >= 15 } void DefaultSbPlayerInterface::WriteSamples( @@ -170,15 +161,9 @@ void DefaultSbPlayerInterface::SetVolume(SbPlayer player, double volume) { } void DefaultSbPlayerInterface::GetInfo(SbPlayer player, -#if SB_API_VERSION >= 15 SbPlayerInfo* out_player_info) { media_metrics_provider_.StartTrackingAction(MediaAction::SBPLAYER_GET_INFO); SbPlayerGetInfo(player, out_player_info); -#else // SB_API_VERSION >= 15 - SbPlayerInfo2* out_player_info2) { - media_metrics_provider_.StartTrackingAction(MediaAction::SBPLAYER_GET_INFO); - SbPlayerGetInfo2(player, out_player_info2); -#endif // SB_API_VERSION >= 15 media_metrics_provider_.EndTrackingAction(MediaAction::SBPLAYER_GET_INFO); } @@ -223,8 +208,6 @@ void DefaultSbPlayerInterface::GetUrlPlayerExtraInfo( } #endif // SB_HAS(PLAYER_WITH_URL) -#if SB_API_VERSION >= 15 - bool DefaultSbPlayerInterface::GetAudioConfiguration( SbPlayer player, int index, SbMediaAudioConfiguration* out_audio_configuration) { @@ -237,7 +220,5 @@ bool DefaultSbPlayerInterface::GetAudioConfiguration( return audio_configuration; } -#endif // SB_API_VERSION >= 15 - } // namespace media } // namespace cobalt diff --git a/cobalt/media/base/sbplayer_interface.h b/cobalt/media/base/sbplayer_interface.h index 4aba0395eaa0..8a9f18ef8417 100644 --- a/cobalt/media/base/sbplayer_interface.h +++ b/cobalt/media/base/sbplayer_interface.h @@ -62,11 +62,8 @@ class SbPlayerInterface { virtual bool SetPlaybackRate(SbPlayer player, double playback_rate) = 0; virtual void SetVolume(SbPlayer player, double volume) = 0; -#if SB_API_VERSION >= 15 virtual void GetInfo(SbPlayer player, SbPlayerInfo* out_player_info) = 0; -#else // SB_API_VERSION >= 15 - virtual void GetInfo(SbPlayer player, SbPlayerInfo2* out_player_info2) = 0; -#endif // SB_API_VERSION >= 15 + virtual SbDecodeTarget GetCurrentFrame(SbPlayer player) = 0; #if SB_HAS(PLAYER_WITH_URL) @@ -84,11 +81,9 @@ class SbPlayerInterface { SbPlayer player, SbUrlPlayerExtraInfo* out_url_player_info) = 0; #endif // SB_HAS(PLAYER_WITH_URL) -#if SB_API_VERSION >= 15 virtual bool GetAudioConfiguration( SbPlayer player, int index, SbMediaAudioConfiguration* out_audio_configuration) = 0; -#endif // SB_API_VERSION >= 15 // disabled by default, but can be enabled via h5vcc setting. void EnableCValStats(bool should_enable) { @@ -131,11 +126,7 @@ class DefaultSbPlayerInterface final : public SbPlayerInterface { int height) override; bool SetPlaybackRate(SbPlayer player, double playback_rate) override; void SetVolume(SbPlayer player, double volume) override; -#if SB_API_VERSION >= 15 void GetInfo(SbPlayer player, SbPlayerInfo* out_player_info) override; -#else // SB_API_VERSION >= 15 - void GetInfo(SbPlayer player, SbPlayerInfo2* out_player_info2) override; -#endif // SB_API_VERSION >= 15 SbDecodeTarget GetCurrentFrame(SbPlayer player) override; #if SB_HAS(PLAYER_WITH_URL) @@ -151,11 +142,9 @@ class DefaultSbPlayerInterface final : public SbPlayerInterface { SbPlayer player, SbUrlPlayerExtraInfo* out_url_player_info) override; #endif // SB_HAS(PLAYER_WITH_URL) -#if SB_API_VERSION >= 15 bool GetAudioConfiguration( SbPlayer player, int index, SbMediaAudioConfiguration* out_audio_configuration) override; -#endif // SB_API_VERSION >= 15 private: void (*enhanced_audio_player_write_samples_)( diff --git a/cobalt/media/decoder_buffer_allocator.cc b/cobalt/media/decoder_buffer_allocator.cc index 6c91b45a3592..eb3607ef7551 100644 --- a/cobalt/media/decoder_buffer_allocator.cc +++ b/cobalt/media/decoder_buffer_allocator.cc @@ -127,13 +127,7 @@ int DecoderBufferAllocator::GetAudioBufferBudget() const { return SbMediaGetAudioBufferBudget(); } -int DecoderBufferAllocator::GetBufferAlignment() const { -#if SB_API_VERSION < 16 - return SbMediaGetBufferAlignment(); -#else - return sizeof(void*); -#endif // SB_API_VERSION < 16 -} +int DecoderBufferAllocator::GetBufferAlignment() const { return sizeof(void*); } int DecoderBufferAllocator::GetBufferPadding() const { return SbMediaGetBufferPadding(); diff --git a/cobalt/media/media_module.cc b/cobalt/media/media_module.cc index f245ac43a9e3..76399ead1d08 100644 --- a/cobalt/media/media_module.cc +++ b/cobalt/media/media_module.cc @@ -200,7 +200,6 @@ bool MediaModule::SetConfiguration(const std::string& name, int32 value) { LOG(INFO) << (value ? "Enabling" : "Disabling") << " media metrics collection."; return true; -#if SB_API_VERSION >= 15 } else if (name == "AudioWriteDurationLocal" && value > 0) { audio_write_duration_local_ = base::TimeDelta::FromMicroseconds(value); LOG(INFO) << "Set AudioWriteDurationLocal to " @@ -211,7 +210,6 @@ bool MediaModule::SetConfiguration(const std::string& name, int32 value) { LOG(INFO) << "Set AudioWriteDurationRemote to " << audio_write_duration_remote_.InMicroseconds(); return true; -#endif // SB_API_VERSION >= 15 } else if (name == "PlayerConfiguration.DecodeToTexturePreferred") { if (sbplayer_interface_->SetDecodeToTexturePreferred(value)) { LOG(INFO) << "Set DecodeToTexturePreferred to " @@ -265,10 +263,7 @@ std::unique_ptr MediaModule::CreateWebMediaPlayer( base::Unretained(this)), client, this, options_.allow_resume_after_suspend, max_audio_samples_per_write_, force_punch_out_by_default_, -#if SB_API_VERSION >= 15 - audio_write_duration_local_, audio_write_duration_remote_, -#endif // SB_API_VERSION >= 15 - &media_log_)); + audio_write_duration_local_, audio_write_duration_remote_, &media_log_)); } void MediaModule::Suspend() { diff --git a/cobalt/media/media_module.h b/cobalt/media/media_module.h index f29973a1f615..591e95474345 100644 --- a/cobalt/media/media_module.h +++ b/cobalt/media/media_module.h @@ -133,12 +133,10 @@ class MediaModule : public WebMediaPlayerFactory, // previous behavior. bool force_punch_out_by_default_ = false; -#if SB_API_VERSION >= 15 base::TimeDelta audio_write_duration_local_ = base::TimeDelta::FromMicroseconds(kSbPlayerWriteDurationLocal); base::TimeDelta audio_write_duration_remote_ = base::TimeDelta::FromMicroseconds(kSbPlayerWriteDurationRemote); -#endif // SB_API_VERSION >= 15 DecoderBufferAllocator decoder_buffer_allocator_; }; diff --git a/cobalt/ui_navigation/interface.cc b/cobalt/ui_navigation/interface.cc index 372ef681f207..e4ae99fcff26 100644 --- a/cobalt/ui_navigation/interface.cc +++ b/cobalt/ui_navigation/interface.cc @@ -143,31 +143,6 @@ void DoBatchUpdate(void (*update_function)(void*), void* context) { NativeInterface InitializeInterface() { NativeInterface interface = {0}; -#if SB_API_VERSION < 16 - SbUiNavInterface sb_ui_interface = {0}; - if (SbUiNavGetInterface(&sb_ui_interface)) { - interface.create_item = sb_ui_interface.create_item; - interface.destroy_item = sb_ui_interface.destroy_item; - interface.set_item_bounds = nullptr; - interface.get_item_bounds = nullptr; - interface.set_focus = sb_ui_interface.set_focus; - interface.set_item_enabled = sb_ui_interface.set_item_enabled; - interface.set_item_dir = sb_ui_interface.set_item_dir; - interface.set_item_size = sb_ui_interface.set_item_size; - interface.set_item_transform = sb_ui_interface.set_item_transform; - interface.get_item_focus_transform = - sb_ui_interface.get_item_focus_transform; - interface.get_item_focus_vector = sb_ui_interface.get_item_focus_vector; - interface.set_item_container_window = - sb_ui_interface.set_item_container_window; - interface.set_item_container_item = sb_ui_interface.set_item_container_item; - interface.set_item_content_offset = sb_ui_interface.set_item_content_offset; - interface.get_item_content_offset = sb_ui_interface.get_item_content_offset; - interface.set_item_focus_duration = sb_ui_interface.set_item_focus_duration; - interface.do_batch_update = sb_ui_interface.do_batch_update; - return interface; - } -#else // SB_API_VERSION < 16 const SbUiNavInterface* sb_ui_interface = static_cast( SbSystemGetExtension(kCobaltExtensionUiNavigationName)); @@ -199,7 +174,6 @@ NativeInterface InitializeInterface() { interface.do_batch_update = sb_ui_interface->do_batch_update; return interface; } -#endif // SB_API_VERSION < 16 interface.create_item = &CreateItem; interface.destroy_item = &DestroyItem; interface.set_item_bounds = &SetItemBounds; diff --git a/cobalt/ui_navigation/interface.h b/cobalt/ui_navigation/interface.h index c38d39017174..1ad29cc9c48c 100644 --- a/cobalt/ui_navigation/interface.h +++ b/cobalt/ui_navigation/interface.h @@ -16,11 +16,7 @@ #define COBALT_UI_NAVIGATION_INTERFACE_H_ #include "starboard/configuration.h" -#if SB_API_VERSION < 16 -#include "starboard/ui_navigation.h" -#else #include "starboard/extension/ui_navigation.h" -#endif // SB_API_VERSION namespace cobalt { namespace ui_navigation { diff --git a/cobalt/web/testing/mock_user_agent_platform_info.h b/cobalt/web/testing/mock_user_agent_platform_info.h index c8eeb2295448..16b37927a247 100644 --- a/cobalt/web/testing/mock_user_agent_platform_info.h +++ b/cobalt/web/testing/mock_user_agent_platform_info.h @@ -40,11 +40,6 @@ class MockUserAgentPlatformInfo : public web::UserAgentPlatformInfo { base::Optional original_design_manufacturer() const override { return optional_empty_string_; } -#if SB_API_VERSION < 15 - SbSystemDeviceType device_type() const override { - return kSbSystemDeviceTypeUnknown; - } -#endif const std::string& device_type_string() const override { return empty_string_; } diff --git a/cobalt/web/user_agent_platform_info.h b/cobalt/web/user_agent_platform_info.h index f523addd888d..e75faa902fa6 100644 --- a/cobalt/web/user_agent_platform_info.h +++ b/cobalt/web/user_agent_platform_info.h @@ -32,9 +32,6 @@ class UserAgentPlatformInfo { virtual const std::string& starboard_version() const = 0; virtual const std::string& os_name_and_version() const = 0; virtual base::Optional original_design_manufacturer() const = 0; -#if SB_API_VERSION < 15 - virtual SbSystemDeviceType device_type() const = 0; -#endif virtual const std::string& device_type_string() const = 0; virtual base::Optional chipset_model_number() const = 0; virtual base::Optional model_year() const = 0; diff --git a/media/base/starboard_utils.cc b/media/base/starboard_utils.cc index 9c3adabdf1f6..df7b5ee1d6ad 100644 --- a/media/base/starboard_utils.cc +++ b/media/base/starboard_utils.cc @@ -126,17 +126,10 @@ SbMediaAudioStreamInfo MediaAudioConfigToSbMediaAudioStreamInfo( MediaAudioCodecToSbMediaAudioCodec(audio_decoder_config.codec()); audio_stream_info.mime = mime_type; -#if SB_API_VERSION < 15 - audio_stream_info.format_tag = 0x00ff; -#endif // SB_API_VERSION < 15 audio_stream_info.number_of_channels = ChannelLayoutToChannelCount(audio_decoder_config.channel_layout()); audio_stream_info.samples_per_second = audio_decoder_config.samples_per_second(); -#if SB_API_VERSION < 15 - audio_stream_info.average_bytes_per_second = 1; - audio_stream_info.block_alignment = 4; -#endif // SB_API_VERSION < 15 audio_stream_info.bits_per_sample = audio_decoder_config.bits_per_channel(); const auto& extra_data = audio_stream_info.codec == kSbMediaAudioCodecAac diff --git a/starboard/BUILD.gn b/starboard/BUILD.gn index 5502dd25ed75..b37a076eeda1 100644 --- a/starboard/BUILD.gn +++ b/starboard/BUILD.gn @@ -177,8 +177,6 @@ source_set("starboard_headers_only") { sources = [ "atomic.h", "audio_sink.h", - "byte_swap.h", - "condition_variable.h", "configuration.h", "configuration_constants.h", "cpu_features.h", @@ -196,20 +194,15 @@ source_set("starboard_headers_only") { "media.h", "memory.h", "microphone.h", - "mutex.h", - "once.h", "player.h", "queue.h", "socket.h", "socket_waiter.h", "storage.h", - "string.h", "system.h", "thread.h", - "time.h", "time_zone.h", "types.h", - "user.h", "window.h", ] diff --git a/starboard/accessibility.h b/starboard/accessibility.h index ba7191b5a8bd..3f765b42653d 100644 --- a/starboard/accessibility.h +++ b/starboard/accessibility.h @@ -19,220 +19,6 @@ #ifndef STARBOARD_ACCESSIBILITY_H_ #define STARBOARD_ACCESSIBILITY_H_ -#if SB_API_VERSION < 16 - -#include "starboard/export.h" -#include "starboard/types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// A group of settings related to text-to-speech functionality, for platforms -// that expose system settings for text-to-speech. -typedef struct SbAccessibilityTextToSpeechSettings { - // Whether this platform has a system setting for text-to-speech or not. - bool has_text_to_speech_setting; - - // Whether the text-to-speech setting is enabled or not. This setting is only - // valid if |has_text_to_speech_setting| is set to true. - bool is_text_to_speech_enabled; -} SbAccessibilityTextToSpeechSettings; - -// Get the platform settings related to the text-to-speech accessibility -// feature. This function returns false if |out_settings| is NULL or if it is -// not zero-initialized. -// -// |out_settings|: A pointer to a zero-initialized -// SbAccessibilityTextToSpeechSettings struct. -SB_EXPORT bool SbAccessibilityGetTextToSpeechSettings( - SbAccessibilityTextToSpeechSettings* out_settings); - -typedef struct SbAccessibilityDisplaySettings { - // Whether this platform has a system setting for high contrast text or not. - bool has_high_contrast_text_setting; - - // Whether the high contrast text setting is enabled or not. - bool is_high_contrast_text_enabled; -} SbAccessibilityDisplaySettings; - -// Get the platform settings related to high contrast text. -// This function returns false if |out_settings| is NULL or if it is -// not zero-initialized. -// -// |out_settings|: A pointer to a zero-initialized -// SbAccessibilityDisplaySettings* struct. -SB_EXPORT bool SbAccessibilityGetDisplaySettings( - SbAccessibilityDisplaySettings* out_settings); - -// Enum for possible closed captioning character edge styles. -typedef enum SbAccessibilityCaptionCharacterEdgeStyle { - kSbAccessibilityCaptionCharacterEdgeStyleNone, - kSbAccessibilityCaptionCharacterEdgeStyleRaised, - kSbAccessibilityCaptionCharacterEdgeStyleDepressed, - kSbAccessibilityCaptionCharacterEdgeStyleUniform, - kSbAccessibilityCaptionCharacterEdgeStyleDropShadow, -} SbAccessibilityCaptionCharacterEdgeStyle; - -// Enum for possible closed captioning colors. -typedef enum SbAccessibilityCaptionColor { - kSbAccessibilityCaptionColorBlue, - kSbAccessibilityCaptionColorBlack, - kSbAccessibilityCaptionColorCyan, - kSbAccessibilityCaptionColorGreen, - kSbAccessibilityCaptionColorMagenta, - kSbAccessibilityCaptionColorRed, - kSbAccessibilityCaptionColorWhite, - kSbAccessibilityCaptionColorYellow, -} SbAccessibilityCaptionColor; - -// Enum for possible closed captioning font families -typedef enum SbAccessibilityCaptionFontFamily { - kSbAccessibilityCaptionFontFamilyCasual, - kSbAccessibilityCaptionFontFamilyCursive, - kSbAccessibilityCaptionFontFamilyMonospaceSansSerif, - kSbAccessibilityCaptionFontFamilyMonospaceSerif, - kSbAccessibilityCaptionFontFamilyProportionalSansSerif, - kSbAccessibilityCaptionFontFamilyProportionalSerif, - kSbAccessibilityCaptionFontFamilySmallCapitals, -} SbAccessibilityCaptionFontFamily; - -// Enum for possible closed captioning font size percentages. -typedef enum SbAccessibilityCaptionFontSizePercentage { - kSbAccessibilityCaptionFontSizePercentage25, - kSbAccessibilityCaptionFontSizePercentage50, - kSbAccessibilityCaptionFontSizePercentage75, - kSbAccessibilityCaptionFontSizePercentage100, - kSbAccessibilityCaptionFontSizePercentage125, - kSbAccessibilityCaptionFontSizePercentage150, - kSbAccessibilityCaptionFontSizePercentage175, - kSbAccessibilityCaptionFontSizePercentage200, - kSbAccessibilityCaptionFontSizePercentage225, - kSbAccessibilityCaptionFontSizePercentage250, - kSbAccessibilityCaptionFontSizePercentage275, - kSbAccessibilityCaptionFontSizePercentage300, -} SbAccessibilityCaptionFontSizePercentage; - -// Enum for possible closed captioning opacity percentages. -typedef enum SbAccessibilityCaptionOpacityPercentage { - kSbAccessibilityCaptionOpacityPercentage0, - kSbAccessibilityCaptionOpacityPercentage25, - kSbAccessibilityCaptionOpacityPercentage50, - kSbAccessibilityCaptionOpacityPercentage75, - kSbAccessibilityCaptionOpacityPercentage100, -} SbAccessibilityCaptionOpacityPercentage; - -// Enum for possible states of closed captioning properties. -typedef enum SbAccessibilityCaptionState { - // The property is not supported by the system. The application should provide - // a way to set this property, otherwise it will not be changeable. - // For any given closed captioning property, if its corresponding state - // property has a value of |kSbAccessibilityCaptionStateUnsupported|, then its - // own value is undefined. For example, if - // |SbAccessibilityCaptionColor::background_color_state| has a value of - // |kSbAccessibilityCaptionStateUnsupported|, then the value of - // |SbAccessibilityCaptionColor::background_color| is undefined. - kSbAccessibilityCaptionStateUnsupported = 0, - - // The property is supported by the system, but the user has not set it. - // The application should provide a default setting for the property to - // handle this case. - kSbAccessibilityCaptionStateUnset, - - // The user has set this property as a system default, meaning that it should - // take priority over app defaults. If - // SbAccessibilityCaptionSettings.supportsOverride contains true, this value - // should be interpreted as explicitly saying "do not override." If it - // contains false, it is up to the application to interpret any additional - // meaning of this value. - kSbAccessibilityCaptionStateSet, - - // This property should take priority over everything but application-level - // overrides, including video caption data. If - // SbAccessibilityCaptionSettings.supportsOverride contains false, then no - // fields of SbAccessibilityCaptionSettings will ever contain this value. - kSbAccessibilityCaptionStateOverride, -} SbAccessibilityCaptionState; - -// A group of settings related to system-level closed captioning settings, for -// platforms that expose closed captioning settings. -typedef struct SbAccessibilityCaptionSettings { - SbAccessibilityCaptionColor background_color; - SbAccessibilityCaptionState background_color_state; - - SbAccessibilityCaptionOpacityPercentage background_opacity; - SbAccessibilityCaptionState background_opacity_state; - - SbAccessibilityCaptionCharacterEdgeStyle character_edge_style; - SbAccessibilityCaptionState character_edge_style_state; - - SbAccessibilityCaptionColor font_color; - SbAccessibilityCaptionState font_color_state; - - SbAccessibilityCaptionFontFamily font_family; - SbAccessibilityCaptionState font_family_state; - - SbAccessibilityCaptionOpacityPercentage font_opacity; - SbAccessibilityCaptionState font_opacity_state; - - SbAccessibilityCaptionFontSizePercentage font_size; - SbAccessibilityCaptionState font_size_state; - - SbAccessibilityCaptionColor window_color; - SbAccessibilityCaptionState window_color_state; - - SbAccessibilityCaptionOpacityPercentage window_opacity; - SbAccessibilityCaptionState window_opacity_state; - - // The |is_enabled| attribute determines if the user has chosen to enable - // closed captions on their system. - bool is_enabled; - - // Some platforms support enabling or disabling captions, some support reading - // whether they are enabled from the system settings, and others support - // neither. As a result, there are separate checks for getting and setting - // the value that is contained in the |is_enabled| attribute. Modifying the - // attribute via |SbAccessibilitySetCaptionsEnabled| will change the setting - // system-wide. Attempting to read |is_enabled| when the value of - // |supports_is_enabled| is false will always return false. Attempting to set - // |is_enabled| via |SbAccessibilitySetCaptionsEnabled| when the value of - // |supports_set_enabled| is false will fail silently. - bool supports_is_enabled; - bool supports_set_enabled; - - // Some platforms may specify that when setting a property, it should override - // data from video streams and application settings (unless the application - // has its own overrides). Depending on whether this attribute contains true - // or false, the values of |SbAccessibilityCaptionState| should be interpreted - // differently. - bool supports_override; -} SbAccessibilityCaptionSettings; - -// Get the platform's settings for system-level closed captions. This function -// returns false if |caption_settings| is NULL or if it is not zero-initialized. -// -// |caption_settings|: A pointer to a zero-initialized -// SbAccessibilityTextToSpeechSettings struct. -SB_EXPORT bool SbAccessibilityGetCaptionSettings( - SbAccessibilityCaptionSettings* caption_settings); - -// Modifies whether closed captions are enabled at a system level. This -// function returns false if this feature is not supported by the platform, or -// if changing the setting is unsuccessful. This function will modify the -// setting system-wide. -// -// |enabled|: A boolean indicating whether captions should be turned on (true) -// or off (false). -SB_EXPORT bool SbAccessibilitySetCaptionsEnabled(bool enabled); - -#ifdef __cplusplus -} // extern "C" -#endif - -#else // SB_API_VERSION < 16 - #error This file is deprecated with SB_API_VERSION 16. -#endif // SB_API_VERSION < 16 - #endif // STARBOARD_ACCESSIBILITY_H_ diff --git a/starboard/android/shared/BUILD.gn b/starboard/android/shared/BUILD.gn index 5ec6ffbdb79a..52040d577ebf 100644 --- a/starboard/android/shared/BUILD.gn +++ b/starboard/android/shared/BUILD.gn @@ -60,13 +60,9 @@ static_library("starboard_platform") { "//starboard/shared/gles/gl_call.h", "//starboard/shared/gles/system_gles2.cc", "//starboard/shared/internal_only.h", - "//starboard/shared/iso/impl/directory_close.h", - "//starboard/shared/iso/impl/directory_get_next.h", - "//starboard/shared/iso/impl/directory_open.h", "//starboard/shared/iso/memory_allocate_unchecked.cc", "//starboard/shared/iso/memory_free.cc", "//starboard/shared/iso/memory_reallocate_unchecked.cc", - "//starboard/shared/iso/string_scan.cc", "//starboard/shared/libevent/socket_waiter_add.cc", "//starboard/shared/libevent/socket_waiter_create.cc", "//starboard/shared/libevent/socket_waiter_destroy.cc", @@ -75,7 +71,6 @@ static_library("starboard_platform") { "//starboard/shared/libevent/socket_waiter_wait.cc", "//starboard/shared/libevent/socket_waiter_wait_timed.cc", "//starboard/shared/libevent/socket_waiter_wake_up.cc", - "//starboard/shared/linux/byte_swap.cc", "//starboard/shared/linux/cpu_features_get.cc", "//starboard/shared/linux/system_get_random_data.cc", "//starboard/shared/linux/system_get_total_cpu_memory.cc", @@ -83,34 +78,12 @@ static_library("starboard_platform") { "//starboard/shared/linux/system_is_debugger_attached.cc", "//starboard/shared/linux/system_symbolize.cc", "//starboard/shared/linux/thread_get_id.cc", - "//starboard/shared/linux/thread_set_name.cc", - "//starboard/shared/nouser/user_get_current.cc", - "//starboard/shared/nouser/user_get_property.cc", - "//starboard/shared/nouser/user_get_signed_in.cc", - "//starboard/shared/nouser/user_internal.cc", - "//starboard/shared/nouser/user_internal.h", "//starboard/shared/opus/opus_audio_decoder.cc", "//starboard/shared/opus/opus_audio_decoder.h", - "//starboard/shared/posix/directory_create.cc", "//starboard/shared/posix/environment.cc", "//starboard/shared/posix/file_atomic_replace.cc", - "//starboard/shared/posix/impl/file_can_open.h", - "//starboard/shared/posix/impl/file_close.h", - "//starboard/shared/posix/impl/file_delete.h", - "//starboard/shared/posix/impl/file_flush.h", - "//starboard/shared/posix/impl/file_get_info.h", - "//starboard/shared/posix/impl/file_get_path_info.h", - "//starboard/shared/posix/impl/file_open.h", - "//starboard/shared/posix/impl/file_read.h", - "//starboard/shared/posix/impl/file_seek.h", - "//starboard/shared/posix/impl/file_truncate.h", - "//starboard/shared/posix/impl/file_write.h", "//starboard/shared/posix/memory_allocate_aligned_unchecked.cc", - "//starboard/shared/posix/memory_flush.cc", "//starboard/shared/posix/memory_free_aligned.cc", - "//starboard/shared/posix/memory_map.cc", - "//starboard/shared/posix/memory_protect.cc", - "//starboard/shared/posix/memory_unmap.cc", "//starboard/shared/posix/page_internal.cc", "//starboard/shared/posix/set_non_blocking_internal.cc", "//starboard/shared/posix/socket_accept.cc", @@ -139,44 +112,17 @@ static_library("starboard_platform") { "//starboard/shared/posix/socket_set_tcp_no_delay.cc", "//starboard/shared/posix/socket_set_tcp_window_scaling.cc", "//starboard/shared/posix/storage_write_record.cc", - "//starboard/shared/posix/string_compare_no_case.cc", - "//starboard/shared/posix/string_compare_no_case_n.cc", - "//starboard/shared/posix/string_format.cc", - "//starboard/shared/posix/string_format_wide.cc", "//starboard/shared/posix/system_break_into_debugger.cc", "//starboard/shared/posix/system_clear_last_error.cc", "//starboard/shared/posix/system_get_error_string.cc", "//starboard/shared/posix/system_get_last_error.cc", "//starboard/shared/posix/system_get_number_of_processors.cc", "//starboard/shared/posix/thread_sleep.cc", - "//starboard/shared/posix/time_get_monotonic_now.cc", - "//starboard/shared/posix/time_get_monotonic_thread_now.cc", - "//starboard/shared/posix/time_get_now.cc", - "//starboard/shared/posix/time_is_time_thread_now_supported.cc", "//starboard/shared/posix/time_zone_get_current.cc", - "//starboard/shared/pthread/condition_variable_broadcast.cc", - "//starboard/shared/pthread/condition_variable_create.cc", - "//starboard/shared/pthread/condition_variable_destroy.cc", - "//starboard/shared/pthread/condition_variable_signal.cc", - "//starboard/shared/pthread/condition_variable_wait.cc", - "//starboard/shared/pthread/condition_variable_wait_timed.cc", - "//starboard/shared/pthread/mutex_acquire.cc", - "//starboard/shared/pthread/mutex_acquire_try.cc", - "//starboard/shared/pthread/mutex_create.cc", - "//starboard/shared/pthread/mutex_destroy.cc", - "//starboard/shared/pthread/mutex_release.cc", - "//starboard/shared/pthread/once.cc", "//starboard/shared/pthread/thread_context_get_pointer.cc", "//starboard/shared/pthread/thread_context_internal.cc", "//starboard/shared/pthread/thread_context_internal.h", - "//starboard/shared/pthread/thread_create_local_key.cc", "//starboard/shared/pthread/thread_create_priority.h", - "//starboard/shared/pthread/thread_destroy_local_key.cc", - "//starboard/shared/pthread/thread_detach.cc", - "//starboard/shared/pthread/thread_get_current.cc", - "//starboard/shared/pthread/thread_get_local_value.cc", - "//starboard/shared/pthread/thread_is_equal.cc", - "//starboard/shared/pthread/thread_join.cc", "//starboard/shared/pthread/thread_sampler_create.cc", "//starboard/shared/pthread/thread_sampler_destroy.cc", "//starboard/shared/pthread/thread_sampler_freeze.cc", @@ -184,7 +130,6 @@ static_library("starboard_platform") { "//starboard/shared/pthread/thread_sampler_internal.h", "//starboard/shared/pthread/thread_sampler_is_supported.cc", "//starboard/shared/pthread/thread_sampler_thaw.cc", - "//starboard/shared/pthread/thread_set_local_value.cc", "//starboard/shared/pthread/thread_yield.cc", "//starboard/shared/signal/crash_signals.h", "//starboard/shared/signal/crash_signals_sigaction.cc", @@ -201,7 +146,6 @@ static_library("starboard_platform") { "//starboard/shared/starboard/audio_sink/stub_audio_sink_type.h", "//starboard/shared/starboard/command_line.cc", "//starboard/shared/starboard/command_line.h", - "//starboard/shared/starboard/directory_can_open.cc", "//starboard/shared/starboard/drm/drm_close_session.cc", "//starboard/shared/starboard/drm/drm_destroy_system.cc", "//starboard/shared/starboard/drm/drm_generate_session_update_request.cc", @@ -214,7 +158,6 @@ static_library("starboard_platform") { "//starboard/shared/starboard/event_schedule.cc", "//starboard/shared/starboard/file_atomic_replace_write_file.cc", "//starboard/shared/starboard/file_atomic_replace_write_file.h", - "//starboard/shared/starboard/file_mode_string_to_flags.cc", "//starboard/shared/starboard/file_storage/storage_close_record.cc", "//starboard/shared/starboard/file_storage/storage_delete_record.cc", "//starboard/shared/starboard/file_storage/storage_get_record_size.cc", @@ -230,10 +173,8 @@ static_library("starboard_platform") { "//starboard/shared/starboard/media/media_get_buffer_allocation_unit.cc", "//starboard/shared/starboard/media/media_get_buffer_garbage_collection_duration_threshold.cc", "//starboard/shared/starboard/media/media_get_buffer_padding.cc", - "//starboard/shared/starboard/media/media_get_buffer_storage_type.cc", "//starboard/shared/starboard/media/media_get_progressive_buffer_budget.cc", "//starboard/shared/starboard/media/media_is_buffer_using_memory_pool.cc", - "//starboard/shared/starboard/memory.cc", "//starboard/shared/starboard/microphone/microphone_close.cc", "//starboard/shared/starboard/microphone/microphone_create.cc", "//starboard/shared/starboard/microphone/microphone_destroy.cc", @@ -245,13 +186,10 @@ static_library("starboard_platform") { "//starboard/shared/starboard/new.cc", "//starboard/shared/starboard/queue_application.cc", "//starboard/shared/starboard/queue_application.h", - "//starboard/shared/starboard/string_duplicate.cc", "//starboard/shared/starboard/system_get_random_uint64.cc", "//starboard/shared/starboard/system_supports_resume.cc", "//starboard/shared/starboard/thread_checker.h", "//starboard/shared/starboard/window_set_default_options.cc", - "//starboard/shared/stub/image_decode.cc", - "//starboard/shared/stub/image_is_decode_supported.cc", "//starboard/shared/stub/system_get_total_gpu_memory.cc", "//starboard/shared/stub/system_get_used_gpu_memory.cc", "//starboard/shared/stub/system_hide_splash_screen.cc", @@ -259,17 +197,6 @@ static_library("starboard_platform") { "//starboard/shared/stub/system_request_focus.cc", "//starboard/shared/stub/system_request_reveal.cc", "//starboard/shared/stub/system_sign_with_certification_secret_key.cc", - "//starboard/shared/stub/ui_nav_get_interface.cc", - "//starboard/shared/stub/window_blur_on_screen_keyboard.cc", - "//starboard/shared/stub/window_focus_on_screen_keyboard.cc", - "//starboard/shared/stub/window_get_on_screen_keyboard_bounding_rect.cc", - "//starboard/shared/stub/window_hide_on_screen_keyboard.cc", - "//starboard/shared/stub/window_is_on_screen_keyboard_shown.cc", - "//starboard/shared/stub/window_on_screen_keyboard_is_supported.cc", - "//starboard/shared/stub/window_on_screen_keyboard_suggestions_supported.cc", - "//starboard/shared/stub/window_set_on_screen_keyboard_keep_focus.cc", - "//starboard/shared/stub/window_show_on_screen_keyboard.cc", - "//starboard/shared/stub/window_update_on_screen_keyboard_suggestions.cc", "accessibility_extension.cc", "accessibility_extension.h", "accessibility_get_caption_settings.cc", @@ -311,28 +238,12 @@ static_library("starboard_platform") { "decode_target_internal.cc", "decode_target_internal.h", "decode_target_release.cc", - "directory_close.cc", - "directory_get_next.cc", - "directory_internal.h", - "directory_open.cc", "drm_create_system.cc", "drm_system.cc", "drm_system.h", "egl_swap_buffers.cc", - "file_can_open.cc", - "file_close.cc", - "file_delete.cc", - "file_exists.cc", - "file_flush.cc", - "file_get_info.cc", - "file_get_path_info.cc", "file_internal.cc", "file_internal.h", - "file_open.cc", - "file_read.cc", - "file_seek.cc", - "file_truncate.cc", - "file_write.cc", "get_home_directory.cc", "graphics.cc", "graphics.h", @@ -396,7 +307,6 @@ static_library("starboard_platform") { "speech_synthesis_internal.cc", "speech_synthesis_is_supported.cc", "speech_synthesis_speak.cc", - "system_get_device_type.cc", "system_get_extensions.cc", "system_get_locale_id.cc", "system_get_path.cc", @@ -410,9 +320,7 @@ static_library("starboard_platform") { "system_request_conceal.cc", "system_request_freeze_no_freezedone_callback.cc", "system_request_stop.cc", - "thread_create.cc", "thread_create_priority.cc", - "thread_get_name.cc", "time_zone_get_name.cc", "trace_util.h", "video_decoder.cc", diff --git a/starboard/android/shared/configuration_constants.cc b/starboard/android/shared/configuration_constants.cc index 6fbbdaf8afe5..f777f984b2bf 100644 --- a/starboard/android/shared/configuration_constants.cc +++ b/starboard/android/shared/configuration_constants.cc @@ -123,11 +123,6 @@ const char* kSbPathSepString = ":"; // generally prefer a byte order of RGBA, regardless of endianness. const int kSbPreferredRgbaByteOrder = SB_PREFERRED_RGBA_BYTE_ORDER_RGBA; -#if SB_API_VERSION < 16 -// The maximum number of users that can be signed in at the same time. -const uint32_t kSbUserMaxSignedIn = 1; -#endif // SB_API_VERSION < 16 - // The maximum size the cache directory is allowed to use in bytes. const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB diff --git a/starboard/android/shared/configuration_public.h b/starboard/android/shared/configuration_public.h index 036a119bc499..652c332cef70 100644 --- a/starboard/android/shared/configuration_public.h +++ b/starboard/android/shared/configuration_public.h @@ -51,32 +51,6 @@ #define SB_IS_WCHAR_T_UNSIGNED 1 #endif -// --- Compiler Configuration ------------------------------------------------ - -#if SB_API_VERSION < 16 -// The platform's annotation for forcing a C function to be inlined. -#define SB_C_FORCE_INLINE __inline__ __attribute__((always_inline)) - -// The platform's annotation for marking a C function as suggested to be -// inlined. -#define SB_C_INLINE inline - -// The platform's annotation for marking a symbol as exported outside of the -// current shared library. -#define SB_EXPORT_PLATFORM __attribute__((visibility("default"))) - -// The platform's annotation for marking a symbol as imported from outside of -// the current linking unit. -#define SB_IMPORT_PLATFORM - -// --- Memory Configuration -------------------------------------------------- - -// Whether this platform can map executable memory. Implies the platform can map -// memory. This is required for platforms that want to JIT. -#define SB_CAN_MAP_EXECUTABLE_MEMORY 1 - -#endif // SB_API_VERSION < 16 - // --- Network Configuration ------------------------------------------------- // Specifies whether this platform supports IPV6. diff --git a/starboard/android/shared/directory_close.cc b/starboard/android/shared/directory_close.cc deleted file mode 100644 index a7718eb0cb8c..000000000000 --- a/starboard/android/shared/directory_close.cc +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include "starboard/directory.h" - -#include - -#include "starboard/android/shared/file_internal.h" - -#include "starboard/android/shared/directory_internal.h" -#include "starboard/shared/iso/impl/directory_close.h" - -bool SbDirectoryClose(SbDirectory directory) { - if (directory && directory->asset_dir) { - AAssetDir_close(directory->asset_dir); - delete directory; - return true; - } - - return ::starboard::shared::iso::impl::SbDirectoryClose(directory); -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/directory_get_next.cc b/starboard/android/shared/directory_get_next.cc deleted file mode 100644 index 6a6ee48214fd..000000000000 --- a/starboard/android/shared/directory_get_next.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include - -#include - -#include "starboard/common/string.h" -#include "starboard/directory.h" - -#include "starboard/android/shared/directory_internal.h" -#include "starboard/configuration_constants.h" -#include "starboard/shared/iso/impl/directory_get_next.h" - -bool SbDirectoryGetNext(SbDirectory directory, - char* out_entry, - size_t out_entry_size) { - if (directory && directory->asset_dir && out_entry && - out_entry_size >= kSbFileMaxName) { - const char* file_name = AAssetDir_getNextFileName(directory->asset_dir); - if (file_name == NULL) { - return false; - } - starboard::strlcpy(out_entry, file_name, out_entry_size); - return true; - } - - return ::starboard::shared::iso::impl::SbDirectoryGetNext( - directory, out_entry, out_entry_size); -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/directory_internal.h b/starboard/android/shared/directory_internal.h deleted file mode 100644 index 1e2108b95104..000000000000 --- a/starboard/android/shared/directory_internal.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_ANDROID_SHARED_DIRECTORY_INTERNAL_H_ -#define STARBOARD_ANDROID_SHARED_DIRECTORY_INTERNAL_H_ - -#include - -#include - -#include "starboard/directory.h" -#include "starboard/shared/internal_only.h" - -struct SbDirectoryPrivate { - // Note: Only one of these two fields will be valid for any given file. - - // The ISO C directory stream handle, or NULL if it's an asset directory. - DIR* directory; - - // If not NULL this is an Android asset directory. - AAssetDir* asset_dir; - - SbDirectoryPrivate() : directory(NULL), asset_dir(NULL) {} -}; - -#endif // STARBOARD_ANDROID_SHARED_DIRECTORY_INTERNAL_H_ diff --git a/starboard/android/shared/directory_open.cc b/starboard/android/shared/directory_open.cc deleted file mode 100644 index bb57549eef66..000000000000 --- a/starboard/android/shared/directory_open.cc +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include "starboard/directory.h" - -#include - -#include "starboard/android/shared/file_internal.h" - -#include "starboard/android/shared/directory_internal.h" -#include "starboard/shared/iso/impl/directory_open.h" - -using starboard::android::shared::IsAndroidAssetPath; -using starboard::android::shared::OpenAndroidAssetDir; - -SbDirectory SbDirectoryOpen(const char* path, SbFileError* out_error) { - if (!IsAndroidAssetPath(path)) { - return ::starboard::shared::iso::impl::SbDirectoryOpen(path, out_error); - } - - AAssetDir* asset_dir = OpenAndroidAssetDir(path); - if (asset_dir) { - SbDirectory result = new SbDirectoryPrivate(); - result->asset_dir = asset_dir; - return result; - } - - if (out_error) { - *out_error = kSbFileErrorFailed; - } - return kSbDirectoryInvalid; -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_can_open.cc b/starboard/android/shared/file_can_open.cc deleted file mode 100644 index 3849cf96cb5a..000000000000 --- a/starboard/android/shared/file_can_open.cc +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include -#include - -#include "starboard/directory.h" - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_can_open.h" - -using starboard::android::shared::IsAndroidAssetPath; -using starboard::android::shared::OpenAndroidAsset; - -bool SbFileCanOpen(const char* path, int flags) { - if (!IsAndroidAssetPath(path)) { - return ::starboard::shared::posix::impl::FileCanOpen(path, flags); - } - - SbFile file = SbFileOpen(path, flags | kSbFileOpenOnly, NULL, NULL); - bool result = SbFileIsValid(file); - SbFileClose(file); - - if (!result) { - DIR* directory = opendir(path); - result = directory != nullptr; - closedir(directory); - } - - return result; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_close.cc b/starboard/android/shared/file_close.cc deleted file mode 100644 index b44eeca4ae62..000000000000 --- a/starboard/android/shared/file_close.cc +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_close.h" - -bool SbFileClose(SbFile file) { - if (file && file->asset) { - AAsset_close(file->asset); - delete file; - return true; - } - - return ::starboard::shared::posix::impl::FileClose(file); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_delete.cc b/starboard/android/shared/file_delete.cc deleted file mode 100644 index 477b6ecc4bf0..000000000000 --- a/starboard/android/shared/file_delete.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_delete.h" - -bool SbFileDelete(const char* path) { - return ::starboard::shared::posix::impl::FileDelete(path); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_exists.cc b/starboard/android/shared/file_exists.cc deleted file mode 100644 index 810315828180..000000000000 --- a/starboard/android/shared/file_exists.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/file.h" - -bool SbFileExists(const char* path) { - return SbFileCanOpen(path, kSbFileRead); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/android/shared/file_flush.cc b/starboard/android/shared/file_flush.cc deleted file mode 100644 index 7ab036bb0f5c..000000000000 --- a/starboard/android/shared/file_flush.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_flush.h" - -bool SbFileFlush(SbFile file) { - return ::starboard::shared::posix::impl::FileFlush(file); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_get_info.cc b/starboard/android/shared/file_get_info.cc deleted file mode 100644 index c7979fbee19a..000000000000 --- a/starboard/android/shared/file_get_info.cc +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_get_info.h" - -bool SbFileGetInfo(SbFile file, SbFileInfo* out_info) { - if (file && file->asset && out_info) { - out_info->creation_time = 0; - out_info->is_directory = 0; - out_info->is_symbolic_link = 0; - out_info->last_accessed = 0; - out_info->last_modified = 0; - out_info->size = AAsset_getLength(file->asset); - return true; - } - - return ::starboard::shared::posix::impl::FileGetInfo(file, out_info); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_get_path_info.cc b/starboard/android/shared/file_get_path_info.cc deleted file mode 100644 index b1a8d58e9964..000000000000 --- a/starboard/android/shared/file_get_path_info.cc +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/file.h" - -#include "starboard/directory.h" - -#include "starboard/android/shared/directory_internal.h" -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_get_path_info.h" - -using starboard::android::shared::IsAndroidAssetPath; -using starboard::android::shared::OpenAndroidAsset; - -bool SbFileGetPathInfo(const char* path, SbFileInfo* out_info) { - if (!IsAndroidAssetPath(path)) { - return ::starboard::shared::posix::impl::FileGetPathInfo(path, out_info); - } - - SbFile file = SbFileOpen(path, kSbFileRead, NULL, NULL); - if (file) { - bool result = SbFileGetInfo(file, out_info); - SbFileClose(file); - return result; - } - - SbDirectory directory = SbDirectoryOpen(path, NULL); - if (directory && directory->asset_dir) { - out_info->creation_time = 0; - out_info->is_directory = 1; - out_info->is_symbolic_link = 0; - out_info->last_accessed = 0; - out_info->last_modified = 0; - out_info->size = 0; - SbDirectoryClose(directory); - return true; - } - - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/android/shared/file_open.cc b/starboard/android/shared/file_open.cc deleted file mode 100644 index 8102b58f32d8..000000000000 --- a/starboard/android/shared/file_open.cc +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_open.h" - -using starboard::android::shared::IsAndroidAssetPath; -using starboard::android::shared::OpenAndroidAsset; - -namespace { - -// Returns the fallback for the given asset path, or an empty string if none. -// NOTE: While Cobalt now provides a mechanism for loading system fonts through -// SbSystemGetPath(), using the fallback logic within SbFileOpen() is -// still preferred for Android's fonts. The reason for this is that the -// Android OS actually allows fonts to be loaded from two locations: one -// that it provides; and one that the devices running its OS, which it -// calls vendors, can provide. Rather than including the full Android font -// package, vendors have the option of using a smaller Android font -// package and supplementing it with their own fonts. -// -// If Android were to use SbSystemGetPath() for its fonts, vendors would -// have no way of providing those supplemental fonts to Cobalt, which -// could result in a limited selection of fonts being available. By -// treating Android's fonts as Cobalt's fonts, Cobalt can still offer a -// straightforward mechanism for including vendor fonts via -// SbSystemGetPath(). -std::string FallbackPath(const std::string& path) { - // We don't package most font files in Cobalt content and fallback to the - // system font file of the same name. - const std::string fonts_xml("fonts.xml"); - const std::string system_fonts_dir("/system/fonts/"); - const std::string cobalt_fonts_dir("/cobalt/assets/fonts/"); - - // Fonts fallback to the system fonts. - if (path.compare(0, cobalt_fonts_dir.length(), cobalt_fonts_dir) == 0) { - std::string file_name = path.substr(cobalt_fonts_dir.length()); - // fonts.xml doesn't fallback. - if (file_name != fonts_xml) { - return system_fonts_dir + file_name; - } - } - return std::string(); -} - -} // namespace - -SbFile SbFileOpen(const char* path, - int flags, - bool* out_created, - SbFileError* out_error) { - if (!IsAndroidAssetPath(path)) { - return ::starboard::shared::posix::impl::FileOpen(path, flags, out_created, - out_error); - } - - // Assets are never created and are always read-only, whether it's actually an - // asset or we end up opening a fallback path. - if (out_created) { - *out_created = false; - } - bool can_read = flags & kSbFileRead; - bool can_write = flags & kSbFileWrite; - if (!can_read || can_write) { - if (out_error) { - *out_error = kSbFileErrorAccessDenied; - } - return kSbFileInvalid; - } - - AAsset* asset = OpenAndroidAsset(path); - if (asset) { - SbFile result = new SbFilePrivate(); - result->asset = asset; - return result; - } - - std::string fallback_path = FallbackPath(path); - if (!fallback_path.empty()) { - SbFile result = ::starboard::shared::posix::impl::FileOpen( - fallback_path.c_str(), flags, out_created, out_error); - return result; - } - - if (out_error) { - *out_error = kSbFileErrorFailed; - } - return kSbFileInvalid; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_read.cc b/starboard/android/shared/file_read.cc deleted file mode 100644 index 2d90d4f8d5b3..000000000000 --- a/starboard/android/shared/file_read.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_read.h" - -int SbFileRead(SbFile file, char* data, int size) { - if (!file || size < 0) { - return -1; - } - - if (file->asset) { - return AAsset_read(file->asset, data, size); - } else { - return ::starboard::shared::posix::impl::FileRead(file, data, size); - } -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_seek.cc b/starboard/android/shared/file_seek.cc deleted file mode 100644 index e64f7fc5b6e9..000000000000 --- a/starboard/android/shared/file_seek.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_seek.h" - -int64_t SbFileSeek(SbFile file, SbFileWhence whence, int64_t offset) { - if (file && file->asset) { - return AAsset_seek64(file->asset, offset, whence); - } else { - return ::starboard::shared::posix::impl::FileSeek(file, whence, offset); - } -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_truncate.cc b/starboard/android/shared/file_truncate.cc deleted file mode 100644 index fe96b632a924..000000000000 --- a/starboard/android/shared/file_truncate.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_truncate.h" - -bool SbFileTruncate(SbFile file, int64_t length) { - return ::starboard::shared::posix::impl::FileTruncate(file, length); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_write.cc b/starboard/android/shared/file_write.cc deleted file mode 100644 index e6c99cb85515..000000000000 --- a/starboard/android/shared/file_write.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_write.h" - -int SbFileWrite(SbFile file, const char* data, int size) { - return ::starboard::shared::posix::impl::FileWrite(file, data, size); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/posix_emu/dirent.cc b/starboard/android/shared/posix_emu/dirent.cc index d3f92f1951e9..507f77ae2810 100644 --- a/starboard/android/shared/posix_emu/dirent.cc +++ b/starboard/android/shared/posix_emu/dirent.cc @@ -18,7 +18,6 @@ #include -#include "starboard/android/shared/directory_internal.h" #include "starboard/android/shared/file_internal.h" #include "starboard/common/mutex.h" #include "starboard/common/string.h" diff --git a/starboard/android/shared/posix_emu/stat.cc b/starboard/android/shared/posix_emu/stat.cc index 572fca2f2dbc..3ed8a9acf5b9 100644 --- a/starboard/android/shared/posix_emu/stat.cc +++ b/starboard/android/shared/posix_emu/stat.cc @@ -18,7 +18,6 @@ #include -#include "starboard/android/shared/directory_internal.h" #include "starboard/android/shared/file_internal.h" #include "starboard/common/log.h" #include "starboard/directory.h" diff --git a/starboard/android/shared/system_get_device_type.cc b/starboard/android/shared/system_get_device_type.cc deleted file mode 100644 index 8c7eb3c0abb8..000000000000 --- a/starboard/android/shared/system_get_device_type.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#if SB_API_VERSION < 15 - -SbSystemDeviceType SbSystemGetDeviceType() { - return kSbSystemDeviceTypeAndroidTV; -} - -#endif diff --git a/starboard/android/shared/thread_create.cc b/starboard/android/shared/thread_create.cc deleted file mode 100644 index 35fb27f2e6d6..000000000000 --- a/starboard/android/shared/thread_create.cc +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include -#include -#include -#include - -#include "starboard/android/shared/jni_env_ext.h" -#include "starboard/common/log.h" -#include "starboard/common/string.h" -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/thread_create_priority.h" -#include "starboard/shared/pthread/types_internal.h" - -namespace starboard { -namespace shared { -namespace pthread { - -void PreThreadRun() {} - -void PostThreadRun() { - // TODO: Currently OnThreadFinish() is specific to the android-forked version - // of this file, thread_create.cc. This functionality could be implemented - // though similar to ThreadSetPriority(), such that we allow platforms to - // override the OnThreadStart()/OnThreadFinish() logic, if they want, and then - // we don't have to fork this file. The only reason that is not done - // currently is because of bad timing with respect to Starboard interface - // changes. - android::shared::JniEnvExt::OnThreadShutdown(); -} - -} // namespace pthread -} // namespace shared -} // namespace starboard - -namespace { - -struct ThreadParams { - SbThreadAffinity affinity; - SbThreadEntryPoint entry_point; - char name[128]; - void* context; - SbThreadPriority priority; -}; - -void* ThreadFunc(void* context) { - ThreadParams* thread_params = static_cast(context); - SbThreadEntryPoint entry_point = thread_params->entry_point; - void* real_context = thread_params->context; - SbThreadAffinity affinity = thread_params->affinity; - if (thread_params->name[0] != '\0') { - pthread_setname_np(pthread_self(), thread_params->name); - } - - starboard::shared::pthread::ThreadSetPriority(thread_params->priority); - - delete thread_params; - - if (SbThreadIsValidAffinity(affinity)) { - cpu_set_t cpu_set; - CPU_ZERO(&cpu_set); - CPU_SET(affinity, &cpu_set); - sched_setaffinity(0, sizeof(cpu_set), &cpu_set); - } - - starboard::shared::pthread::PreThreadRun(); - - void* return_value = entry_point(real_context); - - starboard::shared::pthread::PostThreadRun(); - - return return_value; -} - -} // namespace - -SbThread SbThreadCreate(int64_t stack_size, - SbThreadPriority priority, - SbThreadAffinity affinity, - bool joinable, - const char* name, - SbThreadEntryPoint entry_point, - void* context) { - if (stack_size < 0 || !entry_point) { - return kSbThreadInvalid; - } - -#if defined(ADDRESS_SANITIZER) - // Set a big thread stack size when in ADDRESS_SANITIZER mode. - // This eliminates buffer overflows for deeply nested callstacks. - if (stack_size == 0) { - stack_size = 4096 * 1024; // 4MB - } -#endif - - pthread_attr_t attributes; - int result = pthread_attr_init(&attributes); - if (!IsSuccess(result)) { - return kSbThreadInvalid; - } - - pthread_attr_setdetachstate( - &attributes, - (joinable ? PTHREAD_CREATE_JOINABLE : PTHREAD_CREATE_DETACHED)); - if (stack_size > 0) { - pthread_attr_setstacksize(&attributes, stack_size); - } - - ThreadParams* params = new ThreadParams(); - params->affinity = affinity; - params->entry_point = entry_point; - params->context = context; - - if (name) { - starboard::strlcpy(params->name, name, SB_ARRAY_SIZE_INT(params->name)); - } else { - params->name[0] = '\0'; - } - - params->priority = priority; - - SbThread thread = kSbThreadInvalid; - SB_COMPILE_ASSERT(sizeof(SbThread) >= sizeof(pthread_t), - pthread_t_larger_than_sb_thread); - result = pthread_create(SB_PTHREAD_INTERNAL_THREAD_PTR(thread), &attributes, - ThreadFunc, params); - - pthread_attr_destroy(&attributes); - if (IsSuccess(result)) { - return thread; - } - - return kSbThreadInvalid; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/android/shared/thread_get_name.cc b/starboard/android/shared/thread_get_name.cc deleted file mode 100644 index 9385ad7f6f83..000000000000 --- a/starboard/android/shared/thread_get_name.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include -#include "starboard/thread.h" - -void SbThreadGetName(char* buffer, int buffer_size) { - prctl(PR_GET_NAME, buffer, 0L, 0L, 0L); -} - -#endif diff --git a/starboard/atomic.h b/starboard/atomic.h index 827117510035..036eb3492dd8 100644 --- a/starboard/atomic.h +++ b/starboard/atomic.h @@ -256,10 +256,4 @@ SbAtomicRelease_LoadPtr(volatile const SbAtomicPtr* ptr) { // as inlined. This macro is defined on the command line by GN. #include STARBOARD_ATOMIC_INCLUDE -#if SB_API_VERSION < 15 && defined(__cplusplus) -extern "C++" { -#include "starboard/common/atomic.h" -} // extern "C++" -#endif // SB_API_VERSION < 15 && defined(__cplusplus) - #endif // STARBOARD_ATOMIC_H_ diff --git a/starboard/byte_swap.h b/starboard/byte_swap.h index 55e5263057f8..e86240a8fc06 100644 --- a/starboard/byte_swap.h +++ b/starboard/byte_swap.h @@ -20,74 +20,6 @@ #ifndef STARBOARD_BYTE_SWAP_H_ #define STARBOARD_BYTE_SWAP_H_ -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/export.h" -#include "starboard/types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if SB_IS(BIG_ENDIAN) -#define SB_HOST_TO_NET_S16(x) (x) -#define SB_HOST_TO_NET_U16(x) (x) -#define SB_HOST_TO_NET_S32(x) (x) -#define SB_HOST_TO_NET_U32(x) (x) -#define SB_HOST_TO_NET_S64(x) (x) -#define SB_HOST_TO_NET_U64(x) (x) -#else -#define SB_HOST_TO_NET_S16(x) SbByteSwapS16(x) -#define SB_HOST_TO_NET_U16(x) SbByteSwapU16(x) -#define SB_HOST_TO_NET_S32(x) SbByteSwapS32(x) -#define SB_HOST_TO_NET_U32(x) SbByteSwapU32(x) -#define SB_HOST_TO_NET_S64(x) SbByteSwapS64(x) -#define SB_HOST_TO_NET_U64(x) SbByteSwapU64(x) -#endif - -#define SB_NET_TO_HOST_S16(x) SB_HOST_TO_NET_S16(x) -#define SB_NET_TO_HOST_U16(x) SB_HOST_TO_NET_U16(x) -#define SB_NET_TO_HOST_S32(x) SB_HOST_TO_NET_S32(x) -#define SB_NET_TO_HOST_U32(x) SB_HOST_TO_NET_U32(x) -#define SB_NET_TO_HOST_S64(x) SB_HOST_TO_NET_S64(x) -#define SB_NET_TO_HOST_U64(x) SB_HOST_TO_NET_U64(x) - -// TODO: Determine if these need to be inlined for performance reasons, -// and then act on that determination somehow. - -// Unconditionally swaps the byte order in signed 16-bit |value|. -// |value|: The value for which the byte order will be swapped. -SB_EXPORT int16_t SbByteSwapS16(int16_t value); - -// Unconditionally swaps the byte order in unsigned 16-bit |value|. -// |value|: The value for which the byte order will be swapped. -SB_EXPORT uint16_t SbByteSwapU16(uint16_t value); - -// Unconditionally swaps the byte order in signed 32-bit |value|. -// |value|: The value for which the byte order will be swapped. -SB_EXPORT int32_t SbByteSwapS32(int32_t value); - -// Unconditionally swaps the byte order in unsigned 32-bit |value|. -// |value|: The value for which the byte order will be swapped. -SB_EXPORT uint32_t SbByteSwapU32(uint32_t value); - -// Unconditionally swaps the byte order in signed 64-bit |value|. -// |value|: The value for which the byte order will be swapped. -SB_EXPORT int64_t SbByteSwapS64(int64_t value); - -// Unconditionally swaps the byte order in unsigned 64-bit |value|. -// |value|: The value for which the byte order will be swapped. -SB_EXPORT uint64_t SbByteSwapU64(uint64_t value); - -#ifdef __cplusplus -} // extern "C" -#endif - -#else // SB_API_VERSION < 16 - #error This file is deprecated with SB_API_VERSION 16. -#endif // SB_API_VERSION < 16 - #endif // STARBOARD_BYTE_SWAP_H_ diff --git a/starboard/common/condition_variable.cc b/starboard/common/condition_variable.cc index 9cc6604a5887..9acbf1029ba8 100644 --- a/starboard/common/condition_variable.cc +++ b/starboard/common/condition_variable.cc @@ -23,9 +23,6 @@ namespace starboard { ConditionVariable::ConditionVariable(const Mutex& mutex) : mutex_(&mutex), condition_() { -#if SB_API_VERSION < 16 - SbConditionVariableCreate(&condition_, mutex_->mutex()); -#else #if !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) pthread_condattr_t attribute; pthread_condattr_init(&attribute); @@ -39,33 +36,20 @@ ConditionVariable::ConditionVariable(const Mutex& mutex) int result = pthread_cond_init(&condition_, nullptr); SB_DCHECK(result == 0); #endif // !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) -#endif // SB_API_VERSION < 16 } ConditionVariable::~ConditionVariable() { -#if SB_API_VERSION < 16 - SbConditionVariableDestroy(&condition_); -#else pthread_cond_destroy(&condition_); -#endif // SB_API_VERSION < 16 } void ConditionVariable::Wait() const { mutex_->debugSetReleased(); -#if SB_API_VERSION < 16 - SbConditionVariableWait(&condition_, mutex_->mutex()); -#else pthread_cond_wait(&condition_, mutex_->mutex()); -#endif // SB_API_VERSION < 16 mutex_->debugSetAcquired(); } bool ConditionVariable::WaitTimed(int64_t duration) const { mutex_->debugSetReleased(); -#if SB_API_VERSION < 16 - bool was_signaled = SbConditionVariableIsSignaled( - SbConditionVariableWaitTimed(&condition_, mutex_->mutex(), duration)); -#else if (duration < 0) { duration = 0; } @@ -90,25 +74,16 @@ bool ConditionVariable::WaitTimed(int64_t duration) const { bool was_signaled = pthread_cond_timedwait(&condition_, mutex_->mutex(), &timeout) == 0; -#endif // SB_API_VERSION < 16 mutex_->debugSetAcquired(); return was_signaled; } void ConditionVariable::Broadcast() const { -#if SB_API_VERSION < 16 - SbConditionVariableBroadcast(&condition_); -#else pthread_cond_broadcast(&condition_); -#endif // SB_API_VERSION < 16 } void ConditionVariable::Signal() const { -#if SB_API_VERSION < 16 - SbConditionVariableSignal(&condition_); -#else pthread_cond_signal(&condition_); -#endif // SB_API_VERSION < 16 } } // namespace starboard diff --git a/starboard/common/condition_variable.h b/starboard/common/condition_variable.h index 94a46f691359..c7db1264f3f7 100644 --- a/starboard/common/condition_variable.h +++ b/starboard/common/condition_variable.h @@ -50,11 +50,7 @@ class ConditionVariable { private: const Mutex* mutex_; -#if SB_API_VERSION < 16 - mutable SbConditionVariable condition_; -#else mutable pthread_cond_t condition_; -#endif // SB_API_VERSION < 16 }; } // namespace starboard diff --git a/starboard/common/memory.h b/starboard/common/memory.h index 822b80dc9ec9..55ac1a422e82 100644 --- a/starboard/common/memory.h +++ b/starboard/common/memory.h @@ -12,14 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if SB_API_VERSION < 16 -#include "starboard/memory.h" -#else #include #include #include "starboard/configuration.h" #include "starboard/configuration_constants.h" -#endif // SB_API_VERSION < 16 #ifndef STARBOARD_COMMON_MEMORY_H_ #define STARBOARD_COMMON_MEMORY_H_ diff --git a/starboard/common/mutex.cc b/starboard/common/mutex.cc index e9400d7646f7..1d03c64c8028 100644 --- a/starboard/common/mutex.cc +++ b/starboard/common/mutex.cc @@ -18,38 +18,22 @@ namespace starboard { Mutex::Mutex() : mutex_() { -#if SB_API_VERSION < 16 - SbMutexCreate(&mutex_); -#else pthread_mutex_init(&mutex_, nullptr); -#endif // SB_API_VERSION < 16 debugInit(); } Mutex::~Mutex() { -#if SB_API_VERSION < 16 - SbMutexDestroy(&mutex_); -#else pthread_mutex_destroy(&mutex_); -#endif // SB_API_VERSION < 16 } void Mutex::Acquire() const { debugPreAcquire(); -#if SB_API_VERSION < 16 - SbMutexAcquire(&mutex_); -#else pthread_mutex_lock(&mutex_); -#endif // SB_API_VERSION < 16 debugSetAcquired(); } bool Mutex::AcquireTry() const { -#if SB_API_VERSION < 16 - bool ok = SbMutexAcquireTry(&mutex_) == kSbMutexAcquired; -#else bool ok = pthread_mutex_trylock(&mutex_) == 0; -#endif // SB_API_VERSION < 16 if (ok) { debugSetAcquired(); } @@ -58,11 +42,7 @@ bool Mutex::AcquireTry() const { void Mutex::Release() const { debugSetReleased(); -#if SB_API_VERSION < 16 - SbMutexRelease(&mutex_); -#else pthread_mutex_unlock(&mutex_); -#endif // SB_API_VERSION < 16 } void Mutex::DCheckAcquired() const { @@ -97,11 +77,7 @@ void Mutex::debugPreAcquire() const {} void Mutex::debugSetAcquired() const {} #endif -#if SB_API_VERSION < 16 -SbMutex* Mutex::mutex() const { -#else pthread_mutex_t* Mutex::mutex() const { -#endif return &mutex_; } diff --git a/starboard/common/mutex.h b/starboard/common/mutex.h index da95bf5eff48..c9f240c59436 100644 --- a/starboard/common/mutex.h +++ b/starboard/common/mutex.h @@ -22,10 +22,6 @@ #include "starboard/configuration.h" -#if SB_API_VERSION < 16 -#include "starboard/mutex.h" -#endif // SB_API_VERSION < 16 - namespace starboard { // Inline class wrapper for mutex. @@ -54,13 +50,8 @@ class Mutex { #endif friend class ConditionVariable; -#if SB_API_VERSION < 16 - SbMutex* mutex() const; - mutable SbMutex mutex_; -#else pthread_mutex_t* mutex() const; mutable pthread_mutex_t mutex_; -#endif // SB_API_VERSION < 16 Mutex(const Mutex&) = delete; void operator=(const Mutex&) = delete; }; diff --git a/starboard/common/storage.cc b/starboard/common/storage.cc index 61c54a2fc69c..b9d08051f1fc 100644 --- a/starboard/common/storage.cc +++ b/starboard/common/storage.cc @@ -16,37 +16,15 @@ namespace starboard { -StorageRecord::StorageRecord() - : -#if SB_API_VERSION < 16 - user_(SbUserGetCurrent()), -#endif // SB_API_VERSION < 16 - record_(kSbStorageInvalidRecord) { +StorageRecord::StorageRecord() : record_(kSbStorageInvalidRecord) { Initialize(); } StorageRecord::StorageRecord(const char* name) - : -#if SB_API_VERSION < 16 - user_(SbUserGetCurrent()), -#endif // SB_API_VERSION < 16 - name_(name), - record_(kSbStorageInvalidRecord) { + : name_(name), record_(kSbStorageInvalidRecord) { Initialize(); } -#if SB_API_VERSION < 16 -StorageRecord::StorageRecord(SbUser user) - : user_(user), record_(kSbStorageInvalidRecord) { - Initialize(); -} - -StorageRecord::StorageRecord(SbUser user, const char* name) - : user_(user), name_(name), record_(kSbStorageInvalidRecord) { - Initialize(); -} -#endif // SB_API_VERSION < 16 - StorageRecord::~StorageRecord() { Close(); } @@ -78,21 +56,11 @@ bool StorageRecord::Close() { bool StorageRecord::Delete() { Close(); -#if SB_API_VERSION < 16 - return SbStorageDeleteRecord(user_, name_.empty() ? NULL : name_.c_str()); -#else return SbStorageDeleteRecord(name_.empty() ? NULL : name_.c_str()); -#endif // SB_API_VERSION < 16 } void StorageRecord::Initialize() { -#if SB_API_VERSION < 16 - if (SbUserIsValid(user_)) { - record_ = SbStorageOpenRecord(user_, name_.empty() ? NULL : name_.c_str()); - } -#else record_ = SbStorageOpenRecord(name_.empty() ? NULL : name_.c_str()); -#endif // SB_API_VERSION < 16 } } // namespace starboard diff --git a/starboard/common/storage.h b/starboard/common/storage.h index b5239b29e090..1eb05fc0320e 100644 --- a/starboard/common/storage.h +++ b/starboard/common/storage.h @@ -25,9 +25,6 @@ #include "starboard/configuration.h" #include "starboard/storage.h" #include "starboard/types.h" -#if SB_API_VERSION < 16 -#include "starboard/user.h" -#endif namespace starboard { @@ -35,10 +32,6 @@ class StorageRecord { public: StorageRecord(); explicit StorageRecord(const char* name); -#if SB_API_VERSION < 16 - explicit StorageRecord(SbUser user); - StorageRecord(SbUser user, const char* name); -#endif ~StorageRecord(); bool IsValid(); @@ -51,10 +44,6 @@ class StorageRecord { private: void Initialize(); - -#if SB_API_VERSION < 16 - SbUser user_; -#endif std::string name_; SbStorageRecord record_; }; diff --git a/starboard/configuration.h b/starboard/configuration.h index 078f74deeaef..4c667619ea3e 100644 --- a/starboard/configuration.h +++ b/starboard/configuration.h @@ -327,11 +327,6 @@ struct CompileAssert {}; #endif // SB_C_FORCE_INLINE annotation for forcing a C function to be inlined. -#if SB_API_VERSION < 16 -#if !defined(SB_C_FORCE_INLINE) -#error "Your platform must define SB_C_FORCE_INLINE." -#endif -#else // SB_API_VERSION < 16 #if defined(SB_C_FORCE_INLINE) #error "Your platform must not define SB_C_FORCE_INLINE" #else // defined(SB_C_FORCE_INLINE) @@ -343,19 +338,12 @@ struct CompileAssert {}; #define SB_C_FORCE_INLINE inline #endif #endif // defined(SB_C_FORCE_INLINE) -#endif // SB_API_VERSION < 16 -#if SB_API_VERSION < 16 -#if !defined(SB_C_INLINE) -#error "Your platform must define SB_C_INLINE." -#endif -#else #if defined(SB_C_INLINE) #error "Your platform should not define SB_C_INLINE, it is deprecated." #else #define SB_C_INLINE inline #endif -#endif #if SB_API_VERSION >= 16 #if defined(SB_HAS_QUIRK_SUPPORT_INT16_AUDIO_SAMPLES) @@ -363,12 +351,8 @@ struct CompileAssert {}; #endif // defined(SB_HAS_QUIRK_SUPPORT_INT16_AUDIO_SAMPLES) #endif // SB_API_VERSION >= 16 -// SB_EXPORT_PLATFORM annotates symbols as exported from shared libraries. -#if SB_API_VERSION < 16 -#if !defined(SB_EXPORT_PLATFORM) -#error "Your platform must define SB_EXPORT_PLATFORM." -#endif -#else // SB_API_VERSION >= 16 +// SB_EXPORT_PLATFORM annotates symbols as exported from shared libraries. // +// SB_API_VERSION >= 16 #if !defined(SB_EXPORT_PLATFORM) // auto-configure #if SB_IS(COMPILER_GCC) #define SB_EXPORT_PLATFORM __attribute__((visibility("default"))) @@ -378,14 +362,9 @@ struct CompileAssert {}; #error "Could not determine compiler, you must define SB_EXPORT_PLATFORM." #endif #endif // !defined(SB_EXPORT_PLATFORM) -#endif // SB_API_VERSION >= 16 -// SB_IMPORT_PLATFORM annotates symbols as imported from shared libraries. -#if SB_API_VERSION < 16 -#if !defined(SB_IMPORT_PLATFORM) -#error "Your platform must define SB_IMPORT_PLATFORM." -#endif -#else // SB_API_VERSION >= 16 +// SB_IMPORT_PLATFORM annotates symbols as imported from shared libraries. // +// SB_API_VERSION >= 16 #if !defined(SB_IMPORT_PLATFORM) // auto-configure #if SB_IS(COMPILER_GCC) #define SB_IMPORT_PLATFORM @@ -395,7 +374,6 @@ struct CompileAssert {}; #error "Could not determine compiler, you must define SB_IMPORT_PLATFORM." #endif #endif // !defined(SB_IMPORT_PLATFORM) -#endif // SB_API_VERSION >= 16 // --- Derived Configuration ------------------------------------------------- diff --git a/starboard/configuration_constants.h b/starboard/configuration_constants.h index b0830b6ddc28..65823b954ad2 100644 --- a/starboard/configuration_constants.h +++ b/starboard/configuration_constants.h @@ -138,11 +138,6 @@ SB_EXPORT extern const char kSbPathSepChar; // The string form of SB_PATH_SEP_CHAR. SB_EXPORT extern const char* kSbPathSepString; -#if SB_API_VERSION < 16 -// The maximum number of users that can be signed in at the same time. -SB_EXPORT extern const uint32_t kSbUserMaxSignedIn; -#endif // SB_API_VERSION < 16 - // The maximum size the cache directory is allowed to use in bytes. SB_EXPORT extern const uint32_t kSbMaxSystemPathCacheDirectorySize; diff --git a/starboard/directory.h b/starboard/directory.h index f872ee924985..c5b5af9250d3 100644 --- a/starboard/directory.h +++ b/starboard/directory.h @@ -42,66 +42,6 @@ static inline bool SbDirectoryIsValid(SbDirectory directory) { return directory != kSbDirectoryInvalid; } -#if SB_API_VERSION < 17 -// DEPRECATED with SB_API_VERSION 16 -// -// Opens the given existing directory for listing. This function returns -// kSbDirectoryInvalidHandle if it is not successful. -// -// If |out_error| is provided by the caller, it will be set to the appropriate -// SbFileError code on failure. -// -// |out_error|: An output parameter that, in case of an error, is set to the -// reason that the directory could not be opened. -SB_EXPORT SbDirectory SbDirectoryOpen(const char* path, SbFileError* out_error); - -// DEPRECATED with SB_API_VERSION 16 -// -// Closes an open directory stream handle. The return value indicates whether -// the directory was closed successfully. -// -// |directory|: The directory stream handle to close. -SB_EXPORT bool SbDirectoryClose(SbDirectory directory); - -// DEPRECATED with SB_API_VERSION 16 -// -// Populates |out_entry| with the next entry in the specified directory stream, -// and moves the stream forward by one entry. -// -// Platforms may, but are not required to, return |.| (referring to the -// directory itself) and/or |..| (referring to the directory's parent directory) -// as entries in the directory stream. -// -// This function returns |true| if there was a next directory, and |false| -// at the end of the directory stream or if |out_entry_size| is smaller than -// kSbFileMaxName. -// -// |directory|: The directory stream from which to retrieve the next directory. -// |out_entry|: The null terminated string to be populated with the next -// directory entry. The space allocated for this string should be -// equal to |out_entry_size|. -// |out_entry_size|: The size of the space allocated for |out_entry|. This -// should be at least equal to kSbFileMaxName. -SB_EXPORT bool SbDirectoryGetNext(SbDirectory directory, - char* out_entry, - size_t out_entry_size); - -#endif // SB_API_VERSION < 17 - -#if SB_API_VERSION < 16 -// Indicates whether SbDirectoryOpen is allowed for the given |path|. -// -// |path|: The path to be checked. -SB_EXPORT bool SbDirectoryCanOpen(const char* path); - -// Creates the directory |path|, assuming the parent directory already exists. -// This function returns |true| if the directory now exists (even if it existed -// before) and returns |false| if the directory does not exist. -// -// |path|: The path to be created. -SB_EXPORT bool SbDirectoryCreate(const char* path); -#endif // SB_API_VERSION < 16 - #ifdef __cplusplus } // extern "C" #endif diff --git a/starboard/elf_loader/exported_symbols.cc b/starboard/elf_loader/exported_symbols.cc index 7531c5084b33..1036c4079a60 100644 --- a/starboard/elf_loader/exported_symbols.cc +++ b/starboard/elf_loader/exported_symbols.cc @@ -26,13 +26,7 @@ #include #include -#if SB_API_VERSION < 16 -#include "starboard/accessibility.h" -#endif // SB_API_VERSION < 16 #include "starboard/audio_sink.h" -#if SB_API_VERSION < 16 -#include "starboard/byte_swap.h" -#endif // SB_API_VERSION < 16 #include "starboard/common/log.h" #include "starboard/condition_variable.h" #include "starboard/configuration.h" @@ -44,10 +38,6 @@ #include "starboard/event.h" #include "starboard/file.h" #include "starboard/gles.h" -#if SB_API_VERSION < 16 -#include "starboard/image.h" -#include "starboard/once.h" -#endif // SB_API_VERSION < 16 #include "starboard/log.h" #include "starboard/memory.h" #include "starboard/microphone.h" @@ -70,14 +60,7 @@ #include "starboard/string.h" #include "starboard/system.h" #include "starboard/thread.h" -#if SB_API_VERSION < 16 -#include "starboard/time.h" -#endif // SB_API_VERSION < 16 #include "starboard/time_zone.h" -#if SB_API_VERSION < 16 -#include "starboard/ui_navigation.h" -#include "starboard/user.h" -#endif // SB_API_VERSION < 16 #include "starboard/window.h" #define REGISTER_SYMBOL(s) \ @@ -113,19 +96,10 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(kSbPathSepChar); REGISTER_SYMBOL(kSbPathSepString); REGISTER_SYMBOL(kSbPreferredRgbaByteOrder); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(kSbUserMaxSignedIn); -#endif // SB_API_VERSION < 16 #if SB_API_VERSION >= 16 REGISTER_SYMBOL(kSbCanMapExecutableMemory); REGISTER_SYMBOL(kHasPartialAudioFramesSupport); #endif // SB_API_VERSION >= 16 -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbAccessibilityGetCaptionSettings); - REGISTER_SYMBOL(SbAccessibilityGetDisplaySettings); - REGISTER_SYMBOL(SbAccessibilityGetTextToSpeechSettings); - REGISTER_SYMBOL(SbAccessibilitySetCaptionsEnabled); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbAudioSinkCreate); REGISTER_SYMBOL(SbAudioSinkDestroy); REGISTER_SYMBOL(SbAudioSinkGetMaxChannels); @@ -134,36 +108,9 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(SbAudioSinkIsAudioFrameStorageTypeSupported); REGISTER_SYMBOL(SbAudioSinkIsAudioSampleTypeSupported); REGISTER_SYMBOL(SbAudioSinkIsValid); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbByteSwapS16); - REGISTER_SYMBOL(SbByteSwapS32); - REGISTER_SYMBOL(SbByteSwapS64); - REGISTER_SYMBOL(SbByteSwapU16); - REGISTER_SYMBOL(SbByteSwapU32); - REGISTER_SYMBOL(SbByteSwapU64); - REGISTER_SYMBOL(SbConditionVariableBroadcast); - REGISTER_SYMBOL(SbConditionVariableCreate); - REGISTER_SYMBOL(SbConditionVariableDestroy); - REGISTER_SYMBOL(SbConditionVariableSignal); - REGISTER_SYMBOL(SbConditionVariableWait); - REGISTER_SYMBOL(SbConditionVariableWaitTimed); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbCPUFeaturesGet); REGISTER_SYMBOL(SbDecodeTargetGetInfo); REGISTER_SYMBOL(SbDecodeTargetRelease); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbDirectoryCanOpen); -#endif // SB_API_VERSION < 16 -#if SB_API_VERSION < 17 - REGISTER_SYMBOL(SbDirectoryClose); -#endif // SB_API_VERSION < 17 -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbDirectoryCreate); -#endif // SB_API_VERSION < 16 -#if SB_API_VERSION < 17 - REGISTER_SYMBOL(SbDirectoryGetNext); - REGISTER_SYMBOL(SbDirectoryOpen); -#endif // SB_API_VERSION < 17 REGISTER_SYMBOL(SbDrmCloseSession); REGISTER_SYMBOL(SbDrmCreateSystem); REGISTER_SYMBOL(SbDrmDestroySystem); @@ -175,41 +122,11 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(SbEventCancel); REGISTER_SYMBOL(SbEventSchedule); REGISTER_SYMBOL(SbFileAtomicReplace); -#if SB_API_VERSION < 17 - REGISTER_SYMBOL(SbFileCanOpen); - REGISTER_SYMBOL(SbFileClose); - REGISTER_SYMBOL(SbFileDelete); -#endif // SB_API_VERSION < 17 -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbFileExists); -#endif // SB_API_VERSION < 16 -#if SB_API_VERSION < 17 - REGISTER_SYMBOL(SbFileFlush); - REGISTER_SYMBOL(SbFileGetInfo); -#endif // SB_API_VERSION < 17 -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbFileGetPathInfo); -#endif // SB_API_VERSION < 16 -#if SB_API_VERSION < 17 - REGISTER_SYMBOL(SbFileModeStringToFlags); - REGISTER_SYMBOL(SbFileOpen); - REGISTER_SYMBOL(SbFileRead); - REGISTER_SYMBOL(SbFileSeek); - REGISTER_SYMBOL(SbFileTruncate); - REGISTER_SYMBOL(SbFileWrite); -#endif // SB_API_VERSION < 17 REGISTER_SYMBOL(SbGetEglInterface); REGISTER_SYMBOL(SbGetGlesInterface); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbImageDecode); - REGISTER_SYMBOL(SbImageIsDecodeSupported); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbLog); REGISTER_SYMBOL(SbLogFlush); REGISTER_SYMBOL(SbLogFormat); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbLogIsTty); -#endif REGISTER_SYMBOL(SbLogRaw); REGISTER_SYMBOL(SbLogRawDumpStack); REGISTER_SYMBOL(SbLogRawFormat); @@ -221,36 +138,12 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(SbMediaGetBufferAllocationUnit); REGISTER_SYMBOL(SbMediaGetBufferGarbageCollectionDurationThreshold); REGISTER_SYMBOL(SbMediaGetBufferPadding); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbMediaGetBufferStorageType); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbMediaGetInitialBufferCapacity); REGISTER_SYMBOL(SbMediaGetMaxBufferCapacity); REGISTER_SYMBOL(SbMediaGetProgressiveBufferBudget); REGISTER_SYMBOL(SbMediaGetVideoBufferBudget); REGISTER_SYMBOL(SbMediaIsBufferPoolAllocateOnDemand); REGISTER_SYMBOL(SbMediaIsBufferUsingMemoryPool); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbMemoryAllocate); - REGISTER_SYMBOL(SbMemoryAllocateAligned); - REGISTER_SYMBOL(SbMemoryAllocateAlignedUnchecked); - REGISTER_SYMBOL(SbMemoryAllocateNoReport); - REGISTER_SYMBOL(SbMemoryAllocateUnchecked); - REGISTER_SYMBOL(SbMemoryDeallocate); - REGISTER_SYMBOL(SbMemoryDeallocateAligned); - REGISTER_SYMBOL(SbMemoryDeallocateNoReport); -#if SB_CAN(MAP_EXECUTABLE_MEMORY) - REGISTER_SYMBOL(SbMemoryFlush); -#endif // SB_CAN(MAP_EXECUTABLE_MEMORY) - REGISTER_SYMBOL(SbMemoryFree); - REGISTER_SYMBOL(SbMemoryFreeAligned); - REGISTER_SYMBOL(SbMemoryMap); - REGISTER_SYMBOL(SbMemoryProtect); - REGISTER_SYMBOL(SbMemoryReallocate); - REGISTER_SYMBOL(SbMemoryReallocateUnchecked); - REGISTER_SYMBOL(SbMemoryUnmap); -#endif // SB_API_VERSION < 16 - REGISTER_SYMBOL(SbMicrophoneClose); REGISTER_SYMBOL(SbMicrophoneCreate); REGISTER_SYMBOL(SbMicrophoneDestroy); @@ -258,14 +151,6 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(SbMicrophoneIsSampleRateSupported); REGISTER_SYMBOL(SbMicrophoneOpen); REGISTER_SYMBOL(SbMicrophoneRead); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbMutexAcquire); - REGISTER_SYMBOL(SbMutexAcquireTry); - REGISTER_SYMBOL(SbMutexCreate); - REGISTER_SYMBOL(SbMutexDestroy); - REGISTER_SYMBOL(SbMutexRelease); - REGISTER_SYMBOL(SbOnce); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbPlayerCreate); REGISTER_SYMBOL(SbPlayerDestroy); #if SB_API_VERSION >= 15 @@ -338,19 +223,8 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(SbStorageOpenRecord); REGISTER_SYMBOL(SbStorageReadRecord); REGISTER_SYMBOL(SbStorageWriteRecord); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbStringCompareNoCase); - REGISTER_SYMBOL(SbStringCompareNoCaseN); - REGISTER_SYMBOL(SbStringDuplicate); - REGISTER_SYMBOL(SbStringFormat); - REGISTER_SYMBOL(SbStringFormatWide); - REGISTER_SYMBOL(SbStringScan); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbSystemBreakIntoDebugger); REGISTER_SYMBOL(SbSystemClearLastError); -#if SB_API_VERSION < 15 - REGISTER_SYMBOL(SbSystemGetDeviceType); -#endif REGISTER_SYMBOL(SbSystemGetErrorString); REGISTER_SYMBOL(SbSystemGetExtension); REGISTER_SYMBOL(SbSystemGetLastError); @@ -380,77 +254,27 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(SbSystemSupportsResume); REGISTER_SYMBOL(SbSystemSymbolize); REGISTER_SYMBOL(SbThreadContextGetPointer); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbThreadCreate); - REGISTER_SYMBOL(SbThreadCreateLocalKey); - REGISTER_SYMBOL(SbThreadDestroyLocalKey); - REGISTER_SYMBOL(SbThreadDetach); - REGISTER_SYMBOL(SbThreadGetCurrent); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbThreadGetId); #if SB_API_VERSION >= 16 REGISTER_SYMBOL(SbThreadGetPriority); #endif // SB_API_VERSION >= 16 -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbThreadGetLocalValue); - REGISTER_SYMBOL(SbThreadGetName); - REGISTER_SYMBOL(SbThreadIsEqual); - REGISTER_SYMBOL(SbThreadJoin); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbThreadSamplerCreate); REGISTER_SYMBOL(SbThreadSamplerDestroy); REGISTER_SYMBOL(SbThreadSamplerFreeze); REGISTER_SYMBOL(SbThreadSamplerIsSupported); REGISTER_SYMBOL(SbThreadSamplerThaw); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbThreadSetLocalValue); - REGISTER_SYMBOL(SbThreadSetName); -#endif // SB_API_VERSION < 16 #if SB_API_VERSION >= 16 REGISTER_SYMBOL(SbThreadSetPriority); #endif // SB_API_VERSION >= 16 -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbThreadSleep); - REGISTER_SYMBOL(SbThreadYield); - REGISTER_SYMBOL(SbTimeGetMonotonicNow); - REGISTER_SYMBOL(SbTimeGetMonotonicThreadNow); - REGISTER_SYMBOL(SbTimeGetNow); - REGISTER_SYMBOL(SbTimeIsTimeThreadNowSupported); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbTimeZoneGetCurrent); REGISTER_SYMBOL(SbTimeZoneGetName); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbUiNavGetInterface); - REGISTER_SYMBOL(SbUserGetCurrent); - REGISTER_SYMBOL(SbUserGetProperty); - REGISTER_SYMBOL(SbUserGetPropertySize); - REGISTER_SYMBOL(SbUserGetSignedIn); - REGISTER_SYMBOL(SbWindowBlurOnScreenKeyboard); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbWindowCreate); REGISTER_SYMBOL(SbWindowDestroy); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbWindowFocusOnScreenKeyboard); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbWindowGetDiagonalSizeInInches); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbWindowGetOnScreenKeyboardBoundingRect); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbWindowGetPlatformHandle); REGISTER_SYMBOL(SbWindowGetSize); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbWindowHideOnScreenKeyboard); - REGISTER_SYMBOL(SbWindowIsOnScreenKeyboardShown); - REGISTER_SYMBOL(SbWindowOnScreenKeyboardIsSupported); - REGISTER_SYMBOL(SbWindowOnScreenKeyboardSuggestionsSupported); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbWindowSetDefaultOptions); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbWindowSetOnScreenKeyboardKeepFocus); - REGISTER_SYMBOL(SbWindowShowOnScreenKeyboard); - REGISTER_SYMBOL(SbWindowUpdateOnScreenKeyboardSuggestions); -#endif // SB_API_VERSION < 16 #if SB_API_VERSION >= 16 // POSIX APIs diff --git a/starboard/event.h b/starboard/event.h index b7f245559b3b..2f885d59df02 100644 --- a/starboard/event.h +++ b/starboard/event.h @@ -261,20 +261,8 @@ typedef enum SbEventType { // kSbEventOnScreenKeyboardInvalidTicket. kSbEventTypeOnScreenKeyboardBlurred, -#if SB_API_VERSION < 16 - // The platform has updated the on screen keyboard suggestions. This event is - // triggered by the system or by the application's OnScreenKeyboard update - // suggestions method. The event has int data representing a ticket. The - // ticket is used by the application to mark individual calls to the update - // suggestions method as successfully completed. Events triggered by the - // application have tickets passed in via - // SbWindowUpdateOnScreenKeyboardSuggestions. System-triggered events have - // ticket value kSbEventOnScreenKeyboardInvalidTicket. - kSbEventTypeOnScreenKeyboardSuggestionsUpdated, -#else // Reserved for deprecated events. kSbEventTypeReserved1, -#endif // SB_API_VERSION < 16 // One or more of the fields returned by SbAccessibilityGetCaptionSettings // has changed. diff --git a/starboard/evergreen/arm/hardfp/configuration_public.h b/starboard/evergreen/arm/hardfp/configuration_public.h index c83d82ff60c1..a30aafb14d7b 100644 --- a/starboard/evergreen/arm/hardfp/configuration_public.h +++ b/starboard/evergreen/arm/hardfp/configuration_public.h @@ -47,32 +47,6 @@ #define SB_IS_WCHAR_T_UNSIGNED 1 #endif -// --- Compiler Configuration ------------------------------------------------ - -#if SB_API_VERSION < 16 -// The platform's annotation for forcing a C function to be inlined. -#define SB_C_FORCE_INLINE __inline__ __attribute__((always_inline)) - -// The platform's annotation for marking a C function as suggested to be -// inlined. -#define SB_C_INLINE inline - -// The platform's annotation for marking a symbol as exported outside of the -// current shared library. -#define SB_EXPORT_PLATFORM __attribute__((visibility("default"))) - -// The platform's annotation for marking a symbol as imported from outside of -// the current linking unit. -#define SB_IMPORT_PLATFORM - -// --- Memory Configuration -------------------------------------------------- - -// Whether this platform can map executable memory. Implies SB_HAS_MMAP. This is -// required for platforms that want to JIT. -#define SB_CAN_MAP_EXECUTABLE_MEMORY 1 - -#endif // SB_API_VERSION < 16 - // --- Network Configuration ------------------------------------------------- // Specifies whether this platform supports IPV6. diff --git a/starboard/evergreen/arm/softfp/configuration_public.h b/starboard/evergreen/arm/softfp/configuration_public.h index 792752169c7e..97e37ed7a253 100644 --- a/starboard/evergreen/arm/softfp/configuration_public.h +++ b/starboard/evergreen/arm/softfp/configuration_public.h @@ -47,32 +47,6 @@ #define SB_IS_WCHAR_T_UNSIGNED 1 #endif -// --- Compiler Configuration ------------------------------------------------ - -#if SB_API_VERSION < 16 -// The platform's annotation for forcing a C function to be inlined. -#define SB_C_FORCE_INLINE __inline__ __attribute__((always_inline)) - -// The platform's annotation for marking a C function as suggested to be -// inlined. -#define SB_C_INLINE inline - -// The platform's annotation for marking a symbol as exported outside of the -// current shared library. -#define SB_EXPORT_PLATFORM __attribute__((visibility("default"))) - -// The platform's annotation for marking a symbol as imported from outside of -// the current linking unit. -#define SB_IMPORT_PLATFORM - -// --- Memory Configuration -------------------------------------------------- - -// Whether this platform can map executable memory. Implies SB_HAS_MMAP. This is -// required for platforms that want to JIT. -#define SB_CAN_MAP_EXECUTABLE_MEMORY 1 - -#endif // SB_API_VERSION < 16 - // --- Network Configuration ------------------------------------------------- // Specifies whether this platform supports IPV6. diff --git a/starboard/evergreen/arm64/configuration_public.h b/starboard/evergreen/arm64/configuration_public.h index c14e32a3b08b..5e3c77ed4485 100644 --- a/starboard/evergreen/arm64/configuration_public.h +++ b/starboard/evergreen/arm64/configuration_public.h @@ -47,32 +47,6 @@ #define SB_IS_WCHAR_T_UNSIGNED 1 #endif -// --- Compiler Configuration ------------------------------------------------ - -#if SB_API_VERSION < 16 -// The platform's annotation for forcing a C function to be inlined. -#define SB_C_FORCE_INLINE __inline__ __attribute__((always_inline)) - -// The platform's annotation for marking a C function as suggested to be -// inlined. -#define SB_C_INLINE inline - -// The platform's annotation for marking a symbol as exported outside of the -// current shared library. -#define SB_EXPORT_PLATFORM __attribute__((visibility("default"))) - -// The platform's annotation for marking a symbol as imported from outside of -// the current linking unit. -#define SB_IMPORT_PLATFORM - -// --- Memory Configuration -------------------------------------------------- - -// Whether this platform can map executable memory. Implies SB_HAS_MMAP. This is -// required for platforms that want to JIT. -#define SB_CAN_MAP_EXECUTABLE_MEMORY 1 - -#endif // SB_API_VERSION < 16 - // --- Network Configuration ------------------------------------------------- // Specifies whether this platform supports IPV6. diff --git a/starboard/evergreen/x64/configuration_public.h b/starboard/evergreen/x64/configuration_public.h index 1f9d6a5012f8..22b10cc6b9bd 100644 --- a/starboard/evergreen/x64/configuration_public.h +++ b/starboard/evergreen/x64/configuration_public.h @@ -47,32 +47,6 @@ #define SB_IS_WCHAR_T_UNSIGNED 1 #endif -// --- Compiler Configuration ------------------------------------------------ - -#if SB_API_VERSION < 16 -// The platform's annotation for forcing a C function to be inlined. -#define SB_C_FORCE_INLINE __inline__ __attribute__((always_inline)) - -// The platform's annotation for marking a C function as suggested to be -// inlined. -#define SB_C_INLINE inline - -// The platform's annotation for marking a symbol as exported outside of the -// current shared library. -#define SB_EXPORT_PLATFORM __attribute__((visibility("default"))) - -// The platform's annotation for marking a symbol as imported from outside of -// the current linking unit. -#define SB_IMPORT_PLATFORM - -// --- Memory Configuration -------------------------------------------------- - -// Whether this platform can map executable memory. Implies SB_HAS_MMAP. This is -// required for platforms that want to JIT. -#define SB_CAN_MAP_EXECUTABLE_MEMORY 1 - -#endif // SB_API_VERSION < 16 - // --- Network Configuration ------------------------------------------------- // Specifies whether this platform supports IPV6. diff --git a/starboard/file.h b/starboard/file.h index 697c829d4bc9..6f2641807fbb 100644 --- a/starboard/file.h +++ b/starboard/file.h @@ -129,38 +129,7 @@ static inline bool SbFileIsValid(SbFile file) { return file != kSbFileInvalid; } -// DEPRECATED with SB_API_VERSION 16 -// -// Opens the file at |path|, which must be absolute, creating it if specified by -// |flags|. The read/write position is at the beginning of the file. -// -// Note that this function only guarantees the correct behavior when |path| -// points to a file. The behavior is undefined if |path| points to a directory. -// -// |path|: The absolute path of the file to be opened. -// |flags|: |SbFileFlags| that determine how the file is used in the -// application. Among other things, |flags| can indicate whether the -// application should create |path| if |path| does not already exist. -// |out_created|: Starboard sets this value to |true| if a new file is created -// or if an old file is truncated to zero length to simulate a new file, -// which can happen if the |kSbFileCreateAlways| flag is set. Otherwise, -// Starboard sets this value to |false|. -// |out_error|: If |path| cannot be created, this is set to |kSbFileInvalid|. -// Otherwise, it is |NULL|. -SB_EXPORT SbFile SbFileOpen(const char* path, - int flags, - bool* out_created, - SbFileError* out_error); - -// DEPRECATED with SB_API_VERSION 16 -// -// Closes |file|. The return value indicates whether the file was closed -// successfully. -// -// |file|: The absolute path of the file to be closed. -SB_EXPORT bool SbFileClose(SbFile file); - -#endif // SB_API_VERSION < 17 +#endif // Replaces the content of the file at |path| with |data|. Returns whether the // contents of the file were replaced. The replacement of the content is an @@ -173,191 +142,6 @@ SB_EXPORT bool SbFileAtomicReplace(const char* path, const char* data, int64_t data_size); -#if SB_API_VERSION < 17 - -// DEPRECATED with SB_API_VERSION 16 -// -// Changes the current read/write position in |file|. The return value -// identifies the resultant current read/write position in the file (relative -// to the start) or |-1| in case of an error. This function might not support -// seeking past the end of the file on some platforms. -// -// |file|: The SbFile in which the read/write position will be changed. -// |whence|: The starting read/write position. The position is modified relative -// to this value. -// |offset|: The amount that the read/write position is changed, relative to -// |whence|. -SB_EXPORT int64_t SbFileSeek(SbFile file, SbFileWhence whence, int64_t offset); - -// DEPRECATED with SB_API_VERSION 16 -// -// Reads |size| bytes (or until EOF is reached) from |file| into |data|, -// starting at the file's current position. -// -// The return value specifies the number of bytes read or |-1| if there was -// an error. Note that this function does NOT make a best effort to read all -// data on all platforms; rather, it just reads however many bytes are quickly -// available. However, this function can be run in a loop to make it a -// best-effort read. -// -// |file|: The SbFile from which to read data. -// |data|: The variable to which data is read. -// |size|: The amount of data (in bytes) to read. -SB_EXPORT int SbFileRead(SbFile file, char* data, int size); - -// DEPRECATED with SB_API_VERSION 16 -// -// Writes the given buffer into |file| at the file's current position, -// overwriting any data that was previously there. -// -// The return value identifies the number of bytes written, or |-1| on error. -// Note that this function does NOT make a best effort to write all data; -// rather, it writes however many bytes can be written quickly. Generally, this -// means that it writes however many bytes as possible without blocking on IO. -// Run this function in a loop to ensure that all data is written. -// -// |file|: The SbFile to which data will be written. -// |data|: The data to be written. -// |size|: The amount of data (in bytes) to write. -SB_EXPORT int SbFileWrite(SbFile file, const char* data, int size); - -// DEPRECATED with SB_API_VERSION 16 -// -// Truncates the given |file| to the given |length|. The return value indicates -// whether the file was truncated successfully. -// -// |file|: The file to be truncated. -// |length|: The expected length of the file after it is truncated. If |length| -// is greater than the current size of the file, then the file is extended -// with zeros. If |length| is negative, then the function is a no-op and -// returns |false|. -SB_EXPORT bool SbFileTruncate(SbFile file, int64_t length); - -// DEPRECATED with SB_API_VERSION 16 -// -// Flushes the write buffer to |file|. Data written via SbFileWrite is not -// necessarily committed until the SbFile is flushed or closed. -// -// |file|: The SbFile to which the write buffer is flushed. -SB_EXPORT bool SbFileFlush(SbFile file); - -// DEPRECATED with SB_API_VERSION 16 -// -// Retrieves information about |file|. The return value indicates whether the -// file information was retrieved successfully. -// -// |file|: The SbFile for which information is retrieved. -// |out_info|: The variable into which the retrieved data is placed. This -// variable is not touched if the operation is not successful. -SB_EXPORT bool SbFileGetInfo(SbFile file, SbFileInfo* out_info); - -// DEPRECATED with SB_API_VERSION 16 -// -// Retrieves information about the file at |path|. The return value indicates -// whether the file information was retrieved successfully. -// -// |file|: The absolute path of the file for which information is retrieved. -// |out_info|: The variable into which the retrieved data is placed. This -// variable is not touched if the operation is not successful. -SB_EXPORT bool SbFileGetPathInfo(const char* path, SbFileInfo* out_info); - -// DEPRECATED with SB_API_VERSION 16 -// -// Deletes the regular file, symlink, or empty directory at |path|. This -// function is used primarily to clean up after unit tests. On some platforms, -// this function fails if the file in question is being held open. -// -// |path|: The absolute path of the file, symlink, or directory to be deleted. -SB_EXPORT bool SbFileDelete(const char* path); - -#endif // SB_API_VERSION < 17 - -#if SB_API_VERSION < 16 -// Indicates whether a file or directory exists at |path|. -// -// |path|: The absolute path of the file or directory being checked. -SB_EXPORT bool SbFileExists(const char* path); -#endif // SB_API_VERSION < 16 - -#if SB_API_VERSION < 17 - -// DEPRECATED with SB_API_VERSION 16 -// -// Indicates whether SbFileOpen() with the given |flags| is allowed for |path|. -// -// |path|: The absolute path to be checked. -// |flags|: The flags that are being evaluated for the given |path|. -SB_EXPORT bool SbFileCanOpen(const char* path, int flags); - -// DEPRECATED with SB_API_VERSION 16 -// -// Converts an ISO |fopen()| mode string into flags that can be equivalently -// passed into SbFileOpen(). -// -// |mode|: The mode string to be converted into flags. -SB_EXPORT int SbFileModeStringToFlags(const char* mode); - -// DEPRECATED with SB_API_VERSION 16 -// -// Reads |size| bytes (or until EOF is reached) from |file| into |data|, -// starting at the file's current position. -// -// The return value specifies the number of bytes read or |-1| if there was -// an error. Note that, unlike |SbFileRead|, this function does make a best -// effort to read all data on all platforms. As such, it is not intended for -// stream-oriented files but instead for cases when the normal expectation is -// that |size| bytes can be read unless there is an error. -// -// |file|: The SbFile from which to read data. -// |data|: The variable to which data is read. -// |size|: The amount of data (in bytes) to read. -static inline int SbFileReadAll(SbFile file, char* data, int size) { - if (!SbFileIsValid(file) || size < 0) { - return -1; - } - int bytes_read = 0; - int rv; - do { - rv = SbFileRead(file, data + bytes_read, size - bytes_read); - if (rv <= 0) { - break; - } - bytes_read += rv; - } while (bytes_read < size); - - return bytes_read ? bytes_read : rv; -} - -// DEPRECATED with SB_API_VERSION 16 -// -// Writes the given buffer into |file|, starting at the beginning of the file, -// and overwriting any data that was previously there. Unlike SbFileWrite, this -// function does make a best effort to write all data on all platforms. -// -// The return value identifies the number of bytes written, or |-1| on error. -// -// |file|: The file to which data will be written. -// |data|: The data to be written. -// |size|: The amount of data (in bytes) to write. -static inline int SbFileWriteAll(SbFile file, const char* data, int size) { - if (!SbFileIsValid(file) || size < 0) { - return -1; - } - int bytes_written = 0; - int rv; - do { - rv = SbFileWrite(file, data + bytes_written, size - bytes_written); - if (rv <= 0) { - break; - } - bytes_written += rv; - } while (bytes_written < size); - - return bytes_written ? bytes_written : rv; -} - -#endif // SB_API_VERSION < 17 - #ifdef __cplusplus } // extern "C" #endif diff --git a/starboard/image.h b/starboard/image.h index 37f29c98ae8b..831abe177b1d 100644 --- a/starboard/image.h +++ b/starboard/image.h @@ -42,63 +42,6 @@ #ifndef STARBOARD_IMAGE_H_ #define STARBOARD_IMAGE_H_ -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/decode_target.h" -#include "starboard/export.h" -#include "starboard/types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// Whether the current platform supports hardware accelerated decoding an -// image of mime type |mime_type| into SbDecodeTargetFormat |format|. The -// |mime_type| must not be NULL. The result of this function must not change -// over the course of the program, which means that the results of this function -// may be cached indefinitely. -SB_EXPORT bool SbImageIsDecodeSupported(const char* mime_type, - SbDecodeTargetFormat format); - -// Attempt to decode encoded |mime_type| image data |data| of size |data_size| -// into an SbDecodeTarget of SbDecodeFormatType |format|, possibly using -// SbDecodeTargetProvider |provider|, if it is non-null. Thus, four following -// scenarios regarding the provider may happen: -// -// 1. The provider is required by the |SbImageDecode| implementation and no -// provider is given. The implementation should gracefully fail by -// immediately returning kSbDecodeTargetInvalid. -// 2. The provider is required and is passed in. The implementation will -// proceed forward, using the SbDecodeTarget from the provider. -// 3. The provider is not required and is passed in. The provider will NOT be -// called, and the implementation will proceed to decoding however it -// desires. -// 4. The provider is not required and is not passed in. The implementation -// will proceed forward. -// The |data| pointer must not be NULL. -// The |mime_type| string must not be NULL. -// Thus, it is NOT safe for clients of this API to assume that the |provider| -// it passes in will be called. Finally, if the decode succeeds, a new -// SbDecodeTarget will be allocated. If |mime_type| image decoding for the -// requested format is not supported or the decode fails, -// kSbDecodeTargetInvalid will be returned, with any intermediate allocations -// being cleaned up in the implementation. -SB_EXPORT SbDecodeTarget -SbImageDecode(SbDecodeTargetGraphicsContextProvider* context_provider, - void* data, - int data_size, - const char* mime_type, - SbDecodeTargetFormat format); - -#ifdef __cplusplus -} // extern "C" -#endif - -#else // SB_API_VERSION < 16 - #error This file is deprecated with SB_API_VERSION 16. -#endif // SB_API_VERSION < 16 - #endif // STARBOARD_IMAGE_H_ diff --git a/starboard/linux/shared/BUILD.gn b/starboard/linux/shared/BUILD.gn index ab821f26960c..c39d975fdd66 100644 --- a/starboard/linux/shared/BUILD.gn +++ b/starboard/linux/shared/BUILD.gn @@ -87,7 +87,6 @@ static_library("starboard_platform_sources") { "//starboard/linux/shared/routes.h", "//starboard/linux/shared/soft_mic_platform_service.cc", "//starboard/linux/shared/soft_mic_platform_service.h", - "//starboard/linux/shared/system_get_device_type.cc", "//starboard/linux/shared/system_get_extensions.cc", "//starboard/linux/shared/system_get_path.cc", "//starboard/linux/shared/system_has_capability.cc", @@ -100,13 +99,9 @@ static_library("starboard_platform_sources") { "//starboard/shared/egl/system_egl.cc", "//starboard/shared/gcc/atomic_gcc_public.h", "//starboard/shared/gles/system_gles2.cc", - "//starboard/shared/iso/directory_close.cc", - "//starboard/shared/iso/directory_get_next.cc", - "//starboard/shared/iso/directory_open.cc", "//starboard/shared/iso/memory_allocate_unchecked.cc", "//starboard/shared/iso/memory_free.cc", "//starboard/shared/iso/memory_reallocate_unchecked.cc", - "//starboard/shared/iso/string_scan.cc", "//starboard/shared/libdav1d/dav1d_video_decoder.cc", "//starboard/shared/libdav1d/dav1d_video_decoder.h", "//starboard/shared/libde265/de265_library_loader.cc", @@ -127,7 +122,6 @@ static_library("starboard_platform_sources") { "//starboard/shared/libfdkaac/libfdkaac_library_loader.h", "//starboard/shared/libvpx/vpx_video_decoder.cc", "//starboard/shared/libvpx/vpx_video_decoder.h", - "//starboard/shared/linux/byte_swap.cc", "//starboard/shared/linux/cpu_features_get.cc", "//starboard/shared/linux/dev_input/dev_input.cc", "//starboard/shared/linux/dev_input/dev_input.h", @@ -141,49 +135,25 @@ static_library("starboard_platform_sources") { "//starboard/shared/linux/system_network_status.cc", "//starboard/shared/linux/system_symbolize.cc", "//starboard/shared/linux/thread_get_id.cc", - "//starboard/shared/linux/thread_get_name.cc", - "//starboard/shared/linux/thread_set_name.cc", "//starboard/shared/linux/time_zone_get_name.cc", - "//starboard/shared/nouser/user_get_current.cc", - "//starboard/shared/nouser/user_get_property.cc", - "//starboard/shared/nouser/user_get_signed_in.cc", - "//starboard/shared/nouser/user_internal.cc", "//starboard/shared/openh264/openh264_library_loader.cc", "//starboard/shared/openh264/openh264_library_loader.h", "//starboard/shared/openh264/openh264_video_decoder.cc", "//starboard/shared/openh264/openh264_video_decoder.h", "//starboard/shared/opus/opus_audio_decoder.cc", "//starboard/shared/opus/opus_audio_decoder.h", - "//starboard/shared/posix/directory_create.cc", "//starboard/shared/posix/environment.cc", "//starboard/shared/posix/file_atomic_replace.cc", - "//starboard/shared/posix/file_can_open.cc", - "//starboard/shared/posix/file_close.cc", - "//starboard/shared/posix/file_delete.cc", - "//starboard/shared/posix/file_exists.cc", - "//starboard/shared/posix/file_flush.cc", - "//starboard/shared/posix/file_get_info.cc", - "//starboard/shared/posix/file_get_path_info.cc", - "//starboard/shared/posix/file_open.cc", - "//starboard/shared/posix/file_read.cc", - "//starboard/shared/posix/file_seek.cc", - "//starboard/shared/posix/file_truncate.cc", - "//starboard/shared/posix/file_write.cc", "//starboard/shared/posix/free_space.cc", "//starboard/shared/posix/free_space.h", "//starboard/shared/posix/log.cc", "//starboard/shared/posix/log_flush.cc", "//starboard/shared/posix/log_format.cc", - "//starboard/shared/posix/log_is_tty.cc", "//starboard/shared/posix/log_raw.cc", "//starboard/shared/posix/memory_allocate_aligned_unchecked.cc", - "//starboard/shared/posix/memory_flush.cc", "//starboard/shared/posix/memory_free_aligned.cc", - "//starboard/shared/posix/memory_map.cc", "//starboard/shared/posix/memory_mapped_file.cc", "//starboard/shared/posix/memory_mapped_file.h", - "//starboard/shared/posix/memory_protect.cc", - "//starboard/shared/posix/memory_unmap.cc", "//starboard/shared/posix/page_internal.cc", "//starboard/shared/posix/set_non_blocking_internal.cc", "//starboard/shared/posix/socket_accept.cc", @@ -212,10 +182,6 @@ static_library("starboard_platform_sources") { "//starboard/shared/posix/socket_set_tcp_no_delay.cc", "//starboard/shared/posix/socket_set_tcp_window_scaling.cc", "//starboard/shared/posix/storage_write_record.cc", - "//starboard/shared/posix/string_compare_no_case.cc", - "//starboard/shared/posix/string_compare_no_case_n.cc", - "//starboard/shared/posix/string_format.cc", - "//starboard/shared/posix/string_format_wide.cc", "//starboard/shared/posix/system_break_into_debugger.cc", "//starboard/shared/posix/system_clear_last_error.cc", "//starboard/shared/posix/system_get_error_string.cc", @@ -223,35 +189,11 @@ static_library("starboard_platform_sources") { "//starboard/shared/posix/system_get_locale_id.cc", "//starboard/shared/posix/system_get_number_of_processors.cc", "//starboard/shared/posix/thread_sleep.cc", - "//starboard/shared/posix/time_get_monotonic_now.cc", - "//starboard/shared/posix/time_get_monotonic_thread_now.cc", - "//starboard/shared/posix/time_get_now.cc", - "//starboard/shared/posix/time_is_time_thread_now_supported.cc", "//starboard/shared/posix/time_zone_get_current.cc", - "//starboard/shared/pthread/condition_variable_broadcast.cc", - "//starboard/shared/pthread/condition_variable_create.cc", - "//starboard/shared/pthread/condition_variable_destroy.cc", - "//starboard/shared/pthread/condition_variable_signal.cc", - "//starboard/shared/pthread/condition_variable_wait.cc", - "//starboard/shared/pthread/condition_variable_wait_timed.cc", - "//starboard/shared/pthread/mutex_acquire.cc", - "//starboard/shared/pthread/mutex_acquire_try.cc", - "//starboard/shared/pthread/mutex_create.cc", - "//starboard/shared/pthread/mutex_destroy.cc", - "//starboard/shared/pthread/mutex_release.cc", - "//starboard/shared/pthread/once.cc", "//starboard/shared/pthread/thread_context_get_pointer.cc", "//starboard/shared/pthread/thread_context_internal.cc", "//starboard/shared/pthread/thread_context_internal.h", - "//starboard/shared/pthread/thread_create.cc", - "//starboard/shared/pthread/thread_create_local_key.cc", "//starboard/shared/pthread/thread_create_priority.h", - "//starboard/shared/pthread/thread_destroy_local_key.cc", - "//starboard/shared/pthread/thread_detach.cc", - "//starboard/shared/pthread/thread_get_current.cc", - "//starboard/shared/pthread/thread_get_local_value.cc", - "//starboard/shared/pthread/thread_is_equal.cc", - "//starboard/shared/pthread/thread_join.cc", "//starboard/shared/pthread/thread_priority.cc", "//starboard/shared/pthread/thread_sampler_create.cc", "//starboard/shared/pthread/thread_sampler_destroy.cc", @@ -260,7 +202,6 @@ static_library("starboard_platform_sources") { "//starboard/shared/pthread/thread_sampler_internal.h", "//starboard/shared/pthread/thread_sampler_is_supported.cc", "//starboard/shared/pthread/thread_sampler_thaw.cc", - "//starboard/shared/pthread/thread_set_local_value.cc", "//starboard/shared/pthread/thread_yield.cc", "//starboard/shared/pulse/pulse_audio_sink_type.cc", "//starboard/shared/pulse/pulse_audio_sink_type.h", @@ -291,12 +232,10 @@ static_library("starboard_platform_sources") { "//starboard/shared/starboard/command_line.h", "//starboard/shared/starboard/crash_handler.cc", "//starboard/shared/starboard/crash_handler.h", - "//starboard/shared/starboard/directory_can_open.cc", "//starboard/shared/starboard/event_cancel.cc", "//starboard/shared/starboard/event_schedule.cc", "//starboard/shared/starboard/file_atomic_replace_write_file.cc", "//starboard/shared/starboard/file_atomic_replace_write_file.h", - "//starboard/shared/starboard/file_mode_string_to_flags.cc", "//starboard/shared/starboard/file_storage/storage_close_record.cc", "//starboard/shared/starboard/file_storage/storage_delete_record.cc", "//starboard/shared/starboard/file_storage/storage_get_record_size.cc", @@ -314,16 +253,13 @@ static_library("starboard_platform_sources") { "//starboard/shared/starboard/media/media_get_buffer_allocation_unit.cc", "//starboard/shared/starboard/media/media_get_buffer_garbage_collection_duration_threshold.cc", "//starboard/shared/starboard/media/media_get_buffer_padding.cc", - "//starboard/shared/starboard/media/media_get_buffer_storage_type.cc", "//starboard/shared/starboard/media/media_get_initial_buffer_capacity.cc", "//starboard/shared/starboard/media/media_get_max_buffer_capacity.cc", "//starboard/shared/starboard/media/media_get_progressive_buffer_budget.cc", "//starboard/shared/starboard/media/media_get_video_buffer_budget.cc", "//starboard/shared/starboard/media/media_is_buffer_pool_allocate_on_demand.cc", "//starboard/shared/starboard/media/media_is_buffer_using_memory_pool.cc", - "//starboard/shared/starboard/memory.cc", "//starboard/shared/starboard/queue_application.cc", - "//starboard/shared/starboard/string_duplicate.cc", "//starboard/shared/starboard/system_get_random_uint64.cc", "//starboard/shared/starboard/system_request_blur.cc", "//starboard/shared/starboard/system_request_focus.cc", @@ -331,10 +267,6 @@ static_library("starboard_platform_sources") { "//starboard/shared/starboard/system_request_stop.cc", "//starboard/shared/starboard/system_supports_resume.cc", "//starboard/shared/starboard/window_set_default_options.cc", - "//starboard/shared/stub/accessibility_get_caption_settings.cc", - "//starboard/shared/stub/accessibility_get_display_settings.cc", - "//starboard/shared/stub/accessibility_get_text_to_speech_settings.cc", - "//starboard/shared/stub/accessibility_set_captions_enabled.cc", "//starboard/shared/stub/microphone_close.cc", "//starboard/shared/stub/microphone_create.cc", "//starboard/shared/stub/microphone_destroy.cc", @@ -351,18 +283,7 @@ static_library("starboard_platform_sources") { "//starboard/shared/stub/system_raise_platform_error.cc", "//starboard/shared/stub/system_sign_with_certification_secret_key.cc", "//starboard/shared/stub/thread_create_priority.cc", - "//starboard/shared/stub/ui_nav_get_interface.cc", - "//starboard/shared/stub/window_blur_on_screen_keyboard.cc", - "//starboard/shared/stub/window_focus_on_screen_keyboard.cc", "//starboard/shared/stub/window_get_diagonal_size_in_inches.cc", - "//starboard/shared/stub/window_get_on_screen_keyboard_bounding_rect.cc", - "//starboard/shared/stub/window_hide_on_screen_keyboard.cc", - "//starboard/shared/stub/window_is_on_screen_keyboard_shown.cc", - "//starboard/shared/stub/window_on_screen_keyboard_is_supported.cc", - "//starboard/shared/stub/window_on_screen_keyboard_suggestions_supported.cc", - "//starboard/shared/stub/window_set_on_screen_keyboard_keep_focus.cc", - "//starboard/shared/stub/window_show_on_screen_keyboard.cc", - "//starboard/shared/stub/window_update_on_screen_keyboard_suggestions.cc", ] sources += common_player_sources @@ -376,11 +297,6 @@ static_library("starboard_platform_sources") { ] } - if (sb_api_version < 15) { - sources -= [ "//starboard/shared/starboard/player/player_write_samples.cc" ] - sources += enhanced_audio_sources - } - configs += [ "//starboard/build/config:starboard_implementation", "//third_party/dav1d:public_dav1d_config", diff --git a/starboard/linux/shared/configuration_constants.cc b/starboard/linux/shared/configuration_constants.cc index c5c5fb9725ea..03688816a91a 100644 --- a/starboard/linux/shared/configuration_constants.cc +++ b/starboard/linux/shared/configuration_constants.cc @@ -122,11 +122,6 @@ const char* kSbPathSepString = ":"; // generally prefer a byte order of RGBA, regardless of endianness. const int kSbPreferredRgbaByteOrder = SB_PREFERRED_RGBA_BYTE_ORDER_RGBA; -#if SB_API_VERSION < 16 -// The maximum number of users that can be signed in at the same time. -const uint32_t kSbUserMaxSignedIn = 1; -#endif // SB_API_VERSION < 16 - // The maximum size the cache directory is allowed to use in bytes. const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB diff --git a/starboard/linux/shared/configuration_public.h b/starboard/linux/shared/configuration_public.h index e45b0e53f6e6..9319103f9bf2 100644 --- a/starboard/linux/shared/configuration_public.h +++ b/starboard/linux/shared/configuration_public.h @@ -49,32 +49,6 @@ #define SB_IS_WCHAR_T_UNSIGNED 1 #endif -// --- Attribute Configuration ----------------------------------------------- - -#if SB_API_VERSION < 16 -// The platform's annotation for forcing a C function to be inlined. -#define SB_C_FORCE_INLINE __inline__ __attribute__((always_inline)) - -// The platform's annotation for marking a C function as suggested to be -// inlined. -#define SB_C_INLINE inline - -// The platform's annotation for marking a symbol as exported outside of the -// current shared library. -#define SB_EXPORT_PLATFORM __attribute__((visibility("default"))) - -// The platform's annotation for marking a symbol as imported from outside of -// the current linking unit. -#define SB_IMPORT_PLATFORM - -// --- Memory Configuration -------------------------------------------------- - -// Whether this platform can map executable memory. Implies SB_HAS_MMAP. This is -// required for platforms that want to JIT. -#define SB_CAN_MAP_EXECUTABLE_MEMORY 1 - -#endif // SB_API_VERSION < 16 - // --- Network Configuration ------------------------------------------------- // Specifies whether this platform supports IPV6. diff --git a/starboard/linux/shared/system_get_device_type.cc b/starboard/linux/shared/system_get_device_type.cc deleted file mode 100644 index ba90dbc08077..000000000000 --- a/starboard/linux/shared/system_get_device_type.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#if SB_API_VERSION < 15 - -SbSystemDeviceType SbSystemGetDeviceType() { - return kSbSystemDeviceTypeDesktopPC; -} - -#endif diff --git a/starboard/linux/shared/system_get_extensions.cc b/starboard/linux/shared/system_get_extensions.cc index 454bf3abe3f8..70f80c2db680 100644 --- a/starboard/linux/shared/system_get_extensions.cc +++ b/starboard/linux/shared/system_get_extensions.cc @@ -71,11 +71,6 @@ const void* SbSystemGetExtension(const char* name) { if (strcmp(name, kCobaltExtensionFreeSpaceName) == 0) { return starboard::shared::posix::GetFreeSpaceApi(); } -#if SB_API_VERSION < 15 - if (strcmp(name, kCobaltExtensionEnhancedAudioName) == 0) { - return starboard::shared::enhanced_audio::GetEnhancedAudioApi(); - } -#endif // SB_API_VERSION < 15 if (strcmp(name, kCobaltExtensionDemuxerApi) == 0) { auto command_line = starboard::shared::starboard::Application::Get()->GetCommandLine(); diff --git a/starboard/linux/x64x11/shared/BUILD.gn b/starboard/linux/x64x11/shared/BUILD.gn index eff90ec89710..bf88c3a5483c 100644 --- a/starboard/linux/x64x11/shared/BUILD.gn +++ b/starboard/linux/x64x11/shared/BUILD.gn @@ -38,8 +38,6 @@ static_library("starboard_platform_sources") { sources = [ "//starboard/linux/x64x11/system_get_property.cc", "//starboard/linux/x64x11/system_get_property_impl.cc", - "//starboard/shared/libjpeg/image_decode.cc", - "//starboard/shared/libjpeg/image_is_decode_supported.cc", "//starboard/shared/libjpeg/jpeg_image_decoder.cc", "//starboard/shared/libjpeg/jpeg_image_decoder.h", "//starboard/shared/starboard/link_receiver.cc", diff --git a/starboard/linux/x64x11/system_get_property_impl.cc b/starboard/linux/x64x11/system_get_property_impl.cc index 9a5f9e3db438..aaa660f57251 100644 --- a/starboard/linux/x64x11/system_get_property_impl.cc +++ b/starboard/linux/x64x11/system_get_property_impl.cc @@ -36,14 +36,6 @@ const char kSystemIntegratorName[] = "SystemIntegratorName"; const char kModelYear[] = "2026"; #endif // SB_API_VERSION == 17 -#if SB_API_VERSION == 16 -const char kModelYear[] = "2025"; -#endif // SB_API_VERSION == 16 - -#if SB_API_VERSION == 15 -const char kModelYear[] = "2024"; -#endif // SB_API_VERSION == 15 - } // namespace // Omit namespace linux due to symbol name conflict. diff --git a/starboard/log.h b/starboard/log.h index 51dc73aa6c32..4052d442a0fb 100644 --- a/starboard/log.h +++ b/starboard/log.h @@ -105,11 +105,6 @@ static inline void SbLogFormatF(const char* format, ...) { // multiple threads. SB_EXPORT void SbLogFlush(); -#if SB_API_VERSION < 16 -// Indicates whether the log output goes to a TTY or is being redirected. -SB_EXPORT bool SbLogIsTty(); -#endif - #ifdef __cplusplus } // extern "C" #endif diff --git a/starboard/media.h b/starboard/media.h index 182e8000e91e..2227ad7de07c 100644 --- a/starboard/media.h +++ b/starboard/media.h @@ -133,9 +133,6 @@ typedef enum SbMediaAudioCodingType { typedef enum SbMediaAudioSampleType { kSbMediaAudioSampleTypeInt16Deprecated, kSbMediaAudioSampleTypeFloat32, -#if SB_API_VERSION <= 15 && SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) - kSbMediaAudioSampleTypeInt16 = kSbMediaAudioSampleTypeInt16Deprecated, -#endif // SB_API_VERSION <= 15 && SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) } SbMediaAudioSampleType; // Possible audio frame storage types. @@ -499,11 +496,6 @@ typedef struct SbMediaVideoSampleInfo { // A structure describing the audio configuration parameters of a single audio // output. typedef struct SbMediaAudioConfiguration { -#if SB_API_VERSION < 15 - // The platform-defined index of the associated audio output. - int index; -#endif // SB_API_VERSION < 15 - #if SB_API_VERSION >= 15 // The type of audio connector. Will be |kSbMediaAudioConnectorUnknown| if // this device cannot provide this information. @@ -685,13 +677,6 @@ SB_EXPORT bool SbMediaGetAudioConfiguration( // Value used when a video's bits per pixel is not known. #define kSbMediaBitsPerPixelInvalid 0 -#if SB_API_VERSION < 16 -typedef enum SbMediaBufferStorageType { - kSbMediaBufferStorageTypeMemory, - kSbMediaBufferStorageTypeFile, -} SbMediaBufferStorageType; -#endif // SB_API_VERSION < 16 - // DEPRECATED with SB_API_VERSION 16 // // SbMediaGetBufferAlignment() was deprecated in Starboard 16, its return value @@ -808,17 +793,6 @@ SB_EXPORT int SbMediaGetProgressiveBufferBudget(SbMediaVideoCodec codec, int resolution_height, int bits_per_pixel); -#if SB_API_VERSION < 16 -// Returns SbMediaBufferStorageType of type |SbMediaStorageTypeMemory| or -// |SbMediaStorageTypeFile|. For memory storage, the media buffers will be -// stored in main memory allocated by malloc functions. For file storage, the -// media buffers will be stored in a temporary file in the system cache folder -// acquired by calling SbSystemGetPath() with "kSbSystemPathCacheDirectory". -// Note that when its value is "file" the media stack will still allocate memory -// to cache the buffers in use. -SB_EXPORT SbMediaBufferStorageType SbMediaGetBufferStorageType(); -#endif // SB_API_VERSION < 16 - // DEPRECATED with SB_API_VERSION 16 // // This function is deprecated in Starboard 16 and no longer used. It's not diff --git a/starboard/memory.h b/starboard/memory.h index cb8a1950f0b1..4ca129afd81e 100644 --- a/starboard/memory.h +++ b/starboard/memory.h @@ -65,199 +65,6 @@ typedef enum SbMemoryMapFlags { kSbMemoryMapProtectRead | kSbMemoryMapProtectWrite, } SbMemoryMapFlags; -#if SB_API_VERSION < 16 - -#define SB_MEMORY_MAP_FAILED ((void*)-1) // NOLINT(readability/casting) - -static SB_C_FORCE_INLINE void SbAbortIfAllocationFailed(size_t requested_bytes, - void* address) { - if (SB_UNLIKELY(requested_bytes > 0 && address == NULL)) { - // Will abort the program if no debugger is attached. - SbSystemBreakIntoDebugger(); - } -} - -// Allocates and returns a chunk of memory of at least |size| bytes. This -// function should be called from the client codebase. It is intended to be a -// drop-in replacement for |malloc|. -// -// Note that this function returns |NULL| if it is unable to allocate the -// memory. -// -// |size|: The amount of memory to be allocated. If |size| is 0, the function -// may return |NULL| or it may return a unique pointer value that can be -// passed to SbMemoryDeallocate. -SB_EXPORT void* SbMemoryAllocate(size_t size); - -// DEPRECATED: Same as SbMemoryAllocate(). -SB_EXPORT void* SbMemoryAllocateNoReport(size_t size); - -// Attempts to resize |memory| to be at least |size| bytes, without touching -// the contents of memory. -// - If the function cannot perform the fast resize, it allocates a new chunk -// of memory, copies the contents over, and frees the previous chunk, -// returning a pointer to the new chunk. -// - If the function cannot perform the slow resize, it returns |NULL|, -// leaving the given memory chunk unchanged. -// -// This function should be called from the client codebase. It is meant to be a -// drop-in replacement for |realloc|. -// -// |memory|: The chunk of memory to be resized. |memory| may be NULL, in which -// case it behaves exactly like SbMemoryAllocateUnchecked. -// |size|: The size to which |memory| will be resized. If |size| is |0|, -// the function may return |NULL| or it may return a unique pointer value -// that can be passed to SbMemoryDeallocate. -SB_EXPORT void* SbMemoryReallocate(void* memory, size_t size); - -// Allocates and returns a chunk of memory of at least |size| bytes, aligned to -// |alignment|. This function should be called from the client codebase. It is -// meant to be a drop-in replacement for |memalign|. -// -// The function returns |NULL| if it cannot allocate the memory. In addition, -// the function's behavior is undefined if |alignment| is not a power of two. -// -// |alignment|: The way that data is arranged and accessed in memory. The value -// must be a power of two. -// |size|: The size of the memory to be allocated. If |size| is |0|, the -// function may return |NULL| or it may return a unique aligned pointer value -// that can be passed to SbMemoryDeallocateAligned. -SB_EXPORT void* SbMemoryAllocateAligned(size_t alignment, size_t size); - -// Frees a previously allocated chunk of memory. If |memory| is NULL, then the -// operation is a no-op. This function should be called from the client -// codebase. It is meant to be a drop-in replacement for |free|. -// -// |memory|: The chunk of memory to be freed. -SB_EXPORT void SbMemoryDeallocate(void* memory); - -// DEPRECATED: Same as SbMemoryDeallocate() -SB_EXPORT void SbMemoryDeallocateNoReport(void* memory); - -// Frees a previously allocated chunk of aligned memory. This function should -// be called from the client codebase. It is meant to be a drop-in replacement -// for |_aligned_free|. - -// |memory|: The chunk of memory to be freed. If |memory| is NULL, then the -// function is a no-op. -SB_EXPORT void SbMemoryDeallocateAligned(void* memory); - -///////////////////////////////////////////////////////////////// -// The following functions must be provided by Starboard ports. -///////////////////////////////////////////////////////////////// - -// This is the implementation of SbMemoryAllocate that must be -// provided by Starboard ports. -// -// DO NOT CALL. Call SbMemoryAllocate(...) instead. -SB_DEPRECATED_EXTERNAL(SB_EXPORT void* SbMemoryAllocateUnchecked(size_t size)); - -// This is the implementation of SbMemoryReallocate that must be -// provided by Starboard ports. -// -// DO NOT CALL. Call SbMemoryReallocate(...) instead. -SB_DEPRECATED_EXTERNAL( - SB_EXPORT void* SbMemoryReallocateUnchecked(void* memory, size_t size)); - -// This is the implementation of SbMemoryAllocateAligned that must be -// provided by Starboard ports. -// -// DO NOT CALL. Call SbMemoryAllocateAligned(...) instead. -SB_DEPRECATED_EXTERNAL( - SB_EXPORT void* SbMemoryAllocateAlignedUnchecked(size_t alignment, - size_t size)); - -// This is the implementation of SbMemoryDeallocate that must be provided by -// Starboard ports. -// -// DO NOT CALL. Call SbMemoryDeallocate(...) instead. -SB_DEPRECATED_EXTERNAL(SB_EXPORT void SbMemoryFree(void* memory)); - -// This is the implementation of SbMemoryFreeAligned that must be provided by -// Starboard ports. -// -// DO NOT CALL. Call SbMemoryDeallocateAligned(...) instead. -SB_DEPRECATED_EXTERNAL(SB_EXPORT void SbMemoryFreeAligned(void* memory)); - -// Allocates |size_bytes| worth of physical memory pages and maps them into -// an available virtual region. This function returns |SB_MEMORY_MAP_FAILED| -// on failure. |NULL| is a valid return value. -// -// |size_bytes|: The amount of physical memory pages to be allocated. -// |flags|: The bitwise OR of the protection flags for the mapped memory -// as specified in |SbMemoryMapFlags|. Allocating executable memory is not -// allowed and will fail. If executable memory is needed, map non-executable -// memory first and then switch access to executable using SbMemoryProtect. -// When kSbMemoryMapProtectReserved is used, the address space will not be -// accessible and, if possible, the platform should not count it against any -// memory budget. -// |name|: A value that appears in the debugger on some platforms. The value -// can be up to 32 bytes. -SB_EXPORT void* SbMemoryMap(int64_t size_bytes, int flags, const char* name); - -// Unmap |size_bytes| of physical pages starting from |virtual_address|, -// returning |true| on success. After this function completes, -// [virtual_address, virtual_address + size_bytes) will not be read/writable. -// This function can unmap multiple contiguous regions that were mapped with -// separate calls to SbMemoryMap(). For example, if one call to -// |SbMemoryMap(0x1000)| returns |(void*)0xA000|, and another call to -// |SbMemoryMap(0x1000)| returns |(void*)0xB000|, -// |SbMemoryUnmap(0xA000, 0x2000)| should free both regions. -SB_EXPORT bool SbMemoryUnmap(void* virtual_address, int64_t size_bytes); - -// Change the protection of |size_bytes| of memory regions, starting from -// |virtual_address|, to |flags|, returning |true| on success. -SB_EXPORT bool SbMemoryProtect(void* virtual_address, - int64_t size_bytes, - int flags); - -#if SB_CAN(MAP_EXECUTABLE_MEMORY) -// Flushes any data in the given virtual address range that is cached locally in -// the current processor core to physical memory, ensuring that data and -// instruction caches are cleared. This is required to be called on executable -// memory that has been written to and might be executed in the future. -SB_EXPORT void SbMemoryFlush(void* virtual_address, int64_t size_bytes); -#endif -#endif // SB_API_VERSION < 16 - -#if SB_API_VERSION < 16 -// A wrapper that implements a drop-in replacement for |calloc|, which is used -// in some packages. -static SB_C_INLINE void* SbMemoryCalloc(size_t count, size_t size) { - size_t total = count * size; - void* result = SbMemoryAllocate(total); - if (result) { - memset(result, 0, total); - } - return result; -} - -///////////////////////////////////////////////////////////////// -// Deprecated. Do not use. -///////////////////////////////////////////////////////////////// - -// Same as SbMemoryAllocateUnchecked, but will abort() in the case of an -// allocation failure. -// -// DO NOT CALL. Call SbMemoryAllocate(...) instead. -SB_DEPRECATED_EXTERNAL(SB_EXPORT void* SbMemoryAllocateChecked(size_t size)); - -// Same as SbMemoryReallocateUnchecked, but will abort() in the case of an -// allocation failure. -// -// DO NOT CALL. Call SbMemoryReallocate(...) instead. -SB_DEPRECATED_EXTERNAL(SB_EXPORT void* SbMemoryReallocateChecked(void* memory, - size_t size)); - -// Same as SbMemoryAllocateAlignedUnchecked, but will abort() in the case of an -// allocation failure. -// -// DO NOT CALL. Call SbMemoryAllocateAligned(...) instead. -SB_DEPRECATED_EXTERNAL( - SB_EXPORT void* SbMemoryAllocateAlignedChecked(size_t alignment, - size_t size)); -#endif // SB_API_VERSION < 16 - #ifdef __cplusplus } // extern "C" #endif diff --git a/starboard/nplb/BUILD.gn b/starboard/nplb/BUILD.gn index 60480a16dc5e..eac950c60671 100644 --- a/starboard/nplb/BUILD.gn +++ b/starboard/nplb/BUILD.gn @@ -29,7 +29,6 @@ target(gtest_target_type, "nplb") { "//starboard/shared/starboard/drm/drm_test_helpers.h", "//starboard/testing/fake_graphics_context_provider.cc", "//starboard/testing/fake_graphics_context_provider.h", - "accessibility_test.cc", "align_test.cc", "atomic_base_test.cc", "atomic_test.cc", @@ -43,21 +42,9 @@ target(gtest_target_type, "nplb") { "audio_sink_is_audio_frame_storage_type_supported_test.cc", "audio_sink_is_audio_sample_type_supported_test.cc", "audio_sink_test.cc", - "byte_swap_test.cc", "char_is_signed_test.cc", - "condition_variable_broadcast_test.cc", - "condition_variable_create_test.cc", - "condition_variable_destroy_test.cc", - "condition_variable_signal_test.cc", - "condition_variable_wait_test.cc", - "condition_variable_wait_timed_test.cc", "configuration_test.cc", "cpu_features_get_test.cc", - "directory_can_open_test.cc", - "directory_close_test.cc", - "directory_create_test.cc", - "directory_get_next_test.cc", - "directory_open_test.cc", "drm_get_metrics_test.cc", "drm_helpers.h", "drm_is_server_certificate_updatable_test.cc", @@ -66,29 +53,15 @@ target(gtest_target_type, "nplb") { "egl_test.cc", "extern_c_test.cc", "file_atomic_replace_test.cc", - "file_can_open_test.cc", - "file_close_test.cc", "file_delete_recursive_test.cc", - "file_delete_test.cc", - "file_get_info_test.cc", - "file_get_path_info_test.cc", "file_helpers.cc", - "file_mode_string_to_flags_test.cc", - "file_open_test.cc", - "file_read_test.cc", - "file_read_write_all_test.cc", - "file_seek_test.cc", - "file_truncate_test.cc", - "file_write_test.cc", "flat_map_test.cc", "gles_test.cc", - "image_test.cc", "include_all.c", "include_all_too.c", "key_test.cc", "log_flush_test.cc", "log_format_test.cc", - "log_is_tty_test.cc", "log_raw_dump_stack_test.cc", "log_raw_test.cc", "log_test.cc", @@ -103,12 +76,6 @@ target(gtest_target_type, "nplb") { "media_can_play_mime_and_key_system_test.cc", "media_configuration_test.cc", "media_set_audio_write_duration_test.cc", - "memory_allocate_aligned_test.cc", - "memory_allocate_test.cc", - "memory_deallocate_aligned_test.cc", - "memory_deallocate_test.cc", - "memory_map_test.cc", - "memory_reallocate_test.cc", "microphone_close_test.cc", "microphone_create_test.cc", "microphone_destroy_test.cc", @@ -118,11 +85,6 @@ target(gtest_target_type, "nplb") { "microphone_read_test.cc", "multiple_player_test.cc", "murmurhash2_test.cc", - "mutex_acquire_test.cc", - "mutex_acquire_try_test.cc", - "mutex_create_test.cc", - "mutex_destroy_test.cc", - "once_test.cc", "optional_test.cc", "player_create_test.cc", "player_creation_param_helpers.cc", @@ -238,14 +200,6 @@ target(gtest_target_type, "nplb") { "storage_get_record_size_test.cc", "storage_read_record_test.cc", "storage_write_record_test.cc", - "string_compare_no_case_n_test.cc", - "string_compare_no_case_test.cc", - "string_duplicate_test.cc", - - # TODO: b/307941391: test "SbStringFormatWideTest" is deprecated in SB16 - "string_format_test.cc", - "string_format_wide_test.cc", - "string_scan_test.cc", "system_clear_last_error_test.cc", "system_get_error_string_test.cc", "system_get_extension_test.cc", @@ -267,32 +221,15 @@ target(gtest_target_type, "nplb") { "system_network_status_test.cc", "system_sign_with_certification_secret_key_test.cc", "system_symbolize_test.cc", - "thread_create_test.cc", - "thread_detach_test.cc", - "thread_get_current_test.cc", "thread_get_id_test.cc", - "thread_get_name_test.cc", - "thread_helpers.cc", - "thread_is_equal_test.cc", - "thread_join_test.cc", - "thread_local_value_test.cc", "thread_priority_test.cc", "thread_sampler_test.cc", - "thread_set_name_test.cc", - "thread_sleep_test.cc", "thread_test.cc", - "thread_yield_test.cc", - "time_get_monotonic_now_test.cc", - "time_get_now_test.cc", - "time_narrow_test.cc", "time_zone_get_current_test.cc", "time_zone_get_name_test.cc", "ui_navigation_test.cc", "undefined_behavior_test.cc", "url_player_create_test.cc", - "user_get_current_test.cc", - "user_get_property_test.cc", - "user_get_signed_in_test.cc", "vertical_video_test.cc", "window_create_test.cc", "window_destroy_test.cc", diff --git a/starboard/nplb/accessibility_test.cc b/starboard/nplb/accessibility_test.cc deleted file mode 100644 index 4b02ceb98fb7..000000000000 --- a/starboard/nplb/accessibility_test.cc +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/accessibility.h" -#include "starboard/memory.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbAccessibilityTest, CanCallGetTextToSpeechSettings) { - SbAccessibilityTextToSpeechSettings settings = {0}; - EXPECT_TRUE(SbAccessibilityGetTextToSpeechSettings(&settings)); -} - -TEST(SbAccessibilityTest, CallTextToSpeechWithInvalidArgument) { - // |settings| should be zero-initialized. - SbAccessibilityTextToSpeechSettings settings = {1}; - EXPECT_FALSE(SbAccessibilityGetTextToSpeechSettings(&settings)); - - // Argument should not be NULL. - EXPECT_FALSE(SbAccessibilityGetTextToSpeechSettings(NULL)); -} - -TEST(SbAccessibilityTest, CanCallGetDisplaySettings) { - SbAccessibilityDisplaySettings settings = {0}; - EXPECT_TRUE(SbAccessibilityGetDisplaySettings(&settings)); -} - -TEST(SbAccessibilityTest, CallDisplayWithInvalidArgument) { - // |settings| should be zero-initialized. - SbAccessibilityDisplaySettings settings = {1}; - EXPECT_FALSE(SbAccessibilityGetDisplaySettings(&settings)); - - // Argument should not be NULL. - EXPECT_FALSE(SbAccessibilityGetDisplaySettings(NULL)); -} - -TEST(SbAccessibilityTest, CallGetCaptionSettingsWithInvalidArgument) { - // |settings| should be zero-initialized. - const int kInvalidValue = 0xFE; - SbAccessibilityCaptionSettings settings; - memset(&settings, kInvalidValue, sizeof(settings)); - EXPECT_FALSE(SbAccessibilityGetCaptionSettings(&settings)); - - // Argument should not be NULL. - EXPECT_FALSE(SbAccessibilityGetCaptionSettings(NULL)); -} - -TEST(SbAccessibilityTest, GetCaptionSettingsReturnIsValid) { - // |settings| should be zero-initialized. - SbAccessibilityCaptionSettings settings; - const int kValidInitialValue = 0; - memset(&settings, kValidInitialValue, sizeof(settings)); - EXPECT_TRUE(SbAccessibilityGetCaptionSettings(&settings)); - - if (settings.background_color_state != - kSbAccessibilityCaptionStateUnsupported) { - EXPECT_GE(settings.background_color, kSbAccessibilityCaptionColorBlue); - EXPECT_LE(settings.background_color, kSbAccessibilityCaptionColorYellow); - } - - if (settings.background_opacity_state != - kSbAccessibilityCaptionStateUnsupported) { - EXPECT_GE(settings.background_opacity, - kSbAccessibilityCaptionOpacityPercentage0); - EXPECT_LE(settings.background_opacity, - kSbAccessibilityCaptionOpacityPercentage100); - } - - if (settings.character_edge_style_state != - kSbAccessibilityCaptionStateUnsupported) { - EXPECT_GE(settings.character_edge_style, - kSbAccessibilityCaptionCharacterEdgeStyleNone); - EXPECT_LE(settings.character_edge_style, - kSbAccessibilityCaptionCharacterEdgeStyleDropShadow); - } - - if (settings.font_color_state != kSbAccessibilityCaptionStateUnsupported) { - EXPECT_GE(settings.font_color, kSbAccessibilityCaptionColorBlue); - EXPECT_LE(settings.font_color, kSbAccessibilityCaptionColorYellow); - } - - if (settings.font_family_state != kSbAccessibilityCaptionStateUnsupported) { - EXPECT_GE(settings.font_family, kSbAccessibilityCaptionFontFamilyCasual); - EXPECT_LE(settings.font_family, - kSbAccessibilityCaptionFontFamilySmallCapitals); - } - - if (settings.font_opacity_state != kSbAccessibilityCaptionStateUnsupported) { - EXPECT_GE(settings.font_opacity, kSbAccessibilityCaptionOpacityPercentage0); - EXPECT_LE(settings.font_opacity, - kSbAccessibilityCaptionOpacityPercentage100); - } - - if (settings.font_size_state != kSbAccessibilityCaptionStateUnsupported) { - EXPECT_GE(settings.font_size, kSbAccessibilityCaptionFontSizePercentage25); - EXPECT_LE(settings.font_size, kSbAccessibilityCaptionFontSizePercentage300); - } - - if (settings.window_color_state != kSbAccessibilityCaptionStateUnsupported) { - EXPECT_GE(settings.window_color, kSbAccessibilityCaptionColorBlue); - EXPECT_LE(settings.window_color, kSbAccessibilityCaptionColorYellow); - } - - if (settings.window_opacity_state != - kSbAccessibilityCaptionStateUnsupported) { - EXPECT_GE(settings.window_opacity, - kSbAccessibilityCaptionOpacityPercentage0); - EXPECT_LE(settings.window_opacity, - kSbAccessibilityCaptionOpacityPercentage100); - } -} - -TEST(SbAccessibilityTest, CallSetCaptionsEnabled) { - SbAccessibilityCaptionSettings settings; - const int kValidInitialValue = 0; - memset(&settings, kValidInitialValue, sizeof(settings)); - EXPECT_TRUE(SbAccessibilityGetCaptionSettings(&settings)); - - if (settings.supports_is_enabled && settings.supports_set_enabled) { - // Try changing the enabled state. - EXPECT_TRUE(SbAccessibilitySetCaptionsEnabled(!settings.is_enabled)); - - SbAccessibilityCaptionSettings settings2; - memset(&settings2, kValidInitialValue, sizeof(settings2)); - EXPECT_TRUE(SbAccessibilityGetCaptionSettings(&settings2)); - EXPECT_NE(settings.is_enabled, settings2.is_enabled); - - // Reset the enabled state so the unit test doesn't propagate a new setting. - EXPECT_TRUE(SbAccessibilitySetCaptionsEnabled(settings.is_enabled)); - - SbAccessibilityCaptionSettings settings3; - memset(&settings3, kValidInitialValue, sizeof(settings3)); - EXPECT_TRUE(SbAccessibilityGetCaptionSettings(&settings3)); - EXPECT_EQ(settings.is_enabled, settings3.is_enabled); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/byte_swap_test.cc b/starboard/nplb/byte_swap_test.cc deleted file mode 100644 index 83fe64d68ee0..000000000000 --- a/starboard/nplb/byte_swap_test.cc +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/byte_swap.h" - -#include - -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const uint16_t kTestU16 = 0xABCD; -const uint16_t kExpectedU16 = 0xCDAB; -const int16_t kTestS16 = 0x0123; -const int16_t kExpectedS16 = 0x2301; -const uint32_t kTestU32 = 0xFEDCBA98; -const uint32_t kExpectedU32 = 0x98BADCFE; -const int32_t kTestS32 = 0x01234568; -const int32_t kExpectedS32 = 0x68452301; -const uint64_t kTestU64 = SB_UINT64_C(0xFEDCBA9876543210); -const uint64_t kExpectedU64 = SB_UINT64_C(0x1032547698BADCFE); -const int64_t kTestS64 = static_cast(SB_INT64_C(0xFEDCBA9876543210)); -const int64_t kExpectedS64 = - static_cast(SB_INT64_C(0x1032547698BADCFE)); - -TEST(SbByteSwapTest, SunnyDay) { - EXPECT_EQ(kExpectedU16, SbByteSwapU16(kTestU16)); - EXPECT_EQ(kExpectedS16, SbByteSwapS16(kTestS16)); - - EXPECT_EQ(kExpectedU32, SbByteSwapU32(kTestU32)); - EXPECT_EQ(kExpectedS32, SbByteSwapS32(kTestS32)); - - EXPECT_EQ(kExpectedU64, SbByteSwapU64(kTestU64)); - EXPECT_EQ(kExpectedS64, SbByteSwapS64(kTestS64)); -} - -#if SB_IS(BIG_ENDIAN) -TEST(SbByteSwapTest, BigEndian) { - EXPECT_EQ(kTestU16, SB_HOST_TO_NET_U16(kTestU16)); - EXPECT_EQ(kTestS16, SB_HOST_TO_NET_S16(kTestS16)); - - EXPECT_EQ(kTestU32, SB_HOST_TO_NET_U32(kTestU32)); - EXPECT_EQ(kTestS32, SB_HOST_TO_NET_S32(kTestS32)); - - EXPECT_EQ(kTestU64, SB_HOST_TO_NET_U64(kTestU64)); - EXPECT_EQ(kTestS64, SB_HOST_TO_NET_S64(kTestS64)); -} -#else -TEST(SbByteSwapTest, LittleEndian) { - EXPECT_EQ(kExpectedU16, SB_HOST_TO_NET_U16(kTestU16)); - EXPECT_EQ(kExpectedS16, SB_HOST_TO_NET_S16(kTestS16)); - - EXPECT_EQ(kExpectedU32, SB_HOST_TO_NET_U32(kTestU32)); - EXPECT_EQ(kExpectedS32, SB_HOST_TO_NET_S32(kTestS32)); - - EXPECT_EQ(kExpectedU64, SB_HOST_TO_NET_U64(kTestU64)); - EXPECT_EQ(kExpectedS64, SB_HOST_TO_NET_S64(kTestS64)); -} -#endif - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/condition_variable_broadcast_test.cc b/starboard/nplb/condition_variable_broadcast_test.cc deleted file mode 100644 index fe6bc6dd1bd6..000000000000 --- a/starboard/nplb/condition_variable_broadcast_test.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Broadcast is Sunny Day tested in most of the other SbConditionVariable tests. - -#if SB_API_VERSION < 16 - -#include "starboard/condition_variable.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbConditionVariableBroadcastTest, SunnyDayAutoInit) { - SbConditionVariable condition = SB_CONDITION_VARIABLE_INITIALIZER; - EXPECT_TRUE(SbConditionVariableBroadcast(&condition)); - EXPECT_TRUE(SbConditionVariableDestroy(&condition)); -} - -TEST(SbConditionVariableBroadcastTest, RainyDayNull) { - EXPECT_FALSE(SbConditionVariableBroadcast(NULL)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/condition_variable_create_test.cc b/starboard/nplb/condition_variable_create_test.cc deleted file mode 100644 index d330f1c6c5cb..000000000000 --- a/starboard/nplb/condition_variable_create_test.cc +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/mutex.h" -#include "starboard/condition_variable.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const int kALot = 128 * 1024; -const int kABunch = 2 * 1024; - -TEST(SbConditionVariableCreateTest, SunnyDay) { - SbMutex mutex; - EXPECT_TRUE(SbMutexCreate(&mutex)); - SbConditionVariable condition; - EXPECT_TRUE(SbConditionVariableCreate(&condition, &mutex)); - EXPECT_TRUE(SbConditionVariableDestroy(&condition)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -TEST(SbConditionVariableCreateTest, SunnyDayAutoInit) { - SbMutex mutex = SB_MUTEX_INITIALIZER; - EXPECT_TRUE(SbMutexCreate(&mutex)); - SbConditionVariable condition = SB_CONDITION_VARIABLE_INITIALIZER; - EXPECT_TRUE(SbConditionVariableCreate(&condition, &mutex)); - EXPECT_TRUE(SbConditionVariableDestroy(&condition)); -} - -TEST(SbConditionVariableCreateTest, SunnyDayALot) { - for (int i = 0; i < kALot; ++i) { - SbMutex mutex; - EXPECT_TRUE(SbMutexCreate(&mutex)); - SbConditionVariable condition; - EXPECT_TRUE(SbConditionVariableCreate(&condition, &mutex)); - EXPECT_TRUE(SbConditionVariableDestroy(&condition)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); - } -} - -TEST(SbConditionVariableCreateTest, SunnyDayABunchAtOnce) { - SbMutex mutexes[kABunch]; - SbConditionVariable conditions[kABunch]; - for (int i = 0; i < kABunch; ++i) { - EXPECT_TRUE(SbMutexCreate(&mutexes[i])); - EXPECT_TRUE(SbConditionVariableCreate(&conditions[i], &mutexes[i])); - } - - for (int i = 0; i < kABunch; ++i) { - EXPECT_TRUE(SbConditionVariableDestroy(&conditions[i])); - EXPECT_TRUE(SbMutexDestroy(&mutexes[i])); - } -} - -TEST(SbConditionVariableCreateTest, RainyDayNull) { - EXPECT_FALSE(SbConditionVariableCreate(NULL, NULL)); - - SbMutex mutex; - EXPECT_TRUE(SbMutexCreate(&mutex)); - EXPECT_FALSE(SbConditionVariableCreate(NULL, &mutex)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -TEST(SbConditionVariableCreateTest, SunnyDayNullMutex) { - SbConditionVariable condition; - EXPECT_TRUE(SbConditionVariableCreate(&condition, NULL)); - EXPECT_TRUE(SbConditionVariableDestroy(&condition)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/condition_variable_destroy_test.cc b/starboard/nplb/condition_variable_destroy_test.cc deleted file mode 100644 index 0b830cafe1c6..000000000000 --- a/starboard/nplb/condition_variable_destroy_test.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Destroy is mostly Sunny Day tested in Create. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" -#include "starboard/common/mutex.h" -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbConditionVariableDestroyTest, SunnyDayAutoInit) { - SbConditionVariable condition = SB_CONDITION_VARIABLE_INITIALIZER; - EXPECT_TRUE(SbConditionVariableDestroy(&condition)); -} - -TEST(SbConditionVariableDestroyTest, RainyDayNull) { - EXPECT_FALSE(SbConditionVariableDestroy(NULL)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/condition_variable_signal_test.cc b/starboard/nplb/condition_variable_signal_test.cc deleted file mode 100644 index 705aefcd567e..000000000000 --- a/starboard/nplb/condition_variable_signal_test.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Signal is Sunny Day tested in most of the other SbConditionVariable tests. - -#if SB_API_VERSION < 16 - -#include "starboard/condition_variable.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbConditionVariableSignalTest, SunnyDayAutoInit) { - SbConditionVariable condition = SB_CONDITION_VARIABLE_INITIALIZER; - EXPECT_TRUE(SbConditionVariableSignal(&condition)); - EXPECT_TRUE(SbConditionVariableDestroy(&condition)); -} - -TEST(SbConditionVariableSignalTest, RainyDayNull) { - EXPECT_FALSE(SbConditionVariableSignal(NULL)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/condition_variable_wait_test.cc b/starboard/nplb/condition_variable_wait_test.cc deleted file mode 100644 index ffb81c1f450a..000000000000 --- a/starboard/nplb/condition_variable_wait_test.cc +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration_constants.h" -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbConditionVariableWaitTest, SunnyDayAutoInit) { - TakeThenSignalContext context = {TestSemaphore(0), SB_MUTEX_INITIALIZER, - SB_CONDITION_VARIABLE_INITIALIZER}; - // Start the thread. - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, NULL, - TakeThenSignalEntryPoint, &context); - - EXPECT_TRUE(SbMutexIsSuccess(SbMutexAcquire(&context.mutex))); - - // Tell the thread to signal the condvar, which will cause it to attempt to - // acquire the mutex we are holding. - context.do_signal.Put(); - - // We release the mutex when we wait, allowing the thread to actually do the - // signaling, and ensuring we are waiting before it signals. - SbConditionVariableResult result = - SbConditionVariableWait(&context.condition, &context.mutex); - EXPECT_EQ(kSbConditionVariableSignaled, result); - - EXPECT_TRUE(SbMutexRelease(&context.mutex)); - - // Now we wait for the thread to exit. - EXPECT_TRUE(SbThreadJoin(thread, NULL)); - EXPECT_TRUE(SbConditionVariableDestroy(&context.condition)); - EXPECT_TRUE(SbMutexDestroy(&context.mutex)); -} - -TEST(SbConditionVariableWaitTest, SunnyDay) { - const int kMany = kSbMaxThreads > 64 ? 64 : kSbMaxThreads; - WaiterContext context; - - std::vector threads(kMany); - for (int i = 0; i < kMany; ++i) { - threads[i] = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - true, NULL, WaiterEntryPoint, &context); - } - - for (int i = 0; i < kMany; ++i) { - context.WaitForReturnSignal(); - } - - // Signal the conditions to make the thread wake up and exit. - EXPECT_TRUE(SbConditionVariableBroadcast(&context.condition)); - - // Now we wait for the threads to exit. - for (int i = 0; i < kMany; ++i) { - EXPECT_TRUE(SbThreadJoin(threads[i], NULL)) << "thread = " << threads[i]; - } -} - -TEST(SbConditionVariableWaitTest, RainyDayNull) { - SbConditionVariableResult result = SbConditionVariableWait(NULL, NULL); - EXPECT_EQ(kSbConditionVariableFailed, result); - - SbMutex mutex = SB_MUTEX_INITIALIZER; - result = SbConditionVariableWait(NULL, &mutex); - EXPECT_EQ(kSbConditionVariableFailed, result); - - SbConditionVariable condition = SB_CONDITION_VARIABLE_INITIALIZER; - result = SbConditionVariableWait(&condition, NULL); - EXPECT_EQ(kSbConditionVariableFailed, result); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/condition_variable_wait_timed_test.cc b/starboard/nplb/condition_variable_wait_timed_test.cc deleted file mode 100644 index 1079c603231f..000000000000 --- a/starboard/nplb/condition_variable_wait_timed_test.cc +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" -#include "starboard/common/mutex.h" -#include "starboard/common/time.h" -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -// The SunnyDay, SunnyDayAutoInit, and SunnyDayNearMaxTime test cases directly -// (performs checks in the test case) or indirectly (invokes DoSunnyDay() which -// performs the checks) rely on timing constraints that are prone to failure, -// such as ensuring an action happens within 10 milliseconds. This requirement -// makes the tests flaky since none of these actions can be guaranteed to always -// run within the specified time. - -void DoSunnyDay(TakeThenSignalContext* context, bool check_timeout) { - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, NULL, - TakeThenSignalEntryPoint, context); - - const int64_t kDelay = 10'000; // 10ms - // Allow two-millisecond-level precision. - const int64_t kPrecision = 2'000; // 2ms - - // We know the thread hasn't signaled the condition variable yet, and won't - // unless we tell it, so it should wait at least the whole delay time. - if (check_timeout) { - EXPECT_TRUE(SbMutexIsSuccess(SbMutexAcquire(&context->mutex))); - int64_t start = CurrentMonotonicTime(); - SbConditionVariableResult result = SbConditionVariableWaitTimed( - &context->condition, &context->mutex, kDelay); - EXPECT_EQ(kSbConditionVariableTimedOut, result); - int64_t elapsed = CurrentMonotonicTime() - start; - EXPECT_LE(kDelay, elapsed + kPrecision); - EXPECT_GT(kDelay * 2, elapsed - kPrecision); - EXPECT_TRUE(SbMutexRelease(&context->mutex)); - } - - { - EXPECT_TRUE(SbMutexIsSuccess(SbMutexAcquire(&context->mutex))); - - // Tell the thread to signal the condvar, which will cause it to attempt to - // acquire the mutex we are holding. - context->do_signal.Put(); - - int64_t start = CurrentMonotonicTime(); - - // We release the mutex when we wait, allowing the thread to actually do the - // signaling, and ensuring we are waiting before it signals. - SbConditionVariableResult result = SbConditionVariableWaitTimed( - &context->condition, &context->mutex, kDelay); - EXPECT_EQ(kSbConditionVariableSignaled, result); - - // We should have waited only a very small amount of time. - EXPECT_GT(kDelay, CurrentMonotonicTime() - start); - - EXPECT_TRUE(SbMutexRelease(&context->mutex)); - } - - // Now we wait for the thread to exit. - EXPECT_TRUE(SbThreadJoin(thread, NULL)); - EXPECT_TRUE(SbConditionVariableDestroy(&context->condition)); - EXPECT_TRUE(SbMutexDestroy(&context->mutex)); -} - -// Test marked as flaky because it calls DoSunnyDay(). -TEST(SbConditionVariableWaitTimedTest, FLAKY_SunnyDay) { - TakeThenSignalContext context; - context.delay_after_signal = 0; - EXPECT_TRUE(SbMutexCreate(&context.mutex)); - EXPECT_TRUE(SbConditionVariableCreate(&context.condition, &context.mutex)); - DoSunnyDay(&context, true); -} - -// Test marked as flaky because it calls DoSunnyDay(). -TEST(SbConditionVariableWaitTimedTest, FLAKY_SunnyDayAutoInit) { - { - TakeThenSignalContext context = {TestSemaphore(0), SB_MUTEX_INITIALIZER, - SB_CONDITION_VARIABLE_INITIALIZER, 0}; - DoSunnyDay(&context, true); - } - - // Without the initial timeout test, the two threads will be racing to - // auto-init the mutex and condition variable. So we run several trials in - // this mode, hoping to have the auto-initting contend in various ways. - const int kTrials = 64; - for (int i = 0; i < kTrials; ++i) { - TakeThenSignalContext context = {TestSemaphore(0), SB_MUTEX_INITIALIZER, - SB_CONDITION_VARIABLE_INITIALIZER, 0}; - DoSunnyDay(&context, false); - } -} - -// Test marked as flaky because it relies on timing sensitive execution similar -// to DoSunnyDay(). -TEST(SbConditionVariableWaitTimedTest, FLAKY_SunnyDayNearMaxTime) { - const int64_t kOtherDelay = 10'000; // 10ms - TakeThenSignalContext context = {TestSemaphore(0), SB_MUTEX_INITIALIZER, - SB_CONDITION_VARIABLE_INITIALIZER, - kOtherDelay}; - EXPECT_TRUE(SbMutexCreate(&context.mutex)); - EXPECT_TRUE(SbConditionVariableCreate(&context.condition, &context.mutex)); - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, NULL, - TakeThenSignalEntryPoint, &context); - - // Try to wait until the end of time. - const int64_t kDelay = kSbInt64Max; - - EXPECT_TRUE(SbMutexIsSuccess(SbMutexAcquire(&context.mutex))); - - // Tell the thread to signal the condvar, which will cause it to attempt to - // acquire the mutex we are holding, after it waits for delay_after_signal. - context.do_signal.Put(); - - int64_t start = CurrentMonotonicTime(); - - // We release the mutex when we wait, allowing the thread to actually do the - // signaling, and ensuring we are waiting before it signals. - SbConditionVariableResult result = - SbConditionVariableWaitTimed(&context.condition, &context.mutex, kDelay); - EXPECT_EQ(kSbConditionVariableSignaled, result); - - // We should have waited at least the delay_after_signal amount, but not the - // full delay. - // Add some padding to tolerate slightly imprecise sleeps. - EXPECT_LT(context.delay_after_signal, - CurrentMonotonicTime() - start + (context.delay_after_signal / 10)); - EXPECT_GT(kDelay, CurrentMonotonicTime() - start); - - EXPECT_TRUE(SbMutexRelease(&context.mutex)); - - // Now we wait for the thread to exit. - EXPECT_TRUE(SbThreadJoin(thread, NULL)); - EXPECT_TRUE(SbConditionVariableDestroy(&context.condition)); - EXPECT_TRUE(SbMutexDestroy(&context.mutex)); -} - -TEST(SbConditionVariableWaitTimedTest, RainyDayNull) { - SbConditionVariableResult result = - SbConditionVariableWaitTimed(NULL, NULL, 0); - EXPECT_EQ(kSbConditionVariableFailed, result); - - SbMutex mutex = SB_MUTEX_INITIALIZER; - result = SbConditionVariableWaitTimed(NULL, &mutex, 0); - EXPECT_EQ(kSbConditionVariableFailed, result); - - SbConditionVariable condition = SB_CONDITION_VARIABLE_INITIALIZER; - result = SbConditionVariableWaitTimed(&condition, NULL, 0); - EXPECT_EQ(kSbConditionVariableFailed, result); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/directory_can_open_test.cc b/starboard/nplb/directory_can_open_test.cc deleted file mode 100644 index d404c431062c..000000000000 --- a/starboard/nplb/directory_can_open_test.cc +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include - -#include "starboard/configuration_constants.h" -#include "starboard/directory.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbDirectoryCanOpenTest, SunnyDay) { - std::string path = starboard::nplb::GetTempDir(); - EXPECT_FALSE(path.empty()); - EXPECT_TRUE(SbFileExists(path.c_str())); - - EXPECT_TRUE(SbDirectoryCanOpen(path.c_str())); -} - -TEST(SbDirectoryCanOpenTest, SunnyDayStaticContent) { - for (auto dir_path : GetFileTestsDirectoryPaths()) { - EXPECT_TRUE(SbDirectoryCanOpen(dir_path.c_str())) - << "Can't open: " << dir_path; - } -} - -TEST(SbDirectoryCanOpenTest, FailureMissingStaticContent) { - std::string directory_path = GetFileTestsDataDir(); - std::string missing_dir = directory_path + kSbFileSepChar + "missing_dir"; - EXPECT_FALSE(SbDirectoryCanOpen(missing_dir.c_str())); -} - -TEST(SbDirectoryCanOpenTest, FailureNull) { - EXPECT_FALSE(SbDirectoryCanOpen(NULL)); -} - -TEST(SbDirectoryCanOpenTest, FailureEmpty) { - EXPECT_FALSE(SbDirectoryCanOpen("")); -} - -TEST(SbDirectoryCanOpenTest, FailureRegularFile) { - starboard::nplb::ScopedRandomFile file; - - EXPECT_TRUE(SbFileExists(file.filename().c_str())); - EXPECT_FALSE(SbDirectoryCanOpen(file.filename().c_str())); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/directory_close_test.cc b/starboard/nplb/directory_close_test.cc deleted file mode 100644 index af3d471eed29..000000000000 --- a/starboard/nplb/directory_close_test.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// SbDirectoryClose is well-covered in all the other tests, so just the -// leftovers are here. -#if SB_API_VERSION < 17 -#include "starboard/directory.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbDirectoryCloseTest, FailureInvalid) { - EXPECT_FALSE(SbDirectoryClose(kSbDirectoryInvalid)); -} - -} // namespace -} // namespace nplb -} // namespace starboard -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/directory_create_test.cc b/starboard/nplb/directory_create_test.cc deleted file mode 100644 index 39ac2cbc3adb..000000000000 --- a/starboard/nplb/directory_create_test.cc +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include - -#include "starboard/common/string.h" -#include "starboard/configuration_constants.h" -#include "starboard/directory.h" -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "starboard/system.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const std::string kManyFileSeparators = // NOLINT(runtime/string) - std::string(kSbFileSepString) + kSbFileSepString + kSbFileSepString + - kSbFileSepString; - -// NOTE: There is a test missing here, for creating a directory right off of the -// root. But, this is likely to fail due to permissions, so we can't make a -// reliable test for this. - -TEST(SbDirectoryCreateTest, SunnyDay) { - ScopedRandomFile dir(ScopedRandomFile::kDontCreate); - - const std::string& path = dir.filename(); - - EXPECT_FALSE(SbDirectoryCanOpen(path.c_str())); - EXPECT_TRUE(SbDirectoryCreate(path.c_str())); - EXPECT_TRUE(SbDirectoryCanOpen(path.c_str())); - - // Should return true if called redundantly. - EXPECT_TRUE(SbDirectoryCreate(path.c_str())); - EXPECT_TRUE(SbDirectoryCanOpen(path.c_str())); -} - -TEST(SbDirectoryCreateTest, SunnyDayTrailingSeparators) { - ScopedRandomFile dir(ScopedRandomFile::kDontCreate); - - std::string path = dir.filename() + kManyFileSeparators.c_str(); - - EXPECT_FALSE(SbDirectoryCanOpen(path.c_str())); - EXPECT_TRUE(SbDirectoryCreate(path.c_str())); - EXPECT_TRUE(SbDirectoryCanOpen(path.c_str())); -} - -TEST(SbDirectoryCreateTest, SunnyDayTempDirectory) { - std::vector temp_path(kSbFileMaxPath); - bool system_path_success = SbSystemGetPath(kSbSystemPathTempDirectory, - temp_path.data(), kSbFileMaxPath); - ASSERT_TRUE(system_path_success); - EXPECT_TRUE(SbDirectoryCanOpen(temp_path.data())); - EXPECT_TRUE(SbDirectoryCreate(temp_path.data())); - EXPECT_TRUE(SbDirectoryCanOpen(temp_path.data())); -} - -TEST(SbDirectoryCreateTest, SunnyDayTempDirectoryManySeparators) { - std::vector temp_path(kSbFileMaxPath); - bool system_path_success = SbSystemGetPath( - kSbSystemPathTempDirectory, temp_path.data(), temp_path.size()); - ASSERT_TRUE(system_path_success); - const int new_size = starboard::strlcat( - temp_path.data(), kManyFileSeparators.c_str(), kSbFileMaxPath); - ASSERT_LT(new_size, kSbFileMaxPath); - - EXPECT_TRUE(SbDirectoryCanOpen(temp_path.data())); - EXPECT_TRUE(SbDirectoryCreate(temp_path.data())); - EXPECT_TRUE(SbDirectoryCanOpen(temp_path.data())); -} - -TEST(SbDirectoryCreateTest, FailureNullPath) { - EXPECT_FALSE(SbDirectoryCreate(NULL)); -} - -TEST(SbDirectoryCreateTest, FailureEmptyPath) { - EXPECT_FALSE(SbDirectoryCreate("")); -} - -TEST(SbDirectoryCreateTest, FailureNonexistentParent) { - ScopedRandomFile dir(ScopedRandomFile::kDontCreate); - std::string path = dir.filename() + kSbFileSepString + "test"; - - EXPECT_FALSE(SbDirectoryCanOpen(path.c_str())); - EXPECT_FALSE(SbDirectoryCreate(path.c_str())); - EXPECT_FALSE(SbDirectoryCanOpen(path.c_str())); -} - -TEST(SbDirectoryCreateTest, FailureNotAbsolute) { - const char* kPath = "hallo"; - - EXPECT_FALSE(SbDirectoryCanOpen(kPath)); - EXPECT_FALSE(SbDirectoryCreate(kPath)); - EXPECT_FALSE(SbDirectoryCanOpen(kPath)); -} - -} // namespace -} // namespace nplb -} // namespace starboard -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/directory_get_next_test.cc b/starboard/nplb/directory_get_next_test.cc deleted file mode 100644 index f05b838dd458..000000000000 --- a/starboard/nplb/directory_get_next_test.cc +++ /dev/null @@ -1,213 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include - -#include -#include -#include - -#include "starboard/configuration.h" -#include "starboard/configuration_constants.h" -#include "starboard/directory.h" -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -typedef std::set StringSet; - -bool FileExists(const char* path) { - struct stat info; - return stat(path, &info) == 0; -} - -TEST(SbDirectoryGetNextTest, SunnyDay) { - const int kNumFiles = 65; - ScopedRandomFile files[kNumFiles]; - - std::string directory_name = files[0].filename(); - directory_name.resize(directory_name.find_last_of(kSbFileSepChar)); - EXPECT_TRUE(FileExists(directory_name.c_str())) - << "Missing directory: " << directory_name; - - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen(directory_name.c_str(), &error); - EXPECT_TRUE(SbDirectoryIsValid(directory)); - EXPECT_EQ(kSbFileOk, error); - - // Make sure all the files we created are found exactly once. - StringSet names; - for (int i = 0; i < SB_ARRAY_SIZE_INT(files); ++i) { - names.insert(files[i].filename()); - } - - StringSet names_to_find(names); - while (true) { - std::vector entry(kSbFileMaxName, 0); - if (!SbDirectoryGetNext(directory, entry.data(), entry.size())) { - break; - } - const char* entry_name = entry.data(); - - // SbDirectoryEntry just contains the last component of the absolute path to - // the file, but ScopedRandomFile::filename() returns the full path. - std::string filename; - filename += directory_name; - filename += kSbFileSepChar; - filename += entry_name; - - StringSet::iterator iterator = names_to_find.find(filename); - if (iterator != names_to_find.end()) { - names_to_find.erase(iterator); - } else { - // If it isn't in |names_to_find|, make sure it's some external entry and - // not one of ours. Otherwise, an entry must have shown up twice. - EXPECT_TRUE(names.find(entry_name) == names.end()); - } - } - - // Make sure we found all of our names. - EXPECT_EQ(0, names_to_find.size()); - - EXPECT_TRUE(SbDirectoryClose(directory)); -} - -TEST(SbDirectoryGetNextTest, SunnyDayStaticContent) { - std::string testdata_dir = GetFileTestsDataDir(); - EXPECT_FALSE(testdata_dir.empty()); - EXPECT_TRUE(FileExists(testdata_dir.c_str())) - << "Missing directory: " << testdata_dir; - - // Make sure all the test directories and files are found exactly once. - StringSet paths_to_find; - for (auto path : GetFileTestsDirectoryPaths()) { - paths_to_find.insert(path); - } - for (auto path : GetFileTestsFilePaths()) { - paths_to_find.insert(path); - } - - // Breadth-first traversal of our test data. - std::queue directory_queue; - directory_queue.push(testdata_dir); - while (!directory_queue.empty()) { - std::string path = directory_queue.front(); - directory_queue.pop(); - - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen(path.c_str(), &error); - EXPECT_TRUE(SbDirectoryIsValid(directory)) << "Can't open: " << path; - EXPECT_EQ(kSbFileOk, error) << "Error opening: " << path; - - // Iterate all entries in this directory. - while (true) { - std::vector entry(kSbFileMaxName, 0); - if (!SbDirectoryGetNext(directory, entry.data(), entry.size())) { - break; - } - std::string entry_name = entry.data(); - - // Accept and ignore '.' and '..' directories. - if (entry_name == "." || entry_name == "..") { - continue; - } - - // Absolute path of the entry. - std::string entry_path = path + kSbFileSepChar + entry_name; - - StringSet::iterator iterator = paths_to_find.find(entry_path); - if (iterator != paths_to_find.end()) { - paths_to_find.erase(iterator); - } else { - ADD_FAILURE() << "Unexpected entry: " << entry_path; - } - - // Traverse into the subdirectory. - SbFileInfo file_info; - EXPECT_TRUE(SbFileGetPathInfo(entry_path.c_str(), &file_info)); - if (file_info.is_directory) { - directory_queue.push(entry_path); - } - } - - EXPECT_TRUE(SbDirectoryClose(directory)); - } - - // Make sure we found all of test data directories and files. - EXPECT_EQ(0, paths_to_find.size()); - for (auto it = paths_to_find.begin(); it != paths_to_find.end(); ++it) { - ADD_FAILURE() << "Missing entry: " << *it; - } -} - -TEST(SbDirectoryGetNextTest, FailureInvalidSbDirectory) { - std::vector entry(kSbFileMaxName, 0); - EXPECT_FALSE( - SbDirectoryGetNext(kSbDirectoryInvalid, entry.data(), entry.size())); -} - -TEST(SbDirectoryGetNextTest, FailureNullEntry) { - // Ensure there's at least one file in the directory. - ScopedRandomFile file; - - std::string path = GetTempDir(); - EXPECT_FALSE(path.empty()); - EXPECT_TRUE(FileExists(path.c_str())) << "Directory is " << path; - - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen(path.c_str(), &error); - EXPECT_TRUE(SbDirectoryIsValid(directory)); - EXPECT_EQ(kSbFileOk, error); - EXPECT_FALSE(SbDirectoryGetNext(directory, NULL, kSbFileMaxName)); - EXPECT_TRUE(SbDirectoryClose(directory)); -} - -TEST(SbDirectoryGetNextTest, FailureInvalidAndNull) { - EXPECT_FALSE(SbDirectoryGetNext(kSbDirectoryInvalid, NULL, kSbFileMaxName)); -} - -TEST(SbDirectoryGetNextTest, FailureOnInsufficientSize) { - ScopedRandomFile file; - std::string directory_name = file.filename(); - directory_name.resize(directory_name.find_last_of(kSbFileSepChar)); - EXPECT_TRUE(FileExists(directory_name.c_str())) - << "Directory_name is " << directory_name; - - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen(directory_name.c_str(), &error); - EXPECT_TRUE(SbDirectoryIsValid(directory)); - EXPECT_EQ(kSbFileOk, error); - - std::vector entry(kSbFileMaxName); - for (int i = 0; i < kSbFileMaxName; i++) - entry[i] = i; - std::vector entry_copy = entry; - EXPECT_EQ(SbDirectoryGetNext(directory, entry.data(), 0), false); - EXPECT_EQ(entry.size(), kSbFileMaxName); - for (int i = 0; i < kSbFileMaxName; i++) - EXPECT_EQ(entry[i], entry_copy[i]); - - EXPECT_TRUE(SbDirectoryClose(directory)); -} - -} // namespace -} // namespace nplb -} // namespace starboard -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/directory_open_test.cc b/starboard/nplb/directory_open_test.cc deleted file mode 100644 index 06a39ddadc3b..000000000000 --- a/starboard/nplb/directory_open_test.cc +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include - -#include "starboard/configuration_constants.h" -#include "starboard/directory.h" -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "starboard/system.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -#if SB_API_VERSION < 16 -#define EXPECT_FILE_EXISTS(path) \ - EXPECT_TRUE(SbFileExists(path.c_str())) << "Filename is " << path.c_str() - -TEST(SbDirectoryOpenTest, SunnyDay) { - std::string path = GetTempDir(); - EXPECT_FALSE(path.empty()); - EXPECT_FILE_EXISTS(path); - - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen(path.c_str(), &error); - EXPECT_TRUE(SbDirectoryIsValid(directory)); - EXPECT_EQ(kSbFileOk, error); - EXPECT_TRUE(SbDirectoryClose(directory)); -} -#endif - -TEST(SbDirectoryOpenTest, SunnyDayStaticContent) { - for (auto dir_path : GetFileTestsDirectoryPaths()) { - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen(dir_path.c_str(), &error); - EXPECT_TRUE(SbDirectoryIsValid(directory)) << dir_path; - EXPECT_EQ(kSbFileOk, error) << "Can't open: " << dir_path; - EXPECT_TRUE(SbDirectoryClose(directory)); - } -} - -#if SB_API_VERSION < 16 -TEST(SbDirectoryOpenTest, SunnyDayWithNullError) { - std::string path = GetTempDir(); - EXPECT_FALSE(path.empty()); - EXPECT_FILE_EXISTS(path); - - SbDirectory directory = SbDirectoryOpen(path.c_str(), NULL); - EXPECT_TRUE(SbDirectoryIsValid(directory)); - EXPECT_TRUE(SbDirectoryClose(directory)); -} - -TEST(SbDirectoryOpenTest, ManySunnyDay) { - std::string path = GetTempDir(); - EXPECT_FALSE(path.empty()); - EXPECT_FILE_EXISTS(path); - - const int kMany = kSbFileMaxOpen; - std::vector directories(kMany, 0); - - for (int i = 0; i < directories.size(); ++i) { - SbFileError error = kSbFileErrorMax; - directories[i] = SbDirectoryOpen(path.c_str(), &error); - EXPECT_TRUE(SbDirectoryIsValid(directories[i])); - EXPECT_EQ(kSbFileOk, error); - } - - for (int i = 0; i < directories.size(); ++i) { - EXPECT_TRUE(SbDirectoryClose(directories[i])); - } -} - -TEST(SbDirectoryOpenTest, FailsInvalidPath) { - std::string path = GetTempDir(); - EXPECT_FALSE(path.empty()); - EXPECT_FILE_EXISTS(path); - - // Funny way to make sure the directory seems valid but doesn't exist. - int len = static_cast(path.length()); - if (path[len - 1] != 'z') { - path[len - 1] = 'z'; - } else { - path[len - 1] = 'y'; - } - - ASSERT_FALSE(SbFileExists(path.c_str())); - - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen(path.c_str(), &error); - EXPECT_FALSE(SbDirectoryIsValid(directory)); - EXPECT_EQ(kSbFileErrorNotFound, error); - if (SbDirectoryIsValid(directory)) { - SbDirectoryClose(directory); - } -} -#endif - -TEST(SbDirectoryOpenTest, FailsNullPath) { - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen(NULL, &error); - EXPECT_FALSE(SbDirectoryIsValid(directory)); - EXPECT_EQ(kSbFileErrorNotFound, error); - if (SbDirectoryIsValid(directory)) { - SbDirectoryClose(directory); - } -} - -TEST(SbDirectoryOpenTest, FailsNullPathWithNullError) { - SbDirectory directory = SbDirectoryOpen(NULL, NULL); - EXPECT_FALSE(SbDirectoryIsValid(directory)); - if (SbDirectoryIsValid(directory)) { - SbDirectoryClose(directory); - } -} - -TEST(SbDirectoryOpenTest, FailsEmptyPath) { - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen("", &error); - EXPECT_FALSE(SbDirectoryIsValid(directory)); - EXPECT_EQ(kSbFileErrorNotFound, error); - if (SbDirectoryIsValid(directory)) { - SbDirectoryClose(directory); - } -} - -TEST(SbDirectoryOpenTest, FailsRegularFile) { - ScopedRandomFile file; - - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen(file.filename().c_str(), &error); - EXPECT_FALSE(SbDirectoryIsValid(directory)); - EXPECT_EQ(kSbFileErrorNotADirectory, error); - if (SbDirectoryIsValid(directory)) { - SbDirectoryClose(directory); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/extern_c_test.cc b/starboard/nplb/extern_c_test.cc index 1c42ce015eb0..09b5fc655e34 100644 --- a/starboard/nplb/extern_c_test.cc +++ b/starboard/nplb/extern_c_test.cc @@ -15,14 +15,8 @@ // Ensure that all starboard headers can be included inside extern "C". extern "C" { -#if SB_API_VERSION < 16 -#include "starboard/accessibility.h" -#endif // SB_API_VERSION < 16 #include "starboard/atomic.h" #include "starboard/audio_sink.h" -#if SB_API_VERSION < 16 -#include "starboard/byte_swap.h" -#endif // SB_API_VERSION < 16 #include "starboard/condition_variable.h" #include "starboard/configuration.h" #include "starboard/cpu_features.h" @@ -34,9 +28,6 @@ extern "C" { #include "starboard/export.h" #include "starboard/file.h" #include "starboard/gles.h" -#if SB_API_VERSION < 16 -#include "starboard/image.h" -#endif // SB_API_VERSION < 16 #include "starboard/input.h" #include "starboard/key.h" #include "starboard/log.h" @@ -52,14 +43,7 @@ extern "C" { #include "starboard/string.h" #include "starboard/system.h" #include "starboard/thread.h" -#if SB_API_VERSION < 16 -#include "starboard/time.h" -#endif // SB_API_VERSION < 16 #include "starboard/time_zone.h" #include "starboard/types.h" -#if SB_API_VERSION < 16 -#include "starboard/ui_navigation.h" -#include "starboard/user.h" -#endif // SB_API_VERSION < 16 #include "starboard/window.h" } diff --git a/starboard/nplb/file_can_open_test.cc b/starboard/nplb/file_can_open_test.cc deleted file mode 100644 index 93572606c15e..000000000000 --- a/starboard/nplb/file_can_open_test.cc +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include - -#include "starboard/configuration_constants.h" -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbFileCanOpenTest, NonExistingFileFails) { - ScopedRandomFile random_file(ScopedRandomFile::kDontCreate); - const std::string& filename = random_file.filename(); - - bool result = SbFileCanOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead); - EXPECT_FALSE(result); - - result = SbFileCanOpen(filename.c_str(), kSbFileCreateOnly | kSbFileWrite); - EXPECT_FALSE(result); - - result = SbFileCanOpen(filename.c_str(), - kSbFileOpenAlways | kSbFileRead | kSbFileWrite); - EXPECT_FALSE(result); -} - -TEST(SbFileCanOpenTest, ExistingFileSucceeds) { - ScopedRandomFile random_file; - const std::string& filename = random_file.filename(); - - bool result = SbFileCanOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead); - EXPECT_TRUE(result); - - result = SbFileCanOpen(filename.c_str(), kSbFileCreateOnly | kSbFileWrite); - EXPECT_TRUE(result); - - result = SbFileCanOpen(filename.c_str(), - kSbFileOpenAlways | kSbFileRead | kSbFileWrite); - EXPECT_TRUE(result); -} - -TEST(SbFileCanOpenTest, NonExistingStaticContentFileFails) { - std::string directory_path = GetFileTestsDataDir(); - std::string missing_file = directory_path + kSbFileSepChar + "missing_file"; - EXPECT_FALSE( - SbFileCanOpen(missing_file.c_str(), kSbFileOpenOnly | kSbFileRead)); -} - -TEST(SbFileCanOpenTest, ExistingStaticContentFileSucceeds) { - for (auto path : GetFileTestsFilePaths()) { - EXPECT_TRUE(SbFileCanOpen(path.c_str(), kSbFileOpenOnly | kSbFileRead)) - << "Can't open: " << path; - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_close_test.cc b/starboard/nplb/file_close_test.cc deleted file mode 100644 index 2a40d4274b36..000000000000 --- a/starboard/nplb/file_close_test.cc +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// SbFileClose is partially tested in file_open_test.cc. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbFileCloseTest, CloseInvalidFails) { - bool result = SbFileClose(kSbFileInvalid); - EXPECT_FALSE(result); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_delete_test.cc b/starboard/nplb/file_delete_test.cc deleted file mode 100644 index 95052867700d..000000000000 --- a/starboard/nplb/file_delete_test.cc +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include - -#include - -#include "starboard/directory.h" -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -bool FileExists(const char* path) { - struct stat info; - return stat(path, &info) == 0; -} - -bool DirectoryExists(const char* path) { - struct stat info; - return stat(path, &info) == 0 && S_ISDIR(info.st_mode); -} - -TEST(SbFileDeleteTest, SunnyDayDeleteExistingFile) { - ScopedRandomFile file; - - EXPECT_TRUE(FileExists(file.filename().c_str())); - EXPECT_TRUE(SbFileDelete(file.filename().c_str())); -} - -TEST(SbFileDeleteTest, SunnyDayDeleteExistingDirectory) { - ScopedRandomFile file(ScopedRandomFile::kDontCreate); - - const std::string& path = file.filename(); - - EXPECT_FALSE(FileExists(path.c_str())); - EXPECT_TRUE(mkdir(path.c_str(), 0700) == 0 || DirectoryExists(path.c_str())); - EXPECT_TRUE(DirectoryExists(path.c_str())); - EXPECT_TRUE(SbFileDelete(path.c_str())); -} - -TEST(SbFileDeleteTest, RainyDayNonExistentFileErrors) { - ScopedRandomFile file(ScopedRandomFile::kDontCreate); - - EXPECT_FALSE(FileExists(file.filename().c_str())); - EXPECT_TRUE(SbFileDelete(file.filename().c_str())); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_flush_test.cc b/starboard/nplb/file_flush_test.cc deleted file mode 100644 index 7b8b3143ccbd..000000000000 --- a/starboard/nplb/file_flush_test.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// SbFileFlush is otherwise tested in SbFileWriteTest. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbFileFlushTest, InvalidFileErrors) { - bool result = SbFileFlush(kSbFileInvalid); - EXPECT_FALSE(result); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_get_info_test.cc b/starboard/nplb/file_get_info_test.cc deleted file mode 100644 index 2bfc5da8120a..000000000000 --- a/starboard/nplb/file_get_info_test.cc +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// GetInfo is mostly tested in the course of other tests. - -#if SB_API_VERSION < 17 - -#include - -#include "starboard/common/time.h" -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "starboard/system.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbFileGetInfoTest, InvalidFileErrors) { - SbFileInfo info = {0}; - bool result = SbFileGetInfo(kSbFileInvalid, &info); - EXPECT_FALSE(result); -} - -TEST(SbFileGetInfoTest, WorksOnARegularFile) { - // This test is potentially flaky because it's comparing times. So, building - // in extra sensitivity to make flakiness more apparent. - const int kTrials = 100; - for (int i = 0; i < kTrials; ++i) { - // We can't assume filesystem timestamp precision, so go back a minute - // for a better chance to contain the imprecision and rounding errors. - const int64_t kOneMinuteInMicroseconds = 60'000'000; - int64_t time = - PosixTimeToWindowsTime(CurrentPosixTime()) - kOneMinuteInMicroseconds; - - const int kFileSize = 12; - starboard::nplb::ScopedRandomFile random_file(kFileSize); - const std::string& filename = random_file.filename(); - - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - { - SbFileInfo info = {0}; - bool result = SbFileGetInfo(file, &info); - EXPECT_EQ(kFileSize, info.size); - EXPECT_FALSE(info.is_directory); - EXPECT_FALSE(info.is_symbolic_link); - EXPECT_LE(time, info.last_modified); - EXPECT_LE(time, info.last_accessed); - EXPECT_LE(time, info.creation_time); - } - - bool result = SbFileClose(file); - EXPECT_TRUE(result); - } -} - -TEST(SbFileGetInfoTest, WorksOnStaticContentFiles) { - for (auto filename : GetFileTestsFilePaths()) { - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - SbFileInfo info = {0}; - bool result = SbFileGetInfo(file, &info); - size_t content_length = GetTestFileExpectedContent(filename).length(); - EXPECT_EQ(content_length, info.size); - EXPECT_FALSE(info.is_directory); - EXPECT_FALSE(info.is_symbolic_link); - - EXPECT_TRUE(SbFileClose(file)); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_get_path_info_test.cc b/starboard/nplb/file_get_path_info_test.cc deleted file mode 100644 index e775c4526ffa..000000000000 --- a/starboard/nplb/file_get_path_info_test.cc +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// GetInfo is mostly tested in the course of other tests. -#if SB_API_VERSION < 16 - -#include - -#include "starboard/common/time.h" -#include "starboard/configuration_constants.h" -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "starboard/system.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbFileGetPathInfoTest, InvalidFileErrors) { - SbFileInfo info = {0}; - bool result = SbFileGetPathInfo(NULL, &info); - EXPECT_FALSE(result); - - result = SbFileGetPathInfo("", &info); - EXPECT_FALSE(result); - - result = SbFileGetPathInfo(".", NULL); - EXPECT_FALSE(result); - - result = SbFileGetPathInfo(NULL, NULL); - EXPECT_FALSE(result); - - result = SbFileGetPathInfo("", NULL); - EXPECT_FALSE(result); -} - -TEST(SbFileGetPathInfoTest, WorksOnARegularFile) { - // This test is potentially flaky because it's comparing times. So, building - // in extra sensitivity to make flakiness more apparent. - const int kTrials = 100; - for (int i = 0; i < kTrials; ++i) { - // We can't assume filesystem timestamp precision, so go back a minute - // for a better chance to contain the imprecision and rounding errors. - const int64_t kOneMinuteInMicroseconds = 60'000'000; - int64_t time = - PosixTimeToWindowsTime(CurrentPosixTime()) - kOneMinuteInMicroseconds; - - const int kFileSize = 12; - ScopedRandomFile random_file(kFileSize); - const std::string& filename = random_file.filename(); - - { - SbFileInfo info = {0}; - bool result = SbFileGetPathInfo(filename.c_str(), &info); - EXPECT_EQ(kFileSize, info.size); - EXPECT_FALSE(info.is_directory); - EXPECT_FALSE(info.is_symbolic_link); - EXPECT_LE(time, info.last_modified); - EXPECT_LE(time, info.last_accessed); - EXPECT_LE(time, info.creation_time); - } - } -} - -TEST(SbFileGetPathInfoTest, WorksOnADirectory) { - std::vector path(kSbFileMaxPath); - bool result = - SbSystemGetPath(kSbSystemPathTempDirectory, path.data(), kSbFileMaxPath); - EXPECT_TRUE(result); - - { - SbFileInfo info = {0}; - bool result = SbFileGetPathInfo(path.data(), &info); - EXPECT_LE(0, info.size); - EXPECT_TRUE(info.is_directory); - EXPECT_FALSE(info.is_symbolic_link); - EXPECT_LE(0, info.last_modified); - EXPECT_LE(0, info.last_accessed); - EXPECT_LE(0, info.creation_time); - } -} - -TEST(SbFileGetPathInfoTest, WorksOnStaticContentFiles) { - for (auto filename : GetFileTestsFilePaths()) { - SbFileInfo info = {0}; - bool result = SbFileGetPathInfo(filename.c_str(), &info); - size_t content_length = GetTestFileExpectedContent(filename).length(); - EXPECT_EQ(content_length, info.size); - EXPECT_FALSE(info.is_directory); - EXPECT_FALSE(info.is_symbolic_link); - } -} - -TEST(SbFileGetPathInfoTest, WorksOnStaticContentDirectories) { - for (auto path : GetFileTestsDirectoryPaths()) { - SbFileInfo info = {0}; - bool result = SbFileGetPathInfo(path.data(), &info); - EXPECT_LE(0, info.size); - EXPECT_TRUE(info.is_directory); - EXPECT_FALSE(info.is_symbolic_link); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/file_mode_string_to_flags_test.cc b/starboard/nplb/file_mode_string_to_flags_test.cc deleted file mode 100644 index 9efdf3a2163e..000000000000 --- a/starboard/nplb/file_mode_string_to_flags_test.cc +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include - -#include "starboard/file.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbFileModeStringToFlagsTest, Empties) { - EXPECT_EQ(0, SbFileModeStringToFlags(NULL)); - EXPECT_EQ(0, SbFileModeStringToFlags("")); -} - -TEST(SbFileModeStringToFlagsTest, Arr) { - EXPECT_EQ(kSbFileOpenOnly | kSbFileRead, SbFileModeStringToFlags("r")); - EXPECT_EQ(kSbFileOpenOnly | kSbFileRead | kSbFileWrite, - SbFileModeStringToFlags("r+")); - EXPECT_EQ(kSbFileOpenOnly | kSbFileRead | kSbFileWrite, - SbFileModeStringToFlags("r+b")); - EXPECT_EQ(kSbFileOpenOnly | kSbFileRead | kSbFileWrite, - SbFileModeStringToFlags("rb+")); -} - -TEST(SbFileModeStringToFlagsTest, Wuh) { - EXPECT_EQ(kSbFileCreateAlways | kSbFileWrite, SbFileModeStringToFlags("w")); - EXPECT_EQ(kSbFileCreateAlways | kSbFileWrite | kSbFileRead, - SbFileModeStringToFlags("w+")); - EXPECT_EQ(kSbFileCreateAlways | kSbFileWrite | kSbFileRead, - SbFileModeStringToFlags("w+b")); - EXPECT_EQ(kSbFileCreateAlways | kSbFileWrite | kSbFileRead, - SbFileModeStringToFlags("wb+")); -} - -TEST(SbFileModeStringToFlagsTest, Aah) { - EXPECT_EQ(kSbFileOpenAlways | kSbFileWrite, SbFileModeStringToFlags("a")); - EXPECT_EQ(kSbFileOpenAlways | kSbFileWrite | kSbFileRead, - SbFileModeStringToFlags("a+")); - EXPECT_EQ(kSbFileOpenAlways | kSbFileWrite | kSbFileRead, - SbFileModeStringToFlags("a+b")); - EXPECT_EQ(kSbFileOpenAlways | kSbFileWrite | kSbFileRead, - SbFileModeStringToFlags("ab+")); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_open_test.cc b/starboard/nplb/file_open_test.cc deleted file mode 100644 index 4a99d746c886..000000000000 --- a/starboard/nplb/file_open_test.cc +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include - -#include -#include - -#include "starboard/configuration_constants.h" -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -void BasicTest(bool existing, - int open_flags, - bool expected_created, - bool expected_success, - int original_line) { - ScopedRandomFile random_file(existing ? ScopedRandomFile::kCreate - : ScopedRandomFile::kDontCreate); - const std::string& filename = random_file.filename(); -#define SB_FILE_OPEN_TEST_CONTEXT \ - "existing=" << existing << ", flags=0x" << std::hex << open_flags \ - << std::dec << ", expected_created=" << expected_created \ - << ", expected_success=" << expected_success \ - << ", filename=" << filename \ - << ", original_line=" << original_line - - if (!existing) { - struct stat info; - EXPECT_FALSE(stat(filename.c_str(), &info) == 0) - << SB_FILE_OPEN_TEST_CONTEXT; - if (stat(filename.c_str(), &info) == 0) { - return; - } - } - - bool created = !expected_created; - SbFileError error = kSbFileErrorMax; - SbFile file = SbFileOpen(filename.c_str(), open_flags, &created, &error); - if (!expected_success) { - EXPECT_FALSE(SbFileIsValid(file)) << SB_FILE_OPEN_TEST_CONTEXT; - EXPECT_EQ(expected_created, created) << SB_FILE_OPEN_TEST_CONTEXT; - EXPECT_NE(kSbFileOk, error) << SB_FILE_OPEN_TEST_CONTEXT; - - // Try to clean up in case test fails. - if (SbFileIsValid(file)) { - SbFileClose(file); - } - } else { - EXPECT_TRUE(SbFileIsValid(file)); - EXPECT_EQ(expected_created, created) << SB_FILE_OPEN_TEST_CONTEXT; - EXPECT_EQ(kSbFileOk, error) << SB_FILE_OPEN_TEST_CONTEXT; - if (SbFileIsValid(file)) { - bool result = SbFileClose(file); - EXPECT_TRUE(result) << SB_FILE_OPEN_TEST_CONTEXT; - } - } -#undef SB_FILE_OPEN_TEST_CONTEXT -} - -TEST(SbFileOpenTest, OpenOnlyOpensExistingFile) { - BasicTest(true, kSbFileOpenOnly | kSbFileRead, false, true, __LINE__); -} - -TEST(SbFileOpenTest, OpenOnlyDoesNotOpenNonExistingFile) { - BasicTest(false, kSbFileOpenOnly | kSbFileRead, false, false, __LINE__); -} - -TEST(SbFileOpenTest, CreateOnlyDoesNotCreateExistingFile) { - BasicTest(true, kSbFileCreateOnly | kSbFileWrite, false, false, __LINE__); -} - -TEST(SbFileOpenTest, CreateOnlyCreatesNonExistingFile) { - BasicTest(false, kSbFileCreateOnly | kSbFileWrite, true, true, __LINE__); -} - -TEST(SbFileOpenTest, OpenAlwaysOpensExistingFile) { - BasicTest(true, kSbFileOpenAlways | kSbFileWrite, false, true, __LINE__); -} - -TEST(SbFileOpenTest, OpenAlwaysCreatesNonExistingFile) { - BasicTest(false, kSbFileOpenAlways | kSbFileWrite, true, true, __LINE__); -} - -TEST(SbFileOpenTest, CreateAlwaysTruncatesExistingFile) { - BasicTest(true, kSbFileCreateAlways | kSbFileWrite, true, true, __LINE__); -} - -TEST(SbFileOpenTest, CreateAlwaysCreatesNonExistingFile) { - BasicTest(false, kSbFileCreateAlways | kSbFileWrite, true, true, __LINE__); -} - -TEST(SbFileOpenTest, OpenTruncatedTruncatesExistingFile) { - BasicTest(true, kSbFileOpenTruncated | kSbFileWrite, false, true, __LINE__); -} - -TEST(SbFileOpenTest, OpenTruncatedDoesNotCreateNonExistingFile) { - BasicTest(false, kSbFileOpenTruncated | kSbFileWrite, false, false, __LINE__); -} - -TEST(SbFileOpenTest, WorksWithNullOutParams) { - ScopedRandomFile random_file; - const std::string& filename = random_file.filename(); - - // What error? - { - SbFileError error = kSbFileErrorMax; - SbFile file = SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, - NULL, &error); - ASSERT_TRUE(SbFileIsValid(file)); - EXPECT_EQ(kSbFileOk, error) << "Failed to set error code for " << filename; - bool result = SbFileClose(file); - EXPECT_TRUE(result) << "SbFileClose failed for " << filename; - } - - // Created what? - { - bool created = true; - SbFile file = SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, - &created, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - EXPECT_FALSE(created) << "Failed to set created to false for " << filename; - bool result = SbFileClose(file); - EXPECT_TRUE(result) << "SbFileClose failed for " << filename; - } - - // What what? - { - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - bool result = SbFileClose(file); - EXPECT_TRUE(result) << "SbFileClose failed for " << filename; - } -} - -TEST(SbFileOpenTest, OpenOnlyDoesNotOpenNonExistingStaticContentFile) { - std::string path = GetFileTestsDataDir(); - std::string missing_file = path + kSbFileSepChar + "missing_file"; - bool created = true; - SbFileError error = kSbFileErrorMax; - SbFile file = SbFileOpen(missing_file.c_str(), kSbFileOpenOnly | kSbFileRead, - &created, &error); - EXPECT_FALSE(SbFileIsValid(file)); - EXPECT_FALSE(created); - EXPECT_NE(kSbFileOk, error); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_read_test.cc b/starboard/nplb/file_read_test.cc deleted file mode 100644 index 7d4d4a0a0d4e..000000000000 --- a/starboard/nplb/file_read_test.cc +++ /dev/null @@ -1,300 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include - -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -// Sets up an empty test fixture, required for typed tests. -template -class SbFileReadTest : public testing::Test {}; - -class SbFileReader { - public: - static int Read(SbFile file, char* data, int size) { - return SbFileRead(file, data, size); - } -}; - -class SbFileReaderAll { - public: - static int Read(SbFile file, char* data, int size) { - return SbFileReadAll(file, data, size); - } -}; - -typedef testing::Types SbFileReadTestTypes; - -TYPED_TEST_CASE(SbFileReadTest, SbFileReadTestTypes); - -const int kBufferLength = 16 * 1024; - -TYPED_TEST(SbFileReadTest, InvalidFileErrors) { - char buffer[kBufferLength]; - int result = TypeParam::Read(kSbFileInvalid, buffer, kBufferLength); - EXPECT_EQ(-1, result); -} - -TYPED_TEST(SbFileReadTest, BasicReading) { - // Create a pattern file that is not an even multiple of the buffer size, - // but is over several times the size of the buffer. - const int kFileSize = kBufferLength * 16 / 3; - ScopedRandomFile random_file(kFileSize); - const std::string& filename = random_file.filename(); - - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - // Create a bigger buffer than necessary, so we can test the memory around - // the portion given to SbFileRead. - const int kRealBufferLength = kBufferLength * 2; - char real_buffer[kRealBufferLength] = {0}; - const int kBufferOffset = kBufferLength / 2; - char* buffer = real_buffer + kBufferOffset; - - // Initialize to some arbitrary pattern so we can verify it later. - for (int i = 0; i < kRealBufferLength; ++i) { - real_buffer[i] = '\xCD'; - } - - // Read and check the whole file. - int total = 0; - int previous_total = 0; - int max = 0; - while (true) { - int bytes_read = TypeParam::Read(file, buffer, kBufferLength); - if (bytes_read == 0) { - break; - } - - // Check that we didn't read more than the buffer size. - EXPECT_GE(kBufferLength, bytes_read); - - // Check that we didn't get an error. - EXPECT_LT(0, bytes_read); - - // Do some accounting to check later. - previous_total = total; - total += bytes_read; - if (bytes_read > max) { - max = bytes_read; - } - - ScopedRandomFile::ExpectPattern(previous_total, buffer, bytes_read, - __LINE__); - } - - // Check that we read the whole file. - EXPECT_EQ(kFileSize, total); - - // check that we didn't write over any other parts of the buffer. - for (int i = 0; i < kBufferOffset; ++i) { - EXPECT_EQ('\xCD', real_buffer[i]); - } - - for (int i = kBufferOffset + max; i < kRealBufferLength; ++i) { - EXPECT_EQ('\xCD', real_buffer[i]); - } - - bool result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TYPED_TEST(SbFileReadTest, ReadPastEnd) { - const int kFileSize = kBufferLength; - ScopedRandomFile random_file(kFileSize); - const std::string& filename = random_file.filename(); - - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - // Create a bigger buffer than necessary, so we can test the memory around - // the portion given to SbFileRead. - const int kRealBufferLength = kBufferLength * 2; - char real_buffer[kRealBufferLength] = {0}; - const int kBufferOffset = kBufferLength / 2; - char* buffer = real_buffer + kBufferOffset; - - // Initialize to some arbitrary pattern so we can verify it later. - for (int i = 0; i < kRealBufferLength; ++i) { - real_buffer[i] = '\xCD'; - } - - // Read off the end of the file. - int position = static_cast(SbFileSeek(file, kSbFileFromEnd, 0)); - EXPECT_EQ(kFileSize, position); - int bytes_read = TypeParam::Read(file, buffer, kBufferLength); - EXPECT_EQ(0, bytes_read); - - for (int i = 0; i < kRealBufferLength; ++i) { - EXPECT_EQ('\xCD', real_buffer[i]); - } - - bool result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TYPED_TEST(SbFileReadTest, ReadZeroBytes) { - const int kFileSize = kBufferLength; - ScopedRandomFile random_file(kFileSize); - const std::string& filename = random_file.filename(); - - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - // Create a bigger buffer than necessary, so we can test the memory around - // the portion given to SbFileRead. - const int kRealBufferLength = kBufferLength * 2; - char real_buffer[kRealBufferLength] = {0}; - const int kBufferOffset = kBufferLength / 2; - char* buffer = real_buffer + kBufferOffset; - - // Initialize to some arbitrary pattern so we can verify it later. - for (int i = 0; i < kRealBufferLength; ++i) { - real_buffer[i] = '\xCD'; - } - - // Read zero bytes. - for (int i = 0; i < 10; ++i) { - int bytes_read = TypeParam::Read(file, buffer, 0); - EXPECT_EQ(0, bytes_read); - } - - for (int i = 0; i < kRealBufferLength; ++i) { - EXPECT_EQ('\xCD', real_buffer[i]); - } - - bool result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TYPED_TEST(SbFileReadTest, ReadFromMiddle) { - const int kFileSize = kBufferLength * 2; - ScopedRandomFile random_file(kFileSize); - const std::string& filename = random_file.filename(); - - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - // Create a bigger buffer than necessary, so we can test the memory around - // the portion given to SbFileRead. - const int kRealBufferLength = kBufferLength * 2; - char real_buffer[kRealBufferLength] = {0}; - const int kBufferOffset = kBufferLength / 2; - char* buffer = real_buffer + kBufferOffset; - - // Initialize to some arbitrary pattern so we can verify it later. - for (int i = 0; i < kRealBufferLength; ++i) { - real_buffer[i] = '\xCD'; - } - - // Read from the middle of the file. - int position = - static_cast(SbFileSeek(file, kSbFileFromBegin, kFileSize / 4)); - EXPECT_EQ(kFileSize / 4, position); - int bytes_read = TypeParam::Read(file, buffer, kBufferLength); - EXPECT_GE(kBufferLength, bytes_read); - EXPECT_LT(0, bytes_read); - - ScopedRandomFile::ExpectPattern(position, buffer, bytes_read, __LINE__); - - for (int i = 0; i < kBufferOffset; ++i) { - EXPECT_EQ('\xCD', real_buffer[i]); - } - - for (int i = kBufferOffset + bytes_read; i < kRealBufferLength; ++i) { - EXPECT_EQ('\xCD', real_buffer[i]); - } - - bool result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TYPED_TEST(SbFileReadTest, ReadStaticContent) { - for (auto filename : GetFileTestsFilePaths()) { - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)) << "Can't open: " << filename; - - // Create a bigger buffer than necessary, so we can test the memory around - // the portion given to SbFileRead. - const int kRealBufferLength = kBufferLength * 2; - char real_buffer[kRealBufferLength] = {0}; - const int kBufferOffset = kBufferLength / 2; - char* buffer = real_buffer + kBufferOffset; - - // Initialize to some arbitrary pattern so we can verify it later. - for (int i = 0; i < kRealBufferLength; ++i) { - real_buffer[i] = '\xCD'; - } - - // Read and check the whole file. - std::string content; - int total = 0; - int max = 0; - while (true) { - int bytes_read = TypeParam::Read(file, buffer, kBufferLength); - if (bytes_read == 0) { - break; - } - - // Check that we didn't read more than the buffer size. - EXPECT_GE(kBufferLength, bytes_read); - - // Check that we didn't get an error. - EXPECT_LT(0, bytes_read); - - // Do some accounting to check later. - total += bytes_read; - if (bytes_read > max) { - max = bytes_read; - } - - // Accumulate the content of the whole file. - content.append(buffer, bytes_read); - } - - // Check that we didn't write over any other parts of the buffer. - for (int i = 0; i < kBufferOffset; ++i) { - EXPECT_EQ('\xCD', real_buffer[i]); - } - - for (int i = kBufferOffset + max; i < kRealBufferLength; ++i) { - EXPECT_EQ('\xCD', real_buffer[i]); - } - - EXPECT_EQ(GetTestFileExpectedContent(filename), content); - - bool result = SbFileClose(file); - EXPECT_TRUE(result); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_read_write_all_test.cc b/starboard/nplb/file_read_write_all_test.cc deleted file mode 100644 index 6dc621363818..000000000000 --- a/starboard/nplb/file_read_write_all_test.cc +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -class SbReadWriteAllTestWithBuffer : public ::testing::TestWithParam { - public: - int GetBufferSize() { return GetParam(); } -}; - -TEST_P(SbReadWriteAllTestWithBuffer, ReadFile) { - ScopedRandomFile random_file(0, ScopedRandomFile::kDontCreate); - const std::string& filename = random_file.filename(); - - SbFile file = SbFileOpen(filename.c_str(), kSbFileCreateAlways | kSbFileWrite, - NULL, NULL); - - std::vector file_contents; - file_contents.reserve(GetBufferSize()); - for (int i = 0; i < GetBufferSize(); ++i) { - file_contents.push_back(i % 255); - } - int bytes_written = - SbFileWriteAll(file, file_contents.data(), file_contents.size()); - EXPECT_EQ(GetBufferSize(), bytes_written); - - SbFileClose(file); - - file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - std::vector read_contents(GetBufferSize()); - int bytes_read = - SbFileReadAll(file, read_contents.data(), read_contents.size()); - EXPECT_EQ(GetBufferSize(), bytes_read); - EXPECT_EQ(file_contents, read_contents); - - SbFileClose(file); -} - -INSTANTIATE_TEST_CASE_P( - SbReadAllTestSbReadWriteAllTest, - SbReadWriteAllTestWithBuffer, - ::testing::Values(0, 1, 1024, 16 * 1024, 128 * 1024, 1024 * 1024), - ::testing::PrintToStringParamName()); - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_seek_test.cc b/starboard/nplb/file_seek_test.cc deleted file mode 100644 index 35789796c1e0..000000000000 --- a/starboard/nplb/file_seek_test.cc +++ /dev/null @@ -1,241 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include - -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbFileSeekTest, InvalidFileErrors) { - int result = - static_cast(SbFileSeek(kSbFileInvalid, kSbFileFromBegin, 50)); - EXPECT_EQ(-1, result); - - result = static_cast(SbFileSeek(kSbFileInvalid, kSbFileFromEnd, -50)); - EXPECT_EQ(-1, result); - - result = - static_cast(SbFileSeek(kSbFileInvalid, kSbFileFromCurrent, -50)); - EXPECT_EQ(-1, result); - - result = static_cast(SbFileSeek(kSbFileInvalid, kSbFileFromCurrent, 50)); - EXPECT_EQ(-1, result); -} - -TEST(SbFileSeekTest, FromEndWorks) { - starboard::nplb::ScopedRandomFile random_file; - const std::string& filename = random_file.filename(); - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - SbFileInfo info; - bool result = SbFileGetInfo(file, &info); - EXPECT_TRUE(result); - - int64_t position = SbFileSeek(file, kSbFileFromEnd, 0); - EXPECT_EQ(info.size, position); - - int64_t target = -(random_file.size() / 6); - position = SbFileSeek(file, kSbFileFromEnd, target); - EXPECT_EQ(info.size + target, position); - - position = SbFileSeek(file, kSbFileFromEnd, -info.size); - EXPECT_EQ(0, position); - - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TEST(SbFileSeekTest, FromCurrentWorks) { - starboard::nplb::ScopedRandomFile random_file; - const std::string& filename = random_file.filename(); - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - SbFileInfo info; - bool result = SbFileGetInfo(file, &info); - EXPECT_TRUE(result); - - int64_t position = SbFileSeek(file, kSbFileFromCurrent, 0); - EXPECT_EQ(0, position); - - int64_t target = random_file.size() / 6; - position = SbFileSeek(file, kSbFileFromCurrent, target); - EXPECT_EQ(target, position); - - position = SbFileSeek(file, kSbFileFromCurrent, target); - EXPECT_EQ(target * 2, position); - - position = SbFileSeek(file, kSbFileFromCurrent, 0); - EXPECT_EQ(target * 2, position); - - position = SbFileSeek(file, kSbFileFromCurrent, info.size - position); - EXPECT_EQ(info.size, position); - - position = SbFileSeek(file, kSbFileFromCurrent, -info.size); - EXPECT_EQ(0, position); - - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TEST(SbFileSeekTest, FromBeginWorks) { - starboard::nplb::ScopedRandomFile random_file; - const std::string& filename = random_file.filename(); - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - SbFileInfo info; - bool result = SbFileGetInfo(file, &info); - EXPECT_TRUE(result); - - int64_t position = SbFileSeek(file, kSbFileFromBegin, 0); - EXPECT_EQ(0, position); - - int64_t target = random_file.size() / 6; - position = SbFileSeek(file, kSbFileFromBegin, target); - EXPECT_EQ(target, position); - - target = random_file.size() / 3; - position = SbFileSeek(file, kSbFileFromBegin, target); - EXPECT_EQ(target, position); - - target = info.size - random_file.size() / 6; - position = SbFileSeek(file, kSbFileFromBegin, target); - EXPECT_EQ(target, position); - - position = SbFileSeek(file, kSbFileFromBegin, info.size); - EXPECT_EQ(info.size, position); - - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -std::string GetTestStaticContentFile() { - std::string filename = GetFileTestsFilePaths().front(); - int content_length = GetTestFileExpectedContent(filename).length(); - EXPECT_GT(content_length, 40); - return filename; -} - -TEST(SbFileSeekTest, FromEndInStaticContentWorks) { - std::string filename = GetTestStaticContentFile(); - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - int content_length = GetTestFileExpectedContent(filename).length(); - - SbFileInfo info; - bool result = SbFileGetInfo(file, &info); - EXPECT_TRUE(result); - - int64_t position = SbFileSeek(file, kSbFileFromEnd, 0); - EXPECT_EQ(info.size, position); - - int64_t target = -(content_length / 6); - position = SbFileSeek(file, kSbFileFromEnd, target); - EXPECT_EQ(info.size + target, position); - - position = SbFileSeek(file, kSbFileFromEnd, -info.size); - EXPECT_EQ(0, position); - - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TEST(SbFileSeekTest, FromCurrentInStaticContentWorks) { - std::string filename = GetTestStaticContentFile(); - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - int content_length = GetTestFileExpectedContent(filename).length(); - - SbFileInfo info; - bool result = SbFileGetInfo(file, &info); - EXPECT_TRUE(result); - - int64_t position = SbFileSeek(file, kSbFileFromCurrent, 0); - EXPECT_EQ(0, position); - - int64_t target = content_length / 6; - position = SbFileSeek(file, kSbFileFromCurrent, target); - EXPECT_EQ(target, position); - - position = SbFileSeek(file, kSbFileFromCurrent, target); - EXPECT_EQ(target * 2, position); - - position = SbFileSeek(file, kSbFileFromCurrent, 0); - EXPECT_EQ(target * 2, position); - - position = SbFileSeek(file, kSbFileFromCurrent, info.size - position); - EXPECT_EQ(info.size, position); - - position = SbFileSeek(file, kSbFileFromCurrent, -info.size); - EXPECT_EQ(0, position); - - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TEST(SbFileSeekTest, FromBeginInStaticContentWorks) { - std::string filename = GetFileTestsFilePaths().front(); - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - int content_length = GetTestFileExpectedContent(filename).length(); - - SbFileInfo info; - bool result = SbFileGetInfo(file, &info); - EXPECT_TRUE(result); - - int64_t position = SbFileSeek(file, kSbFileFromBegin, 0); - EXPECT_EQ(0, position); - - int64_t target = content_length / 6; - position = SbFileSeek(file, kSbFileFromBegin, target); - EXPECT_EQ(target, position); - - target = content_length / 3; - position = SbFileSeek(file, kSbFileFromBegin, target); - EXPECT_EQ(target, position); - - target = info.size - content_length / 6; - position = SbFileSeek(file, kSbFileFromBegin, target); - EXPECT_EQ(target, position); - - position = SbFileSeek(file, kSbFileFromBegin, info.size); - EXPECT_EQ(info.size, position); - - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_truncate_test.cc b/starboard/nplb/file_truncate_test.cc deleted file mode 100644 index 6a316d2d7694..000000000000 --- a/starboard/nplb/file_truncate_test.cc +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include - -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbFileTruncateTest, InvalidFileErrors) { - bool result = SbFileTruncate(kSbFileInvalid, 0); - EXPECT_FALSE(result); - - result = SbFileTruncate(kSbFileInvalid, -1); - EXPECT_FALSE(result); - - result = SbFileTruncate(kSbFileInvalid, 100); - EXPECT_FALSE(result); -} - -TEST(SbFileTruncateTest, TruncateToZero) { - const int kStartSize = 123; - const int kEndSize = 0; - ScopedRandomFile random_file(kStartSize); - const std::string& filename = random_file.filename(); - - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileWrite | kSbFileRead, - NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - { - SbFileInfo info = {0}; - bool result = SbFileGetInfo(file, &info); - EXPECT_EQ(kStartSize, info.size); - } - - bool result = SbFileTruncate(file, kEndSize); - EXPECT_TRUE(result); - - { - SbFileInfo info = {0}; - result = SbFileGetInfo(file, &info); - EXPECT_EQ(kEndSize, info.size); - } - - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TEST(SbFileTruncateTest, TruncateUpInSize) { - // "Truncate," I don't think that word means what you think it means. - const int kStartSize = 123; - const int kEndSize = kStartSize * 2; - ScopedRandomFile random_file(kStartSize); - const std::string& filename = random_file.filename(); - - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileWrite | kSbFileRead, - NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - { - SbFileInfo info = {0}; - bool result = SbFileGetInfo(file, &info); - EXPECT_TRUE(result); - EXPECT_EQ(kStartSize, info.size); - } - - int position = static_cast(SbFileSeek(file, kSbFileFromCurrent, 0)); - EXPECT_EQ(0, position); - - bool result = SbFileTruncate(file, kEndSize); - EXPECT_TRUE(result); - - position = static_cast(SbFileSeek(file, kSbFileFromCurrent, 0)); - EXPECT_EQ(0, position); - - { - SbFileInfo info = {0}; - result = SbFileGetInfo(file, &info); - EXPECT_TRUE(result); - EXPECT_EQ(kEndSize, info.size); - } - - char buffer[kEndSize] = {0}; - int bytes = SbFileReadAll(file, buffer, kEndSize); - EXPECT_EQ(kEndSize, bytes); - - ScopedRandomFile::ExpectPattern(0, buffer, kStartSize, __LINE__); - - for (int i = kStartSize; i < kEndSize; ++i) { - EXPECT_EQ(0, buffer[i]); - } - - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_write_test.cc b/starboard/nplb/file_write_test.cc deleted file mode 100644 index 6493a783bc30..000000000000 --- a/starboard/nplb/file_write_test.cc +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Writing is partially tested by some of the file helpers that create files for -// the tests to operate on. - -#if SB_API_VERSION < 17 - -#include - -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -// Sets up an empty test fixture, required for typed tests. -template -class SbFileWriteTest : public testing::Test {}; - -class SbFileWriter { - public: - static int Write(SbFile file, char* data, int size) { - return SbFileWrite(file, data, size); - } -}; - -class SbFileWriterAll { - public: - static int Write(SbFile file, char* data, int size) { - return SbFileWriteAll(file, data, size); - } -}; - -typedef testing::Types SbFileWriteTestTypes; - -TYPED_TEST_CASE(SbFileWriteTest, SbFileWriteTestTypes); - -const int kBufferLength = 16 * 1024; - -TYPED_TEST(SbFileWriteTest, InvalidFileErrors) { - char buffer[kBufferLength] = {0}; - int result = TypeParam::Write(kSbFileInvalid, buffer, kBufferLength); - EXPECT_EQ(-1, result); -} - -TYPED_TEST(SbFileWriteTest, BasicWriting) { - // Choose a file size that is not an even multiple of the buffer size, but - // is over several times the size of the buffer. - const int kFileSize = kBufferLength * 16 / 3; - ScopedRandomFile random_file(0, ScopedRandomFile::kDontCreate); - const std::string& filename = random_file.filename(); - - SbFile file = - SbFileOpen(filename.c_str(), - kSbFileCreateAlways | kSbFileWrite | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - // Create a bigger buffer than necessary, so we can test the memory around - // the portion given to SbFileRead. - char buffer[kBufferLength] = {0}; - - // Initialize to some arbitrary pattern so we can verify it later. - for (int i = 0; i < kBufferLength; ++i) { - buffer[i] = static_cast(i & 0xFF); - } - - // Read and check the whole file. - int total = 0; - while (true) { - if (total == kFileSize) { - break; - } - - int remaining = kFileSize - total; - int to_write = remaining < kBufferLength ? remaining : kBufferLength; - int bytes_written = - TypeParam::Write(file, buffer + (total % kBufferLength), to_write); - - // Check that we didn't write more than the buffer size. - EXPECT_GE(to_write, bytes_written); - - // Check that we didn't get an error. - ASSERT_LT(0, bytes_written); - - total += bytes_written; - EXPECT_EQ(total, SbFileSeek(file, kSbFileFromCurrent, 0)); - } - - // Tests reading and writing from same opened file. - bool result = SbFileFlush(file); - ASSERT_TRUE(result); - int position = static_cast(SbFileSeek(file, kSbFileFromBegin, 0)); - ASSERT_EQ(0, position); - - // Read and check the whole file. - total = 0; - int previous_total = 0; - while (true) { - int bytes_read = SbFileReadAll(file, buffer, kBufferLength); - if (bytes_read == 0) { - break; - } - - // Check that we didn't read more than the buffer size. - EXPECT_GE(kBufferLength, bytes_read); - - // Check that we didn't get an error. - ASSERT_LT(0, bytes_read); - - // Do some accounting to check later. - previous_total = total; - total += bytes_read; - - ScopedRandomFile::ExpectPattern(previous_total, buffer, bytes_read, - __LINE__); - } - - // Check that we read the whole file. - EXPECT_EQ(kFileSize, total); - - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TYPED_TEST(SbFileWriteTest, WriteZeroBytes) { - ScopedRandomFile random_file(0, ScopedRandomFile::kDontCreate); - const std::string& filename = random_file.filename(); - - SbFile file = SbFileOpen(filename.c_str(), kSbFileCreateOnly | kSbFileWrite, - NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - char buffer[kBufferLength] = {0}; - - // Write zero bytes. - for (int i = 0; i < 10; ++i) { - int bytes_written = TypeParam::Write(file, buffer, 0); - EXPECT_EQ(0, bytes_written); - } - - bool result = SbFileClose(file); - EXPECT_TRUE(result); - - file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - SbFileInfo info; - result = SbFileGetInfo(file, &info); - EXPECT_TRUE(result); - EXPECT_EQ(0, info.size); - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/image_test.cc b/starboard/nplb/image_test.cc deleted file mode 100644 index f3b12a081826..000000000000 --- a/starboard/nplb/image_test.cc +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2020 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/image.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const SbDecodeTargetFormat kDecodeTargetFormats[] = { - kSbDecodeTargetFormat1PlaneRGBA, - kSbDecodeTargetFormat1PlaneBGRA, - kSbDecodeTargetFormat2PlaneYUVNV12, - kSbDecodeTargetFormat3PlaneYUVI420, - kSbDecodeTargetFormat3Plane10BitYUVI420, - kSbDecodeTargetFormat1PlaneUYVY, - kSbDecodeTargetFormatInvalid, -}; - -const char* kMimeTypes[] = { - "image/jpeg", "image/png", "image/gif", - "application/json", "image/webp", "invalid", -}; - -// Verify SbImageIsDecodeSupported() can be called with any parameter values. -TEST(ImageTest, IsDecodeSupported) { - for (size_t format = 0; - format < sizeof(kDecodeTargetFormats) / sizeof(kDecodeTargetFormats[0]); - ++format) { - for (size_t mime_type = 0; - mime_type < sizeof(kMimeTypes) / sizeof(kMimeTypes[0]); ++mime_type) { - SbImageIsDecodeSupported(kMimeTypes[mime_type], - kDecodeTargetFormats[format]); - } - } -} - -} // namespace. -} // namespace nplb. -} // namespace starboard. - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/include_all.c b/starboard/nplb/include_all.c index 241c1f385139..1f2c7879367b 100644 --- a/starboard/nplb/include_all.c +++ b/starboard/nplb/include_all.c @@ -14,14 +14,8 @@ // Includes all headers in a C context to make sure they compile as C files. -#if SB_API_VERSION < 16 -#include "starboard/accessibility.h" -#endif // SB_API_VERSION < 16 #include "starboard/atomic.h" #include "starboard/audio_sink.h" -#if SB_API_VERSION < 16 -#include "starboard/byte_swap.h" -#endif // SB_API_VERSION < 16 #include "starboard/condition_variable.h" #include "starboard/configuration.h" #include "starboard/cpu_features.h" @@ -33,9 +27,6 @@ #include "starboard/export.h" #include "starboard/file.h" #include "starboard/gles.h" -#if SB_API_VERSION < 16 -#include "starboard/image.h" -#endif // SB_API_VERSION < 16 #include "starboard/input.h" #include "starboard/key.h" #include "starboard/log.h" @@ -51,15 +42,8 @@ #include "starboard/string.h" #include "starboard/system.h" #include "starboard/thread.h" -#if SB_API_VERSION < 16 -#include "starboard/time.h" -#endif // SB_API_VERSION < 16 #include "starboard/time_zone.h" #include "starboard/types.h" -#if SB_API_VERSION < 16 -#include "starboard/ui_navigation.h" -#include "starboard/user.h" -#endif // SB_API_VERSION < 16 #include "starboard/window.h" // This doesn't really belong here, but ensures that SB_COMPILE_ASSERT works in diff --git a/starboard/nplb/log_is_tty_test.cc b/starboard/nplb/log_is_tty_test.cc deleted file mode 100644 index b9bf61546cba..000000000000 --- a/starboard/nplb/log_is_tty_test.cc +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/log.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbLogIsTtyTest, DontCrashMeBro) { - // Since the tests could be run on a TTY or not, there's no way to decide what - // this function should return. - SbLogIsTty(); - SB_DLOG(INFO) << "Is TTY: " << SbLogIsTty(); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/media_buffer_test.cc b/starboard/nplb/media_buffer_test.cc index d3ee92efa36f..875042817fb9 100644 --- a/starboard/nplb/media_buffer_test.cc +++ b/starboard/nplb/media_buffer_test.cc @@ -116,11 +116,7 @@ std::vector TryToAllocateMemory(int size, ? allocation_unit : (std::rand() % 500 + 100) * 1024; void* allocated_memory = NULL; -#if SB_API_VERSION < 16 - allocated_memory = SbMemoryAllocateAligned(alignment, allocation_increment); -#else posix_memalign(&allocated_memory, alignment, allocation_increment); -#endif EXPECT_NE(allocated_memory, nullptr); if (!allocated_memory) { return allocated_ptrs; @@ -201,32 +197,6 @@ TEST(SbMediaBufferTest, AllocationUnit) { allocated_ptrs = TryToAllocateMemory(initial_buffer_capacity, allocation_unit, sizeof(void*)); } -#if SB_API_VERSION < 16 - if (!HasNonfatalFailure()) { - for (SbMediaType type : kMediaTypes) { - // The test will be run more than once, it's redundant but allows us to - // keep the test logic in one place. - int alignment = SbMediaGetBufferAlignment(); - SB_LOG(INFO) << "alignment=" << alignment; - EXPECT_EQ(alignment & (alignment - 1), 0) - << "Alignment must always be a power of 2"; - if (HasNonfatalFailure()) { - break; - } - int media_budget = type == SbMediaType::kSbMediaTypeAudio - ? kMinAudioBudget - : kMinVideoBudget1080p; - std::vector media_buffer_allocated_memory = - TryToAllocateMemory(media_budget, allocation_unit, alignment); - allocated_ptrs.insert(allocated_ptrs.end(), - media_buffer_allocated_memory.begin(), - media_buffer_allocated_memory.end()); - if (HasNonfatalFailure()) { - break; - } - } - } -#endif // SB_API_VERSION < 16 for (void* ptr : allocated_ptrs) { free(ptr); @@ -305,28 +275,10 @@ TEST(SbMediaBufferTest, ProgressiveBudget) { } } -#if SB_API_VERSION < 16 -TEST(SbMediaBufferTest, StorageType) { - // Just don't crash. - SbMediaBufferStorageType type = SbMediaGetBufferStorageType(); - switch (type) { - case kSbMediaBufferStorageTypeMemory: - case kSbMediaBufferStorageTypeFile: - return; - } - SB_NOTREACHED(); -} -#endif // SB_API_VERSION < 16 - TEST(SbMediaBufferTest, UsingMemoryPool) { -#if SB_API_VERSION < 16 - // Just don't crash. - SbMediaIsBufferUsingMemoryPool(); -#else EXPECT_TRUE(SbMediaIsBufferUsingMemoryPool()) << "This function is deprecated. Media buffer pools are always " << "used in Starboard 16 and newer. Please see starboard/CHANGELOG.md"; -#endif // SB_API_VERSION < 16 } TEST(SbMediaBufferTest, VideoBudget) { @@ -350,18 +302,8 @@ TEST(SbMediaBufferTest, ValidatePerformance) { SbMediaGetBufferGarbageCollectionDurationThreshold); TEST_PERF_FUNCNOARGS_DEFAULT(SbMediaGetInitialBufferCapacity); TEST_PERF_FUNCNOARGS_DEFAULT(SbMediaIsBufferPoolAllocateOnDemand); -#if SB_API_VERSION < 16 - TEST_PERF_FUNCNOARGS_DEFAULT(SbMediaGetBufferStorageType); -#endif // SB_API_VERSION < 16 TEST_PERF_FUNCNOARGS_DEFAULT(SbMediaIsBufferUsingMemoryPool); -#if SB_API_VERSION < 16 - for (auto type : kMediaTypes) { - TEST_PERF_FUNCNOARGS_DEFAULT(SbMediaGetBufferAlignment); - TEST_PERF_FUNCNOARGS_DEFAULT(SbMediaGetBufferPadding); - } -#endif // SB_API_VERSION < 16 - for (auto resolution : kVideoResolutions) { for (auto bits_per_pixel : kBitsPerPixelValues) { for (auto codec : kVideoCodecs) { diff --git a/starboard/nplb/memory_allocate_aligned_test.cc b/starboard/nplb/memory_allocate_aligned_test.cc deleted file mode 100644 index 1ff841a95935..000000000000 --- a/starboard/nplb/memory_allocate_aligned_test.cc +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/memory.h" -#include "starboard/configuration.h" - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -// Choose a size that isn't naturally aligned to anything. -const size_t kSize = 1024 * 128 + 1; - -TEST(SbMemoryAllocateAlignedTest, AllocatesAligned) { - const size_t kMaxAlign = 4096 + 1; - for (size_t align = 2; align < kMaxAlign; align <<= 1) { - void* memory = SbMemoryAllocateAligned(align, kSize); - ASSERT_NE(static_cast(NULL), memory); - EXPECT_TRUE(starboard::common::MemoryIsAligned(memory, align)); - SbMemoryDeallocateAligned(memory); - } -} - -TEST(SbMemoryAllocateAlignedTest, AllocatesAlignedZero) { - const size_t kMaxAlign = 4096 + 1; - for (size_t align = 2; align < kMaxAlign; align <<= 1) { - void* memory = SbMemoryAllocateAligned(align, 0); - // We can't expect anything here because some implementations may return an - // allocated zero-size memory block, and some implementations may return - // NULL. - if (memory) { - EXPECT_TRUE(starboard::common::MemoryIsAligned(memory, align)); - } - SbMemoryDeallocateAligned(memory); - } -} - -TEST(SbMemoryAllocateAlignedTest, CanReadWriteToResult) { - const size_t kAlign = 4096; - void* memory = SbMemoryAllocateAligned(kAlign, kSize); - ASSERT_NE(static_cast(NULL), memory); - char* data = static_cast(memory); - for (int i = 0; i < kSize; ++i) { - data[i] = static_cast(i); - } - - for (int i = 0; i < kSize; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - - SbMemoryDeallocateAligned(memory); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/memory_allocate_test.cc b/starboard/nplb/memory_allocate_test.cc deleted file mode 100644 index ca5aafc2d1fb..000000000000 --- a/starboard/nplb/memory_allocate_test.cc +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const size_t kSize = 1024 * 128; - -TEST(SbMemoryAllocateTest, AllocatesNormally) { - void* memory = SbMemoryAllocate(kSize); - EXPECT_NE(static_cast(NULL), memory); - - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryAllocateTest, AllocatesZero) { - void* memory = SbMemoryAllocate(0); - - // We can't expect anything here because some implementations may return an - // allocated zero-size memory block, and some implementations may return NULL. - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryAllocateTest, AllocatesOne) { - void* memory = SbMemoryAllocate(1); - EXPECT_NE(static_cast(NULL), memory); - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryAllocateTest, CanReadWriteToResult) { - void* memory = SbMemoryAllocate(kSize); - ASSERT_NE(static_cast(NULL), memory); - char* data = static_cast(memory); - for (int i = 0; i < kSize; ++i) { - data[i] = static_cast(i); - } - - for (int i = 0; i < kSize; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - - SbMemoryDeallocate(memory); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/memory_deallocate_aligned_test.cc b/starboard/nplb/memory_deallocate_aligned_test.cc deleted file mode 100644 index e6f746ac91b7..000000000000 --- a/starboard/nplb/memory_deallocate_aligned_test.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" - -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const size_t kSize = 1024 * 128; - -TEST(SbMemoryDeallocateAlignedTest, DeallocatesAligned) { - const size_t kMaxAlign = 4096 + 1; - for (size_t align = 2; align < kMaxAlign; align <<= 1) { - void* memory = SbMemoryAllocateAligned(align, kSize); - SbMemoryDeallocateAligned(memory); - } -} - -TEST(SbMemoryDeallocateAlignedTest, FreesNull) { - SbMemoryDeallocateAligned(NULL); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/memory_deallocate_test.cc b/starboard/nplb/memory_deallocate_test.cc deleted file mode 100644 index aaac6da8e72e..000000000000 --- a/starboard/nplb/memory_deallocate_test.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const size_t kSize = 1024 * 128; - -TEST(SbMemoryDeallocateTest, FreesNormally) { - void* memory = SbMemoryAllocate(kSize); - EXPECT_NE(static_cast(NULL), memory); - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryDeallocateTest, FreesNull) { - SbMemoryDeallocate(NULL); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/memory_map_test.cc b/starboard/nplb/memory_map_test.cc deleted file mode 100644 index 134acc870095..000000000000 --- a/starboard/nplb/memory_map_test.cc +++ /dev/null @@ -1,300 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include - -#include "starboard/common/memory.h" -#include "starboard/configuration_constants.h" -#include "starboard/memory.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const size_t kSize = kSbMemoryPageSize * 8; -const void* kFailed = SB_MEMORY_MAP_FAILED; - -TEST(SbMemoryMapTest, AllocatesNormally) { - void* memory = SbMemoryMap(kSize, kSbMemoryMapProtectRead, "test"); - ASSERT_NE(kFailed, memory); - EXPECT_TRUE(SbMemoryUnmap(memory, kSize)); -} - -TEST(SbMemoryMapTest, AllocatesZero) { - void* memory = SbMemoryMap(0, kSbMemoryMapProtectRead, "test"); - ASSERT_EQ(kFailed, memory); - EXPECT_FALSE(SbMemoryUnmap(memory, 0)); -} - -TEST(SbMemoryMapTest, AllocatesOne) { - void* memory = SbMemoryMap(1, kSbMemoryMapProtectRead, "test"); - ASSERT_NE(kFailed, memory); - EXPECT_TRUE(SbMemoryUnmap(memory, 1)); -} - -TEST(SbMemoryMapTest, AllocatesOnePage) { - void* memory = - SbMemoryMap(kSbMemoryPageSize, kSbMemoryMapProtectRead, "test"); - ASSERT_NE(kFailed, memory); - EXPECT_TRUE(SbMemoryUnmap(memory, kSbMemoryPageSize)); -} - -// Disabled because it is too slow -- currently ~5 seconds on a Linux desktop -// with lots of memory. -TEST(SbMemoryMapTest, DISABLED_DoesNotLeak) { - const int64_t kIterations = 16; - const double kFactor = 1.25; - const size_t kSparseCommittedPages = 256; - - const int64_t kBytesMappedPerIteration = - static_cast(SbSystemGetTotalCPUMemory() * kFactor) / kIterations; - const int64_t kMaxBytesMapped = kBytesMappedPerIteration * kIterations; - - for (int64_t total_bytes_mapped = 0; total_bytes_mapped < kMaxBytesMapped; - total_bytes_mapped += kBytesMappedPerIteration) { - void* memory = - SbMemoryMap(kBytesMappedPerIteration, kSbMemoryMapProtectWrite, "test"); - ASSERT_NE(kFailed, memory); - - // If this is the last iteration of the loop, then force a page commit for - // every single page. For any other iteration, force a page commit for - // |kSparseCommittedPages|. - bool last_iteration = - !(total_bytes_mapped + kBytesMappedPerIteration < kMaxBytesMapped); - uint8_t* first_page = static_cast(memory); - const size_t page_increment_factor = - (last_iteration) - ? size_t(1u) - : std::max(static_cast( - kBytesMappedPerIteration / - (kSparseCommittedPages * kSbMemoryPageSize)), - size_t(1u)); - - for (uint8_t* page = first_page; - page < first_page + kBytesMappedPerIteration; - page += kSbMemoryPageSize * page_increment_factor) { - *page = 0x55; - } - - EXPECT_TRUE(SbMemoryUnmap(memory, kBytesMappedPerIteration)); - } -} - -TEST(SbMemoryMapTest, CanReadWriteToResult) { - void* memory = SbMemoryMap(kSize, kSbMemoryMapProtectReadWrite, "test"); - ASSERT_NE(kFailed, memory); - char* data = static_cast(memory); - for (int i = 0; i < kSize; ++i) { - data[i] = static_cast(i); - } - - for (int i = 0; i < kSize; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - - EXPECT_TRUE(SbMemoryUnmap(memory, kSize)); -} - -#if SB_CAN(MAP_EXECUTABLE_MEMORY) - -typedef int (*SumFunction)(int, int); -static int Sum(int x, int y) { - return x + y; -} -static int Sum2(int x, int y) { - return x + y + x; -} - -// Copy the contents of |Sum| into |memory|, returning an assertion result -// indicating whether the copy was successful, a function pointer to the -// possibly copied |Sum| function data and a function pointer to the selected -// original function.. Clients are expected to immediately call |ASSERT| on -// the assertion result. -std::tuple<::testing::AssertionResult, SumFunction, SumFunction> -CopySumFunctionIntoMemory(void* memory) { - // There's no reliable way to determine the size of the 'Sum' function. If we - // assume the function is at most a certain size, then we might try to read - // beyond mapped memory when copying it to the destination address. We can - // get a reasonable upper bound by assuming that the function's implementation - // does not cross a page boundary, and copy the memory from the beginning of - // the function to the end of the page that it is mapped to. - // - // However, since it's possible the function may cross the page boundary, we - // define two functions and use the one closest to the start of a page. There - // is no guarantee that the linker will place these definitions sequentially - // (although it likely will), so we can't use the address of 'Sum2' as the - // end of 'Sum'. - // - // To avoid the possibility that COMDAT folding will combine these two - // definitions into one, make sure they are different. - - // A function pointer can't be cast to void*, but uint8* seems to be okay. So - // cast to a uint* which will be implicitly casted to a void* below. - SumFunction original_function = ∑ - if (reinterpret_cast(&Sum2) % kSbMemoryPageSize < - reinterpret_cast(&Sum) % kSbMemoryPageSize) { - original_function = &Sum2; - } - - uint8_t* sum_function_start = reinterpret_cast(original_function); - - // MIPS16 instruction are kept odd addresses to differentiate between that and - // MIPS32 instructions. Most other instructions are aligned to at least even - // addresses, so this code should do nothing for those architectures. - // https://www.linux-mips.org/wiki/MIPS16 - ptrdiff_t sum_function_offset = - sum_function_start - - reinterpret_cast( - reinterpret_cast(sum_function_start) & ~0x1); - sum_function_start -= sum_function_offset; - - // Get the last address of the page that |sum_function_start| is on. - uint8_t* sum_function_page_end = reinterpret_cast( - (reinterpret_cast(sum_function_start) / kSbMemoryPageSize) * - kSbMemoryPageSize + - kSbMemoryPageSize); - if (!starboard::common::MemoryIsAligned(sum_function_page_end, - kSbMemoryPageSize)) { - return std::make_tuple(::testing::AssertionFailure() - << "Expected |Sum| page end (" - << static_cast(sum_function_page_end) - << ") to be aligned to " << kSbMemoryPageSize, - nullptr, nullptr); - } - if (sum_function_start >= sum_function_page_end) { - return std::make_tuple(::testing::AssertionFailure() - << "Expected |Sum| function page start (" - << static_cast(sum_function_start) - << ") to be less than |Sum| function page end (" - << static_cast(sum_function_page_end) - << ")", - nullptr, nullptr); - } - - size_t bytes_to_copy = sum_function_page_end - sum_function_start; - if (bytes_to_copy > kSbMemoryPageSize) { - return std::make_tuple( - ::testing::AssertionFailure() - << "Expected bytes required to copy |Sum| to be less than " - << kSbMemoryPageSize << ", Actual: " << bytes_to_copy, - nullptr, nullptr); - } - - memcpy(memory, sum_function_start, bytes_to_copy); - SbMemoryFlush(memory, bytes_to_copy); - - SumFunction mapped_function = reinterpret_cast( - reinterpret_cast(memory) + sum_function_offset); - - return std::make_tuple(::testing::AssertionSuccess(), mapped_function, - original_function); -} - -// Cobalt can not map executable memory. If executable memory is needed, map -// non-executable memory first and use SbMemoryProtect to change memory access -// to executable. -TEST(SbMemoryMapTest, CanNotDirectlyMapMemoryWithExecFlag) { - SbMemoryMapFlags exec_flags[] = { - SbMemoryMapFlags(kSbMemoryMapProtectExec), - SbMemoryMapFlags(kSbMemoryMapProtectRead | kSbMemoryMapProtectExec), - SbMemoryMapFlags(kSbMemoryMapProtectWrite | kSbMemoryMapProtectExec), - SbMemoryMapFlags(kSbMemoryMapProtectRead | kSbMemoryMapProtectWrite | - kSbMemoryMapProtectExec), - }; - for (auto exec_flag : exec_flags) { - void* memory = SbMemoryMap(kSize, exec_flag, "test"); - ASSERT_EQ(kFailed, memory); - EXPECT_FALSE(SbMemoryUnmap(memory, 0)); - } -} -#endif // SB_CAN(MAP_EXECUTABLE_MEMORY) - -TEST(SbMemoryMapTest, CanChangeMemoryProtection) { - SbMemoryMapFlags all_from_flags[] = { - SbMemoryMapFlags(kSbMemoryMapProtectReserved), - SbMemoryMapFlags(kSbMemoryMapProtectRead), - SbMemoryMapFlags(kSbMemoryMapProtectWrite), - SbMemoryMapFlags(kSbMemoryMapProtectRead | kSbMemoryMapProtectWrite), - }; - SbMemoryMapFlags all_to_flags[] = { - SbMemoryMapFlags(kSbMemoryMapProtectReserved), - SbMemoryMapFlags(kSbMemoryMapProtectRead), - SbMemoryMapFlags(kSbMemoryMapProtectWrite), - SbMemoryMapFlags(kSbMemoryMapProtectRead | kSbMemoryMapProtectWrite), -#if SB_CAN(MAP_EXECUTABLE_MEMORY) - SbMemoryMapFlags(kSbMemoryMapProtectExec), - SbMemoryMapFlags(kSbMemoryMapProtectRead | kSbMemoryMapProtectExec), -#endif - }; - - for (SbMemoryMapFlags from_flags : all_from_flags) { - for (SbMemoryMapFlags to_flags : all_to_flags) { - void* memory = SbMemoryMap(kSize, from_flags, "test"); - // If the platform does not support a particular protection flags - // configuration in the first place, then just give them a pass, knowing - // that that feature will be tested elsewhere. - if (memory == SB_MEMORY_MAP_FAILED) { - continue; - } - -#if SB_CAN(MAP_EXECUTABLE_MEMORY) - // We can only test the ability to execute memory after changing - // protections if we have write permissions either now or then, because - // we have to actually put a valid function into the mapped memory. - SumFunction mapped_function = nullptr; - SumFunction original_function = nullptr; - if (from_flags & kSbMemoryMapProtectWrite) { - auto copy_sum_function_result = CopySumFunctionIntoMemory(memory); - ASSERT_TRUE(std::get<0>(copy_sum_function_result)); - mapped_function = std::get<1>(copy_sum_function_result); - original_function = std::get<2>(copy_sum_function_result); - } -#endif - - if (!SbMemoryProtect(memory, kSize, to_flags)) { - EXPECT_TRUE(SbMemoryUnmap(memory, kSize)); - continue; - } - -#if SB_CAN(MAP_EXECUTABLE_MEMORY) - if ((to_flags & kSbMemoryMapProtectExec) && mapped_function != nullptr) { - EXPECT_EQ(original_function(0xc0ba178, 0xbadf00d), - mapped_function(0xc0ba178, 0xbadf00d)); - } -#endif - - if (to_flags & kSbMemoryMapProtectRead) { - for (int i = 0; i < kSize; i++) { - volatile uint8_t force_read = static_cast(memory)[i]; - } - } - if (to_flags & kSbMemoryMapProtectWrite) { - for (int i = 0; i < kSize; i++) { - static_cast(memory)[i] = 0xff; - } - } - - EXPECT_TRUE(SbMemoryUnmap(memory, kSize)); - } - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/memory_reallocate_test.cc b/starboard/nplb/memory_reallocate_test.cc deleted file mode 100644 index 04e91b42f317..000000000000 --- a/starboard/nplb/memory_reallocate_test.cc +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const size_t kSize = 1024 * 128; - -TEST(SbMemoryReallocateTest, AllocatesNormally) { - void* memory = SbMemoryReallocate(NULL, kSize); - EXPECT_NE(static_cast(NULL), memory); - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryReallocateTest, AllocatesZero) { - void* memory = SbMemoryReallocate(NULL, 0); - // We can't expect anything here because some implementations may return an - // allocated zero-size memory block, and some implementations may return NULL. - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryReallocateTest, AllocatesOne) { - void* memory = SbMemoryReallocate(NULL, 1); - EXPECT_NE(static_cast(NULL), memory); - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryReallocateTest, CanReadWriteToResult) { - void* memory = SbMemoryReallocate(NULL, kSize); - ASSERT_NE(static_cast(NULL), memory); - char* data = static_cast(memory); - for (int i = 0; i < kSize; ++i) { - data[i] = i; - } - - for (int i = 0; i < kSize; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryReallocateTest, ReallocatesSmaller) { - void* memory = SbMemoryAllocate(kSize); - ASSERT_NE(static_cast(NULL), memory); - char* data = static_cast(memory); - for (int i = 0; i < kSize; ++i) { - data[i] = i; - } - - for (int i = 0; i < kSize; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - - memory = SbMemoryReallocate(memory, kSize / 2); - data = static_cast(memory); - ASSERT_NE(static_cast(NULL), memory); - for (int i = 0; i < kSize / 2; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryReallocateTest, ReallocatesBigger) { - void* memory = SbMemoryAllocate(kSize); - ASSERT_NE(static_cast(NULL), memory); - char* data = static_cast(memory); - for (int i = 0; i < kSize; ++i) { - data[i] = i; - } - - for (int i = 0; i < kSize; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - - memory = SbMemoryReallocate(memory, kSize * 2); - - ASSERT_NE(static_cast(NULL), memory); - data = static_cast(memory); - for (int i = 0; i < kSize; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - - for (int i = kSize; i < kSize * 2; ++i) { - data[i] = i; - } - - for (int i = kSize; i < kSize * 2; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - - SbMemoryDeallocate(memory); -} - -// Tests unspecified behavior, currently not stable. -// Should be deleted or fixed. -TEST(SbMemoryReallocateTest, DISABLED_ReallocatestoZero) { - void* memory = SbMemoryAllocate(kSize); - - ASSERT_NE(static_cast(NULL), memory); - memory = SbMemoryReallocate(memory, 0); - - // See allocates zero above. - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryReallocateTest, ReallocatestoSameSize) { - void* memory = SbMemoryAllocate(kSize); - ASSERT_NE(static_cast(NULL), memory); - char* data = static_cast(memory); - for (int i = 0; i < kSize; ++i) { - data[i] = i; - } - - for (int i = 0; i < kSize; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - - memory = SbMemoryReallocate(memory, kSize); - - data = static_cast(memory); - ASSERT_NE(static_cast(NULL), memory); - for (int i = 0; i < kSize; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - - SbMemoryDeallocate(memory); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/mutex_acquire_test.cc b/starboard/nplb/mutex_acquire_test.cc deleted file mode 100644 index e2556bf430e2..000000000000 --- a/starboard/nplb/mutex_acquire_test.cc +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/mutex.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -struct TestContext { - TestContext() : count(0) {} - SbMutex mutex; - int count; -}; - -const int kLoops = 10000; - -void* EntryPoint(void* parameter) { - TestContext* context = static_cast(parameter); - - for (int i = 0; i < kLoops; ++i) { - SbMutexAcquire(&context->mutex); - int k = context->count; - k = k + 1; - context->count = k; - SbMutexRelease(&context->mutex); - } - - return NULL; -} - -// This test just tries to acquire a mutex repeatedly while other threads are -// doing the same. -TEST(SbMutexAcquireTest, SunnyDayContended) { - TestContext context; - EXPECT_TRUE(SbMutexCreate(&context.mutex)); - const int kThreads = 4; - SbThread threads[kThreads]; - for (int i = 0; i < kThreads; ++i) { - threads[i] = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - true, NULL, EntryPoint, &context); - } - - for (int i = 0; i < kLoops; ++i) { - for (int j = 0; j < kThreads; ++j) { - EXPECT_TRUE(SbMutexIsSuccess(SbMutexAcquire(&context.mutex))); - int k = context.count; - k = k - 1; - context.count = k; - EXPECT_TRUE(SbMutexRelease(&context.mutex)); - } - } - - // Join other threads and clean up. - for (int i = 0; i < kThreads; ++i) { - EXPECT_TRUE(SbThreadJoin(threads[i], NULL)); - } - EXPECT_TRUE(SbMutexDestroy(&context.mutex)); - EXPECT_EQ(0, context.count); -} - -TEST(SbMutexAcquireTest, SunnyDayUncontended) { - SbMutex mutex; - EXPECT_TRUE(SbMutexCreate(&mutex)); - - SbMutexResult result = SbMutexAcquire(&mutex); - EXPECT_EQ(kSbMutexAcquired, result); - EXPECT_TRUE(SbMutexIsSuccess(result)); - EXPECT_TRUE(SbMutexRelease(&mutex)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -TEST(SbMutexAcquireTest, SunnyDayStaticallyInitialized) { - SbMutex mutex = SB_MUTEX_INITIALIZER; - EXPECT_TRUE(SbMutexIsSuccess(SbMutexAcquire(&mutex))); - EXPECT_TRUE(SbMutexRelease(&mutex)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -TEST(SbMutexAcquireTest, RainyDayAcquireNull) { - SbMutexResult result = SbMutexAcquire(NULL); - EXPECT_EQ(kSbMutexDestroyed, result); -} - -TEST(SbMutexAcquireTest, RainyDayReleaseNull) { - EXPECT_FALSE(SbMutexRelease(NULL)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/mutex_acquire_try_test.cc b/starboard/nplb/mutex_acquire_try_test.cc deleted file mode 100644 index c393478c1525..000000000000 --- a/starboard/nplb/mutex_acquire_try_test.cc +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/mutex.h" -#include "testing/gtest/include/gtest/gtest.h" - -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" - -namespace starboard { -namespace nplb { -namespace { - -struct TestContext { - explicit TestContext(SbMutex* mutex) : was_locked_(false), mutex_(mutex) {} - bool was_locked_; - SbMutex* mutex_; -}; - -void* EntryPoint(void* parameter) { - TestContext* context = static_cast(parameter); - context->was_locked_ = - (SbMutexAcquireTry(context->mutex_) == kSbMutexAcquired); - return NULL; -} - -TEST(SbMutexAcquireTryTest, SunnyDayUncontended) { - SbMutex mutex; - EXPECT_TRUE(SbMutexCreate(&mutex)); - - SbMutexResult result = SbMutexAcquireTry(&mutex); - EXPECT_EQ(result, kSbMutexAcquired); - EXPECT_TRUE(SbMutexIsSuccess(result)); - EXPECT_TRUE(SbMutexRelease(&mutex)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -TEST(SbMutexAcquireTest, SunnyDayAutoInit) { - SbMutex mutex = SB_MUTEX_INITIALIZER; - SbMutexResult result = SbMutexAcquireTry(&mutex); - EXPECT_TRUE(SbMutexRelease(&mutex)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -TEST(SbMutexAcquireTryTest, RainyDayReentrant) { - SbMutex mutex; - EXPECT_TRUE(SbMutexCreate(&mutex)); - - SbMutexResult result = SbMutexAcquireTry(&mutex); - EXPECT_EQ(result, kSbMutexAcquired); - EXPECT_TRUE(SbMutexIsSuccess(result)); - - TestContext context(&mutex); - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, - nplb::kThreadName, &EntryPoint, &context); - - EXPECT_TRUE(SbThreadIsValid(thread)); - EXPECT_TRUE(SbThreadJoin(thread, NULL)); - EXPECT_FALSE(context.was_locked_); - EXPECT_TRUE(SbMutexRelease(&mutex)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -TEST(SbMutexAcquireTest, RainyDayAcquireTryNull) { - SbMutexResult result = SbMutexAcquireTry(NULL); - EXPECT_EQ(kSbMutexDestroyed, result); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/mutex_create_test.cc b/starboard/nplb/mutex_create_test.cc deleted file mode 100644 index a1673ceeec17..000000000000 --- a/starboard/nplb/mutex_create_test.cc +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/mutex.h" -#include "testing/gtest/include/gtest/gtest.h" - -#include "starboard/common/once.h" -#include "starboard/condition_variable.h" - -namespace starboard { -namespace nplb { -namespace { - -const int kALot = 128 * 1024; -const int kABunch = 2 * 1024; - -TEST(SbMutexCreateTest, SunnyDay) { - SbMutex mutex; - EXPECT_TRUE(SbMutexCreate(&mutex)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -TEST(SbMutexCreateTest, SunnyDayAutoInit) { - SbMutex mutex = SB_MUTEX_INITIALIZER; - EXPECT_TRUE(SbMutexCreate(&mutex)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -TEST(SbMutexCreateTest, SunnyDayALot) { - for (int i = 0; i < kALot; ++i) { - SbMutex mutex; - EXPECT_TRUE(SbMutexCreate(&mutex)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); - } -} - -TEST(SbMutexCreateTest, SunnyDayABunchAtOnce) { - SbMutex mutexes[kABunch]; - for (int i = 0; i < kABunch; ++i) { - EXPECT_TRUE(SbMutexCreate(&mutexes[i])); - } - - for (int i = 0; i < kABunch; ++i) { - EXPECT_TRUE(SbMutexDestroy(&mutexes[i])); - } -} - -TEST(SbMutexCreateTest, RainyDayNull) { - EXPECT_FALSE(SbMutexCreate(NULL)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/mutex_destroy_test.cc b/starboard/nplb/mutex_destroy_test.cc deleted file mode 100644 index 6c813388a1b2..000000000000 --- a/starboard/nplb/mutex_destroy_test.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Destroy is mostly Sunny Day tested in Create. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/mutex.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbMutexDestroyTest, SunnyDayAutoInit) { - SbMutex mutex = SB_MUTEX_INITIALIZER; - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -// Destroying a mutex that has already been destroyed is undefined behavior -// and cannot be tested. -TEST(SbMutexDestroyTest, RainyDayNull) { - EXPECT_FALSE(SbMutexDestroy(NULL)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/nplb_evergreen_compat_tests/sabi_test.cc b/starboard/nplb/nplb_evergreen_compat_tests/sabi_test.cc index 51328d9a0005..b44c35347df6 100644 --- a/starboard/nplb/nplb_evergreen_compat_tests/sabi_test.cc +++ b/starboard/nplb/nplb_evergreen_compat_tests/sabi_test.cc @@ -28,115 +28,6 @@ namespace nplb_evergreen_compat_tests { namespace { -#if SB_API_VERSION == 15 -const char* kSabiJsonIdArmHardfp = - "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," - "\"alignment_int\":4,\"alignment_llong\":8,\"alignment_long\":4," - "\"alignment_pointer\":4,\"alignment_short\":2,\"calling_convention\":" - "\"eabi\",\"endianness\":\"little\",\"floating_point_abi\":\"hard\"," - "\"floating_point_fpu\":\"vfpv3\",\"sb_api_version\":15,\"signedness_of_" - "char\":\"signed\",\"signedness_of_enum\":\"signed\",\"size_of_char\":1," - "\"size_of_double\":8,\"size_of_enum\":4,\"size_of_float\":4,\"size_of_" - "int\":4,\"size_of_llong\":8,\"size_of_long\":4,\"size_of_pointer\":4," - "\"size_of_short\":2,\"target_arch\":\"arm\",\"target_arch_sub\":\"v7a\"," - "\"word_size\":32}"; - -const char* kSabiJsonIdArmSoftfp = - "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," - "\"alignment_int\":4,\"alignment_llong\":8,\"alignment_long\":4," - "\"alignment_pointer\":4,\"alignment_short\":2,\"calling_convention\":" - "\"eabi\",\"endianness\":\"little\",\"floating_point_abi\":\"softfp\"," - "\"floating_point_fpu\":\"vfpv3\",\"sb_api_version\":15,\"signedness_of_" - "char\":\"signed\",\"signedness_of_enum\":\"signed\",\"size_of_char\":1," - "\"size_of_double\":8,\"size_of_enum\":4,\"size_of_float\":4,\"size_of_" - "int\":4,\"size_of_llong\":8,\"size_of_long\":4,\"size_of_pointer\":4," - "\"size_of_short\":2,\"target_arch\":\"arm\",\"target_arch_sub\":\"v7a\"," - "\"word_size\":32}"; - -const char* kSabiJsonIdArm64 = - "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," - "\"alignment_int\":4,\"alignment_llong\":8,\"alignment_long\":8," - "\"alignment_pointer\":8,\"alignment_short\":2,\"calling_convention\":" - "\"aarch64\",\"endianness\":\"little\",\"floating_point_abi\":\"\"," - "\"floating_point_fpu\":\"\",\"sb_api_version\":15,\"signedness_of_char\":" - "\"signed\",\"signedness_of_enum\":\"signed\",\"size_of_char\":1,\"size_of_" - "double\":8,\"size_of_enum\":4,\"size_of_float\":4,\"size_of_int\":4," - "\"size_of_llong\":8,\"size_of_long\":8,\"size_of_pointer\":8,\"size_of_" - "short\":2,\"target_arch\":\"arm64\",\"target_arch_sub\":\"v8a\",\"word_" - "size\":64}"; - -const char* kSabiJsonIdX86 = - "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," - "\"alignment_int\":4,\"alignment_llong\":8,\"alignment_long\":4," - "\"alignment_pointer\":4,\"alignment_short\":2,\"calling_convention\":" - "\"sysv\",\"endianness\":\"little\",\"floating_point_abi\":\"\",\"floating_" - "point_fpu\":\"\",\"sb_api_version\":15,\"signedness_of_char\":\"signed\"," - "\"signedness_of_enum\":\"signed\",\"size_of_char\":1,\"size_of_double\":8," - "\"size_of_enum\":4,\"size_of_float\":4,\"size_of_int\":4,\"size_of_" - "llong\":8,\"size_of_long\":4,\"size_of_pointer\":4,\"size_of_short\":2," - "\"target_arch\":\"x86\",\"target_arch_sub\":\"\",\"word_size\":32}"; - -const char* kSabiJsonIdX64Sysv = - "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," - "\"alignment_int\":4,\"alignment_llong\":8,\"alignment_long\":8," - "\"alignment_pointer\":8,\"alignment_short\":2,\"calling_convention\":" - "\"sysv\",\"endianness\":\"little\",\"floating_point_abi\":\"\",\"floating_" - "point_fpu\":\"\",\"sb_api_version\":15,\"signedness_of_char\":\"signed\"," - "\"signedness_of_enum\":\"signed\",\"size_of_char\":1,\"size_of_double\":8," - "\"size_of_enum\":4,\"size_of_float\":4,\"size_of_int\":4,\"size_of_" - "llong\":8,\"size_of_long\":8,\"size_of_pointer\":8,\"size_of_short\":2," - "\"target_arch\":\"x64\",\"target_arch_sub\":\"\",\"word_size\":64}"; -#endif // SB_API_VERSION == 15 - -#if SB_API_VERSION == 16 -const char* kSabiJsonIdArmHardfp = - "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," - "\"alignment_int\":4,\"alignment_llong\":8,\"alignment_long\":4," - "\"alignment_pointer\":4,\"alignment_short\":2,\"calling_convention\":" - "\"eabi\",\"endianness\":\"little\",\"floating_point_abi\":\"hard\"," - "\"floating_point_fpu\":\"vfpv3\",\"sb_api_version\":16,\"signedness_of_" - "char\":\"signed\",\"signedness_of_enum\":\"signed\",\"size_of_char\":1," - "\"size_of_double\":8,\"size_of_enum\":4,\"size_of_float\":4,\"size_of_" - "int\":4,\"size_of_llong\":8,\"size_of_long\":4,\"size_of_pointer\":4," - "\"size_of_short\":2,\"target_arch\":\"arm\",\"target_arch_sub\":\"v7a\"," - "\"word_size\":32}"; - -const char* kSabiJsonIdArmSoftfp = - "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," - "\"alignment_int\":4,\"alignment_llong\":8,\"alignment_long\":4," - "\"alignment_pointer\":4,\"alignment_short\":2,\"calling_convention\":" - "\"eabi\",\"endianness\":\"little\",\"floating_point_abi\":\"softfp\"," - "\"floating_point_fpu\":\"vfpv3\",\"sb_api_version\":16,\"signedness_of_" - "char\":\"signed\",\"signedness_of_enum\":\"signed\",\"size_of_char\":1," - "\"size_of_double\":8,\"size_of_enum\":4,\"size_of_float\":4,\"size_of_" - "int\":4,\"size_of_llong\":8,\"size_of_long\":4,\"size_of_pointer\":4," - "\"size_of_short\":2,\"target_arch\":\"arm\",\"target_arch_sub\":\"v7a\"," - "\"word_size\":32}"; - -const char* kSabiJsonIdArm64 = - "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," - "\"alignment_int\":4,\"alignment_llong\":8,\"alignment_long\":8," - "\"alignment_pointer\":8,\"alignment_short\":2,\"calling_convention\":" - "\"aarch64\",\"endianness\":\"little\",\"floating_point_abi\":\"\"," - "\"floating_point_fpu\":\"\",\"sb_api_version\":16,\"signedness_of_char\":" - "\"signed\",\"signedness_of_enum\":\"signed\",\"size_of_char\":1,\"size_of_" - "double\":8,\"size_of_enum\":4,\"size_of_float\":4,\"size_of_int\":4," - "\"size_of_llong\":8,\"size_of_long\":8,\"size_of_pointer\":8,\"size_of_" - "short\":2,\"target_arch\":\"arm64\",\"target_arch_sub\":\"v8a\",\"word_" - "size\":64}"; - -const char* kSabiJsonIdX64Sysv = - "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," - "\"alignment_int\":4,\"alignment_llong\":8,\"alignment_long\":8," - "\"alignment_pointer\":8,\"alignment_short\":2,\"calling_convention\":" - "\"sysv\",\"endianness\":\"little\",\"floating_point_abi\":\"\",\"floating_" - "point_fpu\":\"\",\"sb_api_version\":16,\"signedness_of_char\":\"signed\"," - "\"signedness_of_enum\":\"signed\",\"size_of_char\":1,\"size_of_double\":8," - "\"size_of_enum\":4,\"size_of_float\":4,\"size_of_int\":4,\"size_of_" - "llong\":8,\"size_of_long\":8,\"size_of_pointer\":8,\"size_of_short\":2," - "\"target_arch\":\"x64\",\"target_arch_sub\":\"\",\"word_size\":64}"; -#endif // SB_API_VERSION == 16 - #if SB_API_VERSION == 17 const char* kSabiJsonIdArmHardfp = "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," @@ -203,9 +94,6 @@ TEST_F(SabiTest, VerifySABI) { sabi_set.insert(kSabiJsonIdArmHardfp); sabi_set.insert(kSabiJsonIdArmSoftfp); sabi_set.insert(kSabiJsonIdArm64); -#if SB_API_VERSION < 16 - sabi_set.insert(kSabiJsonIdX86); -#endif sabi_set.insert(kSabiJsonIdX64Sysv); ASSERT_NE(sabi_set.find(SB_SABI_JSON_ID), sabi_set.end()) @@ -219,9 +107,6 @@ TEST_F(SabiTest, VerifySABI) { << std::endl << " starboard/sabi/arm64/sabi-v" << SB_API_VERSION << ".json" << std::endl -#if SB_API_VERSION < 16 - << " starboard/sabi/x86/sabi-v" << SB_API_VERSION << ".json" << std::endl -#endif << " starboard/sabi/x64/sysv/sabi-v" << SB_API_VERSION << ".json" << std::endl; } diff --git a/starboard/nplb/once_test.cc b/starboard/nplb/once_test.cc deleted file mode 100644 index dcecfbba6b6a..000000000000 --- a/starboard/nplb/once_test.cc +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Broadcast is Sunny Day tested in most of the other SbConditionVariable tests. - -#if SB_API_VERSION < 16 - -#include - -#include "starboard/configuration_constants.h" -#include "starboard/nplb/thread_helpers.h" -#include "starboard/once.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -int s_global_value; - -void IncrementGlobalValue() { - ++s_global_value; -} - -TEST(SbOnceTest, SunnyDaySingleInit) { - SbOnceControl once_control = SB_ONCE_INITIALIZER; - - s_global_value = 0; - EXPECT_TRUE(SbOnce(&once_control, &IncrementGlobalValue)); - - EXPECT_EQ(1, s_global_value); -} - -TEST(SbOnceTest, SunnyDayMultipleInit) { - SbOnceControl once_control = SB_ONCE_INITIALIZER; - - s_global_value = 0; - EXPECT_TRUE(SbOnce(&once_control, &IncrementGlobalValue)); - EXPECT_EQ(1, s_global_value); - - s_global_value = 0; - EXPECT_TRUE(SbOnce(&once_control, &IncrementGlobalValue)); - EXPECT_EQ(0, s_global_value); - - s_global_value = 0; - EXPECT_TRUE(SbOnce(&once_control, &IncrementGlobalValue)); - EXPECT_EQ(0, s_global_value); -} - -struct RunSbOnceContext { - RunSbOnceContext() : once_control(SB_ONCE_INITIALIZER) { - SbMutexCreate(&mutex); - SbConditionVariableCreate(&condition, &mutex); - } - ~RunSbOnceContext() { - SbConditionVariableDestroy(&condition); - SbMutexDestroy(&mutex); - } - - Semaphore semaphore; - SbMutex mutex; - SbConditionVariable condition; - - SbOnceControl once_control; -}; - -void* RunSbOnceEntryPoint(void* context) { - RunSbOnceContext* run_sbonce_context = - reinterpret_cast(context); - - { - SbMutexAcquire(&run_sbonce_context->mutex); - run_sbonce_context->semaphore.Put(); - SbConditionVariableWait(&run_sbonce_context->condition, - &run_sbonce_context->mutex); - SbMutexRelease(&run_sbonce_context->mutex); - } - - sched_yield(); - static const int kIterationCount = 3; - for (int i = 0; i < kIterationCount; ++i) { - SbOnce(&run_sbonce_context->once_control, &IncrementGlobalValue); - } - - return NULL; -} - -// Here we spawn many threads each of which will call SbOnce multiple times -// using a shared SbOnceControl object. We then test that the initialization -// routine got called exactly one time. -TEST(SbOnceTest, SunnyDayMultipleThreadsInit) { - const int kMany = kSbMaxThreads; - std::vector threads(kMany); - - const int kIterationCount = 10; - for (int i = 0; i < kIterationCount; ++i) { - SbOnceControl once_control = SB_ONCE_INITIALIZER; - RunSbOnceContext context; - - s_global_value = 0; - for (int j = 0; j < kMany; ++j) { - threads[j] = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, - kThreadName, RunSbOnceEntryPoint, &context); - } - - // Wait for all threads to finish initializing and become ready, then - // broadcast the signal to begin. We do this to increase the chances that - // threads will call SbOnce() at the same time as each other. - for (int j = 0; j < kMany; ++j) { - context.semaphore.Take(); - } - { - SbMutexAcquire(&context.mutex); - SbConditionVariableBroadcast(&context.condition); - SbMutexRelease(&context.mutex); - } - - // Signal threads to beginWait for all threads to complete. - for (int i = 0; i < kMany; ++i) { - void* result; - SbThreadJoin(threads[i], &result); - } - - EXPECT_EQ(1, s_global_value); - } -} - -TEST(SbOnceTest, RainyDayBadOnceControl) { - s_global_value = 0; - EXPECT_FALSE(SbOnce(NULL, &IncrementGlobalValue)); - - EXPECT_EQ(0, s_global_value); -} - -TEST(SbOnceTest, RainyDayBadInitRoutine) { - SbOnceControl once_control = SB_ONCE_INITIALIZER; - - s_global_value = 0; - EXPECT_FALSE(SbOnce(&once_control, NULL)); - - EXPECT_EQ(0, s_global_value); -} - -SB_ONCE_INITIALIZE_FUNCTION(int, GetIntSingleton); -TEST(SbOnceTest, InitializeOnceMacroFunction) { - int* int_singelton = GetIntSingleton(); - ASSERT_TRUE(int_singelton); - EXPECT_EQ(0, *int_singelton) - << "Singleton Macro does not default initialize."; -} - -} // namespace. -} // namespace nplb. -} // namespace starboard. - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/posix_compliance/posix_memory_map_test.cc b/starboard/nplb/posix_compliance/posix_memory_map_test.cc index 147bf8f44109..cbd2566676eb 100644 --- a/starboard/nplb/posix_compliance/posix_memory_map_test.cc +++ b/starboard/nplb/posix_compliance/posix_memory_map_test.cc @@ -183,13 +183,6 @@ TEST(PosixMemoryMapTest, CanChangeMemoryProtection) { continue; } -#if SB_API_VERSION < 16 -#if SB_CAN(MAP_EXECUTABLE_MEMORY) - const bool kSbCanMapExecutableMemory = true; -#else - const bool kSbCanMapExecutableMemory = false; -#endif -#endif SumFunction mapped_function = nullptr; SumFunction original_function = nullptr; if (kSbCanMapExecutableMemory) { diff --git a/starboard/nplb/storage_helpers.h b/starboard/nplb/storage_helpers.h index 3e030d9ae4c4..48df4ea4ae6d 100644 --- a/starboard/nplb/storage_helpers.h +++ b/starboard/nplb/storage_helpers.h @@ -28,40 +28,24 @@ const int64_t kStorageSize2 = kStorageSize * 2 + kStorageOffset; // Deletes the storage. static inline void ClearStorageRecord() { -#if SB_API_VERSION < 16 - SbStorageDeleteRecord(SbUserGetCurrent(), NULL); -#else SbStorageDeleteRecord(NULL); -#endif } // Deletes the named storage record. static inline void ClearStorageRecord(const char* name) { -#if SB_API_VERSION < 16 - SbStorageDeleteRecord(SbUserGetCurrent(), name); -#else SbStorageDeleteRecord(name); -#endif } // Opens the storage record, validating that it is valid. static inline SbStorageRecord OpenStorageRecord() { -#if SB_API_VERSION < 16 - SbStorageRecord record = SbStorageOpenRecord(SbUserGetCurrent(), NULL); -#else SbStorageRecord record = SbStorageOpenRecord(NULL); -#endif EXPECT_TRUE(SbStorageIsValidRecord(record)); return record; } // Opens the named storage record, validating that it is valid. static inline SbStorageRecord OpenStorageRecord(const char* name) { -#if SB_API_VERSION < 16 - SbStorageRecord record = SbStorageOpenRecord(SbUserGetCurrent(), name); -#else SbStorageRecord record = SbStorageOpenRecord(name); -#endif EXPECT_TRUE(SbStorageIsValidRecord(record)); return record; } diff --git a/starboard/nplb/string_compare_no_case_n_test.cc b/starboard/nplb/string_compare_no_case_n_test.cc deleted file mode 100644 index 5cd234978c80..000000000000 --- a/starboard/nplb/string_compare_no_case_n_test.cc +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -#if SB_API_VERSION < 16 -TEST(SbStringCompareNoCaseNTest, SunnyDaySelf) { - const char kString[] = "0123456789"; - EXPECT_EQ(0, SbStringCompareNoCaseN(kString, kString, strlen(kString))); - EXPECT_EQ(0, SbStringCompareNoCaseN("", "", 0)); -} - -TEST(SbStringCompareNoCaseNTest, SunnyDayEmptyLessThanNotEmpty) { - const char kString[] = "0123456789"; - EXPECT_GT(0, SbStringCompareNoCaseN("", kString, strlen(kString))); -} - -TEST(SbStringCompareNoCaseNTest, SunnyDayEmptyZeroNEqual) { - const char kString[] = "0123456789"; - EXPECT_EQ(0, SbStringCompareNoCaseN("", kString, 0)); -} - -TEST(SbStringCompareNoCaseNTest, SunnyDayBigN) { - const char kString[] = "0123456789"; - EXPECT_EQ(0, SbStringCompareNoCaseN(kString, kString, strlen(kString) * 2)); -} - -TEST(SbStringCompareNoCaseNTest, SunnyDayCase) { - const char kString1[] = "aBcDeFgHiJkLmNoPqRsTuVwXyZ"; - const char kString2[] = "AbCdEfGhIjKlMnOpQrStUvWxYz"; - EXPECT_EQ(0, SbStringCompareNoCaseN(kString1, kString2, strlen(kString1))); - EXPECT_EQ(0, SbStringCompareNoCaseN(kString2, kString1, strlen(kString2))); - - const char kString3[] = "aBcDeFgHiJkLmaBcDeFgHiJkLm"; - const char kString4[] = "AbCdEfGhIjKlMnOpQrStUvWxYz"; - EXPECT_GT(0, SbStringCompareNoCaseN(kString3, kString4, strlen(kString3))); - EXPECT_LT(0, SbStringCompareNoCaseN(kString4, kString3, strlen(kString4))); - EXPECT_EQ(0, - SbStringCompareNoCaseN(kString3, kString4, strlen(kString3) / 2)); - EXPECT_EQ(0, - SbStringCompareNoCaseN(kString4, kString3, strlen(kString4) / 2)); -} -#endif // SB_API_VERSION < 16 - -} // namespace -} // namespace nplb -} // namespace starboard diff --git a/starboard/nplb/string_compare_no_case_test.cc b/starboard/nplb/string_compare_no_case_test.cc deleted file mode 100644 index 73544d0295ca..000000000000 --- a/starboard/nplb/string_compare_no_case_test.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -#if SB_API_VERSION < 16 -TEST(SbStringCompareNoCaseTest, SunnyDaySelf) { - const char kString[] = "0123456789"; - EXPECT_EQ(0, SbStringCompareNoCase(kString, kString)); - EXPECT_EQ(0, SbStringCompareNoCase("", "")); -} - -TEST(SbStringCompareNoCaseTest, SunnyDayEmptyLessThanNotEmpty) { - const char kString[] = "0123456789"; - EXPECT_GT(0, SbStringCompareNoCase("", kString)); -} - -TEST(SbStringCompareNoCaseTest, SunnyDayCase) { - const char kString1[] = "aBcDeFgHiJkLmNoPqRsTuVwXyZ"; - const char kString2[] = "AbCdEfGhIjKlMnOpQrStUvWxYz"; - EXPECT_EQ(0, SbStringCompareNoCase(kString1, kString2)); - EXPECT_EQ(0, SbStringCompareNoCase(kString2, kString1)); -} -#endif // SB_API_VERSION < 16 -} // namespace -} // namespace nplb -} // namespace starboard diff --git a/starboard/nplb/string_duplicate_test.cc b/starboard/nplb/string_duplicate_test.cc deleted file mode 100644 index 27f7fc2f48f2..000000000000 --- a/starboard/nplb/string_duplicate_test.cc +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" -#include "starboard/memory.h" -#include "testing/gtest/include/gtest/gtest.h" - -#if SB_API_VERSION < 16 -namespace starboard { -namespace nplb { -namespace { - -void RunTest(const char* input) { - char* dupe = SbStringDuplicate(input); - const char* kNull = NULL; - EXPECT_NE(kNull, dupe); - EXPECT_EQ(0, SbStringCompareNoCase(input, dupe)); - EXPECT_EQ(strlen(input), strlen(dupe)); - SbMemoryDeallocate(dupe); -} - -TEST(SbStringDuplicateTest, SunnyDay) { - RunTest("0123456789"); - RunTest("0"); -} - -TEST(SbStringDuplicateTest, SunnyDayEmpty) { - RunTest(""); -} - -} // namespace -} // namespace nplb -} // namespace starboard -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/string_format_test.cc b/starboard/nplb/string_format_test.cc deleted file mode 100644 index 465376852c68..000000000000 --- a/starboard/nplb/string_format_test.cc +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Here we are not trying to do anything fancy, just to really sanity check that -// this is hooked up to something. -#if SB_API_VERSION < 16 - -#include "starboard/common/string.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -int Format(char* out_buffer, size_t buffer_size, const char* format, ...) { - va_list arguments; - va_start(arguments, format); - int result = SbStringFormat(out_buffer, buffer_size, format, arguments); - va_end(arguments); - return result; -} - -TEST(SbStringFormatTest, SunnyDay) { - const char kExpected[] = "a1b2c3test"; - char destination[1024] = {0}; - int result = Format(destination, SB_ARRAY_SIZE(destination), "a%db%dc%d%s", 1, - 2, 3, "test"); - size_t expected_length = strlen(kExpected); - EXPECT_EQ(expected_length, result); - for (size_t i = 0; i <= expected_length; ++i) { - EXPECT_EQ(kExpected[i], destination[i]); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - // -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/string_format_wide_test.cc b/starboard/nplb/string_format_wide_test.cc deleted file mode 100644 index 9487c7e7eaee..000000000000 --- a/starboard/nplb/string_format_wide_test.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Here we are not trying to do anything fancy, just to really sanity check that -// this is hooked up to something. -#if SB_API_VERSION < 16 - -#include "starboard/common/string.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -int Format(wchar_t* out_buffer, - size_t buffer_size, - const wchar_t* format, - ...) { - va_list arguments; - va_start(arguments, format); - int result = SbStringFormatWide(out_buffer, buffer_size, format, arguments); - va_end(arguments); - return result; -} - -TEST(SbStringFormatWideTest, SunnyDay) { - const wchar_t kExpected[] = L"a1b2c3test"; - wchar_t destination[1024] = {0}; - int result = Format(destination, SB_ARRAY_SIZE(destination), L"a%db%dc%d%s", - 1, 2, 3, "test"); - size_t expected_length = wcslen(kExpected); - EXPECT_EQ(expected_length, result); - for (size_t i = 0; i <= expected_length; ++i) { - EXPECT_EQ(kExpected[i], destination[i]); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/string_scan_test.cc b/starboard/nplb/string_scan_test.cc deleted file mode 100644 index 0f6d66bc366e..000000000000 --- a/starboard/nplb/string_scan_test.cc +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Here we are not trying to do anything fancy, just to really sanity check that -// this is hooked up to something. - -#if SB_API_VERSION < 16 - -#include "starboard/common/string.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const char kIpGood[] = "192.168.1.2"; -const char kIpBad1[] = "192.1x8.1.2"; -const char kIpBad2[] = "192.1x8"; -const char kIpBad3[] = "x.1.2.3"; -const char kIpBad4[] = "192.168.1.2."; -const char kIpFormat[] = "%u.%u.%u.%u"; - -const char kFloatString[] = "3.14159"; -const char kFloatPattern[] = "%f"; -const char kDoublePattern[] = "%lf"; -const float kExpectedFloat = 3.14159f; -const double kExpectedDouble = 3.14159; - -TEST(SbStringScanTest, SunnyDayIp1) { - unsigned int in[4] = {0}; - EXPECT_EQ(4, SbStringScanF(kIpGood, kIpFormat, in, in + 1, in + 2, in + 3)); - EXPECT_EQ(192, in[0]); - EXPECT_EQ(168, in[1]); - EXPECT_EQ(1, in[2]); - EXPECT_EQ(2, in[3]); -} - -TEST(SbStringScanTest, SunnyDayIp2) { - unsigned int in[4] = {0}; - EXPECT_EQ(4, SbStringScanF(kIpBad4, kIpFormat, in, in + 1, in + 2, in + 3)); - EXPECT_EQ(192, in[0]); - EXPECT_EQ(168, in[1]); - EXPECT_EQ(1, in[2]); - EXPECT_EQ(2, in[3]); -} - -TEST(SbStringScanTest, SunnyDayFloat) { - float f = 0.0f; - EXPECT_EQ(1, SbStringScanF(kFloatString, kFloatPattern, &f)); - EXPECT_EQ(kExpectedFloat, f); - - double d = 0.0; - EXPECT_EQ(1, SbStringScanF(kFloatString, kDoublePattern, &d)); - EXPECT_EQ(kExpectedDouble, d); -} - -TEST(SbStringScanTest, RainyDayIp1) { - unsigned int in[4] = {0}; - EXPECT_EQ(2, SbStringScanF(kIpBad1, kIpFormat, in, in + 1, in + 2, in + 3)); - EXPECT_EQ(192, in[0]); - EXPECT_EQ(1, in[1]); - EXPECT_EQ(0, in[2]); - EXPECT_EQ(0, in[3]); -} - -TEST(SbStringScanTest, RainyDayIp2) { - unsigned int in[4] = {0}; - EXPECT_EQ(2, SbStringScanF(kIpBad2, kIpFormat, in, in + 1, in + 2, in + 3)); - EXPECT_EQ(192, in[0]); - EXPECT_EQ(1, in[1]); - EXPECT_EQ(0, in[2]); - EXPECT_EQ(0, in[3]); -} - -TEST(SbStringScanTest, RainyDayIp3) { - unsigned int in[4] = {0}; - EXPECT_EQ(0, SbStringScanF(kIpBad3, kIpFormat, in, in + 1, in + 2, in + 3)); - EXPECT_EQ(0, in[0]); - EXPECT_EQ(0, in[1]); - EXPECT_EQ(0, in[2]); - EXPECT_EQ(0, in[3]); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/system_get_property_test.cc b/starboard/nplb/system_get_property_test.cc index a50f0821f7a4..5d720ead560c 100644 --- a/starboard/nplb/system_get_property_test.cc +++ b/starboard/nplb/system_get_property_test.cc @@ -28,22 +28,6 @@ namespace { // Size of appropriate value buffer. const size_t kValueSize = 1024; -#if SB_API_VERSION < 15 -bool IsCEDevice(SbSystemDeviceType device_type) { - switch (device_type) { - case kSbSystemDeviceTypeBlueRayDiskPlayer: - case kSbSystemDeviceTypeGameConsole: - case kSbSystemDeviceTypeOverTheTopBox: - case kSbSystemDeviceTypeSetTopBox: - case kSbSystemDeviceTypeTV: - return true; - case kSbSystemDeviceTypeDesktopPC: - case kSbSystemDeviceTypeUnknown: - default: - return false; - } -} -#endif bool IsCEDevice(std::string device_type) { if (device_type == kSystemDeviceTypeBlueRayDiskPlayer || device_type == kSystemDeviceTypeGameConsole || @@ -97,17 +81,6 @@ TEST(SbSystemGetPropertyTest, ReturnsRequired) { BasicTest(kSbSystemPropertyFirmwareVersion, false, true, __LINE__); BasicTest(kSbSystemPropertySystemIntegratorName, false, true, __LINE__); BasicTest(kSbSystemPropertySpeechApiKey, false, true, __LINE__); -#if SB_API_VERSION < 15 - if (IsCEDevice(SbSystemGetDeviceType())) { - BasicTest(kSbSystemPropertyBrandName, true, true, __LINE__); - BasicTest(kSbSystemPropertyModelName, true, true, __LINE__); - BasicTest(kSbSystemPropertyModelYear, false, true, __LINE__); - } else { - BasicTest(kSbSystemPropertyBrandName, false, true, __LINE__); - BasicTest(kSbSystemPropertyModelName, false, true, __LINE__); - BasicTest(kSbSystemPropertyModelYear, false, true, __LINE__); - } -#else const size_t kSystemPropertyMaxLength = 1024; char value[kSystemPropertyMaxLength]; bool result; @@ -122,7 +95,6 @@ TEST(SbSystemGetPropertyTest, ReturnsRequired) { BasicTest(kSbSystemPropertyModelName, false, true, __LINE__); BasicTest(kSbSystemPropertyModelYear, false, true, __LINE__); } -#endif } TEST(SbSystemGetPropertyTest, FailsGracefullyZeroBufferLength) { diff --git a/starboard/nplb/thread_create_test.cc b/starboard/nplb/thread_create_test.cc deleted file mode 100644 index cc06902505cf..000000000000 --- a/starboard/nplb/thread_create_test.cc +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration_constants.h" -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const SbThreadPriority kAllThreadPriorities[] = { - kSbThreadPriorityLowest, kSbThreadPriorityLow, - kSbThreadPriorityNormal, kSbThreadPriorityHigh, - kSbThreadPriorityHighest, kSbThreadPriorityRealTime, - kSbThreadNoPriority, -}; - -TEST(SbThreadCreateTest, SunnyDay) { - const int kTrials = 64; - for (int i = 0; i < kTrials; ++i) { - SbThread thread = SbThreadCreate( - 0, kSbThreadNoPriority, kSbThreadNoAffinity, true, nplb::kThreadName, - nplb::AddOneEntryPoint, nplb::kSomeContext); - EXPECT_TRUE(SbThreadIsValid(thread)); - void* result = NULL; - EXPECT_TRUE(SbThreadJoin(thread, &result)); - EXPECT_EQ(nplb::kSomeContextPlusOne, result); - } -} - -TEST(SbThreadCreateTest, SunnyDayWithPriorities) { - const int kTrials = 64; - for (int i = 0; i < kTrials; ++i) { - SbThreadPriority priority; - switch (i % 7) { - case 0: - priority = kSbThreadPriorityLowest; - break; - case 1: - priority = kSbThreadPriorityLow; - break; - case 2: - priority = kSbThreadPriorityNormal; - break; - case 3: - priority = kSbThreadPriorityHigh; - break; - case 4: - priority = kSbThreadPriorityHighest; - break; - case 5: - priority = kSbThreadPriorityRealTime; - break; - case 6: - priority = kSbThreadNoPriority; - break; - } - SbThread thread = SbThreadCreate(0, priority, kSbThreadNoAffinity, true, - nplb::kThreadName, nplb::AddOneEntryPoint, - nplb::kSomeContext); - EXPECT_TRUE(SbThreadIsValid(thread)); - void* result = NULL; - EXPECT_TRUE(SbThreadJoin(thread, &result)); - EXPECT_EQ(nplb::kSomeContextPlusOne, result); - } -} - -void* CreateNestedThreadFunc(void* context) { - for (auto thread_priority : kAllThreadPriorities) { - SbThread thread = SbThreadCreate( - 0, thread_priority, kSbThreadNoAffinity, true, nplb::kThreadName, - nplb::AddOneEntryPoint, nplb::kSomeContext); - EXPECT_TRUE(SbThreadIsValid(thread)); - void* result = NULL; - EXPECT_TRUE(SbThreadJoin(thread, &result)); - EXPECT_EQ(nplb::kSomeContextPlusOne, result); - } - return NULL; -} - -TEST(SbThreadCreateTest, SunnyDayWithNestedPriorities) { - for (auto thread_priority : kAllThreadPriorities) { - SbThread thread = SbThreadCreate( - 0, thread_priority, kSbThreadNoAffinity, true, nplb::kThreadName, - CreateNestedThreadFunc, nplb::kSomeContext); - EXPECT_TRUE(SbThreadIsValid(thread)); - void* result = NULL; - EXPECT_TRUE(SbThreadJoin(thread, &result)); - } -} - -TEST(SbThreadCreateTest, SunnyDayNoName) { - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, NULL, - nplb::AddOneEntryPoint, nplb::kSomeContext); - EXPECT_TRUE(SbThreadIsValid(thread)); - void* result = NULL; - EXPECT_TRUE(SbThreadJoin(thread, &result)); - EXPECT_EQ(nplb::kSomeContextPlusOne, result); -} - -TEST(SbThreadCreateTest, SunnyDayNoContext) { - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, - nplb::kThreadName, nplb::AddOneEntryPoint, NULL); - EXPECT_TRUE(SbThreadIsValid(thread)); - void* result = NULL; - EXPECT_TRUE(SbThreadJoin(thread, &result)); - EXPECT_EQ(nplb::ToVoid(1), result); -} - -TEST(SbThreadCreateTest, SunnyDayWithAffinity) { - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, 0, true, nplb::kThreadName, - nplb::AddOneEntryPoint, nplb::kSomeContext); - EXPECT_TRUE(SbThreadIsValid(thread)); - void* result = NULL; - EXPECT_TRUE(SbThreadJoin(thread, &result)); - EXPECT_EQ(nplb::kSomeContextPlusOne, result); -} - -TEST(SbThreadCreateTest, SunnyDayDetached) { - SbThread thread = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - false, nplb::kThreadName, - nplb::AddOneEntryPoint, nplb::kSomeContext); - EXPECT_TRUE(SbThreadIsValid(thread)); - void* result = NULL; - EXPECT_FALSE(SbThreadJoin(thread, &result)); -} - -TEST(SbThreadCreateTest, Summertime) { - const int kMany = kSbMaxThreads; - std::vector threads(kMany); - for (int i = 0; i < kMany; ++i) { - threads[i] = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - true, nplb::kThreadName, nplb::AddOneEntryPoint, - nplb::ToVoid(i)); - EXPECT_TRUE(SbThreadIsValid(threads[i])); - } - - for (int i = 0; i < kMany; ++i) { - void* result = NULL; - void* const kExpected = nplb::ToVoid(i + 1); - EXPECT_TRUE(SbThreadJoin(threads[i], &result)); - EXPECT_EQ(kExpected, result); - } -} - -TEST(SbThreadCreateTest, RainyDayNoEntryPoint) { - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, - nplb::kThreadName, NULL, nplb::kSomeContext); - EXPECT_FALSE(SbThreadIsValid(thread)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_detach_test.cc b/starboard/nplb/thread_detach_test.cc deleted file mode 100644 index e50b51be25f5..000000000000 --- a/starboard/nplb/thread_detach_test.cc +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Thread joining is mostly tested in the other tests. - -#if SB_API_VERSION < 16 - -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbThreadDetachTest, SunnyDay) { - SbThread thread = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - true, NULL, AddOneEntryPoint, NULL); - EXPECT_TRUE(SbThreadIsValid(thread)); - SbThreadDetach(thread); - void* result = NULL; - EXPECT_FALSE(SbThreadJoin(thread, &result)); - EXPECT_EQ(NULL, result); -} - -TEST(SbThreadDetachTest, RainyDayInvalid) { - // No way to verify this, but it shouldn't crash. - SbThreadDetach(kSbThreadInvalid); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_get_current_test.cc b/starboard/nplb/thread_get_current_test.cc deleted file mode 100644 index db12599d450d..000000000000 --- a/starboard/nplb/thread_get_current_test.cc +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -void* EntryPoint(void* context) { - // NOLINTNEXTLINE(readability/casting) - return ToVoid((intptr_t)SbThreadGetCurrent()); -} - -TEST(SbThreadGetCurrentTest, SunnyDay) { - const int kThreads = 16; - SbThread threads[kThreads]; - for (int i = 0; i < kThreads; ++i) { - threads[i] = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - true, NULL, EntryPoint, NULL); - EXPECT_TRUE(SbThreadIsValid(threads[i])); - } - - for (int i = 0; i < kThreads; ++i) { - void* result = NULL; - EXPECT_TRUE(SbThreadJoin(threads[i], &result)); - // NOLINTNEXTLINE(readability/casting) - EXPECT_EQ(ToVoid((intptr_t)threads[i]), result); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_get_name_test.cc b/starboard/nplb/thread_get_name_test.cc deleted file mode 100644 index 555bc4ff7395..000000000000 --- a/starboard/nplb/thread_get_name_test.cc +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Thread joining is mostly tested in the other tests. - -#if SB_API_VERSION < 16 - -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -// Returns the thread's ID. -void* GetThreadNameEntryPoint(void* context) { - char name[4096] = {0}; - SbThreadGetName(name, SB_ARRAY_SIZE_INT(name)); - std::string* result = static_cast(context); - *result = name; - return NULL; -} - -TEST(SbThreadGetNameTest, SunnyDay) { - std::string result; - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, - kThreadName, GetThreadNameEntryPoint, &result); - EXPECT_TRUE(SbThreadIsValid(thread)); - EXPECT_TRUE(SbThreadJoin(thread, NULL)); - EXPECT_EQ(kThreadName, result); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif diff --git a/starboard/nplb/thread_helpers.cc b/starboard/nplb/thread_helpers.cc deleted file mode 100644 index 66e893fb0f77..000000000000 --- a/starboard/nplb/thread_helpers.cc +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include - -#include "starboard/nplb/thread_helpers.h" - -#include "starboard/common/condition_variable.h" -#include "starboard/common/mutex.h" -#include "starboard/types.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { - -void DoNotYield() { - // Nope. -} - -// Adds 1 to the input. -void* AddOneEntryPoint(void* context) { - return ToVoid(FromVoid(context) + 1); -} - -void* WaiterEntryPoint(void* context) { - WaiterContext* real_context = static_cast(context); - real_context->Wait(); - return NULL; -} - -void* TakeThenSignalEntryPoint(void* context) { - TakeThenSignalContext* test_context = - static_cast(context); - - // Don't signal the condition variable until we are asked. - test_context->do_signal.Take(); - - if (test_context->delay_after_signal > 0) { - usleep(test_context->delay_after_signal); - } - - // Signal the condition variable. - EXPECT_TRUE(SbMutexIsSuccess(SbMutexAcquire(&test_context->mutex))); - EXPECT_TRUE(SbConditionVariableSignal(&test_context->condition)); - EXPECT_TRUE(SbMutexRelease(&test_context->mutex)); - - return NULL; -} - -WaiterContext::WaiterContext() : unreturned_waiters(0) { - EXPECT_TRUE(SbMutexCreate(&mutex)); - EXPECT_TRUE(SbConditionVariableCreate(&condition, &mutex)); - EXPECT_TRUE(SbConditionVariableCreate(&return_condition, &mutex)); -} - -WaiterContext::~WaiterContext() { - EXPECT_TRUE(SbConditionVariableDestroy(&return_condition)); - EXPECT_TRUE(SbConditionVariableDestroy(&condition)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -void WaiterContext::Wait() { - EXPECT_TRUE(SbMutexIsSuccess(SbMutexAcquire(&mutex))); - ++unreturned_waiters; - EXPECT_TRUE(SbConditionVariableSignal(&return_condition)); - EXPECT_TRUE(SbConditionVariableIsSignaled( - SbConditionVariableWait(&condition, &mutex))); - EXPECT_TRUE(SbMutexRelease(&mutex)); -} - -void WaiterContext::WaitForReturnSignal() { - EXPECT_TRUE(SbMutexIsSuccess(SbMutexAcquire(&mutex))); - while (unreturned_waiters == 0) { - EXPECT_TRUE(SbConditionVariableIsSignaled( - SbConditionVariableWait(&return_condition, &mutex))); - } - --unreturned_waiters; - EXPECT_TRUE(SbMutexRelease(&mutex)); -} - -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_helpers.h b/starboard/nplb/thread_helpers.h index fcc1a6f8738a..5668cae4f49e 100644 --- a/starboard/nplb/thread_helpers.h +++ b/starboard/nplb/thread_helpers.h @@ -15,187 +15,6 @@ #ifndef STARBOARD_NPLB_THREAD_HELPERS_H_ #define STARBOARD_NPLB_THREAD_HELPERS_H_ -#if SB_API_VERSION < 16 +#error This file is deprecated with SB_API_VERSION 16. -#include "starboard/common/mutex.h" -#include "starboard/common/semaphore.h" -#include "starboard/condition_variable.h" -#include "starboard/configuration.h" -#include "starboard/thread.h" -#include "starboard/types.h" - -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { - -class TestSemaphore { - public: - TestSemaphore(); // initial_thread_permits = 0; - explicit TestSemaphore(int initial_thread_permits); - - // Copy constructed needed because of tests. - TestSemaphore(const TestSemaphore& other) - : mutex_(), condition_(mutex_), permits_(other.permits_) {} - ~TestSemaphore(); - - // Increases the permits. One thread will be woken up if it is blocked in - // Take(). - void Put(); - - // The caller is blocked if the counter is negative, and will stay blocked - // until Put() is invoked by another thread. The permits is then - // decremented by one. - - void Take(); - - // A non-blocking version of Take(). If the counter is negative then this - // function returns immediately and the semaphore is not modified. If true - // is returned then the effects are the same as Take(). - bool TakeTry(); - - private: - Mutex mutex_; - ConditionVariable condition_; - int permits_; -}; - -inline TestSemaphore::TestSemaphore() - : mutex_(), condition_(mutex_), permits_(0) {} - -inline TestSemaphore::TestSemaphore(int initial_thread_permits) - : mutex_(), condition_(mutex_), permits_(initial_thread_permits) {} - -inline TestSemaphore::~TestSemaphore() {} - -inline void TestSemaphore::Put() { - ScopedLock lock(mutex_); - ++permits_; - condition_.Signal(); -} - -inline void TestSemaphore::Take() { - ScopedLock lock(mutex_); - while (permits_ <= 0) { - condition_.Wait(); - } - --permits_; -} - -inline bool TestSemaphore::TakeTry() { - ScopedLock lock(mutex_); - if (permits_ <= 0) { - return false; - } - --permits_; - return true; -} - -inline void* ToVoid(intptr_t value) { - return reinterpret_cast(value); -} - -inline intptr_t FromVoid(void* value) { - return reinterpret_cast(value); -} - -void* const kSomeContext = ToVoid(1234); -void* const kSomeContextPlusOne = ToVoid(1235); - -const char* const kThreadName = "ThreadName"; -const char* const kAltThreadName = "AltThreadName"; - -// Does not yield, can't you read? -void DoNotYield(); - -// Adds 1 to the input. -void* AddOneEntryPoint(void* context); - -// Acquires the mutex from the WaiterContext, signals the return_condition, then -// waits on the condition. -void* WaiterEntryPoint(void* context); - -// Takes a token from the TakeThenSignalContext semaphore, and then signals the -// condition variable. -void* TakeThenSignalEntryPoint(void* context); - -// A simple struct that will initialize its members on construction and destroy -// them on destruction. -struct WaiterContext { - WaiterContext(); - ~WaiterContext(); - - // Waits on |condition|, incrementing |unreturned_waiters| and signalling - // |return_condition|. - void Wait(); - - // Waits until unreturned_waiters > 0, and then takes one. - void WaitForReturnSignal(); - - SbMutex mutex; - SbConditionVariable condition; - SbConditionVariable return_condition; - int unreturned_waiters; -}; - -// An aggregate type (which can be initialized with aggregate initialization) to -// be used with the TakeThenSignalEntryPoint. -struct TakeThenSignalContext { - TestSemaphore do_signal; - SbMutex mutex; - SbConditionVariable condition; - int64_t delay_after_signal; -}; - -// AbstractTestThread that is a bare bones class wrapper around Starboard -// thread. Subclasses must override Run(). -class AbstractTestThread { - public: - AbstractTestThread() : thread_(kSbThreadInvalid) {} - virtual ~AbstractTestThread() {} - - // Subclasses should override the Run method. - virtual void Run() = 0; - - // Calls SbThreadCreate() with default parameters. - void Start() { - SbThreadEntryPoint entry_point = ThreadEntryPoint; - - thread_ = SbThreadCreate(0, // default stack_size. - kSbThreadNoPriority, // default priority. - kSbThreadNoAffinity, // default affinity. - true, // joinable. - "AbstractTestThread", entry_point, this); - - if (kSbThreadInvalid == thread_) { - ADD_FAILURE_AT(__FILE__, __LINE__) << "Invalid thread."; - } - return; - } - - void Join() { - if (!SbThreadJoin(thread_, NULL)) { - ADD_FAILURE_AT(__FILE__, __LINE__) << "Could not join thread."; - } - } - - SbThread GetThread() { return thread_; } - - private: - static void* ThreadEntryPoint(void* ptr) { - AbstractTestThread* this_ptr = static_cast(ptr); - this_ptr->Run(); - return NULL; - } - - SbThread thread_; - - AbstractTestThread(const AbstractTestThread&) = delete; - void operator=(const AbstractTestThread&) = delete; -}; - -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 #endif // STARBOARD_NPLB_THREAD_HELPERS_H_ diff --git a/starboard/nplb/thread_is_equal_test.cc b/starboard/nplb/thread_is_equal_test.cc deleted file mode 100644 index 5ab5ffd24b51..000000000000 --- a/starboard/nplb/thread_is_equal_test.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbThreadIsEqualTest, Everything) { - EXPECT_TRUE(SbThreadIsEqual(SbThreadGetCurrent(), SbThreadGetCurrent())); - - SbThread thread = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - true, NULL, AddOneEntryPoint, NULL); - EXPECT_TRUE(SbThreadIsValid(thread)); - - EXPECT_TRUE(SbThreadIsEqual(thread, thread)); - EXPECT_FALSE(SbThreadIsEqual(SbThreadGetCurrent(), thread)); - EXPECT_FALSE(SbThreadIsEqual(thread, SbThreadGetCurrent())); - - EXPECT_TRUE(SbThreadJoin(thread, NULL)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_join_test.cc b/starboard/nplb/thread_join_test.cc deleted file mode 100644 index bf951043c179..000000000000 --- a/starboard/nplb/thread_join_test.cc +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Thread joining is mostly tested in the other tests. - -#if SB_API_VERSION < 16 - -#include - -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbThreadJoinTest, RainyDayInvalid) { - void* result = NULL; - EXPECT_FALSE(SbThreadJoin(kSbThreadInvalid, NULL)); - EXPECT_FALSE(SbThreadJoin(kSbThreadInvalid, &result)); - EXPECT_EQ(NULL, result); -} - -// Tests the expectation that SbThreadJoin() will block until -// the thread function has been run. -TEST(SbThreadLocalValueTest, ThreadJoinWaitsForFunctionRun) { - // Thread functionality needs to bind to functions. In C++11 we'd use a - // lambda function to tie everything together locally, but this - // function-scoped struct with static function emulates this functionality - // pretty well. - struct LocalStatic { - static void* ThreadEntryPoint(void* input) { - int* value = static_cast(input); - static const int64_t kSleepTime = 10'000; // 10 ms. - // Wait to write the value to increase likelihood of catching - // a race condition. - usleep(kSleepTime); - (*value)++; - return NULL; - } - }; - - // Try to increase likelihood of a race condition by running multiple times. - for (int i = 0; i < 10; ++i) { - int num_times_thread_entry_point_run = 0; - SbThread thread = - SbThreadCreate(0, // Signals automatic thread stack size. - kSbThreadNoPriority, // Signals default priority. - kSbThreadNoAffinity, // Signals default affinity. - true, // joinable thread. - "TestThread", LocalStatic::ThreadEntryPoint, - &num_times_thread_entry_point_run); - - ASSERT_NE(kSbThreadInvalid, thread) << "Thread creation not successful"; - ASSERT_TRUE(SbThreadJoin(thread, NULL)); - - ASSERT_EQ(1, num_times_thread_entry_point_run) - << "Expected SbThreadJoin() to be blocked until ThreadFunction runs."; - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_local_value_test.cc b/starboard/nplb/thread_local_value_test.cc deleted file mode 100644 index c76f8989f4d5..000000000000 --- a/starboard/nplb/thread_local_value_test.cc +++ /dev/null @@ -1,195 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration_constants.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -struct ThreadLocalValue { - ThreadLocalValue() : destroyed(false) {} - bool destroyed; -}; - -struct Context { - Context() : key(), in_value(), out_value(), destroyed_before_exit(false) {} - - SbThreadLocalKey key; - void* in_value; - void* out_value; - bool destroyed_before_exit; -}; - -void DestroyThreadLocalValue(void* value) { - ThreadLocalValue* thread_local_value = static_cast(value); - thread_local_value->destroyed = true; -} - -void* EntryPoint(void* context) { - Context* real_context = static_cast(context); - SbThreadSetLocalValue(real_context->key, real_context->in_value); - real_context->out_value = SbThreadGetLocalValue(real_context->key); - ThreadLocalValue* thread_local_value = - static_cast(real_context->out_value); - real_context->destroyed_before_exit = thread_local_value->destroyed; - - return NULL; -} - -void DoSunnyDayTest(bool use_destructor) { - const int kThreads = 16; - ThreadLocalValue values[kThreads]; - Context contexts[kThreads]; - SbThread threads[kThreads]; - ThreadLocalValue my_value; - - SbThreadLocalKey key = - SbThreadCreateLocalKey(use_destructor ? DestroyThreadLocalValue : NULL); - EXPECT_TRUE(SbThreadIsValidLocalKey(key)); - SbThreadSetLocalValue(key, &my_value); - for (int i = 0; i < kThreads; ++i) { - contexts[i].key = key; - contexts[i].in_value = &values[i]; - } - - for (int i = 0; i < kThreads; ++i) { - threads[i] = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - true, NULL, EntryPoint, &contexts[i]); - } - - for (int i = 0; i < kThreads; ++i) { - EXPECT_TRUE(SbThreadIsValid(threads[i])); - EXPECT_TRUE(SbThreadJoin(threads[i], NULL)); - EXPECT_EQ(contexts[i].in_value, contexts[i].out_value); - - // The destructor for all thread-local values will be called at thread exit - // time. - EXPECT_FALSE(contexts[i].destroyed_before_exit); - if (use_destructor) { - EXPECT_TRUE(values[i].destroyed); - } else { - EXPECT_FALSE(values[i].destroyed); - } - } - - EXPECT_FALSE(my_value.destroyed); - SbThreadDestroyLocalKey(key); - - // The destructor will never be called on my_value. - EXPECT_FALSE(my_value.destroyed); -} - -// Helper function that ensures that the returned key is not recycled. -SbThreadLocalKey CreateTLSKey_NoRecycle(SbThreadLocalDestructor dtor) { - SbThreadLocalKey key = SbThreadCreateLocalKey(NULL); - EXPECT_EQ(NULL, SbThreadGetLocalValue(key)); - // Some Starboard implementations may recycle the original key, so this test - // ensures that in that case it will be reset to NULL. - SbThreadSetLocalValue(key, reinterpret_cast(1)); - SbThreadDestroyLocalKey(key); - key = SbThreadCreateLocalKey(DestroyThreadLocalValue); - return key; -} - -// Tests the expectation that thread at-exit destructors don't -// run for ThreadLocal pointers that are set to NULL. -TEST(SbThreadLocalValueTest, NoDestructorsForNullValue) { - static int s_num_destructor_calls = 0; // Must be initialized to 0. - s_num_destructor_calls = 0; // Allows test to be re-run. - - // Thread functionality needs to bind to functions. In C++11 we'd use a - // lambda function to tie everything together locally, but this - // function-scoped struct with static members emulates this functionality - // pretty well. - struct LocalStatic { - // Used as a fake destructor for thread-local-storage objects in this - // test. - static void CountsDestructorCalls(void* value) { s_num_destructor_calls++; } - - // Sets a thread local non-NULL value, and then sets it back to NULL. - static void* ThreadEntryPoint(void* ptr) { - SbThreadLocalKey key = *static_cast(ptr); - EXPECT_EQ(NULL, SbThreadGetLocalValue(key)); - // Set the value and then NULL it out. We expect that because the final - // value set was NULL, that the destructor attached to the thread's - // at-exit function will not run. - SbThreadSetLocalValue(key, reinterpret_cast(1)); - SbThreadSetLocalValue(key, NULL); - return NULL; - } - }; - - // Setup the thread key and bind the fake test destructor. - SbThreadLocalKey key = - CreateTLSKey_NoRecycle(LocalStatic::CountsDestructorCalls); - EXPECT_EQ(NULL, SbThreadGetLocalValue(key)); - - // Spawn the thread. - SbThread thread = SbThreadCreate( - 0, // Signals automatic thread stack size. - kSbThreadNoPriority, // Signals default priority. - kSbThreadNoAffinity, // Signals default affinity. - true, // joinable thread. - "TestThread", LocalStatic::ThreadEntryPoint, static_cast(&key)); - - ASSERT_NE(kSbThreadInvalid, thread) << "Thread creation not successful"; - // 2nd param is return value from ThreadEntryPoint, which is always NULL. - ASSERT_TRUE(SbThreadJoin(thread, NULL)); - - // No destructors should have run. - EXPECT_EQ(0, s_num_destructor_calls); - - SbThreadDestroyLocalKey(key); -} - -TEST(SbThreadLocalValueTest, SunnyDay) { - DoSunnyDayTest(true); -} - -TEST(SbThreadLocalValueTest, SunnyDayNoDestructor) { - DoSunnyDayTest(false); -} - -TEST(SbThreadLocalValueTest, SunnyDayFreshlyCreatedValuesAreNull) { - SbThreadLocalKey key = CreateTLSKey_NoRecycle(NULL); // NULL dtor. - EXPECT_EQ(NULL, SbThreadGetLocalValue(key)); - - EXPECT_EQ(NULL, SbThreadGetLocalValue(key)); - SbThreadDestroyLocalKey(key); -} - -TEST(SbThreadLocalValueTest, SunnyDayMany) { - const int kMany = (2 * kSbMaxThreadLocalKeys) / 3; - std::vector keys(kMany); - - for (int i = 0; i < kMany; ++i) { - keys[i] = SbThreadCreateLocalKey(NULL); - EXPECT_TRUE(SbThreadIsValidLocalKey(keys[i])) << "key #" << i; - } - - for (int i = 0; i < kMany; ++i) { - SbThreadDestroyLocalKey(keys[i]); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_sampler_test.cc b/starboard/nplb/thread_sampler_test.cc index 65f90fc37dbc..4d58631a3a3d 100644 --- a/starboard/nplb/thread_sampler_test.cc +++ b/starboard/nplb/thread_sampler_test.cc @@ -19,11 +19,7 @@ #include "starboard/common/log.h" #include "starboard/common/time.h" -#if SB_API_VERSION < 16 -#include "starboard/nplb/thread_helpers.h" -#else #include "starboard/nplb/posix_compliance/posix_thread_helpers.h" -#endif #include "starboard/thread.h" #include "testing/gtest/include/gtest/gtest.h" @@ -31,11 +27,7 @@ namespace starboard { namespace nplb { namespace { -#if SB_API_VERSION < 16 -class CountingThread : public AbstractTestThread { -#else class CountingThread : public posix::AbstractTestThread { -#endif public: ~CountingThread() { Stop(); } @@ -73,12 +65,7 @@ TEST(ThreadSamplerTest, RainyDayCreateSamplerInvalidThread) { // Creating a sampler for an invalid thread should not succeed, and even // without without calling |SbThreadSamplerDelete| ASAN should not detect a // memory leak. - -#if SB_API_VERSION < 16 - SbThreadSampler sampler = SbThreadSamplerCreate(kSbThreadInvalid); -#else SbThreadSampler sampler = SbThreadSamplerCreate(0); -#endif EXPECT_FALSE(SbThreadSamplerIsValid(sampler)); } diff --git a/starboard/nplb/thread_set_name_test.cc b/starboard/nplb/thread_set_name_test.cc deleted file mode 100644 index 8419dc51e248..000000000000 --- a/starboard/nplb/thread_set_name_test.cc +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Thread joining is mostly tested in the other tests. - -#if SB_API_VERSION < 16 - -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -struct Context { - std::string got_name1; - std::string name_to_set; - std::string got_name2; -}; - -// Gets the thread's name and sets it in the context. -void* SetThreadNameEntryPoint(void* context) { - char name[4096] = {0}; - Context* real_context = static_cast(context); - - SbThreadGetName(name, SB_ARRAY_SIZE_INT(name)); - real_context->got_name1 = name; - - SbThreadSetName(real_context->name_to_set.c_str()); - - SbThreadGetName(name, SB_ARRAY_SIZE_INT(name)); - real_context->got_name2 = name; - - return NULL; -} - -TEST(SbThreadSetNameTest, SunnyDay) { - Context context; - context.name_to_set = kAltThreadName; - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, - kThreadName, SetThreadNameEntryPoint, &context); - EXPECT_TRUE(SbThreadIsValid(thread)); - EXPECT_TRUE(SbThreadJoin(thread, NULL)); - EXPECT_EQ(kThreadName, context.got_name1); - EXPECT_EQ(kAltThreadName, context.got_name2); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif diff --git a/starboard/nplb/thread_sleep_test.cc b/starboard/nplb/thread_sleep_test.cc deleted file mode 100644 index 1a71668be7ee..000000000000 --- a/starboard/nplb/thread_sleep_test.cc +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/time.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -#if SB_API_VERSION < 16 - -namespace starboard { -namespace nplb { -namespace { - -// Allow millisecond-level precision. -const int64_t kPrecision = 1000; // 1ms - -TEST(SbThreadSleepTest, SunnyDay) { - SbThreadSleep(0); - // Well, my work here is done. -} - -// My strategy here is to sleep for an amount of time, and ensure that AT LEAST -// that amount of time has passed. There's really no upper bound for how late -// the thread can wake up, something I completely sympathize with. -TEST(SbThreadSleepTest, SunnyDayAtLeastDelay) { - const int kTrials = 12; - const int64_t one = 1; - for (int trial = 0; trial < kTrials; ++trial) { - // This tests several delays, between about 15 to about 4 milliseconds. - const int64_t kDelay = 1'000'000LL / (one << ((trial % 3) + 6)); - int64_t start = CurrentMonotonicTime(); - SbThreadSleep(kDelay); - int64_t end = CurrentMonotonicTime(); - EXPECT_LE(start + kDelay, end + kPrecision) - << "Trial " << trial << ", kDelay=" << kDelay; - } -} - -TEST(SbThreadSleepTest, RainyDayNegativeDuration) { - const int kTrials = 128; - for (int trial = 0; trial < kTrials; ++trial) { - int64_t start = CurrentMonotonicTime(); - SbThreadSleep(-1'000'000); - EXPECT_GT(200'000, CurrentMonotonicTime() - start) << "Trial " << trial; - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 15 diff --git a/starboard/nplb/thread_yield_test.cc b/starboard/nplb/thread_yield_test.cc deleted file mode 100644 index fbbe5c4f1694..000000000000 --- a/starboard/nplb/thread_yield_test.cc +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/time.h" -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -#if SB_API_VERSION < 16 - -namespace starboard { -namespace nplb { -namespace { - -// Returns whether a given index is a yielder for the given trial. We alternate -// whether 0 or 1 is a Yielder to avoid the first-started advantage. -inline bool IsYielder(int trial, int index) { - return (trial % 2 ? (index % 2 != 0) : (index % 2 == 0)); -} - -// The more loops, the more the yielders should fall behind. -const int kLoops = 10000; - -void* YieldingEntryPoint(void* context) { - for (int i = 0; i < kLoops; ++i) { - SbThreadYield(); - } - - int64_t* end_time = static_cast(context); - *end_time = CurrentMonotonicTime(); - return NULL; -} - -void* UnyieldingEntryPoint(void* context) { - for (int i = 0; i < kLoops; ++i) { - DoNotYield(); - } - - int64_t* end_time = static_cast(context); - *end_time = CurrentMonotonicTime(); - return NULL; -} - -TEST(SbThreadYieldTest, SunnyDay) { - SbThreadYield(); - // Well, my work here is done. -} - -// Okay, okay, I'm not sure how else to test this other than to try to make sure -// that a thread that yields generally gets more CPU time than one that doesn't. -// -// I did test that racing Unyielding threads against each other causes this test -// to fail regularly. By rerunning the test kTrials times, and by swapping which -// thread gets started first, I hope to make this inherently flaky test not -// flaky. -// -// Note: This test may still be flaky, but it should be a lot less flaky than -// before. If this test starts flaking again, tag it with FLAKY_ again. -TEST(SbThreadYieldTest, SunnyDayRace) { - const int kTrials = 20; - int passes = 0; - for (int trial = 0; trial < kTrials; ++trial) { - // Pin to CPU 0 to make sure the threads don't get distributed onto other - // cores. - SbThreadAffinity affinity = 0; - // We want enough racers such that the threads must contend for cpu time, - // and enough data for the averages to be consistently divergent. - const int64_t kRacers = 32; - SbThread threads[kRacers]; - int64_t end_times[kRacers] = {0}; - for (int i = 0; i < kRacers; ++i) { - threads[i] = SbThreadCreate( - 0, kSbThreadNoPriority, affinity, true, NULL, - (IsYielder(trial, i) ? YieldingEntryPoint : UnyieldingEntryPoint), - &(end_times[i])); - } - - for (int i = 0; i < kRacers; ++i) { - EXPECT_TRUE(SbThreadIsValid(threads[i])) << "thread = " << threads[i]; - } - - for (int i = 0; i < kRacers; ++i) { - EXPECT_TRUE(SbThreadJoin(threads[i], NULL)); - } - - // On average, Unyielders should finish sooner than Yielders. - int64_t average_yielder = 0; - int64_t average_unyielder = 0; - const int64_t kRacersPerGroup = kRacers / 2; - for (int i = 0; i < kRacers; ++i) { - if (IsYielder(trial, i)) { - average_yielder += end_times[i] / kRacersPerGroup; - } else { - average_unyielder += end_times[i] / kRacersPerGroup; - } - } - - // If unyielders took less time then yielders, on average, then we consider - // the trial a pass. - if (average_unyielder < average_yielder) { - ++passes; - } - } - - // We expect at least 2/3 of the trials to pass. - EXPECT_LT(kTrials * 2 / 3, passes); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/time_constants.h b/starboard/nplb/time_constants.h index 348424741e14..a8c828acc1c7 100644 --- a/starboard/nplb/time_constants.h +++ b/starboard/nplb/time_constants.h @@ -15,53 +15,6 @@ #ifndef STARBOARD_NPLB_TIME_CONSTANTS_H_ #define STARBOARD_NPLB_TIME_CONSTANTS_H_ -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -namespace starboard { -namespace nplb { - -static const SbTime kExtraMilliseconds = 123 * kSbTimeMillisecond; -static const SbTime kTestSbTimeYear = 525949 * kSbTimeMinute; - -// 1443121328 in POSIX time is -// Thursday, 9/24/2015 19:02:08 UTC -static const SbTime kTestTimePositive = SbTimeFromPosix( - SB_INT64_C(1443121328) * kSbTimeSecond + kExtraMilliseconds); - -// 0 in POSIX time is -// Thursday, 1/1/1970 00:00:00 UTC -static const SbTime kTestTimePosixZero = - SbTimeFromPosix(SB_INT64_C(0) * kSbTimeSecond); - -// -771942639 in POSIX time is -// Monday, 7/16/1945 11:29:21 UTC -static const SbTime kTestTimePosixNegative = - SbTimeFromPosix(SB_INT64_C(-771942639) * kSbTimeSecond); - -// 0 in Windows time is -// Monday, 1/1/1601 00:00:00 UTC -static const SbTime kTestTimeWindowsZero = 0; - -// -15065654400 in POSIX time is -// Wednesday, 8/3/1492 00:00:00 UTC -static const SbTime kTestTimeWindowsNegative = - SbTimeFromPosix(SB_INT64_C(-15065654400) * kSbTimeSecond); - -// 1600970155 in POSIX time is -// Thursday, 9/24/2020 17:55:55 UTC -// NOTE: Update this value once every 25 or so years. -static const SbTime kTestTimeWritten = - SbTimeFromPosix(SB_INT64_C(1600970155) * kSbTimeSecond); - -// 25 years after the time this test was written. -static const SbTime kTestTimePastWritten = - SbTimeFromPosix(kTestTimeWritten + (25 * kTestSbTimeYear)); - -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 +#error This file is deprecated with SB_API_VERSION 16. #endif // STARBOARD_NPLB_TIME_CONSTANTS_H_ diff --git a/starboard/nplb/time_get_monotonic_now_test.cc b/starboard/nplb/time_get_monotonic_now_test.cc deleted file mode 100644 index d984ecd77b1d..000000000000 --- a/starboard/nplb/time_get_monotonic_now_test.cc +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/nplb/time_constants.h" -#include "starboard/time.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbTimeGetMonotonicNowTest, IsMonotonic) { - const int kTrials = 100; - for (int trial = 0; trial < kTrials; ++trial) { - SbTimeMonotonic time1 = SbTimeGetMonotonicNow(); - SbTime clockStart = SbTimeGetNow(); - - // Spin tightly until time changes. - SbTimeMonotonic time2 = 0; - while (true) { - time2 = SbTimeGetMonotonicNow(); - if (time2 != time1) { - EXPECT_GT(time2, time1); - EXPECT_LT(time2 - time1, kSbTimeSecond); - return; - } - - // If time hasn't increased within a second, our "high-resolution" - // monotonic timer is broken. - if (SbTimeGetNow() - clockStart >= kSbTimeSecond) { - GTEST_FAIL() << "SbTimeGetMonotonicNow() hasn't changed within a " - << "second."; - return; - } - } - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/time_get_now_test.cc b/starboard/nplb/time_get_now_test.cc deleted file mode 100644 index 32d9f4265e11..000000000000 --- a/starboard/nplb/time_get_now_test.cc +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/nplb/time_constants.h" -#include "starboard/time.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbTimeGetNowTest, IsKindOfSane) { - SbTime time = SbTimeGetNow(); - - // Now should be after the time I wrote this test. - EXPECT_GT(time, kTestTimeWritten); - - // And it should be before 5 years after I wrote this test, at least for a - // while. - EXPECT_LT(time, kTestTimePastWritten); -} - -TEST(SbTimeGetNowTest, HasDecentResolution) { - const int kNumIterations = 100; - for (int i = 0; i < kNumIterations; ++i) { - SbTime time1 = SbTimeGetNow(); - SbTimeMonotonic timerStart = SbTimeGetMonotonicNow(); - - // Spin tightly until time increments. - SbTime time2 = 0; - while (true) { - time2 = SbTimeGetNow(); - if (time2 != time1) { - EXPECT_NE(time2, time1); - break; - } - - // If time hasn't changed within a second, that's beyond low resolution. - if ((SbTimeGetMonotonicNow() - timerStart) >= kSbTimeSecond) { - GTEST_FAIL() << "SbTimeGetNow() hasn't changed within a second."; - break; - } - } - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/time_narrow_test.cc b/starboard/nplb/time_narrow_test.cc deleted file mode 100644 index ee6f3233bd12..000000000000 --- a/starboard/nplb/time_narrow_test.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbTimeNarrowTest, SunnyDay) { - EXPECT_EQ(0, SbTimeNarrow(1, 1000)); - EXPECT_EQ(-1, SbTimeNarrow(-1, 1000)); - EXPECT_EQ(1, SbTimeNarrow(1000, 1000)); - EXPECT_EQ(1000, SbTimeNarrow(1000000, 1000)); - EXPECT_EQ(-1000, SbTimeNarrow(-1000000, 1000)); - EXPECT_EQ(-1, SbTimeNarrow(-1000, 1000)); - EXPECT_EQ(-2, SbTimeNarrow(-1001, 1000)); - EXPECT_EQ(-1, SbTimeNarrow(-1, 1000000)); - EXPECT_EQ(-1, SbTimeNarrow(-1, 7)); - EXPECT_EQ(-2, SbTimeNarrow(-8, 7)); - EXPECT_EQ(1, SbTimeNarrow(8, 7)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/ui_navigation_test.cc b/starboard/nplb/ui_navigation_test.cc index fa24eec71693..52f7d3f45cca 100644 --- a/starboard/nplb/ui_navigation_test.cc +++ b/starboard/nplb/ui_navigation_test.cc @@ -12,12 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if SB_API_VERSION < 16 -#include "starboard/ui_navigation.h" -#else #include "starboard/extension/ui_navigation.h" #include "starboard/system.h" -#endif // SB_API_VERSION #include "testing/gtest/include/gtest/gtest.h" namespace starboard { @@ -26,14 +22,9 @@ namespace { // This verifies that the UI navigation API is not implemented. TEST(UiNavigationTest, GetInterface) { -#if SB_API_VERSION < 16 - SbUiNavInterface interface; - EXPECT_FALSE(SbUiNavGetInterface(&interface)); -#else const SbUiNavInterface* interface = static_cast( SbSystemGetExtension(kCobaltExtensionUiNavigationName)); EXPECT_FALSE(interface != nullptr); -#endif // SB_API_VERSION } } // namespace. diff --git a/starboard/nplb/user_get_current_test.cc b/starboard/nplb/user_get_current_test.cc deleted file mode 100644 index 705adcf82269..000000000000 --- a/starboard/nplb/user_get_current_test.cc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/user.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbUserGetCurrentTest, SunnyDay) { - SbUser users[10] = {0}; - int result = SbUserGetSignedIn(users, SB_ARRAY_SIZE_INT(users)); - EXPECT_LE(0, result); - - SbUser current = SbUserGetCurrent(); - if (result > 0) { - EXPECT_NE(kSbUserInvalid, current); - } else { - EXPECT_EQ(kSbUserInvalid, current); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/user_get_property_test.cc b/starboard/nplb/user_get_property_test.cc deleted file mode 100644 index ee09ad703db9..000000000000 --- a/starboard/nplb/user_get_property_test.cc +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" -#include "starboard/user.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -void TestProperty(SbUser user, SbUserPropertyId property_id) { - int size = SbUserGetPropertySize(user, property_id); - EXPECT_LE(0, size); - - if (size > 0) { - char* property = new char[size + 10]; - memset(property, 0, size + 10); - EXPECT_TRUE(SbUserGetProperty(user, property_id, property, size)); - for (int i = 0; i < size - 1; ++i) { - EXPECT_NE(property[i], '\0') << "position " << i; - } - for (int i = size - 1; i < size + 10; ++i) { - EXPECT_EQ(property[i], '\0') << "position " << i; - } - delete[] property; - } else { - char property[10] = {0}; - bool result = SbUserGetProperty(user, property_id, property, 10); - for (int i = 0; i < size; ++i) { - EXPECT_EQ(property[i], '\0') << "position " << i; - } - } -} - -TEST(SbUserGetPropertyTest, SunnyDay) { - SbUser current = SbUserGetCurrent(); - if (!SbUserIsValid(current)) { - // Sadly, we can't really test in this case. - return; - } - - TestProperty(current, kSbUserPropertyUserName); - TestProperty(current, kSbUserPropertyUserId); -#if SB_API_VERSION < 16 - TestProperty(current, kSbUserPropertyAvatarUrl); -#endif -} - -TEST(SbUserGetPropertyTest, MultipleTimes) { - SbUser current = SbUserGetCurrent(); - if (!SbUserIsValid(current)) { - // Sadly, we can't really test in this case. - return; - } - - TestProperty(current, kSbUserPropertyUserName); - TestProperty(current, kSbUserPropertyUserName); - - TestProperty(current, kSbUserPropertyUserId); - TestProperty(current, kSbUserPropertyUserId); - -#if SB_API_VERSION < 16 - TestProperty(current, kSbUserPropertyAvatarUrl); - TestProperty(current, kSbUserPropertyAvatarUrl); -#endif -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif diff --git a/starboard/nplb/user_get_signed_in_test.cc b/starboard/nplb/user_get_signed_in_test.cc deleted file mode 100644 index f062f843d3d5..000000000000 --- a/starboard/nplb/user_get_signed_in_test.cc +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/user.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbUserGetSignedInTest, SunnyDay) { - SbUser users[100] = {0}; - int result = SbUserGetSignedIn(users + 10, SB_ARRAY_SIZE_INT(users) - 10); - EXPECT_LE(0, result); - for (int i = 0; i < 10; ++i) { - EXPECT_EQ(kSbUserInvalid, users[i]); - } - - for (int i = 0; i < result; ++i) { - EXPECT_NE(kSbUserInvalid, users[10 + i]); - } - - for (int i = 0; i < 10; ++i) { - EXPECT_EQ(kSbUserInvalid, users[10 + result + i]); - } -} - -TEST(SbUserGetSignedInTest, NullUsers) { - SbUser users[100] = {0}; - int result = SbUserGetSignedIn(users, SB_ARRAY_SIZE_INT(users)); - EXPECT_LE(0, result); - - int result2 = SbUserGetSignedIn(NULL, SB_ARRAY_SIZE_INT(users)); - EXPECT_EQ(result, result2); - - SbUser users2[100] = {0}; - int result3 = SbUserGetSignedIn(users2, 0); - EXPECT_EQ(result, result3); - for (int i = 0; i < SB_ARRAY_SIZE_INT(users2); ++i) { - EXPECT_EQ(kSbUserInvalid, users2[i]); - } - int result4 = SbUserGetSignedIn(NULL, 0); - EXPECT_EQ(result, result4); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif diff --git a/starboard/once.h b/starboard/once.h index 526e028fa644..d2a54c09a483 100644 --- a/starboard/once.h +++ b/starboard/once.h @@ -20,81 +20,6 @@ #ifndef STARBOARD_ONCE_H_ #define STARBOARD_ONCE_H_ -#if SB_API_VERSION < 16 +#error This file is deprecated with SB_API_VERSION 16. -#include "starboard/export.h" -#include "starboard/types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// Max size of the SbOnceControl type. -#define SB_ONCE_MAX_SIZE 64 - -// An opaque handle to a once control type with -// reserved memory buffer of size SB_ONCE_MAX_SIZE and -// aligned at void pointer type. -typedef union SbOnceControl { - // Reserved memory in which the implementation should map its - // native once control variable type. - uint8_t once_buffer[SB_ONCE_MAX_SIZE]; - - // Guarantees alignment of the type to a void pointer. - void* ptr; -} SbOnceControl; - -#ifdef __cplusplus -#define SB_ONCE_INITIALIZER \ - {} -#else -#define SB_ONCE_INITIALIZER \ - { 0 } -#endif - -// Function pointer type for methods that can be called via the SbOnce() system. -typedef void (*SbOnceInitRoutine)(void); - -// Thread-safely runs |init_routine| only once. -// - If this |once_control| has not run a function yet, this function runs -// |init_routine| in a thread-safe way and then returns |true|. -// - If SbOnce() was called with |once_control| before, the function returns -// |true| immediately. -// - If |once_control| or |init_routine| is invalid, the function returns -// |false|. -SB_EXPORT bool SbOnce(SbOnceControl* once_control, - SbOnceInitRoutine init_routine); - -#ifdef __cplusplus -// Defines a function that will initialize the indicated type once and return -// it. This initialization is thread safe if the type being created is side -// effect free. -// -// These macros CAN ONLY BE USED IN A CC file, never in a header file. -// -// Example (in cc file): -// SB_ONCE_INITIALIZE_FUNCTION(MyClass, GetOrCreateMyClass) -// .. -// MyClass* instance = GetOrCreateMyClass(); -// MyClass* instance2 = GetOrCreateMyClass(); -// DCHECK_EQ(instance, instance2); -#define SB_ONCE_INITIALIZE_FUNCTION(Type, FunctionName) \ - Type* FunctionName() { \ - static SbOnceControl s_once_flag = SB_ONCE_INITIALIZER; \ - static Type* s_singleton = NULL; \ - struct Local { \ - static void Init() { \ - s_singleton = new Type(); \ - } \ - }; \ - SbOnce(&s_once_flag, Local::Init); \ - return s_singleton; \ - } -#endif // __cplusplus - -#ifdef __cplusplus -} -#endif - -#endif // SB_API_VERSION < 16 #endif // STARBOARD_ONCE_H_ diff --git a/starboard/raspi/shared/BUILD.gn b/starboard/raspi/shared/BUILD.gn index fcfc835ded38..6997c48fbb06 100644 --- a/starboard/raspi/shared/BUILD.gn +++ b/starboard/raspi/shared/BUILD.gn @@ -50,8 +50,6 @@ static_library("starboard_platform_sources") { "//starboard/raspi/shared/open_max/decode_target_release.cc", "//starboard/raspi/shared/open_max/dispmanx_resource_pool.cc", "//starboard/raspi/shared/open_max/dispmanx_resource_pool.h", - "//starboard/raspi/shared/open_max/image_decode.cc", - "//starboard/raspi/shared/open_max/image_is_decode_supported.cc", "//starboard/raspi/shared/open_max/open_max_component.cc", "//starboard/raspi/shared/open_max/open_max_component.h", "//starboard/raspi/shared/open_max/open_max_component_base.cc", @@ -65,7 +63,6 @@ static_library("starboard_platform_sources") { "//starboard/raspi/shared/open_max/video_decoder.cc", "//starboard/raspi/shared/open_max/video_decoder.h", "//starboard/raspi/shared/player_components_factory.cc", - "//starboard/raspi/shared/system_get_device_type.cc", "//starboard/raspi/shared/system_get_property.cc", "//starboard/raspi/shared/system_gles2.cc", "//starboard/raspi/shared/thread_create_priority.cc", @@ -82,13 +79,9 @@ static_library("starboard_platform_sources") { "//starboard/shared/alsa/alsa_util.h", "//starboard/shared/egl/system_egl.cc", "//starboard/shared/gcc/atomic_gcc_public.h", - "//starboard/shared/iso/directory_close.cc", - "//starboard/shared/iso/directory_get_next.cc", - "//starboard/shared/iso/directory_open.cc", "//starboard/shared/iso/memory_allocate_unchecked.cc", "//starboard/shared/iso/memory_free.cc", "//starboard/shared/iso/memory_reallocate_unchecked.cc", - "//starboard/shared/iso/string_scan.cc", "//starboard/shared/libevent/socket_waiter_add.cc", "//starboard/shared/libevent/socket_waiter_create.cc", "//starboard/shared/libevent/socket_waiter_destroy.cc", @@ -97,7 +90,6 @@ static_library("starboard_platform_sources") { "//starboard/shared/libevent/socket_waiter_wait.cc", "//starboard/shared/libevent/socket_waiter_wait_timed.cc", "//starboard/shared/libevent/socket_waiter_wake_up.cc", - "//starboard/shared/linux/byte_swap.cc", "//starboard/shared/linux/cpu_features_get.cc", "//starboard/shared/linux/dev_input/dev_input.cc", "//starboard/shared/linux/get_home_directory.cc", @@ -109,41 +101,17 @@ static_library("starboard_platform_sources") { "//starboard/shared/linux/system_is_debugger_attached.cc", "//starboard/shared/linux/system_symbolize.cc", "//starboard/shared/linux/thread_get_id.cc", - "//starboard/shared/linux/thread_get_name.cc", - "//starboard/shared/linux/thread_set_name.cc", "//starboard/shared/linux/time_zone_get_name.cc", - "//starboard/shared/nouser/user_get_current.cc", - "//starboard/shared/nouser/user_get_property.cc", - "//starboard/shared/nouser/user_get_signed_in.cc", - "//starboard/shared/nouser/user_internal.cc", "//starboard/shared/opus/opus_audio_decoder.cc", "//starboard/shared/opus/opus_audio_decoder.h", - "//starboard/shared/posix/directory_create.cc", "//starboard/shared/posix/environment.cc", "//starboard/shared/posix/file_atomic_replace.cc", - "//starboard/shared/posix/file_can_open.cc", - "//starboard/shared/posix/file_close.cc", - "//starboard/shared/posix/file_delete.cc", - "//starboard/shared/posix/file_exists.cc", - "//starboard/shared/posix/file_flush.cc", - "//starboard/shared/posix/file_get_info.cc", - "//starboard/shared/posix/file_get_path_info.cc", - "//starboard/shared/posix/file_open.cc", - "//starboard/shared/posix/file_read.cc", - "//starboard/shared/posix/file_seek.cc", - "//starboard/shared/posix/file_truncate.cc", - "//starboard/shared/posix/file_write.cc", "//starboard/shared/posix/log.cc", "//starboard/shared/posix/log_flush.cc", "//starboard/shared/posix/log_format.cc", - "//starboard/shared/posix/log_is_tty.cc", "//starboard/shared/posix/log_raw.cc", "//starboard/shared/posix/memory_allocate_aligned_unchecked.cc", - "//starboard/shared/posix/memory_flush.cc", "//starboard/shared/posix/memory_free_aligned.cc", - "//starboard/shared/posix/memory_map.cc", - "//starboard/shared/posix/memory_protect.cc", - "//starboard/shared/posix/memory_unmap.cc", "//starboard/shared/posix/page_internal.cc", "//starboard/shared/posix/set_non_blocking_internal.cc", "//starboard/shared/posix/socket_accept.cc", @@ -172,10 +140,6 @@ static_library("starboard_platform_sources") { "//starboard/shared/posix/socket_set_tcp_no_delay.cc", "//starboard/shared/posix/socket_set_tcp_window_scaling.cc", "//starboard/shared/posix/storage_write_record.cc", - "//starboard/shared/posix/string_compare_no_case.cc", - "//starboard/shared/posix/string_compare_no_case_n.cc", - "//starboard/shared/posix/string_format.cc", - "//starboard/shared/posix/string_format_wide.cc", "//starboard/shared/posix/system_break_into_debugger.cc", "//starboard/shared/posix/system_clear_last_error.cc", "//starboard/shared/posix/system_get_error_string.cc", @@ -183,35 +147,11 @@ static_library("starboard_platform_sources") { "//starboard/shared/posix/system_get_locale_id.cc", "//starboard/shared/posix/system_get_number_of_processors.cc", "//starboard/shared/posix/thread_sleep.cc", - "//starboard/shared/posix/time_get_monotonic_now.cc", - "//starboard/shared/posix/time_get_monotonic_thread_now.cc", - "//starboard/shared/posix/time_get_now.cc", - "//starboard/shared/posix/time_is_time_thread_now_supported.cc", "//starboard/shared/posix/time_zone_get_current.cc", - "//starboard/shared/pthread/condition_variable_broadcast.cc", - "//starboard/shared/pthread/condition_variable_create.cc", - "//starboard/shared/pthread/condition_variable_destroy.cc", - "//starboard/shared/pthread/condition_variable_signal.cc", - "//starboard/shared/pthread/condition_variable_wait.cc", - "//starboard/shared/pthread/condition_variable_wait_timed.cc", - "//starboard/shared/pthread/mutex_acquire.cc", - "//starboard/shared/pthread/mutex_acquire_try.cc", - "//starboard/shared/pthread/mutex_create.cc", - "//starboard/shared/pthread/mutex_destroy.cc", - "//starboard/shared/pthread/mutex_release.cc", - "//starboard/shared/pthread/once.cc", "//starboard/shared/pthread/thread_context_get_pointer.cc", "//starboard/shared/pthread/thread_context_internal.cc", "//starboard/shared/pthread/thread_context_internal.h", - "//starboard/shared/pthread/thread_create.cc", - "//starboard/shared/pthread/thread_create_local_key.cc", "//starboard/shared/pthread/thread_create_priority.h", - "//starboard/shared/pthread/thread_destroy_local_key.cc", - "//starboard/shared/pthread/thread_detach.cc", - "//starboard/shared/pthread/thread_get_current.cc", - "//starboard/shared/pthread/thread_get_local_value.cc", - "//starboard/shared/pthread/thread_is_equal.cc", - "//starboard/shared/pthread/thread_join.cc", "//starboard/shared/pthread/thread_sampler_create.cc", "//starboard/shared/pthread/thread_sampler_destroy.cc", "//starboard/shared/pthread/thread_sampler_freeze.cc", @@ -219,7 +159,6 @@ static_library("starboard_platform_sources") { "//starboard/shared/pthread/thread_sampler_internal.h", "//starboard/shared/pthread/thread_sampler_is_supported.cc", "//starboard/shared/pthread/thread_sampler_thaw.cc", - "//starboard/shared/pthread/thread_set_local_value.cc", "//starboard/shared/pthread/thread_yield.cc", "//starboard/shared/signal/crash_signals.cc", "//starboard/shared/signal/crash_signals.h", @@ -246,12 +185,10 @@ static_library("starboard_platform_sources") { "//starboard/shared/starboard/command_line.h", "//starboard/shared/starboard/crash_handler.cc", "//starboard/shared/starboard/crash_handler.h", - "//starboard/shared/starboard/directory_can_open.cc", "//starboard/shared/starboard/event_cancel.cc", "//starboard/shared/starboard/event_schedule.cc", "//starboard/shared/starboard/file_atomic_replace_write_file.cc", "//starboard/shared/starboard/file_atomic_replace_write_file.h", - "//starboard/shared/starboard/file_mode_string_to_flags.cc", "//starboard/shared/starboard/file_storage/storage_close_record.cc", "//starboard/shared/starboard/file_storage/storage_delete_record.cc", "//starboard/shared/starboard/file_storage/storage_get_record_size.cc", @@ -269,7 +206,6 @@ static_library("starboard_platform_sources") { "//starboard/shared/starboard/media/media_get_buffer_allocation_unit.cc", "//starboard/shared/starboard/media/media_get_buffer_garbage_collection_duration_threshold.cc", "//starboard/shared/starboard/media/media_get_buffer_padding.cc", - "//starboard/shared/starboard/media/media_get_buffer_storage_type.cc", "//starboard/shared/starboard/media/media_get_initial_buffer_capacity.cc", "//starboard/shared/starboard/media/media_get_max_buffer_capacity.cc", "//starboard/shared/starboard/media/media_get_progressive_buffer_budget.cc", @@ -277,10 +213,8 @@ static_library("starboard_platform_sources") { "//starboard/shared/starboard/media/media_is_audio_supported_aac_and_opus.cc", "//starboard/shared/starboard/media/media_is_buffer_pool_allocate_on_demand.cc", "//starboard/shared/starboard/media/media_is_buffer_using_memory_pool.cc", - "//starboard/shared/starboard/memory.cc", "//starboard/shared/starboard/new.cc", "//starboard/shared/starboard/queue_application.cc", - "//starboard/shared/starboard/string_duplicate.cc", "//starboard/shared/starboard/system_get_random_uint64.cc", "//starboard/shared/starboard/system_request_blur.cc", "//starboard/shared/starboard/system_request_focus.cc", @@ -288,10 +222,6 @@ static_library("starboard_platform_sources") { "//starboard/shared/starboard/system_request_stop.cc", "//starboard/shared/starboard/system_supports_resume.cc", "//starboard/shared/starboard/window_set_default_options.cc", - "//starboard/shared/stub/accessibility_get_caption_settings.cc", - "//starboard/shared/stub/accessibility_get_display_settings.cc", - "//starboard/shared/stub/accessibility_get_text_to_speech_settings.cc", - "//starboard/shared/stub/accessibility_set_captions_enabled.cc", "//starboard/shared/stub/drm_close_session.cc", "//starboard/shared/stub/drm_create_system.cc", "//starboard/shared/stub/drm_destroy_system.cc", @@ -317,18 +247,7 @@ static_library("starboard_platform_sources") { "//starboard/shared/stub/system_network_is_disconnected.cc", "//starboard/shared/stub/system_raise_platform_error.cc", "//starboard/shared/stub/system_sign_with_certification_secret_key.cc", - "//starboard/shared/stub/ui_nav_get_interface.cc", - "//starboard/shared/stub/window_blur_on_screen_keyboard.cc", - "//starboard/shared/stub/window_focus_on_screen_keyboard.cc", "//starboard/shared/stub/window_get_diagonal_size_in_inches.cc", - "//starboard/shared/stub/window_get_on_screen_keyboard_bounding_rect.cc", - "//starboard/shared/stub/window_hide_on_screen_keyboard.cc", - "//starboard/shared/stub/window_is_on_screen_keyboard_shown.cc", - "//starboard/shared/stub/window_on_screen_keyboard_is_supported.cc", - "//starboard/shared/stub/window_on_screen_keyboard_suggestions_supported.cc", - "//starboard/shared/stub/window_set_on_screen_keyboard_keep_focus.cc", - "//starboard/shared/stub/window_show_on_screen_keyboard.cc", - "//starboard/shared/stub/window_update_on_screen_keyboard_suggestions.cc", "run_starboard_main.cc", ] diff --git a/starboard/raspi/shared/configuration_constants.cc b/starboard/raspi/shared/configuration_constants.cc index 2908227f899b..4326c929ffc4 100644 --- a/starboard/raspi/shared/configuration_constants.cc +++ b/starboard/raspi/shared/configuration_constants.cc @@ -124,11 +124,6 @@ const char* kSbPathSepString = ":"; // generally prefer a byte order of RGBA, regardless of endianness. const int kSbPreferredRgbaByteOrder = SB_PREFERRED_RGBA_BYTE_ORDER_RGBA; -#if SB_API_VERSION < 16 -// The maximum number of users that can be signed in at the same time. -const uint32_t kSbUserMaxSignedIn = 1; -#endif // SB_API_VERSION < 16 - // The maximum size the cache directory is allowed to use in bytes. const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB diff --git a/starboard/raspi/shared/configuration_public.h b/starboard/raspi/shared/configuration_public.h index 41cb48f2ee9e..8e5723392bd8 100644 --- a/starboard/raspi/shared/configuration_public.h +++ b/starboard/raspi/shared/configuration_public.h @@ -45,32 +45,6 @@ #define SB_IS_WCHAR_T_UNSIGNED 1 #endif -// --- Attribute Configuration ----------------------------------------------- - -#if SB_API_VERSION < 16 -// The platform's annotation for forcing a C function to be inlined. -#define SB_C_FORCE_INLINE __inline__ __attribute__((always_inline)) - -// The platform's annotation for marking a C function as suggested to be -// inlined. -#define SB_C_INLINE inline - -// The platform's annotation for marking a symbol as exported outside of the -// current shared library. -#define SB_EXPORT_PLATFORM __attribute__((visibility("default"))) - -// The platform's annotation for marking a symbol as imported from outside of -// the current linking unit. -#define SB_IMPORT_PLATFORM - -// --- Memory Configuration -------------------------------------------------- - -// Whether this platform can map executable memory. Implies SB_HAS_MMAP. This is -// required for platforms that want to JIT. -#define SB_CAN_MAP_EXECUTABLE_MEMORY 1 - -#endif // SB_API_VERSION < 16 - // --- Network Configuration ------------------------------------------------- // Specifies whether this platform supports IPV6. diff --git a/starboard/raspi/shared/open_max/image_decode.cc b/starboard/raspi/shared/open_max/image_decode.cc deleted file mode 100644 index fb417eb13be5..000000000000 --- a/starboard/raspi/shared/open_max/image_decode.cc +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/image.h" - -#include "starboard/common/mutex.h" -#include "starboard/raspi/shared/open_max/open_max_image_decode_component.h" - -namespace open_max = starboard::raspi::shared::open_max; - -namespace { -starboard::Mutex decode_lock_; -} - -SbDecodeTarget SbImageDecode(SbDecodeTargetGraphicsContextProvider* provider, - void* data, - int data_size, - const char* mime_type, - SbDecodeTargetFormat format) { - SB_CHECK(data); - SB_DCHECK(SbImageIsDecodeSupported(mime_type, format)); - SbDecodeTarget target = kSbDecodeTargetInvalid; - - // Only one image can be decoded at a time by the component. - { - starboard::ScopedLock lock(decode_lock_); - open_max::OpenMaxImageDecodeComponent decoder; - target = decoder.Decode(provider, mime_type, format, data, data_size); - } - - return target; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/raspi/shared/open_max/image_is_decode_supported.cc b/starboard/raspi/shared/open_max/image_is_decode_supported.cc deleted file mode 100644 index f392b8299c8b..000000000000 --- a/starboard/raspi/shared/open_max/image_is_decode_supported.cc +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/image.h" - -#include "starboard/raspi/shared/open_max/open_max_image_decode_component.h" -#include "starboard/shared/starboard/application.h" - -namespace open_max = starboard::raspi::shared::open_max; - -bool SbImageIsDecodeSupported(const char* mime_type, - SbDecodeTargetFormat format) { - using starboard::shared::starboard::Application; - - auto command_line = Application::Get()->GetCommandLine(); - auto value = command_line->GetSwitchValue("enable_sb_image_decoder"); - // Unfortunately, while openmax image decoding is implemented and supported, - // there is a very sporadic (i.e. around every 1 in 200 image decodes) crash - // bug that will go off. This may be due to a threading issue somewhere, but - // it is not clear right now. So by default we report that we do not support - // Starboard image decoding. - if (value != "true") { - return false; - } - - bool type_supported = - OMX_IMAGE_CodingMax != - open_max::OpenMaxImageDecodeComponent::GetCompressionFormat(mime_type); - return type_supported && format == kSbDecodeTargetFormat1PlaneRGBA; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/raspi/shared/system_get_device_type.cc b/starboard/raspi/shared/system_get_device_type.cc deleted file mode 100644 index a3e78d207d19..000000000000 --- a/starboard/raspi/shared/system_get_device_type.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2020 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#if SB_API_VERSION < 15 - -SbSystemDeviceType SbSystemGetDeviceType() { - return kSbSystemDeviceTypeUnknown; -} - -#endif diff --git a/starboard/shared/iso/directory_close.cc b/starboard/shared/iso/directory_close.cc deleted file mode 100644 index f00b716b9b19..000000000000 --- a/starboard/shared/iso/directory_close.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include "starboard/shared/iso/directory_internal.h" - -#include "starboard/shared/iso/impl/directory_close.h" - -bool SbDirectoryClose(SbDirectory directory) { - return ::starboard::shared::iso::impl::SbDirectoryClose(directory); -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/iso/directory_get_next.cc b/starboard/shared/iso/directory_get_next.cc deleted file mode 100644 index bfb42cef9672..000000000000 --- a/starboard/shared/iso/directory_get_next.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include "starboard/shared/iso/directory_internal.h" - -#include "starboard/shared/iso/impl/directory_get_next.h" - -bool SbDirectoryGetNext(SbDirectory directory, - char* out_entry, - size_t out_entry_size) { - return ::starboard::shared::iso::impl::SbDirectoryGetNext( - directory, out_entry, out_entry_size); -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/iso/directory_internal.h b/starboard/shared/iso/directory_internal.h deleted file mode 100644 index 81e6961d9b26..000000000000 --- a/starboard/shared/iso/directory_internal.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_ISO_DIRECTORY_INTERNAL_H_ -#define STARBOARD_SHARED_ISO_DIRECTORY_INTERNAL_H_ - -#include -#include - -#include "starboard/directory.h" -#include "starboard/shared/internal_only.h" - -struct SbDirectoryPrivate { - // The ISO C directory stream handle. - DIR* directory; -}; - -#endif // STARBOARD_SHARED_ISO_DIRECTORY_INTERNAL_H_ diff --git a/starboard/shared/iso/directory_open.cc b/starboard/shared/iso/directory_open.cc deleted file mode 100644 index 3e994f751543..000000000000 --- a/starboard/shared/iso/directory_open.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include "starboard/shared/iso/directory_internal.h" - -#include "starboard/shared/iso/impl/directory_open.h" - -SbDirectory SbDirectoryOpen(const char* path, SbFileError* out_error) { - return ::starboard::shared::iso::impl::SbDirectoryOpen(path, out_error); -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/iso/impl/directory_close.h b/starboard/shared/iso/impl/directory_close.h deleted file mode 100644 index c5182e832386..000000000000 --- a/starboard/shared/iso/impl/directory_close.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef STARBOARD_SHARED_ISO_IMPL_DIRECTORY_CLOSE_H_ -#define STARBOARD_SHARED_ISO_IMPL_DIRECTORY_CLOSE_H_ -#if SB_API_VERSION < 17 - -#include "starboard/directory.h" - -#include -#include - -#include "starboard/file.h" - -#include "starboard/shared/internal_only.h" -#include "starboard/shared/iso/impl/directory_impl.h" - -namespace starboard { -namespace shared { -namespace iso { -namespace impl { - -bool SbDirectoryClose(SbDirectory directory) { - if (!directory || !directory->directory) { - return false; - } - - bool result = !closedir(directory->directory); - delete directory; - return result; -} - -} // namespace impl -} // namespace iso -} // namespace shared -} // namespace starboard -#endif // SB_API_VERSION < 17 - -#endif // STARBOARD_SHARED_ISO_IMPL_DIRECTORY_CLOSE_H_ diff --git a/starboard/shared/iso/impl/directory_get_next.h b/starboard/shared/iso/impl/directory_get_next.h deleted file mode 100644 index 877b4e2d3aca..000000000000 --- a/starboard/shared/iso/impl/directory_get_next.h +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef STARBOARD_SHARED_ISO_IMPL_DIRECTORY_GET_NEXT_H_ -#define STARBOARD_SHARED_ISO_IMPL_DIRECTORY_GET_NEXT_H_ -#if SB_API_VERSION < 17 - -#include "starboard/directory.h" - -#include -#include - -#include "starboard/common/string.h" -#include "starboard/configuration_constants.h" -#include "starboard/file.h" - -#include "starboard/shared/internal_only.h" -#include "starboard/shared/iso/impl/directory_impl.h" - -namespace starboard { -namespace shared { -namespace iso { -namespace impl { - -bool SbDirectoryGetNext(SbDirectory directory, - char* out_entry, - size_t out_entry_size) { - if (out_entry_size < kSbFileMaxName) { - return false; - } - - if (!directory || !directory->directory || !out_entry) { - return false; - } - - struct dirent dirent_buffer; - struct dirent* dirent; - int result = readdir_r(directory->directory, &dirent_buffer, &dirent); - if (result || !dirent) { - return false; - } - - starboard::strlcpy(out_entry, dirent->d_name, out_entry_size); - return true; -} - -} // namespace impl -} // namespace iso -} // namespace shared -} // namespace starboard -#endif // SB_API_VERSION < 17 - -#endif // STARBOARD_SHARED_ISO_IMPL_DIRECTORY_GET_NEXT_H_ diff --git a/starboard/shared/iso/impl/directory_impl.h b/starboard/shared/iso/impl/directory_impl.h deleted file mode 100644 index 883f29cec328..000000000000 --- a/starboard/shared/iso/impl/directory_impl.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_ISO_IMPL_DIRECTORY_IMPL_H_ -#define STARBOARD_SHARED_ISO_IMPL_DIRECTORY_IMPL_H_ - -#include "starboard/configuration.h" -#include "starboard/directory.h" - -#include "starboard/shared/internal_only.h" - -// Ensure SbDirectory is typedef'd to a SbDirectoryPrivate* that has a directory -// field. -SB_COMPILE_ASSERT(sizeof(((SbDirectory)0)->directory), - SbDirectoryPrivate_must_have_directory); - -#endif // STARBOARD_SHARED_ISO_IMPL_DIRECTORY_IMPL_H_ diff --git a/starboard/shared/iso/impl/directory_open.h b/starboard/shared/iso/impl/directory_open.h deleted file mode 100644 index 391bce427b64..000000000000 --- a/starboard/shared/iso/impl/directory_open.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef STARBOARD_SHARED_ISO_IMPL_DIRECTORY_OPEN_H_ -#define STARBOARD_SHARED_ISO_IMPL_DIRECTORY_OPEN_H_ -#if SB_API_VERSION < 17 - -#include "starboard/directory.h" - -#include -#include - -#include "starboard/file.h" - -#include "starboard/shared/internal_only.h" -#include "starboard/shared/iso/impl/directory_impl.h" - -namespace starboard { -namespace shared { -namespace iso { -namespace impl { - -SbDirectory SbDirectoryOpen(const char* path, SbFileError* out_error) { - if (!path) { - if (out_error) { - *out_error = kSbFileErrorNotFound; - } - return kSbDirectoryInvalid; - } - - DIR* dir = opendir(path); - if (!dir) { - if (out_error) { - switch (errno) { - case EACCES: - *out_error = kSbFileErrorAccessDenied; - break; - case ELOOP: - *out_error = kSbFileErrorFailed; - break; - case ENAMETOOLONG: - *out_error = kSbFileErrorInvalidOperation; - break; - case ENOENT: - *out_error = kSbFileErrorNotFound; - break; - case ENOTDIR: - *out_error = kSbFileErrorNotADirectory; - break; - case EMFILE: - case ENFILE: - *out_error = kSbFileErrorTooManyOpened; - break; - } - } - - return kSbDirectoryInvalid; - } - - SbDirectory result = new SbDirectoryPrivate(); - if (!result) { - closedir(dir); - if (out_error) { - *out_error = kSbFileErrorNoMemory; - } - return kSbDirectoryInvalid; - } - - result->directory = dir; - if (out_error) { - *out_error = kSbFileOk; - } - return result; -} - -} // namespace impl -} // namespace iso -} // namespace shared -} // namespace starboard -#endif // SB_API_VERSION < 17 - -#endif // STARBOARD_SHARED_ISO_IMPL_DIRECTORY_OPEN_H_ diff --git a/starboard/shared/iso/string_scan.cc b/starboard/shared/iso/string_scan.cc deleted file mode 100644 index 50c0fd4c60d6..000000000000 --- a/starboard/shared/iso/string_scan.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/string.h" - -#include -#include - -int SbStringScan(const char* buffer, const char* pattern, va_list arguments) { - return vsscanf(buffer, pattern, arguments); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/libjpeg/image_decode.cc b/starboard/shared/libjpeg/image_decode.cc deleted file mode 100644 index ac590d090c2f..000000000000 --- a/starboard/shared/libjpeg/image_decode.cc +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/image.h" - -#include "starboard/shared/libjpeg/jpeg_image_decoder.h" - -SbDecodeTarget SbImageDecode(SbDecodeTargetGraphicsContextProvider* provider, - void* data, - int data_size, - const char* mime_type, - SbDecodeTargetFormat format) { - if (data == NULL || !SbImageIsDecodeSupported(mime_type, format)) { - return kSbDecodeTargetInvalid; - } - - return starboard::shared::libjpeg::Decode( - provider, format, static_cast(data), data_size); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/libjpeg/image_is_decode_supported.cc b/starboard/shared/libjpeg/image_is_decode_supported.cc deleted file mode 100644 index 9effa2086caa..000000000000 --- a/starboard/shared/libjpeg/image_is_decode_supported.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/image.h" - -#include "starboard/common/string.h" -#include "starboard/decode_target.h" -#include "starboard/shared/starboard/application.h" - -bool SbImageIsDecodeSupported(const char* mime_type, - SbDecodeTargetFormat format) { - using starboard::shared::starboard::Application; - - auto command_line = Application::Get()->GetCommandLine(); - auto value = command_line->GetSwitchValue("enable_sb_image_decoder"); - if (value == "true") { - if (format != kSbDecodeTargetFormat1PlaneRGBA && - format != kSbDecodeTargetFormat1PlaneBGRA) { - return false; - } - return strcmp(mime_type, "image/jpeg") == 0; - } else { - return false; - } -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/linux/byte_swap.cc b/starboard/shared/linux/byte_swap.cc deleted file mode 100644 index b2a104c142b2..000000000000 --- a/starboard/shared/linux/byte_swap.cc +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Not breaking these functions up because however one is implemented, the -// others should be implemented similarly. - -#if SB_API_VERSION < 16 - -#include "starboard/byte_swap.h" - -#include - -int16_t SbByteSwapS16(int16_t value) { - return bswap_16(value); -} - -uint16_t SbByteSwapU16(uint16_t value) { - return bswap_16(value); -} - -int32_t SbByteSwapS32(int32_t value) { - return bswap_32(value); -} - -uint32_t SbByteSwapU32(uint32_t value) { - return bswap_32(value); -} - -int64_t SbByteSwapS64(int64_t value) { - return bswap_64(value); -} - -uint64_t SbByteSwapU64(uint64_t value) { - return bswap_64(value); -} - -#endif diff --git a/starboard/shared/linux/thread_get_name.cc b/starboard/shared/linux/thread_get_name.cc deleted file mode 100644 index e2dfe80c4510..000000000000 --- a/starboard/shared/linux/thread_get_name.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -void SbThreadGetName(char* buffer, int buffer_size) { - pthread_getname_np(pthread_self(), buffer, static_cast(buffer_size)); -} - -#endif diff --git a/starboard/shared/linux/thread_set_name.cc b/starboard/shared/linux/thread_set_name.cc deleted file mode 100644 index fbbe5a689743..000000000000 --- a/starboard/shared/linux/thread_set_name.cc +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/string.h" - -#include "starboard/configuration_constants.h" - -void SbThreadSetName(const char* name) { - // We don't want to rename the main thread. - if (SbThreadGetId() == getpid()) { - return; - } - - char buffer[kSbMaxThreadNameLength]; - - if (strlen(name) >= SB_ARRAY_SIZE_INT(buffer)) { - starboard::strlcpy(buffer, name, SB_ARRAY_SIZE_INT(buffer)); - name = buffer; - } - - if (pthread_setname_np(pthread_self(), name) != 0) { - SB_DLOG(ERROR) << "Failed to set thread name to " << name; - } -} - -#endif diff --git a/starboard/shared/nouser/user_get_current.cc b/starboard/shared/nouser/user_get_current.cc deleted file mode 100644 index a2fd18e15875..000000000000 --- a/starboard/shared/nouser/user_get_current.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/user.h" - -#include "starboard/shared/nouser/user_internal.h" - -// Nouser implementation of getting the current user. We always return a user -// with default attributes. -SbUser SbUserGetCurrent() { - return &starboard::shared::nouser::g_user; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/nouser/user_get_property.cc b/starboard/shared/nouser/user_get_property.cc deleted file mode 100644 index 9cbdaa4a359f..000000000000 --- a/starboard/shared/nouser/user_get_property.cc +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/user.h" - -#include - -#include "starboard/common/string.h" -#include "starboard/configuration_constants.h" -#include "starboard/shared/nouser/user_internal.h" - -int SbUserGetPropertySize(SbUser user, SbUserPropertyId property_id) { - if (!SbUserIsValid(user)) { - return 0; - } - - switch (property_id) { - case kSbUserPropertyUserName: - return static_cast(strlen(user->name) + 1); - - case kSbUserPropertyUserId: - return static_cast(strlen(user->id) + 1); - - default: - return 0; - } -} - -bool SbUserGetProperty(SbUser user, - SbUserPropertyId property_id, - char* out_value, - int value_size) { - if (!SbUserIsValid(user) || !out_value || - value_size < SbUserGetPropertySize(user, property_id)) { - return false; - } - - switch (property_id) { - case kSbUserPropertyUserName: - starboard::strlcpy(out_value, user->name, value_size); - return true; - - case kSbUserPropertyUserId: - starboard::strlcpy(out_value, user->id, value_size); - return true; - - default: - return false; - } -} - -#endif diff --git a/starboard/shared/nouser/user_get_signed_in.cc b/starboard/shared/nouser/user_get_signed_in.cc deleted file mode 100644 index 726ffd8cc602..000000000000 --- a/starboard/shared/nouser/user_get_signed_in.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/user.h" - -#include "starboard/shared/nouser/user_internal.h" - -// Nouser implementation of getting signed-in users. We always return one user -// with default attributes. -int SbUserGetSignedIn(SbUser* out_users, int users_size) { - if (out_users && users_size > 0) { - out_users[0] = &starboard::shared::nouser::g_user; - } - - return 1; -} - -#endif diff --git a/starboard/shared/nouser/user_internal.cc b/starboard/shared/nouser/user_internal.cc deleted file mode 100644 index 83bbba100c85..000000000000 --- a/starboard/shared/nouser/user_internal.cc +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/shared/nouser/user_internal.h" - -#include "starboard/user.h" - -namespace starboard { -namespace shared { -namespace nouser { -// The one instance of the signed-in user. -SbUserPrivate g_user = { - "user", - "user", -}; -} // namespace nouser -} // namespace shared -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/nouser/user_internal.h b/starboard/shared/nouser/user_internal.h deleted file mode 100644 index 728c4b94818f..000000000000 --- a/starboard/shared/nouser/user_internal.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_NOUSER_USER_INTERNAL_H_ -#define STARBOARD_SHARED_NOUSER_USER_INTERNAL_H_ - -#if SB_API_VERSION < 16 - -#include "starboard/shared/internal_only.h" -#include "starboard/user.h" - -struct SbUserPrivate { - static const int kMaxUserName = 256; - - const char name[kMaxUserName]; - const char id[kMaxUserName]; -}; - -namespace starboard { -namespace shared { -namespace nouser { -// The one instance of the signed-in user. -extern SbUserPrivate g_user; -} // namespace nouser -} // namespace shared -} // namespace starboard - -#endif // SB_API_VERSION < 16 - -#endif // STARBOARD_SHARED_NOUSER_USER_INTERNAL_H_ diff --git a/starboard/shared/opus/opus_audio_decoder.cc b/starboard/shared/opus/opus_audio_decoder.cc index 683e7fd1b29d..79b3a6ffc309 100644 --- a/starboard/shared/opus/opus_audio_decoder.cc +++ b/starboard/shared/opus/opus_audio_decoder.cc @@ -133,19 +133,11 @@ bool OpusAudioDecoder::DecodeInternal( audio_stream_info_.number_of_channels * frames_per_au_ * starboard::media::GetBytesPerSample(GetSampleType())); -#if SB_API_VERSION <= 15 && SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) - const char kDecodeFunctionName[] = "opus_multistream_decode"; - int decoded_frames = opus_multistream_decode( - decoder_, static_cast(input_buffer->data()), - input_buffer->size(), - reinterpret_cast(decoded_audio->data()), frames_per_au_, 0); -#else // SB_API_VERSION <= 15 && SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) const char kDecodeFunctionName[] = "opus_multistream_decode_float"; int decoded_frames = opus_multistream_decode_float( decoder_, static_cast(input_buffer->data()), input_buffer->size(), reinterpret_cast(decoded_audio->data()), frames_per_au_, 0); -#endif // SB_API_VERSION <= 15 && SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) if (decoded_frames == OPUS_BUFFER_TOO_SMALL && frames_per_au_ < kMaxOpusFramesPerAU) { frames_per_au_ = kMaxOpusFramesPerAU; @@ -274,11 +266,7 @@ bool OpusAudioDecoder::is_valid() const { SbMediaAudioSampleType OpusAudioDecoder::GetSampleType() const { SB_DCHECK(BelongsToCurrentThread()); -#if SB_API_VERSION <= 15 && SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) - return kSbMediaAudioSampleTypeInt16; -#else // SB_API_VERSION <= 15 && SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) return kSbMediaAudioSampleTypeFloat32; -#endif // SB_API_VERSION <= 15 && SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) } } // namespace opus diff --git a/starboard/shared/posix/directory_create.cc b/starboard/shared/posix/directory_create.cc deleted file mode 100644 index 42ab23b450c3..000000000000 --- a/starboard/shared/posix/directory_create.cc +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/directory.h" - -#include -#include - -#include - -#include "starboard/file.h" - -namespace { - -void RemoveTrailingSeparators(std::string* path) { - size_t found = path->find_last_not_of('/'); - if (found != std::string::npos) { - path->resize(found + 1); - } else { - path->resize(1); - } -} - -std::string GetParent(const std::string& path) { - size_t last_slash = path.find_last_of('/'); - if (last_slash != std::string::npos) { - std::string parent = path.substr(0, last_slash); - RemoveTrailingSeparators(&parent); - return parent; - } - - return ""; -} - -} // namespace - -#if SB_API_VERSION < 16 - -bool SbDirectoryCreate(const char* path) { - // Require a non-empty, absolute path. - if (!path || path[0] != '/') { - return false; - } - - // Clear trailing slashes. - std::string adjusted(path); - RemoveTrailingSeparators(&adjusted); - - if (SbDirectoryCanOpen(adjusted.c_str())) { - return true; - } - - std::string parent = GetParent(adjusted); - if (!parent.empty() && !SbDirectoryCanOpen(parent.c_str())) { - return false; - } - - if (mkdir(adjusted.c_str(), 0700) == 0) { - return true; - } - - // If mkdir failed, the directory may still exist now (because of another - // racing process or thread), so check again. - return SbDirectoryCanOpen(adjusted.c_str()); -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/posix/file_can_open.cc b/starboard/shared/posix/file_can_open.cc deleted file mode 100644 index 896e5faf8b56..000000000000 --- a/starboard/shared/posix/file_can_open.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_can_open.h" - -bool SbFileCanOpen(const char* path, int flags) { - return ::starboard::shared::posix::impl::FileCanOpen(path, flags); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/file_close.cc b/starboard/shared/posix/file_close.cc deleted file mode 100644 index f9a6f5d638e6..000000000000 --- a/starboard/shared/posix/file_close.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_close.h" - -bool SbFileClose(SbFile file) { - return ::starboard::shared::posix::impl::FileClose(file); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/file_delete.cc b/starboard/shared/posix/file_delete.cc deleted file mode 100644 index 3ad7ea095407..000000000000 --- a/starboard/shared/posix/file_delete.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_delete.h" - -bool SbFileDelete(const char* path) { - return ::starboard::shared::posix::impl::FileDelete(path); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/file_exists.cc b/starboard/shared/posix/file_exists.cc deleted file mode 100644 index 97774b07573d..000000000000 --- a/starboard/shared/posix/file_exists.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_exists.h" - -bool SbFileExists(const char* path) { - return ::starboard::shared::posix::impl::FileExists(path); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/posix/file_flush.cc b/starboard/shared/posix/file_flush.cc deleted file mode 100644 index 3f1a4c3c9751..000000000000 --- a/starboard/shared/posix/file_flush.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_flush.h" - -bool SbFileFlush(SbFile file) { - return ::starboard::shared::posix::impl::FileFlush(file); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/file_get_info.cc b/starboard/shared/posix/file_get_info.cc deleted file mode 100644 index 2443587bbce9..000000000000 --- a/starboard/shared/posix/file_get_info.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_get_info.h" - -bool SbFileGetInfo(SbFile file, SbFileInfo* out_info) { - return ::starboard::shared::posix::impl::FileGetInfo(file, out_info); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/file_get_path_info.cc b/starboard/shared/posix/file_get_path_info.cc deleted file mode 100644 index 3f5639cc5a3d..000000000000 --- a/starboard/shared/posix/file_get_path_info.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_get_path_info.h" - -bool SbFileGetPathInfo(const char* path, SbFileInfo* out_info) { - return ::starboard::shared::posix::impl::FileGetPathInfo(path, out_info); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/posix/file_open.cc b/starboard/shared/posix/file_open.cc deleted file mode 100644 index 56675c63fd7a..000000000000 --- a/starboard/shared/posix/file_open.cc +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_open.h" - -SbFile SbFileOpen(const char* path, - int flags, - bool* out_created, - SbFileError* out_error) { - return ::starboard::shared::posix::impl::FileOpen(path, flags, out_created, - out_error); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/file_read.cc b/starboard/shared/posix/file_read.cc deleted file mode 100644 index 3721a8b9b500..000000000000 --- a/starboard/shared/posix/file_read.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_read.h" - -int SbFileRead(SbFile file, char* data, int size) { - return ::starboard::shared::posix::impl::FileRead(file, data, size); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/file_seek.cc b/starboard/shared/posix/file_seek.cc deleted file mode 100644 index ba6ba4ab47b9..000000000000 --- a/starboard/shared/posix/file_seek.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_seek.h" - -int64_t SbFileSeek(SbFile file, SbFileWhence whence, int64_t offset) { - return ::starboard::shared::posix::impl::FileSeek(file, whence, offset); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/file_truncate.cc b/starboard/shared/posix/file_truncate.cc deleted file mode 100644 index f119fb3d0f4d..000000000000 --- a/starboard/shared/posix/file_truncate.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_truncate.h" - -bool SbFileTruncate(SbFile file, int64_t length) { - return ::starboard::shared::posix::impl::FileTruncate(file, length); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/file_write.cc b/starboard/shared/posix/file_write.cc deleted file mode 100644 index 118d183de2b6..000000000000 --- a/starboard/shared/posix/file_write.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_write.h" - -int SbFileWrite(SbFile file, const char* data, int size) { - return ::starboard::shared::posix::impl::FileWrite(file, data, size); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/impl/file_get_path_info.h b/starboard/shared/posix/impl/file_get_path_info.h index 588552c8c1c7..25968ecb3712 100644 --- a/starboard/shared/posix/impl/file_get_path_info.h +++ b/starboard/shared/posix/impl/file_get_path_info.h @@ -17,42 +17,6 @@ #ifndef STARBOARD_SHARED_POSIX_IMPL_FILE_GET_PATH_INFO_H_ #define STARBOARD_SHARED_POSIX_IMPL_FILE_GET_PATH_INFO_H_ -#include "starboard/file.h" - -#include -#include - -#include "starboard/shared/internal_only.h" -#include "starboard/shared/posix/impl/file_impl.h" - -namespace starboard { -namespace shared { -namespace posix { -namespace impl { - -bool FileGetPathInfo(const char* path, SbFileInfo* out_info) { - if (!path || path[0] == '\0' || !out_info) { - return false; - } - - struct stat file_info; - int result = stat(path, &file_info); - if (result) { - return false; - } - - out_info->creation_time = TimeTToWindowsUsec(file_info.st_ctime); - out_info->is_directory = S_ISDIR(file_info.st_mode); - out_info->is_symbolic_link = S_ISLNK(file_info.st_mode); - out_info->last_accessed = TimeTToWindowsUsec(file_info.st_atime); - out_info->last_modified = TimeTToWindowsUsec(file_info.st_mtime); - out_info->size = file_info.st_size; - return true; -} - -} // namespace impl -} // namespace posix -} // namespace shared -} // namespace starboard +#error This file is deprecated with SB_API_VERSION 16. #endif // STARBOARD_SHARED_POSIX_IMPL_FILE_GET_PATH_INFO_H_ diff --git a/starboard/shared/posix/log_is_tty.cc b/starboard/shared/posix/log_is_tty.cc deleted file mode 100644 index f4df478ffa0e..000000000000 --- a/starboard/shared/posix/log_is_tty.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 -#include "starboard/common/log.h" - -#include - -bool SbLogIsTty() { - return isatty(STDERR_FILENO) == 1; -} -#endif // SB_API_VERSION diff --git a/starboard/shared/posix/memory_flush.cc b/starboard/shared/posix/memory_flush.cc deleted file mode 100644 index 8606a8ecb1ed..000000000000 --- a/starboard/shared/posix/memory_flush.cc +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" - -#include - -#include - -#include "starboard/common/log.h" - -#if !SB_CAN(MAP_EXECUTABLE_MEMORY) -#error \ - "You shouldn't implement SbMemoryFlush unless you can map " \ - "memory pages as executable" -#endif - -void SbMemoryFlush(void* virtual_address, int64_t size_bytes) { - char* memory = reinterpret_cast(virtual_address); -#if !SB_IS(ARCH_ARM) && !SB_IS(ARCH_ARM64) - int result = msync(memory, size_bytes, MS_SYNC); - SB_DCHECK(result == 0) << "msync failed: 0x" << std::hex << result << " (" - << std::dec << result << "d)"; -#endif - -#if !defined(__has_builtin) -#define __has_builtin(a) (0) -#endif - -#if __has_builtin(__builtin___clear_cache) - __builtin___clear_cache(memory, memory + size_bytes); -#elif defined(__clear_cache) - __clear_cache(memory, memory + size_bytes); -#endif -} - -#endif diff --git a/starboard/shared/posix/memory_map.cc b/starboard/shared/posix/memory_map.cc deleted file mode 100644 index 97d9e38a9c1e..000000000000 --- a/starboard/shared/posix/memory_map.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" -#include "starboard/shared/posix/page_internal.h" - -void* SbMemoryMap(int64_t size_bytes, int flags, const char* name) { - void* memory = SbPageMap(size_bytes, flags, name); - return memory; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/posix/memory_protect.cc b/starboard/shared/posix/memory_protect.cc deleted file mode 100644 index f1f544b1a55a..000000000000 --- a/starboard/shared/posix/memory_protect.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/memory.h" -#include "starboard/shared/posix/page_internal.h" - -bool SbMemoryProtect(void* virtual_address, int64_t size_bytes, int flags) { - return SbPageProtect(virtual_address, size_bytes, flags); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/posix/memory_unmap.cc b/starboard/shared/posix/memory_unmap.cc deleted file mode 100644 index f539e17b355d..000000000000 --- a/starboard/shared/posix/memory_unmap.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" -#include "starboard/shared/posix/page_internal.h" - -bool SbMemoryUnmap(void* virtual_address, int64_t size_bytes) { - return SbPageUnmap(virtual_address, size_bytes); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/posix/page_internal.cc b/starboard/shared/posix/page_internal.cc index 97ca18459f87..cf39e2ea6b98 100644 --- a/starboard/shared/posix/page_internal.cc +++ b/starboard/shared/posix/page_internal.cc @@ -54,62 +54,8 @@ int SbMemoryMapFlagsToMmapProtect(int sb_flags) { return mmap_protect; } -#if SB_API_VERSION < 16 -int32_t s_tracked_page_count = 0; - -int32_t GetPageCount(size_t byte_count) { - return static_cast( - starboard::common::MemoryAlignToPageSize(byte_count) / kSbMemoryPageSize); -} - -void* SbPageMapUntracked(size_t size_bytes, - int flags, - const char* unused_name) { -#if SB_CAN(MAP_EXECUTABLE_MEMORY) - if (flags & kSbMemoryMapProtectExec) { - // Cobalt does not allow mapping executable memory directly. - return SB_MEMORY_MAP_FAILED; - } -#endif - int mmap_protect = SbMemoryMapFlagsToMmapProtect(flags); - void* mem = mmap(0, size_bytes, mmap_protect, MAP_PRIVATE | MAP_ANON, -1, 0); - return mem; -} - -bool SbPageUnmapUntracked(void* ptr, size_t size_bytes) { - return munmap(ptr, size_bytes) == 0; -} - -#endif // SB_API_VERSION < 16 - } // namespace -#if SB_API_VERSION < 16 -void* SbPageMap(size_t size_bytes, int flags, const char* unused_name) { - void* ret = SbPageMapUntracked(size_bytes, flags, NULL); - if (ret != SB_MEMORY_MAP_FAILED) { - SbAtomicNoBarrier_Increment(&s_tracked_page_count, - GetPageCount(size_bytes)); - } - return ret; -} - -bool SbPageUnmap(void* ptr, size_t size_bytes) { - SbAtomicNoBarrier_Increment(&s_tracked_page_count, -GetPageCount(size_bytes)); - return SbPageUnmapUntracked(ptr, size_bytes); -} - -bool SbPageProtect(void* virtual_address, int64_t size_bytes, int flags) { - int mmap_protect = SbMemoryMapFlagsToMmapProtect(flags); - return mprotect(virtual_address, size_bytes, mmap_protect) == 0; -} - -size_t SbPageGetMappedBytes() { - return static_cast(SbAtomicNoBarrier_Load(&s_tracked_page_count) * - kSbMemoryPageSize); -} -#endif // SB_API_VERSION < 16 - void* SbPageMapFile(void* addr, const char* path, SbMemoryMapFlags flags, diff --git a/starboard/shared/posix/page_internal.h b/starboard/shared/posix/page_internal.h index d65207405327..5dcc9154cfd4 100644 --- a/starboard/shared/posix/page_internal.h +++ b/starboard/shared/posix/page_internal.h @@ -34,32 +34,6 @@ void* SbPageMapFile(void* addr, int64_t file_offset, int64_t size); -#if SB_API_VERSION < 16 -// Allocates |size_bytes| worth of physical memory pages and maps them into an -// available virtual region. On some platforms, |name| appears in the debugger -// and can be up to 32 bytes. Returns SB_MEMORY_MAP_FAILED on failure, as NULL -// is a valid return value. -void* SbPageMap(size_t size_bytes, int flags, const char* name); - -// Unmap |size_bytes| of physical pages starting from |virtual_address|, -// returning true on success. After this, [virtual_address, virtual_address + -// size_bytes) will not be read/writable. SbUnmap() can unmap multiple -// contiguous regions that were mapped with separate calls to -// SbPageMap(). E.g. if one call to SbPageMap(0x1000) returns (void*)0xA000 and -// another call to SbPageMap(0x1000) returns (void*)0xB000, SbPageUnmap(0xA000, -// 0x2000) should free both. -bool SbPageUnmap(void* virtual_address, size_t size_bytes); - -// Change the protection of |size_bytes| of physical pages, starting from -// |virtual_address|, to |flags|, returning |true| on success. -bool SbPageProtect(void* virtual_address, int64_t size_bytes, int flags); - -// Returns the total amount, in bytes, currently allocated via Map(). Should -// always be a multiple of kSbMemoryPageSize. -size_t SbPageGetMappedBytes(); - -#endif // SB_API_VERSION < 16 - #ifdef __cplusplus } // extern "C" #endif diff --git a/starboard/shared/posix/string_compare_no_case.cc b/starboard/shared/posix/string_compare_no_case.cc deleted file mode 100644 index 79479e7eebe1..000000000000 --- a/starboard/shared/posix/string_compare_no_case.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#include // Non-standard, required for some platforms. -#include - -#if SB_API_VERSION < 16 -int SbStringCompareNoCase(const char* string1, const char* string2) { - return strcasecmp(string1, string2); -} -#endif diff --git a/starboard/shared/posix/string_compare_no_case_n.cc b/starboard/shared/posix/string_compare_no_case_n.cc deleted file mode 100644 index e56c4fb7ebce..000000000000 --- a/starboard/shared/posix/string_compare_no_case_n.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#include // Non-standard, required for some platforms. -#include - -#if SB_API_VERSION < 16 -int SbStringCompareNoCaseN(const char* string1, - const char* string2, - size_t count) { - return ::strncasecmp(string1, string2, count); -} -#endif diff --git a/starboard/shared/posix/string_format.cc b/starboard/shared/posix/string_format.cc deleted file mode 100644 index 6835afe2887a..000000000000 --- a/starboard/shared/posix/string_format.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#include -#include - -#if SB_API_VERSION < 16 -int SbStringFormat(char* out_buffer, - size_t buffer_size, - const char* format, - va_list arguments) { - return vsnprintf(out_buffer, buffer_size, format, arguments); -} -#endif diff --git a/starboard/shared/posix/string_format_wide.cc b/starboard/shared/posix/string_format_wide.cc deleted file mode 100644 index 9e77eec6d028..000000000000 --- a/starboard/shared/posix/string_format_wide.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#include -#include -#include - -#if SB_API_VERSION < 16 -int SbStringFormatWide(wchar_t* out_buffer, - size_t buffer_size, - const wchar_t* format, - va_list arguments) { - return vswprintf(out_buffer, buffer_size, format, arguments); -} -#endif diff --git a/starboard/shared/posix/time_get_monotonic_now.cc b/starboard/shared/posix/time_get_monotonic_now.cc deleted file mode 100644 index b5bdf4aa66f0..000000000000 --- a/starboard/shared/posix/time_get_monotonic_now.cc +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/posix/time_internal.h" - -SbTimeMonotonic SbTimeGetMonotonicNow() { - struct timespec time; - if (clock_gettime(CLOCK_MONOTONIC, &time) != 0) { - SB_NOTREACHED() << "clock_gettime(CLOCK_MONOTONIC) failed."; - return 0; - } - - return FromTimespecDelta(&time); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/posix/time_get_monotonic_thread_now.cc b/starboard/shared/posix/time_get_monotonic_thread_now.cc deleted file mode 100644 index 8b23b7ac1b55..000000000000 --- a/starboard/shared/posix/time_get_monotonic_thread_now.cc +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/posix/time_internal.h" - -SbTimeMonotonic SbTimeGetMonotonicThreadNow() { - struct timespec time; - if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &time) != 0) { - SB_NOTREACHED() << "clock_gettime(CLOCK_THREAD_CPUTIME_ID) failed."; - return 0; - } - - return FromTimespecDelta(&time); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/posix/time_get_now.cc b/starboard/shared/posix/time_get_now.cc deleted file mode 100644 index 0323fc43fbc3..000000000000 --- a/starboard/shared/posix/time_get_now.cc +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/posix/time_internal.h" - -SbTime SbTimeGetNow() { - struct timeval time; - if (gettimeofday(&time, NULL) != 0) { - SB_NOTREACHED() << "Could not determine time of day."; - return 0; - } - - return FromTimeval(&time); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/posix/time_internal.h b/starboard/shared/posix/time_internal.h index 6d75f49fae90..16221771b32e 100644 --- a/starboard/shared/posix/time_internal.h +++ b/starboard/shared/posix/time_internal.h @@ -15,46 +15,6 @@ #ifndef STARBOARD_SHARED_POSIX_TIME_INTERNAL_H_ #define STARBOARD_SHARED_POSIX_TIME_INTERNAL_H_ -#if SB_API_VERSION < 16 - -#include -#include - -#include "starboard/shared/internal_only.h" -#include "starboard/time.h" - -namespace { // NOLINT(build/namespaces_headers) -const int64_t kMillisecondsPerSecond = kSbTimeSecond / kSbTimeMillisecond; -const int64_t kNanosecondsPerMicrosecond = 1000; - -inline SbTime FromSeconds(int64_t secs) { - return secs * kSbTimeSecond; -} - -inline SbTime FromNanoseconds(int64_t ns) { - return ns / kNanosecondsPerMicrosecond; -} - -// Converts a timespec representing a duration into microseconds. -inline int64_t FromTimespecDelta(struct timespec* time) { - return FromSeconds(static_cast(time->tv_sec)) + - FromNanoseconds(static_cast(time->tv_nsec)); -} - -// Converts a timeval (relative to POSIX epoch) into microseconds since the -// Windows epoch (1601). -inline int64_t FromTimeval(const struct timeval* time) { - return SbTimeFromPosix(FromSeconds(static_cast(time->tv_sec)) + - time->tv_usec); -} - -// Converts a time_t (relative to POSIX epoch) into microseconds since the -// Windows epoch (1601). -inline int64_t FromTimeT(time_t time) { - return SbTimeFromPosix(FromSeconds(time)); -} -} // namespace - -#endif // SB_API_VERSION < 16 +#error This file is deprecated with SB_API_VERSION 16. #endif // STARBOARD_SHARED_POSIX_TIME_INTERNAL_H_ diff --git a/starboard/shared/posix/time_is_time_thread_now_supported.cc b/starboard/shared/posix/time_is_time_thread_now_supported.cc deleted file mode 100644 index bb0e7097b11a..000000000000 --- a/starboard/shared/posix/time_is_time_thread_now_supported.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -bool SbTimeIsTimeThreadNowSupported() { - return true; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/condition_variable_broadcast.cc b/starboard/shared/pthread/condition_variable_broadcast.cc deleted file mode 100644 index e45b259dac1d..000000000000 --- a/starboard/shared/pthread/condition_variable_broadcast.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/condition_variable.h" - -#include - -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::IsInitialized; - -bool SbConditionVariableBroadcast(SbConditionVariable* condition) { - if (!condition) { - return false; - } - - if (!IsInitialized( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->initialized_state))) { - // If the condition variable is not initialized yet, then there is nothing - // to signal so vacuously return true. - return true; - } - - return IsSuccess(pthread_cond_broadcast( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->condition))); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/condition_variable_create.cc b/starboard/shared/pthread/condition_variable_create.cc deleted file mode 100644 index 52a98a239062..000000000000 --- a/starboard/shared/pthread/condition_variable_create.cc +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/condition_variable.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::SetInitialized; - -namespace { -struct ConditionVariableAttributes { - public: - ConditionVariableAttributes() { - valid_ = IsSuccess(pthread_condattr_init(&attributes_)); - } - ~ConditionVariableAttributes() { - if (valid_) { - SB_CHECK(IsSuccess(pthread_condattr_destroy(&attributes_))); - } - } - - bool valid() const { return valid_; } - pthread_condattr_t* attributes() { return &attributes_; } - - private: - bool valid_; - pthread_condattr_t attributes_; -}; -} // namespace - -bool SbConditionVariableCreate(SbConditionVariable* out_condition, - SbMutex* opt_mutex) { - SB_COMPILE_ASSERT( - sizeof(SbConditionVariable) >= sizeof(SbConditionVariablePrivate), - sb_condition_variable_private_larger_than_sb_condition_variable); - if (!out_condition) { - return false; - } - - ConditionVariableAttributes attributes; - if (!attributes.valid()) { - SB_DLOG(ERROR) << "Failed to call pthread_condattr_init()."; - return false; - } - -#if !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) - // Always use CLOCK_MONOTONIC so that SbConditionVariableWaitTimed() will - // not be based off of the system clock (which can lead to erroneous - // behavior if the system clock is changed while a process is running). - if (!IsSuccess(pthread_condattr_setclock(attributes.attributes(), - CLOCK_MONOTONIC))) { - SB_DLOG(ERROR) << "Failed to call pthread_condattr_setclock()."; - return false; - } -#endif // !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) - - bool status = IsSuccess(pthread_cond_init( - &(SB_PTHREAD_INTERNAL_CONDITION(out_condition)->condition), - attributes.attributes())); - - // We mark that we are initialized regardless of whether initialization - // was successful or not. - SetInitialized( - &(SB_PTHREAD_INTERNAL_CONDITION(out_condition)->initialized_state)); - - if (!status) { - SB_DLOG(ERROR) << "Failed to call pthread_cond_init()."; - } - - return status; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/condition_variable_destroy.cc b/starboard/shared/pthread/condition_variable_destroy.cc deleted file mode 100644 index 9c8e30f4be9c..000000000000 --- a/starboard/shared/pthread/condition_variable_destroy.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/condition_variable.h" - -#include - -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::IsInitialized; - -bool SbConditionVariableDestroy(SbConditionVariable* condition) { - if (!condition) { - return false; - } - - if (!IsInitialized( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->initialized_state))) { - // If the condition variable is not initialized yet, then there is nothing - // to destroy so vacuously return true. - return true; - } - - return IsSuccess(pthread_cond_destroy( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->condition))); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/condition_variable_signal.cc b/starboard/shared/pthread/condition_variable_signal.cc deleted file mode 100644 index b8ee61d2f45a..000000000000 --- a/starboard/shared/pthread/condition_variable_signal.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/condition_variable.h" - -#include - -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::IsInitialized; - -bool SbConditionVariableSignal(SbConditionVariable* condition) { - if (!condition) { - return false; - } - - if (!IsInitialized( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->initialized_state))) { - // If the condition variable is not initialized yet, then there is nothing - // to signal so vacuously return true. - return true; - } - - return IsSuccess(pthread_cond_signal( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->condition))); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/condition_variable_wait.cc b/starboard/shared/pthread/condition_variable_wait.cc deleted file mode 100644 index 397d94d078ab..000000000000 --- a/starboard/shared/pthread/condition_variable_wait.cc +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/condition_variable.h" - -#include - -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::EnsureInitialized; - -SbConditionVariableResult SbConditionVariableWait( - SbConditionVariable* condition, - SbMutex* mutex) { - if (!condition || !mutex) { - return kSbConditionVariableFailed; - } - - if (!EnsureInitialized( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->initialized_state))) { - // The condition variable is set to SB_CONDITION_VARIABLE_INITIALIZER and - // is uninitialized, so call SbConditionVariableCreate() to initialize the - // condition variable. SbConditionVariableCreate() is responsible for - // marking the variable as initialized. - SbConditionVariableCreate(condition, mutex); - } - - if (IsSuccess(pthread_cond_wait( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->condition), - SB_PTHREAD_INTERNAL_MUTEX(mutex)))) { - return kSbConditionVariableSignaled; - } - - return kSbConditionVariableFailed; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/condition_variable_wait_timed.cc b/starboard/shared/pthread/condition_variable_wait_timed.cc deleted file mode 100644 index 8807680cecd0..000000000000 --- a/starboard/shared/pthread/condition_variable_wait_timed.cc +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/condition_variable.h" - -#include -#include -#include - -#include "starboard/common/time.h" -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::EnsureInitialized; - -SbConditionVariableResult SbConditionVariableWaitTimed( - SbConditionVariable* condition, - SbMutex* mutex, - int64_t timeout) { - if (!condition || !mutex) { - return kSbConditionVariableFailed; - } - - if (timeout < 0) { - timeout = 0; - } - -#if !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) - int64_t timeout_time_usec = starboard::CurrentMonotonicTime() + timeout; -#else // !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) - int64_t timeout_time_usec = starboard::CurrentPosixTime() + timeout; -#endif // !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) - - // Detect overflow if timeout is near kSbInt64Max. Since timeout can't be - // negative at this point, if it goes negative after adding now, we know we've - // gone over. Especially posix now, which has a 400 year advantage over - // Chromium (Windows) now. - if (timeout_time_usec < 0) { - timeout_time_usec = kSbInt64Max; - } - - struct timespec timeout_ts; - timeout_ts.tv_sec = timeout_time_usec / 1'000'000; - timeout_ts.tv_nsec = (timeout_time_usec % 1'000'000) * 1000; - - if (!EnsureInitialized( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->initialized_state))) { - // The condition variable is set to SB_CONDITION_VARIABLE_INITIALIZER and - // is uninitialized, so call SbConditionVariableCreate() to initialize the - // condition variable. SbConditionVariableCreate() is responsible for - // marking the variable as initialized. - SbConditionVariableCreate(condition, mutex); - } - - int result = pthread_cond_timedwait( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->condition), - SB_PTHREAD_INTERNAL_MUTEX(mutex), &timeout_ts); - if (IsSuccess(result)) { - return kSbConditionVariableSignaled; - } - - if (result == ETIMEDOUT) { - return kSbConditionVariableTimedOut; - } - - return kSbConditionVariableFailed; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/mutex_acquire.cc b/starboard/shared/pthread/mutex_acquire.cc deleted file mode 100644 index a9f4d26b7eed..000000000000 --- a/starboard/shared/pthread/mutex_acquire.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -#include - -#include "starboard/common/experimental/concurrency_debug.h" -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::EnsureInitialized; -using starboard::shared::starboard::SetInitialized; - -SbMutexResult SbMutexAcquire(SbMutex* mutex) { - if (!mutex) { - return kSbMutexDestroyed; - } - - if (!EnsureInitialized(&(SB_INTERNAL_MUTEX(mutex)->initialized_state))) { - *SB_PTHREAD_INTERNAL_MUTEX(mutex) = PTHREAD_MUTEX_INITIALIZER; - SetInitialized(&(SB_INTERNAL_MUTEX(mutex)->initialized_state)); - } - -#if SB_ENABLE_CONCURRENCY_DEBUG - starboard::experimental::ScopedMutexWaitTracker tracker(mutex); - if (tracker.acquired()) { - return kSbMutexAcquired; - } -#endif // SB_ENABLE_CONCURRENCY_DEBUG - int result = pthread_mutex_lock(SB_PTHREAD_INTERNAL_MUTEX(mutex)); - if (IsSuccess(result)) { - return kSbMutexAcquired; - } - - return kSbMutexBusy; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/mutex_acquire_try.cc b/starboard/shared/pthread/mutex_acquire_try.cc deleted file mode 100644 index 58fb709b5e3a..000000000000 --- a/starboard/shared/pthread/mutex_acquire_try.cc +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -#include - -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::EnsureInitialized; -using starboard::shared::starboard::SetInitialized; - -SbMutexResult SbMutexAcquireTry(SbMutex* mutex) { - if (!mutex) { - return kSbMutexDestroyed; - } - - if (!EnsureInitialized(&(SB_INTERNAL_MUTEX(mutex)->initialized_state))) { - *SB_PTHREAD_INTERNAL_MUTEX(mutex) = PTHREAD_MUTEX_INITIALIZER; - SetInitialized(&(SB_INTERNAL_MUTEX(mutex)->initialized_state)); - } - - int result = pthread_mutex_trylock(SB_PTHREAD_INTERNAL_MUTEX(mutex)); - if (IsSuccess(result)) { - return kSbMutexAcquired; - } - - return kSbMutexBusy; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/mutex_create.cc b/starboard/shared/pthread/mutex_create.cc deleted file mode 100644 index e24abce5dd2a..000000000000 --- a/starboard/shared/pthread/mutex_create.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::SetInitialized; - -bool SbMutexCreate(SbMutex* mutex) { - SB_COMPILE_ASSERT(sizeof(SbMutex) >= sizeof(SbMutexPrivate), - sb_mutex_private_larger_than_sb_mutex); - if (!mutex) { - return false; - } - - SetInitialized(&(SB_INTERNAL_MUTEX(mutex)->initialized_state)); - return IsSuccess(pthread_mutex_init(SB_PTHREAD_INTERNAL_MUTEX(mutex), NULL)); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/mutex_destroy.cc b/starboard/shared/pthread/mutex_destroy.cc deleted file mode 100644 index 754c52d14019..000000000000 --- a/starboard/shared/pthread/mutex_destroy.cc +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/configuration.h" -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::IsInitialized; - -bool SbMutexDestroy(SbMutex* mutex) { - if (!mutex) { - return false; - } - - if (!IsInitialized(&(SB_INTERNAL_MUTEX(mutex)->initialized_state))) { - // If the mutex is not initialized there is nothing to destroy. - return true; - } - - // Both trying to recursively acquire a mutex that is locked by the calling - // thread, as well as deleting a locked mutex, result in undefined behavior. - return IsSuccess(pthread_mutex_destroy(SB_PTHREAD_INTERNAL_MUTEX(mutex))); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/mutex_release.cc b/starboard/shared/pthread/mutex_release.cc deleted file mode 100644 index 0dbe87f363ce..000000000000 --- a/starboard/shared/pthread/mutex_release.cc +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -#include - -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::IsInitialized; - -bool SbMutexRelease(SbMutex* mutex) { - if (!mutex) { - return false; - } - - if (!IsInitialized(&(SB_INTERNAL_MUTEX(mutex)->initialized_state))) { - // If the mutex is not initialized there is nothing to release. - return true; - } - return IsSuccess(pthread_mutex_unlock(SB_PTHREAD_INTERNAL_MUTEX(mutex))); -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/once.cc b/starboard/shared/pthread/once.cc deleted file mode 100644 index b0c757508c45..000000000000 --- a/starboard/shared/pthread/once.cc +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/once.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::EnsureInitialized; -using starboard::shared::starboard::SetInitialized; - -bool SbOnce(SbOnceControl* once_control, SbOnceInitRoutine init_routine) { - SB_COMPILE_ASSERT(sizeof(SbOnceControl) >= sizeof(SbOnceControlPrivate), - sb_once_control_private_larger_than_sb_once_control); - if (once_control == NULL) { - return false; - } - if (init_routine == NULL) { - return false; - } - if (!EnsureInitialized( - &(SB_INTERNAL_ONCE(once_control)->initialized_state))) { - *SB_PTHREAD_INTERNAL_ONCE(once_control) = PTHREAD_ONCE_INIT; - SetInitialized(&(SB_INTERNAL_ONCE(once_control)->initialized_state)); - } - - return pthread_once(SB_PTHREAD_INTERNAL_ONCE(once_control), init_routine) == - 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_create.cc b/starboard/shared/pthread/thread_create.cc deleted file mode 100644 index 41167eb00f54..000000000000 --- a/starboard/shared/pthread/thread_create.cc +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/string.h" -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/thread_create_priority.h" -#include "starboard/shared/pthread/types_internal.h" - -namespace starboard { -namespace shared { -namespace pthread {} // namespace pthread -} // namespace shared -} // namespace starboard - -namespace { - -struct ThreadParams { - SbThreadAffinity affinity; - SbThreadEntryPoint entry_point; - char name[128] = {}; - void* context; - SbThreadPriority priority; -}; - -void* ThreadFunc(void* context) { - ThreadParams* thread_params = static_cast(context); - SbThreadEntryPoint entry_point = thread_params->entry_point; - void* real_context = thread_params->context; - SbThreadAffinity affinity = thread_params->affinity; - if (thread_params->name[0] != '\0') { - pthread_setname_np(pthread_self(), thread_params->name); - } - - starboard::shared::pthread::ThreadSetPriority(thread_params->priority); - - delete thread_params; - -#if defined(_GNU_SOURCE) // sched_setaffinity is a GNU extension - if (SbThreadIsValidAffinity(affinity)) { - cpu_set_t cpu_set; - CPU_ZERO(&cpu_set); - CPU_SET(affinity, &cpu_set); - sched_setaffinity(0, sizeof(cpu_set), &cpu_set); - } -#endif - - return entry_point(real_context); -} - -} // namespace - -SbThread SbThreadCreate(int64_t stack_size, - SbThreadPriority priority, - SbThreadAffinity affinity, - bool joinable, - const char* name, - SbThreadEntryPoint entry_point, - void* context) { - if (stack_size < 0 || !entry_point) { - return kSbThreadInvalid; - } - -#if defined(ADDRESS_SANITIZER) - // Set a big thread stack size when in ADDRESS_SANITIZER mode. - // This eliminates buffer overflows for deeply nested callstacks. - if (stack_size == 0) { - stack_size = 4096 * 1024; // 4MB - } -#endif - - pthread_attr_t attributes; - int result = pthread_attr_init(&attributes); - if (!IsSuccess(result)) { - return kSbThreadInvalid; - } - - pthread_attr_setdetachstate( - &attributes, - (joinable ? PTHREAD_CREATE_JOINABLE : PTHREAD_CREATE_DETACHED)); - - if (stack_size > 0) { - pthread_attr_setstacksize(&attributes, stack_size); - } - - ThreadParams* params = new ThreadParams(); - params->affinity = affinity; - params->entry_point = entry_point; - params->context = context; - - if (name) { - starboard::strlcpy(params->name, name, SB_ARRAY_SIZE_INT(params->name)); - } else { - params->name[0] = '\0'; - } - - params->priority = priority; - - SbThread thread = kSbThreadInvalid; - SB_COMPILE_ASSERT(sizeof(SbThread) >= sizeof(pthread_t), - pthread_t_larger_than_sb_thread); - result = pthread_create(SB_PTHREAD_INTERNAL_THREAD_PTR(thread), &attributes, - ThreadFunc, params); - - pthread_attr_destroy(&attributes); - if (IsSuccess(result)) { - return thread; - } - - return kSbThreadInvalid; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_create_local_key.cc b/starboard/shared/pthread/thread_create_local_key.cc deleted file mode 100644 index 59112c1310d0..000000000000 --- a/starboard/shared/pthread/thread_create_local_key.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/pthread/thread_local_key_internal.h" - -SbThreadLocalKey SbThreadCreateLocalKey(SbThreadLocalDestructor destructor) { - SbThreadLocalKey key = new SbThreadLocalKeyPrivate(); - if (!IsSuccess(pthread_key_create(&key->key, destructor))) { - delete key; - return kSbThreadLocalKeyInvalid; - } - return key; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_destroy_local_key.cc b/starboard/shared/pthread/thread_destroy_local_key.cc deleted file mode 100644 index 264bd10e2b4b..000000000000 --- a/starboard/shared/pthread/thread_destroy_local_key.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/pthread/thread_local_key_internal.h" - -void SbThreadDestroyLocalKey(SbThreadLocalKey key) { - if (!SbThreadIsValidLocalKey(key)) { - return; - } - - pthread_key_delete(key->key); - delete key; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_detach.cc b/starboard/shared/pthread/thread_detach.cc deleted file mode 100644 index 3a760d83727c..000000000000 --- a/starboard/shared/pthread/thread_detach.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/pthread/types_internal.h" - -void SbThreadDetach(SbThread thread) { - if (!SbThreadIsValid(thread)) { - return; - } - - pthread_detach(SB_PTHREAD_INTERNAL_THREAD(thread)); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_get_current.cc b/starboard/shared/pthread/thread_get_current.cc deleted file mode 100644 index 62a5d98576ca..000000000000 --- a/starboard/shared/pthread/thread_get_current.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/pthread/types_internal.h" - -SbThread SbThreadGetCurrent() { - return SB_THREAD(pthread_self()); -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_get_local_value.cc b/starboard/shared/pthread/thread_get_local_value.cc deleted file mode 100644 index 21a79180dbc3..000000000000 --- a/starboard/shared/pthread/thread_get_local_value.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/pthread/thread_local_key_internal.h" - -void* SbThreadGetLocalValue(SbThreadLocalKey key) { - if (!SbThreadIsValidLocalKey(key)) { - return NULL; - } - - return pthread_getspecific(key->key); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_is_equal.cc b/starboard/shared/pthread/thread_is_equal.cc deleted file mode 100644 index 7131ef3cdfe8..000000000000 --- a/starboard/shared/pthread/thread_is_equal.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/pthread/types_internal.h" - -bool SbThreadIsEqual(SbThread thread1, SbThread thread2) { - return pthread_equal(SB_PTHREAD_INTERNAL_THREAD(thread1), - SB_PTHREAD_INTERNAL_THREAD(thread2)) != 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_join.cc b/starboard/shared/pthread/thread_join.cc deleted file mode 100644 index 3136701fdb68..000000000000 --- a/starboard/shared/pthread/thread_join.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" - -bool SbThreadJoin(SbThread thread, void** out_return) { - if (!SbThreadIsValid(thread)) { - return false; - } - - void* joined_return = NULL; - int result = pthread_join(SB_PTHREAD_INTERNAL_THREAD(thread), &joined_return); - if (!IsSuccess(result)) { - return false; - } - - if (out_return) { - *out_return = joined_return; - } - - return true; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_local_key_internal.h b/starboard/shared/pthread/thread_local_key_internal.h index adb74f3882ba..8a1073eb2ba8 100644 --- a/starboard/shared/pthread/thread_local_key_internal.h +++ b/starboard/shared/pthread/thread_local_key_internal.h @@ -15,18 +15,6 @@ #ifndef STARBOARD_SHARED_PTHREAD_THREAD_LOCAL_KEY_INTERNAL_H_ #define STARBOARD_SHARED_PTHREAD_THREAD_LOCAL_KEY_INTERNAL_H_ -#if SB_API_VERSION < 16 +#error This file is deprecated with SB_API_VERSION 16. -#include - -#include "starboard/shared/internal_only.h" -#include "starboard/shared/pthread/is_success.h" -#include "starboard/thread.h" - -struct SbThreadLocalKeyPrivate { - // The underlying thread-local variable handle. - pthread_key_t key; -}; - -#endif // SB_API_VERSION < 16 #endif // STARBOARD_SHARED_PTHREAD_THREAD_LOCAL_KEY_INTERNAL_H_ diff --git a/starboard/shared/pthread/thread_sampler_create.cc b/starboard/shared/pthread/thread_sampler_create.cc index 8968e224ef4f..7d930c28b94a 100644 --- a/starboard/shared/pthread/thread_sampler_create.cc +++ b/starboard/shared/pthread/thread_sampler_create.cc @@ -14,18 +14,9 @@ #include "starboard/shared/pthread/thread_sampler_internal.h" -#if SB_API_VERSION < 16 -SbThreadSampler SbThreadSamplerCreate(SbThread thread) { - if (!SbThreadIsValid(thread)) { - return kSbThreadSamplerInvalid; - } - return new SbThreadSamplerPrivate(thread); -} -#else SbThreadSampler SbThreadSamplerCreate(pthread_t thread) { if (thread == 0) { return kSbThreadSamplerInvalid; } return new SbThreadSamplerPrivate(thread); } -#endif diff --git a/starboard/shared/pthread/thread_sampler_internal.cc b/starboard/shared/pthread/thread_sampler_internal.cc index 744d5de264a6..282ae02dc2cc 100644 --- a/starboard/shared/pthread/thread_sampler_internal.cc +++ b/starboard/shared/pthread/thread_sampler_internal.cc @@ -130,11 +130,7 @@ void SignalHandler::HandleProfilerSignal(int signal, } // namespace -#if SB_API_VERSION < 16 -SbThreadSamplerPrivate::SbThreadSamplerPrivate(SbThread thread) -#else SbThreadSamplerPrivate::SbThreadSamplerPrivate(pthread_t thread) -#endif : thread_(thread) { SignalHandler::AddSampler(); } diff --git a/starboard/shared/pthread/thread_sampler_internal.h b/starboard/shared/pthread/thread_sampler_internal.h index a7b4c4304a39..11fddf3623c5 100644 --- a/starboard/shared/pthread/thread_sampler_internal.h +++ b/starboard/shared/pthread/thread_sampler_internal.h @@ -21,27 +21,15 @@ class SbThreadSamplerPrivate { public: -#if SB_API_VERSION < 16 - explicit SbThreadSamplerPrivate(SbThread thread); -#else explicit SbThreadSamplerPrivate(pthread_t thread); -#endif ~SbThreadSamplerPrivate(); SbThreadContext Freeze(); bool Thaw(); -#if SB_API_VERSION < 16 - SbThread thread() { return thread_; } -#else pthread_t thread() { return thread_; } -#endif private: -#if SB_API_VERSION < 16 - SbThread thread_; -#else pthread_t thread_; -#endif }; #endif // STARBOARD_SHARED_PTHREAD_THREAD_SAMPLER_INTERNAL_H_ diff --git a/starboard/shared/pthread/thread_set_local_value.cc b/starboard/shared/pthread/thread_set_local_value.cc deleted file mode 100644 index 1261d4c83c37..000000000000 --- a/starboard/shared/pthread/thread_set_local_value.cc +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/pthread/thread_local_key_internal.h" - -bool SbThreadSetLocalValue(SbThreadLocalKey key, void* value) { - if (!SbThreadIsValidLocalKey(key)) { - return false; - } - - if (IsSuccess(pthread_setspecific(key->key, value))) { - return true; - } - - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/starboard/directory_can_open.cc b/starboard/shared/starboard/directory_can_open.cc deleted file mode 100644 index 1c54230c910a..000000000000 --- a/starboard/shared/starboard/directory_can_open.cc +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 16 - -#include "starboard/directory.h" - -#include "starboard/file.h" - -bool SbDirectoryCanOpen(const char* path) { - if (!path || !path[0]) { - return false; - } - - SbFileInfo info; - bool result = SbFileGetPathInfo(path, &info); - if (!result) { - return false; - } - - return info.is_directory; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/starboard/file_mode_string_to_flags.cc b/starboard/shared/starboard/file_mode_string_to_flags.cc deleted file mode 100644 index d6c217869a45..000000000000 --- a/starboard/shared/starboard/file_mode_string_to_flags.cc +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/common/log.h" -#include "starboard/common/string.h" -#include "starboard/file.h" - -namespace { -bool IsUpdate(const char* mode) { - for (const char* m = mode; *m != '\0'; ++m) { - if (*m == '+') { - return true; - } - } - - return false; -} -} // namespace - -int SbFileModeStringToFlags(const char* mode) { - if (!mode) { - return 0; - } - - int length = static_cast(strlen(mode)); - if (length < 1) { - return 0; - } - - int flags = 0; - switch (mode[0]) { - case 'r': - if (IsUpdate(mode + 1)) { - flags |= kSbFileWrite; - } - flags |= kSbFileOpenOnly | kSbFileRead; - break; - case 'w': - if (IsUpdate(mode + 1)) { - flags |= kSbFileRead; - } - flags |= kSbFileCreateAlways | kSbFileWrite; - break; - case 'a': - if (IsUpdate(mode + 1)) { - flags |= kSbFileRead; - } - flags |= kSbFileOpenAlways | kSbFileWrite; - break; - default: - SB_NOTREACHED(); - break; - } - return flags; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/starboard/file_storage/storage_delete_record.cc b/starboard/shared/starboard/file_storage/storage_delete_record.cc index 0d1bf129c858..0f8ab8ffc8ec 100644 --- a/starboard/shared/starboard/file_storage/storage_delete_record.cc +++ b/starboard/shared/starboard/file_storage/storage_delete_record.cc @@ -21,12 +21,7 @@ #include "starboard/configuration_constants.h" #include "starboard/shared/starboard/file_storage/storage_internal.h" -#if SB_API_VERSION < 16 -#include "starboard/user.h" -bool SbStorageDeleteRecord(SbUser user, const char* name) { -#else bool SbStorageDeleteRecord(const char* name) { -#endif // SB_API_VERSION < 16 std::vector path(kSbFileMaxPath); bool success = starboard::shared::starboard::GetStorageFilePath( name, path.data(), static_cast(path.size())); diff --git a/starboard/shared/starboard/file_storage/storage_open_record.cc b/starboard/shared/starboard/file_storage/storage_open_record.cc index eaa32c79790e..945ba2260e10 100644 --- a/starboard/shared/starboard/file_storage/storage_open_record.cc +++ b/starboard/shared/starboard/file_storage/storage_open_record.cc @@ -23,12 +23,7 @@ #include "starboard/configuration_constants.h" #include "starboard/shared/starboard/file_storage/storage_internal.h" -#if SB_API_VERSION < 16 -#include "starboard/user.h" -SbStorageRecord SbStorageOpenRecord(SbUser user, const char* name) { -#else SbStorageRecord SbStorageOpenRecord(const char* name) { -#endif // SB_API_VERSION < 16 std::vector path(kSbFileMaxPath); bool success = starboard::shared::starboard::GetStorageFilePath( name, path.data(), static_cast(path.size())); diff --git a/starboard/shared/starboard/media/media_get_buffer_storage_type.cc b/starboard/shared/starboard/media/media_get_buffer_storage_type.cc deleted file mode 100644 index 5cb8977c078b..000000000000 --- a/starboard/shared/starboard/media/media_get_buffer_storage_type.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/media.h" - -#if SB_API_VERSION < 16 -SbMediaBufferStorageType SbMediaGetBufferStorageType() { - return kSbMediaBufferStorageTypeMemory; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/starboard/media/media_util.cc b/starboard/shared/starboard/media/media_util.cc index e0541d47dc08..d0a5cdf2f7d1 100644 --- a/starboard/shared/starboard/media/media_util.cc +++ b/starboard/shared/starboard/media/media_util.cc @@ -133,16 +133,6 @@ AudioStreamInfo& AudioStreamInfo::operator=( void AudioStreamInfo::ConvertTo( SbMediaAudioStreamInfo* audio_stream_info) const { Assign(*this, audio_stream_info); - -#if SB_API_VERSION < 15 - SB_DCHECK(audio_stream_info); - audio_stream_info->format_tag = 0xff; - audio_stream_info->block_alignment = 4; - audio_stream_info->average_bytes_per_second = - audio_stream_info->samples_per_second * - audio_stream_info->number_of_channels * - audio_stream_info->bits_per_sample / 8; -#endif // SB_API_VERSION < 15 } void AudioStreamInfo::ConvertTo( diff --git a/starboard/shared/starboard/memory.cc b/starboard/shared/starboard/memory.cc deleted file mode 100644 index ccd1d97a80a9..000000000000 --- a/starboard/shared/starboard/memory.cc +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" -#include "starboard/atomic.h" -#include "starboard/common/log.h" - -namespace { - -inline void* SbMemoryAllocateImpl(size_t size); -inline void* SbMemoryAllocateAlignedImpl(size_t alignment, size_t size); -inline void* SbMemoryReallocateImpl(void* memory, size_t size); - -} // namespace - -void* SbMemoryAllocate(size_t size) { - void* memory = SbMemoryAllocateImpl(size); - return memory; -} - -void* SbMemoryAllocateNoReport(size_t size) { - return SbMemoryAllocate(size); -} - -void* SbMemoryAllocateAligned(size_t alignment, size_t size) { - void* memory = SbMemoryAllocateAlignedImpl(alignment, size); - return memory; -} - -void* SbMemoryReallocate(void* memory, size_t size) { -#if !defined(COBALT_BUILD_TYPE_GOLD) - SB_CHECK((size != 0) || (memory == nullptr)) - << "Calling SbMemoryReallocate with a non-null pointer and size 0 is not " - "guaranteed to release the memory, and therefore may leak memory."; -#endif - void* new_memory = SbMemoryReallocateImpl(memory, size); - return new_memory; -} - -void SbMemoryDeallocate(void* memory) { - // Report must happen first or else a race condition allows the memory to - // be freed and then reported as allocated, before the allocation is removed. - SbMemoryFree(memory); -} - -void SbMemoryDeallocateNoReport(void* memory) { - SbMemoryDeallocate(memory); -} - -void SbMemoryDeallocateAligned(void* memory) { - // Report must happen first or else a race condition allows the memory to - // be freed and then reported as allocated, before the allocation is removed. - SbMemoryFreeAligned(memory); -} - -// Same as SbMemoryReallocateUnchecked, but will abort() in the case of an -// allocation failure -void* SbMemoryReallocateChecked(void* memory, size_t size) { - void* address = SbMemoryReallocateUnchecked(memory, size); - SbAbortIfAllocationFailed(size, address); - return address; -} - -// Same as SbMemoryAllocateAlignedUnchecked, but will abort() in the case of an -// allocation failure -void* SbMemoryAllocateAlignedChecked(size_t alignment, size_t size) { - void* address = SbMemoryAllocateAlignedUnchecked(alignment, size); - SbAbortIfAllocationFailed(size, address); - return address; -} - -void* SbMemoryAllocateChecked(size_t size) { - void* address = SbMemoryAllocateUnchecked(size); - SbAbortIfAllocationFailed(size, address); - return address; -} - -namespace { - -inline void* SbMemoryAllocateImpl(size_t size) { -#if SB_ABORT_ON_ALLOCATION_FAILURE - return SbMemoryAllocateChecked(size); -#else - return SbMemoryAllocateUnchecked(size); -#endif -} - -inline void* SbMemoryAllocateAlignedImpl(size_t alignment, size_t size) { -#if SB_ABORT_ON_ALLOCATION_FAILURE - return SbMemoryAllocateAlignedChecked(alignment, size); -#else - return SbMemoryAllocateAlignedUnchecked(alignment, size); -#endif -} - -inline void* SbMemoryReallocateImpl(void* memory, size_t size) { -#if SB_ABORT_ON_ALLOCATION_FAILURE - return SbMemoryReallocateChecked(memory, size); -#else - return SbMemoryReallocateUnchecked(memory, size); -#endif -} - -} // namespace - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/starboard/string_duplicate.cc b/starboard/shared/starboard/string_duplicate.cc deleted file mode 100644 index db66152ed262..000000000000 --- a/starboard/shared/starboard/string_duplicate.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/string.h" - -#include "starboard/common/log.h" -#include "starboard/memory.h" - -char* SbStringDuplicate(const char* source) { - size_t length = strlen(source); - char* result = static_cast(SbMemoryAllocate(length + 1)); - SB_DCHECK(length < kSbInt32Max); - int int_length = static_cast(length + 1); - starboard::strlcpy(result, source, int_length); - - return result; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/accessibility_get_caption_settings.cc b/starboard/shared/stub/accessibility_get_caption_settings.cc deleted file mode 100644 index b0fc543a3e04..000000000000 --- a/starboard/shared/stub/accessibility_get_caption_settings.cc +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/accessibility.h" -#include "starboard/common/memory.h" - -bool SbAccessibilityGetCaptionSettings( - SbAccessibilityCaptionSettings* caption_settings) { - if (!caption_settings || - !starboard::common::MemoryIsZero( - caption_settings, sizeof(SbAccessibilityCaptionSettings))) { - return false; - } - - // Since kSbAccessibilityCaptionStateUnsupported == 0, there is no need to - // explicitly set states to kSbAccessibilityCaptionStateUnsupported. - return true; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/accessibility_get_display_settings.cc b/starboard/shared/stub/accessibility_get_display_settings.cc deleted file mode 100644 index 493666c1b576..000000000000 --- a/starboard/shared/stub/accessibility_get_display_settings.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/accessibility.h" - -#include "starboard/common/memory.h" - -bool SbAccessibilityGetDisplaySettings( - SbAccessibilityDisplaySettings* out_setting) { - if (!out_setting || - !starboard::common::MemoryIsZero( - out_setting, sizeof(SbAccessibilityDisplaySettings))) { - return false; - } - out_setting->has_high_contrast_text_setting = false; - return true; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/accessibility_get_text_to_speech_settings.cc b/starboard/shared/stub/accessibility_get_text_to_speech_settings.cc deleted file mode 100644 index 0ae831dbfc1a..000000000000 --- a/starboard/shared/stub/accessibility_get_text_to_speech_settings.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/accessibility.h" - -#include "starboard/common/memory.h" - -bool SbAccessibilityGetTextToSpeechSettings( - SbAccessibilityTextToSpeechSettings* out_setting) { - if (!out_setting || - !starboard::common::MemoryIsZero( - out_setting, sizeof(SbAccessibilityTextToSpeechSettings))) { - return false; - } - out_setting->has_text_to_speech_setting = false; - return true; -} - -#endif diff --git a/starboard/shared/stub/accessibility_set_captions_enabled.cc b/starboard/shared/stub/accessibility_set_captions_enabled.cc deleted file mode 100644 index 458c43b50415..000000000000 --- a/starboard/shared/stub/accessibility_set_captions_enabled.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/accessibility.h" -#include "starboard/configuration.h" - -bool SbAccessibilitySetCaptionsEnabled(bool enabled) { - return false; -} - -#endif diff --git a/starboard/shared/stub/byte_swap.cc b/starboard/shared/stub/byte_swap.cc deleted file mode 100644 index a64b2020eb0e..000000000000 --- a/starboard/shared/stub/byte_swap.cc +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Not breaking these functions up because however one is implemented, the -// others should be implemented similarly. - -#if SB_API_VERSION < 16 - -#include "starboard/byte_swap.h" - -int16_t SbByteSwapS16(int16_t value) { - return 0; -} - -uint16_t SbByteSwapU16(uint16_t value) { - return 0; -} - -int32_t SbByteSwapS32(int32_t value) { - return 0; -} - -uint32_t SbByteSwapU32(uint32_t value) { - return 0; -} - -int64_t SbByteSwapS64(int64_t value) { - return 0; -} - -uint64_t SbByteSwapU64(uint64_t value) { - return 0; -} - -#endif diff --git a/starboard/shared/stub/condition_variable_broadcast.cc b/starboard/shared/stub/condition_variable_broadcast.cc deleted file mode 100644 index 056366ac914b..000000000000 --- a/starboard/shared/stub/condition_variable_broadcast.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" - -bool SbConditionVariableBroadcast(SbConditionVariable* condition) { - return false; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/condition_variable_create.cc b/starboard/shared/stub/condition_variable_create.cc deleted file mode 100644 index 1589001f9a55..000000000000 --- a/starboard/shared/stub/condition_variable_create.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 -#include "starboard/common/condition_variable.h" - -bool SbConditionVariableCreate(SbConditionVariable* out_condition, - SbMutex* opt_mutex) { - return false; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/condition_variable_destroy.cc b/starboard/shared/stub/condition_variable_destroy.cc deleted file mode 100644 index 654d2b1c9318..000000000000 --- a/starboard/shared/stub/condition_variable_destroy.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" - -bool SbConditionVariableDestroy(SbConditionVariable* condition) { - return false; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/condition_variable_signal.cc b/starboard/shared/stub/condition_variable_signal.cc deleted file mode 100644 index 6f905ead1d47..000000000000 --- a/starboard/shared/stub/condition_variable_signal.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" - -bool SbConditionVariableSignal(SbConditionVariable* condition) { - return false; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/condition_variable_wait.cc b/starboard/shared/stub/condition_variable_wait.cc deleted file mode 100644 index 8735a72337bb..000000000000 --- a/starboard/shared/stub/condition_variable_wait.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" - -SbConditionVariableResult SbConditionVariableWait( - SbConditionVariable* condition, - SbMutex* mutex) { - return kSbConditionVariableFailed; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/condition_variable_wait_timed.cc b/starboard/shared/stub/condition_variable_wait_timed.cc deleted file mode 100644 index 908759d0f98a..000000000000 --- a/starboard/shared/stub/condition_variable_wait_timed.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" - -SbConditionVariableResult SbConditionVariableWaitTimed( - SbConditionVariable* condition, - SbMutex* mutex, - int64_t timeout) { - return kSbConditionVariableFailed; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/directory_can_open.cc b/starboard/shared/stub/directory_can_open.cc deleted file mode 100644 index 8f69f9abb4f2..000000000000 --- a/starboard/shared/stub/directory_can_open.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 16 - -#include "starboard/directory.h" - -bool SbDirectoryCanOpen(const char* path) { - return false; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/directory_close.cc b/starboard/shared/stub/directory_close.cc deleted file mode 100644 index 894465617548..000000000000 --- a/starboard/shared/stub/directory_close.cc +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include "starboard/directory.h" - -bool SbDirectoryClose(SbDirectory directory) { - return false; -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/directory_create.cc b/starboard/shared/stub/directory_create.cc deleted file mode 100644 index f82885ca3b80..000000000000 --- a/starboard/shared/stub/directory_create.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/directory.h" - -bool SbDirectoryCreate(const char* path) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/directory_get_next.cc b/starboard/shared/stub/directory_get_next.cc deleted file mode 100644 index f7f81c652ba6..000000000000 --- a/starboard/shared/stub/directory_get_next.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include "starboard/directory.h" - -bool SbDirectoryGetNext(SbDirectory directory, - char* out_entry, - size_t out_entry_size) { - return false; -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/directory_open.cc b/starboard/shared/stub/directory_open.cc deleted file mode 100644 index 19e1d6fc2af2..000000000000 --- a/starboard/shared/stub/directory_open.cc +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include "starboard/directory.h" - -SbDirectory SbDirectoryOpen(const char* path, SbFileError* out_error) { - return kSbDirectoryInvalid; -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_can_open.cc b/starboard/shared/stub/file_can_open.cc deleted file mode 100644 index 132438067b99..000000000000 --- a/starboard/shared/stub/file_can_open.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -bool SbFileCanOpen(const char* path, int flags) { - return false; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_close.cc b/starboard/shared/stub/file_close.cc deleted file mode 100644 index 768d28e26435..000000000000 --- a/starboard/shared/stub/file_close.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -bool SbFileClose(SbFile file) { - return false; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_delete.cc b/starboard/shared/stub/file_delete.cc deleted file mode 100644 index 298b5e0912bf..000000000000 --- a/starboard/shared/stub/file_delete.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -bool SbFileDelete(const char* path) { - return false; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_exists.cc b/starboard/shared/stub/file_exists.cc deleted file mode 100644 index 37ccdd18ab7c..000000000000 --- a/starboard/shared/stub/file_exists.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/file.h" - -bool SbFileExists(const char* path) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/file_flush.cc b/starboard/shared/stub/file_flush.cc deleted file mode 100644 index 48268327c115..000000000000 --- a/starboard/shared/stub/file_flush.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -bool SbFileFlush(SbFile file) { - return false; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_get_info.cc b/starboard/shared/stub/file_get_info.cc deleted file mode 100644 index aa8d32f762f2..000000000000 --- a/starboard/shared/stub/file_get_info.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -bool SbFileGetInfo(SbFile file, SbFileInfo* out_info) { - return false; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_get_path_info.cc b/starboard/shared/stub/file_get_path_info.cc deleted file mode 100644 index 6b441b45302e..000000000000 --- a/starboard/shared/stub/file_get_path_info.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/file.h" - -bool SbFileGetPathInfo(const char* path, SbFileInfo* out_info) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/file_open.cc b/starboard/shared/stub/file_open.cc deleted file mode 100644 index 084fbd7eb37b..000000000000 --- a/starboard/shared/stub/file_open.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -SbFile SbFileOpen(const char* path, - int flags, - bool* out_created, - SbFileError* out_error) { - return kSbFileInvalid; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_read.cc b/starboard/shared/stub/file_read.cc deleted file mode 100644 index 8db62d342148..000000000000 --- a/starboard/shared/stub/file_read.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -int SbFileRead(SbFile file, char* data, int size) { - return 0; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_seek.cc b/starboard/shared/stub/file_seek.cc deleted file mode 100644 index 3655631fd497..000000000000 --- a/starboard/shared/stub/file_seek.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -int64_t SbFileSeek(SbFile file, SbFileWhence whence, int64_t offset) { - return 0; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_truncate.cc b/starboard/shared/stub/file_truncate.cc deleted file mode 100644 index 21c63ca67f52..000000000000 --- a/starboard/shared/stub/file_truncate.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -bool SbFileTruncate(SbFile file, int64_t length) { - return false; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_write.cc b/starboard/shared/stub/file_write.cc deleted file mode 100644 index 35e1314a784c..000000000000 --- a/starboard/shared/stub/file_write.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -int SbFileWrite(SbFile file, const char* data, int size) { - return 0; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/image_decode.cc b/starboard/shared/stub/image_decode.cc deleted file mode 100644 index b5721162269b..000000000000 --- a/starboard/shared/stub/image_decode.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/image.h" - -SbDecodeTarget SbImageDecode(SbDecodeTargetGraphicsContextProvider* provider, - void* data, - int data_size, - const char* mime_type, - SbDecodeTargetFormat format) { - return kSbDecodeTargetInvalid; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/image_is_decode_supported.cc b/starboard/shared/stub/image_is_decode_supported.cc deleted file mode 100644 index 953169e6aeee..000000000000 --- a/starboard/shared/stub/image_is_decode_supported.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/image.h" - -bool SbImageIsDecodeSupported(const char* mime_type, - SbDecodeTargetFormat format) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/media_get_buffer_storage_type.cc b/starboard/shared/stub/media_get_buffer_storage_type.cc deleted file mode 100644 index 23db3566c2ea..000000000000 --- a/starboard/shared/stub/media_get_buffer_storage_type.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/media.h" - -#if SB_API_VERSION < 16 -SbMediaBufferStorageType SbMediaGetBufferStorageType() { - return static_cast(0); -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/mutex_acquire.cc b/starboard/shared/stub/mutex_acquire.cc deleted file mode 100644 index db64efd19d1c..000000000000 --- a/starboard/shared/stub/mutex_acquire.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -SbMutexResult SbMutexAcquire(SbMutex* mutex) { - return kSbMutexDestroyed; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/mutex_acquire_try.cc b/starboard/shared/stub/mutex_acquire_try.cc deleted file mode 100644 index e59f2db4b581..000000000000 --- a/starboard/shared/stub/mutex_acquire_try.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -SbMutexResult SbMutexAcquireTry(SbMutex* mutex) { - return kSbMutexDestroyed; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/mutex_create.cc b/starboard/shared/stub/mutex_create.cc deleted file mode 100644 index 52876be4af47..000000000000 --- a/starboard/shared/stub/mutex_create.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -bool SbMutexCreate(SbMutex* mutex) { - return false; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/mutex_destroy.cc b/starboard/shared/stub/mutex_destroy.cc deleted file mode 100644 index e62414a53ec4..000000000000 --- a/starboard/shared/stub/mutex_destroy.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -bool SbMutexDestroy(SbMutex* mutex) { - return false; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/mutex_release.cc b/starboard/shared/stub/mutex_release.cc deleted file mode 100644 index 21f81caf467a..000000000000 --- a/starboard/shared/stub/mutex_release.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -bool SbMutexRelease(SbMutex* mutex) { - return false; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/once.cc b/starboard/shared/stub/once.cc deleted file mode 100644 index 570f6c4690d2..000000000000 --- a/starboard/shared/stub/once.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/once.h" - -bool SbOnce(SbOnceControl* once_control, SbOnceInitRoutine init_routine) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/storage_delete_record.cc b/starboard/shared/stub/storage_delete_record.cc index 3680cdd97128..f4bc24f007f7 100644 --- a/starboard/shared/stub/storage_delete_record.cc +++ b/starboard/shared/stub/storage_delete_record.cc @@ -14,10 +14,6 @@ #include "starboard/common/storage.h" -#if SB_API_VERSION < 16 -bool SbStorageDeleteRecord(SbUser user, const char* name) { -#else bool SbStorageDeleteRecord(const char* name) { -#endif return false; } diff --git a/starboard/shared/stub/storage_open_record.cc b/starboard/shared/stub/storage_open_record.cc index 25af8d1e2065..5ffbc0fca294 100644 --- a/starboard/shared/stub/storage_open_record.cc +++ b/starboard/shared/stub/storage_open_record.cc @@ -14,10 +14,6 @@ #include "starboard/common/storage.h" -#if SB_API_VERSION < 16 -SbStorageRecord SbStorageOpenRecord(SbUser user, const char* name) { -#else SbStorageRecord SbStorageOpenRecord(const char* name) { -#endif return kSbStorageInvalidRecord; } diff --git a/starboard/shared/stub/string_compare_no_case.cc b/starboard/shared/stub/string_compare_no_case.cc deleted file mode 100644 index aa767bdb86be..000000000000 --- a/starboard/shared/stub/string_compare_no_case.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#if SB_API_VERSION < 16 -int SbStringCompareNoCase(const char* string1, const char* string2) { - return 0; -} -#endif diff --git a/starboard/shared/stub/string_compare_no_case_n.cc b/starboard/shared/stub/string_compare_no_case_n.cc deleted file mode 100644 index aa7ae6323c75..000000000000 --- a/starboard/shared/stub/string_compare_no_case_n.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#if SB_API_VERSION < 16 -int SbStringCompareNoCaseN(const char* string1, - const char* string2, - size_t count) { - return 0; -} -#endif diff --git a/starboard/shared/stub/string_duplicate.cc b/starboard/shared/stub/string_duplicate.cc deleted file mode 100644 index 1514acc6dc27..000000000000 --- a/starboard/shared/stub/string_duplicate.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#if SB_API_VERSION < 16 - -char* SbStringDuplicate(const char* source) { - return NULL; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/string_format.cc b/starboard/shared/stub/string_format.cc deleted file mode 100644 index 66a996088ceb..000000000000 --- a/starboard/shared/stub/string_format.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#if SB_API_VERSION < 16 -int SbStringFormat(char* out_buffer, - size_t buffer_size, - const char* format, - va_list arguments) { - return 0; -} -#endif diff --git a/starboard/shared/stub/string_format_wide.cc b/starboard/shared/stub/string_format_wide.cc deleted file mode 100644 index 4bcabdf50d06..000000000000 --- a/starboard/shared/stub/string_format_wide.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#if SB_API_VERSION < 16 -int SbStringFormatWide(wchar_t* out_buffer, - size_t buffer_size, - const wchar_t* format, - va_list arguments) { - return 0; -} -#endif diff --git a/starboard/shared/stub/string_scan.cc b/starboard/shared/stub/string_scan.cc deleted file mode 100644 index 6646a905a8e7..000000000000 --- a/starboard/shared/stub/string_scan.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/string.h" - -int SbStringScan(const char* buffer, const char* pattern, va_list arguments) { - return 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/system_get_device_type.cc b/starboard/shared/stub/system_get_device_type.cc deleted file mode 100644 index 00ac8d3194a6..000000000000 --- a/starboard/shared/stub/system_get_device_type.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#if SB_API_VERSION < 15 - -SbSystemDeviceType SbSystemGetDeviceType() { - return kSbSystemDeviceTypeUnknown; -} - -#endif diff --git a/starboard/shared/stub/thread_create.cc b/starboard/shared/stub/thread_create.cc deleted file mode 100644 index 5b93031f9d75..000000000000 --- a/starboard/shared/stub/thread_create.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -SbThread SbThreadCreate(int64_t stack_size, - SbThreadPriority priority, - SbThreadAffinity affinity, - bool joinable, - const char* name, - SbThreadEntryPoint entry_point, - void* context) { - return kSbThreadInvalid; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_create_local_key.cc b/starboard/shared/stub/thread_create_local_key.cc deleted file mode 100644 index dd9324efa7e7..000000000000 --- a/starboard/shared/stub/thread_create_local_key.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -SbThreadLocalKey SbThreadCreateLocalKey(SbThreadLocalDestructor destructor) { - return kSbThreadLocalKeyInvalid; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_destroy_local_key.cc b/starboard/shared/stub/thread_destroy_local_key.cc deleted file mode 100644 index 055adc5a2aae..000000000000 --- a/starboard/shared/stub/thread_destroy_local_key.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -void SbThreadDestroyLocalKey(SbThreadLocalKey key) {} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_detach.cc b/starboard/shared/stub/thread_detach.cc deleted file mode 100644 index 381a25025f0a..000000000000 --- a/starboard/shared/stub/thread_detach.cc +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 -#include "starboard/thread.h" - -void SbThreadDetach(SbThread thread) {} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_get_current.cc b/starboard/shared/stub/thread_get_current.cc deleted file mode 100644 index d6b495c38b9d..000000000000 --- a/starboard/shared/stub/thread_get_current.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -SbThread SbThreadGetCurrent() { - return kSbThreadInvalid; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_get_local_value.cc b/starboard/shared/stub/thread_get_local_value.cc deleted file mode 100644 index ac0e867197e9..000000000000 --- a/starboard/shared/stub/thread_get_local_value.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -void* SbThreadGetLocalValue(SbThreadLocalKey key) { - return NULL; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_get_name.cc b/starboard/shared/stub/thread_get_name.cc deleted file mode 100644 index 6f9719219726..000000000000 --- a/starboard/shared/stub/thread_get_name.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -void SbThreadGetName(char* buffer, int buffer_size) {} - -#endif diff --git a/starboard/shared/stub/thread_is_equal.cc b/starboard/shared/stub/thread_is_equal.cc deleted file mode 100644 index d1cf10aacd03..000000000000 --- a/starboard/shared/stub/thread_is_equal.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -bool SbThreadIsEqual(SbThread thread1, SbThread thread2) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_join.cc b/starboard/shared/stub/thread_join.cc deleted file mode 100644 index d19376e56d07..000000000000 --- a/starboard/shared/stub/thread_join.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -bool SbThreadJoin(SbThread thread, void** out_return) { - return false; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_sampler_create.cc b/starboard/shared/stub/thread_sampler_create.cc index 9fbe64b5cd26..5131a4d48749 100644 --- a/starboard/shared/stub/thread_sampler_create.cc +++ b/starboard/shared/stub/thread_sampler_create.cc @@ -15,11 +15,7 @@ #include "starboard/common/log.h" #include "starboard/thread.h" -#if SB_API_VERSION < 16 -SbThreadSampler SbThreadSamplerCreate(SbThread thread) { -#else SbThreadSampler SbThreadSamplerCreate(pthread_t thread) { -#endif SB_NOTIMPLEMENTED() << "Profiling is not supported on this platform."; return kSbThreadSamplerInvalid; } diff --git a/starboard/shared/stub/thread_set_local_value.cc b/starboard/shared/stub/thread_set_local_value.cc deleted file mode 100644 index a716c543a81d..000000000000 --- a/starboard/shared/stub/thread_set_local_value.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -bool SbThreadSetLocalValue(SbThreadLocalKey key, void* value) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_set_name.cc b/starboard/shared/stub/thread_set_name.cc deleted file mode 100644 index dd5592db568b..000000000000 --- a/starboard/shared/stub/thread_set_name.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -void SbThreadSetName(const char* name) {} - -#endif diff --git a/starboard/shared/stub/time_get_monotonic_now.cc b/starboard/shared/stub/time_get_monotonic_now.cc deleted file mode 100644 index a012ce20ab38..000000000000 --- a/starboard/shared/stub/time_get_monotonic_now.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -SbTimeMonotonic SbTimeGetMonotonicNow() { - return SbTimeMonotonic(); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/time_get_monotonic_thread_now.cc b/starboard/shared/stub/time_get_monotonic_thread_now.cc deleted file mode 100644 index edafecbdf13c..000000000000 --- a/starboard/shared/stub/time_get_monotonic_thread_now.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -SbTimeMonotonic SbTimeGetMonotonicThreadNow() { - return SbTimeMonotonic(0); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/time_get_now.cc b/starboard/shared/stub/time_get_now.cc deleted file mode 100644 index 25362a35846b..000000000000 --- a/starboard/shared/stub/time_get_now.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -SbTime SbTimeGetNow() { - return SbTime(); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/time_is_time_thread_now_supported.cc b/starboard/shared/stub/time_is_time_thread_now_supported.cc deleted file mode 100644 index d60e58a4fadd..000000000000 --- a/starboard/shared/stub/time_is_time_thread_now_supported.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -bool SbTimeIsTimeThreadNowSupported() { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/ui_nav_get_interface.cc b/starboard/shared/stub/ui_nav_get_interface.cc deleted file mode 100644 index 66e80ca257c6..000000000000 --- a/starboard/shared/stub/ui_nav_get_interface.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/ui_navigation.h" - -bool SbUiNavGetInterface(SbUiNavInterface* out_interface) { - return false; -} - -#endif // SB_API_VERSION diff --git a/starboard/shared/stub/user_get_current.cc b/starboard/shared/stub/user_get_current.cc deleted file mode 100644 index ead08b7d0bbd..000000000000 --- a/starboard/shared/stub/user_get_current.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/user.h" - -SbUser SbUserGetCurrent() { - return kSbUserInvalid; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/user_get_property.cc b/starboard/shared/stub/user_get_property.cc deleted file mode 100644 index cdb9b4e2f5dd..000000000000 --- a/starboard/shared/stub/user_get_property.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/user.h" - -int SbUserGetPropertySize(SbUser user, SbUserPropertyId property_id) { - return 0; -} - -bool SbUserGetProperty(SbUser user, - SbUserPropertyId property_id, - char* out_value, - int value_size) { - return false; -} - -#endif diff --git a/starboard/shared/stub/user_get_signed_in.cc b/starboard/shared/stub/user_get_signed_in.cc deleted file mode 100644 index 7fbfcc36ba50..000000000000 --- a/starboard/shared/stub/user_get_signed_in.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/user.h" - -int SbUserGetSignedIn(SbUser* out_users, int users_size) { - return 0; -} - -#endif diff --git a/starboard/shared/stub/window_blur_on_screen_keyboard.cc b/starboard/shared/stub/window_blur_on_screen_keyboard.cc deleted file mode 100644 index 389485ea8dd1..000000000000 --- a/starboard/shared/stub/window_blur_on_screen_keyboard.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -void SbWindowBlurOnScreenKeyboard(SbWindow window, int ticket) {} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/window_focus_on_screen_keyboard.cc b/starboard/shared/stub/window_focus_on_screen_keyboard.cc deleted file mode 100644 index 90d8e30e5a57..000000000000 --- a/starboard/shared/stub/window_focus_on_screen_keyboard.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -void SbWindowFocusOnScreenKeyboard(SbWindow window, int ticket) {} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/window_get_on_screen_keyboard_bounding_rect.cc b/starboard/shared/stub/window_get_on_screen_keyboard_bounding_rect.cc deleted file mode 100644 index 4f34c6b4eaef..000000000000 --- a/starboard/shared/stub/window_get_on_screen_keyboard_bounding_rect.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -bool SbWindowGetOnScreenKeyboardBoundingRect(SbWindow window, - SbWindowRect* bounding_rect) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/window_hide_on_screen_keyboard.cc b/starboard/shared/stub/window_hide_on_screen_keyboard.cc deleted file mode 100644 index 22d982c454ac..000000000000 --- a/starboard/shared/stub/window_hide_on_screen_keyboard.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -void SbWindowHideOnScreenKeyboard(SbWindow window, int ticket) {} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/window_is_on_screen_keyboard_shown.cc b/starboard/shared/stub/window_is_on_screen_keyboard_shown.cc deleted file mode 100644 index 1578d07fff2d..000000000000 --- a/starboard/shared/stub/window_is_on_screen_keyboard_shown.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -bool SbWindowIsOnScreenKeyboardShown(SbWindow window) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/window_on_screen_keyboard_is_supported.cc b/starboard/shared/stub/window_on_screen_keyboard_is_supported.cc deleted file mode 100644 index 007245bd06ab..000000000000 --- a/starboard/shared/stub/window_on_screen_keyboard_is_supported.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -bool SbWindowOnScreenKeyboardIsSupported() { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/window_on_screen_keyboard_suggestions_supported.cc b/starboard/shared/stub/window_on_screen_keyboard_suggestions_supported.cc deleted file mode 100644 index 6b4fefd5d4a0..000000000000 --- a/starboard/shared/stub/window_on_screen_keyboard_suggestions_supported.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -bool SbWindowOnScreenKeyboardSuggestionsSupported(SbWindow window) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/window_set_on_screen_keyboard_keep_focus.cc b/starboard/shared/stub/window_set_on_screen_keyboard_keep_focus.cc deleted file mode 100644 index 3a61e02db64c..000000000000 --- a/starboard/shared/stub/window_set_on_screen_keyboard_keep_focus.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -void SbWindowSetOnScreenKeyboardKeepFocus(SbWindow window, bool keep_focus) {} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/window_show_on_screen_keyboard.cc b/starboard/shared/stub/window_show_on_screen_keyboard.cc deleted file mode 100644 index 7ffca5fa6e91..000000000000 --- a/starboard/shared/stub/window_show_on_screen_keyboard.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -void SbWindowShowOnScreenKeyboard(SbWindow window, - const char* input_text, - int ticket) {} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/window_update_on_screen_keyboard_suggestions.cc b/starboard/shared/stub/window_update_on_screen_keyboard_suggestions.cc deleted file mode 100644 index 3ad65ba87da7..000000000000 --- a/starboard/shared/stub/window_update_on_screen_keyboard_suggestions.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -void SbWindowUpdateOnScreenKeyboardSuggestions(SbWindow window, - const char* suggestions[], - int num_suggestions, - int ticket) {} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/storage.h b/starboard/storage.h index 55db9509ddfc..696e2b54ac2f 100644 --- a/starboard/storage.h +++ b/starboard/storage.h @@ -31,9 +31,6 @@ #include "starboard/export.h" #include "starboard/types.h" -#if SB_API_VERSION < 16 -#include "starboard/user.h" -#endif // SB_API_VERSION < 16 #ifdef __cplusplus extern "C" { @@ -53,20 +50,6 @@ static inline bool SbStorageIsValidRecord(SbStorageRecord record) { return record != kSbStorageInvalidRecord; } -#if SB_API_VERSION < 16 -// Opens and returns the SbStorageRecord for |user| named |name|, blocking I/O -// on the calling thread until the open is completed. If |user| is not a valid -// |SbUser|, the function returns |kSbStorageInvalidRecord|. Will return an -// |SbStorageRecord| of size zero if the record does not yet exist. Opening an -// already-open |SbStorageRecord| has undefined behavior. -// -// If |name| is NULL, opens the default storage record for the user, like what -// would have been saved with the previous version of SbStorageOpenRecord. -// -// |user|: The user for which the storage record will be opened. -// |name|: The filesystem-safe name of the record to open. -SB_EXPORT SbStorageRecord SbStorageOpenRecord(SbUser user, const char* name); -#else // SB_API_VERSION < 16 // Opens and returns the SbStorageRecord named |name|, blocking I/O // on the calling thread until the open is completed. Will return an // |SbStorageRecord| of size zero if the record does not yet exist. Opening an @@ -77,7 +60,6 @@ SB_EXPORT SbStorageRecord SbStorageOpenRecord(SbUser user, const char* name); // // |name|: The filesystem-safe name of the record to open. SB_EXPORT SbStorageRecord SbStorageOpenRecord(const char* name); -#endif // SB_API_VERSION < 16 // Closes |record|, synchronously ensuring that all written data is flushed. // This function performs blocking I/O on the calling thread. @@ -129,21 +111,6 @@ SB_EXPORT bool SbStorageWriteRecord(SbStorageRecord record, const char* data, int64_t data_size); -#if SB_API_VERSION < 16 -// Deletes the |SbStorageRecord| for |user| named |name|. The return value -// indicates whether the record existed and was successfully deleted. If the -// record did not exist or could not be deleted, the function returns |false|. -// -// If |name| is NULL, deletes the default storage record for the user, like what -// would have been deleted with the previous version of SbStorageDeleteRecord. -// -// This function must not be called while the user's storage record is open. -// This function performs blocking I/O on the calling thread. -// -// |user|: The user for whom the record will be deleted. -// |name|: The filesystem-safe name of the record to open. -SB_EXPORT bool SbStorageDeleteRecord(SbUser user, const char* name); -#else // SB_API_VERSION < 16 // Deletes the |SbStorageRecord| named |name|. The return value // indicates whether the record existed and was successfully deleted. If the // record did not exist or could not be deleted, the function returns |false|. @@ -156,7 +123,6 @@ SB_EXPORT bool SbStorageDeleteRecord(SbUser user, const char* name); // // |name|: The filesystem-safe name of the record to open. SB_EXPORT bool SbStorageDeleteRecord(const char* name); -#endif // SB_API_VERSION < 16 #ifdef __cplusplus } // extern "C" diff --git a/starboard/stub/BUILD.gn b/starboard/stub/BUILD.gn index 9001c81a3acb..abfc82733012 100644 --- a/starboard/stub/BUILD.gn +++ b/starboard/stub/BUILD.gn @@ -38,8 +38,6 @@ static_library("stub_sources") { "//starboard/shared/starboard/command_line.h", "//starboard/shared/starboard/event_cancel.cc", "//starboard/shared/starboard/event_schedule.cc", - "//starboard/shared/starboard/file_mode_string_to_flags.cc", - "//starboard/shared/starboard/memory.cc", "//starboard/shared/starboard/queue_application.cc", "//starboard/shared/stub/atomic_public.h", "//starboard/shared/stub/audio_sink_create.cc", @@ -50,21 +48,9 @@ static_library("stub_sources") { "//starboard/shared/stub/audio_sink_is_audio_frame_storage_type_supported.cc", "//starboard/shared/stub/audio_sink_is_audio_sample_type_supported.cc", "//starboard/shared/stub/audio_sink_is_valid.cc", - "//starboard/shared/stub/byte_swap.cc", - "//starboard/shared/stub/condition_variable_broadcast.cc", - "//starboard/shared/stub/condition_variable_create.cc", - "//starboard/shared/stub/condition_variable_destroy.cc", - "//starboard/shared/stub/condition_variable_signal.cc", - "//starboard/shared/stub/condition_variable_wait.cc", - "//starboard/shared/stub/condition_variable_wait_timed.cc", "//starboard/shared/stub/cpu_features_get.cc", "//starboard/shared/stub/decode_target_get_info.cc", "//starboard/shared/stub/decode_target_release.cc", - "//starboard/shared/stub/directory_can_open.cc", - "//starboard/shared/stub/directory_close.cc", - "//starboard/shared/stub/directory_create.cc", - "//starboard/shared/stub/directory_get_next.cc", - "//starboard/shared/stub/directory_open.cc", "//starboard/shared/stub/drm_close_session.cc", "//starboard/shared/stub/drm_create_system.cc", "//starboard/shared/stub/drm_destroy_system.cc", @@ -75,20 +61,6 @@ static_library("stub_sources") { "//starboard/shared/stub/drm_update_session.cc", "//starboard/shared/stub/environment.cc", "//starboard/shared/stub/file_atomic_replace.cc", - "//starboard/shared/stub/file_can_open.cc", - "//starboard/shared/stub/file_close.cc", - "//starboard/shared/stub/file_delete.cc", - "//starboard/shared/stub/file_exists.cc", - "//starboard/shared/stub/file_flush.cc", - "//starboard/shared/stub/file_get_info.cc", - "//starboard/shared/stub/file_get_path_info.cc", - "//starboard/shared/stub/file_open.cc", - "//starboard/shared/stub/file_read.cc", - "//starboard/shared/stub/file_seek.cc", - "//starboard/shared/stub/file_truncate.cc", - "//starboard/shared/stub/file_write.cc", - "//starboard/shared/stub/image_decode.cc", - "//starboard/shared/stub/image_is_decode_supported.cc", "//starboard/shared/stub/log.cc", "//starboard/shared/stub/log_flush.cc", "//starboard/shared/stub/log_format.cc", @@ -103,7 +75,6 @@ static_library("stub_sources") { "//starboard/shared/stub/media_get_buffer_allocation_unit.cc", "//starboard/shared/stub/media_get_buffer_garbage_collection_duration_threshold.cc", "//starboard/shared/stub/media_get_buffer_padding.cc", - "//starboard/shared/stub/media_get_buffer_storage_type.cc", "//starboard/shared/stub/media_get_initial_buffer_capacity.cc", "//starboard/shared/stub/media_get_max_buffer_capacity.cc", "//starboard/shared/stub/media_get_progressive_buffer_budget.cc", @@ -112,13 +83,9 @@ static_library("stub_sources") { "//starboard/shared/stub/media_is_buffer_using_memory_pool.cc", "//starboard/shared/stub/memory_allocate_aligned_unchecked.cc", "//starboard/shared/stub/memory_allocate_unchecked.cc", - "//starboard/shared/stub/memory_flush.cc", "//starboard/shared/stub/memory_free.cc", "//starboard/shared/stub/memory_free_aligned.cc", - "//starboard/shared/stub/memory_map.cc", - "//starboard/shared/stub/memory_protect.cc", "//starboard/shared/stub/memory_reallocate_unchecked.cc", - "//starboard/shared/stub/memory_unmap.cc", "//starboard/shared/stub/microphone_close.cc", "//starboard/shared/stub/microphone_create.cc", "//starboard/shared/stub/microphone_destroy.cc", @@ -126,12 +93,6 @@ static_library("stub_sources") { "//starboard/shared/stub/microphone_is_sample_rate_supported.cc", "//starboard/shared/stub/microphone_open.cc", "//starboard/shared/stub/microphone_read.cc", - "//starboard/shared/stub/mutex_acquire.cc", - "//starboard/shared/stub/mutex_acquire_try.cc", - "//starboard/shared/stub/mutex_create.cc", - "//starboard/shared/stub/mutex_destroy.cc", - "//starboard/shared/stub/mutex_release.cc", - "//starboard/shared/stub/once.cc", "//starboard/shared/stub/player_create.cc", "//starboard/shared/stub/player_destroy.cc", "//starboard/shared/stub/player_get_audio_configuration.cc", @@ -186,16 +147,9 @@ static_library("stub_sources") { "//starboard/shared/stub/storage_open_record.cc", "//starboard/shared/stub/storage_read_record.cc", "//starboard/shared/stub/storage_write_record.cc", - "//starboard/shared/stub/string_compare_no_case.cc", - "//starboard/shared/stub/string_compare_no_case_n.cc", - "//starboard/shared/stub/string_duplicate.cc", - "//starboard/shared/stub/string_format.cc", - "//starboard/shared/stub/string_format_wide.cc", - "//starboard/shared/stub/string_scan.cc", "//starboard/shared/stub/system_break_into_debugger.cc", "//starboard/shared/stub/system_clear_last_error.cc", "//starboard/shared/stub/system_egl.cc", - "//starboard/shared/stub/system_get_device_type.cc", "//starboard/shared/stub/system_get_error_string.cc", "//starboard/shared/stub/system_get_last_error.cc", "//starboard/shared/stub/system_get_locale_id.cc", @@ -225,53 +179,24 @@ static_library("stub_sources") { "//starboard/shared/stub/system_supports_resume.cc", "//starboard/shared/stub/system_symbolize.cc", "//starboard/shared/stub/thread_context_get_pointer.cc", - "//starboard/shared/stub/thread_create.cc", - "//starboard/shared/stub/thread_create_local_key.cc", "//starboard/shared/stub/thread_create_priority.cc", - "//starboard/shared/stub/thread_destroy_local_key.cc", - "//starboard/shared/stub/thread_detach.cc", - "//starboard/shared/stub/thread_get_current.cc", "//starboard/shared/stub/thread_get_id.cc", - "//starboard/shared/stub/thread_get_local_value.cc", - "//starboard/shared/stub/thread_get_name.cc", - "//starboard/shared/stub/thread_is_equal.cc", - "//starboard/shared/stub/thread_join.cc", "//starboard/shared/stub/thread_priority.cc", "//starboard/shared/stub/thread_sampler_create.cc", "//starboard/shared/stub/thread_sampler_destroy.cc", "//starboard/shared/stub/thread_sampler_freeze.cc", "//starboard/shared/stub/thread_sampler_is_supported.cc", "//starboard/shared/stub/thread_sampler_thaw.cc", - "//starboard/shared/stub/thread_set_local_value.cc", - "//starboard/shared/stub/thread_set_name.cc", "//starboard/shared/stub/thread_sleep.cc", "//starboard/shared/stub/thread_yield.cc", - "//starboard/shared/stub/time_get_monotonic_now.cc", - "//starboard/shared/stub/time_get_monotonic_thread_now.cc", - "//starboard/shared/stub/time_get_now.cc", - "//starboard/shared/stub/time_is_time_thread_now_supported.cc", "//starboard/shared/stub/time_zone_get_current.cc", "//starboard/shared/stub/time_zone_get_name.cc", - "//starboard/shared/stub/ui_nav_get_interface.cc", - "//starboard/shared/stub/user_get_current.cc", - "//starboard/shared/stub/user_get_property.cc", - "//starboard/shared/stub/user_get_signed_in.cc", - "//starboard/shared/stub/window_blur_on_screen_keyboard.cc", "//starboard/shared/stub/window_create.cc", "//starboard/shared/stub/window_destroy.cc", - "//starboard/shared/stub/window_focus_on_screen_keyboard.cc", "//starboard/shared/stub/window_get_diagonal_size_in_inches.cc", - "//starboard/shared/stub/window_get_on_screen_keyboard_bounding_rect.cc", "//starboard/shared/stub/window_get_platform_handle.cc", "//starboard/shared/stub/window_get_size.cc", - "//starboard/shared/stub/window_hide_on_screen_keyboard.cc", - "//starboard/shared/stub/window_is_on_screen_keyboard_shown.cc", - "//starboard/shared/stub/window_on_screen_keyboard_is_supported.cc", - "//starboard/shared/stub/window_on_screen_keyboard_suggestions_supported.cc", "//starboard/shared/stub/window_set_default_options.cc", - "//starboard/shared/stub/window_set_on_screen_keyboard_keep_focus.cc", - "//starboard/shared/stub/window_show_on_screen_keyboard.cc", - "//starboard/shared/stub/window_update_on_screen_keyboard_suggestions.cc", ] public_configs = [ "//starboard/build/config:starboard_implementation" ] diff --git a/starboard/stub/configuration_constants.cc b/starboard/stub/configuration_constants.cc index db2439f62ba7..1f70040994ef 100644 --- a/starboard/stub/configuration_constants.cc +++ b/starboard/stub/configuration_constants.cc @@ -121,11 +121,6 @@ const char* kSbPathSepString = ":"; // generally prefer a byte order of RGBA, regardless of endianness. const int kSbPreferredRgbaByteOrder = SB_PREFERRED_RGBA_BYTE_ORDER_RGBA; -#if SB_API_VERSION < 16 -// The maximum number of users that can be signed in at the same time. -const uint32_t kSbUserMaxSignedIn = 1; -#endif // SB_API_VERSION < 16 - // The maximum size the cache directory is allowed to use in bytes. const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB diff --git a/starboard/stub/configuration_public.h b/starboard/stub/configuration_public.h index 2ea3d945748e..80f29bfa6aa9 100644 --- a/starboard/stub/configuration_public.h +++ b/starboard/stub/configuration_public.h @@ -48,14 +48,6 @@ #define SB_IS_WCHAR_T_UNSIGNED 1 #endif -// --- Media Configuration --------------------------------------------------- - -#if SB_API_VERSION <= 15 -// The implementation is allowed to support kSbMediaAudioSampleTypeInt16 only -// when this macro is defined. -#undef SB_HAS_QUIRK_SUPPORT_INT16_AUDIO_SAMPLES -#endif // SB_API_VERSION <= 15 - // --- Network Configuration ------------------------------------------------- // Specifies whether this platform supports IPV6. diff --git a/starboard/system.h b/starboard/system.h index ba1bfb38759f..711b015353a7 100644 --- a/starboard/system.h +++ b/starboard/system.h @@ -132,41 +132,6 @@ typedef enum SbSystemPropertyId { #endif } SbSystemPropertyId; -#if SB_API_VERSION < 15 -// Enumeration of device types. -typedef enum SbSystemDeviceType { - // Blue-ray Disc Player (BDP). - kSbSystemDeviceTypeBlueRayDiskPlayer, - - // A relatively high-powered TV device used primarily for playing games. - kSbSystemDeviceTypeGameConsole, - - // Over the top (OTT) devices stream content via the Internet over another - // type of network, e.g. cable or satellite. - kSbSystemDeviceTypeOverTheTopBox, - - // Set top boxes (STBs) stream content primarily over cable or satellite. - // Some STBs can also stream OTT content via the Internet. - kSbSystemDeviceTypeSetTopBox, - - // A Smart TV is a TV that can directly run applications that stream OTT - // content via the Internet. - kSbSystemDeviceTypeTV, - - // Desktop PC. - kSbSystemDeviceTypeDesktopPC, - - // An Android TV Device. - kSbSystemDeviceTypeAndroidTV, - - // A wall video projector. - kSbSystemDeviceTypeVideoProjector, - - // Unknown device. - kSbSystemDeviceTypeUnknown, -} SbSystemDeviceType; -#endif // SB_API_VERSION < 15 - // Runtime capabilities are boolean properties of a platform that can't be // determined at compile-time. They may vary from device to device, but they // will not change over the course of a single execution. They often specify @@ -284,11 +249,6 @@ SB_EXPORT int64_t SbSystemGetTotalGPUMemory(); // SbSystemHasCapability(kSbSystemCapabilityCanQueryGPUMemoryStats) is |true|. SB_EXPORT int64_t SbSystemGetUsedGPUMemory(); -#if SB_API_VERSION < 15 -// Returns the type of the device. -SB_EXPORT SbSystemDeviceType SbSystemGetDeviceType(); -#endif - // Returns if the device is disconnected from network. "Disconnected" is chosen // over connected because disconnection can be determined with more certainty // than connection usually. diff --git a/starboard/thread.h b/starboard/thread.h index c7f3e9fc92ec..f706f9912a0d 100644 --- a/starboard/thread.h +++ b/starboard/thread.h @@ -103,178 +103,6 @@ SB_EXPORT bool SbThreadSetPriority(SbThreadPriority priority); SB_EXPORT bool SbThreadGetPriority(SbThreadPriority* priority); #endif -#if SB_API_VERSION < 16 -// An opaque handle to a thread type. -typedef void* SbThread; - -#define kSbThreadInvalid (SbThread) NULL - -// Function pointer type for SbThreadCreate. |context| is a pointer-sized bit -// of data passed in from the calling thread. -typedef void* (*SbThreadEntryPoint)(void* context); - -// Function pointer type for Thread-Local destructors. -typedef void (*SbThreadLocalDestructor)(void* value); - -// Type for thread core affinity. This generally will be a single cpu (or core -// or hyperthread) identifier. Some platforms may not support affinity, and some -// may have specific rules about how it must be used. -typedef int32_t SbThreadAffinity; - -// Private structure representing a thread-local key. -typedef struct SbThreadLocalKeyPrivate SbThreadLocalKeyPrivate; - -// A handle to a thread-local key. -typedef SbThreadLocalKeyPrivate* SbThreadLocalKey; - -// Well-defined constant value to mean "no affinity." -#define kSbThreadNoAffinity (SbThreadAffinity) kSbInvalidInt - -// Well-defined constant value to mean "no thread local key." -#define kSbThreadLocalKeyInvalid (SbThreadLocalKey) NULL - -// Returns whether the given thread handle is valid. -static inline bool SbThreadIsValid(SbThread thread) { - return thread != kSbThreadInvalid; -} - -// Returns whether the given thread affinity is valid. -static inline bool SbThreadIsValidAffinity(SbThreadAffinity affinity) { - return affinity != kSbThreadNoAffinity; -} - -// Returns whether the given thread local variable key is valid. -static inline bool SbThreadIsValidLocalKey(SbThreadLocalKey key) { - return key != kSbThreadLocalKeyInvalid; -} - -// Creates a new thread, which starts immediately. -// - If the function succeeds, the return value is a handle to the newly -// created thread. -// - If the function fails, the return value is |kSbThreadInvalid|. -// -// |stack_size|: The amount of memory reserved for the thread. Set the value -// to |0| to indicate that the default stack size should be used. -// |priority|: The thread's priority. This value can be set to -// |kSbThreadNoPriority| to use the platform's default priority. As examples, -// it could be set to a fixed, standard priority or to a priority inherited -// from the thread that is calling SbThreadCreate(), or to something else. -// |affinity|: The thread's affinity. This value can be set to -// |kSbThreadNoAffinity| to use the platform's default affinity. -// |joinable|: Indicates whether the thread can be joined (|true|) or should -// start out "detached" (|false|). Note that for joinable threads, when -// you are done with the thread handle, you must call |SbThreadJoin| to -// release system resources associated with the thread. This is not necessary -// for detached threads, but detached threads cannot be joined. -// |name|: A name used to identify the thread. This value is used mainly for -// debugging, it can be |NULL|, and it might not be used in production builds. -// |entry_point|: A pointer to a function that will be executed on the newly -// created thread. -// |context|: This value will be passed to the |entry_point| function. -SB_EXPORT SbThread SbThreadCreate(int64_t stack_size, - SbThreadPriority priority, - SbThreadAffinity affinity, - bool joinable, - const char* name, - SbThreadEntryPoint entry_point, - void* context); - -// Joins the thread on which this function is called with joinable |thread|. -// This function blocks the caller until the designated thread exits, and then -// cleans up that thread's resources. The cleanup process essentially detaches -// thread. -// -// The return value is |true| if the function is successful and |false| if -// |thread| is invalid or detached. -// -// Each joinable thread can only be joined once and must be joined to be fully -// cleaned up. Once SbThreadJoin is called, the thread behaves as if it were -// detached to all threads other than the joining thread. -// -// |thread|: The thread to which the current thread will be joined. The -// |thread| must have been created with SbThreadCreate. -// |out_return|: If this is not |NULL|, then the SbThreadJoin function populates -// it with the return value of the thread's |main| function. -SB_EXPORT bool SbThreadJoin(SbThread thread, void** out_return); - -// Detaches |thread|, which prevents it from being joined. This is sort of like -// a non-blocking join. This function is a no-op if the thread is already -// detached or if the thread is already being joined by another thread. -// -// |thread|: The thread to be detached. -SB_EXPORT void SbThreadDetach(SbThread thread); - -// Yields the currently executing thread, so another thread has a chance to run. -SB_EXPORT void SbThreadYield(); - -// Sleeps the currently executing thread. -// -// |duration|: The minimum amount of time, in microseconds, that the currently -// executing thread should sleep. The function is a no-op if this value is -// negative or |0|. -SB_EXPORT void SbThreadSleep(int64_t duration); - -// Returns the handle of the currently executing thread. -SB_EXPORT SbThread SbThreadGetCurrent(); - -// Indicates whether |thread1| and |thread2| refer to the same thread. -// -// |thread1|: The first thread to compare. -// |thread2|: The second thread to compare. -SB_EXPORT bool SbThreadIsEqual(SbThread thread1, SbThread thread2); - -// Returns the debug name of the currently executing thread. -SB_EXPORT void SbThreadGetName(char* buffer, int buffer_size); - -// Sets the debug name of the currently executing thread by copying the -// specified name string. -// -// |name|: The name to assign to the thread. -SB_EXPORT void SbThreadSetName(const char* name); - -// Creates and returns a new, unique key for thread local data. If the function -// does not succeed, the function returns |kSbThreadLocalKeyInvalid|. -// -// If |destructor| is specified, it will be called in the owning thread, and -// only in the owning thread, when the thread exits. In that case, it is called -// on the local value associated with the key in the current thread as long as -// the local value is not NULL. -// -// |destructor|: A pointer to a function. The value may be NULL if no clean up -// is needed. -SB_EXPORT SbThreadLocalKey -SbThreadCreateLocalKey(SbThreadLocalDestructor destructor); - -// Destroys thread local data for the specified key. The function is a no-op -// if the key is invalid (kSbThreadLocalKeyInvalid|) or has already been -// destroyed. This function does NOT call the destructor on any stored values. -// -// |key|: The key for which to destroy thread local data. -SB_EXPORT void SbThreadDestroyLocalKey(SbThreadLocalKey key); - -// Returns the pointer-sized value for |key| in the currently executing thread's -// local storage. Returns |NULL| if key is |kSbThreadLocalKeyInvalid| or if the -// key has already been destroyed. -// -// |key|: The key for which to return the value. -SB_EXPORT void* SbThreadGetLocalValue(SbThreadLocalKey key); - -// Sets the pointer-sized value for |key| in the currently executing thread's -// local storage. The return value indicates whether |key| is valid and has -// not already been destroyed. -// -// |key|: The key for which to set the key value. -// |value|: The new pointer-sized key value. -SB_EXPORT bool SbThreadSetLocalValue(SbThreadLocalKey key, void* value); - -// Returns whether |thread| is the current thread. -// -// |thread|: The thread to check. -static inline bool SbThreadIsCurrent(SbThread thread) { - return SbThreadGetCurrent() == thread; -} -#endif - // Private structure representing the context of a frozen thread. typedef struct SbThreadContextPrivate SbThreadContextPrivate; @@ -334,12 +162,8 @@ SB_EXPORT bool SbThreadSamplerIsSupported(); // Creates a new thread sampler for the specified |thread|. // // If successful, this function returns the newly created handle. -// If unsuccessful, this function returns |kSbThreadSamplerInvalid|. -#if SB_API_VERSION < 16 -SB_EXPORT SbThreadSampler SbThreadSamplerCreate(SbThread thread); -#else +// If unsuccessful, this function returns |kSbThreadSamplerInvalid| SB_EXPORT SbThreadSampler SbThreadSamplerCreate(pthread_t thread); -#endif // Destroys the |sampler| and frees whatever resources it was using. SB_EXPORT void SbThreadSamplerDestroy(SbThreadSampler sampler); diff --git a/starboard/time.h b/starboard/time.h index ab5c0bf66a88..a0f1a71cd291 100644 --- a/starboard/time.h +++ b/starboard/time.h @@ -19,98 +19,6 @@ #ifndef STARBOARD_TIME_H_ #define STARBOARD_TIME_H_ -#if SB_API_VERSION < 16 - -#include "starboard/export.h" -#include "starboard/types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// The number of microseconds since the epoch of January 1, 1601 UTC, or the -// number of microseconds between two times. Always microseconds, ALWAYS UTC. -typedef int64_t SbTime; - -// A number of microseconds from some point. The main property of this time is -// that it increases monotonically. It should also be as high-resolution a timer -// as we can get on a platform. So, it is good for measuring the time between -// two calls without worrying about a system clock adjustment. It's not good -// for getting the wall clock time. -typedef int64_t SbTimeMonotonic; - -// How many nanoseconds in one SbTime unit (microseconds). -#define kSbTimeNanosecondsPerMicrosecond ((SbTime)1000) - -// One millisecond in SbTime units (microseconds). -#define kSbTimeMillisecond ((SbTime)1000) - -// One second in SbTime units (microseconds). -#define kSbTimeSecond (kSbTimeMillisecond * 1000) - -// One minute in SbTime units (microseconds). -#define kSbTimeMinute (kSbTimeSecond * 60) - -// One hour in SbTime units (microseconds). -#define kSbTimeHour (kSbTimeMinute * 60) - -// One day in SbTime units (microseconds). -#define kSbTimeDay (kSbTimeHour * 24) - -// The maximum value of an SbTime. -#define kSbTimeMax (kSbInt64Max) - -// A term that can be added to an SbTime to convert it into the number of -// microseconds since the POSIX epoch. -#define kSbTimeToPosixDelta (SB_INT64_C(-11644473600) * kSbTimeSecond) - -// Converts |SbTime| into microseconds from the POSIX epoch. -// -// |time|: A time that is either measured in microseconds since the epoch of -// January 1, 1601, UTC, or that measures the number of microseconds -// between two times. -static SB_C_FORCE_INLINE int64_t SbTimeToPosix(SbTime time) { - return time + kSbTimeToPosixDelta; -} - -// Converts microseconds from the POSIX epoch into an |SbTime|. -// -// |time|: A time that measures the number of microseconds since -// January 1, 1970, 00:00:00, UTC. -static SB_C_FORCE_INLINE SbTime SbTimeFromPosix(int64_t time) { - return time - kSbTimeToPosixDelta; -} - -// Safely narrows a number from a more precise unit to a less precise one. This -// function rounds negative values toward negative infinity. -static SB_C_FORCE_INLINE int64_t SbTimeNarrow(int64_t time, int64_t divisor) { - return time >= 0 ? time / divisor : (time - divisor + 1) / divisor; -} - -// Gets the current system time as an |SbTime|. -SB_EXPORT SbTime SbTimeGetNow(); - -// Gets a monotonically increasing time representing right now. -SB_EXPORT SbTimeMonotonic SbTimeGetMonotonicNow(); - -// Returns whether the current platform supports time thread now -SB_EXPORT bool SbTimeIsTimeThreadNowSupported(); - -// Gets a monotonically increasing time representing how long the current -// thread has been in the executing state (i.e. not pre-empted nor waiting -// on an event). This is not necessarily total time and is intended to allow -// measuring thread execution time between two timestamps. If this is not -// available then SbTimeGetMonotonicNow() should be used. -SB_EXPORT SbTimeMonotonic SbTimeGetMonotonicThreadNow(); - -#ifdef __cplusplus -} // extern "C" -#endif - -#else // SB_API_VERSION < 16 - #error This file is deprecated with SB_API_VERSION 16. -#endif // SB_API_VERSION < 16 - #endif // STARBOARD_TIME_H_ diff --git a/starboard/ui_navigation.h b/starboard/ui_navigation.h index 6363b2d383fb..16729a4ec8f5 100644 --- a/starboard/ui_navigation.h +++ b/starboard/ui_navigation.h @@ -33,283 +33,6 @@ #ifndef STARBOARD_UI_NAVIGATION_H_ #define STARBOARD_UI_NAVIGATION_H_ -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/export.h" -#include "starboard/types.h" -#include "starboard/window.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// --- Types ----------------------------------------------------------------- - -// An opaque handle to an implementation-private structure representing a -// navigation item. -typedef struct SbUiNavItemPrivate* SbUiNavItem; - -// Navigation items may be one of the following types. This must be specified -// upon item creation and may not change during the item's lifespan. -typedef enum SbUiNavItemType { - // This is a single focusable item. - kSbUiNavItemTypeFocus, - - // This is a container of navigation items which can also be containers - // themselves or focusable items. Containers themselves cannot be focused. - kSbUiNavItemTypeContainer, -} SbUiNavItemType; - -// Navigation items of type kSbUiNavItemTypeContainer have directionality. If -// directionality is not specified for a container, it should default to -// left-to-right and top-to-bottom. -// @verbatim -// For left-to-right, content offset x = 0 shows the leftmost content. -// |<--Container Size-->| -// +--------------------+--------------------+--------------------+ -// | Not selectable. | Selectable. | Selectable. | -// | Offscreen. | Onscreen. | Offscreen. | -// | Negative position. | Positive position. | Positive position. | -// +--------------------+--------------------+--------------------+ -// ^ -// Content Offset X = 0. -// -// For right-to-left, content offset x = 0 shows the rightmost content. -// |<--Container Size-->| -// +--------------------+--------------------+--------------------+ -// | Selectable. | Selectable. | Not selectable. | -// | Offscreen. | Onscreen. | Offscreen. | -// | Negative position. | Positive position. | Positive position. | -// +--------------------+--------------------+--------------------+ -// ^ -// Content Offset X = 0. @endverbatim -// -// Top-to-bottom is similar to left-to-right, but for the Y position. -// Bottom-to-top is similar to right-to-left, but for the Y position. -typedef struct SbUiNavItemDir { - bool is_left_to_right; - bool is_top_to_bottom; -} SbUiNavItemDir; - -// This represents a 2x3 transform matrix in row-major order. -// @verbatim -// | a b tx | -// | c d ty | @endverbatim -typedef struct SbUiNavMatrix2x3 { - float m[6]; -} SbUiNavMatrix2x3; - -// This represents a 4x4 transform matrix in row-major order. -typedef struct SbUiNavMatrix4 { - float m[16]; -} SbUiNavMatrix4; - -// This structure specifies all the callbacks which the platform UI engine -// should invoke for various interaction events on navigation items. These -// callbacks may be invoked from any thread at any frequency. The -// |callback_context| is the value that was passed on creation of the -// relevant SbUiNavItem. -typedef struct SbUiNavCallbacks { - // Invoke when an item has lost focus. This is only used with focus items. - void (*onblur)(SbUiNavItem item, void* callback_context); - - // Invoke when an item has gained focus. This is only used with focus items. - void (*onfocus)(SbUiNavItem item, void* callback_context); - - // Invoke when an item's content offset is changed. This is only used with - // container items. - void (*onscroll)(SbUiNavItem item, void* callback_context); -} SbUiNavCallbacks; - -// This structure declares the interface to the UI navigation implementation. -// All function pointers must be specified if the platform supports UI -// navigation. -typedef struct SbUiNavInterface { - // Create a new navigation item. When the user interacts with this item - // the appropriate SbUiNavCallbacks function will be invoked with the - // provided |callback_context|. An item is not interactable until it is - // enabled. - SbUiNavItem (*create_item)(SbUiNavItemType type, - const SbUiNavCallbacks* callbacks, - void* callback_context); - - // Destroy the given navigation item. If this is a content of another item, - // then it will first be unregistered. Additionally, if this item contains - // other items, then those will be unregistered as well, but they will not - // be automatically destroyed. - void (*destroy_item)(SbUiNavItem item); - - // This is used to manually force focus on a navigation item of type - // kSbUiNavItemTypeFocus. Any previously focused navigation item should - // receive the blur event. If the item is not transitively a content of the - // root item, then this does nothing. - // - // Specifying kSbUiNavItemInvalid should remove focus from the UI navigation - // system. - void (*set_focus)(SbUiNavItem item); - - // This is used to enable or disable user interaction with the specified - // navigation item. All navigation items are disabled when created, and - // they must be explicitly enabled to allow user interaction. If a container - // is disabled, then all of its contents are not interactable even though - // they remain enabled. If |enabled| is false, it must be guaranteed that - // once this function returns, no callbacks associated with this item will - // be invoked until the item is re-enabled. - void (*set_item_enabled)(SbUiNavItem item, bool enabled); - - // This specifies directionality for container items. Containers within - // containers do not inherit directionality. Directionality must be specified - // for each container explicitly. - // - // This should work even if |item| is disabled. - void (*set_item_dir)(SbUiNavItem item, SbUiNavItemDir dir); - - // Set the minimum amount of time the focus item should remain focused once - // it becomes focused. This may be used to make important focus items harder - // to navigate over. Focus may still be moved before |seconds| has elapsed by - // using the set_focus() function. - // By default, item focus duration is 0 seconds. - void (*set_item_focus_duration)(SbUiNavItem item, float seconds); - - // Set the interactable size of the specified navigation item. By default, - // an item's size is (0,0). - void (*set_item_size)(SbUiNavItem item, float width, float height); - - // Set the transform for the navigation item and its contents if the item is - // a container. This specifies the placement of the item's center within its - // container. The transform origin is the center of the item. Distance is - // measured in pixels with the origin being the top-left of the item's - // container. By default, an item's transform is identity. - void (*set_item_transform)(SbUiNavItem item, - const SbUiNavMatrix2x3* transform); - - // Retrieve the focus transform matrix for the navigation item. The UI - // engine may translate, rotate, and/or tilt focus items to reflect user - // interaction. This transform should be multiplied with the item's transform - // to get its position inside its container. The transform origin is the - // center of the item. Return false if the item position should not be - // changed (i.e. the transform should be treated as identity). - bool (*get_item_focus_transform)(SbUiNavItem item, - SbUiNavMatrix4* out_transform); - - // Retrieve a vector representing the focus location within a focused item. - // This is used to provide feedback about user input that is too small to - // result in a focus change. If there is no focus vector for the navigation - // item, then return false and leave |out_x| and |out_y| unchanged. Otherwise, - // return true and set the output values in the range of [-1, +1] with - // (out_x, out_y) of (-1, -1) being the top-left corner of the navigation - // item and (0, 0) being the center. - bool (*get_item_focus_vector)(SbUiNavItem item, float* out_x, float* out_y); - - // This attaches the given navigation item (which must be a container) to - // the specified window. Navigation items are only interactable if they are - // transitively attached to a window. - // - // The native UI engine should never change this navigation item's content - // offset. It is assumed to be used as a proxy for the system window. - // - // A navigation item may only have a SbUiNavItem or SbWindow as its direct - // container. The navigation item hierarchy is established using - // set_item_container_item() with the root container attached to a SbWindow - // using set_item_container_window() to enable interaction with all enabled - // items in the hierarchy. - // - // If |item| is already registered with a different window, then this will - // unregister it from that window then attach it to the given |window|. It - // is an error to register more than one navigation item with any given - // window. If |window| is kSbWindowInvalid, then this will unregister the - // |item| from its current window if any. Upon destruction of |item| or - // |window|, the |item| is automatically unregistered from the |window|. - void (*set_item_container_window)(SbUiNavItem item, SbWindow window); - - // A container navigation item may contain other navigation items. However, - // it is an error to have circular containment or for |container| to not - // be of type kSbUiNavItemTypeContainer. If |item| already has a different - // container, then this first serves that connection. If |container| is - // kSbUiNavItemInvalid, then this removes |item| from its current container. - // Upon destruction of |item| or |container|, the |item| is automatically - // removed from the |container|. - // - // The position of items within a container are specified relative to the - // container's position. The position of these content items are further - // modified by the container's "content offset". - // - // For example, consider item A with position (5,5) and content offset (0,0). - // Given item B with position (10,10) is registered as a content of item A. - // - // 1) Item B should be drawn at position (15,15). - // - // 2) If item A's content offset is changed to (10,0), then item B should be - // drawn at position (5,15). - // - // Essentially, content items should be drawn at: - // [container position] + [content position] - [container content offset] - // - // Content items may overlap within a container. This can cause obscured items - // to be unfocusable. The only rule that needs to be followed is that contents - // which are focus items can obscure other contents which are containers, but - // not vice versa. The caller must ensure that content focus items do not - // overlap other content focus items and content container items do not - // overlap other content container items. - void (*set_item_container_item)(SbUiNavItem item, SbUiNavItem container); - - // Set the current content offset for the given container. This may be used - // to force scrolling to make certain content items visible. A container - // item's content offset helps determine where its content items should be - // drawn. Essentially, a content item should be drawn at: - // [container position] + [content position] - [container content offset] - // If |item| is not a container, then this does nothing. - // By default, the content offset is (0,0). - // - // This should update the values returned by get_item_content_offset() even - // if the |item| is disabled. - void (*set_item_content_offset)(SbUiNavItem item, - float content_offset_x, - float content_offset_y); - - // Retrieve the current content offset for the navigation item. If |item| is - // not a container, then the content offset is (0,0). - // - // The native UI engine should not change the content offset of a container - // unless one of its contents (possibly recursively) is focused. This is to - // allow seamlessly disabling then re-enabling focus items without having - // their containers change offsets. - void (*get_item_content_offset)(SbUiNavItem item, - float* out_content_offset_x, - float* out_content_offset_y); - - // Call |update_function| with |context| to perform a series of UI navigation - // changes atomically before returning. - void (*do_batch_update)(void (*update_function)(void*), void* context); -} SbUiNavInterface; - -// --- Constants ------------------------------------------------------------- - -// Well-defined value for an invalid navigation item. -#define kSbUiNavItemInvalid ((SbUiNavItem)NULL) - -// --- Functions ------------------------------------------------------------- - -// Returns whether the given navigation item handle is valid. -static SB_C_INLINE bool SbUiNavItemIsValid(SbUiNavItem item) { - return item != kSbUiNavItemInvalid; -} - -// Retrieve the platform's UI navigation implementation. If the platform does -// not provide one, then return false without modifying |out_interface|. -// Otherwise, initialize all members of |out_interface| and return true. -// The |out_interface| pointer must not be NULL. -SB_EXPORT bool SbUiNavGetInterface(SbUiNavInterface* out_interface); - -#ifdef __cplusplus -} // extern "C" -#endif - -#else // SB_API_VERSION < 16 - #error This file is deprecated with SB_API_VERSION 16. -#endif // SB_API_VERSION < 16 - #endif // STARBOARD_UI_NAVIGATION_H_ diff --git a/starboard/user.h b/starboard/user.h index 378b04a558dc..c350bfc393d5 100644 --- a/starboard/user.h +++ b/starboard/user.h @@ -25,100 +25,6 @@ #ifndef STARBOARD_USER_H_ #define STARBOARD_USER_H_ -#if SB_API_VERSION < 16 - -#include "starboard/export.h" -#include "starboard/types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// Private structure representing a device user. -typedef struct SbUserPrivate SbUserPrivate; - -// A handle to a user. -typedef SbUserPrivate* SbUser; - -// A set of string properties that can be queried on a user. -#if SB_API_VERSION < 16 -typedef enum SbUserPropertyId { - // The URL to the avatar for a user. Avatars are not provided on all - // platforms. - kSbUserPropertyAvatarUrl, - - // The path to a user's home directory, if supported on this platform. - kSbUserPropertyHomeDirectory, - - // The username of a user, which may be the same as the User ID, or it may be - // friendlier. - kSbUserPropertyUserName, - - // A unique user ID of a user. - kSbUserPropertyUserId, -} SbUserPropertyId; -#endif - -// Well-defined value for an invalid user. -#define kSbUserInvalid (SbUser) NULL - -// Returns whether the given user handle is valid. -static SB_C_INLINE bool SbUserIsValid(SbUser user) { - return user != kSbUserInvalid; -} - -// Gets the current primary user, if one exists. This is the user that is -// determined, in a platform-specific way, to be the primary user controlling -// the application. For example, the determination might be made because that -// user launched the app, though it should be made using whatever criteria are -// appropriate for the platform. -// -// It is expected that there will be a unique SbUser per signed-in user, and -// that the referenced objects will persist for the lifetime of the app. -SB_EXPORT SbUser SbUserGetCurrent(); - -// Gets a list of up to |users_size| signed-in users and places the results in -// |out_users|. The return value identifies the actual number of signed-in -// users, which may be greater or less than |users_size|. -// -// It is expected that there will be a unique |SbUser| per signed-in user and -// that the referenced objects will persist for the lifetime of the app. -// -// |out_users|: Handles for the retrieved users. -// |users_size|: The maximum number of signed-in users to retrieve. -SB_EXPORT int SbUserGetSignedIn(SbUser* out_users, int users_size); - -// Returns the size of the value of |property_id| for |user|, INCLUDING the -// terminating null character. The function returns |0| if |user| is invalid -// or if |property_id| is not recognized, supported, or set for the user. -// -// |user|: The user for which property size data is being retrieved. -// |property_id|: The property for which the data is requested. -SB_EXPORT int SbUserGetPropertySize(SbUser user, SbUserPropertyId property_id); - -// Retrieves the value of |property_id| for |user| and places it in |out_value|. -// The function returns: -// - |true| if the property value is retrieved successfully -// - |false| if |user| is invalid; if |property_id| isn't recognized, supported, -// or set for |user|; or if |value_size| is too small. -// -// |user|: The user for which property size data is being retrieved. -// |property_id|: The property for which the data is requested. -// |out_value|: The retrieved property value. -// |value_size|: The size of the retrieved property value. -SB_EXPORT bool SbUserGetProperty(SbUser user, - SbUserPropertyId property_id, - char* out_value, - int value_size); - -#ifdef __cplusplus -} // extern "C" -#endif - -#else // SB_API_VERSION < 16 - #error This file is deprecated with SB_API_VERSION 16. -#endif // SB_API_VERSION < 16 - #endif // STARBOARD_USER_H_ diff --git a/starboard/window.h b/starboard/window.h index 06c2b73ebaf7..66e76f300daf 100644 --- a/starboard/window.h +++ b/starboard/window.h @@ -137,94 +137,6 @@ SB_EXPORT bool SbWindowGetSize(SbWindow window, SbWindowSize* size); // |window|: The SbWindow to retrieve the platform handle for. SB_EXPORT void* SbWindowGetPlatformHandle(SbWindow window); -#if SB_API_VERSION < 16 - -// System-triggered OnScreenKeyboard events have ticket value -// kSbEventOnScreenKeyboardInvalidTicket. -#define kSbEventOnScreenKeyboardInvalidTicket (-1) - -// Defines a rectangle via a point |(x, y)| and a size |(width, height)|. This -// structure is used as output for SbWindowGetOnScreenKeyboardBoundingRect. -typedef struct SbWindowRect { - float x; - float y; - float width; - float height; -} SbWindowRect; - -// Return whether the current platform supports an on screen keyboard -SB_EXPORT bool SbWindowOnScreenKeyboardIsSupported(); - -// Determine if the on screen keyboard is shown. -SB_EXPORT bool SbWindowIsOnScreenKeyboardShown(SbWindow window); - -// Get the rectangle of the on screen keyboard in screen pixel coordinates. -// Return |true| if successful. Return |false| if the on screen keyboard is not -// showing. If the function returns |false|, then |rect| will not have been -// modified. -SB_EXPORT -bool SbWindowGetOnScreenKeyboardBoundingRect(SbWindow window, - SbWindowRect* bounding_rect); - -// Notify the system that |keepFocus| has been set for the OnScreenKeyboard. -// |keepFocus| true indicates that the user may not navigate focus off of the -// OnScreenKeyboard via input; focus may only be moved via events sent by the -// app. |keepFocus| false indicates that the user may navigate focus off of the -// OnScreenKeyboard via input. |keepFocus| is initialized to false in the -// OnScreenKeyboard constructor. -SB_EXPORT void SbWindowSetOnScreenKeyboardKeepFocus(SbWindow window, - bool keep_focus); - -// Show the on screen keyboard and populate the input with text |input_text|. -// Fire kSbEventTypeWindowSizeChange and kSbEventTypeOnScreenKeyboardShown if -// necessary. kSbEventTypeOnScreenKeyboardShown has data |ticket|. The passed -// in |input_text| will never be NULL, but may be an empty string. Calling -// SbWindowShowOnScreenKeyboard() when the keyboard is already shown is -// permitted, and the input will be replaced with |input_text|. Showing the on -// screen keyboard does not give it focus. -SB_EXPORT void SbWindowShowOnScreenKeyboard(SbWindow window, - const char* input_text, - int ticket); - -// Hide the on screen keyboard. Fire kSbEventTypeWindowSizeChange and -// kSbEventTypeOnScreenKeyboardHidden if necessary. -// kSbEventTypeOnScreenKeyboardHidden has data |ticket|. Calling -// SbWindowHideOnScreenKeyboard() when the keyboard is already hidden is -// permitted. -SB_EXPORT void SbWindowHideOnScreenKeyboard(SbWindow window, int ticket); - -// Focus the on screen keyboard. Fire kSbEventTypeOnScreenKeyboardFocused. -// kSbEventTypeOnScreenKeyboardFocused has data |ticket|. Calling -// SbWindowFocusOnScreenKeyboard() when the keyboard is already focused is -// permitted. Calling SbWindowFocusOnScreenKeyboard while the on screen keyboard -// is not showing does nothing and does not fire any event. -SB_EXPORT void SbWindowFocusOnScreenKeyboard(SbWindow window, int ticket); - -// Blur the on screen keyboard. Fire kSbEventTypeOnScreenKeyboardBlurred. -// kSbEventTypeOnScreenKeyboardBlurred has data |ticket|. Calling -// SbWindowBlurOnScreenKeyboard() when the keyboard is already blurred is -// permitted. Calling SbWindowBlurOnScreenKeyboard while the on screen keyboard -// is not showing does nothing and does not fire any event. -SB_EXPORT void SbWindowBlurOnScreenKeyboard(SbWindow window, int ticket); - -// Update the on screen keyboard custom suggestions. Fire -// kSbEventTypeOnScreenKeyboardSuggestionsUpdated. -// kSbEventTypeOnScreenKeyboardSuggestionsUpdated has data |ticket|. The -// suggestions should remain up-to-date when the keyboard is shown after being -// hidden. -SB_EXPORT void SbWindowUpdateOnScreenKeyboardSuggestions( - SbWindow window, - const char* suggestions[], - int num_suggestions, - int ticket); - -// Determine if the on screen keyboard has suggestions implemented. If this -// returns false, then calling SbWindowUpdateOnScreenKeyboardSuggestions() will -// be undefined. -SB_EXPORT bool SbWindowOnScreenKeyboardSuggestionsSupported(SbWindow window); - -#endif // SB_API_VERSION < 16 - #ifdef __cplusplus } // extern "C" #endif diff --git a/third_party/googletest/src/googletest/include/gtest/internal/gtest-port.h b/third_party/googletest/src/googletest/include/gtest/internal/gtest-port.h index f3ac2e6a6f0e..13c2809c8518 100644 --- a/third_party/googletest/src/googletest/include/gtest/internal/gtest-port.h +++ b/third_party/googletest/src/googletest/include/gtest/internal/gtest-port.h @@ -2080,11 +2080,6 @@ inline int DoIsATTY(int fd) { return 1; } // only called for stdout inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); } -#if SB_API_VERSION < 16 -inline int StrCaseCmp(const char* s1, const char* s2) { - return SbStringCompareNoCase(s1, s2); -} -#endif //SB_API_VERSION < 16 inline char* StrDup(const char* src) { return strdup(src); } inline int RmDir(const char* dir) { return rmdir(dir); } diff --git a/third_party/musl/BUILD.gn b/third_party/musl/BUILD.gn index c74465777685..78ecc77aac79 100644 --- a/third_party/musl/BUILD.gn +++ b/third_party/musl/BUILD.gn @@ -376,7 +376,6 @@ static_library("c_internal") { # Starboardized implementations "src/starboard/ctype/__ctype_get_mb_cur_max.c", - "src/starboard/errno/__errno_location.c", "src/starboard/exit/abort.c", "src/starboard/hwcap/sethwcap.c", "src/starboard/locale/freelocale.c", @@ -385,29 +384,13 @@ static_library("c_internal") { "src/starboard/locale/newlocale.c", "src/starboard/locale/setlocale.c", "src/starboard/locale/uselocale.c", - "src/starboard/malloc/malloc.c", - "src/starboard/malloc/posix_memalign.c", - "src/starboard/mman/mman.c", - "src/starboard/network/socket.c", - "src/starboard/pthread/pthread.c", - "src/starboard/sched/sched.c", "src/starboard/stdio/fflush.c", "src/starboard/stdio/fputc.c", "src/starboard/stdio/stderr.c", "src/starboard/stdio/stdout.c", "src/starboard/stdio/vfprintf.c", - "src/starboard/stdio/vsnprintf.c", - "src/starboard/stdio/vsscanf.c", - "src/starboard/stdio/vswprintf.c", "src/starboard/stdlib/strtod_l.c", - "src/starboard/sys/time/gettimeofday.c", - "src/starboard/dirent.c", "src/starboard/time/__tz.c", - "src/starboard/time/clock_gettime.c", - "src/starboard/time/gmtime_r.c", - "src/starboard/time/time.c", - "src/starboard/sys/stat.c", - "src/starboard/unistd/unistd.c", "src/stdio/__toread.c", "src/stdio/__uflow.c", "src/stdio/fprintf.c", diff --git a/third_party/musl/src/starboard/dirent.c b/third_party/musl/src/starboard/dirent.c deleted file mode 100644 index 448cea605993..000000000000 --- a/third_party/musl/src/starboard/dirent.c +++ /dev/null @@ -1,67 +0,0 @@ -#if SB_API_VERSION < 16 - -#include - -#include -#include -#include -#include "starboard/common/log.h" -#include "starboard/configuration_constants.h" -#include "starboard/directory.h" -#include "starboard/file.h" - -// copied from starboard/common/string.h -int strlcpy_dirent(char* dst, const char* src, int dst_size) { - for (int i = 0; i < dst_size; ++i) { - if ((dst[i] = src[i]) == 0) // We hit and copied the terminating NULL. - return i; - } - - // We were left off at dst_size. We over copied 1 byte. Null terminate. - if (dst_size != 0) - dst[dst_size - 1] = 0; - - // Count the rest of the |src|, and return its length in characters. - while (src[dst_size]) - ++dst_size; - return dst_size; -} - -struct __dirstream { - SbDirectory dir; -}; - -typedef struct __dirstream DIR; - -DIR* opendir(const char *path){ - SbDirectory result = SbDirectoryOpen(path, NULL); - if (result == kSbDirectoryInvalid){ - return NULL; - } - DIR* ret = (DIR*)(malloc(sizeof(DIR))); - ret->dir = result; - return ret; -} - -int closedir(DIR* dir){ - if (!dir || !dir->dir){ - return -1; - } - return SbDirectoryClose(dir->dir) ? 0 : -1; -} - -int readdir_r(DIR* dir, struct dirent* dirent_buf, struct dirent** dirent){ - if (!dir || !dir->dir || !dirent_buf || !dirent){ - dirent = NULL; - return -1; - } - - *dirent = dirent_buf; - if (SbDirectoryGetNext(dir->dir, (*dirent)->d_name, kSbFileMaxName)){ - return 0; - } - dirent = NULL; - return -1; -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/errno/__errno_location.c b/third_party/musl/src/starboard/errno/__errno_location.c deleted file mode 100644 index 98be08a44fe6..000000000000 --- a/third_party/musl/src/starboard/errno/__errno_location.c +++ /dev/null @@ -1,48 +0,0 @@ -#if SB_API_VERSION < 16 -#include -#include - -#include "starboard/common/log.h" -#include "starboard/thread.h" -#include "../pthread/pthread.h" - -static pthread_key_t g_errno_key = 0; -static pthread_once_t g_errno_once = PTHREAD_ONCE_INIT; - -void initialize_errno_key(void) { - pthread_key_create(&g_errno_key , free); - SB_DCHECK(g_errno_key); -} - -// __errno_location() provides every thread with its own copy of |errno|. -// -// The first time __errno_location() is invoked it will initialize a global key. -// This key will then by used by every thread to set, and get, their instance of -// errno from thread-local storage. - -// This function does not take much effect in musl, use SbSystemGetLastError to set -// errno instead. -int *__errno_location(void) { - int result = pthread_once(&g_errno_once, &initialize_errno_key); - SB_DCHECK(result == 0); - - int* value = (int*)pthread_getspecific(g_errno_key); - - if (value) { - return value; - } - - value = (int*)malloc(sizeof(int)); - - SB_DCHECK(value); - result = pthread_setspecific(g_errno_key, value); - SB_DCHECK(result == 0); - - *value = 0; - - return value; -} - -weak_alias(__errno_location, ___errno_location); - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/malloc/malloc.c b/third_party/musl/src/starboard/malloc/malloc.c deleted file mode 100644 index 8f8e79cbf286..000000000000 --- a/third_party/musl/src/starboard/malloc/malloc.c +++ /dev/null @@ -1,27 +0,0 @@ -#include - -#if SB_API_VERSION < 16 -#include "starboard/memory.h" - -void *calloc(size_t m, size_t n) { - return SbMemoryCalloc(m, n); -} - -void free(void *p) { - SbMemoryDeallocate(p); -} - -void *malloc(size_t n) { - return SbMemoryAllocate(n); -} - -void *realloc(void *p, size_t n) { - return SbMemoryReallocate(p, n); -} - -weak_alias(calloc, __libc_calloc); -weak_alias(free, __libc_free); -weak_alias(malloc, __libc_malloc); -weak_alias(realloc, __libc_realloc); - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/malloc/posix_memalign.c b/third_party/musl/src/starboard/malloc/posix_memalign.c deleted file mode 100644 index fbff429a584e..000000000000 --- a/third_party/musl/src/starboard/malloc/posix_memalign.c +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -#if SB_API_VERSION < 16 -#include "starboard/memory.h" - -int posix_memalign(void **res, size_t align, size_t len) { - if (align < sizeof(void *)) return EINVAL; - void *mem = SbMemoryAllocateAligned(align, len); - // Note that the original posix_memalign() implementation returns errno here, - // set to either EINVAL (if the alignment argument is not a power of 2) or - // ENOMEM (if there was insufficient memory to fulfill the allocation - // request). These are also the two possible errors from memalign() when NULL - // is returned. errno can't be used here because it leaks __errno_location. - // Also, the Starboardized implementation of memalign() returns - // SbMemoryAllocateAligned(), whose behavior is undefined when the alignment - // is not a power of 2. So ENOMEM is returned here. - if (!mem) return ENOMEM; - *res = mem; - return 0; -} -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/mman/mman.c b/third_party/musl/src/starboard/mman/mman.c deleted file mode 100644 index c6e7dae152d5..000000000000 --- a/third_party/musl/src/starboard/mman/mman.c +++ /dev/null @@ -1,61 +0,0 @@ -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#if SB_API_VERSION < 16 -#include "starboard/memory.h" - -static SbMemoryMapFlags ToSbMemoryMapFlags(int prot) { - SbMemoryMapFlags sb_prot = kSbMemoryMapProtectReserved; - if (prot & PROT_READ) { - sb_prot |= kSbMemoryMapProtectRead; - } - if (prot & PROT_WRITE) { - sb_prot |= kSbMemoryMapProtectWrite; - } -#if SB_CAN(MAP_EXECUTABLE_MEMORY) - if (prot & PROT_EXEC) { - sb_prot |= kSbMemoryMapProtectExec; - } -#endif - - return sb_prot; -} - -void *mmap (void* addr, size_t len, int prot, int flags, int fd, off_t off) { - if (addr != NULL) { - return MAP_FAILED; - } - if (fd != -1) { - return MAP_FAILED; - } - void*p = SbMemoryMap(len , ToSbMemoryMapFlags(prot), "musl allocation"); - if (!p) { - return MAP_FAILED; - } - return p; -} - -int munmap (void* addr, size_t len) { - if (SbMemoryUnmap(addr, len)) { - return 0; - } - return -1; -} - -int mprotect (void* addr, size_t len, int prot) { - if (SbMemoryProtect(addr, len, ToSbMemoryMapFlags(prot))) { - return 0; - } - return -1; -} - -int msync (void * addr, size_t len, int flags) { - SbMemoryFlush(addr, len); - return 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/network/socket.c b/third_party/musl/src/starboard/network/socket.c deleted file mode 100644 index a14e0cc0835e..000000000000 --- a/third_party/musl/src/starboard/network/socket.c +++ /dev/null @@ -1,959 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/file.h" -#include "starboard/socket.h" -#include "starboard/system.h" -#include "starboard/time.h" -#include "starboard/types.h" -#include "../pthread/pthread.h" - -// Internal database function to convert SbSocket/SbFile object to -// integer, i.e. POSIX file descriptor. -typedef struct FileOrSocket { - bool is_file; - SbFile file; - SbSocket socket; -} FileOrSocket; - -typedef struct Node { - int key; - struct FileOrSocket* value; - struct Node* next; -} Node; - -typedef struct HashMap { - int size; - Node** array; -} HashMap; - -static pthread_mutex_t lock; -static HashMap* map = NULL; -const int mapSize = 2048; -static int mapRecCount = 0; -const socklen_t kAddressLengthIpv4 = 4; -#if SB_HAS(IPV6) -const socklen_t kAddressLengthIpv6 = 16; -#endif -static int get(int key, bool take, FileOrSocket** valuePtr); - -static void createHashMap(int size) { - map = (HashMap*)malloc(sizeof(HashMap)); - memset(map, 0, sizeof(sizeof(HashMap))); - map->size = size; - map->array = (Node**)malloc(size * sizeof(Node*)); - memset(map->array, 0, size * sizeof(Node*)); -} - -static void destroyHashMap(void){ - if (map!= NULL){ - if (map->array!= NULL){ - free(map->array); - } - free(map); - } -} - -static int generateKey(void){ - static int key = 0; - key++; - if (key == 0x7FFFFFFF){ - key = 1; - } - return key; -} - -static int hash(int key, int size) { - return key % size; -} - -static int put(FileOrSocket* value) { - if (map == NULL) { - pthread_mutex_init(&lock, 0); - createHashMap(mapSize); - } - if (mapRecCount == mapSize){ - return -1; - } - - // avoid collision in map - FileOrSocket* valuePtr = NULL; - int key = generateKey(); - while (get(key, false, &valuePtr) == 0){ - key = generateKey(); - } - - pthread_mutex_lock(&lock); - - int index = hash(key, map->size); - Node* node = (Node*)malloc(sizeof(Node)); - node->key = key; - node->value = value; - node->next = map->array[index]; - map->array[index] = node; - mapRecCount++; - - pthread_mutex_unlock(&lock); - return key; -} - -static int get(int key, bool take, FileOrSocket** valuePtr) { - int index = 0; - int status = 0; - if (map == NULL) { - return -1; - } - - pthread_mutex_lock(&lock); - - index = hash(key, map->size); - Node* node = map->array[index]; - if (node != NULL) { - if (node->key == key) { - *valuePtr = node->value; - } - if (take){ - free(map->array[index]); - map->array[index] = NULL; - mapRecCount--; - } - status = 0; - } else { - status = -1; - } - - pthread_mutex_unlock(&lock); - - return status; -} - -static SB_C_FORCE_INLINE time_t WindowsUsecToTimeT(int64_t time) { - int64_t posix_time = time - 11644473600000000ULL; - posix_time = posix_time / 1000000; - return posix_time; -} - -int TranslateSocketErrnoSbToPosix(SbSocketError sbError) { - switch (sbError) { - case kSbSocketOk: - return 0; - case kSbSocketPending: - return EINPROGRESS; - case kSbSocketErrorConnectionReset: - return ECONNRESET; - case kSbSocketErrorFailed: - default: - return -1; - } -} - -int ConvertSocketAddressPosixToSb(const struct sockaddr* address, SbSocketAddress* sbAddress){ - if (address == NULL){ - errno = EINVAL; - return -1; - } - struct sockaddr_in* addr_in = (struct sockaddr_in*)address; - switch (addr_in->sin_family){ - case AF_INET: - sbAddress->type = kSbSocketAddressTypeIpv4; - memcpy(sbAddress->address, &addr_in->sin_addr, kAddressLengthIpv4); - break; -#if SB_HAS(IPV6) - case AF_INET6: - sbAddress->type = kSbSocketAddressTypeIpv6; - memcpy(sbAddress->address, &addr_in->sin_addr, kAddressLengthIpv6); - break; -#endif - } - sbAddress->port = addr_in->sin_port; - - return 0; -} - -int ConvertSocketAddressSbToPosix(const SbSocketAddress* sbAddress, struct sockaddr* address){ - if (sbAddress == NULL){ - errno = EINVAL; - return -1; - } - struct sockaddr_in* addr_in = (struct sockaddr_in*)address; - switch (sbAddress->type){ - case kSbSocketAddressTypeIpv4: - addr_in->sin_family = AF_INET; - memcpy(&addr_in->sin_addr, sbAddress->address, kAddressLengthIpv4); - break; -#if SB_HAS(IPV6) - case kSbSocketAddressTypeIpv6: - addr_in->sin_family = AF_INET6; - memcpy(&addr_in->sin_addr, sbAddress->address, kAddressLengthIpv6); - break; -#endif - default:{} - } - addr_in->sin_port = sbAddress->port; - - return 0; -} - -// The exported POSIX APIs -// -int fstat(int fildes, struct stat* buf) { - if (fildes < 0) { - errno = EBADF; - return -1; - } - - FileOrSocket* fileOrSock = NULL; - if (get(fildes, false, &fileOrSock) != 0) { - errno = EBADF; - return -1; - } - - if (fileOrSock == NULL || !fileOrSock->is_file) { - errno = EBADF; - return -1; - } - - SbFileInfo info; - if (!SbFileGetInfo(fileOrSock->file, &info)) { - return -1; - } - - buf->st_mode = 0; - if (info.is_directory) { - buf->st_mode = S_IFDIR; - } else if (info.is_symbolic_link) { - buf->st_mode = S_IFLNK; - } - buf->st_ctime = WindowsUsecToTimeT(info.creation_time); - buf->st_atime = WindowsUsecToTimeT(info.last_accessed); - buf->st_mtime = WindowsUsecToTimeT(info.last_modified); - buf->st_size = info.size; - - return 0; -} - -int fsync(int fildes) { - if (fildes < 0) { - errno = EBADF; - return -1; - } - - FileOrSocket* fileOrSock = NULL; - if (get(fildes, false, &fileOrSock) != 0) { - errno = EBADF; - return -1; - } - - if (fileOrSock == NULL || !fileOrSock->is_file) { - errno = EBADF; - return -1; - } - - int result = SbFileFlush(fileOrSock->file) ? 0 : -1; - return result; -} - -int ftruncate(int fildes, off_t length) { - if (fildes < 0) { - errno = EBADF; - return -1; - } - - FileOrSocket* fileOrSock = NULL; - if (get(fildes, false, &fileOrSock) != 0) { - errno = EBADF; - return -1; - } - - if (fileOrSock == NULL || !fileOrSock->is_file) { - errno = EBADF; - return -1; - } - - int result = SbFileTruncate(fileOrSock->file, length) ? 0 : -1; - return result; -} - -off_t lseek(int fildes, off_t offset, int whence) { - if (fildes < 0) { - errno = EBADF; - return -1; - } - - FileOrSocket* fileOrSock = NULL; - if (get(fildes, false, &fileOrSock) != 0) { - errno = EBADF; - return -1; - } - - if (fileOrSock == NULL || !fileOrSock->is_file) { - errno = EBADF; - return -1; - } - - SbFileWhence sbWhence; - if (whence == SEEK_SET) { - sbWhence = kSbFileFromBegin; - } else if (whence == SEEK_CUR) { - sbWhence = kSbFileFromCurrent; - } else if (whence == SEEK_END) { - sbWhence = kSbFileFromEnd; - } else { - return -1; - } - return (off_t)SbFileSeek(fileOrSock->file, sbWhence, (int64_t)offset); -} - -int open(const char* path, int oflag, ...) { - bool out_created; - SbFileError out_error; - - if (path == NULL){ - errno = EINVAL; - return -1; - } - - FileOrSocket* value = (FileOrSocket*)malloc(sizeof(struct FileOrSocket)); - memset(value, 0, sizeof(struct FileOrSocket)); - value->is_file = true; - - // Accept the flag without passing it on. Starboard implementations are - // assumed to deal with it. - if (oflag & O_LARGEFILE) { - oflag &= ~O_LARGEFILE; - } - - // Check if mode is specified. Mode is hard-coded to S_IRUSR | S_IWUSR in - // SbFileOpen. Any other modes are not supported. - if (oflag & O_CREAT) { - mode_t sb_file_mode = S_IRUSR | S_IWUSR; - va_list args; - va_start(args, oflag); - mode_t mode = va_arg(args, int); - if (mode != sb_file_mode) { - out_error = kSbFileErrorFailed; - errno = EINVAL; - return -1; - } - } - - int sb_file_flags = 0; - int access_mode_flag = 0; - - if ((oflag & O_ACCMODE) == O_RDONLY) { - access_mode_flag |= kSbFileRead; - } else if ((oflag & O_ACCMODE) == O_WRONLY) { - access_mode_flag |= kSbFileWrite; - oflag &= ~O_WRONLY; - } else if ((oflag & O_ACCMODE) == O_RDWR) { - access_mode_flag |= kSbFileRead | kSbFileWrite; - oflag &= ~O_RDWR; - } else { - // Applications shall specify exactly one of the first three file access - // modes. - out_error = kSbFileErrorFailed; - errno = EINVAL; - return -1; - } - - if (!oflag) { - sb_file_flags = kSbFileOpenOnly; - } - - if (oflag & O_CREAT && oflag & O_EXCL) { - sb_file_flags = kSbFileCreateOnly; - oflag &= ~(O_CREAT | O_EXCL); - } - if (oflag & O_CREAT && oflag & O_TRUNC) { - sb_file_flags = kSbFileCreateAlways; - oflag &= ~(O_CREAT | O_TRUNC); - } - if (oflag & O_CREAT) { - sb_file_flags = kSbFileOpenAlways; - oflag &= ~O_CREAT; - } - if (oflag & O_TRUNC) { - sb_file_flags = kSbFileOpenTruncated; - oflag &= ~O_TRUNC; - } - - // SbFileOpen does not support any other combination of flags. - if (oflag || !sb_file_flags) { - out_error = kSbFileErrorFailed; - errno = EINVAL; - return -1; - } - - int open_flags = sb_file_flags | access_mode_flag; - - value->file = SbFileOpen(path, open_flags, &out_created, &out_error); - if (!SbFileIsValid(value->file)){ - errno = SbSystemGetLastError(); - free(value); - return -1; - } - - int result = put(value); - if (result <= 0){ - errno = EBADF; - SbFileClose(value->file); - free(value); - } - return result; -} - -ssize_t read(int fildes, void* buf, size_t nbyte) { - if (fildes < 0) { - errno = EBADF; - return -1; - } - - FileOrSocket* fileOrSock = NULL; - if (get(fildes, false, &fileOrSock) != 0) { - errno = EBADF; - return -1; - } - - if (fileOrSock == NULL || !fileOrSock->is_file) { - errno = EBADF; - return -1; - } - return (ssize_t)SbFileRead(fileOrSock->file, buf, (int)nbyte); -} - -ssize_t write(int fildes, const void* buf, size_t nbyte) { - if (fildes < 0) { - errno = EBADF; - return -1; - } - - FileOrSocket* fileOrSock = NULL; - if (get(fildes, false, &fileOrSock) != 0) { - errno = EBADF; - return -1; - } - - if (fileOrSock == NULL || !fileOrSock->is_file) { - errno = EBADF; - return -1; - } - return (ssize_t)SbFileWrite(fileOrSock->file, buf, (int)nbyte); -} - -int socket(int domain, int type, int protocol){ - int address_type, socket_protocol; - switch (domain){ - case AF_INET: - address_type = kSbSocketAddressTypeIpv4; - break; - case AF_INET6: - address_type = kSbSocketAddressTypeIpv6; - break; - default: - errno = EAFNOSUPPORT; - return -1; - } - switch (protocol){ - case IPPROTO_TCP: - socket_protocol = kSbSocketProtocolTcp; - break; - case IPPROTO_UDP: - socket_protocol = kSbSocketProtocolUdp; - break; - default: - errno = EAFNOSUPPORT; - return -1; - } - - FileOrSocket* value = (FileOrSocket*)malloc(sizeof(struct FileOrSocket)); - memset(value, 0, sizeof(struct FileOrSocket)); - value->is_file = false; - value->socket = SbSocketCreate(address_type, socket_protocol); - if (!SbSocketIsValid(value->socket)){ - errno = SbSystemGetLastError(); - free(value); - return -1; - } - - int result = put(value); - if (result <= 0){ - SbSocketDestroy(value->socket); - free(value); - } - return result; -} - -int close(int fd){ - if (fd <= 0) { - errno = EBADF; - return -1; - } - FileOrSocket* valueptr = NULL; - if (get(fd, true, &valueptr) != 0) { - errno = EBADF; - return -1; - } - if (valueptr != NULL) { - bool result = false; - if (valueptr->is_file == false){ - result = SbSocketDestroy(valueptr->socket); - } else { - result = SbFileClose(valueptr->file); - } - if (!result){ - errno = EBADF; - return -1; - } - return 0; - } - errno = EBADF; - return -1; -} - -int bind(int socket, const struct sockaddr* address, socklen_t address_len) { - if (address == NULL){ - errno = EINVAL; - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (socket <= 0 || get(socket, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - - SbSocketAddress local_address = {0}; - ConvertSocketAddressPosixToSb(address, &local_address); - - SbSocketError sbError = SbSocketBind(fileOrSock->socket, &local_address); - errno = TranslateSocketErrnoSbToPosix(sbError); - - if (sbError == kSbSocketOk) { - return 0; - } - return -1; -} - -int listen(int socket, int backlog) { - if (socket <= 0){ - errno = EBADF; - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (get(socket, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - - SbSocketError sbError = SbSocketListen(fileOrSock->socket); - errno = TranslateSocketErrnoSbToPosix(sbError); - - if (sbError == kSbSocketOk) { - return 0; - } - return -1; -} - -int accept(int socket, struct sockaddr* addr, socklen_t* addrlen) { - if (socket <= 0){ - errno = EBADF; - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (get(socket, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - - FileOrSocket* value = (FileOrSocket*)malloc(sizeof(struct FileOrSocket)); - memset(value, 0, sizeof(struct FileOrSocket)); - value->is_file = false; - value->socket = SbSocketAccept(fileOrSock->socket); - if (!SbSocketIsValid(value->socket)){ - errno = SbSystemGetLastError(); - free(value); - return -1; - } - - return put(value); -} - -int connect(int socket, const struct sockaddr* name, socklen_t namelen) { - if (socket <= 0 || name == NULL){ - errno = EBADF; - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (get(socket, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - - SbSocketAddress local_address = {0}; - ConvertSocketAddressPosixToSb(name, &local_address); - - SbSocketError sbError = SbSocketConnect(fileOrSock->socket, &local_address); - errno = TranslateSocketErrnoSbToPosix(sbError); - - if (sbError == kSbSocketOk || sbError == kSbSocketPending) { - return 0; - } - return -1; -} - -ssize_t send(int sockfd, const void* buf, size_t len, int flags) { - if (sockfd <= 0){ - errno = EBADF; - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (get(sockfd, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - - int result = SbSocketSendTo(fileOrSock->socket, buf, len, NULL); - if(result == -1) { - errno = SbSystemGetLastError(); - } - - return result; -} - -ssize_t sendto(int sockfd, const void* buf, size_t len, int flags, - const struct sockaddr* dest_addr, - socklen_t dest_len) { - if (sockfd <= 0){ - errno = EBADF; - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (get(sockfd, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - - SbSocketAddress local_address = {0}; - ConvertSocketAddressPosixToSb(dest_addr, &local_address); - - int result = SbSocketSendTo(fileOrSock->socket, buf, len, dest_addr == NULL? NULL: &local_address); - if(result == -1) { - errno = SbSystemGetLastError(); - } - - return result; -} - -ssize_t recv(int sockfd, void* buf, size_t len, int flags) { - if (sockfd <= 0){ - errno = EBADF; - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (get(sockfd, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - - int result = SbSocketReceiveFrom(fileOrSock->socket, buf, len, NULL); - if(result == -1) { - errno = SbSystemGetLastError(); - } - - return result; -} - -ssize_t recvfrom(int sockfd, - void* buf, - size_t len, - int flags, - struct sockaddr* address, - socklen_t* address_len) { - if (sockfd <= 0){ - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (get(sockfd, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - - SbSocketAddress local_address = {0}; - ConvertSocketAddressPosixToSb(address, &local_address); - - int result = SbSocketReceiveFrom(fileOrSock->socket, buf, len, address == NULL? NULL: &local_address); - if(result == -1) { - errno = SbSystemGetLastError(); - } - - return result; -} - -int getsockname(int sockfd, struct sockaddr *restrict addr, socklen_t *restrict addrlen){ - if (sockfd <= 0){ - errno = EBADF; - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (get(sockfd, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - SbSocketAddress out_address = {0}; - int result = SbSocketGetLocalAddress(fileOrSock->socket, &out_address)? 0: -1; - - struct sockaddr_in* addr_in = (struct sockaddr_in*)addr; - addr_in->sin_family = AF_INET; - addr_in->sin_addr.s_addr = out_address.address; - addr_in->sin_port = out_address.port; - *addrlen = sizeof(struct sockaddr_in); - - return result; -} - -int setsockopt (int sockfd, int level, int optname, const void* optval, - socklen_t optlen){ - if (sockfd <= 0){ - errno = EBADF; - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (get(sockfd, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - - if (level == SOL_SOCKET || level == SOL_TCP || level == IPPROTO_TCP || level == IPPROTO_IP) { - int* operation = (int*)optval; - switch (optname){ - case SO_BROADCAST:{ - bool bool_value = (*operation == 1)? true:false; - return SbSocketSetBroadcast(fileOrSock->socket, bool_value) == true? 0:-1; - } - case SO_REUSEADDR:{ - bool bool_value = *operation == 1? true:false; - return SbSocketSetReuseAddress(fileOrSock->socket, bool_value) == true? 0:-1; - } - case SO_RCVBUF:{ - return SbSocketSetReuseAddress(fileOrSock->socket, *operation) == true? 0:-1; - } - case SO_SNDBUF:{ - return SbSocketSetSendBufferSize(fileOrSock->socket, *operation) == true? 0:-1; - } - case SO_KEEPALIVE:{ - bool bool_value = *operation == 1? true:false; - if (bool_value == false){ - return SbSocketSetTcpKeepAlive(fileOrSock->socket, false, 0) == true? 0:-1; - } - } - case TCP_KEEPIDLE:{ - /* function SbSocketSetTcpKeepAlive() also calls setsockopt() with operation code - TCP_KEEPINTVL. Therefore there is not need to take care of case TCP_KEEPINTVL - separately.*/ - if (*operation > 0){ - SbTime period_microsecond = *operation; - period_microsecond *= 1000000; - return SbSocketSetTcpKeepAlive(fileOrSock->socket, true, period_microsecond) == true? 0:-1; - } - break; - } - case TCP_KEEPINTVL:{ - /* function SbSocketSetTcpKeepAlive() also calls setsockopt() with operation code - TCP_KEEPINTVL. Therefore there is not need to take care of case TCP_KEEPINTVL - separately when TCP_KEEPIDLE is set.*/ - break; - return 0; - } - case TCP_NODELAY: { - bool bool_value = *operation == 1? true:false; - return SbSocketSetTcpNoDelay(fileOrSock->socket, bool_value) == true? 0:-1; - } - case IP_ADD_MEMBERSHIP: { - if (optval == NULL) { - errno = EFAULT; - return -1; - } - const struct ip_mreq* imreq = (const struct ip_mreq*)optval; - SbSocketAddress* addr = (SbSocketAddress*)malloc(sizeof(SbSocketAddress)); - memcpy(addr->address, &(imreq->imr_multiaddr.s_addr), sizeof(imreq->imr_multiaddr.s_addr)); - - return SbSocketJoinMulticastGroup(fileOrSock->socket, addr) == true? 0:-1; - } - default: - return -1; - } - } else { - return -1; - } - - return 0; -} - -int fcntl(int fd, int cmd, ... /*arg*/) { - if (fd <= 0){ - return -1; - } - /* This function was used to set socket non-blocking, - * however since SbSocketCreate() sets the socket to - * non-blocking by default, we don't need to set it again.*/ - return 0; -} - -void freeaddrinfo(struct addrinfo *ai) -{ - struct addrinfo* ptr = ai; - while (ai != NULL){ - if (ai->ai_addr != NULL){ - free(ai->ai_addr); - } - ai = ai->ai_next; - free(ptr); - ptr = ai; - } -} - -int getaddrinfo(const char* node, const char* service, const struct addrinfo* hints, struct addrinfo** res) -{ - int filters = 0; - if (hints != NULL){ - if (hints->ai_family == AF_INET) { - filters = kSbSocketResolveFilterIpv4; - } - else if (hints->ai_family == AF_INET6) { - filters = kSbSocketResolveFilterIpv6; - } - else if (hints->ai_family == AF_UNSPEC) { - filters = kSbSocketResolveFilterIpv6 & kSbSocketResolveFilterIpv4; - } - else { - return -1; - } - } - - SbSocketResolution* sbSockResolve = SbSocketResolve(node, filters); - if (sbSockResolve == NULL){ - return -1; - } - - struct addrinfo* ai = (struct addrinfo*)malloc(sizeof(struct addrinfo)); - memset(ai, 0, sizeof(struct addrinfo)); - *res = ai; - - for(int i = 0; i < sbSockResolve->address_count; i++){ - ai->ai_addr = (struct sockaddr*)malloc(sizeof(struct sockaddr)); - memset(ai->ai_addr, 0, sizeof(struct sockaddr)); - ConvertSocketAddressSbToPosix( &sbSockResolve->addresses[i], ai->ai_addr); - ai->ai_addrlen = sizeof(struct sockaddr); - - if (sbSockResolve->addresses[i].type == kSbSocketAddressTypeIpv4) { - ai->ai_family = AF_INET; - } -#if SB_HAS(IPV6) - if (sbSockResolve->addresses[i].type == kSbSocketAddressTypeIpv6) { - ai->ai_family = AF_INET6; - } -#endif - if (i < sbSockResolve->address_count - 1){ - ai->ai_next = (struct addrinfo*)malloc(sizeof(struct addrinfo)); - memset(ai->ai_next, 0, sizeof(struct addrinfo)); - ai = ai->ai_next; - } - } - - SbSocketFreeResolution(sbSockResolve); - return 0; -} - -void freeifaddrs(struct ifaddrs* ifa){ - struct ifaddrs* ptr = ifa; - while (ifa != NULL){ - if (ifa->ifa_addr != NULL){ - free(ifa->ifa_addr); - } - ifa = ifa->ifa_next; - free(ptr); - ptr = ifa; - } -} - -int getifaddrs(struct ifaddrs** ifap) { - - SbSocketAddress sbAddress = {0}; - if (!SbSocketGetInterfaceAddress(NULL, &sbAddress, NULL)){ - return -1; - } - - *ifap = (struct ifaddrs*)malloc(sizeof(struct ifaddrs)); - memset(*ifap, 0, sizeof(struct ifaddrs)); - struct ifaddrs* ifa = *ifap; - ifa->ifa_addr = (struct sockaddr*)malloc(sizeof(struct sockaddr)); - memset(ifa->ifa_addr, 0, sizeof(struct sockaddr)); - ConvertSocketAddressSbToPosix(&sbAddress, ifa->ifa_addr); - return 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/pthread/pthread.c b/third_party/musl/src/starboard/pthread/pthread.c deleted file mode 100644 index 369ed1075984..000000000000 --- a/third_party/musl/src/starboard/pthread/pthread.c +++ /dev/null @@ -1,262 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "third_party/musl/src/starboard/pthread/pthread.h" - -#include - -#if SB_API_VERSION < 16 - -#include "starboard/common/log.h" -#include "starboard/condition_variable.h" -#include "starboard/mutex.h" -#include "starboard/once.h" -#include "starboard/time.h" - -typedef struct pthread_attr_impl_t { - size_t stack_size; - int detach_state; -} pthread_attr_impl_t; - -int pthread_mutex_init(pthread_mutex_t* mutext, const pthread_mutexattr_t*) { - if (SbMutexCreate((SbMutex*)mutext->mutex_buffer)) { - return 0; - } - return EINVAL; -} - -int pthread_mutex_lock(pthread_mutex_t* mutex) { - SbMutexResult result = SbMutexAcquire((SbMutex*)mutex->mutex_buffer); - if (result == kSbMutexAcquired) { - return 0; - } - return EINVAL; -} - -int pthread_mutex_unlock(pthread_mutex_t* mutex) { - if (SbMutexRelease((SbMutex*)mutex->mutex_buffer)) { - return 0; - } - return EINVAL; -} - -int pthread_mutex_trylock(pthread_mutex_t* mutex) { - SbMutexResult result = SbMutexAcquireTry((SbMutex*)mutex->mutex_buffer); - if (result == kSbMutexAcquired) { - return 0; - } - return EINVAL; -} - -int pthread_mutex_destroy(pthread_mutex_t* mutex) { - if (SbMutexDestroy((SbMutex*)mutex->mutex_buffer)) { - return 0; - } - return EINVAL; -} - -int pthread_cond_broadcast(pthread_cond_t* cond) { - return SbConditionVariableBroadcast((SbConditionVariable*)cond->cond_buffer) - ? 0 - : -1; -} - -int pthread_cond_destroy(pthread_cond_t* cond) { - return SbConditionVariableDestroy((SbConditionVariable*)cond->cond_buffer) - ? 0 - : -1; -} - -int pthread_cond_init(pthread_cond_t* cond, const pthread_condattr_t* attr) { - return SbConditionVariableCreate((SbConditionVariable*)cond->cond_buffer, - NULL /* mutex */) - ? 0 - : -1; -} - -int pthread_cond_signal(pthread_cond_t* cond) { - return SbConditionVariableSignal((SbConditionVariable*)cond->cond_buffer) - ? 0 - : -1; -} - -int pthread_cond_timedwait(pthread_cond_t* cond, - pthread_mutex_t* mutex, - const struct timespec* t) { - SbTimeMonotonic now = SbTimeGetMonotonicNow(); - int64_t timeout_duration_microsec = t->tv_sec * 1000000 + t->tv_nsec / 1000; - timeout_duration_microsec -= now; - SbConditionVariableResult result = SbConditionVariableWaitTimed( - (SbConditionVariable*)cond->cond_buffer, (SbMutex*)mutex->mutex_buffer, - timeout_duration_microsec); - if (result == kSbConditionVariableSignaled) { - return 0; - } else if (result == kSbConditionVariableTimedOut) { - return ETIMEDOUT; - } - return -1; -} - -int pthread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex) { - SbConditionVariableResult result = SbConditionVariableWait( - (SbConditionVariable*)cond->cond_buffer, (SbMutex*)mutex->mutex_buffer); - if (result == kSbConditionVariableSignaled) { - return 0; - } - return -1; -} - -int pthread_condattr_destroy(pthread_condattr_t* attr) { - // Not supported in Starboard 14/15 - SB_DCHECK(false); - return -1; -} - -int pthread_condattr_init(pthread_condattr_t* attr) { - // Not supported in Starboard 14/15 - SB_DCHECK(false); - return -1; -} - -int pthread_condattr_getclock(const pthread_condattr_t* attr, - clockid_t* clock_id) { - // Not supported in Starboard 14/15 - SB_DCHECK(false); - return -1; -} - -int pthread_condattr_setclock(pthread_condattr_t* attr, clockid_t clock_id) { - // Not supported in Starboard 14/15 - SB_DCHECK(false); - return -1; -} - -int pthread_once(pthread_once_t* once_control, void (*init_routine)(void)) { - return SbOnce((SbOnceControl*)once_control->once_buffer, init_routine) ? 0 - : -1; -} - -int pthread_create(pthread_t* thread, - const pthread_attr_t* attr, - void* (*start_routine)(void*), - void* arg) { - int stack_size = 0; - bool joinable = true; - if (attr != NULL) { - stack_size = ((pthread_attr_impl_t*)(attr->attr_buffer))->stack_size; - if ((((pthread_attr_impl_t*)(attr->attr_buffer))->detach_state == - PTHREAD_CREATE_DETACHED)) { - joinable = false; - } - } - - SbThread starboard_thread = - SbThreadCreate(stack_size, kSbThreadNoPriority, kSbThreadNoAffinity, - joinable, NULL, start_routine, arg); - if (SbThreadIsValid(thread)) { - *thread = starboard_thread; - return 0; - } - return EINVAL; -} - -int pthread_join(pthread_t thread, void** value_ptr) { - return SbThreadJoin(thread, value_ptr) ? 0 : EINVAL; -} - -int pthread_detach(pthread_t thread) { - SbThreadDetach(thread); - return 0; -} - -pthread_t pthread_self() { - return SbThreadGetCurrent(); -} - -int pthread_equal(pthread_t t1, pthread_t t2) { - return SbThreadIsEqual(t1, t2); -} - -int pthread_key_create(pthread_key_t* key, void (*destructor)(void*)) { - SbThreadLocalKey sb_key = SbThreadCreateLocalKey(destructor); - if (SbThreadIsValidLocalKey(sb_key)) { - *key = sb_key; - return 0; - } - return -1; -} - -int pthread_key_delete(pthread_key_t key) { - SbThreadDestroyLocalKey((SbThreadLocalKey)key); - return 0; -} - -void* pthread_getspecific(pthread_key_t key) { - return SbThreadGetLocalValue((SbThreadLocalKey)key); -} - -int pthread_setspecific(pthread_key_t key, const void* value) { - return SbThreadSetLocalValue((SbThreadLocalKey)key, value) ? 0 : -1; -} - -int pthread_setname_np(pthread_t thread, const char* name) { - // Starboard 14/15 can only set thread name for the current thread - if (SbThreadGetCurrent() != thread) { - SB_DCHECK(false); - return -1; - } - SbThreadSetName(name); - return 0; -} - -int pthread_getname_np(pthread_t thread, char* name, size_t len) { - // Starboard 14/15 can only get the thread name for the current thread - if (SbThreadGetCurrent() != thread) { - SB_DCHECK(false); - return -1; - } - SbThreadGetName(name, len); - return 0; -} - -int pthread_attr_init(pthread_attr_t* attr) { - memset(attr, 0, sizeof(pthread_attr_t)); - return 0; -} - -int pthread_attr_destroy(pthread_attr_t* attr) { - return 0; -} - -int pthread_attr_getstacksize(const pthread_attr_t* attr, size_t* stack_size) { - *stack_size = ((pthread_attr_impl_t*)(attr->attr_buffer))->stack_size; - return 0; -} - -int pthread_attr_setstacksize(pthread_attr_t* attr, size_t stack_size) { - ((pthread_attr_impl_t*)(attr->attr_buffer))->stack_size = stack_size; - return 0; -} - -int pthread_attr_getdetachstate(const pthread_attr_t* attr, int* detach_state) { - *detach_state = ((pthread_attr_impl_t*)(attr->attr_buffer))->detach_state; - return 0; -} - -int pthread_attr_setdetachstate(pthread_attr_t* attr, int detach_state) { - ((pthread_attr_impl_t*)(attr->attr_buffer))->detach_state = detach_state; - return 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/sched/sched.c b/third_party/musl/src/starboard/sched/sched.c deleted file mode 100644 index 1fe6d369f4df..000000000000 --- a/third_party/musl/src/starboard/sched/sched.c +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 -#include - -#include "starboard/thread.h" - -int sched_yield() { - SbThreadYield(); - return 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/stdio/vsnprintf.c b/third_party/musl/src/starboard/stdio/vsnprintf.c deleted file mode 100644 index b2be99b3763e..000000000000 --- a/third_party/musl/src/starboard/stdio/vsnprintf.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include "starboard/string.h" - -#if SB_API_VERSION < 16 - -int vsnprintf(char *restrict s, size_t n, const char *restrict fmt, va_list ap) { - return SbStringFormat(s, n, fmt, ap); -} - -#endif diff --git a/third_party/musl/src/starboard/stdio/vsscanf.c b/third_party/musl/src/starboard/stdio/vsscanf.c deleted file mode 100644 index e84ba5097c67..000000000000 --- a/third_party/musl/src/starboard/stdio/vsscanf.c +++ /dev/null @@ -1,10 +0,0 @@ -#if SB_API_VERSION < 16 - -#include -#include "starboard/string.h" - -int vsscanf(const char *restrict s, const char *restrict fmt, va_list ap) { - return SbStringScan(s, fmt, ap); -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/stdio/vswprintf.c b/third_party/musl/src/starboard/stdio/vswprintf.c deleted file mode 100644 index a9f932f0b285..000000000000 --- a/third_party/musl/src/starboard/stdio/vswprintf.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include "starboard/string.h" - -#if SB_API_VERSION < 16 - -int vswprintf(wchar_t *restrict s, size_t n, const wchar_t *restrict fmt, va_list ap) { - return SbStringFormatWide(s, n, fmt, ap); -} - -#endif diff --git a/third_party/musl/src/starboard/sys/stat.c b/third_party/musl/src/starboard/sys/stat.c deleted file mode 100644 index 81da1b228d2f..000000000000 --- a/third_party/musl/src/starboard/sys/stat.c +++ /dev/null @@ -1,56 +0,0 @@ -#if SB_API_VERSION < 16 - -#include -#include -#include - -#include -#include -#include "starboard/directory.h" - -int mkdir(const char *path, mode_t mode) -{ - if (SbDirectoryCreate(path)){ - return 0; - } - return -1; -} - -// Reverse implementation of TimeTToWindowsUsec and PosixTimeToWindowsTime for backwards compatibility -// TimeTToWindowsUsec converts to microseconds (*1000000) and then calls PosixTimeToWindowsTime -// PosixTimeToWindows time adds number of microseconds since Jan 1, 1601 (UTC) until Jan 1, 1970 (UTC) -static SB_C_FORCE_INLINE time_t WindowsUsecToTimeT(int64_t time) { - int64_t posix_time = time - 11644473600000000ULL; - posix_time = posix_time / 1000000; - return posix_time; -} - -// SbDirectoryCanOpen, SbFileGetPathInfo, SbFileExists, SbFileCanOpen -int stat(const char *path, struct stat *file_info) -{ - if(!SbFileExists(path)) { - errno = ENOENT; - } - - SbFileInfo out_info; - if (!SbFileGetPathInfo(path, &out_info)){ - return -1; - } - - // In SB_API_VERSION < 16, all files are opened with S_IRUSR | S_IWUSR. - // See starboard/shared/posix/impl/file_open.h. - file_info->st_mode = S_IRUSR | S_IWUSR; - if (out_info.is_directory){ - file_info->st_mode |= S_IFDIR; - } else if (out_info.is_symbolic_link){ - file_info->st_mode |= S_IFLNK; - } - - file_info->st_ctime = WindowsUsecToTimeT(out_info.creation_time); - file_info->st_atime = WindowsUsecToTimeT(out_info.last_accessed); - file_info->st_mtime = WindowsUsecToTimeT(out_info.last_modified); - file_info->st_size = out_info.size; - - return 0; -} -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/sys/time/gettimeofday.c b/third_party/musl/src/starboard/sys/time/gettimeofday.c deleted file mode 100644 index 84e1ab7797fc..000000000000 --- a/third_party/musl/src/starboard/sys/time/gettimeofday.c +++ /dev/null @@ -1,22 +0,0 @@ -#if SB_API_VERSION < 16 - -#include -#include -#include - -#include "starboard/time.h" - -int gettimeofday(struct timeval* tp, void* tzp) { - if (tp == NULL) { - return -1; - } - - int64_t windows_time_micros = SbTimeGetNow(); - // Handle number of microseconds btw Jan 1, 1601 (UTC) and Jan 1, 1970 (UTC). - int64_t posix_time_micros = windows_time_micros - 11644473600000000ULL; - tp->tv_sec = (time_t)(posix_time_micros / 1000000); - tp->tv_usec = (suseconds_t)(posix_time_micros % 1000000); - return 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/time/clock_gettime.c b/third_party/musl/src/starboard/time/clock_gettime.c deleted file mode 100644 index 54f2b49e25e0..000000000000 --- a/third_party/musl/src/starboard/time/clock_gettime.c +++ /dev/null @@ -1,39 +0,0 @@ -#include - -#if SB_API_VERSION < 16 - -#include "starboard/common/log.h" -#include "starboard/time.h" - -// Note that with the original musl implementation of clock_gettime(), errno is -// set when -1 is returned; specific errors are not set here. -int clock_gettime(clockid_t clk, struct timespec *ts) { - // There are only Starboard implementations for monotonic and realtime clocks. - // Starboard does also have SbTimeGetMonotonicThreadNow() for - // CLOCK_PROCESS_CPUTIME_ID, but its definition is wrapped in - // #if SB_HAS(TIME_THREAD_NOW) so it can't be used here. - // CLOCK_PROCESS_CPUTIME_ID is potentially used by Cobalt though, so -1 will - // be returned to indicate a failure instead of crashing with this DCHECK. - SB_DCHECK((clk == CLOCK_MONOTONIC) || (clk == CLOCK_REALTIME) || - (clk == CLOCK_PROCESS_CPUTIME_ID)); - - if (clk == CLOCK_MONOTONIC) { - SbTimeMonotonic t = SbTimeGetMonotonicNow(); - if (t == 0) return -1; - - ts->tv_sec = t / kSbTimeSecond; - ts->tv_nsec = (t % kSbTimeSecond) * kSbTimeNanosecondsPerMicrosecond; - return 0; - } else if (clk == CLOCK_REALTIME) { - SbTime t = SbTimeGetNow(); - if (t == 0) return -1; - - ts->tv_sec = t / kSbTimeSecond; - ts->tv_nsec = (t % kSbTimeSecond) * kSbTimeNanosecondsPerMicrosecond; - return 0; - } else { - return -1; - } -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/time/gmtime_r.c b/third_party/musl/src/starboard/time/gmtime_r.c deleted file mode 100644 index 7e89690add12..000000000000 --- a/third_party/musl/src/starboard/time/gmtime_r.c +++ /dev/null @@ -1,28 +0,0 @@ -#if SB_API_VERSION < 16 - -#include - -#include "starboard/client_porting/eztime/eztime.h" - -struct tm *gmtime_r(const time_t *restrict t, struct tm *restrict tm) { - if (!t || !tm) { - return NULL; - } - EzTimeT ezt = (EzTimeT)*t; - EzTimeExploded ezte; - if (EzTimeTExplodeUTC(&ezt, &ezte) == NULL) { - return NULL; - } - tm->tm_sec = ezte.tm_sec; - tm->tm_min = ezte.tm_min; - tm->tm_hour = ezte.tm_hour; - tm->tm_mday = ezte.tm_mday; - tm->tm_mon = ezte.tm_mon; - tm->tm_year = ezte.tm_year; - tm->tm_wday = ezte.tm_wday; - tm->tm_yday = ezte.tm_yday; - tm->tm_isdst = ezte.tm_isdst; - return tm; -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/time/time.c b/third_party/musl/src/starboard/time/time.c deleted file mode 100644 index da7654d49c5c..000000000000 --- a/third_party/musl/src/starboard/time/time.c +++ /dev/null @@ -1,18 +0,0 @@ -#if SB_API_VERSION < 16 - -#include - -#include "starboard/time.h" - -time_t time(time_t *t) { - int64_t posix_us = SbTimeToPosix(SbTimeGetNow()); - int64_t posix_s = posix_us >= 0 ? posix_us / 1000000 - : (posix_us - 1000000 + 1) / 1000000; - time_t time_s = (time_t)posix_s; - if (t) { - *t = time_s; - } - return time_s; -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/unistd/unistd.c b/third_party/musl/src/starboard/unistd/unistd.c deleted file mode 100644 index 20b36eafcb28..000000000000 --- a/third_party/musl/src/starboard/unistd/unistd.c +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 -#include - -#include "starboard/file.h" -#include "starboard/thread.h" - -int rmdir(const char* path) { - SbFileInfo out_info; - if (!SbFileGetPathInfo(path, &out_info)) { - return -1; - } - int result = SbFileDelete(path) ? 0 : -1; - return result; -} - -int unlink(const char* path) { - SbFileInfo out_info; - if (!SbFileGetPathInfo(path, &out_info)) { - return -1; - } - int result = SbFileDelete(path) ? 0 : -1; - return result; -} - -int usleep(useconds_t useconds) { - SbThreadSleep(useconds); - return 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/v8/src/base/platform/condition-variable.cc b/v8/src/base/platform/condition-variable.cc index 31cfbc01ea28..39be28376f02 100644 --- a/v8/src/base/platform/condition-variable.cc +++ b/v8/src/base/platform/condition-variable.cc @@ -166,9 +166,6 @@ bool ConditionVariable::WaitFor(Mutex* mutex, const TimeDelta& rel_time) { #elif V8_OS_STARBOARD ConditionVariable::ConditionVariable() { -#if SB_API_VERSION < 16 - SbConditionVariableCreate(&native_handle_, nullptr); -#else #if !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) pthread_condattr_t attribute; pthread_condattr_init(&attribute); @@ -182,49 +179,25 @@ ConditionVariable::ConditionVariable() { int result = pthread_cond_init(&native_handle_, nullptr); DCHECK(result == 0); #endif // !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) -#endif // SB_API_VERSION < 16 } ConditionVariable::~ConditionVariable() { -#if SB_API_VERSION < 16 - SbConditionVariableDestroy(&native_handle_); -#else pthread_cond_destroy(&native_handle_); -#endif // SB_API_VERSION < 16 } void ConditionVariable::NotifyOne() { -#if SB_API_VERSION < 16 - SbConditionVariableSignal(&native_handle_); -#else pthread_cond_signal(&native_handle_); -#endif // SB_API_VERSION < 16 } void ConditionVariable::NotifyAll() { -#if SB_API_VERSION < 16 - SbConditionVariableBroadcast(&native_handle_); -#else pthread_cond_broadcast(&native_handle_); -#endif // SB_API_VERSION < 16 } void ConditionVariable::Wait(Mutex* mutex) { -#if SB_API_VERSION < 16 - SbConditionVariableWait(&native_handle_, &mutex->native_handle()); -#else pthread_cond_wait(&native_handle_, &mutex->native_handle()); -#endif // SB_API_VERSION < 16 } bool ConditionVariable::WaitFor(Mutex* mutex, const TimeDelta& rel_time) { -#if SB_API_VERSION < 16 - int64_t microseconds = static_cast(rel_time.InMicroseconds()); - SbConditionVariableResult result = SbConditionVariableWaitTimed( - &native_handle_, &mutex->native_handle(), microseconds); - DCHECK(result != kSbConditionVariableFailed); - return result == kSbConditionVariableSignaled; -#else #if !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) int64_t timeout_time_usec = starboard::CurrentMonotonicTime(); #else @@ -238,7 +211,6 @@ bool ConditionVariable::WaitFor(Mutex* mutex, const TimeDelta& rel_time) { int result = pthread_cond_timedwait(&native_handle_, &mutex->native_handle(), &delay_timestamp); return result == 0; -#endif // SB_API_VERSION < 16 } #endif // V8_OS_STARBOARD diff --git a/v8/src/base/platform/condition-variable.h b/v8/src/base/platform/condition-variable.h index bc1740f1d412..d3737ece34f7 100644 --- a/v8/src/base/platform/condition-variable.h +++ b/v8/src/base/platform/condition-variable.h @@ -10,11 +10,7 @@ #include "src/base/platform/mutex.h" #if V8_OS_STARBOARD -#if SB_API_VERSION < 16 -#include "starboard/condition_variable.h" -#else #include -#endif // SB_API_VERSION < 16 #endif namespace v8 { @@ -75,11 +71,7 @@ class V8_BASE_EXPORT ConditionVariable final { #elif V8_OS_WIN using NativeHandle = CONDITION_VARIABLE; #elif V8_OS_STARBOARD -#if SB_API_VERSION < 16 - using NativeHandle = SbConditionVariable; -#else using NativeHandle = pthread_cond_t; -#endif // SB_API_VERSION < 16 #endif NativeHandle& native_handle() { diff --git a/v8/src/base/platform/mutex.cc b/v8/src/base/platform/mutex.cc index f62a82a94f65..45f45b193d1a 100644 --- a/v8/src/base/platform/mutex.cc +++ b/v8/src/base/platform/mutex.cc @@ -297,35 +297,19 @@ bool SharedMutex::TryLockExclusive() { #elif V8_OS_STARBOARD Mutex::Mutex() { -#if SB_API_VERSION < 16 - SbMutexCreate(&native_handle_); -#else pthread_mutex_init(&native_handle_, nullptr); -#endif } Mutex::~Mutex() { -#if SB_API_VERSION < 16 - SbMutexDestroy(&native_handle_); -#else pthread_mutex_destroy(&native_handle_); -#endif } void Mutex::Lock() { -#if SB_API_VERSION < 16 - SbMutexAcquire(&native_handle_); -#else pthread_mutex_lock(&native_handle_); -#endif } void Mutex::Unlock() { -#if SB_API_VERSION < 16 - SbMutexRelease(&native_handle_); -#else pthread_mutex_unlock(&native_handle_); -#endif } RecursiveMutex::RecursiveMutex() {} diff --git a/v8/src/base/platform/mutex.h b/v8/src/base/platform/mutex.h index 60e58ed73ef3..d3bf739097c6 100644 --- a/v8/src/base/platform/mutex.h +++ b/v8/src/base/platform/mutex.h @@ -68,11 +68,7 @@ class V8_BASE_EXPORT Mutex final { #elif V8_OS_WIN using NativeHandle = SRWLOCK; #elif V8_OS_STARBOARD -#if SB_API_VERSION < 16 - using NativeHandle = SbMutex; -#else using NativeHandle = pthread_mutex_t; -#endif // SB_API_VERSION < 16 #endif NativeHandle& native_handle() { diff --git a/v8/src/libsampler/sampler.cc b/v8/src/libsampler/sampler.cc index a0007f9e53de..e29d2d80f869 100644 --- a/v8/src/libsampler/sampler.cc +++ b/v8/src/libsampler/sampler.cc @@ -176,11 +176,7 @@ namespace sampler { class Sampler::PlatformData { public: PlatformData() -#if SB_API_VERSION < 16 - : thread_(SbThreadGetCurrent()), -#else : thread_(pthread_self()), -#endif thread_sampler_(kSbThreadSamplerInvalid) {} ~PlatformData() { ReleaseThreadSampler(); } @@ -199,11 +195,7 @@ class Sampler::PlatformData { } private: -#if SB_API_VERSION < 16 - SbThread thread_; -#else pthread_t thread_; -#endif SbThreadSampler thread_sampler_; };