Skip to content

Commit

Permalink
Merge pull request #5 from connorimes/master
Browse files Browse the repository at this point in the history
Update upstream to rev 2851086 - changes return types from c_ulonglon…
  • Loading branch information
connorimes committed Nov 19, 2015
2 parents c37b360 + 1c9999f commit 2bc9a95
Show file tree
Hide file tree
Showing 24 changed files with 112 additions and 92 deletions.
6 changes: 3 additions & 3 deletions energymon-dummy-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ extern crate libc;
extern crate energymon_sys;

pub use energymon_sys::energymon;
use libc::{c_int, c_ulonglong, c_char, size_t};
use libc::{c_int, uint64_t, c_char, size_t};

extern "C" {
pub fn energymon_init_dummy(em: *mut energymon) -> c_int;

pub fn energymon_read_total_dummy(em: *const energymon) -> c_ulonglong;
pub fn energymon_read_total_dummy(em: *const energymon) -> uint64_t;

pub fn energymon_finish_dummy(em: *mut energymon) -> c_int;

pub fn energymon_get_source_dummy(buffer: *mut c_char, n: size_t) -> *mut c_char;

pub fn energymon_get_interval_dummy(em: *const energymon) -> c_ulonglong;
pub fn energymon_get_interval_dummy(em: *const energymon) -> uint64_t;

pub fn energymon_get_dummy(em: *mut energymon) -> c_int;
}
6 changes: 3 additions & 3 deletions energymon-msr-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ extern crate libc;
extern crate energymon_sys;

pub use energymon_sys::energymon;
use libc::{c_int, c_ulonglong, c_char, size_t};
use libc::{c_int, uint64_t, c_char, size_t};

extern "C" {
pub fn energymon_init_msr(em: *mut energymon) -> c_int;

pub fn energymon_read_total_msr(em: *const energymon) -> c_ulonglong;
pub fn energymon_read_total_msr(em: *const energymon) -> uint64_t;

pub fn energymon_finish_msr(em: *mut energymon) -> c_int;

pub fn energymon_get_source_msr(buffer: *mut c_char, n: size_t) -> *mut c_char;

pub fn energymon_get_interval_msr(em: *const energymon) -> c_ulonglong;
pub fn energymon_get_interval_msr(em: *const energymon) -> uint64_t;

pub fn energymon_get_msr(em: *mut energymon) -> c_int;
}
6 changes: 3 additions & 3 deletions energymon-odroid-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ extern crate libc;
extern crate energymon_sys;

pub use energymon_sys::energymon;
use libc::{c_int, c_ulonglong, c_char, size_t};
use libc::{c_int, uint64_t, c_char, size_t};

extern "C" {
pub fn energymon_init_odroid(em: *mut energymon) -> c_int;

pub fn energymon_read_total_odroid(em: *const energymon) -> c_ulonglong;
pub fn energymon_read_total_odroid(em: *const energymon) -> uint64_t;

pub fn energymon_finish_odroid(em: *mut energymon) -> c_int;

pub fn energymon_get_source_odroid(buffer: *mut c_char, n: size_t) -> *mut c_char;

pub fn energymon_get_interval_odroid(em: *const energymon) -> c_ulonglong;
pub fn energymon_get_interval_odroid(em: *const energymon) -> uint64_t;

pub fn energymon_get_odroid(em: *mut energymon) -> c_int;
}
6 changes: 3 additions & 3 deletions energymon-osp-polling-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ extern crate libc;
extern crate energymon_sys;

pub use energymon_sys::energymon;
use libc::{c_int, c_ulonglong, c_char, size_t};
use libc::{c_int, uint64_t, c_char, size_t};

extern "C" {
pub fn energymon_init_osp_polling(em: *mut energymon) -> c_int;

pub fn energymon_read_total_osp_polling(em: *const energymon) -> c_ulonglong;
pub fn energymon_read_total_osp_polling(em: *const energymon) -> uint64_t;

pub fn energymon_finish_osp_polling(em: *mut energymon) -> c_int;

pub fn energymon_get_source_osp_polling(buffer: *mut c_char, n: size_t) -> *mut c_char;

pub fn energymon_get_interval_osp_polling(em: *const energymon) -> c_ulonglong;
pub fn energymon_get_interval_osp_polling(em: *const energymon) -> uint64_t;

pub fn energymon_get_osp_polling(em: *mut energymon) -> c_int;
}
6 changes: 3 additions & 3 deletions energymon-osp-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ extern crate libc;
extern crate energymon_sys;

pub use energymon_sys::energymon;
use libc::{c_int, c_ulonglong, c_char, size_t};
use libc::{c_int, uint64_t, c_char, size_t};

extern "C" {
pub fn energymon_init_osp(em: *mut energymon) -> c_int;

pub fn energymon_read_total_osp(em: *const energymon) -> c_ulonglong;
pub fn energymon_read_total_osp(em: *const energymon) -> uint64_t;

pub fn energymon_finish_osp(em: *mut energymon) -> c_int;

pub fn energymon_get_source_osp(buffer: *mut c_char, n: size_t) -> *mut c_char;

pub fn energymon_get_interval_osp(em: *const energymon) -> c_ulonglong;
pub fn energymon_get_interval_osp(em: *const energymon) -> uint64_t;

pub fn energymon_get_osp(em: *mut energymon) -> c_int;
}
6 changes: 3 additions & 3 deletions energymon-rapl-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ extern crate libc;
extern crate energymon_sys;

pub use energymon_sys::energymon;
use libc::{c_int, c_ulonglong, c_char, size_t};
use libc::{c_int, uint64_t, c_char, size_t};

extern "C" {
pub fn energymon_init_rapl(em: *mut energymon) -> c_int;

pub fn energymon_read_total_rapl(em: *const energymon) -> c_ulonglong;
pub fn energymon_read_total_rapl(em: *const energymon) -> uint64_t;

pub fn energymon_finish_rapl(em: *mut energymon) -> c_int;

pub fn energymon_get_source_rapl(buffer: *mut c_char, n: size_t) -> *mut c_char;

pub fn energymon_get_interval_rapl(em: *const energymon) -> c_ulonglong;
pub fn energymon_get_interval_rapl(em: *const energymon) -> uint64_t;

pub fn energymon_get_rapl(em: *mut energymon) -> c_int;
}
6 changes: 3 additions & 3 deletions energymon-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

extern crate libc;

use libc::{c_int, c_ulonglong, c_char, c_void, size_t};
use libc::{c_int, uint64_t, c_char, c_void, size_t};

/// Typedef for initialization function.
pub type energymon_init = extern fn(*mut energymon) -> c_int;
/// Typedef for read function.
pub type energymon_read_total = extern fn(*const energymon) -> c_ulonglong;
pub type energymon_read_total = extern fn(*const energymon) -> uint64_t;
/// Typedef for cleanup function.
pub type energymon_finish = extern fn(*mut energymon) -> c_int;
/// Typedef for function to get human-readable name.
pub type energymon_get_source = extern fn(*mut c_char, size_t) -> *mut c_char;
/// Typedef for function to get refresh interval.
pub type energymon_get_interval = extern fn(*const energymon) -> c_ulonglong;
pub type energymon_get_interval = extern fn(*const energymon) -> uint64_t;

#[repr(C)]
/// Representation of native C struct `energymon`.
Expand Down
5 changes: 3 additions & 2 deletions energymon/dummy/energymon-dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @date 2014-07-30
*/

#include <inttypes.h>
#include <string.h>
#include "energymon.h"
#include "energymon-dummy.h"
Expand All @@ -21,7 +22,7 @@ int energymon_init_dummy(energymon* impl) {
return 0;
}

unsigned long long energymon_read_total_dummy(const energymon* impl) {
uint64_t energymon_read_total_dummy(const energymon* impl) {
return 0;
}

Expand All @@ -33,7 +34,7 @@ char* energymon_get_source_dummy(char* buffer, size_t n) {
return energymon_strencpy(buffer, "Dummy Source", n);
}

unsigned long long energymon_get_interval_dummy(const energymon* em) {
uint64_t energymon_get_interval_dummy(const energymon* em) {
return 1;
}

Expand Down
5 changes: 3 additions & 2 deletions energymon/dummy/energymon-dummy.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@
extern "C" {
#endif

#include <inttypes.h>
#include <stddef.h>
#include "energymon.h"

int energymon_init_dummy(energymon* em);

unsigned long long energymon_read_total_dummy(const energymon* em);
uint64_t energymon_read_total_dummy(const energymon* em);

int energymon_finish_dummy(energymon* em);

char* energymon_get_source_dummy(char* buffer, size_t n);

unsigned long long energymon_get_interval_dummy(const energymon* em);
uint64_t energymon_get_interval_dummy(const energymon* em);

int energymon_get_dummy(energymon* impl);

Expand Down
5 changes: 3 additions & 2 deletions energymon/inc/energymon.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
extern "C" {
#endif

#include <inttypes.h>
#include <stddef.h>

typedef struct energymon energymon;
Expand All @@ -36,7 +37,7 @@ typedef int (*energymon_init) (energymon*);
* @param pointer to an energymon
* @return energy (in uJ)
*/
typedef unsigned long long (*energymon_read_total) (const energymon*);
typedef uint64_t (*energymon_read_total) (const energymon*);

/**
* Stop background tasks, close open file(s), free memory allocations, etc.
Expand All @@ -63,7 +64,7 @@ typedef char* (*energymon_get_source) (char* buffer, size_t n);
* @param pointer to an energymon
* @return the refresh interval
*/
typedef unsigned long long (*energymon_get_interval) (const energymon*);
typedef uint64_t (*energymon_get_interval) (const energymon*);

/**
* A structure to encapsulate a complete implementation. The first five fields
Expand Down
6 changes: 3 additions & 3 deletions energymon/msr/energymon-msr.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,14 @@ int energymon_init_msr(energymon* impl) {
return 0;
}

unsigned long long energymon_read_total_msr(const energymon* impl) {
uint64_t energymon_read_total_msr(const energymon* impl) {
if (impl == NULL || impl->state == NULL) {
return 0;
}

unsigned int i;
uint64_t msr_val;
unsigned long long total = 0;
uint64_t total = 0;
energymon_msr* em = impl->state;
for (i = 0; i < em->msr_count; i++) {
if (read_msr(em->msrs[i].fd, MSR_PKG_ENERGY_STATUS, &msr_val)) {
Expand Down Expand Up @@ -262,7 +262,7 @@ char* energymon_get_source_msr(char* buffer, size_t n) {
return energymon_strencpy(buffer, "X86 MSR", n);
}

unsigned long long energymon_get_interval_msr(const energymon* em) {
uint64_t energymon_get_interval_msr(const energymon* em) {
return 1000;
}

Expand Down
5 changes: 3 additions & 2 deletions energymon/msr/energymon-msr.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
extern "C" {
#endif

#include <inttypes.h>
#include <stddef.h>
#include "energymon.h"

Expand All @@ -25,13 +26,13 @@ extern "C" {

int energymon_init_msr(energymon* impl);

unsigned long long energymon_read_total_msr(const energymon* impl);
uint64_t energymon_read_total_msr(const energymon* impl);

int energymon_finish_msr(energymon* impl);

char* energymon_get_source_msr(char* buffer, size_t n);

unsigned long long energymon_get_interval_msr(const energymon* em);
uint64_t energymon_get_interval_msr(const energymon* em);

int energymon_get_msr(energymon* impl);

Expand Down
15 changes: 8 additions & 7 deletions energymon/odroid-ioctl/energymon-odroid-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -70,7 +71,7 @@ typedef struct energymon_odroid_ioctl {
// sensor update interval in microseconds
unsigned long poll_delay_us;
// total energy estimate
unsigned long long total_uj;
uint64_t total_uj;
// thread variables
pthread_t sensor_thread;
int poll_sensors;
Expand Down Expand Up @@ -144,7 +145,7 @@ static inline int read_sensor(ina231_sensor_t* sensor) {
*/
static inline int close_all_sensors(energymon_odroid_ioctl* em) {
int ret = 0;
int i = 0;
unsigned int i;
#ifdef ODROID_IOCTL_DISABLE_ON_CLOSE
for (i = 0; i < SENSOR_MAX; i++) {
if (em->sensor[i].data.enable) {
Expand All @@ -163,7 +164,7 @@ static inline int close_all_sensors(energymon_odroid_ioctl* em) {
*/
static inline int open_all_sensors(energymon_odroid_ioctl* em) {
int ret = 0;
int i;
unsigned int i;

if (open_sensor_file(DEV_SENSOR_ARM, &em->sensor[SENSOR_ARM]) ||
open_sensor_file(DEV_SENSOR_KFC, &em->sensor[SENSOR_KFC]) ||
Expand Down Expand Up @@ -215,8 +216,8 @@ int energymon_finish_odroid_ioctl(energymon* impl) {
*/
void* odroid_ioctl_poll_sensors(void* args) {
int bad_reading = 0;
unsigned long long sum_uw = 0;
int i = 0;
uint64_t sum_uw = 0;
unsigned int i = 0;
energymon_odroid_ioctl* em = (energymon_odroid_ioctl*) args;
struct timespec ts_interval;
ts_interval.tv_sec = em->poll_delay_us / (1000 * 1000);
Expand Down Expand Up @@ -287,7 +288,7 @@ int energymon_init_odroid_ioctl(energymon* impl) {
return 0;
}

unsigned long long energymon_read_total_odroid_ioctl(const energymon* impl) {
uint64_t energymon_read_total_odroid_ioctl(const energymon* impl) {
if (impl == NULL || impl->state == NULL) {
return -1;
}
Expand All @@ -298,7 +299,7 @@ char* energymon_get_source_odroid_ioctl(char* buffer, size_t n) {
return energymon_strencpy(buffer, "ODROID INA231 Power Sensors via ioctl", n);
}

unsigned long long energymon_get_interval_odroid_ioctl(const energymon* em) {
uint64_t energymon_get_interval_odroid_ioctl(const energymon* em) {
return ((energymon_odroid_ioctl*) em->state)->poll_delay_us;
}

Expand Down
4 changes: 2 additions & 2 deletions energymon/odroid-ioctl/energymon-odroid-ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ extern "C" {

int energymon_init_odroid_ioctl(energymon* em);

unsigned long long energymon_read_total_odroid_ioctl(const energymon* em);
uint64_t energymon_read_total_odroid_ioctl(const energymon* em);

int energymon_finish_odroid_ioctl(energymon* em);

char* energymon_get_source_odroid_ioctl(char* buffer, size_t n);

unsigned long long energymon_get_interval_odroid_ioctl(const energymon* em);
uint64_t energymon_get_interval_odroid_ioctl(const energymon* em);

int energymon_get_odroid_ioctl(energymon* impl);

Expand Down
Loading

0 comments on commit 2bc9a95

Please sign in to comment.