File Coverage

const-c.inc
Criterion Covered Total %
statement 65 197 32.9
branch 15 88 17.0
condition n/a
subroutine n/a
pod n/a
total 80 285 28.0


line stmt bran cond sub pod time code
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
12              
13             #ifndef NVTYPE
14             typedef double NV; /* 5.6 and later define NVTYPE, and typedef NV to it. */
15             #endif
16             #ifndef aTHX_
17             #define aTHX_ /* 5.6 or later define this for threading support. */
18             #endif
19             #ifndef pTHX_
20             #define pTHX_ /* 5.6 or later define this for threading support. */
21             #endif
22              
23             static int
24 2           constant_11 (pTHX_ const char *name, IV *iv_return) {
25             /* When generated this function returned values for the list of names given
26             here. However, subsequent manual editing may have added or removed some.
27             ITIMER_PROF ITIMER_REAL d_getitimer d_nanosleep d_setitimer d_utimensat */
28             /* Offset 7 gives the best switch position. */
29 2           switch (name[7]) {
30             case 'P':
31 0 0         if (memEQ(name, "ITIMER_PROF", 11)) {
32             /* ^ */
33             #ifdef ITIMER_PROF
34 0           *iv_return = ITIMER_PROF;
35 0           return PERL_constant_ISIV;
36             #else
37             return PERL_constant_NOTDEF;
38             #endif
39             }
40 0           break;
41             case 'R':
42 0 0         if (memEQ(name, "ITIMER_REAL", 11)) {
43             /* ^ */
44             #ifdef ITIMER_REAL
45 0           *iv_return = ITIMER_REAL;
46 0           return PERL_constant_ISIV;
47             #else
48             return PERL_constant_NOTDEF;
49             #endif
50             }
51 0           break;
52             case 'i':
53 0 0         if (memEQ(name, "d_getitimer", 11)) {
54             /* ^ */
55             #ifdef HAS_GETITIMER
56 0           *iv_return = 1;
57 0           return PERL_constant_ISIV;
58             #else
59             *iv_return = 0;
60             return PERL_constant_ISIV;
61             #endif
62             }
63 0 0         if (memEQ(name, "d_setitimer", 11)) {
64             /* ^ */
65             #ifdef HAS_SETITIMER
66 0           *iv_return = 1;
67 0           return PERL_constant_ISIV;
68             #else
69             *iv_return = 0;
70             return PERL_constant_ISIV;
71             #endif
72             }
73 0           break;
74             case 'l':
75 1 50         if (memEQ(name, "d_nanosleep", 11)) {
76             /* ^ */
77             #ifdef TIME_HIRES_NANOSLEEP
78 1           *iv_return = 1;
79 1           return PERL_constant_ISIV;
80             #else
81             *iv_return = 0;
82             return PERL_constant_ISIV;
83             #endif
84             }
85 0           break;
86             case 'n':
87 1 50         if (memEQ(name, "d_utimensat", 11)) {
88             /* ^ */
89             #ifdef HAS_UTIMENSAT
90 1           *iv_return = 1;
91 1           return PERL_constant_ISIV;
92             #else
93             *iv_return = 0;
94             return PERL_constant_ISIV;
95             #endif
96             }
97 0           break;
98             }
99 0           return PERL_constant_NOTFOUND;
100             }
101              
102             static int
103 2           constant_12 (pTHX_ const char *name, IV *iv_return) {
104             /* When generated this function returned values for the list of names given
105             here. However, subsequent manual editing may have added or removed some.
106             CLOCK_SECOND CLOCK_UPTIME d_hires_stat */
107             /* Offset 10 gives the best switch position. */
108 2           switch (name[10]) {
109             case 'M':
110 0 0         if (memEQ(name, "CLOCK_UPTIME", 12)) {
111             /* ^ */
112             #ifdef CLOCK_UPTIME
113             *iv_return = CLOCK_UPTIME;
114             return PERL_constant_ISIV;
115             #else
116 0           return PERL_constant_NOTDEF;
117             #endif
118             }
119 0           break;
120             case 'N':
121 0 0         if (memEQ(name, "CLOCK_SECOND", 12)) {
122             /* ^ */
123             #ifdef CLOCK_SECOND
124             *iv_return = CLOCK_SECOND;
125             return PERL_constant_ISIV;
126             #else
127 0           return PERL_constant_NOTDEF;
128             #endif
129             }
130 0           break;
131             case 'a':
132 2 50         if (memEQ(name, "d_hires_stat", 12)) {
133             /* ^ */
134             #ifdef TIME_HIRES_STAT
135 2           *iv_return = 4;
136 2           return PERL_constant_ISIV;
137             #else
138             *iv_return = 0;
139             return PERL_constant_ISIV;
140             #endif
141             }
142 0           break;
143             }
144 0           return PERL_constant_NOTFOUND;
145             }
146              
147             static int
148 1           constant_13 (pTHX_ const char *name, IV *iv_return) {
149             /* When generated this function returned values for the list of names given
150             here. However, subsequent manual editing may have added or removed some.
151             CLOCK_HIGHRES CLOCK_VIRTUAL TIMER_ABSTIME d_hires_utime */
152             /* Offset 12 gives the best switch position. */
153 1           switch (name[12]) {
154             case 'E':
155 0 0         if (memEQ(name, "TIMER_ABSTIM", 12)) {
156             /* E */
157             #ifdef TIMER_ABSTIME
158 0           *iv_return = TIMER_ABSTIME;
159 0           return PERL_constant_ISIV;
160             #else
161             return PERL_constant_NOTDEF;
162             #endif
163             }
164 0           break;
165             case 'L':
166 0 0         if (memEQ(name, "CLOCK_VIRTUA", 12)) {
167             /* L */
168             #ifdef CLOCK_VIRTUAL
169             *iv_return = CLOCK_VIRTUAL;
170             return PERL_constant_ISIV;
171             #else
172 0           return PERL_constant_NOTDEF;
173             #endif
174             }
175 0           break;
176             case 'S':
177 0 0         if (memEQ(name, "CLOCK_HIGHRE", 12)) {
178             /* S */
179             #ifdef CLOCK_HIGHRES
180             *iv_return = CLOCK_HIGHRES;
181             return PERL_constant_ISIV;
182             #else
183 0           return PERL_constant_NOTDEF;
184             #endif
185             }
186 0           break;
187             case 'e':
188 1 50         if (memEQ(name, "d_hires_utim", 12)) {
189             /* e */
190             #ifdef TIME_HIRES_UTIME
191 1           *iv_return = 1;
192 1           return PERL_constant_ISIV;
193             #else
194             *iv_return = 0;
195             return PERL_constant_ISIV;
196             #endif
197             }
198 0           break;
199             }
200 0           return PERL_constant_NOTFOUND;
201             }
202              
203             static int
204 8           constant_14 (pTHX_ const char *name, IV *iv_return) {
205             /* When generated this function returned values for the list of names given
206             here. However, subsequent manual editing may have added or removed some.
207             CLOCKS_PER_SEC CLOCK_BOOTTIME CLOCK_REALTIME CLOCK_SOFTTIME ITIMER_VIRTUAL
208             d_clock_getres d_gettimeofday */
209             /* Offset 8 gives the best switch position. */
210 8           switch (name[8]) {
211             case 'A':
212 1 50         if (memEQ(name, "CLOCK_REALTIME", 14)) {
213             /* ^ */
214             #ifdef CLOCK_REALTIME
215 1           *iv_return = CLOCK_REALTIME;
216 1           return PERL_constant_ISIV;
217             #else
218             return PERL_constant_NOTDEF;
219             #endif
220             }
221 0           break;
222             case 'E':
223 1 50         if (memEQ(name, "CLOCKS_PER_SEC", 14)) {
224             /* ^ */
225             #ifdef CLOCKS_PER_SEC
226 1           *iv_return = CLOCKS_PER_SEC;
227 1           return PERL_constant_ISIV;
228             #else
229             return PERL_constant_NOTDEF;
230             #endif
231             }
232 0           break;
233             case 'F':
234 0 0         if (memEQ(name, "CLOCK_SOFTTIME", 14)) {
235             /* ^ */
236             #ifdef CLOCK_SOFTTIME
237             *iv_return = CLOCK_SOFTTIME;
238             return PERL_constant_ISIV;
239             #else
240 0           return PERL_constant_NOTDEF;
241             #endif
242             }
243 0           break;
244             case 'I':
245 1 50         if (memEQ(name, "ITIMER_VIRTUAL", 14)) {
246             /* ^ */
247             #ifdef ITIMER_VIRTUAL
248 1           *iv_return = ITIMER_VIRTUAL;
249 1           return PERL_constant_ISIV;
250             #else
251             return PERL_constant_NOTDEF;
252             #endif
253             }
254 0           break;
255             case 'O':
256 0 0         if (memEQ(name, "CLOCK_BOOTTIME", 14)) {
257             /* ^ */
258             #ifdef CLOCK_BOOTTIME
259 0           *iv_return = CLOCK_BOOTTIME;
260 0           return PERL_constant_ISIV;
261             #else
262             return PERL_constant_NOTDEF;
263             #endif
264             }
265 0           break;
266             case 'e':
267 4 50         if (memEQ(name, "d_gettimeofday", 14)) {
268             /* ^ */
269             #ifdef HAS_GETTIMEOFDAY
270 4           *iv_return = 1;
271 4           return PERL_constant_ISIV;
272             #else
273             *iv_return = 0;
274             return PERL_constant_ISIV;
275             #endif
276             }
277 0           break;
278             case 'g':
279 1 50         if (memEQ(name, "d_clock_getres", 14)) {
280             /* ^ */
281             #ifdef TIME_HIRES_CLOCK_GETRES
282 1           *iv_return = 1;
283 1           return PERL_constant_ISIV;
284             #else
285             *iv_return = 0;
286             return PERL_constant_ISIV;
287             #endif
288             }
289 0           break;
290             }
291 0           return PERL_constant_NOTFOUND;
292             }
293              
294             static int
295 1           constant_15 (pTHX_ const char *name, IV *iv_return) {
296             /* When generated this function returned values for the list of names given
297             here. However, subsequent manual editing may have added or removed some.
298             CLOCK_MONOTONIC CLOCK_TIMEOFDAY ITIMER_REALPROF d_clock_gettime */
299             /* Offset 7 gives the best switch position. */
300 1           switch (name[7]) {
301             case 'I':
302 0 0         if (memEQ(name, "CLOCK_TIMEOFDAY", 15)) {
303             /* ^ */
304             #ifdef CLOCK_TIMEOFDAY
305             *iv_return = CLOCK_TIMEOFDAY;
306             return PERL_constant_ISIV;
307             #else
308 0           return PERL_constant_NOTDEF;
309             #endif
310             }
311 0           break;
312             case 'O':
313 0 0         if (memEQ(name, "CLOCK_MONOTONIC", 15)) {
314             /* ^ */
315             #ifdef CLOCK_MONOTONIC
316 0           *iv_return = CLOCK_MONOTONIC;
317 0           return PERL_constant_ISIV;
318             #else
319             return PERL_constant_NOTDEF;
320             #endif
321             }
322 0           break;
323             case 'R':
324 0 0         if (memEQ(name, "ITIMER_REALPROF", 15)) {
325             /* ^ */
326             #ifdef ITIMER_REALPROF
327             *iv_return = ITIMER_REALPROF;
328             return PERL_constant_ISIV;
329             #else
330 0           return PERL_constant_NOTDEF;
331             #endif
332             }
333 0           break;
334             case '_':
335 1 50         if (memEQ(name, "d_clock_gettime", 15)) {
336             /* ^ */
337             #ifdef TIME_HIRES_CLOCK_GETTIME
338 1           *iv_return = 1;
339 1           return PERL_constant_ISIV;
340             #else
341             *iv_return = 0;
342             return PERL_constant_ISIV;
343             #endif
344             }
345 0           break;
346             }
347 0           return PERL_constant_NOTFOUND;
348             }
349              
350             static int
351 0           constant_19 (pTHX_ const char *name, IV *iv_return) {
352             /* When generated this function returned values for the list of names given
353             here. However, subsequent manual editing may have added or removed some.
354             CLOCK_MONOTONIC_RAW CLOCK_REALTIME_FAST CLOCK_UPTIME_COARSE */
355             /* Offset 9 gives the best switch position. */
356 0           switch (name[9]) {
357             case 'I':
358 0 0         if (memEQ(name, "CLOCK_UPTIME_COARSE", 19)) {
359             /* ^ */
360             #ifdef CLOCK_UPTIME_COARSE
361             *iv_return = CLOCK_UPTIME_COARSE;
362             return PERL_constant_ISIV;
363             #else
364 0           return PERL_constant_NOTDEF;
365             #endif
366             }
367 0           break;
368             case 'L':
369 0 0         if (memEQ(name, "CLOCK_REALTIME_FAST", 19)) {
370             /* ^ */
371             #ifdef CLOCK_REALTIME_FAST
372             *iv_return = CLOCK_REALTIME_FAST;
373             return PERL_constant_ISIV;
374             #else
375 0           return PERL_constant_NOTDEF;
376             #endif
377             }
378 0           break;
379             case 'O':
380 0 0         if (memEQ(name, "CLOCK_MONOTONIC_RAW", 19)) {
381             /* ^ */
382             #ifdef CLOCK_MONOTONIC_RAW
383 0           *iv_return = CLOCK_MONOTONIC_RAW;
384 0           return PERL_constant_ISIV;
385             #else
386             return PERL_constant_NOTDEF;
387             #endif
388             }
389 0           break;
390             }
391 0           return PERL_constant_NOTFOUND;
392             }
393              
394             static int
395 20           constant (pTHX_ const char *name, STRLEN len, IV *iv_return) {
396             /* Initially switch on the length of the name. */
397             /* When generated this function returned values for the list of names given
398             in this section of perl code. Rather than manually editing these functions
399             to add or remove constants, which would result in this comment and section
400             of code becoming inaccurate, we recommend that you edit this section of
401             code, and use it to regenerate a new set of constant functions which you
402             then use to replace the originals.
403              
404             Regenerate these constant functions by feeding this entire source file to
405             perl -x
406              
407             #!/usr/local/bin/perl -w
408             use ExtUtils::Constant qw (constant_types C_constant XS_constant);
409              
410             my $types = {map {($_, 1)} qw(IV)};
411             my @names = (qw(CLOCKS_PER_SEC CLOCK_BOOTTIME CLOCK_HIGHRES CLOCK_MONOTONIC
412             CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_FAST
413             CLOCK_MONOTONIC_PRECISE CLOCK_MONOTONIC_RAW
414             CLOCK_PROCESS_CPUTIME_ID CLOCK_PROF CLOCK_REALTIME
415             CLOCK_REALTIME_COARSE CLOCK_REALTIME_FAST CLOCK_REALTIME_PRECISE
416             CLOCK_REALTIME_RAW CLOCK_SECOND CLOCK_SOFTTIME
417             CLOCK_THREAD_CPUTIME_ID CLOCK_TIMEOFDAY CLOCK_UPTIME
418             CLOCK_UPTIME_COARSE CLOCK_UPTIME_FAST CLOCK_UPTIME_PRECISE
419             CLOCK_UPTIME_RAW CLOCK_VIRTUAL ITIMER_PROF ITIMER_REAL
420             ITIMER_REALPROF ITIMER_VIRTUAL TIMER_ABSTIME),
421             {name=>"d_clock", type=>"IV", macro=>"TIME_HIRES_CLOCK", value=>"1", default=>["IV", "0"]},
422             {name=>"d_clock_getres", type=>"IV", macro=>"TIME_HIRES_CLOCK_GETRES", value=>"1", default=>["IV", "0"]},
423             {name=>"d_clock_gettime", type=>"IV", macro=>"TIME_HIRES_CLOCK_GETTIME", value=>"1", default=>["IV", "0"]},
424             {name=>"d_clock_nanosleep", type=>"IV", macro=>"TIME_HIRES_CLOCK_NANOSLEEP", value=>"1", default=>["IV", "0"]},
425             {name=>"d_futimens", type=>"IV", macro=>"HAS_FUTIMENS", value=>"1", default=>["IV", "0"]},
426             {name=>"d_getitimer", type=>"IV", macro=>"HAS_GETITIMER", value=>"1", default=>["IV", "0"]},
427             {name=>"d_gettimeofday", type=>"IV", macro=>"HAS_GETTIMEOFDAY", value=>"1", default=>["IV", "0"]},
428             {name=>"d_hires_stat", type=>"IV", macro=>"TIME_HIRES_STAT", value=>"4", default=>["IV", "0"]},
429             {name=>"d_hires_utime", type=>"IV", macro=>"TIME_HIRES_UTIME", value=>"1", default=>["IV", "0"]},
430             {name=>"d_nanosleep", type=>"IV", macro=>"TIME_HIRES_NANOSLEEP", value=>"1", default=>["IV", "0"]},
431             {name=>"d_setitimer", type=>"IV", macro=>"HAS_SETITIMER", value=>"1", default=>["IV", "0"]},
432             {name=>"d_ualarm", type=>"IV", macro=>"HAS_UALARM", value=>"1", default=>["IV", "0"]},
433             {name=>"d_usleep", type=>"IV", macro=>"HAS_USLEEP", value=>"1", default=>["IV", "0"]},
434             {name=>"d_utimensat", type=>"IV", macro=>"HAS_UTIMENSAT", value=>"1", default=>["IV", "0"]});
435              
436             print constant_types(), "\n"; # macro defs
437             foreach (C_constant ("Time::HiRes", 'constant', 'IV', $types, undef, 3, @names) ) {
438             print $_, "\n"; # C constant subs
439             }
440             print "\n#### XS Section:\n";
441             print XS_constant ("Time::HiRes", $types);
442             __END__