11#define RUBY_DEFINES_H 1
13#if defined(__cplusplus)
20#include "ruby/config.h"
22#include RUBY_EXTCONF_H
27# define CONSTFUNC(x) x
33# define DEPRECATED(x) x
36# define DEPRECATED_BY(n,x) DEPRECATED(x)
38#ifndef DEPRECATED_TYPE
39# define DEPRECATED_TYPE(mesg, decl) decl
41#ifndef RUBY_CXX_DEPRECATED
42# define RUBY_CXX_DEPRECATED(mesg)
48# define ALWAYS_INLINE(x) x
51# define HAVE_ATTRIBUTE_ERRORFUNC 0
52# define ERRORFUNC(mesg, x) x
54# define HAVE_ATTRIBUTE_ERRORFUNC 1
57# define HAVE_ATTRIBUTE_WARNINGFUNC 0
58# define WARNINGFUNC(mesg, x) x
60# define HAVE_ATTRIBUTE_WARNINGFUNC 1
63#ifndef GCC_VERSION_SINCE
64# if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
65# define GCC_VERSION_SINCE(major, minor, patchlevel) \
66 ((__GNUC__ > (major)) || \
67 ((__GNUC__ == (major) && \
68 ((__GNUC_MINOR__ > (minor)) || \
69 (__GNUC_MINOR__ == (minor) && __GNUC_PATCHLEVEL__ >= (patchlevel))))))
71# define GCC_VERSION_SINCE(major, minor, patchlevel) 0
74#ifndef GCC_VERSION_BEFORE
75# if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
76# define GCC_VERSION_BEFORE(major, minor, patchlevel) \
77 ((__GNUC__ < (major)) || \
78 ((__GNUC__ == (major) && \
79 ((__GNUC_MINOR__ < (minor)) || \
80 (__GNUC_MINOR__ == (minor) && __GNUC_PATCHLEVEL__ <= (patchlevel))))))
82# define GCC_VERSION_BEFORE(major, minor, patchlevel) 0
88#define RB_LIKELY(x) (__builtin_expect(!!(x), 1))
89#define RB_UNLIKELY(x) (__builtin_expect(!!(x), 0))
91#define RB_LIKELY(x) (x)
92#define RB_UNLIKELY(x) (x)
99#if defined(__clang__) || GCC_VERSION_SINCE(4, 3, 0)
100#define COLDFUNC __attribute__((cold))
106#if defined __MINGW_PRINTF_FORMAT
107#define PRINTF_ARGS(decl, string_index, first_to_check) \
108 decl __attribute__((format(__MINGW_PRINTF_FORMAT, string_index, first_to_check)))
110#define PRINTF_ARGS(decl, string_index, first_to_check) \
111 decl __attribute__((format(printf, string_index, first_to_check)))
114#define PRINTF_ARGS(decl, string_index, first_to_check) decl
118#define RB_GNUC_EXTENSION __extension__
119#define RB_GNUC_EXTENSION_BLOCK(x) __extension__ ({ x; })
121#define RB_GNUC_EXTENSION
122#define RB_GNUC_EXTENSION_BLOCK(x) (x)
127#ifdef HAVE_SYS_TYPES_H
128# include <sys/types.h>
130#ifdef HAVE_SYS_STAT_H
131# include <sys/stat.h>
142# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
150#ifdef HAVE_INTTYPES_H
151# include <inttypes.h>
156#ifdef HAVE_STDALIGN_H
157# include <stdalign.h>
163#ifdef HAVE_SYS_SELECT_H
164# include <sys/select.h>
167#ifdef RUBY_USE_SETJMPEX
176# ifndef HAVE_PROTOTYPES
177# define HAVE_PROTOTYPES 1
179# ifndef HAVE_STDARG_PROTOTYPES
180# define HAVE_STDARG_PROTOTYPES 1
185#ifdef HAVE_PROTOTYPES
192#ifdef HAVE_STDARG_PROTOTYPES
193# define __(args) args
204#ifndef RUBY_SYMBOL_EXPORT_BEGIN
205# define RUBY_SYMBOL_EXPORT_BEGIN
206# define RUBY_SYMBOL_EXPORT_END
211#define xmalloc ruby_xmalloc
212#define xmalloc2 ruby_xmalloc2
213#define xcalloc ruby_xcalloc
214#define xrealloc ruby_xrealloc
215#define xrealloc2 ruby_xrealloc2
216#define xfree ruby_xfree
218#if GCC_VERSION_SINCE(4,3,0)
219# define RUBY_ATTR_ALLOC_SIZE(params) __attribute__ ((alloc_size params))
220#elif defined(__has_attribute)
221# if __has_attribute(alloc_size)
222# define RUBY_ATTR_ALLOC_SIZE(params) __attribute__((__alloc_size__ params))
225#ifndef RUBY_ATTR_ALLOC_SIZE
226# define RUBY_ATTR_ALLOC_SIZE(params)
229#ifdef __has_attribute
230# if __has_attribute(malloc)
231# define RUBY_ATTR_MALLOC __attribute__((__malloc__))
234#ifndef RUBY_ATTR_MALLOC
235# define RUBY_ATTR_MALLOC
238#ifdef __has_attribute
239# if __has_attribute(returns_nonnull)
240# define RUBY_ATTR_RETURNS_NONNULL __attribute__((__returns_nonnull__))
243#ifndef RUBY_ATTR_RETURNS_NONNULL
244# define RUBY_ATTR_RETURNS_NONNULL
254#ifndef USE_GC_MALLOC_OBJ_INFO_DETAILS
255#define USE_GC_MALLOC_OBJ_INFO_DETAILS 0
258#if USE_GC_MALLOC_OBJ_INFO_DETAILS
266#define ruby_xmalloc(s1) ruby_xmalloc_with_location(s1, __FILE__, __LINE__)
267#define ruby_xmalloc2(s1, s2) ruby_xmalloc2_with_location(s1, s2, __FILE__, __LINE__)
268#define ruby_xcalloc(s1, s2) ruby_xcalloc_with_location(s1, s2, __FILE__, __LINE__)
269#define ruby_xrealloc(ptr, s1) ruby_xrealloc_with_location(ptr, s1, __FILE__, __LINE__)
270#define ruby_xrealloc2(ptr, s1, s2) ruby_xrealloc2_with_location(ptr, s1, s2, __FILE__, __LINE__)
272extern const char *ruby_malloc_info_file;
273extern int ruby_malloc_info_line;
276ruby_xmalloc_with_location(
size_t s,
const char *file,
int line)
279 ruby_malloc_info_file = file;
280 ruby_malloc_info_line = line;
282 ruby_malloc_info_file =
NULL;
287ruby_xmalloc2_with_location(
size_t s1,
size_t s2,
const char *file,
int line)
290 ruby_malloc_info_file = file;
291 ruby_malloc_info_line = line;
293 ruby_malloc_info_file =
NULL;
298ruby_xcalloc_with_location(
size_t s1,
size_t s2,
const char *file,
int line)
301 ruby_malloc_info_file = file;
302 ruby_malloc_info_line = line;
304 ruby_malloc_info_file =
NULL;
309ruby_xrealloc_with_location(
void *
ptr,
size_t s,
const char *file,
int line)
312 ruby_malloc_info_file = file;
313 ruby_malloc_info_line = line;
315 ruby_malloc_info_file =
NULL;
320ruby_xrealloc2_with_location(
void *
ptr,
size_t s1,
size_t s2,
const char *file,
int line)
323 ruby_malloc_info_file = file;
324 ruby_malloc_info_line = line;
326 ruby_malloc_info_file =
NULL;
331#define STRINGIZE(expr) STRINGIZE0(expr)
333#define STRINGIZE0(expr) #expr
337# define HAVE_TRUE_LONG_LONG 1
340#if SIZEOF_LONG_LONG > 0
341# define LONG_LONG long long
342#elif SIZEOF___INT64 > 0
343# define HAVE_LONG_LONG 1
344# define LONG_LONG __int64
345# undef SIZEOF_LONG_LONG
346# define SIZEOF_LONG_LONG SIZEOF___INT64
360# define DOSISH_DRIVE_LETTER
363#ifdef AC_APPLE_UNIVERSAL_BUILD
364#undef WORDS_BIGENDIAN
366#define WORDS_BIGENDIAN
380# error FALSE must be false
385# error TRUE must be true
390#ifndef RUBY_FUNC_EXPORTED
391#define RUBY_FUNC_EXPORTED
396#define MJIT_FUNC_EXPORTED RUBY_FUNC_EXPORTED
397#define MJIT_SYMBOL_EXPORT_BEGIN RUBY_SYMBOL_EXPORT_BEGIN
398#define MJIT_SYMBOL_EXPORT_END RUBY_SYMBOL_EXPORT_END
400#if defined(MJIT_HEADER) && defined(_MSC_VER)
401# undef MJIT_FUNC_EXPORTED
402# define MJIT_FUNC_EXPORTED static
406#define RUBY_EXTERN extern
411# define EXTERN _Pragma("message \"EXTERN is deprecated, use RUBY_EXTERN instead\""); \
413# elif defined _MSC_VER
414# define EXTERN __pragma(message(__FILE__"("STRINGIZE(__LINE__)"): warning: "\
415 "EXTERN is deprecated, use RUBY_EXTERN instead")); \
418# define EXTERN <-<-"EXTERN is deprecated, use RUBY_EXTERN instead"->->
422#ifndef RUBY_MBCHAR_MAXSIZE
423#define RUBY_MBCHAR_MAXSIZE INT_MAX
429# define FLUSH_REGISTER_WINDOWS rb_sparc_flush_register_windows()
431# define FLUSH_REGISTER_WINDOWS ((void)0)
439#define PATH_SEP_CHAR PATH_SEP[0]
441#define PATH_ENV "PATH"
444#define ENV_IGNORECASE
447#ifndef CASEFOLD_FILESYSTEM
449# define CASEFOLD_FILESYSTEM 1
451# define CASEFOLD_FILESYSTEM 0
456#define DLEXT_MAXLEN 4
460#define RUBY_PLATFORM "unknown-unknown"
463#ifndef FUNC_MINIMIZED
464#define FUNC_MINIMIZED(x) x
466#ifndef FUNC_UNOPTIMIZED
467#define FUNC_UNOPTIMIZED(x) x
469#ifndef RUBY_ALIAS_FUNCTION_TYPE
470#define RUBY_ALIAS_FUNCTION_TYPE(type, prot, name, args) \
471 FUNC_MINIMIZED(type prot) {return (type)name args;}
473#ifndef RUBY_ALIAS_FUNCTION_VOID
474#define RUBY_ALIAS_FUNCTION_VOID(prot, name, args) \
475 FUNC_MINIMIZED(void prot) {name args;}
477#ifndef RUBY_ALIAS_FUNCTION
478#define RUBY_ALIAS_FUNCTION(prot, name, args) \
479 RUBY_ALIAS_FUNCTION_TYPE(VALUE, prot, name, args)
481#ifndef RUBY_FUNC_NONNULL
482#define RUBY_FUNC_NONNULL(n, x) x
485#ifndef UNALIGNED_WORD_ACCESS
486# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
487 defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
488 defined(__powerpc64__) || \
489 defined(__aarch64__) || \
491# define UNALIGNED_WORD_ACCESS 1
493# define UNALIGNED_WORD_ACCESS 0
497# define PACKED_STRUCT(x) x
499#ifndef PACKED_STRUCT_UNALIGNED
500# if UNALIGNED_WORD_ACCESS
501# define PACKED_STRUCT_UNALIGNED(x) PACKED_STRUCT(x)
503# define PACKED_STRUCT_UNALIGNED(x) x
508#define RUBY_ALIGNAS(x)
513#elif defined(__cplusplus) && (__cplusplus >= 201103L)
514#define RUBY_ALIGNOF alignof
515#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
516#define RUBY_ALIGNOF _Alignof
518#define RUBY_ALIGNOF(type) ((size_t)offsetof(struct { char f1; type f2; }, f2))
521#define NORETURN_STYLE_NEW 1
524#elif defined(__cplusplus) && (__cplusplus >= 201103L)
525#define NORETURN(x) [[ noreturn ]] x
526#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
527#define NORETURN(x) _Noreturn x
534#if defined(__cplusplus)
#define RUBY_ATTR_ALLOC_SIZE(params)
void * ruby_xrealloc2(void *, size_t, size_t) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2
void void void * ruby_xrealloc(void *, size_t) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2))
void void * ruby_xcalloc(size_t, size_t) RUBY_ATTR_MALLOC RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((1
#define RUBY_ATTR_RETURNS_NONNULL
void * ruby_xmalloc(size_t) RUBY_ATTR_MALLOC RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((1))
void * ruby_xmalloc2(size_t, size_t) RUBY_ATTR_MALLOC RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((1
void void ruby_xfree(void *)
void * ruby_xmalloc2_body(size_t n, size_t size)
void * ruby_xrealloc_body(void *ptr, size_t new_size)
void * ruby_xmalloc_body(size_t size)
void * ruby_xcalloc_body(size_t n, size_t size)
void * ruby_xrealloc2_body(void *ptr, size_t n, size_t size)
void rb_sparc_flush_register_windows(void)