]> rtime.felk.cvut.cz Git - frescor/frsh-forb.git/blobdiff - src/forb/src/refcnt.c
forb: attomic reference counting does not work in RTEMS
[frescor/frsh-forb.git] / src / forb / src / refcnt.c
index 9c76737996f2608dd3ee2c437df56b9316d768b5..5712cedc4243f45f387779c5209115c4f005798b 100644 (file)
@@ -79,7 +79,11 @@ void forb_ref_init(struct forb_ref *ref)
  */
 void forb_ref_get(struct forb_ref *ref)
 {
+#ifdef RTEMS
+       ++(ref->refcount);
+#else
        __sync_add_and_fetch(&ref->refcount, 1);
+#endif
 }
 
 /** 
@@ -95,7 +99,11 @@ void forb_ref_get(struct forb_ref *ref)
  */
 int forb_ref_put(struct forb_ref *ref, void (*release) (struct forb_ref *ref))
 {
+#ifdef RTEMS
+       if (--(ref->refcount) == 0) {
+#else
        if (__sync_add_and_fetch(&ref->refcount, -1) == 0) {
+#endif   
                release(ref);
                return 1;
        }