static void LoadHeader (LoadState* S) { int version; lua_Number x,tx=TEST_NUMBER; LoadSignature(S); version=LoadByte(S); if (version>VERSION) luaG_runerror(S->L,"%s too new: " "read version %d.%d; expected at most %d.%d", S->name,V(version),V(VERSION)); if (version<VERSION0) /* check last major change */ luaG_runerror(S->L,"%s too old: " "read version %d.%d; expected at least %d.%d", S->name,V(version),V(VERSION0)); S->swap=(luaU_endianness()!=LoadByte(S)); /* need to swap bytes? */ TESTSIZE(sizeof(int),"int"); TESTSIZE(sizeof(size_t), "size_t"); TESTSIZE(sizeof(Instruction), "Instruction"); TESTSIZE(SIZE_OP, "OP"); TESTSIZE(SIZE_A, "A"); TESTSIZE(SIZE_B, "B"); TESTSIZE(SIZE_C, "C"); TESTSIZE(sizeof(lua_Number), "number"); x=LoadNumber(S); if ((long)x!=(long)tx) /* disregard errors in last bits of fraction */ luaG_runerror(S->L,"unknown number format in %s",S->name); }
static void DumpHeader(DumpState* D) { DumpLiteral(LUA_SIGNATURE,D); DumpByte(VERSION,D); DumpByte(luaU_endianness(),D); DumpByte(sizeof(int),D); DumpByte(sizeof(size_t),D); DumpByte(sizeof(Instruction),D); DumpByte(SIZE_OP,D); DumpByte(SIZE_A,D); DumpByte(SIZE_B,D); DumpByte(SIZE_C,D); DumpByte(sizeof(lua_Number),D); DumpNumber(TEST_NUMBER,D); }