diff options
author | Neal H. Walfield <neal@gnu.org> | 2008-12-17 13:50:53 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@gnu.org> | 2008-12-17 13:50:53 +0100 |
commit | ee961b372e1d403d3fb205b5887025ccc72c0a87 (patch) | |
tree | dd1830ea785c25d7aa8c09ba0fe4f23f57eed9e5 /libviengoos | |
parent | 49802ec3b83bf6f9d9b3a7f911eb42bed22a8895 (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.
Diffstat (limited to 'libviengoos')
-rw-r--r-- | libviengoos/ChangeLog | 7 | ||||
-rw-r--r-- | libviengoos/Makefile.am | 2 | ||||
-rw-r--r-- | libviengoos/headers.m4 | 1 | ||||
-rw-r--r-- | libviengoos/viengoos/addr-trans.h | 2 | ||||
-rw-r--r-- | libviengoos/viengoos/addr.h | 2 | ||||
-rw-r--r-- | libviengoos/viengoos/math.h | 72 |
6 files changed, 83 insertions, 3 deletions
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 |