Merge branches/quickjs to trunk. This is the way.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3621 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
COPYINGMakefileREADME.mdSConstruct
apps/cory
core
app.jsauth.htmlauth.jsbCrypt.jsclient.jscore.jshttpd.jsindex.htmlisaac.jsnetwork.jsstyle.cssterminal.js
deps
base64c
crypt_blowfish
LINKSMakefilePERFORMANCEREADMEcrypt.3crypt.hcrypt_blowfish.ccrypt_blowfish.hcrypt_gensalt.ccrypt_gensalt.hglibc-2.1.3-crypt.diffglibc-2.14-crypt.diffglibc-2.3.6-crypt.diffow-crypt.hwrapper.cx86.S
libuv
.gitattributes
.github
.gitignore.mailmapAUTHORSCMakeLists.txtCONTRIBUTING.mdChangeLogLICENSELICENSE-docsMAINTAINERS.mdMakefile.amREADME.mdSUPPORTED_PLATFORMS.mdautogen.shconfigure.acdocs
Makefilemake.bat
code
cgi
detach
dns
helloworld
idle-basic
idle-compute
interfaces
locks
multi-echo-server
onchange
pipe-echo-server
plugin
proc-streams
progress
queue-cancel
queue-work
ref-timer
signal
spawn
tcp-echo-server
thread-create
tty-gravity
tty
udp-dhcp
uvcat
uvstop
uvtee
uvwget
src
api.rstasync.rstcheck.rstconf.pydesign.rstdll.rstdns.rsterrors.rstfs.rstfs_event.rstfs_poll.rstguide.rst
guide
about.rstbasics.rsteventloops.rstfilesystem.rstintroduction.rstnetworking.rstprocesses.rstthreads.rstutilities.rst
handle.rstidle.rstindex.rstloop.rstmetrics.rstmigration_010_100.rstmisc.rstpipe.rstpoll.rstprepare.rstprocess.rstrequest.rstsignal.rstsphinx-plugins
static
architecture.png
stream.rsttcp.rstthreading.rstthreadpool.rsttimer.rsttty.rstudp.rstupgrading.rstversion.rstdiagrams.key
favicon.icologo.pngloop_iteration.pngimg
include
uv.h
libuv-static.pc.inlibuv.pc.inuv
m4
src
fs-poll.cheap-inl.hidna.cidna.hinet.cqueue.hrandom.cstrscpy.cstrscpy.hthreadpool.ctimer.c
unix
aix-common.caix.candroid-ifaddrs.casync.catomic-ops.hbsd-ifaddrs.cbsd-proctitle.ccore.ccygwin.cdarwin-proctitle.cdarwin-stub.hdarwin.cdl.cfreebsd.cfs.cfsevents.cgetaddrinfo.cgetnameinfo.chaiku.cibmi.cinternal.hkqueue.clinux-core.clinux-inotify.clinux-syscalls.clinux-syscalls.hloop-watcher.cloop.cnetbsd.cno-fsevents.cno-proctitle.copenbsd.cos390-syscalls.cos390-syscalls.hos390.cpipe.cpoll.cposix-hrtime.cposix-poll.cprocess.cprocfs-exepath.cproctitle.cpthread-fixes.cqnx.crandom-devurandom.crandom-getentropy.crandom-getrandom.crandom-sysctl-linux.csignal.cspinlock.hstream.csunos.csysinfo-loadavg.csysinfo-memory.ctcp.cthread.ctty.cudp.c
uv-common.cuv-common.huv-data-getter-setters.cversion.cwin
async.catomicops-inl.hcore.cdetect-wakeup.cdl.cerror.cfs-event.cfs-fd-hash-inl.hfs.cgetaddrinfo.cgetnameinfo.chandle-inl.hhandle.cinternal.hloop-watcher.cpipe.cpoll.cprocess-stdio.cprocess.creq-inl.hsignal.csnprintf.cstream-inl.hstream.ctcp.cthread.ctty.cudp.cutil.cwinapi.cwinapi.hwinsock.cwinsock.h
test
benchmark-async-pummel.cbenchmark-async.cbenchmark-fs-stat.cbenchmark-getaddrinfo.cbenchmark-list.hbenchmark-loop-count.cbenchmark-million-async.cbenchmark-million-timers.cbenchmark-multi-accept.cbenchmark-ping-pongs.cbenchmark-ping-udp.cbenchmark-pound.cbenchmark-pump.cbenchmark-sizes.cbenchmark-spawn.cbenchmark-tcp-write-batch.cbenchmark-thread.cbenchmark-udp-pummel.cblackhole-server.cdns-server.cecho-server.c
fixtures
run-benchmarks.crun-tests.crunner-unix.crunner-unix.hrunner-win.crunner-win.hrunner.crunner.htask.htest-active.ctest-async-null-cb.ctest-async.ctest-barrier.ctest-callback-order.ctest-callback-stack.ctest-close-fd.ctest-close-order.ctest-condvar.ctest-connect-unspecified.ctest-connection-fail.ctest-cwd-and-chdir.ctest-default-loop-close.ctest-delayed-accept.ctest-dlerror.ctest-eintr-handling.ctest-embed.ctest-emfile.ctest-env-vars.ctest-error.ctest-fail-always.ctest-fork.ctest-fs-copyfile.ctest-fs-event.ctest-fs-fd-hash.ctest-fs-open-flags.ctest-fs-poll.ctest-fs-readdir.ctest-fs.ctest-get-currentexe.ctest-get-loadavg.ctest-get-memory.ctest-get-passwd.ctest-getaddrinfo.ctest-gethostname.ctest-getnameinfo.ctest-getsockname.ctest-getters-setters.ctest-gettimeofday.ctest-handle-fileno.ctest-homedir.ctest-hrtime.ctest-idle.ctest-idna.ctest-ip4-addr.ctest-ip6-addr.ctest-ipc-heavy-traffic-deadlock-bug.ctest-ipc-send-recv.ctest-ipc.ctest-list.htest-loop-alive.ctest-loop-close.ctest-loop-configure.ctest-loop-handles.ctest-loop-stop.ctest-loop-time.ctest-metrics.ctest-multiple-listen.ctest-mutexes.ctest-osx-select.ctest-pass-always.ctest-ping-pong.ctest-pipe-bind-error.ctest-pipe-close-stdout-read-stdin.ctest-pipe-connect-error.ctest-pipe-connect-multiple.ctest-pipe-connect-prepare.ctest-pipe-getsockname.ctest-pipe-pending-instances.ctest-pipe-sendmsg.ctest-pipe-server-close.ctest-pipe-set-fchmod.ctest-pipe-set-non-blocking.ctest-platform-output.ctest-poll-close-doesnt-corrupt-stack.ctest-poll-close.ctest-poll-closesocket.ctest-poll-oob.ctest-poll.ctest-process-priority.ctest-process-title-threadsafe.ctest-process-title.ctest-queue-foreach-delete.ctest-random.ctest-ref.ctest-run-nowait.ctest-run-once.ctest-semaphore.ctest-shutdown-close.ctest-shutdown-eof.ctest-shutdown-twice.ctest-signal-multiple-loops.ctest-signal-pending-on-close.ctest-signal.ctest-socket-buffer-size.ctest-spawn.ctest-stdio-over-pipes.ctest-strscpy.ctest-tcp-alloc-cb-fail.ctest-tcp-bind-error.ctest-tcp-bind6-error.ctest-tcp-close-accept.ctest-tcp-close-reset.ctest-tcp-close-while-connecting.ctest-tcp-close.ctest-tcp-connect-error-after-write.ctest-tcp-connect-error.ctest-tcp-connect-timeout.ctest-tcp-connect6-error.ctest-tcp-create-socket-early.ctest-tcp-flags.ctest-tcp-oob.ctest-tcp-open.ctest-tcp-read-stop-start.ctest-tcp-read-stop.ctest-tcp-shutdown-after-write.ctest-tcp-try-write-error.ctest-tcp-try-write.ctest-tcp-unexpected-read.ctest-tcp-write-after-connect.ctest-tcp-write-fail.ctest-tcp-write-queue-order.ctest-tcp-write-to-half-open-connection.ctest-tcp-writealot.ctest-test-macros.ctest-thread-equal.ctest-thread.ctest-threadpool-cancel.ctest-threadpool.ctest-timer-again.ctest-timer-from-check.ctest-timer.ctest-tmpdir.ctest-tty-duplicate-key.ctest-tty-escape-sequence-processing.ctest-tty.ctest-udp-alloc-cb-fail.ctest-udp-bind.ctest-udp-connect.ctest-udp-create-socket-early.ctest-udp-dgram-too-big.ctest-udp-ipv6.ctest-udp-mmsg.ctest-udp-multicast-interface.ctest-udp-multicast-interface6.ctest-udp-multicast-join.ctest-udp-multicast-join6.ctest-udp-multicast-ttl.ctest-udp-open.ctest-udp-options.ctest-udp-send-and-recv.ctest-udp-send-hang-loop.ctest-udp-send-immediate.ctest-udp-send-unreachable.ctest-udp-sendmmsg-error.ctest-udp-try-send.ctest-uname.ctest-walk-handles.ctest-watcher-cross-stop.ctools
uv_win_longpath.manifestquickjs
ChangelogMakefileTODOVERSIONcutils.ccutils.h
doc
examples
jscompress.clibbf.clibbf.hlibregexp.clibregexp.hlibunicode-table.hlibunicode.cqjs.cqjsc.cqjscalc.jsquickjs-atom.hquickjs-libc.cquickjs-libc.hquickjs-opcode.hquickjs.cquickjs.hrelease.shrepl.jsrun-test262.ctest262.conftest262_errors.txttest262bn.conftest262bn_errors.txttests
bjson.cmicrobench.jstest262.patchtest_bignum.jstest_bjson.jstest_builtin.jstest_language.jstest_op_overloading.jstest_qjscalc.jstest_std.jstest_worker.jstest_worker_module.js
unicode_download.shunicode_gen.cunicode_gen_def.hsqlite
xopt
.circleci
.dockerignore.editorconfig.gitignoreCMakeLists.txtREADME.mdsnprintf.ctest
.gitignoreautohelp-1.outautohelp.cmacro-1.outmacro.cnocondense-1.outnocondense-sloppy-1.outnocondense-sloppy-2.outnocondense-sloppy-3.outnocondense-sloppy.cnocondense.coptional-longarg-1.outoptional-longarg.crequired-1.outrequired.csimple-1.outsimple.csloppyshorts-1.outsloppyshorts.ctest-case.sh
xopt.cxopt.hpackages/cory
about
administration
await
bbs
blink
blog
chat
chattest
contest
db
documentation
emojipush
geolocation
guess
hello
images
index
invite
invite2
ldjam34
libchat
libdocument
libencoding
libhttp
libiframe
libirc
liblist
libunfurl
libxml
libxmpp
meetup
messages
mmoturtle
monitor
news
reminder
sharedwiki
smtp
splits
tanks
test
tmirce
todo
turtle
ui
whatnext
wiki
xmas2016
youtube
src
Database.cppDatabase.hFile.cppFile.hMutex.cppMutex.hPacketStream.cppPacketStream.hSerialize.cppSerialize.hSocket.cppSocket.hTask.cppTask.hTaskStub.cppTaskStub.hTaskTryCatch.cppTaskTryCatch.hTls.hTlsContextWrapper.cppTlsContextWrapper.hbcrypt.cbcrypt.hdatabase.cdatabase.hfile.cfile.hmain.cmain.cpppacketstream.cpacketstream.hquickjstest.cserialize.cserialize.hsocket.csocket.hssb.cssb.connections.cssb.connections.hssb.hssb.qjs.cssb.qjs.hssb.rpc.cssb.rpc.hssb.tests.ctask.ctask.htaskstub.ctaskstub.htls.ctls.htlscontextwrapper.ctlscontextwrapper.htrace.ctrace.h
tests
tools
240
deps/libuv/src/unix/openbsd.c
vendored
Normal file
240
deps/libuv/src/unix/openbsd.c
vendored
Normal file
@ -0,0 +1,240 @@
|
||||
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "uv.h"
|
||||
#include "internal.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/sched.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <paths.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
int uv__platform_loop_init(uv_loop_t* loop) {
|
||||
return uv__kqueue_init(loop);
|
||||
}
|
||||
|
||||
|
||||
void uv__platform_loop_delete(uv_loop_t* loop) {
|
||||
}
|
||||
|
||||
|
||||
void uv_loadavg(double avg[3]) {
|
||||
struct loadavg info;
|
||||
size_t size = sizeof(info);
|
||||
int which[] = {CTL_VM, VM_LOADAVG};
|
||||
|
||||
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0) < 0) return;
|
||||
|
||||
avg[0] = (double) info.ldavg[0] / info.fscale;
|
||||
avg[1] = (double) info.ldavg[1] / info.fscale;
|
||||
avg[2] = (double) info.ldavg[2] / info.fscale;
|
||||
}
|
||||
|
||||
|
||||
int uv_exepath(char* buffer, size_t* size) {
|
||||
int mib[4];
|
||||
char **argsbuf = NULL;
|
||||
size_t argsbuf_size = 100U;
|
||||
size_t exepath_size;
|
||||
pid_t mypid;
|
||||
int err;
|
||||
|
||||
if (buffer == NULL || size == NULL || *size == 0)
|
||||
return UV_EINVAL;
|
||||
|
||||
mypid = getpid();
|
||||
for (;;) {
|
||||
err = UV_ENOMEM;
|
||||
argsbuf = uv__reallocf(argsbuf, argsbuf_size);
|
||||
if (argsbuf == NULL)
|
||||
goto out;
|
||||
mib[0] = CTL_KERN;
|
||||
mib[1] = KERN_PROC_ARGS;
|
||||
mib[2] = mypid;
|
||||
mib[3] = KERN_PROC_ARGV;
|
||||
if (sysctl(mib, ARRAY_SIZE(mib), argsbuf, &argsbuf_size, NULL, 0) == 0) {
|
||||
break;
|
||||
}
|
||||
if (errno != ENOMEM) {
|
||||
err = UV__ERR(errno);
|
||||
goto out;
|
||||
}
|
||||
argsbuf_size *= 2U;
|
||||
}
|
||||
|
||||
if (argsbuf[0] == NULL) {
|
||||
err = UV_EINVAL; /* FIXME(bnoordhuis) More appropriate error. */
|
||||
goto out;
|
||||
}
|
||||
|
||||
*size -= 1;
|
||||
exepath_size = strlen(argsbuf[0]);
|
||||
if (*size > exepath_size)
|
||||
*size = exepath_size;
|
||||
|
||||
memcpy(buffer, argsbuf[0], *size);
|
||||
buffer[*size] = '\0';
|
||||
err = 0;
|
||||
|
||||
out:
|
||||
uv__free(argsbuf);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
uint64_t uv_get_free_memory(void) {
|
||||
struct uvmexp info;
|
||||
size_t size = sizeof(info);
|
||||
int which[] = {CTL_VM, VM_UVMEXP};
|
||||
|
||||
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0))
|
||||
return UV__ERR(errno);
|
||||
|
||||
return (uint64_t) info.free * sysconf(_SC_PAGESIZE);
|
||||
}
|
||||
|
||||
|
||||
uint64_t uv_get_total_memory(void) {
|
||||
uint64_t info;
|
||||
int which[] = {CTL_HW, HW_PHYSMEM64};
|
||||
size_t size = sizeof(info);
|
||||
|
||||
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0))
|
||||
return UV__ERR(errno);
|
||||
|
||||
return (uint64_t) info;
|
||||
}
|
||||
|
||||
|
||||
uint64_t uv_get_constrained_memory(void) {
|
||||
return 0; /* Memory constraints are unknown. */
|
||||
}
|
||||
|
||||
|
||||
int uv_resident_set_memory(size_t* rss) {
|
||||
struct kinfo_proc kinfo;
|
||||
size_t page_size = getpagesize();
|
||||
size_t size = sizeof(struct kinfo_proc);
|
||||
int mib[6];
|
||||
|
||||
mib[0] = CTL_KERN;
|
||||
mib[1] = KERN_PROC;
|
||||
mib[2] = KERN_PROC_PID;
|
||||
mib[3] = getpid();
|
||||
mib[4] = sizeof(struct kinfo_proc);
|
||||
mib[5] = 1;
|
||||
|
||||
if (sysctl(mib, ARRAY_SIZE(mib), &kinfo, &size, NULL, 0) < 0)
|
||||
return UV__ERR(errno);
|
||||
|
||||
*rss = kinfo.p_vm_rssize * page_size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uv_uptime(double* uptime) {
|
||||
time_t now;
|
||||
struct timeval info;
|
||||
size_t size = sizeof(info);
|
||||
static int which[] = {CTL_KERN, KERN_BOOTTIME};
|
||||
|
||||
if (sysctl(which, ARRAY_SIZE(which), &info, &size, NULL, 0))
|
||||
return UV__ERR(errno);
|
||||
|
||||
now = time(NULL);
|
||||
|
||||
*uptime = (double)(now - info.tv_sec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
|
||||
unsigned int ticks = (unsigned int)sysconf(_SC_CLK_TCK),
|
||||
multiplier = ((uint64_t)1000L / ticks), cpuspeed;
|
||||
uint64_t info[CPUSTATES];
|
||||
char model[512];
|
||||
int numcpus = 1;
|
||||
int which[] = {CTL_HW,HW_MODEL};
|
||||
int percpu[] = {CTL_KERN,KERN_CPTIME2,0};
|
||||
size_t size;
|
||||
int i, j;
|
||||
uv_cpu_info_t* cpu_info;
|
||||
|
||||
size = sizeof(model);
|
||||
if (sysctl(which, ARRAY_SIZE(which), &model, &size, NULL, 0))
|
||||
return UV__ERR(errno);
|
||||
|
||||
which[1] = HW_NCPUONLINE;
|
||||
size = sizeof(numcpus);
|
||||
if (sysctl(which, ARRAY_SIZE(which), &numcpus, &size, NULL, 0))
|
||||
return UV__ERR(errno);
|
||||
|
||||
*cpu_infos = uv__malloc(numcpus * sizeof(**cpu_infos));
|
||||
if (!(*cpu_infos))
|
||||
return UV_ENOMEM;
|
||||
|
||||
i = 0;
|
||||
*count = numcpus;
|
||||
|
||||
which[1] = HW_CPUSPEED;
|
||||
size = sizeof(cpuspeed);
|
||||
if (sysctl(which, ARRAY_SIZE(which), &cpuspeed, &size, NULL, 0))
|
||||
goto error;
|
||||
|
||||
size = sizeof(info);
|
||||
for (i = 0; i < numcpus; i++) {
|
||||
percpu[2] = i;
|
||||
if (sysctl(percpu, ARRAY_SIZE(percpu), &info, &size, NULL, 0))
|
||||
goto error;
|
||||
|
||||
cpu_info = &(*cpu_infos)[i];
|
||||
|
||||
cpu_info->cpu_times.user = (uint64_t)(info[CP_USER]) * multiplier;
|
||||
cpu_info->cpu_times.nice = (uint64_t)(info[CP_NICE]) * multiplier;
|
||||
cpu_info->cpu_times.sys = (uint64_t)(info[CP_SYS]) * multiplier;
|
||||
cpu_info->cpu_times.idle = (uint64_t)(info[CP_IDLE]) * multiplier;
|
||||
cpu_info->cpu_times.irq = (uint64_t)(info[CP_INTR]) * multiplier;
|
||||
|
||||
cpu_info->model = uv__strdup(model);
|
||||
cpu_info->speed = cpuspeed;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
*count = 0;
|
||||
for (j = 0; j < i; j++)
|
||||
uv__free((*cpu_infos)[j].model);
|
||||
|
||||
uv__free(*cpu_infos);
|
||||
*cpu_infos = NULL;
|
||||
return UV__ERR(errno);
|
||||
}
|
Reference in New Issue
Block a user