Skip to content

Commit

Permalink
Adding thred local variables to all files, tracking static function
Browse files Browse the repository at this point in the history
local variables
  • Loading branch information
N-Holzschuch committed Nov 3, 2019
1 parent acce13f commit d38829e
Show file tree
Hide file tree
Showing 57 changed files with 1,873 additions and 644 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Frameworks/
Frameworks_iphoneOS/
Frameworks_simulator/
Python3_ios.framework/
ios_system.framework/
lua_ios.framework/
# Unixen: object and executable files.
*.o
src/vim
Expand Down
2 changes: 1 addition & 1 deletion src/arabic.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
#define a_s_LAM_ALEF 0xfefb
#define a_f_LAM_ALEF 0xfefc

static struct achar {
static __thread struct achar {
unsigned c;
unsigned isolated;
unsigned initial;
Expand Down
21 changes: 15 additions & 6 deletions src/auto/configure
Original file line number Diff line number Diff line change
Expand Up @@ -5501,6 +5501,8 @@ $as_echo "no" >&6; }
LUA_LIBS="-L${vi_cv_path_lua_pfx}/lib -llua"
fi
fi
# specific for iOS:
LUA_LIBS="-F.. -framework lua_ios"
if test "$enable_luainterp" = "dynamic"; then
lua_ok="yes"
else
Expand Down Expand Up @@ -11858,7 +11860,9 @@ if ac_fn_c_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: OK" >&5
$as_echo "OK" >&6; }
else
as_fn_error $? "FAILED" "$LINENO" 5
# iOS: force yes
$as_echo "OK" >&6;
# as_fn_error $? "FAILED" "$LINENO" 5
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
Expand Down Expand Up @@ -11975,9 +11979,12 @@ if ac_fn_c_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
as_fn_error $? "NOT FOUND!
You need to install a terminal library; for example ncurses.
Or specify the name of the library with --with-tlib." "$LINENO" 5
# iOS: force yes on tgetent()
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
# as_fn_error $? "NOT FOUND!
# You need to install a terminal library; for example ncurses.
# Or specify the name of the library with --with-tlib." "$LINENO" 5
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
Expand Down Expand Up @@ -14778,8 +14785,10 @@ $as_echo "yes, we need CoreServices" >&6; }
LIBS="$LIBS -framework CoreServices"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, we need AppKit" >&5
$as_echo "yes, we need AppKit" >&6; }
LIBS="$LIBS -framework AppKit"
$as_echo "yes, we need AppKit/UIKit" >&6; }
# iOS, TODO: make this automatic
# LIBS="$LIBS -framework AppKit"
LIBS="-F .. -framework ios_system $LIBS -framework UIKit -lobjc -framework Foundation -framework lua_ios -framework Python3_ios "
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
Expand Down
57 changes: 43 additions & 14 deletions src/autocmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ typedef struct AutoPat
char last; // last pattern for apply_autocmds()
} AutoPat;

static struct event_name
static __thread struct event_name
{
char *name; // event name
event_T event; // event number
Expand Down Expand Up @@ -191,7 +191,7 @@ static struct event_name
{NULL, (event_T)0}
};

static AutoPat *first_autopat[NUM_EVENTS] =
static __thread AutoPat *first_autopat[NUM_EVENTS] =
{
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
Expand All @@ -201,7 +201,7 @@ static AutoPat *first_autopat[NUM_EVENTS] =
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};

static AutoPat *last_autopat[NUM_EVENTS] =
static __thread AutoPat *last_autopat[NUM_EVENTS] =
{
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
Expand Down Expand Up @@ -232,22 +232,32 @@ typedef struct AutoPatCmd
struct AutoPatCmd *next; // chain of active apc-s for auto-invalidation
} AutoPatCmd;

static AutoPatCmd *active_apc_list = NULL; /* stack of active autocommands */
static __thread AutoPatCmd *active_apc_list = NULL; /* stack of active autocommands */

/*
* augroups stores a list of autocmd group names.
*/
static garray_T augroups = {0, 0, sizeof(char_u *), 10, NULL};
static __thread garray_T augroups = {0, 0, sizeof(char_u *), 10, NULL};
#define AUGROUP_NAME(i) (((char_u **)augroups.ga_data)[i])
/* use get_deleted_augroup() to get this */
static char_u *deleted_augroup = NULL;
static __thread char_u *deleted_augroup = NULL;

/*
* Set by the apply_autocmds_group function if the given event is equal to
* EVENT_FILETYPE. Used by the readfile function in order to determine if
* EVENT_BUFREADPOST triggered the EVENT_FILETYPE.
*
* Relying on this value requires one to reset it prior calling
* apply_autocmds_group.
*/
extern __thread int au_did_filetype INIT(= FALSE);

/*
* The ID of the current group. Group 0 is the default one.
*/
static int current_augroup = AUGROUP_DEFAULT;
static __thread int current_augroup = AUGROUP_DEFAULT;

static int au_need_clean = FALSE; /* need to delete marked patterns */
static __thread int au_need_clean = FALSE; /* need to delete marked patterns */

static char_u *event_nr2name(event_T event);
static int au_get_grouparg(char_u **argp);
Expand All @@ -256,9 +266,9 @@ static int apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io,
static void auto_next_pat(AutoPatCmd *apc, int stop_at_last);
static int au_find_group(char_u *name);

static event_T last_event;
static int last_group;
static int autocmd_blocked = 0; /* block all autocmds */
static __thread event_T last_event;
static __thread int last_group;
static __thread int autocmd_blocked = 0; /* block all autocmds */

static char_u *
get_deleted_augroup(void)
Expand Down Expand Up @@ -617,6 +627,25 @@ free_all_autocmds(void)
vim_free(s);
}
ga_clear(&augroups);


#if TARGET_OS_IPHONE
// reset everything
for (i = 0; i < NUM_EVENTS; i++) {
first_autopat[i] = NULL;
last_autopat[i] = NULL;
}
// also reset static variables
augroups = (garray_T) {0, 0, sizeof(char_u *), 10, NULL};
active_apc_list = NULL;
deleted_augroup = NULL;
au_did_filetype = FALSE;
current_augroup = AUGROUP_DEFAULT;
au_need_clean = FALSE; /* need to delete marked patterns */
last_event = 0;
last_group = 0;
autocmd_blocked = 0; /* block all autocmds */
#endif
}
#endif

Expand Down Expand Up @@ -1591,7 +1620,7 @@ aucmd_restbuf(
}
}

static int autocmd_nested = FALSE;
static __thread int autocmd_nested = FALSE;

/*
* Execute autocommands for "event" and file name "fname".
Expand Down Expand Up @@ -2204,7 +2233,7 @@ apply_autocmds_group(
}

# ifdef FEAT_EVAL
static char_u *old_termresponse = NULL;
static __thread char_u *old_termresponse = NULL;
# endif

/*
Expand Down Expand Up @@ -2435,7 +2464,7 @@ get_augroup_name(expand_T *xp UNUSED, int idx)
return AUGROUP_NAME(idx); // return a name
}

static int include_groups = FALSE;
static __thread int include_groups = FALSE;

char_u *
set_context_in_autocmd(
Expand Down
6 changes: 3 additions & 3 deletions src/blowfish.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ typedef struct {


/* Blowfish code */
static UINT32_T pax_init[18] = {
static __thread UINT32_T pax_init[18] = {
0x243f6a88u, 0x85a308d3u, 0x13198a2eu,
0x03707344u, 0xa4093822u, 0x299f31d0u,
0x082efa98u, 0xec4e6c89u, 0x452821e6u,
Expand All @@ -66,7 +66,7 @@ static UINT32_T pax_init[18] = {
0xb5470917u, 0x9216d5d9u, 0x8979fb1bu
};

static UINT32_T sbx_init[4][256] = {
static __thread UINT32_T sbx_init[4][256] = {
{0xd1310ba6u, 0x98dfb5acu, 0x2ffd72dbu, 0xd01adfb7u,
0xb8e1afedu, 0x6a267e96u, 0xba7c9045u, 0xf12c7f99u,
0x24a19947u, 0xb3916cf7u, 0x0801f2e2u, 0x858efc16u,
Expand Down Expand Up @@ -492,7 +492,7 @@ typedef struct {
* Assert bf(password, plaintxt) is cryptxt.
* Assert csum(pax sbx(password)) is keysum.
*/
static struct_bf_test_data bf_test_data[] = {
static __thread struct_bf_test_data bf_test_data[] = {
{
"password",
"salt",
Expand Down
24 changes: 16 additions & 8 deletions src/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ static void clear_wininfo(buf_T *buf);
#endif

#if defined(FEAT_QUICKFIX)
static char *msg_loclist = N_("[Location List]");
static char *msg_qflist = N_("[Quickfix List]");
static __thread char *msg_loclist = N_("[Location List]");
static __thread char *msg_qflist = N_("[Quickfix List]");
#endif
static char *e_auabort = N_("E855: Autocommands caused command to abort");
static __thread char *e_auabort = N_("E855: Autocommands caused command to abort");

// Number of times free_buffer() was called.
static int buf_free_count = 0;
static __thread int buf_free_count = 0;

static int top_file_num = 1; // highest file number
static garray_T buf_reuse = GA_EMPTY; // file numbers to recycle
static __thread int top_file_num = 1; // highest file number
static __thread garray_T buf_reuse = GA_EMPTY; // file numbers to recycle

/*
* Return the highest possible buffer number.
Expand Down Expand Up @@ -3672,8 +3672,8 @@ col_print(
}

#if defined(FEAT_TITLE) || defined(PROTO)
static char_u *lasttitle = NULL;
static char_u *lasticon = NULL;
static __thread char_u *lasttitle = NULL;
static __thread char_u *lasticon = NULL;

/*
* Put the file name in the title bar and icon of the window.
Expand Down Expand Up @@ -3935,8 +3935,16 @@ resettitle(void)
void
free_titles(void)
{
#ifdef TARGET_OS_IPHONE
VIM_CLEAR(lasttitle);
VIM_CLEAR(lasticon);
top_file_num = 1;
buf_free_count = 0;
buf_reuse = (garray_T) GA_EMPTY; // file numbers to recycle
#else
vim_free(lasttitle);
vim_free(lasticon);
#endif
}
# endif

Expand Down
7 changes: 6 additions & 1 deletion src/change.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ changed_internal(void)
}

#ifdef FEAT_EVAL
static long next_listener_id = 0;
static __thread long next_listener_id = 0;

/*
* Check if the change at "lnum" is above or overlaps with an existing
Expand Down Expand Up @@ -336,6 +336,9 @@ may_invoke_listeners(buf_T *buf, linenr_T lnum, linenr_T lnume, int added)
* Called when a sequence of changes is done: invoke listeners added with
* listener_add().
*/
#if TARGET_OS_IPHONE
static __thread int recursive = FALSE;
#endif
void
invoke_listeners(buf_T *buf)
{
Expand All @@ -347,7 +350,9 @@ invoke_listeners(buf_T *buf)
linenr_T end = 0;
linenr_T added = 0;
int save_updating_screen = updating_screen;
#if !TARGET_OS_IPHONE
static int recursive = FALSE;
#endif

if (buf->b_recorded_changes == NULL // nothing changed
|| buf->b_listener == NULL // no listeners
Expand Down
Loading

0 comments on commit d38829e

Please sign in to comment.