*
* Gets the current value of @atomic.
*
- * This call acts as a full compiler and hardware memory barrier (before
- * the get).
+ * This call acts as a full compiler and hardware
+ * memory barrier (before the get).
*
* Returns: the value of the integer
*
*
* Sets the value of @atomic to @newval.
*
- * This call acts as a full compiler and hardware memory barrier (after
- * the set).
+ * This call acts as a full compiler and hardware
+ * memory barrier (after the set).
*
* Since: 2.4
- **/
+ */
void
(g_atomic_int_set) (volatile gint *atomic,
gint newval)
*
* Increments the value of @atomic by 1.
*
+ * Think of this operation as an atomic version of
+ * <literal>{ *@atomic += 1; }</literal>
+ *
* This call acts as a full compiler and hardware memory barrier.
*
* Since: 2.4
*
* Decrements the value of @atomic by 1.
*
+ * Think of this operation as an atomic version of
+ * <literal>{ *@atomic -= 1; return (*@atomic == 0); }</literal>
+ *
* This call acts as a full compiler and hardware memory barrier.
*
* Returns: %TRUE if the resultant value is zero
* @oldval: the value to compare with
* @newval: the value to conditionally replace with
*
- * Compares @atomic to @oldval and, if equal, sets it to @newval. If
- * @atomic was not equal to @oldval then no change occurs.
+ * Compares @atomic to @oldval and, if equal, sets it to @newval.
+ * If @atomic was not equal to @oldval then no change occurs.
*
* This compare and exchange is done atomically.
*
+ * Think of this operation as an atomic version of
+ * <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
+ *
* This call acts as a full compiler and hardware memory barrier.
*
* Returns: %TRUE if the exchange took place
*
* Atomically adds @val to the value of @atomic.
*
+ * Think of this operation as an atomic version of
+ * <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
+ *
* This call acts as a full compiler and hardware memory barrier.
*
* Returns: the value of @atomic before the add, signed
*
* This call acts as a full compiler and hardware memory barrier.
*
+ * Think of this operation as an atomic version of
+ * <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
+ *
* Returns: the value of @atomic before the operation, unsigned
*
* Since: 2.30
* Performs an atomic bitwise 'or' of the value of @atomic and @val,
* storing the result back in @atomic.
*
+ * Think of this operation as an atomic version of
+ * <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
+ *
* This call acts as a full compiler and hardware memory barrier.
*
* Returns: the value of @atomic before the operation, unsigned
* Performs an atomic bitwise 'xor' of the value of @atomic and @val,
* storing the result back in @atomic.
*
+ * Think of this operation as an atomic version of
+ * <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
+ *
* This call acts as a full compiler and hardware memory barrier.
*
* Returns: the value of @atomic before the operation, unsigned
*
* Gets the current value of @atomic.
*
- * This call acts as a full compiler and hardware memory barrier (before
- * the get).
+ * This call acts as a full compiler and hardware
+ * memory barrier (before the get).
*
* Returns: the value of the pointer
*
*
* Sets the value of @atomic to @newval.
*
- * This call acts as a full compiler and hardware memory barrier (after
- * the set).
+ * This call acts as a full compiler and hardware
+ * memory barrier (after the set).
*
* Since: 2.4
**/
* @oldval: the value to compare with
* @newval: the value to conditionally replace with
*
- * Compares @atomic to @oldval and, if equal, sets it to @newval. If
- * @atomic was not equal to @oldval then no change occurs.
+ * Compares @atomic to @oldval and, if equal, sets it to @newval.
+ * If @atomic was not equal to @oldval then no change occurs.
*
* This compare and exchange is done atomically.
*
+ * Think of this operation as an atomic version of
+ * <literal>{ if (*@atomic == @oldval) { *@atomic = @newval; return TRUE; } else return FALSE; }</literal>
+ *
* This call acts as a full compiler and hardware memory barrier.
*
* Returns: %TRUE if the exchange took place
*
* Atomically adds @val to the value of @atomic.
*
+ * Think of this operation as an atomic version of
+ * <literal>{ tmp = *atomic; *@atomic += @val; return tmp; }</literal>
+ *
* This call acts as a full compiler and hardware memory barrier.
*
* Returns: the value of @atomic before the add, signed
* Performs an atomic bitwise 'and' of the value of @atomic and @val,
* storing the result back in @atomic.
*
+ * Think of this operation as an atomic version of
+ * <literal>{ tmp = *atomic; *@atomic &= @val; return tmp; }</literal>
+ *
* This call acts as a full compiler and hardware memory barrier.
*
* Returns: the value of @atomic before the operation, unsigned
* Performs an atomic bitwise 'or' of the value of @atomic and @val,
* storing the result back in @atomic.
*
+ * Think of this operation as an atomic version of
+ * <literal>{ tmp = *atomic; *@atomic |= @val; return tmp; }</literal>
+ *
* This call acts as a full compiler and hardware memory barrier.
*
* Returns: the value of @atomic before the operation, unsigned
* Performs an atomic bitwise 'xor' of the value of @atomic and @val,
* storing the result back in @atomic.
*
+ * Think of this operation as an atomic version of
+ * <literal>{ tmp = *atomic; *@atomic ^= @val; return tmp; }</literal>
+ *
* This call acts as a full compiler and hardware memory barrier.
*
* Returns: the value of @atomic before the operation, unsigned
/* GLIB - Library of useful routines for C programming
* Copyright (C) 2011 Red Hat, Inc.
*
- * glib-unix.c: UNIX specific API wrappers and convenience functions
+ * glib-unix.c: UNIX specific API wrappers and convenience functions
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
{
int saved_errno = errno;
g_set_error_literal (error,
- G_UNIX_ERROR,
- 0,
- g_strerror (errno));
+ G_UNIX_ERROR,
+ 0,
+ g_strerror (errno));
errno = saved_errno;
return FALSE;
}
static gboolean
g_unix_set_error_from_errno_saved (GError **error,
- int saved_errno)
+ int saved_errno)
{
g_set_error_literal (error,
- G_UNIX_ERROR,
- 0,
- g_strerror (saved_errno));
+ G_UNIX_ERROR,
+ 0,
+ g_strerror (saved_errno));
errno = saved_errno;
return FALSE;
}
* Similar to the UNIX pipe() call, but on modern systems like Linux
* uses the pipe2() system call, which atomically creates a pipe with
* the configured flags. The only supported flag currently is
- * %FD_CLOEXEC. If for example you want to configure %O_NONBLOCK, that
- * must still be done separately with fcntl().
+ * %FD_CLOEXEC. If for example you want to configure %O_NONBLOCK,
+ * that must still be done separately with fcntl().
*
- * <note>This function does *not* take %O_CLOEXEC, it takes %FD_CLOEXEC as if
- * for fcntl(); these are different on Linux/glibc.</note>
+ * <note>This function does *not* take %O_CLOEXEC, it takes
+ * %FD_CLOEXEC as if for fcntl(); these are different on
+ * Linux/glibc.</note>
*
* Returns: %TRUE on success, %FALSE if not (and errno will be set).
*
*/
gboolean
g_unix_open_pipe (int *fds,
- int flags,
- GError **error)
+ int flags,
+ GError **error)
{
int ecode;
* on some older ones may use %O_NDELAY.
*
* Returns: %TRUE if successful
+ *
+ * Since: 2.30
*/
gboolean
-g_unix_set_fd_nonblocking (gint fd,
- gboolean nonblock,
- GError **error)
+g_unix_set_fd_nonblocking (gint fd,
+ gboolean nonblock,
+ GError **error)
{
#ifdef F_GETFL
glong fcntl_flags;
* be monitored. Note that unlike the UNIX default, all sources which
* have created a watch will be dispatched, regardless of which
* underlying thread invoked g_unix_signal_create_watch().
- *
+ *
* For example, an effective use of this function is to handle SIGTERM
* cleanly; flushing any outstanding files, and then calling
* g_main_loop_quit (). It is not safe to do any of this a regular
* executed.
*
* Returns: A newly created #GSource
+ *
+ * Since: 2.30
*/
GSource *
g_unix_signal_source_new (int signum)
* using g_source_remove().
*
* Returns: An ID (greater than 0) for the event source
+ *
+ * Since: 2.30
*/
guint
g_unix_signal_add_watch_full (int signum,
- int priority,
- GSourceFunc handler,
- gpointer user_data,
- GDestroyNotify notify)
+ int priority,
+ GSourceFunc handler,
+ gpointer user_data,
+ GDestroyNotify notify)
{
guint id;
GSource *source;