+2006-07-26 Francois-Xavier Coudert <coudert@clipper.ens.fr>
+
+ * intrinsic.c (add_functions): Add INT2, SHORT, INT8, LONG,
+ LSTAT, MCLOCK and MCLOCK8 intrinsic functions.
+ (add_subroutines): Add LSTAT intrinsic subroutine.
+ * gfortran.h (gfc_generic_isym_id): Add GFC_ISYM_INT2,
+ GFC_ISYM_INT8, GFC_ISYM_LONG, GFC_ISYM_LSTAT, GFC_ISYM_MCLOCK
+ and GFC_ISYM_MCLOCK8.
+ * iresolve.c (gfc_resolve_int2, gfc_resolve_int8,
+ gfc_resolve_long, gfc_resolve_lstat, gfc_resolve_mclock,
+ gfc_resolve_mclock8, gfc_resolve_lstat_sub): New functions.
+ * check.c (gfc_check_intconv): New function.
+ * trans-intrinsic.c (gfc_conv_intrinsic_function): Add cases for
+ the added GFC_ISYM_*.
+ * simplify.c (gfc_simplify_intconv, gfc_simplify_int2,
+ gfc_simplify_int8, gfc_simplify_long): New functions.
+ * intrinsic.h (gfc_check_intconv, gfc_simplify_int2,
+ gfc_simplify_int8, gfc_simplify_long, gfc_resolve_int2,
+ gfc_resolve_int8, gfc_resolve_long, gfc_resolve_lstat,
+ gfc_resolve_mclock, gfc_resolve_mclock8, gfc_resolve_lstat_sub):
+ Add prototypes.
+
2006-07-24 Erik Edelmann <eedelman@gcc.gnu.org>
PR fortran/28416
2006-07-22 Steven Bosscher <steven@gcc.gnu.org>
- PR fortran/28439
+ PR fortran/28439
* trans-stmt.c (gfc_trans_arithmetic_if): Evaluate the condition once.
2006-07-16 Jakub Jelinek <jakub@redhat.com>
try
+gfc_check_intconv (gfc_expr * x)
+{
+ if (numeric_check (x, 0) == FAILURE)
+ return FAILURE;
+
+ return SUCCESS;
+}
+
+
+try
gfc_check_ior (gfc_expr * i, gfc_expr * j)
{
if (type_check (i, 0, BT_INTEGER) == FAILURE)
GFC_ISYM_IERRNO,
GFC_ISYM_INDEX,
GFC_ISYM_INT,
+ GFC_ISYM_INT2,
+ GFC_ISYM_INT8,
GFC_ISYM_IOR,
GFC_ISYM_IRAND,
GFC_ISYM_ISATTY,
GFC_ISYM_LGT,
GFC_ISYM_LLE,
GFC_ISYM_LLT,
- GFC_ISYM_LOG,
GFC_ISYM_LOC,
+ GFC_ISYM_LOG,
GFC_ISYM_LOG10,
GFC_ISYM_LOGICAL,
+ GFC_ISYM_LONG,
+ GFC_ISYM_LSTAT,
GFC_ISYM_MALLOC,
GFC_ISYM_MATMUL,
GFC_ISYM_MAX,
GFC_ISYM_MAXLOC,
GFC_ISYM_MAXVAL,
+ GFC_ISYM_MCLOCK,
+ GFC_ISYM_MCLOCK8,
GFC_ISYM_MERGE,
GFC_ISYM_MIN,
GFC_ISYM_MINLOC,
make_generic ("int", GFC_ISYM_INT, GFC_STD_F77);
+ add_sym_1 ("int2", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
+ gfc_check_intconv, gfc_simplify_int2, gfc_resolve_int2,
+ a, BT_REAL, dr, REQUIRED);
+
+ make_alias ("short", GFC_STD_GNU);
+
+ make_generic ("int2", GFC_ISYM_INT2, GFC_STD_GNU);
+
+ add_sym_1 ("int8", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
+ gfc_check_intconv, gfc_simplify_int8, gfc_resolve_int8,
+ a, BT_REAL, dr, REQUIRED);
+
+ make_generic ("int8", GFC_ISYM_INT8, GFC_STD_GNU);
+
+ add_sym_1 ("long", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
+ gfc_check_intconv, gfc_simplify_long, gfc_resolve_long,
+ a, BT_REAL, dr, REQUIRED);
+
+ make_generic ("long", GFC_ISYM_LONG, GFC_STD_GNU);
+
add_sym_2 ("ior", 1, 1, BT_INTEGER, di, GFC_STD_F95,
gfc_check_ior, gfc_simplify_ior, gfc_resolve_ior,
i, BT_INTEGER, di, REQUIRED, j, BT_INTEGER, di, REQUIRED);
make_generic ("logical", GFC_ISYM_LOGICAL, GFC_STD_F95);
+ add_sym_2 ("lstat", 0, 1, BT_INTEGER, di, GFC_STD_GNU,
+ gfc_check_stat, NULL, gfc_resolve_lstat,
+ a, BT_CHARACTER, dc, REQUIRED, b, BT_INTEGER, di, REQUIRED);
+
+ make_generic ("lstat", GFC_ISYM_LSTAT, GFC_STD_GNU);
+
add_sym_1 ("malloc", 0, 1, BT_INTEGER, ii, GFC_STD_GNU, gfc_check_malloc,
NULL, gfc_resolve_malloc, a, BT_INTEGER, di, REQUIRED);
make_generic ("maxval", GFC_ISYM_MAXVAL, GFC_STD_F95);
+ add_sym_0 ("mclock", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
+ NULL, NULL, gfc_resolve_mclock);
+
+ make_generic ("mclock", GFC_ISYM_MCLOCK, GFC_STD_GNU);
+
+ add_sym_0 ("mclock8", 1, 0, BT_INTEGER, di, GFC_STD_GNU,
+ NULL, NULL, gfc_resolve_mclock8);
+
+ make_generic ("mclock8", GFC_ISYM_MCLOCK8, GFC_STD_GNU);
+
add_sym_3 ("merge", 1, 1, BT_REAL, dr, GFC_STD_F95,
gfc_check_merge, NULL, gfc_resolve_merge,
ts, BT_REAL, dr, REQUIRED, fs, BT_REAL, dr, REQUIRED,
ut, BT_INTEGER, di, REQUIRED, vl, BT_INTEGER, di, REQUIRED,
st, BT_INTEGER, di, OPTIONAL);
+ add_sym_3s ("lstat", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
+ gfc_check_stat_sub, NULL, gfc_resolve_lstat_sub,
+ name, BT_CHARACTER, dc, REQUIRED, vl, BT_INTEGER, di, REQUIRED,
+ st, BT_INTEGER, di, OPTIONAL);
+
add_sym_3s ("stat", 0, 1, BT_UNKNOWN, 0, GFC_STD_GNU,
gfc_check_stat_sub, NULL, gfc_resolve_stat_sub,
name, BT_CHARACTER, dc, REQUIRED, vl, BT_INTEGER, di, REQUIRED,
try gfc_check_ieor (gfc_expr *, gfc_expr *);
try gfc_check_index (gfc_expr *, gfc_expr *, gfc_expr *);
try gfc_check_int (gfc_expr *, gfc_expr *);
+try gfc_check_intconv (gfc_expr *);
try gfc_check_ior (gfc_expr *, gfc_expr *);
try gfc_check_irand (gfc_expr *);
try gfc_check_isatty (gfc_expr *);
gfc_expr *gfc_simplify_ieor (gfc_expr *, gfc_expr *);
gfc_expr *gfc_simplify_index (gfc_expr *, gfc_expr *, gfc_expr *);
gfc_expr *gfc_simplify_int (gfc_expr *, gfc_expr *);
+gfc_expr *gfc_simplify_int2 (gfc_expr *);
+gfc_expr *gfc_simplify_int8 (gfc_expr *);
+gfc_expr *gfc_simplify_long (gfc_expr *);
gfc_expr *gfc_simplify_ifix (gfc_expr *);
gfc_expr *gfc_simplify_idint (gfc_expr *);
gfc_expr *gfc_simplify_ior (gfc_expr *, gfc_expr *);
void gfc_resolve_ichar (gfc_expr *, gfc_expr *);
void gfc_resolve_idnint (gfc_expr *, gfc_expr *);
void gfc_resolve_int (gfc_expr *, gfc_expr *, gfc_expr *);
+void gfc_resolve_int2 (gfc_expr *, gfc_expr *);
+void gfc_resolve_int8 (gfc_expr *, gfc_expr *);
+void gfc_resolve_long (gfc_expr *, gfc_expr *);
void gfc_resolve_ior (gfc_expr *, gfc_expr *, gfc_expr *);
void gfc_resolve_isatty (gfc_expr *, gfc_expr *);
void gfc_resolve_ishft (gfc_expr *, gfc_expr *, gfc_expr *);
void gfc_resolve_log (gfc_expr *, gfc_expr *);
void gfc_resolve_log10 (gfc_expr *, gfc_expr *);
void gfc_resolve_logical (gfc_expr *, gfc_expr *, gfc_expr *);
+void gfc_resolve_lstat (gfc_expr *, gfc_expr *, gfc_expr *);
void gfc_resolve_malloc (gfc_expr *, gfc_expr *);
void gfc_resolve_matmul (gfc_expr *, gfc_expr *, gfc_expr *);
void gfc_resolve_max (gfc_expr *, gfc_actual_arglist *);
void gfc_resolve_maxloc (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *);
void gfc_resolve_maxval (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *);
+void gfc_resolve_mclock (gfc_expr *);
+void gfc_resolve_mclock8 (gfc_expr *);
void gfc_resolve_merge (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *);
void gfc_resolve_min (gfc_expr *, gfc_actual_arglist *);
void gfc_resolve_minloc (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *);
void gfc_resolve_hostnm_sub (gfc_code *);
void gfc_resolve_idate (gfc_code *);
void gfc_resolve_itime (gfc_code *);
+void gfc_resolve_lstat_sub (gfc_code *);
void gfc_resolve_kill_sub (gfc_code *);
void gfc_resolve_mvbits (gfc_code *);
void gfc_resolve_perror (gfc_code *);
void
+gfc_resolve_int2 (gfc_expr * f, gfc_expr * a)
+{
+ f->ts.type = BT_INTEGER;
+ f->ts.kind = 2;
+
+ f->value.function.name =
+ gfc_get_string ("__int_%d_%c%d", f->ts.kind, gfc_type_letter (a->ts.type),
+ a->ts.kind);
+}
+
+
+void
+gfc_resolve_int8 (gfc_expr * f, gfc_expr * a)
+{
+ f->ts.type = BT_INTEGER;
+ f->ts.kind = 8;
+
+ f->value.function.name =
+ gfc_get_string ("__int_%d_%c%d", f->ts.kind, gfc_type_letter (a->ts.type),
+ a->ts.kind);
+}
+
+
+void
+gfc_resolve_long (gfc_expr * f, gfc_expr * a)
+{
+ f->ts.type = BT_INTEGER;
+ f->ts.kind = 4;
+
+ f->value.function.name =
+ gfc_get_string ("__int_%d_%c%d", f->ts.kind, gfc_type_letter (a->ts.type),
+ a->ts.kind);
+}
+
+
+void
gfc_resolve_isatty (gfc_expr * f, gfc_expr * u)
{
gfc_typespec ts;
void
+gfc_resolve_mclock (gfc_expr * f)
+{
+ f->ts.type = BT_INTEGER;
+ f->ts.kind = 4;
+ f->value.function.name = PREFIX("mclock");
+}
+
+
+void
+gfc_resolve_mclock8 (gfc_expr * f)
+{
+ f->ts.type = BT_INTEGER;
+ f->ts.kind = 8;
+ f->value.function.name = PREFIX("mclock8");
+}
+
+
+void
gfc_resolve_merge (gfc_expr * f, gfc_expr * tsource,
gfc_expr * fsource ATTRIBUTE_UNUSED,
gfc_expr * mask ATTRIBUTE_UNUSED)
void
+gfc_resolve_lstat (gfc_expr * f, gfc_expr * n ATTRIBUTE_UNUSED,
+ gfc_expr * a ATTRIBUTE_UNUSED)
+{
+ f->ts.type = BT_INTEGER;
+ f->ts.kind = gfc_default_integer_kind;
+ f->value.function.name = gfc_get_string (PREFIX("lstat_i%d"), f->ts.kind);
+}
+
+
+void
gfc_resolve_fstat (gfc_expr * f, gfc_expr * n, gfc_expr * a ATTRIBUTE_UNUSED)
{
f->ts.type = BT_INTEGER;
void
+gfc_resolve_lstat_sub (gfc_code * c)
+{
+ const char *name;
+
+ name = gfc_get_string (PREFIX("lstat_i%d_sub"), gfc_default_integer_kind);
+ c->resolved_sym = gfc_get_intrinsic_sub_symbol (name);
+}
+
+
+void
gfc_resolve_fstat_sub (gfc_code * c)
{
const char *name;
}
+static gfc_expr *
+gfc_simplify_intconv (gfc_expr * e, int kind, const char *name)
+{
+ gfc_expr *rpart, *rtrunc, *result;
+
+ if (e->expr_type != EXPR_CONSTANT)
+ return NULL;
+
+ result = gfc_constant_result (BT_INTEGER, kind, &e->where);
+
+ switch (e->ts.type)
+ {
+ case BT_INTEGER:
+ mpz_set (result->value.integer, e->value.integer);
+ break;
+
+ case BT_REAL:
+ rtrunc = gfc_copy_expr (e);
+ mpfr_trunc (rtrunc->value.real, e->value.real);
+ gfc_mpfr_to_mpz (result->value.integer, rtrunc->value.real);
+ gfc_free_expr (rtrunc);
+ break;
+
+ case BT_COMPLEX:
+ rpart = gfc_complex2real (e, kind);
+ rtrunc = gfc_copy_expr (rpart);
+ mpfr_trunc (rtrunc->value.real, rpart->value.real);
+ gfc_mpfr_to_mpz (result->value.integer, rtrunc->value.real);
+ gfc_free_expr (rpart);
+ gfc_free_expr (rtrunc);
+ break;
+
+ default:
+ gfc_error ("Argument of %s at %L is not a valid type", name, &e->where);
+ gfc_free_expr (result);
+ return &gfc_bad_expr;
+ }
+
+ return range_check (result, name);
+}
+
+gfc_expr *
+gfc_simplify_int2 (gfc_expr * e)
+{
+ return gfc_simplify_intconv (e, 2, "INT2");
+}
+
+gfc_expr *
+gfc_simplify_int8 (gfc_expr * e)
+{
+ return gfc_simplify_intconv (e, 8, "INT8");
+}
+
+gfc_expr *
+gfc_simplify_long (gfc_expr * e)
+{
+ return gfc_simplify_intconv (e, 4, "LONG");
+}
+
+
gfc_expr *
gfc_simplify_ifix (gfc_expr * e)
{
/* Integer conversions are handled separately to make sure we get the
correct rounding mode. */
case GFC_ISYM_INT:
+ case GFC_ISYM_INT2:
+ case GFC_ISYM_INT8:
+ case GFC_ISYM_LONG:
gfc_conv_intrinsic_int (se, expr, FIX_TRUNC_EXPR);
break;
case GFC_ISYM_IRAND:
case GFC_ISYM_ISATTY:
case GFC_ISYM_LINK:
+ case GFC_ISYM_LSTAT:
case GFC_ISYM_MALLOC:
case GFC_ISYM_MATMUL:
+ case GFC_ISYM_MCLOCK:
+ case GFC_ISYM_MCLOCK8:
case GFC_ISYM_RAND:
case GFC_ISYM_RENAME:
case GFC_ISYM_SECOND:
+2006-07-26 Francois-Xavier Coudert <coudert@clipper.ens.fr>
+
+ * gfortran.dg/mclock.f90: New test.
+ * gfortran.dg/int_conv_1.f90: New test.
+ * gfortran.dg/stat_1.f90: New test.
+ * gfortran.dg/stat_2.f90: New test.
+
2006-07-25 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/28335
--- /dev/null
+! { dg-do run }
+! { dg-options "-std=gnu" }
+ integer(kind=2) :: i2, j2, k2, l2, m2, n2, o2
+ integer(kind=4) :: i4, j4
+ integer(kind=8) :: i8, j8
+ real :: x
+ complex :: z
+
+ i2 = huge(i2) / 3
+ i8 = int8(i2)
+ i4 = long(i2)
+ j2 = short(i2)
+ k2 = int2(i2)
+ l2 = int2(i8)
+ m2 = short(i8)
+ n2 = int2(i4)
+ o2 = short(i4)
+
+ if (i8 /= i2 .or. i4 /= i2 .or. j2 /= i2 .or. k2 /= i2 &
+ .or. l2 /= i2 .or. m2 /= i2 .or. n2 /= i2 .or. o2 /= i2) call abort
+
+ x = i2
+ i8 = int8(x)
+ i4 = long(x)
+ j2 = short(x)
+ k2 = int2(x)
+ if (i8 /= i2 .or. i4 /= i2 .or. j2 /= i2 .or. k2 /= i2) call abort
+
+ z = i2 + (0.,-42.)
+ i8 = int8(z)
+ i4 = long(z)
+ j2 = short(z)
+ k2 = int2(z)
+ if (i8 /= i2 .or. i4 /= i2 .or. j2 /= i2 .or. k2 /= i2) call abort
+
+ end
--- /dev/null
+! { dg-do run }
+! { dg-options "-std=gnu" }
+ integer(kind=4) :: i4, j4
+ integer(kind=8) :: i8, j8
+
+ i4 = mclock()
+ i8 = mclock8()
+ j4 = mclock()
+ j8 = mclock8()
+
+ if (i4 > j4 .or. i8 > j8 .or. i4 > i8 .or. j4 > j8) call abort
+
+ end
--- /dev/null
+! { dg-do run }
+! { dg-options "-std=gnu" }
+ character(len=*), parameter :: f = "testfile"
+ integer :: s1(13), r1, s2(13), r2, s3(13), r3
+
+ open (10,file=f)
+ write (10,"(A)") "foo"
+ close (10,status="keep")
+
+ open (10,file=f)
+ call lstat (f, s1, r1)
+ call stat (f, s2, r2)
+ call fstat (10, s3, r3)
+
+ if (r1 /= 0 .or. r2 /= 0 .or. r3 /= 0) call abort
+ if (any (s1 /= s2) .or. any (s1 /= s3)) call abort
+ if (s1(5) /= getuid()) call abort
+ if (s1(6) /= getgid()) call abort
+ if (s1(8) < 3 .or. s1(8) > 5) call abort
+
+ close (10,status="delete")
+ end
--- /dev/null
+! { dg-do run }
+! { dg-options "-std=gnu" }
+ character(len=*), parameter :: f = "testfile"
+ integer :: s1(13), r1, s2(13), r2, s3(13), r3
+
+ open (10,file=f)
+ write (10,"(A)") "foo"
+ close (10,status="keep")
+
+ open (10,file=f)
+ r1 = lstat (f, s1)
+ r2 = stat (f, s2)
+ r3 = fstat (10, s3)
+
+ if (r1 /= 0 .or. r2 /= 0 .or. r3 /= 0) call abort
+ if (any (s1 /= s2) .or. any (s1 /= s3)) call abort
+ if (s1(5) /= getuid()) call abort
+ if (s1(6) /= getgid()) call abort
+ if (s1(8) < 3 .or. s1(8) > 5) call abort
+
+ close (10,status="delete")
+ end
+2006-07-26 Francois-Xavier Coudert <coudert@clipper.ens.fr>
+
+ * configure.ac: Check for function clock.
+ * Makefile.am: Compile new file intrinsics/clock.c.
+ * intrinsics/clock.c: New file.
+ * Makefile.in: Regenerate.
+ * configure: Regenerate.
+ * config.h.in: Regenerate.
+ * intrinsics/stat.c: Rename the old stat_i?_sub functions to
+ helper functions stat_i?_sub_0, and use them for both STAT and
+ LSTAT.
+
2006-07-25 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/28335
intrinsics/bessel.c \
intrinsics/c99_functions.c \
intrinsics/chdir.c \
+intrinsics/clock.c \
intrinsics/cpu_time.c \
intrinsics/cshift0.c \
intrinsics/ctime.c \
list_read.lo lock.lo open.lo read.lo size_from_kind.lo \
transfer.lo unit.lo unix.lo write.lo
am__objects_30 = associated.lo abort.lo args.lo bessel.lo \
- c99_functions.lo chdir.lo cpu_time.lo cshift0.lo ctime.lo \
- date_and_time.lo env.lo erf.lo eoshift0.lo eoshift2.lo \
- etime.lo exit.lo fget.lo flush.lo fnum.lo ftell.lo gerror.lo \
- getcwd.lo getlog.lo getXid.lo hyper.lo hostnm.lo kill.lo \
- ierrno.lo ishftc.lo link.lo malloc.lo mvbits.lo \
+ c99_functions.lo chdir.lo clock.lo cpu_time.lo cshift0.lo \
+ ctime.lo date_and_time.lo env.lo erf.lo eoshift0.lo \
+ eoshift2.lo etime.lo exit.lo fget.lo flush.lo fnum.lo ftell.lo \
+ gerror.lo getcwd.lo getlog.lo getXid.lo hyper.lo hostnm.lo \
+ kill.lo ierrno.lo ishftc.lo link.lo malloc.lo mvbits.lo \
pack_generic.lo perror.lo signal.lo size.lo sleep.lo \
spread_generic.lo string_intrinsics.lo system.lo rand.lo \
random.lo rename.lo reshape_generic.lo reshape_packed.lo \
intrinsics/bessel.c \
intrinsics/c99_functions.c \
intrinsics/chdir.c \
+intrinsics/clock.c \
intrinsics/cpu_time.c \
intrinsics/cshift0.c \
intrinsics/ctime.c \
chdir.lo: intrinsics/chdir.c
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o chdir.lo `test -f 'intrinsics/chdir.c' || echo '$(srcdir)/'`intrinsics/chdir.c
+clock.lo: intrinsics/clock.c
+ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o clock.lo `test -f 'intrinsics/clock.c' || echo '$(srcdir)/'`intrinsics/clock.c
+
cpu_time.lo: intrinsics/cpu_time.c
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cpu_time.lo `test -f 'intrinsics/cpu_time.c' || echo '$(srcdir)/'`intrinsics/cpu_time.c
/* Define to 1 if you have the `chsize' function. */
#undef HAVE_CHSIZE
+/* Define to 1 if you have the `clock' function. */
+#undef HAVE_CLOCK
+
/* libm includes clog */
#undef HAVE_CLOG
-for ac_func in sleep time ttyname signal alarm ctime
+
+for ac_func in sleep time ttyname signal alarm ctime clock
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
# Check for library functions.
AC_CHECK_FUNCS(getrusage times mkstemp strtof strtold snprintf ftruncate chsize)
AC_CHECK_FUNCS(chdir strerror getlogin gethostname kill link symlink perror)
-AC_CHECK_FUNCS(sleep time ttyname signal alarm ctime)
+AC_CHECK_FUNCS(sleep time ttyname signal alarm ctime clock)
# Check libc for getgid, getpid, getuid
AC_CHECK_LIB([c],[getgid],[AC_DEFINE([HAVE_GETGID],[1],[libc includes getgid])])
--- /dev/null
+/* Implementation of the MCLOCK and MCLOCK8 g77 intrinsics.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+ Contributed by François-Xavier Coudert <coudert@clipper.ens.fr>
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+In addition to the permissions in the GNU General Public License, the
+Free Software Foundation gives you unlimited permission to link the
+compiled version of this file into combinations with other programs,
+and to distribute those combinations without any restriction coming
+from the use of this file. (The General Public License restrictions
+do apply in other respects; for example, they cover modification of
+the file, and distribution when not linked into a combine
+executable.)
+
+Libgfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public
+License along with libgfortran; see the file COPYING. If not,
+write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA. */
+
+#include "config.h"
+#include "libgfortran.h"
+
+#ifdef TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# ifdef HAVE_TIME_H
+# include <time.h>
+# endif
+# endif
+#endif
+
+
+/* INTEGER(KIND=4) FUNCTION MCLOCK() */
+
+extern GFC_INTEGER_4 mclock (void);
+export_proto(mclock);
+
+GFC_INTEGER_4
+mclock (void)
+{
+#ifdef HAVE_CLOCK
+ return (GFC_INTEGER_4) clock ();
+#else
+ return (GFC_INTEGER_4) -1;
+#endif
+}
+
+
+/* INTEGER(KIND=8) FUNCTION MCLOCK8() */
+
+extern GFC_INTEGER_8 mclock8 (void);
+export_proto(mclock8);
+
+GFC_INTEGER_8
+mclock8 (void)
+{
+#ifdef HAVE_CLOCK
+ return (GFC_INTEGER_8) clock ();
+#else
+ return (GFC_INTEGER_8) -1;
+#endif
+}
+
CHARACTER(len=*), INTENT(IN) :: FILE
INTEGER, INTENT(OUT), :: SARRAY(13) */
-extern void stat_i4_sub (char *, gfc_array_i4 *, GFC_INTEGER_4 *,
- gfc_charlen_type);
-iexport_proto(stat_i4_sub);
+/*extern void stat_i4_sub_0 (char *, gfc_array_i4 *, GFC_INTEGER_4 *,
+ gfc_charlen_type, int);
+internal_proto(stat_i4_sub_0);*/
-void
-stat_i4_sub (char *name, gfc_array_i4 *sarray, GFC_INTEGER_4 *status,
- gfc_charlen_type name_len)
+static void
+stat_i4_sub_0 (char *name, gfc_array_i4 *sarray, GFC_INTEGER_4 *status,
+ gfc_charlen_type name_len, int is_lstat)
{
int val;
char *str;
memcpy (str, name, name_len);
str[name_len] = '\0';
- val = stat(str, &sb);
+ if (is_lstat)
+ val = lstat(str, &sb);
+ else
+ val = stat(str, &sb);
if (val == 0)
{
if (status != NULL)
*status = (val == 0) ? 0 : errno;
}
+
+
+extern void stat_i4_sub (char *, gfc_array_i4 *, GFC_INTEGER_4 *,
+ gfc_charlen_type);
+iexport_proto(stat_i4_sub);
+
+void
+stat_i4_sub (char *name, gfc_array_i4 *sarray, GFC_INTEGER_4 *status,
+ gfc_charlen_type name_len)
+{
+ stat_i4_sub_0 (name, sarray, status, name_len, 0);
+}
iexport(stat_i4_sub);
-extern void stat_i8_sub (char *, gfc_array_i8 *, GFC_INTEGER_8 *,
+
+extern void lstat_i4_sub (char *, gfc_array_i4 *, GFC_INTEGER_4 *,
gfc_charlen_type);
-iexport_proto(stat_i8_sub);
+iexport_proto(lstat_i4_sub);
void
-stat_i8_sub (char *name, gfc_array_i8 *sarray, GFC_INTEGER_8 *status,
+lstat_i4_sub (char *name, gfc_array_i4 *sarray, GFC_INTEGER_4 *status,
gfc_charlen_type name_len)
{
+ stat_i4_sub_0 (name, sarray, status, name_len, 1);
+}
+iexport(lstat_i4_sub);
+
+
+
+static void
+stat_i8_sub_0 (char *name, gfc_array_i8 *sarray, GFC_INTEGER_8 *status,
+ gfc_charlen_type name_len, int is_lstat)
+{
int val;
char *str;
struct stat sb;
memcpy (str, name, name_len);
str[name_len] = '\0';
- val = stat(str, &sb);
+ if (is_lstat)
+ val = lstat(str, &sb);
+ else
+ val = stat(str, &sb);
if (val == 0)
{
if (status != NULL)
*status = (val == 0) ? 0 : errno;
}
+
+
+extern void stat_i8_sub (char *, gfc_array_i8 *, GFC_INTEGER_8 *,
+ gfc_charlen_type);
+iexport_proto(stat_i8_sub);
+
+void
+stat_i8_sub (char *name, gfc_array_i8 *sarray, GFC_INTEGER_8 *status,
+ gfc_charlen_type name_len)
+{
+ stat_i8_sub_0 (name, sarray, status, name_len, 0);
+}
+
iexport(stat_i8_sub);
+
+extern void lstat_i8_sub (char *, gfc_array_i8 *, GFC_INTEGER_8 *,
+ gfc_charlen_type);
+iexport_proto(lstat_i8_sub);
+
+void
+lstat_i8_sub (char *name, gfc_array_i8 *sarray, GFC_INTEGER_8 *status,
+ gfc_charlen_type name_len)
+{
+ stat_i8_sub_0 (name, sarray, status, name_len, 1);
+}
+
+iexport(lstat_i8_sub);
+
+
extern GFC_INTEGER_4 stat_i4 (char *, gfc_array_i4 *, gfc_charlen_type);
export_proto(stat_i4);
}
+/* SUBROUTINE STAT(FILE, SARRAY, STATUS)
+ CHARACTER(len=*), INTENT(IN) :: FILE
+ INTEGER, INTENT(OUT), :: SARRAY(13)
+ INTEGER, INTENT(OUT), OPTIONAL :: STATUS
+
+ FUNCTION STAT(FILE, SARRAY)
+ INTEGER STAT
+ CHARACTER(len=*), INTENT(IN) :: FILE
+ INTEGER, INTENT(OUT), :: SARRAY(13) */
+
+extern GFC_INTEGER_4 lstat_i4 (char *, gfc_array_i4 *, gfc_charlen_type);
+export_proto(lstat_i4);
+
+GFC_INTEGER_4
+lstat_i4 (char *name, gfc_array_i4 *sarray, gfc_charlen_type name_len)
+{
+ GFC_INTEGER_4 val;
+ lstat_i4_sub (name, sarray, &val, name_len);
+ return val;
+}
+
+extern GFC_INTEGER_8 lstat_i8 (char *, gfc_array_i8 *, gfc_charlen_type);
+export_proto(lstat_i8);
+
+GFC_INTEGER_8
+lstat_i8 (char *name, gfc_array_i8 *sarray, gfc_charlen_type name_len)
+{
+ GFC_INTEGER_8 val;
+ lstat_i8_sub (name, sarray, &val, name_len);
+ return val;
+}
+
+
+
/* SUBROUTINE FSTAT(UNIT, SARRAY, STATUS)
INTEGER, INTENT(IN) :: UNIT
INTEGER, INTENT(OUT) :: SARRAY(13)