Added support for SceneEngine as a TS program

--- applications/testapps/mp42ts/main.c
+++ applications/testapps/mp42ts/main.c
@@ -25,6 +25,7 @@
 #include <gpac/constants.h>
 #include <gpac/base_coding.h>
 #include <gpac/ietf.h>
+#include <gpac/scene_engine.h>
 #include <gpac/mpegts.h>

 void usage()
@@ -42,6 +43,22 @@
 		);
 }

+
+
+
+#define MAX_MUX_SRC_PROG	100
+typedef struct
+{
+	GF_ISOFile *mp4;
+	u32 nb_streams, pcr_idx;
+	GF_ESInterface streams[40];
+	GF_Descriptor *iod;
+	GF_SceneEngine *seng;
+	GF_Thread *th;
+	char *src_name;
+	u32 rate;
+	Bool repeat;
+} M2TSProgram;

 typedef struct
 {
@@ -57,6 +74,17 @@
 	Bool loop;
 	u64 ts_offset;
 } GF_ESIMP4;
+
+typedef struct
+{
+	u32 carousel_period, ts_delta;
+	u16 aggregate_on_stream;
+	Bool adjust_carousel_time;
+	Bool discard;
+	Bool rap;
+	Bool critical;
+	Bool vers_inc;
+} GF_ESIStream;

 static GF_Err mp4_input_ctrl(GF_ESInterface *ifce, u32 act_type, void *param)
 {
@@ -246,6 +274,18 @@
 	ifce->input_udta = priv;
 }

+
+static GF_Err seng_input_ctrl(GF_ESInterface *ifce, u32 act_type, void *param)
+{
+	if (act_type==GF_ESI_INPUT_DESTROY) {
+		//free my data
+		ifce->input_udta = NULL;
+		return GF_OK;
+	}
+
+	return GF_OK;
+}
+
 typedef struct
 {
 	/*RTP channel*/
@@ -303,6 +343,227 @@
 	}
 	return GF_OK;
 }
+
+GF_Err SampleCallBack(void *calling_object, u16 ESID, char *data, u32 size, u64 ts)
+{
+	u32 i=0;
+
+	if (calling_object) {
+		M2TSProgram *prog = (M2TSProgram *)calling_object;
+			while (i<prog->nb_streams){
+				if (prog->streams[i].output_ctrl==NULL) {
+					fprintf(stdout, "MULTIPLEX NOT YET CREATED\n");
+					return GF_OK;
+				}
+				if (prog->streams[i].stream_id == ESID) {
+					GF_ESIStream *priv = (GF_ESIStream *)prog->streams[i].input_udta;
+					GF_ESIPacket pck;
+					memset(&pck, 0, sizeof(GF_ESIPacket));
+					pck.data = data;
+					pck.data_len = size;
+					pck.flags |= GF_ESI_DATA_HAS_CTS;
+					pck.flags |= GF_ESI_DATA_AU_START;
+					pck.flags |= GF_ESI_DATA_AU_END;
+					if (priv->rap)
+						pck.flags |= GF_ESI_DATA_AU_RAP;
+					if (prog->repeat || !priv->vers_inc) {
+						pck.flags |= GF_ESI_DATA_REPEAT;
+						fprintf(stdout, "RAP carousel from scene engine sent\n");
+					} else {
+						fprintf(stdout, "Update from scene engine sent\n");
+					}
+					prog->streams[i].output_ctrl(&prog->streams[i], GF_ESI_OUTPUT_DATA_DISPATCH, &pck);
+					return GF_OK;
+				}
+			i++;
+			}
+	}
+	return GF_OK;
+}
+
+static Bool run = 1;
+
+static void set_broadcast_params(M2TSProgram *prog, u16 esid, u32 period, u32 ts_delta, u16 aggregate_on_stream, Bool adjust_carousel_time, Bool force_rap, Bool aggregate_au, Bool discard_pending, Bool signal_rap, Bool signal_critical, Bool version_inc)
+{
+	u32 i=0;
+	GF_ESIStream *priv=NULL;
+	GF_ESInterface *esi=NULL;
+
+	/*locate our stream*/
+	if (esid) {
+		while (i<prog->nb_streams) {
+			if (prog->streams[i].stream_id == esid){
+				priv = (GF_ESIStream *)prog->streams[i].input_udta;
+				esi = &prog->streams[i];
+				break;
+			}
+			else{
+				i++;
+			}
+		}
+	}
+
+	/*TODO - set/reset the ESID for the parsers*/
+	if (!priv) return NULL;
+
+	/*TODO - if discard is set, abort current carousel*/
+	if (discard_pending) {
+	}
+
+	/*remember RAP flag*/
+	priv->rap = signal_rap;
+	priv->critical = signal_critical;
+	priv->vers_inc = version_inc;
+
+	priv->ts_delta = ts_delta;
+	priv->adjust_carousel_time = adjust_carousel_time;
+
+	/*change stream aggregation mode*/
+	if ((aggregate_on_stream != (u16)-1) && (priv->aggregate_on_stream != aggregate_on_stream)) {
+		gf_seng_enable_aggregation(prog->seng, esid, aggregate_on_stream);
+		priv->aggregate_on_stream = aggregate_on_stream;
+	}
+	/*change stream aggregation mode*/
+	if (priv->aggregate_on_stream==esi->stream_id) {
+		if (priv->aggregate_on_stream && (period!=(u32)-1) && (esi->repeat_rate != period)) {
+			esi->repeat_rate = period;
+		}
+	} else {
+		esi->repeat_rate = 0;
+	}
+
+	return priv;
+}
+
+u32 seng_output(void *param)
+{
+	GF_Err e;
+	u64 last_src_modif, mod_time;
+	Bool has_carousel=0;
+	M2TSProgram *prog = (M2TSProgram *)param;
+	GF_SceneEngine *seng = prog->seng;
+	Bool update_context=0;
+	u32 i=0;
+	Bool force_rap, adjust_carousel_time, discard_pending, signal_rap, signal_critical, version_inc, aggregate_au;
+	u32 period, ts_delta;
+	u16 es_id, aggregate_on_stream;
+
+	if (prog->rate){
+		has_carousel = 1;
+	}
+	gf_sleep(2000);
+	gf_seng_encode_context(seng, SampleCallBack);
+
+	last_src_modif = prog->src_name ? gf_file_modification_time(prog->src_name) : 0;
+
+	while (run) {
+		if (gf_prompt_has_input()) {
+			char c = gf_prompt_get_char();
+			switch (c) {
+			case 'u':
+			{
+				GF_Err e;
+				char szCom[8192];
+				fprintf(stdout, "Enter command to send:\n");
+				fflush(stdin);
+				szCom[0] = 0;
+				scanf("%[^\t\n]", szCom);
+				prog->repeat = 0;
+				e = gf_seng_encode_from_string(seng, 0, 0, szCom, SampleCallBack);
+				prog->repeat = 1;
+				if (e) fprintf(stdout, "Processing command failed: %s\n", gf_error_to_string(e));
+				update_context=1;
+			}
+				break;
+			case 'p':
+			{
+				char rad[GF_MAX_PATH];
+				fprintf(stdout, "Enter output file name - \"std\" for stdout: ");
+				scanf("%s", rad);
+				e = gf_seng_save_context(seng, !strcmp(rad, "std") ? NULL : rad);
+				fprintf(stdout, "Dump done (%s)\n", gf_error_to_string(e));
+			}
+				break;
+			}
+			e = GF_OK;
+		}
+		if (prog->src_name) {
+			mod_time = gf_file_modification_time(prog->src_name);
+			if (mod_time != last_src_modif) {
+				FILE *srcf;
+				char flag_buf[201], *flag;
+				fprintf(stdout, "Update file modified - processing\n");
+				last_src_modif = mod_time;
+
+				srcf = fopen(prog->src_name, "rt");
+				if (!srcf) continue;
+
+				/*checks if we have a broadcast config*/
+				fgets(flag_buf, 200, srcf);
+				fclose(srcf);
+
+				aggregate_au = force_rap = adjust_carousel_time = discard_pending = signal_rap = signal_critical = 0;
+				version_inc = 1;
+				period = -1;
+				aggregate_on_stream = -1;
+				ts_delta = 0;
+				es_id = 0;
+
+				/*find our keyword*/
+				flag = strstr(flag_buf, "gpac_broadcast_config ");
+				if (flag) {
+					flag += strlen("gpac_broadcast_config ");
+					/*move to next word*/
+					while (flag && (flag[0]==' ')) flag++;
+
+					while (1) {
+						char *sep = strchr(flag, ' ');
+						if (sep) sep[0] = 0;
+						if (!strnicmp(flag, "esid=", 5)) es_id = atoi(flag+5);
+						else if (!strnicmp(flag, "period=", 7)) period = atoi(flag+7);
+						else if (!strnicmp(flag, "ts=", 3)) ts_delta = atoi(flag+3);
+						else if (!strnicmp(flag, "carousel=", 9)) aggregate_on_stream = atoi(flag+9);
+						else if (!strnicmp(flag, "restamp=", 8)) adjust_carousel_time = atoi(flag+8);
+						else if (!strnicmp(flag, "discard=", 8)) discard_pending = atoi(flag+8);
+						else if (!strnicmp(flag, "aggregate=", 10)) aggregate_au = atoi(flag+10);
+						else if (!strnicmp(flag, "force_rap=", 10)) force_rap = atoi(flag+10);
+						else if (!strnicmp(flag, "rap=", 4)) signal_rap = atoi(flag+4);
+						else if (!strnicmp(flag, "critical=", 9)) signal_critical = atoi(flag+9);
+						else if (!strnicmp(flag, "vers_inc=", 9)) version_inc = atoi(flag+9);
+						if (sep) {
+							sep[0] = ' ';
+							flag = sep+1;
+						} else {
+							break;
+						}
+					}
+
+					set_broadcast_params(prog, es_id, period, ts_delta, aggregate_on_stream, adjust_carousel_time, force_rap, aggregate_au, discard_pending, signal_rap, signal_critical, version_inc);
+				}
+
+
+				e = gf_seng_encode_from_file(seng, es_id, aggregate_au ? 0 : 1, prog->src_name, SampleCallBack);
+				if (e) fprintf(stdout, "Processing command failed: %s\n", gf_error_to_string(e));
+				else gf_seng_aggregate_context(seng, 0);
+				update_context=1;
+
+
+
+			}
+		}
+		if (update_context) {
+			prog->repeat = 1;
+			e = gf_seng_encode_context(seng, SampleCallBack	);
+			prog->repeat = 0;
+		}
+
+		gf_sleep(10);
+	}
+
+
+	return e ? 1 : 0;
+}
+

 static void rtp_sl_packet_cbk(void *udta, char *payload, u32 size, GF_SLHeader *hdr, GF_Err e)
 {
@@ -420,21 +681,36 @@
 	fprintf(stdout, "RTP interface initialized\n");
 }

-#define MAX_MUX_SRC_PROG	100
-typedef struct
-{
-	GF_ISOFile *mp4;
-	u32 nb_streams, pcr_idx;
-	GF_ESInterface streams[40];
-	GF_Descriptor *iod;
-} M2TSProgram;
-
-Bool open_program(M2TSProgram *prog, const char *src, u32 carousel_rate, Bool *force_mpeg4)
+void fill_seng_es_ifce(GF_ESInterface *ifce, u32 i, GF_SceneEngine *seng, u32 period)
+{
+	GF_Err e=GF_OK;
+	char *config_buffer;
+	u32 len;
+	GF_ESIStream *stream;
+
+	memset(ifce, 0, sizeof(GF_ESInterface));
+	gf_seng_get_stream_config(seng, i, &ifce->stream_id, &config_buffer, &len, &ifce->stream_type, &ifce->object_type_indication, &ifce->timescale);
+
+	ifce->repeat_rate = period;
+	GF_SAFEALLOC(stream, GF_ESIStream);
+	stream->rap = 1;
+	ifce->input_udta = stream;
+
+//	e = gf_seng_set_carousel_time(seng, ifce->stream_id, period);
+	fprintf(stdout, "Caroussel %d", &period);
+	if (e) {
+		fprintf(stdout, "Cannot set carousel time on stream %d to %d: %s\n", ifce->stream_id, period, gf_error_to_string(e));
+	}
+	ifce->input_ctrl = seng_input_ctrl;
+
+}
+
+Bool open_program(M2TSProgram *prog, const char *src, u32 carousel_rate, Bool *force_mpeg4, const char *update)
 {
 	GF_SDPInfo *sdp;
 	u32 i;
 	GF_Err e;
-
+
 	memset(prog, 0, sizeof(M2TSProgram));

 	/* Open ISO file  */
@@ -556,6 +832,38 @@
 		if (prog->pcr_idx) prog->pcr_idx-=1;
 		gf_sdp_info_del(sdp);
 		return 2;
+	//open .bt file
+	} else if (strstr(src, ".bt")) {
+		u32 load_type=0;
+		prog->seng = gf_seng_init(prog, src, load_type, NULL, (load_type == GF_SM_LOAD_DIMS) ? 1 : 0);
+
+	    if (!prog->seng) {
+			fprintf(stdout, "Cannot create scene engine\n");
+			exit(0);
+		}
+		else{
+			fprintf(stdout, "Scene engine created.\n");
+		}
+
+		prog->iod = gf_seng_get_iod(prog->seng);
+
+		prog->nb_streams = gf_seng_get_stream_count(prog->seng);
+		prog->rate = carousel_rate;
+		*force_mpeg4 = 1;
+
+		for (i=0; i<prog->nb_streams; i++) {
+			fill_seng_es_ifce(&prog->streams[i], i, prog->seng, prog->rate);
+			fprintf(stdout, "Fill interface/n");
+			if (!prog->pcr_idx && (prog->streams[i].stream_type == GF_STREAM_VISUAL)) {
+				prog->pcr_idx = i+1;
+			}
+		}
+		if (!prog->pcr_idx) prog->pcr_idx=1;
+		prog->pcr_idx-=1;
+		prog->th = gf_th_new("Carousel");
+		prog->src_name = update;
+		gf_th_run(prog->th, seng_output, prog);
+		return 1;
 	} else {
 		fprintf(stderr, "Error opening %s - not a supported input media, skipping.\n", src);
 		return 0;
@@ -579,6 +887,7 @@
 	u16 port = 1234;
 	u32 output_type;
 	u32 check_count;
+	char *src_name = NULL;
 	M2TSProgram progs[MAX_MUX_SRC_PROG];

 	real_time=0;
@@ -594,9 +903,8 @@
 	carrousel_rate = 500;

 	gf_sys_init(0);
-	gf_log_set_level(GF_LOG_INFO);
-	gf_log_set_tools(GF_LOG_RTP);
-	gf_log_set_tools(GF_LOG_CONTAINER);
+	gf_log_set_level(GF_LOG_ERROR);
+	gf_log_set_tools(0xFFFFFFFF);

 	for (i=1; i<argc; i++) {
 		char *arg = argv[i];
@@ -611,7 +919,7 @@
 				gf_log_set_tools(gf_log_parse_tools(argv[i]+4));
 			} else if (!strnicmp(arg, "-prog=", 6)) {
 				memset(&progs[nb_progs], 0, sizeof(M2TSProgram));
-				res = open_program(&progs[nb_progs], arg+6, carrousel_rate, &mpeg4_signaling);
+				res = open_program(&progs[nb_progs], arg+6, carrousel_rate, &mpeg4_signaling, src_name);
 				if (res) {
 					nb_progs++;
 					if (res==2) real_time=1;
@@ -621,6 +929,9 @@
 			} else if (!strnicmp(arg, "-time=", 6)) {
 				run_time = atoi(arg+6);
 			}
+			else if (!strnicmp(arg, "-src=", 5)){
+				src_name = arg+5;
+			}
 		}
 		/*output*/
 		else {
@@ -769,7 +1080,7 @@
 					char c = gf_prompt_get_char();
 					if (c == 'q') break;
 				}
-				fprintf(stdout, "M2TS: time %d - TS time %d - avg bitrate %d\r", gf_m2ts_get_sys_clock(muxer), gf_m2ts_get_ts_clock(muxer), muxer->avg_br);
+				//fprintf(stdout, "M2TS: time %d - TS time %d - avg bitrate %d\r", gf_m2ts_get_sys_clock(muxer), gf_m2ts_get_ts_clock(muxer), muxer->avg_br);
 			}
 		} else if (run_time) {
 			if (gf_m2ts_get_ts_clock(muxer) > run_time) {
@@ -783,6 +1094,7 @@

 exit:
+	run = 0;
 	if (ts_file) fclose(ts_file);
 	if (ts_udp) gf_sk_del(ts_udp);
 	if (ts_rtp) gf_rtp_del(ts_rtp);


fixing doxygen warnings

fixing doxygen warnings

git-svn-id: 5398946ba177a3e438c2dae55e2cdfc2fb96c905@3576 a9d63959-f2ad-4865-b262-bf0e56cfafb6

--- filters/include/pcl/filters/statistical_outlier_removal.h
+++ filters/include/pcl/filters/statistical_outlier_removal.h
@@ -125,7 +125,7 @@
         negative_ = negative;
       }

-      /** \brief Get the value of the internal #negative_ parameter. If
+      /** \brief Get the value of the internal negative_ parameter. If
         * true, all points \e except the input indices will be returned.
         */
       inline bool


It is possible for sqlite3_prepare_v2 to return SQLITE_OK while leaving the returned SQL statement empty.

--- generic/pgtclSqlite.c
+++ generic/pgtclSqlite.c
@@ -49,6 +49,12 @@
 		Tcl_AppendResult(interp, sqlite3_errmsg(sqlite_db), (char *)NULL);
 		return TCL_ERROR;
 	}
+
+	if(!*statement_ptr) {
+		Tcl_AppendResult(interp, "Empty SQL statement provided.", (char *)NULL);
+		return TCL_ERROR;
+	}
+
 	return TCL_OK;
 }


missing semicolon

missing semicolon

--- generic/solver_main.c
+++ generic/solver_main.c
@@ -33,7 +33,7 @@
         {
             buffer[i + 1] = y_host[NUM * i + j];
         }
-        apply_reverse_mask(&buffer[2])
+        apply_reverse_mask(&buffer[2]);
         fwrite(buffer, sizeof(double), NN + 2, pFile);
     }
 }


Remove obsolete remove_const_reference.h reference

--- geode/value/extract.h
+++ geode/value/extract.h
@@ -6,7 +6,6 @@
 #include <geode/value/Compute.h>
 #include <geode/structure/Tuple.h>
 #include <geode/utility/curry.h>
-#include <geode/utility/remove_const_reference.h>
 namespace geode {

 template<int n,class Tuple> static inline auto extract_helper(const ValueRef<Tuple>& value)


mkfs.gfs2: should have an optional fs size parm

bz 450764

This patch fixes two problems with the previous patch for
an optional "blocks" parameter to mkfs.gfs2.  The bugs
are: (1) If the blocks specified is too big, it gave a wrong
message.  This fixes the message and prints out what the
numbers are (to help the user get it right).  (2) If the
number of blocks was specified, the device size was reported
incorrectly.

--- gfs2/mkfs/main_mkfs.c
+++ gfs2/mkfs/main_mkfs.c
@@ -318,7 +318,7 @@
  */

 static void
-print_results(struct gfs2_sbd *sdp)
+print_results(struct gfs2_sbd *sdp, uint64_t real_device_size)
 {
 	if (sdp->debug)
 		printf("\n");
@@ -332,7 +332,8 @@

 	printf("Blocksize:                 %u\n", sdp->bsize);
 	printf("Device Size                %.2f GB (%"PRIu64" blocks)\n",
-	       sdp->device_size / ((float)(1 << 30)) * sdp->bsize, sdp->device_size);
+	       real_device_size / ((float)(1 << 30)),
+	       real_device_size / sdp->bsize);
 	printf("Filesystem Size:           %.2f GB (%"PRIu64" blocks)\n",
 	       sdp->fssize / ((float)(1 << 30)) * sdp->bsize, sdp->fssize);

@@ -365,6 +366,7 @@
 	unsigned int x;
 	int error;
 	int rgsize_specified = 0;
+	uint64_t real_device_size;

 	memset(sdp, 0, sizeof(struct gfs2_sbd));
 	sdp->bsize = GFS2_DEFAULT_BSIZE;
@@ -401,14 +403,19 @@

 	/* Get the device geometry */

+	device_size(sdp->device_fd, &real_device_size);
 	device_geometry(sdp);
 	/* Convert optional block-count to basic blocks */
 	if (sdp->orig_fssize) {
 		sdp->orig_fssize *= sdp->bsize;
 		sdp->orig_fssize >>= GFS2_BASIC_BLOCK_SHIFT;
-		if (sdp->orig_fssize > sdp->device.length)
-			die("specified block count is smaller than the"
-			    "actual device.\n");
+		if (sdp->orig_fssize > sdp->device.length) {
+			fprintf(stderr, "%s: Specified block count is bigger "
+				"than the actual device.\n", prog_name);
+			die("Device Size is %.2f GB (%"PRIu64" blocks)\n",
+			       real_device_size / ((float)(1 << 30)),
+			       real_device_size / sdp->bsize);
+		}
 		sdp->device.length = sdp->orig_fssize;
 	}
 	fix_device_geometry(sdp);
@@ -449,5 +456,5 @@
 		die("error closing device (%d): %s\n",
 		    error, strerror(errno));

-	print_results(sdp);
-}
+	print_results(sdp, real_device_size);
+}


gfxdrivers/gl: shader fixes

gfxdrivers/gl: shader fixes

1) do not send color key as converted float to fragment shader,
   let the shader convert floats to int and then compare the integer values.
   (fixes df_dok's non-full-saturated color key values)
   There might be a possible optimization in the new shader code.

2) for state validation flags include SRC_COLORKEY in ALL

Send color key to shader as integer for each color channel,

--- gfxdrivers/gl/gl_2d.c
+++ gfxdrivers/gl/gl_2d.c
@@ -67,7 +67,7 @@

      BLENDFUNC    = 0x00010000,

-     ALL          = 0x0001031F
+     ALL          = 0x0001071F
 };

 /*
@@ -334,13 +334,13 @@
 {
      D_DEBUG_AT( GL__2D, "%s()\n", __FUNCTION__ );

-     /* convert RGB32 color values to float */
-     float fr = (float)((state->src_colorkey & 0x00FF0000) >> 16)/255.0f;
-     float fg = (float)((state->src_colorkey & 0x0000FF00) >>  8)/255.0f;
-     float fb = (float)((state->src_colorkey & 0x000000FF)      )/255.0f;
-
-     /* send float converted color key to shader */
-     glUniform3fARB( gdev->location_colorkey, fr, fg, fb );
+     /* convert RGB32 color values to int */
+     int r = (state->src_colorkey & 0x00FF0000) >> 16;
+     int g = (state->src_colorkey & 0x0000FF00) >>  8;
+     int b = (state->src_colorkey & 0x000000FF)      ;
+
+     /* send converted color key to shader */
+     glUniform3iARB( gdev->location_colorkey, r, g, b );

      /* Set the flag. */
      GL_VALIDATE( SRC_COLORKEY );
@@ -551,11 +551,15 @@
      static const char * ff = "#extension GL_ARB_texture_rectangle : enable\n"
                               "\n"
                               "uniform sampler2DRect myTexture;\n"
-                              "uniform vec3 src_colorkey;\n"
+                              "uniform ivec3 src_colorkey;\n"
                               "void main (void)\n"
                               "{\n"
                               "   vec4 value = texture2DRect(myTexture, vec2(gl_TexCoord[0]));\n"
-                              "   if (vec3(value) == src_colorkey)\n"
+                              "   int r = int(value.r*255.0);\n"
+                              "   int g = int(value.g*255.0);\n"
+                              "   int b = int(value.b*255.0);\n"
+                              "\n"
+                              "   if (r == src_colorkey.x && g == src_colorkey.y && b == src_colorkey.z)\n"
                               "      discard;\n"
                               "   gl_FragColor = value;\n"
                               "}\n";


pyg_value_from_pyobject(): Simplify GVariant type check

Use pyg_type_from_object_strict() instead of the much more expensive and local
pyg_get_gvariant_type().

--- gi/_gobject/pygtype.c
+++ gi/_gobject/pygtype.c
@@ -725,26 +725,6 @@

     g_value_take_boxed(value, value_array);
     return 0;
-}
-
-static
-PyObject *
-pyg_get_gvariant_type()
-{
-    static PyObject *variant_type = NULL;
-    PyObject *py_module;
-
-    if (variant_type == NULL) {
-	py_module = PyImport_ImportModule ("gi.repository.GLib");
-	if (py_module == NULL)
-	    return NULL;
-
-	variant_type = PyObject_GetAttrString (py_module, "Variant");
-
-	Py_DECREF (py_module);
-    }
-
-    return variant_type;
 }

 /**
@@ -1013,10 +993,9 @@
 	break;
     case G_TYPE_VARIANT:
         {
-            PyObject* variant_type = pyg_get_gvariant_type();
             if (obj == Py_None)
                 g_value_set_variant(value, NULL);
-            else if (variant_type != NULL && PyObject_IsInstance(obj, variant_type))
+            else if (pyg_type_from_object_strict(obj, FALSE) == G_TYPE_VARIANT)
                 g_value_set_variant(value, pyg_boxed_get(obj, GVariant));
             else
                 return -1;


docs: Mention D-Bus reply types are tuples

The g_dbus_connection_call() documentation doesn’t make it clear that
the reply type is always a tuple.

Signed-off-by: Philip Withnall <29c2a2ac2a854b9cf047275aa9de346d096be2e0@endlessm.com>
Reviewed-by: nobody

--- gio/gdbusconnection.c
+++ gio/gdbusconnection.c
@@ -6006,7 +6006,8 @@
  * @method_name: the name of the method to invoke
  * @parameters: (nullable): a #GVariant tuple with parameters for the method
  *     or %NULL if not passing parameters
- * @reply_type: (nullable): the expected type of the reply, or %NULL
+ * @reply_type: (nullable): the expected type of the reply (which will be a
+ *     tuple), or %NULL
  * @flags: flags from the #GDBusCallFlags enumeration
  * @timeout_msec: the timeout in milliseconds, -1 to use the default
  *     timeout or %G_MAXINT for no timeout
@@ -6028,7 +6029,9 @@
  *
  * If @reply_type is non-%NULL then the reply will be checked for having this type and an
  * error will be raised if it does not match.  Said another way, if you give a @reply_type
- * then any non-%NULL return value will be of this type.
+ * then any non-%NULL return value will be of this type. Unless it’s
+ * %G_VARIANT_TYPE_UNIT, the @reply_type will be a tuple containing one or more
+ * values.
  *
  * If the @parameters #GVariant is floating, it is consumed. This allows
  * convenient 'inline' use of g_variant_new(), e.g.:


g_socket_listener_add_any_inet_port is Since 2.24

accidentally committed an old patch without updating.

--- gio/gsocketlistener.c
+++ gio/gsocketlistener.c
@@ -947,7 +947,7 @@
  *
  * Returns: the port number, or 0 in case of failure.
  *
- * Since: 2.22
+ * Since: 2.24
  **/
 guint16
 g_socket_listener_add_any_inet_port (GSocketListener  *listener,


2001-11-21  Marcus Brinkmann  <marcus@g10code.de>

	* gpgmeplug.c: Include config.h only if [HAVE_CONFIG_H].  Do not
	include util.h.
	(deinitialize): Use free, not _gpgme_free.
	(setDirectoryServers): Use calloc, not xtrycalloc.  Use free, not
	_gpgme_free.  Use malloc instead xtrymalloc.
	(appendDirectoryServer): Use realloc, not xtryrealloc.

--- gpgmeplug/gpgmeplug.c
+++ gpgmeplug/gpgmeplug.c
@@ -42,7 +42,9 @@
     \see cryptplug.h
 */

+#ifdef HAVE_CONFIG_H
 #include <config.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -50,7 +52,6 @@
 #include <errno.h>

 #include <gpgme.h>
-#include <util.h>

 #include "cryptplug.h"

@@ -145,10 +146,10 @@
 {
   unsigned int i;
   for( i = 0; i < config.numDirectoryServers; ++i ) {
-    _gpgme_free( (char *)config.directoryServers[i].servername );
-    _gpgme_free( (char *)config.directoryServers[i].description );
+    free( (char *)config.directoryServers[i].servername );
+    free( (char *)config.directoryServers[i].description );
   }
-  _gpgme_free( config.directoryServers );
+  free( config.directoryServers );
 }

@@ -584,17 +585,17 @@
                             const char* description )
 {
   struct DirectoryServer *newServers = NULL;
-  newServers = xtryrealloc( config.directoryServers,
-                         (1+config.numDirectoryServers) * sizeof *newServers );
+  newServers = realloc( config.directoryServers,
+			(1+config.numDirectoryServers) * sizeof *newServers );
   if( newServers ) {
     config.directoryServers = newServers;
     newServers[ config.numDirectoryServers ].servername =
-      xtrymalloc( strlen( servername ) );
+      malloc( strlen( servername ) );
     if( newServers[ config.numDirectoryServers ].servername ) {
       strcpy( (char *)newServers[ config.numDirectoryServers ].servername,
         servername );
       newServers[ config.numDirectoryServers ].description =
-        xtrymalloc( strlen(  description ) );
+        malloc( strlen(  description ) );
       if( newServers[ config.numDirectoryServers ].description ) {
         strcpy( (char *)newServers[ config.numDirectoryServers ].description,
           description );
@@ -610,18 +611,18 @@
   unsigned int i;
   int oldSize = config.numDirectoryServers;
   struct DirectoryServer *newServers = NULL;
-  newServers = xtrycalloc ( size, sizeof *newServers );
+  newServers = calloc ( size, sizeof *newServers );
   if( newServers ) {
     for( i=0; i < oldSize; ++i ) {
-      _gpgme_free( (char *)config.directoryServers[i].servername );
-      _gpgme_free( (char *)config.directoryServers[i].description );
+      free( (char *)config.directoryServers[i].servername );
+      free( (char *)config.directoryServers[i].description );
     }
-    _gpgme_free( config.directoryServers );
+    free( config.directoryServers );
     for( i=0; i < size; ++i ) {
-      newServers[ i ].servername = xtrymalloc( strlen( server[i].servername ) );
+      newServers[ i ].servername = malloc( strlen( server[i].servername ) );
       if( newServers[ i ].servername ) {
         strcpy( (char *)newServers[ i ].servername, server[i].servername );
-        newServers[ i ].description = xtrymalloc( strlen( server[i].description ) );
+        newServers[ i ].description = malloc( strlen( server[i].description ) );
         if( newServers[ i ].description ) {
           strcpy( (char *)newServers[ i ].description, server[i].description );
           newServers[ i ].port = server[i].port;


- Check return value of the encoded keyword before using it.

Pointed out by:	Christian Weisgerber <naddy -at- mips.inka.de>

--- contrib/csup/rcsfile.c
+++ contrib/csup/rcsfile.c
@@ -232,6 +232,7 @@
 {
 	struct delta *d;
 	struct tag *t;
+	const char *keyword;
 	int error;

 	assert(rf != NULL);
@@ -264,10 +265,13 @@
 		return(error);
 	/* Write expand. */
 	if (rf->expand != EXPAND_DEFAULT) {
-		error = proto_printf(wr, "E %s\n",
-		    keyword_encode_expand(rf->expand));
-		if (error)
-			return(error);
+		keyword = keyword_encode_expand(rf->expand);
+		if (keyword != NULL) {
+			error = proto_printf(wr, "E %s\n",
+			    keyword_encode_expand(rf->expand));
+			if (error)
+				return(error);
+		}
 	}

 	/* Write tags to server. */


Disentangle some really grody ifdef logic

--- contrib/htslib/faidx.c
+++ contrib/htslib/faidx.c
@@ -252,19 +252,21 @@
 	sprintf(str, "%s.fai", fn);

 #ifdef _USE_KNETFILE
-    if (strstr(fn, "ftp://") == fn || strstr(fn, "http://") == fn)
-    {
-        fp = download_and_open(str);
-        if ( !fp )
-        {
-            fprintf(stderr, "[fai_load] failed to open remote FASTA index %s\n", str);
-            free(str);
-            return 0;
-        }
-    }
-    else
-#endif
-        fp = fopen(str, "rb");
+  if (strstr(fn, "ftp://") == fn || strstr(fn, "http://") == fn)
+  {
+      fp = download_and_open(str);
+      if ( !fp )
+      {
+          fprintf(stderr, "[fai_load] failed to open remote FASTA index %s\n", str);
+          free(str);
+          return 0;
+      }
+  } else {
+    fp = fopen(str, "rb");
+  }
+#else
+  fp = fopen(str, "rb");
+#endif
 	if (fp == 0) {
 		fprintf(stderr, "[fai_load] build FASTA index.\n");
 		fai_build(fn);


Dike out bits specific to i386.  This pretty much means no kgdb for
non-i386 platforms.

I would however like to see a shared file here.  If a function or two cannot
be shared we should create ${TARGET_ARCH}/kvm-fbsd-${TARGET_ARCH}.c.

--- gnu/usr.bin/binutils/gdb/kvm-fbsd.c
+++ gnu/usr.bin/binutils/gdb/kvm-fbsd.c
@@ -52,11 +52,12 @@
 #endif
 #include <machine/frame.h>

-#if __FreeBSD_version >= 500032 && defined(i386)
 #define _KERNEL
 #include <sys/pcpu.h>
 #undef _KERNEL

+#include <assert.h>
+
 static void kcore_files_info PARAMS ((struct target_ops *));

 static void kcore_close PARAMS ((int));
@@ -113,8 +114,8 @@
 extern struct target_ops kcore_ops;	/* Forward decl */

 /* Non-zero means we are debugging a kernel core file */
-int kernel_debugging = 0;
-int kernel_writablecore = 0;
+int kernel_debugging;
+int kernel_writablecore;

 static char *core_file;
 static int core_kd = -1;
@@ -176,7 +177,7 @@
        switch (frametype) {
        case tf_normal:
                return (this_saved_pc);
-
+#ifdef __i386__
 #define oEIP   offsetof(struct trapframe, tf_eip)

        case tf_trap:
@@ -188,6 +189,7 @@
        case tf_syscall:
                return (read_memory_integer (fr->frame + 8 + oEIP, 4));
 #undef oEIP
+#endif
        }
 }

@@ -897,16 +899,28 @@
       current_ptd = PTD;
     }
   else
+#ifdef __i386__
     current_ptd = pcb.pcb_cr3;
+#else
+  	assert(0);
+#endif

   /*
    * Read the first-level page table (ptd).
    */
+#ifdef __i386__
   v = current_ptd + ( (unsigned)addr >> PDRSHIFT) * sizeof pte;
+#else
+  v = current_ptd + ( (unsigned)addr            ) * sizeof pte;
+#endif
   if (physrd (fd, v, (char *)&pte, sizeof pte) < 0 || (pte&PG_V) == 0)
     return (~0);

+#ifdef __i386__
   if (pte & PG_PS)
+#else
+  if (pte        )
+#endif
     {
       /*
        * No second-level page table; ptd describes one 4MB page.
@@ -914,7 +928,11 @@
        * it cr0, and that the kernel doesn't support 36-bit physical
        * addresses).
        */
+#ifdef __i386__
 #define	PAGE4M_MASK	(NBPDR - 1)
+#else
+#define	PAGE4M_MASK	0
+#endif
 #define	PG_FRAME4M	(~PAGE4M_MASK)
       addr = (pte & PG_FRAME4M) + (addr & PAGE4M_MASK);
     }
@@ -923,11 +941,19 @@
       /*
        * Read the second-level page table.
        */
+#ifdef __i386__
       v = (pte&PG_FRAME) + ((addr >> PAGE_SHIFT)&(NPTEPG-1)) * sizeof pte;
+#else
+      v = (pte         ) + ((addr >> PAGE_SHIFT)&(NPTEPG-1)) * sizeof pte;
+#endif
       if (physrd (fd, v, (char *) &pte, sizeof (pte)) < 0 || (pte&PG_V) == 0)
 	return (~0);

+#ifdef __i386__
       addr = (pte & PG_FRAME) + (addr & PAGE_MASK);
+#else
+      addr = (pte           ) + (addr & PAGE_MASK);
+#endif
     }
 #if 0
   printf ("vtophys (%x) -> %x\n", oldaddr, addr);
@@ -967,15 +993,19 @@
   noreg = 0;
   for (i = 0; i < 3; ++i)		/* eax,ecx,edx */
     supply_register (i, (char *)&noreg);
+#ifdef __i386__
   supply_register (3, (char *)&pcb.pcb_ebx);
   supply_register (SP_REGNUM, (char *)&pcb.pcb_esp);
   supply_register (FP_REGNUM, (char *)&pcb.pcb_ebp);
   supply_register (6, (char *)&pcb.pcb_esi);
   supply_register (7, (char *)&pcb.pcb_edi);
   supply_register (PC_REGNUM, (char *)&pcb.pcb_eip);
+#endif
   for (i = 9; i < 14; ++i)		/* eflags, cs, ss, ds, es, fs */
     supply_register (i, (char *)&noreg);
+#ifdef __i386__
   supply_register (15, (char *)&pcb.pcb_gs);
+#endif

   /* XXX 80387 registers? */
 }
@@ -1024,14 +1054,9 @@

 static struct target_ops kcore_ops;

-#else
-int kernel_debugging = 0;
-#endif
-
 void
 _initialize_kcorelow()
 {
-#if __FreeBSD_version >= 500032 && defined(i386)
   kcore_ops.to_shortname = "kcore";
   kcore_ops.to_longname = "Kernel core dump file";
   kcore_ops.to_doc =
@@ -1053,5 +1078,4 @@
   add_target (&kcore_ops);
   add_com ("proc", class_obscure, set_proc_cmd, "Set current process context");
   add_com ("cpu", class_obscure, set_cpu_cmd, "Set current cpu");
-#endif
-}
+}


compile fix for ray masks for subdiv geometries

--- kernels/xeon/geometry/subdivpatch1cached_intersector1.h
+++ kernels/xeon/geometry/subdivpatch1cached_intersector1.h
@@ -194,8 +194,11 @@
 #endif

         /* ray mask test */
+        const size_t geomID = pre.current_patch->geom;
+        const size_t primID = pre.current_patch->prim;
+        Geometry* geometry = scene->get(geomID);
 #if defined(RTCORE_RAY_MASK)
-        if (geometry->mask & ray.mask) == 0) return;
+        if ((geometry->mask & ray.mask) == 0) return;
 #endif

 	/* calculate hit information */
@@ -214,9 +217,6 @@
 	v = uv[0];
 #endif
 	size_t i = select_min(valid,t);
-        const size_t geomID = pre.current_patch->geom;
-        const size_t primID = pre.current_patch->prim;
-        Geometry* geometry = scene->get(geomID);

         /* intersection filter test */
 #if defined(RTCORE_INTERSECTION_FILTER)
@@ -320,15 +320,15 @@
 #endif

         /* ray mask test */
-#if defined(RTCORE_RAY_MASK)
-        if ((geometry->mask & ray.mask) == 0) return false;
-#endif
-
-        /* intersection filter test */
-#if defined(RTCORE_INTERSECTION_FILTER)
         const size_t geomID = pre.current_patch->geom;
         const size_t primID = pre.current_patch->prim;
         Geometry* geometry = scene->get(geomID);
+#if defined(RTCORE_RAY_MASK)
+        if ((geometry->mask & ray.mask) == 0) return false;
+#endif
+
+        /* intersection filter test */
+#if defined(RTCORE_INTERSECTION_FILTER)
         if (unlikely(geometry->hasOcclusionFilter1()))
         {
           /* calculate hit information */
@@ -491,8 +491,11 @@
 #endif

         /* ray mask test */
+        const size_t geomID = pre.current_patch->geom;
+        const size_t primID = pre.current_patch->prim;
+        Geometry* geometry = scene->get(geomID);
 #if defined(RTCORE_RAY_MASK)
-        if (geometry->mask & ray.mask) == 0) return;
+        if ((geometry->mask & ray.mask) == 0) return;
 #endif

 	/* calculate hit information */
@@ -511,9 +514,6 @@
 	v = uv[0];
 #endif
         size_t i = select_min(valid,t);
-        const size_t geomID = pre.current_patch->geom;
-        const size_t primID = pre.current_patch->prim;
-        Geometry* geometry = scene->get(geomID);

         /* intersection filter test */
 #if defined(RTCORE_INTERSECTION_FILTER)
@@ -623,15 +623,15 @@
 #endif

         /* ray mask test */
-#if defined(RTCORE_RAY_MASK)
-        if ((geometry->mask & ray.mask) == 0) return false;
-#endif
-
-        /* intersection filter test */
-#if defined(RTCORE_INTERSECTION_FILTER)
         const size_t geomID = pre.current_patch->geom;
         const size_t primID = pre.current_patch->prim;
         Geometry* geometry = scene->get(geomID);
+#if defined(RTCORE_RAY_MASK)
+        if ((geometry->mask & ray.mask) == 0) return false;
+#endif
+
+        /* intersection filter test */
+#if defined(RTCORE_INTERSECTION_FILTER)
         if (unlikely(geometry->hasOcclusionFilter1()))
         {
           /* calculate hit information */


Finished with grok/C/CRevEngineer/sizesOfThings.c

 - finished for now
 - added example of %n formatting
 - printf actually returns the number of char printed

--- grok/C/CRevEngineer/sizesOfThings.c
+++ grok/C/CRevEngineer/sizesOfThings.c
@@ -74,7 +74,7 @@
 void myFunc2(void);
 void choose_myFunc(void (*func_ptr)(void));

-int main(void)
+int main(int argc, char *argv[])
 {
     char ch = '1';
     short si = 1;
@@ -183,7 +183,7 @@

     void (*myFunc_ptr)(void);
     void (*anotherFunc_ptr)(void);
-    int (*main_ptr)(void) = &main;
+    int (*main_ptr)(int, char**) = &main;

     myFunc_ptr = &myFunc1;
     anotherFunc_ptr = &myFunc2;
@@ -201,6 +201,27 @@
     printf("difference of function names (same type) = %td\n", myFunc1 - myFunc2);
     printf("difference of function ptrs (different types) = %td\n", (void *)myFunc_ptr - (void *)main_ptr);
     printf("difference of function names (different types) = %td\n", (void *)myFunc1 - (void *)main);
+    if (argc > 1) printf("\n");
+
+    int n;
+
+    for (int jj = 1; jj < argc; ++jj) {
+        printf(" %s %n\n", argv[jj], &n);
+        printf("|");
+        for (int kk = 0; kk < n - 2; ++kk)
+            printf("-");
+        printf("|\n");
+    }
+
+    if (argc > 1) printf("\n");
+
+    for (int jj = 1; jj < argc; ++jj) {
+        n = printf(" %s \n", argv[jj]) - 1;
+        printf(">");
+        for (int kk = 0; kk < n - 2; ++kk)
+            printf("-");
+        printf("<\n");
+    }

     return 0;
 }


rtsp-session-pool: corrected session timeout detection

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

--- gst/rtsp-server/rtsp-session-pool.c
+++ gst/rtsp-server/rtsp-session-pool.c
@@ -519,11 +519,8 @@
 {
   gint timeout;
   GTimeVal now;
-  gint64 tmp;
-
-  tmp = g_source_get_time ((GSource *) psrc);
-  now.tv_sec = tmp / G_USEC_PER_SEC;
-  now.tv_usec = tmp % G_USEC_PER_SEC;
+
+  g_get_current_time (&now);

   timeout = gst_rtsp_session_next_timeout (sess, &now);
   GST_INFO ("%p: next timeout: %d", sess, timeout);


Completion: remove info_toggled_cb()

Completion: remove info_toggled_cb()

Use g_object_bind_property() instead.

--- gtksourceview/gtksourcecompletion.c
+++ gtksourceview/gtksourcecompletion.c
@@ -1072,20 +1072,6 @@
 	}

 	update_window_position (completion);
-}
-
-static void
-info_toggled_cb (GtkToggleButton     *widget,
-		 GtkSourceCompletion *completion)
-{
-	if (gtk_toggle_button_get_active (widget))
-	{
-		gtk_widget_show (completion->priv->info_window);
-	}
-	else
-	{
-		gtk_widget_hide (completion->priv->info_window);
-	}
 }

 static void
@@ -2768,11 +2754,6 @@
 	gtk_window_set_attached_to (GTK_WINDOW (completion->priv->main_window),
 				    GTK_WIDGET (completion->priv->view));

-	g_signal_connect (completion->priv->info_button,
-			  "toggled",
-			  G_CALLBACK (info_toggled_cb),
-			  completion);
-
 	g_object_unref (builder);

 	/* Info window */
@@ -2785,6 +2766,10 @@

 	gtk_window_set_attached_to (GTK_WINDOW (completion->priv->info_window),
 				    GTK_WIDGET (completion->priv->main_window));
+
+	g_object_bind_property (completion->priv->info_button, "active",
+				completion->priv->info_window, "visible",
+				G_BINDING_DEFAULT);

 	/* Default info widget */
 	completion->priv->default_info = gtk_label_new (NULL);


Include John Wier's extended FIFO fix... (and set editor command correctly this time)

--- unichrome/via_swov.c
+++ unichrome/via_swov.c
@@ -2019,6 +2019,7 @@
     if (flags & DDOVER_BOB)
 	deinterlaceMode |= DDOVER_BOB;

+    /* check this is correct place to enable 3259 fifo */
     if ((pVia->ChipId == PCI_CHIP_CLE3122 || pVia->ChipId == PCI_CHIP_VT3259) && (pScrn->currentMode->HDisplay > 1024)) {
 	DBG_DD(ErrorF("UseExtendedFIFO\n"));
 	pVia->swov.gdwUseExtendedFIFO = 1;


i965: Make batch dumping go to stderr, too.

All our other debug goes there.

Reviewed-by: Kenneth Graunke <bd2562f754ec92342f93f61c25d731e290a2ffa8@whitecape.org>

--- src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -143,6 +143,7 @@
 					 batch->used);
    }

+   drm_intel_decode_set_output_file(decode, stderr);
    drm_intel_decode(decode);

    drm_intel_decode_context_free(decode);


i965: Separate miptree creation from auxiliary buffer setup

Currently the logic allocating and setting up miptrees is closely
combined with decision making when to re-allocate buffers in
X-tiled layout and when to associate colors with auxiliary buffers.

These auxiliary buffers are in turn also represented as miptrees
and are created by the same miptree creation logic calling itself
recursively. This means considering in vain if the auxiliary buffers
should be represented in X-tiled layout or if they should be
associated with auxiliary buffers again.
While this is somewhat unnecessary, this doesn't impose any problems
currently. Miptrees for auxiliary buffers are created as simgle-sampled
fusing the consideration for multi-sampled compression auxiliary
buffers. The format in turn is such that is not applicable for
single-sampled fast clears (that would require accompaning auxiliary
buffer).
But once the driver starts to support lossless compression of color
buffers the auxiliary buffer will have a format that would itself
be applicable for lossless compression. This would be rather
difficult and ugly to detect in the current miptree creation logic,
and therefore this patch seeks to separate the association logic
from the general allocation and setup steps.

v2 (Ben):
   - Do not reconsider for X-tiling in intel_miptree_create()
     as it was just forced to Y-tiling in miptree_create().
   - Do not drop checks for allocation failures.

Signed-off-by: Topi Pohjolainen <749697f19798b7f640b17221fd283b903825f071@intel.com>

--- src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -609,17 +609,17 @@
    return size;
 }

-struct intel_mipmap_tree *
-intel_miptree_create(struct brw_context *brw,
-                     GLenum target,
-                     mesa_format format,
-                     GLuint first_level,
-                     GLuint last_level,
-                     GLuint width0,
-                     GLuint height0,
-                     GLuint depth0,
-                     GLuint num_samples,
-                     uint32_t layout_flags)
+static struct intel_mipmap_tree *
+miptree_create(struct brw_context *brw,
+               GLenum target,
+               mesa_format format,
+               GLuint first_level,
+               GLuint last_level,
+               GLuint width0,
+               GLuint height0,
+               GLuint depth0,
+               GLuint num_samples,
+               uint32_t layout_flags)
 {
    struct intel_mipmap_tree *mt;
    mesa_format tex_format = format;
@@ -644,12 +644,8 @@
       return NULL;
    }

-   bool y_or_x = false;
-
-   if (mt->tiling == (I915_TILING_Y | I915_TILING_X)) {
-      y_or_x = true;
+   if (mt->tiling == (I915_TILING_Y | I915_TILING_X))
       mt->tiling = I915_TILING_Y;
-   }

    if (layout_flags & MIPTREE_LAYOUT_ACCELERATED_UPLOAD)
       alloc_flags |= BO_ALLOC_FOR_RENDER;
@@ -682,11 +678,37 @@

    mt->pitch = pitch;

+   return mt;
+}
+
+struct intel_mipmap_tree *
+intel_miptree_create(struct brw_context *brw,
+                     GLenum target,
+                     mesa_format format,
+                     GLuint first_level,
+                     GLuint last_level,
+                     GLuint width0,
+                     GLuint height0,
+                     GLuint depth0,
+                     GLuint num_samples,
+                     uint32_t layout_flags)
+{
+   struct intel_mipmap_tree *mt = miptree_create(
+                                     brw, target, format,
+                                     first_level, last_level,
+                                     width0, height0, depth0, num_samples,
+                                     layout_flags);
+
    /* If the BO is too large to fit in the aperture, we need to use the
     * BLT engine to support it.  Prior to Sandybridge, the BLT paths can't
     * handle Y-tiling, so we need to fall back to X.
     */
-   if (brw->gen < 6 && y_or_x && mt->bo->size >= brw->max_gtt_map_object_size) {
+   if (brw->gen < 6 && mt->bo->size >= brw->max_gtt_map_object_size &&
+       mt->tiling == I915_TILING_Y) {
+      unsigned long pitch = mt->pitch;
+      const uint32_t alloc_flags =
+         (layout_flags & MIPTREE_LAYOUT_ACCELERATED_UPLOAD) ?
+         BO_ALLOC_FOR_RENDER : 0;
       perf_debug("%dx%d miptree larger than aperture; falling back to X-tiled\n",
                  mt->total_width, mt->total_height);


i965/gen6: Force ALL_SLICES_AT_EACH_LOD for separate stencil/hiz

For gen6 we will use the ALL_SLICES_AT_EACH_LOD miptree layout for
separate stencil/hiz. This is needed because gen6 hiz and separate
stencil only support a single miplevel. When accessing the other LODs,
we will program a tile aligned offset for the bo.

PRM Volume 1, Part 1, 7.18.3.7.2 For separate stencil buffer [DevILK]
to [DevSNB]:
 "The separate stencil buffer does not support mip mapping, thus the
  storage for LODs other than LOD 0 is not needed."

We still allocate storage for the other stencil mip-levels within a
single texture, but each mip-level will use non-mip-array spacing.

PRM Volume 2, Part 1, 7.5.3 Hierarchical Depth Buffer
 "[DevSNB]: The hierarchical depth buffer does not support the LOD
  field, it is assumed by hardware to be zero. A separate
  hierarachical depth buffer is required for each LOD used, and the
  corresponding buffer’s state delivered to hardware each time a new
  depth buffer state with modified LOD is delivered."

We allocate storage for the other hiz mip-levels within a single
texture, but each mip-level will use non-mip-array spacing.

Signed-off-by: Jordan Justen <a79006884ba9cf5f4f7fcbb92a15b208780d8c97@intel.com>
Reviewed-by: Topi Pohjolainen <749697f19798b7f640b17221fd283b903825f071@intel.com>
Acked-by: Kenneth Graunke <bd2562f754ec92342f93f61c25d731e290a2ffa8@whitecape.org>

--- src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -379,6 +379,7 @@
        _mesa_get_format_base_format(format) == GL_DEPTH_STENCIL &&
        (brw->must_use_separate_stencil ||
 	(brw->has_separate_stencil && brw_is_hiz_depth_format(brw, format)))) {
+      const bool force_all_slices_at_each_lod = brw->gen == 6;
       mt->stencil_mt = intel_miptree_create(brw,
                                             mt->target,
                                             MESA_FORMAT_S_UINT8,
@@ -390,7 +391,7 @@
                                             true,
                                             num_samples,
                                             INTEL_MIPTREE_TILING_ANY,
-                                            false);
+                                            force_all_slices_at_each_lod);
       if (!mt->stencil_mt) {
 	 intel_miptree_release(&mt);
 	 return NULL;
@@ -1407,6 +1408,7 @@
 			struct intel_mipmap_tree *mt)
 {
    assert(mt->hiz_mt == NULL);
+   const bool force_all_slices_at_each_lod = brw->gen == 6;
    mt->hiz_mt = intel_miptree_create(brw,
                                      mt->target,
                                      mt->format,
@@ -1418,7 +1420,7 @@
                                      true,
                                      mt->num_samples,
                                      INTEL_MIPTREE_TILING_ANY,
-                                     false);
+                                     force_all_slices_at_each_lod);

    if (!mt->hiz_mt)
       return false;


Avoid performing encoding conversion on command tag strings during EndCommand.

Since all current and foreseeable future command tags will be pure ASCII,
there is no need to do conversion on them.  This saves a few cycles and also
avoids polluting otherwise-pristine subtransaction memory contexts, which
is the cause of the backend memory leak exhibited in bug #5302.  (Someday
we'll probably want to have a better method of determining whether
subtransaction contexts need to be kept around, but today is not that day.)

Backpatch to 8.0.  The cycle-shaving aspect of this would work in 7.4
too, but without subtransactions the memory-leak aspect doesn't apply,
so it doesn't seem worth touching 7.4.

--- src/backend/tcop/dest.c
+++ src/backend/tcop/dest.c
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/tcop/dest.c,v 1.76 2010/01/02 16:57:52 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/tcop/dest.c,v 1.77 2010/01/30 20:09:53 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -142,7 +142,11 @@
 	{
 		case DestRemote:
 		case DestRemoteExecute:
-			pq_puttextmessage('C', commandTag);
+			/*
+			 * We assume the commandTag is plain ASCII and therefore
+			 * requires no encoding conversion.
+			 */
+			pq_putmessage('C', commandTag, strlen(commandTag) + 1);
 			break;

 		case DestNone:
@@ -183,7 +187,7 @@
 			if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3)
 				pq_putemptymessage('I');
 			else
-				pq_puttextmessage('I', "");
+				pq_putmessage('I', "", 1);
 			break;

 		case DestNone:


[intel] Report buffer size when allocating with INTEL_DEBUG=bufmgr and TTM.

--- src/mesa/drivers/dri/intel/intel_bufmgr_ttm.c
+++ src/mesa/drivers/dri/intel/intel_bufmgr_ttm.c
@@ -435,7 +435,7 @@
     ttm_buf->relocs = NULL;
     ttm_buf->last_flags = ttm_buf->drm_bo.flags;

-    DBG("bo_create: %p (%s)\n", &ttm_buf->bo, ttm_buf->name);
+    DBG("bo_create: %p (%s) %db\n", &ttm_buf->bo, ttm_buf->name, size);

     return &ttm_buf->bo;
 }


Clean up comments/dead code from relocation buffer change.

--- src/mesa/drivers/dri/intel/intel_bufmgr_ttm.c
+++ src/mesa/drivers/dri/intel/intel_bufmgr_ttm.c
@@ -301,7 +301,6 @@
      * DWORD 0: relocation count
      * DWORD 1: relocation type
      * DWORD 2+3: handle to next relocation list (currently none) 64-bits
-     * DWORD 3: unused
      */
     bo_ttm->reloc_buf_data[0] = 0;
     bo_ttm->reloc_buf_data[1] = I915_RELOC_TYPE_0;
@@ -714,10 +713,6 @@

 	/* Add the target to the validate list */
 	intel_add_validate_buffer(r->target_buf, r->validate_flags);
-
-	/* Update the index of the target in the relocation entry */
-	reloc_entry = bo_ttm->reloc_buf_data + I915_RELOC_HEADER +
-	    i * I915_RELOC0_STRIDE;
     }
 }


radeon: set gl_texture_image::TexFormat field in radeonSetTexBuffer2()

See https://bugs.freedesktop.org/show_bug.cgi?id=31544

Note: this is a candidate for the 7.9 branch

--- src/mesa/drivers/dri/radeon/radeon_texstate.c
+++ src/mesa/drivers/dri/radeon/radeon_texstate.c
@@ -705,18 +705,24 @@
 	t->override_offset = 0;
 	switch (rb->cpp) {
 	case 4:
-		if (texture_format == __DRI_TEXTURE_FORMAT_RGB)
+		if (texture_format == __DRI_TEXTURE_FORMAT_RGB) {
 			t->pp_txformat = tx_table[MESA_FORMAT_RGB888].format;
-		else
+			texImage->TexFormat = MESA_FORMAT_RGB888;
+		}
+		else {
 			t->pp_txformat = tx_table[MESA_FORMAT_ARGB8888].format;
+			texImage->TexFormat = MESA_FORMAT_ARGB8888;
+		}
 		t->pp_txfilter |= tx_table[MESA_FORMAT_ARGB8888].filter;
 		break;
 	case 3:
 	default:
+		texImage->TexFormat = MESA_FORMAT_RGB888;
 		t->pp_txformat = tx_table[MESA_FORMAT_RGB888].format;
 		t->pp_txfilter |= tx_table[MESA_FORMAT_RGB888].filter;
 		break;
 	case 2:
+		texImage->TexFormat = MESA_FORMAT_RGB565;
 		t->pp_txformat = tx_table[MESA_FORMAT_RGB565].format;
 		t->pp_txfilter |= tx_table[MESA_FORMAT_RGB565].filter;
 		break;


r178: - Defer decryption/decompression until we know we'll need it; this stops us from doing post-writeback decryption on chunks we won't need again.  Major performance improvement for small chunksizes.

--- convergent/chunkdata.c
+++ convergent/chunkdata.c
@@ -20,6 +20,7 @@
 	ST_LOAD_META,        /* Loading metadata */
 	ST_META,             /* Have metadata but not data */
 	ST_LOAD_DATA,        /* Loading data */
+	ST_ENCRYPTED,        /* Have metadata and clean, encrypted data */
 	ST_CLEAN,            /* Have metadata and data */
 	ST_DIRTY,            /* Data is dirty */
 	ST_STORE_DATA,       /* Storing data */
@@ -91,6 +92,7 @@
 {
 	switch (state) {
 	case ST_INVALID:
+	case ST_ENCRYPTED:
 	case ST_CLEAN:
 	case ST_ERROR:
 		return 1;
@@ -376,7 +378,6 @@
 	struct convergent_dev *dev=data;
 	struct chunkdata_table *table=dev->chunkdata;
 	struct chunkdata *cd;
-	int error;
 	unsigned long flags;

 	mutex_lock_workqueue(&dev->lock);
@@ -389,27 +390,20 @@
 		list_del_init(&cd->lh_pending_completion);
 		spin_unlock_irqrestore(&table->pending_completion_lock, flags);

-		error=cd->error;
-		/* XXX we have a bit of a problem: we encrypt in-place.  so if
-		   we just did write-back, we need to decrypt again to keep the
-		   data clean. */
-		if (error)
+		if (cd->error) {
 			log(KERN_ERR, "I/O error %s chunk " SECTOR_FORMAT,
 						cd->state == ST_LOAD_DATA ?
 						"reading" : "writing", cd->cid);
-		else
-			if (chunk_tfm(cd, READ))
-				error=-EIO;
-
-		/* XXX arguably we should report write errors to userspace */
-		if (error)
-			transition_error(cd, error);
-		else if (cd->state == ST_LOAD_DATA)
-			transition(cd, ST_CLEAN);
-		else if (cd->state == ST_STORE_DATA)
+			/* XXX arguably we should report write errors to
+			   userspace */
+			transition_error(cd, cd->error);
+		} else if (cd->state == ST_LOAD_DATA) {
+			transition(cd, ST_ENCRYPTED);
+		} else if (cd->state == ST_STORE_DATA) {
 			transition(cd, ST_DIRTY_META);
-		else
+		} else {
 			BUG();
+		}

 		update_chunk(cd);
 		spin_lock_irqsave(&table->pending_completion_lock, flags);
@@ -495,6 +489,7 @@

 		switch (cd->state) {
 		case ST_META:
+		case ST_ENCRYPTED:
 			if (chunk->flags & CHUNK_READ)
 				continue;
 			else
@@ -600,7 +595,10 @@
 	BUG_ON(!(cd->flags & CD_USER));
 	switch (cd->state) {
 	case ST_STORE_META:
-		transition(cd, ST_CLEAN);
+		/* We encrypted the data in-place to do write-back, and if
+		   we won't need this chunk again there's no point in wasting
+		   cycles decrypting it */
+		transition(cd, ST_ENCRYPTED);
 		__end_usermsg(cd);
 		break;
 	default:
@@ -698,6 +696,22 @@
 		}
 		break;
 	case ST_LOAD_DATA:
+		break;
+	case ST_ENCRYPTED:
+		/* Have metadata and encrypted data */
+		if (chunk != NULL) {
+			if (chunk->flags & CHUNK_READ) {
+				/* The first-in-queue needs to be able to
+				   read the chunk */
+				if (chunk_tfm(cd, READ))
+					transition_error(cd, -EIO);
+				else
+					transition(cd, ST_CLEAN);
+				goto again;
+			} else {
+				try_start_io(chunk->parent);
+			}
+		}
 		break;
 	case ST_CLEAN:
 		/* Have metadata and data */


Improved handling of pass for POST requests.

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

--- bin/varnishd/cache_fetch.c
+++ bin/varnishd/cache_fetch.c
@@ -261,9 +261,10 @@
 	int mklen, is_head;
 	struct http_conn htc[1];
 	int i;
-	int content_length;
-	char hdr[20];
-	char *ptr;
+	int content_length, content_written;
+	int read;
+	char *ptr, *endp;
+	char *p = NULL;

 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
 	CHECK_OBJ_NOTNULL(sp->wrk, WORKER_MAGIC);
@@ -293,12 +294,21 @@

 	/* If a POST request was passed to fetch, we must send
 	 * any pipelined bytes to the backend as well */
-	if (!strcmp(http_GetReq(sp->http), "POST")) {
-		sprintf(hdr, "%ccontent-length:", 15);
-		assert(http_GetHdr(sp->http, hdr, &ptr));
-		content_length = atoi(ptr);
-		if (sp->htc->pipeline.b != NULL && content_length > 0)
-			WRK_Write(w, sp->htc->pipeline.b, content_length);
+	if(http_GetHdr(sp->http, H_Content_Length, &ptr)) {
+		endp = ptr + strlen(ptr);
+		content_length = (int)strtol(ptr, &endp, 10);
+		content_written = 0;
+		while (content_written < content_length) {
+			p = malloc(content_length);
+			read = HTC_Read(sp->htc, p, content_length);
+			content_written += WRK_Write(w, p, read);
+			if (WRK_Flush(w)) {
+				VBE_UpdateHealth(sp, vc, -1);
+				VBE_ClosedFd(sp->wrk, vc);
+				return (__LINE__);
+			}
+			free(p);
+		}
 	}

 	if (WRK_Flush(w)) {


i#1551 port to ARM: fix 3 encoding bugs

i#1551 port to ARM: fix 3 encoding bugs

Fix T32.16 encoding error: TYPE_M_POS_REG must have base and index <= r7.

Fix bug in encode_T32_modified_immed_ok() handling immeds like 0x00000100.

Fix encoding bugs in Thumb split-immed shift values: the value was shadowed
and an extra immed was written incorrectly.

Review-URL: https://codereview.appspot.com/205110043

--- core/arch/arm/encode.c
+++ core/arch/arm/encode.c
@@ -905,7 +905,7 @@
                 return false;
         }
     }
-    if (first_one <= 8) /* ROR must be from 8 through 31 */
+    if (first_one < 8) /* ROR must be from 8 through 31 */
         return false;
     /* ROR amount runs from 8 through 31: 8 has 1bcdefgh starting at bit 31. */
     di->mod_imm_enc = ((8 + (31 - first_one)) << 7) | ((val >> (first_one - 7)) & 0x7f);
@@ -1411,7 +1411,9 @@
     case TYPE_M_NEG_REG:
         if (opnd_is_base_disp(opnd) &&
             opnd_get_base(opnd) != REG_NULL &&
+            !(di->T32_16 && opnd_get_base(opnd) > DR_REG_R7) &&
             opnd_get_index(opnd) != REG_NULL &&
+            !(di->T32_16 && opnd_get_index(opnd) > DR_REG_R7) &&
             opnd_get_index_shift(opnd, NULL) == DR_SHIFT_NONE &&
             BOOLS_MATCH(TEST(DR_OPND_NEGATED, opnd_get_flags(opnd)),
                         optype == TYPE_M_NEG_REG) &&
@@ -2211,7 +2213,7 @@
         if (size_temp == OPSZ_5b && di->shift_has_type &&
             di->shift_type_idx == opnum - 1 && di->shift_uses_immed) {
             /* Convert to raw values */
-            ptr_int_t sh2, val;
+            ptr_int_t sh2;
             if (!encode_shift_values(di->shift_type, opnd_get_immed_int(opnd),
                                      &sh2, &val)) {
                 CLIENT_ASSERT(false, "internal encoding error");
@@ -2221,7 +2223,6 @@
                 encode_immed(di, 21, OPSZ_1b, sh2 >> 1, false/*unsigned*/);
             else
                 encode_immed(di, 4, OPSZ_2b, sh2, false/*unsigned*/);
-            encode_immed(di, 7, size_temp, val, false/*unsigned*/);
         } else
             val = get_immed_val_abs(di, opnd);
         if (size_temp == OPSZ_5b) {


Add "recv N" action

Add "recv N" action

--- bin/varnishtest/vtc_http.c
+++ bin/varnishtest/vtc_http.c
@@ -976,6 +976,34 @@
 }

 /**********************************************************************
+ * Receive N characters
+ */
+
+static void
+cmd_http_recv(CMD_ARGS)
+{
+	struct http *hp;
+	int i, n;
+	uint8_t u[32];
+
+	(void)cmd;
+	(void)vl;
+	CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);
+	AN(av[1]);
+	AZ(av[2]);
+	n = strtoul(av[1], NULL, 0);
+	while (n > 0) {
+		i = read(hp->fd, u, n > 32 ? 32 : n);
+		if (i > 0)
+			vtc_dump(hp->vl, 4, "recv", u, i);
+		else
+			vtc_log(hp->vl, hp->fatal, "recv() got %d (%s)", i,
+			    strerror(errno));
+		n -= i;
+	}
+}
+
+/**********************************************************************
  * Send a string
  */

@@ -1307,6 +1335,7 @@
 	{ "rxrespbody",		cmd_http_rxrespbody },
 	{ "gunzip",		cmd_http_gunzip_body },
 	{ "expect",		cmd_http_expect },
+	{ "recv",		cmd_http_recv },
 	{ "send",		cmd_http_send },
 	{ "send_n",		cmd_http_send_n },
 	{ "send_urgent",	cmd_http_send_urgent },


Fix compilation errors.

Fix compilation errors.

--- core/base/inc/Rtypes.h
+++ core/base/inc/Rtypes.h
@@ -228,7 +228,7 @@
 template <typename T>
    class ClassDefGenerateInitInstanceLocalInjector {
       static atomic_TClass_ptr fgIsA;
-      static std::atomic<std::string> fgName;
+      static std::string fgName;
       static std::mutex fgMutex;
    public:
       static void *New(void *p) { return p ? new(p) T : new T; };
@@ -238,13 +238,13 @@
       static void DeleteArray(void *p) { delete[] ((T*)p); }
       static void Destruct(void *p) { ((T*)p)->~T();  }
       static ::ROOT::TGenericClassInfo *GenerateInitInstanceLocal() {
-         T *ptr = 0;
          static ::TVirtualIsAProxy* isa_proxy = new ::TInstrumentedIsAProxy<T>(0);
          static ::ROOT::TGenericClassInfo
             R__instance(T::Class_Name(), T::Class_Version(),
                         T::DeclFileName(), T::DeclFileLine(),
-                        typeid(T), ROOT::Internal::DefineBehavior(ptr, ptr),
+                        typeid(T), ROOT::Internal::DefineBehavior((T*)0, (T*)0),
                         &T::Dictionary, isa_proxy, 0, sizeof(T) );
+         std::lock_guard<std::mutex> guard(fgMutex);
          R__instance.SetNew(&New);
          R__instance.SetNewArray(&NewArray);
          R__instance.SetDelete(&Delete);
@@ -256,7 +256,7 @@
       static TClass *Class() { if (!fgIsA) Dictionary(); return fgIsA; }
       static const char* Name() {
          if (fgName.empty()) {
-            std::lock_guard guard(fgMutex);
+            std::lock_guard<std::mutex> guard(fgMutex);
             if (fgName.empty()) {
                TClassEdit::GetNormalizedName(fgName,
                                              TypeNameExtraction<T>::get());
@@ -267,9 +267,9 @@
    };

    template<typename T>
-   atomic_TClass_ptr ClassDefGenerateInitInstanceLocalInjector<T>::fgIsA = 0;
+   atomic_TClass_ptr ClassDefGenerateInitInstanceLocalInjector<T>::fgIsA{};
    template<typename T>
-   std::atomic<std::string> ClassDefGenerateInitInstanceLocalInjector<T>::fgName{};
+   std::string ClassDefGenerateInitInstanceLocalInjector<T>::fgName{};

 }} // namespace ROOT::Internal
 #endif // R__NO_INLINE_CLASSDEF


Fail tests if the process got a signal.

Fail tests if the process got a signal.

--- bin/varnishtest/vtc_main.c
+++ bin/varnishtest/vtc_main.c
@@ -57,9 +57,6 @@
 #include "vtim.h"
 #include "vct.h"

-#define		MAX_FILESIZE		(1024 * 1024)
-
-
 struct vtc_tst {
 	unsigned		magic;
 #define TST_MAGIC		0x618d8b88
@@ -167,7 +164,7 @@

 	CAST_OBJ_NOTNULL(jp, ve->priv, JOB_MAGIC);

-	// printf("%p %s %d\n", ve, jp->tst->filename, what);
+	// printf("CB %p %s %d\n", ve, jp->tst->filename, what);
 	if (what == 0)
 		AZ(kill(jp->child, SIGKILL)); /* XXX: Timeout */
 	else
@@ -186,10 +183,9 @@
 		t = VTIM_mono() - jp->t0;
 		AZ(close(ve->fd));

-		if (stx)
+		ecode = WTERMSIG(stx);
+		if (ecode == 0)
 			ecode = WEXITSTATUS(stx);
-		else
-			ecode = 0;

 		if (ecode > 1 && vtc_verbosity)
 			printf("%s\n", jp->buf);


Added server and server= to LmProxy in the ruby bindings

--- bindings/ruby/rblm-proxy.c
+++ bindings/ruby/rblm-proxy.c
@@ -75,6 +75,30 @@
 	return Qnil;
 }

+VALUE
+proxy_get_server (VALUE self)
+{
+	LmProxy *proxy = rb_lm_proxy_from_ruby_object (self);
+
+	return rb_str_new2 (lm_proxy_get_server (proxy));
+}
+
+VALUE
+proxy_set_server (VALUE self, VALUE server)
+{
+	LmProxy *proxy = rb_lm_proxy_from_ruby_object (self);
+	VALUE    str_val;
+
+	if (!rb_respond_to (server, rb_intern ("to_s"))) {
+		rb_raise (rb_eArgError, "server should respond to to_s");
+	}
+
+	str_val = rb_funcall (server, rb_intern ("to_s"), 0);
+	lm_proxy_set_server (proxy, StringValuePtr (str_val));
+
+	return Qnil;
+}
+
 extern void
 Init_lm_proxy (VALUE lm_mLM)
 {
@@ -85,5 +109,7 @@
 	rb_define_method (lm_cProxy, "initialize", proxy_initialize, -1);
 	rb_define_method (lm_cProxy, "type", proxy_get_type, 0);
 	rb_define_method (lm_cProxy, "type=", proxy_set_type, 1);
+	rb_define_method (lm_cProxy, "server", proxy_get_server, 0);
+	rb_define_method (lm_cProxy, "server=", proxy_set_server, 1);
 }


plugin_descriptor: fix quotes passed to py_namespace field

--- kernel/include/bs/plugin_descriptor.h
+++ kernel/include/bs/plugin_descriptor.h
@@ -11,6 +11,10 @@

 #if defined(BSPY_EXPORTING) || defined(BSPY_EXPORTING_PLUGIN)
 #include <pybind11/pybind11.h>
+namespace blue_sky { namespace python {
+namespace py = pybind11;
+using namespace pybind11::literals;
+}}
 #endif

 #include "setup_common_api.h"
@@ -94,7 +98,7 @@
 }

 #define BS_PLUGIN_DESCRIPTOR(name, version, description) \
-BS_PLUGIN_DESCRIPTOR_EXT(name, version, description, #name)
+BS_PLUGIN_DESCRIPTOR_EXT(name, version, description, name)

 //! type of get plugin descrptor pointer function
 typedef blue_sky::plugin_descriptor* (*BS_GET_PLUGIN_DESCRIPTOR)();


morton builder performs initial split before splitting loop, performance increased slightly

--- kernels/builders/bvh_builder_morton.h
+++ kernels/builders/bvh_builder_morton.h
@@ -325,7 +325,7 @@
           const unsigned int code_end   = morton[current.end()-1].code;
           unsigned int bitpos = lzcnt(code_start^code_end);

-          /* if all items mapped to same morton code, then create new morton codes for the items */
+          /* if all items mapped to same morton code, then re-create new morton codes for the items */
           if (unlikely(bitpos == 32))
           {
             recreateMortonCodes(current);
@@ -372,19 +372,18 @@
           if (toplevel && current.size() <= singleThreadThreshold)
             progressMonitor(current.size());

-          __aligned(64) range<unsigned> children[MAX_BRANCHING_FACTOR];
-
           /* create leaf node */
           if (unlikely(depth+MIN_LARGE_LEAF_LEVELS >= maxDepth || current.size() <= minLeafSize)) {
             return createLargeLeaf(depth,current,alloc);
           }

           /* fill all children by always splitting the one with the largest surface area */
-          size_t numChildren = 1;
-          children[0] = current;
-
-          do {
-
+          range<unsigned> children[MAX_BRANCHING_FACTOR];
+          split(current,children[0],children[1]);
+          size_t numChildren = 2;
+
+          while (numChildren < branchingFactor)
+          {
             /* find best child with largest number of primitives */
             int bestChild = -1;
             unsigned bestItems = 0;
@@ -403,21 +402,19 @@
             if (bestChild == -1) break;

             /*! split best child into left and right child */
-            __aligned(64) range<unsigned> left, right;
+            range<unsigned> left, right;
             split(children[bestChild],left,right);

             /* add new children left and right */
             children[bestChild] = children[numChildren-1];
             children[numChildren-1] = left;
             children[numChildren+0] = right;
-            numChildren++;
-
-          } while (numChildren < branchingFactor);
+            numChildren++;
+          }

           /* create leaf node if no split is possible */
-          if (unlikely(numChildren == 1)) {
+          if (unlikely(numChildren == 1))
             return createLeaf(current,alloc);
-          }

           /* allocate node */
           auto node = createNode(alloc,numChildren);
@@ -448,7 +445,6 @@
         /* build function */
         ReductionTy build(BuildPrim* src, BuildPrim* tmp, size_t numPrimitives)
         {
-          /* using 4 phases radix sort */
           morton = src;
           radix_sort_u32(src,tmp,numPrimitives,singleThreadThreshold);


gimble: Implement board_is_dts_port

gimble: Implement board_is_dts_port

BUG=none
BRANCH=none
TEST=make -j BOARD=gimble

Signed-off-by: Scott Chao <8cefa9751fac9aaa897ba1213763a96ba8dbd20d@wistron.corp-partner.google.com>
Change-Id: I445701602e1d59e15cd738cb64ca7b4c7ba732f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3026703
Reviewed-by: caveh jalali <08e24a66aefda7a55ca7d73f8903e0fb16eec763@chromium.org>
Reviewed-by: Boris Mittelberg <46897f4fb5cad4b1d5146ad1fd460d7f4825bbf7@google.com>
Commit-Queue: Boris Mittelberg <46897f4fb5cad4b1d5146ad1fd460d7f4825bbf7@google.com>

--- board/gimble/usbc_config.c
+++ board/gimble/usbc_config.c
@@ -279,3 +279,8 @@
 	 * TODO(b/179513527): add USB-C support
 	 */
 }
+
+__override bool board_is_dts_port(int port)
+{
+	return port == USBC_PORT_C0;
+}


Reorganized comments

Reorganized comments

git-svn-id: 78680c43735c8fc1bfd988e787ae5b6171b14100@5603 743f73a2-0892-4f1a-8574-ff7a07c3af4f

--- mex/mexlib.h
+++ mex/mexlib.h
@@ -6,8 +6,11 @@
 extern "C" {
 #endif

-#define TURBLIB_EXIT_ON_ERROR 0
+#define TURBLIB_EXIT_ON_ERROR 0

-#define MEX_MSG_TXT mexWarnMsgTxt /* mexWarnMsgTxt - warn on error; mexErrMsgTxt - exit on error */
+/* MEX function to print error information:
+  mexWarnMsgTxt - warn on error
+  mexErrMsgTxt  - exit on error */
+#define MEX_MSG_TXT mexWarnMsgTxt

 #endif


pk: Allow out == NULL in canonicalize_uuid()

- Allow canonicalize_uuid() to be called with a NULL second argument, which
validates the UUID specified in the first argument but doesn't copy it
anywhere

- Return PK_NOMEM instead of PK_INVALID from canonicalize_uuid() when
appropriate

--- parcelkeeper/util.c
+++ parcelkeeper/util.c
@@ -409,22 +409,27 @@
 {
 	uuid_t *uuid;
 	uuid_rc_t uurc;
-	pk_err_t ret=PK_INVALID;
+	pk_err_t ret;

 	uurc=uuid_create(&uuid);
 	if (uurc) {
 		pk_log(LOG_ERROR, "Can't create UUID object: %s",
 					uuid_error(uurc));
-		return PK_INVALID;
+		return PK_NOMEM;
 	}
 	if (uuid_import(uuid, UUID_FMT_STR, in, strlen(in) + 1)) {
 		pk_log(LOG_ERROR, "Invalid UUID");
+		ret=PK_INVALID;
 		goto out;
 	}
-	uurc=uuid_export(uuid, UUID_FMT_STR, (void *)out, NULL);
-	if (uurc) {
-		pk_log(LOG_ERROR, "Can't format UUID: %s", uuid_error(uurc));
-		goto out;
+	if (out != NULL) {
+		uurc=uuid_export(uuid, UUID_FMT_STR, (void *)out, NULL);
+		if (uurc) {
+			pk_log(LOG_ERROR, "Can't format UUID: %s",
+						uuid_error(uurc));
+			ret=PK_NOMEM;
+			goto out;
+		}
 	}
 	ret=PK_SUCCESS;
 out:


Changed default behaviour for invalid paths to THROW

--- parse/jsd_options.h
+++ parse/jsd_options.h
@@ -26,7 +26,7 @@

 		ParsingOptions(InvalidPropertyHandlingBehaviour invalidPropertyHandler = InvalidPropertyHandlingBehaviour::THROW,
-                       InvalidPathHandlingBehaviour invalidPathHandler = InvalidPathHandlingBehaviour::TAG);
+                       InvalidPathHandlingBehaviour invalidPathHandler = InvalidPathHandlingBehaviour::THROW);
 	};

 	const auto DefaultParserOptions = ParsingOptions{};


Treat missing TR in SoftMask as identity.

--- pdf/pdf_interpret.c
+++ pdf/pdf_interpret.c
@@ -1633,7 +1633,7 @@
 					gstate->luminosity = 0;

 				tr = pdf_dict_gets(val, "TR");
-				if (strcmp(pdf_to_name(tr), "Identity"))
+				if (tr && strcmp(pdf_to_name(tr), "Identity"))
 					fz_warn(ctx, "ignoring transfer function");
 			}
 			else if (pdf_is_name(val) && !strcmp(pdf_to_name(val), "None"))


Fixed for Clang

Fixed for Clang

--- graph/DirectedGraph.h
+++ graph/DirectedGraph.h
@@ -36,8 +36,7 @@
 bool DirectedGraph<Node,Edge>::HasDescendent(const int n,const int d)
 {
   P::NewTraversal();
-  FindCallback<int> findNode;
-  findNode.node = d;
+  FindCallback<int> findNode(d);
   ForwardIterator it;
   return P::_SimpleDFS(n,findNode,it);
 }


Create SEGVbo.h

Create SEGVbo.h

error: pathspec 'graphics/src/SEGVbo.h' did not match any file(s) known to git

--- graphics/src/SEGVbo.h
+++ graphics/src/SEGVbo.h
@@ -0,0 +1,38 @@
+#include <iostream>
+#include <vector>
+
+#ifndef __SEGVBO__
+#define __SEGVBO__
+
+struct SEGVertex
+{
+	SEVector vertex;
+	SEVector normal;
+	float s0, t0;
+};
+
+struct SEGTriangle
+{
+	SEGVertex a;
+	SEGVertex b;
+	SEGVertex c;
+	ushort indices[3];
+};
+
+struct SEGVertexHolder
+{
+	std::vector<SEGTriangle> triangles;
+};
+
+class SEGVbo
+{
+public:
+	SEGVbo(SEGVertexHolder holder);
+	~SEGVbo();
+private:
+	unsigned int vaoID[1];
+	unsigned int vboID[1];
+	SEGVertexHolder holder;
+};
+
+#endif /* define(__SEGVBO__) */


comments for balanced

comments for balanced

--- src/operator_optimizer/cost_based_optimizer.c
+++ src/operator_optimizer/cost_based_optimizer.c
@@ -778,6 +778,7 @@
 	return ycurPath;
 }

+//TODO just use equal
 static boolean
 checkEqual(List *l1, List *l2)
 {
@@ -814,13 +815,15 @@
 	return balancedItvl;
 }

+
 static boolean
 balancedGenerateNextChoice (OptimizerState *state)
 {
 	updateBestPlan(state);
-	int cnt = ((BalancedState *)(state->hook))->count;
-	List *fifoList = ((BalancedState *)(state->hook))->fifo;
-	BalancedInterval *bl = ((BalancedState *)(state->hook))->bl;
+	BalancedState *balSt = (BalancedState *)(state->hook);
+	int cnt = balSt->count;
+	List *fifoList = balSt->fifo;
+	BalancedInterval *bl = balSt->bl;
 	//boolean returnFlag = FALSE;
 	if(cnt == 1)
 	{
@@ -840,13 +843,24 @@
 		}
 		state->curPath = NIL;
 		fifoList = appendToTailOfList(fifoList, copyBalancedInterval(bl));
-
 	}
 	else
 	{
+	    boolean needLowToMid = TRUE;
+	    boolean needMidToHigh = TRUE;
+
+	    // do we need to generate [low,mid]
+	    List *temp = addOne(bl->beginInterval, state->numChoices);
+	    if (equals(state->curPath,temp))
+	        needLowToMid = FALSE;
+	    // do we need to generate [mid,high]
+	    List *temp = addOne(state->curPath, state->numChoices);
+        if (equals(bl->endInterval,temp))
+            needMidToHigh = FALSE;

 		//check if middle equal to low, if not equal return false
 		boolean sameFlag1 = TRUE;
+		//TODO use equal is safe when not the same length
 		FORBOTH(int, l, h, bl->beginInterval, state->curPath)
 		{
 			if(l != h)
@@ -875,6 +889,7 @@
 		bl1->endInterval = copyObject(state->curPath);
 		bl1->previousLH = -1;
 		bl1->numContinues = 0;
+		//TODO  find common prefix length as function/macro
 		FORBOTH(int, l, h, bl1->beginInterval, bl1->endInterval)
 		{
 			if(l == h)
@@ -909,7 +924,7 @@
 		}
         //if true should minus 1
 		else if(sameFlag2 == TRUE){
-		    bl1->endInterval = minusOne(state->curPath, state->numChoices);
+		    bl1->endInterval = minusOne(state->curPath, state->numChoices);//TODO use end one here
 		    //check if need to add to the fifo
 		    List *temp = addOne(bl1->beginInterval, state->numChoices);
 		    boolean eqFlag = checkEqual(temp, bl1->endInterval);
@@ -959,15 +974,15 @@

 		if(fifoList != NIL)
 		{
-			((BalancedState *)(state->hook))->bl = copyBalancedInterval ((BalancedInterval *) getHeadOfList(fifoList));
-		}
-
-	}
-
-	(((BalancedState *)(state->hook))->count) ++;
+			balSt->bl = copyBalancedInterval ((BalancedInterval *) getHeadOfList(fifoList));
+		}
+
+	}
+
+	(balSt->count) ++;
 	state->numChoices = NIL;
 	state->curPath = NIL;
-	((BalancedState *)(state->hook))->fifo = fifoList;
+	balSt->fifo = fifoList;

     return (fifoList != NIL || cnt == 1);


Fixed warning

Fixed warning

--- core/bh_dynamic_list.c
+++ core/bh_dynamic_list.c
@@ -55,7 +55,7 @@
 bh_intp bh_dynamic_list_append(bh_dynamic_list* list)
 {
     if (list->elsize <= 0)
-        return NULL;
+        return -1;

     if (list->count >= list->allocated)
     {


MdePkg/HiiImageEx: Fix incorrect parameter type in GetImageInfo()

In latest UEFI2.6 spec, the type of the fourth parameter in function
GetImageInfo() is "EFI_IMAGE_OUTPUT", but in the header file, it is
"EFI_IMAGE_INPUT". Now correct it to follow the spec.

Cc: Liming Gao <6480311aeeb4b006862f6d13ebabddc03f51e507@intel.com>
Cc: Eric Dong <fa9eeec52367040ac98013bc4b2913db170588f8@intel.com>
Cc: Cecil Sheng <5b1dfedb372b73790b8cb8d9e8324d70d4696878@hpe.com>
Cc: Abner Chang <2d6c573c4d3f0af63370e2ae56167057351c198d@hpe.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <1e8692d8ed8470b17e8ddd7612a0f029768dcb56@intel.com>
Reviewed-by: Liming Gao <6480311aeeb4b006862f6d13ebabddc03f51e507@intel.com>

--- MdePkg/Include/Protocol/HiiImageEx.h
+++ MdePkg/Include/Protocol/HiiImageEx.h
@@ -225,7 +225,7 @@
   IN CONST  EFI_HII_IMAGE_EX_PROTOCOL       *This,
   IN        EFI_HII_HANDLE                  PackageList,
   IN        EFI_IMAGE_ID                    ImageId,
-  OUT       EFI_IMAGE_INPUT                 *Image
+  OUT       EFI_IMAGE_OUTPUT                *Image
   );

 ///


keyboard subrange with octave scaling

keyboard subrange with octave scaling

--- midimotors.c
+++ midimotors.c
@@ -11,8 +11,7 @@

 // http://www.phy.mtu.edu/~suits/notefreqs.html
-const float scale[] = {130.81, 138.59, 146.83, 155.56, 164.81, 174.61, 185.00, 196.00, 207.65, 220.00, 233.08, 246.94};
-int scaleHalfPeriods[12];
+const float baseScale[] = {130.81, 138.59, 146.83, 155.56, 164.81, 174.61, 185.00, 196.00, 207.65, 220.00, 233.08, 246.94};

 // try to play notes on 4 gpio pins simultaneously
@@ -26,8 +25,12 @@
 int multiplier = 180 / 24; // 180 steps per revolution, 24 teeth per gear

 // keep track of midi keys that are down
-#define KEYRANGE 128
+// monitor 37 notes starting at note 60
+#define KEYLOW 60
+#define KEYRANGE 37
 int keys[KEYRANGE];
+unsigned int scaleHalfPeriods[KEYRANGE];
+

 int main(int argc, char **argv) {
@@ -55,10 +58,10 @@

   for (i=0; i<KEYRANGE; i++) {
     keys[i] = 0;
-  }
-
-  for (i=0; i<12; i++) {
-    scaleHalfPeriods[i] = 1000000 / scale[i] / 64;
+
+    scaleHalfPeriods[i] = 1000000 / baseScale[i % 12] / 32;
+    // octave up
+    scaleHalfPeriods[i] >>= (i / 12);
   }

   for (i=0; i<N; i++) {
@@ -97,15 +100,19 @@
         if (snd_midi_event_encode_byte(midiParser, buffer[0], &seqEvent) == 1) {
           if (seqEvent.type==SND_SEQ_EVENT_NOTEON) {
             //printf("NOTE %d %d\n", seqEvent.data.note.note, seqEvent.data.note.velocity);
+            int noteNum = seqEvent.data.note.note;
+            if (noteNum < KEYLOW || noteNum >= KEYLOW+KEYRANGE) break;
             if (seqEvent.data.note.velocity > 0) {
-              keys[seqEvent.data.note.note] = 1;
+              keys[noteNum-KEYLOW] = 1;
             }
             else {
-              keys[seqEvent.data.note.note] = 0;
+              keys[noteNum-KEYLOW] = 0;
             }
           }
           else if (seqEvent.type==SND_SEQ_EVENT_NOTEOFF) {
-            keys[seqEvent.data.note.note] = 0;
+            int noteNum = seqEvent.data.note.note;
+            if (noteNum < KEYLOW || noteNum >= KEYLOW+KEYRANGE) break;
+            keys[noteNum-KEYLOW] = 0;
           }

           int n = 0;
@@ -113,7 +120,8 @@
             if (keys[i]) {
               printf("%d ", i);
               if (n < N) {
-                halfPeriods[n] = scaleHalfPeriods[i % 12];
+                halfPeriods[n] = scaleHalfPeriods[i];
+                printf("(%d) ", scaleHalfPeriods[i]);
                 n++;
               }
             }


flvdemux: specify we only output raw AAC in template caps

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

--- gst/flv/gstflvdemux.c
+++ gst/flv/gstflvdemux.c
@@ -59,7 +59,7 @@
     GST_STATIC_CAPS
     ("audio/x-adpcm, layout = (string) swf, channels = (int) { 1, 2 }, rate = (int) { 5512, 11025, 22050, 44100 }; "
         "audio/mpeg, mpegversion = (int) 1, layer = (int) 3, channels = (int) { 1, 2 }, rate = (int) { 5512, 8000, 11025, 22050, 44100 }, parsed = (boolean) TRUE; "
-        "audio/mpeg, mpegversion = (int) 4, framed = (boolean) TRUE; "
+        "audio/mpeg, mpegversion = (int) 4, stream-format = (string) raw, framed = (boolean) TRUE; "
         "audio/x-nellymoser, channels = (int) { 1, 2 }, rate = (int) { 5512, 8000, 11025, 16000, 22050, 44100 }; "
         "audio/x-raw-int, endianness = (int) LITTLE_ENDIAN, channels = (int) { 1, 2 }, width = (int) 8, depth = (int) 8, rate = (int) { 5512, 11025, 22050, 44100 }, signed = (boolean) FALSE; "
         "audio/x-raw-int, endianness = (int) LITTLE_ENDIAN, channels = (int) { 1, 2 }, width = (int) 16, depth = (int) 16, rate = (int) { 5512, 11025, 22050, 44100 }, signed = (boolean) TRUE; "


gst/quicktime/atoms.c: Fix mj2 sample description metadata construction.

Original commit message from CVS:
* gst/quicktime/atoms.c: (build_jp2h_extension):
Fix mj2 sample description metadata construction.

--- gst/quicktime/atoms.c
+++ gst/quicktime/atoms.c
@@ -2895,7 +2895,7 @@
   } else
     return FALSE;

-  buf = gst_buffer_new_and_alloc (22 + 12);
+  buf = gst_buffer_new_and_alloc (22 + 15);
   data = GST_BUFFER_DATA (buf);

   /* ihdr = image header box */
@@ -2917,7 +2917,7 @@

   /* colour specification box */
   data += 22;
-  GST_WRITE_UINT32_BE (data, 12);
+  GST_WRITE_UINT32_BE (data, 15);
   GST_WRITE_UINT32_LE (data + 4, GST_MAKE_FOURCC ('c', 'o', 'l', 'r'));
   /* specification method: enumerated */
   GST_WRITE_UINT8 (data + 8, 0x1);
@@ -2926,7 +2926,7 @@
   /* approximation; reserved */
   GST_WRITE_UINT8 (data + 10, 0x0);
   /* enumerated colourspace */
-  GST_WRITE_UINT8 (data + 11, cenum);
+  GST_WRITE_UINT32_BE (data + 11, cenum);

   atom_data = atom_data_new_from_gst_buffer (FOURCC_jp2h, buf);
   gst_buffer_unref (buf);


Migrate ::StringPiece to absl::string_view. PiperOrigin-RevId: 222828687

--- tensorflow/core/platform/regexp.h
+++ tensorflow/core/platform/regexp.h
@@ -16,6 +16,7 @@
 #ifndef TENSORFLOW_PLATFORM_REGEXP_H_
 #define TENSORFLOW_PLATFORM_REGEXP_H_

+#include "absl/strings/string_view.h"
 #include "tensorflow/core/platform/platform.h"
 #include "tensorflow/core/platform/types.h"

@@ -23,7 +24,7 @@
     defined(GOOGLE_RE2)
 #include "tensorflow/core/platform/google/build_config/re2.h"
 namespace tensorflow {
-typedef ::StringPiece RegexpStringPiece;
+typedef absl::string_view RegexpStringPiece;
 }  // namespace tensorflow

 #else


rtspsrc: avoid seek DISCONT when only rate changes in same direction

Not setting DISCONT avoids a noticable delay when seeking
with only rate changing, in the same direction as current
rate.

--- gst/rtsp/gstrtspsrc.c
+++ gst/rtsp/gstrtspsrc.c
@@ -2751,7 +2751,7 @@
   gdouble rate;
   GstFormat format;
   GstSeekFlags flags;
-  GstSeekType cur_type = GST_SEEK_TYPE_NONE, stop_type;
+  GstSeekType cur_type = GST_SEEK_TYPE_NONE, stop_type = GST_SEEK_TYPE_NONE;
   gint64 cur, stop;
   gboolean flush, server_side_trickmode;
   gboolean update;
@@ -2759,11 +2759,15 @@
   GstSegment seeksegment = { 0, };
   GList *walk;
   const gchar *seek_style = NULL;
+  gboolean rate_change_only = FALSE;
+  gboolean rate_change_same_direction = FALSE;

   GST_DEBUG_OBJECT (src, "doing seek with event %" GST_PTR_FORMAT, event);

   gst_event_parse_seek (event, &rate, &format, &flags,
       &cur_type, &cur, &stop_type, &stop);
+  rate_change_only = cur_type == GST_SEEK_TYPE_NONE
+      && stop_type == GST_SEEK_TYPE_NONE;

   /* we need TIME format */
   if (format != src->segment.format)
@@ -2818,6 +2822,7 @@
    * right values in the segment to perform the seek */
   GST_DEBUG_OBJECT (src, "configuring seek");
   seeksegment.duration = GST_CLOCK_TIME_NONE;
+  rate_change_same_direction = (rate * seeksegment.rate) > 0;
   gst_segment_do_seek (&seeksegment, rate, format, flags,
       cur_type, cur, stop_type, stop, &update);

@@ -2861,11 +2866,13 @@
   GST_DEBUG_OBJECT (src, "Creating newsegment from %" G_GINT64_FORMAT
       " to %" G_GINT64_FORMAT, src->segment.position, stop);

-  /* mark discont */
-  GST_DEBUG_OBJECT (src, "mark DISCONT, we did a seek to another position");
-  for (walk = src->streams; walk; walk = g_list_next (walk)) {
-    GstRTSPStream *stream = (GstRTSPStream *) walk->data;
-    stream->discont = TRUE;
+  /* mark discont when needed */
+  if (!(rate_change_only && rate_change_same_direction)) {
+    GST_DEBUG_OBJECT (src, "mark DISCONT, we did a seek to another position");
+    for (walk = src->streams; walk; walk = g_list_next (walk)) {
+      GstRTSPStream *stream = (GstRTSPStream *) walk->data;
+      stream->discont = TRUE;
+    }
   }

   /* and continue playing if needed. If we are not acting as a live source,


misc/debug.h: use __attribute__ instead of __attribute in WARN_UNUSED so we don't confuse KDevelop

--- misc/debug.h
+++ misc/debug.h
@@ -115,7 +115,7 @@
 #endif

 #ifdef __GNUC__
-    #define WARN_UNUSED __attribute((warn_unused_result))
+    #define WARN_UNUSED __attribute__((warn_unused_result))
 #else
     #define WARN_UNUSED
 #endif


rtspsrc: update for gst_element_make_from_uri() changes

--- gst/rtsp/gstrtspsrc.c
+++ gst/rtsp/gstrtspsrc.c
@@ -1517,7 +1517,7 @@
       tmp_rtp >= src->client_port_range.max)
     goto no_ports;

-  udpsrc0 = gst_element_make_from_uri (GST_URI_SRC, host, NULL);
+  udpsrc0 = gst_element_make_from_uri (GST_URI_SRC, host, NULL, NULL);
   if (udpsrc0 == NULL)
     goto no_udp_protocol;
   g_object_set (G_OBJECT (udpsrc0), "port", tmp_rtp, "reuse", FALSE, NULL);
@@ -1566,7 +1566,7 @@
   }

   /* allocate port+1 for RTCP now */
-  udpsrc1 = gst_element_make_from_uri (GST_URI_SRC, host, NULL);
+  udpsrc1 = gst_element_make_from_uri (GST_URI_SRC, host, NULL, NULL);
   if (udpsrc1 == NULL)
     goto no_udp_rtcp_protocol;

@@ -2675,7 +2675,8 @@
   /* creating UDP source for RTP */
   if (min != -1) {
     uri = g_strdup_printf ("udp://%s:%d", destination, min);
-    stream->udpsrc[0] = gst_element_make_from_uri (GST_URI_SRC, uri, NULL);
+    stream->udpsrc[0] =
+        gst_element_make_from_uri (GST_URI_SRC, uri, NULL, NULL);
     g_free (uri);
     if (stream->udpsrc[0] == NULL)
       goto no_element;
@@ -2690,7 +2691,8 @@
   /* creating another UDP source for RTCP */
   if (max != -1) {
     uri = g_strdup_printf ("udp://%s:%d", destination, max);
-    stream->udpsrc[1] = gst_element_make_from_uri (GST_URI_SRC, uri, NULL);
+    stream->udpsrc[1] =
+        gst_element_make_from_uri (GST_URI_SRC, uri, NULL, NULL);
     g_free (uri);
     if (stream->udpsrc[1] == NULL)
       goto no_element;
@@ -2817,7 +2819,8 @@
         rtp_port);

     uri = g_strdup_printf ("udp://%s:%d", destination, rtp_port);
-    stream->udpsink[0] = gst_element_make_from_uri (GST_URI_SINK, uri, NULL);
+    stream->udpsink[0] =
+        gst_element_make_from_uri (GST_URI_SINK, uri, NULL, NULL);
     g_free (uri);
     if (stream->udpsink[0] == NULL)
       goto no_sink_element;
@@ -2869,7 +2872,8 @@
         rtcp_port);

     uri = g_strdup_printf ("udp://%s:%d", destination, rtcp_port);
-    stream->udpsink[1] = gst_element_make_from_uri (GST_URI_SINK, uri, NULL);
+    stream->udpsink[1] =
+        gst_element_make_from_uri (GST_URI_SINK, uri, NULL, NULL);
     g_free (uri);
     if (stream->udpsink[1] == NULL)
       goto no_sink_element;


mm/hugetlb: use pmd_page() in follow_huge_pmd()

Commit 61f77eda9bbf ("mm/hugetlb: reduce arch dependent code around
follow_huge_*") broke follow_huge_pmd() on s390, where pmd and pte
layout differ and using pte_page() on a huge pmd will return wrong
results.  Using pmd_page() instead fixes this.

All architectures that were touched by that commit have pmd_page()
defined, so this should not break anything on other architectures.

Fixes: 61f77eda "mm/hugetlb: reduce arch dependent code around follow_huge_*"
Signed-off-by: Gerald Schaefer <7a67bf9a8691f9f1ca8ce9577e14c37413ea5f58@de.ibm.com>
Acked-by: Naoya Horiguchi <8e7a128cd0264d3269a891fb3e87507c2985f8af@ah.jp.nec.com>
Cc: Hugh Dickins <d3abdf3e2800e6cb849f11b81e6eb50b34d96431@google.com>
Cc: Michal Hocko <829500b200af6c2a0eca4dfd5c388e6b8fbe8dc6@suse.cz>, Andrea Arcangeli <aarcange@redhat.com>
Cc: Martin Schwidefsky <52616596d8f5df0d597e85ab515377f92f939c68@de.ibm.com>
Acked-by: David Rientjes <d8cd2994e15bc61ddb2b113030bda55eebc3a0fe@google.com>
Cc: <4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@vger.kernel.org>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>


mm: swap: mark swap pages writeback before queueing for direct IO

As pointed out by Andrew Morton, the swap-over-NFS writeback is not
setting PageWriteback before it is queued for direct IO.  While swap
pages do not participate in BDI or process dirty accounting and the IO
is synchronous, the writeback bit is still required and not setting it
in this case was an oversight.  swapoff depends on the page writeback to
synchronoise all pending writes on a swap page before it is reused.
Swapcache freeing and reuse depend on checking the PageWriteback under
lock to ensure the page is safe to reuse.

Direct IO handlers and the direct IO handler for NFS do not deal with
PageWriteback as they are synchronous writes.  In the case of NFS, it
schedules pages (or a page in the case of swap) for IO and then waits
synchronously for IO to complete in nfs_direct_write().  It is
recognised that this is a slowdown from normal swap handling which is
asynchronous and uses a completion handler.  Shoving PageWriteback
handling down into direct IO handlers looks like a bad fit to handle the
swap case although it may have to be dealt with some day if swap is
converted to use direct IO in general and bmap is finally done away
with.  At that point it will be necessary to refit asynchronous direct
IO with completion handlers onto the swap subsystem.

As swapcache currently depends on PageWriteback to protect against
races, this patch sets PageWriteback under the page lock before queueing
it for direct IO.  It is cleared when the direct IO handler returns.  IO
errors are treated similarly to the direct-to-bio case except PageError
is not set as in the case of swap-over-NFS, it is likely to be a
transient error.

It was asked what prevents such a page being reclaimed in parallel.
With this patch applied, such a page will now be skipped (most of the
time) or blocked until the writeback completes.  Reclaim checks
PageWriteback under the page lock before calling try_to_free_swap and
the page lock should prevent the page being requeued for IO before it is
freed.

This and Jerome's related patch should considered for -stable as far
back as 3.6 when swap-over-NFS was introduced.

[5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org: use pr_err_ratelimited()]
[5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org: remove hopefully-unneeded cast in printk]
Signed-off-by: Mel Gorman <39ea6a09710987173e32e37c86918024a0f441c1@suse.de>
Cc: Jerome Marchand <d3643b417d7bb29446cdadf5ebe2f94cac95db45@redhat.com>
Cc: Hugh Dickins <d3abdf3e2800e6cb849f11b81e6eb50b34d96431@google.com>
Cc: <4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@vger.kernel.org>	[3.6+]
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- mm/page_io.c
+++ mm/page_io.c
@@ -223,6 +223,7 @@
 		kiocb.ki_left = PAGE_SIZE;
 		kiocb.ki_nbytes = PAGE_SIZE;

+		set_page_writeback(page);
 		unlock_page(page);
 		ret = mapping->a_ops->direct_IO(KERNEL_WRITE,
 						&kiocb, &iov,
@@ -232,8 +233,22 @@
 			count_vm_event(PSWPOUT);
 			ret = 0;
 		} else {
+			/*
+			 * In the case of swap-over-nfs, this can be a
+			 * temporary failure if the system has limited
+			 * memory for allocating transmit buffers.
+			 * Mark the page dirty and avoid
+			 * rotate_reclaimable_page but rate-limit the
+			 * messages but do not flag PageError like
+			 * the normal direct-to-bio case as it could
+			 * be temporary.
+			 */
 			set_page_dirty(page);
+			ClearPageReclaim(page);
+			pr_err_ratelimited("Write error on dio swapfile (%Lu)\n",
+				page_file_offset(page));
 		}
+		end_page_writeback(page);
 		return ret;
 	}


mm: vmalloc allocator off by one

mm: vmalloc allocator off by one

Fix off by one bug in the KVA allocator that can leave gaps in the address
space.

Signed-off-by: Nick Piggin <24829078df5003d9dd1dd871ca2aeb0b1cf95ef4@suse.de>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- mm/vmalloc.c
+++ mm/vmalloc.c
@@ -362,7 +362,7 @@
 				goto found;
 		}

-		while (addr + size >= first->va_start && addr + size <= vend) {
+		while (addr + size > first->va_start && addr + size <= vend) {
 			addr = ALIGN(first->va_end + PAGE_SIZE, align);

 			n = rb_next(&first->rb_node);


修复小bug

修复小bug

--- core/includes/spider.h
+++ core/includes/spider.h
@@ -5,6 +5,7 @@
 #include "downloader.h"
 #include "pageProcesser.h"
 #include "utils.h"
+#include "cJSON.h"

 #define DOWNLOAD 1
 #define SAVE     0


Water: Fix outline color for rectangles which are also filled, use dfb_gfxcard_fillquadrangles() for quadrangles.

--- interfaces/IWater/elements.c
+++ interfaces/IWater/elements.c
@@ -456,9 +456,6 @@
           if (flags & WEF_DRAW) {
                D_DEBUG_AT( IWater_TEST_Elem, "  -> DRAW + FILL\n" );

-               SetWaterColor( state, &state->attributes[WAT_DRAW_COLOR].color );
-               SetWaterColor( state, &state->attributes[WAT_FILL_COLOR].color );
-
                if (TEST_ANY_TRANSFORM( &state->attributes[WAT_RENDER_TRANSFORM].transform )) {
                     for (i=0; i<n; i++) {
                          int          num;
@@ -475,6 +472,8 @@

                          D_DEBUG_AT( IWater_TEST_Elem, "  -> inner %4d,%4d - %4dx%4d [%d]\n", DFB_RECTANGLE_VALS( &rects[i] ), i );

+                         SetWaterColor( state, &state->attributes[WAT_FILL_COLOR].color );
+
                          dfb_gfxcard_fillrectangles( &rects[i], 1, &state->state );

@@ -485,17 +484,23 @@
                               D_DEBUG_AT( IWater_TEST_Elem, "  -> %4d,%4d - %4dx%4d [%d]\n", DFB_RECTANGLE_VALS( &outlines[l] ), l );
 #endif

+                         SetWaterColor( state, &state->attributes[WAT_DRAW_COLOR].color );
+
                          dfb_gfxcard_fillrectangles( &outlines[0], num, &state->state );
                     }
                }
                else {
                     for (i=0; i<n; i++) {
+                         SetWaterColor( state, &state->attributes[WAT_DRAW_COLOR].color );
+
                          dfb_gfxcard_drawrectangle( &rects[i], &state->state );

                          rects[i].x += 1;
                          rects[i].y += 1;
                          rects[i].w -= 2;
                          rects[i].h -= 2;
+
+                         SetWaterColor( state, &state->attributes[WAT_FILL_COLOR].color );

                          dfb_gfxcard_fillrectangles( &rects[i], 1, &state->state );
                     }
@@ -704,9 +709,6 @@
           if (flags & WEF_DRAW) {
                D_DEBUG_AT( IWater_TEST_Elem, "  -> DRAW + FILL\n" );

-               SetWaterColor( state, &state->attributes[WAT_DRAW_COLOR].color );
-               SetWaterColor( state, &state->attributes[WAT_FILL_COLOR].color );
-
                if (TEST_ANY_TRANSFORM( &state->attributes[WAT_RENDER_TRANSFORM].transform )) {
                     for (i=0; i<n; i++) {
                          int          num;
@@ -723,6 +725,7 @@

                          D_DEBUG_AT( IWater_TEST_Elem, "  -> inner %4d,%4d - %4dx%4d [%d]\n", DFB_RECTANGLE_VALS( &rects[i] ), i );

+                         SetWaterColor( state, &state->attributes[WAT_FILL_COLOR].color );
                          dfb_gfxcard_fillrectangles( &rects[i], 1, &state->state );

@@ -733,6 +736,7 @@
                               D_DEBUG_AT( IWater_TEST_Elem, "  -> %4d,%4d - %4dx%4d [%d]\n", DFB_RECTANGLE_VALS( &outlines[l] ), l );
 #endif

+                         SetWaterColor( state, &state->attributes[WAT_DRAW_COLOR].color );
                          dfb_gfxcard_fillrectangles( &outlines[0], num, &state->state );
                     }
                }
@@ -752,8 +756,6 @@
           else {
                D_DEBUG_AT( IWater_TEST_Elem, "  -> FILL only\n" );

-               SetWaterColor( state, &state->attributes[WAT_FILL_COLOR].color );
-
                if (TEST_ANY_TRANSFORM( &state->attributes[WAT_RENDER_TRANSFORM].transform )) {
                     TEST_Transform_Rectangles( &state->attributes[WAT_RENDER_TRANSFORM].transform, rects, n );

@@ -764,6 +766,7 @@
 #endif
                }

+               SetWaterColor( state, &state->attributes[WAT_FILL_COLOR].color );
                dfb_gfxcard_fillrectangles( &rects[0], n, &state->state );
           }
      }
@@ -973,6 +976,7 @@
                         unsigned int              num_values )
 {
      int         i, n;
+#if 0
      DFBTriangle tris[num_values/8 * 2];

      D_DEBUG_AT( IWater_TEST_Elem, "%s( %p [%u] )\n", __FUNCTION__, values, num_values );
@@ -1013,7 +1017,37 @@
      SetWaterColor( state, &state->attributes[WAT_FILL_COLOR].color );

      dfb_gfxcard_filltriangles( tris, n, &state->state );
-
+#else
+     DFBPoint points[num_values/2];
+
+     D_DEBUG_AT( IWater_TEST_Elem, "%s( %p [%u] )\n", __FUNCTION__, values, num_values );
+
+     for (n=0, i=0; i<num_values; n++, i+=2) {
+          points[n].x = values[i+0].i;
+          points[n].y = values[i+1].i;
+     }
+
+     D_DEBUG_AT( IWater_TEST_Elem, "  -> %d points\n", n );
+
+     if (!n)
+          return DFB_OK;
+
+#if D_DEBUG_ENABLED
+     for (i=0; i<n; i++)
+          D_DEBUG_AT( IWater_TEST_Elem, "  -> %4d,%4d [%d]\n", DFB_POINT_VALS( &points[i] ), i );
+#endif
+
+     TEST_Transform_Points( &state->attributes[WAT_RENDER_TRANSFORM].transform, points, n );
+
+#if D_DEBUG_ENABLED
+     for (i=0; i<n; i++)
+          D_DEBUG_AT( IWater_TEST_Elem, "  -> %4d,%4d [%d]\n", DFB_POINT_VALS( &points[i] ), i );
+#endif
+
+     SetWaterColor( state, &state->attributes[WAT_FILL_COLOR].color );
+
+     dfb_gfxcard_fillquadrangles( points, n / 4, &state->state );
+#endif
      return DFB_OK;
 }


- reference correct variable in comment

- reference correct variable in comment

ok tedu@

--- ufs/ufs/ufs_dirhash.c
+++ ufs/ufs/ufs_dirhash.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ufs_dirhash.c,v 1.20 2008/06/12 06:58:40 deraadt Exp $	*/
+/* $OpenBSD: ufs_dirhash.c,v 1.21 2009/08/20 19:18:05 jasper Exp $	*/
 /*
  * Copyright (c) 2001, 2002 Ian Dowse.  All rights reserved.
  *
@@ -380,7 +380,7 @@
 			/*
 			 * We found an entry with the expected offset. This
 			 * is probably the entry we want, but if not, the
-			 * code below will turn off seqoff and retry.
+			 * code below will turn off seqopt and retry.
 			 */
 			slot = i;
 		} else


trayicon-x11: Fix warnings when visual is not available.

This fixes a regression introduced in commit
b1a1685a33eca16979e63d79915395af0b36. gdk_visual_get_*_pixel_details()
should not be called with a NULL visual.

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

--- gtk/gtktrayicon-x11.c
+++ gtk/gtktrayicon-x11.c
@@ -336,7 +336,6 @@
   gulong nitems;
   gulong bytes_after;
   int error, result;
-  GdkVisual *visual;

   g_assert (icon->priv->manager_window != None);

@@ -351,18 +350,25 @@
 			       &bytes_after, &(prop.prop_ch));
   error = gdk_error_trap_pop ();

-  visual = NULL;
-
   if (!error && result == Success &&
       type == XA_VISUALID && nitems == 1 && format == 32)
     {
-      VisualID visual_id = prop.prop[0];
+      VisualID visual_id;
+      GdkVisual *visual;
+
+      visual_id = prop.prop[0];
       visual = gdk_x11_screen_lookup_visual (screen, visual_id);
-    }
-
-  icon->priv->manager_visual = visual;
-  icon->priv->manager_visual_rgba = visual != NULL &&
-    (visual->red_prec + visual->blue_prec + visual->green_prec < visual->depth);
+
+      icon->priv->manager_visual = visual;
+      icon->priv->manager_visual_rgba = visual != NULL &&
+        (visual->red_prec + visual->blue_prec + visual->green_prec < visual->depth);
+    }
+  else
+    {
+      icon->priv->manager_visual = NULL;
+      icon->priv->manager_visual_rgba = FALSE;
+    }
+

   /* For the background-relative hack we use when we aren't using a real RGBA
    * visual, we can't be double-buffered */