/* Generic helper function for repacking arrays.
- Copyright (C) 2003-2014 Free Software Foundation, Inc.
+ Copyright (C) 2003-2020 Free Software Foundation, Inc.
Contributed by Paul Brook <paul@nowt.org>
This file is part of the GNU Fortran runtime library (libgfortran).
<http://www.gnu.org/licenses/>. */
#include "libgfortran.h"
-#include <stdlib.h>
-#include <assert.h>
#include <string.h>
extern void internal_unpack (gfc_array_char *, const void *);
index_type dsize;
char *dest;
const char *src;
- int n;
- int size;
+ index_type size;
int type_size;
dest = d->base_addr;
{
case GFC_DTYPE_INTEGER_1:
case GFC_DTYPE_LOGICAL_1:
- case GFC_DTYPE_DERIVED_1:
internal_unpack_1 ((gfc_array_i1 *) d, (const GFC_INTEGER_1 *) s);
return;
# endif
#endif
- case GFC_DTYPE_DERIVED_2:
+ default:
+ break;
+ }
+
+ switch (GFC_DESCRIPTOR_SIZE(d))
+ {
+ case 1:
+ internal_unpack_1 ((gfc_array_i1 *) d, (const GFC_INTEGER_1 *) s);
+ return;
+
+ case 2:
if (GFC_UNALIGNED_2(d->base_addr) || GFC_UNALIGNED_2(s))
break;
else
internal_unpack_2 ((gfc_array_i2 *) d, (const GFC_INTEGER_2 *) s);
return;
}
- case GFC_DTYPE_DERIVED_4:
+
+ case 4:
if (GFC_UNALIGNED_4(d->base_addr) || GFC_UNALIGNED_4(s))
break;
else
return;
}
- case GFC_DTYPE_DERIVED_8:
+ case 8:
if (GFC_UNALIGNED_8(d->base_addr) || GFC_UNALIGNED_8(s))
break;
else
}
#ifdef HAVE_GFC_INTEGER_16
- case GFC_DTYPE_DERIVED_16:
+ case 16:
if (GFC_UNALIGNED_16(d->base_addr) || GFC_UNALIGNED_16(s))
break;
else
return;
}
#endif
-
default:
break;
}
dim = GFC_DESCRIPTOR_RANK (d);
dsize = 1;
- for (n = 0; n < dim; n++)
+ for (index_type n = 0; n < dim; n++)
{
count[n] = 0;
stride[n] = GFC_DESCRIPTOR_STRIDE(d,n);
dest += stride0;
count[0]++;
/* Advance to the next source element. */
- n = 0;
+ index_type n = 0;
while (count[n] == extent[n])
{
/* When we get to the end of a dimension, reset it and increment