diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2019-07-31 16:59:49 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2019-07-31 16:59:49 +0200 |
commit | 1687222e1b9e74c89cafbb5910e72d8ec7bfd40f (patch) | |
tree | d78102ce30207c63e7608eeba743efd680c888dc /sanei/sanei_thread.c | |
parent | 58912f68c2489bcee787599837447e0d64dfd61a (diff) |
New upstream version 1.0.28upstream/1.0.28
Diffstat (limited to 'sanei/sanei_thread.c')
-rw-r--r-- | sanei/sanei_thread.c | 25 |
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); } } |