ruby-changes:66041
From: Benoit <ko1@a...>
Date: Tue, 4 May 2021 21:57:15 +0900 (JST)
Subject: [ruby-changes:66041] 68d6bd0873 (master): Fix trivial -Wundef warnings
https://git.ruby-lang.org/ruby.git/commit/?id=68d6bd0873 From 68d6bd0873557c12bec6f8e0f8db622f1499d8a7 Mon Sep 17 00:00:00 2001 From: Benoit Daloze <eregontp@g...> Date: Thu, 29 Apr 2021 14:31:05 +0200 Subject: Fix trivial -Wundef warnings * See [Feature #17752] Co-authored-by: xtkoba (Tee KOBAYASHI) <xtkoba+ruby@g...> --- builtin.c | 2 +- builtin.h | 2 +- dir.c | 2 +- eval_intern.h | 2 +- gc.c | 2 +- hash.c | 2 +- include/ruby/internal/attr/const.h | 2 +- memory_view.c | 4 ++-- ractor_core.h | 2 +- ruby.c | 2 +- template/sizes.c.tmpl | 2 +- thread_pthread.h | 2 +- tool/mk_builtin_loader.rb | 2 +- vm.c | 2 +- vm_core.h | 8 ++++---- vm_exec.c | 2 ++ 16 files changed, 21 insertions(+), 19 deletions(-) diff --git a/builtin.c b/builtin.c index 7c3653d..21fff95 100644 --- a/builtin.c +++ b/builtin.c @@ -3,7 +3,7 @@ https://github.com/ruby/ruby/blob/trunk/builtin.c#L3 #include "iseq.h" #include "builtin.h" -#if CROSS_COMPILING +#ifdef CROSS_COMPILING #define INCLUDED_BY_BUILTIN_C 1 #include "mini_builtin.c" diff --git a/builtin.h b/builtin.h index 3b2f477..5b4bda1 100644 --- a/builtin.h +++ b/builtin.h @@ -65,7 +65,7 @@ PUREFUNC(static inline VALUE rb_vm_lvar(rb_execution_context_t *ec, int index)); https://github.com/ruby/ruby/blob/trunk/builtin.h#L65 static inline VALUE rb_vm_lvar(rb_execution_context_t *ec, int index) { -#if VM_CORE_H_EC_DEFINED +#if defined(VM_CORE_H_EC_DEFINED) && VM_CORE_H_EC_DEFINED return ec->cfp->ep[index]; #else return rb_vm_lvar_exposed(ec, index); diff --git a/dir.c b/dir.c index 8ff812e..fb31bd4 100644 --- a/dir.c +++ b/dir.c @@ -216,7 +216,7 @@ typedef enum { https://github.com/ruby/ruby/blob/trunk/dir.c#L216 #else #define FNM_SYSCASE 0 #endif -#if _WIN32 +#ifdef _WIN32 #define FNM_SHORTNAME 0x20 #else #define FNM_SHORTNAME 0 diff --git a/eval_intern.h b/eval_intern.h index 3238df1..475fd4d 100644 --- a/eval_intern.h +++ b/eval_intern.h @@ -144,7 +144,7 @@ LONG WINAPI rb_w32_stack_overflow_handler(struct _EXCEPTION_POINTERS *); https://github.com/ruby/ruby/blob/trunk/eval_intern.h#L144 #define EC_REPUSH_TAG() (void)(_ec->tag = &_tag) -#if defined __GNUC__ && __GNUC__ == 4 && (__GNUC_MINOR__ >= 6 && __GNUC_MINOR__ <= 8) || __clang__ +#if defined __GNUC__ && __GNUC__ == 4 && (__GNUC_MINOR__ >= 6 && __GNUC_MINOR__ <= 8) || defined __clang__ /* This macro prevents GCC 4.6--4.8 from emitting maybe-uninitialized warnings. * This macro also prevents Clang from dumping core in EC_EXEC_TAG(). * (I confirmed Clang 4.0.1 and 5.0.0.) diff --git a/gc.c b/gc.c index 1507be6..4eb5488 100644 --- a/gc.c +++ b/gc.c @@ -830,7 +830,7 @@ enum { https://github.com/ruby/ruby/blob/trunk/gc.c#L830 }; #define HEAP_PAGE_ALIGN (1 << HEAP_PAGE_ALIGN_LOG) #define HEAP_PAGE_SIZE HEAP_PAGE_ALIGN -#if defined(HAVE_MMAP) && (PAGE_SIZE <= HEAP_PAGE_SIZE) +#if defined(HAVE_MMAP) && (!defined(PAGE_SIZE) || PAGE_SIZE <= HEAP_PAGE_SIZE) # define USE_MMAP_ALIGNED_ALLOC 1 #else # define USE_MMAP_ALIGNED_ALLOC 0 diff --git a/hash.c b/hash.c index 000e816..ce0e72a 100644 --- a/hash.c +++ b/hash.c @@ -800,7 +800,7 @@ ar_force_convert_table(VALUE hash, const char *file, int line) https://github.com/ruby/ruby/blob/trunk/hash.c#L800 if (RHASH_AR_TABLE(hash)) { unsigned i, bound = RHASH_AR_TABLE_BOUND(hash); -#if RHASH_CONVERT_TABLE_DEBUG +#if defined(RHASH_CONVERT_TABLE_DEBUG) && RHASH_CONVERT_TABLE_DEBUG rb_obj_info_dump(hash); fprintf(stderr, "force_convert: %s:%d\n", file, line); RB_DEBUG_COUNTER_INC(obj_hash_force_convert); diff --git a/include/ruby/internal/attr/const.h b/include/ruby/internal/attr/const.h index b1f27e2..c9e8577 100644 --- a/include/ruby/internal/attr/const.h +++ b/include/ruby/internal/attr/const.h @@ -37,7 +37,7 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/attr/const.h#L37 #endif /** Enables #RBIMPL_ATTR_CONST if and only if. ! #RUBY_DEBUG. */ -#if !RUBY_DEBUG +#if !defined(RUBY_DEBUG) || !RUBY_DEBUG # define RBIMPL_ATTR_CONST_UNLESS_DEBUG() RBIMPL_ATTR_CONST() #else # define RBIMPL_ATTR_CONST_UNLESS_DEBUG() /* void */ diff --git a/memory_view.c b/memory_view.c index ce28037..9609eca 100644 --- a/memory_view.c +++ b/memory_view.c @@ -671,7 +671,7 @@ extract_item_member(const uint8_t *ptr, const rb_memory_view_item_component_t *m https://github.com/ruby/ruby/blob/trunk/memory_view.c#L671 return LL2NUM(val.ll); } else { -#if SIZEOF_INT64_t == SIZEOF_LONG +#if SIZEOF_INT64_T == SIZEOF_LONG return LONG2NUM(val.i64); #else return LL2NUM(val.i64); @@ -683,7 +683,7 @@ extract_item_member(const uint8_t *ptr, const rb_memory_view_item_component_t *m https://github.com/ruby/ruby/blob/trunk/memory_view.c#L683 return ULL2NUM(val.ull); } else { -#if SIZEOF_UINT64_t == SIZEOF_LONG +#if SIZEOF_UINT64_T == SIZEOF_LONG return ULONG2NUM(val.u64); #else return ULL2NUM(val.u64); diff --git a/ractor_core.h b/ractor_core.h index fb104cd..63279eb 100644 --- a/ractor_core.h +++ b/ractor_core.h @@ -261,7 +261,7 @@ static inline void https://github.com/ruby/ruby/blob/trunk/ractor_core.h#L261 rb_ractor_set_current_ec(rb_ractor_t *cr, rb_execution_context_t *ec) { #ifdef RB_THREAD_LOCAL_SPECIFIER - #if __APPLE__ + #ifdef __APPLE__ rb_current_ec_set(ec); #else ruby_current_ec = ec; diff --git a/ruby.c b/ruby.c index 21c2daa..9ca7c2a 100644 --- a/ruby.c +++ b/ruby.c @@ -1826,7 +1826,7 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1826 opt->script_name = rb_str_new_cstr(opt->script); opt->script = RSTRING_PTR(opt->script_name); -#if _WIN32 +#ifdef _WIN32 translit_char_bin(RSTRING_PTR(opt->script_name), '\\', '/'); #elif defined DOSISH translit_char(RSTRING_PTR(opt->script_name), '\\', '/'); diff --git a/template/sizes.c.tmpl b/template/sizes.c.tmpl index 848a29f..31060f5 100644 --- a/template/sizes.c.tmpl +++ b/template/sizes.c.tmpl @@ -43,7 +43,7 @@ Init_sizeof(void) https://github.com/ruby/ruby/blob/trunk/template/sizes.c.tmpl#L43 % next % end % cond = conditions[type] -#if SIZEOF_<%= type.tr_cpp %> != 0<%= " && #{cond}" if cond %> +#if defined(SIZEOF_<%= type.tr_cpp %>) && SIZEOF_<%= type.tr_cpp %> != 0<%= " && #{cond}" if cond %> DEFINE(<%= type %>, <%= type.tr_cpp %>); #endif % end diff --git a/thread_pthread.h b/thread_pthread.h index 1d6ea13..8b7583d 100644 --- a/thread_pthread.h +++ b/thread_pthread.h @@ -100,7 +100,7 @@ native_tls_set(native_tls_key_t key, void *ptr) https://github.com/ruby/ruby/blob/trunk/thread_pthread.h#L100 RUBY_SYMBOL_EXPORT_BEGIN #ifdef RB_THREAD_LOCAL_SPECIFIER - #if __APPLE__ + #ifdef __APPLE__ // on Darwin, TLS can not be accessed across .so struct rb_execution_context_struct *rb_current_ec(); void rb_current_ec_set(struct rb_execution_context_struct *); diff --git a/tool/mk_builtin_loader.rb b/tool/mk_builtin_loader.rb index c1d2376..309ff61 100644 --- a/tool/mk_builtin_loader.rb +++ b/tool/mk_builtin_loader.rb @@ -343,7 +343,7 @@ def mk_builtin_header file https://github.com/ruby/ruby/blob/trunk/tool/mk_builtin_loader.rb#L343 f.puts f.puts " // arity_check" f.puts "COMPILER_WARNING_PUSH" - f.puts "#if GCC_VERSION_SINCE(5, 1, 0) || __clang__" + f.puts "#if GCC_VERSION_SINCE(5, 1, 0) || defined __clang__" f.puts "COMPILER_WARNING_ERROR(-Wincompatible-pointer-types)" f.puts "#endif" bs.each{|func, (argc, cfunc_name)| diff --git a/vm.c b/vm.c index 8c62d7d..ea8b21e 100644 --- a/vm.c +++ b/vm.c @@ -3262,7 +3262,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/vm.c#L3262 nsdr(VALUE self) { VALUE ary = rb_ary_new(); -#if HAVE_BACKTRACE +#ifdef HAVE_BACKTRACE #include <execinfo.h> #define MAX_NATIVE_TRACE 1024 static void *trace[MAX_NATIVE_TRACE]; diff --git a/vm_core.h b/vm_core.h index f21d850..72120d5 100644 --- a/vm_core.h +++ b/vm_core.h @@ -670,7 +670,7 @@ typedef struct rb_vm_struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L670 #endif const struct rb_callcache *global_cc_cache_table[VM_GLOBAL_CC_CACHE_TABLE_SIZE]; // vm_eval.c -#if USE_VM_CLOCK +#if defined(USE_VM_CLOCK) && USE_VM_CLOCK uint32_t clock; #endif @@ -870,7 +870,7 @@ struct rb_execution_context_struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L870 /* interrupt flags */ rb_atomic_t interrupt_flag; rb_atomic_t interrupt_mask; /* size should match flag */ -#if USE_VM_CLOCK +#if defined(USE_VM_CLOCK) && USE_VM_CLOCK uint32_t checked_clock; #endif @@ -1804,7 +1804,7 @@ static inline rb_execution_context_t * https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1804 rb_current_execution_context(void) { #ifdef RB_THREAD_LOCAL_SPECIFIER - #if __APPLE__ + #ifdef __APPLE__ rb_execution_context_t *ec = rb_current_ec(); #else rb_execution_context_t *ec = ruby_current_ec; @@ -1891,7 +1891,7 @@ enum { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L1891 static inline bool RUBY_VM_INTERRUPTED_ANY(rb_execution_context_t *ec) { -#if USE_VM_CLOCK +#if defined(USE_VM_CLOCK) && USE_VM_CLOCK uint32_t current_clock = rb_ec_vm_ptr(ec)->clock; if (current_clock != ec->checked_clock) { diff --git a/vm_exec.c b/vm_exec.c index 7aa56f6..305ff90 100644 --- a/vm_exec.c +++ b/vm_exec.c @@ -104,6 +104,8 @@ vm_exec_core(rb_execution_context_t *ec, VALUE initial) https://github.com/ruby/ruby/blob/trunk/vm_exec.c#L104 #else register rb_control_frame_t *reg_cfp; const VALUE *reg_pc; +#define USE_MACHINE_REGS 0 + #endif (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/