-
Notifications
You must be signed in to change notification settings - Fork 2
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 #7 from koron-go/darwin-support-1
add darwin (macos) support
- Loading branch information
Showing
2 changed files
with
24 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// +build !windows | ||
// +build !linux | ||
// +build !darwin | ||
// +build !freebsd | ||
// +build !plan9 | ||
// +build !netbsd | ||
|
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,23 @@ | ||
package phymem | ||
|
||
// #include <mach/mach.h> | ||
// | ||
//static vm_size_t getRSS(void) { | ||
// struct task_basic_info info; | ||
// mach_msg_type_number_t size = sizeof(info); | ||
// kern_return_t kerr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &size); | ||
// return kerr == KERN_SUCCESS ? info.resident_size : 0; | ||
//} | ||
import "C" | ||
import "errors" | ||
|
||
// for test. | ||
const providedCurrent = true | ||
|
||
func Current() (uint, error) { | ||
rss := uint(C.getRSS()) | ||
if rss == 0 { | ||
return 0, errors.New("failed to get RSS") | ||
} | ||
return rss, nil | ||
} |