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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [reent/] [timer.c] - Blame information for rev 1010

Go to most recent revision | Details | Compare with Previous | View Log

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