Add and use get_commutative_other_op().

Add and use get_commutative_other_op().

--- ir/ir/iropt.c
+++ ir/ir/iropt.c
@@ -741,6 +741,18 @@
 	return n;
 }

+static ir_node *get_commutative_other_op(ir_node *const node, ir_node *const op)
+{
+	assert(is_op_commutative(get_irn_op(node)));
+	ir_node *const l = get_binop_left(node);
+	ir_node *const r = get_binop_right(node);
+	if (l == op)
+		return r;
+	if (r == op)
+		return l;
+	return NULL;
+}
+
 /**
  * Eor is commutative and has neutral 0.
  */
@@ -754,34 +766,21 @@
 	ir_node *a = get_Eor_left(n);
 	ir_node *b = get_Eor_right(n);

+	ir_node *x;
+	ir_node *z;
 	if (is_Eor(a) || is_Or_Eor_Add(a)) {
-		ir_node *aa = get_binop_left(a);
-		ir_node *ab = get_binop_right(a);
-
-		if (aa == b) {
-			/* (a ^ b) ^ a -> b */
-			n = ab;
-			DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_EOR_A_B_A);
-			return n;
-		} else if (ab == b) {
-			/* (a ^ b) ^ b -> a */
-			n = aa;
-			DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_EOR_A_B_A);
-			return n;
-		}
+		x = b;
+		z = a;
+		goto inverse;
 	}
 	if (is_Eor(b) || is_Or_Eor_Add(b)) {
-		ir_node *ba = get_binop_left(b);
-		ir_node *bb = get_binop_right(b);
-
-		if (ba == a) {
-			/* a ^ (a ^ b) -> b */
-			n = bb;
-			DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_EOR_A_B_A);
-			return n;
-		} else if (bb == a) {
-			/* a ^ (b ^ a) -> b */
-			n = ba;
+		x = a;
+		z = b;
+inverse:;
+		ir_node *const y = get_commutative_other_op(z, x);
+		if (y) {
+			/* x ^ (x ^ y) -> y */
+			n = y;
 			DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_EOR_A_B_A);
 			return n;
 		}
@@ -1026,15 +1025,13 @@
 		return n;
 	}
 	/* (a|X) & a => a*/
-	if ((is_Or(a) || is_Or_Eor_Add(a))
-	    && (b == get_binop_left(a) || b == get_binop_right(a))) {
+	if ((is_Or(a) || is_Or_Eor_Add(a)) && get_commutative_other_op(a, b)) {
 		n = b;
 		DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_AND);
 		return n;
 	}
 	/* a & (a|X) => a*/
-	if ((is_Or(b) || is_Or_Eor_Add(b))
-	    && (a == get_binop_left(b) || a == get_binop_right(b))) {
+	if ((is_Or(b) || is_Or_Eor_Add(b)) && get_commutative_other_op(b, a)) {
 		n = a;
 		DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_AND);
 		return n;
@@ -2697,41 +2694,16 @@
 	}
 	/* do NOT execute this code if reassociation is enabled, it does the inverse! */
 	if (!is_reassoc_running() && is_Mul(a)) {
-		ir_node *ma = get_Mul_left(a);
-		ir_node *mb = get_Mul_right(a);
-
-		if (ma == b) {
-			ir_node  *blk = get_nodes_block(n);
-			ir_graph *irg = get_irn_irg(n);
-			n = new_rd_Mul(
-					get_irn_dbg_info(n),
-					blk,
-					ma,
-					new_rd_Sub(
-						get_irn_dbg_info(n),
-						blk,
-						mb,
-						new_r_Const(irg, get_mode_one(mode)),
-						mode),
-					mode);
-			DBG_OPT_ALGSIM0(oldn, n, FS_OPT_SUB_MUL_A_X_A);
-			return n;
-		}
-
-		if (mb == b) {
-			ir_node  *blk = get_nodes_block(n);
-			ir_graph *irg = get_irn_irg(n);
-			n = new_rd_Mul(
-					get_irn_dbg_info(n),
-					blk,
-					mb,
-					new_rd_Sub(
-						get_irn_dbg_info(n),
-						blk,
-						ma,
-						new_r_Const(irg, get_mode_one(mode)),
-						mode),
-					mode);
+		ir_node *const x = b;
+		ir_node *const y = get_commutative_other_op(a, x);
+		if (y) {
+			/* (x * y) - x -> x * (y - 1) */
+			dbg_info *const dbg = get_irn_dbg_info(n);
+			ir_node  *const blk = get_nodes_block(n);
+			ir_graph *const irg = get_irn_irg(n);
+			ir_node  *const one = new_r_Const(irg, get_mode_one(mode));
+			ir_node  *const sub = new_rd_Sub(dbg, blk, y, one, mode);
+			n = new_rd_Mul(dbg, blk, x, sub, mode);
 			DBG_OPT_ALGSIM0(oldn, n, FS_OPT_SUB_MUL_A_X_A);
 			return n;
 		}
@@ -3450,52 +3422,24 @@
 			}
 		}
 	}
+	ir_node *x;
+	ir_node *y;
 	if (is_Eor(a) || is_Or_Eor_Add(a)) {
-		ir_node *al = get_binop_left(a);
-		ir_node *ar = get_binop_right(a);
-
-		if (al == b) {
-			/* (b ^ a) & b -> ~a & b */
-			dbg_info *dbg  = get_irn_dbg_info(n);
-			ir_node *block = get_nodes_block(n);
-
-			ar = new_rd_Not(dbg, block, ar, mode);
-			n  = new_rd_And(dbg, block, ar, b, mode);
-			DBG_OPT_ALGSIM0(oldn, n, FS_OPT_EOR_TO_NOT);
-			return n;
-		}
-		if (ar == b) {
-			/* (a ^ b) & b -> ~a & b */
-			dbg_info *dbg  = get_irn_dbg_info(n);
-			ir_node *block = get_nodes_block(n);
-
-			al = new_rd_Not(dbg, block, al, mode);
-			n  = new_rd_And(dbg, block, al, b, mode);
-			DBG_OPT_ALGSIM0(oldn, n, FS_OPT_EOR_TO_NOT);
-			return n;
-		}
+		x = b;
+		y = get_commutative_other_op(a, x);
+		if (y) /* (x ^ y) & x -> ~y & x */
+			goto absorb;
 	}
 	if (is_Eor(b) || is_Or_Eor_Add(b)) {
-		ir_node *bl = get_binop_left(b);
-		ir_node *br = get_binop_right(b);
-
-		if (bl == a) {
-			/* a & (a ^ b) -> a & ~b */
-			dbg_info *dbg  = get_irn_dbg_info(n);
-			ir_node *block = get_nodes_block(n);
-
-			br = new_rd_Not(dbg, block, br, mode);
-			n  = new_rd_And(dbg, block, br, a, mode);
-			DBG_OPT_ALGSIM0(oldn, n, FS_OPT_EOR_TO_NOT);
-			return n;
-		}
-		if (br == a) {
-			/* a & (b ^ a) -> a & ~b */
-			dbg_info *dbg  = get_irn_dbg_info(n);
-			ir_node *block = get_nodes_block(n);
-
-			bl = new_rd_Not(dbg, block, bl, mode);
-			n  = new_rd_And(dbg, block, bl, a, mode);
+		x = a;
+		y = get_commutative_other_op(b, x);
+		if (y) {
+			/* x & (x ^ y) -> ~y & x */
+absorb:;
+			dbg_info *const dbg   = get_irn_dbg_info(n);
+			ir_node  *const block = get_nodes_block(n);
+			ir_node  *const noty  = new_rd_Not(dbg, block, y, mode);
+			n = new_rd_And(dbg, block, noty, x, mode);
 			DBG_OPT_ALGSIM0(oldn, n, FS_OPT_EOR_TO_NOT);
 			return n;
 		}
@@ -4128,35 +4072,25 @@
 			}

 			/* X+A == A, A+X == A, X^A == A, A^X == A, A-X == A -> X == 0 */
+			ir_node *x;
 			if (is_Add(left) || is_Eor(left) || is_Sub(left) || is_Or_Eor_Add(left)) {
-				ir_node *ll = get_binop_left(left);
-				ir_node *lr = get_binop_right(left);
-
-				if (lr == right && (is_Add(left) || is_Eor(left) || is_Or_Eor_Add(left))) {
-					ir_node *tmp = ll;
-					ll = lr;
-					lr = tmp;
+				if (is_Sub(left)) {
+					x = get_Sub_right(left) == right ? get_Sub_left(left) : NULL;
+				} else {
+					x = get_commutative_other_op(left, right);
 				}
-				if (ll == right) {
+				goto cmp_x_eq_0;
+			}
+			if (is_Add(right) || is_Eor(right) || is_Sub(right) || is_Or_Eor_Add(right)) {
+				if (is_Sub(right)) {
+					x = get_Sub_right(right) == left ? get_Sub_left(right) : NULL;
+				} else {
+					x = get_commutative_other_op(right, left);
+				}
+cmp_x_eq_0:
+				if (x) {
 					ir_graph *irg = get_irn_irg(n);
-					left     = lr;
-					right   = create_zero_const(irg, mode);
-					changed = true;
-					DBG_OPT_ALGSIM0(n, n, FS_OPT_CMP_OP_OP);
-				}
-			}
-			if (is_Add(right) || is_Eor(right) || is_Sub(right) || is_Or_Eor_Add(right)) {
-				ir_node *rl = get_binop_left(right);
-				ir_node *rr = get_binop_right(right);
-
-				if (rr == left && (is_Add(right) || is_Eor(left) || is_Or_Eor_Add(right))) {
-					ir_node *tmp = rl;
-					rl = rr;
-					rr = tmp;
-				}
-				if (rl == left) {
-					ir_graph *irg = get_irn_irg(n);
-					left     = rr;
+					left    = x;
 					right   = create_zero_const(irg, mode);
 					changed = true;
 					DBG_OPT_ALGSIM0(n, n, FS_OPT_CMP_OP_OP);


Removed inheritance of std:less in network data structures
BUG=None
TEST-None

Review URL: http://codereview.chromium.org/3116032

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@57159 0039d316-1c4b-4281-b951-d872f2087c98

--- chrome/browser/geolocation/device_data_provider.h
+++ chrome/browser/geolocation/device_data_provider.h
@@ -24,7 +24,6 @@
 #pragma once

 #include <algorithm>
-#include <functional>
 #include <set>
 #include <vector>

@@ -133,7 +132,7 @@

 // This is to allow AccessPointData to be used in std::set. We order
 // lexicographically by MAC address.
-struct AccessPointDataLess : public std::less<AccessPointData> {
+struct AccessPointDataLess {
   bool operator()(const AccessPointData& data1,
                   const AccessPointData& data2) const {
     return data1.mac_address < data2.mac_address;
@@ -185,7 +184,7 @@

 // This is to allow RouterData to be used in std::set. We order
 // lexicographically by MAC address.
-struct RouterDataLess : public std::less<RouterData> {
+struct RouterDataLess {
   bool operator()(const RouterData& data1,
                   const RouterData& data2) const {
     return data1.mac_address < data2.mac_address;


Consistentcy: log to stderr for both enc and dec

--- heatshrink_encoder.c
+++ heatshrink_encoder.c
@@ -22,7 +22,7 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <assert.h>
-#define LOG(...) printf(__VA_ARGS__)
+#define LOG(...) fprintf(stderr, __VA_ARGS__)
 #define ASSERT(X) assert(X)
 static const char *state_names[] = {
     "not_full",


remove empty lines in output

remove empty lines in output

git-svn-id: 31d9d2f6432a47c86a3640814024c107794ea77c@33031 0785d39b-7218-0410-832d-ea1e28bc413d

--- deal.II/include/deal.II/algorithms/operator.templates.h
+++ deal.II/include/deal.II/algorithms/operator.templates.h
@@ -147,7 +147,6 @@
             if (v == 0) continue;
             for (unsigned int j=0; j<v->size(); ++j)
               (*os) << ' ' << (*v)(j);
-            (*os) << std::endl;
           }
         (*os) << std::endl;
       }


Thrift-1444:FunctionRunner - add syntactic sugar to create shared_ptrs
Client: cpp
Patch: Dave Watson

Simplify FunctionRunner addTask calls.

git-svn-id: e03702e31dc1037215618ef8d1dc0ebc5b0b17e5@1210741 13f79535-47bb-0310-9956-ffa450edef68

--- lib/cpp/src/concurrency/FunctionRunner.h
+++ lib/cpp/src/concurrency/FunctionRunner.h
@@ -34,16 +34,15 @@
  *  void* my_thread_main(void* arg);
  *  shared_ptr<ThreadFactory> factory = ...;
  *  // To create a thread that executes my_thread_main once:
- *  shared_ptr<Thread> thread =
- *    factory->newThread(shared_ptr<FunctionRunner>(
- *      new FunctionRunner(my_thread_main, some_argument)));
+ *  shared_ptr<Thread> thread = factory->newThread(
+ *    FunctionRunner::create(my_thread_main, some_argument));
  *  thread->start();
  *
  *  bool A::foo();
  *  A* a = new A();
  *  // To create a thread that executes a.foo() every 100 milliseconds:
- *  factory->newThread(shared_ptr<FunctionRunner>(
- *    new FunctionRunner(std::tr1::bind(&A::foo, a), 100)))->start();
+ *  factory->newThread(FunctionRunner::create(
+ *    std::tr1::bind(&A::foo, a), 100))->start();
  *
  */

@@ -55,6 +54,20 @@
   typedef std::tr1::function<void()> VoidFunc;

   typedef std::tr1::function<bool()> BoolFunc;
+
+  /**
+   * Syntactic sugar to make it easier to create new FunctionRunner
+   * objects wrapped in shared_ptr.
+   */
+  static boost::shared_ptr<FunctionRunner> create(const VoidFunc& cob) {
+    return boost::shared_ptr<FunctionRunner>(new FunctionRunner(cob));
+  }
+
+  static boost::shared_ptr<FunctionRunner> create(PthreadFuncPtr func,
+                                                  void* arg) {
+    return boost::shared_ptr<FunctionRunner>(new FunctionRunner(func, arg));
+  }
+

   /**
    * Given a 'pthread_create' style callback, this FunctionRunner will


Create ILog.h

Create ILog.h

error: pathspec 'Kiwa-tech/Common/Log/ILog.h' did not match any file(s) known to git

--- Kiwa-tech/Common/Log/ILog.h
+++ Kiwa-tech/Common/Log/ILog.h
@@ -0,0 +1 @@
+


leaky fd fix

leaky fd fix

--- smtp.c
+++ smtp.c
@@ -209,6 +209,7 @@
 	return( SMTP_ERROR );
     }

+    *snetp = snet;
     tv.tv_sec = SMTP_TIME_CONNECT;
     tv.tv_usec = 0;

@@ -338,7 +339,6 @@
 		return( SMTP_BAD_CONNECTION );
 	    }
 	}
-	*snetp = snet;
 	hq->hq_status = HOST_MX;
 	return( SMTP_OK );


Fix autofocus logic

Fix autofocus logic

--- src/omv/sensors/ov5640.c
+++ src/omv/sensors/ov5640.c
@@ -677,7 +677,7 @@
     ret |= cambus_writeb2(&sensor->bus, sensor->slv_addr, SYSTEM_RESET_00, 0x20); // force mcu reset

     // Write firmware
-    uint16_t fw_addr = MCU_FIRMWARE_BASE;
+    uint16_t fw_addr = __REV16(MCU_FIRMWARE_BASE);
     ret |= cambus_write_bytes(&sensor->bus, sensor->slv_addr, (uint8_t *) &fw_addr, 2, CAMBUS_XFER_SUSPEND);
     ret |= cambus_write_bytes(&sensor->bus, sensor->slv_addr, (uint8_t *) af_firmware_regs, sizeof(af_firmware_regs), CAMBUS_XFER_NO_FLAGS);


remove propagation of Unknown. This causes problems in backends in in
Firm "hand" construction

[r7523]

--- ir/ir/iropt.c
+++ ir/ir/iropt.c
@@ -3500,8 +3500,15 @@

       if (is_Bad(pred))
         return new_Bad();
+#if 0
+      /* Propagating Unknowns here seems to be a bad idea, because
+         sometimes we need a node as a input and did not want that
+         it kills it's user.
+         However, i might be useful to move this into a later phase
+         (it you thing optimizing such code is useful). */
       if (is_Unknown(pred) && mode_is_data(get_irn_mode(node)))
         return new_Unknown(get_irn_mode(node));
+#endif
     }
   }
 #if 0


Modified argc restriction in sort.c

Modified argc restriction in sort.c

--- sort.c
+++ sort.c
@@ -15,11 +15,15 @@
 }

 int main(int argc, char **argv){
-  int i = -1;
   int a[] = {1, 232, 4, 32, 24, 5, 6, 77, 22};
   char c;

-  printf("Input array follows\n");
+  if (argc != 2){
+    printf("Error: Check usage\n\n");
+    help_opts(argv[0]);
+    exit(1);
+  }
+
   print_array(&a[0], sizeof(a)/sizeof(a[0]));
   printf("\n");

@@ -27,25 +31,21 @@
     switch (c)
       {
       case 'a':
-        i = 1;
         printf("Executing Bubble sort\n");
         bubble_sort(&a[0], sizeof(a)/sizeof(a[0]));
         break;

       case 'b':
-        i = 1;
         printf("Executing Selection sort\n");
         selection_sort(&a[0], sizeof(a)/sizeof(a[0]));
         break;

       case 'c':
-        i = 1;
         printf("Executing Selection sort\n");
         insertion_sort(&a[0], sizeof(a)/sizeof(a[0]));
         break;

       case 'h':
-        i = 1;
         help_opts(argv[0]);
         exit(0);

@@ -55,12 +55,6 @@
       }
   }

-  if (i == -1){
-    printf("Error: Input options are mandatory\n\n");
-    help_opts(argv[0]);
-    exit(1);
-  }
-
   printf("\n");
   printf("Sorted list follows: \n");
   print_array(&a[0], sizeof(a)/sizeof(a[0]));


dnd: Support dropping as text/plain;charset=utf-8

--- clients/dnd.c
+++ clients/dnd.c
@@ -82,6 +82,7 @@
 static const int item_padding = 16;

 static const char flower_mime_type[] = "application/x-wayland-dnd-flower";
+static const char text_mime_type[] = "text/plain;charset=utf-8";

 static struct item *
 item_create(struct display *display, int x, int y, int seed)
@@ -280,13 +281,26 @@
 {
 	struct dnd_flower_message dnd_flower_message;
 	struct dnd_drag *dnd_drag = data;
-
-	dnd_flower_message.seed = dnd_drag->item->seed;
-	dnd_flower_message.x_offset = dnd_drag->x_offset;
-	dnd_flower_message.y_offset = dnd_drag->y_offset;
-
-	if (write(fd, &dnd_flower_message, sizeof dnd_flower_message) < 0)
-		abort();
+	char buffer[128];
+	int n;
+
+	if (strcmp(mime_type, flower_mime_type) == 0) {
+		dnd_flower_message.seed = dnd_drag->item->seed;
+		dnd_flower_message.x_offset = dnd_drag->x_offset;
+		dnd_flower_message.y_offset = dnd_drag->y_offset;
+
+		if (write(fd, &dnd_flower_message,
+			  sizeof dnd_flower_message) < 0)
+			abort();
+	} else if (strcmp(mime_type, text_mime_type) == 0) {
+		n = snprintf(buffer, sizeof buffer, "seed=%d x=%d y=%d\n",
+			     dnd_drag->item->seed,
+			     dnd_drag->x_offset,
+			     dnd_drag->y_offset);
+
+		if (write(fd, buffer, n) < 0)
+			abort();
+	}

 	close(fd);
 }
@@ -425,9 +439,9 @@
 						    &data_source_listener,
 						    dnd_drag);
 			wl_data_source_offer(dnd_drag->data_source,
-					     "application/x-wayland-dnd-flower");
+					     flower_mime_type);
 			wl_data_source_offer(dnd_drag->data_source,
-					     "text/plain; charset=utf-8");
+					     text_mime_type);
 		}

 		wl_data_device_start_drag(input_get_data_device(input),


fix crash regression in swscale with odd size YUV image

fixes https://github.com/mltframework/shotcut/issues/1266

--- src/modules/avformat/filter_swscale.c
+++ src/modules/avformat/filter_swscale.c
@@ -132,7 +132,7 @@
 		avinframe->sample_aspect_ratio = av_d2q(mlt_frame_get_aspect_ratio(frame), 1024);
 		avinframe->interlaced_frame = !mlt_properties_get_int(properties, "progressive");
 		avinframe->top_field_first = mlt_properties_get_int(properties, "top_field_first");
-		mlt_image_format_planes(*format, iwidth, iheight, *image, avinframe->data, avinframe->linesize);
+		av_image_fill_arrays(avinframe->data, avinframe->linesize, *image, avinframe->format, iwidth, iheight, 1);

 		// Setup the output image
 		av_frame_copy_props(avoutframe, avinframe);


[C++, ILT] Removed disabled code in IltProvider.h

Change-Id: I2eb4afa7b287a9b9bb3ae2ee7bbe992c7cd0e67b

--- tests/inter-language-test/src/main/cpp/IltProvider.h
+++ tests/inter-language-test/src/main/cpp/IltProvider.h
@@ -20,17 +20,7 @@
 #define MY_PROVIDER_H

 #include "joynr/interlanguagetest/DefaultTestInterfaceProvider.h"
-#if 0
-#include "joynr/vehicle/QtTestInterfaceStation.h"
-#include "joynr/vehicle/QtCountry.h"
-#endif
-//#include "joynr/joynrlogging.h"
 #include "joynr/Logger.h"
-#if 0
-#include <QList>
-#include <QMap>
-#include <QMutex>
-#endif

 /**
   * A TestInterface Provider with a circular list of radio stations


gdu volume monitor: Fix check for symlinks in /dev, was reversed

Spotted by Emilio Pozuelo Monfort in
https://bugzilla.gnome.org/show_bug.cgi?id=601497

--- monitor/gdu/ggduvolumemonitor.c
+++ monitor/gdu/ggduvolumemonitor.c
@@ -1427,7 +1427,7 @@
           GduDevice *device;

           /* doesn't exist */
-          if (realpath (device_file, resolved_path) != NULL)
+          if (realpath (device_file, resolved_path) == NULL)
             continue;

           /* is handled by DKD */


is_sorted function added

is_sorted function added

--- sort.h
+++ sort.h
@@ -92,6 +92,30 @@
 	quick_sort(begin, end, less<T>());
 }

+// True if given set of data is sorted according to given predicate.
+// Ie, for every pair of objects x = data[i], y = data[i + 1], pred(y, x) doesn't return true;
+template<typename TIter, typename TPredicate>
+bool is_sorted(TIter begin, TIter end, TPredicate pred)
+{
+	TIter it = begin;
+	TIter it_prev = it;
+	bool is_sorted = true;
+	while (it != end)
+	{
+		if (it_prev != it)
+		{
+			if (pred(*it, *it_prev))
+			{
+				is_sorted = false;
+				break;
+			}
+		}
+		it_prev = it;
+		++it;
+	}
+	return is_sorted;
 }

+} // rde
+
 #endif


Add len and subscr (a hack) support for strings.

--- py/runtime.c
+++ py/runtime.c
@@ -14,11 +14,6 @@
 #include "mpyconfig.h"
 #include "runtime.h"
 #include "bc.h"
-
-#if MICROPY_ENABLE_FLOAT
-// for sqrt
-#include <math.h>
-#endif

 #if 0 // print debugging info
 #define DEBUG_PRINT (1)
@@ -873,7 +868,10 @@

 py_obj_t py_builtin_len(py_obj_t o_in) {
     py_small_int_t len = 0;
-    if (IS_O(o_in, O_TUPLE) || IS_O(o_in, O_LIST)) {
+    if (IS_O(o_in, O_STR)) {
+        py_obj_base_t *o = o_in;
+        len = strlen(qstr_str(o->u_str));
+    } else if (IS_O(o_in, O_TUPLE) || IS_O(o_in, O_LIST)) {
         py_obj_base_t *o = o_in;
         len = o->u_tuple_list.len;
     } else if (IS_O(o_in, O_MAP)) {
@@ -892,6 +890,7 @@
             val = -val;
         }
         return TO_SMALL_INT(val);
+#if MICROPY_ENABLE_FLOAT
     } else if (IS_O(o_in, O_FLOAT)) {
         py_obj_base_t *o = o_in;
         // TODO check for NaN etc
@@ -902,7 +901,8 @@
         }
     } else if (IS_O(o_in, O_COMPLEX)) {
         py_obj_base_t *o = o_in;
-        return py_obj_new_float(sqrt(o->u_complex.real*o->u_complex.real + o->u_complex.imag*o->u_complex.imag));
+        return py_obj_new_float(machine_sqrt(o->u_complex.real*o->u_complex.real + o->u_complex.imag*o->u_complex.imag));
+#endif
     } else {
         assert(0);
         return py_const_none;
@@ -1279,7 +1279,12 @@
 py_obj_t rt_binary_op(int op, py_obj_t lhs, py_obj_t rhs) {
     DEBUG_OP_printf("binary %d %p %p\n", op, lhs, rhs);
     if (op == RT_BINARY_OP_SUBSCR) {
-        if ((IS_O(lhs, O_TUPLE) || IS_O(lhs, O_LIST))) {
+        if (IS_O(lhs, O_STR)) {
+            // string access
+            // XXX a hack!
+            const char *str = qstr_str(((py_obj_base_t*)lhs)->u_str);
+            return py_obj_new_int(str[FROM_SMALL_INT(rhs)]);
+        } else if ((IS_O(lhs, O_TUPLE) || IS_O(lhs, O_LIST))) {
             // tuple/list load
             uint index = get_index(lhs, rhs);
             return ((py_obj_base_t*)lhs)->u_tuple_list.items[index];


Mark FILESYSTEM_ERRCOUNT_NOTIFY_LIMIT as an unsigned int

Fix the compilationof mavlink_mission.cpp failing with

error: comparison between signed and unsigned integer expressions
[-Werror=sign-compare]

--- src/modules/mavlink/mavlink_mission.h
+++ src/modules/mavlink/mavlink_mission.h
@@ -133,7 +133,7 @@

 	bool _verbose;

-	static constexpr int	FILESYSTEM_ERRCOUNT_NOTIFY_LIMIT = 2;	///< Error count limit before stopping to report FS errors
+	static constexpr unsigned int	FILESYSTEM_ERRCOUNT_NOTIFY_LIMIT = 2;	///< Error count limit before stopping to report FS errors

 	/* do not allow top copying this class */
 	MavlinkMissionManager(MavlinkMissionManager &);


ir: Simplify trivial Phi detection in equivalent_node_Phi().

--- ir/ir/iropt.c
+++ ir/ir/iropt.c
@@ -1361,32 +1361,20 @@
 	if (n_preds == 0)
 		return n;

-	/* Find first non-self-referencing input */
+	/* Determine whether the Phi is trivial, i.e. it only references itself and
+	 * one other value. */
 	bool     had_self_loop = false;
 	ir_node *first_val     = NULL;
-	int      i;
-	for (i = 0; i < n_preds; ++i) {
-		first_val = get_Phi_pred(n, i);
-		/* not self pointer */
-		if (first_val != n) {
-			/* then found first value. */
-			break;
-		} else {
+	foreach_irn_in(n, i, pred) {
+		if (pred == n) {
 			had_self_loop = true;
-		}
-	}
-
-	/* search for rest of inputs, determine if any of these
-	 * are non-self-referencing */
-	for (++i; i < n_preds; ++i) {
-		const ir_node *scnd_val = get_Phi_pred(n, i);
-		if (scnd_val == n) {
-			had_self_loop = true;
-			continue;
-		}
-		/* more than 1 unique value found? abort */
-		if (scnd_val != first_val)
-			return n;
+		} else if (pred != first_val) {
+			/* more than 1 unique value found? abort */
+			if (first_val)
+				return n;
+			/* First non-self-referencing input */
+			first_val = pred;
+		}
 	}

 	/* if we are here then all inputs are either self-loops or first_val */


Free memory used by timsort.

Free memory used by timsort.

--- sort.h
+++ sort.h
@@ -341,6 +341,10 @@
     tim_sort_merge(dst, run_stack, stack_curr, store); \
     stack_curr--; \
   } \
+  if (store->storage != NULL)\
+  {\
+    free(store->storage);\
+  }\
   return;\
 }\
 }\


py: Remove obsolete mp_delete_subscr declaration.

--- py/runtime.h
+++ py/runtime.h
@@ -52,7 +52,6 @@
 void mp_load_method_maybe(mp_obj_t base, qstr attr, mp_obj_t *dest);
 void mp_store_attr(mp_obj_t base, qstr attr, mp_obj_t val);
 void mp_store_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val);
-void mp_delete_subscr(mp_obj_t base, mp_obj_t index);

 mp_obj_t mp_getiter(mp_obj_t o);
 mp_obj_t mp_iternext_allow_raise(mp_obj_t o); // may return MP_OBJ_NULL instead of raising StopIteration()


Remove the unused set common oneof variables in helper

--- src/google/protobuf/compiler/javanano/javanano_helpers.h
+++ src/google/protobuf/compiler/javanano/javanano_helpers.h
@@ -191,9 +191,6 @@

 bool HasMapField(const Descriptor* descriptor);

-void SetCommonOneofVariables(const FieldDescriptor* field,
-                             map<string, string>* variables);
-
 }  // namespace javanano
 }  // namespace compiler
 }  // namespace protobuf


remove pure virtual

remove pure virtual

--- src/uas/UASParameterDataModel.h
+++ src/uas/UASParameterDataModel.h
@@ -13,7 +13,7 @@

     /** @brief Write a new pending parameter value that may be eventually sent to the UAS */
-    virtual void setPendingParameter(int componentId,  QString& paramKey,  QVariant& paramValue) = 0;
+    virtual void setPendingParameter(int componentId,  QString& paramKey,  QVariant& paramValue);

     QMap<int, QMap<QString, QVariant>* >  getPendingParameters() {
        return pendingParameters;


[svn] initialize variable before using it

--- src/modules/music/enna_module_music.c
+++ src/modules/music/enna_module_music.c
@@ -264,7 +264,7 @@
 	  {
 	     Evas_Object *item;
 	     Enna_Metadata *metadata;
-	     Evas_Object *icon;
+	     Evas_Object *icon = NULL;

 	     metadata = enna_mediaplayer_metadata_get();
 	     item = enna_listitem_add(mod->em->evas);


Update unix_like_serial.c

Update unix_like_serial.c

--- com.embeddedunveiled.native/linux_serial/src/unix_like_serial.c
+++ com.embeddedunveiled.native/linux_serial/src/unix_like_serial.c
@@ -918,9 +918,7 @@
 	/* Clear IO buffers after applying new valid settings to make port in 100% sane condition. */
 #if defined (__linux__)
 	ioctl(fd, TCFLSH, TCIOFLUSH);
-	ioctl(fd, TCFLSH, TCIOFLUSH);
 #elif defined (__APPLE__) || defined (__SunOS)
-	tcflush(fd, TCIOFLUSH);
 	tcflush(fd, TCIOFLUSH);
 #endif

@@ -1027,6 +1025,13 @@
 		if(DEBUG) fflush(stderr);
 		return (negative * errno);
 	}
+#endif
+
+	/* Clear IO buffers after applying new valid settings to make port in 100% sane condition. */
+#if defined (__linux__)
+	ioctl(fd, TCFLSH, TCIOFLUSH);
+#elif defined (__APPLE__) || defined (__SunOS)
+	tcflush(fd, TCIOFLUSH);
 #endif

 	return 0;


Fix copilation.

Fix copilation.

--- KERN/nke/sctp_nke/Mavericks/netinet/sctp_sysctl.c
+++ KERN/nke/sctp_nke/Mavericks/netinet/sctp_sysctl.c
@@ -459,7 +459,7 @@
 	number_of_remote_addresses = 0;

 	SCTP_INP_INFO_RLOCK();
-#if !defined(__Windows__)
+#if defined(__APPLE__)
 	if (req->oldptr == USER_ADDR_NULL) {
 #else
 	if (req->data == NULL) {
@@ -491,7 +491,7 @@
 #endif
 		return (0);
 	}
-#if !defined(__Windows__)
+#if defined(__APPLE__)
 	if (req->newptr != USER_ADDR_NULL) {
 #else
 	if (req->new_data != NULL) {


Fix openslide_public attribute syntax

Fix openslide_public attribute syntax

--- src/openslide-features.h
+++ src/openslide-features.h
@@ -34,7 +34,7 @@
 #    define openslide_public __declspec(dllimport)
 #  endif
 #elif __GNUC__ > 3
-# define openslide_public __attribute((visibility("default")))
+# define openslide_public __attribute__ ((visibility("default")))
 #else
 # define openslide_public
 #endif


cosmetics,cwebp: remove an else after a return

this is redundant with an if block that returns

BUG=webp:355

Change-Id: I4d2e520f89a8e144ab13aa3696f305365e584a0e

--- examples/cwebp.c
+++ examples/cwebp.c
@@ -486,10 +486,10 @@
       *metadata_written |= METADATA_XMP;
     }
     return ok;
-  } else {
-    // No metadata, just write the original image file.
-    return (fwrite(webp, webp_size, 1, out) == 1);
-  }
+  }
+
+  // No metadata, just write the original image file.
+  return (fwrite(webp, webp_size, 1, out) == 1);
 }

 //------------------------------------------------------------------------------


honor useragent and timeout arguments

honor useragent and timeout arguments

--- downslib.c
+++ downslib.c
@@ -294,8 +294,8 @@
                     object,
                     use_ssl,
                     filename,
-                    DEFAULT_USERAGENT,
-                    DEFAULT_TIMEOUT,
+                    useragent? useragent : DEFAULT_USERAGENT,
+                    timeout? timeout : DEFAULT_TIMEOUT,
                     cb);

     _free_host(host);


Added local optimization: (x & 0x7F...F) - x -> x & 0x80...0.

--- ir/ir/iropt.c
+++ ir/ir/iropt.c
@@ -3451,6 +3451,23 @@
 			ir_node  *not   = new_rd_Not(dbgi, block, add, mode);
 			return not;
 		}
+		/* (x & 0x7F...F) - x -> x & 0x80...0 */
+		if (is_And(a) && get_And_left(a) == b) {
+			ir_node *ab = get_And_right(a);
+			if (is_Const(ab)) {
+				ir_tarval *tv       = get_Const_tarval(ab);
+				ir_tarval *all_one  = get_mode_all_one(mode);
+				ir_tarval *expected = tarval_shr_unsigned(all_one, 1);
+				if (tv == expected) {
+					dbg_info  *const dbgi   = get_irn_dbg_info(n);
+					ir_node   *const block  = get_nodes_block(n);
+					ir_graph  *const irg    = get_irn_irg(n);
+					ir_tarval *const tv_not = tarval_not(tv);
+					ir_node   *const not_c  = new_rd_Const(dbgi, irg, tv_not);
+					return new_rd_And(dbgi, block, b, not_c, mode);
+				}
+			}
+		}
 		/* x-(x&y) = x & ~y */
 		if (is_And(b)) {
 			ir_node *and_left  = get_And_left(b);


Potentially confusing function removed

Potentially confusing function removed

--- NaoTHSoccer/Source/Representations/Modeling/PlayerInfo.h
+++ NaoTHSoccer/Source/Representations/Modeling/PlayerInfo.h
@@ -80,10 +80,6 @@
   /** the currently used scheme. */
   std::string scheme;

-  bool isGoalie() const {
-      return playerNumber == 1;
-  }
-
   static std::string toString(RobotState value);
   static std::string toString(RobotSetPlay value);


sort.h: tweak breaking points

sort.h: tweak breaking points


liuzianglib beta 2.4.21V45,20171030

liuzianglib beta 2.4.21V45,20171030

修复了DC::Exception中的一个阻止编译的问题。

--- DC_Exception.h
+++ DC_Exception.h
@@ -3,8 +3,8 @@
 #define liuzianglib_ERROR
 #include <string>
 #include <time.h>
-//Version 2.4.21V30
-//20170914
+//Version 2.4.21V45
+//20171030

 namespace DC {

@@ -12,7 +12,7 @@
 	public:
 		Exception() = default;

-		template <typename T, class = typename std::enable_if<!std::is_same<typename std::decay<T>::type, Exception>::value, U>::type>
+		template <typename T, class = typename std::enable_if<!std::is_same<typename std::decay<T>::type, Exception>::value, std::string>::type>
 		Exception(T&& inputTitle) {
 			Title = std::forward<T>(inputTitle);
 		}


px4io: handle errors from adc_measure()

px4io: handle errors from adc_measure()

don't update the voltage/current values on error

--- src/modules/px4iofirmware/registers.c
+++ src/modules/px4iofirmware/registers.c
@@ -506,10 +506,12 @@
 			 * Intercept corrected for best results @ 12V.
 			 */
 			unsigned counts = adc_measure(ADC_VBATT);
-			unsigned mV = (4150 + (counts * 46)) / 10 - 200;
-			unsigned corrected = (mV * r_page_setup[PX4IO_P_SETUP_VBATT_SCALE]) / 10000;
-
-			r_page_status[PX4IO_P_STATUS_VBATT] = corrected;
+			if (counts != 0xffff) {
+				unsigned mV = (4150 + (counts * 46)) / 10 - 200;
+				unsigned corrected = (mV * r_page_setup[PX4IO_P_SETUP_VBATT_SCALE]) / 10000;
+
+				r_page_status[PX4IO_P_STATUS_VBATT] = corrected;
+			}
 		}

 		/* PX4IO_P_STATUS_IBATT */
@@ -521,7 +523,10 @@
 			  FMU sort it out, with user selectable
 			  configuration for their sensor
 			 */
-			r_page_status[PX4IO_P_STATUS_IBATT] = adc_measure(ADC_IN5);
+			unsigned counts = adc_measure(ADC_IN5);
+			if (counts != 0xffff) {
+				r_page_status[PX4IO_P_STATUS_IBATT] = counts;
+			}
 		}

 		SELECT_PAGE(r_page_status);


Tweaks ChromeURLDataManager comments.

Tweaks ChromeURLDataManager comments.

BUG=none
TEST=none

Review URL: http://codereview.chromium.org/6624019

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@76928 0039d316-1c4b-4281-b951-d872f2087c98

--- chrome/browser/ui/webui/chrome_url_data_manager.h
+++ chrome/browser/ui/webui/chrome_url_data_manager.h
@@ -52,7 +52,7 @@
   // asynchronously. DataSources are collectively owned with refcounting smart
   // pointers and should never be deleted on the IO thread, since their calls
   // are handled almost always on the UI thread and there's a possibility of a
-  // data race.  The |DeleteOnUIThread| trait is used to enforce this.
+  // data race.  The |DeleteDataSource| trait above is used to enforce this.
   //
   // An implementation of DataSource should handle calls to
   // StartDataRequest() by starting its (implementation-specific) asynchronous


Make tiff permute code a little nicer

Make tiff permute code a little nicer

--- src/openslide-ops-tiff.c
+++ src/openslide-ops-tiff.c
@@ -315,11 +315,13 @@
   TIFFRGBAImageGet(&wtt->img, dest, wtt->tile_width, wtt->tile_height);

   // permute
-  for (int i = 0; i < (wtt->tile_width * wtt->tile_height); i++) {
-    uint32_t *p = dest + i;
-    *p = (*p & 0xFF00FF00)
-      | ((*p << 16) & 0xFF0000)
-      | ((*p >> 16) & 0xFF);
+  uint32_t *p = dest;
+  uint32_t *end = dest + wtt->tile_width * wtt->tile_height;
+  while (p < end) {
+    uint32_t val = *p;
+    *p++ = (val & 0xFF00FF00)
+      | ((val << 16) & 0xFF0000)
+      | ((val >> 16) & 0xFF);
   }
 }


Update LibDS version

Update LibDS version

--- lib/LibDS/include/LibDS.h
+++ lib/LibDS/include/LibDS.h
@@ -28,7 +28,7 @@
 extern "C" {
 #endif

-#define LIB_DS_VERSION "2.0.0"
+#define LIB_DS_VERSION "2.0.1"

 #include "DS_Timer.h"
 #include "DS_Types.h"


doxymain.h updated

doxymain.h updated

git-svn-id: 4e7379b20b57f8e3dde5a0b7363f233184647162@5 4e380d45-d1fd-0310-85a7-d18ec86df0ad

--- doxymain.h
+++ doxymain.h
@@ -17,7 +17,7 @@
  * - prevention of OS file buffering overhead
  * - algorithm pipelining
  *
- * \section platforms Platforms supported
+ * \section platforms Supported Operating Systems
  * - Linux (kernel >= 2.4.18)
  * - SunOS
  * - Windows XP/2000
@@ -131,6 +131,196 @@

 /*!
+ * \page installation_msvc Installation (Windows/MS Visual C++ 7.1 - Stxxl from version 0.9)
+ *
+ * \section download Download
+ *
+ * - Install the Boost libraries (required).
+ * - Download the \c Stxxl zip file from here.
+ * - Unpack the zip file in some directory (e.g. \c 'c:\\'),
+ * - Change to \c stxxl directory: \c cd \c stxxl ,
+ * - Change \c make.settings.msvc file according to your system configuration
+ *   - \c STXXL root directory \c STXXL_ROOT variable( \c directory_where_you_unpacked_the_tar_ball\\stxxl , e.g. \c 'c:\\stxxl')
+ *   - change BOOST_ROOT variable according to the Boost root path
+ *   - set OPT variable to /O2 or other VC++ optimization level you like (optionally)
+ *   - set DEBUG variable to /MDd for debug version of the \c Stxxl library or to /MD for the version without debugging information in object files
+ * - Run: \verbatim make library_msvc \endverbatim
+ * - Run: \verbatim make tests_g++ \endverbatim (optional, if you want to compile and run some test programs)
+ *
+ * Programs using Stxxl can be compiled using g++ command line options from \c compiler.options
+ * file. The linking options you can find in \c linker.options file. Alternatively you can
+ * include \c make.settings file in your make files and use \c STXXL_COMPILER_OPTIONS and
+ * \c STXXL_LINKER_OPTIONS variables, defined therein.
+ *
+ * For example:

+ * \verbatim g++ -c my_example.cpp $(STXXL_COMPILER_OPTIONS) \endverbatim

+ * \verbatim g++ my_example.o -o my_example.bin $(STXXL_LINKER_OPTIONS) \endverbatim
+ *
+ * Before you try to run one of the \c STXXL examples
+ * (or your own \c STXXL program) you must configure the disk
+ * space that will be used as external memory for the library. For instructions how to do that,
+ * see the next section.
+ *
+ *
+ * \section space Disk space
+ *
+ * To get best performance with \c STXXL  you should assign separate disks to it.
+ * These disks should be used by the library only.
+ * Since \c STXXL is developed to exploit disk parallelism, the performance of your
+ * external memory application will increase if you use more than one disk.
+ * But from how many disks your application can benefit depends on how "I/O bound" it is.
+ * With modern disk bandwidths
+ * about of 50-75 MB/s most of applications are I/O bound for one disk. This means that if you add another disk
+ * the running time will be halved. Adding more disks might also increase performance significantly.
+ *
+ * \section filesystem Recommended file system
+ *
+ * Our library take benefit of direct user memory - disk transfers (direct access) which avoids
+ * superfluous copies.
+ * We recommend to use the
+ * \c XFS file system link that
+ * gives good read and write performance for large files.
+ * Note that file creation speed of \c XFS is slow, so that disk
+ * files should be precreated.
+ *
+ * \section configuration Disk configuration file
+ *
+ * You must define the disk configuration for an
+ * \c STXXL program in a file named \c '.stxxl' that must reside
+ * in the same directory where you execute the program.
+ * You can change the default file name for the configuration
+ * file by setting the enviroment variable \c STXXLCFG .
+ *
+ *
+ * Each line of the configuration file describes a disk.
+ * A disk description uses the following format:

+ * \c disk=full_disk_filename,capacity,access_method
+ *
+ * Description of the parameters:
+ * - \c full_disk_filename : full disk filename. In order to access disks STXXL uses file
+ * access methods. Each disk is respresented as a file. If you have a disk that is mapped in unix
+ * to the path /mnt/disk0/, then the correct value for the \c full_disk_filename would be
+ * \c /mnt/disk0/some_file_name ,
+ * - \c capacity : maximum capacity of the disk in megabytes
+ * - \c access_method : \c STXXL has a number of different file access implementations for POSIX systems, choose one of them:
+ *   - \c syscall uses \c read and \c write system calls which perform disk transfers directly
+ *   on user memory pages without superfluous copy (currently the fastest method)
+ *   - \c mmap : performs disks transfers using \c mmap and \c munmap system calls
+ *   - \c simdisk : simulates timings of the IBM IC35L080AVVA07 disk, full_disk_filename must point
+ *     to a file on a RAM disk partition with sufficient space
+ *
+ *
+ * See also example configuration file \c 'stxxl/config_example' included into the tarball.
+ *
+ * \section excreation Formatting external memory files
+ *
+ * In order to get the maximum performance one should format disk files described in the configuration file,
+ * before running \c STXXL applications.
+ *
+ * The format utility is included into the set of \c STXXL utilities ( \c utils/createdisks.bin ). Run this utility
+ * for each disk you have defined in the disk configuration file.
+ *
+ *
+ * */
+
+
+
+/*!
+ * \page installation_sunos_g++ Installation (SunOS/g++ - Stxxl from version 0.9)
+ *
+ * \section download Download
+ *
+ * - Download gzipped tar ball from here.
+ * - Unpack in some directory executing: \c tar \c zfxv \c stxxl.tgz ,
+ * - Change to \c stxxl directory: \c cd \c stxxl ,
+ * - Change \c make.settings.g++ file according to your system configuration
+ *   - \c STXXL root directory \c STXXL_ROOT variable( \c directory_where_you_unpacked_the_tar_ball/stxxl )
+ *   - change USE_BOOST variable to 'yes' if you want Stxxl to use Boost libraries (you should have Boost libraries already installed)
+ *   - change USE_LINUX variable to 'no'
+ *   - change BOOST_INCLUDE variable according to the Boost include path (if you set USE_BOOST to 'yes')
+ *   - set OPT variable to -O3 or other g++ optimization level you like (optionally)
+ *   - set DEBUG variable to -g or other g++ debugging option if you want to produce debug version of the Stxxl library or Stxxl examples
+ * - Run: \verbatim make library_g++ \endverbatim
+ * - Run: \verbatim make tests_g++ \endverbatim (optional, if you want to compile and run some test programs)
+ *
+ * Programs using Stxxl can be compiled using g++ command line options from \c compiler.options
+ * file. The linking options you can find in \c linker.options file. Alternatively you can
+ * include \c make.settings file in your make files and use \c STXXL_COMPILER_OPTIONS and
+ * \c STXXL_LINKER_OPTIONS variables, defined therein.
+ *
+ * For example:

+ * \verbatim g++ -c my_example.cpp $(STXXL_COMPILER_OPTIONS) \endverbatim

+ * \verbatim g++ my_example.o -o my_example.bin $(STXXL_LINKER_OPTIONS) \endverbatim
+ *
+ * Before you try to run one of the \c STXXL examples
+ * (or your own \c STXXL program) you must configure the disk
+ * space that will be used as external memory for the library. For instructions how to do that,
+ * see the next section.
+ *
+ *
+ * \section space Disk space
+ *
+ * To get best performance with \c STXXL  you should assign separate disks to it.
+ * These disks should be used by the library only.
+ * Since \c STXXL is developed to exploit disk parallelism, the performance of your
+ * external memory application will increase if you use more than one disk.
+ * But from how many disks your application can benefit depends on how "I/O bound" it is.
+ * With modern disk bandwidths
+ * about of 50-75 MB/s most of applications are I/O bound for one disk. This means that if you add another disk
+ * the running time will be halved. Adding more disks might also increase performance significantly.
+ *
+ * \section filesystem Recommended file system
+ *
+ * Our library take benefit of direct user memory - disk transfers (direct access) which avoids
+ * superfluous copies.
+ * We recommend to use the
+ * \c XFS file system link that
+ * gives good read and write performance for large files.
+ * Note that file creation speed of \c XFS is slow, so that disk
+ * files should be precreated.
+ *
+ * \section configuration Disk configuration file
+ *
+ * You must define the disk configuration for an
+ * \c STXXL program in a file named \c '.stxxl' that must reside
+ * in the same directory where you execute the program.
+ * You can change the default file name for the configuration
+ * file by setting the enviroment variable \c STXXLCFG .
+ *
+ *
+ * Each line of the configuration file describes a disk.
+ * A disk description uses the following format:

+ * \c disk=full_disk_filename,capacity,access_method
+ *
+ * Description of the parameters:
+ * - \c full_disk_filename : full disk filename. In order to access disks STXXL uses file
+ * access methods. Each disk is respresented as a file. If you have a disk that is mapped in unix
+ * to the path /mnt/disk0/, then the correct value for the \c full_disk_filename would be
+ * \c /mnt/disk0/some_file_name ,
+ * - \c capacity : maximum capacity of the disk in megabytes
+ * - \c access_method : \c STXXL has a number of different file access implementations for POSIX systems, choose one of them:
+ *   - \c syscall uses \c read and \c write system calls which perform disk transfers directly
+ *   on user memory pages without superfluous copy (currently the fastest method)
+ *   - \c mmap : performs disks transfers using \c mmap and \c munmap system calls
+ *   - \c simdisk : simulates timings of the IBM IC35L080AVVA07 disk, full_disk_filename must point
+ *     to a file on a RAM disk partition with sufficient space
+ *
+ *
+ * See also example configuration file \c 'stxxl/config_example' included into the tarball.
+ *
+ * \section excreation Formatting external memory files
+ *
+ * In order to get the maximum performance one should format disk files described in the configuration file,
+ * before running \c STXXL applications.
+ *
+ * The format utility is included into the set of \c STXXL utilities ( \c utils/createdisks.bin ). Run this utility
+ * for each disk you have defined in the disk configuration file.
+ *
+ *
+ * */
+
+
+/*!
  * \page installation Installation (Linux/g++ - Stxxl versions earlier than 0.9)
  *
  * \section download Download


ls1bdev: don't hardcode the uart base address in rt_hw_console_output

--- bsp/ls1bdev/drivers/board.c
+++ bsp/ls1bdev/drivers/board.c
@@ -71,6 +71,23 @@
 	rt_kprintf("current sr: 0x%08x\n", read_c0_status());
 }

+#define __raw_out_put(unr) \
+	while (*ptr) \
+	{ \
+		if (*ptr == '\n') \
+		{ \
+			/* FIFO status, contain valid data */ \
+			while (!(UART_LSR(UART##unr##_BASE) & (UARTLSR_TE | UARTLSR_TFE))); \
+			/* write data */ \
+			UART_DAT(UART##unr##_BASE) = '\r'; \
+		} \
+		/* FIFO status, contain valid data */ \
+		while (!(UART_LSR(UART##unr##_BASE) & (UARTLSR_TE | UARTLSR_TFE))); \
+		/* write data */ \
+		UART_DAT(UART##unr##_BASE) = *ptr; \
+		ptr ++; \
+	}
+
 /* UART line status register value */
 #define UARTLSR_ERROR	(1 << 7)
 #define UARTLSR_TE		(1 << 6)
@@ -82,24 +99,13 @@
 #define UARTLSR_DR		(1 << 0)
 void rt_hw_console_output(const char *ptr)
 {
-	/* stream mode */
-	while (*ptr)
-	{
-		if (*ptr == '\n')
-		{
-			/* FIFO status, contain valid data */
-			while (!(UART_LSR(UART0_BASE) & (UARTLSR_TE | UARTLSR_TFE)));
-			/* write data */
-			UART_DAT(UART0_BASE) = '\r';
-		}
-
-		/* FIFO status, contain valid data */
-		while (!(UART_LSR(UART0_BASE) & (UARTLSR_TE | UARTLSR_TFE)));
-		/* write data */
-		UART_DAT(UART0_BASE) = *ptr;
-
-		ptr ++;
-	}
+#if defined(RT_USING_UART0)
+    __raw_out_put(0);
+#elif defined(RT_USING_UART1)
+    __raw_out_put(1);
+#elif defined(RT_USING_UART3)
+    __raw_out_put(3);
+#endif
 }

 /*@}*/


kmswebrtcdatachannelbin: Add log when any data channel is resetted

Change-Id: I30f293084731e5d7872e93c0b40a2a776d5070b4

--- src/gst-plugins/webrtcendpoint/kmswebrtcdatachannelbin.c
+++ src/gst-plugins/webrtcendpoint/kmswebrtcdatachannelbin.c
@@ -105,6 +105,7 @@
   ResetStreamFunc _reset_cb = NULL;                            \
   gpointer _reset_data;                                        \
   KMS_WEBRTC_DATA_CHANNEL_BIN_LOCK (obj);                      \
+  GST_DEBUG_OBJECT ((obj), "Resetting data channel");          \
   (obj)->priv->state = KMS_WEB_RTC_DATA_CHANNEL_STATE_CLOSING; \
   _reset_cb = (obj)->priv->reset_cb;                           \
   _reset_data = (obj)->priv->reset_data;                       \


Added some sanity checks to snake drawing algorithm.

--- LOGIC/SnakeGame/SnakeMain.c
+++ LOGIC/SnakeGame/SnakeMain.c
@@ -10,10 +10,38 @@
 #include "buttons.h"
 #include <stdlib.h>

+
+/*
+This is the coordinate system used. Each game coordinate corresponds to 2x2 pixels.
+
+px   0 1 2 3 4 5 6 7 8 9 ...
+  crd 0   1   2   3   4
+0   * *|* *|* *|* *|
+1 0 * *|* *|* *|* *|
+    ---+---+---+---+
+2   * *|   |   |   |
+3 1 * *|   |   |   |
+    ---+---+---+---+
+4   * *|   |   |   |
+5 2 * *|   |   |   |
+    ---+---+---+---+
+6   * *|   |   |   |
+7 3 * *|   |   |   |
+    ---+---+---+---+
+8   * *|   |   |   |
+9 4 * *|   |   |   |
+    ---+---+---+---+
+...
+
+*/
+
 /* This file will contain the long-planned Snake Game on the power hour machine...*/

-#define GAME_BORDER_WIDTH 3u /* Set this at 3 pixels.    */
+#define GAME_BORDER_WIDTH 2u /* Set this at 2 pixels.    */
 #define SNAKE_SPEED       4u /* Set at 400 ms intervals. */
+
+#define MAX_COORD_X NUMBER_OF_COLUMNS / 2u
+#define MAX_COORD_Y NUMBER_OF_ROWS / 2u

 typedef enum
 {
@@ -234,7 +262,8 @@
 {
     Point BeginPixel;
     Point EndPixel;
-    Point end; /* This is in the snake coordinate system. */
+    Point end;  /* This is in the game coordinate system. */
+    Point head; /* This is in the game coordinate system.  */

     if (elem == NULL)
     {
@@ -242,10 +271,18 @@
     }

     end = getTailOfElement(elem);
+    /* Perform sanity check. */
+    /* If element is out of bounds, then we still draw it, but cut off the out of bounds part. */
+
+    head.x = MIN(elem->begin.x , MAX_COORD_X);
+    head.y = MIN(elem->begin.y , MAX_COORD_Y);
+    end.x = MIN(end.x, MAX_COORD_X);
+    end.y = MIN(end.y, MAX_COORD_Y);
+

     /* Initialize these to top left pixels. */
-    BeginPixel.x = elem->begin.x * 2;
-    BeginPixel.y = elem->begin.y * 2;
+    BeginPixel.x = head.x * 2;
+    BeginPixel.y = head.y * 2;

     EndPixel.x = end.x * 2;
     EndPixel.y = end.y * 2;


Fixed a potential buffer overflow problem, in the device name handling.

PR:		bin/15101

--- usr.sbin/cdcontrol/cdcontrol.c
+++ usr.sbin/cdcontrol/cdcontrol.c
@@ -33,6 +33,7 @@
 #include <sys/file.h>
 #include <sys/cdio.h>
 #include <sys/ioctl.h>
+#include <sys/param.h>
 #include <histedit.h>

 #define VERSION "2.0"
@@ -1036,17 +1037,18 @@

 int open_cd ()
 {
-	char devbuf[80];
+	char devbuf[MAXPATHLEN];

 	if (fd > -1)
 		return (1);

-	if (*cdname == '/')
-		strcpy (devbuf, cdname);
-	else if (*cdname == 'r')
-		sprintf (devbuf, "/dev/%s", cdname);
-	else
-		sprintf (devbuf, "/dev/r%s", cdname);
+	if (*cdname == '/') {
+		snprintf (devbuf, MAXPATHLEN, "%s", cdname);
+	} else if (*cdname == 'r') {
+		snprintf (devbuf, MAXPATHLEN, "/dev/%s", cdname);
+	} else {
+		snprintf (devbuf, MAXPATHLEN, "/dev/r%s", cdname);
+	}

 	fd = open (devbuf, O_RDONLY);


Add hint instructions for call/ret inlining

These mark boundaries where the ABI ensures liveness
properties of registers.

This is important for future liveness analysis and corresponding
optimizations.

--- spec.c
+++ spec.c
@@ -130,6 +130,10 @@

 typedef enum _InstrType {
     IT_None = 0, IT_Invalid,
+    // Hints: not actual instructions
+    IT_HINT_CALL, // starting inlining of another function at this point
+    IT_HINT_RET,  // ending inlining at this point
+    //
     IT_NOP,
     IT_CLTQ,
     IT_PUSH, IT_POP, IT_LEAVE,
@@ -300,6 +304,10 @@
     int genOrderCount;
     CBB* genOrder[GENORDER_MAX];

+    // for optimization passes
+    Bool addInliningHints;
+    Bool doCopyPass; // test pass
+
     // debug output
     Bool showDecoding, showEmuState, showEmuSteps, showOptSteps;
 } Rewriter;
@@ -347,6 +355,10 @@

     r->cc = 0;
     r->es = 0;
+
+    // optimization passes
+    r->addInliningHints = True;
+    r->doCopyPass = True;

     // default: debug off
     r->showDecoding = False;
@@ -2044,6 +2056,9 @@
     int opCount = 0;

     switch(it) {
+    case IT_HINT_CALL: n = "H-call"; break;
+    case IT_HINT_RET:  n = "H-ret"; break;
+
     case IT_NOP:     n = "nop"; break;
     case IT_RET:     n = "ret"; break;
     case IT_LEAVE:   n = "leave"; break;
@@ -2175,13 +2190,13 @@
 {
     static char buf[100];
     int off = 0, i, j;
-    for(i = start, j=0; i < instr->len && j<count; i++, j++) {
+    for(i = start, j=0; (i < instr->len) && (j<count); i++, j++) {
         uint8_t b = ((uint8_t*) instr->addr)[i];
         off += sprintf(buf+off, " %02x", b);
     }
     for(;j<count;j++)
         off += sprintf(buf+off, "   ");
-    return buf;
+    return (off == 0) ? "" : buf;
 }

 void brew_print_decoded(DBB* bb)
@@ -2670,10 +2685,10 @@
     case OT_Ind32:
     case OT_Ind64:
         // dst memory
-        assert(opValType(src) == opValType(dst));
         switch(src->type) {
         case OT_Reg32:
         case OT_Reg64:
+            assert(opValType(src) == opValType(dst));
             // use 'mov r/m,r 32/64' (0x89 MR)
             return genModRM(buf, 0x89, -1, dst, src, VT_None);

@@ -3458,6 +3473,10 @@
             case IT_SUB:
                 used = genSub(buf, &(instr->src), &(instr->dst));
                 break;
+            case IT_HINT_CALL:
+            case IT_HINT_RET:
+                used = 0;
+                break;
             default: assert(0);
             }
         }
@@ -4845,13 +4864,17 @@
                cbb->dec_addr, cbb->esID);
     }

-    newInstrs = optPassCopy(r, cbb);
-    if (newInstrs)
-        cbb->instr = newInstrs;
+    if (r->doCopyPass) {
+        newInstrs = optPassCopy(r, cbb);
+        if (newInstrs)
+            cbb->instr = newInstrs;
+    }
 }

 //----------------------------------------------------------
 // Emulator for instruction types
+
+

 // return 0 to fall through to next instruction, or return address to jump to
 uint64_t emulateInstr(Rewriter* c, EmuState* es, Instr* instr)
@@ -4902,6 +4925,7 @@
         break;

     case IT_CALL:
+        // TODO: keep call. For now, we always inline
         getOpValue(&v1, es, &(instr->dst));
         assert(es->depth < MAX_CALLDEPTH);
         assert(csIsStatic(v1.state)); // call target must be known
@@ -4915,6 +4939,12 @@
         setMemValue(&v2, &addr, es, VT_64, 1);

         es->ret_stack[es->depth++] = v2.val;
+
+        if (c->addInliningHints) {
+            Instr i;
+            initSimpleInstr(&i, IT_HINT_CALL);
+            capture(c, &i);
+        }

         // special handling for known functions
         if ((v1.val == (uint64_t) makeDynamic) &&
@@ -5270,6 +5300,12 @@
         break;

     case IT_RET:
+        if (c->addInliningHints) {
+            Instr i;
+            initSimpleInstr(&i, IT_HINT_RET);
+            capture(c, &i);
+        }
+
         es->depth--;
         if (es->depth >= 0) {
             // pop return address from stack
@@ -5442,6 +5478,12 @@
     // and start with this CBB
     bb_addr = cbb->dec_addr;
     c->currentCapBB = cbb;
+    if (c->addInliningHints) {
+        // hint: here starts a function, we can assume ABI calling conventions
+        Instr i;
+        initSimpleInstr(&i, IT_HINT_CALL);
+        capture(c, &i);
+    }

     if (c->showEmuSteps) {
         printf("Processing BB (%lx|%d)\n", cbb->dec_addr, cbb->esID);


more reactions to Thread/Thread::Ptr refactor/change

--- Library/Sources/Stroika/Frameworks/Service/Main.h
+++ Library/Sources/Stroika/Frameworks/Service/Main.h
@@ -759,7 +759,7 @@

             private:
                 Execution::Synchronized<shared_ptr<IApplicationRep>> fAppRep_;
-                Execution::Synchronized<Execution::Thread>           fRunThread_;
+                Execution::Synchronized<Execution::Thread::Ptr>      fRunThread_;
             };
 #endif

@@ -800,7 +800,7 @@

             private:
                 static WindowsService*      s_SvcRunningTHIS_;
-                Execution::Thread::Ptr       fRunThread_;
+                Execution::Thread::Ptr      fRunThread_;
                 SERVICE_STATUS_HANDLE       fServiceStatusHandle_; // nullptr if invalid - not INVALID_HANDLE
                 SERVICE_STATUS              fServiceStatus_;
                 shared_ptr<IApplicationRep> fAppRep_;


tiff: Fold _paint_region() into caller

tiff: Fold _paint_region() into caller

--- src/openslide-ops-tiff.c
+++ src/openslide-ops-tiff.c
@@ -405,29 +405,23 @@
   _openslide_cache_entry_unref(cache_entry);
 }

-static void _paint_region(openslide_t *osr, TIFF *tiff, cairo_t *cr,
-                          int64_t x, int64_t y,
-                          struct _openslide_level *level,
-                          int32_t w, int32_t h) {
-  struct tiff_level *l = (struct tiff_level *) level;
-
-  // set the directory
-  SET_DIR_OR_FAIL(osr, tiff, l->dir)
-
-  _openslide_grid_paint_region(l->grid, cr, tiff,
-                               x / level->downsample,
-                               y / level->downsample,
-                               level, w, h);
-}
-
 static void paint_region(openslide_t *osr, cairo_t *cr,
 			 int64_t x, int64_t y,
 			 struct _openslide_level *level,
 			 int32_t w, int32_t h) {
   struct _openslide_tiffopsdata *data = osr->data;
+  struct tiff_level *l = (struct tiff_level *) level;
+
   TIFF *tiff = _openslide_tiffcache_get(data->tc);
   if (tiff) {
-    _paint_region(osr, tiff, cr, x, y, level, w, h);
+    if (TIFFSetDirectory(tiff, l->dir)) {
+      _openslide_grid_paint_region(l->grid, cr, tiff,
+                                   x / l->base.downsample,
+                                   y / l->base.downsample,
+                                   level, w, h);
+    } else {
+      _openslide_set_error(osr, "Cannot set TIFF directory");
+    }
   } else {
     _openslide_set_error(osr, "Cannot open TIFF file");
   }


Switch to using the "neworder" for rotating log files, by default.  The
main advantage of this is that daemon's are only signalled once per run,
instead of once for each file that is rotated.

MFC after:	2 weeks

--- usr.sbin/newsyslog/newsyslog.c
+++ usr.sbin/newsyslog/newsyslog.c
@@ -90,6 +90,9 @@

 /* Define this symbol to try out the "new order" for work items. */
 #define	TRY_NEWORDER
+#ifndef USE_NEWORDER
+#define	USE_NEWORDER	1	/* Initial value for dbg_new_order */
+#endif

 /*
  * Bit-values for the 'flags' parsed from a config-file entry.
@@ -162,7 +165,12 @@
 SLIST_HEAD(zwlisthead, zipwork_entry) zwhead = SLIST_HEAD_INITIALIZER(zwhead);

 int dbg_at_times;		/* -D Show details of 'trim_at' code */
-int dbg_new_order;		/* -D Try the 'neworder' of doing the work */
+/*
+ * The debug options "neworder" and "oldorder" can be used to change
+ * which order work is done in.  Note that both options will disappear
+ * in the near future, and the "new" order will be the only order.
+ */
+int dbg_new_order = USE_NEWORDER;

 int archtodir = 0;		/* Archive old logfiles to other directory */
 int createlogs;			/* Create (non-GLOB) logfiles which do not */


--- DK/DKInclude.h
+++ DK/DKInclude.h
@@ -221,24 +221,25 @@
 #		define DKGL_FUNCTION_NAME		__func__
 #	endif

+#   define DKGL_NOOP							(void)0 // Forces the macro to end the statement with a semicolon.
 #	define DKERROR_THROW(desc)				DKFoundation::DKErrorRaiseException(DKGL_FUNCTION_NAME, __FILE__, __LINE__, desc)
-#	define DKASSERT_DESC(expr, desc)		{if (!(expr)) DKERROR_THROW(desc);}
-#	define DKASSERT(expr)					{if (!(expr)) DKERROR_THROW("");}
-#	define DKASSERT_STD_DESC(expr, desc)	{if (!(expr)) throw std::runtime_error(desc);}
-#	define DKASSERT_STD(expr)				{if (!(expr)) throw std::runtime_error("");}
+#	define DKASSERT_DESC(expr, desc)			{if (!(expr)) DKERROR_THROW(desc);}				DKGL_NOOP
+#	define DKASSERT(expr)					{if (!(expr)) DKERROR_THROW("");}				DKGL_NOOP
+#	define DKASSERT_STD_DESC(expr, desc)	    {if (!(expr)) throw std::runtime_error(desc);}	DKGL_NOOP
+#	define DKASSERT_STD(expr)				{if (!(expr)) throw std::runtime_error("");}		DKGL_NOOP

 #	ifdef DKGL_DEBUG_ENABLED
-#		define DKERROR_THROW_DEBUG(desc)			DKERROR_THROW(desc)
+#		define DKERROR_THROW_DEBUG(desc)				DKERROR_THROW(desc)
 #		define DKASSERT_DESC_DEBUG(expr, desc)		DKASSERT_DESC(expr, desc)
 #		define DKASSERT_DEBUG(expr)					DKASSERT(expr)
 #		define DKASSERT_STD_DESC_DEBUG(expr, desc)	DKASSERT_STD_DESC(expr, desc)
 #		define DKASSERT_STD_DEBUG(expr)				DKASSERT_STD(expr)
 #	else
-#		define DKERROR_THROW_DEBUG(desc)			(void)0
-#		define DKASSERT_DESC_DEBUG(expr, desc)		(void)0
-#		define DKASSERT_DEBUG(expr)					(void)0
-#		define DKASSERT_STD_DESC_DEBUG(expr, desc)	(void)0
-#		define DKASSERT_STD_DEBUG(expr)				(void)0
+#		define DKERROR_THROW_DEBUG(desc)				DKGL_NOOP
+#		define DKASSERT_DESC_DEBUG(expr, desc)		DKGL_NOOP
+#		define DKASSERT_DEBUG(expr)					DKGL_NOOP
+#		define DKASSERT_STD_DESC_DEBUG(expr, desc)	DKGL_NOOP
+#		define DKASSERT_STD_DEBUG(expr)				DKGL_NOOP
 #	endif

 #	ifndef DKGL_MEMORY_DEBUG
@@ -249,15 +250,15 @@
 #		endif
 #	endif /* DKGL_MEMORY_DEBUG */
 #	if DKGL_MEMORY_DEBUG
-#		define DKASSERT_MEM_DESC(expr, desc)		{if (!(expr)) throw std::runtime_error(desc);}
-#		define DKASSERT_MEM(expr)					{if (!(expr)) throw std::runtime_error("");}
+#		define DKASSERT_MEM_DESC(expr, desc)			{if (!(expr)) throw std::runtime_error(desc);}	DKGL_NOOP
+#		define DKASSERT_MEM(expr)					{if (!(expr)) throw std::runtime_error("");}		DKGL_NOOP
 #		define DKASSERT_MEM_DESC_DEBUG(expr, desc)	DKASSERT_STD_DESC(expr, desc)
 #		define DKASSERT_MEM_DEBUG(expr)				DKASSERT_STD(expr)
 #	else
-#		define DKASSERT_MEM_DESC(expr, desc)		(void)0
-#		define DKASSERT_MEM(expr)					(void)0
-#		define DKASSERT_MEM_DESC_DEBUG(expr, desc)	(void)0
-#		define DKASSERT_MEM_DEBUG(expr)				(void)0
+#		define DKASSERT_MEM_DESC(expr, desc)			DKGL_NOOP
+#		define DKASSERT_MEM(expr)					DKGL_NOOP
+#		define DKASSERT_MEM_DESC_DEBUG(expr, desc)	DKGL_NOOP
+#		define DKASSERT_MEM_DEBUG(expr)				DKGL_NOOP
 #	endif
 #endif	// #ifdef __cplusplus


Use Bool enum for booleans

Use Bool enum for booleans

--- spec.c
+++ spec.c
@@ -15,6 +15,8 @@

 typedef struct _EmuState EmuState;
 typedef struct _CaptureConfig CaptureConfig;
+
+typedef enum { False, True } Bool;

 /*------------------------------------------------------------
  * Code Storage
@@ -223,40 +225,40 @@
     return 0; // invalid;
 }

-int opIsImm(Operand* o)
+Bool opIsImm(Operand* o)
 {
     switch(o->type) {
     case OT_Imm8:
     case OT_Imm16:
     case OT_Imm32:
     case OT_Imm64:
-	return 1;
-    }
-    return 0;
-}
-
-int opIsReg(Operand* o)
+        return True;
+    }
+    return False;
+}
+
+Bool opIsReg(Operand* o)
 {
     switch(o->type) {
     case OT_Reg8:
     case OT_Reg16:
     case OT_Reg32:
     case OT_Reg64:
-	return 1;
-    }
-    return 0;
-}
-
-int opIsInd(Operand* o)
+        return True;
+    }
+    return False;
+}
+
+Bool opIsInd(Operand* o)
 {
     switch(o->type) {
     case OT_Ind8:
     case OT_Ind16:
     case OT_Ind32:
     case OT_Ind64:
-	return 1;
-    }
-    return 0;
+        return True;
+    }
+    return False;
 }

 Operand* getRegOp(ValType t, Reg r)
@@ -406,6 +408,7 @@

 // r/m, r. r parsed as op2/reg and digit. Encoding see SDM 2.1
+// return number of bytes parsed
 int parseModRM(uint8_t* p, int rex, Operand* o1, Operand* o2, int* digit)
 {
     int modrm, mod, rm, reg; // modRM byte
@@ -756,6 +759,8 @@
 /*------------------------------------------------------------*/
 /* x86_64 code generation
  */
+
+// generator helpers: return number of bytes written

 int genRet(uint8_t* buf)
 {
@@ -1105,6 +1110,7 @@

 /*------------------------------------------------------------*/
 /* x86_64 capturing emulator
+ * trace execution in the emulator to capture code to generate
  *
  * We maintain states (known/static vs unknown/dynamic at capture time)
  * for registers and values on stack. To be able to do the latter, we
@@ -1112,9 +1118,6 @@
  * memory writes with dynamic address. This assumption should be fine,
  * as such behavior is dangerous and potentially a bug.
  */
-
-// we trace execution in an emulator for code generation
-// TODO: branching depending on dynamic data

 // emulator capture states
 typedef enum _CaptureState {
@@ -1306,7 +1309,7 @@
     printf(" %016lx  %s\n", (uint64_t)a, (a == sp) ? "*" : " ");
 }

-char combineState(CaptureState s1, CaptureState s2, int isSameValue)
+char combineState(CaptureState s1, CaptureState s2, Bool isSameValue)
 {
     // dead/invalid: combining with something invalid makes result invalid
     if ((s1 == CS_DEAD) || (s2 == CS_DEAD)) return CS_DEAD;
@@ -1332,18 +1335,19 @@
     return CS_DYNAMIC;
 }

-// if addr on stack, return 1 and stack offset in <off>, otherwise return 0
-// the returned offset only is static/known if the address was stack-relative
-int getStackOffset(EmuState* es, EmuValue* addr, EmuValue* off)
+// if addr on stack, return true and stack offset in <off>,
+//  otherwise return false
+// the returned offset is static only if address is stack-relative
+Bool getStackOffset(EmuState* es, EmuValue* addr, EmuValue* off)
 {
     uint8_t* a = (uint8_t*) addr->val;
     if ((a >= es->stack) && (a < es->stack + es->stacksize)) {
         off->type = VT_32;
         off->state = (addr->state == CS_STACKRELATIVE) ? CS_STATIC : CS_DYNAMIC;
         off->val = a - es->stack;
-        return 1;
-    }
-    return 0;
+        return True;
+    }
+    return False;
 }

 void getRegValue(EmuValue* v, EmuState* es, Reg r, ValType t)
@@ -1361,7 +1365,7 @@
 }

 void getMemValue(EmuValue* v, EmuValue* addr, EmuState* es, ValType t,
-                 int shouldBeStack)
+                 Bool shouldBeStack)
 {
     EmuValue off;
     CaptureState state;
@@ -1408,7 +1412,8 @@
     EmuValue off;
     uint32_t* a32;
     uint64_t* a64;
-    int i, isOnStack;
+    int i;
+    Bool isOnStack;

     isOnStack = getStackOffset(es, addr, &off);
     if (!isOnStack)
@@ -1525,11 +1530,11 @@
 }

 // false if not on stack or stack offset not static/known
-int keepsCaptureState(EmuState* es, Operand* o)
+Bool keepsCaptureState(EmuState* es, Operand* o)
 {
     EmuValue addr;
     EmuValue off;
-    int isOnStack;
+    Bool isOnStack;

     assert(!opIsImm(o));
     if (opIsReg(o)) return 1;
@@ -1537,7 +1542,7 @@
     getOpAddr(&addr, es, o);
     isOnStack = getStackOffset(es, &addr, &off);
     if (!isOnStack) return 0;
-    return (off.state == CS_STATIC) ? 1:0;
+    return (off.state == CS_STATIC);
 }

 void applyStaticToInd(Operand* o, EmuState* es)
@@ -1839,7 +1844,7 @@

     printEmuState(es);

-    // return value according calling convention
+    // return value according to calling convention
     return es->reg[Reg_AX];
 }


distributor: use wait until scheme

distributor: use wait until scheme

Instead of polling for bufptr64 to be updated, use
wait until scheme for this case.

Signed-off-by: Feifei Wang <2493857810266eaae720c9869c8b9d6ce45d3739@arm.com>
Reviewed-by: Ruifeng Wang <a548d51fbc42485a8ba807711a537e88c2b59dd2@arm.com>
Acked-by: Jerin Jacob <352c4d4f9291b869992ddb67daa45ddc149fed30@marvell.com>

--- lib/distributor/rte_distributor_single.c
+++ lib/distributor/rte_distributor_single.c
@@ -33,9 +33,8 @@
 	union rte_distributor_buffer_single *buf = &d->bufs[worker_id];
 	int64_t req = (((int64_t)(uintptr_t)oldpkt) << RTE_DISTRIB_FLAG_BITS)
 			| RTE_DISTRIB_GET_BUF;
-	while (unlikely(__atomic_load_n(&buf->bufptr64, __ATOMIC_RELAXED)
-			& RTE_DISTRIB_FLAGS_MASK))
-		rte_pause();
+	RTE_WAIT_UNTIL_MASKED(&buf->bufptr64, RTE_DISTRIB_FLAGS_MASK,
+		==, 0, __ATOMIC_RELAXED);

 	/* Sync with distributor on GET_BUF flag. */
 	__atomic_store_n(&(buf->bufptr64), req, __ATOMIC_RELEASE);
@@ -74,9 +73,8 @@
 	union rte_distributor_buffer_single *buf = &d->bufs[worker_id];
 	uint64_t req = (((int64_t)(uintptr_t)oldpkt) << RTE_DISTRIB_FLAG_BITS)
 			| RTE_DISTRIB_RETURN_BUF;
-	while (unlikely(__atomic_load_n(&buf->bufptr64, __ATOMIC_RELAXED)
-			& RTE_DISTRIB_FLAGS_MASK))
-		rte_pause();
+	RTE_WAIT_UNTIL_MASKED(&buf->bufptr64, RTE_DISTRIB_FLAGS_MASK,
+		==, 0, __ATOMIC_RELAXED);

 	/* Sync with distributor on RETURN_BUF flag. */
 	__atomic_store_n(&(buf->bufptr64), req, __ATOMIC_RELEASE);


COMP: Fix build error introduced in previous commit

--- Libs/Visualization/VTK/Widgets/ctkVTKRenderView.h
+++ Libs/Visualization/VTK/Widgets/ctkVTKRenderView.h
@@ -123,10 +123,11 @@
   void lookFromAxis(const ctkAxesWidget::Axis& axis);

   /// \deprecated
-  /// \brief Change camera to look from a given axis to the focal point
-  /// Translate/Rotate the camera to look from a given axis
+  /// \brief Change camera to look from a given axis to the focal point.
+  /// Translate/Rotate the camera to look from a given axis.
+  /// \param fov is not used (it is kept for backward compatibility of the API)
   /// \sa lookFromAxis(const ctkAxesWidget::Axis&)
-  void lookFromAxis(const ctkAxesWidget::Axis& axis, double fov = 10.);
+  void lookFromAxis(const ctkAxesWidget::Axis& axis, double fov);

 public:


Remove last comment from old tiffdump.c

Remove last comment from old tiffdump.c

--- src/openslide-tiffdump.c
+++ src/openslide-tiffdump.c
@@ -386,11 +386,6 @@

   g_debug("version: %d", version);

-  /*
-   * Now check version (if needed, it's been byte-swapped).
-   * Note that this isn't actually a version number, it's a
-   * magic number that doesn't change (stupid).
-   */
   if (version != TIFF_VERSION) {
     return NULL;
   }


When warning that a log file can't be compressed, tell the reader which log file it was.

--- usr.sbin/newsyslog/newsyslog.c
+++ usr.sbin/newsyslog/newsyslog.c
@@ -623,7 +623,7 @@
 	}
 	if ((flags & CE_COMPACT)) {
 		if (need_notification && !notified)
-			warnx("log not compressed because daemon not notified");
+			warnx("log %s not compressed because daemon not notified", log);
 		else if (noaction)
 			printf("Compress %s.0\n", log);
 		else {


Refactored the handling of manager capacity hints.

--- hs-bdd/src/bdd_mgr.c
+++ hs-bdd/src/bdd_mgr.c
@@ -40,12 +40,15 @@
     return res;
 }

+/* Converts the given size hint into the smallest valid size greater
+ * than or equal to the hint.  A valid size is a power of two greater
+ * than or equal to 128. */
 static unsigned
-up_to_next_power_of_two (unsigned n)
+size_hint_to_size (unsigned hint)
 {
     unsigned i;
-    for (i = 1; i < n; i *= 2) {}
-    return i;
+    for (i = 1; i < hint; i *= 2) {}
+    return 128u > i ? 128u : i;
 }

 /* Copies the BDD subgraph with the given root from the old node array
@@ -118,7 +121,7 @@
     node_t *old_nodes;
     unsigned i;

-    mgr->capacity = up_to_next_power_of_two (new_capacity_hint);
+    mgr->capacity = size_hint_to_size (new_capacity_hint);
     old_raw_bdd_map = mgr->raw_bdd_map;
     old_usr_bdd_map = mgr->usr_bdd_map;
     old_nodes = mgr->nodes;
@@ -249,7 +252,7 @@

     mgr->num_vars = num_vars;

-    mgr->capacity = up_to_next_power_of_two (capacity_hint + 32);
+    mgr->capacity = size_hint_to_size (capacity_hint);
     mgr->num_nodes = 0;
     mgr->num_deleted_nodes = 0;
     mgr->nodes = create_node_array (mgr->capacity);


Fixed linux timer and sleep

Fixed linux timer and sleep

--- dependancies/vul_timer.h
+++ dependancies/vul_timer.h
@@ -39,6 +39,7 @@
 	#define WIN32_LEAN_AND_MEAN
 	#include <windows.h>
 #elif defined( VUL_LINUX )
+	#include <time.h>
 	#include <unistd.h>
 	#include <sys/resource.h>
 	#include <sys/times.h>
@@ -104,7 +105,7 @@
 	c->zero = clock( );
 #elif defined( VUL_LINUX )
 	c->zero = clock( );
-	clock_gettime( CLOCK_MONOTONIC, &c->start );
+	clock_gettime( CLOCK_REALTIME, &c->start );
 #elif defined( VUL_OSX )
 	c->start = mach_absolute_time( );
 	mach_timebase_info( &c->timebase_info );
@@ -185,9 +186,9 @@
 	return ( ui64_t )new_ticks;
 #elif defined( VUL_LINUX )
 	struct timespec now;
-	clock_gettime( CLOCK_MONOTONIC, &now );
+	clock_gettime( CLOCK_REALTIME, &now );
 	return ( ( now.tv_sec - c->start.tv_sec ) * 1000 )
-	      +( ( now.tv_nsec - c->start.tv_nsec ) / 1000 );
+	      +( ( now.tv_nsec - c->start.tv_nsec ) / 1000000 );
 #elif defined( VUL_OSX )
 	uint64_t end = mach_absolute_time( );
 	uint64_t elapsed = end - c->start;
@@ -239,9 +240,9 @@
 	return new_micro;
 #elif defined( VUL_LINUX )
 	struct timespec now;
-	clock_gettime( CLOCK_MONOTONIC, &now );
+	clock_gettime( CLOCK_REALTIME, &now );
 	return ( ( now.tv_sec - c->start.tv_sec ) * 1000000 )
-	      +( now.tv_nsec - c->start.tv_nsec );
+	      +( now.tv_nsec - c->start.tv_nsec ) / 1000;
 #elif defined( VUL_OSX )
 	uint64_t end = mach_absolute_time( );
 	uint64_t elapsed = end - c->start;
@@ -279,7 +280,17 @@
 	Sleep( ms );
 	return 0;
 #elif defined( VUL_LINUX ) || defined( VUL_OSX )
-	return sleep( milliseconds );
+	struct timespec rem, req;
+	int err;
+	long tmp;
+
+	req.tv_sec = ( time_t )milliseconds / 1000;
+	req.tv_nsec = ( long )( milliseconds % 1000l ) * 1000000l;
+	err = clock_nanosleep( CLOCK_REALTIME, 0, &req, &rem );
+	if( err ) {
+		return ( int )( rem.tv_sec * 1000 ) + ( int )( rem.tv_nsec / 1000000l );
+	}
+	return 0;
 #else
 	assert( 0 && "vul_timer.h: OS not supported. Did you forget to specify an OS define?" );
 #endif


warden: Add more hooks to execute on instance start

Change-Id: I78ccced5aa16e1f1a87aaa2828a31f9536e2e47f

--- clone/clone.c
+++ clone/clone.c
@@ -63,6 +63,22 @@
     exit(1);
   }

+  /* Setup hook script paths */
+  char hook_before_pivot[PATH_MAX];
+  char hook_after_pivot[PATH_MAX];
+
+  /* Use verbatim path for before hook */
+  realpath("./hook-child-before-pivot.sh", hook_before_pivot);
+
+  /* Prefix /mnt to path for after hook */
+  strcpy(hook_after_pivot, "/mnt");
+  realpath("./hook-child-after-pivot.sh", hook_after_pivot + strlen(hook_after_pivot));
+
+  rv = run(hook_before_pivot);
+  if (rv == -1) {
+    exit(1);
+  }
+
   rv = chdir(h->new_root_path);
   if (rv == -1) {
     fprintf(stderr, "chdir: %s\n", strerror(errno));
@@ -90,6 +106,11 @@
   rv = chdir("/");
   if (rv == -1) {
     fprintf(stderr, "chdir: %s\n", strerror(errno));
+    exit(1);
+  }
+
+  rv = run(hook_after_pivot);
+  if (rv == -1) {
     exit(1);
   }

@@ -206,16 +227,21 @@
     exit(1);
   }

+  rv = run("./hook-parent-before-clone.sh");
+  if (rv == -1) {
+    fprintf(stderr, "unable to run before clone hook\n");
+    exit(1);
+  }
+
   rv = parent_clone_child(h);
   if (rv == -1) {
     fprintf(stderr, "unable to clone child\n");
     exit(1);
   }

-  /* Execute post-clone script before waking up child */
-  rv = run("./post-clone.sh");
-  if (rv == -1) {
-    fprintf(stderr, "unable to run post-clone.sh\n");
+  rv = run("./hook-parent-after-clone.sh");
+  if (rv == -1) {
+    fprintf(stderr, "unable to run after clone hook\n");
     exit(1);
   }


Change radio settings storage layout

Change radio settings storage layout

--- mos/chips/cc1101/cc1101.c
+++ mos/chips/cc1101/cc1101.c
@@ -273,59 +273,61 @@
 // Radio initialization
 //

-static const uint8_t rfConfig[][2] = {
+static const uint8_t rfConfig[] = {
     // Generated by SmartRF Studio
-    { REG_FIFOTHR,  0x47 }, // RX FIFO and TX FIFO Thresholds
-    { REG_FSCTRL1,  0x06 }, // Frequency Synthesizer Control
-    { REG_FSCTRL0,  0x00 }, // Frequency Synthesizer Control
-    { REG_FREQ2,    0x21 }, // Frequency Control Word, High Byte
-    { REG_FREQ1,    0x62 }, // Frequency Control Word, Middle Byte
-    { REG_FREQ0,    0x76 }, // Frequency Control Word, Low Byte
-    { REG_MDMCFG4,  0xF5 }, // Modem Configuration
-    { REG_MDMCFG3,  0x83 }, // Modem Configuration
-    { REG_MDMCFG2,  0x13 }, // Modem Configuration
-    { REG_MDMCFG1,  0x22 }, // Modem Configuration
-    { REG_MDMCFG0,  0xF8 }, // Modem Configuration
-    { REG_DEVIATN,  0x15 }, // Modem Deviation Setting
-    { REG_MCSM0,    0x18 }, // Main Radio Control State Machine Configuration
-    { REG_FOCCFG,   0x16 }, // Frequency Offset Compensation Configuration
-    { REG_BSCFG,    0x6C }, // Bit Synchronization Configuration
-    { REG_AGCCTRL2, 0x03 }, // AGC Control
-    { REG_AGCCTRL1, 0x40 }, // AGC Control
-    { REG_AGCCTRL0, 0x91 }, // AGC Control
-    { REG_FREND1,   0x56 }, // Front End RX Configuration
-    { REG_FREND0,   0x10 }, // Front End TX Configuration
-    { REG_FSCAL3,   0xE9 }, // Frequency Synthesizer Calibration
-    { REG_FSCAL2,   0x2A }, // Frequency Synthesizer Calibration
-    { REG_FSCAL1,   0x00 }, // Frequency Synthesizer Calibration
-    { REG_FSCAL0,   0x1F }, // Frequency Synthesizer Calibration
+    [REG_FIFOTHR]  = 0x47, // RX FIFO and TX FIFO Thresholds
+    [REG_FSCTRL1]  = 0x06, // Frequency Synthesizer Control
+    [REG_FSCTRL0]  = 0x00, // Frequency Synthesizer Control
+    [REG_FREQ2]    = 0x21, // Frequency Control Word, High Byte
+    [REG_FREQ1]    = 0x62, // Frequency Control Word, Middle Byte
+    [REG_FREQ0]    = 0x76, // Frequency Control Word, Low Byte
+    [REG_MDMCFG4]  = 0xF5, // Modem Configuration
+    [REG_MDMCFG3]  = 0x83, // Modem Configuration
+    [REG_MDMCFG2]  = 0x13, // Modem Configuration
+    [REG_MDMCFG1]  = 0x22, // Modem Configuration
+    [REG_MDMCFG0]  = 0xF8, // Modem Configuration
+    [REG_DEVIATN]  = 0x15, // Modem Deviation Setting
+    [REG_MCSM2]    = 0x07, // Main Radio Control State Machine Configuration
+    [REG_MCSM0]    = 0x18, // Main Radio Control State Machine Configuration
+    [REG_FOCCFG]   = 0x16, // Frequency Offset Compensation Configuration
+    [REG_BSCFG]    = 0x6C, // Bit Synchronization Configuration
+    [REG_AGCCTRL2] = 0x03, // AGC Control
+    [REG_AGCCTRL1] = 0x40, // AGC Control
+    [REG_AGCCTRL0] = 0x91, // AGC Control
+    [REG_WOREVT1]  = 0x87,
+    [REG_WOREVT0]  = 0x6B,
+    [REG_WORCTRL]  = 0xFB,
+    [REG_FREND1]   = 0x56, // Front End RX Configuration
+    [REG_FREND0]   = 0x10, // Front End TX Configuration
+    [REG_FSCAL3]   = 0xE9, // Frequency Synthesizer Calibration
+    [REG_FSCAL2]   = 0x2A, // Frequency Synthesizer Calibration
+    [REG_FSCAL1]   = 0x00, // Frequency Synthesizer Calibration
+    [REG_FSCAL0]   = 0x1F, // Frequency Synthesizer Calibration
+    [REG_RCCTRL1]  = 0x41,
+    [REG_RCCTRL0]  = 0x00,

     // Custom setup
-    { REG_CHANNR,   CC1101_DEFAULT_CHANNEL },
-    { REG_PKTCTRL1, 0x0C }, // Flush FIFO if CRC not OK, append status bytes
-    { REG_PKTCTRL0, 0x05 }, // CRC enable, variable packet length
-    //{ REG_ADDR,   0x00 }, // Node address
-    { REG_PKTLEN,   CC1101_MAX_PACKET_LEN }, // Maximum packet length
-    { REG_SYNC1,    MSB(CC1101_SYNC_WORD) }, // Sync word
-    { REG_SYNC0,    LSB(CC1101_SYNC_WORD) },
-    { REG_MCSM1,    0x03 }, // Switch to RX after packet transmission, stay in
-                            // IDLE after receiving a packet
-    { REG_PATABLE,  CC1101_TXPOWER }, // Default transmit power
+    [REG_CHANNR]   = CC1101_DEFAULT_CHANNEL,
+    [REG_PKTCTRL1] = 0x0C, // Flush FIFO if CRC not OK, append status bytes
+    [REG_PKTCTRL0] = 0x05, // CRC enable, variable packet length
+    [REG_ADDR]     = 0x00, // Node address
+    [REG_PKTLEN]   = CC1101_MAX_PACKET_LEN, // Maximum packet length
+    [REG_SYNC1]    = MSB(CC1101_SYNC_WORD), // Sync word
+    [REG_SYNC0]    = LSB(CC1101_SYNC_WORD),
+    [REG_MCSM1]    = 0x03, // Switch to RX after packet transmission, stay in
+                           // IDLE after receiving a packet

     // Interrupt setup
-#if CC1101_GDO_INTR != 0
-    { REG_IOCFG0,   0x2E }, // High impedance -- disable clock signal output
-#endif
-#define XREG_IOCFG(x) REG_IOCFG ## x
-#define REG_IOCFG(x)  XREG_IOCFG(x)
-    { REG_IOCFG(CC1101_GDO_INTR), 0x07 } // Assert when a packet has been
-                                         // received with CRC OK
+    // Generate interrupt on packet received with CRC OK (0x07), set the two
+    // other GDO pins to high impedance (0x2E)
+#define IOCFG_VAL(x) (CC1101_GDO_INTR == (x) ? 0x07 : 0x2E)
+    [REG_IOCFG2]   = IOCFG_VAL(2),
+    [REG_IOCFG1]   = IOCFG_VAL(1),
+    [REG_IOCFG0]   = IOCFG_VAL(0),
 };

 void cc1101Init(void)
 {
-    size_t i;
-
     spiBusInit(CC1101_SPI_ID, SPI_MODE_MASTER);
     pinAsOutput(CC1101_CSN_PORT, CC1101_CSN_PIN);

@@ -341,10 +343,8 @@
 #endif

     // Set up registers
-    for (i = 0; i < sizeof(rfConfig) / sizeof(rfConfig[0]); i++)
-    {
-        setreg(rfConfig[i][0], rfConfig[i][1]);
-    }
+    burstWrite(REG_IOCFG2, rfConfig, sizeof(rfConfig));
+    setreg(REG_PATABLE, CC1101_TXPOWER);

     // Enable radio interrupts
     pinIntRising(CC1101_INTR_PORT, CC1101_INTR_PIN);


core: Optimize json_from_string() to avoid copy

https://bugzilla.gnome.org/show_bug.cgi?id=774688

--- json-glib/json-utils.c
+++ json-glib/json-utils.c
@@ -63,7 +63,7 @@
       return NULL;
     }

-  retval = json_node_copy (json_parser_get_root (parser));
+  retval = json_parser_steal_root (parser);

   g_object_unref (parser);


test_sv_erase, test_sv_erase added

test_sv_erase, test_sv_erase added

--- examples/stest.c
+++ examples/stest.c
@@ -1682,14 +1682,66 @@
 	return res;
 }

+#define TEST_SV_CAT_RESIZE(v, ntest, alloc, push, type, a, b)		       \
+	sv_t *v = alloc(type, 0);					       \
+	push(&v, a); push(&v, b); push(&v, b); push(&v, b); push(&v, b);       \
+	push(&v, b); push(&v, a); push(&v, b); push(&v, b); push(&v, b);       \
+	sv_t *v##2 = NULL;						       \
+	sv_cat_resize(&v##2, v, 2);					       \
+	res |= !v ? 1<<(ntest*3) :					       \
+		(sv_size(v##2) == 2 ? 0 : 2<<(ntest*3)) |		       \
+		(!sv_ncmp(v, 0, v##2, 0, sv_size(v##2)) ? 0 : 4 << (ntest*3)) |\
+		(sv_ncmp(v, 0, v##2, 0, sv_size(v)) > 0 ? 0 : 8 << (ntest*3)) |\
+		(sv_ncmp(v##2, 0, v, 0, sv_size(v)) < 0 ? 0 : 16 << (ntest*3));\
+	sv_free(&v, &v##2);
+
 static int test_sv_cat_resize()
 {
-	return 0; /* TODO */
-}
+	int res = 0;
+	const int r = 12, s = 34;
+	TEST_SV_CAT_RESIZE(z, 0, sv_alloc, sv_push, sizeof(struct AA), &a1, &a2);
+	TEST_SV_CAT_RESIZE(b, 1, sv_alloc_t, sv_push_i, SV_I8, r, s);
+	TEST_SV_CAT_RESIZE(c, 2, sv_alloc_t, sv_push_u, SV_U8, r, s);
+	TEST_SV_CAT_RESIZE(d, 3, sv_alloc_t, sv_push_i, SV_I16, r, s);
+	TEST_SV_CAT_RESIZE(e, 4, sv_alloc_t, sv_push_u, SV_U16, r, s);
+	TEST_SV_CAT_RESIZE(f, 5, sv_alloc_t, sv_push_i, SV_I32, r, s);
+	TEST_SV_CAT_RESIZE(g, 6, sv_alloc_t, sv_push_u, SV_U32, r, s);
+	TEST_SV_CAT_RESIZE(h, 7, sv_alloc_t, sv_push_i, SV_I64, r, s);
+	TEST_SV_CAT_RESIZE(i, 8, sv_alloc_t, sv_push_u, SV_U64, r, s);
+	return res;
+}
+
+#define TEST_SV_ERASE(v, ntest, alloc, push, check, type, a, b)	 \
+	sv_t *v = alloc(type, 0);					 \
+	push(&v, b); push(&v, a); push(&v, a); push(&v, a); push(&v, a); \
+	push(&v, a); push(&v, b); push(&v, a); push(&v, a); push(&v, a); \
+	sv_erase(&v, 1, 5);						 \
+	res |= !v ? 1 << (ntest * 3) :					 \
+		    ((check) ? 0 : 2 << (ntest * 3)) |			 \
+		    (sv_size(v) == 5 ? 0 : 4 << (ntest * 3));		 \
+	sv_free(&v);

 static int test_sv_erase()
 {
-	return 0; /* TODO */
+	int res = 0;
+	const int r = 12, s = 34;
+	TEST_SV_ERASE(z, 0, sv_alloc, sv_push,
+	    ((const struct AA *)sv_at(z, 0))->a ==
+		    ((const struct AA *)sv_at(z, 1))->a,
+	    sizeof(struct AA), &a1, &a2);
+	#define SVIAT(v) sv_i_at(v, 0) == sv_i_at(v, 1)
+	#define SVUAT(v) sv_u_at(v, 0) == sv_u_at(v, 1)
+	TEST_SV_ERASE(b, 1, sv_alloc_t, sv_push_i, SVIAT(b), SV_I8, r, s);
+	TEST_SV_ERASE(c, 2, sv_alloc_t, sv_push_u, SVUAT(c), SV_U8, r, s);
+	TEST_SV_ERASE(d, 3, sv_alloc_t, sv_push_i, SVIAT(d), SV_I16, r, s);
+	TEST_SV_ERASE(e, 4, sv_alloc_t, sv_push_u, SVUAT(e), SV_U16, r, s);
+	TEST_SV_ERASE(f, 5, sv_alloc_t, sv_push_i, SVIAT(f), SV_I32, r, s);
+	TEST_SV_ERASE(g, 6, sv_alloc_t, sv_push_u, SVUAT(g), SV_U32, r, s);
+	TEST_SV_ERASE(h, 7, sv_alloc_t, sv_push_i, SVIAT(h), SV_I64, r, s);
+	TEST_SV_ERASE(i, 8, sv_alloc_t, sv_push_u, SVUAT(i), SV_U64, r, s);
+	#undef SVIAT
+	#undef SVUAT
+	return res;
 }

 static int test_sv_resize()


Add void:Dataset to the set of collection classes.

--- processors/spindle/classes.c
+++ processors/spindle/classes.c
@@ -77,6 +77,7 @@

 static const char *collection_matches[] = {
 	"http://purl.org/dc/dcmitype/Collection",
+	"http://rdfs.org/ns/void#Dataset",
 	NULL
 };


[Youtube] React to capabilities_changed

[Youtube] React to capabilities_changed

Trigger a refresh when the capabilities indicate that the credentials
are valid.


Fixing use of memcpy that should have been a memmove. This misuse was causing a 16 byte copy to take 7ms o_o

--- iree/vm/ref.c
+++ iree/vm/ref.c
@@ -159,7 +159,7 @@
   }

   // Assign ref to out_ref and increment the counter.
-  memcpy(out_ref, ref, sizeof(*out_ref));
+  memmove(out_ref, ref, sizeof(*out_ref));
   if (out_ref->ptr) {
     volatile iree_atomic_ref_count_t* counter =
         iree_vm_get_ref_counter_ptr(out_ref);
@@ -185,7 +185,7 @@
   }

   // Assign ref to out_ref and increment the counter if not moving.
-  memcpy(out_ref, ref, sizeof(*out_ref));
+  memmove(out_ref, ref, sizeof(*out_ref));
   if (out_ref->ptr && !is_move) {
     // Retain by incrementing counter and preserving the source ref.
     volatile iree_atomic_ref_count_t* counter =


finished with shatter demo

finished with shatter demo

--- Demo/Shatter.c
+++ Demo/Shatter.c
@@ -33,6 +33,7 @@
 	cpFloat cellSize;
 	int width, height;
 	cpBB bb;
+	cpVect focus;
 };

 static inline cpVect
@@ -149,7 +150,7 @@
 }

 static void
-ShatterShape(cpSpace *space, cpShape *shape, cpFloat cellSize)
+ShatterShape(cpSpace *space, cpShape *shape, cpFloat cellSize, cpVect focus)
 {
 	cpSpaceRemoveShape(space, shape);
 	cpSpaceRemoveBody(space, shape->body);
@@ -158,7 +159,7 @@
 	int width = (bb.r - bb.l)/cellSize + 1;
 	int height = (bb.t - bb.b)/cellSize + 1;
 //	printf("Splitting as %dx%d\n", width, height);
-	struct WorleyContex context = {rand(), cellSize, width, height, bb};
+	struct WorleyContex context = {rand(), cellSize, width, height, bb, focus};

 	for(int i=0; i<context.width; i++){
 		for(int j=0; j<context.height; j++){
@@ -187,9 +188,9 @@
 		cpNearestPointQueryInfo info;
 		if(cpSpaceNearestPointQueryNearest(space, ChipmunkDemoMouse, 0, GRABABLE_MASK_BIT, CP_NO_GROUP, &info)){
 			cpBB bb = cpShapeGetBB(info.shape);
-			cpFloat cell_size = cpfmax(bb.r - bb.l, bb.t - bb.b)/5.0f;
+			cpFloat cell_size = cpfmax(bb.r - bb.l, bb.t - bb.b)/10.0f;
 			if(cell_size > 5.0f){
-				ShatterShape(space, info.shape, cell_size);
+				ShatterShape(space, info.shape, cell_size, ChipmunkDemoMouse);
 			} else {
 				printf("Too small to splinter %f\n", cell_size);
 			}


fix const-ness

fix const-ness

Change-Id: I09c85fdb90b4380c8fc03c8b5652bb9cf29b2021

--- examples/vwebp.c
+++ examples/vwebp.c
@@ -388,7 +388,7 @@
 int main(int argc, char *argv[]) {
   WebPDecoderConfig config;
   int c;
-  const WebPIterator* const curr = &kParams.curr_frame;
+  WebPIterator* const curr = &kParams.curr_frame;
   WebPIterator* const prev = &kParams.prev_frame;

   if (!WebPInitDecoderConfig(&config)) {


teamd: lacp: alloc user to set port prio and key via config

Signed-off-by: Jiri Pirko <fa978af6b66b63204eae0f383d59a9477a8acf5e@redhat.com>

--- teamd/teamd_runner_lacp.c
+++ teamd/teamd_runner_lacp.c
@@ -148,6 +148,12 @@
 		uint8_t	duplex;
 		bool up;
 	} __link_last;
+	struct {
+		uint16_t prio;
+#define		LACP_PORT_CFG_DFLT_PRIO 0xff
+		uint16_t key;
+#define		LACP_PORT_CFG_DFLT_KEY 0
+	} cfg;
 };

 static int lacp_load_config(struct teamd_context *ctx, struct lacp *lacp)
@@ -459,8 +465,9 @@
 	struct lacpdu_info *actor = &lacp_port->actor;

 	actor->system_priority = htons(lacp_port->lacp->cfg.sys_prio);
-        actor->key = htons(0x00);
-        actor->port_priority = htons(0xff);
+	memcpy(actor->system, lacp_port->ctx->hwaddr, ETH_ALEN);
+        actor->key = htons(lacp_port->cfg.key);
+        actor->port_priority = htons(lacp_port->cfg.prio);
 	actor->port = htons(lacp_port->tdport->ifindex);
 }

@@ -468,11 +475,8 @@

 static int lacp_port_actor_update(struct lacp_port *lacp_port)
 {
-	struct lacpdu_info *actor = &lacp_port->actor;
 	int err;
 	uint8_t state = 0;
-
-	memcpy(actor->system, lacp_port->ctx->hwaddr, ETH_ALEN);

 	err = lacp_update_selected(lacp_port->lacp);
 	if (err)
@@ -493,7 +497,7 @@
 		state |= INFO_STATE_AGGREGATION;
 	teamd_log_dbg("%s: lacp info state: 0x%02X.", lacp_port->tdport->ifname,
 						      state);
-	actor->state = state;
+	lacp_port->actor.state = state;
 	return lacpdu_send(lacp_port);
 }

@@ -696,6 +700,43 @@
 	return 0;
 }

+static int lacp_port_load_config(struct teamd_context *ctx,
+				 struct lacp_port *lacp_port)
+{
+	const char *port_name = lacp_port->tdport->ifname;
+	int err;
+	int tmp;
+
+	err = json_unpack(ctx->config_json, "{s:{s:{s:i}}}", "ports", port_name,
+							     "lacp_prio", &tmp);
+	if (err) {
+		lacp_port->cfg.prio = LACP_PORT_CFG_DFLT_PRIO;
+	} else if (tmp < 0 || tmp > USHRT_MAX) {
+		teamd_log_err("%s: \"lacp_prio\" value is out of its limits.",
+			      port_name);
+		return -EINVAL;
+	} else {
+		lacp_port->cfg.prio = tmp;
+	}
+	teamd_log_dbg("%s: Using lacp_prio \"%d\".", port_name,
+		      lacp_port->cfg.prio);
+
+	err = json_unpack(ctx->config_json, "{s:{s:{s:i}}}", "ports", port_name,
+							     "lacp_key", &tmp);
+	if (err) {
+		lacp_port->cfg.key = LACP_PORT_CFG_DFLT_KEY;
+	} else if (tmp < 0 || tmp > USHRT_MAX) {
+		teamd_log_err("%s: \"lacp_key\" value is out of its limits.",
+			      port_name);
+		return -EINVAL;
+	} else {
+		lacp_port->cfg.key = tmp;
+	}
+	teamd_log_dbg("%s: Using lacp_key \"%d\".", port_name,
+		      lacp_port->cfg.key);
+	return 0;
+}
+
 static int lacp_port_added(struct teamd_context *ctx,
 			   struct teamd_port *tdport)
 {
@@ -706,6 +747,12 @@
 	lacp_port->ctx = ctx;
 	lacp_port->tdport = tdport;
 	lacp_port->lacp = lacp;
+
+	err = lacp_port_load_config(ctx, lacp_port);
+	if (err) {
+		teamd_log_err("Failed to load port config.");
+		return err;
+	}

 	err = teamd_packet_sock_open(&lacp_port->sock,
 				     tdport->ifindex,


test: trivial cleanups

test: trivial cleanups

Signed-off-by: Felipe Contreras <de77a8b9cd239b204c19c52ed62e48ab47243362@gmail.com>

--- dsp_test.c
+++ dsp_test.c
@@ -102,20 +102,20 @@
 {
 	events[0] = calloc(1, sizeof(struct dsp_notification));
 	if (!dsp_node_register_notify(dsp_handle, node,
-				      DSP_NODEMESSAGEREADY, 1,
-				      events[0]))
+				DSP_NODEMESSAGEREADY, 1,
+				events[0]))
 		return false;

 	events[1] = calloc(1, sizeof(struct dsp_notification));
 	if (!dsp_register_notify(dsp_handle, proc,
-				 DSP_MMUFAULT, 1,
-				 events[1]))
+				DSP_MMUFAULT, 1,
+				events[1]))
 		return false;

 	events[2] = calloc(1, sizeof(struct dsp_notification));
 	if (!dsp_register_notify(dsp_handle, proc,
-				 DSP_SYSERROR, 1,
-				 events[2]))
+				DSP_SYSERROR, 1,
+				events[2]))
 		return false;

 	return true;
@@ -134,7 +134,7 @@
 	case 0:
 		dsp_node_get_message(dsp_handle, node, msg, 100);
 		pr_debug("got dsp message: 0x%0x 0x%0x 0x%0x",
-			 msg->cmd, msg->arg_1, msg->arg_2);
+				msg->cmd, msg->arg_1, msg->arg_2);
 		return true;
 	case 1:
 		pr_err("got DSP MMUFAULT");
@@ -217,7 +217,7 @@
 		}

 		printf("ping: id=%d, msg=%d, mem=%d\n",
-		       msg.cmd, msg.arg_1, msg.arg_2);
+				msg.cmd, msg.arg_1, msg.arg_2);

 		if (--times == 0)
 			break;