summaryrefslogtreecommitdiffstats
path: root/include/c11
Commit message (Collapse)AuthorAgeFilesLines
* Introduce .editorconfigEric Engestrom2016-08-311-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | A few weeks ago, Jose Fonseca suggested [0] we use .editorconfig files to try and enforce the formatting of the code, to which Michel Dänzer suggested [1] we start by importing the existing .dir-locals.el settings. The first draft was discussed in the RFC [2]. These .editorconfig are a first step, one that has the advantage of requiring little to no intervention from the devs once the settings files are in place, but the settings are very limited. This does have the advantage of applying while the code is being written. This doesn't replace the need for more comprehensive formatting tools such as clang-format & clang-tidy, but those reformat the code after the fact. [0] https://lists.freedesktop.org/archives/mesa-dev/2016-June/121545.html [1] https://lists.freedesktop.org/archives/mesa-dev/2016-June/121639.html [2] https://lists.freedesktop.org/archives/mesa-dev/2016-July/123431.html Acked-by: Nicolai Hähnle <nicolai.haehnle@amd.com> Acked-by: Eric Anholt <eric@anholt.net> Signed-off-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
* Disable use of weak in threads_posix.h on CygwinJon Turney2016-07-151-1/+1
| | | | | | | | | Weak doesn't work the same on PE/COFF as on ELF, they are only weak references. Specifically, since nothing else pulls in the object which contains pthread_mutexattr_init() (and coming from the C library, that is the only thing that object contains), means that it ends up as 0 Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
* c11/threads: resolve link issues with -O0Emil Velikov2016-05-241-0/+26
| | | | | | | | | | | | | | | | | | | Add weak symbol notation for the pthread_mutexattr* symbols, thus making the linker happy. When building with -O1 or greater the optimiser will kick in and remove the said functions as they are dead/unreachable code. Ideally we'll enable the optimisations locally, yet that does not seem to work atm. v2: Add the AX_GCC_FUNC_ATTRIBUTE([weak]) hunk in configure. Cc: Alejandro Piñeiro <apinheiro@igalia.com> Cc: Ben Widawsky <ben@bwidawsk.net> Cc: Ilia Mirkin <imirkin@alum.mit.edu> Cc: Rob Herring <robh@kernel.org> Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Tested-by: Rob Clark <robdclark@gmail.com> Tested-by: Mark Janes <mark.a.janes@intel.com>
* c11/threads: create mutexattrs only when neededEmil Velikov2016-05-231-2/+7
| | | | | | | | If the mutexattrs are the default one can just pass NULL to pthread_mutex_init. As the compiler does not know this detail it unnecessarily creates/destroys the attrs. Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
* c11/threads: initialize timeout structureJan Vesely2015-10-081-0/+6
| | | | | Signed-off-by: Jan Vesely <jano.vesely@gmail.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
* c11/threads: Assert that mtx is non-NULL and check return values.Matt Turner2015-09-251-25/+23
| | | | | | | | | | | | Passing NULL to C11 threads functions isn't safe, so there's no need for our implementation to handle it. Cuts about 1k of .text. text data bss dec hex filename 5009514 198440 26328 5234282 4fde6a i965_dri.so before 5008346 198440 26328 5233114 4fd9da i965_dri.so after Reviewed-by: Timothy Arceri <t_arceri@yahoo.com.au> Reviewed-by: Brian Paul <brianp@vmware.com>
* c11/threads: Use PTHREAD_MUTEX_RECURSIVE by defaultFelix Janda2015-03-161-6/+1
| | | | | | | | | | | | Previously PTHREAD_MUTEX_RECURSIVE_NP had been used on linux for compatibility with old glibc. Since mesa defines __GNU_SOURCE__ on linux PTHREAD_MUTEX_RECURSIVE is also available since at least 1998. So we can unconditionally use the portable version PTHREAD_MUTEX_RECURSIVE. Cc: "10.5" <mesa-stable@lists.freedesktop.org> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88534 Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
* c11/threads: correct assertionEmil Velikov2014-08-121-1/+1
| | | | | | | | | | We should assert when either the function or the flag pointer is null or we'll end up with a null reference a few lines later. Currently unused by mesa thus it has gone unnoticed. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
* c11/threads: don't include assert.h if the assert macro is already definedBrian Paul2014-03-192-0/+4
| | | | | | | | | | | | | | | | | In the gallium code, the assert() macro could come from either the system's assert.h file (via c11/threads.h) or from gallium's u_debug.h. It looks like all known assert.h files unconditionally #undef assert before defining their own version. So the assert you get depends on whether threads.h or u_debug.h was included last. In the gallium code we really want to use the assert() from u_debug.h (it behaves better on Windows). In gallium, c11/threads.h is only included after u_debug.h in the os_thread.h wrapper. So Adding an #ifndef assert test in the threads*.h files avoids using the system's assert(). Cc: "10.1" <mesa-stable@lists.freedesktop.org> Reviewed-by: José Fonseca <jfonseca@vmware.com>
* c11/threads: Don't implement thrd_current on Windows.José Fonseca2014-03-041-2/+32
| | | | | | | | | | | | | | | | | | | | | | GetCurrentThread() returns a pseudo-handle (a constant which only makes sense when used within the calling thread) and not a real handle. DuplicateHandle() will return a real handle, but it will create a new handle every time we call. Calling DuplicateHandle() here means we will leak handles, which can cause serious problems. In short, the Windows implementation of thrd_t needs a thorough make over, and it won't be pretty. It looks like C11 committee over-simplified things: it would be much better to have seperate objects for threads and thread IDs like C++11 does. For now, just comment out the thrd_current() implementation, so we get build errors if anybody tries to use it. Thanks to Brian Paul for spotting and diagnosing this problem. Cc: "10.0" "10.1" <mesa-stable@lists.freedesktop.org> Reviewed-by: Brian Paul <brianp@vmware.com>
* c11/threads: Fix nano to milisecond conversion.José Fonseca2014-03-041-1/+1
| | | | | | | | Per https://gist.github.com/yohhoy/2223710/#comment-710118 Cc: "10.0" "10.1" <mesa-stable@lists.freedesktop.org> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Michel Dänzer <michel@daenzer.net>
* c11: Add missing stdlib.h include.José Fonseca2014-01-281-0/+1
| | | | | | For malloc/free. Silences gcc mingw warnings.
* c11: Do not use pthread_mutex_timedlock on NetBSD.Vinson Lee2014-01-241-1/+1
| | | | | | | | | | | | This patch fixes the NetBSD build. NetBSD does not have pthread_mutex_timedlock. CC glapi_dispatch.lo threads_posix.h: In function 'mtx_timedlock': threads_posix.h:216:5: error: implicit declaration of function 'pthread_mutex_timedlock' Signed-off-by: Vinson Lee <vlee@freedesktop.org>
* c11: Fix missing pthread_mutex_timedlock declaration warnings on MacOSX.José Fonseca2014-01-231-1/+7
|
* c11: Update docs/license.html and include verbatim copy of Boost license.José Fonseca2014-01-233-3/+66
|
* c11: Import threads.h emulation library.José Fonseca2014-01-233-0/+992
Implementation is based of https://gist.github.com/2223710 with the following modifications: - inline implementatation - 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) - respect HAVE_PTHREAD macro Reviewed-by: Brian Paul <brianp@vmware.com> Acked-by: Ian Romanick <ian.d.romanick@intel.com> Acked-by: Chad Versace <chad.versace@linux.intel.com>