Fix gcc c90 compliance warnings
[zfs.git] / module / zfs / include / sys / refcount.h
index d3fe7b1..1752c64 100644 (file)
  * CDDL HEADER END
  */
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
 #ifndef        _SYS_REFCOUNT_H
 #define        _SYS_REFCOUNT_H
 
-#pragma ident  "%Z%%M% %I%     %E% SMI"
-
 #include <sys/inttypes.h>
 #include <sys/list.h>
 #include <sys/zfs_context.h>
@@ -43,7 +40,7 @@ extern "C" {
  */
 #define        FTAG ((char *)__func__)
 
-#if defined(DEBUG) || !defined(_KERNEL)
+#ifdef ZFS_DEBUG
 typedef struct reference {
        list_node_t ref_link;
        void *ref_holder;
@@ -70,11 +67,12 @@ int64_t refcount_add(refcount_t *rc, void *holder_tag);
 int64_t refcount_remove(refcount_t *rc, void *holder_tag);
 int64_t refcount_add_many(refcount_t *rc, uint64_t number, void *holder_tag);
 int64_t refcount_remove_many(refcount_t *rc, uint64_t number, void *holder_tag);
+void refcount_transfer(refcount_t *dst, refcount_t *src);
 
 void refcount_init(void);
 void refcount_fini(void);
 
-#else /* DEBUG */
+#else  /* ZFS_DEBUG */
 
 typedef struct refcount {
        uint64_t rc_count;
@@ -91,11 +89,16 @@ typedef struct refcount {
        atomic_add_64_nv(&(rc)->rc_count, number)
 #define        refcount_remove_many(rc, number, holder) \
        atomic_add_64_nv(&(rc)->rc_count, -number)
+#define        refcount_transfer(dst, src) { \
+       uint64_t __tmp = (src)->rc_count; \
+       atomic_add_64(&(src)->rc_count, -__tmp); \
+       atomic_add_64(&(dst)->rc_count, __tmp); \
+}
 
 #define        refcount_init()
 #define        refcount_fini()
 
-#endif /* DEBUG */
+#endif /* ZFS_DEBUG */
 
 #ifdef __cplusplus
 }