[waffle] [PATCH 16/33] third_party/threads: import c11 threads emulation wrappers

Chad Versace chad.versace at linux.intel.com
Mon Jul 21 21:44:59 PDT 2014


On 07/07/2014 10:28 AM, Emil Velikov wrote:
> Will be used to simplify/abstract the threads differences
> across posix/win32 waffle.
> 
> Based upon https://gist.github.com/2223710 with modifications from mesa:
>  - retain XP compatability
>  - add temporary hack for static mutex initializers (as they are not part
>    of the stack but still widely used internally)
>  - make TIME_UTC a conditional macro (some system headers already define
>    it, so this prevents conflict)
>  - fix missing pthread_mutex_timedlock declaration warnings on MacOSX
>  - do not use pthread_mutex_timedlock on NetBSD
>  - fix nano to milisecond conversion, per
>    https://gist.github.com/yohhoy/2223710/#comment-710118
>  - don't implement thrd_current on Windows
>  - don't include assert.h if the assert macro is already defined
> 
> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
> ---
>  CMakeLists.txt                      |   6 +
>  third_party/threads/CMakeLists.txt  |  18 ++
>  third_party/threads/LICENSE         |  29 ++
>  third_party/threads/threads.h       | 180 ++++++++++++
>  third_party/threads/threads_posix.c | 325 ++++++++++++++++++++++
>  third_party/threads/threads_win32.c | 527 ++++++++++++++++++++++++++++++++++++
>  6 files changed, 1085 insertions(+)
>  create mode 100644 third_party/threads/CMakeLists.txt
>  create mode 100644 third_party/threads/LICENSE
>  create mode 100644 third_party/threads/threads.h
>  create mode 100644 third_party/threads/threads_posix.c
>  create mode 100644 third_party/threads/threads_win32.c

This patch gives me the warnings below. The warnings look like scary type that
will eat you alive when your least expecting, so the warnings need fixing
before committing these files to Waffle.

Other than the warnings, the patch looks good to me.

-- Build files have been written to: /home/chadv/proj/hh/default/out/profiles/debug/build/waffle
ninja: Entering directory `/home/chadv/proj/hh/default/out/profiles/debug/build/waffle'
[9/146] Building C object third_party/threads/CMakeFiles/threads_bundled.dir/threads_posix.c.o
/home/chadv/proj/hh/default/src/waffle/third_party/threads/threads_posix.c: In function ‘impl_thrd_routine’:
/home/chadv/proj/hh/default/src/waffle/third_party/threads/threads_posix.c:69:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     return (void*)pack.func(pack.arg);
            ^
/home/chadv/proj/hh/default/src/waffle/third_party/threads/threads_posix.c: In function ‘thrd_exit’:
/home/chadv/proj/hh/default/src/waffle/third_party/threads/threads_posix.c:256:18: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     pthread_exit((void*)res);
                  ^
/home/chadv/proj/hh/default/src/waffle/third_party/threads/threads_posix.c: In function ‘thrd_join’:
/home/chadv/proj/hh/default/src/waffle/third_party/threads/threads_posix.c:266:16: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
         *res = (int)code;


More information about the waffle mailing list