Sha256: 2131f679440a5ca9924dcaa1d037969b8449e8b96e4555dcb2186ec5a75b5e63

Contents?: true

Size: 1.54 KB

Versions: 6

Compression:

Stored size: 1.54 KB

Contents

#include "extconf.h"

// This file exports functions used to access private Ruby VM APIs and internals.
// To do this, it imports a few VM internal (private) headers.
//
// **Important Note**: Our medium/long-term plan is to stop relying on all private Ruby headers, and instead request and
// contribute upstream changes so that they become official public VM APIs.
//
// In the meanwhile, be very careful when changing things here :)

#ifdef USE_MJIT_HEADER
// Pick up internal structures from the private Ruby MJIT header file
#include RUBY_MJIT_HEADER
#else
// On older Rubies, use a copy of the VM internal headers shipped in the debase-ruby_core_source gem
#include <vm_core.h>
#endif

// MRI has a similar rb_thread_ptr() function which we can't call it directly
// because Ruby does not expose the thread_data_type publicly.
// Instead, we have our own version of that function, and we lazily initialize the thread_data_type pointer
// from a known-correct object: the current thread.
//
// Note that beyond returning the rb_thread_struct*, rb_check_typeddata() raises an exception
// if the argument passed in is not actually a `Thread` instance.
static inline struct rb_thread_struct *thread_struct_from_object(VALUE thread) {
  static const rb_data_type_t *thread_data_type = NULL;
  if (thread_data_type == NULL) thread_data_type = RTYPEDDATA_TYPE(rb_thread_current());

  return (struct rb_thread_struct *) rb_check_typeddata(thread, thread_data_type);
}

rb_nativethread_id_t pthread_id_for(VALUE thread) {
  return thread_struct_from_object(thread)->thread_id;
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ddtrace-1.0.0 ext/ddtrace_profiling_native_extension/private_vm_api_access.c
ddtrace-1.0.0.beta2 ext/ddtrace_profiling_native_extension/private_vm_api_access.c
ddtrace-1.0.0.beta1 ext/ddtrace_profiling_native_extension/private_vm_api_access.c
ddtrace-0.54.2 ext/ddtrace_profiling_native_extension/private_vm_api_access.c
ddtrace-0.54.1 ext/ddtrace_profiling_native_extension/private_vm_api_access.c
ddtrace-0.54.0 ext/ddtrace_profiling_native_extension/private_vm_api_access.c