1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-24 22:40:51 -08:00

Merge branch 2018-06-27/job004056.

Copied from Perforce
 Change: 194409
This commit is contained in:
Gareth Rees 2018-07-04 16:46:04 +01:00
commit 6b0e42e0e9
5 changed files with 42 additions and 5 deletions

View file

@ -57,7 +57,14 @@ static void inc(unsigned long i)
#define COUNT 100000l
static void *thread0(void *p)
{
unsigned i;
testlib_unused(p);
LockClaimGlobal();
LockReleaseGlobal();
for (i = 0; i < COUNT; ++i)
LockClaimGlobalRecursive();
for (i = 0; i < COUNT; ++i)
LockReleaseGlobalRecursive();
inc(COUNT);
return NULL;
}

View file

@ -136,13 +136,32 @@ void LockInitGlobal(void)
globalLockInit = TRUE;
}
static void lockEnsureGlobalLock(void)
/* lockEnsureGlobalLock -- one-time initialization of global locks
*
* InitOnceExecuteOnce ensures that only one thread can be running the
* callback at a time, which allows to safely check globalLockInit. See
* <https://docs.microsoft.com/en-us/windows/desktop/api/synchapi/nf-synchapi-initonceexecuteonce>
* but note that at time of writing (2018-06-27) the documentation has
* the arguments the wrong way round (parameter comes before context).
*/
static BOOL CALLBACK lockEnsureGlobalLockCallback(INIT_ONCE *init_once, void *parameter, void **context)
{
/* Ensure both global locks have been initialized. */
/* There is a race condition initializing them (job004056). */
UNUSED(init_once);
AVER(parameter == UNUSED_POINTER);
UNUSED(context);
if (!globalLockInit) {
LockInitGlobal();
}
return TRUE;
}
static void lockEnsureGlobalLock(void)
{
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
BOOL b = InitOnceExecuteOnce(&init_once, lockEnsureGlobalLockCallback,
UNUSED_POINTER, NULL);
AVER(b);
}
void (LockClaimGlobalRecursive)(void)

View file

@ -50,7 +50,8 @@ Supported target platforms
The MPS is currently supported for deployment on:
- Windows XP or later, on IA-32 and x86-64, using Microsoft Visual C/C++;
- Windows Vista or later, on IA-32 and x86-64, using Microsoft Visual
C/C++;
- Linux 2.6 or later, on IA-32 using GCC and on x86-64 using GCC or
Clang/LLVM;

View file

@ -15,6 +15,15 @@ New features
#. On FreeBSD, Linux and macOS, the MPS is now able to run in the
child process after ``fork()``. See :ref:`topic-thread-fork`.
#. The MPS now supports Windows Vista or later; it no longer supports
Windows XP. (Microsoft's own support for Windows XP `expired in
April 2014`_.) This is so that we can use |InitOnceExecuteOnce|_ to
ensure thread-safe initialization.
.. _expired in April 2014: https://www.microsoft.com/en-gb/windowsforbusiness/end-of-xp-support
.. |InitOnceExecuteOnce| replace:: ``InitOnceExecuteOnce()``
.. _InitOnceExecuteOnce: https://docs.microsoft.com/en-us/windows/desktop/api/synchapi/nf-synchapi-initonceexecuteonce
.. _release-notes-1.116:

View file

@ -72,7 +72,8 @@ Supported target platforms
The MPS is currently supported for deployment on:
- Windows XP or later, on IA-32 and x86-64, using Microsoft Visual C/C++;
- Windows Vista or later, on IA-32 and x86-64, using Microsoft Visual
C/C++;
- Linux 2.6 or later, on IA-32 using GCC and on x86-64 using GCC or
Clang/LLVM;