Commit Graph

9951 Commits

Author SHA1 Message Date
Matthias Clasen
4cd0b86103 Add pointer bitlocks to the docs 2011-06-03 20:54:32 -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
Giovanni Campagna
f2bd54d0c5 gvariant: fix introspection annotations
g_variant_get_strv and g_variant_get_bytestring return arrays that
are null terminated and have an explicit length. Since gjs doesn't
support (out) arrays with length, mark them also null-terminated
(but leave the length annotation, so pygobject can remove the argument)

https://bugzilla.gnome.org/show_bug.cgi?id=646635
2011-06-03 16:39:43 -04:00
David Zeuthen
53ced63c6d Fix include path for gdbus-codegen example XML
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-06-03 14:45:29 -04:00
David Zeuthen
6d54505b2d Fix docs for D-Bus introspection data structures
Mark structs as boxed types and use /*< public >*/ so the struct
members are properly shown.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-06-03 14:39:04 -04:00
David Zeuthen
723adbc2fe Move gdbus-codegen example code and docs into separate directories
This avoids the generated types (e.g. ExampleAnimal, ExampleCat,
ExampleObject and ExampleObjectManagerClient) being referenced in the
core gio docs. This was requested by Matthias.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-06-03 14:18:56 -04:00
Colin Walters
3bd3067ffc gobject: Use _ prefixing in private headers over G_GNUC_INTERNAL in public headers
This helps out gtk-doc and g-ir-scanner, and also makes much clearer
what's private versus public.

https://bugzilla.gnome.org/show_bug.cgi?id=651745
2011-06-03 12:40:01 -04:00
Colin Walters
d51198baad spawn-multithreaded: New test case
We didn't have any coverage of threads spawning processes, which we
should definitely support.

https://bugzilla.gnome.org/show_bug.cgi?id=651725
2011-06-03 11:43:26 -04:00
Colin Walters
c34a6a66e7 gmain: Consolidate UNIX signal init state handling
For a future signalfd() patch, it will be easier to handle if
we don't separate initialization from watching for a particular
signal.

https://bugzilla.gnome.org/show_bug.cgi?id=651725
2011-06-03 11:38:18 -04:00
Colin Walters
6ea274bca4 gmain: Clean up SIGCHLD handling
Unify it more with the rest of the signal handling code.  There's
no reason not to specify SA_RESTART and SA_NOCLDSTOP for flags
always, so just do it.

Remove unnecessary initialization, and push the internal API
towards just ensure_unix_signal_handler_installed_unlocked().

https://bugzilla.gnome.org/show_bug.cgi?id=651725
2011-06-03 11:38:18 -04:00
Hanro
16bdb12e6d gkeyfile: Only test file descriptors against -1
Windows CE at least will return other (valid) negative values.
2011-06-02 15:44:19 -04:00
Colin Walters
7ed328aaf0 gdbus: Avoid blocking on worker thread in connection initialization
I can't see a reason to spin until the worker thread runs, so don't.
This avoids ugly sched_yield() calls that show up in strace and
annoy me; the code is cleaner now too.

We now grab the types needed for the WebKit workaround in the
thread creation area, but only release them when the thread itself
exits.

https://bugzilla.gnome.org/show_bug.cgi?id=651650
2011-06-01 16:43:34 -04:00
Matthias Clasen
a588974561 Expand content type docs slighly 2011-05-31 19:27:04 -04:00
Matthias Clasen
151016922d Add a note about atomic changes 2011-05-31 14:53:30 -04:00
Colin Walters
a06863de60 Add a boxed type for GVariantBuilder, mark GVariantIter as (skip)
Based on a patch by Giovanni Campagna <gcampagna@src.gnome.org>

From discussion, GVariantIter is not useful for bindings, but
GVariantBuilder may be.

https://bugzilla.gnome.org/show_bug.cgi?id=646635
2011-05-31 13:37:14 -04:00
Colin Walters
6af9dd5135 gutils.c: Annotation fixes 2011-05-31 13:25:09 -04:00
Colin Walters
581ed51f0d g_shell_parse_argv: Annotate 2011-05-31 13:10:28 -04:00
Colin Walters
98ebc596cf gfileutils: Annotations for g_file_{get,set}_contents
These are actually byte arrays.
2011-05-31 12:00:41 -04:00
Colin Walters
2300be5be3 Consistently use G_GNUC_EXTENSION instead of __extension__
g-ir-scanner doesn't like __extension__, and while I can add it, since
we have this macro, we should be using it consistently.
2011-05-31 10:35:38 -04:00
muralis
a84e6f982f gthreadedresolver: fix hang on g_thread_pool_push() failure
In resolve_sync function in gthreadedresolver.c, if g_thread_pool_push
fails due to thread creation failure, we are just simply appending the
data to the queue of work to do. After the failure, we might wait
indefinitely in g_cond_wait. In case of g_thread_pool_push failure,
propagate the error so that this function does not blocks forever in
case of failure.

https://bugzilla.gnome.org/show_bug.cgi?id=651034
2011-05-31 08:56:50 -04:00
Carles Ferrando
fb34889871 [l10n]Updated Catalan (Valencian) translation 2011-05-29 14:04:16 +02:00
Jorge González
59098fcc9b Updated Spanish translation 2011-05-29 09:47:30 +02:00
Matthias Clasen
807d41b89b Documentation fixups 2011-05-29 00:05:07 -04:00
Matthias Clasen
85ab379ac6 Clean up includes 2011-05-28 23:27:24 -04:00
Matthias Clasen
23b6691428 Reduce excessive whitespace 2011-05-28 23:15:07 -04:00
Matthias Clasen
a3c3aaa499 Remove redundant comments
The comments in gthreadpool.h were duplicating the
doc comments in the sources.
2011-05-28 22:49:59 -04:00
Matthias Clasen
666adc2dc0 Volatile not necessary after all
I was temporarily confused.
2011-05-28 22:33:37 -04:00
Matthias Clasen
53f93aacf3 GTree: Declare ref_count as volatile 2011-05-28 22:03:05 -04:00
Matthias Clasen
a4f00f39da GAsyncQueue: Make ref_count a volatile gint 2011-05-28 22:02:13 -04:00
Matthias Clasen
a33abe9c21 GAsyncQueue: Remove excessive atomic operations
Almost every function was double-checking the ref count,
unnecessarily.
2011-05-28 21:43:45 -04:00
Matthias Clasen
edc7fde495 GArray: Avoid unncessary atomic accesses to refcounts
Not really necessary to double-check the ref-count.
2011-05-28 21:41:08 -04:00
Matthias Clasen
abf719362a GHash: Avoid nonatomic access to the reference count
Not really necessary to constantly double-check the ref
count, anyway.
2011-05-28 21:40:12 -04:00
Matthias Clasen
f12650392b Fix a typo 2011-05-28 21:14:36 -04:00
Matthias Clasen
d35e83d337 Documentation tweaks
Add Since tags, etc.
2011-05-28 21:12:52 -04:00
Neil Roberts
2df4750ace gsocket: Fix some cases of returning error without setting *error
g_socket_shutdown and g_socket_close were calling check_socket with a
NULL error parameter so any errors wouldn't get propagated up.

https://bugzilla.gnome.org/show_bug.cgi?id=651327
2011-05-28 19:46:15 -04:00
Neil Roberts
0703dbc21f gsocket: Fix the error message for a failed g_socket_shutdown
The GError message for g_socket_shutdown was reporting that it was
"Unable to create socket" which is presumably a cut-and-paste bug.

https://bugzilla.gnome.org/show_bug.cgi?id=651327
2011-05-28 19:46:14 -04:00
Antoine Jacoutot
56c0d0f384 Fix compile warnings on OpenBSD.
https://bugzilla.gnome.org/show_bug.cgi?id=651223
2011-05-28 18:59:38 -04:00
Matthias Clasen
05c7dcab37 Remove unnecessary casts
The new atomic implementations don't need these anymore to
avoid warnings.
2011-05-28 18:42:09 -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
8382135265 glib: Rewrite gatomic.[ch]
- remove all inline assembly versions

 - implement the atomic operations using either GCC intrinsics, the
   Windows interlocked API or a mutex-based fallback

 - drop gatomic-gcc.c since these are now defined in the header file.
   Adjust Makefile.am accordingly.

 - expand the set of operations: support 'get', 'set', 'compare and
   exchange', 'add', 'or', and 'xor' for both integers and pointers

 - deprecate g_atomic_int_exchange_and_add since g_atomic_int_add (as
   with all the new arithmetic operations) now returns the prior value

 - unify the use of macros: all functions are now wrapped in macros that
   perform the proper casts and checks

 - remove G_GNUC_MAY_ALIAS use; it was never required for the integer
   operations (since casting between pointers that only vary in
   signedness of the target is explicitly permitted) and we avoid the
   need for the pointer operations by using simple 'void *' instead of
   'gpointer *' (which caused the 'type-punned pointer' warning)

 - provide function implementations of g_atomic_int_inc and
   g_atomic_int_dec_and_test: these were strictly macros before

 - improve the documentation to make it very clear exactly which types
   of pointers these operations may be used with

 - remove a few uses of the now-deprecated g_atomic_int_exchange_and_add

 - drop initialisation of gatomic from gthread (by using a GStaticMutex
   instead of a GMutex)

 - update glib.symbols and documentation sections files

Closes #650823 and #650935
2011-05-28 16:10:44 -04:00
Matthias Clasen
2fb57ff46f Quiet down the build a bit 2011-05-28 14:29:08 -04:00
Matthias Clasen
ae85e3b7b6 Quell warnings from g_once_init_enter_impl 2011-05-28 13:59:20 -04:00
Matthias Clasen
f5bc2e00c7 Trivial: fix a variable name
It is indices, not indeces.
2011-05-28 13:57:47 -04:00
Simon McVittie
22cc6ce679 Add a regression test for GNOME#642026
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=642026
Bug-NB: NB#257512
2011-05-28 10:00:42 -04:00
Simon McVittie
e83210425f GStaticPrivate: protect GRealThread.private_data with a bit-lock
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=642026
Bug-NB: NB#257512
2011-05-28 10:00:41 -04:00
Simon McVittie
83f1b12388 Refactor GStaticPrivate accessors to facilitate protecting them with locks
* g_static_private_get: have a single entry and exit

* g_static_private_set: delay creation of GArray so the whole tail of
  the function can be under the private_data lock without risking
  deadlock with the g_thread lock; call the destructor last, after
  we could have unlocked

* g_static_private_free: choose next thread in list before accessing
  private_data, to keep all accesses together

* g_thread_cleanup: steal private_data first, then work exclusively with
  the stolen array (which doesn't need to be under a lock any more)

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=642026
Bug-NB: NB#257512
2011-05-28 10:00:40 -04:00
Simon McVittie
b05f0b351c g_static_private_free: defer non-trivial destruction til after we unlock
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=642026
Bug-NB: NB#257512
2011-05-28 10:00:40 -04:00
Simon McVittie
d5f0ec1e8e GRealThread: remove obsolete comment about gmain.c, which no longer has a copy
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=642026
Bug-NB: NB#257512
2011-05-28 10:00:39 -04:00