Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move static variables to local state structures in libcob/strings.c #137

Closed
Closed
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 @@ -78,6 +78,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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, here and below add an empty lime after the name

* 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 @@ -117,6 +122,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 @@ -11206,3 +11206,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
Loading