Mercurial > hg > aboriginal
annotate sources/patches/linux-noperl-timeconst.patch @ 1619:3413e8427702
The lfs m4 build wasn't including -lrt when probing for posix_spawn, thus trying to recreate what was already there and causing a conflicting definition. Change patch to insert it into libc proper.
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 23 Aug 2013 06:02:55 -0500 |
parents | 3cbf1abde44a |
children | 6ffd2181ac58 |
rev | line source |
---|---|
1598 | 1 Replace timeconst.bc with the c version I've been using for years (to replace |
2 the perl version). Eventually I should add bc to toybox, but for now... | |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
3 |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
4 diff --git a/kernel/Makefile b/kernel/Makefile |
1598 | 5 index eceac38..f00be6d 100644 |
6 --- /dev/null | |
7 +++ linux/kernel/mktimeconst.c | |
8 @@ -0,0 +1,110 @@ | |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
9 +/* Copyright 2010 Parallels Inc, licensed under GPLv2 */ |
1598 | 10 +/* Copyright 2010-2013 Rob Landley <rob@landley.net> */ |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
11 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
12 +#include <inttypes.h> |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
13 +#include <stdio.h> |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
14 +#include <stdlib.h> |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
15 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
16 +int main(int argc, char *argv[]) |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
17 +{ |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
18 + uint64_t hz, periods[] = {1000, 1000000}; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
19 + char *names[] = {"MSEC", "USEC"}; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
20 + FILE *file; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
21 + int i, j; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
22 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
23 + if (argc != 3 || (hz = atol(argv[1])) < 1 |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
24 + || !(file = fopen(argv[2], "w"))) |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
25 + { |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
26 + fprintf(stderr, "Usage: mktimeconst HZ FILENAME\n\n"); |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
27 + fprintf(stderr, "Generate a header file with constants to convert between\n"); |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
28 + fprintf(stderr, "decimal HZ timer ticks and milisecond or microsecond delays,\n"); |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
29 + fprintf(stderr, "using reciprocal multiplication to avoid 64 bit division.\n"); |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
30 + exit(1); |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
31 + } |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
32 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
33 + fprintf(file, |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
34 + "/* Automatically generated by kernel/mktimeconst */\n" |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
35 + "/* Conversion constants for HZ == %"PRIu64" */\n\n" |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
36 + "#ifndef __KERNEL_TIMECONST_H\n" |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
37 + "#define __KERNEL_TIMECONST_H\n\n" |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
38 + "#include <linux/param.h>\n" |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
39 + "#include <linux/types.h>\n\n" |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
40 + "#if HZ != %"PRIu64"\n" |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
41 + "#error \"kernel/timeconst.h has the wrong HZ value!\"\n" |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
42 + "#endif\n\n", hz, hz); |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
43 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
44 + /* Repeat for MSEC and USEC */ |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
45 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
46 + for (i = 0; i < 2; i++) { |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
47 + uint64_t gcd, period; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
48 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
49 + /* Find greatest common denominator using Euclid's algorithm. */ |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
50 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
51 + gcd = hz; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
52 + period = periods[i]; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
53 + while (period) { |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
54 + uint64_t temp = gcd % period; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
55 + gcd = period; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
56 + period = temp; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
57 + } |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
58 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
59 + /* Output both directions (HZ_TO_PERIOD and PERIOD_TO_HZ) */ |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
60 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
61 + for (j = 0; j < 2; j++) { |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
62 + char name[16]; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
63 + uint64_t from = j ? periods[i] : hz; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
64 + uint64_t to = j ? hz : periods[i]; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
65 + uint64_t mul32 = 0, adj32 = 0, shift = 0; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
66 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
67 + sprintf(name, j ? "%s_TO_HZ" : "HZ_TO_%s", names[i]); |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
68 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
69 + /* Figure out what shift value gives 32 significant |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
70 + bits of MUL32 data. (Worst case to=1 from=1000000 |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
71 + uses 52 bits, to<<shift won't overflow 64 bit math.) |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
72 + */ |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
73 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
74 + for (;;) { |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
75 + mul32 = ((to << shift) + from - 1) / from; |
1379
ddbd48ced0d7
Fix from Geoffroy Weisenhorn: on 32-bit hosts mktimeconst needs 1L<<31 to be an _unsigned_ long constant.
Rob Landley <rob@landley.net>
parents:
1337
diff
changeset
|
76 + if (mul32 >= (1UL<<31)) |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
77 + break; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
78 + shift++; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
79 + } |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
80 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
81 + /* ADJ32 is is just (((FROM/GCD)-1)<<SHIFT)/(FROM/GCD) |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
82 + but this can overflow 64 bit math (examples, HZ=24 |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
83 + or HZ=122). Worst case scenario uses 32+20+20=72 |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
84 + bits. Workaround: split off bottom 32 bits and |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
85 + reassemble after calculation (32+64=96 bits). */ |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
86 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
87 + adj32 = from / gcd; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
88 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
89 + if (shift > 32) { |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
90 + uint64_t upper, lower; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
91 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
92 + upper = (adj32 - 1) << (shift - 32); |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
93 + lower = (upper % adj32) << 32; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
94 + adj32 = ((upper/adj32) << 32) + (lower/adj32); |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
95 + } else |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
96 + adj32 = ((adj32 - 1) << shift) / adj32; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
97 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
98 + /* Emit the constants into the header file. */ |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
99 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
100 + fprintf(file, "#define %s_MUL32\tU64_C(0x%"PRIx64")\n", |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
101 + name, mul32); |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
102 + fprintf(file, "#define %s_ADJ32\tU64_C(0x%"PRIx64")\n", |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
103 + name, adj32); |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
104 + fprintf(file, "#define %s_SHR32\t%"PRIu64"\n", |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
105 + name, shift); |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
106 + fprintf(file, "#define %s_NUM\t\tU64_C(%"PRIu64")\n", |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
107 + name, to/gcd); |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
108 + fprintf(file, "#define %s_DEN\t\tU64_C(%"PRIu64")\n\n", |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
109 + name, from/gcd); |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
110 + } |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
111 + } |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
112 + fprintf(file, "#endif /* __KERNEL_TIMECONST_H */\n"); |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
113 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
114 + /* Notice if the disk fills up. */ |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
115 + |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
116 + fflush(stdout); |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
117 + return ferror(stdout); |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
118 +} |
1598 | 119 --- linux/kernel/timeconst.bc 2013-04-28 19:36:01.000000000 -0500 |
120 +++ /dev/null 2013-02-23 10:58:11.743993346 -0600 | |
121 @@ -1,108 +0,0 @@ | |
122 -scale=0 | |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
123 - |
1598 | 124 -define gcd(a,b) { |
125 - auto t; | |
126 - while (b) { | |
127 - t = b; | |
128 - b = a % b; | |
129 - a = t; | |
130 - } | |
131 - return a; | |
132 -} | |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
133 - |
1598 | 134 -/* Division by reciprocal multiplication. */ |
135 -define fmul(b,n,d) { | |
136 - return (2^b*n+d-1)/d; | |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
137 -} |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
138 - |
1598 | 139 -/* Adjustment factor when a ceiling value is used. Use as: |
140 - (imul * n) + (fmulxx * n + fadjxx) >> xx) */ | |
141 -define fadj(b,n,d) { | |
142 - auto v; | |
143 - d = d/gcd(n,d); | |
144 - v = 2^b*(d-1)/d; | |
145 - return v; | |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
146 -} |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
147 - |
1598 | 148 -/* Compute the appropriate mul/adj values as well as a shift count, |
149 - which brings the mul value into the range 2^b-1 <= x < 2^b. Such | |
150 - a shift value will be correct in the signed integer range and off | |
151 - by at most one in the upper half of the unsigned range. */ | |
152 -define fmuls(b,n,d) { | |
153 - auto s, m; | |
154 - for (s = 0; 1; s++) { | |
155 - m = fmul(s,n,d); | |
156 - if (m >= 2^(b-1)) | |
157 - return s; | |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
158 - } |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
159 - return 0; |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
160 -} |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
161 - |
1598 | 162 -define timeconst(hz) { |
163 - print "/* Automatically generated by kernel/timeconst.bc */\n" | |
164 - print "/* Time conversion constants for HZ == ", hz, " */\n" | |
165 - print "\n" | |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
166 - |
1598 | 167 - print "#ifndef KERNEL_TIMECONST_H\n" |
168 - print "#define KERNEL_TIMECONST_H\n\n" | |
169 - | |
170 - print "#include <linux/param.h>\n" | |
171 - print "#include <linux/types.h>\n\n" | |
172 - | |
173 - print "#if HZ != ", hz, "\n" | |
174 - print "#error \qkernel/timeconst.h has the wrong HZ value!\q\n" | |
175 - print "#endif\n\n" | |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
176 - |
1598 | 177 - if (hz < 2) { |
178 - print "#error Totally bogus HZ value!\n" | |
179 - } else { | |
180 - s=fmuls(32,1000,hz) | |
181 - obase=16 | |
182 - print "#define HZ_TO_MSEC_MUL32\tU64_C(0x", fmul(s,1000,hz), ")\n" | |
183 - print "#define HZ_TO_MSEC_ADJ32\tU64_C(0x", fadj(s,1000,hz), ")\n" | |
184 - obase=10 | |
185 - print "#define HZ_TO_MSEC_SHR32\t", s, "\n" | |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
186 - |
1598 | 187 - s=fmuls(32,hz,1000) |
188 - obase=16 | |
189 - print "#define MSEC_TO_HZ_MUL32\tU64_C(0x", fmul(s,hz,1000), ")\n" | |
190 - print "#define MSEC_TO_HZ_ADJ32\tU64_C(0x", fadj(s,hz,1000), ")\n" | |
191 - obase=10 | |
192 - print "#define MSEC_TO_HZ_SHR32\t", s, "\n" | |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
193 - |
1598 | 194 - obase=10 |
195 - cd=gcd(hz,1000) | |
196 - print "#define HZ_TO_MSEC_NUM\t\t", 1000/cd, "\n" | |
197 - print "#define HZ_TO_MSEC_DEN\t\t", hz/cd, "\n" | |
198 - print "#define MSEC_TO_HZ_NUM\t\t", hz/cd, "\n" | |
199 - print "#define MSEC_TO_HZ_DEN\t\t", 1000/cd, "\n" | |
200 - print "\n" | |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
201 - |
1598 | 202 - s=fmuls(32,1000000,hz) |
203 - obase=16 | |
204 - print "#define HZ_TO_USEC_MUL32\tU64_C(0x", fmul(s,1000000,hz), ")\n" | |
205 - print "#define HZ_TO_USEC_ADJ32\tU64_C(0x", fadj(s,1000000,hz), ")\n" | |
206 - obase=10 | |
207 - print "#define HZ_TO_USEC_SHR32\t", s, "\n" | |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
208 - |
1598 | 209 - s=fmuls(32,hz,1000000) |
210 - obase=16 | |
211 - print "#define USEC_TO_HZ_MUL32\tU64_C(0x", fmul(s,hz,1000000), ")\n" | |
212 - print "#define USEC_TO_HZ_ADJ32\tU64_C(0x", fadj(s,hz,1000000), ")\n" | |
213 - obase=10 | |
214 - print "#define USEC_TO_HZ_SHR32\t", s, "\n" | |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
215 - |
1598 | 216 - obase=10 |
217 - cd=gcd(hz,1000000) | |
218 - print "#define HZ_TO_USEC_NUM\t\t", 1000000/cd, "\n" | |
219 - print "#define HZ_TO_USEC_DEN\t\t", hz/cd, "\n" | |
220 - print "#define USEC_TO_HZ_NUM\t\t", hz/cd, "\n" | |
221 - print "#define USEC_TO_HZ_DEN\t\t", 1000000/cd, "\n" | |
222 - print "\n" | |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
223 - |
1598 | 224 - print "#endif /* KERNEL_TIMECONST_H */\n" |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
225 - } |
1598 | 226 - halt |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
227 -} |
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
228 - |
1598 | 229 -timeconst(hz) |
230 --- linux/kernel/Makefile | |
231 +++ linux/kernel/Makefile | |
232 @@ -125,19 +125,13 @@ | |
233 | |
234 $(obj)/time.o: $(obj)/timeconst.h | |
235 | |
236 -quiet_cmd_hzfile = HZFILE $@ | |
237 - cmd_hzfile = echo "hz=$(CONFIG_HZ)" > $@ | |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
238 - |
1598 | 239 -targets += hz.bc |
240 -$(obj)/hz.bc: $(objtree)/include/config/hz.h FORCE | |
241 - $(call if_changed,hzfile) | |
1337
1bc0c01950ca
Switch to the noperl patches for 2.6.38.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
242 - |
1598 | 243 -quiet_cmd_bc = BC $@ |
244 - cmd_bc = bc -q $(filter-out FORCE,$^) > $@ | |
245 +hostprogs-y += mktimeconst | |
246 +quiet_cmd_mktimeconst = TIMEC $@ | |
247 + cmd_mktimeconst = $(obj)/mktimeconst $(CONFIG_HZ) $@ || ( rm -f $@ && exit 1 ) | |
248 | |
249 targets += timeconst.h | |
250 -$(obj)/timeconst.h: $(obj)/hz.bc $(src)/timeconst.bc FORCE | |
251 - $(call if_changed,bc) | |
252 +$(obj)/timeconst.h: $(obj)/mktimeconst FORCE | |
253 + $(call if_changed,mktimeconst) | |
254 | |
255 ifeq ($(CONFIG_MODULE_SIG),y) | |
256 # |