(root)/
gcc-13.2.0/
gcc/
fortran/
libgfortran.h
       1  /* Header file to the Fortran front-end and runtime library
       2     Copyright (C) 2007-2023 Free Software Foundation, Inc.
       3  
       4  This file is part of GCC.
       5  
       6  GCC is free software; you can redistribute it and/or modify it under
       7  the terms of the GNU General Public License as published by the Free
       8  Software Foundation; either version 3, or (at your option) any later
       9  version.
      10  
      11  GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12  WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14  for more details.
      15  
      16  You should have received a copy of the GNU General Public License
      17  along with GCC; see the file COPYING3.  If not see
      18  <http://www.gnu.org/licenses/>.  */
      19  
      20  
      21  /* Flags to specify which standard/extension contains a feature.
      22     Note that no features were obsoleted nor deleted in F2003.
      23     Please remember to keep those definitions in sync with
      24     gfortran.texi.  */
      25  #define GFC_STD_F2018_DEL	(1<<11)	/* Deleted in F2018.  */
      26  #define GFC_STD_F2018_OBS	(1<<10)	/* Obsolescent in F2018.  */
      27  #define GFC_STD_F2018		(1<<9)	/* New in F2018.  */
      28  #define GFC_STD_F2008_OBS	(1<<8)	/* Obsolescent in F2008.  */
      29  #define GFC_STD_F2008		(1<<7)	/* New in F2008.  */
      30  #define GFC_STD_LEGACY		(1<<6)	/* Backward compatibility.  */
      31  #define GFC_STD_GNU		(1<<5)	/* GNU Fortran extension.  */
      32  #define GFC_STD_F2003		(1<<4)	/* New in F2003.  */
      33  #define GFC_STD_F95		(1<<3)	/* New in F95.  */
      34  #define GFC_STD_F95_DEL		(1<<2)	/* Deleted in F95.  */
      35  #define GFC_STD_F95_OBS		(1<<1)	/* Obsolescent in F95.  */
      36  #define GFC_STD_F77		(1<<0)	/* Included in F77, but not deleted or
      37  					   obsolescent in later standards.  */
      38  
      39  /* Combinations of the above flags that specify which classes of features
      40   * are allowed with a certain -std option.  */
      41  #define GFC_STD_OPT_F95		(GFC_STD_F77 | GFC_STD_F95 | GFC_STD_F95_OBS  \
      42  				| GFC_STD_F2008_OBS | GFC_STD_F2018_OBS \
      43  				| GFC_STD_F2018_DEL)
      44  #define GFC_STD_OPT_F03		(GFC_STD_OPT_F95 | GFC_STD_F2003)
      45  #define GFC_STD_OPT_F08		(GFC_STD_OPT_F03 | GFC_STD_F2008)
      46  #define GFC_STD_OPT_F18		((GFC_STD_OPT_F08 | GFC_STD_F2018) \
      47  				& (~GFC_STD_F2018_DEL))
      48  
      49  /* Bitmasks for the various FPE that can be enabled.  These need to be straight integers
      50     e.g., 8 instead of (1<<3), because they will be included in Fortran source.  */
      51  #define GFC_FPE_INVALID      1
      52  #define GFC_FPE_DENORMAL     2
      53  #define GFC_FPE_ZERO         4
      54  #define GFC_FPE_OVERFLOW     8
      55  #define GFC_FPE_UNDERFLOW   16
      56  #define GFC_FPE_INEXACT     32
      57  
      58  /* Defines for floating-point rounding modes.  */
      59  #define GFC_FPE_DOWNWARD   1
      60  #define GFC_FPE_TONEAREST  2
      61  #define GFC_FPE_TOWARDZERO 3
      62  #define GFC_FPE_UPWARD     4
      63  #define GFC_FPE_AWAY       5
      64  
      65  /* Size of the buffer required to store FPU state for any target.
      66     In particular, this has to be larger than fenv_t on all glibc targets.
      67     Currently, the winner is x86_64 with 32 bytes.  */
      68  #define GFC_FPE_STATE_BUFFER_SIZE 32
      69  
      70  /* Bitmasks for the various runtime checks that can be enabled.  */
      71  #define GFC_RTCHECK_BOUNDS      (1<<0)
      72  #define GFC_RTCHECK_ARRAY_TEMPS (1<<1)
      73  #define GFC_RTCHECK_RECURSION   (1<<2)
      74  #define GFC_RTCHECK_DO          (1<<3)
      75  #define GFC_RTCHECK_POINTER     (1<<4)
      76  #define GFC_RTCHECK_MEM         (1<<5)
      77  #define GFC_RTCHECK_BITS        (1<<6)
      78  #define GFC_RTCHECK_ALL        (GFC_RTCHECK_BOUNDS | GFC_RTCHECK_ARRAY_TEMPS \
      79  				| GFC_RTCHECK_RECURSION | GFC_RTCHECK_DO \
      80  				| GFC_RTCHECK_POINTER | GFC_RTCHECK_MEM \
      81  				| GFC_RTCHECK_BITS)
      82  
      83  /* Special unit numbers used to convey certain conditions.  Numbers -4
      84     thru -9 available.  NEWUNIT values start at -10.  */
      85  #define GFC_INTERNAL_UNIT  -1    /* KIND=1 Internal Unit.  */
      86  #define GFC_INTERNAL_UNIT4 -2    /* KIND=4 Internal Unit.  */
      87  #define GFC_INVALID_UNIT   -3
      88  
      89  /* Possible values for the CONVERT I/O specifier.  */
      90  /* Keep in sync with GFC_FLAG_CONVERT_* in gcc/flag-types.h.  */
      91  typedef enum
      92  {
      93    GFC_CONVERT_NONE = -1,
      94    GFC_CONVERT_NATIVE = 0,
      95    GFC_CONVERT_SWAP,
      96    GFC_CONVERT_BIG,
      97    GFC_CONVERT_LITTLE,
      98    GFC_CONVERT_R16_IEEE = 4,
      99    GFC_CONVERT_R16_IEEE_SWAP,
     100    GFC_CONVERT_R16_IEEE_BIG,
     101    GFC_CONVERT_R16_IEEE_LITTLE,
     102    GFC_CONVERT_R16_IBM = 8,
     103    GFC_CONVERT_R16_IBM_SWAP,
     104    GFC_CONVERT_R16_IBM_BIG,
     105    GFC_CONVERT_R16_IBM_LITTLE,
     106  }
     107  unit_convert;
     108  
     109  
     110  /* Runtime errors.  */
     111  typedef enum
     112  {
     113    LIBERROR_FIRST = -3,		/* Marker for the first error.  */
     114    LIBERROR_EOR = -2,		/* End of record, must be negative.  */
     115    LIBERROR_END = -1,		/* End of file, must be negative.  */
     116    LIBERROR_OK = 0,		/* Indicates success, must be zero.  */
     117    LIBERROR_OS = 5000,		/* OS error, more info in errno.  */
     118    LIBERROR_OPTION_CONFLICT,
     119    LIBERROR_BAD_OPTION,
     120    LIBERROR_MISSING_OPTION,
     121    LIBERROR_ALREADY_OPEN,
     122    LIBERROR_BAD_UNIT,
     123    LIBERROR_FORMAT,
     124    LIBERROR_BAD_ACTION,
     125    LIBERROR_ENDFILE,
     126    LIBERROR_BAD_US,
     127    LIBERROR_READ_VALUE,
     128    LIBERROR_READ_OVERFLOW,
     129    LIBERROR_INTERNAL,
     130    LIBERROR_INTERNAL_UNIT,
     131    LIBERROR_ALLOCATION,
     132    LIBERROR_DIRECT_EOR,
     133    LIBERROR_SHORT_RECORD,
     134    LIBERROR_CORRUPT_FILE,
     135    LIBERROR_INQUIRE_INTERNAL_UNIT, /* Must be different from STAT_STOPPED_IMAGE.  */
     136    LIBERROR_BAD_WAIT_ID,
     137    LIBERROR_NO_MEMORY,
     138    LIBERROR_LAST			/* Not a real error, the last error # + 1.  */
     139  }
     140  libgfortran_error_codes;
     141  
     142  /* Must kept in sync with libgfortran/caf/libcaf.h.  */
     143  typedef enum
     144  {
     145    GFC_STAT_UNLOCKED = 0,
     146    GFC_STAT_LOCKED,
     147    GFC_STAT_LOCKED_OTHER_IMAGE,
     148    GFC_STAT_STOPPED_IMAGE = 6000, /* See LIBERROR_INQUIRE_INTERNAL_UNIT above. */
     149    GFC_STAT_FAILED_IMAGE  = 6001
     150  }
     151  libgfortran_stat_codes;
     152  
     153  typedef enum
     154  {
     155    GFC_CAF_ATOMIC_ADD = 1,
     156    GFC_CAF_ATOMIC_AND,
     157    GFC_CAF_ATOMIC_OR,
     158    GFC_CAF_ATOMIC_XOR
     159  } libcaf_atomic_codes;
     160  
     161  
     162  /* For CO_REDUCE.  */
     163  #define GFC_CAF_BYREF      (1<<0)
     164  #define GFC_CAF_HIDDENLEN  (1<<1)
     165  #define GFC_CAF_ARG_VALUE  (1<<2)
     166  #define GFC_CAF_ARG_DESC   (1<<3)
     167  
     168  
     169  /* Default unit number for preconnected standard input and output.  */
     170  #define GFC_STDIN_UNIT_NUMBER 5
     171  #define GFC_STDOUT_UNIT_NUMBER 6
     172  #define GFC_STDERR_UNIT_NUMBER 0
     173  
     174  /* F2003 onward. For std < F2003, error caught in array.cc(gfc_match_array_ref).  */
     175  #define GFC_MAX_DIMENSIONS 15
     176  
     177  #define GFC_DTYPE_RANK_MASK 0x0F
     178  #define GFC_DTYPE_TYPE_SHIFT 4
     179  #define GFC_DTYPE_TYPE_MASK 0x70
     180  #define GFC_DTYPE_SIZE_SHIFT 7
     181  
     182  /* Basic types.  BT_VOID is used by ISO C Binding so funcs like c_f_pointer
     183     can take any arg with the pointer attribute as a param.  These are also
     184     used in the run-time library for IO.  */
     185  typedef enum
     186  { BT_UNKNOWN = 0, BT_INTEGER, BT_LOGICAL, BT_REAL, BT_COMPLEX,
     187    BT_DERIVED, BT_CHARACTER, BT_CLASS, BT_PROCEDURE, BT_HOLLERITH, BT_VOID,
     188    BT_ASSUMED, BT_UNION, BT_BOZ
     189  }
     190  bt;
     191  
     192  /* Enumeration of the possible floating-point types. These values
     193     correspond to the hidden arguments of the IEEE_CLASS_TYPE
     194     derived-type of IEEE_ARITHMETIC.  */
     195  
     196  enum {
     197    IEEE_OTHER_VALUE = 0,
     198    IEEE_SIGNALING_NAN,
     199    IEEE_QUIET_NAN,
     200    IEEE_NEGATIVE_INF,
     201    IEEE_NEGATIVE_NORMAL,
     202    IEEE_NEGATIVE_DENORMAL,
     203    IEEE_NEGATIVE_SUBNORMAL = IEEE_NEGATIVE_DENORMAL,
     204    IEEE_NEGATIVE_ZERO,
     205    IEEE_POSITIVE_ZERO,
     206    IEEE_POSITIVE_DENORMAL,
     207    IEEE_POSITIVE_SUBNORMAL = IEEE_POSITIVE_DENORMAL,
     208    IEEE_POSITIVE_NORMAL,
     209    IEEE_POSITIVE_INF
     210  };