Commit 4c0c6b9f by Steven G. Kargl Committed by Paul Brook

gfortran.h (enum gfc_generic_isym_id): Add GFC_ISYM_GET?ID.

2004-08-29  Steven G. Kargl  <kargls@comcast.net>
	Paul Brook  <paul@codesourcery.com>

	* gfortran.h (enum gfc_generic_isym_id): Add GFC_ISYM_GET?ID.
	(gfc_check_f, gfc_simplify_f): Add f0.
	* intrinsic.c (do_check): Call f0.  Flatten.
	(add_sym_0): Fix prototype.  Set f0.
	(add_functions): Add getgid, getgid and getuid.
	(resolve_intrinsic): Remove obsolete comment.
	(do_simplify): Call f0.
	* intrinsic.h (gfc_resolve_getgid, gfc_resolve_getpid,
	gfc_resolve_getuid): Add prototypes.
	* iresolve.c (gfc_resolve_getgid, gfc_resolve_getpid,
	gfc_resolve_getuid): New functions.
	* trans-intrinsic.c (gfc_conv_intrinsic_function): Handle
	GFC_ISYM_GET?ID.
libgfortran/
	* Makefile.am: Add intrinsics/getXid.c.
	* configure.ac: Add tests for get{g,p,u}id.
	* config.h.in: Regenerate.
	* Makefile.in: Regenerate.
	* configure: Regenerate.

Co-Authored-By: Paul Brook <paul@codesourcery.com>

From-SVN: r86703
parent e5a002e3
2004-08-29 Steven G. Kargl <kargls@comcast.net>
Paul Brook <paul@codesourcery.com>
* gfortran.h (enum gfc_generic_isym_id): Add GFC_ISYM_GET?ID.
(gfc_check_f, gfc_simplify_f): Add f0.
* intrinsic.c (do_check): Call f0. Flatten.
(add_sym_0): Fix prototype. Set f0.
(add_functions): Add getgid, getgid and getuid.
(resolve_intrinsic): Remove obsolete comment.
(do_simplify): Call f0.
* intrinsic.h (gfc_resolve_getgid, gfc_resolve_getpid,
gfc_resolve_getuid): Add prototypes.
* iresolve.c (gfc_resolve_getgid, gfc_resolve_getpid,
gfc_resolve_getuid): New functions.
* trans-intrinsic.c (gfc_conv_intrinsic_function): Handle
GFC_ISYM_GET?ID.
2004-08-28 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
* error.c (gfc_error_init_1): Remove blank line in front of
......
......@@ -306,6 +306,9 @@ enum gfc_generic_isym_id
GFC_ISYM_EXPONENT,
GFC_ISYM_FLOOR,
GFC_ISYM_FRACTION,
GFC_ISYM_GETGID,
GFC_ISYM_GETPID,
GFC_ISYM_GETUID,
GFC_ISYM_IACHAR,
GFC_ISYM_IAND,
GFC_ISYM_IARGC,
......@@ -918,6 +921,7 @@ gfc_intrinsic_arg;
typedef union
{
try (*f0)(void);
try (*f1)(struct gfc_expr *);
try (*f1m)(gfc_actual_arglist *);
try (*f2)(struct gfc_expr *, struct gfc_expr *);
......@@ -937,6 +941,7 @@ gfc_check_f;
typedef union
{
struct gfc_expr *(*f0)(void);
struct gfc_expr *(*f1)(struct gfc_expr *);
struct gfc_expr *(*f2)(struct gfc_expr *, struct gfc_expr *);
struct gfc_expr *(*f3)(struct gfc_expr *, struct gfc_expr *,
......
......@@ -153,51 +153,36 @@ static try
do_check (gfc_intrinsic_sym * specific, gfc_actual_arglist * arg)
{
gfc_expr *a1, *a2, *a3, *a4, *a5;
try t;
if (arg == NULL)
return (*specific->check.f0) ();
a1 = arg->expr;
arg = arg->next;
if (arg == NULL)
t = (*specific->check.f1) (a1);
else
{
a2 = arg->expr;
arg = arg->next;
return (*specific->check.f1) (a1);
if (arg == NULL)
t = (*specific->check.f2) (a1, a2);
else
{
a3 = arg->expr;
arg = arg->next;
a2 = arg->expr;
arg = arg->next;
if (arg == NULL)
return (*specific->check.f2) (a1, a2);
if (arg == NULL)
t = (*specific->check.f3) (a1, a2, a3);
else
{
a4 = arg->expr;
arg = arg->next;
a3 = arg->expr;
arg = arg->next;
if (arg == NULL)
return (*specific->check.f3) (a1, a2, a3);
if (arg == NULL)
t = (*specific->check.f4) (a1, a2, a3, a4);
else
{
a5 = arg->expr;
arg = arg->next;
a4 = arg->expr;
arg = arg->next;
if (arg == NULL)
return (*specific->check.f4) (a1, a2, a3, a4);
if (arg == NULL)
t = (*specific->check.f5) (a1, a2, a3, a4, a5);
else
{
gfc_internal_error ("do_check(): too many args");
}
}
}
}
}
a5 = arg->expr;
arg = arg->next;
if (arg == NULL)
return (*specific->check.f5) (a1, a2, a3, a4, a5);
return t;
gfc_internal_error ("do_check(): too many args");
}
......@@ -307,17 +292,17 @@ add_sym (const char *name, int elemental, int actual_ok ATTRIBUTE_UNUSED,
static void add_sym_0 (const char *name, int elemental, int actual_ok, bt type,
int kind,
try (*check)(gfc_expr *),
gfc_expr *(*simplify)(gfc_expr *),
void (*resolve)(gfc_expr *,gfc_expr *)
try (*check)(void),
gfc_expr *(*simplify)(void),
void (*resolve)(gfc_expr *)
) {
gfc_simplify_f sf;
gfc_check_f cf;
gfc_resolve_f rf;
cf.f1 = check;
sf.f1 = simplify;
rf.f1 = resolve;
cf.f0 = check;
sf.f0 = simplify;
rf.f0 = resolve;
add_sym (name, elemental, actual_ok, type, kind, cf, sf, rf,
(void*)0);
......@@ -1172,6 +1157,16 @@ add_functions (void)
make_generic ("fraction", GFC_ISYM_FRACTION);
/* Unix IDs (g77 compatibility) */
add_sym_0 ("getgid", 1, 0, BT_INTEGER, di, NULL, NULL, gfc_resolve_getgid);
make_generic ("getgid", GFC_ISYM_GETGID);
add_sym_0 ("getpid", 1, 0, BT_INTEGER, di, NULL, NULL, gfc_resolve_getpid);
make_generic ("getpid", GFC_ISYM_GETPID);
add_sym_0 ("getuid", 1, 0, BT_INTEGER, di, NULL, NULL, gfc_resolve_getuid);
make_generic ("getuid", GFC_ISYM_GETUID);
add_sym_1 ("huge", 0, 1, BT_REAL, dr,
gfc_check_huge, gfc_simplify_huge, NULL,
x, BT_UNKNOWN, dr, 0);
......@@ -2273,15 +2268,6 @@ resolve_intrinsic (gfc_intrinsic_sym * specific, gfc_expr * e)
arg = e->value.function.actual;
/* At present only the iargc extension intrinsic takes no arguments,
and it doesn't need a resolution function, but this is here for
generality. */
if (arg == NULL)
{
(*specific->resolve.f0) (e);
return;
}
/* Special case hacks for MIN and MAX. */
if (specific->resolve.f1m == gfc_resolve_max
|| specific->resolve.f1m == gfc_resolve_min)
......@@ -2290,6 +2276,12 @@ resolve_intrinsic (gfc_intrinsic_sym * specific, gfc_expr * e)
return;
}
if (arg == NULL)
{
(*specific->resolve.f0) (e);
return;
}
a1 = arg->expr;
arg = arg->next;
......@@ -2373,6 +2365,12 @@ do_simplify (gfc_intrinsic_sym * specific, gfc_expr * e)
arg = e->value.function.actual;
if (arg == NULL)
{
result = (*specific->simplify.f0) ();
goto finish;
}
a1 = arg->expr;
arg = arg->next;
......
......@@ -252,6 +252,9 @@ void gfc_resolve_exp (gfc_expr *, gfc_expr *);
void gfc_resolve_exponent (gfc_expr *, gfc_expr *);
void gfc_resolve_floor (gfc_expr *, gfc_expr *, gfc_expr *);
void gfc_resolve_fraction (gfc_expr *, gfc_expr *);
void gfc_resolve_getgid (gfc_expr *);
void gfc_resolve_getpid (gfc_expr *);
void gfc_resolve_getuid (gfc_expr *);
void gfc_resolve_iand (gfc_expr *, gfc_expr *, gfc_expr *);
void gfc_resolve_ibclr (gfc_expr *, gfc_expr *, gfc_expr *);
void gfc_resolve_ibits (gfc_expr *, gfc_expr *, gfc_expr *, gfc_expr *);
......
......@@ -545,6 +545,32 @@ gfc_resolve_fraction (gfc_expr * f, gfc_expr * x)
void
gfc_resolve_getgid (gfc_expr * f)
{
f->ts.type = BT_INTEGER;
f->ts.kind = 4;
f->value.function.name = gfc_get_string (PREFIX("getgid"));
}
void
gfc_resolve_getpid (gfc_expr * f)
{
f->ts.type = BT_INTEGER;
f->ts.kind = 4;
f->value.function.name = gfc_get_string (PREFIX("getpid"));
}
void
gfc_resolve_getuid (gfc_expr * f)
{
f->ts.type = BT_INTEGER;
f->ts.kind = 4;
f->value.function.name = gfc_get_string (PREFIX("getuid"));
}
void
gfc_resolve_iand (gfc_expr * f, gfc_expr * i, gfc_expr * j ATTRIBUTE_UNUSED)
{
......
......@@ -2925,6 +2925,9 @@ gfc_conv_intrinsic_function (gfc_se * se, gfc_expr * expr)
case GFC_ISYM_RAND:
case GFC_ISYM_ETIME:
case GFC_ISYM_SECOND:
case GFC_ISYM_GETGID:
case GFC_ISYM_GETPID:
case GFC_ISYM_GETUID:
gfc_conv_intrinsic_funcall (se, expr);
break;
......
2004-08-29 Steven G. Kargl <kargls@comcast.net>
Paul Brook <paul@codesourcery.com>
* Makefile.am: Add intrinsics/getXid.c.
* configure.ac: Add tests for get{g,p,u}id.
* config.h.in: Regenerate.
* Makefile.in: Regenerate.
* configure: Regenerate.
2004-08-28 Paul Brook <paul@codesourcery.com>
PR libfortran/17195
......
......@@ -47,6 +47,7 @@ intrinsics/env.c \
intrinsics/eoshift0.c \
intrinsics/eoshift2.c \
intrinsics/etime.c \
intrinsics/getXid.c \
intrinsics/ishftc.c \
intrinsics/pack_generic.c \
intrinsics/size.c \
......
......@@ -120,11 +120,12 @@ am__objects_32 = backspace.lo close.lo endfile.lo format.lo inquire.lo \
unit.lo unix.lo write.lo
am__objects_33 = associated.lo abort.lo args.lo c99_functions.lo \
cpu_time.lo cshift0.lo date_and_time.lo env.lo eoshift0.lo \
eoshift2.lo etime.lo ishftc.lo pack_generic.lo size.lo \
spread_generic.lo string_intrinsics.lo rand.lo random.lo \
reshape_generic.lo reshape_packed.lo selected_kind.lo \
system_clock.lo transpose_generic.lo unpack_generic.lo \
in_pack_generic.lo in_unpack_generic.lo normalize.lo
eoshift2.lo etime.lo getXid.lo ishftc.lo pack_generic.lo \
size.lo spread_generic.lo string_intrinsics.lo rand.lo \
random.lo reshape_generic.lo reshape_packed.lo \
selected_kind.lo system_clock.lo transpose_generic.lo \
unpack_generic.lo in_pack_generic.lo in_unpack_generic.lo \
normalize.lo
am__objects_34 =
am__objects_35 = _abs_c4.lo _abs_c8.lo _abs_i4.lo _abs_i8.lo \
_abs_r4.lo _abs_r8.lo _exp_r4.lo _exp_r8.lo _exp_c4.lo \
......@@ -318,6 +319,7 @@ intrinsics/env.c \
intrinsics/eoshift0.c \
intrinsics/eoshift2.c \
intrinsics/etime.c \
intrinsics/getXid.c \
intrinsics/ishftc.c \
intrinsics/pack_generic.c \
intrinsics/size.c \
......@@ -2062,6 +2064,15 @@ etime.obj: intrinsics/etime.c
etime.lo: intrinsics/etime.c
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o etime.lo `test -f 'intrinsics/etime.c' || echo '$(srcdir)/'`intrinsics/etime.c
getXid.o: intrinsics/getXid.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o getXid.o `test -f 'intrinsics/getXid.c' || echo '$(srcdir)/'`intrinsics/getXid.c
getXid.obj: intrinsics/getXid.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o getXid.obj `if test -f 'intrinsics/getXid.c'; then $(CYGPATH_W) 'intrinsics/getXid.c'; else $(CYGPATH_W) '$(srcdir)/intrinsics/getXid.c'; fi`
getXid.lo: intrinsics/getXid.c
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o getXid.lo `test -f 'intrinsics/getXid.c' || echo '$(srcdir)/'`intrinsics/getXid.c
ishftc.o: intrinsics/ishftc.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ishftc.o `test -f 'intrinsics/ishftc.c' || echo '$(srcdir)/'`intrinsics/ishftc.c
......
......@@ -39,15 +39,24 @@
/* libm includes frexpf */
#undef HAVE_FREXPF
/* libc includes getgid */
#undef HAVE_GETGID
/* Define to 1 if you have the `getpagesize' function. */
#undef HAVE_GETPAGESIZE
/* libc includes getpid */
#undef HAVE_GETPID
/* Define to 1 if you have the `getrusage' function. */
#undef HAVE_GETRUSAGE
/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
/* libc includes getuid */
#undef HAVE_GETUID
/* libm includes hypotf */
#undef HAVE_HYPOTF
......
......@@ -160,6 +160,11 @@ AC_CHECK_LIB([m],[csin],[need_math="no"],[need_math="yes"])
# Check for library functions.
AC_CHECK_FUNCS(getrusage times)
# Check libc for getgid, getpid, getuid
AC_CHECK_LIB([c],[getgid],[AC_DEFINE([HAVE_GETGID],[1],[libc includes getgid])])
AC_CHECK_LIB([c],[getpid],[AC_DEFINE([HAVE_GETPID],[1],[libc includes getpid])])
AC_CHECK_LIB([c],[getuid],[AC_DEFINE([HAVE_GETUID],[1],[libc includes getuid])])
# Check for C99 (and other IEEE) math functions
AC_CHECK_LIB([m],[acosf],[AC_DEFINE([HAVE_ACOSF],[1],[libm includes acosf])])
AC_CHECK_LIB([m],[asinf],[AC_DEFINE([HAVE_ASINF],[1],[libm includes asinf])])
......
/* Wrapper for the unix get{g,p,u}id functions.
Copyright (C) 2004 Free Software Foundation, Inc.
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 Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with libgfortran; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "config.h"
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "libgfortran.h"
#ifdef HAVE_GETGID
GFC_INTEGER_4 prefix(getgid) (void)
{
return (GFC_INTEGER_4) getgid ();
}
#endif
#ifdef HAVE_GETPID
GFC_INTEGER_4 prefix(getpid) (void)
{
return (GFC_INTEGER_4) getpid ();
}
#endif
#ifdef HAVE_GETUID
GFC_INTEGER_4 prefix(getuid) (void)
{
return (GFC_INTEGER_4) getuid ();
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment