summaryrefslogtreecommitdiff
path: root/src/c11
Commit message (Collapse)AuthorAgeFilesLines
* c11: Remove _MTX_INITIALIZER_NP for windowsYonggang Luo2022-11-091-2/+0
| | | | | | | Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Acked-by: David Heidelberg <david.heidelberg@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18493>
* c11: Getting the macro guard of HAVE_PTHREAD in c11/threads.h to be ↵Yonggang Luo2022-10-202-3/+3
| | | | | | | | | | | | | | | consistence with util/u_uthread.h The macro guard of #if defined(_WIN32) && !defined(__CYGWIN__) is comes from yohhoy's implementation and that's not consistence with util/u_uthread.h, this caused it's hard to understand. Now we change the behavior that's always rely on how meson detecting HAVE_PTHREAD. So we always disable detecting of threads on Win32 as it's always included in the kernel32 library to avoid detecting pthreads in mingw. Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18425>
* meson/mesa/wide: define WIN32_LEAN_AND_MEAN with pre_argsYonggang Luo2022-10-202-6/+0
| | | | | | Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18425>
* c11: Remove the code for Windows XPYonggang Luo2022-10-201-35/+0
| | | | | | | | | We already require Windows Vista or later before this commit; So the code for Windows XP can be removed. Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18425>
* c11: Update the values of enum mtx_plain, mtx_recursive, mtx_timed to make ↵Yonggang Luo2022-09-141-3/+3
| | | | | | | | | | | | | | | | | | | | | | sure mtx_recursive != mtx_plain | mtx_recursive According to c11 standards, there is 4 variant of mtx_init parameter, mtx_plain mtx_timed mtx_plain|mtx_recursive mtx_timed|mtx_recursive Directly use mtx_recursive is not a thing, so we need make sure mtx_plain and mtx_plain|mtx_recursive are not equal, So now we choose the values from Android c11 threads.h for enum mtx_plain, mtx_recursive, mtx_timed, to make sure c11/threads.h be more c11 conformance, and can raise error when the type parameter of mtx_init are not one of mtx_plain mtx_timed mtx_plain|mtx_recursive mtx_timed|mtx_recursive Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18445>
* c11: #include <threads.h> when the os/platform provide itYonggang Luo2022-08-182-1/+19
| | | | | | | | | | Closes #6964 CC: mesa-stable Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18043>
* c11: Remove mtx_try from mtx enums as it's not a part of c11 standardYonggang Luo2022-08-153-8/+5
| | | | | | | | | | | | | | And we support for four types of mtx init enum values that define by C11 standard: 0 mtx_plain - a simple, non-recursive mutex is created. 2 mtx_timed - a non-recursive mutex, that supports timeout, is created. 1 mtx_plain | mtx_recursive - a recursive mutex is created. 3 mtx_timed | mtx_recursive - a recursive mutex, that supports timeout, is created. musl library also use these enum combination Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18036>
* c11: Implement and use of thrd_current properly on win32Yonggang Luo2022-08-102-28/+47
| | | | | | | | | | Now thrd_t are a struct that contains both thread handle and thread id. For threads that not created by thrd_create, thrd_current are returning pseudo thread handle; but we can still compare threads differences by using thread id. Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17071>
* c11: call impl_tss_dtor_invoke with tls callback for win32Yonggang Luo2022-08-104-3/+46
| | | | | | Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17071>
* c11: It's should detect PTHREAD_DESTRUCTOR_ITERATIONS when define ↵Yonggang Luo2022-08-101-1/+1
| | | | | | | | | | | | | | | | | TSS_DTOR_ITERATIONS INIT_ONCE_STATIC_INIT looks like miscopied from Win32's init once macro Correct implementation for reference https://gitlab.inria.fr/gustedt/p99/-/blob/master/p99/p99_threads_posix.h#L64 C11 standard: https://en.cppreference.com/w/c/thread/TSS_DTOR_ITERATIONS As TSS_DTOR_ITERATIONS didn't used in mesa codebase, so it's won't affect anything in mesa Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17071>
* c11: Fixes the declaration of timespec_get in time.h for macOSYonggang Luo2022-08-091-1/+12
| | | | | | | | | | | | | ../src/util/tests/timespec_test.cpp:327:4: error: use of undeclared identifier 'timespec_get'; did you mean 'timespec_eq'? timespec_get(&a, TIME_UTC); ^~~~~~~~~~~~ timespec_eq ../src/util/timespec.h:299:1: note: 'timespec_eq' declared here timespec_eq(const struct timespec *a, const struct timespec *b) Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Acked-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16995>
* c11: reinstate the original license and authorshipEmil Velikov2022-06-272-4/+50
| | | | | | | | | | | | The original code that was copied in was Boost licensed, so keep that in. Since Yonggang Luo has code quite some work, keep their copyright alongside the original one. Fixes: b2ddec4e98f ("c11: Implement c11/time.h with c11/impl/time.c") Fixes: e6392fcf3d8 ("c11: Move the implementation of threads.h into c source code") Acked-by: Yonggang Luo <luoyonggang@gmail.com> Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17232>
* c11: Implement thread_local in c11/threads.hYonggang Luo2022-06-151-0/+26
| | | | | | | | Use thread_local when possible Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15087>
* c11: Fixes memory leak of pack in thrd_create on win32Yonggang Luo2022-06-151-0/+1
| | | | | | Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15087>
* c11: Move the implementation of threads.h into c source codeYonggang Luo2022-06-155-0/+968
| | | | | | | | | By doing this, now the global variable impl_tss_dtor_tbl are only defined one time. So the memory usage would reduced Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15087>
* c11: Implement timespec_get on win32 properly when not availableYonggang Luo2022-06-091-4/+22
| | | | | | Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15497>
* c11: Implement c11/time.h with c11/impl/time.cYonggang Luo2022-06-093-0/+132
Create c11/time.h instead of put timespec_get in `c11/threads.h` Creating impl folder is used to avoid `#include <time.h>` point the c11/time.h file Detecting if `struct timespec` present with meson Define TIME_UTC in `c11/time.h` instead `c11/threads.h` Define `struct timespec` in `c11/time.h` when not present. Implement timespec_get in c11/impl/time.c instead threads.h Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15497>