aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-08 17:44:51 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-08 17:44:51 +0000
commit51af3690dd225e1e3bf6f5c687d2e05cd9c85fce (patch)
treed37adb13ec69829960f21d187cbd689d780338eb /include
parent735b11cd170935199f7970c039c46176ef7b2c9a (diff)
downloadruby-51af3690dd225e1e3bf6f5c687d2e05cd9c85fce.tar.gz
* configure.in: check function attirbute const and pure,
and define CONSTFUNC and PUREFUNC if available. Note that I don't add those options as default because it still shows many false-positive (it seems not to consider longjmp). * vm_eval.c (stack_check): get rb_thread_t* as an argument to avoid duplicate call of GET_THREAD(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include')
-rw-r--r--include/ruby/encoding.h16
-rw-r--r--include/ruby/intern.h36
-rw-r--r--include/ruby/io.h2
-rw-r--r--include/ruby/oniguruma.h6
-rw-r--r--include/ruby/ruby.h6
-rw-r--r--include/ruby/st.h20
6 files changed, 42 insertions, 44 deletions
diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h
index ceedf0db65..4e10b77f7a 100644
--- a/include/ruby/encoding.h
+++ b/include/ruby/encoding.h
@@ -113,8 +113,8 @@ int rb_char_to_option_kcode(int c, int *option, int *kcode);
int rb_enc_replicate(const char *, rb_encoding *);
int rb_define_dummy_encoding(const char *);
-int rb_enc_dummy_p(rb_encoding *enc);
-int rb_enc_to_index(rb_encoding *enc);
+PUREFUNC(int rb_enc_dummy_p(rb_encoding *enc));
+PUREFUNC(int rb_enc_to_index(rb_encoding *enc));
int rb_enc_get_index(VALUE obj);
void rb_enc_set_index(VALUE obj, int encindex);
int rb_enc_find_index(const char *name);
@@ -240,8 +240,8 @@ rb_enc_asciicompat_inline(rb_encoding *enc)
#define rb_enc_asciicompat(enc) rb_enc_asciicompat_inline(enc)
int rb_enc_casefold(char *to, const char *p, const char *e, rb_encoding *enc);
-int rb_enc_toupper(int c, rb_encoding *enc);
-int rb_enc_tolower(int c, rb_encoding *enc);
+CONSTFUNC(int rb_enc_toupper(int c, rb_encoding *enc));
+CONSTFUNC(int rb_enc_tolower(int c, rb_encoding *enc));
ID rb_intern3(const char*, long, rb_encoding*);
ID rb_interned_id_p(const char *, long, rb_encoding *);
int rb_enc_symname_p(const char*, rb_encoding*);
@@ -251,7 +251,7 @@ long rb_str_coderange_scan_restartable(const char*, const char*, rb_encoding*, i
int rb_enc_str_asciionly_p(VALUE);
#define rb_enc_str_asciicompat_p(str) rb_enc_asciicompat(rb_enc_get(str))
VALUE rb_enc_from_encoding(rb_encoding *enc);
-int rb_enc_unicode_p(rb_encoding *enc);
+PUREFUNC(int rb_enc_unicode_p(rb_encoding *enc));
rb_encoding *rb_ascii8bit_encoding(void);
rb_encoding *rb_utf8_encoding(void);
rb_encoding *rb_usascii_encoding(void);
@@ -260,13 +260,13 @@ rb_encoding *rb_filesystem_encoding(void);
rb_encoding *rb_default_external_encoding(void);
rb_encoding *rb_default_internal_encoding(void);
#ifndef rb_ascii8bit_encindex
-int rb_ascii8bit_encindex(void);
+CONSTFUNC(int rb_ascii8bit_encindex(void));
#endif
#ifndef rb_utf8_encindex
-int rb_utf8_encindex(void);
+CONSTFUNC(int rb_utf8_encindex(void));
#endif
#ifndef rb_usascii_encindex
-int rb_usascii_encindex(void);
+CONSTFUNC(int rb_usascii_encindex(void));
#endif
int rb_locale_encindex(void);
int rb_filesystem_encindex(void);
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index 7edfccbbf7..a33f7cc407 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -254,9 +254,9 @@ NORETURN(DEPRECATED(PRINTF_ARGS(void rb_compile_error_with_enc(const char*, int,
NORETURN(DEPRECATED(PRINTF_ARGS(void rb_compile_error_append(const char*, ...), 1, 2)));
NORETURN(void rb_error_frozen(const char*));
NORETURN(void rb_error_frozen_object(VALUE));
-void rb_error_untrusted(VALUE);
+CONSTFUNC(void rb_error_untrusted(VALUE));
void rb_check_frozen(VALUE);
-void rb_check_trusted(VALUE);
+CONSTFUNC(void rb_check_trusted(VALUE));
#define rb_check_frozen_internal(obj) do { \
VALUE frozen_obj = (obj); \
if (OBJ_FROZEN(frozen_obj)) { \
@@ -293,7 +293,6 @@ const char *rb_sourcefile(void);
VALUE rb_check_funcall(VALUE, ID, int, const VALUE*);
NORETURN(void rb_error_arity(int, int, int));
-#define rb_check_arity rb_check_arity /* for ifdef */
static inline int
rb_check_arity(int argc, int min, int max)
{
@@ -301,6 +300,7 @@ rb_check_arity(int argc, int min, int max)
rb_error_arity(argc, min, max);
return argc;
}
+#define rb_check_arity rb_check_arity /* for ifdef */
#if defined(NFDBITS) && defined(HAVE_RB_FD_INIT)
typedef struct {
@@ -482,7 +482,7 @@ VALUE rb_str_encode_ospath(VALUE);
int rb_is_absolute_path(const char *);
/* gc.c */
NORETURN(void rb_memerror(void));
-int rb_during_gc(void);
+PUREFUNC(int rb_during_gc(void););
void rb_gc_mark_locations(const VALUE*, const VALUE*);
void rb_mark_tbl(struct st_table*);
void rb_mark_set(struct st_table*);
@@ -580,7 +580,7 @@ VALUE rb_num_coerce_relop(VALUE, VALUE, ID);
VALUE rb_num_coerce_bit(VALUE, VALUE, ID);
VALUE rb_num2fix(VALUE);
VALUE rb_fix2str(VALUE, int);
-VALUE rb_dbl_cmp(double, double);
+CONSTFUNC(VALUE rb_dbl_cmp(double, double));
/* object.c */
int rb_eql(VALUE, VALUE);
VALUE rb_any_to_s(VALUE);
@@ -592,17 +592,17 @@ VALUE rb_obj_clone(VALUE);
VALUE rb_obj_dup(VALUE);
VALUE rb_obj_init_copy(VALUE,VALUE);
VALUE rb_obj_taint(VALUE);
-VALUE rb_obj_tainted(VALUE);
+PUREFUNC(VALUE rb_obj_tainted(VALUE));
VALUE rb_obj_untaint(VALUE);
VALUE rb_obj_untrust(VALUE);
-VALUE rb_obj_untrusted(VALUE);
+PUREFUNC(VALUE rb_obj_untrusted(VALUE));
VALUE rb_obj_trust(VALUE);
VALUE rb_obj_freeze(VALUE);
-VALUE rb_obj_frozen_p(VALUE);
+PUREFUNC(VALUE rb_obj_frozen_p(VALUE));
VALUE rb_obj_id(VALUE);
VALUE rb_obj_class(VALUE);
-VALUE rb_class_real(VALUE);
-VALUE rb_class_inherited_p(VALUE, VALUE);
+PUREFUNC(VALUE rb_class_real(VALUE));
+PUREFUNC(VALUE rb_class_inherited_p(VALUE, VALUE));
VALUE rb_class_superclass(VALUE);
VALUE rb_class_get_superclass(VALUE);
VALUE rb_convert_type(VALUE,int,const char*,const char*);
@@ -621,13 +621,13 @@ double rb_cstr_to_dbl(const char*, int);
double rb_str_to_dbl(VALUE, int);
/* parse.y */
ID rb_id_attrset(ID);
-int rb_is_const_id(ID);
-int rb_is_global_id(ID);
-int rb_is_instance_id(ID);
-int rb_is_attrset_id(ID);
-int rb_is_class_id(ID);
-int rb_is_local_id(ID);
-int rb_is_junk_id(ID);
+CONSTFUNC(int rb_is_const_id(ID));
+CONSTFUNC(int rb_is_global_id(ID));
+CONSTFUNC(int rb_is_instance_id(ID));
+CONSTFUNC(int rb_is_attrset_id(ID));
+CONSTFUNC(int rb_is_class_id(ID));
+CONSTFUNC(int rb_is_local_id(ID));
+CONSTFUNC(int rb_is_junk_id(ID));
int rb_symname_p(const char*);
int rb_sym_interned_p(VALUE);
VALUE rb_backref_get(void);
@@ -784,7 +784,7 @@ VALUE rb_sym_to_s(VALUE);
long rb_str_strlen(VALUE);
VALUE rb_str_length(VALUE);
long rb_str_offset(VALUE, long);
-size_t rb_str_capacity(VALUE);
+PUREFUNC(size_t rb_str_capacity(VALUE););
VALUE rb_str_ellipsize(VALUE, long);
VALUE rb_str_scrub(VALUE, VALUE);
/* symbol.c */
diff --git a/include/ruby/io.h b/include/ruby/io.h
index a15795252b..60d6f6d32e 100644
--- a/include/ruby/io.h
+++ b/include/ruby/io.h
@@ -130,7 +130,7 @@ FILE *rb_io_stdio_file(rb_io_t *fptr);
FILE *rb_fdopen(int, const char*);
int rb_io_modestr_fmode(const char *modestr);
int rb_io_modestr_oflags(const char *modestr);
-int rb_io_oflags_fmode(int oflags);
+CONSTFUNC(int rb_io_oflags_fmode(int oflags));
void rb_io_check_writable(rb_io_t*);
void rb_io_check_readable(rb_io_t*);
void rb_io_check_char_readable(rb_io_t *fptr);
diff --git a/include/ruby/oniguruma.h b/include/ruby/oniguruma.h
index defa3917e5..b45072f48d 100644
--- a/include/ruby/oniguruma.h
+++ b/include/ruby/oniguruma.h
@@ -342,10 +342,8 @@ ONIG_EXTERN
int onigenc_init P_((void));
ONIG_EXTERN
int onigenc_set_default_encoding P_((OnigEncoding enc));
-ONIG_EXTERN
-OnigEncoding onigenc_get_default_encoding P_((void));
-ONIG_EXTERN
-void onigenc_set_default_caseconv_table P_((const OnigUChar* table));
+PUREFUNC(ONIG_EXTERN OnigEncoding onigenc_get_default_encoding P_((void)));
+PUREFUNC(ONIG_EXTERN void onigenc_set_default_caseconv_table P_((const OnigUChar* table)));
ONIG_EXTERN
OnigUChar* onigenc_get_right_adjust_char_head_with_prev P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s, const OnigUChar* end, const OnigUChar** prev));
ONIG_EXTERN
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 9fc7c68e63..0283d7b721 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -624,7 +624,7 @@ int rb_safe_level(void);
void rb_set_safe_level(int);
#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
int ruby_safe_level_2_error(void) __attribute__((error("$SAFE=2 to 4 are obsolete")));
-int ruby_safe_level_2_warning(void) __attribute__((warning("$SAFE=2 to 4 are obsolete")));
+int ruby_safe_level_2_warning(void) __attribute__((const,warning("$SAFE=2 to 4 are obsolete")));
# ifdef RUBY_EXPORT
# define ruby_safe_level_2_warning() ruby_safe_level_2_error()
# endif
@@ -650,7 +650,7 @@ int ruby_safe_level_2_warning(void) __attribute__((warning("$SAFE=2 to 4 are obs
#define rb_set_safe_level(level) rb_set_safe_level(RUBY_SAFE_LEVEL_CHECK(level, error))
#endif
void rb_set_safe_level_force(int);
-void rb_secure_update(VALUE);
+CONSTFUNC(void rb_secure_update(VALUE));
NORETURN(void rb_insecure_operation(void));
VALUE rb_errinfo(void);
@@ -952,7 +952,7 @@ enum {
RMODULE_ENUM_END
};
-double rb_float_value(VALUE);
+PUREFUNC(double rb_float_value(VALUE));
VALUE rb_float_new(double);
VALUE rb_float_new_in_heap(double);
diff --git a/include/ruby/st.h b/include/ruby/st.h
index 190bad2a35..de5aaaebec 100644
--- a/include/ruby/st.h
+++ b/include/ruby/st.h
@@ -131,18 +131,18 @@ void st_free_table(st_table *);
void st_cleanup_safe(st_table *, st_data_t);
void st_clear(st_table *);
st_table *st_copy(st_table *);
-int st_numcmp(st_data_t, st_data_t);
-st_index_t st_numhash(st_data_t);
-int st_locale_insensitive_strcasecmp(const char *s1, const char *s2);
-int st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n);
+CONSTFUNC(int st_numcmp(st_data_t, st_data_t));
+CONSTFUNC(st_index_t st_numhash(st_data_t));
+PUREFUNC(int st_locale_insensitive_strcasecmp(const char *s1, const char *s2));
+PUREFUNC(int st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n));
#define st_strcasecmp st_locale_insensitive_strcasecmp
#define st_strncasecmp st_locale_insensitive_strncasecmp
-size_t st_memsize(const st_table *);
-st_index_t st_hash(const void *ptr, size_t len, st_index_t h);
-st_index_t st_hash_uint32(st_index_t h, uint32_t i);
-st_index_t st_hash_uint(st_index_t h, st_index_t i);
-st_index_t st_hash_end(st_index_t h);
-st_index_t st_hash_start(st_index_t h);
+PUREFUNC(size_t st_memsize(const st_table *));
+PUREFUNC(st_index_t st_hash(const void *ptr, size_t len, st_index_t h));
+CONSTFUNC(st_index_t st_hash_uint32(st_index_t h, uint32_t i));
+CONSTFUNC(st_index_t st_hash_uint(st_index_t h, st_index_t i));
+CONSTFUNC(st_index_t st_hash_end(st_index_t h));
+CONSTFUNC(st_index_t st_hash_start(st_index_t h));
#define st_hash_start(h) ((st_index_t)(h))
RUBY_SYMBOL_EXPORT_END