~ubuntu-branches/ubuntu/lucid/xenomai/lucid

« back to all changes in this revision

Viewing changes to include/asm-generic/bits/timeconv.h

  • Committer: Bazaar Package Importer
  • Author(s): Andres Rodriguez
  • Date: 2009-06-24 22:17:01 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090624221701-mwnah8aj90zmp6uj
Tags: 2.4.8-2ubuntu1
* Merge from debian unstable (LP: #391918), remaining changes:
  - Add lpia to supported architectures.
  - debian/rules: Create file for debhelper to pick up, use debhelper to
    install it.
  - debian/libxenomai1.dirs: Do not create directory.
  - debian/libxenomai1.preinst: Remove symlink on upgrade, remove old udev.
    rule unless modified in which case move to new name.
  - debian/libxenomai1.postinst: Do not create symlink.
  - debian/libxenomai1.postrm: No symlink to remove.
  - Bump build-depend on debhelper to install udev rules into
    /lib/udev/rules.d, add Breaks on udev to get correct version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2009 Philippe Gerum <rpm@xenomai.org>.
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Lesser General Public License for more details.
 
13
 
 
14
 * You should have received a copy of the GNU Lesser General Public
 
15
 * License along with this library; if not, write to the Free Software
 
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
 
17
 */
 
18
 
 
19
#ifndef _XENO_ASM_GENERIC_BITS_TIMECONV_H
 
20
#define _XENO_ASM_GENERIC_BITS_TIMECONV_H
 
21
 
 
22
#include <asm/xenomai/arith.h>
 
23
 
 
24
static unsigned long long cpufreq;
 
25
 
 
26
#ifdef XNARCH_HAVE_LLMULSHFT
 
27
static unsigned int tsc_scale, tsc_shift;
 
28
#endif
 
29
 
 
30
#ifdef XNARCH_HAVE_LLMULSHFT
 
31
long long xnarch_tsc_to_ns(long long ticks)
 
32
{
 
33
        return xnarch_llmulshft(ticks, tsc_scale, tsc_shift);
 
34
}
 
35
long long xnarch_tsc_to_ns_rounded(long long ticks)
 
36
{
 
37
        unsigned int shift = tsc_shift - 1;
 
38
        return (xnarch_llmulshft(ticks, tsc_scale, shift) + 1) / 2;
 
39
}
 
40
#else  /* !XNARCH_HAVE_LLMULSHFT */
 
41
long long xnarch_tsc_to_ns(long long ticks)
 
42
{
 
43
        return xnarch_llimd(ticks, 1000000000, cpufreq);
 
44
}
 
45
long long xnarch_tsc_to_ns_rounded(long long ticks)
 
46
{
 
47
        return (xnarch_llimd(ticks, 1000000000, cpufreq/2) + 1) / 2;
 
48
}
 
49
#endif /* !XNARCH_HAVE_LLMULSHFT */
 
50
 
 
51
long long xnarch_ns_to_tsc(long long ns)
 
52
{
 
53
        return xnarch_llimd(ns, cpufreq, 1000000000);
 
54
}
 
55
 
 
56
static inline void xnarch_init_timeconv(unsigned long long freq)
 
57
{
 
58
        cpufreq = freq;
 
59
#ifdef XNARCH_HAVE_LLMULSHFT
 
60
        xnarch_init_llmulshft(1000000000, freq, &tsc_scale, &tsc_shift);
 
61
#endif
 
62
}
 
63
 
 
64
#ifdef __KERNEL__
 
65
EXPORT_SYMBOL(xnarch_tsc_to_ns);
 
66
EXPORT_SYMBOL(xnarch_ns_to_tsc);
 
67
#endif /* __KERNEL__ */
 
68
 
 
69
#endif /* !_XENO_ASM_GENERIC_BITS_TIMECONV_H */