Module: xenomai-forge
Branch: next
Commit: f4849e8b3e023491b6f1bcc3aeb8560a390e92f7
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=f4849e8b3e023491b6f1bcc3aeb8560a390e92f7

Author: Philippe Gerum <r...@xenomai.org>
Date:   Thu Jul  4 09:16:46 2013 +0200

cobalt: move arithmetic helpers to the uapi section

---

 include/cobalt/Makefile.am                     |    1 +
 include/cobalt/Makefile.in                     |    1 +
 include/cobalt/arith.h                         |   44 +++++
 include/cobalt/asm-arm/Makefile.am             |    1 -
 include/cobalt/asm-arm/Makefile.in             |    1 -
 include/cobalt/asm-arm/uapi/Makefile.am        |    1 +
 include/cobalt/asm-arm/uapi/Makefile.in        |    1 +
 include/cobalt/asm-arm/{ => uapi}/arith.h      |    8 +-
 include/cobalt/asm-blackfin/Makefile.am        |    1 -
 include/cobalt/asm-blackfin/Makefile.in        |    1 -
 include/cobalt/asm-blackfin/uapi/Makefile.am   |    1 +
 include/cobalt/asm-blackfin/uapi/Makefile.in   |    1 +
 include/cobalt/asm-blackfin/{ => uapi}/arith.h |    8 +-
 include/cobalt/asm-generic/Makefile.am         |    1 -
 include/cobalt/asm-generic/Makefile.in         |    1 -
 include/cobalt/asm-generic/uapi/Makefile.am    |    1 +
 include/cobalt/asm-generic/uapi/Makefile.in    |    1 +
 include/cobalt/asm-generic/{ => uapi}/arith.h  |  222 +++++++++++-------------
 include/cobalt/asm-generic/uapi/features.h     |    1 -
 include/cobalt/asm-nios2/Makefile.am           |    1 -
 include/cobalt/asm-nios2/Makefile.in           |    1 -
 include/cobalt/asm-nios2/uapi/Makefile.am      |    1 +
 include/cobalt/asm-nios2/uapi/Makefile.in      |    1 +
 include/cobalt/asm-nios2/{ => uapi}/arith.h    |    8 +-
 include/cobalt/asm-powerpc/Makefile.am         |    1 -
 include/cobalt/asm-powerpc/Makefile.in         |    1 -
 include/cobalt/asm-powerpc/uapi/Makefile.am    |    1 +
 include/cobalt/asm-powerpc/uapi/Makefile.in    |    1 +
 include/cobalt/asm-powerpc/{ => uapi}/arith.h  |    9 +-
 include/cobalt/asm-sh/Makefile.am              |    1 -
 include/cobalt/asm-sh/Makefile.in              |    1 -
 include/cobalt/asm-sh/uapi/Makefile.am         |    1 +
 include/cobalt/asm-sh/uapi/Makefile.in         |    1 +
 include/cobalt/asm-sh/{ => uapi}/arith.h       |    9 +-
 include/cobalt/asm-x86/Makefile.am             |    1 -
 include/cobalt/asm-x86/Makefile.in             |    1 -
 include/cobalt/asm-x86/uapi/Makefile.am        |    1 +
 include/cobalt/asm-x86/uapi/Makefile.in        |    1 +
 include/cobalt/asm-x86/{ => uapi}/arith.h      |   10 +-
 include/cobalt/kernel/Makefile.am              |    1 +
 include/cobalt/kernel/Makefile.in              |    1 +
 include/cobalt/kernel/arith.h                  |   35 ++++
 kernel/cobalt/arch/arm/machine.c               |    2 +-
 kernel/cobalt/arch/x86/machine.c               |    2 +-
 kernel/cobalt/clock.c                          |    2 +-
 kernel/cobalt/posix/clock.c                    |    1 -
 kernel/cobalt/posix/internal.h                 |    2 +-
 kernel/cobalt/sched.c                          |    2 +-
 kernel/cobalt/timer.c                          |    2 +-
 kernel/drivers/ipc/internal.h                  |    2 +-
 kernel/drivers/testing/timerbench.c            |    5 +-
 lib/cobalt/ticks.c                             |    2 +-
 lib/copperplate/clockobj.c                     |    2 +-
 testsuite/unit/arith-noinline.c                |    2 +-
 testsuite/unit/arith.c                         |    2 +-
 55 files changed, 232 insertions(+), 182 deletions(-)

diff --git a/include/cobalt/Makefile.am b/include/cobalt/Makefile.am
index cece4eb..23afa9f 100644
--- a/include/cobalt/Makefile.am
+++ b/include/cobalt/Makefile.am
@@ -1,6 +1,7 @@
 includesubdir = $(includedir)/cobalt
 
 includesub_HEADERS =   \
+       arith.h         \
        core.h          \
        fcntl.h         \
        mqueue.h        \
diff --git a/include/cobalt/Makefile.in b/include/cobalt/Makefile.in
index 57ed864..81131d0 100644
--- a/include/cobalt/Makefile.in
+++ b/include/cobalt/Makefile.in
@@ -312,6 +312,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 includesubdir = $(includedir)/cobalt
 includesub_HEADERS = \
+       arith.h         \
        core.h          \
        fcntl.h         \
        mqueue.h        \
diff --git a/include/cobalt/arith.h b/include/cobalt/arith.h
new file mode 100644
index 0000000..1c100b3
--- /dev/null
+++ b/include/cobalt/arith.h
@@ -0,0 +1,44 @@
+/**
+ *   Generic arithmetic/conversion routines.
+ *   Copyright &copy; 2005 Stelian Pop.
+ *   Copyright &copy; 2005 Gilles Chanteperdrix.
+ *
+ * This library 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 of the License, or (at your option) any later version.
+ *
+ * This library 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 this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
+ */
+#ifndef _COBALT_ARITH_H
+#define _COBALT_ARITH_H
+
+#include <stddef.h>
+#include <endian.h>
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define endianstruct { unsigned int _h; unsigned int _l; }
+#else /* __BYTE_ORDER == __LITTLE_ENDIAN */
+#define endianstruct { unsigned int _l; unsigned int _h; }
+#endif /* __BYTE_ORDER == __LITTLE_ENDIAN */
+
+static inline unsigned xnarch_do_div(unsigned long long *a, unsigned d)
+{
+       unsigned int r = *a % d;
+       *a /= d;
+
+       return r;
+}
+
+#define do_div(a, d) xnarch_do_div(&(a), (d))
+
+#include <asm/xenomai/uapi/arith.h>
+
+#endif /* !_COBALT_ARITH_H */
diff --git a/include/cobalt/asm-arm/Makefile.am 
b/include/cobalt/asm-arm/Makefile.am
index 7fc56d6..2635e3c 100644
--- a/include/cobalt/asm-arm/Makefile.am
+++ b/include/cobalt/asm-arm/Makefile.am
@@ -1,7 +1,6 @@
 includesubdir = $(includedir)/asm-arm
 
 includesub_HEADERS =   \
-       arith.h         \
        calibration.h   \
        features.h      \
        fptest.h        \
diff --git a/include/cobalt/asm-arm/Makefile.in 
b/include/cobalt/asm-arm/Makefile.in
index cd77223..7377a2a 100644
--- a/include/cobalt/asm-arm/Makefile.in
+++ b/include/cobalt/asm-arm/Makefile.in
@@ -312,7 +312,6 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 includesubdir = $(includedir)/asm-arm
 includesub_HEADERS = \
-       arith.h         \
        calibration.h   \
        features.h      \
        fptest.h        \
diff --git a/include/cobalt/asm-arm/uapi/Makefile.am 
b/include/cobalt/asm-arm/uapi/Makefile.am
index a299780..eb7d364 100644
--- a/include/cobalt/asm-arm/uapi/Makefile.am
+++ b/include/cobalt/asm-arm/uapi/Makefile.am
@@ -1,6 +1,7 @@
 includesubdir = $(includedir)/asm-arm/uapi
 
 includesub_HEADERS =   \
+       arith.h         \
        features.h      \
        syscall.h       \
        tsc.h
diff --git a/include/cobalt/asm-arm/uapi/Makefile.in 
b/include/cobalt/asm-arm/uapi/Makefile.in
index cdad91b..759ca12 100644
--- a/include/cobalt/asm-arm/uapi/Makefile.in
+++ b/include/cobalt/asm-arm/uapi/Makefile.in
@@ -274,6 +274,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 includesubdir = $(includedir)/asm-arm/uapi
 includesub_HEADERS = \
+       arith.h         \
        features.h      \
        syscall.h       \
        tsc.h
diff --git a/include/cobalt/asm-arm/arith.h 
b/include/cobalt/asm-arm/uapi/arith.h
similarity index 96%
rename from include/cobalt/asm-arm/arith.h
rename to include/cobalt/asm-arm/uapi/arith.h
index eb01fd5..34187e9 100644
--- a/include/cobalt/asm-arm/arith.h
+++ b/include/cobalt/asm-arm/uapi/arith.h
@@ -1,5 +1,5 @@
-#ifndef _COBALT_ASM_ARM_ARITH_H
-#define _COBALT_ASM_ARM_ARITH_H
+#ifndef _COBALT_ASM_ARM_UAPI_ARITH_H
+#define _COBALT_ASM_ARM_UAPI_ARITH_H
 
 #include <asm/xenomai/uapi/features.h>
 
@@ -30,7 +30,7 @@ mach_arm_nodiv_llimd(const long long op,
        } while (0)
 #endif /* arm <= v3 */
 
-#include <asm-generic/xenomai/arith.h>
+#include <asm-generic/xenomai/uapi/arith.h>
 
 #if __LINUX_ARM_ARCH__ >= 4 && (!defined(CONFIG_THUMB2_KERNEL) || 
!defined(CONFIG_FTRACE))
 #define mach_arm_nodiv_ullimd_str                      \
@@ -124,4 +124,4 @@ mach_arm_nodiv_llimd(const long long op,
 
 extern struct xnarch_u32frac mach_arm_tsc_to_timer;
 
-#endif /* _COBALT_ASM_ARM_ARITH_H */
+#endif /* _COBALT_ASM_ARM_UAPI_ARITH_H */
diff --git a/include/cobalt/asm-blackfin/Makefile.am 
b/include/cobalt/asm-blackfin/Makefile.am
index f4e3635..d0003a5 100644
--- a/include/cobalt/asm-blackfin/Makefile.am
+++ b/include/cobalt/asm-blackfin/Makefile.am
@@ -1,7 +1,6 @@
 includesubdir = $(includedir)/asm-blackfin
 
 includesub_HEADERS =   \
-       arith.h         \
        calibration.h   \
        features.h      \
        fptest.h        \
diff --git a/include/cobalt/asm-blackfin/Makefile.in 
b/include/cobalt/asm-blackfin/Makefile.in
index 46a2316..2d3b54d 100644
--- a/include/cobalt/asm-blackfin/Makefile.in
+++ b/include/cobalt/asm-blackfin/Makefile.in
@@ -312,7 +312,6 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 includesubdir = $(includedir)/asm-blackfin
 includesub_HEADERS = \
-       arith.h         \
        calibration.h   \
        features.h      \
        fptest.h        \
diff --git a/include/cobalt/asm-blackfin/uapi/Makefile.am 
b/include/cobalt/asm-blackfin/uapi/Makefile.am
index 507586b..e07a3bb 100644
--- a/include/cobalt/asm-blackfin/uapi/Makefile.am
+++ b/include/cobalt/asm-blackfin/uapi/Makefile.am
@@ -1,5 +1,6 @@
 includesubdir = $(includedir)/asm-blackfin/uapi
 
 includesub_HEADERS =   \
+       arith.h         \
        features.h      \
        syscall.h
diff --git a/include/cobalt/asm-blackfin/uapi/Makefile.in 
b/include/cobalt/asm-blackfin/uapi/Makefile.in
index 2b73846..5af6c48 100644
--- a/include/cobalt/asm-blackfin/uapi/Makefile.in
+++ b/include/cobalt/asm-blackfin/uapi/Makefile.in
@@ -274,6 +274,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 includesubdir = $(includedir)/asm-blackfin/uapi
 includesub_HEADERS = \
+       arith.h         \
        features.h      \
        syscall.h
 
diff --git a/include/cobalt/asm-blackfin/arith.h 
b/include/cobalt/asm-blackfin/uapi/arith.h
similarity index 88%
rename from include/cobalt/asm-blackfin/arith.h
rename to include/cobalt/asm-blackfin/uapi/arith.h
index b537d2a..425b295 100644
--- a/include/cobalt/asm-blackfin/arith.h
+++ b/include/cobalt/asm-blackfin/uapi/arith.h
@@ -17,8 +17,8 @@
  * 02111-1307, USA.
  */
 
-#ifndef _COBALT_ASM_BLACKFIN_ARITH_H
-#define _COBALT_ASM_BLACKFIN_ARITH_H
+#ifndef _COBALT_ASM_BLACKFIN_UAPI_ARITH_H
+#define _COBALT_ASM_BLACKFIN_UAPI_ARITH_H
 
 #include <asm/xenomai/uapi/features.h>
 
@@ -40,6 +40,6 @@
                   : "d"(s0), "d"(s1) : "cc");                          \
        } while (0)
 
-#include <asm-generic/xenomai/arith.h>
+#include <asm-generic/xenomai/uapi/arith.h>
 
-#endif /* _COBALT_ASM_BLACKFIN_ARITH_H */
+#endif /* _COBALT_ASM_BLACKFIN_UAPI_ARITH_H */
diff --git a/include/cobalt/asm-generic/Makefile.am 
b/include/cobalt/asm-generic/Makefile.am
index 4a57452..ab80c4f 100644
--- a/include/cobalt/asm-generic/Makefile.am
+++ b/include/cobalt/asm-generic/Makefile.am
@@ -1,7 +1,6 @@
 includesubdir = $(includedir)/asm-generic
 
 includesub_HEADERS =   \
-       arith.h         \
        features.h      \
        machine.h       \
        mayday.h        \
diff --git a/include/cobalt/asm-generic/Makefile.in 
b/include/cobalt/asm-generic/Makefile.in
index 2fdc584..0f3aed5 100644
--- a/include/cobalt/asm-generic/Makefile.in
+++ b/include/cobalt/asm-generic/Makefile.in
@@ -312,7 +312,6 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 includesubdir = $(includedir)/asm-generic
 includesub_HEADERS = \
-       arith.h         \
        features.h      \
        machine.h       \
        mayday.h        \
diff --git a/include/cobalt/asm-generic/uapi/Makefile.am 
b/include/cobalt/asm-generic/uapi/Makefile.am
index 2915821..20d7dd2 100644
--- a/include/cobalt/asm-generic/uapi/Makefile.am
+++ b/include/cobalt/asm-generic/uapi/Makefile.am
@@ -1,5 +1,6 @@
 includesubdir = $(includedir)/asm-generic/uapi
 
 includesub_HEADERS =   \
+       arith.h         \
        features.h      \
        syscall.h
diff --git a/include/cobalt/asm-generic/uapi/Makefile.in 
b/include/cobalt/asm-generic/uapi/Makefile.in
index 429282f..fa9ae2e 100644
--- a/include/cobalt/asm-generic/uapi/Makefile.in
+++ b/include/cobalt/asm-generic/uapi/Makefile.in
@@ -274,6 +274,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 includesubdir = $(includedir)/asm-generic/uapi
 includesub_HEADERS = \
+       arith.h         \
        features.h      \
        syscall.h
 
diff --git a/include/cobalt/asm-generic/arith.h 
b/include/cobalt/asm-generic/uapi/arith.h
similarity index 59%
rename from include/cobalt/asm-generic/arith.h
rename to include/cobalt/asm-generic/uapi/arith.h
index d878713..480e062 100644
--- a/include/cobalt/asm-generic/arith.h
+++ b/include/cobalt/asm-generic/uapi/arith.h
@@ -3,75 +3,44 @@
  *   Copyright &copy; 2005 Stelian Pop.
  *   Copyright &copy; 2005 Gilles Chanteperdrix.
  *
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
- *   USA; either version 2 of the License, or (at your option) any later
- *   version.
+ * This library 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 of the License, or (at your option) any later version.
  *
- *   This program 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 General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * This library 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 this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
-
-#ifndef _COBALT_ASM_GENERIC_ARITH_H
-#define _COBALT_ASM_GENERIC_ARITH_H
-
-#ifdef __KERNEL__
-#include <asm/byteorder.h>
-#include <asm/div64.h>
-
-#ifdef __BIG_ENDIAN
-#define endianstruct struct { unsigned _h; unsigned _l; } _s
-#else /* __LITTLE_ENDIAN */
-#define endianstruct struct { unsigned _l; unsigned _h; } _s
-#endif
-
-#else /* !__KERNEL__ */
-#include <stddef.h>
-#include <endian.h>
-
-#if __BYTE_ORDER == __BIG_ENDIAN
-#define endianstruct struct { unsigned _h; unsigned _l; } _s
-#else /* __BYTE_ORDER == __LITTLE_ENDIAN */
-#define endianstruct struct { unsigned _l; unsigned _h; } _s
-#endif /* __BYTE_ORDER == __LITTLE_ENDIAN */
-
-static inline unsigned xnarch_do_div(unsigned long long *a, unsigned d)
-{
-       unsigned r = *a % d;
-       *a /= d;
-       return r;
-}
-
-#define do_div(a, d) xnarch_do_div(&(a), (d))
-
-#endif /* !__KERNEL__ */
+#ifndef _COBALT_ASM_GENERIC_UAPI_ARITH_H
+#define _COBALT_ASM_GENERIC_UAPI_ARITH_H
 
 #ifndef xnarch_u64tou32
 #define xnarch_u64tou32(ull, h, l) ({          \
-    union { unsigned long long _ull;            \
-    endianstruct;                               \
-    } _u;                                       \
-    _u._ull = (ull);                            \
-    (h) = _u._s._h;                             \
-    (l) = _u._s._l;                             \
+      union {                                  \
+             unsigned long long _ull;          \
+             struct endianstruct _s;           \
+      } _u;                                    \
+      _u._ull = (ull);                         \
+      (h) = _u._s._h;                          \
+      (l) = _u._s._l;                          \
 })
 #endif /* !xnarch_u64tou32 */
 
 #ifndef xnarch_u64fromu32
 #define xnarch_u64fromu32(h, l) ({             \
-    union { unsigned long long _ull;            \
-    endianstruct;                               \
-    } _u;                                       \
-    _u._s._h = (h);                             \
-    _u._s._l = (l);                             \
-    _u._ull;                                    \
+       union {                                 \
+               unsigned long long _ull;        \
+               struct endianstruct _s;         \
+       } _u;                                   \
+       _u._s._h = (h);                         \
+       _u._s._l = (l);                         \
+       _u._ull;                                \
 })
 #endif /* !xnarch_u64fromu32 */
 
@@ -79,7 +48,7 @@ static inline unsigned xnarch_do_div(unsigned long long *a, 
unsigned d)
 static inline __attribute__((__const__)) unsigned long long
 xnarch_generic_ullmul(const unsigned m0, const unsigned m1)
 {
-    return (unsigned long long) m0 * m1;
+       return (unsigned long long) m0 * m1;
 }
 #define xnarch_ullmul(m0,m1) xnarch_generic_ullmul((m0),(m1))
 #endif /* !xnarch_ullmul */
@@ -89,12 +58,12 @@ static inline unsigned long long xnarch_generic_ulldiv 
(unsigned long long ull,
                                                        const unsigned uld,
                                                        unsigned long *const rp)
 {
-    const unsigned r = do_div(ull, uld);
+       const unsigned r = do_div(ull, uld);
 
-    if (rp)
-       *rp = r;
+       if (rp)
+               *rp = r;
 
-    return ull;
+       return ull;
 }
 #define xnarch_ulldiv(ull,uld,rp) xnarch_generic_ulldiv((ull),(uld),(rp))
 #endif /* !xnarch_ulldiv */
@@ -111,16 +80,16 @@ xnarch_generic_divmod64(unsigned long long a,
 {
        unsigned long long q;
 #if defined(__KERNEL__) && BITS_PER_LONG < 64
+       unsigned long long
+               xnarch_generic_full_divmod64(unsigned long long a,
+                                            unsigned long long b,
+                                            unsigned long long *rem);
        if (b <= 0xffffffffULL) {
                unsigned long r;
                q = xnarch_ulldiv(a, b, &r);
                if (rem)
                        *rem = r;
        } else {
-               extern unsigned long long
-                       xnarch_generic_full_divmod64(unsigned long long a,
-                                                    unsigned long long b,
-                                                    unsigned long long *rem);
                if (a < b) {
                        if (rem)
                                *rem = a;
@@ -129,11 +98,11 @@ xnarch_generic_divmod64(unsigned long long a,
 
                return xnarch_generic_full_divmod64(a, b, rem);
        }
-#else /* BITS_PER_LONG >= 64 */
+#else /* !(__KERNEL__ && BITS_PER_LONG < 64) */
        q = a / b;
        if (rem)
                *rem = a % b;
-#endif /* BITS_PER_LONG < 64 */
+#endif  /* !(__KERNEL__ && BITS_PER_LONG < 64) */
        return q;
 }
 #define xnarch_divmod64(a,b,rp) xnarch_generic_divmod64((a),(b),(rp))
@@ -144,9 +113,9 @@ static inline __attribute__((__const__)) int 
xnarch_generic_imuldiv(int i,
                                                                    int mult,
                                                                    int div)
 {
-    /* Returns (int)i = (unsigned long long)i*(unsigned)(mult)/(unsigned)div. 
*/
-    const unsigned long long ull = xnarch_ullmul(i, mult);
-    return xnarch_uldivrem(ull, div, NULL);
+       /* (int)i = (unsigned long long)i*(unsigned)(mult)/(unsigned)div. */
+       const unsigned long long ull = xnarch_ullmul(i, mult);
+       return xnarch_uldivrem(ull, div, NULL);
 }
 #define xnarch_imuldiv(i,m,d) xnarch_generic_imuldiv((i),(m),(d))
 #endif /* !xnarch_imuldiv */
@@ -172,12 +141,12 @@ xnarch_generic_div96by32(const unsigned long long h,
                         const unsigned d,
                         unsigned long *const rp)
 {
-    unsigned long rh;
-    const unsigned qh = xnarch_uldivrem(h, d, &rh);
-    const unsigned long long t = xnarch_u64fromu32(rh, l);
-    const unsigned ql = xnarch_uldivrem(t, d, rp);
+       unsigned long rh;
+       const unsigned qh = xnarch_uldivrem(h, d, &rh);
+       const unsigned long long t = xnarch_u64fromu32(rh, l);
+       const unsigned ql = xnarch_uldivrem(t, d, rp);
 
-    return xnarch_u64fromu32(qh, ql);
+       return xnarch_u64fromu32(qh, ql);
 }
 
 #ifndef xnarch_llimd
@@ -186,16 +155,16 @@ unsigned long long xnarch_generic_ullimd(const unsigned 
long long op,
                                         const unsigned m,
                                         const unsigned d)
 {
-    unsigned oph, opl, tlh, tll;
-    unsigned long long th, tl;
+       unsigned int oph, opl, tlh, tll;
+       unsigned long long th, tl;
 
-    xnarch_u64tou32(op, oph, opl);
-    tl = xnarch_ullmul(opl, m);
-    xnarch_u64tou32(tl, tlh, tll);
-    th = xnarch_ullmul(oph, m);
-    th += tlh;
+       xnarch_u64tou32(op, oph, opl);
+       tl = xnarch_ullmul(opl, m);
+       xnarch_u64tou32(tl, tlh, tll);
+       th = xnarch_ullmul(oph, m);
+       th += tlh;
 
-    return xnarch_generic_div96by32(th, tll, d, NULL);
+       return xnarch_generic_div96by32(th, tll, d, NULL);
 }
 
 static inline __attribute__((__const__)) long long
@@ -204,7 +173,7 @@ xnarch_generic_llimd (long long op, unsigned m, unsigned d)
        long long ret;
        int sign = 0;
 
-       if(op < 0LL) {
+       if (op < 0LL) {
                sign = 1;
                op = -op;
        }
@@ -217,9 +186,9 @@ xnarch_generic_llimd (long long op, unsigned m, unsigned d)
 
 #ifndef _xnarch_u96shift
 #define xnarch_u96shift(h, m, l, s) ({         \
-       unsigned _l = (l);                      \
-       unsigned _m = (m);                      \
-       unsigned _s = (s);                      \
+       unsigned int _l = (l);                  \
+       unsigned int _m = (m);                  \
+       unsigned int _s = (s);                  \
        _l >>= _s;                              \
        _l |= (_m << (32 - _s));                \
        _m >>= _s;                              \
@@ -230,7 +199,7 @@ xnarch_generic_llimd (long long op, unsigned m, unsigned d)
 
 static inline long long xnarch_llmi(int i, int j)
 {
-       /* Signed fast 32x32->64 multiplication */
+       /* Fast 32x32->64 signed multiplication */
        return (long long) i * j;
 }
 
@@ -241,7 +210,7 @@ xnarch_generic_llmulshft(const long long op,
                          const unsigned m,
                          const unsigned s)
 {
-       unsigned oph, opl, tlh, tll, thh, thl;
+       unsigned int oph, opl, tlh, tll, thh, thl;
        unsigned long long th, tl;
 
        xnarch_u64tou32(op, oph, opl);
@@ -268,9 +237,11 @@ static inline void xnarch_init_u32frac(struct 
xnarch_u32frac *const f,
                                       const unsigned m,
                                       const unsigned d)
 {
-       /* Avoid clever compiler optimizations to occur when d is
-          known at compile-time. The performance of this function is
-          not critical since it is only called at init time. */
+       /*
+        * Avoid clever compiler optimizations to occur when d is
+        * known at compile-time. The performance of this function is
+        * not critical since it is only called at init time.
+        */
        volatile unsigned vol_d = d;
        f->integ = m / d;
        f->frac = xnarch_generic_div96by32
@@ -306,31 +277,31 @@ xnarch_generic_nodiv_imuldiv_ceil(unsigned op, const 
struct xnarch_u32frac f)
 static inline __attribute__((__const__)) unsigned long long
 xnarch_mul64by64_high(const unsigned long long op, const unsigned long long m)
 {
-    /* Compute high 64 bits of multiplication 64 bits x 64 bits. */
-    register unsigned long long t0, t1, t2, t3;
-    register unsigned oph, opl, mh, ml, t0h, t0l, t1h, t1l, t2h, t2l, t3h, t3l;
-
-    xnarch_u64tou32(op, oph, opl);
-    xnarch_u64tou32(m, mh, ml);
-    t0 = xnarch_ullmul(opl, ml);
-    xnarch_u64tou32(t0, t0h, t0l);
-    t3 = xnarch_ullmul(oph, mh);
-    xnarch_u64tou32(t3, t3h, t3l);
-    xnarch_add96and64(t3h, t3l, t0h, 0, t0l >> 31);
-    t1 = xnarch_ullmul(oph, ml);
-    xnarch_u64tou32(t1, t1h, t1l);
-    xnarch_add96and64(t3h, t3l, t0h, t1h, t1l);
-    t2 = xnarch_ullmul(opl, mh);
-    xnarch_u64tou32(t2, t2h, t2l);
-    xnarch_add96and64(t3h, t3l, t0h, t2h, t2l);
-
-    return xnarch_u64fromu32(t3h, t3l);
+       /* Compute high 64 bits of multiplication 64 bits x 64 bits. */
+       register unsigned long long t0, t1, t2, t3;
+       register unsigned int oph, opl, mh, ml, t0h, t0l, t1h, t1l, t2h, t2l, 
t3h, t3l;
+
+       xnarch_u64tou32(op, oph, opl);
+       xnarch_u64tou32(m, mh, ml);
+       t0 = xnarch_ullmul(opl, ml);
+       xnarch_u64tou32(t0, t0h, t0l);
+       t3 = xnarch_ullmul(oph, mh);
+       xnarch_u64tou32(t3, t3h, t3l);
+       xnarch_add96and64(t3h, t3l, t0h, 0, t0l >> 31);
+       t1 = xnarch_ullmul(oph, ml);
+       xnarch_u64tou32(t1, t1h, t1l);
+       xnarch_add96and64(t3h, t3l, t0h, t1h, t1l);
+       t2 = xnarch_ullmul(opl, mh);
+       xnarch_u64tou32(t2, t2h, t2l);
+       xnarch_add96and64(t3h, t3l, t0h, t2h, t2l);
+
+       return xnarch_u64fromu32(t3h, t3l);
 }
 
 static inline unsigned long long
 xnarch_generic_nodiv_ullimd(const unsigned long long op,
-                            const unsigned long long frac,
-                            unsigned integ)
+                           const unsigned long long frac,
+                           unsigned int integ)
 {
        return xnarch_mul64by64_high(op, frac) + integ * op;
 }
@@ -339,12 +310,13 @@ xnarch_generic_nodiv_ullimd(const unsigned long long op,
 
 #ifndef xnarch_nodiv_llimd
 static inline __attribute__((__const__)) long long
-xnarch_generic_nodiv_llimd(long long op, unsigned long long frac, unsigned 
integ)
+xnarch_generic_nodiv_llimd(long long op, unsigned long long frac,
+                          unsigned int integ)
 {
        long long ret;
        int sign = 0;
 
-       if(op < 0LL) {
+       if (op < 0LL) {
                sign = 1;
                op = -op;
        }
@@ -362,10 +334,12 @@ static inline void xnarch_init_llmulshft(const unsigned 
m_in,
                                         unsigned *m_out,
                                         unsigned *s_out)
 {
-       /* Avoid clever compiler optimizations to occur when d is
-          known at compile-time. The performance of this function is
-          not critical since it is only called at init time. */
-       volatile unsigned vol_d = d_in;
+       /*
+        * Avoid clever compiler optimizations to occur when d is
+        * known at compile-time. The performance of this function is
+        * not critical since it is only called at init time.
+        */
+       volatile unsigned int vol_d = d_in;
        unsigned long long mult;
 
        *s_out = 31;
@@ -376,7 +350,7 @@ static inline void xnarch_init_llmulshft(const unsigned 
m_in,
                        break;
                (*s_out)--;
        }
-       *m_out = (unsigned)mult;
+       *m_out = (unsigned int)mult;
 }
 
 #define xnarch_ullmod(ull,uld,rem)   ({ xnarch_ulldiv(ull,uld,rem); (*rem); })
@@ -388,4 +362,4 @@ static inline void xnarch_init_llmulshft(const unsigned 
m_in,
 #define xnarch_mod64(a,b)            ({ unsigned long long _rem; \
                                        xnarch_divmod64((a),(b),&_rem); _rem; })
 
-#endif /* _COBALT_ASM_GENERIC_ARITH_H */
+#endif /* _COBALT_ASM_GENERIC_UAPI_ARITH_H */
diff --git a/include/cobalt/asm-generic/uapi/features.h 
b/include/cobalt/asm-generic/uapi/features.h
index 9393ecb..c20f76e 100644
--- a/include/cobalt/asm-generic/uapi/features.h
+++ b/include/cobalt/asm-generic/uapi/features.h
@@ -15,7 +15,6 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
-
 #ifndef _COBALT_ASM_GENERIC_UAPI_FEATURES_H
 #define _COBALT_ASM_GENERIC_UAPI_FEATURES_H
 
diff --git a/include/cobalt/asm-nios2/Makefile.am 
b/include/cobalt/asm-nios2/Makefile.am
index c3e6bf3..87e8947 100644
--- a/include/cobalt/asm-nios2/Makefile.am
+++ b/include/cobalt/asm-nios2/Makefile.am
@@ -1,7 +1,6 @@
 includesubdir = $(includedir)/asm-nios2
 
 includesub_HEADERS =   \
-       arith.h         \
        calibration.h   \
        features.h      \
        fptest.h        \
diff --git a/include/cobalt/asm-nios2/Makefile.in 
b/include/cobalt/asm-nios2/Makefile.in
index 25bd4c0..d104c22 100644
--- a/include/cobalt/asm-nios2/Makefile.in
+++ b/include/cobalt/asm-nios2/Makefile.in
@@ -274,7 +274,6 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 includesubdir = $(includedir)/asm-nios2
 includesub_HEADERS = \
-       arith.h         \
        calibration.h   \
        features.h      \
        fptest.h        \
diff --git a/include/cobalt/asm-nios2/uapi/Makefile.am 
b/include/cobalt/asm-nios2/uapi/Makefile.am
index 811c460..8a3fc2a 100644
--- a/include/cobalt/asm-nios2/uapi/Makefile.am
+++ b/include/cobalt/asm-nios2/uapi/Makefile.am
@@ -1,5 +1,6 @@
 includesubdir = $(includedir)/asm-nios2/uapi
 
 includesub_HEADERS =   \
+       arith.h         \
        features.h      \
        syscall.h
diff --git a/include/cobalt/asm-nios2/uapi/Makefile.in 
b/include/cobalt/asm-nios2/uapi/Makefile.in
index 99755dc..578775a 100644
--- a/include/cobalt/asm-nios2/uapi/Makefile.in
+++ b/include/cobalt/asm-nios2/uapi/Makefile.in
@@ -274,6 +274,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 includesubdir = $(includedir)/asm-nios2/uapi
 includesub_HEADERS = \
+       arith.h         \
        features.h      \
        syscall.h
 
diff --git a/include/cobalt/asm-nios2/arith.h 
b/include/cobalt/asm-nios2/uapi/arith.h
similarity index 88%
rename from include/cobalt/asm-nios2/arith.h
rename to include/cobalt/asm-nios2/uapi/arith.h
index 7d70309..804224d 100644
--- a/include/cobalt/asm-nios2/arith.h
+++ b/include/cobalt/asm-nios2/uapi/arith.h
@@ -17,8 +17,8 @@
  * 02111-1307, USA.
  */
 
-#ifndef _COBALT_ASM_NIOS2_ARITH_H
-#define _COBALT_ASM_NIOS2_ARITH_H
+#ifndef _COBALT_ASM_NIOS2_UAPI_ARITH_H
+#define _COBALT_ASM_NIOS2_UAPI_ARITH_H
 
 #include <asm/xenomai/uapi/features.h>
 
@@ -37,6 +37,6 @@
                         : "r8", "r9");                                 \
        } while (0);
 
-#include <asm-generic/xenomai/arith.h>
+#include <asm-generic/xenomai/uapi/arith.h>
 
-#endif /* _COBALT_ASM_NIOS2_ARITH_H */
+#endif /* _COBALT_ASM_NIOS2_UAPI_ARITH_H */
diff --git a/include/cobalt/asm-powerpc/Makefile.am 
b/include/cobalt/asm-powerpc/Makefile.am
index a2b6850..07cbf02 100644
--- a/include/cobalt/asm-powerpc/Makefile.am
+++ b/include/cobalt/asm-powerpc/Makefile.am
@@ -1,7 +1,6 @@
 includesubdir = $(includedir)/asm-powerpc
 
 includesub_HEADERS =   \
-       arith.h         \
        calibration.h   \
        features.h      \
        fptest.h        \
diff --git a/include/cobalt/asm-powerpc/Makefile.in 
b/include/cobalt/asm-powerpc/Makefile.in
index 55f42db..4cd697d 100644
--- a/include/cobalt/asm-powerpc/Makefile.in
+++ b/include/cobalt/asm-powerpc/Makefile.in
@@ -312,7 +312,6 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 includesubdir = $(includedir)/asm-powerpc
 includesub_HEADERS = \
-       arith.h         \
        calibration.h   \
        features.h      \
        fptest.h        \
diff --git a/include/cobalt/asm-powerpc/uapi/Makefile.am 
b/include/cobalt/asm-powerpc/uapi/Makefile.am
index 5633850..788d155 100644
--- a/include/cobalt/asm-powerpc/uapi/Makefile.am
+++ b/include/cobalt/asm-powerpc/uapi/Makefile.am
@@ -1,6 +1,7 @@
 includesubdir = $(includedir)/asm-powerpc/uapi
 
 includesub_HEADERS =   \
+       arith.h         \
        features.h      \
        syscall.h       \
        features.h
diff --git a/include/cobalt/asm-powerpc/uapi/Makefile.in 
b/include/cobalt/asm-powerpc/uapi/Makefile.in
index 5716527..860c0dc 100644
--- a/include/cobalt/asm-powerpc/uapi/Makefile.in
+++ b/include/cobalt/asm-powerpc/uapi/Makefile.in
@@ -274,6 +274,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 includesubdir = $(includedir)/asm-powerpc/uapi
 includesub_HEADERS = \
+       arith.h         \
        features.h      \
        syscall.h       \
        features.h
diff --git a/include/cobalt/asm-powerpc/arith.h 
b/include/cobalt/asm-powerpc/uapi/arith.h
similarity index 91%
rename from include/cobalt/asm-powerpc/arith.h
rename to include/cobalt/asm-powerpc/uapi/arith.h
index 379924e..f4dbc52 100644
--- a/include/cobalt/asm-powerpc/arith.h
+++ b/include/cobalt/asm-powerpc/uapi/arith.h
@@ -15,9 +15,8 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
-
-#ifndef _COBALT_ASM_POWERPC_ARITH_H
-#define _COBALT_ASM_POWERPC_ARITH_H
+#ifndef _COBALT_ASM_POWERPC_UAPI_ARITH_H
+#define _COBALT_ASM_POWERPC_UAPI_ARITH_H
 
 #include <asm/xenomai/uapi/features.h>
 
@@ -62,6 +61,6 @@ mach_powerpc_nodiv_ullimd(const unsigned long long op,
 
 #endif /* !__powerpc64__ */
 
-#include <asm-generic/xenomai/arith.h>
+#include <asm-generic/xenomai/uapi/arith.h>
 
-#endif /* _COBALT_ASM_POWERPC_ARITH_H */
+#endif /* _COBALT_ASM_POWERPC_UAPI_ARITH_H */
diff --git a/include/cobalt/asm-sh/Makefile.am 
b/include/cobalt/asm-sh/Makefile.am
index 42e7fc9..4b0dc3e 100644
--- a/include/cobalt/asm-sh/Makefile.am
+++ b/include/cobalt/asm-sh/Makefile.am
@@ -1,7 +1,6 @@
 includesubdir = $(includedir)/asm-sh
 
 includesub_HEADERS =   \
-       arith.h         \
        calibration.h   \
        features.h      \
        fptest.h        \
diff --git a/include/cobalt/asm-sh/Makefile.in 
b/include/cobalt/asm-sh/Makefile.in
index d8da5fe..3e1da6b 100644
--- a/include/cobalt/asm-sh/Makefile.in
+++ b/include/cobalt/asm-sh/Makefile.in
@@ -312,7 +312,6 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 includesubdir = $(includedir)/asm-sh
 includesub_HEADERS = \
-       arith.h         \
        calibration.h   \
        features.h      \
        fptest.h        \
diff --git a/include/cobalt/asm-sh/uapi/Makefile.am 
b/include/cobalt/asm-sh/uapi/Makefile.am
index cb19333..4362d26 100644
--- a/include/cobalt/asm-sh/uapi/Makefile.am
+++ b/include/cobalt/asm-sh/uapi/Makefile.am
@@ -1,5 +1,6 @@
 includesubdir = $(includedir)/asm-sh/uapi
 
 includesub_HEADERS =   \
+       arith.h         \
        features.h      \
        syscall.h
diff --git a/include/cobalt/asm-sh/uapi/Makefile.in 
b/include/cobalt/asm-sh/uapi/Makefile.in
index 4a1913e..ac581d8 100644
--- a/include/cobalt/asm-sh/uapi/Makefile.in
+++ b/include/cobalt/asm-sh/uapi/Makefile.in
@@ -274,6 +274,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 includesubdir = $(includedir)/asm-sh/uapi
 includesub_HEADERS = \
+       arith.h         \
        features.h      \
        syscall.h
 
diff --git a/include/cobalt/asm-sh/arith.h b/include/cobalt/asm-sh/uapi/arith.h
similarity index 87%
rename from include/cobalt/asm-sh/arith.h
rename to include/cobalt/asm-sh/uapi/arith.h
index 93f9c86..3ef2222 100644
--- a/include/cobalt/asm-sh/arith.h
+++ b/include/cobalt/asm-sh/uapi/arith.h
@@ -16,9 +16,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  * 02111-1307, USA.
  */
-
-#ifndef _COBALT_ASM_SH_ARITH_H
-#define _COBALT_ASM_SH_ARITH_H
+#ifndef _COBALT_ASM_SH_UAPI_ARITH_H
+#define _COBALT_ASM_SH_UAPI_ARITH_H
 
 #include <asm/xenomai/uapi/features.h>
 
@@ -32,6 +31,6 @@
                         : "r"(s0), "r"(s1), "r" (0) : "t");    \
        } while (0)
 
-#include <asm-generic/xenomai/arith.h>
+#include <asm-generic/xenomai/uapi/arith.h>
 
-#endif /* _COBALT_ASM_SH_ARITH_H */
+#endif /* _COBALT_ASM_SH_UAPI_ARITH_H */
diff --git a/include/cobalt/asm-x86/Makefile.am 
b/include/cobalt/asm-x86/Makefile.am
index 515f347..5c98444 100644
--- a/include/cobalt/asm-x86/Makefile.am
+++ b/include/cobalt/asm-x86/Makefile.am
@@ -1,7 +1,6 @@
 includesubdir = $(includedir)/asm-x86
 
 includesub_HEADERS =   \
-       arith.h         \
        calibration.h   \
        features.h      \
        fptest.h        \
diff --git a/include/cobalt/asm-x86/Makefile.in 
b/include/cobalt/asm-x86/Makefile.in
index ca27de2..85e9715 100644
--- a/include/cobalt/asm-x86/Makefile.in
+++ b/include/cobalt/asm-x86/Makefile.in
@@ -312,7 +312,6 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 includesubdir = $(includedir)/asm-x86
 includesub_HEADERS = \
-       arith.h         \
        calibration.h   \
        features.h      \
        fptest.h        \
diff --git a/include/cobalt/asm-x86/uapi/Makefile.am 
b/include/cobalt/asm-x86/uapi/Makefile.am
index 231f511..51dfb2f 100644
--- a/include/cobalt/asm-x86/uapi/Makefile.am
+++ b/include/cobalt/asm-x86/uapi/Makefile.am
@@ -1,5 +1,6 @@
 includesubdir = $(includedir)/asm-x86/uapi
 
 includesub_HEADERS =   \
+       arith.h         \
        features.h      \
        syscall.h
diff --git a/include/cobalt/asm-x86/uapi/Makefile.in 
b/include/cobalt/asm-x86/uapi/Makefile.in
index d501408..58ce511 100644
--- a/include/cobalt/asm-x86/uapi/Makefile.in
+++ b/include/cobalt/asm-x86/uapi/Makefile.in
@@ -274,6 +274,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 includesubdir = $(includedir)/asm-x86/uapi
 includesub_HEADERS = \
+       arith.h         \
        features.h      \
        syscall.h
 
diff --git a/include/cobalt/asm-x86/arith.h 
b/include/cobalt/asm-x86/uapi/arith.h
similarity index 97%
rename from include/cobalt/asm-x86/arith.h
rename to include/cobalt/asm-x86/uapi/arith.h
index d9f6a77..af883a3 100644
--- a/include/cobalt/asm-x86/arith.h
+++ b/include/cobalt/asm-x86/uapi/arith.h
@@ -21,9 +21,9 @@
  *   02111-1307, USA.
  */
 
-#ifndef _COBALT_ASM_X86_ARITH_H
-#define _COBALT_ASM_X86_ARITH_H
-#define _COBALT_ASM_X86_ARITH_H
+#ifndef _COBALT_ASM_X86_UAPI_ARITH_H
+#define _COBALT_ASM_X86_UAPI_ARITH_H
+#define _COBALT_ASM_X86_UAPI_ARITH_H
 
 #include <asm/xenomai/uapi/features.h>
 
@@ -241,6 +241,6 @@ mach_x86_64_nodiv_ullimd(unsigned long long op,
 
 #endif /* x86_64 */
 
-#include <asm-generic/xenomai/arith.h>
+#include <asm-generic/xenomai/uapi/arith.h>
 
-#endif /* _COBALT_ASM_X86_ARITH_H */
+#endif /* _COBALT_ASM_X86_UAPI_ARITH_H */
diff --git a/include/cobalt/kernel/Makefile.am 
b/include/cobalt/kernel/Makefile.am
index 540e02c..f49b6f2 100644
--- a/include/cobalt/kernel/Makefile.am
+++ b/include/cobalt/kernel/Makefile.am
@@ -1,6 +1,7 @@
 
 noinst_HEADERS =       \
        apc.h           \
+       arith.h         \
        assert.h        \
        bheap.h         \
        bufd.h          \
diff --git a/include/cobalt/kernel/Makefile.in 
b/include/cobalt/kernel/Makefile.in
index 9f11791..1d95b51 100644
--- a/include/cobalt/kernel/Makefile.in
+++ b/include/cobalt/kernel/Makefile.in
@@ -246,6 +246,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 noinst_HEADERS = \
        apc.h           \
+       arith.h         \
        assert.h        \
        bheap.h         \
        bufd.h          \
diff --git a/include/cobalt/kernel/arith.h b/include/cobalt/kernel/arith.h
new file mode 100644
index 0000000..0ce9e91
--- /dev/null
+++ b/include/cobalt/kernel/arith.h
@@ -0,0 +1,35 @@
+/**
+ *   Generic arithmetic/conversion routines.
+ *   Copyright &copy; 2005 Stelian Pop.
+ *   Copyright &copy; 2005 Gilles Chanteperdrix.
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
+ *   USA; either version 2 of the License, or (at your option) any later
+ *   version.
+ *
+ *   This program 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 General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+#ifndef _COBALT_KERNEL_ARITH_H
+#define _COBALT_KERNEL_ARITH_H
+
+#include <asm/byteorder.h>
+#include <asm/div64.h>
+
+#ifdef __BIG_ENDIAN
+#define endianstruct { unsigned int _h; unsigned int _l; }
+#else /* __LITTLE_ENDIAN */
+#define endianstruct { unsigned int _l; unsigned int _h; }
+#endif
+
+#include <asm/xenomai/uapi/arith.h>
+
+#endif /* _COBALT_KERNEL_ARITH_H */
diff --git a/kernel/cobalt/arch/arm/machine.c b/kernel/cobalt/arch/arm/machine.c
index 9938ab4..0293366 100644
--- a/kernel/cobalt/arch/arm/machine.c
+++ b/kernel/cobalt/arch/arm/machine.c
@@ -19,9 +19,9 @@
  */
 
 #include <linux/mm.h>
+#include <cobalt/kernel/arith.h>
 #include <asm/cacheflush.h>
 #include <asm/xenomai/machine.h>
-#include <asm/xenomai/arith.h>
 
 struct xnarch_u32frac mach_arm_tsc_to_timer;
 
diff --git a/kernel/cobalt/arch/x86/machine.c b/kernel/cobalt/arch/x86/machine.c
index 0b6bff2..855cdab 100644
--- a/kernel/cobalt/arch/x86/machine.c
+++ b/kernel/cobalt/arch/x86/machine.c
@@ -18,8 +18,8 @@
  *   02111-1307, USA.
  */
 
+#include <cobalt/kernel/arith.h>
 #include <asm/xenomai/machine.h>
-#include <asm/xenomai/arith.h>
 #include <asm/xenomai/smi.h>
 
 #ifdef __i386__
diff --git a/kernel/cobalt/clock.c b/kernel/cobalt/clock.c
index 16d1dc5..556fb4e 100644
--- a/kernel/cobalt/clock.c
+++ b/kernel/cobalt/clock.c
@@ -29,7 +29,7 @@
 #include <cobalt/kernel/pod.h>
 #include <cobalt/kernel/timer.h>
 #include <cobalt/kernel/clock.h>
-#include <asm/xenomai/arith.h>
+#include <cobalt/kernel/arith.h>
 
 static unsigned long long clockfreq;
 
diff --git a/kernel/cobalt/posix/clock.c b/kernel/cobalt/posix/clock.c
index 112e342..29dcd05 100644
--- a/kernel/cobalt/posix/clock.c
+++ b/kernel/cobalt/posix/clock.c
@@ -49,7 +49,6 @@
  *@{*/
 
 #include <cobalt/kernel/vdso.h>
-#include <asm/xenomai/arith.h>
 #include "internal.h"
 #include "thread.h"
 #include "clock.h"
diff --git a/kernel/cobalt/posix/internal.h b/kernel/cobalt/posix/internal.h
index 6c20531..8b72fac 100644
--- a/kernel/cobalt/posix/internal.h
+++ b/kernel/cobalt/posix/internal.h
@@ -25,9 +25,9 @@
 #include <cobalt/kernel/select.h>
 #include <cobalt/kernel/assert.h>
 #include <cobalt/kernel/list.h>
+#include <cobalt/kernel/arith.h>
 #include <cobalt/uapi/syscall.h>
 #include <asm/xenomai/syscall.h>
-#include <asm/xenomai/arith.h>
 #include "registry.h"
 
 #ifndef CONFIG_XENO_OPT_DEBUG_COBALT
diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index 09dfe83..f8df929 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -27,7 +27,7 @@
 #include <cobalt/kernel/intr.h>
 #include <cobalt/kernel/heap.h>
 #include <cobalt/kernel/shadow.h>
-#include <asm/xenomai/arith.h>
+#include <cobalt/kernel/arith.h>
 #include <asm/xenomai/thread.h>
 
 static struct xnsched_class *xnsched_class_highest;
diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c
index 3183ace..3823bc6 100644
--- a/kernel/cobalt/timer.c
+++ b/kernel/cobalt/timer.c
@@ -44,7 +44,7 @@
 #include <cobalt/kernel/intr.h>
 #include <cobalt/kernel/clock.h>
 #include <cobalt/kernel/trace.h>
-#include <asm/xenomai/arith.h>
+#include <cobalt/kernel/arith.h>
 
 static inline void xntimer_enqueue(xntimer_t *timer)
 {
diff --git a/kernel/drivers/ipc/internal.h b/kernel/drivers/ipc/internal.h
index da7549f..4aca153 100644
--- a/kernel/drivers/ipc/internal.h
+++ b/kernel/drivers/ipc/internal.h
@@ -22,7 +22,7 @@
 #define _RTIPC_INTERNAL_H
 
 #include <cobalt/kernel/registry.h>
-#include <asm/xenomai/arith.h>
+#include <cobalt/kernel/clock.h>
 #include <rtdm/rtdm.h>
 #include <rtdm/rtdm_driver.h>
 
diff --git a/kernel/drivers/testing/timerbench.c 
b/kernel/drivers/testing/timerbench.c
index 77282c8..604a138 100644
--- a/kernel/drivers/testing/timerbench.c
+++ b/kernel/drivers/testing/timerbench.c
@@ -17,11 +17,8 @@
  */
 
 #include <linux/module.h>
-#ifdef CONFIG_IPIPE_TRACE
 #include <linux/ipipe_trace.h>
-#endif /* CONFIG_IPIPE_TRACE */
-
-#include <asm/xenomai/arith.h>
+#include <cobalt/kernel/arith.h>
 #include <rtdm/rttesting.h>
 #include <rtdm/rtdm_driver.h>
 
diff --git a/lib/cobalt/ticks.c b/lib/cobalt/ticks.c
index b683c35..fda63f0 100644
--- a/lib/cobalt/ticks.c
+++ b/lib/cobalt/ticks.c
@@ -15,7 +15,7 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
  */
-#include <asm/xenomai/arith.h>
+#include <cobalt/arith.h>
 #include <cobalt/ticks.h>
 
 static unsigned long long clockfreq;
diff --git a/lib/copperplate/clockobj.c b/lib/copperplate/clockobj.c
index 766d418..05a14db 100644
--- a/lib/copperplate/clockobj.c
+++ b/lib/copperplate/clockobj.c
@@ -282,7 +282,7 @@ int clockobj_set_resolution(struct clockobj *clkobj, 
unsigned int resolution_ns)
 
 #ifdef CONFIG_XENO_COBALT
 
-#include <asm/xenomai/arith.h>
+#include <cobalt/arith.h>
 
 #ifndef CONFIG_XENO_LORES_CLOCK_DISABLED
 
diff --git a/testsuite/unit/arith-noinline.c b/testsuite/unit/arith-noinline.c
index 2723173..abe402d 100644
--- a/testsuite/unit/arith-noinline.c
+++ b/testsuite/unit/arith-noinline.c
@@ -1,7 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <asm/xenomai/arith.h>
+#include <cobalt/arith.h>
 
 long long dummy(void)
 {
diff --git a/testsuite/unit/arith.c b/testsuite/unit/arith.c
index df2516a..8c5674e 100644
--- a/testsuite/unit/arith.c
+++ b/testsuite/unit/arith.c
@@ -3,7 +3,7 @@
 
 #include <alchemy/timer.h>
 
-#include <asm/xenomai/arith.h>
+#include <cobalt/arith.h>
 
 #include "arith-noinline.h"
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to