2015-07-16 Nathan Sidwell <nathan@codesourcery.com>
gcc/
* config/nvptx/mkoffload.c (process): Constify target data.
* config/i386/intelmic-mkoffload.c (generate_target_descr_file):
Constify target data.
(generate_target_offloadend_file): Likewise.
libgomp/
* target.c (struct offload_image_descr): Constify target_data.
(gomp_offload_image_to_device): Likewise.
(GOMP_offload_register): Likewise.
(GOMP_offload_unrefister): Likewise.
===================================================================
@@ -58,7 +58,7 @@ static gomp_mutex_t register_lock;
struct offload_image_descr {
enum offload_target_type type;
void *host_table;
- void *target_data;
+ const void *target_data;
};
/* Array of descriptors of offload images. */
@@ -642,7 +642,7 @@ gomp_update (struct gomp_device_descr *d
static void
gomp_offload_image_to_device (struct gomp_device_descr *devicep,
- void *host_table, void *target_data,
+ void *host_table, const void *target_data,
bool is_register_lock)
{
void **host_func_table = ((void ***) host_table)[0];
@@ -731,7 +731,7 @@ gomp_offload_image_to_device (struct gom
void
GOMP_offload_register (void *host_table, enum offload_target_type target_type,
- void *target_data)
+ const void *target_data)
{
int i;
gomp_mutex_lock (®ister_lock);
@@ -765,7 +765,7 @@ GOMP_offload_register (void *host_table,
void
GOMP_offload_unregister (void *host_table, enum offload_target_type target_type,
- void *target_data)
+ const void *target_data)
{
void **host_func_table = ((void ***) host_table)[0];
void **host_funcs_end = ((void ***) host_table)[1];
===================================================================
@@ -334,7 +334,7 @@ struct ptx_event
struct ptx_image_data
{
- void *target_data;
+ const void *target_data;
CUmodule module;
struct ptx_image_data *next;
};
@@ -1633,7 +1633,7 @@ typedef struct nvptx_tdata
} nvptx_tdata_t;
int
-GOMP_OFFLOAD_load_image (int ord, void *target_data,
+GOMP_OFFLOAD_load_image (int ord, const void *target_data,
struct addr_pair **target_table)
{
CUmodule module;
@@ -1641,7 +1641,7 @@ GOMP_OFFLOAD_load_image (int ord, void *
unsigned int fn_entries, var_entries, i, j;
CUresult r;
struct targ_fn_descriptor *targ_fns;
- nvptx_tdata_t const *img_header = (nvptx_tdata_t const *) target_data;
+ const nvptx_tdata_t *img_header = (const nvptx_tdata_t *) target_data;
struct ptx_image_data *new_image;
GOMP_OFFLOAD_init_device (ord);
@@ -1704,9 +1704,10 @@ GOMP_OFFLOAD_load_image (int ord, void *
}
void
-GOMP_OFFLOAD_unload_image (int tid __attribute__((unused)), void *target_data)
+GOMP_OFFLOAD_unload_image (int tid __attribute__((unused)),
+ const void *target_data)
{
- void **img_header = (void **) target_data;
+ const void *const *img_header = (const void *const *) target_data;
struct targ_fn_descriptor *targ_fns
= (struct targ_fn_descriptor *) img_header[0];
struct ptx_image_data *image, *prev = NULL, *newhd = NULL;
===================================================================
@@ -111,7 +111,7 @@ GOMP_OFFLOAD_fini_device (int n __attrib
STATIC int
GOMP_OFFLOAD_load_image (int n __attribute__ ((unused)),
- void *i __attribute__ ((unused)),
+ const void *t __attribute__ ((unused)),
struct addr_pair **r __attribute__ ((unused)))
{
return 0;
@@ -119,7 +119,7 @@ GOMP_OFFLOAD_load_image (int n __attribu
STATIC void
GOMP_OFFLOAD_unload_image (int n __attribute__ ((unused)),
- void *i __attribute__ ((unused)))
+ const void *t __attribute__ ((unused)))
{
}
===================================================================
@@ -748,8 +748,8 @@ struct gomp_device_descr
int (*get_num_devices_func) (void);
void (*init_device_func) (int);
void (*fini_device_func) (int);
- int (*load_image_func) (int, void *, struct addr_pair **);
- void (*unload_image_func) (int, void *);
+ int (*load_image_func) (int, const void *, struct addr_pair **);
+ void (*unload_image_func) (int, const void *);
void *(*alloc_func) (int, size_t);
void (*free_func) (int, void *);
void *(*dev2host_func) (int, void *, const void *, size_t);
===================================================================
@@ -255,7 +255,7 @@ get_target_table (int device, int &num_f
corresponding target addresses. */
static void
-offload_image (void *target_image)
+offload_image (const void *target_image)
{
struct TargetImage {
int64_t size;
@@ -328,7 +328,8 @@ offload_image (void *target_image)
}
extern "C" int
-GOMP_OFFLOAD_load_image (int device, void *target_image, addr_pair **result)
+GOMP_OFFLOAD_load_image (int device, const void *target_image,
+ addr_pair **result)
{
TRACE ("(device = %d, target_image = %p)", device, target_image);
@@ -352,7 +353,7 @@ GOMP_OFFLOAD_load_image (int device, voi
}
extern "C" void
-GOMP_OFFLOAD_unload_image (int device, void *target_image)
+GOMP_OFFLOAD_unload_image (int device, const void *target_image)
{
TRACE ("(device = %d, target_image = %p)", device, target_image);
===================================================================
@@ -863,7 +863,7 @@ process (FILE *in, FILE *out)
fprintf (out, "};\n\n");
fprintf (out,
- "static struct nvptx_tdata {\n"
+ "static const struct nvptx_tdata {\n"
" const char *ptx_src;\n"
" const char *const *var_names;\n"
" __SIZE_TYPE__ var_num;\n"
@@ -880,7 +880,8 @@ process (FILE *in, FILE *out)
fprintf (out, "#ifdef __cplusplus\n"
"extern \"C\" {\n"
"#endif\n");
- fprintf (out, "extern void GOMP_offload_register (void *, int, void *);\n");
+ fprintf (out, "extern void GOMP_offload_register"
+ " (void *, int, const void *);\n");
fprintf (out, "#ifdef __cplusplus\n"
"}\n"
"#endif\n");
===================================================================
@@ -241,18 +241,18 @@ generate_target_descr_file (const char *
fatal_error (input_location, "cannot open '%s'", src_filename);
fprintf (src_file,
- "extern void *__offload_funcs_end[];\n"
- "extern void *__offload_vars_end[];\n\n"
+ "extern const void *const __offload_funcs_end[];\n"
+ "extern const void *const __offload_vars_end[];\n\n"
- "void *__offload_func_table[0]\n"
+ "const void *const __offload_func_table[0]\n"
"__attribute__ ((__used__, visibility (\"hidden\"),\n"
"section (\".gnu.offload_funcs\"))) = { };\n\n"
- "void *__offload_var_table[0]\n"
+ "const void *const __offload_var_table[0]\n"
"__attribute__ ((__used__, visibility (\"hidden\"),\n"
"section (\".gnu.offload_vars\"))) = { };\n\n"
- "void *__OFFLOAD_TARGET_TABLE__[]\n"
+ "const void *const __OFFLOAD_TARGET_TABLE__[]\n"
"__attribute__ ((__used__, visibility (\"hidden\"))) = {\n"
" &__offload_func_table, &__offload_funcs_end,\n"
" &__offload_var_table, &__offload_vars_end\n"
@@ -301,11 +301,11 @@ generate_target_offloadend_file (const c
fatal_error (input_location, "cannot open '%s'", src_filename);
fprintf (src_file,
- "void *__offload_funcs_end[0]\n"
+ "const void *const __offload_funcs_end[0]\n"
"__attribute__ ((__used__, visibility (\"hidden\"),\n"
"section (\".gnu.offload_funcs\"))) = { };\n\n"
- "void *__offload_vars_end[0]\n"
+ "const void *const __offload_vars_end[0]\n"
"__attribute__ ((__used__, visibility (\"hidden\"),\n"
"section (\".gnu.offload_vars\"))) = { };\n");
fclose (src_file);
@@ -339,10 +339,10 @@ generate_host_descr_file (const char *ho
fprintf (src_file,
"extern void *__OFFLOAD_TABLE__;\n"
- "extern void *__offload_image_intelmic_start;\n"
- "extern void *__offload_image_intelmic_end;\n\n"
+ "extern const void *const __offload_image_intelmic_start;\n"
+ "extern const void *const __offload_image_intelmic_end;\n\n"
- "static const void *__offload_target_data[] = {\n"
+ "static const void *const __offload_target_data[] = {\n"
" &__offload_image_intelmic_start, &__offload_image_intelmic_end\n"
"};\n\n");
@@ -350,11 +350,11 @@ generate_host_descr_file (const char *ho
"#ifdef __cplusplus\n"
"extern \"C\"\n"
"#endif\n"
- "void GOMP_offload_register (void *, int, void *);\n"
+ "void GOMP_offload_register (void *, int, const void *);\n"
"#ifdef __cplusplus\n"
"extern \"C\"\n"
"#endif\n"
- "void GOMP_offload_unregister (void *, int, void *);\n\n"
+ "void GOMP_offload_unregister (void *, int, const void *);\n\n"
"__attribute__((constructor))\n"
"static void\n"