source: trunk/libs/newlib/src/newlib/libm/machine/spu/headers/tgamma.h

Last change on this file was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 789 bytes
Line 
1#include <errno.h>
2#include "headers/truncd2.h"
3#include "headers/tgammad2.h"
4
5static __inline double _tgamma(double x)
6{
7  double res;
8  vector double vx;
9  vector double truncx;
10  vector double vc = { 0.0, 0.0 };
11  vector unsigned long long cmpres;
12  vector signed int verrno, ferrno;
13  vector signed int fail = { EDOM, EDOM, EDOM, EDOM };
14
15  vx = spu_promote(x, 0);
16  res = spu_extract(_tgammad2(vx), 0);
17
18#ifndef _IEEE_LIBM
19  /*
20   * use vector truncd2 rather than splat x, and splat truncx.
21   */
22  truncx = _truncd2(vx);
23  cmpres = spu_cmpeq(truncx, vx);
24  verrno = spu_splats(errno);
25  ferrno = spu_sel(verrno, fail, (vector unsigned int) cmpres);
26  cmpres = spu_cmpgt(vc, vx);
27  errno = spu_extract(spu_sel(verrno, ferrno, (vector unsigned int) cmpres), 0);
28#endif
29  return res;
30}
Note: See TracBrowser for help on using the repository browser.