Module: xenomai-2.5 Branch: master Commit: 684ce4be595d500b882b51b69ab15174d8905ad9 URL: http://git.xenomai.org/?p=xenomai-2.5.git;a=commit;h=684ce4be595d500b882b51b69ab15174d8905ad9
Author: Jan Kiszka <jan.kis...@siemens.com> Date: Wed Feb 10 22:02:11 2010 +0100 Push time conversion services into libxeno_common This both fixes the breakage in multi-skin scenarios due to private variables vs. weak functions in timeconv.h and avoids that this code is redundantly included by every skin. Signed-off-by: Jan Kiszka <jan.kis...@siemens.com> --- include/asm-generic/arith.h | 4 ++- include/asm-generic/bits/timeconv.h | 18 +++++++--------- include/asm-generic/system.h | 12 ++-------- include/asm-generic/timeconv.h | 32 +++++++++++++++++++++++++++++ include/native/timer.h | 1 + src/skins/common/Makefile.am | 2 +- src/skins/common/bind.c | 3 ++ src/skins/common/timeconv.c | 38 +++++++++++++++++++++++++++++++++++ src/skins/native/init.c | 3 -- src/skins/native/timer.c | 16 +------------- src/skins/posix/clock.c | 18 +-------------- src/skins/posix/init.c | 5 ---- 12 files changed, 92 insertions(+), 60 deletions(-) diff --git a/include/asm-generic/arith.h b/include/asm-generic/arith.h index 416e742..c147768 100644 --- a/include/asm-generic/arith.h +++ b/include/asm-generic/arith.h @@ -393,7 +393,9 @@ static inline void xnarch_init_llmulshft(const unsigned m_in, #define xnarch_nodiv_ullimd rthal_nodiv_ullimd #define xnarch_nodiv_llimd rthal_nodiv_llimd #define xnarch_llmulshft rthal_llmulshft -#define xnarch_get_cpu_tsc rthal_rdtsc + +unsigned long long xnarch_divrem_billion(unsigned long long value, + unsigned long *rem); /*...@}*/ diff --git a/include/asm-generic/bits/timeconv.h b/include/asm-generic/bits/timeconv.h index fde8e5d..c3db32c 100644 --- a/include/asm-generic/bits/timeconv.h +++ b/include/asm-generic/bits/timeconv.h @@ -32,24 +32,23 @@ static rthal_u32frac_t bln_frac; #endif #ifdef XNARCH_HAVE_LLMULSHFT -__attribute__ ((weak)) long long xnarch_tsc_to_ns(long long ticks) { return xnarch_llmulshft(ticks, tsc_scale, tsc_shift); } -__attribute__ ((weak)) + long long xnarch_tsc_to_ns_rounded(long long ticks) { unsigned int shift = tsc_shift - 1; return (xnarch_llmulshft(ticks, tsc_scale, shift) + 1) / 2; } + #ifdef XNARCH_HAVE_NODIV_LLIMD -__attribute__ ((weak)) long long xnarch_ns_to_tsc(long long ns) { return xnarch_nodiv_llimd(ns, tsc_frac.frac, tsc_frac.integ); } -__attribute__ ((weak)) + unsigned long long xnarch_divrem_billion(unsigned long long value, unsigned long *rem) { @@ -66,24 +65,24 @@ unsigned long long xnarch_divrem_billion(unsigned long long value, return q; } #else /* !XNARCH_HAVE_NODIV_LLIMD */ -__attribute__ ((weak)) long long xnarch_ns_to_tsc(long long ns) { return xnarch_llimd(ns, 1 << tsc_shift, tsc_scale); } #endif /* !XNARCH_HAVE_NODIV_LLIMD */ + #else /* !XNARCH_HAVE_LLMULSHFT */ -__attribute__ ((weak)) + long long xnarch_tsc_to_ns(long long ticks) { return xnarch_llimd(ticks, 1000000000, clockfreq); } -__attribute__ ((weak)) + long long xnarch_tsc_to_ns_rounded(long long ticks) { return (xnarch_llimd(ticks, 1000000000, clockfreq/2) + 1) / 2; } -__attribute__ ((weak)) + long long xnarch_ns_to_tsc(long long ns) { return xnarch_llimd(ns, clockfreq, 1000000000); @@ -91,7 +90,6 @@ long long xnarch_ns_to_tsc(long long ns) #endif /* !XNARCH_HAVE_LLMULSHFT */ #ifndef XNARCH_HAVE_NODIV_LLIMD -__attribute__ ((weak)) unsigned long long xnarch_divrem_billion(unsigned long long value, unsigned long *rem) { @@ -100,7 +98,7 @@ unsigned long long xnarch_divrem_billion(unsigned long long value, } #endif /* !XNARCH_HAVE_NODIV_LLIMD */ -static inline void xnarch_init_timeconv(unsigned long long freq) +static void xnarch_init_timeconv(unsigned long long freq) { clockfreq = freq; #ifdef XNARCH_HAVE_LLMULSHFT diff --git a/include/asm-generic/system.h b/include/asm-generic/system.h index 176de1b..bff7140 100644 --- a/include/asm-generic/system.h +++ b/include/asm-generic/system.h @@ -38,6 +38,7 @@ #include <asm/ptrace.h> #include <asm/xenomai/hal.h> #include <asm/xenomai/atomic.h> +#include <asm-generic/xenomai/timeconv.h> #include <nucleus/shadow.h> /* debug support */ @@ -282,22 +283,15 @@ typedef struct xnarch_heapcb { unsigned long long xnarch_get_host_time(void); -long long xnarch_tsc_to_ns(long long ts); - -long long xnarch_tsc_to_ns_rounded(long long ts); - -long long xnarch_ns_to_tsc(long long ns); - unsigned long long xnarch_get_cpu_time(void); -unsigned long long xnarch_divrem_billion(unsigned long long value, - unsigned long *rem); - static inline unsigned long long xnarch_get_cpu_freq(void) { return RTHAL_CPU_FREQ; } +#define xnarch_get_cpu_tsc rthal_rdtsc + #define xnarch_halt(emsg) \ do { \ rthal_emergency_console(); \ diff --git a/include/asm-generic/timeconv.h b/include/asm-generic/timeconv.h new file mode 100644 index 0000000..7943949 --- /dev/null +++ b/include/asm-generic/timeconv.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2010 Jan Kiszka <jan.kis...@siemens.com>. + * + * 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 _XENO_ASM_GENERIC_TIMECONV_H +#define _XENO_ASM_GENERIC_TIMECONV_H + +#ifndef __KERNEL__ +extern xnsysinfo_t sysinfo; + +void xeno_init_timeconv(int muxid); +#endif + +long long xnarch_tsc_to_ns(long long ticks); +long long xnarch_tsc_to_ns_rounded(long long ticks); +long long xnarch_ns_to_tsc(long long ns); + +#endif /* !_XENO_ASM_GENERIC_TIMECONV_H */ diff --git a/include/native/timer.h b/include/native/timer.h index 45beffc..4d16e5d 100644 --- a/include/native/timer.h +++ b/include/native/timer.h @@ -48,6 +48,7 @@ typedef struct rt_timer_info { #if defined(__KERNEL__) || defined(__XENO_SIM__) #include <nucleus/timer.h> +#include <asm-generic/xenomai/timeconv.h> extern xntbase_t *__native_tbase; diff --git a/src/skins/common/Makefile.am b/src/skins/common/Makefile.am index 4a785d5..8466833 100644 --- a/src/skins/common/Makefile.am +++ b/src/skins/common/Makefile.am @@ -1,7 +1,7 @@ noinst_LTLIBRARIES = libxeno_common.la noinst_HEADERS = sem_heap.h -libxeno_common_la_SOURCES = bind.c current.c sigshadow.c +libxeno_common_la_SOURCES = bind.c current.c sigshadow.c timeconv.c if CONFIG_XENO_FASTSYNCH libxeno_common_la_SOURCES += sem_heap.c diff --git a/src/skins/common/bind.c b/src/skins/common/bind.c index 4f0c43c..0c9917a 100644 --- a/src/skins/common/bind.c +++ b/src/skins/common/bind.c @@ -6,6 +6,7 @@ #include <asm/xenomai/syscall.h> #include <asm-generic/xenomai/bits/current.h> +#include <asm-generic/xenomai/timeconv.h> #include <asm-generic/xenomai/stack.h> #include <asm/xenomai/bits/bind.h> #include "sem_heap.h" @@ -136,6 +137,8 @@ xeno_bind_skin_opt(unsigned skin_magic, const char *skin, xeno_featinfo = finfo; xeno_main_tid = pthread_self(); + + xeno_init_timeconv(muxid); return muxid; } diff --git a/src/skins/common/timeconv.c b/src/skins/common/timeconv.c new file mode 100644 index 0000000..9b2ba23 --- /dev/null +++ b/src/skins/common/timeconv.c @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 Jan Kiszka <jan.kis...@siemens.com>. + * + * 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. + */ + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> + +#include <asm/xenomai/syscall.h> +#include <asm-generic/xenomai/bits/timeconv.h> + +xnsysinfo_t sysinfo; + +void xeno_init_timeconv(int muxid) +{ + int err = XENOMAI_SYSCALL2(__xn_sys_info, muxid, &sysinfo); + if (err) { + fprintf(stderr, "Xenomai: sys_info failed: %s\n", + strerror(-err)); + exit(EXIT_FAILURE); + } + + xnarch_init_timeconv(sysinfo.cpufreq); +} diff --git a/src/skins/native/init.c b/src/skins/native/init.c index 76e43cd..aa5e41d 100644 --- a/src/skins/native/init.c +++ b/src/skins/native/init.c @@ -28,7 +28,6 @@ #include <asm/xenomai/bits/bind.h> int __native_muxid = -1; -void native_timer_init(int); #ifndef HAVE___THREAD pthread_key_t __native_tskey; @@ -57,7 +56,5 @@ void __init_xeno_interface(void) __native_muxid = xeno_bind_skin(XENO_SKIN_MAGIC, "native", "xeno_native", NULL); - native_timer_init(__native_muxid); - __native_muxid = __xn_mux_shifted_id(__native_muxid); } diff --git a/src/skins/native/timer.c b/src/skins/native/timer.c index 45a1e17..2cc9286 100644 --- a/src/skins/native/timer.c +++ b/src/skins/native/timer.c @@ -20,24 +20,10 @@ #include <stdlib.h> #include <native/syscall.h> #include <native/timer.h> -#include <asm-generic/xenomai/bits/timeconv.h> +#include <asm-generic/xenomai/timeconv.h> extern int __native_muxid; -static xnsysinfo_t sysinfo; - -void native_timer_init(int muxid) -{ - int err = XENOMAI_SYSCALL2(__xn_sys_info, muxid, &sysinfo); - if (err) { - fprintf(stderr, "Native skin init: " - "sys_info: %s\n", strerror(-err)); - exit(EXIT_FAILURE); - } - - xnarch_init_timeconv(sysinfo.cpufreq); -} - int rt_timer_set_mode(RTIME tickval) { return XENOMAI_SKINCALL1(__native_muxid, __native_timer_set_mode, diff --git a/src/skins/posix/clock.c b/src/skins/posix/clock.c index 98595d4..7b2e42d 100644 --- a/src/skins/posix/clock.c +++ b/src/skins/posix/clock.c @@ -23,25 +23,11 @@ #include <pthread.h> /* For pthread_setcanceltype. */ #include <posix/syscall.h> #include <time.h> -#include <asm-generic/xenomai/bits/timeconv.h> +#include <asm/xenomai/arith.h> +#include <asm-generic/xenomai/timeconv.h> extern int __pse51_muxid; -#ifdef XNARCH_HAVE_NONPRIV_TSC -static xnsysinfo_t sysinfo; - -void pse51_clock_init(int muxid) -{ - int err = -XENOMAI_SYSCALL2(__xn_sys_info, muxid, &sysinfo); - if (err) { - fprintf(stderr, "Xenomai Posix skin init: " - "sys_info: %s\n", strerror(err)); - exit(EXIT_FAILURE); - } - xnarch_init_timeconv(sysinfo.cpufreq); -} -#endif /* XNARCH_HAVE_NONPRIV_TSC */ - int __wrap_clock_getres(clockid_t clock_id, struct timespec *tp) { int err = -XENOMAI_SKINCALL2(__pse51_muxid, diff --git a/src/skins/posix/init.c b/src/skins/posix/init.c index f27adb4..14f9837 100644 --- a/src/skins/posix/init.c +++ b/src/skins/posix/init.c @@ -42,7 +42,6 @@ int __rtdm_fd_start = INT_MAX; static int fork_handler_registered; int __wrap_pthread_setschedparam(pthread_t, int, const struct sched_param *); -void pse51_clock_init(int); static __attribute__ ((constructor)) void __init_posix_interface(void) @@ -55,10 +54,6 @@ void __init_posix_interface(void) muxid = xeno_bind_skin(PSE51_SKIN_MAGIC, "POSIX", "xeno_posix", NULL); -#ifdef XNARCH_HAVE_NONPRIV_TSC - pse51_clock_init(muxid); -#endif /* XNARCH_HAVE_NONPRIV_TSC */ - __pse51_muxid = __xn_mux_shifted_id(muxid); muxid = XENOMAI_SYSBIND(RTDM_SKIN_MAGIC, _______________________________________________ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git