You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2022/02/02 10:02:27 UTC

svn commit: r1897689 - in /httpd/httpd/trunk: include/httpd.h server/util.c server/util_pcre.c

Author: ylavic
Date: Wed Feb  2 10:02:26 2022
New Revision: 1897689

URL: http://svn.apache.org/viewvc?rev=1897689&view=rev
Log:
core: Follow up to r1897240: Opt-out for AP_HAS_THREAD_LOCAL and/or pcre's usage.

If the compiler's thread_local is not efficient enough on some platforms, or
not desired, have a way to disable its usage in httpd (at compile time).

Handle -DAP_NO_THREAD_LOCAL and/or -DAPREG_NO_THREAD_LOCAL as build opt-out for
thread_local usage in httpd gobally and/or in ap_regex only (respectively).


Modified:
    httpd/httpd/trunk/include/httpd.h
    httpd/httpd/trunk/server/util.c
    httpd/httpd/trunk/server/util_pcre.c

Modified: httpd/httpd/trunk/include/httpd.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/httpd.h?rev=1897689&r1=1897688&r2=1897689&view=diff
==============================================================================
--- httpd/httpd/trunk/include/httpd.h (original)
+++ httpd/httpd/trunk/include/httpd.h Wed Feb  2 10:02:26 2022
@@ -2566,7 +2566,7 @@ AP_DECLARE(void *) ap_realloc(void *ptr,
 
 #if APR_HAS_THREADS
 
-#if APR_VERSION_AT_LEAST(1,8,0)
+#if APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL)
 
 /**
  * APR 1.8+ implement those already.
@@ -2581,8 +2581,9 @@ AP_DECLARE(void *) ap_realloc(void *ptr,
 #define ap_thread_current               apr_thread_current
 #define ap_thread_current_after_fork    apr_thread_current_after_fork
 
-#else  /* !APR_VERSION_AT_LEAST(1,8,0) */
+#else /* APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL) */
 
+#ifndef AP_NO_THREAD_LOCAL
 /**
  * AP_THREAD_LOCAL keyword mapping the compiler's.
  */
@@ -2595,6 +2596,7 @@ AP_DECLARE(void *) ap_realloc(void *ptr,
 #elif defined(WIN32) && defined(_MSC_VER)
 #define AP_THREAD_LOCAL __declspec(thread)
 #endif
+#endif /* ndef AP_NO_THREAD_LOCAL */
 
 #ifndef AP_THREAD_LOCAL
 #define AP_HAS_THREAD_LOCAL 0
@@ -2610,16 +2612,16 @@ AP_DECLARE(apr_status_t) ap_thread_creat
 AP_DECLARE(void) ap_thread_current_after_fork(void);
 AP_DECLARE(apr_thread_t *) ap_thread_current(void);
 
-#endif /* !APR_VERSION_AT_LEAST(1,8,0) */
+#endif /* APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL) */
 
 AP_DECLARE(apr_status_t) ap_thread_main_create(apr_thread_t **thread,
                                                apr_pool_t *pool);
 
-#else  /* !APR_HAS_THREADS */
+#else  /* APR_HAS_THREADS */
 
 #define AP_HAS_THREAD_LOCAL 0
 
-#endif /* !APR_HAS_THREADS */
+#endif /* APR_HAS_THREADS */
 
 /**
  * Get server load params

Modified: httpd/httpd/trunk/server/util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util.c?rev=1897689&r1=1897688&r2=1897689&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util.c (original)
+++ httpd/httpd/trunk/server/util.c Wed Feb  2 10:02:26 2022
@@ -3263,11 +3263,11 @@ AP_DECLARE(void *) ap_realloc(void *ptr,
 
 #if APR_HAS_THREADS
 
-#if APR_VERSION_AT_LEAST(1,8,0)
+#if APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL)
 
 #define ap_thread_current_create apr_thread_current_create
 
-#else  /* !APR_VERSION_AT_LEAST(1,8,0) */
+#else /* APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL) */
 
 #if AP_HAS_THREAD_LOCAL
 
@@ -3357,7 +3357,7 @@ AP_DECLARE(apr_thread_t *) ap_thread_cur
 #endif
 }
 
-#endif /* !APR_VERSION_AT_LEAST(1,8,0) */
+#endif /* APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL) */
 
 static apr_status_t main_thread_cleanup(void *arg)
 {

Modified: httpd/httpd/trunk/server/util_pcre.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_pcre.c?rev=1897689&r1=1897688&r2=1897689&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_pcre.c (original)
+++ httpd/httpd/trunk/server/util_pcre.c Wed Feb  2 10:02:26 2022
@@ -313,7 +313,7 @@ void free_match_data(match_data_pt data,
 #endif
 }
 
-#if AP_HAS_THREAD_LOCAL
+#if AP_HAS_THREAD_LOCAL && !defined(APREG_NO_THREAD_LOCAL)
 
 struct apreg_tls {
     match_data_pt data;
@@ -380,7 +380,7 @@ static match_data_pt get_match_data(apr_
     return tls->data;
 }
 
-#else /* !AP_HAS_THREAD_LOCAL */
+#else /* AP_HAS_THREAD_LOCAL && !defined(APREG_NO_THREAD_LOCAL) */
 
 static APR_INLINE match_data_pt get_match_data(apr_size_t size,
                                                match_vector_pt small_vector,
@@ -390,7 +390,7 @@ static APR_INLINE match_data_pt get_matc
     return alloc_match_data(size, small_vector);
 }
 
-#endif /* !AP_HAS_THREAD_LOCAL */
+#endif /* AP_HAS_THREAD_LOCAL && !defined(APREG_NO_THREAD_LOCAL) */
 
 AP_DECLARE(int) ap_regexec(const ap_regex_t *preg, const char *string,
                            apr_size_t nmatch, ap_regmatch_t *pmatch,