check pthread_rwlockattr_getkind_np for porting

posix_api
YuQing 2022-01-28 12:44:21 +08:00
parent 013b7888ea
commit a39005253b
3 changed files with 23 additions and 4 deletions

View File

@ -12,6 +12,6 @@ Chinese language: http://www.fastken.com/
# the command lines as: # the command lines as:
git clone https://github.com/happyfish100/libfastcommon.git git clone https://github.com/happyfish100/libfastcommon.git
cd libfastcommon; git checkout V1.0.48 cd libfastcommon; git checkout V1.0.55
./make.sh clean && ./make.sh && ./make.sh install ./make.sh clean && ./make.sh && ./make.sh install

23
make.sh
View File

@ -138,10 +138,29 @@ cat <<EOF > src/_os_define.h
#endif #endif
EOF EOF
if [ -f /usr/lib/libpthread.so ] || [ -f /usr/local/lib/libpthread.so ] || [ -f /usr/lib64/libpthread.so ] || [ -f /usr/lib/libpthread.a ] || [ -f /usr/local/lib/libpthread.a ] || [ -f /usr/lib64/libpthread.a ]; then pthread_path=''
for path in /lib /lib64 /usr/lib /usr/lib64 /usr/local/lib; do
if [ -d $path ]; then
pthread_path=$(find $path -name libpthread.so | head -n 1)
if [ -n "$pthread_path" ]; then
break
fi
pthread_path=$(find $path -name libpthread.a | head -n 1)
if [ -n "$pthread_path" ]; then
break
fi
fi
done
if [ -n "$pthread_path" ]; then
LIBS="$LIBS -lpthread" LIBS="$LIBS -lpthread"
line=$(nm $pthread_path | fgrep pthread_rwlockattr_getkind_np | fgrep -w T)
if [ -n "$line" ]; then
CFLAGS="$CFLAGS -DWITH_PTHREAD_RWLOCKATTR_GETKIND_NP=1"
fi
elif [ -f /usr/lib/libc_r.so ]; then elif [ -f /usr/lib/libc_r.so ]; then
line=`nm -D /usr/lib/libc_r.so | grep pthread_create | grep -w T` line=$(nm -D /usr/lib/libc_r.so | grep pthread_create | grep -w T)
if [ -n "$line" ]; then if [ -n "$line" ]; then
LIBS="$LIBS -lc_r" LIBS="$LIBS -lc_r"
fi fi

View File

@ -80,7 +80,7 @@ int init_pthread_rwlock(pthread_rwlock_t *rwlock)
int result; int result;
#ifdef OS_LINUX #ifdef WITH_PTHREAD_RWLOCKATTR_GETKIND_NP
attr.ptr = &attr.holder; attr.ptr = &attr.holder;
if ((result=pthread_rwlockattr_init(attr.ptr)) != 0) { if ((result=pthread_rwlockattr_init(attr.ptr)) != 0) {
logError("file: "__FILE__", line: %d, " logError("file: "__FILE__", line: %d, "