OK, turing.

<- leave blank

Mon Jul 22 01:09:28 EDT 2024

diff fc859af624883111ad21311d50dd5ebfaad3b741 uncommitted
--- a/sys/src/libjson/json.c
+++ b/sys/src/libjson/json.c
@@ -1,6 +1,7 @@
 #include <u.h>
 #include <libc.h>
 #include <ctype.h>
+#include <bio.h>
 #include <json.h>

 typedef struct Lex Lex;
@@ -16,8 +17,9 @@

 struct Lex
 {
+ Biobuf *b;
	char *s;
- ulong slen;
+ int slen_;
	int t;
	double n;
	char *buf;
@@ -24,6 +26,22 @@
	Rune peeked;
 };

+static char*
+ensure(Lex *l, char *p)
+{
+ char *t;
+ int n;
+
+ n = p - l->buf;
+ if(n +UTFmax + 1< l->slen_)
+ return p;
+ l->slen_ += l->slen_/2 + 1;
+ if((t = realloc(l->buf, l->slen_)) == nil)
+ return nil;
+ l->buf = t;
+ return t + n;
+}
+
 static Rune
 getch(Lex *l)
 {
@@ -34,9 +52,15 @@
		l->peeked = 0;
		return r;
	}
- if(l->s[0] == '\0')
- return 0;
- l->s += chartorune(&r, l->s);
+ if(l->b != nil){
+ r = Bgetrune(l->b);
+ if(r == -1)
+ r = 0;
+ }else{
+ if(l->s[0] == '\0')
+ return 0;
+ l->s += chartorune(&r, l->s);
+ }
	return r;
 }

@@ -102,11 +126,11 @@
	if(r >= 0x80 || isalpha(r)){
		t = l->buf;
		for(;;){
- t += runetochar(t, &r);
- if(t >= l->buf + l->slen){
+ if((t = ensure(l, t)) == nil){
				werrstr("json: literal too long");
				return -1;
			}
+ t += runetochar(t, &r);
			r = peekch(l);
			if(r < 0x80 && !isalpha(r))
				break;
@@ -187,11 +211,11 @@
				}
			}
			r2 = 0;
- t += runetochar(t, &r);
- if(t >= l->buf + l->slen){
- werrstr("json: string too long");
+ if((t = ensure(l, t)) == nil){
+ werrstr("json: literal too long");
				return -1;
			}
+ t += runetochar(t, &r);
		}
		*t = 0;
		l->t = TSTRING;
@@ -315,6 +339,27 @@
 }

 JSON*
+jsonload(Biobuf *b)
+{
+ JSON *j;
+ Lex l;
+
+ memset(&l, 0, sizeof(l));
+ l.b = b;
+ l.buf = nil;
+ j = jsonobj(&l);
+ free(l.buf);
+
+ if(peeknonspace(&l) != 0){
+ jsonfree(j);
+ werrstr("json: unexpected trailing data");
+ return nil;
+ }
+ return j;
+
+}
+
+JSON*
 jsonparse(char *s)
 {
	JSON *j;
@@ -322,8 +367,8 @@

	memset(&l, 0, sizeof(l));
	l.s = s;
- l.slen = strlen(s);
- if((l.buf = mallocz(l.slen+UTFmax+1, 1)) == nil)
+ l.slen_ = strlen(s);
+ if((l.buf = mallocz(l.slen_+UTFmax+1, 1)) == nil)
		return nil;

	j = jsonobj(&l);


Sun Jul 21 03:28:04 EDT 2024
git.9front.org/plan9front/plan9front/b8986a889d7e3a445c0265c5cfb3b1db385db756/sys/doc/troff.pdf/raw



Sat Jul 20 14:38:12 EDT 2024
BEGIN { MAXGEN = 1500000; NONWORD = "\n"; w1 = w2 = NONWORD }
{ for(i = 1 ; i <= NF ; i++){ # read all words
		statetab[w1,w2,++nsuffix[w1,w2]] = $i
		w1 = w2
		w2 = $i
	}
}
END {
	statetab[w1,w2,++nsuffix[w1,w2]] = NONWORD # add tail
	w1 = w2 = NONWORD
	for(i = 0 ; i < MAXGEN ; i++){ # gen
		r = int(rand() * nsuffix[w1,w2]) + 1 # nsuffix >= 1
		p = statetab[w1,w2,r]
		if(p == NONWORD)
			exit
		print p
		w1 = w2 # advance chain
		w2 = p
	}
}


Sat Jul 20 12:27:54 EDT 2024
diff 23e7a571724aa78dd33ffdde9da1c0fa330c3aae uncommitted
--- a/sys/src/9/port/proc.c
+++ b/sys/src/9/port/proc.c
@@ -206,8 +206,6 @@
		return;
	}
	up = runproc();
- if(up->edf == nil)
- up->priority = reprioritize(up);
	if(up != m->readied)
		m->schedticks = m->ticks + HZ/10;
	m->readied = nil;
@@ -352,6 +350,10 @@
	int fairshare, n, load, ratio;

	updatecpu(p);
+
+ if(p->fixedpri)
+ return p->basepri;
+
	load = MACHP(0)->load;
	if(load == 0)
		return p->basepri;
@@ -404,7 +406,20 @@
		return -1;
	}
	p->state = Ready;
+
+ /*
+ * When the priority is very low (process is using
+ * more than its fair share) or when it has changed,
+ * reset processor affinity.
+ *
+ * This is to prevent a cpu from always picking
+ * a low priority process with affinity over
+ * a higher priority one without.
+ */
+ if(pri < 3 || pri != p->priority)
+ p->mp = nil;
	p->priority = pri;
+
	if(pri == PriEdf){
		Proc *pp, *l;

@@ -640,6 +655,8 @@
	if(edflock(p)){
		edfrun(p, rq == &runq[PriEdf]); /* start deadline timer and do
		admin */
		edfunlock();
+ } else {
+ p->priority = reprioritize(p);
	}
	pt = proctrace;
	if(pt != nil)
@@ -709,8 +726,9 @@
	p->lastlock = nil;
	p->lastilock = nil;
	p->nlocks = 0;
- p->delaysched = 0;
	p->trace = 0;
+ p->preempted = 0;
+ p->delaysched = 0;

	/* sched params */
	p->mp = nil;


Sat Jul 20 12:16:01 EDT 2024
a new market-based typesetting system that is affordable to learn

Sat Jul 20 04:56:30 EDT 2024
#include <stdio.h>

int main() {
    int x = 5;
    int y = (x++) + (x++);
    printf("y = %d\n", y);
    return 0;
}

Fri Jul 19 14:28:12 EDT 2024
/proc/7449/text:arm64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/arm64
acid: RenderBackend_CalcMask(s=0xbcf300)+0x190
/usr/mkf/tmp/src/cstory/src/Backends/Rendering/9front.cpp:216
	r=0x0
	w=0x321b000000280
	h=0x280000001e0
	m=0xcde4f8
	mask=0xe330f8
RenderBackend_Blit(colour_key=0x1,x=0x90,y=0xae,rect=0xc00b0,source_surface=0xbcf300,destination_surface=0xc1200)+0xec
/usr/mkf/tmp/src/cstory/src/Backends/Rendering/9front.cpp:240
	r=0x0
	r2=0xae00000090
PutBitmap3(surf_no=0x15,x=0x48,y=0x1000000057,rect=0x1c4108)+0x1a8
/usr/mkf/tmp/src/cstory/src/Draw.cpp:494
PutNpChar(fx=0x0,fy=0x0)+0x160 /usr/mkf/tmp/src/cstory/src/NpChar.cpp:374
	a=0xaa00000000
	n=0x372e8000000aa
ModeOpening()+0x178 /usr/mkf/tmp/src/cstory/src/Game.cpp:195
	wait=0x1
	frame_x=0x3925800000000
	frame_y=0x0
Game()+0x9c /usr/mkf/tmp/src/cstory/src/Game.cpp:729
	path=0x6d61672f7379732f
npe_main_renamed()+0x678 /usr/mkf/tmp/src/cstory/src/Main.cpp:351
	conf=0x0
	unused_rect=0x0
	window_icon_resource_size=0xe7
	window_icon_width=0xfefefefe00000090
	window_icon_height=0x9000000040
	window_icon_rgb_pixels=0x2440e0
	cursor_resource_size=0xfefefefe00000090
	cursor_width=0x2440e000000008
	cursor_height=0x800000040
	cursor_rgba_pixels=0x0
	rcLoading=0x0
	rcFull=0x0
threadmain(argv=0x1fffeff98,argc=0xfefefefe00000001)+0x28
/usr/mkf/tmp/src/npe/libnpe/_main.c:23
mainlauncher()+0x10 /sys/src/libthread/main.c:17
launcherarm64(arg=0x1fffeff98,f=0xa78ec)+0x8 /sys/src/libthread/arm64.c:8
launcherarm64(arg=0x1fffeff98,f=0xa78ec)+0xfffffffffffffff8
/sys/src/libthread/channel.c:583
RenderBackend_CalcMask+0x124
/usr/mkf/tmp/src/cstory/src/Backends/Rendering/9front.cpp:208
acid:
echo kill > /proc/7449/ctl


Fri Jul 19 12:19:37 EDT 2024
> (define ((foo bar) baz) (baz bar))
> ((foo 1) integer?)
#t
> (define (foo bar) (lambda (baz) (baz bar)))
> ((foo 1) integer?)
#t

Fri Jul 19 11:59:21 EDT 2024
diff 23e7a571724aa78dd33ffdde9da1c0fa330c3aae uncommitted
--- a/sys/src/cmd/ip/ipconfig/ipv6.c
+++ b/sys/src/cmd/ip/ipconfig/ipv6.c
@@ -662,8 +662,7 @@
	for(rr = &routelist; (r = *rr) != nil;){
		if(m > 100
		|| r->prefixlt != ~0UL && r->prefixlt < now-r->time
- || r->routerlt != ~0UL && r->routerlt < now-r->time
- || ipcmp(r->src, ra->src) == 0 && r->routerlt != 0 && conf.routerlt ==
0){
+ || r->routerlt != ~0UL && r->routerlt < now-r->time){
			DEBUG("purging RA from %I on %s; pfx %I %M",
				r->src, conf.dev, r->laddr, r->mask);
			if(!noconfig && validip(r->gaddr))
@@ -758,7 +757,7 @@
			}
		} else {
			seen = 0;
- if(conf.preflt == 0)
+ if(conf.validlt == 0)
				continue;
			r = malloc(sizeof(*r));
		}


Fri Jul 19 09:05:57 EDT 2024
(def- data
  [[75]
   [95 64]
   [17 47 82]
   [18 35 87 10]
   [20 04 82 47 65]
   [19 01 23 75 03 34]
   [88 02 77 73 07 63 67]
   [99 65 04 28 06 16 70 92]
   [41 41 26 56 83 40 80 70 33]
   [41 48 72 33 47 32 37 16 94 29]
   [53 71 44 65 25 43 91 52 97 51 14]
   [70 11 33 28 77 73 17 78 39 68 17 57]
   [91 71 52 38 17 14 91 43 58 50 27 29 48]
   [63 66 04 68 89 53 67 30 73 16 69 87 40 31]
   [04 62 98 27 23 09 70 98 73 93 38 53 60 04 23]])

(defn- car [l] (get l 0))
(defn- cdr [l] (slice l 1))
(defn- C [f y] (fn [x] (f x y)))
(defn- null?  [l] (= (length l) 0))

(defn- L [l i]
  (if (null?  l)
    @[0]
    (let [cur (get (car l) i)]
     (map (C + cur) (array/concat (L (cdr l) i) (L (cdr l) (+ i 1)))))))

(def- l (L data 0))

(print (apply max l))

Fri Jul 19 07:16:03 EDT 2024
(def- data
  [[75]
   [95 64]
   [17 47 82]
   [18 35 87 10]
   [20 04 82 47 65]
   [19 01 23 75 03 34]
   [88 02 77 73 07 63 67]
   [99 65 04 28 06 16 70 92]
   [41 41 26 56 83 40 80 70 33]
   [41 48 72 33 47 32 37 16 94 29]
   [53 71 44 65 25 43 91 52 97 51 14]
   [70 11 33 28 77 73 17 78 39 68 17 57]
   [91 71 52 38 17 14 91 43 58 50 27 29 48]
   [63 66 04 68 89 53 67 30 73 16 69 87 40 31]
   [04 62 98 27 23 09 70 98 73 93 38 53 60 04 23]])

(defn- car [l] (get l 0))
(defn- cdr [l] (slice l 1))
(defn- C [f y] (fn [x] (f x y)))
(defn- null?  [l] (= (length l) 0))

(defn- L [l i]
  (if (null?  l)
    [0]
    (let [cur (get (car l) i)]
      (array/concat (map (C + cur) (L (cdr l) i))
		    (map (C + cur) (L (cdr l) (+ i 1)))))))

(def- l (L data 0))

(print (apply max l))


prev | next