diff options
author | Jim Wilson <jim.wilson@r3-a15.aus-colo> | 2017-06-26 21:40:47 +0000 |
---|---|---|
committer | Jim Wilson <wilson@gcc.gnu.org> | 2017-06-26 14:40:47 -0700 |
commit | b971fa7f33010910a351d06e8c1e2fc81787e791 (patch) | |
tree | b3b89b10b37626121cb9c6bd74ec09bc0d63a45e | |
parent | b0d1023d5f5f52a21d00f6e7eb5d46898c052171 (diff) | |
download | gcc-b971fa7f33010910a351d06e8c1e2fc81787e791.zip gcc-b971fa7f33010910a351d06e8c1e2fc81787e791.tar.gz gcc-b971fa7f33010910a351d06e8c1e2fc81787e791.tar.bz2 |
Fix for SPEC CPU2017 621.wrf_s failure, add missing locking code.
libgfortran/
PR libfortran/81195
* io/unit.c (get_unit): Call __gthread_mutex_lock before newunit_stack
and newunit_tos references. Call __gthread_mutex_unlock afterward.
From-SVN: r249667
-rw-r--r-- | libgfortran/ChangeLog | 6 | ||||
-rw-r--r-- | libgfortran/io/unit.c | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index de85da9..778056b 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2017-06-26 Jim Wilson <jim.wilson@r3-a15.aus-colo> + + PR libfortran/81195 + * io/unit.c (get_unit): Call __gthread_mutex_lock before newunit_stack + and newunit_tos references. Call __gthread_mutex_unlock afterward. + 2017-06-24 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/52473 diff --git a/libgfortran/io/unit.c b/libgfortran/io/unit.c index bcc1e37..ef94294 100644 --- a/libgfortran/io/unit.c +++ b/libgfortran/io/unit.c @@ -583,14 +583,17 @@ get_unit (st_parameter_dt *dtp, int do_create) } else { + __gthread_mutex_lock (&unit_lock); if (newunit_tos) { dtp->common.unit = newunit_stack[newunit_tos].unit_number; unit = newunit_stack[newunit_tos--].unit; + __gthread_mutex_unlock (&unit_lock); unit->fbuf->act = unit->fbuf->pos = 0; } else { + __gthread_mutex_unlock (&unit_lock); dtp->common.unit = newunit_alloc (); unit = xcalloc (1, sizeof (gfc_unit)); fbuf_init (unit, 128); @@ -603,12 +606,15 @@ get_unit (st_parameter_dt *dtp, int do_create) /* If an internal unit number is passed from the parent to the child it should have been stashed on the newunit_stack ready to be used. Check for it now and return the internal unit if found. */ + __gthread_mutex_lock (&unit_lock); if (newunit_tos && (dtp->common.unit <= NEWUNIT_START) && (dtp->common.unit == newunit_stack[newunit_tos].unit_number)) { unit = newunit_stack[newunit_tos--].unit; + __gthread_mutex_unlock (&unit_lock); return unit; } + __gthread_mutex_unlock (&unit_lock); /* Has to be an external unit. */ dtp->u.p.unit_is_internal = 0; |