Classes | Defines | Functions

atomic.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  atomic_t

Defines

#define LOCK   "lock ; "
 Copyright (C) 2007 Doug Judd (Zvents, Inc.)
#define ATOMIC_INIT(i)   { (i) }
#define atomic_read(v)   ((v)->counter)
 atomic_read - read atomic variable
#define atomic_set(v, i)   (((v)->counter) = (i))
 atomic_set - set atomic variable
#define atomic_clear_mask(mask, addr)
#define atomic_set_mask(mask, addr)
#define atomic_inc_return(v)   (atomic_add_return(1,v))
#define atomic_dec_return(v)   (atomic_sub_return(1,v))

Functions

static __inline__ void atomic_add (int i, atomic_t *v)
 atomic_add - add integer to atomic variable
static __inline__ void atomic_sub (int i, atomic_t *v)
 atomic_sub - subtract the atomic variable
static __inline__ int atomic_add_return (int i, atomic_t *v)
 atomic_add_return - add and return
static __inline__ int atomic_sub_return (int i, atomic_t *v)
static __inline__ int atomic_sub_and_test (int i, atomic_t *v)
 atomic_sub_and_test - subtract value from variable and test result
static __inline__ void atomic_inc (atomic_t *v)
 atomic_inc - increment atomic variable
static __inline__ void atomic_dec (atomic_t *v)
 atomic_dec - decrement atomic variable
static __inline__ int atomic_dec_and_test (atomic_t *v)
 atomic_dec_and_test - decrement and test
static __inline__ int atomic_inc_and_test (atomic_t *v)
 atomic_inc_and_test - increment and test
static __inline__ int atomic_add_negative (int i, atomic_t *v)
 atomic_add_negative - add and test if negative

Define Documentation

#define atomic_clear_mask (   mask,
  addr 
)
Value:
__asm__ __volatile__(LOCK "andl %0,%1" \
: : "r" (~(mask)),"m" (*addr) : "memory")

Definition at line 221 of file atomic.h.

#define atomic_dec_return (   v )    (atomic_sub_return(1,v))

Definition at line 230 of file atomic.h.

#define atomic_inc_return (   v )    (atomic_add_return(1,v))

Definition at line 229 of file atomic.h.

#define ATOMIC_INIT (   i )    { (i) }

Definition at line 39 of file atomic.h.

#define atomic_read (   v )    ((v)->counter)

atomic_read - read atomic variable

Parameters:
vpointer of type atomic_t

Atomically reads the value of v.

Definition at line 47 of file atomic.h.

#define atomic_set (   v,
 
)    (((v)->counter) = (i))

atomic_set - set atomic variable

Parameters:
vpointer of type atomic_t
irequired value

Atomically sets the value of v to i.

Definition at line 56 of file atomic.h.

#define atomic_set_mask (   mask,
  addr 
)
Value:
__asm__ __volatile__(LOCK "orl %0,%1" \
: : "r" (mask),"m" (*(addr)) : "memory")

Definition at line 225 of file atomic.h.

#define LOCK   "lock ; "

Copyright (C) 2007 Doug Judd (Zvents, Inc.)

This file is part of Hypertable.

Hypertable is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version.

Hypertable 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 General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Definition at line 30 of file atomic.h.


Function Documentation

static __inline__ void atomic_add ( int  i,
atomic_t v 
) [static]

atomic_add - add integer to atomic variable

Parameters:
iinteger value to add
vpointer of type atomic_t

Atomically adds i to v.

Definition at line 65 of file atomic.h.

static __inline__ int atomic_add_negative ( int  i,
atomic_t v 
) [static]

atomic_add_negative - add and test if negative

Parameters:
vpointer of type atomic_t
iinteger value to add

Atomically adds i to v and returns true if the result is negative, or false when result is greater than or equal to zero.

Definition at line 209 of file atomic.h.

static __inline__ int atomic_add_return ( int  i,
atomic_t v 
) [static]

atomic_add_return - add and return

Parameters:
vpointer of type atomic_t
iinteger value to add

Atomically adds i to v and returns i + v

Definition at line 96 of file atomic.h.

static __inline__ void atomic_dec ( atomic_t v ) [static]

atomic_dec - decrement atomic variable

Parameters:
vpointer of type atomic_t

Atomically decrements v by 1.

Definition at line 154 of file atomic.h.

static __inline__ int atomic_dec_and_test ( atomic_t v ) [static]

atomic_dec_and_test - decrement and test

Parameters:
vpointer of type atomic_t

Atomically decrements v by 1 and returns true if the result is 0, or false for all other cases.

Definition at line 170 of file atomic.h.

static __inline__ void atomic_inc ( atomic_t v ) [static]

atomic_inc - increment atomic variable

Parameters:
vpointer of type atomic_t

Atomically increments v by 1.

Definition at line 140 of file atomic.h.

static __inline__ int atomic_inc_and_test ( atomic_t v ) [static]

atomic_inc_and_test - increment and test

Parameters:
vpointer of type atomic_t

Atomically increments v by 1 and returns true if the result is zero, or false for all other cases.

Definition at line 189 of file atomic.h.

static __inline__ void atomic_sub ( int  i,
atomic_t v 
) [static]

atomic_sub - subtract the atomic variable

Parameters:
iinteger value to subtract
vpointer of type atomic_t

Atomically subtracts i from v.

Definition at line 80 of file atomic.h.

static __inline__ int atomic_sub_and_test ( int  i,
atomic_t v 
) [static]

atomic_sub_and_test - subtract value from variable and test result

Parameters:
iinteger value to subtract
vpointer of type atomic_t

Atomically subtracts i from v and returns true if the result is zero, or false for all other cases.

Definition at line 123 of file atomic.h.

static __inline__ int atomic_sub_return ( int  i,
atomic_t v 
) [static]

Definition at line 108 of file atomic.h.