Skip to content

Commit

Permalink
[feature-requests:#448] using state structures instead of state vars …
Browse files Browse the repository at this point in the history
…for strings

libcob
* coblocal.h (COB_TLS): add a new attribute for thread local static
* common.h, common.c (cob_cleanup_thread): add a cleanup function for threads
* strings.c: moved static variables to structures

tests:
* testsuite.at, testsuite.src/backcomp.at, Makefile.am: added a new test suite to test the backward compatibility of strings functions (INSPECT, STRING, UNSTRING)
  • Loading branch information
engboris committed Jul 23, 2024
1 parent 7a173e6 commit 9f1a64c
Show file tree
Hide file tree
Showing 10 changed files with 4,384 additions and 310 deletions.
3 changes: 3 additions & 0 deletions cobc/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,9 @@ output_data (cb_tree x)
output (")->data");
}
break;
case CB_TAG_DIRECT:
output ("%s", CB_DIRECT (x)->line);
break;
/* LCOV_EXCL_START */
default:
CB_TREE_TAG_UNEXPECTED_ABORT (x);
Expand Down
9 changes: 9 additions & 0 deletions libcob/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@
* termio.c (pretty_display_numeric), mlio.c (get_num):
changed to use the attributes of the receiving field

2024-07-19 Simon Sobisch <[email protected]>

* coblocal.h (COB_TLS): add a new attribute for thread local static.
* common.h, common.c (cob_cleanup_thread): add a cleanup function for threads

2024-05-15 Simon Sobisch <[email protected]>

* profiling.c: fix compile warnings
Expand Down Expand Up @@ -129,6 +134,10 @@

* common.c: add missing include libxml/parser.h

2024-02-26 Boris Eng <[email protected]>
FR #488: using state structures instead of state vars for strings
* strings.c: moved static variables to structures

2024-01-25 David Declerck <[email protected]>

FR #459: support COLLATING SEQUENCE clause on SELECT / INDEXED files
Expand Down
15 changes: 14 additions & 1 deletion libcob/coblocal.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,20 @@ Note: also defined together with __clang__ in both frontends:
#define COB_MOUSE_INTERVAL cobsetptr->cob_mouse_interval
#define COB_USE_ESC cobsetptr->cob_use_esc

#if defined(COB_TLS)
/* already defined, for example as static to explicit disable TLS */
#elif defined(_WIN32)
#define COB_TLS __declspec(thread)
#elif defined(__GNUC__) && (__GNUC__ >= 4) || defined(__clang__) || \
defined(__hpux) || defined(_AIX) || defined(__sun)
#define COB_TLS static __thread
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#include <threads.h>
#define COB_TLS thread_local
#else
#define COB_TLS static /* fallback definition */
#endif

/* Global settings structure */

typedef struct __cob_settings {
Expand Down Expand Up @@ -324,7 +338,6 @@ typedef struct __cob_settings {
unsigned int cob_exit_wait; /* wait on program exit if no ACCEPT came after last DISPLAY */
const char *cob_exit_msg; /* message for cob_exit_wait */


/* reportio.c */
unsigned int cob_col_just_lrc; /* Justify data in column LEFT/RIGHT/CENTER */

Expand Down
5 changes: 5 additions & 0 deletions libcob/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -11218,3 +11218,8 @@ init_statement_list (void)
#undef COB_STATEMENT
}
#endif

void cob_cleanup_thread ()
{
cob_exit_strings ();
}
2 changes: 2 additions & 0 deletions libcob/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,8 @@ COB_EXPIMP void cob_runtime_hint (const char *, ...) COB_A_FORMAT12;
COB_EXPIMP void cob_runtime_error (const char *, ...) COB_A_FORMAT12;
COB_EXPIMP void cob_runtime_warning (const char *, ...) COB_A_FORMAT12;

COB_EXPIMP void cob_cleanup_thread ();

/* General functions */

COB_EXPIMP int cob_is_initialized (void);
Expand Down
Loading

0 comments on commit 9f1a64c

Please sign in to comment.