Debian Codegraph @

include/ruby/internal/arithmetic/intptr_t.h

raw
1 #ifndef RBIMPL_ARITHMETIC_INTPTR_T_H /*-*-C++-*-vi:se ft=cpp:*/
2 #define RBIMPL_ARITHMETIC_INTPTR_T_H
3 /**
4 * @file
5 * @author Ruby developers <[email protected]>
6 * @copyright This file is a part of the programming language Ruby.
7 * Permission is hereby granted, to either redistribute and/or
8 * modify this file, provided that the conditions mentioned in the
9 * file COPYING are met. Consult the file for details.
10 * @warning Symbols prefixed with either `RBIMPL` or `rbimpl` are
11 * implementation details. Don't take them as canon. They could
12 * rapidly appear then vanish. The name (path) of this header file
13 * is also an implementation detail. Do not expect it to persist
14 * at the place it is now. Developers are free to move it anywhere
15 * anytime at will.
16 * @note To ruby-core: remember that this header can be possibly
17 * recursively included from extension libraries written in C++.
18 * Do not expect for instance `__VA_ARGS__` is always available.
19 * We assume C99 for ruby itself but we don't assume languages of
20 * extension libraries. They could be written in C++98.
21 * @brief Arithmetic conversion between C's `intptr_t` and Ruby's.
22 */
23 #include "ruby/internal/config.h"
24
25 #ifdef HAVE_STDINT_H
26 # include <stdint.h>
27 #endif
28
29 #include "ruby/internal/value.h"
30 #include "ruby/internal/dllexport.h"
31
32 #define rb_int_new rb_int2inum /**< @alias{rb_int2inum} */
33 #define rb_uint_new rb_uint2inum /**< @alias{rb_uint2inum} */
34
35 RBIMPL_SYMBOL_EXPORT_BEGIN()
36
37 /**
38 * Converts a C's `intptr_t` into an instance of ::rb_cInteger.
39 *
40 * @param[in] i Arbitrary `intptr_t` value.
41 * @return An instance of ::rb_cInteger.
42 * @note This function always allocates Bignums, even if the given number
43 * is small enough to fit into a Fixnum.
44 */
45 VALUE rb_int2big(intptr_t i);
46
47 /**
48 * Converts a C's `intptr_t` into an instance of ::rb_cInteger.
49 *
50 * @param[in] i Arbitrary `intptr_t` value.
51 * @return An instance of ::rb_cInteger.
52 */
53 VALUE rb_int2inum(intptr_t i);
54
55 /**
56 * Converts a C's `intptr_t` into an instance of ::rb_cInteger.
57 *
58 * @param[in] i Arbitrary `intptr_t` value.
59 * @return An instance of ::rb_cInteger.
60 * @note This function always allocates Bignums, even if the given number
61 * is small enough to fit into a Fixnum.
62 */
63 VALUE rb_uint2big(uintptr_t i);
64
65 /**
66 * Converts a C's `uintptr_t` into an instance of ::rb_cInteger.
67 *
68 * @param[in] i Arbitrary `uintptr_t` value.
69 * @return An instance of ::rb_cInteger.
70 */
71 VALUE rb_uint2inum(uintptr_t i);
72 RBIMPL_SYMBOL_EXPORT_END()
73
74 #endif /* RBIMPL_ARITHMETIC_INTPTR_T_H */