gamma: Add support for all RGB formats

gamma: Add support for all RGB formats

--- gst/videofilter/gstgamma.c
+++ gst/videofilter/gstgamma.c
@@ -65,21 +65,31 @@
 #define DEFAULT_PROP_GAMMA  1

 static GstStaticPadTemplate gst_gamma_src_template =
-GST_STATIC_PAD_TEMPLATE ("src",
+    GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
     GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV
         ("{ IYUV, I420, YV12, Y41B, Y42B, Y444, NV12, NV21, "
-            "  YUY2, UYVY, AYUV, YVYU}"))
+            "  YUY2, UYVY, AYUV, YVYU}") ";"
+        GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"
+        GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA ";"
+        GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_RGBx ";"
+        GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_BGRx ";"
+        GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR)
     );

 static GstStaticPadTemplate gst_gamma_sink_template =
-GST_STATIC_PAD_TEMPLATE ("sink",
+    GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
     GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV
         ("{ IYUV, I420, YV12, Y41B, Y42B, Y444, NV12, NV21, "
-            "  YUY2, UYVY, AYUV, YVYU}"))
+            "  YUY2, UYVY, AYUV, YVYU}") ";"
+        GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"
+        GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA ";"
+        GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_RGBx ";"
+        GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_BGRx ";"
+        GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR)
     );

 static void gst_gamma_set_property (GObject * object, guint prop_id,
@@ -246,6 +256,68 @@
   for (i = 0; i < height; i++) {
     for (j = 0; j < width; j++) {
       *data = table[*data];
+      data += pixel_stride;
+    }
+    data += row_wrap;
+  }
+}
+
+static const int cog_ycbcr_to_rgb_matrix_8bit_sdtv[] = {
+  298, 0, 409, -57068,
+  298, -100, -208, 34707,
+  298, 516, 0, -70870,
+};
+
+static const gint cog_rgb_to_ycbcr_matrix_8bit_sdtv[] = {
+  66, 129, 25, 4096,
+  -38, -74, 112, 32768,
+  112, -94, -18, 32768,
+};
+
+#define APPLY_MATRIX(m,o,v1,v2,v3) ((m[o*4] * v1 + m[o*4+1] * v2 + m[o*4+2] * v3 + m[o*4+3]) >> 8)
+
+static void
+gst_gamma_packed_rgb_ip (GstGamma * gamma, guint8 * data)
+{
+  gint i, j, height;
+  gint width, row_stride, row_wrap;
+  gint pixel_stride;
+  const guint8 *table = gamma->gamma_table;
+  gint offsets[3];
+  gint r, g, b;
+  gint y, u, v;
+
+  offsets[0] = gst_video_format_get_component_offset (gamma->format, 0,
+      gamma->width, gamma->height);
+  offsets[1] = gst_video_format_get_component_offset (gamma->format, 1,
+      gamma->width, gamma->height);
+  offsets[2] = gst_video_format_get_component_offset (gamma->format, 2,
+      gamma->width, gamma->height);
+
+  width = gst_video_format_get_component_width (gamma->format, 0, gamma->width);
+  height = gst_video_format_get_component_height (gamma->format, 0,
+      gamma->height);
+  row_stride = gst_video_format_get_row_stride (gamma->format, 0, gamma->width);
+  pixel_stride = gst_video_format_get_pixel_stride (gamma->format, 0);
+  row_wrap = row_stride - pixel_stride * width;
+
+  for (i = 0; i < height; i++) {
+    for (j = 0; j < width; j++) {
+      r = data[offsets[0]];
+      g = data[offsets[1]];
+      b = data[offsets[2]];
+
+      y = APPLY_MATRIX (cog_rgb_to_ycbcr_matrix_8bit_sdtv, 0, r, g, b);
+      u = APPLY_MATRIX (cog_rgb_to_ycbcr_matrix_8bit_sdtv, 1, r, g, b);
+      v = APPLY_MATRIX (cog_rgb_to_ycbcr_matrix_8bit_sdtv, 2, r, g, b);
+
+      y = table[CLAMP (y, 0, 255)];
+      r = APPLY_MATRIX (cog_ycbcr_to_rgb_matrix_8bit_sdtv, 0, y, u, v);
+      g = APPLY_MATRIX (cog_ycbcr_to_rgb_matrix_8bit_sdtv, 1, y, u, v);
+      b = APPLY_MATRIX (cog_ycbcr_to_rgb_matrix_8bit_sdtv, 2, y, u, v);
+      data[offsets[0]] = CLAMP (r, 0, 255);
+      data[offsets[1]] = CLAMP (g, 0, 255);
+      data[offsets[2]] = CLAMP (b, 0, 255);
       data += pixel_stride;
     }
     data += row_wrap;
@@ -285,6 +357,18 @@
     case GST_VIDEO_FORMAT_YVYU:
       gamma->process = gst_gamma_packed_yuv_ip;
       break;
+    case GST_VIDEO_FORMAT_ARGB:
+    case GST_VIDEO_FORMAT_ABGR:
+    case GST_VIDEO_FORMAT_RGBA:
+    case GST_VIDEO_FORMAT_BGRA:
+    case GST_VIDEO_FORMAT_xRGB:
+    case GST_VIDEO_FORMAT_xBGR:
+    case GST_VIDEO_FORMAT_RGBx:
+    case GST_VIDEO_FORMAT_BGRx:
+    case GST_VIDEO_FORMAT_RGB:
+    case GST_VIDEO_FORMAT_BGR:
+      gamma->process = gst_gamma_packed_rgb_ip;
+      break;
     default:
       goto invalid_caps;
       break;


wavparse: proper closing segment construction

Fixes #618982.

--- gst/wavparse/gstwavparse.c
+++ gst/wavparse/gstwavparse.c
@@ -963,17 +963,14 @@
       /* we are running the current segment and doing a non-flushing seek,
        * close the segment first based on the previous last_stop. */
       GST_DEBUG_OBJECT (wav, "closing running segment %" G_GINT64_FORMAT
-          " to %" G_GINT64_FORMAT, wav->segment.accum, wav->segment.last_stop);
+          " to %" G_GINT64_FORMAT, wav->segment.start, wav->segment.last_stop);

       /* queue the segment for sending in the stream thread */
       if (wav->close_segment)
         gst_event_unref (wav->close_segment);
       wav->close_segment = gst_event_new_new_segment (TRUE,
           wav->segment.rate, wav->segment.format,
-          wav->segment.accum, wav->segment.last_stop, wav->segment.accum);
-
-      /* keep track of our last_stop */
-      seeksegment.accum = wav->segment.last_stop;
+          wav->segment.start, wav->segment.last_stop, wav->segment.start);
     }
   }

@@ -1905,7 +1902,9 @@
     duration = next_timestamp - timestamp;

     /* update current running segment position */
-    gst_segment_set_last_stop (&wav->segment, GST_FORMAT_TIME, next_timestamp);
+    if (G_LIKELY (next_timestamp >= wav->segment.start))
+      gst_segment_set_last_stop (&wav->segment, GST_FORMAT_TIME,
+          next_timestamp);
   } else if (wav->fact) {
     guint64 bps =
         gst_util_uint64_scale_int (wav->datasize, wav->rate, wav->fact);
@@ -1922,7 +1921,8 @@
       timestamp = GST_CLOCK_TIME_NONE;
     duration = GST_CLOCK_TIME_NONE;
     /* update current running segment position with byte offset */
-    gst_segment_set_last_stop (&wav->segment, GST_FORMAT_BYTES, nextpos);
+    if (G_LIKELY (nextpos >= wav->segment.start))
+      gst_segment_set_last_stop (&wav->segment, GST_FORMAT_BYTES, nextpos);
   }
   if ((pos > 0) && wav->vbr) {
     /* don't set timestamps for VBR files if it's not the first buffer */


wavparse: set buffer offsets before using the buffer for the first time

gst_type_find_helper_for_buffer() will need the correct offset
set on the buffer (ie. 0) and not the byte offset we started
pulling the data from.

--- gst/wavparse/gstwavparse.c
+++ gst/wavparse/gstwavparse.c
@@ -1858,6 +1858,16 @@
     }
   }

+  obtained = GST_BUFFER_SIZE (buf);
+
+  /* our positions in bytes */
+  pos = wav->offset - wav->datastart;
+  nextpos = pos + obtained;
+
+  /* update offsets, does not overflow. */
+  GST_BUFFER_OFFSET (buf) = pos / wav->bytes_per_sample;
+  GST_BUFFER_OFFSET_END (buf) = nextpos / wav->bytes_per_sample;
+
   /* first chunk of data? create the source pad. We do this only here so
    * we can detect broken .wav files with dts disguised as raw PCM (sigh) */
   if (G_UNLIKELY (wav->first)) {
@@ -1875,16 +1885,6 @@
       wav->start_segment = NULL;
     }
   }
-
-  obtained = GST_BUFFER_SIZE (buf);
-
-  /* our positions in bytes */
-  pos = wav->offset - wav->datastart;
-  nextpos = pos + obtained;
-
-  /* update offsets, does not overflow. */
-  GST_BUFFER_OFFSET (buf) = pos / wav->bytes_per_sample;
-  GST_BUFFER_OFFSET_END (buf) = nextpos / wav->bytes_per_sample;

   if (wav->bps > 0) {
     /* and timestamps if we have a bitrate, be careful for overflows */


Display localised accelerator keys also in OTHER mode

This fixes bug 572797.

--- gtk/gtkcellrendereraccel.c
+++ gtk/gtkcellrendereraccel.c
@@ -249,7 +249,10 @@
 	{
 	  gchar *name;

-	  name = gtk_accelerator_name (keysym, mask);
+	  name = gtk_accelerator_get_label (keysym, mask);
+	  if (name == NULL)
+	    name = gtk_accelerator_name (keysym, mask);
+
 	  if (keysym == 0)
 	    {
 	      gchar *tmp;


lib: add note about higher-level extent allocation function

--- lib/extent.c
+++ lib/extent.c
@@ -8,6 +8,12 @@
 #include "extent.h"
 #include "debug.h"

+
+/* TODO: need a higher-level function that will return a number of extents that
+ * add up to the requested length if a single extent can't be found;
+ * we can use the fact that we have access to the ext tree to allocate the
+ * largest extents that we know about so files have the fewest possible frags;
+ * use this when allocating file data extents */

 uint32_t ext_alloc(uint32_t len) {
 	/* traverse the ext tree horizontally and find a free extent that is


computedvalues: Split out a function

computedvalues: Split out a function

--- gtk/gtkcsscomputedvalues.c
+++ gtk/gtkcsscomputedvalues.c
@@ -71,6 +71,16 @@
 {
   if (section)
     gtk_css_section_unref (section);
+}
+
+static void
+gtk_css_computed_values_ensure_array (GtkCssComputedValues *values,
+                                      guint                 at_least_size)
+{
+  if (values->values == NULL)
+    values->values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
+  if (at_least_size > values->values->len)
+   g_ptr_array_set_size (values->values, at_least_size);
 }

 void
@@ -89,10 +99,7 @@
   prop = _gtk_css_style_property_lookup_by_id (id);
   parent = gtk_style_context_get_parent (context);

-  if (values->values == NULL)
-    values->values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
-  if (id <= values->values->len)
-   g_ptr_array_set_size (values->values, id + 1);
+  gtk_css_computed_values_ensure_array (values, id + 1);

   /* http://www.w3.org/TR/css3-cascade/#cascade
    * Then, for every element, the value for each property can be found
@@ -181,10 +188,7 @@
 {
   g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));

-  if (values->values == NULL)
-    values->values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
-  if (id >= values->values->len)
-   g_ptr_array_set_size (values->values, id + 1);
+  gtk_css_computed_values_ensure_array (values, id + 1);

   if (g_ptr_array_index (values->values, id))
     _gtk_css_value_unref (g_ptr_array_index (values->values, id));


* change to ANSI C style.

* change to ANSI C style.

--- gtk2/ext/gtk2/rbgtkimage.c
+++ gtk2/ext/gtk2/rbgtkimage.c
@@ -24,10 +24,7 @@
 */

 static VALUE
-image_initialize(argc, argv, self)
-    int argc;
-    VALUE *argv;
-    VALUE self;
+image_initialize(int argc, VALUE *argv, VALUE self)
 {
     VALUE arg1, arg2;
     GType gtype;
@@ -68,10 +65,7 @@
 }

 static VALUE
-image_set(argc, argv, self)
-    int argc;
-    VALUE *argv;
-    VALUE self;
+image_set(int argc, VALUE *argv, VALUE self)
 {
     VALUE arg1, arg2;
     GType gtype;
@@ -125,8 +119,7 @@

 #if GTK_CHECK_VERSION(2,8,0)
 static VALUE
-image_clear(self)
-    VALUE self;
+image_clear(VALUE self)
 {
     gtk_image_clear(_SELF(self));
     return self;


* change to ANSI C style.

* change to ANSI C style.

--- gtk2/ext/gtk2/rbgtkstyle.c
+++ gtk2/ext/gtk2/rbgtkstyle.c
@@ -37,8 +37,7 @@
 }

 static VALUE
-style_copy(self)
-    VALUE self;
+style_copy(VALUE self)
 {
     return GOBJ2RVAL(gtk_style_copy(_SELF(self)));
 }


add FIXME for AS number overflow bug in unit-test-only code path

--- lib/rpki/cms/roa_serialize.c
+++ lib/rpki/cms/roa_serialize.c
@@ -1075,6 +1075,15 @@
  * ( signature != NULL ) free(signature); return ansr; }
  */

+/*
+ FIXME: This does not handle the full range of 32-bit AS numbers.
+ Fortunately, it is called only from a single unit test and is never
+ used in production.  It may be better to just remove the entire
+ calling code path (starts at the top from roaFromConfig).  We now
+ have other ways of generating ROAs from text files other than
+ roaFromConfig().  And/or we need to fix write_casn_num() as well as
+ its internal limit-checking code.
+*/
 static int setAS_ID(
     struct ROA *roa,
     unsigned char *asidstring)
@@ -1082,7 +1091,7 @@
     int iLen = 0;
     int iAS_ID = 0;

-    // Because we only accept 0 < ASID < 2**32
+    // FIXME: We deny AS 0 and AS numbers > 999999999, but allow negatives!
     iLen = strlen((char *)asidstring);
     if (9 < iLen)
         return ERR_SCM_INVALASID;


Delete common_Utilities.h

Delete common_Utilities.h

--- bin/common_Utilities.h
+++ bin/common_Utilities.h
@@ -1,37 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class common_Utilities */
-
-#ifndef _Included_common_Utilities
-#define _Included_common_Utilities
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Class:     common_Utilities
- * Method:    realToString
- * Signature: (D)Ljava/lang/String;
- */
-JNIEXPORT jstring JNICALL Java_common_Utilities_realToString
-  (JNIEnv *, jclass, jdouble);
-
-/*
- * Class:     common_Utilities
- * Method:    byteToString
- * Signature: (B)Ljava/lang/String;
- */
-JNIEXPORT jstring JNICALL Java_common_Utilities_byteToString
-  (JNIEnv *, jclass, jbyte);
-
-/*
- * Class:     common_Utilities
- * Method:    str2d
- * Signature: (Ljava/lang/String;)D
- */
-JNIEXPORT jdouble JNICALL Java_common_Utilities_str2d
-  (JNIEnv *, jclass, jstring);
-
-#ifdef __cplusplus
-}
-#endif
-#endif


#include "compat.h" for asprintf().  Sort includes.

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

--- bin/varnishd/mgt_vcc.c
+++ bin/varnishd/mgt_vcc.c
@@ -4,13 +4,15 @@
  * VCL compiler stuff
  */

+#include <sys/types.h>
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <sys/types.h>
-
+
+#include "compat.h"
 #include "vsb.h"
 #include "queue.h"


Eliminated obsolete type declarations for string conversions.

svn path=/trunk/; revision=307

--- bindings/f77/plstubs.h
+++ bindings/f77/plstubs.h
@@ -1,9 +1,12 @@
 /* $Id$
    $Log$
-   Revision 1.13  1993/07/16 22:31:41  mjl
-   Changed method for getting stub conversion right.  Now need to define
-   the macro STUB_LINKAGE with any of the supported conversion types.
-
+   Revision 1.14  1993/07/20 06:50:28  mjl
+   Eliminated obsolete type declarations for string conversions.
+
+ * Revision 1.13  1993/07/16  22:31:41  mjl
+ * Changed method for getting stub conversion right.  Now need to define
+ * the macro STUB_LINKAGE with any of the supported conversion types.
+ *
  * Revision 1.12  1993/07/02  07:26:10  mjl
  * Changed include of plplot.h to plplotP.h.  Also added IRIX support.
  *
@@ -54,11 +57,6 @@
 #define INCLUDED_PLSTUBS

 #include "plplotP.h"
-
-/* These are needed for system-independent Fortran->C string linkage. */
-
-extern char cstring1[300], cstring2[300], cstring3[300];
-extern char cstring4[300], cstring5[300], cstring6[300];

 /*----------------------------------------------------------------------*\
 * Select name transformation based on system type.


Remove delegate parameter for resetCredentialsOfUser

Multiple declarations of method 'resetCredentialsOfUser:delegate:' found and ignored

--- bindings/ios/MEGASdk.h
+++ bindings/ios/MEGASdk.h
@@ -1256,9 +1256,8 @@
  * - [MEGARequest flag] - Returns YES
  *
  * @param user MEGAUser of the contact whose credentials want to be reset
- * @param delegate MEGARequestDelegate to track this request
- */
-- (void)resetCredentialsOfUser:(MEGAUser *)user delegate:(id<MEGARequestDelegate>)delegate;
+ */
+- (void)resetCredentialsOfUser:(MEGAUser *)user;

 #pragma mark - Create account and confirm account Requests


[ECacheReaper] Recover data for private folders

When, for whatever reason, some 3rd-party plugin with its own private
directory wasn't installed, its private directory was moved to trash,
but never recovered, even when it was installed again.

--- libebackend/e-cache-reaper.c
+++ libebackend/e-cache-reaper.c
@@ -387,18 +387,15 @@

 static void
 cache_reaper_recover_from_trash (ECacheReaper *extension,
-                                 ESource *source,
+                                 const gchar *directory_uid,
                                  GFile *base_directory,
                                  GFile *trash_directory)
 {
 	GFile *source_directory;
 	GFile *target_directory;
-	const gchar *uid;
-
-	uid = e_source_get_uid (source);
-
-	source_directory = g_file_get_child (trash_directory, uid);
-	target_directory = g_file_get_child (base_directory, uid);
+
+	source_directory = g_file_get_child (trash_directory, directory_uid);
+	target_directory = g_file_get_child (base_directory, directory_uid);

 	/* This is a no-op if the source directory does not exist. */
 	cache_reaper_move_directory (source_directory, target_directory);
@@ -408,9 +405,34 @@
 }

 static void
+cache_reaper_recover_for_uid (ECacheReaper *extension,
+			      const gchar *uid)
+{
+	guint ii;
+
+	/* The Cache Reaper is not too proud to dig through the
+	 * trash on the off chance the newly-added source has a
+	 * recoverable data or cache directory. */
+
+	for (ii = 0; ii < extension->n_data_directories; ii++)
+		cache_reaper_recover_from_trash (
+			extension, uid,
+			extension->data_directories[ii],
+			extension->data_trash_directories[ii]);
+
+	for (ii = 0; ii < extension->n_cache_directories; ii++)
+		cache_reaper_recover_from_trash (
+			extension, uid,
+			extension->cache_directories[ii],
+			extension->cache_trash_directories[ii]);
+}
+
+static void
 cache_reaper_files_loaded_cb (ESourceRegistryServer *server,
                               ECacheReaper *extension)
 {
+	GSList *link;
+
 	cache_reaper_scan_data_directories (extension);
 	cache_reaper_scan_cache_directories (extension);

@@ -422,6 +444,13 @@
 				cache_reaper_reap_trash_directories,
 				extension);
 	}
+
+	for (link = extension->private_directories; link; link = g_slist_next (link)) {
+		const gchar *directory = link->data;
+
+		if (directory && *directory)
+			cache_reaper_recover_for_uid (extension, directory);
+	}
 }

 static void
@@ -429,23 +458,7 @@
                               ESource *source,
                               ECacheReaper *extension)
 {
-	guint ii;
-
-	/* The Cache Reaper is not too proud to dig through the
-	 * trash on the off chance the newly-added source has a
-	 * recoverable data or cache directory. */
-
-	for (ii = 0; ii < extension->n_data_directories; ii++)
-		cache_reaper_recover_from_trash (
-			extension, source,
-			extension->data_directories[ii],
-			extension->data_trash_directories[ii]);
-
-	for (ii = 0; ii < extension->n_cache_directories; ii++)
-		cache_reaper_recover_from_trash (
-			extension, source,
-			extension->cache_directories[ii],
-			extension->cache_trash_directories[ii]);
+	cache_reaper_recover_for_uid (extension, e_source_get_uid (source));
 }

 static void
@@ -681,6 +694,8 @@
 		return;

 	cache_reaper->private_directories = g_slist_prepend (cache_reaper->private_directories, g_strdup (name));
+
+	cache_reaper_recover_for_uid (cache_reaper, name);
 }

 /**


small fixes

small fixes

--- lib/lpxpak.h
+++ lib/lpxpak.h
@@ -367,8 +367,8 @@
 lpxpak_t *
 _lpxpak_parse_data_(const void *data, lpxpakindex_t *index)
 {
-     lpxpakindex_t *ti = NULL;;
-     lpxpak_t *xpak = NULL;;
+     lpxpakindex_t *ti = NULL;
+     lpxpak_t *xpak = NULL;
      lpxpak_t *tx = NULL;

      if ( (xpak = (lpxpak_t *)malloc(sizeof(lpxpak_t))) == NULL ) {


mainly format changes and some little progress in lpxpak_parse_data

--- lib/lpxpak.h
+++ lib/lpxpak.h
@@ -40,21 +40,21 @@
 lpxpak_parse_path(const char *path);

 lpxpak_t *
-lpxpak_parse_data(const void *data, size_t n)
+lpxpak_parse_data(const void *data, size_t len)
 {
      lpxpak_t *xpak;
-     const void *temp = NULL;
      uint32_t count = 0;
-     char tmp[9];
-     temp = data;
-     /* get the first 8 bytes ("XPAKPACK") and check if they read "XPAKPACK"
-      * to make sure we have a valid xpak string */
-     memcpy(tmp, temp, 8);
-     if (! strcmp(tmp, "XPAKPACK") == 0) {
+
+     /* check if the first 8 bytes of the xpak data read "XPAKPACK" and the
+      * last 8 bytes of of the data read "XPAKSTOP" to make sure we have a
+      * valid xpak */
+     if ((memcmp(data, "XPAKPACK", 8) != 0) ||
+         (memcmp(data+len-8, "XPAKSTOP", 8 != 0))) {
           errno = EINVAL;
           return NULL;
      }
-     temp += 8; count += 8;
+     count += 8;
+
      /* allocate the needed memory from the Heap */
      xpak = (lpxpak_t *)malloc(sizeof(lpxpak_t));
      data = NULL;
@@ -69,10 +69,10 @@
      void *tmp;
      uint32_t xpakoffset;
      lpxpak_t *xpak;
-
+
      if (fstat(fd, &xpakstat) == -1)
           return NULL;
-
+
      if (! S_ISREG(xpakstat.st_mode) ) {
           errno = EINVAL;
           return NULL;
@@ -80,7 +80,7 @@

      /* seek to the start of the STOP string */
      lseek(fd, __LP_XPAK_STOP_OFFSET__*-1, SEEK_END);
-
+
      /* allocate 4bytes from the heap, read in 4bytes, check if the read in
       * data is "STOP"(encoded as an ASCII String) - otherwise this would be
       * an invalid xpak and finally free that piece of memory */
@@ -92,21 +92,21 @@
           return NULL;
      }
      free(tmp);
-
+
      /* seek to the start of the xpak_offset value */
      lseek(fd, __LP_XPAK_OFFSET_OFFSET__*-1, SEEK_END);
-
+
      /* read the offset */
      read(fd, &xpakoffset, 4);
-
+
      /* convert it from network to local byteorder */
      xpakoffset = ntohl(xpakoffset);
-
+
      /* allocate <xpakoffset> bytes of data and read the xpak_blob in. */
      xpakdata = malloc(xpakoffset);
      lseek(fd, (off_t)(xpakoffset+__LP_XPAK_OFFSET_OFFSET__)*-1, SEEK_END);
      read(fd, xpakdata, (size_t)xpakoffset);
-
+
      xpak = lpxpak_parse_data(xpakdata, (size_t)xpakoffset);

      free(xpakdata);
@@ -128,6 +128,5 @@
      int fd;

      fd = open(path, O_RDONLY);
-
      return lpxpak_parse_fd(fd);
 }


fix buffer overrun in on_read_core (due to the incorrect len returned by h2o_buffer_reserve)

--- lib/memory.c
+++ lib/memory.c
@@ -213,7 +213,7 @@
     }

     ret.base = inbuf->bytes + inbuf->size;
-    ret.len = inbuf->capacity - inbuf->size;
+    ret.len = inbuf->_buf + inbuf->capacity - ret.base;

     return ret;
 }


Fix incorrect assert in String::Substring.

--- include/apto/core/String.h
+++ include/apto/core/String.h
@@ -155,7 +155,7 @@
     inline BasicString Substring(int idx = 0, int length = -1) const
     {
       assert(idx >= 0);
-      assert(idx < GetSize());
+      assert(idx <= GetSize());
       assert(length <= (GetSize() - idx));
       return BasicString((length >= 0) ? length : (GetSize() - idx), m_value->GetRep() + idx);
     }


[MIPS] SB1: Fix interrupt disable hazard.      The SB1 core has a three cycle interrupt disable hazard but we were wrongly treating it as fully interlocked.      Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

[MIPS] SB1: Fix interrupt disable hazard.

The SB1 core has a three cycle interrupt disable hazard but we were
wrongly treating it as fully interlocked.

Signed-off-by: Ralf Baechle <92f48d309cda194c8eda36aa8f9ae28c488fa208@linux-mips.org>

--- include/asm-mips/hazards.h
+++ include/asm-mips/hazards.h
@@ -3,7 +3,9 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (C) 2003, 2004 Ralf Baechle
+ * Copyright (C) 2003, 2004 Ralf Baechle <ralf@linux-mips.org>
+ * Copyright (C) MIPS Technologies, Inc.
+ *   written by Ralf Baechle <ralf@linux-mips.org>
  */
 #ifndef _ASM_HAZARDS_H
 #define _ASM_HAZARDS_H
@@ -74,8 +76,7 @@
 #define irq_disable_hazard
 	_ehb

-#elif defined(CONFIG_CPU_R10000) || defined(CONFIG_CPU_RM9000) || \
-      defined(CONFIG_CPU_SB1)
+#elif defined(CONFIG_CPU_R10000) || defined(CONFIG_CPU_RM9000)

 /*
  * R10000 rocks - all hazards handled in hardware, so this becomes a nobrainer.
@@ -99,13 +100,13 @@
 #else /* __ASSEMBLY__ */

 __asm__(
-	"	.macro	_ssnop					\n\t"
-	"	sll	$0, $0, 1				\n\t"
-	"	.endm						\n\t"
-	"							\n\t"
-	"	.macro	_ehb					\n\t"
-	"	sll	$0, $0, 3				\n\t"
-	"	.endm						\n\t");
+	"	.macro	_ssnop					\n"
+	"	sll	$0, $0, 1				\n"
+	"	.endm						\n"
+	"							\n"
+	"	.macro	_ehb					\n"
+	"	sll	$0, $0, 3				\n"
+	"	.endm						\n");

 #ifdef CONFIG_CPU_RM9000

@@ -117,17 +118,21 @@

 #define mtc0_tlbw_hazard()						\
 	__asm__ __volatile__(						\
-		".set\tmips32\n\t"					\
-		"_ssnop; _ssnop; _ssnop; _ssnop\n\t"			\
-		".set\tmips0")
+	"	.set	mips32					\n"	\
+	"	_ssnop						\n"	\
+	"	_ssnop						\n"	\
+	"	_ssnop						\n"	\
+	"	_ssnop						\n"	\
+	"	.set	mips0					\n")

 #define tlbw_use_hazard()						\
 	__asm__ __volatile__(						\
-		".set\tmips32\n\t"					\
-		"_ssnop; _ssnop; _ssnop; _ssnop\n\t"			\
-		".set\tmips0")
-
-#define back_to_back_c0_hazard()	do { } while (0)
+	"	.set	mips32					\n"	\
+	"	_ssnop						\n"	\
+	"	_ssnop						\n"	\
+	"	_ssnop						\n"	\
+	"	_ssnop						\n"	\
+	"	.set	mips0					\n")

 #else

@@ -136,15 +141,25 @@
  */
 #define mtc0_tlbw_hazard()						\
 	__asm__ __volatile__(						\
-		".set noreorder\n\t"					\
-		"nop; nop; nop; nop; nop; nop;\n\t"			\
-		".set reorder\n\t")
+	"	.set	noreorder				\n"	\
+	"	nop						\n"	\
+	"	nop						\n"	\
+	"	nop						\n"	\
+	"	nop						\n"	\
+	"	nop						\n"	\
+	"	nop						\n"	\
+	"	.set	reorder					\n")

 #define tlbw_use_hazard()						\
 	__asm__ __volatile__(						\
-		".set noreorder\n\t"					\
-		"nop; nop; nop; nop; nop; nop;\n\t"			\
-		".set reorder\n\t")
+	"	.set	noreorder				\n"	\
+	"	nop						\n"	\
+	"	nop						\n"	\
+	"	nop						\n"	\
+	"	nop						\n"	\
+	"	nop						\n"	\
+	"	nop						\n"	\
+	"	.set	reorder					\n")

 #endif

@@ -156,49 +171,26 @@

 #ifdef CONFIG_CPU_MIPSR2

+__asm__("	.macro	irq_enable_hazard			\n"
+	"	_ehb						\n"
+	"	.endm						\n"
+	"							\n"
+	"	.macro	irq_disable_hazard			\n"
+	"	_ehb						\n"
+	"	.endm						\n");
+
+#elif defined(CONFIG_CPU_R10000) || defined(CONFIG_CPU_RM9000)
+
+/*
+ * R10000 rocks - all hazards handled in hardware, so this becomes a nobrainer.
+ */
+
 __asm__(
-	"	.macro\tirq_enable_hazard			\n\t"
-	"	_ehb						\n\t"
-	"	.endm						\n\t"
-	"							\n\t"
-	"	.macro\tirq_disable_hazard			\n\t"
-	"	_ehb						\n\t"
-	"	.endm						\n\t"
-	"							\n\t"
-	"	.macro\tback_to_back_c0_hazard			\n\t"
-	"	_ehb						\n\t"
-	"	.endm");
-
-#define irq_enable_hazard()						\
-	__asm__ __volatile__(						\
-	"irq_enable_hazard")
-
-#define irq_disable_hazard()						\
-	__asm__ __volatile__(						\
-	"irq_disable_hazard")
-
-#define back_to_back_c0_hazard()					\
-	__asm__ __volatile__(						\
-	"back_to_back_c0_hazard")
-
-#elif defined(CONFIG_CPU_R10000) || defined(CONFIG_CPU_RM9000) || \
-      defined(CONFIG_CPU_SB1)
-
-/*
- * R10000 rocks - all hazards handled in hardware, so this becomes a nobrainer.
- */
-
-__asm__(
-	"	.macro\tirq_enable_hazard			\n\t"
-	"	.endm						\n\t"
-	"							\n\t"
-	"	.macro\tirq_disable_hazard			\n\t"
-	"	.endm");
-
-#define irq_enable_hazard()	do { } while (0)
-#define irq_disable_hazard()	do { } while (0)
-
-#define back_to_back_c0_hazard()	do { } while (0)
+	"	.macro	irq_enable_hazard			\n"
+	"	.endm						\n"
+	"							\n"
+	"	.macro	irq_disable_hazard			\n"
+	"	.endm						\n");

 #else

@@ -209,29 +201,63 @@
  */

 __asm__(
-	"	#						\n\t"
-	"	# There is a hazard but we do not care		\n\t"
-	"	#						\n\t"
-	"	.macro\tirq_enable_hazard			\n\t"
-	"	.endm						\n\t"
-	"							\n\t"
-	"	.macro\tirq_disable_hazard			\n\t"
-	"	_ssnop; _ssnop; _ssnop				\n\t"
+	"	#						\n"
+	"	# There is a hazard but we do not care		\n"
+	"	#						\n"
+	"	.macro\tirq_enable_hazard			\n"
+	"	.endm						\n"
+	"							\n"
+	"	.macro\tirq_disable_hazard			\n"
+	"	_ssnop						\n"
+	"	_ssnop						\n"
+	"	_ssnop						\n"
+	"	.endm						\n");
+
+#endif
+
+#define irq_enable_hazard()						\
+	__asm__ __volatile__("irq_enable_hazard")
+#define irq_disable_hazard()						\
+	__asm__ __volatile__("irq_disable_hazard")
+
+
+/*
+ * Back-to-back hazards -
+ *
+ * What is needed to separate a move to cp0 from a subsequent read from the
+ * same cp0 register?
+ */
+#ifdef CONFIG_CPU_MIPSR2
+
+__asm__("	.macro	back_to_back_c0_hazard			\n"
+	"	_ehb						\n"
+	"	.endm						\n");
+
+#elif defined(CONFIG_CPU_R10000) || defined(CONFIG_CPU_RM9000) || \
+      defined(CONFIG_CPU_SB1)
+
+__asm__("	.macro	back_to_back_c0_hazard			\n"
+	"	.endm						\n");
+
+#else
+
+__asm__("	.macro	back_to_back_c0_hazard			\n"
+	"	.set	noreorder				\n"
+	"	_ssnop						\n"
+	"	_ssnop						\n"
+	"	_ssnop						\n"
+	"	.set	reorder					\n"
 	"	.endm");

-#define irq_enable_hazard()	do { } while (0)
-#define irq_disable_hazard()						\
-	__asm__ __volatile__(						\
-	"irq_disable_hazard")
+#endif

 #define back_to_back_c0_hazard()					\
-	__asm__ __volatile__(						\
-	"	.set noreorder				\n"		\
-	"	nop; nop; nop				\n"		\
-	"	.set reorder				\n")
-
-#endif
-
+	__asm__ __volatile__("back_to_back_c0_hazard")
+
+
+/*
+ * Instruction execution hazard
+ */
 #ifdef CONFIG_CPU_MIPSR2
 /*
  * gcc has a tradition of misscompiling the previous construct using the


removed to_hex from formatter

removed to_hex from formatter

--- include/c11log/formatter.h
+++ include/c11log/formatter.h
@@ -17,8 +17,6 @@

 typedef std::function<std::string(const std::string& logger_name, const std::string&, level::level_enum, const c11log::log_clock::time_point&)> format_fn;

-
-std::string to_hex(const unsigned char* buf, std::size_t size);

 class formatter
 {


Added SK_BUILD_FOR_NACL to SkPreConfig.h

Submitted on behalf of bmilnor@

git-svn-id: e8541e15acce502a64c929015570ad1648e548cd@6656 2bbb7eff-a529-9590-31e7-b0007b416f81

--- include/core/SkPreConfig.h
+++ include/core/SkPreConfig.h
@@ -16,7 +16,7 @@

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

-#if !defined(SK_BUILD_FOR_ANDROID) && !defined(SK_BUILD_FOR_ANDROID_NDK) && !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_PALM) && !defined(SK_BUILD_FOR_WINCE) && !defined(SK_BUILD_FOR_WIN32) && !defined(SK_BUILD_FOR_UNIX) && !defined(SK_BUILD_FOR_MAC) && !defined(SK_BUILD_FOR_SDL) && !defined(SK_BUILD_FOR_BREW)
+#if !defined(SK_BUILD_FOR_ANDROID) && !defined(SK_BUILD_FOR_ANDROID_NDK) && !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_PALM) && !defined(SK_BUILD_FOR_WINCE) && !defined(SK_BUILD_FOR_WIN32) && !defined(SK_BUILD_FOR_UNIX) && !defined(SK_BUILD_FOR_MAC) && !defined(SK_BUILD_FOR_SDL) && !defined(SK_BUILD_FOR_BREW) && !defined(SK_BUILD_FOR_NACL)

     #ifdef __APPLE__
         #include "TargetConditionals.h"


TargetLCO updated.

TargetLCO updated.

--- include/dashmm/targetlco.h
+++ include/dashmm/targetlco.h
@@ -75,8 +75,9 @@
   TargetLCO(hpx_addr_t data, int n_targs) : lco_{data}, n_targs_{n_targs} { }

   /// Construct an LCO from input TargetRef. This will create the LCO.
-  explicit TargetLCO(const targetref_t &targets) {
-    Init init{targets};
+  explicit TargetLCO(int n_inputs, const targetref_t &targets) {
+    // TODO update
+    Data init{n_inputs, targets};
     lco_ = hpx_lco_user_new(sizeof(Data), init_, operation_, predicate_,
                             &init, sizeof(init));
     assert(lco_ != HPX_NULL);
@@ -96,25 +97,6 @@
   hpx_addr_t lco() const {return lco_;}

   int n() const {return n_targs_;}
-
-  /// Indicate to the underlying LCO that all operations have been scheduled
-  void finalize() const {
-    if (lco_ != HPX_NULL) {
-      int code = kFinish;
-      hpx_lco_set_lsync(lco_, sizeof(code), &code, HPX_NULL);
-    }
-  }
-
-  /// Indicate to the underlying LCO that it should expect \param num more
-  /// operations
-  void schedule(int num) const {
-    if (lco_ != HPX_NULL) {
-      int input[2] = {kSetOnly, num};
-      // NOTE: This one must be remote complete so that there is no timing issue
-      // between scheduling an input and finalizing the schedule.
-      hpx_lco_set_rsync(lco_, sizeof(int) * 2, input);
-    }
-  }

   /// Contribute a S->T operation to the referred targets
   ///
@@ -180,14 +162,7 @@

   /// LCO data type
   struct Data {
-    int arrived;
-    int scheduled;
-    int finished;
-    targetref_t targets;
-  };
-
-  /// LCO initialization type
-  struct Init {
+    int yet_to_arrive;
     targetref_t targets;
   };

@@ -218,20 +193,15 @@

   /// Codes to define what the LCO set is doing.
   enum SetCodes {
-    kSetOnly = 1,
-    kStoT = 2,
-    kMtoT = 3,
-    kLtoT = 4,
-    kFinish = 5
+    kStoT = 0,
+    kMtoT = 1,
+    kLtoT = 2,
   };

   /// Initialize the LCO
   static void init_handler(Data *i, size_t bytes,
-                           Init *init, size_t init_bytes) {
-    i->arrived = 0;
-    i->scheduled = 0;
-    i->finished = 0;
-    i->targets = init->targets;
+                           Data *init, size_t init_bytes) {
+    *i = *init;
   }

   /// The 'set' operation on the LCO
@@ -239,9 +209,10 @@
   /// This takes a number of forms based on the input code.
   static void operation_handler(Data *lhs, void *rhs, size_t bytes) {
     int *code = static_cast<int *>(rhs);
-    if (*code == kSetOnly) {    // this is a pair of ints, a code and a count
-      lhs->scheduled += code[1];
-    } else if (*code == kStoT) {
+    lhs->yet_to_arrive -= 1;
+    assert(lhs->yet_to_arrive >= 0);
+
+    if (*code == kStoT) {
       // The input contains the sources
       StoT *input = static_cast<StoT *>(rhs);

@@ -255,11 +226,8 @@
       expansion_t expand{nullptr, 0, -1};
       expand.S_to_T(input->sources, &input->sources[input->count],
                      targets, &targets[lhs->targets.n()]);
-      expand.release(); // NOTE: This is not strictly needed

       hpx_gas_unpin(lhs->targets.data());
-
-      lhs->arrived += 1;
     } else if (*code == kMtoT) {
       MtoT *input = static_cast<MtoT *>(rhs);

@@ -275,8 +243,6 @@
       expand.release();

       hpx_gas_unpin(lhs->targets.data());
-
-      lhs->arrived += 1;
     } else if (*code == kLtoT) {
       LtoT *input = static_cast<LtoT *>(rhs);

@@ -292,10 +258,6 @@
       expand.release();

       hpx_gas_unpin(lhs->targets.data());
-
-      lhs->arrived += 1;
-    } else if (*code == kFinish) {
-      lhs->finished = 1;
     } else {
       assert(0 && "Incorrect code to TargetLCO");
     }
@@ -304,7 +266,7 @@
   /// The LCO is set if it has been finalized, and all scheduled operations
   /// have taken place.
   static bool predicate_handler(Data *i, size_t bytes) {
-    return i->finished && (i->arrived == i->scheduled);
+    return (i->yet_to_arrive == 0);
   }

   /// The global address of the LCO


include/led_onoff_states.h: Format with clang-format

BUG=b:236386294
BRANCH=none
TEST=none

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

--- include/led_onoff_states.h
+++ include/led_onoff_states.h
@@ -10,19 +10,15 @@

 #include "ec_commands.h"

-#define LED_INDEFINITE	UINT8_MAX
-#define LED_ONE_SEC	(1000 / HOOK_TICK_INTERVAL_MS)
-#define LED_OFF         EC_LED_COLOR_COUNT
+#define LED_INDEFINITE UINT8_MAX
+#define LED_ONE_SEC (1000 / HOOK_TICK_INTERVAL_MS)
+#define LED_OFF EC_LED_COLOR_COUNT

 /*
  * All LED states should have one phase defined,
  * and an additional phase can be defined for blinking
  */
-enum led_phase {
-	LED_PHASE_0,
-	LED_PHASE_1,
-	LED_NUM_PHASES
-};
+enum led_phase { LED_PHASE_0, LED_PHASE_1, LED_NUM_PHASES };

 /*
  * STATE_CHARGING_LVL_1 is when 0 <= charge_percentage < led_charge_level_1


crashdump: fix undefined reference to `elfcorehdr_addr'

fix build bug introduced by 95b68dec0d5 "calgary iommu: use the first
kernels TCE tables in kdump":

arch/x86/kernel/built-in.o: In function `calgary_iommu_init':
(.init.text+0x8399): undefined reference to `elfcorehdr_addr'
arch/x86/kernel/built-in.o: In function `calgary_iommu_init':
(.init.text+0x856c): undefined reference to `elfcorehdr_addr'
arch/x86/kernel/built-in.o: In function `detect_calgary':
(.init.text+0x8c68): undefined reference to `elfcorehdr_addr'
arch/x86/kernel/built-in.o: In function `detect_calgary':
(.init.text+0x8d0c): undefined reference to `elfcorehdr_addr'

make elfcorehdr_addr a generally available symbol.

Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@elte.hu>

--- include/linux/crash_dump.h
+++ include/linux/crash_dump.h
@@ -8,7 +8,13 @@
 #include <linux/proc_fs.h>

 #define ELFCORE_ADDR_MAX	(-1ULL)
+
+#ifdef CONFIG_PROC_VMCORE
 extern unsigned long long elfcorehdr_addr;
+#else
+static const unsigned long long elfcorehdr_addr = ELFCORE_ADDR_MAX;
+#endif
+
 extern ssize_t copy_oldmem_page(unsigned long, char *, size_t,
 						unsigned long, int);
 extern const struct file_operations proc_vmcore_operations;


__in_dev_get_rtnl() can use rtnl_dereference()

If caller holds RTNL, we dont need a memory barrier
(smp_read_barrier_depends) included in rcu_dereference().

Just use rtnl_dereference() to properly document the assertions.

Signed-off-by: Eric Dumazet <a0baddf32b28d2f9429941ed4af2fe636e210591@gmail.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- include/linux/inetdevice.h
+++ include/linux/inetdevice.h
@@ -222,7 +222,7 @@

 static inline struct in_device *__in_dev_get_rtnl(const struct net_device *dev)
 {
-	return rcu_dereference_check(dev->ip_ptr, lockdep_rtnl_is_held());
+	return rtnl_dereference(dev->ip_ptr);
 }

 extern void in_dev_finish_destroy(struct in_device *idev);


mfd: palmas: Format the header file

mfd: palmas: Format the header file

Formats the palmas header file. Convert all
the offset values to hexadecimal.

Signed-off-by: Keerthy <bd0da4b944f4f5c71572cb1afabf3c293f45b4c8@ti.com>
Signed-off-by: Lee Jones <630e34333487a351a857f6b705e04d30b37c1629@linaro.org>


dmaengine: shdma: Make dummy shdma_chan_filter() always return false

If CONFIG_SH_DMAE_BASE (which is required for DMA engine support for
legacy SH, SH/R-Mobile, and R-Car Gen1, but not for R-Car Gen2) is not
enabled, but CONFIG_RCAR_DMAC (for R-Car Gen2 DMA engine support) is,
and the DTS doesn't provide a "dmas" property for a device,
dma_request_slave_channel_compat() incorrectly succeeds, and returns a
DMA channel.

However, when trying to use that DMA channel later, it fails with:

    rcar-dmac e6700000.dma-controller: rcar_dmac_prep_slave_sg: bad parameter: len=1, id=-22

(Fortunately most drivers can handle this failure, and fall back to
PIO)

The reason for this is that a NULL legacy filter function is used, which
actually means "all channels are OK", not "do not match".
If CONFIG_SH_DMAE_BASE is enabled (like in shmobile_defconfig, which
supports other SoCs besides R-Car Gen2), shdma_chan_filter() correctly
returns false, as no available channel on R-Car Gen2 matches a
shdma-base channel.
If the DTS does provide a "dmas" property, dma_request_slave_channel()
succeeds, and legacy filter-based matching is not used.

To fix this, change shdma_chan_filter from being NULL to a dummy
function that always returns false, like is done on other platforms.

Signed-off-by: Geert Uytterhoeven <a1ff81395f7e6bf5b509fe9aab06bf3419493e1d@glider.be>
Signed-off-by: Vinod Koul <5cf69c63beb17bf38d63aa0e923ee8256af0e205@intel.com>


add a helper method.

add a helper method.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@94012 91177308-0d34-0410-b5e6-96231b3b80d8

--- include/llvm/PassSupport.h
+++ include/llvm/PassSupport.h
@@ -82,6 +82,11 @@
   /// TODO : Rename
   intptr_t getTypeInfo() const { return PassID; }

+  /// Return true if this PassID implements the specified ID pointer.
+  bool isPassID(void *IDPtr) const {
+    return PassID == (intptr_t)IDPtr;
+  }
+
   /// isAnalysisGroup - Return true if this is an analysis group, not a normal
   /// pass.
   ///


Support abstract types by keeping on the use list of the abstract type.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@425 91177308-0d34-0410-b5e6-96231b3b80d8

--- include/llvm/SymbolTable.h
+++ include/llvm/SymbolTable.h
@@ -16,9 +16,9 @@
 #ifndef LLVM_SYMBOL_TABLE_H
 #define LLVM_SYMBOL_TABLE_H

+#include "llvm/Value.h"
 #include <vector>
 #include <map>
-#include <string>

 class Value;
 class Type;
@@ -27,7 +27,8 @@
 // Make the vector be a data member, and base it on UniqueID's
 // That should be much more efficient!
 //
-class SymbolTable : public map<const Type *, map<const string, Value *> > {
+class SymbolTable : public AbstractTypeUser,
+		    public map<const Type *, map<const string, Value *> > {
   typedef map<const string, Value *> VarMap;
   typedef map<const Type *, VarMap> super;

@@ -53,7 +54,20 @@
   type_iterator type_find(const Value *D);

   // insert - Add named definition to the symbol table...
-  void insert(Value *N);
+  inline void insert(Value *N) {
+    assert(N->hasName() && "Value must be named to go into symbol table!");
+    insertEntry(N->getName(), N);
+  }
+
+  // insert - Insert a constant or type into the symbol table with the specified
+  // name...  There can be a many to one mapping between names and
+  // (constant/type)s.
+  //
+  inline void insert(const string &Name, Value *V) {
+    assert((V->isType() || V->isConstant()) &&
+	   "Can only insert types and constants here!");
+    insertEntry(Name, V);
+  }

   void remove(Value *N);
   Value *type_remove(const type_iterator &It);
@@ -84,6 +98,15 @@
   inline type_const_iterator type_end(const Type *TypeID) const {
     return find(TypeID)->second.end();
   }
+
+private:
+  // insertEntry - Insert a value into the symbol table with the specified
+  // name...
+  //
+  void insertEntry(const string &Name, Value *V);
+
+  // This function is called when one of the types in the type plane are refined
+  virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
 };

 #endif


fix (SipiXmp.h): added missing library

fix (SipiXmp.h): added missing library

--- include/metadata/SipiXmp.h
+++ include/metadata/SipiXmp.h
@@ -26,6 +26,7 @@
 #define __defined_xmp_h

 #include <string>
+#include <mutex>
 #include <exiv2/xmp.hpp> //!< Import xmp from the exiv2 library!
 #include <exiv2/error.hpp>


code cleanup

code cleanup

--- include/msp430/core/gpio.h
+++ include/msp430/core/gpio.h
@@ -26,6 +26,21 @@

 #ifndef GPIO_H_
 #define GPIO_H_
+
+#ifdef __GNUC__
+#define ALWAYS_INLINE inline __attribute__((always_inline))
+#define NEVER_INLINE __attribute__((noinline))
+#ifndef __always_inline
+#define __always_inline __attribute__((always_inline))
+#endif
+#ifndef __noinline
+#define __noinline __attribute__((noinline))
+#endif
+#else
+#define ALWAYS_INLINE inline
+#define NEVER_INLINE
+#warning This code takes advantage of features only found in msp430-gcc!!!
+#endif

 #include <logic.h>

@@ -45,6 +60,11 @@
   ,OUTPUT=0x01
   ,INPUT_PULLUP=0x02
   ,INPUT_PULLDOWN=0x04
+
+  ,TIMER_INPUT=0x1000
+  ,TIMER_OUTPUT=0x1100
+  ,UART_TX=0x1200
+  ,UART_RX=0x1400
 };

 enum pin_value {
@@ -65,76 +85,103 @@
   ,u8_SFR pren
 >
 struct GPIO_PORT_BASE0 {
-  static u8_CSFR PIN()  { return pin;  }
-  static u8_SFR POUT()  { return pout; }
-  static u8_SFR PDIR()  { return pdir; }
-  static u8_SFR PSEL()  { return psel; }
-  static u8_SFR PREN()  { return pren; }
-  static yesno_e hasPSEL2() { return NO; }
-  static yesno_e hasInterrupt() { return NO; }
-  static const int _portno = portno;
-
-  /**
-   * pin direction configuration methods
-   */
-  ALWAYS_INLINE static void set_mode(const uint8_t mask, pin_mode mode) {
-    if ( 0 ) {
-    }
-    else if (mode == OUTPUT ) {
-      setmode_output(mask);
-    }
-    else if ( mode == INPUT ) {
-      setmode_input(mask);
-    }
-    else if (mode == INPUT_PULLUP) {
-        setmode_inputpullup(mask);
-    }
-    else if (mode == INPUT_PULLDOWN) {
-        setmode_inputpulldown(mask);
-    }
-  }
-
-  ALWAYS_INLINE static void setmode_input(const uint8_t mask) {
-    pdir &= ~mask;
-  }
-
-  ALWAYS_INLINE static void setmode_inputpullup(const uint8_t mask) {
-    pdir &= ~mask; set_pins(mask); pren |= mask;
-  }
-
-  ALWAYS_INLINE static void setmode_inputpulldown(const uint8_t mask) {
-    pdir &= ~mask;  clear_pins(mask); pren |= mask;
-  }
-
-  ALWAYS_INLINE static void setmode_output(const uint8_t mask ) {
-    pdir |= mask;
-  }
-
-  /*
-   * port wide (8bits) get/set methods
-   */
-  ALWAYS_INLINE static void set_value(const uint8_t value) {
-    pout = value;
-  }
-
-  ALWAYS_INLINE static uint8_t get_value() {
-    return pin;
-  }
-
-  ALWAYS_INLINE static void set_pins(const uint8_t pin_mask) {
-    pout |= pin_mask;
-  }
-
-  ALWAYS_INLINE static void clear_pins(const uint8_t pin_mask) {
-    pout &= ~pin_mask;
-  }
-
-  ALWAYS_INLINE static void toggle_pins(const uint8_t pin_mask) {
-    pout ^= pin_mask;
-  }
-
-  /* TODO: fix this PSEL2 not available on some PORTS */
-  /* TODO: devise generic scheme for setting alternate pin functions */
+    static const int _portno = portno;
+
+    static ALWAYS_INLINE u8_SFR POUT() { return pout; }
+    static ALWAYS_INLINE u8_CSFR PIN() { return pin; }
+    static ALWAYS_INLINE u8_SFR PSEL() { return psel; }
+
+    /**
+     * pin direction configuration methods
+     */
+    static ALWAYS_INLINE void setmode_input(const uint8_t pins_mask) {
+        pdir &= ~pins_mask;
+    }
+
+    static ALWAYS_INLINE void setmode_inputpullup(const uint8_t pins_mask) {
+        pdir &= ~pins_mask;
+        set(pins_mask);
+        pren |= pins_mask;
+    }
+
+    static ALWAYS_INLINE void setmode_inputpulldown(const uint8_t pins_mask) {
+        pdir &= ~pins_mask;
+        clear(pins_mask);
+        pren |= pins_mask;
+    }
+
+    static ALWAYS_INLINE void setmode_output(const uint8_t pins_mask) {
+        pdir |= pins_mask;
+    }
+
+    static ALWAYS_INLINE void set_mode(const uint8_t pins_mask, pin_mode mode) {
+        if (0) {
+        }
+        else if (mode == OUTPUT) {
+            setmode_output(pins_mask);
+        }
+        else if (mode == INPUT) {
+            setmode_input(pins_mask);
+        }
+        else if (mode == INPUT_PULLUP) {
+            setmode_inputpullup(pins_mask);
+        }
+        else if (mode == INPUT_PULLDOWN) {
+            setmode_inputpulldown(pins_mask);
+        }
+    }
+
+    /*
+     * port wide (8bits) get/set methods
+     */
+    static ALWAYS_INLINE void set_value(const uint8_t value) {
+        pout = value;
+    }
+
+    static ALWAYS_INLINE uint8_t get_value() {
+        return pin;
+    }
+
+    static ALWAYS_INLINE void set(const uint8_t pins_mask) {
+        pout |= pins_mask;
+    }
+
+    static ALWAYS_INLINE void clear(const uint8_t pins_mask) {
+        pout &= ~pins_mask;
+    }
+
+    static ALWAYS_INLINE void toggle(const uint8_t pins_mask) {
+        pout ^= pins_mask;
+    }
+
+    /*
+     * pin query functions
+     */
+    static ALWAYS_INLINE unsigned read(const uint8_t pin_mask) {
+        return (pin & pin_mask);
+    }
+
+    /*
+     *
+     */
+    static ALWAYS_INLINE bool test(const uint8_t pin_mask) {
+        return (pin & pin_mask);
+    }
+
+    /*
+     *
+     */
+    static ALWAYS_INLINE unsigned is_low(const uint8_t pins_mask) {
+        return (pin & pins_mask) == 0 ? 1 : 0;
+    }
+
+    /*
+     *
+     */
+    static ALWAYS_INLINE unsigned is_high(const uint8_t pin_mask) {
+        return (pin & pin_mask) == pin_mask ? 1 : 0;
+    }
+    /* TODO: devise generic scheme for setting alternate pin functions */
 };

 /*
@@ -155,7 +202,6 @@
   GPIO_PORT_BASE0<portno,pin,pout,pdir,psel,pren>
 {
   static u8_SFR PSEL2() { return psel2; }
-  static yesno_e hasPSEL2() { return YES; }
 };

 /*
@@ -177,10 +223,11 @@
 struct GPIO_PORT0 :
 GPIO_PORT_BASE0<portno,pin,pout,pdir,psel,pren>
 {
+  static volatile uint8_t _fakepsel;
+
   static u8_SFR PIFG()  { return pifg; }
   static u8_SFR PIES()  { return pies; }
   static u8_SFR PIE()   { return pie; }
-  static yesno_e hasInterrupt() { return YES; }

   /* TODO: implement decent pin interrupt ISR handlers () */
 };
@@ -219,23 +266,29 @@
  *       of a GPIO_PIN
  */
 template<
-  bool active_low = false
-  ,bool uart_tx_pin = false
-  ,bool uart_rx_pin = false
+   bool active_low   = false
+  ,bool uart_tx_pin  = false
+  ,bool uart_rx_pin  = false
   ,bool spi_sclk_pin = false
   ,bool spi_mosi_pin = false
   ,bool spi_mis0_pin = false
+  ,bool timer_out_pin = false
+  ,bool timer_in_pin = false
 >
 struct gpio_pincaps_t {
   static const bool is_active_low = active_low;
   static const bool canbe_uart_tx = uart_tx_pin;
   static const bool canbe_uart_rx = uart_rx_pin;
+  static const bool canbe_timer_out = timer_out_pin;
+  static const bool can_be_timer_in = timer_in_pin;
 };

 typedef gpio_pincaps_t<true> gpio_pin_button;
 typedef gpio_pincaps_t<true,true> gpio_pin_uart_tx;
 typedef gpio_pincaps_t<true,false,true> gpio_pin_uart_rx;
 typedef gpio_pincaps_t<false,false,false,true> gpio_pin_spi_sclk;
+typedef gpio_pincaps_t<false,false,false,false,false,false,true> gpio_pin_timer_tx;
+typedef gpio_pincaps_t<false,false,false,false,false,false,false,true> gpio_pin_timer_rx;

 /*
  * GPIO_PIN<> - pin template
@@ -248,107 +301,87 @@
   static const int _portno = PORT::_portno;
   typedef CAPS_T pin_cap;

-  static u8_CSFR PIN()  { return PORT::PIN();  }
-  static u8_SFR POUT()  { return PORT::POUT(); }
-  static u8_SFR PDIR()  { return PORT::PDIR(); }
-  static u8_SFR PSEL()  { return PORT::PSEL(); }
-  static u8_SFR PSEL2() { return PORT::PSEL2();}
-  static u8_SFR PREN()  { return PORT::PREN(); }
-
-  static u8_SFR PIFG()  { return PORT::PIFG(); }
-  static u8_SFR PIES()  { return PORT::PIES(); }
-  static u8_SFR PIE()   { return PORT::PIE(); }
+  static ALWAYS_INLINE u8_SFR POUT() { return PORT::POUT(); }
+  static ALWAYS_INLINE u8_CSFR PIN()  { return PORT::PIN();  }
+  static ALWAYS_INLINE u8_SFR PSEL() { return PORT::PSEL(); }

   /*
    * pin direction functions
    */
-  ALWAYS_INLINE static void setmode_input() {
-    PORT::PDIR() &= ~MASK;
-  }
-
-  /*
-   * clear internal pullup resistor
-   */
-  ALWAYS_INLINE static void disable_pupd_resistor() {
-    PORT::PREN() &= ~MASK;
-  }
-
-  /*
-   * set internal pullup resistor
-   */
-  ALWAYS_INLINE static void enable_pupd_resistor() {
-    PORT::PREN() |= MASK;
-  }
-  /*
-   *
-   */
-  ALWAYS_INLINE static void setmode_inputpullup() {
-    PORT::PDIR() &= ~MASK;
-    high();
-    enable_pupd_resistor();
-  }
-
-  /*
-   *
-   */
-  ALWAYS_INLINE static void setmode_inputpulldown() {
-    PORT::PDIR() &= ~MASK;
-    low();
-    enable_pupd_resistor();
-  }
-
-  /*
-   *
-   */
-  ALWAYS_INLINE static void setmode_output() {
-    PORT::PDIR() |= MASK;
-  }
-
-  /*
-   *
-   */
-  ALWAYS_INLINE static void set_mode(const pin_mode mode) {
-    if (0) {
-    }
-    else if (mode == OUTPUT) {
-      setmode_output();
-    }
-    else if (mode == INPUT) {
-      setmode_input();
-    }
-    else if (mode == INPUT_PULLUP) {
-      setmode_inputpullup();
-    }
-    else if (mode == INPUT_PULLDOWN) {
-      setmode_inputpulldown();
-    }
-  }
+  static ALWAYS_INLINE void setmode_input() {
+      mode_gpio();
+      PORT::setmode_input(MASK);
+  }
+
+  /*
+   *
+   */
+  static ALWAYS_INLINE void setmode_inputpullup() {
+      mode_gpio();
+      PORT::setmode_inputpullup(MASK);
+  }
+
+  /*
+   *
+   */
+  static ALWAYS_INLINE void setmode_inputpulldown() {
+      mode_gpio();
+      PORT::setmode_inputpulldown(MASK);
+  }
+
+  /*
+   *
+   */
+  static ALWAYS_INLINE void setmode_output() {
+      mode_gpio();
+      PORT::setmode_output(MASK);
+  }
+
+  /*
+   *
+   */
+  static ALWAYS_INLINE void set_mode(const pin_mode mode) {
+      // TBD provide core alt switch
+      PORT::set_mode(MASK,mode);
+  }
+
+  /*
+   * alt_functions - overrideable
+   */
+  static ALWAYS_INLINE void mode_gpio() {}
+
+  static ALWAYS_INLINE void mode_timer_out() {}
+  static ALWAYS_INLINE void mode_timer_in() {}
+
+  static ALWAYS_INLINE void mode_uart() {}
+  static ALWAYS_INLINE void mode_uart_rx() {}
+  static ALWAYS_INLINE void mode_uart_tx() {}
+
+  static ALWAYS_INLINE void mode_spi() {}
+  static ALWAYS_INLINE void mode_spi_clk() {}
+  static ALWAYS_INLINE void mode_spi_mosi() {}
+  static ALWAYS_INLINE void mode_spi_miso() {}

   /*
    * pin query functions
    */
-  ALWAYS_INLINE static unsigned read() {
-    return (PORT::PIN() & MASK ) != 0;
-  }
-
-  /*
-   *
-   */
-  ALWAYS_INLINE static unsigned is_low() {
-    return (PORT::PIN() & MASK ) == 0;
-  }
-
-  /*
-   *
-   */
-  ALWAYS_INLINE static unsigned is_high() {
-    return (PORT::PIN() & MASK ) != 0;
-  }
-
-  /*
-   *
-   */
-  ALWAYS_INLINE static unsigned is_pushed() {
+
+  static ALWAYS_INLINE bool is_low() {
+      return !(PORT::test(MASK));
+  }
+
+  static ALWAYS_INLINE bool is_high() {
+      return (PORT::test(MASK));
+  }
+
+  static ALWAYS_INLINE bool read() {
+      return PORT::read(MASK) ? 1 : 0;
+  }
+
+  /*
+   *
+   */
+  static ALWAYS_INLINE unsigned is_pushed() {
     if ( pin_cap::is_active_low ) {
       return is_low();
     }
@@ -360,7 +393,7 @@
   /*
    * pin modification functions
    */
-  ALWAYS_INLINE static void write(pin_value value) {
+  static ALWAYS_INLINE void write(pin_value value) {
     if (value == HIGH) {
       high();
     }
@@ -372,52 +405,50 @@
   /*
    *
    */
-  ALWAYS_INLINE static void high() {
-    PORT::POUT() |= MASK;
-  }
-
-  /*
-   *
-   */
-  ALWAYS_INLINE static void low() {
-    if ( MASK )
-      PORT::POUT() &= ~MASK;
-  }
-
-  /*
-   *
-   */
-  ALWAYS_INLINE static void toggle() {
-    if ( MASK )
-      PORT::POUT() ^= MASK;
+  static ALWAYS_INLINE void high() {
+      PORT::set(MASK);
+  }
+
+  /*
+   *
+   */
+  static ALWAYS_INLINE void low() {
+      PORT::clear(MASK);
+  }
+
+  /*
+   *
+   */
+  static ALWAYS_INLINE void toggle() {
+      PORT::toggle(MASK);
   }

   /*
    * port wide (8bits) set direction using pin as port
    */
-  ALWAYS_INLINE static void set_modes(const uint8_t pins_mask, pin_mode mode) {
+  static ALWAYS_INLINE void set_modes(const uint8_t pins_mask, pin_mode mode) {
     PORT::set_mode(pins_mask, mode);
   }

   /*
    * port wide (8bits) modifications using pin as port
    */
-  ALWAYS_INLINE static void set_pins(const uint8_t pins_mask) {
-    PORT::POUT() |= pins_mask;
-  }
-
-  /*
-   *
-   */
-  ALWAYS_INLINE static void clear_pins(const uint8_t pins_mask) {
-    PORT::POUT() &= ~pins_mask;
-  }
-
-  /*
-   *
-   */
-  ALWAYS_INLINE static void toggle_pins(const uint8_t pins_mask) {
-    PORT::POUT() ^= pins_mask;
+  static ALWAYS_INLINE void set_pins(const uint8_t pins_mask) {
+      PORT::set(pins_mask);
+  }
+
+  /*
+   *
+   */
+  static ALWAYS_INLINE void clear_pins(const uint8_t pins_mask) {
+      PORT::clear(pins_mask);
+  }
+
+  /*
+   *
+   */
+  static ALWAYS_INLINE void toggle_pins(const uint8_t pins_mask) {
+      PORT::toggle(pins_mask);
   }

   /* TODO: fix this, not all pins have interrupt capability */
@@ -459,8 +490,14 @@
     static uint8_t PINMASK() { return 0; }

     static void set_mode(const uint8_t, pin_mode) {}
-    static const int _portno = 0;
+    //static const int _portno = 0;
   } port;
+  static volatile uint8_t _psel;
+  static volatile uint8_t _fake_pin;
+
+  static u8_SFR PSEL() { return (u8_SFR)_psel; }
+  static u8_SFR PSEL2() { return (u8_SFR)_psel; }
+  static u8_SFR PIN() { return (u8_SFR)_fake_pin; }

   static const uint8_t pin_mask=0;
   static const int _portno = 0;


Updated nui3 with uncommited changes to nui2

git-svn-id: ff55ab05972971099f5457a5dcea4a0fa6dcbe78@3696 9db30882-7939-4ce0-a36a-45f8a15c01b5

--- include/nglUTFStringConv.h
+++ include/nglUTFStringConv.h
@@ -12,16 +12,7 @@

 typedef ConversionResult (*UTFConverter) (const char** sourceStart, const char* sourceEnd, char** targetStart, char* targetEnd, ConversionFlags flags);

-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-  ConversionResult NoConversion(const char** sourceStart, const char* sourceEnd, char** targetStart, char* targetEnd, ConversionFlags flags);
-
-#ifdef __cplusplus
-}
-#endif
+ConversionResult NoConversion(const char** sourceStart, const char* sourceEnd, char** targetStart, char* targetEnd, ConversionFlags flags);

 class NGL_API nglUTFStringConv : public nglStringConv
 {


feat(core): Add statistics structures

feat(core): Add statistics structures

--- include/open62541/common.h
+++ include/open62541/common.h
@@ -2,10 +2,11 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
- *    Copyright 2016-2017 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
+ *    Copyright 2016-2020 (c) Fraunhofer IOSB (Author: Julius Pfrommer)
  *    Copyright 2016 (c) Sten Grüner
  *    Copyright 2016-2017 (c) Stefan Profanter, fortiss GmbH
  *    Copyright 2017 (c) Florian Palm
+ *    Copyright 2020 (c) HMS Industrial Networks AB (Author: Jonas Green)
  */

 #ifndef UA_COMMON_H_
@@ -144,6 +145,46 @@
     UA_ORDER_MORE = 1
 } UA_Order;

+/**
+ * Statistic counters
+ * ------------------
+ *
+ * The stack manage statistic counter for the following layers:
+ * - Network
+ * - Secure channel
+ * - Session
+ *
+ * The session layer counters are matching the counters of the
+ * ServerDiagnosticsSummaryDataType that are defined in the OPC UA Part 5
+ * specification. Counter of the other layers are not specified by OPC UA but
+ * are harmonized with the session layer counters if possible. */
+
+typedef struct {
+    size_t currentConnectionCount;
+    size_t cumulatedConnectionCount;
+    size_t rejectedConnectionCount;
+    size_t connectionTimeoutCount;
+    size_t connectionAbortCount;
+} UA_NetworkStatistics;
+
+typedef struct {
+    size_t currentChannelCount;
+    size_t cumulatedChannelCount;
+    size_t rejectedChannelCount;
+    size_t channelTimeoutCount; /* only used by servers */
+    size_t channelAbortCount;
+    size_t channelPurgeCount;   /* only used by servers */
+} UA_SecureChannelStatistics;
+
+typedef struct {
+    size_t currentSessionCount;
+    size_t cumulatedSessionCount;
+    size_t securityRejectedSessionCount; /* only used by servers */
+    size_t rejectedSessionCount;
+    size_t sessionTimeoutCount;          /* only used by servers */
+    size_t sessionAbortCount;            /* only used by servers */
+} UA_SessionStatistics;
+
 _UA_END_DECLS

 #endif /* UA_COMMON_H_ */


add in spin mutex specialization for osx

--- include/parallel/threads.h
+++ include/parallel/threads.h
@@ -49,6 +49,11 @@
 #  include <pthread.h>
 #  include <algorithm>
 #  include <vector>
+
+#ifdef __APPLE__
+#include <libkern/OSAtomic.h>
+#endif
+
 #endif

 // Thread-Local-Storage macros
@@ -560,6 +565,35 @@
    * Spin mutex.  Implements mutual exclusion by busy-waiting in user
    * space for the lock to be acquired.
    */
+#ifdef __APPLE__
+  class spin_mutex
+  {
+  public:
+    spin_mutex() : slock(0) {} // The convention is that the lock being zero is _unlocked_
+    ~spin_mutex() {}
+
+    void lock () { OSSpinLockLock(&slock); }
+    void unlock () { OSSpinLockUnlock(&slock); }
+
+    class scoped_lock
+    {
+    public:
+      scoped_lock () : smutex(NULL) {}
+      explicit scoped_lock ( spin_mutex& in_smutex ) : smutex(&in_smutex) { smutex->lock(); }
+
+      ~scoped_lock () { release(); }
+
+      void acquire ( spin_mutex& in_smutex ) { smutex = &in_smutex; smutex->lock(); }
+      void release () { if(smutex) smutex->unlock(); smutex = NULL; }
+
+    private:
+      spin_mutex * smutex;
+    };
+
+  private:
+    OSSpinLock slock;
+  };
+#else
   class spin_mutex
   {
   public:
@@ -588,6 +622,7 @@
   private:
     pthread_mutex_t mutex;
   };
+#endif

   //-------------------------------------------------------------------
   /**


semaphore: add up/down api

semaphore: add up/down api

semaphore_{lock,unlock} can be quite confusing for a semaphore api, so let's
add their semaphore_(up/down} equivalent.

Signed-off-by: Fabien Parent <2a93cde040adee823a667eed2882d05f12a84573@gmail.com>

--- include/phabos/semaphore.h
+++ include/phabos/semaphore.h
@@ -23,5 +23,15 @@
 void semaphore_unlock(struct semaphore *semaphore);
 void semaphore_destroy(struct semaphore *semaphore);

+static inline void semaphore_up(struct semaphore *semaphore)
+{
+    semaphore_unlock(semaphore);
+}
+
+static inline void semaphore_down(struct semaphore *semaphore)
+{
+    semaphore_lock(semaphore);
+}
+
 #endif /* __SEMAPHORE_H__ */


Add a pack method to location.

Add a pack method to location.

--- include/po6/net/location.h
+++ include/po6/net/location.h
@@ -81,6 +81,11 @@
         }

     public:
+        void pack(struct sockaddr* addr, socklen_t* addrlen) const
+        {
+            address.pack(addr, addrlen, port);
+        }
+
         void set(const sockaddr* sa, socklen_t salen)
         {
             if (sa->sa_family == AF_INET && salen >= sizeof(sockaddr_in))


Add ksceNetConnect

Add ksceNetConnect

--- include/psp2kern/net/net.h
+++ include/psp2kern/net/net.h
@@ -545,6 +545,7 @@
 int ksceNetSocket(const char *name, int domain, int type, int protocol);
 int ksceNetAccept(int s, SceNetSockaddr *addr, unsigned int *addrlen);
 int ksceNetBind(int s, const SceNetSockaddr *addr, unsigned int addrlen);
+int ksceNetConnect(int s, const SceNetSockaddr *name, unsigned int namelen);
 int ksceNetListen(int s, int backlog);
 int ksceNetRecvfrom(int s, void *buf, unsigned int len, int flags, SceNetSockaddr *from, unsigned int *fromlen);
 int ksceNetSendto(int s, const void *msg, unsigned int len, int flags, const SceNetSockaddr *to, unsigned int tolen);


Add missing file

Add missing file

error: pathspec 'include/shadowdive/fonts.h' did not match any file(s) known to git

--- include/shadowdive/fonts.h
+++ include/shadowdive/fonts.h
@@ -0,0 +1,35 @@
+#ifndef _FONTS_H
+#define _FONTS_H
+
+typedef struct sd_rgba_image_t sd_rgba_image;
+
+#include <stdint.h>
+
+typedef struct sd_char_big_t {
+    char data[8];
+} sd_char_big;
+
+typedef struct sd_char_small_t {
+    char data[6];
+} sd_char_small;
+
+typedef struct sd_font_big_t {
+    sd_char_big chars[224];
+} sd_font_big;
+
+typedef struct sd_font_small_t {
+    sd_char_small chars[224];
+} sd_font_small;
+
+sd_font_small* sd_font_small_create();
+sd_font_big* sd_font_big_create();
+void sd_font_small_delete(sd_font_small *font);
+void sd_font_big_delete(sd_font_big *font);
+
+int sd_font_small_load(sd_font_small *font, const char *file);
+int sd_font_big_load(sd_font_big *font, const char *file);
+
+sd_rgba_image* sd_font_big_decode(sd_char_big *ch, uint32_t color);
+sd_rgba_image* sd_font_small_decode(sd_char_small *ch, uint32_t color);
+
+#endif // _FONTS_H


Remove needless return

Remove needless return

--- lib/plugin.c
+++ lib/plugin.c
@@ -436,7 +436,7 @@
 grn_plugin_free(grn_ctx *ctx, void *ptr, const char *file, int line,
                 const char *func)
 {
-  return grn_free(ctx, ptr, file, line, func);
+  grn_free(ctx, ptr, file, line, func);
 }

 /*


Add a printf for previous to know when that happens.

--HG--
extra : convert_revision : 9d716b7906f2ef7226afb608361e1286f45ce355

--- lib/remove.c
+++ lib/remove.c
@@ -194,6 +194,8 @@
 			    "sha256", &sha256);
 			rv = xbps_check_file_hash(path, sha256);
 			if (rv == ENOENT) {
+				printf("WARNING: '%s' doesn't exist!\n",
+				    file);
 				free(path);
 				continue;
 			} else if (rv == ERANGE) {


Add option for 2400 baud to PC programs.

--- lib/serial.c
+++ lib/serial.c
@@ -81,6 +81,9 @@

   speed_t speed = 0;
   switch (opts->baudrate) {
+  case 2400:
+    speed = B2400;
+    break;
   case 9600:
     speed = B9600;
     break;


server.c: test **truncated_send_len** for partial

Testing against truncated_send_malloc won't work if we've already
buffered and completed a partial buffer, as truncated_send_malloc
isn't free'd until the socket is destroyed.

--- lib/server.c
+++ lib/server.c
@@ -572,7 +572,7 @@

 		/* pending truncated sends have uber priority */

-		if (wsi->truncated_send_malloc) {
+		if (wsi->truncated_send_len) {
 			if (pollfd->revents & LWS_POLLOUT)
 				if (lws_issue_raw(wsi, wsi->truncated_send_malloc +
 					wsi->truncated_send_offset,


avm1: Delete\Delete2 opcodes stubs with correct stack handling

--- swf/avm1.c
+++ swf/avm1.c
@@ -807,8 +807,23 @@
 }

 static void action_mb_ascii_to_char(LVGActionCtx *ctx, uint8_t *a) { DBG_BREAK; }
-static void action_delete(LVGActionCtx *ctx, uint8_t *a) { DBG_BREAK; }
-static void action_delete2(LVGActionCtx *ctx, uint8_t *a) { DBG_BREAK; }
+static void action_delete(LVGActionCtx *ctx, uint8_t *a)
+{
+    ASVal *se_prop = &ctx->stack[ctx->stack_ptr];
+    ASVal *se_cls  = se_prop + 1;
+    ctx->stack_ptr += 2;
+    assert(ASVAL_STRING == se_prop->type && ASVAL_CLASS == se_cls->type);
+    // TODO: delete property from se_cls
+}
+
+static void action_delete2(LVGActionCtx *ctx, uint8_t *a)
+{
+    ASVal *se_prop = &ctx->stack[ctx->stack_ptr];
+    ctx->stack_ptr += 1;
+    assert(ASVAL_STRING == se_prop->type);
+    // TODO: delete property from cuttent scope
+}
+
 static void action_define_local(LVGActionCtx *ctx, uint8_t *a)
 {
     ASVal *se_val = &ctx->stack[ctx->stack_ptr];
@@ -1047,6 +1062,8 @@
     if (ASVAL_UNDEFINED == se_var->type)
         return;
     assert(ASVAL_CLASS == se_var->type);
+    if (ASVAL_CLASS != se_var->type)
+        return;
     ASClass *c = se_var->cls;
     for (int i = 0; i < c->num_members; i++)
         if (0 == strcmp_identifier(ctx, se_member->str, c->members[i].name))


lib/string.c: improve strrchr()

lib/string.c: improve strrchr()

Instead of potentially passing over the string twice in case c is not
found, just keep track of the last occurrence.  According to
bloat-o-meter, this also cuts the generated code by a third (54 vs 36
bytes).  Oh, and we get rid of those 7-space indented lines.

Signed-off-by: Rasmus Villemoes <ba324ca7b1c77fc20bb970d5aff6eea9377918a5@rasmusvillemoes.dk>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>


minor string cleanup

minor string cleanup


thread.h: fix typo in doc string

thread.h: fix typo in doc string

--- lib/thread.h
+++ lib/thread.h
@@ -296,7 +296,7 @@
      * displayed, and a futher exception re-thrown to allow the main
      * application to catch the error (this could be the same exception that
      * was originally thrown if a single thread was run). This means the
-     * application will continue processing if any the remaining threads
+     * application will continue processing if any of the remaining threads
      * remain active, and it may be a while before the application itself is
      * allowed to handle the error appropriately. If this is behaviour is not
      * appropriate, and you expect exceptions to be thrown occasionally, you


add some casts to please lint.  these are the typical tv_sec vs time_t problems.  in time, we will move to 64 bit time_t, when the time is right (ha ha) but not before.  These casts do not harm the future model. ok cloder millert


Honor extractor's umask in git-tar-tree.

The archive generated with git-tar-tree had 0755 and 0644 mode bits.
This inconvenienced the extractor with umask 002 by robbing g+w bit
unconditionally.  Just write it out with loose permissions bits and
let the umask of the extractor do its job.

Signed-off-by: Junio C Hamano <dc50d1021234060e53ec42a77d526afa2fe07479@cox.net>

--- tar-tree.c
+++ tar-tree.c
@@ -353,6 +353,8 @@

 		if (size < namelen + 20 || sscanf(buffer, "%o", &mode) != 1)
 			die("corrupt 'tree' file");
+		if (S_ISDIR(mode) || S_ISREG(mode))
+			mode |= (mode & 0100) ? 0777 : 0666;
 		buffer = sha1 + 20;
 		size -= namelen + 20;


Rename m_mask variable to m_hash_mask for better code clarity.

--- include/tsl/ordered_hash.h
+++ include/tsl/ordered_hash.h
@@ -441,7 +441,7 @@
                                          KeyEqual(equal),
                                          m_buckets_data(alloc),
                                          m_buckets(static_empty_bucket_ptr()),
-                                         m_mask(0),
+                                         m_hash_mask(0),
                                          m_values(alloc),
                                          m_grow_on_next_insert(false)
     {
@@ -454,7 +454,7 @@

             m_buckets_data.resize(bucket_count);
             m_buckets = m_buckets_data.data(),
-            m_mask = bucket_count - 1;
+            m_hash_mask = bucket_count - 1;
         }

         this->max_load_factor(max_load_factor);
@@ -465,7 +465,7 @@
                                              m_buckets_data(other.m_buckets_data),
                                              m_buckets(m_buckets_data.empty()?static_empty_bucket_ptr():
                                                                               m_buckets_data.data()),
-                                             m_mask(other.m_mask),
+                                             m_hash_mask(other.m_hash_mask),
                                              m_values(other.m_values),
                                              m_grow_on_next_insert(other.m_grow_on_next_insert),
                                              m_max_load_factor(other.m_max_load_factor),
@@ -482,7 +482,7 @@
                                             m_buckets_data(std::move(other.m_buckets_data)),
                                             m_buckets(m_buckets_data.empty()?static_empty_bucket_ptr():
                                                                              m_buckets_data.data()),
-                                            m_mask(other.m_mask),
+                                            m_hash_mask(other.m_hash_mask),
                                             m_values(std::move(other.m_values)),
                                             m_grow_on_next_insert(other.m_grow_on_next_insert),
                                             m_max_load_factor(other.m_max_load_factor),
@@ -490,7 +490,7 @@
     {
         other.m_buckets_data.clear();
         other.m_buckets = static_empty_bucket_ptr();
-        other.m_mask = 0;
+        other.m_hash_mask = 0;
         other.m_values.clear();
         other.m_grow_on_next_insert = false;
         other.m_load_threshold = 0;
@@ -505,7 +505,7 @@
             m_buckets = m_buckets_data.empty()?static_empty_bucket_ptr():
                                                m_buckets_data.data();

-            m_mask = other.m_mask;
+            m_hash_mask = other.m_hash_mask;
             m_values = other.m_values;
             m_grow_on_next_insert = other.m_grow_on_next_insert;
             m_max_load_factor = other.m_max_load_factor;
@@ -785,7 +785,7 @@
         swap(static_cast<KeyEqual&>(*this), static_cast<KeyEqual&>(other));
         swap(m_buckets_data, other.m_buckets_data);
         swap(m_buckets, other.m_buckets);
-        swap(m_mask, other.m_mask);
+        swap(m_hash_mask, other.m_hash_mask);
         swap(m_values, other.m_values);
         swap(m_grow_on_next_insert, other.m_grow_on_next_insert);
         swap(m_max_load_factor, other.m_max_load_factor);
@@ -1177,7 +1177,7 @@
                                            m_buckets_data.data();
         // Everything should be noexcept from here.

-        m_mask = (bucket_count > 0)?(bucket_count - 1):0;
+        m_hash_mask = (bucket_count > 0)?(bucket_count - 1):0;
         this->max_load_factor(m_max_load_factor);
         m_grow_on_next_insert = false;

@@ -1437,7 +1437,7 @@
     }

     std::size_t bucket_for_hash(std::size_t hash) const noexcept {
-        return hash & m_mask;
+        return hash & m_hash_mask;
     }

     std::size_t iterator_to_index(const_iterator it) const noexcept {
@@ -1526,7 +1526,7 @@
         else {
             m_buckets_data.reserve(numeric_cast<size_type>(bucket_count_ds, "Deserialized bucket_count is too big."));
             m_buckets = m_buckets_data.data(),
-            m_mask = m_buckets_data.capacity() - 1;
+            m_hash_mask = m_buckets_data.capacity() - 1;

             reserve_space_for_values(numeric_cast<size_type>(nb_elements, "Deserialized nb_elements is too big."));
             for(slz_size_type el = 0; el < nb_elements; el++) {
@@ -1597,7 +1597,7 @@
      */
     bucket_entry* m_buckets;

-    size_type m_mask;
+    size_type m_hash_mask;

     values_container_type m_values;


fixed the broken md5 logic

fixed the broken md5 logic

--- lib/verify.c
+++ lib/verify.c
@@ -38,18 +38,22 @@
     int size;
     char ** unameList, ** gnameList;
     int_32 useBrokenMd5;
+    int_32 * brokenPtr;

 #if WORDS_BIGENDIAN
-    if (!headerGetEntry(h, RPMTAG_BROKENMD5, NULL, &useBrokenMd5, NULL)) {
+    if (!headerGetEntry(h, RPMTAG_BROKENMD5, NULL, (void **) &brokenPtr, NULL)) {
 	char * rpmVersion;

-	if (headerGetEntry(h, RPMTAG_RPMVERSION, NULL, &rpmVersion, NULL)) {
+	if (headerGetEntry(h, RPMTAG_RPMVERSION, NULL, (void **) &rpmVersion,
+				NULL)) {
 	    useBrokenMd5 = ((rpmvercmp(rpmVersion, "2.3.3") >= 0) &&
 			    (rpmvercmp(rpmVersion, "2.3.8") <= 0));
 	} else {
 	    useBrokenMd5 = 1;
 	}
 	headerAddEntry(h, RPMTAG_BROKENMD5, RPM_INT32_TYPE, &useBrokenMd5, 1);
+    } else {
+	useBrokenMd5 = *brokenPtr;
     }
 #else
     useBrokenMd5 = 0;


Remove unneeded left padding with zeros

Remove unneeded left padding with zeros

--- libc/stdio.c
+++ libc/stdio.c
@@ -55,6 +55,7 @@
       //variables can't be declared in switch statements, so these are here just in case
       int* number;
       const char* str;
+      bool has_reached_nonzero_digits = false;
       //TODO: Implement all the other things (%g...)
       switch(format[i + 1]) {
         case '%':
@@ -75,7 +76,8 @@
           }
           number = int_to_digits(va_arg(args, int));
           for(unsigned int j = 0; j < 10; j++) {
-            putchar((char) number[j] + '0');
+            if(number[j] != 0) has_reached_nonzero_digits = true;
+            if(number[j] != 0 || has_reached_nonzero_digits == true || j == 9) putchar((char) number[j] + '0');
           }
           break;
         default:


Reinitialize properly rootfd

Reinitialize properly rootfd

--- libpkg/pkg.c
+++ libpkg/pkg.c
@@ -118,6 +118,7 @@
 	pkg_list_free(pkg, PKG_SHLIBS_PROVIDED);
 	if (pkg->rootfd != -1)
 		close(pkg->rootfd);
+	pkg->rootfd = -1;

 	pkg->type = type;
 }


Reset automatic in pkg_reset()

Reset automatic in pkg_reset()

--- libpkg/pkg.c
+++ libpkg/pkg.c
@@ -79,8 +79,7 @@
 	pkg->flatsize = 0;
 	pkg->new_flatsize = 0;
 	pkg->new_pkgsize = 0;
-	pkg->flags = 0;
-	pkg->rowid = 0;
+	pkg->automatic = false;
 	pkg->licenselogic = 1;

 	pkg_list_free(pkg, PKG_LICENSES);
@@ -95,6 +94,7 @@
 	pkg_list_free(pkg, PKG_USERS);
 	pkg_list_free(pkg, PKG_GROUPS);

+	pkg->rowid = 0;
 	pkg->type = type;
 }


Fix $_set: test arg #3 instead of #2

Fix $_set: test arg #3 instead of #2

--- template.c
+++ template.c
@@ -187,14 +187,14 @@
 	mp$_ptr z;

 	z = _checkmp$(L, 1, 1);
-	if (!lua_isnoneornil(L, 2)) {
+	if (!lua_isnoneornil(L, 3)) {
 		int base;
-		/* 2 arguments: set(str, base) */
+		/* 2 arguments: z:set(str, base) */
 		luaL_checkstring(L, 2);
 		base = _check_inbase(L, 3);
 		$__set_str(L, z, 2, base);
 	} else {
-		/* 1 argument set(value) */
+		/* 1 argument z:set(value) */
 		$__set(L, 2, z);
 	}
 	lua_settop(L, 1);


Use q_div for integer -> rational division

--- template.c
+++ template.c
@@ -321,6 +321,8 @@

 OP_DCL(ternop, addmul)
 OP_DCL(ternop, submul)
+
+static int q_div(lua_State *L);

 static int z__intdiv_s(lua_State *L, int mode)
 {
@@ -428,24 +430,6 @@

 static int z_fdiv_q(lua_State *L) { return z__intdiv_s(L, 2); }
 static int z_fdiv_r(lua_State *L) { return z__intdiv_s(L, 3); }
-
-static mpq_ptr q_new(lua_State *L);
-
-/* z_ratdiv is always called as an operator */
-static int z_ratdiv(lua_State *L)
-{
-	mpq_ptr a;
-	mpz_ptr b, c;
-
-	a = q_new(L);
-	b = _tompz(L, 1);
-	c = _tompz(L, 2);
-	_check_divisor(L, c);
-	mpz_set(mpq_numref(a), b);
-	mpz_set(mpq_denref(a), c);
-	mpq_canonicalize(a);
-	return 1;
-}

 #define PRED_DCL(op) \
 static int z_##op(lua_State *L) { lua_pushboolean(L, mpz_##op(_tompz(L, 1))); return 1; }
@@ -712,7 +696,7 @@
 	METAMETHOD(eq),
 	METAMETHOD(lt),
 #if defined(MPZ)
-	METAMETHOD_ALIAS(div, ratdiv),
+	{ "__div",	q_div	},
 	METAMETHOD_ALIAS(idiv, fdiv_q),
 	METAMETHOD_ALIAS(mod, fdiv_r),
 	METAMETHOD(pow),


Set the cursor after the current character.

--- terminal.c
+++ terminal.c
@@ -28,6 +28,8 @@

     term->nCols = 10;
     term->nRows = 5;
+
+    fbMoveCursor(term->fbOriginX, term->fbOriginY);
 }

 void term_update()
@@ -102,9 +104,6 @@

 void term_putChar(unsigned char c)
 {
-    fbMoveCursor(currentTerminal->fbOriginX + currentTerminal->cursorX,
-                 currentTerminal->fbOriginY + currentTerminal->cursorY);
-
     fbPutChar(c);

     currentTerminal->cursorX++;
@@ -121,6 +120,8 @@
         }
     }

+    fbMoveCursor(currentTerminal->fbOriginX + currentTerminal->cursorX,
+                    currentTerminal->fbOriginY + currentTerminal->cursorY);
 }

 void term_putString(unsigned char* str)


remove unused code, rename struct {sixel_canvas_t, cell_t} bitmap -> pixmap

--- terminal.h
+++ terminal.h
@@ -3,13 +3,12 @@
 {
 	struct cell_t *cellp;

-	//cellp             = &term->cells[x + y * term->cols];
 	cellp             = &term->cells[y][x];
 	cellp->glyphp     = term->glyph_map[DEFAULT_CHAR];
 	cellp->color_pair = term->color_pair; /* bce */
 	cellp->attribute  = ATTR_RESET;
 	cellp->width      = HALF;
-	cellp->has_bitmap = false;
+	cellp->has_pixmap = false;

 	term->line_dirty[y] = true;
 }
@@ -18,8 +17,6 @@
 {
 	struct cell_t *dst, *src;

-	//dst = &term->cells[dst_x + dst_y * term->cols];
-	//src = &term->cells[src_x + src_y * term->cols];
 	dst = &term->cells[dst_y][dst_x];
 	src = &term->cells[src_y][src_x];

@@ -57,15 +54,13 @@

 	cell.attribute  = term->attribute;
 	cell.width      = glyphp->width;
-	cell.has_bitmap = false;
-
-	//cellp    = &term->cells[x + y * term->cols];
+	cell.has_pixmap = false;
+
 	cellp    = &term->cells[y][x];
 	*cellp   = cell;
 	term->line_dirty[y] = true;

 	if (cell.width == WIDE && x + 1 < term->cols) {
-		//cellp        = &term->cells[x + 1 + y * term->cols];
 		cellp        = &term->cells[y][x + 1];
 		*cellp       = cell;
 		cellp->width = NEXT_TO_WIDE;
@@ -77,7 +72,6 @@
 void scroll(struct terminal *term, int from, int to, int offset)
 {
 	int i, j, size, abs_offset, scroll_lines;
-	//struct cell_t *dst, *src;

 	if (offset == 0 || from >= to)
 		return;
@@ -88,21 +82,14 @@
 	for (i = from; i <= to; i++)
 		term->line_dirty[i] = true;

+	size = sizeof(struct cell_t) * term->cols;
 	abs_offset = abs(offset);
-	//size = sizeof(struct cell_t) * ((to - from + 1) - abs_offset) * term->cols;
-	size = sizeof(struct cell_t) * term->cols;
 	scroll_lines = (to - from + 1) - abs_offset;
-
-	//dst = term->cells + from * term->cols;
-	//src = term->cells + (from + abs_offset) * term->cols;
-	//dst = &term->cells[from][0];
-	//src = &term->cells[from + abs_offset][0];

 	if (offset > 0) { /* scroll down */
 		/* scroll down:
 			cells[from] ... cells[from + scroll_lines - 1]: copy from cells[i + offset]
 			cells[from + scroll_lines] ... cells[to]      : erase */
-		//memmove(dst, src, size);
 		for (i = from; i < from + scroll_lines; i++)
 			memmove(term->cells[i], term->cells[i + offset], size);

@@ -113,8 +100,7 @@
 		/* scroll up:
 			cells[from + abs_offset] ... cells[to]      : copy from cells[i - offset]
 			cells[from] ... cells[from + abs_offset - 1]: erase */
-		//memmove(src, dst, size);
-		for (i = to; i >= from + abs_offset; i--)
+		for (i = to; i >= from + abs_offset; i--) /* copy last line first */
 			memmove(term->cells[i], term->cells[i - abs_offset], size);

 		for (i = from; i < from + abs_offset; i++)
@@ -368,7 +354,7 @@

 	term->line_dirty = (bool *) ecalloc(term->lines, sizeof(bool));
 	term->tabstop    = (bool *) ecalloc(term->cols, sizeof(bool));
-	//term->cells      = (struct cell_t *) ecalloc(term->cols * term->lines, sizeof(struct cell_t));
+
 	term->cells      = (struct cell_t **) ecalloc(term->lines, sizeof(struct cell_t *));
 	for (i = 0; i < term->lines; i++)
 		term->cells[i] = (struct cell_t *) ecalloc(term->cols, sizeof(struct cell_t));
@@ -393,7 +379,7 @@
 		term->drcs[i] = NULL;

 	/* allocate sixel buffer */
-	term->sixel.bitmap = (uint8_t *) ecalloc(width * height, BYTES_PER_PIXEL);
+	term->sixel.pixmap = (uint8_t *) ecalloc(width * height, BYTES_PER_PIXEL);

 	reset(term);
 }
@@ -414,5 +400,5 @@
 		if (term->drcs[i] != NULL)
 			free(term->drcs[i]);

-	free(term->sixel.bitmap);
-}
+	free(term->sixel.pixmap);
+}


debug

debug

--- test_run.c
+++ test_run.c
@@ -13,7 +13,7 @@
   {
     while (get_angle()-target_angle<30 && get_angle()-target_angle>-30)
     {
-      motor_forward(10000,70);
+      motor_forward(5000,70);
     }
     while(get_angle()-target_angle>=30)
     {


[TESTS] testtree: queue task in creation order

--- testtree.c
+++ testtree.c
@@ -163,7 +163,7 @@
     unsigned long links_used = 0;
     unsigned long neighbours = 0;
     unsigned long long x;
-    struct task *task, *lasttask;
+    struct task *task, *lasttask, *firsttask;
     struct tree_node *node;
     struct timeval t_start, t_random, t_insert, t_lookup, t_walk, t_move, t_delete;
     static unsigned long long start, calibrate, end, cycles, cycles2, cycles3;
@@ -200,7 +200,7 @@
 	//printf("Timing %d random()+malloc... ", total);

 	rdtscll(start);
-	lasttask = NULL;
+	firsttask = lasttask = NULL;
 	for (i = 0; i < total; i++) {
 	    ////unsigned long long x = (i << 16) + ((random() & 63ULL) << 32) + (random() % 1000);
 	    //unsigned long l = (random() % 1000)*1000; // to emulate tv_usec based on milliseconds
@@ -237,12 +237,22 @@

 	    // simulates some sparse groups of values like with a scheduler
 	    x = (i / 1000) * 50000 + (i % 1000) * 4 - 1500;
-
+	    //x = i>>2;
 	    task = (struct task *)calloc(1,sizeof(*task));
 	    task->expire = x;//*x;//total-i-1;//*/(x>>10)&65535;//i&65535;//(x>>8)&65535;//rev32(i);//i&32767;//x;//i ^ (long)lasttask;
 	    task->wq = &wait_queue;
-	    task->data = (void *)lasttask;
+
+	    if (!firsttask)
+		firsttask = task;
+	    if (lasttask)
+		lasttask->data = (void *)task;
 	    lasttask = task;
+	    task->data = NULL;
+
+	    /* tasks will be queued backwards */
+	    memcpy(task->task_data, &i, sizeof(i));
+	    lasttask = task;
+	    //printf("task %p = %ld\n", task, i);
 	}
 	rdtscll(end);
 	tv_now(&t_random);
@@ -250,7 +260,7 @@

 	printf("Timing %d insert... ", total);
 	cycles = 0;
-	task = lasttask;
+	task = firsttask;
 	for (i = 0; i < total; i++) {
 	    rdtscll(start); rdtscll(calibrate); // account for the time spent calling rdtsc too !
 	    insert_task_queue(task);
@@ -286,8 +296,12 @@
     node = tree_first(&wait_queue);
     cycles = 0;

+    //printf("\n");
     rdtscll(start);
     while (node) {
+	//task = tree_entry(node);
+	//memcpy(&i, task->task_data, sizeof(i));
+	//printf("next: %p = %ld\n", task, i);
 	node = tree_next(node);
     }
     rdtscll(end);
@@ -300,8 +314,12 @@
     node = tree_last(&wait_queue);
     cycles = 0;

+    //printf("\n");
     rdtscll(start);
     while (node) {
+	//task = tree_entry(node);
+	//memcpy(&i, task->task_data, sizeof(i));
+	//printf("prev: %p = %ld\n", task, i);
 	node = tree_prev(node);
     }
     rdtscll(end);


Reduce stack collection to 20ms.

Reduce stack collection to 20ms.

--- tideways.c
+++ tideways.c
@@ -472,7 +472,7 @@
 PHP_INI_ENTRY("tideways.distributed_tracing_hosts", "127.0.0.1", PHP_INI_ALL, NULL)
 PHP_INI_ENTRY("tideways.log_level", "0", PHP_INI_ALL, NULL)
 PHP_INI_ENTRY("tideways.max_spans", "1500", PHP_INI_ALL, NULL)
-PHP_INI_ENTRY("tideways.stack_threshold", "50000", PHP_INI_ALL, NULL)
+PHP_INI_ENTRY("tideways.stack_threshold", "20000", PHP_INI_ALL, NULL)
 PHP_INI_ENTRY("tideways.timeout", "10000", PHP_INI_ALL, NULL)
 PHP_INI_ENTRY("tideways.service", "", PHP_INI_ALL, NULL)


Followed directions of issue 386 regarding posix signals

--- timedrun.c
+++ timedrun.c
@@ -7,11 +7,11 @@

 #include <assert.h>

-static int caught = 0;
+volatile sig_atomic_t caught_sig = 0;

-static void caught_signal(int which)
+static void signal_handler(int which)
 {
-    caught = which;
+    caught_sig = which;
 }

 static int wait_for_process(pid_t pid)
@@ -21,7 +21,7 @@
     int i = 0;
     struct sigaction sig_handler;

-    sig_handler.sa_handler = caught_signal;
+    sig_handler.sa_handler = signal_handler;
     sig_handler.sa_flags = 0;

     sigaction(SIGALRM, &sig_handler, NULL);
@@ -44,8 +44,8 @@
             switch (i) {
             case 0:
                 /* On the first iteration, pass the signal through */
-                sig = caught > 0 ? caught : SIGTERM;
-                if (caught == SIGALRM) {
+                sig = caught_sig > 0 ? caught_sig : SIGTERM;
+                if (caught_sig == SIGALRM) {
                    fprintf(stderr, "Timeout.. killing the process\n");
                 }
                 break;


added divide

added divide

--- tiny_csg.h
+++ tiny_csg.h
@@ -88,6 +88,18 @@
 tcsg_polygon_vector tcsg_union(tcsg_polygon_vector* i_a, tcsg_polygon_vector* i_b);
 tcsg_polygon_vector tcsg_intersect(tcsg_polygon_vector* i_a, tcsg_polygon_vector* i_b);
 tcsg_polygon_vector tcsg_subtract(tcsg_polygon_vector* i_a, tcsg_polygon_vector* i_b);
+void tcsg_split(const tcsg_plane* i_p, tcsg_polygon_vector* i_list, tcsg_polygon_vector* o_front, tcsg_polygon_vector* o_back);
+
+enum {
+    tcsg_k_py,
+    tcsg_k_ny,
+    tcsg_k_px,
+    tcsg_k_nx,
+    tcsg_k_pz,
+    tcsg_k_nz,
+    tcsg_k_div_max
+};
+void tcsg_divide(tcsg_polygon_vector* i_list, tcsg_polygon_vector* o_dirs[tcsg_k_div_max]);

 void tcsg_from_tris(tcsg_vert* i_verts, unsigned short* i_index, int i_tri_count, tcsg_user_data i_ud, tcsg_polygon_vector* o_v);
 tcsg_polygon_vector tcsg_cube(tcsg_user_data i_ud, const tcsg_f3* i_cntr, const tcsg_f3* i_rad);
@@ -487,6 +499,7 @@
 tcsg__bsp tcsg__build_bsp(tcsg_polygon_vector* i_list)
 {
     tcsg__bsp o = { 0 };
+    tcsg__sb_reserve(o.nodes, tcsg__sb_count(i_list->polys));
     tcsg__build_bsp_r(&o, i_list);
     return o;
 }
@@ -570,6 +583,53 @@
     tcsg_polygon_vector_free(&bia);

     return aob;
+}
+
+void tcsg_split(const tcsg_plane* i_p, tcsg_polygon_vector* i_list, tcsg_polygon_vector* o_front, tcsg_polygon_vector* o_back)
+{
+    tcsg_polygon_vector f = { 0 };
+    tcsg_polygon_vector b = { 0 };
+
+    if (!o_front) {
+        o_front = &f;
+    }
+    if (!o_back) {
+        o_back = &b;
+    }
+
+    tcsg__split(i_p, tcsg__sb_begin(i_list->polys), tcsg__sb_end(i_list->polys), i_list->max_vert_count, o_front, o_front, o_back, o_back);
+
+    if (o_front == &f) {
+        tcsg_polygon_vector_free(&f);
+    }
+    if (o_back == &b) {
+        tcsg_polygon_vector_free(&b);
+    }
+}
+
+void tcsg_divide(tcsg_polygon_vector* i_list, tcsg_polygon_vector* o_dirs[tcsg_k_div_max])
+{
+    const tcsg_f3 data[tcsg_k_div_max] = {
+        { 0, 1, 0 },
+        { 0, -1, 0 },
+        { 1, 0, 0 },
+        { -1, 0, 0 } ,
+        { 0, 0, 1 },
+        { 0, 0, -1 } ,
+    };
+    const float k_45deg = 0.4f;
+
+    for (tcsg_polygon** pi = tcsg__sb_begin(i_list->polys), **pe = tcsg__sb_end(i_list->polys); pi != pe; ++pi) {
+        for (int i = 0; i < tcsg_k_div_max; ++i) {
+            const float dp = tcsg_f3_dot(data + i, &(*pi)->plane.normal);
+            if (k_45deg < dp) {
+                if (o_dirs[i]) {
+                    tcsg_polygon_vector_pushback(o_dirs[i], *pi);
+                    break;
+                }
+            }
+        }
+    }
 }

 void tcsg_from_tris(tcsg_vert* i_verts, unsigned short* i_index, int i_tri_count, tcsg_user_data i_ud, tcsg_polygon_vector* o_v)
@@ -641,6 +701,26 @@
     tcsg_polygon_vector aIb = tcsg_intersect(&a, &b);
     tcsg_polygon_vector aSb = tcsg_subtract(&a, &b);

+    {
+        tcsg_polygon_vector _aUb = { 0 };
+        tcsg_polygon_vector _aIb = { 0 };
+        tcsg_polygon_vector _aSb = { 0 };
+
+        tcsg_polygon_vector* t[tcsg_k_div_max] = { 0 };
+        t[0] = &_aUb;
+        tcsg_divide(&aUb, t);
+
+        t[0] = &_aIb;
+        tcsg_divide(&aIb, t);
+
+        t[0] = &_aSb;
+        tcsg_divide(&aSb, t);
+
+        tcsg_polygon_vector_free(&_aUb);
+        tcsg_polygon_vector_free(&_aIb);
+        tcsg_polygon_vector_free(&_aSb);
+    }
+
     tcsg_polygon_vector_free(&a);
     tcsg_polygon_vector_free(&b);
     tcsg_polygon_vector_free(&aUb);


add missing checks.

add missing checks.

--- tuio2_in.c
+++ tuio2_in.c
@@ -631,9 +631,9 @@
 {
 	for(const method_t *meth = methods; meth->cb; meth++)
 	{
-		if(!meth->path || !strcmp(meth->path, path))
-		{
-			if(!meth->fmt || !strcmp(meth->fmt, fmt))
+		if(path && (!meth->path || !strcmp(meth->path, path)) )
+		{
+			if(fmt && (!meth->fmt || !strcmp(meth->fmt, fmt)) )
 			{
 				if(meth->cb(path, fmt, args, data))
 					break; // event handled, break


uhidtool: Add timestamp-debugger cmd hack

Signed-off-by: Andrew Andrianov <02e0a999c50b1f88df7a8f5a04e1b76b35ea6a88@ncrmnt.org>

--- uhidtool.c
+++ uhidtool.c
@@ -69,6 +69,7 @@
 	{"info",     	  no_argument,       0, 'i'},
 	{"run",      	  no_argument,       0, 'R'},
 	{"progress",      required_argument, 0, 'b'},
+    {"debug-timestamp",      	  no_argument,       0, '1'},
 	{0, 0, 0, 0}
 };

@@ -357,7 +358,19 @@
 			else if (strcmp(optarg, "none")==0)
 				uhidProgressCb(NULL);
 			break;
+		/* Debugging shit */
+		case '1':
+		{
+			while (1) {
+				uint64_t s = platform_get_timestamp();
+				printf("==> %" PRIu64 "\n", s);
+				while(platform_get_timestamp() - s < 1000)
+					usleep(100);
+			}
 		}
+		}
+
+
 	}
 	bailout(0);
 }


shm: Close buffer fds after mmap

shm: Close buffer fds after mmap

--- libswc/shm.c
+++ libswc/shm.c
@@ -33,6 +33,7 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <sys/mman.h>
+#include <unistd.h>
 #include <wayland-server.h>
 #include <wld/pixman.h>
 #include <wld/wld.h>
@@ -172,33 +173,34 @@

 	if (!(pool = malloc(sizeof *pool))) {
 		wl_resource_post_no_memory(resource);
-		return;
+		goto error0;
 	}

 	pool->resource = wl_resource_create(client, &wl_shm_pool_interface, wl_resource_get_version(resource), id);

 	if (!pool->resource) {
 		wl_resource_post_no_memory(resource);
-		goto error0;
+		goto error1;
 	}

 	wl_resource_set_implementation(pool->resource, &shm_pool_implementation, pool, &destroy_pool_resource);
 	pool->data = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
-
 	if (pool->data == MAP_FAILED) {
 		wl_resource_post_error(resource, WL_SHM_ERROR_INVALID_FD, "mmap failed: %s", strerror(errno));
-		goto error1;
-	}
-
+		goto error2;
+	}
+
+	close(fd);
 	pool->size = size;
 	pool->references = 1;
-
 	return;

+error2:
+	wl_resource_destroy(pool->resource);
 error1:
-	wl_resource_destroy(pool->resource);
+	free(pool);
 error0:
-	free(pool);
+	close(fd);
 }

 static struct wl_shm_interface shm_implementation = {


xkb: Use WARNING

xkb: Use WARNING

--- libswc/xkb.c
+++ libswc/xkb.c
@@ -112,7 +112,7 @@

     if (!keymap_string)
     {
-        printf("could not get XKB keymap as a string\n");
+        WARNING("Could not get XKB keymap as a string\n");
         goto error0;
     }

@@ -123,7 +123,7 @@

     if (xkb->keymap.fd == -1)
     {
-        printf("could not create XKB keymap file\n");
+        WARNING("Could not create XKB keymap file\n");
         goto error1;
     }

@@ -131,7 +131,7 @@

     if (posix_fallocate(xkb->keymap.fd, 0, xkb->keymap.size) != 0)
     {
-        printf("could not resize XKB keymap file\n");
+        WARNING("Could not resize XKB keymap file\n");
         goto error2;
     }

@@ -140,7 +140,7 @@

     if (xkb->keymap.area == MAP_FAILED)
     {
-        printf("could not mmap XKB keymap string\n");
+        WARNING("Could not mmap XKB keymap string\n");
         goto error2;
     }


Debug: Show now says that a method is builtin instead of line 0. Fixes #81.

Saying a method was from line zero was rather odd, because that could sound
somewhat impossible to a new user. So say that it's a builtin value, because
it is and that makes more sense.

--- lily_debug.c
+++ lily_debug.c
@@ -359,9 +359,13 @@
     show_sig(reg_info.sig, NULL);
     lily_impl_debugf(") %s register #%d", reg_type, reg_num);

-    if (reg_info.name != NULL)
-        lily_impl_debugf(" (%s from line %d)\n", reg_info.name,
-                         reg_info.line_num);
+    if (reg_info.name != NULL) {
+        if (reg_info.line_num != 0)
+            lily_impl_debugf(" (%s from line %d)\n", reg_info.name,
+                    reg_info.line_num);
+        else
+            lily_impl_debugf(" (builtin value %s)\n", reg_info.name);
+    }
     else
         lily_impl_debugf("\n");
 }
@@ -673,7 +677,12 @@
     lily_impl_debugf("Showing all methods:\n");
     while (var != NULL) {
         if (var->sig->cls->id == SYM_CLASS_METHOD) {
-            lily_impl_debugf("method %s @ line %d\n", var->name, var->line_num);
+            if (var->line_num != 0)
+                lily_impl_debugf("method %s @ line %d\n", var->name,
+                        var->line_num);
+            else
+                lily_impl_debugf("builtin method %s\n", var->name);
+
             show_code(lily_main->value.method, var->value.method, msgbuf, 0);
         }
         var = var->next;
@@ -689,8 +698,13 @@
     scope_str = is_global ? "global" : "local";

     lily_impl_debugf("Showing %s register #%d", scope_str, reg_id);
-    if (reg->name != NULL)
-        lily_impl_debugf(" (%s from line %d)\n", reg->name, reg->line_num);
+    if (reg->name != NULL) {
+        if (reg->line_num != 0)
+            lily_impl_debugf(" (%s from line %d)\n", reg->name,
+                    reg->line_num);
+        else
+            lily_impl_debugf(" (builtin value %s)\n", reg->name);
+    }
     else
         lily_impl_debugf("\n");


line-range: fix "blame -L X,-N" regression

"blame -L X,-N" is documented as blaming "N lines ending at X".  In
practice, the behavior is achieved by swapping the two range endpoints
if the second is less than the first.  25ed3412 (Refactor parse_loc;
2013-03-28) broke this interpretation by removing the swapping code from
blame.c and failing to add it to line-range.c along with other code
relocated from blame.c. Thus, such a range is effectively treated as
empty.  Fix this regression.

Signed-off-by: Eric Sunshine <8d6e34f987851aa599257d3831a1af040886842f@sunshineco.com>
Signed-off-by: Junio C Hamano <a6723cc3f76163bf7adb636a73ac3b0ceb3e6b9b@pobox.com>

--- line-range.c
+++ line-range.c
@@ -211,6 +211,8 @@
 		    void *cb_data, long lines, long *begin, long *end,
 		    const char *path)
 {
+	*begin = *end = 0;
+
 	if (*arg == ':') {
 		arg = parse_range_funcname(arg, nth_line_cb, cb_data, lines, begin, end, path);
 		if (!arg || *arg)
@@ -226,6 +228,11 @@
 	if (*arg)
 		return -1;

+	if (*begin && *end && *end < *begin) {
+		long tmp;
+		tmp = *end; *end = *begin; *begin = tmp;
+	}
+
 	return 0;
 }


Disable RFM95 for now

Disable RFM95 for now

--- Mk3/stm32/lora_sensor/Src/main.c
+++ Mk3/stm32/lora_sensor/Src/main.c
@@ -82,12 +82,10 @@

     uint8_t count = 0;

-    uint8_t reg_val = 0;
-
     /* SPI chip select high */
     HAL_GPIO_WritePin(GPIOB, SPI2_CS_Pin, GPIO_PIN_SET);
     HAL_Delay(30);
-    RFM95_init(&hspi2);
+    //RFM95_init(&hspi2);

     uint8_t payload_buff[14];
     PAYLOAD_Garden payload_garden;
@@ -116,10 +114,6 @@
             HAL_UART_Transmit(&huart1, (uint8_t*) tx1_buffer,
                     strlen(tx1_buffer), 5000);

-//            reg_val = RFM95_readRegister(&hspi2, RFM95_REG_OP_MODE);
-//            sprintf(tx1_buffer, "Reg val: %02X\n", reg_val);
-//            HAL_UART_Transmit(&huart1, (uint8_t*) tx1_buffer,
-//                    strlen(tx1_buffer), 5000);

             HAL_GPIO_WritePin(GPIOA, LED_Pin, GPIO_PIN_SET);
             sprintf(tx1_buffer, "Count is %d\n", count);
@@ -130,14 +124,14 @@
             payload_garden.MessageId = count;
             PAYLOAD_Garden_serialize(payload_garden, payload_buff);

-            RFM95_send(&hspi2, payload_buff, 14);
+            //RFM95_send(&hspi2, payload_buff, 14);

             state = MAIN_STATE_TX;
         }

         /* Do nothing while the transmission is in progress */
         else if (state == MAIN_STATE_TX && dio0_action == 1) {
-            RFM95_setMode(&hspi2, RFM95_MODE_SLEEP);
+            //RFM95_setMode(&hspi2, RFM95_MODE_SLEEP);

             state = MAIN_STATE_SLEEP;
         }


scroll-view: Connect to the correct property names

MxScrollView connects to 'notify::hadjustment' and 'notify::vadjustment'
instead of 'notify::horizontal-adjustment' and
'notify::vertical-adjustment', respectively.

Fixes: http://bugzilla.meego.com/show_bug.cgi?id=1198

--- mx/mx-scroll-view.c
+++ mx/mx-scroll-view.c
@@ -770,10 +770,10 @@
       mx_scroll_view_parent_iface->add (container, actor);

       /* Get adjustments for scroll-bars */
-      g_signal_connect (actor, "notify::hadjustment",
+      g_signal_connect (actor, "notify::horizontal-adjustment",
                         G_CALLBACK (child_hadjustment_notify_cb),
                         container);
-      g_signal_connect (actor, "notify::vadjustment",
+      g_signal_connect (actor, "notify::vertical-adjustment",
                         G_CALLBACK (child_vadjustment_notify_cb),
                         container);
       child_hadjustment_notify_cb (G_OBJECT (actor), NULL, container);


Fix the library link adding.

Fix the library link adding.

--- myrbuild/myrbuild.c
+++ myrbuild/myrbuild.c
@@ -42,6 +42,7 @@
 char *sysname;

 regex_t usepat;
+Htab *compiled;

 static void usage(char *prog)
 {
@@ -188,19 +189,18 @@
     size_t i, ndeps;
     char **cmd;
     size_t ncmd;
+    char *s;
     char *localdep;
     char *deps[512];
     char use[1024];
     char obj[1024];
     char *extra[] = {"-g", "-o", "" /* filename */};

+    if (hthas(compiled, file))
+        return;
     if (hassuffix(file, ".myr")) {
         swapsuffix(use, sizeof use, file, ".myr", ".use");
         swapsuffix(obj, sizeof obj, file, ".myr", ".o");
-        if (isfresh(file, use))
-            return;
-        if (isfresh(file, obj))
-            return;
         getdeps(file, deps, 512, &ndeps);
         for (i = 0; i < ndeps; i++) {
             if (isquoted(deps[i])) {
@@ -211,6 +211,10 @@
                 lappend(&libs, &nlibs, deps[i]);
             }
         }
+        if (isfresh(file, use))
+            return;
+        if (isfresh(file, obj))
+            return;
         gencmd(&cmd, &ncmd, muse, file, NULL, 0);
         run(cmd);

@@ -224,6 +228,8 @@
         gencmd(&cmd, &ncmd, as, file, extra, 3);
         run(cmd);
     }
+    s = strdup(file);
+    htput(compiled, s, s);
 }

 void mergeuse(char **files, size_t nfiles)
@@ -383,6 +389,7 @@
     if (libname && binname)
         die("Can't specify both library and binary names");

+    compiled = mkht(strhash, streq);
     regcomp(&usepat, "^[[:space:]]*use[[:space:]]+([^[:space:]]+)", REG_EXTENDED);
     for (i = optind; i < argc; i++)
         compile(argv[i]);