Ruby  2.0.0p598(2014-11-13revision48408)
Data Structures | Macros | Enumerations | Functions | Variables
load.c File Reference
#include "ruby/ruby.h"
#include "ruby/util.h"
#include "internal.h"
#include "dln.h"
#include "eval_intern.h"
#include "probes.h"
#include "node.h"

Go to the source code of this file.

Data Structures

struct  loaded_feature_searching
 

Macros

#define numberof(array)   (int)(sizeof(array) / sizeof((array)[0]))
 
#define IS_RBEXT(e)   (strcmp((e), ".rb") == 0)
 
#define IS_SOEXT(e)   (strcmp((e), ".so") == 0 || strcmp((e), ".o") == 0)
 
#define IS_DLEXT(e)   (strcmp((e), DLEXT) == 0)
 
#define rb_intern(str)   rb_intern2((str), strlen(str))
 

Enumerations

enum  expand_type { EXPAND_ALL, EXPAND_RELATIVE, EXPAND_HOME, EXPAND_NON_CACHE }
 

Functions

VALUE rb_get_load_path (void)
 
static void rb_construct_expanded_load_path (int type, int *has_relative, int *has_non_cache)
 
static VALUE load_path_getcwd (void)
 
VALUE rb_get_expanded_load_path (void)
 
static VALUE load_path_getter (ID id, rb_vm_t *vm)
 
static VALUE get_loaded_features (void)
 
static void reset_loaded_features_snapshot (void)
 
static struct st_tableget_loaded_features_index_raw (void)
 
static st_tableget_loading_table (void)
 
static void features_index_add_single (VALUE short_feature, VALUE offset)
 
static void features_index_add (VALUE feature, VALUE offset)
 
static int loaded_features_index_clear_i (st_data_t key, st_data_t val, st_data_t arg)
 
static st_tableget_loaded_features_index (void)
 
static VALUE loaded_feature_path (const char *name, long vlen, const char *feature, long len, int type, VALUE load_path)
 
static int loaded_feature_path_i (st_data_t v, st_data_t b, st_data_t f)
 
static int rb_feature_p (const char *feature, const char *ext, int rb, int expanded, const char **fn)
 
int rb_provided (const char *feature)
 
int rb_feature_provided (const char *feature, const char **loading)
 
static void rb_provide_feature (VALUE feature)
 
void rb_provide (const char *feature)
 
 NORETURN (static void load_failed(VALUE))
 
static void rb_load_internal (VALUE fname, int wrap)
 
void rb_load (VALUE fname, int wrap)
 
void rb_load_protect (VALUE fname, int wrap, int *state)
 
static VALUE rb_f_load (int argc, VALUE *argv)
 
static char * load_lock (const char *ftptr)
 
static int release_thread_shield (st_data_t *key, st_data_t *value, st_data_t done, int existing)
 
static void load_unlock (const char *ftptr, int done)
 
VALUE rb_f_require (VALUE obj, VALUE fname)
 
VALUE rb_f_require_relative (VALUE obj, VALUE fname)
 
static int search_required (VALUE fname, volatile VALUE *path, int safe_level)
 
static void load_failed (VALUE fname)
 
static VALUE load_ext (VALUE path)
 
VALUE rb_require_safe (VALUE fname, int safe)
 
VALUE rb_require (const char *fname)
 
static int register_init_ext (st_data_t *key, st_data_t *value, st_data_t init, int existing)
 
RUBY_FUNC_EXPORTED void ruby_init_ext (const char *name, void(*init)(void))
 
static VALUE rb_mod_autoload (VALUE mod, VALUE sym, VALUE file)
 
static VALUE rb_mod_autoload_p (VALUE mod, VALUE sym)
 
static VALUE rb_f_autoload (VALUE obj, VALUE sym, VALUE file)
 
static VALUE rb_f_autoload_p (VALUE obj, VALUE sym)
 
void Init_load ()
 

Variables

VALUE ruby_dln_librefs
 
static const char *const loadable_ext []
 

Macro Definition Documentation

#define IS_DLEXT (   e)    (strcmp((e), DLEXT) == 0)

Definition at line 22 of file load.c.

Referenced by loaded_feature_path(), rb_feature_p(), rb_feature_provided(), and search_required().

#define IS_RBEXT (   e)    (strcmp((e), ".rb") == 0)

Definition at line 17 of file load.c.

Referenced by loaded_feature_path(), rb_feature_p(), rb_feature_provided(), and search_required().

#define IS_SOEXT (   e)    (strcmp((e), ".so") == 0 || strcmp((e), ".o") == 0)

Definition at line 18 of file load.c.

Referenced by rb_feature_p(), rb_feature_provided(), and search_required().

#define numberof (   array)    (int)(sizeof(array) / sizeof((array)[0]))

Definition at line 15 of file load.c.

Referenced by features_index_add_single(), and rb_feature_p().

#define rb_intern (   str)    rb_intern2((str), strlen(str))

Enumeration Type Documentation

Enumerator
EXPAND_ALL 
EXPAND_RELATIVE 
EXPAND_HOME 
EXPAND_NON_CACHE 

Definition at line 40 of file load.c.

Function Documentation

static void features_index_add ( VALUE  feature,
VALUE  offset 
)
static
static void features_index_add_single ( VALUE  short_feature,
VALUE  offset 
)
static
static VALUE get_loaded_features ( void  )
static

Definition at line 163 of file load.c.

References GET_VM.

Referenced by Init_load(), rb_feature_p(), and rb_provide_feature().

static st_table* get_loaded_features_index ( void  )
static
static struct st_table* get_loaded_features_index_raw ( void  )
static

Definition at line 176 of file load.c.

References GET_VM.

Referenced by features_index_add_single().

static st_table* get_loading_table ( void  )
static

Definition at line 182 of file load.c.

References GET_VM.

Referenced by load_lock(), load_unlock(), rb_feature_p(), and ruby_init_ext().

void Init_load ( )
static VALUE load_ext ( VALUE  path)
static

Definition at line 927 of file load.c.

References dln_load(), NOEX_PUBLIC, RSTRING_PTR, and SCOPE_SET.

Referenced by rb_require_safe().

static void load_failed ( VALUE  fname)
static

Definition at line 921 of file load.c.

References rb_load_fail().

Referenced by rb_f_load(), rb_load(), and rb_require_safe().

static char* load_lock ( const char *  ftptr)
static
static VALUE load_path_getcwd ( void  )
static

Definition at line 102 of file load.c.

References my_getcwd, rb_filesystem_str_new_cstr(), and xfree.

Referenced by rb_get_expanded_load_path().

static VALUE load_path_getter ( ID  id,
rb_vm_t vm 
)
static

Definition at line 157 of file load.c.

References rb_vm_struct::load_path.

Referenced by Init_load().

static void load_unlock ( const char *  ftptr,
int  done 
)
static

Definition at line 758 of file load.c.

References get_loading_table(), key, release_thread_shield(), and st_update().

Referenced by rb_require_safe().

static VALUE loaded_feature_path ( const char *  name,
long  vlen,
const char *  feature,
long  len,
int  type,
VALUE  load_path 
)
static

Definition at line 310 of file load.c.

References e, i, IS_DLEXT, IS_RBEXT, len, n, p, RARRAY_LEN, RARRAY_PTR(), RSTRING_LEN, s, and StringValuePtr.

Referenced by loaded_feature_path_i(), and rb_feature_p().

static int loaded_feature_path_i ( st_data_t  v,
st_data_t  b,
st_data_t  f 
)
static
static int loaded_features_index_clear_i ( st_data_t  key,
st_data_t  val,
st_data_t  arg 
)
static

Definition at line 266 of file load.c.

References ST_DELETE, and xfree.

Referenced by get_loaded_features_index().

NORETURN ( static void   load_failedVALUE)
static void rb_construct_expanded_load_path ( int  type,
int has_relative,
int has_non_cache 
)
static
static VALUE rb_f_autoload ( VALUE  obj,
VALUE  sym,
VALUE  file 
)
static

Definition at line 1116 of file load.c.

References klass, NIL_P(), rb_class_real(), rb_eTypeError, rb_mod_autoload(), rb_raise(), and rb_vm_cbase().

Referenced by Init_load().

static VALUE rb_f_autoload_p ( VALUE  obj,
VALUE  sym 
)
static

Definition at line 1137 of file load.c.

References klass, NIL_P(), Qnil, rb_mod_autoload_p(), and rb_vm_cbase().

Referenced by Init_load().

static VALUE rb_f_load ( int  argc,
VALUE argv 
)
static
VALUE rb_f_require ( VALUE  obj,
VALUE  fname 
)

Definition at line 806 of file load.c.

References rb_require_safe(), and rb_safe_level.

Referenced by Init_load().

VALUE rb_f_require_relative ( VALUE  obj,
VALUE  fname 
)
static int rb_feature_p ( const char *  feature,
const char *  ext,
int  rb,
int  expanded,
const char **  fn 
)
static
int rb_feature_provided ( const char *  feature,
const char **  loading 
)
VALUE rb_get_expanded_load_path ( void  )
VALUE rb_get_load_path ( void  )

Definition at line 34 of file load.c.

References GET_VM.

void rb_load ( VALUE  fname,
int  wrap 
)

Definition at line 638 of file load.c.

References FilePathValue, load_failed(), rb_find_file(), rb_load_internal(), and tmp.

Referenced by rb_load_protect().

static void rb_load_internal ( VALUE  fname,
int  wrap 
)
static
void rb_load_protect ( VALUE  fname,
int  wrap,
int state 
)

Definition at line 646 of file load.c.

References EXEC_TAG, POP_TAG, PUSH_TAG, rb_load(), and status.

static VALUE rb_mod_autoload ( VALUE  mod,
VALUE  sym,
VALUE  file 
)
static

Definition at line 1072 of file load.c.

References FilePathValue, Qnil, rb_autoload(), rb_to_id(), and RSTRING_PTR.

Referenced by Init_load(), and rb_f_autoload().

static VALUE rb_mod_autoload_p ( VALUE  mod,
VALUE  sym 
)
static

Definition at line 1095 of file load.c.

References Qnil, rb_autoload_p(), and rb_check_id().

Referenced by Init_load(), and rb_f_autoload_p().

void rb_provide ( const char *  feature)

Definition at line 566 of file load.c.

References rb_provide_feature(), and rb_usascii_str_new2.

Referenced by InitVM_Enumerator().

static void rb_provide_feature ( VALUE  feature)
static
int rb_provided ( const char *  feature)

Definition at line 517 of file load.c.

References rb_feature_provided().

VALUE rb_require ( const char *  fname)
VALUE rb_require_safe ( VALUE  fname,
int  safe 
)
static int register_init_ext ( st_data_t key,
st_data_t value,
st_data_t  init,
int  existing 
)
static

Definition at line 1032 of file load.c.

References name, NEW_MEMO, rb_warn(), ruby_strdup(), and ST_CONTINUE.

Referenced by ruby_init_ext().

static int release_thread_shield ( st_data_t key,
st_data_t value,
st_data_t  done,
int  existing 
)
static

Definition at line 745 of file load.c.

References rb_thread_shield_destroy(), rb_thread_shield_release(), ST_CONTINUE, ST_DELETE, ST_STOP, and xfree.

Referenced by load_unlock().

static void reset_loaded_features_snapshot ( void  )
static
RUBY_FUNC_EXPORTED void ruby_init_ext ( const char *  name,
void(*)(void init 
)

Definition at line 1047 of file load.c.

References get_loading_table(), GET_VM, register_init_ext(), st_init_strtable(), and st_update().

Referenced by init_golf().

static int search_required ( VALUE  fname,
volatile VALUE path,
int  safe_level 
)
static

Variable Documentation

const char* const loadable_ext[]
static
Initial value:
= {
".rb", DLEXT,
0
}

Definition at line 25 of file load.c.

Referenced by rb_feature_p(), and search_required().

VALUE ruby_dln_librefs

Definition at line 13 of file load.c.

Referenced by Init_load(), and rb_require_safe().