Re: [Xenomai-core] [patch] factoring arithmetic routines.
Gilles Chanteperdrix wrote: Gilles Chanteperdrix wrote: > > Hi, > > For your review, here is an attempt to factor arithmetic routines in > asm-generic/hal.h. And with the blackfin architecture... Applied, thanks. ___ Xenomai-core mailing list Xenomai-core@gna.org https://mail.gna.org/listinfo/xenomai-core -- Philippe.
Re: [Xenomai-core] [patch] factoring arithmetic routines.
Gilles Chanteperdrix wrote: Gilles Chanteperdrix wrote: > > Hi, > > For your review, here is an attempt to factor arithmetic routines in > asm-generic/hal.h. And with the blackfin architecture... Applied, thanks. ___ Xenomai-core mailing list Xenomai-core@gna.org https://mail.gna.org/listinfo/xenomai-core -- Philippe. ___ Xenomai-core mailing list Xenomai-core@gna.org https://mail.gna.org/listinfo/xenomai-core
Re: [Xenomai-core] [patch] factoring arithmetic routines.
Gilles Chanteperdrix wrote: Hi, For your review, here is an attempt to factor arithmetic routines in asm-generic/hal.h. I am not sure the way I did it is the best one. Maybe defining some HAVE_ARCH symbols, would have been better. Maybe moving the definitions in asm-generic/system.h would have been better than the #defines before #include for side effects. I am not to pleased with the double definition of div96by32 either. Please feel free to comment, insult, etc... Queued for -rc3, froggie, etc... Index: include/asm-arm/hal.h === --- include/asm-arm/hal.h (revision 453) +++ include/asm-arm/hal.h (working copy) @@ -29,12 +29,6 @@ #ifndef _XENO_ASM_ARM_HAL_H #define _XENO_ASM_ARM_HAL_H -#include /* Read the generic bits. */ -#include -#include - -typedef unsigned long long rthal_time_t; - #ifdef __BIG_ENDIAN #define endianstruct struct { u_long _h; u_long _l; } _s #else /* __LITTLE_ENDIAN */ @@ -50,72 +44,12 @@ (l) = _u._s._l; \ }) -#define __rthal_u64fromu32(h, l) ({ \ -union { unsigned long long _ull;\ -endianstruct; \ -} _u; \ -_u._s._h = (h); \ -_u._s._l = (l); \ -_u._ull;\ -}) +#include /* Read the generic bits. */ +#include +#include -static inline unsigned long long rthal_ullmul(const unsigned long m0, - const unsigned long m1) -{ -return (unsigned long long) m0 * m1; -} +typedef unsigned long long rthal_time_t; -static inline unsigned long long rthal_ulldiv (unsigned long long ull, - const unsigned long uld, - unsigned long *const rp) -{ -unsigned long r = do_div(ull, uld); - -if (rp) - *rp = r; - -return ull; -} - -#define rthal_uldivrem(ull,ul,rp) ((u_long) rthal_ulldiv((ull),(ul),(rp))) - -static inline int rthal_imuldiv (int i, int mult, int div) { - -/* Returns (int)i = (unsigned long long)i*(u_long)(mult)/(u_long)div. */ -const unsigned long long ull = rthal_ullmul(i, mult); -return rthal_uldivrem(ull, div, NULL); -} - -static inline __attribute_const__ -unsigned long long __rthal_ullimd (const unsigned long long op, - const unsigned long m, - const unsigned long d) -{ -u_long oph, opl, tlh, tll, qh, rh, ql; -unsigned long long th, tl; - -__rthal_u64tou32(op, oph, opl); -tl = rthal_ullmul(opl, m); -__rthal_u64tou32(tl, tlh, tll); -th = rthal_ullmul(oph, m); -th += tlh; - -qh = rthal_uldivrem(th, d, &rh); -th = __rthal_u64fromu32(rh, tll); -ql = rthal_uldivrem(th, d, NULL); -return __rthal_u64fromu32(qh, ql); -} - -static inline long long rthal_llimd (long long op, - unsigned long m, - unsigned long d) -{ - -if(op < 0LL) -return -__rthal_ullimd(-op, m, d); -return __rthal_ullimd(op, m, d); -} - #if __LINUX_ARM_ARCH__ < 5 static inline __attribute_const__ unsigned long ffnz (unsigned long x) { int r = 0; Index: include/asm-generic/hal.h === --- include/asm-generic/hal.h (revision 453) +++ include/asm-generic/hal.h (working copy) @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include #define RTHAL_DOMAIN_ID 0x58454e4f @@ -278,6 +280,124 @@ #define rthal_printk printk +#ifdef __BIG_ENDIAN +#define endianstruct struct { u_long _h; u_long _l; } _s +#else /* __LITTLE_ENDIAN */ +#define endianstruct struct { u_long _l; u_long _h; } _s +#endif + +#ifndef __rthal_u64tou32 +#define __rthal_u64tou32(ull, h, l) ({ \ +union { unsigned long long _ull;\ +endianstruct; \ +} _u; \ +_u._ull = (ull);\ +(h) = _u._s._h; \ +(l) = _u._s._l; \ +}) +#endif /* !__rthal_u64tou32 */ + +#ifndef __rthal_u64fromu32 +#define __rthal_u64fromu32(h, l) ({ \ +union { unsigned long long _ull;\ +endianstruct; \ +} _u; \ +_u._s._h = (h); \ +_u._s._l = (l); \ +_u._ull;\ +}) +#endif /* !__rthal_u64fromu32 */ + +#ifndef rthal_ullmul +static inline __attribute_const__ unsigned long long +__rthal_generic_ullmul(const unsigned m0, const un
Re: [Xenomai-core] [patch] factoring arithmetic routines.
Gilles Chanteperdrix wrote: > > Hi, > > For your review, here is an attempt to factor arithmetic routines in > asm-generic/hal.h. And with the blackfin architecture... -- Gilles Chanteperdrix. xeno-arith.diff Description: Binary data
[Xenomai-core] [patch] factoring arithmetic routines.
Hi, For your review, here is an attempt to factor arithmetic routines in asm-generic/hal.h. I am not sure the way I did it is the best one. Maybe defining some HAVE_ARCH symbols, would have been better. Maybe moving the definitions in asm-generic/system.h would have been better than the #defines before #include for side effects. I am not to pleased with the double definition of div96by32 either. Please feel free to comment, insult, etc... -- Gilles Chanteperdrix. Index: include/asm-arm/hal.h === --- include/asm-arm/hal.h (revision 453) +++ include/asm-arm/hal.h (working copy) @@ -29,12 +29,6 @@ #ifndef _XENO_ASM_ARM_HAL_H #define _XENO_ASM_ARM_HAL_H -#include/* Read the generic bits. */ -#include -#include - -typedef unsigned long long rthal_time_t; - #ifdef __BIG_ENDIAN #define endianstruct struct { u_long _h; u_long _l; } _s #else /* __LITTLE_ENDIAN */ @@ -50,72 +44,12 @@ (l) = _u._s._l; \ }) -#define __rthal_u64fromu32(h, l) ({ \ -union { unsigned long long _ull;\ -endianstruct; \ -} _u; \ -_u._s._h = (h); \ -_u._s._l = (l); \ -_u._ull;\ -}) +#include/* Read the generic bits. */ +#include +#include -static inline unsigned long long rthal_ullmul(const unsigned long m0, - const unsigned long m1) -{ -return (unsigned long long) m0 * m1; -} +typedef unsigned long long rthal_time_t; -static inline unsigned long long rthal_ulldiv (unsigned long long ull, - const unsigned long uld, - unsigned long *const rp) -{ -unsigned long r = do_div(ull, uld); - -if (rp) - *rp = r; - -return ull; -} - -#define rthal_uldivrem(ull,ul,rp) ((u_long) rthal_ulldiv((ull),(ul),(rp))) - -static inline int rthal_imuldiv (int i, int mult, int div) { - -/* Returns (int)i = (unsigned long long)i*(u_long)(mult)/(u_long)div. */ -const unsigned long long ull = rthal_ullmul(i, mult); -return rthal_uldivrem(ull, div, NULL); -} - -static inline __attribute_const__ -unsigned long long __rthal_ullimd (const unsigned long long op, - const unsigned long m, - const unsigned long d) -{ -u_long oph, opl, tlh, tll, qh, rh, ql; -unsigned long long th, tl; - -__rthal_u64tou32(op, oph, opl); -tl = rthal_ullmul(opl, m); -__rthal_u64tou32(tl, tlh, tll); -th = rthal_ullmul(oph, m); -th += tlh; - -qh = rthal_uldivrem(th, d, &rh); -th = __rthal_u64fromu32(rh, tll); -ql = rthal_uldivrem(th, d, NULL); -return __rthal_u64fromu32(qh, ql); -} - -static inline long long rthal_llimd (long long op, - unsigned long m, - unsigned long d) -{ - -if(op < 0LL) -return -__rthal_ullimd(-op, m, d); -return __rthal_ullimd(op, m, d); -} - #if __LINUX_ARM_ARCH__ < 5 static inline __attribute_const__ unsigned long ffnz (unsigned long x) { int r = 0; Index: include/asm-generic/hal.h === --- include/asm-generic/hal.h (revision 453) +++ include/asm-generic/hal.h (working copy) @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include #define RTHAL_DOMAIN_ID0x58454e4f @@ -278,6 +280,124 @@ #define rthal_printk printk +#ifdef __BIG_ENDIAN +#define endianstruct struct { u_long _h; u_long _l; } _s +#else /* __LITTLE_ENDIAN */ +#define endianstruct struct { u_long _l; u_long _h; } _s +#endif + +#ifndef __rthal_u64tou32 +#define __rthal_u64tou32(ull, h, l) ({ \ +union { unsigned long long _ull;\ +endianstruct; \ +} _u; \ +_u._ull = (ull);\ +(h) = _u._s._h; \ +(l) = _u._s._l; \ +}) +#endif /* !__rthal_u64tou32 */ + +#ifndef __rthal_u64fromu32 +#define __rthal_u64fromu32(h, l) ({ \ +union { unsigned long long _ull;\ +endianstruct; \ +} _u; \ +_u._s._h = (h); \ +_u._s._l = (l); \ +_u._ull;\ +}) +#endif /* !__rthal_u64fromu32 */ + +#ifndef rthal_ullmul +static inline __attribute_const__ unsigned long long +__rthal_generic_ullmul(const unsigned m0, const unsigned m1) +{ +return (unsigned long long) m0 * m1; +} +
Re: [Xenomai-core] [patch] factoring arithmetic routines.
Gilles Chanteperdrix wrote: Hi, For your review, here is an attempt to factor arithmetic routines in asm-generic/hal.h. I am not sure the way I did it is the best one. Maybe defining some HAVE_ARCH symbols, would have been better. Maybe moving the definitions in asm-generic/system.h would have been better than the #defines before #include for side effects. I am not to pleased with the double definition of div96by32 either. Please feel free to comment, insult, etc... Queued for -rc3, froggie, etc... Index: include/asm-arm/hal.h === --- include/asm-arm/hal.h (revision 453) +++ include/asm-arm/hal.h (working copy) @@ -29,12 +29,6 @@ #ifndef _XENO_ASM_ARM_HAL_H #define _XENO_ASM_ARM_HAL_H -#include /* Read the generic bits. */ -#include -#include - -typedef unsigned long long rthal_time_t; - #ifdef __BIG_ENDIAN #define endianstruct struct { u_long _h; u_long _l; } _s #else /* __LITTLE_ENDIAN */ @@ -50,72 +44,12 @@ (l) = _u._s._l; \ }) -#define __rthal_u64fromu32(h, l) ({ \ -union { unsigned long long _ull;\ -endianstruct; \ -} _u; \ -_u._s._h = (h); \ -_u._s._l = (l); \ -_u._ull;\ -}) +#include /* Read the generic bits. */ +#include +#include -static inline unsigned long long rthal_ullmul(const unsigned long m0, - const unsigned long m1) -{ -return (unsigned long long) m0 * m1; -} +typedef unsigned long long rthal_time_t; -static inline unsigned long long rthal_ulldiv (unsigned long long ull, - const unsigned long uld, - unsigned long *const rp) -{ -unsigned long r = do_div(ull, uld); - -if (rp) - *rp = r; - -return ull; -} - -#define rthal_uldivrem(ull,ul,rp) ((u_long) rthal_ulldiv((ull),(ul),(rp))) - -static inline int rthal_imuldiv (int i, int mult, int div) { - -/* Returns (int)i = (unsigned long long)i*(u_long)(mult)/(u_long)div. */ -const unsigned long long ull = rthal_ullmul(i, mult); -return rthal_uldivrem(ull, div, NULL); -} - -static inline __attribute_const__ -unsigned long long __rthal_ullimd (const unsigned long long op, - const unsigned long m, - const unsigned long d) -{ -u_long oph, opl, tlh, tll, qh, rh, ql; -unsigned long long th, tl; - -__rthal_u64tou32(op, oph, opl); -tl = rthal_ullmul(opl, m); -__rthal_u64tou32(tl, tlh, tll); -th = rthal_ullmul(oph, m); -th += tlh; - -qh = rthal_uldivrem(th, d, &rh); -th = __rthal_u64fromu32(rh, tll); -ql = rthal_uldivrem(th, d, NULL); -return __rthal_u64fromu32(qh, ql); -} - -static inline long long rthal_llimd (long long op, - unsigned long m, - unsigned long d) -{ - -if(op < 0LL) -return -__rthal_ullimd(-op, m, d); -return __rthal_ullimd(op, m, d); -} - #if __LINUX_ARM_ARCH__ < 5 static inline __attribute_const__ unsigned long ffnz (unsigned long x) { int r = 0; Index: include/asm-generic/hal.h === --- include/asm-generic/hal.h (revision 453) +++ include/asm-generic/hal.h (working copy) @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include #define RTHAL_DOMAIN_ID 0x58454e4f @@ -278,6 +280,124 @@ #define rthal_printk printk +#ifdef __BIG_ENDIAN +#define endianstruct struct { u_long _h; u_long _l; } _s +#else /* __LITTLE_ENDIAN */ +#define endianstruct struct { u_long _l; u_long _h; } _s +#endif + +#ifndef __rthal_u64tou32 +#define __rthal_u64tou32(ull, h, l) ({ \ +union { unsigned long long _ull;\ +endianstruct; \ +} _u; \ +_u._ull = (ull);\ +(h) = _u._s._h; \ +(l) = _u._s._l; \ +}) +#endif /* !__rthal_u64tou32 */ + +#ifndef __rthal_u64fromu32 +#define __rthal_u64fromu32(h, l) ({ \ +union { unsigned long long _ull;\ +endianstruct; \ +} _u; \ +_u._s._h = (h); \ +_u._s._l = (l); \ +_u._ull;\ +}) +#endif /* !__rthal_u64fromu32 */ + +#ifndef rthal_ullmul +static inline __attribute_const__ unsigned long long +__rthal_generic_ullmul(const unsigned m0, const un
Re: [Xenomai-core] [patch] factoring arithmetic routines.
Gilles Chanteperdrix wrote: > > Hi, > > For your review, here is an attempt to factor arithmetic routines in > asm-generic/hal.h. And with the blackfin architecture... -- Gilles Chanteperdrix. xeno-arith.diff Description: Binary data ___ Xenomai-core mailing list Xenomai-core@gna.org https://mail.gna.org/listinfo/xenomai-core
[Xenomai-core] [patch] factoring arithmetic routines.
Hi, For your review, here is an attempt to factor arithmetic routines in asm-generic/hal.h. I am not sure the way I did it is the best one. Maybe defining some HAVE_ARCH symbols, would have been better. Maybe moving the definitions in asm-generic/system.h would have been better than the #defines before #include for side effects. I am not to pleased with the double definition of div96by32 either. Please feel free to comment, insult, etc... -- Gilles Chanteperdrix. Index: include/asm-arm/hal.h === --- include/asm-arm/hal.h (revision 453) +++ include/asm-arm/hal.h (working copy) @@ -29,12 +29,6 @@ #ifndef _XENO_ASM_ARM_HAL_H #define _XENO_ASM_ARM_HAL_H -#include/* Read the generic bits. */ -#include -#include - -typedef unsigned long long rthal_time_t; - #ifdef __BIG_ENDIAN #define endianstruct struct { u_long _h; u_long _l; } _s #else /* __LITTLE_ENDIAN */ @@ -50,72 +44,12 @@ (l) = _u._s._l; \ }) -#define __rthal_u64fromu32(h, l) ({ \ -union { unsigned long long _ull;\ -endianstruct; \ -} _u; \ -_u._s._h = (h); \ -_u._s._l = (l); \ -_u._ull;\ -}) +#include/* Read the generic bits. */ +#include +#include -static inline unsigned long long rthal_ullmul(const unsigned long m0, - const unsigned long m1) -{ -return (unsigned long long) m0 * m1; -} +typedef unsigned long long rthal_time_t; -static inline unsigned long long rthal_ulldiv (unsigned long long ull, - const unsigned long uld, - unsigned long *const rp) -{ -unsigned long r = do_div(ull, uld); - -if (rp) - *rp = r; - -return ull; -} - -#define rthal_uldivrem(ull,ul,rp) ((u_long) rthal_ulldiv((ull),(ul),(rp))) - -static inline int rthal_imuldiv (int i, int mult, int div) { - -/* Returns (int)i = (unsigned long long)i*(u_long)(mult)/(u_long)div. */ -const unsigned long long ull = rthal_ullmul(i, mult); -return rthal_uldivrem(ull, div, NULL); -} - -static inline __attribute_const__ -unsigned long long __rthal_ullimd (const unsigned long long op, - const unsigned long m, - const unsigned long d) -{ -u_long oph, opl, tlh, tll, qh, rh, ql; -unsigned long long th, tl; - -__rthal_u64tou32(op, oph, opl); -tl = rthal_ullmul(opl, m); -__rthal_u64tou32(tl, tlh, tll); -th = rthal_ullmul(oph, m); -th += tlh; - -qh = rthal_uldivrem(th, d, &rh); -th = __rthal_u64fromu32(rh, tll); -ql = rthal_uldivrem(th, d, NULL); -return __rthal_u64fromu32(qh, ql); -} - -static inline long long rthal_llimd (long long op, - unsigned long m, - unsigned long d) -{ - -if(op < 0LL) -return -__rthal_ullimd(-op, m, d); -return __rthal_ullimd(op, m, d); -} - #if __LINUX_ARM_ARCH__ < 5 static inline __attribute_const__ unsigned long ffnz (unsigned long x) { int r = 0; Index: include/asm-generic/hal.h === --- include/asm-generic/hal.h (revision 453) +++ include/asm-generic/hal.h (working copy) @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include #define RTHAL_DOMAIN_ID0x58454e4f @@ -278,6 +280,124 @@ #define rthal_printk printk +#ifdef __BIG_ENDIAN +#define endianstruct struct { u_long _h; u_long _l; } _s +#else /* __LITTLE_ENDIAN */ +#define endianstruct struct { u_long _l; u_long _h; } _s +#endif + +#ifndef __rthal_u64tou32 +#define __rthal_u64tou32(ull, h, l) ({ \ +union { unsigned long long _ull;\ +endianstruct; \ +} _u; \ +_u._ull = (ull);\ +(h) = _u._s._h; \ +(l) = _u._s._l; \ +}) +#endif /* !__rthal_u64tou32 */ + +#ifndef __rthal_u64fromu32 +#define __rthal_u64fromu32(h, l) ({ \ +union { unsigned long long _ull;\ +endianstruct; \ +} _u; \ +_u._s._h = (h); \ +_u._s._l = (l); \ +_u._ull;\ +}) +#endif /* !__rthal_u64fromu32 */ + +#ifndef rthal_ullmul +static inline __attribute_const__ unsigned long long +__rthal_generic_ullmul(const unsigned m0, const unsigned m1) +{ +return (unsigned long long) m0 * m1; +} +