epoc32/include/stdapis/glib-2.0/glib/gatomic.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 0 061f57f2323e
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
/* GLIB - Library of useful routines for C programming
williamr@2
     2
 * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
williamr@2
     3
 *
williamr@2
     4
 * g_atomic_*: atomic operations.
williamr@2
     5
 * Copyright (C) 2003 Sebastian Wilhelmi
williamr@2
     6
 * Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
williamr@2
     7
 *
williamr@2
     8
 * This library is free software; you can redistribute it and/or
williamr@2
     9
 * modify it under the terms of the GNU Lesser General Public
williamr@2
    10
 * License as published by the Free Software Foundation; either
williamr@2
    11
 * version 2 of the License, or (at your option) any later version.
williamr@2
    12
 *
williamr@2
    13
 * This library is distributed in the hope that it will be useful,
williamr@2
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
williamr@2
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
williamr@2
    16
 * Lesser General Public License for more details.
williamr@2
    17
 *
williamr@2
    18
 * You should have received a copy of the GNU Lesser General Public
williamr@2
    19
 * License along with this library; if not, write to the
williamr@2
    20
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
williamr@2
    21
 * Boston, MA 02111-1307, USA.
williamr@2
    22
 */
williamr@2
    23
 
williamr@2
    24
/*
williamr@2
    25
 * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
williamr@2
    26
 * file for a list of people on the GLib Team.  See the ChangeLog
williamr@2
    27
 * files for a list of changes.  These files are distributed with
williamr@2
    28
 * GLib at ftp://ftp.gtk.org/pub/gtk/.
williamr@2
    29
 */
williamr@2
    30
 
williamr@2
    31
#ifndef __G_ATOMIC_H__
williamr@2
    32
#define __G_ATOMIC_H__
williamr@2
    33
 
williamr@2
    34
#include <_ansi.h> 
williamr@2
    35
#include <glib/gtypes.h>
williamr@2
    36
williamr@2
    37
G_BEGIN_DECLS
williamr@2
    38
 
williamr@2
    39
IMPORT_C gint     g_atomic_int_exchange_and_add         (volatile gint     *atomic, 
williamr@2
    40
						gint      	   val);
williamr@2
    41
IMPORT_C void     g_atomic_int_add                      (volatile gint     *atomic, 
williamr@2
    42
						gint      	   val);
williamr@2
    43
IMPORT_C gboolean g_atomic_int_compare_and_exchange     (volatile gint     *atomic, 
williamr@2
    44
						gint      	   oldval,
williamr@2
    45
						gint      	   newval);
williamr@2
    46
IMPORT_C gboolean g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic, 
williamr@2
    47
						gpointer  	   oldval, 
williamr@2
    48
						gpointer  	   newval);
williamr@2
    49
williamr@2
    50
IMPORT_C gint     g_atomic_int_get                      (volatile  gint     *atomic);
williamr@2
    51
IMPORT_C void     g_atomic_int_set                      (volatile gint  	  *atomic,
williamr@2
    52
						gint               newval);
williamr@2
    53
IMPORT_C gpointer g_atomic_pointer_get                  (volatile gpointer *atomic);
williamr@2
    54
IMPORT_C void     g_atomic_pointer_set                  (volatile gpointer *atomic,
williamr@2
    55
						gpointer           newval);
williamr@2
    56
williamr@2
    57
#ifndef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED
williamr@2
    58
# define g_atomic_int_get(atomic) 		(*(atomic))
williamr@2
    59
# define g_atomic_int_set(atomic, newval) 	((void) (*(atomic) = (newval)))
williamr@2
    60
# define g_atomic_pointer_get(atomic) 		(*(atomic))
williamr@2
    61
# define g_atomic_pointer_set(atomic, newval)	((void) (*(atomic) = (newval)))
williamr@2
    62
#endif /* G_ATOMIC_OP_MEMORY_BARRIER_NEEDED */
williamr@2
    63
williamr@2
    64
#define g_atomic_int_inc(atomic) (g_atomic_int_add ((atomic), 1))
williamr@2
    65
#define g_atomic_int_dec_and_test(atomic)				\
williamr@2
    66
  (g_atomic_int_exchange_and_add ((atomic), -1) == 1)
williamr@2
    67
williamr@2
    68
G_END_DECLS
williamr@2
    69
 
williamr@2
    70
#endif /* __G_ATOMIC_H__ */