1 #define PERL_constant_NOTFOUND 1
2 #define PERL_constant_NOTDEF 2
3 #define PERL_constant_ISIV 3
4 #define PERL_constant_ISNO 4
5 #define PERL_constant_ISNV 5
6 #define PERL_constant_ISPV 6
7 #define PERL_constant_ISPVN 7
8 #define PERL_constant_ISSV 8
9 #define PERL_constant_ISUNDEF 9
10 #define PERL_constant_ISUV 10
11 #define PERL_constant_ISYES 11
14 typedef double NV; /* 5.6 and later define NVTYPE, and typedef NV to it. */
17 #define aTHX_ /* 5.6 or later define this for threading support. */
20 #define pTHX_ /* 5.6 or later define this for threading support. */
23 constant_11 (pTHX_ const char *name, IV *iv_return) {
24 /* When generated this function returned values for the list of names given
25 here. However, subsequent manual editing may have added or removed some.
26 ITIMER_PROF ITIMER_REAL d_getitimer d_nanosleep d_setitimer */
27 /* Offset 7 gives the best switch position. */
30 if (memEQ(name, "ITIMER_PROF", 11)) {
33 *iv_return = ITIMER_PROF;
34 return PERL_constant_ISIV;
36 return PERL_constant_NOTDEF;
41 if (memEQ(name, "ITIMER_REAL", 11)) {
44 *iv_return = ITIMER_REAL;
45 return PERL_constant_ISIV;
47 return PERL_constant_NOTDEF;
52 if (memEQ(name, "d_getitimer", 11)) {
56 return PERL_constant_ISIV;
59 return PERL_constant_ISIV;
62 if (memEQ(name, "d_setitimer", 11)) {
66 return PERL_constant_ISIV;
69 return PERL_constant_ISIV;
74 if (memEQ(name, "d_nanosleep", 11)) {
76 #ifdef TIME_HIRES_NANOSLEEP
78 return PERL_constant_ISIV;
81 return PERL_constant_ISIV;
86 return PERL_constant_NOTFOUND;
90 constant_14 (pTHX_ const char *name, IV *iv_return) {
91 /* When generated this function returned values for the list of names given
92 here. However, subsequent manual editing may have added or removed some.
93 CLOCKS_PER_SEC CLOCK_REALTIME CLOCK_SOFTTIME ITIMER_VIRTUAL d_clock_getres
95 /* Offset 8 gives the best switch position. */
98 if (memEQ(name, "CLOCK_REALTIME", 14)) {
100 #ifdef CLOCK_REALTIME
101 *iv_return = CLOCK_REALTIME;
102 return PERL_constant_ISIV;
104 return PERL_constant_NOTDEF;
109 if (memEQ(name, "CLOCKS_PER_SEC", 14)) {
111 #ifdef CLOCKS_PER_SEC
112 *iv_return = CLOCKS_PER_SEC;
113 return PERL_constant_ISIV;
115 return PERL_constant_NOTDEF;
120 if (memEQ(name, "CLOCK_SOFTTIME", 14)) {
122 #ifdef CLOCK_SOFTTIME
123 *iv_return = CLOCK_SOFTTIME;
124 return PERL_constant_ISIV;
126 return PERL_constant_NOTDEF;
131 if (memEQ(name, "ITIMER_VIRTUAL", 14)) {
133 #ifdef ITIMER_VIRTUAL
134 *iv_return = ITIMER_VIRTUAL;
135 return PERL_constant_ISIV;
137 return PERL_constant_NOTDEF;
142 if (memEQ(name, "d_gettimeofday", 14)) {
144 #ifdef HAS_GETTIMEOFDAY
146 return PERL_constant_ISIV;
149 return PERL_constant_ISIV;
154 if (memEQ(name, "d_clock_getres", 14)) {
156 #ifdef TIME_HIRES_CLOCK_GETRES
158 return PERL_constant_ISIV;
161 return PERL_constant_ISIV;
166 return PERL_constant_NOTFOUND;
170 constant_15 (pTHX_ const char *name, IV *iv_return) {
171 /* When generated this function returned values for the list of names given
172 here. However, subsequent manual editing may have added or removed some.
173 CLOCK_MONOTONIC CLOCK_TIMEOFDAY ITIMER_REALPROF d_clock_gettime */
174 /* Offset 7 gives the best switch position. */
177 if (memEQ(name, "CLOCK_TIMEOFDAY", 15)) {
179 #ifdef CLOCK_TIMEOFDAY
180 *iv_return = CLOCK_TIMEOFDAY;
181 return PERL_constant_ISIV;
183 return PERL_constant_NOTDEF;
188 if (memEQ(name, "CLOCK_MONOTONIC", 15)) {
190 #ifdef CLOCK_MONOTONIC
191 *iv_return = CLOCK_MONOTONIC;
192 return PERL_constant_ISIV;
194 return PERL_constant_NOTDEF;
199 if (memEQ(name, "ITIMER_REALPROF", 15)) {
201 #ifdef ITIMER_REALPROF
202 *iv_return = ITIMER_REALPROF;
203 return PERL_constant_ISIV;
205 return PERL_constant_NOTDEF;
210 if (memEQ(name, "d_clock_gettime", 15)) {
212 #ifdef TIME_HIRES_CLOCK_GETTIME
214 return PERL_constant_ISIV;
217 return PERL_constant_ISIV;
222 return PERL_constant_NOTFOUND;
226 constant (pTHX_ const char *name, STRLEN len, IV *iv_return) {
227 /* Initially switch on the length of the name. */
228 /* When generated this function returned values for the list of names given
229 in this section of perl code. Rather than manually editing these functions
230 to add or remove constants, which would result in this comment and section
231 of code becoming inaccurate, we recommend that you edit this section of
232 code, and use it to regenerate a new set of constant functions which you
233 then use to replace the originals.
235 Regenerate these constant functions by feeding this entire source file to
239 use ExtUtils::Constant qw (constant_types C_constant XS_constant);
241 my $types = {map {($_, 1)} qw(IV)};
242 my @names = (qw(CLOCKS_PER_SEC CLOCK_HIGHRES CLOCK_MONOTONIC
243 CLOCK_PROCESS_CPUTIME_ID CLOCK_REALTIME CLOCK_SOFTTIME
244 CLOCK_THREAD_CPUTIME_ID CLOCK_TIMEOFDAY ITIMER_PROF ITIMER_REAL
245 ITIMER_REALPROF ITIMER_VIRTUAL TIMER_ABSTIME),
246 {name=>"d_clock", type=>"IV", macro=>"TIME_HIRES_CLOCK", value=>"1", default=>["IV", "0"]},
247 {name=>"d_clock_getres", type=>"IV", macro=>"TIME_HIRES_CLOCK_GETRES", value=>"1", default=>["IV", "0"]},
248 {name=>"d_clock_gettime", type=>"IV", macro=>"TIME_HIRES_CLOCK_GETTIME", value=>"1", default=>["IV", "0"]},
249 {name=>"d_clock_nanosleep", type=>"IV", macro=>"TIME_HIRES_CLOCK_NANOSLEEP", value=>"1", default=>["IV", "0"]},
250 {name=>"d_getitimer", type=>"IV", macro=>"HAS_GETITIMER", value=>"1", default=>["IV", "0"]},
251 {name=>"d_gettimeofday", type=>"IV", macro=>"HAS_GETTIMEOFDAY", value=>"1", default=>["IV", "0"]},
252 {name=>"d_hires_stat", type=>"IV", macro=>"TIME_HIRES_STAT", value=>"1", default=>["IV", "0"]},
253 {name=>"d_nanosleep", type=>"IV", macro=>"TIME_HIRES_NANOSLEEP", value=>"1", default=>["IV", "0"]},
254 {name=>"d_setitimer", type=>"IV", macro=>"HAS_SETITIMER", value=>"1", default=>["IV", "0"]},
255 {name=>"d_ualarm", type=>"IV", macro=>"HAS_UALARM", value=>"1", default=>["IV", "0"]},
256 {name=>"d_usleep", type=>"IV", macro=>"HAS_USLEEP", value=>"1", default=>["IV", "0"]});
258 print constant_types(); # macro defs
259 foreach (C_constant ("Time::HiRes", 'constant', 'IV', $types, undef, 3, @names) ) {
260 print $_, "\n"; # C constant subs
262 print "#### XS Section:\n";
263 print XS_constant ("Time::HiRes", $types);
269 if (memEQ(name, "d_clock", 7)) {
270 #ifdef TIME_HIRES_CLOCK
272 return PERL_constant_ISIV;
275 return PERL_constant_ISIV;
280 /* Names all of length 8. */
281 /* d_ualarm d_usleep */
282 /* Offset 7 gives the best switch position. */
285 if (memEQ(name, "d_ualar", 7)) {
289 return PERL_constant_ISIV;
292 return PERL_constant_ISIV;
297 if (memEQ(name, "d_uslee", 7)) {
301 return PERL_constant_ISIV;
304 return PERL_constant_ISIV;
311 return constant_11 (aTHX_ name, iv_return);
314 if (memEQ(name, "d_hires_stat", 12)) {
315 #ifdef TIME_HIRES_STAT
317 return PERL_constant_ISIV;
320 return PERL_constant_ISIV;
325 /* Names all of length 13. */
326 /* CLOCK_HIGHRES TIMER_ABSTIME */
327 /* Offset 2 gives the best switch position. */
330 if (memEQ(name, "TIMER_ABSTIME", 13)) {
333 *iv_return = TIMER_ABSTIME;
334 return PERL_constant_ISIV;
336 return PERL_constant_NOTDEF;
341 if (memEQ(name, "CLOCK_HIGHRES", 13)) {
344 *iv_return = CLOCK_HIGHRES;
345 return PERL_constant_ISIV;
347 return PERL_constant_NOTDEF;
354 return constant_14 (aTHX_ name, iv_return);
357 return constant_15 (aTHX_ name, iv_return);
360 if (memEQ(name, "d_clock_nanosleep", 17)) {
361 #ifdef TIME_HIRES_CLOCK_NANOSLEEP
363 return PERL_constant_ISIV;
366 return PERL_constant_ISIV;
371 if (memEQ(name, "CLOCK_THREAD_CPUTIME_ID", 23)) {
372 #ifdef CLOCK_THREAD_CPUTIME_ID
373 *iv_return = CLOCK_THREAD_CPUTIME_ID;
374 return PERL_constant_ISIV;
376 return PERL_constant_NOTDEF;
381 if (memEQ(name, "CLOCK_PROCESS_CPUTIME_ID", 24)) {
382 #ifdef CLOCK_PROCESS_CPUTIME_ID
383 *iv_return = CLOCK_PROCESS_CPUTIME_ID;
384 return PERL_constant_ISIV;
386 return PERL_constant_NOTDEF;
391 return PERL_constant_NOTFOUND;