visaljs 0.0.0-stage → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +45 -2
- package/cli.js +8084 -0
- package/node/include/js_node.h +46 -0
- package/node/prelude/async_hooks.js +88 -0
- package/node/prelude/buffer.js +31 -0
- package/node/prelude/crypto.js +114 -0
- package/node/prelude/events.js +227 -0
- package/node/prelude/fs.js +79 -0
- package/node/prelude/http.js +536 -0
- package/node/prelude/http2.js +30 -0
- package/node/prelude/internal/crypto/asym.js +333 -0
- package/node/prelude/internal/crypto/cipher.js +205 -0
- package/node/prelude/internal/crypto/hash.js +137 -0
- package/node/prelude/internal/crypto/kdf.js +182 -0
- package/node/prelude/internal/crypto/keys.js +603 -0
- package/node/prelude/internal/crypto/random.js +118 -0
- package/node/prelude/internal/crypto/util.js +76 -0
- package/node/prelude/internal/errors.js +88 -0
- package/node/prelude/internal/querystring.js +105 -0
- package/node/prelude/module.js +53 -0
- package/node/prelude/net.js +51 -0
- package/node/prelude/os.js +129 -0
- package/node/prelude/path.js +257 -0
- package/node/prelude/process.js +21 -0
- package/node/prelude/querystring.js +469 -0
- package/node/prelude/stream.js +1327 -0
- package/node/prelude/stream_promises.js +7 -0
- package/node/prelude/stream_web.js +6 -0
- package/node/prelude/string_decoder.js +236 -0
- package/node/prelude/tty.js +18 -0
- package/node/prelude/url.js +1156 -0
- package/node/prelude/util.js +64 -0
- package/node/prelude/zlib.js +81 -0
- package/node/src/host_fs.c +126 -0
- package/node/src/host_http.c +486 -0
- package/node/src/host_os.c +505 -0
- package/node/src/host_sys.c +78 -0
- package/node/third_party/libuv/LICENSE +19 -0
- package/node/third_party/libuv/include/uv/aix.h +32 -0
- package/node/third_party/libuv/include/uv/bsd.h +34 -0
- package/node/third_party/libuv/include/uv/darwin.h +61 -0
- package/node/third_party/libuv/include/uv/errno.h +483 -0
- package/node/third_party/libuv/include/uv/linux.h +34 -0
- package/node/third_party/libuv/include/uv/os390.h +33 -0
- package/node/third_party/libuv/include/uv/posix.h +31 -0
- package/node/third_party/libuv/include/uv/sunos.h +44 -0
- package/node/third_party/libuv/include/uv/threadpool.h +37 -0
- package/node/third_party/libuv/include/uv/tree.h +521 -0
- package/node/third_party/libuv/include/uv/unix.h +512 -0
- package/node/third_party/libuv/include/uv/version.h +43 -0
- package/node/third_party/libuv/include/uv/win.h +698 -0
- package/node/third_party/libuv/include/uv.h +1990 -0
- package/node/third_party/libuv/src/fs-poll.c +290 -0
- package/node/third_party/libuv/src/heap-inl.h +245 -0
- package/node/third_party/libuv/src/idna.c +560 -0
- package/node/third_party/libuv/src/idna.h +31 -0
- package/node/third_party/libuv/src/inet.c +298 -0
- package/node/third_party/libuv/src/queue.h +90 -0
- package/node/third_party/libuv/src/random.c +123 -0
- package/node/third_party/libuv/src/strscpy.c +38 -0
- package/node/third_party/libuv/src/strscpy.h +39 -0
- package/node/third_party/libuv/src/strtok.c +52 -0
- package/node/third_party/libuv/src/strtok.h +27 -0
- package/node/third_party/libuv/src/thread-common.c +175 -0
- package/node/third_party/libuv/src/threadpool.c +419 -0
- package/node/third_party/libuv/src/timer.c +200 -0
- package/node/third_party/libuv/src/unix/async.c +418 -0
- package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +164 -0
- package/node/third_party/libuv/src/unix/core.c +2104 -0
- package/node/third_party/libuv/src/unix/darwin-proctitle.c +176 -0
- package/node/third_party/libuv/src/unix/darwin-stub.h +97 -0
- package/node/third_party/libuv/src/unix/darwin-syscalls.h +17 -0
- package/node/third_party/libuv/src/unix/darwin.c +237 -0
- package/node/third_party/libuv/src/unix/dl.c +80 -0
- package/node/third_party/libuv/src/unix/fs.c +2303 -0
- package/node/third_party/libuv/src/unix/fsevents.c +906 -0
- package/node/third_party/libuv/src/unix/getaddrinfo.c +252 -0
- package/node/third_party/libuv/src/unix/getnameinfo.c +121 -0
- package/node/third_party/libuv/src/unix/internal.h +530 -0
- package/node/third_party/libuv/src/unix/kqueue.c +667 -0
- package/node/third_party/libuv/src/unix/linux.c +2761 -0
- package/node/third_party/libuv/src/unix/loop-watcher.c +68 -0
- package/node/third_party/libuv/src/unix/loop.c +240 -0
- package/node/third_party/libuv/src/unix/pipe.c +555 -0
- package/node/third_party/libuv/src/unix/poll.c +159 -0
- package/node/third_party/libuv/src/unix/process.c +1123 -0
- package/node/third_party/libuv/src/unix/procfs-exepath.c +45 -0
- package/node/third_party/libuv/src/unix/proctitle.c +157 -0
- package/node/third_party/libuv/src/unix/random-devurandom.c +93 -0
- package/node/third_party/libuv/src/unix/random-getentropy.c +57 -0
- package/node/third_party/libuv/src/unix/random-getrandom.c +86 -0
- package/node/third_party/libuv/src/unix/random-sysctl-linux.c +99 -0
- package/node/third_party/libuv/src/unix/signal.c +581 -0
- package/node/third_party/libuv/src/unix/stream.c +1567 -0
- package/node/third_party/libuv/src/unix/tcp.c +673 -0
- package/node/third_party/libuv/src/unix/thread.c +975 -0
- package/node/third_party/libuv/src/unix/tty.c +510 -0
- package/node/third_party/libuv/src/unix/udp.c +1434 -0
- package/node/third_party/libuv/src/uv-common.c +1051 -0
- package/node/third_party/libuv/src/uv-common.h +474 -0
- package/node/third_party/libuv/src/uv-data-getter-setters.c +119 -0
- package/node/third_party/libuv/src/version.c +45 -0
- package/node/third_party/llhttp/LICENSE +22 -0
- package/node/third_party/llhttp/api.c +509 -0
- package/node/third_party/llhttp/http.c +170 -0
- package/node/third_party/llhttp/llhttp.c +10099 -0
- package/node/third_party/llhttp/llhttp.h +907 -0
- package/package.json +25 -4
- package/runtime/include/js_atoms.gen.h +68 -0
- package/runtime/include/js_atoms.h +54 -0
- package/runtime/include/js_bigint.h +93 -0
- package/runtime/include/js_buffer.h +79 -0
- package/runtime/include/js_builtins.h +168 -0
- package/runtime/include/js_console.h +58 -0
- package/runtime/include/js_convert.h +22 -0
- package/runtime/include/js_core.def +188 -0
- package/runtime/include/js_crypto.h +58 -0
- package/runtime/include/js_error.h +37 -0
- package/runtime/include/js_exception.h +65 -0
- package/runtime/include/js_function.h +167 -0
- package/runtime/include/js_gc.h +195 -0
- package/runtime/include/js_generator.h +96 -0
- package/runtime/include/js_host.h +19 -0
- package/runtime/include/js_jobs.h +84 -0
- package/runtime/include/js_module.h +16 -0
- package/runtime/include/js_object.h +384 -0
- package/runtime/include/js_ops.h +111 -0
- package/runtime/include/js_promise.h +45 -0
- package/runtime/include/js_regexp.h +25 -0
- package/runtime/include/js_runtime.h +30 -0
- package/runtime/include/js_symbol.h +62 -0
- package/runtime/include/js_web.h +110 -0
- package/runtime/include/jscell.h +48 -0
- package/runtime/include/jscontext.h +240 -0
- package/runtime/include/jsnum.h +42 -0
- package/runtime/include/jsstring.h +161 -0
- package/runtime/include/jsvalue.h +142 -0
- package/runtime/src/arguments.c +115 -0
- package/runtime/src/array.c +1145 -0
- package/runtime/src/arraybuffer.c +608 -0
- package/runtime/src/async_iter.c +479 -0
- package/runtime/src/atoms.c +157 -0
- package/runtime/src/base64.c +107 -0
- package/runtime/src/bigint.c +1189 -0
- package/runtime/src/blob.c +371 -0
- package/runtime/src/buffer.c +1357 -0
- package/runtime/src/builtin_table.c +100 -0
- package/runtime/src/builtins.c +987 -0
- package/runtime/src/builtins_util.h +53 -0
- package/runtime/src/collections.c +912 -0
- package/runtime/src/components.c +28 -0
- package/runtime/src/console.c +637 -0
- package/runtime/src/convert.c +82 -0
- package/runtime/src/core_all.c +21 -0
- package/runtime/src/crypto.c +116 -0
- package/runtime/src/crypto_asym.c +644 -0
- package/runtime/src/crypto_cipher.c +671 -0
- package/runtime/src/crypto_hash.c +260 -0
- package/runtime/src/crypto_host.c +414 -0
- package/runtime/src/crypto_internal.h +304 -0
- package/runtime/src/crypto_kdf.c +143 -0
- package/runtime/src/crypto_key.c +171 -0
- package/runtime/src/crypto_pkey.c +794 -0
- package/runtime/src/crypto_subtle.c +1675 -0
- package/runtime/src/date.c +940 -0
- package/runtime/src/domexception.c +169 -0
- package/runtime/src/elements.c +312 -0
- package/runtime/src/elements.h +45 -0
- package/runtime/src/encoding.c +485 -0
- package/runtime/src/error.c +297 -0
- package/runtime/src/events.c +793 -0
- package/runtime/src/exception.c +56 -0
- package/runtime/src/fetch.c +772 -0
- package/runtime/src/function.c +530 -0
- package/runtime/src/gc.c +803 -0
- package/runtime/src/generator.c +218 -0
- package/runtime/src/global.c +119 -0
- package/runtime/src/headers.c +557 -0
- package/runtime/src/inspect.c +1792 -0
- package/runtime/src/internal.h +80 -0
- package/runtime/src/iterate.c +94 -0
- package/runtime/src/iterator.c +409 -0
- package/runtime/src/jobs.c +337 -0
- package/runtime/src/jsnum.c +353 -0
- package/runtime/src/json.c +1028 -0
- package/runtime/src/math.c +243 -0
- package/runtime/src/module.c +336 -0
- package/runtime/src/number.c +176 -0
- package/runtime/src/object.c +1265 -0
- package/runtime/src/ops.c +322 -0
- package/runtime/src/os.c +196 -0
- package/runtime/src/os.h +29 -0
- package/runtime/src/process.c +432 -0
- package/runtime/src/promise.c +721 -0
- package/runtime/src/proxy.c +570 -0
- package/runtime/src/reflect.c +194 -0
- package/runtime/src/regexp.c +1141 -0
- package/runtime/src/regexp_anchor.h +34 -0
- package/runtime/src/regexp_message.h +32 -0
- package/runtime/src/shape.c +294 -0
- package/runtime/src/shape.h +46 -0
- package/runtime/src/streams.c +1046 -0
- package/runtime/src/streams.h +47 -0
- package/runtime/src/string.c +364 -0
- package/runtime/src/string_builtins.c +837 -0
- package/runtime/src/symbol.c +143 -0
- package/runtime/src/test_host.c +59 -0
- package/runtime/src/typedarray.c +1330 -0
- package/runtime/src/tznames.gen.h +712 -0
- package/runtime/src/uri.c +169 -0
- package/runtime/src/url.c +2116 -0
- package/runtime/src/weak.c +486 -0
- package/runtime/src/web.c +214 -0
- package/runtime/src/wrapper.c +59 -0
- package/runtime/src/writable.c +1486 -0
- package/runtime/third_party/ada-idna/LICENSE-MIT +18 -0
- package/runtime/third_party/ada-idna/README.md +27 -0
- package/runtime/third_party/ada-idna/convert.mjs +83 -0
- package/runtime/third_party/ada-idna/idna.c +416 -0
- package/runtime/third_party/ada-idna/idna.h +15 -0
- package/runtime/third_party/ada-idna/idna_tables.h +2657 -0
- package/runtime/third_party/bearssl/LICENSE.txt +21 -0
- package/runtime/third_party/bearssl/README.txt +136 -0
- package/runtime/third_party/bearssl/VERSION +1 -0
- package/runtime/third_party/bearssl/inc/bearssl.h +183 -0
- package/runtime/third_party/bearssl/inc/bearssl_aead.h +1059 -0
- package/runtime/third_party/bearssl/inc/bearssl_block.h +2618 -0
- package/runtime/third_party/bearssl/inc/bearssl_ec.h +967 -0
- package/runtime/third_party/bearssl/inc/bearssl_hash.h +1346 -0
- package/runtime/third_party/bearssl/inc/bearssl_hmac.h +241 -0
- package/runtime/third_party/bearssl/inc/bearssl_kdf.h +284 -0
- package/runtime/third_party/bearssl/inc/bearssl_pem.h +294 -0
- package/runtime/third_party/bearssl/inc/bearssl_prf.h +150 -0
- package/runtime/third_party/bearssl/inc/bearssl_rand.h +397 -0
- package/runtime/third_party/bearssl/inc/bearssl_rsa.h +1655 -0
- package/runtime/third_party/bearssl/inc/bearssl_ssl.h +4296 -0
- package/runtime/third_party/bearssl/inc/bearssl_x509.h +1474 -0
- package/runtime/third_party/bearssl/src/aead/ccm.c +346 -0
- package/runtime/third_party/bearssl/src/aead/eax.c +525 -0
- package/runtime/third_party/bearssl/src/aead/gcm.c +318 -0
- package/runtime/third_party/bearssl/src/codec/ccopy.c +44 -0
- package/runtime/third_party/bearssl/src/codec/dec16be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec16le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec32be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec32le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec64be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/dec64le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc16be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc16le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc32be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc32le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc64be.c +38 -0
- package/runtime/third_party/bearssl/src/codec/enc64le.c +38 -0
- package/runtime/third_party/bearssl/src/codec/pemdec.c +526 -0
- package/runtime/third_party/bearssl/src/codec/pemdec.t0 +314 -0
- package/runtime/third_party/bearssl/src/codec/pemenc.c +173 -0
- package/runtime/third_party/bearssl/src/config.h +247 -0
- package/runtime/third_party/bearssl/src/ec/ec_all_m15.c +121 -0
- package/runtime/third_party/bearssl/src/ec/ec_all_m31.c +171 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_i15.c +398 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_i31.c +390 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m15.c +1478 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m31.c +800 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m62.c +605 -0
- package/runtime/third_party/bearssl/src/ec/ec_c25519_m64.c +831 -0
- package/runtime/third_party/bearssl/src/ec/ec_curve25519.c +46 -0
- package/runtime/third_party/bearssl/src/ec/ec_default.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ec_keygen.c +86 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m15.c +2124 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m31.c +1469 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m62.c +1765 -0
- package/runtime/third_party/bearssl/src/ec/ec_p256_m64.c +1781 -0
- package/runtime/third_party/bearssl/src/ec/ec_prime_i15.c +824 -0
- package/runtime/third_party/bearssl/src/ec/ec_prime_i31.c +826 -0
- package/runtime/third_party/bearssl/src/ec/ec_pubkey.c +85 -0
- package/runtime/third_party/bearssl/src/ec/ec_secp256r1.c +51 -0
- package/runtime/third_party/bearssl/src/ec/ec_secp384r1.c +57 -0
- package/runtime/third_party/bearssl/src/ec/ec_secp521r1.c +64 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_atr.c +134 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_sign_asn1.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_sign_raw.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_vrfy_asn1.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_default_vrfy_raw.c +36 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_bits.c +47 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_sign_asn1.c +45 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_sign_raw.c +174 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_vrfy_asn1.c +48 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i15_vrfy_raw.c +166 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_bits.c +47 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_sign_asn1.c +45 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_sign_raw.c +173 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_vrfy_asn1.c +48 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_i31_vrfy_raw.c +165 -0
- package/runtime/third_party/bearssl/src/ec/ecdsa_rta.c +121 -0
- package/runtime/third_party/bearssl/src/hash/dig_oid.c +84 -0
- package/runtime/third_party/bearssl/src/hash/dig_size.c +50 -0
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul.c +345 -0
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul32.c +251 -0
- package/runtime/third_party/bearssl/src/hash/ghash_ctmul64.c +154 -0
- package/runtime/third_party/bearssl/src/hash/ghash_pclmul.c +389 -0
- package/runtime/third_party/bearssl/src/hash/ghash_pwr8.c +411 -0
- package/runtime/third_party/bearssl/src/hash/md5.c +208 -0
- package/runtime/third_party/bearssl/src/hash/md5sha1.c +141 -0
- package/runtime/third_party/bearssl/src/hash/mgf1.c +56 -0
- package/runtime/third_party/bearssl/src/hash/multihash.c +166 -0
- package/runtime/third_party/bearssl/src/hash/sha1.c +191 -0
- package/runtime/third_party/bearssl/src/hash/sha2big.c +285 -0
- package/runtime/third_party/bearssl/src/hash/sha2small.c +341 -0
- package/runtime/third_party/bearssl/src/inner.h +2577 -0
- package/runtime/third_party/bearssl/src/int/i15_add.c +46 -0
- package/runtime/third_party/bearssl/src/int/i15_bitlen.c +44 -0
- package/runtime/third_party/bearssl/src/int/i15_decmod.c +124 -0
- package/runtime/third_party/bearssl/src/int/i15_decode.c +56 -0
- package/runtime/third_party/bearssl/src/int/i15_decred.c +100 -0
- package/runtime/third_party/bearssl/src/int/i15_encode.c +56 -0
- package/runtime/third_party/bearssl/src/int/i15_fmont.c +59 -0
- package/runtime/third_party/bearssl/src/int/i15_iszero.c +39 -0
- package/runtime/third_party/bearssl/src/int/i15_moddiv.c +465 -0
- package/runtime/third_party/bearssl/src/int/i15_modpow.c +50 -0
- package/runtime/third_party/bearssl/src/int/i15_modpow2.c +160 -0
- package/runtime/third_party/bearssl/src/int/i15_montmul.c +184 -0
- package/runtime/third_party/bearssl/src/int/i15_mulacc.c +61 -0
- package/runtime/third_party/bearssl/src/int/i15_muladd.c +173 -0
- package/runtime/third_party/bearssl/src/int/i15_ninv15.c +38 -0
- package/runtime/third_party/bearssl/src/int/i15_reduce.c +66 -0
- package/runtime/third_party/bearssl/src/int/i15_rshift.c +47 -0
- package/runtime/third_party/bearssl/src/int/i15_sub.c +46 -0
- package/runtime/third_party/bearssl/src/int/i15_tmont.c +36 -0
- package/runtime/third_party/bearssl/src/int/i31_add.c +46 -0
- package/runtime/third_party/bearssl/src/int/i31_bitlen.c +44 -0
- package/runtime/third_party/bearssl/src/int/i31_decmod.c +124 -0
- package/runtime/third_party/bearssl/src/int/i31_decode.c +57 -0
- package/runtime/third_party/bearssl/src/int/i31_decred.c +103 -0
- package/runtime/third_party/bearssl/src/int/i31_encode.c +79 -0
- package/runtime/third_party/bearssl/src/int/i31_fmont.c +60 -0
- package/runtime/third_party/bearssl/src/int/i31_iszero.c +39 -0
- package/runtime/third_party/bearssl/src/int/i31_moddiv.c +488 -0
- package/runtime/third_party/bearssl/src/int/i31_modpow.c +65 -0
- package/runtime/third_party/bearssl/src/int/i31_modpow2.c +160 -0
- package/runtime/third_party/bearssl/src/int/i31_montmul.c +127 -0
- package/runtime/third_party/bearssl/src/int/i31_mulacc.c +74 -0
- package/runtime/third_party/bearssl/src/int/i31_muladd.c +157 -0
- package/runtime/third_party/bearssl/src/int/i31_ninv31.c +39 -0
- package/runtime/third_party/bearssl/src/int/i31_reduce.c +66 -0
- package/runtime/third_party/bearssl/src/int/i31_rshift.c +47 -0
- package/runtime/third_party/bearssl/src/int/i31_sub.c +46 -0
- package/runtime/third_party/bearssl/src/int/i31_tmont.c +36 -0
- package/runtime/third_party/bearssl/src/int/i32_add.c +51 -0
- package/runtime/third_party/bearssl/src/int/i32_bitlen.c +44 -0
- package/runtime/third_party/bearssl/src/int/i32_decmod.c +77 -0
- package/runtime/third_party/bearssl/src/int/i32_decode.c +63 -0
- package/runtime/third_party/bearssl/src/int/i32_decred.c +107 -0
- package/runtime/third_party/bearssl/src/int/i32_div32.c +56 -0
- package/runtime/third_party/bearssl/src/int/i32_encode.c +72 -0
- package/runtime/third_party/bearssl/src/int/i32_fmont.c +60 -0
- package/runtime/third_party/bearssl/src/int/i32_iszero.c +39 -0
- package/runtime/third_party/bearssl/src/int/i32_modpow.c +65 -0
- package/runtime/third_party/bearssl/src/int/i32_montmul.c +69 -0
- package/runtime/third_party/bearssl/src/int/i32_mulacc.c +56 -0
- package/runtime/third_party/bearssl/src/int/i32_muladd.c +138 -0
- package/runtime/third_party/bearssl/src/int/i32_ninv32.c +39 -0
- package/runtime/third_party/bearssl/src/int/i32_reduce.c +66 -0
- package/runtime/third_party/bearssl/src/int/i32_sub.c +51 -0
- package/runtime/third_party/bearssl/src/int/i32_tmont.c +36 -0
- package/runtime/third_party/bearssl/src/int/i62_modpow2.c +493 -0
- package/runtime/third_party/bearssl/src/kdf/hkdf.c +107 -0
- package/runtime/third_party/bearssl/src/kdf/shake.c +590 -0
- package/runtime/third_party/bearssl/src/mac/hmac.c +122 -0
- package/runtime/third_party/bearssl/src/mac/hmac_ct.c +193 -0
- package/runtime/third_party/bearssl/src/rand/aesctr_drbg.c +206 -0
- package/runtime/third_party/bearssl/src/rand/hmac_drbg.c +157 -0
- package/runtime/third_party/bearssl/src/rand/sysrng.c +252 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_keygen.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_modulus.c +36 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_oaep_decrypt.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_oaep_encrypt.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pkcs1_sign.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pkcs1_vrfy.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_priv.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_privexp.c +36 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pss_sign.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pss_vrfy.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pub.c +38 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_default_pubexp.c +36 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_keygen.c +583 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_modulus.c +99 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_oaep_decrypt.c +41 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_oaep_encrypt.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pkcs1_sign.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pkcs1_vrfy.c +43 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_priv.c +209 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_privexp.c +320 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pss_sign.c +40 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pss_vrfy.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pub.c +113 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i15_pubexp.c +152 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_keygen.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_keygen_inner.c +608 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_modulus.c +99 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_oaep_decrypt.c +41 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_oaep_encrypt.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pkcs1_sign.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pkcs1_vrfy.c +43 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_priv.c +203 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_privexp.c +318 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pss_sign.c +40 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pss_vrfy.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pub.c +106 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i31_pubexp.c +152 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_oaep_decrypt.c +41 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_oaep_encrypt.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pkcs1_sign.c +37 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pkcs1_vrfy.c +43 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_priv.c +160 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pss_sign.c +40 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pss_vrfy.c +44 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i32_pub.c +77 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_keygen.c +57 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_oaep_decrypt.c +61 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_oaep_encrypt.c +64 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pkcs1_sign.c +57 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pkcs1_vrfy.c +63 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_priv.c +223 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pss_sign.c +60 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pss_vrfy.c +64 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_i62_pub.c +125 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_oaep_pad.c +112 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_oaep_unpad.c +145 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pkcs1_sig_pad.c +100 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pkcs1_sig_unpad.c +121 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pss_sig_pad.c +106 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_pss_sig_unpad.c +121 -0
- package/runtime/third_party/bearssl/src/rsa/rsa_ssl_decrypt.c +52 -0
- package/runtime/third_party/bearssl/src/settings.c +306 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_cbcdec.c +69 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_cbcenc.c +67 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_ctr.c +84 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_ctrcbc.c +142 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_dec.c +254 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_big_enc.c +157 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_common.c +112 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct.c +328 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64.c +398 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_cbcdec.c +104 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_cbcenc.c +81 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_ctr.c +114 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_ctrcbc.c +433 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_dec.c +159 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct64_enc.c +115 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_cbcdec.c +111 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_cbcenc.c +91 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_ctr.c +116 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_ctrcbc.c +422 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_dec.c +170 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_ct_enc.c +112 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8.c +445 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_cbcdec.c +670 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_cbcenc.c +417 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_ctr.c +717 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_pwr8_ctrcbc.c +946 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_cbcdec.c +69 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_cbcenc.c +67 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_ctr.c +84 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_ctrcbc.c +142 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_dec.c +176 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_small_enc.c +129 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni.c +240 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_cbcdec.c +223 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_cbcenc.c +122 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_ctr.c +211 -0
- package/runtime/third_party/bearssl/src/symcipher/aes_x86ni_ctrcbc.c +596 -0
- package/runtime/third_party/bearssl/src/symcipher/chacha20_ct.c +106 -0
- package/runtime/third_party/bearssl/src/symcipher/chacha20_sse2.c +237 -0
- package/runtime/third_party/bearssl/src/symcipher/des_ct.c +411 -0
- package/runtime/third_party/bearssl/src/symcipher/des_ct_cbcdec.c +87 -0
- package/runtime/third_party/bearssl/src/symcipher/des_ct_cbcenc.c +69 -0
- package/runtime/third_party/bearssl/src/symcipher/des_support.c +166 -0
- package/runtime/third_party/bearssl/src/symcipher/des_tab.c +310 -0
- package/runtime/third_party/bearssl/src/symcipher/des_tab_cbcdec.c +85 -0
- package/runtime/third_party/bearssl/src/symcipher/des_tab_cbcenc.c +67 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmul.c +260 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmul32.c +297 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_ctmulq.c +475 -0
- package/runtime/third_party/bearssl/src/symcipher/poly1305_i15.c +221 -0
- package/runtime/third_party/bearssl/src/x509/asn1.t0 +757 -0
- package/runtime/third_party/bearssl/src/x509/asn1enc.c +93 -0
- package/runtime/third_party/bearssl/src/x509/encode_ec_pk8der.c +110 -0
- package/runtime/third_party/bearssl/src/x509/encode_ec_rawder.c +161 -0
- package/runtime/third_party/bearssl/src/x509/encode_rsa_pk8der.c +97 -0
- package/runtime/third_party/bearssl/src/x509/encode_rsa_rawder.c +96 -0
- package/runtime/third_party/bearssl/src/x509/skey_decoder.c +653 -0
- package/runtime/third_party/bearssl/src/x509/skey_decoder.t0 +376 -0
- package/runtime/third_party/bearssl/src/x509/x509_decoder.c +776 -0
- package/runtime/third_party/bearssl/src/x509/x509_decoder.t0 +324 -0
- package/runtime/third_party/bearssl/src/x509/x509_knownkey.c +105 -0
- package/runtime/third_party/bearssl/src/x509/x509_minimal.c +1722 -0
- package/runtime/third_party/bearssl/src/x509/x509_minimal.t0 +1526 -0
- package/runtime/third_party/bearssl/src/x509/x509_minimal_full.c +59 -0
- package/runtime/third_party/quickjs-dtoa/LICENSE +22 -0
- package/runtime/third_party/quickjs-dtoa/README.md +23 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.c +1640 -0
- package/runtime/third_party/quickjs-dtoa/dtoa.h +83 -0
- package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +89 -0
- package/runtime/third_party/quickjs-regexp/LICENSE +22 -0
- package/runtime/third_party/quickjs-regexp/README.md +22 -0
- package/runtime/third_party/quickjs-regexp/cutils.c +641 -0
- package/runtime/third_party/quickjs-regexp/cutils.h +457 -0
- package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +73 -0
- package/runtime/third_party/quickjs-regexp/libregexp.c +3448 -0
- package/runtime/third_party/quickjs-regexp/libregexp.h +65 -0
- package/runtime/third_party/quickjs-regexp/libunicode-table.h +5206 -0
- package/runtime/third_party/quickjs-regexp/libunicode.c +2124 -0
- package/runtime/third_party/quickjs-regexp/libunicode.h +196 -0
- package/runtime/third_party/v8-ieee754/LICENSE +61 -0
- package/runtime/third_party/v8-ieee754/README.md +22 -0
- package/runtime/third_party/v8-ieee754/convert.py +84 -0
- package/runtime/third_party/v8-ieee754/ieee754.c +3030 -0
- package/runtime/third_party/v8-ieee754/ieee754.h +27 -0
- package/runtime/tools/regexp_compile.c +90 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
|
2
|
+
*
|
|
3
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
* of this software and associated documentation files (the "Software"), to
|
|
5
|
+
* deal in the Software without restriction, including without limitation the
|
|
6
|
+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
7
|
+
* sell copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
* furnished to do so, subject to the following conditions:
|
|
9
|
+
*
|
|
10
|
+
* The above copyright notice and this permission notice shall be included in
|
|
11
|
+
* all copies or substantial portions of the Software.
|
|
12
|
+
*
|
|
13
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
18
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
19
|
+
* IN THE SOFTWARE.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#include "uv.h"
|
|
23
|
+
#include "uv-common.h"
|
|
24
|
+
|
|
25
|
+
#ifdef _WIN32
|
|
26
|
+
#include "win/internal.h"
|
|
27
|
+
#include "win/handle-inl.h"
|
|
28
|
+
#define uv__make_close_pending(h) uv__want_endgame((h)->loop, (h))
|
|
29
|
+
#else
|
|
30
|
+
#include "unix/internal.h"
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
#include <assert.h>
|
|
34
|
+
#include <stdlib.h>
|
|
35
|
+
#include <string.h>
|
|
36
|
+
|
|
37
|
+
struct poll_ctx {
|
|
38
|
+
uv_fs_poll_t* parent_handle;
|
|
39
|
+
int busy_polling;
|
|
40
|
+
unsigned int interval;
|
|
41
|
+
uint64_t start_time;
|
|
42
|
+
uv_loop_t* loop;
|
|
43
|
+
uv_fs_poll_cb poll_cb;
|
|
44
|
+
uv_timer_t timer_handle;
|
|
45
|
+
uv_fs_t fs_req; /* TODO(bnoordhuis) mark fs_req internal */
|
|
46
|
+
uv_stat_t statbuf;
|
|
47
|
+
struct poll_ctx* previous; /* context from previous start()..stop() period */
|
|
48
|
+
char path[1]; /* variable length */
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
static int statbuf_eq(const uv_stat_t* a, const uv_stat_t* b);
|
|
52
|
+
static void poll_cb(uv_fs_t* req);
|
|
53
|
+
static void timer_cb(uv_timer_t* timer);
|
|
54
|
+
static void timer_close_cb(uv_handle_t* timer);
|
|
55
|
+
|
|
56
|
+
static uv_stat_t zero_statbuf;
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle) {
|
|
60
|
+
uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_POLL);
|
|
61
|
+
handle->poll_ctx = NULL;
|
|
62
|
+
return 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
int uv_fs_poll_start(uv_fs_poll_t* handle,
|
|
67
|
+
uv_fs_poll_cb cb,
|
|
68
|
+
const char* path,
|
|
69
|
+
unsigned int interval) {
|
|
70
|
+
struct poll_ctx* ctx;
|
|
71
|
+
uv_loop_t* loop;
|
|
72
|
+
size_t len;
|
|
73
|
+
int err;
|
|
74
|
+
|
|
75
|
+
if (uv_is_active((uv_handle_t*)handle))
|
|
76
|
+
return 0;
|
|
77
|
+
|
|
78
|
+
loop = handle->loop;
|
|
79
|
+
len = strlen(path);
|
|
80
|
+
ctx = uv__calloc(1, sizeof(*ctx) + len);
|
|
81
|
+
|
|
82
|
+
if (ctx == NULL)
|
|
83
|
+
return UV_ENOMEM;
|
|
84
|
+
|
|
85
|
+
ctx->loop = loop;
|
|
86
|
+
ctx->poll_cb = cb;
|
|
87
|
+
ctx->interval = interval ? interval : 1;
|
|
88
|
+
ctx->start_time = uv_now(loop);
|
|
89
|
+
ctx->parent_handle = handle;
|
|
90
|
+
memcpy(ctx->path, path, len + 1);
|
|
91
|
+
|
|
92
|
+
err = uv_timer_init(loop, &ctx->timer_handle);
|
|
93
|
+
if (err < 0)
|
|
94
|
+
goto error;
|
|
95
|
+
|
|
96
|
+
ctx->timer_handle.flags |= UV_HANDLE_INTERNAL;
|
|
97
|
+
uv__handle_unref(&ctx->timer_handle);
|
|
98
|
+
|
|
99
|
+
err = uv_fs_stat(loop, &ctx->fs_req, ctx->path, poll_cb);
|
|
100
|
+
if (err < 0)
|
|
101
|
+
goto error;
|
|
102
|
+
|
|
103
|
+
if (handle->poll_ctx != NULL)
|
|
104
|
+
ctx->previous = handle->poll_ctx;
|
|
105
|
+
handle->poll_ctx = ctx;
|
|
106
|
+
uv__handle_start(handle);
|
|
107
|
+
|
|
108
|
+
return 0;
|
|
109
|
+
|
|
110
|
+
error:
|
|
111
|
+
uv__free(ctx);
|
|
112
|
+
return err;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
int uv_fs_poll_stop(uv_fs_poll_t* handle) {
|
|
117
|
+
struct poll_ctx* ctx;
|
|
118
|
+
|
|
119
|
+
if (!uv_is_active((uv_handle_t*)handle))
|
|
120
|
+
return 0;
|
|
121
|
+
|
|
122
|
+
ctx = handle->poll_ctx;
|
|
123
|
+
assert(ctx != NULL);
|
|
124
|
+
assert(ctx->parent_handle == handle);
|
|
125
|
+
|
|
126
|
+
/* Close the timer if it's active. If it's inactive, there's a stat request
|
|
127
|
+
* in progress and poll_cb will take care of the cleanup.
|
|
128
|
+
*/
|
|
129
|
+
if (uv_is_active((uv_handle_t*)&ctx->timer_handle))
|
|
130
|
+
uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb);
|
|
131
|
+
|
|
132
|
+
uv__handle_stop(handle);
|
|
133
|
+
|
|
134
|
+
return 0;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
int uv_fs_poll_getpath(uv_fs_poll_t* handle, char* buffer, size_t* size) {
|
|
139
|
+
struct poll_ctx* ctx;
|
|
140
|
+
size_t required_len;
|
|
141
|
+
|
|
142
|
+
if (buffer == NULL || size == NULL || *size == 0)
|
|
143
|
+
return UV_EINVAL;
|
|
144
|
+
|
|
145
|
+
if (!uv_is_active((uv_handle_t*)handle)) {
|
|
146
|
+
*size = 0;
|
|
147
|
+
return UV_EINVAL;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
ctx = handle->poll_ctx;
|
|
151
|
+
assert(ctx != NULL);
|
|
152
|
+
|
|
153
|
+
required_len = strlen(ctx->path);
|
|
154
|
+
if (required_len >= *size) {
|
|
155
|
+
*size = required_len + 1;
|
|
156
|
+
return UV_ENOBUFS;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
memcpy(buffer, ctx->path, required_len);
|
|
160
|
+
*size = required_len;
|
|
161
|
+
buffer[required_len] = '\0';
|
|
162
|
+
|
|
163
|
+
return 0;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
void uv__fs_poll_close(uv_fs_poll_t* handle) {
|
|
168
|
+
uv_fs_poll_stop(handle);
|
|
169
|
+
|
|
170
|
+
if (handle->poll_ctx == NULL)
|
|
171
|
+
uv__make_close_pending((uv_handle_t*)handle);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
static void timer_cb(uv_timer_t* timer) {
|
|
176
|
+
struct poll_ctx* ctx;
|
|
177
|
+
|
|
178
|
+
ctx = container_of(timer, struct poll_ctx, timer_handle);
|
|
179
|
+
assert(ctx->parent_handle != NULL);
|
|
180
|
+
assert(ctx->parent_handle->poll_ctx == ctx);
|
|
181
|
+
ctx->start_time = uv_now(ctx->loop);
|
|
182
|
+
|
|
183
|
+
if (uv_fs_stat(ctx->loop, &ctx->fs_req, ctx->path, poll_cb))
|
|
184
|
+
abort();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
static void poll_cb(uv_fs_t* req) {
|
|
189
|
+
uv_stat_t* statbuf;
|
|
190
|
+
struct poll_ctx* ctx;
|
|
191
|
+
uint64_t interval;
|
|
192
|
+
uv_fs_poll_t* handle;
|
|
193
|
+
|
|
194
|
+
ctx = container_of(req, struct poll_ctx, fs_req);
|
|
195
|
+
handle = ctx->parent_handle;
|
|
196
|
+
|
|
197
|
+
if (!uv_is_active((uv_handle_t*)handle) || uv__is_closing(handle))
|
|
198
|
+
goto out;
|
|
199
|
+
|
|
200
|
+
if (req->result != 0) {
|
|
201
|
+
if (ctx->busy_polling != req->result) {
|
|
202
|
+
ctx->poll_cb(ctx->parent_handle,
|
|
203
|
+
req->result,
|
|
204
|
+
&ctx->statbuf,
|
|
205
|
+
&zero_statbuf);
|
|
206
|
+
ctx->busy_polling = req->result;
|
|
207
|
+
}
|
|
208
|
+
goto out;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
statbuf = &req->statbuf;
|
|
212
|
+
|
|
213
|
+
if (ctx->busy_polling != 0)
|
|
214
|
+
if (ctx->busy_polling < 0 || !statbuf_eq(&ctx->statbuf, statbuf))
|
|
215
|
+
ctx->poll_cb(ctx->parent_handle, 0, &ctx->statbuf, statbuf);
|
|
216
|
+
|
|
217
|
+
ctx->statbuf = *statbuf;
|
|
218
|
+
ctx->busy_polling = 1;
|
|
219
|
+
|
|
220
|
+
out:
|
|
221
|
+
uv_fs_req_cleanup(req);
|
|
222
|
+
|
|
223
|
+
if (!uv_is_active((uv_handle_t*)handle) || uv__is_closing(handle)) {
|
|
224
|
+
uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* Reschedule timer, subtract the delay from doing the stat(). */
|
|
229
|
+
interval = ctx->interval;
|
|
230
|
+
interval -= (uv_now(ctx->loop) - ctx->start_time) % interval;
|
|
231
|
+
|
|
232
|
+
if (uv_timer_start(&ctx->timer_handle, timer_cb, interval, 0))
|
|
233
|
+
abort();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
static void timer_close_cb(uv_handle_t* timer) {
|
|
238
|
+
struct poll_ctx* ctx;
|
|
239
|
+
struct poll_ctx* it;
|
|
240
|
+
struct poll_ctx* last;
|
|
241
|
+
uv_fs_poll_t* handle;
|
|
242
|
+
|
|
243
|
+
ctx = container_of(timer, struct poll_ctx, timer_handle);
|
|
244
|
+
handle = ctx->parent_handle;
|
|
245
|
+
if (ctx == handle->poll_ctx) {
|
|
246
|
+
handle->poll_ctx = ctx->previous;
|
|
247
|
+
if (handle->poll_ctx == NULL && uv__is_closing(handle))
|
|
248
|
+
uv__make_close_pending((uv_handle_t*)handle);
|
|
249
|
+
} else {
|
|
250
|
+
for (last = handle->poll_ctx, it = last->previous;
|
|
251
|
+
it != ctx;
|
|
252
|
+
last = it, it = it->previous) {
|
|
253
|
+
assert(last->previous != NULL);
|
|
254
|
+
}
|
|
255
|
+
last->previous = ctx->previous;
|
|
256
|
+
}
|
|
257
|
+
uv__free(ctx);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
static int statbuf_eq(const uv_stat_t* a, const uv_stat_t* b) {
|
|
262
|
+
return a->st_ctim.tv_nsec == b->st_ctim.tv_nsec
|
|
263
|
+
&& a->st_mtim.tv_nsec == b->st_mtim.tv_nsec
|
|
264
|
+
&& a->st_birthtim.tv_nsec == b->st_birthtim.tv_nsec
|
|
265
|
+
&& a->st_ctim.tv_sec == b->st_ctim.tv_sec
|
|
266
|
+
&& a->st_mtim.tv_sec == b->st_mtim.tv_sec
|
|
267
|
+
&& a->st_birthtim.tv_sec == b->st_birthtim.tv_sec
|
|
268
|
+
&& a->st_size == b->st_size
|
|
269
|
+
&& a->st_mode == b->st_mode
|
|
270
|
+
&& a->st_uid == b->st_uid
|
|
271
|
+
&& a->st_gid == b->st_gid
|
|
272
|
+
&& a->st_ino == b->st_ino
|
|
273
|
+
&& a->st_dev == b->st_dev
|
|
274
|
+
&& a->st_flags == b->st_flags
|
|
275
|
+
&& a->st_gen == b->st_gen;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
#if defined(_WIN32)
|
|
280
|
+
|
|
281
|
+
#include "win/internal.h"
|
|
282
|
+
#include "win/handle-inl.h"
|
|
283
|
+
|
|
284
|
+
void uv__fs_poll_endgame(uv_loop_t* loop, uv_fs_poll_t* handle) {
|
|
285
|
+
assert(handle->flags & UV_HANDLE_CLOSING);
|
|
286
|
+
assert(!(handle->flags & UV_HANDLE_CLOSED));
|
|
287
|
+
uv__handle_close(handle);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
#endif /* _WIN32 */
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/* Copyright (c) 2013, Ben Noordhuis <info@bnoordhuis.nl>
|
|
2
|
+
*
|
|
3
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
4
|
+
* purpose with or without fee is hereby granted, provided that the above
|
|
5
|
+
* copyright notice and this permission notice appear in all copies.
|
|
6
|
+
*
|
|
7
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
8
|
+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
9
|
+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
10
|
+
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
11
|
+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
12
|
+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
13
|
+
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
#ifndef UV_SRC_HEAP_H_
|
|
17
|
+
#define UV_SRC_HEAP_H_
|
|
18
|
+
|
|
19
|
+
#include <stddef.h> /* NULL */
|
|
20
|
+
|
|
21
|
+
#if defined(__GNUC__)
|
|
22
|
+
# define HEAP_EXPORT(declaration) __attribute__((unused)) static declaration
|
|
23
|
+
#else
|
|
24
|
+
# define HEAP_EXPORT(declaration) static declaration
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
struct heap_node {
|
|
28
|
+
struct heap_node* left;
|
|
29
|
+
struct heap_node* right;
|
|
30
|
+
struct heap_node* parent;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/* A binary min heap. The usual properties hold: the root is the lowest
|
|
34
|
+
* element in the set, the height of the tree is at most log2(nodes) and
|
|
35
|
+
* it's always a complete binary tree.
|
|
36
|
+
*
|
|
37
|
+
* The heap function try hard to detect corrupted tree nodes at the cost
|
|
38
|
+
* of a minor reduction in performance. Compile with -DNDEBUG to disable.
|
|
39
|
+
*/
|
|
40
|
+
struct heap {
|
|
41
|
+
struct heap_node* min;
|
|
42
|
+
unsigned int nelts;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/* Return non-zero if a < b. */
|
|
46
|
+
typedef int (*heap_compare_fn)(const struct heap_node* a,
|
|
47
|
+
const struct heap_node* b);
|
|
48
|
+
|
|
49
|
+
/* Public functions. */
|
|
50
|
+
HEAP_EXPORT(void heap_init(struct heap* heap));
|
|
51
|
+
HEAP_EXPORT(struct heap_node* heap_min(const struct heap* heap));
|
|
52
|
+
HEAP_EXPORT(void heap_insert(struct heap* heap,
|
|
53
|
+
struct heap_node* newnode,
|
|
54
|
+
heap_compare_fn less_than));
|
|
55
|
+
HEAP_EXPORT(void heap_remove(struct heap* heap,
|
|
56
|
+
struct heap_node* node,
|
|
57
|
+
heap_compare_fn less_than));
|
|
58
|
+
HEAP_EXPORT(void heap_dequeue(struct heap* heap, heap_compare_fn less_than));
|
|
59
|
+
|
|
60
|
+
/* Implementation follows. */
|
|
61
|
+
|
|
62
|
+
HEAP_EXPORT(void heap_init(struct heap* heap)) {
|
|
63
|
+
heap->min = NULL;
|
|
64
|
+
heap->nelts = 0;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
HEAP_EXPORT(struct heap_node* heap_min(const struct heap* heap)) {
|
|
68
|
+
return heap->min;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* Swap parent with child. Child moves closer to the root, parent moves away. */
|
|
72
|
+
static void heap_node_swap(struct heap* heap,
|
|
73
|
+
struct heap_node* parent,
|
|
74
|
+
struct heap_node* child) {
|
|
75
|
+
struct heap_node* sibling;
|
|
76
|
+
struct heap_node t;
|
|
77
|
+
|
|
78
|
+
t = *parent;
|
|
79
|
+
*parent = *child;
|
|
80
|
+
*child = t;
|
|
81
|
+
|
|
82
|
+
parent->parent = child;
|
|
83
|
+
if (child->left == child) {
|
|
84
|
+
child->left = parent;
|
|
85
|
+
sibling = child->right;
|
|
86
|
+
} else {
|
|
87
|
+
child->right = parent;
|
|
88
|
+
sibling = child->left;
|
|
89
|
+
}
|
|
90
|
+
if (sibling != NULL)
|
|
91
|
+
sibling->parent = child;
|
|
92
|
+
|
|
93
|
+
if (parent->left != NULL)
|
|
94
|
+
parent->left->parent = parent;
|
|
95
|
+
if (parent->right != NULL)
|
|
96
|
+
parent->right->parent = parent;
|
|
97
|
+
|
|
98
|
+
if (child->parent == NULL)
|
|
99
|
+
heap->min = child;
|
|
100
|
+
else if (child->parent->left == parent)
|
|
101
|
+
child->parent->left = child;
|
|
102
|
+
else
|
|
103
|
+
child->parent->right = child;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
HEAP_EXPORT(void heap_insert(struct heap* heap,
|
|
107
|
+
struct heap_node* newnode,
|
|
108
|
+
heap_compare_fn less_than)) {
|
|
109
|
+
struct heap_node** parent;
|
|
110
|
+
struct heap_node** child;
|
|
111
|
+
unsigned int path;
|
|
112
|
+
unsigned int n;
|
|
113
|
+
unsigned int k;
|
|
114
|
+
|
|
115
|
+
newnode->left = NULL;
|
|
116
|
+
newnode->right = NULL;
|
|
117
|
+
newnode->parent = NULL;
|
|
118
|
+
|
|
119
|
+
/* Calculate the path from the root to the insertion point. This is a min
|
|
120
|
+
* heap so we always insert at the left-most free node of the bottom row.
|
|
121
|
+
*/
|
|
122
|
+
path = 0;
|
|
123
|
+
for (k = 0, n = 1 + heap->nelts; n >= 2; k += 1, n /= 2)
|
|
124
|
+
path = (path << 1) | (n & 1);
|
|
125
|
+
|
|
126
|
+
/* Now traverse the heap using the path we calculated in the previous step. */
|
|
127
|
+
parent = child = &heap->min;
|
|
128
|
+
while (k > 0) {
|
|
129
|
+
parent = child;
|
|
130
|
+
if (path & 1)
|
|
131
|
+
child = &(*child)->right;
|
|
132
|
+
else
|
|
133
|
+
child = &(*child)->left;
|
|
134
|
+
path >>= 1;
|
|
135
|
+
k -= 1;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/* Insert the new node. */
|
|
139
|
+
newnode->parent = *parent;
|
|
140
|
+
*child = newnode;
|
|
141
|
+
heap->nelts += 1;
|
|
142
|
+
|
|
143
|
+
/* Walk up the tree and check at each node if the heap property holds.
|
|
144
|
+
* It's a min heap so parent < child must be true.
|
|
145
|
+
*/
|
|
146
|
+
while (newnode->parent != NULL && less_than(newnode, newnode->parent))
|
|
147
|
+
heap_node_swap(heap, newnode->parent, newnode);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
HEAP_EXPORT(void heap_remove(struct heap* heap,
|
|
151
|
+
struct heap_node* node,
|
|
152
|
+
heap_compare_fn less_than)) {
|
|
153
|
+
struct heap_node* smallest;
|
|
154
|
+
struct heap_node** max;
|
|
155
|
+
struct heap_node* child;
|
|
156
|
+
unsigned int path;
|
|
157
|
+
unsigned int k;
|
|
158
|
+
unsigned int n;
|
|
159
|
+
|
|
160
|
+
if (heap->nelts == 0)
|
|
161
|
+
return;
|
|
162
|
+
|
|
163
|
+
/* Calculate the path from the min (the root) to the max, the left-most node
|
|
164
|
+
* of the bottom row.
|
|
165
|
+
*/
|
|
166
|
+
path = 0;
|
|
167
|
+
for (k = 0, n = heap->nelts; n >= 2; k += 1, n /= 2)
|
|
168
|
+
path = (path << 1) | (n & 1);
|
|
169
|
+
|
|
170
|
+
/* Now traverse the heap using the path we calculated in the previous step. */
|
|
171
|
+
max = &heap->min;
|
|
172
|
+
while (k > 0) {
|
|
173
|
+
if (path & 1)
|
|
174
|
+
max = &(*max)->right;
|
|
175
|
+
else
|
|
176
|
+
max = &(*max)->left;
|
|
177
|
+
path >>= 1;
|
|
178
|
+
k -= 1;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
heap->nelts -= 1;
|
|
182
|
+
|
|
183
|
+
/* Unlink the max node. */
|
|
184
|
+
child = *max;
|
|
185
|
+
*max = NULL;
|
|
186
|
+
|
|
187
|
+
if (child == node) {
|
|
188
|
+
/* We're removing either the max or the last node in the tree. */
|
|
189
|
+
if (child == heap->min) {
|
|
190
|
+
heap->min = NULL;
|
|
191
|
+
}
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/* Replace the to be deleted node with the max node. */
|
|
196
|
+
child->left = node->left;
|
|
197
|
+
child->right = node->right;
|
|
198
|
+
child->parent = node->parent;
|
|
199
|
+
|
|
200
|
+
if (child->left != NULL) {
|
|
201
|
+
child->left->parent = child;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (child->right != NULL) {
|
|
205
|
+
child->right->parent = child;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (node->parent == NULL) {
|
|
209
|
+
heap->min = child;
|
|
210
|
+
} else if (node->parent->left == node) {
|
|
211
|
+
node->parent->left = child;
|
|
212
|
+
} else {
|
|
213
|
+
node->parent->right = child;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/* Walk down the subtree and check at each node if the heap property holds.
|
|
217
|
+
* It's a min heap so parent < child must be true. If the parent is bigger,
|
|
218
|
+
* swap it with the smallest child.
|
|
219
|
+
*/
|
|
220
|
+
for (;;) {
|
|
221
|
+
smallest = child;
|
|
222
|
+
if (child->left != NULL && less_than(child->left, smallest))
|
|
223
|
+
smallest = child->left;
|
|
224
|
+
if (child->right != NULL && less_than(child->right, smallest))
|
|
225
|
+
smallest = child->right;
|
|
226
|
+
if (smallest == child)
|
|
227
|
+
break;
|
|
228
|
+
heap_node_swap(heap, child, smallest);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* Walk up the subtree and check that each parent is less than the node
|
|
232
|
+
* this is required, because `max` node is not guaranteed to be the
|
|
233
|
+
* actual maximum in tree
|
|
234
|
+
*/
|
|
235
|
+
while (child->parent != NULL && less_than(child, child->parent))
|
|
236
|
+
heap_node_swap(heap, child->parent, child);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
HEAP_EXPORT(void heap_dequeue(struct heap* heap, heap_compare_fn less_than)) {
|
|
240
|
+
heap_remove(heap, heap->min, less_than);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
#undef HEAP_EXPORT
|
|
244
|
+
|
|
245
|
+
#endif /* UV_SRC_HEAP_H_ */
|