Skip to content

Commit 596126e

Browse files
committed
merge revision(s) b42afa1, f1f0cc1, 543e3a1, ed28061, 46e4c86: [Backport #21500]
Suppress gcc 15 unterminated-string-initialization warnings Separate `__has_attribute` from `defined(__has_attribute)` Fix Visual C warnings: ``` regenc.h(121): warning C4067: unexpected tokens following preprocessor directive - expected a newline ``` Cast up `int` instruction code to `VALUE` Fix Visual C warnings: ``` iseq.c(3793): warning C4312: 'type cast': conversion from 'int' to 'void *' of greater size iseq.c(3794): warning C4312: 'type cast': conversion from 'int' to 'void *' of greater size ``` Do not let files depend on a phony target Detect `clock_gettime` and `clock_getres` for winpthreads
1 parent 782aef1 commit 596126e

File tree

16 files changed

+69
-14
lines changed

16 files changed

+69
-14
lines changed

common.mk

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,10 @@ clean-platform distclean-platform realclean-platform:
854854

855855
RUBYSPEC_CAPIEXT = spec/ruby/optional/capi/ext
856856
RUBYSPEC_CAPIEXT_SRCDIR = $(srcdir)/$(RUBYSPEC_CAPIEXT)
857-
RUBYSPEC_CAPIEXT_DEPS = $(RUBYSPEC_CAPIEXT_SRCDIR)/rubyspec.h $(RUBY_H_INCLUDES) $(LIBRUBY) build-ext
857+
RUBYSPEC_CAPIEXT_DEPS = $(RUBYSPEC_CAPIEXT_SRCDIR)/rubyspec.h $(RUBY_H_INCLUDES) $(LIBRUBY)
858+
859+
rubyspec-capiext: build-ext $(DOT_WAIT)
860+
# make-dependent rules should be included after this and built after build-ext.
858861

859862
clean-spec: PHONY
860863
-$(Q) $(RM) $(RUBYSPEC_CAPIEXT)/*.$(OBJEXT) $(RUBYSPEC_CAPIEXT)/*.$(DLEXT)
@@ -9955,6 +9958,7 @@ marshal.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
99559958
marshal.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
99569959
marshal.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
99579960
marshal.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
9961+
marshal.$(OBJEXT): {$(VPATH)}internal/attr/nonstring.h
99589962
marshal.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
99599963
marshal.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
99609964
marshal.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
@@ -10575,6 +10579,7 @@ miniinit.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
1057510579
miniinit.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
1057610580
miniinit.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
1057710581
miniinit.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
10582+
miniinit.$(OBJEXT): {$(VPATH)}internal/attr/nonstring.h
1057810583
miniinit.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
1057910584
miniinit.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
1058010585
miniinit.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
@@ -17191,6 +17196,7 @@ signal.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
1719117196
signal.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
1719217197
signal.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
1719317198
signal.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
17199+
signal.$(OBJEXT): {$(VPATH)}internal/attr/nonstring.h
1719417200
signal.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
1719517201
signal.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
1719617202
signal.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
@@ -17956,6 +17962,7 @@ string.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
1795617962
string.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
1795717963
string.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
1795817964
string.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
17965+
string.$(OBJEXT): {$(VPATH)}internal/attr/nonstring.h
1795917966
string.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
1796017967
string.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
1796117968
string.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
@@ -18418,6 +18425,7 @@ symbol.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
1841818425
symbol.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
1841918426
symbol.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
1842018427
symbol.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
18428+
symbol.$(OBJEXT): {$(VPATH)}internal/attr/nonstring.h
1842118429
symbol.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
1842218430
symbol.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
1842318431
symbol.$(OBJEXT): {$(VPATH)}internal/attr/pure.h

configure.ac

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,8 +1250,6 @@ main()
12501250
ac_cv_func_gmtime_r=yes
12511251
rb_cv_large_fd_select=yes
12521252
ac_cv_type_struct_timeval=yes
1253-
ac_cv_func_clock_gettime=yes
1254-
ac_cv_func_clock_getres=yes
12551253
ac_cv_func_malloc_usable_size=no
12561254
ac_cv_type_off_t=yes
12571255
ac_cv_sizeof_off_t=8

defs/gmake.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,8 @@ update-deps:
505505

506506
# order-only-prerequisites doesn't work for $(RUBYSPEC_CAPIEXT)
507507
# because the same named directory exists in the source tree.
508-
$(RUBYSPEC_CAPIEXT)/%.$(DLEXT): $(srcdir)/$(RUBYSPEC_CAPIEXT)/%.c $(RUBYSPEC_CAPIEXT_DEPS)
508+
$(RUBYSPEC_CAPIEXT)/%.$(DLEXT): $(srcdir)/$(RUBYSPEC_CAPIEXT)/%.c $(RUBYSPEC_CAPIEXT_DEPS) \
509+
| build-ext
509510
$(ECHO) building $@
510511
$(Q) $(MAKEDIRS) $(@D)
511512
$(Q) $(DLDSHARED) -L. $(XDLDFLAGS) $(XLDFLAGS) $(LDFLAGS) $(INCFLAGS) $(CPPFLAGS) $(OUTFLAG)$@ $< $(LIBRUBYARG)

enc/depend

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7016,6 +7016,7 @@ enc/trans/iso2022.$(OBJEXT): internal/attr/nodiscard.h
70167016
enc/trans/iso2022.$(OBJEXT): internal/attr/noexcept.h
70177017
enc/trans/iso2022.$(OBJEXT): internal/attr/noinline.h
70187018
enc/trans/iso2022.$(OBJEXT): internal/attr/nonnull.h
7019+
enc/trans/iso2022.$(OBJEXT): internal/attr/nonstring.h
70197020
enc/trans/iso2022.$(OBJEXT): internal/attr/noreturn.h
70207021
enc/trans/iso2022.$(OBJEXT): internal/attr/packed_struct.h
70217022
enc/trans/iso2022.$(OBJEXT): internal/attr/pure.h

enc/trans/iso2022.trans

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "transcode_data.h"
2+
#include "ruby/internal/attr/nonstring.h"
23

34
<%
45
map = {
@@ -436,7 +437,7 @@ rb_cp50221_encoder = {
436437

437438
/* JIS0201 to JIS0208 conversion table */
438439
enum {tbl0208_num = 0xDF - 0xA1 + 1};
439-
static const char tbl0208[tbl0208_num][2] = {
440+
RBIMPL_ATTR_NONSTRING() static const char tbl0208[tbl0208_num][2] = {
440441
"\x21\x23", "\x21\x56", "\x21\x57", "\x21\x22",
441442
"\x21\x26", "\x25\x72", "\x25\x21", "\x25\x23",
442443
"\x25\x25", "\x25\x27", "\x25\x29", "\x25\x63",
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#ifndef RBIMPL_ATTR_NONSTRING_H /*-*-C++-*-vi:se ft=cpp:*/
2+
#define RBIMPL_ATTR_NONSTRING_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 Defines #RBIMPL_ATTR_NONSTRING.
22+
*/
23+
#include "ruby/internal/has/attribute.h"
24+
25+
/** Wraps (or simulates) `__attribute__((nonstring))` */
26+
#if RBIMPL_HAS_ATTRIBUTE(nonstring)
27+
# define RBIMPL_ATTR_NONSTRING() __attribute__((nonstring))
28+
#else
29+
# define RBIMPL_ATTR_NONSTRING() /* void */
30+
#endif
31+
32+
#endif /* RBIMPL_ATTR_NONSTRING_H */

iseq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3765,7 +3765,7 @@ rb_vm_encoded_insn_data_table_init(void)
37653765
const void * const *table = rb_vm_get_insns_address_table();
37663766
#define INSN_CODE(insn) ((VALUE)table[insn])
37673767
#else
3768-
#define INSN_CODE(insn) (insn)
3768+
#define INSN_CODE(insn) ((VALUE)(insn))
37693769
#endif
37703770
st_data_t insn;
37713771
encoded_insn_data = st_init_numtable_with_size(VM_INSTRUCTION_SIZE / 2);

marshal.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "ruby/util.h"
4141
#include "builtin.h"
4242
#include "shape.h"
43+
#include "ruby/internal/attr/nonstring.h"
4344

4445
#define BITSPERSHORT (2*CHAR_BIT)
4546
#define SHORTMASK ((1<<BITSPERSHORT)-1)
@@ -1524,7 +1525,7 @@ name_equal(const char *name, size_t nlen, const char *p, long l)
15241525
static int
15251526
sym2encidx(VALUE sym, VALUE val)
15261527
{
1527-
static const char name_encoding[8] = "encoding";
1528+
RBIMPL_ATTR_NONSTRING() static const char name_encoding[8] = "encoding";
15281529
const char *p;
15291530
long l;
15301531
if (rb_enc_get_index(sym) != ENCINDEX_US_ASCII) return -1;

regenc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ typedef struct {
118118

119119
typedef struct {
120120
short int len;
121+
#if defined(__has_attribute)
122+
# if __has_attribute(nonstring)
123+
__attribute__((nonstring))
124+
# endif
125+
#endif
121126
const UChar name[6];
122127
int ctype;
123128
} PosixBracketEntryType;

signal.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "ruby_atomic.h"
4646
#include "vm_core.h"
4747
#include "ractor_core.h"
48+
#include "ruby/internal/attr/nonstring.h"
4849

4950
#ifdef NEED_RUBY_ATOMIC_OPS
5051
rb_atomic_t
@@ -975,7 +976,7 @@ check_reserved_signal_(const char *name, size_t name_len, int signo)
975976
if (prev) {
976977
ssize_t RB_UNUSED_VAR(err);
977978
static const int stderr_fd = 2;
978-
#define NOZ(name, str) name[sizeof(str)-1] = str
979+
#define NOZ(name, str) RBIMPL_ATTR_NONSTRING() name[sizeof(str)-1] = str
979980
static const char NOZ(msg1, " received in ");
980981
static const char NOZ(msg2, " handler\n");
981982

0 commit comments

Comments
 (0)