00001 /* 00002 * Copyright (C) 2006 iptelorg GmbH 00003 * 00004 * Permission to use, copy, modify, and distribute this software for any 00005 * purpose with or without fee is hereby granted, provided that the above 00006 * copyright notice and this permission notice appear in all copies. 00007 * 00008 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 00009 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 00010 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 00011 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 00012 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 00013 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 00014 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00015 */ 00016 00035 /* 00036 * History: 00037 * -------- 00038 * 2006-03-08 created by andrei 00039 * 2007-05-13 split from atomic_ops.h (andrei) 00040 */ 00041 00042 00043 #ifndef __atomic_common 00044 #define __atomic_common 00045 00052 typedef struct{ volatile int val; } atomic_t; 00053 00054 00063 00065 #define atomic_set_int(pvar, i) (*(int*)(pvar)=i) 00066 #define atomic_set_long(pvar, i) (*(long*)(pvar)=i) 00067 #define atomic_get_int(pvar) (*(int*)(pvar)) 00068 #define atomic_get_long(pvar) (*(long*)(pvar)) 00069 00070 #define atomic_set(at_var, value) (atomic_set_int(&((at_var)->val), (value))) 00071 00072 inline static int atomic_get(atomic_t *v) 00073 { 00074 return atomic_get_int(&(v->val)); 00075 } 00076 00079 #endif
1.7.1