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 CLOCK_REALTIME ITIMER_VIRTUAL d_clock_getres d_gettimeofday */
94 /* Offset 6 gives the best switch position. */
97 if (memEQ(name, "CLOCK_REALTIME", 14)) {
100 *iv_return = CLOCK_REALTIME;
101 return PERL_constant_ISIV;
103 return PERL_constant_NOTDEF;
108 if (memEQ(name, "ITIMER_VIRTUAL", 14)) {
110 #ifdef ITIMER_VIRTUAL
111 *iv_return = ITIMER_VIRTUAL;
112 return PERL_constant_ISIV;
114 return PERL_constant_NOTDEF;
119 if (memEQ(name, "d_gettimeofday", 14)) {
121 #ifdef HAS_GETTIMEOFDAY
123 return PERL_constant_ISIV;
126 return PERL_constant_ISIV;
131 if (memEQ(name, "d_clock_getres", 14)) {
133 #ifdef TIME_HIRES_CLOCK_GETRES
135 return PERL_constant_ISIV;
138 return PERL_constant_ISIV;
143 return PERL_constant_NOTFOUND;
147 constant_15 (pTHX_ const char *name, IV *iv_return) {
148 /* When generated this function returned values for the list of names given
149 here. However, subsequent manual editing may have added or removed some.
150 CLOCK_MONOTONIC CLOCK_TIMEOFDAY ITIMER_REALPROF d_clock_gettime */
151 /* Offset 7 gives the best switch position. */
154 if (memEQ(name, "CLOCK_TIMEOFDAY", 15)) {
156 #ifdef CLOCK_TIMEOFDAY
157 *iv_return = CLOCK_TIMEOFDAY;
158 return PERL_constant_ISIV;
160 return PERL_constant_NOTDEF;
165 if (memEQ(name, "CLOCK_MONOTONIC", 15)) {
167 #ifdef CLOCK_MONOTONIC
168 *iv_return = CLOCK_MONOTONIC;
169 return PERL_constant_ISIV;
171 return PERL_constant_NOTDEF;
176 if (memEQ(name, "ITIMER_REALPROF", 15)) {
178 #ifdef ITIMER_REALPROF
179 *iv_return = ITIMER_REALPROF;
180 return PERL_constant_ISIV;
182 return PERL_constant_NOTDEF;
187 if (memEQ(name, "d_clock_gettime", 15)) {
189 #ifdef TIME_HIRES_CLOCK_GETTIME
191 return PERL_constant_ISIV;
194 return PERL_constant_ISIV;
199 return PERL_constant_NOTFOUND;
203 constant (pTHX_ const char *name, STRLEN len, IV *iv_return) {
204 /* Initially switch on the length of the name. */
205 /* When generated this function returned values for the list of names given
206 in this section of perl code. Rather than manually editing these functions
207 to add or remove constants, which would result in this comment and section
208 of code becoming inaccurate, we recommend that you edit this section of
209 code, and use it to regenerate a new set of constant functions which you
210 then use to replace the originals.
212 Regenerate these constant functions by feeding this entire source file to
216 use ExtUtils::Constant qw (constant_types C_constant XS_constant);
218 my $types = {map {($_, 1)} qw(IV)};
219 my @names = (qw(CLOCK_HIGHRES CLOCK_MONOTONIC CLOCK_PROCESS_CPUTIME_ID
220 CLOCK_REALTIME CLOCK_THREAD_CPUTIME_ID CLOCK_TIMEOFDAY
221 ITIMER_PROF ITIMER_REAL ITIMER_REALPROF ITIMER_VIRTUAL),
222 {name=>"d_clock_getres", type=>"IV", macro=>"TIME_HIRES_CLOCK_GETRES", value=>"1", default=>["IV", "0"]},
223 {name=>"d_clock_gettime", type=>"IV", macro=>"TIME_HIRES_CLOCK_GETTIME", value=>"1", default=>["IV", "0"]},
224 {name=>"d_getitimer", type=>"IV", macro=>"HAS_GETITIMER", value=>"1", default=>["IV", "0"]},
225 {name=>"d_gettimeofday", type=>"IV", macro=>"HAS_GETTIMEOFDAY", value=>"1", default=>["IV", "0"]},
226 {name=>"d_nanosleep", type=>"IV", macro=>"TIME_HIRES_NANOSLEEP", value=>"1", default=>["IV", "0"]},
227 {name=>"d_setitimer", type=>"IV", macro=>"HAS_SETITIMER", value=>"1", default=>["IV", "0"]},
228 {name=>"d_ualarm", type=>"IV", macro=>"HAS_UALARM", value=>"1", default=>["IV", "0"]},
229 {name=>"d_usleep", type=>"IV", macro=>"HAS_USLEEP", value=>"1", default=>["IV", "0"]});
231 print constant_types(); # macro defs
232 foreach (C_constant ("Time::HiRes", 'constant', 'IV', $types, undef, 3, @names) ) {
233 print $_, "\n"; # C constant subs
235 print "#### XS Section:\n";
236 print XS_constant ("Time::HiRes", $types);
242 /* Names all of length 8. */
243 /* d_ualarm d_usleep */
244 /* Offset 7 gives the best switch position. */
247 if (memEQ(name, "d_ualar", 7)) {
251 return PERL_constant_ISIV;
254 return PERL_constant_ISIV;
259 if (memEQ(name, "d_uslee", 7)) {
263 return PERL_constant_ISIV;
266 return PERL_constant_ISIV;
273 return constant_11 (aTHX_ name, iv_return);
276 if (memEQ(name, "CLOCK_HIGHRES", 13)) {
278 *iv_return = CLOCK_HIGHRES;
279 return PERL_constant_ISIV;
281 return PERL_constant_NOTDEF;
286 return constant_14 (aTHX_ name, iv_return);
289 return constant_15 (aTHX_ name, iv_return);
292 if (memEQ(name, "CLOCK_THREAD_CPUTIME_ID", 23)) {
293 #ifdef CLOCK_THREAD_CPUTIME_ID
294 *iv_return = CLOCK_THREAD_CPUTIME_ID;
295 return PERL_constant_ISIV;
297 return PERL_constant_NOTDEF;
302 if (memEQ(name, "CLOCK_PROCESS_CPUTIME_ID", 24)) {
303 #ifdef CLOCK_PROCESS_CPUTIME_ID
304 *iv_return = CLOCK_PROCESS_CPUTIME_ID;
305 return PERL_constant_ISIV;
307 return PERL_constant_NOTDEF;
312 return PERL_constant_NOTFOUND;