From: Brian J. Murrell Date: Tue, 22 Jun 2010 19:09:31 +0000 (-0400) Subject: b=20355 formalize support for pthreads X-Git-Tag: v2_0_0-rc1~25 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=004cc2b4c6eb32672985e2f4b4bbf9413e314547 b=20355 formalize support for pthreads BG/P needs proper pthreads library arguments for linking, so properly support pthreads properly in configure, using AX_PTHREAD. The need for the pthread subdirs is because you cannot adjust the CC variable value used on a per target basis, only for an entire Makefile. This is the same problem we had with using the MPICC for some targets. So to make some targets compile with the CC that the AX_PTHREAD macro discovers/sets, we need to use a new Makefile. File locations remain the same however. i=panda (b1_8 version) i=whitebear (b1_8 version) --- diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index d764b23..a0739d4 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -846,31 +846,291 @@ else fi AC_SUBST(LIBEFENCE) +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_pthread.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +# +# DESCRIPTION +# +# This macro figures out how to build C programs using POSIX threads. It +# sets the PTHREAD_LIBS output variable to the threads library and linker +# flags, and the PTHREAD_CFLAGS output variable to any special C compiler +# flags that are needed. (The user can also force certain compiler +# flags/libs to be tested by setting these environment variables.) +# +# Also sets PTHREAD_CC to any special C compiler that is needed for +# multi-threaded programs (defaults to the value of CC otherwise). (This +# is necessary on AIX to use the special cc_r compiler alias.) +# +# NOTE: You are assumed to not only compile your program with these flags, +# but also link it with them as well. e.g. you should link with +# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS +# +# If you are only building threads programs, you may wish to use these +# variables in your default LIBS, CFLAGS, and CC: +# +# LIBS="$PTHREAD_LIBS $LIBS" +# CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +# CC="$PTHREAD_CC" +# +# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant +# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name +# (e.g. PTHREAD_CREATE_UNDETACHED on AIX). +# +# ACTION-IF-FOUND is a list of shell commands to run if a threads library +# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it +# is not found. If ACTION-IF-FOUND is not specified, the default action +# will define HAVE_PTHREAD. +# +# Please let the authors know if this macro fails on any platform, or if +# you have any other suggestions or comments. This macro was based on work +# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help +# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by +# Alejandro Forero Cuervo to the autoconf macro repository. We are also +# grateful for the helpful feedback of numerous users. +# +# LICENSE +# +# Copyright (c) 2008 Steven G. Johnson +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 8 + +AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) +AC_DEFUN([AX_PTHREAD], [ +AC_REQUIRE([AC_CANONICAL_HOST]) +AC_LANG_SAVE +AC_LANG_C +ax_pthread_ok=no + +# We used to check for pthread.h first, but this fails if pthread.h +# requires special compiler flags (e.g. on True64 or Sequent). +# It gets checked for in the link test anyway. + +# First of all, check if the user has set any of the PTHREAD_LIBS, +# etcetera environment variables, and if threads linking works using +# them: +if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) + AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes) + AC_MSG_RESULT($ax_pthread_ok) + if test x"$ax_pthread_ok" = xno; then + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" + fi + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" +fi -# -------- check for -lpthread support ---- -AC_MSG_CHECKING([whether to use libpthread for libcfs library]) -AC_ARG_ENABLE([libpthread], - AC_HELP_STRING([--disable-libpthread], - [disable libpthread]), - [],[enable_libpthread=yes]) -if test "$enable_libpthread" = "yes" ; then - AC_CHECK_LIB([pthread], [pthread_create], - [ENABLE_LIBPTHREAD="yes"], - [ENABLE_LIBPTHREAD="no"]) - if test "$ENABLE_LIBPTHREAD" = "yes" ; then - AC_MSG_RESULT([$ENABLE_LIBPTHREAD]) - PTHREAD_LIBS="-lpthread" - AC_DEFINE([HAVE_LIBPTHREAD], 1, [use libpthread]) - else - PTHREAD_LIBS="" - AC_MSG_RESULT([no libpthread is found]) +# We must check for the threads library under a number of different +# names; the ordering is very important because some systems +# (e.g. DEC) have both -lpthread and -lpthreads, where one of the +# libraries is broken (non-POSIX). + +# Create a list of thread flags to try. Items starting with a "-" are +# C compiler flags, and other items are library names, except for "none" +# which indicates that we try without any flags at all, and "pthread-config" +# which is a program returning the flags for the Pth emulation library. + +ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" + +# The ordering *is* (sometimes) important. Some notes on the +# individual items follow: + +# pthreads: AIX (must check this before -lpthread) +# none: in case threads are in libc; should be tried before -Kthread and +# other compiler flags to prevent continual compiler warnings +# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) +# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) +# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) +# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) +# -pthreads: Solaris/gcc +# -mthreads: Mingw32/gcc, Lynx/gcc +# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it +# doesn't hurt to check since this sometimes defines pthreads too; +# also defines -D_REENTRANT) +# ... -mt is also the pthreads flag for HP/aCC +# pthread: Linux, etcetera +# --thread-safe: KAI C++ +# pthread-config: use pthread-config program (for GNU Pth library) + +case "${host_cpu}-${host_os}" in + *solaris*) + + # On Solaris (at least, for some versions), libc contains stubbed + # (non-functional) versions of the pthreads routines, so link-based + # tests will erroneously succeed. (We need to link with -pthreads/-mt/ + # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather + # a function called by this macro, so we could check for that, but + # who knows whether they'll stub that too in a future libc.) So, + # we'll just look for -pthreads and -lpthread first: + + ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" + ;; + + *-darwin*) + ax_pthread_flags="-pthread $ax_pthread_flags" + ;; +esac + +if test x"$ax_pthread_ok" = xno; then +for flag in $ax_pthread_flags; do + + case $flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + + -*) + AC_MSG_CHECKING([whether pthreads work with $flag]) + PTHREAD_CFLAGS="$flag" + ;; + + pthread-config) + AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no) + if test x"$ax_pthread_config" = xno; then continue; fi + PTHREAD_CFLAGS="`pthread-config --cflags`" + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" + ;; + + *) + AC_MSG_CHECKING([for the pthreads library -l$flag]) + PTHREAD_LIBS="-l$flag" + ;; + esac + + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we + # need a special flag -Kthread to make this header compile.) + # We check for pthread_join because it is in -lpthread on IRIX + # while pthread_create is in libc. We check for pthread_attr_init + # due to DEC craziness with -lpthreads. We check for + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. + AC_TRY_LINK([#include + static void routine(void* a) {a=0;} + static void* start_routine(void* a) {return a;}], + [pthread_t th; pthread_attr_t attr; + pthread_join(th, 0); + pthread_attr_init(&attr); + pthread_cleanup_push(routine, 0); + pthread_create(&th,0,start_routine,0); + pthread_cleanup_pop(0); ], + [ax_pthread_ok=yes]) + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + AC_MSG_RESULT($ax_pthread_ok) + if test "x$ax_pthread_ok" = xyes; then + break; + fi + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi + +# Various other checks: +if test "x$ax_pthread_ok" = xyes; then + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. + AC_MSG_CHECKING([for joinable pthread attribute]) + attr_name=unknown + for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do + AC_TRY_LINK([#include ], [int attr=$attr; return attr;], + [attr_name=$attr; break]) + done + AC_MSG_RESULT($attr_name) + if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then + AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, + [Define to necessary symbol if this constant + uses a non-standard name on your system.]) + fi + + AC_MSG_CHECKING([if more special flags are required for pthreads]) + flag=no + case "${host_cpu}-${host_os}" in + *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; + *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; + esac + AC_MSG_RESULT(${flag}) + if test "x$flag" != xno; then + PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" + fi + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + # More AIX lossage: must compile with xlc_r or cc_r + if test x"$GCC" != xyes; then + AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) + else + PTHREAD_CC=$CC fi - AC_SUBST(PTHREAD_LIBS) else - AC_MSG_RESULT([no (disabled explicitly)]) - ENABLE_LIBPTHREAD="no" + PTHREAD_CC="$CC" +fi + +AC_SUBST(PTHREAD_LIBS) +AC_SUBST(PTHREAD_CFLAGS) +AC_SUBST(PTHREAD_CC) + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test x"$ax_pthread_ok" = xyes; then + ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) + : +else + ax_pthread_ok=no + $2 fi -AC_SUBST(ENABLE_LIBPTHREAD) +AC_LANG_RESTORE +])dnl AX_PTHREAD + +AX_PTHREAD([[]]) ]) diff --git a/libcfs/include/libcfs/posix/libcfs.h b/libcfs/include/libcfs/posix/libcfs.h index 18551ca..6191854 100644 --- a/libcfs/include/libcfs/posix/libcfs.h +++ b/libcfs/include/libcfs/posix/libcfs.h @@ -75,7 +75,7 @@ #include #endif -#ifdef HAVE_LIBPTHREAD +#ifdef HAVE_PTHREAD #include #endif diff --git a/libcfs/include/libcfs/user-lock.h b/libcfs/include/libcfs/user-lock.h index d6da6a5..ca6656f 100644 --- a/libcfs/include/libcfs/user-lock.h +++ b/libcfs/include/libcfs/user-lock.h @@ -236,7 +236,7 @@ typedef struct { volatile int counter; } cfs_atomic_t; ((v)->counter != u ? (v)->counter += a : 0) #define cfs_atomic_inc_not_zero(v) cfs_atomic_add_unless((v), 1, 0) -#ifdef HAVE_LIBPTHREAD +#ifdef HAVE_PTHREAD #include /* @@ -268,7 +268,7 @@ void cfs_mt_atomic_dec(cfs_mt_atomic_t *a); void cfs_mt_atomic_add(int b, cfs_mt_atomic_t *a); void cfs_mt_atomic_sub(int b, cfs_mt_atomic_t *a); -#endif /* HAVE_LIBPTHREAD */ +#endif /* HAVE_PTHREAD */ /************************************************************************** * diff --git a/libcfs/include/libcfs/user-prim.h b/libcfs/include/libcfs/user-prim.h index 9b2755c..d7ddd11 100644 --- a/libcfs/include/libcfs/user-prim.h +++ b/libcfs/include/libcfs/user-prim.h @@ -145,7 +145,7 @@ static inline int cfs_psdev_deregister(cfs_psdev_t *foo) #define cfs_kernel_thread(l,m,n) (LBUG(), l, 0) #define cfs_kthread_run(fn,d,fmt,...) LBUG() -#ifdef HAVE_LIBPTHREAD +#ifdef HAVE_PTHREAD typedef int (*cfs_thread_t)(void *); int cfs_create_thread(cfs_thread_t func, void *arg); #else diff --git a/libcfs/include/libcfs/util/platform.h b/libcfs/include/libcfs/util/platform.h index 8a17a83..52dcef5 100644 --- a/libcfs/include/libcfs/util/platform.h +++ b/libcfs/include/libcfs/util/platform.h @@ -60,7 +60,7 @@ extern void add_history(char *); #include #include -#if HAVE_LIBPTHREAD +#if HAVE_PTHREAD #include #include #include @@ -96,18 +96,18 @@ typedef VFunction rl_voidfunc_t; * POSIX compliant inter-process synchronization aren't supported well * in Darwin, pthread_mutex_t and pthread_cond_t can only work as * inter-thread synchronization, they wouldn't work even being put in - * shared memory for multi-process. PTHREAD_PROCESS_SHARED is not - * supported by Darwin also (pthread_mutexattr_setpshared() with the - * PTHREAD_PROCESS_SHARED attribute will return EINVAL). + * shared memory for multi-process. PTHREAD_PROCESS_SHARED is not + * supported by Darwin also (pthread_mutexattr_setpshared() with the + * PTHREAD_PROCESS_SHARED attribute will return EINVAL). * * The only inter-process sychronization mechanism can be used in Darwin * is POSIX NAMED semaphores and file lock, here we use NAMED semaphore - * to implement mutex and condition. + * to implement mutex and condition. * * XXX Liang: - * They are just proto-type now, more tests are needed. + * They are just proto-type now, more tests are needed. */ -#define L_LOCK_DEBUG (0) +#define L_LOCK_DEBUG (0) #define L_SEM_NAMESIZE 32 @@ -248,7 +248,7 @@ static inline void l_cond_broadcast(l_cond_t *cond) #endif /* HAVE_LIBREADLINE */ #include #include -#if HAVE_LIBPTHREAD +#if HAVE_PTHREAD #ifndef __WINNT__ #include #include @@ -263,7 +263,7 @@ typedef pthread_cond_t l_cond_t; #define l_cond_init(c) pthread_cond_init(c, NULL) #define l_cond_broadcast(c) pthread_cond_broadcast(c) #define l_cond_wait(c, s) pthread_cond_wait(c, s) -#endif /* HAVE_LIBPTHREAD */ +#endif /* HAVE_PTHREAD */ #endif /* __linux__ */ diff --git a/libcfs/include/libcfs/winnt/winnt-time.h b/libcfs/include/libcfs/winnt/winnt-time.h index 8ce1927..4db469c 100644 --- a/libcfs/include/libcfs/winnt/winnt-time.h +++ b/libcfs/include/libcfs/winnt/winnt-time.h @@ -262,14 +262,14 @@ static inline int cfs_time_beforeq_64(__u64 t1, __u64 t2) #else /* !__KERNEL__ */ #include -#ifdef HAVE_LIBPTHREAD +#ifdef HAVE_PTHREAD #include #else struct timespec { unsigned long tv_sec; unsigned long tv_nsec; }; -#endif /* HAVE_LIBPTHREAD */ +#endif /* HAVE_THREAD */ #include "../user-time.h" diff --git a/libcfs/libcfs/user-lock.c b/libcfs/libcfs/user-lock.c index ab5cf6e..2b1c11e 100644 --- a/libcfs/libcfs/user-lock.c +++ b/libcfs/libcfs/user-lock.c @@ -255,7 +255,7 @@ void cfs_fini_rwsem(cfs_rw_semaphore_t *s) (void)s; } -#ifdef HAVE_LIBPTHREAD +#ifdef HAVE_PTHREAD /* * Multi-threaded user space completion @@ -356,7 +356,7 @@ void cfs_mt_atomic_sub(int b, cfs_mt_atomic_t *a) pthread_mutex_unlock(&atomic_guard_lock); } -#endif /* HAVE_LIBPTHREAD */ +#endif /* HAVE_PTHREAD */ /* !__KERNEL__ */ diff --git a/libcfs/libcfs/user-prim.c b/libcfs/libcfs/user-prim.c index f5de83b..f7efe72 100644 --- a/libcfs/libcfs/user-prim.c +++ b/libcfs/libcfs/user-prim.c @@ -195,7 +195,7 @@ cfs_time_t cfs_timer_deadline(cfs_timer_t *l) } -#ifdef HAVE_LIBPTHREAD +#ifdef HAVE_PTHREAD /* * Threads diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4 index dc77f7d..ea5a833 100644 --- a/lnet/autoconf/lustre-lnet.m4 +++ b/lnet/autoconf/lustre-lnet.m4 @@ -196,7 +196,7 @@ AC_ARG_ENABLE([usocklnd], [],[enable_usocklnd='yes']) if test x$enable_usocklnd = xyes ; then - if test "$ENABLE_LIBPTHREAD" = "yes" ; then + if test "$ax_pthread_ok" = "yes" ; then AC_MSG_RESULT([yes]) USOCKLND="usocklnd" else @@ -1159,6 +1159,7 @@ lnet/ulnds/autoMakefile lnet/ulnds/socklnd/Makefile lnet/ulnds/ptllnd/Makefile lnet/utils/Makefile +lnet/utils/pthread/Makefile lnet/include/lnet/darwin/Makefile ]) ]) diff --git a/lnet/include/lnet/lib-lnet.h b/lnet/include/lnet/lib-lnet.h index 20b587b..65591d3 100644 --- a/lnet/include/lnet/lib-lnet.h +++ b/lnet/include/lnet/lib-lnet.h @@ -94,7 +94,7 @@ static inline int lnet_md_unlinkable (lnet_libmd_t *md) #define LNET_MUTEX_DOWN(m) cfs_mutex_down(m) #define LNET_MUTEX_UP(m) cfs_mutex_up(m) #else -# ifndef HAVE_LIBPTHREAD +# ifndef HAVE_PTHREAD #define LNET_SINGLE_THREADED_LOCK(l) \ do { \ LASSERT ((l) == 0); \ @@ -662,7 +662,7 @@ int lnet_acceptor_port(void); void lnet_router_checker(void); #endif -#ifdef HAVE_LIBPTHREAD +#ifdef HAVE_PTHREAD int lnet_count_acceptor_nis(void); int lnet_acceptor_port(void); #endif diff --git a/lnet/include/lnet/lib-types.h b/lnet/include/lnet/lib-types.h index e6edd00..2e0a66f 100644 --- a/lnet/include/lnet/lib-types.h +++ b/lnet/include/lnet/lib-types.h @@ -366,7 +366,7 @@ typedef struct lnet_lnd /* query of peer aliveness */ void (*lnd_query)(struct lnet_ni *ni, lnet_nid_t peer, cfs_time_t *when); -#if defined(__KERNEL__) || defined(HAVE_LIBPTHREAD) +#if defined(__KERNEL__) || defined(HAVE_PTHREAD) /* accept a new connection */ int (*lnd_accept)(struct lnet_ni *ni, cfs_socket_t *sock); #endif @@ -538,7 +538,7 @@ typedef struct cfs_semaphore_t ln_api_mutex; cfs_semaphore_t ln_lnd_mutex; #else -# ifndef HAVE_LIBPTHREAD +# ifndef HAVE_PTHREAD int ln_lock; int ln_api_mutex; int ln_lnd_mutex; diff --git a/lnet/include/lnet/linux/lib-lnet.h b/lnet/include/lnet/linux/lib-lnet.h index 1dc494c..2ec3250 100644 --- a/lnet/include/lnet/linux/lib-lnet.h +++ b/lnet/include/lnet/linux/lib-lnet.h @@ -62,7 +62,7 @@ lnet_page2phys (struct page *p) case 8: /* page_to_phys returns a 64 bit physical address :) */ return page_to_phys(p); - + default: LBUG(); return 0; @@ -72,7 +72,7 @@ lnet_page2phys (struct page *p) #else /* __KERNEL__ */ # include # include -# ifdef HAVE_LIBPTHREAD +# ifdef HAVE_PTHREAD # include # endif #endif diff --git a/lnet/lnet/acceptor.c b/lnet/lnet/acceptor.c index 1a5652c..9e08276 100644 --- a/lnet/lnet/acceptor.c +++ b/lnet/lnet/acceptor.c @@ -37,7 +37,7 @@ #define DEBUG_SUBSYSTEM S_LNET #include -#if defined(__KERNEL__) || defined(HAVE_LIBPTHREAD) +#if defined(__KERNEL__) || defined(HAVE_PTHREAD) static int accept_port = 988; static int accept_backlog = 127; @@ -594,4 +594,4 @@ void lnet_acceptor_stop(void) { } -#endif /* defined(__KERNEL__) || defined(HAVE_LIBPTHREAD) */ +#endif /* defined(__KERNEL__) || defined(HAVE_PTHREAD) */ diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index 2f681d7..0718451 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -169,7 +169,7 @@ lnet_get_networks (void) return default_networks; } -# ifndef HAVE_LIBPTHREAD +# ifndef HAVE_PTHREAD void lnet_init_locks(void) { @@ -840,7 +840,7 @@ lnet_count_acceptor_nis (void) { /* Return the # of NIs that need the acceptor. */ int count = 0; -#if defined(__KERNEL__) || defined(HAVE_LIBPTHREAD) +#if defined(__KERNEL__) || defined(HAVE_PTHREAD) cfs_list_t *tmp; lnet_ni_t *ni; @@ -854,7 +854,7 @@ lnet_count_acceptor_nis (void) LNET_UNLOCK(); -#endif /* defined(__KERNEL__) || defined(HAVE_LIBPTHREAD) */ +#endif /* defined(__KERNEL__) || defined(HAVE_PTHREAD) */ return count; } @@ -1064,7 +1064,7 @@ lnet_startup_lndnis (void) the_lnet.ln_eqwaitni = ni; } } else { -# ifndef HAVE_LIBPTHREAD +# ifndef HAVE_PTHREAD LCONSOLE_ERROR_MSG(0x106, "LND %s not supported in a " "single-threaded runtime\n", libcfs_lnd2str(lnd_type)); @@ -1138,7 +1138,7 @@ LNetInit(void) # ifdef CRAY_XT3 LNET_REGISTER_ULND(the_ptllnd); # endif -# ifdef HAVE_LIBPTHREAD +# ifdef HAVE_PTHREAD LNET_REGISTER_ULND(the_tcplnd); # endif #endif diff --git a/lnet/lnet/lib-eq.c b/lnet/lnet/lib-eq.c index 61af852..272fdea 100644 --- a/lnet/lnet/lib-eq.c +++ b/lnet/lnet/lib-eq.c @@ -203,7 +203,7 @@ LNetEQPoll (lnet_handle_eq_t *eventqs, int neq, int timeout_ms, #else struct timeval then; struct timeval now; -# ifdef HAVE_LIBPTHREAD +# ifdef HAVE_PTHREAD struct timespec ts; # endif lnet_ni_t *eqwaitni = the_lnet.ln_eqwaitni; @@ -311,7 +311,7 @@ LNetEQPoll (lnet_handle_eq_t *eventqs, int neq, int timeout_ms, RETURN (0); } -# ifndef HAVE_LIBPTHREAD +# ifndef HAVE_PTHREAD /* If I'm single-threaded, LNET fails at startup if it can't * set the_lnet.ln_eqwaitni correctly. */ LBUG(); diff --git a/lnet/lnet/lib-msg.c b/lnet/lnet/lib-msg.c index 089d788..b535113 100644 --- a/lnet/lnet/lib-msg.c +++ b/lnet/lnet/lib-msg.c @@ -85,7 +85,7 @@ lnet_enq_event_locked (lnet_eq_t *eq, lnet_event_t *ev) if (cfs_waitq_active(&the_lnet.ln_waitq)) cfs_waitq_broadcast(&the_lnet.ln_waitq); #else -# ifndef HAVE_LIBPTHREAD +# ifndef HAVE_PTHREAD /* LNetEQPoll() calls into _the_ LND to wait for action */ # else /* Wake anyone waiting in LNetEQPoll() */ diff --git a/lnet/utils/Makefile.am b/lnet/utils/Makefile.am index 37a2e04..51cb252 100644 --- a/lnet/utils/Makefile.am +++ b/lnet/utils/Makefile.am @@ -41,6 +41,12 @@ LIBCFSUTIL= $(top_builddir)/libcfs/libcfs/libcfsutil.a if LIBLUSTRE +SUBDIRS = . pthread +endif + +DIST_SUBDIRS = pthread + +if LIBLUSTRE noinst_LIBRARIES = libuptlctl.a endif @@ -61,9 +67,6 @@ libptlctl_a_SOURCES = portals.c debug.c if UTILS sbin_PROGRAMS += ptlctl routerstat wirecheck lst -if LIBLUSTRE -sbin_PROGRAMS += lstclient -endif if BUILD_GMLND sbin_PROGRAMS += gmlndnid @@ -103,10 +106,6 @@ if LIBLUSTRE LIB_SELFTEST = $(top_builddir)/libcfs/libcfs/libcfs.a $(top_builddir)/lnet/lnet/liblnet.a $(top_builddir)/lnet/selftest/libselftest.a liblst.a : $(LIB_SELFTEST) $(LND_LIBS) sh $(srcdir)/genlib.sh "$(LIBS)" "$(LND_LIBS)" "$(PTHREAD_LIBS)" - -lstclient_SOURCES = lstclient.c -lstclient_LDADD = -L. -lptlctl -llst $(LIBREADLINE) $(LIBEFENCE) $(PTHREAD_LIBS) -lstclient_DEPENDENCIES = libptlctl.a liblst.a endif EXTRA_DIST = genlib.sh diff --git a/lnet/utils/pthread/Makefile.am b/lnet/utils/pthread/Makefile.am new file mode 100644 index 0000000..c242564 --- /dev/null +++ b/lnet/utils/pthread/Makefile.am @@ -0,0 +1,10 @@ +sbin_PROGRAMS = lstclient + +CC = $(PTHREAD_CC) +LD = $(PTHREAD_CC) + +lstclient_CFLAGS = $(PTHREAD_CFLAGS) +lstclient_SOURCES = ../lstclient.c +lstclient_LDFLAGS = $(PTHREAD_CFLAGS) +lstclient_LDADD = -L.. -lptlctl -llst $(LIBREADLINE) $(LIBEFENCE) $(PTHREAD_LIBS) +lstclient_DEPENDENCIES = ../libptlctl.a ../liblst.a diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index acc2415..6a825e5 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -2573,6 +2573,7 @@ lustre/tests/Makefile lustre/tests/mpi/Makefile lustre/utils/Makefile lustre/utils/gss/Makefile +lustre/utils/pthread/Makefile lustre/obdclass/darwin/Makefile ]) ]) diff --git a/lustre/liblustre/tests/Makefile.am b/lustre/liblustre/tests/Makefile.am index 07726dd..39b22d0 100644 --- a/lustre/liblustre/tests/Makefile.am +++ b/lustre/liblustre/tests/Makefile.am @@ -6,6 +6,9 @@ AM_LIBS = $(LIBEFENCE) $(LIBREADLINE) LLIB_EXEC = $(top_builddir)/lustre/utils/liblustreapi.a $(top_builddir)/lustre/liblustre/liblustre.a $(CAP_LIBS) $(PTHREAD_LIBS) $(ZLIB) +CC = $(PTHREAD_CC) +LD = $(PTHREAD_CC) + if LIBLUSTRE noinst_LIBRARIES = libtestcommon.a @@ -32,21 +35,25 @@ DIST_SUBDIRS := mpi libtestcommon_a_SOURCES = test_common.c test_common.h sanity_SOURCES = sanity.c -sanity_CFLAGS = $(LL_CFLAGS) +sanity_CFLAGS = $(LL_CFLAGS) $(PTHREAD_CFLAGS) +sanity_LDFLAGS := $(PTHREAD_CFLAGS) sanity_LDADD := libtestcommon.a $(LLIB_EXEC) sanity_DEPENDENCIES = $(top_builddir)/lustre/liblustre/liblustre.a libtestcommon.a recovery_small_SOURCES = recovery_small.c -recovery_small_CFLAGS = $(LL_CFLAGS) +recovery_small_CFLAGS = $(LL_CFLAGS) $(PTHREAD_CFLAGS) +recovery_small_LDFLAGS := $(PTHREAD_CFLAGS) recovery_small_LDADD := libtestcommon.a $(LLIB_EXEC) recovery_small_DEPENDENCIES = $(top_builddir)/lustre/liblustre/liblustre.a libtestcommon.a replay_single_SOURCES = replay_single.c -replay_single_CFLAGS = $(LL_CFLAGS) +replay_single_CFLAGS = $(LL_CFLAGS) $(PTHREAD_CFLAGS) +replay_single_LDFLAGS := $(PTHREAD_CFLAGS) replay_single_LDADD := libtestcommon.a $(LLIB_EXEC) replay_single_DEPENDENCIES = $(top_builddir)/lustre/liblustre/liblustre.a libtestcommon.a replay_ost_single_SOURCES = replay_ost_single.c -replay_ost_single_CFLAGS = $(LL_CFLAGS) +replay_ost_single_CFLAGS = $(LL_CFLAGS) $(PTHREAD_CFLAGS) +replay_ost_single_LDFLAGS := $(PTHREAD_CFLAGS) replay_ost_single_LDADD := libtestcommon.a $(LLIB_EXEC) replay_ost_single_DEPENDENCIES = $(top_builddir)/lustre/liblustre/liblustre.a libtestcommon.a diff --git a/lustre/utils/Makefile.am b/lustre/utils/Makefile.am index f6c234b..871c4be 100644 --- a/lustre/utils/Makefile.am +++ b/lustre/utils/Makefile.am @@ -1,5 +1,6 @@ # Administration utilities Makefile +SUBDIRS = if GSS SUBDIRS = gss endif @@ -8,6 +9,10 @@ AM_CFLAGS=$(LLCFLAGS) AM_CPPFLAGS=$(LLCPPFLAGS) -DLUSTRE_UTILS=1 AM_LDFLAGS := -L$(top_builddir)/lnet/utils +DIST_SUBDIRS = gss pthread + +SUBDIRS += . pthread + LIBPTLCTL := $(top_builddir)/lnet/utils/libptlctl.a $(top_builddir)/libcfs/libcfs/libcfsutil.a sbin_scripts = lrun @@ -19,32 +24,17 @@ EXTRA_PROGRAMS = wirecheck # mount only finds helpers in /sbin rootsbin_PROGRAMS = mount.lustre -sbin_PROGRAMS = mkfs.lustre tunefs.lustre lctl wiretest \ +sbin_PROGRAMS = mkfs.lustre tunefs.lustre wiretest \ l_getidentity llverfs llverdev \ llog_reader lr_reader lshowmount lustre_rsync \ ll_recover_lost_found_objs ltrack_stats ll_decode_filter_fid -if LIBPTHREAD -sbin_PROGRAMS += loadgen -endif -bin_PROGRAMS = lfs req_layout +bin_PROGRAMS = req_layout bin_SCRIPTS = $(bin_scripts) sbin_SCRIPTS = $(sbin_scripts) endif # UTILS lib_LIBRARIES = liblustreapi.a libiam.a -lctl_SOURCES = obd.c lustre_cfg.c lctl.c obdctl.h -lctl_LDADD := $(LIBREADLINE) liblustreapi.a $(LIBPTLCTL) -lctl_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a - -lfs_SOURCES = lfs.c obd.c lustre_cfg.c -lfs_LDADD := $(LIBREADLINE) liblustreapi.a $(LIBPTLCTL) -lfs_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a - -loadgen_SOURCES = loadgen.c lustre_cfg.c obd.c -loadgen_LDADD := $(LIBREADLINE) liblustreapi.a $(LIBPTLCTL) $(PTHREAD_LIBS) -loadgen_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a - lustre_rsync_SOURCES = lustre_rsync.c obd.c lustre_cfg.c lustre_rsync.h lustre_rsync_LDADD := $(LIBREADLINE) liblustreapi.a $(LIBPTLCTL) lustre_rsync_DEPENDENCIES := $(LIBPTLCTL) liblustreapi.a @@ -59,7 +49,7 @@ if EXT2FS_DEVEL EXT2FSLIB = -lext2fs E2PLIB = -le2p else -E2PLIB = +E2PLIB = EXT2FSLIB = endif @@ -122,4 +112,3 @@ newwiretest: wirehdr.c wirecheck LANG=C ./wirecheck >> wiretest.c cp ../ptlrpc/wirehdr.c ../ptlrpc/wiretest.c LANG=C ./wirecheck >> ../ptlrpc/wiretest.c - diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 8a6ec94..619c96b 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -75,7 +75,7 @@ #define MAX_STRING_SIZE 128 #define DEVICES_LIST "/proc/fs/lustre/devices" -#if HAVE_LIBPTHREAD +#if HAVE_PTHREAD #include #include #include diff --git a/lustre/utils/pthread/Makefile.am b/lustre/utils/pthread/Makefile.am new file mode 100644 index 0000000..426f6cc --- /dev/null +++ b/lustre/utils/pthread/Makefile.am @@ -0,0 +1,29 @@ +AM_CPPFLAGS = $(LLCPPFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -DLUSTRE_UTILS +AM_CFLAGS = $(LLCFLAGS) + +LIBPTLCTL := $(top_builddir)/lnet/utils/libptlctl.a $(top_builddir)/libcfs/libcfs/libcfsutil.a + +sbin_PROGRAMS = lctl +sbin_PROGRAMS += loadgen +bin_PROGRAMS = lfs + +CC = $(PTHREAD_CC) +LD = $(PTHREAD_CC) + +lctl_CFLAGS = $(PTHREAD_CFLAGS) +lctl_SOURCES = ../obd.c ../lustre_cfg.c ../lctl.c ../obdctl.h +lctl_LDFLAGS := $(PTHREAD_CFLAGS) +lctl_LDADD := $(LIBREADLINE) ../liblustreapi.a $(LIBPTLCTL) $(PTHREAD_LIBS) +lctl_DEPENDENCIES := $(LIBPTLCTL) ../liblustreapi.a + +lfs_CFLAGS = $(PTHREAD_CFLAGS) +lfs_SOURCES = ../lfs.c ../lustre_cfg.c ../obd.c +lfs_LDFLAGS := $(PTHREAD_CFLAGS) +lfs_LDADD := $(LIBREADLINE) ../liblustreapi.a $(LIBPTLCTL) $(PTHREAD_LIBS) +lfs_DEPENDENCIES := $(LIBPTLCTL) ../liblustreapi.a + +loadgen_CFLAGS = $(PTHREAD_CFLAGS) +loadgen_SOURCES = ../loadgen.c ../lustre_cfg.c ../obd.c +loadgen_LDFLAGS := $(PTHREAD_CFLAGS) +loadgen_LDADD := $(LIBREADLINE) ../liblustreapi.a $(LIBPTLCTL) $(PTHREAD_LIBS) +loadgen_DEPENDENCIES := $(LIBPTLCTL) ../liblustreapi.a