Upgrade to Time-HiRes-1.82
[p5sagit/p5-mst-13.2.git] / ext / Time / HiRes / fallback / const-c.inc
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 static int
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.  */
28   switch (name[7]) {
29   case 'P':
30     if (memEQ(name, "ITIMER_PROF", 11)) {
31     /*                      ^          */
32 #ifdef ITIMER_PROF
33       *iv_return = ITIMER_PROF;
34       return PERL_constant_ISIV;
35 #else
36       return PERL_constant_NOTDEF;
37 #endif
38     }
39     break;
40   case 'R':
41     if (memEQ(name, "ITIMER_REAL", 11)) {
42     /*                      ^          */
43 #ifdef ITIMER_REAL
44       *iv_return = ITIMER_REAL;
45       return PERL_constant_ISIV;
46 #else
47       return PERL_constant_NOTDEF;
48 #endif
49     }
50     break;
51   case 'i':
52     if (memEQ(name, "d_getitimer", 11)) {
53     /*                      ^          */
54 #ifdef HAS_GETITIMER
55       *iv_return = 1;
56       return PERL_constant_ISIV;
57 #else
58       *iv_return = 0;
59       return PERL_constant_ISIV;
60 #endif
61     }
62     if (memEQ(name, "d_setitimer", 11)) {
63     /*                      ^          */
64 #ifdef HAS_SETITIMER
65       *iv_return = 1;
66       return PERL_constant_ISIV;
67 #else
68       *iv_return = 0;
69       return PERL_constant_ISIV;
70 #endif
71     }
72     break;
73   case 'l':
74     if (memEQ(name, "d_nanosleep", 11)) {
75     /*                      ^          */
76 #ifdef TIME_HIRES_NANOSLEEP
77       *iv_return = 1;
78       return PERL_constant_ISIV;
79 #else
80       *iv_return = 0;
81       return PERL_constant_ISIV;
82 #endif
83     }
84     break;
85   }
86   return PERL_constant_NOTFOUND;
87 }
88
89 static int
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.  */
95   switch (name[6]) {
96   case 'R':
97     if (memEQ(name, "CLOCK_REALTIME", 14)) {
98     /*                     ^              */
99 #ifdef CLOCK_REALTIME
100       *iv_return = CLOCK_REALTIME;
101       return PERL_constant_ISIV;
102 #else
103       return PERL_constant_NOTDEF;
104 #endif
105     }
106     break;
107   case '_':
108     if (memEQ(name, "ITIMER_VIRTUAL", 14)) {
109     /*                     ^              */
110 #ifdef ITIMER_VIRTUAL
111       *iv_return = ITIMER_VIRTUAL;
112       return PERL_constant_ISIV;
113 #else
114       return PERL_constant_NOTDEF;
115 #endif
116     }
117     break;
118   case 'i':
119     if (memEQ(name, "d_gettimeofday", 14)) {
120     /*                     ^              */
121 #ifdef HAS_GETTIMEOFDAY
122       *iv_return = 1;
123       return PERL_constant_ISIV;
124 #else
125       *iv_return = 0;
126       return PERL_constant_ISIV;
127 #endif
128     }
129     break;
130   case 'k':
131     if (memEQ(name, "d_clock_getres", 14)) {
132     /*                     ^              */
133 #ifdef TIME_HIRES_CLOCK_GETRES
134       *iv_return = 1;
135       return PERL_constant_ISIV;
136 #else
137       *iv_return = 0;
138       return PERL_constant_ISIV;
139 #endif
140     }
141     break;
142   }
143   return PERL_constant_NOTFOUND;
144 }
145
146 static int
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.  */
152   switch (name[7]) {
153   case 'I':
154     if (memEQ(name, "CLOCK_TIMEOFDAY", 15)) {
155     /*                      ^              */
156 #ifdef CLOCK_TIMEOFDAY
157       *iv_return = CLOCK_TIMEOFDAY;
158       return PERL_constant_ISIV;
159 #else
160       return PERL_constant_NOTDEF;
161 #endif
162     }
163     break;
164   case 'O':
165     if (memEQ(name, "CLOCK_MONOTONIC", 15)) {
166     /*                      ^              */
167 #ifdef CLOCK_MONOTONIC
168       *iv_return = CLOCK_MONOTONIC;
169       return PERL_constant_ISIV;
170 #else
171       return PERL_constant_NOTDEF;
172 #endif
173     }
174     break;
175   case 'R':
176     if (memEQ(name, "ITIMER_REALPROF", 15)) {
177     /*                      ^              */
178 #ifdef ITIMER_REALPROF
179       *iv_return = ITIMER_REALPROF;
180       return PERL_constant_ISIV;
181 #else
182       return PERL_constant_NOTDEF;
183 #endif
184     }
185     break;
186   case '_':
187     if (memEQ(name, "d_clock_gettime", 15)) {
188     /*                      ^              */
189 #ifdef TIME_HIRES_CLOCK_GETTIME
190       *iv_return = 1;
191       return PERL_constant_ISIV;
192 #else
193       *iv_return = 0;
194       return PERL_constant_ISIV;
195 #endif
196     }
197     break;
198   }
199   return PERL_constant_NOTFOUND;
200 }
201
202 static int
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.
211
212      Regenerate these constant functions by feeding this entire source file to
213      perl -x
214
215 #!perl -w
216 use ExtUtils::Constant qw (constant_types C_constant XS_constant);
217
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"]});
230
231 print constant_types(); # macro defs
232 foreach (C_constant ("Time::HiRes", 'constant', 'IV', $types, undef, 3, @names) ) {
233     print $_, "\n"; # C constant subs
234 }
235 print "#### XS Section:\n";
236 print XS_constant ("Time::HiRes", $types);
237 __END__
238    */
239
240   switch (len) {
241   case 8:
242     /* Names all of length 8.  */
243     /* d_ualarm d_usleep */
244     /* Offset 7 gives the best switch position.  */
245     switch (name[7]) {
246     case 'm':
247       if (memEQ(name, "d_ualar", 7)) {
248       /*                      m     */
249 #ifdef HAS_UALARM
250         *iv_return = 1;
251         return PERL_constant_ISIV;
252 #else
253         *iv_return = 0;
254         return PERL_constant_ISIV;
255 #endif
256       }
257       break;
258     case 'p':
259       if (memEQ(name, "d_uslee", 7)) {
260       /*                      p     */
261 #ifdef HAS_USLEEP
262         *iv_return = 1;
263         return PERL_constant_ISIV;
264 #else
265         *iv_return = 0;
266         return PERL_constant_ISIV;
267 #endif
268       }
269       break;
270     }
271     break;
272   case 11:
273     return constant_11 (aTHX_ name, iv_return);
274     break;
275   case 13:
276     if (memEQ(name, "CLOCK_HIGHRES", 13)) {
277 #ifdef CLOCK_HIGHRES
278       *iv_return = CLOCK_HIGHRES;
279       return PERL_constant_ISIV;
280 #else
281       return PERL_constant_NOTDEF;
282 #endif
283     }
284     break;
285   case 14:
286     return constant_14 (aTHX_ name, iv_return);
287     break;
288   case 15:
289     return constant_15 (aTHX_ name, iv_return);
290     break;
291   case 23:
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;
296 #else
297       return PERL_constant_NOTDEF;
298 #endif
299     }
300     break;
301   case 24:
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;
306 #else
307       return PERL_constant_NOTDEF;
308 #endif
309     }
310     break;
311   }
312   return PERL_constant_NOTFOUND;
313 }
314