Ruby
2.7.7p221 (2022-11-24 revision 168ec2b1e5ad0e4688e963d9de019557c78feed9)
missing
nan.c
Go to the documentation of this file.
1
#include "
ruby/missing.h
"
2
#include <
assert.h
>
3
#include <stdlib.h>
4
#include <string.h>
5
6
double
7
nan
(
const
char
*spec)
8
{
9
#if 0
10
/* FIXME: we have not yet seen any situation this is
11
* necessary. Please write a proper implementation that
12
* covers this branch. */
13
if
(spec && spec[0]) {
14
double
generated_nan;
15
int
len
=
snprintf
(
NULL
, 0,
"NAN(%s)"
, spec);
16
char
*
buf
=
malloc
(
len
+ 1);
/* +1 for NUL */
17
sprintf
(
buf
,
"NAN(%s)"
, spec);
18
generated_nan =
strtod
(
buf
,
NULL
);
19
free
(
buf
);
20
return
generated_nan;
21
}
22
else
23
#endif
24
{
25
assert
(!spec || !spec[0]);
26
return
(
double
)
NAN
;
27
}
28
}
assert.h
free
#define free(x)
Definition:
dln.c:52
missing.h
nan
double nan(const char *spec)
Definition:
nan.c:7
NULL
#define NULL
Definition:
rb_mjit_min_header-2.7.7.h:11172
sprintf
int sprintf(char *__restrict__, const char *__restrict__,...) __attribute__((__format__(__printf__
malloc
void * malloc(size_t) __attribute__((__malloc__)) __attribute__((__warn_unused_result__)) __attribute__((__alloc_size__(1)))
snprintf
int snprintf(char *__restrict__, size_t, const char *__restrict__,...) __attribute__((__format__(__printf__
len
__inline__ const void *__restrict__ size_t len
Definition:
rb_mjit_min_header-2.7.7.h:3017
NAN
#define NAN
Definition:
rb_mjit_min_header-2.7.7.h:3660
buf
struct rb_call_cache buf
Definition:
rb_mjit_min_header-2.7.7.h:13369
assert
#define assert
Definition:
rb_mjit_min_header-2.7.7.h:9036
strtod
#define strtod(s, e)
Definition:
util.h:76
Generated by
1.9.2