23 #include <sys/ioctl.h>
31 #if defined(__clang__)
34 #include "//'SYS1.SAMPLIB(CSRSIC)'"
39 #define CSD_OFFSET 0x294
50 #define RCTLACS_OFFSET 0xC4
53 #define CSD_NUMBER_ONLINE_CPUS 0xD4
56 #define CVTOPCTP_OFFSET 0x25C
59 #define RMCTRCT_OFFSET 0xE4
62 #define CVTRCEP_OFFSET 0x490
68 #define RCEPOOL_OFFSET 0x004
71 #define RCEAFC_OFFSET 0x088
74 #define CPCMODEL_LENGTH 16
80 #define ASCBRSME 0x16C
89 #define PGTH_CURRENT 1
91 #define PGTHAPATH 0x20
92 #pragma linkage(BPX4GTH, OS)
93 #pragma linkage(BPX1GTH, OS)
132 if (
loop->ep != NULL) {
140 unsigned long long timestamp;
181 struct Output_path_type {
190 void* Output_address;
191 struct Output_path_type* Output_path;
197 Output_length =
sizeof(Output_buf);
198 Output_address = &Output_buf;
199 Input_address = &Input_data;
200 memset(&Input_data, 0,
sizeof Input_data);
202 Input_data.pid = pid;
206 BPX4GTH(&Input_length,
214 BPX1GTH(&Input_length,
229 assert(((Output_buf.Output_data.offsetPath >>24) & 0xFF) ==
'A');
232 Output_path = (
struct Output_path_type*) ((
char*) (&Output_buf) +
233 (Output_buf.Output_data.offsetPath & 0x00FFFFFF));
235 if (Output_path->len >=
len) {
257 char abspath[PATH_MAX];
278 if (strchr(
args,
'/') != NULL) {
279 if (realpath(
args, abspath) != abspath)
282 abspath_size = strlen(abspath);
285 if (*
size > abspath_size)
286 *
size = abspath_size;
294 char trypath[PATH_MAX];
295 char* clonedpath = NULL;
303 if (clonedpath == NULL)
306 token = strtok(clonedpath,
":");
307 while (token != NULL) {
308 snprintf(trypath,
sizeof(trypath) - 1,
"%s/%s", token,
args);
309 if (realpath(trypath, abspath) == abspath) {
312 abspath_size = strlen(abspath);
315 if (*
size > abspath_size)
316 *
size = abspath_size;
325 token = strtok(NULL,
":");
370 rax = *(
char* __ptr32 *)(ascb +
ASCBRSME);
371 nframes = *(
unsigned int*)(rax +
RAXFMCT);
373 *rss = nframes * sysconf(_SC_PAGESIZE);
383 u.ut_type = BOOT_TIME;
387 *uptime = difftime64(time64(&t),
v->ut_tv.tv_sec);
415 cpu_info = *cpu_infos;
418 cpu_info->
speed = *(
int*)(info.siv1v2si22v1.si22v1cpucapability);
441 __net_ifconf6header_t ifc;
442 __net_ifconf6entry_t* ifr;
443 __net_ifconf6entry_t*
p;
444 __net_ifconf6entry_t flg;
450 if (0 > (sockfd =
socket(AF_INET, SOCK_DGRAM, IPPROTO_IP)))
453 ifc.__nif6h_version = 1;
457 if (ioctl(sockfd, SIOCGIFCONF6, &ifc) == -1) {
464 ifr = (__net_ifconf6entry_t*)(ifc.__nif6h_buffer);
465 while ((
char*)ifr < (
char*)ifc.__nif6h_buffer + ifc.__nif6h_buflen) {
467 ifr = (__net_ifconf6entry_t*)((
char*)ifr + ifc.__nif6h_entrylen);
469 if (!(
p->__nif6e_addr.sin6_family ==
AF_INET6 ||
470 p->__nif6e_addr.sin6_family == AF_INET))
473 if (!(
p->__nif6e_flags & _NIF6E_FLAGS_ON_LINK_ACTIVE))
485 address = *addresses;
487 ifr = (__net_ifconf6entry_t*)(ifc.__nif6h_buffer);
488 while ((
char*)ifr < (
char*)ifc.__nif6h_buffer + ifc.__nif6h_buflen) {
490 ifr = (__net_ifconf6entry_t*)((
char*)ifr + ifc.__nif6h_entrylen);
492 if (!(
p->__nif6e_addr.sin6_family ==
AF_INET6 ||
493 p->__nif6e_addr.sin6_family == AF_INET))
496 if (!(
p->__nif6e_flags & _NIF6E_FLAGS_ON_LINK_ACTIVE))
503 if (
p->__nif6e_addr.sin6_family ==
AF_INET6)
510 address->
is_internal = flg.__nif6e_flags & _NIF6E_FLAGS_LOOPBACK ? 1 : 0;
542 sockfd =
socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
548 if (ioctl(sockfd, SIOCGIFCONF, &ifc) == -1) {
553 #define MAX(a,b) (((a)>(b))?(a):(b))
554 #define ADDR_SIZE(p) MAX((p).sa_len, sizeof(p))
558 while ((
char*)ifr < (
char*)ifc.ifc_req + ifc.ifc_len) {
560 ifr = (
struct ifreq*)
561 ((
char*)ifr +
sizeof(ifr->ifr_name) +
ADDR_SIZE(ifr->ifr_addr));
563 if (!(
p->ifr_addr.sa_family ==
AF_INET6 ||
564 p->ifr_addr.sa_family == AF_INET))
567 memcpy(flg.ifr_name,
p->ifr_name,
sizeof(flg.ifr_name));
568 if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) {
573 if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING))
592 address = *addresses;
601 while ((
char*)ifr < (
char*)ifc.ifc_req + ifc.ifc_len) {
603 ifr = (
struct ifreq*)
604 ((
char*)ifr +
sizeof(ifr->ifr_name) +
ADDR_SIZE(ifr->ifr_addr));
606 if (!(
p->ifr_addr.sa_family ==
AF_INET6 ||
607 p->ifr_addr.sa_family == AF_INET))
610 memcpy(flg.ifr_name,
p->ifr_name,
sizeof(flg.ifr_name));
611 if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) {
616 if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING))
629 address->
is_internal = flg.ifr_flags & IFF_LOOPBACK ? 1 : 0;
657 assert(
loop->watchers != NULL);
664 for (
i = 0;
i < nfds;
i++)
669 if (
loop->ep != NULL)
679 p[0].events = POLLIN;
683 while (rv == -1 && errno == EINTR);
688 if (
p[0].revents & POLLNVAL)
719 reg_struct.__rfis_cmd = _RFIS_REG;
721 reg_struct.__rfis_type = 1;
728 rc = __w_pioctl(
path, _IOCC_REGFILEINT,
sizeof(reg_struct), ®_struct);
736 sizeof(
handle->rfis_rftok));
753 reg_struct.__rfis_cmd = _RFIS_UNREG;
755 reg_struct.__rfis_type = 1;
757 sizeof(
handle->rfis_rftok));
764 rc = __w_pioctl(
"/", _IOCC_REGFILEINT,
sizeof(reg_struct), ®_struct);
765 if (rc != 0 && errno != EALREADY && errno != ENOENT)
785 if (msglen == -1 && errno == ENOMSG)
792 if (
msg.__rfim_event == _RFIM_ATTR ||
msg.__rfim_event == _RFIM_WRITE)
794 else if (
msg.__rfim_event == _RFIM_RENAME)
807 static const int max_safe_timeout = 1789569;
822 if (
loop->nfds == 0) {
840 assert(w->
fd < (
int)
loop->nwatchers);
875 if (
sizeof(
int32_t) ==
sizeof(
long) &&
timeout >= max_safe_timeout)
914 assert(
loop->watchers != NULL);
917 for (
i = 0;
i < nfds;
i++) {
932 assert((
unsigned) fd < loop->nwatchers);
961 loop->watchers[
loop->nwatchers] = NULL;
962 loop->watchers[
loop->nwatchers + 1] = NULL;
982 real_timeout -= (
loop->time -
base);
983 if (real_timeout <= 0)