Sha256: b673dbbed1d92b4c5102a54438ba06bd3edfeab78272f0ca98b5115c4e63bc8b

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

#include <stdlib.h>
#include <ruby.h>

static VALUE rb_Pyroscope;

#include <stdio.h>
#include <string.h>

int Start(char*, int, char*, char*);
int Stop(int);
int ChangeName(char*, int);

static VALUE
pyroscope_start(VALUE self, VALUE appName, VALUE pid, VALUE serverAddress) {
  VALUE r_appName = StringValue(appName);
  char *c_appName = RSTRING_PTR(r_appName);

  int c_pid = FIX2INT(pid);

  VALUE r_serverAddress = StringValue(serverAddress);
  char *c_serverAddress = RSTRING_PTR(r_serverAddress);

  int res = Start(c_appName, c_pid, "rbspy", c_serverAddress);

  return INT2FIX(res);
}

static VALUE
pyroscope_stop(VALUE self, VALUE pid) {
  int c_pid = FIX2INT(pid);
  int res = Stop(c_pid);
  return INT2FIX(res);
}

static VALUE
pyroscope_change_name(VALUE self, VALUE appName, VALUE pid) {
  VALUE r_appName = StringValue(appName);
  char *c_appName = RSTRING_PTR(r_appName);
  int c_pid = FIX2INT(pid);

  int res = ChangeName(c_appName, c_pid);
  return INT2FIX(res);
}

void
Init_pyroscope_c() {
  rb_Pyroscope = rb_define_module("Pyroscope");
  rb_define_module_function(rb_Pyroscope, "_start", pyroscope_start, 3);
  rb_define_module_function(rb_Pyroscope, "_stop", pyroscope_stop, 1);
  rb_define_module_function(rb_Pyroscope, "_change_name", pyroscope_change_name, 2);
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pyroscope-0.0.16 ext/pyroscope/pyroscope.c
pyroscope-0.0.14 ext/pyroscope/pyroscope.c
pyroscope-0.0.13 ext/pyroscope/pyroscope.c
pyroscope-0.0.12 ext/pyroscope/pyroscope.c