Home | History | Annotate | Line # | Download | only in intrinsics
      1      1.1  mrg /* Generic implementation of the MOVE_ALLOC intrinsic
      2  1.1.1.4  mrg    Copyright (C) 2006-2024 Free Software Foundation, Inc.
      3      1.1  mrg    Contributed by Paul Thomas
      4      1.1  mrg 
      5      1.1  mrg This file is part of the GNU Fortran runtime library (libgfortran).
      6      1.1  mrg 
      7      1.1  mrg Libgfortran is free software; you can redistribute it and/or
      8      1.1  mrg modify it under the terms of the GNU General Public
      9      1.1  mrg License as published by the Free Software Foundation; either
     10      1.1  mrg version 3 of the License, or (at your option) any later version.
     11      1.1  mrg 
     12      1.1  mrg Ligbfortran is distributed in the hope that it will be useful,
     13      1.1  mrg but WITHOUT ANY WARRANTY; without even the implied warranty of
     14      1.1  mrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15      1.1  mrg GNU General Public License for more details.
     16      1.1  mrg 
     17      1.1  mrg Under Section 7 of GPL version 3, you are granted additional
     18      1.1  mrg permissions described in the GCC Runtime Library Exception, version
     19      1.1  mrg 3.1, as published by the Free Software Foundation.
     20      1.1  mrg 
     21      1.1  mrg You should have received a copy of the GNU General Public License and
     22      1.1  mrg a copy of the GCC Runtime Library Exception along with this program;
     23      1.1  mrg see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
     24      1.1  mrg <http://www.gnu.org/licenses/>.  */
     25      1.1  mrg 
     26      1.1  mrg #include "libgfortran.h"
     27      1.1  mrg 
     28      1.1  mrg 
     29      1.1  mrg extern void move_alloc (gfc_array_char *, gfc_array_char *);
     30      1.1  mrg export_proto(move_alloc);
     31      1.1  mrg 
     32      1.1  mrg void
     33      1.1  mrg move_alloc (gfc_array_char * from, gfc_array_char * to)
     34      1.1  mrg {
     35      1.1  mrg   int i;
     36      1.1  mrg 
     37      1.1  mrg   free (to->base_addr);
     38      1.1  mrg 
     39      1.1  mrg   for (i = 0; i < GFC_DESCRIPTOR_RANK (from); i++)
     40      1.1  mrg     {
     41      1.1  mrg       GFC_DIMENSION_SET(to->dim[i],GFC_DESCRIPTOR_LBOUND(from,i),
     42      1.1  mrg 			GFC_DESCRIPTOR_UBOUND(from,i),
     43      1.1  mrg 			GFC_DESCRIPTOR_STRIDE(from,i));
     44      1.1  mrg       GFC_DIMENSION_SET(from->dim[i],GFC_DESCRIPTOR_LBOUND(from,i),
     45      1.1  mrg 			GFC_DESCRIPTOR_LBOUND(from,i), 0);
     46      1.1  mrg     }
     47      1.1  mrg 
     48      1.1  mrg   to->offset = from->offset;
     49      1.1  mrg   GFC_DTYPE_COPY(to,from);
     50      1.1  mrg   to->base_addr = from->base_addr;
     51      1.1  mrg   from->base_addr = NULL;
     52      1.1  mrg }
     53      1.1  mrg 
     54      1.1  mrg extern void move_alloc_c (gfc_array_char *, GFC_INTEGER_4,
     55      1.1  mrg 			  gfc_array_char *, GFC_INTEGER_4);
     56      1.1  mrg export_proto(move_alloc_c);
     57      1.1  mrg 
     58      1.1  mrg void
     59      1.1  mrg move_alloc_c (gfc_array_char * from,
     60      1.1  mrg 	      GFC_INTEGER_4 from_length __attribute__((unused)),
     61      1.1  mrg 	      gfc_array_char * to,
     62      1.1  mrg 	      GFC_INTEGER_4 to_length __attribute__((unused)))
     63      1.1  mrg {
     64      1.1  mrg   move_alloc (from, to);
     65      1.1  mrg }
     66