From d5ae0bbc3db56be344987ed88876b723e6c8dbea Mon Sep 17 00:00:00 2001 From: Mattias Ellert Date: Thu, 15 May 2008 12:50:25 +0000 Subject: [PATCH] Fix for bug #306751: sanei-thread with pthreads on 64 bit --- ChangeLog | 12 +++++++ backend/agfafocus.h | 2 +- backend/artec_eplus48u.c | 2 +- backend/artec_eplus48u.h | 2 +- backend/avision.h | 2 +- backend/coolscan.h | 2 +- backend/hp-handle.c | 10 +++--- backend/hp3500.c | 2 +- backend/microtek2.h | 2 +- backend/mustek.c | 2 +- backend/mustek.h | 2 +- backend/pie.c | 2 +- backend/pixma.c | 14 ++++---- backend/plustek-pp.h | 2 +- backend/plustek.c | 2 +- backend/plustek.h | 2 +- backend/plustek_pp.c | 2 +- backend/snapscan.c | 7 ++-- backend/snapscan.h | 7 ++-- backend/sp15c.h | 7 ++-- backend/tamarack.h | 2 +- backend/test.c | 6 ++-- backend/test.h | 2 +- backend/u12.c | 2 +- backend/u12.h | 2 +- backend/umax.c | 3 +- backend/umax.h | 2 +- include/sane/sanei_thread.h | 16 +++++++--- sanei/sanei_thread.c | 64 +++++++++++++++++++------------------ 29 files changed, 107 insertions(+), 77 deletions(-) diff --git a/ChangeLog b/ChangeLog index a5346978d..09e6c913b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-05-15 Mattias Ellert + * backend/agfafocus.h, backend/artec_eplus48u.c, + backend/artec_eplus48u.h, backend/avision.h, backend/coolscan.h, + backend/hp-handle.c, backend/hp3500.c, backend/microtek2.h, + backend/mustek.c, backend/mustek.h, backend/pie.c, backend/pixma.c, + backend/plustek-pp.h, backend/plustek.c, backend/plustek.h, + backend/plustek_pp.c, backend/snapscan.c, backend/snapscan.h, + backend/sp15c.h, backend/tamarack.h, backend/test.c, backend/test.h, + backend/u12.c, backend/u12.h, backend/umax.c, backend/umax.h, + include/sane/sanei_thread.h, sanei/sanei_thread.c: + Fix for bug #306751: sanei-thread with pthreads on 64 bit + 2008-04-12 Stéphane Voltz * backend/rts8891.c 150/300 dpi mode fixes for 'XPA' sensor HP4470 models diff --git a/backend/agfafocus.h b/backend/agfafocus.h index c1431289f..078b68e27 100644 --- a/backend/agfafocus.h +++ b/backend/agfafocus.h @@ -120,7 +120,7 @@ typedef struct AgfaFocus_Scanner int lines_available; /* Lines in scanner memory */ int fd; /* SCSI filedescriptor */ - pid_t reader_pid; /* process id of reader */ + SANE_Pid reader_pid; /* process id of reader */ int pipe; /* pipe to reader process */ int reader_pipe; /* pipe from reader process */ diff --git a/backend/artec_eplus48u.c b/backend/artec_eplus48u.c index 32db306c1..d2c9fb2b1 100644 --- a/backend/artec_eplus48u.c +++ b/backend/artec_eplus48u.c @@ -3478,7 +3478,7 @@ static SANE_Status do_cancel (Artec48U_Scanner * s, SANE_Bool closepipe) { struct SIGACTION act; - pid_t res; + SANE_Pid res; XDBG ((1, "do_cancel\n")); s->scanning = SANE_FALSE; diff --git a/backend/artec_eplus48u.h b/backend/artec_eplus48u.h index 14f1ca264..7c3b90751 100644 --- a/backend/artec_eplus48u.h +++ b/backend/artec_eplus48u.h @@ -282,7 +282,7 @@ struct Artec48U_Scanner Artec48U_Device *dev; Artec48U_Line_Reader *reader; FILE *pipe_handle; - int reader_pid; + SANE_Pid reader_pid; int pipe; int reader_pipe; SANE_Option_Descriptor opt[NUM_OPTIONS]; diff --git a/backend/avision.h b/backend/avision.h index 9d00415ac..1ff8d951d 100644 --- a/backend/avision.h +++ b/backend/avision.h @@ -443,7 +443,7 @@ typedef struct Avision_Scanner /* Avision HW Access Connection (SCSI/USB abstraction) */ Avision_Connection av_con; - pid_t reader_pid; /* process id of reader */ + SANE_Pid reader_pid; /* process id of reader */ int read_fds; /* pipe reading end */ int write_fds; /* pipe writing end */ diff --git a/backend/coolscan.h b/backend/coolscan.h index 26a0eec40..d3e415441 100644 --- a/backend/coolscan.h +++ b/backend/coolscan.h @@ -122,7 +122,7 @@ typedef struct Coolscan SANE_Option_Descriptor opt[NUM_OPTIONS]; - pid_t reader_pid; + SANE_Pid reader_pid; int reader_fds; int pipe; int scanning; diff --git a/backend/hp-handle.c b/backend/hp-handle.c index a2cb9f660..8b4bb8ee3 100644 --- a/backend/hp-handle.c +++ b/backend/hp-handle.c @@ -74,7 +74,7 @@ struct hp_handle_s HpDevice dev; SANE_Parameters scan_params; - pid_t reader_pid; + SANE_Pid reader_pid; int child_forked; /* Flag if we used fork() or not */ size_t bytes_left; int pipe_read_fd; @@ -207,7 +207,7 @@ hp_handle_startReader (HpHandle this, HpScsi scsi) return SANE_STATUS_IO_ERROR; } - DBG(1, "start_reader: reader process %d started\n", this->reader_pid); + DBG(1, "start_reader: reader process %ld started\n", (long) this->reader_pid); return SANE_STATUS_GOOD; } @@ -226,7 +226,7 @@ hp_handle_stopScan (HpHandle this) if (this->reader_pid) { int info; - DBG(3, "hp_handle_stopScan: killing child (%d)\n", this->reader_pid); + DBG(3, "hp_handle_stopScan: killing child (%ld)\n", (long) this->reader_pid); if (this->child_forked) { kill(this->reader_pid, SIGTERM); @@ -744,8 +744,8 @@ sanei_hp_handle_cancel (HpHandle this) if ( (this->reader_pid) && (this->dev->compat & HP_COMPAT_OJ_1150C) ) { - DBG(3,"sanei_hp_handle_cancel: send SIGTERM to child (%d)\n", - this->reader_pid); + DBG(3,"sanei_hp_handle_cancel: send SIGTERM to child (%ld)\n", + (long) this->reader_pid); if (this->child_forked) kill(this->reader_pid, SIGTERM); else diff --git a/backend/hp3500.c b/backend/hp3500.c index 3ae834134..071b975c0 100644 --- a/backend/hp3500.c +++ b/backend/hp3500.c @@ -164,7 +164,7 @@ struct hp3500_data int sfd; int pipe_r; int pipe_w; - int reader_pid; + SANE_Pid reader_pid; int resolution; int mode; diff --git a/backend/microtek2.h b/backend/microtek2.h index d8214c5e9..6b83ad0e2 100644 --- a/backend/microtek2.h +++ b/backend/microtek2.h @@ -1144,7 +1144,7 @@ typedef struct Microtek2_Scanner { int cancelled; int sfd; /* SCSI filedescriptor */ int fd[2]; /* file descriptors for pipe */ - pid_t pid; /* pid of child process */ + SANE_Pid pid; /* pid of child process */ FILE *fp; } Microtek2_Scanner; diff --git a/backend/mustek.c b/backend/mustek.c index d5af3a601..5fe63198f 100644 --- a/backend/mustek.c +++ b/backend/mustek.c @@ -2952,7 +2952,7 @@ do_stop (Mustek_Scanner * s) struct timeval now; long int scan_time; long int scan_size; - pid_t pid; + SANE_Pid pid; /* print scanning time */ gettimeofday (&now, 0); diff --git a/backend/mustek.h b/backend/mustek.h index 58a395ddf..57db2954f 100644 --- a/backend/mustek.h +++ b/backend/mustek.h @@ -270,7 +270,7 @@ typedef struct Mustek_Scanner SANE_Bool one_pass_color_scan; SANE_Int resolution_code; int fd; /* SCSI filedescriptor */ - pid_t reader_pid; /* process id of reader */ + SANE_Pid reader_pid; /* process id of reader */ int reader_fds; /* OS/2: pipe write handler for reader */ int pipe; /* pipe to reader process */ long start_time; /* at this time the scan started */ diff --git a/backend/pie.c b/backend/pie.c index 7394b51f6..fd058fb63 100644 --- a/backend/pie.c +++ b/backend/pie.c @@ -307,7 +307,7 @@ typedef struct Pie_Scanner int scanning; /* true if actually doing a scan */ SANE_Parameters params; - pid_t reader_pid; + SANE_Pid reader_pid; int pipe; int reader_fds; diff --git a/backend/pixma.c b/backend/pixma.c index 7e67d4eb9..9b0a0d9e5 100644 --- a/backend/pixma.c +++ b/backend/pixma.c @@ -109,7 +109,7 @@ typedef struct pixma_sane_t unsigned image_bytes_read; unsigned page_count; /* valid for ADF */ - int reader_taskid; + SANE_Pid reader_taskid; int wpipe, rpipe; SANE_Bool reader_stop; } pixma_sane_t; @@ -806,10 +806,10 @@ reader_thread (void *arg) return reader_loop (ss); } -static int +static SANE_Pid terminate_reader_task (pixma_sane_t * ss, int *exit_code) { - int result, pid; + SANE_Pid result, pid; int status = 0; pid = ss->reader_taskid; @@ -847,7 +847,7 @@ static int start_reader_task (pixma_sane_t * ss) { int fds[2]; - int pid; + SANE_Pid pid; int is_forked; if (ss->rpipe != -1 || ss->wpipe != -1) @@ -862,7 +862,7 @@ start_reader_task (pixma_sane_t * ss) if (ss->reader_taskid != -1) { PDBG (pixma_dbg - (1, "BUG:reader_taskid(%d) != -1\n", ss->reader_taskid)); + (1, "BUG:reader_taskid(%ld) != -1\n", (long) ss->reader_taskid)); terminate_reader_task (ss, NULL); } if (pipe (fds) == -1) @@ -898,7 +898,7 @@ start_reader_task (pixma_sane_t * ss) PDBG (pixma_dbg (1, "ERROR:unable to start reader task\n")); return PIXMA_ENOMEM; } - PDBG (pixma_dbg (3, "Reader task id=%d (%s)\n", pid, + PDBG (pixma_dbg (3, "Reader task id=%ld (%s)\n", (long) pid, (is_forked) ? "forked" : "threaded")); ss->reader_taskid = pid; return 0; @@ -957,7 +957,7 @@ read_image (pixma_sane_t * ss, void *buf, unsigned size, int *readlen) ss->image_bytes_read, ss->sp.image_size)); close (ss->rpipe); ss->rpipe = -1; - if (terminate_reader_task (ss, &status) > 0 + if (terminate_reader_task (ss, &status) != -1 && status != SANE_STATUS_GOOD) { return status; diff --git a/backend/plustek-pp.h b/backend/plustek-pp.h index 85360ffd7..65759c8a0 100644 --- a/backend/plustek-pp.h +++ b/backend/plustek-pp.h @@ -602,7 +602,7 @@ typedef union typedef struct Plustek_Scanner { struct Plustek_Scanner *next; - pid_t reader_pid; /* process id of reader */ + SANE_Pid reader_pid; /* process id of reader */ SANE_Status exit_code; /* status of the reader process */ int r_pipe; /* pipe to reader process */ int w_pipe; /* pipe from reader process */ diff --git a/backend/plustek.c b/backend/plustek.c index 528dcf02d..68f045acf 100644 --- a/backend/plustek.c +++ b/backend/plustek.c @@ -566,7 +566,7 @@ static SANE_Status do_cancel( Plustek_Scanner *scanner, SANE_Bool closepipe ) { struct SIGACTION act; - pid_t res; + SANE_Pid res; DBG( _DBG_PROC,"do_cancel\n" ); scanner->scanning = SANE_FALSE; diff --git a/backend/plustek.h b/backend/plustek.h index df7c0b5af..68cf5711a 100644 --- a/backend/plustek.h +++ b/backend/plustek.h @@ -383,7 +383,7 @@ typedef union typedef struct Plustek_Scanner { struct Plustek_Scanner *next; - pid_t reader_pid; /* process id of reader */ + SANE_Pid reader_pid; /* process id of reader */ SANE_Status exit_code; /* status of the reader process */ int r_pipe; /* pipe to reader process */ int w_pipe; /* pipe from reader process */ diff --git a/backend/plustek_pp.c b/backend/plustek_pp.c index 3dafe3386..af089cf18 100644 --- a/backend/plustek_pp.c +++ b/backend/plustek_pp.c @@ -461,7 +461,7 @@ static int reader_process( void *args ) static SANE_Status do_cancel( Plustek_Scanner *scanner, SANE_Bool closepipe ) { struct SIGACTION act; - pid_t res; + SANE_Pid res; short int_cnt; DBG( _DBG_PROC,"do_cancel\n" ); diff --git a/backend/snapscan.c b/backend/snapscan.c index f1f1d8055..8f7dc60bb 100644 --- a/backend/snapscan.c +++ b/backend/snapscan.c @@ -1813,7 +1813,7 @@ void sane_cancel (SANE_Handle h) char *me = "sane_snapscan_cancel"; SnapScan_Scanner *pss = (SnapScan_Scanner *) h; struct SIGACTION act; - pid_t res; + SANE_Pid res; DBG (DL_CALL_TRACE, "%s\n", me); switch (pss->state) @@ -1934,7 +1934,10 @@ SANE_Status sane_get_select_fd (SANE_Handle h, SANE_Int * fd) /* * $Log$ - * Revision 1.71 2008/01/29 17:48:42 kitno-guest + * Revision 1.72 2008/05/15 12:50:24 ellert-guest + * Fix for bug #306751: sanei-thread with pthreads on 64 bit + * + * Revision 1.71 2008-01-29 17:48:42 kitno-guest * fix snapscan bug, add LiDE 600F * * Revision 1.70 2007-11-18 10:59:18 ellert-guest diff --git a/backend/snapscan.h b/backend/snapscan.h index 5a2873751..7913aa25a 100644 --- a/backend/snapscan.h +++ b/backend/snapscan.h @@ -353,7 +353,7 @@ struct snapscan_scanner int opens; /* open count */ int rpipe[2]; /* reader pipe descriptors */ int orig_rpipe_flags; /* initial reader pipe flags */ - pid_t child; /* child reader process pid */ + SANE_Pid child; /* child reader process pid */ SnapScan_Mode mode; /* mode */ SnapScan_Mode preview_mode; /* preview mode */ SnapScan_Source source; /* scanning source */ @@ -424,7 +424,10 @@ struct snapscan_scanner /* * $Log$ - * Revision 1.41 2006/02/02 21:28:05 oliver-guest + * Revision 1.42 2008/05/15 12:50:24 ellert-guest + * Fix for bug #306751: sanei-thread with pthreads on 64 bit + * + * Revision 1.41 2006-02-02 21:28:05 oliver-guest * Corrected USB ID for Benq 310 * * Revision 1.40 2006/01/01 22:57:01 oliver-guest diff --git a/backend/sp15c.h b/backend/sp15c.h index 3d986f070..6522abe02 100644 --- a/backend/sp15c.h +++ b/backend/sp15c.h @@ -49,7 +49,10 @@ static const char RCSid_h[] = "$Header$"; /* ------------------------------------------------------------------------- */ /* * $Log$ - * Revision 1.7 2005/09/19 19:57:48 fzago-guest + * Revision 1.8 2008/05/15 12:50:24 ellert-guest + * Fix for bug #306751: sanei-thread with pthreads on 64 bit + * + * Revision 1.7 2005-09-19 19:57:48 fzago-guest * Replaced __unused__ with __sane_unused__ to avoid a namespace conflict. * * Revision 1.6 2004/11/13 19:53:04 fzago-guest @@ -147,7 +150,7 @@ struct sp15c int scanning; /* "in progress" flag */ int autofeeder; /* detected */ int use_adf; /* requested */ - int reader_pid; /* child is running */ + SANE_Pid reader_pid; /* child is running */ int prescan; /* ??? */ /***** terms for "set window" command *****/ diff --git a/backend/tamarack.h b/backend/tamarack.h index 885e66cd8..65697ac23 100644 --- a/backend/tamarack.h +++ b/backend/tamarack.h @@ -113,7 +113,7 @@ typedef struct Tamarack_Scanner int resolution_code; #endif int fd; /* SCSI filedescriptor */ - pid_t reader_pid; /* process id of reader */ + SANE_Pid reader_pid; /* process id of reader */ int pipe; /* pipe to reader process */ int reader_pipe; /* pipe from reader process */ diff --git a/backend/test.c b/backend/test.c index acd3ee283..5272e1549 100644 --- a/backend/test.c +++ b/backend/test.c @@ -1351,10 +1351,10 @@ finish_pass (Test_Device * test_device) if (test_device->reader_pid != -1) { int status; - int pid; + SANE_Pid pid; - DBG (2, "finish_pass: terminating reader process %d\n", - test_device->reader_pid); + DBG (2, "finish_pass: terminating reader process %ld\n", + (long) test_device->reader_pid); sanei_thread_kill (test_device->reader_pid); pid = sanei_thread_waitpid (test_device->reader_pid, &status); if (pid == -1) diff --git a/backend/test.h b/backend/test.h index a0eff34b4..9392fd979 100644 --- a/backend/test.h +++ b/backend/test.h @@ -126,7 +126,7 @@ typedef struct Test_Device Option_Value val[num_options]; SANE_Parameters params; SANE_String name; - SANE_Int reader_pid; + SANE_Pid reader_pid; SANE_Int reader_fds; SANE_Int pipe; FILE *pipe_handle; diff --git a/backend/u12.c b/backend/u12.c index d04799eee..cfe141d72 100644 --- a/backend/u12.c +++ b/backend/u12.c @@ -385,7 +385,7 @@ static int reader_process( void *args ) static SANE_Status do_cancel( U12_Scanner *scanner, SANE_Bool closepipe ) { struct SIGACTION act; - pid_t res; + SANE_Pid res; DBG( _DBG_PROC,"do_cancel\n" ); diff --git a/backend/u12.h b/backend/u12.h index f085a0f40..5d18c967e 100644 --- a/backend/u12.h +++ b/backend/u12.h @@ -304,7 +304,7 @@ typedef struct u12d typedef struct u12s { struct u12s *next; - pid_t reader_pid; /* process id of reader */ + SANE_Pid reader_pid; /* process id of reader */ SANE_Status exit_code; /* status of the reader process */ int r_pipe; /* pipe to reader process */ int w_pipe; /* pipe from reader process */ diff --git a/backend/umax.c b/backend/umax.c index 668d25490..074c1f7d3 100644 --- a/backend/umax.c +++ b/backend/umax.c @@ -4664,7 +4664,8 @@ static size_t max_string_size(SANE_String_Const strings[]) static SANE_Status do_cancel(Umax_Scanner *scanner) { - int pid, status; + SANE_Pid pid; + int status; DBG(DBG_sane_proc,"do_cancel\n"); diff --git a/backend/umax.h b/backend/umax.h index 297597ffa..682e58b2a 100644 --- a/backend/umax.h +++ b/backend/umax.h @@ -487,7 +487,7 @@ typedef struct Umax_Scanner int scanning; SANE_Parameters params; - pid_t reader_pid; + SANE_Pid reader_pid; int pipe_read_fd; int pipe_write_fd; } Umax_Scanner; diff --git a/include/sane/sanei_thread.h b/include/sane/sanei_thread.h index b2154fd34..5897b0c6a 100644 --- a/include/sane/sanei_thread.h +++ b/include/sane/sanei_thread.h @@ -60,6 +60,12 @@ #define sanei_thread_h #include "../include/sane/config.h" +#ifdef USE_PTHREAD +typedef long SANE_Pid; +#else +typedef int SANE_Pid; +#endif + /** Initialize sanei_thread. * * This function must be called before any other sanei_thread function. @@ -87,7 +93,7 @@ extern SANE_Bool sanei_thread_is_forked (void); * - task id * - -1 if creating the new task failed */ -extern int sanei_thread_begin (int (*func) (void *args), void *args); +extern SANE_Pid sanei_thread_begin (int (*func) (void *args), void *args); /** Terminate spawned task. * @@ -102,7 +108,7 @@ extern int sanei_thread_begin (int (*func) (void *args), void *args); * - 0 on success * - any other value if an error occured while terminating the task */ -extern int sanei_thread_kill (int pid); +extern int sanei_thread_kill (SANE_Pid pid); /** Send a signal to a task. * @@ -117,7 +123,7 @@ extern int sanei_thread_kill (int pid); * - 0 - on success * - any other value - if an error occured while sending the signal */ -extern int sanei_thread_sendsig (int pid, int sig); +extern int sanei_thread_sendsig (SANE_Pid pid, int sig); /** Wait for task termination. * @@ -131,7 +137,7 @@ extern int sanei_thread_sendsig (int pid, int sig); * @return * - the pid of the task we have been waiting for */ -extern int sanei_thread_waitpid (int pid, int *status); +extern SANE_Pid sanei_thread_waitpid (SANE_Pid pid, int *status); /** Check the current status of the spawned task * @@ -142,6 +148,6 @@ extern int sanei_thread_waitpid (int pid, int *status); * - SANE_STATUS_GOOD - if the task finished without errors * - any other value - if the task finished unexpectantly or hasn't finished yet */ -extern SANE_Status sanei_thread_get_status (int pid); +extern SANE_Status sanei_thread_get_status (SANE_Pid pid); #endif /* sanei_thread_h */ diff --git a/sanei/sanei_thread.c b/sanei/sanei_thread.c index 346ac67ad..49f1e5f14 100644 --- a/sanei/sanei_thread.c +++ b/sanei/sanei_thread.c @@ -117,9 +117,9 @@ sanei_thread_is_forked( void ) } int -sanei_thread_kill( int pid ) +sanei_thread_kill( SANE_Pid pid ) { - DBG(2, "sanei_thread_kill() will kill %d\n", (int)pid); + DBG(2, "sanei_thread_kill() will kill %ld\n", (long) pid); #ifdef USE_PTHREAD #if defined (__APPLE__) && defined (__MACH__) return pthread_kill((pthread_t)pid, SIGUSR2); @@ -154,10 +154,10 @@ local_thread( void *arg ) * args pointer to scanner data structure * */ -int +SANE_Pid sanei_thread_begin( int (*func)(void *args), void* args ) { - int pid; + SANE_Pid pid; td.func = func; td.func_data = args; @@ -172,8 +172,8 @@ sanei_thread_begin( int (*func)(void *args), void* args ) return pid; } -int -sanei_thread_waitpid( int pid, int *status ) +SANE_Pid +sanei_thread_waitpid( SANE_Pid pid, int *status ) { if (status) *status = 0; @@ -181,7 +181,7 @@ sanei_thread_waitpid( int pid, int *status ) } int -sanei_thread_sendsig( int pid, int sig ) +sanei_thread_sendsig( SANE_Pid pid, int sig ) { return 0; } @@ -207,10 +207,10 @@ local_thread( void *arg ) * args pointer to scanner data structure * */ -int +SANE_Pid sanei_thread_begin( int (*func)(void *args), void* args ) { - int pid; + SANE_Pid pid; td.func = func; td.func_data = args; @@ -229,8 +229,8 @@ sanei_thread_begin( int (*func)(void *args), void* args ) return pid; } -int -sanei_thread_waitpid( int pid, int *status ) +SANE_Pid +sanei_thread_waitpid( SANE_Pid pid, int *status ) { int32 st; if ( wait_for_thread(pid, &st) < B_OK ) @@ -241,7 +241,7 @@ sanei_thread_waitpid( int pid, int *status ) } int -sanei_thread_sendsig( int pid, int sig ) +sanei_thread_sendsig( SANE_Pid pid, int sig ) { if (sig == SIGKILL) sig = SIGKILLTHR; @@ -325,7 +325,7 @@ restore_sigpipe( void ) #else /* the process stuff */ static int -eval_wp_result( int pid, int wpres, int pf ) +eval_wp_result( SANE_Pid pid, int wpres, int pf ) { int retval = SANE_STATUS_IO_ERROR; @@ -348,12 +348,12 @@ eval_wp_result( int pid, int wpres, int pf ) } #endif -int +SANE_Pid sanei_thread_begin( int (func)(void *args), void* args ) { - int pid; #ifdef USE_PTHREAD struct sigaction act; + int result; pthread_t thread; /* if signal handler for SIGPIPE is SIG_DFL, replace by SIG_IGN */ @@ -372,17 +372,18 @@ sanei_thread_begin( int (func)(void *args), void* args ) td.func = func; td.func_data = args; - pid = pthread_create( &thread, NULL, local_thread, &td ); + result = pthread_create( &thread, NULL, local_thread, &td ); usleep( 1 ); - if ( pid != 0 ) { - DBG( 1, "pthread_create() failed with %d\n", pid ); + if ( result != 0 ) { + DBG( 1, "pthread_create() failed with %d\n", result ); return -1; } - DBG( 2, "pthread_create() created thread %d\n", (int)thread ); - return (int)thread; + DBG( 2, "pthread_create() created thread %ld\n", (SANE_Pid)thread ); + return (SANE_Pid)thread; #else + SANE_Pid pid; pid = fork(); if( pid < 0 ) { DBG( 1, "fork() failed\n" ); @@ -392,7 +393,7 @@ sanei_thread_begin( int (func)(void *args), void* args ) if( pid == 0 ) { /* run in child context... */ - int status = func( args ); + int status = func( args ); /* don't use exit() since that would run the atexit() handlers */ _exit( status ); @@ -404,32 +405,33 @@ sanei_thread_begin( int (func)(void *args), void* args ) } int -sanei_thread_sendsig( int pid, int sig ) +sanei_thread_sendsig( SANE_Pid pid, int sig ) { #ifdef USE_PTHREAD - DBG(2, "sanei_thread_sendsig() %d to thread(id=%d)\n", sig, pid); - return pthread_kill((pthread_t)pid, sig ); + DBG(2, "sanei_thread_sendsig() %d to thread (id=%ld)\n", sig, pid); + return pthread_kill( (pthread_t)pid, sig ); #else DBG(2, "sanei_thread_sendsig() %d to process (id=%d)\n", sig, pid); return kill( pid, sig ); #endif } -int -sanei_thread_waitpid( int pid, int *status ) +SANE_Pid +sanei_thread_waitpid( SANE_Pid pid, int *status ) { #ifdef USE_PTHREAD int *ls; #else int ls; #endif - int result, stat; + SANE_Pid result; + int stat; stat = 0; - DBG(2, "sanei_thread_waitpid() - %d\n", pid); + DBG(2, "sanei_thread_waitpid() - %ld\n", (long) pid); #ifdef USE_PTHREAD - result = pthread_join((pthread_t)pid, (void*)&ls ); + result = pthread_join( (pthread_t)pid, (void*)&ls ); if( 0 == result ) { if( PTHREAD_CANCELED == ls ) { @@ -444,7 +446,7 @@ sanei_thread_waitpid( int pid, int *status ) /* call detach in any case to make sure that the thread resources * will be freed, when the thread has terminated */ - DBG(2, "* detaching thread(%d)\n", pid ); + DBG(2, "* detaching thread(%ld)\n", pid ); pthread_detach((pthread_t)pid); if (status) *status = stat; @@ -468,7 +470,7 @@ sanei_thread_waitpid( int pid, int *status ) #endif /* HAVE_OS2_H */ SANE_Status -sanei_thread_get_status( int pid ) +sanei_thread_get_status( SANE_Pid pid ) { #if defined USE_PTHREAD || defined HAVE_OS2_H || defined __BEOS__ _VAR_NOT_USED( pid );