Skip to content

Commit

Permalink
Restore MRI modifications
Browse files Browse the repository at this point in the history
* Drop modifications in forwardable.rb, they should no longer be needed.
* Try to reduce the diff a bit and make Truffle-changed lines contiguous
  to let the diff apply better.
* Conflicts:
lib/cext/include/ruby/encoding.h
lib/cext/include/ruby/intern.h
lib/cext/include/ruby/ruby.h
lib/mri/forwardable.rb
lib/mri/monitor.rb
lib/mri/rubygems/test_case.rb
src/main/c/openssl/ossl.c
src/main/c/openssl/ossl.h
src/main/c/openssl/ossl_asn1.c
src/main/c/openssl/ossl_engine.c
src/main/c/openssl/ossl_ocsp.c
src/main/c/openssl/ossl_pkcs12.c
src/main/c/openssl/ossl_pkey.c
src/main/c/openssl/ossl_pkey_dsa.c
src/main/c/openssl/ossl_pkey_ec.c
src/main/c/openssl/ossl_pkey_rsa.c
src/main/c/openssl/ossl_ssl.c
src/main/c/openssl/ossl_x509store.c
src/main/c/zlib/zlib.c
  • Loading branch information
chrisseaton authored and eregon committed Apr 30, 2018
1 parent 52b5417 commit d675e82
Show file tree
Hide file tree
Showing 43 changed files with 632 additions and 870 deletions.
65 changes: 29 additions & 36 deletions lib/cext/include/ruby/encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,12 @@ enum ruby_encoding_consts {
#define ENCODING_SHIFT RUBY_ENCODING_SHIFT
#define ENCODING_MASK RUBY_ENCODING_MASK

#define RB_ENCODING_SET_INLINED(obj,i) do {\
RBASIC(obj)->flags &= ~RUBY_ENCODING_MASK;\
RBASIC(obj)->flags |= (VALUE)(i) << RUBY_ENCODING_SHIFT;\
} while (0)
#define RB_ENCODING_SET_INLINED(obj,i) RB_ENCODING_SET(obj,i)
#define RB_ENCODING_SET(obj,i) rb_enc_set_index((obj), (i))

#define RB_ENCODING_GET_INLINED(obj) \
(int)((RBASIC(obj)->flags & RUBY_ENCODING_MASK)>>RUBY_ENCODING_SHIFT)
#define RB_ENCODING_GET(obj) \
(RB_ENCODING_GET_INLINED(obj) != RUBY_ENCODING_INLINE_MAX ? \
RB_ENCODING_GET_INLINED(obj) : \
rb_enc_get_index(obj))
#define RB_ENCODING_GET(obj) rb_enc_get_index(obj)

#define RB_ENCODING_IS_ASCII8BIT(obj) (RB_ENCODING_GET_INLINED(obj) == 0)

Expand All @@ -61,12 +55,9 @@ enum ruby_encoding_consts {

enum ruby_coderange_type {
RUBY_ENC_CODERANGE_UNKNOWN = 0,
RUBY_ENC_CODERANGE_7BIT = ((int)RUBY_FL_USER8),
RUBY_ENC_CODERANGE_VALID = ((int)RUBY_FL_USER9),
RUBY_ENC_CODERANGE_BROKEN = ((int)(RUBY_FL_USER8|RUBY_FL_USER9)),
RUBY_ENC_CODERANGE_MASK = (RUBY_ENC_CODERANGE_7BIT|
RUBY_ENC_CODERANGE_VALID|
RUBY_ENC_CODERANGE_BROKEN)
RUBY_ENC_CODERANGE_7BIT = 1,
RUBY_ENC_CODERANGE_VALID = 2,
RUBY_ENC_CODERANGE_BROKEN = 4
};

static inline int
Expand All @@ -75,7 +66,7 @@ rb_enc_coderange_clean_p(int cr)
return (cr ^ (cr >> 1)) & RUBY_ENC_CODERANGE_7BIT;
}
#define RB_ENC_CODERANGE_CLEAN_P(cr) rb_enc_coderange_clean_p(cr)
#define RB_ENC_CODERANGE(obj) ((int)RBASIC(obj)->flags & RUBY_ENC_CODERANGE_MASK)
enum ruby_coderange_type RB_ENC_CODERANGE(VALUE obj);
#define RB_ENC_CODERANGE_ASCIIONLY(obj) (RB_ENC_CODERANGE(obj) == RUBY_ENC_CODERANGE_7BIT)
#define RB_ENC_CODERANGE_SET(obj,cr) (\
RBASIC(obj)->flags = \
Expand Down Expand Up @@ -108,7 +99,9 @@ rb_enc_coderange_clean_p(int cr)
#define ENC_CODERANGE_AND(a, b) RB_ENC_CODERANGE_AND(a, b)
#define ENCODING_CODERANGE_SET(obj, encindex, cr) RB_ENCODING_CODERANGE_SET(obj, encindex, cr)

typedef const OnigEncodingType rb_encoding;
typedef struct rb_encoding {
char *name;
} rb_encoding;

int rb_char_to_option_kcode(int c, int *option, int *kcode);

Expand Down Expand Up @@ -141,6 +134,9 @@ VALUE rb_obj_encoding(VALUE);
VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *enc);
VALUE rb_enc_uint_chr(unsigned int code, rb_encoding *enc);

VALUE rb_external_str_with_enc(VALUE string, rb_encoding *eenc);
rb_encoding *get_encoding(VALUE string);
#define STR_ENC_GET(string) get_encoding(string)
VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *);
VALUE rb_str_export_to_enc(VALUE, rb_encoding *);
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to);
Expand Down Expand Up @@ -171,8 +167,8 @@ rb_encoding *rb_enc_find(const char *name);
#define rb_enc_name(enc) (enc)->name

/* rb_encoding * -> minlen/maxlen */
#define rb_enc_mbminlen(enc) (enc)->min_enc_len
#define rb_enc_mbmaxlen(enc) (enc)->max_enc_len
int rb_enc_mbminlen(rb_encoding *enc);
int rb_enc_mbmaxlen(rb_encoding *enc);

/* -> mbclen (no error notification: 0 < ret <= e-p, no exception) */
int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc);
Expand All @@ -182,11 +178,11 @@ int rb_enc_fast_mbclen(const char *p, const char *e, rb_encoding *enc);

/* -> chlen, invalid or needmore */
int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc);
#define MBCLEN_CHARFOUND_P(ret) ONIGENC_MBCLEN_CHARFOUND_P(ret)
#define MBCLEN_CHARFOUND_LEN(ret) ONIGENC_MBCLEN_CHARFOUND_LEN(ret)
int MBCLEN_CHARFOUND_P(int r);
int MBCLEN_CHARFOUND_LEN(int r);
#define MBCLEN_INVALID_P(ret) ONIGENC_MBCLEN_INVALID_P(ret)
#define MBCLEN_NEEDMORE_P(ret) ONIGENC_MBCLEN_NEEDMORE_P(ret)
#define MBCLEN_NEEDMORE_LEN(ret) ONIGENC_MBCLEN_NEEDMORE_LEN(ret)
int MBCLEN_NEEDMORE_P(int r);
int MBCLEN_NEEDMORE_LEN(int r);

/* -> 0x00..0x7f, -1 */
int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc);
Expand All @@ -213,7 +209,7 @@ int rb_enc_code_to_mbclen(int code, rb_encoding *enc);
/* start, ptr, end, encoding -> prev_char */
#define rb_enc_prev_char(s,p,e,enc) ((char *)onigenc_get_prev_char_head((enc),(UChar*)(s),(UChar*)(p),(UChar*)(e)))
/* start, ptr, end, encoding -> next_char */
#define rb_enc_left_char_head(s,p,e,enc) ((char *)onigenc_get_left_adjust_char_head((enc),(UChar*)(s),(UChar*)(p),(UChar*)(e)))
char* rb_enc_left_char_head(char *start, char *p, char *end, rb_encoding *enc);
#define rb_enc_right_char_head(s,p,e,enc) ((char *)onigenc_get_right_adjust_char_head((enc),(UChar*)(s),(UChar*)(p),(UChar*)(e)))
#define rb_enc_step_back(s,p,e,n,enc) ((char *)onigenc_step_back((enc),(UChar*)(s),(UChar*)(p),(UChar*)(e),(int)(n)))

Expand All @@ -231,12 +227,7 @@ int rb_enc_code_to_mbclen(int code, rb_encoding *enc);
#define rb_enc_isspace(c,enc) ONIGENC_IS_CODE_SPACE((enc),(c))
#define rb_enc_isdigit(c,enc) ONIGENC_IS_CODE_DIGIT((enc),(c))

static inline int
rb_enc_asciicompat_inline(rb_encoding *enc)
{
return rb_enc_mbminlen(enc)==1 && !rb_enc_dummy_p(enc);
}
#define rb_enc_asciicompat(enc) rb_enc_asciicompat_inline(enc)
int rb_enc_asciicompat(rb_encoding *enc);

int rb_enc_casefold(char *to, const char *p, const char *e, rb_encoding *enc);
CONSTFUNC(int rb_enc_toupper(int c, rb_encoding *enc));
Expand Down Expand Up @@ -287,6 +278,8 @@ VALUE rb_check_symbol_cstr(const char *ptr, long len, rb_encoding *enc);
RUBY_EXTERN VALUE rb_cEncoding;

/* econv stuff */
struct rb_econv_t {};


typedef enum {
econv_invalid_byte_sequence,
Expand Down Expand Up @@ -383,24 +376,24 @@ enum ruby_econv_flag_type {
#else
0,
#endif
#define ECONV_ERROR_HANDLER_MASK RUBY_ECONV_ERROR_HANDLER_MASK
// #define ECONV_ERROR_HANDLER_MASK RUBY_ECONV_ERROR_HANDLER_MASK
#define ECONV_INVALID_MASK RUBY_ECONV_INVALID_MASK
#define ECONV_INVALID_REPLACE RUBY_ECONV_INVALID_REPLACE
#define ECONV_UNDEF_MASK RUBY_ECONV_UNDEF_MASK
#define ECONV_UNDEF_REPLACE RUBY_ECONV_UNDEF_REPLACE
#define ECONV_UNDEF_HEX_CHARREF RUBY_ECONV_UNDEF_HEX_CHARREF
#define ECONV_DECORATOR_MASK RUBY_ECONV_DECORATOR_MASK
#define ECONV_NEWLINE_DECORATOR_MASK RUBY_ECONV_NEWLINE_DECORATOR_MASK
#define ECONV_NEWLINE_DECORATOR_READ_MASK RUBY_ECONV_NEWLINE_DECORATOR_READ_MASK
#define ECONV_NEWLINE_DECORATOR_WRITE_MASK RUBY_ECONV_NEWLINE_DECORATOR_WRITE_MASK
// #define ECONV_DECORATOR_MASK RUBY_ECONV_DECORATOR_MASK
// #define ECONV_NEWLINE_DECORATOR_MASK RUBY_ECONV_NEWLINE_DECORATOR_MASK
// #define ECONV_NEWLINE_DECORATOR_READ_MASK RUBY_ECONV_NEWLINE_DECORATOR_READ_MASK
// #define ECONV_NEWLINE_DECORATOR_WRITE_MASK RUBY_ECONV_NEWLINE_DECORATOR_WRITE_MASK
#define ECONV_UNIVERSAL_NEWLINE_DECORATOR RUBY_ECONV_UNIVERSAL_NEWLINE_DECORATOR
#define ECONV_CRLF_NEWLINE_DECORATOR RUBY_ECONV_CRLF_NEWLINE_DECORATOR
#define ECONV_CR_NEWLINE_DECORATOR RUBY_ECONV_CR_NEWLINE_DECORATOR
#define ECONV_XML_TEXT_DECORATOR RUBY_ECONV_XML_TEXT_DECORATOR
#define ECONV_XML_ATTR_CONTENT_DECORATOR RUBY_ECONV_XML_ATTR_CONTENT_DECORATOR
#define ECONV_STATEFUL_DECORATOR_MASK RUBY_ECONV_STATEFUL_DECORATOR_MASK
// #define ECONV_STATEFUL_DECORATOR_MASK RUBY_ECONV_STATEFUL_DECORATOR_MASK
#define ECONV_XML_ATTR_QUOTE_DECORATOR RUBY_ECONV_XML_ATTR_QUOTE_DECORATOR
#define ECONV_DEFAULT_NEWLINE_DECORATOR RUBY_ECONV_DEFAULT_NEWLINE_DECORATOR
// #define ECONV_DEFAULT_NEWLINE_DECORATOR RUBY_ECONV_DEFAULT_NEWLINE_DECORATOR
/* end of flags for rb_econv_open */

/* flags for rb_econv_convert */
Expand Down
94 changes: 12 additions & 82 deletions lib/cext/include/ruby/intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ RUBY_SYMBOL_EXPORT_BEGIN

/* array.c */
void rb_mem_clear(register VALUE*, register long);
VALUE rb_assoc_new(VALUE, VALUE);
#define rb_assoc_new(a, b) rb_ary_new3(2, a, b)
VALUE rb_check_array_type(VALUE);
VALUE rb_ary_new(void);
VALUE rb_ary_new_capa(long capa);
Expand All @@ -54,12 +54,12 @@ VALUE rb_ary_new_from_values(long n, const VALUE *elts);
VALUE rb_ary_tmp_new(long);
void rb_ary_free(VALUE);
void rb_ary_modify(VALUE);
VALUE rb_ary_freeze(VALUE);
#define rb_ary_freeze(array) rb_obj_freeze(array)
VALUE rb_ary_shared_with_p(VALUE, VALUE);
VALUE rb_ary_aref(int, const VALUE*, VALUE);
VALUE rb_ary_subseq(VALUE, long, long);
void rb_ary_store(VALUE, long, VALUE);
VALUE rb_ary_dup(VALUE);
#define rb_ary_dup(array) rb_obj_dup(array)
VALUE rb_ary_resurrect(VALUE ary);
VALUE rb_ary_to_ary(VALUE);
VALUE rb_ary_to_s(VALUE);
Expand Down Expand Up @@ -264,23 +264,6 @@ CONSTFUNC(void rb_check_trusted(VALUE));
} \
} while (0)
#define rb_check_trusted_internal(obj) ((void) 0)
#ifdef __GNUC__
#define rb_check_frozen(obj) __extension__({rb_check_frozen_internal(obj);})
#define rb_check_trusted(obj) __extension__({rb_check_trusted_internal(obj);})
#else
static inline void
rb_check_frozen_inline(VALUE obj)
{
rb_check_frozen_internal(obj);
}
#define rb_check_frozen(obj) rb_check_frozen_inline(obj)
static inline void
rb_check_trusted_inline(VALUE obj)
{
rb_check_trusted_internal(obj);
}
#define rb_check_trusted(obj) rb_check_trusted_inline(obj)
#endif
void rb_check_copyable(VALUE obj, VALUE orig);

#define RB_OBJ_INIT_COPY(obj, orig) \
Expand All @@ -293,13 +276,7 @@ const char *rb_sourcefile(void);
VALUE rb_check_funcall(VALUE, ID, int, const VALUE*);

NORETURN(void rb_error_arity(int, int, int));
static inline int
rb_check_arity(int argc, int min, int max)
{
if ((argc < min) || (max != UNLIMITED_ARGUMENTS && argc > max))
rb_error_arity(argc, min, max);
return argc;
}
void rb_check_arity(int argc, int min, int max);
#define rb_check_arity rb_check_arity /* for ifdef */

#if defined(NFDBITS) && defined(HAVE_RB_FD_INIT)
Expand Down Expand Up @@ -510,7 +487,7 @@ void rb_hash_foreach(VALUE, int (*)(ANYARGS), VALUE);
VALUE rb_hash(VALUE);
VALUE rb_hash_new(void);
VALUE rb_hash_dup(VALUE);
VALUE rb_hash_freeze(VALUE);
#define rb_hash_freeze(array) rb_obj_freeze(array)
VALUE rb_hash_aref(VALUE, VALUE);
VALUE rb_hash_lookup(VALUE, VALUE);
VALUE rb_hash_lookup2(VALUE, VALUE, VALUE);
Expand Down Expand Up @@ -649,7 +626,7 @@ VALUE rb_detach_process(rb_pid_t pid);
/* range.c */
VALUE rb_range_new(VALUE, VALUE, int);
VALUE rb_range_beg_len(VALUE, long*, long*, long, int);
int rb_range_values(VALUE range, VALUE *begp, VALUE *endp, int *exclp);
MUST_INLINE int rb_range_values(VALUE range, VALUE *begp, VALUE *endp, int *exclp);
/* random.c */
unsigned int rb_genrand_int32(void);
double rb_genrand_real(void);
Expand Down Expand Up @@ -733,11 +710,11 @@ VALUE rb_str_buf_append(VALUE, VALUE);
VALUE rb_str_buf_cat(VALUE, const char*, long);
VALUE rb_str_buf_cat2(VALUE, const char*);
VALUE rb_str_buf_cat_ascii(VALUE, const char*);
VALUE rb_obj_as_string(VALUE);
#define rb_obj_as_string(object) rb_any_to_s(object)
VALUE rb_check_string_type(VALUE);
void rb_must_asciicompat(VALUE);
VALUE rb_str_dup(VALUE);
VALUE rb_str_resurrect(VALUE str);
#define rb_str_dup(string) rb_obj_dup(string)
#define rb_str_resurrect(string) rb_obj_dup(string)
VALUE rb_str_locktmp(VALUE);
VALUE rb_str_unlocktmp(VALUE);
VALUE rb_str_dup_frozen(VALUE);
Expand All @@ -750,7 +727,7 @@ VALUE rb_str_subseq(VALUE, long, long);
char *rb_str_subpos(VALUE, long, long*);
void rb_str_modify(VALUE);
void rb_str_modify_expand(VALUE, long);
VALUE rb_str_freeze(VALUE);
#define rb_str_freeze(string) rb_obj_freeze(string)
void rb_str_set_len(VALUE, long);
VALUE rb_str_resize(VALUE, long);
VALUE rb_str_cat(VALUE, const char*, long);
Expand All @@ -774,7 +751,7 @@ VALUE rb_str_equal(VALUE str1, VALUE str2);
VALUE rb_str_drop_bytes(VALUE, long);
void rb_str_update(VALUE, long, long, VALUE);
VALUE rb_str_replace(VALUE, VALUE);
VALUE rb_str_inspect(VALUE);
#define rb_str_inspect(string) rb_inspect(string)
VALUE rb_str_dump(VALUE);
VALUE rb_str_split(VALUE, const char*);
NORETURN(DEPRECATED(void rb_str_associate(VALUE, VALUE)));
Expand All @@ -792,67 +769,22 @@ VALUE rb_str_scrub(VALUE, VALUE);
VALUE rb_sym_all_symbols(void);

#ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
#define rb_str_new(str, len) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(str) && __builtin_constant_p(len)) ? \
rb_str_new_static((str), (len)) : \
rb_str_new((str), (len)) \
)
#define rb_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(str)) ? \
rb_str_new_static((str), (long)strlen(str)) : \
rb_str_new_cstr(str) \
)
#define rb_usascii_str_new(str, len) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(str) && __builtin_constant_p(len)) ? \
rb_usascii_str_new_static((str), (len)) : \
rb_usascii_str_new((str), (len)) \
)
VALUE rb_str_new_cstr(const char *string);
#define rb_utf8_str_new(str, len) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(str) && __builtin_constant_p(len)) ? \
rb_utf8_str_new_static((str), (len)) : \
rb_utf8_str_new((str), (len)) \
)
#define rb_tainted_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(str)) ? \
rb_tainted_str_new((str), (long)strlen(str)) : \
rb_tainted_str_new_cstr(str) \
)
#define rb_usascii_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(str)) ? \
rb_usascii_str_new_static((str), (long)strlen(str)) : \
rb_usascii_str_new_cstr(str) \
)
#define rb_utf8_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(str)) ? \
rb_utf8_str_new_static((str), (long)strlen(str)) : \
rb_utf8_str_new_cstr(str) \
)
#define rb_external_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(str)) ? \
rb_external_str_new((str), (long)strlen(str)) : \
rb_external_str_new_cstr(str) \
)
#define rb_locale_str_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(str)) ? \
rb_locale_str_new((str), (long)strlen(str)) : \
rb_locale_str_new_cstr(str) \
)
#define rb_str_buf_new_cstr(str) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(str)) ? \
rb_str_buf_cat(rb_str_buf_new((long)strlen(str)), \
(str), (long)strlen(str)) : \
rb_str_buf_new_cstr(str) \
)
#define rb_str_cat_cstr(str, ptr) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(ptr)) ? \
rb_str_cat((str), (ptr), (long)strlen(ptr)) : \
rb_str_cat_cstr((str), (ptr)) \
)
#define rb_exc_new_cstr(klass, ptr) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(ptr)) ? \
rb_exc_new((klass), (ptr), (long)strlen(ptr)) : \
rb_exc_new_cstr((klass), (ptr)) \
)
#endif
#define rb_str_new2 rb_str_new_cstr
#define rb_str_new3 rb_str_new_shared
Expand All @@ -861,9 +793,7 @@ VALUE rb_sym_all_symbols(void);
#define rb_tainted_str_new2 rb_tainted_str_new_cstr
#define rb_str_buf_new2 rb_str_buf_new_cstr
#define rb_usascii_str_new2 rb_usascii_str_new_cstr
#define rb_str_buf_cat rb_str_cat
#define rb_str_buf_cat2 rb_str_cat_cstr
#define rb_str_cat2 rb_str_cat_cstr
#define rb_strlen_lit(str) (sizeof(str "") - 1)
#define rb_str_new_lit(str) rb_str_new_static((str), rb_strlen_lit(str))
#define rb_usascii_str_new_lit(str) rb_usascii_str_new_static((str), rb_strlen_lit(str))
Expand Down
Loading

0 comments on commit d675e82

Please sign in to comment.