Provide a FirstOne and LastOne implemention for archs without hand crafted
assembly substitutes.
This commit is contained in:
parent
c4556bac9f
commit
89338eebd6
2 changed files with 69 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
|||
$NetBSD: distinfo,v 1.5 2002/01/12 05:48:15 jlam Exp $
|
||||
$NetBSD: distinfo,v 1.6 2002/04/04 19:28:10 jmc Exp $
|
||||
|
||||
SHA1 (crafty-18.13/crafty-18.13.tar.gz) = 9ec43d2c629eaa6bbb0df53b719764487a9d2be2
|
||||
Size (crafty-18.13/crafty-18.13.tar.gz) = 363916 bytes
|
||||
|
@ -9,3 +9,4 @@ Size (crafty-18.13/read.me) = 6942 bytes
|
|||
SHA1 (crafty-18.13/crafty.faq) = 7ba5cc19e190fdcf1697e3130c679ce5e50141db
|
||||
Size (crafty-18.13/crafty.faq) = 10252 bytes
|
||||
SHA1 (patch-aa) = 7e6306d7ba0cc1ac6159c717328bd172785326f1
|
||||
SHA1 (patch-ab) = f25fba723d970a04811481947715dfeaf97a988f
|
||||
|
|
67
games/crafty/patches/patch-ab
Normal file
67
games/crafty/patches/patch-ab
Normal file
|
@ -0,0 +1,67 @@
|
|||
$NetBSD: patch-ab,v 1.3 2002/04/04 19:28:10 jmc Exp $
|
||||
|
||||
--- boolean.c.orig Thu Apr 4 07:18:52 2002
|
||||
+++ boolean.c Thu Apr 4 19:19:16 2002
|
||||
@@ -61,23 +61,49 @@
|
||||
}
|
||||
|
||||
int FirstOne(BITBOARD arg1) {
|
||||
+ unsigned int i, j, k;
|
||||
+
|
||||
+ j = k = 0;
|
||||
if (arg1>>48)
|
||||
- return (first_ones[arg1>>48]);
|
||||
- if ((arg1>>32)&65535)
|
||||
- return (first_ones[(arg1>>32)&65535]+16);
|
||||
- if ((arg1>>16)&65535)
|
||||
- return (first_ones[(arg1>>16)&65535]+32);
|
||||
- return (first_ones[arg1&65535]+48);
|
||||
+ i = ((BITBOARD)(arg1>>48));
|
||||
+ else if ((arg1>>32)&65535) {
|
||||
+ i = ((arg1>>32)&65535);
|
||||
+ j = 16;
|
||||
+ } else if ((arg1>>16)&65535) {
|
||||
+ i = (arg1>>16)&65535;
|
||||
+ j = 32;
|
||||
+ } else {
|
||||
+ i = arg1&65535;
|
||||
+ j = 48;
|
||||
+ }
|
||||
+ while (i >>= 1)
|
||||
+ k++;
|
||||
+ k = 16 - k;
|
||||
+ return (j + k - 1);
|
||||
}
|
||||
|
||||
int LastOne(BITBOARD arg1) {
|
||||
- if (arg1&65535)
|
||||
- return (last_ones[arg1&65535]+48);
|
||||
- if ((arg1>>16)&65535)
|
||||
- return (last_ones[(arg1>>16)&65535]+32);
|
||||
- if ((arg1>>32)&65535)
|
||||
- return (last_ones[(arg1>>32)&65535]+16);
|
||||
- return (last_ones[arg1>>48]);
|
||||
+ unsigned int i,j,k;
|
||||
+
|
||||
+ j = k = 0;
|
||||
+ if (arg1&65535) {
|
||||
+ i = arg1&65535;
|
||||
+ j = 48;
|
||||
+ } else if ((arg1>>16)&65535) {
|
||||
+ i = (arg1>>16)&65535;
|
||||
+ j = 32;
|
||||
+ } else if ((arg1>>32)&65535) {
|
||||
+ i = (arg1>>32)&65535;
|
||||
+ j = 16;
|
||||
+ } else
|
||||
+ i = arg1>>48;
|
||||
+
|
||||
+ while ((i & 0x1) == 0) {
|
||||
+ i >>= 1;
|
||||
+ k++;
|
||||
+ }
|
||||
+ k = 16 - k;
|
||||
+ return j + k - 1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
Loading…
Reference in a new issue