[vlc-commits] [Git][videolan/vlc][master] 4 commits: win32: thread: use a more meaningful value for VLC_THREAD_CANCELED

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu Oct 14 06:51:05 UTC 2021



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
24e41d00 by Steve Lhomme at 2021-10-14T06:35:32+00:00
win32: thread: use a more meaningful value for VLC_THREAD_CANCELED

So we tell the thread was canceled. NULL is usually the value returned by
threads terminating normally.

The proper value to return on a canceled thread is VLC_THREAD_CANCELED.

- - - - -
9c5738e8 by Steve Lhomme at 2021-10-14T06:35:32+00:00
os2: thread: use a more meaningful value for VLC_THREAD_CANCELED

So we tell the thread was canceled. NULL is usually the value returned by
threads terminating normally.

The proper value to return on a canceled thread is VLC_THREAD_CANCELED.

- - - - -
a52361f2 by Steve Lhomme at 2021-10-14T06:35:32+00:00
android: thread: return the proper value when a thread is canceled

- - - - -
c3550f23 by Steve Lhomme at 2021-10-14T06:35:32+00:00
android: thread: use a more meaningful value for VLC_THREAD_CANCELED

So we tell the thread was canceled. NULL is usually the value returned by
threads terminating normally.

- - - - -


4 changed files:

- include/vlc_threads.h
- src/android/thread.c
- src/os2/thread.c
- src/win32/thread.c


Changes:

=====================================
include/vlc_threads.h
=====================================
@@ -57,7 +57,7 @@ VLC_API void vlc_testcancel(void);
 # endif
 
 typedef struct vlc_thread *vlc_thread_t;
-# define VLC_THREAD_CANCELED NULL
+# define VLC_THREAD_CANCELED ((void*) UINTPTR_MAX)
 
 typedef struct vlc_threadvar *vlc_threadvar_t;
 typedef struct vlc_timer *vlc_timer_t;
@@ -85,7 +85,7 @@ static inline int vlc_poll(struct pollfd *fds, unsigned nfds, int timeout)
 # include <errno.h>
 
 typedef struct vlc_thread *vlc_thread_t;
-#define VLC_THREAD_CANCELED NULL
+#define VLC_THREAD_CANCELED ((void*) UINTPTR_MAX)
 
 typedef struct vlc_threadvar *vlc_threadvar_t;
 typedef struct vlc_timer *vlc_timer_t;
@@ -126,7 +126,7 @@ static inline int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
 # define LIBVLC_USE_PTHREAD_CLEANUP   1
 
 typedef struct vlc_thread *vlc_thread_t;
-#define VLC_THREAD_CANCELED NULL
+#define VLC_THREAD_CANCELED ((void*) UINTPTR_MAX)
 typedef pthread_key_t   vlc_threadvar_t;
 typedef struct vlc_timer *vlc_timer_t;
 


=====================================
src/android/thread.c
=====================================
@@ -191,7 +191,7 @@ void vlc_testcancel (void)
     if (!atomic_load(&thread->killed))
         return;
 
-    pthread_exit(NULL);
+    pthread_exit(VLC_THREAD_CANCELED);
 }
 
 /* threadvar */


=====================================
src/os2/thread.c
=====================================
@@ -589,7 +589,7 @@ void vlc_testcancel (void)
          p->proc (p->data);
 
     DosPostEventSem( th->done_event );
-    th->data = NULL; /* TODO: special value? */
+    th->data = VLC_THREAD_CANCELED;
     vlc_thread_cleanup (th);
     _endthread();
 }


=====================================
src/win32/thread.c
=====================================
@@ -468,7 +468,7 @@ noreturn static void vlc_docancel(struct vlc_thread *th)
     for (vlc_cleanup_t *p = th->cleaners; p != NULL; p = p->next)
         p->proc (p->data);
 
-    th->data = NULL; /* TODO: special value? */
+    th->data = VLC_THREAD_CANCELED;
 #ifdef VLC_WINSTORE_APP
     ExitThread(0);
 #else // !VLC_WINSTORE_APP



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/231338e4a98f164c12e9665bd60a50c37de562a1...c3550f2348b54e05667ee45afc3b4b68eb050afb

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/231338e4a98f164c12e9665bd60a50c37de562a1...c3550f2348b54e05667ee45afc3b4b68eb050afb
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list