系统调用中断相关,高手请答

wudijuntuan 2012-11-16 04:24:37
在看ace源代码的时候遇到了两个宏
#define ACE_OSCALL_RETURN(X,TYPE,FAILVALUE) \
do \
return (TYPE) (X); \
while (0)
#define ACE_OSCALL(X,TYPE,FAILVALUE,RESULT) \
do \
RESULT = (TYPE) (X); \
while (0)

根据作者的注释:
/**
* ACE_OSCALL* macros
*
* @deprecated ACE_OSCALL_RETURN and ACE_OSCALL should not be used.
* Please restart system calls in your application code.
* See the @c sigaction(2) man page for documentation
* regarding enabling restartable system calls across
* signals via the @c SA_RESTART flag.
*
* The following two macros used ensure that system calls are properly
* restarted (if necessary) when interrupts occur. However, that
* capability was never enabled by any of our supported platforms.
* In fact, some parts of ACE would not function properly when that
* ability was enabled. Furthermore, they assumed that ability to
* restart system calls was determined statically. That assumption
* does not hold for modern platforms, where that ability is
* determined dynamically at run-time.
*/

大概是出于考虑系统调用时遇到中断的异常情况,但没体会到这宏这样设计究竟能起到什么作用,
以下是某处代码对该宏的使用:
ACE_INLINE struct tm *
ACE_OS::gmtime (const time_t *t)
{
ACE_OS_TRACE ("ACE_OS::gmtime");
#if defined (ACE_LACKS_GMTIME)
ACE_UNUSED_ARG (t);
ACE_NOTSUP_RETURN (0);
#else
ACE_OSCALL_RETURN (::gmtime (t), struct tm *, 0);
#endif /* ACE_LACKS_GMTIME */
}


大家说说你的看法
...全文
85 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
转角天边 2012-11-16
  • 打赏
  • 举报
回复
没看过ace,不懂ace,我只能帮顶了

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧