Add unit test for daap_record_cmp_by_album

Signed-off-by: W. Michael Petullo <a17fed27eaa842282862ff7c1b9c8395a26ac320@flyn.org>

--- libdmapsharing/daap-record.c
+++ libdmapsharing/daap-record.c
@@ -17,6 +17,8 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
+
+#include "config.h"

 #include <libdmapsharing/daap-record.h>
 #include <libdmapsharing/dmap-enums.h>
@@ -250,3 +252,96 @@
 	g_free (sort_album_b);
 	return ret;
 }
+
+#ifdef HAVE_CHECK
+
+#include <check.h>
+#include <libdmapsharing/test-daap-record.h>
+#include <libdmapsharing/test-dmap-db.h>
+
+START_TEST(daap_record_cmp_by_album_test)
+{
+	gint id;
+	gchar *album;
+	TestDAAPRecord *record;
+	GList *records = NULL;
+	DMAPDb *db = DMAP_DB(test_dmap_db_new());
+
+	/* Create records, add to database, add identifiers to list. */
+	record = test_daap_record_new();
+	g_object_set(record, "songalbum", "a", NULL);
+	g_object_set(record, "sort-album", "a", NULL);
+	id = dmap_db_add(db, DMAP_RECORD(record));
+	g_object_unref(record);
+	records = g_list_append (records, GINT_TO_POINTER(id));
+
+	record = test_daap_record_new();
+	g_object_set(record, "songalbum",  "c", NULL);
+	g_object_set(record, "sort-album", "c", NULL);
+	id = dmap_db_add(db, DMAP_RECORD(record));
+	g_object_unref(record);
+	records = g_list_append (records, GINT_TO_POINTER(id));
+
+	record = test_daap_record_new();
+	g_object_set(record, "songalbum",  "b", NULL);
+	g_object_set(record, "sort-album", "b", NULL);
+	id = dmap_db_add(db, DMAP_RECORD(record));
+	g_object_unref(record);
+	records = g_list_append (records, GINT_TO_POINTER(id));
+
+	/* Check list of record identifiers is not yet sorted (a, c, b). */
+	id = GPOINTER_TO_INT(g_list_nth_data(records, 0));
+	record = TEST_DAAP_RECORD(dmap_db_lookup_by_id(db, id));
+	g_object_get(record, "songalbum", &album, NULL);
+	ck_assert_str_eq("a", album);
+	g_object_unref(record);
+	g_free(album);
+
+	id = GPOINTER_TO_INT(g_list_nth_data(records, 1));
+	record = TEST_DAAP_RECORD(dmap_db_lookup_by_id(db, id));
+	g_object_get(record, "songalbum", &album, NULL);
+	ck_assert_str_eq("c", album);
+	g_object_unref(record);
+	g_free(album);
+
+	id = GPOINTER_TO_INT(g_list_nth_data(records, 2));
+	record = TEST_DAAP_RECORD(dmap_db_lookup_by_id(db, id));
+	g_object_get(record, "songalbum", &album, NULL);
+	ck_assert_str_eq("b", album);
+	g_object_unref(record);
+	g_free(album);
+
+	records = g_list_sort_with_data(records,
+	                               (GCompareDataFunc) daap_record_cmp_by_album,
+	                                db);
+
+	/* Check list of record identifiers is now sorted (a, b, c). */
+	id = GPOINTER_TO_INT(g_list_nth_data(records, 0));
+	record = TEST_DAAP_RECORD(dmap_db_lookup_by_id(db, id));
+	g_object_get(record, "songalbum", &album, NULL);
+	ck_assert_str_eq("a", album);
+	g_object_unref(record);
+	g_free(album);
+
+	id = GPOINTER_TO_INT(g_list_nth_data(records, 1));
+	record = TEST_DAAP_RECORD(dmap_db_lookup_by_id(db, id));
+	g_object_get(record, "songalbum", &album, NULL);
+	ck_assert_str_eq("b", album);
+	g_object_unref(record);
+	g_free(album);
+
+	id = GPOINTER_TO_INT(g_list_nth_data(records, 2));
+	record = TEST_DAAP_RECORD(dmap_db_lookup_by_id(db, id));
+	g_object_get(record, "songalbum", &album, NULL);
+	ck_assert_str_eq("c", album);
+	g_object_unref(record);
+	g_free(album);
+
+	g_list_free(records);
+	g_object_unref(db);
+}
+END_TEST
+
+#include "daap-record-suite.c"
+
+#endif


Fix function-attributes test case to not rely on llvm-gcc.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@56734 91177308-0d34-0410-b5e6-96231b3b80d8

--- test/CodeGen/function-attributes.c
+++ test/CodeGen/function-attributes.c
@@ -1,8 +1,12 @@
-// RUN: clang -emit-llvm -o %t.clang.ll %s &&
-// RUN: %llvmgcc -c --emit-llvm -o - %s | llvm-dis -f -o %t.gcc.ll &&
-// RUN: grep "define" %t.clang.ll | sort > %t.clang.defs &&
-// RUN: grep "define" %t.gcc.ll | sort > %t.gcc.defs &&
-// RUN: diff %t.clang.defs %t.gcc.defs
+// RUN: clang -emit-llvm -o %t %s &&
+// RUN: grep 'define i8 @f0(i32 %x) signext nounwind' %t &&
+// RUN: grep 'define i8 @f1(i32 %x) zeroext nounwind' %t &&
+// RUN: grep 'define void @f2(i8 signext %x) nounwind' %t &&
+// RUN: grep 'define void @f3(i8 zeroext %x) nounwind' %t &&
+// RUN: grep 'define i16 @f4(i32 %x) signext nounwind' %t &&
+// RUN: grep 'define i16 @f5(i32 %x) zeroext nounwind' %t &&
+// RUN: grep 'define void @f6(i16 signext %x) nounwind' %t &&
+// RUN: grep 'define void @f7(i16 zeroext %x) nounwind' %t

 signed char f0(int x) { return x; }


Do not ack pending messages until they are displayed

svn path=/trunk/; revision=857

--- libempathy/empathy-tp-chat.c
+++ libempathy/empathy-tp-chat.c
@@ -355,7 +355,7 @@
 									    -1,
 									    message_ids,
 									    tp_chat_async_cb,
-									    "acknowledging pending messages",
+									    "acknowledging received message",
 									    NULL,
 									    chat);
 		g_array_free (message_ids, TRUE);
@@ -439,6 +439,7 @@
 {
 	EmpathyTpChatPriv *priv = GET_PRIV (chat);
 	guint              i;
+	GArray            *message_ids = NULL;

 	priv->had_pending_messages = TRUE;

@@ -446,6 +447,11 @@
 		empathy_debug (DEBUG_DOMAIN, "Error listing pending messages: %s",
 			       error->message);
 		return;
+	}
+
+	if (priv->acknowledge) {
+		message_ids = g_array_sized_new (FALSE, FALSE, sizeof (guint),
+						 messages_list->len);
 	}

 	for (i = 0; i < messages_list->len; i++) {
@@ -469,6 +475,10 @@

 		empathy_debug (DEBUG_DOMAIN, "Message pending: %s", message_body);

+		if (message_ids) {
+			g_array_append_val (message_ids, message_id);
+		}
+
 		message = tp_chat_build_message (EMPATHY_TP_CHAT (chat),
 						 message_type,
 						 timestamp,
@@ -477,6 +487,17 @@

 		tp_chat_emit_or_queue_message (EMPATHY_TP_CHAT (chat), message);
 		g_object_unref (message);
+	}
+
+	if (message_ids) {
+		tp_cli_channel_type_text_call_acknowledge_pending_messages (priv->channel,
+									    -1,
+									    message_ids,
+									    tp_chat_async_cb,
+									    "acknowledging pending messages",
+									    NULL,
+									    chat);
+		g_array_free (message_ids, TRUE);
 	}
 }


Merging of projects/armv6, part 2

Merging of projects/armv6, part 2

Handle TLS for ARMv6 and ARMv7

--- libexec/rtld-elf/arm/reloc.c
+++ libexec/rtld-elf/arm/reloc.c
@@ -433,7 +433,9 @@
 void
 allocate_initial_tls(Obj_Entry *objs)
 {
+#ifdef ARM_TP_ADDRESS
 	void **_tp = (void **)ARM_TP_ADDRESS;
+#endif

 	/*
 	* Fix the size of the static TLS block by using the maximum
@@ -443,16 +445,27 @@

 	tls_static_space = tls_last_offset + tls_last_size + RTLD_STATIC_TLS_EXTRA;

+#ifdef ARM_TP_ADDRESS
 	(*_tp) = (void *) allocate_tls(objs, NULL, TLS_TCB_SIZE, 8);
+#else
+	sysarch(ARM_SET_TP, allocate_tls(objs, NULL, TLS_TCB_SIZE, 8));
+#endif
 }

 void *
 __tls_get_addr(tls_index* ti)
 {
+	char *p;
+#ifdef ARM_TP_ADDRESS
 	void **_tp = (void **)ARM_TP_ADDRESS;
-	char *p;

 	p = tls_get_addr_common((Elf_Addr **)(*_tp), ti->ti_module, ti->ti_offset);
+#else
+	void *_tp;
+	__asm __volatile("mrc  p15, 0, %0, c13, c0, 3"		\
+	    : "=r" (_tp));
+	p = tls_get_addr_common((Elf_Addr **)(_tp), ti->ti_module, ti->ti_offset);
+#endif

 	return (p);
 }


s/GTK_TYPE_GDK_EVENT/GDK_TYPE_EVENT/

--- libgnomeui/gnome-icon-list.c
+++ libgnomeui/gnome-icon-list.c
@@ -1884,7 +1884,7 @@
 			gnome_marshal_VOID__INT_BOXED,
 			GTK_TYPE_NONE, 2,
 			GTK_TYPE_INT,
-			GTK_TYPE_GDK_EVENT);
+			GDK_TYPE_EVENT);

 	gil_signals[UNSELECT_ICON] =
 		gtk_signal_new (
@@ -1895,7 +1895,7 @@
 			gnome_marshal_VOID__INT_BOXED,
 			GTK_TYPE_NONE, 2,
 			GTK_TYPE_INT,
-			GTK_TYPE_GDK_EVENT);
+			GDK_TYPE_EVENT);

 	gil_signals[TEXT_CHANGED] =
 		gtk_signal_new (


eek, fix typo in parentheses in strcmp call

--- liblicense/module_wrangler.c
+++ liblicense/module_wrangler.c
@@ -323,7 +323,7 @@
 		/* If we detect application/octet-stream, this is hopeless.
 		 * At least warn the user that it happened; hopefully
 		 * he can report it to me. */
-		if (strcmp(state->__mime_type, "application/octet-stream" == 0)) {
+		if (strcmp(state->__mime_type, "application/octet-stream") == 0) {
 		  fprintf(stderr, "liblicense: xdg_mime: Found no matching MIME type, using application/octet-stream\n");
 		  fprintf(stderr, "liblicense: xdg_mime: License reading and writing are unlikely to work for this file; if you expect otherwise, contact the liblicense developers.\n");
 		}


Use the memory allocators specified by memcached_set_memory_allocators

--- libmemcached/memcached_get.c
+++ libmemcached/memcached_get.c
@@ -473,33 +473,15 @@
     uint32_t* hash;
     bool* dead_servers;

-    if (ptr->call_malloc)
-    {
-      hash= ptr->call_malloc(ptr, sizeof(uint32_t) * number_of_keys);
-      dead_servers= ptr->call_malloc(ptr, sizeof(bool) * ptr->number_of_hosts);
-    }
-    else
-    {
-      hash = malloc(sizeof(uint32_t) * number_of_keys);
-      dead_servers= malloc(sizeof(bool) * ptr->number_of_hosts);
-    }
+    hash= ptr->call_malloc(ptr, sizeof(uint32_t) * number_of_keys);
+    dead_servers= ptr->call_calloc(ptr, ptr->number_of_hosts, sizeof(bool));

     if (hash == NULL || dead_servers == NULL)
     {
-      if (ptr->call_free)
-      {
-        if (hash != NULL) ptr->call_free(ptr, hash);
-        if (dead_servers != NULL) ptr->call_free(ptr, dead_servers);
-      }
-      else
-      {
-        free(hash); /* No need to check for NULL (just look in the C spec) */
-        free(dead_servers);
-      }
+      ptr->call_free(ptr, hash);
+      ptr->call_free(ptr, dead_servers);
       return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
     }
-
-    memset(dead_servers, 0, sizeof(bool) * ptr->number_of_hosts);

     if (is_master_key_set)
       for (unsigned int x= 0; x < number_of_keys; ++x)
@@ -508,18 +490,11 @@
       for (unsigned int x= 0; x < number_of_keys; ++x)
         hash[x]= memcached_generate_hash(ptr, keys[x], key_length[x]);

-    rc= replication_binary_mget(ptr, hash, dead_servers, keys, key_length, number_of_keys);
-
-    if (ptr->call_free)
-    {
-      ptr->call_free(ptr, hash);
-      ptr->call_free(ptr, dead_servers);
-    }
-    else
-    {
-      free(hash);
-      free(dead_servers);
-    }
+    rc= replication_binary_mget(ptr, hash, dead_servers, keys,
+                                key_length, number_of_keys);
+
+    ptr->call_free(ptr, hash);
+    ptr->call_free(ptr, dead_servers);

     return MEMCACHED_SUCCESS;
   }


renderother: rename geom_node to geometry

This variable is not a node anymore but the generic geometry.

--- libnodegl/node_renderother.c
+++ libnodegl/node_renderother.c
@@ -400,11 +400,11 @@
         s->topology = NGLI_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
         s->draw = draw_simple;
     } else {
-        struct geometry *geom_node = *(struct geometry **)o->geometry->priv_data;
-        struct buffer *vertices = geom_node->vertices_buffer;
-        struct buffer *uvcoords = geom_node->uvcoords_buffer;
-        struct buffer_layout vertices_layout = geom_node->vertices_layout;
-        struct buffer_layout uvcoords_layout = geom_node->uvcoords_layout;
+        struct geometry *geometry = *(struct geometry **)o->geometry->priv_data;
+        struct buffer *vertices = geometry->vertices_buffer;
+        struct buffer *uvcoords = geometry->uvcoords_buffer;
+        struct buffer_layout vertices_layout = geometry->vertices_layout;
+        struct buffer_layout uvcoords_layout = geometry->uvcoords_layout;

         if (!uvcoords) {
             LOG(ERROR, "the specified geometry is missing UV coordinates");
@@ -430,8 +430,8 @@
         s->uvcoord_attr.buffer = uvcoords;

         s->nb_vertices = vertices_layout.count;
-        s->topology = geom_node->topology;
-        s->draw = geom_node->indices_buffer ? draw_indexed : draw_simple;
+        s->topology = geometry->topology;
+        s->draw = geometry->indices_buffer ? draw_indexed : draw_simple;
     }

     return combine_filters_code(s, o, base_name, base_fragment);


Handle return values in peas_method_apply_valist()

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

--- libpeas/peas-introspection.c
+++ libpeas/peas-introspection.c
@@ -25,7 +25,7 @@

 #include "peas-introspection.h"

-static void
+static gboolean
 read_next_argument (GArgument  *cur_arg,
                     va_list     args,
                     GITypeInfo *arg_type_info)
@@ -121,8 +121,111 @@
       cur_arg->v_pointer = va_arg (args, gpointer);
       break;
     default:
-      g_return_if_reached ();
-    }
+      g_return_val_if_reached (FALSE);
+    }
+
+  return TRUE;
+}
+
+static gboolean
+set_return_value (gpointer    in_retval,
+                  GArgument  *out_retval,
+                  GITypeInfo *retval_type_info)
+{
+  /* We should discourage people to actually use NULL for the return value. */
+  g_return_val_if_fail (in_retval != NULL, TRUE);
+
+  switch (g_type_info_get_tag (retval_type_info))
+    {
+    case GI_TYPE_TAG_VOID:
+    case GI_TYPE_TAG_BOOLEAN:
+      *((gboolean *) in_retval) = out_retval->v_boolean;
+      break;
+    case GI_TYPE_TAG_INT8:
+      *((gint8 *) in_retval) = out_retval->v_int8;
+      break;
+    case GI_TYPE_TAG_UINT8:
+      *((guint8 *) in_retval) = out_retval->v_uint8;
+      break;
+    case GI_TYPE_TAG_INT16:
+      *((gint16 *) in_retval) = out_retval->v_int16;
+      break;
+    case GI_TYPE_TAG_UINT16:
+      *((guint16 *) in_retval) = out_retval->v_uint16;
+      break;
+    case GI_TYPE_TAG_INT32:
+      *((gint32 *) in_retval) = out_retval->v_int32;
+      break;
+    case GI_TYPE_TAG_UINT32:
+      *((guint32 *) in_retval) = out_retval->v_uint32;
+      break;
+    case GI_TYPE_TAG_INT64:
+      *((gint64 *) in_retval) = out_retval->v_int64;
+      break;
+    case GI_TYPE_TAG_UINT64:
+      *((guint64 *) in_retval) = out_retval->v_uint64;
+      break;
+    case GI_TYPE_TAG_SHORT:
+      *((gshort *) in_retval) = out_retval->v_short;
+      break;
+    case GI_TYPE_TAG_USHORT:
+      *((gushort *) in_retval) = out_retval->v_ushort;
+      break;
+    case GI_TYPE_TAG_INT:
+      *((gint *) in_retval) = out_retval->v_int;
+      break;
+    case GI_TYPE_TAG_UINT:
+      *((guint *) in_retval) = out_retval->v_uint;
+      break;
+    case GI_TYPE_TAG_LONG:
+      *((glong *) in_retval) = out_retval->v_long;
+      break;
+    case GI_TYPE_TAG_ULONG:
+      *((gulong *) in_retval) = out_retval->v_ulong;
+      break;
+    case GI_TYPE_TAG_SSIZE:
+      *((gssize *) in_retval) = out_retval->v_ssize;
+      break;
+    case GI_TYPE_TAG_SIZE:
+      *((gsize *) in_retval) = out_retval->v_size;
+      break;
+    case GI_TYPE_TAG_FLOAT:
+      *((gfloat *) in_retval) = out_retval->v_float;
+      break;
+    case GI_TYPE_TAG_DOUBLE:
+      *((gdouble *) in_retval) = out_retval->v_double;
+      break;
+    case GI_TYPE_TAG_TIME_T:
+      /* borrowed from gfield.c in gobject-introspection */
+#if SIZEOF_TIME_T == 4
+      *((gint32 *) in_retval) = out_retval->v_int32;
+#elif SIZEOF_TIME_T == 8
+      *((gint64 *) in_retval) = out_retval->v_int64;
+#else
+#  error "Unexpected size for time_t: not 4 or 8"
+#endif
+      break;
+    case GI_TYPE_TAG_GTYPE:
+      /* apparently, GType is meant to be a gsize, from gobject/gtype.h in glib */
+      *((gsize *) in_retval) = out_retval->v_size;
+      break;
+    case GI_TYPE_TAG_UTF8:
+    case GI_TYPE_TAG_FILENAME:
+      *((gchar **) in_retval) = out_retval->v_string;
+      break;
+    case GI_TYPE_TAG_ARRAY:
+    case GI_TYPE_TAG_INTERFACE:
+    case GI_TYPE_TAG_GLIST:
+    case GI_TYPE_TAG_GSLIST:
+    case GI_TYPE_TAG_GHASH:
+    case GI_TYPE_TAG_ERROR:
+      *((gsize **) in_retval) = out_retval->v_pointer;
+      break;
+    default:
+      g_return_val_if_reached (FALSE);
+    }
+
+  return TRUE;
 }

 GICallableInfo *
@@ -174,17 +277,20 @@
                           va_list      args)
 {
   GICallableInfo *func_info;
+  GITypeInfo *retval_info;
+  GArgument out_retval;
   guint n_args, n_in_args, n_out_args;
   GArgument *in_args, *out_args;
-  GArgument retval;
   guint i;
-  gboolean ret;
+  gboolean ret = TRUE;
   GError *error = NULL;

   func_info = peas_method_get_info (iface_type, method_name);
   if (func_info == NULL)
     return FALSE;

+  retval_info = g_callable_info_get_return_type (func_info);
+
   n_args = g_callable_info_get_n_args (func_info);
   n_in_args = 0;
   n_out_args = 0;
@@ -195,7 +301,7 @@
   /* Set the object as the first argument for the method. */
   in_args[n_in_args++].v_pointer = instance;

-  for (i = 0; i < n_args; i++)
+  for (i = 0; ret && i < n_args; i++)
     {
       GIArgInfo *arg_info;
       GITypeInfo *arg_type_info;
@@ -206,7 +312,7 @@
       switch (g_arg_info_get_direction (arg_info))
         {
         case GI_DIRECTION_IN:
-          read_next_argument (&in_args[n_in_args++], args, arg_type_info);
+          ret = read_next_argument (&in_args[n_in_args++], args, arg_type_info);
           break;
         /* In the other cases, we expect we will always have a pointer. */
         case GI_DIRECTION_INOUT:
@@ -221,15 +327,38 @@
       g_base_info_unref ((GIBaseInfo *) arg_info);
     }

-  ret = g_function_info_invoke (func_info, in_args, n_in_args, out_args, n_out_args, &retval, &error);
   if (!ret)
     {
-      g_debug ("Error while calling %s.%s: %s", g_type_name (iface_type), method_name, error->message);
+      g_warning ("Invalid argument type for calling '%s.%s'",
+                 g_type_name (iface_type), method_name);
+      goto out;
+    }
+
+  ret = g_function_info_invoke (func_info, in_args, n_in_args, out_args,
+                                n_out_args, &out_retval, &error);
+  if (!ret)
+    {
+      g_warning ("Error while calling '%s.%s': %s",
+                 g_type_name (iface_type), method_name, error->message);
       g_error_free (error);
-    }
-
+      goto out;
+    }
+
+  if (g_type_info_get_tag (retval_info) != GI_TYPE_TAG_VOID)
+    {
+      ret = set_return_value (va_arg (args, gpointer), &out_retval, retval_info);
+
+      if (!ret)
+        {
+          g_warning ("Invalid return type for '%s.%s'",
+                     g_type_name (iface_type), method_name);
+        }
+    }
+
+out:
   g_free (in_args);
   g_free (out_args);
+  g_base_info_unref ((GIBaseInfo *) retval_info);
   g_base_info_unref ((GIBaseInfo *) func_info);

   return ret;


use cudamemcpy instead of unified memory. something is broken with unified memory

--- cnn/aligned-mem-pool.h
+++ cnn/aligned-mem-pool.h
@@ -19,14 +19,12 @@

 namespace cnn {

-/// use CUDA 6.0 features, use unified memory so that GPU memory content can be
-/// accessible to CPU, after calling cudaDeviceSynchronize();
 inline void* cnn_mm_malloc(size_t n, size_t align, bool on_cpu_only = false) {
   void* ptr = nullptr;
   if (!on_cpu_only)
   {
 #if HAVE_CUDA
-      CUDA_CHECK(cudaMallocManaged(&ptr, n));
+      CUDA_CHECK(cudaMalloc(&ptr, n));
 #else
       ptr = _mm_malloc(n, align);
 #endif
@@ -35,6 +33,16 @@
   {
       ptr = _mm_malloc(n, align);
   }
+
+#ifdef HAVE_CUDA
+//  if (verbose){
+//      size_t total_mem, free_mem;
+//      CUDA_CHECK(cudaMemGetInfo(&free_mem, &total_mem));
+//      std::cout << ":Allocated " << n;
+//      std::cout << " Currently " << free_mem << " bytes free" << std::endl;
+//  }
+#endif
+
   if (!ptr) {
     std::cerr << "Memory allocation failed n=" << n << " align=" << align << std::endl;
     throw cnn::out_of_memory("Memory allocation failed in cnn_mm_malloc()");


baseparse: Try to generate caps on the srcpad before forwarding GAP event

To configure downstream elements and complete initial pre-rolling,
ensure we have default output caps before forwarding GAP event.

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

--- libs/gst/base/gstbaseparse.c
+++ libs/gst/base/gstbaseparse.c
@@ -1053,6 +1053,83 @@
   return ret;
 }

+static gboolean
+update_upstream_provided (GQuark field_id, const GValue * value,
+    gpointer user_data)
+{
+  GstCaps *default_caps = user_data;
+  gint i;
+  gint caps_size;
+
+  caps_size = gst_caps_get_size (default_caps);
+  for (i = 0; i < caps_size; i++) {
+    GstStructure *structure = gst_caps_get_structure (default_caps, i);
+    if (gst_structure_id_has_field (structure, field_id))
+      gst_structure_id_set_value (structure, field_id, value);
+  }
+
+  return TRUE;
+}
+
+static GstCaps *
+gst_base_parse_negotiate_default_caps (GstBaseParse * parse)
+{
+  GstCaps *caps, *templcaps;
+  GstCaps *sinkcaps = NULL;
+  GstCaps *default_caps = NULL;
+  GstStructure *structure;
+
+  templcaps = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SRC_PAD (parse));
+  caps = gst_pad_peer_query_caps (GST_BASE_PARSE_SRC_PAD (parse), templcaps);
+  if (caps)
+    gst_caps_unref (templcaps);
+  else
+    caps = templcaps;
+  templcaps = NULL;
+
+  if (!caps || gst_caps_is_empty (caps) || gst_caps_is_any (caps)) {
+    goto caps_error;
+  }
+
+  GST_LOG_OBJECT (parse, "peer caps  %" GST_PTR_FORMAT, caps);
+
+  /* before fixating, try to use whatever upstream provided */
+  default_caps = gst_caps_copy (caps);
+  sinkcaps = gst_pad_get_current_caps (GST_BASE_PARSE_SINK_PAD (parse));
+
+  GST_LOG_OBJECT (parse, "current caps %" GST_PTR_FORMAT " for sinkpad",
+      sinkcaps);
+
+  if (sinkcaps) {
+    structure = gst_caps_get_structure (sinkcaps, 0);
+    gst_structure_foreach (structure, update_upstream_provided, default_caps);
+  }
+
+  default_caps = gst_caps_fixate (default_caps);
+
+  if (!default_caps) {
+    GST_WARNING_OBJECT (parse, "Failed to create default caps !");
+    goto caps_error;
+  }
+
+  GST_INFO_OBJECT (parse,
+      "Chose default caps %" GST_PTR_FORMAT " for initial gap", default_caps);
+
+  gst_caps_unref (sinkcaps);
+  gst_caps_unref (caps);
+
+  return default_caps;
+
+caps_error:
+  {
+    if (caps)
+      gst_caps_unref (caps);
+    if (sinkcaps)
+      gst_caps_unref (sinkcaps);
+    return NULL;
+  }
+}
+
 /* gst_base_parse_sink_event:
  * @pad: #GstPad that received the event.
  * @event: #GstEvent to be handled.
@@ -1072,7 +1149,6 @@

   return ret;
 }
-

 /* gst_base_parse_sink_event_default:
  * @parse: #GstBaseParse.
@@ -1320,6 +1396,26 @@
     case GST_EVENT_GAP:
     {
       GST_DEBUG_OBJECT (parse, "draining current data due to gap event");
+
+      /* Ensure we have caps before forwarding the event */
+      if (!gst_pad_has_current_caps (GST_BASE_PARSE_SRC_PAD (parse))) {
+        GstCaps *default_caps = NULL;
+        if ((default_caps = gst_base_parse_negotiate_default_caps (parse))) {
+          GST_DEBUG_OBJECT (parse,
+              "Store caps event to pending list for initial pre-rolling");
+          parse->priv->pending_events =
+              g_list_prepend (parse->priv->pending_events,
+              gst_event_new_caps (default_caps));
+          gst_caps_unref (default_caps);
+        } else {
+          gst_event_unref (event);
+          event = NULL;
+          ret = FALSE;
+          GST_ELEMENT_ERROR (parse, STREAM, FORMAT, (NULL),
+              ("Parser output not negotiated before GAP event."));
+          break;
+        }
+      }

       gst_base_parse_push_pending_events (parse);


Fix null pointer dereference.

Fix null pointer dereference.

--- p11-kit/p11-kit-lib.c
+++ p11-kit/p11-kit-lib.c
@@ -1058,7 +1058,7 @@
 		}

 		if (config) {
-			option = hash_get (module->config, field);
+			option = hash_get (config, field);
 			if (option)
 				option = strdup (option);
 		}


added code to compute plane ray intersection parameter + generalized intersection to use the precision if the plane (not just float)

git-svn-id: 0a20d38d1bcdb3210d244a647211d61b0aabf366@86 5b8196f7-c1c0-4be6-8b13-4feed349168d

--- Vectors.h
+++ Vectors.h
@@ -1449,16 +1449,30 @@
   /// Determine the intersection point of the plane and a line `ab'.
   /// @return whether or not the two intersect.  If false, `hit' will not be
   ///         valid.
-  bool intersect(const FLOATVECTOR3& a, const FLOATVECTOR3& b,
-                 FLOATVECTOR3& hit) const {
-    const float denom = (*this) ^ (a - b);
+  bool intersect(const VECTOR3<T>& a, const VECTOR3<T>& b,
+                 VECTOR3<T>& hit) const {
+    const T denom = (*this) ^ (a - b);
     if(EpsilonEqual(denom, 0.0f)) {
       return false;
     }
-    const float t = (((*this) ^ a) + this->d()) / denom;
+    const T t = (((*this) ^ a) + this->d()) / denom;
     hit = a + (t*(b - a));
     return true;
   }
+
+  /// Determine the parametric intersection point of the plane and a line `ab'.
+  /// @return whether or not the two intersect.  If false, `hit' will not be
+  ///         valid.
+  bool intersect(const VECTOR3<T>& a, const VECTOR3<T>& b,
+                 T& hit) const {
+    const T denom = (*this) ^ (a - b);
+    if(EpsilonEqual(denom, 0.0f)) {
+      return false;
+    }
+    hit = (((*this) ^ a) + this->d()) / denom;
+    return true;
+  }
+
 };

 typedef PLANE<float>  FLOATPLANE;


Corrected relaxation zone function

Corrected relaxation zone function


SIMPLIFY : split original loop in two : first looking forward if the next I-frame's DTS is inferior the the one we have. If it is, then this is the key-frame we're looking for. If not, then look backward : the key-frame will be the previous I-frame

--- libsjindex/sj_search_index.c
+++ libsjindex/sj_search_index.c
@@ -133,33 +133,20 @@

 static int find_relative_key_frame(Index *key_frame, SJ_IndexContext sj_ic)
 {
-    int i = sj_ic.index_pos;
-    int j = i;
-    int exit_loop = 0;
-    Index *prev = NULL, *next = NULL;
-
-    for(; i >= 0 || j < sj_ic.index_num; i--, j++) {
-        if (sj_ic.indexes[i].pic_type == 1 && i >= 0) {
-            exit_loop++;
-            prev = &sj_ic.indexes[i];
-        }
-        if (sj_ic.indexes[j].pic_type == 1 && j < sj_ic.index_num ) {
-            next = &sj_ic.indexes[j];
-            exit_loop++;
-        }
-        if (exit_loop == 2 || (exit_loop == 1 && (i < 0 || j >= sj_ic.index_num))) {
-            break;
+    // if the next I_frame has a dts inferior to the searched dts then this I_frame is the related key_frame
+    for (int i = sj_ic.index_pos; i < sj_ic.index_num; i++){
+        if (sj_ic.indexes[i].pic_type == 1 && sj_ic.indexes[i].dts < sj_ic.indexes[sj_ic.index_pos].dts) {
+            key_frame = &sj_ic.indexes[i];
+            return 0;
         }
     }
-    if (!next || sj_ic.indexes[sj_ic.index_pos].dts < next->dts) {
-        *key_frame = *prev;
-        return 0;
-    }
-    if (!prev || sj_ic.indexes[sj_ic.index_pos].dts < prev->dts) {
-        *key_frame = *next;
-        return 0;
+    // otherwise, look before the searched frame
+    for (int i = sj_ic.index_pos; i >= 0; i--) {
+        if (sj_ic.indexes[i].pic_type == 1) {
+            key_frame = &sj_ic.indexes[i];
+            return 0;
+        }
     }
-    *key_frame = sj_ic.indexes[sj_ic.index_pos].dts - next->dts < sj_ic.indexes[sj_ic.index_pos].dts - prev->dts ? *next : *prev ;
     return 0;
 }


stuff

stuff

--- libsrc/convolution/im_conv.c
+++ libsrc/convolution/im_conv.c
@@ -65,7 +65,7 @@
  * 	- int rounding was +1 too much, argh
  * 	- only rebuild the buffer offsets if bpl changes
  * 5/4/09
- * 	- tiny speedup ... change ++ to +=1 in inner loop
+ * 	- tiny speedups and cleanups
  * 	- add restrict, though it doesn't seem to help gcc
  */

@@ -120,7 +120,7 @@
 	INTMASK *mask;		/* Copy of mask arg */

 	int nnz;		/* Number of non-zero mask elements */
-	int * restrict coeff;	/* Array of non-zero mask coefficients */
+	int *coeff;		/* Array of non-zero mask coefficients */

 	int underflow;		/* Global underflow/overflow counts */
 	int overflow;
@@ -202,7 +202,7 @@
 	REGION *ir;		/* Input region */

 	int *offsets;		/* Offsets for each non-zero matrix element */
-	PEL * restrict * restrict pts;	/* Per-non-zero mask element pointers */
+	PEL **pts;		/* Per-non-zero mask element pointers */

 	int underflow;		/* Underflow/overflow counts */
 	int overflow;
@@ -263,25 +263,22 @@
 }

 #define INNER { \
-	sum += *t * (*p)[x]; \
-	t += 1; \
-	p += 1; \
+	sum += t[i] * p[i][x]; \
+	i += 1; \
 }

 /* INT and FLOAT inner loops.
  */
 #define CONV_INT( TYPE, IM_CLIP ) { \
-	TYPE *q = (TYPE *) IM_REGION_ADDR( or, le, y ); \
+	TYPE ** restrict p = (TYPE **) seq->pts; \
+	TYPE * restrict q = (TYPE *) IM_REGION_ADDR( or, le, y ); \
 	\
 	for( x = 0; x < sz; x++ ) {  \
-		int * restrict t; \
-		TYPE ** restrict p; \
 		int sum; \
+		int i; \
  		\
-		z = 0; \
 		sum = 0; \
-		t = conv->coeff; \
-		p = (TYPE **) seq->pts; \
+		i = 0; \
 		IM_UNROLL( conv->nnz, INNER ); \
  		\
 		sum = ((sum + rounding) / mask->scale) + mask->offset; \
@@ -293,17 +290,15 @@
 }

 #define CONV_FLOAT( TYPE ) { \
-	TYPE *q = (TYPE *) IM_REGION_ADDR( or, le, y ); \
+	TYPE ** restrict p = (TYPE **) seq->pts; \
+	TYPE * restrict q = (TYPE *) IM_REGION_ADDR( or, le, y ); \
 	\
 	for( x = 0; x < sz; x++ ) {  \
-		int * restrict t; \
-		TYPE ** restrict p; \
 		double sum; \
+		int i; \
  		\
-		z = 0; \
 		sum = 0; \
-		t = conv->coeff; \
-		p = (TYPE **) seq->pts; \
+		i = 0; \
 		IM_UNROLL( conv->nnz, INNER ); \
  		\
 		sum = (sum / mask->scale) + mask->offset; \
@@ -322,6 +317,7 @@
 	Conv *conv = (Conv *) b;
 	REGION *ir = seq->ir;
 	INTMASK *mask = conv->mask;
+	int * restrict t = conv->coeff;

 	/* You might think this should be (scale+1)/2, but then we'd be adding
 	 * one for scale == 1.


tests for convertTo<int>()

tests for convertTo<int>()

error: pathspec 'code/tests/ConvertTo.h' did not match any file(s) known to git

--- code/tests/ConvertTo.h
+++ code/tests/ConvertTo.h
@@ -0,0 +1,17 @@
+#include <cxxtest/TestSuite.h>
+
+#include "stdsneezy.h"
+#include "tests/ValueTraits.h"
+
+class ConvertTo : public CxxTest::TestSuite
+{
+
+ public:
+  void testNumTypes(){
+    TS_ASSERT_EQUALS(5, convertTo<int>("5"));
+    TS_ASSERT_EQUALS(5, convertTo<unsigned int>("5"));
+    TS_ASSERT_EQUALS(5.5, convertTo<float>("5.5"));
+    TS_ASSERT_EQUALS(5.5, convertTo<double>("5.5"));
+
+  }
+};


RMA sync bugfix

RMA sync bugfix

--- test/experiments/intranode-bcast.c
+++ test/experiments/intranode-bcast.c
@@ -18,6 +18,7 @@
     void * temp = NULL;
     MPI_Win wintemp = MPI_WIN_NULL;
     MPI_Win_allocate_shared(winsize, ts, MPI_INFO_NULL, MPI_COMM_NODE, &temp, &wintemp);
+    MPI_Win_lock_all(0, wintemp);

     if (nrank==0) {
         memcpy(temp, buffer, (size_t)count*ts);
@@ -27,6 +28,7 @@
         memcpy(buffer, temp, (size_t)count*ts);
     }

+    MPI_Win_unlock_all(wintemp);
     MPI_Win_free(&wintemp);
     return MPI_SUCCESS;
 }


Fix handling of propflags when setting variables

--- libswfdec/swfdec_as_object.c
+++ libswfdec/swfdec_as_object.c
@@ -214,6 +214,22 @@
 }

 static gboolean
+swfdec_as_object_variable_enabled_in_version (SwfdecAsVariable *var,
+    guint version)
+{
+  if (var->flags & SWFDEC_AS_VARIABLE_VERSION_6_UP && version < 6)
+    return FALSE;
+  if (var->flags & SWFDEC_AS_VARIABLE_VERSION_NOT_6 && version == 6)
+    return FALSE;
+  if (var->flags & SWFDEC_AS_VARIABLE_VERSION_7_UP && version < 7)
+    return FALSE;
+  if (var->flags & SWFDEC_AS_VARIABLE_VERSION_8_UP && version < 8)
+    return FALSE;
+
+  return TRUE;
+}
+
+static gboolean
 swfdec_as_object_do_get (SwfdecAsObject *object, SwfdecAsObject *orig,
     const char *variable, SwfdecAsValue *val, guint *flags)
 {
@@ -223,13 +239,8 @@
     return FALSE;

   /* variable flag checks */
-  if (var->flags & SWFDEC_AS_VARIABLE_VERSION_6_UP && object->context->version < 6)
-    return FALSE;
-  if (var->flags & SWFDEC_AS_VARIABLE_VERSION_NOT_6 && object->context->version == 6)
-    return FALSE;
-  if (var->flags & SWFDEC_AS_VARIABLE_VERSION_7_UP && object->context->version < 7)
-    return FALSE;
-  if (var->flags & SWFDEC_AS_VARIABLE_VERSION_8_UP && object->context->version < 8)
+  if (!swfdec_as_object_variable_enabled_in_version (var,
+	object->context->version))
     return FALSE;

   if (var->get) {
@@ -355,32 +366,40 @@

 static SwfdecAsVariable *
 swfdec_as_object_hash_lookup_with_prototype (SwfdecAsObject *object,
-    const char *variable)
+    const char *variable, SwfdecAsObject **proto)
 {
   SwfdecAsVariable *var;
+  SwfdecAsObject *proto_;

   g_return_val_if_fail (swfdec_as_variable_name_is_valid (variable), NULL);

+  proto_ = NULL;
+
+  // match first level variable even if it has version flags that hide it in
+  // this version
   var = swfdec_as_object_hash_lookup (object, variable);
   if (var == NULL && variable != SWFDEC_AS_STR___proto__) {
     guint i;
-    SwfdecAsObject *proto;
-
-    proto = swfdec_as_object_get_prototype (object);
-
-    for (i = 0; i < SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT && proto; i++) {
-      var = swfdec_as_object_hash_lookup (proto, variable);
+
+    proto_ = swfdec_as_object_get_prototype (object);
+
+    for (i = 0; i < SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT && proto_; i++) {
+      var = swfdec_as_object_hash_lookup (proto_, variable);
       if (var && var->get)
 	break;
-      proto = swfdec_as_object_get_prototype (proto);
+      proto_ = swfdec_as_object_get_prototype (proto_);
       var = NULL;
     }
+
     if (i == SWFDEC_AS_OBJECT_PROTOTYPE_RECURSION_LIMIT) {
       swfdec_as_context_abort (object->context, "Prototype recursion limit exceeded");
       return NULL;
     }
   }

+  if (proto != NULL)
+    *proto = proto_;
+
   return var;
 }

@@ -390,13 +409,27 @@
 {
   SwfdecAsVariable *var;
   SwfdecAsWatch *watch;
+  SwfdecAsObject *proto;

   if (!swfdec_as_variable_name_is_valid (variable))
     return;

-  var = swfdec_as_object_hash_lookup_with_prototype (object, variable);
+  var = swfdec_as_object_hash_lookup_with_prototype (object, variable, &proto);
   if (swfdec_as_context_is_aborted (object->context))
     return;
+
+  // if variable is disabled in this version
+  if (var != NULL && !swfdec_as_object_variable_enabled_in_version (var,
+	object->context->version)) {
+    if (proto == NULL) {
+      // it's at the top level, remove getter and setter plus overwrite
+      var->get = NULL;
+      var->set = NULL;
+    } else {
+      // it's in proto, we create a new one at the top level
+      var = NULL;
+    }
+  }

   if (var == NULL) {
     var = swfdec_as_object_hash_create (object, variable, flags);
@@ -432,7 +465,8 @@
       swfdec_as_function_call (watch->watch, object, 4, args, &ret);
       swfdec_as_context_run (object->context);
       swfdec_as_watch_unref (watch);
-      var = swfdec_as_object_hash_lookup_with_prototype (object, variable);
+      var = swfdec_as_object_hash_lookup_with_prototype (object, variable,
+	  NULL);
       if (swfdec_as_context_is_aborted (object->context))
 	return;
       if (var == NULL) {


wpan-ping: align wpan-ping version with the general wpan-tools version

As we have it shipped with wpan-tools now we do not have a reason to go for a
different version scheme.

Signed-off-by: Stefan Schmidt <eb0877843acc39f8ef6f7269937dee931c372d23@osg.samsung.com>

--- wpan-ping/wpan-ping.c
+++ wpan-ping/wpan-ping.c
@@ -474,7 +474,7 @@
 			conf->interface = optarg;
 			break;
 		case 'v':
-			fprintf(stdout, "wpan-ping 0.1\n");
+			fprintf(stdout, "wpan-ping " PACKAGE_VERSION "\n");
 			return 1;
 		case 'h':
 			usage(argv[0]);


Bug 2573311: Fixed flip in image from .NET library

--- wrapper/net/libdmtx.c
+++ wrapper/net/libdmtx.c
@@ -283,13 +283,10 @@
 	dmtx_uint32_t width = dmtxImageGetProp(enc->image, DmtxPropWidth);
 	dmtx_uint32_t height = dmtxImageGetProp(enc->image, DmtxPropHeight);

-	if (width == stride)
-		memcpy((void *) bitmap, enc->image->pxl, stride * height);
-	else
-		for (i = 0; i < height; i++)
-			memcpy((void *) (bitmap + i * stride),
-			enc->image->pxl + i * 3 * width,
-			3 * width);
+	for (i = 0; i < height; i++)
+		memcpy((void *) (bitmap + (height-i-1) * stride),
+		enc->image->pxl + i * 3 * width,
+		3 * width);
 }

 DMTX_EXTERN void


Remove unnecessary const

Remove unnecessary const

--- xchainer/array_node.h
+++ xchainer/array_node.h
@@ -63,7 +63,7 @@
     std::shared_ptr<internal::ArrayBody> GetBody() { return body_.lock(); }

 private:
-    const std::weak_ptr<internal::ArrayBody> body_;
+    std::weak_ptr<internal::ArrayBody> body_;
     std::shared_ptr<OpNode> next_op_node_;
     Shape shape_;
     Dtype dtype_;


PROTON-1418: pn_vlogf missing newline after log.

--- proton-c/src/core/log.c
+++ proton-c/src/core/log.c
@@ -50,6 +50,7 @@

 void pn_vlogf_impl(const char *fmt, va_list ap) {
     vfprintf(stderr, fmt, ap);
+    fprintf(stderr, "\n");
 }

 /**@internal


logging catches line numbers better

logging catches line numbers better

--- library/rqdql/cpp/include/brokers.h
+++ library/rqdql/cpp/include/brokers.h
@@ -139,9 +139,6 @@
     }
     s->setText(boost::algorithm::join(sigs, " "));
     setText(boost::algorithm::join(texts, " "));
-    if (!hasText()) {
-        setText("strange...?");
-    }
     setSignature(s);
 }


HttpServer: Fix parsing of chunked encoding.

--- aprinter/net/http/HttpServer.h
+++ aprinter/net/http/HttpServer.h
@@ -150,11 +150,16 @@
     struct Client : public TheRequestInterface {
         enum class State : uint8_t {
             NOT_CONNECTED, WAIT_SEND_BUF_FOR_REQUEST,
-            RECV_REQUEST_LINE, RECV_HEADER_LINE, HEAD_RECEIVED, USER_GONE,
+            RECV_REQUEST_LINE, RECV_HEADER_LINE,
+            HEAD_RECEIVED, USER_GONE,
             DISCONNECT_AFTER_SENDING, CALLING_REQUEST_TERMINATED
         };

-        enum class RecvState : uint8_t {INVALID, NOT_STARTED, RECV_KNOWN_LENGTH, RECV_CHUNK_HEADER, RECV_CHUNK_DATA, COMPLETED};
+        enum class RecvState : uint8_t {
+            INVALID, NOT_STARTED, RECV_KNOWN_LENGTH,
+            RECV_CHUNK_HEADER, RECV_CHUNK_DATA, RECV_CHUNK_TRAILER,
+            RECV_TRAILER, COMPLETED
+        };

         enum class SendState : uint8_t {INVALID, HEAD_NOT_SENT, SEND_BODY, SEND_LAST_CHUNK, COMPLETED};

@@ -443,8 +448,10 @@
                 case State::HEAD_RECEIVED:
                 case State::USER_GONE: {
                     switch (m_recv_state) {
-                        case RecvState::RECV_CHUNK_HEADER: {
-                            // Receiving the chunk-header line.
+                        case RecvState::RECV_CHUNK_HEADER:
+                        case RecvState::RECV_CHUNK_TRAILER:
+                        case RecvState::RECV_TRAILER: {
+                            // Receiving a line.
                             recv_line(c, m_header_line, Params::MaxHeaderLineLength);
                         } break;

@@ -475,22 +482,21 @@
                                 return m_user->requestBufferEvent(c);
                             }

-                            // Is the entire body received?
-                            if (m_req_body_recevied) {
-                                // Receiving the request body is now completed.
-                                AMBRO_ASSERT(is_combined_timeout_cleared(c, CombinedTimeout::RECV)) // was cleared above because m_rem_req_body_length==0
-                                m_recv_state = RecvState::COMPLETED;
-
-                                // Maybe we can move on to the next request.
-                                check_for_next_request(c);
+                            // Consume/discard data until the entire body is received.
+                            if (!m_req_body_recevied) {
+                                size_t amount = get_request_body_avail(c);
+                                if (amount > 0) {
+                                    consume_request_body(c, amount);
+                                }
                                 return;
                             }

-                            // Accept and discard any available request-body data.
-                            size_t amount = get_request_body_avail(c);
-                            if (amount > 0) {
-                                consume_request_body(c, amount);
-                            }
+                            // Receiving the request body is now completed.
+                            AMBRO_ASSERT(is_combined_timeout_cleared(c, CombinedTimeout::RECV)) // was cleared above because m_rem_req_body_length==0
+                            m_recv_state = RecvState::COMPLETED;
+
+                            // Maybe we can move on to the next request.
+                            check_for_next_request(c);
                         } break;
                     }
                 } break;
@@ -728,28 +734,61 @@

                 case State::HEAD_RECEIVED:
                 case State::USER_GONE: {
-                    AMBRO_ASSERT(m_recv_state == RecvState::RECV_CHUNK_HEADER)
                     AMBRO_ASSERT(!m_req_body_recevied)

-                    // Check for errors in line parsing.
-                    if (overflow || m_null_in_line) {
-                        TheMain::print_pgm_string(c, AMBRO_PSTR("//HttpClientBadChunkLine\n"));
-                        return close_gracefully(c, HttpStatusCodes::BadRequest());
+                    switch (m_recv_state) {
+                        case RecvState::RECV_CHUNK_HEADER: {
+                            // Check for errors in line parsing.
+                            if (overflow || m_null_in_line) {
+                                TheMain::print_pgm_string(c, AMBRO_PSTR("//HttpClientBadChunkLine\n"));
+                                return close_gracefully(c, HttpStatusCodes::BadRequest());
+                            }
+
+                            // Parse the chunk length.
+                            char *endptr;
+                            unsigned long long int value = strtoull(m_header_line, &endptr, 16);
+                            if (endptr == m_header_line || (*endptr != '\0' && *endptr != ';')) {
+                                TheMain::print_pgm_string(c, AMBRO_PSTR("//HttpClientBadChunkLine\n"));
+                                return close_gracefully(c, HttpStatusCodes::BadRequest());
+                            }
+
+                            if (value == 0) {
+                                // This is the final zero chunk, move on to receiving the trailing headers.
+                                m_recv_state = RecvState::RECV_TRAILER;
+                                m_rem_allowed_length = Params::MaxRequestHeadLength;
+                            } else {
+                                // Remember the chunk length and continue in event_handler.
+                                m_recv_state = RecvState::RECV_CHUNK_DATA;
+                                m_rem_req_body_length = value;
+                            }
+                            m_recv_event.prependNow(c);
+                        } break;
+
+                        case RecvState::RECV_CHUNK_TRAILER: {
+                            // This is supposed to be just an empty line following the chunk payload.
+                            if (length > 0) {
+                                TheMain::print_pgm_string(c, AMBRO_PSTR("//HttpClientBadChunkTrailer\n"));
+                                return close_gracefully(c, HttpStatusCodes::BadRequest());
+                            }
+
+                            // Now read the other trailer lines.
+                            m_recv_state = RecvState::RECV_CHUNK_HEADER;
+                            m_rem_allowed_length = Params::MaxHeaderLineLength;
+                            m_recv_event.prependNow(c);
+                        } break;
+
+                        case RecvState::RECV_TRAILER: {
+                            if (length == 0) {
+                                // End of trailer, go via this state for simplicity.
+                                m_recv_state = RecvState::RECV_CHUNK_DATA;
+                                m_rem_req_body_length = 0;
+                                m_req_body_recevied = true;
+                            }
+                            m_recv_event.prependNow(c);
+                        } break;
+
+                        default: AMBRO_ASSERT(false);
                     }
-
-                    // Parse the chunk length.
-                    char *endptr;
-                    unsigned long long int value = strtoull(m_header_line, &endptr, 16);
-                    if (endptr == m_header_line || (*endptr != '\0' && *endptr != ';')) {
-                        TheMain::print_pgm_string(c, AMBRO_PSTR("//HttpClientBadChunkLine\n"));
-                        return close_gracefully(c, HttpStatusCodes::BadRequest());
-                    }
-
-                    // Remember the chunk length and continue in event_handler.
-                    m_rem_req_body_length = value;
-                    m_req_body_recevied = (value == 0);
-                    m_recv_state = RecvState::RECV_CHUNK_DATA;
-                    m_recv_event.prependNow(c);
                 } break;

                 default: AMBRO_ASSERT(false);
@@ -915,9 +954,11 @@

         bool receiving_request_body (Context c)
         {
-            return (m_recv_state == RecvState::RECV_KNOWN_LENGTH ||
-                    m_recv_state == RecvState::RECV_CHUNK_HEADER ||
-                    m_recv_state == RecvState::RECV_CHUNK_DATA);
+            return (m_recv_state == RecvState::RECV_KNOWN_LENGTH   ||
+                    m_recv_state == RecvState::RECV_CHUNK_HEADER   ||
+                    m_recv_state == RecvState::RECV_CHUNK_DATA     ||
+                    m_recv_state == RecvState::RECV_CHUNK_TRAILER  ||
+                    m_recv_state == RecvState::RECV_TRAILER);
         }

         void start_receiving_request_body (Context c, bool user_accepting)
@@ -934,17 +975,16 @@
             }

             // Remember if the user is accepting the body (else we're discarding it).
-            if (user_accepting) {
-                m_user_accepting_request_body = true;
-            }
+            m_user_accepting_request_body = user_accepting;

             // Start receiving the request body, chunked or known-length.
             if (m_have_chunked) {
+                m_recv_state = RecvState::RECV_CHUNK_HEADER;
+                m_rem_allowed_length = Params::MaxHeaderLineLength;
                 m_req_body_recevied = false;
-                prepare_for_receiving_chunk_header(c);
             } else {
+                m_recv_state = RecvState::RECV_KNOWN_LENGTH;
                 m_req_body_recevied = (m_rem_req_body_length == 0);
-                m_recv_state = RecvState::RECV_KNOWN_LENGTH;
             }
             m_recv_event.prependNow(c);
         }
@@ -953,10 +993,11 @@
         {
             AMBRO_ASSERT(receiving_request_body(c))

-            if (m_recv_state == RecvState::RECV_CHUNK_HEADER) {
+            if (m_recv_state == RecvState::RECV_KNOWN_LENGTH || m_recv_state == RecvState::RECV_CHUNK_DATA) {
+                return (size_t)MinValue((uint64_t)m_rx_buf_length, m_rem_req_body_length);
+            } else {
                 return 0;
             }
-            return (size_t)MinValue((uint64_t)m_rx_buf_length, m_rem_req_body_length);
         }

         void consume_request_body (Context c, size_t amount)
@@ -981,7 +1022,8 @@
                 if (m_recv_state == RecvState::RECV_KNOWN_LENGTH) {
                     m_req_body_recevied = true;
                 } else {
-                    prepare_for_receiving_chunk_header(c);
+                    m_recv_state = RecvState::RECV_CHUNK_TRAILER;
+                    m_rem_allowed_length = Params::MaxHeaderLineLength;
                 }
                 m_recv_event.prependNow(c);
             }
@@ -1000,13 +1042,6 @@
                 m_user_accepting_request_body = false;
                 m_recv_event.prependNow(c);
             }
-        }
-
-        void prepare_for_receiving_chunk_header (Context c)
-        {
-            // We need to set m_rem_allowed_length each time we start to receive a chunk header.
-            m_recv_state = RecvState::RECV_CHUNK_HEADER;
-            m_rem_allowed_length = Params::MaxHeaderLineLength;
         }

         void close_gracefully (Context c, char const *resp_status)


code cleanup

code cleanup

--- modules/rtp_in/sdp_fetch.c
+++ modules/rtp_in/sdp_fetch.c
@@ -101,25 +101,23 @@
 	case GF_NETIO_DATA_TRANSFERED:
 		if (sdp->original_url) {
 			u32 sdp_size;
-			gf_dm_sess_get_stats(rtp->dnload, NULL, NULL, &sdp_size, NULL, NULL, NULL);
-			if (!sdp_size)
-				break;
-		}
-
-		{
-			const char *szFile = gf_dm_sess_get_cache_name(rtp->dnload);
-			if (!szFile) {
-				e = GF_SERVICE_ERROR;
-			} else {
-				e = GF_OK;
-				RP_SDPFromFile(rtp, (char *) szFile, sdp->chan);
-				gf_free(sdp->remote_url);
-				if (sdp->original_url) gf_free(sdp->original_url);
-				gf_free(sdp);
-				rtp->sdp_temp = NULL;
-				return;
+			e = gf_dm_sess_get_stats(rtp->dnload, NULL, NULL, &sdp_size, NULL, NULL, NULL);
+			if (sdp_size) {
+				const char *szFile = gf_dm_sess_get_cache_name(rtp->dnload);
+				if (!szFile) {
+					e = GF_SERVICE_ERROR;
+				} else {
+					e = GF_OK;
+					RP_SDPFromFile(rtp, (char *) szFile, sdp->chan);
+					gf_free(sdp->remote_url);
+					if (sdp->original_url) gf_free(sdp->original_url);
+					gf_free(sdp);
+					rtp->sdp_temp = NULL;
+					return;
+				}
 			}
 		}
+		break;
 	default:
 		if (e == GF_OK) return;
 	}


Updated svn:keywords property.

Updated svn:keywords property.

git-svn-id: 6c2b1bd10c324c49ea9d9e6e31006a80e70507cb@2155 5242fede-7e19-0410-aef8-94bd7d2200fb

--- source/headers/geos/geom/prep/PreparedGeometryFactory.h
+++ source/headers/geos/geom/prep/PreparedGeometryFactory.h
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id
+ * $Id$
  *
  * GEOS - Geometry Engine Open Source
  * http://geos.refractions.net


Converted yuv to "vout display" API.

Converted yuv to "vout display" API.

--- modules/video_output/yuv.c
+++ modules/video_output/yuv.c
@@ -31,303 +31,258 @@

 #include <vlc_common.h>
 #include <vlc_plugin.h>
-#include <vlc_vout.h>
+#include <vlc_vout_display.h>
+#include <vlc_picture_pool.h>
 #include <vlc_charset.h>

 /*****************************************************************************
+ * Module descriptor
+ *****************************************************************************/
+#define YUV_FILE_TEXT N_("device, fifo or filename")
+#define YUV_FILE_LONGTEXT N_("device, fifo or filename to write yuv frames too.")
+
+#define CHROMA_TEXT N_("Chroma used.")
+#define CHROMA_LONGTEXT N_(\
+    "Force use of a specific chroma for output. Default is I420.")
+
+#define YUV4MPEG2_TEXT N_("YUV4MPEG2 header (default disabled)")
+#define YUV4MPEG2_LONGTEXT N_("The YUV4MPEG2 header is compatible " \
+    "with mplayer yuv video ouput and requires YV12/I420 fourcc. By default "\
+    "vlc writes the fourcc of the picture frame into the output destination.")
+
+#define CFG_PREFIX "yuv-"
+
+static int  Open (vlc_object_t *);
+static void Close(vlc_object_t *);
+
+vlc_module_begin()
+    set_shortname(N_("YUV output"))
+    set_description(N_("YUV video output"))
+    set_category(CAT_VIDEO)
+    set_subcategory(SUBCAT_VIDEO_VOUT)
+    set_capability("vout display", 0)
+
+    add_string(CFG_PREFIX "file", "stream.yuv", NULL,
+                YUV_FILE_TEXT, YUV_FILE_LONGTEXT, false)
+    add_string(CFG_PREFIX "chroma", NULL, NULL,
+                CHROMA_TEXT, CHROMA_LONGTEXT, true)
+    add_bool  (CFG_PREFIX "yuv4mpeg2", false, NULL,
+                YUV4MPEG2_TEXT, YUV4MPEG2_LONGTEXT, true)
+
+    set_callbacks(Open, Close)
+vlc_module_end()
+
+/*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static int  Create    ( vlc_object_t * );
-static void Destroy   ( vlc_object_t * );
-
-static int  Init      ( vout_thread_t * );
-static void End       ( vout_thread_t *p_vout );
-static void Display   ( vout_thread_t *, picture_t * );
-
-/*****************************************************************************
- * Module descriptor
- *****************************************************************************/
-
-#define YUV_FILE_TEXT N_("device, fifo or filename")
-#define YUV_FILE_LONGTEXT N_("device, fifo or filename to write yuv frames too." )
-
-#define CHROMA_TEXT N_("Chroma used.")
-#define CHROMA_LONGTEXT N_( \
-    "Force use of a specific chroma for output. Default is I420." )
-
-#define YUV4MPEG2_TEXT N_( "YUV4MPEG2 header (default disabled)" )
-#define YUV4MPEG2_LONGTEXT N_( "The YUV4MPEG2 header is compatible " \
-    "with mplayer yuv video ouput and requires YV12/I420 fourcc. By default "\
-    "vlc writes the fourcc of the picture frame into the output destination." )
-
-#define CFG_PREFIX "yuv-"
-
-vlc_module_begin ()
-    set_shortname( N_( "YUV output" ) )
-    set_description( N_( "YUV video output" ) )
-    set_category( CAT_VIDEO )
-    set_subcategory( SUBCAT_VIDEO_VOUT )
-    set_capability( "video output", 0 )
-
-    add_string( CFG_PREFIX "file", "stream.yuv", NULL,
-                YUV_FILE_TEXT, YUV_FILE_LONGTEXT, false )
-    add_string( CFG_PREFIX "chroma", NULL, NULL,
-                CHROMA_TEXT, CHROMA_LONGTEXT, true )
-    add_bool  ( CFG_PREFIX "yuv4mpeg2", false, NULL,
-                YUV4MPEG2_TEXT, YUV4MPEG2_LONGTEXT, true )
-
-    set_callbacks( Create, Destroy )
-vlc_module_end ()
-
 static const char *const ppsz_vout_options[] = {
     "file", "chroma", "yuv4mpeg2", NULL
 };

-static void WriteYUV( vout_thread_t *p_vout, video_format_t fmt,
-                      picture_t *p_pic );
-
-/*****************************************************************************
- * vout_sys_t: video output descriptor
- *****************************************************************************/
-struct vout_sys_t
-{
-    char *psz_file;
-    FILE *p_fd;
-    bool  b_header;
-    bool  b_yuv4mpeg2;
-    vlc_fourcc_t i_chroma;
+/* */
+static picture_t *Get    (vout_display_t *);
+static void       Display(vout_display_t *, picture_t *);
+static int        Control(vout_display_t *, int, va_list);
+static void       Manage (vout_display_t *);
+
+/*****************************************************************************
+ * vout_display_sys_t: video output descriptor
+ *****************************************************************************/
+struct vout_display_sys_t {
+    FILE *f;
+    bool  is_first;
+    bool  is_yuv4mpeg2;
+    bool  use_dr;
+
+    picture_pool_t *pool;
 };

-/*****************************************************************************
- * Create: allocates video thread
- *****************************************************************************
- * This function allocates and initializes a vout method.
- *****************************************************************************/
-static int Create( vlc_object_t *p_this )
-{
-    vout_thread_t *p_vout = ( vout_thread_t * )p_this;
-    vout_sys_t *p_sys;
-    char *psz_fcc;
-
-    config_ChainParse( p_vout, CFG_PREFIX, ppsz_vout_options,
-                       p_vout->p_cfg );
+/* */
+static int Open(vlc_object_t *object)
+{
+    vout_display_t *vd = (vout_display_t *)object;
+    vout_display_sys_t *sys;

     /* Allocate instance and initialize some members */
-    p_vout->p_sys = p_sys = malloc( sizeof( vout_sys_t ) );
-    if( !p_vout->p_sys )
+    vd->sys = sys = malloc(sizeof(*sys));
+    if (!sys)
         return VLC_ENOMEM;

-    p_sys->b_header = false;
-    p_sys->p_fd = NULL;
-
-    p_sys->b_yuv4mpeg2 = var_CreateGetBool( p_this, CFG_PREFIX "yuv4mpeg2" );
-    p_sys->i_chroma = VLC_CODEC_I420;
-
-    p_sys->psz_file =
-            var_CreateGetString( p_this, CFG_PREFIX "file" );
-    p_sys->p_fd = utf8_fopen( p_sys->psz_file, "wb" );
-    if( !p_sys->p_fd )
-    {
-        free( p_sys->psz_file );
-        free( p_sys );
+    sys->is_first = false;
+    sys->is_yuv4mpeg2 = var_CreateGetBool(vd, CFG_PREFIX "yuv4mpeg2");
+    sys->pool = NULL;
+
+    /* */
+    char *psz_fcc = var_CreateGetNonEmptyString(vd, CFG_PREFIX "chroma");
+    const vlc_fourcc_t requested_chroma = vlc_fourcc_GetCodecFromString(VIDEO_ES,
+                                                                        psz_fcc);
+    free(psz_fcc);
+
+    const vlc_fourcc_t chroma = requested_chroma ? requested_chroma :
+                                                   VLC_CODEC_I420;
+    if (sys->is_yuv4mpeg2) {
+        switch (chroma) {
+        case VLC_CODEC_YV12:
+        case VLC_CODEC_I420:
+        case VLC_CODEC_J420:
+            break;
+        default:
+            msg_Err(vd, "YUV4MPEG2 mode needs chroma YV12 not %4.4s as requested",
+                    (char *)&chroma);
+            free(sys);
+            return VLC_EGENERIC;
+        }
+    }
+    sys->use_dr = chroma == vd->fmt.i_chroma;
+    msg_Dbg(vd, "Using chroma %4.4s", (char *)&chroma);
+
+    /* */
+    char *name = var_CreateGetNonEmptyString(vd, CFG_PREFIX "file");
+    if (!name) {
+        msg_Err(vd, "Empty file name");
+        free(sys);
         return VLC_EGENERIC;
     }
-
-    psz_fcc = var_CreateGetNonEmptyString( p_this, CFG_PREFIX "chroma" );
-    const vlc_fourcc_t i_requested_chroma =
-        vlc_fourcc_GetCodecFromString( VIDEO_ES, psz_fcc );
-    if( i_requested_chroma )
-        p_sys->i_chroma = i_requested_chroma;
-    free( psz_fcc );
-
-    if( p_sys->b_yuv4mpeg2 )
-    {
-        switch( p_sys->i_chroma )
-        {
-            case VLC_CODEC_YV12:
-            case VLC_CODEC_I420:
-            case VLC_CODEC_J420:
-                break;
-            default:
-                msg_Err( p_this,
-                    "YUV4MPEG2 mode needs chroma YV12 not %4s as requested",
-                    (char *)&(p_sys->i_chroma) );
-                fclose( p_vout->p_sys->p_fd );
-                free( p_vout->p_sys->psz_file );
-                free( p_vout->p_sys );
-                return VLC_EGENERIC;
-        }
-    }
-
-    msg_Dbg( p_this, "using chroma %4s", (char *)&(p_sys->i_chroma) );
-
-    p_vout->pf_init = Init;
-    p_vout->pf_end = End;
-    p_vout->pf_manage = NULL;
-    p_vout->pf_render = NULL;
-    p_vout->pf_display = Display;
-
+    sys->f = utf8_fopen(name, "wb");
+
+    if (!sys->f) {
+        msg_Err(vd, "Failed to open %s", name);
+        free(name);
+        free(sys);
+        return VLC_EGENERIC;
+    }
+    msg_Dbg(vd, "Writing data to %s", name);
+    free(name);
+
+    /* */
+    video_format_t fmt = vd->fmt;
+    fmt.i_chroma = chroma;
+    video_format_FixRgb(&fmt);
+
+    /* */
+    vout_display_info_t info = vd->info;
+    info.has_hide_mouse = true;
+
+    /* */
+    vd->fmt     = fmt;
+    vd->info    = info;
+    vd->get     = Get;
+    vd->prepare = NULL;
+    vd->display = Display;
+    vd->control = Control;
+    vd->manage  = Manage;
+
+    vout_display_SendEventFullscreen(vd, false);
     return VLC_SUCCESS;
 }

-/*****************************************************************************
- * Init: initialize video thread
- *****************************************************************************/
-static int Init( vout_thread_t *p_vout )
-{
-    vout_sys_t *p_sys = (vout_sys_t *) p_vout->p_sys;
-    int i_index;
-    picture_t *p_pic;
-
-    /* Initialize the output structure */
-    if( p_vout->render.i_chroma != p_sys->i_chroma )
-        p_vout->output.i_chroma = p_vout->fmt_out.i_chroma = p_sys->i_chroma;
+/* */
+static void Close(vlc_object_t *object)
+{
+    vout_display_t *vd = (vout_display_t *)object;
+    vout_display_sys_t *sys = vd->sys;
+
+    if (sys->pool)
+        picture_pool_Delete(sys->pool);
+    fclose(sys->f);
+    free(sys);
+}
+
+/*****************************************************************************
+ *
+ *****************************************************************************/
+static picture_t *Get(vout_display_t *vd)
+{
+    vout_display_sys_t *sys = vd->sys;
+    if (!sys->pool) {
+        sys->pool = picture_pool_NewFromFormat(&vd->fmt, sys->use_dr ? VOUT_MAX_PICTURES : 1);
+        if (!sys->pool)
+            return NULL;
+    }
+    return picture_pool_Get(sys->pool);
+}
+
+static void Display(vout_display_t *vd, picture_t *picture)
+{
+    vout_display_sys_t *sys = vd->sys;
+
+    /* */
+    video_format_t fmt = vd->fmt;
+    fmt.i_sar_num = vd->source.i_sar_num;
+    fmt.i_sar_den = vd->source.i_sar_den;
+
+    /* */
+    char type;
+    if (picture->b_progressive)
+        type = 'p';
+    else if (picture->b_top_field_first)
+        type = 't';
     else
-       p_vout->output.i_chroma = p_vout->render.i_chroma;
-
-    p_vout->output.pf_setpalette = NULL;
-    p_vout->output.i_width = p_vout->render.i_width;
-    p_vout->output.i_height = p_vout->render.i_height;
-    p_vout->output.i_aspect = p_vout->output.i_width
-                               * VOUT_ASPECT_FACTOR / p_vout->output.i_height;
-
-    p_vout->output.i_rmask = 0xff0000;
-    p_vout->output.i_gmask = 0x00ff00;
-    p_vout->output.i_bmask = 0x0000ff;
-
-    /* Try to initialize 1 direct buffer */
-    p_pic = NULL;
-
-    /* Find an empty picture slot */
-    for( i_index = 0 ; i_index < VOUT_MAX_PICTURES ; i_index++ )
-    {
-        if( p_vout->p_picture[ i_index ].i_status == FREE_PICTURE )
-        {
-            p_pic = p_vout->p_picture + i_index;
-            break;
-        }
-    }
-
-    /* Allocate the picture */
-    if( p_pic == NULL )
-        return VLC_EGENERIC;
-
-    vout_AllocatePicture( VLC_OBJECT(p_vout), p_pic, p_vout->output.i_chroma,
-                          p_vout->output.i_width, p_vout->output.i_height,
-                          p_vout->output.i_aspect );
-
-    if( p_pic->i_planes == 0 )
-    {
-        return VLC_EGENERIC;
-    }
-
-    p_pic->i_status = DESTROYED_PICTURE;
-    p_pic->i_type   = DIRECT_PICTURE;
-
-    PP_OUTPUTPICTURE[ I_OUTPUTPICTURES ] = p_pic;
-    I_OUTPUTPICTURES++;
-    return VLC_SUCCESS;
-}
-
-/*****************************************************************************
- * Destroy: destroy video thread
- *****************************************************************************
- * Terminate an output method created by Create
- *****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
-{
-    int i_index;
-    vout_thread_t *p_vout = ( vout_thread_t * )p_this;
-
-    for( i_index = I_OUTPUTPICTURES-1; i_index >= 0; i_index-- )
-    {
-        free( PP_OUTPUTPICTURE[ i_index ]->p_data );
-    }
-
-    /* Destroy structure */
-    fclose( p_vout->p_sys->p_fd );
-
-    free( p_vout->p_sys->psz_file );
-    free( p_vout->p_sys );
-}
-
-/*****************************************************************************
- * Display: displays previously rendered output
- *****************************************************************************
- * This function copies the rendered picture into our circular buffer.
- *****************************************************************************/
-static void Display( vout_thread_t *p_vout, picture_t *p_pic )
-{
-    video_format_t fmt_in;
-
-    memset( &fmt_in, 0, sizeof( fmt_in ) );
-    video_format_Copy( &fmt_in, &p_pic->format );
-    /* assume square pixels if i_sar_num = 0 */
-    if( p_pic->format.i_sar_num == 0 )
-        fmt_in.i_sar_num = fmt_in.i_sar_den = 1;
-
-    WriteYUV( p_vout, fmt_in, p_pic );
-    video_format_Clean( &fmt_in );
-    return;
-}
-
-static void End( vout_thread_t *p_vout )
-{
-    VLC_UNUSED(p_vout);
-}
-
-static void WriteYUV( vout_thread_t *p_vout, video_format_t fmt,
-                      picture_t *p_pic )
-{
-    vout_sys_t *p_sys = p_vout->p_sys;
-
-    if( !p_pic || !p_sys ) return;
-
-#if 0
-    msg_Dbg( p_vout, "writing %d bytes of fourcc %4s",
-             i_bytes, (char *)&fmt.i_chroma );
-#endif
-    if( !p_sys->b_header )
-    {
-        const char *p_hdr = "";
-        if( p_sys->b_yuv4mpeg2 )
-        {
+        type = 'b';
+
+    if (type != 'p') {
+        msg_Warn(vd, "Received a non progressive frame, "
+                     "it will be written as progressive.");
+        type = 'p';
+    }
+
+    /* */
+    if (!sys->is_first) {
+        const char *header;
+        char buffer[5];
+        if (sys->is_yuv4mpeg2) {
             /* MPlayer compatible header, unfortunately it doesn't tell you
              * the exact fourcc used. */
-            p_hdr = "YUV4MPEG2";
+            header = "YUV4MPEG2";
+        } else {
+            snprintf(buffer, sizeof(buffer), "%4.4s",
+                     (const char*)&fmt.i_chroma);
+            header = buffer;
         }
-        else
-        {
-            p_hdr = (const char*)&fmt.i_chroma;
+
+        fprintf(sys->f, "%s W%d H%d F%d:%d I%c A%d:%d\n",
+                header,
+                fmt.i_visible_width, fmt.i_visible_height,
+                fmt.i_frame_rate, fmt.i_frame_rate_base,
+                type,
+                fmt.i_sar_num, fmt.i_sar_den);
+        sys->is_first = true;
+    }
+
+    /* */
+    fprintf(sys->f, "FRAME\n");
+    for (int i = 0; i < picture->i_planes; i++) {
+        const plane_t *plane = &picture->p[i];
+        for( int y = 0; y < plane->i_visible_lines; y++) {
+            const size_t written = fwrite(&plane->p_pixels[y*plane->i_pitch],
+                                          1, plane->i_visible_pitch, sys->f);
+            if (written != (size_t)plane->i_visible_pitch)
+                msg_Warn(vd, "only %zd of %d bytes written",
+                         written, plane->i_visible_pitch);
         }
-        fprintf( p_sys->p_fd, "%4s W%d H%d F%d:%d I%c A%d:%d\n",
-                 p_hdr,
-                 fmt.i_width, fmt.i_height,
-                 fmt.i_frame_rate, fmt.i_frame_rate_base,
-                 (p_pic->b_progressive ? 'p' :
-                         (p_pic->b_top_field_first ? 't' : 'b')),
-                 fmt.i_sar_num, fmt.i_sar_den );
-        fflush( p_sys->p_fd );
-        p_sys->b_header = true;
-    }
-
-    fprintf( p_sys->p_fd, "FRAME\n" );
-    if( p_pic->b_progressive )
-    {
-        size_t i_bytes = (fmt.i_width * fmt.i_height * fmt.i_bits_per_pixel) >> 3;
-        size_t i_written = 0;
-
-        i_written = fwrite( p_pic->p_data, 1, i_bytes, p_sys->p_fd );
-        if( i_written != i_bytes )
-        {
-            msg_Warn( p_vout, "only %zd of %zd bytes written",
-                      i_written, i_bytes );
-        }
-    }
-    else
-    {
-        msg_Warn( p_vout, "only progressive frames are supported, "
-                          "use a deinterlace filter" );
-    }
-    fflush( p_sys->p_fd );
-}
+    }
+    fflush(sys->f);
+
+    /* */
+    picture_Release(picture);
+}
+
+static int Control(vout_display_t *vd, int query, va_list args)
+{
+    VLC_UNUSED(vd);
+    switch (query) {
+    case VOUT_DISPLAY_CHANGE_FULLSCREEN: {
+        const vout_display_cfg_t *cfg = va_arg(args, const vout_display_cfg_t *);
+        if (cfg->is_fullscreen)
+            return VLC_EGENERIC;
+        return VLC_SUCCESS;
+    }
+    default:
+        return VLC_EGENERIC;
+    }
+}
+static void Manage (vout_display_t *vd)
+{
+    VLC_UNUSED(vd);
+}
+


Protect sgmap extents with splvm(); from NetBSD.

--- arch/alpha/dev/sgmap_typedep.c
+++ arch/alpha/dev/sgmap_typedep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sgmap_typedep.c,v 1.4 2004/11/09 19:17:01 claudio Exp $ */
+/* $OpenBSD: sgmap_typedep.c,v 1.5 2006/03/13 19:50:07 miod Exp $ */
 /* $NetBSD: sgmap_typedep.c,v 1.17 2001/07/19 04:27:37 thorpej Exp $ */

 /*-
@@ -68,7 +68,7 @@
 	bus_addr_t dmaoffset, sgva;
 	bus_size_t sgvalen, boundary, alignment;
 	SGMAP_PTE_TYPE *pte, *page_table = sgmap->aps_pt;
-	int pteidx, error, spill;
+	int s, pteidx, error, spill;

 	/* Initialize the spill page PTE if it hasn't been already. */
 	if (__C(SGMAP_TYPE,_prefetch_spill_page_pte) == 0)
@@ -123,8 +123,10 @@
 	    (endva - va), sgvalen, map->_dm_boundary, boundary);
 #endif

+	s = splvm();
 	error = extent_alloc(sgmap->aps_ex, sgvalen, alignment, 0, boundary,
 	    (flags & BUS_DMA_NOWAIT) ? EX_NOWAIT : EX_WAITOK, &sgva);
+	splx(s);
 	if (error)
 		return (error);

@@ -301,7 +303,7 @@
 {
 	SGMAP_PTE_TYPE *pte, *page_table = sgmap->aps_pt;
 	bus_addr_t osgva, sgva, esgva;
-	int spill, seg, pteidx;
+	int s, error, spill, seg, pteidx;

 	for (seg = 0; seg < map->dm_nsegs; seg++) {
 		/* XXX Always have a spill page for now... */
@@ -330,8 +332,11 @@
 		alpha_mb();

 		/* Free the virtual address space used by the mapping. */
-		if (extent_free(sgmap->aps_ex, osgva, (esgva - osgva),
-		    EX_NOWAIT) != 0)
+		s = splvm();
+		error = extent_free(sgmap->aps_ex, osgva, (esgva - osgva),
+		    EX_NOWAIT);
+		splx(s);
+		if (error != 0)
 			panic(__S(__C(SGMAP_TYPE,_unload)));
 	}


Similar fix to amd64 and i386 for isa bus_dma.

Don't trunc_page when determining the highest address to alloc. it is
not what pglistalloc expects and pmemrange will fail that allocation.

For consistency, if we fail to alloc under 16meg then alloc high as
assume we'll bounce (same as i386 and amd64)

ok deraadt@

--- arch/alpha/isa/isadma_bounce.c
+++ arch/alpha/isa/isadma_bounce.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: isadma_bounce.c,v 1.8 2008/06/26 05:42:08 ray Exp $	*/
+/*	$OpenBSD: isadma_bounce.c,v 1.9 2010/03/27 02:09:54 oga Exp $	*/
 /* $NetBSD: isadma_bounce.c,v 1.3 2000/06/29 09:02:57 mrg Exp $ */

 /*-
@@ -518,15 +518,18 @@
     bus_size_t alignment, bus_size_t boundary, bus_dma_segment_t *segs,
     int nsegs, int *rsegs, int flags)
 {
-	paddr_t high;
-
-	if (avail_end > ISA_DMA_BOUNCE_THRESHOLD)
-		high = trunc_page(ISA_DMA_BOUNCE_THRESHOLD);
-	else
-		high = trunc_page(avail_end);
-
-	return (_bus_dmamem_alloc_range(t, size, alignment, boundary,
-	    segs, nsegs, rsegs, flags, 0, high));
+	int error;
+
+	/* Try in ISA addressable region first */
+	error = _bus_dmamem_alloc_range(t, size, alignment, boundary,
+	    segs, nsegs, rsegs, flags, 0, ISA_DMA_BOUNCE_THRESHOLD);
+	if (!error)
+		return (error);
+
+	/* Otherwise try anywhere (we'll bounce later) */
+	error = _bus_dmamem_alloc_range(t, size, alignment, boundary,
+	    segs, nsegs, rsegs, flags, (paddr_t)0, (paddr_t)-1);
+	return (error);
 }

 /**********************************************************************
@@ -541,9 +544,10 @@
 	int error = 0;

 	cookie->id_bouncebuflen = round_page(size);
-	error = isadma_bounce_dmamem_alloc(t, cookie->id_bouncebuflen,
+	error = _bus_dmamem_alloc_range(t, cookie->id_bouncebuflen,
 	    PAGE_SIZE, map->_dm_boundary, cookie->id_bouncesegs,
-	    map->_dm_segcnt, &cookie->id_nbouncesegs, flags);
+	    map->_dm_segcnt, &cookie->id_nbouncesegs, flags,
+	    0, ISA_DMA_BOUNCE_THRESHOLD);
 	if (error)
 		goto out;
 	error = _bus_dmamem_map(t, cookie->id_bouncesegs,


board: msm_9625: Add TSENS as part of early init

Add TSENS driver to support clients the ability to read
temperature.

Change-Id: I05f000b732ff575b8c957aaac31033cb22e9bc4f
Signed-off-by: Siddartha Mohanadoss <9c97603a3a6be1a8a5dd7a9c9672e79ad0487bf3@codeaurora.org>

--- arch/arm/mach-msm/board-9625.c
+++ arch/arm/mach-msm/board-9625.c
@@ -107,6 +107,8 @@
 			"msm_sdcc.2", NULL),
 	OF_DEV_AUXDATA("qcom,msm-sdcc", 0xF9864000, \
 			"msm_sdcc.3", NULL),
+	OF_DEV_AUXDATA("qcom,msm-tsens", 0xFC4A8000, \
+			"msm-tsens", NULL),
 	{}
 };


msm: clock-8960: Support alternate PLL4 clock plan

PLL4 may be running at either 491.52MHz or 393.216MHz. Detect the
rate at runtime and select the appropriate frequency tables so that
the same rates for PLL4-based clocks can be used with either
configuration.

To ensure that any PLL configuration done as part of reg_init()
takes place before the rate-detection occurs, move the reg_init()
call to the top of msm8960_clock_pre_init().

Change-Id: I547ce16334acaeee4797147e47684672d8a5bade
Signed-off-by: Matt Wagantall <f353a1326f7aad71d23381a3beb9470c3b31d81b@codeaurora.org>


msm: smp2p_gpio: Change non-fatal error message to SMP2P_INFO

Calling smp2p_set_value() with an invalid gpio_chip type is not fatal,
and does not require printing an error to the kernel log.

Change the log message type to SMP2P_INFO to reflect the non-fatal status
of this error.

Change-Id: I7fc9a876d3b0637894e174e4b29422af6d0f1f79
Signed-off-by: Jeffrey Hugo <818337a29cd9de0a36216deae1fd60ff7b0ab832@codeaurora.org>

--- arch/arm/mach-msm/smp2p_gpio.c
+++ arch/arm/mach-msm/smp2p_gpio.c
@@ -133,7 +133,7 @@
 		return;

 	if (chip->is_inbound) {
-		SMP2P_ERR("%s: '%s':%d virq %d invalid operation\n",
+		SMP2P_INFO("%s: '%s':%d virq %d invalid operation\n",
 			__func__, chip->name, chip->remote_pid,
 			chip->irq_base + offset);
 		return;


omap iommu: cleanup iommu page address mask and definitions

This is just a cleanup, but adds a few macros here, which can be used
in the proceeding patches.

Signed-off-by: Hiroshi DOYU <e891c4ae8deef7e6c0a3fb82004ec71ca9fb7e00@nokia.com>
Signed-off-by: Tony Lindgren <1001e8702733cced254345e193c88aaa47a4f5de@atomide.com>

--- arch/arm/plat-omap/iopgtable.h
+++ arch/arm/plat-omap/iopgtable.h
@@ -1,7 +1,7 @@
 /*
  * omap iommu: pagetable definitions
  *
- * Copyright (C) 2008-2009 Nokia Corporation
+ * Copyright (C) 2008-2010 Nokia Corporation
  *
  * Written by Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
  *
@@ -13,26 +13,52 @@
 #ifndef __PLAT_OMAP_IOMMU_H
 #define __PLAT_OMAP_IOMMU_H

+/*
+ * "L2 table" address mask and size definitions.
+ */
 #define IOPGD_SHIFT		20
-#define IOPGD_SIZE		(1 << IOPGD_SHIFT)
+#define IOPGD_SIZE		(1UL << IOPGD_SHIFT)
 #define IOPGD_MASK		(~(IOPGD_SIZE - 1))
-#define IOSECTION_MASK		IOPGD_MASK
-#define PTRS_PER_IOPGD		(1 << (32 - IOPGD_SHIFT))
+
+/*
+ * "section" address mask and size definitions.
+ */
+#define IOSECTION_SHIFT		20
+#define IOSECTION_SIZE		(1UL << IOSECTION_SHIFT)
+#define IOSECTION_MASK		(~(IOSECTION_SIZE - 1))
+
+/*
+ * "supersection" address mask and size definitions.
+ */
+#define IOSUPER_SHIFT		24
+#define IOSUPER_SIZE		(1UL << IOSUPER_SHIFT)
+#define IOSUPER_MASK		(~(IOSUPER_SIZE - 1))
+
+#define PTRS_PER_IOPGD		(1UL << (32 - IOPGD_SHIFT))
 #define IOPGD_TABLE_SIZE	(PTRS_PER_IOPGD * sizeof(u32))

-#define IOSUPER_SIZE		(IOPGD_SIZE << 4)
-#define IOSUPER_MASK		(~(IOSUPER_SIZE - 1))
+/*
+ * "small page" address mask and size definitions.
+ */
+#define IOPTE_SHIFT		12
+#define IOPTE_SIZE		(1UL << IOPTE_SHIFT)
+#define IOPTE_MASK		(~(IOPTE_SIZE - 1))

-#define IOPTE_SHIFT		12
-#define IOPTE_SIZE		(1 << IOPTE_SHIFT)
-#define IOPTE_MASK		(~(IOPTE_SIZE - 1))
-#define IOPAGE_MASK		IOPTE_MASK
-#define PTRS_PER_IOPTE		(1 << (IOPGD_SHIFT - IOPTE_SHIFT))
+/*
+ * "large page" address mask and size definitions.
+ */
+#define IOLARGE_SHIFT		16
+#define IOLARGE_SIZE		(1UL << IOLARGE_SHIFT)
+#define IOLARGE_MASK		(~(IOLARGE_SIZE - 1))
+
+#define PTRS_PER_IOPTE		(1UL << (IOPGD_SHIFT - IOPTE_SHIFT))
 #define IOPTE_TABLE_SIZE	(PTRS_PER_IOPTE * sizeof(u32))

-#define IOLARGE_SIZE		(IOPTE_SIZE << 4)
-#define IOLARGE_MASK		(~(IOLARGE_SIZE - 1))
+#define IOPAGE_MASK		IOPTE_MASK

+/*
+ * some descriptor attributes.
+ */
 #define IOPGD_TABLE		(1 << 0)
 #define IOPGD_SECTION		(2 << 0)
 #define IOPGD_SUPER		(1 << 18 | 2 << 0)
@@ -40,12 +66,14 @@
 #define IOPTE_SMALL		(2 << 0)
 #define IOPTE_LARGE		(1 << 0)

+/* to find an entry in a page-table-directory */
 #define iopgd_index(da)		(((da) >> IOPGD_SHIFT) & (PTRS_PER_IOPGD - 1))
 #define iopgd_offset(obj, da)	((obj)->iopgd + iopgd_index(da))

 #define iopte_paddr(iopgd)	(*iopgd & ~((1 << 10) - 1))
 #define iopte_vaddr(iopgd)	((u32 *)phys_to_virt(iopte_paddr(iopgd)))

+/* to find an entry in the second-level page table. */
 #define iopte_index(da)		(((da) >> IOPTE_SHIFT) & (PTRS_PER_IOPTE - 1))
 #define iopte_offset(iopgd, da)	(iopte_vaddr(iopgd) + iopte_index(da))


arm64: perf: Remove unnecessary printk

arm64: perf: Remove unnecessary printk

ARM64 pmu prints an error message in event_init() when
no hardware PMU is available. This is pretty annoying as
it keeps printing the message for every single trial, flooding
the kernel logs, unnecessarily. The return code is sufficient for
the user to figure out the reason.

Signed-off-by: Suzuki K. Poulose <25f0e69a3d23ed1d9a060214a9ff1a9504ba3f49@arm.com>
Signed-off-by: Will Deacon <b913f13ef92ac157955c954ccaaff7be065faba4@arm.com>

--- arch/arm64/kernel/perf_event.c
+++ arch/arm64/kernel/perf_event.c
@@ -435,10 +435,8 @@
 	unsigned int i, irqs;
 	struct platform_device *pmu_device = armpmu->plat_device;

-	if (!pmu_device) {
-		pr_err("no PMU device registered\n");
+	if (!pmu_device)
 		return -ENODEV;
-	}

 	irqs = min(pmu_device->num_resources, num_possible_cpus());
 	if (!irqs) {


don't touch via 8237 for now, until it is fixed. what mickey committed is obviosuly NOT what I tested, since that worked.

--- arch/i386/pci/pci_intr_fixup.c
+++ arch/i386/pci/pci_intr_fixup.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: pci_intr_fixup.c,v 1.43 2005/10/20 15:12:27 mickey Exp $	*/
+/*	$OpenBSD: pci_intr_fixup.c,v 1.44 2005/10/24 16:02:40 henning Exp $	*/
 /*	$NetBSD: pci_intr_fixup.c,v 1.10 2000/08/10 21:18:27 soda Exp $	*/

 /*
@@ -182,8 +182,6 @@

 	{ PCI_VENDOR_VIATECH,	PCI_PRODUCT_VIATECH_VT8231_ISA,
 	  via8231_init },
-	{ PCI_VENDOR_VIATECH,	PCI_PRODUCT_VIATECH_VT8237_ISA,
-	  via8231_init },

 	{ PCI_VENDOR_SIS,	PCI_PRODUCT_SIS_85C503,
 	  sis85c503_init },


[IA64] ia64 does not need umount2() syscall

ia64 doesn't have old and new versions of the umount system call.
It just has the new version.

Fixes this build warning:
<stdin>:395:2: warning: #warning syscall umount2 not implemented

Signed-off-by: Tony Luck <e7984595ec0368ff920a7b3521dc7093683f6f26@intel.com>

--- arch/ia64/include/asm/unistd.h
+++ arch/ia64/include/asm/unistd.h
@@ -329,6 +329,7 @@
 #define __IGNORE_utime		/* utimes() */
 #define __IGNORE_getpgrp	/* getpgid() */
 #define __IGNORE_vfork		/* clone() */
+#define __IGNORE_umount2	/* umount() */

 #define __ARCH_WANT_SYS_RT_SIGACTION
 #define __ARCH_WANT_SYS_RT_SIGSUSPEND


Release the secondary processor initialization interlock a bit later, after the currently running processor has advertized itself as ready.

--- arch/mvme88k/mvme88k/machdep.c
+++ arch/mvme88k/mvme88k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.218 2009/02/13 23:26:51 miod Exp $	*/
+/* $OpenBSD: machdep.c,v 1.219 2009/02/13 23:31:29 miod Exp $	*/
 /*
  * Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
  * Copyright (c) 1996 Nivas Madhur
@@ -759,12 +759,12 @@
 	cpu_configuration_print(0);
 	ncpus++;

-	__cpu_simple_unlock(&cpu_boot_mutex);
-
 	microuptime(&ci->ci_schedstate.spc_runtime);
 	ci->ci_curproc = NULL;
 	ci->ci_randseed = random();
 	SET(ci->ci_flags, CIF_ALIVE);
+
+	__cpu_simple_unlock(&cpu_boot_mutex);

 	set_psr(get_psr() & ~PSR_IND);
 	spl0();


ppc: Remove duplicate definition of PV_POWER7

One definition of PV_POWER7 seems enough to me.

Signed-off-by: Peter Zijlstra <645ca7d3a8d3d4f60557176cd361ea8351edc32b@chello.nl>
Signed-off-by: Benjamin Herrenschmidt <a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org>

--- arch/powerpc/include/asm/reg.h
+++ arch/powerpc/include/asm/reg.h
@@ -1003,7 +1003,6 @@
 #define PV_970		0x0039
 #define PV_POWER5	0x003A
 #define PV_POWER5p	0x003B
-#define PV_POWER7	0x003F
 #define PV_970FX	0x003C
 #define PV_POWER6	0x003E
 #define PV_POWER7	0x003F


powerpc/perf: Add BHRB constraint and IFM MMCRA handling for EBB

We want a way for users of EBB (Event Based Branches) to also access the
BHRB (Branch History Rolling Buffer). EBB does not interoperate with our
existing BHRB support, which is wired into the generic Linux branch
stack sampling support.

To support EBB & BHRB we add three new bits to the event code. The first
bit indicates that the event wants access to the BHRB, and the other two
bits indicate the desired IFM (Instruction Filtering Mode).

We allow multiple events to request access to the BHRB, but they must
agree on the IFM value. Events which are not interested in the BHRB can
also interoperate with events which do.

Finally we program the desired IFM value into MMCRA. Although we do this
for every event, we know that the value will be identical for all events
that request BHRB access.

Signed-off-by: Michael Ellerman <864f124608374e06e4da1fa5d2e47ed839b95411@ellerman.id.au>
Signed-off-by: Benjamin Herrenschmidt <a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org>

--- arch/powerpc/perf/power8-pmu.c
+++ arch/powerpc/perf/power8-pmu.c
@@ -64,9 +64,11 @@
  *
  *        60        56        52        48        44        40        36        32
  * | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - |
- *   |                                 [      thresh_cmp     ]   [  thresh_ctl   ]
- *   |                                                                   |
- *   *- EBB (Linux)                      thresh start/stop OR FAB match -*
+ *   | | [ ]                           [      thresh_cmp     ]   [  thresh_ctl   ]
+ *   | |  |                                                              |
+ *   | |  *- IFM (Linux)                 thresh start/stop OR FAB match -*
+ *   | *- BHRB (Linux)
+ *   *- EBB (Linux)
  *
  *        28        24        20        16        12         8         4         0
  * | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - |
@@ -116,10 +118,18 @@
  *	MMCRA[57:59] = sample[0:2]	(RAND_SAMP_ELIG)
  *	MMCRA[61:62] = sample[3:4]	(RAND_SAMP_MODE)
  *
+ * if EBB and BHRB:
+ *	MMCRA[32:33] = IFM
+ *
  */

 #define EVENT_EBB_MASK		1ull
 #define EVENT_EBB_SHIFT		PERF_EVENT_CONFIG_EBB_SHIFT
+#define EVENT_BHRB_MASK		1ull
+#define EVENT_BHRB_SHIFT	62
+#define EVENT_WANTS_BHRB	(EVENT_BHRB_MASK << EVENT_BHRB_SHIFT)
+#define EVENT_IFM_MASK		3ull
+#define EVENT_IFM_SHIFT		60
 #define EVENT_THR_CMP_SHIFT	40	/* Threshold CMP value */
 #define EVENT_THR_CMP_MASK	0x3ff
 #define EVENT_THR_CTL_SHIFT	32	/* Threshold control value (start/stop) */
@@ -144,6 +154,12 @@
 #define EVENT_IS_MARKED		(EVENT_MARKED_MASK << EVENT_MARKED_SHIFT)
 #define EVENT_PSEL_MASK		0xff	/* PMCxSEL value */

+/* Bits defined by Linux */
+#define EVENT_LINUX_MASK	\
+	((EVENT_EBB_MASK  << EVENT_EBB_SHIFT)			|	\
+	 (EVENT_BHRB_MASK << EVENT_BHRB_SHIFT)			|	\
+	 (EVENT_IFM_MASK  << EVENT_IFM_SHIFT))
+
 #define EVENT_VALID_MASK	\
 	((EVENT_THRESH_MASK    << EVENT_THRESH_SHIFT)		|	\
 	 (EVENT_SAMPLE_MASK    << EVENT_SAMPLE_SHIFT)		|	\
@@ -152,7 +168,7 @@
 	 (EVENT_UNIT_MASK      << EVENT_UNIT_SHIFT)		|	\
 	 (EVENT_COMBINE_MASK   << EVENT_COMBINE_SHIFT)		|	\
 	 (EVENT_MARKED_MASK    << EVENT_MARKED_SHIFT)		|	\
-	 (EVENT_EBB_MASK       << EVENT_EBB_SHIFT)		|	\
+	  EVENT_LINUX_MASK					|	\
 	  EVENT_PSEL_MASK)

 /* MMCRA IFM bits - POWER8 */
@@ -176,10 +192,11 @@
  *
  *        28        24        20        16        12         8         4         0
  * | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - |
- *                   |   [ ]   [  sample ]   [     ]   [6] [5]   [4] [3]   [2] [1]
- *              EBB -*    |                     |
- *                        |                     |      Count of events for each PMC.
- *      L1 I/D qualifier -*                     |        p1, p2, p3, p4, p5, p6.
+ *               [ ] |   [ ]   [  sample ]   [     ]   [6] [5]   [4] [3]   [2] [1]
+ *                |  |    |                     |
+ *      BHRB IFM -*  |    |                     |      Count of events for each PMC.
+ *              EBB -*    |                     |        p1, p2, p3, p4, p5, p6.
+ *      L1 I/D qualifier -*                     |
  *                     nc - number of counters -*
  *
  * The PMC fields P1..P6, and NC, are adder fields. As we accumulate constraints
@@ -197,6 +214,9 @@

 #define CNST_EBB_VAL(v)		(((v) & EVENT_EBB_MASK) << 24)
 #define CNST_EBB_MASK		CNST_EBB_VAL(EVENT_EBB_MASK)
+
+#define CNST_IFM_VAL(v)		(((v) & EVENT_IFM_MASK) << 25)
+#define CNST_IFM_MASK		CNST_IFM_VAL(EVENT_IFM_MASK)

 #define CNST_L1_QUAL_VAL(v)	(((v) & 3) << 22)
 #define CNST_L1_QUAL_MASK	CNST_L1_QUAL_VAL(3)
@@ -244,6 +264,7 @@
 #define MMCRA_THR_SEL_SHIFT		16
 #define MMCRA_THR_CMP_SHIFT		32
 #define MMCRA_SDAR_MODE_TLB		(1ull << 42)
+#define MMCRA_IFM_SHIFT			30

 static inline bool event_is_fab_match(u64 event)
@@ -277,7 +298,7 @@
 			return -1;

 		/* Ignore Linux defined bits when checking event below */
-		base_event = event & ~(EVENT_EBB_MASK << EVENT_EBB_SHIFT);
+		base_event = event & ~EVENT_LINUX_MASK;

 		if (pmc >= 5 && base_event != 0x500fa && base_event != 0x600f4)
 			return -1;
@@ -346,6 +367,15 @@
 	if (!pmc && ebb)
 		/* EBB events must specify the PMC */
 		return -1;
+
+	if (event & EVENT_WANTS_BHRB) {
+		if (!ebb)
+			/* Only EBB events can request BHRB */
+			return -1;
+
+		mask  |= CNST_IFM_MASK;
+		value |= CNST_IFM_VAL(event >> EVENT_IFM_SHIFT);
+	}

 	/*
 	 * All events must agree on EBB, either all request it or none.
@@ -434,6 +464,11 @@
 			mmcra |= val << MMCRA_THR_SEL_SHIFT;
 			val = (event[i] >> EVENT_THR_CMP_SHIFT) & EVENT_THR_CMP_MASK;
 			mmcra |= val << MMCRA_THR_CMP_SHIFT;
+		}
+
+		if (event[i] & EVENT_WANTS_BHRB) {
+			val = (event[i] >> EVENT_IFM_SHIFT) & EVENT_IFM_MASK;
+			mmcra |= val << MMCRA_IFM_SHIFT;
 		}

 		hwc[i] = pmc - 1;


implement BUFCACHEPERCENT and take care with kva space

--- arch/powerpc/powerpc/machdep.c
+++ arch/powerpc/powerpc/machdep.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: machdep.c,v 1.5 1997/02/05 01:33:54 rahnds Exp $	*/
+/*	$OpenBSD: machdep.c,v 1.6 1997/02/24 12:50:28 deraadt Exp $	*/
 /*	$NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $	*/

 /*
@@ -465,16 +465,29 @@
 	valloc(msqids, struct msqid_ds, msginfo.msgmni);
 #endif

+#ifndef BUFCACHEPERCENT
+#define BUFCACHEPERCENT 5
+#endif
 	/*
 	 * Decide on buffer space to use.
 	 */
 	if (bufpages == 0)
-		bufpages = (physmem / 20) / CLSIZE;
+		bufpages = (physmem / ((100/BUFCACHEPERCENT) / CLSIZE);
 	if (nbuf == 0) {
 		nbuf = bufpages;
 		if (nbuf < 16)
 			nbuf = 16;
 	}
+	/* Restrict to at most 70% filled kvm */
+	if (nbuf * MAXBSIZE >
+	    (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) * 7 / 10)
+		nbuf = (VM_MAX_KERNEL_ADDRESS-VM_MIN_KERNEL_ADDRESS) /
+		    MAXBSIZE * 7 / 10;
+
+	/* More buffer pages than fits into the buffers is senseless.  */
+	if (bufpages > nbuf * MAXBSIZE / CLBYTES)
+		bufpages = nbuf * MAXBSIZE / CLBYTES;
+
 	if (nswbuf == 0) {
 		nswbuf = (nbuf / 2) & ~1;
 		if (nswbuf > 256)


Fix crash in TextField when there is no font or no text

--- libswfdec/swfdec_text_field_movie.c
+++ libswfdec/swfdec_text_field_movie.c
@@ -533,7 +533,8 @@
   swfdec_text_format_set_defaults (text->format_new);
   text->format_new->color = text->text->color;
   text->format_new->align = text->text->align;
-  text->format_new->font = text->text->font->name;
+  if (text->text->font != NULL && text->text->font->name != NULL)
+    text->format_new->font = text->text->font->name;
   text->format_new->size = text->text->size / 20;
   text->format_new->left_margin = text->text->left_margin / 20;
   text->format_new->right_margin = text->text->right_margin / 20;
@@ -547,6 +548,9 @@
   if (text->text->text_input != NULL) {
     swfdec_text_field_movie_set_text (text,
 	swfdec_as_context_get_string (cx, text->text->text_input),
+	text->text->html);
+  } else {
+    swfdec_text_field_movie_set_text (text, SWFDEC_AS_STR_EMPTY,
 	text->text->html);
   }


Scan all render nodes in dispatcher

Scan all render nodes in dispatcher

In certain configurations, notably in containers it is possible to have /sys/class/drm/renderD128 and
/sys/class/drm/renderD129 but no /dev/dri/renderD128. This fix enumerate all renderD128+(0..63) instead of stopping
at first failure.

--- api/mfx_dispatch/linux/device_ids.h
+++ api/mfx_dispatch/linux/device_ids.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2021 Intel Corporation
+// Copyright (c) 2022 Intel Corporation
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to deal
@@ -19,6 +19,7 @@
 // SOFTWARE.

 #include <stdio.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <algorithm>
 #include <string>
@@ -413,21 +414,29 @@
     std::vector <Device> result;
     for (; i < 64; ++i) {
         Device device;
-        std::string path = std::string(dir) + "/renderD" + std::to_string(128 + i) + vendor_id_file;
+        std::string node_num = std::to_string(128 + i);
+        std::string path = std::string(dir) + "/renderD" + node_num + vendor_id_file;
         FILE *file = fopen(path.c_str(), "r");
-        if (!file) break;
+        if (!file) continue;
         err = fscanf(file, "%x", &device.vendor_id);
         fclose(file);
-        if (err == EOF) break;
+        if (err == EOF) continue;
         if (device.vendor_id != 0x8086) {  // Filter out non-Intel devices
             continue;
         }
-        path = std::string(dir) + "/renderD" + std::to_string(128 + i) + device_id_file;
+        path = std::string(dir) + "/renderD" + node_num + device_id_file;
         file = fopen(path.c_str(), "r");
-        if (!file) break;
+        if (!file) continue;
         err = fscanf(file, "%x", &device.device_id);
         fclose(file);
-        if (err == EOF) break;
+        if (err == EOF) continue;
+
+        // if user only mapped /dev/dri/renderD129 in container, need to skip /dev/dri/renderD128
+        path = "/dev/dri/renderD" + node_num;
+        int fd = open(path.c_str(), O_RDWR);
+        if (fd < 0) continue; //device not accessible
+        close(fd);
+
         device.platform = get_platform(device.device_id);
         result.emplace_back(device);
     }


s390/bitops: get rid of __BITOPS_BARRIER()

Signed-off-by: Heiko Carstens <8dcf0f69152f32f23184f83357a3731522e56b9c@de.ibm.com>
Signed-off-by: Martin Schwidefsky <52616596d8f5df0d597e85ab515377f92f939c68@de.ibm.com>

--- arch/s390/include/asm/bitops.h
+++ arch/s390/include/asm/bitops.h
@@ -98,7 +98,6 @@
 #endif /* CONFIG_64BIT */

 #define __BITOPS_WORDS(bits) (((bits) + BITS_PER_LONG - 1) / BITS_PER_LONG)
-#define __BITOPS_BARRIER() asm volatile("" : : : "memory")

 #ifdef CONFIG_SMP
 /*
@@ -164,7 +163,7 @@
 	mask = 1UL << (nr & (BITS_PER_LONG - 1));
 	/* Do the atomic update. */
 	__BITOPS_LOOP(old, new, addr, mask, __BITOPS_OR);
-	__BITOPS_BARRIER();
+	barrier();
 	return (old & mask) != 0;
 }

@@ -183,7 +182,7 @@
 	mask = ~(1UL << (nr & (BITS_PER_LONG - 1)));
 	/* Do the atomic update. */
 	__BITOPS_LOOP(old, new, addr, mask, __BITOPS_AND);
-	__BITOPS_BARRIER();
+	barrier();
 	return (old ^ new) != 0;
 }

@@ -202,7 +201,7 @@
 	mask = 1UL << (nr & (BITS_PER_LONG - 1));
 	/* Do the atomic update. */
 	__BITOPS_LOOP(old, new, addr, mask, __BITOPS_XOR);
-	__BITOPS_BARRIER();
+	barrier();
 	return (old & mask) != 0;
 }
 #endif /* CONFIG_SMP */


add an implementation for _load_uio on UIO_SYSSPACE objects that looks strangely similiar to _load_mbuf.  Btw, /dev/crypto is working on sabre based systems with hifn7751 from soekris.

--- arch/sparc64/sparc64/machdep.c
+++ arch/sparc64/sparc64/machdep.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: machdep.c,v 1.24 2001/11/16 20:58:45 jason Exp $	*/
+/*	$OpenBSD: machdep.c,v 1.25 2001/11/16 21:28:08 jason Exp $	*/
 /*	$NetBSD: machdep.c,v 1.108 2001/07/24 19:30:14 eeh Exp $ */

 /*-
@@ -1283,65 +1283,38 @@
 	struct uio *uio;
 	int flags;
 {
-/*
- * XXXXXXX The problem with this routine is that it needs to
- * lock the user address space that is being loaded, but there
- * is no real way for us to unlock it during the unload process.
- */
-#if 0
+	/*
+	 * XXXXXXX The problem with this routine is that it needs to
+	 * lock the user address space that is being loaded, but there
+	 * is no real way for us to unlock it during the unload process.
+	 * As a result, only UIO_SYSSPACE uio's are allowed for now.
+	 */
 	bus_dma_segment_t segs[MAX_DMA_SEGS];
 	int i, j;
 	size_t len;
-	struct proc *p = uio->uio_procp;
-	struct pmap *pm;
-
-	/*
-	 * Check user read/write access to the data buffer.
-	 */
-	if (uio->uio_segflg == UIO_USERSPACE) {
-		pm = p->p_vmspace->vm_map.pmap;
-		for (i = 0; i < uio->uio_iovcnt; i++) {
-			/* XXXCDC: map not locked, rethink */
-			if (__predict_false(!uvm_useracc(uio->uio_iov[i].iov_base,
-				     uio->uio_iov[i].iov_len,
-/* XXX is UIO_WRITE correct? */
-				     (uio->uio_rw == UIO_WRITE) ? B_WRITE : B_READ)))
-				return (EFAULT);
-		}
-	} else
-		pm = pmap_kernel();
-
-	i = 0;
+
+	if (uio->uio_segflg != UIO_SYSSPACE)
+		return (EOPNOTSUPP);
+
+	/* Record for *_unload */
+	map->_dm_type = _DM_TYPE_UIO;
+	map->_dm_source = (void *)uio;
+
+	i = j = 0;
 	len = 0;
-	for (j=0; j<uio->uio_iovcnt; j++) {
-		struct iovec *iov = &uio->uio_iov[j];
-		vaddr_t vaddr = (vaddr_t)iov->iov_base;
-		bus_size_t buflen = iov->iov_len;
-
-		/*
-		 * Lock the part of the user address space involved
-		 *    in the transfer.
-		 */
-		PHOLD(p);
-		if (__predict_false(uvm_vslock(p, vaddr, buflen,
-			    (uio->uio_rw == UIO_WRITE) ?
-			    VM_PROT_READ | VM_PROT_WRITE : VM_PROT_READ)
-			    != 0)) {
-				goto after_vsunlock;
-			}
-
+	while (j < uio->uio_iovcnt) {
+		vaddr_t vaddr = (vaddr_t)uio->uio_iov[j].iov_base;
+		long buflen = (long)uio->uio_iov[j].iov_len;
+
 		len += buflen;
 		while (buflen > 0 && i < MAX_DMA_SEGS) {
 			paddr_t pa;
 			long incr;

 			incr = min(buflen, NBPG);
-			(void) pmap_extract(pm, vaddr, &pa);
+			(void) pmap_extract(pmap_kernel(), vaddr, &pa);
 			buflen -= incr;
 			vaddr += incr;
-			if (segs[i].ds_len == 0)
-				segs[i].ds_addr = pa;
-

 			if (i > 0 && pa == (segs[i-1].ds_addr + segs[i-1].ds_len)
 			    && ((segs[i-1].ds_len + incr) < map->_dm_maxsegsz)) {
@@ -1356,20 +1329,16 @@
 			segs[i]._ds_mlist = NULL;
 			i++;
 		}
-		uvm_vsunlock(p, bp->b_data, todo);
-		PRELE(p);
- 		if (buflen > 0 && i >= MAX_DMA_SEGS)
+		j++;
+		if ((uio->uio_iovcnt - j) && i >= MAX_DMA_SEGS) {
 			/* Exceeded the size of our dmamap */
-			return E2BIG;
-	}
-	map->_dm_type = DM_TYPE_UIO;
-	map->_dm_source = (void *)uio;
-	return (bus_dmamap_load_raw(t, map, segs, i,
-				    (bus_size_t)len, flags));
-	return 0;
-#else
-	return (EOPNOTSUPP);
-#endif
+			map->_dm_type = 0;
+			map->_dm_source = NULL;
+			return (E2BIG);
+		}
+	}
+
+	return (bus_dmamap_load_raw(t, map, segs, i, (bus_size_t)len, flags));
 }

 /*


No need to clock i2s during i2c operations, so don't.  Relocate i2c open/close into init routine.

--- arch/zaurus/dev/zaurus_audio.c
+++ arch/zaurus/dev/zaurus_audio.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: zaurus_audio.c,v 1.5 2005/05/23 22:53:22 pascoe Exp $	*/
+/*	$OpenBSD: zaurus_audio.c,v 1.6 2005/05/26 03:28:43 pascoe Exp $	*/

 /*
  * Copyright (c) 2005 Christopher Pascoe <pascoe@openbsd.org>
@@ -180,6 +180,7 @@
 {
 	struct zaudio_softc		*sc = (struct zaudio_softc *)self;
 	struct pxaip_attach_args	*pxa = aux;
+	int err;

 	sc->sc_powerhook = powerhook_establish(zaudio_power, sc);
 	if (sc->sc_powerhook == NULL) {
@@ -203,10 +204,11 @@
 	}

 	/* Check for an I2C response from the wm8750 */
-	pxa2x0_i2s_open(&sc->sc_i2s);	/* supply the codec with a clock */
 	pxa2x0_i2c_open(&sc->sc_i2c);
-
-	if (wm8750_write(sc, RESET_REG, 0)) {
+	err = wm8750_write(sc, RESET_REG, 0);
+	pxa2x0_i2c_close(&sc->sc_i2c);
+
+	if (err) {
 		printf(": codec failed to respond\n");
 		goto fail_probe;
 	}
@@ -221,9 +223,6 @@

 	zaudio_init(sc);

-	pxa2x0_i2c_close(&sc->sc_i2c);
-	pxa2x0_i2s_close(&sc->sc_i2s);
-
 	printf(": I2C, I2S, WM8750 Audio\n");

 	audio_attach_mi(&wm8750_hw_if, sc, &sc->sc_dev);
@@ -231,8 +230,6 @@
 	return;

 fail_probe:
-	pxa2x0_i2c_close(&sc->sc_i2c);
-	pxa2x0_i2s_close(&sc->sc_i2s);
 	pxa2x0_i2c_detach_sub(&sc->sc_i2c);
 fail_i2c:
 	pxa2x0_i2s_detach_sub(&sc->sc_i2s);
@@ -266,6 +263,8 @@
 void
 zaudio_init(struct zaudio_softc *sc)
 {
+	pxa2x0_i2c_open(&sc->sc_i2c);
+
 	/* Reset the codec */
 	wm8750_write(sc, RESET_REG, 0);
 	delay(100);
@@ -281,6 +280,8 @@
 	zaudio_update_volume(sc, ZAUDIO_OP_SPKR);
 	zaudio_update_volume(sc, ZAUDIO_OP_HP);
 	scoop_set_headphone(0);
+
+	pxa2x0_i2c_close(&sc->sc_i2c);
 }

 void