Only strip kernel modules if there is something to strip
[qi-bootmenu-system.git] / sources / patches / linux-2.6.25-rc1-noperl.patch
blobb350685346ff0bcba2a541200c90ef2b3aa03a88
1 diff -ruN linux-2.6.30/kernel/Makefile linux-2.6.30.new/kernel/Makefile
2 --- linux-2.6.30/kernel/Makefile 2009-06-09 22:05:27.000000000 -0500
3 +++ linux-2.6.30.new/kernel/Makefile 2009-06-22 14:29:16.000000000 -0500
4 @@ -122,7 +122,7 @@
5 $(obj)/time.o: $(obj)/timeconst.h
7 quiet_cmd_timeconst = TIMEC $@
8 - cmd_timeconst = $(PERL) $< $(CONFIG_HZ) > $@
9 + cmd_timeconst = $(CONFIG_SHELL) $< $(CONFIG_HZ) $@
10 targets += timeconst.h
11 -$(obj)/timeconst.h: $(src)/timeconst.pl FORCE
12 +$(obj)/timeconst.h: $(src)/timeconst.sh FORCE
13 $(call if_changed,timeconst)
14 diff -ruN linux-2.6.30/kernel/timeconst.pl linux-2.6.30.new/kernel/timeconst.pl
15 --- linux-2.6.30/kernel/timeconst.pl 2009-06-09 22:05:27.000000000 -0500
16 +++ linux-2.6.30.new/kernel/timeconst.pl 1969-12-31 18:00:00.000000000 -0600
17 @@ -1,378 +0,0 @@
18 -#!/usr/bin/perl
19 -# -----------------------------------------------------------------------
21 -# Copyright 2007-2008 rPath, Inc. - All Rights Reserved
23 -# This file is part of the Linux kernel, and is made available under
24 -# the terms of the GNU General Public License version 2 or (at your
25 -# option) any later version; incorporated herein by reference.
27 -# -----------------------------------------------------------------------
31 -# Usage: timeconst.pl HZ > timeconst.h
34 -# Precomputed values for systems without Math::BigInt
35 -# Generated by:
36 -# timeconst.pl --can 24 32 48 64 100 122 128 200 250 256 300 512 1000 1024 1200
37 -%canned_values = (
38 - 24 => [
39 - '0xa6aaaaab','0x2aaaaaa',26,
40 - 125,3,
41 - '0xc49ba5e4','0x1fbe76c8b4',37,
42 - 3,125,
43 - '0xa2c2aaab','0xaaaa',16,
44 - 125000,3,
45 - '0xc9539b89','0x7fffbce4217d',47,
46 - 3,125000,
47 - ], 32 => [
48 - '0xfa000000','0x6000000',27,
49 - 125,4,
50 - '0x83126e98','0xfdf3b645a',36,
51 - 4,125,
52 - '0xf4240000','0x0',17,
53 - 31250,1,
54 - '0x8637bd06','0x3fff79c842fa',46,
55 - 1,31250,
56 - ], 48 => [
57 - '0xa6aaaaab','0x6aaaaaa',27,
58 - 125,6,
59 - '0xc49ba5e4','0xfdf3b645a',36,
60 - 6,125,
61 - '0xa2c2aaab','0x15555',17,
62 - 62500,3,
63 - '0xc9539b89','0x3fffbce4217d',46,
64 - 3,62500,
65 - ], 64 => [
66 - '0xfa000000','0xe000000',28,
67 - 125,8,
68 - '0x83126e98','0x7ef9db22d',35,
69 - 8,125,
70 - '0xf4240000','0x0',18,
71 - 15625,1,
72 - '0x8637bd06','0x1fff79c842fa',45,
73 - 1,15625,
74 - ], 100 => [
75 - '0xa0000000','0x0',28,
76 - 10,1,
77 - '0xcccccccd','0x733333333',35,
78 - 1,10,
79 - '0x9c400000','0x0',18,
80 - 10000,1,
81 - '0xd1b71759','0x1fff2e48e8a7',45,
82 - 1,10000,
83 - ], 122 => [
84 - '0x8325c53f','0xfbcda3a',28,
85 - 500,61,
86 - '0xf9db22d1','0x7fbe76c8b',35,
87 - 61,500,
88 - '0x8012e2a0','0x3ef36',18,
89 - 500000,61,
90 - '0xffda4053','0x1ffffbce4217',45,
91 - 61,500000,
92 - ], 128 => [
93 - '0xfa000000','0x1e000000',29,
94 - 125,16,
95 - '0x83126e98','0x3f7ced916',34,
96 - 16,125,
97 - '0xf4240000','0x40000',19,
98 - 15625,2,
99 - '0x8637bd06','0xfffbce4217d',44,
100 - 2,15625,
101 - ], 200 => [
102 - '0xa0000000','0x0',29,
103 - 5,1,
104 - '0xcccccccd','0x333333333',34,
105 - 1,5,
106 - '0x9c400000','0x0',19,
107 - 5000,1,
108 - '0xd1b71759','0xfff2e48e8a7',44,
109 - 1,5000,
110 - ], 250 => [
111 - '0x80000000','0x0',29,
112 - 4,1,
113 - '0x80000000','0x180000000',33,
114 - 1,4,
115 - '0xfa000000','0x0',20,
116 - 4000,1,
117 - '0x83126e98','0x7ff7ced9168',43,
118 - 1,4000,
119 - ], 256 => [
120 - '0xfa000000','0x3e000000',30,
121 - 125,32,
122 - '0x83126e98','0x1fbe76c8b',33,
123 - 32,125,
124 - '0xf4240000','0xc0000',20,
125 - 15625,4,
126 - '0x8637bd06','0x7ffde7210be',43,
127 - 4,15625,
128 - ], 300 => [
129 - '0xd5555556','0x2aaaaaaa',30,
130 - 10,3,
131 - '0x9999999a','0x1cccccccc',33,
132 - 3,10,
133 - '0xd0555556','0xaaaaa',20,
134 - 10000,3,
135 - '0x9d495183','0x7ffcb923a29',43,
136 - 3,10000,
137 - ], 512 => [
138 - '0xfa000000','0x7e000000',31,
139 - 125,64,
140 - '0x83126e98','0xfdf3b645',32,
141 - 64,125,
142 - '0xf4240000','0x1c0000',21,
143 - 15625,8,
144 - '0x8637bd06','0x3ffef39085f',42,
145 - 8,15625,
146 - ], 1000 => [
147 - '0x80000000','0x0',31,
148 - 1,1,
149 - '0x80000000','0x0',31,
150 - 1,1,
151 - '0xfa000000','0x0',22,
152 - 1000,1,
153 - '0x83126e98','0x1ff7ced9168',41,
154 - 1,1000,
155 - ], 1024 => [
156 - '0xfa000000','0xfe000000',32,
157 - 125,128,
158 - '0x83126e98','0x7ef9db22',31,
159 - 128,125,
160 - '0xf4240000','0x3c0000',22,
161 - 15625,16,
162 - '0x8637bd06','0x1fff79c842f',41,
163 - 16,15625,
164 - ], 1200 => [
165 - '0xd5555556','0xd5555555',32,
166 - 5,6,
167 - '0x9999999a','0x66666666',31,
168 - 6,5,
169 - '0xd0555556','0x2aaaaa',22,
170 - 2500,3,
171 - '0x9d495183','0x1ffcb923a29',41,
172 - 3,2500,
176 -$has_bigint = eval 'use Math::BigInt qw(bgcd); 1;';
178 -sub bint($)
180 - my($x) = @_;
181 - return Math::BigInt->new($x);
185 -# Constants for division by reciprocal multiplication.
186 -# (bits, numerator, denominator)
188 -sub fmul($$$)
190 - my ($b,$n,$d) = @_;
192 - $n = bint($n);
193 - $d = bint($d);
195 - return scalar (($n << $b)+$d-bint(1))/$d;
198 -sub fadj($$$)
200 - my($b,$n,$d) = @_;
202 - $n = bint($n);
203 - $d = bint($d);
205 - $d = $d/bgcd($n, $d);
206 - return scalar (($d-bint(1)) << $b)/$d;
209 -sub fmuls($$$) {
210 - my($b,$n,$d) = @_;
211 - my($s,$m);
212 - my($thres) = bint(1) << ($b-1);
214 - $n = bint($n);
215 - $d = bint($d);
217 - for ($s = 0; 1; $s++) {
218 - $m = fmul($s,$n,$d);
219 - return $s if ($m >= $thres);
221 - return 0;
224 -# Generate a hex value if the result fits in 64 bits;
225 -# otherwise skip.
226 -sub bignum_hex($) {
227 - my($x) = @_;
228 - my $s = $x->as_hex();
230 - return (length($s) > 18) ? undef : $s;
233 -# Provides mul, adj, and shr factors for a specific
234 -# (bit, time, hz) combination
235 -sub muladj($$$) {
236 - my($b, $t, $hz) = @_;
237 - my $s = fmuls($b, $t, $hz);
238 - my $m = fmul($s, $t, $hz);
239 - my $a = fadj($s, $t, $hz);
240 - return (bignum_hex($m), bignum_hex($a), $s);
243 -# Provides numerator, denominator values
244 -sub numden($$) {
245 - my($n, $d) = @_;
246 - my $g = bgcd($n, $d);
247 - return ($n/$g, $d/$g);
250 -# All values for a specific (time, hz) combo
251 -sub conversions($$) {
252 - my ($t, $hz) = @_;
253 - my @val = ();
255 - # HZ_TO_xx
256 - push(@val, muladj(32, $t, $hz));
257 - push(@val, numden($t, $hz));
259 - # xx_TO_HZ
260 - push(@val, muladj(32, $hz, $t));
261 - push(@val, numden($hz, $t));
263 - return @val;
266 -sub compute_values($) {
267 - my($hz) = @_;
268 - my @val = ();
269 - my $s, $m, $a, $g;
271 - if (!$has_bigint) {
272 - die "$0: HZ == $hz not canned and ".
273 - "Math::BigInt not available\n";
276 - # MSEC conversions
277 - push(@val, conversions(1000, $hz));
279 - # USEC conversions
280 - push(@val, conversions(1000000, $hz));
282 - return @val;
285 -sub outputval($$)
287 - my($name, $val) = @_;
288 - my $csuf;
290 - if (defined($val)) {
291 - if ($name !~ /SHR/) {
292 - $val = "U64_C($val)";
294 - printf "#define %-23s %s\n", $name.$csuf, $val.$csuf;
298 -sub output($@)
300 - my($hz, @val) = @_;
301 - my $pfx, $bit, $suf, $s, $m, $a;
303 - print "/* Automatically generated by kernel/timeconst.pl */\n";
304 - print "/* Conversion constants for HZ == $hz */\n";
305 - print "\n";
306 - print "#ifndef KERNEL_TIMECONST_H\n";
307 - print "#define KERNEL_TIMECONST_H\n";
308 - print "\n";
310 - print "#include <linux/param.h>\n";
311 - print "#include <linux/types.h>\n";
313 - print "\n";
314 - print "#if HZ != $hz\n";
315 - print "#error \"kernel/timeconst.h has the wrong HZ value!\"\n";
316 - print "#endif\n";
317 - print "\n";
319 - foreach $pfx ('HZ_TO_MSEC','MSEC_TO_HZ',
320 - 'HZ_TO_USEC','USEC_TO_HZ') {
321 - foreach $bit (32) {
322 - foreach $suf ('MUL', 'ADJ', 'SHR') {
323 - outputval("${pfx}_$suf$bit", shift(@val));
326 - foreach $suf ('NUM', 'DEN') {
327 - outputval("${pfx}_$suf", shift(@val));
331 - print "\n";
332 - print "#endif /* KERNEL_TIMECONST_H */\n";
335 -# Pretty-print Perl values
336 -sub perlvals(@) {
337 - my $v;
338 - my @l = ();
340 - foreach $v (@_) {
341 - if (!defined($v)) {
342 - push(@l, 'undef');
343 - } elsif ($v =~ /^0x/) {
344 - push(@l, "\'".$v."\'");
345 - } else {
346 - push(@l, $v.'');
349 - return join(',', @l);
352 -($hz) = @ARGV;
354 -# Use this to generate the %canned_values structure
355 -if ($hz eq '--can') {
356 - shift(@ARGV);
357 - @hzlist = sort {$a <=> $b} (@ARGV);
359 - print "# Precomputed values for systems without Math::BigInt\n";
360 - print "# Generated by:\n";
361 - print "# timeconst.pl --can ", join(' ', @hzlist), "\n";
362 - print "\%canned_values = (\n";
363 - my $pf = "\t";
364 - foreach $hz (@hzlist) {
365 - my @values = compute_values($hz);
366 - print "$pf$hz => [\n";
367 - while (scalar(@values)) {
368 - my $bit;
369 - foreach $bit (32) {
370 - my $m = shift(@values);
371 - my $a = shift(@values);
372 - my $s = shift(@values);
373 - print "\t\t", perlvals($m,$a,$s), ",\n";
375 - my $n = shift(@values);
376 - my $d = shift(@values);
377 - print "\t\t", perlvals($n,$d), ",\n";
379 - print "\t]";
380 - $pf = ', ';
382 - print "\n);\n";
383 -} else {
384 - $hz += 0; # Force to number
385 - if ($hz < 1) {
386 - die "Usage: $0 HZ\n";
389 - @val = @{$canned_values{$hz}};
390 - if (!defined(@val)) {
391 - @val = compute_values($hz);
393 - output($hz, @val);
395 -exit 0;
396 diff -ruN linux-2.6.30/kernel/timeconst.sh linux-2.6.30.new/kernel/timeconst.sh
397 --- linux-2.6.30/kernel/timeconst.sh 1969-12-31 18:00:00.000000000 -0600
398 +++ linux-2.6.30.new/kernel/timeconst.sh 2009-06-22 14:29:16.000000000 -0500
399 @@ -0,0 +1,148 @@
400 +#!/bin/sh
402 +if [ $# -ne 2 ]
403 +then
404 + echo "Usage: timeconst.sh HZ FILENAME"
405 + echo
406 + echo "Generate a header file with constants for coverting between"
407 + echo "decimal HZ timer ticks and milisecond or microsecond delays."
408 + echo
409 + exit 1
412 +HZ=$1
413 +shift
414 +FILENAME=$1
416 +# Sanity test: even the shell in Red Hat 9 (circa 2003) supported 64 bit math.
418 +if [ $((1 << 32)) -lt 0 ]
419 +then
420 + echo "timeconst.sh needs a shell with 64 bit math, such as bash,"
421 + echo "busybox ash, or dash running on a 64 bit host."
422 + exit 1
425 +# If this script exits for any reason before this trap is removed,
426 +# delete the output file so a partial file won't confuse the build.
428 +trap "rm $FILENAME" EXIT
430 +# Output start of header file
432 +cat > $FILENAME << EOF || exit 1
433 +/* Automatically generated by kernel/timeconst.sh */
434 +/* Conversion constants for HZ == $HZ */
436 +#ifndef __KERNEL_TIMECONST_H
437 +#define __KERNEL_TIMECONST_H
439 +#include <linux/param.h>
440 +#include <linux/types.h>
442 +#if HZ != $HZ
443 +#error "kernel/timeconst.h has the wrong HZ value!"
444 +#endif
446 +EOF
448 +# For both Milliseconds and Microseconds
450 +cat << EOF |
451 +MSEC 1000
452 +USEC 1000000
453 +EOF
454 +while read NAME PERIOD
456 + # Find greatest common denominator (using Euclid's algorithm)
458 + A=$HZ
459 + B=$PERIOD
461 + while [ $B -ne 0 ]
462 + do
463 + C=$(( $A % $B ))
464 + A=$B
465 + B=$C
466 + done
468 + GCD=$A
470 + # Do this for each direction (HZ_TO_PERIOD and PERIOD_TO_HZ)
472 + for DIRECTION in 0 1
473 + do
474 + if [ $DIRECTION -eq 0 ]
475 + then
476 + CONVERT="HZ_TO_${NAME}"
477 + FROM=$HZ
478 + TO=$PERIOD
479 + else
480 + CONVERT="${NAME}_TO_HZ"
481 + FROM=$PERIOD
482 + TO=$HZ
483 + fi
485 + # Calculate 32 significant bits of MUL32 data.
487 + SHIFT=0
488 + while true
489 + do
490 + # This can't overflow 64 bit math. Pathological case
491 + # (TO=1, FROM=1000000) uses around 32+20=52 bits.
493 + MUL32=$(( ( ( $TO << $SHIFT ) + $FROM - 1 ) / $FROM ))
495 + # Keep increasing $SHIFT until we've got 32 bits.
497 + [ $MUL32 -gt $(( 1 << 31 )) ] && break
498 + SHIFT=$(( $SHIFT + 1 ))
499 + done
500 + MUL32=$( printf %x $MUL32 )
502 + # ADJ32 is just (((FROM/GCD)-1)<<SHIFT)/(FROM/GCD) but this
503 + # can overflow 64 bit math (examples, HZ=24 or HZ=122).
504 + # Pathological case could use 32+20+20=72 bits. (And this is
505 + # the pathological case because a larger $HZ results in a
506 + # smaller $SHIFT, so even insane HZ>USEC cases should be ok.)
508 + # To get around this, we chop the bottom 32 bits off the
509 + # calculation and then reassemble it to avoid overflow:
510 + # 32+64=96, which is > 72.
512 + ADJ32=$(( $FROM / $GCD ))
513 + if [ $SHIFT -gt 32 ]
514 + then
515 + UPPER=$(( ( $ADJ32 - 1 ) << ( $SHIFT - 32 ) ))
516 + LOWER=$(( ( $UPPER % $ADJ32 ) << 32 ))
517 + ADJ32=$(( ( ( $UPPER / $ADJ32 ) << 32 ) + ( $LOWER / $ADJ32 )))
518 + else
519 + ADJ32=$(( ( ( $ADJ32 - 1 ) << $SHIFT) / $ADJ32 ))
520 + fi
521 + ADJ32=$( printf %x $ADJ32 )
523 + NUM=$(( $TO / $GCD ))
524 + DEN=$(( $FROM / $GCD ))
526 + # Output next chunk of header data to file
529 + echo "#define ${CONVERT}_MUL32 U64_C(0x$MUL32)" &&
530 + echo "#define ${CONVERT}_ADJ32 U64_C(0x$ADJ32)" &&
531 + echo "#define ${CONVERT}_SHR32 $SHIFT" &&
532 + echo "#define ${CONVERT}_NUM U64_C($NUM)" &&
533 + echo "#define ${CONVERT}_DEN U64_C($DEN)"
534 + ) >> $FILENAME || exit 1
535 + done
536 +done
539 + echo
540 + echo "#endif /* __KERNEL_TIMECHONST_H */"
541 +) >> $FILENAME || exit 1
543 +# Don't rm $FILENAME on exit anymore.
545 +trap "" EXIT
547 +exit 0