erts: Move all inet tcp CONNECTED timers to multi timer

--- erts/emulator/drivers/common/inet_drv.c
+++ erts/emulator/drivers/common/inet_drv.c
@@ -1010,6 +1010,9 @@
 static void fire_multi_timers(MultiTimerData **first, ErlDrvPort port,
 			      ErlDrvData data);
 static void remove_multi_timer(MultiTimerData **first, ErlDrvPort port, MultiTimerData *p);
+static void cancel_multi_timer(MultiTimerData **first, ErlDrvPort port,
+                               void (*timeout_fun)(ErlDrvData drv_data,
+                                                   ErlDrvTermData caller));

 static void tcp_inet_multi_timeout(ErlDrvData e, ErlDrvTermData caller);
 static void clean_multi_timers(MultiTimerData **first, ErlDrvPort port);
@@ -9779,15 +9782,14 @@
 	    driver_demonitor_process(desc->inet.port, &monitor);
 	    send_async_error(desc->inet.dport, id, caller, am_closed);
 	}
-	clean_multi_timers(&(desc->mtd), desc->inet.port);
-    }
-
+    }
     else if (desc->inet.state == INET_STATE_CONNECTING) {
 	async_error_am(INETP(desc), am_closed);
     }
     else if (desc->inet.state == INET_STATE_CONNECTED) {
 	async_error_am_all(INETP(desc), am_closed);
     }
+    clean_multi_timers(&(desc->mtd), desc->inet.port);
 }

 /*
@@ -9828,6 +9830,15 @@
     tcp_clear_output(desc);

     erl_inet_close(INETP(desc));
+}
+
+static void tcp_inet_recv_timeout(ErlDrvData e, ErlDrvTermData dummy)
+{
+    tcp_descriptor* desc = (tcp_descriptor*)e;
+    ASSERT(!desc->inet.active);
+    sock_select(INETP(desc),(FD_READ|FD_CLOSE),0);
+    desc->i_remain = 0;
+    async_error_am(INETP(desc), am_timeout);
 }

 /* TCP requests from Erlang */
@@ -10117,7 +10128,8 @@
 		async_error_am(INETP(desc), am_timeout);
 	    else {
 		if (timeout != INET_INFINITY)
-		    driver_set_timer(desc->inet.port, timeout);
+                    add_multi_timer(&(desc->mtd), INETP(desc)->port, 0,
+                                    timeout, &tcp_inet_recv_timeout);
 		if (!INETP(desc)->is_ignored)
 		    sock_select(INETP(desc),(FD_READ|FD_CLOSE),1);
 		else
@@ -10223,12 +10235,27 @@

 }

+static void tcp_inet_send_timeout(ErlDrvData e, ErlDrvTermData dummy)
+{
+    tcp_descriptor* desc = (tcp_descriptor*)e;
+    ASSERT(IS_BUSY(INETP(desc)));
+    ASSERT(desc->busy_on_send);
+    desc->inet.caller = desc->inet.busy_caller;
+    desc->inet.state &= ~INET_F_BUSY;
+    desc->busy_on_send = 0;
+    set_busy_port(desc->inet.port, 0);
+    inet_reply_error_am(INETP(desc), am_timeout);
+    if (desc->send_timeout_close) {
+        tcp_desc_close(desc);
+    }
+}
+
 /*
 ** tcp_inet_timeout:
 ** called when timer expire:
 ** TCP socket may be:
 **
-** a)  receiving   -- deselect
+** a)  receiving   -- send timeout
 ** b)  connecting  -- close socket
 ** c)  accepting   -- reset listener
 **
@@ -10244,24 +10271,7 @@
     if ((state & INET_F_MULTI_CLIENT)) { /* Multi-client always means multi-timers */
 	fire_multi_timers(&(desc->mtd), desc->inet.port, e);
     } else if ((state & INET_STATE_CONNECTED) == INET_STATE_CONNECTED) {
-	if (desc->busy_on_send) {
-	    ASSERT(IS_BUSY(INETP(desc)));
-	    desc->inet.caller = desc->inet.busy_caller;
-	    desc->inet.state &= ~INET_F_BUSY;
-	    desc->busy_on_send = 0;
-	    set_busy_port(desc->inet.port, 0);
-	    inet_reply_error_am(INETP(desc), am_timeout);
-	    if (desc->send_timeout_close) {
-		tcp_desc_close(desc);
-	    }
-	}
-	else {
-	    /* assume recv timeout */
-	    ASSERT(!desc->inet.active);
-	    sock_select(INETP(desc),(FD_READ|FD_CLOSE),0);
-	    desc->i_remain = 0;
-	    async_error_am(INETP(desc), am_timeout);
-	}
+        fire_multi_timers(&(desc->mtd), desc->inet.port, e);
     }
     else if ((state & INET_STATE_CONNECTING) == INET_STATE_CONNECTING) {
 	/* assume connect timeout */
@@ -10429,7 +10439,7 @@
 	desc->inet.caller = desc->inet.busy_caller;
 	tcp_clear_output(desc);
 	if (desc->busy_on_send) {
-	    driver_cancel_timer(desc->inet.port);
+            cancel_multi_timer(&(desc->mtd), INETP(desc)->port, &tcp_inet_send_timeout);
 	    desc->busy_on_send = 0;
 	    DEBUGF(("tcp_recv_closed(%ld): busy on send\r\n", port));
 	}
@@ -10444,9 +10454,10 @@
          */
         desc->tcp_add_flags |= TCP_ADDF_DELAYED_CLOSE_SEND;
     }
+
     if (!desc->inet.active) {
-	/* We must cancel any timer here ! */
-	driver_cancel_timer(desc->inet.port);
+        /* We must cancel any timer here ! */
+        clean_multi_timers(&(desc->mtd), INETP(desc)->port);
 	/* passive mode do not terminate port ! */
 	tcp_clear_input(desc);
 	if (desc->inet.exitf) {
@@ -10481,7 +10492,7 @@
 	    desc->inet.caller = desc->inet.busy_caller;
 	    tcp_clear_output(desc);
 	    if (desc->busy_on_send) {
-		driver_cancel_timer(desc->inet.port);
+                cancel_multi_timer(&(desc->mtd), INETP(desc)->port, &tcp_inet_send_timeout);
 		desc->busy_on_send = 0;
 	    }
 	    desc->inet.state &= ~INET_F_BUSY;
@@ -10490,7 +10501,7 @@
 	}
 	if (!desc->inet.active) {
 	    /* We must cancel any timer here ! */
-	    driver_cancel_timer(desc->inet.port);
+            clean_multi_timers(&(desc->mtd), INETP(desc)->port);
 	    tcp_clear_input(desc);
 	    if (desc->inet.exitf) {
 		tcp_desc_close(desc);
@@ -10595,13 +10606,13 @@
     if (len == 0) {
 	/* empty buffer or waiting for more input */
 	if ((desc->i_buf == NULL) || (desc->i_remain > 0))
-	    return count;
+	    return 0;
 	if ((n = tcp_remain(desc, &len)) != 0) {
 	    if (n < 0) /* packet error */
 		return n;
 	    if (len > 0)  /* more data pending */
 		desc->i_remain = len;
-	    return count;
+	    return 0;
 	}
     }

@@ -10653,9 +10664,7 @@
 	len = 0;

 	if (!desc->inet.active) {
-	    if (!desc->busy_on_send) {
-		driver_cancel_timer(desc->inet.port);
-	    }
+            cancel_multi_timer(&(desc->mtd), INETP(desc)->port, &tcp_inet_recv_timeout);
 	    sock_select(INETP(desc),(FD_READ|FD_CLOSE),0);
 	    if (desc->i_buf != NULL)
 		tcp_restart_input(desc);
@@ -10681,7 +10690,7 @@
     int len;
     int nread;

-    if (desc->i_buf == NULL) {  /* allocte a read buffer */
+    if (desc->i_buf == NULL) {  /* allocate a read buffer */
 	int sz = (request_len > 0) ? request_len : desc->inet.bufsz;

 	if ((desc->i_buf = alloc_buffer(sz)) == NULL)
@@ -10754,10 +10763,11 @@
 	    return tcp_deliver(desc, desc->i_ptr - desc->i_ptr_start);
     }
     else {
-	if ((nread = tcp_remain(desc, &len)) < 0)
+        nread = tcp_remain(desc, &len);
+	if (nread < 0)
 	    return tcp_recv_error(desc, EMSGSIZE);
 	else if (nread == 0)
-	    return tcp_deliver(desc, len);
+            return tcp_deliver(desc, len);
 	else if (len > 0)
 	    desc->i_remain = len;  /* set remain */
     }
@@ -11135,8 +11145,8 @@
     if (IS_BUSY(INETP(desc))) {
 	desc->inet.caller = desc->inet.busy_caller;
 	if (desc->busy_on_send) {
-	    driver_cancel_timer(desc->inet.port);
-	    desc->busy_on_send = 0;
+            cancel_multi_timer(&(desc->mtd), INETP(desc)->port, &tcp_inet_send_timeout);
+	    desc->busy_on_send = 0;
 	}
 	desc->inet.state &= ~INET_F_BUSY;
 	set_busy_port(desc->inet.port, 0);
@@ -11288,7 +11298,9 @@
 	    set_busy_port(desc->inet.port, 1);
 	    if (desc->send_timeout != INET_INFINITY) {
 		desc->busy_on_send = 1;
-		driver_set_timer(desc->inet.port, desc->send_timeout);
+                add_multi_timer(&(desc->mtd), INETP(desc)->port,
+                                0 /* arg */, desc->send_timeout /* timeout */,
+                                &tcp_inet_send_timeout);
 	    }
 	    return 1;
 	}
@@ -11386,7 +11398,9 @@
 	    set_busy_port(desc->inet.port, 1);
 	    if (desc->send_timeout != INET_INFINITY) {
 		desc->busy_on_send = 1;
-		driver_set_timer(desc->inet.port, desc->send_timeout);
+                add_multi_timer(&(desc->mtd), INETP(desc)->port,
+                                0 /* arg */, desc->send_timeout /* timeout */,
+                                &tcp_inet_send_timeout);
 	    }
 	    return 1;
 	}
@@ -11490,7 +11504,8 @@

             /* if we have a timer then cancel and send ok to client */
             if (desc->busy_on_send) {
-                driver_cancel_timer(desc->inet.port);
+                cancel_multi_timer(&(desc->mtd), INETP(desc)->port,
+                                   &tcp_inet_send_timeout);
                 desc->busy_on_send = 0;
             }

@@ -11822,7 +11837,7 @@
 		    set_busy_port(desc->inet.port, 0);
 		    /* if we have a timer then cancel and send ok to client */
 		    if (desc->busy_on_send) {
-			driver_cancel_timer(desc->inet.port);
+                        cancel_multi_timer(&(desc->mtd), INETP(desc)->port, &tcp_inet_send_timeout);
 			desc->busy_on_send = 0;
 		    }
 		    inet_reply_ok(INETP(desc));
@@ -12634,7 +12649,7 @@
 		udesc->i_buf = NULL;
 		if (!desc->active) {
 		    async_error(desc, err);
-		    driver_cancel_timer(desc->port);
+                    driver_cancel_timer(desc->port);
 		    sock_select(desc,FD_READ,0);
 		}
 		else {
@@ -12723,7 +12738,7 @@
 		return count;
 	    count++;
 	    if (!desc->active) {
-		driver_cancel_timer(desc->port); /* possibly cancel */
+                driver_cancel_timer(desc->port);
 		sock_select(desc,FD_READ,0);
 		return count;  /* passive mode (read one packet only) */
 	    }
@@ -12806,26 +12821,28 @@
 			      ErlDrvData data)
 {
     ErlDrvTime next_timeout;
-    if (!*first) {
+    MultiTimerData *curr = *first;
+    if (!curr) {
 	ASSERT(0);
 	return;
     }
 #ifdef DEBUG
     {
 	ErlDrvTime chk = erl_drv_monotonic_time(ERL_DRV_MSEC);
-	ASSERT(chk >= (*first)->when);
+	ASSERT(chk >= curr->when);
     }
 #endif
     do {
-	MultiTimerData *save = *first;
-	*first = save->next;
+	MultiTimerData *save = curr;
+        *first = save->next;
+	curr = *first;
 	(*(save->timeout_function))(data,save->caller);
 	FREE(save);
-	if (*first == NULL) {
+	if (curr == NULL) {
 	    return;
 	}
-	(*first)->prev = NULL;
-	next_timeout = (*first)->when - erl_drv_monotonic_time(ERL_DRV_MSEC);
+	curr->prev = NULL;
+	next_timeout = curr->when - erl_drv_monotonic_time(ERL_DRV_MSEC);
     } while (next_timeout <= 0);
     driver_set_timer(port, (unsigned long) next_timeout);
 }
@@ -12862,6 +12879,20 @@
     FREE(p);
 }

+/* Cancel a timer based on the timeout_fun */
+static void cancel_multi_timer(MultiTimerData **first, ErlDrvPort port,
+                               void (*timeout_fun)(ErlDrvData drv_data,
+                                                   ErlDrvTermData caller))
+{
+    MultiTimerData *timer = *first;
+    while(timer && timer->timeout_function != timeout_fun) {
+        timer = timer->next;
+    }
+    if (timer) {
+        remove_multi_timer(first, port, timer);
+    }
+}
+
 static MultiTimerData *add_multi_timer(MultiTimerData **first, ErlDrvPort port,
 				       ErlDrvTermData caller, unsigned timeout,
 				       void (*timeout_fun)(ErlDrvData drv_data,
@@ -12869,7 +12900,7 @@
 {
     MultiTimerData *mtd, *p, *s;
     mtd = ALLOC(sizeof(MultiTimerData));
-    mtd->when = erl_drv_monotonic_time(ERL_DRV_MSEC) + ((ErlDrvTime) timeout) + 1;
+    mtd->when = erl_drv_monotonic_time(ERL_DRV_MSEC) + ((ErlDrvTime) timeout);
     mtd->timeout_function = timeout_fun;
     mtd->caller = caller;
     mtd->next = mtd->prev = NULL;


printf() now can print numbers >= 0x80000000 (bigger than 32 (or 31?) bit number). Int num was changed to unsigned long num.

Also features some minor changes to spelling etc. A major printf revision would be nice..

--- src/clib/stdio.c
+++ src/clib/stdio.c
@@ -12,7 +12,7 @@

 void printf(const char *fmt, ...) {
 unsigned char *pos;
-int num = 0;
+unsigned long num = 0;
 int print_int = 0;
 va_list args;
 va_start(args, fmt);
@@ -41,7 +41,7 @@
 		case 'x': // hex, change the base
 			radix = 16;
 		case 'd':
-			num = va_arg(args, unsigned int);
+			num = va_arg(args, unsigned long);
 			print_int = 1;
 			break;

@@ -69,21 +69,17 @@
 if (print_int == 1) {
 // a simple writech(num) would print the number corresponding to the hex ascii value
 /* This is basically a bad itoa function */
+
 /* get the numbers in reverse order */
 int help = 0, help2 = 0, help3 = 0;
-unsigned char helpstring[]="xxxxxxxxxxx";
-/*
-if (num == 127) {
-	printf("!!!\n");
-	num = 126;
-	}
-*/
-// this loop through numbers higher than 10
+unsigned char *helpstring = 0;
+
+// this loops through numbers higher than 10
 while (num / radix > 0) {
 	help3 = num % radix + '0';
 	if (help3 > '9') // it's a hex!
 		help3 = help3 + 7; // make it a number, '9' + 7 = 'A' (10 in hex)
-	helpstring[help++] = help3;
+	helpstring[help++] = help3;
 	num = num / radix;
 	help2++;
 	}
@@ -92,11 +88,12 @@
 help3 = num % radix + '0';
 if (help3 > '9') // it's a hex!
 	help3 = help3 + 7; // make it a number
-helpstring[help++] = help3;
+helpstring[help++] = help3;

 /* reverse to original order */
 int temp = 0, first = 0;
 int last = help2;
+

 while (first < last) {
 	temp = helpstring[first];
@@ -105,7 +102,8 @@
 	last--;
 	first++;
 	}
-/* now, print*/
+
+/* now, print*/
 help = 0;
 last = help2;
 pos = helpstring;


better ratio calcuration

better ratio calcuration

--- src/clock_icon.c
+++ src/clock_icon.c
@@ -2,13 +2,13 @@
 #include "common.h"

-#define CLOCK_CENTER_RADIUS     3
-#define CLOCK_HAND_NARROW_RATIO (4.f / 20.f)
-#define CLOCK_HOUR_HAND_RATIO   (12.f / 20.f)
-#define CLOCK_MIN_HAND_RATIO    (18.f / 20.f)
-#define CLOCK_SEC_HAND_RATIO    (18.f / 20.f)
-#define CLOCK_HOUR_MARK_RATIO   (4.f / 20.f)
-#define CLOCK_MIN_MARK_RATIO    (1.f / 20.f)
+#define CLOCK_CENTER_RADIUS             3
+#define CLOCK_HAND_NARROW_LENGTH(r)     ((r) * 4 / 20)
+#define CLOCK_HOUR_HAND_LENGTH(r)       ((r) * 12 / 20)
+#define CLOCK_MIN_HAND_LENGTH(r)        ((r) * 18 / 20)
+#define CLOCK_SEC_HAND_LENGTH(r)        ((r) * 18 / 20)
+#define CLOCK_HOUR_MARK_START_LENGTH(r) ((r) * 16 / 20)
+#define CLOCK_MIN_MARK_START_LENGTH(r)  ((r) * 19 / 20)

 static clock_icon_data *clock_icon_data_get(ClockIcon *aIcon) {
@@ -66,7 +66,7 @@

 static void draw_clock_hand(GContext *aCtx, GPoint aCenter, int32_t aRadius,
         bool aZoomedIn, int32_t aHandLen, int32_t aAngle) {
-    int32_t handLen2 = aRadius * CLOCK_HAND_NARROW_RATIO;
+    int32_t handLen2 = CLOCK_HAND_NARROW_LENGTH(aRadius);
     if (aZoomedIn) {
         draw_angle_line(aCtx, aCenter, aAngle, CLOCK_CENTER_RADIUS, handLen2, LineWidth1);
         draw_angle_line(aCtx, aCenter, aAngle, handLen2, aHandLen, LineWidth3);
@@ -95,7 +95,7 @@
         graphics_context_set_stroke_color(aCtx, GColorWhite);
         for (int32_t i = 0; i < 60; ++i) {
             int32_t len1 = radius;
-            int32_t len2 = radius * (1.f - ((i % 5 == 0) ? CLOCK_HOUR_MARK_RATIO : CLOCK_MIN_MARK_RATIO));
+            int32_t len2 = (i % 5 == 0) ? CLOCK_HOUR_MARK_START_LENGTH(radius) : CLOCK_MIN_MARK_START_LENGTH(radius);
             int32_t angle = TRIG_MAX_ANGLE * i / 60.f;
             draw_angle_line(aCtx, center, angle, len1, len2,
                 (i % 5 == 0) ? LineWidth2 : LineWidth1);
@@ -116,16 +116,16 @@

     // 時針
     draw_clock_hand(aCtx, center, radius, zoomedIn,
-        radius * CLOCK_HOUR_HAND_RATIO,
+        CLOCK_HOUR_HAND_LENGTH(radius),
         TRIG_MAX_ANGLE * (h + m / 60.f) / 12.f);

     // 分針
     draw_clock_hand(aCtx, center, radius, zoomedIn,
-        radius * CLOCK_MIN_HAND_RATIO,
+        CLOCK_MIN_HAND_LENGTH(radius),
         TRIG_MAX_ANGLE * (m + s / 60.f) / 60.f);

     // 秒針
-    int32_t secLength = radius * CLOCK_SEC_HAND_RATIO;
+    int32_t secLength = CLOCK_SEC_HAND_LENGTH(radius);
     int32_t secAngle = TRIG_MAX_ANGLE * s / 60.f;
     if (zoomedIn) {
         draw_angle_line(aCtx, center, secAngle, CLOCK_CENTER_RADIUS, secLength, LineWidth1);


another shift bug

another shift bug

R=r
OCL=19525
CL=19525

--- src/cmd/6g/gen.c
+++ src/cmd/6g/gen.c
@@ -6,7 +6,6 @@
 #undef	EXTERN
 #define	EXTERN
 #include "gg.h"
-//#include "opt.h"

 enum
 {
@@ -93,17 +92,17 @@
 	gclean();
 	checklabels();

+	if(curfn->type->outtuple != 0) {
+		gins(ACALL, N, throwreturn);
+	}
+
+	pc->as = ARET;	// overwrite AEND
+	pc->lineno = lineno;
+
 //	if(debug['N']) {
 //		regopt(ptxt);
 //		debug['N'] = 0;
 //	}
-
-	if(curfn->type->outtuple != 0) {
-		gins(ACALL, N, throwreturn);
-	}
-
-	pc->as = ARET;	// overwrite AEND
-	pc->lineno = lineno;

 	// fill in argument size
 	ptxt->to.offset = rnd(curfn->type->argwid, maxround);
@@ -1212,7 +1211,13 @@
 	if(nr->op == OLITERAL) {
 		regalloc(&n1, nl->type, res);
 		cgen(nl, &n1);
-		gins(a, nr, &n1);
+		if(mpgetfix(nr->val.u.xval) >= nl->type->width*8) {
+			// large shift gets 2 shifts by width
+			nodconst(&n3, types[TUINT32], nl->type->width*8-1);
+			gins(a, &n3, &n1);
+			gins(a, &n3, &n1);
+		} else
+			gins(a, nr, &n1);
 		gmove(&n1, res);
 		regfree(&n1);
 		goto ret;


6l: change default output name to 6.out.exe on windows

R=golang-dev, vcc.163
CC=golang-dev
http://codereview.appspot.com/4670049

--- src/cmd/6l/obj.c
+++ src/cmd/6l/obj.c
@@ -84,7 +84,7 @@
 	listinit();
 	memset(debug, 0, sizeof(debug));
 	nerrors = 0;
-	outfile = "6.out";
+	outfile = nil;
 	HEADTYPE = -1;
 	INITTEXT = -1;
 	INITDAT = -1;
@@ -134,10 +134,19 @@
 	if(argc != 1)
 		usage();

-	libinit();
+	mywhatsys();	// get goos

 	if(HEADTYPE == -1)
 		HEADTYPE = headtype(goos);
+
+	if(outfile == nil) {
+		if(HEADTYPE == Hwindows)
+			outfile = "6.out.exe";
+		else
+			outfile = "6.out";
+	}
+
+	libinit();

 	switch(HEADTYPE) {
 	default:


cmd/8g: eliminate obviously useless temps before regopt.

This patch introduces a sort of pre-regopt peephole optimization.
When a temporary is introduced that just holds a value for the
duration of the next instruction and is otherwise unused, we
elide it to make the job of regopt easier.

Since x86 has very few registers, this situation happens very
often. The result is large savings in stack variables for
arithmetic-heavy functions.

crypto/aes

benchmark                 old ns/op    new ns/op    delta
BenchmarkEncrypt               1301          392  -69.87%
BenchmarkDecrypt               1309          368  -71.89%
BenchmarkExpand                2913         1036  -64.44%
benchmark                  old MB/s     new MB/s  speedup
BenchmarkEncrypt              12.29        40.74    3.31x
BenchmarkDecrypt              12.21        43.37    3.55x

crypto/md5

benchmark                 old ns/op    new ns/op    delta
BenchmarkHash8Bytes            1761          914  -48.10%
BenchmarkHash1K               16912         5570  -67.06%
BenchmarkHash8K              123895        38286  -69.10%
benchmark                  old MB/s     new MB/s  speedup
BenchmarkHash8Bytes            4.54         8.75    1.93x
BenchmarkHash1K               60.55       183.83    3.04x
BenchmarkHash8K               66.12       213.97    3.24x

bench/go1

benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    8364835000   8303154000   -0.74%
BenchmarkFannkuch11      7511723000   6381729000  -15.04%
BenchmarkGobDecode         27764090     27103270   -2.38%
BenchmarkGobEncode         11240880     11184370   -0.50%
BenchmarkGzip            1470224000    856668400  -41.73%
BenchmarkGunzip           240660800    201697300  -16.19%
BenchmarkJSONEncode       155225800    185571900  +19.55%
BenchmarkJSONDecode       243347900    282123000  +15.93%
BenchmarkMandelbrot200     12240970     12201880   -0.32%
BenchmarkParse              8837445      8765210   -0.82%
BenchmarkRevcomp         2556310000   1868566000  -26.90%
BenchmarkTemplate         389298000    379792000   -2.44%
benchmark                  old MB/s     new MB/s  speedup
BenchmarkGobDecode            27.64        28.32    1.02x
BenchmarkGobEncode            68.28        68.63    1.01x
BenchmarkGzip                 13.20        22.65    1.72x
BenchmarkGunzip               80.63        96.21    1.19x
BenchmarkJSONEncode           12.50        10.46    0.84x
BenchmarkJSONDecode            7.97         6.88    0.86x
BenchmarkParse                 6.55         6.61    1.01x
BenchmarkRevcomp              99.43       136.02    1.37x
BenchmarkTemplate              4.98         5.11    1.03x

Fixes issue 4035.

R=golang-dev, minux.ma, rsc
CC=golang-dev
http://codereview.appspot.com/6828056

--- src/cmd/8g/reg.c
+++ src/cmd/8g/reg.c
@@ -40,6 +40,7 @@
 static	int	first	= 1;

 static	void	fixjmp(Prog*);
+static	void	fixtemp(Prog*);

 Reg*
 rega(void)
@@ -135,6 +136,7 @@
 		first = 0;
 	}

+	fixtemp(firstp);
 	fixjmp(firstp);

 	// count instructions
@@ -1692,3 +1694,122 @@
 		print("\n");
 	}
 }
+
+static uint32
+fnv1(Sym *sym)
+{
+	uint32 h;
+	char *s;
+
+	h = 2166136261U;
+	for(s=sym->name;*s;s++) {
+		h = (16777619 * h) ^ (uint32)(uint8)(*s);
+	}
+	return h;
+}
+
+static uint16
+hash32to16(uint32 h)
+{
+	return (h & 0xffff) ^ (h >> 16);
+}
+
+/*
+ * fixtemp eliminates sequences like:
+ *   MOV reg1, mem
+ *   OP mem, reg2
+ * when mem is a stack variable which is not mentioned
+ * anywhere else. The instructions are replaced by
+ *   OP reg1, reg2
+ * this reduces the number of variables that the register optimizer
+ * sees, which lets it do a better job and makes it less likely to turn
+ * itself off.
+ */
+void
+fixtemp(Prog *firstp)
+{
+	static uint8 counts[1<<16]; // A hash table to count variable occurences.
+	int i;
+	Prog *p, *p2;
+	uint32 h;
+
+	if(debug['R'] && debug['v'])
+		print("\nfixtemp\n");
+
+	// Count variable references. We actually use a hashtable so this
+	// is only approximate.
+	for(i=0; i<nelem(counts); i++)
+		counts[i] = 0;
+	for(p=firstp; p!=P; p=p->link) {
+		if(p->from.type == D_AUTO) {
+			h = hash32to16(fnv1(p->from.sym));
+			//print("seen %S hash %d\n", p->from.sym, hash32to16(h));
+			if(counts[h] < 10)
+				counts[h]++;
+		}
+		if(p->to.type == D_AUTO) {
+			h = hash32to16(fnv1(p->to.sym));
+			//print("seen %S hash %d\n", p->to.sym, hash32to16(h));
+			if(counts[h] < 10)
+				counts[h]++;
+		}
+	}
+
+	// Eliminate single-write, single-read stack variables.
+	for(p=firstp; p!=P; p=p->link) {
+		if(debug['R'] && debug['v'])
+			print("%P\n", p);
+		if(p->link == P
+			|| !RtoB(p->from.type)
+			|| p->to.type != D_AUTO
+			|| isfloat[p->to.etype])
+			continue;
+		switch(p->as) {
+		case AMOVB:
+			if(p->to.width == 1)
+				break;
+		case AMOVW:
+			if(p->to.width == 2)
+				break;
+		case AMOVL:
+			if(p->to.width == 4)
+				break;
+		default:
+			continue;
+		}
+		// p is a MOV reg, mem.
+		// and it is not a float.
+		p2 = p->link;
+		h = hash32to16(fnv1(p->to.sym));
+		if(counts[h] != 2) {
+			continue;
+		}
+		switch(p2->as) {
+		case ALEAL:
+		case AFMOVL:
+		case AFMOVW:
+		case AFMOVV:
+			// funny
+			continue;
+		}
+		// p2 is OP mem, reg2
+		// and OP is not a funny instruction.
+		if(p2->from.sym == p->to.sym
+			&& p2->from.offset == p->to.offset
+			&& p2->from.type == p->to.type) {
+			if(debug['R'] && debug['v']) {
+				print(" ===elide== %D\n", &p->to);
+				print("%P", p2);
+			}
+			// p2 is OP mem, reg2.
+			// change to OP reg, reg2 and
+			// eliminate the mov.
+			p2->from = p->from;
+			*p = *p2;
+			p->link = p2->link;
+			if(debug['R'] && debug['v']) {
+				print(" ===change== %P\n", p);
+			}
+		}
+	}
+}


restrict declarations of type map/chan/string
(they must be pointers)

R=r
OCL=21009
CL=21009

--- src/cmd/gc/dcl.c
+++ src/cmd/gc/dcl.c
@@ -483,8 +483,18 @@
 	if(n->op != ODCLFIELD || n->type == T)
 		fatal("stotype: oops %N\n", n);

-	if(n->type->etype == TARRAY && n->type->bound < 0)
-		yyerror("type of a structure field cannot be an open array");
+	switch(n->type->etype) {
+	case TARRAY:
+		if(n->type->bound < 0)
+			yyerror("type of a structure field cannot be an open array");
+		break;
+
+	case TCHAN:
+	case TMAP:
+	case TSTRING:
+		yyerror("%T can exist only in pointer form", n->type);
+		break;
+	}

 	switch(n->val.ctype) {
 	case CTSTR:
@@ -730,6 +740,15 @@
 		vargen++;
 		gen = vargen;
 		pushdcl(s);
+	}
+
+	if(t != T) {
+		switch(t->etype) {
+		case TCHAN:
+		case TMAP:
+		case TSTRING:
+			yyerror("%T can exist only in pointer form", t);
+		}
 	}

 	redeclare("variable", s);


gc: maybe the code is only mostly dead

gc: maybe the code is only mostly dead

R=ken2
CC=golang-dev
http://codereview.appspot.com/2346044

--- src/cmd/gc/gen.c
+++ src/cmd/gc/gen.c
@@ -257,17 +257,6 @@
 		break;

 	case OIF:
-		if(n->ntest == N || n->ntest->op == OLITERAL) {
-			// drop dead code in if true or if false.
-			// the linker will do it for us in general,
-			// but this avoids writnig to the object file
-			// in a very common case.
-			if(n->ntest == N || n->ntest->val.u.bval)
-				genlist(n->nbody);
-			else
-				genlist(n->nelse);
-			break;
-		}
 		p1 = gjmp(P);			//		goto test
 		p2 = gjmp(P);			// p2:		goto else
 		patch(p1, pc);				// test:


cmd/gc: fix comment for caninl

cmd/gc: fix comment for caninl

Was describing an old implementation.

R=ken2
CC=golang-dev
http://codereview.appspot.com/6553066

--- src/cmd/gc/inl.c
+++ src/cmd/gc/inl.c
@@ -111,10 +111,8 @@
 	lineno = lno;
 }

-// Caninl determines whether fn is inlineable. Currently that means:
-// fn is exactly 1 statement, either a return or an assignment, and
-// some temporary constraints marked TODO.  If fn is inlineable, saves
-// fn->nbody in fn->inl and substitutes it with a copy.
+// Caninl determines whether fn is inlineable.
+// If so, caninl saves fn->nbody in fn->inl and substitutes it with a copy.
 void
 caninl(Node *fn)
 {


gc: backslash newline is not a legal escape sequence in strings

Fixes issue 827.

R=ken2
CC=golang-dev, rsc
http://codereview.appspot.com/1592041

--- src/cmd/gc/lex.c
+++ src/cmd/gc/lex.c
@@ -1160,7 +1160,6 @@

 	*escflg = 0;

-loop:
 	c = getr();
 	switch(c) {
 	case EOF:
@@ -1180,9 +1179,6 @@

 	c = getr();
 	switch(c) {
-	case '\n':
-		goto loop;
-
 	case 'x':
 		*escflg = 1;	// it's a byte
 		i = 2;


Create fill_palette_circular function

Create fill_palette_circular function

--- src/colorutils.h
+++ src/colorutils.h
@@ -1566,7 +1566,7 @@
                       TBlendType blendType=LINEARBLEND);

-// Fill a range of LEDs with a sequece of entryies from a palette
+// Fill a range of LEDs with a sequence of entries from a palette
 template <typename PALETTE>
 void fill_palette(CRGB* L, uint16_t N, uint8_t startIndex, uint8_t incIndex,
                   const PALETTE& pal, uint8_t brightness, TBlendType blendType)
@@ -1575,6 +1575,23 @@
     for( uint16_t i = 0; i < N; ++i) {
         L[i] = ColorFromPalette( pal, colorIndex, brightness, blendType);
         colorIndex += incIndex;
+    }
+}
+
+// Fill a range of LEDs with a sequence of entries from a palette, so that
+// the entire palette smoothly covers the range of LEDs
+template <typename PALETTE>
+void fill_palette_circular(CRGB* L, uint16_t N, uint8_t startIndex,
+                           const PALETTE& pal, uint8_t brightness, TBlendType blendType)
+{
+    if (N == 0) return;  // avoiding div/0
+
+    const uint16_t colorChange = 65536 / N;              // color change for each LED, * 256 for precision
+    uint16_t colorIndex = ((uint16_t) startIndex) << 8;  // offset for color index, with precision (*256)
+
+   for (uint16_t i = 0; i < N; ++i) {
+        L[i] = ColorFromPalette(pal, (colorIndex >> 8), brightness, blendType);
+        colorIndex += colorChange;
     }
 }


* Merged changes up to eAthena 15074.

* Merged changes up to eAthena 15074.

git-svn-id: c1e39603916b71782cde5facdf0b79eff05c1414@15541 54d463be-8e91-2dee-dedb-b68131a5f0ec

--- src/common/mmo.h
+++ src/common/mmo.h
@@ -378,7 +378,7 @@
 } mail_status;

 struct mail_message {
-	unsigned int id;
+	int id;
 	int send_id;
 	char send_name[NAME_LENGTH];
 	int dest_id;


Remove redundant glTexImage2D() call

Remove redundant glTexImage2D() call

When we later upload the cursor image with glTexImage2D(), that will unbind
the image just fine.  No need for a NULL upload.  Except that that doesn't
currently happen with mesa drivers, but the NULL upload is redundant either
way.

--- src/compositor.c
+++ src/compositor.c
@@ -410,10 +410,6 @@
 	glBindTexture(GL_TEXTURE_2D, es->texture);

 	if (wl_buffer_is_shm(buffer)) {
-		/* Unbind any EGLImage texture that may be bound, so we don't
-		 * overwrite it.*/
-		glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
-			     0, 0, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL);
 		es->pitch = wl_shm_buffer_get_stride(buffer) / 4;
 		glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT,
 			     es->pitch, buffer->height, 0,


compositor: weston_surface_assign_output() to use bounding box

Use the bounding box to compute an approximation of which output
contains most of the surface.

Move the region32 init outside the loop, and fini it, too.

Signed-off-by: Pekka Paalanen <6c0263d81461c956d504307112a4ce25eaacc3d1@gmail.com>

--- src/compositor.c
+++ src/compositor.c
@@ -1037,14 +1037,14 @@
 	uint32_t max, area;
 	pixman_box32_t *e;

+	weston_surface_update_transform(es);
+
 	new_output = NULL;
 	max = 0;
+	pixman_region32_init(&region);
 	wl_list_for_each(output, &ec->output_list, link) {
-		pixman_region32_init_rect(&region,
-					  es->geometry.x, es->geometry.y,
-					  es->geometry.width,
-					  es->geometry.height);
-		pixman_region32_intersect(&region, &region, &output->region);
+		pixman_region32_intersect(&region, &es->transform.boundingbox,
+					  &output->region);

 		e = pixman_region32_extents(&region);
 		area = (e->x2 - e->x1) * (e->y2 - e->y1);
@@ -1054,6 +1054,7 @@
 			max = area;
 		}
 	}
+	pixman_region32_fini(&region);

 	es->output = new_output;
 	if (!wl_list_empty(&es->frame_callback_list)) {


compositor: Clip pointer coordinates on pointer enter as well

When tiling window managers resize a non-resizable window they're violating
ICCCM.  Not some hippie-community standard like EWMH, but ICCCM, which is
about as old and sacred as the constitution.  If they want to force a window
to be a size it wasn't designed for, at least they could have the decency to
reparent the client window into a bigger containing window of whatever size
they think it should be.  But apparently ICCCM compliance is too much to ask.

Anyway, all that just to say that it's really not our fault when we get an
enter event with coordinates outside the valid output region.  But we'll
clip it anyway and work around mis-behaving tiling WMs.

--- src/compositor.c
+++ src/compositor.c
@@ -1756,6 +1756,7 @@
 	struct wl_pointer *pointer = seat->seat.pointer;

 	if (output) {
+		clip_pointer_motion(seat, &x, &y);
 		weston_seat_update_drag_surface(seat,
 						x - pointer->x,
 						y - pointer->y);


GabbleConnection: use GabbleMucFactory as a GabbleChannelManager

20080805145014-53eee-5f188c0b2be3d6e0dd8419036eadb6151b56a931.gz

--- src/connection.c
+++ src/connection.c
@@ -193,11 +193,6 @@

   g_ptr_array_add (channel_factories, self->roster);

-  self->muc_factory = g_object_new (GABBLE_TYPE_MUC_FACTORY,
-      "connection", self,
-      NULL);
-  g_ptr_array_add (channel_factories, self->muc_factory);
-
   g_ptr_array_add (channel_factories,
                    g_object_new (GABBLE_TYPE_MEDIA_FACTORY,
                                  "connection", self,


src/connection.c: Delclare all local variables before using

--- src/connection.c
+++ src/connection.c
@@ -262,9 +262,9 @@
 static int ldbus_connection_register_object_path(lua_State *L) {
 	DBusConnection *connection = *(void **)luaL_checkudata(L, 1, "ldbus_DBusConnection");
 	const char *path = luaL_checkstring(L, 2);
-	luaL_checktype(L, 3, LUA_TFUNCTION);
 	int ref;
 	State_and_ref *user_data;
+	luaL_checktype(L, 3, LUA_TFUNCTION);
 	lua_settop(L, 3);
 	ref = luaL_ref(L, LUA_REGISTRYINDEX);
 	user_data = lua_newuserdata(L, sizeof(State_and_ref));


backoff delay updates

backoff delay updates

--- src/connection.c
+++ src/connection.c
@@ -38,6 +38,7 @@

 #define HTTP_CUSTOM_HEADER_COUNT                    	5
 #define INITIAL_CJWT_RETRY                    	-2
+#define UPDATE_HEALTH_FILE_INTERVAL_SECS		450

 /* Close codes defined in RFC 6455, section 11.7. */
 enum {
@@ -229,8 +230,7 @@
 void init_backoff_timer (backoff_timer_t *timer, int max_count)
 {
   timer->count = 1;
-  if (max_count != -1)
-    timer->max_count = max_count;
+  timer->max_count = max_count;
   timer->delay = 1;
   clock_gettime (CLOCK_REALTIME, &timer->ts);
 }
@@ -272,30 +272,29 @@
   struct timespec ts;
   int rtn;

+  // periodically update the health file.
+  clock_gettime (CLOCK_REALTIME, &ts);
+  if ((ts.tv_sec - timer->ts.tv_sec) >= UPDATE_HEALTH_FILE_INTERVAL_SECS) {
+    start_conn_in_progress ();
+    timer->ts.tv_sec += UPDATE_HEALTH_FILE_INTERVAL_SECS;
+  }
+
+  update_backoff_delay (timer);
+  ParodusInfo("Waiting with backoffRetryTime %d seconds\n", timer->delay);
+  ts.tv_sec += timer->delay;
+
   pthread_mutex_lock (&backoff_delay_mut);
-
-  clock_gettime (CLOCK_REALTIME, &ts);
-  if ((ts.tv_sec - timer->ts.tv_sec) >= 180) {
-    pthread_mutex_unlock (&backoff_delay_mut);
-    start_conn_in_progress ();
-    pthread_mutex_lock (&backoff_delay_mut);
-    timer->ts.tv_sec += 180;
-  }
-
-  update_backoff_delay (timer);
-  ts.tv_sec += timer->delay;
   // The condition variable will only be set if we shut down.
   rtn = pthread_cond_timedwait (&backoff_delay_con, &backoff_delay_mut, &ts);
-
   pthread_mutex_unlock (&backoff_delay_mut);
+
   if (g_shutdown)
     return BACKOFF_SHUTDOWN;
   if ((rtn != 0) && (rtn != ETIMEDOUT)) {
-    ParodusError ("pthread_cond_timedwait error in backoff_delay.\n");
+    ParodusError ("pthread_cond_timedwait error (%d) in backoff_delay.\n", rtn);
     return BACKOFF_ERR;
   }

-  ParodusInfo("Waiting with backoffRetryTime %d seconds\n", timer->delay);
   return BACKOFF_DELAY_TAKEN;
 }


Use GabblePrivateTubesFactory as a ChannelManager

20080731191948-53eee-56af9766eef7c9a7517d2dbcfa1cccb806df25cf.gz

--- src/connection.c
+++ src/connection.c
@@ -203,9 +203,6 @@
                                  "connection", self,
                                  NULL));

-  self->private_tubes_factory = gabble_private_tubes_factory_new (self);
-  g_ptr_array_add (channel_factories, self->private_tubes_factory);
-
   /* Temporary hack for requestotron support - divert the channel factories
    * and channel managers to somewhere under our control */
   self->channel_factories = channel_factories;
@@ -217,6 +214,9 @@
       g_object_new (GABBLE_TYPE_IM_FACTORY,
         "connection", self,
         NULL));
+
+  self->private_tubes_factory = gabble_private_tubes_factory_new (self);
+  g_ptr_array_add (self->channel_managers, self->private_tubes_factory);

   return channel_factories;
 }


Re-order so checks pass!

Re-order so checks pass!

--- src/const-info.c
+++ src/const-info.c
@@ -219,12 +219,12 @@
 	{ "GETDNS_RETURN_GOOD", 0 },
 	{ "GETDNS_RETURN_INVALID_PARAMETER", 311 },
 	{ "GETDNS_RETURN_MEMORY_ERROR", 310 },
-	{ "GETDNS_RETURN_NO_UPSTREAM_AVAILABLE", 398},
 	{ "GETDNS_RETURN_NEED_MORE_SPACE", 399 },
 	{ "GETDNS_RETURN_NOT_IMPLEMENTED", 312 },
 	{ "GETDNS_RETURN_NO_SUCH_DICT_NAME", 305 },
 	{ "GETDNS_RETURN_NO_SUCH_EXTENSION", 307 },
 	{ "GETDNS_RETURN_NO_SUCH_LIST_ITEM", 304 },
+	{ "GETDNS_RETURN_NO_UPSTREAM_AVAILABLE", 398},
 	{ "GETDNS_RETURN_UNKNOWN_TRANSACTION", 303 },
 	{ "GETDNS_RETURN_WRONG_TYPE_REQUESTED", 306 },
 	{ "GETDNS_RRCLASS_ANY", 255 },


Fixed ref leak on QMenu inject code.

Fixed ref leak on QMenu inject code.

Reviewer: Marcelo Lira <6be3b93b2f09145ada72571578cc4097e4ba9a9e@openbossa.org>
          Luciano Wolf <luciano.wolf@openbossa.org>

--- PySide/QtGui/glue/qmenu_glue.h
+++ PySide/QtGui/glue/qmenu_glue.h
@@ -13,8 +13,8 @@
     self->addAction(act);

     PyObject *pyAct = Shiboken::Converter<QAction*>::toPython(act);
-    PyObject* result = PyObject_CallMethod(pyAct, "connect", "OsO", pyAct, SIGNAL(triggered()), callback);
-    if (result == 0) {
+    Shiboken::AutoDecRef result(PyObject_CallMethod(pyAct, "connect", "OsO", pyAct, SIGNAL(triggered()), callback));
+    if (result.isNull()) {
         Py_DECREF(pyAct);
         return 0;
     }


fix mistake in static assertion, patch by Markus Moll.

--- Eigen/src/Core/Block.h
+++ Eigen/src/Core/Block.h
@@ -122,7 +122,7 @@
       : m_matrix(matrix), m_startRow(startRow), m_startCol(startCol),
         m_blockRows(matrix.rows()), m_blockCols(matrix.cols())
     {
-      EIGEN_STATIC_ASSERT(RowsAtCompileTime!=Dynamic && RowsAtCompileTime!=Dynamic,THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE)
+      EIGEN_STATIC_ASSERT(RowsAtCompileTime!=Dynamic && ColsAtCompileTime!=Dynamic,THIS_METHOD_IS_ONLY_FOR_FIXED_SIZE)
       ei_assert(startRow >= 0 && BlockRows >= 1 && startRow + BlockRows <= matrix.rows()
           && startCol >= 0 && BlockCols >= 1 && startCol + BlockCols <= matrix.cols());
     }


*** empty log message ***

*** empty log message ***

--- Examples/sensitivity.c
+++ Examples/sensitivity.c
@@ -26,7 +26,7 @@
   si.setSymParam(OsiSymSensitivityAnalysis, true);

   si.initialSolve();
-#ifdef SENSITIVITY_ANALYSIS
+
   int ind[2];
   double val[2];
   ind[0] = 4; val[0] = 7000;
@@ -36,13 +36,6 @@
   double ub =  si.getUbForNewRhs(2, ind, val);

   printf("\nBounds for the new rhs:\n lb: %f\n ub: %f \n\n", lb, ub);
-
-#else
-
-  printf("\nSensitivity analysis is disabled!"
-	 "Please modify the configuration file to enable this feature");
-
-#endif

   return(0);

@@ -63,12 +56,10 @@

    sym_solve(env);

-#ifdef SENSITIVITY_ANALYSIS
-
    int ind[2];
    double val[2];
    ind[0] = 4; val[0] = 7000;
-   ind[1] = 7; val[0] = 6000;
+   ind[1] = 7; val[1] = 6000;

    double lb, ub;
    sym_get_lb_for_new_rhs(env, 2, ind, val, &lb);
@@ -76,13 +67,6 @@

    printf("\nBounds for the new rhs:\n lb: %f\n ub: %f \n\n", lb, ub);

-#else
-
-   printf("\nSensitivity analysis is disabled!"
-	  "Please modify the configuration file to enable this feature");
-
-#endif
-
    sym_close_environment(env);

    return(0);


Add in the configMAX_SYSCALL_INTERRUPT_PRIORITY constant.

git-svn-id: 43aea61533866f88f23079d48f4f5dc2d5288937@338 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

--- Demo/PIC32MX_MPLAB/FreeRTOSConfig.h
+++ Demo/PIC32MX_MPLAB/FreeRTOSConfig.h
@@ -69,14 +69,15 @@
 #define configCPU_CLOCK_HZ				( ( unsigned portLONG ) 72000000UL )
 #define configPERIPHERAL_CLOCK_HZ		( ( unsigned portLONG ) 36000000UL )
 #define configMAX_PRIORITIES			( ( unsigned portBASE_TYPE ) 5 )
-#define configMINIMAL_STACK_SIZE		( 230 )
-#define configISR_STACK_SIZE			( 130 )
-#define configTOTAL_HEAP_SIZE			( ( size_t ) 29000 )
+#define configMINIMAL_STACK_SIZE		( 210 )
+#define configISR_STACK_SIZE			( 400 )
+#define configTOTAL_HEAP_SIZE			( ( size_t ) 25000 )
 #define configMAX_TASK_NAME_LEN			( 8 )
 #define configUSE_TRACE_FACILITY		0
 #define configUSE_16_BIT_TICKS			0
 #define configIDLE_SHOULD_YIELD			1
 #define configUSE_MUTEXES				1
+#define configCHECK_FOR_STACK_OVERFLOW	2

 /* Co-routine definitions. */
 #define configUSE_CO_ROUTINES 		0
@@ -93,8 +94,14 @@
 #define INCLUDE_vTaskDelayUntil			1
 #define INCLUDE_vTaskDelay				1

+/* The priority at which the tick interrupt runs.  This should probably be
+kept at 1. */
+#define configKERNEL_INTERRUPT_PRIORITY			0x01

-#define configKERNEL_INTERRUPT_PRIORITY	0x01
+/* The maximum interrupt priority from which FreeRTOS.org API functions can
+be called.  Only API functions that end in ...FromISR() can be used within
+interrupts. */
+#define configMAX_SYSCALL_INTERRUPT_PRIORITY	0x03

 #endif /* FREERTOS_CONFIG_H */


fixed comment

fixed comment

--- c/switch_case/switch_case/src/switch_case/switch_case.c
+++ c/switch_case/switch_case/src/switch_case/switch_case.c
@@ -4,7 +4,7 @@
 /* main関数の定義 */
 int main(void){

-  /* 変数の定義 */
+  /* 変数の宣言 */
   int a; /* int型変数a */
   int b; /* int型変数b */
   char op; /* 入力された演算子記号文字を格納するchar型変数op. */


Fixing enums #6

Fixing enums #6

--- cegui/include/CEGUI/RendererModules/Direct3D11/Shader.h
+++ cegui/include/CEGUI/RendererModules/Direct3D11/Shader.h
@@ -51,11 +51,11 @@
     /**
      * The ShaderType represents a vertex shader
      */
-    ShaderType::VERTEX,
+    VERTEX,
     /**
      * The ShaderType represents a pixel shader
      */
-    ShaderType::PIXEL
+    PIXEL
 };
 //----------------------------------------------------------------------------//


Inline yield when called with no arguments.

It was already inline when called with one argument.

--- src/core/cfuns.c
+++ src/core/cfuns.c
@@ -35,6 +35,10 @@
     (void) opts;
     return janet_v_count(args) == 1;
 }
+static int maxarity1(JanetFopts opts, JanetSlot *args) {
+    (void) opts;
+    return janet_v_count(args) <= 1;
+}
 static int minarity2(JanetFopts opts, JanetSlot *args) {
     (void) opts;
     return janet_v_count(args) >= 2;
@@ -115,7 +119,11 @@
     return genericSS(opts, JOP_LENGTH, args[0]);
 }
 static JanetSlot do_yield(JanetFopts opts, JanetSlot *args) {
-    return genericSSI(opts, JOP_SIGNAL, args[0], 3);
+    if (janet_v_count(args) == 0) {
+        return genericSSI(opts, JOP_SIGNAL, janetc_cslot(janet_wrap_nil()), 3);
+    } else {
+        return genericSSI(opts, JOP_SIGNAL, args[0], 3);
+    }
 }
 static JanetSlot do_resume(JanetFopts opts, JanetSlot *args) {
     return opreduce(opts, args, JOP_RESUME, janet_wrap_nil());
@@ -262,7 +270,7 @@
     {fixarity0, do_debug},
     {fixarity1, do_error},
     {minarity2, do_apply},
-    {fixarity1, do_yield},
+    {maxarity1, do_yield},
     {fixarity2, do_resume},
     {fixarity2, do_get},
     {fixarity3, do_put},


Add line, col to error messages when available.

--- src/core/debug.c
+++ src/core/debug.c
@@ -150,8 +150,44 @@
             if (frame->func && frame->pc) {
                 int32_t off = (int32_t)(frame->pc - def->bytecode);
                 if (def->sourcemap) {
+                    /* Try to get line and column information */
                     JanetSourceMapping mapping = def->sourcemap[off];
-                    fprintf(out, " at (%d:%d)", mapping.start, mapping.end);
+                    char buf[1024];
+                    size_t nread;
+                    int32_t offset = 0;
+                    int32_t line = 1;
+                    int32_t col = 1;
+                    int notdone = 1;
+                    char last = 0;
+                    FILE *f;
+                    if (def->source && (f = fopen((const char *)def->source, "rb"))) {
+                        while (notdone && (nread = fread(buf, 1, sizeof(buf), f)) > 0) {
+                            for(size_t i = 0; i < nread; i++) {
+                                char c = buf[i];
+                                if (c == '\r') {
+                                    line++;
+                                    col = 1;
+                                } if (c == '\n') {
+                                    col = 1;
+                                    if (last != '\r') {
+                                        line++;
+                                    }
+                                } else {
+                                    col++;
+                                }
+                                last = c;
+                                if (offset == mapping.start) {
+                                    fprintf(out, " on line %d, column %d", line, col);
+                                    notdone = 0;
+                                    break;
+                                }
+                                offset++;
+                            }
+                        }
+                        fclose(f);
+                    } else {
+                        fprintf(out, " at (%d:%d)", mapping.start, mapping.end);
+                    }
                 } else {
                     fprintf(out, " pc=%d", off);
                 }


input: When Shift is pressed in CapsLock state send small letters.

--- src/core/input.c
+++ src/core/input.c
@@ -2183,7 +2183,7 @@
           DFBInputDeviceKeymapSymbolIndex index =
                (event->modifiers & DIMM_ALTGR) ? DIKSI_ALT : DIKSI_BASE;

-          if ((event->modifiers & DIMM_SHIFT) || (entry->locks & event->locks))
+          if (!(event->modifiers & DIMM_SHIFT) ^ !(entry->locks & event->locks))
                index++;

           /* don't modify modifiers */
@@ -2687,7 +2687,7 @@
               DFBInputDeviceModifierMask  modifiers,
               DFBInputDeviceLockState     locks )
 {
-     bool shift = (modifiers & DIMM_SHIFT) || (locks & DILS_CAPS);
+     bool shift = !(modifiers & DIMM_SHIFT) ^ !(locks & DILS_CAPS);

      if (id >= DIKI_A && id <= DIKI_Z)
           return (shift ? DIKS_CAPITAL_A : DIKS_SMALL_A) + id - DIKI_A;


remote: Use g_autofree in daemonConfigFilePath()

Signed-off-by: Fabiano Fidêncio <2931bae082ef9bc04523ba759c03a4778316d48f@redhat.com>
Reviewed-by: Ján Tomko <4cab11cfb98d3c937327354a78eb07dbb6ee2bc6@redhat.com>

--- src/remote/remote_daemon_config.c
+++ src/remote/remote_daemon_config.c
@@ -79,19 +79,15 @@
     if (privileged) {
         *configfile = g_strdup(SYSCONFDIR "/libvirt/" DAEMON_NAME ".conf");
     } else {
-        char *configdir = NULL;
+        g_autofree char *configdir = NULL;

         if (!(configdir = virGetUserConfigDirectory()))
-            goto error;
+            return -1;

         *configfile = g_strdup_printf("%s/%s.conf", configdir, DAEMON_NAME);
-        VIR_FREE(configdir);
     }

     return 0;
-
- error:
-    return -1;
 }

 struct daemonConfig*


add greenlet getter

add greenlet getter

--- meinheld/server/client.c
+++ meinheld/server/client.c
@@ -57,6 +57,15 @@
 }

 static inline PyObject *
+ClientObject_get_greenlet(ClientObject *self, PyObject *args)
+{
+    if(self->greenlet){
+        return self->greenlet;
+    }
+    Py_RETURN_NONE;
+}
+
+static inline PyObject *
 ClientObject_get_fd(ClientObject *self, PyObject *args)
 {
     return Py_BuildValue("i", self->client->fd);
@@ -64,6 +73,7 @@

 static PyMethodDef ClientObject_method[] = {
     { "set_greenlet",      (PyCFunction)ClientObject_set_greenlet, METH_VARARGS, 0 },
+    { "get_greenlet",      (PyCFunction)ClientObject_get_greenlet, METH_NOARGS, 0 },
     {"get_fd", (PyCFunction)ClientObject_get_fd, METH_VARARGS, "get fd"},
     { NULL, NULL}
 };


Update server2.c

Update server2.c


removed dependency on scheduler

removed dependency on scheduler

--- lib/HttpServer/HttpHandlerFactory.h
+++ lib/HttpServer/HttpHandlerFactory.h
@@ -43,7 +43,6 @@
     class HttpRequest;
     class HttpResponse;
     class MaintenanceCallback;
-    class Scheduler;

 // -----------------------------------------------------------------------------
 // --SECTION--                                          class HttpHandlerFactory


Disable copy on Mutex objects

Disable copy on Mutex objects

--- src/core/mutex.h
+++ src/core/mutex.h
@@ -13,6 +13,10 @@
     {
     private:
         pthread_mutex_t mutex;
+
+        // Disable copy construction and assignment.
+        Mutex (const Mutex&);
+        const Mutex &operator = (const Mutex&);

     public:
         inline Mutex ()


added MMC_NICE waiting

added MMC_NICE waiting

--- Firmware/src/halconf.h
+++ Firmware/src/halconf.h
@@ -229,7 +229,7 @@
  *          use a DMA channel and heavily loads the CPU.
  */
 #if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
-#define MMC_NICE_WAITING            FALSE
+#define MMC_NICE_WAITING            TRUE
 #endif

 /*===========================================================================*/


Minor code cleanup.

Minor code cleanup.

--- samples/rsxTestVP/source/main.c
+++ samples/rsxTestVP/source/main.c
@@ -20,11 +20,12 @@
 #include "nv_shaders.h"
 #include "vshader.vcg.h"

+
+// Small matrix math library, these are not optimised at all.
 typedef struct
 {
        float data[4][4];
 } realityMatrix;
-

 realityMatrix realityMatrixMul(realityMatrix *left,realityMatrix *right)
 {
@@ -36,9 +37,9 @@
                for(col=0;col<4;++col)
                {
                        result.data[row][col]=left->data[row][0]*right->data[0][col]+
-											 left->data[row][1]*right->data[1][col]+
-											 left->data[row][2]*right->data[2][col]+
-											 left->data[row][3]*right->data[3][col];
+					     left->data[row][1]*right->data[1][col]+
+					     left->data[row][2]*right->data[2][col]+
+					     left->data[row][3]*right->data[3][col];
                }
        }

@@ -140,7 +141,6 @@
 }

 int currentBuffer = 0;
-//realityTexture *ball; // Texture.

 u32 *tx_mem;
 u32 tx_offset;
@@ -149,6 +149,7 @@
 const struct _Vertex
 {
 	float x,y,z,w;
+	float a,r,g,b;
 	float u,v;
 } VertexBufferMain[]=
 {
@@ -226,6 +227,7 @@
 	//shouldn't do attribute scan every frame but it's just a sample :)
 	positionAttr = realityVertexProgramGetInputAttribute((realityVertexProgram*)vshader_bin,"inputvertex.vertex");
 	textureAttr = realityVertexProgramGetInputAttribute((realityVertexProgram*)vshader_bin,"inputvertex.texcoord");
+

 	//Bind the memory array to the input attributes
 	//rsx requires the offset in his memory area


Fix for compiling cpPolyline with MSVC

Fix for compiling cpPolyline with MSVC

--- src/cpPolyline.c
+++ src/cpPolyline.c
@@ -561,7 +561,7 @@
 static struct Notch
 DeepestNotch(int count, cpVect *verts, int hullCount, cpVect *hullVerts, int first, cpFloat tol)
 {
-	struct Notch notch = {};
+	struct Notch notch = {0};
 	int j = Next(first, count);

 	for(int i=0; i<hullCount; i++){


Align buffer size up not down

Align buffer size up not down

--- src/csp_buffer.c
+++ src/csp_buffer.c
@@ -29,6 +29,8 @@
 #include <csp/arch/csp_malloc.h>
 #include <csp/arch/csp_semaphore.h>

+#define CSP_BUFFER_ALIGN	(sizeof(int *))
+
 typedef struct csp_skbf_s {
 	unsigned int refcount;
 	void * skbf_addr;
@@ -36,7 +38,7 @@
 } csp_skbf_t;

 static csp_queue_handle_t csp_buffers;
-static void * csp_buffer_pool;
+static char * csp_buffer_pool;
 static unsigned int count, size;

 CSP_DEFINE_CRITICAL(csp_critical_lock);
@@ -49,6 +51,7 @@
 	count = buf_count;
 	size = buf_size;
 	unsigned int skbfsize = (sizeof(csp_skbf_t) + size);
+	skbfsize = skbfsize + CSP_BUFFER_ALIGN - (skbfsize % CSP_BUFFER_ALIGN);
 	unsigned int poolsize = count * skbfsize;

 	csp_buffer_pool = csp_malloc(poolsize);
@@ -70,7 +73,7 @@
 		 * natual pointer boundary for the platform.
 		 * It requires that the buffer size is divisable with the platform integer length
 		 */
-		buf = (csp_skbf_t *) ((int *) csp_buffer_pool + i * skbfsize / sizeof(int *));
+		buf = (csp_skbf_t *) &csp_buffer_pool[i * skbfsize];
 		buf->refcount = 0;
 		buf->skbf_addr = buf;


start refactoring alsa code.

start refactoring alsa code.

--- src/cubeb_alsa.c
+++ src/cubeb_alsa.c
@@ -150,6 +150,59 @@
   rebuild_pfds(ctx);
 }

+static void
+cubeb_process_stream(cubeb_stream * stm)
+{
+  long got;
+  snd_pcm_sframes_t avail;
+  void * p;
+
+  avail = snd_pcm_avail_update(stm->pcm);
+  if (avail == -EPIPE) {
+    snd_pcm_recover(stm->pcm, avail, 1);
+    avail = snd_pcm_avail_update(stm->pcm);
+  }
+  p = calloc(1, snd_pcm_frames_to_bytes(stm->pcm, avail));
+  assert(p);
+  got = stm->data_callback(stm, stm->user_ptr, p, avail);
+  if (got < 0) {
+    assert(0); /* XXX handle this case */
+  }
+  if (got > 0) {
+    snd_pcm_sframes_t wrote = snd_pcm_writei(stm->pcm, p, got);
+    stm->write_position += wrote;
+  }
+  if (got != avail) {
+    struct cubeb_msg msg;
+#if 0
+    snd_pcm_state_t state = snd_pcm_state(stm->pcm);
+    r = snd_pcm_drain(stm->pcm);
+    assert(r == 0 || r == -EAGAIN);
+#endif
+
+    /* XXX write out a period of data to ensure real data is flushed to speakers */
+
+    /* XXX only fire this once */
+    stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_DRAINED);
+
+#if 1
+    /* XXX can't rebuild pfds until we've finished processing the current list */
+    stm->state = CUBEB_STREAM_STATE_DEACTIVATING;
+
+    msg.type = CUBEB_MSG_DEL_STREAM;
+    msg.data = stm;
+    cubeb_send_msg(stm->context, &msg);
+#else
+    /* disable fds for poll */
+    /* XXX this will be undone upon next rebuild, so need to flag this somehow */
+    for (i = 0; i < stm->n_descriptors; ++i) {
+      tmppfds[i].fd = -1;
+    }
+#endif
+  }
+  free(p);
+}
+
 static void *
 cubeb_run_thread(void * context)
 {
@@ -185,52 +238,7 @@
       }

       if (revents & POLLOUT) {
-        long got;
-        snd_pcm_sframes_t avail = snd_pcm_avail_update(stm->pcm);
-        void * p;
-        if (avail == -EPIPE) {
-          snd_pcm_recover(stm->pcm, avail, 1);
-          avail = snd_pcm_avail_update(stm->pcm);
-        }
-        p = calloc(1, snd_pcm_frames_to_bytes(stm->pcm, avail));
-        assert(p);
-        got = stm->data_callback(stm, stm->user_ptr, p, avail);
-        if (got < 0) {
-          assert(0); /* XXX handle this case */
-        }
-        if (got > 0) {
-          snd_pcm_sframes_t wrote = snd_pcm_writei(stm->pcm, p, got);
-          stm->write_position += wrote;
-        }
-        if (got != avail) {
-          struct cubeb_msg msg;
-#if 0
-          snd_pcm_state_t state = snd_pcm_state(stm->pcm);
-          r = snd_pcm_drain(stm->pcm);
-          assert(r == 0 || r == -EAGAIN);
-#endif
-
-          /* XXX write out a period of data to ensure real data is flushed to speakers */
-
-          /* XXX only fire this once */
-          stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_DRAINED);
-
-#if 1
-          /* XXX can't rebuild pfds until we've finished processing the current list */
-          stm->state = CUBEB_STREAM_STATE_DEACTIVATING;
-
-          msg.type = CUBEB_MSG_DEL_STREAM;
-          msg.data = stm;
-          cubeb_send_msg(stm->context, &msg);
-#else
-          /* disable fds for poll */
-          /* XXX this will be undone upon next rebuild, so need to flag this somehow */
-          for (i = 0; i < stm->n_descriptors; ++i) {
-            tmppfds[i].fd = -1;
-          }
-#endif
-        }
-        free(p);
+        cubeb_process_stream(stm);
       }

       tmppfds += stm->n_descriptors;


Improved memory handling for error cases

--- src/daliserver.c
+++ src/daliserver.c
@@ -104,6 +104,8 @@
 static void show_banner();

 int main(int argc, char *const argv[]) {
+	int error = 0;
+
 	log_debug("Parsing options");
 	Options *opts = parse_opt(argc, argv);
 	if (!opts) {
@@ -132,50 +134,64 @@
 	log_debug("Initializing dispatch queue");
 	DispatchPtr dispatch = dispatch_new();
 	if (!dispatch) {
-		return -1;
-	}
-	//dispatch_set_timeout(dispatch, 100);
-
-	UsbDaliPtr usb = NULL;
-	if (!opts->dryrun) {
-		log_debug("Initializing USB connection");
-		usb = usbdali_open(NULL, dispatch);
-		if (!usb) {
-			return -1;
-		}
-	}
-
-	log_debug("Initializing server");
-	ServerPtr server = server_open(dispatch, opts->address, opts->port, DEFAULT_NET_FRAMESIZE, net_frame_handler, usb);
-	if (!server) {
-		return -1;
-	}
-
-	usbdali_set_outband_callback(usb, dali_outband_handler, server);
-	usbdali_set_inband_callback(usb, dali_inband_handler);
-
-	log_debug("Creating shutdown notifier");
-	killsocket = ipc_new();
-	if (!killsocket) {
-		return -1;
-	}
-	ipc_register(killsocket, dispatch);
-
-	log_info("Server ready, waiting for events");
-	running = 1;
-	signal(SIGTERM, signal_handler);
-	signal(SIGINT, signal_handler);
-	while (running && dispatch_run(dispatch, usbdali_get_timeout(usb)));
-
-	log_info("Shutting daliserver down");
-	ipc_free(killsocket);
-	server_close(server);
-	usbdali_close(usb);
-	dispatch_free(dispatch);
+		error = -1;
+	} else {
+		//dispatch_set_timeout(dispatch, 100);
+
+		UsbDaliPtr usb = NULL;
+		if (!opts->dryrun) {
+			log_debug("Initializing USB connection");
+			usb = usbdali_open(NULL, dispatch);
+			if (!usb) {
+				error = -1;
+			}
+		}
+
+		if (opts->dryrun || usb) {
+			log_debug("Initializing server");
+			ServerPtr server = server_open(dispatch, opts->address, opts->port, DEFAULT_NET_FRAMESIZE, net_frame_handler, usb);
+
+			if (!server) {
+				error = -1;
+			} else {
+				if (usb) {
+					usbdali_set_outband_callback(usb, dali_outband_handler, server);
+					usbdali_set_inband_callback(usb, dali_inband_handler);
+				}
+
+				log_debug("Creating shutdown notifier");
+				killsocket = ipc_new();
+
+				if (!killsocket) {
+					error = -1;
+				} else {
+					ipc_register(killsocket, dispatch);
+
+					log_info("Server ready, waiting for events");
+					running = 1;
+					signal(SIGTERM, signal_handler);
+					signal(SIGINT, signal_handler);
+					while (running && dispatch_run(dispatch, usbdali_get_timeout(usb)));
+
+					log_info("Shutting daliserver down");
+					ipc_free(killsocket);
+				}
+
+				server_close(server);
+			}
+
+			if (usb) {
+				usbdali_close(usb);
+			}
+		}
+
+		dispatch_free(dispatch);
+	}
+
 	free_opt(opts);
-
+
 	log_info("Exiting");
-	return 0;
+	return error;
 }

 static void signal_handler(int sig) {
@@ -243,9 +259,9 @@
 		log_info("Got frame: 0x%02x 0x%02x 0x%02x 0x%02x", (uint8_t) buffer[0], (uint8_t) buffer[1], (uint8_t) buffer[2], (uint8_t) buffer[3]);
 		if ((uint8_t) buffer[0] == DEFAULT_NET_PROTOCOL) {
 			if ((uint8_t) buffer[1] == NET_TYPE_SEND) {
-				DaliFramePtr frame = daliframe_new((uint8_t) buffer[2], (uint8_t) buffer[3]);
 				UsbDaliPtr dali = (UsbDaliPtr) arg;
 				if (dali) {
+					DaliFramePtr frame = daliframe_new((uint8_t) buffer[2], (uint8_t) buffer[3]);
 					usbdali_queue(dali, frame, conn);
 				}
 			} else {


Allow using device numbers on Windows.

Allow using device numbers on Windows.

--- src/disc_win32.c
+++ src/disc_win32.c
@@ -130,8 +130,8 @@
 	}
 }

-char *mb_disc_get_default_device_unportable(void) {
-	int i;
+char *get_nth_device_or_default(int number) {
+	int i, counter = 0;
 	char device[MAX_DEV_LEN];
 	DWORD mask = GetLogicalDrives();

@@ -140,13 +140,23 @@
 			snprintf(device, MAX_DEV_LEN, "%c:", i + 'A');

 			if (GetDriveType(device) == DRIVE_CDROM) {
-				strncpy(default_device, device, MAX_DEV_LEN);
-				return default_device;
+				counter++;
+
+				if (counter == number)
+				{
+					strncpy(default_device, device, MAX_DEV_LEN);
+					return default_device;
+				}
 			}
 		}
 	}

 	return MB_DEFAULT_DEVICE;
+}
+
+char *mb_disc_get_default_device_unportable(void) {
+	/* Return the first available CD drive or the default */
+	return get_nth_device_or_default(1);
 }

 int mb_disc_has_feature_unportable(enum discid_feature feature) {
@@ -204,7 +214,13 @@
 			    unsigned int features) {
 	mb_disc_toc toc;
 	HANDLE hDevice;
-	int i;
+	int i, device_number;
+
+	device_number = (int) strtol(device, NULL, 10);
+
+	if (device_number > 0) {
+		device = get_nth_device_or_default(device_number);
+	}

 	if ( !mb_disc_winnt_read_toc(disc, &toc, device) )
 		return 0;


Make sure to not send exchange reports after being canceled

--- src/downloader.c
+++ src/downloader.c
@@ -823,7 +823,6 @@
                 pointer->report->message = STORJ_REPORT_DOWNLOAD_ERROR;
         }

-        // TODO don't send error on canceled download
         if (req->shard_data) {
             free(req->shard_data);
         }
@@ -1165,6 +1164,10 @@
 static void queue_send_exchange_reports(storj_download_state_t *state)
 {

+    if (state->canceled) {
+        return;
+    }
+
     for (int i = 0; i < state->total_pointers; i++) {

         storj_pointer_t *pointer = &state->pointers[i];
@@ -1505,7 +1508,6 @@

     queue_request_shards(state);

-    // send back download status reports to the bridge
     queue_send_exchange_reports(state);

 finish_up:


Fix GPGME_CREATE_NOPASSWD without pinentry loopback.

* src/engine-gpg.c(gpg_createkey): Pass --batch to gpg when
GPGME_CREATE_NOPASSWD is set.

--
Signed-off-by: Ben Kibbey <e5f42c7b1752daf48072fc2d69931de1c690bf14@luxsci.net>

--- src/engine-gpg.c
+++ src/engine-gpg.c
@@ -2139,6 +2139,8 @@
       err = add_arg (gpg, "--passphrase");
       if (!err)
         err = add_arg (gpg, "");
+      if (!err)
+        err = add_arg (gpg, "--batch");
     }
   if (!err && (flags & GPGME_CREATE_FORCE))
     err = add_arg (gpg, "--yes");


Also anticipate the more data at the end of an ilnp64 case

--- str2host.c
+++ str2host.c
@@ -1323,9 +1323,12 @@
 {
 	unsigned int a, b, c, d;
 	uint16_t shorts[4];
-
-	if (sscanf(str, "%4x:%4x:%4x:%4x", &a, &b, &c, &d) != 4 ||
-			strpbrk(str, "+-") /* no signs */) {
+	int l;
+
+	if (sscanf(str, "%4x:%4x:%4x:%4x%n", &a, &b, &c, &d, &l) != 4 ||
+			l != (int)strlen(str) || /* more data to read */
+			strpbrk(str, "+-")       /* signed hexes */
+			) {
 		return LDNS_STATUS_INVALID_ILNP64;
 	} else {
 		shorts[0] = htons(a);


nconfig: Avoid Wunused-but-set warning

nconfig: Avoid Wunused-but-set warning

I am seeing Wunused-but-set warning while make nconfig.  Looks like
active_menu is not used. Removing it fixes the warning.

Signed-off-by: Raghavendra D Prabhu <902715110abadbb2f215999f21b340f5d535a2f0@wnohang.net>
Acked-by: WANG Cong <0f114804888b88d50037b04b42e57b858d851b87@gmail.com>
Signed-off-by: Michal Marek <0c835876a532a476f30fdb1f6e963bae6c5a1a04@suse.cz>

--- scripts/kconfig/nconf.c
+++ scripts/kconfig/nconf.c
@@ -1067,7 +1067,6 @@
 	struct menu *submenu = 0;
 	const char *prompt = menu_get_prompt(menu);
 	struct symbol *sym;
-	struct menu *active_menu = NULL;
 	int res;
 	int current_index = 0;
 	int last_top_row = 0;
@@ -1152,7 +1151,6 @@
 			continue;

 		submenu = (struct menu *) item_data();
-		active_menu = (struct menu *)item_data();
 		if (!submenu || !menu_is_visible(submenu))
 			continue;
 		if (submenu)


GP_TextMaxWidth() fixed forgotten xmul and xspace.

--- core/GP_TextMetric.c
+++ core/GP_TextMetric.c
@@ -72,7 +72,8 @@
 {
 	unsigned int space_width = SpaceWidth(style);
 	//TODO: is style->font->char_width font character max width?
-	unsigned int char_width  = style->font->char_width;
+	unsigned int char_width  = style->font->char_width *
+	                           (style->pixel_xmul + style->pixel_xspace);

 	if (len == 0)
 		return 0;


CwiseUnaryOp -> SparseCwiseUnaryOp

CwiseUnaryOp -> SparseCwiseUnaryOp

--HG--
extra : convert_revision : svn%3A283d02a7-25f6-0310-bc7c-ecb5cbfe19da/trunk/kdesupport/eigen2%40947890

--- Eigen/src/Sparse/SparseMatrixBase.h
+++ Eigen/src/Sparse/SparseMatrixBase.h
@@ -84,9 +84,9 @@
                         const Derived&
                      >::ret ConjugateReturnType;
     /** \internal the return type of MatrixBase::real() */
-    typedef CwiseUnaryOp<ei_scalar_real_op<Scalar>, Derived> RealReturnType;
+    typedef SparseCwiseUnaryOp<ei_scalar_real_op<Scalar>, Derived> RealReturnType;
     /** \internal the return type of MatrixBase::imag() */
-    typedef CwiseUnaryOp<ei_scalar_imag_op<Scalar>, Derived> ImagReturnType;
+    typedef SparseCwiseUnaryOp<ei_scalar_imag_op<Scalar>, Derived> ImagReturnType;
     /** \internal the return type of MatrixBase::adjoint() */
     typedef SparseTranspose</*NestByValue<*/typename ei_cleantype<ConjugateReturnType>::type> /*>*/
             AdjointReturnType;


Delete binary_search.h

Delete binary_search.h


[fix] header import for RSKImageCropper to solve build error

--- ios/ImageCropPicker.h
+++ ios/ImageCropPicker.h
@@ -3,7 +3,7 @@

 #import <Foundation/Foundation.h>
 #import <QBImagePickerController/QBImagePickerController.h>
-#import <RSKImageCropper.h>
+#import <RSKImageCropper/RSKImageCropper.h>
 #import <math.h>
 #import <WeexSDK/WXModuleProtocol.h>
 #import "UIImage+Resize.h"


board/endeavour/led.c: Format with clang-format

BUG=b:236386294
BRANCH=none
TEST=none

Change-Id: Ied1bc054842985c82d11115b1656c261f9881036
Signed-off-by: Jack Rosenthal <d3f605bef1867f59845d4ce6e4f83b8dc9e4e0ae@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3728294
Reviewed-by: Jeremy Bettis <4df7b5147fee087dca33c181f288ee7dbf56e022@chromium.org>

--- board/endeavour/led.c
+++ board/endeavour/led.c
@@ -15,7 +15,7 @@
 #include "timer.h"
 #include "util.h"

-const enum ec_led_id supported_led_ids[] = {EC_LED_ID_POWER_LED};
+const enum ec_led_id supported_led_ids[] = { EC_LED_ID_POWER_LED };
 const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);

 enum led_color {
@@ -71,9 +71,9 @@
 	}
 }

-#define LED_PULSE_US		(2 * SECOND)
+#define LED_PULSE_US (2 * SECOND)
 /* 40 msec for nice and smooth transition. */
-#define LED_PULSE_TICK_US	(40 * MSEC)
+#define LED_PULSE_TICK_US (40 * MSEC)

 /* When pulsing is enabled, brightness is incremented by <duty_inc> every
  * <interval> usec from 0 to 100% in LED_PULSE_US usec. Then it's decremented
@@ -190,8 +190,7 @@
 	}
 	return EC_SUCCESS;
 }
-DECLARE_CONSOLE_COMMAND(led, command_led,
-			"[debug|red|white|off|crit]",
+DECLARE_CONSOLE_COMMAND(led, command_led, "[debug|red|white|off|crit]",
 			"Turn on/off LED.");

 void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)


pazquel: Detect the Refresh key at row 3

Pazquel uses the Vivaldi keyboard. The Refresh key is at T2
(col:2, row:3), instead of T3 (col:2, row:2). The code filters out
the Refresh key and check any boot key remaining.

BRANCH=trogdor
BUG=b:194553244
TEST=Pressed Refresh (T2) at boot. And could find the log:
"KB boot key mask".

Without this change, pressing T2 at boot wouldn't trigger
check_key_list() and spit "KB boot key mask" log.

Signed-off-by: Tang Qijun <6cb74b763495701197493702dbfc94ea5367fc16@ecs.corp-partner.google.com>
Change-Id: I594cac4f0f63dc3f138a5811c187d1e335c3ecfd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3113250
Reviewed-by: Wai-Hong Tam <04b587fdf5845741a0c5a8b9cd59ca72d73ef8fc@google.com>
Commit-Queue: Philip Chen <3ee404f9ef892bc3fda6e6a76e65843b5fa44db2@chromium.org>
Tested-by: Philip Chen <3ee404f9ef892bc3fda6e6a76e65843b5fa44db2@chromium.org>

--- board/pazquel/board.h
+++ board/pazquel/board.h
@@ -23,7 +23,7 @@

 /* Keyboard */
 #define CONFIG_KEYBOARD_PROTOCOL_MKBP
-
+#define CONFIG_KEYBOARD_REFRESH_ROW3
 #define CONFIG_PWM_KBLIGHT

 /* Battery */


rambi: Implement battery cutoff command

rambi: Implement battery cutoff command

Needed for shipping systems.  Puts battery into shutdown mode until AC
reapplied.

BUG=chrome-os-partner:23634
BRANCH=none
TEST=With system on battery power, 'battcutoff'.  System will shut off
     after a few seconds.  Power button will not turn it on.  Plugging
     AC power in will turn system back on.

Change-Id: I10a28c3c21623508dc8e4dee1cc5dc8d6fb9a6af
Signed-off-by: Randall Spangler <62698fdbb84d1779579ee80c3f39fac22017e5bc@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/174888
Reviewed-by: Dave Parker <a0cbe8131c36e5e74e2155ca4ce91517847db706@chromium.org>

--- board/rambi/battery.c
+++ board/rambi/battery.c
@@ -6,7 +6,14 @@
  */

 #include "battery.h"
+#include "battery_smart.h"
+#include "console.h"
 #include "gpio.h"
+#include "host_command.h"
+#include "util.h"
+
+/* Shutdown mode parameter to write to manufacturer access register */
+#define SB_SHUTDOWN_DATA	0x0010

 const struct battery_temperature_ranges bat_temp_ranges = {
 	.start_charging_min_c = 0,
@@ -29,4 +36,31 @@
 	return &info;
 }

-/* TODO(crosbug.com/p/23597): Battery cutoff command; need vendor info */
+static int cutoff(void)
+{
+	int rv;
+
+	/* Ship mode command must be sent twice to take effect */
+	rv = sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA);
+
+	if (rv != EC_SUCCESS)
+		return rv;
+
+	return sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA);
+}
+
+static int battery_command_cut_off(struct host_cmd_handler_args *args)
+{
+	return cutoff() ? EC_RES_SUCCESS : EC_RES_ERROR;
+}
+DECLARE_HOST_COMMAND(EC_CMD_BATTERY_CUT_OFF, battery_command_cut_off,
+		     EC_VER_MASK(0));
+
+static int command_battcutoff(int argc, char **argv)
+{
+	return cutoff();
+}
+DECLARE_CONSOLE_COMMAND(battcutoff, command_battcutoff,
+			NULL,
+			"Enable battery cutoff (ship mode)",
+			NULL);


bootstrap:inference: type_inference_tuple: fix detection type/value mix

Fix necessary for partially named return tuple in function prototype:
	fun foo = Error, fd:Int

--- bootstrap/inference.c
+++ bootstrap/inference.c
@@ -1368,11 +1368,12 @@
 static ERROR type_inference_tuple(struct module *mod, struct node *node) {
   size_t n = 0;
   FOREACH_SUB(s, node) {
-    if (n > 0 && (node->flags & NODE_IS_TYPE) != (s->flags & NODE_IS_TYPE)) {
+    const uint32_t s_flags = (s->which == DEFARG ? subs_last(s) : s)->flags;
+    if (n > 0 && (node->flags & NODE_IS_TYPE) != (s_flags & NODE_IS_TYPE)) {
       error e = mk_except_type(mod, s, "tuple combines values and types");
       THROW(e);
     }
-    node->flags |= (s->flags & NODE__TRANSITIVE);
+    node->flags |= (s_flags & NODE__TRANSITIVE);
     n += 1;
   }


Removed obsolete log message.

Removed obsolete log message.

--- winpr/libwinpr/timezone/timezone.c
+++ winpr/libwinpr/timezone/timezone.c
@@ -1711,8 +1711,6 @@
 #else
 	tz->Bias = 0;
 #endif
-	WLog_DBG(TAG, "tzname[std]: %s, tzname[dst]: %s, timezone: %ld, Daylight: %d",
-			   tzname[0], tzname[1], timezone, daylight);

 	dtz = winpr_detect_windows_time_zone(tz->Bias);


Changes to bitfield sending

Changes to bitfield sending

--- bt_download_manager.c
+++ bt_download_manager.c
@@ -192,7 +192,12 @@
             pwp_handshaker_release(peer->mh);
             peer->mh = pwp_msghandler_new(peer->pc);
             pwp_conn_set_state(peer->pc, PC_HANDSHAKE_RECEIVED);
-            pwp_conn_send_bitfield(peer->pc);
+            __log(me, NULL, "send,bitfield");
+            if (0 == pwp_send_bitfield(config_get_int(me->cfg,"npieces"),
+                    me->pieces_completed, __FUNC_peerconn_send_to_peer))
+            {
+                bt_dm_remove_peer(me,peer);
+            }
             break;
         default:
             return 0;


Reorganize the chain construction a bit to avoid a cast.

Before applying the patch in r1589, I tweaked the code to always fetch
the chain (to avoid a compiler warning about uninitialized 'chain').
However, that causes a leak when building a one-cert chain. So... free
the old chain. (the original was fine in setting chain, but the
compiler didn't know that)

* buckets/ssl_buckets.c:
  (validate_server_certificate): free any possible fetched chain.
    reorganize the chain construction a bit. toss the later cast.

--- buckets/ssl_buckets.c
+++ buckets/ssl_buckets.c
@@ -455,8 +455,9 @@
         (depth == 0 || failures)) {
         apr_status_t status;
         STACK_OF(X509) *chain;
-        serf_ssl_certificate_t **certs;
-        apr_size_t i, certs_len;
+        const serf_ssl_certificate_t **certs;
+        int i;
+        int certs_len;
         apr_pool_t *subpool;

         apr_pool_create(&subpool, ctx->pool);
@@ -467,6 +468,7 @@
         /* If an intermediate certificate is invalid, or if the chain can't
            be retrieved, just pass the current certificate. */
         if (depth > 0 || !chain) {
+            sk_X509_pop_free(chain, X509_free);  /* NULL is okay  */
             chain = sk_X509_new_null();
             sk_X509_push(chain, X509_dup(server_cert));
         }
@@ -474,20 +476,24 @@
         certs_len = sk_X509_num(chain);
         certs = apr_pcalloc(subpool, sizeof(*certs) * (certs_len + 1));
         for (i = 0; i < certs_len; ++i) {
-            *(certs+i) = apr_palloc(subpool, sizeof(serf_ssl_certificate_t));
-            (*(certs+i))->ssl_cert = sk_X509_value(chain, i);
-            (*(certs+i))->depth = (int)i;
-        }
-        /* Set the correct depth if we're passing an invalid certificate. */
-        if (certs_len == 1) {
-            (*certs)->depth = depth;
+            serf_ssl_certificate_t *cert = apr_palloc(subpool, sizeof(*cert));
+
+            cert->ssl_cert = sk_X509_value(chain, i);
+
+            /* If we're passing a single certificate, then use the proper
+               depth. Otherwise, use its position in the chain.  */
+            if (certs_len == 1)
+                cert->depth = depth;
+            else
+                cert->depth = i;
+
+            certs[i] = cert;
         }

         /* Callback for further verification. */
-        status = ctx->server_cert_chain_callback(
-            ctx->server_cert_userdata, failures,
-            (const serf_ssl_certificate_t * const *)certs, certs_len);
-
+        status = ctx->server_cert_chain_callback(ctx->server_cert_userdata,
+                                                 failures,
+                                                 certs, certs_len);
         if (status == APR_SUCCESS) {
             cert_valid = 1;
         } else {


Accept EINTR from waitpid()

Accept EINTR from waitpid()

git-svn-id: 7d4b18ab7d176792635d6a7a77dd8cbbea8e8daa@3095 d4fa192b-c00b-0410-8231-f00ffab90ce4

--- bin/varnishd/mgt_vcc.c
+++ bin/varnishd/mgt_vcc.c
@@ -143,7 +143,7 @@
 	char sf[] = "./vcl.########.c";
 	char of[sizeof sf + 1];
 	char *retval;
-	int p[2], sfd, srclen, status;
+	int rv, p[2], sfd, srclen, status;
 	pid_t pid;
 	void *dlh;
 	struct vlu *vlu;
@@ -213,12 +213,15 @@
 	AZ(close(p[0]));
 	VLU_Destroy(vlu);
 	(void)unlink(sf);
-	if (waitpid(pid, &status, 0) < 0) {
-		vsb_printf(sb, "%s(): waitpid() failed: %s",
-		    __func__, strerror(errno));
-		(void)unlink(of);
-		return (NULL);
-	}
+	do {
+		rv = waitpid(pid, &status, 0);
+		if (rv < 0 && errno != EINTR) {
+			vsb_printf(sb, "%s(): waitpid() failed: %s",
+			    __func__, strerror(errno));
+			(void)unlink(of);
+			return (NULL);
+		}
+	} while (rv < 0);
 	if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
 		vsb_printf(sb, "%s(): Compiler failed", __func__);
 		if (WIFEXITED(status))


Look for s-maxage before max-age.  This may need to be revisited.

git-svn-id: 2c9807fa3ff65b17195bd55dc8a6c4261e10127b@1386 d4fa192b-c00b-0410-8231-f00ffab90ce4

--- bin/varnishd/rfc2616.c
+++ bin/varnishd/rfc2616.c
@@ -109,7 +109,8 @@
 	retirement_age = INT_MAX;

 	u1 = u2 = 0;
-	if (http_GetHdrField(hp, H_Cache_Control, "max-age", &p)) {
+	if (http_GetHdrField(hp, H_Cache_Control, "s-maxage", &p) ||
+	    http_GetHdrField(hp, H_Cache_Control, "max-age", &p)) {
 		u1 = strtoul(p, NULL, 0);
 		u2 = 0;
 		if (http_GetHdr(hp, H_Age, &p)) {


xbps-create: switch --homepage to -H, add -h/--help. (cherry picked from commit 3a383c41f5dc77f5c08c90a9831123243ffa9109)

--- bin/xbps-create/main.c
+++ bin/xbps-create/main.c
@@ -59,7 +59,7 @@
 usage(void)
 {
 	fprintf(stdout,
-	"usage: %s [options] [file1] [file2] ...\n\n"
+	"usage: %s [options]\n\n"
 	"  Options:\n"
 	"    -A, --architecture   Package architecture (e.g: noarch, i686, etc).\n"
 	"    -B, --built-with     Package builder string (e.g: xbps-src-30).\n"
@@ -70,7 +70,8 @@
 	"    -d, --destdir        Package destdir.\n"
 	"    -F, --config-files   Configuration files (blank separated list,\n"
 	"                         e.g '/etc/foo.conf /etc/foo-blah.conf').\n"
-	"    -h, --homepage       Homepage.\n"
+	"    -H, --homepage       Homepage.\n"
+	"    -h, --help           Show help.\n"
 	"    -l, --license        License.\n"
 	"    -M, --mutable-files  Mutable files list (blank separated list,\n"
 	"                         e.g: '/usr/lib/foo /usr/bin/blah').\n"
@@ -84,8 +85,10 @@
 	"                         e.g: 'foo>=1.0 blah<2.0').\n"
 	"    -S, --long-desc      Long description (80 cols per line).\n"
 	"    -s, --desc           Short description (max 80 characters).\n"
-	"    -V, --version        Prints the xbps release version\n\n"
-	"  Example:\n"
+	"    -V, --version        Prints XBPS release version.\n\n"
+	"  NOTE:\n"
+	"    At least four flags are required: architecture, destdir, pkgver and desc.\n\n"
+	"  EXAMPLE:\n"
 	"    $ %s -A noarch -n foo-1.0_1 -s \"foo pkg\" -d dir\n",
 	_PROGNAME, _PROGNAME);
 	exit(EXIT_FAILURE);
@@ -515,7 +518,8 @@
 		{ "dependencies", required_argument, NULL, 'D' },
 		{ "destdir", required_argument, NULL, 'd' },
 		{ "config-files", required_argument, NULL, 'F' },
-		{ "homepage", required_argument, NULL, 'h' },
+		{ "homepage", required_argument, NULL, 'H' },
+		{ "help", no_argument, NULL, 'h' },
 		{ "license", required_argument, NULL, 'l' },
 		{ "mutable-files", required_argument, NULL, 'M' },
 		{ "maintainer", required_argument, NULL, 'm' },
@@ -544,7 +548,7 @@
 	config_files = mutable_files = NULL;

 	while ((c = getopt_long(argc, argv,
-		"A:B:C:D:d:F:h:l:M:m:n:P:pqR:S:s:V", longopts, &c)) != -1) {
+		"A:B:C:D:d:F:H:hl:M:m:n:P:pqR:S:s:V", longopts, &c)) != -1) {
 		if (optarg && strcmp(optarg, "") == 0)
 			optarg = NULL;

@@ -568,6 +572,9 @@
 			config_files = optarg;
 			break;
 		case 'h':
+			usage();
+			break;
+		case 'H':
 			homepage = optarg;
 			break;
 		case 'l':


export prototype of C function MseedLoad() that implements the respective MAL command

--- sql/backends/monet5/vaults/mseed.h
+++ sql/backends/monet5/vaults/mseed.h
@@ -86,6 +86,7 @@

 vault_export str MseedImport(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 vault_export str MseedLoadSQL(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
+vault_export str MseedLoad(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);

 #define _MSEED_DEBUG_


Portage PowerPC 64 bits

Portage PowerPC 64 bits

git-svn-id: e7e61699ce1738538ffebb75374fbea0924bc775@7431 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02

--- asmrun/signals_osdep.h
+++ asmrun/signals_osdep.h
@@ -96,6 +96,28 @@

 #elif defined(TARGET_power) && defined(SYS_rhapsody)

+#ifdef __ppc64__
+
+  #define DECLARE_SIGNAL_HANDLER(name) \
+     static void name(int sig, struct __siginfo * code, void * context)
+
+  #define SET_SIGACT(sigact,name) \
+     sigact.sa_sigaction = (name); \
+     sigact.sa_flags = SA_SIGINFO | SA_64REGSET
+
+  typedef unsigned long long context_reg;
+
+  #include <sys/ucontext.h>
+
+  #define CONTEXT_STATE (((struct ucontext64 *)context)->uc_mcontext64->ss)
+
+  #define CONTEXT_PC (CONTEXT_STATE.srr0)
+  #define CONTEXT_EXCEPTION_POINTER (CONTEXT_STATE.r29)
+  #define CONTEXT_YOUNG_LIMIT (CONTEXT_STATE.r30)
+  #define CONTEXT_YOUNG_PTR (CONTEXT_STATE.r31)
+
+#else
+
   #include <sys/utsname.h>

   #define DECLARE_SIGNAL_HANDLER(name) \
@@ -106,6 +128,7 @@
      sigact.sa_flags = SA_SIGINFO

   typedef unsigned long context_reg;
+
   #define CONTEXT_PC (*context_gpr_p(context, -2))
   #define CONTEXT_EXCEPTION_POINTER (*context_gpr_p(context, 29))
   #define CONTEXT_YOUNG_LIMIT (*context_gpr_p(context, 30))
@@ -168,6 +191,8 @@
     }
   #endif

+#endif
+
 /****************** PowerPC, ELF (Linux) */

 #elif defined(TARGET_power) && defined(SYS_elf)


android: Use helper function to convert bdaddr to android format

This will make easier to understand why swap is needed.

--- android/adapter.c
+++ android/adapter.c
@@ -31,6 +31,7 @@
 #include "log.h"
 #include "hal-msg.h"
 #include "ipc.h"
+#include "utils.h"
 #include "adapter.h"

 static GIOChannel *notification_io = NULL;
@@ -384,7 +385,7 @@

 	ev->props[0].type = HAL_PROP_ADAPTER_ADDR;
 	ev->props[0].len = sizeof(bdaddr_t);
-	baswap((bdaddr_t *) ev->props[0].val, &adapter->bdaddr);
+	bdaddr2android(&adapter->bdaddr, ev->props[0].val);

 	ipc_send(notification_io, HAL_SERVICE_ID_BLUETOOTH,
 				HAL_EV_ADAPTER_PROPS_CHANGED, len, ev, -1);


ImageJ launcher: remove obsolete warnings

Neither the launcher nor Fiji Build are built by Fiji Build itself
any longer.

Signed-off-by: Johannes Schindelin <53fb8db7833fca1e1746dd8592f61048d350f64c@gmx.de>

--- launcher/src/main/c/ImageJ.c
+++ launcher/src/main/c/ImageJ.c
@@ -3246,19 +3246,6 @@
 	die("%s", buffer->buffer);
 }

-static int is_building(const char *target)
-{
-	int i;
-	if (main_argc < 3 ||
-			(strcmp(main_argv[1], "--build") &&
-			 strcmp(main_argv[1], "--fake")))
-		return 0;
-	for (i = 2; i < main_argc; i++)
-		if (!strcmp(main_argv[i], target))
-			return 1;
-	return 0;
-}
-
 static const char *maybe_substitute_ij_jar(const char *relative_path)
 {
 	const char *replacement = NULL;
@@ -3465,9 +3452,6 @@
 		if (run_precompiled || !file_exists(fake_jar) ||
 				file_is_newer(precompiled_fake_jar, fake_jar))
 			fake_jar = precompiled_fake_jar;
-		if (file_is_newer(ij_path("src-plugins/fake/fiji/build/Fake.java"), fake_jar) &&
-				!is_building("jars/fake.jar"))
-			error("Warning: jars/fake.jar is not up-to-date");
 		string_set_length(&arg, 0);
 		string_addf(&arg, "-Djava.class.path=%s", fake_jar);
 		add_option_string(&options, &arg, 0);
@@ -3566,13 +3550,6 @@
 #else
 #define EXE_EXTENSION
 #endif
-
-	string_setf(&buffer, "%s/ij" EXE_EXTENSION, ij_dir);
-	string_setf(&buffer2, "%s/ij.c", ij_dir);
-	if (file_exists(ij_path("ImageJ" EXE_EXTENSION)) &&
-			file_is_newer(ij_path("ImageJ.c"), ij_path("ImageJ" EXE_EXTENSION)) &&
-			!is_building("ImageJ"))
-		error("Warning: your ImageJ executable is not up-to-date");

 #ifdef __linux__
 	string_append_path_list(java_library_path, getenv("LD_LIBRARY_PATH"));


Including running time

Including running time

--- iotests/aioRequests.c
+++ iotests/aioRequests.c
@@ -14,6 +14,8 @@
 extern int keepRunning;
 extern int singlePosition;
 extern int flushEvery;
+
+#define DISPLAYEVERY 1

 size_t aioMultiplePositions( positionType *positions,
 			     const size_t sz,
@@ -113,11 +115,11 @@

 	double gt = timedouble();

-	if (gt - last >= 1) {
-	  if (!tableMode) fprintf(stderr,"submitted %.1lf GiB, in flight/queue: %zd, received=%zd, index=%zd, %.0lf IO/sec, %.1lf MiB/sec\n", TOGiB(totalReadBytes + totalWriteBytes), inFlight, received, pos, submitted / (gt - start), (totalReadBytes + totalWriteBytes) / (gt - start)/1024.0/1024);
+	if (gt - last >= DISPLAYEVERY) {
+	  if (!tableMode) fprintf(stderr,"[%.1lf] submitted %.1lf GiB, in flight/queue: %zd, received=%zd, index=%zd, %.0lf IO/sec, %.1lf MiB/sec\n", gt - start, TOGiB(totalReadBytes + totalWriteBytes), inFlight, received, pos, submitted / (gt - start), (totalReadBytes + totalWriteBytes) / (gt - start)/1024.0/1024);
 	  last = gt;
-	  if ((!keepRunning) || (gt - start > secTimeout)) {
-	    //	  fprintf(stderr,"timeout\n");
+	  if ((!keepRunning) || ((long)(gt - start) >= secTimeout)) {
+	    //	    	  fprintf(stderr,"timeout\n");
 	    goto endoffunction;
 	  }
 	}
@@ -141,11 +143,11 @@

     ret = io_getevents(ctx, 0, QD, events, NULL);

-    if ((!keepRunning) || (timedouble() - start > secTimeout)) {
+    /*    if ((!keepRunning) || ((long)(timedouble() - start) >= secTimeout)) {
       if (received > 0) {
 	break;
       }
-    }
+      }*/

     if (ret > 0) {

@@ -241,7 +243,7 @@
   }

   double start = timedouble();
-  fprintf(stderr,"*info* started verification (%.2lf GiB)\n", TOGiB(bytesToVerify));
+  fprintf(stderr,"*info* started verification (%.1lf GiB)\n", TOGiB(bytesToVerify));

   for (size_t i = 0; i < maxpos; i++) {
     if (positions[i].success) {


widget-factory: Make the activity mode more complete

Test the 'no more pulse' situation. When the slider goes all
the way to the right towards slow, we remove the pulse timeout.

--- demos/widget-factory/widget-factory.c
+++ demos/widget-factory/widget-factory.c
@@ -130,9 +130,20 @@
 }

 static gint pulse_time = 250;
-
-static void
-update_pulse_time (GtkAdjustment *adjustment)
+static guint pulse_id = 0;
+
+static gboolean
+pulse_it (GtkWidget *widget)
+{
+  gtk_progress_bar_pulse (GTK_PROGRESS_BAR (widget));
+
+  pulse_id = g_timeout_add (pulse_time, (GSourceFunc)pulse_it, widget);
+
+  return G_SOURCE_REMOVE;
+}
+
+static void
+update_pulse_time (GtkAdjustment *adjustment, GtkWidget *widget)
 {
   gdouble value;

@@ -140,16 +151,16 @@

   /* vary between 50 and 450 */
   pulse_time = 50 + 4 * value;
-}
-
-static gboolean
-pulse_it (GtkWidget *widget)
-{
-  gtk_progress_bar_pulse (GTK_PROGRESS_BAR (widget));
-
-  g_timeout_add (pulse_time, pulse_it, widget);
-
-  return G_SOURCE_REMOVE;
+
+  if (value == 100 && pulse_id != 0)
+    {
+      g_source_remove (pulse_id);
+      pulse_id = 0;
+    }
+  else if (value < 100 && pulse_id == 0)
+    {
+      pulse_id = g_timeout_add (pulse_time, (GSourceFunc)pulse_it, widget);
+    }
 }

 static void
@@ -188,12 +199,11 @@
                                    win_entries, G_N_ELEMENTS (win_entries),
                                    window);

+  widget = (GtkWidget *)gtk_builder_get_object (builder, "progressbar3");
+  pulse_id = g_timeout_add (250, (GSourceFunc)pulse_it, widget);
   g_signal_connect (gtk_builder_get_object (builder, "adjustment1"),
                     "value-changed",
-                    G_CALLBACK (update_pulse_time), NULL);
-
-  widget = (GtkWidget *)gtk_builder_get_object (builder, "progressbar3");
-  g_timeout_add (250, (GSourceFunc)pulse_it, widget);
+                    G_CALLBACK (update_pulse_time), widget);

   widget = (GtkWidget *)gtk_builder_get_object (builder, "page2dismiss");
   g_signal_connect (widget, "clicked", G_CALLBACK (dismiss), NULL);


Improved start sets for blocks with one pred.

--- ir/be/bespillbelady.c
+++ ir/be/bespillbelady.c
@@ -4,8 +4,6 @@
  * Copyright:   (c) Universitaet Karlsruhe
  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
  *
- * NOTE: Comments my be (partially) wrong, since there was a major bug
- *       (spilling of phis, prespill) whose fixing changed a lot.
  */
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -50,7 +48,6 @@
 static firm_dbg_module_t *dbg = NULL;

 #define MIN(a,b) (((a)<(b))?(a):(b))
-#undef SINGLE_START_PROJS

 typedef struct _workset_t workset_t;

@@ -76,10 +73,6 @@
 	int len;			/**< current length */
 	loc_t vals[1];		/**< inlined array of the values/distances in this working set */
 };
-
-typedef struct _block_info_t {
-	workset_t *ws_start, *ws_end;
-} block_info_t;

 /**
  * Alloc a new workset on obstack @p ob with maximum size @p max
@@ -219,13 +212,28 @@
 #define workset_get_val(ws, i) ((ws)->vals[i].irn)
 #define workset_sort(ws) qsort((ws)->vals, (ws)->len, sizeof((ws)->vals[0]), loc_compare);

+typedef struct _block_info_t {
+	workset_t *ws_start, *ws_end;
+} block_info_t;
+
+
+static INLINE void *new_block_info(struct obstack *ob) {
+	block_info_t *res = obstack_alloc(ob, sizeof(*res));
+	res->ws_start = NULL;
+	res->ws_end = NULL;
+
+	return res;
+}
+
+#define get_block_info(blk)			((block_info_t *)get_irn_link(blk))
+#define set_block_info(blk, info)	set_irn_link(blk, info)

 static int is_mem_phi(const ir_node *irn, void *data) {
 	workset_t *sws;
 	ir_node *blk = get_nodes_block(irn);

 	DBG((dbg, DBG_SPILL, "Is %+F a mem-phi?\n", irn));
-	sws = ((block_info_t *) get_irn_link(blk))->ws_start;
+	sws = get_block_info(blk)->ws_start;
 	DBG((dbg, DBG_SPILL, "  %d\n", !workset_contains(sws, irn)));
 	return !workset_contains(sws, irn);
 }
@@ -237,6 +245,82 @@
 #define get_distance(bel, from, from_step, def, skip_from_uses) \
 		((arch_irn_is_ignore(bel->arch, def) ) ? 0 : be_get_next_use(bel->uses, from, from_step, def, skip_from_uses))

+
+/**
+ * Performs the actions neccessary to grant the request that:
+ * - new_vals can be held in registers
+ * - as few as possible other values are disposed
+ * - the worst values get disposed
+ *
+ * @p is_usage indicates that the values in new_vals are used (not defined)
+ * In this case reloads must be performed
+ */
+static void displace(belady_env_t *bel, workset_t *new_vals, int is_usage) {
+	ir_node *val;
+	int i, len, max_allowed, demand, iter;
+	workset_t *ws = bel->ws;
+	ir_node **to_insert = alloca(bel->n_regs * sizeof(*to_insert));
+
+	/*
+	 * 1. Identify the number of needed slots and the values to reload
+	 */
+	demand = 0;
+	workset_foreach(new_vals, val, iter) {
+		/* mark value as used */
+		if (is_usage)
+			pset_insert_ptr(bel->used, val);
+
+		if (!workset_contains(ws, val)) {
+			DBG((dbg, DBG_DECIDE, "    insert %+F\n", val));
+			to_insert[demand++] = val;
+			if (is_usage)
+				be_add_reload(bel->senv, val, bel->instr);
+		} else
+			DBG((dbg, DBG_DECIDE, "    skip %+F\n", val));
+	}
+	DBG((dbg, DBG_DECIDE, "    demand = %d\n", demand));
+
+
+	/*
+	 * 2. Make room for at least 'demand' slots
+	 */
+	len = workset_get_length(ws);
+	max_allowed = bel->n_regs - demand;
+
+	/* Only make more free room if we do not have enough */
+	if (len > max_allowed) {
+		/* get current next-use distance */
+		for (i=0; i<ws->len; ++i)
+			workset_set_time(ws, i, get_distance(bel, bel->instr, bel->instr_nr, workset_get_val(ws, i), !is_usage));
+
+		/* sort entries by increasing nextuse-distance*/
+		workset_sort(ws);
+
+		/* Logic for not needed live-ins: If a value is disposed
+		   before its first usage, remove it from start workset */
+		for (i=max_allowed; i<ws->len; ++i) {
+			ir_node *irn = ws->vals[i].irn;
+			if (!pset_find_ptr(bel->used, irn)) {
+				ir_node *curr_bb = get_nodes_block(bel->instr);
+				workset_t *ws_start = get_block_info(curr_bb)->ws_start;
+				workset_remove(ws_start, irn);
+
+				DBG((dbg, DBG_DECIDE, "    dispose %+F dumb\n", irn));
+			} else
+				DBG((dbg, DBG_DECIDE, "    dispose %+F\n", irn));
+		}
+
+		/* kill the last 'demand' entries in the array */
+		workset_set_length(ws, max_allowed);
+	}
+
+	/*
+	 * 3. Insert the new values into the workset
+	 */
+	workset_bulk_insert(bel->ws, demand, to_insert);
+}
+
+static void belady(ir_node *blk, void *env);

 /**
  * Collects all values live-in at block @p blk and all phi results in this block.
@@ -245,19 +329,28 @@
  *  their args to break interference and make it possible to spill them to the
  *  same spill slot.
  */
-static void compute_block_start_info(ir_node *blk, void *env) {
+static block_info_t *compute_block_start_info(ir_node *blk, void *env) {
 	belady_env_t *bel = env;
-	block_info_t *blk_info;
 	ir_node *irn, *first;
 	irn_live_t *li;
 	int i, count, ws_count;
 	loc_t loc, *starters;
 	ir_graph *irg = get_irn_irg(blk);
 	struct obstack ob;
-
+	block_info_t *res = get_block_info(blk);
+
+	/* Have we seen this block before? */
+	if (res)
+		return res;
+
+	/* Create the block info for this block. */
+	res = new_block_info(&bel->ob);
+	set_block_info(blk, res);
+
+
+	/* Get all values living at the block start sorted by next use*/
 	obstack_init(&ob);

-	/* Get all values living at the block start */
 	DBG((dbg, DBG_START, "Living at start of %+F:\n", blk));
 	first = sched_first(blk);
 	count = 0;
@@ -279,21 +372,42 @@
 			DBG((dbg, DBG_START, "    %+F:\n", irn));
 			count++;
 		}
+
 	starters = obstack_finish(&ob);
-
-	/* Sort all values */
 	qsort(starters, count, sizeof(starters[0]), loc_compare);

-	/* Create the start workset for this block. Copy the best ones from starters */
-	blk_info = obstack_alloc(&bel->ob, sizeof(*blk_info));
-	set_irn_link(blk, blk_info);
-
-	ws_count = MIN(count, bel->n_regs);
-	blk_info->ws_start = new_workset(&bel->ob, bel);
-	workset_bulk_fill(blk_info->ws_start, ws_count, starters);
-
-	/* Spill the phis among the remaining values */
-	for (i=ws_count; i<count; ++i) {
+
+	/* If we have only one predecessor, we want the start_set of blk to be the end_set of pred */
+	if (get_irn_arity(blk) == 1 && blk != get_irg_start_block(get_irn_irg(blk))) {
+		ir_node *pred_blk       = get_Block_cfgpred_block(blk, 0);
+		block_info_t *pred_info = get_block_info(pred_blk);
+
+		/* if pred block has not been processed yet, do it now */
+		if (! pred_info) {
+			belady(pred_blk, bel);
+			pred_info = get_block_info(pred_blk);
+		}
+
+		/* now we have an end_set of pred */
+		assert(pred_info->ws_end && "The recursive call (above) is supposed to compute an end_set");
+		res->ws_start = workset_clone(&bel->ob, pred_info->ws_end);
+
+	} else
+
+	/* Else we want the start_set to be the values used 'the closest' */
+	{
+		/* Copy the best ones from starters to start workset */
+		ws_count = MIN(count, bel->n_regs);
+		res->ws_start = new_workset(&bel->ob, bel);
+		workset_bulk_fill(res->ws_start, ws_count, starters);
+	}
+
+
+	/* The phis of this block which are not in the start set have to be spilled later.
+	 * Therefore we add temporary copies in the pred_blocks so the spills can spill
+	 * into the same spill slot.
+	 * After spilling these copies get deleted. */
+	for (i=workset_get_length(res->ws_start); i<count; ++i) {
 		int o, max;

 		irn = starters[i].irn;
@@ -314,81 +428,9 @@
 	}

 	obstack_free(&ob, NULL);
-}
-
-/**
- * Performs the actions neccessary to grant the request that:
- * - new_vals can be held in registers
- * - as few as possible other values are disposed
- * - the worst values get disposed
- *
- * @p is_usage indicates that the values in new_vals are used (not defined)
- * In this case reloads must be performed
- */
-static void displace(belady_env_t *bel, workset_t *new_vals, int is_usage) {
-	ir_node *val;
-	int i, len, max_allowed, demand, iter;
-	workset_t *ws = bel->ws;
-	ir_node **to_insert = alloca(bel->n_regs * sizeof(*to_insert));
-
-	/*
-	 * 1. Identify the number of needed slots and the values to reload
-	 */
-	demand = 0;
-	workset_foreach(new_vals, val, iter) {
-		/* mark value as used */
-		if (is_usage)
-			pset_insert_ptr(bel->used, val);
-
-		if (!workset_contains(ws, val)) {
-			DBG((dbg, DBG_DECIDE, "    insert %+F\n", val));
-			to_insert[demand++] = val;
-			if (is_usage)
-				be_add_reload(bel->senv, val, bel->instr);
-		} else
-			DBG((dbg, DBG_DECIDE, "    skip %+F\n", val));
-	}
-	DBG((dbg, DBG_DECIDE, "    demand = %d\n", demand));
-
-
-	/*
-	 * 2. Make room for at least 'demand' slots
-	 */
-	len = workset_get_length(ws);
-	max_allowed = bel->n_regs - demand;
-
-	/* Only make more free room if we do not have enough */
-	if (len > max_allowed) {
-		/* get current next-use distance */
-		for (i=0; i<ws->len; ++i)
-			workset_set_time(ws, i, get_distance(bel, bel->instr, bel->instr_nr, workset_get_val(ws, i), !is_usage));
-
-		/* sort entries by increasing nextuse-distance*/
-		workset_sort(ws);
-
-		/* Logic for not needed live-ins: If a value is disposed
-		   before its first usage, remove it from start workset */
-		for (i=max_allowed; i<ws->len; ++i) {
-			ir_node *irn = ws->vals[i].irn;
-			if (!pset_find_ptr(bel->used, irn)) {
-				ir_node *curr_bb = get_nodes_block(bel->instr);
-				workset_t *ws_start = ((block_info_t *) get_irn_link(curr_bb))->ws_start;
-				workset_remove(ws_start, irn);
-
-				DBG((dbg, DBG_DECIDE, "    dispose %+F dumb\n", irn));
-			} else
-				DBG((dbg, DBG_DECIDE, "    dispose %+F\n", irn));
-		}
-
-		/* kill the last 'demand' entries in the array */
-		workset_set_length(ws, max_allowed);
-	}
-
-	/*
-	 * 3. Insert the new values into the workset
-	 */
-	workset_bulk_insert(bel->ws, demand, to_insert);
-}
+	return res;
+}
+

 /**
  * For the given block @p blk, decide for each values
@@ -400,17 +442,20 @@
 	workset_t *new_vals;
 	ir_node *irn;
 	int iter;
-
-#ifdef SINGLE_START_PROJS
-	ir_node *start_blk = get_irg_start_block(get_irn_irg(blk));
-#endif
-	block_info_t *blk_info = get_irn_link(blk);
+	block_info_t *blk_info;
+
+	/* Don't do a block twice */
+	if (get_block_info(blk))
+		return;
+
+	/* get the starting workset for this block */
+	blk_info = compute_block_start_info(blk, bel);

 	DBG((dbg, DBG_DECIDE, "\n"));
 	DBG((dbg, DBG_DECIDE, "Decide for %+F\n", blk));

 	workset_copy(bel->ws, blk_info->ws_start);
-	DBG((dbg, DBG_WSETS, "Initial start workset for %+F:\n", blk));
+	DBG((dbg, DBG_WSETS, "Start workset for %+F:\n", blk));
 	workset_foreach(bel->ws, irn, iter)
 		DBG((dbg, DBG_WSETS, "  %+F\n", irn));

@@ -423,14 +468,6 @@
 		assert(workset_get_length(bel->ws) <= bel->n_regs && "Too much values in workset!");

-#ifdef SINGLE_START_PROJS
-		if (is_Phi(irn) ||
-			(is_Proj(irn) && blk!=start_blk) ||
-			(get_irn_mode(irn) == mode_T && blk==start_blk)) {
-			DBG((dbg, DBG_DECIDE, "  ...%+F skipped\n", irn));
-			continue;
-		}
-#else
 		/* projs are handled with the tuple value.
 		 * Phis are no real instr (see insert_starters)
 		 * instr_nr does not increase */
@@ -438,7 +475,6 @@
 			DBG((dbg, DBG_DECIDE, "  ...%+F skipped\n", irn));
 			continue;
 		}
-#endif
 		DBG((dbg, DBG_DECIDE, "  ...%+F\n", irn));

 		/* set instruction in the workset */
@@ -466,9 +502,6 @@

 	/* Remember end-workset for this block */
 	blk_info->ws_end = workset_clone(&bel->ob, bel->ws);
-	DBG((dbg, DBG_WSETS, "Start workset for %+F:\n", blk));
-	workset_foreach(blk_info->ws_start, irn, iter)
-		DBG((dbg, DBG_WSETS, "  %+F\n", irn));
 	DBG((dbg, DBG_WSETS, "End workset for %+F:\n", blk));
 	workset_foreach(blk_info->ws_end, irn, iter)
 		DBG((dbg, DBG_WSETS, "  %+F\n", irn));
@@ -487,12 +520,12 @@
 	DBG((dbg, DBG_FIX, "\n"));
 	DBG((dbg, DBG_FIX, "Fixing %+F\n", blk));

-	wsb = ((block_info_t *)get_irn_link(blk))->ws_start;
+	wsb = get_block_info(blk)->ws_start;

 	/* process all pred blocks */
 	for (i=0, max=get_irn_arity(blk); i<max; ++i) {
 		ir_node *irnb, *irnp, *pred = get_Block_cfgpred_block(blk, i);
-		workset_t *wsp = ((block_info_t *)get_irn_link(pred))->ws_end;
+		workset_t *wsp = get_block_info(pred)->ws_end;

 		DBG((dbg, DBG_FIX, "  Pred %+F\n", pred));

@@ -597,14 +630,12 @@
 	DBG((dbg, LEVEL_1, "running on register class: %s\n", bel.cls->name));

 	/* do the work */
-	irg_block_walk_graph(chordal_env->irg, compute_block_start_info, NULL, &bel);
-	irg_block_walk_graph(chordal_env->irg, belady, NULL, &bel);
+	be_clear_links(chordal_env->irg);
+	irg_block_walk_graph(chordal_env->irg, NULL, belady, &bel);
 	irg_block_walk_graph(chordal_env->irg, fix_block_borders, NULL, &bel);
 	be_insert_spills_reloads(bel.senv, bel.reloads);
 	remove_unused_reloads(chordal_env->irg, &bel);
 	remove_copies(&bel);
-
-

 	/* clean up */
 	del_pset(bel.reloads);


next bug found in 179.parser

next bug found in 179.parser

[r13962]

error: pathspec 'ir/be/test/fehler13.c' did not match any file(s) known to git

--- ir/be/test/fehler13.c
+++ ir/be/test/fehler13.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+int main()
+{
+	const char *s = "This is cool";
+	const char *t;
+
+	for(t=s; !((isspace(*t) || (*t == '\"')) || *t=='\0'); t++)
+		;
+
+	printf("Res: %s\n", t);
+
+	return 0;
+}