简体   繁体   English

在glibc中哪里可以找到数学函数ceil()的源代码?

[英]Where to find the source code of math function ceil() in glibc?

I have downloaded glibc's source code, and find the function ceil() for a long time, but I cannot find it, who can tell me where is it? 我已经下载了glibc的源代码,并找到了功能ceil()很长时间了,但是我找不到它,谁能告诉我它在哪里?

And where can I find some detailed information about how to find certain function's source code in glibc's source. 在哪里可以找到有关如何在glibc的源代码中找到某些函数的源代码的详细信息。

Thank you. 谢谢。

At a guess, it's probably written in assembly language. 大概是用汇编语言编写的。 It's basically done in three steps: 基本上可以通过三个步骤完成:

  1. Change rounding mode to "round up" 将舍入模式更改为“舍入”
  2. round to integer (FRNDINT) 舍入到整数(FRNDINT)
  3. restore previous rounding mode. 恢复以前的舍入模式。

Unfortunately, the code to change the rounding mode is fairly ugly. 不幸的是,更改取整模式的代码相当丑陋。 The rounding mode is a few bits in the floating point control register. 舍入模式是浮点控制寄存器中的几位。 You can't change the FPCR inside the FPU, so you have to store it, then load it into a register on the CPU, modify some bits, store that, and load the modified version back into the FPU. 您不能在FPU内更改FPCR,因此您必须先存储它,然后将其加载到CPU上的寄存器中,修改一些位,进行存储,然后将修改后的版本加载回FPU中。 Then you execute one FP instruction, and do the same again, but in reverse. 然后,您执行一条FP指令,然后再次执行相同的操作,但是相反。

I do seem to recall some of Intel's literature years ago talking about this, and (perhaps) talking about a better way to handle it -- but I could be imagining that, and even if I'm not, I don't remember how their improved version worked. 我似乎确实想起了几年前英特尔的一些文献,并且(也许)在谈论一种更好的处理方法-但我可能在想像中,即使不是,我也不记得如何他们的改进版本有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM