/[hurd]/hurd-l4/libhurd-cap-server/cap-server.h
ViewVC logotype

Diff of /hurd-l4/libhurd-cap-server/cap-server.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by marcus, Wed Oct 27 20:13:53 2004 UTC revision 1.10 by marcus, Fri Oct 29 03:18:50 2004 UTC
# Line 26  Line 26 
26  #include <errno.h>  #include <errno.h>
27  #include <pthread.h>  #include <pthread.h>
28    
29    /* FIXME: This is not a public header file!  So we may have to ship
30       a <hurd/atomic.h>.  */
31    #include <atomic.h>
32    
33  #include <hurd/slab.h>  #include <hurd/slab.h>
34  #include <hurd/types.h>  #include <hurd/types.h>
35    
# Line 213  struct hurd_cap_obj Line 217  struct hurd_cap_obj
217    pthread_mutex_t lock;    pthread_mutex_t lock;
218    
219    /* The reference counter for this object.  */    /* The reference counter for this object.  */
220    unsigned int refs;    uatomic32_t refs;
221    
222    /* The state of this object.  If this is _HURD_CAP_STATE_GREEN, you    /* The state of this object.  If this is _HURD_CAP_STATE_GREEN, you
223       can use the capability object.  Otherwise, you should refrain       can use the capability object.  Otherwise, you should refrain
# Line 351  hurd_cap_obj_unlock (hurd_cap_obj_t obj) Line 355  hurd_cap_obj_unlock (hurd_cap_obj_t obj)
355  static inline void  static inline void
356  hurd_cap_obj_ref (hurd_cap_obj_t obj)  hurd_cap_obj_ref (hurd_cap_obj_t obj)
357  {  {
358    assert (obj->refs < UINT_MAX);    atomic_increment (&obj->refs);
   
   obj->refs++;  
359  }  }
360    
361    
362  /* Remove one reference for the capability object OBJ, which must be  /* Remove one reference for the capability object OBJ.  Note that the
363     locked.  Note that the caller must have at least two references for     caller must have at least two references for this capability object
364     this capability object when using this function.  To release the     when using this function.  To release the last reference,
365     last reference, hurd_cap_obj_drop must be used instead.  */     hurd_cap_obj_drop must be used instead.  */
366  static inline void  static inline void
367  hurd_cap_obj_rele (hurd_cap_obj_t obj)  hurd_cap_obj_rele (hurd_cap_obj_t obj)
368  {  {
369    assert (obj->refs > 1);    atomic_decrement (&obj->refs);
   
   obj->refs--;  
370  }  }
371    
372    

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26