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