changing {} style to match majority of previous style

This commit is contained in:
Philippe Teuwen 2019-03-10 11:20:22 +01:00
commit 961d929f4d
320 changed files with 5502 additions and 10485 deletions

View file

@ -104,8 +104,7 @@ static void reallymarkobject(global_State *g, GCObject *o);
** if key is not marked, mark its entry as dead (therefore removing it
** from the table)
*/
static void removeentry(Node *n)
{
static void removeentry(Node *n) {
lua_assert(ttisnil(gval(n)));
if (valiswhite(gkey(n)))
setdeadvalue(gkey(n)); /* unused and unmarked key; remove it */
@ -119,8 +118,7 @@ static void removeentry(Node *n)
** other objects: if really collected, cannot keep them; for objects
** being finalized, keep them in keys, but not in values
*/
static int iscleared(global_State *g, const TValue *o)
{
static int iscleared(global_State *g, const TValue *o) {
if (!iscollectable(o)) return 0;
else if (ttisstring(o)) {
markobject(g, rawtsvalue(o)); /* strings are `values', so are never weak */
@ -133,8 +131,7 @@ static int iscleared(global_State *g, const TValue *o)
** barrier that moves collector forward, that is, mark the white object
** being pointed by a black object.
*/
void luaC_barrier_(lua_State *L, GCObject *o, GCObject *v)
{
void luaC_barrier_(lua_State *L, GCObject *o, GCObject *v) {
global_State *g = G(L);
lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));
lua_assert(g->gcstate != GCSpause);
@ -154,8 +151,7 @@ void luaC_barrier_(lua_State *L, GCObject *o, GCObject *v)
** only works for tables; access to 'gclist' is not uniform across
** different types.)
*/
void luaC_barrierback_(lua_State *L, GCObject *o)
{
void luaC_barrierback_(lua_State *L, GCObject *o) {
global_State *g = G(L);
lua_assert(isblack(o) && !isdead(g, o) && gch(o)->tt == LUA_TTABLE);
black2gray(o); /* make object gray (again) */
@ -172,8 +168,7 @@ void luaC_barrierback_(lua_State *L, GCObject *o)
** it again. Otherwise, use a backward barrier, to avoid marking all
** possible instances.
*/
LUAI_FUNC void luaC_barrierproto_(lua_State *L, Proto *p, Closure *c)
{
LUAI_FUNC void luaC_barrierproto_(lua_State *L, Proto *p, Closure *c) {
global_State *g = G(L);
lua_assert(isblack(obj2gco(p)));
if (p->cache == NULL) { /* first time? */
@ -190,8 +185,7 @@ LUAI_FUNC void luaC_barrierproto_(lua_State *L, Proto *p, Closure *c)
** check color (and invariants) for an upvalue that was closed,
** i.e., moved into the 'allgc' list
*/
void luaC_checkupvalcolor(global_State *g, UpVal *uv)
{
void luaC_checkupvalcolor(global_State *g, UpVal *uv) {
GCObject *o = obj2gco(uv);
lua_assert(!isblack(o)); /* open upvalues are never black */
if (isgray(o)) {
@ -213,8 +207,7 @@ void luaC_checkupvalcolor(global_State *g, UpVal *uv)
** object itself (used only by states).
*/
GCObject *luaC_newobj(lua_State *L, int tt, size_t sz, GCObject **list,
int offset)
{
int offset) {
global_State *g = G(L);
char *raw = cast(char *, luaM_newobject(L, novariant(tt), sz));
GCObject *o = obj2gco(raw + offset);
@ -244,8 +237,7 @@ GCObject *luaC_newobj(lua_State *L, int tt, size_t sz, GCObject **list,
** to appropriate list to be visited (and turned black) later. (Open
** upvalues are already linked in 'headuv' list.)
*/
static void reallymarkobject(global_State *g, GCObject *o)
{
static void reallymarkobject(global_State *g, GCObject *o) {
lu_mem size;
white2gray(o);
switch (gch(o)->tt) {
@ -305,8 +297,7 @@ static void reallymarkobject(global_State *g, GCObject *o)
/*
** mark metamethods for basic types
*/
static void markmt(global_State *g)
{
static void markmt(global_State *g) {
int i;
for (i = 0; i < LUA_NUMTAGS; i++)
markobject(g, g->mt[i]);
@ -316,8 +307,7 @@ static void markmt(global_State *g)
/*
** mark all objects in list of being-finalized
*/
static void markbeingfnz(global_State *g)
{
static void markbeingfnz(global_State *g) {
GCObject *o;
for (o = g->tobefnz; o != NULL; o = gch(o)->next) {
makewhite(g, o);
@ -330,8 +320,7 @@ static void markbeingfnz(global_State *g)
** mark all values stored in marked open upvalues. (See comment in
** 'lstate.h'.)
*/
static void remarkupvals(global_State *g)
{
static void remarkupvals(global_State *g) {
UpVal *uv;
for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) {
if (isgray(obj2gco(uv)))
@ -344,8 +333,7 @@ static void remarkupvals(global_State *g)
** mark root set and reset all gray lists, to start a new
** incremental (or full) collection
*/
static void restartcollection(global_State *g)
{
static void restartcollection(global_State *g) {
g->gray = g->grayagain = NULL;
g->weak = g->allweak = g->ephemeron = NULL;
markobject(g, g->mainthread);
@ -363,8 +351,7 @@ static void restartcollection(global_State *g)
** =======================================================
*/
static void traverseweakvalue(global_State *g, Table *h)
{
static void traverseweakvalue(global_State *g, Table *h) {
Node *n, *limit = gnodelast(h);
/* if there is array part, assume it may have white values (do not
traverse it just to check) */
@ -387,8 +374,7 @@ static void traverseweakvalue(global_State *g, Table *h)
}
static int traverseephemeron(global_State *g, Table *h)
{
static int traverseephemeron(global_State *g, Table *h) {
int marked = 0; /* true if an object is marked in this traversal */
int hasclears = 0; /* true if table has white keys */
int prop = 0; /* true if table has entry "white-key -> white-value" */
@ -425,8 +411,7 @@ static int traverseephemeron(global_State *g, Table *h)
}
static void traversestrongtable(global_State *g, Table *h)
{
static void traversestrongtable(global_State *g, Table *h) {
Node *n, *limit = gnodelast(h);
int i;
for (i = 0; i < h->sizearray; i++) /* traverse array part */
@ -444,15 +429,14 @@ static void traversestrongtable(global_State *g, Table *h)
}
static lu_mem traversetable(global_State *g, Table *h)
{
static lu_mem traversetable(global_State *g, Table *h) {
const char *weakkey, *weakvalue;
const TValue *mode = gfasttm(g, h->metatable, TM_MODE);
markobject(g, h->metatable);
if (mode && ttisstring(mode) && /* is there a weak mode? */
((weakkey = strchr(svalue(mode), 'k')),
(weakvalue = strchr(svalue(mode), 'v')),
(weakkey || weakvalue))) { /* is really weak? */
((weakkey = strchr(svalue(mode), 'k')),
(weakvalue = strchr(svalue(mode), 'v')),
(weakkey || weakvalue))) { /* is really weak? */
black2gray(obj2gco(h)); /* keep table gray */
if (!weakkey) /* strong keys? */
traverseweakvalue(g, h);
@ -467,8 +451,7 @@ static lu_mem traversetable(global_State *g, Table *h)
}
static int traverseproto(global_State *g, Proto *f)
{
static int traverseproto(global_State *g, Proto *f) {
int i;
if (f->cache && iswhite(obj2gco(f->cache)))
f->cache = NULL; /* allow cache to be collected */
@ -490,16 +473,14 @@ static int traverseproto(global_State *g, Proto *f)
}
static lu_mem traverseCclosure(global_State *g, CClosure *cl)
{
static lu_mem traverseCclosure(global_State *g, CClosure *cl) {
int i;
for (i = 0; i < cl->nupvalues; i++) /* mark its upvalues */
markvalue(g, &cl->upvalue[i]);
return sizeCclosure(cl->nupvalues);
}
static lu_mem traverseLclosure(global_State *g, LClosure *cl)
{
static lu_mem traverseLclosure(global_State *g, LClosure *cl) {
int i;
markobject(g, cl->p); /* mark its prototype */
for (i = 0; i < cl->nupvalues; i++) /* mark its upvalues */
@ -508,8 +489,7 @@ static lu_mem traverseLclosure(global_State *g, LClosure *cl)
}
static lu_mem traversestack(global_State *g, lua_State *th)
{
static lu_mem traversestack(global_State *g, lua_State *th) {
StkId o = th->stack;
if (o == NULL)
return 1; /* stack not completely built yet */
@ -528,8 +508,7 @@ static lu_mem traversestack(global_State *g, lua_State *th)
** traverse one gray object, turning it to black (except for threads,
** which are always gray).
*/
static void propagatemark(global_State *g)
{
static void propagatemark(global_State *g) {
lu_mem size;
GCObject *o = g->gray;
lua_assert(isgray(o));
@ -576,14 +555,12 @@ static void propagatemark(global_State *g)
}
static void propagateall(global_State *g)
{
static void propagateall(global_State *g) {
while (g->gray) propagatemark(g);
}
static void propagatelist(global_State *g, GCObject *l)
{
static void propagatelist(global_State *g, GCObject *l) {
lua_assert(g->gray == NULL); /* no grays left */
g->gray = l;
propagateall(g); /* traverse all elements from 'l' */
@ -594,8 +571,7 @@ static void propagatelist(global_State *g, GCObject *l)
** lists when traversed, traverse the original lists to avoid traversing
** twice the same table (which is not wrong, but inefficient)
*/
static void retraversegrays(global_State *g)
{
static void retraversegrays(global_State *g) {
GCObject *weak = g->weak; /* save original lists */
GCObject *grayagain = g->grayagain;
GCObject *ephemeron = g->ephemeron;
@ -607,8 +583,7 @@ static void retraversegrays(global_State *g)
}
static void convergeephemerons(global_State *g)
{
static void convergeephemerons(global_State *g) {
int changed;
do {
GCObject *w;
@ -639,8 +614,7 @@ static void convergeephemerons(global_State *g)
** clear entries with unmarked keys from all weaktables in list 'l' up
** to element 'f'
*/
static void clearkeys(global_State *g, GCObject *l, GCObject *f)
{
static void clearkeys(global_State *g, GCObject *l, GCObject *f) {
for (; l != f; l = gco2t(l)->gclist) {
Table *h = gco2t(l);
Node *n, *limit = gnodelast(h);
@ -658,8 +632,7 @@ static void clearkeys(global_State *g, GCObject *l, GCObject *f)
** clear entries with unmarked values from all weaktables in list 'l' up
** to element 'f'
*/
static void clearvalues(global_State *g, GCObject *l, GCObject *f)
{
static void clearvalues(global_State *g, GCObject *l, GCObject *f) {
for (; l != f; l = gco2t(l)->gclist) {
Table *h = gco2t(l);
Node *n, *limit = gnodelast(h);
@ -679,8 +652,7 @@ static void clearvalues(global_State *g, GCObject *l, GCObject *f)
}
static void freeobj(lua_State *L, GCObject *o)
{
static void freeobj(lua_State *L, GCObject *o) {
switch (gch(o)->tt) {
case LUA_TPROTO:
luaF_freeproto(L, gco2p(o));
@ -726,8 +698,7 @@ static GCObject **sweeplist(lua_State *L, GCObject **p, lu_mem count);
** sweep the (open) upvalues of a thread and resize its stack and
** list of call-info structures.
*/
static void sweepthread(lua_State *L, lua_State *L1)
{
static void sweepthread(lua_State *L, lua_State *L1) {
if (L1->stack == NULL) return; /* stack not completely built yet */
sweepwholelist(L, &L1->openupval); /* sweep open upvalues */
luaE_freeCI(L1); /* free extra CallInfo slots */
@ -748,8 +719,7 @@ static void sweepthread(lua_State *L, lua_State *L1)
** one will be old too.
** When object is a thread, sweep its list of open upvalues too.
*/
static GCObject **sweeplist(lua_State *L, GCObject **p, lu_mem count)
{
static GCObject **sweeplist(lua_State *L, GCObject **p, lu_mem count) {
global_State *g = G(L);
int ow = otherwhite(g);
int toclear, toset; /* bits to clear and to set in all live objects */
@ -786,8 +756,7 @@ static GCObject **sweeplist(lua_State *L, GCObject **p, lu_mem count)
/*
** sweep a list until a live object (or end of list)
*/
static GCObject **sweeptolive(lua_State *L, GCObject **p, int *n)
{
static GCObject **sweeptolive(lua_State *L, GCObject **p, int *n) {
GCObject **old = p;
int i = 0;
do {
@ -807,8 +776,7 @@ static GCObject **sweeptolive(lua_State *L, GCObject **p, int *n)
** =======================================================
*/
static void checkSizes(lua_State *L)
{
static void checkSizes(lua_State *L) {
global_State *g = G(L);
if (g->gckind != KGC_EMERGENCY) { /* do not change sizes in emergency */
int hs = g->strt.size / 2; /* half the size of the string table */
@ -819,8 +787,7 @@ static void checkSizes(lua_State *L)
}
static GCObject *udata2finalize(global_State *g)
{
static GCObject *udata2finalize(global_State *g) {
GCObject *o = g->tobefnz; /* get first element */
lua_assert(isfinalized(o));
g->tobefnz = gch(o)->next; /* remove it from 'tobefnz' list */
@ -834,15 +801,13 @@ static GCObject *udata2finalize(global_State *g)
}
static void dothecall(lua_State *L, void *ud)
{
static void dothecall(lua_State *L, void *ud) {
UNUSED(ud);
luaD_call(L, L->top - 2, 0, 0);
}
static void GCTM(lua_State *L, int propagateerrors)
{
static void GCTM(lua_State *L, int propagateerrors) {
global_State *g = G(L);
const TValue *tm;
TValue v;
@ -878,8 +843,7 @@ static void GCTM(lua_State *L, int propagateerrors)
** move all unreachable objects (or 'all' objects) that need
** finalization from list 'finobj' to list 'tobefnz' (to be finalized)
*/
static void separatetobefnz(lua_State *L, int all)
{
static void separatetobefnz(lua_State *L, int all) {
global_State *g = G(L);
GCObject **p = &g->finobj;
GCObject *curr;
@ -907,12 +871,11 @@ static void separatetobefnz(lua_State *L, int all)
** if object 'o' has a finalizer, remove it from 'allgc' list (must
** search the list to find it) and link it in 'finobj' list.
*/
void luaC_checkfinalizer(lua_State *L, GCObject *o, Table *mt)
{
void luaC_checkfinalizer(lua_State *L, GCObject *o, Table *mt) {
global_State *g = G(L);
if (testbit(gch(o)->marked, SEPARATED) || /* obj. is already separated... */
isfinalized(o) || /* ... or is finalized... */
gfasttm(g, mt, TM_GC) == NULL) /* or has no finalizer? */
isfinalized(o) || /* ... or is finalized... */
gfasttm(g, mt, TM_GC) == NULL) /* or has no finalizer? */
return; /* nothing to be done */
else { /* move 'o' to 'finobj' list */
GCObject **p;
@ -948,8 +911,7 @@ void luaC_checkfinalizer(lua_State *L, GCObject *o, Table *mt)
** set a reasonable "time" to wait before starting a new GC cycle;
** cycle will start when memory use hits threshold
*/
static void setpause(global_State *g, l_mem estimate)
{
static void setpause(global_State *g, l_mem estimate) {
l_mem debt, threshold;
estimate = estimate / PAUSEADJ; /* adjust 'estimate' */
threshold = (g->gcpause < MAX_LMEM / estimate) /* overflow? */
@ -972,8 +934,7 @@ static void setpause(global_State *g, l_mem estimate)
** of the real sweep.
** Returns how many objects it swept.
*/
static int entersweep(lua_State *L)
{
static int entersweep(lua_State *L) {
global_State *g = G(L);
int n = 0;
g->gcstate = GCSsweepstring;
@ -989,8 +950,7 @@ static int entersweep(lua_State *L)
/*
** change GC mode
*/
void luaC_changemode(lua_State *L, int mode)
{
void luaC_changemode(lua_State *L, int mode) {
global_State *g = G(L);
if (mode == g->gckind) return; /* nothing to change */
if (mode == KGC_GEN) { /* change to generational mode */
@ -1011,8 +971,7 @@ void luaC_changemode(lua_State *L, int mode)
/*
** call all pending finalizers
*/
static void callallpendingfinalizers(lua_State *L, int propagateerrors)
{
static void callallpendingfinalizers(lua_State *L, int propagateerrors) {
global_State *g = G(L);
while (g->tobefnz) {
resetoldbit(g->tobefnz);
@ -1021,8 +980,7 @@ static void callallpendingfinalizers(lua_State *L, int propagateerrors)
}
void luaC_freeallobjects(lua_State *L)
{
void luaC_freeallobjects(lua_State *L) {
global_State *g = G(L);
int i;
separatetobefnz(L, 1); /* separate all objects with finalizers */
@ -1038,8 +996,7 @@ void luaC_freeallobjects(lua_State *L)
}
static l_mem atomic(lua_State *L)
{
static l_mem atomic(lua_State *L) {
global_State *g = G(L);
l_mem work = -cast(l_mem, g->GCmemtrav); /* start counting work */
GCObject *origweak, *origall;
@ -1081,8 +1038,7 @@ static l_mem atomic(lua_State *L)
}
static lu_mem singlestep(lua_State *L)
{
static lu_mem singlestep(lua_State *L) {
global_State *g = G(L);
switch (g->gcstate) {
case GCSpause: {
@ -1151,16 +1107,14 @@ static lu_mem singlestep(lua_State *L)
** advances the garbage collector until it reaches a state allowed
** by 'statemask'
*/
void luaC_runtilstate(lua_State *L, int statesmask)
{
void luaC_runtilstate(lua_State *L, int statesmask) {
global_State *g = G(L);
while (!testbit(statesmask, g->gcstate))
singlestep(L);
}
static void generationalcollection(lua_State *L)
{
static void generationalcollection(lua_State *L) {
global_State *g = G(L);
lua_assert(g->gcstate == GCSpropagate);
if (g->GCestimate == 0) { /* signal for another major collection? */
@ -1181,8 +1135,7 @@ static void generationalcollection(lua_State *L)
}
static void incstep(lua_State *L)
{
static void incstep(lua_State *L) {
global_State *g = G(L);
l_mem debt = g->GCdebt;
int stepmul = g->gcstepmul;
@ -1206,8 +1159,7 @@ static void incstep(lua_State *L)
/*
** performs a basic GC step
*/
void luaC_forcestep(lua_State *L)
{
void luaC_forcestep(lua_State *L) {
global_State *g = G(L);
int i;
if (isgenerational(g)) generationalcollection(L);
@ -1221,8 +1173,7 @@ void luaC_forcestep(lua_State *L)
/*
** performs a basic GC step only if collector is running
*/
void luaC_step(lua_State *L)
{
void luaC_step(lua_State *L) {
global_State *g = G(L);
if (g->gcrunning) luaC_forcestep(L);
else luaE_setdebt(g, -GCSTEPSIZE); /* avoid being called too often */
@ -1234,8 +1185,7 @@ void luaC_step(lua_State *L)
** performs a full GC cycle; if "isemergency", does not call
** finalizers (which could change stack positions)
*/
void luaC_fullgc(lua_State *L, int isemergency)
{
void luaC_fullgc(lua_State *L, int isemergency) {
global_State *g = G(L);
int origkind = g->gckind;
lua_assert(origkind != KGC_EMERGENCY);