]> rtime.felk.cvut.cz Git - frescor/frsh-forb.git/commitdiff
forb: attomic reference counting does not work in RTEMS
authorPetr Benes <benesp16@fel.cvut.cz>
Sat, 3 Sep 2011 14:24:52 +0000 (16:24 +0200)
committerPetr Benes <benesp16@fel.cvut.cz>
Sat, 3 Sep 2011 14:24:52 +0000 (16:24 +0200)
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;
        }