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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgfortran/] [intrinsics/] [etime.c] - Blame information for rev 801

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

Line No. Rev Author Line
1 733 jeremybenn
/* Implementation of the ETIME intrinsic.
2
   Copyright (C) 2004, 2005, 2006, 2007, 2009, 2011 Free Software
3
   Foundation, Inc.
4
   Contributed by Steven G. Kargl <kargls@comcast.net>.
5
 
6
This file is part of the GNU Fortran runtime library (libgfortran).
7
 
8
Libgfortran is free software; you can redistribute it and/or
9
modify it under the terms of the GNU General Public
10
License as published by the Free Software Foundation; either
11
version 3 of the License, or (at your option) any later version.
12
 
13
Libgfortran is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
GNU General Public License for more details.
17
 
18
Under Section 7 of GPL version 3, you are granted additional
19
permissions described in the GCC Runtime Library Exception, version
20
3.1, as published by the Free Software Foundation.
21
 
22
You should have received a copy of the GNU General Public License and
23
a copy of the GCC Runtime Library Exception along with this program;
24
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
25
<http://www.gnu.org/licenses/>.  */
26
 
27
#include "libgfortran.h"
28
#include "time_1.h"
29
 
30
extern void etime_sub (gfc_array_r4 *t, GFC_REAL_4 *result);
31
iexport_proto(etime_sub);
32
 
33
void
34
etime_sub (gfc_array_r4 *t, GFC_REAL_4 *result)
35
{
36
  GFC_REAL_4 tu, ts, tt, *tp;
37
  long user_sec, user_usec, system_sec, system_usec;
38
 
39
  if (((GFC_DESCRIPTOR_EXTENT(t,0))) < 2)
40
    runtime_error ("Insufficient number of elements in TARRAY.");
41
 
42
  if (gf_cputime (&user_sec, &user_usec, &system_sec, &system_usec) == 0)
43
    {
44
      tu = (GFC_REAL_4)(user_sec + 1.e-6 * user_usec);
45
      ts = (GFC_REAL_4)(system_sec + 1.e-6 * system_usec);
46
      tt = tu + ts;
47
    }
48
  else
49
    {
50
      tu = (GFC_REAL_4)-1.0;
51
      ts = (GFC_REAL_4)-1.0;
52
      tt = (GFC_REAL_4)-1.0;
53
    }
54
 
55
  tp = t->data;
56
 
57
  *tp = tu;
58
  tp += GFC_DESCRIPTOR_STRIDE(t,0);
59
  *tp = ts;
60
  *result = tt;
61
}
62
iexport(etime_sub);
63
 
64
extern GFC_REAL_4 etime (gfc_array_r4 *t);
65
export_proto(etime);
66
 
67
GFC_REAL_4
68
etime (gfc_array_r4 *t)
69
{
70
  GFC_REAL_4 val;
71
  etime_sub (t, &val);
72
  return val;
73
}

powered by: WebSVN 2.1.0

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