#ifndef LIBGFOR_H
#define LIBGFOR_H
#include <math.h>
#include <stddef.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846264338327
#endif
#include "config.h"
#if HAVE_COMPLEX_H
# include <complex.h>
#else
#define complex __complex__
#endif
#if HAVE_STDINT_H
#include <stdint.h>
#endif
#if HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
typedef off_t gfc_offset;
#ifndef NULL
#define NULL (void *) 0
#endif
#ifndef __GNUC__
#define __attribute__(x)
#endif
#define prefix(x) _gfortran_ ## x
#ifndef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
#endif
#define REALPART(z) (__real__(z))
#define IMAGPART(z) (__imag__(z))
#define COMPLEX_ASSIGN(z_, r_, i_) {__real__(z_) = (r_); __imag__(z_) = (i_);}
typedef int32_t GFC_INTEGER_4;
typedef int64_t GFC_INTEGER_8;
typedef uint32_t GFC_UINTEGER_4;
typedef uint64_t GFC_UINTEGER_8;
typedef GFC_INTEGER_4 GFC_LOGICAL_4;
typedef GFC_INTEGER_8 GFC_LOGICAL_8;
typedef float GFC_REAL_4;
typedef double GFC_REAL_8;
typedef complex float GFC_COMPLEX_4;
typedef complex double GFC_COMPLEX_8;
typedef size_t index_type;
typedef GFC_INTEGER_4 gfc_charlen_type;
#define l8_to_l4_offset prefix(l8_to_l4_offset)
extern int l8_to_l4_offset;
#define GFOR_POINTER_L8_TO_L4(p8) \
(l8_to_l4_offset + (GFC_LOGICAL_4 *)(p8))
#define GFC_INTEGER_4_HUGE \
(GFC_INTEGER_4)((((GFC_UINTEGER_4)1) << 31) - 1)
#define GFC_INTEGER_8_HUGE \
(GFC_INTEGER_8)((((GFC_UINTEGER_8)1) << 63) - 1)
#define GFC_REAL_4_HUGE FLT_MAX
#define GFC_REAL_8_HUGE DBL_MAX
#ifndef GFC_MAX_DIMENSIONS
#define GFC_MAX_DIMENSIONS 7
#endif
typedef struct descriptor_dimension
{
index_type stride;
index_type lbound;
index_type ubound;
}
descriptor_dimension;
#define GFC_ARRAY_DESCRIPTOR(r, type) \
struct {\
type *data;\
type *base;\
index_type dtype;\
descriptor_dimension dim[r];\
}
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) gfc_array_void;
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, char) gfc_array_char;
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_4) gfc_array_i4;
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_INTEGER_8) gfc_array_i8;
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_4) gfc_array_r4;
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_REAL_8) gfc_array_r8;
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_4) gfc_array_c4;
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_COMPLEX_8) gfc_array_c8;
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_4) gfc_array_l4;
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, GFC_LOGICAL_8) gfc_array_l8;
#define GFC_DTYPE_RANK_MASK 0x07
#define GFC_DTYPE_TYPE_SHIFT 3
#define GFC_DTYPE_TYPE_MASK 0x38
#define GFC_DTYPE_SIZE_SHIFT 6
enum
{
GFC_DTYPE_UNKNOWN = 0,
GFC_DTYPE_INTEGER,
GFC_DTYPE_LOGICAL,
GFC_DTYPE_REAL,
GFC_DTYPE_COMPLEX,
GFC_DTYPE_DERIVED,
GFC_DTYPE_CHARACTER
};
#define GFC_DESCRIPTOR_RANK(desc) ((desc)->dtype & GFC_DTYPE_RANK_MASK)
#define GFC_DESCRIPTOR_TYPE(desc) (((desc)->dtype & GFC_DTYPE_TYPE_MASK) \
>> GFC_DTYPE_TYPE_SHIFT)
#define GFC_DESCRIPTOR_SIZE(desc) ((desc)->dtype >> GFC_DTYPE_SIZE_SHIFT)
#define GFC_DESCRIPTOR_DATA(desc) ((desc)->data)
#define GFC_DESCRIPTOR_DTYPE(desc) ((desc)->dtype)
#define stringize(x) expand_macro(x)
#define expand_macro(x) # x
typedef struct
{
int stdin_unit, stdout_unit, optional_plus;
int allocate_init_flag, allocate_init_value;
int locus;
int separator_len;
const char *separator;
int mem_check;
int use_stderr, all_unbuffered, default_recl;
int fpu_round, fpu_precision, fpu_invalid, fpu_denormal, fpu_zerodiv,
fpu_overflow, fpu_underflow, fpu_precision_loss;
int sighup, sigint;
}
options_t;
#define options prefix(options)
extern options_t options;
typedef struct
{
const char *name;
int value;
}
st_option;
typedef enum
{
ERROR_FIRST = -3,
ERROR_EOR = -2,
ERROR_END = -1,
ERROR_OK = 0,
ERROR_OS,
ERROR_OPTION_CONFLICT,
ERROR_BAD_OPTION,
ERROR_MISSING_OPTION,
ERROR_ALREADY_OPEN,
ERROR_BAD_UNIT,
ERROR_FORMAT,
ERROR_BAD_ACTION,
ERROR_ENDFILE,
ERROR_BAD_US,
ERROR_READ_VALUE,
ERROR_READ_OVERFLOW,
ERROR_LAST
}
error_codes;
#define line prefix(line)
extern unsigned line;
#define filename prefix(filename)
extern char *filename;
#define gfc_alloca(x) __builtin_alloca(x)
#define library_start prefix(library_start)
void library_start (void);
#define library_end prefix(library_end)
void library_end (void);
#define set_args prefix(set_args)
void set_args (int, char **);
#define get_args prefix(get_args)
void get_args (int *, char ***);
#define itoa prefix(itoa)
char *itoa (int64_t);
#define xtoa prefix(xtoa)
char *xtoa (uint64_t);
#define os_error prefix(os_error)
void os_error (const char *) __attribute__ ((noreturn));
#define show_locus prefix(show_locus)
void show_locus (void);
#define runtime_error prefix(runtime_error)
void runtime_error (const char *) __attribute__ ((noreturn));
#define internal_error prefix(internal_error)
void internal_error (const char *) __attribute__ ((noreturn));
#define get_oserror prefix(get_oserror)
const char *get_oserror (void);
#define write_error prefix(write_error)
void write_error (const char *);
#define sys_exit prefix(sys_exit)
void sys_exit (int) __attribute__ ((noreturn));
#define st_printf prefix(st_printf)
int st_printf (const char *, ...) __attribute__ ((format (printf, 1, 2)));
#define st_sprintf prefix(st_sprintf)
void st_sprintf (char *, const char *, ...) __attribute__ ((format (printf, 2, 3)));
#define translate_error prefix(translate_error)
const char *translate_error (int);
#define generate_error prefix(generate_error)
void generate_error (int, const char *);
#define memory_init prefix(memory_init)
void memory_init (void);
#define runtime_cleanup prefix(runtime_cleanup)
void runtime_cleanup (void);
#define get_mem prefix(get_mem)
void *get_mem (size_t) __attribute__ ((malloc));
#define free_mem prefix(free_mem)
void free_mem (void *);
#define internal_malloc_size prefix(internal_malloc_size)
void *internal_malloc_size (size_t);
#define internal_malloc prefix(internal_malloc)
void *internal_malloc (GFC_INTEGER_4);
#define internal_malloc64 prefix(internal_malloc64)
void *internal_malloc64 (GFC_INTEGER_8);
#define internal_free prefix(internal_free)
void internal_free (void *);
#define allocate prefix(allocate)
void allocate (void **, GFC_INTEGER_4, GFC_INTEGER_4 *);
#define allocate64 prefix(allocate64)
void allocate64 (void **, GFC_INTEGER_8, GFC_INTEGER_4 *);
#define deallocate prefix(deallocate)
void deallocate (void **, GFC_INTEGER_4 *);
#define check_buffered prefix(check_buffered)
int check_buffered (int);
#define init_variables prefix(init_variables)
void init_variables (void);
#define show_variables prefix(show_variables)
void show_variables (void);
#define find_option prefix(find_option)
int find_option (const char *, int, st_option *, const char *);
#define fstrlen prefix(fstrlen)
int fstrlen (const char *, int);
#define fstrcpy prefix(fstrcpy)
void fstrcpy (char *, int, const char *, int);
#define cf_strcpy prefix(cf_strcpy)
void cf_strcpy (char *, int, const char *);
#define init_units prefix(init_units)
void init_units (void);
#define close_units prefix(close_units)
void close_units (void);
#define stop_numeric prefix(stop_numeric)
void stop_numeric (GFC_INTEGER_4);
#define reshape_packed prefix(reshape_packed)
void reshape_packed (char *, index_type, const char *, index_type,
const char *, index_type);
#define internal_pack prefix(internal_pack)
void *internal_pack (gfc_array_char *);
#define internal_unpack prefix(internal_unpack)
void internal_unpack (gfc_array_char *, const void *);
#define internal_pack_4 prefix(internal_pack_4)
GFC_INTEGER_4 *internal_pack_4 (gfc_array_i4 *);
#define internal_pack_8 prefix(internal_pack_8)
GFC_INTEGER_8 *internal_pack_8 (gfc_array_i8 *);
#define internal_unpack_4 prefix(internal_unpack_4)
void internal_unpack_4 (gfc_array_i4 *, const GFC_INTEGER_4 *);
#define internal_unpack_8 prefix(internal_unpack_8)
void internal_unpack_8 (gfc_array_i8 *, const GFC_INTEGER_8 *);
#define date_and_time prefix(date_and_time)
void date_and_time (char *, char *, char *, gfc_array_i4 *,
GFC_INTEGER_4, GFC_INTEGER_4, GFC_INTEGER_4);
#define compare_string prefix(compare_string)
GFC_INTEGER_4 compare_string (GFC_INTEGER_4, const char *,
GFC_INTEGER_4, const char *);
#define random_seed prefix(random_seed)
void random_seed (GFC_INTEGER_4 * size, gfc_array_i4 * put,
gfc_array_i4 * get);
#define normalize_r4_i4 prefix(normalize_r4_i4)
GFC_REAL_4 normalize_r4_i4 (GFC_UINTEGER_4, GFC_UINTEGER_4);
#define normalize_r8_i8 prefix(normalize_r8_i8)
GFC_REAL_8 normalize_r8_i8 (GFC_UINTEGER_8, GFC_UINTEGER_8);
typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) array_t;
#define size0 prefix(size0)
index_type size0 (const array_t * array);
#endif