Commit | Line | Data |
98b50af3 |
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 | 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 | switch (name[7]) { |
30 | case 'P': |
31 | if (memEQ(name, "ITIMER_PROF", 11)) { |
32 | /* ^ */ |
33 | #ifdef ITIMER_PROF |
34 | *iv_return = ITIMER_PROF; |
35 | return PERL_constant_ISIV; |
36 | #else |
37 | return PERL_constant_NOTDEF; |
38 | #endif |
39 | } |
40 | break; |
41 | case 'R': |
42 | if (memEQ(name, "ITIMER_REAL", 11)) { |
43 | /* ^ */ |
44 | #ifdef ITIMER_REAL |
45 | *iv_return = ITIMER_REAL; |
46 | return PERL_constant_ISIV; |
47 | #else |
48 | return PERL_constant_NOTDEF; |
49 | #endif |
50 | } |
51 | break; |
52 | case 'i': |
53 | if (memEQ(name, "d_getitimer", 11)) { |
54 | /* ^ */ |
55 | #ifdef HAS_GETITIMER |
56 | *iv_return = 1; |
57 | return PERL_constant_ISIV; |
58 | #else |
59 | *iv_return = 0; |
60 | return PERL_constant_ISIV; |
61 | #endif |
62 | } |
63 | if (memEQ(name, "d_setitimer", 11)) { |
64 | /* ^ */ |
65 | #ifdef HAS_SETITIMER |
66 | *iv_return = 1; |
67 | return PERL_constant_ISIV; |
68 | #else |
69 | *iv_return = 0; |
70 | return PERL_constant_ISIV; |
71 | #endif |
72 | } |
73 | break; |
74 | case 'l': |
75 | if (memEQ(name, "d_nanosleep", 11)) { |
76 | /* ^ */ |
77 | #ifdef HAS_NANOSLEEP |
78 | *iv_return = 1; |
79 | 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 | constant (pTHX_ const char *name, STRLEN len, IV *iv_return) { |
92 | /* Initially switch on the length of the name. */ |
93 | /* When generated this function returned values for the list of names given |
94 | in this section of perl code. Rather than manually editing these functions |
95 | to add or remove constants, which would result in this comment and section |
96 | of code becoming inaccurate, we recommend that you edit this section of |
97 | code, and use it to regenerate a new set of constant functions which you |
98 | then use to replace the originals. |
99 | |
100 | Regenerate these constant functions by feeding this entire source file to |
101 | perl -x |
102 | |
103 | #!/usr/local/bin/perl5.8.0 -w |
104 | use ExtUtils::Constant qw (constant_types C_constant XS_constant); |
105 | |
106 | my $types = {map {($_, 1)} qw(IV)}; |
107 | my @names = (qw(ITIMER_PROF ITIMER_REAL ITIMER_REALPROF ITIMER_VIRTUAL), |
108 | {name=>"d_getitimer", type=>"IV", macro=>"HAS_GETITIMER", value=>"1", default=>["IV", "0"]}, |
109 | {name=>"d_gettimeofday", type=>"IV", macro=>"HAS_GETTIMEOFDAY", value=>"1", default=>["IV", "0"]}, |
110 | {name=>"d_nanosleep", type=>"IV", macro=>"HAS_NANOSLEEP", value=>"1", default=>["IV", "0"]}, |
111 | {name=>"d_setitimer", type=>"IV", macro=>"HAS_SETITIMER", value=>"1", default=>["IV", "0"]}, |
112 | {name=>"d_ualarm", type=>"IV", macro=>"HAS_UALARM", value=>"1", default=>["IV", "0"]}, |
113 | {name=>"d_usleep", type=>"IV", macro=>"HAS_USLEEP", value=>"1", default=>["IV", "0"]}); |
114 | |
115 | print constant_types(); # macro defs |
116 | foreach (C_constant ("Time::HiRes", 'constant', 'IV', $types, undef, 3, @names) ) { |
117 | print $_, "\n"; # C constant subs |
118 | } |
119 | print "#### XS Section:\n"; |
120 | print XS_constant ("Time::HiRes", $types); |
121 | __END__ |
122 | */ |
123 | |
124 | switch (len) { |
125 | case 8: |
126 | /* Names all of length 8. */ |
127 | /* d_ualarm d_usleep */ |
128 | /* Offset 7 gives the best switch position. */ |
129 | switch (name[7]) { |
130 | case 'm': |
131 | if (memEQ(name, "d_ualarm", 8)) { |
132 | /* ^ */ |
133 | #ifdef HAS_UALARM |
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 | case 'p': |
143 | if (memEQ(name, "d_usleep", 8)) { |
144 | /* ^ */ |
145 | #ifdef HAS_USLEEP |
146 | *iv_return = 1; |
147 | return PERL_constant_ISIV; |
148 | #else |
149 | *iv_return = 0; |
150 | return PERL_constant_ISIV; |
151 | #endif |
152 | } |
153 | break; |
154 | } |
155 | break; |
156 | case 11: |
157 | return constant_11 (aTHX_ name, iv_return); |
158 | break; |
159 | case 14: |
160 | /* Names all of length 14. */ |
161 | /* ITIMER_VIRTUAL d_gettimeofday */ |
162 | /* Offset 6 gives the best switch position. */ |
163 | switch (name[6]) { |
164 | case '_': |
165 | if (memEQ(name, "ITIMER_VIRTUAL", 14)) { |
166 | /* ^ */ |
167 | #ifdef ITIMER_VIRTUAL |
168 | *iv_return = ITIMER_VIRTUAL; |
169 | return PERL_constant_ISIV; |
170 | #else |
171 | return PERL_constant_NOTDEF; |
172 | #endif |
173 | } |
174 | break; |
175 | case 'i': |
176 | if (memEQ(name, "d_gettimeofday", 14)) { |
177 | /* ^ */ |
178 | #ifdef HAS_GETTIMEOFDAY |
179 | *iv_return = 1; |
180 | return PERL_constant_ISIV; |
181 | #else |
182 | *iv_return = 0; |
183 | return PERL_constant_ISIV; |
184 | #endif |
185 | } |
186 | break; |
187 | } |
188 | break; |
189 | case 15: |
190 | if (memEQ(name, "ITIMER_REALPROF", 15)) { |
191 | #ifdef ITIMER_REALPROF |
192 | *iv_return = ITIMER_REALPROF; |
193 | return PERL_constant_ISIV; |
194 | #else |
195 | return PERL_constant_NOTDEF; |
196 | #endif |
197 | } |
198 | break; |
199 | } |
200 | return PERL_constant_NOTFOUND; |
201 | } |
202 | |