diff options
author | Valery Ushakov <uwe@stderr.spb.ru> | 2017-08-17 00:13:41 +0300 |
---|---|---|
committer | Valery Ushakov <uwe@stderr.spb.ru> | 2017-08-17 00:13:41 +0300 |
commit | 4a062f32e3dd93bf371feb27f3ccc28d7930099e (patch) | |
tree | 3f82934c7fd112eecc65efa0db68ed759028f76e | |
parent | c12c42236c5882afe34356ec8e4088a6ac9c3629 (diff) | |
parent | 8823998c509302a526d8711095f664dd06997234 (diff) |
Merged with inferno-os/inferno-os via default.
-rwxr-xr-x | MacOSX/386/bin/data2c | bin | 18596 -> 18624 bytes | |||
-rwxr-xr-x | MacOSX/386/bin/iyacc | bin | 50912 -> 50880 bytes | |||
-rwxr-xr-x | MacOSX/386/bin/mk | bin | 65152 -> 61052 bytes | |||
-rwxr-xr-x | MacOSX/386/bin/mkext | bin | 32252 -> 32276 bytes | |||
-rwxr-xr-x | Nt/386/bin/awk.exe | bin | 167936 -> 272896 bytes | |||
-rwxr-xr-x | Nt/386/bin/c2l.exe | bin | 254464 -> 284672 bytes | |||
-rwxr-xr-x | Nt/386/bin/cat.exe | bin | 52224 -> 95744 bytes | |||
-rwxr-xr-x | Nt/386/bin/cp.exe | bin | 69120 -> 108032 bytes | |||
-rwxr-xr-x | Nt/386/bin/data2c.exe | bin | 55808 -> 98304 bytes | |||
-rwxr-xr-x | Nt/386/bin/echo.exe | bin | 46592 -> 89088 bytes | |||
-rwxr-xr-x | Nt/386/bin/format.exe | bin | 79872 -> 118272 bytes | |||
-rwxr-xr-x | Nt/386/bin/iyacc.exe | bin | 97792 -> 135168 bytes | |||
-rwxr-xr-x | Nt/386/bin/mk.exe | bin | 124416 -> 166912 bytes | |||
-rwxr-xr-x | Nt/386/bin/mkdir.exe | bin | 48128 -> 91136 bytes | |||
-rwxr-xr-x | Nt/386/bin/mkext.exe | bin | 80384 -> 118784 bytes | |||
-rwxr-xr-x | Nt/386/bin/mv.exe | bin | 72704 -> 110080 bytes | |||
-rwxr-xr-x | Nt/386/bin/rcsh.exe | bin | 133120 -> 176640 bytes | |||
-rwxr-xr-x | Nt/386/bin/rm.exe | bin | 69120 -> 101888 bytes | |||
-rwxr-xr-x | Nt/386/bin/sed.exe | bin | 80896 -> 124416 bytes | |||
-rwxr-xr-x | Nt/386/bin/test.exe | bin | 71168 -> 105472 bytes | |||
-rwxr-xr-x | Nt/386/bin/tr.exe | bin | 52224 -> 95744 bytes | |||
-rwxr-xr-x | Nt/386/include/lib9.h | 4 | ||||
-rw-r--r-- | appl/cmd/limbo/typecheck.b | 4 | ||||
-rw-r--r-- | bitbucket-pipelines.yml | 10 | ||||
-rw-r--r-- | dis/lib/factotum.dis | bin | 7319 -> 7285 bytes | |||
-rw-r--r-- | dis/limbo.dis | bin | 343624 -> 343678 bytes | |||
-rw-r--r-- | dis/mount.dis | bin | 5602 -> 5568 bytes | |||
-rw-r--r-- | emu/Linux/asm-386.S | 52 | ||||
-rw-r--r-- | emu/Linux/asm-arm.S | 53 | ||||
-rw-r--r-- | emu/Linux/asm-mips.S | 30 | ||||
-rw-r--r-- | emu/Linux/asm-power.S | 33 | ||||
-rw-r--r-- | emu/Linux/asm-spim.S | 29 | ||||
-rw-r--r-- | emu/Linux/os-clone.c | 531 | ||||
-rw-r--r-- | emu/MacOSX/win.c | 2 | ||||
-rw-r--r-- | emu/Nt/r16.c | 90 | ||||
-rw-r--r-- | emu/Nt/win.c | 21 | ||||
-rw-r--r-- | emu/port/devpointer.c | 9 | ||||
-rw-r--r-- | emu/port/portmkfile | 20 | ||||
-rw-r--r-- | libinterp/runt.c | 2 | ||||
-rw-r--r-- | libmath/blas.c | 2 | ||||
-rw-r--r-- | limbo/typecheck.c | 4 | ||||
-rw-r--r-- | mkfiles/mkfile-Nt-386 | 2 | ||||
-rw-r--r-- | tools/libstyx/styxserver.c | 4 | ||||
-rw-r--r-- | utils/awk/missing95.c | 42 | ||||
-rw-r--r-- | utils/mk/Nt.c | 1 | ||||
-rw-r--r-- | utils/rcsh/rc.h | 1 |
46 files changed, 145 insertions, 801 deletions
diff --git a/MacOSX/386/bin/data2c b/MacOSX/386/bin/data2c Binary files differindex 897fab5a..011c76f6 100755 --- a/MacOSX/386/bin/data2c +++ b/MacOSX/386/bin/data2c diff --git a/MacOSX/386/bin/iyacc b/MacOSX/386/bin/iyacc Binary files differindex d5b0636d..39dc058f 100755 --- a/MacOSX/386/bin/iyacc +++ b/MacOSX/386/bin/iyacc diff --git a/MacOSX/386/bin/mk b/MacOSX/386/bin/mk Binary files differindex 543e8a25..da668229 100755 --- a/MacOSX/386/bin/mk +++ b/MacOSX/386/bin/mk diff --git a/MacOSX/386/bin/mkext b/MacOSX/386/bin/mkext Binary files differindex e0eceb79..7640e95c 100755 --- a/MacOSX/386/bin/mkext +++ b/MacOSX/386/bin/mkext diff --git a/Nt/386/bin/awk.exe b/Nt/386/bin/awk.exe Binary files differindex 77711a2c..6cfc878e 100755 --- a/Nt/386/bin/awk.exe +++ b/Nt/386/bin/awk.exe diff --git a/Nt/386/bin/c2l.exe b/Nt/386/bin/c2l.exe Binary files differindex c3e2e950..71baae87 100755 --- a/Nt/386/bin/c2l.exe +++ b/Nt/386/bin/c2l.exe diff --git a/Nt/386/bin/cat.exe b/Nt/386/bin/cat.exe Binary files differindex e9eb0d6c..ebd1b62d 100755 --- a/Nt/386/bin/cat.exe +++ b/Nt/386/bin/cat.exe diff --git a/Nt/386/bin/cp.exe b/Nt/386/bin/cp.exe Binary files differindex 1d8c6efe..849a5a63 100755 --- a/Nt/386/bin/cp.exe +++ b/Nt/386/bin/cp.exe diff --git a/Nt/386/bin/data2c.exe b/Nt/386/bin/data2c.exe Binary files differindex 9dfd90dd..7f8c6674 100755 --- a/Nt/386/bin/data2c.exe +++ b/Nt/386/bin/data2c.exe diff --git a/Nt/386/bin/echo.exe b/Nt/386/bin/echo.exe Binary files differindex c2fcf3d8..442b7110 100755 --- a/Nt/386/bin/echo.exe +++ b/Nt/386/bin/echo.exe diff --git a/Nt/386/bin/format.exe b/Nt/386/bin/format.exe Binary files differindex 3b99b70f..cd921c82 100755 --- a/Nt/386/bin/format.exe +++ b/Nt/386/bin/format.exe diff --git a/Nt/386/bin/iyacc.exe b/Nt/386/bin/iyacc.exe Binary files differindex d0d21e30..204e4643 100755 --- a/Nt/386/bin/iyacc.exe +++ b/Nt/386/bin/iyacc.exe diff --git a/Nt/386/bin/mk.exe b/Nt/386/bin/mk.exe Binary files differindex 1674cbe8..20a11aff 100755 --- a/Nt/386/bin/mk.exe +++ b/Nt/386/bin/mk.exe diff --git a/Nt/386/bin/mkdir.exe b/Nt/386/bin/mkdir.exe Binary files differindex 29dad0b4..ea938e56 100755 --- a/Nt/386/bin/mkdir.exe +++ b/Nt/386/bin/mkdir.exe diff --git a/Nt/386/bin/mkext.exe b/Nt/386/bin/mkext.exe Binary files differindex e49a5376..41a03d1a 100755 --- a/Nt/386/bin/mkext.exe +++ b/Nt/386/bin/mkext.exe diff --git a/Nt/386/bin/mv.exe b/Nt/386/bin/mv.exe Binary files differindex c664c77e..dd3a6c70 100755 --- a/Nt/386/bin/mv.exe +++ b/Nt/386/bin/mv.exe diff --git a/Nt/386/bin/rcsh.exe b/Nt/386/bin/rcsh.exe Binary files differindex 0af9618b..947e3cb0 100755 --- a/Nt/386/bin/rcsh.exe +++ b/Nt/386/bin/rcsh.exe diff --git a/Nt/386/bin/rm.exe b/Nt/386/bin/rm.exe Binary files differindex a7f85e7d..34f05b54 100755 --- a/Nt/386/bin/rm.exe +++ b/Nt/386/bin/rm.exe diff --git a/Nt/386/bin/sed.exe b/Nt/386/bin/sed.exe Binary files differindex 8aa45f0e..d086fffa 100755 --- a/Nt/386/bin/sed.exe +++ b/Nt/386/bin/sed.exe diff --git a/Nt/386/bin/test.exe b/Nt/386/bin/test.exe Binary files differindex d90a0ba1..14d92c5d 100755 --- a/Nt/386/bin/test.exe +++ b/Nt/386/bin/test.exe diff --git a/Nt/386/bin/tr.exe b/Nt/386/bin/tr.exe Binary files differindex a079480e..eaf728aa 100755 --- a/Nt/386/bin/tr.exe +++ b/Nt/386/bin/tr.exe diff --git a/Nt/386/include/lib9.h b/Nt/386/include/lib9.h index d10c51ed..fd48f043 100755 --- a/Nt/386/include/lib9.h +++ b/Nt/386/include/lib9.h @@ -16,7 +16,11 @@ #define strtod infstrtod #define strtoll infstrtoll #define strtoull infstrtoull +#ifndef INFERNO_KEEPENVIRON +/* environ is perfectly legal as the name of a local, field name or struct, but windows redefines it */ +/* the extern char** environ is only needed by two programs, so #undef it for everything else */ #undef environ +#endif /* do-it-yourself isinf and isnan */ #ifndef isnan diff --git a/appl/cmd/limbo/typecheck.b b/appl/cmd/limbo/typecheck.b index 5629500b..88060840 100644 --- a/appl/cmd/limbo/typecheck.b +++ b/appl/cmd/limbo/typecheck.b @@ -759,9 +759,11 @@ concheck(n: ref Node, isglobal: int) exname(d: ref Decl): string { s := ""; - m := impmods.sym; + m: ref Sym; if(d.dot != nil) m = d.dot.sym; + else if(impmods != nil) + m = impmods.sym; if(m != nil) s += m.name+"."; if(fndec != nil) diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml new file mode 100644 index 00000000..2cc07efb --- /dev/null +++ b/bitbucket-pipelines.yml @@ -0,0 +1,10 @@ +image: i386/gcc:6.1 + +pipelines: + default: + - step: + script: + - PATH=$PATH:$PWD/Linux/386/bin MKFLAGS='SYSHOST=Linux OBJTYPE=386 ROOT='$PWD + - mk $MKFLAGS mkdirs + - mk $MKFLAGS emuinstall + - emu cat /dev/sysctl || echo ' -' exited with status $? '(ignored)' diff --git a/dis/lib/factotum.dis b/dis/lib/factotum.dis Binary files differindex e994c9cd..789a1dd6 100644 --- a/dis/lib/factotum.dis +++ b/dis/lib/factotum.dis diff --git a/dis/limbo.dis b/dis/limbo.dis Binary files differindex 0bf51ff0..b4e3acac 100644 --- a/dis/limbo.dis +++ b/dis/limbo.dis diff --git a/dis/mount.dis b/dis/mount.dis Binary files differindex 9593dc47..1666bb5f 100644 --- a/dis/mount.dis +++ b/dis/mount.dis diff --git a/emu/Linux/asm-386.S b/emu/Linux/asm-386.S index 31946335..fe5ce6c1 100644 --- a/emu/Linux/asm-386.S +++ b/emu/Linux/asm-386.S @@ -1,59 +1,7 @@ .file "asm-Linux-386.S" -#include "syscall.h" .text /* - * executeonnewstack(void *tos, void (*tramp)(void *arg), void *arg) - */ - - .type executeonnewstack,@function - .global executeonnewstack -executeonnewstack: - pushl %ebp - movl %esp, %ebp - pushl %esi - - movl 8(%ebp), %esi /* get tos */ - subl $4, %esi - movl 16(%ebp), %eax - movl %eax, (%esi) /* stash arg on new stack */ - subl $4, %esi - movl 12(%ebp), %eax - movl %eax, (%esi) /* stash tramp on new stack */ - mov %esi, %esp /* swap stacks pronto */ - popl %eax /* recover the tramp address */ - subl %ebp, %ebp /* stop stack traceback here */ - call *%eax /* and jump to it (ho ho) */ - - /* if we return here, tramp didn't do its job */ - - addl $8, %esp /* clean up for pose value */ - - leal SYS_exit, %eax - int $0x80 - -/* - * unlockandexit(int *key) - * - * NB: the return status may be garbaged if the stack is reused - * between the unlock and the system call, but this should - * not matter since no task is waiting for the result - */ - - .type unlockandexit,@function - .global unlockandexit -unlockandexit: - pushl %ebp - movl %esp, %ebp - - movl 8(%ebp), %esi /* get the key address */ - pushl $0 /* exit status 0 */ - movl $0, %eax /* unlock the stack allocator */ - movl %eax, (%esi) - leal SYS_exit, %eax /* call exit */ - int $0x80 - -/* * umult(ulong m1, ulong m2, ulong *hi) */ diff --git a/emu/Linux/asm-arm.S b/emu/Linux/asm-arm.S index 90a337ff..5446dde6 100644 --- a/emu/Linux/asm-arm.S +++ b/emu/Linux/asm-arm.S @@ -1,60 +1,7 @@ .file "asm-Linux-arm.S" -#include "syscall.h" .text /* - * void executeonnewstack(void *tos, void (*tramp)(void *arg), void *arg) - */ - - .align 2 - .global executeonnewstack - .type executeonnewstack, %function -executeonnewstack: - @ args = 0, pretend = 0, frame = 12 - @ frame_needed = 1, uses_anonymous_args = 0 - mov ip, sp - stmfd sp!, {fp, ip, lr, pc} - sub fp, ip, #4 - sub sp, sp, #12 - str r0, [fp, #-16] /* store tos */ - str r1, [fp, #-20] /* store tramp */ - str r2, [fp, #-24] /* store arg */ - ldr r0, [fp, #-24] /* get arg */ - ldr r2, [fp, #-16] /* get tos */ - mov sp, r2 /* set new stack */ - mov lr, pc - blx r1 /* call tramp*/ - - /* if we return here, tramp didn't do it's job */ - mov r0, #0 - mov r7, #SYS_exit - swi 0x0 - ldmea fp, {fp, sp, pc} - .size executeonnewstack, .-executeonnewstack - -/* - * void unlockandexit(int *key) - */ - - .align 2 - .global unlockandexit - .type unlockandexit, %function -unlockandexit: - @ args = 0, pretend = 0, frame = 4 - @ frame_needed = 1, uses_anonymous_args = 0 - mov ip, sp - stmfd sp!, {fp, ip, lr, pc} - sub fp, ip, #4 - sub sp, sp, #4 - mov r1, #0 - str r1, [r0] - mov r0, #0 - mov r7, #SYS_exit - swi 0x0 - ldmea fp, {fp, sp, pc} - .size unlockandexit, .-unlockandexit - -/* * ulong umult(ulong m1, ulong m2, ulong *hi) */ diff --git a/emu/Linux/asm-mips.S b/emu/Linux/asm-mips.S index 087b8550..d2780f6a 100644 --- a/emu/Linux/asm-mips.S +++ b/emu/Linux/asm-mips.S @@ -1,37 +1,7 @@ -#include "syscall.h" #include <sys/asm.h> #include <sys/regdef.h> #include <asm/cachectl.h> -/* - * executeonnewstack(void *tos, void (*tramp)(void *arg), void *arg) - */ - -LEAF(executeonnewstack) - and a0,a0,~7 - addu sp,a0,-16 - move a0,a2 - move t9,a1 - jalr t9 - - li v0,SYS_exit - li a0,0 - syscall - - END(executeonnewstack) - -/* - * unlockandexit(int *key) - */ - -LEAF(unlockandexit) - lw a1,0(a0) - li v0,SYS_exit - li a0,0 - sw a0,0(a1) - syscall - END(unlockandexit) - LEAF(FPsave) cfc1 t0, $31 sw t0, 0(a0) /* a0 is argument */ diff --git a/emu/Linux/asm-power.S b/emu/Linux/asm-power.S index 6af21fba..7187f938 100644 --- a/emu/Linux/asm-power.S +++ b/emu/Linux/asm-power.S @@ -59,36 +59,3 @@ _tas: 2: sync blr - -/* - * void - * executeonnewstack(void *tos, void (*tramp)(void *arg), void *arg) - */ - .align 2 - .global executeonnewstack -executeonnewstack: - mr %r1,%r3 /* change stacks */ - stwu %lr,-16(%r1) /* save lr to aid the traceback */ - li %r0,0 - stw %r0,20(%r1) - mr %r3,%r5 - mtctr %r4 - bctrl /* tramp(arg) */ - br - -/* - * void unlockandexit(int *key) - * - * NB: the return status may be garbaged if the stack is reused - * between the unlock and the system call, but this should - * not matter since no task is waiting for the result - */ - .align 2 - .globl unlockandexit -unlockandexit: - li %r0,0x0 - stw %r0,0(%r3) /* unlock */ - li %r0,1 /* sys exit; 234 is exit group */ - li %r3,0 /* exit status */ - sc - br diff --git a/emu/Linux/asm-spim.S b/emu/Linux/asm-spim.S index 087b8550..77ae3d4c 100644 --- a/emu/Linux/asm-spim.S +++ b/emu/Linux/asm-spim.S @@ -1,36 +1,7 @@ -#include "syscall.h" #include <sys/asm.h> #include <sys/regdef.h> #include <asm/cachectl.h> -/* - * executeonnewstack(void *tos, void (*tramp)(void *arg), void *arg) - */ - -LEAF(executeonnewstack) - and a0,a0,~7 - addu sp,a0,-16 - move a0,a2 - move t9,a1 - jalr t9 - - li v0,SYS_exit - li a0,0 - syscall - - END(executeonnewstack) - -/* - * unlockandexit(int *key) - */ - -LEAF(unlockandexit) - lw a1,0(a0) - li v0,SYS_exit - li a0,0 - sw a0,0(a1) - syscall - END(unlockandexit) LEAF(FPsave) cfc1 t0, $31 diff --git a/emu/Linux/os-clone.c b/emu/Linux/os-clone.c deleted file mode 100644 index 992235d4..00000000 --- a/emu/Linux/os-clone.c +++ /dev/null @@ -1,531 +0,0 @@ -#include <sys/types.h> -#include <time.h> -#include <termios.h> -#include <signal.h> -#include <pwd.h> -#include <sched.h> -#include <sys/resource.h> -#include <sys/wait.h> -#include <sys/time.h> - -#include <stdint.h> - -#include "dat.h" -#include "fns.h" -#include "error.h" - -#include <semaphore.h> - -#include <raise.h> - -/* glibc 2.3.3-NTPL messes up getpid() by trying to cache the result, so we'll do it ourselves */ -#include <sys/syscall.h> -#define getpid() syscall(SYS_getpid) - -/* temporarily suppress CLONE_PTRACE so it works on broken Linux kernels */ -#undef CLONE_PTRACE -#define CLONE_PTRACE 0 - -enum -{ - DELETE = 0x7f, - CTRLC = 'C'-'@', - NSTACKSPERALLOC = 16, - X11STACK= 256*1024 -}; -char *hosttype = "Linux"; - -extern void unlockandexit(int*); -extern void executeonnewstack(void*, void (*f)(void*), void*); - -static void *stackalloc(Proc *p, void **tos); -static void stackfreeandexit(void *stack); - -typedef sem_t Sem; - -extern int dflag; - -int gidnobody = -1; -int uidnobody = -1; -static struct termios tinit; - -void -pexit(char *msg, int t) -{ - Osenv *e; - Proc *p; - Sem *sem; - void *kstack; - - lock(&procs.l); - p = up; - if(p->prev) - p->prev->next = p->next; - else - procs.head = p->next; - - if(p->next) - p->next->prev = p->prev; - else - procs.tail = p->prev; - unlock(&procs.l); - - if(0) - print("pexit: %s: %s\n", p->text, msg); - - e = p->env; - if(e != nil) { - closefgrp(e->fgrp); - closepgrp(e->pgrp); - closeegrp(e->egrp); - closesigs(e->sigs); - free(e->user); - } - kstack = p->kstack; - free(p->prog); - sem = p->os; - if(sem != nil) - sem_destroy(sem); - free(p->os); - free(p); - if(kstack != nil) - stackfreeandexit(kstack); -} - -int -tramp(void *arg) -{ - Proc *p; - p = arg; - p->pid = p->sigid = getpid(); - (*p->func)(p->arg); - pexit("{Tramp}", 0); - return 0; /* not reached */ -} - -void -kproc(char *name, void (*func)(void*), void *arg, int flags) -{ - Proc *p; - Pgrp *pg; - Fgrp *fg; - Egrp *eg; - void *tos; - Sem *sem; - - p = newproc(); - if(0) - print("start %s:%#p\n", name, p); - if(p == nil) - panic("kproc(%s): no memory", name); - - sem = malloc(sizeof(*sem)); - if(sem == nil) - panic("can't allocate semaphore"); - sem_init(sem, 0, 0); - p->os = sem; - - if(flags & KPDUPPG) { - pg = up->env->pgrp; - incref(&pg->r); - p->env->pgrp = pg; - } - if(flags & KPDUPFDG) { - fg = up->env->fgrp; - incref(&fg->r); - p->env->fgrp = fg; - } - if(flags & KPDUPENVG) { - eg = up->env->egrp; - incref(&eg->r); - p->env->egrp = eg; - } - - p->env->uid = up->env->uid; - p->env->gid = up->env->gid; - kstrdup(&p->env->user, up->env->user); - - strcpy(p->text, name); - - p->func = func; - p->arg = arg; - - if(flags & KPX11){ - p->kstack = nil; /* never freed; also up not defined */ - tos = (char*)mallocz(X11STACK, 0) + X11STACK - sizeof(vlong); - }else - p->kstack = stackalloc(p, &tos); - - lock(&procs.l); - if(procs.tail != nil) { - p->prev = procs.tail; - procs.tail->next = p; - } - else { - procs.head = p; - p->prev = nil; - } - procs.tail = p; - unlock(&procs.l); - - if(clone(tramp, tos, CLONE_PTRACE|CLONE_VM|CLONE_FS|CLONE_FILES|SIGCHLD, p, nil, nil, nil) <= 0) - panic("kproc: clone failed"); -} - -static void -sysfault(char *what, void *addr) -{ - char buf[64]; - - snprint(buf, sizeof(buf), "sys: %s%#p", what, addr); - disfault(nil, buf); -} - -static void -trapILL(int signo, siginfo_t *si, void *a) -{ - USED(signo); - USED(a); - sysfault("illegal instruction pc=", si->si_addr); -} - -static int -isnilref(siginfo_t *si) -{ - return si != 0 && (si->si_addr == (void*)~(uintptr_t)0 || (uintptr_t)si->si_addr < 512); -} - -static void -trapmemref(int signo, siginfo_t *si, void *a) -{ - USED(a); /* ucontext_t*, could fetch pc in machine-dependent way */ - if(isnilref(si)) - disfault(nil, exNilref); - else if(signo == SIGBUS) - sysfault("bad address addr=", si->si_addr); /* eg, misaligned */ - else - sysfault("segmentation violation addr=", si->si_addr); -} - -static void -trapFPE(int signo, siginfo_t *si, void *a) -{ - char buf[64]; - - USED(signo); - USED(a); - snprint(buf, sizeof(buf), "sys: fp: exception status=%.4lux pc=%#p", getfsr(), si->si_addr); - disfault(nil, buf); -} - -static void -trapUSR1(int signo) -{ - int intwait; - - USED(signo); - - intwait = up->intwait; - up->intwait = 0; /* clear it to let proc continue in osleave */ - - if(up->type != Interp) /* Used to unblock pending I/O */ - return; - - if(intwait == 0) /* Not posted so it's a sync error */ - disfault(nil, Eintr); /* Should never happen */ -} - -/* called to wake up kproc blocked on a syscall */ -void -oshostintr(Proc *p) -{ - kill(p->sigid, SIGUSR1); -} - -void -osblock(void) -{ - Sem *sem; - - sem = up->os; - while(sem_wait(sem)) - {} /* retry on signals (which shouldn't happen) */ -} - -void -osready(Proc *p) -{ - sem_post(p->os); -} - -void -oslongjmp(void *regs, osjmpbuf env, int val) -{ - USED(regs); - siglongjmp(env, val); -} - -static void -termset(void) -{ - struct termios t; - - tcgetattr(0, &t); - tinit = t; - t.c_lflag &= ~(ICANON|ECHO|ISIG); - t.c_cc[VMIN] = 1; - t.c_cc[VTIME] = 0; - tcsetattr(0, TCSANOW, &t); -} - -static void -termrestore(void) -{ - tcsetattr(0, TCSANOW, &tinit); -} - -void -cleanexit(int x) -{ - USED(x); - - if(up->intwait) { - up->intwait = 0; - return; - } - - if(dflag == 0) - termrestore(); - - kill(0, SIGKILL); - exit(0); -} - -void -osreboot(char *file, char **argv) -{ - if(dflag == 0) - termrestore(); - execvp(file, argv); - error("reboot failure"); -} - -void -libinit(char *imod) -{ - struct sigaction act; - struct passwd *pw; - Proc *p; - void *tos; - char sys[64]; - - setsid(); - - gethostname(sys, sizeof(sys)); - kstrdup(&ossysname, sys); - pw = getpwnam("nobody"); - if(pw != nil) { - uidnobody = pw->pw_uid; - gidnobody = pw->pw_gid; - } - - if(dflag == 0) - termset(); - - memset(&act, 0, sizeof(act)); - act.sa_handler = trapUSR1; - sigaction(SIGUSR1, &act, nil); - - act.sa_handler = SIG_IGN; - sigaction(SIGCHLD, &act, nil); - - /* - * For the correct functioning of devcmd in the - * face of exiting slaves - */ - signal(SIGPIPE, SIG_IGN); - if(signal(SIGTERM, SIG_IGN) != SIG_IGN) - signal(SIGTERM, cleanexit); - if(signal(SIGINT, SIG_IGN) != SIG_IGN) - signal(SIGINT, cleanexit); - - if(sflag == 0) { - act.sa_flags = SA_SIGINFO; - act.sa_sigaction = trapILL; - sigaction(SIGILL, &act, nil); - act.sa_sigaction = trapFPE; - sigaction(SIGFPE, &act, nil); - act.sa_sigaction = trapmemref; - sigaction(SIGBUS, &act, nil); - sigaction(SIGSEGV, &act, nil); - act.sa_flags &= ~SA_SIGINFO; - } - - p = newproc(); - p->kstack = stackalloc(p, &tos); - - pw = getpwuid(getuid()); - if(pw != nil) - kstrdup(&eve, pw->pw_name); - else - print("cannot getpwuid\n"); - - p->env->uid = getuid(); - p->env->gid = getgid(); - - executeonnewstack(tos, emuinit, imod); -} - -int -readkbd(void) -{ - int n; - char buf[1]; - - n = read(0, buf, sizeof(buf)); - if(n < 0) - print("keyboard close (n=%d, %s)\n", n, strerror(errno)); - if(n <= 0) - pexit("keyboard thread", 0); - - switch(buf[0]) { - case '\r': - buf[0] = '\n'; - break; - case DELETE: - buf[0] = 'H' - '@'; - break; - case CTRLC: - cleanexit(0); - break; - } - return buf[0]; -} - -/* - * Return an abitrary millisecond clock time - */ -long -osmillisec(void) -{ - static long sec0 = 0, usec0; - struct timeval t; - - if(gettimeofday(&t,(struct timezone*)0)<0) - return 0; - - if(sec0 == 0) { - sec0 = t.tv_sec; - usec0 = t.tv_usec; - } - return (t.tv_sec-sec0)*1000+(t.tv_usec-usec0+500)/1000; -} - -/* - * Return the time since the epoch in nanoseconds and microseconds - * The epoch is defined at 1 Jan 1970 - */ -vlong -osnsec(void) -{ - struct timeval t; - - gettimeofday(&t, nil); - return (vlong)t.tv_sec*1000000000L + t.tv_usec*1000; -} - -vlong -osusectime(void) -{ - struct timeval t; - - gettimeofday(&t, nil); - return (vlong)t.tv_sec * 1000000 + t.tv_usec; -} - -int -osmillisleep(ulong milsec) -{ - struct timespec time; - - time.tv_sec = milsec/1000; - time.tv_nsec= (milsec%1000)*1000000; - nanosleep(&time, NULL); - return 0; -} - -int -limbosleep(ulong milsec) -{ - return osmillisleep(milsec); -} - -void -osyield(void) -{ - sched_yield(); -} - -void -ospause(void) -{ - for(;;) - pause(); -} - -void -oslopri(void) -{ - setpriority(PRIO_PROCESS, 0, getpriority(PRIO_PROCESS,0)+4); -} - -static struct { - Lock l; - void *free; -} stacklist; - -static void -_stackfree(void *stack) -{ - *((void **)stack) = stacklist.free; - stacklist.free = stack; -} - -static void -stackfreeandexit(void *stack) -{ - lock(&stacklist.l); - _stackfree(stack); - unlockandexit(&stacklist.l.val); -} - -static void * -stackalloc(Proc *p, void **tos) -{ - void *rv; - lock(&stacklist.l); - if (stacklist.free == 0) { - int x; - /* - * obtain some more by using sbrk() - */ - void *more = sbrk(KSTACK * (NSTACKSPERALLOC + 1)); - if (more == 0) - panic("stackalloc: no more stacks"); - /* - * align to KSTACK - */ - more = (void *)((((unsigned long)more) + (KSTACK - 1)) & ~(KSTACK - 1)); - /* - * free all the new stacks onto the freelist - */ - for (x = 0; x < NSTACKSPERALLOC; x++) - _stackfree((char *)more + KSTACK * x); - } - rv = stacklist.free; - stacklist.free = *(void **)rv; - unlock(&stacklist.l); - *tos = rv + KSTACK - sizeof(vlong); - *(Proc **)rv = p; - return rv; -} diff --git a/emu/MacOSX/win.c b/emu/MacOSX/win.c index ffe54a6b..6f8a7e52 100644 --- a/emu/MacOSX/win.c +++ b/emu/MacOSX/win.c @@ -4,7 +4,7 @@ #define Rect _Rect #include <Carbon/Carbon.h> -#include <QuickTime/QuickTime.h> // for full screen +//#include <QuickTime/QuickTime.h> // for full screen #undef Rect #undef Point diff --git a/emu/Nt/r16.c b/emu/Nt/r16.c index 92a36521..ba0ceb0d 100644 --- a/emu/Nt/r16.c +++ b/emu/Nt/r16.c @@ -9,26 +9,16 @@ #include "error.h" #include "r16.h" -#define Bit(i) (7-(i)) -/* N 0's preceded by i 1's, T(Bit(2)) is 1100 0000 */ -#define T(i) (((1 << (Bit(i)+1))-1) ^ 0xFF) -/* 0000 0000 0000 0111 1111 1111 */ -#define RuneX(i) ((1 << (Bit(i) + ((i)-1)*Bitx))-1) - enum { - Bitx = Bit(1), - - Tx = T(1), /* 1000 0000 */ - Rune1 = (1<<(Bit(0)+0*Bitx))-1, /* 0000 0000 0000 0000 0111 1111 */ - - Maskx = (1<<Bitx)-1, /* 0011 1111 */ - Testx = Maskx ^ 0xFF, /* 1100 0000 */ + Bits10 = 0x03ff, /* 0011 1111 1111 */ - SurrogateMin = 0xD800, - SurrogateMax = 0xDFFF, + R16self = 0x10000, - Bad = Runeerror, + HSurrogateMin = 0xd800, + HSurrogateMax = 0xdbff, + LSurrogateMin = 0xdc00, + LSurrogateMax = 0xdfff, }; Rune16* @@ -60,22 +50,27 @@ char* runes16toutf(char *p, Rune16 *r, int nc) { char *op, *ep; - int n, c; - Rune rc; + int n; + Rune c, lc; op = p; ep = p + nc; while(c = *r++) { - n = 1; - if(c >= Runeself) - n = runelen(c); + if(c > Runemax) + c = Runeerror; + if(c >= LSurrogateMin && c <= LSurrogateMax) + c = Runeerror; + if(c >= HSurrogateMin && c<= HSurrogateMax){ + lc = *r++; + if(lc >= LSurrogateMin || lc <= LSurrogateMax) + c = (c&Bits10)<<10 | (lc&Bits10) + R16self; + else + c = Runeerror; + } + n = runelen(c); if(p + n >= ep) break; - rc = c; - if(c < Runeself) - *p++ = c; - else - p += runetochar(p, &rc); + p += runetochar(p, &c); } *p = '\0'; return op; @@ -84,20 +79,18 @@ runes16toutf(char *p, Rune16 *r, int nc) int rune16nlen(Rune16 *r, int nrune) { - int nb, i; + int nb; Rune c; nb = 0; while(nrune--) { c = *r++; - if(c <= Rune1){ - nb++; - } else { - for(i = 2; i < UTFmax + 1; i++) - if(c <= RuneX(i) || i == UTFmax){ - nb += i; - break; - } + if(c < R16self) + nb += runelen(c); + else { + c -= R16self; + nb += runelen(HSurrogateMin | (c>>10)); + nb += runelen(LSurrogateMin | (c&Bits10)); } } return nb; @@ -113,7 +106,17 @@ utftorunes16(Rune16 *r, char *p, int nc) er = r + nc; while(*p != '\0' && r + 1 < er){ p += chartorune(&rc, p); - *r++ = rc; /* we'll ignore surrogate pairs */ + if(rc < R16self){ + *r++ = rc; + continue; + } + if(rc > Runemax || er-r < 2){ + *r++ = Runeerror; + continue; + } + rc -= R16self; + *r++ = HSurrogateMin | (rc>>10); + *r++ = LSurrogateMin | (rc&Bits10); } *r = '\0'; return or; @@ -167,8 +170,17 @@ int widebytes(wchar_t *ws) { int n = 0; - - while (*ws) - n += runelen(*ws++); + wchar_t c; + + while (*ws){ + c = *ws++; + if(c < R16self) + n += runelen(c); + else { + c -= R16self; + n += runelen(HSurrogateMin | (c>>10)); + n += runelen(LSurrogateMin | (c&Bits10)); + } + } return n+1; } diff --git a/emu/Nt/win.c b/emu/Nt/win.c index c1bccfa7..b1480fd7 100644 --- a/emu/Nt/win.c +++ b/emu/Nt/win.c @@ -308,6 +308,7 @@ WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) LPMINMAXINFO mmi; LONG x, y, w, h, b; HCURSOR dcurs; + POINT m; switch(msg) { case WM_SETCURSOR: @@ -320,6 +321,15 @@ WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) dcurs = LoadCursor(NULL, IDC_ARROW); SetCursor(dcurs); break; + case WM_MOUSEWHEEL: + if((int)wparam>0) + b = 8; + else + b = 16; + m.x = LOWORD(lparam); + m.y = HIWORD(lparam); + ScreenToClient(hwnd, &m); + goto mok; case WM_LBUTTONDBLCLK: b = (1<<8) | 1; goto process; @@ -338,8 +348,9 @@ WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) case WM_RBUTTONDOWN: b = 0; process: - x = LOWORD(lparam); - y = HIWORD(lparam); + m.x = LOWORD(lparam); + m.y = HIWORD(lparam); + mok: if(wparam & MK_LBUTTON) b |= 1; if(wparam & MK_MBUTTON) @@ -350,7 +361,7 @@ WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) else b |= 4; //right button } - mousetrack(b, x, y, 0); + mousetrack(b, m.x, m.y, 0); break; case WM_SYSKEYDOWN: if(gkscanq) @@ -446,10 +457,6 @@ WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) gkbdputc(gkbdq, wparam); break; case WM_CLOSE: - // no longer used? - //m.b = 128; - //m.modify = 1; - //mousetrack(128, 0, 0, 1); DestroyWindow(hwnd); break; case WM_DESTROY: diff --git a/emu/port/devpointer.c b/emu/port/devpointer.c index 30bad028..0590c2cc 100644 --- a/emu/port/devpointer.c +++ b/emu/port/devpointer.c @@ -74,15 +74,6 @@ mousetrack(int b, int x, int y, int isdelta) y += mouse.v.y; } msec = osmillisec(); - if(0 && b && (mouse.v.b ^ b)&0x1f){ - if(msec - mouse.v.msec < 300 && mouse.lastb == b - && abs(mouse.v.x - x) < 12 && abs(mouse.v.y - y) < 12) - b |= 1<<8; - mouse.lastb = b & 0x1f; - mouse.v.msec = msec; - } - if((b&(1<<8))==0 && x == mouse.v.x && y == mouse.v.y && mouse.v.b == b) - return; lastb = mouse.v.b; mouse.v.x = x; mouse.v.y = y; diff --git a/emu/port/portmkfile b/emu/port/portmkfile index b17818c6..04e8b145 100644 --- a/emu/port/portmkfile +++ b/emu/port/portmkfile @@ -51,21 +51,21 @@ i$CONF.acid: i$CONF lib%.a:V: $SHELLTYPE-lib%.a rc-lib%.a nt-lib%.a:VQ: - echo '@{builtin cd' $ROOT/lib$stem '; mk SHELLTYPE=$SHELLTYPE SYSTARG=$SYSTARG OBJTYPE=$OBJTYPE install}' - @{builtin cd $ROOT/lib$stem; mk 'SHELLTYPE='$SHELLTYPE 'SYSTARG='$SYSTARG 'OBJTYPE='$OBJTYPE install} + echo '@{builtin cd' $ROOT/lib$stem '; mk $MKFLAGS SHELLTYPE=$SHELLTYPE SYSTARG=$SYSTARG OBJTYPE=$OBJTYPE install}' + @{builtin cd $ROOT/lib$stem; mk $MKFLAGS 'SHELLTYPE='$SHELLTYPE 'SYSTARG='$SYSTARG 'OBJTYPE='$OBJTYPE install} sh-lib%.a:VQ: - echo "(cd $ROOT/lib$stem ; mk SHELLTYPE=$SHELLTYPE SYSTARG=$SYSTARG OBJTYPE=$OBJTYPE install)" - (cd $ROOT/lib$stem; mk 'SHELLTYPE='$SHELLTYPE 'SYSTARG='$SYSTARG 'OBJTYPE='$OBJTYPE install) + echo "(cd $ROOT/lib$stem ; mk $MKFLAGS SHELLTYPE=$SHELLTYPE SYSTARG=$SYSTARG OBJTYPE=$OBJTYPE install)" + (cd $ROOT/lib$stem; mk $MKFLAGS 'SHELLTYPE='$SHELLTYPE 'SYSTARG='$SYSTARG 'OBJTYPE='$OBJTYPE install) %-rc %-nt:V: for(i in $CONFLIST) - mk 'CONF='$i $stem + mk 'CONF='$i $MKFLAGS $stem %-sh:V: for i in $CONFLIST do - mk 'CONF='$i $stem + mk 'CONF='$i $MKFLAGS $stem done clean:V: cleanconf-$SHELLTYPE @@ -88,15 +88,15 @@ cleanconf-nt:V: nuke-sh:QV: for i in $LIBDIRS do - echo "(cd $ROOT/lib$i ; mk SHELLTYPE=$SHELLTYPE SYSTARG=$SYSTARG OBJTYPE=$OBJTYPE nuke)" - (cd $ROOT/lib$i; mk 'SHELLTYPE='$SHELLTYPE 'SYSTARG='$SYSTARG 'OBJTYPE='$OBJTYPE nuke) + echo "(cd $ROOT/lib$i ; mk $MKFLAGS SHELLTYPE=$SHELLTYPE SYSTARG=$SYSTARG OBJTYPE=$OBJTYPE nuke)" + (cd $ROOT/lib$i; mk $MKFLAGS 'SHELLTYPE='$SHELLTYPE 'SYSTARG='$SYSTARG 'OBJTYPE='$OBJTYPE nuke) done nuke-rc nuke-nt:QV: for (i in $LIBDIRS) { - echo '@{cd $ROOT/lib$i ; mk SHELLTYPE=$SHELLTYPE SYSTARG=$SYSTARG OBJTYPE=$OBJTYPE nuke}' - @{cd $ROOT/lib$i; mk 'SHELLTYPE='$SHELLTYPE 'SYSTARG='$SYSTARG 'OBJTYPE='$OBJTYPE nuke} + echo '@{cd $ROOT/lib$i ; mk $MKFLAGS SHELLTYPE=$SHELLTYPE SYSTARG=$SYSTARG OBJTYPE=$OBJTYPE nuke}' + @{cd $ROOT/lib$i; mk $MKFLAGS 'SHELLTYPE='$SHELLTYPE 'SYSTARG='$SYSTARG 'OBJTYPE='$OBJTYPE nuke} } nuke:V: clean nuke-$SHELLTYPE diff --git a/libinterp/runt.c b/libinterp/runt.c index 81a5490b..977d642c 100644 --- a/libinterp/runt.c +++ b/libinterp/runt.c @@ -376,7 +376,7 @@ Sys_char2byte(void *fp) c = f->c; if(a == H || (UWORD)n>=a->len) error(exBounds); - if(c<0 || c>=(1<<16)) + if(c<0 || c>=Runemax) c = Runeerror; if(c < Runeself){ a->data[n] = c; diff --git a/libmath/blas.c b/libmath/blas.c index e40d2310..4e005674 100644 --- a/libmath/blas.c +++ b/libmath/blas.c @@ -58,5 +58,5 @@ norm2(int n, double *x) sum += *x * *x; x++; } - return sum; + return sqrt(sum); } diff --git a/limbo/typecheck.c b/limbo/typecheck.c index 52e0295d..ce3da87b 100644 --- a/limbo/typecheck.c +++ b/limbo/typecheck.c @@ -873,9 +873,11 @@ exname(Decl *d) n = 0; sprint(buf, "%d", scope-ScopeGlobal); - m = impmods->sym; + m = nil; if(d->dot) m = d->dot->sym; + else if(impmods) + m = impmods->sym; if(m) n += strlen(m->name)+1; if(fndec) diff --git a/mkfiles/mkfile-Nt-386 b/mkfiles/mkfile-Nt-386 index 8bfe66d1..90fdb256 100644 --- a/mkfiles/mkfile-Nt-386 +++ b/mkfiles/mkfile-Nt-386 @@ -24,7 +24,7 @@ CFLAGS= -c\ -W3\ -Zi\ -MT\ - -D_WIN32_WINNT=0x0400\ + -D_WIN32_WINNT=0x0600\ -I$ROOT/Nt/386/include\ -I$ROOT/include\ $XCFLAGS\ diff --git a/tools/libstyx/styxserver.c b/tools/libstyx/styxserver.c index 34257349..96700280 100644 --- a/tools/libstyx/styxserver.c +++ b/tools/libstyx/styxserver.c @@ -72,9 +72,9 @@ styxfatal(char *fmt, ...) } static void -styxassert(int true, char *reason) +styxassert(int vtrue, char *reason) { - if(!true) + if(!vtrue) styxfatal("assertion failed: %s\n", reason); } diff --git a/utils/awk/missing95.c b/utils/awk/missing95.c index 64138ade..4daa8d2e 100644 --- a/utils/awk/missing95.c +++ b/utils/awk/missing95.c @@ -10,3 +10,45 @@ FILE *popen(char *s, char *m) { int pclose(FILE *f) { return _pclose(f); /* return NULL; */ } + +#include <windows.h> +#include <winbase.h> +#include <winsock.h> + +/* system doesn't work properly in some 32/64 (WoW64) combinations */ +int system(char *s) { + int status, n; + PROCESS_INFORMATION pinfo; + STARTUPINFO si; + char *cmd; + char app[256]; + static char cmdexe[] = "\\cmd.exe"; + + memset(&si, 0, sizeof(si)); + si.cb = sizeof(si); +// si.dwFlags = STARTF_USESHOWWINDOW; +// si.wShowWindow = SW_SHOW; + + n = GetSystemDirectory(app, sizeof(app)-sizeof(cmdexe)); + if(n > sizeof(app)) + return -1; + strcat_s(app, sizeof(app), cmdexe); + n = strlen(s)+20; + cmd = malloc(n); + if(cmd == NULL) + return -1; + strcpy_s(cmd, n, "cmd.exe /c"); + strcat_s(cmd, n, s); + if(!CreateProcess(app, cmd, NULL, NULL, TRUE, CREATE_DEFAULT_ERROR_MODE, NULL/* env*/, NULL /*wdir*/, &si, &pinfo)){ + fprintf(stderr, "can't create process %s %d\n", s, GetLastError()); + free(cmd); + return -1; + } + free(cmd); + if(WaitForSingleObject(pinfo.hProcess, INFINITE) == WAIT_FAILED) + return -1; + if(!GetExitCodeProcess(pinfo.hProcess, &status)) + status = 1; + //fprintf(stderr, "status %d\n", status); + return status; +} diff --git a/utils/mk/Nt.c b/utils/mk/Nt.c index c2250762..93955f9a 100644 --- a/utils/mk/Nt.c +++ b/utils/mk/Nt.c @@ -1,3 +1,4 @@ +#define INFERNO_KEEPENVIRON #include "mk.h" #include <signal.h> #include <sys/utime.h> diff --git a/utils/rcsh/rc.h b/utils/rcsh/rc.h index f7d56746..d01150a6 100644 --- a/utils/rcsh/rc.h +++ b/utils/rcsh/rc.h @@ -1,3 +1,4 @@ +#define INFERNO_KEEPENVIRON #include <lib9.h> #define Lock Rclock |