xref: /llvm-project/flang/include/flang/Runtime/magic-numbers.h (revision ff862d6de92f478253a332ec48cfc2c2add76bb3)
1 #if 0 /*===-- include/flang/Runtime/magic-numbers.h -----------------------===*/
2 /*
3  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4  * See https://llvm.org/LICENSE.txt for license information.
5  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6  *
7  *===----------------------------------------------------------------------===*/
8 #endif
9 #if 0
10 This header can be included into both Fortran and C.
11 
12 This file defines various code values that need to be exported
13 to predefined Fortran standard modules as well as to C/C++
14 code in the compiler and runtime library.
15 These include:
16  - the error/end code values that can be returned
17    to an IOSTAT= or STAT= specifier on a Fortran I/O statement
18    or coindexed data reference (see Fortran 2018 12.11.5,
19    16.10.2, and 16.10.2.33)
20 Codes from <errno.h>, e.g. ENOENT, are assumed to be positive
21 and are used "raw" as IOSTAT values.
22 
23 CFI_ERROR_xxx and CFI_INVALID_xxx macros from ISO_Fortran_binding.h
24 have small positive values.  The FORTRAN_RUNTIME_STAT_xxx macros here
25 start at 100 so as to never conflict with those codes.
26 #endif
27 #ifndef FORTRAN_RUNTIME_MAGIC_NUMBERS_H_
28 #define FORTRAN_RUNTIME_MAGIC_NUMBERS_H_
29 
30 #define FORTRAN_DEFAULT_OUTPUT_UNIT 6
31 #define FORTRAN_DEFAULT_INPUT_UNIT 5
32 #define FORTRAN_ERROR_UNIT 0
33 
34 #define FORTRAN_RUNTIME_IOSTAT_END (-1)
35 #define FORTRAN_RUNTIME_IOSTAT_EOR (-2)
36 #define FORTRAN_RUNTIME_IOSTAT_FLUSH (-3)
37 #define FORTRAN_RUNTIME_IOSTAT_INQUIRE_INTERNAL_UNIT 256
38 
39 #define FORTRAN_RUNTIME_STAT_FAILED_IMAGE 101
40 #define FORTRAN_RUNTIME_STAT_LOCKED 102
41 #define FORTRAN_RUNTIME_STAT_LOCKED_OTHER_IMAGE 103
42 #define FORTRAN_RUNTIME_STAT_STOPPED_IMAGE 104
43 #define FORTRAN_RUNTIME_STAT_UNLOCKED 105
44 #define FORTRAN_RUNTIME_STAT_UNLOCKED_FAILED_IMAGE 106
45 
46 #if 0
47 Status codes for GET_COMMAND_ARGUMENT. The status for 'value too short' needs
48 to be -1, the others must be positive.
49 #endif
50 #define FORTRAN_RUNTIME_STAT_INVALID_ARG_NUMBER 107
51 #define FORTRAN_RUNTIME_STAT_MISSING_ARG 108
52 #define FORTRAN_RUNTIME_STAT_VALUE_TOO_SHORT -1
53 
54 #if 0
55 Status codes for GET_ENVIRONMENT_VARIABLE. Values mandated by the standard.
56 #endif
57 #define FORTRAN_RUNTIME_STAT_MISSING_ENV_VAR 1
58 #define FORTRAN_RUNTIME_STAT_ENV_VARS_UNSUPPORTED 2
59 
60 #if 0
61 Processor-defined status code for MOVE_ALLOC where arguments are the
62 same allocatable.
63 #endif
64 #define FORTRAN_RUNTIME_STAT_MOVE_ALLOC_SAME_ALLOCATABLE 109
65 
66 #if 0
67 Additional status code for a bad pointer DEALLOCATE.
68 #endif
69 #define FORTRAN_RUNTIME_STAT_BAD_POINTER_DEALLOCATION 110
70 
71 #if 0
72 Status codes for GETCWD.
73 #endif
74 #define FORTRAN_RUNTIME_STAT_MISSING_CWD 111
75 
76 #if 0
77 ieee_class_type values
78 The sequence is that of F18 Clause 17.2p3, but nothing depends on that.
79 #endif
80 #define _FORTRAN_RUNTIME_IEEE_SIGNALING_NAN 1
81 #define _FORTRAN_RUNTIME_IEEE_QUIET_NAN 2
82 #define _FORTRAN_RUNTIME_IEEE_NEGATIVE_INF 3
83 #define _FORTRAN_RUNTIME_IEEE_NEGATIVE_NORMAL 4
84 #define _FORTRAN_RUNTIME_IEEE_NEGATIVE_SUBNORMAL 5
85 #define _FORTRAN_RUNTIME_IEEE_NEGATIVE_ZERO 6
86 #define _FORTRAN_RUNTIME_IEEE_POSITIVE_ZERO 7
87 #define _FORTRAN_RUNTIME_IEEE_POSITIVE_SUBNORMAL 8
88 #define _FORTRAN_RUNTIME_IEEE_POSITIVE_NORMAL 9
89 #define _FORTRAN_RUNTIME_IEEE_POSITIVE_INF 10
90 #define _FORTRAN_RUNTIME_IEEE_OTHER_VALUE 11
91 
92 #if 0
93 ieee_flag_type values
94 The values are those of a common but not universal fenv.h file.
95 The denorm value is a nonstandard extension.
96 #endif
97 #define _FORTRAN_RUNTIME_IEEE_INVALID 1
98 #define _FORTRAN_RUNTIME_IEEE_DENORM 2
99 #define _FORTRAN_RUNTIME_IEEE_DIVIDE_BY_ZERO 4
100 #define _FORTRAN_RUNTIME_IEEE_OVERFLOW 8
101 #define _FORTRAN_RUNTIME_IEEE_UNDERFLOW 16
102 #define _FORTRAN_RUNTIME_IEEE_INEXACT 32
103 #define _FORTRAN_RUNTIME_IEEE_ALL \
104   _FORTRAN_RUNTIME_IEEE_INVALID | _FORTRAN_RUNTIME_IEEE_DENORM | \
105       _FORTRAN_RUNTIME_IEEE_DIVIDE_BY_ZERO | _FORTRAN_RUNTIME_IEEE_OVERFLOW | \
106       _FORTRAN_RUNTIME_IEEE_UNDERFLOW | _FORTRAN_RUNTIME_IEEE_INEXACT
107 
108 #if 0
109 ieee_round_type values
110 The values are those of the llvm.get.rounding intrinsic, which is assumed by
111 ieee_arithmetic module rounding procedures.
112 #endif
113 #define _FORTRAN_RUNTIME_IEEE_TO_ZERO 0
114 #define _FORTRAN_RUNTIME_IEEE_NEAREST 1
115 #define _FORTRAN_RUNTIME_IEEE_UP 2
116 #define _FORTRAN_RUNTIME_IEEE_DOWN 3
117 #define _FORTRAN_RUNTIME_IEEE_AWAY 4
118 #define _FORTRAN_RUNTIME_IEEE_OTHER 5
119 
120 #if 0
121 INTEGER(kind=4) extents for ieee_exceptions module types ieee_modes_type and
122 ieee_status_type. These extent values are large enough to hold femode_t and
123 fenv_t data in many environments. An environment that does not meet these
124 size constraints may allocate memory with runtime size values.
125 #endif
126 #define _FORTRAN_RUNTIME_IEEE_FEMODE_T_EXTENT 2
127 #define _FORTRAN_RUNTIME_IEEE_FENV_T_EXTENT 8
128 
129 #endif
130