GnuCOBOL  2.0
A free COBOL compiler
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
cobc.h File Reference
#include <stdio.h>
#include "libcob.h"
#include "flag.def"
#include "warning.def"
#include "codeoptim.def"
#include "config.def"
#include <unistd.h>
#include <strings.h>
#include "lib/gettext.h"
Include dependency graph for cobc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  cb_text_list
 
struct  cb_replace_list
 
struct  cb_define_struct
 
struct  local_filename
 
struct  filename
 
struct  cb_exception
 
struct  noreserve
 
struct  cobc_mem_struct
 

Macros

#define _(s)   s
 
#define N_(s)   s
 
#define F_OK   0
 
#define X_OK   1
 
#define W_OK   2
 
#define R_OK   4
 
#define COBC_ABORT()   cobc_abort(__FILE__, __LINE__)
 
#define COBC_DUMB_ABORT()   cobc_dumb_abort(__FILE__, __LINE__)
 
#define CB_FORMAT_FIXED   0
 
#define CB_FORMAT_FREE   1
 
#define CB_REPLACE_LEADING   1U
 
#define CB_REPLACE_TRAILING   2U
 
#define CB_STRINGIFY(s)   #s
 
#define CB_XSTRINGIFY(s)   CB_STRINGIFY(s)
 
#define CB_ASSIGN_MF   0 /* Micro Focus compatibility */
 
#define CB_ASSIGN_IBM   1U /* IBM compatibility */
 
#define CB_ASSIGN_COBOL2002   2U /* COBOL 2002 standard */
 
#define CB_BYTEORDER_BIG_ENDIAN   0
 
#define CB_BYTEORDER_NATIVE   1U
 
#define CB_BINARY_SIZE_1_2_4_8   0 /* 1,2,4,8 bytes */
 
#define CB_BINARY_SIZE_1__8   1U /* 1,2,3,4,5,6,7,8 bytes */
 
#define CB_BINARY_SIZE_2_4_8   2U /* 2,4,8 bytes */
 
#define PLEX_ACT_IF   0
 
#define PLEX_ACT_ELSE   1U
 
#define PLEX_ACT_END   2U
 
#define PLEX_ACT_ELIF   3U
 
#define PLEX_DEF_NONE   0
 
#define PLEX_DEF_LIT   1U
 
#define PLEX_DEF_NUM   2U
 
#define PLEX_DEF_DEL   3U
 
#define CB_CS_ACCEPT   (1U << 0)
 
#define CB_CS_ALPHABET   (1U << 1)
 
#define CB_CS_ASSIGN   (1U << 2)
 
#define CB_CS_CALL   (1U << 3)
 
#define CB_CS_CONSTANT   (1U << 4)
 
#define CB_CS_DATE   (1U << 5)
 
#define CB_CS_DAY   (1U << 6)
 
#define CB_CS_DISPLAY   (1U << 7)
 
#define CB_CS_ERASE   (1U << 8)
 
#define CB_CS_EXIT   (1U << 9)
 
#define CB_CS_FROM   (1U << 10)
 
#define CB_CS_PROGRAM_ID   (1U << 11)
 
#define CB_CS_ROUNDED   (1U << 12)
 
#define CB_CS_SET   (1U << 13)
 
#define CB_CS_STOP   (1U << 14)
 
#define CB_CS_WITH   (1U << 15)
 
#define CB_EXCEPTION_NAME(id)   cb_exception_table[id].name
 
#define CB_EXCEPTION_CODE(id)   cb_exception_table[id].code
 
#define CB_EXCEPTION_ENABLE(id)   cb_exception_table[id].enable
 
#define CB_FLAG(var, pdok, name, doc)   extern int var;
 
#define CB_FLAG_RQ(var, pdok, name, def, opt, doc)   extern int var;
 
#define CB_FLAG_NQ(pdok, name, opt, doc)
 
#define CB_WARNDEF(var, name, doc)   extern int var;
 
#define CB_NOWARNDEF(var, name, doc)   extern int var;
 
#define CB_OPTIM_DEF(x)   x,
 
#define CB_CONFIG_ANY(type, var, name)   extern type var;
 
#define CB_CONFIG_INT(var, name)   extern int var;
 
#define CB_CONFIG_STRING(var, name)   extern const char *var;
 
#define CB_CONFIG_BOOLEAN(var, name)   extern int var;
 
#define CB_CONFIG_SUPPORT(var, name)   extern enum cb_support var;
 
#define CB_MSG_STYLE_GCC   0
 
#define CB_MSG_STYLE_MSC   1U
 
#define _(s)   gettext(s)
 
#define N_(s)   gettext_noop(s)
 
#define COBC_ABORT()   cobc_abort(__FILE__, __LINE__)
 
#define COBC_DUMB_ABORT()   cobc_dumb_abort(__FILE__, __LINE__)
 
#define CB_FORMAT_FIXED   0
 
#define CB_FORMAT_FREE   1
 
#define CB_REPLACE_LEADING   1U
 
#define CB_REPLACE_TRAILING   2U
 
#define CB_STRINGIFY(s)   #s
 
#define CB_XSTRINGIFY(s)   CB_STRINGIFY(s)
 
#define CB_ASSIGN_MF   0 /* Micro Focus compatibility */
 
#define CB_ASSIGN_IBM   1U /* IBM compatibility */
 
#define CB_ASSIGN_COBOL2002   2U /* COBOL 2002 standard */
 
#define CB_BYTEORDER_BIG_ENDIAN   0
 
#define CB_BYTEORDER_NATIVE   1U
 
#define CB_BINARY_SIZE_1_2_4_8   0 /* 1,2,4,8 bytes */
 
#define CB_BINARY_SIZE_1__8   1U /* 1,2,3,4,5,6,7,8 bytes */
 
#define CB_BINARY_SIZE_2_4_8   2U /* 2,4,8 bytes */
 
#define PLEX_ACT_IF   0
 
#define PLEX_ACT_ELSE   1U
 
#define PLEX_ACT_END   2U
 
#define PLEX_ACT_ELIF   3U
 
#define PLEX_DEF_NONE   0
 
#define PLEX_DEF_LIT   1U
 
#define PLEX_DEF_NUM   2U
 
#define PLEX_DEF_DEL   3U
 
#define CB_CS_ACCEPT   (1U << 0)
 
#define CB_CS_ALPHABET   (1U << 1)
 
#define CB_CS_ASSIGN   (1U << 2)
 
#define CB_CS_CALL   (1U << 3)
 
#define CB_CS_CONSTANT   (1U << 4)
 
#define CB_CS_DATE   (1U << 5)
 
#define CB_CS_DAY   (1U << 6)
 
#define CB_CS_DISPLAY   (1U << 7)
 
#define CB_CS_ERASE   (1U << 8)
 
#define CB_CS_EXIT   (1U << 9)
 
#define CB_CS_FROM   (1U << 10)
 
#define CB_CS_PROGRAM_ID   (1U << 11)
 
#define CB_CS_ROUNDED   (1U << 12)
 
#define CB_CS_SET   (1U << 13)
 
#define CB_CS_STOP   (1U << 14)
 
#define CB_CS_WITH   (1U << 15)
 
#define CB_EXCEPTION_NAME(id)   cb_exception_table[id].name
 
#define CB_EXCEPTION_CODE(id)   cb_exception_table[id].code
 
#define CB_EXCEPTION_ENABLE(id)   cb_exception_table[id].enable
 
#define CB_FLAG(var, pdok, name, doc)   extern int var;
 
#define CB_FLAG_RQ(var, pdok, name, def, opt, doc)   extern int var;
 
#define CB_FLAG_NQ(pdok, name, opt, doc)
 
#define CB_WARNDEF(var, name, doc)   extern int var;
 
#define CB_NOWARNDEF(var, name, doc)   extern int var;
 
#define CB_OPTIM_DEF(x)   x,
 
#define CB_CONFIG_ANY(type, var, name)   extern type var;
 
#define CB_CONFIG_INT(var, name)   extern int var;
 
#define CB_CONFIG_STRING(var, name)   extern const char *var;
 
#define CB_CONFIG_BOOLEAN(var, name)   extern int var;
 
#define CB_CONFIG_SUPPORT(var, name)   extern enum cb_support var;
 
#define CB_MSG_STYLE_GCC   0
 
#define CB_MSG_STYLE_MSC   1U
 
#define _(s)   gettext(s)
 
#define N_(s)   gettext_noop(s)
 
#define COBC_ABORT()   cobc_abort(__FILE__, __LINE__)
 
#define COBC_DUMB_ABORT()   cobc_dumb_abort(__FILE__, __LINE__)
 
#define CB_FORMAT_FIXED   0
 
#define CB_FORMAT_FREE   1
 
#define CB_REPLACE_LEADING   1U
 
#define CB_REPLACE_TRAILING   2U
 
#define CB_STRINGIFY(s)   #s
 
#define CB_XSTRINGIFY(s)   CB_STRINGIFY(s)
 
#define CB_ASSIGN_MF   0 /* Micro Focus compatibility */
 
#define CB_ASSIGN_IBM   1U /* IBM compatibility */
 
#define CB_ASSIGN_COBOL2002   2U /* COBOL 2002 standard */
 
#define CB_BYTEORDER_BIG_ENDIAN   0
 
#define CB_BYTEORDER_NATIVE   1U
 
#define CB_BINARY_SIZE_1_2_4_8   0 /* 1,2,4,8 bytes */
 
#define CB_BINARY_SIZE_1__8   1U /* 1,2,3,4,5,6,7,8 bytes */
 
#define CB_BINARY_SIZE_2_4_8   2U /* 2,4,8 bytes */
 
#define PLEX_ACT_IF   0
 
#define PLEX_ACT_ELSE   1U
 
#define PLEX_ACT_END   2U
 
#define PLEX_ACT_ELIF   3U
 
#define PLEX_DEF_NONE   0
 
#define PLEX_DEF_LIT   1U
 
#define PLEX_DEF_NUM   2U
 
#define PLEX_DEF_DEL   3U
 
#define CB_CS_ACCEPT   (1U << 0)
 
#define CB_CS_ALPHABET   (1U << 1)
 
#define CB_CS_ASSIGN   (1U << 2)
 
#define CB_CS_CALL   (1U << 3)
 
#define CB_CS_CONSTANT   (1U << 4)
 
#define CB_CS_DATE   (1U << 5)
 
#define CB_CS_DAY   (1U << 6)
 
#define CB_CS_DISPLAY   (1U << 7)
 
#define CB_CS_ERASE   (1U << 8)
 
#define CB_CS_EXIT   (1U << 9)
 
#define CB_CS_FROM   (1U << 10)
 
#define CB_CS_PROGRAM_ID   (1U << 11)
 
#define CB_CS_ROUNDED   (1U << 12)
 
#define CB_CS_SET   (1U << 13)
 
#define CB_CS_STOP   (1U << 14)
 
#define CB_CS_WITH   (1U << 15)
 
#define CB_EXCEPTION_NAME(id)   cb_exception_table[id].name
 
#define CB_EXCEPTION_CODE(id)   cb_exception_table[id].code
 
#define CB_EXCEPTION_ENABLE(id)   cb_exception_table[id].enable
 
#define CB_FLAG(var, pdok, name, doc)   extern int var;
 
#define CB_FLAG_RQ(var, pdok, name, def, opt, doc)   extern int var;
 
#define CB_FLAG_NQ(pdok, name, opt, doc)
 
#define CB_WARNDEF(var, name, doc)   extern int var;
 
#define CB_NOWARNDEF(var, name, doc)   extern int var;
 
#define CB_OPTIM_DEF(x)   x,
 
#define CB_CONFIG_ANY(type, var, name)   extern type var;
 
#define CB_CONFIG_INT(var, name)   extern int var;
 
#define CB_CONFIG_STRING(var, name)   extern const char *var;
 
#define CB_CONFIG_BOOLEAN(var, name)   extern int var;
 
#define CB_CONFIG_SUPPORT(var, name)   extern enum cb_support var;
 
#define CB_MSG_STYLE_GCC   0
 
#define CB_MSG_STYLE_MSC   1U
 
#define _(s)   gettext(s)
 
#define N_(s)   gettext_noop(s)
 
#define COBC_ABORT()   cobc_abort(__FILE__, __LINE__)
 
#define COBC_DUMB_ABORT()   cobc_dumb_abort(__FILE__, __LINE__)
 
#define CB_FORMAT_FIXED   0
 
#define CB_FORMAT_FREE   1
 
#define CB_REPLACE_LEADING   1U
 
#define CB_REPLACE_TRAILING   2U
 
#define CB_STRINGIFY(s)   #s
 
#define CB_XSTRINGIFY(s)   CB_STRINGIFY(s)
 
#define CB_ASSIGN_MF   0 /* Micro Focus compatibility */
 
#define CB_ASSIGN_IBM   1U /* IBM compatibility */
 
#define CB_ASSIGN_COBOL2002   2U /* COBOL 2002 standard */
 
#define CB_BYTEORDER_BIG_ENDIAN   0
 
#define CB_BYTEORDER_NATIVE   1U
 
#define CB_BINARY_SIZE_1_2_4_8   0 /* 1,2,4,8 bytes */
 
#define CB_BINARY_SIZE_1__8   1U /* 1,2,3,4,5,6,7,8 bytes */
 
#define CB_BINARY_SIZE_2_4_8   2U /* 2,4,8 bytes */
 
#define PLEX_ACT_IF   0
 
#define PLEX_ACT_ELSE   1U
 
#define PLEX_ACT_END   2U
 
#define PLEX_ACT_ELIF   3U
 
#define PLEX_DEF_NONE   0
 
#define PLEX_DEF_LIT   1U
 
#define PLEX_DEF_NUM   2U
 
#define PLEX_DEF_DEL   3U
 
#define CB_CS_ACCEPT   (1U << 0)
 
#define CB_CS_ALPHABET   (1U << 1)
 
#define CB_CS_ASSIGN   (1U << 2)
 
#define CB_CS_CALL   (1U << 3)
 
#define CB_CS_CONSTANT   (1U << 4)
 
#define CB_CS_DATE   (1U << 5)
 
#define CB_CS_DAY   (1U << 6)
 
#define CB_CS_DISPLAY   (1U << 7)
 
#define CB_CS_ERASE   (1U << 8)
 
#define CB_CS_EXIT   (1U << 9)
 
#define CB_CS_FROM   (1U << 10)
 
#define CB_CS_PROGRAM_ID   (1U << 11)
 
#define CB_CS_ROUNDED   (1U << 12)
 
#define CB_CS_SET   (1U << 13)
 
#define CB_CS_STOP   (1U << 14)
 
#define CB_CS_WITH   (1U << 15)
 
#define CB_EXCEPTION_NAME(id)   cb_exception_table[id].name
 
#define CB_EXCEPTION_CODE(id)   cb_exception_table[id].code
 
#define CB_EXCEPTION_ENABLE(id)   cb_exception_table[id].enable
 
#define CB_FLAG(var, pdok, name, doc)   extern int var;
 
#define CB_FLAG_RQ(var, pdok, name, def, opt, doc)   extern int var;
 
#define CB_FLAG_NQ(pdok, name, opt, doc)
 
#define CB_WARNDEF(var, name, doc)   extern int var;
 
#define CB_NOWARNDEF(var, name, doc)   extern int var;
 
#define CB_OPTIM_DEF(x)   x,
 
#define CB_CONFIG_ANY(type, var, name)   extern type var;
 
#define CB_CONFIG_INT(var, name)   extern int var;
 
#define CB_CONFIG_STRING(var, name)   extern const char *var;
 
#define CB_CONFIG_BOOLEAN(var, name)   extern int var;
 
#define CB_CONFIG_SUPPORT(var, name)   extern enum cb_support var;
 
#define CB_MSG_STYLE_GCC   0
 
#define CB_MSG_STYLE_MSC   1U
 
#define _(s)   gettext(s)
 
#define N_(s)   gettext_noop(s)
 
#define COBC_ABORT()   cobc_abort(__FILE__, __LINE__)
 
#define COBC_DUMB_ABORT()   cobc_dumb_abort(__FILE__, __LINE__)
 
#define CB_FORMAT_FIXED   0
 
#define CB_FORMAT_FREE   1
 
#define CB_REPLACE_LEADING   1U
 
#define CB_REPLACE_TRAILING   2U
 
#define CB_STRINGIFY(s)   #s
 
#define CB_XSTRINGIFY(s)   CB_STRINGIFY(s)
 
#define CB_ASSIGN_MF   0 /* Micro Focus compatibility */
 
#define CB_ASSIGN_IBM   1U /* IBM compatibility */
 
#define CB_ASSIGN_COBOL2002   2U /* COBOL 2002 standard */
 
#define CB_BYTEORDER_BIG_ENDIAN   0
 
#define CB_BYTEORDER_NATIVE   1U
 
#define CB_BINARY_SIZE_1_2_4_8   0 /* 1,2,4,8 bytes */
 
#define CB_BINARY_SIZE_1__8   1U /* 1,2,3,4,5,6,7,8 bytes */
 
#define CB_BINARY_SIZE_2_4_8   2U /* 2,4,8 bytes */
 
#define PLEX_ACT_IF   0
 
#define PLEX_ACT_ELSE   1U
 
#define PLEX_ACT_END   2U
 
#define PLEX_ACT_ELIF   3U
 
#define PLEX_DEF_NONE   0
 
#define PLEX_DEF_LIT   1U
 
#define PLEX_DEF_NUM   2U
 
#define PLEX_DEF_DEL   3U
 
#define CB_CS_ACCEPT   (1U << 0)
 
#define CB_CS_ALPHABET   (1U << 1)
 
#define CB_CS_ASSIGN   (1U << 2)
 
#define CB_CS_CALL   (1U << 3)
 
#define CB_CS_CONSTANT   (1U << 4)
 
#define CB_CS_DATE   (1U << 5)
 
#define CB_CS_DAY   (1U << 6)
 
#define CB_CS_DISPLAY   (1U << 7)
 
#define CB_CS_ERASE   (1U << 8)
 
#define CB_CS_EXIT   (1U << 9)
 
#define CB_CS_FROM   (1U << 10)
 
#define CB_CS_PROGRAM_ID   (1U << 11)
 
#define CB_CS_ROUNDED   (1U << 12)
 
#define CB_CS_SET   (1U << 13)
 
#define CB_CS_STOP   (1U << 14)
 
#define CB_CS_WITH   (1U << 15)
 
#define CB_EXCEPTION_NAME(id)   cb_exception_table[id].name
 
#define CB_EXCEPTION_CODE(id)   cb_exception_table[id].code
 
#define CB_EXCEPTION_ENABLE(id)   cb_exception_table[id].enable
 
#define CB_FLAG(var, pdok, name, doc)   extern int var;
 
#define CB_FLAG_RQ(var, pdok, name, def, opt, doc)   extern int var;
 
#define CB_FLAG_NQ(pdok, name, opt, doc)
 
#define CB_WARNDEF(var, name, doc)   extern int var;
 
#define CB_NOWARNDEF(var, name, doc)   extern int var;
 
#define CB_OPTIM_DEF(x)   x,
 
#define CB_CONFIG_ANY(type, var, name)   extern type var;
 
#define CB_CONFIG_INT(var, name)   extern int var;
 
#define CB_CONFIG_STRING(var, name)   extern const char *var;
 
#define CB_CONFIG_BOOLEAN(var, name)   extern int var;
 
#define CB_CONFIG_SUPPORT(var, name)   extern enum cb_support var;
 
#define CB_MSG_STYLE_GCC   0
 
#define CB_MSG_STYLE_MSC   1U
 

Enumerations

enum  cb_operation_type { CB_OPERATION_READ = 0, CB_OPERATION_WRITE, CB_OPERATION_ASSIGN }
 
enum  cb_support {
  CB_OK = 0, CB_WARNING, CB_ARCHAIC, CB_OBSOLETE,
  CB_SKIP, CB_IGNORE, CB_ERROR, CB_UNCONFORMABLE
}
 
enum  cb_std_def {
  CB_STD_OC = 0, CB_STD_MF, CB_STD_IBM, CB_STD_MVS,
  CB_STD_BS2000, CB_STD_85, CB_STD_2002
}
 
enum  cb_optim { COB_OPTIM_MIN = 0, COB_OPTIM_MAX }
 

Functions

void * cobc_malloc (const size_t)
 memory allocation for use when compiling More...
 
void cobc_free (void *)
 deallocation of compile time memory More...
 
void * cobc_strdup (const char *)
 safely duplicate a character array More...
 
void * cobc_realloc (void *, const size_t)
 
void * cobc_main_malloc (const size_t)
 
void * cobc_main_strdup (const char *)
 
void * cobc_main_realloc (void *, const size_t)
 
void cobc_main_free (void *)
 
void * cobc_parse_malloc (const size_t)
 
void * cobc_parse_strdup (const char *)
 
void * cobc_parse_realloc (void *, const size_t)
 
void cobc_parse_free (void *)
 
void * cobc_plex_malloc (const size_t)
 
void * cobc_plex_strdup (const char *)
 
void * cobc_check_string (const char *)
 
void cobc_abort_pr (const char *,...) COB_A_FORMAT12
 
DECLNORET void cobc_abort (const char *, const int) COB_A_NORETURN
 
DECLNORET void cobc_too_many_errors (void) COB_A_NORETURN
 
DECLNORET void cobc_dumb_abort (const char *, const int)
 
size_t cobc_check_valid_name (const char *, const unsigned int)
 
int cb_load_std (const char *)
 
int cb_config_entry (char *, const char *, const int)
 
int cb_load_conf (const char *, const int, const int)
 
void cobc_init_scanner (void)
 
void cobc_init_typeck (void)
 
void cobc_init_reserved (void)
 
int pplex (void)
 
int ppparse (void)
 
int ppopen (const char *, struct cb_replace_list *)
 
int ppcopy (const char *, const char *, struct cb_replace_list *)
 
void pp_set_replace_list (struct cb_replace_list *, const cob_u32_t)
 
void ppparse_error (const char *)
 
void ppparse_clear_vars (const struct cb_define_struct *)
 
void plex_clear_vars (void)
 
void plex_clear_all (void)
 
void plex_call_destroy (void)
 
void plex_action_directive (const unsigned int, const unsigned int)
 
int yylex (void)
 
int yyparse (void)
 
void ylex_clear_all (void)
 
void ylex_call_destroy (void)
 
void cob_gen_optim (const enum cb_optim)
 
void cb_warning (const char *,...) COB_A_FORMAT12
 
void cb_error (const char *,...) COB_A_FORMAT12
 
void cb_plex_warning (const size_t, const char *,...) COB_A_FORMAT23
 
void cb_plex_error (const size_t, const char *,...) COB_A_FORMAT23
 
void configuration_error (const char *, const int, const char *,...) COB_A_FORMAT34
 
unsigned int cb_verify (const enum cb_support, const char *)
 

Variables

int cb_source_format
 
struct cb_exception cb_exception_table []
 
int cb_id
 
int cb_attr_id
 
int cb_literal_id
 
int cb_field_id
 
int cobc_flag_main
 
int cb_flag_functions_all
 
int cb_flag_main
 
int cobc_wants_debug
 
int errorcount
 
int warningcount
 
int warningopt
 
int no_physical_cancel
 
cob_u32_t optimize_defs []
 
char * cb_oc_build_stamp
 
const char * cb_source_file
 
int cb_source_line
 
const char * cob_config_dir
 
unsigned int cobc_gen_listing
 
const char * demangle_name
 
FILE * cb_storage_file
 
const char * cb_storage_file_name
 
char ** cb_saveargv
 
int cb_saveargc
 
FILE * cb_listing_file
 
struct cb_text_listcb_include_list
 
struct cb_text_listcb_intrinsic_list
 
struct cb_text_listcb_extension_list
 
struct cb_text_listcb_static_call_list
 
struct cb_text_listcb_early_exit_list
 
struct cb_programcurrent_program
 
struct cb_statementcurrent_statement
 
struct cb_labelcurrent_section
 
struct cb_labelcurrent_paragraph
 
int functions_are_all
 
struct noreservecobc_nores_base
 
FILE * ppin = (FILE *) 0
 
FILE * ppout = (FILE *) 0
 
char * cobc_glob_line
 
FILE * yyin
 
FILE * yyout
 
size_t suppress_warn
 
size_t cb_msg_style
 

Macro Definition Documentation

#define _ (   s)    gettext(s)
#define _ (   s)    gettext(s)
#define _ (   s)    gettext(s)
#define _ (   s)    gettext(s)
#define _ (   s)    s
#define CB_ASSIGN_COBOL2002   2U /* COBOL 2002 standard */
#define CB_ASSIGN_COBOL2002   2U /* COBOL 2002 standard */
#define CB_ASSIGN_COBOL2002   2U /* COBOL 2002 standard */
#define CB_ASSIGN_COBOL2002   2U /* COBOL 2002 standard */
#define CB_ASSIGN_COBOL2002   2U /* COBOL 2002 standard */
#define CB_ASSIGN_IBM   1U /* IBM compatibility */
#define CB_ASSIGN_IBM   1U /* IBM compatibility */
#define CB_ASSIGN_IBM   1U /* IBM compatibility */
#define CB_ASSIGN_IBM   1U /* IBM compatibility */
#define CB_ASSIGN_IBM   1U /* IBM compatibility */
#define CB_ASSIGN_MF   0 /* Micro Focus compatibility */
#define CB_ASSIGN_MF   0 /* Micro Focus compatibility */
#define CB_ASSIGN_MF   0 /* Micro Focus compatibility */
#define CB_ASSIGN_MF   0 /* Micro Focus compatibility */
#define CB_ASSIGN_MF   0 /* Micro Focus compatibility */
#define CB_BINARY_SIZE_1_2_4_8   0 /* 1,2,4,8 bytes */
#define CB_BINARY_SIZE_1_2_4_8   0 /* 1,2,4,8 bytes */
#define CB_BINARY_SIZE_1_2_4_8   0 /* 1,2,4,8 bytes */
#define CB_BINARY_SIZE_1_2_4_8   0 /* 1,2,4,8 bytes */
#define CB_BINARY_SIZE_1_2_4_8   0 /* 1,2,4,8 bytes */
#define CB_BINARY_SIZE_1__8   1U /* 1,2,3,4,5,6,7,8 bytes */
#define CB_BINARY_SIZE_1__8   1U /* 1,2,3,4,5,6,7,8 bytes */
#define CB_BINARY_SIZE_1__8   1U /* 1,2,3,4,5,6,7,8 bytes */
#define CB_BINARY_SIZE_1__8   1U /* 1,2,3,4,5,6,7,8 bytes */
#define CB_BINARY_SIZE_1__8   1U /* 1,2,3,4,5,6,7,8 bytes */
#define CB_BINARY_SIZE_2_4_8   2U /* 2,4,8 bytes */
#define CB_BINARY_SIZE_2_4_8   2U /* 2,4,8 bytes */
#define CB_BINARY_SIZE_2_4_8   2U /* 2,4,8 bytes */
#define CB_BINARY_SIZE_2_4_8   2U /* 2,4,8 bytes */
#define CB_BINARY_SIZE_2_4_8   2U /* 2,4,8 bytes */
#define CB_BYTEORDER_BIG_ENDIAN   0
#define CB_BYTEORDER_BIG_ENDIAN   0
#define CB_BYTEORDER_BIG_ENDIAN   0
#define CB_BYTEORDER_BIG_ENDIAN   0
#define CB_BYTEORDER_BIG_ENDIAN   0
#define CB_BYTEORDER_NATIVE   1U
#define CB_BYTEORDER_NATIVE   1U

Referenced by cb_config_entry().

#define CB_BYTEORDER_NATIVE   1U
#define CB_BYTEORDER_NATIVE   1U
#define CB_BYTEORDER_NATIVE   1U
#define CB_CONFIG_ANY (   type,
  var,
  name 
)    extern type var;
#define CB_CONFIG_ANY (   type,
  var,
  name 
)    extern type var;
#define CB_CONFIG_ANY (   type,
  var,
  name 
)    extern type var;
#define CB_CONFIG_ANY (   type,
  var,
  name 
)    extern type var;
#define CB_CONFIG_ANY (   type,
  var,
  name 
)    extern type var;
#define CB_CONFIG_BOOLEAN (   var,
  name 
)    extern int var;
#define CB_CONFIG_BOOLEAN (   var,
  name 
)    extern int var;
#define CB_CONFIG_BOOLEAN (   var,
  name 
)    extern int var;
#define CB_CONFIG_BOOLEAN (   var,
  name 
)    extern int var;
#define CB_CONFIG_BOOLEAN (   var,
  name 
)    extern int var;
#define CB_CONFIG_INT (   var,
  name 
)    extern int var;
#define CB_CONFIG_INT (   var,
  name 
)    extern int var;
#define CB_CONFIG_INT (   var,
  name 
)    extern int var;
#define CB_CONFIG_INT (   var,
  name 
)    extern int var;
#define CB_CONFIG_INT (   var,
  name 
)    extern int var;
#define CB_CONFIG_STRING (   var,
  name 
)    extern const char *var;
#define CB_CONFIG_STRING (   var,
  name 
)    extern const char *var;
#define CB_CONFIG_STRING (   var,
  name 
)    extern const char *var;
#define CB_CONFIG_STRING (   var,
  name 
)    extern const char *var;
#define CB_CONFIG_STRING (   var,
  name 
)    extern const char *var;
#define CB_CONFIG_SUPPORT (   var,
  name 
)    extern enum cb_support var;
#define CB_CONFIG_SUPPORT (   var,
  name 
)    extern enum cb_support var;
#define CB_CONFIG_SUPPORT (   var,
  name 
)    extern enum cb_support var;
#define CB_CONFIG_SUPPORT (   var,
  name 
)    extern enum cb_support var;
#define CB_CONFIG_SUPPORT (   var,
  name 
)    extern enum cb_support var;
#define CB_CS_ACCEPT   (1U << 0)
#define CB_CS_ACCEPT   (1U << 0)
#define CB_CS_ACCEPT   (1U << 0)
#define CB_CS_ACCEPT   (1U << 0)
#define CB_CS_ACCEPT   (1U << 0)
#define CB_CS_ALPHABET   (1U << 1)
#define CB_CS_ALPHABET   (1U << 1)
#define CB_CS_ALPHABET   (1U << 1)
#define CB_CS_ALPHABET   (1U << 1)
#define CB_CS_ALPHABET   (1U << 1)
#define CB_CS_ASSIGN   (1U << 2)
#define CB_CS_ASSIGN   (1U << 2)
#define CB_CS_ASSIGN   (1U << 2)
#define CB_CS_ASSIGN   (1U << 2)
#define CB_CS_ASSIGN   (1U << 2)
#define CB_CS_CALL   (1U << 3)
#define CB_CS_CALL   (1U << 3)
#define CB_CS_CALL   (1U << 3)
#define CB_CS_CALL   (1U << 3)
#define CB_CS_CALL   (1U << 3)
#define CB_CS_CONSTANT   (1U << 4)
#define CB_CS_CONSTANT   (1U << 4)
#define CB_CS_CONSTANT   (1U << 4)
#define CB_CS_CONSTANT   (1U << 4)
#define CB_CS_CONSTANT   (1U << 4)
#define CB_CS_DATE   (1U << 5)
#define CB_CS_DATE   (1U << 5)
#define CB_CS_DATE   (1U << 5)
#define CB_CS_DATE   (1U << 5)
#define CB_CS_DATE   (1U << 5)
#define CB_CS_DAY   (1U << 6)
#define CB_CS_DAY   (1U << 6)
#define CB_CS_DAY   (1U << 6)
#define CB_CS_DAY   (1U << 6)
#define CB_CS_DAY   (1U << 6)
#define CB_CS_DISPLAY   (1U << 7)
#define CB_CS_DISPLAY   (1U << 7)
#define CB_CS_DISPLAY   (1U << 7)
#define CB_CS_DISPLAY   (1U << 7)
#define CB_CS_DISPLAY   (1U << 7)
#define CB_CS_ERASE   (1U << 8)
#define CB_CS_ERASE   (1U << 8)
#define CB_CS_ERASE   (1U << 8)
#define CB_CS_ERASE   (1U << 8)
#define CB_CS_ERASE   (1U << 8)
#define CB_CS_EXIT   (1U << 9)
#define CB_CS_EXIT   (1U << 9)
#define CB_CS_EXIT   (1U << 9)

Referenced by while().

#define CB_CS_EXIT   (1U << 9)
#define CB_CS_EXIT   (1U << 9)
#define CB_CS_FROM   (1U << 10)
#define CB_CS_FROM   (1U << 10)
#define CB_CS_FROM   (1U << 10)
#define CB_CS_FROM   (1U << 10)
#define CB_CS_FROM   (1U << 10)
#define CB_CS_PROGRAM_ID   (1U << 11)
#define CB_CS_PROGRAM_ID   (1U << 11)
#define CB_CS_PROGRAM_ID   (1U << 11)

Referenced by lookup_reserved_word().

#define CB_CS_PROGRAM_ID   (1U << 11)
#define CB_CS_PROGRAM_ID   (1U << 11)
#define CB_CS_ROUNDED   (1U << 12)
#define CB_CS_ROUNDED   (1U << 12)
#define CB_CS_ROUNDED   (1U << 12)
#define CB_CS_ROUNDED   (1U << 12)
#define CB_CS_ROUNDED   (1U << 12)
#define CB_CS_SET   (1U << 13)
#define CB_CS_SET   (1U << 13)
#define CB_CS_SET   (1U << 13)
#define CB_CS_SET   (1U << 13)
#define CB_CS_SET   (1U << 13)
#define CB_CS_STOP   (1U << 14)
#define CB_CS_STOP   (1U << 14)
#define CB_CS_STOP   (1U << 14)
#define CB_CS_STOP   (1U << 14)
#define CB_CS_STOP   (1U << 14)
#define CB_CS_WITH   (1U << 15)
#define CB_CS_WITH   (1U << 15)
#define CB_CS_WITH   (1U << 15)
#define CB_CS_WITH   (1U << 15)
#define CB_CS_WITH   (1U << 15)
#define CB_EXCEPTION_CODE (   id)    cb_exception_table[id].code
#define CB_EXCEPTION_CODE (   id)    cb_exception_table[id].code
#define CB_EXCEPTION_CODE (   id)    cb_exception_table[id].code

Referenced by output_stmt().

#define CB_EXCEPTION_CODE (   id)    cb_exception_table[id].code
#define CB_EXCEPTION_CODE (   id)    cb_exception_table[id].code
#define CB_EXCEPTION_ENABLE (   id)    cb_exception_table[id].enable
#define CB_EXCEPTION_ENABLE (   id)    cb_exception_table[id].enable
#define CB_EXCEPTION_ENABLE (   id)    cb_exception_table[id].enable
#define CB_EXCEPTION_ENABLE (   id)    cb_exception_table[id].enable
#define CB_EXCEPTION_NAME (   id)    cb_exception_table[id].name
#define CB_EXCEPTION_NAME (   id)    cb_exception_table[id].name
#define CB_EXCEPTION_NAME (   id)    cb_exception_table[id].name
#define CB_EXCEPTION_NAME (   id)    cb_exception_table[id].name
#define CB_EXCEPTION_NAME (   id)    cb_exception_table[id].name
#define CB_FLAG (   var,
  pdok,
  name,
  doc 
)    extern int var;
#define CB_FLAG (   var,
  pdok,
  name,
  doc 
)    extern int var;
#define CB_FLAG (   var,
  pdok,
  name,
  doc 
)    extern int var;
#define CB_FLAG (   var,
  pdok,
  name,
  doc 
)    extern int var;
#define CB_FLAG (   var,
  pdok,
  name,
  doc 
)    extern int var;
#define CB_FLAG_NQ (   pdok,
  name,
  opt,
  doc 
)
#define CB_FLAG_NQ (   pdok,
  name,
  opt,
  doc 
)
#define CB_FLAG_NQ (   pdok,
  name,
  opt,
  doc 
)
#define CB_FLAG_NQ (   pdok,
  name,
  opt,
  doc 
)
#define CB_FLAG_NQ (   pdok,
  name,
  opt,
  doc 
)
#define CB_FLAG_RQ (   var,
  pdok,
  name,
  def,
  opt,
  doc 
)    extern int var;
#define CB_FLAG_RQ (   var,
  pdok,
  name,
  def,
  opt,
  doc 
)    extern int var;
#define CB_FLAG_RQ (   var,
  pdok,
  name,
  def,
  opt,
  doc 
)    extern int var;
#define CB_FLAG_RQ (   var,
  pdok,
  name,
  def,
  opt,
  doc 
)    extern int var;
#define CB_FLAG_RQ (   var,
  pdok,
  name,
  def,
  opt,
  doc 
)    extern int var;
#define CB_FORMAT_FIXED   0
#define CB_FORMAT_FIXED   0

Referenced by check_listing(), and ppinput().

#define CB_FORMAT_FIXED   0
#define CB_FORMAT_FIXED   0
#define CB_FORMAT_FIXED   0
#define CB_FORMAT_FREE   1
#define CB_FORMAT_FREE   1

Referenced by ppinput(), and while().

#define CB_FORMAT_FREE   1
#define CB_FORMAT_FREE   1
#define CB_FORMAT_FREE   1
#define CB_MSG_STYLE_GCC   0
#define CB_MSG_STYLE_GCC   0
#define CB_MSG_STYLE_GCC   0
#define CB_MSG_STYLE_GCC   0
#define CB_MSG_STYLE_GCC   0

Referenced by main().

#define CB_MSG_STYLE_MSC   1U
#define CB_MSG_STYLE_MSC   1U
#define CB_MSG_STYLE_MSC   1U
#define CB_MSG_STYLE_MSC   1U
#define CB_MSG_STYLE_MSC   1U

Referenced by cobc_print_info(), main(), and print_error().

#define CB_NOWARNDEF (   var,
  name,
  doc 
)    extern int var;
#define CB_NOWARNDEF (   var,
  name,
  doc 
)    extern int var;
#define CB_NOWARNDEF (   var,
  name,
  doc 
)    extern int var;
#define CB_NOWARNDEF (   var,
  name,
  doc 
)    extern int var;
#define CB_NOWARNDEF (   var,
  name,
  doc 
)    extern int var;
#define CB_OPTIM_DEF (   x)    x,
#define CB_OPTIM_DEF (   x)    x,
#define CB_OPTIM_DEF (   x)    x,
#define CB_OPTIM_DEF (   x)    x,
#define CB_OPTIM_DEF (   x)    x,
#define CB_REPLACE_LEADING   1U
#define CB_REPLACE_LEADING   1U

Referenced by ppecho().

#define CB_REPLACE_LEADING   1U
#define CB_REPLACE_LEADING   1U
#define CB_REPLACE_LEADING   1U
#define CB_REPLACE_TRAILING   2U
#define CB_REPLACE_TRAILING   2U
#define CB_REPLACE_TRAILING   2U

Referenced by ppecho().

#define CB_REPLACE_TRAILING   2U
#define CB_REPLACE_TRAILING   2U
#define CB_STRINGIFY (   s)    #s
#define CB_STRINGIFY (   s)    #s
#define CB_STRINGIFY (   s)    #s
#define CB_STRINGIFY (   s)    #s
#define CB_STRINGIFY (   s)    #s
#define CB_WARNDEF (   var,
  name,
  doc 
)    extern int var;
#define CB_WARNDEF (   var,
  name,
  doc 
)    extern int var;
#define CB_WARNDEF (   var,
  name,
  doc 
)    extern int var;
#define CB_WARNDEF (   var,
  name,
  doc 
)    extern int var;
#define CB_WARNDEF (   var,
  name,
  doc 
)    extern int var;
#define CB_XSTRINGIFY (   s)    CB_STRINGIFY(s)
#define CB_XSTRINGIFY (   s)    CB_STRINGIFY(s)
#define CB_XSTRINGIFY (   s)    CB_STRINGIFY(s)
#define CB_XSTRINGIFY (   s)    CB_STRINGIFY(s)
#define CB_XSTRINGIFY (   s)    CB_STRINGIFY(s)

Referenced by codegen().

#define COBC_ABORT ( )    cobc_abort(__FILE__, __LINE__)
#define COBC_ABORT ( )    cobc_abort(__FILE__, __LINE__)
#define COBC_ABORT ( )    cobc_abort(__FILE__, __LINE__)
#define COBC_ABORT ( )    cobc_abort(__FILE__, __LINE__)
#define COBC_DUMB_ABORT ( )    cobc_dumb_abort(__FILE__, __LINE__)
#define COBC_DUMB_ABORT ( )    cobc_dumb_abort(__FILE__, __LINE__)
#define COBC_DUMB_ABORT ( )    cobc_dumb_abort(__FILE__, __LINE__)

Referenced by cb_field_size(), and cb_tree_type().

#define COBC_DUMB_ABORT ( )    cobc_dumb_abort(__FILE__, __LINE__)
#define COBC_DUMB_ABORT ( )    cobc_dumb_abort(__FILE__, __LINE__)
#define N_ (   s)    gettext_noop(s)
#define N_ (   s)    gettext_noop(s)
#define N_ (   s)    gettext_noop(s)
#define N_ (   s)    gettext_noop(s)
#define N_ (   s)    s
#define PLEX_ACT_ELIF   3U
#define PLEX_ACT_ELIF   3U
#define PLEX_ACT_ELIF   3U
#define PLEX_ACT_ELIF   3U

Referenced by plex_action_directive().

#define PLEX_ACT_ELIF   3U
#define PLEX_ACT_ELSE   1U

Referenced by plex_action_directive().

#define PLEX_ACT_ELSE   1U
#define PLEX_ACT_ELSE   1U
#define PLEX_ACT_ELSE   1U
#define PLEX_ACT_ELSE   1U
#define PLEX_ACT_END   2U
#define PLEX_ACT_END   2U

Referenced by plex_action_directive().

#define PLEX_ACT_END   2U
#define PLEX_ACT_END   2U
#define PLEX_ACT_END   2U
#define PLEX_ACT_IF   0

Referenced by plex_action_directive().

#define PLEX_ACT_IF   0
#define PLEX_ACT_IF   0
#define PLEX_ACT_IF   0
#define PLEX_ACT_IF   0
#define PLEX_DEF_DEL   3U
#define PLEX_DEF_DEL   3U
#define PLEX_DEF_DEL   3U
#define PLEX_DEF_DEL   3U
#define PLEX_DEF_DEL   3U
#define PLEX_DEF_LIT   1U
#define PLEX_DEF_LIT   1U
#define PLEX_DEF_LIT   1U
#define PLEX_DEF_LIT   1U
#define PLEX_DEF_LIT   1U
#define PLEX_DEF_NONE   0
#define PLEX_DEF_NONE   0
#define PLEX_DEF_NONE   0
#define PLEX_DEF_NONE   0
#define PLEX_DEF_NONE   0
#define PLEX_DEF_NUM   2U
#define PLEX_DEF_NUM   2U
#define PLEX_DEF_NUM   2U
#define PLEX_DEF_NUM   2U
#define PLEX_DEF_NUM   2U
#define W_OK   2

Referenced by indexed_open().

#define X_OK   1

Enumeration Type Documentation

Enumerator
CB_OPERATION_READ 
CB_OPERATION_WRITE 
CB_OPERATION_ASSIGN 
122  {
123  CB_OPERATION_READ = 0,
126 };
enum cb_optim
Enumerator
COB_OPTIM_MIN 
COB_OPTIM_MAX 
256  {
257  COB_OPTIM_MIN = 0,
258 #include "codeoptim.def"
260 };
enum cb_std_def
Enumerator
CB_STD_OC 
CB_STD_MF 
CB_STD_IBM 
CB_STD_MVS 
CB_STD_BS2000 
CB_STD_85 
CB_STD_2002 
141  {
142  CB_STD_OC = 0,
143  CB_STD_MF,
144  CB_STD_IBM,
145  CB_STD_MVS,
147  CB_STD_85,
149 };
enum cb_support
Enumerator
CB_OK 
CB_WARNING 
CB_ARCHAIC 
CB_OBSOLETE 
CB_SKIP 
CB_IGNORE 
CB_ERROR 
CB_UNCONFORMABLE 
129  {
130  CB_OK = 0,
131  CB_WARNING,
132  CB_ARCHAIC,
133  CB_OBSOLETE,
134  CB_SKIP,
135  CB_IGNORE,
136  CB_ERROR,
138 };

Function Documentation

int cb_config_entry ( char *  ,
const char *  ,
const int   
)

References _, CB_ANY, CB_ARCHAIC, CB_ASSIGN_IBM, CB_ASSIGN_MF, CB_BINARY_SIZE_1_2_4_8, CB_BINARY_SIZE_1__8, CB_BINARY_SIZE_2_4_8, CB_BOOLEAN, CB_BYTEORDER_BIG_ENDIAN, CB_BYTEORDER_NATIVE, CB_CONFIG_SIZE, CB_ERROR, CB_IGNORE, CB_INT, CB_OBSOLETE, CB_OK, CB_SKIP, CB_STRING, CB_SUPPORT, CB_UNCONFORMABLE, CB_WARNING, cobc_main_malloc(), cobc_nores_base, config_table, configuration_error(), invalid_value(), config_struct::name, noreserve::next, noreserve::noresword, NULL, read_string(), unsupported_value(), config_struct::val, and config_struct::var.

Referenced by cb_load_conf(), and process_command_line().

136 {
137  char *s;
138  const char *name;
139  char *e;
140  struct noreserve *noresptr;
141  size_t size;
142  const char *val;
143  void *var;
144  size_t i;
145  size_t j;
146 
147  /* Get tag */
148  s = strpbrk (buff, " \t:=");
149  if (!s) {
150  configuration_error (fname, line,
151  _("Invalid configuration '%s'"), buff);
152  return -1;
153  }
154  *s = 0;
155 
156  /* Find entry */
157  for (i = 0; i < CB_CONFIG_SIZE; i++) {
158  if (strcmp (buff, config_table[i].name) == 0) {
159  break;
160  }
161  }
162  if (i == CB_CONFIG_SIZE) {
163  configuration_error (fname, line, _("Unknown configuration tag '%s'"), buff);
164  return -1;
165  }
166 
167  /* Get value */
168  /* Move pointer to beginning of value */
169  for (s++; *s && strchr (" \t:=", *s); s++) {
170  ;
171  }
172  /* Set end pointer to first # (comment) or end of value */
173  for (e = s + 1; *e && !strchr ("#", *e); e++) {
174  ;
175  }
176  /* Remove trailing white-spaces */
177  for (--e; e >= s && strchr (" \t\r\n", *e); e--) {
178  ;
179  }
180  e[1] = 0;
181  config_table[i].val = s;
182 
183  /* Set value */
184  name = config_table[i].name;
185  var = config_table[i].var;
186  val = config_table[i].val;
187  switch (config_table[i].type) {
188  case CB_ANY:
189  if (strcmp (name, "assign-clause") == 0) {
190  if (strcmp (val, "cobol2002") == 0) {
191  unsupported_value (fname, line, name, val);
192  return -1;
193  } else if (strcmp (val, "mf") == 0) {
194  cb_assign_clause = CB_ASSIGN_MF;
195  } else if (strcmp (val, "ibm") == 0) {
196  cb_assign_clause = CB_ASSIGN_IBM;
197  } else {
198  invalid_value (fname, line, name, val);
199  return -1;
200  }
201  } else if (strcmp (name, "binary-size") == 0) {
202  if (strcmp (val, "2-4-8") == 0) {
203  cb_binary_size = CB_BINARY_SIZE_2_4_8;
204  } else if (strcmp (val, "1-2-4-8") == 0) {
205  cb_binary_size = CB_BINARY_SIZE_1_2_4_8;
206  } else if (strcmp (val, "1--8") == 0) {
207  cb_binary_size = CB_BINARY_SIZE_1__8;
208  } else {
209  invalid_value (fname, line, name, val);
210  return -1;
211  }
212  } else if (strcmp (name, "binary-byteorder") == 0) {
213  if (strcmp (val, "native") == 0) {
214  cb_binary_byteorder = CB_BYTEORDER_NATIVE;
215  } else if (strcmp (val, "big-endian") == 0) {
216  cb_binary_byteorder = CB_BYTEORDER_BIG_ENDIAN;
217  } else {
218  invalid_value (fname, line, name, val);
219  return -1;
220  }
221  }
222  break;
223  case CB_INT:
224  for (j = 0; val[j]; j++) {
225  if (val[j] < '0' || val[j] > '9') {
226  invalid_value (fname, line, name, val);
227  return -1;
228  break;
229  }
230  }
231  *((int *)var) = atoi (val);
232  break;
233  case CB_STRING:
234  val = read_string (val);
235 
236  if (strcmp (name, "include") == 0) {
237  if (fname) {
238  /* Include another conf file */
239  return 1;
240  } else {
242  _("'%s' not supported with -cb_conf"), name);
243  return -1;
244  }
245  } else if (strcmp (name, "not-reserved") == 0) {
246  size = strlen (val);
247  noresptr = cobc_main_malloc (sizeof (struct noreserve)
248  + size + 1U);
249  noresptr->noresword = (char *)noresptr
250  + sizeof (struct noreserve);
251  memcpy (noresptr->noresword, val, size);
252  noresptr->next = cobc_nores_base;
253  cobc_nores_base = noresptr;
254  } else {
255  *((const char **)var) = val;
256  }
257  break;
258  case CB_BOOLEAN:
259  if (strcmp (val, "yes") == 0) {
260  *((int *)var) = 1;
261  } else if (strcmp (val, "no") == 0) {
262  *((int *)var) = 0;
263  } else {
264  invalid_value (fname, line, name, val);
265  return -1;
266  }
267  break;
268  case CB_SUPPORT:
269  if (strcmp (val, "ok") == 0) {
270  *((enum cb_support *)var) = CB_OK;
271  } else if (strcmp (val, "warning") == 0) {
272  *((enum cb_support *)var) = CB_WARNING;
273  } else if (strcmp (val, "archaic") == 0) {
274  *((enum cb_support *)var) = CB_ARCHAIC;
275  } else if (strcmp (val, "obsolete") == 0) {
276  *((enum cb_support *)var) = CB_OBSOLETE;
277  } else if (strcmp (val, "skip") == 0) {
278  *((enum cb_support *)var) = CB_SKIP;
279  } else if (strcmp (val, "ignore") == 0) {
280  *((enum cb_support *)var) = CB_IGNORE;
281  } else if (strcmp (val, "error") == 0) {
282  *((enum cb_support *)var) = CB_ERROR;
283  } else if (strcmp (val, "unconformable") == 0) {
284  *((enum cb_support *)var) = CB_UNCONFORMABLE;
285  } else {
286  invalid_value (fname, line, name, val);
287  return -1;
288  }
289  break;
290  default:
291  configuration_error (fname, line, _("Invalid type for '%s'"), name);
292  return -1;
293  }
294  return 0;
295 }
int cb_load_conf ( const char *  ,
const int  ,
const int   
)

References _, cb_config_entry(), CB_CONFIG_SIZE, cb_load_conf(), cob_config_dir, COB_SMALL_BUFF, COB_SMALL_MAX, config_table, configuration_error(), line, NULL, read_string(), SLASH_STR, and config_struct::val.

Referenced by cb_load_conf(), cb_load_std(), and process_command_line().

299 {
300  const unsigned char *x;
301  const char *name;
302  FILE *fp;
303  size_t i;
304  int sub_ret, ret;
305  int line;
306  char buff[COB_SMALL_BUFF];
307 
308  /* Initialize the configuration table */
309  if (check_nodef) {
310  for (i = 0; i < CB_CONFIG_SIZE; i++) {
311  config_table[i].val = NULL;
312  }
313  }
314 
315  if (prefix_dir) {
316  snprintf (buff, (size_t)COB_SMALL_MAX,
317  "%s%s%s", cob_config_dir, SLASH_STR, fname);
318  name = buff;
319  } else {
320  name = fname;
321  }
322  /* Open the configuration file */
323  fp = fopen (name, "r");
324  if (fp == NULL) {
325  fflush (stderr);
326  configuration_error (name, 0, _("No such file or directory"));
327  return -1;
328  }
329 
330  /* Read the configuration file */
331  ret = 0;
332  line = 0;
333  while (fgets (buff, COB_SMALL_BUFF, fp)) {
334  line++;
335 
336  /* Skip line comments, empty lines */
337  if (buff[0] == '#' || buff[0] == '\n') {
338  continue;
339  }
340 
341  /* Skip blank lines */
342  for (x = (const unsigned char *)buff; *x; x++) {
343  if (isgraph (*x)) {
344  break;
345  }
346  }
347  if (!*x) {
348  continue;
349  }
350 
351  sub_ret = cb_config_entry (buff, fname, line);
352  if (sub_ret == 1) {
353  /* Include another configuration file */
354  /* Find entry for getting include value */
355  for (i = 0; i < CB_CONFIG_SIZE; i++) {
356  if (strcmp (buff, config_table[i].name) == 0) {
357  break;
358  }
359  }
360  sub_ret = cb_load_conf (read_string(config_table[i].val), 0, 1);
361  if (sub_ret != 0) {
362  fclose (fp);
363  /* Only 1 include allowed */
364  if (sub_ret == 1) {
366  _("Only one include in configuration files allowed"));
367  sub_ret = -1;
368  }
369  }
370  }
371  if (sub_ret != 0) ret = sub_ret;
372  }
373  fclose (fp);
374 
375  /* Checks for missing definitions */
376  if (check_nodef) {
377  for (i = 2U; i < CB_CONFIG_SIZE; i++) {
378  if (config_table[i].val == NULL) {
379  configuration_error (fname, 0, _("No definition of '%s'"),
380  config_table[i].name);
381  ret = -1;
382  }
383  }
384  }
385 
386  return ret;
387 }
int cb_load_std ( const char *  )

References cb_load_conf().

Referenced by process_command_line().

130 {
131  return cb_load_conf (name, 1, 1);
132 }
void cb_plex_error ( const size_t  ,
const char *  ,
  ... 
)

References _, cb_source_line, cobc_too_many_errors(), errorcount, NULL, and print_error().

Referenced by plex_action_directive(), ppinput(), and ppparse_error().

130 {
131  va_list ap;
132 
133  va_start (ap, fmt);
134  print_error (NULL, (int)(cb_source_line + sline), _("Error: "), fmt, ap);
135  va_end (ap);
136  if (++errorcount > 100) {
138  }
139 }
void cb_plex_warning ( const size_t  ,
const char *  ,
  ... 
)

References _, cb_source_line, NULL, print_error(), and warningcount.

Referenced by ppinput(), and while().

119 {
120  va_list ap;
121 
122  va_start (ap, fmt);
123  print_error (NULL, (int)(cb_source_line + sline), _("Warning: "), fmt, ap);
124  va_end (ap);
125  warningcount++;
126 }
unsigned int cb_verify ( const enum  cb_support,
const char *   
)

References _, CB_ARCHAIC, CB_ERROR, cb_error(), CB_IGNORE, CB_OBSOLETE, CB_OK, CB_SKIP, CB_UNCONFORMABLE, CB_WARNING, cb_warning(), and warningopt.

Referenced by cb_emit_goto(), check_comments(), compute_size(), validate_field_1(), and while().

198 {
199  switch (tag) {
200  case CB_OK:
201  return 1;
202  case CB_WARNING:
203  return 1;
204  case CB_ARCHAIC:
205  if (cb_warn_archaic) {
206  cb_warning (_("%s is archaic in %s"), feature, cb_config_name);
207  }
208  return 1;
209  case CB_OBSOLETE:
210  if (cb_warn_obsolete) {
211  cb_warning (_("%s is obsolete in %s"), feature, cb_config_name);
212  }
213  return 1;
214  case CB_SKIP:
215  return 0;
216  case CB_IGNORE:
217  if (warningopt) {
218  cb_warning (_("%s ignored"), feature);
219  }
220  return 0;
221  case CB_ERROR:
222  return 0;
223  case CB_UNCONFORMABLE:
224  cb_error (_("%s does not conform to %s"), feature, cb_config_name);
225  return 0;
226  default:
227  break;
228  }
229  return 0;
230 }
void cb_warning ( const char *  ,
  ... 
)
void cob_gen_optim ( const enum  cb_optim)

References _, COBC_ABORT, cobc_abort_pr(), and output_storage().

Referenced by codegen().

48 {
49  switch (val) {
50 
51  case COB_SET_SCREEN:
52  output_storage ("static void COB_NOINLINE");
53  output_storage ("cob_set_screen (cob_screen *s, cob_screen *next,");
54  output_storage (" cob_screen *child, cob_field *field, cob_field *value,");
55  output_storage (" cob_field *line, cob_field *column,");
56  output_storage (" cob_field *foreg, cob_field *backg, cob_field *prompt,");
57  output_storage (" const int type, const int occurs, const int attr)");
58  output_storage ("{");
59  output_storage (" s->next = next;");
60  output_storage (" s->child = child;");
61  output_storage (" s->field = field;");
62  output_storage (" s->value = value;");
63  output_storage (" s->line = line;");
64  output_storage (" s->column = column;");
65  output_storage (" s->foreg = foreg;");
66  output_storage (" s->backg = backg;");
67  output_storage (" s->prompt = prompt;");
68  output_storage (" s->type = type;");
69  output_storage (" s->occurs = occurs;");
70  output_storage (" s->attr = attr;");
71  output_storage ("}");
72  return;
73 
74  case COB_POINTER_MANIP:
75  output_storage ("static void COB_NOINLINE");
76  output_storage ("cob_pointer_manip (cob_field *f1, cob_field *f2, const unsigned int addsub)");
77  output_storage ("{");
78  output_storage (" unsigned char *tmptr;");
79  output_storage (" memcpy (&tmptr, f1->data, sizeof(void *));");
80  output_storage (" if (addsub) {");
81  output_storage (" tmptr -= cob_get_int (f2);");
82  output_storage (" } else {");
83  output_storage (" tmptr += cob_get_int (f2);");
84  output_storage (" }");
85  output_storage (" memcpy (f1->data, &tmptr, sizeof(void *));");
86  output_storage ("}");
87  return;
88 
89  case COB_GET_NUMDISP:
90  output_storage ("static int COB_NOINLINE");
91  output_storage ("cob_get_numdisp (const void *data, const size_t size)");
92  output_storage ("{");
93  output_storage (" const unsigned char *p;");
94  output_storage (" size_t n;");
95  output_storage (" int retval;");
96 
97  output_storage (" p = (const unsigned char *)data;");
98  output_storage (" retval = 0;");
99  output_storage (" for (n = 0; n < size; ++n, ++p) {");
100  output_storage (" retval *= 10;");
101  output_storage (" retval += (*p & 0x0F);");
102  output_storage (" }");
103  output_storage (" return retval;");
104  output_storage ("}");
105  return;
106 
107  case COB_CMP_PACKED_INT:
108  output_storage ("static int COB_NOINLINE");
109  output_storage ("cob_cmp_packed_int (const cob_field *f, const cob_s64_t n)");
110  output_storage ("{");
111  output_storage (" unsigned char *p;");
112  output_storage (" size_t size;");
113  output_storage (" cob_s64_t val;");
114 
115  output_storage (" val = 0;");
116  output_storage (" p = f->data;");
117  output_storage (" for (size = 0; size < f->size - 1; ++size, ++p) {");
118  output_storage (" val *= 10;");
119  output_storage (" val += *p >> 4;");
120  output_storage (" val *= 10;");
121  output_storage (" val += *p & 0x0f;");
122  output_storage (" }");
123  output_storage (" val *= 10;");
124  output_storage (" val += *p >> 4;");
125  output_storage (" if ((*p & 0x0f) == 0x0d) {");
126  output_storage (" val = -val;");
127  output_storage (" }");
128  output_storage (" return (val < n) ? -1 : (val > n);");
129  output_storage ("}");
130  return;
131 
132  case COB_GET_PACKED_INT:
133  output_storage ("static int COB_NOINLINE");
134  output_storage ("cob_get_packed_int (const cob_field *f)");
135  output_storage ("{");
136  output_storage (" unsigned char *p;");
137  output_storage (" size_t size;");
138  output_storage (" int val = 0;");
139 
140  output_storage (" p = f->data;");
141  output_storage (" for (size = 0; size < f->size - 1; ++size, ++p) {");
142  output_storage (" val *= 10;");
143  output_storage (" val += *p >> 4;");
144  output_storage (" val *= 10;");
145  output_storage (" val += *p & 0x0f;");
146  output_storage (" }");
147  output_storage (" val *= 10;");
148  output_storage (" val += *p >> 4;");
149  output_storage (" if ((*p & 0x0f) == 0x0d) {");
150  output_storage (" val = -val;");
151  output_storage (" }");
152  output_storage (" return val;");
153  output_storage ("}");
154  return;
155 
156  case COB_ADD_PACKED_INT:
157  output_storage ("static int COB_NOINLINE");
158  output_storage ("cob_add_packed_int (cob_field *f, const int val)");
159  output_storage ("{");
160  output_storage (" unsigned char *p;");
161  output_storage (" size_t size;");
162  output_storage (" int carry = 0;");
163  output_storage (" int n;");
164  output_storage (" int inc;");
165 
166  output_storage (" if (val == 0) {");
167  output_storage (" return 0;");
168  output_storage (" }");
169  output_storage (" p = f->data + f->size - 1;");
170  output_storage (" if ((*p & 0x0f) == 0x0d) {");
171  output_storage (" if (val > 0) {");
172  output_storage (" return cob_add_int (f, val, 0);");
173  output_storage (" }");
174  output_storage (" n = -val;");
175  output_storage (" } else {");
176  output_storage (" if (val < 0) {");
177  output_storage (" return cob_add_int (f, val, 0);");
178  output_storage (" }");
179  output_storage (" n = val;");
180  output_storage (" }");
181  output_storage (" inc = (*p >> 4) + (n %% 10);");
182  output_storage (" n /= 10;");
183  output_storage (" carry = inc / 10;");
184  output_storage (" *p = ((inc %% 10) << 4) | (*p & 0x0f);");
185  output_storage (" p--;");
186 
187  output_storage (" for (size = 0; size < f->size - 1; ++size, --p) {");
188  output_storage (" if (!carry && !n) {");
189  output_storage (" break;");
190  output_storage (" }");
191  output_storage (" inc = ((*p >> 4) * 10) + (*p & 0x0f) + carry + (n %% 100);");
192  output_storage (" carry = inc / 100;");
193  output_storage (" n /= 100;");
194  output_storage (" inc %%= 100;");
195  output_storage (" *p = ((inc / 10) << 4) | (inc %% 10);");
196  output_storage (" }");
197  output_storage (" return 0;");
198  output_storage ("}");
199  return;
200 
201  /* Aligned variants */
202 
203  /* Aligned compares */
204 
205  case COB_CMP_ALIGN_U16:
206  output_storage ("static COB_INLINE COB_A_INLINE int");
207  output_storage ("cob_cmp_align_u16 (const void *p, const cob_s64_t n)");
208  output_storage ("{");
209  output_storage (" unsigned short val;");
210 
211  output_storage (" if (unlikely(n < 0)) {");
212  output_storage (" return 1;");
213  output_storage (" }");
214  output_storage (" val = *(unsigned short __unaligned *)p;");
215  output_storage (" return (val < n) ? -1 : (val > n);");
216  output_storage ("}");
217  return;
218 
219  case COB_CMP_ALIGN_S16:
220  output_storage ("static COB_INLINE COB_A_INLINE int");
221  output_storage ("cob_cmp_align_s16 (const void *p, const cob_s64_t n)");
222  output_storage ("{");
223  output_storage (" short val;");
224 
225  output_storage (" val = *(short __unaligned *)p;");
226  output_storage (" return (val < n) ? -1 : (val > n);");
227  output_storage ("}");
228  return;
229 
230  case COB_CMP_ALIGN_U32:
231  output_storage ("static COB_INLINE COB_A_INLINE int");
232  output_storage ("cob_cmp_align_u32 (const void *p, const cob_s64_t n)");
233  output_storage ("{");
234  output_storage (" unsigned int val;");
235 
236  output_storage (" if (unlikely(n < 0)) {");
237  output_storage (" return 1;");
238  output_storage (" }");
239  output_storage (" val = *(unsigned int __unaligned *)p;");
240  output_storage (" return (val < n) ? -1 : (val > n);");
241  output_storage ("}");
242  return;
243 
244  case COB_CMP_ALIGN_S32:
245  output_storage ("static COB_INLINE COB_A_INLINE int");
246  output_storage ("cob_cmp_align_s32 (const void *p, const cob_s64_t n)");
247  output_storage ("{");
248  output_storage (" int val;");
249 
250  output_storage (" val = *(int __unaligned *)p;");
251  output_storage (" return (val < n) ? -1 : (val > n);");
252  output_storage ("}");
253  return;
254 
255  case COB_CMP_ALIGN_U64:
256  output_storage ("static COB_INLINE COB_A_INLINE int");
257  output_storage ("cob_cmp_align_u64 (const void *p, const cob_s64_t n)");
258  output_storage ("{");
259  output_storage (" cob_u64_t val;");
260 
261  output_storage (" if (unlikely(n < 0)) {");
262  output_storage (" return 1;");
263  output_storage (" }");
264  output_storage (" val = *(cob_u64_t __unaligned *)p;");
265  output_storage (" return (val < n) ? -1 : (val > n);");
266  output_storage ("}");
267  return;
268 
269  case COB_CMP_ALIGN_S64:
270  output_storage ("static COB_INLINE COB_A_INLINE int");
271  output_storage ("cob_cmp_align_s64 (const void *p, const cob_s64_t n)");
272  output_storage ("{");
273  output_storage (" cob_s64_t val;");
274 
275  output_storage (" val = *(cob_s64_t __unaligned *)p;");
276  output_storage (" return (val < n) ? -1 : (val > n);");
277  output_storage ("}");
278  return;
279 
280  /* Aligned adds */
281 
282  case COB_ADD_ALIGN_U16:
283  output_storage ("static COB_INLINE COB_A_INLINE void");
284  output_storage ("cob_add_align_u16 (void *p, const int val)");
285  output_storage ("{");
286  output_storage (" *(unsigned short __unaligned *)p += val;");
287  output_storage ("}");
288  return;
289 
290  case COB_ADD_ALIGN_S16:
291  output_storage ("static COB_INLINE COB_A_INLINE void");
292  output_storage ("cob_add_align_s16 (void *p, const int val)");
293  output_storage ("{");
294  output_storage (" *(short __unaligned *)p += val;");
295  output_storage ("}");
296  return;
297 
298  case COB_ADD_ALIGN_U32:
299  output_storage ("static COB_INLINE COB_A_INLINE void");
300  output_storage ("cob_add_align_u32 (void *p, const int val)");
301  output_storage ("{");
302  output_storage (" *(unsigned int __unaligned *)p += val;");
303  output_storage ("}");
304  return;
305 
306  case COB_ADD_ALIGN_S32:
307  output_storage ("static COB_INLINE COB_A_INLINE void");
308  output_storage ("cob_add_align_s32 (void *p, const int val)");
309  output_storage ("{");
310  output_storage (" *(int __unaligned *)p += val;");
311  output_storage ("}");
312  return;
313 
314  case COB_ADD_ALIGN_U64:
315  output_storage ("static COB_INLINE COB_A_INLINE void");
316  output_storage ("cob_add_align_u64 (void *p, const int val)");
317  output_storage ("{");
318  output_storage (" *(cob_u64_t __unaligned *)p += val;");
319  output_storage ("}");
320  return;
321 
322  case COB_ADD_ALIGN_S64:
323  output_storage ("static COB_INLINE COB_A_INLINE void");
324  output_storage ("cob_add_align_s64 (void *p, const int val)");
325  output_storage ("{");
326  output_storage (" *(cob_s64_t __unaligned *)p += val;");
327  output_storage ("}");
328  return;
329 
330  /* Aligned subtracts */
331 
332  case COB_SUB_ALIGN_U16:
333  output_storage ("static COB_INLINE COB_A_INLINE void");
334  output_storage ("cob_sub_align_u16 (void *p, const int val)");
335  output_storage ("{");
336  output_storage (" *(unsigned short __unaligned *)p -= val;");
337  output_storage ("}");
338  return;
339 
340  case COB_SUB_ALIGN_S16:
341  output_storage ("static COB_INLINE COB_A_INLINE void");
342  output_storage ("cob_sub_align_s16 (void *p, const int val)");
343  output_storage ("{");
344  output_storage (" *(short __unaligned *)p -= val;");
345  output_storage ("}");
346  return;
347 
348  case COB_SUB_ALIGN_U32:
349  output_storage ("static COB_INLINE COB_A_INLINE void");
350  output_storage ("cob_sub_align_u32 (void *p, const int val)");
351  output_storage ("{");
352  output_storage (" *(unsigned int __unaligned *)p -= val;");
353  output_storage ("}");
354  return;
355 
356  case COB_SUB_ALIGN_S32:
357  output_storage ("static COB_INLINE COB_A_INLINE void");
358  output_storage ("cob_sub_align_s32 (void *p, const int val)");
359  output_storage ("{");
360  output_storage (" *(int __unaligned *)p -= val;");
361  output_storage ("}");
362  return;
363 
364  case COB_SUB_ALIGN_U64:
365  output_storage ("static COB_INLINE COB_A_INLINE void");
366  output_storage ("cob_sub_align_u64 (void *p, const int val)");
367  output_storage ("{");
368  output_storage (" *(cob_u64_t __unaligned *)p -= val;");
369  output_storage ("}");
370  return;
371 
372  case COB_SUB_ALIGN_S64:
373  output_storage ("static COB_INLINE COB_A_INLINE void");
374  output_storage ("cob_sub_align_s64 (void *p, const int val)");
375  output_storage ("{");
376  output_storage (" *(cob_s64_t __unaligned *)p -= val;");
377  output_storage ("}");
378  return;
379 
380  case COB_CMPSWP_ALIGN_U16:
381  output_storage ("static COB_INLINE COB_A_INLINE int");
382  output_storage ("cob_cmpswp_align_u16 (const void *p, const cob_s64_t n)");
383  output_storage ("{");
384  output_storage (" unsigned short val;");
385 
386  output_storage (" if (unlikely(n < 0)) {");
387  output_storage (" return 1;");
388  output_storage (" }");
389  output_storage (" val = COB_BSWAP_16 (*(unsigned short __unaligned *)p);");
390  output_storage (" return (val < n) ? -1 : (val > n);");
391  output_storage ("}");
392  return;
393 
394  case COB_CMPSWP_ALIGN_S16:
395  output_storage ("static COB_INLINE COB_A_INLINE int");
396  output_storage ("cob_cmpswp_align_s16 (const void *p, const cob_s64_t n)");
397  output_storage ("{");
398  output_storage (" short val;");
399 
400  output_storage (" val = COB_BSWAP_16 (*(short __unaligned *)p);");
401  output_storage (" return (val < n) ? -1 : (val > n);");
402  output_storage ("}");
403  return;
404 
405  case COB_CMPSWP_ALIGN_U32:
406  output_storage ("static COB_INLINE COB_A_INLINE int");
407  output_storage ("cob_cmpswp_align_u32 (const void *p, const cob_s64_t n)");
408  output_storage ("{");
409  output_storage (" unsigned int val;");
410 
411  output_storage (" if (unlikely(n < 0)) {");
412  output_storage (" return 1;");
413  output_storage (" }");
414  output_storage (" val = COB_BSWAP_32 (*(unsigned int __unaligned *)p);");
415  output_storage (" return (val < n) ? -1 : (val > n);");
416  output_storage ("}");
417  return;
418 
419  case COB_CMPSWP_ALIGN_S32:
420  output_storage ("static COB_INLINE COB_A_INLINE int");
421  output_storage ("cob_cmpswp_align_s32 (const void *p, const cob_s64_t n)");
422  output_storage ("{");
423  output_storage (" int val;");
424 
425  output_storage (" val = COB_BSWAP_32 (*(int __unaligned *)p);");
426  output_storage (" return (val < n) ? -1 : (val > n);");
427  output_storage ("}");
428  return;
429 
430  case COB_CMPSWP_ALIGN_U64:
431  output_storage ("static COB_INLINE COB_A_INLINE int");
432  output_storage ("cob_cmpswp_align_u64 (const void *p, const cob_s64_t n)");
433  output_storage ("{");
434  output_storage (" cob_u64_t val;");
435 
436  output_storage (" if (unlikely(n < 0)) {");
437  output_storage (" return 1;");
438  output_storage (" }");
439  output_storage (" val = COB_BSWAP_64 (*(cob_u64_t __unaligned *)p);");
440  output_storage (" return (val < n) ? -1 : (val > n);");
441  output_storage ("}");
442  return;
443 
444  case COB_CMPSWP_ALIGN_S64:
445  output_storage ("static COB_INLINE COB_A_INLINE int");
446  output_storage ("cob_cmpswp_align_s64 (const void *p, const cob_s64_t n)");
447  output_storage ("{");
448  output_storage (" cob_s64_t val;");
449 
450  output_storage (" val = COB_BSWAP_64 (*(cob_s64_t __unaligned *)p);");
451  output_storage (" return (val < n) ? -1 : (val > n);");
452  output_storage ("}");
453  return;
454 
455  /* Binary compare */
456 
457  case COB_CMP_U8:
458  output_storage ("static COB_INLINE COB_A_INLINE int");
459  output_storage ("cob_cmp_u8 (const void *p, const cob_s64_t n)");
460  output_storage ("{");
461  output_storage (" if (unlikely(n < 0)) {");
462  output_storage (" return 1;");
463  output_storage (" }");
464  output_storage (" return (*(const unsigned char *)p < n) ? -1 : (*(const unsigned char *)p > n);");
465  output_storage ("}");
466  return;
467 
468  case COB_CMP_S8:
469  output_storage ("static COB_INLINE COB_A_INLINE int");
470  output_storage ("cob_cmp_s8 (const void *p, const cob_s64_t n)");
471  output_storage ("{");
472  output_storage (" return (*(const signed char *)p < n) ? -1 : (*(const signed char *)p > n);");
473  output_storage ("}");
474  return;
475 
476  case COB_CMP_U16:
477  output_storage ("static COB_INLINE COB_A_INLINE int");
478  output_storage ("cob_cmp_u16 (const void *p, const cob_s64_t n)");
479  output_storage ("{");
480 #ifndef COB_ALLOW_UNALIGNED
481  output_storage (" void *x;");
482 #endif
483  output_storage (" unsigned short val;");
484 
485  output_storage (" if (unlikely(n < 0)) {");
486  output_storage (" return 1;");
487  output_storage (" }");
488 #ifdef COB_ALLOW_UNALIGNED
489  output_storage (" val = *(const unsigned short __unaligned *)p;");
490 #else
491  output_storage (" x = &val;");
492  output_storage (" optim_memcpy (x, p, 2);");
493 #endif
494  output_storage (" return (val < n) ? -1 : (val > n);");
495  output_storage ("}");
496  return;
497 
498  case COB_CMP_S16:
499  output_storage ("static COB_INLINE COB_A_INLINE int");
500  output_storage ("cob_cmp_s16 (const void *p, const cob_s64_t n)");
501  output_storage ("{");
502  output_storage (" short val;");
503 
504 #ifdef COB_ALLOW_UNALIGNED
505  output_storage (" val = *(const short __unaligned *)p;");
506 #else
507  output_storage (" void *x;");
508 
509  output_storage (" x = &val;");
510  output_storage (" optim_memcpy (x, p, 2);");
511 #endif
512  output_storage (" return (val < n) ? -1 : (val > n);");
513  output_storage ("}");
514  return;
515 
516  case COB_CMP_U24:
517  output_storage ("static COB_INLINE COB_A_INLINE int");
518  output_storage ("cob_cmp_u24 (const void *p, const cob_s64_t n)");
519  output_storage ("{");
520  output_storage (" unsigned char *x;");
521  output_storage (" unsigned int val = 0;");
522 
523  output_storage (" if (unlikely(n < 0)) {");
524  output_storage (" return 1;");
525  output_storage (" }");
526 #ifdef WORDS_BIGENDIAN
527  output_storage (" x = ((unsigned char *)&val) + 1;");
528 #else
529  output_storage (" x = (unsigned char *)&val;");
530 #endif
531  output_storage (" optim_memcpy (x, p, 3);");
532  output_storage (" return (val < n) ? -1 : (val > n);");
533  output_storage ("}");
534  return;
535 
536  case COB_CMP_S24:
537  output_storage ("static COB_INLINE COB_A_INLINE int");
538  output_storage ("cob_cmp_s24 (const void *p, const cob_s64_t n)");
539  output_storage ("{");
540  output_storage (" unsigned char *x;");
541  output_storage (" int val = 0;");
542 
543 #ifdef WORDS_BIGENDIAN
544  output_storage (" x = (unsigned char *)&val;");
545 #else
546  output_storage (" x = ((unsigned char *)&val) + 1;");
547 #endif
548  output_storage (" optim_memcpy (x, p, 3);");
549  output_storage (" val >>= 8; /* Shift with sign */");
550  output_storage (" return (val < n) ? -1 : (val > n);");
551  output_storage ("}");
552  return;
553 
554  case COB_CMP_U32:
555  output_storage ("static COB_INLINE COB_A_INLINE int");
556  output_storage ("cob_cmp_u32 (const void *p, const cob_s64_t n)");
557  output_storage ("{");
558 #ifndef COB_ALLOW_UNALIGNED
559  output_storage (" void *x;");
560 #endif
561  output_storage (" unsigned int val;");
562 
563  output_storage (" if (unlikely(n < 0)) {");
564  output_storage (" return 1;");
565  output_storage (" }");
566 #ifdef COB_ALLOW_UNALIGNED
567  output_storage (" val = *(const unsigned int __unaligned *)p;");
568 #else
569  output_storage (" x = &val;");
570  output_storage (" optim_memcpy (x, p, 4);");
571 #endif
572  output_storage (" return (val < n) ? -1 : (val > n);");
573  output_storage ("}");
574  return;
575 
576  case COB_CMP_S32:
577  output_storage ("static COB_INLINE COB_A_INLINE int");
578  output_storage ("cob_cmp_s32 (const void *p, const cob_s64_t n)");
579  output_storage ("{");
580  output_storage (" int val;");
581 
582 #ifdef COB_ALLOW_UNALIGNED
583  output_storage (" val = *(const int __unaligned *)p;");
584 #else
585  output_storage (" void *x;");
586 
587  output_storage (" x = &val;");
588  output_storage (" optim_memcpy (x, p, 4);");
589 #endif
590  output_storage (" return (val < n) ? -1 : (val > n);");
591  output_storage ("}");
592  return;
593 
594  case COB_CMP_U40:
595  output_storage ("static COB_INLINE COB_A_INLINE int");
596  output_storage ("cob_cmp_u40 (const void *p, const cob_s64_t n)");
597  output_storage ("{");
598  output_storage (" cob_u64_t val = 0;");
599  output_storage (" unsigned char *x;");
600 
601  output_storage (" if (unlikely(n < 0)) {");
602  output_storage (" return 1;");
603  output_storage (" }");
604 #ifdef WORDS_BIGENDIAN
605  output_storage (" x = ((unsigned char *)&val) + 3;");
606 #else
607  output_storage (" x = (unsigned char *)&val;");
608 #endif
609  output_storage (" optim_memcpy (x, p, 5);");
610  output_storage (" return (val < n) ? -1 : (val > n);");
611  output_storage ("}");
612  return;
613 
614  case COB_CMP_S40:
615  output_storage ("static COB_INLINE COB_A_INLINE int");
616  output_storage ("cob_cmp_s40 (const void *p, const cob_s64_t n)");
617  output_storage ("{");
618  output_storage (" cob_s64_t val = 0;");
619  output_storage (" unsigned char *x;");
620 
621 #ifdef WORDS_BIGENDIAN
622  output_storage (" x = (unsigned char *)&val;");
623 #else
624  output_storage (" x = ((unsigned char *)&val) + 3;");
625 #endif
626  output_storage (" optim_memcpy (x, p, 5);");
627  output_storage (" val >>= 24; /* Shift with sign */");
628  output_storage (" return (val < n) ? -1 : (val > n);");
629  output_storage ("}");
630  return;
631 
632  case COB_CMP_U48:
633  output_storage ("static COB_INLINE COB_A_INLINE int");
634  output_storage ("cob_cmp_u48 (const void *p, const cob_s64_t n)");
635  output_storage ("{");
636  output_storage (" cob_u64_t val = 0;");
637  output_storage (" unsigned char *x;");
638 
639  output_storage (" if (unlikely(n < 0)) {");
640  output_storage (" return 1;");
641  output_storage (" }");
642 #ifdef WORDS_BIGENDIAN
643  output_storage (" x = ((unsigned char *)&val) + 2;");
644 #else
645  output_storage (" x = (unsigned char *)&val;");
646 #endif
647  output_storage (" optim_memcpy (x, p, 6);");
648  output_storage (" return (val < n) ? -1 : (val > n);");
649  output_storage ("}");
650  return;
651 
652  case COB_CMP_S48:
653  output_storage ("static COB_INLINE COB_A_INLINE int");
654  output_storage ("cob_cmp_s48 (const void *p, const cob_s64_t n)");
655  output_storage ("{");
656  output_storage (" cob_s64_t val = 0;");
657  output_storage (" unsigned char *x;");
658 
659 #ifdef WORDS_BIGENDIAN
660  output_storage (" x = (unsigned char *)&val;");
661 #else
662  output_storage (" x = ((unsigned char *)&val) + 2;");
663 #endif
664  output_storage (" optim_memcpy (x, p, 6);");
665  output_storage (" val >>= 16; /* Shift with sign */");
666  output_storage (" return (val < n) ? -1 : (val > n);");
667  output_storage ("}");
668  return;
669 
670  case COB_CMP_U56:
671  output_storage ("static COB_INLINE COB_A_INLINE int");
672  output_storage ("cob_cmp_u56 (const void *p, const cob_s64_t n)");
673  output_storage ("{");
674  output_storage (" cob_u64_t val = 0;");
675  output_storage (" unsigned char *x;");
676 
677  output_storage (" if (unlikely(n < 0)) {");
678  output_storage (" return 1;");
679  output_storage (" }");
680 #ifdef WORDS_BIGENDIAN
681  output_storage (" x = ((unsigned char *)&val) + 1;");
682 #else
683  output_storage (" x = (unsigned char *)&val;");
684 #endif
685  output_storage (" optim_memcpy (x, p, 7);");
686  output_storage (" return (val < n) ? -1 : (val > n);");
687  output_storage ("}");
688  return;
689 
690  case COB_CMP_S56:
691  output_storage ("static COB_INLINE COB_A_INLINE int");
692  output_storage ("cob_cmp_s56 (const void *p, const cob_s64_t n)");
693  output_storage ("{");
694  output_storage (" cob_s64_t val = 0;");
695  output_storage (" unsigned char *x;");
696 
697 #ifdef WORDS_BIGENDIAN
698  output_storage (" x = (unsigned char *)&val;");
699 #else
700  output_storage (" x = ((unsigned char *)&val) + 1;");
701 #endif
702  output_storage (" optim_memcpy (x, p, 7);");
703  output_storage (" val >>= 8; /* Shift with sign */");
704  output_storage (" return (val < n) ? -1 : (val > n);");
705  output_storage ("}");
706  return;
707 
708  case COB_CMP_U64:
709  output_storage ("static COB_INLINE COB_A_INLINE int");
710  output_storage ("cob_cmp_u64 (const void *p, const cob_s64_t n)");
711  output_storage ("{");
712 #ifndef COB_ALLOW_UNALIGNED
713  output_storage (" void *x;");
714 #endif
715  output_storage (" cob_u64_t val;");
716 
717  output_storage (" if (unlikely(n < 0)) {");
718  output_storage (" return 1;");
719  output_storage (" }");
720 #ifdef COB_ALLOW_UNALIGNED
721  output_storage (" val = *(const cob_u64_t __unaligned *)p;");
722 #else
723  output_storage (" x = &val;");
724  output_storage (" optim_memcpy (x, p, 8);");
725 #endif
726  output_storage (" return (val < n) ? -1 : (val > n);");
727  output_storage ("}");
728  return;
729 
730  case COB_CMP_S64:
731  output_storage ("static COB_INLINE COB_A_INLINE int");
732  output_storage ("cob_cmp_s64 (const void *p, const cob_s64_t n)");
733  output_storage ("{");
734  output_storage (" cob_s64_t val;");
735 
736 #ifdef COB_ALLOW_UNALIGNED
737  output_storage (" val = *(const cob_s64_t __unaligned *)p;");
738 #else
739  output_storage (" void *x;");
740 
741  output_storage (" x = &val;");
742  output_storage (" optim_memcpy (x, p, 8);");
743 #endif
744  output_storage (" return (val < n) ? -1 : (val > n);");
745  output_storage ("}");
746  return;
747 
748  /* Add/Subtract */
749 
750  case COB_ADD_U8:
751  output_storage ("static COB_INLINE COB_A_INLINE void");
752  output_storage ("cob_add_u8 (void *p, const int val)");
753  output_storage ("{");
754  output_storage (" *(unsigned char *)p += val;");
755  output_storage ("}");
756  return;
757 
758  case COB_ADD_S8:
759  output_storage ("static COB_INLINE COB_A_INLINE void");
760  output_storage ("cob_add_s8 (void *p, const int val)");
761  output_storage ("{");
762  output_storage (" *(signed char *)p += val;");
763  output_storage ("}");
764  return;
765 
766  case COB_ADD_U16:
767  output_storage ("static COB_INLINE COB_A_INLINE void");
768  output_storage ("cob_add_u16 (void *p, const int val)");
769  output_storage ("{");
770 #ifdef COB_ALLOW_UNALIGNED
771  output_storage (" *(unsigned short __unaligned *)p += val;");
772 #else
773  output_storage (" void *x;");
774  output_storage (" unsigned short n;");
775 
776  output_storage (" x = &n;");
777  output_storage (" optim_memcpy (x, p, 2);");
778  output_storage (" n += val;");
779  output_storage (" optim_memcpy (p, x, 2);");
780 #endif
781  output_storage ("}");
782  return;
783 
784  case COB_ADD_S16:
785  output_storage ("static COB_INLINE COB_A_INLINE void");
786  output_storage ("cob_add_s16 (void *p, const int val)");
787  output_storage ("{");
788 #ifdef COB_ALLOW_UNALIGNED
789  output_storage (" *(short __unaligned *)p += val;");
790 #else
791  output_storage (" void *x;");
792  output_storage (" short n;");
793 
794  output_storage (" x = &n;");
795  output_storage (" optim_memcpy (x, p, 2);");
796  output_storage (" n += val;");
797  output_storage (" optim_memcpy (p, x, 2);");
798 #endif
799  output_storage ("}");
800  return;
801 
802  case COB_ADD_U24:
803  output_storage ("static COB_INLINE COB_A_INLINE void");
804  output_storage ("cob_add_u24 (void *p, const int val)");
805  output_storage ("{");
806  output_storage (" unsigned char *x;");
807  output_storage (" unsigned int n = 0;");
808 
809 #ifdef WORDS_BIGENDIAN
810  output_storage (" x = ((unsigned char *)&n) + 1;");
811 #else
812  output_storage (" x = (unsigned char *)&n;");
813 #endif
814  output_storage (" optim_memcpy (x, p, 3);");
815  output_storage (" n += val;");
816  output_storage (" optim_memcpy (p, x, 3);");
817  output_storage ("}");
818  return;
819 
820  case COB_ADD_S24:
821  output_storage ("static COB_INLINE COB_A_INLINE void");
822  output_storage ("cob_add_s24 (void *p, const int val)");
823  output_storage ("{");
824  output_storage (" unsigned char *x;");
825  output_storage (" int n = 0;");
826 
827 #ifdef WORDS_BIGENDIAN
828  output_storage (" x = (unsigned char *)&n;");
829 #else
830  output_storage (" x = ((unsigned char *)&n) + 1;");
831 #endif
832  output_storage (" optim_memcpy (x, p, 3);");
833  output_storage (" n >>= 8; /* Shift with sign */");
834  output_storage (" n += val;");
835 #ifdef WORDS_BIGENDIAN
836  output_storage (" x = ((unsigned char *)&n) + 1;");
837 #else
838  output_storage (" x = (unsigned char *)&n;");
839 #endif
840  output_storage (" optim_memcpy (p, x, 3);");
841  output_storage ("}");
842  return;
843 
844  case COB_ADD_U32:
845  output_storage ("static COB_INLINE COB_A_INLINE void");
846  output_storage ("cob_add_u32 (void *p, const int val)");
847  output_storage ("{");
848 #ifdef COB_ALLOW_UNALIGNED
849  output_storage (" *(unsigned int __unaligned *)p += val;");
850 #else
851  output_storage (" void *x;");
852  output_storage (" unsigned int n;");
853 
854  output_storage (" x = &n;");
855  output_storage (" optim_memcpy (x, p, 4);");
856  output_storage (" n += val;");
857  output_storage (" optim_memcpy (p, x, 4);");
858 #endif
859  output_storage ("}");
860  return;
861 
862  case COB_ADD_S32:
863  output_storage ("static COB_INLINE COB_A_INLINE void");
864  output_storage ("cob_add_s32 (void *p, const int val)");
865  output_storage ("{");
866 #ifdef COB_ALLOW_UNALIGNED
867  output_storage (" *(int __unaligned *)p += val;");
868 #else
869  output_storage (" void *x;");
870  output_storage (" int n;");
871 
872  output_storage (" x = &n;");
873  output_storage (" optim_memcpy (x, p, 4);");
874  output_storage (" n += val;");
875  output_storage (" optim_memcpy (p, x, 4);");
876 #endif
877  output_storage ("}");
878  return;
879 
880  case COB_ADD_U40:
881  output_storage ("static COB_INLINE COB_A_INLINE void");
882  output_storage ("cob_add_u40 (void *p, const int val)");
883  output_storage ("{");
884  output_storage (" cob_u64_t n = 0;");
885  output_storage (" unsigned char *x;");
886 
887 #ifdef WORDS_BIGENDIAN
888  output_storage (" x = ((unsigned char *)&n) + 3;");
889 #else
890  output_storage (" x = (unsigned char *)&n;");
891 #endif
892  output_storage (" optim_memcpy (x, p, 5);");
893  output_storage (" n += val;");
894  output_storage (" optim_memcpy (p, x, 5);");
895  output_storage ("}");
896  return;
897 
898  case COB_ADD_S40:
899  output_storage ("static COB_INLINE COB_A_INLINE void");
900  output_storage ("cob_add_s40 (void *p, const int val)");
901  output_storage ("{");
902  output_storage (" cob_s64_t n = 0;");
903  output_storage (" unsigned char *x;");
904 
905 #ifdef WORDS_BIGENDIAN
906  output_storage (" x = (unsigned char *)&n;");
907 #else
908  output_storage (" x = ((unsigned char *)&n) + 3;");
909 #endif
910  output_storage (" optim_memcpy (x, p, 5);");
911  output_storage (" n >>= 24; /* Shift with sign */");
912  output_storage (" n += val;");
913 #ifdef WORDS_BIGENDIAN
914  output_storage (" x = ((unsigned char *)&n) + 3;");
915 #else
916  output_storage (" x = (unsigned char *)&n;");
917 #endif
918  output_storage (" optim_memcpy (p, x, 5);");
919  output_storage ("}");
920  return;
921 
922  case COB_ADD_U48:
923  output_storage ("static COB_INLINE COB_A_INLINE void");
924  output_storage ("cob_add_u48 (void *p, const int val)");
925  output_storage ("{");
926  output_storage (" cob_u64_t n = 0;");
927  output_storage (" unsigned char *x;");
928 
929 #ifdef WORDS_BIGENDIAN
930  output_storage (" x = ((unsigned char *)&n) + 2;");
931 #else
932  output_storage (" x = (unsigned char *)&n;");
933 #endif
934  output_storage (" optim_memcpy (x, p, 6);");
935  output_storage (" n += val;");
936  output_storage (" optim_memcpy (p, x, 6);");
937  output_storage ("}");
938  return;
939 
940  case COB_ADD_S48:
941  output_storage ("static COB_INLINE COB_A_INLINE void");
942  output_storage ("cob_add_s48 (void *p, const int val)");
943  output_storage ("{");
944  output_storage (" cob_s64_t n = 0;");
945  output_storage (" unsigned char *x;");
946 
947 #ifdef WORDS_BIGENDIAN
948  output_storage (" x = (unsigned char *)&n;");
949 #else
950  output_storage (" x = ((unsigned char *)&n) + 2;");
951 #endif
952  output_storage (" optim_memcpy (x, p, 6);");
953  output_storage (" n >>= 16; /* Shift with sign */");
954  output_storage (" n += val;");
955 #ifdef WORDS_BIGENDIAN
956  output_storage (" x = ((unsigned char *)&n) + 2;");
957 #else
958  output_storage (" x = (unsigned char *)&n;");
959 #endif
960  output_storage (" optim_memcpy (p, x, 6);");
961  output_storage ("}");
962  return;
963 
964  case COB_ADD_U56:
965  output_storage ("static COB_INLINE COB_A_INLINE void");
966  output_storage ("cob_add_u56 (void *p, const int val)");
967  output_storage ("{");
968  output_storage (" cob_u64_t n = 0;");
969  output_storage (" unsigned char *x;");
970 
971 #ifdef WORDS_BIGENDIAN
972  output_storage (" x = ((unsigned char *)&n) + 1;");
973 #else
974  output_storage (" x = (unsigned char *)&n;");
975 #endif
976  output_storage (" optim_memcpy (x, p, 7);");
977  output_storage (" n += val;");
978  output_storage (" optim_memcpy (p, x, 7);");
979  output_storage ("}");
980  return;
981 
982  case COB_ADD_S56:
983  output_storage ("static COB_INLINE COB_A_INLINE void");
984  output_storage ("cob_add_s56 (void *p, const int val)");
985  output_storage ("{");
986  output_storage (" cob_s64_t n = 0;");
987  output_storage (" unsigned char *x;");
988 
989 #ifdef WORDS_BIGENDIAN
990  output_storage (" x = (unsigned char *)&n;");
991 #else
992  output_storage (" x = ((unsigned char *)&n) + 1;");
993 #endif
994  output_storage (" optim_memcpy (x, p, 7);");
995  output_storage (" n >>= 8; /* Shift with sign */");
996  output_storage (" n += val;");
997 #ifdef WORDS_BIGENDIAN
998  output_storage (" x = ((unsigned char *)&n) + 1;");
999 #else
1000  output_storage (" x = (unsigned char *)&n;");
1001 #endif
1002  output_storage (" optim_memcpy (p, x, 7);");
1003  output_storage ("}");
1004  return;
1005 
1006  case COB_ADD_U64:
1007  output_storage ("static COB_INLINE COB_A_INLINE void");
1008  output_storage ("cob_add_u64 (void *p, const int val)");
1009  output_storage ("{");
1010 #ifdef COB_ALLOW_UNALIGNED
1011  output_storage (" *(cob_u64_t __unaligned *)p += val;");
1012 #else
1013  output_storage (" void *x;");
1014  output_storage (" cob_u64_t n;");
1015 
1016  output_storage (" x = &n;");
1017  output_storage (" optim_memcpy (x, p, 8);");
1018  output_storage (" n += val;");
1019  output_storage (" optim_memcpy (p, x, 8);");
1020 #endif
1021  output_storage ("}");
1022  return;
1023 
1024  case COB_ADD_S64:
1025  output_storage ("static COB_INLINE COB_A_INLINE void");
1026  output_storage ("cob_add_s64 (void *p, const int val)");
1027  output_storage ("{");
1028 #ifdef COB_ALLOW_UNALIGNED
1029  output_storage (" *(cob_s64_t __unaligned *)p += val;");
1030 #else
1031  output_storage (" void *x;");
1032  output_storage (" cob_s64_t n;");
1033 
1034  output_storage (" x = &n;");
1035  output_storage (" optim_memcpy (x, p, 8);");
1036  output_storage (" n += val;");
1037  output_storage (" optim_memcpy (p, x, 8);");
1038 #endif
1039  output_storage ("}");
1040  return;
1041 
1042  case COB_SUB_U8:
1043  output_storage ("static COB_INLINE COB_A_INLINE void");
1044  output_storage ("cob_sub_u8 (void *p, const int val)");
1045  output_storage ("{");
1046  output_storage (" *(unsigned char *)p -= val;");
1047  output_storage ("}");
1048  return;
1049 
1050  case COB_SUB_S8:
1051  output_storage ("static COB_INLINE COB_A_INLINE void");
1052  output_storage ("cob_sub_s8 (void *p, const int val)");
1053  output_storage ("{");
1054  output_storage (" *(signed char *)p -= val;");
1055  output_storage ("}");
1056  return;
1057 
1058  case COB_SUB_U16:
1059  output_storage ("static COB_INLINE COB_A_INLINE void");
1060  output_storage ("cob_sub_u16 (void *p, const int val)");
1061  output_storage ("{");
1062 #ifdef COB_ALLOW_UNALIGNED
1063  output_storage (" *(unsigned short __unaligned *)p -= val;");
1064 #else
1065  output_storage (" void *x;");
1066  output_storage (" unsigned short n;");
1067 
1068  output_storage (" x = &n;");
1069  output_storage (" optim_memcpy (x, p, 2);");
1070  output_storage (" n -= val;");
1071  output_storage (" optim_memcpy (p, x, 2);");
1072 #endif
1073  output_storage ("}");
1074  return;
1075 
1076  case COB_SUB_S16:
1077  output_storage ("static COB_INLINE COB_A_INLINE void");
1078  output_storage ("cob_sub_s16 (void *p, const int val)");
1079  output_storage ("{");
1080 #ifdef COB_ALLOW_UNALIGNED
1081  output_storage (" *(short __unaligned *)p -= val;");
1082 #else
1083  output_storage (" void *x;");
1084  output_storage (" short n;");
1085 
1086  output_storage (" x = &n;");
1087  output_storage (" optim_memcpy (x, p, 2);");
1088  output_storage (" n -= val;");
1089  output_storage (" optim_memcpy (p, x, 2);");
1090 #endif
1091  output_storage ("}");
1092  return;
1093 
1094  case COB_SUB_U24:
1095  output_storage ("static COB_INLINE COB_A_INLINE void");
1096  output_storage ("cob_sub_u24 (void *p, const int val)");
1097  output_storage ("{");
1098  output_storage (" unsigned char *x;");
1099  output_storage (" unsigned int n = 0;");
1100 
1101 #ifdef WORDS_BIGENDIAN
1102  output_storage (" x = ((unsigned char *)&n) + 1;");
1103 #else
1104  output_storage (" x = (unsigned char *)&n;");
1105 #endif
1106  output_storage (" optim_memcpy (x, p, 3);");
1107  output_storage (" n -= val;");
1108  output_storage (" optim_memcpy (p, x, 3);");
1109  output_storage ("}");
1110  return;
1111 
1112  case COB_SUB_S24:
1113  output_storage ("static COB_INLINE COB_A_INLINE void");
1114  output_storage ("cob_sub_s24 (void *p, const int val)");
1115  output_storage ("{");
1116  output_storage (" unsigned char *x;");
1117  output_storage (" int n = 0;");
1118 
1119 #ifdef WORDS_BIGENDIAN
1120  output_storage (" x = (unsigned char *)&n;");
1121 #else
1122  output_storage (" x = ((unsigned char *)&n) + 1;");
1123 #endif
1124  output_storage (" optim_memcpy (x, p, 3);");
1125  output_storage (" n >>= 8; /* Shift with sign */");
1126  output_storage (" n -= val;");
1127 #ifdef WORDS_BIGENDIAN
1128  output_storage (" x = ((unsigned char *)&n) + 1;");
1129 #else
1130  output_storage (" x = (unsigned char *)&n;");
1131 #endif
1132  output_storage (" optim_memcpy (p, x, 3);");
1133  output_storage ("}");
1134  return;
1135 
1136  case COB_SUB_U32:
1137  output_storage ("static COB_INLINE COB_A_INLINE void");
1138  output_storage ("cob_sub_u32 (void *p, const int val)");
1139  output_storage ("{");
1140 #ifdef COB_ALLOW_UNALIGNED
1141  output_storage (" *(unsigned int __unaligned *)p -= val;");
1142 #else
1143  output_storage (" void *x;");
1144  output_storage (" unsigned int n;");
1145 
1146  output_storage (" x = &n;");
1147  output_storage (" optim_memcpy (x, p, 4);");
1148  output_storage (" n -= val;");
1149  output_storage (" optim_memcpy (p, x, 4);");
1150 #endif
1151  output_storage ("}");
1152  return;
1153 
1154  case COB_SUB_S32:
1155  output_storage ("static COB_INLINE COB_A_INLINE void");
1156  output_storage ("cob_sub_s32 (void *p, const int val)");
1157  output_storage ("{");
1158 #ifdef COB_ALLOW_UNALIGNED
1159  output_storage (" *(int __unaligned *)p -= val;");
1160 #else
1161  output_storage (" void *x;");
1162  output_storage (" int n;");
1163 
1164  output_storage (" x = &n;");
1165  output_storage (" optim_memcpy (x, p, 4);");
1166  output_storage (" n -= val;");
1167  output_storage (" optim_memcpy (p, x, 4);");
1168 #endif
1169  output_storage ("}");
1170  return;
1171 
1172  case COB_SUB_U40:
1173  output_storage ("static COB_INLINE COB_A_INLINE void");
1174  output_storage ("cob_sub_u40 (void *p, const int val)");
1175  output_storage ("{");
1176  output_storage (" cob_u64_t n = 0;");
1177  output_storage (" unsigned char *x;");
1178 
1179 #ifdef WORDS_BIGENDIAN
1180  output_storage (" x = ((unsigned char *)&n) + 3;");
1181 #else
1182  output_storage (" x = (unsigned char *)&n;");
1183 #endif
1184  output_storage (" optim_memcpy (x, p, 5);");
1185  output_storage (" n -= val;");
1186  output_storage (" optim_memcpy (p, x, 5);");
1187  output_storage ("}");
1188  return;
1189 
1190  case COB_SUB_S40:
1191  output_storage ("static COB_INLINE COB_A_INLINE void");
1192  output_storage ("cob_sub_s40 (void *p, const int val)");
1193  output_storage ("{");
1194  output_storage (" cob_s64_t n = 0;");
1195  output_storage (" unsigned char *x;");
1196 
1197 #ifdef WORDS_BIGENDIAN
1198  output_storage (" x = (unsigned char *)&n;");
1199 #else
1200  output_storage (" x = ((unsigned char *)&n) + 3;");
1201 #endif
1202  output_storage (" optim_memcpy (x, p, 5);");
1203  output_storage (" n >>= 24; /* Shift with sign */");
1204  output_storage (" n -= val;");
1205 #ifdef WORDS_BIGENDIAN
1206  output_storage (" x = ((unsigned char *)&n) + 3;");
1207 #else
1208  output_storage (" x = (unsigned char *)&n;");
1209 #endif
1210  output_storage (" optim_memcpy (p, x, 5);");
1211  output_storage ("}");
1212  return;
1213 
1214  case COB_SUB_U48:
1215  output_storage ("static COB_INLINE COB_A_INLINE void");
1216  output_storage ("cob_sub_u48 (void *p, const int val)");
1217  output_storage ("{");
1218  output_storage (" cob_u64_t n = 0;");
1219  output_storage (" unsigned char *x;");
1220 
1221 #ifdef WORDS_BIGENDIAN
1222  output_storage (" x = ((unsigned char *)&n) + 2;");
1223 #else
1224  output_storage (" x = (unsigned char *)&n;");
1225 #endif
1226  output_storage (" optim_memcpy (x, p, 6);");
1227  output_storage (" n -= val;");
1228  output_storage (" optim_memcpy (p, x, 6);");
1229  output_storage ("}");
1230  return;
1231 
1232  case COB_SUB_S48:
1233  output_storage ("static COB_INLINE COB_A_INLINE void");
1234  output_storage ("cob_sub_s48 (void *p, const int val)");
1235  output_storage ("{");
1236  output_storage (" cob_s64_t n = 0;");
1237  output_storage (" unsigned char *x;");
1238 
1239 #ifdef WORDS_BIGENDIAN
1240  output_storage (" x = (unsigned char *)&n;");
1241 #else
1242  output_storage (" x = ((unsigned char *)&n) + 2;");
1243 #endif
1244  output_storage (" optim_memcpy (x, p, 6);");
1245  output_storage (" n >>= 16; /* Shift with sign */");
1246  output_storage (" n -= val;");
1247 #ifdef WORDS_BIGENDIAN
1248  output_storage (" x = ((unsigned char *)&n) + 2;");
1249 #else
1250  output_storage (" x = (unsigned char *)&n;");
1251 #endif
1252  output_storage (" optim_memcpy (p, x, 6);");
1253  output_storage ("}");
1254  return;
1255 
1256  case COB_SUB_U56:
1257  output_storage ("static COB_INLINE COB_A_INLINE void");
1258  output_storage ("cob_sub_u56 (void *p, const int val)");
1259  output_storage ("{");
1260  output_storage (" cob_u64_t n = 0;");
1261  output_storage (" unsigned char *x;");
1262 
1263 #ifdef WORDS_BIGENDIAN
1264  output_storage (" x = ((unsigned char *)&n) + 1;");
1265 #else
1266  output_storage (" x = (unsigned char *)&n;");
1267 #endif
1268  output_storage (" optim_memcpy (x, p, 7);");
1269  output_storage (" n -= val;");
1270  output_storage (" optim_memcpy (p, x, 7);");
1271  output_storage ("}");
1272  return;
1273 
1274  case COB_SUB_S56:
1275  output_storage ("static COB_INLINE COB_A_INLINE void");
1276  output_storage ("cob_sub_s56 (void *p, const int val)");
1277  output_storage ("{");
1278  output_storage (" cob_s64_t n = 0;");
1279  output_storage (" unsigned char *x;");
1280 
1281 #ifdef WORDS_BIGENDIAN
1282  output_storage (" x = (unsigned char *)&n;");
1283 #else
1284  output_storage (" x = ((unsigned char *)&n) + 1;");
1285 #endif
1286  output_storage (" optim_memcpy (x, p, 7);");
1287  output_storage (" n >>= 8; /* Shift with sign */");
1288  output_storage (" n -= val;");
1289 #ifdef WORDS_BIGENDIAN
1290  output_storage (" x = ((unsigned char *)&n) + 1;");
1291 #else
1292  output_storage (" x = (unsigned char *)&n;");
1293 #endif
1294  output_storage (" optim_memcpy (p, x, 7);");
1295  output_storage ("}");
1296  return;
1297 
1298  case COB_SUB_U64:
1299  output_storage ("static COB_INLINE COB_A_INLINE void");
1300  output_storage ("cob_sub_u64 (void *p, const int val)");
1301  output_storage ("{");
1302 #ifdef COB_ALLOW_UNALIGNED
1303  output_storage (" *(cob_u64_t __unaligned *)p -= val;");
1304 #else
1305  output_storage (" void *x;");
1306  output_storage (" cob_u64_t n;");
1307 
1308  output_storage (" x = &n;");
1309  output_storage (" optim_memcpy (x, p, 8);");
1310  output_storage (" n -= val;");
1311  output_storage (" optim_memcpy (p, x, 8);");
1312 #endif
1313  output_storage ("}");
1314  return;
1315 
1316  case COB_SUB_S64:
1317  output_storage ("static COB_INLINE COB_A_INLINE void");
1318  output_storage ("cob_sub_s64 (void *p, const int val)");
1319  output_storage ("{");
1320 #ifdef COB_ALLOW_UNALIGNED
1321  output_storage (" *(cob_s64_t __unaligned *)p -= val;");
1322 #else
1323  output_storage (" void *x;");
1324  output_storage (" cob_s64_t n;");
1325 
1326  output_storage (" x = &n;");
1327  output_storage (" optim_memcpy (x, p, 8);");
1328  output_storage (" n -= val;");
1329  output_storage (" optim_memcpy (p, x, 8);");
1330 #endif
1331  output_storage ("}");
1332  return;
1333 
1334  /* Binary swapped compare */
1335 
1336  case COB_CMPSWP_U16:
1337  output_storage ("static COB_INLINE COB_A_INLINE int");
1338  output_storage ("cob_cmpswp_u16 (const void *p, const cob_s64_t n)");
1339  output_storage ("{");
1340 #ifndef COB_ALLOW_UNALIGNED
1341  output_storage (" void *x;");
1342 #endif
1343  output_storage (" unsigned short val;");
1344 
1345  output_storage (" if (unlikely(n < 0)) {");
1346  output_storage (" return 1;");
1347  output_storage (" }");
1348 #ifdef COB_ALLOW_UNALIGNED
1349  output_storage (" val = COB_BSWAP_16 (*(unsigned short __unaligned *)p);");
1350 #else
1351  output_storage (" x = &val;");
1352  output_storage (" optim_memcpy (x, p, 2);");
1353  output_storage (" val = COB_BSWAP_16 (val);");
1354 #endif
1355  output_storage (" return (val < n) ? -1 : (val > n);");
1356  output_storage ("}");
1357  return;
1358 
1359  case COB_CMPSWP_S16:
1360  output_storage ("static COB_INLINE COB_A_INLINE int");
1361  output_storage ("cob_cmpswp_s16 (const void *p, const cob_s64_t n)");
1362  output_storage ("{");
1363  output_storage (" short val;");
1364 
1365 #ifdef COB_ALLOW_UNALIGNED
1366  output_storage (" val = COB_BSWAP_16 (*(short __unaligned *)p);");
1367 #else
1368  output_storage (" void *x;");
1369 
1370  output_storage (" x = &val;");
1371  output_storage (" optim_memcpy (x, p, 2);");
1372  output_storage (" val = COB_BSWAP_16 (val);");
1373 #endif
1374  output_storage (" return (val < n) ? -1 : (val > n);");
1375  output_storage ("}");
1376  return;
1377 
1378  case COB_CMPSWP_U24:
1379  output_storage ("static COB_INLINE COB_A_INLINE int");
1380  output_storage ("cob_cmpswp_u24 (const void *p, const cob_s64_t n)");
1381  output_storage ("{");
1382  output_storage (" unsigned char *x;");
1383  output_storage (" unsigned int val = 0;");
1384 
1385  output_storage (" if (unlikely(n < 0)) {");
1386  output_storage (" return 1;");
1387  output_storage (" }");
1388  output_storage (" x = ((unsigned char *)&val) + 1;");
1389  output_storage (" optim_memcpy (x, p, 3);");
1390  output_storage (" val = COB_BSWAP_32 (val);");
1391  output_storage (" return (val < n) ? -1 : (val > n);");
1392  output_storage ("}");
1393  return;
1394 
1395  case COB_CMPSWP_S24:
1396  output_storage ("static COB_INLINE COB_A_INLINE int");
1397  output_storage ("cob_cmpswp_s24 (const void *p, const cob_s64_t n)");
1398  output_storage ("{");
1399  output_storage (" unsigned char *x;");
1400  output_storage (" int val = 0;");
1401 
1402  output_storage (" x = (unsigned char *)&val;");
1403  output_storage (" optim_memcpy (x, p, 3);");
1404  output_storage (" val = COB_BSWAP_32 (val);");
1405  output_storage (" val >>= 8; /* Shift with sign */");
1406  output_storage (" return (val < n) ? -1 : (val > n);");
1407  output_storage ("}");
1408  return;
1409 
1410  case COB_CMPSWP_U32:
1411  output_storage ("static COB_INLINE COB_A_INLINE int");
1412  output_storage ("cob_cmpswp_u32 (const void *p, const cob_s64_t n)");
1413  output_storage ("{");
1414 #ifndef COB_ALLOW_UNALIGNED
1415  output_storage (" void *x;");
1416 #endif
1417  output_storage (" unsigned int val;");
1418 
1419  output_storage (" if (unlikely(n < 0)) {");
1420  output_storage (" return 1;");
1421  output_storage (" }");
1422 #ifdef COB_ALLOW_UNALIGNED
1423  output_storage (" val = COB_BSWAP_32 (*(const unsigned int __unaligned *)p);");
1424 #else
1425  output_storage (" x = &val;");
1426  output_storage (" optim_memcpy (x, p, 4);");
1427  output_storage (" val = COB_BSWAP_32 (val);");
1428 #endif
1429  output_storage (" return (val < n) ? -1 : (val > n);");
1430  output_storage ("}");
1431  return;
1432 
1433  case COB_CMPSWP_S32:
1434  output_storage ("static COB_INLINE COB_A_INLINE int");
1435  output_storage ("cob_cmpswp_s32 (const void *p, const cob_s64_t n)");
1436  output_storage ("{");
1437  output_storage (" int val;");
1438 
1439 #ifdef COB_ALLOW_UNALIGNED
1440  output_storage (" val = COB_BSWAP_32 (*(const int __unaligned *)p);");
1441 #else
1442  output_storage (" void *x;");
1443 
1444  output_storage (" x = &val;");
1445  output_storage (" optim_memcpy (x, p, 4);");
1446  output_storage (" val = COB_BSWAP_32 (val);");
1447 #endif
1448  output_storage (" return (val < n) ? -1 : (val > n);");
1449  output_storage ("}");
1450  return;
1451 
1452  case COB_CMPSWP_U40:
1453  output_storage ("static COB_INLINE COB_A_INLINE int");
1454  output_storage ("cob_cmpswp_u40 (const void *p, const cob_s64_t n)");
1455  output_storage ("{");
1456  output_storage (" cob_u64_t val = 0;");
1457  output_storage (" unsigned char *x;");
1458 
1459  output_storage (" if (unlikely(n < 0)) {");
1460  output_storage (" return 1;");
1461  output_storage (" }");
1462  output_storage (" x = ((unsigned char *)&val) + 3;");
1463  output_storage (" optim_memcpy (x, p, 5);");
1464  output_storage (" val = COB_BSWAP_64 (val);");
1465  output_storage (" return (val < n) ? -1 : (val > n);");
1466  output_storage ("}");
1467  return;
1468 
1469  case COB_CMPSWP_S40:
1470  output_storage ("static COB_INLINE COB_A_INLINE int");
1471  output_storage ("cob_cmpswp_s40 (const void *p, const cob_s64_t n)");
1472  output_storage ("{");
1473  output_storage (" cob_s64_t val = 0;");
1474  output_storage (" unsigned char *x;");
1475 
1476  output_storage (" x = (unsigned char *)&val;");
1477  output_storage (" optim_memcpy (x, p, 5);");
1478  output_storage (" val = COB_BSWAP_64 (val);");
1479  output_storage (" val >>= 24; /* Shift with sign */");
1480  output_storage (" return (val < n) ? -1 : (val > n);");
1481  output_storage ("}");
1482  return;
1483 
1484  case COB_CMPSWP_U48:
1485  output_storage ("static COB_INLINE COB_A_INLINE int");
1486  output_storage ("cob_cmpswp_u48 (const void *p, const cob_s64_t n)");
1487  output_storage ("{");
1488  output_storage (" cob_u64_t val = 0;");
1489  output_storage (" unsigned char *x;");
1490 
1491  output_storage (" if (unlikely(n < 0)) {");
1492  output_storage (" return 1;");
1493  output_storage (" }");
1494  output_storage (" x = ((unsigned char *)&val) + 2;");
1495  output_storage (" optim_memcpy (x, p, 6);");
1496  output_storage (" val = COB_BSWAP_64 (val);");
1497  output_storage (" return (val < n) ? -1 : (val > n);");
1498  output_storage ("}");
1499  return;
1500 
1501  case COB_CMPSWP_S48:
1502  output_storage ("static COB_INLINE COB_A_INLINE int");
1503  output_storage ("cob_cmpswp_s48 (const void *p, const cob_s64_t n)");
1504  output_storage ("{");
1505  output_storage (" cob_s64_t val = 0;");
1506  output_storage (" unsigned char *x;");
1507 
1508  output_storage (" x = (unsigned char *)&val;");
1509  output_storage (" optim_memcpy (x, p, 6);");
1510  output_storage (" val = COB_BSWAP_64 (val);");
1511  output_storage (" val >>= 16; /* Shift with sign */");
1512  output_storage (" return (val < n) ? -1 : (val > n);");
1513  output_storage ("}");
1514  return;
1515 
1516  case COB_CMPSWP_U56:
1517  output_storage ("static COB_INLINE COB_A_INLINE int");
1518  output_storage ("cob_cmpswp_u56 (const void *p, const cob_s64_t n)");
1519  output_storage ("{");
1520  output_storage (" cob_u64_t val = 0;");
1521  output_storage (" unsigned char *x;");
1522 
1523  output_storage (" if (unlikely(n < 0)) {");
1524  output_storage (" return 1;");
1525  output_storage (" }");
1526  output_storage (" x = ((unsigned char *)&val) + 1;");
1527  output_storage (" optim_memcpy (x, p, 7);");
1528  output_storage (" val = COB_BSWAP_64 (val);");
1529  output_storage (" return (val < n) ? -1 : (val > n);");
1530  output_storage ("}");
1531  return;
1532 
1533  case COB_CMPSWP_S56:
1534  output_storage ("static COB_INLINE COB_A_INLINE int");
1535  output_storage ("cob_cmpswp_s56 (const void *p, const cob_s64_t n)");
1536  output_storage ("{");
1537  output_storage (" cob_s64_t val = 0;");
1538  output_storage (" unsigned char *x;");
1539 
1540  output_storage (" x = (unsigned char *)&val;");
1541  output_storage (" optim_memcpy (x, p, 7);");
1542  output_storage (" val = COB_BSWAP_64 (val);");
1543  output_storage (" val >>= 8; /* Shift with sign */");
1544  output_storage (" return (val < n) ? -1 : (val > n);");
1545  output_storage ("}");
1546  return;
1547 
1548  case COB_CMPSWP_U64:
1549  output_storage ("static COB_INLINE COB_A_INLINE int");
1550  output_storage ("cob_cmpswp_u64 (const void *p, const cob_s64_t n)");
1551  output_storage ("{");
1552 #ifndef COB_ALLOW_UNALIGNED
1553  output_storage (" void *x;");
1554 #endif
1555  output_storage (" cob_u64_t val;");
1556 
1557  output_storage (" if (unlikely(n < 0)) {");
1558  output_storage (" return 1;");
1559  output_storage (" }");
1560 #ifdef COB_ALLOW_UNALIGNED
1561  output_storage (" val = COB_BSWAP_64 (*(const cob_u64_t __unaligned *)p);");
1562 #else
1563  output_storage (" x = &val;");
1564  output_storage (" optim_memcpy (x, p, 8);");
1565  output_storage (" val = COB_BSWAP_64 (val);");
1566 #endif
1567  output_storage (" return (val < n) ? -1 : (val > n);");
1568  output_storage ("}");
1569  return;
1570 
1571  case COB_CMPSWP_S64:
1572  output_storage ("static COB_INLINE COB_A_INLINE int");
1573  output_storage ("cob_cmpswp_s64 (const void *p, const cob_s64_t n)");
1574  output_storage ("{");
1575  output_storage (" cob_s64_t val;");
1576 
1577 #ifdef COB_ALLOW_UNALIGNED
1578  output_storage (" val = COB_BSWAP_64 (*(const cob_s64_t __unaligned *)p);");
1579 #else
1580  output_storage (" void *x;");
1581  output_storage (" x = &val;");
1582  output_storage (" optim_memcpy (x, p, 8);");
1583  output_storage (" val = COB_BSWAP_64 (val);");
1584 #endif
1585  output_storage (" return (val < n) ? -1 : (val > n);");
1586  output_storage ("}");
1587  return;
1588 
1589  /* Binary swapped add */
1590 
1591  case COB_ADDSWP_U16:
1592  output_storage ("static COB_INLINE COB_A_INLINE void");
1593  output_storage ("cob_addswp_u16 (void *p, const int val)");
1594  output_storage ("{");
1595  output_storage (" unsigned short n;");
1596 
1597 #ifdef COB_ALLOW_UNALIGNED
1598  output_storage (" n = COB_BSWAP_16 (*(unsigned short __unaligned *)p);");
1599  output_storage (" n += val;");
1600  output_storage (" *(unsigned short __unaligned *)p = COB_BSWAP_16(n);");
1601 #else
1602  output_storage (" unsigned char *x;");
1603  output_storage (" unsigned char *px = p;");
1604 
1605  output_storage (" x = (unsigned char *)&n;");
1606  output_storage (" x[0] = px[1];");
1607  output_storage (" x[1] = px[0];");
1608  output_storage (" n += val;");
1609  output_storage (" px[0] = x[1];");
1610  output_storage (" px[1] = x[0];");
1611 #endif
1612  output_storage ("}");
1613  return;
1614 
1615  case COB_ADDSWP_S16:
1616  output_storage ("static COB_INLINE COB_A_INLINE void");
1617  output_storage ("cob_addswp_s16 (void *p, const int val)");
1618  output_storage ("{");
1619  output_storage (" short n;");
1620 
1621 #ifdef COB_ALLOW_UNALIGNED
1622  output_storage (" n = COB_BSWAP_16 (*(short __unaligned *)p);");
1623  output_storage (" n += val;");
1624  output_storage (" *(short __unaligned *)p = COB_BSWAP_16(n);");
1625 #else
1626  output_storage (" unsigned char *x;");
1627  output_storage (" unsigned char *px = p;");
1628 
1629  output_storage (" x = (unsigned char *)&n;");
1630  output_storage (" x[0] = px[1];");
1631  output_storage (" x[1] = px[0];");
1632  output_storage (" n += val;");
1633  output_storage (" px[0] = x[1];");
1634  output_storage (" px[1] = x[0];");
1635 #endif
1636  output_storage ("}");
1637  return;
1638 
1639  case COB_ADDSWP_U24:
1640  output_storage ("static COB_INLINE COB_A_INLINE void");
1641  output_storage ("cob_addswp_u24 (void *p, const int val)");
1642  output_storage ("{");
1643  output_storage (" unsigned char *x;");
1644  output_storage (" unsigned char *px = p;");
1645  output_storage (" unsigned int n = 0;");
1646 
1647  output_storage (" x = (unsigned char *)&n;");
1648  output_storage (" x[0] = px[2];");
1649  output_storage (" x[1] = px[1];");
1650  output_storage (" x[2] = px[0];");
1651  output_storage (" n += val;");
1652  output_storage (" px[0] = x[2];");
1653  output_storage (" px[1] = x[1];");
1654  output_storage (" px[2] = x[0];");
1655  output_storage ("}");
1656  return;
1657 
1658  case COB_ADDSWP_S24:
1659  output_storage ("static COB_INLINE COB_A_INLINE void");
1660  output_storage ("cob_addswp_s24 (void *p, const int val)");
1661  output_storage ("{");
1662  output_storage (" unsigned char *x;");
1663  output_storage (" unsigned char *px = p;");
1664  output_storage (" int n = 0;");
1665 
1666  output_storage (" x = ((unsigned char *)&n) + 1;");
1667  output_storage (" x[0] = px[2];");
1668  output_storage (" x[1] = px[1];");
1669  output_storage (" x[2] = px[0];");
1670  output_storage (" n >>= 8; /* Shift with sign */");
1671  output_storage (" n += val;");
1672  output_storage (" x = (unsigned char *)&n;");
1673  output_storage (" px[0] = x[2];");
1674  output_storage (" px[1] = x[1];");
1675  output_storage (" px[2] = x[0];");
1676  output_storage ("}");
1677  return;
1678 
1679  case COB_ADDSWP_U32:
1680  output_storage ("static COB_INLINE COB_A_INLINE void");
1681  output_storage ("cob_addswp_u32 (void *p, const int val)");
1682  output_storage ("{");
1683  output_storage (" unsigned int n;");
1684 
1685 #ifdef COB_ALLOW_UNALIGNED
1686  output_storage (" n = COB_BSWAP_32 (*(unsigned int __unaligned *)p);");
1687  output_storage (" n += val;");
1688  output_storage (" *(unsigned int __unaligned *)p = COB_BSWAP_32(n);");
1689 #else
1690  output_storage (" unsigned char *x;");
1691  output_storage (" unsigned char *px = p;");
1692 
1693  output_storage (" x = (unsigned char *)&n;");
1694  output_storage (" x[0] = px[3];");
1695  output_storage (" x[1] = px[2];");
1696  output_storage (" x[2] = px[1];");
1697  output_storage (" x[3] = px[0];");
1698  output_storage (" n += val;");
1699  output_storage (" px[0] = x[3];");
1700  output_storage (" px[1] = x[2];");
1701  output_storage (" px[2] = x[1];");
1702  output_storage (" px[3] = x[0];");
1703 #endif
1704  output_storage ("}");
1705  return;
1706 
1707  case COB_ADDSWP_S32:
1708  output_storage ("static COB_INLINE COB_A_INLINE void");
1709  output_storage ("cob_addswp_s32 (void *p, const int val)");
1710  output_storage ("{");
1711  output_storage (" int n;");
1712 
1713 #ifdef COB_ALLOW_UNALIGNED
1714  output_storage (" n = COB_BSWAP_32 (*(int __unaligned *)p);");
1715  output_storage (" n += val;");
1716  output_storage (" *(int __unaligned *)p = COB_BSWAP_32(n);");
1717 #else
1718  output_storage (" unsigned char *x;");
1719  output_storage (" unsigned char *px = p;");
1720 
1721  output_storage (" x = (unsigned char *)&n;");
1722  output_storage (" x[0] = px[3];");
1723  output_storage (" x[1] = px[2];");
1724  output_storage (" x[2] = px[1];");
1725  output_storage (" x[3] = px[0];");
1726  output_storage (" n += val;");
1727  output_storage (" px[0] = x[3];");
1728  output_storage (" px[1] = x[2];");
1729  output_storage (" px[2] = x[1];");
1730  output_storage (" px[3] = x[0];");
1731 #endif
1732  output_storage ("}");
1733  return;
1734 
1735  case COB_ADDSWP_U40:
1736  output_storage ("static COB_INLINE COB_A_INLINE void");
1737  output_storage ("cob_addswp_u40 (void *p, const int val)");
1738  output_storage ("{");
1739  output_storage (" cob_u64_t n = 0;");
1740  output_storage (" unsigned char *x;");
1741  output_storage (" unsigned char *px = p;");
1742 
1743  output_storage (" x = (unsigned char *)&n;");
1744  output_storage (" x[0] = px[4];");
1745  output_storage (" x[1] = px[3];");
1746  output_storage (" x[2] = px[2];");
1747  output_storage (" x[3] = px[1];");
1748  output_storage (" x[4] = px[0];");
1749  output_storage (" n += val;");
1750  output_storage (" px[0] = x[4];");
1751  output_storage (" px[1] = x[3];");
1752  output_storage (" px[2] = x[2];");
1753  output_storage (" px[3] = x[1];");
1754  output_storage (" px[4] = x[0];");
1755  output_storage ("}");
1756  return;
1757 
1758  case COB_ADDSWP_S40:
1759  output_storage ("static COB_INLINE COB_A_INLINE void");
1760  output_storage ("cob_addswp_s40 (void *p, const int val)");
1761  output_storage ("{");
1762  output_storage (" cob_s64_t n = 0;");
1763  output_storage (" unsigned char *x;");
1764  output_storage (" unsigned char *px = p;");
1765 
1766  output_storage (" x = ((unsigned char *)&n) + 3;");
1767  output_storage (" x[0] = px[4];");
1768  output_storage (" x[1] = px[3];");
1769  output_storage (" x[2] = px[2];");
1770  output_storage (" x[3] = px[1];");
1771  output_storage (" x[4] = px[0];");
1772  output_storage (" n >>= 24; /* Shift with sign */");
1773  output_storage (" n += val;");
1774  output_storage (" x = (unsigned char *)&n;");
1775  output_storage (" px[0] = x[4];");
1776  output_storage (" px[1] = x[3];");
1777  output_storage (" px[2] = x[2];");
1778  output_storage (" px[3] = x[1];");
1779  output_storage (" px[4] = x[0];");
1780  output_storage ("}");
1781  return;
1782 
1783  case COB_ADDSWP_U48:
1784  output_storage ("static COB_INLINE COB_A_INLINE void");
1785  output_storage ("cob_addswp_u48 (void *p, const int val)");
1786  output_storage ("{");
1787  output_storage (" cob_u64_t n = 0;");
1788  output_storage (" unsigned char *x;");
1789  output_storage (" unsigned char *px = p;");
1790 
1791  output_storage (" x = (unsigned char *)&n;");
1792  output_storage (" x[0] = px[5];");
1793  output_storage (" x[1] = px[4];");
1794  output_storage (" x[2] = px[3];");
1795  output_storage (" x[3] = px[2];");
1796  output_storage (" x[4] = px[1];");
1797  output_storage (" x[5] = px[0];");
1798  output_storage (" n += val;");
1799  output_storage (" px[0] = x[5];");
1800  output_storage (" px[1] = x[4];");
1801  output_storage (" px[2] = x[3];");
1802  output_storage (" px[3] = x[2];");
1803  output_storage (" px[4] = x[1];");
1804  output_storage (" px[5] = x[0];");
1805  output_storage ("}");
1806  return;
1807 
1808  case COB_ADDSWP_S48:
1809  output_storage ("static COB_INLINE COB_A_INLINE void");
1810  output_storage ("cob_addswp_s48 (void *p, const int val)");
1811  output_storage ("{");
1812  output_storage (" cob_s64_t n = 0;");
1813  output_storage (" unsigned char *x;");
1814  output_storage (" unsigned char *px = p;");
1815 
1816  output_storage (" x = ((unsigned char *)&n) + 2;");
1817  output_storage (" x[0] = px[5];");
1818  output_storage (" x[1] = px[4];");
1819  output_storage (" x[2] = px[3];");
1820  output_storage (" x[3] = px[2];");
1821  output_storage (" x[4] = px[1];");
1822  output_storage (" x[5] = px[0];");
1823  output_storage (" n >>= 16; /* Shift with sign */");
1824  output_storage (" n += val;");
1825  output_storage (" x = (unsigned char *)&n;");
1826  output_storage (" px[0] = x[5];");
1827  output_storage (" px[1] = x[4];");
1828  output_storage (" px[2] = x[3];");
1829  output_storage (" px[3] = x[2];");
1830  output_storage (" px[4] = x[1];");
1831  output_storage (" px[5] = x[0];");
1832  output_storage ("}");
1833  return;
1834 
1835  case COB_ADDSWP_U56:
1836  output_storage ("static COB_INLINE COB_A_INLINE void");
1837  output_storage ("cob_addswp_u56 (void *p, const int val)");
1838  output_storage ("{");
1839  output_storage (" cob_u64_t n = 0;");
1840  output_storage (" unsigned char *x;");
1841  output_storage (" unsigned char *px = p;");
1842 
1843  output_storage (" x = (unsigned char *)&n;");
1844  output_storage (" x[0] = px[6];");
1845  output_storage (" x[1] = px[5];");
1846  output_storage (" x[2] = px[4];");
1847  output_storage (" x[3] = px[3];");
1848  output_storage (" x[4] = px[2];");
1849  output_storage (" x[5] = px[1];");
1850  output_storage (" x[6] = px[0];");
1851  output_storage (" n += val;");
1852  output_storage (" px[0] = x[6];");
1853  output_storage (" px[1] = x[5];");
1854  output_storage (" px[2] = x[4];");
1855  output_storage (" px[3] = x[3];");
1856  output_storage (" px[4] = x[2];");
1857  output_storage (" px[5] = x[1];");
1858  output_storage (" px[6] = x[0];");
1859  output_storage ("}");
1860  return;
1861 
1862  case COB_ADDSWP_S56:
1863  output_storage ("static COB_INLINE COB_A_INLINE void");
1864  output_storage ("cob_addswp_s56 (void *p, const int val)");
1865  output_storage ("{");
1866  output_storage (" cob_s64_t n = 0;");
1867  output_storage (" unsigned char *x;");
1868  output_storage (" unsigned char *px = p;");
1869 
1870  output_storage (" x = ((unsigned char *)&n) + 1;");
1871  output_storage (" x[0] = px[6];");
1872  output_storage (" x[1] = px[5];");
1873  output_storage (" x[2] = px[4];");
1874  output_storage (" x[3] = px[3];");
1875  output_storage (" x[4] = px[2];");
1876  output_storage (" x[5] = px[1];");
1877  output_storage (" x[6] = px[0];");
1878  output_storage (" n >>= 8; /* Shift with sign */");
1879  output_storage (" n += val;");
1880  output_storage (" x = (unsigned char *)&n;");
1881  output_storage (" px[0] = x[6];");
1882  output_storage (" px[1] = x[5];");
1883  output_storage (" px[2] = x[4];");
1884  output_storage (" px[3] = x[3];");
1885  output_storage (" px[4] = x[2];");
1886  output_storage (" px[5] = x[1];");
1887  output_storage (" px[6] = x[0];");
1888  output_storage ("}");
1889  return;
1890 
1891  case COB_ADDSWP_U64:
1892  output_storage ("static COB_INLINE COB_A_INLINE void");
1893  output_storage ("cob_addswp_u64 (void *p, const int val)");
1894  output_storage ("{");
1895  output_storage (" cob_u64_t n;");
1896 
1897 #ifdef COB_ALLOW_UNALIGNED
1898  output_storage (" n = COB_BSWAP_64 (*(cob_u64_t __unaligned *)p);");
1899  output_storage (" n += val;");
1900  output_storage (" *(cob_u64_t __unaligned *)p = COB_BSWAP_64(n);");
1901 #else
1902  output_storage (" unsigned char *x;");
1903  output_storage (" unsigned char *px = p;");
1904 
1905  output_storage (" x = (unsigned char *)&n;");
1906  output_storage (" x[0] = px[7];");
1907  output_storage (" x[1] = px[6];");
1908  output_storage (" x[2] = px[5];");
1909  output_storage (" x[3] = px[4];");
1910  output_storage (" x[4] = px[3];");
1911  output_storage (" x[5] = px[2];");
1912  output_storage (" x[6] = px[1];");
1913  output_storage (" x[7] = px[0];");
1914  output_storage (" n += val;");
1915  output_storage (" px[0] = x[7];");
1916  output_storage (" px[1] = x[6];");
1917  output_storage (" px[2] = x[5];");
1918  output_storage (" px[3] = x[4];");
1919  output_storage (" px[4] = x[3];");
1920  output_storage (" px[5] = x[2];");
1921  output_storage (" px[6] = x[1];");
1922  output_storage (" px[7] = x[0];");
1923 #endif
1924  output_storage ("}");
1925  return;
1926 
1927  case COB_ADDSWP_S64:
1928  output_storage ("static COB_INLINE COB_A_INLINE void");
1929  output_storage ("cob_addswp_s64 (void *p, const int val)");
1930  output_storage ("{");
1931  output_storage (" cob_s64_t n;");
1932 
1933 #ifdef COB_ALLOW_UNALIGNED
1934  output_storage (" n = COB_BSWAP_64 (*(cob_s64_t __unaligned *)p);");
1935  output_storage (" n += val;");
1936  output_storage (" *(cob_s64_t __unaligned *)p = COB_BSWAP_64(n);");
1937 #else
1938  output_storage (" unsigned char *x;");
1939  output_storage (" unsigned char *px = p;");
1940 
1941  output_storage (" x = (unsigned char *)&n;");
1942  output_storage (" x[0] = px[7];");
1943  output_storage (" x[1] = px[6];");
1944  output_storage (" x[2] = px[5];");
1945  output_storage (" x[3] = px[4];");
1946  output_storage (" x[4] = px[3];");
1947  output_storage (" x[5] = px[2];");
1948  output_storage (" x[6] = px[1];");
1949  output_storage (" x[7] = px[0];");
1950  output_storage (" n += val;");
1951  output_storage (" px[0] = x[7];");
1952  output_storage (" px[1] = x[6];");
1953  output_storage (" px[2] = x[5];");
1954  output_storage (" px[3] = x[4];");
1955  output_storage (" px[4] = x[3];");
1956  output_storage (" px[5] = x[2];");
1957  output_storage (" px[6] = x[1];");
1958  output_storage (" px[7] = x[0];");
1959 #endif
1960  output_storage ("}");
1961  return;
1962 
1963  /* Binary swapped subtract */
1964 
1965  case COB_SUBSWP_U16:
1966  output_storage ("static COB_INLINE COB_A_INLINE void");
1967  output_storage ("cob_subswp_u16 (void *p, const int val)");
1968  output_storage ("{");
1969  output_storage (" unsigned short n;");
1970 
1971 #ifdef COB_ALLOW_UNALIGNED
1972  output_storage (" n = COB_BSWAP_16 (*(unsigned short __unaligned *)p);");
1973  output_storage (" n -= val;");
1974  output_storage (" *(unsigned short __unaligned *)p = COB_BSWAP_16(n);");
1975 #else
1976  output_storage (" unsigned char *x;");
1977  output_storage (" unsigned char *px = p;");
1978 
1979  output_storage (" x = (unsigned char *)&n;");
1980  output_storage (" x[0] = px[1];");
1981  output_storage (" x[1] = px[0];");
1982  output_storage (" n -= val;");
1983  output_storage (" px[0] = x[1];");
1984  output_storage (" px[1] = x[0];");
1985 #endif
1986  output_storage ("}");
1987  return;
1988 
1989  case COB_SUBSWP_S16:
1990  output_storage ("static COB_INLINE COB_A_INLINE void");
1991  output_storage ("cob_subswp_s16 (void *p, const int val)");
1992  output_storage ("{");
1993  output_storage (" short n;");
1994 
1995 #ifdef COB_ALLOW_UNALIGNED
1996  output_storage (" n = COB_BSWAP_16 (*(short __unaligned *)p);");
1997  output_storage (" n -= val;");
1998  output_storage (" *(short __unaligned *)p = COB_BSWAP_16(n);");
1999 #else
2000  output_storage (" unsigned char *x;");
2001  output_storage (" unsigned char *px = p;");
2002 
2003  output_storage (" x = (unsigned char *)&n;");
2004  output_storage (" x[0] = px[1];");
2005  output_storage (" x[1] = px[0];");
2006  output_storage (" n -= val;");
2007  output_storage (" px[0] = x[1];");
2008  output_storage (" px[1] = x[0];");
2009 #endif
2010  output_storage ("}");
2011  return;
2012 
2013  case COB_SUBSWP_U24:
2014  output_storage ("static COB_INLINE COB_A_INLINE void");
2015  output_storage ("cob_subswp_u24 (void *p, const int val)");
2016  output_storage ("{");
2017  output_storage (" unsigned char *x;");
2018  output_storage (" unsigned char *px = p;");
2019  output_storage (" unsigned int n = 0;");
2020 
2021  output_storage (" x = (unsigned char *)&n;");
2022  output_storage (" x[0] = px[2];");
2023  output_storage (" x[1] = px[1];");
2024  output_storage (" x[2] = px[0];");
2025  output_storage (" n -= val;");
2026  output_storage (" px[0] = x[2];");
2027  output_storage (" px[1] = x[1];");
2028  output_storage (" px[2] = x[0];");
2029  output_storage ("}");
2030  return;
2031 
2032  case COB_SUBSWP_S24:
2033  output_storage ("static COB_INLINE COB_A_INLINE void");
2034  output_storage ("cob_subswp_s24 (void *p, const int val)");
2035  output_storage ("{");
2036  output_storage (" unsigned char *x;");
2037  output_storage (" unsigned char *px = p;");
2038  output_storage (" int n = 0;");
2039 
2040  output_storage (" x = ((unsigned char *)&n) + 1;");
2041  output_storage (" x[0] = px[2];");
2042  output_storage (" x[1] = px[1];");
2043  output_storage (" x[2] = px[0];");
2044  output_storage (" n >>= 8; /* Shift with sign */");
2045  output_storage (" n -= val;");
2046  output_storage (" x = (unsigned char *)&n;");
2047  output_storage (" px[0] = x[2];");
2048  output_storage (" px[1] = x[1];");
2049  output_storage (" px[2] = x[0];");
2050  output_storage ("}");
2051  return;
2052 
2053  case COB_SUBSWP_U32:
2054  output_storage ("static COB_INLINE COB_A_INLINE void");
2055  output_storage ("cob_subswp_u32 (void *p, const int val)");
2056  output_storage ("{");
2057  output_storage (" unsigned int n;");
2058 
2059 #ifdef COB_ALLOW_UNALIGNED
2060  output_storage (" n = COB_BSWAP_32 (*(unsigned int __unaligned *)p);");
2061  output_storage (" n -= val;");
2062  output_storage (" *(unsigned int __unaligned *)p = COB_BSWAP_32(n);");
2063 #else
2064  output_storage (" unsigned char *x;");
2065  output_storage (" unsigned char *px = p;");
2066 
2067  output_storage (" x = (unsigned char *)&n;");
2068  output_storage (" x[0] = px[3];");
2069  output_storage (" x[1] = px[2];");
2070  output_storage (" x[2] = px[1];");
2071  output_storage (" x[3] = px[0];");
2072  output_storage (" n -= val;");
2073  output_storage (" px[0] = x[3];");
2074  output_storage (" px[1] = x[2];");
2075  output_storage (" px[2] = x[1];");
2076  output_storage (" px[3] = x[0];");
2077 #endif
2078  output_storage ("}");
2079  return;
2080 
2081  case COB_SUBSWP_S32:
2082  output_storage ("static COB_INLINE COB_A_INLINE void");
2083  output_storage ("cob_subswp_s32 (void *p, const int val)");
2084  output_storage ("{");
2085  output_storage (" int n;");
2086 
2087 #ifdef COB_ALLOW_UNALIGNED
2088  output_storage (" n = COB_BSWAP_32 (*(int __unaligned *)p);");
2089  output_storage (" n -= val;");
2090  output_storage (" *(int __unaligned *)p = COB_BSWAP_32(n);");
2091 #else
2092  output_storage (" unsigned char *x;");
2093  output_storage (" unsigned char *px = p;");
2094 
2095  output_storage (" x = (unsigned char *)&n;");
2096  output_storage (" x[0] = px[3];");
2097  output_storage (" x[1] = px[2];");
2098  output_storage (" x[2] = px[1];");
2099  output_storage (" x[3] = px[0];");
2100  output_storage (" n -= val;");
2101  output_storage (" px[0] = x[3];");
2102  output_storage (" px[1] = x[2];");
2103  output_storage (" px[2] = x[1];");
2104  output_storage (" px[3] = x[0];");
2105 #endif
2106  output_storage ("}");
2107  return;
2108 
2109  case COB_SUBSWP_U40:
2110  output_storage ("static COB_INLINE COB_A_INLINE void");
2111  output_storage ("cob_subswp_u40 (void *p, const int val)");
2112  output_storage ("{");
2113  output_storage (" cob_u64_t n = 0;");
2114  output_storage (" unsigned char *x;");
2115  output_storage (" unsigned char *px = p;");
2116 
2117  output_storage (" x = (unsigned char *)&n;");
2118  output_storage (" x[0] = px[4];");
2119  output_storage (" x[1] = px[3];");
2120  output_storage (" x[2] = px[2];");
2121  output_storage (" x[3] = px[1];");
2122  output_storage (" x[4] = px[0];");
2123  output_storage (" n -= val;");
2124  output_storage (" px[0] = x[4];");
2125  output_storage (" px[1] = x[3];");
2126  output_storage (" px[2] = x[2];");
2127  output_storage (" px[3] = x[1];");
2128  output_storage (" px[4] = x[0];");
2129  output_storage ("}");
2130  return;
2131 
2132  case COB_SUBSWP_S40:
2133  output_storage ("static COB_INLINE COB_A_INLINE void");
2134  output_storage ("cob_subswp_s40 (void *p, const int val)");
2135  output_storage ("{");
2136  output_storage (" cob_s64_t n = 0;");
2137  output_storage (" unsigned char *x;");
2138  output_storage (" unsigned char *px = p;");
2139 
2140  output_storage (" x = ((unsigned char *)&n) + 3;");
2141  output_storage (" x[0] = px[4];");
2142  output_storage (" x[1] = px[3];");
2143  output_storage (" x[2] = px[2];");
2144  output_storage (" x[3] = px[1];");
2145  output_storage (" x[4] = px[0];");
2146  output_storage (" n >>= 24; /* Shift with sign */");
2147  output_storage (" n -= val;");
2148  output_storage (" x = (unsigned char *)&n;");
2149  output_storage (" px[0] = x[4];");
2150  output_storage (" px[1] = x[3];");
2151  output_storage (" px[2] = x[2];");
2152  output_storage (" px[3] = x[1];");
2153  output_storage (" px[4] = x[0];");
2154  output_storage ("}");
2155  return;
2156 
2157  case COB_SUBSWP_U48:
2158  output_storage ("static COB_INLINE COB_A_INLINE void");
2159  output_storage ("cob_subswp_u48 (void *p, const int val)");
2160  output_storage ("{");
2161  output_storage (" cob_u64_t n = 0;");
2162  output_storage (" unsigned char *x;");
2163  output_storage (" unsigned char *px = p;");
2164 
2165  output_storage (" x = (unsigned char *)&n;");
2166  output_storage (" x[0] = px[5];");
2167  output_storage (" x[1] = px[4];");
2168  output_storage (" x[2] = px[3];");
2169  output_storage (" x[3] = px[2];");
2170  output_storage (" x[4] = px[1];");
2171  output_storage (" x[5] = px[0];");
2172  output_storage (" n -= val;");
2173  output_storage (" px[0] = x[5];");
2174  output_storage (" px[1] = x[4];");
2175  output_storage (" px[2] = x[3];");
2176  output_storage (" px[3] = x[2];");
2177  output_storage (" px[4] = x[1];");
2178  output_storage (" px[5] = x[0];");
2179  output_storage ("}");
2180  return;
2181 
2182  case COB_SUBSWP_S48:
2183  output_storage ("static COB_INLINE COB_A_INLINE void");
2184  output_storage ("cob_subswp_s48 (void *p, const int val)");
2185  output_storage ("{");
2186  output_storage (" cob_s64_t n = 0;");
2187  output_storage (" unsigned char *x;");
2188  output_storage (" unsigned char *px = p;");
2189 
2190  output_storage (" x = ((unsigned char *)&n) + 2;");
2191  output_storage (" x[0] = px[5];");
2192  output_storage (" x[1] = px[4];");
2193  output_storage (" x[2] = px[3];");
2194  output_storage (" x[3] = px[2];");
2195  output_storage (" x[4] = px[1];");
2196  output_storage (" x[5] = px[0];");
2197  output_storage (" n >>= 16; /* Shift with sign */");
2198  output_storage (" n -= val;");
2199  output_storage (" x = (unsigned char *)&n;");
2200  output_storage (" px[0] = x[5];");
2201  output_storage (" px[1] = x[4];");
2202  output_storage (" px[2] = x[3];");
2203  output_storage (" px[3] = x[2];");
2204  output_storage (" px[4] = x[1];");
2205  output_storage (" px[5] = x[0];");
2206  output_storage ("}");
2207  return;
2208 
2209  case COB_SUBSWP_U56:
2210  output_storage ("static COB_INLINE COB_A_INLINE void");
2211  output_storage ("cob_subswp_u56 (void *p, const int val)");
2212  output_storage ("{");
2213  output_storage (" cob_u64_t n = 0;");
2214  output_storage (" unsigned char *x;");
2215  output_storage (" unsigned char *px = p;");
2216 
2217  output_storage (" x = (unsigned char *)&n;");
2218  output_storage (" x[0] = px[6];");
2219  output_storage (" x[1] = px[5];");
2220  output_storage (" x[2] = px[4];");
2221  output_storage (" x[3] = px[3];");
2222  output_storage (" x[4] = px[2];");
2223  output_storage (" x[5] = px[1];");
2224  output_storage (" x[6] = px[0];");
2225  output_storage (" n -= val;");
2226  output_storage (" px[0] = x[6];");
2227  output_storage (" px[1] = x[5];");
2228  output_storage (" px[2] = x[4];");
2229  output_storage (" px[3] = x[3];");
2230  output_storage (" px[4] = x[2];");
2231  output_storage (" px[5] = x[1];");
2232  output_storage (" px[6] = x[0];");
2233  output_storage ("}");
2234  return;
2235 
2236  case COB_SUBSWP_S56:
2237  output_storage ("static COB_INLINE COB_A_INLINE void");
2238  output_storage ("cob_subswp_s56 (void *p, const int val)");
2239  output_storage ("{");
2240  output_storage (" cob_s64_t n = 0;");
2241  output_storage (" unsigned char *x;");
2242  output_storage (" unsigned char *px = p;");
2243 
2244  output_storage (" x = ((unsigned char *)&n) + 1;");
2245  output_storage (" x[0] = px[6];");
2246  output_storage (" x[1] = px[5];");
2247  output_storage (" x[2] = px[4];");
2248  output_storage (" x[3] = px[3];");
2249  output_storage (" x[4] = px[2];");
2250  output_storage (" x[5] = px[1];");
2251  output_storage (" x[6] = px[0];");
2252  output_storage (" n >>= 8; /* Shift with sign */");
2253  output_storage (" n -= val;");
2254  output_storage (" x = (unsigned char *)&n;");
2255  output_storage (" px[0] = x[6];");
2256  output_storage (" px[1] = x[5];");
2257  output_storage (" px[2] = x[4];");
2258  output_storage (" px[3] = x[3];");
2259  output_storage (" px[4] = x[2];");
2260  output_storage (" px[5] = x[1];");
2261  output_storage (" px[6] = x[0];");
2262  output_storage ("}");
2263  return;
2264 
2265  case COB_SUBSWP_U64:
2266  output_storage ("static COB_INLINE COB_A_INLINE void");
2267  output_storage ("cob_subswp_u64 (void *p, const int val)");
2268  output_storage ("{");
2269  output_storage (" cob_u64_t n;");
2270 
2271 #ifdef COB_ALLOW_UNALIGNED
2272  output_storage (" n = COB_BSWAP_64 (*(cob_u64_t __unaligned *)p);");
2273  output_storage (" n -= val;");
2274  output_storage (" *(cob_u64_t __unaligned *)p = COB_BSWAP_64(n);");
2275 #else
2276  output_storage (" unsigned char *x;");
2277  output_storage (" unsigned char *px = p;");
2278 
2279  output_storage (" x = (unsigned char *)&n;");
2280  output_storage (" x[0] = px[7];");
2281  output_storage (" x[1] = px[6];");
2282  output_storage (" x[2] = px[5];");
2283  output_storage (" x[3] = px[4];");
2284  output_storage (" x[4] = px[3];");
2285  output_storage (" x[5] = px[2];");
2286  output_storage (" x[6] = px[1];");
2287  output_storage (" x[7] = px[0];");
2288  output_storage (" n -= val;");
2289  output_storage (" px[0] = x[7];");
2290  output_storage (" px[1] = x[6];");
2291  output_storage (" px[2] = x[5];");
2292  output_storage (" px[3] = x[4];");
2293  output_storage (" px[4] = x[3];");
2294  output_storage (" px[5] = x[2];");
2295  output_storage (" px[6] = x[1];");
2296  output_storage (" px[7] = x[0];");
2297 #endif
2298  output_storage ("}");
2299  return;
2300 
2301  case COB_SUBSWP_S64:
2302  output_storage ("static COB_INLINE COB_A_INLINE void");
2303  output_storage ("cob_subswp_s64 (void *p, const int val)");
2304  output_storage ("{");
2305  output_storage (" cob_s64_t n;");
2306 
2307 #ifdef COB_ALLOW_UNALIGNED
2308  output_storage (" n = COB_BSWAP_64 (*(cob_s64_t __unaligned *)p);");
2309  output_storage (" n -= val;");
2310  output_storage (" *(cob_s64_t __unaligned *)p = COB_BSWAP_64(n);");
2311 #else
2312  output_storage (" unsigned char *x;");
2313  output_storage (" unsigned char *px = p;");
2314 
2315  output_storage (" x = (unsigned char *)&n;");
2316  output_storage (" x[0] = px[7];");
2317  output_storage (" x[1] = px[6];");
2318  output_storage (" x[2] = px[5];");
2319  output_storage (" x[3] = px[4];");
2320  output_storage (" x[4] = px[3];");
2321  output_storage (" x[5] = px[2];");
2322  output_storage (" x[6] = px[1];");
2323  output_storage (" x[7] = px[0];");
2324  output_storage (" n -= val;");
2325  output_storage (" px[0] = x[7];");
2326  output_storage (" px[1] = x[6];");
2327  output_storage (" px[2] = x[5];");
2328  output_storage (" px[3] = x[4];");
2329  output_storage (" px[4] = x[3];");
2330  output_storage (" px[5] = x[2];");
2331  output_storage (" px[6] = x[1];");
2332  output_storage (" px[7] = x[0];");
2333 #endif
2334  output_storage ("}");
2335  return;
2336 
2337  /* Binary set swapped value */
2338  case COB_SETSWP_U16:
2339  output_storage ("static COB_INLINE COB_A_INLINE void");
2340  output_storage ("cob_setswp_u16 (void *p, const int val)");
2341  output_storage ("{");
2342  output_storage (" unsigned short n;");
2343 
2344 #ifdef COB_ALLOW_UNALIGNED
2345  output_storage (" n = val;");
2346  output_storage (" *(unsigned short __unaligned *)p = COB_BSWAP_16(n);");
2347 #else
2348  output_storage (" unsigned char *x;");
2349  output_storage (" unsigned char *px = p;");
2350 
2351  output_storage (" n = val;");
2352  output_storage (" x = (unsigned char *)&n;");
2353  output_storage (" px[0] = x[1];");
2354  output_storage (" px[1] = x[0];");
2355 #endif
2356  output_storage ("}");
2357  return;
2358 
2359  case COB_SETSWP_S16:
2360  output_storage ("static COB_INLINE COB_A_INLINE void");
2361  output_storage ("cob_setswp_s16 (void *p, const int val)");
2362  output_storage ("{");
2363  output_storage (" short n;");
2364 
2365 #ifdef COB_ALLOW_UNALIGNED
2366  output_storage (" n = val;");
2367  output_storage (" *(short __unaligned *)p = COB_BSWAP_16(n);");
2368 #else
2369  output_storage (" unsigned char *x;");
2370  output_storage (" unsigned char *px = p;");
2371 
2372  output_storage (" n = val;");
2373  output_storage (" x = (unsigned char *)&n;");
2374  output_storage (" px[0] = x[1];");
2375  output_storage (" px[1] = x[0];");
2376 #endif
2377  output_storage ("}");
2378  return;
2379 
2380  case COB_SETSWP_U24:
2381  output_storage ("static COB_INLINE COB_A_INLINE void");
2382  output_storage ("cob_setswp_u24 (void *p, const int val)");
2383  output_storage ("{");
2384  output_storage (" unsigned char *x;");
2385  output_storage (" unsigned char *px = p;");
2386  output_storage (" unsigned int n;");
2387 
2388  output_storage (" n = val;");
2389  output_storage (" x = (unsigned char *)&n;");
2390  output_storage (" px[0] = x[2];");
2391  output_storage (" px[1] = x[1];");
2392  output_storage (" px[2] = x[0];");
2393  output_storage ("}");
2394  return;
2395 
2396  case COB_SETSWP_S24:
2397  output_storage ("static COB_INLINE COB_A_INLINE void");
2398  output_storage ("cob_setswp_s24 (void *p, const int val)");
2399  output_storage ("{");
2400  output_storage (" unsigned char *x;");
2401  output_storage (" unsigned char *px = p;");
2402  output_storage (" int n;");
2403 
2404  output_storage (" n = val;");
2405  output_storage (" x = (unsigned char *)&n;");
2406  output_storage (" px[0] = x[2];");
2407  output_storage (" px[1] = x[1];");
2408  output_storage (" px[2] = x[0];");
2409  output_storage ("}");
2410  return;
2411 
2412  case COB_SETSWP_U32:
2413  output_storage ("static COB_INLINE COB_A_INLINE void");
2414  output_storage ("cob_setswp_u32 (void *p, const int val)");
2415  output_storage ("{");
2416  output_storage (" unsigned int n;");
2417 
2418 #ifdef COB_ALLOW_UNALIGNED
2419  output_storage (" n = val;");
2420  output_storage (" *(unsigned int __unaligned *)p = COB_BSWAP_32(n);");
2421 #else
2422  output_storage (" unsigned char *x;");
2423  output_storage (" unsigned char *px = p;");
2424 
2425  output_storage (" n = val;");
2426  output_storage (" x = (unsigned char *)&n;");
2427  output_storage (" px[0] = x[3];");
2428  output_storage (" px[1] = x[2];");
2429  output_storage (" px[2] = x[1];");
2430  output_storage (" px[3] = x[0];");
2431 #endif
2432  output_storage ("}");
2433  return;
2434 
2435  case COB_SETSWP_S32:
2436  output_storage ("static COB_INLINE COB_A_INLINE void");
2437  output_storage ("cob_setswp_s32 (void *p, const int val)");
2438  output_storage ("{");
2439  output_storage (" int n;");
2440 
2441 #ifdef COB_ALLOW_UNALIGNED
2442  output_storage (" n = val;");
2443  output_storage (" *(int __unaligned *)p = COB_BSWAP_32(n);");
2444 #else
2445  output_storage (" unsigned char *x;");
2446  output_storage (" unsigned char *px = p;");
2447 
2448  output_storage (" n = val;");
2449  output_storage (" x = (unsigned char *)&n;");
2450  output_storage (" px[0] = x[3];");
2451  output_storage (" px[1] = x[2];");
2452  output_storage (" px[2] = x[1];");
2453  output_storage (" px[3] = x[0];");
2454 #endif
2455  output_storage ("}");
2456  return;
2457 
2458  case COB_SETSWP_U40:
2459  output_storage ("static COB_INLINE COB_A_INLINE void");
2460  output_storage ("cob_setswp_u40 (void *p, const int val)");
2461  output_storage ("{");
2462  output_storage (" cob_u64_t n;");
2463  output_storage (" unsigned char *x;");
2464  output_storage (" unsigned char *px = p;");
2465 
2466  output_storage (" n = val;");
2467  output_storage (" x = (unsigned char *)&n;");
2468  output_storage (" px[0] = x[4];");
2469  output_storage (" px[1] = x[3];");
2470  output_storage (" px[2] = x[2];");
2471  output_storage (" px[3] = x[1];");
2472  output_storage (" px[4] = x[0];");
2473  output_storage ("}");
2474  return;
2475 
2476  case COB_SETSWP_S40:
2477  output_storage ("static COB_INLINE COB_A_INLINE void");
2478  output_storage ("cob_setswp_s40 (void *p, const int val)");
2479  output_storage ("{");
2480  output_storage (" cob_s64_t n;");
2481  output_storage (" unsigned char *x;");
2482  output_storage (" unsigned char *px = p;");
2483 
2484  output_storage (" n = val;");
2485  output_storage (" x = (unsigned char *)&n;");
2486  output_storage (" px[0] = x[4];");
2487  output_storage (" px[1] = x[3];");
2488  output_storage (" px[2] = x[2];");
2489  output_storage (" px[3] = x[1];");
2490  output_storage (" px[4] = x[0];");
2491  output_storage ("}");
2492  return;
2493 
2494  case COB_SETSWP_U48:
2495  output_storage ("static COB_INLINE COB_A_INLINE void");
2496  output_storage ("cob_setswp_u48 (void *p, const int val)");
2497  output_storage ("{");
2498  output_storage (" cob_u64_t n;");
2499  output_storage (" unsigned char *x;");
2500  output_storage (" unsigned char *px = p;");
2501 
2502  output_storage (" n = val;");
2503  output_storage (" x = (unsigned char *)&n;");
2504  output_storage (" px[0] = x[5];");
2505  output_storage (" px[1] = x[4];");
2506  output_storage (" px[2] = x[3];");
2507  output_storage (" px[3] = x[2];");
2508  output_storage (" px[4] = x[1];");
2509  output_storage (" px[5] = x[0];");
2510  output_storage ("}");
2511  return;
2512 
2513  case COB_SETSWP_S48:
2514  output_storage ("static COB_INLINE COB_A_INLINE void");
2515  output_storage ("cob_setswp_s48 (void *p, const int val)");
2516  output_storage ("{");
2517  output_storage (" cob_s64_t n;");
2518  output_storage (" unsigned char *x;");
2519  output_storage (" unsigned char *px = p;");
2520 
2521  output_storage (" n = val;");
2522  output_storage (" x = (unsigned char *)&n;");
2523  output_storage (" px[0] = x[5];");
2524  output_storage (" px[1] = x[4];");
2525  output_storage (" px[2] = x[3];");
2526  output_storage (" px[3] = x[2];");
2527  output_storage (" px[4] = x[1];");
2528  output_storage (" px[5] = x[0];");
2529  output_storage ("}");
2530  return;
2531 
2532  case COB_SETSWP_U56:
2533  output_storage ("static COB_INLINE COB_A_INLINE void");
2534  output_storage ("cob_setswp_u56 (void *p, const int val)");
2535  output_storage ("{");
2536  output_storage (" cob_u64_t n;");
2537  output_storage (" unsigned char *x;");
2538  output_storage (" unsigned char *px = p;");
2539 
2540  output_storage (" n = val;");
2541  output_storage (" x = (unsigned char *)&n;");
2542  output_storage (" px[0] = x[6];");
2543  output_storage (" px[1] = x[5];");
2544  output_storage (" px[2] = x[4];");
2545  output_storage (" px[3] = x[3];");
2546  output_storage (" px[4] = x[2];");
2547  output_storage (" px[5] = x[1];");
2548  output_storage (" px[6] = x[0];");
2549  output_storage ("}");
2550  return;
2551 
2552  case COB_SETSWP_S56:
2553  output_storage ("static COB_INLINE COB_A_INLINE void");
2554  output_storage ("cob_setswp_s56 (void *p, const int val)");
2555  output_storage ("{");
2556  output_storage (" cob_s64_t n;");
2557  output_storage (" unsigned char *x;");
2558  output_storage (" unsigned char *px = p;");
2559 
2560  output_storage (" n = val;");
2561  output_storage (" x = (unsigned char *)&n;");
2562  output_storage (" px[0] = x[6];");
2563  output_storage (" px[1] = x[5];");
2564  output_storage (" px[2] = x[4];");
2565  output_storage (" px[3] = x[3];");
2566  output_storage (" px[4] = x[2];");
2567  output_storage (" px[5] = x[1];");
2568  output_storage (" px[6] = x[0];");
2569  output_storage ("}");
2570  return;
2571 
2572  case COB_SETSWP_U64:
2573  output_storage ("static COB_INLINE COB_A_INLINE void");
2574  output_storage ("cob_setswp_u64 (void *p, const int val)");
2575  output_storage ("{");
2576  output_storage (" cob_u64_t n;");
2577 
2578 #ifdef COB_ALLOW_UNALIGNED
2579  output_storage (" n = val;");
2580  output_storage (" *(cob_u64_t __unaligned *)p = COB_BSWAP_64(n);");
2581 #else
2582  output_storage (" unsigned char *x;");
2583  output_storage (" unsigned char *px = p;");
2584 
2585  output_storage (" n = val;");
2586  output_storage (" x = (unsigned char *)&n;");
2587  output_storage (" px[0] = x[7];");
2588  output_storage (" px[1] = x[6];");
2589  output_storage (" px[2] = x[5];");
2590  output_storage (" px[3] = x[4];");
2591  output_storage (" px[4] = x[3];");
2592  output_storage (" px[5] = x[2];");
2593  output_storage (" px[6] = x[1];");
2594  output_storage (" px[7] = x[0];");
2595 #endif
2596  output_storage ("}");
2597  return;
2598 
2599  case COB_SETSWP_S64:
2600  output_storage ("static COB_INLINE COB_A_INLINE void");
2601  output_storage ("cob_setswp_s64 (void *p, const int val)");
2602  output_storage ("{");
2603  output_storage (" cob_s64_t n;");
2604 
2605 #ifdef COB_ALLOW_UNALIGNED
2606  output_storage (" n = val;");
2607  output_storage (" *(cob_s64_t __unaligned *)p = COB_BSWAP_64(n);");
2608 #else
2609  output_storage (" unsigned char *x;");
2610  output_storage (" unsigned char *px = p;");
2611 
2612  output_storage (" n = val;");
2613  output_storage (" x = (unsigned char *)&n;");
2614  output_storage (" px[0] = x[7];");
2615  output_storage (" px[1] = x[6];");
2616  output_storage (" px[2] = x[5];");
2617  output_storage (" px[3] = x[4];");
2618  output_storage (" px[4] = x[3];");
2619  output_storage (" px[5] = x[2];");
2620  output_storage (" px[6] = x[1];");
2621  output_storage (" px[7] = x[0];");
2622 #endif
2623  output_storage ("}");
2624  return;
2625  default:
2626  break;
2627  }
2628  cobc_abort_pr (_("Unexpected optimization value"));
2629  COBC_ABORT ();
2630 }
DECLNORET void cobc_abort ( const char *  ,
const int   
)

References _, cobc_abort_pr(), and cobc_abort_terminate().

Referenced by cobc_dumb_abort().

607 {
608  cobc_abort_pr (_("%s:%d Internal compiler error"), filename, linenum);
610 }
void* cobc_check_string ( const char *  )

References _, base_string, cobc_abort_pr(), cobc_abort_terminate(), cobc_main_malloc(), cobc_main_strdup(), strcache::next, unlikely, and strcache::val.

Referenced by cb_build_binary_picture(), cb_build_picture(), cb_build_program_id(), cb_define_list_add(), and cb_encode_program_id().

942 {
943  struct strcache *s;
944 
945 #ifdef COB_TREE_DEBUG
946  if (unlikely(!dupstr)) {
947  cobc_abort_pr (_("Call to cobc_check_string with NULL pointer"));
949  }
950 #endif
951  for (s = base_string; s; s = s->next) {
952  if (!strcmp (dupstr, (const char *)s->val)) {
953  return s->val;
954  }
955  }
956  s = cobc_main_malloc (sizeof(struct strcache));
957  s->next = base_string;
958  s->val = cobc_main_strdup (dupstr);
959  base_string = s;
960  return s->val;
961 }
size_t cobc_check_valid_name ( const char *  ,
const unsigned  int 
)

References cob_csyns, COB_NUM_CSYNS, cobc_bcompare(), cobc_error_name(), and p.

Referenced by cb_build_program_id(), and process_filename().

1133 {
1134  const char *p;
1135  size_t len;
1136 
1137  for (p = name, len = 0; *p; p++, len++) {
1138  if (*p == '/' || *p == '\\') {
1139  cobc_error_name (name, prechk, 5U);
1140  return 1;
1141  }
1142  }
1143  if (len < 1) {
1144  cobc_error_name (name, prechk, 1U);
1145  return 1;
1146  }
1147  if (!cb_relaxed_syntax_check && len > 31) {
1148  cobc_error_name (name, prechk, 1U);
1149  return 1;
1150  }
1151  if (*name == '_' || *name == ' ') {
1152  cobc_error_name (name, prechk, 2U);
1153  return 1;
1154  }
1155  if (prechk && len > 3 &&
1156  (!memcmp (name, "cob_", (size_t)4) ||
1157  !memcmp (name, "COB_", (size_t)4))) {
1158  cobc_error_name (name, prechk, 3U);
1159  return 1;
1160  }
1161  if (bsearch (name, cob_csyns, COB_NUM_CSYNS,
1162  sizeof (char *), cobc_bcompare)) {
1163  cobc_error_name (name, prechk, 4U);
1164  return 1;
1165  }
1166  return 0;
1167 }
DECLNORET void cobc_dumb_abort ( const char *  ,
const int   
)

References cobc_abort().

614 {
615  cobc_abort (filename, linenum);
616 }
void cobc_free ( void *  )

deallocation of compile time memory

References _, cobc_abort_pr(), cobc_abort_terminate(), and unlikely.

Referenced by cb_define_list_add(), cb_reset_78(), cb_reset_global_78(), clear_initial_values(), cobc_cmd_print(), cobc_deciph_funcs(), cobc_free_mem(), cobc_main_free(), cobc_main_realloc(), cobc_parse_free(), cobc_parse_realloc(), cobc_var_print(), main(), plex_clear_all(), ppecho(), preprocess(), process(), process_env_copy_path(), scan_define_options(), while(), and ylex_clear_all().

658 {
659 #ifdef COB_TREE_DEBUG
660  if (unlikely(!mptr)) {
661  cobc_abort_pr (_("Call to cobc_free with NULL pointer"));
663  }
664 #endif
665  free(mptr);
666 }
void cobc_init_reserved ( void  )

References cob_lower_tab, p, pcob_lower_tab, and pcob_lower_val.

Referenced by main().

2799 {
2800  const unsigned char *p;
2801  const unsigned char *v;
2802 
2803  memset (cob_lower_tab, 0, sizeof(cob_lower_tab));
2804  p = pcob_lower_tab;
2805  v = pcob_lower_val;
2806  for (; *p; ++p, ++v) {
2807  cob_lower_tab[*p] = *v;
2808  }
2809 }
void cobc_init_scanner ( void  )

References p.

Referenced by main().

4659 {
4660  const unsigned char *p;
4661 
4662  memset (valid_char, 0, sizeof(valid_char));
4663  for (p = pvalid_char; *p; ++p) {
4664  valid_char[*p] = 1;
4665  }
4666 }
void cobc_init_typeck ( void  )

References expr_prio, p, pvalid_char, and valid_char.

Referenced by main().

8511 {
8512  const unsigned char *p;
8513 
8514  memset (valid_char, 0, sizeof(valid_char));
8515  for (p = pvalid_char; *p; ++p) {
8516  valid_char[*p] = 1;
8517  }
8518  memset(expr_prio, 0, sizeof(expr_prio));
8519  expr_prio['x' & 0xFF] = 0;
8520  expr_prio['^' & 0xFF] = 1;
8521  expr_prio['*' & 0xFF] = 2;
8522  expr_prio['/' & 0xFF] = 2;
8523  expr_prio['+' & 0xFF] = 3;
8524  expr_prio['-' & 0xFF] = 3;
8525  expr_prio['=' & 0xFF] = 4;
8526  expr_prio['~' & 0xFF] = 4;
8527  expr_prio['<' & 0xFF] = 4;
8528  expr_prio['>' & 0xFF] = 4;
8529  expr_prio['[' & 0xFF] = 4;
8530  expr_prio[']' & 0xFF] = 4;
8531  expr_prio['!' & 0xFF] = 5;
8532  expr_prio['&' & 0xFF] = 6;
8533  expr_prio['|' & 0xFF] = 7;
8534  expr_prio[')' & 0xFF] = 8;
8535  expr_prio['(' & 0xFF] = 9;
8536  expr_prio[0] = 10;
8537 }
void cobc_main_free ( void *  )

References cobc_free(), cobc_mem_struct::memptr, cobc_mem_struct::next, and NULL.

779 {
780  struct cobc_mem_struct *curr;
781  struct cobc_mem_struct *prev;
782 
783  prev = NULL;
784  for (curr = cobc_mainmem_base; curr; curr = curr->next) {
785  if (curr->memptr == prevptr) {
786  break;
787  }
788  prev = curr;
789  }
790  if (!curr) {
791  return;
792  }
793  if (prev) {
794  prev->next = curr->next;
795  } else {
796  /* At mainmem_base */
797  cobc_mainmem_base = curr->next;
798  }
799  cobc_free (curr);
800 }
void* cobc_main_malloc ( const size_t  )
void* cobc_main_realloc ( void *  ,
const size_t   
)

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_free(), cobc_mem_struct::memlen, cobc_mem_struct::memptr, cobc_mem_struct::next, NULL, and unlikely.

Referenced by cb_expr_shift(), cobc_add_str(), cobc_chk_buff_size(), file_basename(), and output_initialize_one().

739 {
740  struct cobc_mem_struct *m;
741  struct cobc_mem_struct *curr;
742  struct cobc_mem_struct *prev;
743 
744  m = calloc ((size_t)1, sizeof(struct cobc_mem_struct) + size);
745  if (unlikely(!m)) {
746  cobc_abort_pr (_("Cannot allocate %d bytes of memory - Aborting"),
747  (int)size);
749  }
750  m->memptr = (char *)m + sizeof(struct cobc_mem_struct);
751  m->memlen = size;
752 
753  prev = NULL;
754  for (curr = cobc_mainmem_base; curr; curr = curr->next) {
755  if (curr->memptr == prevptr) {
756  break;
757  }
758  prev = curr;
759  }
760  if (unlikely(!curr)) {
761  cobc_abort_pr (_("Attempt to reallocate non-allocated memory - Aborting"));
763  }
764  m->next = curr->next;
765  if (prev) {
766  prev->next = m;
767  } else {
768  /* At mainmem_base */
769  cobc_mainmem_base = m;
770  }
771  memcpy (m->memptr, curr->memptr, curr->memlen);
772  cobc_free (curr);
773 
774  return m->memptr;
775 }
void* cobc_main_strdup ( const char *  )

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_main_malloc(), p, and unlikely.

Referenced by cb_text_list_add(), cobc_check_string(), cobc_getenv(), cobc_set_value(), main(), process_command_line(), process_filename(), process_link(), and read_string().

721 {
722  void *p;
723  size_t n;
724 
725 #ifdef COB_TREE_DEBUG
726  if (unlikely(!dupstr)) {
727  cobc_abort_pr (_("Call to cobc_main_strdup with NULL pointer"));
729  }
730 #endif
731  n = strlen (dupstr);
732  p = cobc_main_malloc (n + 1);
733  memcpy (p, dupstr, n);
734  return p;
735 }
void* cobc_malloc ( const size_t  )

memory allocation for use when compiling

Allocate size bytes of memory, cleared to zeros. Aborts compile if memory unavailable.

References _, cobc_abort_pr(), cobc_abort_terminate(), and unlikely.

Referenced by cb_add_78(), cb_add_const_var(), cobc_strdup(), ppopen(), and process().

644 {
645  void *mptr;
646 
647  mptr = calloc ((size_t)1, size);
648  if (unlikely(!mptr)) {
649  cobc_abort_pr (_("Cannot allocate %d bytes of memory - Aborting"),
650  (int)size);
652  }
653  return mptr;
654 }
void cobc_parse_free ( void *  )

References cobc_free(), cobc_mem_struct::memptr, cobc_mem_struct::next, and NULL.

Referenced by cb_build_move_literal(), terminator_clear(), terminator_error(), and terminator_warning().

881 {
882  struct cobc_mem_struct *curr;
883  struct cobc_mem_struct *prev;
884 
885  prev = NULL;
886  for (curr = cobc_parsemem_base; curr; curr = curr->next) {
887  if (curr->memptr == prevptr) {
888  break;
889  }
890  prev = curr;
891  }
892  if (!curr) {
893  return;
894  }
895  if (prev) {
896  prev->next = curr->next;
897  } else {
898  /* At parsemem_base */
899  cobc_parsemem_base = curr->next;
900  }
901  cobc_free (curr);
902 }
void* cobc_parse_realloc ( void *  ,
const size_t   
)

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_free(), cobc_mem_struct::memlen, cobc_mem_struct::memptr, cobc_mem_struct::next, NULL, and unlikely.

841 {
842  struct cobc_mem_struct *m;
843  struct cobc_mem_struct *curr;
844  struct cobc_mem_struct *prev;
845 
846  m = calloc ((size_t)1, sizeof(struct cobc_mem_struct) + size);
847  if (unlikely(!m)) {
848  cobc_abort_pr (_("Cannot allocate %d bytes of memory - Aborting"),
849  (int)size);
851  }
852  m->memptr = (char *)m + sizeof(struct cobc_mem_struct);
853  m->memlen = size;
854 
855  prev = NULL;
856  for (curr = cobc_parsemem_base; curr; curr = curr->next) {
857  if (curr->memptr == prevptr) {
858  break;
859  }
860  prev = curr;
861  }
862  if (unlikely(!curr)) {
863  cobc_abort_pr (_("Attempt to reallocate non-allocated memory - Aborting"));
865  }
866  m->next = curr->next;
867  if (prev) {
868  prev->next = m;
869  } else {
870  /* At parsemem_base */
871  cobc_parsemem_base = m;
872  }
873  memcpy (m->memptr, curr->memptr, curr->memlen);
874  cobc_free (curr);
875 
876  return m->memptr;
877 }
void* cobc_parse_strdup ( const char *  )

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_parse_malloc(), p, and unlikely.

Referenced by cb_build_class_name(), cb_build_debug(), cb_emit_evaluate(), cb_to_cname(), lookup_string(), lookup_word(), and while().

823 {
824  void *p;
825  size_t n;
826 
827 #ifdef COB_TREE_DEBUG
828  if (unlikely(!dupstr)) {
829  cobc_abort_pr (_("Call to cobc_parse_strdup with NULL pointer"));
831  }
832 #endif
833  n = strlen (dupstr);
834  p = cobc_parse_malloc (n + 1);
835  memcpy (p, dupstr, n);
836  return p;
837 }
void* cobc_plex_malloc ( const size_t  )

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_plexmem_base, cobc_mem_struct::memptr, cobc_mem_struct::next, and unlikely.

Referenced by cobc_plex_strdup(), pp_text_list_add(), ppp_define_add(), ppp_list_add(), and ppp_replace_list_add().

907 {
908  struct cobc_mem_struct *m;
909 
910  m = calloc ((size_t)1, sizeof(struct cobc_mem_struct) + size);
911  if (unlikely(!m)) {
912  cobc_abort_pr (_("Cannot allocate %d bytes of memory - Aborting"),
913  (int)size);
915  }
916  m->memptr = (char *)m + sizeof(struct cobc_mem_struct);
917  m->next = cobc_plexmem_base;
918  cobc_plexmem_base = m;
919  return m->memptr;
920 }
void* cobc_plex_strdup ( const char *  )

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_plex_malloc(), p, and unlikely.

Referenced by ppp_define_add(), ppp_list_add(), ppp_set_value(), switch_to_buffer(), and while().

924 {
925  void *p;
926  size_t n;
927 
928 #ifdef COB_TREE_DEBUG
929  if (unlikely(!dupstr)) {
930  cobc_abort_pr (_("Call to cobc_plex_strdup with NULL pointer"));
932  }
933 #endif
934  n = strlen (dupstr);
935  p = cobc_plex_malloc (n + 1);
936  memcpy (p, dupstr, n);
937  return p;
938 }
void* cobc_realloc ( void *  ,
const size_t   
)

References _, cobc_abort_pr(), cobc_abort_terminate(), and unlikely.

Referenced by read_literal(), scan_x(), and scan_z().

688 {
689  void *mptr;
690 
691  mptr = realloc (prevptr, size);
692  if (unlikely(!mptr)) {
693  cobc_abort_pr (_("Cannot reallocate %d bytes of memory - Aborting"),
694  (int)size);
696  }
697  return mptr;
698 }
void* cobc_strdup ( const char *  )

safely duplicate a character array

References _, cobc_abort_pr(), cobc_abort_terminate(), cobc_malloc(), p, and unlikely.

Referenced by cb_define_list_add(), cobc_cmd_print(), cobc_deciph_funcs(), cobc_var_print(), ppecho(), ppopen(), process_command_line(), process_env_copy_path(), scan_define_options(), and while().

670 {
671  void *p;
672  size_t n;
673 
674 #ifdef COB_TREE_DEBUG
675  if (unlikely(!dupstr)) {
676  cobc_abort_pr (_("Call to cobc_strdup with NULL pointer"));
678  }
679 #endif
680  n = strlen (dupstr);
681  p = cobc_malloc (n + 1);
682  memcpy (p, dupstr, n);
683  return p;
684 }
DECLNORET void cobc_too_many_errors ( void  )

References _, cobc_abort_pr(), and cobc_abort_terminate().

Referenced by cb_error(), cb_error_x(), and cb_plex_error().

600 {
601  cobc_abort_pr (_("Too many errors - Aborting compilation"));
603 }
void configuration_error ( const char *  ,
const int  ,
const char *  ,
  ... 
)

References _, and conf_error_displayed.

Referenced by cb_config_entry(), cb_load_conf(), invalid_value(), process_command_line(), and unsupported_value().

144 {
145  va_list args;
146 
147  if (!conf_error_displayed) {
149  fputs (_("Configuration Error"), stderr);
150  putc ('\n', stderr);
151  }
152 
153  if (fname) {
154  if (line) {
155  fprintf (stderr, "%s:%d: ", fname, line);
156  } else {
157  fprintf (stderr, "%s: ", fname);
158  }
159  } else {
160  fputs ("cb_conf: ", stderr);
161  }
162 
163  va_start(args, fmt);
164  vfprintf (stderr, fmt, args);
165  va_end(args);
166 
167  putc ('\n', stderr);
168  fflush (stderr);
169 }
void plex_action_directive ( const unsigned  int,
const unsigned  int 
)

References _, cb_plex_error(), cb_source_line, plex_stack::cmd, COBC_ABORT, cobc_abort_pr(), plex_stack::cond, plex_stack::line, PLEX_ACT_ELIF, PLEX_ACT_ELSE, PLEX_ACT_END, PLEX_ACT_IF, PLEX_COND_DEPTH, plex_cond_stack, plex_nest_depth, and plex_stack::skip.

4563 {
4564  unsigned int n;
4565 
4566  /* Action IF/ELSE/END-IF/ELIF */
4567  switch (cmdtype) {
4568  case PLEX_ACT_IF:
4569  /* Push stack - First occurrence is dummy */
4570  if (++plex_nest_depth >= PLEX_COND_DEPTH) {
4571  cobc_abort_pr (_("Directive nest depth exceeded - %d"),
4572  PLEX_COND_DEPTH);
4573  COBC_ABORT ();
4574  }
4576  /* Intersection with previous - first is always 0 */
4577  n = plex_cond_stack[plex_nest_depth - 1].skip | !is_true;
4581  plex_skip_input = n;
4582  return;
4583  case PLEX_ACT_ELSE:
4584  /* Must have an associated IF/ELIF */
4585  if (!plex_nest_depth ||
4586  plex_cond_stack[plex_nest_depth].cmd != 1) {
4588  _("ELSE directive without matching IF/ELIF"));
4589  return;
4590  }
4592  /* Reverse any IF/ELIF condition */
4596  /* Intersection with previous */
4598  return;
4599  case PLEX_ACT_END:
4600  /* Must have an associated IF/ELIF/ELSE */
4601  if (!plex_nest_depth ||
4604  _("END-IF directive without matching IF/ELIF/ELSE"));
4605  return;
4606  }
4611  /* Pop stack - set skip to previous */
4612  plex_nest_depth--;
4614  return;
4615  case PLEX_ACT_ELIF:
4616  /* Must have an associated IF/ELIF */
4617  if (!plex_nest_depth ||
4618  plex_cond_stack[plex_nest_depth].cmd != 1) {
4620  _("ELIF directive without matching IF/ELIF"));
4621  return;
4622  }
4624  if (plex_cond_stack[plex_nest_depth].cond) {
4625  /* Previous IF or one of previous ELIF was true */
4626  /* Set to skip */
4627  n = 1U;
4628  } else if (is_true) {
4629  /* Condition is true */
4631  n = 0;
4632  } else {
4633  /* Set to skip */
4634  n = 1U;
4635  }
4637  /* Intersection with previous */
4639  return;
4640  default:
4641  cobc_abort_pr (_("Invalid internal case - %u"),
4642  cmdtype);
4643  COBC_ABORT ();
4644  }
4645 }
void plex_call_destroy ( void  )

References pplex_destroy().

Referenced by preprocess().

4557 {
4558  (void)pplex_destroy ();
4559 }
void plex_clear_all ( void  )

References cobc_free(), and NULL.

Referenced by main().

4544 {
4545  if (plexbuff1) {
4546  cobc_free (plexbuff1);
4547  plexbuff1 = NULL;
4548  }
4549  if (plexbuff2) {
4550  cobc_free (plexbuff2);
4551  plexbuff2 = NULL;
4552  }
4553 }
void plex_clear_vars ( void  )

References plex_cond_stack.

Referenced by preprocess().

4533 {
4534  /* Reset variables */
4535  plex_skip_input = 0;
4536  plex_nest_depth = 0;
4537  memset (plex_cond_stack, 0, sizeof(plex_cond_stack));
4539  comment_allowed = 1;
4540 }
void pp_set_replace_list ( struct cb_replace_list ,
const cob_u32_t   
)

References base_replace_list, cb_replace_list::last, cb_replace_list::next, NULL, and cb_replace_list::prev.

4376 {
4377  /* Handle REPLACE verb */
4378  if (!list) {
4379  /* REPLACE [LAST] OFF */
4380  if (!is_pushpop) {
4382  return;
4383  }
4384  if (!base_replace_list) {
4385  return;
4386  }
4388  return;
4389  }
4390  /* REPLACE [ALSO] ... */
4391  if (base_replace_list && is_pushpop) {
4392  list->last->next = base_replace_list;
4393  list->prev = base_replace_list;
4394  } else {
4395  list->prev = NULL;
4396  }
4397  base_replace_list = list;
4398 }
int ppcopy ( const char *  ,
const char *  ,
struct cb_replace_list  
)

References _, cb_error(), cb_extension_list, cb_include_list, COB_SMALL_MAX, cb_text_list::next, plexbuff1, ppopen(), R_OK, and cb_text_list::text.

4485 {
4486  struct cb_text_list *il;
4487  struct cb_text_list *el;
4488  const char *s;
4489 
4490  /* Locate and open COPY file */
4491  if (lib) {
4492  snprintf (plexbuff1, (size_t)COB_SMALL_MAX, "%s/%s", lib, name);
4493  s = plexbuff1;
4494  } else {
4495  s = name;
4496  }
4497 
4498  /* Find the file */
4499  if (access (s, R_OK) == 0) {
4500  return ppopen (s, replace_list);
4501  }
4502 
4503  for (el = cb_extension_list; el; el = el->next) {
4504  snprintf (plexbuff2, (size_t)COB_SMALL_MAX, "%s%s", s, el->text);
4505  if (access (plexbuff2, R_OK) == 0) {
4506  return ppopen (plexbuff2, replace_list);
4507  }
4508  }
4509 
4510  if (*s != '/') {
4511  for (il = cb_include_list; il; il = il->next) {
4512  for (el = cb_extension_list; el; el = el->next) {
4513  snprintf (plexbuff2, (size_t)COB_SMALL_MAX,
4514  "%s/%s%s", il->text, name, el->text);
4515  if (access (plexbuff2, R_OK) == 0) {
4516  return ppopen (plexbuff2, replace_list);
4517  }
4518  }
4519  }
4520  }
4521  cb_error ("%s: %s", name, _("No such file or directory"));
4522  return -1;
4523 }
int pplex ( void  )
int ppopen ( const char *  ,
struct cb_replace_list  
)

References _, copy_info::buffer, cb_error(), cb_source_file, cb_source_format, cb_source_line, cobc_malloc(), cobc_strdup(), copy_stack, current_replace_list, copy_info::dname, errorcount, copy_info::file, cb_replace_list::last, copy_info::line, cb_replace_list::next, copy_info::next, p, pp_create_buffer(), ppin, copy_info::quotation_mark, quotation_mark, copy_info::replacing, replacing_list, copy_info::source_format, switch_to_buffer(), YY_BUF_SIZE, and YY_CURRENT_BUFFER.

Referenced by ppcopy(), and preprocess().

4402 {
4403  struct copy_info *p;
4404  char *s;
4405  char *dname;
4406 
4407 #ifdef _WIN32
4408  unsigned char bom[4];
4409 #endif
4410 
4411  if (ppin) {
4412  for (; newline_count > 0; newline_count--) {
4413  ungetc ('\n', ppin);
4414  }
4415  }
4416 
4417  /* Open copy/source file */
4418 #ifdef __OS400__
4419  ppin = fopen (name, "r");
4420 #else
4421  ppin = fopen (name, "rb");
4422 #endif
4423  if (!ppin) {
4424  if (cb_source_file) {
4425  cb_error ("%s: %s", name,
4426  _("No such file or directory"));
4427  } else {
4428  fflush (stderr);
4429  fprintf (stderr, "%s: %s", name,
4430  _("No such file or directory"));
4431  fflush (stderr);
4432  errorcount++;
4433  }
4434  return -1;
4435  }
4436 #ifdef _WIN32
4437  /* Check for BOM */
4438  if (fread (bom, 3, 1, ppin) == 1) {
4439  if (bom[0] != 0xEF || bom[1] != 0xBB || bom[2] != 0xBF) {
4440  rewind (ppin);
4441  }
4442  } else {
4443  rewind (ppin);
4444  }
4445 #endif
4446 
4447  /* Preserve the current buffer */
4448  p = cobc_malloc (sizeof (struct copy_info));
4449  p->file = cb_source_file;
4451 
4452  /* Save variables */
4454  p->line = cb_source_line;
4457 
4458  p->next = copy_stack;
4459  copy_stack = p;
4460 
4461  /* Set replacing list */
4462  if (replacing_list) {
4463  if (current_replace_list) {
4464  replacing_list->last->next = current_replace_list;
4466  }
4468  }
4469 
4470  dname = cobc_strdup (name);
4471  p->dname = dname;
4472  for (s = dname; *s; ++s) {
4473  if (*s == '\\') {
4474  *s = '/';
4475  }
4476  }
4477 
4478  /* Switch to new buffer */
4480  return 0;
4481 }
int ppparse ( void  )

Referenced by preprocess().

void ppparse_clear_vars ( const struct cb_define_struct )

References cb_define_struct::name, cb_define_struct::next, NULL, ppp_define_add(), and cb_define_struct::value.

Referenced by preprocess().

495 {
496  const struct cb_define_struct *q;
497 
499  /* Set standard DEFINE's */
500  if (cb_perform_osvs) {
502  "PERFORM-TYPE",
503  "'OSVS'", 0);
504  } else {
506  "PERFORM-TYPE",
507  "'MF'", 0);
508  }
509  if (cb_ebcdic_sign) {
511  "SIGN",
512  "'EBCDIC'", 0);
513  } else {
515  "SIGN",
516  "'ASCII'", 0);
517  }
518 #ifdef WORDS_BIGENDIAN
520  "ENDIAN",
521  "'BIG'", 0);
522 #else
524  "ENDIAN",
525  "'LITTLE'", 0);
526 #endif
527 #if ' ' == 0x20
529  "CHARSET",
530  "'ASCII'", 0);
531 #elif ' ' == 0x40
533  "CHARSET",
534  "'EBCDIC'", 0);
535 #else
537  "CHARSET",
538  "'UNKNOWN'", 0);
539 #endif
540  /* Set DEFINE's from '-D' option(s) */
541  for (q = p; q; q = q->next) {
543  q->name,
544  q->value, 0);
545  }
546 }
void ppparse_error ( const char *  )

References cb_plex_error().

4527 {
4529 }
void ylex_call_destroy ( void  )

References NULL, and yylex_destroy().

Referenced by process_translate().

4537 {
4538  /* Release flex buffers */
4539  (void)yylex_destroy ();
4540  const78ptr = NULL;
4541 }
void ylex_clear_all ( void  )

References cobc_free(), and NULL.

Referenced by main().

4516 {
4517  /* Clear buffers after parsing all source elements */
4518  if (picbuff2) {
4519  cobc_free (picbuff2);
4520  picbuff2 = NULL;
4521  }
4522  if (picbuff1) {
4523  cobc_free (picbuff1);
4524  picbuff1 = NULL;
4525  }
4526  if (plexbuff) {
4527  cobc_free (plexbuff);
4528  plexbuff = NULL;
4529  }
4530  plexsize = 0;
4531  pic1size = 0;
4532  pic2size = 0;
4533 }
int yylex ( void  )
int yyparse ( void  )

Variable Documentation

int cb_attr_id

Referenced by lookup_attr(), and main().

struct cb_text_list* cb_early_exit_list

Referenced by output_call().

struct cb_exception cb_exception_table[]
struct cb_text_list* cb_extension_list

Referenced by ppcopy().

int cb_field_id

Referenced by cb_build_field(), and main().

int cb_flag_functions_all
int cb_flag_main

Referenced by process_command_line().

struct cb_text_list* cb_include_list

Referenced by ppcopy().

struct cb_text_list* cb_intrinsic_list

Referenced by while().

FILE* cb_listing_file
int cb_literal_id

Referenced by lookup_literal(), and main().

size_t cb_msg_style

Referenced by cobc_print_info(), main(), and print_error().

char* cb_oc_build_stamp
int cb_saveargc

Referenced by main(), and output_header().

char** cb_saveargv

Referenced by main(), and output_header().

int cb_source_format
struct cb_text_list* cb_static_call_list

Referenced by output_call().

FILE* cb_storage_file
const char* cb_storage_file_name

Referenced by codegen(), and process_translate().

const char* cob_config_dir

Referenced by cb_load_conf(), and main().

unsigned int cobc_gen_listing
char * cobc_glob_line
struct noreserve* cobc_nores_base
int cobc_wants_debug

Referenced by main(), and process_command_line().

struct cb_label * current_paragraph
struct cb_label * current_section
const char* demangle_name

Referenced by main().

int functions_are_all

Referenced by cb_build_program(), and while().

int no_physical_cancel
FILE * ppout = (FILE *) 0
size_t suppress_warn
int warningcount
FILE* yyin
FILE* yyout