* aclocal.m4 acinlcude.m4 configure configure.in: modified checks for

pthread support, added switch --enable-fork-process which toggles
  between the usage of fork and pthread, set the default behaviour to
  pthread usage on Darwin
* include/sane/config.h: added the HAVE_LIBPTHRAD stuff
* sanei/sanei_thread.c include/sane/sanei_thread.h: fixed compilation issue
  on OS/2, added support for fork too, so that we can use sanei_thread
  functions in any case.
* backend/plustek.[ch]: changes due to the sanei_thread-lib work
merge-requests/1/head
Gerhard Jaeger 2003-10-07 07:38:37 +00:00
rodzic fec6141ad1
commit 81eaf06a10
10 zmienionych plików z 724 dodań i 153 usunięć

Wyświetl plik

@ -1,3 +1,15 @@
2003-10-07 Gerhard Jaeger <gerhard@gjaeger.de>
* aclocal.m4 acinlcude.m4 configure configure.in: modified checks for
pthread support, added switch --enable-fork-process which toggles
between the usage of fork and pthread, set the default behaviour to
pthread usage on Darwin
* include/sane/config.h: added the HAVE_LIBPTHRAD stuff
* sanei/sanei_thread.c include/sane/sanei_thread.h: fixed compilation issue
on OS/2, added support for fork too, so that we can use sanei_thread
functions in any case.
* backend/plustek.[ch]: changes due to the sanei_thread-lib work
2003-10-06 Peter Kirchgessner <peter@kirchgessner.net>
* backend/hp.c, backend/hp-option.h: Bug #300248 fixed
@ -11,7 +23,7 @@
2003-10-06 Thomas Soumarmon <thomas.soumarmon@cogitae.net>
* backend/hp5400_*: fixed bug #300252 : added static to all non
SANE specific functions + changed #include <sane/..> into
SANE specific functions + changed #include <sane/..> into
#include "../include/sane/..." as mentioned in the
backend-writing.txt file

Wyświetl plik

@ -8,6 +8,7 @@ dnl SANE_EXTRACT_LDFLAGS(LDFLAGS, LIBS)
dnl SANE_V4L_VERSION
dnl SANE_CHECK_JPEG
dnl SANE_CHECK_IEEE1284
dnl SANE_CHECK_PTHREAD
dnl JAPHAR_GREP_CFLAGS(flag, cmd_if_missing, cmd_if_present)
dnl SANE_LINKER_RPATH
dnl SANE_CHECK_U_TYPES
@ -222,6 +223,45 @@ AC_DEFUN([SANE_CHECK_IEEE1284],
fi
])
#
# Checks for pthread support
AC_DEFUN([SANE_CHECK_PTHREAD],
[
AC_MSG_CHECKING([whether to enable pthread support])
case "${host_os}" in
darwin*) # currently only enabled on MacOS X
use_pthread=yes
;;
*)
use_pthread=no
esac
#
# now that we have the systems preferences, we check
# the user
AC_ARG_ENABLE( [fork-process],
AC_HELP_STRING([--enable-fork-process],
[use fork instead of pthread (default)]),
[
if test $enableval != yes ; then
use_pthread=yes
fi
])
AC_MSG_RESULT([$use_pthread])
if test $use_pthread = yes ; then
AC_CHECK_HEADERS(pthread.h,
[AC_CHECK_LIB(pthread,pthread_create,)
saved_LIBS="${LIBS}"
LIBS="${LIBS} -lpthread"
AC_CHECK_FUNCS(pthread_create, enable_dynamic=yes,)
AC_CHECK_FUNCS(pthread_kill, enable_dynamic=yes,)
AC_CHECK_FUNCS(pthread_join, enable_dynamic=yes,)
AC_CHECK_FUNCS(pthread_detach, enable_dynamic=yes,)
LIBS="${saved_LIBS}"
],)
fi
])
#
# Checks for jpeg library >= v6B (61), needed for DC210, DC240, and

67
aclocal.m4 vendored
Wyświetl plik

@ -1,14 +1,15 @@
dnl aclocal.m4 generated automatically by aclocal 1.4-p4
# generated automatically by aclocal 1.7.2 -*- Autoconf -*-
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
# Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
dnl PARTICULAR PURPOSE.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
dnl
dnl Contains the following macros
@ -239,9 +240,40 @@ AC_DEFUN([SANE_CHECK_IEEE1284],
# Checks for pthread support
AC_DEFUN([SANE_CHECK_PTHREAD],
[
AC_CHECK_HEADER(pthread.h, [
LIBS="${LIBS} -lpthread"
])
AC_MSG_CHECKING([whether to enable pthread support])
case "${host_os}" in
darwin*) # currently only enabled on MacOS X
use_pthread=yes
;;
*)
use_pthread=no
esac
#
# now that we have the systems preferences, we check
# the user
AC_ARG_ENABLE( [fork-process],
AC_HELP_STRING([--enable-fork-process],
[use fork instead of pthread (default)]),
[
if test $enableval != yes ; then
use_pthread=yes
fi
])
AC_MSG_RESULT([$use_pthread])
if test $use_pthread = yes ; then
AC_CHECK_HEADERS(pthread.h,
[AC_CHECK_LIB(pthread,pthread_create,)
saved_LIBS="${LIBS}"
LIBS="${LIBS} -lpthread"
AC_CHECK_FUNCS(pthread_create, enable_dynamic=yes,)
AC_CHECK_FUNCS(pthread_kill, enable_dynamic=yes,)
AC_CHECK_FUNCS(pthread_join, enable_dynamic=yes,)
AC_CHECK_FUNCS(pthread_detach, enable_dynamic=yes,)
LIBS="${saved_LIBS}"
],)
fi
])
#
@ -6339,7 +6371,16 @@ SED=$lt_cv_path_SED
AC_MSG_RESULT([$SED])
])
#serial 1
# isc-posix.m4 serial 2 (gettext-0.11.2)
dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
dnl Public License, this file may be distributed as part of a program
dnl that contains a configuration script generated by Autoconf, under
dnl the same distribution terms as the rest of that program.
# This file is not needed with autoconf-2.53 and newer. Remove it in 2005.
# This test replaces the one in autoconf.
# Currently this macro should have the same name as the autoconf macro
# because gettext's gettext.m4 (distributed in the automake package)

Wyświetl plik

@ -129,7 +129,6 @@
#include <math.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/ioctl.h>
@ -137,18 +136,15 @@
#include "sane/sanei.h"
#include "sane/saneopts.h"
#define BACKEND_VERSION "0.46-2"
#define BACKEND_VERSION "0.46-3"
#define BACKEND_NAME plustek
#include "sane/sanei_backend.h"
#include "sane/sanei_config.h"
/*we're using this possibility only on MacOS X... */
#if defined HAVE_PTHREAD_H && defined HAVE_IOKIT_IOKITLIB_H
#define _PLUSTEK_USE_THREAD
#endif
#ifdef _PLUSTEK_USE_THREAD
#include "sane/sanei_thread.h"
/** we're using this possibility only on MacOS X... */
#if defined HAVE_LIBPTHREAD
#define _PLUSTEK_USE_THREAD
#endif
/** might be used to disable all USB stuff - esp. for OS/2 */
@ -355,7 +351,7 @@ static SANE_Bool getReaderProcessExitCode( Plustek_Scanner *scanner )
if( scanner->reader_pid > 0 ) {
res = waitpid( scanner->reader_pid, &status, WNOHANG );
res = sanei_thread_waitpid( scanner->reader_pid, &status, WNOHANG );
if( res == scanner->reader_pid ) {
@ -551,31 +547,16 @@ static SANE_Status do_cancel( Plustek_Scanner *scanner, SANE_Bool closepipe )
sigaction( SIGALRM, &act, 0 );
/* kill our child process and wait until done */
if( scanner->child_forked ) {
kill( scanner->reader_pid, SIGUSR1 );
sanei_thread_kill( scanner->reader_pid, SIGUSR1 );
/* give'em 10 seconds 'til done...*/
alarm(10);
res = waitpid( scanner->reader_pid, 0, 0 );
} else {
#ifdef _PLUSTEK_USE_THREAD
sanei_thread_kill( scanner->reader_pid, SIGUSR1 );
alarm(10);
res = sanei_thread_waitpid( scanner->reader_pid, 0, 0);
#else
res = scanner->reader_pid;
#endif
}
/* give'em 10 seconds 'til done...*/
alarm(10);
res = sanei_thread_waitpid( scanner->reader_pid, 0, 0 );
alarm(0);
if( res != scanner->reader_pid ) {
DBG( _DBG_PROC,"waitpid() failed !\n");
#ifdef _PLUSTEK_USE_THREAD
DBG( _DBG_PROC,"sanei_thread_waitpid() failed !\n");
sanei_thread_kill( scanner->reader_pid, SIGKILL );
#else
kill( scanner->reader_pid, SIGKILL );
#endif
}
scanner->reader_pid = 0;
DBG( _DBG_PROC,"reader_process killed\n");
@ -1244,9 +1225,7 @@ SANE_Status sane_init( SANE_Int *version_code, SANE_Auth_Callback authorize )
sanei_usb_init();
sanei_lm983x_init();
#endif
#ifdef _PLUSTEK_USE_THREAD
sanei_thread_init();
#endif
#if defined PACKAGE && defined VERSION
DBG( _DBG_SANE_INIT, "Plustek backend V"BACKEND_VERSION", part of "
@ -2075,11 +2054,9 @@ SANE_Status sane_start( SANE_Handle handle )
/* create reader routine as new process */
s->bytes_read = 0;
#ifdef _PLUSTEK_USE_THREAD
s->child_forked = SANE_FALSE;
s->pipe = fds[1];
s->reader_pid = sanei_thread_begin( reader_thread, s );
s->pipe = fds[1];
s->reader_pid = sanei_thread_begin( reader_thread, s );
#else
s->child_forked = SANE_TRUE;
s->reader_pid = fork();
#endif
cancelRead = SANE_FALSE;
@ -2118,7 +2095,7 @@ SANE_Status sane_start( SANE_Handle handle )
signal( SIGCHLD, sig_chldhandler );
if( s->child_forked )
if( sanei_thread_is_forked())
close(fds[1]);
s->pipe = fds[0];
@ -2152,7 +2129,7 @@ SANE_Status sane_read( SANE_Handle handle, SANE_Byte *data,
/* if we already had red the picture, so it's okay and stop */
if( s->bytes_read ==
(unsigned long)(s->params.lines * s->params.bytes_per_line)) {
waitpid( s->reader_pid, 0, 0 );
sanei_thread_waitpid( s->reader_pid, 0, 0 );
s->reader_pid = -1;
drvclose( s->hw );
return close_pipe(s);

Wyświetl plik

@ -43,7 +43,6 @@
* - 0.46 - flag initialized is now used as device index
* - added calFile to Plustek_Device
* - removed _OPT_HALFTONE
* - added pthread support
* .
* <hr>
* This file is part of the SANE package.
@ -370,7 +369,6 @@ typedef struct Plustek_Scanner
{
struct Plustek_Scanner *next;
pid_t reader_pid; /* process id of reader */
SANE_Bool child_forked; /* use fork or pthreads */
SANE_Status exit_code; /* status of the reader process */
int pipe; /* pipe to reader process */
unsigned long bytes_read; /* number of bytes currently read*/

556
configure vendored
Wyświetl plik

@ -1026,6 +1026,7 @@ Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-warnings turn on tons of compiler warnings (GCC only)
--enable-fork-process use fork instead of pthread (default)
--disable-libusb disable support for libusb
--disable-ipv6 disable IPv6 support
--enable-static[=PKGS]
@ -5408,18 +5409,48 @@ _ACEOF
fi
if test "${ac_cv_header_pthread_h+set}" = set; then
echo "$as_me:$LINENO: checking for pthread.h" >&5
echo $ECHO_N "checking for pthread.h... $ECHO_C" >&6
if test "${ac_cv_header_pthread_h+set}" = set; then
echo "$as_me:$LINENO: checking whether to enable pthread support" >&5
echo $ECHO_N "checking whether to enable pthread support... $ECHO_C" >&6
case "${host_os}" in
darwin*) # currently only enabled on MacOS X
use_pthread=yes
;;
*)
use_pthread=no
esac
#
# now that we have the systems preferences, we check
# the user
# Check whether --enable-fork-process or --disable-fork-process was given.
if test "${enable_fork_process+set}" = set; then
enableval="$enable_fork_process"
if test $enableval != yes ; then
use_pthread=yes
fi
fi;
echo "$as_me:$LINENO: result: $use_pthread" >&5
echo "${ECHO_T}$use_pthread" >&6
if test $use_pthread = yes ; then
for ac_header in pthread.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
echo "$as_me:$LINENO: result: $ac_cv_header_pthread_h" >&5
echo "${ECHO_T}$ac_cv_header_pthread_h" >&6
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
else
# Is the header compilable?
echo "$as_me:$LINENO: checking pthread.h usability" >&5
echo $ECHO_N "checking pthread.h usability... $ECHO_C" >&6
echo "$as_me:$LINENO: checking $ac_header usability" >&5
echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
@ -5428,7 +5459,7 @@ cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <pthread.h>
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
@ -5454,8 +5485,8 @@ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
echo "${ECHO_T}$ac_header_compiler" >&6
# Is the header present?
echo "$as_me:$LINENO: checking pthread.h presence" >&5
echo $ECHO_N "checking pthread.h presence... $ECHO_C" >&6
echo "$as_me:$LINENO: checking $ac_header presence" >&5
echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
@ -5463,7 +5494,7 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <pthread.h>
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
@ -5496,10 +5527,10 @@ echo "${ECHO_T}$ac_header_preproc" >&6
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc in
yes:no )
{ echo "$as_me:$LINENO: WARNING: pthread.h: accepted by the compiler, rejected by the preprocessor!" >&5
echo "$as_me: WARNING: pthread.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ echo "$as_me:$LINENO: WARNING: pthread.h: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: pthread.h: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
(
cat <<\_ASBOX
## ------------------------------------ ##
@ -5510,12 +5541,12 @@ _ASBOX
sed "s/^/$as_me: WARNING: /" >&2
;;
no:yes )
{ echo "$as_me:$LINENO: WARNING: pthread.h: present but cannot be compiled" >&5
echo "$as_me: WARNING: pthread.h: present but cannot be compiled" >&2;}
{ echo "$as_me:$LINENO: WARNING: pthread.h: check for missing prerequisite headers?" >&5
echo "$as_me: WARNING: pthread.h: check for missing prerequisite headers?" >&2;}
{ echo "$as_me:$LINENO: WARNING: pthread.h: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: pthread.h: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
(
cat <<\_ASBOX
## ------------------------------------ ##
@ -5526,24 +5557,430 @@ _ASBOX
sed "s/^/$as_me: WARNING: /" >&2
;;
esac
echo "$as_me:$LINENO: checking for pthread.h" >&5
echo $ECHO_N "checking for pthread.h... $ECHO_C" >&6
if test "${ac_cv_header_pthread_h+set}" = set; then
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_cv_header_pthread_h=$ac_header_preproc
eval "$as_ac_Header=$ac_header_preproc"
fi
echo "$as_me:$LINENO: result: $ac_cv_header_pthread_h" >&5
echo "${ECHO_T}$ac_cv_header_pthread_h" >&6
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
fi
if test $ac_cv_header_pthread_h = yes; then
if test `eval echo '${'$as_ac_Header'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
LIBS="${LIBS} -lpthread"
echo "$as_me:$LINENO: checking for pthread_create in -lpthread" >&5
echo $ECHO_N "checking for pthread_create in -lpthread... $ECHO_C" >&6
if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lpthread $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char pthread_create ();
int
main ()
{
pthread_create ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_pthread_pthread_create=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_pthread_pthread_create=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_create" >&5
echo "${ECHO_T}$ac_cv_lib_pthread_pthread_create" >&6
if test $ac_cv_lib_pthread_pthread_create = yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBPTHREAD 1
_ACEOF
LIBS="-lpthread $LIBS"
fi
saved_LIBS="${LIBS}"
LIBS="${LIBS} -lpthread"
for ac_func in pthread_create
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func (); below.
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
<limits.h> exists even on freestanding compilers. */
#ifdef __STDC__
# include <limits.h>
#else
# include <assert.h>
#endif
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
{
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char $ac_func ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
char (*f) () = $ac_func;
#endif
#ifdef __cplusplus
}
#endif
int
main ()
{
return f != $ac_func;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
eval "$as_ac_var=yes"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
enable_dynamic=yes
fi
done
for ac_func in pthread_kill
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func (); below.
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
<limits.h> exists even on freestanding compilers. */
#ifdef __STDC__
# include <limits.h>
#else
# include <assert.h>
#endif
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
{
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char $ac_func ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
char (*f) () = $ac_func;
#endif
#ifdef __cplusplus
}
#endif
int
main ()
{
return f != $ac_func;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
eval "$as_ac_var=yes"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
enable_dynamic=yes
fi
done
for ac_func in pthread_join
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func (); below.
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
<limits.h> exists even on freestanding compilers. */
#ifdef __STDC__
# include <limits.h>
#else
# include <assert.h>
#endif
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
{
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char $ac_func ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
char (*f) () = $ac_func;
#endif
#ifdef __cplusplus
}
#endif
int
main ()
{
return f != $ac_func;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
eval "$as_ac_var=yes"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
enable_dynamic=yes
fi
done
for ac_func in pthread_detach
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
if eval "test \"\${$as_ac_var+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func (); below.
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
<limits.h> exists even on freestanding compilers. */
#ifdef __STDC__
# include <limits.h>
#else
# include <assert.h>
#endif
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
{
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char $ac_func ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
char (*f) () = $ac_func;
#endif
#ifdef __cplusplus
}
#endif
int
main ()
{
return f != $ac_func;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
eval "$as_ac_var=yes"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
eval "$as_ac_var=no"
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
if test `eval echo '${'$as_ac_var'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
enable_dynamic=yes
fi
done
LIBS="${saved_LIBS}"
fi
done
fi
@ -5919,7 +6356,6 @@ fi
for ac_header in fcntl.h unistd.h libc.h sys/dsreq.h sys/select.h \
@ -5930,7 +6366,7 @@ for ac_header in fcntl.h unistd.h libc.h sys/dsreq.h sys/select.h \
sys/types.h sys/scsi/scsi.h sys/scsi/sgdefs.h sys/scsi/targets/scgio.h \
apollo/scsi.h sys/sdi_comm.h sys/passthrudef.h linux/ppdev.h \
dev/ppbus/ppi.h machine/cpufunc.h usb.h sys/bitypes.h sys/sem.h sys/poll.h \
IOKit/IOKitLib.h windows.h pthread.h
IOKit/IOKitLib.h windows.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
@ -9373,7 +9809,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
echo '#line 9376 "configure"' > conftest.$ac_ext
echo '#line 9812 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@ -10552,7 +10988,7 @@ fi
# Provide some information about the compiler.
echo "$as_me:10555:" \
echo "$as_me:10991:" \
"checking for Fortran 77 compiler version" >&5
ac_compiler=`set X $ac_compile; echo $2`
{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
@ -11557,11 +11993,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:11560: $lt_compile\"" >&5)
(eval echo "\"\$as_me:11996: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:11564: \$? = $ac_status" >&5
echo "$as_me:12000: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@ -11789,11 +12225,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:11792: $lt_compile\"" >&5)
(eval echo "\"\$as_me:12228: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:11796: \$? = $ac_status" >&5
echo "$as_me:12232: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@ -11856,11 +12292,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:11859: $lt_compile\"" >&5)
(eval echo "\"\$as_me:12295: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:11863: \$? = $ac_status" >&5
echo "$as_me:12299: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@ -13868,7 +14304,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 13871 "configure"
#line 14307 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -13966,7 +14402,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 13969 "configure"
#line 14405 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -16098,11 +16534,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:16101: $lt_compile\"" >&5)
(eval echo "\"\$as_me:16537: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:16105: \$? = $ac_status" >&5
echo "$as_me:16541: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@ -16165,11 +16601,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:16168: $lt_compile\"" >&5)
(eval echo "\"\$as_me:16604: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:16172: \$? = $ac_status" >&5
echo "$as_me:16608: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@ -17408,7 +17844,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 17411 "configure"
#line 17847 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -17506,7 +17942,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 17509 "configure"
#line 17945 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -18328,11 +18764,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:18331: $lt_compile\"" >&5)
(eval echo "\"\$as_me:18767: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:18335: \$? = $ac_status" >&5
echo "$as_me:18771: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@ -18395,11 +18831,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:18398: $lt_compile\"" >&5)
(eval echo "\"\$as_me:18834: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:18402: \$? = $ac_status" >&5
echo "$as_me:18838: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@ -20335,11 +20771,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:20338: $lt_compile\"" >&5)
(eval echo "\"\$as_me:20774: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:20342: \$? = $ac_status" >&5
echo "$as_me:20778: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@ -20567,11 +21003,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:20570: $lt_compile\"" >&5)
(eval echo "\"\$as_me:21006: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:20574: \$? = $ac_status" >&5
echo "$as_me:21010: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
@ -20634,11 +21070,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:20637: $lt_compile\"" >&5)
(eval echo "\"\$as_me:21073: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:20641: \$? = $ac_status" >&5
echo "$as_me:21077: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@ -22646,7 +23082,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 22649 "configure"
#line 23085 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -22744,7 +23180,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 22747 "configure"
#line 23183 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H

Wyświetl plik

@ -108,7 +108,7 @@ AC_CHECK_HEADERS(fcntl.h unistd.h libc.h sys/dsreq.h sys/select.h \
sys/types.h sys/scsi/scsi.h sys/scsi/sgdefs.h sys/scsi/targets/scgio.h \
apollo/scsi.h sys/sdi_comm.h sys/passthrudef.h linux/ppdev.h \
dev/ppbus/ppi.h machine/cpufunc.h usb.h sys/bitypes.h sys/sem.h sys/poll.h \
IOKit/IOKitLib.h windows.h pthread.h )
IOKit/IOKitLib.h windows.h )
AC_CHECK_HEADERS([asm/io.h],,,[#include <sys/types.h>])
SANE_CHECK_MISSING_HEADERS
SANE_V4L_VERSION

Wyświetl plik

@ -127,6 +127,9 @@
/* Define to 1 if you have the `nsl' library (-lnsl). */
#undef HAVE_LIBNSL
/* Define to 1 if you have the `pthread' library (-lpthread). */
#undef HAVE_LIBPTHREAD
/* Define to 1 if you have the `scsi' library (-lscsi). */
#undef HAVE_LIBSCSI
@ -169,9 +172,21 @@
/* Define to 1 if you have the `poll' function. */
#undef HAVE_POLL
/* Define to 1 if you have the `pthread_create' function. */
#undef HAVE_PTHREAD_CREATE
/* Define to 1 if you have the `pthread_detach' function. */
#undef HAVE_PTHREAD_DETACH
/* Define to 1 if you have the <pthread.h> header file. */
#undef HAVE_PTHREAD_H
/* Define to 1 if you have the `pthread_join' function. */
#undef HAVE_PTHREAD_JOIN
/* Define to 1 if you have the `pthread_kill' function. */
#undef HAVE_PTHREAD_KILL
/* Define to 1 if you have the `scsireq_enter' function. */
#undef HAVE_SCSIREQ_ENTER

Wyświetl plik

@ -66,28 +66,32 @@
* @{
*/
extern void sanei_thread_init( void );
/**
*/
extern SANE_Bool sanei_thread_is_forked( void );
/** <b>Do not use in backends</b>
*
* Wrapper for @c fork.
*/
extern int sanei_thread_begin( void (*start)(void *arg), void* arg_list);
extern int sanei_thread_begin( void (*start)(void *arg), void* args );
/** <b>Do not use in backends</b>
*
* Wrapper for @c kill.
* Wrapper for @c kill.
*/
extern int sanei_thread_kill( int pid, int sig);
/** <b>Do not use in backends</b>
*
* Wrapper for @c waitpid.
* Wrapper for @c waitpid.
*/
extern int sanei_thread_waitpid( int pid, int *stat_loc, int options);
/** <b>Do not use in backends</b>
*
* Wrapper for @c wait.
* Wrapper for @c wait.
*/
extern int sanei_thread_wait( int *stat_loc);
/* @} */

Wyświetl plik

@ -37,7 +37,7 @@
If you write modifications of your own for SANE, it is your choice
whether to permit this exception to apply to your modifications.
If you do not wish that, delete this exception notice.
If you do not wish that, delete this exception notice.
Helper functions for the OS/2 port (using threads instead of forked
processes). Don't use them in the backends, they are used automatically by
@ -54,25 +54,40 @@
# include <unistd.h>
#endif
#define BACKEND_NAME sanei_thread /**< name of this module for debugging */
#include "../include/sane/sane.h"
#include "../include/sane/sanei_debug.h"
#include "../include/sane/sanei_thread.h"
#ifndef _VAR_NOT_USED
# define _VAR_NOT_USED(x) ((x)=(x))
#endif
/** for init issues - here only for the debug output
*/
void
sanei_thread_init( void )
{
DBG_INIT();
}
#ifdef HAVE_OS2_H
#define INCL_DOSPROCESS
#include <os2.h>
#include <sane/sanei_thread.h>
/*
* starts a new thread or process
* parameters:
* start address of reader function
* arg_list pointer to scanner data structure
* star address of reader function
* args pointer to scanner data structure
*
*/
int
sanei_thread_begin( void (*start)(void *arg),
void* arg_list)
sanei_thread_begin( void (*start)(void *arg), void* args )
{
return _beginthread( start, NULL, 1024*1024, arg_list);
return _beginthread( start, NULL, 1024*1024, args );
}
int
@ -96,48 +111,63 @@ sanei_thread_wait( int *stat_loc)
return -1; /* return error because I don't know child pid */
}
#endif /* HAVE_OS2_H */
#else /* HAVE_OS2_H */
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
#include <sane/sanei_thread.h>
#define BACKEND_NAME sanei_thread /**< the name of this module for dbg */
#include "../include/sane/sane.h"
#include "../include/sane/sanei_debug.h"
void
sanei_thread_init( void )
{
DBG_INIT();
}
#ifdef HAVE_LIBPTHREAD
# include <pthread.h>
#else
# include <sys/wait.h>
#endif
int
sanei_thread_begin( void (*start)(void *arg), void* arg_list )
sanei_thread_begin( void (*start)(void *arg), void* args )
{
int hd;
int pid;
#ifdef HAVE_LIBPTHREAD
pthread_t thread;
hd = pthread_create( &thread, NULL, start, arg_list );
pid = pthread_create( &thread, NULL, start, args );
if ( hd != 0 ) {
DBG(1, "pthread_create() failed with %d\n", hd );
if ( pid != 0 ) {
DBG( 1, "pthread_create() failed with %d\n", pid );
return -1;
}
DBG( 2, "pthread_create() created thread %d\n", (int)thread );
return (int)thread;
#else
pid = fork();
if( pid < 0 ) {
DBG( 1, "fork() failed\n" );
return -1;
}
if( pid == 0 ) {
/* run in child context... */
int status = 0;
start( args );
/* don't use exit() since that would run the atexit() handlers */
_exit( status );
}
/* parents return */
return pid;
#endif
}
int
sanei_thread_kill( int pid, int sig)
{
DBG(2, "pthread_kill() will kill %d\n", (int)pid);
DBG(2, "sanei_thread_kill() will kill %d\n", (int)pid);
#ifdef HAVE_LIBPTHREAD
return pthread_kill((pthread_t)pid, sig );
#else
return kill( pid, sig );
#endif
}
int
@ -146,9 +176,27 @@ sanei_thread_waitpid( int pid, int *stat_loc, int options )
if (stat_loc)
*stat_loc = 0;
#ifdef HAVE_LIBPTHREAD
_VAR_NOT_USED( options );
if( 0 == pthread_join((pthread_t)pid, (void*)stat_loc ))
pthread_detach((pthread_t)pid );
return pid;
#else
return waitpid( pid, stat_loc, options );
#endif
}
#endif /* HAVE_PTHREAD_H */
SANE_Bool
sanei_thread_is_forked( void )
{
#ifdef HAVE_LIBPTHREAD
return SANE_FALSE;
#else
return SANE_TRUE;
#endif
}
#endif /* HAVE_OS2_H */