OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [newlib/] [newlib/] [libc/] [reent/] [timer.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
/* Reentrant versions of times and gettimeofday system calls for the
2
   clock and time ANSI C routines.
3
   This implementation just calls the times/gettimeofday system calls.
4
   Gettimeofday may not be available on all targets.  It's presence
5
   here is dubious.  Consider it for internal use only.  */
6
 
7
#include <reent.h>
8
#include <time.h>
9
#include <sys/times.h>
10
#include <_syslist.h>
11
 
12
/* Some targets provides their own versions of these functions.  Those
13
   targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS.  */
14
 
15
#ifdef _REENT_ONLY
16
#ifndef REENTRANT_SYSCALLS_PROVIDED
17
#define REENTRANT_SYSCALLS_PROVIDED
18
#endif
19
#endif
20
 
21
#ifdef REENTRANT_SYSCALLS_PROVIDED
22
 
23
int _dummy_time_syscalls = 1;
24
 
25
#else
26
 
27
/* We use the errno variable used by the system dependent layer.  */
28
#undef errno
29
extern int errno;
30
 
31
/*
32
FUNCTION
33
        <<_times_r>>---Reentrant version of times
34
 
35
INDEX
36
        _times_r
37
 
38
ANSI_SYNOPSIS
39
        #include <reent.h>
40
        #include <sys/times.h>
41
        clock_t _times_r(struct _reent *<[ptr]>, struct tms *<[ptms]>);
42
 
43
TRAD_SYNOPSIS
44
        #include <reent.h>
45
        #include <sys/times.h>
46
        clock_t _times_r(<[ptr]>, <[ptms]>)
47
        struct _reent *<[ptr]>;
48
        struct tms *<[ptms]>;
49
 
50
DESCRIPTION
51
        This is a reentrant version of <<times>>.  It
52
        takes a pointer to the global data block, which holds
53
        <<errno>>.
54
*/
55
 
56
clock_t
57
_times_r (ptr, ptms)
58
     struct _reent *ptr;
59
     struct tms *ptms;
60
{
61
  clock_t ret;
62
 
63
  ret = _times (ptms);
64
  return ret;
65
}
66
 
67
/*
68
FUNCTION
69
        <<_gettimeofday_r>>---Reentrant version of gettimeofday
70
 
71
INDEX
72
        _gettimeofday_r
73
 
74
ANSI_SYNOPSIS
75
        #include <reent.h>
76
        #include <time.h>
77
        int _gettimeofday_r(struct _reent *<[ptr]>,
78
                struct timeval *<[ptimeval]>,
79
                struct timezone *<[ptimezone]>);
80
 
81
TRAD_SYNOPSIS
82
        #include <reent.h>
83
        #include <time.h>
84
        int _gettimeofday_r(<[ptr]>, <[ptimeval]>, <[ptimezone]>)
85
        struct _reent *<[ptr]>;
86
        struct timeval *<[ptimeval]>;
87
        struct timezone *<[ptimezone]>;
88
 
89
DESCRIPTION
90
        This is a reentrant version of <<gettimeofday>>.  It
91
        takes a pointer to the global data block, which holds
92
        <<errno>>.
93
 
94
        This function is only available for a few targets.
95
        Check libc.a to see if its available on yours.
96
*/
97
 
98
int
99
_gettimeofday_r (ptr, ptimeval, ptimezone)
100
     struct _reent *ptr;
101
     struct timeval *ptimeval;
102
     struct timezone *ptimezone;
103
{
104
  int ret;
105
 
106
  errno = 0;
107
  if ((ret = _gettimeofday (ptimeval, ptimezone)) == -1 && errno != 0)
108
    ptr->_errno = errno;
109
  return ret;
110
}
111
 
112
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.