aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/io/unit.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgfortran/io/unit.c')
-rw-r--r--libgfortran/io/unit.c54
1 files changed, 23 insertions, 31 deletions
diff --git a/libgfortran/io/unit.c b/libgfortran/io/unit.c
index 0d0ca8f..559dba9 100644
--- a/libgfortran/io/unit.c
+++ b/libgfortran/io/unit.c
@@ -27,7 +27,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include "fbuf.h"
#include "format.h"
#include "unix.h"
-#include "async.h"
#include <string.h>
#include <assert.h>
@@ -241,7 +240,7 @@ insert_unit (int n)
#else
__GTHREAD_MUTEX_INIT_FUNCTION (&u->lock);
#endif
- LOCK (&u->lock);
+ __gthread_mutex_lock (&u->lock);
u->priority = pseudo_random ();
unit_root = insert (u, unit_root);
return u;
@@ -328,9 +327,7 @@ get_gfc_unit (int n, int do_create)
gfc_unit *p;
int c, created = 0;
- NOTE ("Unit n=%d, do_create = %d", n, do_create);
- LOCK (&unit_lock);
-
+ __gthread_mutex_lock (&unit_lock);
retry:
for (c = 0; c < CACHE_SIZE; c++)
if (unit_cache[c] != NULL && unit_cache[c]->unit_number == n)
@@ -369,7 +366,7 @@ retry:
{
/* Newly created units have their lock held already
from insert_unit. Just unlock UNIT_LOCK and return. */
- UNLOCK (&unit_lock);
+ __gthread_mutex_unlock (&unit_lock);
return p;
}
@@ -377,10 +374,10 @@ found:
if (p != NULL && (p->child_dtio == 0))
{
/* Fast path. */
- if (! TRYLOCK (&p->lock))
+ if (! __gthread_mutex_trylock (&p->lock))
{
/* assert (p->closed == 0); */
- UNLOCK (&unit_lock);
+ __gthread_mutex_unlock (&unit_lock);
return p;
}
@@ -388,15 +385,15 @@ found:
}
- UNLOCK (&unit_lock);
+ __gthread_mutex_unlock (&unit_lock);
if (p != NULL && (p->child_dtio == 0))
{
- LOCK (&p->lock);
+ __gthread_mutex_lock (&p->lock);
if (p->closed)
{
- LOCK (&unit_lock);
- UNLOCK (&p->lock);
+ __gthread_mutex_lock (&unit_lock);
+ __gthread_mutex_unlock (&p->lock);
if (predec_waiting_locked (p) == 0)
destroy_unit_mutex (p);
goto retry;
@@ -643,7 +640,7 @@ init_units (void)
fbuf_init (u, 0);
- UNLOCK (&u->lock);
+ __gthread_mutex_unlock (&u->lock);
}
if (options.stdout_unit >= 0)
@@ -674,7 +671,7 @@ init_units (void)
fbuf_init (u, 0);
- UNLOCK (&u->lock);
+ __gthread_mutex_unlock (&u->lock);
}
if (options.stderr_unit >= 0)
@@ -705,13 +702,13 @@ init_units (void)
fbuf_init (u, 256); /* 256 bytes should be enough, probably not doing
any kind of exotic formatting to stderr. */
- UNLOCK (&u->lock);
+ __gthread_mutex_unlock (&u->lock);
}
/* The default internal units. */
u = insert_unit (GFC_INTERNAL_UNIT);
- UNLOCK (&u->lock);
+ __gthread_mutex_unlock (&u->lock);
u = insert_unit (GFC_INTERNAL_UNIT4);
- UNLOCK (&u->lock);
+ __gthread_mutex_unlock (&u->lock);
}
@@ -720,9 +717,6 @@ close_unit_1 (gfc_unit *u, int locked)
{
int i, rc;
- if (u->au)
- async_close (u->au);
-
/* If there are previously written bytes from a write with ADVANCE="no"
Reposition the buffer before closing. */
if (u->previous_nonadvancing_write)
@@ -732,7 +726,7 @@ close_unit_1 (gfc_unit *u, int locked)
u->closed = 1;
if (!locked)
- LOCK (&unit_lock);
+ __gthread_mutex_lock (&unit_lock);
for (i = 0; i < CACHE_SIZE; i++)
if (unit_cache[i] == u)
@@ -750,7 +744,7 @@ close_unit_1 (gfc_unit *u, int locked)
newunit_free (u->unit_number);
if (!locked)
- UNLOCK (&u->lock);
+ __gthread_mutex_unlock (&u->lock);
/* If there are any threads waiting in find_unit for this unit,
avoid freeing the memory, the last such thread will free it
@@ -759,7 +753,7 @@ close_unit_1 (gfc_unit *u, int locked)
destroy_unit_mutex (u);
if (!locked)
- UNLOCK (&unit_lock);
+ __gthread_mutex_unlock (&unit_lock);
return rc;
}
@@ -767,9 +761,7 @@ close_unit_1 (gfc_unit *u, int locked)
void
unlock_unit (gfc_unit *u)
{
- NOTE ("unlock_unit = %d", u->unit_number);
- UNLOCK (&u->lock);
- NOTE ("unlock_unit done");
+ __gthread_mutex_unlock (&u->lock);
}
/* close_unit()-- Close a unit. The stream is closed, and any memory
@@ -793,10 +785,10 @@ close_unit (gfc_unit *u)
void
close_units (void)
{
- LOCK (&unit_lock);
+ __gthread_mutex_lock (&unit_lock);
while (unit_root != NULL)
close_unit_1 (unit_root, 1);
- UNLOCK (&unit_lock);
+ __gthread_mutex_unlock (&unit_lock);
free (newunits);
@@ -903,7 +895,7 @@ finish_last_advance_record (gfc_unit *u)
int
newunit_alloc (void)
{
- LOCK (&unit_lock);
+ __gthread_mutex_lock (&unit_lock);
if (!newunits)
{
newunits = xcalloc (16, 1);
@@ -917,7 +909,7 @@ newunit_alloc (void)
{
newunits[ii] = true;
newunit_lwi = ii + 1;
- UNLOCK (&unit_lock);
+ __gthread_mutex_unlock (&unit_lock);
return -ii + NEWUNIT_START;
}
}
@@ -930,7 +922,7 @@ newunit_alloc (void)
memset (newunits + old_size, 0, old_size);
newunits[old_size] = true;
newunit_lwi = old_size + 1;
- UNLOCK (&unit_lock);
+ __gthread_mutex_unlock (&unit_lock);
return -old_size + NEWUNIT_START;
}