Skip to content

Commit

Permalink
xxx
Browse files Browse the repository at this point in the history
  • Loading branch information
lefessan committed Oct 18, 2023
1 parent 7fafce3 commit ebc7f78
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 37 deletions.
31 changes: 14 additions & 17 deletions cobc/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1754,22 +1754,22 @@ output_standard_includes (struct cb_program *prog)
{
struct cb_program *p;

#if !defined (_GNU_SOURCE) && defined (_XOPEN_SOURCE_EXTENDED)
output_line ("#ifndef\t_XOPEN_SOURCE_EXTENDED");
output_line ("#define\t_XOPEN_SOURCE_EXTENDED 1");
output_line ("#endif");
#endif
if (cb_setting_XOPEN_SOURCE_EXTENDED){
output_line ("#ifndef\t_XOPEN_SOURCE_EXTENDED");
output_line ("#define\t_XOPEN_SOURCE_EXTENDED 1");
output_line ("#endif");
}
#if 0 /* Simon: why should we include that? */
output_line ("#include <stdio.h>");
#endif
output_line ("#include <string.h> /* for memcpy, memcmp and friends */");
#ifdef WORDS_BIGENDIAN
output_line ("#define WORDS_BIGENDIAN 1");
#endif
#ifdef COB_KEYWORD_INLINE
output_line ("#define COB_KEYWORD_INLINE %s",
CB_XSTRINGIFY(COB_KEYWORD_INLINE));
#endif
if (cb_setting_WORDS_BIGENDIAN){
output_line ("#define WORDS_BIGENDIAN 1");
}
if (cb_setting_COB_INLINE_KEYWORD){
output_line ("#define COB_KEYWORD_INLINE %s",
cb_setting_COB_INLINE_KEYWORD);
}
if (cb_flag_winmain) {
output_line ("#include <windows.h>");
}
Expand Down Expand Up @@ -6523,15 +6523,12 @@ output_call (struct cb_call *p)
ret_ptr = 1;
}

#ifdef _WIN32
if (p->convention & CB_CONV_STDCALL) {
if (cb_setting_WIN32 &&
(p->convention & CB_CONV_STDCALL) ) {
convention = "_std";
} else {
convention = "";
}
#else
convention = "";
#endif

/* System routine entry points */
if (p->is_system) {
Expand Down
9 changes: 2 additions & 7 deletions cobc/ppparse.y
Original file line number Diff line number Diff line change
Expand Up @@ -582,15 +582,10 @@ ppparse_clear_vars (const struct cb_define_struct *p)
"SIGN",
"'ASCII'", 0);
}
#ifdef WORDS_BIGENDIAN
ppp_setvar_list = ppp_define_add (ppp_setvar_list,
"ENDIAN",
"'BIG'", 0);
#else
ppp_setvar_list = ppp_define_add (ppp_setvar_list,
"ENDIAN",
"'LITTLE'", 0);
#endif
cb_setting_WORDS_BIGENDIAN ? "'BIG'" : "'LITTLE'",
0);
#if ' ' == 0x20
ppp_setvar_list = ppp_define_add (ppp_setvar_list,
"CHARSET",
Expand Down
47 changes: 47 additions & 0 deletions cobc/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,38 @@ relatively to the directory containing `cobc` (`$bindir`):
* `COB_LIBRARY_PATH`: set to `$bindir/../lib/gnucobol`
* `COB_LIBS`: `-L$bindir/../lib` is added in front
TODO in codegen.c:
* COB_ALIGN_PRAGMA_8
* USE_INT_HEX
* COB_NON_ALIGNED
* COB_SHORT_BORK
* COB_EBCDIC_MACHINE
* GEN_CHAR_AS_UINT
* GEN_SINGLE_MEMCPY
* NO_INIT_SOURCE_LOC
* COB_64_BIT_POINTER
* COB_TREE_DEBUG
* COBC_HAS_CUTOFF_FLAG
TODO in typeck.c:
* COB_EBCDIC_MACHINE
* COB_NON_ALIGNED
* COB_SHORT_BORK
* COB_ALLOW_UNALIGNED
* COB_64_BIT_POINTER
* WITH_EXTENDED_SCREENIO
* WIN32
* WITH_XML2
TODO in parser.y:
* COB_EBCDIC_MACHINE
* COB_32_BIT_LONG
TODO in ppparse.y:
* #if ' ' == 0x20
* #elif ' ' == 0x40
*/

#ifndef COB_DEBUG_FLAGS
Expand Down Expand Up @@ -148,6 +180,17 @@ relatively to the directory containing `cobc` (`$bindir`):
#define COB_NON_ALIGNED 0
#endif

#if !defined (_GNU_SOURCE) && defined (_XOPEN_SOURCE_EXTENDED)
#define XOPEN_SOURCE_EXTENDED 1
#else
#define XOPEN_SOURCE_EXTENDED 0
#endif

#ifdef COB_KEYWORD_INLINE
#define COB_INLINE_KEYWORD CB_XSTRINGIFY(COB_KEYWORD_INLINE)
#else
#define COB_INLINE_KEYWORD NULL
#endif


#ifndef COBC_IS_RELOCATABLE
Expand All @@ -166,6 +209,10 @@ relatively to the directory containing `cobc` (`$bindir`):
#define HAVE_MPIR_H 0
#endif

#ifndef WORDS_BIGENDIAN
#define WORDS_BIGENDIAN 0
#endif

#ifndef HAVE_ATTRIBUTE_CONSTRUCTOR
#define HAVE_ATTRIBUTE_CONSTRUCTOR 0
#endif
Expand Down
23 changes: 22 additions & 1 deletion cobc/settings.def
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@

/* All these settings must belong to these two categories:
- Settings that modify the way other commands are called (paths, options, etc.)
- Settings that modify the way the C code is generated

We are not interested by compile time defines from config.h that only
modify the code of cobc, but have no impact on its runtime behavior.
*/

STRING_SETTING (
"executable name for module runner",
COBCRUN_NAME )
Expand Down Expand Up @@ -65,7 +73,12 @@ STRING_SETTING (
"strip command",
COB_STRIP_CMD )

/* just to test BOOL_SETTING */
STRING_SETTING (
"need keyword for inline",
COB_INLINE_KEYWORD )




BOOL_SETTING (
"has __attribute__((aligned))",
Expand Down Expand Up @@ -119,6 +132,14 @@ BOOL_SETTING (
"Support for non aligned structures",
COB_NON_ALIGNED )

BOOL_SETTING (
"XOPEN_SOURCE_EXTENDED is needed",
XOPEN_SOURCE_EXTENDED )

BOOL_SETTING (
"set to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel).",
WORDS_BIGENDIAN )



#if 0
Expand Down
24 changes: 12 additions & 12 deletions cobc/typeck.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,18 +551,18 @@ cb_is_integer_field (struct cb_field *f)
if (f->usage == CB_USAGE_BINARY
&& cb_binary_truncate)
return 0;
#ifdef WORDS_BIGENDIAN
if (f->usage != CB_USAGE_COMP_5
&& f->usage != CB_USAGE_DISPLAY
&& f->usage != CB_USAGE_BINARY
&& f->usage != CB_USAGE_COMP_X)
return 0;
#else
if (f->usage != CB_USAGE_COMP_5
&& f->usage != CB_USAGE_BINARY
&& f->usage != CB_USAGE_DISPLAY)
return 0;
#endif
if (cb_setting_WORDS_BIGENDIAN){
if (f->usage != CB_USAGE_COMP_5
&& f->usage != CB_USAGE_DISPLAY
&& f->usage != CB_USAGE_BINARY
&& f->usage != CB_USAGE_COMP_X)
return 0;
} else {
if (f->usage != CB_USAGE_COMP_5
&& f->usage != CB_USAGE_BINARY
&& f->usage != CB_USAGE_DISPLAY)
return 0;
}
if (f->storage == CB_STORAGE_WORKING
#ifdef COB_SHORT_BORK
&& (f->size == 4 || f->size == 8 || f->size == 1)
Expand Down

0 comments on commit ebc7f78

Please sign in to comment.