summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbael He <abaelhe@icloud.com>2022-08-25 11:12:08 +0800
committerQi Wang <interwq@gmail.com>2022-09-07 11:56:41 -0700
commit56ddbea270e5c73ba5a4977550e02c2b3706ae80 (patch)
tree00abe412d6702116a9bf165cbbabe8140bea2193
parentce29b4c3d9256956a8d60302b5d1fa72c3479686 (diff)
downloadjemalloc-56ddbea270e5c73ba5a4977550e02c2b3706ae80.tar.gz
error: implicit declaration of function 'pthread_create_fptr_init' is invalid in C99
./autogen.sh \ && ./configure --prefix=/usr/local --enable-static --enable-autogen --enable-xmalloc --with-static-libunwind=/usr/local/lib/libunwind.a --enable-lazy-lock --with-jemalloc-prefix='' \ && make -j16 ... gcc -std=gnu11 -Werror=unknown-warning-option -Wall -Wextra -Wshorten-64-to-32 -Wsign-compare -Wundef -Wno-format-zero-length -Wpointer-arith -Wno-missing-braces -Wno-missing-field-initializers -pipe -g3 -Wimplicit-fallthrough -O3 -funroll-loops -fPIC -DPIC -c -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/edata_cache.sym.o src/edata_cache.c src/background_thread.c:768:6: error: implicit declaration of function 'pthread_create_fptr_init' is invalid in C99 [-Werror,-Wimplicit-function-declaration] pthread_create_fptr_init()) { ^ src/background_thread.c:768:6: note: did you mean 'pthread_create_wrapper_init'? src/background_thread.c:34:1: note: 'pthread_create_wrapper_init' declared here pthread_create_wrapper_init(void) { ^ 1 error generated. make: *** [src/background_thread.sym.o] Error 1 make: *** Waiting for unfinished jobs....
-rw-r--r--src/background_thread.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/background_thread.c b/src/background_thread.c
index f22174d6..3171dd31 100644
--- a/src/background_thread.c
+++ b/src/background_thread.c
@@ -46,6 +46,39 @@ pthread_create_wrapper(pthread_t *__restrict thread, const pthread_attr_t *attr,
return pthread_create_fptr(thread, attr, start_routine, arg);
}
+
+#ifdef JEMALLOC_HAVE_DLSYM
+#include <dlfcn.h>
+#endif
+
+static bool
+pthread_create_fptr_init(void) {
+ if (pthread_create_fptr != NULL) {
+ return false;
+ }
+ /*
+ * Try the next symbol first, because 1) when use lazy_lock we have a
+ * wrapper for pthread_create; and 2) application may define its own
+ * wrapper as well (and can call malloc within the wrapper).
+ */
+#ifdef JEMALLOC_HAVE_DLSYM
+ pthread_create_fptr = dlsym(RTLD_NEXT, "pthread_create");
+#else
+ pthread_create_fptr = NULL;
+#endif
+ if (pthread_create_fptr == NULL) {
+ if (config_lazy_lock) {
+ malloc_write("<jemalloc>: Error in dlsym(RTLD_NEXT, "
+ "\"pthread_create\")\n");
+ abort();
+ } else {
+ /* Fall back to the default symbol. */
+ pthread_create_fptr = pthread_create;
+ }
+ }
+
+ return false;
+}
#endif /* JEMALLOC_PTHREAD_CREATE_WRAPPER */
#ifndef JEMALLOC_BACKGROUND_THREAD
@@ -710,39 +743,6 @@ background_thread_stats_read(tsdn_t *tsdn, background_thread_stats_t *stats) {
#undef BILLION
#undef BACKGROUND_THREAD_MIN_INTERVAL_NS
-#ifdef JEMALLOC_HAVE_DLSYM
-#include <dlfcn.h>
-#endif
-
-static bool
-pthread_create_fptr_init(void) {
- if (pthread_create_fptr != NULL) {
- return false;
- }
- /*
- * Try the next symbol first, because 1) when use lazy_lock we have a
- * wrapper for pthread_create; and 2) application may define its own
- * wrapper as well (and can call malloc within the wrapper).
- */
-#ifdef JEMALLOC_HAVE_DLSYM
- pthread_create_fptr = dlsym(RTLD_NEXT, "pthread_create");
-#else
- pthread_create_fptr = NULL;
-#endif
- if (pthread_create_fptr == NULL) {
- if (config_lazy_lock) {
- malloc_write("<jemalloc>: Error in dlsym(RTLD_NEXT, "
- "\"pthread_create\")\n");
- abort();
- } else {
- /* Fall back to the default symbol. */
- pthread_create_fptr = pthread_create;
- }
- }
-
- return false;
-}
-
/*
* When lazy lock is enabled, we need to make sure setting isthreaded before
* taking any background_thread locks. This is called early in ctl (instead of