Commit Graph

11188 Commits

Author SHA1 Message Date
Ryan Lortie
3d13ee1b5f GVariant format string docs: fix maybe types
The documentation for maybe types failed to mention 'a' as one of the
types that was handled with a single pointer for which NULL means
"nothing".  Correct that omission.

Problem caught by Shaun McCance.
2011-10-21 15:04:37 -04:00
Matthias Clasen
e52437982c Make g_ascii_strtod behave as documented
The docs explicitly state that we reset errno, so lets do that,
even if we just wrap strtod_l. Also move the argument check
out of the ifdef.

https://bugzilla.gnome.org/show_bug.cgi?id=662398
2011-10-21 15:00:14 -04:00
Simon McVittie
848df03e16 GDBusConnection: check for initializedness in most public API
The only exceptions are those of the trivial getters/setters that don't
already need the initialization check for its secondary role as a memory
barrier (this is consistent with GSocket, where trivial getters/setters
don't check):

* g_dbus_connection_set_exit_on_close
* g_dbus_connection_get_exit_on_close
* g_dbus_connection_is_closed

g_dbus_connection_set_exit_on_close needs to be safe for
use before initialization anyway, so it can be set at construct-time.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=661689
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: David Zeuthen <davidz@redhat.com>
2011-10-21 16:02:33 +01:00
Simon McVittie
3958a9fc1e GDBusConnection: document use while uninitialized as undefined behaviour
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=661689
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=662208
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: David Zeuthen <davidz@redhat.com>
2011-10-21 16:02:31 +01:00
Simon McVittie
a7ea949294 GDBusConnection: check for initialization where needed for thread-safety
Also document which fields require such a check in order to have correct
threading semantics.

This usage doesn't matches the GInitable documentation, which suggests
use of a GError - but using an uninitialized GDBusConnection is
programming error, and not usefully recoverable. (The GInitable
documentation may have been a mistake - GNOME#662208.) Also, not all of
the places where we need it can raise a GError.

The check serves a dual purpose: it turns a non-deterministic crash into
a deterministic critical warning, and is also a memory barrier for
thread-safety. All of these functions dereference or return fields that
are meant to be protected by FLAG_INITIALIZED, so they could crash or
return an undefined value to their caller without this, if called from a
thread that isn't the one that called initable_init() (although I can't
think of any way to do that without encountering a memory barrier,
undefined behaviour, or a race condition that leads to undefined
behaviour if the non-initializing thread wins the race).

One exception is that initable_init() itself makes a synchronous call.
We deal with that by passing new internal flags up the call stack, to
reassure g_dbus_connection_send_message_unlocked() that it can go ahead.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=661689
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=661992
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: David Zeuthen <davidz@redhat.com>
2011-10-21 16:02:27 +01:00
Simon McVittie
245d68be6f GDBusConnection: replace is_initialized with an atomic flag
The comment implied that even failed initialization would set
is_initialized = TRUE, but this wasn't the case - failed initialization
would only set initialization_error, and it was necessary to check both.

It turns out the documented semantics are nicer than the implemented
semantics, since this lets us use atomic operations, which are also
memory barriers, to avoid needing separate memory barriers or locks
for initialization_error (and other members that are read-only after
construction).

I expect to need more than one atomically-accessed flag to fix thread
safety, so instead of a minimal implementation I've turned is_initialized
into a flags word.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=661689
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=661992
Reviewed-by: David Zeuthen <davidz@redhat.com>
2011-10-21 16:02:22 +01:00
Chun-wei Fan
e1a481ec0a Fix VS 2008 property sheet
Missed a required ';'-sorry about this.  DOH! :|
2011-10-20 14:42:51 +08:00
Matthias Clasen
269acbe703 Deprecate g_atexit
This function was just not a good idea to begin with.
Its documentation gives plenty of reason not to use it.
2011-10-19 21:03:43 -04:00
Cosimo Cecchi
3569af4af1 desktop-app-info: annotate g_desktop_app_info_get_keywords()
https://bugzilla.gnome.org/show_bug.cgi?id=662096
2011-10-19 17:27:21 -04:00
Ryan Lortie
9da3dc292c more NEWS 2011-10-19 15:26:25 -04:00
Ryan Lortie
2a98cc635e The usual docs unbreaking... 2011-10-19 15:07:22 -04:00
Ryan Lortie
3fd412549f configure.ac: join the cargo-cult of _cv_
For some reason, the setting of g_atomic_lock_free wasn't making it down
to the lower part of the configure script where glibconfig.h was being
generated when building using mingw32-configure.

If we prefix glib_cv_ to the start of the variable name (like everyone
else is doing) then it magically starts working.

I love you, automake.
2011-10-19 10:11:54 -04:00
Simon McVittie
612d238467 gdbus-non-socket test: avoid use of a GMainContext across a fork
See https://bugzilla.gnome.org/show_bug.cgi?id=658999 for why this would
be bad.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=662100
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: David Zeuthen <davidz@redhat.com>
2011-10-19 10:50:02 +01:00
Simon McVittie
be89f052c2 gdbus-exit-on-close test: cover more possibilities
We didn't previously test anything except the implicit default of TRUE.
Now we test implicit TRUE, explicit TRUE, explicit FALSE, and
disconnecting at the local end (which regressed while fixing Bug #651268).

Also avoid some questionable use of a main context, which fell foul of
Bug #658999 and caused this test to be disabled in master.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=662100
Bug-NB: NB#287088
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: David Zeuthen <davidz@redhat.com>
2011-10-19 10:50:02 +01:00
Simon McVittie
5e0492da50 GDBusWorker: if a read was cancelled it means we closed the connection
This was a regression caused by my previous work on GDBusWorker thread-safety
(Bug #651268). The symptom is that if you disconnect a GDBusConnection
locally, the default implementation of GDBusConnection::closed
terminates your process, even though it shouldn't do that for
locally-closed connections; this is because GDBusWorker didn't think a
cancelled read was a local close.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=662100
Bug-NB: NB#287088
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: David Zeuthen <davidz@redhat.com>
2011-10-19 10:49:56 +01:00
Simon McVittie
6c33e1cd9d Revert "Disable two GDBus tests"
This reverts commit 05ef173466.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=662100
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: David Zeuthen <davidz@redhat.com>
2011-10-19 10:37:27 +01:00
Ryan Lortie
99f0eaa4c5 Fix bug in g_static_rec_mutex_unlock_full()
pthreads doesn't implement the _lock_full() and _unlock_full() calls on
recursive mutexes so we don't have it on GRecMutex either.  Now that
we're using GRecMutex to implement GStaticRecMutex, we have to fake it
by keeping an internal counter of the number of locks and calling
g_rec_mutex_unlock() the appropriate number of times.

The code to do this looked like:

  depth = mutex->depth;
  while (mutex->depth--)
    g_rec_mutex_unlock (rm);
  return depth;

which unfortunately did one last decrement after mutex->depth was
already zero (leaving it equal to -1).

When locked the next time, the count would then increase from -1 to 0
and then the next _unlock_full() call would not do any calls to
g_rec_mutex_unlock(), leading to a deadlock.

https://bugzilla.gnome.org/show_bug.cgi?id=661914
2011-10-18 23:26:00 -04:00
Ryan Lortie
aba0f0c38b gatomic: introduce G_ATOMIC_LOCK_FREE
We clean up the detection of if we should do 'real' atomic operations or
mutex-emulated ones with the introduction of a new (public) macro:
G_ATOMIC_LOCK_FREE.  If defined, our atomic operations are guaranteed to
be done in hardware.

We need to use __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 to determine if our
compiler supports GCC-style atomic operations from the gatomic.h header
because we might be building a program against GLib using a different
set of compiler options (or a different compiler) than was used to build
GLib itself.

Unfortunately, this macro is not available on clang, so it has currently
regressed to using the mutex emulation.  A bug about that has been
opened here:

  http://llvm.org/bugs/show_bug.cgi?id=11174
2011-10-18 16:45:28 -04:00
Ryan Lortie
c9b6c3c85a gatomic: cast to the correct pointer sign
In the fallback case of the g_atomic_int_ macros we had some (gint*)
casts that should have been (guint*) casts.
2011-10-18 16:45:28 -04:00
Mario Blättermann
4641d13770 [l10n] Updated German translation 2011-10-18 22:28:23 +02:00
David Zeuthen
915e2238c4 gio: Introduce get_sort_key() methods on GDrive, GVolume and GMount
This is needed to implement efficient and predictable proxy volume
monitors, see

 https://bugzilla.gnome.org/show_bug.cgi?id=661711

for details.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-10-18 14:29:18 -04:00
Javier Jardón
4a25d21bd0 tests/gobject: Use G_VALUE_INIT 2011-10-18 17:12:33 +01:00
Javier Jardón
108480b7ba gobject: Use G_VALUE_INIT 2011-10-18 17:12:33 +01:00
Javier Jardón
8d3250016d gio: Use G_VALUE_INIT 2011-10-18 17:12:33 +01:00
Sjoerd Simons
f07201c314 GDBusConnection: Fix race in /gdbus/connection/life-cycle
GDBusConnection sets the closed flag in the worker thread, then adds an
idle callback (which refs the Connection) to signal this in the main
thread. The tests session_bus_down doesn't spin the mainloop, so the
"closed" signal will always fire if iterating the mainloop later (and
drops the ref when doing so). But _is_closed can return TRUE even before
signalling this, in which case the "closed" signal isn't fired and the
ref isn't dropped, causing the test to fail.

Instead simply always wait for the closed signal, which is a good thing
to check anyway and ensures the ref is closed.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=661896
Reviewed-by: Matthias Clasen <mclasen@redhat.com>
2011-10-18 13:18:09 +01:00
Alexander Larsson
cf3f1b026b Actually Don't define GLIB_COMPILATION in libgthread
Last commit was wrong, fixing it up
2011-10-18 14:15:07 +02:00
Alexander Larsson
be770969e9 Don't define GLIB_COMPILATION in libgthread
This was turning all the GLIB_VARs in the glib headers into
dllexports on windows, causing all sort of nastiness. libgthread is
mostly empty now anyway, so we don't need any GLIB_COMPILATION like
flag.
2011-10-18 13:34:06 +02:00
Matthias Clasen
735420e546 Fix an include guard mismatch
Spotted by Colin Walters.
2011-10-17 17:01:36 -04:00
Alexander Larsson
52389bd010 Fix up testcase broken due to g_thread_new API change 2011-10-17 23:00:29 +02:00
Chun-wei Fan
f3ac581713 Move _glib_get_locale_dir to ggettext.c
-Move _glib_get_locale_dir to ggettext.c, as Matthias suggested
-Made up for the headers that needed to be included in ggettext.c to avoid
 C4013 (implicit declaration of ...) errors/warnings
2011-10-18 01:01:02 +08:00
Piotr Drąg
9973383bd0 Updated POTFILES.in 2011-10-17 18:31:48 +02:00
Chun-wei Fan
32214583c3 Fix gio.symbols
g_simple_action_get_parameter_type is now static, so this symbol needs to
be removed from here...
2011-10-17 23:54:17 +08:00
Chun-wei Fan
b25177fc4f GLib: Add forgotten includes and build fixes
-gcharset.c, genviron.c, gunicollate.c: Some headers were missed in those
 files that triggered C4013 warnings/errors (aka. implicit declaration
 of ... in GCC).  Make up for them here.
-gwin32.h: Only define g_win32_get_package_installation_directory/
 g_win32_get_package_installation_subdirectory as macros
 (alias of g_win32_get_package_installation_directory_utf8/
 g_win32_get_package_installation_subdirectory_utf8) on Win64 (x64) as
 g_win32_get_package_installation_directory/
 g_win32_get_package_installation_subdirectory have seperate existing
 implmentations for Win32-this is a long-standing problem but was covered-
 up by G_DISABLE_DEPRECATED, which we are stopping to use as of 2.31.0.
2011-10-17 23:54:05 +08:00
Ryan Lortie
e5fd0f5df6 Revert "Bug 652827 - glib-2.29.8 no longer builds with mingw.org's toolchain"
This reverts commit 3492122112.
2011-10-17 10:55:02 -04:00
Chun-wei Fan
3a04f87968 Update VS property sheets
Some new headers were added...
2011-10-17 17:47:00 +08:00
Chun-wei Fan
e192f45a93 glib/tests/thread.c: Add config guards
Not all systems come with unistd.h and sys/time.h, so use config guards
on them so that they are only included when available.
2011-10-17 17:18:20 +08:00
Chun-wei Fan
1bfa7e7e86 Update VS property sheets
gcache.h is now a deprecated header, so up the "install" part for it.
2011-10-17 16:40:44 +08:00
Matthias Clasen
2f71118e78 More include cleanups 2011-10-17 02:14:39 -04:00
Chun-wei Fan
eb125665d8 Update VS property sheets
Stop using G_DISABLE_DEPRECATED as there are now warnings for usage of
deprecated APIs/items in GLib
2011-10-17 14:18:35 +08:00
Matthias Clasen
0ec3c744c4 include cleanup 2011-10-17 01:59:35 -04:00
Matthias Clasen
d9053e026c Make things compile again 2011-10-17 01:52:10 -04:00
Matthias Clasen
08933846e4 Move gettext variations into their own files 2011-10-17 01:50:00 -04:00
Matthias Clasen
67bf0083db Reshuffle some functions between gutils and gfileutils
Move filename-related functions to gfileutils, and move
size formatting functions to gutils.
2011-10-17 01:30:31 -04:00
Matthias Clasen
23afdb119e include cleanup 2011-10-17 01:30:09 -04:00
Matthias Clasen
f8a7471308 Trivial 2011-10-17 01:11:56 -04:00
Matthias Clasen
fbe24cab21 Reshuffle genviron.c
Split win32 functions off into their own section, instead
of having large and unwieldy ifdef sections inside each function.

Also move the compat versions of env functions over from gutils.c
2011-10-17 00:39:43 -04:00
Ryan Lortie
b0ab7aba6b push G_THREADS_MANDATORY over the cliff
This was used as an optimisation for the macro hackery that used to live
in gthread.h.  If a particular library or program knew that it could
rely on thread support being enabled, it would allow for static
evaluation of conditionals in some of those macros.

Since the macros are dead and thread support is now always-on, we can
get rid of this bit of legacy.
2011-10-16 21:59:55 -04:00
Ryan Lortie
b076020719 gobject/gio: some last missed statics/inclues 2011-10-16 21:53:03 -04:00
Ryan Lortie
a6d9cf3380 gthread/: fix up declarations
g_thread_init() is now a deprecated API, so drop G_DISABLE_DEPRECATED
from the CFLAGS for gthread/.  Add the missing declaration for
g_thread_init_with_errorcheck_mutexes() back to deprecated/gthread.h.
2011-10-16 21:50:26 -04:00
Ryan Lortie
3eec796b18 Add private prototype for g_thread_init_glib()
This function was never put in a header and was only used internally
from libgthread, but we should keep the symbol around to avoid
triggering any false-positives on ABI checkers.

For -Wmissing-prototypes compatibility with this unusual case, we should
add a private prototype in the .c file just before.
2011-10-16 21:41:15 -04:00