看板mud
标 题[文件] MudOS 的 runtime configuration file 设定内容修正
发信站交大资工凤凰城资讯站 (Wed Mar 1 20:00:21 2006)
转信站ptt!ctu-reader!Spring!news.nctu!news.ntu!news.ee.ttu!netnews.csie.nctu
版本: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