source: trunk/libs/newlib/src/libgloss/sparc_leon/asm-leon/timer.h @ 678

Last change on this file since 678 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.2 KB
Line 
1/*
2 * Copyright (c) 2011 Aeroflex Gaisler
3 *
4 * BSD license:
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
25
26#ifndef _ASMSPARC_TIMER_H
27#define _ASMSPARC_TIMER_H
28
29#include <asm-leon/queue.h>
30/*#include <sys/fsu_pthread_queue.h>*/
31#include <sys/time.h>
32#include <asm-leon/clock.h>
33
34#ifndef __ASSEMBLER__
35typedef int (*timerevent_handler) (void *);
36struct timerevent
37{
38  TAILQ_ENTRY (timerevent) n;
39  struct timespec expire;
40  timerevent_handler handler;
41  void *arg;
42
43};
44#endif
45
46#define GT_TIMESPEC(t1, t2) \
47      (t1.tv_sec > t2.tv_sec || \
48       (t1.tv_sec == t2.tv_sec && \
49        t1.tv_nsec > t2.tv_nsec))
50
51#define GT_TIMEVAL(t1, t2) \
52      (t1.tv_sec > t2.tv_sec || \
53       (t1.tv_sec == t2.tv_sec && \
54        t1.tv_usec > t2.tv_usec))
55
56/*
57 * MINUS_TIME only works if src1 > src2
58 */
59#define MINUS_TIMEVAL(dst, src1, src2) \
60    if ((src2).tv_usec > (src1).tv_usec) { \
61      (dst).tv_sec = (src1).tv_sec - (src2).tv_sec - 1; \
62      (dst).tv_usec = ((src1).tv_usec - (src2).tv_usec) + USEC_PER_SEC; \
63    } \
64    else { \
65      (dst).tv_sec = (src1).tv_sec - (src2).tv_sec; \
66      (dst).tv_usec = (src1).tv_usec - (src2).tv_usec; \
67    }
68
69/* Protypes */
70#ifndef __ASSEMBLER__
71void leonbare_init_ticks ();
72int addtimer (struct timerevent *e);
73#endif
74
75#endif
Note: See TracBrowser for help on using the repository browser.