由於與NDK12和NDK13b2,我在想「移植」 libx264的使用信號()(和ndk12失蹤bsd_signal())的使用的sigaction(),而不是發現最近出現的問題。如何將signal()移植到sigaction()?
問題是,我不太清楚簡單的&什麼是用sigaction()來代替signal()調用的最快方法。使用以下信號處理程序
:
static void sigill_handler(int sig)
{
if(!canjump)
{
signal(sig, SIG_DFL);
raise(sig);
}
canjump = 0;
siglongjmp(jmpbuf, 1);
}
這是有問題的x264_cpu_detect
功能
對於所有的i看到的,它主要用於X264快照/普通/ cpu.c以下面的方式...目前,我猜我只需要解決ARM版本,但我';;仍然必須替換所有signal()
與sigaction()
發生,所以我可能只是涵蓋他們兩個,以獲得東西建設...
僅供參考 - NDK13 beta2仍然有「不穩定的」libc和構建不會失敗部分,而是第一次調用其他地方的rand()
函數......所以我運氣不佳,取代signal()調用可能比僅僅等待官方NDK13版本更好。我這樣做是爲了擺脫文本重定位的,所以我可以在API 24(安卓N)
的功能有問題的部分調用signal()
運行庫(和doubango):
#elif SYS_LINUX
uint32_t x264_cpu_detect(void)
{
static void (*oldsig)(int);
oldsig = signal(SIGILL, sigill_handler);
if(sigsetjmp(jmpbuf, 1))
{
signal(SIGILL, oldsig);
return 0;
}
canjump = 1;
asm volatile("mtspr 256, %0\n\t"
"vand 0, 0, 0\n\t"
:
: "r"(-1));
canjump = 0;
signal(SIGILL, oldsig);
return X264_CPU_ALTIVEC;
}
#endif
#elif ARCH_ARM
void x264_cpu_neon_test(void);
int x264_cpu_fast_neon_mrc_test(void);
uint32_t x264_cpu_detect(void)
{
int flags = 0;
#if HAVE_ARMV6
flags |= X264_CPU_ARMV6;
// don't do this hack if compiled with -mfpu=neon
#if !HAVE_NEON
static void (* oldsig)(int);
oldsig = signal(SIGILL, sigill_handler);
if(sigsetjmp(jmpbuf, 1))
{
signal(SIGILL, oldsig);
return flags;
}
canjump = 1;
x264_cpu_neon_test();
canjump = 0;
signal(SIGILL, oldsig);
#endif
flags |= X264_CPU_NEON;
// fast neon -> arm (Cortex-A9) detection relies on user access to the
// cycle counter; this assumes ARMv7 performance counters.
// NEON requires at least ARMv7, ARMv8 may require changes here, but
// hopefully this hacky detection method will have been replaced by then.
// Note that there is potential for a race condition if another program or
// x264 instance disables or reinits the counters while x264 is using them,
// which may result in incorrect detection and the counters stuck enabled.
// right now Apple does not seem to support performance counters for this test
#ifndef __MACH__
flags |= x264_cpu_fast_neon_mrc_test() ? X264_CPU_FAST_NEON_MRC : 0;
#endif
// TODO: write dual issue test? currently it's A8 (dual issue) vs. A9 (fast mrc)
#endif
return flags;
}
#else
uint32_t x264_cpu_detect(void)
{
return 0;
}
所以問題是這樣的:在保留當前功能的同時,用sigaction()
替換signal()
調用的最快/最簡單//最快的方式是什麼?
編輯: 我試圖擺脫signal()
原因是這些編譯錯誤:
/home/devshark/SCRATCH/doubango/thirdparties/android/armv5te/lib/dist/libx264.a(cpu.o):cpu.c:function sigill_handler: error: undefined reference to 'bsd_signal'
/home/devshark/SCRATCH/doubango/thirdparties/android/armv5te/lib/dist/libx264.a(cpu.o):cpu.c:function x264_cpu_detect: error: undefined reference to 'bsd_signal'
/home/devshark/SCRATCH/doubango/thirdparties/android/armv5te/lib/dist/libx264.a(cpu.o):cpu.c:function x264_cpu_detect: error: undefined reference to 'bsd_signal'
/home/devshark/SCRATCH/doubango/thirdparties/android/armv5te/lib/dist/libx264.a(cpu.o):cpu.c:function x264_cpu_detect: error: undefined reference to 'bsd_signal'
我已經知道這是一個已知的問題NDK12,這可能通過將bsd_signal
回要解決NDK13中的libc。然而,在它處於測試狀態的libc不穩定的情況下 - 它目前缺少rand()函數,只是等待它可能無法實現。但在最糟糕的情況下,我想我只能等待它並在發佈後重試。
但由於它目前是,我想使用該庫的預建版本有文本的遷移,以及正在運行新的API /版本的Android操作系統的手機拒絕。
EDIT2: 我也知道signal()
通常作品引擎蓋下使用sigaction()
,但也許我不會bsd_signal相關的建立,錯誤...因爲我懷疑,這其中ISN」使用它。它使用bsd_signal明顯,這可能是也可能不是同一個基礎的東西:/
'signal()'究竟有什麼問題?你爲什麼想擺脫它? – Sergio
由於NDK12沒有定義'bsd_signal'符號並引發編輯中提到的構建錯誤。 TL; DR =因爲它會導致構建錯誤。 – Shark
但是你不在示例代碼中使用'bsd_signal()',那麼它與你的問題有什麼關係? –