Skip to content

Commit 5a9b346

Browse files
author
Alex Cole
committed
Better 64-bit compatibility.
1 parent 167ed36 commit 5a9b346

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

core.inc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ native getpubvar(const name[]);
302302
*/
303303
stock getpubvar(const __name[])
304304
{
305+
const __cellbytes = cellbits / charbits;
305306
new __entry = __findpubvar(__name);
306307
if (__entry)
307308
{
@@ -311,7 +312,7 @@ stock getpubvar(const __name[])
311312
// Get the old data (fortunately the pointer is relative to `DAT`).
312313
#emit LREF.S.pri __entry
313314
// Return the value in `pri`.
314-
#emit STACK 4
315+
#emit STACK __cellbytes
315316
#emit RETN
316317
}
317318
return 0;
@@ -332,6 +333,7 @@ native setpubvar(const name[], value);
332333
*/
333334
stock setpubvar(const __name[], __value)
334335
{
336+
const __cellbytes = cellbits / charbits;
335337
new __entry = __findpubvar(__name);
336338
if (__entry)
337339
{
@@ -344,7 +346,7 @@ stock setpubvar(const __name[], __value)
344346
#emit LOAD.S.alt __value
345347
#emit SREF.S.alt __entry
346348
// Return the value in `pri`.
347-
#emit STACK 4
349+
#emit STACK __cellbytes
348350
#emit RETN
349351
}
350352
return 0;
@@ -380,9 +382,10 @@ native numpubvars();
380382
*/
381383
stock numpubvars()
382384
{
385+
const __cellbytes = cellbits / charbits;
383386
// In 32-bit scripts this is `64`, but in 64-bit scripts it is only `96`. Part of the header
384387
// entry is always 32-bit, regardless of the cell bit width. We need it in bytes.
385-
const __defsize = cellbits / charbits + 4;
388+
const __defsize = __cellbytes + 4;
386389
new __start, __end;
387390
// Now we start doing assembly magic to dig through the AMX header itself.
388391
// Get the offset from the start of the file to the start of the data segment (DAT).

0 commit comments

Comments
 (0)