From 8f36a7d620b3e1d0130b352dc02d58c066c7ba92 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Fri, 21 Dec 2018 11:28:49 +0100 Subject: [PATCH] [WIP] libgomp/target.c magic constants self-documentation --- libgomp/libgomp.h | 10 +++++----- libgomp/target.c | 11 +++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h index 19e5fbb24e26..eef380d7b0fc 100644 --- a/libgomp/libgomp.h +++ b/libgomp/libgomp.h @@ -873,6 +873,11 @@ struct target_var_desc { uintptr_t length; }; +/* Special values for struct target_var_desc's offset. */ +#define OFFSET_INLINED (~(uintptr_t) 0) +#define OFFSET_POINTER (~(uintptr_t) 1) +#define OFFSET_STRUCT (~(uintptr_t) 2) + struct target_mem_desc { /* Reference count. */ uintptr_t refcount; @@ -903,11 +908,6 @@ struct target_mem_desc { artificial pointer to "omp declare target link" object. */ #define REFCOUNT_LINK (~(uintptr_t) 1) -/* Special offset values. */ -#define OFFSET_INLINED (~(uintptr_t) 0) -#define OFFSET_POINTER (~(uintptr_t) 1) -#define OFFSET_STRUCT (~(uintptr_t) 2) - struct splay_tree_key_s { /* Address of the host object. */ uintptr_t host_start; diff --git a/libgomp/target.c b/libgomp/target.c index d7acdd9b784b..201da567d73a 100644 --- a/libgomp/target.c +++ b/libgomp/target.c @@ -45,8 +45,6 @@ #include "plugin-suffix.h" #endif -#define FIELD_TGT_EMPTY (~(size_t) 0) - static void gomp_target_init (void); /* The whole initialization code for offloading plugins is only run one. */ @@ -748,7 +746,8 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, if (not_found_cnt) tgt->array = gomp_malloc (not_found_cnt * sizeof (*tgt->array)); splay_tree_node array = tgt->array; - size_t j, field_tgt_offset = 0, field_tgt_clear = ~(size_t) 0; + const size_t field_tgt_empty = ~(size_t) 0; + size_t j, field_tgt_offset = 0, field_tgt_clear = field_tgt_empty; uintptr_t field_tgt_base = 0; for (i = 0; i < mapnum; i++) @@ -841,7 +840,7 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, k->host_end = k->host_start + sizeof (void *); splay_tree_key n = splay_tree_lookup (mem_map, k); /* Need to account for the case where a struct field hasn't been - mapped onto the accelerator yet. */ + mapped onto the device yet. */ if (n && n->refcount != REFCOUNT_LINK) gomp_map_vars_existing (devicep, n, k, &tgt->list[i], kind & typemask, cbufp); @@ -858,12 +857,12 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, size_t align = (size_t) 1 << (kind >> rshift); tgt->list[i].key = k; k->tgt = tgt; - if (field_tgt_clear != FIELD_TGT_EMPTY) + if (field_tgt_clear != field_tgt_empty) { k->tgt_offset = k->host_start - field_tgt_base + field_tgt_offset; if (i == field_tgt_clear) - field_tgt_clear = FIELD_TGT_EMPTY; + field_tgt_clear = field_tgt_empty; } else { -- 2.17.1