summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@gnu.org>2008-12-17 13:50:53 +0100
committerNeal H. Walfield <neal@gnu.org>2008-12-17 13:50:53 +0100
commitee961b372e1d403d3fb205b5887025ccc72c0a87 (patch)
treedd1830ea785c25d7aa8c09ba0fe4f23f57eed9e5
parent49802ec3b83bf6f9d9b3a7f911eb42bed22a8895 (diff)
Move hurd/math.h to libviengoos.
hurd/ 2008-12-17 Neal H. Walfield <neal@gnu.org> * math.h: Move to ../libviengoos/viengoos. Update users. * bits/ia32/math.h: Remove file. * headers.m4: Don't link hurd/math.h or hurd/bits/math.h. libviengoos/ 2008-12-17 Neal H. Walfield <neal@gnu.org> * viengoos/math.h: Move from ../hurd. Rewrite to use gcc builtin functions. * Makefile.am (viengoos_headers): Add math.h. * headers.m4: Link viengoos/math.h.
-rw-r--r--hurd/ChangeLog6
-rw-r--r--hurd/bits/ia32/math.h54
-rw-r--r--hurd/headers.m42
-rw-r--r--hurd/math.h139
-rw-r--r--libviengoos/ChangeLog7
-rw-r--r--libviengoos/Makefile.am2
-rw-r--r--libviengoos/headers.m41
-rw-r--r--libviengoos/viengoos/addr-trans.h2
-rw-r--r--libviengoos/viengoos/addr.h2
-rw-r--r--libviengoos/viengoos/math.h72
10 files changed, 89 insertions, 198 deletions
diff --git a/hurd/ChangeLog b/hurd/ChangeLog
index 8b17eed..eeb2a90 100644
--- a/hurd/ChangeLog
+++ b/hurd/ChangeLog
@@ -1,5 +1,11 @@
2008-12-17 Neal H. Walfield <neal@gnu.org>
+ * math.h: Move to ../libviengoos/viengoos. Update users.
+ * bits/ia32/math.h: Remove file.
+ * headers.m4: Don't link hurd/math.h or hurd/bits/math.h.
+
+2008-12-17 Neal H. Walfield <neal@gnu.org>
+
* activity.h: Move to ../libviengoos/viengoos. Update references.
* addr-trans.h: Likewise.
* addr.h: Likewise.
diff --git a/hurd/bits/ia32/math.h b/hurd/bits/ia32/math.h
deleted file mode 100644
index c1e6479..0000000
--- a/hurd/bits/ia32/math.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* hurd/math.h - Public interface to Hurd mathematical support functions.
- Copyright (C) 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
- Written by Marcus Brinkmann <marcus@gnu.org>.
-
- This file is part of the GNU Hurd.
-
- The GNU Hurd is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License
- as published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- The GNU Hurd is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU L4 library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
-
-#ifndef _HURD_BITS_MATH_H
-#define _HURD_BITS_MATH_H
-
-#include <stdint.h>
-
-/* Calculate the MSB set in DATA. DATA is not 0. */
-static inline uintptr_t
-__VG_msb (uintptr_t data)
-{
- uintptr_t msb;
-
- __asm__ ("bsr %[data], %[msb]"
- : [msb] "=r" (msb)
- : [data] "rm" (data));
-
- return msb + 1;
-}
-
-
-/* Calculate the LSB set in DATA. DATA is not 0. */
-static inline uintptr_t
-__VG_lsb (uintptr_t data)
-{
- uintptr_t lsb;
-
- __asm__ ("bsf %[data], %[lsb]"
- : [lsb] "=r" (lsb)
- : [data] "rm" (data));
-
- return lsb + 1;
-}
-
-#endif
diff --git a/hurd/headers.m4 b/hurd/headers.m4
index d5842fb..da2d579 100644
--- a/hurd/headers.m4
+++ b/hurd/headers.m4
@@ -20,6 +20,4 @@ AC_CONFIG_LINKS([sysroot/include/hurd/stddef.h:hurd/stddef.h
sysroot/include/hurd/mutex.h:hurd/mutex.h
sysroot/include/hurd/rmutex.h:hurd/rmutex.h
sysroot/include/hurd/error.h:hurd/error.h
- sysroot/include/hurd/math.h:hurd/math.h
- sysroot/include/hurd/bits/math.h:hurd/bits/${arch}/math.h
])
diff --git a/hurd/math.h b/hurd/math.h
deleted file mode 100644
index e9e66bb..0000000
--- a/hurd/math.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/* l4/math.h - Public interface to Hurd mathematical support functions.
- Copyright (C) 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
- Written by Marcus Brinkmann <marcus@gnu.org>.
-
- This file is part of the GNU Hurd.
-
- The GNU Hurd is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public License
- as published by the Free Software Foundation; either version 2.1 of
- the License, or (at your option) any later version.
-
- The GNU Hurd is distributed in the hope that it will be
- useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU L4 library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
-
-#ifndef _HURD_MATH_H
-#define _HURD_MATH_H
-
-#include <stdint.h>
-#include <bits/wordsize.h>
-#include <hurd/bits/math.h>
-
-/* Return 0 if DATA is 0, or the bit number of the most significant
- bit set in DATA. The least significant bit is 1, the most
- significant bit 32 resp. 64. */
-static inline uintptr_t
-vg_msb (uintptr_t data)
-{
- if (__builtin_constant_p (data))
- {
-#define __VG_MSB_TRY(b) else if (data < (1 << (b))) return (b)
-#define __VG_MSB_IS(b) else return (b)
-
- if (!data)
- return 0;
- __VG_MSB_TRY(1); __VG_MSB_TRY(2); __VG_MSB_TRY(3); __VG_MSB_TRY(4);
- __VG_MSB_TRY(5); __VG_MSB_TRY(6); __VG_MSB_TRY(7); __VG_MSB_TRY(8);
- __VG_MSB_TRY(9); __VG_MSB_TRY(10); __VG_MSB_TRY(11); __VG_MSB_TRY(12);
- __VG_MSB_TRY(13); __VG_MSB_TRY(14); __VG_MSB_TRY(15); __VG_MSB_TRY(16);
- __VG_MSB_TRY(17); __VG_MSB_TRY(18); __VG_MSB_TRY(19); __VG_MSB_TRY(20);
- __VG_MSB_TRY(21); __VG_MSB_TRY(22); __VG_MSB_TRY(23); __VG_MSB_TRY(24);
- __VG_MSB_TRY(25); __VG_MSB_TRY(26); __VG_MSB_TRY(27); __VG_MSB_TRY(28);
- __VG_MSB_TRY(29); __VG_MSB_TRY(30); __VG_MSB_TRY(31);
-#if __WORDSIZE == 32
- __VG_MSB_IS(32);
-#else
- __VG_MSB_TRY(32); __VG_MSB_TRY(33); __VG_MSB_TRY(34); __VG_MSB_TRY(35);
- __VG_MSB_TRY(36); __VG_MSB_TRY(37); __VG_MSB_TRY(38); __VG_MSB_TRY(39);
- __VG_MSB_TRY(40); __VG_MSB_TRY(41); __VG_MSB_TRY(42); __VG_MSB_TRY(43);
- __VG_MSB_TRY(44); __VG_MSB_TRY(45); __VG_MSB_TRY(46); __VG_MSB_TRY(47);
- __VG_MSB_TRY(48); __VG_MSB_TRY(49); __VG_MSB_TRY(50); __VG_MSB_TRY(51);
- __VG_MSB_TRY(52); __VG_MSB_TRY(53); __VG_MSB_TRY(54); __VG_MSB_TRY(55);
- __VG_MSB_TRY(56); __VG_MSB_TRY(57); __VG_MSB_TRY(58); __VG_MSB_TRY(59);
- __VG_MSB_TRY(60); __VG_MSB_TRY(61); __VG_MSB_TRY(62); __VG_MSB_TRY(63);
- __VG_MSB_IS(64);
-#endif
- }
-
- if (__builtin_expect (data != 0, 1))
- return __VG_msb (data);
- else
- return 0;
-}
-
-static inline uintptr_t
-vg_msb64 (uint64_t data)
-{
-#if __WORDSIZE == 64
- return vg_msb (data);
-#else
- int d = vg_msb (data >> 32);
- if (d)
- return d + 32;
- return vg_msb (data);
-#endif
-}
-
-/* Return 0 if DATA is 0, or the bit number of the least significant
- bit set in DATA. The least significant bit is 1, the most
- significant bit 32 resp. 64. */
-static inline uintptr_t
-vg_lsb (uintptr_t data)
-{
- if (__builtin_constant_p (data))
- {
-#define __VG_LSB_TRY(b) else if (data >= (1 << (b - 1))) return (b)
-#define __VG_LSB_IS(b) else return (b)
-
- if (!data)
- return 0;
-#if __WORDSIZE == 64
- __VG_LSB_TRY(64); __VG_LSB_TRY(63); __VG_LSB_TRY(62); __VG_LSB_TRY(61);
- __VG_LSB_TRY(60); __VG_LSB_TRY(59); __VG_LSB_TRY(58); __VG_LSB_TRY(57);
- __VG_LSB_TRY(56); __VG_LSB_TRY(55); __VG_LSB_TRY(54); __VG_LSB_TRY(53);
- __VG_LSB_TRY(52); __VG_LSB_TRY(51); __VG_LSB_TRY(50); __VG_LSB_TRY(49);
- __VG_LSB_TRY(48); __VG_LSB_TRY(47); __VG_LSB_TRY(46); __VG_LSB_TRY(45);
- __VG_LSB_TRY(44); __VG_LSB_TRY(43); __VG_LSB_TRY(42); __VG_LSB_TRY(41);
- __VG_LSB_TRY(40); __VG_LSB_TRY(39); __VG_LSB_TRY(38); __VG_LSB_TRY(37);
- __VG_LSB_TRY(36); __VG_LSB_TRY(35); __VG_LSB_TRY(34); __VG_LSB_TRY(33);
-#endif
- __VG_LSB_TRY(32); __VG_LSB_TRY(31); __VG_LSB_TRY(30); __VG_LSB_TRY(29);
- __VG_LSB_TRY(28); __VG_LSB_TRY(27); __VG_LSB_TRY(26); __VG_LSB_TRY(25);
- __VG_LSB_TRY(24); __VG_LSB_TRY(23); __VG_LSB_TRY(22); __VG_LSB_TRY(21);
- __VG_LSB_TRY(20); __VG_LSB_TRY(19); __VG_LSB_TRY(18); __VG_LSB_TRY(17);
- __VG_LSB_TRY(16); __VG_LSB_TRY(15); __VG_LSB_TRY(14); __VG_LSB_TRY(13);
- __VG_LSB_TRY(12); __VG_LSB_TRY(11); __VG_LSB_TRY(10); __VG_LSB_TRY(9);
- __VG_LSB_TRY(8); __VG_LSB_TRY(7); __VG_LSB_TRY(6); __VG_LSB_TRY(5);
- __VG_LSB_TRY(4); __VG_LSB_TRY(3); __VG_LSB_TRY(2); __VG_LSB_IS(1);
- }
-
- if (__builtin_expect (data != 0, 1))
- return __VG_lsb (data);
- else
- return 0;
-}
-
-static inline uintptr_t
-vg_lsb64 (uint64_t data)
-{
-#if __WORDSIZE == 64
- return vg_lsb (data);
-#else
- int d = vg_lsb (data);
- if (d)
- return d;
- d = vg_lsb (data >> 32);
- if (d)
- return d + 32;
- return 0;
-#endif
-}
-
-#endif
diff --git a/libviengoos/ChangeLog b/libviengoos/ChangeLog
index 1e3bbc5..5991b0a 100644
--- a/libviengoos/ChangeLog
+++ b/libviengoos/ChangeLog
@@ -1,5 +1,12 @@
2008-12-17 Neal H. Walfield <neal@gnu.org>
+ * viengoos/math.h: Move from ../hurd. Rewrite to use gcc builtin
+ functions.
+ * Makefile.am (viengoos_headers): Add math.h.
+ * headers.m4: Link viengoos/math.h.
+
+2008-12-17 Neal H. Walfield <neal@gnu.org>
+
* Makefile.am: New file.
* headers.m4: Likewise.
* t-addr-trans.c: Move from ../hurd.
diff --git a/libviengoos/Makefile.am b/libviengoos/Makefile.am
index 6e7b1c4..c3169d0 100644
--- a/libviengoos/Makefile.am
+++ b/libviengoos/Makefile.am
@@ -22,7 +22,7 @@ viengoos_headers = addr.h addr-trans.h cap.h \
thread.h folio.h activity.h futex.h messenger.h \
message.h ipc.h \
rpc.h \
- misc.h
+ math.h misc.h
nobase_include_HEADERS = viengoos.h \
$(addprefix viengoos/, $(viengoos_headers))
diff --git a/libviengoos/headers.m4 b/libviengoos/headers.m4
index 834985f..b32b0f2 100644
--- a/libviengoos/headers.m4
+++ b/libviengoos/headers.m4
@@ -23,6 +23,7 @@ AC_CONFIG_LINKS([
sysroot/include/viengoos/message.h:libviengoos/viengoos/message.h
sysroot/include/viengoos/ipc.h:libviengoos/viengoos/ipc.h
sysroot/include/viengoos/rpc.h:libviengoos/viengoos/rpc.h
+ sysroot/include/viengoos/math.h:libviengoos/viengoos/math.h
sysroot/include/viengoos/misc.h:libviengoos/viengoos/misc.h
])
diff --git a/libviengoos/viengoos/addr-trans.h b/libviengoos/viengoos/addr-trans.h
index de49ce7..b48f132 100644
--- a/libviengoos/viengoos/addr-trans.h
+++ b/libviengoos/viengoos/addr-trans.h
@@ -23,7 +23,7 @@
#include <stdint.h>
#include <hurd/stddef.h>
-#include <hurd/math.h>
+#include <viengoos/math.h>
/* Capabilities have two primary functions: they designate objects and
they participate in address translation. This structure controls
diff --git a/libviengoos/viengoos/addr.h b/libviengoos/viengoos/addr.h
index badfcd9..8fa59be 100644
--- a/libviengoos/viengoos/addr.h
+++ b/libviengoos/viengoos/addr.h
@@ -23,7 +23,7 @@
#define _VIENGOOS_ADDR_H 1
#include <hurd/types.h>
-#include <hurd/math.h>
+#include <viengoos/math.h>
#include <stdint.h>
#include <assert.h>
diff --git a/libviengoos/viengoos/math.h b/libviengoos/viengoos/math.h
new file mode 100644
index 0000000..5ab54c8
--- /dev/null
+++ b/libviengoos/viengoos/math.h
@@ -0,0 +1,72 @@
+/* l4/math.h - Public interface to Hurd mathematical support functions.
+ Copyright (C) 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
+ Written by Marcus Brinkmann <marcus@gnu.org>.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU L4 library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#ifndef _HURD_MATH_H
+#define _HURD_MATH_H
+
+#include <stdint.h>
+#include <bits/wordsize.h>
+
+/* Return 0 if DATA is 0, or the bit number of the most significant
+ bit set in DATA. The least significant bit is 1, the most
+ significant bit 32 resp. 64. */
+static inline uintptr_t
+vg_msb (uintptr_t data)
+{
+ if (! data)
+ return 0;
+
+#if __WORDSIZE == 64
+ return 8 * sizeof (data) - __builtin_clzll (data);
+#else
+ return 8 * sizeof (data) - __builtin_clz (data);
+#endif
+}
+
+static inline uintptr_t
+vg_msb64 (uint64_t data)
+{
+ if (! data)
+ return 0;
+
+ return 8 * sizeof (data) - __builtin_clzll (data);
+}
+
+/* Return 0 if DATA is 0, or the bit number of the least significant
+ bit set in DATA. The least significant bit is 1, the most
+ significant bit 32 resp. 64. */
+static inline uintptr_t
+vg_lsb (uintptr_t data)
+{
+#if __WORDSIZE == 64
+ return __builtin_ffsll (data);
+#else
+ return __builtin_ffs (data);
+#endif
+}
+
+static inline uintptr_t
+vg_lsb64 (uint64_t data)
+{
+ return __builtin_ffsll (data);
+}
+
+#endif