diff options
author | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-04-13 20:15:58 +0000 |
---|---|---|
committer | tkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-04-13 20:15:58 +0000 |
commit | ed3634f6081c293b5b93fdc8a90f5e45b70445d8 (patch) | |
tree | e022b93b7ac1c858cd02bc0f837fdaae49b136ff /libgfortran/runtime/in_pack_generic.c | |
parent | 5207e7191fb89a5bc8f1a710d6a0be83bfb890ca (diff) | |
download | gcc-ed3634f6081c293b5b93fdc8a90f5e45b70445d8.tar.gz |
2008-04-13 Thomas Koenig <tkoenig@gcc.gnu.org>
Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR libfortran/32972
PR libfortran/32512
configure.ac: Add test for uintptr_t.
configure: Regenerated.
config.h.in: Regenerated.
* libgfortran.h: GFC_DTYPE_DERIVED_1: New macro.
GFC_DTYPE_DERIVED_2: New macro.
GFC_DTYPE_DERIVED_4: New macro.
GFC_DTYPE_DERIVED_8: New macro.
GFC_DTYPE_DERIVED_16: New macro.
GFC_UNALIGNED_2: New macro.
GFC_UNALIGNED_4: New macro.
GFC_UNALIGNED_8: New macro.
GFC_UNALIGNED_16: New macro.
intptr_t: Define if we don't have it.
uintptr_t: Likewise.
* runtime/backtrace.c (show_backtrace): Use intptr_t.
* intrinsics/signal.c (signal_sub): Likewise.
(signal_sub_int): Likewise.
(alarm_sub_int_i4): Likewise.
* intrinsics/spread_generic.c (spread): Use the integer
routines for handling derived types of sizes 1, 2, 4, 8 and 16
if the alignment of all pointers is correct.
(spread_scalar): Likewise.
* intrinsics/pack_generic.c (pack): Likewise.
Use GFD_DTYPE_TYPE_SIZE to avoid nested switch statements.
* intrinsics/unpack_generic.c (unpack1): Likewise.
(unpack0): Likewise.
* runtime/in_pack_generic.c (internal_pack): Likewise.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
2008-04-13 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/32972
PR libfortran/32512
* gfortran.dg/internal_pack_1.f90: Add test for derived type.
* gfortran.dg/intrinsic_spread_1.f90: Likewise.
* gfortran.dg/intrinsic_pack_1.f90: Likewise.
* gfortran.dg/intrinsic_unpack_1.f90: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@134245 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/runtime/in_pack_generic.c')
-rw-r--r-- | libgfortran/runtime/in_pack_generic.c | 113 |
1 files changed, 64 insertions, 49 deletions
diff --git a/libgfortran/runtime/in_pack_generic.c b/libgfortran/runtime/in_pack_generic.c index 067cd280e08..79cbbd7df29 100644 --- a/libgfortran/runtime/in_pack_generic.c +++ b/libgfortran/runtime/in_pack_generic.c @@ -51,7 +51,7 @@ internal_pack (gfc_array_char * source) int n; int packed; index_type size; - int type; + index_type type_size; if (source->dim[0].stride == 0) { @@ -59,73 +59,88 @@ internal_pack (gfc_array_char * source) return source->data; } - type = GFC_DESCRIPTOR_TYPE (source); + type_size = GFC_DTYPE_TYPE_SIZE(source); size = GFC_DESCRIPTOR_SIZE (source); - switch (type) + switch (type_size) { - case GFC_DTYPE_INTEGER: - case GFC_DTYPE_LOGICAL: - switch (size) - { - case sizeof (GFC_INTEGER_1): - return internal_pack_1 ((gfc_array_i1 *) source); - - case sizeof (GFC_INTEGER_2): - return internal_pack_2 ((gfc_array_i2 *) source); - - case sizeof (GFC_INTEGER_4): - return internal_pack_4 ((gfc_array_i4 *) source); - - case sizeof (GFC_INTEGER_8): - return internal_pack_8 ((gfc_array_i8 *) source); + case GFC_DTYPE_INTEGER_1: + case GFC_DTYPE_LOGICAL_1: + case GFC_DTYPE_DERIVED_1: + return internal_pack_1 ((gfc_array_i1 *) source); + + case GFC_DTYPE_INTEGER_2: + case GFC_DTYPE_LOGICAL_2: + return internal_pack_2 ((gfc_array_i2 *) source); + + case GFC_DTYPE_INTEGER_4: + case GFC_DTYPE_LOGICAL_4: + return internal_pack_4 ((gfc_array_i4 *) source); + + case GFC_DTYPE_INTEGER_8: + case GFC_DTYPE_LOGICAL_8: + return internal_pack_8 ((gfc_array_i8 *) source); #if defined(HAVE_GFC_INTEGER_16) - case sizeof (GFC_INTEGER_16): - return internal_pack_16 ((gfc_array_i16 *) source); + case GFC_DTYPE_INTEGER_16: + case GFC_DTYPE_LOGICAL_16: + return internal_pack_16 ((gfc_array_i16 *) source); #endif - } - break; - - case GFC_DTYPE_REAL: - switch (size) - { - case sizeof (GFC_REAL_4): - return internal_pack_r4 ((gfc_array_r4 *) source); + case GFC_DTYPE_REAL_4: + return internal_pack_r4 ((gfc_array_r4 *) source); - case sizeof (GFC_REAL_8): - return internal_pack_r8 ((gfc_array_r8 *) source); + case GFC_DTYPE_REAL_8: + return internal_pack_r8 ((gfc_array_r8 *) source); #if defined (HAVE_GFC_REAL_10) - case sizeof (GFC_REAL_10): - return internal_pack_r10 ((gfc_array_r10 *) source); + case GFC_DTYPE_REAL_10: + return internal_pack_r10 ((gfc_array_r10 *) source); #endif #if defined (HAVE_GFC_REAL_16) - case sizeof (GFC_REAL_16): - return internal_pack_r16 ((gfc_array_r16 *) source); + case GFC_DTYPE_REAL_16: + return internal_pack_r16 ((gfc_array_r16 *) source); #endif - } - case GFC_DTYPE_COMPLEX: - switch (size) - { - case sizeof (GFC_COMPLEX_4): - return internal_pack_c4 ((gfc_array_c4 *) source); - - case sizeof (GFC_COMPLEX_8): - return internal_pack_c8 ((gfc_array_c8 *) source); + case GFC_DTYPE_COMPLEX_4: + return internal_pack_c4 ((gfc_array_c4 *) source); + + case GFC_DTYPE_COMPLEX_8: + return internal_pack_c8 ((gfc_array_c8 *) source); #if defined (HAVE_GFC_COMPLEX_10) - case sizeof (GFC_COMPLEX_10): - return internal_pack_c10 ((gfc_array_c10 *) source); + case GFC_DTYPE_COMPLEX_10: + return internal_pack_c10 ((gfc_array_c10 *) source); #endif #if defined (HAVE_GFC_COMPLEX_16) - case sizeof (GFC_COMPLEX_16): - return internal_pack_c16 ((gfc_array_c16 *) source); + case GFC_DTYPE_COMPLEX_16: + return internal_pack_c16 ((gfc_array_c16 *) source); #endif - } - break; + case GFC_DTYPE_DERIVED_2: + if (GFC_UNALIGNED_2(source->data)) + break; + else + return internal_pack_2 ((gfc_array_i2 *) source); + + case GFC_DTYPE_DERIVED_4: + if (GFC_UNALIGNED_4(source->data)) + break; + else + return internal_pack_4 ((gfc_array_i4 *) source); + + case GFC_DTYPE_DERIVED_8: + if (GFC_UNALIGNED_8(source->data)) + break; + else + return internal_pack_8 ((gfc_array_i8 *) source); + +#ifdef HAVE_GFC_INTEGER_16 + case GFC_DTYPE_DERIVED_16: + if (GFC_UNALIGNED_16(source->data)) + break; + else + return internal_pack_16 ((gfc_array_i16 *) source); +#endif default: break; |