Remove most volatility from readtoken1() restoring execution
speed to approximately where it was before the changes made in version 1.96 (which assumed this would eventually happen.)
This commit is contained in:
parent
dec2ca90b9
commit
b506e0ff4c
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: parser.c,v 1.102 2016/02/28 23:12:23 christos Exp $ */
|
/* $NetBSD: parser.c,v 1.103 2016/03/08 14:10:04 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1991, 1993
|
* Copyright (c) 1991, 1993
|
||||||
@ -37,7 +37,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95";
|
static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: parser.c,v 1.102 2016/02/28 23:12:23 christos Exp $");
|
__RCSID("$NetBSD: parser.c,v 1.103 2016/03/08 14:10:04 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -971,7 +971,8 @@ struct tokenstate {
|
|||||||
#define QS 0x10
|
#define QS 0x10
|
||||||
|
|
||||||
#define LEVELS_PER_BLOCK 8
|
#define LEVELS_PER_BLOCK 8
|
||||||
#define VSS volatile struct statestack
|
#define VSS struct statestack
|
||||||
|
#define VVSS volatile VSS
|
||||||
|
|
||||||
struct statestack {
|
struct statestack {
|
||||||
VSS *prev; /* previous block in list */
|
VSS *prev; /* previous block in list */
|
||||||
@ -979,13 +980,13 @@ struct statestack {
|
|||||||
struct tokenstate tokenstate[LEVELS_PER_BLOCK];
|
struct tokenstate tokenstate[LEVELS_PER_BLOCK];
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline volatile struct tokenstate *
|
static inline struct tokenstate *
|
||||||
currentstate(VSS *stack)
|
currentstate(VSS *stack)
|
||||||
{
|
{
|
||||||
return &stack->tokenstate[stack->cur];
|
return &stack->tokenstate[stack->cur];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline volatile struct tokenstate *
|
static inline struct tokenstate *
|
||||||
prevstate(VSS *stack)
|
prevstate(VSS *stack)
|
||||||
{
|
{
|
||||||
if (stack->cur != 0)
|
if (stack->cur != 0)
|
||||||
@ -998,7 +999,7 @@ prevstate(VSS *stack)
|
|||||||
static inline VSS *
|
static inline VSS *
|
||||||
bump_state_level(VSS *stack)
|
bump_state_level(VSS *stack)
|
||||||
{
|
{
|
||||||
volatile struct tokenstate *os, *ts;
|
struct tokenstate *os, *ts;
|
||||||
|
|
||||||
os = currentstate(stack);
|
os = currentstate(stack);
|
||||||
|
|
||||||
@ -1079,21 +1080,22 @@ cleanup_state_stack(VSS *stack)
|
|||||||
#define varnest (currentstate(stack)->ts_varnest)
|
#define varnest (currentstate(stack)->ts_varnest)
|
||||||
#define arinest (currentstate(stack)->ts_arinest)
|
#define arinest (currentstate(stack)->ts_arinest)
|
||||||
#define quoted (currentstate(stack)->ts_quoted)
|
#define quoted (currentstate(stack)->ts_quoted)
|
||||||
#define TS_PUSH() (stack = bump_state_level(stack))
|
#define TS_PUSH() (vstack = stack = bump_state_level(stack))
|
||||||
#define TS_POP() (stack = drop_state_level(stack))
|
#define TS_POP() (vstack = stack = drop_state_level(stack))
|
||||||
|
|
||||||
STATIC int
|
STATIC int
|
||||||
readtoken1(int firstc, char const *syn, char *eofmark, int striptabs)
|
readtoken1(int firstc, char const *syn, char *eofmark, int striptabs)
|
||||||
{
|
{
|
||||||
int c = firstc;
|
int c = firstc;
|
||||||
char * volatile out;
|
char * out;
|
||||||
int len;
|
int len;
|
||||||
char line[EOFMARKLEN + 1];
|
char line[EOFMARKLEN + 1];
|
||||||
struct nodelist *bqlist;
|
struct nodelist *bqlist;
|
||||||
volatile int quotef;
|
int quotef;
|
||||||
volatile int oldstyle;
|
int oldstyle;
|
||||||
VSS static_stack;
|
VSS static_stack;
|
||||||
VSS *stack = &static_stack;
|
VSS *stack = &static_stack;
|
||||||
|
VVSS *vstack = stack;
|
||||||
|
|
||||||
stack->prev = NULL;
|
stack->prev = NULL;
|
||||||
stack->cur = 0;
|
stack->cur = 0;
|
||||||
@ -1556,7 +1558,7 @@ parsebackq: {
|
|||||||
struct nodelist **nlpp;
|
struct nodelist **nlpp;
|
||||||
int savepbq;
|
int savepbq;
|
||||||
union node *n;
|
union node *n;
|
||||||
char *volatile str = NULL;
|
char *str = NULL;
|
||||||
struct jmploc jmploc;
|
struct jmploc jmploc;
|
||||||
struct jmploc *volatile savehandler = NULL;
|
struct jmploc *volatile savehandler = NULL;
|
||||||
int savelen;
|
int savelen;
|
||||||
@ -1566,7 +1568,7 @@ parsebackq: {
|
|||||||
if (setjmp(jmploc.loc)) {
|
if (setjmp(jmploc.loc)) {
|
||||||
if (str)
|
if (str)
|
||||||
ckfree(str);
|
ckfree(str);
|
||||||
cleanup_state_stack(stack);
|
cleanup_state_stack(__UNVOLATILE(vstack));
|
||||||
parsebackquote = 0;
|
parsebackquote = 0;
|
||||||
handler = savehandler;
|
handler = savehandler;
|
||||||
longjmp(handler->loc, 1);
|
longjmp(handler->loc, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user