31 #ifndef SUNOS_NO_IFADDRS
35 #include <net/if_dl.h>
36 #include <net/if_arp.h>
37 #include <sys/sockio.h>
39 #include <sys/loadavg.h>
48 #define PORT_FIRED 0x69
49 #define PORT_UNUSED 0x0
50 #define PORT_LOADED 0x99
51 #define PORT_DELETED -1
53 #if (!defined(_LP64)) && (_FILE_OFFSET_BITS - 0 == 64)
54 #define PROCFS_FILE_OFFSET_BITS_HACK 1
55 #undef _FILE_OFFSET_BITS
57 #define PROCFS_FILE_OFFSET_BITS_HACK 0
62 #if (PROCFS_FILE_OFFSET_BITS_HACK - 0 == 1)
63 #define _FILE_OFFSET_BITS 64
72 loop->backend_fd = -1;
90 if (
loop->fs_fd != -1) {
95 if (
loop->backend_fd != -1) {
97 loop->backend_fd = -1;
103 #if defined(PORT_SOURCE_FILE)
104 if (
loop->fs_fd != -1) {
115 struct port_event* events;
122 events = (
struct port_event*)
loop->watchers[
loop->nwatchers];
129 if ((
int) events[
i].portev_object ==
fd)
130 events[
i].portev_object = -1;
135 if (port_associate(
loop->backend_fd, PORT_SOURCE_FD,
fd, POLLIN, 0))
138 if (port_dissociate(
loop->backend_fd, PORT_SOURCE_FD,
fd)) {
139 perror(
"(libuv) port_dissociate()");
148 struct port_event events[1024];
149 struct port_event* pe;
169 if (
loop->nfds == 0) {
182 if (port_associate(
loop->backend_fd,
187 perror(
"(libuv) port_associate()");
191 w->events =
w->pevents;
198 sigaddset(pset, SIGPROF);
226 events[0].portev_source = 0;
232 pthread_sigmask(SIG_BLOCK, pset,
NULL);
234 err = port_getn(
loop->backend_fd,
241 pthread_sigmask(SIG_UNBLOCK, pset,
NULL);
247 if (errno ==
EINTR || errno == ETIME) {
250 perror(
"(libuv) port_getn()");
261 if (events[0].portev_source == 0) {
262 if (reset_timeout != 0) {
285 loop->watchers[
loop->nwatchers] = (
void*) events;
289 fd = pe->portev_object;
296 assert((
unsigned) fd < loop->nwatchers);
307 if (
w == &
loop->signal_io_watcher) {
311 w->cb(
loop,
w, pe->portev_events);
324 if (reset_timeout != 0) {
329 if (have_signals != 0) {
331 loop->signal_io_watcher.cb(
loop, &
loop->signal_io_watcher, POLLIN);
337 if (have_signals != 0)
349 if (saved_errno == ETIME) {
363 diff =
loop->time - base;
389 snprintf(
buf,
sizeof(
buf),
"/proc/%lu/path/a.out", (
unsigned long) getpid());
405 return (
uint64_t) sysconf(_SC_PAGESIZE) * sysconf(_SC_AVPHYS_PAGES);
410 return (
uint64_t) sysconf(_SC_PAGESIZE) * sysconf(_SC_PHYS_PAGES);
420 (void) getloadavg(avg, 3);
424 #if defined(PORT_SOURCE_FILE)
430 if (port_associate(
handle->loop->fs_fd,
433 FILE_ATTRIB | FILE_MODIFIED,
445 unsigned int revents) {
470 while (
r == -1 && errno ==
EINTR);
472 if ((
r == -1 && errno == ETIME) ||
n == 0)
476 assert((
r == 0) &&
"unexpected port_get() error");
479 if (pe.portev_events & (FILE_ATTRIB | FILE_MODIFIED))
481 if (pe.portev_events & ~(FILE_ATTRIB | FILE_MODIFIED))
488 r = uv__fs_event_rearm(
handle);
506 unsigned int flags) {
515 if (
handle->loop->fs_fd == -1) {
516 portfd = port_create();
519 handle->loop->fs_fd = portfd;
550 port_dissociate(
handle->loop->fs_fd,
578 unsigned int flags) {
606 if (
read(
fd, &psinfo,
sizeof(psinfo)) ==
sizeof(psinfo)) {
607 *rss = (
size_t)psinfo.pr_rssize * 1024;
621 long hz = sysconf(_SC_CLK_TCK);
627 ksp = kstat_lookup(kc, (
char*)
"unix", 0, (
char*)
"system_misc");
628 if (kstat_read(kc, ksp,
NULL) == -1) {
631 knp = (kstat_named_t*) kstat_data_lookup(ksp, (
char*)
"clk_intr");
632 *uptime = knp->value.ul / hz;
653 while ((ksp = kstat_lookup(kc, (
char*)
"cpu_info", lookup_instance,
NULL))) {
657 *cpu_infos =
uv__malloc(lookup_instance *
sizeof(**cpu_infos));
663 *
count = lookup_instance;
665 cpu_info = *cpu_infos;
667 while ((ksp = kstat_lookup(kc, (
char*)
"cpu_info", lookup_instance,
NULL))) {
668 if (kstat_read(kc, ksp,
NULL) == -1) {
672 knp = kstat_data_lookup(ksp, (
char*)
"clock_MHz");
673 assert(knp->data_type == KSTAT_DATA_INT32 ||
674 knp->data_type == KSTAT_DATA_INT64);
675 cpu_info->
speed = (knp->data_type == KSTAT_DATA_INT32) ? knp->value.i32
678 knp = kstat_data_lookup(ksp, (
char*)
"brand");
679 assert(knp->data_type == KSTAT_DATA_STRING);
687 cpu_info = *cpu_infos;
690 ksp = kstat_lookup(kc, (
char*)
"cpu", lookup_instance, (
char*)
"sys");
695 if (kstat_read(kc, ksp,
NULL) == -1) {
702 knp = kstat_data_lookup(ksp, (
char*)
"cpu_ticks_user");
703 assert(knp->data_type == KSTAT_DATA_UINT64);
706 knp = kstat_data_lookup(ksp, (
char*)
"cpu_ticks_kernel");
707 assert(knp->data_type == KSTAT_DATA_UINT64);
710 knp = kstat_data_lookup(ksp, (
char*)
"cpu_ticks_idle");
711 assert(knp->data_type == KSTAT_DATA_UINT64);
714 knp = kstat_data_lookup(ksp, (
char*)
"intr");
715 assert(knp->data_type == KSTAT_DATA_UINT64);
730 #ifdef SUNOS_NO_IFADDRS
745 struct sockaddr_dl* sa_addr;
748 struct arpreq arpreq;
751 sa_addr = (
struct sockaddr_dl*)(ent->
ifa_addr);
758 memset(&arpreq, 0,
sizeof(arpreq));
775 if (
ioctl(
sockfd, SIOCGARP, (
char*)&arpreq) == -1) {
825 address = *addresses;
__BEGIN_DECLS int getifaddrs(struct ifaddrs **ifap)
void freeifaddrs(struct ifaddrs *ifa)
static mcore_handle handle
static static fork const void static count static fd const char const char static newpath const char static path const char path
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
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 socket
static static sync static getppid static getegid const char static filename char static len readlink
static static sync static getppid static getegid const char static filename ioctl
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
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)
#define QUEUE_DATA(ptr, type, field)
#define QUEUE_INSERT_TAIL(h, q)
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 in6_addr sin6_addr
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)
void uv__io_start(uv_loop_t *loop, uv__io_t *w, unsigned int events)
void uv__io_init(uv__io_t *w, uv__io_cb cb, int fd)
#define SAVE_ERRNO(block)
uint64_t uv_get_total_memory(void)
void uv__fs_event_close(uv_fs_event_t *handle)
static int uv__set_phys_addr(uv_interface_address_t *address, struct ifaddrs *ent)
void uv_loadavg(double avg[3])
int uv_fs_event_stop(uv_fs_event_t *handle)
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)
int uv__platform_loop_init(uv_loop_t *loop)
int uv_fs_event_start(uv_fs_event_t *handle, uv_fs_event_cb cb, const char *filename, unsigned int flags)
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)
int uv_fs_event_init(uv_loop_t *loop, uv_fs_event_t *handle)
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)
static int uv__ifaddr_exclude(struct ifaddrs *ent)
int uv_exepath(char *buffer, size_t *size)
int uv_resident_set_memory(size_t *rss)
char * uv__strdup(const char *s)
void * uv__malloc(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__handle_init(loop_, h, type_)
#define uv__handle_stop(h)
#define uv__get_internal_fields(loop)
#define uv__handle_start(h)
void(* uv_fs_event_cb)(uv_fs_event_t *handle, const char *filename, int events, int status)
static const z80_opcode fd[]
int read(izstream &zs, T *x, Items items)