win32thread.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*****************************************************************************
  2. * win32thread.h: windows threading
  3. *****************************************************************************
  4. * Copyright (C) 2010-2018 x264 project
  5. *
  6. * Authors: Steven Walters <kemuri9@gmail.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
  21. *
  22. * This program is also available under a commercial proprietary license.
  23. * For more information, contact us at licensing@x264.com.
  24. *****************************************************************************/
  25. #ifndef X264_WIN32THREAD_H
  26. #define X264_WIN32THREAD_H
  27. #include <windows.h>
  28. /* the following macro is used within x264 */
  29. #undef ERROR
  30. typedef struct
  31. {
  32. void *handle;
  33. void *(*func)( void* arg );
  34. void *arg;
  35. void **p_ret;
  36. void *ret;
  37. } x264_pthread_t;
  38. #define x264_pthread_attr_t int
  39. /* the conditional variable api for windows 6.0+ uses critical sections and not mutexes */
  40. typedef CRITICAL_SECTION x264_pthread_mutex_t;
  41. #define X264_PTHREAD_MUTEX_INITIALIZER {0}
  42. #define x264_pthread_mutexattr_t int
  43. #if HAVE_WINRT
  44. typedef CONDITION_VARIABLE x264_pthread_cond_t;
  45. #else
  46. typedef struct
  47. {
  48. void *Ptr;
  49. } x264_pthread_cond_t;
  50. #endif
  51. #define x264_pthread_condattr_t int
  52. int x264_pthread_create( x264_pthread_t *thread, const x264_pthread_attr_t *attr,
  53. void *(*start_routine)( void* ), void *arg );
  54. int x264_pthread_join( x264_pthread_t thread, void **value_ptr );
  55. int x264_pthread_mutex_init( x264_pthread_mutex_t *mutex, const x264_pthread_mutexattr_t *attr );
  56. int x264_pthread_mutex_destroy( x264_pthread_mutex_t *mutex );
  57. int x264_pthread_mutex_lock( x264_pthread_mutex_t *mutex );
  58. int x264_pthread_mutex_unlock( x264_pthread_mutex_t *mutex );
  59. int x264_pthread_cond_init( x264_pthread_cond_t *cond, const x264_pthread_condattr_t *attr );
  60. int x264_pthread_cond_destroy( x264_pthread_cond_t *cond );
  61. int x264_pthread_cond_broadcast( x264_pthread_cond_t *cond );
  62. int x264_pthread_cond_wait( x264_pthread_cond_t *cond, x264_pthread_mutex_t *mutex );
  63. int x264_pthread_cond_signal( x264_pthread_cond_t *cond );
  64. #define x264_pthread_attr_init(a) 0
  65. #define x264_pthread_attr_destroy(a) 0
  66. int x264_win32_threading_init( void );
  67. void x264_win32_threading_destroy( void );
  68. int x264_pthread_num_processors_np( void );
  69. #endif