History

add support for thread-local storage

The apple targets are not done yet.

Quentin Carbonneaux committed 4 years ago

Commit 00a30951 parent 5cea0c212 files · +145 −70Browse files

Showing the changes to parse.c (1 of 12 files). Show all

Unified · Split

parse.c+19−12
@@ -45,6 +45,7 @@ enum { · 44 unmodified lines
4545 Tjnz,
4646 Tret,
4747 Texport,
48+ Tthread,
4849 Tfunc,
4950 Ttype,
5051 Tdata,
@@ -99,6 +100,7 @@ static char *kwmap[Ntok] = { · 48 unmodified lines
99100 [Tjnz] = "jnz",
100101 [Tret] = "ret",
101102 [Texport] = "export",
103+ [Tthread] = "thread",
102104 [Tfunc] = "function",
103105 [Ttype] = "type",
104106 [Tdata] = "data",
@@ -399,30 +401,34 @@ parseref() · 294 unmodified lines
399401
400402 memset(&c, 0, sizeof c);
401403 switch (next()) {
404+ default:
405+ return R;
402406 case Ttmp:
403407 return tmpref(tokval.str);
404408 case Tint:
405409 c.type = CBits;
406410 c.bits.i = tokval.num;
407− goto Look;
411+ break;
408412 case Tflts:
409413 c.type = CBits;
410414 c.bits.s = tokval.flts;
411415 c.flt = 1;
412− goto Look;
416+ break;
413417 case Tfltd:
414418 c.type = CBits;
415419 c.bits.d = tokval.fltd;
416420 c.flt = 2;
417− goto Look;
421+ break;
422+ case Tthread:
423+ c.rel = RelThr;
424+ expect(Tglo);
425+ /* fall through */
418426 case Tglo:
419427 c.type = CAddr;
420428 c.label = intern(tokval.str);
421− Look:
422− return newcon(&c, curf);
423− default:
424− return R;
429+ break;
425430 }
431+ return newcon(&c, curf);
426432 }
427433
428434 static int
@@ -1101,6 +1107,9 @@ parselnk(Lnk *lnk) · 672 unmodified lines
11011107 case Texport:
11021108 lnk->export = 1;
11031109 break;
1110+ case Tthread:
1111+ lnk->thread = 1;
1112+ break;
11041113 case Tsection:
11051114 if (lnk->sec)
11061115 err("only one section allowed");
@@ -1113,9 +1122,9 @@ parselnk(Lnk *lnk) · 6 unmodified lines
11131122 }
11141123 break;
11151124 default:
1116− if (haslnk)
1117− if (t != Tdata)
1118− if (t != Tfunc)
1125+ if (t == Tfunc && lnk->thread)
1126+ err("only data may have thread linkage");
1127+ if (haslnk && t != Tdata && t != Tfunc)
11191128 err("only data and function have linkage");
11201129 return t;
11211130 }
@@ -1244,8 +1253,6 @@ printfn(Fn *fn, FILE *f) · 122 unmodified lines
12441253 Ins *i;
12451254 uint n;
12461255
1247− if (fn->lnk.export)
1248− fprintf(f, "export ");
12491256 fprintf(f, "function $%s() {\n", fn->name);
12501257 for (b=fn->start; b; b=b->link) {
12511258 fprintf(f, "@%s\n", b->name);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t