2005-04-15 Thomas Koenig <Thomas.Koenig@online.de>
[official-gcc.git] / libgfortran / io / lock.c
blob21d04d720ac48b5f8cfa964d11290ca016d5f080
1 /* Thread/recursion locking
2 Copyright 2002 Free Software Foundation, Inc.
3 Contributed by Paul Brook <paul@nowt.org> and Andy Vaught
5 This file is part of the GNU Fortran 95 runtime library (libgfortran).
7 Libgfortran is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 In addition to the permissions in the GNU General Public License, the
13 Free Software Foundation gives you unlimited permission to link the
14 compiled version of this file into combinations with other programs,
15 and to distribute those combinations without any restriction coming
16 from the use of this file. (The General Public License restrictions
17 do apply in other respects; for example, they cover modification of
18 the file, and distribution when not linked into a combine
19 executable.)
21 Libgfortran is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
26 You should have received a copy of the GNU General Public
27 License along with libgfortran; see the file COPYING. If not,
28 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. */
31 #include "config.h"
32 #include <string.h>
33 #include "libgfortran.h"
34 #include "io.h"
36 st_parameter ioparm = { };
37 iexport_data(ioparm);
39 namelist_info *ionml = 0;
40 global_t g = { };
43 /* library_start()-- Called with a library call is entered. */
45 void
46 library_start (void)
48 if (g.in_library)
49 internal_error ("Recursive library calls not allowed");
51 /* The in_library flag indicates whether we're currently processing a
52 library call. Some calls leave immediately, but READ and WRITE
53 processing return control to the caller but are still considered to
54 stay within the library. */
55 g.in_library = 1;
57 if (ioparm.iostat != NULL && ioparm.library_return == LIBRARY_OK)
58 *ioparm.iostat = ERROR_OK;
60 ioparm.library_return = LIBRARY_OK;
64 /* library_end()-- Called when a library call is complete in order to
65 clean up for the next call. */
67 void
68 library_end (void)
70 int t;
71 namelist_info * t1, *t2;
73 g.in_library = 0;
74 filename = NULL;
75 line = 0;
77 t = ioparm.library_return;
78 if (ionml != NULL)
80 t1 = ionml;
81 while (t1 != NULL)
83 t2 = t1;
84 t1 = t1->next;
85 free_mem (t2);
89 ionml = NULL;
90 memset (&ioparm, '\0', sizeof (ioparm));
91 ioparm.library_return = t;