Detect if platform is missing spin locks and provide an dummy implementation. Emit warning during compilation and runtime (in debug)

This commit is contained in:
Riccardo Mottola 2018-04-23 20:37:28 +02:00
parent 635b71e442
commit 6f7e480913
4 changed files with 38 additions and 1 deletions

View file

@ -1,3 +1,8 @@
2018-04-23 Riccardo Mottola <rm@gnu.org>
* Source/NSThread.m:
Detect if platform is missing spin locks and provide an dummy implementation. Emit warning during compilation and runtime (in debug).
2018-04-16 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSThread.m: ensure that the thread specific memory key is

View file

@ -471,6 +471,9 @@
/* Define to 1 if you have the <pthread_np.h> header file. */
#undef HAVE_PTHREAD_NP_H
/* Define to 1 if you have the `pthread_spin_lock' function. */
#undef HAVE_PTHREAD_SPIN_LOCK
/* Define this if you work on sysv */
#undef HAVE_PTS_STREAM_MODULES

View file

@ -1,5 +1,5 @@
/** Control of executable units within a shared virtual memory space
Copyright (C) 1996-2000 Free Software Foundation, Inc.
Copyright (C) 1996-2018 Free Software Foundation, Inc.
Original Author: Scott Christley <scottc@net-community.com>
Rewritten by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
@ -35,6 +35,30 @@
#import "GSPThread.h"
// Dummy implementatation
// cleaner than IFDEF'ing the code everywhere
#ifndef HAVE_PTHREAD_SPIN_LOCK
#warning no spin_locks, using dummy versions
typedef int pthread_spinlock_t;
int pthread_spin_init(pthread_spinlock_t *lock, int pshared
{
NSDebugLog(@"NSThread.m: Warning this platform does not support spin locks");
return 0;
}
int pthread_spin_lock(pthread_spinlock_t *lock)
{
return 0;
}
int pthread_spin_unlock(pthread_spinlock_t *lock)
{
return 0;c
}
int pthread_spin_destroy(pthread_spinlock_t *lock)
{
return 0;
}
#endif
/** Structure for holding lock information for a thread.
*/
typedef struct {

View file

@ -1819,6 +1819,11 @@ case $gs_cv_pthread_setname_np in
;;
esac
#--------------------------------------------------------------------
# Check if we have spinlock support
#--------------------------------------------------------------------
AC_CHECK_FUNCS(pthread_spin_lock)
#--------------------------------------------------------------------
# Check whether we can get the system thread ID
#--------------------------------------------------------------------