cvs: php-src /ext/com_dotnet com_persist.c com_wrapper.c
| From: | Wez Furlong | Date: | Sat, 31 Jul 2004 17:27:03 +0000 |
| Subject: | cvs: php-src /ext/com_dotnet com_persist.c com_wrapper.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-28120@lists.php.net to get a copy of this message | ||
wez Sat Jul 31 13:27:03 2004 EDT
Modified files:
/php-src/ext/com_dotnet com_persist.c com_wrapper.c
Log:
Allow COM to build under non-zts.
Thanks Frank.
http://cvs.php.net/diff.php/php-src/ext/com_dotnet/com_persist.c?r1=1.2&r2=1.3&ty=u
Index: php-src/ext/com_dotnet/com_persist.c
diff -u php-src/ext/com_dotnet/com_persist.c:1.2 php-src/ext/com_dotnet/com_persist.c:1.3
--- php-src/ext/com_dotnet/com_persist.c:1.2 Wed Jun 16 19:57:25 2004
+++ php-src/ext/com_dotnet/com_persist.c Sat Jul 31 13:27:03 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_persist.c,v 1.2 2004/06/16 23:57:25 abies Exp $ */
+/* $Id: com_persist.c,v 1.3 2004/07/31 17:27:03 wez Exp $ */
/* Infrastructure for working with persistent COM objects.
* Implements: IStream* wrapper for PHP streams.
@@ -38,7 +38,7 @@
typedef struct {
CONST_VTBL struct IStreamVtbl *lpVtbl;
- THREAD_T engine_thread;
+ DWORD engine_thread;
LONG refcount;
php_stream *stream;
int id;
@@ -53,17 +53,23 @@
istream_destructor(stm);
}
+#ifdef ZTS
+# define TSRMLS_FIXED() TSRMLS_FETCH();
+#else
+# define TSRMLS_FIXED()
+#endif
+
#define FETCH_STM() \
+ TSRMLS_FIXED() \
php_istream *stm = (php_istream*)This; \
- if (tsrm_thread_id() != stm->engine_thread) \
- return E_UNEXPECTED;
+ if (GetCurrentThreadId() != stm->engine_thread) \
+ return RPC_E_WRONG_THREAD;
static HRESULT STDMETHODCALLTYPE stm_queryinterface(
IStream *This,
/* [in] */ REFIID riid,
/* [iid_is][out] */ void **ppvObject)
{
- TSRMLS_FETCH();
FETCH_STM();
if (IsEqualGUID(&IID_IUnknown, riid) ||
@@ -79,7 +85,6 @@
static ULONG STDMETHODCALLTYPE stm_addref(IStream *This)
{
- TSRMLS_FETCH();
FETCH_STM();
return InterlockedIncrement(&stm->refcount);
@@ -88,7 +93,6 @@
static ULONG STDMETHODCALLTYPE stm_release(IStream *This)
{
ULONG ret;
- TSRMLS_FETCH();
FETCH_STM();
ret = InterlockedDecrement(&stm->refcount);
@@ -103,7 +107,6 @@
static HRESULT STDMETHODCALLTYPE stm_read(IStream *This, void *pv, ULONG cb, ULONG *pcbRead)
{
int nread;
- TSRMLS_FETCH();
FETCH_STM();
nread = php_stream_read(stm->stream, pv, cb);
@@ -120,7 +123,6 @@
static HRESULT STDMETHODCALLTYPE stm_write(IStream *This, void const *pv, ULONG cb, ULONG
*pcbWritten)
{
int nwrote;
- TSRMLS_FETCH();
FETCH_STM();
nwrote = php_stream_write(stm->stream, pv, cb);
@@ -140,7 +142,6 @@
off_t offset;
int whence;
int ret;
- TSRMLS_FETCH();
FETCH_STM();
switch (dwOrigin) {
@@ -169,7 +170,6 @@
static HRESULT STDMETHODCALLTYPE stm_set_size(IStream *This, ULARGE_INTEGER libNewSize)
{
- TSRMLS_FETCH();
FETCH_STM();
if (libNewSize.HighPart) {
@@ -190,7 +190,6 @@
static HRESULT STDMETHODCALLTYPE stm_copy_to(IStream *This, IStream *pstm, ULARGE_INTEGER cb,
ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
{
- TSRMLS_FETCH();
FETCH_STM();
return E_NOTIMPL;
@@ -198,7 +197,6 @@
static HRESULT STDMETHODCALLTYPE stm_commit(IStream *This, DWORD grfCommitFlags)
{
- TSRMLS_FETCH();
FETCH_STM();
php_stream_flush(stm->stream);
@@ -281,7 +279,7 @@
return NULL;
memset(stm, 0, sizeof(*stm));
- stm->engine_thread = tsrm_thread_id();
+ stm->engine_thread = GetCurrentThreadId();
stm->lpVtbl = &php_istream_vtbl;
stm->refcount = 1;
stm->stream = stream;
http://cvs.php.net/diff.php/php-src/ext/com_dotnet/com_wrapper.c?r1=1.7&r2=1.8&ty=u
Index: php-src/ext/com_dotnet/com_wrapper.c
diff -u php-src/ext/com_dotnet/com_wrapper.c:1.7 php-src/ext/com_dotnet/com_wrapper.c:1.8
--- php-src/ext/com_dotnet/com_wrapper.c:1.7 Thu Jul 29 10:06:24 2004
+++ php-src/ext/com_dotnet/com_wrapper.c Sat Jul 31 13:27:03 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: com_wrapper.c,v 1.7 2004/07/29 14:06:24 wez Exp $ */
+/* $Id: com_wrapper.c,v 1.8 2004/07/31 17:27:03 wez Exp $ */
/* This module exports a PHP object as a COM object by wrapping it
* using IDispatchEx */
@@ -38,7 +38,7 @@
/* now the PHP stuff */
- THREAD_T engine_thread; /* for sanity checking */
+ DWORD engine_thread; /* for sanity checking */
zval *object; /* the object exported */
LONG refcount; /* COM reference count */
@@ -74,7 +74,7 @@
va_list ap;
char buf[4096];
- sprintf(buf, "T=%08x ", tsrm_thread_id());
+ sprintf(buf, "T=%08x ", GetCurrentThreadId());
OutputDebugString(buf);
va_start(ap, fmt);
@@ -86,10 +86,17 @@
}
/* }}} */
+#ifdef ZTS
+# define TSRMLS_FIXED() TSRMLS_FETCH();
+#else
+# define TSRMLS_FIXED()
+#endif
+
#define FETCH_DISP(methname) \
+ TSRMLS_FIXED() \
php_dispatchex *disp = (php_dispatchex*)This; \
trace(" PHP:%s %s\n", Z_OBJCE_P(disp->object)->name, methname); \
- if (tsrm_thread_id() != disp->engine_thread) \
+ if (GetCurrentThreadId() != disp->engine_thread) \
return RPC_E_WRONG_THREAD;
@@ -98,8 +105,6 @@
/* [in] */ REFIID riid,
/* [iid_is][out] */ void **ppvObject)
{
- TSRMLS_FETCH();
-
FETCH_DISP("QueryInterface");
if (IsEqualGUID(&IID_IUnknown, riid) ||
@@ -117,8 +122,6 @@
static ULONG STDMETHODCALLTYPE disp_addref(IDispatchEx *This)
{
- TSRMLS_FETCH();
-
FETCH_DISP("AddRef");
return InterlockedIncrement(&disp->refcount);
@@ -127,8 +130,6 @@
static ULONG STDMETHODCALLTYPE disp_release(IDispatchEx *This)
{
ULONG ret;
- TSRMLS_FETCH();
-
FETCH_DISP("Release");
ret = InterlockedDecrement(&disp->refcount);
@@ -145,8 +146,6 @@
IDispatchEx *This,
/* [out] */ UINT *pctinfo)
{
- TSRMLS_FETCH();
-
FETCH_DISP("GetTypeInfoCount");
*pctinfo = 0;
@@ -159,8 +158,6 @@
/* [in] */ LCID lcid,
/* [out] */ ITypeInfo **ppTInfo)
{
- TSRMLS_FETCH();
-
FETCH_DISP("GetTypeInfo");
*ppTInfo = NULL;
@@ -177,8 +174,6 @@
{
UINT i;
HRESULT ret = S_OK;
- TSRMLS_FETCH();
-
FETCH_DISP("GetIDsOfNames");
for (i = 0; i < cNames; i++) {
@@ -229,8 +224,6 @@
char *name;
unsigned int namelen;
zval **tmp;
- TSRMLS_FETCH();
-
FETCH_DISP("GetDispID");
name = php_com_olestring_to_string(bstrName, &namelen, COMG(code_page) TSRMLS_CC);
@@ -264,8 +257,6 @@
zval *retval = NULL;
zval ***params = NULL;
HRESULT ret = DISP_E_MEMBERNOTFOUND;
- TSRMLS_FETCH();
-
FETCH_DISP("InvokeEx");
if (SUCCESS == zend_hash_index_find(disp->dispid_to_name, id, (void**)&name)) {
@@ -351,8 +342,6 @@
/* [in] */ BSTR bstrName,
/* [in] */ DWORD grfdex)
{
- TSRMLS_FETCH();
-
FETCH_DISP("DeleteMemberByName");
/* TODO: unset */
@@ -364,8 +353,6 @@
IDispatchEx *This,
/* [in] */ DISPID id)
{
- TSRMLS_FETCH();
-
FETCH_DISP("DeleteMemberByDispID");
/* TODO: unset */
@@ -379,8 +366,6 @@
/* [in] */ DWORD grfdexFetch,
/* [out] */ DWORD *pgrfdex)
{
- TSRMLS_FETCH();
-
FETCH_DISP("GetMemberProperties");
return DISP_E_UNKNOWNNAME;
@@ -392,8 +377,6 @@
/* [out] */ BSTR *pbstrName)
{
zval *name;
- TSRMLS_FETCH();
-
FETCH_DISP("GetMemberName");
if (SUCCESS == zend_hash_index_find(disp->dispid_to_name, id, (void**)&name)) {
@@ -413,8 +396,6 @@
/* [out] */ DISPID *pid)
{
ulong next = id+1;
- TSRMLS_FETCH();
-
FETCH_DISP("GetNextDispID");
while(!zend_hash_index_exists(disp->dispid_to_name, next))
@@ -431,8 +412,6 @@
IDispatchEx *This,
/* [out] */ IUnknown **ppunk)
{
- TSRMLS_FETCH();
-
FETCH_DISP("GetNameSpaceParent");
*ppunk = NULL;
@@ -549,7 +528,7 @@
memset(disp, 0, sizeof(php_dispatchex));
- disp->engine_thread = tsrm_thread_id();
+ disp->engine_thread = GetCurrentThreadId();
disp->lpVtbl = &php_dispatch_vtbl;
disp->refcount = 1;