sched.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. Copyright (c) 2011-2016 mingw-w64 project
  3. Permission is hereby granted, free of charge, to any person obtaining a
  4. copy of this software and associated documentation files (the "Software"),
  5. to deal in the Software without restriction, including without limitation
  6. the rights to use, copy, modify, merge, publish, distribute, sublicense,
  7. and/or sell copies of the Software, and to permit persons to whom the
  8. Software is furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  16. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  17. DEALINGS IN THE SOFTWARE.
  18. */
  19. #include <stddef.h>
  20. #include <errno.h>
  21. #include <sys/types.h>
  22. #include <process.h>
  23. #include <limits.h>
  24. #include <signal.h>
  25. #include <sys/timeb.h>
  26. #ifndef WIN_PTHREADS_SCHED_H
  27. #define WIN_PTHREADS_SCHED_H
  28. #ifndef SCHED_OTHER
  29. /* Some POSIX realtime extensions, mostly stubbed */
  30. #define SCHED_OTHER 0
  31. #define SCHED_FIFO 1
  32. #define SCHED_RR 2
  33. #define SCHED_MIN SCHED_OTHER
  34. #define SCHED_MAX SCHED_RR
  35. struct sched_param {
  36. int sched_priority;
  37. };
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. #if defined(IN_WINPTHREAD)
  42. # if defined(DLL_EXPORT) && !defined(WINPTHREAD_EXPORT_ALL_DEBUG)
  43. # define WINPTHREAD_SCHED_API __declspec(dllexport) /* building the DLL */
  44. # else
  45. # define WINPTHREAD_SCHED_API /* building the static library */
  46. # endif
  47. #else
  48. # if defined(WINPTHREADS_USE_DLLIMPORT)
  49. # define WINPTHREAD_SCHED_API __declspec(dllimport) /* user wants explicit `dllimport` */
  50. # else
  51. # define WINPTHREAD_SCHED_API /* the default; auto imported in case of DLL */
  52. # endif
  53. #endif
  54. int WINPTHREAD_SCHED_API sched_yield(void);
  55. int WINPTHREAD_SCHED_API sched_get_priority_min(int pol);
  56. int WINPTHREAD_SCHED_API sched_get_priority_max(int pol);
  57. int WINPTHREAD_SCHED_API sched_getscheduler(pid_t pid);
  58. int WINPTHREAD_SCHED_API sched_setscheduler(pid_t pid, int pol, const struct sched_param *param);
  59. #ifdef __cplusplus
  60. }
  61. #endif
  62. #endif
  63. #ifndef sched_rr_get_interval
  64. #define sched_rr_get_interval(_p, _i) \
  65. ( errno = ENOTSUP, (int) -1 )
  66. #endif
  67. #endif /* WIN_PTHREADS_SCHED_H */