Skip to content

Commit

Permalink
Fix old-style function definition warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
cfis committed Jan 7, 2024
1 parent 10d29d5 commit 0038424
Show file tree
Hide file tree
Showing 14 changed files with 477 additions and 477 deletions.
2 changes: 1 addition & 1 deletion ext/ruby_prof/rp_allocation.c
Expand Up @@ -110,7 +110,7 @@ VALUE prof_allocation_wrap(prof_allocation_t* allocation)
}

/* ====== Allocation Table ====== */
st_table* prof_allocations_create()
st_table* prof_allocations_create(void)
{
return rb_st_init_numtable();
}
Expand Down
2 changes: 1 addition & 1 deletion ext/ruby_prof/rp_call_tree.c
Expand Up @@ -480,7 +480,7 @@ static VALUE prof_call_tree_load(VALUE self, VALUE data)
return data;
}

void rp_init_call_tree()
void rp_init_call_tree(void)
{
/* CallTree */
cRpCallTree = rb_define_class_under(mProf, "CallTree", rb_cObject);
Expand Down
2 changes: 1 addition & 1 deletion ext/ruby_prof/rp_call_tree.h
Expand Up @@ -42,6 +42,6 @@ prof_call_tree_t* prof_get_call_tree(VALUE self);
VALUE prof_call_tree_wrap(prof_call_tree_t* call_tree);
void prof_call_tree_free(prof_call_tree_t* call_tree);

void rp_init_call_tree();
void rp_init_call_tree(void);

#endif //__RP_CALL_TREE_H__
4 changes: 2 additions & 2 deletions ext/ruby_prof/rp_call_trees.c
Expand Up @@ -21,7 +21,7 @@ prof_call_trees_t* prof_get_call_trees(VALUE self)
return result;
}

prof_call_trees_t* prof_call_trees_create()
prof_call_trees_t* prof_call_trees_create(void)
{
prof_call_trees_t* result = ALLOC(prof_call_trees_t);
result->start = ALLOC_N(prof_call_tree_t*, INITIAL_CALL_TREES_SIZE);
Expand Down Expand Up @@ -279,7 +279,7 @@ VALUE prof_call_trees_load(VALUE self, VALUE data)
return data;
}

void rp_init_call_trees()
void rp_init_call_trees(void)
{
cRpCallTrees = rb_define_class_under(mProf, "CallTrees", rb_cObject);
rb_undef_method(CLASS_OF(cRpCallTrees), "new");
Expand Down
56 changes: 28 additions & 28 deletions ext/ruby_prof/rp_call_trees.h
@@ -1,28 +1,28 @@
/* Copyright (C) 2005-2013 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
Please see the LICENSE file for copyright and distribution information */

#ifndef __RP_CALL_TREES_H__
#define __RP_CALL_TREES_H__

#include "ruby_prof.h"
#include "rp_call_tree.h"

/* Array of call_tree objects */
typedef struct prof_call_trees_t
{
prof_call_tree_t** start;
prof_call_tree_t** end;
prof_call_tree_t** ptr;

VALUE object;
} prof_call_trees_t;


void rp_init_call_trees();
prof_call_trees_t* prof_call_trees_create();
void prof_call_trees_free(prof_call_trees_t* call_trees);
prof_call_trees_t* prof_get_call_trees(VALUE self);
void prof_add_call_tree(prof_call_trees_t* call_trees, prof_call_tree_t* call_tree);
VALUE prof_call_trees_wrap(prof_call_trees_t* call_trees);

#endif //__RP_CALL_TREES_H__
/* Copyright (C) 2005-2013 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
Please see the LICENSE file for copyright and distribution information */

#ifndef __RP_CALL_TREES_H__
#define __RP_CALL_TREES_H__

#include "ruby_prof.h"
#include "rp_call_tree.h"

/* Array of call_tree objects */
typedef struct prof_call_trees_t
{
prof_call_tree_t** start;
prof_call_tree_t** end;
prof_call_tree_t** ptr;

VALUE object;
} prof_call_trees_t;


void rp_init_call_trees(void);
prof_call_trees_t* prof_call_trees_create(void);
void prof_call_trees_free(prof_call_trees_t* call_trees);
prof_call_trees_t* prof_get_call_trees(VALUE self);
void prof_add_call_tree(prof_call_trees_t* call_trees, prof_call_tree_t* call_tree);
VALUE prof_call_trees_wrap(prof_call_trees_t* call_trees);

#endif //__RP_CALL_TREES_H__
94 changes: 47 additions & 47 deletions ext/ruby_prof/rp_measure_allocations.c
@@ -1,47 +1,47 @@
/* Copyright (C) 2005-2013 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
Please see the LICENSE file for copyright and distribution information */

/* :nodoc: */

#include "rp_measurement.h"

static VALUE cMeasureAllocations;
VALUE total_allocated_objects_key;

static double measure_allocations(rb_trace_arg_t* trace_arg)
{
static double result = 0;

if (trace_arg)
{
// Only process creation of new objects
rb_event_flag_t event = rb_tracearg_event_flag(trace_arg);
if (event == RUBY_INTERNAL_EVENT_NEWOBJ) {
// Don't count allocations of internal IMemo objects
VALUE object = rb_tracearg_object(trace_arg);
if (BUILTIN_TYPE(object) != T_IMEMO)
result++;
}
}
return result;
}

prof_measurer_t* prof_measurer_allocations(bool track_allocations)
{
prof_measurer_t* measure = ALLOC(prof_measurer_t);
measure->mode = MEASURE_ALLOCATIONS;
measure->measure = measure_allocations;
measure->multiplier = 1;
// Need to track allocations to get RUBY_INTERNAL_EVENT_NEWOBJ event
measure->track_allocations = track_allocations;

return measure;
}

void rp_init_measure_allocations()
{
total_allocated_objects_key = ID2SYM(rb_intern("total_allocated_objects"));
rb_define_const(mProf, "ALLOCATIONS", INT2NUM(MEASURE_ALLOCATIONS));

cMeasureAllocations = rb_define_class_under(mMeasure, "Allocations", rb_cObject);
}
/* Copyright (C) 2005-2013 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
Please see the LICENSE file for copyright and distribution information */

/* :nodoc: */

#include "rp_measurement.h"

static VALUE cMeasureAllocations;
VALUE total_allocated_objects_key;

static double measure_allocations(rb_trace_arg_t* trace_arg)
{
static double result = 0;

if (trace_arg)
{
// Only process creation of new objects
rb_event_flag_t event = rb_tracearg_event_flag(trace_arg);
if (event == RUBY_INTERNAL_EVENT_NEWOBJ) {
// Don't count allocations of internal IMemo objects
VALUE object = rb_tracearg_object(trace_arg);
if (BUILTIN_TYPE(object) != T_IMEMO)
result++;
}
}
return result;
}

prof_measurer_t* prof_measurer_allocations(bool track_allocations)
{
prof_measurer_t* measure = ALLOC(prof_measurer_t);
measure->mode = MEASURE_ALLOCATIONS;
measure->measure = measure_allocations;
measure->multiplier = 1;
// Need to track allocations to get RUBY_INTERNAL_EVENT_NEWOBJ event
measure->track_allocations = track_allocations;

return measure;
}

void rp_init_measure_allocations(void)
{
total_allocated_objects_key = ID2SYM(rb_intern("total_allocated_objects"));
rb_define_const(mProf, "ALLOCATIONS", INT2NUM(MEASURE_ALLOCATIONS));

cMeasureAllocations = rb_define_class_under(mMeasure, "Allocations", rb_cObject);
}
2 changes: 1 addition & 1 deletion ext/ruby_prof/rp_measure_memory.c
Expand Up @@ -38,7 +38,7 @@ prof_measurer_t* prof_measurer_memory(bool track_allocations)
return measure;
}

void rp_init_measure_memory()
void rp_init_measure_memory(void)
{
rb_define_const(mProf, "MEMORY", INT2NUM(MEASURE_MEMORY));

Expand Down
132 changes: 66 additions & 66 deletions ext/ruby_prof/rp_measure_process_time.c
@@ -1,66 +1,66 @@
/* Copyright (C) 2005-2019 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
Please see the LICENSE file for copyright and distribution information */

#include "rp_measurement.h"
#include <time.h>

static VALUE cMeasureProcessTime;

static double measure_process_time(rb_trace_arg_t* trace_arg)
{
#if defined(_WIN32)
FILETIME createTime;
FILETIME exitTime;
FILETIME kernelTime;
FILETIME userTime;

ULARGE_INTEGER kernelTimeInt;
ULARGE_INTEGER userTimeInt;

GetProcessTimes(GetCurrentProcess(), &createTime, &exitTime, &kernelTime, &userTime);

kernelTimeInt.LowPart = kernelTime.dwLowDateTime;
kernelTimeInt.HighPart = kernelTime.dwHighDateTime;
userTimeInt.LowPart = userTime.dwLowDateTime;
userTimeInt.HighPart = userTime.dwHighDateTime;

return (double)(kernelTimeInt.QuadPart + userTimeInt.QuadPart);
#elif !defined(CLOCK_PROCESS_CPUTIME_ID)
#include <sys/resource.h>
struct rusage usage;
getrusage(RUSAGE_SELF, &usage);
return usage.ru_stime.tv_sec + usage.ru_utime.tv_sec + ((usage.ru_stime.tv_usec + usage.ru_utime.tv_usec) / 1000000.0);
#else
struct timespec clock;
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &clock);
return clock.tv_sec + (clock.tv_nsec / 1000000000.0);
#endif
}

static double multiplier_process_time(void)
{
#if defined(_WIN32)
// Times are in 100-nanosecond time units. So instead of 10-9 use 10-7
return 1.0 / 10000000.0;
#else
return 1.0;
#endif
}

prof_measurer_t* prof_measurer_process_time(bool track_allocations)
{
prof_measurer_t* measure = ALLOC(prof_measurer_t);
measure->mode = MEASURE_PROCESS_TIME;
measure->measure = measure_process_time;
measure->multiplier = multiplier_process_time();
measure->track_allocations = track_allocations;
return measure;
}

void rp_init_measure_process_time()
{
rb_define_const(mProf, "CLOCKS_PER_SEC", INT2NUM(CLOCKS_PER_SEC));
rb_define_const(mProf, "PROCESS_TIME", INT2NUM(MEASURE_PROCESS_TIME));

cMeasureProcessTime = rb_define_class_under(mMeasure, "ProcessTime", rb_cObject);
}
/* Copyright (C) 2005-2019 Shugo Maeda <shugo@ruby-lang.org> and Charlie Savage <cfis@savagexi.com>
Please see the LICENSE file for copyright and distribution information */

#include "rp_measurement.h"
#include <time.h>

static VALUE cMeasureProcessTime;

static double measure_process_time(rb_trace_arg_t* trace_arg)
{
#if defined(_WIN32)
FILETIME createTime;
FILETIME exitTime;
FILETIME kernelTime;
FILETIME userTime;

ULARGE_INTEGER kernelTimeInt;
ULARGE_INTEGER userTimeInt;

GetProcessTimes(GetCurrentProcess(), &createTime, &exitTime, &kernelTime, &userTime);

kernelTimeInt.LowPart = kernelTime.dwLowDateTime;
kernelTimeInt.HighPart = kernelTime.dwHighDateTime;
userTimeInt.LowPart = userTime.dwLowDateTime;
userTimeInt.HighPart = userTime.dwHighDateTime;

return (double)(kernelTimeInt.QuadPart + userTimeInt.QuadPart);
#elif !defined(CLOCK_PROCESS_CPUTIME_ID)
#include <sys/resource.h>
struct rusage usage;
getrusage(RUSAGE_SELF, &usage);
return usage.ru_stime.tv_sec + usage.ru_utime.tv_sec + ((usage.ru_stime.tv_usec + usage.ru_utime.tv_usec) / 1000000.0);
#else
struct timespec clock;
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &clock);
return clock.tv_sec + (clock.tv_nsec / 1000000000.0);
#endif
}

static double multiplier_process_time(void)
{
#if defined(_WIN32)
// Times are in 100-nanosecond time units. So instead of 10-9 use 10-7
return 1.0 / 10000000.0;
#else
return 1.0;
#endif
}

prof_measurer_t* prof_measurer_process_time(bool track_allocations)
{
prof_measurer_t* measure = ALLOC(prof_measurer_t);
measure->mode = MEASURE_PROCESS_TIME;
measure->measure = measure_process_time;
measure->multiplier = multiplier_process_time();
measure->track_allocations = track_allocations;
return measure;
}

void rp_init_measure_process_time(void)
{
rb_define_const(mProf, "CLOCKS_PER_SEC", INT2NUM(CLOCKS_PER_SEC));
rb_define_const(mProf, "PROCESS_TIME", INT2NUM(MEASURE_PROCESS_TIME));

cMeasureProcessTime = rb_define_class_under(mMeasure, "ProcessTime", rb_cObject);
}

0 comments on commit 0038424

Please sign in to comment.