summaryrefslogtreecommitdiff
path: root/sanei/sanei_thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'sanei/sanei_thread.c')
-rw-r--r--sanei/sanei_thread.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/sanei/sanei_thread.c b/sanei/sanei_thread.c
index fcf52c1..f701423 100644
--- a/sanei/sanei_thread.c
+++ b/sanei/sanei_thread.c
@@ -115,20 +115,22 @@ sanei_thread_is_forked( void )
/* Use this to mark a SANE_Pid as invaild instead of marking with -1.
*/
+#ifdef USE_PTHREAD
static void
sanei_thread_set_invalid( SANE_Pid *pid )
{
#ifdef WIN32
#ifdef WINPTHREAD_API
- *pid = 0;
+ *pid = (pthread_t) 0;
#else
pid->p = 0;
#endif
#else
- *pid = -1;
+ *pid = (pthread_t) -1;
#endif
}
+#endif
/* Return if PID is a valid PID or not. */
SANE_Bool
@@ -162,12 +164,12 @@ sanei_thread_pid_to_long( SANE_Pid pid )
#ifdef WIN32
#ifdef WINPTHREAD_API
- rc = pid;
+ rc = (long) pid;
#else
rc = pid.p;
#endif
#else
- rc = pid;
+ rc = (long) pid;
#endif
return rc;
@@ -225,7 +227,7 @@ sanei_thread_begin( int (*func)(void *args), void* args )
DBG( 1, "_beginthread() failed\n" );
return -1;
}
-
+
DBG( 2, "_beginthread() created thread %d\n", pid );
return pid;
}
@@ -282,7 +284,7 @@ sanei_thread_begin( int (*func)(void *args), void* args )
DBG( 1, "resume_thread() failed\n" );
return -1;
}
-
+
DBG( 2, "spawn_thread() created thread %d\n", pid );
return pid;
}
@@ -374,7 +376,7 @@ restore_sigpipe( void )
sigemptyset( &act.sa_mask );
act.sa_flags = 0;
act.sa_handler = SIG_DFL;
-
+
DBG( 2, "restoring SIGPIPE to SIG_DFL\n" );
sigaction( SIGPIPE, &act, NULL );
}
@@ -443,7 +445,7 @@ sanei_thread_begin( int (func)(void *args), void* args )
}
else
DBG( 2, "pthread_create() created thread %ld\n",
- (SANE_Pid)thread );
+ sanei_thread_pid_to_long(thread) );
return (SANE_Pid)thread;
#else
@@ -458,7 +460,7 @@ sanei_thread_begin( int (func)(void *args), void* args )
/* run in child context... */
int status = func( args );
-
+
/* don't use exit() since that would run the atexit() handlers */
_exit( status );
}
@@ -511,10 +513,11 @@ sanei_thread_waitpid( SANE_Pid pid, int *status )
}
if ( EDEADLK == rc ) {
if ( (pthread_t)pid != pthread_self() ) {
- /* call detach in any case to make sure that the thread resources
+ /* call detach in any case to make sure that the thread resources
* will be freed, when the thread has terminated
*/
- DBG(2, "* detaching thread(%ld)\n", pid );
+ DBG(2, "* detaching thread(%ld)\n",
+ sanei_thread_pid_to_long(pid) );
pthread_detach((pthread_t)pid);
}
}