summaryrefslogtreecommitdiff
path: root/games/crafty/patches
diff options
context:
space:
mode:
authorjmc <jmc>2002-04-04 19:28:10 +0000
committerjmc <jmc>2002-04-04 19:28:10 +0000
commit049f2c75c7d9d468e91814da765988b6ece3abd5 (patch)
tree87b54489a5d1db09d0142532167cbd8067a02869 /games/crafty/patches
parent6c634b4745ce4a191dd8e21d8543e11495531931 (diff)
downloadpkgsrc-049f2c75c7d9d468e91814da765988b6ece3abd5.tar.gz
Provide a FirstOne and LastOne implemention for archs without hand crafted
assembly substitutes.
Diffstat (limited to 'games/crafty/patches')
-rw-r--r--games/crafty/patches/patch-ab67
1 files changed, 67 insertions, 0 deletions
diff --git a/games/crafty/patches/patch-ab b/games/crafty/patches/patch-ab
new file mode 100644
index 00000000000..9277af05ed2
--- /dev/null
+++ b/games/crafty/patches/patch-ab
@@ -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