Skip to content

Commit

Permalink
Place "__thread" after "static" keyword to support GCC
Browse files Browse the repository at this point in the history
  • Loading branch information
lfittl committed Oct 30, 2017
1 parent 6f308f6 commit 6ea9e95
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 32 deletions.
6 changes: 5 additions & 1 deletion scripts/extract_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,11 @@ def write_out
str += "\n" + @mock[symbol] + "\n"
elsif @external_variables.include?(symbol) && symbols.include?(symbol)
file_thread_local_variables << symbol
str += "\n__thread " + skipped_code.strip + "\n"
if skipped_code.include?('static')
str += "\n" + skipped_code.strip.gsub('static', 'static __thread') + "\n"
else
str += "\n__thread " + skipped_code.strip + "\n"
end
else
# In the off chance that part of a macro is before a symbol (e.g. ifdef),
# but the closing part is inside (e.g. endif) we need to output all macros inside skipped parts
Expand Down
2 changes: 1 addition & 1 deletion src/postgres/contrib_pgcrypto_sha1.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#include "sha1.h"

/* constant table */
__thread static uint32 _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6};
static __thread uint32 _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6};


#define K(t) _K[(t) / 20]
Expand Down
2 changes: 1 addition & 1 deletion src/postgres/src_backend_nodes_extensible.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "nodes/extensible.h"
#include "utils/hsearch.h"

__thread static HTAB *extensible_node_methods = NULL;
static __thread HTAB *extensible_node_methods = NULL;



Expand Down
2 changes: 1 addition & 1 deletion src/postgres/src_backend_parser_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -8536,7 +8536,7 @@ static yyconst struct yy_trans_info yy_transition[37005] =

{ 1, 0 }, };

__thread static yyconst struct yy_trans_info *yy_start_state_list[27] =
static __thread yyconst struct yy_trans_info *yy_start_state_list[27] =
{
&yy_transition[1],
&yy_transition[3],
Expand Down
2 changes: 1 addition & 1 deletion src/postgres/src_backend_storage_lmgr_s_lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@



__thread static int spins_per_delay = DEFAULT_SPINS_PER_DELAY;
static __thread int spins_per_delay = DEFAULT_SPINS_PER_DELAY;



Expand Down
2 changes: 1 addition & 1 deletion src/postgres/src_backend_tcop_postgres.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ __thread int max_stack_depth = 100;
*/

/* max_stack_depth converted to bytes for speed of checking */
__thread static long max_stack_depth_bytes = 100 * 1024L;
static __thread long max_stack_depth_bytes = 100 * 1024L;


/*
Expand Down
6 changes: 3 additions & 3 deletions src/postgres/src_backend_utils_error_elog.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ static void write_eventlog(int level, const char *line, int len);
/* We provide a small stack of ErrorData records for re-entrant cases */
#define ERRORDATA_STACK_SIZE 5

__thread static ErrorData errordata[ERRORDATA_STACK_SIZE];
static __thread ErrorData errordata[ERRORDATA_STACK_SIZE];


__thread static int errordata_stack_depth = -1;
static __thread int errordata_stack_depth = -1;
/* index of topmost active frame */

__thread static int recursion_depth = 0;
static __thread int recursion_depth = 0;
/* to detect actual recursion */

/*
Expand Down
6 changes: 3 additions & 3 deletions src/postgres/src_backend_utils_hash_dynahash.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ static bool has_seq_scans(HTAB *hashp);
/*
* memory allocation support
*/
__thread static MemoryContext CurrentDynaHashCxt = NULL;
static __thread MemoryContext CurrentDynaHashCxt = NULL;



Expand Down Expand Up @@ -1042,10 +1042,10 @@ hash_corrupted(HTAB *hashp)

#define MAX_SEQ_SCANS 100

__thread static HTAB *seq_scan_tables[MAX_SEQ_SCANS];
static __thread HTAB *seq_scan_tables[MAX_SEQ_SCANS];
/* tables being scanned */
/* subtransaction nest level */
__thread static int num_seq_scans = 0;
static __thread int num_seq_scans = 0;



Expand Down
4 changes: 2 additions & 2 deletions src/postgres/src_backend_utils_mb_mbutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ typedef struct ConvProcInfo
/*
* These variables track the currently-selected encodings.
*/
__thread static const pg_enc2name *ClientEncoding = &pg_enc2name_tbl[PG_SQL_ASCII];
static __thread const pg_enc2name *ClientEncoding = &pg_enc2name_tbl[PG_SQL_ASCII];

__thread static const pg_enc2name *DatabaseEncoding = &pg_enc2name_tbl[PG_SQL_ASCII];
static __thread const pg_enc2name *DatabaseEncoding = &pg_enc2name_tbl[PG_SQL_ASCII];



Expand Down
2 changes: 1 addition & 1 deletion src/postgres/src_backend_utils_mmgr_aset.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static void AllocSetCheck(MemoryContext context);
/*
* This is the virtual function table for AllocSet contexts.
*/
__thread static MemoryContextMethods AllocSetMethods = {
static __thread MemoryContextMethods AllocSetMethods = {
AllocSetAlloc,
AllocSetFree,
AllocSetRealloc,
Expand Down
4 changes: 2 additions & 2 deletions src/postgres/src_pl_plpgsql_src_pl_comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@
__thread PLpgSQL_stmt_block *plpgsql_parse_result;


__thread static int datums_alloc;
static __thread int datums_alloc;

__thread int plpgsql_nDatums;

__thread PLpgSQL_datum **plpgsql_Datums;

__thread static int datums_last;
static __thread int datums_last;


__thread char *plpgsql_error_funcname;
Expand Down
2 changes: 1 addition & 1 deletion src/postgres/src_pl_plpgsql_src_pl_funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
* items.
* ----------
*/
__thread static PLpgSQL_nsitem *ns_top = NULL;
static __thread PLpgSQL_nsitem *ns_top = NULL;



Expand Down
22 changes: 11 additions & 11 deletions src/postgres/src_pl_plpgsql_src_pl_scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,39 +244,39 @@ typedef struct
*/

/* The stuff the core lexer needs */
__thread static core_yyscan_t yyscanner = NULL;
static __thread core_yyscan_t yyscanner = NULL;

__thread static core_yy_extra_type core_yy;
static __thread core_yy_extra_type core_yy;


/* The original input string */
__thread static const char *scanorig;
static __thread const char *scanorig;


/* Current token's length (corresponds to plpgsql_yylval and plpgsql_yylloc) */
__thread static int plpgsql_yyleng;
static __thread int plpgsql_yyleng;


/* Current token's code (corresponds to plpgsql_yylval and plpgsql_yylloc) */
__thread static int plpgsql_yytoken;
static __thread int plpgsql_yytoken;


/* Token pushback stack */
#define MAX_PUSHBACKS 4

__thread static int num_pushbacks;
static __thread int num_pushbacks;

__thread static int pushback_token[MAX_PUSHBACKS];
static __thread int pushback_token[MAX_PUSHBACKS];

__thread static TokenAuxData pushback_auxdata[MAX_PUSHBACKS];
static __thread TokenAuxData pushback_auxdata[MAX_PUSHBACKS];


/* State for plpgsql_location_to_lineno() */
__thread static const char *cur_line_start;
static __thread const char *cur_line_start;

__thread static const char *cur_line_end;
static __thread const char *cur_line_end;

__thread static int cur_line_num;
static __thread int cur_line_num;


/* Internal functions */
Expand Down
6 changes: 3 additions & 3 deletions src/postgres/src_port_erand48.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@
#define RAND48_MULT_2 (0x0005)
#define RAND48_ADD (0x000b)

__thread static unsigned short _rand48_seed[3] = {
static __thread unsigned short _rand48_seed[3] = {
RAND48_SEED_0,
RAND48_SEED_1,
RAND48_SEED_2
};

__thread static unsigned short _rand48_mult[3] = {
static __thread unsigned short _rand48_mult[3] = {
RAND48_MULT_0,
RAND48_MULT_1,
RAND48_MULT_2
};

__thread static unsigned short _rand48_add = RAND48_ADD;
static __thread unsigned short _rand48_add = RAND48_ADD;



Expand Down

0 comments on commit 6ea9e95

Please sign in to comment.