1 Commits

Author SHA1 Message Date
Jean-Baptiste Nahan
9a0cf72040 add PIE support 2026-02-10 23:33:24 +01:00
5 changed files with 5 additions and 104 deletions

13
.github/FUNDING.yml vendored
View File

@@ -1,13 +0,0 @@
# These are supported funding model platforms
github: [macintoshplus] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
# patreon: # Replace with a single Patreon username
# open_collective: # Replace with a single Open Collective username
# ko_fi: # Replace with a single Ko-fi username
# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
# liberapay: # Replace with a single Liberapay username
# issuehunt: # Replace with a single IssueHunt username
# otechie: # Replace with a single Otechie username
# lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
# custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

View File

@@ -1,4 +1,4 @@
CubicleSoft PHP Extension: Synchronization Objects (sync)
CubicleSoft PHP Extension: Synchronization Objects (sync)
==========================================================
The 'sync' extension introduces synchronization objects into PHP. Named and unnamed Mutex, Semaphore, Event, Reader-Writer, and named Shared Memory objects provide OS-level synchronization mechanisms on both *NIX (POSIX shared memory and pthread shared memory synchronization required) and Windows platforms. The extension comes with a test suite that integrates cleanly into 'make test'.
@@ -7,39 +7,6 @@ The 'sync' extension is a direct port of and compatible with the cross platform
This extension uses the liberal MIT open source license. And, of course, it sits on GitHub for all of that pull request and issue tracker goodness to easily submit changes and ideas respectively.
| Version | Status |
|---------|------------------------------|
| master | unmaintened :x: |
| v1.x | maintened :white_check_mark: |
Maintained PHP Versions compatibility:
| PHP Version | Status |
|-------------|------------------------|
| 5.x | no :x: |
| 7.x | no :x: |
| 8.0 | yes :white_check_mark: |
| 8.1 | yes :white_check_mark: |
| 8.2 | yes :white_check_mark: |
| 8.3 | yes :white_check_mark: |
| 8.4 | yes :white_check_mark: |
| 8.5 | yes :white_check_mark: |
Installation system support:
| Platform | Status |
|----------|------------------------|
| PECL | no :x: |
| PIE | yes :white_check_mark: |
To install the extension, use PIE (PHP Installer Extension) with a command like:
```bash
pie install php-win-ext/sync
```
Details
-------
@@ -196,4 +163,4 @@ if ($mem->first())
}
$result = $mem->write(json_encode(array("name" => "my_report.txt")));
```
```

View File

@@ -1,9 +1,9 @@
{
"name": "php-win-ext/sync",
"name": "php/sync",
"type": "php-ext",
"license": "MIT",
"description": "A PHP extension for Synchronization Objects (sync)",
"require": {
"php": ">= 8.0.0"
}
}
}

View File

@@ -12,7 +12,7 @@
extern zend_module_entry sync_module_entry;
#define phpext_sync_ptr &sync_module_entry
#define PHP_SYNC_VERSION "1.1.4"
#define PHP_SYNC_VERSION "1.1.3"
#ifdef PHP_WIN32
# define PHP_SYNC_API __declspec(dllexport)

53
sync.c
View File

@@ -900,11 +900,7 @@ PHP_METHOD(sync_Mutex, __construct)
obj->MxWinMutex = CreateMutexA(&SecAttr, FALSE, name);
if (obj->MxWinMutex == NULL)
{
#if PHP_VERSION_ID < 80500
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Mutex could not be created", 0 TSRMLS_CC);
#else
zend_throw_exception(zend_ce_exception, "Mutex could not be created", 0 TSRMLS_CC);
#endif
return;
}
@@ -916,11 +912,7 @@ PHP_METHOD(sync_Mutex, __construct)
if (Result < 0)
{
#if PHP_VERSION_ID < 80500
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Mutex could not be created", 0 TSRMLS_CC);
#else
zend_throw_exception(zend_ce_exception, "Mutex could not be created", 0 TSRMLS_CC);
#endif
return;
}
@@ -982,12 +974,7 @@ PHP_METHOD(sync_Mutex, lock)
if (pthread_mutex_lock(&obj->MxPthreadCritSection) != 0)
{
#if PHP_VERSION_ID < 80500
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Unable to acquire mutex critical section", 0 TSRMLS_CC);
#else
zend_throw_exception(zend_ce_exception, "Unable to acquire mutex critical section", 0 TSRMLS_CC);
#endif
RETURN_FALSE;
}
@@ -1156,11 +1143,7 @@ PHP_METHOD(sync_Semaphore, __construct)
obj->MxWinSemaphore = CreateSemaphoreA(&SecAttr, (LONG)initialval, (LONG)initialval, name);
if (obj->MxWinSemaphore == NULL)
{
#if PHP_VERSION_ID < 80500
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Semaphore could not be created", 0 TSRMLS_CC);
#else
zend_throw_exception(zend_ce_exception, "Semaphore could not be created", 0 TSRMLS_CC);
#endif
return;
}
@@ -1172,11 +1155,7 @@ PHP_METHOD(sync_Semaphore, __construct)
if (Result < 0)
{
#if PHP_VERSION_ID < 80500
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Semaphore could not be created", 0 TSRMLS_CC);
#else
zend_throw_exception(zend_ce_exception, "Semaphore could not be created", 0 TSRMLS_CC);
#endif
return;
}
@@ -1378,11 +1357,7 @@ PHP_METHOD(sync_Event, __construct)
obj->MxWinWaitEvent = CreateEventA(&SecAttr, (BOOL)manual, (prefire ? TRUE : FALSE), name);
if (obj->MxWinWaitEvent == NULL)
{
#if PHP_VERSION_ID < 80500
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Event object could not be created", 0 TSRMLS_CC);
#else
zend_throw_exception(zend_ce_exception, "Event object could not be created", 0 TSRMLS_CC);
#endif
return;
}
@@ -1394,11 +1369,7 @@ PHP_METHOD(sync_Event, __construct)
if (Result < 0)
{
#if PHP_VERSION_ID < 80500
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Event object could not be created", 0 TSRMLS_CC);
#else
zend_throw_exception(zend_ce_exception, "Event object could not be created", 0 TSRMLS_CC);
#endif
return;
}
@@ -1735,11 +1706,7 @@ PHP_METHOD(sync_ReaderWriter, __construct)
if (obj->MxWinRSemMutex == NULL || obj->MxWinRSemaphore == NULL || obj->MxWinRWaitEvent == NULL || obj->MxWinWWaitMutex == NULL)
{
#if PHP_VERSION_ID < 80500
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Reader-Writer object could not be created", 0 TSRMLS_CC);
#else
zend_throw_exception(zend_ce_exception, "Reader-Writer object could not be created", 0 TSRMLS_CC);
#endif
return;
}
@@ -1752,11 +1719,7 @@ PHP_METHOD(sync_ReaderWriter, __construct)
if (Result < 0)
{
#if PHP_VERSION_ID < 80500
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Reader-Writer object could not be created", 0 TSRMLS_CC);
#else
zend_throw_exception(zend_ce_exception, "Reader-Writer object could not be created", 0 TSRMLS_CC);
#endif
return;
}
@@ -2090,11 +2053,7 @@ PHP_METHOD(sync_SharedMemory, __construct)
if (name_len < 1)
{
#if PHP_VERSION_ID < 80500
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "An invalid name was passed", 0 TSRMLS_CC);
#else
zend_throw_exception(zend_ce_exception, "An invalid name was passed", 0 TSRMLS_CC);
#endif
return;
}
@@ -2118,11 +2077,7 @@ PHP_METHOD(sync_SharedMemory, __construct)
if (obj->MxFile == NULL)
{
#if PHP_VERSION_ID < 80500
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Shared memory file mapping could not be created/opened", 0 TSRMLS_CC);
#else
zend_throw_exception(zend_ce_exception, "Shared memory file mapping could not be created/opened", 0 TSRMLS_CC);
#endif
return;
}
@@ -2138,11 +2093,7 @@ PHP_METHOD(sync_SharedMemory, __construct)
if (obj->MxMem == NULL)
{
#if PHP_VERSION_ID < 80500
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Shared memory segment could not be mapped", 0 TSRMLS_CC);
#else
zend_throw_exception(zend_ce_exception, "Shared memory segment could not be mapped", 0 TSRMLS_CC);
#endif
return;
}
@@ -2156,11 +2107,7 @@ PHP_METHOD(sync_SharedMemory, __construct)
if (Result < 0)
{
#if PHP_VERSION_ID < 80500
zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Shared memory object could not be created/opened", 0 TSRMLS_CC);
#else
zend_throw_exception(zend_ce_exception, "Shared memory object could not be created/opened", 0 TSRMLS_CC);
#endif
return;
}