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