rbb 99/10/21 07:31:29
Modified: src/lib/apr/include apr_portable.h src/lib/apr/locks/unix intraproc.c locks.c locks.h src/lib/apr/threadproc/unix thread.c threadcancel.c threadpriv.c threadproc.h Log: Modify APR so that if we build without threads, we do not create no-op functions. Revision Changes Path 1.9 +13 -3 apache-2.0/src/lib/apr/include/apr_portable.h Index: apr_portable.h =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_portable.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- apr_portable.h 1999/10/11 17:51:47 1.8 +++ apr_portable.h 1999/10/21 14:31:19 1.9 @@ -64,6 +64,7 @@ extern "C" { #endif /* __cplusplus */ +#include "apr_config.h" #include "apr_general.h" #include "apr_thread_proc.h" #include "apr_file_io.h" @@ -165,18 +166,23 @@ #else /* No Interprocess serialization, too bad. */ #endif +#if APR_HAS_THREADS + /* If no threads, no need for thread locks */ #if defined (USE_PTHREAD_SERIALIZE) pthread_mutex_t *intraproc; #endif +#endif }; typedef int ap_os_file_t; typedef DIR ap_os_dir_t; typedef int ap_os_sock_t; typedef struct os_lock_t ap_os_lock_t; +#if APR_HAS_THREADS && HAVE_PTHREAD_H typedef pthread_t ap_os_thread_t; -typedef pid_t ap_os_proc_t; typedef pthread_key_t ap_os_threadkey_t; +#endif +typedef pid_t ap_os_proc_t; typedef struct timeval ap_os_time_t; #endif @@ -184,19 +190,23 @@ ap_status_t ap_get_os_dir(ap_os_dir_t *, ap_dir_t *); ap_status_t ap_get_os_sock(ap_os_sock_t *, ap_socket_t *); ap_status_t ap_get_os_lock(ap_os_lock_t *, ap_lock_t *); -ap_status_t ap_get_os_thread(ap_os_thread_t *, ap_thread_t *); ap_status_t ap_get_os_proc(ap_os_proc_t *, ap_proc_t *); ap_status_t ap_get_os_time(ap_os_time_t **, ap_time_t *); +#if APR_HAS_THREADS && HAVE_PTHREAD_H +ap_status_t ap_get_os_thread(ap_os_thread_t *, ap_thread_t *); ap_status_t ap_get_os_threadkey(ap_os_threadkey_t *, ap_key_t *); +#endif ap_status_t ap_put_os_file(ap_file_t **, ap_os_file_t *, ap_context_t *); ap_status_t ap_put_os_dir(ap_dir_t **, ap_os_dir_t *, ap_context_t *); ap_status_t ap_put_os_sock(ap_socket_t **, ap_os_sock_t *, ap_context_t *); ap_status_t ap_put_os_lock(ap_lock_t **, ap_os_lock_t *, ap_context_t *); -ap_status_t ap_put_os_thread(ap_thread_t **, ap_os_thread_t *, ap_context_t *); ap_status_t ap_put_os_proc(ap_proc_t **, ap_os_proc_t *, ap_context_t *); ap_status_t ap_put_os_time(ap_time_t **, ap_os_time_t *, ap_context_t *); +#if APR_HAS_THREADS && HAVE_PTHREAD_H +ap_status_t ap_put_os_thread(ap_thread_t **, ap_os_thread_t *, ap_context_t *); ap_status_t ap_put_os_threadkey(ap_key_t **, ap_os_threadkey_t *, ap_context_t *); +#endif #ifdef __cplusplus } 1.7 +4 -1 apache-2.0/src/lib/apr/locks/unix/intraproc.c Index: intraproc.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/locks/unix/intraproc.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- intraproc.c 1999/10/12 19:21:10 1.6 +++ intraproc.c 1999/10/21 14:31:20 1.7 @@ -52,12 +52,14 @@ * project, please see <http://www.apache.org/>. * */ - +#include "apr_config.h" #include "apr_lock.h" #include "apr_general.h" #include "apr_lib.h" #include "locks.h" +#if APR_HAS_THREADS + #if defined (USE_PTHREAD_SERIALIZE) ap_status_t lock_intra_cleanup(void *data) @@ -119,4 +121,5 @@ } return stat; } +#endif #endif 1.11 +20 -0 apache-2.0/src/lib/apr/locks/unix/locks.c Index: locks.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/locks/unix/locks.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- locks.c 1999/10/15 14:20:01 1.10 +++ locks.c 1999/10/21 14:31:20 1.11 @@ -96,9 +96,13 @@ } if (type != APR_CROSS_PROCESS) { +#if APR_HAS_THREADS if ((stat = create_intra_lock(new)) != APR_SUCCESS) { return stat; } +#else + return APR_ENOTIMPL; +#endif } if (type != APR_INTRAPROCESS) { if ((stat = create_inter_lock(new)) != APR_SUCCESS) { @@ -118,9 +122,13 @@ { ap_status_t stat; if (lock->type != APR_CROSS_PROCESS) { +#if APR_HAS_THREADS if ((stat = lock_intra(lock)) != APR_SUCCESS) { return stat; } +#else + return APR_ENOTIMPL; +#endif } if (lock->type != APR_INTRAPROCESS) { if ((stat = lock_inter(lock)) != APR_SUCCESS) { @@ -140,9 +148,13 @@ ap_status_t stat; if (lock->type != APR_CROSS_PROCESS) { +#if APR_HAS_THREADS if ((stat = unlock_intra(lock)) != APR_SUCCESS) { return stat; } +#else + return APR_ENOTIMPL; +#endif } if (lock->type != APR_INTRAPROCESS) { if ((stat = unlock_inter(lock)) != APR_SUCCESS) { @@ -163,9 +175,13 @@ { ap_status_t stat; if (lock->type != APR_CROSS_PROCESS) { +#if APR_HAS_THREADS if ((stat = destroy_intra_lock(lock)) != APR_SUCCESS) { return stat; } +#else + return APR_ENOTIMPL; +#endif } if (lock->type != APR_INTRAPROCESS) { if ((stat = destroy_inter_lock(lock)) != APR_SUCCESS) { @@ -258,9 +274,11 @@ oslock->lock_it = lock->lock_it; oslock->unlock_it = lock->unlock_it; #endif +#if APR_HAS_THREADS #if defined (USE_PTHREAD_SERIALIZE) oslock->intraproc = lock->intraproc; #endif +#endif return APR_SUCCESS; } @@ -290,8 +308,10 @@ (*lock)->lock_it = thelock->lock_it; (*lock)->unlock_it = thelock->unlock_it; #endif +#if APR_HAS_THREADS #if defined (USE_PTHREAD_SERIALIZE) (*lock)->intraproc = thelock->intraproc; +#endif #endif return APR_SUCCESS; } 1.5 +8 -0 apache-2.0/src/lib/apr/locks/unix/locks.h Index: locks.h =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/locks/unix/locks.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- locks.h 1999/10/04 16:36:58 1.4 +++ locks.h 1999/10/21 14:31:21 1.5 @@ -72,7 +72,9 @@ #include <stdio.h> #include <fcntl.h> #endif +#if APR_HAS_THREADS && HAVE_PTHREAD_H #include <pthread.h> +#endif #ifndef HAVE_UNION_SEMUN /* it makes no sense, but this isn't defined on solaris */ @@ -103,18 +105,24 @@ #else /* No Interprocess serialization. Too bad. */ #endif +#if APR_HAS_THREADS + /* APR doesn't have threads, no sense in having an thread lock mechanism. + */ #if defined (USE_PTHREAD_SERIALIZE) pthread_mutex_t *intraproc; #endif +#endif /* At some point, we should do a type for both inter and intra process * locking here. Something like pthread_mutex with PTHREAD_PROCESS_SHARED */ }; +#if APR_HAS_THREADS ap_status_t create_intra_lock(struct lock_t *new); ap_status_t lock_intra(struct lock_t *lock); ap_status_t unlock_intra(struct lock_t *lock); ap_status_t destroy_intra_lock(struct lock_t *lock); +#endif ap_status_t create_inter_lock(struct lock_t *new); ap_status_t lock_inter(struct lock_t *lock); 1.8 +6 -79 apache-2.0/src/lib/apr/threadproc/unix/thread.c Index: thread.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/threadproc/unix/thread.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- thread.c 1999/10/15 14:20:23 1.7 +++ thread.c 1999/10/21 14:31:22 1.8 @@ -53,6 +53,10 @@ * */ +#include "apr_config.h" + +#ifdef APR_HAS_THREADS + #include "threadproc.h" #include "apr_thread_proc.h" #include "apr_general.h" @@ -289,84 +293,7 @@ } (*thd)->td = thethd; return APR_SUCCESS; -} -#else - /* No pthread.h, no threads for right now.*/ -ap_status_t ap_create_threadattr(struct threadattr_t **new, ap_context_t *cont) -{ - *new = NULL; - return APR_SUCCESS; -} - -ap_status_t ap_setthreadattr_detach(struct threadattr_t *attr, ap_int32_t on) -{ - return APR_SUCCESS; -} - -ap_status_t ap_getthreadattr_detach(struct threadattr_t *attr) -{ - return APR_NOTDETACH; -} - -ap_status_t ap_create_thread(struct thread_t **new, struct threadattr_t *attr, - ap_thread_start_t func, void *data, - ap_context_t *cont) -{ - *new = NULL; - return stat; -} - -ap_status_t ap_thread_exit(ap_thread_t *thd, ap_status_t *retval) -{ - APR_SUCCESS; -} - -ap_status_t ap_thread_join(ap_status_t *retval, struct thread_t *thd) -{ - return APR_SUCCESS; -} - -ap_status_t ap_thread_detach(struct thread_t *thd) -{ - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_threaddata(void **, char *, ap_thread_t *) - * Return the context associated with the current thread. - * arg 1) The currently open thread. - * arg 2) The user data associated with the thread. - */ -ap_status_t ap_get_threaddata(void **data, char *key, struct thread_t *thread) -{ - data = NULL; - return APR_ENOTHREAD; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_set_threaddata(ap_thread_t *, void *, char *, - ap_status_t (*cleanup) (void *)) - * Return the context associated with the current thread. - * arg 1) The currently open thread. - * arg 2) The user data to associate with the thread. - */ -ap_status_t ap_set_threaddata(void *data, char *key, - ap_status_t (*cleanup) (void *), - struct thread_t *thread) -{ - return APR_ENOTHREAD; -} - -ap_status_t ap_get_os_thread(ap_os_thread_t *thethd, struct thread_t *thd) -{ - thethd = NULL; - return APR_SUCCESS; -} - -ap_status_t ap_put_os_thread(ap_context_t *cont, struct thread_t **thd, - ap_os_thread_t *thethd) -{ - return APR_SUCCESS; } -#endif +#endif /* HAVE_PTHREAD_H */ +#endif /* APR_HAS_THREADS */ 1.4 +3 -16 apache-2.0/src/lib/apr/threadproc/unix/threadcancel.c Index: threadcancel.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/threadproc/unix/threadcancel.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- threadcancel.c 1999/10/11 17:52:19 1.3 +++ threadcancel.c 1999/10/21 14:31:22 1.4 @@ -53,6 +53,8 @@ * */ +#if APR_HAS_THREADS + #include "threadproc.h" #include "apr_thread_proc.h" #include "apr_general.h" @@ -112,20 +114,5 @@ return stat; } } -#else -ap_status_t ap_cancel_thread(struct thread_t *thd) -{ - return APR_SUCCESS; -} - -ap_status_t ap_setcanceltype(ap_int32_t type, ap_context_t *cont) -{ - return APR_SUCCESS; -} - -ap_status_t ap_setcancelstate(ap_int32_t type, ap_context_t *cont) -{ - return APR_SUCCESS; -} #endif - +#endif 1.8 +4 -59 apache-2.0/src/lib/apr/threadproc/unix/threadpriv.c Index: threadpriv.c =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/threadproc/unix/threadpriv.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- threadpriv.c 1999/10/15 14:20:24 1.7 +++ threadpriv.c 1999/10/21 14:31:23 1.8 @@ -53,6 +53,7 @@ * */ +#include "apr_config.h" #include "threadproc.h" #include "apr_thread_proc.h" #include "apr_general.h" @@ -60,6 +61,8 @@ #include "apr_portable.h" #include "apr_lib.h" +#if APR_HAS_THREADS + #ifdef HAVE_PTHREAD_H /* ***APRDOC******************************************************** * ap_status_t ap_create_thread_private(ap_context_t *, void *(void *), @@ -203,64 +206,6 @@ } (*key)->key = *thekey; return APR_SUCCESS; -} -#else -ap_status_t ap_create_thread_private(struct threadkey_t **key, - void (*dest)(void *), ap_context_t *cont) -{ - *key = NULL; - return APR_SUCCESS; -} - -ap_status_t ap_get_thread_private(void **new, struct threadkey_t *key) -{ - (*new) = NULL; - return APR_SUCCESS; -} - -ap_status_t ap_set_thread_private(void *priv, struct threadkey_t *key) -{ - return APR_SUCCESS; -} - -ap_status_t ap_delete_thread_private(struct threadkey_t *key) -{ - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_get_threadkeydata(ap_threadkey_t *, void *) - * Return the context associated with the current threadkey. - * arg 1) The currently open threadkey. - * arg 2) The user data associated with the threadkey. - */ -ap_status_t ap_get_threadkeydata(void **data, char *key, struct threadkey_t *threadkey) -{ - return APR_SUCCESS; -} - -/* ***APRDOC******************************************************** - * ap_status_t ap_set_threadkeydata(ap_threadkey_t *, void *) - * Return the context associated with the current threadkey. - * arg 1) The currently open threadkey. - * arg 2) The user data to associate with the threadkey. - */ -ap_status_t ap_set_threadkeydata(void *data, - char *key, ap_status_t (*cleanup) (void *), - struct threadkey_t *threadkey) -{ - return APR_SUCCESS; -} - -ap_status_t ap_get_os_threadkey(ap_os_threadkey_t *thekey, struct threadkey_t *key) -{ - thekey = NULL; - return APR_SUCCESS; -} - -ap_status_t ap_put_os_threadkey(struct threadkey_t **key, - ap_os_threadkey_t *thekey, ap_context_t *cont) -{ - return APR_SUCCESS; } +#endif #endif 1.4 +3 -1 apache-2.0/src/lib/apr/threadproc/unix/threadproc.h Index: threadproc.h =================================================================== RCS file: /home/cvs/apache-2.0/src/lib/apr/threadproc/unix/threadproc.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- threadproc.h 1999/10/04 16:37:40 1.3 +++ threadproc.h 1999/10/21 14:31:26 1.4 @@ -52,7 +52,7 @@ * project, please see <http://www.apache.org/>. * */ - +#include "apr_config.h" #include "apr_thread_proc.h" #include "apr_file_io.h" #include <pthread.h> @@ -62,6 +62,7 @@ #define SHELL_PATH "/bin/sh" +#if APR_HAS_THREADS struct thread_t { ap_context_t *cntxt; pthread_t *td; @@ -76,6 +77,7 @@ ap_context_t *cntxt; pthread_key_t key; }; +#endif struct procattr_t { ap_context_t *cntxt;