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
45 Tjnz,45 Tjnz,
46 Tret,46 Tret,
47 Texport,47 Texport,
48 Tthread,
48 Tfunc,49 Tfunc,
49 Ttype,50 Ttype,
50 Tdata,51 Tdata,
@@ -99,6 +100,7 @@ static char *kwmap[Ntok] = { · 48 unmodified lines
99 [Tjnz] = "jnz",100 [Tjnz] = "jnz",
100 [Tret] = "ret",101 [Tret] = "ret",
101 [Texport] = "export",102 [Texport] = "export",
103 [Tthread] = "thread",
102 [Tfunc] = "function",104 [Tfunc] = "function",
103 [Ttype] = "type",105 [Ttype] = "type",
104 [Tdata] = "data",106 [Tdata] = "data",
@@ -399,30 +401,34 @@ parseref() · 294 unmodified lines
399 401
400 memset(&c, 0, sizeof c);402 memset(&c, 0, sizeof c);
401 switch (next()) {403 switch (next()) {
404 default:
405 return R;
402 case Ttmp:406 case Ttmp:
403 return tmpref(tokval.str);407 return tmpref(tokval.str);
404 case Tint:408 case Tint:
405 c.type = CBits;409 c.type = CBits;
406 c.bits.i = tokval.num;410 c.bits.i = tokval.num;
407 goto Look;411 break;
408 case Tflts:412 case Tflts:
409 c.type = CBits;413 c.type = CBits;
410 c.bits.s = tokval.flts;414 c.bits.s = tokval.flts;
411 c.flt = 1;415 c.flt = 1;
412 goto Look;416 break;
413 case Tfltd:417 case Tfltd:
414 c.type = CBits;418 c.type = CBits;
415 c.bits.d = tokval.fltd;419 c.bits.d = tokval.fltd;
416 c.flt = 2;420 c.flt = 2;
417 goto Look;421 break;
422 case Tthread:
423 c.rel = RelThr;
424 expect(Tglo);
425 /* fall through */
418 case Tglo:426 case Tglo:
419 c.type = CAddr;427 c.type = CAddr;
420 c.label = intern(tokval.str);428 c.label = intern(tokval.str);
421 Look:429 break;
422 return newcon(&c, curf);
423 default:
424 return R;
425 }430 }
431 return newcon(&c, curf);
426}432}
427 433
428static int434static int
@@ -1101,6 +1107,9 @@ parselnk(Lnk *lnk) · 672 unmodified lines
1101 case Texport:1107 case Texport:
1102 lnk->export = 1;1108 lnk->export = 1;
1103 break;1109 break;
1110 case Tthread:
1111 lnk->thread = 1;
1112 break;
1104 case Tsection:1113 case Tsection:
1105 if (lnk->sec)1114 if (lnk->sec)
1106 err("only one section allowed");1115 err("only one section allowed");
@@ -1113,9 +1122,9 @@ parselnk(Lnk *lnk) · 6 unmodified lines
1113 }1122 }
1114 break;1123 break;
1115 default:1124 default:
1116 if (haslnk)1125 if (t == Tfunc && lnk->thread)
1117 if (t != Tdata)1126 err("only data may have thread linkage");
1118 if (t != Tfunc)1127 if (haslnk && t != Tdata && t != Tfunc)
1119 err("only data and function have linkage");1128 err("only data and function have linkage");
1120 return t;1129 return t;
1121 }1130 }
@@ -1244,8 +1253,6 @@ printfn(Fn *fn, FILE *f) · 122 unmodified lines
1244 Ins *i;1253 Ins *i;
1245 uint n;1254 uint n;
1246 1255
1247 if (fn->lnk.export)
1248 fprintf(f, "export ");
1249 fprintf(f, "function $%s() {\n", fn->name);1256 fprintf(f, "function $%s() {\n", fn->name);
1250 for (b=fn->start; b; b=b->link) {1257 for (b=fn->start; b; b=b->link) {
1251 fprintf(f, "@%s\n", b->name);1258 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