[文件] MudOS 的 runtime configuration file 設定內容修正
版本:MudOS v22.2b14
對象:想要使用 LPC->C 這項功能的人
修改內容:
以 ES2 為例,若 runtime configuration file 內原本這段是這樣:
# the file where all global simulated efuns are defined.
simulated efun file : /adm/obj/simul_efun
請修正為這樣:
# the file where all global simulated efuns are defined.
simulated efun file : adm/obj/simul_efun.c
* 開頭的 / 去掉,末端加上 .c。
打算用 LPC->C 的人一定要這樣修改,
否則就算 *.B 檔產生出來也把對應的 C code 編譯進 MudOS,
MudOS 仍然會去吃原本的 LPC code 來跑。
如果 MudOS 是在 AMD64 上用 64-bit mode 在 Linux/FreeBSD 上跑,
請自己想辦法把 MudOS 裡對所有 data type size 的錯誤假設修正為具可攜性的寫法,
最基本要讓它能動作的方式是修改 binaries.c:
244 #ifdef LPC_TO_C
245 program_t *int_load_binary P2(char *, name, lpc_object_t *, lpc_obj)
246 #else
247 program_t *int_load_binary P1(char *, name)
248 #endif
249 {
250 char file_name_buf[400];
251 char *buf, *iname, *file_name = file_name_buf, *file_name_two = &file_name_buf[200];
252 FILE *f;
253 int i, buf_size, ilen;
254 time_t mtime;
255 short len;
256 program_t *p, *prog;
257 object_t *ob;
258 struct stat st;
把 253 行的 i 放到 254 行去,
將它宣告為 time_t,
這是因為 AMD64 下的 time_t 是 64-bit,
然而卻又出現類似下面的 code 假設 sizeof(time_t) == sizeof(int):
308 if ((fread((char *) &i, sizeof i, 1, f) != 1 || driver_id != i)
319 if (fread((char *) &i, sizeof i, 1, f) != 1 || config_id != i) {
C 的 int 在 AMD64 的環境下還是 32-bit,
但是 time_t 已經從 32-bit 變成 64-bit,
所以從檔案讀出來的資料會偏掉,
導致判斷結果不正確。
上面只是舉例不是完整的解決方案,
MudOS 的 code 應該還有不少對 32-bit platform 的假設,
而且 AMD64 不在 MudOS 官方聲明的支援範圍內,
所以請勿亂試,不然出問題就得自己修正了。
--
※ Origin: 交大資工鳳凰城資訊站 <bbs.csie.nctu.edu.tw>
◆ From: 218-171-137-182.dynamic.hinet.net
mud 近期熱門文章
PTT遊戲區 即時熱門文章
44
143