Changes for 4.5.0 snapshot
[newlib-cygwin.git] / libgloss / frv / sim-time.c
blob7a6af4acbe4f719fc5934d4e5cdbfaeba879ac7c
1 /* sim-time.c -- stubs so clock can be linked in.
3 * Copyright (c) 2002 Red Hat, Inc
5 * The authors hereby grant permission to use, copy, modify, distribute,
6 * and license this software and its documentation for any purpose, provided
7 * that existing copyright notices are retained in all copies and that this
8 * notice is included verbatim in any distributions. No written agreement,
9 * license, or royalty fee is required for any of the authorized uses.
10 * Modifications to this software may be copyrighted by their authors
11 * and need not follow the licensing terms described here, provided that
12 * the new terms are clearly indicated on the first page of each file where
13 * they apply.
15 #include <errno.h>
16 #include <sys/time.h>
17 #include <sys/times.h>
18 #include "glue.h"
21 * time -- simulator interface to return current time in seconds.
23 __asm__ ("\
24 .text\n\
25 .globl _sim_time\n\
26 .type _sim_time,@function\n\
27 _sim_time:\n\
28 setlos #18, gr7\n\
29 tira gr0, #0\n\
30 ret\n\
31 .Lsim:\n\
32 .size _sim_time,.Lsim-_sim_time");
34 extern time_t _sim_time (void) __asm__("_sim_time");
38 * time -- return current time in seconds.
40 time_t
41 time (time_t *t)
43 time_t ret = _sim_time ();
45 if (t)
46 *t = ret;
48 return ret;
52 * _times -- no clock, so return an error.
54 int
55 _times (struct tms *buf)
57 errno = EINVAL;
58 return (-1);
62 * _gettimeofday -- implement in terms of time, which means we can't return the
63 * microseconds.
65 int
66 _gettimeofday (struct timeval *tv,
67 void *tzvp)
69 struct timezone *tz = tzvp;
70 if (tz)
71 tz->tz_minuteswest = tz->tz_dsttime = 0;
73 tv->tv_usec = 0;
74 tv->tv_sec = _sim_time ();
75 return 0;