File Coverage

cpan/Time-HiRes/const-c.inc
Criterion Covered Total %
statement 45 80 56.2
branch n/a
condition n/a
subroutine n/a
total 45 80 56.2


line stmt bran cond sub 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 */
28           /* Offset 7 gives the best switch position. */
29 2         switch (name[7]) {
30           case 'P':
31 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           break;
41           case 'R':
42 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           break;
52           case 'i':
53 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         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           break;
74           case 'l':
75 2         if (memEQ(name, "d_nanosleep", 11)) {
76           /* ^ */
77           #ifdef TIME_HIRES_NANOSLEEP
78 2         *iv_return = 1;
79 2         return PERL_constant_ISIV;
80           #else
81           *iv_return = 0;
82           return PERL_constant_ISIV;
83           #endif
84           }
85           break;
86           }
87           return PERL_constant_NOTFOUND;
88           }
89            
90           static int
91 14         constant_14 (pTHX_ const char *name, IV *iv_return) {
92           /* When generated this function returned values for the list of names given
93           here. However, subsequent manual editing may have added or removed some.
94           CLOCKS_PER_SEC CLOCK_REALTIME CLOCK_SOFTTIME ITIMER_VIRTUAL d_clock_getres
95           d_gettimeofday */
96           /* Offset 8 gives the best switch position. */
97 14         switch (name[8]) {
98           case 'A':
99 2         if (memEQ(name, "CLOCK_REALTIME", 14)) {
100           /* ^ */
101           #ifdef CLOCK_REALTIME
102 2         *iv_return = CLOCK_REALTIME;
103 2         return PERL_constant_ISIV;
104           #else
105           return PERL_constant_NOTDEF;
106           #endif
107           }
108           break;
109           case 'E':
110 0         if (memEQ(name, "CLOCKS_PER_SEC", 14)) {
111           /* ^ */
112           #ifdef CLOCKS_PER_SEC
113 0         *iv_return = CLOCKS_PER_SEC;
114 0         return PERL_constant_ISIV;
115           #else
116           return PERL_constant_NOTDEF;
117           #endif
118           }
119           break;
120           case 'F':
121 0         if (memEQ(name, "CLOCK_SOFTTIME", 14)) {
122           /* ^ */
123           #ifdef CLOCK_SOFTTIME
124           *iv_return = CLOCK_SOFTTIME;
125           return PERL_constant_ISIV;
126           #else
127           return PERL_constant_NOTDEF;
128           #endif
129           }
130           break;
131           case 'I':
132 2         if (memEQ(name, "ITIMER_VIRTUAL", 14)) {
133           /* ^ */
134           #ifdef ITIMER_VIRTUAL
135 2         *iv_return = ITIMER_VIRTUAL;
136 2         return PERL_constant_ISIV;
137           #else
138           return PERL_constant_NOTDEF;
139           #endif
140           }
141           break;
142           case 'e':
143 8         if (memEQ(name, "d_gettimeofday", 14)) {
144           /* ^ */
145           #ifdef HAS_GETTIMEOFDAY
146 8         *iv_return = 1;
147 8         return PERL_constant_ISIV;
148           #else
149           *iv_return = 0;
150           return PERL_constant_ISIV;
151           #endif
152           }
153           break;
154           case 'g':
155 2         if (memEQ(name, "d_clock_getres", 14)) {
156           /* ^ */
157           #ifdef TIME_HIRES_CLOCK_GETRES
158 2         *iv_return = 1;
159 2         return PERL_constant_ISIV;
160           #else
161           *iv_return = 0;
162           return PERL_constant_ISIV;
163           #endif
164           }
165           break;
166           }
167 0         return PERL_constant_NOTFOUND;
168           }
169            
170           static int
171 2         constant_15 (pTHX_ const char *name, IV *iv_return) {
172           /* When generated this function returned values for the list of names given
173           here. However, subsequent manual editing may have added or removed some.
174           CLOCK_MONOTONIC CLOCK_TIMEOFDAY ITIMER_REALPROF d_clock_gettime */
175           /* Offset 7 gives the best switch position. */
176 2         switch (name[7]) {
177           case 'I':
178 0         if (memEQ(name, "CLOCK_TIMEOFDAY", 15)) {
179           /* ^ */
180           #ifdef CLOCK_TIMEOFDAY
181           *iv_return = CLOCK_TIMEOFDAY;
182           return PERL_constant_ISIV;
183           #else
184           return PERL_constant_NOTDEF;
185           #endif
186           }
187           break;
188           case 'O':
189 0         if (memEQ(name, "CLOCK_MONOTONIC", 15)) {
190           /* ^ */
191           #ifdef CLOCK_MONOTONIC
192 0         *iv_return = CLOCK_MONOTONIC;
193 0         return PERL_constant_ISIV;
194           #else
195           return PERL_constant_NOTDEF;
196           #endif
197           }
198           break;
199           case 'R':
200 0         if (memEQ(name, "ITIMER_REALPROF", 15)) {
201           /* ^ */
202           #ifdef ITIMER_REALPROF
203           *iv_return = ITIMER_REALPROF;
204           return PERL_constant_ISIV;
205           #else
206           return PERL_constant_NOTDEF;
207           #endif
208           }
209           break;
210           case '_':
211 2         if (memEQ(name, "d_clock_gettime", 15)) {
212           /* ^ */
213           #ifdef TIME_HIRES_CLOCK_GETTIME
214 2         *iv_return = 1;
215 2         return PERL_constant_ISIV;
216           #else
217           *iv_return = 0;
218           return PERL_constant_ISIV;
219           #endif
220           }
221           break;
222           }
223 0         return PERL_constant_NOTFOUND;
224           }
225            
226           static int
227 30         constant (pTHX_ const char *name, STRLEN len, IV *iv_return) {
228           /* Initially switch on the length of the name. */
229           /* When generated this function returned values for the list of names given
230           in this section of perl code. Rather than manually editing these functions
231           to add or remove constants, which would result in this comment and section
232           of code becoming inaccurate, we recommend that you edit this section of
233           code, and use it to regenerate a new set of constant functions which you
234           then use to replace the originals.
235            
236           Regenerate these constant functions by feeding this entire source file to
237           perl -x
238            
239           #!/home/pjcj/g/Test-Smoke/perl-current-gcov/miniperl -w
240           use ExtUtils::Constant qw (constant_types C_constant XS_constant);
241            
242           my $types = {map {($_, 1)} qw(IV)};
243           my @names = (qw(CLOCKS_PER_SEC CLOCK_HIGHRES CLOCK_MONOTONIC
244           CLOCK_PROCESS_CPUTIME_ID CLOCK_REALTIME CLOCK_SOFTTIME
245           CLOCK_THREAD_CPUTIME_ID CLOCK_TIMEOFDAY ITIMER_PROF ITIMER_REAL
246           ITIMER_REALPROF ITIMER_VIRTUAL TIMER_ABSTIME),
247           {name=>"d_clock", type=>"IV", macro=>"TIME_HIRES_CLOCK", value=>"1", default=>["IV", "0"]},
248           {name=>"d_clock_getres", type=>"IV", macro=>"TIME_HIRES_CLOCK_GETRES", value=>"1", default=>["IV", "0"]},
249           {name=>"d_clock_gettime", type=>"IV", macro=>"TIME_HIRES_CLOCK_GETTIME", value=>"1", default=>["IV", "0"]},
250           {name=>"d_clock_nanosleep", type=>"IV", macro=>"TIME_HIRES_CLOCK_NANOSLEEP", value=>"1", default=>["IV", "0"]},
251           {name=>"d_getitimer", type=>"IV", macro=>"HAS_GETITIMER", value=>"1", default=>["IV", "0"]},
252           {name=>"d_gettimeofday", type=>"IV", macro=>"HAS_GETTIMEOFDAY", value=>"1", default=>["IV", "0"]},
253           {name=>"d_hires_stat", type=>"IV", macro=>"TIME_HIRES_STAT", value=>"4", default=>["IV", "0"]},
254           {name=>"d_nanosleep", type=>"IV", macro=>"TIME_HIRES_NANOSLEEP", value=>"1", default=>["IV", "0"]},
255           {name=>"d_setitimer", type=>"IV", macro=>"HAS_SETITIMER", value=>"1", default=>["IV", "0"]},
256           {name=>"d_ualarm", type=>"IV", macro=>"HAS_UALARM", value=>"1", default=>["IV", "0"]},
257           {name=>"d_usleep", type=>"IV", macro=>"HAS_USLEEP", value=>"1", default=>["IV", "0"]});
258            
259           print constant_types(), "\n"; # macro defs
260           foreach (C_constant ("Time::HiRes", 'constant', 'IV', $types, undef, 3, @names) ) {
261           print $_, "\n"; # C constant subs
262           }
263           print "\n#### XS Section:\n";
264           print XS_constant ("Time::HiRes", $types);
265           __END__