Resolve #55: SCPI_ExprChannelListEntry example

--- examples/common/scpi-def.c
+++ examples/common/scpi-def.c
@@ -185,6 +185,148 @@

     SCPI_ResultArbitraryBlock(context, data, len);

+    return SCPI_RES_OK;
+}
+
+struct _scpi_channel_value_t {
+    int32_t row;
+    int32_t col;
+};
+typedef struct _scpi_channel_value_t scpi_channel_value_t;
+
+/**
+ * @brief
+ * parses lists
+ * channel numbers > 0.
+ * no checks yet.
+ * valid: (@1), (@3!1:1!3), ...
+ * (@1!1:3!2) would be 1!1, 1!2, 2!1, 2!2, 3!1, 3!2.
+ * (@3!1:1!3) would be 3!1, 3!2, 3!3, 2!1, 2!2, 2!3, ... 1!3.
+ *
+ * @param channel_list channel list, compare to SCPI99 Vol 1 Ch. 8.3.2
+ */
+static scpi_result_t TEST_Chanlst(scpi_t *context) {
+    scpi_parameter_t channel_list_param;
+#define maxrow 2    //maximum number of rows
+#define maxcol 6    //maximum number of columns
+#define maxdim 2    //maximum number of dimensions
+    scpi_channel_value_t array[maxrow * maxcol]; //array which holds values in order (2D)
+    size_t chanlst_idx; //index for channel list
+    size_t arr_idx = 0; //index for array
+    size_t n, m = 1; //counters for row (n) and columns (m)
+
+    // get channel list
+    if (SCPI_Parameter(context, &channel_list_param, TRUE)) {
+        scpi_expr_result_t res;
+        scpi_bool_t is_range;
+        int32_t values_from[maxdim];
+        int32_t values_to[maxdim];
+        size_t dimensions;
+
+        bool for_stop_row = false; //true if iteration for rows has to stop
+        bool for_stop_col = false; //true if iteration for columns has to stop
+        int32_t dir_row = 1; //direction of counter for rows, +/-1
+        int32_t dir_col = 1; //direction of counter for columns, +/-1
+
+        // the next statement is valid usage and it gets only real number of dimensions for the first item (index 0)
+        if (!SCPI_ExprChannelListEntry(context, &channel_list_param, 0, &is_range, NULL, NULL, 0, &dimensions)) {
+            chanlst_idx = 0; //call first index
+            arr_idx = 0; //set arr_idx to 0
+            do { //if valid, iterate over channel_list_param index while res == valid (do-while cause we have to do it once)
+                res = SCPI_ExprChannelListEntry(context, &channel_list_param, chanlst_idx, &is_range, values_from, values_to, 4, &dimensions);
+                if (is_range == false) { //still can have multiple dimensions
+                    if (dimensions == 1) {
+                        //here we have our values
+                        //row == values_from[0]
+                        //col == 0 (fixed number)
+                        //call a function or something
+                        array[arr_idx].row = values_from[0];
+                        array[arr_idx].col = 0;
+                    } else if (dimensions == 2) {
+                        //here we have our values
+                        //row == values_fom[0]
+                        //col == values_from[1]
+                        //call a function or something
+                        array[arr_idx].row = values_from[0];
+                        array[arr_idx].col = values_from[1];
+                    } else {
+                        return SCPI_RES_ERR;
+                        break;
+                    }
+                    arr_idx++; //inkrement array where we want to save our values to, not neccessary otherwise
+                } else if (is_range == true) {
+                    if (values_from[0] > values_to[0]) {
+                        dir_row = -1; //we have to decrement from values_from
+                    } else { //if (values_from[0] < values_to[0])
+                        dir_row = +1; //default, we increment from values_from
+                    }
+
+                    //iterating over rows, do it once -> set for_stop_row = false
+                    //needed if there is channel list index isn't at end yet
+                    for_stop_row = false;
+                    for (n = values_from[0]; for_stop_row == false; n += dir_row) {
+                        //usual case for ranges, 2 dimensions
+                        if (dimensions == 2) {
+                            if (values_from[1] > values_to[1]) {
+                                dir_col = -1;
+                            } else if (values_from[1] < values_to[1]) {
+                                dir_col = +1;
+                            }
+                            //iterating over columns, do it at least once -> set for_stop_col = false
+                            //needed if there is channel list index isn't at end yet
+                            for_stop_col = false;
+                            for (m = values_from[1]; for_stop_col == false; m += dir_col) {
+                                //here we have our values
+                                //row == n
+                                //col == m
+                                //call a function or something
+                                array[arr_idx].row = n;
+                                array[arr_idx].col = m;
+                                arr_idx++;
+                                if (m == (size_t)values_to[1]) {
+                                    //endpoint reached, stop column for-loop
+                                    for_stop_col = true;
+                                }
+                            }
+                            //special case for range, example: (@2!1)
+                        } else if (dimensions == 1) {
+                            //here we have values
+                            //row == n
+                            //col == 0 (fixed number)
+                            //call function or sth.
+                            array[arr_idx].row = n;
+                            array[arr_idx].col = 0;
+                            arr_idx++;
+                        }
+                        if (n == (size_t)values_to[0]) {
+                            //endpoint reached, stop row for-loop
+                            for_stop_row = true;
+                        }
+                    }
+
+
+                } else {
+                    return SCPI_RES_ERR;
+                    break;
+                }
+                //increase index
+                chanlst_idx++;
+            } while (SCPI_EXPR_OK == SCPI_ExprChannelListEntry(context, &channel_list_param, chanlst_idx, &is_range, values_from, values_to, 4, &dimensions));
+            //while checks, whether incremented index is valid
+        }
+        //do something at the end if needed
+        array[arr_idx].row = 0;
+        array[arr_idx].col = 0;
+    }
+
+    {
+        size_t i;
+        fprintf(stderr, "TEST_Chanlst: ");
+        for (i = 0; i< arr_idx; i++) {
+            fprintf(stderr, "%d!%d, ", array[i].row, array[i].col);
+        }
+        fprintf(stderr, "\r\n");
+    }
     return SCPI_RES_OK;
 }

@@ -256,6 +398,7 @@
     {.pattern = "TEST#:NUMbers#", .callback = TEST_Numbers,},
     {.pattern = "TEST:TEXT", .callback = TEST_Text,},
     {.pattern = "TEST:ARBitrary?", .callback = TEST_ArbQ,},
+    {.pattern = "TEST:CHANnellist", .callback = TEST_Chanlst,},

     SCPI_CMD_LIST_END
 };


lib-storage: Fixed listing subscriptions in shared namespaces.

--- src/lib-storage/list/mailbox-list-subscriptions.c
+++ src/lib-storage/list/mailbox-list-subscriptions.c
@@ -26,7 +26,7 @@
 	struct mail_namespace *ns, *default_ns = list->ns;
 	struct mail_namespace *namespaces = default_ns->user->namespaces;
 	struct mailbox_node *node;
-	const char *vname, *ns_name;
+	const char *vname, *ns_name, *list_name;
 	unsigned int len;
 	bool created;

@@ -60,7 +60,8 @@
 		/* we'll need to get the namespace autocreated.
 		   one easy way is to just ask if a mailbox name under
 		   it is valid, and it gets created */
-		(void)mailbox_list_is_valid_existing_name(list, name);
+		list_name = ns_name + ns->prefix_len;
+		(void)mailbox_list_is_valid_existing_name(list, list_name);
 		ns = mail_namespace_find_unsubscribable(namespaces, ns_name);
 		i_assert(ns != NULL &&
 			 (ns->flags & NAMESPACE_FLAG_AUTOCREATED) != 0);


quiet compiler warning about ptr->int conversion

--- include/list.h
+++ include/list.h
@@ -32,7 +32,7 @@

 /* give offset of a field inside struct */
 #ifndef offsetof
-#define offsetof(type, field) ((unsigned)&(((type *)0)->field))
+#define offsetof(type, field) ((unsigned long)&(((type *)0)->field))
 #endif

 /* given pointer to field inside struct, return pointer to struct */


gl: Only show WARNING about breaking signatures when we would.

I find it confusing that it shows a warning about a dangerous
option when it is NOT in the dangerous state.

It's also more obvious that it's become dangerous when a warning
appears at the time the user selects the dangerous option.

--- platform/gl/gl-annotate.c
+++ platform/gl/gl-annotate.c
@@ -107,7 +107,7 @@

 	fz_try(ctx)
 	{
-		if (pdf_count_signatures(ctx, pdf))
+		if (pdf_count_signatures(ctx, pdf) && !save_opts.do_incremental)
 		{
 			if (can_be_incremental)
 				ui_label("WARNING: Saving non-incrementally will break existing signatures");


protocol

protocol

error: pathspec 'vtrc-server/vtrc-connection-impl.h' did not match any file(s) known to git

--- vtrc-server/vtrc-connection-impl.h
+++ vtrc-server/vtrc-connection-impl.h
@@ -0,0 +1,131 @@
+#ifndef VTRC_CONNECTION_IMPL_H
+#define VTRC_CONNECTION_IMPL_H
+
+namespace vtrc { namespace server { namespace endpoints {
+
+    namespace {
+
+        namespace basio = boost::asio;
+        namespace bsys  = boost::system;
+
+        template <typename ParentType>
+        struct connection_impl: public ParentType {
+
+            typedef ParentType                          parent_type;
+            typedef connection_impl<ParentType>         this_type;
+            typedef typename ParentType::socket_type    socket_type;
+
+            endpoint_iface                     &endpoint_;
+            application                        &app_;
+            basio::io_service                  &ios_;
+            common::enviroment                  env_;
+
+            std::vector<char>                   read_buff_;
+
+            vtrc::shared_ptr<protocol_layer_s>  protocol_;
+
+            connection_impl(endpoint_iface &endpoint, socket_type *sock)
+                :parent_type(sock)
+                ,endpoint_(endpoint)
+                ,app_(endpoint_.get_application( ))
+                ,ios_(app_.get_io_service( ))
+                ,env_(endpoint_.get_enviroment( ))
+                ,read_buff_(4096)
+            {
+                protocol_ = vtrc::make_shared<server::protocol_layer_s>
+                                                     (vtrc::ref(app_), this);
+            }
+
+            static vtrc::shared_ptr<this_type> create
+                             (endpoint_iface &endpoint, socket_type *sock)
+            {
+                vtrc::shared_ptr<this_type> new_inst
+                                    (vtrc::make_shared<this_type>
+                                                  (vtrc::ref(endpoint), sock));
+                new_inst->init( );
+                return new_inst;
+            }
+
+            void init( )
+            {
+                start_reading( );
+                protocol_ ->init( );
+            }
+
+            bool ready( ) const
+            {
+                protocol_->ready( );
+            }
+
+            endpoint_iface &endpoint( )
+            {
+                return endpoint_;
+            }
+
+            std::string prepare_for_write( const char *data, size_t length )
+            {
+                return protocol_->prepare_data( data, length );
+            }
+
+            void on_write_error( const bsys::error_code &error )
+            {
+                protocol_->on_write_error( error );
+                parent_type::close( );
+                //app_.get_clients( )->drop(this); // delete
+            }
+
+            void start_reading( )
+            {
+#if 0
+                basio::io_service::strand &disp(get_dispatcher( ));
+                get_socket( ).async_read_some(
+                        basio::buffer( &read_buff_[0], read_buff_.size( ) ),
+                        disp.wrap(vtrc::bind( &this_type::read_handler, this,
+                             basio::placeholders::error,
+                             basio::placeholders::bytes_transferred,
+                             weak_from_this( )))
+                    );
+#else
+                parent_type::get_socket( ).async_read_some(
+                        basio::buffer( &read_buff_[0], read_buff_.size( ) ),
+                            vtrc::bind( &this_type::read_handler, this,
+                                 basio::placeholders::error,
+                                 basio::placeholders::bytes_transferred,
+                                 parent_type::weak_from_this( ))
+                    );
+#endif
+            }
+
+            void read_handler( const bsys::error_code &error, size_t bytes,
+                               common::connection_iface_wptr parent)
+            {
+                common::connection_iface_sptr lk(parent.lock( ));
+                if( !lk ) return;
+
+                if( !error ) {
+                    try {
+                        protocol_->process_data( &read_buff_[0], bytes );
+                    } catch( const std::exception & /*ex*/ ) {
+                        parent_type::close( );
+                        app_.get_clients( )->drop(this); // delete
+                        return;
+                    }
+                    start_reading( );
+                } else {
+                    protocol_->on_read_error( error );
+                    parent_type::close( );
+                    app_.get_clients( )->drop(this); // delete
+                }
+            }
+
+            protocol_layer_s &get_protocol( )
+            {
+                return *protocol_;
+            }
+        };
+
+    } // namespace
+
+}}}
+
+#endif // VTRCCONNECTIONIMPL_H


Add MSVC and Windows support

Add MSVC and Windows support

--- C/mandelbrot.c
+++ C/mandelbrot.c
@@ -19,7 +19,13 @@
 #include <float.h>
 #include <errno.h>
 #include <limits.h>
+
+#ifdef _WIN32
+#include <time.h>
+#include <Windows.h>
+#else
 #include <sys/time.h>
+#endif

 typedef enum exitcode_t {
     ERROR_ALLOC_MEMORY = 1,
@@ -390,12 +396,24 @@

 double gettime()
 {
+#ifdef _WIN32
+    LARGE_INTEGER t, freq;
+
+    QueryPerformanceFrequency(&freq);
+    QueryPerformanceCounter(&t);
+
+    t.QuadPart *= 1000000;
+    t.QuadPart /= freq.QuadPart;
+
+    return t.QuadPart / 1000000.0;
+#else
     struct timeval tv;

     if (gettimeofday(&tv, NULL) != 0)
         die(ERROR_GETTIME);

     return (double) tv.tv_sec + (double) tv.tv_usec / 1000000.0;
+#endif
 }

 int eval_int_arg(const char *s, int min, int max)


. re-changement de vout_sdl.c pour que �a fonctionne en woody.

--- plugins/sdl/vout_sdl.c
+++ plugins/sdl/vout_sdl.c
@@ -120,6 +120,7 @@
     {
         SDL_UnlockSurface ( p_vout->p_sys->p_display );
     }
+    free( p_vout->p_sys );
 }

 /*****************************************************************************
@@ -193,6 +194,7 @@
  *****************************************************************************/
 static int SDLOpenDisplay( vout_thread_t *p_vout, char *psz_display, void *p_data )
 {
+    SDL_Rect    clipping_rect;

     /* Initialize library */
     if( SDL_Init(SDL_INIT_VIDEO) < 0 )
@@ -256,9 +258,11 @@
 */

     /* Set clipping for text */
-    SDL_SetClipping(p_vout->p_sys->p_display, 0, 0,
-                    p_vout->p_sys->p_display->w,
-                    p_vout->p_sys->p_display->h);
+    clipping_rect.x = 0;
+    clipping_rect.y = 0;
+    clipping_rect.w = p_vout->p_sys->p_display->w;
+    clipping_rect.h = p_vout->p_sys->p_display->h;
+    SDL_SetClipRect(p_vout->p_sys->p_display, &clipping_rect);


bnx2x: Restore 1G LED on BCM57712+BCM8727 designs.

Fix no-LED problem when link speed is 1G on BCM57712 + BCM8727 designs, by
removing a logic error checking for a different PHY.

Signed-off-by: Yaniv Rosner <863d04138a679eefe08d0a31ca0f8f3a07fae2ff@broadcom.com>
Signed-off-by: Eilon Greenstein <5ba67022bcc5f9ee9b9819ddc35fa83823aa47ee@broadcom.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
+++ drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
@@ -6216,12 +6216,14 @@

 		tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED);
 		if (params->phy[EXT_PHY1].type ==
-			  PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE)
-			EMAC_WR(bp, EMAC_REG_EMAC_LED, tmp & 0xfff1);
-		else {
-			EMAC_WR(bp, EMAC_REG_EMAC_LED,
-				(tmp | EMAC_LED_OVERRIDE));
-		}
+			PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE)
+			tmp &= ~(EMAC_LED_1000MB_OVERRIDE |
+				EMAC_LED_100MB_OVERRIDE |
+				EMAC_LED_10MB_OVERRIDE);
+		else
+			tmp |= EMAC_LED_OVERRIDE;
+
+		EMAC_WR(bp, EMAC_REG_EMAC_LED, tmp);
 		break;

 	case LED_MODE_OPER:
@@ -6276,10 +6278,15 @@
 				       hw_led_mode);
 		} else if ((params->phy[EXT_PHY1].type ==
 			    PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) &&
-			   (mode != LED_MODE_OPER)) {
+			   (mode == LED_MODE_ON)) {
 			REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4, 0);
 			tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED);
-			EMAC_WR(bp, EMAC_REG_EMAC_LED, tmp | 0x3);
+			EMAC_WR(bp, EMAC_REG_EMAC_LED, tmp |
+				EMAC_LED_OVERRIDE | EMAC_LED_1000MB_OVERRIDE);
+			/* Break here; otherwise, it'll disable the
+			 * intended override.
+			 */
+			break;
 		} else
 			REG_WR(bp, NIG_REG_LED_MODE_P0 + port*4,
 			       hw_led_mode);
@@ -6294,13 +6301,9 @@
 			       LED_BLINK_RATE_VAL_E1X_E2);
 		REG_WR(bp, NIG_REG_LED_CONTROL_BLINK_RATE_ENA_P0 +
 		       port*4, 1);
-		if ((params->phy[EXT_PHY1].type !=
-		     PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM54618SE) &&
-		    (mode != LED_MODE_OPER)) {
-			tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED);
-			EMAC_WR(bp, EMAC_REG_EMAC_LED,
-				(tmp & (~EMAC_LED_OVERRIDE)));
-		}
+		tmp = EMAC_RD(bp, EMAC_REG_EMAC_LED);
+		EMAC_WR(bp, EMAC_REG_EMAC_LED,
+			(tmp & (~EMAC_LED_OVERRIDE)));

 		if (CHIP_IS_E1(bp) &&
 		    ((speed == SPEED_2500) ||


unsigned char * -> uint8_t *, more careful error handling

--- framebuffer.h
+++ framebuffer.h
@@ -25,28 +25,17 @@
 };

 struct framebuffer {
-	unsigned char *fp;              /* pointer of framebuffer (read only) */
-	unsigned char *buf;             /* copy of framebuffer */
+	uint8_t *fp;                    /* pointer of framebuffer (read only) */
+	uint8_t *buf;                   /* copy of framebuffer */
 	int fd;                         /* file descriptor of framebuffer */
 	int width, height;              /* display resolution */
 	long screen_size;               /* screen data size (byte) */
 	int line_length;                /* line length (byte) */
-	int bpp;                        /* BYTES per pixel */
+	int bytes_per_pixel;            /* BYTES per pixel */
 	struct fb_cmap *cmap,           /* cmap for legacy framebuffer (8bpp pseudocolor) */
 		*cmap_org;                  /* copy of default cmap */
 	struct fb_var_screeninfo vinfo; /* display info: need for get_color() */
 };
-
-void cmap_create(struct fb_cmap **cmap)
-{
-	*cmap           = (struct fb_cmap *) ecalloc(1, sizeof(struct fb_cmap));
-	(*cmap)->start  = 0;
-	(*cmap)->len    = CMAP_COLORS;
-	(*cmap)->red    = (uint16_t *) ecalloc(CMAP_COLORS, sizeof(uint16_t));
-	(*cmap)->green  = (uint16_t *) ecalloc(CMAP_COLORS, sizeof(uint16_t));
-	(*cmap)->blue   = (uint16_t *) ecalloc(CMAP_COLORS, sizeof(uint16_t));
-	(*cmap)->transp = NULL;
-}

 void cmap_die(struct fb_cmap *cmap)
 {
@@ -59,7 +48,27 @@
 	}
 }

-void cmap_init(struct framebuffer *fb, struct fb_var_screeninfo *vinfo)
+bool cmap_create(struct fb_cmap **cmap)
+{
+	if ((*cmap = (struct fb_cmap *) ecalloc(1, sizeof(struct fb_cmap))) == NULL)
+		return false;
+
+	(*cmap)->start  = 0;
+	(*cmap)->len    = CMAP_COLORS;
+
+	(*cmap)->red    = (uint16_t *) ecalloc(CMAP_COLORS, sizeof(uint16_t));
+	(*cmap)->green  = (uint16_t *) ecalloc(CMAP_COLORS, sizeof(uint16_t));
+	(*cmap)->blue   = (uint16_t *) ecalloc(CMAP_COLORS, sizeof(uint16_t));
+	(*cmap)->transp = NULL;
+
+	if (!(*cmap)->red || !(*cmap)->green || !(*cmap)->blue) {
+		cmap_die(*cmap);
+		return false;
+	}
+	return true;
+}
+
+bool cmap_init(struct framebuffer *fb, struct fb_var_screeninfo *vinfo)
 {
 	int i;
 	uint8_t index;
@@ -67,7 +76,7 @@

 	if (ioctl(fb->fd, FBIOGETCMAP, fb->cmap_org)) {
 		/* not fatal, but we cannot restore original cmap */
-		fprintf(stderr, "couldn't get original cmap\n");
+		logging(ERROR, "couldn't get original cmap\n");
 		cmap_die(fb->cmap_org);
 		fb->cmap_org = NULL;
 	}
@@ -104,8 +113,7 @@
 		b = b * bit_mask[16] / bit_mask[CMAP_BLUE_MASK];

 		/*
-		if (DEBUG)
-			fprintf(stderr, "index:%.2X r:%.4X g:%.4X b:%.4X\n", index, r, g, b);
+		logging(DEBUG, "index:%.2X r:%.4X g:%.4X b:%.4X\n", index, r, g, b);
 		*/

 		/* check bit reverse flag */
@@ -117,8 +125,11 @@
 			bit_reverse(b, 16) & bit_mask[16]: b;
 	}

-	if (ioctl(fb->fd, FBIOPUTCMAP, fb->cmap))
-		fatal("ioctl: FBIOGET_VSCREENINFO failed");
+	if (ioctl(fb->fd, FBIOPUTCMAP, fb->cmap)) {
+		logging(ERROR, "ioctl: FBIOGET_VSCREENINFO failed\n");
+		return false;
+	}
+	return true;
 }

 void draw_cmap_table(struct framebuffer *fb)
@@ -137,14 +148,15 @@

 		for (h = 0; h < CELL_HEIGHT; h++) {
 			for (w = 0; w < CELL_WIDTH; w++) {
-				memcpy(fb->fp + (CELL_WIDTH * w_offset + w) * fb->bpp
-					+ (h + h_offset) * fb->line_length, &c, fb->bpp);
+				/* BUG: this memcpy is invalid, may fail at 24bpp and MSByte first env */
+				memcpy(fb->fp + (CELL_WIDTH * w_offset + w) * fb->bytes_per_pixel
+					+ (h + h_offset) * fb->line_length, &c, fb->bytes_per_pixel);
 			}
 		}
 	}
 }

-inline uint32_t get_color(struct fb_var_screeninfo *vinfo, uint8_t r, uint8_t g, uint8_t b)
+static inline uint32_t get_color(struct fb_var_screeninfo *vinfo, uint8_t r, uint8_t g, uint8_t b)
 {
 	if (vinfo->bits_per_pixel == 8) {
 		/*
@@ -180,22 +192,47 @@
 		+ (b << vinfo->blue.offset);
 }

-void fb_init(struct framebuffer *fb)
+bool fb_init(struct framebuffer *fb)
 {
 	char *path;
 	struct fb_fix_screeninfo finfo;
 	struct fb_var_screeninfo vinfo;
+
+	const char *fb_type[] = {
+		[FB_TYPE_PACKED_PIXELS]      = "FB_TYPE_PACKED_PIXELS",
+		[FB_TYPE_PLANES]             = "FB_TYPE_PLANES",
+		[FB_TYPE_INTERLEAVED_PLANES] = "FB_TYPE_INTERLEAVED_PLANES",
+		[FB_TYPE_TEXT]               = "FB_TYPE_TEXT",
+		[FB_TYPE_VGA_PLANES]         = "FB_TYPE_VGA_PLANES",
+		[FB_TYPE_FOURCC]             = "FB_TYPE_FOURCC",
+	};
+	const char *fb_visual[] = {
+		[FB_VISUAL_MONO01]             = "FB_VISUAL_MONO01",
+		[FB_VISUAL_MONO10]             = "FB_VISUAL_MONO10",
+		[FB_VISUAL_TRUECOLOR]          = "FB_VISUAL_TRUECOLOR",
+		[FB_VISUAL_PSEUDOCOLOR]        = "FB_VISUAL_PSEUDOCOLOR",
+		[FB_VISUAL_DIRECTCOLOR]        = "FB_VISUAL_DIRECTCOLOR",
+		[FB_VISUAL_STATIC_PSEUDOCOLOR] = "FB_VISUAL_STATIC_PSEUDOCOLOR",
+		[FB_VISUAL_FOURCC]             = "FB_VISUAL_FOURCC",
+	};

 	if ((path = getenv("FRAMEBUFFER")) != NULL)
 		fb->fd = eopen(path, O_RDWR);
 	else
 		fb->fd = eopen(fb_path, O_RDWR);

-	if (ioctl(fb->fd, FBIOGET_FSCREENINFO, &finfo))
-		fatal("ioctl: FBIOGET_FSCREENINFO failed");
-
-	if (ioctl(fb->fd, FBIOGET_VSCREENINFO, &vinfo))
-		fatal("ioctl: FBIOGET_VSCREENINFO failed");
+	if (fb->fd < 0)
+		return false;
+
+	if (ioctl(fb->fd, FBIOGET_FSCREENINFO, &finfo)) {
+		logging(ERROR, "ioctl: FBIOGET_FSCREENINFO failed\n");
+		goto err_init_failed;
+	}
+
+	if (ioctl(fb->fd, FBIOGET_VSCREENINFO, &vinfo)) {
+		logging(ERROR, "ioctl: FBIOGET_VSCREENINFO failed\n");
+		goto err_init_failed;
+	}

 	/* check screen offset and initialize because linux console change this */
 	/*
@@ -210,25 +247,40 @@
 	fb->screen_size = finfo.smem_len;
 	fb->line_length = finfo.line_length;

-	if ((finfo.visual == FB_VISUAL_TRUECOLOR || finfo.visual == FB_VISUAL_DIRECTCOLOR)
+	if (finfo.visual == FB_VISUAL_TRUECOLOR
 		&& (vinfo.bits_per_pixel == 15 || vinfo.bits_per_pixel == 16
 		|| vinfo.bits_per_pixel == 24 || vinfo.bits_per_pixel == 32)) {
 		fb->cmap = fb->cmap_org = NULL;
-		fb->bpp = my_ceil(vinfo.bits_per_pixel, BITS_PER_BYTE);
-	}
-	else if (finfo.visual == FB_VISUAL_PSEUDOCOLOR
+		fb->bytes_per_pixel = my_ceil(vinfo.bits_per_pixel, BITS_PER_BYTE);
+	} else if ((finfo.visual == FB_VISUAL_PSEUDOCOLOR || finfo.visual == FB_VISUAL_DIRECTCOLOR)
 		&& vinfo.bits_per_pixel == 8) {
-		cmap_create(&fb->cmap);
-		cmap_create(&fb->cmap_org);
-		cmap_init(fb, &vinfo);
-		fb->bpp = 1;
-	}
-	else /* non packed pixel, mono color, grayscale: not implimented */
-		fatal("unsupported framebuffer type");
-
-	fb->fp    = (unsigned char *) emmap(0, fb->screen_size, PROT_WRITE | PROT_READ, MAP_SHARED, fb->fd, 0);
-	fb->buf   = (unsigned char *) ecalloc(1, fb->screen_size);
+		/* XXX: direct color is not tested! */
+		if (!cmap_create(&fb->cmap) || !cmap_create(&fb->cmap_org) || !cmap_init(fb, &vinfo)) {
+			logging(ERROR, "cmap init failed\n");
+			goto err_init_failed;
+		}
+		fb->bytes_per_pixel = 1;
+	} else { /* non packed pixel, mono color, grayscale: not implimented */
+		logging(ERROR, "unsupported framebuffer type\nvisual:%s type:%s bpp:%d\n",
+			fb_visual[finfo.visual], fb_type[finfo.type], vinfo.bits_per_pixel);
+		goto err_init_failed;
+	}
+
+	if ((fb->fp = (uint8_t *) emmap(0, fb->screen_size, PROT_WRITE, MAP_SHARED, fb->fd, 0)) == MAP_FAILED)
+		goto err_init_failed;
+
+	if ((fb->buf = (uint8_t *) ecalloc(1, fb->screen_size)) == NULL)
+		goto err_init_failed;
+
 	fb->vinfo = vinfo;
+	return true;
+
+err_init_failed:
+	if (fb->fp != MAP_FAILED)
+		munmap(fb->fp, fb->screen_size);
+	if (fb->fd >= 0)
+		close(fb->fd);
+	return false;
 }

 void fb_die(struct framebuffer *fb)


optimize sc_int_common(built_in_int_type)

--- systemc-utils/bca-subset/src/sysc/datatypes/int/sc_int.h
+++ systemc-utils/bca-subset/src/sysc/datatypes/int/sc_int.h
@@ -72,16 +72,6 @@
     return (width <= W) ? value : wrap(value);
   }
   sc_inline static value_type adjust_setbit(value_type newvalue, int pos) { return newvalue; }
-};
-
-template <typename Traits, bool B> struct sc_int_wrap_if;
-template <typename Traits> struct sc_int_wrap_if<Traits,false> {
-  typedef typename Traits::value_type value_type;
-  sc_inline static value_type wrap(value_type value) { return value; }
-};
-template <typename Traits> struct sc_int_wrap_if<Traits,true> {
-  typedef typename Traits::value_type value_type;
-  sc_inline static value_type wrap(value_type value) { return Traits::wrap(value); }
 };

 struct sc_int_bitref_r {
@@ -637,12 +627,23 @@
   value_type m_value;
   sc_inline operator value_type() const { return m_value; }
   sc_inline sc_int_common() {}
-  sc_inline sc_int_common(value_type x) : m_value(traits_type::wrap(x)) {}
-  template <int V> sc_inline sc_int_common(const sc_int_common<S,V>& x)
-    : m_value(sc_int_wrap_if<traits_type,(W<V)>::wrap(x.m_value)) {}
   template <typename SS, bool WIDE>
-  sc_inline sc_int_common(const sc_int_ranged<SS,WIDE>& x)
-    : m_value(traits_type::wrap(x, sc_int_assign_width<WIDE,(W>32)>(x,S()))) {}
+  sc_inline static value_type wrap(const sc_int_ranged<SS,WIDE>& x) {
+    return traits_type::wrap(x, sc_int_assign_width<WIDE,(W>32)>(x,S()));
+  }
+  sc_inline sc_int_common(bool               x) : m_value(wrap(sc_int_rsi(x))) {}
+  sc_inline sc_int_common(signed char        x) : m_value(wrap(sc_int_rsi(x))) {}
+  sc_inline sc_int_common(unsigned char      x) : m_value(wrap(sc_int_rsi(x))) {}
+  sc_inline sc_int_common(signed short       x) : m_value(wrap(sc_int_rsi(x))) {}
+  sc_inline sc_int_common(unsigned short     x) : m_value(wrap(sc_int_rsi(x))) {}
+  sc_inline sc_int_common(signed int         x) : m_value(wrap(sc_int_rsi(x))) {}
+  sc_inline sc_int_common(unsigned int       x) : m_value(wrap(sc_int_rui(x))) {}
+  sc_inline sc_int_common(signed long long   x) : m_value(wrap(sc_int_rsl(x))) {}
+  sc_inline sc_int_common(unsigned long long x) : m_value(wrap(sc_int_rul(x))) {}
+  template <typename SS, bool WIDE>
+  sc_inline sc_int_common(const sc_int_ranged<SS,WIDE>& x) : m_value(wrap(x)) {}
+  template <typename SS, int WW>
+  sc_inline sc_int_common(const sc_int_common<SS,WW>& x) : m_value(wrap(x.to_ranged())) {}
   sc_inline const ranged_type to_ranged() const
     { return ranged_type(m_value, traits_type::MINVAL, traits_type::RANGE); }


Add a visuals-quality property to BaconVideoWidget


Handle NEED_TIMEZONE, NEED_MYREALLOC

Handle NEED_TIMEZONE, NEED_MYREALLOC

--- misc/miscfn.h
+++ misc/miscfn.h
@@ -39,4 +39,15 @@
 char *realpath(const char *path, char resolved_path []);
 #endif

+#if NEED_TIMEZONE
+#include <sys/stdtypes.h>
+extern time_t timezone;
 #endif
+
+#if NEED_MYREALLOC
+#include <sys/stdtypes.h>
+#define realloc(ptr,size) myrealloc(ptr,size)
+extern void *myrealloc(void *, size_t);
+#endif
+
+#endif


virtual: Don't show mailboxes as \Noselect.

--- src/plugins/virtual/virtual-storage.c
+++ src/plugins/virtual/virtual-storage.c
@@ -523,7 +523,7 @@
 	if ((*flags & MAILBOX_NOSELECT) == 0) {
 		/* make sure it's a selectable mailbox */
 		maildir_path = t_strconcat(path, "/"VIRTUAL_CONFIG_FNAME, NULL);
-		if (stat(maildir_path, &st) < 0 || !S_ISDIR(st.st_mode))
+		if (stat(maildir_path, &st) < 0)
 			*flags |= MAILBOX_NOSELECT;
 	}
 	return ret;


rts: Fix memory leak when loading ELF objects

Issue discovered by Coverity Scan, CID 43168.

Signed-off-by: Austin Seipp <7ea35d812706d9213868749011af1ed4fa2f6aa0@well-typed.com>
(cherry picked from commit b7278d3d7bbe384eee7538b1e50bb741e99fb01d)

--- rts/Linker.c
+++ rts/Linker.c
@@ -1878,6 +1878,7 @@
             // success -- try to dlopen the first named file
             IF_DEBUG(linker, debugBelch("match%s\n",""));
             line[match[2].rm_eo] = '\0';
+            stgFree((void*)errmsg); // Free old message before creating new one
             errmsg = internal_dlopen(line+match[2].rm_so);
             break;
          }


Fix code style

Fix code style

--- src/OVAL/probes/unix/linux/systemdunitdependency_probe.c
+++ src/OVAL/probes/unix/linux/systemdunitdependency_probe.c
@@ -155,8 +155,9 @@
 	if (values_s) {
 		char **values = oscap_split(values_s, ", ");
 		for (int i = 0; values[i] != NULL; ++i) {
-			if (oscap_strcmp(values[i], "") == 0)
+			if (oscap_strcmp(values[i], "") == 0) {
 				continue;
+			}

 			if (add_unit_dependency(values[i], item, visited_units) == 0) {
 				get_all_dependencies_by_unit(conn, values[i], item, visited_units);


Fixed error checking at the end of fusion_read_loop().

--- src/core/fusion/fusion.c
+++ src/core/fusion/fusion.c
@@ -223,10 +223,7 @@
           }
      }

-     if (len < 0)
-          FPERROR( "reading from fusion device failed\n" );
-     else
-          FERROR( "read zero bytes from fusion device\n" );
+     FPERROR( "reading from fusion device failed\n" );

      return NULL;
 }


Fix motion detection on start up

Fix motion detection on start up

--- host_applications/linux/apps/raspicam/RaspiMJPEG.c
+++ host_applications/linux/apps/raspicam/RaspiMJPEG.c
@@ -246,14 +246,29 @@
    // run
    //
    if(cfg_val[c_autostart]) {
-      if(cfg_stru[c_control_file] != 0) printLog("MJPEG streaming, ready to receive commands\n");
-      else printLog("MJPEG streaming\n");
+      if(cfg_stru[c_control_file] != 0){
+         printLog("MJPEG streaming, ready to receive commands\n");
+         //kick off motion detection at start if required.
+         if(cfg_val[c_motion_detection] && cfg_val[c_motion_external]) {
+            char *cmd_temp;
+            asprintf(&cmd_temp, "%s", "md 0");
+            process_cmd(cmd_temp, 4);
+            sleep(1);
+            cmd_temp[3] = '1';
+            process_cmd(cmd_temp, 4);
+            free(cmd_temp);
+         }
+      } else {
+         printLog("MJPEG streaming\n");
+      }
    }
    else {
       if(cfg_stru[c_control_file] != 0) printLog("MJPEG idle, ready to receive commands\n");
       else printLog("MJPEG idle\n");
    }

+   updateStatus();
+
    struct sigaction action;
    memset(&action, 0, sizeof(struct sigaction));
    action.sa_handler = term;


Use sc_pkcs15_find_pin_by_auth_id() in asepcos_create_key() to correctly set the newly created key up for use with the configured PIN.

--- src/pkcs15init/pkcs15-asepcos.c
+++ src/pkcs15init/pkcs15-asepcos.c
@@ -577,12 +577,20 @@
 	                   kinfo->path.value[kinfo->path.len-1];

 	if (obj->auth_id.len != 0) {
-		/* the key is proctected by a PIN */
-		/* XXX use the pkcs15 structures for this */
+		/* the key is protected by a PIN */
+		sc_pkcs15_object_t *pin;
+		struct sc_pkcs15_auth_info *auth_info;
 		sc_cardctl_asepcos_akn2fileid_t st;

-		st.akn = sc_pkcs15init_get_pin_reference(p15card, profile,
-			                        SC_AC_SYMBOLIC, SC_PKCS15INIT_USER_PIN);
+		r = sc_pkcs15_find_pin_by_auth_id(p15card, &obj->auth_id, &pin);
+		if (r != SC_SUCCESS) {
+			sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "unable to determine reference for the PIN");
+			return r;
+		}
+
+		auth_info = (struct sc_pkcs15_auth_info *)pin->data;
+
+		st.akn = auth_info->attrs.pin.reference;
 		r = sc_card_ctl(p15card->card, SC_CARDCTL_ASEPCOS_AKN2FILEID, &st);
 		if (r != SC_SUCCESS) {
 			sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "unable to determine file id of the PIN");


Added Matrix4::transposed method

Added Matrix4::transposed method

--- math/Matrix4.h
+++ math/Matrix4.h
@@ -68,6 +68,9 @@

         //! Calculate the inverse matrix.
         Matrix4         inversed( void ) const;
+
+		//! Calculate the transpose matrix.
+		Matrix4			transposed( void ) const;

 		//! Sets the matrix row by index.
 		void			setRow( int index, const Vec4& value );
@@ -290,6 +293,18 @@
         return result;
 	}

+	// ** Matrix4::transposed
+	inline Matrix4 Matrix4::transposed( void ) const
+	{
+		Matrix4 result;
+
+		for( s32 i = 0; i < 4; i++ ) {
+			result.setRow( i, column( i ) );
+		}
+
+		return result;
+	}
+
 	// ** Matrix4::row
 	inline Vec4 Matrix4::row( int index ) const
 	{


fix "proxy has expired" error message

--- gsi/credential/source/library/globus_gsi_credential.c
+++ gsi/credential/source/library/globus_gsi_credential.c
@@ -281,10 +281,10 @@
                     results[result_index],
                     GLOBUS_GSI_CRED_ERROR_WITH_CRED,
                     ("The proxy credential: %s\n      with subject: %s\n"
-                     "      has expired %d minutes ago.\n",
+                     "      expired %d minutes ago.\n",
                      proxy,
                      subject,
-                     (-lifetime)));
+                     (-lifetime)/60));

                 free(subject);
                 goto exit;


isl_scan.c: scan_0D: add memory management annotation

Signed-off-by: Sven Verdoolaege <e5350bbed4977f5eb8ae1dc6abd9ae59d21ace75@kotnet.org>

--- isl_scan.c
+++ isl_scan.c
@@ -65,7 +65,7 @@
 	return callback->add(callback, sample);
 }

-static int scan_0D(struct isl_basic_set *bset,
+static int scan_0D(__isl_take isl_basic_set *bset,
 	struct isl_scan_callback *callback)
 {
 	struct isl_vec *sample;


[SIGAR-19] Change cpu time units to milliseconds

--- src/os/darwin/darwin_sigar.c
+++ src/os/darwin/darwin_sigar.c
@@ -206,6 +206,8 @@
     (*sigar)->pagesize = getpagesize();
 #ifdef __FreeBSD__
     (*sigar)->ticks = 100; /* sysconf(_SC_CLK_TCK) == 128 !? */
+#else
+    (*sigar)->ticks = sysconf(_SC_CLK_TCK);
 #endif
     (*sigar)->last_pid = -1;

@@ -486,10 +488,10 @@
         return errno;
     }

-    cpu->user = cpuload.cpu_ticks[CPU_STATE_USER];
-    cpu->sys  = cpuload.cpu_ticks[CPU_STATE_SYSTEM];
-    cpu->idle = cpuload.cpu_ticks[CPU_STATE_IDLE];
-    cpu->nice = cpuload.cpu_ticks[CPU_STATE_NICE];
+    cpu->user = SIGAR_TICK2MSEC(cpuload.cpu_ticks[CPU_STATE_USER]);
+    cpu->sys  = SIGAR_TICK2MSEC(cpuload.cpu_ticks[CPU_STATE_SYSTEM]);
+    cpu->idle = SIGAR_TICK2MSEC(cpuload.cpu_ticks[CPU_STATE_IDLE]);
+    cpu->nice = SIGAR_TICK2MSEC(cpuload.cpu_ticks[CPU_STATE_NICE]);
     cpu->wait = 0; /*N/A*/
     cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle;

@@ -511,10 +513,10 @@
         return status;
     }

-    cpu->user = SIGAR_TICK2SEC(cp_time[CP_USER]);
-    cpu->nice = SIGAR_TICK2SEC(cp_time[CP_NICE]);
-    cpu->sys  = SIGAR_TICK2SEC(cp_time[CP_SYS] + cp_time[CP_INTR]);
-    cpu->idle = SIGAR_TICK2SEC(cp_time[CP_IDLE]);
+    cpu->user = SIGAR_TICK2MSEC(cp_time[CP_USER]);
+    cpu->nice = SIGAR_TICK2MSEC(cp_time[CP_NICE]);
+    cpu->sys  = SIGAR_TICK2MSEC(cp_time[CP_SYS] + cp_time[CP_INTR]);
+    cpu->idle = SIGAR_TICK2MSEC(cp_time[CP_IDLE]);
     cpu->wait = 0; /*N/A*/
     cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle;
 #endif
@@ -549,10 +551,10 @@

         cpu = &cpulist->data[cpulist->number++];

-        cpu->user = cpuload[i].cpu_ticks[CPU_STATE_USER];
-        cpu->sys  = cpuload[i].cpu_ticks[CPU_STATE_SYSTEM];
-        cpu->idle = cpuload[i].cpu_ticks[CPU_STATE_IDLE];
-        cpu->nice = cpuload[i].cpu_ticks[CPU_STATE_NICE];
+        cpu->user = SIGAR_TICK2MSEC(cpuload[i].cpu_ticks[CPU_STATE_USER]);
+        cpu->sys  = SIGAR_TICK2MSEC(cpuload[i].cpu_ticks[CPU_STATE_SYSTEM]);
+        cpu->idle = SIGAR_TICK2MSEC(cpuload[i].cpu_ticks[CPU_STATE_IDLE]);
+        cpu->nice = SIGAR_TICK2MSEC(cpuload[i].cpu_ticks[CPU_STATE_NICE]);
         cpu->wait = 0; /*N/A*/
         cpu->total = cpu->user + cpu->nice + cpu->sys + cpu->idle;
     }
@@ -786,6 +788,9 @@

     return SIGAR_OK;
 }
+
+#define tv2msec(tv) \
+   (((sigar_uint64_t)tv.tv_sec * SIGAR_MSEC) + (((sigar_uint64_t)tv.tv_usec) / 1000))

 #ifdef DARWIN
 #define tval2msec(tval) \
@@ -836,9 +841,6 @@

     return SIGAR_OK;
 }
-#else
-#define tv2msec(tv) \
-   (((sigar_uint64_t)tv.tv_sec * SIGAR_MSEC) + (((sigar_uint64_t)tv.tv_usec) / 1000))
 #endif

 int sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid,


Decrease indentation

Decrease indentation

--- extension/boolexpr/binary.c
+++ extension/boolexpr/binary.c
@@ -22,89 +22,84 @@
 static struct BoolExpr *
 _commutative_binify(struct BoolExpr *op)
 {
-    if (op->data.xs->length == 2) {
+    if (op->data.xs->length == 2)
         return BoolExpr_IncRef(op);
+
+    size_t mid = op->data.xs->length / 2;
+    size_t n0 = mid;
+    size_t n1 = op->data.xs->length - mid;
+    struct BoolExpr **items0 = op->data.xs->items;
+    struct BoolExpr **items1 = op->data.xs->items + mid;
+    struct BoolExpr *xs[2];
+    struct BoolExpr *temp;
+    struct BoolExpr *y;
+
+    if (n0 == 1) {
+        xs[0] = BoolExpr_IncRef(items0[0]);
     }
     else {
-        size_t mid = op->data.xs->length / 2;
-        size_t n0 = mid;
-        size_t n1 = op->data.xs->length - mid;
-        struct BoolExpr **items0 = op->data.xs->items;
-        struct BoolExpr **items1 = op->data.xs->items + mid;
-        struct BoolExpr *xs[2];
-        struct BoolExpr *temp;
-        struct BoolExpr *y;
+        CHECK_NULL(temp, _op_new(op->kind, n0, items0));
+        CHECK_NULL_1(xs[0], _commutative_binify(temp), temp);
+        BoolExpr_DecRef(temp);
+    }

-        if (n0 == 1) {
-            xs[0] = BoolExpr_IncRef(items0[0]);
-        }
-        else {
-            CHECK_NULL(temp, _op_new(op->kind, n0, items0));
-            CHECK_NULL_1(xs[0], _commutative_binify(temp), temp);
-            BoolExpr_DecRef(temp);
-        }
+    CHECK_NULL_1(temp, _op_new(op->kind, n1, items1), xs[0]);
+    CHECK_NULL_2(xs[1], _commutative_binify(temp), xs[0], temp);
+    BoolExpr_DecRef(temp);

-        CHECK_NULL_1(temp, _op_new(op->kind, n1, items1), xs[0]);
-        CHECK_NULL_2(xs[1], _commutative_binify(temp), xs[0], temp);
-        BoolExpr_DecRef(temp);
+    CHECK_NULL_2(y, _op_new(op->kind, 2, xs), xs[0], xs[1]);
+    BoolExpr_DecRef(xs[0]);
+    BoolExpr_DecRef(xs[1]);

-        CHECK_NULL_2(y, _op_new(op->kind, 2, xs), xs[0], xs[1]);
-        BoolExpr_DecRef(xs[0]);
-        BoolExpr_DecRef(xs[1]);
-
-        return y;
-    }
+    return y;
 }

 static struct BoolExpr *
 _eq_binify(struct BoolExpr *op)
 {
-    if (op->data.xs->length == 2) {
+    if (op->data.xs->length == 2)
         return BoolExpr_IncRef(op);
-    }
-    else {
-        size_t length;
-        struct BoolExpr **xs;
-        struct BoolExpr *temp;
-        struct BoolExpr *y;

-        length = (op->data.xs->length * (op->data.xs->length - 1)) >> 1;
-        xs = (struct BoolExpr **) malloc(length * sizeof(struct BoolExpr *));
+    size_t length;
+    struct BoolExpr **xs;
+    struct BoolExpr *temp;
+    struct BoolExpr *y;

-        for (size_t i = 0, index = 0; i < (op->data.xs->length - 1); ++i) {
-            for (size_t j = i+1; j < op->data.xs->length; ++j, ++index) {
-                xs[index] = EqualN(2, op->data.xs->items[i],
-                                      op->data.xs->items[j]);
-                if (xs[index] == NULL) {
-                    /* LCOV_EXCL_START */
-                    for (size_t k = 0; k < index; ++k)
-                        BoolExpr_DecRef(xs[k]);
-                    free(xs);
-                    return NULL;
-                    /* LCOV_EXCL_STOP */
-                }
+    length = (op->data.xs->length * (op->data.xs->length - 1)) >> 1;
+    xs = (struct BoolExpr **) malloc(length * sizeof(struct BoolExpr *));
+
+    for (size_t i = 0, index = 0; i < (op->data.xs->length - 1); ++i) {
+        for (size_t j = i+1; j < op->data.xs->length; ++j, ++index) {
+            xs[index] = EqualN(2, op->data.xs->items[i], op->data.xs->items[j]);
+            if (xs[index] == NULL) {
+                /* LCOV_EXCL_START */
+                for (size_t k = 0; k < index; ++k)
+                    BoolExpr_DecRef(xs[k]);
+                free(xs);
+                return NULL;
+                /* LCOV_EXCL_STOP */
             }
         }
+    }

-        temp = And(length, xs);
-        if (temp == NULL) {
-            /* LCOV_EXCL_START */
-            for (size_t i = 0; i < length; ++i)
-                BoolExpr_DecRef(xs[i]);
-            free(xs);
-            /* LCOV_EXCL_STOP */
-        }
-
+    temp = And(length, xs);
+    if (temp == NULL) {
+        /* LCOV_EXCL_START */
         for (size_t i = 0; i < length; ++i)
             BoolExpr_DecRef(xs[i]);
         free(xs);
+        /* LCOV_EXCL_STOP */
+    }

-        CHECK_NULL_1(y, _commutative_binify(temp), temp);
-        BoolExpr_DecRef(temp);
+    for (size_t i = 0; i < length; ++i)
+        BoolExpr_DecRef(xs[i]);
+    free(xs);

-        return y;
-    }
+    CHECK_NULL_1(y, _commutative_binify(temp), temp);
+    BoolExpr_DecRef(temp);
+
+    return y;
 }

@@ -134,18 +129,16 @@
 struct BoolExpr *
 BoolExpr_ToBinary(struct BoolExpr *ex)
 {
-    if (IS_ATOM(ex)) {
+    if (IS_ATOM(ex))
         return BoolExpr_IncRef(ex);
-    }
-    else {
-        struct BoolExpr *temp;
-        struct BoolExpr *y;

-        CHECK_NULL(temp, _op_transform(ex, BoolExpr_ToBinary));
-        CHECK_NULL_1(y, _op_binify[temp->kind](temp), temp);
-        BoolExpr_DecRef(temp);
+    struct BoolExpr *temp;
+    struct BoolExpr *y;

-        return y;
-    }
+    CHECK_NULL(temp, _op_transform(ex, BoolExpr_ToBinary));
+    CHECK_NULL_1(y, _op_binify[temp->kind](temp), temp);
+    BoolExpr_DecRef(temp);
+
+    return y;
 }


Disable printf in crash reporting for release builds

--- platform/mbed_error.c
+++ platform/mbed_error.c
@@ -211,7 +211,9 @@
         if ((report_error_ctx->crc_error_ctx == crc_val) && (report_error_ctx->is_error_processed == 0)) {
             is_reboot_error_valid = true;
             //Report the error info
+#ifndef NDEBUG
             printf("\n== The system has been rebooted due to a fatal error. ==\n");
+#endif

             //Call the mbed_error_reboot_callback, this enables applications to do some handling before we do the handling
             mbed_error_reboot_callback(report_error_ctx);
@@ -223,7 +225,9 @@
 #if MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED
                 if (report_error_ctx->error_reboot_count >= MBED_CONF_PLATFORM_ERROR_REBOOT_MAX) {
                     //We have rebooted more than enough, hold the system here.
+#ifndef NDEBUG
                     printf("\n== Reboot count(=%ld) exceeded maximum, system halting ==\n", report_error_ctx->error_reboot_count);
+#endif
                     mbed_halt_system();
                 }
 #endif


lib-storage: Avoid assert-crashing with non-mUTF7/UTF8 entries in subscriptions file.

--- src/lib-storage/list/mailbox-list-subscriptions.c
+++ src/lib-storage/list/mailbox-list-subscriptions.c
@@ -3,6 +3,7 @@
 #include "lib.h"
 #include "ioloop.h"
 #include "array.h"
+#include "unichar.h"
 #include "imap-match.h"
 #include "subscription-file.h"
 #include "mailbox-tree.h"
@@ -92,6 +93,8 @@
 		return -1;
 	} else {
 		vname = mailbox_list_get_vname(list, name);
+		if (!uni_utf8_str_is_valid(vname))
+			return -1;
 		node = mailbox_tree_get(list->subscriptions, vname, &created);
 		node->flags = MAILBOX_SUBSCRIBED;
 	}


Update mlib.h

Update mlib.h

Added the keyboard functions.

--- include/mlib.h
+++ include/mlib.h
@@ -29,6 +29,8 @@
 short get_file_size(char* filename);

 // Define the keyboard functions.
+short wait_for_key(void);
+short check_for_key(void);

 // Define the screen functions.
 void print_string(char* string);


Define groupings as constant

Define groupings as constant

--- compiler/generator_csharp.c
+++ compiler/generator_csharp.c
@@ -1228,7 +1228,7 @@

     g->V[0] = q->name;

-    w(g, "~Mprivate static string ~V0 = ");
+    w(g, "~Mprivate const string ~V0 = ");
     write_literal_string(g, b);
     w(g, ";~N");
 }


revert toolchain changes

revert toolchain changes

--- platform/mbed_toolchain.h
+++ platform/mbed_toolchain.h
@@ -277,7 +277,7 @@
 #if defined(__CC_ARM)
 #define MBED_DEPRECATED(M) __attribute__((deprecated))
 #elif defined(__GNUC__) || defined(__clang__)
-#define MBED_DEPRECATED(M)
+#define MBED_DEPRECATED(M) __attribute__((deprecated(M)))
 #else
 #define MBED_DEPRECATED(M)
 #endif


Improved summary output string generation

--- C/mandelbrot.c
+++ C/mandelbrot.c
@@ -322,9 +322,14 @@
     return d;
 }

-void print_durations(const double *values, int num_values)
+char *durations2string(const double *values, int num_values)
 {
     double *sorted_values;
+    char *buf;
+    char tmp[32];
+    int buf_len = 256;
+    int tmp_len;
+    int pos;

     if (!(sorted_values = malloc(num_values * sizeof(double))))
         die(ERROR_ALLOC_MEMORY);
@@ -332,14 +337,31 @@
     memcpy(sorted_values, values, num_values * sizeof(double));
     qsort(sorted_values, num_values, sizeof(double), cmp_doubles_func);

-    printf("[");
-
-    for (int i = 0; i < num_values; ++i)
-        printf("%s%f", (i > 0) ? ", " : "", sorted_values[i]);
-
-    printf("]");
-
+    if (!(buf = malloc(buf_len * sizeof(char))))
+        die(ERROR_ALLOC_MEMORY);
+
+    sprintf(buf, "[");
+    pos = strlen(buf);
+
+    for (int i = 0; i < num_values; ++i) {
+        sprintf(tmp, "%s%f", (i > 0) ? ", " : "", sorted_values[i]);
+        tmp_len = strlen(tmp);
+
+        if ((pos + tmp_len + 1) > buf_len) {
+            buf_len += 256;
+
+            if (!(buf = realloc(buf, buf_len)))
+                die(ERROR_ALLOC_MEMORY);
+        }
+
+        memcpy(buf + pos, tmp, tmp_len + 1);
+        pos += tmp_len;
+    }
+
+    sprintf(buf + pos, "]");
     free(sorted_values);
+
+    return buf;
 }

 void show_summary(const double *durations, int repetitions)
@@ -347,9 +369,9 @@
     if (repetitions == 1) {
         printf("%f s\n", durations[0]);
     } else {
-        printf("mean: %f s, median: %f s (repetitions=%d) ", mean(durations, repetitions), median(durations, repetitions), repetitions);
-        print_durations(durations, repetitions);
-        printf("\n");
+        char *s = durations2string(durations, repetitions);
+        printf("mean: %f s, median: %f s (repetitions=%d) %s\n", mean(durations, repetitions), median(durations, repetitions), repetitions, s);
+        free(s);
     }
 }


Always unset delay on about: pages

Always unset delay on about: pages

These pages are not affected by delay but going to
a different page will honor the still set delay.

--- midori/midori-view.c
+++ midori/midori-view.c
@@ -3849,6 +3849,7 @@

             katze_assign (view->uri, NULL);
             katze_assign (view->mime_type, g_strdup ("text/html"));
+            katze_item_set_meta_integer (view->item, "delay", -1);

             if (speeddial_markup == NULL)
                 speeddial_markup = prepare_speed_dial_html (view, TRUE);
@@ -4007,6 +4008,7 @@
             webkit_web_view_load_html_string (
                 WEBKIT_WEB_VIEW (view->web_view), data, view->uri);
             g_free (data);
+            katze_item_set_meta_integer (view->item, "delay", -1);
             if (g_strcmp0 (view->item->uri, view->uri))
                 katze_item_set_uri (view->item, view->uri);
             g_object_notify (G_OBJECT (view), "uri");


ixgbe: Fix up some ethtool results when adapter is removed

Some ethtool tests returned apparently good results when the
adapter was in a removed state. Fix that by checking for removal.
This also fixes two paths that could return uninitialized memory
in data[4].

Signed-off-by: Mark Rustad <54e60e0b3ed6972c60d10aba14475cde8644c703@intel.com>
Tested-by: Phil Schmitt <e59a1cb13110d2d5848864a809262db69840c26d@intel.com>
Signed-off-by: Aaron Brown <4723df1d9a4136f7b76e1bf6434e33afc91d2139@intel.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -1,7 +1,7 @@
 /*******************************************************************************

   Intel 10 Gigabit PCI Express Linux driver
-  Copyright(c) 1999 - 2013 Intel Corporation.
+  Copyright(c) 1999 - 2014 Intel Corporation.

   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
@@ -1247,6 +1247,11 @@
 	struct ixgbe_hw *hw = &adapter->hw;
 	bool link_up;
 	u32 link_speed = 0;
+
+	if (ixgbe_removed(hw->hw_addr)) {
+		*data = 1;
+		return 1;
+	}
 	*data = 0;

 	hw->mac.ops.check_link(hw, &link_speed, &link_up, true);
@@ -1969,6 +1974,7 @@
 		data[1] = 1;
 		data[2] = 1;
 		data[3] = 1;
+		data[4] = 1;
 		eth_test->flags |= ETH_TEST_FL_FAILED;
 		return;
 	}
@@ -1988,6 +1994,7 @@
 					data[1] = 1;
 					data[2] = 1;
 					data[3] = 1;
+					data[4] = 1;
 					eth_test->flags |= ETH_TEST_FL_FAILED;
 					clear_bit(__IXGBE_TESTING,
 						  &adapter->state);


rename sc_int_ranged_si to sc_int_rsi etc

--- systemc-utils/bca-subset/src/sysc/datatypes/int/sc_int.h
+++ systemc-utils/bca-subset/src/sysc/datatypes/int/sc_int.h
@@ -284,10 +284,10 @@
 };

 template <typename S, bool WIDE> struct sc_int_ranged;
-typedef sc_int_ranged<  signed,false>  sc_int_ranged_si;
-typedef sc_int_ranged<unsigned,false>  sc_int_ranged_ui;
-typedef sc_int_ranged<  signed,true >  sc_int_ranged_sl;
-typedef sc_int_ranged<unsigned,true >  sc_int_ranged_ul;
+typedef sc_int_ranged<  signed,false>  sc_int_rsi; // ranged signed integer
+typedef sc_int_ranged<unsigned,false>  sc_int_rui; // ranged unsigned integer
+typedef sc_int_ranged<  signed,true >  sc_int_rsl; // ranged signed long long
+typedef sc_int_ranged<unsigned,true >  sc_int_rul; // ranged unsigned long long

 template <> struct sc_int_ranged<signed,false> : public sc_int_ranged_body<signed,false> {
   typedef sc_int_ranged_body<signed,false> base_type;
@@ -306,7 +306,7 @@
   typedef base_type::uvalue_type uvalue_type;
   sc_int_ranged(uvalue_type val, uvalue_type minval, uvalue_type range) : base_type(val, minval, range) {}
   explicit sc_int_ranged(unsigned int x)   : base_type(x, 0u, 0xffffffffu) {}
-  explicit sc_int_ranged(const sc_int_ranged_si& x) : base_type(x.m_uval, x.m_minval, x.m_range) {}
+  explicit sc_int_ranged(const sc_int_rsi& x) : base_type(x.m_uval, x.m_minval, x.m_range) {}
 };

 template <> struct sc_int_ranged<signed,true> : public sc_int_ranged_body<signed,true> {
@@ -314,11 +314,11 @@
   typedef base_type::uvalue_type uvalue_type;
   sc_int_ranged(uvalue_type val, uvalue_type minval, uvalue_type range) : base_type(val, minval, range) {}
   explicit sc_int_ranged(signed long long x) : base_type(x, 0x8000000000000000ull, 0xffffffffffffffffull) {}
-  explicit sc_int_ranged(const sc_int_ranged_si& x)
+  explicit sc_int_ranged(const sc_int_rsi& x)
     : base_type(static_cast<int>(x.m_uval),
 		x.unsigned_range() ? static_cast<int>(0x80000000u) : static_cast<int>(x.m_minval),
 		x.unsigned_range() ? 0xffffffffu : x.m_range) {}
-  explicit sc_int_ranged(const sc_int_ranged_ui& x)
+  explicit sc_int_ranged(const sc_int_rui& x)
     : base_type(x.m_uval, x.signed_range() ? 0 : x.m_minval, x.signed_range() ? 0xffffffffu : x.m_range) {}
 };

@@ -327,13 +327,13 @@
   typedef base_type::uvalue_type uvalue_type;
   sc_int_ranged(uvalue_type val, uvalue_type minval, uvalue_type range) : base_type(val, minval, range) {}
   explicit sc_int_ranged(unsigned long long x) : base_type(x, 0, 0xfffffffffffffffful) {}
-  explicit sc_int_ranged(const sc_int_ranged_si& x)
+  explicit sc_int_ranged(const sc_int_rsi& x)
     : base_type(static_cast<int>(x.m_uval),
 		x.unsigned_range() ? static_cast<int>(0x80000000u) : static_cast<int>(x.m_minval),
 		x.unsigned_range() ? 0xffffffffu : x.m_range) {}
-  explicit sc_int_ranged(const sc_int_ranged_ui& x)
+  explicit sc_int_ranged(const sc_int_rui& x)
     : base_type(x.m_uval, x.signed_range() ? 0 : x.m_minval, x.signed_range() ? 0xffffffffu : x.m_range) {}
-  explicit sc_int_ranged(const sc_int_ranged_sl& x) : base_type(x.m_uval, x.m_minval, x.m_range) {}
+  explicit sc_int_ranged(const sc_int_rsl& x) : base_type(x.m_uval, x.m_minval, x.m_range) {}
 };

 template <typename S, bool WIDE>
@@ -350,128 +350,116 @@
   return sc_int_ranged<S,WIDE>(val, minval, range);
 }

-inline const sc_int_ranged_ui operator+(const sc_int_ranged_si& a, const sc_int_ranged_ui& b)
-  { return static_cast<sc_int_ranged_ui>(a) + b; }
-inline const sc_int_ranged_sl operator+(const sc_int_ranged_si& a, const sc_int_ranged_sl& b)
-  { return static_cast<sc_int_ranged_sl>(a) + b; }
-inline const sc_int_ranged_sl operator+(const sc_int_ranged_ui& a, const sc_int_ranged_sl& b)
-  { return static_cast<sc_int_ranged_sl>(a) + b; }
-inline const sc_int_ranged_ul operator+(const sc_int_ranged_si& a, const sc_int_ranged_ul& b)
-  { return static_cast<sc_int_ranged_ul>(a) + b; }
-inline const sc_int_ranged_ul operator+(const sc_int_ranged_ui& a, const sc_int_ranged_ul& b)
-  { return static_cast<sc_int_ranged_ul>(a) + b; }
-inline const sc_int_ranged_ul operator+(const sc_int_ranged_sl& a, const sc_int_ranged_ul& b)
-  { return static_cast<sc_int_ranged_ul>(a) + b; }
-inline const sc_int_ranged_ui operator+(const sc_int_ranged_ui& a, const sc_int_ranged_si& b)
-  { return a + static_cast<sc_int_ranged_ui>(b); }
-inline const sc_int_ranged_sl operator+(const sc_int_ranged_sl& a, const sc_int_ranged_si& b)
-  { return a + static_cast<sc_int_ranged_sl>(b); }
-inline const sc_int_ranged_sl operator+(const sc_int_ranged_sl& a, const sc_int_ranged_ui& b)
-  { return a + static_cast<sc_int_ranged_sl>(b); }
-inline const sc_int_ranged_ul operator+(const sc_int_ranged_ul& a, const sc_int_ranged_si& b)
-  { return a + static_cast<sc_int_ranged_ul>(b); }
-inline const sc_int_ranged_ul operator+(const sc_int_ranged_ul& a, const sc_int_ranged_ui& b)
-  { return a + static_cast<sc_int_ranged_ul>(b); }
-inline const sc_int_ranged_ul operator+(const sc_int_ranged_ul& a, const sc_int_ranged_sl& b)
-  { return a + static_cast<sc_int_ranged_ul>(b); }
+inline const sc_int_rui operator+(const sc_int_rsi& a, const sc_int_rui& b) { return static_cast<sc_int_rui>(a) + b; }
+inline const sc_int_rsl operator+(const sc_int_rsi& a, const sc_int_rsl& b) { return static_cast<sc_int_rsl>(a) + b; }
+inline const sc_int_rsl operator+(const sc_int_rui& a, const sc_int_rsl& b) { return static_cast<sc_int_rsl>(a) + b; }
+inline const sc_int_rul operator+(const sc_int_rsi& a, const sc_int_rul& b) { return static_cast<sc_int_rul>(a) + b; }
+inline const sc_int_rul operator+(const sc_int_rui& a, const sc_int_rul& b) { return static_cast<sc_int_rul>(a) + b; }
+inline const sc_int_rul operator+(const sc_int_rsl& a, const sc_int_rul& b) { return static_cast<sc_int_rul>(a) + b; }
+inline const sc_int_rui operator+(const sc_int_rui& a, const sc_int_rsi& b) { return a + static_cast<sc_int_rui>(b); }
+inline const sc_int_rsl operator+(const sc_int_rsl& a, const sc_int_rsi& b) { return a + static_cast<sc_int_rsl>(b); }
+inline const sc_int_rsl operator+(const sc_int_rsl& a, const sc_int_rui& b) { return a + static_cast<sc_int_rsl>(b); }
+inline const sc_int_rul operator+(const sc_int_rul& a, const sc_int_rsi& b) { return a + static_cast<sc_int_rul>(b); }
+inline const sc_int_rul operator+(const sc_int_rul& a, const sc_int_rui& b) { return a + static_cast<sc_int_rul>(b); }
+inline const sc_int_rul operator+(const sc_int_rul& a, const sc_int_rsl& b) { return a + static_cast<sc_int_rul>(b); }

 template <typename L, typename R> struct sc_int_ranged_binop_traits;
-template <> struct sc_int_ranged_binop_traits<sc_int_ranged_si,sc_int_ranged_si> { typedef sc_int_ranged_si result_type; };
-template <> struct sc_int_ranged_binop_traits<sc_int_ranged_si,sc_int_ranged_ui> { typedef sc_int_ranged_ui result_type; };
-template <> struct sc_int_ranged_binop_traits<sc_int_ranged_si,sc_int_ranged_sl> { typedef sc_int_ranged_sl result_type; };
-template <> struct sc_int_ranged_binop_traits<sc_int_ranged_si,sc_int_ranged_ul> { typedef sc_int_ranged_ul result_type; };
-template <> struct sc_int_ranged_binop_traits<sc_int_ranged_ui,sc_int_ranged_si> { typedef sc_int_ranged_ui result_type; };
-template <> struct sc_int_ranged_binop_traits<sc_int_ranged_ui,sc_int_ranged_ui> { typedef sc_int_ranged_ui result_type; };
-template <> struct sc_int_ranged_binop_traits<sc_int_ranged_ui,sc_int_ranged_sl> { typedef sc_int_ranged_sl result_type; };
-template <> struct sc_int_ranged_binop_traits<sc_int_ranged_ui,sc_int_ranged_ul> { typedef sc_int_ranged_ul result_type; };
-template <> struct sc_int_ranged_binop_traits<sc_int_ranged_sl,sc_int_ranged_si> { typedef sc_int_ranged_sl result_type; };
-template <> struct sc_int_ranged_binop_traits<sc_int_ranged_sl,sc_int_ranged_ui> { typedef sc_int_ranged_sl result_type; };
-template <> struct sc_int_ranged_binop_traits<sc_int_ranged_sl,sc_int_ranged_sl> { typedef sc_int_ranged_sl result_type; };
-template <> struct sc_int_ranged_binop_traits<sc_int_ranged_sl,sc_int_ranged_ul> { typedef sc_int_ranged_ul result_type; };
-template <> struct sc_int_ranged_binop_traits<sc_int_ranged_ul,sc_int_ranged_si> { typedef sc_int_ranged_ul result_type; };
-template <> struct sc_int_ranged_binop_traits<sc_int_ranged_ul,sc_int_ranged_ui> { typedef sc_int_ranged_ul result_type; };
-template <> struct sc_int_ranged_binop_traits<sc_int_ranged_ul,sc_int_ranged_sl> { typedef sc_int_ranged_ul result_type; };
-template <> struct sc_int_ranged_binop_traits<sc_int_ranged_ul,sc_int_ranged_ul> { typedef sc_int_ranged_ul result_type; };
-
-inline const sc_int_ranged_si operator+(const sc_int_ranged_si& a, bool               b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_si operator+(const sc_int_ranged_si& a, signed char        b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_si operator+(const sc_int_ranged_si& a, unsigned char      b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_si operator+(const sc_int_ranged_si& a, signed short       b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_si operator+(const sc_int_ranged_si& a, unsigned short     b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_si operator+(const sc_int_ranged_si& a, signed int         b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_ui operator+(const sc_int_ranged_si& a, unsigned int       b) { return a + sc_int_ranged_ui(b); }
-inline const sc_int_ranged_sl operator+(const sc_int_ranged_si& a, signed long long   b) { return a + sc_int_ranged_sl(b); }
-inline const sc_int_ranged_ul operator+(const sc_int_ranged_si& a, unsigned long long b) { return a + sc_int_ranged_ul(b); }
-
-inline const sc_int_ranged_ui operator+(const sc_int_ranged_ui& a, bool               b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_ui operator+(const sc_int_ranged_ui& a, signed char        b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_ui operator+(const sc_int_ranged_ui& a, unsigned char      b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_ui operator+(const sc_int_ranged_ui& a, signed short       b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_ui operator+(const sc_int_ranged_ui& a, unsigned short     b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_ui operator+(const sc_int_ranged_ui& a, signed int         b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_ui operator+(const sc_int_ranged_ui& a, unsigned int       b) { return a + sc_int_ranged_ui(b); }
-inline const sc_int_ranged_sl operator+(const sc_int_ranged_ui& a, signed long long   b) { return a + sc_int_ranged_sl(b); }
-inline const sc_int_ranged_ul operator+(const sc_int_ranged_ui& a, unsigned long long b) { return a + sc_int_ranged_ul(b); }
-
-inline const sc_int_ranged_sl operator+(const sc_int_ranged_sl& a, bool               b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_sl operator+(const sc_int_ranged_sl& a, signed char        b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_sl operator+(const sc_int_ranged_sl& a, unsigned char      b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_sl operator+(const sc_int_ranged_sl& a, signed short       b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_sl operator+(const sc_int_ranged_sl& a, unsigned short     b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_sl operator+(const sc_int_ranged_sl& a, signed int         b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_sl operator+(const sc_int_ranged_sl& a, unsigned int       b) { return a + sc_int_ranged_ui(b); }
-inline const sc_int_ranged_sl operator+(const sc_int_ranged_sl& a, signed long long   b) { return a + sc_int_ranged_sl(b); }
-inline const sc_int_ranged_ul operator+(const sc_int_ranged_sl& a, unsigned long long b) { return a + sc_int_ranged_ul(b); }
-
-inline const sc_int_ranged_ul operator+(const sc_int_ranged_ul& a, bool               b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_ul operator+(const sc_int_ranged_ul& a, signed char        b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_ul operator+(const sc_int_ranged_ul& a, unsigned char      b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_ul operator+(const sc_int_ranged_ul& a, signed short       b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_ul operator+(const sc_int_ranged_ul& a, unsigned short     b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_ul operator+(const sc_int_ranged_ul& a, signed int         b) { return a + sc_int_ranged_si(b); }
-inline const sc_int_ranged_ul operator+(const sc_int_ranged_ul& a, unsigned int       b) { return a + sc_int_ranged_ui(b); }
-inline const sc_int_ranged_ul operator+(const sc_int_ranged_ul& a, signed long long   b) { return a + sc_int_ranged_sl(b); }
-inline const sc_int_ranged_ul operator+(const sc_int_ranged_ul& a, unsigned long long b) { return a + sc_int_ranged_ul(b); }
-
-inline const sc_int_ranged_si operator+(bool               a, const sc_int_ranged_si& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_si operator+(signed char        a, const sc_int_ranged_si& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_si operator+(unsigned char      a, const sc_int_ranged_si& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_si operator+(signed short       a, const sc_int_ranged_si& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_si operator+(unsigned short     a, const sc_int_ranged_si& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_si operator+(signed int         a, const sc_int_ranged_si& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_ui operator+(unsigned int       a, const sc_int_ranged_si& b) { return sc_int_ranged_ui(a) + b; }
-inline const sc_int_ranged_sl operator+(signed long long   a, const sc_int_ranged_si& b) { return sc_int_ranged_sl(a) + b; }
-inline const sc_int_ranged_ul operator+(unsigned long long a, const sc_int_ranged_si& b) { return sc_int_ranged_ul(a) + b; }
-
-inline const sc_int_ranged_ui operator+(bool               a, const sc_int_ranged_ui& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_ui operator+(signed char        a, const sc_int_ranged_ui& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_ui operator+(unsigned char      a, const sc_int_ranged_ui& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_ui operator+(signed short       a, const sc_int_ranged_ui& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_ui operator+(unsigned short     a, const sc_int_ranged_ui& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_ui operator+(signed int         a, const sc_int_ranged_ui& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_ui operator+(unsigned int       a, const sc_int_ranged_ui& b) { return sc_int_ranged_ui(a) + b; }
-inline const sc_int_ranged_sl operator+(signed long long   a, const sc_int_ranged_ui& b) { return sc_int_ranged_sl(a) + b; }
-inline const sc_int_ranged_ul operator+(unsigned long long a, const sc_int_ranged_ui& b) { return sc_int_ranged_ul(a) + b; }
-
-inline const sc_int_ranged_sl operator+(bool               a, const sc_int_ranged_sl& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_sl operator+(signed char        a, const sc_int_ranged_sl& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_sl operator+(unsigned char      a, const sc_int_ranged_sl& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_sl operator+(signed short       a, const sc_int_ranged_sl& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_sl operator+(unsigned short     a, const sc_int_ranged_sl& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_sl operator+(signed int         a, const sc_int_ranged_sl& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_sl operator+(unsigned int       a, const sc_int_ranged_sl& b) { return sc_int_ranged_ui(a) + b; }
-inline const sc_int_ranged_sl operator+(signed long long   a, const sc_int_ranged_sl& b) { return sc_int_ranged_sl(a) + b; }
-inline const sc_int_ranged_ul operator+(unsigned long long a, const sc_int_ranged_sl& b) { return sc_int_ranged_ul(a) + b; }
-
-inline const sc_int_ranged_ul operator+(bool               a, const sc_int_ranged_ul& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_ul operator+(signed char        a, const sc_int_ranged_ul& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_ul operator+(unsigned char      a, const sc_int_ranged_ul& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_ul operator+(signed short       a, const sc_int_ranged_ul& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_ul operator+(unsigned short     a, const sc_int_ranged_ul& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_ul operator+(signed int         a, const sc_int_ranged_ul& b) { return sc_int_ranged_si(a) + b; }
-inline const sc_int_ranged_ul operator+(unsigned int       a, const sc_int_ranged_ul& b) { return sc_int_ranged_ui(a) + b; }
-inline const sc_int_ranged_ul operator+(signed long long   a, const sc_int_ranged_ul& b) { return sc_int_ranged_sl(a) + b; }
-inline const sc_int_ranged_ul operator+(unsigned long long a, const sc_int_ranged_ul& b) { return sc_int_ranged_ul(a) + b; }
+template <> struct sc_int_ranged_binop_traits<sc_int_rsi,sc_int_rsi> { typedef sc_int_rsi result_type; };
+template <> struct sc_int_ranged_binop_traits<sc_int_rsi,sc_int_rui> { typedef sc_int_rui result_type; };
+template <> struct sc_int_ranged_binop_traits<sc_int_rsi,sc_int_rsl> { typedef sc_int_rsl result_type; };
+template <> struct sc_int_ranged_binop_traits<sc_int_rsi,sc_int_rul> { typedef sc_int_rul result_type; };
+template <> struct sc_int_ranged_binop_traits<sc_int_rui,sc_int_rsi> { typedef sc_int_rui result_type; };
+template <> struct sc_int_ranged_binop_traits<sc_int_rui,sc_int_rui> { typedef sc_int_rui result_type; };
+template <> struct sc_int_ranged_binop_traits<sc_int_rui,sc_int_rsl> { typedef sc_int_rsl result_type; };
+template <> struct sc_int_ranged_binop_traits<sc_int_rui,sc_int_rul> { typedef sc_int_rul result_type; };
+template <> struct sc_int_ranged_binop_traits<sc_int_rsl,sc_int_rsi> { typedef sc_int_rsl result_type; };
+template <> struct sc_int_ranged_binop_traits<sc_int_rsl,sc_int_rui> { typedef sc_int_rsl result_type; };
+template <> struct sc_int_ranged_binop_traits<sc_int_rsl,sc_int_rsl> { typedef sc_int_rsl result_type; };
+template <> struct sc_int_ranged_binop_traits<sc_int_rsl,sc_int_rul> { typedef sc_int_rul result_type; };
+template <> struct sc_int_ranged_binop_traits<sc_int_rul,sc_int_rsi> { typedef sc_int_rul result_type; };
+template <> struct sc_int_ranged_binop_traits<sc_int_rul,sc_int_rui> { typedef sc_int_rul result_type; };
+template <> struct sc_int_ranged_binop_traits<sc_int_rul,sc_int_rsl> { typedef sc_int_rul result_type; };
+template <> struct sc_int_ranged_binop_traits<sc_int_rul,sc_int_rul> { typedef sc_int_rul result_type; };
+
+inline const sc_int_rsi operator+(const sc_int_rsi& a, bool               b) { return a + sc_int_rsi(b); }
+inline const sc_int_rsi operator+(const sc_int_rsi& a, signed char        b) { return a + sc_int_rsi(b); }
+inline const sc_int_rsi operator+(const sc_int_rsi& a, unsigned char      b) { return a + sc_int_rsi(b); }
+inline const sc_int_rsi operator+(const sc_int_rsi& a, signed short       b) { return a + sc_int_rsi(b); }
+inline const sc_int_rsi operator+(const sc_int_rsi& a, unsigned short     b) { return a + sc_int_rsi(b); }
+inline const sc_int_rsi operator+(const sc_int_rsi& a, signed int         b) { return a + sc_int_rsi(b); }
+inline const sc_int_rui operator+(const sc_int_rsi& a, unsigned int       b) { return a + sc_int_rui(b); }
+inline const sc_int_rsl operator+(const sc_int_rsi& a, signed long long   b) { return a + sc_int_rsl(b); }
+inline const sc_int_rul operator+(const sc_int_rsi& a, unsigned long long b) { return a + sc_int_rul(b); }
+
+inline const sc_int_rui operator+(const sc_int_rui& a, bool               b) { return a + sc_int_rsi(b); }
+inline const sc_int_rui operator+(const sc_int_rui& a, signed char        b) { return a + sc_int_rsi(b); }
+inline const sc_int_rui operator+(const sc_int_rui& a, unsigned char      b) { return a + sc_int_rsi(b); }
+inline const sc_int_rui operator+(const sc_int_rui& a, signed short       b) { return a + sc_int_rsi(b); }
+inline const sc_int_rui operator+(const sc_int_rui& a, unsigned short     b) { return a + sc_int_rsi(b); }
+inline const sc_int_rui operator+(const sc_int_rui& a, signed int         b) { return a + sc_int_rsi(b); }
+inline const sc_int_rui operator+(const sc_int_rui& a, unsigned int       b) { return a + sc_int_rui(b); }
+inline const sc_int_rsl operator+(const sc_int_rui& a, signed long long   b) { return a + sc_int_rsl(b); }
+inline const sc_int_rul operator+(const sc_int_rui& a, unsigned long long b) { return a + sc_int_rul(b); }
+
+inline const sc_int_rsl operator+(const sc_int_rsl& a, bool               b) { return a + sc_int_rsi(b); }
+inline const sc_int_rsl operator+(const sc_int_rsl& a, signed char        b) { return a + sc_int_rsi(b); }
+inline const sc_int_rsl operator+(const sc_int_rsl& a, unsigned char      b) { return a + sc_int_rsi(b); }
+inline const sc_int_rsl operator+(const sc_int_rsl& a, signed short       b) { return a + sc_int_rsi(b); }
+inline const sc_int_rsl operator+(const sc_int_rsl& a, unsigned short     b) { return a + sc_int_rsi(b); }
+inline const sc_int_rsl operator+(const sc_int_rsl& a, signed int         b) { return a + sc_int_rsi(b); }
+inline const sc_int_rsl operator+(const sc_int_rsl& a, unsigned int       b) { return a + sc_int_rui(b); }
+inline const sc_int_rsl operator+(const sc_int_rsl& a, signed long long   b) { return a + sc_int_rsl(b); }
+inline const sc_int_rul operator+(const sc_int_rsl& a, unsigned long long b) { return a + sc_int_rul(b); }
+
+inline const sc_int_rul operator+(const sc_int_rul& a, bool               b) { return a + sc_int_rsi(b); }
+inline const sc_int_rul operator+(const sc_int_rul& a, signed char        b) { return a + sc_int_rsi(b); }
+inline const sc_int_rul operator+(const sc_int_rul& a, unsigned char      b) { return a + sc_int_rsi(b); }
+inline const sc_int_rul operator+(const sc_int_rul& a, signed short       b) { return a + sc_int_rsi(b); }
+inline const sc_int_rul operator+(const sc_int_rul& a, unsigned short     b) { return a + sc_int_rsi(b); }
+inline const sc_int_rul operator+(const sc_int_rul& a, signed int         b) { return a + sc_int_rsi(b); }
+inline const sc_int_rul operator+(const sc_int_rul& a, unsigned int       b) { return a + sc_int_rui(b); }
+inline const sc_int_rul operator+(const sc_int_rul& a, signed long long   b) { return a + sc_int_rsl(b); }
+inline const sc_int_rul operator+(const sc_int_rul& a, unsigned long long b) { return a + sc_int_rul(b); }
+
+inline const sc_int_rsi operator+(bool               a, const sc_int_rsi& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rsi operator+(signed char        a, const sc_int_rsi& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rsi operator+(unsigned char      a, const sc_int_rsi& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rsi operator+(signed short       a, const sc_int_rsi& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rsi operator+(unsigned short     a, const sc_int_rsi& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rsi operator+(signed int         a, const sc_int_rsi& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rui operator+(unsigned int       a, const sc_int_rsi& b) { return sc_int_rui(a) + b; }
+inline const sc_int_rsl operator+(signed long long   a, const sc_int_rsi& b) { return sc_int_rsl(a) + b; }
+inline const sc_int_rul operator+(unsigned long long a, const sc_int_rsi& b) { return sc_int_rul(a) + b; }
+
+inline const sc_int_rui operator+(bool               a, const sc_int_rui& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rui operator+(signed char        a, const sc_int_rui& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rui operator+(unsigned char      a, const sc_int_rui& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rui operator+(signed short       a, const sc_int_rui& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rui operator+(unsigned short     a, const sc_int_rui& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rui operator+(signed int         a, const sc_int_rui& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rui operator+(unsigned int       a, const sc_int_rui& b) { return sc_int_rui(a) + b; }
+inline const sc_int_rsl operator+(signed long long   a, const sc_int_rui& b) { return sc_int_rsl(a) + b; }
+inline const sc_int_rul operator+(unsigned long long a, const sc_int_rui& b) { return sc_int_rul(a) + b; }
+
+inline const sc_int_rsl operator+(bool               a, const sc_int_rsl& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rsl operator+(signed char        a, const sc_int_rsl& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rsl operator+(unsigned char      a, const sc_int_rsl& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rsl operator+(signed short       a, const sc_int_rsl& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rsl operator+(unsigned short     a, const sc_int_rsl& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rsl operator+(signed int         a, const sc_int_rsl& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rsl operator+(unsigned int       a, const sc_int_rsl& b) { return sc_int_rui(a) + b; }
+inline const sc_int_rsl operator+(signed long long   a, const sc_int_rsl& b) { return sc_int_rsl(a) + b; }
+inline const sc_int_rul operator+(unsigned long long a, const sc_int_rsl& b) { return sc_int_rul(a) + b; }
+
+inline const sc_int_rul operator+(bool               a, const sc_int_rul& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rul operator+(signed char        a, const sc_int_rul& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rul operator+(unsigned char      a, const sc_int_rul& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rul operator+(signed short       a, const sc_int_rul& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rul operator+(unsigned short     a, const sc_int_rul& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rul operator+(signed int         a, const sc_int_rul& b) { return sc_int_rsi(a) + b; }
+inline const sc_int_rul operator+(unsigned int       a, const sc_int_rul& b) { return sc_int_rui(a) + b; }
+inline const sc_int_rul operator+(signed long long   a, const sc_int_rul& b) { return sc_int_rsl(a) + b; }
+inline const sc_int_rul operator+(unsigned long long a, const sc_int_rul& b) { return sc_int_rul(a) + b; }

 ////////////////////////////////////////////////////////////////


NVMe WIP updates

NVMe WIP updates

--- freebsd_dev.c
+++ freebsd_dev.c
@@ -123,16 +123,13 @@
 	nvmeio->cmd.nsid = NVME_GLOBAL_NAMESPACE_TAG;
 	nvmeio->cmd.cdw10 = NVME_LOG_HEALTH_INFORMATION | (numd << 16);

-	cam_fill_nvmeio(&ccb->nvmeio,
+	cam_fill_nvmeadmin(&ccb->nvmeio,
 			/* retries */1,
 			/* cbfcnp */NULL,
 			/* flags */CAM_DIR_IN,
 			/* data_ptr */buf,
 			/* dxfer_len */bsize,
 			/* timeout */5000);
-
-	/* hack to signify this is an Admin command */
-	ccb->ccb_h.xflags = 0x10;
 #endif
 	return 0;
 }
@@ -323,7 +320,9 @@
 static int32_t
 __device_info_nvme(struct fbsd_smart *fsmart, struct ccb_getdev *cgd)
 {
+	union ccb *ccb;
 	smart_info_t *sinfo = NULL;
+	struct nvme_controller_data cd;

 	if (!fsmart || !cgd) {
 		return -1;
@@ -333,19 +332,38 @@

 	sinfo->supported = true;

-	if (cgd->nvme_cdata) {
-		/* TODO nvme_cdata and nvme_data appear to be kernel pointers */
-#if 0
-		cam_strvis((uint8_t *)sinfo->device, cgd->nvme_cdata->mn,
-				sizeof(cgd->nvme_cdata->mn),
-				sizeof(sinfo->device));
-		cam_strvis((uint8_t *)sinfo->rev, cgd->nvme_cdata->fr,
-				sizeof(cgd->nvme_cdata->fr),
-				sizeof(sinfo->rev));
-		cam_strvis((uint8_t *)sinfo->serial, cgd->nvme_cdata->sn,
-				sizeof(cgd->nvme_cdata->sn),
-				sizeof(sinfo->serial));
+	ccb = cam_getccb(fsmart->camdev);
+	if (ccb != NULL) {
+		struct ccb_dev_advinfo *cdai = &ccb->cdai;
+
+		CCB_CLEAR_ALL_EXCEPT_HDR(cdai);
+
+		cdai->ccb_h.func_code = XPT_DEV_ADVINFO;
+		cdai->ccb_h.flags = CAM_DIR_IN;
+		cdai->flags = CDAI_FLAG_NONE;
+#ifdef CDAI_TYPE_NVME_CNTRL
+		cdai->buftype = CDAI_TYPE_NVME_CNTRL;
+#else
+		cdai->buftype = 6;
 #endif
+		cdai->bufsiz = sizeof(struct nvme_controller_data);
+		cdai->buf = (uint8_t *)&cd;
+
+		if (cam_send_ccb(fsmart->camdev, ccb) >= 0) {
+			if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
+				cam_strvis((uint8_t *)sinfo->device, cd.mn,
+						sizeof(cd.mn),
+						sizeof(sinfo->device));
+				cam_strvis((uint8_t *)sinfo->rev, cd.fr,
+						sizeof(cd.fr),
+						sizeof(sinfo->rev));
+				cam_strvis((uint8_t *)sinfo->serial, cd.sn,
+						sizeof(cd.sn),
+						sizeof(sinfo->serial));
+			}
+		}
+
+		cam_freeccb(ccb);
 	}

 	return 0;
@@ -371,6 +389,17 @@

 		CCB_CLEAR_ALL_EXCEPT_HDR(cgd);

+		/*
+		 * XXX although convenient, GDEV_TYPE won't work for NVMe b/c
+		 * of the pointer silliness. What we get from GDEV_TYPE is:
+		 *  - device (ata/model, scsi/product)
+		 *  - revision (ata, scsi)
+		 *  - serial (ata)
+		 *  - vendor (scsi)
+		 *  - supported (ata)
+		 *
+		 *  Serial # for all proto via ccb_dev_advinfo (buftype CDAI_TYPE_SERIAL_NUM)
+		 */
 		ccb->ccb_h.func_code = XPT_GDEV_TYPE;

 		if (cam_send_ccb(fsmart->camdev, ccb) >= 0) {
@@ -391,6 +420,8 @@
 				}
 			}
 		}
+
+		cam_freeccb(ccb);
 	}

 	return rc;


Support fat archives on OS X

Support fat archives on OS X

Based on the darcs patch from Greg Wright in #4828.

--- rts/Linker.c
+++ rts/Linker.c
@@ -101,6 +101,8 @@
 #elif defined(darwin_HOST_OS)
 #  define OBJFORMAT_MACHO
 #  include <regex.h>
+#  include <mach/machine.h>
+#  include <mach-o/fat.h>
 #  include <mach-o/loader.h>
 #  include <mach-o/nlist.h>
 #  include <mach-o/reloc.h>
@@ -1701,11 +1703,30 @@
     char *fileName;
     size_t fileNameSize;
     int isObject, isGnuIndex;
-    char tmp[12];
+    char tmp[20];
     char *gnuFileIndex;
     int gnuFileIndexSize;
-#if !defined(USE_MMAP) && defined(darwin_HOST_OS)
+#if defined(darwin_HOST_OS)
+    int i;
+    uint32_t nfat_arch, nfat_offset, cputype, cpusubtype;
+#if defined(i386_HOST_ARCH)
+    const uint32_t mycputype = CPU_TYPE_X86;
+    const uint32_t mycpusubtype = CPU_SUBTYPE_X86_ALL;
+#elif defined(x86_64_HOST_ARCH)
+    const uint32_t mycputype = CPU_TYPE_X86_64;
+    const uint32_t mycpusubtype = CPU_SUBTYPE_X86_64_ALL;
+#elif defined(powerpc_HOST_ARCH)
+    const uint32_t mycputype = CPU_TYPE_POWERPC;
+    const uint32_t mycpusubtype = CPU_SUBTYPE_POWERPC_ALL;
+#elif defined(powerpc64_HOST_ARCH)
+    const uint32_t mycputype = CPU_TYPE_POWERPC64;
+    const uint32_t mycpusubtype = CPU_SUBTYPE_POWERPC_ALL;
+#else
+#error Unknown Darwin architecture
+#endif
+#if !defined(USE_MMAP)
     int misalignment;
+#endif
 #endif

     IF_DEBUG(linker, debugBelch("loadArchive: start\n"));
@@ -1721,9 +1742,74 @@
     if (!f)
         barf("loadObj: can't read `%s'", path);

+    /* Check if this is an archive by looking for the magic "!<arch>\n"
+     * string.  Usually, if this fails, we barf and quit.  On Darwin however,
+     * we may have a fat archive, which contains archives for more than
+     * one architecture.  Fat archives start with the magic number 0xcafebabe,
+     * always stored big endian.  If we find a fat_header, we scan through
+     * the fat_arch structs, searching through for one for our host
+     * architecture.  If a matching struct is found, we read the offset
+     * of our archive data (nfat_offset) and seek forward nfat_offset bytes
+     * from the start of the file.
+     *
+     * A subtlety is that all of the members of the fat_header and fat_arch
+     * structs are stored big endian, so we need to call byte order
+     * conversion functions.
+     *
+     * If we find the appropriate architecture in a fat archive, we gobble
+     * its magic "!<arch>\n" string and continue processing just as if
+     * we had a single architecture archive.
+     */
+
     n = fread ( tmp, 1, 8, f );
+    if (n != 8)
+        barf("loadArchive: Failed reading header from `%s'", path);
     if (strncmp(tmp, "!<arch>\n", 8) != 0) {
+
+#if defined(darwin_HOST_OS)
+        /* Not a standard archive, look for a fat archive magic number: */
+        if (ntohl(*(uint32_t *)tmp) == FAT_MAGIC) {
+            nfat_arch = ntohl(*(uint32_t *)(tmp + 4));
+            IF_DEBUG(linker, debugBelch("loadArchive: found a fat archive containing %d architectures\n", nfat_arch));
+            nfat_offset = 0;
+
+            for (i = 0; i < (int)nfat_arch; i++) {
+                /* search for the right arch */
+                n = fread( tmp, 1, 20, f );
+                if (n != 8)
+                    barf("loadArchive: Failed reading arch from `%s'", path);
+                cputype = ntohl(*(uint32_t *)tmp);
+                cpusubtype = ntohl(*(uint32_t *)(tmp + 4));
+
+                if (cputype == mycputype && cpusubtype == mycpusubtype) {
+                    IF_DEBUG(linker, debugBelch("loadArchive: found my archive in a fat archive\n"));
+                    nfat_offset = ntohl(*(uint32_t *)(tmp + 8));
+                    break;
+                }
+            }
+
+            if (nfat_offset == 0) {
+               barf ("loadArchive: searched %d architectures, but no host arch found", (int)nfat_arch);
+            }
+            else {
+                n = fseek( f, nfat_offset, SEEK_SET );
+                if (n != 0)
+                    barf("loadArchive: Failed to seek to arch in `%s'", path);
+                n = fread ( tmp, 1, 8, f );
+                if (n != 8)
+                    barf("loadArchive: Failed reading header from `%s'", path);
+                if (strncmp(tmp, "!<arch>\n", 8) != 0) {
+                    barf("loadArchive: couldn't find archive in `%s' at offset %d", path, nfat_offset);
+                }
+            }
+        }
+        else {
+            barf("loadArchive: Neither an archive, nor a fat archive: `%s'", path);
+        }
+
+#else
         barf("loadArchive: Not an archive: `%s'", path);
+#endif
     }

     IF_DEBUG(linker, debugBelch("loadArchive: loading archive contents\n"));
@@ -1739,12 +1825,11 @@
                 barf("loadArchive: Failed reading file name from `%s'", path);
             }
         }
+
 #if defined(darwin_HOST_OS)
-        else {
-            if (strncmp(fileName, "!<arch>\n", 8) == 0) {
-                IF_DEBUG(linker, debugBelch("loadArchive: found the start of another archive, breaking\n"));
-                break;
-            }
+        if (strncmp(fileName, "!<arch>\n", 8) == 0) {
+            IF_DEBUG(linker, debugBelch("loadArchive: found the start of another archive, breaking\n"));
+            break;
         }
 #endif

@@ -1770,6 +1855,8 @@

         IF_DEBUG(linker, debugBelch("loadArchive: size of this archive member is %d\n", memberSize));
         n = fread ( tmp, 1, 2, f );
+        if (n != 2)
+            barf("loadArchive: Failed reading magic from `%s'", path);
         if (strncmp(tmp, "\x60\x0A", 2) != 0)
             barf("loadArchive: Failed reading magic from `%s' at %ld. Got %c%c",
                  path, ftell(f), tmp[0], tmp[1]);


Fix win32 build error.

Fix win32 build error.

--- src/core/iomgr/pollset.h
+++ src/core/iomgr/pollset.h
@@ -35,6 +35,7 @@
 #define __GRPC_INTERNAL_IOMGR_POLLSET_H_

 #include <grpc/support/port_platform.h>
+#include <grpc/support/time.h>

 /* A grpc_pollset is a set of file descriptors that a higher level item is
    interested in. For example:


Rebuilt against resynced userland

Rebuilt against resynced userland

--- host_applications/linux/apps/raspicam/RaspiMJPEG.h
+++ host_applications/linux/apps/raspicam/RaspiMJPEG.h
@@ -31,7 +31,7 @@
 /**
  * \file RaspiMJPEG.h
  **/
-#define VERSION "5.5.2"
+#define VERSION "5.6.1"

 #include <stdio.h>
 #include <stdlib.h>


add basic isl_multi_union_pw_aff_apply_pw_multi_aff tests

These will be extended with tests where the isl_multi_union_pw_aff
argument has an explicit domain when support for such objects is added.

Signed-off-by: Sven Verdoolaege <235c10dd23b819f81cdc9756a251746bc184cab6@gmail.com>

--- isl_test.c
+++ isl_test.c
@@ -5229,6 +5229,86 @@
 }

 /* Inputs for basic tests of binary operations on
+ * pairs of isl_multi_union_pw_aff and isl_pw_multi_aff objects.
+ * "fn" is the function that is tested.
+ * "arg1" and "arg2" are string descriptions of the inputs.
+ * "res" is a string description of the expected result.
+ */
+struct {
+	__isl_give isl_multi_union_pw_aff *(*fn)(
+		__isl_take isl_multi_union_pw_aff *mupa,
+		__isl_take isl_pw_multi_aff *pma);
+	const char *arg1;
+	const char *arg2;
+	const char *res;
+} mupa_pma_tests[] = {
+	{ &isl_multi_union_pw_aff_apply_pw_multi_aff,
+	  "C[{ A[i,j] -> [i]; B[i,j] -> [j] }, "
+	    "{ A[i,j] -> [j]; B[i,j] -> [i] }]",
+	  "{ C[a,b] -> D[b,a] }",
+	  "D[{ A[i,j] -> [j]; B[i,j] -> [i] }, "
+	    "{ A[i,j] -> [i]; B[i,j] -> [j] }]" },
+	{ &isl_multi_union_pw_aff_apply_pw_multi_aff,
+	  "C[{ A[i,j] -> [i] : i >= 0; B[i,j] -> [j] }, "
+	    "{ A[i,j] -> [j]; B[i,j] -> [i] }]",
+	  "{ C[a,b] -> D[b,a] }",
+	  "D[{ A[i,j] -> [j] : i >= 0; B[i,j] -> [i] }, "
+	    "{ A[i,j] -> [i] : i >= 0; B[i,j] -> [j] }]" },
+	{ &isl_multi_union_pw_aff_apply_pw_multi_aff,
+	  "C[{ A[i,j] -> [i]; B[i,j] -> [j] }]",
+	  "[N] -> { C[a] -> D[a + N] }",
+	  "[N] -> D[{ A[i,j] -> [i + N]; B[i,j] -> [j + N] }]" },
+	{ &isl_multi_union_pw_aff_apply_pw_multi_aff,
+	  "C[{ A[i,j] -> [i]; B[i,j] -> [j] }]",
+	  "{ C[a] -> D[a] : a >= 0; C[a] -> D[-a] : a < 0 }",
+	  "D[{ A[i,j] -> [i] : i >= 0; A[i,j] -> [-i] : i < 0; "
+	      "B[i,j] -> [j] : j >= 0; B[i,j] -> [-j] : j < 0 }]" },
+	{ &isl_multi_union_pw_aff_apply_pw_multi_aff,
+	  "C[{ A[i,j] -> [i]; B[i,j] -> [j] }, "
+	    "{ A[i,j] -> [j]; B[i,j] -> [i] }]",
+	  "{ C[a,b] -> D[a,b] : a >= b; C[a,b] -> D[b,a] : a < b }",
+	  "D[{ A[i,j] -> [i] : i >= j; A[i,j] -> [j] : i < j; "
+	      "B[i,j] -> [j] : i <= j; B[i,j] -> [i] : i > j }, "
+	    "{ A[i,j] -> [j] : i >= j; A[i,j] -> [i] : i < j; "
+	      "B[i,j] -> [i] : i <= j; B[i,j] -> [j] : i > j }]" },
+	{ &isl_multi_union_pw_aff_apply_pw_multi_aff,
+	  "C[]",
+	  "{ C[] -> D[] }",
+	  "D[]" },
+};
+
+/* Perform some basic tests of binary operations on
+ * pairs of isl_multi_union_pw_aff and isl_pw_multi_aff objects.
+ */
+static int test_mupa_pma(isl_ctx *ctx)
+{
+	int i;
+	isl_bool ok;
+	isl_multi_union_pw_aff *mupa, *res;
+	isl_pw_multi_aff *pma;
+
+	for (i = 0; i < ARRAY_SIZE(mupa_pma_tests); ++i) {
+		mupa = isl_multi_union_pw_aff_read_from_str(ctx,
+						    mupa_pma_tests[i].arg1);
+		pma = isl_pw_multi_aff_read_from_str(ctx,
+						    mupa_pma_tests[i].arg2);
+		res = isl_multi_union_pw_aff_read_from_str(ctx,
+						    mupa_pma_tests[i].res);
+		mupa = mupa_pma_tests[i].fn(mupa, pma);
+		ok = isl_multi_union_pw_aff_plain_is_equal(mupa, res);
+		isl_multi_union_pw_aff_free(mupa);
+		isl_multi_union_pw_aff_free(res);
+		if (ok < 0)
+			return -1;
+		if (!ok)
+			isl_die(ctx, isl_error_unknown,
+				"unexpected result", return -1);
+	}
+
+	return 0;
+}
+
+/* Inputs for basic tests of binary operations on
  * pairs of isl_multi_union_pw_aff and isl_union_pw_multi_aff objects.
  * "fn" is the function that is tested.
  * "arg1" and "arg2" are string descriptions of the inputs.
@@ -5320,6 +5400,8 @@
 	if (test_mupa_ma(ctx) < 0)
 		return -1;
 	if (test_mupa_pa(ctx) < 0)
+		return -1;
+	if (test_mupa_pma(ctx) < 0)
 		return -1;
 	if (test_mupa_upma(ctx) < 0)
 		return -1;


examples/dpdk_qat: fix reference to old mbuf field

Since commit 08b563ffb19 ("mbuf: replace data pointer by an offset"),
data is not an mbuf field anymore.

Signed-off-by: Pablo de Lara <28355d9cfe41bb8148aea0fb24f47aae8f4217a1@intel.com>
Acked-by: Thomas Monjalon <ee2fa8b2681c737f775687e475dcbf2028a412f1@6wind.com>

--- examples/dpdk_qat/crypto.c
+++ examples/dpdk_qat/crypto.c
@@ -183,7 +183,7 @@
  *
  */
 #define PACKET_DATA_START_PHYS(p) \
-		((p)->buf_physaddr + ((char *)p->data - (char *)p->buf_addr))
+		((p)->buf_physaddr + (p)->data_off)

 /*
  * A fixed offset to where the crypto is to be performed, which is the first
@@ -773,7 +773,7 @@
 crypto_encrypt(struct rte_mbuf *rte_buff, enum cipher_alg c, enum hash_alg h)
 {
 	CpaCySymDpOpData *opData =
-			(CpaCySymDpOpData *) ((char *) (rte_buff->data)
+			(CpaCySymDpOpData *) (rte_pktmbuf_mtod(rte_buff, char *)
 					+ CRYPTO_OFFSET_TO_OPDATA);
 	uint32_t lcore_id;

@@ -848,7 +848,7 @@
 crypto_decrypt(struct rte_mbuf *rte_buff, enum cipher_alg c, enum hash_alg h)
 {

-	CpaCySymDpOpData *opData = (void*) (((char *) rte_buff->data)
+	CpaCySymDpOpData *opData = (void*) (rte_pktmbuf_mtod(rte_buff, char *)
 			+ CRYPTO_OFFSET_TO_OPDATA);
 	uint32_t lcore_id;


darwin fix

darwin fix

--- src/os/darwin/darwin_sigar.c
+++ src/os/darwin/darwin_sigar.c
@@ -160,7 +160,9 @@
     }
 #endif

+#ifndef DARWIN
     get_koffsets(*sigar);
+#endif

     (*sigar)->ncpu = ncpu;


lib-storage: Don't crash listing subscription entry of "ns prefix" without separator.

--- src/lib-storage/list/mailbox-list-subscriptions.c
+++ src/lib-storage/list/mailbox-list-subscriptions.c
@@ -61,11 +61,16 @@

 	/* When listing pub/ namespace, skip over the namespace
 	   prefix in the name. the rest of the name is storage_name. */
-	if (ns != NULL) {
-		i_assert(strncmp(name, ns->prefix, ns->prefix_len) == 0);
+	if (ns == NULL)
+		ns = default_ns;
+	else if (strncmp(name, ns->prefix, ns->prefix_len) == 0)
 		name += ns->prefix_len;
-	} else {
-		ns = default_ns;
+	else {
+		/* "pub" entry - this shouldn't be possible normally, because
+		   it should be saved as "pub/", but handle it anyway */
+		i_assert(strncmp(name, ns->prefix, ns->prefix_len-1) == 0 &&
+			 name[ns->prefix_len-1] == '\0');
+		name = "";
 	}

 	len = strlen(name);


- Changed NeXus version number to 1.3.1Ray

git-svn-id: 1001b6e0dd469eaa302a741812f7f5d223cf35f7@108 ff5d1e40-2be0-497f-93bd-dc18237bd3c7

--- include/napi.h
+++ include/napi.h
@@ -40,7 +40,7 @@
 #ifndef NEXUSAPI
 #define NEXUSAPI

-#define NEXUS_VERSION	"1.3.0"		/* major.minor.patch */
+#define NEXUS_VERSION	"1.3.1"		/* major.minor.patch */

 #ifdef GENIE_IMPLEMENTATION__		/* OpenGENIE is fussy about consts */
 #   define CONSTCHAR	const char


Change color calculations float

Change color calculations float

--- C/mandelbrot.c
+++ C/mandelbrot.c
@@ -136,16 +136,16 @@
     free(gradient);
 }

-void color_from_gradient_range(gradient_color_t *left, gradient_color_t *right, double pos, double *r, double *g, double *b)
-{
-    double pos2 = (pos - left->pos) / (right->pos - left->pos);
+void color_from_gradient_range(gradient_color_t *left, gradient_color_t *right, float pos, float *r, float *g, float *b)
+{
+    float pos2 = (pos - left->pos) / (right->pos - left->pos);

     *r = ((right->r - left->r) * pos2) + left->r;
     *g = ((right->g - left->g) * pos2) + left->g;
     *b = ((right->b - left->b) * pos2) + left->b;
 }

-int color_from_gradient(gradient_t *gradient, double pos, double *r, double *g, double *b)
+int color_from_gradient(gradient_t *gradient, float pos, float *r, float *g, float *b)
 {
     gradient_color_t *left, *right;

@@ -166,7 +166,7 @@
 }

 void mandelbrot_calc(int image_width, int image_height, int max_iterations, double center_x, double center_y, double height,
-                     int *histogram, int *iterations_per_pixel, double *smoothed_distances_to_next_iteration_per_pixel)
+                     int *histogram, int *iterations_per_pixel, float *smoothed_distances_to_next_iteration_per_pixel)
 {
     const double width = height * ((double) image_width / (double) image_height);

@@ -225,7 +225,7 @@
 }

 void mandelbrot_colorize(int image_width, int image_height, int max_iterations, gradient_t *gradient,
-                         unsigned char *image_data, int *histogram, int *iterations_per_pixel, double *smoothed_distances_to_next_iteration_per_pixel, double *normalized_colors)
+                         unsigned char *image_data, int *histogram, int *iterations_per_pixel, float *smoothed_distances_to_next_iteration_per_pixel, float *normalized_colors)
 {
     // Sum all iterations, not counting the last one at position histogram[max_iterations] (which
     // are points in the Mandelbrot Set).
@@ -255,18 +255,18 @@
                 image_data[3 * pixel + 2] = 0;
             } else {
                 // we use the color of the previous iteration in order to cover the full gradient range
-                double r, g, b;
-                double color_of_previous_iter = normalized_colors[iter - 1];
-                double color_of_current_iter  = normalized_colors[iter];
-
-                double smoothed_distance_to_next_iteration = smoothed_distances_to_next_iteration_per_pixel[pixel];  // 0 .. <1.0
-                double pos_in_gradient = color_of_previous_iter + smoothed_distance_to_next_iteration * (color_of_current_iter - color_of_previous_iter);
+                float r, g, b;
+                float color_of_previous_iter = normalized_colors[iter - 1];
+                float color_of_current_iter  = normalized_colors[iter];
+
+                float smoothed_distance_to_next_iteration = smoothed_distances_to_next_iteration_per_pixel[pixel];  // 0 .. <1.0
+                float pos_in_gradient = color_of_previous_iter + smoothed_distance_to_next_iteration * (color_of_current_iter - color_of_previous_iter);

                 color_from_gradient(gradient, pos_in_gradient, &r, &g, &b);

-                image_data[3 * pixel + 0] = (unsigned char) (255.0 * r);
-                image_data[3 * pixel + 1] = (unsigned char) (255.0 * g);
-                image_data[3 * pixel + 2] = (unsigned char) (255.0 * b);
+                image_data[3 * pixel + 0] = (unsigned char) (255.0f * r);
+                image_data[3 * pixel + 1] = (unsigned char) (255.0f * g);
+                image_data[3 * pixel + 2] = (unsigned char) (255.0f * b);
             }
         }
     }
@@ -439,20 +439,20 @@
 {
     int *histogram;
     int *iterations_per_pixel;
-    double *smoothed_distances_to_next_iteration_per_pixel;
-    double *normalized_colors;
+    float *smoothed_distances_to_next_iteration_per_pixel;
+    float *normalized_colors;

     // histogram & normalized_colors: for simplicity we only use indices [1] .. [max_iterations], [0] is unused
     if (!(histogram = malloc((max_iterations + 1) * sizeof(int))))
         die(ERROR_ALLOC_MEMORY);

-    if (!(normalized_colors = malloc((max_iterations + 1) * sizeof(double))))
+    if (!(normalized_colors = malloc((max_iterations + 1) * sizeof(float))))
         die(ERROR_ALLOC_MEMORY);

     if (!(iterations_per_pixel = malloc(image_width * image_height * sizeof(int))))
         die(ERROR_ALLOC_MEMORY);

-    if (!(smoothed_distances_to_next_iteration_per_pixel = malloc(image_width * image_height * sizeof(double))))
+    if (!(smoothed_distances_to_next_iteration_per_pixel = malloc(image_width * image_height * sizeof(float))))
         die(ERROR_ALLOC_MEMORY);

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


Fix issues related to trying to erase lengths of zero.  NB: This is basically to allow an out of range index so long as the operation size is 0.

--- cegui/include/CEGUIString.h
+++ cegui/include/CEGUIString.h
@@ -2433,6 +2433,10 @@
 	*/
 	String& erase(size_type idx, size_type len = npos)
 	{
+        // cover the no-op case.
+        if (len == 0)
+            return *this;
+
 		if (d_cplength <= idx)
 			CEGUI_THROW(std::out_of_range("Index is out of range for CEGUI::String"));