isnan的源代码在哪里? [英] Where is the source code for isnan?

查看:294
本文介绍了isnan的源代码在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于标准的层次,c ++的include文件是一个老鼠巢。我试图找出实际调用的 __ isnan ,并且找不到具有实际定义的任何地方。



所以我只是用-S编写来看看程序集,如果我写:

  #include< ieee754.h> 

void f(double x){
if(__isinf(x)...

if(__isnan(x))...
}

这两个例程都被调用,我想看到实际的定义,可能会重构事情像这样是内联的,因为它应该只是一个比较,虽然当这个值在一个浮点寄存器中时很难实现。



无论如何或者不是一个好主意,问题是:WHERE是 __ isnan(x)的源代码

解决方案

Glibc在 sysdeps 文件夹,它支持的每个系统。你正在寻找的是一个 sysdeps / ieee754 / dbl-64 / s_isnan.c 我发现这个与 git grep __isnan



(虽然C ++头文件)包含模板的代码,C库中的函数不会,您必须查看glibc或任何一个。)


Because of the layers of standards, the include files for c++ are a rats nest. I was trying to figure out what __isnan actually calls, and couldn't find anywhere with an actual definition.

So I just compiled with -S to see the assembly, and if I write:

#include <ieee754.h>

void f(double x) {
  if (__isinf(x) ...

  if (__isnan(x)) ...
}

Both of these routines are called. I would like to see the actual definition, and possibly refactor things like this to be inline, since it should be just a bit comparison, albeit one that is hard to achieve when the value is in a floating point register.

Anyway, whether or not it's a good idea, the question stands: WHERE is the source code for __isnan(x)?

解决方案

Glibc has versions of the code in the sysdeps folder for each of the systems it supports. The one you’re looking for is in sysdeps/ieee754/dbl-64/s_isnan.c. I found this with git grep __isnan.

(While C++ headers include code for templates, functions from the C library will not, and you have to look inside glibc or whichever.)

这篇关于isnan的源代码在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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