CVS update: php31/ext/gd
| From: | shane | Date: | Sat, 17 Oct 1998 20:57:41 +0000 |
| Subject: | CVS update: php31/ext/gd | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-1889@lists.php.net to get a copy of this message | ||
Date: Saturday October 17, 1998 @ 16:57
Author: shane
Update of /repository/php31/ext/gd
In directory asf:/u2/tmp/cvs-serv42/ext/gd
Modified Files:
gd.c gd.dsp
Log Message:
make gd compilable on both 3.0 and 3.1
Index: php31/ext/gd/gd.c
diff -c php31/ext/gd/gd.c:2.6 php31/ext/gd/gd.c:2.7
*** php31/ext/gd/gd.c:2.6 Sat Oct 17 16:45:30 1998
--- php31/ext/gd/gd.c Sat Oct 17 16:57:40 1998
***************
*** 29,42 ****
+----------------------------------------------------------------------+
*/
! /* $Id: gd.c,v 2.6 1998/10/17 20:45:30 shane Exp $ */
/* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
Cold Spring Harbor Labs. */
/* Note that there is no code from the gd package in this file */
#ifdef THREAD_SAFE
! # include "tls.h"
#endif
#include "php.h"
#include "internal_functions.h"
--- 29,47 ----
+----------------------------------------------------------------------+
*/
! /* $Id: gd.c,v 2.7 1998/10/17 20:57:40 shane Exp $ */
/* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
Cold Spring Harbor Labs. */
/* Note that there is no code from the gd package in this file */
+ #define IS_EXT_MODULE
#ifdef THREAD_SAFE
! # ifndef PHP_31
! # undef THREAD_SAFE /*no need in 3.0*/
! # else
! # include "tls.h"
! # endif
#endif
#include "php.h"
#include "internal_functions.h"
***************
*** 78,83 ****
--- 83,89 ----
#ifdef THREAD_SAFE
DWORD GDlibTls;
static int numthreads=0;
+ void *gdlib_mutex=NULL;
typedef struct gdlib_global_struct{
int le_gd;
***************
*** 85,95 ****
} gdlib_global_struct;
# define GD_GLOBAL(a) gdlib_globals->a
- # define GD_TLS_VARS \
- gdlib_global_struct *gdlib_globals; \
- gdlib_globals=TlsGetValue(GDlibTls);
-
#else
# define GD_GLOBAL(a) a
# define GD_TLS_VARS
--- 91,98 ----
} gdlib_global_struct;
# define GD_GLOBAL(a) gdlib_globals->a
+ # define GD_TLS_VARS gdlib_global_struct *gdlib_globals = TlsGetValue(GDlibTls);
#else
# define GD_GLOBAL(a) a
# define GD_TLS_VARS
***************
*** 146,182 ****
};
#if COMPILE_DL
! #include "dl/phpdl.h"
DLEXPORT php3_module_entry *get_module(void) { return &gd_module_entry; }
-
- #if (WIN32|WINNT) && defined(THREAD_SAFE)
-
- /*NOTE: You should have an odbc.def file where you
- export DllMain*/
- BOOL WINAPI DllMain(HANDLE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved)
- {
- switch( ul_reason_for_call ) {
- case DLL_PROCESS_ATTACH:
- if ((GDlibTls=TlsAlloc())==0xFFFFFFFF){
- return 0;
- }
- break;
- case DLL_THREAD_ATTACH:
- break;
- case DLL_THREAD_DETACH:
- break;
- case DLL_PROCESS_DETACH:
- if (!TlsFree(GDlibTls)){
- return 0;
- }
- break;
- }
- return 1;
- }
#endif
- #endif
#define PolyMaxPoints 256
--- 149,161 ----
};
#if COMPILE_DL
! # if PHP_31
! # include "../phpdl.h"
! # else
! # include "dl/phpdl.h"
! # endif
DLEXPORT php3_module_entry *get_module(void) { return &gd_module_entry; }
#endif
#define PolyMaxPoints 256
***************
*** 184,206 ****
int php3_minit_gd(INIT_FUNC_ARGS)
{
! #ifdef THREAD_SAFE
gdlib_global_struct *gdlib_globals;
! #if !COMPILE_DL
! CREATE_MUTEX(gdlib_mutex,"GDLIB_TLS");
! SET_MUTEX(gdlib_mutex);
numthreads++;
if (numthreads==1){
! if ((GDlibTls=TlsAlloc())==0xFFFFFFFF){
! FREE_MUTEX(gdlib_mutex);
! return 0;
! }}
! FREE_MUTEX(gdlib_mutex);
! #endif
! gdlib_globals = (gdlib_global_struct *) LocalAlloc(LPTR, sizeof(gdlib_global_struct));
! TlsSetValue(GDlibTls, (void *) gdlib_globals);
#endif
-
GD_GLOBAL(le_gd) = register_list_destructors(gdImageDestroy, NULL);
GD_GLOBAL(le_gd_font) = register_list_destructors(php3_free_gd_font, NULL);
return SUCCESS;
--- 163,186 ----
int php3_minit_gd(INIT_FUNC_ARGS)
{
! #if defined(THREAD_SAFE)
gdlib_global_struct *gdlib_globals;
! PHP3_MUTEX_ALLOC(gdlib_mutex);
! PHP3_MUTEX_LOCK(gdlib_mutex);
numthreads++;
if (numthreads==1){
! if (!PHP3_TLS_PROC_STARTUP(GDlibTls)){
! PHP3_MUTEX_UNLOCK(gdlib_mutex);
! PHP3_MUTEX_FREE(gdlib_mutex);
! return FAILURE;
! }
! }
! PHP3_MUTEX_UNLOCK(gdlib_mutex);
! if(!PHP3_TLS_THREAD_INIT(GDlibTls,gdlib_globals,gdlib_global_struct)){
! PHP3_MUTEX_FREE(gdlib_mutex);
! return FAILURE;
! }
#endif
GD_GLOBAL(le_gd) = register_list_destructors(gdImageDestroy, NULL);
GD_GLOBAL(le_gd_font) = register_list_destructors(php3_free_gd_font, NULL);
return SUCCESS;
***************
*** 219,239 ****
}
int php3_mend_gd(void){
#ifdef THREAD_SAFE
! gdlib_global_struct *gdlib_globals;
! gdlib_globals = TlsGetValue(GDlibTls);
! if (gdlib_globals != 0)
! LocalFree((HLOCAL) gdlib_globals);
! #if !COMPILE_DL
! SET_MUTEX(gdlib_mutex);
numthreads--;
! if (!numthreads){
! if (!TlsFree(GDlibTls)){
! FREE_MUTEX(gdlib_mutex);
! return 0;
! }}
! FREE_MUTEX(gdlib_mutex);
! #endif
#endif
return SUCCESS;
}
--- 199,216 ----
}
int php3_mend_gd(void){
+ GD_TLS_VARS;
#ifdef THREAD_SAFE
! PHP3_TLS_THREAD_FREE(gdlib_globals);
! PHP3_MUTEX_LOCK(gdlib_mutex);
numthreads--;
! if (numthreads<1) {
! PHP3_TLS_PROC_SHUTDOWN(GDlibTls);
! PHP3_MUTEX_UNLOCK(gdlib_mutex);
! PHP3_MUTEX_FREE(gdlib_mutex);
! return SUCCESS;
! }
! PHP3_MUTEX_UNLOCK(gdlib_mutex);
#endif
return SUCCESS;
}
Index: php31/ext/gd/gd.dsp
diff -c php31/ext/gd/gd.dsp:2.3 php31/ext/gd/gd.dsp:2.4
*** php31/ext/gd/gd.dsp:2.3 Sat Oct 17 16:45:30 1998
--- php31/ext/gd/gd.dsp Sat Oct 17 16:57:40 1998
***************
*** 69,75 ****
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D
"_WINDOWS" /YX /FD /c
! # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../../../include" /I "./" /I
"../../" /I "../../main" /D PHP_31=1 /D HAVE_GD=1 /D "THREAD_SAFE" /D
"DEBUG" /D "_DEBUG" /D "HAVE_GDTTF" /D "COMPILE_DL" /D
"MSVC5" /D "WIN32" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
--- 69,75 ----
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D
"_WINDOWS" /YX /FD /c
! # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../../../include" /I "./" /I
"../../" /I "../../main" /I "../../os/nt" /D PHP_31=1 /D HAVE_GD=1 /D
"THREAD_SAFE" /D "DEBUG" /D "_DEBUG" /D "HAVE_GDTTF" /D
"COMPILE_DL" /D "MSVC5" /D "WIN32" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net