diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-10-19 08:54:23 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-10-19 11:10:59 +0300 |
commit | ffd2f9fe0e7641596e586ce92b0fd3804adec2cd (patch) | |
tree | 2a27956414e000c908bb7299955988cee96698b8 /malloc.c | |
parent | 95b934dbdae5883f589da6cf4e5a4d27aa575204 (diff) | |
download | bdwgc-ffd2f9fe0e7641596e586ce92b0fd3804adec2cd.tar.gz |
Remove false warning of missing libpthread.so on Linux
Issue #477 (bdwgc).
Some libc implementations like bionic, uclib and glibc 2.34 (and later)
do not have libpthread.so because the pthreads-related code is located
in libc.so, thus potential calloc calls from such code are forwarded
to real (libc) calloc without any special handling on the libgc side.
* malloc.c [REDIRECT_MALLOC && !REDIRECT_MALLOC_IN_HEADER
&& GC_LINUX_THREADS] (GC_init_lib_bounds): Do not call WARN to report
missing libpthread.so if __UCLIBC__ or not defined __GLIBC__ or glibc
version is 2.34 or above; add comment and TODO item.
Diffstat (limited to 'malloc.c')
-rw-r--r-- | malloc.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -469,9 +469,19 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_uncollectable(size_t lb) GC_init(); /* if not called yet */ if (!GC_text_mapping("libpthread-", &GC_libpthread_start, &GC_libpthread_end)) { + /* Some libc implementations like bionic, uclib and glibc 2.34 */ + /* do not have libpthread.so because the pthreads-related code */ + /* is located in libc.so, thus potential calloc calls from such */ + /* code are forwarded to real (libc) calloc without any special */ + /* handling on the libgc side. Checking glibc version at */ + /* compile time to turn off the warning seems to be fine. */ + /* TODO: Remove GC_text_mapping() call for this case. */ +# if defined(__GLIBC__) && !defined(__UCLIBC__) \ + && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 34)) WARN("Failed to find libpthread.so text mapping: Expect crash\n", 0); - /* This might still work with some versions of libpthread, */ - /* so we don't abort. Perhaps we should. */ + /* This might still work with some versions of libpthread, */ + /* so we do not abort. */ +# endif } if (!GC_text_mapping("ld-", &GC_libld_start, &GC_libld_end)) { WARN("Failed to find ld.so text mapping: Expect crash\n", 0); |