可能有人解释__declspec(裸体)吗? [英] Could someone explain __declspec(naked) please?

查看:246
本文介绍了可能有人解释__declspec(裸体)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我寻找到移植的Windows到Linux编写的脚本引擎;它是Winamp的可视化平台AVS。我不知道这是否在目前甚至有可能。从我可以告诉code正在采取的C函数的地址 nseel_asm_atan nseel_asm_atan_end 键,将它们存储在表内,它可以code执行过程中参考。

我看了MS的文档,但我不能确定什么 __ declspec(裸)确实。什么是文件中提及的序言和结语code?是与Windows调用约定?这是便携式?使用类似技术的基于Linux的事例?

 静态双(* __ ATAN)(双)=&安培; ATAN;
__declspec(裸体)无效nseel_asm_atan(无效)
{
  FUNC1_ENTER  * __ nextBlock = __atan(* parm_a);  FUNC_LEAVE
}
__declspec(裸体)无效nseel_asm_atan_end(无效){}


解决方案

基本上函数序言设置局部变量堆栈帧和结语需要清除它的照顾。这通常是由编译器自动完成。如果你使用 __ declspec(裸),设立这个堆栈帧将高达你,它给你更多的灵活性。

有许多参考资料:这里这里,<一个href=\"http://stackoverflow.com/questions/886836/writing-naked-functions-with-custom-prolog-and-epilog-$c$c-in-visual-studio\">also这里多。

在GNU gcc编译器还支持裸,但显然不是针对x86:搜索在页面裸(我还没有尝试,看看它是否适用于x86)的

I'm looking into porting a script engine written for Windows to Linux; it's for Winamp's visualization platform AVS. I'm not sure if it's even possible at the moment. From what I can tell the code is taking the addresses of the C functions nseel_asm_atan and nseel_asm_atan_end and storing them inside a table that it can reference during code execution.

I've looked at MS's documentation, but I'm unsure what __declspec(naked) really does. What is prolog and epilog code mentioned in the documentation? Is that related to Windows calling conventions? Is this portable? Know of any Linux-based examples using similar techniques?

static double (*__atan)(double) = &atan;
__declspec ( naked ) void nseel_asm_atan(void)
{
  FUNC1_ENTER

  *__nextBlock = __atan(*parm_a);

  FUNC_LEAVE
}
__declspec ( naked ) void nseel_asm_atan_end(void) {}

解决方案

Basically the function prologue sets up a stack frame for local variables and the epilogue takes care of cleaning it up. This is usually done automatically by the compiler. If you use __declspec(naked), setting up this stack frame will be up to you so it gives you more flexibility.

There are many references: here , here, also here and more.

The GNU gcc compiler also supports naked, but apparently not for x86: search for "naked" in the page (I haven't tried to see if it works on x86)

这篇关于可能有人解释__declspec(裸体)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆