Commit Graph

24 Commits

Author SHA1 Message Date
Philip Withnall
25a7c817d3 glib: Add missing (nullable) and (optional) annotations
Add various (nullable) and (optional) annotations which were missing
from a variety of functions. Also port a couple of existing (allow-none)
annotations in the same files to use (nullable) and (optional) as
appropriate instead.

Secondly, add various (not nullable) annotations as needed by the new
default in gobject-introspection of marking gpointers as (nullable). See
https://bugzilla.gnome.org/show_bug.cgi?id=729660.

This includes adding some stub documentation comments for the
assertion macro error functions, which weren’t previously documented.
The new comments are purely to allow for annotations, and hence are
marked as (skip) to prevent the symbols appearing in the GIR file.

https://bugzilla.gnome.org/show_bug.cgi?id=719966
2015-11-07 10:48:32 +01:00
Tim-Philipp Müller
627a145e16 threads: use FUTEX_WAIT_PRIVATE and FUTEX_WAKE_PRIVATE if possible
This avoids some expensive code paths in the kernel, see
http://lwn.net/Articles/229668/

https://bugzilla.gnome.org/show_bug.cgi?id=741442
2015-03-12 21:01:36 -04:00
Daniel Mustieles
078dbda148 Updated FSF's address 2014-01-31 14:31:55 +01:00
Matthias Clasen
2330f7e65e Use __asm__ instead of asm
This is a little more robust as various compiler flags make
gcc forget about asm.

https://bugzilla.gnome.org/show_bug.cgi?id=693299
2014-01-20 08:43:02 -05:00
Dan Winship
13958ee429 gbitlock: fix this to not unconditionally use futex emulation
Ryan accidentally committed some debugging code a long time ago,
causing this file to always use futex emulation even when real futex
support was available. I noticed this a while later and pointed it out
to him, and assumed he was going to fix it, but I guess he assumed I
was going to fix it, and then neither of us did...

https://bugzilla.gnome.org/show_bug.cgi?id=699500
2013-05-04 10:09:39 -04:00
Dan Winship
b8c13a01b6 win32: misc warning fixes
https://bugzilla.gnome.org/show_bug.cgi?id=688109
2012-11-15 14:19:06 -05:00
Simon McVittie
1425aa664d GBitLock: turn assumptions of g_futex_int_address into a static assertion
We'll probably never encounter a platform where these fail, but that's
what static assertions are for...

https://bugzilla.gnome.org/show_bug.cgi?id=548954
2012-01-02 12:23:01 -05:00
Matthias Clasen
4527e7cbf7 gbitlock: Drop @returns syntax from doc comments 2011-11-21 11:09:42 -05:00
Ryan Lortie
2a677d1370 locks: drop _INIT macros
All locks are now zero-initialised, so we can drop the G_*_INIT macros
for them.

Adjust various users around GLib accordingly and change the docs.

https://bugzilla.gnome.org/show_bug.cgi?id=659866
2011-10-02 22:33:10 -04:00
Ryan Lortie
f1d34d0187 libglib: stop using g_cond_new in some places
Port a couple of low-level users of g_cond_new to use G_COND_INIT or
g_cond_init() as appropriate.
2011-09-21 16:06:52 -04:00
Ryan Lortie
f35362f3ae libglib: drop use of GStaticMutex
Use GMutex directly instead.
2011-09-21 15:55:36 -04:00
Ryan Lortie
808035666a gbitlock: #include "gslice.h"
This is needed if we're doing emulated futexes.
2011-09-18 22:21:19 -04:00
Ryan Lortie
413186a962 emufutex: remove init from g_thread_init_glib
Use a GStaticMutex instead.
2011-09-09 13:23:48 -04:00
Christophe Fergeau
602f8baa0b bitlock: don't use asm goto on older gcc
asm goto was addded in gcc 4.5 so don't try to use it on gcc versions
older than this one. This is achieved by explicitly checking gcc
version, an alternative would be to try to compile a program using
asm volatile in configure.

https://bugzilla.gnome.org/show_bug.cgi?id=651959
2011-06-08 22:39:35 -04:00
Ryan Lortie
df0b208831 Implement pointer sized bitlocks
Based on a patch from Alexander Larsson.

https://bugzilla.gnome.org/show_bug.cgi?id=651467
2011-06-03 20:50:18 -04:00
Ryan Lortie
1a80405a36 bitlock: hand-code assembly version for x86
The __sync_fetch_and_or() operation on x86 is a bit suboptimal when the
result isn't ignored.  Normally we could use the 'lock or' assembly
instruction to accomplish this, but this instruction discards the
previous value.

In order to work around this issue, GCC is forced to emit a
compare-and-exchange loop.

We can easily use the 'lock bts' instruction, though.  It can't be used
in the general case for __sync_fetch_and_or() but it works great for our
case (test and set a single bit).

I filed a bug against GCC[1] to get this exposed as a new intrinsic (or
have the optimiser detect the case) but until then we'll hand-code it on
x86 and amd64.

The uncontended case sees a 31% improvement on my test machine.

 [1] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49244

https://bugzilla.gnome.org/show_bug.cgi?id=651467
2011-06-03 17:33:39 -04:00
Ryan Lortie
d09443fe20 optimise bitlocks with new atomic operations
Add a performance test for bitlocks.

Make use of the new g_atomic_int_{and,or} to avoid having to do the
usual compare-and-exchange loop.

On a test machine, the change increases performance from approximately
20 million uncontended acquire/releases per second to 31 million.
2011-05-28 17:39:12 -04:00
Ryan Lortie
858a328792 Fix futex(2) detection and use
Commit 22e7fc34c4 introduced a regression:
futexes were always disabled and the emulated codepath was always being
used.  That commit was in response to an originally buggy
implementationt hat wrote junk into config.h (but happened to be working
properly).

Fix up the mess and while we're at it, close bug #631231 by including
syscall.h from the correct location and using __NR_futex instead of
SYS_futex.

Closes #631231.
2011-05-28 17:27:12 -04:00
Ryan Lortie
2e53e50244 glib/: fully remove galias hacks 2010-07-07 19:34:35 -04:00
Ryan Lortie
e2bc5c2112 g_bit_lock: remove double variable declarations
Remove double declaration of local static variables used for futex
emulation.

Problem found by Haakon Sporsheim <haakon.sporsheim@gmail.com>.
2010-02-01 18:32:34 -05:00
Ryan Lortie
522dafe126 gbitlock: fix gtkdoc brokenness 2010-01-30 12:32:37 -05:00
Ryan Lortie
fe89b2ea29 Since: markers for g_bit_*lock() 2010-01-28 19:12:55 -05:00
Ryan Lortie
40eae351b1 Bug 548967 - 1 bit mutex lock: add tests
Add a test case for the new API.

Always check the emulated futex(2) implementation, even on systems with
futex support.
2010-01-28 18:41:20 -05:00
Ryan Lortie
669b0f2d6b Bug 548967 - 1 bit mutex lock
Add support for a mutex lock that consumes only one bit of storage
inside of an integer on systems that support futexes.  Futex is emulated
(at a higher cost) on systems that don't have it -- but only in the
contended case.
2010-01-28 12:40:46 -05:00