PAPI 7.1.0.0
Loading...
Searching...
No Matches
pfmlib_os_macos.c File Reference
Include dependency graph for pfmlib_os_macos.c:

Go to the source code of this file.

Enumerations

enum  mib_name_t { TYPE_NONE , TYPE_STR , TYPE_INT }
 

Functions

int __pfm_getcpuinfo_attr (const char *attr, char *ret_buf, size_t maxlen)
 
void pfm_init_syscalls (void)
 

Enumeration Type Documentation

◆ mib_name_t

enum mib_name_t
Enumerator
TYPE_NONE 
TYPE_STR 
TYPE_INT 

Definition at line 34 of file pfmlib_os_macos.c.

34 {
mib_name_t
@ TYPE_NONE
@ TYPE_STR
@ TYPE_INT

Function Documentation

◆ __pfm_getcpuinfo_attr()

int __pfm_getcpuinfo_attr ( const char *  attr,
char *  ret_buf,
size_t  maxlen 
)

Definition at line 54 of file pfmlib_os_macos.c.

55{
57 union {
58 char str[32];
59 int val;
60 } value;
61 char *name = NULL;
62 int mib[16];
63 int ret = -1;
64 size_t len, mib_len;
65
66 if (attr == NULL || ret_buf == NULL || maxlen < 1)
67 return -1;
68
69 *ret_buf = '\0';
70
71 if (!strcmp(attr, "vendor_id")) {
72 name = "machdep.cpu.vendor";
73 type = TYPE_STR;
74 } else if (!strcmp(attr, "model")) {
75 name = "machdep.cpu.model";
76 type = TYPE_INT;
77 } else if (!strcmp(attr, "cpu family")) {
78 name = "machdep.cpu.family";
79 type = TYPE_INT;
80 }
81
82 mib_len = 16;
83 ret = sysctlnametomib(name, mib, &mib_len);
84 if (ret)
85 return -1;
86
87 len = sizeof(value);
88 ret = sysctl(mib, mib_len, &value, &len, NULL, 0);
89 if (ret)
90 return ret;
91
92 if (type == TYPE_STR)
93 strncpy(ret_buf, value.str, maxlen);
94 else if (type == TYPE_INT)
95 snprintf(ret_buf, maxlen, "%d", value.val);
96
97 __pfm_vbprintf("attr=%s ret=%d ret_buf=%s\n", attr, ret, ret_buf);
98
99 return ret;
100}
uint16_t type
void __pfm_vbprintf(const char *fmt,...)
Definition: pfmlib_priv.c:52
const char * name
Definition: rocs.c:225
Here is the call graph for this function:

◆ pfm_init_syscalls()

void pfm_init_syscalls ( void  )

Definition at line 103 of file pfmlib_os_macos.c.

104{
105}
Here is the caller graph for this function: