Remove tls.[ch]

This commit is contained in:
Zeev Suraski 1999-04-23 20:06:01 +00:00
parent f53afa6edd
commit 6f7c0edee3
55 changed files with 21 additions and 499 deletions

View File

@ -30,9 +30,6 @@
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "ext/standard/head.h"
#include "php_globals.h"

View File

@ -55,9 +55,6 @@
*************************************************************************/
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#if 0
#include "bcdefs.h"
#include "proto.h"

View File

@ -30,9 +30,6 @@
#include "dl/phpdl.h"
#endif
#if defined(THREAD_SAFE)
#include "tls.h"
#endif
#include <stdlib.h>
#include "php.h"

View File

@ -29,9 +29,7 @@
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include <stdio.h>
#include "php.h"
#include "php3_string.h"

View File

@ -33,9 +33,7 @@
web site at http://www.fileproplus.com/
*/
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "safe_mode.h"
#include "fopen-wrappers.h"

View File

@ -35,9 +35,7 @@
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 "ext/standard/head.h"
#include <math.h>

View File

@ -8,9 +8,6 @@
#if HAVE_IMAP
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#ifndef MSVC5
#include "build-defs.h"
#endif

View File

@ -101,12 +101,6 @@ Changes 12.11.1998 (danny.heijl@cevi.be)
#if defined(COMPILE_DL)
#include "dl/phpdl.h"
#endif
#if defined(THREAD_SAFE)
#include "tls.h"
DWORD InformixTls;
static int numthreads=0;
void *ifx_mutex;
#endif
#if WIN32|WINNT
#include <winsock.h>

View File

@ -32,15 +32,6 @@
/* $Id$ */
#define IS_EXT_MODULE
#if !PHP_31 && defined(THREAD_SAFE)
#undef THREAD_SAFE
#endif
#ifdef THREAD_SAFE
#include "tls.h"
DWORD ldapTLS;
static int numthreads=0;
void *ldap_mutex;
#endif
#include "php.h"

View File

@ -28,9 +28,6 @@
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#if COMPILE_DL

View File

@ -28,9 +28,6 @@
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include <string.h>
#include "php.h"

View File

@ -30,9 +30,7 @@
#define HASH_OF(p) ((p)->type==IS_ARRAY ? (p)->value.ht : (((p)->type==IS_OBJECT ? (p)->value.obj.properties : NULL)))
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "internal_functions_registry.h"

View File

@ -27,9 +27,6 @@
+----------------------------------------------------------------------+
*/
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "php3_browscap.h"
#include "php_ini.h"

View File

@ -33,9 +33,6 @@
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "zend_operators.h"
#include "datetime.h"

View File

@ -29,9 +29,6 @@
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "fopen-wrappers.h"

View File

@ -29,9 +29,6 @@
+----------------------------------------------------------------------+
*/
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "dl.h"
#include "php_globals.h"

View File

@ -30,9 +30,6 @@
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>

View File

@ -28,9 +28,6 @@
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include <stdio.h>
#include "php.h"
#include <ctype.h>

View File

@ -27,9 +27,6 @@
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "php_globals.h"
#include "ext/standard/flock_compat.h"

View File

@ -28,9 +28,7 @@
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "safe_mode.h"
#include "fopen-wrappers.h"

View File

@ -30,9 +30,6 @@
/* $Id$ */
#include <math.h> /* modf() */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "ext/standard/head.h"
#include "php3_string.h"

View File

@ -28,9 +28,7 @@
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include <stdlib.h>
#if HAVE_UNISTD_H

View File

@ -27,9 +27,7 @@
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include <stdio.h>
#include "php.h"
#include "ext/standard/php3_standard.h"

View File

@ -28,9 +28,6 @@
+----------------------------------------------------------------------+
*/
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "reg.h"
#include "html.h"

View File

@ -27,9 +27,7 @@
| Zeev Suraski <zeev@zend.com> |
+----------------------------------------------------------------------+
*/
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "php_globals.h"

View File

@ -29,9 +29,7 @@
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "php3_filestat.h"
#include "php_globals.h"

View File

@ -33,9 +33,6 @@
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#ifndef MSVC5
#include "build-defs.h"

View File

@ -28,9 +28,6 @@
+----------------------------------------------------------------------+
*/
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "phpmath.h"
#include "snprintf.h"

View File

@ -30,9 +30,6 @@
/*
* md5.c - Copyright 1997 Lachlan Roche
*/
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include <stdio.h>
#include "php.h"

View File

@ -36,9 +36,6 @@
#include <string.h>
#include <errno.h>
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "microtime.h"
#include "snprintf.h"

View File

@ -27,9 +27,7 @@
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include <stdio.h>
#include "php.h"
#include "ext/standard/php3_standard.h"

View File

@ -27,9 +27,7 @@
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include <stdio.h>

View File

@ -27,9 +27,7 @@
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "pageinfo.h"

View File

@ -27,9 +27,7 @@
+----------------------------------------------------------------------+
*/
/* $Id: */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include <stdio.h>
#include "php.h"
#include "php3_standard.h"

View File

@ -29,9 +29,7 @@
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include <stdio.h>
#include "php.h"
#include "php3_string.h"

View File

@ -31,9 +31,7 @@
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include <stdio.h>
#include "php.h"
#include "reg.h"

View File

@ -28,9 +28,7 @@
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "zend_globals.h"

View File

@ -28,9 +28,7 @@
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include <stdlib.h>

View File

@ -34,9 +34,6 @@
#include <sys/types.h>
/* php.h includes the correct regex.h */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "url.h"

View File

@ -27,9 +27,6 @@
+----------------------------------------------------------------------+
*/
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

View File

@ -28,9 +28,6 @@
#endif
#define IS_EXT_MODULE
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include <stdio.h>

View File

@ -28,9 +28,6 @@
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include <stdlib.h>

View File

@ -29,10 +29,6 @@
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include "php_globals.h"

View File

@ -36,9 +36,6 @@
#undef SHUTDOWN_DEBUG
#define SHUTDOWN_DEBUG(resource)
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include <stdio.h>
#include "php.h"
#ifdef MSVC5

View File

@ -27,9 +27,7 @@
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#include <stdio.h>

View File

@ -30,10 +30,6 @@
*/
/* $Id$ */
#ifdef THREAD_SAFE
#include "tls.h"
#include "php.h"
#else
#include "httpd.h"
#include "http_config.h"
#if MODULE_MAGIC_NUMBER > 19980712
@ -48,7 +44,6 @@
#include "http_protocol.h"
#include "http_request.h"
#include "http_log.h"
#endif
/* These are taken out of php_ini.h

View File

@ -27,10 +27,6 @@
+----------------------------------------------------------------------+
*/
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#if HAVE_UNISTD_H

View File

@ -27,9 +27,6 @@
+----------------------------------------------------------------------+
*/
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h"
#ifndef THREAD_SAFE

113
tls.c
View File

@ -1,113 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP HTML Embedded Scripting Language Version 3.0 |
+----------------------------------------------------------------------+
| Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
+----------------------------------------------------------------------+
| This program is free software; you can redistribute it and/or modify |
| it under the terms of one of the following licenses: |
| |
| A) the GNU General Public License as published by the Free Software |
| Foundation; either version 2 of the License, or (at your option) |
| any later version. |
| |
| B) the PHP License as published by the PHP Development Team and |
| included in the distribution in the file: LICENSE |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
| |
| You should have received a copy of both licenses referred to here. |
| If you did not, or have any questions about PHP licensing, please |
| contact core@php.net. |
+----------------------------------------------------------------------+
| Authors: |
| |
+----------------------------------------------------------------------+
*/
#include "tls.h"
#if THREAD_SAFE
/*This is indeed a global!*/
DWORD TlsIndex;
#else
php3_globals_struct *php3_globals;
#endif
/* just copying from some samples, can replace this with
standard php error messaging */
VOID ErrorExit (LPTSTR lpszMessage)
{
fprintf(stderr, "%s\n", lpszMessage);
ExitProcess(0);
}
/*all these functions are called from DllMain()
in a NON thread safe version, tls_startup and
tls_shutdown should be initiated before anything
else. This will allocate memory for globals.
called at dll load*/
int tls_startup(void){
#if THREAD_SAFE
if ((TlsIndex=TlsAlloc())==0xFFFFFFFF){
return 0;
}
#else
php3_globals=malloc(sizeof(php3_globals));
#endif
return 1;
}
/*called at dll unload*/
int tls_shutdown(void){
#if THREAD_SAFE
if (!TlsFree(TlsIndex)){
return 0;
}
#else
free(php3_globals);
#endif
return 1;
}
#if THREAD_SAFE
/*called at start of thread*/
int tls_create(void){
php3_globals_struct *php3_globals;
php3_globals = (php3_globals_struct *) LocalAlloc(LPTR, sizeof(php3_globals_struct));
if (! TlsSetValue(TlsIndex, (void *) php3_globals))
ErrorExit("TlsSetValue error");
return 1;
}
/*called at end of thread*/
int tls_destroy(void){
php3_globals_struct *php3_globals;
php3_globals = TlsGetValue(TlsIndex);
if (php3_globals != 0)
LocalFree((HLOCAL) php3_globals);
return 1;
}
#endif
/*
accessing data inside a thread
This short function shows how the global struct
is accessed in a function. THREAD_SAFE should
only need to be defined on windows server modules
void thread_safe_access_of_globals(VOID)
{
TLS_VARS;
if ((php3_globals == 0) && (GetLastError() != 0)) {
ErrorExit("TlsGetValue error");
}
}
*/

207
tls.h
View File

@ -1,207 +0,0 @@
/*
+----------------------------------------------------------------------+
| PHP HTML Embedded Scripting Language Version 3.0 |
+----------------------------------------------------------------------+
| Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
+----------------------------------------------------------------------+
| This program is free software; you can redistribute it and/or modify |
| it under the terms of one of the following licenses: |
| |
| A) the GNU General Public License as published by the Free Software |
| Foundation; either version 2 of the License, or (at your option) |
| any later version. |
| |
| B) the PHP License as published by the PHP Development Team and |
| included in the distribution in the file: LICENSE |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
| |
| You should have received a copy of both licenses referred to here. |
| If you did not, or have any questions about PHP licensing, please |
| contact core@php.net. |
+----------------------------------------------------------------------+
| Authors: |
| |
+----------------------------------------------------------------------+
*/
#ifndef _TLS_H_
#define _TLS_H_
#if WIN32|WINNT
#include "win32/pwd.h"
#include "win32/sendmail.h"
#include <winsock.h>
#endif
#include "alloc.h"
#include "ext/standard/head.h"
#include "ext/bcmath/number.h"
#include "constants.h"
#include <sys/stat.h>
#if USE_SAPI
#include "serverapi/sapi.h"
#endif
typedef struct php3_global_struct{
/*all globals must be here*/
/*alloc.c*/
void *cache[MAX_CACHED_MEMORY][MAX_CACHED_ENTRIES];
unsigned char cache_count[MAX_CACHED_MEMORY];
int saved_umask;
mem_header *head;
unsigned int allocated_memory;
/*getopt.c*/
char *optarg;
int optind;
int opterr;
int optopt;
/*file.c*/
int pclose_ret;
int wsa_fp;
/*zend-parser.tab.c*/
HashTable function_table;
HashTable include_names;
int current_lineno;
int include_count;
FunctionState function_state;
FunctionState php3g_function_state_for_require;
char *class_name;
HashTable *class_symbol_table;
pval return_value,globals;
unsigned int param_index;
pval *array_ptr;
/*list.c*/
int module_count;
int current_module_being_cleaned;
/*main.c*/
int initialized;
int module_initialized;
char *php3_ini_path;
unsigned char header_is_being_sent;
#if APACHE
request_rec *php3_rqst;
#endif
#if USE_SAPI
struct sapi_request_info *sapi_rqst;
#endif
#if WIN32|WINNT
unsigned int wintimer_counter;
unsigned int wintimer;
unsigned int timerstart;
#endif
FILE *phpin;
/*request_info.c*/
php3_request_info request_info;
/*token_cache.c*/
pval phplval;
/*constants.c*/
HashTable php3_constants;
/*Functions*/
/*bc math*/
long bc_precision;
bc_num _zero_;
bc_num _one_;
bc_num _two_;
/*browscap.c*/
HashTable browser_hash;
char *lookup_browser_name;
pval *found_browser_entry;
/*dir.c*/
int dirp_id;
int le_dirp;
/*file.c*/
int fgetss_state;
int le_fp;
int le_pp;
/*filestat.c*/
char *CurrentStatFile;
#if MSVC5
unsigned int CurrentStatLength;
#else
int CurrentStatLength;
#endif
struct stat sb;
#if HAVE_SYMLINK
struct stat lsb;
#endif
/*formated_print.c*/
char cvt_buf[80]; /*STATIC VAR*/
/*head.c*/
int php3_PrintHeader;
CookieList *top;
char *cont_type;
int header_called;
/*info.c*/
#if APACHE
module *top_module;
#endif
/*pageinfo.c*/
long page_uid;
long page_inode;
long page_mtime;
/*post.c*/
int le_uploads;
/*strings.h*/
char *strtok_string;
char *strtok_pos1; /*STATIC VAR*/
char *strtok_pos2; /*STATIC VAR*/
#ifndef HAVE_STRERROR
char str_ebuf[40]; /*STATIC VAR*/
#endif
#if WIN32|WINNT
/*pwd.c*/
struct passwd pw; /* should we return a malloc()'d structure */
/*sendmail.c*/
char Buffer[MAIL_BUFFER_SIZE];
SOCKET sc;
WSADATA Data;
struct hostent *adr;
SOCKADDR_IN sock_in;
int WinsockStarted;
char *AppName;
char MailHost[HOST_NAME_LEN];
char LocalHost[HOST_NAME_LEN];
/*winsyslog.c*/
char *loghdr; /* log file header string */
HANDLE loghdl; /* handle of event source */
/*time.c*/
unsigned int proftimer,virttimer,realtimer;
LPMSG phpmsg;
/*winutil*/
char Win_Error_msg[256];
#endif
/*check for each module if it is compiled staticly
we should include their globals here.*/
} php3_globals_struct;
#ifdef THREAD_SAFE
extern DWORD TlsIndex;
extern int tls_create(void);
extern int tls_destroy(void);
/* these are from the flex scanner */
#ifndef YY_TLS_VARS
#define phptext php_gbl->text
#define phpleng php_gbl->leng
extern DWORD phpLexTlsIndex;
#define YY_TLS_VARS flex_globals *php_gbl = TlsGetValue(phpLexTlsIndex)
#endif
/* Other needed defines */
#if !defined(COMPILE_DL)
extern int phplex(pval *phplval, struct php3_global_struct *php3_globals, flex_globals *php_gbl);
#endif
#else
extern php3_globals_struct *php3_globals;
#endif
extern int tls_startup(void);
extern int tls_shutdown(void);
#endif

View File

@ -23,9 +23,6 @@
much useful things under MS-DOS, but using them avoids many "#ifdef
MSDOS" in ported UN*X code ... */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h" /*php specific */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

View File

@ -18,9 +18,6 @@
*
*/
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h" /*php specific */
#include <stdio.h>
#include <stdlib.h>

View File

@ -13,9 +13,7 @@
/* Include stuff ************************************************************ */
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "time.h"
#include "unistd.h"
#include "signal.h"

View File

@ -1,9 +1,3 @@
#ifdef THREAD_SAFE
#include "tls.h"
#else
#define TLS_VARS
#define GLOBAL(a) a
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "winutil.h"
@ -14,16 +8,14 @@ static char Win_Error_msg[256];
char *php3_win_err(void)
{
TLS_VARS;
FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) GLOBAL(Win_Error_msg),
(LPTSTR) Win_Error_msg,
256,
NULL);
return GLOBAL(Win_Error_msg);
return Win_Error_msg;
}

View File

@ -50,9 +50,6 @@
* Lift a leg, Yunie. Luv ya forever!!!!
*/
#ifdef THREAD_SAFE
#include "tls.h"
#endif
#include "php.h" /*php specific */
#include "syslog.h"
#include <stdio.h>