output class value in svg files

output class value in svg files

--- plugin/core/gvrender_core_svg.c
+++ plugin/core/gvrender_core_svg.c
@@ -208,9 +208,17 @@
 static void svg_begin_layer(GVJ_t * job, char *layername, int layerNum,
 			    int numLayers)
 {
+    obj_state_t *obj = job->obj;
+    char *str;
+
     gvputs(job, "<g id=\"");
     gvputs(job, xml_string(layername));
-    gvputs(job, "\" class=\"layer\">\n");
+    gvputs(job, "\" class=\"layer");
+    if ((str = agget(obj->u.n, "class"))) {
+	gvputs(job, " ");
+	gvputs(job, xml_string(str));
+    }
+    gvputs(job, "\">\n");
 }

 static void svg_end_layer(GVJ_t * job)
@@ -225,14 +233,19 @@
 static void svg_begin_page(GVJ_t * job)
 {
     obj_state_t *obj = job->obj;
+    char *str;

     /* its really just a page of the graph, but its still a graph,
      * and it is the entire graph if we're not currently paging */
     gvputs(job, "<g id=\"");
     gvputs(job, xml_string(obj->id));
-    gvputs(job, "\" class=\"graph\"");
+    gvputs(job, "\" class=\"graph");
+    if ((str = agget(obj->u.n, "class"))) {
+        gvputs(job, " ");
+        gvputs(job, xml_string(str));
+    }
     gvprintf(job,
-	     " transform=\"scale(%g %g) rotate(%d) translate(%g %g)\">\n",
+	     "\" transform=\"scale(%g %g) rotate(%d) translate(%g %g)\">\n",
 	     job->scale.x, job->scale.y, -job->rotation,
 	     job->translation.x, -job->translation.y);
     /* default style */
@@ -251,10 +264,16 @@
 static void svg_begin_cluster(GVJ_t * job)
 {
     obj_state_t *obj = job->obj;
+    char *str;

     gvputs(job, "<g id=\"");
     gvputs(job, xml_string(obj->id));
-    gvputs(job, "\" class=\"cluster\">");
+    gvputs(job, "\" class=\"cluster");
+    if ((str = agget(obj->u.n, "class"))) {
+        gvputs(job, " ");
+        gvputs(job, xml_string(str));
+    }
+    gvputs(job, "\">\n");
     gvputs(job, "<title>");
     gvputs(job, xml_string(agnameof(obj->u.g)));
     gvputs(job, "</title>\n");
@@ -268,12 +287,18 @@
 static void svg_begin_node(GVJ_t * job)
 {
     obj_state_t *obj = job->obj;
+    char *str;

     gvputs(job, "<g id=\"");
     gvputs(job, xml_string(obj->id));
     if (job->layerNum > 1)
 	gvprintf (job, "_%s", xml_string(job->gvc->layerIDs[job->layerNum]));
-    gvputs(job, "\" class=\"node\">");
+    gvputs(job, "\" class=\"node");
+    if ((str = agget(obj->u.n, "class"))) {
+        gvputs(job, " ");
+        gvputs(job, xml_string(str));
+    }
+    gvputs(job, "\">\n");
     gvputs(job, "<title>");
     gvputs(job, xml_string(agnameof(obj->u.n)));
     gvputs(job, "</title>\n");
@@ -288,10 +313,16 @@
 {
     obj_state_t *obj = job->obj;
     char *ename;
+    char *str;

     gvputs(job, "<g id=\"");
     gvputs(job, xml_string(obj->id));
-    gvputs(job, "\" class=\"edge\">");
+    gvputs(job, "\" class=\"edge");
+    if ((str = agget(obj->u.n, "class"))) {
+        gvputs(job, " ");
+        gvputs(job, xml_string(str));
+    }
+    gvputs(job, "\">\n");

     gvputs(job, "<title>");
     ename = strdup_and_subst_obj("\\E", (void *) (obj->u.e));


arm: _FaultShow: fix typo MMFSR -> UFSR

arm: _FaultShow: fix typo MMFSR -> UFSR

The right param should be SCB_UFSR not SCB_MMFSR

Signed-off-by: qianfan Zhao <0d01fab1932da5a147025f14dd5829cf5bf10d4d@163.com>

--- arch/arm/core/fault.c
+++ arch/arm/core/fault.c
@@ -141,7 +141,7 @@

 #if defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
 	PR_EXC("MMFSR: 0x%x, BFSR: 0x%x, UFSR: 0x%x\n",
-	       SCB_MMFSR, SCB_BFSR, SCB_MMFSR);
+	       SCB_MMFSR, SCB_BFSR, SCB_UFSR);
 #if defined(CONFIG_ARM_SECURE_FIRMWARE)
 	PR_EXC("SFSR: 0x%x\n", SAU->SFSR);
 #endif /* CONFIG_ARM_SECURE_FIRMWARE */


mdraid: Fix g_strsplit() leaks

mdraid: Fix g_strsplit() leaks

--- src/plugins/mdraid.c
+++ src/plugins/mdraid.c
@@ -255,10 +255,15 @@
                     /* mdadm --examine output for a set being migrated */
                     vals = g_strsplit (key_val[1], "<--", 2);
                     g_hash_table_insert (table, g_strstrip (key_val[0]), g_strstrip (vals[0]));
+                    g_free (key_val[1]);
                     g_free (vals[1]);
+                    g_free (vals);
                 } else {
                     g_hash_table_insert (table, g_strstrip (key_val[0]), g_strstrip (key_val[1]));
                 }
+                g_free (key_val);
+            } else {
+                g_strfreev (key_val);
             }
             (*num_items)++;
         } else


Adjust gsb error msg

Adjust gsb error msg

--- apache2/re_operators.c
+++ apache2/re_operators.c
@@ -1127,6 +1127,10 @@

                 if(ret > 0) {
                     set_match_to_tx(msr, capture, match);
+                    if (! *error_msg) {
+                        *error_msg = apr_psprintf(msr->mp, "Gsb lookup for \"%s\" succeeded.",
+                                log_escape_nq(msr->mp, match));
+                    }
                     return 1;
                 }

@@ -1145,6 +1149,10 @@

                         if(ret > 0) {
                             set_match_to_tx(msr, capture, canon);
+                            if (! *error_msg) {
+                                *error_msg = apr_psprintf(msr->mp, "Gsb lookup for \"%s\" succeeded.",
+                                        log_escape_nq(msr->mp, canon));
+                            }
                             return 1;
                         }
                     }
@@ -1172,6 +1180,10 @@

                             if(ret > 0) {
                                 set_match_to_tx(msr, capture, canon);
+                                if (! *error_msg) {
+                                    *error_msg = apr_psprintf(msr->mp, "Gsb lookup for \"%s\" succeeded.",
+                                            log_escape_nq(msr->mp, canon));
+                                }
                                 return 1;
                             }
                         }
@@ -1985,7 +1997,7 @@

         /* This message will be logged. */
         *error_msg = apr_psprintf(msr->mp, "CC# match \"%s\" at %s. [offset \"%d\"]",
-            regex->pattern, var->name, offset);
+                regex->pattern, var->name, offset);

         return 1;
     }


btshell: Fix bogus error message on connect

--- apps/btshell/src/cmd.c
+++ apps/btshell/src/cmd.c
@@ -823,7 +823,9 @@
     if (ext == 0x00) {
         rc = btshell_conn_initiate(own_addr_type, peer_addr_param, duration_ms,
                                    &phy_1M_params);
-        console_printf("error connecting; rc=%d\n", rc);
+        if (rc) {
+            console_printf("error connecting; rc=%d\n", rc);
+        }
         return rc;
     }

@@ -831,7 +833,9 @@
         rc = btshell_ext_conn_initiate(own_addr_type, peer_addr_param,
                                        duration_ms, &phy_1M_params,
                                        NULL, NULL);
-        console_printf("error connecting; rc=%d\n", rc);
+        if (rc) {
+            console_printf("error connecting; rc=%d\n", rc);
+        }
         return rc;
     }


Add missing include exposed by recent commits

--- libswc/shell_surface.c
+++ libswc/shell_surface.c
@@ -24,6 +24,7 @@
 #include "swc.h"
 #include "compositor_surface.h"
 #include "shell_surface.h"
+#include "util.h"
 #include "window.h"

 #include <stdlib.h>


ARM: 7819/1: fiq: Cast the first argument of flush_icache_range()

Commit 2ba85e7af4 (ARM: Fix FIQ code on VIVT CPUs) causes the following build warning:

arch/arm/kernel/fiq.c:92:3: warning: passing argument 1 of 'cpu_cache.coherent_kern_range' makes integer from pointer without a cast [enabled by default]

Cast it as '(unsigned long)base' to avoid the warning.

Signed-off-by: Fabio Estevam <679188261afeb60eb822cd934fd7b46a48ddd743@freescale.com>
Signed-off-by: Russell King <f6aa0246ff943bfa8602cdf60d40c481b38ed232@arm.linux.org.uk>


gabble_presence_cache_set_property: simplify construct-only 'connection'

There's no point in defending against already having presence_handles;
because connection is construct-only, it can only be set once.

--- src/presence-cache.c
+++ src/presence-cache.c
@@ -491,26 +491,15 @@
   GabblePresenceCache *cache = GABBLE_PRESENCE_CACHE (object);
   GabblePresenceCachePrivate *priv = GABBLE_PRESENCE_CACHE_PRIV (cache);
   TpHandleRepoIface *contact_repo;
-  TpHandleSet *new_presence_handles;

   switch (property_id) {
     case PROP_CONNECTION:
+      g_assert (priv->conn == NULL);              /* construct-only */
+      g_assert (priv->presence_handles == NULL);  /* construct-only */
       priv->conn = g_value_get_object (value);
       contact_repo = tp_base_connection_get_handles (
           (TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
-
-      new_presence_handles = tp_handle_set_new (contact_repo);
-
-      if (priv->presence_handles)
-        {
-          const TpIntSet *add;
-          TpIntSet *tmp;
-          add = tp_handle_set_peek (priv->presence_handles);
-          tmp = tp_handle_set_update (new_presence_handles, add);
-          tp_handle_set_destroy (priv->presence_handles);
-          tp_intset_destroy (tmp);
-        }
-      priv->presence_handles = new_presence_handles;
+      priv->presence_handles = tp_handle_set_new (contact_repo);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);


ARM: 8133/1: use irq_set_affinity with force=false when migrating irqs

Since commit 1dbfa187dad ("ARM: irq migration: force migration off CPU
going down") the ARM interrupt migration code on cpu offline calls
irqchip.irq_set_affinity() with the argument force=true. At the point
of this change the argument had no effect because it was not used by
any interrupt chip driver and there was no semantics defined.

This changed with commit 01f8fa4f01d8 ("genirq: Allow forcing cpu
affinity of interrupts") which made the force argument useful to route
interrupts to not yet online cpus without checking the target cpu
against the cpu online mask. The following commit ffde1de64012
("irqchip: gic: Support forced affinity setting") implemented this for
the GIC interrupt controller.

As a consequence the ARM cpu offline irq migration fails if CPU0 is
offlined, because CPU0 is still set in the affinity mask and the
validataion against cpu online mask is skipped to the force argument
being true. The following first_cpu(mask) selection always selects
CPU0 as the target.

Solve the issue by calling irq_set_affinity() with force=false from
the CPU offline irq migration code so the GIC driver validates the
affinity mask against CPU online mask and therefore removes CPU0 from
the possible target candidates.

Tested on TC2 hotpluging CPU0 in and out. Without this patch the system
locks up as the IRQs are not migrated away from CPU0.

Signed-off-by: Sudeep Holla <2f8b50d4d9838571c9f6955972f29e9e41079295@arm.com>
Acked-by: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>
Acked-by: Mark Rutland <1db9dd262beaa64f35756dd39531d9747b7778bb@arm.com>
Cc: <4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@vger.kernel.org> # 3.10.x
Signed-off-by: Russell King <f6aa0246ff943bfa8602cdf60d40c481b38ed232@arm.linux.org.uk>


fix ushort save with values >32k

fix ushort save with values >32k

we were not setting the fits offset correctly for ushort images, thanks
weaverwb

--- libvips/foreign/fits.c
+++ libvips/foreign/fits.c
@@ -21,6 +21,8 @@
  * 	- bandsplit for write
  * 13/12/11
  * 	- redo as a set of fns ready for wrapping in a new-style class
+ * 23/6/13
+ * 	- fix ushort save with values >32k, thanks weaverwb
  */

 /*
@@ -191,8 +193,10 @@
  */
 static int fits2vips_formats[][3] = {
 	{ BYTE_IMG, VIPS_FORMAT_UCHAR, TBYTE },
-	{ SHORT_IMG,  VIPS_FORMAT_USHORT, TUSHORT },
-	{ LONG_IMG,  VIPS_FORMAT_UINT, TUINT },
+	{ SHORT_IMG,  VIPS_FORMAT_SHORT, TSHORT },
+	{ USHORT_IMG,  VIPS_FORMAT_USHORT, TUSHORT },
+	{ LONG_IMG,  VIPS_FORMAT_INT, TINT },
+	{ ULONG_IMG,  VIPS_FORMAT_UINT, TUINT },
 	{ FLOAT_IMG,  VIPS_FORMAT_FLOAT, TFLOAT },
 	{ DOUBLE_IMG, VIPS_FORMAT_DOUBLE, TDOUBLE }
 };


fix bug in priority_queue: wrong sink methond

--- src/priority_queue.c
+++ src/priority_queue.c
@@ -1,3 +1,9 @@
+
+/*
+ * Copyright (C) Zhu Jiashun
+ * Copyright (C) Zaver
+ */
+
 #include "priority_queue.h"

 int zv_pq_init(zv_pq_t *zv_pq, zv_pq_comparator_pt comp, size_t size) {
@@ -68,7 +74,7 @@

     while (2*k <= nalloc) {
         j = 2*k;
-        if (j < nalloc && zv_pq->comp(zv_pq->pq[j], zv_pq->pq[j+1])) j++;
+        if (j < nalloc && zv_pq->comp(zv_pq->pq[j+1], zv_pq->pq[j])) j++;
         if (!zv_pq->comp(zv_pq->pq[j], zv_pq->pq[k])) break;
         exch(zv_pq, j, k);
         k = j;


arm: msm: add oprofile pmu support

arm: msm: add oprofile pmu support

add oprofile pmu support for msm.

Signed-off-by: Daniel Walker <664f14bf9af4dadf8666a74e4a7425b312868d0d@codeaurora.org>

--- arch/arm/kernel/pmu.c
+++ arch/arm/kernel/pmu.c
@@ -44,6 +44,8 @@
 	IRQ_IOP33X_CORE_PMU,
 #elif defined(CONFIG_ARCH_PXA)
 	IRQ_PMU,
+#elif defined(CONFIG_ARCH_MSM_ARM11)
+	INT_ARM11_PMU,
 #endif
 };


oops in ref_string_get

oops in ref_string_get

duh typo

--- libvips/iofuncs/type.c
+++ libvips/iofuncs/type.c
@@ -518,8 +518,6 @@
 vips_ref_string_get( VipsRefString *refstr, size_t *length )
 {
 	VipsArea *area = VIPS_AREA( refstr );
-
-	g_assert( area->type == G_TYPE_DOUBLE );

 	return( vips_area_get_data( area, length, NULL, NULL, NULL ) );
 }


ARM: 6984/1: enhance TCM robustness

ARM: 6984/1: enhance TCM robustness

The PB11MPCore reports "3" DTCM banks, but anything above 2 is an
"undefined" value, so push this to become 0. Further add some checks
if code is compiled to TCM even if there is no D/ITCM present in the
system, and if we can really fit the compiled code. We don't do the
BUG() since it's not helpful, it's better to deal with non-present
TCM dynamically. If there is nothing compiled to the TCM and no TCM
is detected, it will now just shut up even if TCM support is enabled.

Signed-off-by: Linus Walleij <9cd9d802d23c0ed5e224beabf4ae4a5c478746ef@linaro.org>
Signed-off-by: Russell King <f6aa0246ff943bfa8602cdf60d40c481b38ed232@arm.linux.org.uk>

--- arch/arm/kernel/tcm.c
+++ arch/arm/kernel/tcm.c
@@ -134,6 +134,10 @@
 			(tcm_region & 1) ? "" : "not ");
 	}

+	/* Not much fun you can do with a size 0 bank */
+	if (tcm_size == 0)
+		return 0;
+
 	/* Force move the TCM bank to where we want it, enable */
 	tcm_region = *offset | (tcm_region & 0x00000ffeU) | 1;

@@ -165,11 +169,19 @@
 	u32 tcm_status = read_cpuid_tcmstatus();
 	u8 dtcm_banks = (tcm_status >> 16) & 0x03;
 	u8 itcm_banks = (tcm_status & 0x03);
+	size_t dtcm_code_sz = &__edtcm_data - &__sdtcm_data;
+	size_t itcm_code_sz = &__eitcm_text - &__sitcm_text;
 	char *start;
 	char *end;
 	char *ram;
 	int ret;
 	int i;
+
+	/* Values greater than 2 for D/ITCM banks are "reserved" */
+	if (dtcm_banks > 2)
+		dtcm_banks = 0;
+	if (itcm_banks > 2)
+		itcm_banks = 0;

 	/* Setup DTCM if present */
 	if (dtcm_banks > 0) {
@@ -177,6 +189,13 @@
 			ret = setup_tcm_bank(0, i, dtcm_banks, &dtcm_end);
 			if (ret)
 				return;
+		}
+		/* This means you compiled more code than fits into DTCM */
+		if (dtcm_code_sz > (dtcm_end - DTCM_OFFSET)) {
+			pr_info("CPU DTCM: %u bytes of code compiled to "
+				"DTCM but only %lu bytes of DTCM present\n",
+				dtcm_code_sz, (dtcm_end - DTCM_OFFSET));
+			goto no_dtcm;
 		}
 		dtcm_res.end = dtcm_end - 1;
 		request_resource(&iomem_resource, &dtcm_res);
@@ -186,18 +205,28 @@
 		start = &__sdtcm_data;
 		end   = &__edtcm_data;
 		ram   = &__dtcm_start;
-		/* This means you compiled more code than fits into DTCM */
-		BUG_ON((end - start) > (dtcm_end - DTCM_OFFSET));
-		memcpy(start, ram, (end-start));
-		pr_debug("CPU DTCM: copied data from %p - %p\n", start, end);
-	}
-
+		memcpy(start, ram, dtcm_code_sz);
+		pr_debug("CPU DTCM: copied data from %p - %p\n",
+			 start, end);
+	} else if (dtcm_code_sz) {
+		pr_info("CPU DTCM: %u bytes of code compiled to DTCM but no "
+			"DTCM banks present in CPU\n", dtcm_code_sz);
+	}
+
+no_dtcm:
 	/* Setup ITCM if present */
 	if (itcm_banks > 0) {
 		for (i = 0; i < itcm_banks; i++) {
 			ret = setup_tcm_bank(1, i, itcm_banks, &itcm_end);
 			if (ret)
 				return;
+		}
+		/* This means you compiled more code than fits into ITCM */
+		if (itcm_code_sz > (itcm_end - ITCM_OFFSET)) {
+			pr_info("CPU ITCM: %u bytes of code compiled to "
+				"ITCM but only %lu bytes of ITCM present\n",
+				itcm_code_sz, (itcm_end - ITCM_OFFSET));
+			return;
 		}
 		itcm_res.end = itcm_end - 1;
 		request_resource(&iomem_resource, &itcm_res);
@@ -207,10 +236,12 @@
 		start = &__sitcm_text;
 		end   = &__eitcm_text;
 		ram   = &__itcm_start;
-		/* This means you compiled more code than fits into ITCM */
-		BUG_ON((end - start) > (itcm_end - ITCM_OFFSET));
-		memcpy(start, ram, (end-start));
-		pr_debug("CPU ITCM: copied code from %p - %p\n", start, end);
+		memcpy(start, ram, itcm_code_sz);
+		pr_debug("CPU ITCM: copied code from %p - %p\n",
+			 start, end);
+	} else if (itcm_code_sz) {
+		pr_info("CPU ITCM: %u bytes of code compiled to ITCM but no "
+			"ITCM banks present in CPU\n", itcm_code_sz);
 	}
 }


better flushing/purging of removed/changed mappings, hack around the pv/vp desync

--- arch/hppa/hppa/pmap.c
+++ arch/hppa/hppa/pmap.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: pmap.c,v 1.55 2002/02/04 18:13:05 mickey Exp $	*/
+/*	$OpenBSD: pmap.c,v 1.56 2002/02/06 19:29:06 mickey Exp $	*/

 /*
  * Copyright (c) 1998-2001 Michael Shalayeff
@@ -377,6 +377,8 @@
 #endif
 	pvp->pvp_freelist = pv->pv_next;
 	pv->pv_next = NULL;
+	pv->pv_hash = NULL;
+	pv->pv_pmap = NULL;

 	return pv;
 }
@@ -453,8 +455,12 @@
 		DPRINTF(PDB_ENTER, ("pmap_enter_pv: adding to the list\n"));
 #ifdef PMAPDEBUG
 		for (npv = pv; npv; npv = npv->pv_next)
-			if (pmap == npv->pv_pmap && va == npv->pv_va)
-				panic("pmap_enter_pv: already in pv_tab");
+			if (pmap == npv->pv_pmap && va == npv->pv_va) {
+				printf("pmap_enter_pv: %p already in pv_tab",
+				    npv);
+				pmap_enter_va(npv); /* HACK UGLY HACK HACK */
+				return (npv);
+			}
 #endif
 		hpv = pv;
 		npv = pv->pv_next;
@@ -503,8 +509,8 @@
 		ppv = pv->pv_next;
 		pmap_remove_va(pv);
 		if (ppv) {
-			/*npv->pv_tlbprot |= pv->pv_tlbprot &
-			    (TLB_DIRTY | TLB_REF);*/
+			ppv->pv_tlbprot |= pv->pv_tlbprot &
+			    (TLB_DIRTY | TLB_REF);
 			*pv = *ppv;
 			pmap_free_pv(ppv);
 		} else
@@ -514,6 +520,8 @@
 			;

 		if (pv) {
+			pv->pv_tlbprot |= ppv->pv_tlbprot &
+			    (TLB_DIRTY | TLB_REF);
 			pv->pv_next = ppv->pv_next;
 			pmap_remove_va(ppv);
 			pmap_free_pv(ppv);
@@ -1098,15 +1106,16 @@
 				pv->pv_tlbprot &= ~TLB_AR_MASK;
 				pv->pv_tlbprot |= tlbprot;

-				pmap_clear_va(pv->pv_space, pv->pv_va);
-
 				/*
 				 * Purge the current TLB entry (if any)
 				 * to force a fault and reload with the
 				 * new protection.
 				 */
+				ficache(pv->pv_space, pv->pv_va, NBPG);
+				pitlb(pv->pv_space, pv->pv_va);
+				fdcache(pv->pv_space, pv->pv_va, NBPG);
 				pdtlb(pv->pv_space, pv->pv_va);
-				pitlb(pv->pv_space, pv->pv_va);
+				pmap_clear_va(pv->pv_space, pv->pv_va);
 			}
 		}
 		splx(s);
@@ -1175,14 +1184,15 @@
 			pv->pv_tlbprot &= ~TLB_AR_MASK;
 			pv->pv_tlbprot |= tlbprot;

-			pmap_clear_va(space, pv->pv_va);
-
 			/*
 			 * Purge the current TLB entry (if any) to force
 			 * a fault and reload with the new protection.
 			 */
-			pitlb(space, pv->pv_va);
-			pdtlb(space, pv->pv_va);
+			ficache(space, sva, NBPG);
+			pitlb(space, sva);
+			fdcache(space, sva, NBPG);
+			pdtlb(space, sva);
+			pmap_clear_va(space, sva);
 		}
 	}
 }
@@ -1503,10 +1513,8 @@
 		pv->pv_pmap = pmap_kernel();
 		pv->pv_space = HPPA_SID_KERNEL;
 		pv->pv_tlbpage = tlbbtop(pa);
-		pv->pv_tlbprot = HPPA_PID_KERNEL |
+		pv->pv_tlbprot = HPPA_PID_KERNEL | TLB_WIRED |
 		    pmap_prot(pmap_kernel(), prot) |
-		    TLB_WIRED | /* TLB_REF | TLB_DIRTY | */
-		    TLB_UNCACHEABLE |
 		    ((pa & HPPA_IOSPACE) == HPPA_IOSPACE? TLB_UNCACHEABLE : 0);
 		pmap_enter_va(pv);
 	}


added condition if its just an 'if' statement

--- src/eval-apply.c
+++ src/eval-apply.c
@@ -66,10 +66,14 @@

 object *make_if(object *predicate, object *consequent,
                 object *alternative) {
+    object *end = the_empty_list;
+    if(alternative->obj_type != EMPTY_LIST){
+      end = cons(alternative, the_empty_list);
+    }
     return cons(if_symbol,
                 cons(predicate,
                      cons(consequent,
-                          cons(alternative, the_empty_list))));
+                          end)));
 }

 char is_if(object *expression) {


make hptdump take a space arg and print only entried for that space, all on -1

--- arch/hppa/hppa/pmap.c
+++ arch/hppa/hppa/pmap.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: pmap.c,v 1.54 2002/02/03 01:58:13 mickey Exp $	*/
+/*	$OpenBSD: pmap.c,v 1.55 2002/02/04 18:13:05 mickey Exp $	*/

 /*
  * Copyright (c) 1998-2001 Michael Shalayeff
@@ -204,7 +204,7 @@
 u_int pv_nfree;

 #ifdef PMAPDEBUG
-void pmap_hptdump __P((void));
+void pmap_hptdump __P((int sp));
 #endif

 u_int	kern_prot[8], user_prot[8];
@@ -1538,27 +1538,35 @@
  * prints whole va->pa (aka HPT or HVT)
  */
 void
-pmap_hptdump()
+pmap_hptdump(sp)
+	int sp;
 {
 	register struct hpt_entry *hpt, *ehpt;
 	register struct pv_entry *pv;
+	register int hpthf;

 	mfctl(CR_HPTMASK, ehpt);
 	mfctl(CR_VTOP, hpt);
 	ehpt = (struct hpt_entry *)((int)hpt + (int)ehpt + 1);
 	db_printf("HPT dump %p-%p:\n", hpt, ehpt);
-	for (; hpt < ehpt; hpt++)
-		if (hpt->hpt_valid || hpt->hpt_entry) {
-			db_printf("hpt@%p: %x{%sv=%x:%x},%b,%x\n",
-			    hpt, *(int *)hpt, (hpt->hpt_valid?"ok,":""),
-			    hpt->hpt_space, hpt->hpt_vpn << 9,
-			    hpt->hpt_tlbprot, TLB_BITS,
-			    tlbptob(hpt->hpt_tlbpage));
-			for (pv = hpt->hpt_entry; pv; pv = pv->pv_hash)
+	for (hpthf = 0; hpt < ehpt; hpt++, hpthf = 0)
+		for (pv = hpt->hpt_entry; pv; pv = pv->pv_hash)
+			if (sp < 0 || sp == pv->pv_space) {
+				if (!hpthf) {
+					db_printf(
+					    "hpt@%p: %x{%sv=%x:%x},%b,%x\n",
+					    hpt, *(u_int *)hpt,
+					    (hpt->hpt_valid?"ok,":""),
+					    hpt->hpt_space, hpt->hpt_vpn << 9,
+					    hpt->hpt_tlbprot, TLB_BITS,
+					    tlbptob(hpt->hpt_tlbpage));
+
+					hpthf++;
+				}
 				db_printf("    pv={%p,%x:%x,%b,%x}->%p\n",
 				    pv->pv_pmap, pv->pv_space, pv->pv_va,
 				    pv->pv_tlbprot, TLB_BITS,
 				    tlbptob(pv->pv_tlbpage), pv->pv_hash);
-		}
-}
-#endif
+			}
+}
+#endif


minor change

minor change

Signed-off-by: Jens Nyberg <7200009990a46d4bb36e24284136c70d739d75fd@gmail.com>

--- src/kernel/x86/arch.c
+++ src/kernel/x86/arch.c
@@ -9,7 +9,7 @@
 #include "mmu.h"

 #define CONTAINERS                      16
-#define TASKS                           64
+#define TASKS                           128
 #define GDTDESCRIPTORS                  6
 #define IDTDESCRIPTORS                  256
 #define TSSDESCRIPTORS                  1


no SEGV, if :main is defined with more than 1 param

git-svn-id: 6e74a02f85675cec270f5d931b0f6998666294a3@12870 d31e2699-5ff4-0310-a27c-f18f2fbe73fe

--- src/exceptions.c
+++ src/exceptions.c
@@ -698,6 +698,14 @@
     /*
      * FIXME classify errors
      */
+    if (!the_exception) {
+	PIO_eprintf(interpreter,
+                "real_exception (severity:%d error:%d): %Ss\n"
+                "likely reason: argument count mismatch in main "
+                "(more than 1 param)\n",
+	    EXCEPT_error, exitcode, msg );
+        exit(exitcode);
+    }
     the_exception->severity = EXCEPT_error;
     the_exception->error = exitcode;
     the_exception->msg = msg;


Improve the AES acceleration, by allocating a contiguous DMA-able
buffer on attach, and using it for encrypt/decrypt operations.  Still
disabled, since the driver cannot currently handle an operation larger
than supported by this buffer.  (Interactive ssh does work with this
code, however.)

"commit, of course" deraadt@

--- arch/i386/pci/glxsb.c
+++ arch/i386/pci/glxsb.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: glxsb.c,v 1.2 2006/11/17 16:06:16 tom Exp $	*/
+/*	$OpenBSD: glxsb.c,v 1.3 2006/11/19 02:08:10 tom Exp $	*/

 /*
  * Copyright (c) 2006 Tom Cosgrove <tom@openbsd.org>
@@ -39,7 +39,7 @@
 #include <dev/pci/pcivar.h>
 #include <dev/pci/pcidevs.h>

-#undef CRYPTO
+#undef CRYPTO			/* XXX AES support not yet ready XXX */
 #ifdef CRYPTO
 #include <crypto/cryptodev.h>
 #include <crypto/rijndael.h>
@@ -123,7 +123,29 @@

 #define SB_MEM_SIZE		0x0810		/* Size of memory block */

+#define SB_AES_ALIGN		0x0010		/* Source and dest buffers */
+						/* must be 16-byte aligned */
+
+/*
+ * The Geode LX security block AES acceleration doesn't perform scatter-
+ * gather: it just takes source and destination addresses.  Therefore the
+ * plain- and ciphertexts need to be contiguous.  To this end, we allocate
+ * a buffer for both, and accept the overhead of copying in and out.  If
+ * the number of bytes in one operation is bigger than allowed for by the
+ * buffer (buffer is twice the size of the max length, as it has both input
+ * and output) then we have to perform multiple encryptions/decryptions.
+ */
+#define GLXSB_MAX_AES_LEN	8192
+
 #ifdef CRYPTO
+struct glxsb_dma_map {
+	bus_dmamap_t		dma_map;
+	bus_dma_segment_t	dma_seg;
+	int			dma_nsegs;
+	int			dma_size;
+	caddr_t			dma_vaddr;
+	uint32_t		dma_paddr;
+};
 struct glxsb_session {
 	uint32_t	ses_key[4];
 	uint8_t		ses_iv[16];
@@ -139,6 +161,8 @@
 	struct timeout		sc_to;

 #ifdef CRYPTO
+	bus_dma_tag_t		sc_dmat;
+	struct glxsb_dma_map	sc_dma;
 	int32_t			sc_cid;
 	int			sc_nsessions;
 	struct glxsb_session	*sc_sessions;
@@ -174,8 +198,13 @@
 int glxsb_crypto_freesession(uint64_t);
 static void glxsb_bus_space_write_consec_16(bus_space_tag_t,
     bus_space_handle_t, bus_size_t, uint32_t *);
-static __inline void glxsb_aes(struct glxsb_softc *, uint32_t, void *, void *,
-    void *, int, void *);
+static __inline void glxsb_aes(struct glxsb_softc *, uint32_t, uint32_t,
+    uint32_t, void *, int, void *);
+
+int glxsb_dma_alloc(struct glxsb_softc *, int, struct glxsb_dma_map *);
+void glxsb_dma_pre_op(struct glxsb_softc *, struct glxsb_dma_map *);
+void glxsb_dma_post_op(struct glxsb_softc *, struct glxsb_dma_map *);
+void glxsb_dma_free(struct glxsb_softc *, struct glxsb_dma_map *);

 #endif /* CRYPTO */

@@ -248,6 +277,8 @@
 	    SB_AI_AES_B_COMPLETE | SB_AI_EEPROM_COMPLETE;
 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, SB_AES_INT, intr);

+	sc->sc_dmat = pa->pa_dmat;
+
 	if (glxsb_crypto_setup(sc))
 		printf(" AES");
 #endif
@@ -276,6 +307,10 @@
 glxsb_crypto_setup(struct glxsb_softc *sc)
 {
 	int algs[CRYPTO_ALGORITHM_MAX + 1];
+
+	/* Allocate a contiguous DMA-able buffer to work in */
+	if (glxsb_dma_alloc(sc, GLXSB_MAX_AES_LEN * 2, &sc->sc_dma) != 0)
+		return 0;

 	bzero(algs, sizeof(algs));
 	algs[CRYPTO_AES_CBC] = CRYPTO_ALG_FLAG_SUPPORTED;
@@ -371,33 +406,23 @@
  * Must be called at splnet() or higher
  */
 static __inline void
-glxsb_aes(struct glxsb_softc *sc, uint32_t control, void *src, void *dst,
-    void *key, int len, void *iv)
-{
-	uint32_t intr;
+glxsb_aes(struct glxsb_softc *sc, uint32_t control, uint32_t psrc,
+    uint32_t pdst, void *key, int len, void *iv)
+{
+	uint32_t status;
 	int i;
-	extern paddr_t vtophys(vaddr_t);
-	static int re_check = 0;
-
-	if (re_check) {
-		panic("glxsb: call again :(\n");
-	} else {
-		re_check = 1;
-	}

 	if (len & 0xF) {
-		printf("glxsb: len must be a multiple of 16 (not %d)\n", len);
-		re_check = 0;
+		printf("%s: len must be a multiple of 16 (not %d)\n",
+		    sc->sc_dev.dv_xname, len);
 		return;
 	}

 	/* Set the source */
-	bus_space_write_4(sc->sc_iot, sc->sc_ioh, SB_SOURCE_A,
-	    (uint32_t) vtophys((vaddr_t) src));
+	bus_space_write_4(sc->sc_iot, sc->sc_ioh, SB_SOURCE_A, psrc);

 	/* Set the destination address */
-	bus_space_write_4(sc->sc_iot, sc->sc_ioh, SB_DEST_A,
-	    (uint32_t) vtophys((vaddr_t) dst));
+	bus_space_write_4(sc->sc_iot, sc->sc_ioh, SB_DEST_A, pdst);

 	/* Set the data length */
 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, SB_LENGTH_A, len);
@@ -419,26 +444,38 @@
 	/*
 	 * Now wait until it is done.
 	 *
-	 * We do a busy wait: typically the SB completes after 7 or 8
-	 * iterations (yet to see more than 9).  Wait up to a hundred
-	 * just in case.
+	 * We do a busy wait.  Obviously the number of iterations of
+	 * the loop required to perform the AES operation depends upon
+	 * the number of bytes to process.
+	 *
+	 * On a 500 MHz Geode LX we see
+	 *
+	 *	length (bytes)	typical max iterations
+	 *	    16		   12
+	 *	    64		   22
+	 *	   256		   59
+	 *	  1024		  212
+	 *	  8192		1,537
+	 *
+	 * Since we have a maximum size of operation defined in
+	 * GLXSB_MAX_AES_LEN, we use this constant to decide how long
+	 * to wait.  Allow a couple of orders of magnitude longer than
+	 * it should really take, just in case.
 	 */
-	for (i = 0; i < 100; i++) {
-		intr = bus_space_read_4(sc->sc_iot, sc->sc_ioh, SB_AES_INT);
-
-		if (intr & SB_AI_AES_A_COMPLETE) {	/* Done */
-			bus_space_write_4(sc->sc_iot, sc->sc_ioh, SB_AES_INT,
-			    intr);
-
-			if (i > sc->maxpolls)	/* XXX */
+	for (i = 0; i < GLXSB_MAX_AES_LEN * 10; i++) {
+		status = bus_space_read_4(sc->sc_iot, sc->sc_ioh, SB_CTL_A);
+
+		if ((status & SB_CTL_ST) == 0) {	/* Done */
+			if (i > sc->maxpolls) {	/* XXX */
 				sc->maxpolls = i;
-			re_check = 0;
+				printf("%s: maxpolls now %d (len = %d)\n",
+				    sc->sc_dev.dv_xname, i, len);
+			}
 			return;
 		}
 	}

-	re_check = 0;
-	printf("glxsb: operation failed to complete\n");
+	printf("%s: operation failed to complete\n", sc->sc_dev.dv_xname);
 }

 int
@@ -447,9 +484,8 @@
 	struct glxsb_softc *sc = glxsb_sc;
 	struct glxsb_session *ses;
 	struct cryptodesc *crd;
-	char *op_buf = NULL;
-	char *op_src;			/* Source and dest buffers must */
-	char *op_dst;			/* be 16-byte aligned */
+	char *op_src, *op_dst;
+	uint32_t op_psrc, op_pdst;
 	uint8_t op_iv[16];
 	int sesn, err = 0;
 	uint32_t control;
@@ -469,6 +505,14 @@
 		goto out;
 	}

+	/* XXX TEMP TEMP TEMP need to handle this properly */
+	if (crd->crd_len > GLXSB_MAX_AES_LEN) {
+		printf("%s: operation too big: %d > %d\n",
+		    sc->sc_dev.dv_xname, crd->crd_len, GLXSB_MAX_AES_LEN);
+		err = ENOMEM;
+		goto out;
+	}
+
 	sesn = GLXSB_SESSION(crp->crp_sid);
 	if (sesn >= sc->sc_nsessions) {
 		err = EINVAL;
@@ -478,16 +522,13 @@

 	/*
 	 * XXX Check if we can have input == output on Geode LX.
-	 * XXX In the meantime, allocate space for two separate
-	 *     (adjacent) buffers
+	 * XXX In the meantime, use two separate (adjacent) buffers.
 	 */
-	op_buf = malloc(crd->crd_len * 2, M_DEVBUF, M_NOWAIT);
-	if (op_buf == NULL) {
-		err = ENOMEM;
-		goto out;
-	}
-	op_src = op_buf;
-	op_dst = op_buf + crd->crd_len;
+	op_src = sc->sc_dma.dma_vaddr;
+	op_dst = sc->sc_dma.dma_vaddr + crd->crd_len;
+
+	op_psrc = sc->sc_dma.dma_paddr;
+	op_pdst = sc->sc_dma.dma_paddr + crd->crd_len;

 	if (crd->crd_flags & CRD_F_ENCRYPT) {
 		control = SB_CTL_ENC;
@@ -533,8 +574,12 @@
 	else
 		bcopy(crp->crp_buf + crd->crd_skip, op_src, crd->crd_len);

-	glxsb_aes(sc, control, op_src, op_dst, ses->ses_key,
+	glxsb_dma_pre_op(sc, &sc->sc_dma);
+
+	glxsb_aes(sc, control, op_psrc, op_pdst, ses->ses_key,
 	    crd->crd_len, op_iv);
+
+	glxsb_dma_post_op(sc, &sc->sc_dma);

 	if (crp->crp_flags & CRYPTO_F_IMBUF)
 		m_copyback((struct mbuf *)crp->crp_buf,
@@ -558,15 +603,94 @@
 			    ses->ses_iv, 16);
 	}

+	bzero(sc->sc_dma.dma_vaddr, crd->crd_len * 2);
+
 out:
-	if (op_buf != NULL) {
-		bzero(op_buf, crd->crd_len * 2);
-		free(op_buf, M_DEVBUF);
-	}
 	crp->crp_etype = err;
 	crypto_done(crp);
 	splx(s);
 	return (err);
 }

+int
+glxsb_dma_alloc(struct glxsb_softc *sc, int size, struct glxsb_dma_map *dma)
+{
+	int rc;
+
+	dma->dma_nsegs = 1;
+	dma->dma_size = size;
+
+	rc = bus_dmamap_create(sc->sc_dmat, size, dma->dma_nsegs, size,
+	    0, BUS_DMA_NOWAIT, &dma->dma_map);
+	if (rc != 0) {
+		printf("%s: couldn't create DMA map for %d bytes (%d)\n",
+		    sc->sc_dev.dv_xname, size, rc);
+
+		goto fail0;
+	}
+
+	rc = bus_dmamem_alloc(sc->sc_dmat, size, SB_AES_ALIGN, 0,
+	    &dma->dma_seg, dma->dma_nsegs, &dma->dma_nsegs, BUS_DMA_NOWAIT);
+	if (rc != 0) {
+		printf("%s: couldn't allocate DMA memory of %d bytes (%d)\n",
+		    sc->sc_dev.dv_xname, size, rc);
+
+		goto fail1;
+	}
+
+	rc = bus_dmamem_map(sc->sc_dmat, &dma->dma_seg, 1, size,
+	    &dma->dma_vaddr, BUS_DMA_NOWAIT);
+	if (rc != 0) {
+		printf("%s: couldn't map DMA memory for %d bytes (%d)\n",
+		    sc->sc_dev.dv_xname, size, rc);
+
+		goto fail2;
+	}
+
+	rc = bus_dmamap_load(sc->sc_dmat, dma->dma_map, dma->dma_vaddr,
+	    size, NULL, BUS_DMA_NOWAIT);
+	if (rc != 0) {
+		printf("%s: couldn't load DMA memory for %d bytes (%d)\n",
+		    sc->sc_dev.dv_xname, size, rc);
+
+		goto fail3;
+	}
+
+	dma->dma_paddr = dma->dma_map->dm_segs[0].ds_addr;
+
+	return 0;
+
+fail3:
+	bus_dmamem_unmap(sc->sc_dmat, dma->dma_vaddr, size);
+fail2:
+	bus_dmamem_free(sc->sc_dmat, &dma->dma_seg, dma->dma_nsegs);
+fail1:
+	bus_dmamap_destroy(sc->sc_dmat, dma->dma_map);
+fail0:
+	return rc;
+}
+
+void
+glxsb_dma_pre_op(struct glxsb_softc *sc, struct glxsb_dma_map *dma)
+{
+	bus_dmamap_sync(sc->sc_dmat, dma->dma_map, 0, dma->dma_size,
+	    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+}
+
+void
+glxsb_dma_post_op(struct glxsb_softc *sc, struct glxsb_dma_map *dma)
+{
+	bus_dmamap_sync(sc->sc_dmat, dma->dma_map, 0, dma->dma_size,
+	    BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
+}
+
+void
+glxsb_dma_free(struct glxsb_softc *sc, struct glxsb_dma_map *dma)
+{
+	bus_dmamap_unload(sc->sc_dmat, dma->dma_map);
+	bus_dmamem_unmap(sc->sc_dmat, dma->dma_vaddr, dma->dma_size);
+	bus_dmamem_free(sc->sc_dmat, &dma->dma_seg, dma->dma_nsegs);
+	bus_dmamap_destroy(sc->sc_dmat, dma->dma_map);
+}
+
 #endif /* CRYPTO */


Fix possibly uninitialized variable warning.

--- src/expression.c
+++ src/expression.c
@@ -663,7 +663,7 @@
     tok->vector_length = 1;
     tok->vector_index = 0;
     tok->vector_length_locked = 0;
-    int n, i;
+    int n=index, i=index;
     char c = str[index];
     int integer_found = 0;


um: get_safe_registers() should be done in flush_thread(), not start_thread()

... or we'll end up buggering the results of ELF_PLAT_INIT()

Signed-off-by: Al Viro <de609eb4d5d70b1d38ec6642adbfc33a2781f63c@zeniv.linux.org.uk>

--- arch/um/kernel/exec.c
+++ arch/um/kernel/exec.c
@@ -32,13 +32,14 @@
 		       "err = %d\n", ret);
 		force_sig(SIGKILL, current);
 	}
+	get_safe_registers(current_pt_regs()->regs.gp,
+			   current_pt_regs()->regs.fp);

 	__switch_mm(&current->mm->context.id);
 }

 void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
 {
-	get_safe_registers(regs->regs.gp, regs->regs.fp);
 	PT_REGS_IP(regs) = eip;
 	PT_REGS_SP(regs) = esp;
 	current->ptrace &= ~PT_DTRACE;


from ragge; unneccessary

from ragge; unneccessary

--- arch/vax/mba/hpdefs.h
+++ arch/vax/mba/hpdefs.h
@@ -1,81 +0,0 @@
-/*	$NetBSD: hpdefs.h,v 1.1 1995/02/13 00:44:00 ragge Exp $ */
-/*
- * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed at Ludd, University of Lule}.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
- /* All bugs are subject to removal without further notice */
-
-
-
-/* hpdefs.h - 940325/ragge */
-
-#define HPCS1_DVA	0x800	/* Drive avail, in dual-port config */
-#define HPDS_VV		0x40	/* Volume valid, not changed */
-#define HPDS_DRY	0x80	/* Drive ready to accept commands */
-#define HPDS_DPR	0x100	/* Drive present */
-#define HPDS_PGM	0x200	/* Programmable in dual-port config */
-#define HPDS_WRL	0x800	/* Write locked media */
-#define HPDS_MOL	0x1000	/* Medium on-line */
-#define HPDT_DRQ	0x800	/* Dual-port disk */
-
-/*
- * Drive status, per drive
- */
-struct hp_info {
-        daddr_t hp_dsize;       /* size in sectors */
-/*      u_long  hp_type;        /* drive type */
-        u_long  hp_mediaid;     /* media id */
-        int     hp_state;       /* open/closed state */
-        struct  hp_geom {       /* geometry information */
-                u_short rg_nsectors;    /* sectors/track */
-                u_short rg_ngroups;     /* track groups */
-                u_short rg_ngpc;        /* groups/cylinder */
-                u_short rg_ntracks;     /* ngroups*ngpc */
-                u_short rg_ncyl;        /* ra_dsize/ntracks/nsectors */
-#ifdef notyet
-                u_short rg_rctsize;     /* size of rct */
-                u_short rg_rbns;        /* replacement blocks per track */
-                u_short rg_nrct;        /* number of rct copies */
-#endif
-        } hp_geom;
-        int     hp_wlabel;      /* label sector is currently writable */
-        u_long  hp_openpart;    /* partitions open */
-        u_long  hp_bopenpart;   /* block partitions open */
-        u_long  hp_copenpart;   /* character partitions open */
-};
-
-/*
- * Device to unit number and partition and back
- */
-#define UNITSHIFT       3
-#define UNITMASK        7
-#define hpunit(dev)    (minor(dev) >> UNITSHIFT)
-#define hppart(dev)    (minor(dev) & UNITMASK)
-#define hpminor(u, p)  (((u) << UNITSHIFT) | (p))
-


x86: memtest: use pointers of equal type for comparison

Commit c9690998ef48ffefeccb91c70a7739eebdea57f9 (x86: memtest: remove
64-bit division) introduced following compile warning:

arch/x86/mm/memtest.c: In function 'memtest':
arch/x86/mm/memtest.c:56: warning: comparison of distinct pointer types lacks a cast
arch/x86/mm/memtest.c:58: warning: comparison of distinct pointer types lacks a cast

Signed-off-by: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>

--- arch/x86/mm/memtest.c
+++ arch/x86/mm/memtest.c
@@ -40,21 +40,20 @@

 static void __init memtest(u64 pattern, u64 start_phys, u64 size)
 {
-	u64 *p;
-	void *start, *end;
+	u64 *p, *start, *end;
 	u64 start_bad, last_bad;
 	u64 start_phys_aligned;
-	size_t incr;
+	const size_t incr = sizeof(pattern);

-	incr = sizeof(pattern);
 	start_phys_aligned = ALIGN(start_phys, incr);
 	start = __va(start_phys_aligned);
-	end = start + size - (start_phys_aligned - start_phys);
+	end = start + (size - (start_phys_aligned - start_phys)) / incr;
 	start_bad = 0;
 	last_bad = 0;

 	for (p = start; p < end; p++)
 		*p = pattern;
+
 	for (p = start; p < end; p++, start_phys_aligned += incr) {
 		if (*p == pattern)
 			continue;


mm/xtensa: use common help functions to free reserved pages

Use common help functions to free reserved pages.

Signed-off-by: Jiang Liu <68ee766e574f18b34b683085865827393efe88bd@huawei.com>
Cc: Chris Zankel <711c73f64afdce07b7e38039a96d2224209e9a6c@zankel.net>
Cc: Max Filippov <8c5ea195856807f4f02a6e0749c87ea6b7375f38@gmail.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- arch/xtensa/mm/init.c
+++ arch/xtensa/mm/init.c
@@ -208,32 +208,17 @@
 	       highmemsize >> 10);
 }

-void
-free_reserved_mem(void *start, void *end)
-{
-	for (; start < end; start += PAGE_SIZE) {
-		ClearPageReserved(virt_to_page(start));
-		init_page_count(virt_to_page(start));
-		free_page((unsigned long)start);
-		totalram_pages++;
-	}
-}
-
 #ifdef CONFIG_BLK_DEV_INITRD
 extern int initrd_is_mapped;

 void free_initrd_mem(unsigned long start, unsigned long end)
 {
-	if (initrd_is_mapped) {
-		free_reserved_mem((void*)start, (void*)end);
-		printk ("Freeing initrd memory: %ldk freed\n",(end-start)>>10);
-	}
+	if (initrd_is_mapped)
+		free_reserved_area(start, end, 0, "initrd");
 }
 #endif

 void free_initmem(void)
 {
-	free_reserved_mem(__init_begin, __init_end);
-	printk("Freeing unused kernel memory: %zuk freed\n",
-	       (__init_end - __init_begin) >> 10);
-}
+	free_initmem_default(0);
+}


A more elegant way to handle 64bit getaddrinfo() on OpenVMS

--- src/psocketaddress.c
+++ src/psocketaddress.c
@@ -56,6 +56,12 @@
 #  endif
 #endif

+#ifdef P_OS_VMS
+#  if PLIBSYS_SIZEOF_VOID_P == 8
+#    define addrinfo __addrinfo64
+#  endif
+#endif
+
 struct PSocketAddress_ {
 	PSocketFamily	family;
 	union addr_ {
@@ -131,18 +137,8 @@
 {
 	PSocketAddress		*ret;
 #if defined (P_OS_WIN) || defined (PLIBSYS_HAS_GETADDRINFO)
-#  ifdef P_OS_VMS
-#    if PLIBSYS_SIZEOF_VOID_P == 4
-	struct __addrinfo32	hints;
-	struct __addrinfo32	*res;
-#    else
-	struct __addrinfo64	hints;
-	struct __addrinfo64	*res;
-#    endif
-#  else
 	struct addrinfo		hints;
 	struct addrinfo		*res;
-#  endif
 #endif

 #ifdef P_OS_WIN


Fix some spelling mistakes in comments

Fix some spelling mistakes in comments

--- src/puthread-amiga.c
+++ src/puthread-amiga.c
@@ -150,7 +150,7 @@
 	return key_idx;
 }

-/* Must used only inside a protected critical region */
+/* Must be used only inside a protected critical region */

 static pint
 pp_uthread_find_next_id (void)
@@ -190,7 +190,7 @@
 	return cur_id;
 }

-/* Must used only inside a protected critical region */
+/* Must be used only inside a protected critical region */

 static PUThreadInfo *
 pp_uthread_find_thread_info (struct Task *task)
@@ -208,7 +208,7 @@
 	return NULL;
 }

-/* Must used only inside a protected critical region */
+/* Must be used only inside a protected critical region */

 static PUThreadInfo *
 pp_uthread_find_or_create_thread_info (struct Task *task)


added enabled/disabled config option for serval plugin

--- plugins/serval-dna/serval-dna.c
+++ plugins/serval-dna/serval-dna.c
@@ -62,7 +62,7 @@
 static co_obj_t *sock_alarms = NULL;
 static co_obj_t *timer_alarms = NULL;
 bool serval_registered = false;
-bool daemon_started = true;
+bool daemon_started = false;
 extern co_obj_t *err_msg;

 // Private functions
@@ -342,6 +342,7 @@
 }

 SCHEMA(serval) {
+  SCHEMA_ADD("servald","enabled");
   SCHEMA_ADD("serval_path",DEFAULT_SERVAL_PATH);
   SCHEMA_ADD("mdp_sid",DEFAULT_SID);
   SCHEMA_ADD("mdp_keyring",DEFAULT_MDP_PATH);
@@ -369,14 +370,17 @@
   DEBUG("mdp_path: %s",mdp_path);
   DEBUG("mdp_path_len: %d",mdp_path_len);

-  stowSid(packedSid,0,mdp_sid);
-  CHECK(serval_init_keyring(packedSid,
+  if (strcmp(mdp_sid,DEFAULT_SID) != 0) {
+    stowSid(packedSid,0,mdp_sid);
+    CHECK(serval_init_keyring(packedSid,
 			 SID_SIZE,
 			 mdp_path,
 			 mdp_path_len,
 			 &mdp_keyring,
 			 &mdp_key,
 			 &mdp_key_len), "Failed to initialize olsrd-mdp Serval keyring");
+  } else
+    DEBUG("Not initializing olsrd-mdp keyring");

   return 1;
 error:
@@ -393,6 +397,10 @@
 }

 int co_plugin_init(co_obj_t *self, co_obj_t **output, co_obj_t *params) {
+  char *enabled = NULL;
+  co_profile_get_str(co_profile_global(),&enabled,"servald",sizeof("servald"));
+  if (strcmp(enabled,"disabled") == 0) return 1;
+
   DEBUG("Initializing Serval plugin");

   srandomdev();
@@ -442,6 +450,8 @@
 }

 int co_plugin_shutdown(co_obj_t *self, co_obj_t **output, co_obj_t *params) {
+  if (daemon_started == false) return 1;
+
   DEBUG("Serval shutdown");

   if (mdp_keyring) keyring_free(mdp_keyring);
@@ -450,10 +460,10 @@

   dna_helper_shutdown();

-  co_list_parse(sock_alarms,destroy_alarms,NULL);
+//   co_list_parse(sock_alarms,destroy_alarms,NULL);
   co_obj_free(sock_alarms);  // halloc will free list items

-  co_list_parse(timer_alarms,destroy_alarms,NULL);
+//   co_list_parse(timer_alarms,destroy_alarms,NULL);
   co_obj_free(timer_alarms); // halloc will free list items

   keyring_free(keyring);


Remove macros to work for different gsttracer versions

--- plugins/tracers/gstqueuelevel.c
+++ plugins/tracers/gstqueuelevel.c
@@ -24,10 +24,6 @@
  * A tracing module that takes queue's current level
  */

-#ifdef HAVE_CONFIG_H
-#  include "config.h"
-#endif
-
 #include "gstqueuelevel.h"
 #include "gstctf.h"

@@ -50,11 +46,7 @@
     GstBufferList * list);
 static gboolean is_queue (GstElement * element);

-
-
-#ifdef GST_STABLE_RELEASE
 static GstTracerRecord *tr_qlevel;
-#endif

 static const gchar queue_level_metadata_event[] = "event {\n\
     name = queuelevel;\n\
@@ -94,16 +86,9 @@
   size_time_string =
       g_strdup_printf ("%" GST_TIME_FORMAT, GST_TIME_ARGS (size_time));

-#ifdef GST_STABLE_RELEASE
   gst_tracer_record_log (tr_qlevel, element_name, size_bytes, size_buffers,
       size_time_string);
-#else
-  gst_tracer_log_trace (gst_structure_new ("queuelevel",
-          "queue", G_TYPE_STRING, element_name,
-          "size_bytes", G_TYPE_UINT, size_bytes,
-          "size_buffers", G_TYPE_UINT, size_buffers,
-          "size_time", G_TYPE_STRING, size_time_string, NULL));
-#endif
+
   g_free (size_time_string);

   do_print_queue_level_event (QUEUE_LEVEL_EVENT_ID, element_name, size_bytes,
@@ -151,7 +136,6 @@
 {
 }

-
 static void
 gst_queue_level_tracer_init (GstQueueLevelTracer * self)
 {
@@ -167,7 +151,6 @@
   gst_shark_tracer_register_hook (tracer, "pad-pull-range-pre",
       G_CALLBACK (do_queue_level));

-#ifdef GST_STABLE_RELEASE
   tr_qlevel = gst_tracer_record_new ("queuelevel.class",
       "queue", GST_TYPE_STRUCTURE, gst_structure_new ("scope",
           "type", G_TYPE_GTYPE, G_TYPE_STRING,
@@ -182,17 +165,6 @@
       GST_TYPE_STRUCTURE, gst_structure_new ("scope", "type", G_TYPE_GTYPE,
           G_TYPE_STRING, "related-to", GST_TYPE_TRACER_VALUE_SCOPE,
           GST_TRACER_VALUE_SCOPE_ELEMENT, NULL), NULL);
-#else
-  gst_tracer_log_trace (gst_structure_new ("queuelevel.class",
-          "queue", GST_TYPE_STRUCTURE, gst_structure_new ("scope", "related-to",
-              G_TYPE_STRING, "element", NULL), "size_bytes", GST_TYPE_STRUCTURE,
-          gst_structure_new ("scope", "related-to", G_TYPE_STRING, "element",
-              NULL), "size_buffers", GST_TYPE_STRUCTURE,
-          gst_structure_new ("scope", "related-to", G_TYPE_STRING, "element",
-              NULL), "size_time", GST_TYPE_STRUCTURE,
-          gst_structure_new ("scope", "related-to", G_TYPE_STRING, "element",
-              NULL), NULL));
-#endif

   metadata_event =
       g_strdup_printf (queue_level_metadata_event, QUEUE_LEVEL_EVENT_ID, 0);


py: fix memory leak in sack-py.c:new_package

--- src/python/sack-py.c
+++ src/python/sack-py.c
@@ -67,6 +67,7 @@
     } else {
 	package = PyObject_CallObject((PyObject*)&package_Type, arglist);
     }
+    Py_DECREF(arglist);
     return package;
 }


Missed definiton of QTimer *pollMnTimer;

--- src/qt/clientmodel.h
+++ src/qt/clientmodel.h
@@ -93,6 +93,7 @@
     BanTableModel *banTableModel;

     QTimer *pollTimer;
+    QTimer *pollMnTimer;

     void subscribeToCoreSignals();
     void unsubscribeFromCoreSignals();


lib-fs: fs-posix now allows reading from the same file that was created.

--- src/lib-fs/fs-posix.c
+++ src/lib-fs/fs-posix.c
@@ -404,6 +404,8 @@
 	i_free_and_null(file->temp_path);
 	file->success = TRUE;
 	file->seek_to_beginning = TRUE;
+	/* allow opening the file after writing to it */
+	file->open_mode = FS_OPEN_MODE_READONLY;
 	return 0;
 }


elm genlist: Partial revert of my wrong commit r75161.

SVN revision: 75180

--- src/lib/elm_genlist.c
+++ src/lib/elm_genlist.c
@@ -577,31 +577,23 @@

    ELM_GENLIST_DATA_GET(obj, sd);

-   static int i = 0;
    /* parent class' early call */
    if (!sd->s_iface) return;

    if (sd->on_sub_del) return;;

-fprintf(stderr, "%s %d\t", __func__, i++);
-   evas_object_size_hint_min_get(obj, &minw, &minh);
+   evas_object_size_hint_min_get(obj, &minw, NULL);
    evas_object_size_hint_max_get(obj, &maxw, &maxh);

-fprintf(stderr, "minw %d minh %d maxw %d maxh %d\t", minw, minh, maxw, maxh);
-
    edje_object_size_min_calc(ELM_WIDGET_DATA(sd)->resize_obj, &vmw, &vmh);

-fprintf(stderr, "edje vmw %d vmh %d\t", vmw, vmh);
-
    if (sd->mode == ELM_LIST_COMPRESS)
      {
         Evas_Coord vw, vh;

         sd->s_iface->content_viewport_size_get(obj, &vw, &vh);
-fprintf(stderr, "viewport vw %d vh %d", vw, vh);
         if ((vw != 0) && (vw != sd->prev_viewport_w))
           {
-fprintf(stderr, "\n\t prev_viewport_w %d", sd->prev_viewport_w);
              Item_Block *itb;

              sd->prev_viewport_w = vw;
@@ -629,7 +621,6 @@

    evas_object_size_hint_min_set(obj, minw, minh);
    evas_object_size_hint_max_set(obj, maxw, maxh);
-fprintf(stderr, "\n\tminw %d minh %d", minw, minh);
 }

 static void


Elementary genlist: Indentation fix for reorder patch.

SVN revision: 60110

--- src/lib/elm_genlist.c
+++ src/lib/elm_genlist.c
@@ -2415,18 +2415,18 @@
                               }
                          }
                        if (!it->move_effect_enabled)
-                          {
-                             {
-                                if (it->mode_view)
-                                  _item_position(it, it->mode_view, it->scrl_x,
-                                                 it->scrl_y);
-                                else
-                                  _item_position(it, it->base.view, it->scrl_x,
-                                                 it->scrl_y);
-                             }
-                           it->old_scrl_x = it->scrl_x;
-                           it->old_scrl_y = it->scrl_y;
-                          }
+                         {
+                              {
+                                 if (it->mode_view)
+                                   _item_position(it, it->mode_view, it->scrl_x,
+                                                  it->scrl_y);
+                                 else
+                                   _item_position(it, it->base.view, it->scrl_x,
+                                                  it->scrl_y);
+                              }
+                            it->old_scrl_x = it->scrl_x;
+                            it->old_scrl_y = it->scrl_y;
+                         }
                     }
                   else
                     {


and fix some genlist bugs i spotted!

and fix some genlist bugs i spotted!

SVN revision: 39177

--- src/lib/elm_genlist.c
+++ src/lib/elm_genlist.c
@@ -584,7 +584,6 @@
 {
    Pan *sd = evas_object_smart_data_get(obj);
    Evas_Coord ow, oh;
-   if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
    evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
    ow = sd->wd->minw - ow;
    if (ow < 0) ow = 0;
@@ -594,6 +593,7 @@
    if (y < 0) y = 0;
    if (x > ow) x = ow;
    if (y > oh) y = oh;
+   if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
    sd->wd->pan_x = x;
    sd->wd->pan_y = y;
    evas_object_smart_changed(obj);
@@ -784,8 +784,10 @@
    it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
    if (itb->count < 1)
      {
+        Item_Block *itbn = (Item_Block *)(((Eina_Inlist *)(itb))->next);
         it->wd->blocks = eina_inlist_remove(it->wd->blocks, (Eina_Inlist *)itb);
         free(itb);
+        if (itbn) itbn->changed = 1;
      }
    else
      {
@@ -829,6 +831,7 @@
 static void
 _item_del(Item *it)
 {
+   it->delete_me = 1;
    if (it->wd->show_item == it) it->wd->show_item = NULL;
    if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
    if ((!it->delete_me) && (it->itc->func.del)) it->itc->func.del(it->data, it->wd->obj);
@@ -847,21 +850,20 @@
 static void
 _item_block_add(Widget_Data *wd, Item *it, Item *itpar)
 {
-   Item_Block *itb;
+   Item_Block *itb = NULL;

    if (!it->rel)
      {
         newblock:
-        itb = calloc(1, sizeof(Item_Block));
-        if (!itb) return;
-        itb->wd = wd;
         if (!it->parent)
           {
              if (it->rel)
                {
+                  itb = calloc(1, sizeof(Item_Block));
+                  if (!itb) return;
+                  itb->wd = wd;
                   if (!it->rel->block)
                     {
-                       printf("EEK rel no block\n");
                        wd->blocks = eina_inlist_append(wd->blocks, (Eina_Inlist *)itb);
                        itb->items = eina_list_append(itb->items, it);
                     }
@@ -883,12 +885,46 @@
                {
                   if (it->before)
                     {
-                       wd->blocks = eina_inlist_prepend(wd->blocks, (Eina_Inlist *)itb);
+                       if (wd->blocks)
+                         {
+                            itb = (Item_Block *)(wd->blocks);
+                            if (itb->count >= 32)
+                              {
+                                 itb = calloc(1, sizeof(Item_Block));
+                                 if (!itb) return;
+                                 itb->wd = wd;
+                                 wd->blocks = eina_inlist_prepend(wd->blocks, (Eina_Inlist *)itb);
+                              }
+                         }
+                       else
+                         {
+                            itb = calloc(1, sizeof(Item_Block));
+                            if (!itb) return;
+                            itb->wd = wd;
+                            wd->blocks = eina_inlist_prepend(wd->blocks, (Eina_Inlist *)itb);
+                         }
                        itb->items = eina_list_prepend(itb->items, it);
                     }
                   else
                     {
-                       wd->blocks = eina_inlist_append(wd->blocks, (Eina_Inlist *)itb);
+                       if (wd->blocks)
+                         {
+                            itb = (Item_Block *)(wd->blocks->last);
+                            if (itb->count >= 32)
+                              {
+                                 itb = calloc(1, sizeof(Item_Block));
+                                 if (!itb) return;
+                                 itb->wd = wd;
+                                 wd->blocks = eina_inlist_append(wd->blocks, (Eina_Inlist *)itb);
+                              }
+                         }
+                       else
+                         {
+                            itb = calloc(1, sizeof(Item_Block));
+                            if (!itb) return;
+                            itb->wd = wd;
+                            wd->blocks = eina_inlist_append(wd->blocks, (Eina_Inlist *)itb);
+                         }
                        itb->items = eina_list_append(itb->items, it);
                     }
                }
@@ -901,7 +937,10 @@
    else
      {
         itb = it->rel->block;
-        if ((!itb) || (itb->count > 32)) goto newblock;
+        if ((!itb) || (itb->count >= 32))
+          {
+             goto newblock;
+          }
         if (it->before)
           itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
         else


elementary/genlist: fix indent

elementary/genlist: fix indent

SVN revision: 71385

--- src/lib/elm_genlist.c
+++ src/lib/elm_genlist.c
@@ -2336,7 +2336,7 @@
                }
              else
                {
-                  if ((itb->wd->homogeneous) &&
+                  if ((itb->wd->homogeneous) &&
                       (itb->wd->mode == ELM_LIST_COMPRESS))
                     {
                        if (it->group)
@@ -3306,11 +3306,11 @@
    evas_object_event_callback_add(it->item->deco_it_view, EVAS_CALLBACK_MOUSE_MOVE,
                                   _mouse_move, it);

-   /* text_get, content_get, state_get */
    /* FIXME: If you see that assert, please notify us and we
       will clean our mess */
    assert(eina_list_count(it->item->deco_it_content_objs) == 0);

+   /* text_get, content_get, state_get */
    _item_text_realize(it, it->item->deco_it_view, &it->item->deco_it_texts, NULL);
    if (!it->item->deco_it_contents)
      it->item->deco_it_contents =
@@ -3401,10 +3401,9 @@

    snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->decorate_it_type);
    snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->decorate_it_type);
-
    edje_object_signal_emit(it->item->deco_it_view, buf, "elm");
-   edje_object_signal_callback_add(it->item->deco_it_view, buf2, "elm", _decorate_item_finished_signal_cb, it);
-
+   edje_object_signal_callback_add(it->item->deco_it_view, buf2, "elm",
+                                   _decorate_item_finished_signal_cb, it);
    wd->mode_item = NULL;
 }

@@ -3459,14 +3458,17 @@
    _elm_genlist_item_odd_even_update(it);
    _elm_genlist_item_state_update(it, NULL);

-   if (effect_on) edje_object_signal_emit(it->deco_all_view, "elm,state,decorate,enabled,effect", "elm");
-   else edje_object_signal_emit(it->deco_all_view, "elm,state,decorate,enabled", "elm");
+   if (effect_on) edje_object_signal_emit(it->deco_all_view,
+                                          "elm,state,decorate,enabled,effect", "elm");
+   else edje_object_signal_emit(it->deco_all_view,
+                                "elm,state,decorate,enabled", "elm");

    _item_mouse_callbacks_del(it, VIEW(it));
    _item_mouse_callbacks_add(it, it->deco_all_view);

    _item_text_realize(it, it->deco_all_view, &it->item->deco_all_texts, NULL);
-   if (it->flipped) edje_object_signal_emit(it->deco_all_view, "elm,state,flip,enabled", "elm");
+   if (it->flipped) edje_object_signal_emit(it->deco_all_view,
+                                            "elm,state,flip,enabled", "elm");
    if (!it->item->deco_all_contents)
      it->item->deco_all_contents =
         elm_widget_stringlist_get(edje_object_data_get(it->deco_all_view, "contents"));
@@ -4101,7 +4103,7 @@
 _item_process_post(Widget_Data *wd, Elm_Gen_Item *it, Eina_Bool qadd)
 {
    Eina_Bool showme = EINA_FALSE;
-
+
    if (it->item->block->changed)
      {
         showme = _item_block_recalc(it->item->block, it->item->block->num, qadd);
@@ -4245,7 +4247,9 @@
    it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
    _item_block_del(it);

-   it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
+   it->wd->items = eina_inlist_append_relative(it->wd->items,
+                                               EINA_INLIST_GET(it),
+                                               EINA_INLIST_GET(after));
    it->item->rel = after;
    it->item->rel->relcount++;
    it->item->before = EINA_FALSE;
@@ -4264,7 +4268,9 @@

    it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
    _item_block_del(it);
-   it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
+   it->wd->items = eina_inlist_prepend_relative(it->wd->items,
+                                                EINA_INLIST_GET(it),
+                                                EINA_INLIST_GET(before));
    it->item->rel = before;
    it->item->rel->relcount++;
    it->item->before = EINA_TRUE;


Basic animation supports UIEdgeInsets value type

--- pop/POPBasicAnimationInternal.h
+++ pop/POPBasicAnimationInternal.h
@@ -24,6 +24,7 @@
     case kPOPValuePoint:
     case kPOPValueSize:
     case kPOPValueRect:
+    case kPOPValueEdgeInsets:
     case kPOPValueColor:
       POPInterpolateVector(count, outVec, fromVec, toVec, p);
       break;


elementary/genlist: clean up codes

elementary/genlist: clean up codes

SVN revision: 71541

--- src/lib/elm_genlist.c
+++ src/lib/elm_genlist.c
@@ -1846,14 +1846,15 @@
      {
         const Eina_List *l;
         const char *key;
+        Evas_Object *ic;

         EINA_LIST_FOREACH(*source, l, key)
           {
              if (parts && fnmatch(parts, key, FNM_PERIOD))
                continue;

-             Evas_Object *ic = it->itc->func.content_get
-                ((void *)it->base.data, WIDGET(it), l->data);
+             ic = it->itc->func.content_get
+               ((void *)it->base.data, WIDGET(it), key);

              if (ic)
                {
@@ -1861,11 +1862,8 @@
                   edje_object_part_swallow(target, key, ic);
                   evas_object_show(ic);
                   elm_widget_sub_object_add(WIDGET(it), ic);
-                  if (it->item->deco_it_view || it->wd->decorate_all_mode)
-                    {
-                       if (elm_widget_item_disabled_get(it))
-                         elm_widget_disabled_set(ic, EINA_TRUE);
-                    }
+                  if (elm_widget_item_disabled_get(it))
+                    elm_widget_disabled_set(ic, EINA_TRUE);
                }
           }
      }


Fix passing work_item to thread pool in on_rpc_response and on_rpc_fragment().

--- src/rpc_connection.c
+++ src/rpc_connection.c
@@ -267,6 +267,7 @@
 static void
 on_rpc_response(rpc_connection_t conn, rpc_object_t args, rpc_object_t id)
 {
+	struct work_item *item;
 	GError *err = NULL;
 	rpc_call_t call;

@@ -280,7 +281,9 @@
 	call->rc_result = args;

 	if (call->rc_callback) {
-		g_thread_pool_push(conn->rco_callback_pool, call, &err);
+		item = g_malloc0(sizeof(*item));
+		item->call = call;
+		g_thread_pool_push(conn->rco_callback_pool, item, &err);
 		if (err != NULL) {

 		}
@@ -294,6 +297,7 @@
 static void
 on_rpc_fragment(rpc_connection_t conn, rpc_object_t args, rpc_object_t id)
 {
+	struct work_item *item;
 	GError *err = NULL;
 	rpc_call_t call;
 	rpc_object_t payload;
@@ -318,7 +322,9 @@
 	call->rc_seqno = seqno;

 	if (call->rc_callback) {
-		g_thread_pool_push(conn->rco_callback_pool, call, &err);
+		item = g_malloc0(sizeof(*item));
+		item->call = call;
+		g_thread_pool_push(conn->rco_callback_pool, item, &err);
 		if (err != NULL) {

 		}
@@ -1105,7 +1111,7 @@
 	call->rc_interface = interface;
 	call->rc_method = name;
 	call->rc_args = args != NULL ? args : rpc_array_create();
-	call->rc_callback = callback;
+	call->rc_callback = callback != NULL ? Block_copy(callback) : NULL;

 	if (path)
 		rpc_dictionary_set_string(payload, "path", path);


Don't rely on module to DTRT keeping memdeb_p safe. Store copy in our private space and use it instead.

--- src/rtpp_module_if.c
+++ src/rtpp_module_if.c
@@ -49,6 +49,9 @@
     void *dmp;
     struct rtpp_minfo *mip;
     struct rtpp_module_priv *mpvt;
+    /* Privary version of the module's memdeb_p, store it here */
+    /* just in case module screws it up                        */
+    void *memdeb_p;
 };

 static void rtpp_mif_dtor(struct rtpp_module_if_priv *);
@@ -98,8 +101,8 @@
     pvt->mip->strdup = &rtpp_memdeb_strdup;
     pvt->mip->asprintf = &rtpp_memdeb_asprintf;
     pvt->mip->vasprintf = &rtpp_memdeb_vasprintf;
-    pvt->mip->memdeb_p = rtpp_memdeb_init();
-    rtpp_memdeb_setlog(pvt->mip->memdeb_p, log);
+    pvt->memdeb_p = rtpp_memdeb_init();
+    rtpp_memdeb_setlog(pvt->memdeb_p, log);
 #else
     pvt->mip->malloc = (rtpp_module_malloc_t)&malloc;
     pvt->mip->free = (rtpp_module_free_t)&free;
@@ -108,9 +111,10 @@
     pvt->mip->asprintf = rtpp_module_asprintf;
     pvt->mip->vasprintf = rtpp_module_vasprintf;
 #endif
-    if (pvt->mip->memdeb_p == NULL) {
+    if (pvt->memdeb_p == NULL) {
         goto e2;
     }
+    pvt->mip->memdeb_p = pvt->memdeb_p;

     if (pvt->mip->ctor != NULL) {
         pvt->mpvt = pvt->mip->ctor(cfsp);
@@ -125,7 +129,7 @@
     return ((&pvt->pub));
 e3:
 #if RTPP_CHECK_LEAKS
-    rtpp_memdeb_dtor(pvt->mip->memdeb_p);
+    rtpp_memdeb_dtor(pvt->memdeb_p);
 #endif
 e2:
     dlclose(pvt->dmp);
@@ -145,8 +149,8 @@
         pvt->mip->dtor(pvt->mpvt);
     }
 #if RTPP_CHECK_LEAKS
-    rtpp_memdeb_dumpstats(pvt->mip->memdeb_p, 1);
-    rtpp_memdeb_dtor(pvt->mip->memdeb_p);
+    rtpp_memdeb_dumpstats(pvt->memdeb_p, 1);
+    rtpp_memdeb_dtor(pvt->memdeb_p);
 #endif
     dlclose(pvt->dmp);
     free(pvt);


Save out the last working version

Save out the last working version

error: pathspec 'src/libSeamCarve-v3.c' did not match any file(s) known to git

--- src/libSeamCarve-v3.c
+++ src/libSeamCarve-v3.c
@@ -0,0 +1,860 @@
+/**
+ * Masters Thesis Work: OCR
+ * Christopher Stoll, 2014 -- v3, major refactoring
+ */
+
+#ifndef LIBSEAMCARVE_C
+#define LIBSEAMCARVE_C
+
+#include <stdio.h>
+#include <limits.h>
+#include <string.h>
+#include "pixel.h"
+#include "libWrappers.c"
+#include "libBinarization.c"
+#include "libEnergies.c"
+#include "libMinMax.c"
+
+#define SEAM_TRACE_INCREMENT 16
+#define THRESHHOLD_SOBEL 96
+#define THRESHHOLD_USECOUNT 64
+
+/*
+ * Trace all the seams
+ * The least signifigant pixels will be traced multiple times and have a higher value (whiter)
+ * The most signifigant pixels will not be traced at all and have a value of zero (black)
+ */
+static void findSeams(struct pixel *imageVector, int imageWidth, int imageHeight, int direction)
+{
+	// TODO: create macro definition
+	int directionVertical = 0;
+	int directionHorizontal = 1;
+	if ((direction != directionVertical) && (direction != directionHorizontal)) {
+		return;
+	}
+
+	int imageSize = 0; // width when going horizontal, height when going vertical
+	int loopBeg = 0; // where the outer loop begins
+	int loopEnd = 0; // where the outer loop ends
+	int loopInc = 0; // the increment of the outer loop
+
+	int nextPixelR = 0; // next pixel to the right
+	int nextPixelC = 0; // next pixel to the center
+	int nextPixelL = 0; // next pixel to the left
+	int currentMin = 0; // the minimum of nextPixelR, nextPixelC, and nextPixelL
+	int countGoR = 0; // how many times the seam diverged upward
+	int countGoL = 0; // how many times the seam diverged downward
+
+	int nextPixelDistR = 0; // memory distance to the next pixel to the right
+	int nextPixelDistC = 0; // memory distance to the next pixel to the center
+	int nextPixelDistL = 0; // memory distance to the next pixel to the left
+
+	// loop conditions depend upon the direction
+	if (direction == directionVertical) {
+		loopBeg = (imageWidth * imageHeight) - 1 - imageWidth;
+		loopEnd = (imageWidth * imageHeight) - 1;
+		loopInc = 1;
+
+		// also set the next pixel distances
+		nextPixelDistR = imageWidth - 1;
+		nextPixelDistC = imageWidth;
+		nextPixelDistL = imageWidth + 1;
+
+		imageSize = imageHeight;
+	} else {
+		loopBeg = imageWidth - 1;
+		loopEnd = (imageWidth * imageHeight) - 0;//1;
+		loopInc = imageWidth;
+
+		// also set the next pixel distances
+		nextPixelDistR = imageWidth + 1;
+		nextPixelDistC = 1;
+		nextPixelDistL = (imageWidth - 1) * -1;
+
+		imageSize = imageWidth;
+	}
+
+	int minValueLocation = 0;
+	// for every pixel in the right-most or bottom-most column of the image
+	for (int k = loopBeg; k < loopEnd; k += loopInc) {
+		// process seams with the lowest weights
+		//if (imageVector[k].seamval <= minValue) {
+			// start from the left-most column
+			minValueLocation = k;
+			countGoR = 0;
+			countGoL = 0;
+
+			// move right-to-left ot bottom-to-top across/up the image
+			//printf("%d\n", (imageSize - 1));
+			for (int j = (imageSize - 1); j > 0; --j) {
+
+				// THIS IS THE CRUCIAL PART
+				if (imageVector[minValueLocation].usecount < (255-SEAM_TRACE_INCREMENT)) {
+					imageVector[minValueLocation].usecount += SEAM_TRACE_INCREMENT;
+					imageVector[minValueLocation].usecountR += SEAM_TRACE_INCREMENT;
+					imageVector[minValueLocation].usecountG += SEAM_TRACE_INCREMENT;
+					imageVector[minValueLocation].usecountB += SEAM_TRACE_INCREMENT;
+				}
+
+				// get the possible next pixles
+				/*
+				if (direction == directionVertical) {
+					if (((minValueLocation - imageWidth + 1) % imageWidth) != 0) {
+						nextPixelR = imageVector[minValueLocation - imageWidth + 1].seamval;
+					} else {
+						nextPixelR = INT_MAX;
+					}
+					nextPixelC = imageVector[minValueLocation - imageWidth].seamval;
+					nextPixelL = imageVector[minValueLocation - imageWidth - 1].seamval;
+				} else {
+					nextPixelR = imageVector[minValueLocation - 1 - imageWidth].seamval;
+					nextPixelC = imageVector[minValueLocation - 1].seamval;
+					if ((k + 1) != loopEnd) {
+						nextPixelL = imageVector[minValueLocation - 1 + imageWidth].seamval;
+					} else {
+						nextPixelL = INT_MAX;
+					}
+				}
+				*/
+	            if ((minValueLocation - nextPixelDistR) > 0) {
+	                nextPixelR = imageVector[minValueLocation - nextPixelDistR].seamval;
+	            } else {
+	                nextPixelR = INT_MAX;
+	            }
+	            nextPixelC = imageVector[minValueLocation - nextPixelDistC].seamval;
+	            if ((minValueLocation - nextPixelDistL) < loopEnd) {
+	                nextPixelL = imageVector[minValueLocation - nextPixelDistL].seamval;
+	            } else {
+	                nextPixelL = INT_MAX;
+	            }
+
+				// use the minimum of the possible pixels
+				currentMin = min3(nextPixelR, nextPixelC, nextPixelL);
+
+				// attempt to make the seam go back down if it was forced up and ice versa
+				// the goal is to end on the same line which the seam started on, this
+				// minimizes crazy diagonal seams which cut out important information
+				if (countGoR == countGoL) {
+					if (currentMin == nextPixelC) {
+						minValueLocation -= nextPixelDistC;
+					} else if (currentMin == nextPixelR) {
+						minValueLocation -= nextPixelDistR;
+						++countGoR;
+					} else if (currentMin == nextPixelL) {
+						minValueLocation -= nextPixelDistL;
+						++countGoL;
+					}
+				} else if (countGoR > countGoL) {
+					if (currentMin == nextPixelL) {
+						minValueLocation -= nextPixelDistL;
+						++countGoL;
+					} else if (currentMin == nextPixelC) {
+						minValueLocation -= nextPixelDistC;
+					} else if (currentMin == nextPixelR) {
+						minValueLocation -= nextPixelDistR;
+						++countGoR;
+					}
+				} else if (countGoR < countGoL) {
+					if (currentMin == nextPixelR) {
+						minValueLocation -= nextPixelDistR;
+						++countGoR;
+					} else if (currentMin == nextPixelC) {
+						minValueLocation -= nextPixelDistC;
+					} else if (currentMin == nextPixelL) {
+						minValueLocation -= nextPixelDistL;
+						++countGoL;
+					}
+				}
+			}
+		//}
+	}
+}
+
+static void setPixelPathVertical(struct pixel *imageVector, int imageWidth, int currentPixel, int currentCol)
+{
+	int pixelAbove = 0;
+	int aboveL = 0;
+	int aboveC = 0;
+	int aboveR = 0;
+	int newValue = 0;
+
+	pixelAbove = currentPixel - imageWidth;
+	// avoid falling off the left end
+	if (currentCol > 0) {
+		// avoid falling off the right end
+		if (currentCol < imageWidth) {
+			aboveL = imageVector[pixelAbove - 1].seamval;
+			aboveC = imageVector[pixelAbove].seamval;
+			aboveR = imageVector[pixelAbove + 1].seamval;
+			newValue = min3(aboveL, aboveC, aboveR);
+		} else {
+			aboveL = imageVector[pixelAbove - 1].seamval;
+			aboveC = imageVector[pixelAbove].seamval;
+			aboveR = INT_MAX;
+			newValue = min(aboveL, aboveC);
+		}
+	} else {
+		aboveL = INT_MAX;
+		aboveC = imageVector[pixelAbove].seamval;
+		aboveR = imageVector[pixelAbove + 1].seamval;
+		newValue = min(aboveC, aboveR);
+	}
+	imageVector[currentPixel].seamval += newValue;
+	//
+	// This (below) is kinda a big deal
+	//
+	if (imageVector[currentPixel].seamval > 0) {
+		imageVector[currentPixel].seamval -= 1;
+	}
+}
+
+static int fillSeamMatrixVertical(struct pixel *imageVector, int imageWidth, int imageHeight)
+{
+	int result = 0;
+	int currentPixel = 0;
+	// do not process the first row, start with j=1
+	for (int j = 1; j < imageHeight; ++j) {
+		for (int i = 0; i < imageWidth; ++i) {
+			currentPixel = (j * imageWidth) + i;
+			setPixelPathVertical(imageVector, imageWidth, currentPixel, i);
+
+			if (imageVector[currentPixel].seamval != 0) {
+				++result;
+			}
+		}
+	}
+	return result;
+}
+
+static void findSeamsVertical(struct pixel *imageVector, int imageWidth, int imageHeight)
+{
+	findSeams(imageVector, imageWidth, imageHeight, 0);
+}
+
+static void setPixelPathHorizontal(struct pixel *imageVector, int imageWidth, int imageHeight, int currentPixel, int currentCol)
+{
+	// avoid falling off the right
+	if (currentCol < imageWidth) {
+		int pixelLeft = 0;
+		int leftT = 0;
+		int leftM = 0;
+		int leftB = 0;
+		int newValue = 0;
+
+		pixelLeft = currentPixel - 1;
+		// avoid falling off the top
+		if (currentPixel > imageWidth) {
+			// avoid falling off the bottom
+			if (currentPixel < ((imageWidth * imageHeight) - imageWidth)) {
+				leftT = imageVector[pixelLeft - imageWidth].seamval;
+				leftM = imageVector[pixelLeft].seamval;
+				leftB = imageVector[pixelLeft + imageWidth].seamval;
+				newValue = min3(leftT, leftM, leftB);
+			} else {
+				leftT = imageVector[pixelLeft - imageWidth].seamval;
+				leftM = imageVector[pixelLeft].seamval;
+				leftB = INT_MAX;
+				newValue = min(leftT, leftM);
+			}
+		} else {
+			leftT = INT_MAX;
+			leftM = imageVector[pixelLeft].seamval;
+			leftB = imageVector[pixelLeft + imageWidth].seamval;
+			newValue = min(leftM, leftB);
+		}
+		imageVector[currentPixel].seamval += newValue;
+		//
+		// This (below) is kinda a big deal
+		//
+		if (imageVector[currentPixel].seamval > 0) {
+			imageVector[currentPixel].seamval -= 1;
+		}
+	}
+}
+
+static int fillSeamMatrixHorizontal(struct pixel *imageVector, int imageWidth, int imageHeight)
+{
+	int result = 0;
+	int currentPixel = 0;
+	// do not process the first row, start with j=1
+	// must be in reverse order from verticle seam, calulate colums as we move across (top down, left to right)
+	for (int i = 0; i < imageWidth; ++i) {
+		for (int j = 1; j < imageHeight; ++j) {
+			currentPixel = (j * imageWidth) + i;
+			setPixelPathHorizontal(imageVector, imageWidth, imageHeight, currentPixel, i);
+
+			if (imageVector[currentPixel].seamval != 0) {
+				++result;
+			}
+		}
+	}
+	return result;
+}
+
+static void findSeamsHorizontal(struct pixel *imageVector, int imageWidth, int imageHeight)
+{
+	findSeams(imageVector, imageWidth, imageHeight, 1);
+}
+
+/*
+ * The main function
+ */
+static int *seamCarve(int *imageVector, int imageWidth, int imageHeight, int imageDepth, int forceBinarization, int forceDirection, int forceEdge, int preGauss)
+{
+	struct pixel *workingImageH = (struct pixel*)xmalloc((unsigned long)imageWidth * (unsigned long)imageHeight * sizeof(struct pixel));
+	struct pixel *workingImageV = (struct pixel*)xmalloc((unsigned long)imageWidth * (unsigned long)imageHeight * sizeof(struct pixel));
+	int *resultImage = (int*)xmalloc((unsigned long)imageWidth * (unsigned long)imageHeight * (unsigned long)imageDepth * sizeof(int));
+
+	int inputPixel = 0;
+	int outputPixel = 0;
+	int currentPixel = 0;
+	// fill initial data structures
+	for (int j = 0; j < imageHeight; ++j) {
+		for (int i = 0; i < imageWidth; ++i) {
+			currentPixel = (j * imageWidth) + i;
+			inputPixel = currentPixel * imageDepth;
+
+			struct pixel newPixelH;
+			newPixelH.r = imageVector[inputPixel];
+			newPixelH.g = imageVector[inputPixel+1];
+			newPixelH.b = imageVector[inputPixel+2];
+			newPixelH.a = 0;//imageVector[inputPixel];
+			newPixelH.bright = imageVector[inputPixel+3];
+			newPixelH.gaussA = 0;
+			newPixelH.gaussB = 0;
+			newPixelH.energy = 0;
+			newPixelH.seamval = 0;
+			newPixelH.usecount = 0;
+			newPixelH.usecountR = 0;
+			newPixelH.usecountG = 0;
+			newPixelH.usecountB = 0;
+			workingImageH[currentPixel] = newPixelH;
+
+			struct pixel newPixelV;
+			newPixelV.r = imageVector[inputPixel];
+			newPixelV.g = imageVector[inputPixel+1];
+			newPixelV.b = imageVector[inputPixel+2];
+			newPixelV.a = 0;//imageVector[inputPixel];
+			newPixelV.bright = imageVector[inputPixel+3];
+			newPixelV.gaussA = 0;
+			newPixelV.gaussB = 0;
+			newPixelV.energy = 0;
+			newPixelV.seamval = 0;
+			newPixelV.usecount = 0;
+			newPixelV.usecountR = 0;
+			newPixelV.usecountG = 0;
+			newPixelV.usecountB = 0;
+			workingImageV[currentPixel] = newPixelV;
+
+			resultImage[inputPixel] = 0;
+		}
+	}
+
+
+	// binarize the image as/if requested
+	if (forceBinarization == 1) {
+		// not really binarized, but brightness passed though a cosine function
+		// this increases differentiation between light and dark pixels
+		int currentBrightness = 0;
+		double currentRadians = 0;
+		for (int j = 0; j < imageHeight; ++j) {
+			for (int i = 0; i < imageWidth; ++i) {
+				currentPixel = (j * imageWidth) + i;
+
+				currentBrightness = workingImageH[currentPixel].bright;
+				currentRadians = ((double)currentBrightness / 255.0) * 3.14159265359;
+				currentBrightness = (int)(((1.0 - cos(currentRadians)) / 2.0) * 255.0);
+
+				workingImageH[currentPixel].bright = currentBrightness;
+				workingImageV[currentPixel].bright = currentBrightness;
+			}
+		}
+
+	} else if (forceBinarization == 2) {
+		int currentBrightness = 0;
+		double currentRadians = 0;
+		for (int j = 0; j < imageHeight; ++j) {
+			for (int i = 0; i < imageWidth; ++i) {
+				currentPixel = (j * imageWidth) + i;
+
+				currentBrightness = workingImageH[currentPixel].bright;
+				currentRadians = ((double)currentBrightness / 255.0) * 3.14159265359;
+				currentBrightness = (int)(((1.0 - cos(currentRadians)) / 2.0) * 255.0);
+
+				currentRadians = ((double)currentBrightness / 255.0) * 3.14159265359;
+				currentBrightness = (int)(((1.0 - cos(currentRadians)) / 2.0) * 255.0);
+
+				workingImageH[currentPixel].bright = currentBrightness;
+				workingImageV[currentPixel].bright = currentBrightness;
+			}
+		}
+
+	} else if (forceBinarization == 3) {
+		int currentBrightness = 0;
+		double currentRadians = 0;
+		for (int j = 0; j < imageHeight; ++j) {
+			for (int i = 0; i < imageWidth; ++i) {
+				currentPixel = (j * imageWidth) + i;
+
+				currentBrightness = workingImageH[currentPixel].bright;
+				currentRadians = ((double)currentBrightness / 255.0) * 3.14159265359;
+				currentBrightness = (int)(((1.0 - cos(currentRadians)) / 2.0) * 255.0);
+
+				currentRadians = ((double)currentBrightness / 255.0) * 3.14159265359;
+				currentBrightness = (int)(((1.0 - cos(currentRadians)) / 2.0) * 255.0);
+
+				currentRadians = ((double)currentBrightness / 255.0) * 3.14159265359;
+				currentBrightness = (int)(((1.0 - cos(currentRadians)) / 2.0) * 255.0);
+
+				workingImageH[currentPixel].bright = currentBrightness;
+				workingImageV[currentPixel].bright = currentBrightness;
+			}
+		}
+
+	} else if (forceBinarization == 4) {
+		int currentBrightness = 0;
+		double currentRadians = 0;
+		for (int j = 0; j < imageHeight; ++j) {
+			for (int i = 0; i < imageWidth; ++i) {
+				currentPixel = (j * imageWidth) + i;
+
+				currentBrightness = workingImageH[currentPixel].bright;
+				currentRadians = ((double)currentBrightness / 255.0) * 3.14159265359;
+				currentBrightness = (int)(((1.0 - cos(currentRadians)) / 2.0) * 255.0);
+
+				currentRadians = ((double)currentBrightness / 255.0) * 3.14159265359;
+				currentBrightness = (int)(((1.0 - cos(currentRadians)) / 2.0) * 255.0);
+
+				currentRadians = ((double)currentBrightness / 255.0) * 3.14159265359;
+				currentBrightness = (int)(((1.0 - cos(currentRadians)) / 2.0) * 255.0);
+
+				currentRadians = ((double)currentBrightness / 255.0) * 3.14159265359;
+				currentBrightness = (int)(((1.0 - cos(currentRadians)) / 2.0) * 255.0);
+
+				workingImageH[currentPixel].bright = currentBrightness;
+				workingImageV[currentPixel].bright = currentBrightness;
+			}
+		}
+
+	} else if (forceBinarization == 5) {
+		// TODO: merge with above loops and below loops (split)
+
+		int bins[256];
+		int currentBrightness = 0;
+
+		// get historgram
+		for (int j = 0; j < imageHeight; ++j) {
+			for (int i = 0; i < imageWidth; ++i) {
+				currentPixel = (j * imageWidth) + i;
+				currentBrightness = workingImageH[currentPixel].bright;
+				bins[currentBrightness] += 1;
+			}
+		}
+
+		int threshold = otsuBinarization(bins, (imageWidth * imageHeight));
+
+		// apply threshold
+		for (int j = 0; j < imageHeight; ++j) {
+			for (int i = 0; i < imageWidth; ++i) {
+				currentPixel = (j * imageWidth) + i;
+				currentBrightness = workingImageH[currentPixel].bright;
+				if (currentBrightness > threshold) {
+					workingImageH[currentPixel].bright = 255;
+				} else {
+					workingImageH[currentPixel].bright = 0;
+				}
+			}
+		}
+	}
+
+	int tmpDoG = 0;
+	int tmpSobel = 0;
+
+	// get energy values using the prescribed method
+	for (int j = 0; j < imageHeight; ++j) {
+		for (int i = 0; i < imageWidth; ++i) {
+			currentPixel = (j * imageWidth) + i;
+
+			if (preGauss == 1) {
+				workingImageH[currentPixel].bright = getPixelGaussian(workingImageH, imageWidth, imageHeight, 1, currentPixel, 20);
+				workingImageV[currentPixel].bright = workingImageH[currentPixel].bright;
+			} else if (preGauss == 2) {
+				workingImageH[currentPixel].bright = getPixelGaussian(workingImageH, imageWidth, imageHeight, 1, currentPixel, 40);
+				workingImageV[currentPixel].bright = workingImageH[currentPixel].bright;
+			} else if (preGauss == 3) {
+				workingImageH[currentPixel].bright = getPixelGaussian(workingImageH, imageWidth, imageHeight, 1, currentPixel, 80);
+				workingImageV[currentPixel].bright = workingImageH[currentPixel].bright;
+			}
+
+			if (forceEdge == 1) {
+				// workingImageH[currentPixel].gaussA = getPixelGaussian(workingImageH, imageWidth, imageHeight, 1, currentPixel, 12);
+				// workingImageH[currentPixel].gaussB = getPixelGaussian(workingImageH, imageWidth, imageHeight, 1, currentPixel, 13);
+				workingImageH[currentPixel].gaussA = getPixelGaussian(workingImageH, imageWidth, imageHeight, 1, currentPixel, 14);
+				workingImageH[currentPixel].gaussB = getPixelGaussian(workingImageH, imageWidth, imageHeight, 1, currentPixel, 16);
+
+				workingImageV[currentPixel].gaussA = workingImageH[currentPixel].gaussA;
+				workingImageV[currentPixel].gaussB = workingImageH[currentPixel].gaussB;
+
+				workingImageH[currentPixel].energy = getPixelEnergyDoG(workingImageH, currentPixel);
+			} else if (forceEdge == 2) {
+				workingImageH[currentPixel].bright = getPixelGaussian(workingImageH, imageWidth, imageHeight, 1, currentPixel, 80);
+				workingImageH[currentPixel].energy = sqrt(getPixelEnergyLaplacian(workingImageH, imageWidth, imageHeight, currentPixel));
+			} else if (forceEdge == 3) {
+				workingImageH[currentPixel].bright = getPixelGaussian(workingImageH, imageWidth, imageHeight, 1, currentPixel, 40);
+				workingImageH[currentPixel].energy = sqrt(getPixelEnergyLaplacian(workingImageH, imageWidth, imageHeight, currentPixel));
+			} else if (forceEdge == 4) {
+				workingImageH[currentPixel].bright = getPixelGaussian(workingImageH, imageWidth, imageHeight, 1, currentPixel, 20);
+				workingImageH[currentPixel].energy = sqrt(getPixelEnergyLaplacian(workingImageH, imageWidth, imageHeight, currentPixel));
+			} else if (forceEdge == 5) {
+				workingImageH[currentPixel].energy = getPixelEnergySobel(workingImageH, imageWidth, imageHeight, currentPixel);
+			} else if (forceEdge == 6) {
+				workingImageH[currentPixel].energy = getPixelGaussian(workingImageH, imageWidth, imageHeight, 1, currentPixel, 9999);
+			} else if (forceEdge == 7) {
+				workingImageH[currentPixel].energy = getPixelEnergySimple(workingImageH, imageWidth, imageHeight, currentPixel, 1);
+			} else if (forceEdge == 8) {
+				workingImageH[currentPixel].gaussA = getPixelGaussian(workingImageH, imageWidth, imageHeight, 1, currentPixel, 14);
+				workingImageH[currentPixel].gaussB = getPixelGaussian(workingImageH, imageWidth, imageHeight, 1, currentPixel, 16);
+
+				workingImageV[currentPixel].gaussA = workingImageH[currentPixel].gaussA;
+				workingImageV[currentPixel].gaussB = workingImageH[currentPixel].gaussB;
+
+				tmpDoG = getPixelEnergyDoG(workingImageH, currentPixel);
+				tmpSobel = getPixelEnergySobel(workingImageH, imageWidth, imageHeight, currentPixel);
+
+				//workingImageH[currentPixel].energy = (tmpDoG + ((tmpSobel / 100) * 20));
+				workingImageH[currentPixel].energy = (tmpDoG + ((tmpSobel / 80) * 20)) / 2;
+			} else if (forceEdge == 9) {
+				workingImageH[currentPixel].bright = getPixelGaussian(workingImageH, imageWidth, imageHeight, 1, currentPixel, 80);
+				tmpDoG = sqrt(getPixelEnergyLaplacian(workingImageH, imageWidth, imageHeight, currentPixel));
+				tmpSobel = getPixelEnergySobel(workingImageH, imageWidth, imageHeight, currentPixel);
+
+				if (tmpDoG && tmpSobel) {
+					workingImageH[currentPixel].energy = (tmpDoG + (tmpSobel / 24));
+					//printf("%d + (%d / 20) = %d \n", tmpDoG, tmpSobel, workingImageH[currentPixel].energy);
+				} else {
+					workingImageH[currentPixel].energy = 0;
+				}
+			}
+
+			workingImageH[currentPixel].seamval = workingImageH[currentPixel].energy;
+			workingImageV[currentPixel].energy = workingImageH[currentPixel].energy;
+			workingImageV[currentPixel].seamval = workingImageV[currentPixel].energy;
+
+			// also grab sobel energy
+			/*
+			workingImageH[currentPixel].sobelA = getPixelEnergySobel(workingImageH, imageWidth, imageHeight, currentPixel);
+			workingImageV[currentPixel].sobelA = workingImageH[currentPixel].sobelA;
+
+			if (workingImageH[currentPixel].sobelA > THRESHHOLD_SOBEL) {
+				workingImageH[currentPixel].energy = workingImageH[currentPixel].sobelA / 4;
+				workingImageH[currentPixel].seamval = workingImageH[currentPixel].energy;
+				workingImageV[currentPixel].energy = workingImageH[currentPixel].sobelA / 4;
+				workingImageV[currentPixel].seamval = workingImageV[currentPixel].energy;
+			}
+			*/
+		}
+	}
+
+	/*
+	for (int j = 0; j < imageHeight; ++j) {
+		for (int i = 0; i < imageWidth; ++i) {
+			currentPixel = (j * imageWidth) + i;
+			workingImageH[currentPixel].energy = getPixelEnergySobel(workingImageH, imageWidth, imageHeight, currentPixel);
+		}
+	}
+	*/
+
+	// find seams in the prescribed direction
+	int resultDirection = 0;
+	if (forceDirection == 1) {
+		fillSeamMatrixHorizontal(workingImageH, imageWidth, imageHeight);
+		findSeamsHorizontal(workingImageH, imageWidth, imageHeight);
+		resultDirection = 1;
+	} else if (forceDirection == 2) {
+		fillSeamMatrixVertical(workingImageV, imageWidth, imageHeight);
+		findSeamsVertical(workingImageV, imageWidth, imageHeight);
+		resultDirection = 2;
+	} else if (forceDirection >= 3) {
+		fillSeamMatrixHorizontal(workingImageH, imageWidth, imageHeight);
+		fillSeamMatrixVertical(workingImageV, imageWidth, imageHeight);
+
+		findSeamsHorizontal(workingImageH, imageWidth, imageHeight);
+		findSeamsVertical(workingImageV, imageWidth, imageHeight);
+
+		resultDirection = forceDirection;
+	} else {
+		int horizontalSeamCost = fillSeamMatrixHorizontal(workingImageH, imageWidth, imageHeight);
+		int verticalSeamCost = fillSeamMatrixVertical(workingImageV, imageWidth, imageHeight);
+		printf("Sum traversal cost of all seams: horizontal = %d, vertical = %d \n", verticalSeamCost, horizontalSeamCost);
+
+		findSeamsHorizontal(workingImageH, imageWidth, imageHeight);
+		findSeamsVertical(workingImageV, imageWidth, imageHeight);
+
+		if (horizontalSeamCost < verticalSeamCost) {
+			resultDirection = 1;
+		} else {
+			resultDirection = 2;
+		}
+	}
+
+	// prepare results for output
+	if (resultDirection == 1) {
+		for (int j = 0; j < imageHeight; ++j) {
+			for (int i = 0; i < imageWidth; ++i) {
+				currentPixel = (j * imageWidth) + i;
+				outputPixel = currentPixel * imageDepth;
+
+				if (workingImageH[currentPixel].usecount > THRESHHOLD_USECOUNT) {
+					resultImage[outputPixel] = 255;
+					resultImage[outputPixel+1] = 0;
+					resultImage[outputPixel+2] = 0;
+					resultImage[outputPixel+3] = 255;
+				} else {
+					resultImage[outputPixel] = workingImageH[currentPixel].r;
+					resultImage[outputPixel+1] = workingImageH[currentPixel].g;
+					resultImage[outputPixel+2] = workingImageH[currentPixel].b;
+					resultImage[outputPixel+3] = 255;
+				}
+			}
+		}
+	} else if (resultDirection == 2) {
+		for (int j = 0; j < imageHeight; ++j) {
+			for (int i = 0; i < imageWidth; ++i) {
+				currentPixel = (j * imageWidth) + i;
+				outputPixel = currentPixel * imageDepth;
+
+				if (workingImageV[currentPixel].usecount > THRESHHOLD_USECOUNT) {
+					resultImage[outputPixel] = 255;
+					resultImage[outputPixel+1] = 0;
+					resultImage[outputPixel+2] = 0;
+					resultImage[outputPixel+3] = 255;
+				} else {
+					resultImage[outputPixel] = workingImageV[currentPixel].r;
+					resultImage[outputPixel+1] = workingImageV[currentPixel].g;
+					resultImage[outputPixel+2] = workingImageV[currentPixel].b;
+					resultImage[outputPixel+3] = 255;
+				}
+			}
+		}
+	} else if (resultDirection == 3) {
+		int currentUseCount = 0;
+		for (int j = 0; j < imageHeight; ++j) {
+			for (int i = 0; i < imageWidth; ++i) {
+				currentPixel = (j * imageWidth) + i;
+				outputPixel = currentPixel * imageDepth;
+
+				currentUseCount = max(workingImageH[currentPixel].usecount, workingImageV[currentPixel].usecount);
+				if (currentUseCount > THRESHHOLD_USECOUNT) {
+					resultImage[outputPixel] = 255;
+					resultImage[outputPixel+1] = 0;
+					resultImage[outputPixel+2] = 0;
+					resultImage[outputPixel+3] = 255;
+				} else {
+					resultImage[outputPixel] = workingImageH[currentPixel].r /1;
+					resultImage[outputPixel+1] = workingImageH[currentPixel].g /1;
+					resultImage[outputPixel+2] = workingImageH[currentPixel].b /1;
+					resultImage[outputPixel+3] = 255;
+				}
+			}
+		}
+	} else if (resultDirection == 4) {
+		int currentUseCount = 0;
+		for (int j = 0; j < imageHeight; ++j) {
+			for (int i = 0; i < imageWidth; ++i) {
+				currentPixel = (j * imageWidth) + i;
+				outputPixel = currentPixel * imageDepth;
+
+				currentUseCount = max(workingImageH[currentPixel].usecount, workingImageV[currentPixel].usecount);
+				if (currentUseCount > 256) {
+					resultImage[outputPixel] = 255;
+					resultImage[outputPixel+1] = 0;
+					resultImage[outputPixel+2] = 0;
+					resultImage[outputPixel+3] = 255;
+				} else {
+					resultImage[outputPixel] = min(max(workingImageH[currentPixel].bright, 0), 255);
+					resultImage[outputPixel+1] = min(max(workingImageH[currentPixel].bright, 0), 255);
+					resultImage[outputPixel+2] = min(max(workingImageH[currentPixel].bright, 0), 255);
+					resultImage[outputPixel+3] = 255;
+				}
+			}
+		}
+	} else if (resultDirection == 5) {
+		int energyScale = 16;
+		int currentUseCount = 0;
+		for (int j = 0; j < imageHeight; ++j) {
+			for (int i = 0; i < imageWidth; ++i) {
+				currentPixel = (j * imageWidth) + i;
+				outputPixel = currentPixel * imageDepth;
+
+				currentUseCount = max(workingImageH[currentPixel].usecount, workingImageV[currentPixel].usecount);
+				if (currentUseCount > 256) {
+					resultImage[outputPixel] = 255;
+					resultImage[outputPixel+1] = 0;
+					resultImage[outputPixel+2] = 0;
+					resultImage[outputPixel+3] = 255;
+				} else {
+					resultImage[outputPixel] = min(max((workingImageH[currentPixel].energy * energyScale), 0), 255);
+					resultImage[outputPixel+1] = min(max((workingImageH[currentPixel].energy * energyScale), 0), 255);
+					resultImage[outputPixel+2] = min(max((workingImageH[currentPixel].energy * energyScale), 0), 255);
+					resultImage[outputPixel+3] = 255;
+				}
+			}
+		}
+	} else if (resultDirection == 6) {
+		int seamValueScale = 16;
+		int currentUseCount = 0;
+		for (int j = 0; j < imageHeight; ++j) {
+			for (int i = 0; i < imageWidth; ++i) {
+				currentPixel = (j * imageWidth) + i;
+				outputPixel = currentPixel * imageDepth;
+
+				currentUseCount = max(workingImageH[currentPixel].usecount, workingImageV[currentPixel].usecount);
+				if (currentUseCount > 256) {
+					resultImage[outputPixel] = 255;
+					resultImage[outputPixel+1] = 0;
+					resultImage[outputPixel+2] = 0;
+					resultImage[outputPixel+3] = 255;
+				} else {
+					resultImage[outputPixel] = min(max((workingImageH[currentPixel].seamval * seamValueScale), 0), 255);
+					resultImage[outputPixel+1] = min(max((workingImageH[currentPixel].seamval * seamValueScale), 0), 255);
+					resultImage[outputPixel+2] = min(max((workingImageH[currentPixel].seamval * seamValueScale), 0), 255);
+					resultImage[outputPixel+3] = 255;
+				}
+			}
+		}
+	} else if (resultDirection == 7) {
+		int seamValueScale = 4;
+		int currentUseCount = 0;
+
+		for (int j = 0; j < imageHeight; ++j) {
+			for (int i = 0; i < imageWidth; ++i) {
+				currentPixel = (j * imageWidth) + i;
+				outputPixel = currentPixel * imageDepth;
+
+				currentUseCount = max(workingImageH[currentPixel].usecount, workingImageV[currentPixel].usecount);
+				if (currentUseCount > 256) {
+					resultImage[outputPixel] = 255;
+					resultImage[outputPixel+1] = 0;
+					resultImage[outputPixel+2] = 0;
+					resultImage[outputPixel+3] = 255;
+				} else {
+					resultImage[outputPixel] = 255-min(max((workingImageH[currentPixel].usecountR), 0), 255);
+					resultImage[outputPixel+1] = 255-min(max((workingImageH[currentPixel].usecountG), 0), 255);
+					resultImage[outputPixel+2] = 255-min(max((workingImageH[currentPixel].usecountB), 0), 255);
+					resultImage[outputPixel+3] = 255;
+				}
+			}
+		}
+	} else if (resultDirection == 8) {
+		int seamValueScale = 4;
+		int currentUseCount = 0;
+
+		for (int j = 0; j < imageHeight; ++j) {
+			for (int i = 0; i < imageWidth; ++i) {
+				currentPixel = (j * imageWidth) + i;
+				outputPixel = currentPixel * imageDepth;
+
+				currentUseCount = max(workingImageH[currentPixel].usecount, workingImageV[currentPixel].usecount);
+				if (currentUseCount > 256) {
+					resultImage[outputPixel] = 255;
+					resultImage[outputPixel+1] = 0;
+					resultImage[outputPixel+2] = 0;
+					resultImage[outputPixel+3] = 255;
+				} else {
+					resultImage[outputPixel] = 255-min(max((workingImageV[currentPixel].usecountR), 0), 255);
+					resultImage[outputPixel+1] = 255-min(max((workingImageV[currentPixel].usecountG), 0), 255);
+					resultImage[outputPixel+2] = 255-min(max((workingImageV[currentPixel].usecountB), 0), 255);
+					resultImage[outputPixel+3] = 255;
+				}
+			}
+		}
+	} else if (resultDirection == 99) {
+		int seamValueScale = 4;
+
+		for (int j = 0; j < imageHeight; ++j) {
+			for (int i = 0; i < imageWidth; ++i) {
+				currentPixel = (j * imageWidth) + i;
+				outputPixel = currentPixel * imageDepth;
+
+				if ((workingImageH[currentPixel].usecountR == 0) && (workingImageH[currentPixel].usecountG == 0) && (workingImageH[currentPixel].usecountB == 0)) {
+					resultImage[outputPixel] = min(max((workingImageH[currentPixel].seamval * 4), 0), 255);
+					resultImage[outputPixel+1] = min(max((workingImageH[currentPixel].seamval * 4), 0), 255);
+					resultImage[outputPixel+2] = min(max((workingImageH[currentPixel].seamval * 4), 0), 255);
+					resultImage[outputPixel+3] = 255;
+				} else {
+					resultImage[outputPixel] = min(max((workingImageH[currentPixel].usecountR), 0), 255);
+					resultImage[outputPixel+1] = 0;//min(max((workingImageH[currentPixel].usecountG), 0), 255);
+					resultImage[outputPixel+2] = 0;//min(max((workingImageH[currentPixel].usecountB), 0), 255);
+					resultImage[outputPixel+3] = 255;
+				}
+			}
+		}
+
+	} else if (resultDirection == 99) {
+		int seamValueScale = 4;
+		int currentUseCount = 0;
+
+		for (int j = 0; j < imageHeight; ++j) {
+			for (int i = 0; i < imageWidth; ++i) {
+				currentPixel = (j * imageWidth) + i;
+				outputPixel = currentPixel * imageDepth;
+
+				// currentUseCount = max(workingImageH[currentPixel].usecount, workingImageV[currentPixel].usecount);
+				currentUseCount = workingImageH[currentPixel].usecount;
+				if (currentUseCount == 0) {
+					resultImage[outputPixel] = 0;
+					resultImage[outputPixel+1] = 0;
+					resultImage[outputPixel+2] = 0;
+					resultImage[outputPixel+3] = 255;
+				} else {
+					resultImage[outputPixel] = 255;
+					resultImage[outputPixel+1] = 255;
+					resultImage[outputPixel+2] = 255;
+					resultImage[outputPixel+3] = 0;
+				}
+			}
+		}
+
+	} else if (resultDirection == 99) {
+		int currentUseCount = 0;
+		for (int j = 0; j < imageHeight; ++j) {
+			for (int i = 0; i < imageWidth; ++i) {
+				currentPixel = (j * imageWidth) + i;
+				outputPixel = currentPixel * imageDepth;
+
+				//currentUseCount = max(workingImageH[currentPixel].usecount, workingImageV[currentPixel].usecount);
+				currentUseCount = min(max((workingImageH[currentPixel].usecount + workingImageV[currentPixel].usecount), 0), 255);
+				resultImage[outputPixel] = 255-currentUseCount;
+				resultImage[outputPixel+1] = 255-currentUseCount;
+				resultImage[outputPixel+2] = 255-currentUseCount;
+				resultImage[outputPixel+3] = 255;
+			}
+		}
+	} else if (resultDirection == 9) {
+		int currentUseCount = 0;
+		for (int j = 0; j < imageHeight; ++j) {
+			for (int i = 0; i < imageWidth; ++i) {
+				currentPixel = (j * imageWidth) + i;
+				outputPixel = currentPixel * imageDepth;
+
+				//currentUseCount = max(workingImageH[currentPixel].usecount, workingImageV[currentPixel].usecount);
+				currentUseCount = min(max((workingImageH[currentPixel].usecount + workingImageV[currentPixel].usecount), 0), 255);
+				if (!currentUseCount) {
+					resultImage[outputPixel] = 0;
+					resultImage[outputPixel+1] = 0;
+					resultImage[outputPixel+2] = 0;
+					resultImage[outputPixel+3] = 255;
+				} else {
+					resultImage[outputPixel] = 255;
+					resultImage[outputPixel+1] = 255;
+					resultImage[outputPixel+2] = 255;
+					resultImage[outputPixel+3] = 255;
+				}
+			}
+		}
+	}
+
+	return resultImage;
+}
+
+#endif


Run destructor when talloc_free()ing a cert

--- src/libec/cert/cert.c
+++ src/libec/cert/cert.c
@@ -41,6 +41,14 @@
   c->valid_from = valid_from ?: time(NULL);
   c->valid_until = valid_until ?: ~0LL;
   c->version = EC_LAYOUT_VERSION;
+
+  //clean up on talloc free
+  int talloc_destructor(void *ptr) {
+    ec_cert_destroy(ptr);
+    return 0;
+  }
+  talloc_set_destructor(c, talloc_destructor);
+
   return c;
 }


remove unused internal function

remove unused internal function

--- arb_poly/zeta_series.c
+++ arb_poly/zeta_series.c
@@ -25,15 +25,6 @@

 #include "arb_poly.h"
 #include "acb_poly.h"
-
-static __inline__ void
-_arb_vec_printd(arb_srcptr vec, slong len, slong digits)
-{
-    slong i;
-    for (i = 0; i < len; i++)
-        arb_printd(vec + i, digits), flint_printf("\n");
-}
-

 /* series of c^(d+x) */
 static __inline__ void


liblink: allow either of a pair of conflicting symbols to say dupok

This makes the linker's -X flag work again.

R=iant
CC=bradfitz, golang-codereviews, golang-dev
https://codereview.appspot.com/44360043

--- src/liblink/objfile.c
+++ src/liblink/objfile.c
@@ -503,7 +503,7 @@
 		v = ctxt->version;
 	s = linklookup(ctxt, name, v);
 	if(s->type != 0 && s->type != SXREF) {
-		if(s->type != SBSS && s->type != SNOPTRBSS && (!dupok || !s->dupok))
+		if(s->type != SBSS && s->type != SNOPTRBSS && !dupok && !s->dupok)
 			sysfatal("duplicate symbol %s (types %d and %d) in %s and %s", s->name, s->type, t, s->file, pn);
 		if(s->np > 0)
 			s = linklookup(ctxt, ".dup", ndup++); // scratch