Message ID | 561E0598.6030003@embedded-brains.de |
---|---|
State | New |
Headers | show |
On Wed, Oct 14, 2015 at 09:34:48AM +0200, Sebastian Huber wrote: > /home/EB/sebastian_h/archive/gcc-git/libgomp/fortran.c:28:0: > /home/EB/sebastian_h/archive/gcc-git/libgomp/fortran.c:73:18: note: expected > 'int *' but argument is of type 'int32_t * {aka long int *}' Ugh, wasn't aware that some targets use long int for int32_t :(. > The following patch fixes the problem, but I am not sure if this is really > the best way to address this issue: > > diff --git a/libgomp/fortran.c b/libgomp/fortran.c > index ceff9ac..44aaf92 100644 > --- a/libgomp/fortran.c > +++ b/libgomp/fortran.c > @@ -481,7 +481,9 @@ omp_get_place_num_procs_8_ (const int64_t *place_num) > void > omp_get_place_proc_ids_ (const int32_t *place_num, int32_t *ids) > { > - omp_get_place_proc_ids (*place_num, ids); > + int int_ids; > + omp_get_place_proc_ids (*place_num, &int_ids); > + *ids = int_ids; > } > > void > @@ -505,7 +507,9 @@ omp_get_partition_num_places_ (void) > void > omp_get_partition_place_nums_ (int32_t *place_nums) > { > - omp_get_partition_place_nums (place_nums); > + int int_place_nums; > + omp_get_partition_place_nums (&int_place_nums); > + *place_nums = int_place_nums; > } No, both the above changes are wrong. There is not a single int32_t written, but could be many more, it is an array of 32-bit integers. I'd say you just want to cast explicitly, omp_get_place_proc_ids (*place_num, (int *) ids); and omp_get_parition_place_nums ((int *) place_nums); The reason for int32_t is that on the Fortran side it is integer(kind=4) and everywhere else for that int32_t is used. If this works, the patch is preapproved. As for aliasing, it will always be int stores vs. integer(kind=4) reads, int32_t is just a type used in the wrappers. Jakub
On 14/10/15 10:04, Jakub Jelinek wrote: > On Wed, Oct 14, 2015 at 09:34:48AM +0200, Sebastian Huber wrote: >> >/home/EB/sebastian_h/archive/gcc-git/libgomp/fortran.c:28:0: >> >/home/EB/sebastian_h/archive/gcc-git/libgomp/fortran.c:73:18: note: expected >> >'int *' but argument is of type 'int32_t * {aka long int *}' > Ugh, wasn't aware that some targets use long int for int32_t:(. > This is actually a feature of the newlib-stdint.h: [...] /* newlib uses 32-bit long in certain cases for all non-SPU targets. */ #ifndef STDINT_LONG32 #define STDINT_LONG32 (LONG_TYPE_SIZE == 32) #endif #define SIG_ATOMIC_TYPE "int" /* The newlib logic actually checks for sizes greater than 32 rather than equal to 64 for various 64-bit types. */ #define INT8_TYPE (CHAR_TYPE_SIZE == 8 ? "signed char" : 0) #define INT16_TYPE (SHORT_TYPE_SIZE == 16 ? "short int" : INT_TYPE_SIZE == 16 ? "int" : CHAR_TYPE_SIZE == 16 ? "signed char" : 0) #define INT32_TYPE (STDINT_LONG32 ? "long int" : INT_TYPE_SIZE == 32 ? "int" : SHORT_TYPE_SIZE == 32 ? "short int" : CHAR_TYPE_SIZE == 32 ? "signed char" : 0) [...] This regularly causes problems like this. In addition it leads to a complicated PRI* macro definition in <inttypes.h>.
On 14/10/15 10:04, Jakub Jelinek wrote: > No, both the above changes are wrong. There is not a single int32_t > written, but could be many more, it is an array of 32-bit integers. > I'd say you just want to cast explicitly, > omp_get_place_proc_ids (*place_num, (int *) ids); > and > omp_get_parition_place_nums ((int *) place_nums); > The reason for int32_t is that on the Fortran side it is integer(kind=4) > and everywhere else for that int32_t is used. > If this works, the patch is preapproved. I checked this in: https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=228805
diff --git a/libgomp/fortran.c b/libgomp/fortran.c index ceff9ac..44aaf92 100644 --- a/libgomp/fortran.c +++ b/libgomp/fortran.c @@ -481,7 +481,9 @@ omp_get_place_num_procs_8_ (const int64_t *place_num) void omp_get_place_proc_ids_ (const int32_t *place_num, int32_t *ids) { - omp_get_place_proc_ids (*place_num, ids); + int int_ids; + omp_get_place_proc_ids (*place_num, &int_ids); + *ids = int_ids; } void @@ -505,7 +507,9 @@ omp_get_partition_num_places_ (void) void omp_get_partition_place_nums_ (int32_t *place_nums) { - omp_get_partition_place_nums (place_nums); + int int_place_nums; + omp_get_partition_place_nums (&int_place_nums); + *place_nums = int_place_nums; } void