├── .gitignore ├── LICENSE ├── LuaJIT-2.0.4 ├── COPYRIGHT ├── Makefile ├── README ├── doc │ ├── bluequad-print.css │ ├── bluequad.css │ ├── changes.html │ ├── contact.html │ ├── ext_c_api.html │ ├── ext_ffi.html │ ├── ext_ffi_api.html │ ├── ext_ffi_semantics.html │ ├── ext_ffi_tutorial.html │ ├── ext_jit.html │ ├── extensions.html │ ├── faq.html │ ├── img │ │ └── contact.png │ ├── install.html │ ├── luajit.html │ ├── running.html │ └── status.html ├── dynasm │ ├── dasm_arm.h │ ├── dasm_arm.lua │ ├── dasm_mips.h │ ├── dasm_mips.lua │ ├── dasm_ppc.h │ ├── dasm_ppc.lua │ ├── dasm_proto.h │ ├── dasm_x64.lua │ ├── dasm_x86.h │ ├── dasm_x86.lua │ └── dynasm.lua ├── etc │ ├── luajit.1 │ └── luajit.pc └── src │ ├── Makefile │ ├── Makefile.dep │ ├── host │ ├── README │ ├── buildvm │ ├── buildvm.c │ ├── buildvm.h │ ├── buildvm_arch.h │ ├── buildvm_asm.c │ ├── buildvm_fold.c │ ├── buildvm_lib.c │ ├── buildvm_peobj.c │ ├── genminilua.lua │ ├── minilua │ └── minilua.c │ ├── jit │ ├── bc.lua │ ├── bcsave.lua │ ├── dis_arm.lua │ ├── dis_mips.lua │ ├── dis_mipsel.lua │ ├── dis_ppc.lua │ ├── dis_x64.lua │ ├── dis_x86.lua │ ├── dump.lua │ ├── v.lua │ └── vmdef.lua │ ├── lauxlib.h │ ├── lib_aux.c │ ├── lib_base.c │ ├── lib_bit.c │ ├── lib_debug.c │ ├── lib_ffi.c │ ├── lib_init.c │ ├── lib_io.c │ ├── lib_jit.c │ ├── lib_math.c │ ├── lib_os.c │ ├── lib_package.c │ ├── lib_string.c │ ├── lib_table.c │ ├── lj.supp │ ├── lj_alloc.c │ ├── lj_alloc.h │ ├── lj_api.c │ ├── lj_arch.h │ ├── lj_asm.c │ ├── lj_asm.h │ ├── lj_asm_arm.h │ ├── lj_asm_mips.h │ ├── lj_asm_ppc.h │ ├── lj_asm_x86.h │ ├── lj_bc.c │ ├── lj_bc.h │ ├── lj_bcdef.h │ ├── lj_bcdump.h │ ├── lj_bcread.c │ ├── lj_bcwrite.c │ ├── lj_carith.c │ ├── lj_carith.h │ ├── lj_ccall.c │ ├── lj_ccall.h │ ├── lj_ccallback.c │ ├── lj_ccallback.h │ ├── lj_cconv.c │ ├── lj_cconv.h │ ├── lj_cdata.c │ ├── lj_cdata.h │ ├── lj_char.c │ ├── lj_char.h │ ├── lj_clib.c │ ├── lj_clib.h │ ├── lj_cparse.c │ ├── lj_cparse.h │ ├── lj_crecord.c │ ├── lj_crecord.h │ ├── lj_ctype.c │ ├── lj_ctype.h │ ├── lj_debug.c │ ├── lj_debug.h │ ├── lj_def.h │ ├── lj_dispatch.c │ ├── lj_dispatch.h │ ├── lj_emit_arm.h │ ├── lj_emit_mips.h │ ├── lj_emit_ppc.h │ ├── lj_emit_x86.h │ ├── lj_err.c │ ├── lj_err.h │ ├── lj_errmsg.h │ ├── lj_ff.h │ ├── lj_ffdef.h │ ├── lj_ffrecord.c │ ├── lj_ffrecord.h │ ├── lj_folddef.h │ ├── lj_frame.h │ ├── lj_func.c │ ├── lj_func.h │ ├── lj_gc.c │ ├── lj_gc.h │ ├── lj_gdbjit.c │ ├── lj_gdbjit.h │ ├── lj_ir.c │ ├── lj_ir.h │ ├── lj_ircall.h │ ├── lj_iropt.h │ ├── lj_jit.h │ ├── lj_lex.c │ ├── lj_lex.h │ ├── lj_lib.c │ ├── lj_lib.h │ ├── lj_libdef.h │ ├── lj_load.c │ ├── lj_mcode.c │ ├── lj_mcode.h │ ├── lj_meta.c │ ├── lj_meta.h │ ├── lj_obj.c │ ├── lj_obj.h │ ├── lj_opt_dce.c │ ├── lj_opt_fold.c │ ├── lj_opt_loop.c │ ├── lj_opt_mem.c │ ├── lj_opt_narrow.c │ ├── lj_opt_sink.c │ ├── lj_opt_split.c │ ├── lj_parse.c │ ├── lj_parse.h │ ├── lj_recdef.h │ ├── lj_record.c │ ├── lj_record.h │ ├── lj_snap.c │ ├── lj_snap.h │ ├── lj_state.c │ ├── lj_state.h │ ├── lj_str.c │ ├── lj_str.h │ ├── lj_strscan.c │ ├── lj_strscan.h │ ├── lj_tab.c │ ├── lj_tab.h │ ├── lj_target.h │ ├── lj_target_arm.h │ ├── lj_target_mips.h │ ├── lj_target_ppc.h │ ├── lj_target_x86.h │ ├── lj_trace.c │ ├── lj_trace.h │ ├── lj_traceerr.h │ ├── lj_udata.c │ ├── lj_udata.h │ ├── lj_vm.h │ ├── lj_vm.s │ ├── lj_vmevent.c │ ├── lj_vmevent.h │ ├── lj_vmmath.c │ ├── ljamalg.c │ ├── lua.h │ ├── lua.hpp │ ├── luaconf.h │ ├── luajit │ ├── luajit.c │ ├── luajit.h │ ├── lualib.h │ ├── msvcbuild.bat │ ├── ps4build.bat │ ├── psvitabuild.bat │ ├── vm_arm.dasc │ ├── vm_mips.dasc │ ├── vm_ppc.dasc │ ├── vm_ppcspe.dasc │ ├── vm_x86.dasc │ └── xedkbuild.bat ├── Makefile ├── README.md ├── doc ├── ANNOUNCE.txt └── node9-hackers-guide.txt ├── fs ├── appl │ ├── apptest.lua │ ├── export.lua │ ├── listen.lua │ ├── ls.lua │ ├── mount.lua │ ├── sh.lua │ ├── styxlisten.lua │ ├── syscall.lua │ ├── test.lua │ └── unmount.lua ├── module │ ├── arg.lua │ ├── bytebuffer.h │ ├── kern.h │ ├── ninevals.h │ ├── node9.h │ ├── sys.lua │ ├── syscalls.h │ └── sysconst.h └── os │ ├── init │ ├── nodeinit.lua │ └── sched.lua │ └── lib │ ├── environments.lua │ ├── kernel.lua │ ├── pl │ ├── Date.lua │ ├── List.lua │ ├── Map.lua │ ├── MultiMap.lua │ ├── OrderedMap.lua │ ├── Set.lua │ ├── app.lua │ ├── array2d.lua │ ├── class.lua │ ├── compat.lua │ ├── comprehension.lua │ ├── config.lua │ ├── data.lua │ ├── dir.lua │ ├── file.lua │ ├── func.lua │ ├── import_into.lua │ ├── init.lua │ ├── input.lua │ ├── lapp.lua │ ├── lexer.lua │ ├── luabalanced.lua │ ├── operator.lua │ ├── path.lua │ ├── permute.lua │ ├── pretty.lua │ ├── seq.lua │ ├── sip.lua │ ├── strict.lua │ ├── stringio.lua │ ├── stringx.lua │ ├── tablex.lua │ ├── template.lua │ ├── test.lua │ ├── text.lua │ ├── types.lua │ ├── utils.lua │ └── xml.lua │ └── schedulers │ └── roundrobin.lua ├── images └── totoro-spirit.png ├── lib9.make ├── libbio.make ├── libnode9.make ├── libsec.make ├── libuv ├── libuv-1.6.1 ├── .mailmap ├── AUTHORS ├── CONTRIBUTING.md ├── ChangeLog ├── LICENSE ├── Makefile ├── Makefile.am ├── Makefile.in ├── Makefile.mingw ├── README.md ├── aclocal.m4 ├── android-configure ├── ar-lib ├── autogen.sh ├── autom4te.cache │ ├── output.0 │ ├── output.1 │ ├── requests │ ├── traces.0 │ └── traces.1 ├── checksparse.sh ├── common.gypi ├── compile ├── config.guess ├── config.log ├── config.status ├── config.sub ├── configure ├── configure.ac ├── depcomp ├── docs │ ├── Makefile │ ├── make.bat │ └── src │ │ ├── async.rst │ │ ├── check.rst │ │ ├── conf.py │ │ ├── design.rst │ │ ├── dll.rst │ │ ├── dns.rst │ │ ├── errors.rst │ │ ├── fs.rst │ │ ├── fs_event.rst │ │ ├── fs_poll.rst │ │ ├── handle.rst │ │ ├── idle.rst │ │ ├── index.rst │ │ ├── loop.rst │ │ ├── migration_010_100.rst │ │ ├── misc.rst │ │ ├── pipe.rst │ │ ├── poll.rst │ │ ├── prepare.rst │ │ ├── process.rst │ │ ├── request.rst │ │ ├── signal.rst │ │ ├── sphinx-plugins │ │ └── manpage.py │ │ ├── static │ │ ├── architecture.png │ │ ├── diagrams.key │ │ │ ├── Data │ │ │ │ ├── st0-311.jpg │ │ │ │ └── st1-475.jpg │ │ │ ├── Index.zip │ │ │ ├── Metadata │ │ │ │ ├── BuildVersionHistory.plist │ │ │ │ ├── DocumentIdentifier │ │ │ │ └── Properties.plist │ │ │ ├── preview-micro.jpg │ │ │ ├── preview-web.jpg │ │ │ └── preview.jpg │ │ ├── favicon.ico │ │ ├── logo.png │ │ └── loop_iteration.png │ │ ├── stream.rst │ │ ├── tcp.rst │ │ ├── threading.rst │ │ ├── threadpool.rst │ │ ├── timer.rst │ │ ├── tty.rst │ │ └── udp.rst ├── gyp_uv.py ├── img │ ├── banner.png │ └── logos.svg ├── include │ ├── android-ifaddrs.h │ ├── pthread-fixes.h │ ├── stdint-msvc2008.h │ ├── tree.h │ ├── uv-aix.h │ ├── uv-bsd.h │ ├── uv-darwin.h │ ├── uv-errno.h │ ├── uv-linux.h │ ├── uv-sunos.h │ ├── uv-threadpool.h │ ├── uv-unix.h │ ├── uv-version.h │ ├── uv-win.h │ └── uv.h ├── install-sh ├── libtool ├── libuv.pc ├── libuv.pc.in ├── ltmain.sh ├── m4 │ ├── .gitignore │ ├── as_case.m4 │ └── libuv-check-flags.m4 ├── missing ├── samples │ ├── .gitignore │ └── socks5-proxy │ │ ├── .gitignore │ │ ├── LICENSE │ │ ├── Makefile │ │ ├── build.gyp │ │ ├── client.c │ │ ├── defs.h │ │ ├── getopt.c │ │ ├── main.c │ │ ├── s5.c │ │ ├── s5.h │ │ ├── server.c │ │ └── util.c ├── src │ ├── .deps │ │ ├── .dirstamp │ │ ├── libuv_la-fs-poll.Plo │ │ ├── libuv_la-inet.Plo │ │ ├── libuv_la-threadpool.Plo │ │ ├── libuv_la-uv-common.Plo │ │ └── libuv_la-version.Plo │ ├── .dirstamp │ ├── fs-poll.c │ ├── heap-inl.h │ ├── inet.c │ ├── queue.h │ ├── threadpool.c │ ├── unix │ │ ├── .deps │ │ │ ├── .dirstamp │ │ │ ├── libuv_la-aix.Plo │ │ │ ├── libuv_la-android-ifaddrs.Plo │ │ │ ├── libuv_la-async.Plo │ │ │ ├── libuv_la-core.Plo │ │ │ ├── libuv_la-darwin-proctitle.Plo │ │ │ ├── libuv_la-darwin.Plo │ │ │ ├── libuv_la-dl.Plo │ │ │ ├── libuv_la-freebsd.Plo │ │ │ ├── libuv_la-fs.Plo │ │ │ ├── libuv_la-fsevents.Plo │ │ │ ├── libuv_la-getaddrinfo.Plo │ │ │ ├── libuv_la-getnameinfo.Plo │ │ │ ├── libuv_la-kqueue.Plo │ │ │ ├── libuv_la-linux-core.Plo │ │ │ ├── libuv_la-linux-inotify.Plo │ │ │ ├── libuv_la-linux-syscalls.Plo │ │ │ ├── libuv_la-loop-watcher.Plo │ │ │ ├── libuv_la-loop.Plo │ │ │ ├── libuv_la-netbsd.Plo │ │ │ ├── libuv_la-openbsd.Plo │ │ │ ├── libuv_la-pipe.Plo │ │ │ ├── libuv_la-poll.Plo │ │ │ ├── libuv_la-process.Plo │ │ │ ├── libuv_la-proctitle.Plo │ │ │ ├── libuv_la-pthread-fixes.Plo │ │ │ ├── libuv_la-signal.Plo │ │ │ ├── libuv_la-stream.Plo │ │ │ ├── libuv_la-sunos.Plo │ │ │ ├── libuv_la-tcp.Plo │ │ │ ├── libuv_la-thread.Plo │ │ │ ├── libuv_la-timer.Plo │ │ │ ├── libuv_la-tty.Plo │ │ │ └── libuv_la-udp.Plo │ │ ├── .dirstamp │ │ ├── aix.c │ │ ├── android-ifaddrs.c │ │ ├── async.c │ │ ├── atomic-ops.h │ │ ├── core.c │ │ ├── darwin-proctitle.c │ │ ├── darwin.c │ │ ├── dl.c │ │ ├── freebsd.c │ │ ├── fs.c │ │ ├── fsevents.c │ │ ├── getaddrinfo.c │ │ ├── getnameinfo.c │ │ ├── internal.h │ │ ├── kqueue.c │ │ ├── linux-core.c │ │ ├── linux-inotify.c │ │ ├── linux-syscalls.c │ │ ├── linux-syscalls.h │ │ ├── loop-watcher.c │ │ ├── loop.c │ │ ├── netbsd.c │ │ ├── openbsd.c │ │ ├── pipe.c │ │ ├── poll.c │ │ ├── process.c │ │ ├── proctitle.c │ │ ├── pthread-fixes.c │ │ ├── signal.c │ │ ├── spinlock.h │ │ ├── stream.c │ │ ├── sunos.c │ │ ├── tcp.c │ │ ├── thread.c │ │ ├── timer.c │ │ ├── tty.c │ │ └── udp.c │ ├── uv-common.c │ ├── uv-common.h │ ├── version.c │ └── win │ │ ├── .deps │ │ ├── libuv_la-async.Plo │ │ ├── libuv_la-core.Plo │ │ ├── libuv_la-dl.Plo │ │ ├── libuv_la-error.Plo │ │ ├── libuv_la-fs-event.Plo │ │ ├── libuv_la-fs.Plo │ │ ├── libuv_la-getaddrinfo.Plo │ │ ├── libuv_la-getnameinfo.Plo │ │ ├── libuv_la-handle.Plo │ │ ├── libuv_la-loop-watcher.Plo │ │ ├── libuv_la-pipe.Plo │ │ ├── libuv_la-poll.Plo │ │ ├── libuv_la-process-stdio.Plo │ │ ├── libuv_la-process.Plo │ │ ├── libuv_la-req.Plo │ │ ├── libuv_la-signal.Plo │ │ ├── libuv_la-stream.Plo │ │ ├── libuv_la-tcp.Plo │ │ ├── libuv_la-thread.Plo │ │ ├── libuv_la-timer.Plo │ │ ├── libuv_la-tty.Plo │ │ ├── libuv_la-udp.Plo │ │ ├── libuv_la-util.Plo │ │ ├── libuv_la-winapi.Plo │ │ └── libuv_la-winsock.Plo │ │ ├── async.c │ │ ├── atomicops-inl.h │ │ ├── core.c │ │ ├── dl.c │ │ ├── error.c │ │ ├── fs-event.c │ │ ├── fs.c │ │ ├── getaddrinfo.c │ │ ├── getnameinfo.c │ │ ├── handle-inl.h │ │ ├── handle.c │ │ ├── internal.h │ │ ├── loop-watcher.c │ │ ├── pipe.c │ │ ├── poll.c │ │ ├── process-stdio.c │ │ ├── process.c │ │ ├── req-inl.h │ │ ├── req.c │ │ ├── signal.c │ │ ├── stream-inl.h │ │ ├── stream.c │ │ ├── tcp.c │ │ ├── thread.c │ │ ├── timer.c │ │ ├── tty.c │ │ ├── udp.c │ │ ├── util.c │ │ ├── winapi.c │ │ ├── winapi.h │ │ ├── winsock.c │ │ └── winsock.h ├── test │ ├── .deps │ │ ├── test_run_tests-blackhole-server.Po │ │ ├── test_run_tests-dns-server.Po │ │ ├── test_run_tests-echo-server.Po │ │ ├── test_run_tests-run-tests.Po │ │ ├── test_run_tests-runner-unix.Po │ │ ├── test_run_tests-runner-win.Po │ │ ├── test_run_tests-runner.Po │ │ ├── test_run_tests-test-active.Po │ │ ├── test_run_tests-test-async-null-cb.Po │ │ ├── test_run_tests-test-async.Po │ │ ├── test_run_tests-test-barrier.Po │ │ ├── test_run_tests-test-callback-order.Po │ │ ├── test_run_tests-test-callback-stack.Po │ │ ├── test_run_tests-test-close-fd.Po │ │ ├── test_run_tests-test-close-order.Po │ │ ├── test_run_tests-test-condvar.Po │ │ ├── test_run_tests-test-connection-fail.Po │ │ ├── test_run_tests-test-cwd-and-chdir.Po │ │ ├── test_run_tests-test-default-loop-close.Po │ │ ├── test_run_tests-test-delayed-accept.Po │ │ ├── test_run_tests-test-dlerror.Po │ │ ├── test_run_tests-test-embed.Po │ │ ├── test_run_tests-test-emfile.Po │ │ ├── test_run_tests-test-error.Po │ │ ├── test_run_tests-test-fail-always.Po │ │ ├── test_run_tests-test-fs-event.Po │ │ ├── test_run_tests-test-fs-poll.Po │ │ ├── test_run_tests-test-fs.Po │ │ ├── test_run_tests-test-get-currentexe.Po │ │ ├── test_run_tests-test-get-loadavg.Po │ │ ├── test_run_tests-test-get-memory.Po │ │ ├── test_run_tests-test-getaddrinfo.Po │ │ ├── test_run_tests-test-getnameinfo.Po │ │ ├── test_run_tests-test-getsockname.Po │ │ ├── test_run_tests-test-handle-fileno.Po │ │ ├── test_run_tests-test-homedir.Po │ │ ├── test_run_tests-test-hrtime.Po │ │ ├── test_run_tests-test-idle.Po │ │ ├── test_run_tests-test-ip4-addr.Po │ │ ├── test_run_tests-test-ip6-addr.Po │ │ ├── test_run_tests-test-ipc-send-recv.Po │ │ ├── test_run_tests-test-ipc.Po │ │ ├── test_run_tests-test-loop-alive.Po │ │ ├── test_run_tests-test-loop-close.Po │ │ ├── test_run_tests-test-loop-configure.Po │ │ ├── test_run_tests-test-loop-handles.Po │ │ ├── test_run_tests-test-loop-stop.Po │ │ ├── test_run_tests-test-loop-time.Po │ │ ├── test_run_tests-test-multiple-listen.Po │ │ ├── test_run_tests-test-mutexes.Po │ │ ├── test_run_tests-test-osx-select.Po │ │ ├── test_run_tests-test-pass-always.Po │ │ ├── test_run_tests-test-ping-pong.Po │ │ ├── test_run_tests-test-pipe-bind-error.Po │ │ ├── test_run_tests-test-pipe-close-stdout-read-stdin.Po │ │ ├── test_run_tests-test-pipe-connect-error.Po │ │ ├── test_run_tests-test-pipe-connect-prepare.Po │ │ ├── test_run_tests-test-pipe-getsockname.Po │ │ ├── test_run_tests-test-pipe-sendmsg.Po │ │ ├── test_run_tests-test-pipe-server-close.Po │ │ ├── test_run_tests-test-pipe-set-non-blocking.Po │ │ ├── test_run_tests-test-platform-output.Po │ │ ├── test_run_tests-test-poll-close-doesnt-corrupt-stack.Po │ │ ├── test_run_tests-test-poll-close.Po │ │ ├── test_run_tests-test-poll-closesocket.Po │ │ ├── test_run_tests-test-poll.Po │ │ ├── test_run_tests-test-process-title.Po │ │ ├── test_run_tests-test-ref.Po │ │ ├── test_run_tests-test-run-nowait.Po │ │ ├── test_run_tests-test-run-once.Po │ │ ├── test_run_tests-test-semaphore.Po │ │ ├── test_run_tests-test-shutdown-close.Po │ │ ├── test_run_tests-test-shutdown-eof.Po │ │ ├── test_run_tests-test-shutdown-twice.Po │ │ ├── test_run_tests-test-signal-multiple-loops.Po │ │ ├── test_run_tests-test-signal.Po │ │ ├── test_run_tests-test-socket-buffer-size.Po │ │ ├── test_run_tests-test-spawn.Po │ │ ├── test_run_tests-test-stdio-over-pipes.Po │ │ ├── test_run_tests-test-tcp-bind-error.Po │ │ ├── test_run_tests-test-tcp-bind6-error.Po │ │ ├── test_run_tests-test-tcp-close-accept.Po │ │ ├── test_run_tests-test-tcp-close-while-connecting.Po │ │ ├── test_run_tests-test-tcp-close.Po │ │ ├── test_run_tests-test-tcp-connect-error-after-write.Po │ │ ├── test_run_tests-test-tcp-connect-error.Po │ │ ├── test_run_tests-test-tcp-connect-timeout.Po │ │ ├── test_run_tests-test-tcp-connect6-error.Po │ │ ├── test_run_tests-test-tcp-create-socket-early.Po │ │ ├── test_run_tests-test-tcp-flags.Po │ │ ├── test_run_tests-test-tcp-oob.Po │ │ ├── test_run_tests-test-tcp-open.Po │ │ ├── test_run_tests-test-tcp-read-stop.Po │ │ ├── test_run_tests-test-tcp-shutdown-after-write.Po │ │ ├── test_run_tests-test-tcp-try-write.Po │ │ ├── test_run_tests-test-tcp-unexpected-read.Po │ │ ├── test_run_tests-test-tcp-write-after-connect.Po │ │ ├── test_run_tests-test-tcp-write-fail.Po │ │ ├── test_run_tests-test-tcp-write-queue-order.Po │ │ ├── test_run_tests-test-tcp-write-to-half-open-connection.Po │ │ ├── test_run_tests-test-tcp-writealot.Po │ │ ├── test_run_tests-test-thread-equal.Po │ │ ├── test_run_tests-test-thread.Po │ │ ├── test_run_tests-test-threadpool-cancel.Po │ │ ├── test_run_tests-test-threadpool.Po │ │ ├── test_run_tests-test-timer-again.Po │ │ ├── test_run_tests-test-timer-from-check.Po │ │ ├── test_run_tests-test-timer.Po │ │ ├── test_run_tests-test-tty.Po │ │ ├── test_run_tests-test-udp-bind.Po │ │ ├── test_run_tests-test-udp-create-socket-early.Po │ │ ├── test_run_tests-test-udp-dgram-too-big.Po │ │ ├── test_run_tests-test-udp-ipv6.Po │ │ ├── test_run_tests-test-udp-multicast-interface.Po │ │ ├── test_run_tests-test-udp-multicast-interface6.Po │ │ ├── test_run_tests-test-udp-multicast-join.Po │ │ ├── test_run_tests-test-udp-multicast-join6.Po │ │ ├── test_run_tests-test-udp-multicast-ttl.Po │ │ ├── test_run_tests-test-udp-open.Po │ │ ├── test_run_tests-test-udp-options.Po │ │ ├── test_run_tests-test-udp-send-and-recv.Po │ │ ├── test_run_tests-test-udp-send-immediate.Po │ │ ├── test_run_tests-test-udp-send-unreachable.Po │ │ ├── test_run_tests-test-udp-try-send.Po │ │ ├── test_run_tests-test-walk-handles.Po │ │ └── test_run_tests-test-watcher-cross-stop.Po │ ├── benchmark-async-pummel.c │ ├── benchmark-async.c │ ├── benchmark-fs-stat.c │ ├── benchmark-getaddrinfo.c │ ├── benchmark-list.h │ ├── benchmark-loop-count.c │ ├── benchmark-million-async.c │ ├── benchmark-million-timers.c │ ├── benchmark-multi-accept.c │ ├── benchmark-ping-pongs.c │ ├── benchmark-pound.c │ ├── benchmark-pump.c │ ├── benchmark-sizes.c │ ├── benchmark-spawn.c │ ├── benchmark-tcp-write-batch.c │ ├── benchmark-thread.c │ ├── benchmark-udp-pummel.c │ ├── blackhole-server.c │ ├── dns-server.c │ ├── echo-server.c │ ├── fixtures │ │ ├── empty_file │ │ └── load_error.node │ ├── run-benchmarks.c │ ├── run-tests.c │ ├── runner-unix.c │ ├── runner-unix.h │ ├── runner-win.c │ ├── runner-win.h │ ├── runner.c │ ├── runner.h │ ├── task.h │ ├── test-active.c │ ├── test-async-null-cb.c │ ├── test-async.c │ ├── test-barrier.c │ ├── test-callback-order.c │ ├── test-callback-stack.c │ ├── test-close-fd.c │ ├── test-close-order.c │ ├── test-condvar.c │ ├── test-connection-fail.c │ ├── test-cwd-and-chdir.c │ ├── test-default-loop-close.c │ ├── test-delayed-accept.c │ ├── test-dlerror.c │ ├── test-embed.c │ ├── test-emfile.c │ ├── test-error.c │ ├── test-fail-always.c │ ├── test-fs-event.c │ ├── test-fs-poll.c │ ├── test-fs.c │ ├── test-get-currentexe.c │ ├── test-get-loadavg.c │ ├── test-get-memory.c │ ├── test-getaddrinfo.c │ ├── test-getnameinfo.c │ ├── test-getsockname.c │ ├── test-handle-fileno.c │ ├── test-homedir.c │ ├── test-hrtime.c │ ├── test-idle.c │ ├── test-ip4-addr.c │ ├── test-ip6-addr.c │ ├── test-ipc-send-recv.c │ ├── test-ipc.c │ ├── test-list.h │ ├── test-loop-alive.c │ ├── test-loop-close.c │ ├── test-loop-configure.c │ ├── test-loop-handles.c │ ├── test-loop-stop.c │ ├── test-loop-time.c │ ├── test-multiple-listen.c │ ├── test-mutexes.c │ ├── test-osx-select.c │ ├── test-pass-always.c │ ├── test-ping-pong.c │ ├── test-pipe-bind-error.c │ ├── test-pipe-close-stdout-read-stdin.c │ ├── test-pipe-connect-error.c │ ├── test-pipe-connect-prepare.c │ ├── test-pipe-getsockname.c │ ├── test-pipe-sendmsg.c │ ├── test-pipe-server-close.c │ ├── test-pipe-set-non-blocking.c │ ├── test-platform-output.c │ ├── test-poll-close-doesnt-corrupt-stack.c │ ├── test-poll-close.c │ ├── test-poll-closesocket.c │ ├── test-poll.c │ ├── test-process-title.c │ ├── test-ref.c │ ├── test-run-nowait.c │ ├── test-run-once.c │ ├── test-semaphore.c │ ├── test-shutdown-close.c │ ├── test-shutdown-eof.c │ ├── test-shutdown-twice.c │ ├── test-signal-multiple-loops.c │ ├── test-signal.c │ ├── test-socket-buffer-size.c │ ├── test-spawn.c │ ├── test-stdio-over-pipes.c │ ├── test-tcp-bind-error.c │ ├── test-tcp-bind6-error.c │ ├── test-tcp-close-accept.c │ ├── test-tcp-close-while-connecting.c │ ├── test-tcp-close.c │ ├── test-tcp-connect-error-after-write.c │ ├── test-tcp-connect-error.c │ ├── test-tcp-connect-timeout.c │ ├── test-tcp-connect6-error.c │ ├── test-tcp-create-socket-early.c │ ├── test-tcp-flags.c │ ├── test-tcp-oob.c │ ├── test-tcp-open.c │ ├── test-tcp-read-stop.c │ ├── test-tcp-shutdown-after-write.c │ ├── test-tcp-try-write.c │ ├── test-tcp-unexpected-read.c │ ├── test-tcp-write-after-connect.c │ ├── test-tcp-write-fail.c │ ├── test-tcp-write-queue-order.c │ ├── test-tcp-write-to-half-open-connection.c │ ├── test-tcp-writealot.c │ ├── test-thread-equal.c │ ├── test-thread.c │ ├── test-threadpool-cancel.c │ ├── test-threadpool.c │ ├── test-timer-again.c │ ├── test-timer-from-check.c │ ├── test-timer.c │ ├── test-tty.c │ ├── test-udp-bind.c │ ├── test-udp-create-socket-early.c │ ├── test-udp-dgram-too-big.c │ ├── test-udp-ipv6.c │ ├── test-udp-multicast-interface.c │ ├── test-udp-multicast-interface6.c │ ├── test-udp-multicast-join.c │ ├── test-udp-multicast-join6.c │ ├── test-udp-multicast-ttl.c │ ├── test-udp-open.c │ ├── test-udp-options.c │ ├── test-udp-send-and-recv.c │ ├── test-udp-send-immediate.c │ ├── test-udp-send-unreachable.c │ ├── test-udp-try-send.c │ ├── test-walk-handles.c │ └── test-watcher-cross-stop.c ├── uv.gyp └── vcbuild.bat ├── luajit ├── ndate.make ├── node9.make ├── premake5.lua ├── rebuild.sh ├── run.sh └── src ├── include ├── kerndate.h ├── nine.h └── ninejit.h ├── main.c ├── misc └── luajit-src-Makefile ├── misc9.c ├── node9.lua ├── nodearch.c ├── nodearch.lua ├── nodetopo.c ├── premake5.lua ├── styx ├── hosting │ └── libuv │ │ ├── NOTE │ │ ├── NOTICE │ │ ├── asm-386.s │ │ ├── asm-power.s │ │ ├── cmd.c │ │ ├── deveia.c │ │ ├── devfs.c │ │ ├── emu │ │ ├── emu-g │ │ ├── emu-node9 │ │ ├── emu.c │ │ ├── emu.root.h │ │ ├── include │ │ ├── emu.h │ │ └── emu.root.h │ │ ├── keycodes.h │ │ ├── mkfile │ │ ├── mkfile-g │ │ ├── mkfile-x11 │ │ └── os-uv.c ├── include │ ├── NOTICE │ ├── a.out.h │ ├── bio.h │ ├── cursor.h │ ├── draw.h │ ├── drawif.h │ ├── dynld.h │ ├── fcall.h │ ├── flate.h │ ├── freetype.h │ ├── freetype │ │ ├── cache │ │ │ ├── ftccache.h │ │ │ ├── ftccmap.h │ │ │ ├── ftcglyph.h │ │ │ ├── ftcimage.h │ │ │ ├── ftcmanag.h │ │ │ ├── ftcsbits.h │ │ │ └── ftlru.h │ │ ├── config │ │ │ ├── ftconfig.h │ │ │ ├── ftconfig.h.orig │ │ │ ├── ftheader.h │ │ │ ├── ftmodule.h │ │ │ ├── ftmodule.h.orig │ │ │ ├── ftoption.h │ │ │ ├── ftstdlib.h │ │ │ └── ftstdlib.h.orig │ │ ├── freetype.h │ │ ├── ft2build.h │ │ ├── ftbbox.h │ │ ├── ftbdf.h │ │ ├── ftcache.h │ │ ├── ftchapters.h │ │ ├── fterrdef.h │ │ ├── fterrors.h │ │ ├── ftglyph.h │ │ ├── ftgzip.h │ │ ├── ftimage.h │ │ ├── ftincrem.h │ │ ├── ftlist.h │ │ ├── ftmac.h │ │ ├── ftmm.h │ │ ├── ftmoderr.h │ │ ├── ftmodule.h │ │ ├── ftoutln.h │ │ ├── ftpfr.h │ │ ├── ftrender.h │ │ ├── ftsizes.h │ │ ├── ftsnames.h │ │ ├── ftstroker.h │ │ ├── ftsynth.h │ │ ├── ftsysio.h │ │ ├── ftsysmem.h │ │ ├── ftsystem.h │ │ ├── fttrigon.h │ │ ├── fttypes.h │ │ ├── ftxf86.h │ │ ├── internal │ │ │ ├── autohint.h │ │ │ ├── bdftypes.h │ │ │ ├── cfftypes.h │ │ │ ├── fnttypes.h │ │ │ ├── ftcalc.h │ │ │ ├── ftcore.h │ │ │ ├── ftdebug.h │ │ │ ├── ftdriver.h │ │ │ ├── ftexcept.h │ │ │ ├── ftgloadr.h │ │ │ ├── fthash.h │ │ │ ├── ftmemory.h │ │ │ ├── ftobject.h │ │ │ ├── ftobjs.h │ │ │ ├── ftstream.h │ │ │ ├── fttrace.h │ │ │ ├── internal.h │ │ │ ├── pcftypes.h │ │ │ ├── pfr.h │ │ │ ├── psaux.h │ │ │ ├── pshints.h │ │ │ ├── psnames.h │ │ │ ├── sfnt.h │ │ │ ├── t1types.h │ │ │ ├── t42types.h │ │ │ └── tttypes.h │ │ ├── t1tables.h │ │ ├── ttnameid.h │ │ ├── tttables.h │ │ └── tttags.h │ ├── interp.h │ ├── isa.h │ ├── kernel.h │ ├── keyboard.h │ ├── libsec.h │ ├── logfs.h │ ├── logfsos.h │ ├── mathi.h │ ├── memdraw.h │ ├── memlayer.h │ ├── mp.h │ ├── nandecc.h │ ├── nandfs.h │ ├── pool.h │ ├── pooldefs.h │ ├── prefab.h │ ├── raise.h │ ├── rdbg.h │ ├── styx.h │ ├── styxserver.h │ ├── tk.h │ ├── trace.h │ ├── version.h │ └── vm.h ├── libs │ ├── include │ │ └── os.h │ ├── lib9 │ │ ├── NOTICE │ │ ├── argv0.c │ │ ├── charstod.c │ │ ├── cistrcmp.c │ │ ├── cistrncmp.c │ │ ├── cistrstr.c │ │ ├── cleanname.c │ │ ├── convD2M.c │ │ ├── convM2D.c │ │ ├── convM2S.c │ │ ├── convS2M.c │ │ ├── create.c │ │ ├── dirstat-Nt.c │ │ ├── dirstat-posix.c │ │ ├── dirwstat.c │ │ ├── dofmt.c │ │ ├── dorfmt.c │ │ ├── errfmt.c │ │ ├── errstr-Nt.c │ │ ├── errstr-Plan9.c │ │ ├── errstr-posix.c │ │ ├── exits.c │ │ ├── fcallfmt.c │ │ ├── fltfmt.c │ │ ├── fmt.c │ │ ├── fmtdef.h │ │ ├── fmtfd.c │ │ ├── fmtlock.c │ │ ├── fmtprint.c │ │ ├── fmtquote.c │ │ ├── fmtrune.c │ │ ├── fmtstr.c │ │ ├── fmtvprint.c │ │ ├── fprint.c │ │ ├── getcallerpc-DragonFly-386.S │ │ ├── getcallerpc-FreeBSD-386.S │ │ ├── getcallerpc-FreeBSD-X86_64.s │ │ ├── getcallerpc-Hp-s800.s │ │ ├── getcallerpc-Irix-mips.s │ │ ├── getcallerpc-Linux-386.S │ │ ├── getcallerpc-Linux-X86_64.s │ │ ├── getcallerpc-Linux-arm.S │ │ ├── getcallerpc-Linux-power.c │ │ ├── getcallerpc-Linux-spim.S │ │ ├── getcallerpc-MacOSX-386.s │ │ ├── getcallerpc-MacOSX-X86_64.s │ │ ├── getcallerpc-MacOSX-power.s │ │ ├── getcallerpc-NetBSD-386.S │ │ ├── getcallerpc-OpenBSD-386.S │ │ ├── getcallerpc-Solaris-386.s │ │ ├── getcallerpc-Solaris-sparc.s │ │ ├── getcallerpc-Unixware-386.s │ │ ├── getfields.c │ │ ├── getuser-Nt.c │ │ ├── getuser-posix.c │ │ ├── getwd-Nt.c │ │ ├── getwd-posix.c │ │ ├── isnan-posix.c │ │ ├── lock-Hp-s800.s │ │ ├── lock-Irix-mips.s │ │ ├── lock-MacOSX-power.s │ │ ├── lock-Nt-386.c │ │ ├── lock-Solaris-386.s │ │ ├── lock-Solaris-sparc.s │ │ ├── lock-Unixware-386.s │ │ ├── lock.c │ │ ├── mkfile │ │ ├── mkfile-Nt │ │ ├── mkfile-Plan9 │ │ ├── mkfile-Posix │ │ ├── nulldir.c │ │ ├── pow10.c │ │ ├── pread-Nt.c │ │ ├── premake5.lua │ │ ├── print.c │ │ ├── qsort.c │ │ ├── readn.c │ │ ├── rerrstr.c │ │ ├── rune.c │ │ ├── runeseprint.c │ │ ├── runesmprint.c │ │ ├── runesnprint.c │ │ ├── runestrchr.c │ │ ├── runestrlen.c │ │ ├── runetype.c │ │ ├── runetypebody-6.2.0.h │ │ ├── runevseprint.c │ │ ├── sbrk-posix.c │ │ ├── seek.c │ │ ├── seprint.c │ │ ├── setbinmode-Nt.c │ │ ├── smprint.c │ │ ├── snprint.c │ │ ├── sprint.c │ │ ├── strdup.c │ │ ├── strecpy.c │ │ ├── strtoll.c │ │ ├── strtoull.c │ │ ├── sysfatal.c │ │ ├── tokenize.c │ │ ├── u16.c │ │ ├── u32.c │ │ ├── u64.c │ │ ├── utfecpy.c │ │ ├── utflen.c │ │ ├── utfnlen.c │ │ ├── utfrrune.c │ │ ├── utfrune.c │ │ ├── vfprint.c │ │ ├── vseprint.c │ │ ├── vsmprint.c │ │ └── vsnprint.c │ ├── libbio │ │ ├── NOTICE │ │ ├── bbuffered.c │ │ ├── bfildes.c │ │ ├── bflush.c │ │ ├── bgetc.c │ │ ├── bgetd.c │ │ ├── bgetrune.c │ │ ├── binit.c │ │ ├── boffset.c │ │ ├── bprint.c │ │ ├── bputc.c │ │ ├── bputrune.c │ │ ├── brdline.c │ │ ├── brdstr.c │ │ ├── bread.c │ │ ├── bseek.c │ │ ├── bvprint.c │ │ ├── bwrite.c │ │ ├── mkfile │ │ └── premake5.lua │ └── libsec │ │ ├── aes.c │ │ ├── blowfish.c │ │ ├── decodepem.c │ │ ├── des.c │ │ ├── des3CBC.c │ │ ├── des3ECB.c │ │ ├── desCBC.c │ │ ├── desECB.c │ │ ├── desmodes.c │ │ ├── dsaalloc.c │ │ ├── dsagen.c │ │ ├── dsaprimes.c │ │ ├── dsaprivtopub.c │ │ ├── dsasign.c │ │ ├── dsaverify.c │ │ ├── egalloc.c │ │ ├── egdecrypt.c │ │ ├── egencrypt.c │ │ ├── eggen.c │ │ ├── egprivtopub.c │ │ ├── egsign.c │ │ ├── egtest.c │ │ ├── egverify.c │ │ ├── fastrand.c │ │ ├── genprime.c │ │ ├── genrandom.c │ │ ├── gensafeprime.c │ │ ├── genstrongprime.c │ │ ├── hmac.c │ │ ├── hmactest.c │ │ ├── idea.c │ │ ├── md4.c │ │ ├── md4test.c │ │ ├── md5.c │ │ ├── md5block.c │ │ ├── md5pickle.c │ │ ├── mkfile │ │ ├── nfastrand.c │ │ ├── premake5.lua │ │ ├── primetest.c │ │ ├── prng.c │ │ ├── probably_prime.c │ │ ├── rc4.c │ │ ├── reduce-nt │ │ ├── reduce-rc │ │ ├── reduce-sh │ │ ├── rsaalloc.c │ │ ├── rsadecrypt.c │ │ ├── rsaencrypt.c │ │ ├── rsafill.c │ │ ├── rsagen.c │ │ ├── rsaprivtopub.c │ │ ├── rsatest.c │ │ ├── sha1.c │ │ ├── sha1block.c │ │ ├── sha1pickle.c │ │ ├── sha2.c │ │ ├── sha256block.c │ │ ├── sha512block.c │ │ ├── smallprimes.c │ │ └── smallprimetest.c ├── platform │ ├── FreeBSD │ │ ├── asm-386.S │ │ ├── audio.c │ │ ├── cmd.c │ │ ├── deveia.c │ │ ├── devfs.c │ │ ├── emu │ │ ├── emu-g │ │ ├── include │ │ │ ├── fpuctl.h │ │ │ ├── lib9.h │ │ │ └── old-emu.h │ │ ├── mkfile │ │ ├── mkfile-FreeBSD │ │ └── os.c │ ├── Linux │ │ ├── asm-386.S │ │ ├── asm-arm.S │ │ ├── asm-mips.S │ │ ├── asm-power.S │ │ ├── asm-spim.S │ │ ├── audio-oss.c │ │ ├── cmd.c │ │ ├── deveia.c │ │ ├── devfs.c │ │ ├── emu │ │ ├── emu-g │ │ ├── emu-wrt │ │ ├── emu.c │ │ ├── include │ │ │ ├── fpuctl.h │ │ │ └── lib9.h │ │ ├── mk-wrt │ │ ├── mkfile │ │ ├── mkfile-p │ │ ├── os-clone.c │ │ ├── os.c │ │ ├── segflush-386.c │ │ ├── segflush-arm.c │ │ ├── segflush-mips.S │ │ ├── segflush-power.c │ │ └── segflush-spim.S │ ├── MacOSX │ │ ├── NOTE │ │ ├── NOTICE │ │ ├── asm-386.s │ │ ├── asm-power.s │ │ ├── cmd.c │ │ ├── deveia.c │ │ ├── devfs.c │ │ ├── emu │ │ ├── emu-g │ │ ├── include │ │ │ └── lib9.h │ │ ├── keycodes.h │ │ ├── mkfile │ │ ├── mkfile-g │ │ ├── mkfile-x11 │ │ ├── os-orig.c │ │ └── os.c │ ├── Nt │ │ ├── audio.c │ │ ├── cmd.c │ │ ├── devarch.c │ │ ├── deveia.c │ │ ├── devfs.c │ │ ├── emu │ │ ├── fp.c │ │ ├── ie │ │ ├── ie-os.c │ │ ├── ie-win.c │ │ ├── ieplugin.h │ │ ├── ipif.c │ │ ├── ipif6.c │ │ ├── mkfile │ │ ├── nt.rc │ │ ├── os.c │ │ ├── r16.c │ │ ├── r16.h │ │ ├── vlrt.c │ │ └── win.c │ └── README ├── svcs │ ├── alloc.c │ ├── attic │ │ ├── discall-2-luvcall.c │ │ ├── kproc-pthreads.c │ │ ├── node9.c │ │ ├── node9.c-2 │ │ └── node9.h │ ├── cache.c │ ├── chan.c │ ├── dat.h │ ├── dev.c │ ├── devcap.c │ ├── devcmd.c │ ├── devcons.c │ ├── devdup.c │ ├── devdynld.c │ ├── devdynldx.c │ ├── devenv.c │ ├── devfs-posix.c │ ├── devindir.c │ ├── devip.c │ ├── devmem.c │ ├── devmnt.c │ ├── devpipe.c │ ├── devprof.c │ ├── devprog.c │ ├── devroot.c │ ├── devsrv.c │ ├── devssl.c │ ├── devtab.c │ ├── dial.c │ ├── dynld.c │ ├── dynldc.c │ ├── env.c │ ├── error.c │ ├── error.h │ ├── errstr.c │ ├── exportfs.c │ ├── exptab.c │ ├── fns.h │ ├── ip.h │ ├── ipaux.c │ ├── ipif-posix.c │ ├── ipif6-posix.c │ ├── kproc-libuv.c │ ├── latin1.c │ ├── latin1.h │ ├── lock.c │ ├── master │ ├── master.local │ ├── node9.c │ ├── parse.c │ ├── pgrp.c │ ├── portmkfile │ ├── print.c │ ├── proc.c │ ├── qio.c │ ├── random.c │ ├── srv.c │ ├── styx.c │ ├── sysfile.c │ ├── uqid.c │ └── vm.c └── utils │ ├── include │ └── a.out.h │ ├── ndate │ ├── ndate.c │ └── premake5.lua └── trace.c /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | *.lai 17 | 18 | # Shared objects (inc. Windows DLLs) 19 | *.dll 20 | *.so 21 | *.so.* 22 | *.dylib 23 | 24 | # Executables 25 | *.exe 26 | *.out 27 | *.app 28 | *.i*86 29 | *.x86_64 30 | *.hex 31 | 32 | # Debug files 33 | *.dSYM/ 34 | 35 | # misc production directories 36 | /bin/* 37 | /lib/* 38 | /attic/* 39 | /testing/* 40 | /src/build/* 41 | 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Jim Burnes 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/README: -------------------------------------------------------------------------------- 1 | README for LuaJIT 2.0.4 2 | ----------------------- 3 | 4 | LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language. 5 | 6 | Project Homepage: http://luajit.org/ 7 | 8 | LuaJIT is Copyright (C) 2005-2015 Mike Pall. 9 | LuaJIT is free software, released under the MIT license. 10 | See full Copyright Notice in the COPYRIGHT file or in luajit.h. 11 | 12 | Documentation for LuaJIT is available in HTML format. 13 | Please point your favorite browser to: 14 | 15 | doc/luajit.html 16 | 17 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/doc/img/contact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/LuaJIT-2.0.4/doc/img/contact.png -------------------------------------------------------------------------------- /LuaJIT-2.0.4/dynasm/dasm_x64.lua: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- DynASM x64 module. 3 | -- 4 | -- Copyright (C) 2005-2015 Mike Pall. All rights reserved. 5 | -- See dynasm.lua for full copyright notice. 6 | ------------------------------------------------------------------------------ 7 | -- This module just sets 64 bit mode for the combined x86/x64 module. 8 | -- All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | x64 = true -- Using a global is an ugly, but effective solution. 12 | return require("dasm_x86") 13 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/etc/luajit.pc: -------------------------------------------------------------------------------- 1 | # Package information for LuaJIT to be used by pkg-config. 2 | majver=2 3 | minver=0 4 | relver=4 5 | version=${majver}.${minver}.${relver} 6 | abiver=5.1 7 | 8 | prefix=/usr/local 9 | multilib=lib 10 | exec_prefix=${prefix} 11 | libdir=${exec_prefix}/${multilib} 12 | libname=luajit-${abiver} 13 | includedir=${prefix}/include/luajit-${majver}.${minver} 14 | 15 | INSTALL_LMOD=${prefix}/share/lua/${abiver} 16 | INSTALL_CMOD=${prefix}/${multilib}/lua/${abiver} 17 | 18 | Name: LuaJIT 19 | Description: Just-in-time compiler for Lua 20 | URL: http://luajit.org 21 | Version: ${version} 22 | Requires: 23 | Libs: -L${libdir} -l${libname} 24 | Libs.private: -Wl,-E -lm -ldl 25 | Cflags: -I${includedir} 26 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/host/README: -------------------------------------------------------------------------------- 1 | The files in this directory are only used during the build process of LuaJIT. 2 | For cross-compilation, they must be executed on the host, not on the target. 3 | 4 | These files should NOT be installed! 5 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/host/buildvm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/LuaJIT-2.0.4/src/host/buildvm -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/host/minilua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/LuaJIT-2.0.4/src/host/minilua -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/jit/dis_mipsel.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT MIPSEL disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2015 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the little-endian functions from the 8 | -- MIPS disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local require = require 12 | 13 | module(...) 14 | 15 | local dis_mips = require(_PACKAGE.."dis_mips") 16 | 17 | create = dis_mips.create_el 18 | disass = dis_mips.disass_el 19 | regname = dis_mips.regname 20 | 21 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/jit/dis_x64.lua: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------- 2 | -- LuaJIT x64 disassembler wrapper module. 3 | -- 4 | -- Copyright (C) 2005-2015 Mike Pall. All rights reserved. 5 | -- Released under the MIT license. See Copyright Notice in luajit.h 6 | ---------------------------------------------------------------------------- 7 | -- This module just exports the 64 bit functions from the combined 8 | -- x86/x64 disassembler module. All the interesting stuff is there. 9 | ------------------------------------------------------------------------------ 10 | 11 | local require = require 12 | 13 | module(...) 14 | 15 | local dis_x86 = require(_PACKAGE.."dis_x86") 16 | 17 | create = dis_x86.create64 18 | disass = dis_x86.disass64 19 | regname = dis_x86.regname64 20 | 21 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj.supp: -------------------------------------------------------------------------------- 1 | # Valgrind suppression file for LuaJIT 2.0. 2 | { 3 | Optimized string compare 4 | Memcheck:Addr4 5 | fun:lj_str_cmp 6 | } 7 | { 8 | Optimized string compare 9 | Memcheck:Addr1 10 | fun:lj_str_cmp 11 | } 12 | { 13 | Optimized string compare 14 | Memcheck:Addr4 15 | fun:lj_str_new 16 | } 17 | { 18 | Optimized string compare 19 | Memcheck:Addr1 20 | fun:lj_str_new 21 | } 22 | { 23 | Optimized string compare 24 | Memcheck:Cond 25 | fun:lj_str_new 26 | } 27 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj_alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Bundled memory allocator. 3 | ** Donated to the public domain. 4 | */ 5 | 6 | #ifndef _LJ_ALLOC_H 7 | #define _LJ_ALLOC_H 8 | 9 | #include "lj_def.h" 10 | 11 | #ifndef LUAJIT_USE_SYSMALLOC 12 | LJ_FUNC void *lj_alloc_create(void); 13 | LJ_FUNC void lj_alloc_destroy(void *msp); 14 | LJ_FUNC void *lj_alloc_f(void *msp, void *ptr, size_t osize, size_t nsize); 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj_asm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** IR assembler (SSA IR -> machine code). 3 | ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_ASM_H 7 | #define _LJ_ASM_H 8 | 9 | #include "lj_jit.h" 10 | 11 | #if LJ_HASJIT 12 | LJ_FUNC void lj_asm_trace(jit_State *J, GCtrace *T); 13 | LJ_FUNC void lj_asm_patchexit(jit_State *J, GCtrace *T, ExitNo exitno, 14 | MCode *target); 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj_bc.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Bytecode instruction modes. 3 | ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_bc_c 7 | #define LUA_CORE 8 | 9 | #include "lj_obj.h" 10 | #include "lj_bc.h" 11 | 12 | /* Bytecode offsets and bytecode instruction modes. */ 13 | #include "lj_bcdef.h" 14 | 15 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj_carith.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** C data arithmetic. 3 | ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CARITH_H 7 | #define _LJ_CARITH_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASFFI 12 | 13 | LJ_FUNC int lj_carith_op(lua_State *L, MMS mm); 14 | 15 | #if LJ_32 && LJ_HASJIT 16 | LJ_FUNC int64_t lj_carith_mul64(int64_t x, int64_t k); 17 | #endif 18 | LJ_FUNC uint64_t lj_carith_divu64(uint64_t a, uint64_t b); 19 | LJ_FUNC int64_t lj_carith_divi64(int64_t a, int64_t b); 20 | LJ_FUNC uint64_t lj_carith_modu64(uint64_t a, uint64_t b); 21 | LJ_FUNC int64_t lj_carith_modi64(int64_t a, int64_t b); 22 | LJ_FUNC uint64_t lj_carith_powu64(uint64_t x, uint64_t k); 23 | LJ_FUNC int64_t lj_carith_powi64(int64_t x, int64_t k); 24 | 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj_ccallback.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FFI C callback handling. 3 | ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CCALLBACK_H 7 | #define _LJ_CCALLBACK_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_ctype.h" 11 | 12 | #if LJ_HASFFI 13 | 14 | /* Really belongs to lj_vm.h. */ 15 | LJ_ASMF void lj_vm_ffi_callback(void); 16 | 17 | LJ_FUNC MSize lj_ccallback_ptr2slot(CTState *cts, void *p); 18 | LJ_FUNCA lua_State * LJ_FASTCALL lj_ccallback_enter(CTState *cts, void *cf); 19 | LJ_FUNCA void LJ_FASTCALL lj_ccallback_leave(CTState *cts, TValue *o); 20 | LJ_FUNC void *lj_ccallback_new(CTState *cts, CType *ct, GCfunc *fn); 21 | LJ_FUNC void lj_ccallback_mcode_free(CTState *cts); 22 | 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj_clib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FFI C library loader. 3 | ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_CLIB_H 7 | #define _LJ_CLIB_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASFFI 12 | 13 | /* Namespace for C library indexing. */ 14 | #define CLNS_INDEX ((1u<env. */ 20 | } CLibrary; 21 | 22 | LJ_FUNC TValue *lj_clib_index(lua_State *L, CLibrary *cl, GCstr *name); 23 | LJ_FUNC void lj_clib_load(lua_State *L, GCtab *mt, GCstr *name, int global); 24 | LJ_FUNC void lj_clib_unload(CLibrary *cl); 25 | LJ_FUNC void lj_clib_default(lua_State *L, GCtab *mt); 26 | 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj_ff.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Fast function IDs. 3 | ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_FF_H 7 | #define _LJ_FF_H 8 | 9 | /* Fast function ID. */ 10 | typedef enum { 11 | FF_LUA_ = FF_LUA, /* Lua function (must be 0). */ 12 | FF_C_ = FF_C, /* Regular C function (must be 1). */ 13 | #define FFDEF(name) FF_##name, 14 | #include "lj_ffdef.h" 15 | FF__MAX 16 | } FastFunc; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj_ffrecord.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Fast function call recorder. 3 | ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_FFRECORD_H 7 | #define _LJ_FFRECORD_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | 12 | #if LJ_HASJIT 13 | /* Data used by handlers to record a fast function. */ 14 | typedef struct RecordFFData { 15 | TValue *argv; /* Runtime argument values. */ 16 | ptrdiff_t nres; /* Number of returned results (defaults to 1). */ 17 | uint32_t data; /* Per-ffid auxiliary data (opcode, literal etc.). */ 18 | } RecordFFData; 19 | 20 | LJ_FUNC int32_t lj_ffrecord_select_mode(jit_State *J, TRef tr, TValue *tv); 21 | LJ_FUNC void lj_ffrecord_func(jit_State *J); 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj_func.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Function handling (prototypes, functions and upvalues). 3 | ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_FUNC_H 7 | #define _LJ_FUNC_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Prototypes. */ 12 | LJ_FUNC void LJ_FASTCALL lj_func_freeproto(global_State *g, GCproto *pt); 13 | 14 | /* Upvalues. */ 15 | LJ_FUNCA void LJ_FASTCALL lj_func_closeuv(lua_State *L, TValue *level); 16 | LJ_FUNC void LJ_FASTCALL lj_func_freeuv(global_State *g, GCupval *uv); 17 | 18 | /* Functions (closures). */ 19 | LJ_FUNC GCfunc *lj_func_newC(lua_State *L, MSize nelems, GCtab *env); 20 | LJ_FUNC GCfunc *lj_func_newL_empty(lua_State *L, GCproto *pt, GCtab *env); 21 | LJ_FUNCA GCfunc *lj_func_newL_gc(lua_State *L, GCproto *pt, GCfuncL *parent); 22 | LJ_FUNC void LJ_FASTCALL lj_func_free(global_State *g, GCfunc *c); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj_gdbjit.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Client for the GDB JIT API. 3 | ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_GDBJIT_H 7 | #define _LJ_GDBJIT_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | 12 | #if LJ_HASJIT && defined(LUAJIT_USE_GDBJIT) 13 | 14 | LJ_FUNC void lj_gdbjit_addtrace(jit_State *J, GCtrace *T); 15 | LJ_FUNC void lj_gdbjit_deltrace(jit_State *J, GCtrace *T); 16 | 17 | #else 18 | #define lj_gdbjit_addtrace(J, T) UNUSED(T) 19 | #define lj_gdbjit_deltrace(J, T) UNUSED(T) 20 | #endif 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj_mcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Machine code management. 3 | ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_MCODE_H 7 | #define _LJ_MCODE_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #if LJ_HASJIT || LJ_HASFFI 12 | LJ_FUNC void lj_mcode_sync(void *start, void *end); 13 | #endif 14 | 15 | #if LJ_HASJIT 16 | 17 | #include "lj_jit.h" 18 | 19 | LJ_FUNC void lj_mcode_free(jit_State *J); 20 | LJ_FUNC MCode *lj_mcode_reserve(jit_State *J, MCode **lim); 21 | LJ_FUNC void lj_mcode_commit(jit_State *J, MCode *m); 22 | LJ_FUNC void lj_mcode_abort(jit_State *J); 23 | LJ_FUNC MCode *lj_mcode_patch(jit_State *J, MCode *ptr, int finish); 24 | LJ_FUNC_NORET void lj_mcode_limiterr(jit_State *J, size_t need); 25 | 26 | #define lj_mcode_commitbot(J, m) (J->mcbot = (m)) 27 | 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj_obj.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Miscellaneous object handling. 3 | ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_obj_c 7 | #define LUA_CORE 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Object type names. */ 12 | LJ_DATADEF const char *const lj_obj_typename[] = { /* ORDER LUA_T */ 13 | "no value", "nil", "boolean", "userdata", "number", "string", 14 | "table", "function", "userdata", "thread", "proto", "cdata" 15 | }; 16 | 17 | LJ_DATADEF const char *const lj_obj_itypename[] = { /* ORDER LJ_T */ 18 | "nil", "boolean", "boolean", "userdata", "string", "upval", "thread", 19 | "proto", "function", "trace", "cdata", "table", "userdata", "number" 20 | }; 21 | 22 | /* Compare two objects without calling metamethods. */ 23 | int lj_obj_equal(cTValue *o1, cTValue *o2) 24 | { 25 | if (itype(o1) == itype(o2)) { 26 | if (tvispri(o1)) 27 | return 1; 28 | if (!tvisnum(o1)) 29 | return gcrefeq(o1->gcr, o2->gcr); 30 | } else if (!tvisnumber(o1) || !tvisnumber(o2)) { 31 | return 0; 32 | } 33 | return numberVnum(o1) == numberVnum(o2); 34 | } 35 | 36 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj_parse.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Lua parser (source code -> bytecode). 3 | ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_PARSE_H 7 | #define _LJ_PARSE_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_lex.h" 11 | 12 | LJ_FUNC GCproto *lj_parse(LexState *ls); 13 | LJ_FUNC GCstr *lj_parse_keepstr(LexState *ls, const char *str, size_t l); 14 | #if LJ_HASFFI 15 | LJ_FUNC void lj_parse_keepcdata(LexState *ls, TValue *tv, GCcdata *cd); 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj_snap.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Snapshot handling. 3 | ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_SNAP_H 7 | #define _LJ_SNAP_H 8 | 9 | #include "lj_obj.h" 10 | #include "lj_jit.h" 11 | 12 | #if LJ_HASJIT 13 | LJ_FUNC void lj_snap_add(jit_State *J); 14 | LJ_FUNC void lj_snap_purge(jit_State *J); 15 | LJ_FUNC void lj_snap_shrink(jit_State *J); 16 | LJ_FUNC IRIns *lj_snap_regspmap(GCtrace *T, SnapNo snapno, IRIns *ir); 17 | LJ_FUNC void lj_snap_replay(jit_State *J, GCtrace *T); 18 | LJ_FUNC const BCIns *lj_snap_restore(jit_State *J, void *exptr); 19 | LJ_FUNC void lj_snap_grow_buf_(jit_State *J, MSize need); 20 | LJ_FUNC void lj_snap_grow_map_(jit_State *J, MSize need); 21 | 22 | static LJ_AINLINE void lj_snap_grow_buf(jit_State *J, MSize need) 23 | { 24 | if (LJ_UNLIKELY(need > J->sizesnap)) lj_snap_grow_buf_(J, need); 25 | } 26 | 27 | static LJ_AINLINE void lj_snap_grow_map(jit_State *J, MSize need) 28 | { 29 | if (LJ_UNLIKELY(need > J->sizesnapmap)) lj_snap_grow_map_(J, need); 30 | } 31 | 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj_state.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** State and stack handling. 3 | ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_STATE_H 7 | #define _LJ_STATE_H 8 | 9 | #include "lj_obj.h" 10 | 11 | #define incr_top(L) \ 12 | (++L->top >= tvref(L->maxstack) && (lj_state_growstack1(L), 0)) 13 | 14 | #define savestack(L, p) ((char *)(p) - mref(L->stack, char)) 15 | #define restorestack(L, n) ((TValue *)(mref(L->stack, char) + (n))) 16 | 17 | LJ_FUNC void lj_state_relimitstack(lua_State *L); 18 | LJ_FUNC void lj_state_shrinkstack(lua_State *L, MSize used); 19 | LJ_FUNCA void LJ_FASTCALL lj_state_growstack(lua_State *L, MSize need); 20 | LJ_FUNC void LJ_FASTCALL lj_state_growstack1(lua_State *L); 21 | 22 | static LJ_AINLINE void lj_state_checkstack(lua_State *L, MSize need) 23 | { 24 | if ((mref(L->maxstack, char) - (char *)L->top) <= 25 | (ptrdiff_t)need*(ptrdiff_t)sizeof(TValue)) 26 | lj_state_growstack(L, need); 27 | } 28 | 29 | LJ_FUNC lua_State *lj_state_new(lua_State *L); 30 | LJ_FUNC void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L); 31 | #if LJ_64 32 | LJ_FUNC lua_State *lj_state_newstate(lua_Alloc f, void *ud); 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj_strscan.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** String scanning. 3 | ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_STRSCAN_H 7 | #define _LJ_STRSCAN_H 8 | 9 | #include "lj_obj.h" 10 | 11 | /* Options for accepted/returned formats. */ 12 | #define STRSCAN_OPT_TOINT 0x01 /* Convert to int32_t, if possible. */ 13 | #define STRSCAN_OPT_TONUM 0x02 /* Always convert to double. */ 14 | #define STRSCAN_OPT_IMAG 0x04 15 | #define STRSCAN_OPT_LL 0x08 16 | #define STRSCAN_OPT_C 0x10 17 | 18 | /* Returned format. */ 19 | typedef enum { 20 | STRSCAN_ERROR, 21 | STRSCAN_NUM, STRSCAN_IMAG, 22 | STRSCAN_INT, STRSCAN_U32, STRSCAN_I64, STRSCAN_U64, 23 | } StrScanFmt; 24 | 25 | LJ_FUNC StrScanFmt lj_strscan_scan(const uint8_t *p, TValue *o, uint32_t opt); 26 | LJ_FUNC int LJ_FASTCALL lj_strscan_num(GCstr *str, TValue *o); 27 | #if LJ_DUALNUM 28 | LJ_FUNC int LJ_FASTCALL lj_strscan_number(GCstr *str, TValue *o); 29 | #else 30 | #define lj_strscan_number(s, o) lj_strscan_num((s), (o)) 31 | #endif 32 | 33 | /* Check for number or convert string to number/int in-place (!). */ 34 | static LJ_AINLINE int lj_strscan_numberobj(TValue *o) 35 | { 36 | return tvisnumber(o) || (tvisstr(o) && lj_strscan_number(strV(o), o)); 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj_udata.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Userdata handling. 3 | ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #define lj_udata_c 7 | #define LUA_CORE 8 | 9 | #include "lj_obj.h" 10 | #include "lj_gc.h" 11 | #include "lj_udata.h" 12 | 13 | GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env) 14 | { 15 | GCudata *ud = lj_mem_newt(L, sizeof(GCudata) + sz, GCudata); 16 | global_State *g = G(L); 17 | newwhite(g, ud); /* Not finalized. */ 18 | ud->gct = ~LJ_TUDATA; 19 | ud->udtype = UDTYPE_USERDATA; 20 | ud->len = sz; 21 | /* NOBARRIER: The GCudata is new (marked white). */ 22 | setgcrefnull(ud->metatable); 23 | setgcref(ud->env, obj2gco(env)); 24 | /* Chain to userdata list (after main thread). */ 25 | setgcrefr(ud->nextgc, mainthread(g)->nextgc); 26 | setgcref(mainthread(g)->nextgc, obj2gco(ud)); 27 | return ud; 28 | } 29 | 30 | void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud) 31 | { 32 | lj_mem_free(g, ud, sizeudata(ud)); 33 | } 34 | 35 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lj_udata.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Userdata handling. 3 | ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LJ_UDATA_H 7 | #define _LJ_UDATA_H 8 | 9 | #include "lj_obj.h" 10 | 11 | LJ_FUNC GCudata *lj_udata_new(lua_State *L, MSize sz, GCtab *env); 12 | LJ_FUNC void LJ_FASTCALL lj_udata_free(global_State *g, GCudata *ud); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // C++ wrapper for LuaJIT header files. 2 | 3 | extern "C" { 4 | #include "lua.h" 5 | #include "lauxlib.h" 6 | #include "lualib.h" 7 | #include "luajit.h" 8 | } 9 | 10 | -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/luajit: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/LuaJIT-2.0.4/src/luajit -------------------------------------------------------------------------------- /LuaJIT-2.0.4/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Standard library header. 3 | ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h 4 | */ 5 | 6 | #ifndef _LUALIB_H 7 | #define _LUALIB_H 8 | 9 | #include "lua.h" 10 | 11 | #define LUA_FILEHANDLE "FILE*" 12 | 13 | #define LUA_COLIBNAME "coroutine" 14 | #define LUA_MATHLIBNAME "math" 15 | #define LUA_STRLIBNAME "string" 16 | #define LUA_TABLIBNAME "table" 17 | #define LUA_IOLIBNAME "io" 18 | #define LUA_OSLIBNAME "os" 19 | #define LUA_LOADLIBNAME "package" 20 | #define LUA_DBLIBNAME "debug" 21 | #define LUA_BITLIBNAME "bit" 22 | #define LUA_JITLIBNAME "jit" 23 | #define LUA_FFILIBNAME "ffi" 24 | 25 | LUALIB_API int luaopen_base(lua_State *L); 26 | LUALIB_API int luaopen_math(lua_State *L); 27 | LUALIB_API int luaopen_string(lua_State *L); 28 | LUALIB_API int luaopen_table(lua_State *L); 29 | LUALIB_API int luaopen_io(lua_State *L); 30 | LUALIB_API int luaopen_os(lua_State *L); 31 | LUALIB_API int luaopen_package(lua_State *L); 32 | LUALIB_API int luaopen_debug(lua_State *L); 33 | LUALIB_API int luaopen_bit(lua_State *L); 34 | LUALIB_API int luaopen_jit(lua_State *L); 35 | LUALIB_API int luaopen_ffi(lua_State *L); 36 | 37 | LUALIB_API void luaL_openlibs(lua_State *L); 38 | 39 | #ifndef lua_assert 40 | #define lua_assert(x) ((void)0) 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Node9 is a hosted 64-bit operating system based on Bell Lab's Inferno OS, but 2 | using the Lua scripting language instead of Limbo and the LuaJIT high 3 | performance virtual machine instead of the Dis virtual machine. It also uses 4 | the libuv I/O library for maximum portability, efficient event processing and 5 | thread management. 6 | 7 | See the [node9-hackers-guide.txt][hackers] file in ./doc for more information. 8 | 9 | For current status and development information, check out the [Wiki][wiki9] 10 | 11 | See Also: 12 | * [Inferno OS][inferno] 13 | * [Limbo][limbo] 14 | * [DIS VM][dis] 15 | * [Lua][lua] 16 | * [LuaJIT][luajit] 17 | * [libuv][libuv] 18 | 19 | [inferno]: http://www.vitanuova.com/inferno/ 20 | [limbo]: http://www.vitanuova.com/inferno/limbo.html 21 | [dis]: http://www.vitanuova.com/inferno/papers/dis.html 22 | [lua]: http://www.lua.org/ 23 | [luajit]: http://luajit.org/ 24 | [libuv]: http://docs.libuv.org/en/v1.x/ 25 | [hackers]: https://github.com/jvburnes/node9/blob/master/doc/node9-hackers-guide.txt 26 | [wiki9]: https://github.com/jvburnes/node9/wiki 27 | -------------------------------------------------------------------------------- /fs/appl/ls.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- simple ls function 3 | -- 4 | function init(argv) 5 | 6 | sys = import('sys') 7 | local path = argv[2] or "." 8 | 9 | local ldir = sys.open(path, sys.OREAD) 10 | 11 | if (ldir.fd < 0) then 12 | sys.print("ls: could not open path '%s'\n",path) 13 | else 14 | 15 | local need_hdr = true 16 | while true do 17 | local dirpack = sys.dirread(ldir) 18 | if dirpack.num == 0 then break end 19 | if need_hdr then 20 | sys.print("\n%s\n",path) 21 | sys.print("perms uid gid size atime name\n") 22 | need_hdr = false 23 | end 24 | 25 | local dir = dirpack.dirs 26 | for i=0, dirpack.num-1 do 27 | sys.print("%s\n",dir) 28 | dir = dir + 1 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /fs/appl/unmount.lua: -------------------------------------------------------------------------------- 1 | usage = "unmount [source] target" 2 | 3 | function fail(status, msg) 4 | sys.fprint(sys.fildes(2), "unmount: %s\n", msg); 5 | error("fail:" .. status) 6 | end 7 | 8 | function nomod(mod) 9 | fail("load", string.format("can't load %s: %s", mod, sys.errstr())) 10 | end 11 | 12 | function init(argv) 13 | sys = import("sys") 14 | buffers = import("buffers") 15 | arg = import('arg') 16 | 17 | -- massage the argument list 18 | 19 | if not arg then nomod('arg') end 20 | arg.setusage(usage) 21 | 22 | local opts = arg.getopt(argv,"") 23 | 24 | local argl = arg.strip() 25 | 26 | if #argl < 1 or #argl > 2 then arg.usage() end 27 | 28 | local target = table.remove(argl) 29 | 30 | local source = argl[1] 31 | 32 | -- and unmount 33 | local rc = sys.unmount(source, target) 34 | 35 | if rc < 0 then 36 | fail("unmount", string.format("unmount failed because: %s", sys.errstr())) 37 | end 38 | 39 | end 40 | 41 | -------------------------------------------------------------------------------- /fs/module/kern.h: -------------------------------------------------------------------------------- 1 | typedef 2 | struct Qid 3 | { 4 | uint64_t path; 5 | uint32_t vers; 6 | uint8_t type; 7 | } Qid; 8 | 9 | typedef 10 | struct Dir { 11 | 12 | /* system-modified data */ 13 | uint32_t type; /* server type */ 14 | uint32_t dev; /* server subtype */ 15 | /* file data */ 16 | Qid qid; /* unique id from server */ 17 | uint32_t mode; /* permissions */ 18 | uint32_t atime; /* last read time */ 19 | uint32_t mtime; /* last write time */ 20 | int64_t length; /* file length */ 21 | char *name; /* last element of path */ 22 | char *uid; /* owner name */ 23 | char *gid; /* group name */ 24 | char *muid; /* last modifier name */ 25 | } Dir; 26 | 27 | -------------------------------------------------------------------------------- /fs/module/ninevals.h: -------------------------------------------------------------------------------- 1 | /* plan9/inferno-specific value types */ 2 | typedef int64_t vlong; 3 | typedef uint64_t uvlong; 4 | typedef unsigned long ulong; 5 | typedef unsigned short ushort; 6 | typedef unsigned int uint; 7 | typedef unsigned char uchar; 8 | 9 | -------------------------------------------------------------------------------- /fs/module/sysconst.h: -------------------------------------------------------------------------------- 1 | enum SysConst { 2 | Sys_Maxint = 2147483647, 3 | Sys_QTDIR = 128, 4 | Sys_QTAPPEND = 64, 5 | Sys_QTEXCL = 32, 6 | Sys_QTAUTH = 8, 7 | Sys_QTTMP = 4, 8 | Sys_QTFILE = 0, 9 | Sys_ATOMICIO = 8192, 10 | Sys_SEEKSTART = 0, 11 | Sys_SEEKRELA = 1, 12 | Sys_SEEKEND = 2, 13 | Sys_NAMEMAX = 256, 14 | Sys_ERRMAX = 128, 15 | Sys_WAITLEN = 192, 16 | Sys_OREAD = 0, 17 | Sys_OWRITE = 1, 18 | Sys_ORDWR = 2, 19 | Sys_OTRUNC = 16, 20 | Sys_ORCLOSE = 64, 21 | Sys_OEXCL = 4096, 22 | Sys_DMDIR = 0x80000000, 23 | Sys_DMAPPEND = 0x40000000, 24 | Sys_DMEXCL = 0x20000000, 25 | Sys_DMAUTH = 0x08000000, 26 | Sys_DMTMP = 67108864, 27 | Sys_MREPL = 0, 28 | Sys_MBEFORE = 1, 29 | Sys_MAFTER = 2, 30 | Sys_MCREATE = 4, 31 | Sys_MCACHE = 16, 32 | Sys_NEWFD = 1, 33 | Sys_FORKFD = 2, 34 | Sys_NEWNS = 4, 35 | Sys_FORKNS = 8, 36 | Sys_NEWPGRP = 16, 37 | Sys_NODEVS = 32, 38 | Sys_NEWENV = 64, 39 | Sys_FORKENV = 128, 40 | Sys_EXPWAIT = 0, 41 | Sys_EXPASYNC = 1, 42 | Sys_UTFmax = 4, 43 | Sys_UTFerror = 65533, 44 | Sys_Runemax = 1114111, 45 | Sys_Runemask = 2097151, 46 | }; 47 | -------------------------------------------------------------------------------- /fs/os/lib/pl/init.lua: -------------------------------------------------------------------------------- 1 | -------------- 2 | -- Entry point for loading all PL libraries only on demand, into the global space. 3 | -- Requiring 'pl' means that whenever a module is implicitly accesssed 4 | -- (e.g. `utils.split`) 5 | -- then that module is dynamically loaded. The submodules are all brought into 6 | -- the global space. 7 | --Updated to use @{pl.import_into} 8 | -- @module pl 9 | require'pl.import_into'(_G) 10 | 11 | if rawget(_G,'PENLIGHT_STRICT') then require 'pl.strict' end 12 | -------------------------------------------------------------------------------- /images/totoro-spirit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/images/totoro-spirit.png -------------------------------------------------------------------------------- /libuv: -------------------------------------------------------------------------------- 1 | libuv-1.6.1 -------------------------------------------------------------------------------- /libuv-1.6.1/android-configure: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export TOOLCHAIN=$PWD/android-toolchain 4 | mkdir -p $TOOLCHAIN 5 | $1/build/tools/make-standalone-toolchain.sh \ 6 | --toolchain=arm-linux-androideabi-4.8 \ 7 | --arch=arm \ 8 | --install-dir=$TOOLCHAIN \ 9 | --platform=android-9 10 | export PATH=$TOOLCHAIN/bin:$PATH 11 | export AR=arm-linux-androideabi-ar 12 | export CC=arm-linux-androideabi-gcc 13 | export CXX=arm-linux-androideabi-g++ 14 | export LINK=arm-linux-androideabi-g++ 15 | export PLATFORM=android 16 | 17 | if [ $2 -a $2 == 'gyp' ] 18 | then 19 | ./gyp_uv.py -Dtarget_arch=arm -DOS=android 20 | fi 21 | -------------------------------------------------------------------------------- /libuv-1.6.1/docs/src/check.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _check: 3 | 4 | :c:type:`uv_check_t` --- Check handle 5 | ===================================== 6 | 7 | Check handles will run the given callback once per loop iteration, right 8 | after polling for i/o. 9 | 10 | 11 | Data types 12 | ---------- 13 | 14 | .. c:type:: uv_check_t 15 | 16 | Check handle type. 17 | 18 | .. c:type:: void (*uv_check_cb)(uv_check_t* handle) 19 | 20 | Type definition for callback passed to :c:func:`uv_check_start`. 21 | 22 | 23 | Public members 24 | ^^^^^^^^^^^^^^ 25 | 26 | N/A 27 | 28 | .. seealso:: The :c:type:`uv_handle_t` members also apply. 29 | 30 | 31 | API 32 | --- 33 | 34 | .. c:function:: int uv_check_init(uv_loop_t*, uv_check_t* check) 35 | 36 | Initialize the handle. 37 | 38 | .. c:function:: int uv_check_start(uv_check_t* check, uv_check_cb cb) 39 | 40 | Start the handle with the given callback. 41 | 42 | .. c:function:: int uv_check_stop(uv_check_t* check) 43 | 44 | Stop the handle, the callback will no longer be called. 45 | 46 | .. seealso:: The :c:type:`uv_handle_t` API functions also apply. 47 | -------------------------------------------------------------------------------- /libuv-1.6.1/docs/src/dll.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _dll: 3 | 4 | Shared library handling 5 | ======================= 6 | 7 | libuv provides cross platform utilities for loading shared libraries and 8 | retrieving symbols from them, using the following API. 9 | 10 | 11 | Data types 12 | ---------- 13 | 14 | .. c:type:: uv_lib_t 15 | 16 | Shared library data type. 17 | 18 | 19 | Public members 20 | ^^^^^^^^^^^^^^ 21 | 22 | N/A 23 | 24 | 25 | API 26 | --- 27 | 28 | .. c:function:: int uv_dlopen(const char* filename, uv_lib_t* lib) 29 | 30 | Opens a shared library. The filename is in utf-8. Returns 0 on success and 31 | -1 on error. Call :c:func:`uv_dlerror` to get the error message. 32 | 33 | .. c:function:: void uv_dlclose(uv_lib_t* lib) 34 | 35 | Close the shared library. 36 | 37 | .. c:function:: uv_dlsym(uv_lib_t* lib, const char* name, void** ptr) 38 | 39 | Retrieves a data pointer from a dynamic library. It is legal for a symbol 40 | to map to NULL. Returns 0 on success and -1 if the symbol was not found. 41 | 42 | .. c:function:: const char* uv_dlerror(const uv_lib_t* lib) 43 | 44 | Returns the last uv_dlopen() or uv_dlsym() error message. 45 | -------------------------------------------------------------------------------- /libuv-1.6.1/docs/src/prepare.rst: -------------------------------------------------------------------------------- 1 | 2 | .. _prepare: 3 | 4 | :c:type:`uv_prepare_t` --- Prepare handle 5 | ========================================= 6 | 7 | Prepare handles will run the given callback once per loop iteration, right 8 | before polling for i/o. 9 | 10 | 11 | Data types 12 | ---------- 13 | 14 | .. c:type:: uv_prepare_t 15 | 16 | Prepare handle type. 17 | 18 | .. c:type:: void (*uv_prepare_cb)(uv_prepare_t* handle) 19 | 20 | Type definition for callback passed to :c:func:`uv_prepare_start`. 21 | 22 | 23 | Public members 24 | ^^^^^^^^^^^^^^ 25 | 26 | N/A 27 | 28 | .. seealso:: The :c:type:`uv_handle_t` members also apply. 29 | 30 | 31 | API 32 | --- 33 | 34 | .. c:function:: int uv_prepare_init(uv_loop_t* loop, uv_prepare_t* prepare) 35 | 36 | Initialize the handle. 37 | 38 | .. c:function:: int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb) 39 | 40 | Start the handle with the given callback. 41 | 42 | .. c:function:: int uv_prepare_stop(uv_prepare_t* prepare) 43 | 44 | Stop the handle, the callback will no longer be called. 45 | 46 | .. seealso:: The :c:type:`uv_handle_t` API functions also apply. 47 | -------------------------------------------------------------------------------- /libuv-1.6.1/docs/src/static/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/libuv-1.6.1/docs/src/static/architecture.png -------------------------------------------------------------------------------- /libuv-1.6.1/docs/src/static/diagrams.key/Data/st0-311.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/libuv-1.6.1/docs/src/static/diagrams.key/Data/st0-311.jpg -------------------------------------------------------------------------------- /libuv-1.6.1/docs/src/static/diagrams.key/Data/st1-475.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/libuv-1.6.1/docs/src/static/diagrams.key/Data/st1-475.jpg -------------------------------------------------------------------------------- /libuv-1.6.1/docs/src/static/diagrams.key/Index.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/libuv-1.6.1/docs/src/static/diagrams.key/Index.zip -------------------------------------------------------------------------------- /libuv-1.6.1/docs/src/static/diagrams.key/Metadata/BuildVersionHistory.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Template: White (2014-02-28 09:41) 6 | M6.2.2-1878-1 7 | 8 | 9 | -------------------------------------------------------------------------------- /libuv-1.6.1/docs/src/static/diagrams.key/Metadata/DocumentIdentifier: -------------------------------------------------------------------------------- 1 | F69E9CD9-EEF1-4223-9DA4-A1EA7FE112BA -------------------------------------------------------------------------------- /libuv-1.6.1/docs/src/static/diagrams.key/Metadata/Properties.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/libuv-1.6.1/docs/src/static/diagrams.key/Metadata/Properties.plist -------------------------------------------------------------------------------- /libuv-1.6.1/docs/src/static/diagrams.key/preview-micro.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/libuv-1.6.1/docs/src/static/diagrams.key/preview-micro.jpg -------------------------------------------------------------------------------- /libuv-1.6.1/docs/src/static/diagrams.key/preview-web.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/libuv-1.6.1/docs/src/static/diagrams.key/preview-web.jpg -------------------------------------------------------------------------------- /libuv-1.6.1/docs/src/static/diagrams.key/preview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/libuv-1.6.1/docs/src/static/diagrams.key/preview.jpg -------------------------------------------------------------------------------- /libuv-1.6.1/docs/src/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/libuv-1.6.1/docs/src/static/favicon.ico -------------------------------------------------------------------------------- /libuv-1.6.1/docs/src/static/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/libuv-1.6.1/docs/src/static/logo.png -------------------------------------------------------------------------------- /libuv-1.6.1/docs/src/static/loop_iteration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/libuv-1.6.1/docs/src/static/loop_iteration.png -------------------------------------------------------------------------------- /libuv-1.6.1/img/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/libuv-1.6.1/img/banner.png -------------------------------------------------------------------------------- /libuv-1.6.1/libuv.pc: -------------------------------------------------------------------------------- 1 | prefix=/usr/local 2 | exec_prefix=/usr/local 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | 6 | Name: libuv 7 | Version: 1.6.1 8 | Description: multi-platform support library with a focus on asynchronous I/O. 9 | 10 | Libs: -L${libdir} -luv -lpthread -ldl 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /libuv-1.6.1/libuv.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: @PACKAGE_NAME@ 7 | Version: @PACKAGE_VERSION@ 8 | Description: multi-platform support library with a focus on asynchronous I/O. 9 | 10 | Libs: -L${libdir} -luv @LIBS@ 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /libuv-1.6.1/ltmain.sh: -------------------------------------------------------------------------------- 1 | /opt/local/share/libtool/config/ltmain.sh -------------------------------------------------------------------------------- /libuv-1.6.1/m4/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore libtoolize-generated files. 2 | *.m4 3 | !as_case.m4 4 | !libuv-check-flags.m4 5 | -------------------------------------------------------------------------------- /libuv-1.6.1/m4/as_case.m4: -------------------------------------------------------------------------------- 1 | # AS_CASE(WORD, [PATTERN1], [IF-MATCHED1]...[DEFAULT]) 2 | # ---------------------------------------------------- 3 | # Expand into 4 | # | case WORD in 5 | # | PATTERN1) IF-MATCHED1 ;; 6 | # | ... 7 | # | *) DEFAULT ;; 8 | # | esac 9 | m4_define([_AS_CASE], 10 | [m4_if([$#], 0, [m4_fatal([$0: too few arguments: $#])], 11 | [$#], 1, [ *) $1 ;;], 12 | [$#], 2, [ $1) m4_default([$2], [:]) ;;], 13 | [ $1) m4_default([$2], [:]) ;; 14 | $0(m4_shiftn(2, $@))])dnl 15 | ]) 16 | m4_defun([AS_CASE], 17 | [m4_ifval([$2$3], 18 | [case $1 in 19 | _AS_CASE(m4_shift($@)) 20 | esac])]) 21 | 22 | -------------------------------------------------------------------------------- /libuv-1.6.1/samples/.gitignore: -------------------------------------------------------------------------------- 1 | # Copyright StrongLoop, Inc. 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 | *.mk 22 | *.Makefile 23 | -------------------------------------------------------------------------------- /libuv-1.6.1/samples/socks5-proxy/.gitignore: -------------------------------------------------------------------------------- 1 | # Copyright StrongLoop, Inc. 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 | /build/ 22 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/.deps/.dirstamp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/libuv-1.6.1/src/.deps/.dirstamp -------------------------------------------------------------------------------- /libuv-1.6.1/src/.dirstamp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/libuv-1.6.1/src/.dirstamp -------------------------------------------------------------------------------- /libuv-1.6.1/src/unix/.deps/.dirstamp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/libuv-1.6.1/src/unix/.deps/.dirstamp -------------------------------------------------------------------------------- /libuv-1.6.1/src/unix/.deps/libuv_la-aix.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/unix/.deps/libuv_la-android-ifaddrs.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/unix/.deps/libuv_la-freebsd.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/unix/.deps/libuv_la-netbsd.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/unix/.deps/libuv_la-openbsd.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/unix/.deps/libuv_la-pthread-fixes.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/unix/.deps/libuv_la-sunos.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/unix/.dirstamp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/libuv-1.6.1/src/unix/.dirstamp -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-async.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-core.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-dl.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-error.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-fs-event.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-fs.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-getaddrinfo.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-getnameinfo.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-handle.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-loop-watcher.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-pipe.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-poll.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-process-stdio.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-process.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-req.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-signal.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-stream.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-tcp.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-thread.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-timer.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-tty.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-udp.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-util.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-winapi.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/.deps/libuv_la-winsock.Plo: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/src/win/req.c: -------------------------------------------------------------------------------- 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 23 | 24 | #include "uv.h" 25 | #include "internal.h" 26 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-blackhole-server.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-dns-server.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-echo-server.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-run-tests.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-runner-unix.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-runner-win.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-runner.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-active.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-async-null-cb.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-async.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-barrier.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-callback-order.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-callback-stack.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-close-fd.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-close-order.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-condvar.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-connection-fail.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-cwd-and-chdir.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-default-loop-close.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-delayed-accept.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-dlerror.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-embed.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-emfile.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-error.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-fail-always.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-fs-event.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-fs-poll.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-fs.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-get-currentexe.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-get-loadavg.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-get-memory.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-getaddrinfo.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-getnameinfo.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-getsockname.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-handle-fileno.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-homedir.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-hrtime.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-idle.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-ip4-addr.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-ip6-addr.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-ipc-send-recv.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-ipc.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-loop-alive.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-loop-close.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-loop-configure.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-loop-handles.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-loop-stop.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-loop-time.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-multiple-listen.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-mutexes.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-osx-select.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-pass-always.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-ping-pong.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-pipe-bind-error.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-pipe-close-stdout-read-stdin.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-pipe-connect-error.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-pipe-connect-prepare.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-pipe-getsockname.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-pipe-sendmsg.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-pipe-server-close.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-pipe-set-non-blocking.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-platform-output.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-poll-close-doesnt-corrupt-stack.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-poll-close.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-poll-closesocket.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-poll.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-process-title.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-ref.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-run-nowait.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-run-once.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-semaphore.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-shutdown-close.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-shutdown-eof.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-shutdown-twice.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-signal-multiple-loops.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-signal.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-socket-buffer-size.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-spawn.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-stdio-over-pipes.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-bind-error.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-bind6-error.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-close-accept.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-close-while-connecting.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-close.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-connect-error-after-write.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-connect-error.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-connect-timeout.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-connect6-error.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-create-socket-early.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-flags.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-oob.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-open.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-read-stop.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-shutdown-after-write.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-try-write.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-unexpected-read.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-write-after-connect.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-write-fail.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-write-queue-order.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-write-to-half-open-connection.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tcp-writealot.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-thread-equal.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-thread.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-threadpool-cancel.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-threadpool.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-timer-again.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-timer-from-check.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-timer.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-tty.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-udp-bind.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-udp-create-socket-early.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-udp-dgram-too-big.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-udp-ipv6.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-udp-multicast-interface.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-udp-multicast-interface6.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-udp-multicast-join.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-udp-multicast-join6.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-udp-multicast-ttl.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-udp-open.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-udp-options.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-udp-send-and-recv.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-udp-send-immediate.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-udp-send-unreachable.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-udp-try-send.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-walk-handles.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/.deps/test_run_tests-test-watcher-cross-stop.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/fixtures/empty_file: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/libuv-1.6.1/test/fixtures/empty_file -------------------------------------------------------------------------------- /libuv-1.6.1/test/fixtures/load_error.node: -------------------------------------------------------------------------------- 1 | foobar 2 | -------------------------------------------------------------------------------- /libuv-1.6.1/test/test-homedir.c: -------------------------------------------------------------------------------- 1 | #include "uv.h" 2 | #include "task.h" 3 | #include 4 | 5 | #define PATHMAX 1024 6 | #define SMALLPATH 1 7 | 8 | TEST_IMPL(homedir) { 9 | char homedir[PATHMAX]; 10 | size_t len; 11 | char last; 12 | int r; 13 | 14 | /* Test the normal case */ 15 | len = sizeof homedir; 16 | homedir[0] = '\0'; 17 | ASSERT(strlen(homedir) == 0); 18 | r = uv_os_homedir(homedir, &len); 19 | ASSERT(r == 0); 20 | ASSERT(strlen(homedir) == len); 21 | ASSERT(len > 0); 22 | ASSERT(homedir[len] == '\0'); 23 | 24 | if (len > 1) { 25 | last = homedir[len - 1]; 26 | #ifdef _WIN32 27 | ASSERT(last != '\\'); 28 | #else 29 | ASSERT(last != '/'); 30 | #endif 31 | } 32 | 33 | /* Test the case where the buffer is too small */ 34 | len = SMALLPATH; 35 | r = uv_os_homedir(homedir, &len); 36 | ASSERT(r == UV_ENOBUFS); 37 | ASSERT(len > SMALLPATH); 38 | 39 | /* Test invalid inputs */ 40 | r = uv_os_homedir(NULL, &len); 41 | ASSERT(r == UV_EINVAL); 42 | r = uv_os_homedir(homedir, NULL); 43 | ASSERT(r == UV_EINVAL); 44 | len = 0; 45 | r = uv_os_homedir(homedir, &len); 46 | ASSERT(r == UV_EINVAL); 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /luajit: -------------------------------------------------------------------------------- 1 | LuaJIT-2.0.4 -------------------------------------------------------------------------------- /rebuild.sh: -------------------------------------------------------------------------------- 1 | cd libuv; sh autogen.sh; ./configure; make 2 | rm .libs/lib*.so* 3 | rm .libs/lib*.dylib 4 | cd ../luajit; make 5 | rm src/lib*.so* 6 | rm src/lib*.dylib 7 | cd .. 8 | #premake5 clean 9 | rm -rf src/build 10 | #rm *.make 11 | #rm Makefile 12 | premake5 gmake 13 | make config=debug_linux 14 | 15 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | # quick run script 2 | # 3 | # uncomment one of the following for your OS 4 | #export DYLD_LIBRARY_PATH=./lib 5 | export LD_LIBRARY_PATH=./lib 6 | bin/node9 7 | -------------------------------------------------------------------------------- /src/include/kerndate.h: -------------------------------------------------------------------------------- 1 | #define KERNDATE 1439854030 2 | -------------------------------------------------------------------------------- /src/include/nine.h: -------------------------------------------------------------------------------- 1 | #ifndef NINE_FILE_H 2 | #define NINE_FILE_H 3 | 4 | #include 5 | #include 6 | #include "queue.h" 7 | #include "dat.h" 8 | #include "fns.h" 9 | #include "error.h" 10 | #include "kernel.h" 11 | 12 | typedef struct kargs_s kargs_t; 13 | void tramp(void *); 14 | extern void termset(void); 15 | extern void termrestore(void); 16 | 17 | 18 | /* trace stuff */ 19 | #define TRACE_INFO 0 20 | #define TRACE_WARN 10 21 | #define TRACE_ERROR 100 22 | #define TRACE_DEBUG 1000 23 | 24 | extern int tracelvl; 25 | 26 | #define trace(lvl, ...) {if (lvl <= (tracelvl)) {time_t now = time(NULL); struct tm mdy; char timestr[70]; gmtime_r(&now, &mdy); strftime(timestr, sizeof(timestr), "%c", &mdy); print("%s ",timestr); print(" " __VA_ARGS__); print("\n"); }} 27 | 28 | #include /* Always include this when calling Lua */ 29 | #include /* Always include this when calling Lua */ 30 | #include /* Always include this when calling Lua */ 31 | 32 | 33 | /* command line args */ 34 | struct kargs_s { 35 | int argc; 36 | char **argv; 37 | }; 38 | 39 | 40 | void panic(char *fmt, ...); 41 | extern int hostuid; 42 | extern int hostgid; 43 | extern void setsigs(void); 44 | void sysinit(void); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/nodearch.c: -------------------------------------------------------------------------------- 1 | /* 2 | * cpu-specific architecture information, part of libarch 3 | * 4 | * cpu type, arch, sizeof words and various structures like jump bufs etc 5 | * 6 | * this module and nodetopo comprise 'libarch' 7 | */ 8 | #include "dat.h" 9 | //#include "emu.h" 10 | 11 | //extern char* hosttype; 12 | //extern char* cputype; 13 | 14 | char *cputype = "amd-64"; 15 | char *hosttype = "MacOSX"; 16 | 17 | char *hostcpu() { 18 | return cputype; 19 | } 20 | 21 | char *hostos() { 22 | return hosttype; 23 | } 24 | 25 | /* the machine architecture word size in bytes, usually 4 or 8 */ 26 | int wordsize() { 27 | return sizeof(long); 28 | } 29 | 30 | 31 | /* number of 32-bit words (ints) in the os machine state */ 32 | int jumpsize() { 33 | return sizeof(osjmpbuf) >> 2; 34 | } 35 | -------------------------------------------------------------------------------- /src/nodearch.lua: -------------------------------------------------------------------------------- 1 | -- get machine info: this needs to be loaded *before* the node9 cdefs 2 | 3 | -- first the misc machine info 4 | 5 | ffi.cdef[[ 6 | extern char *hostcpu(); 7 | 8 | extern char *hostos(); 9 | 10 | /* the machine architecture word size in bytes, usually 4 or 8 */ 11 | extern int wordsize(); 12 | 13 | /* number of 32-bit words (ints) in the os machine state */ 14 | extern int jumpsize(); 15 | 16 | ]] 17 | -------------------------------------------------------------------------------- /src/nodetopo.c: -------------------------------------------------------------------------------- 1 | /* just a placeholder for now */ 2 | int numcpus() 3 | { 4 | return 2; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /src/styx/hosting/libuv/NOTE: -------------------------------------------------------------------------------- 1 | - still interp mode only, jit not complete 2 | - mkfile uses Carbon only; mkfile-x11 uses X11R6 from Apple 3 | - both powerpc and x86 versions compiled from this source 4 | - mkfile-g doesn't include graphics (uses emu-g not emu as configuration) 5 | -------------------------------------------------------------------------------- /src/styx/hosting/libuv/NOTICE: -------------------------------------------------------------------------------- 1 | MacOSX port Copyright © 2001-2003 Corpus Callosum Corporation, 2 | with portions Copyright © 2001-2003 Geoff Collyer 3 | MacOSX-x86 Copyright © 2006 Corpus Callosum Corporation 4 | -------------------------------------------------------------------------------- /src/styx/hosting/libuv/asm-386.s: -------------------------------------------------------------------------------- 1 | /* 2 | * these are the same as on the PC (eg, Linux) 3 | */ 4 | 5 | /* .globl _FPsave 6 | _FPsave: 7 | pushl %ebp 8 | movl %esp, %ebp 9 | movl 8(%ebp), %eax 10 | fstenv (%eax) 11 | popl %ebp 12 | ret 13 | 14 | .globl _FPrestore 15 | _FPrestore: 16 | pushl %ebp 17 | movl %esp, %ebp 18 | movl 8(%ebp), %eax 19 | fldenv (%eax) 20 | popl %ebp 21 | ret 22 | */ 23 | .globl __tas 24 | __tas: 25 | movl $1, %eax 26 | movl 4(%esp), %ecx 27 | xchgl %eax, 0(%ecx) 28 | ret 29 | -------------------------------------------------------------------------------- /src/styx/hosting/libuv/asm-power.s: -------------------------------------------------------------------------------- 1 | /* 2 | * File: asm-power.s 3 | * 4 | * Copyright (c) 2003, Corpus Callosum Corporation. All rights reserved. 5 | */ 6 | 7 | #include 8 | 9 | .text 10 | 11 | LEAF(_FPsave) 12 | mffs f0 13 | stfd f0,0(r3) 14 | blr 15 | END(_FPsave) 16 | 17 | LEAF(_FPrestore) 18 | lfd f0,0(r3) 19 | mtfsf 0xff,f0 20 | blr 21 | END(_FPrestore) 22 | 23 | LEAF(__tas) 24 | sync 25 | mr r4,r3 26 | addi r5,0,0x1 27 | 1: 28 | lwarx r3,0,r4 29 | cmpwi r3,0x0 30 | bne- 2f 31 | stwcx. r5,0,r4 32 | bne- 1b /* Lost reservation, try again */ 33 | 2: 34 | sync 35 | blr 36 | END(__tas) 37 | -------------------------------------------------------------------------------- /src/styx/hosting/libuv/devfs.c: -------------------------------------------------------------------------------- 1 | #include "devfs-posix.c" 2 | 3 | static vlong 4 | osdisksize(int fd) 5 | { 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/styx/hosting/libuv/emu.root.h: -------------------------------------------------------------------------------- 1 | int rootmaxq = 10; 2 | Dirtab roottab[10] = { 3 | "", {0, 0, QTDIR}, 0, 0555, 4 | "dev", {1, 0, QTDIR}, 0, 0555, 5 | "fd", {2, 0, QTDIR}, 0, 0555, 6 | "prog", {3, 0, QTDIR}, 0, 0555, 7 | "prof", {4, 0, QTDIR}, 0, 0555, 8 | "net", {5, 0, QTDIR}, 0, 0555, 9 | "net.alt", {6, 0, QTDIR}, 0, 0555, 10 | "chan", {7, 0, QTDIR}, 0, 0555, 11 | "nvfs", {8, 0, QTDIR}, 0, 0555, 12 | "env", {9, 0, QTDIR}, 0, 0555, 13 | }; 14 | Rootdata rootdata[10] = { 15 | 0, &roottab[1], 9, nil, 16 | 0, nil, 0, nil, 17 | 0, nil, 0, nil, 18 | 0, nil, 0, nil, 19 | 0, nil, 0, nil, 20 | 0, nil, 0, nil, 21 | 0, nil, 0, nil, 22 | 0, nil, 0, nil, 23 | 0, nil, 0, nil, 24 | 0, nil, 0, nil, 25 | }; 26 | -------------------------------------------------------------------------------- /src/styx/hosting/libuv/include/emu.h: -------------------------------------------------------------------------------- 1 | #ifndef EMU_H 2 | #define EMU_H 3 | 4 | #include 5 | 6 | /* 7 | * hosted hypervisor and microkernel implementation-specifics for threads, synchronization, 8 | * events, i/o, messaging, timers etc. 9 | */ 10 | 11 | /* 12 | * libuv stuff 13 | */ 14 | 15 | extern uv_key_t prdakey; 16 | extern Dev* devtab[]; 17 | 18 | 19 | #define up ((proc_t*)uv_key_get(&prdakey)) 20 | 21 | typedef sigjmp_buf osjmpbuf; 22 | #define ossetjmp(buf) sigsetjmp(buf, 1) 23 | 24 | /* os and hosting-specific bindings */ 25 | typedef struct Osdep Osdep; 26 | struct Osdep { 27 | unsigned long self; /* the thread id, not the thread pointer itself */ 28 | uv_thread_t thread; /* the actual thread */ 29 | uv_sem_t sem; /* OS wait semaphore */ 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/styx/hosting/libuv/include/emu.root.h: -------------------------------------------------------------------------------- 1 | int rootmaxq = 10; 2 | Dirtab roottab[10] = { 3 | "", {0, 0, QTDIR}, 0, 0555, 4 | "dev", {1, 0, QTDIR}, 0, 0555, 5 | "fd", {2, 0, QTDIR}, 0, 0555, 6 | "prog", {3, 0, QTDIR}, 0, 0555, 7 | "prof", {4, 0, QTDIR}, 0, 0555, 8 | "net", {5, 0, QTDIR}, 0, 0555, 9 | "net.alt", {6, 0, QTDIR}, 0, 0555, 10 | "chan", {7, 0, QTDIR}, 0, 0555, 11 | "nvfs", {8, 0, QTDIR}, 0, 0555, 12 | "env", {9, 0, QTDIR}, 0, 0555, 13 | }; 14 | Rootdata rootdata[10] = { 15 | 0, &roottab[1], 9, nil, 16 | 0, nil, 0, nil, 17 | 0, nil, 0, nil, 18 | 0, nil, 0, nil, 19 | 0, nil, 0, nil, 20 | 0, nil, 0, nil, 21 | 0, nil, 0, nil, 22 | 0, nil, 0, nil, 23 | 0, nil, 0, nil, 24 | 0, nil, 0, nil, 25 | }; 26 | -------------------------------------------------------------------------------- /src/styx/hosting/libuv/mkfile: -------------------------------------------------------------------------------- 1 | SYSTARG=MacOSX 2 | <../../mkconfig 3 | SYSTARG=MacOSX 4 | 5 | #Configurable parameters 6 | 7 | CONF=emu #default configuration 8 | CONFLIST=emu 9 | CLEANCONFLIST= 10 | 11 | INSTALLDIR=$ROOT/$SYSTARG/$OBJTYPE/bin #path of directory where kernel is installed 12 | 13 | #end configurable parameters 14 | 15 | <$ROOT/mkfiles/mkfile-$SYSTARG-$OBJTYPE #set vars based on target system 16 | 17 | <| $SHELLNAME ../port/mkdevlist $CONF #sets $IP, $DEVS, $PORT, $LIBS 18 | 19 | OBJ=\ 20 | asm-$OBJTYPE.$O\ 21 | os.$O\ 22 | $CONF.root.$O\ 23 | lock.$O\ 24 | $DEVS\ 25 | $PORT\ 26 | 27 | HFILES=\ 28 | 29 | CFLAGS='-DROOT="'$ROOT'"'\ 30 | '-DOBJTYPE="'$OBJTYPE'"'\ 31 | -DEMU -I. -I../port\ 32 | -I$ROOT/$SYSTARG/$OBJTYPE/include\ 33 | -I$ROOT/include -I$ROOT/libinterp\ 34 | $CTHREADFLAGS $CFLAGS $EMUOPTIONS\ 35 | 36 | KERNDATE=`{$NDATE} 37 | 38 | SYSLIBS= \ 39 | -lm\ 40 | -framework Carbon -framework QuickTime\ 41 | -lpthread\ 42 | -framework CoreFoundation\ 43 | -framework IOKit\ 44 | 45 | default:V: $O.$CONF 46 | 47 | <../port/portmkfile 48 | 49 | $O.$CONF: $OBJ $CONF.c $CONF.root.h $LIBFILES 50 | $CC $CFLAGS '-DKERNDATE='$KERNDATE $CONF.c 51 | $LD $LDFLAGS -o $target $OBJ $CONF.$O $LIBFILES $SYSLIBS 52 | 53 | install:V: $O.$CONF 54 | cp $O.$CONF $INSTALLDIR/$CONF 55 | 56 | devfs.c:N: ../port/devfs-posix.c 57 | -------------------------------------------------------------------------------- /src/styx/hosting/libuv/mkfile-g: -------------------------------------------------------------------------------- 1 | SYSTARG=MacOSX 2 | <../../mkconfig 3 | SYSTARG=MacOSX 4 | 5 | #Configurable parameters 6 | 7 | CONF=emu-g #default configuration 8 | CONFLIST=emu 9 | CLEANCONFLIST= 10 | 11 | INSTALLDIR=$ROOT/$SYSTARG/$OBJTYPE/bin #path of directory where kernel is installed 12 | 13 | #end configurable parameters 14 | 15 | <$ROOT/mkfiles/mkfile-$SYSTARG-$OBJTYPE #set vars based on target system 16 | 17 | <| $SHELLNAME ../port/mkdevlist $CONF #sets $IP, $DEVS, $PORT, $LIBS 18 | 19 | OBJ=\ 20 | asm-$OBJTYPE.$O\ 21 | os.$O\ 22 | $CONF.root.$O\ 23 | lock.$O\ 24 | $DEVS\ 25 | $PORT\ 26 | 27 | HFILES=\ 28 | 29 | CFLAGS='-DROOT="'$ROOT'"'\ 30 | '-DOBJTYPE="'$OBJTYPE'"'\ 31 | -DEMU -I. -I../port\ 32 | -I$ROOT/$SYSTARG/$OBJTYPE/include\ 33 | -I$ROOT/include -I$ROOT/libinterp\ 34 | $CTHREADFLAGS $CFLAGS $EMUOPTIONS\ 35 | 36 | KERNDATE=`{$NDATE} 37 | 38 | SYSLIBS= \ 39 | -lm\ 40 | -lpthread\ 41 | -framework CoreFoundation\ 42 | -framework IOKit\ 43 | 44 | default:V: $O.$CONF 45 | 46 | <../port/portmkfile 47 | 48 | $O.$CONF: $OBJ $CONF.c $CONF.root.h $LIBFILES 49 | $CC $CFLAGS '-DKERNDATE='$KERNDATE $CONF.c 50 | $LD $LDFLAGS -o $target $OBJ $CONF.$O $LIBFILES $SYSLIBS 51 | 52 | install:V: $O.$CONF 53 | cp $O.$CONF $INSTALLDIR/$CONF 54 | 55 | devfs.c:N: ../port/devfs-posix.c 56 | -------------------------------------------------------------------------------- /src/styx/include/a.out.h: -------------------------------------------------------------------------------- 1 | #include "../utils/include/a.out.h" 2 | -------------------------------------------------------------------------------- /src/styx/include/cursor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a separate file because image.h cannot be 3 | * included in many of the graphics drivers due to 4 | * name conflicts 5 | */ 6 | 7 | typedef struct Drawcursor Drawcursor; 8 | struct Drawcursor 9 | { 10 | int hotx; 11 | int hoty; 12 | int minx; 13 | int miny; 14 | int maxx; 15 | int maxy; 16 | uchar* data; 17 | }; 18 | 19 | void drawcursor(Drawcursor*); 20 | -------------------------------------------------------------------------------- /src/styx/include/drawif.h: -------------------------------------------------------------------------------- 1 | extern Font* checkfont(Draw_Font*); 2 | extern Image* checkimage(Draw_Image*); 3 | extern Screen* checkscreen(Draw_Screen*); 4 | extern Display* checkdisplay(Draw_Display*); 5 | extern void freedrawdisplay(Heap*, int); 6 | extern void freedrawfont(Heap*, int); 7 | extern void freedrawimage(Heap*, int); 8 | extern void freedrawscreen(Heap*, int); 9 | extern Font* lookupfont(Draw_Font*); 10 | extern Image* lookupimage(Draw_Image*); 11 | extern Screen* lookupscreen(Draw_Screen*); 12 | extern Draw_Image* mkdrawimage(Image*, Draw_Screen*, Draw_Display*, void*); 13 | -------------------------------------------------------------------------------- /src/styx/include/flate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * errors from deflate, deflateinit, deflateblock, 3 | * inflate, inflateinit, inflateblock. 4 | * convertable to a string by flateerr 5 | */ 6 | enum 7 | { 8 | FlateOk = 0, 9 | FlateNoMem = -1, 10 | FlateInputFail = -2, 11 | FlateOutputFail = -3, 12 | FlateCorrupted = -4, 13 | FlateInternal = -5, 14 | }; 15 | 16 | int deflateinit(void); 17 | int deflate(void *wr, int (*w)(void*, void*, int), void *rr, int (*r)(void*, void*, int), int level, int debug); 18 | 19 | int inflateinit(void); 20 | int inflate(void *wr, int (*w)(void*, void*, int), void *getr, int (*get)(void*)); 21 | 22 | int inflateblock(uchar *dst, int dsize, uchar *src, int ssize); 23 | int deflateblock(uchar *dst, int dsize, uchar *src, int ssize, int level, int debug); 24 | 25 | int deflatezlib(void *wr, int (*w)(void*, void*, int), void *rr, int (*r)(void*, void*, int), int level, int debug); 26 | int inflatezlib(void *wr, int (*w)(void*, void*, int), void *getr, int (*get)(void*)); 27 | 28 | int inflatezlibblock(uchar *dst, int dsize, uchar *src, int ssize); 29 | int deflatezlibblock(uchar *dst, int dsize, uchar *src, int ssize, int level, int debug); 30 | 31 | char *flateerr(int err); 32 | 33 | ulong *mkcrctab(ulong); 34 | ulong blockcrc(ulong *tab, ulong crc, void *buf, int n); 35 | 36 | ulong adler32(ulong adler, void *buf, int n); 37 | -------------------------------------------------------------------------------- /src/styx/include/freetype.h: -------------------------------------------------------------------------------- 1 | /* 2 | * interface to libfreetype without recourse to the real freetype headers 3 | * which would otherwise require full-blown CPP 4 | */ 5 | 6 | typedef struct FTfaceinfo FTfaceinfo; 7 | struct FTfaceinfo { 8 | int nfaces; 9 | int index; 10 | int style; 11 | int height; 12 | int ascent; 13 | char* familyname; 14 | char* stylename; 15 | }; 16 | 17 | typedef struct FTface FTface; 18 | struct FTface { 19 | void* ft_lib; 20 | void* ft_face; 21 | }; 22 | 23 | typedef struct FTglyph FTglyph; 24 | struct FTglyph { 25 | int top; 26 | int left; 27 | int advx; 28 | int advy; 29 | int height; 30 | int width; 31 | int bpr; 32 | uchar* bitmap; 33 | }; 34 | 35 | typedef struct FTmatrix FTmatrix; 36 | struct FTmatrix { 37 | int a; 38 | int b; 39 | int c; 40 | int d; 41 | }; 42 | 43 | typedef struct FTvector FTvector; 44 | struct FTvector { 45 | int dx; 46 | int dy; 47 | }; 48 | 49 | extern char* ftnewface(char *, int, FTface*, FTfaceinfo*); 50 | extern char* ftloadmemface(void*, int, int, FTface*, FTfaceinfo*); 51 | extern char* ftsetcharsize(FTface, int, int, int, FTfaceinfo*); 52 | extern void ftsettransform(FTface, FTmatrix*, FTvector*); 53 | extern int fthaschar(FTface,int); 54 | extern char* ftloadglyph(FTface, int, FTglyph*); 55 | extern void ftdoneface(FTface); 56 | -------------------------------------------------------------------------------- /src/styx/include/freetype/config/ftmodule.h: -------------------------------------------------------------------------------- 1 | FT_USE_MODULE(autohint_module_class) 2 | FT_USE_MODULE(cff_driver_class) 3 | /*FT_USE_MODULE(t1cid_driver_class)*/ 4 | /*FT_USE_MODULE(pcf_driver_class)*/ 5 | /*FT_USE_MODULE(bdf_driver_class)*/ 6 | FT_USE_MODULE(psaux_module_class) 7 | FT_USE_MODULE(psnames_module_class) 8 | FT_USE_MODULE(pshinter_module_class) 9 | FT_USE_MODULE(ft_raster1_renderer_class) 10 | FT_USE_MODULE(sfnt_module_class) 11 | FT_USE_MODULE(ft_smooth_renderer_class) 12 | FT_USE_MODULE(ft_smooth_lcd_renderer_class) 13 | FT_USE_MODULE(ft_smooth_lcdv_renderer_class) 14 | FT_USE_MODULE(tt_driver_class) 15 | FT_USE_MODULE(t1_driver_class) 16 | FT_USE_MODULE(t42_driver_class) 17 | FT_USE_MODULE(pfr_driver_class) 18 | /*FT_USE_MODULE(winfnt_driver_class)*/ 19 | 20 | -------------------------------------------------------------------------------- /src/styx/include/freetype/config/ftmodule.h.orig: -------------------------------------------------------------------------------- 1 | FT_USE_MODULE(autohint_module_class) 2 | FT_USE_MODULE(cff_driver_class) 3 | FT_USE_MODULE(t1cid_driver_class) 4 | FT_USE_MODULE(pcf_driver_class) 5 | FT_USE_MODULE(bdf_driver_class) 6 | FT_USE_MODULE(psaux_module_class) 7 | FT_USE_MODULE(psnames_module_class) 8 | FT_USE_MODULE(pshinter_module_class) 9 | FT_USE_MODULE(ft_raster1_renderer_class) 10 | FT_USE_MODULE(sfnt_module_class) 11 | FT_USE_MODULE(ft_smooth_renderer_class) 12 | FT_USE_MODULE(ft_smooth_lcd_renderer_class) 13 | FT_USE_MODULE(ft_smooth_lcdv_renderer_class) 14 | FT_USE_MODULE(tt_driver_class) 15 | FT_USE_MODULE(t1_driver_class) 16 | FT_USE_MODULE(t42_driver_class) 17 | FT_USE_MODULE(pfr_driver_class) 18 | FT_USE_MODULE(winfnt_driver_class) 19 | 20 | -------------------------------------------------------------------------------- /src/styx/include/logfsos.h: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | -------------------------------------------------------------------------------- /src/styx/include/nandecc.h: -------------------------------------------------------------------------------- 1 | #pragma src "/usr/inferno/libnandfs" 2 | 3 | typedef enum NandEccError { 4 | NandEccErrorBad, 5 | NandEccErrorGood, 6 | NandEccErrorOneBit, 7 | NandEccErrorOneBitInEcc, 8 | } NandEccError; 9 | 10 | ulong nandecc(uchar buf[256]); 11 | NandEccError nandecccorrect(uchar buf[256], ulong calcecc, ulong *storedecc, int reportbad); 12 | 13 | -------------------------------------------------------------------------------- /src/styx/include/pooldefs.h: -------------------------------------------------------------------------------- 1 | #define left u.s.bhl 2 | #define right u.s.bhr 3 | #define fwd u.s.bhf 4 | #define prev u.s.bhv 5 | #define parent u.s.bhp 6 | -------------------------------------------------------------------------------- /src/styx/include/raise.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Exceptions thrown by the interpreter 3 | */ 4 | extern char exAlt[]; /* alt send/recv on same chan */ 5 | extern char exBusy[]; /* channel busy */ 6 | extern char exModule[]; /* module not loaded */ 7 | extern char exCompile[]; /* compile failed */ 8 | extern char exCrange[]; /* constant range */ 9 | extern char exCctovflw[]; /* constant table overflow */ 10 | extern char exCphase[]; /* compiler phase error */ 11 | extern char exType[]; /* type not constructed correctly */ 12 | extern char exZdiv[]; /* zero divide */ 13 | extern char exHeap[]; /* out of memory: heap */ 14 | extern char exImage[]; /* out of memory: image */ 15 | extern char exItype[]; /* inconsistent type */ 16 | extern char exMathia[]; /* invalid math argument */ 17 | extern char exBounds[]; /* array bounds error */ 18 | extern char exNegsize[]; /* negative array size */ 19 | extern char exNomem[]; /* out of memory: main */ 20 | extern char exSpawn[]; /* spawn a builtin module */ 21 | extern char exOp[]; /* illegal dis instruction */ 22 | extern char exTcheck[]; /* type check */ 23 | extern char exInval[]; /* invalid argument */ 24 | extern char exNilref[]; /* dereference of nil */ 25 | extern char exRange[]; /* value out of range */ 26 | extern char exLoadedmod[]; /* need newmod */ 27 | -------------------------------------------------------------------------------- /src/styx/include/rdbg.h: -------------------------------------------------------------------------------- 1 | /* Remote kernel debug protocol */ 2 | enum 3 | { 4 | Terr='0', /* not sent */ 5 | Rerr, 6 | Tmget, 7 | Rmget, 8 | Tmput, 9 | Rmput, 10 | 11 | Tspid, /* obsolete */ 12 | Rspid, /* obsolete */ 13 | Tproc, 14 | Rproc, 15 | Tstatus, 16 | Rstatus, 17 | Trnote, 18 | Rrnote, 19 | 20 | Tstartstop, 21 | Rstartstop, 22 | Twaitstop, 23 | Rwaitstop, 24 | Tstart, 25 | Rstart, 26 | Tstop, 27 | Rstop, 28 | Tkill, 29 | Rkill, 30 | 31 | Tcondbreak, 32 | Rcondbreak, 33 | 34 | RDBMSGLEN = 10 /* tag byte, 9 data bytes */ 35 | }; 36 | -------------------------------------------------------------------------------- /src/styx/include/trace.h: -------------------------------------------------------------------------------- 1 | typedef enum Tevent { 2 | SAdmit = 0, /* Edf admit */ 3 | SRelease, /* Edf release, waiting to be scheduled */ 4 | SEdf, /* running under EDF */ 5 | SRun, /* running best effort */ 6 | SReady, /* runnable but not running */ 7 | SSleep, /* blocked */ 8 | SYield, /* blocked waiting for release */ 9 | SSlice, /* slice exhausted */ 10 | SDeadline, /* proc's deadline */ 11 | SExpel, /* Edf expel */ 12 | SDead, /* proc dies */ 13 | SInts, /* Interrupt start */ 14 | SInte, /* Interrupt end */ 15 | SUser, /* user event */ 16 | Nevent, 17 | } Tevent; 18 | 19 | typedef struct Traceevent Traceevent; 20 | struct Traceevent { 21 | ulong pid; 22 | ulong etype; /* Event type */ 23 | vlong time; /* time stamp */ 24 | }; 25 | -------------------------------------------------------------------------------- /src/styx/include/version.h: -------------------------------------------------------------------------------- 1 | #define VERSION "First Edition (20150610)" 2 | -------------------------------------------------------------------------------- /src/styx/include/vm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * All the virtual machine interfaces 3 | */ 4 | #include "/usr/inferno/include/interp.h" 5 | #include "/usr/inferno/include/isa.h" 6 | #include "/usr/inferno/libinterp/runt.h" 7 | 8 | int srvf2c(char*, char*, int, Sys_FileIO*); 9 | -------------------------------------------------------------------------------- /src/styx/libs/include/os.h: -------------------------------------------------------------------------------- 1 | #include 2 | extern ulong truerand(void); 3 | extern vlong nsec(void); 4 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/argv0.c: -------------------------------------------------------------------------------- 1 | char* argv0 = 0; 2 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/cistrcmp.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | int 4 | cistrcmp(char *s1, char *s2) 5 | { 6 | int c1, c2; 7 | 8 | while(*s1){ 9 | c1 = *(uchar*)s1++; 10 | c2 = *(uchar*)s2++; 11 | 12 | if(c1 == c2) 13 | continue; 14 | 15 | if(c1 >= 'A' && c1 <= 'Z') 16 | c1 -= 'A' - 'a'; 17 | 18 | if(c2 >= 'A' && c2 <= 'Z') 19 | c2 -= 'A' - 'a'; 20 | 21 | if(c1 != c2) 22 | return c1 - c2; 23 | } 24 | return -*s2; 25 | } 26 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/cistrncmp.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | int 4 | cistrncmp(char *s1, char *s2, int n) 5 | { 6 | int c1, c2; 7 | 8 | while(*s1 && n-- > 0){ 9 | c1 = *(uchar*)s1++; 10 | c2 = *(uchar*)s2++; 11 | 12 | if(c1 == c2) 13 | continue; 14 | 15 | if(c1 >= 'A' && c1 <= 'Z') 16 | c1 -= 'A' - 'a'; 17 | 18 | if(c2 >= 'A' && c2 <= 'Z') 19 | c2 -= 'A' - 'a'; 20 | 21 | if(c1 != c2) 22 | return c1 - c2; 23 | } 24 | if(n <= 0) 25 | return 0; 26 | return -*s2; 27 | } 28 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/cistrstr.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | char* 4 | cistrstr(char *s, char *sub) 5 | { 6 | int c, csub, n; 7 | 8 | csub = *sub; 9 | if(csub == '\0') 10 | return s; 11 | if(csub >= 'A' && csub <= 'Z') 12 | csub -= 'A' - 'a'; 13 | sub++; 14 | n = strlen(sub); 15 | for(; c = *s; s++){ 16 | if(c >= 'A' && c <= 'Z') 17 | c -= 'A' - 'a'; 18 | if(c == csub && cistrncmp(s+1, sub, n) == 0) 19 | return s; 20 | } 21 | return nil; 22 | } 23 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/create.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | #include 4 | 5 | int 6 | create(char *f, int mode, int perm) 7 | { 8 | int m; 9 | 10 | m = 0; 11 | switch(mode & 3){ 12 | case OREAD: 13 | case OEXEC: 14 | m = O_RDONLY; 15 | break; 16 | case OWRITE: 17 | m = O_WRONLY; 18 | break; 19 | case ORDWR: 20 | m = O_RDWR; 21 | break; 22 | } 23 | m |= O_CREAT|O_TRUNC; 24 | 25 | if(perm & DMDIR){ 26 | if(mkdir(f, perm&0777) < 0) 27 | return -1; 28 | perm &= ~DMDIR; 29 | m &= 3; 30 | } 31 | return open(f, m, perm); 32 | } 33 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/dirwstat.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | #include 4 | 5 | int 6 | dirfwstat(int fd, Dir *d) 7 | { 8 | return -1; 9 | } 10 | 11 | int 12 | dirwstat(char *name, Dir *d) 13 | { 14 | return -1; 15 | } 16 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/errfmt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | #include "fmtdef.h" 16 | 17 | int 18 | errfmt(Fmt *f) 19 | { 20 | char buf[ERRMAX]; 21 | 22 | rerrstr(buf, sizeof buf); 23 | return _fmtcpy(f, buf, utflen(buf), strlen(buf)); 24 | } 25 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/errstr-Nt.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | static char errstring[ERRMAX]; 5 | 6 | enum 7 | { 8 | Magic = 0xffffff 9 | }; 10 | 11 | static void 12 | winerror(int e, char *buf, uint nerr) 13 | { 14 | int r; 15 | char buf2[ERRMAX], *p, *q; 16 | 17 | r = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 18 | 0, e, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 19 | buf2, sizeof(buf2), 0); 20 | 21 | if(r == 0) 22 | snprint(buf2, ERRMAX, "windows error %d", e); 23 | 24 | q = buf2; 25 | for(p = buf2; *p; p++) { 26 | if(*p == '\r') 27 | continue; 28 | if(*p == '\n') 29 | *q++ = ' '; 30 | else 31 | *q++ = *p; 32 | } 33 | *q = '\0'; 34 | utfecpy(buf, buf+nerr, buf2); 35 | } 36 | 37 | void 38 | werrstr(char *fmt, ...) 39 | { 40 | va_list arg; 41 | 42 | va_start(arg, fmt); 43 | vseprint(errstring, errstring+sizeof(errstring), fmt, arg); 44 | va_end(arg); 45 | SetLastError(Magic); 46 | } 47 | 48 | int 49 | errstr(char *buf, uint nerr) 50 | { 51 | DWORD le; 52 | 53 | le = GetLastError(); 54 | if(le == Magic) 55 | utfecpy(buf, buf+nerr, errstring); 56 | else 57 | winerror(le, buf, nerr); 58 | return 1; 59 | } 60 | 61 | void 62 | oserrstr(char *buf, uint nerr) 63 | { 64 | winerror(GetLastError(), buf, nerr); 65 | } 66 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/errstr-Plan9.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | void 4 | oserrstr(char *buf, uint nerr) 5 | { 6 | *buf = 0; 7 | errstr(buf, nerr); 8 | } 9 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/errstr-posix.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | #include 4 | 5 | static char errstring[ERRMAX]; 6 | 7 | enum 8 | { 9 | Magic = 0xffffff 10 | }; 11 | 12 | void 13 | werrstr(char *fmt, ...) 14 | { 15 | va_list arg; 16 | 17 | va_start(arg, fmt); 18 | vseprint(errstring, errstring+sizeof(errstring), fmt, arg); 19 | va_end(arg); 20 | errno = Magic; 21 | } 22 | 23 | void 24 | oserrstr(char *buf, uint nerr) 25 | { 26 | char *s; 27 | 28 | if(errno != EINTR) 29 | s = strerror(errno); 30 | else 31 | s = "interrupted"; 32 | utfecpy(buf, buf+nerr, s); 33 | } 34 | 35 | int 36 | errstr(char *buf, uint nerr) 37 | { 38 | if(errno == Magic) 39 | utfecpy(buf, buf+nerr, errstring); 40 | else 41 | oserrstr(buf, nerr); 42 | return 1; 43 | } 44 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/exits.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | void 4 | exits(char *s) 5 | { 6 | if(s == 0 || *s == 0) 7 | exit(0); 8 | exit(1); 9 | } 10 | 11 | void 12 | _exits(char *s) 13 | { 14 | if(s == 0 || *s == 0) 15 | _exit(0); 16 | _exit(1); 17 | } 18 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/fmtlock.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | 16 | void 17 | _fmtlock(void) 18 | { 19 | } 20 | 21 | void 22 | _fmtunlock(void) 23 | { 24 | } 25 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/fmtrune.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | #include "fmtdef.h" 16 | 17 | int 18 | fmtrune(Fmt *f, int r) 19 | { 20 | Rune *rt; 21 | char *t; 22 | int n; 23 | 24 | if(f->runes){ 25 | rt = f->to; 26 | FMTRCHAR(f, rt, f->stop, r); 27 | f->to = rt; 28 | n = 1; 29 | }else{ 30 | t = f->to; 31 | FMTRUNE(f, t, f->stop, r); 32 | n = t - (char*)f->to; 33 | f->to = t; 34 | } 35 | f->nfmt += n; 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/fmtstr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | 16 | char* 17 | fmtstrflush(Fmt *f) 18 | { 19 | if(f->start == nil) 20 | return nil; 21 | *(char*)f->to = '\0'; 22 | return f->start; 23 | } 24 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/fprint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | 16 | int 17 | fprint(int fd, char *fmt, ...) 18 | { 19 | int n; 20 | va_list args; 21 | 22 | va_start(args, fmt); 23 | n = vfprint(fd, fmt, args); 24 | va_end(args); 25 | return n; 26 | } 27 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getcallerpc-DragonFly-386.S: -------------------------------------------------------------------------------- 1 | .file "getcallerpc-DragonFly-386.S" 2 | 3 | .type getcallerpc,@function 4 | .global getcallerpc 5 | getcallerpc: 6 | movl 4(%esp), %eax 7 | movl -4(%eax), %eax 8 | ret 9 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getcallerpc-FreeBSD-386.S: -------------------------------------------------------------------------------- 1 | .file "getcallerpc-FreeBSD-386.S" 2 | 3 | .type getcallerpc,@function 4 | .global getcallerpc 5 | getcallerpc: 6 | movl 4(%esp), %eax 7 | movl -4(%eax), %eax 8 | ret 9 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getcallerpc-Hp-s800.s: -------------------------------------------------------------------------------- 1 | .LEVEL 1.1 2 | 3 | .SPACE $TEXT$,SORT=8 4 | .SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=0x2c,CODE_ONLY,SORT=24 5 | getcallerpc 6 | .PROC 7 | .CALLINFO FRAME=0,ARGS_SAVED 8 | .ENTRY 9 | LDI 0,%r28 10 | .EXIT 11 | BV,N %r0(%r2) 12 | .PROCEND 13 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getcallerpc-Irix-mips.s: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | LEAF(getcallerpc) 5 | .set noreorder 6 | lw v0, 28(sp) 7 | j ra 8 | .set reorder 9 | END(getcallerpc) 10 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getcallerpc-Linux-386.S: -------------------------------------------------------------------------------- 1 | .file "getcallerpc-Linux-386.S" 2 | .type getcallerpc,@function 3 | .global getcallerpc 4 | getcallerpc: 5 | movl 4(%esp), %eax 6 | movl -4(%eax), %eax 7 | ret 8 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getcallerpc-Linux-arm.S: -------------------------------------------------------------------------------- 1 | /* getcallerpc for arm Linux is placed in lib9.h as inline function*/ 2 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getcallerpc-Linux-power.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | ulong 4 | getcallerpc(void *x) 5 | { 6 | ulong *lp; 7 | 8 | lp = x; 9 | 10 | return lp[-1]; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getcallerpc-Linux-spim.S: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | LEAF(getcallerpc) 5 | .set noreorder 6 | addiu t0,a0,-4 7 | j ra 8 | lw v0,0(t0) 9 | .set reorder 10 | END(getcallerpc) 11 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getcallerpc-MacOSX-386.s: -------------------------------------------------------------------------------- 1 | .file "getcallerpc-MacOSX-386.s" 2 | .text 3 | .globl _getcallerpc 4 | _getcallerpc: 5 | movl 4(%esp), %eax 6 | movl -4(%eax), %eax 7 | ret 8 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getcallerpc-MacOSX-power.s: -------------------------------------------------------------------------------- 1 | /* 2 | File: getcallerpc-Darwin-power.s 3 | 4 | getcallerpc() is passed a pointer 5 | 6 | Plan 9 asm: 7 | 8 | TEXT getcallerpc(SB), $-4 9 | MOVW 0(R1), R3 10 | RETURN 11 | 12 | */ 13 | 14 | #import 15 | 16 | .text 17 | LABEL(_getcallerpc) 18 | mflr r3 19 | blr 20 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getcallerpc-NetBSD-386.S: -------------------------------------------------------------------------------- 1 | .file "getcallerpc-NetBSD-386.S" 2 | 3 | .type getcallerpc,@function 4 | .global getcallerpc 5 | getcallerpc: 6 | movl 4(%esp), %eax 7 | movl -4(%eax), %eax 8 | ret 9 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getcallerpc-OpenBSD-386.S: -------------------------------------------------------------------------------- 1 | .file "getcallerpc-OpenBSD-386.S" 2 | 3 | .type getcallerpc,@function 4 | .global getcallerpc 5 | getcallerpc: 6 | movl 4(%esp), %eax 7 | movl -4(%eax), %eax 8 | ret 9 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getcallerpc-Solaris-386.s: -------------------------------------------------------------------------------- 1 | .align 4 2 | .globl getcallerpc 3 | getcallerpc: 4 | movl 4(%esp), %eax 5 | movl -4(%eax), %eax 6 | ret 7 | .align 4 8 | .type getcallerpc,@function 9 | .size getcallerpc,.-getcallerpc 10 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getcallerpc-Solaris-sparc.s: -------------------------------------------------------------------------------- 1 | .section ".text", #alloc, #execinstr 2 | .align 8 3 | .skip 16 4 | .global getcallerpc 5 | .type getcallerpc, #function 6 | getcallerpc: ! ignore argument 7 | retl 8 | add %i7,0,%o0 9 | 10 | .size getcallerpc,(.-getcallerpc) 11 | 12 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getcallerpc-Unixware-386.s: -------------------------------------------------------------------------------- 1 | .align 4 2 | .globl getcallerpc 3 | getcallerpc: 4 | movl 4(%esp), %eax 5 | movl -4(%eax), %eax 6 | ret 7 | .align 4 8 | .type getcallerpc,@function 9 | .size getcallerpc,.-getcallerpc 10 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getfields.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | int 3 | getfields(char *str, char **args, int max, int mflag, char *set) 4 | { 5 | Rune r; 6 | int nr, intok, narg; 7 | 8 | if(max <= 0) 9 | return 0; 10 | 11 | narg = 0; 12 | args[narg] = str; 13 | if(!mflag) 14 | narg++; 15 | intok = 0; 16 | for(;; str += nr) { 17 | nr = chartorune(&r, str); 18 | if(r == 0) 19 | break; 20 | if(utfrune(set, r)) { 21 | if(narg >= max) 22 | break; 23 | *str = 0; 24 | intok = 0; 25 | args[narg] = str + nr; 26 | if(!mflag) 27 | narg++; 28 | } else { 29 | if(!intok && mflag) 30 | narg++; 31 | intok = 1; 32 | } 33 | } 34 | return narg; 35 | } 36 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getuser-Nt.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | char* 4 | getuser(void) 5 | { 6 | /* could do better, but result isn't really used */ 7 | return "unknown"; 8 | } 9 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getuser-posix.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | char* 5 | getuser(void) 6 | { 7 | struct passwd *p; 8 | 9 | static char *user = 0; 10 | 11 | if (!user) { 12 | p = getpwuid(getuid()); 13 | if (p && p->pw_name) { 14 | user = malloc(strlen(p->pw_name)+1); 15 | if (user) 16 | strcpy(user, p->pw_name); 17 | } 18 | } 19 | if(!user) 20 | user = "unknown"; 21 | return user; 22 | } 23 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getwd-Nt.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | 5 | char* 6 | getwd(char *buf, int size) 7 | { 8 | int n; 9 | char *p; 10 | 11 | buf[0] = 0; 12 | 13 | n = GetCurrentDirectory(size, buf); 14 | if(n == 0) { 15 | /*winerror();*/ 16 | return 0; 17 | } 18 | 19 | for(p=buf; *p; p++) 20 | if(*p == '\\') 21 | *p = '/'; 22 | 23 | return buf; 24 | } 25 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/getwd-posix.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #undef getwd 3 | #include 4 | 5 | char * 6 | infgetwd(char *buf, int size) 7 | { 8 | return getcwd(buf, size); 9 | } 10 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/isnan-posix.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int 4 | isNaN(double d) 5 | { 6 | return isnan(d); 7 | } 8 | 9 | int 10 | isInf(double d, int sign) 11 | { 12 | if(sign < 0) 13 | return isinf(d) < 0; 14 | return isinf(d); 15 | } 16 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/lock-Hp-s800.s: -------------------------------------------------------------------------------- 1 | ; 2 | ; /* 3 | ; * To get lock routine, compile this into a .s, then SUBSTITUTE 4 | ; * a LOAD AND CLEAR WORD instruction for the load and store of 5 | ; * l->key. 6 | ; * 7 | ; */ 8 | ; typedef struct Lock { 9 | ; int key; 10 | ; } Lock; 11 | ; 12 | ; int 13 | ; mutexlock(Lock *l) 14 | ; { 15 | ; int key; 16 | ; 17 | ; key = l->key; 18 | ; l->key = 0; 19 | ; return key != 0; 20 | ; } 21 | 22 | .LEVEL 1.1 23 | 24 | .SPACE $TEXT$,SORT=8 25 | .SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=0x2c,CODE_ONLY,SORT=24 26 | mutexlock 27 | .PROC 28 | .CALLINFO FRAME=0,ARGS_SAVED 29 | .ENTRY 30 | ; SUBSTITUTED LDW 0(%r26),%r31 31 | ; SUBSTITUTED STWS %r0,0(%r26) 32 | LDCWS 0(%r26),%r31 ; SUBSTITUTED 33 | COMICLR,= 0,%r31,%r28 34 | LDI 1,%r28 35 | .EXIT 36 | BV,N %r0(%r2) 37 | .PROCEND 38 | .end 39 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/lock-Irix-mips.s: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* 5 | * lock from r4000 book 6 | */ 7 | LEAF(canlock) 8 | .set noreorder 9 | 1: 10 | ll t0,0(a0) /* a0 is argument */ 11 | or t1, t0, 1 12 | sc t1,0(a0) 13 | beq t1,zero,1b 14 | nop 15 | j $31 /* lock held */ 16 | xor v0, t0, 1 17 | 18 | .set reorder 19 | END(canlock) 20 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/lock-MacOSX-power.s: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | LEAF(__tas) 4 | sync 5 | mr r4,r3 6 | addi r5,0,0x1 7 | 1: 8 | lwarx r3,0,r4 9 | cmpwi r3,0x0 10 | bne- 2f 11 | stwcx. r5,0,r4 12 | bne- 1b /* Lost reservation, try again */ 13 | 2: 14 | sync 15 | blr 16 | END(__tas) 17 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/lock-Nt-386.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | int 4 | _tas(int *la) 5 | { 6 | int v; 7 | 8 | _asm { 9 | mov eax, la 10 | mov ebx, 1 11 | xchg ebx, [eax] 12 | mov v, ebx 13 | } 14 | return v; 15 | } 16 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/lock-Solaris-386.s: -------------------------------------------------------------------------------- 1 | .section .bss 2 | .align 4 3 | .L4_.bss: 4 | .align 4 5 | Solaris_Asm_IntP: / Offset 0 6 | .type Solaris_Asm_IntP,@object 7 | .size Solaris_Asm_IntP,4 8 | .set .,.+4 9 | Solaris_Asm_VoidP: / Offset 4 10 | .type Solaris_Asm_VoidP,@object 11 | .size Solaris_Asm_VoidP,4 12 | .set .,.+4 13 | .section .data 14 | .align 4 15 | .L2_.data: 16 | .align 4 17 | .L01: .string "canlock corrupted 0x%lux\n\000" 18 | .set .,.+0x2 19 | .section .text 20 | .align 4 21 | .L1_.text: 22 | 23 | .align 4 24 | .align 4 25 | .globl canlock 26 | canlock: 27 | pushl %ebp 28 | movl %esp,%ebp 29 | pushl %esi 30 | movl 8(%ebp),%eax 31 | movl %eax,Solaris_Asm_IntP 32 | movl $1, %ecx 33 | xchg (%eax), %ecx 34 | andl %ecx,%ecx 35 | jne .L1 36 | movl $1,%esi 37 | jmp .L2 38 | .align 4 39 | .L3: 40 | subl %esi,%esi 41 | jmp .L2 42 | .align 4 43 | .L1: 44 | cmpl $1,%ecx 45 | je .L3 46 | pushl %ecx 47 | pushl $.L01 48 | call print 49 | addl $8,%esp 50 | .L2: 51 | movl %esi,%eax 52 | popl %esi 53 | leave 54 | ret 55 | .type canlock,@function 56 | .size canlock,.-canlock 57 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/lock-Solaris-sparc.s: -------------------------------------------------------------------------------- 1 | 2 | .section ".text", #alloc, #execinstr 3 | .align 8 4 | .skip 16 5 | .global canlock 6 | .type canlock,#function 7 | 8 | canlock: 9 | or %g0,1,%o1 10 | swap [%o0],%o1 ! o0 points to lock; key is first word 11 | cmp %o1,1 12 | bne .gotit 13 | nop 14 | retl ! key was 1 15 | or %g0,0,%o0 16 | .gotit: 17 | retl ! key was not 1 18 | or %g0,1,%o0 19 | 20 | .size canlock,(.-canlock) 21 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/lock-Unixware-386.s: -------------------------------------------------------------------------------- 1 | .section .bss 2 | .align 4 3 | .L4_.bss: 4 | .align 4 5 | Unixware_Asm_IntP: / Offset 0 6 | .type Unixware_Asm_IntP,@object 7 | .size Unixware_Asm_IntP,4 8 | .set .,.+4 9 | Unixware_Asm_VoidP: / Offset 4 10 | .type Unixware_Asm_VoidP,@object 11 | .size Unixware_Asm_VoidP,4 12 | .set .,.+4 13 | .section .data 14 | .align 4 15 | .L2_.data: 16 | .align 4 17 | .L01: .string "canlock corrupted 0x%lux\n\000" 18 | .set .,.+0x2 19 | .section .text 20 | .align 4 21 | .L1_.text: 22 | 23 | .align 4 24 | .align 4 25 | .globl canlock 26 | canlock: 27 | pushl %ebp 28 | movl %esp,%ebp 29 | pushl %esi 30 | movl 8(%ebp),%eax 31 | movl %eax,Unixware_Asm_IntP 32 | movl $1, %ecx 33 | xchg (%eax), %ecx 34 | andl %ecx,%ecx 35 | jne .L1 36 | movl $1,%esi 37 | jmp .L2 38 | .align 4 39 | .L3: 40 | subl %esi,%esi 41 | jmp .L2 42 | .align 4 43 | .L1: 44 | cmpl $1,%ecx 45 | je .L3 46 | pushl %ecx 47 | pushl $.L01 48 | call print 49 | addl $8,%esp 50 | .L2: 51 | movl %esi,%eax 52 | popl %esi 53 | leave 54 | ret 55 | .type canlock,@function 56 | .size canlock,.-canlock 57 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/mkfile-Nt: -------------------------------------------------------------------------------- 1 | TARGFILES=\ 2 | $IMPORTFILES\ 3 | dirstat-Nt.$O\ 4 | errstr-Nt.$O\ 5 | getuser-Nt.$O\ 6 | getwd-Nt.$O\ 7 | setbinmode-Nt.$O\ 8 | lock-Nt-386.$O\ 9 | pread-Nt.$O\ 10 | isnan-posix.$O\ 11 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/mkfile-Plan9: -------------------------------------------------------------------------------- 1 | TARGFILES=errstr-Plan9.$O\ 2 | 3 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/mkfile-Posix: -------------------------------------------------------------------------------- 1 | TARGFILES=\ 2 | $IMPORTFILES\ 3 | dirstat-posix.$O\ 4 | errstr-posix.$O\ 5 | getuser-posix.$O\ 6 | getcallerpc-$SYSTARG-$OBJTYPE.$O\ 7 | getwd-posix.$O\ 8 | sbrk-posix.$O\ 9 | isnan-posix.$O\ 10 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/nulldir.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | void 4 | nulldir(Dir *d) 5 | { 6 | memset(d, ~0, sizeof(Dir)); 7 | d->name = d->uid = d->gid = d->muid = ""; 8 | } 9 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/pread-Nt.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | long 4 | pread(int fd, void *buf, long n, vlong offset) 5 | { 6 | if(seek(fd, offset, 0) < 0) 7 | return -1; 8 | return read(fd, buf, n); 9 | } 10 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/premake5.lua: -------------------------------------------------------------------------------- 1 | 2 | project "lib9" 3 | -- is this kind of app 4 | kind "StaticLib" 5 | targetname "9" 6 | buildoptions {"-fPIC"} 7 | -- is dependent on these files 8 | files {"convD2M.c", "convM2D.c", "convM2S.c", "convS2M.c", "fcallfmt.c", "runestrchr.c", "runestrlen.c", "runetype.c", "strtoll.c", "strtoull.c", 9 | "rune.c", "argv0.c", "charstod.c", "cistrcmp.c", "cistrncmp.c", "cistrstr.c", "cleanname.c", "create.c", "dirwstat.c", "dofmt.c", "dorfmt.c", 10 | "errfmt.c", "exits.c", "fmt.c", "fmtfd.c", "fmtlock.c", "fmtprint.c", "fmtquote.c", "fmtrune.c", "fmtstr.c", "fmtvprint.c", "fprint.c", 11 | "getfields.c", "nulldir.c", "pow10.c", "print.c", "qsort.c", "readn.c", "rerrstr.c", "runeseprint.c", "runesmprint.c", "runesnprint.c", 12 | "runevseprint.c", "seek.c", "seprint.c", "smprint.c", "snprint.c", "sprint.c", "strdup.c", "strecpy.c", "sysfatal.c", "tokenize.c", "u16.c", 13 | "u32.c", "u64.c", "utflen.c", "utfnlen.c", "utfrrune.c", "utfrune.c", "utfecpy.c", "vfprint.c", "vseprint.c", "vsmprint.c", "vsnprint.c", 14 | "dirstat-posix.c", "errstr-posix.c", "getuser-posix.c", "getwd-posix.c", "sbrk-posix.c", "isnan-posix.c" } 15 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/print.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | 16 | int 17 | print(char *fmt, ...) 18 | { 19 | int n; 20 | va_list args; 21 | 22 | va_start(args, fmt); 23 | n = vfprint(1, fmt, args); 24 | va_end(args); 25 | return n; 26 | } 27 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/readn.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | long 4 | readn(int f, void *av, long n) 5 | { 6 | char *a; 7 | long m, t; 8 | 9 | a = av; 10 | t = 0; 11 | while(t < n){ 12 | m = read(f, a+t, n-t); 13 | if(m <= 0){ 14 | if(t == 0) 15 | return m; 16 | break; 17 | } 18 | t += m; 19 | } 20 | return t; 21 | } 22 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/rerrstr.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | void 4 | rerrstr(char *buf, uint nbuf) 5 | { 6 | char tmp[ERRMAX]; 7 | 8 | tmp[0] = 0; 9 | errstr(tmp, sizeof tmp); 10 | utfecpy(buf, buf+nbuf, tmp); 11 | errstr(tmp, sizeof tmp); 12 | } 13 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/runeseprint.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | Rune* 4 | runeseprint(Rune *buf, Rune *e, char *fmt, ...) 5 | { 6 | Rune *p; 7 | va_list args; 8 | 9 | va_start(args, fmt); 10 | p = runevseprint(buf, e, fmt, args); 11 | va_end(args); 12 | return p; 13 | } 14 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/runesmprint.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | Rune* 4 | runesmprint(char *fmt, ...) 5 | { 6 | va_list args; 7 | Rune *p; 8 | 9 | va_start(args, fmt); 10 | p = runevsmprint(fmt, args); 11 | va_end(args); 12 | return p; 13 | } 14 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/runesnprint.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | int 4 | runesnprint(Rune *buf, int len, char *fmt, ...) 5 | { 6 | int n; 7 | va_list args; 8 | 9 | va_start(args, fmt); 10 | n = runevsnprint(buf, len, fmt, args); 11 | va_end(args); 12 | return n; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/runestrchr.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | Rune* 4 | runestrchr(Rune *s, Rune c) 5 | { 6 | Rune c0 = c; 7 | Rune c1; 8 | 9 | if(c == 0) { 10 | while(*s++) 11 | ; 12 | return s-1; 13 | } 14 | 15 | while(c1 = *s++) 16 | if(c1 == c0) 17 | return s-1; 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/runestrlen.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | 4 | long 5 | runestrlen(Rune *s) 6 | { 7 | int i; 8 | 9 | i = 0; 10 | while(*s++) 11 | i++; 12 | return i; 13 | } 14 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/runetype.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | Rune*_runebsearch(Rune c, Rune *t, int n, int ne); 4 | 5 | #include "runetypebody-6.2.0.h" 6 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/runevseprint.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include "fmtdef.h" 3 | 4 | Rune* 5 | runevseprint(Rune *buf, Rune *e, char *fmt, va_list args) 6 | { 7 | Fmt f; 8 | 9 | if(e <= buf) 10 | return nil; 11 | f.runes = 1; 12 | f.start = buf; 13 | f.to = buf; 14 | f.stop = e - 1; 15 | f.flush = nil; 16 | f.farg = nil; 17 | f.nfmt = 0; 18 | va_copy(f.args, args); 19 | dofmt(&f, fmt); 20 | va_end(f.args); 21 | *(Rune*)f.to = '\0'; 22 | return f.to; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/sbrk-posix.c: -------------------------------------------------------------------------------- 1 | #ifdef __APPLE_CC__ /* look for a better way */ 2 | #include "lib9.h" 3 | #undef _POSIX_C_SOURCE 4 | #undef getwd 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include 26 | 27 | #include 28 | 29 | 30 | __typeof__(sbrk(0)) 31 | sbrk(int size) 32 | { 33 | void *brk; 34 | kern_return_t err; 35 | 36 | err = vm_allocate( (vm_map_t) mach_task_self(), 37 | (vm_address_t *)&brk, 38 | size, 39 | VM_FLAGS_ANYWHERE); 40 | if (err != KERN_SUCCESS) 41 | brk = (void*)-1; 42 | 43 | return brk; 44 | } 45 | #else 46 | /* dummy function for everyone else, in case its ar complains about empty files */ 47 | void __fakesbrk(void){} 48 | #endif 49 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/seek.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | #include 4 | 5 | vlong 6 | seek(int fd, vlong where, int from) 7 | { 8 | return lseek(fd, where, from); 9 | } 10 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/seprint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | 16 | char* 17 | seprint(char *buf, char *e, char *fmt, ...) 18 | { 19 | char *p; 20 | va_list args; 21 | 22 | va_start(args, fmt); 23 | p = vseprint(buf, e, fmt, args); 24 | va_end(args); 25 | return p; 26 | } 27 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/setbinmode-Nt.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | void 4 | setbinmode(void) 5 | { 6 | _setmode(0, _O_BINARY); 7 | _setmode(1, _O_BINARY); 8 | _setmode(2, _O_BINARY); 9 | } 10 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/smprint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | 16 | char* 17 | smprint(char *fmt, ...) 18 | { 19 | va_list args; 20 | char *p; 21 | 22 | va_start(args, fmt); 23 | p = vsmprint(fmt, args); 24 | va_end(args); 25 | return p; 26 | } 27 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/snprint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | 16 | int 17 | snprint(char *buf, int len, char *fmt, ...) 18 | { 19 | int n; 20 | va_list args; 21 | 22 | va_start(args, fmt); 23 | n = vsnprint(buf, len, fmt, args); 24 | va_end(args); 25 | return n; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/sprint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | 16 | int 17 | sprint(char *buf, char *fmt, ...) 18 | { 19 | int n; 20 | uint len; 21 | va_list args; 22 | 23 | len = 1<<30; /* big number, but sprint is deprecated anyway */ 24 | /* 25 | * the stack might be near the top of memory, so 26 | * we must be sure not to overflow a 32-bit pointer. 27 | */ 28 | if((uintptr)buf+len < (uintptr)buf) 29 | len = -(uint)buf-1; 30 | 31 | va_start(args, fmt); 32 | n = vsnprint(buf, len, fmt, args); 33 | va_end(args); 34 | return n; 35 | } 36 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/strdup.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | char* 4 | strdup(const char *s) 5 | { 6 | char *os; 7 | 8 | os = malloc(strlen(s) + 1); 9 | if(os == 0) 10 | return 0; 11 | return strcpy(os, s); 12 | } 13 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/strecpy.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | char* 4 | strecpy(char *to, char *e, char *from) 5 | { 6 | if(to >= e) 7 | return to; 8 | to = memccpy(to, from, '\0', e - to); 9 | if(to == nil){ 10 | to = e - 1; 11 | *to = '\0'; 12 | }else{ 13 | to--; 14 | } 15 | return to; 16 | } 17 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/sysfatal.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | 4 | 5 | static void 6 | _sysfatalimpl(char *fmt, va_list arg) 7 | { 8 | char buf[1024]; 9 | 10 | vseprint(buf, buf+sizeof(buf), fmt, arg); 11 | if(argv0) 12 | fprint(2, "%s: %s\n", argv0, buf); 13 | else 14 | fprint(2, "%s\n", buf); 15 | exits(buf); 16 | } 17 | 18 | void (*_sysfatal)(char *fmt, va_list arg) = _sysfatalimpl; 19 | 20 | void 21 | sysfatal(char *fmt, ...) 22 | { 23 | va_list arg; 24 | 25 | va_start(arg, fmt); 26 | (*_sysfatal)(fmt, arg); 27 | va_end(arg); 28 | } 29 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/u16.c: -------------------------------------------------------------------------------- 1 | #include 2 | static char t16e[] = "0123456789ABCDEF"; 3 | 4 | int 5 | dec16(uchar *out, int lim, char *in, int n) 6 | { 7 | int c, w = 0, i = 0; 8 | uchar *start = out; 9 | uchar *eout = out + lim; 10 | 11 | while(n-- > 0){ 12 | c = *in++; 13 | if('0' <= c && c <= '9') 14 | c = c - '0'; 15 | else if('a' <= c && c <= 'z') 16 | c = c - 'a' + 10; 17 | else if('A' <= c && c <= 'Z') 18 | c = c - 'A' + 10; 19 | else 20 | continue; 21 | w = (w<<4) + c; 22 | i++; 23 | if(i == 2){ 24 | if(out + 1 > eout) 25 | goto exhausted; 26 | *out++ = w; 27 | w = 0; 28 | i = 0; 29 | } 30 | } 31 | exhausted: 32 | return out - start; 33 | } 34 | 35 | int 36 | enc16(char *out, int lim, uchar *in, int n) 37 | { 38 | uint c; 39 | char *eout = out + lim; 40 | char *start = out; 41 | 42 | while(n-- > 0){ 43 | c = *in++; 44 | if(out + 2 >= eout) 45 | goto exhausted; 46 | *out++ = t16e[c>>4]; 47 | *out++ = t16e[c&0xf]; 48 | } 49 | exhausted: 50 | *out = 0; 51 | return out - start; 52 | } 53 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/utfecpy.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | char* 4 | utfecpy(char *to, char *e, char *from) 5 | { 6 | char *end; 7 | 8 | if(to >= e) 9 | return to; 10 | end = memccpy(to, from, '\0', e - to); 11 | if(end == nil){ 12 | end = e; 13 | while(end>to && (*--end&0xC0)==0x80) 14 | ; 15 | *end = '\0'; 16 | }else{ 17 | end--; 18 | } 19 | return end; 20 | } 21 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/utflen.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | int 4 | utflen(char *s) 5 | { 6 | int c; 7 | long n; 8 | Rune rune; 9 | 10 | n = 0; 11 | for(;;) { 12 | c = *(uchar*)s; 13 | if(c < Runeself) { 14 | if(c == 0) 15 | return n; 16 | s++; 17 | } else 18 | s += chartorune(&rune, s); 19 | n++; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/utfnlen.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | int 4 | utfnlen(char *s, long m) 5 | { 6 | int c; 7 | long n; 8 | Rune rune; 9 | char *es; 10 | 11 | es = s + m; 12 | for(n = 0; s < es; n++) { 13 | c = *(uchar*)s; 14 | if(c < Runeself){ 15 | if(c == '\0') 16 | break; 17 | s++; 18 | continue; 19 | } 20 | if(!fullrune(s, es-s)) 21 | break; 22 | s += chartorune(&rune, s); 23 | } 24 | return n; 25 | } 26 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/utfrrune.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | char* 4 | utfrrune(char *s, long c) 5 | { 6 | long c1; 7 | Rune r; 8 | char *s1; 9 | 10 | if(c < Runesync) /* not part of utf sequence */ 11 | return strrchr(s, c); 12 | 13 | s1 = 0; 14 | for(;;) { 15 | c1 = *(uchar*)s; 16 | if(c1 < Runeself) { /* one byte rune */ 17 | if(c1 == 0) 18 | return s1; 19 | if(c1 == c) 20 | s1 = s; 21 | s++; 22 | continue; 23 | } 24 | c1 = chartorune(&r, s); 25 | if(r == c) 26 | s1 = s; 27 | s += c1; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/utfrune.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | 3 | char* 4 | utfrune(char *s, long c) 5 | { 6 | long c1; 7 | Rune r; 8 | int n; 9 | 10 | if(c < Runesync) /* not part of utf sequence */ 11 | return strchr(s, c); 12 | 13 | for(;;) { 14 | c1 = *(uchar*)s; 15 | if(c1 < Runeself) { /* one byte rune */ 16 | if(c1 == 0) 17 | return 0; 18 | if(c1 == c) 19 | return s; 20 | s++; 21 | continue; 22 | } 23 | n = chartorune(&r, s); 24 | if(r == c) 25 | return s; 26 | s += n; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/vseprint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | #include "fmtdef.h" 16 | 17 | char* 18 | vseprint(char *buf, char *e, char *fmt, va_list args) 19 | { 20 | Fmt f; 21 | 22 | if(e <= buf) 23 | return nil; 24 | f.runes = 0; 25 | f.start = buf; 26 | f.to = buf; 27 | f.stop = e - 1; 28 | f.flush = nil; 29 | f.farg = nil; 30 | f.nfmt = 0; 31 | va_copy(f.args, args); 32 | dofmt(&f, fmt); 33 | va_end(f.args); 34 | *(char*)f.to = '\0'; 35 | return f.to; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /src/styx/libs/lib9/vsnprint.c: -------------------------------------------------------------------------------- 1 | /* 2 | * The authors of this software are Rob Pike and Ken Thompson. 3 | * Copyright (c) 2002 by Lucent Technologies. 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose without fee is hereby granted, provided that this entire notice 6 | * is included in all copies of any software which is or includes a copy 7 | * or modification of this software and in all copies of the supporting 8 | * documentation for such software. 9 | * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED 10 | * WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY 11 | * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY 12 | * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. 13 | */ 14 | #include "lib9.h" 15 | #include "fmtdef.h" 16 | 17 | int 18 | vsnprint(char *buf, int len, char *fmt, va_list args) 19 | { 20 | Fmt f; 21 | 22 | if(len <= 0) 23 | return -1; 24 | f.runes = 0; 25 | f.start = buf; 26 | f.to = buf; 27 | f.stop = buf + len - 1; 28 | f.flush = nil; 29 | f.farg = nil; 30 | f.nfmt = 0; 31 | va_copy(f.args, args); 32 | dofmt(&f, fmt); 33 | va_end(f.args); 34 | *(char*)f.to = '\0'; 35 | return (char*)f.to - buf; 36 | } 37 | -------------------------------------------------------------------------------- /src/styx/libs/libbio/bbuffered.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | int 5 | Bbuffered(Biobuf *bp) 6 | { 7 | switch(bp->state) { 8 | case Bracteof: 9 | case Bractive: 10 | return -bp->icount; 11 | 12 | case Bwactive: 13 | return bp->bsize + bp->ocount; 14 | 15 | case Binactive: 16 | return 0; 17 | } 18 | fprint(2, "Bbuffered: unknown state %d\n", bp->state); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /src/styx/libs/libbio/bfildes.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | int 5 | Bfildes(Biobuf *bp) 6 | { 7 | 8 | return bp->fid; 9 | } 10 | -------------------------------------------------------------------------------- /src/styx/libs/libbio/bflush.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | int 5 | Bflush(Biobuf *bp) 6 | { 7 | int n, c; 8 | 9 | switch(bp->state) { 10 | case Bwactive: 11 | n = bp->bsize+bp->ocount; 12 | if(n == 0) 13 | return 0; 14 | c = write(bp->fid, bp->bbuf, n); 15 | if(n == c) { 16 | bp->offset += n; 17 | bp->ocount = -bp->bsize; 18 | return 0; 19 | } 20 | bp->state = Binactive; 21 | bp->ocount = 0; 22 | break; 23 | 24 | case Bracteof: 25 | bp->state = Bractive; 26 | 27 | case Bractive: 28 | bp->icount = 0; 29 | bp->gbuf = bp->ebuf; 30 | return 0; 31 | } 32 | return Beof; 33 | } 34 | -------------------------------------------------------------------------------- /src/styx/libs/libbio/bgetc.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | int 5 | Bgetc(Biobuf *bp) 6 | { 7 | int i; 8 | 9 | loop: 10 | i = bp->icount; 11 | if(i != 0) { 12 | bp->icount = i+1; 13 | return bp->ebuf[i]; 14 | } 15 | if(bp->state != Bractive) { 16 | if(bp->state == Bracteof) 17 | bp->state = Bractive; 18 | return Beof; 19 | } 20 | /* 21 | * get next buffer, try to keep Bungetsize 22 | * characters pre-catenated from the previous 23 | * buffer to allow that many ungets. 24 | */ 25 | memmove(bp->bbuf-Bungetsize, bp->ebuf-Bungetsize, Bungetsize); 26 | i = read(bp->fid, bp->bbuf, bp->bsize); 27 | bp->gbuf = bp->bbuf; 28 | if(i <= 0) { 29 | bp->state = Bracteof; 30 | if(i < 0) 31 | bp->state = Binactive; 32 | return Beof; 33 | } 34 | if(i < bp->bsize) { 35 | memmove(bp->ebuf-i-Bungetsize, bp->bbuf-Bungetsize, i+Bungetsize); 36 | bp->gbuf = bp->ebuf-i; 37 | } 38 | bp->icount = -i; 39 | bp->offset += i; 40 | goto loop; 41 | } 42 | 43 | int 44 | Bungetc(Biobuf *bp) 45 | { 46 | 47 | if(bp->state == Bracteof) 48 | bp->state = Bractive; 49 | if(bp->state != Bractive) 50 | return Beof; 51 | bp->icount--; 52 | return 1; 53 | } 54 | -------------------------------------------------------------------------------- /src/styx/libs/libbio/bgetd.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | struct bgetd 5 | { 6 | Biobuf* b; 7 | int eof; 8 | }; 9 | 10 | static int 11 | Bgetdf(void *vp) 12 | { 13 | int c; 14 | struct bgetd *bg = vp; 15 | 16 | c = Bgetc(bg->b); 17 | if(c == Beof) 18 | bg->eof = 1; 19 | return c; 20 | } 21 | 22 | int 23 | Bgetd(Biobuf *bp, double *dp) 24 | { 25 | double d; 26 | struct bgetd b; 27 | 28 | b.b = bp; 29 | b.eof = 0; 30 | d = charstod(Bgetdf, &b); 31 | if(b.eof) 32 | return -1; 33 | Bungetc(bp); 34 | *dp = d; 35 | return 1; 36 | } 37 | -------------------------------------------------------------------------------- /src/styx/libs/libbio/bgetrune.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | long 5 | Bgetrune(Biobuf *bp) 6 | { 7 | int c, i; 8 | Rune rune; 9 | char str[UTFmax]; 10 | 11 | c = Bgetc(bp); 12 | if(c < Runeself) { /* one char */ 13 | bp->runesize = 1; 14 | return c; 15 | } 16 | str[0] = c; 17 | bp->runesize = 0; 18 | 19 | for(i=1;;) { 20 | c = Bgetc(bp); 21 | if(c < 0) 22 | return c; 23 | if (i >= sizeof str) 24 | return Runeerror; 25 | str[i++] = c; 26 | 27 | if(fullrune(str, i)) { 28 | /* utf is long enough to be a rune, but could be bad. */ 29 | bp->runesize = chartorune(&rune, str); 30 | if (rune == Runeerror) 31 | bp->runesize = 0; /* push back nothing */ 32 | else 33 | /* push back bytes unconsumed by chartorune */ 34 | for(; i > bp->runesize; i--) 35 | Bungetc(bp); 36 | return rune; 37 | } 38 | } 39 | } 40 | 41 | int 42 | Bungetrune(Biobuf *bp) 43 | { 44 | 45 | if(bp->state == Bracteof) 46 | bp->state = Bractive; 47 | if(bp->state != Bractive) 48 | return Beof; 49 | bp->icount -= bp->runesize; 50 | bp->runesize = 0; 51 | return 1; 52 | } 53 | -------------------------------------------------------------------------------- /src/styx/libs/libbio/boffset.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | vlong 5 | Boffset(Biobuf *bp) 6 | { 7 | vlong n; 8 | 9 | switch(bp->state) { 10 | default: 11 | fprint(2, "Boffset: unknown state %d\n", bp->state); 12 | n = Beof; 13 | break; 14 | 15 | case Bracteof: 16 | case Bractive: 17 | n = bp->offset + bp->icount; 18 | break; 19 | 20 | case Bwactive: 21 | n = bp->offset + (bp->bsize + bp->ocount); 22 | break; 23 | } 24 | return n; 25 | } 26 | -------------------------------------------------------------------------------- /src/styx/libs/libbio/bprint.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | int 5 | Bprint(Biobuf *bp, char *fmt, ...) 6 | { 7 | va_list arg; 8 | int n; 9 | 10 | va_start(arg, fmt); 11 | n = Bvprint(bp, fmt, arg); 12 | va_end(arg); 13 | return n; 14 | } 15 | -------------------------------------------------------------------------------- /src/styx/libs/libbio/bputc.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | int 5 | Bputc(Biobuf *bp, int c) 6 | { 7 | int i; 8 | 9 | for(;;) { 10 | i = bp->ocount; 11 | if(i) { 12 | bp->ebuf[i++] = c; 13 | bp->ocount = i; 14 | return 0; 15 | } 16 | if(Bflush(bp) == Beof) 17 | break; 18 | } 19 | return Beof; 20 | } 21 | -------------------------------------------------------------------------------- /src/styx/libs/libbio/bputrune.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | int 5 | Bputrune(Biobuf *bp, long c) 6 | { 7 | Rune rune; 8 | char str[UTFmax]; 9 | int n; 10 | 11 | rune = c; 12 | if(rune < Runeself) { 13 | Bputc(bp, rune); 14 | return 1; 15 | } 16 | n = runetochar(str, &rune); 17 | if(n == 0) 18 | return Bbad; 19 | if(Bwrite(bp, str, n) != n) 20 | return Beof; 21 | return n; 22 | } 23 | -------------------------------------------------------------------------------- /src/styx/libs/libbio/bread.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | long 5 | Bread(Biobuf *bp, void *ap, long count) 6 | { 7 | long c; 8 | uchar *p; 9 | int i, n, ic; 10 | 11 | p = ap; 12 | c = count; 13 | ic = bp->icount; 14 | 15 | while(c > 0) { 16 | n = -ic; 17 | if(n > c) 18 | n = c; 19 | if(n == 0) { 20 | if(bp->state != Bractive) 21 | break; 22 | i = read(bp->fid, bp->bbuf, bp->bsize); 23 | if(i <= 0) { 24 | bp->state = Bracteof; 25 | if(i < 0) 26 | bp->state = Binactive; 27 | break; 28 | } 29 | bp->gbuf = bp->bbuf; 30 | bp->offset += i; 31 | if(i < bp->bsize) { 32 | memmove(bp->ebuf-i, bp->bbuf, i); 33 | bp->gbuf = bp->ebuf-i; 34 | } 35 | ic = -i; 36 | continue; 37 | } 38 | memmove(p, bp->ebuf+ic, n); 39 | c -= n; 40 | ic += n; 41 | p += n; 42 | } 43 | bp->icount = ic; 44 | if(count == c && bp->state == Binactive) 45 | return -1; 46 | return count-c; 47 | } 48 | -------------------------------------------------------------------------------- /src/styx/libs/libbio/bseek.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | vlong 5 | Bseek(Biobuf *bp, vlong offset, int base) 6 | { 7 | vlong n, d; 8 | 9 | switch(bp->state) { 10 | default: 11 | fprint(2, "Bseek: unknown state %d\n", bp->state); 12 | return Beof; 13 | 14 | case Bracteof: 15 | bp->state = Bractive; 16 | bp->icount = 0; 17 | bp->gbuf = bp->ebuf; 18 | 19 | case Bractive: 20 | n = offset; 21 | if(base == 1) { 22 | n += Boffset(bp); 23 | base = 0; 24 | } 25 | 26 | /* 27 | * try to seek within buffer 28 | */ 29 | if(base == 0) { 30 | /* 31 | * if d is too large for an int, icount may wrap, 32 | * so we need to ensure that icount hasn't wrapped 33 | * and points within the buffer's valid data. 34 | */ 35 | d = n - Boffset(bp); 36 | bp->icount += d; 37 | if(d <= bp->bsize && bp->icount <= 0 && 38 | bp->ebuf - bp->gbuf >= -bp->icount) 39 | return n; 40 | } 41 | 42 | /* 43 | * reset the buffer 44 | */ 45 | n = seek(bp->fid, n, base); 46 | bp->icount = 0; 47 | bp->gbuf = bp->ebuf; 48 | break; 49 | 50 | case Bwactive: 51 | Bflush(bp); 52 | n = seek(bp->fid, offset, base); 53 | break; 54 | } 55 | bp->offset = n; 56 | return n; 57 | } 58 | -------------------------------------------------------------------------------- /src/styx/libs/libbio/bvprint.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | static int 5 | fmtBflush(Fmt *f) 6 | { 7 | Biobuf *bp; 8 | 9 | bp = f->farg; 10 | bp->ocount = (char*)f->to - (char*)f->stop; 11 | if(Bflush(bp) < 0) 12 | return 0; 13 | f->stop = bp->ebuf; 14 | f->to = (char*)f->stop + bp->ocount; 15 | f->start = f->to; 16 | return 1; 17 | } 18 | 19 | int 20 | Bvprint(Biobuf *bp, char *fmt, va_list arg) 21 | { 22 | int n; 23 | Fmt f; 24 | 25 | f.runes = 0; 26 | f.stop = bp->ebuf; 27 | f.start = (char*)f.stop + bp->ocount; 28 | f.to = f.start; 29 | f.flush = fmtBflush; 30 | f.farg = bp; 31 | f.nfmt = 0; 32 | #ifdef va_copy 33 | va_copy(f.args, arg); 34 | #else 35 | f.args = arg; 36 | #endif 37 | n = dofmt(&f, fmt); 38 | #ifdef va_copy 39 | va_end(f.args); 40 | #endif 41 | bp->ocount = (char*)f.to - (char*)f.stop; 42 | return n; 43 | } 44 | -------------------------------------------------------------------------------- /src/styx/libs/libbio/bwrite.c: -------------------------------------------------------------------------------- 1 | #include "lib9.h" 2 | #include 3 | 4 | long 5 | Bwrite(Biobuf *bp, void *ap, long count) 6 | { 7 | long c; 8 | uchar *p; 9 | int i, n, oc; 10 | char errbuf[ERRMAX]; 11 | 12 | p = ap; 13 | c = count; 14 | oc = bp->ocount; 15 | 16 | while(c > 0) { 17 | n = -oc; 18 | if(n > c) 19 | n = c; 20 | if(n == 0) { 21 | if(bp->state != Bwactive) 22 | return Beof; 23 | i = write(bp->fid, bp->bbuf, bp->bsize); 24 | if(i != bp->bsize) { 25 | errstr(errbuf, sizeof errbuf); 26 | if(strstr(errbuf, "interrupt") == nil) 27 | bp->state = Binactive; 28 | errstr(errbuf, sizeof errbuf); 29 | return Beof; 30 | } 31 | bp->offset += i; 32 | oc = -bp->bsize; 33 | continue; 34 | } 35 | memmove(bp->ebuf+oc, p, n); 36 | oc += n; 37 | c -= n; 38 | p += n; 39 | } 40 | bp->ocount = oc; 41 | return count-c; 42 | } 43 | -------------------------------------------------------------------------------- /src/styx/libs/libbio/mkfile: -------------------------------------------------------------------------------- 1 | <../mkconfig 2 | 3 | LIB=libbio.a 4 | OFILES=\ 5 | bbuffered.$O\ 6 | bfildes.$O\ 7 | bflush.$O\ 8 | bgetrune.$O\ 9 | bgetc.$O\ 10 | bgetd.$O\ 11 | binit.$O\ 12 | boffset.$O\ 13 | bprint.$O\ 14 | bputrune.$O\ 15 | bputc.$O\ 16 | brdline.$O\ 17 | brdstr.$O\ 18 | bread.$O\ 19 | bseek.$O\ 20 | bvprint.$O\ 21 | bwrite.$O\ 22 | 23 | HFILES= $ROOT/include/bio.h 24 | 25 | <$ROOT/mkfiles/mksyslib-$SHELLTYPE 26 | -------------------------------------------------------------------------------- /src/styx/libs/libbio/premake5.lua: -------------------------------------------------------------------------------- 1 | project "libbio" 2 | -- is this kind of app 3 | kind "StaticLib" 4 | targetname "bio" 5 | buildoptions { "-fPIC" } 6 | -- warnings and config settings 7 | -- and is dependent on these files 8 | files {"bbuffered.c", "bfildes.c", "bflush.c", "bgetrune.c", "bgetc.c", "bgetd.c", "binit.c", "boffset.c", "bprint.c", "bputrune.c", "bputc.c", "brdline.c", "brdstr.c", "bread.c", "bseek.c", "bvprint.c", "bwrite.c"} 9 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/des3ECB.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | // I wasn't sure what to do when the buffer was not 6 | // a multiple of 8. I did what lacy's cryptolib did 7 | // to be compatible, but it looks dangerous to me 8 | // since its encrypting plain text with the key. -- presotto 9 | 10 | void 11 | des3ECBencrypt(uchar *p, int len, DES3state *s) 12 | { 13 | int i; 14 | uchar tmp[8]; 15 | 16 | for(; len >= 8; len -= 8){ 17 | triple_block_cipher(s->expanded, p, DES3EDE); 18 | p += 8; 19 | } 20 | 21 | if(len > 0){ 22 | for (i=0; i<8; i++) 23 | tmp[i] = i; 24 | triple_block_cipher(s->expanded, tmp, DES3EDE); 25 | for (i = 0; i < len; i++) 26 | p[i] ^= tmp[i]; 27 | } 28 | } 29 | 30 | void 31 | des3ECBdecrypt(uchar *p, int len, DES3state *s) 32 | { 33 | int i; 34 | uchar tmp[8]; 35 | 36 | for(; len >= 8; len -= 8){ 37 | triple_block_cipher(s->expanded, p, DES3DED); 38 | p += 8; 39 | } 40 | 41 | if(len > 0){ 42 | for (i=0; i<8; i++) 43 | tmp[i] = i; 44 | triple_block_cipher(s->expanded, tmp, DES3EDE); 45 | for (i = 0; i < len; i++) 46 | p[i] ^= tmp[i]; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/desCBC.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | // Because of the way that non multiple of 8 6 | // buffers are handled, the decryptor must 7 | // be fed buffers of the same size as the 8 | // encryptor 9 | 10 | 11 | // If the length is not a multiple of 8, I encrypt 12 | // the overflow to be compatible with lacy's cryptlib 13 | void 14 | desCBCencrypt(uchar *p, int len, DESstate *s) 15 | { 16 | uchar *p2, *ip, *eip; 17 | 18 | for(; len >= 8; len -= 8){ 19 | p2 = p; 20 | ip = s->ivec; 21 | for(eip = ip+8; ip < eip; ) 22 | *p2++ ^= *ip++; 23 | block_cipher(s->expanded, p, 0); 24 | memmove(s->ivec, p, 8); 25 | p += 8; 26 | } 27 | 28 | if(len > 0){ 29 | ip = s->ivec; 30 | block_cipher(s->expanded, ip, 0); 31 | for(eip = ip+len; ip < eip; ) 32 | *p++ ^= *ip++; 33 | } 34 | } 35 | 36 | void 37 | desCBCdecrypt(uchar *p, int len, DESstate *s) 38 | { 39 | uchar *ip, *eip, *tp; 40 | uchar tmp[8]; 41 | 42 | for(; len >= 8; len -= 8){ 43 | memmove(tmp, p, 8); 44 | block_cipher(s->expanded, p, 1); 45 | tp = tmp; 46 | ip = s->ivec; 47 | for(eip = ip+8; ip < eip; ){ 48 | *p++ ^= *ip; 49 | *ip++ = *tp++; 50 | } 51 | } 52 | 53 | if(len > 0){ 54 | ip = s->ivec; 55 | block_cipher(s->expanded, ip, 0); 56 | for(eip = ip+len; ip < eip; ) 57 | *p++ ^= *ip++; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/desECB.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | // I wasn't sure what to do when the buffer was not 6 | // a multiple of 8. I did what lacy's cryptolib did 7 | // to be compatible, but it looks dangerous to me 8 | // since its encrypting plain text with the key. -- presotto 9 | 10 | void 11 | desECBencrypt(uchar *p, int len, DESstate *s) 12 | { 13 | int i; 14 | uchar tmp[8]; 15 | 16 | for(; len >= 8; len -= 8){ 17 | block_cipher(s->expanded, p, 0); 18 | p += 8; 19 | } 20 | 21 | if(len > 0){ 22 | for (i=0; i<8; i++) 23 | tmp[i] = i; 24 | block_cipher(s->expanded, tmp, 0); 25 | for (i = 0; i < len; i++) 26 | p[i] ^= tmp[i]; 27 | } 28 | } 29 | 30 | void 31 | desECBdecrypt(uchar *p, int len, DESstate *s) 32 | { 33 | int i; 34 | uchar tmp[8]; 35 | 36 | for(; len >= 8; len -= 8){ 37 | block_cipher(s->expanded, p, 1); 38 | p += 8; 39 | } 40 | 41 | if(len > 0){ 42 | for (i=0; i<8; i++) 43 | tmp[i] = i; 44 | block_cipher(s->expanded, tmp, 0); 45 | for (i = 0; i < len; i++) 46 | p[i] ^= tmp[i]; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/desmodes.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | 4 | /* 5 | * these routines use the 64bit format for 6 | * DES keys. 7 | */ 8 | 9 | void 10 | setupDESstate(DESstate *s, uchar key[8], uchar *ivec) 11 | { 12 | memset(s, 0, sizeof(*s)); 13 | memmove(s->key, key, sizeof(s->key)); 14 | des_key_setup(key, s->expanded); 15 | if(ivec) 16 | memmove(s->ivec, ivec, 8); 17 | s->setup = 0xdeadbeef; 18 | } 19 | 20 | void 21 | setupDES3state(DES3state *s, uchar key[3][8], uchar *ivec) 22 | { 23 | memset(s, 0, sizeof(*s)); 24 | memmove(s->key, key, sizeof(s->key)); 25 | des_key_setup(key[0], s->expanded[0]); 26 | des_key_setup(key[1], s->expanded[1]); 27 | des_key_setup(key[2], s->expanded[2]); 28 | if(ivec) 29 | memmove(s->ivec, ivec, 8); 30 | s->setup = 0xdeadbeef; 31 | } 32 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/dsaalloc.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | DSApub* 6 | dsapuballoc(void) 7 | { 8 | DSApub *dsa; 9 | 10 | dsa = mallocz(sizeof(*dsa), 1); 11 | if(dsa == nil) 12 | sysfatal("dsapuballoc"); 13 | return dsa; 14 | } 15 | 16 | void 17 | dsapubfree(DSApub *dsa) 18 | { 19 | if(dsa == nil) 20 | return; 21 | mpfree(dsa->p); 22 | mpfree(dsa->q); 23 | mpfree(dsa->alpha); 24 | mpfree(dsa->key); 25 | free(dsa); 26 | } 27 | 28 | 29 | DSApriv* 30 | dsaprivalloc(void) 31 | { 32 | DSApriv *dsa; 33 | 34 | dsa = mallocz(sizeof(*dsa), 1); 35 | if(dsa == nil) 36 | sysfatal("dsaprivalloc"); 37 | return dsa; 38 | } 39 | 40 | void 41 | dsaprivfree(DSApriv *dsa) 42 | { 43 | if(dsa == nil) 44 | return; 45 | mpfree(dsa->pub.p); 46 | mpfree(dsa->pub.q); 47 | mpfree(dsa->pub.alpha); 48 | mpfree(dsa->pub.key); 49 | mpfree(dsa->secret); 50 | free(dsa); 51 | } 52 | 53 | DSAsig* 54 | dsasigalloc(void) 55 | { 56 | DSAsig *dsa; 57 | 58 | dsa = mallocz(sizeof(*dsa), 1); 59 | if(dsa == nil) 60 | sysfatal("dsasigalloc"); 61 | return dsa; 62 | } 63 | 64 | void 65 | dsasigfree(DSAsig *dsa) 66 | { 67 | if(dsa == nil) 68 | return; 69 | mpfree(dsa->r); 70 | mpfree(dsa->s); 71 | free(dsa); 72 | } 73 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/dsaprivtopub.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | DSApub* 6 | dsaprivtopub(DSApriv *priv) 7 | { 8 | DSApub *pub; 9 | 10 | pub = dsapuballoc(); 11 | pub->p = mpcopy(priv->pub.p); 12 | pub->q = mpcopy(priv->pub.q); 13 | pub->alpha = mpcopy(priv->pub.alpha); 14 | pub->key = mpcopy(priv->pub.key); 15 | return pub; 16 | } 17 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/dsasign.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | DSAsig* 6 | dsasign(DSApriv *priv, mpint *m) 7 | { 8 | DSApub *pub = &priv->pub; 9 | DSAsig *sig; 10 | mpint *qm1, *k, *kinv, *r, *s; 11 | mpint *q = pub->q, *p = pub->p, *alpha = pub->alpha; 12 | int qlen = mpsignif(q); 13 | 14 | qm1 = mpnew(0); 15 | kinv = mpnew(0); 16 | r = mpnew(0); 17 | s = mpnew(0); 18 | k = mpnew(0); 19 | mpsub(pub->q, mpone, qm1); 20 | 21 | // find a k that has an inverse mod q 22 | while(1){ 23 | mprand(qlen, genrandom, k); 24 | if((mpcmp(mpone, k) > 0) || (mpcmp(k, pub->q) >= 0)) 25 | continue; 26 | mpextendedgcd(k, q, r, kinv, s); 27 | if(mpcmp(r, mpone) != 0) 28 | sysfatal("dsasign: pub->q not prime"); 29 | break; 30 | } 31 | 32 | // make kinv positive 33 | mpmod(kinv, pub->q, kinv); 34 | 35 | // r = ((alpha**k) mod p) mod q 36 | mpexp(alpha, k, p, r); 37 | mpmod(r, q, r); 38 | 39 | // s = (kinv*(m + ar)) mod q 40 | mpmul(r, priv->secret, s); 41 | mpadd(s, m, s); 42 | mpmul(s, kinv, s); 43 | mpmod(s, q, s); 44 | 45 | sig = dsasigalloc(); 46 | sig->r = r; 47 | sig->s = s; 48 | mpfree(qm1); 49 | mpfree(k); 50 | mpfree(kinv); 51 | return sig; 52 | } 53 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/dsaverify.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | int 6 | dsaverify(DSApub *pub, DSAsig *sig, mpint *m) 7 | { 8 | int rv = -1; 9 | mpint *u1, *u2, *v, *sinv; 10 | 11 | if(mpcmp(sig->r, mpone) < 0 || mpcmp(sig->r, pub->q) >= 0) 12 | return rv; 13 | if(mpcmp(sig->s, mpone) < 0 || mpcmp(sig->s, pub->q) >= 0) 14 | return rv; 15 | u1 = mpnew(0); 16 | u2 = mpnew(0); 17 | v = mpnew(0); 18 | sinv = mpnew(0); 19 | 20 | // find (s**-1) mod q, make sure it exists 21 | mpextendedgcd(sig->s, pub->q, u1, sinv, v); 22 | if(mpcmp(u1, mpone) != 0) 23 | goto out; 24 | 25 | // u1 = (sinv * m) mod q, u2 = (r * sinv) mod q 26 | mpmul(sinv, m, u1); 27 | mpmod(u1, pub->q, u1); 28 | mpmul(sig->r, sinv, u2); 29 | mpmod(u2, pub->q, u2); 30 | 31 | // v = (((alpha**u1)*(key**u2)) mod p) mod q 32 | mpexp(pub->alpha, u1, pub->p, sinv); 33 | mpexp(pub->key, u2, pub->p, v); 34 | mpmul(sinv, v, v); 35 | mpmod(v, pub->p, v); 36 | mpmod(v, pub->q, v); 37 | 38 | if(mpcmp(v, sig->r) == 0) 39 | rv = 0; 40 | out: 41 | mpfree(v); 42 | mpfree(u1); 43 | mpfree(u2); 44 | mpfree(sinv); 45 | return rv; 46 | } 47 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/egalloc.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | EGpub* 6 | egpuballoc(void) 7 | { 8 | EGpub *eg; 9 | 10 | eg = mallocz(sizeof(*eg), 1); 11 | if(eg == nil) 12 | sysfatal("egpuballoc"); 13 | return eg; 14 | } 15 | 16 | void 17 | egpubfree(EGpub *eg) 18 | { 19 | if(eg == nil) 20 | return; 21 | mpfree(eg->p); 22 | mpfree(eg->alpha); 23 | mpfree(eg->key); 24 | free(eg); 25 | } 26 | 27 | 28 | EGpriv* 29 | egprivalloc(void) 30 | { 31 | EGpriv *eg; 32 | 33 | eg = mallocz(sizeof(*eg), 1); 34 | if(eg == nil) 35 | sysfatal("egprivalloc"); 36 | return eg; 37 | } 38 | 39 | void 40 | egprivfree(EGpriv *eg) 41 | { 42 | if(eg == nil) 43 | return; 44 | mpfree(eg->pub.p); 45 | mpfree(eg->pub.alpha); 46 | mpfree(eg->pub.key); 47 | mpfree(eg->secret); 48 | free(eg); 49 | } 50 | 51 | EGsig* 52 | egsigalloc(void) 53 | { 54 | EGsig *eg; 55 | 56 | eg = mallocz(sizeof(*eg), 1); 57 | if(eg == nil) 58 | sysfatal("egsigalloc"); 59 | return eg; 60 | } 61 | 62 | void 63 | egsigfree(EGsig *eg) 64 | { 65 | if(eg == nil) 66 | return; 67 | mpfree(eg->r); 68 | mpfree(eg->s); 69 | free(eg); 70 | } 71 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/egdecrypt.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | mpint* 6 | egdecrypt(EGpriv *priv, mpint *in, mpint *out) 7 | { 8 | EGpub *pub = &priv->pub; 9 | mpint *gamma, *delta; 10 | mpint *p = pub->p; 11 | int plen = mpsignif(p)+1; 12 | int shift = ((plen+Dbits-1)/Dbits)*Dbits; 13 | 14 | if(out == nil) 15 | out = mpnew(0); 16 | gamma = mpnew(0); 17 | delta = mpnew(0); 18 | mpright(in, shift, gamma); 19 | mpleft(gamma, shift, delta); 20 | mpsub(in, delta, delta); 21 | mpexp(gamma, priv->secret, p, out); 22 | mpinvert(out, p, gamma); 23 | mpmul(gamma, delta, out); 24 | mpmod(out, p, out); 25 | mpfree(gamma); 26 | mpfree(delta); 27 | return out; 28 | } 29 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/egencrypt.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | mpint* 6 | egencrypt(EGpub *pub, mpint *in, mpint *out) 7 | { 8 | mpint *m, *k, *gamma, *delta, *pm1; 9 | mpint *p = pub->p, *alpha = pub->alpha; 10 | int plen = mpsignif(p); 11 | int shift = ((plen+Dbits)/Dbits)*Dbits; 12 | // in libcrypt version, (int)(LENGTH(pub->p)*sizeof(NumType)*CHARBITS); 13 | 14 | if(out == nil) 15 | out = mpnew(0); 16 | pm1 = mpnew(0); 17 | m = mpnew(0); 18 | gamma = mpnew(0); 19 | delta = mpnew(0); 20 | mpmod(in, p, m); 21 | while(1){ 22 | k = mprand(plen, genrandom, nil); 23 | if((mpcmp(mpone, k) <= 0) && (mpcmp(k, pm1) < 0)) 24 | break; 25 | } 26 | mpexp(alpha, k, p, gamma); 27 | mpexp(pub->key, k, p, delta); 28 | mpmul(m, delta, delta); 29 | mpmod(delta, p, delta); 30 | mpleft(gamma, shift, out); 31 | mpadd(delta, out, out); 32 | mpfree(pm1); 33 | mpfree(m); 34 | mpfree(k); 35 | mpfree(gamma); 36 | mpfree(delta); 37 | return out; 38 | } 39 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/eggen.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | EGpriv* 6 | eggen(int nlen, int rounds) 7 | { 8 | EGpub *pub; 9 | EGpriv *priv; 10 | 11 | priv = egprivalloc(); 12 | pub = &priv->pub; 13 | pub->p = mpnew(0); 14 | pub->alpha = mpnew(0); 15 | pub->key = mpnew(0); 16 | priv->secret = mpnew(0); 17 | gensafeprime(pub->p, pub->alpha, nlen, rounds); 18 | mprand(nlen-1, genrandom, priv->secret); 19 | mpexp(pub->alpha, priv->secret, pub->p, pub->key); 20 | return priv; 21 | } 22 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/egprivtopub.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | EGpub* 6 | egprivtopub(EGpriv *priv) 7 | { 8 | EGpub *pub; 9 | 10 | pub = egpuballoc(); 11 | if(pub == nil) 12 | return nil; 13 | pub->p = mpcopy(priv->pub.p); 14 | pub->alpha = mpcopy(priv->pub.alpha); 15 | pub->key = mpcopy(priv->pub.key); 16 | return pub; 17 | } 18 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/egsign.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | EGsig* 6 | egsign(EGpriv *priv, mpint *m) 7 | { 8 | EGpub *pub = &priv->pub; 9 | EGsig *sig; 10 | mpint *pm1, *k, *kinv, *r, *s; 11 | mpint *p = pub->p, *alpha = pub->alpha; 12 | int plen = mpsignif(p); 13 | 14 | pm1 = mpnew(0); 15 | kinv = mpnew(0); 16 | r = mpnew(0); 17 | s = mpnew(0); 18 | k = mpnew(0); 19 | mpsub(p, mpone, pm1); 20 | while(1){ 21 | mprand(plen, genrandom, k); 22 | if((mpcmp(mpone, k) > 0) || (mpcmp(k, pm1) >= 0)) 23 | continue; 24 | mpextendedgcd(k, pm1, r, kinv, s); 25 | if(mpcmp(r, mpone) != 0) 26 | continue; 27 | break; 28 | } 29 | mpmod(kinv, pm1, kinv); // make kinv positive 30 | mpexp(alpha, k, p, r); 31 | mpmul(priv->secret, r, s); 32 | mpmod(s, pm1, s); 33 | mpsub(m, s, s); 34 | mpmul(kinv, s, s); 35 | mpmod(s, pm1, s); 36 | sig = egsigalloc(); 37 | sig->r = r; 38 | sig->s = s; 39 | mpfree(pm1); 40 | mpfree(k); 41 | mpfree(kinv); 42 | return sig; 43 | } 44 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/egtest.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | void 6 | main(void) 7 | { 8 | EGpriv *sk; 9 | mpint *m, *gamma, *delta, *in, *out; 10 | int plen, shift; 11 | 12 | fmtinstall('B', mpconv); 13 | 14 | sk = egprivalloc(); 15 | sk->pub.p = uitomp(2357, nil); 16 | sk->pub.alpha = uitomp(2, nil); 17 | sk->pub.key = uitomp(1185, nil); 18 | sk->secret = uitomp(1751, nil); 19 | 20 | m = uitomp(2035, nil); 21 | 22 | plen = mpsignif(sk->pub.p)+1; 23 | shift = ((plen+Dbits-1)/Dbits)*Dbits; 24 | gamma = uitomp(1430, nil); 25 | delta = uitomp(697, nil); 26 | out = mpnew(0); 27 | in = mpnew(0); 28 | mpleft(gamma, shift, in); 29 | mpadd(delta, in, in); 30 | egdecrypt(sk, in, out); 31 | 32 | if(mpcmp(m, out) != 0) 33 | print("decrypt failed to recover message\n"); 34 | } 35 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/egverify.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | int 6 | egverify(EGpub *pub, EGsig *sig, mpint *m) 7 | { 8 | mpint *p = pub->p, *alpha = pub->alpha; 9 | mpint *r = sig->r, *s = sig->s; 10 | mpint *v1, *v2, *rs; 11 | int rv = -1; 12 | 13 | if(mpcmp(r, mpone) < 0 || mpcmp(r, p) >= 0) 14 | return rv; 15 | v1 = mpnew(0); 16 | rs = mpnew(0); 17 | v2 = mpnew(0); 18 | mpexp(pub->key, r, p, v1); 19 | mpexp(r, s, p, rs); 20 | mpmul(v1, rs, v1); 21 | mpmod(v1, p, v1); 22 | mpexp(alpha, m, p, v2); 23 | if(mpcmp(v1, v2) == 0) 24 | rv = 0; 25 | mpfree(v1); 26 | mpfree(rs); 27 | mpfree(v2); 28 | return rv; 29 | } 30 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/fastrand.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | 4 | /* 5 | * use the X917 random number generator to create random 6 | * numbers (faster than truerand() but not as random). 7 | */ 8 | ulong 9 | fastrand(void) 10 | { 11 | ulong x; 12 | 13 | genrandom((uchar*)&x, sizeof x); 14 | return x; 15 | } 16 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/genprime.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | // generate a probable prime. accuracy is the miller-rabin interations 6 | void 7 | genprime(mpint *p, int n, int accuracy) 8 | { 9 | mpdigit x; 10 | 11 | // generate n random bits with high and low bits set 12 | mpbits(p, n); 13 | genrandom((uchar*)p->p, (n+7)/8); 14 | p->top = (n+Dbits-1)/Dbits; 15 | x = 1; 16 | x <<= ((n-1)%Dbits); 17 | p->p[p->top-1] &= (x-1); 18 | p->p[p->top-1] |= x; 19 | p->p[0] |= 1; 20 | 21 | // keep icrementing till it looks prime 22 | for(;;){ 23 | if(probably_prime(p, accuracy)) 24 | break; 25 | mpadd(p, mptwo, p); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/gensafeprime.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | // find a prime p of length n and a generator alpha of Z^*_p 6 | // Alg 4.86 Menezes et al () Handbook, p.164 7 | void 8 | gensafeprime(mpint *p, mpint *alpha, int n, int accuracy) 9 | { 10 | mpint *q, *b; 11 | 12 | q = mpnew(n-1); 13 | while(1){ 14 | genprime(q, n-1, accuracy); 15 | mpleft(q, 1, p); 16 | mpadd(p, mpone, p); // p = 2*q+1 17 | if(probably_prime(p, accuracy)) 18 | break; 19 | } 20 | // now find a generator alpha of the multiplicative 21 | // group Z*_p of order p-1=2q 22 | b = mpnew(0); 23 | while(1){ 24 | mprand(n, genrandom, alpha); 25 | mpmod(alpha, p, alpha); 26 | mpmul(alpha, alpha, b); 27 | mpmod(b, p, b); 28 | if(mpcmp(b, mpone) == 0) 29 | continue; 30 | mpexp(alpha, q, p, b); 31 | if(mpcmp(b, mpone) != 0) 32 | break; 33 | } 34 | mpfree(b); 35 | mpfree(q); 36 | } 37 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/genstrongprime.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | // Gordon's algorithm for generating a strong prime 6 | // Menezes et al () Handbook, p.150 7 | void 8 | genstrongprime(mpint *p, int n, int accuracy) 9 | { 10 | mpint *s, *t, *r, *i; 11 | 12 | if(n < 64) 13 | n = 64; 14 | 15 | s = mpnew(n/2); 16 | genprime(s, (n/2)-16, accuracy); 17 | t = mpnew(n/2); 18 | genprime(t, n-mpsignif(s)-32, accuracy); 19 | 20 | // first r = 2it + 1 that's prime 21 | i = mpnew(16); 22 | r = mpnew(0); 23 | itomp(0x8000, i); 24 | mpleft(t, 1, t); // 2t 25 | mpmul(i, t, r); // 2it 26 | mpadd(r, mpone, r); // 2it + 1 27 | for(;;){ 28 | if(probably_prime(r, 18)) 29 | break; 30 | mpadd(r, t, r); // r += 2t 31 | } 32 | 33 | // p0 = 2(s**(r-2) mod r)s - 1 34 | itomp(2, p); 35 | mpsub(r, p, p); 36 | mpexp(s, p, r, p); 37 | mpmul(s, p, p); 38 | mpleft(p, 1, p); 39 | mpsub(p, mpone, p); 40 | 41 | // first p = p0 + 2irs that's prime 42 | itomp(0x8000, i); 43 | mpleft(r, 1, r); // 2r 44 | mpmul(r, s, r); // 2rs 45 | mpmul(r, i, i); // 2irs 46 | mpadd(p, i, p); // p0 + 2irs 47 | for(;;){ 48 | if(probably_prime(p, accuracy)) 49 | break; 50 | mpadd(p, r, p); // p += 2rs 51 | } 52 | 53 | mpfree(i); 54 | mpfree(s); 55 | mpfree(r); 56 | mpfree(t); 57 | } 58 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/hmactest.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | uchar key[] = "Jefe"; 6 | uchar data[] = "what do ya want for nothing?"; 7 | 8 | void 9 | main(void) 10 | { 11 | int i; 12 | uchar hash[MD5dlen]; 13 | 14 | hmac_md5(data, strlen((char*)data), key, 4, hash, nil); 15 | for(i=0; i 3 | #include 4 | 5 | char *tests[] = { 6 | "", 7 | "a", 8 | "abc", 9 | "message digest", 10 | "abcdefghijklmnopqrstuvwxyz", 11 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 12 | "12345678901234567890123456789012345678901234567890123456789012345678901234567890", 13 | 0 14 | }; 15 | 16 | void 17 | main(void) 18 | { 19 | char **pp; 20 | uchar *p; 21 | int i; 22 | uchar digest[MD5dlen]; 23 | 24 | for(pp = tests; *pp; pp++){ 25 | p = (uchar*)*pp; 26 | md4(p, strlen(*pp), digest, 0); 27 | for(i = 0; i < MD5dlen; i++) 28 | print("%2.2ux", digest[i]); 29 | print("\n"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/md5pickle.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | 4 | char* 5 | md5pickle(MD5state *s) 6 | { 7 | char *p; 8 | int m, n; 9 | 10 | m = 17+4*9+4*((s->blen+3)/3 + 1); 11 | p = malloc(m); 12 | if(p == nil) 13 | return p; 14 | n = sprint(p, "%16.16llux %8.8ux %8.8ux %8.8ux %8.8ux ", 15 | s->len, 16 | s->state[0], s->state[1], s->state[2], 17 | s->state[3]); 18 | enc64(p+n, m-n, s->buf, s->blen); 19 | return p; 20 | } 21 | 22 | MD5state* 23 | md5unpickle(char *p) 24 | { 25 | MD5state *s; 26 | 27 | s = malloc(sizeof(*s)); 28 | if(s == nil) 29 | return nil; 30 | s->len = strtoull(p, &p, 16); 31 | s->state[0] = strtoul(p, &p, 16); 32 | s->state[1] = strtoul(p, &p, 16); 33 | s->state[2] = strtoul(p, &p, 16); 34 | s->state[3] = strtoul(p, &p, 16); 35 | s->blen = dec64(s->buf, sizeof(s->buf), p, strlen(p)); 36 | s->malloced = 1; 37 | s->seeded = 1; 38 | return s; 39 | } 40 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/mkfile: -------------------------------------------------------------------------------- 1 | <../../mkconfig 2 | 3 | LIB=libsec.a 4 | 5 | CFILES = des.c desmodes.c desECB.c desCBC.c des3ECB.c des3CBC.c\ 6 | aes.c blowfish.c \ 7 | idea.c \ 8 | hmac.c md5.c md5block.c md4.c sha1.c sha1block.c\ 9 | sha2.c sha256block.c sha512block.c\ 10 | sha1pickle.c md5pickle.c\ 11 | rc4.c\ 12 | genrandom.c prng.c fastrand.c nfastrand.c\ 13 | probably_prime.c smallprimetest.c genprime.c dsaprimes.c gensafeprime.c genstrongprime.c\ 14 | rsagen.c rsafill.c rsaencrypt.c rsadecrypt.c rsaalloc.c rsaprivtopub.c \ 15 | eggen.c egencrypt.c egdecrypt.c egalloc.c egprivtopub.c egsign.c egverify.c \ 16 | dsagen.c dsaalloc.c dsaprivtopub.c dsasign.c dsaverify.c \ 17 | 18 | ALLOFILES=${CFILES:%.c=%.$O} 19 | 20 | # cull things in the per-machine directories from this list 21 | OFILES= `{$SHELLNAME ./reduce-$SHELLTYPE $O $TARGMODEL-$OBJTYPE $ALLOFILES } 22 | 23 | HFILES=\ 24 | $ROOT/include/libsec.h\ 25 | $ROOT/libmp/port/os.h\ 26 | 27 | CFLAGS=$CFLAGS -I../../libmp/port 28 | 29 | UPDATE=mkfile\ 30 | $HFILES\ 31 | $CFILES\ 32 | 33 | <$ROOT/mkfiles/mksyslib-$SHELLTYPE 34 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/nfastrand.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | 4 | #define Maxrand ((1UL<<31)-1) 5 | 6 | ulong 7 | nfastrand(ulong n) 8 | { 9 | ulong m, r; 10 | 11 | /* 12 | * set m to the maximum multiple of n <= 2^31-1 13 | * so we want a random number < m. 14 | */ 15 | if(n > Maxrand) 16 | sysfatal("nfastrand: n too large"); 17 | 18 | m = Maxrand - Maxrand % n; 19 | while((r = fastrand()) >= m) 20 | ; 21 | return r%n; 22 | } 23 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/premake5.lua: -------------------------------------------------------------------------------- 1 | project "libsec" 2 | -- is this kind of app 3 | kind "StaticLib" 4 | targetname "sec" 5 | buildoptions {"-fPIC"} 6 | includedirs{ "../include"} 7 | -- and is dependent on these files 8 | files { "des.c", "desmodes.c", "desECB.c", "desCBC.c", "des3ECB.c", "des3CBC.c", "aes.c", "blowfish.c", "idea.c", "hmac.c", "md5.c", "md5block.c", 9 | "md4.c", "sha1.c", "sha1block.c", "sha2.c", "sha256block.c", "sha512block.c", "sha1pickle.c", "md5pickle.c", "rc4.c", "genrandom.c", "prng.c", 10 | "fastrand.c", "nfastrand.c", "probably_prime.c", "smallprimetest.c", "genprime.c", "dsaprimes.c", "gensafeprime.c", "genstrongprime.c", 11 | "rsagen.c", "rsafill.c", "rsaencrypt.c", "rsadecrypt.c", "rsaalloc.c", "rsaprivtopub.c", "eggen.c", "egencrypt.c", "egdecrypt.c", 12 | "egalloc.c", "egprivtopub.c", "egsign.c", "egverify.c", "dsagen.c", "dsaalloc.c", "dsaprivtopub.c", "dsasign.c", "dsaverify.c"} 13 | 14 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/prng.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | // 6 | // just use the libc prng to fill a buffer 7 | // 8 | void 9 | prng(uchar *p, int n) 10 | { 11 | uchar *e; 12 | 13 | for(e = p+n; p < e; p++) 14 | *p = rand(); 15 | } 16 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/reduce-nt: -------------------------------------------------------------------------------- 1 | # for now, just return the input files 2 | shift # $O 3 | shift # $SYSTARG-$OBJTYPE 4 | echo -n $* 5 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/reduce-rc: -------------------------------------------------------------------------------- 1 | O=$1 2 | shift 3 | nonport=$1 4 | shift 5 | 6 | ls -p ../$nonport/*.[cs] >[2]/dev/null | sed 's/..$//' > /tmp/reduce.$pid 7 | # 8 | # if empty directory, just return the input files 9 | # 10 | if (! ~ $status '|') { 11 | echo $* 12 | rm /tmp/reduce.$pid 13 | exit 0 14 | } 15 | echo $* | tr ' ' \012 | grep -v -f /tmp/reduce.$pid | tr \012 ' ' 16 | rm /tmp/reduce.$pid 17 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/reduce-sh: -------------------------------------------------------------------------------- 1 | O=$1 2 | shift 3 | nonport=$1 4 | shift 5 | 6 | for i in $* 7 | do 8 | j=`echo $i | sed 's/\.'$O'//'` 9 | if test ! -f ../$nonport/$j.c -a ! -f ../$nonport/$j.s -a ! -f ../$nonport/$j.spp 10 | then 11 | echo $i 12 | fi 13 | done 14 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/rsaalloc.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | RSApub* 6 | rsapuballoc(void) 7 | { 8 | RSApub *rsa; 9 | 10 | rsa = mallocz(sizeof(*rsa), 1); 11 | if(rsa == nil) 12 | sysfatal("rsapuballoc"); 13 | return rsa; 14 | } 15 | 16 | void 17 | rsapubfree(RSApub *rsa) 18 | { 19 | if(rsa == nil) 20 | return; 21 | mpfree(rsa->ek); 22 | mpfree(rsa->n); 23 | free(rsa); 24 | } 25 | 26 | 27 | RSApriv* 28 | rsaprivalloc(void) 29 | { 30 | RSApriv *rsa; 31 | 32 | rsa = mallocz(sizeof(*rsa), 1); 33 | if(rsa == nil) 34 | sysfatal("rsaprivalloc"); 35 | return rsa; 36 | } 37 | 38 | void 39 | rsaprivfree(RSApriv *rsa) 40 | { 41 | if(rsa == nil) 42 | return; 43 | mpfree(rsa->pub.ek); 44 | mpfree(rsa->pub.n); 45 | mpfree(rsa->dk); 46 | mpfree(rsa->p); 47 | mpfree(rsa->q); 48 | mpfree(rsa->kp); 49 | mpfree(rsa->kq); 50 | mpfree(rsa->c2); 51 | free(rsa); 52 | } 53 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/rsadecrypt.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | // decrypt rsa using garner's algorithm for the chinese remainder theorem 6 | // seminumerical algorithms, knuth, pp 253-254 7 | // applied cryptography, menezes et al, pg 612 8 | mpint* 9 | rsadecrypt(RSApriv *rsa, mpint *in, mpint *out) 10 | { 11 | mpint *v1, *v2; 12 | 13 | if(out == nil) 14 | out = mpnew(0); 15 | 16 | // convert in to modular representation 17 | v1 = mpnew(0); 18 | mpmod(in, rsa->p, v1); 19 | v2 = mpnew(0); 20 | mpmod(in, rsa->q, v2); 21 | 22 | // exponentiate the modular rep 23 | mpexp(v1, rsa->kp, rsa->p, v1); 24 | mpexp(v2, rsa->kq, rsa->q, v2); 25 | 26 | // out = v1 + p*((v2-v1)*c2 mod q) 27 | mpsub(v2, v1, v2); 28 | mpmul(v2, rsa->c2, v2); 29 | mpmod(v2, rsa->q, v2); 30 | mpmul(v2, rsa->p, out); 31 | mpadd(v1, out, out); 32 | 33 | mpfree(v1); 34 | mpfree(v2); 35 | 36 | return out; 37 | } 38 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/rsaencrypt.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | mpint* 6 | rsaencrypt(RSApub *rsa, mpint *in, mpint *out) 7 | { 8 | if(out == nil) 9 | out = mpnew(0); 10 | mpexp(in, rsa->ek, rsa->n, out); 11 | return out; 12 | } 13 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/rsaprivtopub.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | #include 4 | 5 | RSApub* 6 | rsaprivtopub(RSApriv *priv) 7 | { 8 | RSApub *pub; 9 | 10 | pub = rsapuballoc(); 11 | if(pub == nil) 12 | return nil; 13 | pub->n = mpcopy(priv->pub.n); 14 | pub->ek = mpcopy(priv->pub.ek); 15 | return pub; 16 | } 17 | -------------------------------------------------------------------------------- /src/styx/libs/libsec/sha1pickle.c: -------------------------------------------------------------------------------- 1 | #include "os.h" 2 | #include 3 | 4 | char* 5 | sha1pickle(SHA1state *s) 6 | { 7 | char *p; 8 | int m, n; 9 | 10 | m = 5*9+4*((s->blen+3)/3); 11 | p = malloc(m); 12 | if(p == nil) 13 | return p; 14 | n = sprint(p, "%8.8ux %8.8ux %8.8ux %8.8ux %8.8ux ", 15 | s->state[0], s->state[1], s->state[2], 16 | s->state[3], s->state[4]); 17 | enc64(p+n, m-n, s->buf, s->blen); 18 | return p; 19 | } 20 | 21 | SHA1state* 22 | sha1unpickle(char *p) 23 | { 24 | SHA1state *s; 25 | 26 | s = malloc(sizeof(*s)); 27 | if(s == nil) 28 | return nil; 29 | s->state[0] = strtoul(p, &p, 16); 30 | s->state[1] = strtoul(p, &p, 16); 31 | s->state[2] = strtoul(p, &p, 16); 32 | s->state[3] = strtoul(p, &p, 16); 33 | s->state[4] = strtoul(p, &p, 16); 34 | s->blen = dec64(s->buf, sizeof(s->buf), p, strlen(p)); 35 | s->malloced = 1; 36 | s->seeded = 1; 37 | return s; 38 | } 39 | -------------------------------------------------------------------------------- /src/styx/platform/FreeBSD/deveia.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FreeBSD serial port definitions 3 | */ 4 | 5 | static char *sysdev[] = { 6 | "/dev/cuaa0", 7 | "/dev/cuaa1", 8 | "/dev/cuaa2", 9 | "/dev/cuaa3", 10 | }; 11 | 12 | #include 13 | #include "deveia-posix.c" 14 | #include "deveia-bsd.c" 15 | 16 | 17 | static struct tcdef_t bps[] = { 18 | {0, B0}, 19 | {50, B50}, 20 | {75, B75}, 21 | {110, B110}, 22 | {134, B134}, 23 | {150, B150}, 24 | {200, B200}, 25 | {300, B300}, 26 | {600, B600}, 27 | {1200, B1200}, 28 | {1800, B1800}, 29 | {2400, B2400}, 30 | {4800, B4800}, 31 | {9600, B9600}, 32 | {19200, B19200}, 33 | {38400, B38400}, 34 | {57600, B57600}, 35 | {115200, B115200}, 36 | {230400, B230400}, 37 | {-1, -1} 38 | }; 39 | 40 | -------------------------------------------------------------------------------- /src/styx/platform/FreeBSD/devfs.c: -------------------------------------------------------------------------------- 1 | #include "nine.h" 2 | 3 | #include "devfs-posix.c" 4 | 5 | vlong 6 | osdisksize(int fd) 7 | { 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /src/styx/platform/FreeBSD/include/old-emu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * system- and machine-specific declarations for emu: 3 | * floating-point save and restore, signal handling primitive, and 4 | * implementation of the current-process variable `up'. 5 | */ 6 | 7 | /* 8 | * This structure must agree with FPsave and FPrestore asm routines 9 | */ 10 | typedef struct FPU FPU; 11 | struct FPU 12 | { 13 | uchar env[28]; 14 | }; 15 | 16 | #define KSTACK (32 * 1024) 17 | 18 | static __inline Proc *getup(void) { 19 | Proc *p; 20 | __asm__( "movl %%esp, %%eax\n\t" 21 | : "=a" (p) 22 | ); 23 | return *(Proc **)((unsigned long)p & ~(KSTACK - 1)); 24 | }; 25 | 26 | #define up (getup()) 27 | 28 | typedef sigjmp_buf osjmpbuf; 29 | #define ossetjmp(buf) sigsetjmp(buf, 1) 30 | 31 | -------------------------------------------------------------------------------- /src/styx/platform/FreeBSD/mkfile: -------------------------------------------------------------------------------- 1 | SYSTARG=FreeBSD 2 | OBJTYPE=386 3 | <../../mkconfig 4 | SYSTARG=FreeBSD 5 | OBJTYPE=386 6 | 7 | #Configurable parameters 8 | 9 | CONF=emu #default configuration 10 | CONFLIST=emu 11 | CLEANCONFLIST= 12 | 13 | INSTALLDIR=$ROOT/$SYSTARG/$OBJTYPE/bin #path of directory where kernel is installed 14 | 15 | X11LIBS= -lX11 -lXext 16 | 17 | #end configurable parameters 18 | 19 | <$ROOT/mkfiles/mkfile-$SYSTARG-$OBJTYPE #set vars based on target system 20 | 21 | <| $SHELLNAME ../port/mkdevlist $CONF #sets $IP, $DEVS, $PORT, $LIBS 22 | 23 | OBJ=\ 24 | asm-$OBJTYPE.$O\ 25 | os.$O\ 26 | $CONF.root.$O\ 27 | lock.$O\ 28 | $DEVS\ 29 | $PORT\ 30 | 31 | HFILES=\ 32 | 33 | CFLAGS='-DROOT="'$ROOT'"' -DEMU -I. -I../port -I$ROOT/$SYSTARG/$OBJTYPE/include -I$ROOT/include -I$ROOT/libinterp $CTHREADFLAGS $CFLAGS $EMUOPTIONS 34 | SYSLIBS= -lm $X11LIBS 35 | KERNDATE=`{$NDATE} 36 | 37 | default:V: $O.$CONF 38 | 39 | <../port/portmkfile 40 | 41 | $O.$CONF: $OBJ $CONF.c $CONF.root.h $LIBFILES 42 | $CC $CFLAGS '-DKERNDATE='$KERNDATE $CONF.c 43 | $LD $LDFLAGS -o $target $OBJ $CONF.$O $LIBFILES $SYSLIBS 44 | 45 | install:V: $O.$CONF 46 | cp $O.$CONF $INSTALLDIR/$CONF 47 | 48 | devfs.$O: ../port/devfs-posix.c 49 | -------------------------------------------------------------------------------- /src/styx/platform/FreeBSD/mkfile-FreeBSD: -------------------------------------------------------------------------------- 1 | # 2 | # architecture-dependent files for FreeBSD 3 | # 4 | 5 | LDFLAGS= 6 | 7 | TARGFILES=devfs-posix.$O\ 8 | deveia-FreeBSD.$O\ 9 | devip.$O\ 10 | ipif-posix.$O\ 11 | os-FreeBSD.$O\ 12 | win-x11.$O\ 13 | srv.$O\ 14 | lock.$O\ 15 | asm-FreeBSD-$OBJTYPE.$O 16 | 17 | SYSLIBS=/usr/X11R6/lib/libX11.a -lm 18 | -------------------------------------------------------------------------------- /src/styx/platform/Linux/asm-mips.S: -------------------------------------------------------------------------------- 1 | #include "syscall.h" 2 | #include 3 | #include 4 | #include 5 | 6 | /* 7 | * executeonnewstack(void *tos, void (*tramp)(void *arg), void *arg) 8 | */ 9 | 10 | LEAF(executeonnewstack) 11 | and a0,a0,~7 12 | addu sp,a0,-16 13 | move a0,a2 14 | move t9,a1 15 | jalr t9 16 | 17 | li v0,SYS_exit 18 | li a0,0 19 | syscall 20 | 21 | END(executeonnewstack) 22 | 23 | /* 24 | * unlockandexit(int *key) 25 | */ 26 | 27 | LEAF(unlockandexit) 28 | lw a1,0(a0) 29 | li v0,SYS_exit 30 | li a0,0 31 | sw a0,0(a1) 32 | syscall 33 | END(unlockandexit) 34 | 35 | LEAF(FPsave) 36 | cfc1 t0, $31 37 | sw t0, 0(a0) /* a0 is argument */ 38 | j $31 39 | END(FPsave) 40 | 41 | LEAF(FPrestore) 42 | lw t0, 0(a0) /* a0 is argument */ 43 | ctc1 t0, $31 44 | j $31 45 | END(FPrestore) 46 | 47 | LEAF(_tas) 48 | .set noreorder 49 | 1: 50 | ll v0,0(a0) /* a0 is argument */ 51 | or t1, v0, 1 52 | sc t1,0(a0) 53 | beq t1,zero,1b 54 | nop 55 | j $31 /* lock held */ 56 | nop 57 | .set reorder 58 | END(_tas) 59 | -------------------------------------------------------------------------------- /src/styx/platform/Linux/asm-spim.S: -------------------------------------------------------------------------------- 1 | #include "syscall.h" 2 | #include 3 | #include 4 | #include 5 | 6 | /* 7 | * executeonnewstack(void *tos, void (*tramp)(void *arg), void *arg) 8 | */ 9 | 10 | LEAF(executeonnewstack) 11 | and a0,a0,~7 12 | addu sp,a0,-16 13 | move a0,a2 14 | move t9,a1 15 | jalr t9 16 | 17 | li v0,SYS_exit 18 | li a0,0 19 | syscall 20 | 21 | END(executeonnewstack) 22 | 23 | /* 24 | * unlockandexit(int *key) 25 | */ 26 | 27 | LEAF(unlockandexit) 28 | lw a1,0(a0) 29 | li v0,SYS_exit 30 | li a0,0 31 | sw a0,0(a1) 32 | syscall 33 | END(unlockandexit) 34 | 35 | LEAF(FPsave) 36 | cfc1 t0, $31 37 | sw t0, 0(a0) /* a0 is argument */ 38 | j $31 39 | END(FPsave) 40 | 41 | LEAF(FPrestore) 42 | lw t0, 0(a0) /* a0 is argument */ 43 | ctc1 t0, $31 44 | j $31 45 | END(FPrestore) 46 | 47 | LEAF(_tas) 48 | .set noreorder 49 | 1: 50 | ll v0,0(a0) /* a0 is argument */ 51 | or t1, v0, 1 52 | sc t1,0(a0) 53 | beq t1,zero,1b 54 | nop 55 | j $31 /* lock held */ 56 | nop 57 | .set reorder 58 | END(_tas) 59 | -------------------------------------------------------------------------------- /src/styx/platform/Linux/deveia.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Linux serial port definitions 3 | */ 4 | 5 | static char *sysdev[] = { 6 | "/dev/ttyS0", 7 | "/dev/ttyS1", 8 | "/dev/ttyS2", 9 | "/dev/ttyS3", 10 | "/dev/ttyS4", 11 | "/dev/ttyS5", 12 | "/dev/ttyS6", 13 | "/dev/ttyS7", 14 | }; 15 | 16 | #include 17 | #include "deveia-posix.c" 18 | #include "deveia-bsd.c" 19 | 20 | 21 | static struct tcdef_t bps[] = { 22 | {0, B0}, 23 | {50, B50}, 24 | {75, B75}, 25 | {110, B110}, 26 | {134, B134}, 27 | {150, B150}, 28 | {200, B200}, 29 | {300, B300}, 30 | {600, B600}, 31 | {1200, B1200}, 32 | {1800, B1800}, 33 | {2400, B2400}, 34 | {4800, B4800}, 35 | {9600, B9600}, 36 | {19200, B19200}, 37 | {38400, B38400}, 38 | {57600, B57600}, 39 | {115200, B115200}, 40 | {230400, B230400}, 41 | {460800, B460800}, 42 | {-1, -1} 43 | }; 44 | 45 | -------------------------------------------------------------------------------- /src/styx/platform/Linux/devfs.c: -------------------------------------------------------------------------------- 1 | #include "nine.h" 2 | 3 | #include "devfs-posix.c" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | static vlong 10 | osdisksize(int fd) 11 | { 12 | uvlong u64; 13 | long l; 14 | struct hd_geometry geo; 15 | 16 | memset(&geo, 0, sizeof geo); 17 | l = 0; 18 | u64 = 0; 19 | #ifdef BLKGETSIZE64 20 | if(ioctl(fd, BLKGETSIZE64, &u64) >= 0) 21 | return u64; 22 | #endif 23 | if(ioctl(fd, BLKGETSIZE, &l) >= 0) 24 | return l*512; 25 | if(ioctl(fd, HDIO_GETGEO, &geo) >= 0) 26 | return (vlong)geo.heads*geo.sectors*geo.cylinders*512; 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /src/styx/platform/Linux/mk-wrt: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | OPENWRT=$HOME/OpenWrt-SDK-Linux-i686-1 4 | INFERNO=/usr/inferno 5 | 6 | PATH=$OPENWRT/staging_dir_mipsel/bin:$INFERNO/Linux/386/bin:$PATH 7 | 8 | mk OBJTYPE=spim CONF=emu-wrt CONFLIST=emu-wrt SYSLIBS=-lm WIN= $* 9 | -------------------------------------------------------------------------------- /src/styx/platform/Linux/segflush-386.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "nine.h" 5 | 6 | int 7 | segflush(void *a, ulong n) 8 | { 9 | USED(a); USED(n); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /src/styx/platform/Linux/segflush-arm.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "dat.h" 5 | 6 | #define SYS_cacheflush __ARM_NR_cacheflush 7 | 8 | int 9 | segflush(void *a, ulong n) 10 | { 11 | if(n) 12 | syscall(SYS_cacheflush, a, (char*)a+n-1, 1); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /src/styx/platform/Linux/segflush-mips.S: -------------------------------------------------------------------------------- 1 | #include "syscall.h" 2 | #include 3 | #include 4 | #include 5 | 6 | /* 7 | * int segflush(void *p, ulong len) 8 | */ 9 | 10 | LEAF(segflush) 11 | li a2,BCACHE 12 | li v0,SYS_cacheflush 13 | syscall 14 | li v0,0 15 | j $31 16 | END(segflush) 17 | -------------------------------------------------------------------------------- /src/styx/platform/Linux/segflush-power.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "dat.h" 5 | 6 | 7 | /* 8 | * from geoff collyer's port 9 | * invalidate instruction cache and write back data cache from a to a+n-1, 10 | * at least. 11 | */ 12 | int 13 | segflush(void *a, ulong n) 14 | { 15 | ulong *p; 16 | 17 | // cache blocks are often eight words (32 bytes) long, sometimes 16 bytes. 18 | // need to determine it dynamically? 19 | for (p = (ulong *)((ulong)a & ~7UL); (char *)p < (char *)a + n; p++) 20 | __asm__("dcbst 0,%0\n\t" // not dcbf, which writes back, then invalidates 21 | "icbi 0,%0\n\t" 22 | : // no output 23 | : "ar" (p) 24 | ); 25 | __asm__("sync\n\t" 26 | : // no output 27 | : 28 | ); 29 | __asm__("isync\n\t" 30 | : // no output 31 | : 32 | ); 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /src/styx/platform/Linux/segflush-spim.S: -------------------------------------------------------------------------------- 1 | #include "syscall.h" 2 | #include 3 | #include 4 | #include 5 | 6 | /* 7 | * int segflush(void *p, ulong len) 8 | */ 9 | 10 | LEAF(segflush) 11 | li a2,BCACHE 12 | li v0,SYS_cacheflush 13 | syscall 14 | li v0,0 15 | j $31 16 | END(segflush) 17 | -------------------------------------------------------------------------------- /src/styx/platform/MacOSX/NOTE: -------------------------------------------------------------------------------- 1 | - still interp mode only, jit not complete 2 | - mkfile uses Carbon only; mkfile-x11 uses X11R6 from Apple 3 | - both powerpc and x86 versions compiled from this source 4 | - mkfile-g doesn't include graphics (uses emu-g not emu as configuration) 5 | -------------------------------------------------------------------------------- /src/styx/platform/MacOSX/NOTICE: -------------------------------------------------------------------------------- 1 | MacOSX port Copyright © 2001-2003 Corpus Callosum Corporation, 2 | with portions Copyright © 2001-2003 Geoff Collyer 3 | MacOSX-x86 Copyright © 2006 Corpus Callosum Corporation 4 | -------------------------------------------------------------------------------- /src/styx/platform/MacOSX/asm-386.s: -------------------------------------------------------------------------------- 1 | /* 2 | * these are the same as on the PC (eg, Linux) 3 | */ 4 | 5 | .globl _FPsave 6 | _FPsave: 7 | pushl %ebp 8 | movl %esp, %ebp 9 | movl 8(%ebp), %eax 10 | fstenv (%eax) 11 | popl %ebp 12 | ret 13 | 14 | .globl _FPrestore 15 | _FPrestore: 16 | pushl %ebp 17 | movl %esp, %ebp 18 | movl 8(%ebp), %eax 19 | fldenv (%eax) 20 | popl %ebp 21 | ret 22 | 23 | .globl __tas 24 | __tas: 25 | movl $1, %eax 26 | movl 4(%esp), %ecx 27 | xchgl %eax, 0(%ecx) 28 | ret 29 | -------------------------------------------------------------------------------- /src/styx/platform/MacOSX/asm-power.s: -------------------------------------------------------------------------------- 1 | /* 2 | * File: asm-power.s 3 | * 4 | * Copyright (c) 2003, Corpus Callosum Corporation. All rights reserved. 5 | */ 6 | 7 | #include 8 | 9 | .text 10 | 11 | LEAF(_FPsave) 12 | mffs f0 13 | stfd f0,0(r3) 14 | blr 15 | END(_FPsave) 16 | 17 | LEAF(_FPrestore) 18 | lfd f0,0(r3) 19 | mtfsf 0xff,f0 20 | blr 21 | END(_FPrestore) 22 | 23 | LEAF(__tas) 24 | sync 25 | mr r4,r3 26 | addi r5,0,0x1 27 | 1: 28 | lwarx r3,0,r4 29 | cmpwi r3,0x0 30 | bne- 2f 31 | stwcx. r5,0,r4 32 | bne- 1b /* Lost reservation, try again */ 33 | 2: 34 | sync 35 | blr 36 | END(__tas) 37 | -------------------------------------------------------------------------------- /src/styx/platform/MacOSX/devfs.c: -------------------------------------------------------------------------------- 1 | #include "nine.h" 2 | 3 | #include "devfs-posix.c" 4 | 5 | vlong 6 | osdisksize(int fd) 7 | { 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /src/styx/platform/MacOSX/mkfile: -------------------------------------------------------------------------------- 1 | SYSTARG=MacOSX 2 | <../../mkconfig 3 | SYSTARG=MacOSX 4 | 5 | #Configurable parameters 6 | 7 | CONF=emu #default configuration 8 | CONFLIST=emu 9 | CLEANCONFLIST= 10 | 11 | INSTALLDIR=$ROOT/$SYSTARG/$OBJTYPE/bin #path of directory where kernel is installed 12 | 13 | #end configurable parameters 14 | 15 | <$ROOT/mkfiles/mkfile-$SYSTARG-$OBJTYPE #set vars based on target system 16 | 17 | <| $SHELLNAME ../port/mkdevlist $CONF #sets $IP, $DEVS, $PORT, $LIBS 18 | 19 | OBJ=\ 20 | asm-$OBJTYPE.$O\ 21 | os.$O\ 22 | $CONF.root.$O\ 23 | lock.$O\ 24 | $DEVS\ 25 | $PORT\ 26 | 27 | HFILES=\ 28 | 29 | CFLAGS='-DROOT="'$ROOT'"'\ 30 | '-DOBJTYPE="'$OBJTYPE'"'\ 31 | -DEMU -I. -I../port\ 32 | -I$ROOT/$SYSTARG/$OBJTYPE/include\ 33 | -I$ROOT/include -I$ROOT/libinterp\ 34 | $CTHREADFLAGS $CFLAGS $EMUOPTIONS\ 35 | 36 | KERNDATE=`{$NDATE} 37 | 38 | SYSLIBS= \ 39 | -lm\ 40 | -framework Carbon -framework QuickTime\ 41 | -lpthread\ 42 | -framework CoreFoundation\ 43 | -framework IOKit\ 44 | 45 | default:V: $O.$CONF 46 | 47 | <../port/portmkfile 48 | 49 | $O.$CONF: $OBJ $CONF.c $CONF.root.h $LIBFILES 50 | $CC $CFLAGS '-DKERNDATE='$KERNDATE $CONF.c 51 | $LD $LDFLAGS -o $target $OBJ $CONF.$O $LIBFILES $SYSLIBS 52 | 53 | install:V: $O.$CONF 54 | cp $O.$CONF $INSTALLDIR/$CONF 55 | 56 | devfs.c:N: ../port/devfs-posix.c 57 | -------------------------------------------------------------------------------- /src/styx/platform/MacOSX/mkfile-g: -------------------------------------------------------------------------------- 1 | SYSTARG=MacOSX 2 | <../../mkconfig 3 | SYSTARG=MacOSX 4 | 5 | #Configurable parameters 6 | 7 | CONF=emu-g #default configuration 8 | CONFLIST=emu 9 | CLEANCONFLIST= 10 | 11 | INSTALLDIR=$ROOT/$SYSTARG/$OBJTYPE/bin #path of directory where kernel is installed 12 | 13 | #end configurable parameters 14 | 15 | <$ROOT/mkfiles/mkfile-$SYSTARG-$OBJTYPE #set vars based on target system 16 | 17 | <| $SHELLNAME ../port/mkdevlist $CONF #sets $IP, $DEVS, $PORT, $LIBS 18 | 19 | OBJ=\ 20 | asm-$OBJTYPE.$O\ 21 | os.$O\ 22 | $CONF.root.$O\ 23 | lock.$O\ 24 | $DEVS\ 25 | $PORT\ 26 | 27 | HFILES=\ 28 | 29 | CFLAGS='-DROOT="'$ROOT'"'\ 30 | '-DOBJTYPE="'$OBJTYPE'"'\ 31 | -DEMU -I. -I../port\ 32 | -I$ROOT/$SYSTARG/$OBJTYPE/include\ 33 | -I$ROOT/include -I$ROOT/libinterp\ 34 | $CTHREADFLAGS $CFLAGS $EMUOPTIONS\ 35 | 36 | KERNDATE=`{$NDATE} 37 | 38 | SYSLIBS= \ 39 | -lm\ 40 | -lpthread\ 41 | -framework CoreFoundation\ 42 | -framework IOKit\ 43 | 44 | default:V: $O.$CONF 45 | 46 | <../port/portmkfile 47 | 48 | $O.$CONF: $OBJ $CONF.c $CONF.root.h $LIBFILES 49 | $CC $CFLAGS '-DKERNDATE='$KERNDATE $CONF.c 50 | $LD $LDFLAGS -o $target $OBJ $CONF.$O $LIBFILES $SYSLIBS 51 | 52 | install:V: $O.$CONF 53 | cp $O.$CONF $INSTALLDIR/$CONF 54 | 55 | devfs.c:N: ../port/devfs-posix.c 56 | -------------------------------------------------------------------------------- /src/styx/platform/Nt/nt.rc: -------------------------------------------------------------------------------- 1 | 100 ICON inferno.ico 2 | -------------------------------------------------------------------------------- /src/styx/platform/Nt/r16.h: -------------------------------------------------------------------------------- 1 | typedef unsigned short Rune16; 2 | 3 | wchar_t *widen(char *s); 4 | char *narrowen(wchar_t *ws); 5 | int widebytes(wchar_t *ws); 6 | int runeslen(Rune16*); 7 | Rune16* runesdup(Rune*); 8 | Rune16* utftorunes(Rune*, char*, int); 9 | char* runestoutf(char*, Rune16*, int); 10 | int runescmp(Rune16*, Rune*); 11 | -------------------------------------------------------------------------------- /src/styx/platform/README: -------------------------------------------------------------------------------- 1 | There's a directory here for each node9 platform combination. These are the 2 | depedendencies that are outside the scope of libuv (or haven't been included 3 | yet). 4 | 5 | -------------------------------------------------------------------------------- /src/styx/svcs/cache.c: -------------------------------------------------------------------------------- 1 | #include "nine.h" 2 | 3 | /* 4 | * no cache in hosted mode 5 | */ 6 | void 7 | cinit(void) 8 | { 9 | } 10 | 11 | void 12 | copen(Chan *c) 13 | { 14 | c->flag &= ~CCACHE; 15 | } 16 | 17 | int 18 | cread(Chan *c, uchar *b, int n, vlong off) 19 | { 20 | USED(c); 21 | USED(b); 22 | USED(n); 23 | USED(off); 24 | return 0; 25 | } 26 | 27 | void 28 | cwrite(Chan *c, uchar *buf, int n, vlong off) 29 | { 30 | USED(c); 31 | USED(buf); 32 | USED(n); 33 | USED(off); 34 | } 35 | 36 | void 37 | cupdate(Chan *c, uchar *buf, int n, vlong off) 38 | { 39 | USED(c); 40 | USED(buf); 41 | USED(n); 42 | USED(off); 43 | } 44 | 45 | -------------------------------------------------------------------------------- /src/styx/svcs/devindir.c: -------------------------------------------------------------------------------- 1 | #include "nine.h" 2 | 3 | static Chan * 4 | indirattach(char *spec) 5 | { 6 | char *p; 7 | Dev *d; 8 | 9 | if(*spec == 0) 10 | error(Ebadspec); 11 | p = strrchr(spec, '!'); 12 | if(p == nil) 13 | p = ""; 14 | else 15 | *p++ = 0; 16 | d = devbyname(spec); 17 | if(d == nil || d->dc == '*'){ 18 | snprint(up->env->errstr, ERRMAX, "unknown device: %s", spec); 19 | error(up->env->errstr); 20 | } 21 | if(up->env->pgrp->nodevs && 22 | (utfrune("|esDa", d->dc) == nil || d->dc == 's' && *p!='\0')) 23 | error(Enoattach); 24 | return d->attach(p); 25 | } 26 | 27 | Dev indirdevtab = { 28 | '*', 29 | "indir", 30 | 31 | devinit, 32 | indirattach, 33 | }; 34 | -------------------------------------------------------------------------------- /src/styx/svcs/devtab.c: -------------------------------------------------------------------------------- 1 | #include "nine.h" 2 | 3 | 4 | long 5 | devtabread(Chan *c, void* buf, long n, vlong off) 6 | { 7 | int i; 8 | Dev *dev; 9 | char *alloc, *e, *p; 10 | 11 | USED(c); 12 | alloc = malloc(READSTR); 13 | if(alloc == nil) 14 | error(Enomem); 15 | 16 | p = alloc; 17 | e = p + READSTR; 18 | for(i = 0; devtab[i] != nil; i++){ 19 | dev = devtab[i]; 20 | p = seprint(p, e, "#%C %s\n", dev->dc, dev->name); 21 | } 22 | 23 | if(waserror()){ 24 | free(alloc); 25 | nexterror(); 26 | } 27 | n = readstr(off, buf, n, alloc); 28 | free(alloc); 29 | poperror(); 30 | 31 | return n; 32 | } 33 | -------------------------------------------------------------------------------- /src/styx/svcs/dynld.c: -------------------------------------------------------------------------------- 1 | #include "dat.h" 2 | #include "fns.h" 3 | #include "error.h" 4 | #include 5 | #include 6 | 7 | /* 8 | * kernel interface to dynld, for use by devdynld.c, 9 | * libinterp/dlm.c, and possibly others 10 | */ 11 | 12 | typedef struct Fd Fd; 13 | struct Fd { 14 | int fd; 15 | }; 16 | 17 | static long 18 | readfd(void *a, void *buf, long nbytes) 19 | { 20 | return kread(((Fd*)a)->fd, buf, nbytes); 21 | } 22 | 23 | static vlong 24 | seekfd(void *a, vlong off, int t) 25 | { 26 | return kseek(((Fd*)a)->fd, off, t); 27 | } 28 | 29 | static void 30 | errfd(char *s) 31 | { 32 | kstrcpy(up->env->errstr, s, ERRMAX); 33 | } 34 | 35 | Dynobj* 36 | kdynloadfd(int fd, Dynsym *tab, int ntab) 37 | { 38 | Dynobj *o; 39 | Fd f; 40 | 41 | f.fd = fd; 42 | return dynloadgen(&f, readfd, seekfd, errfd, tab, ntab, 0); 43 | } 44 | 45 | int 46 | kdynloadable(int fd) 47 | { 48 | Fd f; 49 | 50 | f.fd = fd; 51 | return dynloadable(&f, readfd, seekfd); 52 | } 53 | -------------------------------------------------------------------------------- /src/styx/svcs/dynldc.c: -------------------------------------------------------------------------------- 1 | #include "dat.h" 2 | #include "fns.h" 3 | #include "error.h" 4 | #include 5 | #include 6 | 7 | /* 8 | * channel-based kernel interface to dynld, for use by devdynld.c, 9 | * libinterp/dlm.c, and possibly others 10 | */ 11 | 12 | static long 13 | readfc(void *a, void *buf, long nbytes) 14 | { 15 | Chan *c = a; 16 | 17 | if(waserror()) 18 | return -1; 19 | nbytes = devtab[c->type]->read(c, buf, nbytes, c->offset); 20 | poperror(); 21 | return nbytes; 22 | } 23 | 24 | static vlong 25 | seekfc(void *a, vlong off, int t) 26 | { 27 | Chan *c = a; 28 | 29 | if(c->qid.type & QTDIR || off < 0) 30 | return -1; /* won't happen */ 31 | switch(t){ 32 | case 0: 33 | lock(c); 34 | c->offset = off; 35 | unlock(c); 36 | break; 37 | case 1: 38 | lock(c); 39 | off += c->offset; 40 | c->offset = off; 41 | unlock(c); 42 | break; 43 | case 2: 44 | return -1; /* not needed */ 45 | } 46 | return off; 47 | } 48 | 49 | static void 50 | errfc(char *s) 51 | { 52 | kstrcpy(up->env->errstr, s, ERRMAX); 53 | } 54 | 55 | Dynobj* 56 | kdynloadchan(Chan *c, Dynsym *tab, int ntab) 57 | { 58 | return dynloadgen(c, readfc, seekfc, errfc, tab, ntab, 0); 59 | } 60 | 61 | int 62 | kdynloadable(Chan *c) 63 | { 64 | return dynloadable(c, readfc, seekfc); 65 | } 66 | -------------------------------------------------------------------------------- /src/styx/svcs/errstr.c: -------------------------------------------------------------------------------- 1 | #include "nine.h" 2 | 3 | /* 4 | * General OS interface to errors 5 | */ 6 | void 7 | kwerrstr(char *fmt, ...) 8 | { 9 | va_list arg; 10 | char buf[ERRMAX]; 11 | 12 | va_start(arg, fmt); 13 | vseprint(buf, buf+sizeof(buf), fmt, arg); 14 | va_end(arg); 15 | kstrcpy(up->env->errstr, buf, ERRMAX); 16 | } 17 | 18 | void 19 | kerrstr(char *err, uint size) 20 | { 21 | char tmp[ERRMAX]; 22 | 23 | kstrcpy(tmp, up->env->errstr, sizeof(tmp)); 24 | kstrcpy(up->env->errstr, err, ERRMAX); 25 | kstrcpy(err, tmp, size); 26 | } 27 | 28 | void 29 | kgerrstr(char *err, uint size) 30 | { 31 | char *s; 32 | 33 | s = ""; 34 | if(up != nil) 35 | s = up->env->errstr; 36 | kstrcpy(err, s, size); /* TO DO */ 37 | } 38 | -------------------------------------------------------------------------------- /src/styx/svcs/exptab.c: -------------------------------------------------------------------------------- 1 | #include "nine.h" 2 | #include 3 | 4 | /* dummy export table */ 5 | 6 | Dynsym _exporttab[] = { 0, 0, nil }; 7 | -------------------------------------------------------------------------------- /src/styx/svcs/master: -------------------------------------------------------------------------------- 1 | # do not edit; automatically generated 2 | 3 | % mem 4 | * indir 5 | / root 6 | A audio 7 | C cmd 8 | D ssl 9 | F tinyfs 10 | I ip 11 | M mnt 12 | P prof 13 | U fs 14 | ^ snarf 15 | a arch 16 | c cons 17 | d dup 18 | e env 19 | i draw 20 | m pointer 21 | p prog 22 | s srv 23 | | pipe 24 | τ tk 25 | ₪ srv9 26 | 27 | α local use 28 | β local use 29 | γ local use 30 | δ local use 31 | ε local use 32 | ζ local use 33 | η local use 34 | θ local use 35 | ι local use 36 | κ local use 37 | -------------------------------------------------------------------------------- /src/styx/svcs/master.local: -------------------------------------------------------------------------------- 1 | α local use 2 | β local use 3 | γ local use 4 | δ local use 5 | ε local use 6 | ζ local use 7 | η local use 8 | θ local use 9 | ι local use 10 | κ local use 11 | -------------------------------------------------------------------------------- /src/styx/svcs/print.c: -------------------------------------------------------------------------------- 1 | #include "nine.h" 2 | 3 | static Lock fmtl; 4 | 5 | void 6 | _fmtlock(void) 7 | { 8 | lock(&fmtl); 9 | } 10 | 11 | void 12 | _fmtunlock(void) 13 | { 14 | unlock(&fmtl); 15 | } 16 | 17 | int 18 | _efgfmt(Fmt *f) 19 | { 20 | USED(f); 21 | return -1; 22 | } 23 | -------------------------------------------------------------------------------- /src/styx/utils/ndate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jvburnes/node9/a9226646a686b2e6458544b405d50daff8d1798b/src/styx/utils/ndate -------------------------------------------------------------------------------- /src/styx/utils/ndate.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void 4 | main(void) 5 | { 6 | ulong t; 7 | 8 | t = time(0); 9 | print("#define KERNDATE %lud\n", t); 10 | exits(0); 11 | } 12 | -------------------------------------------------------------------------------- /src/styx/utils/premake5.lua: -------------------------------------------------------------------------------- 1 | -- build support utils 2 | project "ndate" 3 | kind "ConsoleApp" 4 | targetdir(".") 5 | files {"ndate.c"} 6 | links {"9"} 7 | -------------------------------------------------------------------------------- /src/trace.c: -------------------------------------------------------------------------------- 1 | #define MAXMESSAGES 0x100 2 | #define MSGMASK (MAXMESSAGES-1) 3 | 4 | int64_t msgnum = -1; 5 | 6 | static char*[] messages[MAXMSGS]; 7 | static uint64_t timestamp[MAXMSGS]; 8 | static unsigned long tid[MAXMSGS]; 9 | 10 | 11 | void trace(char* msg) { 12 | ++msgnum; 13 | int64_t mnum = msgnum&MSGMASK; 14 | messages[mnum] = msg; 15 | timestamp[mnum] = uv_hrtime(); 16 | tid[mnum] = uv_thread_self(); 17 | } 18 | --------------------------------------------------------------------------------