Merge branch 'master' into windows
[ardour.git] / msvc_extra_headers / ardourext / sched.h.input
1 /*
2  * Module: sched.h
3  *
4  * Purpose:
5  *      Provides an implementation of POSIX realtime extensions
6  *      as defined in 
7  *
8  *              POSIX 1003.1b-1993      (POSIX.1b)
9  *
10  * --------------------------------------------------------------------------
11  *
12  *      Pthreads-win32 - POSIX Threads Library for Win32
13  *      Copyright(C) 1998 John E. Bossom
14  *      Copyright(C) 1999,2005 Pthreads-win32 contributors
15  * 
16  *      Contact Email: rpj@callisto.canberra.edu.au
17  * 
18  *      The current list of contributors is contained
19  *      in the file CONTRIBUTORS included with the source
20  *      code distribution. The list can also be seen at the
21  *      following World Wide Web location:
22  *      http://sources.redhat.com/pthreads-win32/contributors.html
23  * 
24  *      This library is free software; you can redistribute it and/or
25  *      modify it under the terms of the GNU Lesser General Public
26  *      License as published by the Free Software Foundation; either
27  *      version 2 of the License, or (at your option) any later version.
28  * 
29  *      This library is distributed in the hope that it will be useful,
30  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
31  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
32  *      Lesser General Public License for more details.
33  * 
34  *      You should have received a copy of the GNU Lesser General Public
35  *      License along with this library in the file COPYING.LIB;
36  *      if not, write to the Free Software Foundation, Inc.,
37  *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
38  */
39 #ifndef SCHED_H
40 #ifdef  _SCHED_H  // Test added by JE - 12-12-2009
41 #error  "ardourext/sched.h conflicts with an existing pthread library"
42 #endif
43 // Now make sure we can't accidentally include a conflicting library !!
44 #define _SCHED_H
45 #define SCHED_H
46
47 #undef PTW32_LEVEL
48
49 #if defined(_POSIX_SOURCE)
50 #define PTW32_LEVEL 0
51 /* Early POSIX */
52 #endif
53
54 #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
55 #undef PTW32_LEVEL
56 #define PTW32_LEVEL 1
57 /* Include 1b, 1c and 1d */
58 #endif
59
60 #if defined(INCLUDE_NP)
61 #undef PTW32_LEVEL
62 #define PTW32_LEVEL 2
63 /* Include Non-Portable extensions */
64 #endif
65
66 #define PTW32_LEVEL_MAX 3
67
68 #if !defined(PTW32_LEVEL)
69 #define PTW32_LEVEL PTW32_LEVEL_MAX
70 /* Include everything */
71 #endif
72
73
74 #if __GNUC__ && ! defined (__declspec)
75 # error Please upgrade your GNU compiler to one that supports __declspec.
76 #endif
77
78 /*
79  * When building the DLL code, you should define PTW32_BUILD so that
80  * the variables/functions are exported correctly. When using the DLL,
81  * do NOT define PTW32_BUILD, and then the variables/functions will
82  * be imported correctly.
83  */
84 #ifndef PTW32_STATIC_LIB
85 #  ifdef PTW32_BUILD
86 #    define PTW32_DLLPORT __declspec (dllexport)
87 #  else
88 #    define PTW32_DLLPORT __declspec (dllimport)
89 #  endif
90 #else
91 #  define PTW32_DLLPORT
92 #endif
93
94 /*
95  * This is a duplicate of what is in the autoconf config.h,
96  * which is only used when building the pthread-win32 libraries.
97  */
98
99 #ifndef PTW32_CONFIG_H
100 #  if defined(WINCE)
101 #    define NEED_ERRNO
102 #    define NEED_SEM
103 #  endif
104 #  if defined(_UWIN) || defined(__MINGW32__)
105 #    define HAVE_MODE_T
106 #  endif
107 #endif
108
109 /*
110  *
111  */
112
113 #if PTW32_LEVEL >= PTW32_LEVEL_MAX
114 #ifdef NEED_ERRNO
115 #include "need_errno.h"
116 #else
117 #include <errno.h>
118 #endif
119 #endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
120
121 #if defined(__MINGW32__) || defined(_UWIN)
122 #if PTW32_LEVEL >= PTW32_LEVEL_MAX
123 /* For pid_t */
124 #  include <sys/types.h>
125 /* Required by Unix 98 */
126 #  include <time.h>
127 #endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */
128 #else
129 typedef int pid_t;
130 #endif
131
132 /* Thread scheduling policies */
133
134 enum {
135   SCHED_OTHER = 0,
136   SCHED_FIFO,
137   SCHED_RR,
138   SCHED_MIN   = SCHED_OTHER,
139   SCHED_MAX   = SCHED_RR
140 };
141
142 struct sched_param {
143   int sched_priority;
144 };
145
146 #ifdef __cplusplus
147 extern "C"
148 {
149 #endif                          /* __cplusplus */
150
151 PTW32_DLLPORT int __cdecl sched_yield (void);
152
153 PTW32_DLLPORT int __cdecl sched_get_priority_min (int policy);
154
155 PTW32_DLLPORT int __cdecl sched_get_priority_max (int policy);
156
157 PTW32_DLLPORT int __cdecl sched_setscheduler (pid_t pid, int policy);
158
159 PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid);
160
161 /*
162  * Note that this macro returns ENOTSUP rather than
163  * ENOSYS as might be expected. However, returning ENOSYS
164  * should mean that sched_get_priority_{min,max} are
165  * not implemented as well as sched_rr_get_interval.
166  * This is not the case, since we just don't support
167  * round-robin scheduling. Therefore I have chosen to
168  * return the same value as sched_setscheduler when
169  * SCHED_RR is passed to it.
170  */
171 #define sched_rr_get_interval(_pid, _interval) \
172   ( errno = ENOTSUP, (int) -1 )
173
174
175 #ifdef __cplusplus
176 }                               /* End of extern "C" */
177 #endif                          /* __cplusplus */
178
179 #undef PTW32_LEVEL
180 #undef PTW32_LEVEL_MAX
181
182 #endif                          /* !SCHED_H */
183