<commit_before>#include <sys/time.h>
#include "ruby/ruby.h"
#include "ruby/debug.h"

static VALUE mGCProf;
static VALUE sym_time, sym_count, sym_immediate_sweep;
static struct {
    size_t serial;
    VALUE tpval;
    VALUE proc;

    VALUE info;
    VALUE start;
    VALUE end_mark;
    VALUE end_sweep;
} _gcprof;

  static inline double
walltime()
{
  struct timespec ts;
#ifdef HAVE_CLOCK_GETTIME
  if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
    rb_sys_fail("clock_gettime");
  }
#else
  {
    struct timeval tv;
    if (gettimeofday(&tv, 0) < 0) {
      rb_sys_fail("gettimeofday");
    }
    ts.tv_sec = tv.tv_sec;
    ts.tv_nsec = tv.tv_usec * 1000;
  }
#endif
  return ts.tv_sec + ts.tv_nsec * 1e-9;
}

static char *
event_flag_name(rb_event_flag_t flag)
{
  switch (flag) {
    case RUBY_INTERNAL_EVENT_GC_START:
      return "gc_start";
    case RUBY_INTERNAL_EVENT_GC_END_MARK:
      return "gc_end_mark";
    case RUBY_INTERNAL_EVENT_GC_END_SWEEP:
      return "gc_end_sweep";
    default:
      return "unknown";
  }
}

static void
invoke_proc(void *data)
{
  VALUE args[4] = {_gcprof.info, _gcprof.start, _gcprof.end_mark, _gcprof.end_sweep};
  if (_gcprof.serial != (size_t)data) return;
  if (_gcprof.serial != NUM2SIZET(rb_hash_aref(_gcprof.end_sweep, sym_count))) args[3] = Qnil;
  rb_proc_call_with_block(_gcprof.proc, 4, args, Qnil);
}

static void
gc_hook_i(VALUE tpval, void *data)<commit_msg>fix some build warnings and errors<commit_after>#include <time.h>
#include <sys/time.h>
#include "ruby/ruby.h"
#include "ruby/debug.h"

static VALUE mGCProf;
static VALUE sym_time, sym_count, sym_immediate_sweep;
static struct {
    size_t serial;
    VALUE tpval;
    VALUE proc;

    VALUE info;
    VALUE start;
    VALUE end_mark;
    VALUE end_sweep;
} _gcprof;

  static inline double
walltime()
{
  struct timespec ts;
#ifdef HAVE_CLOCK_GETTIME
  if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
    rb_sys_fail("clock_gettime");
  }
#else
  {
    struct timeval tv;
    if (gettimeofday(&tv, 0) < 0) {
      rb_sys_fail("gettimeofday");
    }
    ts.tv_sec = tv.tv_sec;
    ts.tv_nsec = tv.tv_usec * 1000;
  }
#endif
  return ts.tv_sec + ts.tv_nsec * 1e-9;
}

static const char *
event_flag_name(rb_event_flag_t flag)
{
  switch (flag) {
    case RUBY_INTERNAL_EVENT_GC_START:
      return "gc_start";
    case RUBY_INTERNAL_EVENT_GC_END_MARK:
      return "gc_end_mark";
    case RUBY_INTERNAL_EVENT_GC_END_SWEEP:
      return "gc_end_sweep";
    default:
      return "unknown";
  }
}

static void
invoke_proc(void *data)
{
  VALUE args[4] = {_gcprof.info, _gcprof.start, _gcprof.end_mark, _gcprof.end_sweep};
  if (_gcprof.serial != (size_t)data) return;
  if (_gcprof.serial != NUM2SIZET(rb_hash_aref(_gcprof.end_sweep, sym_count))) args[3] = Qnil;
  rb_proc_call_with_block(_gcprof.proc, 4, args, Qnil);
}

static void
gc_hook_i(VALUE tpval, void *data)
{'fraction_non_alphanumeric': 0.11577123050259966, 'fraction_numerical': 0.00901213171577123, 'mean_word_length': 3.8260869565217392, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4839386', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1165, 'n_words': 237}