On Mon, Jul 13, 2015 at 05:26:43PM +0200, Jakub Jelinek wrote:
> > > Perhaps
> > > #define REFCOUNT_INFINITY (~(uintptr_t) 0)
> > > ?
> > 
> > Probably, I don't know.
> 
> Ok, I'll change this later.

Ok, here is what I've committed:

2015-07-14  Jakub Jelinek  <ja...@redhat.com>

        * libgomp.h (REFCOUNT_INFINITY): Define.
        * target.c (gomp_map_vars_existing, gomp_map_vars, gomp_unmap_vars,
        gomp_offload_image_to_device, omp_target_associate_ptr,
        omp_target_disassociate_ptr): Use REFCOUNT_INFINITY instead of
        INT_MAX.

--- libgomp/libgomp.h.jj        2015-07-09 09:42:47.000000000 +0200
+++ libgomp/libgomp.h   2015-07-14 10:18:42.992294453 +0200
@@ -679,6 +679,9 @@ struct target_mem_desc {
   struct target_var_desc list[];
 };
 
+/* Special value for refcount - infinity.  */
+#define REFCOUNT_INFINITY (~(uintptr_t) 0)
+
 struct splay_tree_key_s {
   /* Address of the host object.  */
   uintptr_t host_start;
--- libgomp/target.c.jj 2015-07-13 14:48:11.000000000 +0200
+++ libgomp/target.c    2015-07-14 10:19:11.408614050 +0200
@@ -172,7 +172,7 @@ gomp_map_vars_existing (struct gomp_devi
                            (void *) (oldn->tgt->tgt_start + oldn->tgt_offset),
                            (void *) newn->host_start,
                            newn->host_end - newn->host_start);
-  if (oldn->refcount != INT_MAX)
+  if (oldn->refcount != REFCOUNT_INFINITY)
     oldn->refcount++;
 }
 
@@ -438,7 +438,7 @@ gomp_map_vars (struct gomp_device_descr
                          tgt->list[j].key = k;
                          tgt->list[j].copy_from = false;
                          tgt->list[j].always_copy_from = false;
-                         if (k->refcount != INT_MAX)
+                         if (k->refcount != REFCOUNT_INFINITY)
                            k->refcount++;
                          gomp_map_pointer (tgt,
                                            (uintptr_t) *(void **) hostaddrs[j],
@@ -580,7 +580,7 @@ gomp_unmap_vars (struct target_mem_desc
       bool do_unmap = false;
       if (k->refcount > 1)
        {
-         if (k->refcount != INT_MAX)
+         if (k->refcount != REFCOUNT_INFINITY)
            k->refcount--;
        }
       else if (k->async_refcount > 0)
@@ -727,7 +727,7 @@ gomp_offload_image_to_device (struct gom
       k->host_end = k->host_start + 1;
       k->tgt = tgt;
       k->tgt_offset = target_table[i].start;
-      k->refcount = INT_MAX;
+      k->refcount = REFCOUNT_INFINITY;
       k->async_refcount = 0;
       array->left = NULL;
       array->right = NULL;
@@ -752,7 +752,7 @@ gomp_offload_image_to_device (struct gom
       k->host_end = k->host_start + (uintptr_t) host_var_table[i * 2 + 1];
       k->tgt = tgt;
       k->tgt_offset = target_var->start;
-      k->refcount = INT_MAX;
+      k->refcount = REFCOUNT_INFINITY;
       k->async_refcount = 0;
       array->left = NULL;
       array->right = NULL;
@@ -1507,7 +1507,7 @@ omp_target_associate_ptr (void *host_ptr
       k->host_end = cur_node.host_end;
       k->tgt = tgt;
       k->tgt_offset = (uintptr_t) device_ptr + device_offset;
-      k->refcount = INT_MAX;
+      k->refcount = REFCOUNT_INFINITY;
       k->async_refcount = 0;
       array->left = NULL;
       array->right = NULL;
@@ -1550,7 +1550,7 @@ omp_target_disassociate_ptr (void *ptr,
     }
   if (n
       && n->host_start == cur_node.host_start
-      && n->refcount == INT_MAX
+      && n->refcount == REFCOUNT_INFINITY
       && n->tgt->tgt_start == 0
       && n->tgt->to_free == NULL
       && n->tgt->refcount == 1

        Jakub

Reply via email to