-
Notifications
You must be signed in to change notification settings - Fork 9
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
Make global variables thread-safe in the extension #19
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,17 +28,30 @@ | |
#undef FALSE | ||
#define putchar(c) rb_nkf_putchar(c) | ||
|
||
#ifndef RB_THREAD_LOCAL_SPECIFIER | ||
# if __STDC_VERSION__ >= 201112 | ||
# define RB_THREAD_LOCAL_SPECIFIER _Thread_local | ||
# elif defined(__GNUC__) | ||
/* note that ICC (linux) and Clang are covered by __GNUC__ */ | ||
# define RB_THREAD_LOCAL_SPECIFIER __thread | ||
# endif | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic is borrowed from the So on Ruby 3.4 we rely on the available out of the box |
||
|
||
#ifndef RB_THREAD_LOCAL_SPECIFIER | ||
# define RB_THREAD_LOCAL_SPECIFIER | ||
#endif | ||
|
||
/* Input/Output pointers */ | ||
|
||
static unsigned char *output; | ||
static unsigned char *input; | ||
static int input_ctr; | ||
static int i_len; | ||
static int output_ctr; | ||
static int o_len; | ||
static int incsize; | ||
static RB_THREAD_LOCAL_SPECIFIER unsigned char *output; | ||
static RB_THREAD_LOCAL_SPECIFIER unsigned char *input; | ||
static RB_THREAD_LOCAL_SPECIFIER int input_ctr; | ||
static RB_THREAD_LOCAL_SPECIFIER int i_len; | ||
static RB_THREAD_LOCAL_SPECIFIER int output_ctr; | ||
static RB_THREAD_LOCAL_SPECIFIER int o_len; | ||
static RB_THREAD_LOCAL_SPECIFIER int incsize; | ||
|
||
static VALUE result; | ||
static RB_THREAD_LOCAL_SPECIFIER VALUE result; | ||
|
||
static int | ||
rb_nkf_putchar(unsigned int c) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't analyse thoroughly which global variables are modified and which aren't so updated declaration of all the static global variables.