[sane-devel] pthread support and MacOS X
Henning Meier-Geinitz
henning@meier-geinitz.de
Sun, 5 Oct 2003 23:54:48 +0200
Hi,
On Sun, Oct 05, 2003 at 06:16:12PM +0200, Jaeger, Gerhard wrote:
> I've currently added pthread support to the sanei_thread lib and changed
> the Plustek backend, so that it will use threading instead of forking on
> MacOS X. Could somebody please test this?
> Also the detection of pthreads is not correct, please test also...
Just some quick comments, I'll test more during the next few days:
- I think it's good to have support for different types of fork/thread
whatever. However, I'd like to have that completely in sanei_thread
(or wherever). So I'd call sanei_thread_begin in my backend and
don't care if it expands to pthreads, OS/2 threads or fork. This
means some limitations (e.g. only one parameter for OS/2?) and we
have to check that the reader processes work with both threads and
processes. Otherwise we must have #ifdefs for 3 platforms in our
backends as both OS/2 and MacOS need special care now. MacOSX needs
sanei_thread_whatever, OS/2 needs fork() and a encapsulated
reader_process and everything else needs fork() only.
- The docu in include/sane/sanei_thread.h should be updated (but only
when we are sure if we keep the current implementation)
- SANE_CHECK_PTHREAD must go into acinclude.m4. aclocal.m4 is
generated automatically from acinclude.m4 when you run "aclocal".
(After that run autoheader and autoconf). Otherwise it would be
deleted by the next run of aclocal.
- Linking fails on Free- and OpenBSD. I had only a quick look
but I think it's because they don't have a libpthread but pthread.h.
Before adding -lpthread you should check if the lib is available
(not only a header). Maybe you should check for the header first and
then if one of the pthread functions is available (in libc). If it
isn't, try if it's available in libpthread and link that lib.
- I'm not sure if we should use threads by default (link to
libpthread) or only on MacOS X. Maybe that should be a configure
option (--enable-pthreads: default yes on MAcOS, no everwhere else)?
There are other compilation/linking problems on other platforms but
they may not be related to pthread. I'll look later.
Bye,
Henning