Unity3D mono arm 非要吃中斷 33
來源:程序員人生 發(fā)布時(shí)間:2015-04-01 08:18:02 閱讀次數(shù):3535次
現(xiàn)在也不到有多少游戲是 Unity3D 寫的
操作倒是很省事,在Unity中寫了程序,直接生成了 Android的 APK
但內(nèi)部其實(shí)還是聽復(fù)雜的,對用 C#生成的腳本需要用 mono 來解釋履行
而Android利用本來就是運(yùn)行在Dalvik Java 虛擬機(jī), 就是經(jīng)過了兩層 runtime 才運(yùn)行
不過我們更”變態(tài)“,我們想在qemu-arm ( 主機(jī)是x86) 中運(yùn)行帶 mono 的Unity程序
結(jié)果遇到個(gè)問題
mono 報(bào)錯(cuò)
mono : * Assertion at mini-posix.c:382, condition `sigaction (signo, &sa, &previous_sa) != ⑴' not met
加 log 發(fā)現(xiàn)是設(shè)置 中斷 33 出現(xiàn)的問題
========
do_sigaction sig 33 host_sig 33 ret ⑴
02⑴0 03:54:43.441 147 186 F mono : * Assertion at mini-posix.c:382, condition `sigaction (signo, &sa, &previous_sa)
!= ⑴' not met
編寫了1個(gè)小程序 pnp5 直接截取中斷 33 出錯(cuò)
$ LD_LIBRARY_PATH=./system/bionic_arm/system/lib ./system/target_libc/system/bin/qemu-arm ./system/bionic_arm/system/bin/pnp5
sigaction 33 return ⑴
用glibc編譯此程序運(yùn)行也出錯(cuò)
應(yīng)當(dāng)是Ubuntu Linux 不讓 設(shè)置 中斷
33
不過既然 Unity 這么流行,不可能就這樣出錯(cuò),在arm手機(jī)實(shí)驗(yàn)
用NDK編譯此程序,竟然沒有出錯(cuò)

因此在Android的 linux中, 中斷 33是允許設(shè)置的
程序清單
payne@payne-desktop:~/pnp/pnp5$ cat Android.mk
#ifeq ($(TARGET_ARCH),arm)
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:=
main.c
LOCAL_MODULE:= pnp5
LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
#endif
payne@payne-desktop:~/pnp/pnp5$ cat main.c
#include <signal.h>
#include <stdio.h>
void
termination_handler (int signum)
{
/*
struct temp_file *p;
for (p = temp_file_list; p; p = p->next)
unlink (p->name);
*/
}
int
main (void)
{
struct sigaction new_action, old_action;
int my_singals[9] = { 4,6,7,8,11,16,13,34,33 };
int i=0;
/* Set up the structure to specify the new action. */
new_action.sa_handler = termination_handler;
sigemptyset (&new_action.sa_mask);
new_action.sa_flags = 0;
for ( i=0; i<9; i++ )
printf(" sigaction %d return %d
",my_singals[i], sigaction(my_singals[i], &new_action, &old_action));
return 0;
}
另外 Unity 生成的 x86 lib是可以在Ubuntu Linux 下跑得,所以只有 mono-arm 的庫才設(shè)置中斷 33
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)