📄 ost_pthread.m4
字号:
dnl Copyright (C) 1999-2000 Open Source Telecom Corporation.dnl dnl This program is free software; you can redistribute it and/or modifydnl it under the terms of the GNU General Public License as published bydnl the Free Software Foundation; either version 2 of the License, ordnl (at your option) any later version.dnl dnl This program is distributed in the hope that it will be useful,dnl but WITHOUT ANY WARRANTY; without even the implied warranty ofdnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See thednl GNU General Public License for more details.dnl dnl You should have received a copy of the GNU General Public Licensednl along with this program; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.dnl dnl As a special exception to the GNU General Public License, if you dnl distribute this file as part of a program that contains a configuration dnl script generated by Autoconf, you may include it under the same dnl distribution terms that you use for the rest of that program.AC_DEFUN(OST_LIB_PTHREAD,[ AC_REQUIRE([OST_SYS_POSIX]) AC_REQUIRE([OST_HEADER_SYSTIME]) THREAD_FLAGS="-D_REENTRANT -D_THREAD_SAFE" THREAD_LIBS= AC_CHECK_HEADERS(pthread.h, ost_cv_posix_threads=yes, ost_cv_posix_threads=no) if test $ost_cv_posix_threads = yes ; then AC_CACHE_CHECK(whether ${CC-cc} accepts -pthread, ost_cv_prog_cc_pthread, [echo 'void f(){}' >conftest.c if test -z "`${CC-cc} -pthread -c conftest.c 2>&1`"; then ost_cv_prog_cc_pthread=yes else ost_cv_prog_cc_pthread=no fi rm -f conftest* ]) ost_cv_thread_library=none AC_CHECK_LIB(pthread, pthread_self, ost_cv_thread_library=pthread, AC_CHECK_LIB(pthreads, pthread_self, ost_cv_thread_library=pthreads)) if test $ost_cv_thread_library = none ; then AC_CHECK_LIB(gthreads, pthread_self,[ AC_CHECK_LIB(malloc, malloc) ost_cv_thread_library=gthreads]) fi if test $ost_cv_thread_library = none ; then AC_CHECK_LIB(cma, pthread_self, ost_cv_thread_library=cma) fi if test $ost_cv_thread_library = none ; then AC_CHECK_LIB(c_r, pthread_self, ost_cv_thread_library=c_r) fi if test $ost_cv_thread_library = none ; then AC_CHECK_LIB(c, pthread_self, ost_cv_thread_library=c) fi if test $ost_cv_thread_library = none ; then AC_MSG_ERROR(no library for posix threads found!) fi AC_CHECK_LIB($ost_cv_thread_library, nanosleep, AC_DEFINE(HAVE_PTHREAD_NANOSLEEP),[ AC_CHECK_LIB(posix4, nanosleep,[ AC_DEFINE(HAVE_PTHREAD_NANOSLEEP) THREAD_LIBS="$THREAD_LIBS -lposix4" ]) ]) if test $ost_cv_thread_library = c_r ; then if test $ost_cv_prog_cc_pthread = yes ; then ost_cv_thread_library=c fi fi if test $ost_cv_thread_library != c ; then THREAD_LIBS="$THREAD_LIBS -l$ost_cv_thread_library" fi if test $ost_cv_prog_cc_pthread = yes ; then THREAD_FLAGS="$THREAD_FLAGS -pthread" fi AC_SUBST(THREAD_FLAGS) AC_SUBST(THREAD_LIBS) AC_CHECK_HEADERS(pthread_np.h) AC_CHECK_HEADERS(semaphore.h) AC_CHECK_HEADERS(sched.h) AC_CHECK_HEADERS(sys/sched.h) AC_CACHE_CHECK("for recursive mutex type support", ost_cv_mutex_recursive, [ ost_cv_mutex_recursive="none" AC_TRY_COMPILE( [#include <pthread.h>], [return PTHREAD_MUTEXTYPE_RECURSIVE;], ost_cv_mutex_recursive="portable", [ AC_EGREP_HEADER(PTHREAD_MUTEXTYPE_RECURSIVE_NP,pthread.h, ost_cv_mutex_recursive=non-portable) AC_EGREP_HEADER(PTHREAD_MUTEX_RECURSIVE_NP,pthread.h, ost_cv_mutex_recursive=linux) AC_EGREP_HEADER(MUTEX_TYPE_COUNTING_FAST,pthread.h, ost_cv_mutex_recursive=counting) ]) rm -f conftest* ]) if test $ost_cv_mutex_recursive = "none" ; then AC_TRY_COMPILE( [#include <pthread.h>], [return MUTEX_TYPE_COUNTING_FAST;], ost_cv_mutex_recursive=counting) fi case $ost_cv_mutex_recursive in non-portable) AC_DEFINE(PTHREAD_MUTEXTYPE_RECURSIVE, PTHREAD_MUTEXTYPE_RECURSIVE_NP) ;; linux) AC_DEFINE(PTHREAD_MUTEXTYPE_RECURSIVE, PTHREAD_MUTEX_RECURSIVE_NP) ;; counting) AC_DEFINE(PTHREAD_MUTEXTYPE_RECURSIVE, MUTEX_TYPE_COUNTING_FAST) ;; esac AC_CHECK_LIB($ost_cv_thread_library, pthread_mutexattr_settype, AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_SETTYPE), [ AC_CHECK_LIB($ost_cv_thread_library, pthread_mutexattr_settype_np, AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_SETTYPE_NP)) AC_CHECK_LIB($ost_cv_thread_library, pthread_mutexattr_setkind_np, AC_DEFINE(HAVE_PTHREAD_MUTEXATTR_SETKIND_NP)) ] ) AC_CHECK_LIB($ost_cv_thread_library, pthread_attr_setstacksize, AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACKSIZE)) AC_CHECK_LIB($ost_cv_thread_library, pthread_yield, AC_DEFINE(HAVE_PTHREAD_YIELD),[ AC_CHECK_LIB($ost_cv_thread_library, sched_yield, AC_DEFINE(HAVE_PTHREAD_SCHED_YIELD)) ]) AC_CHECK_LIB($ost_cv_thread_library, pthread_cancel,[ AC_DEFINE(HAVE_PTHREAD_CANCEL) AC_CHECK_LIB($ost_cv_thread_library, pthread_setcanceltype, AC_DEFINE(HAVE_PTHREAD_SETCANCELTYPE), AC_CHECK_LIB($ost_cv_thread_library, pthread_setcanel, AC_DEFINE(HAVE_PTHREAD_SETCANCEL))) ]) AC_CHECK_LIB($ost_cv_thread_library, pthread_delay_np, AC_DEFINE(HAVE_PTHREAD_DELAY_NP)) fi])dnl ACCONFIG TEMPLATEdnl #undef PTHREAD_MUTEXTYPE_RECURSIVEdnl #undef HAVE_PTHREAD_MUTEXATTR_SETTYPEdnl #undef HAVE_PTHREAD_MUTEXATTR_SETTYPE_NPdnl #undef HAVE_PTHREAD_MUTEXATTR_SETKIND_NPdnl #undef HAVE_PTHREAD_ATTR_SETSTACKSIZEdnl #undef HAVE_PTHREAD_DELAY_NPdnl #undef HAVE_PTHREAD_SCHED_YIELDdnl #undef HAVE_PTHREAD_YIELDdnl #undef HAVE_PTHREAD_NANOSLEEPdnl #undef HAVE_PTHREAD_CANCELdnl #undef HAVE_PTHREAD_SETCANCELTYPEdnl #undef HAVE_PTHREAD_SETCANCELdnl END ACCONFIGdnl ACCONFIG BOTTOMdnl dnl #if defined(__SVR4) && defined(__sun)dnl #define _THR_SUNOS5dnl #elsednl #if defined(__SVR4__) && defined(__SUN__)dnl #define _THR_SUNOS5dnl #endifdnl #endifdnl #ifdef _THR_SUNOS5dnl #include "/usr/include/thread.h"dnl #endifdnl dnl #if defined(HAVE_PTHREAD_H) && defined(_THREAD_SAFE)dnl #ifndef __USE_UNIX98dnl #define __USE_UNIX98dnl #include <pthread.h>dnl #undef __USE_UNIX98dnl #elsednl #include <pthread.h>dnl #endifdnl #ifdef HAVE_PTHREAD_NP_Hdnl #include <pthread_np.h>dnl #endifdnl #ifdef HAVE_SEMAPHORE_Hdnl #include <semaphore.h>dnl #endifdnl #ifdef _POSIX_PRIORITY_SCHEDULINGdnl #ifdef HAVE_SCHED_Hdnl #include <sched.h>dnl #elsednl #ifdef HAVE_SYS_SCHED_Hdnl #include <sys/sched.h>dnl #endifdnl #endifdnl #endifdnl dnl #define __PTHREAD_H__dnl #ifndef PTHREAD_MUTEXTYPE_RECURSIVEdnl #ifdef MUTEX_TYPE_COUNTING_FASTdnl #define PTHREAD_MUTEXTYPE_RECURSIVE MUTEX_TYPE_COUNTING_FASTdnl #endifdnl #endifdnl #ifndef HAVE_PTHREAD_MUTEXATTR_SETTYPEdnl #if HAVE_PTHREAD_MUTEXATTR_SETKIND_NPdnl #ifndef PTHREAD_MUTEXTYPE_RECURSIVEdnl #define PTHREAD_MUTEXTYPE_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NPdnl #endifdnl #define pthread_mutexattr_gettype(x, y) pthread_mutexattr_getkind_np(x, y)dnl #define pthread_mutexattr_settype(x, y) pthread_mutexattr_setkind_np(x, y)dnl #endif dnl #if HAVE_PTHREAD_MUTEXATTR_SETTYPE_NPdnl #ifndef PTHREAD_MUTEXTYPE_RECURSIVEdnl #define PTHREAD_MUTEXTYPE_RECURSIVE PTHREAD_MUTEXTYPE_RECURSIVE_NPdnl #endifdnl #define pthread_mutexattr_settype(x, y) pthread_mutexattr_settype_np(x, y)dnl #define pthread_mutexattr_gettype(x, y) pthread_mutexattr_gettype_np(x, y)dnl #endifdnl #endifdnl dnl #ifndef HAVE_PTHREAD_YIELDdnl #ifdef HAVE_PTHREAD_SCHED_YIELDdnl #define pthread_yield() sched_yield()dnl #define HAVE_PTHREAD_YIELDdnl #endifdnl #endifdnl dnl #ifndef HAVE_PTHREAD_DELAYdnl #ifdef HAVE_PTHREAD_DELAY_NPdnl #define HAVE_PTHREAD_DELAYdnl #define pthread_delay(x) pthread_delay_np(x)dnl #endifdnl #ifdef HAVE_PTHREAD_NANOSLEEPdnl #ifndef HAVE_PTHREAD_DELAYdnl #define HAVE_PTHREAD_DELAYdnl #define pthread_delay(x) nanosleep(x, NULL)dnl #endifdnl #endifdnl #endifdnl dnl #ifdef HAVE_PTHREAD_ATTR_SETSTACKdnl #ifndef PTHREAD_STACK_MINdnl #define PTHREAD_STACK_MIN 8192dnl #endifdnl #endifdnl dnl #ifndef HAVE_PTHREAD_CANCELdnl #ifdef SIGCANCELdnl #define _SIG_THREAD_CANCEL SIGCANCELdnl #elsednl #define _SIG_THREAD_CANCEL SIGQUITdnl #endifdnl #define pthread_cancel(x) pthread_kill(x, _SIG_THREAD_CANCEL)dnl #endifdnl dnl #ifndef HAVE_PTHREAD_SETCANCELTYPEdnl #ifdef HAVE_PTHREAD_SETCANCELdnl enumdnl { PTHREAD_CANCEL_ASYNCHRONOUS = CANCEL_ON,dnl PTHREAD_CANCEL_DEFERRED = CANCEL_OFF};dnl enumdnl { PTHREAD_CANCEL_ENABLE = CANCEL_ON,dnl PTHREAD_CANCEL_DISABLE = CANCEL_OFF};dnl #define pthread_setcancelstate(x, y) \dnl (y == NULL) ? pthread_setcancel(x) : *y = pthread_setcanceldnl #define pthread_setcanceltype(x, y) \dnl (y == NULL) ? pthread_setasynccancel(x) | *y = pthread_setasynccancel(x)dnl #elsednl #define pthread_setcanceltype(x, y)dnl #define pthread_setcancelstate(x, y)dnl #endifdnl #endifdnl dnl #endifdnl dnl END ACCONFIG
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -