diff --git a/Makefile.incl b/Makefile.incl index ae73fb4c97..78e0394f31 100644 --- a/Makefile.incl +++ b/Makefile.incl @@ -1,15 +1,6 @@ ## -*-Makefile -*- ## $Id$ -# MYSQL_INCLUDES = /usr/local/mysql/include -# MYSQL_INCLUDES2 = /usr/local/mysql/include/mysql -# MYSQL_INCLUDES3 = /usr/include/mysql - -# MYSQL_LIBS = \ -# -L/usr/local/mysql/lib -L/sw/lib/mysql -L/usr/local/lib/mysql \ -# -lmysqlclient -L/usr/local/lib -lz \ -# -lm $(NETLIBS) - # Note: MYSQL_CFLAGS and MYSQL_LIBS set by configure from mysql_config MYSQL_LIBS = @MYSQL_LIBS@ diff --git a/api/boinc_api.h b/api/boinc_api.h index 5ee3e818df..743586537e 100755 --- a/api/boinc_api.h +++ b/api/boinc_api.h @@ -2,18 +2,18 @@ // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License at // http://boinc.berkeley.edu/license_1.0.txt -// +// // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the // License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is the Berkeley Open Infrastructure for Network Computing. -// +// under the License. +// +// The Original Code is the Berkeley Open Infrastructure for Network Computing. +// // The Initial Developer of the Original Code is the SETI@home project. // Portions created by the SETI@home project are Copyright (C) 2002 -// University of California at Berkeley. All Rights Reserved. -// +// University of California at Berkeley. All Rights Reserved. +// // Contributor(s): // @@ -52,6 +52,7 @@ public: size_t write(const void *, size_t size, size_t nitems); int close(); int flush(); + long tell() const; }; extern int boinc_init(); diff --git a/api/mfile.C b/api/mfile.C index c073f75c7c..545c9fd47f 100644 --- a/api/mfile.C +++ b/api/mfile.C @@ -2,18 +2,18 @@ // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License at // http://boinc.berkeley.edu/license_1.0.txt -// +// // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the // License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is the Berkeley Open Infrastructure for Network Computing. -// +// under the License. +// +// The Original Code is the Berkeley Open Infrastructure for Network Computing. +// // The Initial Developer of the Original Code is the SETI@home project. // Portions created by the SETI@home project are Copyright (C) 2002 -// University of California at Berkeley. All Rights Reserved. -// +// University of California at Berkeley. All Rights Reserved. +// // Contributor(s): // @@ -84,3 +84,8 @@ int MFILE::flush() { len = 0; return fflush(f); } + +long MFILE::tell() const +{ + return f ? ftell(f) : -1; +} diff --git a/checkin_notes b/checkin_notes index a26fa0f24f..443cc6663b 100755 --- a/checkin_notes +++ b/checkin_notes @@ -5736,6 +5736,7 @@ Karl 2003/08/14 version number. - scheduler: renamed config.h to sched_config.h to avoid conflict with default autoconf config.h + - api: added MFILE::ftell() function Astropulse/ configure.ac, configure (added) @@ -5746,6 +5747,14 @@ Karl 2003/08/14 client/ ap_file_io.C + sched/ + config.h ->renamed-> sched_config.h + *.C + api/ + boinc_api.h + mfile.C + + Karl,Dave 2003/08/14 - rewriting scheduler diff --git a/configure b/configure index 3e831557e9..e01baef700 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac Revision: 1.31 . +# From configure.ac Revision: 1.32 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57 for BOINC 1.11. # diff --git a/configure.ac b/configure.ac index dd078556e5..899c41398d 100644 --- a/configure.ac +++ b/configure.ac @@ -66,26 +66,6 @@ dnl yes dnl #endif dnl ], AC_DEFINE(unix, 1, [unix])) -AC_DEFUN([AC_CHECK_MYSQL],[ -AC_ARG_VAR([MYSQL_CONFIG], [mysql_config program]) -if test -z "$MYSQL_CONFIG"; then -AC_PATH_PROG(MYSQL_CONFIG,mysql_config,,[$PATH:/usr/local/mysql/bin]) -fi -if test -z "$MYSQL_CONFIG" -then - AC_MSG_ERROR([mysql_config executable not found]) -else - AC_MSG_CHECKING(mysql libraries) - MYSQL_LIBS=`${MYSQL_CONFIG} --libs` - AC_MSG_RESULT($MYSQL_LIBS) - AC_MSG_CHECKING(mysql includes) - MYSQL_CFLAGS=`${MYSQL_CONFIG} --cflags` - AC_MSG_RESULT($MYSQL_CFLAGS) -fi -]) -AC_SUBST(MYSQL_LIBS) -AC_SUBST(MYSQL_CFLAGS) - dnl Checks for programs. AC_PROG_CC AC_PROG_CXX @@ -113,11 +93,8 @@ dnl Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS(fcntl.h malloc.h strings.h sys/time.h unistd.h sys/systeminfo.h sys/swap.h sys/sysctl.h sys/resource.h sys/types.h dirent.h sys/utsname.h netdb.h netinet/in.h arpa/inet.h signal.h sys/wait.h sys/file.h sys/ipc.h sys/shm.h) - -dnl Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST AC_HEADER_TIME +AC_CHECK_HEADERS(arpa/inet.h dirent.h fcntl.h malloc.h netdb.h netinet/in.h netinet/tcp.h signal.h strings.h sys/file.h sys/ipc.h sys/mount.h sys/resource.h sys/select.h sys/shm.h sys/socket.h sys/statvfs.h sys/swap.h sys/sysctl.h sys/systeminfo.h sys/time.h sys/types.h sys/utsname.h sys/vmmeter.h sys/wait.h unistd.h) dnl TODO: use compiler to test these; there probably exists an autoconf macro already! case "$target" in @@ -135,15 +112,9 @@ AC_FUNC_VPRINTF AC_FUNC_WAIT3 AC_CHECK_FUNCS(gethostname gettimeofday mkdir select socket strstr uname lockf flock strftime setpriority) -dnl Checks for header files. -AC_HEADER_DIRENT -AC_HEADER_STDC -AC_CHECK_HEADERS(fcntl.h malloc.h sys/time.h unistd.h sys/select.h sys/statvfs.h sys/swap.h sys/systeminfo.h sys/sysctl.h sys/vmmeter.h sys/socket.h sys/types.h dirent.h sys/utsname.h netdb.h netinet/in.h netinet/tcp.h arpa/inet.h sys/resource.h signal.h sys/wait.h sys/mount.h sys/ipc.h sys/shm.h) - dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_SIZE_T -AC_HEADER_TIME AC_STRUCT_TM AC_STRUCT_TIMEZONE diff --git a/m4/acx_pthread.m4 b/m4/acx_pthread.m4 new file mode 100644 index 0000000000..d318ab01d9 --- /dev/null +++ b/m4/acx_pthread.m4 @@ -0,0 +1,190 @@ +dnl Available from the GNU Autoconf Macro Archive at: +dnl http://www.gnu.org/software/ac-archive/htmldoc/acx_pthread.html +dnl +AC_DEFUN([ACX_PTHREAD], [ +AC_REQUIRE([AC_CANONICAL_HOST]) +AC_LANG_SAVE +AC_LANG_C +acx_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, acx_pthread_ok=yes) + AC_MSG_RESULT($acx_pthread_ok) + if test x"$acx_pthread_ok" = xno; then + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" + fi + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" +fi + +# 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. + +acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt" + +# 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) +# pthread: Linux, etcetera +# --thread-safe: KAI C++ + +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 -pthread or + # -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: + + acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags" + ;; +esac + +if test x"$acx_pthread_ok" = xno; then +for flag in $acx_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" + ;; + + *) + 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 ], + [pthread_t th; pthread_join(th, 0); + pthread_attr_init(0); pthread_cleanup_push(0, 0); + pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], + [acx_pthread_ok=yes]) + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + AC_MSG_RESULT($acx_pthread_ok) + if test "x$acx_pthread_ok" = xyes; then + break; + fi + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi + +# Various other checks: +if test "x$acx_pthread_ok" = xyes; then + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Detect AIX lossage: threads are created detached by default + # and the JOINABLE attribute has a nonstandard name (UNDETACHED). + AC_MSG_CHECKING([for joinable pthread attribute]) + AC_TRY_LINK([#include ], + [int attr=PTHREAD_CREATE_JOINABLE;], + ok=PTHREAD_CREATE_JOINABLE, ok=unknown) + if test x"$ok" = xunknown; then + AC_TRY_LINK([#include ], + [int attr=PTHREAD_CREATE_UNDETACHED;], + ok=PTHREAD_CREATE_UNDETACHED, ok=unknown) + fi + if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then + AC_DEFINE(PTHREAD_CREATE_JOINABLE, $ok, + [Define to the necessary symbol if this constant + uses a non-standard name on your system.]) + fi + AC_MSG_RESULT(${ok}) + if test x"$ok" = xunknown; then + AC_MSG_WARN([we do not know how to create joinable pthreads]) + fi + + AC_MSG_CHECKING([if more special flags are required for pthreads]) + flag=no + case "${host_cpu}-${host_os}" in + *-aix* | *-freebsd*) 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 cc_r + AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC}) +else + 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"$acx_pthread_ok" = xyes; then + ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) + : +else + acx_pthread_ok=no + $2 +fi +AC_LANG_RESTORE +])dnl ACX_PTHREAD diff --git a/m4/kc_mysql.m4 b/m4/kc_mysql.m4 new file mode 100644 index 0000000000..c8d3446671 --- /dev/null +++ b/m4/kc_mysql.m4 @@ -0,0 +1,22 @@ + +dnl $Id$ + +AC_DEFUN([AC_CHECK_MYSQL],[ +AC_ARG_VAR([MYSQL_CONFIG], [mysql_config program]) +if test -z "$MYSQL_CONFIG"; then +AC_PATH_PROG(MYSQL_CONFIG,mysql_config,,[$PATH:/usr/local/mysql/bin]) +fi +if test -z "$MYSQL_CONFIG" +then + AC_MSG_ERROR([mysql_config executable not found]) +else + AC_MSG_CHECKING(mysql libraries) + MYSQL_LIBS=`${MYSQL_CONFIG} --libs` + AC_MSG_RESULT($MYSQL_LIBS) + AC_MSG_CHECKING(mysql includes) + MYSQL_CFLAGS=`${MYSQL_CONFIG} --cflags` + AC_MSG_RESULT($MYSQL_CFLAGS) +fi +AC_SUBST(MYSQL_LIBS) +AC_SUBST(MYSQL_CFLAGS) +])