From d0a432f32c856b43d9ffb3d90eab0e475fd6f95d Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Thu, 21 Sep 2023 12:03:08 -0500 Subject: [PATCH] test --- meson.build | 10 ++--- osdep/threads.c | 4 ++ osdep/win32/include/semaphore.h | 44 ------------------- .../{pthread.c => win32_internal_pthreads.c} | 3 -- .../pthread.h => win32_internal_pthreads.h} | 22 ++++++++++ test/meson.build | 2 +- 6 files changed, 31 insertions(+), 54 deletions(-) delete mode 100644 osdep/win32/include/semaphore.h rename osdep/win32/{pthread.c => win32_internal_pthreads.c} (99%) rename osdep/win32/{include/pthread.h => win32_internal_pthreads.h} (86%) diff --git a/meson.build b/meson.build index 29a93e5757ed6..9505a506cd897 100644 --- a/meson.build +++ b/meson.build @@ -351,7 +351,6 @@ endif # This currently works because these are the last flags set # in the build for windows. Adding any new flags after this # will probably break something. -includedir = [] win32_pthreads = get_option('win32-internal-pthreads').require( win32 and not posix, error_message: 'the os is not win32!', @@ -362,8 +361,7 @@ if features['win32-internal-pthreads'] # Note: Adding this include causes POSIX_TIMERS to be defined for # unclear reasons (some confusion with probably). # Hack around it by using HAVE_WIN32_INTERNAL_PTHREADS. - includedir += include_directories('osdep/win32/include') - sources += files('osdep/win32/pthread.c') + sources += files('osdep/win32/win32_internal_pthreads.c') endif pthread_debug = get_option('pthread-debug').require( @@ -1724,8 +1722,8 @@ client_api_version = major + '.' + minor + '.0' libmpv = library('mpv', sources, dependencies: dependencies, gnu_symbol_visibility: 'hidden', link_args: cc.get_supported_link_arguments(['-Wl,-Bsymbolic']), - version: client_api_version, include_directories: includedir, - install: get_option('libmpv'), build_by_default: get_option('libmpv')) + version: client_api_version, install: get_option('libmpv'), + build_by_default: get_option('libmpv')) if get_option('libmpv') @@ -1767,7 +1765,7 @@ if get_option('cplayer') install_data('etc/mpv-symbolic.svg', install_dir: join_paths(hicolor_dir, 'symbolic', 'apps')) mpv = executable('mpv', objects: libmpv.extract_all_objects(recursive: true), dependencies: dependencies, - win_subsystem: 'windows,6.0', include_directories: includedir, install: true) + win_subsystem: 'windows,6.0', install: true) endif if get_option('tests') diff --git a/osdep/threads.c b/osdep/threads.c index 17642a3f89878..c2bc193ac7604 100644 --- a/osdep/threads.c +++ b/osdep/threads.c @@ -28,6 +28,10 @@ #include #endif +#if HAVE_WIN32_INTERNAL_PTHREADS +#include "osdep/win32/win32_internal_pthreads.h" +#endif + int mpthread_mutex_init_recursive(pthread_mutex_t *mutex) { pthread_mutexattr_t attr; diff --git a/osdep/win32/include/semaphore.h b/osdep/win32/include/semaphore.h deleted file mode 100644 index bc0ed2e374913..0000000000000 --- a/osdep/win32/include/semaphore.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2017 the mpv developers - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef MP_WRAP_SEMAPHORE_H_ -#define MP_WRAP_SEMAPHORE_H_ - -#include - -// See pthread.h for rationale. -#define sem_init m_sem_init -#define sem_destroy m_sem_destroy -#define sem_wait m_sem_wait -#define sem_trywait m_sem_trywait -#define sem_timedwait m_sem_timedwait -#define sem_post m_sem_post - -#define SEM_VALUE_MAX 100 - -typedef struct { - pthread_mutex_t lock; - pthread_cond_t wakeup; - unsigned int value; -} sem_t; - -int sem_init(sem_t *sem, int pshared, unsigned int value); -int sem_destroy(sem_t *sem); -int sem_wait(sem_t *sem); -int sem_trywait(sem_t *sem); -int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout); -int sem_post(sem_t *sem); - -#endif diff --git a/osdep/win32/pthread.c b/osdep/win32/win32_internal_pthreads.c similarity index 99% rename from osdep/win32/pthread.c rename to osdep/win32/win32_internal_pthreads.c index a178d72253e6d..77269816ff8a6 100644 --- a/osdep/win32/pthread.c +++ b/osdep/win32/win32_internal_pthreads.c @@ -13,9 +13,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include - #include #include #include diff --git a/osdep/win32/include/pthread.h b/osdep/win32/win32_internal_pthreads.h similarity index 86% rename from osdep/win32/include/pthread.h rename to osdep/win32/win32_internal_pthreads.h index 6c87949831880..24e366887d529 100644 --- a/osdep/win32/include/pthread.h +++ b/osdep/win32/win32_internal_pthreads.h @@ -96,4 +96,26 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void pthread_set_name_np(pthread_t thread, const char *name); +#define sem_init m_sem_init +#define sem_destroy m_sem_destroy +#define sem_wait m_sem_wait +#define sem_trywait m_sem_trywait +#define sem_timedwait m_sem_timedwait +#define sem_post m_sem_post + +#define SEM_VALUE_MAX 100 + +typedef struct { + pthread_mutex_t lock; + pthread_cond_t wakeup; + unsigned int value; +} sem_t; + +int sem_init(sem_t *sem, int pshared, unsigned int value); +int sem_destroy(sem_t *sem); +int sem_wait(sem_t *sem); +int sem_trywait(sem_t *sem); +int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout); +int sem_post(sem_t *sem); + #endif diff --git a/test/meson.build b/test/meson.build index 7562af1cf7bc9..aa60d2499adf8 100644 --- a/test/meson.build +++ b/test/meson.build @@ -37,7 +37,7 @@ if features['win32-internal-pthreads'] test_utils_args += '-DWIN32_TESTS' test_utils_files += ['osdep/timer.c', 'osdep/timer-win2.c', - 'osdep/win32/pthread.c', + 'osdep/win32/win32_internal_pthreads.c', 'osdep/windows_utils.c'] endif