Permalink
Browse files

This commit was manufactured by cvs2svn to create tag

'BEFORE_PHP4_APACHE_MODULE_CHANGE'.
  • Loading branch information...
1 parent 58a0ae7 commit bce48107d369a7fb016e75af9ca7ce8358778154 SVN Migration committed May 22, 1999
Showing with 0 additions and 18,505 deletions.
  1. +0 −4 TSRM/Makefile.am
  2. +0 −392 TSRM/TSRM.c
  3. +0 −100 TSRM/TSRM.dsp
  4. +0 −97 TSRM/TSRM.h
  5. +0 −7 TSRM/acconfig.h
  6. +0 −24 TSRM/buildconf
  7. +0 −24 TSRM/configure.in
  8. +0 −186 Zend/FlexLexer.h
  9. +0 −37 Zend/LICENSE
  10. +0 −26 Zend/Makefile.am
  11. +0 −111 Zend/ZEND_CHANGES
  12. +0 −258 Zend/ZendCore.dep
  13. +0 −50 Zend/acconfig.h
  14. +0 −20 Zend/acinclude.m4
  15. +0 −24 Zend/buildconf
  16. +0 −39 Zend/config.unix.h
  17. +0 −38 Zend/config.w32.h
  18. +0 −146 Zend/configure.in
  19. +0 −1,541 Zend/flex.skl
  20. +0 −363 Zend/libzend.dsp
  21. +0 −363 Zend/libzendts.dsp
  22. +0 −655 Zend/zend-parser.y
  23. +0 −48 Zend/zend-scanner.h
  24. +0 −1,465 Zend/zend-scanner.l
  25. +0 −360 Zend/zend.c
  26. +0 −225 Zend/zend.h
  27. BIN Zend/zend.ico
  28. +0 −795 Zend/zend_API.c
  29. +0 −104 Zend/zend_API.h
  30. +0 −550 Zend/zend_alloc.c
  31. +0 −123 Zend/zend_alloc.h
  32. +0 −1,910 Zend/zend_compile.c
  33. +0 −534 Zend/zend_compile.h
  34. +0 −241 Zend/zend_constants.c
  35. +0 −55 Zend/zend_constants.h
  36. +0 −33 Zend/zend_errors.h
  37. +0 −1,906 Zend/zend_execute.c
  38. +0 −71 Zend/zend_execute.h
  39. +0 −480 Zend/zend_execute_API.c
  40. +0 −149 Zend/zend_extensions.c
  41. +0 −98 Zend/zend_extensions.h
  42. +0 −231 Zend/zend_globals.h
  43. +0 −1,163 Zend/zend_hash.c
  44. +0 −153 Zend/zend_hash.h
  45. +0 −163 Zend/zend_highlight.c
  46. +0 −45 Zend/zend_highlight.h
  47. +0 −147 Zend/zend_indent.c
  48. +0 −22 Zend/zend_indent.h
  49. +0 −221 Zend/zend_list.c
  50. +0 −62 Zend/zend_list.h
  51. +0 −213 Zend/zend_llist.c
  52. +0 −55 Zend/zend_llist.h
  53. +0 −53 Zend/zend_modules.h
  54. +0 −392 Zend/zend_opcode.c
  55. +0 −1,342 Zend/zend_operators.c
  56. +0 −68 Zend/zend_operators.h
  57. +0 −74 Zend/zend_ptr_stack.c
  58. +0 −37 Zend/zend_ptr_stack.h
  59. +0 −36 Zend/zend_sprintf.c
  60. +0 −114 Zend/zend_stack.c
  61. +0 −39 Zend/zend_stack.h
  62. +0 −167 Zend/zend_variables.c
  63. +0 −38 Zend/zend_variables.h
  64. +0 −18 ext/pcre/config0.m4
View
@@ -1,4 +0,0 @@
-## process this file with automake to produce Makefile.am
-AUTOMAKE_OPTIONS=foreign
-lib_LIBRARIES=libtsrm.a
-libtsrm_a_SOURCES = TSRM.c
View
@@ -1,392 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | Thread Safe Resource Manager |
- +----------------------------------------------------------------------+
- | Copyright (c) 1998, 1999 Zeev Suraski |
- +----------------------------------------------------------------------+
- | This source file is subject to the Zend license, that is bundled |
- | with this package in the file LICENSE. If you did not receive a |
- | copy of the Zend license, please mail us at zend@zend.com so we can |
- | send you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Zeev Suraski <zeev@zend.com> |
- +----------------------------------------------------------------------+
-*/
-
-
-#include "TSRM.h"
-#include <stdio.h>
-#include <stdlib.h>
-
-#if HAVE_STDARG_H
-#include <stdarg.h>
-#endif
-
-typedef struct _tsrm_tls_entry tsrm_tls_entry;
-
-struct _tsrm_tls_entry {
- void **storage;
- int count;
- THREAD_T thread_id;
- tsrm_tls_entry *next;
-};
-
-
-typedef struct {
- size_t size;
- void (*ctor)(void *resource);
- void (*dtor)(void *resource);
-} tsrm_resource_type;
-
-
-/* The memory manager table */
-static tsrm_tls_entry **tsrm_tls_table;
-static int tsrm_tls_table_size;
-static ts_rsrc_id id_count;
-
-/* The resource sizes table */
-static tsrm_resource_type *resource_types_table;
-static int resource_types_table_size;
-
-
-static MUTEX_T tsmm_mutex; /* thread-safe memory manager mutex */
-
-/* Debug support */
-static int tsrm_debug(const char *format, ...);
-static int tsrm_debug_status;
-
-
-/* Startup TSRM (call once for the entire process) */
-TSRM_FUNC int tsrm_startup(int expected_threads, int expected_resources, int debug_status)
-{
- tsrm_tls_table_size = expected_threads;
- tsrm_tls_table = (tsrm_tls_entry **) calloc(tsrm_tls_table_size, sizeof(tsrm_tls_entry *));
- if (!tsrm_tls_table) {
- return 0;
- }
- id_count=0;
-
- resource_types_table_size = expected_resources;
- resource_types_table = (tsrm_resource_type *) calloc(resource_types_table_size, sizeof(tsrm_resource_type));
- if (!resource_types_table) {
- free(tsrm_tls_table);
- return 0;
- }
-
- tsmm_mutex = tsrm_mutex_alloc();
-
- tsrm_debug_status = debug_status;
-
- tsrm_debug("Started up TSRM, %d expected threads, %d expected resources\n", expected_threads, expected_resources);
- return 1;
-}
-
-
-/* Shutdown TSRM (call once for the entire process) */
-TSRM_FUNC void tsrm_shutdown()
-{
- int i;
-
- if (tsrm_tls_table) {
- for (i=0; i<tsrm_tls_table_size; i++) {
- tsrm_tls_entry *p = tsrm_tls_table[i], *next_p;
-
- while (p) {
- int j;
-
- next_p = p->next;
- for (j=0; j<id_count; j++) {
- free(p->storage[j]);
- }
- free(p->storage);
- free(p);
- p = next_p;
- }
- }
- free(tsrm_tls_table);
- }
- if (resource_types_table) {
- free(resource_types_table);
- }
- tsrm_mutex_free(tsmm_mutex);
- tsrm_debug("Shutdown TSRM\n");
-}
-
-
-/* allocates a new thread-safe-resource id */
-TSRM_FUNC ts_rsrc_id ts_allocate_id(size_t size, void (*ctor)(void *resource), void (*dtor)(void *resource))
-{
- ts_rsrc_id new_id;
- int i;
-
- tsrm_debug("Obtaining a new resource id, %d bytes\n", size);
-
- tsrm_mutex_lock(tsmm_mutex);
-
- /* obtain a resource id */
- new_id = id_count++;
- tsrm_debug("Obtained resource id %d\n", new_id);
-
- /* store the new resource type in the resource sizes table */
- if (resource_types_table_size < id_count) {
- resource_types_table = (tsrm_resource_type *) realloc(resource_types_table, sizeof(tsrm_resource_type)*id_count);
- if (!resource_types_table) {
- return -1;
- }
- resource_types_table_size = id_count;
- }
- resource_types_table[new_id].size = size;
- resource_types_table[new_id].ctor = ctor;
- resource_types_table[new_id].dtor = dtor;
-
- /* enlarge the arrays for the already active threads */
- for (i=0; i<tsrm_tls_table_size; i++) {
- tsrm_tls_entry *p = tsrm_tls_table[i];
-
- while (p) {
- if (p->count < id_count) {
- int j;
-
- p->storage = (void *) realloc(p->storage, sizeof(void *)*id_count);
- for (j=p->count; j<id_count; j++) {
- p->storage[j] = (void *) malloc(resource_types_table[j].size);
- if (resource_types_table[j].ctor) {
- resource_types_table[j].ctor(p->storage[j]);
- }
- }
- p->count = id_count;
- }
- p = p->next;
- }
- }
- tsrm_mutex_unlock(tsmm_mutex);
-
- tsrm_debug("Successfully allocated new resource id %d\n", new_id);
- return new_id;
-}
-
-
-static void allocate_new_resource(tsrm_tls_entry **thread_resources_ptr, THREAD_T thread_id)
-{
- int i;
-
- (*thread_resources_ptr) = (tsrm_tls_entry *) malloc(sizeof(tsrm_tls_entry));
- (*thread_resources_ptr)->storage = (void **) malloc(sizeof(void *)*id_count);
- (*thread_resources_ptr)->count = id_count;
- (*thread_resources_ptr)->thread_id = thread_id;
- (*thread_resources_ptr)->next = NULL;
- for (i=0; i<id_count; i++) {
- (*thread_resources_ptr)->storage[i] = (void *) malloc(resource_types_table[i].size);
- if (resource_types_table[i].ctor) {
- resource_types_table[i].ctor((*thread_resources_ptr)->storage[i]);
- }
- }
-}
-
-
-/* fetches the requested resource for the current thread */
-void *ts_resource(ts_rsrc_id id)
-{
- THREAD_T thread_id = tsrm_thread_id();
- int hash_value;
- tsrm_tls_entry *thread_resources;
- void *resource;
-
- tsrm_debug("Fetching resource id %d for thread %ld\n", id, (long) thread_id);
- tsrm_mutex_lock(tsmm_mutex);
-
- hash_value = THREAD_HASH_OF(thread_id, tsrm_tls_table_size);
- thread_resources = tsrm_tls_table[hash_value];
-
- if (!thread_resources) {
- allocate_new_resource(&tsrm_tls_table[hash_value], thread_id);
- thread_resources = tsrm_tls_table[hash_value];
- } else {
- do {
- if (thread_resources->thread_id == thread_id) {
- break;
- }
- if (thread_resources->next) {
- thread_resources = thread_resources->next;
- } else {
- allocate_new_resource(&thread_resources->next, thread_id);
- thread_resources = thread_resources->next;
- break;
- }
- } while (thread_resources);
- }
-
- resource = thread_resources->storage[id];
-
- tsrm_mutex_unlock(tsmm_mutex);
-
- tsrm_debug("Successfully fetched resource id %d for thread id %ld - %x\n", id, (long) thread_id, (long) resource);
- return resource;
-}
-
-
-/* frees all resources allocated for the current thread */
-void ts_free_thread()
-{
- THREAD_T thread_id = tsrm_thread_id();
- int hash_value;
- tsrm_tls_entry *thread_resources;
- tsrm_tls_entry *last=NULL;
-
- tsrm_mutex_lock(tsmm_mutex);
- hash_value = THREAD_HASH_OF(thread_id, tsrm_tls_table_size);
- thread_resources = tsrm_tls_table[hash_value];
-
- while (thread_resources) {
- if (thread_resources->thread_id == thread_id) {
- int i;
-
- for (i=0; i<thread_resources->count; i++) {
- if (resource_types_table[i].dtor) {
- resource_types_table[i].dtor(thread_resources->storage[i]);
- }
- free(thread_resources->storage[i]);
- }
- free(thread_resources->storage);
- if (last) {
- last->next = thread_resources->next;
- } else {
- tsrm_tls_table[hash_value]=NULL;
- }
- free(thread_resources);
- break;
- }
- if (thread_resources->next) {
- last = thread_resources;
- }
- thread_resources = thread_resources->next;
- }
- tsrm_mutex_unlock(tsmm_mutex);
-}
-
-
-/* deallocates all occurrences of a given id */
-void ts_free_id(ts_rsrc_id id)
-{
-}
-
-
-
-
-/*
- * Utility Functions
- */
-
-/* Obtain the current thread id */
-TSRM_FUNC THREAD_T tsrm_thread_id(void)
-{
-#ifdef WIN32
- return GetCurrentThreadId();
-#elif defined(PTHREADS)
- return pthread_self();
-#elif defined(NSAPI)
- return systhread_current();
-#elif defined(PI3WEB)
- return PIThread_getCurrent();
-#endif
-}
-
-
-/* Allocate a mutex */
-TSRM_FUNC MUTEX_T tsrm_mutex_alloc( void )
-{
- MUTEX_T mutexp;
-
-#ifdef WIN32
- mutexp = CreateMutex(NULL,FALSE,NULL);
-#elif defined(PTHREADS)
- mutexp = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
- pthread_mutex_init(mutexp,NULL);
-#elif defined(NSAPI)
- mutexp = crit_init();
-#elif defined(PI3WEB)
- mutexp = PIPlatform_allocLocalMutex();
-#endif
-#ifdef THR_DEBUG
- printf("Mutex created thread: %d\n",mythreadid());
-#endif
- return( mutexp );
-}
-
-
-/* Free a mutex */
-TSRM_FUNC void tsrm_mutex_free( MUTEX_T mutexp )
-{
- if (mutexp) {
-#ifdef WIN32
- CloseHandle(mutexp);
-#elif defined(PTHREADS)
- free(mutexp);
-#elif defined(NSAPI)
- crit_terminate(mutexp);
-#elif defined(PI3WEB)
- PISync_delete(mutexp)
-#endif
- }
-#ifdef THR_DEBUG
- printf("Mutex freed thread: %d\n",mythreadid());
-#endif
-}
-
-
-/* Lock a mutex */
-TSRM_FUNC int tsrm_mutex_lock( MUTEX_T mutexp )
-{
- //tsrm_debug("Mutex locked thread: %ld\n",tsrm_thread_id());
-#ifdef WIN32
- return WaitForSingleObject(mutexp,1000);
-#elif defined(PTHREADS)
- return pthread_mutex_lock(mutexp);
-#elif defined(NSAPI)
- return crit_enter(mutexp);
-#elif defined(PI3WEB)
- return PISync_lock(mutexp);
-#endif
-}
-
-
-/* Unlock a mutex */
-TSRM_FUNC int tsrm_mutex_unlock( MUTEX_T mutexp )
-{
- //tsrm_debug("Mutex unlocked thread: %ld\n",tsrm_thread_id());
-#ifdef WIN32
- return ReleaseMutex(mutexp);
-#elif defined(PTHREADS)
- return pthread_mutex_unlock(mutexp);
-#elif defined(NSAPI)
- return crit_exit(mutexp);
-#elif defined(PI3WEB)
- return PISync_unlock(mutexp);
-#endif
-}
-
-
-/*
- * Debug support
- */
-
-static int tsrm_debug(const char *format, ...)
-{
- if (tsrm_debug_status) {
- va_list args;
- int size;
-
- va_start(args, format);
- size = vprintf(format, args);
- va_end(args);
- return size;
- } else {
- return 0;
- }
-}
-
-
-void tsrm_debug_set(int status)
-{
- tsrm_debug_status = status;
-}
Oops, something went wrong.

0 comments on commit bce4810

Please sign in to comment.