/* Implementation of the MAXLOC intrinsic
- Copyright 2002, 2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2002-2017 Free Software Foundation, Inc.
Contributed by Paul Brook <paul@nowt.org>
This file is part of the GNU Fortran 95 runtime library (libgfortran).
<http://www.gnu.org/licenses/>. */
#include "libgfortran.h"
-#include <stdlib.h>
-#include <assert.h>
-#include <limits.h>
#if defined (HAVE_GFC_REAL_16) && defined (HAVE_GFC_INTEGER_4)
if (rank <= 0)
runtime_error ("Rank of array needs to be > 0");
- if (retarray->data == NULL)
+ if (retarray->base_addr == NULL)
{
GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
retarray->offset = 0;
- retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank);
+ retarray->base_addr = xmallocarray (rank, sizeof (GFC_INTEGER_4));
}
else
{
}
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
- dest = retarray->data;
+ dest = retarray->base_addr;
for (n = 0; n < rank; n++)
{
sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
}
}
- base = array->data;
+ base = array->base_addr;
/* Initialize the return value. */
for (n = 0; n < rank; n++)
if (rank <= 0)
runtime_error ("Rank of array needs to be > 0");
- if (retarray->data == NULL)
+ if (retarray->base_addr == NULL)
{
GFC_DIMENSION_SET(retarray->dim[0], 0, rank - 1, 1);
retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
retarray->offset = 0;
- retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank);
+ retarray->base_addr = xmallocarray (rank, sizeof (GFC_INTEGER_4));
}
else
{
mask_kind = GFC_DESCRIPTOR_SIZE (mask);
- mbase = mask->data;
+ mbase = mask->base_addr;
if (mask_kind == 1 || mask_kind == 2 || mask_kind == 4 || mask_kind == 8
#ifdef HAVE_GFC_LOGICAL_16
runtime_error ("Funny sized logical array");
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
- dest = retarray->data;
+ dest = retarray->base_addr;
for (n = 0; n < rank; n++)
{
sstride[n] = GFC_DESCRIPTOR_STRIDE(array,n);
}
}
- base = array->data;
+ base = array->base_addr;
/* Initialize the return value. */
for (n = 0; n < rank; n++)
if (rank <= 0)
runtime_error ("Rank of array needs to be > 0");
- if (retarray->data == NULL)
+ if (retarray->base_addr == NULL)
{
GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1);
retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1;
retarray->offset = 0;
- retarray->data = internal_malloc_size (sizeof (GFC_INTEGER_4) * rank);
+ retarray->base_addr = xmallocarray (rank, sizeof (GFC_INTEGER_4));
}
else if (unlikely (compile_options.bounds_check))
{
}
dstride = GFC_DESCRIPTOR_STRIDE(retarray,0);
- dest = retarray->data;
+ dest = retarray->base_addr;
for (n = 0; n<rank; n++)
dest[n * dstride] = 0 ;
}