aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPascal Obry <obry@adacore.com>2014-11-20 10:47:11 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2014-11-20 11:47:11 +0100
commit6654786e8fcc06afd500494533b0400138241b98 (patch)
treed223591c9e818c0a139b752507fc7073d438020c /gcc
parent04e9213da79a04f1f87f1b15ed141a065b3d0185 (diff)
downloadgcc-6654786e8fcc06afd500494533b0400138241b98.zip
gcc-6654786e8fcc06afd500494533b0400138241b98.tar.gz
gcc-6654786e8fcc06afd500494533b0400138241b98.tar.bz2
adaint.c (remove_handle): New local routine without a lock.
2014-11-20 Pascal Obry <obry@adacore.com> * adaint.c (remove_handle): New local routine without a lock. (win32_wait): fix the critical section to properly protect needed code, use new remove_handle. (__gnat_win32_remove_handle): refactor code with remove_handle. From-SVN: r217832
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/adaint.c31
2 files changed, 25 insertions, 13 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 610203b..e12e368 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,10 @@
+2014-11-20 Pascal Obry <obry@adacore.com>
+
+ * adaint.c (remove_handle): New local routine without a lock.
+ (win32_wait): fix the critical section to properly protect needed
+ code, use new remove_handle.
+ (__gnat_win32_remove_handle): refactor code with remove_handle.
+
2014-11-20 Eric Botcazou <ebotcazou@adacore.com>
* inline.adb (Analyze_Inlined_Bodies): Iterate between loading
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index 0acaa74..4820677 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -2334,7 +2334,6 @@ static int *PID_LIST = NULL, plist_length = 0, plist_max_length = 0;
static void
add_handle (HANDLE h, int pid)
{
-
/* -------------------- critical section -------------------- */
(*Lock_Task) ();
@@ -2355,14 +2354,11 @@ add_handle (HANDLE h, int pid)
/* -------------------- critical section -------------------- */
}
-void
-__gnat_win32_remove_handle (HANDLE h, int pid)
+static void
+remove_handle (HANDLE h, int pid)
{
int j;
- /* -------------------- critical section -------------------- */
- (*Lock_Task) ();
-
for (j = 0; j < plist_length; j++)
{
if ((HANDLES_LIST[j] == h) || (PID_LIST[j] == pid))
@@ -2374,6 +2370,15 @@ __gnat_win32_remove_handle (HANDLE h, int pid)
break;
}
}
+}
+
+void
+__gnat_win32_remove_handle (HANDLE h, int pid)
+{
+ /* -------------------- critical section -------------------- */
+ (*Lock_Task) ();
+
+ remove_handle(h, pid);
(*Unlock_Task) ();
/* -------------------- critical section -------------------- */
@@ -2464,31 +2469,31 @@ win32_wait (int *status)
DWORD res;
int hl_len;
+ /* -------------------- critical section -------------------- */
+ (*Lock_Task) ();
+
if (plist_length == 0)
{
errno = ECHILD;
+ (*Unlock_Task) ();
return -1;
}
- /* -------------------- critical section -------------------- */
- (*Lock_Task) ();
-
hl_len = plist_length;
hl = (HANDLE *) xmalloc (sizeof (HANDLE) * hl_len);
memmove (hl, HANDLES_LIST, sizeof (HANDLE) * hl_len);
- (*Unlock_Task) ();
- /* -------------------- critical section -------------------- */
-
res = WaitForMultipleObjects (hl_len, hl, FALSE, INFINITE);
h = hl[res - WAIT_OBJECT_0];
GetExitCodeProcess (h, &exitcode);
pid = PID_LIST [res - WAIT_OBJECT_0];
- __gnat_win32_remove_handle (h, -1);
+ remove_handle (h, -1);
+ (*Unlock_Task) ();
+ /* -------------------- critical section -------------------- */
free (hl);
*status = (int) exitcode;