-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from orls/basic-osx-support
Basic Mac OSX support
- Loading branch information
Showing
10 changed files
with
102 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#define _GNU_SOURCE | ||
#include <sys/time.h> | ||
#include <sys/resource.h> | ||
|
||
#include "spx_resource_stats.h" | ||
#include "spx_thread.h" | ||
|
||
void spx_resource_stats_init(void) | ||
{ | ||
} | ||
|
||
void spx_resource_stats_shutdown(void) | ||
{ | ||
} | ||
|
||
|
||
size_t spx_resource_stats_wall_time(void) | ||
{ | ||
struct timeval tv; | ||
int ret = 0; | ||
ret = gettimeofday(&tv, NULL); | ||
if (ret == 0) { | ||
return tv.tv_sec * 1000 * 1000 + tv.tv_usec; | ||
} | ||
return ret; | ||
} | ||
|
||
size_t spx_resource_stats_cpu_time(void) | ||
{ | ||
struct rusage ru; | ||
getrusage(RUSAGE_SELF, &ru); | ||
return (ru.ru_utime.tv_sec + ru.ru_stime.tv_sec ) * 1000 * 1000 + | ||
(ru.ru_utime.tv_usec + ru.ru_stime.tv_usec); | ||
} | ||
|
||
void spx_resource_stats_io(size_t * in, size_t * out) | ||
{ | ||
// MacOS doesn't expose any per-process I/O counters equivalent to linux | ||
// procfs. | ||
*in = 0; | ||
*out = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#ifdef linux | ||
# include "spx_resource_stats-linux.c" | ||
#elif defined(__APPLE__) && defined(__MACH__) | ||
# include "spx_resource_stats-macos.c" | ||
#else | ||
# error "Your platform is not supported. Please open an issue." | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <time.h> | ||
#include <sys/time.h> | ||
|
||
#if defined(__APPLE__) && defined(__MACH__) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 101200) | ||
int clock_gettime(int clk_id, struct timespec *res) | ||
{ | ||
struct timeval tv; | ||
int ret = 0; | ||
ret = gettimeofday(&tv, NULL); | ||
if (ret == 0) { | ||
res->tv_sec = tv.tv_sec; | ||
res->tv_nsec = tv.tv_usec * 1000; | ||
} | ||
return ret; | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters