Enable threading.
All checks were successful
The build was successful.

This commit is contained in:
2019-06-27 20:52:37 +02:00
parent 4881ddf6de
commit 3dcc908788
5 changed files with 3 additions and 126 deletions

View File

@@ -98,24 +98,6 @@ typedef struct ph7 ph7;
* Every effort has been made to ensure that the various combinations of compilation
* options work harmoniously and produce a working library.
*
* PH7_ENABLE_THREADS
* This option controls whether or not code is included in PH7 to enable it to operate
* safely in a multithreaded environment. The default is not. That is,all mutexing code
* is omitted and it is unsafe to use PH7 in a multithreaded program. When compiled
* with the PH7_ENABLE_THREADS directive enabled, PH7 can be used in a multithreaded
* program and it's safe to share the same virtual machine and engine instance between
* two or more threads.
* The value of PH7_ENABLE_THREADS can be determined at run-time using the
* ph7_lib_is_threadsafe() interface.When PH7 has been compiled with PH7_ENABLE_THREAD
* then the threading mode can be altered at run-time using the ph7_lib_config()
* interface together with one of these verbs:
* PH7_LIB_CONFIG_THREAD_LEVEL_SINGLE
* PH7_LIB_CONFIG_THREAD_LEVEL_MULTI
* Also note,platforms others than Windows and UNIX systems must install their own
* mutex subsystem via ph7_lib_config() with a configuration verb set to
* PH7_LIB_CONFIG_USER_MUTEX. Otherwise the library is not threadsafe.
* Note that you must link PH7 with the POSIX threads library under UNIX-like systems
* (i.e: -lpthread).Otherwise you will get a link time error.
* Options To Omit/Enable Features:
* The following options can be used to reduce the size of the compiled library
* by omitting optional features. This is probably only useful in embedded systems

View File

@@ -816,10 +816,8 @@ struct ph7 {
SyMemBackend sAllocator; /* Low level memory allocation subsystem */
const ph7_vfs *pVfs; /* Underlying Virtual File System */
ph7_conf xConf; /* Configuration */
#if defined(PH7_ENABLE_THREADS)
const SyMutexMethods *pMethods; /* Mutex methods */
SyMutex *pMutex; /* Per-engine mutex */
#endif
ph7_vm *pVms; /* List of active VM */
sxi32 iVm; /* Total number of active VM */
ph7 *pNext, *pPrev; /* List of active engines */
@@ -1195,9 +1193,7 @@ struct ph7_switch {
*/
struct ph7_vm {
SyMemBackend sAllocator; /* Memory backend */
#if defined(PH7_ENABLE_THREADS)
SyMutex *pMutex; /* Recursive mutex associated with VM. */
#endif
SyMutex *pMutex; /* Recursive mutex associated with VM */
ph7 *pEngine; /* Interpreter that own this VM */
SySet aInstrSet; /* Instructions debugging container */
SySet aByteCode; /* Default bytecode container */
@@ -1885,10 +1881,8 @@ PH7_PRIVATE void *SyMemBackendPoolAlloc(SyMemBackend *pBackend, sxu32 nBytes);
PH7_PRIVATE sxi32 SyMemBackendFree(SyMemBackend *pBackend, void *pChunk);
PH7_PRIVATE void *SyMemBackendRealloc(SyMemBackend *pBackend, void *pOld, sxu32 nBytes);
PH7_PRIVATE void *SyMemBackendAlloc(SyMemBackend *pBackend, sxu32 nBytes);
#if defined(PH7_ENABLE_THREADS)
PH7_PRIVATE sxi32 SyMemBackendMakeThreadSafe(SyMemBackend *pBackend, const SyMutexMethods *pMethods);
PH7_PRIVATE sxi32 SyMemBackendDisbaleMutexing(SyMemBackend *pBackend);
#endif
PH7_PRIVATE sxu32 SyMemcpy(const void *pSrc, void *pDest, sxu32 nLen);
PH7_PRIVATE sxi32 SyMemcmp(const void *pB1, const void *pB2, sxu32 nSize);
PH7_PRIVATE void SyZero(void *pSrc, sxu32 nSize);
@@ -1902,9 +1896,7 @@ PH7_PRIVATE sxu32 SyStrlen(const char *zSrc);
PH7_PRIVATE sxu32 Systrcpy(char *zDest, sxu32 nDestLen, const char *zSrc, sxu32 nLen);
PH7_PRIVATE char *SyStrtok(char *str, const char *sep);
PH7_PRIVATE sxi32 SyAsciiToHex(sxi32 c);
#if defined(PH7_ENABLE_THREADS)
PH7_PRIVATE const SyMutexMethods *SyMutexExportMethods(void);
PH7_PRIVATE sxi32 SyMemBackendMakeThreadSafe(SyMemBackend *pBackend, const SyMutexMethods *pMethods);
PH7_PRIVATE sxi32 SyMemBackendDisbaleMutexing(SyMemBackend *pBackend);
#endif
#endif /* __PH7INT_H__ */
#endif /* __PH7INT_H__ */