38 #include <sys/epoll.h>
39 #include <sys/param.h>
40 #include <sys/prctl.h>
41 #include <sys/sysinfo.h>
46 #define HAVE_IFADDRS_H 1
49 # if __UCLIBC_MAJOR__ < 0 && __UCLIBC_MINOR__ < 9 && __UCLIBC_SUBLEVEL__ < 32
50 # undef HAVE_IFADDRS_H
55 # if defined(__ANDROID__)
60 # include <sys/socket.h>
61 # include <net/ethernet.h>
62 # include <netpacket/packet.h>
66 #ifndef CLOCK_MONOTONIC_COARSE
67 # define CLOCK_MONOTONIC_COARSE 6
74 #ifndef CLOCK_BOOTTIME
75 # define CLOCK_BOOTTIME 7
93 if (
fd == -1 && (errno == ENOSYS || errno ==
EINVAL)) {
94 fd = epoll_create(256);
101 loop->inotify_fd = -1;
115 old_watchers =
loop->inotify_watchers;
118 loop->backend_fd = -1;
130 if (
loop->inotify_fd == -1)
return;
133 loop->inotify_fd = -1;
160 if (
loop->backend_fd >= 0) {
164 memset(&dummy, 0,
sizeof(dummy));
200 static const int max_safe_timeout = 1789569;
201 static int no_epoll_pwait_cached;
202 static int no_epoll_wait_cached;
224 if (
loop->nfds == 0) {
241 e.events =
w->pevents;
263 w->events =
w->pevents;
268 sigemptyset(&sigset);
269 sigaddset(&sigset, SIGPROF);
270 sigmask |= 1 << (SIGPROF - 1);
306 if (
sizeof(
int32_t) ==
sizeof(
long) &&
timeout >= max_safe_timeout)
309 if (sigmask != 0 && no_epoll_pwait != 0)
310 if (pthread_sigmask(SIG_BLOCK, &sigset,
NULL))
313 if (no_epoll_wait != 0 || (sigmask != 0 && no_epoll_pwait == 0)) {
314 nfds = epoll_pwait(
loop->backend_fd,
319 if (
nfds == -1 && errno == ENOSYS) {
328 if (
nfds == -1 && errno == ENOSYS) {
334 if (sigmask != 0 && no_epoll_pwait != 0)
335 if (pthread_sigmask(SIG_UNBLOCK, &sigset,
NULL))
347 if (reset_timeout != 0) {
365 if (errno == ENOSYS) {
367 assert(no_epoll_wait == 0 || no_epoll_pwait == 0);
374 if (reset_timeout != 0) {
401 loop->watchers[
loop->nwatchers] =
x.watchers;
414 assert((
unsigned) fd < loop->nwatchers);
433 pe->
events &=
w->pevents | POLLERR | POLLHUP;
458 if (
w == &
loop->signal_io_watcher) {
469 if (reset_timeout != 0) {
474 if (have_signals != 0) {
476 loop->signal_io_watcher.cb(
loop, &
loop->signal_io_watcher, POLLIN);
482 if (have_signals != 0)
503 real_timeout -= (
loop->time - base);
504 if (real_timeout <= 0)
513 static clock_t fast_clock_id = -1;
525 clock_id = CLOCK_MONOTONIC;
533 clock_id = CLOCK_MONOTONIC;
535 if (t.
tv_nsec <= 1 * 1000 * 1000)
542 if (clock_gettime(clock_id, &t))
559 while (
fd == -1 && errno ==
EINTR);
566 while (
n == -1 && errno ==
EINTR);
573 s = strchr(
buf,
' ');
585 for (
i = 1;
i <= 22;
i++) {
586 s = strchr(
s + 1,
' ');
598 *rss =
val * getpagesize();
607 static volatile int no_clock_boottime;
615 if (no_clock_boottime) {
616 retry:
r = clock_gettime(CLOCK_MONOTONIC, &now);
619 no_clock_boottime = 1;
635 if (!fgets(
buf,
sizeof(
buf), statfile_fp))
639 while (fgets(
buf,
sizeof(
buf), statfile_fp)) {
640 if (strncmp(
buf,
"cpu", 3))
654 unsigned int numcpus;
663 if (statfile_fp ==
NULL)
687 if (ci[0].speed == 0)
696 if (fclose(statfile_fp))
718 static const char model_marker[] =
"model name\t: ";
719 static const char speed_marker[] =
"cpu MHz\t\t: ";
720 const char* inferred_model;
721 unsigned int model_idx;
722 unsigned int speed_idx;
728 (void) &model_marker;
729 (void) &speed_marker;
738 #if defined(__arm__) || \
739 defined(__i386__) || \
740 defined(__mips__) || \
746 while (fgets(
buf,
sizeof(
buf), fp)) {
747 if (model_idx < numcpus) {
748 if (strncmp(
buf, model_marker,
sizeof(model_marker) - 1) == 0) {
749 model =
buf +
sizeof(model_marker) - 1;
755 ci[model_idx++].
model = model;
759 #if defined(__arm__) || defined(__mips__)
760 if (model_idx < numcpus) {
763 static const char model_marker[] =
"Processor\t: ";
765 static const char model_marker[] =
"cpu model\t\t: ";
767 if (strncmp(
buf, model_marker,
sizeof(model_marker) - 1) == 0) {
768 model =
buf +
sizeof(model_marker) - 1;
774 ci[model_idx++].
model = model;
779 if (speed_idx < numcpus) {
780 if (strncmp(
buf, speed_marker,
sizeof(speed_marker) - 1) == 0) {
781 ci[speed_idx++].
speed = atoi(
buf +
sizeof(speed_marker) - 1);
795 inferred_model =
"unknown";
797 inferred_model = ci[model_idx - 1].
model;
799 while (model_idx < numcpus) {
800 model =
uv__strndup(inferred_model, strlen(inferred_model));
803 ci[model_idx++].
model = model;
811 unsigned int numcpus,
815 unsigned int multiplier;
826 ticks = (
unsigned int)sysconf(_SC_CLK_TCK);
827 multiplier = ((
uint64_t)1000L / ticks);
828 assert(ticks != (
unsigned int) -1);
833 if (!fgets(
buf,
sizeof(
buf), statfile_fp))
838 while (fgets(
buf,
sizeof(
buf), statfile_fp)) {
842 if (strncmp(
buf,
"cpu", 3))
848 int r = sscanf(
buf,
"cpu%u ", &
n);
851 for (
len =
sizeof(
"cpu0");
n /= 10;
len++);
860 if (6 != sscanf(
buf +
len,
873 ts.
sys =
sys * multiplier;
875 ts.
irq =
irq * multiplier;
891 "/sys/devices/system/cpu/cpu%u/cpufreq/scaling_cur_freq",
918 return !exclude_type;
922 #ifndef HAVE_IFADDRS_H
930 struct sockaddr_ll *sll;
958 address = *addresses;
988 address = *addresses;
990 for (
i = 0;
i < (*count);
i++) {
991 size_t namelen = strlen(ent->
ifa_name);
993 if (strncmp(address->
name, ent->
ifa_name, namelen) == 0 &&
994 (address->
name[namelen] == 0 || address->
name[namelen] ==
':')) {
995 sll = (
struct sockaddr_ll*)ent->
ifa_addr;
1022 #if defined(PR_SET_NAME)
1023 prctl(PR_SET_NAME, title);
1040 while (
n == -1 && errno ==
EINTR);
1062 p = strstr(
buf, what);
1070 sscanf(
p,
"%" PRIu64 " kB", &rc);
1137 if (3 == sscanf(
buf,
"%lf %lf %lf", &avg[0], &avg[1], &avg[2]))
1143 avg[0] = (double)
info.loads[0] / 65536.0;
1144 avg[1] = (
double)
info.loads[1] / 65536.0;
1145 avg[2] = (double)
info.loads[2] / 65536.0;
__BEGIN_DECLS int getifaddrs(struct ifaddrs **ifap)
void freeifaddrs(struct ifaddrs *ifa)
RzBinInfo * info(RzBinFile *bf)
const lzma_allocator const uint8_t size_t uint8_t * out
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf nice
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags void static offset const char static length static mode static who const char struct statfs static buf unsigned unsigned num
static uint64_t uv__read_cgroups_uint64(const char *cgroup, const char *param)
static int uv__ifaddr_exclude(struct ifaddrs *ent, int exclude_type)
static int read_times(FILE *statfile_fp, unsigned int numcpus, uv_cpu_info_t *ci)
uint64_t uv_get_total_memory(void)
static uint64_t read_cpufreq(unsigned int cpunum)
static uint64_t uv__read_proc_meminfo(const char *what)
void uv_loadavg(double avg[3])
void uv__set_process_title(const char *title)
static void read_speeds(unsigned int numcpus, uv_cpu_info_t *ci)
void uv__platform_invalidate_fd(uv_loop_t *loop, int fd)
uint64_t uv_get_free_memory(void)
int uv_interface_addresses(uv_interface_address_t **addresses, int *count)
void uv__io_poll(uv_loop_t *loop, int timeout)
uint64_t uv__hrtime(uv_clocktype_t type)
int uv__io_check_fd(uv_loop_t *loop, int fd)
static int read_models(unsigned int numcpus, uv_cpu_info_t *ci)
int uv__platform_loop_init(uv_loop_t *loop)
static int uv__cpu_num(FILE *statfile_fp, unsigned int *numcpus)
int uv_uptime(double *uptime)
void uv_free_interface_addresses(uv_interface_address_t *addresses, int count)
int uv__io_fork(uv_loop_t *loop)
static int uv__slurp(const char *filename, char *buf, size_t len)
int uv_cpu_info(uv_cpu_info_t **cpu_infos, int *count)
uint64_t uv_get_constrained_memory(void)
void uv__platform_loop_delete(uv_loop_t *loop)
#define CLOCK_MONOTONIC_COARSE
int uv_resident_set_memory(size_t *rss)
int uv__inotify_fork(uv_loop_t *loop, void *old_watchers)
static const char struct stat static buf struct stat static buf static vhangup int struct rusage static rusage sysinfo
static const char struct stat static buf struct stat static buf static vhangup int struct rusage static rusage struct sysinfo static info unsigned static __unused struct utsname static buf const char static size const char static name static pid unsigned static persona static fsgid const void static flags const struct iovec static count static fd const void static len static munlockall struct sched_param static p static sched_yield static policy const struct timespec struct timespec static rem uid_t uid_t uid_t static suid struct pollfd unsigned nfds
assert(limit<=UINT32_MAX/2)
int epoll_wait(uv__os390_epoll *lst, struct epoll_event *events, int maxevents, int timeout)
int epoll_ctl(uv__os390_epoll *lst, int op, int fd, struct epoll_event *event)
uv__os390_epoll * epoll_create1(int flags)
#define QUEUE_DATA(ptr, type, field)
static struct sockaddr static addrlen static backlog const void static flags void flags
_W64 unsigned int uintptr_t
struct sockaddr * ifa_addr
struct ifaddrs * ifa_next
struct sockaddr * ifa_netmask
struct uv_cpu_times_s cpu_times
struct sockaddr_in6 netmask6
struct sockaddr_in6 address6
struct sockaddr_in netmask4
union uv_interface_address_s::@399 netmask
union uv_interface_address_s::@398 address
struct sockaddr_in address4
void uv__io_stop(uv_loop_t *loop, uv__io_t *w, unsigned int events)
int uv__open_cloexec(const char *path, int flags)
int uv__close_nocheckstdio(int fd)
FILE * uv__open_file(const char *path)
#define SAVE_ERRNO(block)
char * uv__strndup(const char *s, size_t n)
char * uv__strdup(const char *s)
void * uv__calloc(size_t count, size_t size)
void uv__metrics_update_idle_time(uv_loop_t *loop)
void uv__metrics_set_provider_entry_time(uv_loop_t *loop)
#define uv__load_relaxed(p)
#define uv__store_relaxed(p, v)
#define uv__get_internal_fields(loop)
UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t *cpu_infos, int count)
static const z80_opcode fd[]
int read(izstream &zs, T *x, Items items)