Save block pointers contents before releasing interrupts so that panic messages are consistent, from mickey@, okay pedro@

--- ufs/ffs/ffs_softdep.c
+++ ufs/ffs/ffs_softdep.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: ffs_softdep.c,v 1.85 2007/04/04 18:53:20 pedro Exp $	*/
+/*	$OpenBSD: ffs_softdep.c,v 1.86 2007/04/15 10:48:35 pedro Exp $	*/

 /*
  * Copyright 1998, 2000 Marshall Kirk McKusick. All Rights Reserved.
@@ -3444,6 +3444,7 @@
 	struct fs *fs;
 #ifdef DIAGNOSTIC
 	ufs_lbn_t prevlbn = 0;
+	ufs1_daddr_t d1, d2;
 #endif
 	int i, deplist;

@@ -3490,18 +3491,18 @@
 		}
 		prevlbn = adp->ad_lbn;
 		if (adp->ad_lbn < NDADDR &&
-		    dp->di_db[adp->ad_lbn] != adp->ad_newblkno) {
+		    (d1 = dp->di_db[adp->ad_lbn]) != (d2 = adp->ad_newblkno)) {
 			FREE_LOCK(&lk);
 			panic("%s: direct pointer #%ld mismatch %d != %d",
-			    "softdep_write_inodeblock", adp->ad_lbn,
-			    dp->di_db[adp->ad_lbn], adp->ad_newblkno);
+			    "softdep_write_inodeblock", adp->ad_lbn, d1, d2);
 		}
 		if (adp->ad_lbn >= NDADDR &&
-		    dp->di_ib[adp->ad_lbn - NDADDR] != adp->ad_newblkno) {
+		    (d1 = dp->di_ib[adp->ad_lbn - NDADDR]) !=
+		    (d2 = adp->ad_newblkno)) {
 			FREE_LOCK(&lk);
 			panic("%s: indirect pointer #%ld mismatch %d != %d",
 			    "softdep_write_inodeblock", adp->ad_lbn - NDADDR,
-			    dp->di_ib[adp->ad_lbn - NDADDR], adp->ad_newblkno);
+			    d1, d2);
 		}
 		deplist |= 1 << adp->ad_lbn;
 		if ((adp->ad_state & ATTACHED) == 0) {
@@ -3590,7 +3591,7 @@
 	struct ufs2_dinode *dp;
 	struct fs *fs = inodedep->id_fs;
 #ifdef DIAGNOSTIC
-	ufs2_daddr_t prevlbn = -1;
+	ufs2_daddr_t prevlbn = -1, d1, d2;
 #endif
 	int deplist, i;

@@ -3636,11 +3637,11 @@
 			panic("softdep_write_inodeblock: lbn order");
 		}
 		prevlbn = adp->ad_lbn;
-		if (dp->di_extb[adp->ad_lbn] != adp->ad_newblkno) {
+		if ((d1 = dp->di_extb[adp->ad_lbn]) !=
+		    (d2 = adp->ad_newblkno)) {
 			FREE_LOCK(&lk);
 			panic("%s: direct pointer #%ld mismatch %ld != %ld",
-			    "softdep_write_inodeblock", adp->ad_lbn,
-			    dp->di_extb[adp->ad_lbn], adp->ad_newblkno);
+			    "softdep_write_inodeblock", adp->ad_lbn, d1, d2);
 		}
 		deplist |= 1 << adp->ad_lbn;
 		if ((adp->ad_state & ATTACHED) == 0) {
@@ -3704,18 +3705,18 @@
 		}
 		prevlbn = adp->ad_lbn;
 		if (adp->ad_lbn < NDADDR &&
-		    dp->di_db[adp->ad_lbn] != adp->ad_newblkno) {
+		    (d1 = dp->di_db[adp->ad_lbn]) != (d2 = adp->ad_newblkno)) {
 			FREE_LOCK(&lk);
 			panic("%s: direct pointer #%ld mismatch %ld != %ld",
-			    "softdep_write_inodeblock", adp->ad_lbn,
-			    dp->di_db[adp->ad_lbn], adp->ad_newblkno);
+			    "softdep_write_inodeblock", adp->ad_lbn, d1, d2);
 		}
 		if (adp->ad_lbn >= NDADDR &&
-		    dp->di_ib[adp->ad_lbn - NDADDR] != adp->ad_newblkno) {
+		    (d1 = dp->di_ib[adp->ad_lbn - NDADDR]) !=
+		    (d2 = adp->ad_newblkno)) {
 			FREE_LOCK(&lk);
 			panic("%s: indirect pointer #%ld mismatch %ld != %ld",
 			    "softdep_write_inodeblock", adp->ad_lbn - NDADDR,
-			   dp->di_ib[adp->ad_lbn - NDADDR], adp->ad_newblkno);
+			    d1, d2);
 		}
 		deplist |= 1 << adp->ad_lbn;
 		if ((adp->ad_state & ATTACHED) == 0) {


Bug 1016836: Remove the unused function swap_in_key_value. r=ryan.sleevi.

--- lib/freebl/rsa.c
+++ lib/freebl/rsa.c
@@ -1353,31 +1353,6 @@
     return rsa_PrivateKeyOp(key, output, input, PR_TRUE);
 }

-static SECStatus
-swap_in_key_value(PLArenaPool *arena, mp_int *mpval, SECItem *buffer)
-{
-    int len;
-    mp_err err = MP_OKAY;
-    memset(buffer->data, 0, buffer->len);
-    len = mp_unsigned_octet_size(mpval);
-    if (len <= 0) return SECFailure;
-    if ((unsigned int)len <= buffer->len) {
-	/* The new value is no longer than the old buffer, so use it */
-	err = mp_to_unsigned_octets(mpval, buffer->data, len);
-	if (err >= 0) err = MP_OKAY;
-	buffer->len = len;
-    } else if (arena) {
-	/* The new value is longer, but working within an arena */
-	(void)SECITEM_AllocItem(arena, buffer, len);
-	err = mp_to_unsigned_octets(mpval, buffer->data, len);
-	if (err >= 0) err = MP_OKAY;
-    } else {
-	/* The new value is longer, no arena, can't handle this key */
-	return SECFailure;
-    }
-    return (err == MP_OKAY) ? SECSuccess : SECFailure;
-}
-
 SECStatus
 RSA_PrivateKeyCheck(RSAPrivateKey *key)
 {


Since __sparc__ gets defined on sparc64 too, add a !defined (__sparc64__)
to the condition that protects CPU_ISSUN4OR4C.  While we currently define
that macro on sparc64 too, we won't in the near future.

ok miod@

--- ufs/ufs/ufs_dirhash.c
+++ ufs/ufs/ufs_dirhash.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ufs_dirhash.c,v 1.14 2006/06/21 09:50:52 mickey Exp $	*/
+/* $OpenBSD: ufs_dirhash.c,v 1.15 2007/07/23 17:28:25 kettenis Exp $	*/
 /*
  * Copyright (c) 2001, 2002 Ian Dowse.  All rights reserved.
  *
@@ -1062,7 +1062,7 @@
 	    "dirhash", &pool_allocator_nointr);
 	pool_sethiwat(&ufsdirhash_pool, 512);
 	TAILQ_INIT(&ufsdirhash_list);
-#if defined (__sparc__)
+#if defined (__sparc__) && !defined (__sparc64__)
 	if (!CPU_ISSUN4OR4C)
 #elif defined (__vax__)
 	if (0)


refdb: add retry logic to the threaded tests

The logic simply consists of retrying for as long as the library says
the data is locked, but it eventually gets through.

--- tests/threads/refdb.c
+++ tests/threads/refdb.c
@@ -52,7 +52,7 @@

 static void *create_refs(void *arg)
 {
-	int i;
+	int i, error;
 	struct th_data *data = (struct th_data *) arg;
 	git_oid head;
 	char name[128];
@@ -70,7 +70,9 @@
 		if (i == 5) {
 			git_refdb *refdb;
 			cl_git_pass(git_repository_refdb(&refdb, repo));
-			cl_git_pass(git_refdb_compress(refdb));
+			do {
+				error = git_refdb_compress(refdb);
+			} while (error == GIT_ELOCKED);
 			git_refdb_free(refdb);
 		}
 	}
@@ -86,7 +88,7 @@

 static void *delete_refs(void *arg)
 {
-	int i;
+	int i, error;
 	struct th_data *data = (struct th_data *) arg;
 	git_reference *ref;
 	char name[128];
@@ -99,14 +101,20 @@
 			name, sizeof(name), "refs/heads/thread-%03d-%02d", (data->id) & ~0x3, i);

 		if (!git_reference_lookup(&ref, repo, name)) {
-			cl_git_pass(git_reference_delete(ref));
+			do {
+				error = git_reference_delete(ref);
+			} while (error == GIT_ELOCKED);
+			cl_git_pass(error);
 			git_reference_free(ref);
 		}

 		if (i == 5) {
 			git_refdb *refdb;
 			cl_git_pass(git_repository_refdb(&refdb, repo));
-			cl_git_pass(git_refdb_compress(refdb));
+			do {
+				error = git_refdb_compress(refdb);
+			} while (error == GIT_ELOCKED);
+			cl_git_pass(error);
 			git_refdb_free(refdb);
 		}
 	}


extend parameter auto-learning to prctl

extend parameter auto-learning to prctl


target: apq8084: Configure VBIF & CLK_CTL for APQ8084

Configure VBIF & CLK_CTL registers for APQ8084
with target specific values before timing
generator enable. This configuration matches
with VBIF & CLK_CTL setting in kernel.

Change-Id: I014be2b805f39da0edeec8ec6f8d772211b94c57

--- target/apq8084/target_display.c
+++ target/apq8084/target_display.c
@@ -211,6 +211,36 @@
 	return NO_ERROR;
 }

+int target_display_pre_on()
+{
+	writel(0x000000FA, MDP_QOS_REMAPPER_CLASS_0);
+	writel(0x00000055, MDP_QOS_REMAPPER_CLASS_1);
+	writel(0xC0000CCD, MDP_CLK_CTRL0);
+	writel(0xD0000CCC, MDP_CLK_CTRL1);
+	writel(0x00CCCCCC, MDP_CLK_CTRL2);
+	writel(0x000000CC, MDP_CLK_CTRL6);
+	writel(0x0CCCC0C0, MDP_CLK_CTRL3);
+	writel(0xCCCCC0C0, MDP_CLK_CTRL4);
+	writel(0xCCCCC0C0, MDP_CLK_CTRL5);
+	writel(0x00CCC000, MDP_CLK_CTRL7);
+
+	writel(0x00000001, VBIF_VBIF_DDR_FORCE_CLK_ON);
+	writel(0x00080808, VBIF_VBIF_IN_RD_LIM_CONF0);
+	writel(0x08000808, VBIF_VBIF_IN_RD_LIM_CONF1);
+	writel(0x00080808, VBIF_VBIF_IN_RD_LIM_CONF2);
+	writel(0x00000808, VBIF_VBIF_IN_RD_LIM_CONF3);
+	writel(0x10000000, VBIF_VBIF_IN_WR_LIM_CONF0);
+	writel(0x00100000, VBIF_VBIF_IN_WR_LIM_CONF1);
+	writel(0x10000000, VBIF_VBIF_IN_WR_LIM_CONF2);
+	writel(0x00000000, VBIF_VBIF_IN_WR_LIM_CONF3);
+	writel(0x00013fff, VBIF_VBIF_ABIT_SHORT);
+	writel(0x000000A4, VBIF_VBIF_ABIT_SHORT_CONF);
+	writel(0x00003FFF, VBIF_VBIF_GATE_OFF_WRREQ_EN);
+	writel(0x00000003, VBIF_VBIF_DDR_RND_RBN_QOS_ARB);
+
+	return NO_ERROR;
+}
+
 void display_init(void)
 {
 	uint32_t ret = 0;


ghash-pclmulqdq: fix one left usage of a __builtin pclmulqdq instead of the _mm version

--- src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq_impl.c
+++ src/crypto/mac/ghash/pclmulqdq/ghash_pclmulqdq_impl.c
@@ -82,7 +82,7 @@
 	__m128i tmph = _mm_srli_si128(h, 8);
 	tmph = _mm_xor_si128(tmph, h);

-	z1 = __builtin_ia32_pclmulqdq128(tmpv, tmph, 0x00);
+	z1 = _mm_clmulepi64_si128(tmpv, tmph, 0x00);
 	z1 = _mm_xor_si128(z1, z0);
 	z1 = _mm_xor_si128(z1, z2);


Cleaned up push instruction unit test

Cleaned up push instruction unit test

--- tests/instructions/test_instructions.c
+++ tests/instructions/test_instructions.c
@@ -17,6 +17,7 @@

 // The instruction locations for the successive instructions after our push
 // to help with addressing and indirection
+static const uint32_t IMMEDIATE = 0;
 static const uint32_t NEXT_INSTR = INSTRUCTION_SIZE;
 static const uint32_t NEXT2_INSTR = INSTRUCTION_SIZE * 2;
 static const uint32_t NEXT3_INSTR = INSTRUCTION_SIZE * 3;
@@ -67,195 +68,113 @@
 }

 /**
- * Tests 'isntr_push()'.
- */
-void test_instr_push()
-{
-    // TODO: Create a util function similiar to pop_test_util()
-
-    // MODE_IMMEDIATE_B
-    allocate();
-    exec(create_instruction(INSTR_PUSH, MODE_IMMEDIATE_B, EMPTY_BYTE,
-                            DUMMY_VALUE_8));
-    CU_ASSERT(DUMMY_VALUE_8 == pop());
-    deallocate();
-
-    // MODE_IMMEDIATE_W
-    allocate();
-    exec(create_instruction(INSTR_PUSH, MODE_IMMEDIATE_W, DUMMY_VALUE_8,
-                            DUMMY_VALUE_8));
-    CU_ASSERT(DUMMY_VALUE_16 == pop());
-    deallocate();
-
-    // MODE_DATA_32
-    allocate();
-    *((uint32_t *) (ram + INSTRUCTION_SIZE)) = DUMMY_VALUE_32;
-    exec(create_instruction(INSTR_PUSH, MODE_DATA_32, EMPTY_BYTE,
-                            EMPTY_BYTE));
-    CU_ASSERT(DUMMY_VALUE_32 == pop());
-    deallocate();
-
-    // MODE_DATA_32_ADDR
-    allocate();
-    // Store address 2*instr in the next instruction (ram[instr])
-    store_dword(ram, NEXT_INSTR, NEXT2_INSTR);
-    // Store a dummy value in ram[instr*2]
-    store_dword(ram, NEXT2_INSTR, DUMMY_VALUE_32);
-    exec(create_instruction(INSTR_PUSH, MODE_DATA_32_ADDR, EMPTY_BYTE,
-                            EMPTY_BYTE));
-    CU_ASSERT(DUMMY_VALUE_32 == pop());
-    deallocate();
-
-    // MODE_DATA_32_ADDR_W
-    allocate();
-    // Store address 2*instr in the next instruction (ram[instr])
-    store_dword(ram, NEXT_INSTR, NEXT2_INSTR);
-    // Store a dummy value in ram[instr*2]
-    store_word(ram, NEXT2_INSTR, DUMMY_VALUE_16);
-    exec(create_instruction(INSTR_PUSH, MODE_DATA_32_ADDR_W, EMPTY_BYTE,
-                            EMPTY_BYTE));
-    CU_ASSERT(DUMMY_VALUE_16 == pop());
-    deallocate();
-
-    // MODE_DATA_32_ADDR_B
-    allocate();
-    // Store address 2*instr in the next instruction (ram[instr])
-    store_dword(ram, NEXT_INSTR, NEXT2_INSTR);
-    // Store a dummy value in ram[instr*2]
-    store_byte(ram, NEXT2_INSTR, DUMMY_VALUE_8);
-    exec(create_instruction(INSTR_PUSH, MODE_DATA_32_ADDR_B, EMPTY_BYTE,
-                            EMPTY_BYTE));
-    CU_ASSERT(DUMMY_VALUE_8 == pop());
-    deallocate();
-
-    // MODE_DATA_32_INDR
-    allocate();
-    // Store address 2*instr in the next instruction (ram[instr])
-    store_dword(ram, NEXT_INSTR, NEXT2_INSTR);
-    // Store address 3*instr in ram[instr*2]
-    store_dword(ram, NEXT2_INSTR, NEXT3_INSTR);
-    // Store a dummy value in ram[instr*4]
-    store_dword(ram, NEXT3_INSTR, DUMMY_VALUE_32);
-    exec(create_instruction(INSTR_PUSH, MODE_DATA_32_INDR, EMPTY_BYTE,
-                            EMPTY_BYTE));
-    CU_ASSERT(DUMMY_VALUE_32 == pop());
-    deallocate();
-
-    // MODE_DATA_32_INDR_W
-    allocate();
-    // Store address 2*instr in the next instruction (ram[instr])
-    store_dword(ram, NEXT_INSTR, NEXT2_INSTR);
-    // Store address 3*instr in ram[instr*2]
-    store_dword(ram, NEXT2_INSTR, NEXT3_INSTR);
-    // Store a dummy value in ram[instr*4]
-    store_word(ram, NEXT3_INSTR, DUMMY_VALUE_16);
-    exec(create_instruction(INSTR_PUSH, MODE_DATA_32_INDR_W, EMPTY_BYTE,
-                            EMPTY_BYTE));
-    CU_ASSERT(DUMMY_VALUE_16 == pop());
-    deallocate();
-
-    // MODE_DATA_32_INDR_B
-    allocate();
-    // Store address 2*instr in the next instruction (ram[instr])
-    store_dword(ram, NEXT_INSTR, NEXT2_INSTR);
-    // Store address 3*instr in ram[instr*2]
-    store_dword(ram, NEXT2_INSTR, NEXT3_INSTR);
-    // Store a dummy value in ram[instr*4]
-    store_byte(ram, NEXT3_INSTR, DUMMY_VALUE_8);
-    exec(create_instruction(INSTR_PUSH, MODE_DATA_32_INDR_B, EMPTY_BYTE,
-                            EMPTY_BYTE));
-    CU_ASSERT(DUMMY_VALUE_8 == pop());
-    deallocate();
-
-    // MODE_REGISTER
-    allocate();
-    r[TEST_REGISTER] = DUMMY_VALUE_32;
-    exec(create_instruction(INSTR_PUSH, MODE_REGISTER, EMPTY_BYTE,
-                            TEST_REGISTER));
-    CU_ASSERT(DUMMY_VALUE_32 == pop());
-    deallocate();
-
-    // MODE_REGISTER_ADDR
-    allocate();
-    // Point register to next instruction
-    r[TEST_REGISTER] = NEXT_INSTR;
-    // Store the dummy value in that next instruction
-    store_dword(ram, NEXT_INSTR, DUMMY_VALUE_32);
-    exec(create_instruction(INSTR_PUSH, MODE_REGISTER_ADDR, EMPTY_BYTE,
-                            TEST_REGISTER));
-    CU_ASSERT(DUMMY_VALUE_32 == pop());
-    deallocate();
-
-    // MODE_REGISTER_ADDR_W
-    allocate();
-    // Point register to next instruction
-    r[TEST_REGISTER] = NEXT_INSTR;
-    // Store the dummy value in that next instruction
-    store_word(ram, NEXT_INSTR, DUMMY_VALUE_16);
-    exec(create_instruction(INSTR_PUSH, MODE_REGISTER_ADDR_W, EMPTY_BYTE,
-                            TEST_REGISTER));
-    CU_ASSERT(DUMMY_VALUE_16 == pop());
-    deallocate();
-
-    // MODE_REGISTER_ADDR_B
-    allocate();
-    // Point register to next instruction
-    r[TEST_REGISTER] = NEXT_INSTR;
-    // Store the dummy value in that next instruction
-    store_byte(ram, NEXT_INSTR, DUMMY_VALUE_8);
-    exec(create_instruction(INSTR_PUSH, MODE_REGISTER_ADDR_B, EMPTY_BYTE,
-                            TEST_REGISTER));
-    CU_ASSERT(DUMMY_VALUE_8 == pop());
-    deallocate();
-
-    // MODE_REGISTER_INDR
-    allocate();
-    // Point register to next instruction
-    r[TEST_REGISTER] = NEXT_INSTR;
-    store_dword(ram, NEXT_INSTR, NEXT2_INSTR);
-    store_dword(ram, NEXT2_INSTR, DUMMY_VALUE_32);
-    exec(create_instruction(INSTR_PUSH, MODE_REGISTER_INDR, EMPTY_BYTE,
-                            TEST_REGISTER));
-    CU_ASSERT(DUMMY_VALUE_32 == pop());
-    deallocate();
-
-    // MODE_REGISTER_INDR_W
-    allocate();
-    // Point register to next instruction
-    r[TEST_REGISTER] = NEXT_INSTR;
-    store_dword(ram, NEXT_INSTR, NEXT2_INSTR);
-    store_word(ram, NEXT2_INSTR, DUMMY_VALUE_16);
-    exec(create_instruction(INSTR_PUSH, MODE_REGISTER_INDR_W, EMPTY_BYTE,
-                            TEST_REGISTER));
-    CU_ASSERT(DUMMY_VALUE_16 == pop());
-    deallocate();
-
-    // MODE_REGISTER_INDR_B
-    allocate();
-    // Point register to next instruction
-    r[TEST_REGISTER] = NEXT_INSTR;
-    store_dword(ram, NEXT_INSTR, NEXT2_INSTR);
-    store_byte(ram, NEXT2_INSTR, DUMMY_VALUE_8);
-    exec(create_instruction(INSTR_PUSH, MODE_REGISTER_INDR_B, EMPTY_BYTE,
-                            TEST_REGISTER));
-    CU_ASSERT(DUMMY_VALUE_8 == pop());
+ * A utility function to avoid duplication when testing push() implementations.
+ *
+ * @param pop_value TODO
+ * @param push_mode TODO
+ * @param storage_location TODO
+ * @param source_location TODO
+ */
+void
+push_test_util(uint32_t pop_value, uint8_t push_mode, uint32_t storage_location,
+               int source_location)
+{
+    allocate();
+
+    if (storage_location != IMMEDIATE)
+    {
+        if (storage_location == NEXT2_INSTR)
+            store_dword(ram, NEXT_INSTR, NEXT2_INSTR);
+
+        if (source_location == SOURCE_IMMEDIATE &&
+            storage_location == NEXT3_INSTR)
+        {
+            store_dword(ram, NEXT_INSTR, NEXT2_INSTR);
+            store_dword(ram, NEXT2_INSTR, NEXT3_INSTR);
+        }
+        else if (source_location == SOURCE_REGISTER)
+            r[TEST_REGISTER] = NEXT_INSTR;
+    }
+
+    switch (pop_value)
+    {
+        case DUMMY_VALUE_8:
+            if (source_location == SOURCE_IMMEDIATE)
+            {
+                store_byte(ram, storage_location, DUMMY_VALUE_8);
+                exec(create_instruction(INSTR_PUSH, push_mode, EMPTY_BYTE,
+                                        DUMMY_VALUE_8));
+            }
+            else if (source_location == SOURCE_REGISTER)
+            {
+                if (storage_location == IMMEDIATE)
+                    r[TEST_REGISTER] = DUMMY_VALUE_8;
+                else
+                    store_byte(ram, storage_location, DUMMY_VALUE_8);
+            }
+            break;
+        case DUMMY_VALUE_16:
+            if (source_location == SOURCE_IMMEDIATE)
+            {
+                store_word(ram, storage_location, DUMMY_VALUE_16);
+                exec(create_instruction(INSTR_PUSH, push_mode, DUMMY_VALUE_8,
+                                        DUMMY_VALUE_8));
+            }
+            else if (source_location == SOURCE_REGISTER)
+            {
+                if (storage_location == IMMEDIATE)
+                    r[TEST_REGISTER] = DUMMY_VALUE_16;
+                else
+                    store_word(ram, storage_location, DUMMY_VALUE_16);
+            }
+            break;
+        case DUMMY_VALUE_32:
+            if (source_location == SOURCE_IMMEDIATE)
+            {
+                store_dword(ram, storage_location, DUMMY_VALUE_32);
+                exec(create_instruction(INSTR_PUSH, push_mode, EMPTY_BYTE,
+                                        EMPTY_BYTE));
+            }
+            else if (source_location == SOURCE_REGISTER)
+            {
+                if (storage_location == IMMEDIATE)
+                    r[TEST_REGISTER] = DUMMY_VALUE_32;
+                else
+                    store_dword(ram, storage_location, DUMMY_VALUE_32);
+            }
+            break;
+        default:
+        CU_FAIL("Invalid pop_value");
+    }
+
+    if (source_location == SOURCE_REGISTER)
+        exec(create_instruction(INSTR_PUSH, push_mode, EMPTY_BYTE,
+                                TEST_REGISTER));
+
+    CU_ASSERT(pop_value == pop());
     deallocate();
 }

 /**
  * A utility function to avoid duplication when testing pop() implementations.
- */
-void pop_test_util(uint32_t push_value, uint8_t pop_mode, uint32_t get_location,
-                   int source)
+ *
+ * @param push_value TODO
+ * @param pop_mode TODO
+ * @param storage_location TODO
+ * @param source_location TODO
+ */
+void
+pop_test_util(uint32_t push_value, uint8_t pop_mode, uint32_t storage_location,
+              int source_location)
 {
     allocate();
     push(push_value);

-    if (source == SOURCE_IMMEDIATE)
+    if (source_location == SOURCE_IMMEDIATE)
     {
         store_dword(ram, NEXT_INSTR, NEXT2_INSTR);

-        if (get_location == NEXT3_INSTR)
+        if (storage_location == NEXT3_INSTR)
             store_dword(ram, NEXT2_INSTR, NEXT3_INSTR);

         exec(create_instruction(INSTR_POP, pop_mode, EMPTY_BYTE,
@@ -266,14 +185,14 @@
         //  We can point the register to next instruction by default
         r[TEST_REGISTER] = NEXT_INSTR;

-        if (get_location == NEXT2_INSTR)
+        if (storage_location == NEXT2_INSTR)
             store_dword(ram, NEXT_INSTR, NEXT2_INSTR);

         exec(create_instruction(INSTR_POP, pop_mode, EMPTY_BYTE,
                                 TEST_REGISTER));
     }

-    if (get_location == REGISTER_LOCATION)
+    if (storage_location == REGISTER_LOCATION)
     {
         CU_ASSERT(push_value == r[TEST_REGISTER]);
     }
@@ -282,13 +201,13 @@
         switch (push_value)
         {
             case DUMMY_VALUE_32:
-            CU_ASSERT(push_value == get_dword(ram, get_location));
+            CU_ASSERT(push_value == get_dword(ram, storage_location));
                 break;
             case DUMMY_VALUE_16:
-            CU_ASSERT(push_value == get_word(ram, get_location));
+            CU_ASSERT(push_value == get_word(ram, storage_location));
                 break;
             case DUMMY_VALUE_8:
-            CU_ASSERT(push_value == get_byte(ram, get_location));
+            CU_ASSERT(push_value == get_byte(ram, storage_location));
                 break;
             default:
             CU_FAIL("Invalid push_value");
@@ -299,6 +218,44 @@
 }

 /**
+ * Tests 'isntr_push()'.
+ */
+void test_instr_push()
+{
+    push_test_util(DUMMY_VALUE_8, MODE_IMMEDIATE_B, IMMEDIATE,
+                   SOURCE_IMMEDIATE);
+    push_test_util(DUMMY_VALUE_16, MODE_IMMEDIATE_W, IMMEDIATE,
+                   SOURCE_IMMEDIATE);
+    push_test_util(DUMMY_VALUE_32, MODE_DATA_32, NEXT_INSTR, SOURCE_IMMEDIATE);
+    push_test_util(DUMMY_VALUE_32, MODE_DATA_32_ADDR, NEXT2_INSTR,
+                   SOURCE_IMMEDIATE);
+    push_test_util(DUMMY_VALUE_16, MODE_DATA_32_ADDR_W, NEXT2_INSTR,
+                   SOURCE_IMMEDIATE);
+    push_test_util(DUMMY_VALUE_8, MODE_DATA_32_ADDR_B, NEXT2_INSTR,
+                   SOURCE_IMMEDIATE);
+    push_test_util(DUMMY_VALUE_32, MODE_DATA_32_INDR, NEXT3_INSTR,
+                   SOURCE_IMMEDIATE);
+    push_test_util(DUMMY_VALUE_16, MODE_DATA_32_INDR_W, NEXT3_INSTR,
+                   SOURCE_IMMEDIATE);
+    push_test_util(DUMMY_VALUE_8, MODE_DATA_32_INDR_B, NEXT3_INSTR,
+                   SOURCE_IMMEDIATE);
+    push_test_util(DUMMY_VALUE_32, MODE_REGISTER, IMMEDIATE,
+                   SOURCE_REGISTER);
+    push_test_util(DUMMY_VALUE_32, MODE_REGISTER_ADDR, NEXT_INSTR,
+                   SOURCE_REGISTER);
+    push_test_util(DUMMY_VALUE_16, MODE_REGISTER_ADDR_W, NEXT_INSTR,
+                   SOURCE_REGISTER);
+    push_test_util(DUMMY_VALUE_8, MODE_REGISTER_ADDR_B, NEXT_INSTR,
+                   SOURCE_REGISTER);
+    push_test_util(DUMMY_VALUE_32, MODE_REGISTER_INDR, NEXT2_INSTR,
+                   SOURCE_REGISTER);
+    push_test_util(DUMMY_VALUE_16, MODE_REGISTER_INDR_W, NEXT2_INSTR,
+                   SOURCE_REGISTER);
+    push_test_util(DUMMY_VALUE_8, MODE_REGISTER_INDR_B, NEXT2_INSTR,
+                   SOURCE_REGISTER);
+}
+
+/**
  * Tests 'isntr_pop()'.
  */
 void test_instr_pop()


Add git r done version of detail::raw_pointer_cast

--HG--
extra : convert_revision : svn%3A83215879-3e5a-4751-8c9d-778f44bb06a5/trunk%40150

error: pathspec 'thrust/detail/casts.h' did not match any file(s) known to git

--- thrust/detail/casts.h
+++ thrust/detail/casts.h
@@ -0,0 +1,68 @@
+/*
+ *  Copyright 2008-2009 NVIDIA Corporation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/*! \file casts.h
+ *  \brief Unsafe casts for internal use.
+ */
+
+#pragma once
+
+#include <thrust/iterator/iterator_traits.h>
+
+namespace thrust
+{
+
+namespace detail
+{
+
+namespace dispatch
+{
+
+template<typename TrivialIterator>
+  typename thrust::iterator_traits<TrivialIterator>::value_type *
+    raw_pointer_cast(TrivialIterator i,
+                     thrust::random_access_host_iterator_tag)
+{
+  typedef typename thrust::iterator_traits<TrivialIterator>::value_type * Pointer;
+
+  // cast away constness
+  return const_cast<Pointer>(&*i);
+} // end raw_pointer_cast()
+
+// this path will work for device_ptr & device_vector::iterator
+template<typename TrivialIterator>
+  typename thrust::iterator_traits<TrivialIterator>::value_type *
+    raw_pointer_cast(TrivialIterator i,
+                     thrust::random_access_device_iterator_tag)
+{
+  typedef typename thrust::iterator_traits<TrivialIterator>::value_type * Pointer;
+
+  // cast away constness
+  return const_cast<Pointer>((&*i).get());
+} // end raw_pointer_cast()
+
+} // end dispatch
+
+template<typename TrivialIterator>
+  typename thrust::iterator_traits<TrivialIterator>::value_type *raw_pointer_cast(TrivialIterator i)
+{
+  return detail::dispatch::raw_pointer_cast(i, thrust::iterator_traits<TrivialIterator>::iterator_category());
+} // end raw_pointer_cast()
+
+} // end detail
+
+} // end thrust
+


Fix Op-Amp control in LCD emulation

Fix Op-Amp control in LCD emulation

--- ti/hardware/display.c
+++ ti/hardware/display.c
@@ -162,7 +162,7 @@
 	} else if (val & 0x20) { // 0b001XXXXX
 		lcd->Y = val & 0x1F;
 		printf("\tLCD: Set Y (horizontal!) to 0x%02X\n", lcd->Y);
-	} else if (val & 0x18) { // 0b00011***
+	} else if ((val & 0x18) == 0x18) { // 0b00011***
 		// test mode - not emulating yet
 	} else if (val & 0x10) { // 0b00010*XX
 		lcd->op_amp1 = val & 0x03;


Patch from sven-ola

Patch from sven-ola

--- lib/httpinfo/src/olsrd_httpinfo.c
+++ lib/httpinfo/src/olsrd_httpinfo.c
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_httpinfo.c,v 1.55 2005/12/16 15:16:42 kattemat Exp $
+ * $Id: olsrd_httpinfo.c,v 1.56 2005/12/17 17:22:26 kattemat Exp $
  */

 /*
@@ -472,9 +472,15 @@
       if(tab_entries[i].filename)
 	{
 #ifdef NETDIRECT
+	  c = build_http_header(HTTP_OK, OLSR_TRUE, size, req, MAX_HTTPREQ_SIZE);
+	  r = send(client_sockets[curr_clients], req, c, 0);
+	  if(r < 0)
+	    {
+	      olsr_printf(1, "(HTTPINFO) Failed sending data to client!\n");
+	      goto close_connection;
+	    }
 	  netsprintf_error = 0;
 	  netsprintf_direct = 1;
-	  c = build_http_header(HTTP_OK, OLSR_TRUE, size, req, MAX_HTTPREQ_SIZE);
 #endif
 	  y = 0;
 	  while(http_ok_head[y])


MAINT: fix casting warnings in mapping.c

--- numpy/core/src/multiarray/mapping.c
+++ numpy/core/src/multiarray/mapping.c
@@ -169,7 +169,8 @@
     int new_ndim, fancy_ndim, used_ndim, index_ndim;
     int curr_idx, get_idx;

-    npy_intp i, n;
+    int i;
+    npy_intp n;

     npy_bool make_tuple = 0;
     PyObject *obj = NULL;
@@ -348,14 +349,15 @@
 #else
             if (PyLong_CheckExact(obj) || !PyArray_Check(obj)) {
 #endif
-                i = PyArray_PyIntAsIntp(obj);
-                if ((i == -1) && PyErr_Occurred()) {
+                npy_intp ind = PyArray_PyIntAsIntp(obj);
+
+                if ((ind == -1) && PyErr_Occurred()) {
                     PyErr_Clear();
                 }
                 else {
                     index_type |= HAS_INTEGER;
                     indices[curr_idx].object = NULL;
-                    indices[curr_idx].value = i;
+                    indices[curr_idx].value = ind;
                     indices[curr_idx].type = HAS_INTEGER;
                     used_ndim += 1;
                     new_ndim += 0;
@@ -527,15 +529,16 @@
                  * sure that array-likes or odder arrays are always
                  * handled right.
                  */
-                i = PyArray_PyIntAsIntp((PyObject *)arr);
+                npy_intp ind = PyArray_PyIntAsIntp((PyObject *)arr);
+
                 Py_DECREF(arr);
-                if ((i == -1) && PyErr_Occurred()) {
+                if ((ind == -1) && PyErr_Occurred()) {
                     goto failed_building_indices;
                 }
                 else {
                     index_type |= (HAS_INTEGER | HAS_SCALAR_ARRAY);
                     indices[curr_idx].object = NULL;
-                    indices[curr_idx].value = i;
+                    indices[curr_idx].value = ind;
                     indices[curr_idx].type = HAS_INTEGER;
                     used_ndim += 1;
                     new_ndim += 0;
@@ -2445,8 +2448,8 @@

         /* advance curr_dim for non-fancy indices */
         else if (indices[i].type == HAS_ELLIPSIS) {
-            curr_dim += indices[i].value;
-            result_dim += indices[i].value;
+            curr_dim += (int)indices[i].value;
+            result_dim += (int)indices[i].value;
         }
         else if (indices[i].type != HAS_NEWAXIS){
             curr_dim += 1;
@@ -2891,7 +2894,7 @@
         stride = extra_op_dtype->elsize;
         for (i=PyArray_NDIM(subspace) - 1; i >= 0; i--) {
             strides[mit->nd_fancy + strideperm[i].perm] = stride;
-            stride *= PyArray_DIM(subspace, strideperm[i].perm);
+            stride *= PyArray_DIM(subspace, (int)strideperm[i].perm);
         }

         /*


httpinfo: also show the position on the 'All' tab

Signed-off-by: Ferry Huberts <66e11f9f5d965b69497c7e73d5e808f8b13c1218@pelagic.nl>

--- lib/httpinfo/src/olsrd_httpinfo.c
+++ lib/httpinfo/src/olsrd_httpinfo.c
@@ -1098,6 +1098,9 @@
   build_neigh_body(abuf);
   build_topo_body(abuf);
   build_mid_body(abuf);
+#ifdef HTTPINFO_PUD
+  build_pud_body(abuf);
+#endif
 }

 #ifdef HTTPINFO_PUD


mmu: pin the whole kernel

mmu: pin the whole kernel

This will enable testing of the implementation until the
critical set of pages is identified and known to the
kernel.

Signed-off-by: Andrew Boie <aab045b28152628be6af0e556050d0381fd0a34d@intel.com>

--- kernel/mmu.c
+++ kernel/mmu.c
@@ -527,8 +527,20 @@
 	 */
 	VIRT_FOREACH(Z_KERNEL_VIRT_START, Z_KERNEL_VIRT_SIZE, addr)
 	{
-		frame_mapped_set(z_phys_to_page_frame(BOOT_VIRT_TO_PHYS(addr)),
-				 addr);
+		pf = z_phys_to_page_frame(BOOT_VIRT_TO_PHYS(addr));
+		frame_mapped_set(pf, addr);
+
+		/* TODO: for now we pin the whole Zephyr image. Demand paging
+		 * currently tested with anonymously-mapped pages which are not
+		 * pinned.
+		 *
+		 * We will need to setup linker regions for a subset of kernel
+		 * code/data pages which are pinned in memory and
+		 * may not be evicted. This will contain critical CPU data
+		 * structures, and any code used to perform page fault
+		 * handling, page-ins, etc.
+		 */
+		pf->flags |= Z_PAGE_FRAME_PINNED;
 	}

 	/* Any remaining pages that aren't mapped, reserved, or pinned get


jsoninfo: downcase plugin keys since they can have any case, and convert int/long values to JSON int

--- lib/jsoninfo/src/olsrd_jsoninfo.c
+++ lib/jsoninfo/src/olsrd_jsoninfo.c
@@ -853,7 +853,21 @@
       abuf_json_open_array_entry(abuf);
       abuf_json_string(abuf, "plugin", pentry->name);
       for (pparam = pentry->params; pparam; pparam = pparam->next) {
-       abuf_json_string(abuf, pparam->key, pparam->value);
+        int i, keylen = strlen(pparam->key);
+        char key[keylen + 1];
+        long value;
+        char valueTest[256];
+        strcpy(key, pparam->key);
+        for (i = 0; i < keylen; i++)
+          key[i] = tolower(key[i]);
+
+        // test if a int/long and set as such in JSON
+        value = atol(pparam->value);
+        snprintf(valueTest, 255, "%li", value);
+        if (strcmp(valueTest, pparam->value) == 0)
+          abuf_json_int(abuf, key, value);
+        else
+          abuf_json_string(abuf, key, pparam->value);
       }
       abuf_json_close_array_entry(abuf);
     }


refactor usbd class drivers hanlding class/interface

--- tinyusb/device/usbd.c
+++ tinyusb/device/usbd.c
@@ -50,6 +50,8 @@
 // MACRO CONSTANT TYPEDEF
 //--------------------------------------------------------------------+
 typedef struct {
+  uint8_t class_code;
+
   void (* init) (void);
   tusb_error_t (* open)(uint8_t rhport, tusb_desc_interface_t const * desc_intf, uint16_t* p_length);
   tusb_error_t (* control_request_st) (uint8_t rhport, tusb_control_request_t const *);
@@ -78,51 +80,46 @@
 tud_desc_init_t _usbd_descs[CONTROLLER_DEVICE_NUMBER];
 usbd_device_info_t usbd_devices[CONTROLLER_DEVICE_NUMBER];

-
-
 static usbd_class_driver_t const usbd_class_drivers[] =
 {
-  #if DEVICE_CLASS_HID
-    [TUSB_CLASS_HID] =
-    {
-        .init                    = hidd_init,
-        .open                    = hidd_open,
-        .control_request_st = hidd_control_request_st,
-        .xfer_cb                 = hidd_xfer_cb,
-        .sof                     = NULL,
-        .close                   = hidd_close
+  #if CFG_TUD_CDC
+    {
+        .class_code         = TUSB_CLASS_CDC,
+        .init               = cdcd_init,
+        .open               = cdcd_open,
+        .control_request_st = cdcd_control_request_st,
+        .xfer_cb            = cdcd_xfer_cb,
+        .sof                = cdcd_sof,
+        .close              = cdcd_close
     },
   #endif

-  #if CFG_TUD_MSC
-    [TUSB_CLASS_MSC] =
-    {
-        .init                    = mscd_init,
-        .open                    = mscd_open,
-        .control_request_st = mscd_control_request_st,
-        .xfer_cb                 = mscd_xfer_cb,
-        .sof                     = NULL,
-        .close                   = mscd_close
+  #if DEVICE_CLASS_HID
+    {
+        .class_code         = TUSB_CLASS_HID,
+        .init               = hidd_init,
+        .open               = hidd_open,
+        .control_request_st = hidd_control_request_st,
+        .xfer_cb            = hidd_xfer_cb,
+        .sof                = NULL,
+        .close              = hidd_close
     },
   #endif

-  #if CFG_TUD_CDC
-    [TUSB_CLASS_CDC] =
-    {
-        .init                    = cdcd_init,
-        .open                    = cdcd_open,
-        .control_request_st = cdcd_control_request_st,
-        .xfer_cb                 = cdcd_xfer_cb,
-        .sof                     = cdcd_sof,
-        .close                   = cdcd_close
+  #if CFG_TUD_MSC
+    {
+        .class_code         = TUSB_CLASS_MSC,
+        .init               = mscd_init,
+        .open               = mscd_open,
+        .control_request_st = mscd_control_request_st,
+        .xfer_cb            = mscd_xfer_cb,
+        .sof                = NULL,
+        .close              = mscd_close
     },
   #endif
-
 };

 enum { USBD_CLASS_DRIVER_COUNT = sizeof(usbd_class_drivers) / sizeof(usbd_class_driver_t) };
-
-

 //tusb_desc_device_qualifier_t _device_qual =
 //{
@@ -227,12 +224,9 @@
   arrclr_( _usbd_descs );

   //------------- class init -------------//
-  for (uint8_t class_code = TUSB_CLASS_AUDIO; class_code < USBD_CLASS_DRIVER_COUNT; class_code++)
-  {
-    if ( usbd_class_drivers[class_code].init )
-    {
-      usbd_class_drivers[class_code].init();
-    }
+  for (uint8_t i = 0; i < USBD_CLASS_DRIVER_COUNT; i++)
+  {
+    usbd_class_drivers[i].init();
   }

   return TUSB_ERROR_NONE;
@@ -270,22 +264,22 @@
   else if (USBD_EVENTID_XFER_DONE == event.event_id)
   {
     // TODO only call respective interface callback
-    // Call class handling function. Those doest not own the endpoint should check and return
-    for (uint8_t class_code = TUSB_CLASS_AUDIO; class_code < USBD_CLASS_DRIVER_COUNT; class_code++)
-    {
-      if ( usbd_class_drivers[class_code].xfer_cb )
-      {
-        usbd_class_drivers[class_code].xfer_cb( event.rhport, event.xfer_done.ep_addr, (tusb_event_t) event.sub_event_id, event.xfer_done.xferred_byte);
+    // Call class handling function. Those does not own the endpoint should check and return
+    for (uint8_t i = 0; i < USBD_CLASS_DRIVER_COUNT; i++)
+    {
+      if ( usbd_class_drivers[i].xfer_cb )
+      {
+        usbd_class_drivers[i].xfer_cb( event.rhport, event.xfer_done.ep_addr, (tusb_event_t) event.sub_event_id, event.xfer_done.xferred_byte);
       }
     }
   }
   else if (USBD_EVENTID_SOF == event.event_id)
   {
-    for (uint8_t class_code = TUSB_CLASS_AUDIO; class_code < USBD_CLASS_DRIVER_COUNT; class_code++)
-    {
-      if ( usbd_class_drivers[class_code].sof )
-      {
-        usbd_class_drivers[class_code].sof( event.rhport );
+    for (uint8_t i = 0; i < USBD_CLASS_DRIVER_COUNT; i++)
+    {
+      if ( usbd_class_drivers[i].sof )
+      {
+        usbd_class_drivers[i].sof( event.rhport );
       }
     }
   }
@@ -352,15 +346,17 @@
   //------------- Class/Interface Specific Request -------------//
   else if ( TUSB_REQ_RCPT_INTERFACE == p_request->bmRequestType_bit.recipient)
   {
-    static uint8_t class_code;
-
-    class_code = usbd_devices[rhport].interface2class[ u16_low_u8(p_request->wIndex) ];
-
-    // TODO [Custom] TUSB_CLASS_DIAGNOSTIC, vendor etc ...
-    if ( (class_code > 0) && (class_code < USBD_CLASS_DRIVER_COUNT) &&
-         usbd_class_drivers[class_code].control_request_st )
-    {
-      STASK_INVOKE( usbd_class_drivers[class_code].control_request_st(rhport, p_request), error );
+    static uint8_t drid;
+    uint8_t const class_code = usbd_devices[rhport].interface2class[ u16_low_u8(p_request->wIndex) ];
+
+    for (drid = 0; drid < USBD_CLASS_DRIVER_COUNT; drid++)
+    {
+      if ( usbd_class_drivers[drid].class_code == class_code ) break;
+    }
+
+    if ( (drid < USBD_CLASS_DRIVER_COUNT) && usbd_class_drivers[drid].control_request_st )
+    {
+      STASK_INVOKE( usbd_class_drivers[drid].control_request_st(rhport, p_request), error );
     }else
     {
       dcd_control_stall(rhport); // Stall unsupported request
@@ -416,18 +412,23 @@
     {
       TU_ASSERT( TUSB_DESC_INTERFACE == p_desc[DESCRIPTOR_OFFSET_TYPE], TUSB_ERROR_NOT_SUPPORTED_YET );

-      uint8_t class_index;
-      tusb_desc_interface_t* p_desc_interface = (tusb_desc_interface_t*) p_desc;
-
-      class_index = p_desc_interface->bInterfaceClass;
-
-      TU_ASSERT( class_index != 0 && class_index < USBD_CLASS_DRIVER_COUNT && usbd_class_drivers[class_index].open != NULL, TUSB_ERROR_NOT_SUPPORTED_YET );
-      TU_ASSERT( 0 == usbd_devices[rhport].interface2class[p_desc_interface->bInterfaceNumber], TUSB_ERROR_FAILED); // duplicate interface number TODO alternate setting
-
-      usbd_devices[rhport].interface2class[p_desc_interface->bInterfaceNumber] = class_index;
+      tusb_desc_interface_t* p_desc_itf = (tusb_desc_interface_t*) p_desc;
+      uint8_t const class_code = p_desc_itf->bInterfaceClass;
+
+      // Check if class is supported
+      uint8_t drid;
+      for (drid = 0; drid < USBD_CLASS_DRIVER_COUNT; drid++)
+      {
+        if ( usbd_class_drivers[drid].class_code == class_code ) break;
+      }
+      TU_ASSERT( drid < USBD_CLASS_DRIVER_COUNT, TUSB_ERROR_NOT_SUPPORTED_YET );
+
+      // duplicate interface number TODO support alternate setting
+      TU_ASSERT( 0 == usbd_devices[rhport].interface2class[p_desc_itf->bInterfaceNumber], TUSB_ERROR_FAILED);
+      usbd_devices[rhport].interface2class[p_desc_itf->bInterfaceNumber] = class_code;

       uint16_t length=0;
-      TU_ASSERT_ERR( usbd_class_drivers[class_index].open( rhport, p_desc_interface, &length ) );
+      TU_ASSERT_ERR( usbd_class_drivers[drid].open( rhport, p_desc_itf, &length ) );

       TU_ASSERT( length >= sizeof(tusb_desc_interface_t), TUSB_ERROR_FAILED );
       p_desc += length;
@@ -509,9 +510,9 @@
       memclr_(&usbd_devices[rhport], sizeof(usbd_device_info_t));
       osal_queue_flush(_usbd_q);
       osal_semaphore_reset(_usbd_ctrl_sem);
-      for (uint8_t class_code = TUSB_CLASS_AUDIO; class_code < USBD_CLASS_DRIVER_COUNT; class_code++)
-      {
-        if ( usbd_class_drivers[class_code].close ) usbd_class_drivers[class_code].close( rhport );
+      for (uint8_t i = 0; i < USBD_CLASS_DRIVER_COUNT; i++)
+      {
+        if ( usbd_class_drivers[i].close ) usbd_class_drivers[i].close( rhport );
       }
     break;


[Issue142] forced add sum file

[Issue142] forced add sum file

error: pathspec 'tofu/geom/_fast_sum.c' did not match any file(s) known to git

--- tofu/geom/_fast_sum.c
+++ tofu/geom/_fast_sum.c
@@ -0,0 +1,27 @@
+// C - algorithm for fast sum of a matrix (similar to np.sum(), sum row by row)
+#define MAX 8
+void sum_rows_blocks(double *orig, double *out, int n_rows, int n_cols){
+   int n_blocks=n_rows/MAX;
+   for (int b=0; b<n_blocks; b++){   //for every block
+       double res[MAX]={0.0};        //initialize to 0.0
+       for(int j=0;j<n_cols;j++){
+           for(int i=0;i<MAX;i++){   //calculate sum for MAX-rows simultaniously
+              res[i]+=orig[(b*MAX+i)*n_cols+j];
+           }
+       }
+       for(int i=0;i<MAX;i++){
+             out[b*MAX+i]=res[i];
+       }
+   }
+   //left_overs:
+   int left=n_rows-n_blocks*MAX;
+   double res[MAX]={0.0};         //initialize to 0.0
+   for(int j=0;j<n_cols;j++){
+       for(int i=0;i<left;i++){   //calculate sum for left rows simultaniously
+              res[i]+=orig[(n_blocks*MAX)*n_cols+j];
+       }
+   }
+   for(int i=0;i<left;i++){
+         out[n_blocks*MAX+i]=res[i];
+   }
+}


Better support for custom types

Better support for custom types

--- tokoloshhead/config.h
+++ tokoloshhead/config.h
@@ -1,10 +1,39 @@
 #ifndef CONFIG_H
 #define CONFIG_H
+#include <QtCore>

-#include <QtCore>
+
+#if 0
+#define CONFIG_REGISTER_TYPE(t) \
+    Q_DECLARE_METATYPE(t); \
+    struct CONFIG_TYPE_#t { \
+        Config {
+};
+#endif
+
+template <typename T>
+class Streamer
+{
+public:
+    static void save(QDataStream &ds, const void *data)
+    {
+        const char *ch = reinterpret_cast<const char *>(data);
+        ds.writeRawData(ch, sizeof(T));
+    }
+    static void load(QDataStream &ds, void *data)
+    {
+        char *ch = reinterpret_cast<char *>(data);
+        ds.readRawData(ch, sizeof(T));
+    }
+};
+
 class Config
 {
 public:
+    template <typename T> static void registerType(const char *name)
+    {
+        QMetaType::registerStreamOperators(name, Streamer<T>::save, Streamer<T>::load);
+    }
     static void setEnabled(const QString &key, bool on)
     {
         Config::setValue(key, on);
@@ -104,7 +133,12 @@
     {
         arguments();
         QSettings *s = settings();
-        s->setValue(key.toLower(), qVariantValue<T>(t));
+        const QVariant var = qVariantFromValue<T>(t);
+        if (var.type() != QVariant::UserType) {
+            s->setValue(key.toLower(), qVariantValue<T>(t));
+        } else {
+            s->setValue(key.toLower(), var);
+        }
         s->sync();
     }


remove declaration for deleted functions

--- kwm/window.h
+++ kwm/window.h
@@ -74,21 +74,15 @@

 bool IsWindowTilable(window_info *Window);
 bool IsWindowTilable(AXUIElementRef WindowRef);
-bool IsWindowResizable(AXUIElementRef WindowRef);
-bool IsWindowMovable(AXUIElementRef WindowRef);
 void CenterWindowInsideNodeContainer(AXUIElementRef WindowRef, int *Xptr, int *Yptr, int *Wptr, int *Hptr);

 void SetWindowDimensions(AXUIElementRef WindowRef, window_info *Window, int X, int Y, int Width, int Height);
 void CenterWindow(screen_info *Screen, window_info *Window);
 void MoveFloatingWindow(int X, int Y);

-int GetWindowIDFromRef(AXUIElementRef WindowRef);
 window_info GetWindowByRef(AXUIElementRef WindowRef);
 window_info *GetWindowByID(int WindowID);
-std::string GetWindowTitle(AXUIElementRef WindowRef);
-CGSize GetWindowSize(AXUIElementRef WindowRef);
 CGPoint GetWindowPos(window_info *Window);
-CGPoint GetWindowPos(AXUIElementRef WindowRef);
 void GetWindowInfo(const void *Key, const void *Value, void *Context);
 bool GetWindowRole(window_info *Window, CFTypeRef *Role, CFTypeRef *SubRole);
 bool GetWindowRef(window_info *Window, AXUIElementRef *WindowRef);


Improve private function documentation.

Improve private function documentation.

--- lib/lha_reader.c
+++ lib/lha_reader.c
@@ -83,7 +83,15 @@
 	LHAFileHeader *dir_stack;
 };

-// Free the current decoder structure and reset the decoder pointer to NULL.
+/**
+ * Free the current decoder structure.
+ *
+ * If the reader has an allocated decoder being used to decompress the
+ * current file, the decoder is freed and the decoder pointer reset
+ * to NULL.
+ *
+ * @param reader         Pointer to the LHA reader structure.
+ */

 static void close_decoder(LHAReader *reader)
 {
@@ -102,8 +110,15 @@
 	}
 }

-// Create the decoder structure to decompress the data from the
-// current file. Returns 1 for success.
+/**
+ * Create the decoder structure to decompress the data from the
+ * current file.
+ *
+ * @param reader         Pointer to the LHA reader structure.
+ * @param callback       Callback function to invoke to track progress.
+ * @param callback_data  Extra pointer to pass to the callback function.
+ * @return               Non-zero for success, zero for failure.
+ */

 static int open_decoder(LHAReader *reader,
                         LHADecoderProgressCallback callback,
@@ -202,7 +217,17 @@
 	reader->dir_policy = policy;
 }

-// Returns true if the top directory in the stack should be popped off.
+/**
+ * Check if the directory at the top of the stack should be popped.
+ *
+ * Extracting a directory is a two stage process; after the directory
+ * is created, it is pushed onto the directory stack. Later the
+ * directory must be popped off the stack and its metadata applied.
+ *
+ * @param reader         Pointer to the LHA reader structure.
+ * @return               Non-zero if there is a directory at the top of
+ *                       the stack that should be popped.
+ */

 static int end_of_top_dir(LHAReader *reader)
 {
@@ -314,11 +339,17 @@
 	return lha_decoder_read(reader->decoder, buf, buf_len);
 }

-// Decompress the current file, invoking the specified callback function
-// to monitor progress (if not NULL). Assumes that open_decoder() has
-// already been called to initialize decode the file. Decompressed data
-// is written to 'output' if it is not NULL.
-// Returns true if the file decompressed successfully.
+/**
+ * Decompress the current file.
+ *
+ * Assumes that @param open_decoder has already been called to
+ * start the decode process.
+ *
+ * @param reader         Pointer to the LHA reader structure.
+ * @param output         FILE handle to write decompressed data, or NULL
+ *                       if the decompressed data should be discarded.
+ * @return               Non-zero if the file decompressed successfully.
+ */

 static int do_decode(LHAReader *reader, FILE *output)
 {
@@ -368,9 +399,14 @@
 	    && do_decode(reader, NULL);
 }

-// Open an output stream into which to decompress the current file.
-// The filename is constructed from the file header of the current file,
-// or 'filename' is used if it is not NULL.
+/**
+ * Open an output stream into which to decompress the current file.
+ *
+ * @param reader         Pointer to the LHA reader structure.
+ * @param filename       Name of the file to open.
+ * @return               FILE handle of the opened file, or NULL in
+ *                       case of failure.
+ */

 static FILE *open_output_file(LHAReader *reader, char *filename)
 {
@@ -388,8 +424,18 @@
 	return lha_arch_fopen(filename, unix_uid, unix_gid, unix_perms);
 }

-// Set file timestamp(s) for the specified file using values from the
-// specified header.
+/**
+ * Set file timestamps for the specified file.
+ *
+ * If possible, the more accurate Windows timestamp values are used;
+ * otherwise normal Unix timestamps are used.
+ *
+ * @param path     Path to the file or directory to set.
+ * @param header   Pointer to file header structure containing the
+ *                 timestamps to set.
+ * @return         Non-zero if the timestamps were set successfully,
+ *                 or zero for failure.
+ */

 static int set_timestamps_from_header(char *path, LHAFileHeader *header)
 {
@@ -410,7 +456,18 @@
 	}
 }

-// Second stage of directory extraction: set metadata.
+/**
+ * Set directory metadata.
+ *
+ * This is the second stage of directory extraction. Metadata (timestamps
+ * and permissions) should be set on a dictory after the contents of
+ * the directory has been extracted.
+ *
+ * @param header     Pointer to file header structure containing the
+ *                   metadata to set.
+ * @param path       Path to the directory on which to set the metadata.
+ * @return           Non-zero for success, or zero for failure.
+ */

 static int set_directory_metadata(LHAFileHeader *header, char *path)
 {
@@ -445,6 +502,21 @@
 	return 1;
 }

+/**
+ * "Extract" (create) a directory.
+ *
+ * The current file is assumed to be a directory. This is the first
+ * stage in extracting a directory; after the directory is created,
+ * it is added to the directory stack so that the metadata apply stage
+ * runs later. (If the LHA_READER_DIR_PLAIN policy is used, metadata
+ * is just applied now).
+ *
+ * @param reader    Pointer to the LHA reader structure.
+ * @param path      Path to the directory, or NULL to use the path from
+ *                  the file header.
+ * @return          Non-zero for success, or zero for failure.
+ */
+
 static int extract_directory(LHAReader *reader, char *path)
 {
 	LHAFileHeader *header;
@@ -493,6 +565,15 @@
 	return 1;
 }

+/**
+ * Get the full path for the given file header.
+ *
+ * @param header     Pointer to the file header structure.
+ * @return           Pointer to an allocated string containing the full
+ *                   file or directory path, or NULL for failure. The
+ *                   string must be freed by the caller.
+ */
+
 static char *full_path_for_header(LHAFileHeader *header)
 {
 	char *result;
@@ -517,6 +598,18 @@
 	}
 }

+/**
+ * Extract the current file.
+ *
+ * @param reader         Pointer to the LHA reader structure.
+ * @param filename       Filename into which to extract the file, or NULL
+ *                       to use the filename from the file header.
+ * @param callback       Callback function to invoke to track progress.
+ * @param callback_data  Extra pointer to pass to the callback function.
+ * @return               Non-zero if the file was successfully extracted,
+ *                       or zero for failure.
+ */
+
 static int extract_file(LHAReader *reader, char *filename,
                         LHADecoderProgressCallback callback,
                         void *callback_data)
@@ -564,6 +657,16 @@
 	return result;
 }

+/**
+ * Extract a Unix symbolic link.
+ *
+ * @param reader         Pointer to the LHA reader structure.
+ * @param filename       Filename into which to extract the symlink, or NULL
+ *                       to use the filename from the file header.
+ * @return               Non-zero if the symlink was extracted successfully,
+ *                       or zero for failure.
+ */
+
 static int extract_symlink(LHAReader *reader, char *filename)
 {
 	char *tmp_filename = NULL;
@@ -589,6 +692,21 @@

 	return result;
 }
+
+/**
+ * Extract a "normal" file.
+ *
+ * This just extracts the file header most recently read by the
+ * BasicReader.
+ *
+ * @param reader         Pointer to the LHA reader structure.
+ * @param filename       Filename into which to extract the file, or NULL
+ *                       to use the filename from the file header.
+ * @param callback       Callback function to invoke to track progress.
+ * @param callback_data  Extra pointer to pass to the callback function.
+ * @return               Non-zero if the file was successfully extracted,
+ *                       or zero for failure.
+ */

 static int extract_normal(LHAReader *reader,
                           char *filename,


Change the return value of kvm_read/kvm_write to be -1 on error, to
match the documented interface.

Previously it returned 0 on error.

PR:		bin/10511

--- lib/libkvm/kvm.c
+++ lib/libkvm/kvm.c
@@ -375,12 +375,12 @@
 		errno = 0;
 		if (lseek(kd->vmfd, (off_t)kva, 0) == -1 && errno != 0) {
 			_kvm_err(kd, 0, "invalid address (%x)", kva);
-			return (0);
+			return (-1);
 		}
 		cc = read(kd->vmfd, buf, len);
 		if (cc < 0) {
 			_kvm_syserr(kd, 0, "kvm_read");
-			return (0);
+			return (-1);
 		} else if (cc < len)
 			_kvm_err(kd, kd->program, "short read");
 		return (cc);
@@ -391,7 +391,7 @@

 			cc = _kvm_kvatop(kd, kva, &pa);
 			if (cc == 0)
-				return (0);
+				return (-1);
 			if (cc > len)
 				cc = len;
 			errno = 0;
@@ -437,19 +437,19 @@
 		errno = 0;
 		if (lseek(kd->vmfd, (off_t)kva, 0) == -1 && errno != 0) {
 			_kvm_err(kd, 0, "invalid address (%x)", kva);
-			return (0);
+			return (-1);
 		}
 		cc = write(kd->vmfd, buf, len);
 		if (cc < 0) {
 			_kvm_syserr(kd, 0, "kvm_write");
-			return (0);
+			return (-1);
 		} else if (cc < len)
 			_kvm_err(kd, kd->program, "short write");
 		return (cc);
 	} else {
 		_kvm_err(kd, kd->program,
 		    "kvm_write not implemented for dead kernels");
-		return (0);
+		return (-1);
 	}
 	/* NOTREACHED */
 }


Merging.

Merging.

--- lib/libmid/gfx.c
+++ lib/libmid/gfx.c
@@ -30,8 +30,10 @@
 		return NULL;

 	gfx.rend = SDL_CreateRenderer(gfx.win, -1, 0);
-	if (!gfx.rend)
+	if (!gfx.rend){
+		SDL_DestroyWindow(gfx.win);
 		return NULL;
+	}

 	return &gfx;
 }
@@ -142,13 +144,21 @@

 Img *txt2img(Gfx *g, Txt *t, const char *s){
 	SDL_Surface *srf = TTF_RenderUTF8_Blended(t->font, s, c2s(t->color));
+<<<<<<< local
+	assert(srf != NULL);
+=======
 	if (!srf)
 		return NULL;
+>>>>>>> other

 	SDL_Texture *tex = SDL_CreateTextureFromSurface(g->rend, srf);
 	SDL_FreeSurface(srf);
+<<<<<<< local
+	assert(tex != NULL);
+=======
 	if (!tex)
 		return NULL;
+>>>>>>> other

 	Img *i = malloc(sizeof(*i));
 	if (!i)


plugins.c (load_plugin): Discard any left-over dlerror messages.
Declare handle variable at start of function to conform to ISO C 90.

git-svn-id: b7def5e201329fdc6881ed493a1f7b725c4b51fb@667 a26ef69c-88ff-0310-839f-98b793d9c207

--- plugins.c
+++ plugins.c
@@ -106,6 +106,7 @@
 load_plugin(struct nsd *nsd, const char *name, const char *arg)
 {
 	nsd_plugin_init_type *init;
+	void *handle;
 	const char *error;
 	const char *init_name = "nsd_plugin_init_" STR(NSD_PLUGIN_INTERFACE_VERSION);
 	const nsd_plugin_descriptor_type *descriptor;
@@ -114,16 +115,19 @@
 		syslog(LOG_ERR, "maximum number of plugins exceeded");
 		return 0;
 	}
+
+	dlerror();		/* Discard previous errors (FreeBSD hack).  */

-	void *handle = dlopen(name, RTLD_NOW);
-	if (!handle) {
-		syslog(LOG_ERR, "failed to load plugin: %s", dlerror());
+	handle = dlopen(name, RTLD_NOW);
+	error = dlerror();
+	if (error) {
+		syslog(LOG_ERR, "failed to load plugin: %s", error);
 		return 0;
 	}

 	init = dlsym(handle, init_name);
 	error = dlerror();
-	if (error != NULL) {
+	if (error) {
 		syslog(LOG_ERR, "no plugin init function: %s", error);
 		dlclose(handle);
 		return 0;


Préparation pour la fonction addpoint

Préparation pour la fonction addpoint

--- polygon.c
+++ polygon.c
@@ -374,7 +374,7 @@

 		}

-		outpoly = addPoint(outpoly, inpoly.head->value);
+		outpoly = addPoint(outpoly, inpoly.head->value, 2);

 	}


Add comment on header

Add comment on header

--- polygon.h
+++ polygon.h
@@ -1,3 +1,12 @@
 /** Author : Paul TREHIOU & Victor SENE
  *  Date : November 2014
- **/+ **/
+
+ /**
+  * Function wich create a point with a specified abscisse and ordinate
+  * abscisse - real
+  * ordinate - real
+  * return a new point
+  */
+
+


Fixed a couple of errors introduced in the last big changeset.  Also, the size_t typesize has been used so as to deal with array lengths.

git-svn-id: 108acfae5aa60014687236af38b4a092d1fda749@177 23631f54-0842-0410-b4f0-d76cd42f001b

--- numexpr/interpreter.c
+++ numexpr/interpreter.c
@@ -936,9 +936,9 @@
 }

 static inline int
-vm_engine_1(int start, int blen, struct vm_params params, int *pc_error)
-{
-    unsigned int index;
+vm_engine_1(size_t start, size_t blen, struct vm_params params, int *pc_error)
+{
+    size_t index;
     for (index = start; index < blen; index += BLOCK_SIZE1) {
 #define VECTOR_SIZE BLOCK_SIZE1
 #include "interp_body.c"
@@ -948,9 +948,9 @@
 }

 static inline int
-vm_engine_2(int start, int blen, struct vm_params params, int *pc_error)
-{
-    unsigned int index;
+vm_engine_2(size_t start, size_t blen, struct vm_params params, int *pc_error)
+{
+    size_t index;
     for (index = start; index < blen; index += BLOCK_SIZE2) {
 #define VECTOR_SIZE BLOCK_SIZE2
 #include "interp_body.c"
@@ -960,10 +960,11 @@
 }

 static inline int
-vm_engine_rest(int start, int blen, struct vm_params params, int *pc_error)
-{
-    unsigned int index = start;
-    unsigned int rest = blen - start;
+vm_engine_rest(size_t start, size_t blen,
+               struct vm_params params, int *pc_error)
+{
+    size_t index = start;
+    size_t rest = blen - start;
 #define VECTOR_SIZE rest
 #include "interp_body.c"
 #undef VECTOR_SIZE
@@ -971,12 +972,12 @@
 }

 static int
-run_interpreter(NumExprObject *self, int len, char *output, char **inputs,
+run_interpreter(NumExprObject *self, size_t len, char *output, char **inputs,
                 struct index_data *index_data, int *pc_error)
 {
     int r;
     Py_ssize_t plen;
-    unsigned int blen1, blen2;
+    size_t blen1, blen2;
     struct vm_params params;

     *pc_error = -1;
@@ -1018,7 +1019,8 @@
     struct index_data *inddata = NULL;
     unsigned int n_inputs, n_dimensions = 0;
     intp shape[MAX_DIMS];
-    int i, j, size, r, pc_error;
+    int i, j, r, pc_error;
+    size_t size;
     char **inputs = NULL;
     intp strides[MAX_DIMS]; /* clean up XXX */


Revert "Add test for constant-time comparison and copy"

This reverts commit 0fe81b0ebf715830907d91749ac5364804e64a26.

--- tests/unit/s2n_cttime_functions_test.c
+++ tests/unit/s2n_cttime_functions_test.c
@@ -1,40 +0,0 @@
-/*
- * Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- *  http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-#include "s2n_test.h"
-
-#include <stdint.h>
-
-#include <utils/s2n_safety.h>
-
-#include "testlib/s2n_testlib.h"
-
-uint8_t dst0[9];
-const uint8_t src[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
-
-int main(int argc, char **argv)
-{
-    uint8_t dst1[9];
-
-    BEGIN_TEST();
-
-    EXPECT_SUCCESS(s2n_constant_time_copy_or_dont(dst1, src, 9, 0 /* do copy */));
-    EXPECT_EQUAL(s2n_constant_time_equals(dst1, src, 9), 1);
-
-    EXPECT_SUCCESS(s2n_constant_time_copy_or_dont(dst0, src, 9, 1 /* don't */));
-    EXPECT_EQUAL(s2n_constant_time_equals(dst0, src, 9), 0);
-
-    END_TEST();
-}


Don't expect NULL terminated name/value in nghttp2_hd_deflate_hd

If it is called through libnghttp2 internally, name/value pairs are
all NULL-terminated.  But it is one of public API, and we cannot
expect that applications always make NULL-terminated string for
name/value pairs.

--- lib/nghttp2_hd.c
+++ lib/nghttp2_hd.c
@@ -509,12 +509,14 @@
       flags = (uint8_t)(flags & ~NGHTTP2_HD_FLAG_NAME_ALLOC);
       ent->nv.name = (uint8_t *)"";
     } else {
-      /* copy including terminating NULL byte */
-      ent->nv.name = nghttp2_memdup(name, namelen + 1, mem);
+      /* name may not be NULL terminated on compression. */
+      ent->nv.name = nghttp2_mem_malloc(mem, namelen + 1);
       if (ent->nv.name == NULL) {
         rv = NGHTTP2_ERR_NOMEM;
         goto fail;
       }
+      memcpy(ent->nv.name, name, namelen);
+      ent->nv.name[namelen] = '\0';
     }
   } else {
     ent->nv.name = name;
@@ -525,12 +527,14 @@
       flags = (uint8_t)(flags & ~NGHTTP2_HD_FLAG_VALUE_ALLOC);
       ent->nv.value = (uint8_t *)"";
     } else {
-      /* copy including terminating NULL byte */
-      ent->nv.value = nghttp2_memdup(value, valuelen + 1, mem);
+      /* value may not be NULL terminated on compression. */
+      ent->nv.value = nghttp2_mem_malloc(mem, valuelen + 1);
       if (ent->nv.value == NULL) {
         rv = NGHTTP2_ERR_NOMEM;
         goto fail2;
       }
+      memcpy(ent->nv.value, value, valuelen);
+      ent->nv.value[valuelen] = '\0';
     }
   } else {
     ent->nv.value = value;
@@ -1429,7 +1433,8 @@
   nghttp2_mem *mem;
   uint32_t hash;

-  DEBUGF(fprintf(stderr, "deflatehd: deflating %s: %s\n", nv->name, nv->value));
+  DEBUGF(fprintf(stderr, "deflatehd: deflating %.*s: %.*s\n", (int)nv->namelen,
+                 nv->name, (int)nv->valuelen, nv->value));

   mem = deflater->ctx.mem;


Use ksl_blk_objalloc_new from ksl_head_init

--- lib/ngtcp2_ksl.c
+++ lib/ngtcp2_ksl.c
@@ -68,10 +68,17 @@
   ksl->n = 0;
 }

+static ngtcp2_ksl_blk *ksl_blk_objalloc_new(ngtcp2_ksl *ksl) {
+  return ngtcp2_objalloc_ksl_blk_len_get(&ksl->blkalloc,
+                                         ksl_blklen(ksl->nodelen));
+}
+
+static void ksl_blk_objalloc_del(ngtcp2_ksl *ksl, ngtcp2_ksl_blk *blk) {
+  ngtcp2_objalloc_ksl_blk_release(&ksl->blkalloc, blk);
+}
+
 static int ksl_head_init(ngtcp2_ksl *ksl) {
-  size_t blklen = ksl_blklen(ksl->nodelen);
-  ngtcp2_ksl_blk *head =
-      ngtcp2_objalloc_ksl_blk_len_get(&ksl->blkalloc, blklen);
+  ngtcp2_ksl_blk *head = ksl_blk_objalloc_new(ksl);
   if (!head) {
     return NGTCP2_ERR_NOMEM;
   }
@@ -92,15 +99,6 @@
   }

   ngtcp2_objalloc_free(&ksl->blkalloc);
-}
-
-static ngtcp2_ksl_blk *ksl_blk_objalloc_new(ngtcp2_ksl *ksl) {
-  return ngtcp2_objalloc_ksl_blk_len_get(&ksl->blkalloc,
-                                         ksl_blklen(ksl->nodelen));
-}
-
-static void ksl_blk_objalloc_del(ngtcp2_ksl *ksl, ngtcp2_ksl_blk *blk) {
-  ngtcp2_objalloc_ksl_blk_release(&ksl->blkalloc, blk);
 }

 /*


Clean up

Clean up

--- lib/ngtcp2_log.c
+++ lib/ngtcp2_log.c
@@ -564,34 +564,7 @@
           log->user_data, (NGTCP2_LOG_TP " supported_version[%zu]=0x%08x\n"),
           NGTCP2_LOG_TP_HD_FIELDS, i, params->v.ee.supported_versions[i]);
     }
-    break;
-  }
-
-  log->log_printf(log->user_data,
-                  (NGTCP2_LOG_TP " initial_max_stream_data_bidi_local=%u\n"),
-                  NGTCP2_LOG_TP_HD_FIELDS,
-                  params->initial_max_stream_data_bidi_local);
-  log->log_printf(log->user_data,
-                  (NGTCP2_LOG_TP " initial_max_stream_data_bidi_remote=%u\n"),
-                  NGTCP2_LOG_TP_HD_FIELDS,
-                  params->initial_max_stream_data_bidi_remote);
-  log->log_printf(log->user_data,
-                  (NGTCP2_LOG_TP " initial_max_stream_data_uni=%u\n"),
-                  NGTCP2_LOG_TP_HD_FIELDS, params->initial_max_stream_data_uni);
-  log->log_printf(log->user_data, (NGTCP2_LOG_TP " initial_max_data=%u\n"),
-                  NGTCP2_LOG_TP_HD_FIELDS, params->initial_max_data);
-  log->log_printf(log->user_data,
-                  (NGTCP2_LOG_TP " initial_max_bidi_streams=%u\n"),
-                  NGTCP2_LOG_TP_HD_FIELDS, params->initial_max_bidi_streams);
-  log->log_printf(log->user_data,
-                  (NGTCP2_LOG_TP " initial_max_uni_streams=%u\n"),
-                  NGTCP2_LOG_TP_HD_FIELDS, params->initial_max_uni_streams);
-  log->log_printf(log->user_data, (NGTCP2_LOG_TP " idle_timeout=%u\n"),
-                  NGTCP2_LOG_TP_HD_FIELDS, params->idle_timeout);
-  log->log_printf(log->user_data, (NGTCP2_LOG_TP " max_packet_size=%u\n"),
-                  NGTCP2_LOG_TP_HD_FIELDS, params->max_packet_size);
-
-  if (exttype == NGTCP2_TRANSPORT_PARAMS_TYPE_ENCRYPTED_EXTENSIONS) {
+
     if (params->stateless_reset_token_present) {
       log->log_printf(log->user_data,
                       (NGTCP2_LOG_TP " stateless_reset_token=0x%s\n"),
@@ -637,8 +610,33 @@
                           buf, params->original_connection_id.data,
                           params->original_connection_id.datalen));
     }
-  }
-
+
+    break;
+  }
+
+  log->log_printf(log->user_data,
+                  (NGTCP2_LOG_TP " initial_max_stream_data_bidi_local=%u\n"),
+                  NGTCP2_LOG_TP_HD_FIELDS,
+                  params->initial_max_stream_data_bidi_local);
+  log->log_printf(log->user_data,
+                  (NGTCP2_LOG_TP " initial_max_stream_data_bidi_remote=%u\n"),
+                  NGTCP2_LOG_TP_HD_FIELDS,
+                  params->initial_max_stream_data_bidi_remote);
+  log->log_printf(log->user_data,
+                  (NGTCP2_LOG_TP " initial_max_stream_data_uni=%u\n"),
+                  NGTCP2_LOG_TP_HD_FIELDS, params->initial_max_stream_data_uni);
+  log->log_printf(log->user_data, (NGTCP2_LOG_TP " initial_max_data=%u\n"),
+                  NGTCP2_LOG_TP_HD_FIELDS, params->initial_max_data);
+  log->log_printf(log->user_data,
+                  (NGTCP2_LOG_TP " initial_max_bidi_streams=%u\n"),
+                  NGTCP2_LOG_TP_HD_FIELDS, params->initial_max_bidi_streams);
+  log->log_printf(log->user_data,
+                  (NGTCP2_LOG_TP " initial_max_uni_streams=%u\n"),
+                  NGTCP2_LOG_TP_HD_FIELDS, params->initial_max_uni_streams);
+  log->log_printf(log->user_data, (NGTCP2_LOG_TP " idle_timeout=%u\n"),
+                  NGTCP2_LOG_TP_HD_FIELDS, params->idle_timeout);
+  log->log_printf(log->user_data, (NGTCP2_LOG_TP " max_packet_size=%u\n"),
+                  NGTCP2_LOG_TP_HD_FIELDS, params->max_packet_size);
   log->log_printf(log->user_data, (NGTCP2_LOG_TP " ack_delay_exponent=%u\n"),
                   NGTCP2_LOG_TP_HD_FIELDS, params->ack_delay_exponent);
   log->log_printf(log->user_data, (NGTCP2_LOG_TP " max_ack_delay=%u\n"),


normalizer: add explicit casts to suppress warnings

--- lib/normalizer.c
+++ lib/normalizer.c
@@ -38,7 +38,7 @@
   GRN_PTR_INIT(&vars[0].value, 0, GRN_ID_NIL);

   if (name_length < 0) {
-    name_length = strlen(name_ptr);
+    name_length = (int)strlen(name_ptr);
   }

   {
@@ -151,7 +151,8 @@
                 if (ch) { ch[-1] += 2; s_ += 2; }
                 continue;
               } else {
-                *d++ = c >> 8; *d = c & 0xff;
+                *d++ = (unsigned char)(c >> 8);
+                *d = (unsigned char)(c & 0xff);
               }
               break;
             case 0xa1eb :
@@ -161,11 +162,13 @@
                 if (ch) { ch[-1] += 2; s_ += 2; }
                 continue;
               } else {
-                *d++ = c >> 8; *d = c & 0xff;
+                *d++ = (unsigned char)(c >> 8);
+                *d = (unsigned char)(c & 0xff);
               }
               break;
             default :
-              *d++ = c >> 8; *d = c & 0xff;
+              *d++ = (unsigned char)(c >> 8);
+              *d = (unsigned char)(c & 0xff);
               break;
             }
             ctype = GRN_CHAR_KATAKANA;
@@ -318,8 +321,9 @@
   }
   if (cp) { *cp = GRN_CHAR_NULL; }
   *d = '\0';
-  nstr->n_characters = length;
-  nstr->normalized_length_in_bytes = (size_t)(d - (unsigned char *)nstr->normalized);
+  nstr->n_characters = (unsigned int)length;
+  nstr->normalized_length_in_bytes =
+    (unsigned int)(d - (unsigned char *)nstr->normalized);
   return NULL;
 }

@@ -392,7 +396,8 @@
             if (ch) { ch[-1]++; s_++; }
             continue;
           } else {
-            *d++ = c >> 8; *d = c & 0xff;
+            *d++ = (unsigned char)(c >> 8);
+            *d = (unsigned char)(c & 0xff);
           }
           break;
         case 0x814b :
@@ -402,11 +407,13 @@
             if (ch) { ch[-1]++; s_++; }
             continue;
           } else {
-            *d++ = c >> 8; *d = c & 0xff;
+            *d++ = (unsigned char)(c >> 8);
+            *d = (unsigned char)(c & 0xff);
           }
           break;
         default :
-          *d++ = c >> 8; *d = c & 0xff;
+          *d++ = (unsigned char)(c >> 8);
+          *d = (unsigned char)(c & 0xff);
           break;
         }
         ctype = GRN_CHAR_KATAKANA;
@@ -554,8 +561,9 @@
   }
   if (cp) { *cp = GRN_CHAR_NULL; }
   *d = '\0';
-  nstr->n_characters = length;
-  nstr->normalized_length_in_bytes = (size_t)(d - (unsigned char *)nstr->normalized);
+  nstr->n_characters = (unsigned int)length;
+  nstr->normalized_length_in_bytes =
+    (unsigned int)(d - (unsigned char *)nstr->normalized);
   return NULL;
 }

@@ -919,7 +927,7 @@
                                          utf8_char[2] <= 0xbd))) {
       /* U+3070 HIRAGANA LETTER BA ..
        * U+307D HIRAGANA LETTER PO */
-      unsigned char mod3 = (utf8_char[2] - 1) % 3;
+      unsigned char mod3 = (unsigned char)((utf8_char[2] - 1) % 3);
       if (mod3 != 0) {
         unified[0] = utf8_char[0];
         unified[1] = utf8_char[1];
@@ -967,7 +975,7 @@
                                          utf8_char[2] <= 0x9d))) {
       /* U+30D0 KATAKANA LETTER BA ..
        * U+30DD KATAKANA LETTER PO */
-      unsigned char mod3 = (utf8_char[2] - 2) % 3;
+      unsigned char mod3 = (unsigned char)((utf8_char[2] - 2) % 3);
       if (mod3 != 0) {
         unified[0] = utf8_char[0];
         unified[1] = utf8_char[1];
@@ -1170,7 +1178,7 @@
     size_t unified_char_length;
     grn_char_type char_type;

-    char_length = grn_charlen_(ctx, current, end, GRN_ENC_UTF8);
+    char_length = (size_t)grn_charlen_(ctx, current, end, GRN_ENC_UTF8);
     unified_char_length = char_length;

     if (data->context.t) {
@@ -1286,7 +1294,7 @@
     unify->d += unified_char_length;
     unify->n_characters++;
     if (unify->t) {
-      *(unify->t++) = char_type;
+      *(unify->t++) = (uint8_t)char_type;
     }
     if (unify->c) {
       size_t i;
@@ -1332,7 +1340,7 @@
 {
   size_t char_length;

-  char_length = grn_charlen_(ctx, current, end, GRN_ENC_UTF8);
+  char_length = (size_t)grn_charlen_(ctx, current, end, GRN_ENC_UTF8);

   *n_used_bytes = char_length;
   *n_used_characters = 1;
@@ -1345,7 +1353,7 @@
     const unsigned char *next = current + char_length;
     size_t next_char_length;

-    next_char_length = grn_charlen_(ctx, next, end, GRN_ENC_UTF8);
+    next_char_length = (size_t)grn_charlen_(ctx, next, end, GRN_ENC_UTF8);
     if (next_char_length == 3 &&
         next[0] == 0xe3 &&
         next[1] == 0x82) {
@@ -1424,7 +1432,7 @@
 {
   size_t char_length;

-  char_length = grn_charlen_(ctx, current, end, GRN_ENC_UTF8);
+  char_length = (size_t)grn_charlen_(ctx, current, end, GRN_ENC_UTF8);
   *n_used_bytes = char_length;
   *n_used_characters = 1;

@@ -1442,7 +1450,7 @@
     unified_buffer[(*n_unified_bytes)++] = 0x96;
     (*n_unified_characters)++;

-    next_char_length = grn_charlen_(ctx, next, end, GRN_ENC_UTF8);
+    next_char_length = (size_t)grn_charlen_(ctx, next, end, GRN_ENC_UTF8);
     if (next_char_length == 3 &&
         next[0] == 0xe3 &&
         next[1] == 0x82 &&
@@ -1506,7 +1514,7 @@
   const bool from_start = (start == current);
   const unsigned char *current_keep = current;
   while (current < end) {
-    size_t char_length = grn_charlen_(ctx, current, end, GRN_ENC_UTF8);
+    size_t char_length = (size_t)grn_charlen_(ctx, current, end, GRN_ENC_UTF8);
     (*n_used_bytes) += char_length;
     (*n_used_characters)++;

@@ -1602,12 +1610,14 @@
           while (unified_current < unified_end) {
             size_t unified_char_length;

-            unified_char_length = grn_charlen_(ctx,
-                                               unified_current,
-                                               unified_end,
-                                               GRN_ENC_UTF8);
+            unified_char_length = (size_t)grn_charlen_(ctx,
+                                                       unified_current,
+                                                       unified_end,
+                                                       GRN_ENC_UTF8);
             if (unify->t) {
-              *(unify->t++) = data->options->char_type_func(unified_current);
+              grn_char_type unified_char_type =
+                data->options->char_type_func(unified_current);
+              *(unify->t++) = (uint8_t)unified_char_type;
             }
             if (unify->c) {
               size_t i;
@@ -1853,14 +1863,15 @@
   source = source_ = (unsigned char *)(data.string->original);
   source_end = source + data.string->original_length_in_bytes;
   for (; source < source_end; source += source_char_length) {
-    source_char_length = grn_charlen_(ctx, source, source_end, GRN_ENC_UTF8);
+    source_char_length =
+      (size_t)grn_charlen_(ctx, source, source_end, GRN_ENC_UTF8);
     if (source_char_length == 0) {
       break;
     }
     if (data.remove_tokenized_delimiter_p &&
         grn_tokenizer_is_tokenized_delimiter(ctx,
                                              (const char *)source,
-                                             source_char_length,
+                                             (unsigned int)source_char_length,
                                              GRN_ENC_UTF8)) {
       continue;
     }
@@ -1899,7 +1910,8 @@
         }
       }
       for (; current < current_end; current += current_length) {
-        current_length = grn_charlen_(ctx, current, current_end, GRN_ENC_UTF8);
+        current_length =
+          (size_t)grn_charlen_(ctx, current, current_end, GRN_ENC_UTF8);
         if (current_length == 0) {
           break;
         }
@@ -1961,9 +1973,10 @@
   if (context->t) { *(context->t) = GRN_CHAR_NULL; }
   if (context->o) { *(context->o) = data.string->original_length_in_bytes; }
   *(context->d) = '\0';
-  data.string->n_characters = context->n_characters;
+  data.string->n_characters = (unsigned int)(context->n_characters);
   data.string->normalized = context->dest;
-  data.string->normalized_length_in_bytes = (size_t)(context->d - context->dest);
+  data.string->normalized_length_in_bytes =
+    (unsigned int)(context->d - context->dest);
   data.string->checks = context->checks;
   data.string->ctypes = context->types;
   data.string->offsets = context->offsets;
@@ -2075,8 +2088,9 @@
   }
   if (cp) { *cp = GRN_CHAR_NULL; }
   *d = '\0';
-  nstr->n_characters = length;
-  nstr->normalized_length_in_bytes = (size_t)(d - (unsigned char *)nstr->normalized);
+  nstr->n_characters = (unsigned int)length;
+  nstr->normalized_length_in_bytes =
+    (unsigned int)(d - (unsigned char *)nstr->normalized);
   return NULL;
 }

@@ -2211,8 +2225,9 @@
   }
   if (cp) { *cp = GRN_CHAR_NULL; }
   *d = '\0';
-  nstr->n_characters = length;
-  nstr->normalized_length_in_bytes = (size_t)(d - (unsigned char *)nstr->normalized);
+  nstr->n_characters = (unsigned int)length;
+  nstr->normalized_length_in_bytes =
+    (unsigned int)(d - (unsigned char *)nstr->normalized);
   return NULL;
 }

@@ -2335,8 +2350,9 @@
   }
   if (cp) { *cp = GRN_CHAR_NULL; }
   *d = '\0';
-  nstr->n_characters = length;
-  nstr->normalized_length_in_bytes = (size_t)(d - (unsigned char *)nstr->normalized);
+  nstr->n_characters = (unsigned int)length;
+  nstr->normalized_length_in_bytes =
+    (unsigned int)(d - (unsigned char *)nstr->normalized);
   return NULL;
 }

@@ -2708,7 +2724,7 @@
             (int)(name_raw.length), name_raw.value);
         break;
       }
-      options->normalized_column = grn_ctx_get(ctx, name, name_length);
+      options->normalized_column = grn_ctx_get(ctx, name, (int)name_length);
       if (!options->normalized_column) {
         ERR(GRN_INVALID_ARGUMENT,
             "%s[%.*s] nonexistent column: <%.*s>",
@@ -2898,7 +2914,7 @@
     grn_obj *target_column = grn_table_column(ctx,
                                               normalized_table,
                                               raw_target_name.value,
-                                              raw_target_name.length);
+                                              (ssize_t)(raw_target_name.length));
     grn_obj_unref(ctx, normalized_table);
     if (!target_column) {
       ERR(GRN_INVALID_ARGUMENT,
@@ -3036,7 +3052,7 @@
     if (data->need_offsets) {
       GRN_UINT64_PUT(ctx,
                      offsets,
-                     source_current - source + current_source_offset);
+                     (uint64_t)(source_current - source) + current_source_offset);
     }
     previous_source_current = source_current;
     source_current += source_char_length;
@@ -3067,7 +3083,7 @@
             source_current);
         return;
       }
-      GRN_INT16_VALUE_AT(checks, last_check_index) += source_char_length;
+      GRN_INT16_VALUE_AT(checks, last_check_index) += (int16_t)source_char_length;
       source_current += source_char_length;
     }
   } else if (normalized_current < normalized_end) {
@@ -3093,7 +3109,8 @@
       if (data->need_offsets) {
         GRN_UINT64_PUT(ctx,
                        offsets,
-                       previous_source_current - source + current_source_offset);
+                       (uint64_t)(previous_source_current - source) +
+                       current_source_offset);
       }
       normalized_current += normalized_char_length;
       if (data->count_n_normalized_characters_in_checks) {
@@ -3199,13 +3216,14 @@
 #define MAX_N_HITS 16
     grn_pat_scan_hit hits[MAX_N_HITS];
     const char *rest;
-    unsigned int i, n_hits;
+    int i, n_hits;
     unsigned int previous = 0;
     size_t chunk_length;

     n_hits = grn_pat_scan(ctx,
                           (grn_pat *)(options->target_table),
-                          source, source_end - source,
+                          source,
+                          (unsigned int)(source_end - source),
                           hits,
                           MAX_N_HITS,
                           &rest);
@@ -3233,7 +3251,7 @@
                                                    hits[i].id,
                                                    GRN_ID_NIL,
                                                    GRN_ID_MAX,
-                                                   ii->n_elements,
+                                                   (int)(ii->n_elements),
                                                    0);
         if (cursor) {
           grn_posting *ii_posting;
@@ -3274,10 +3292,10 @@
       previous = hits[i].offset + hits[i].length;
     }

-    chunk_length = rest - source;
+    chunk_length = (size_t)(rest - source);
     if (chunk_length - previous > 0) {
       const char *source_previous = source + previous;
-      size_t source_previous_length = source_end - source - previous;
+      size_t source_previous_length = (size_t)(source_end - source - previous);
       GRN_TEXT_PUT(ctx, normalized, source_previous, source_previous_length);
       table_normalize_added(ctx,
                             &data,
@@ -3312,8 +3330,8 @@
     }
   }

-  string->n_characters = data.n_normalized_characters;
-  string->normalized_length_in_bytes = GRN_TEXT_LEN(normalized);
+  string->n_characters = (unsigned int)(data.n_normalized_characters);
+  string->normalized_length_in_bytes = (unsigned int)GRN_TEXT_LEN(normalized);
   string->normalized = grn_bulk_detach(ctx, normalized);

   if (data.need_checks) {


Add a checkpoint save before exiting

Add a checkpoint save before exiting

--- v/loop.c
+++ v/loop.c
@@ -477,6 +477,8 @@
     u3t_damp();
     u3_lo_exit();

+    //  save a checkpoint before exiting
+    u3e_save();
     exit(u3_Host.xit_i);
   }
   else {


Remove unused arms from arvo external core.

--- v/reck.c
+++ v/reck.c
@@ -121,7 +121,7 @@
 static u2_noun
 _reck_nock_poke(u2_reck* rec_u, u2_noun ovo)
 {
-  u2_noun fun = u2_cn_nock(u2k(rec_u->roc), u2k(u2_cx_at(42, rec_u->roc)));
+  u2_noun fun = u2_cn_nock(u2k(rec_u->roc), u2k(u2_cx_at(22, rec_u->roc)));
   u2_noun sam, pro;

   sam = u2nc(u2k(rec_u->now), ovo);
@@ -156,7 +156,7 @@
 static u2_noun
 _reck_nock_peek(u2_reck* rec_u, u2_noun hap)
 {
-  u2_noun fun = u2_cn_nock(u2k(rec_u->roc), u2k(u2_cx_at(87, rec_u->roc)));
+  u2_noun fun = u2_cn_nock(u2k(rec_u->roc), u2k(u2_cx_at(23, rec_u->roc)));
   u2_noun sam = u2nc(u2k(rec_u->now), hap);

   return u2_cn_mung(fun, sam);
@@ -178,7 +178,7 @@
 static u2_noun
 _reck_nock_wish(u2_reck* rec_u, u2_noun txt)
 {
-  u2_noun fun = u2_cn_nock(u2k(rec_u->roc), u2k(u2_cx_at(20, rec_u->roc)));
+  u2_noun fun = u2_cn_nock(u2k(rec_u->roc), u2k(u2_cx_at(10, rec_u->roc)));

   return u2_cn_mung(fun, txt);
 }


Remove some ames printfs; fix a warning.

--- v/sist.c
+++ v/sist.c
@@ -894,7 +894,7 @@
     ent_w = 0;

     if ( -1 == lseek64(fid_i, 4ULL * end_d, SEEK_SET) ) {
-      fprintf(stderr, "end_d %llx\n", end_d);
+      fprintf(stderr, "end_d %llu\n", end_d);
       perror("lseek");
       uL(fprintf(uH, "record (%s) is corrupt (c)\n", ful_c));
       u2_lo_bail(rec_u);


fuse_buf_copy: check if buffers are the same

When copying fuse buffers, check if the source and destination are the
same and omit the copy as appropriate.  Also check if the source and
destination memory regions overlap and use memmove in that case.

--- lib/buffer.c
+++ lib/buffer.c
@@ -217,7 +217,16 @@
 	int dst_is_fd = dst->flags & FUSE_BUF_IS_FD;

 	if (!src_is_fd && !dst_is_fd) {
-		memcpy(dst->mem + dst_off, src->mem + src_off, len);
+		void *dstmem = dst->mem + dst_off;
+		void *srcmem = src->mem + src_off;
+
+		if (dstmem != srcmem) {
+			if (dstmem + len <= srcmem || srcmem + len <= dstmem)
+				memcpy(dstmem, srcmem, len);
+			else
+				memmove(dstmem, srcmem, len);
+		}
+
 		return len;
 	} else if (!src_is_fd) {
 		return fuse_buf_write(dst, dst_off, src, src_off, len);
@@ -259,6 +268,9 @@
 {
 	size_t copied = 0;

+	if (dstv == srcv)
+		return fuse_buf_size(dstv);
+
 	for (;;) {
 		const struct fuse_buf *src = fuse_bufvec_current(srcv);
 		const struct fuse_buf *dst = fuse_bufvec_current(dstv);


try to avoid fs caching on various platforms

--- v/sist.c
+++ v/sist.c
@@ -551,14 +551,24 @@

   //  Create the record file.
   {
+    c3_i pig_i = O_CREAT | O_WRONLY | O_EXCL;
+#ifdef O_DSYNC
+    pig_i |= O_DSYNC;
+#endif
     snprintf(ful_c, 2048, "%s/.urb/egz.hope", u2_Host.cpu_c);

-    if ( ((fid_i = open(ful_c, O_CREAT | O_WRONLY | O_EXCL, 0600)) < 0) ||
+    if ( ((fid_i = open(ful_c, pig_i, 0600)) < 0) ||
          (fstat(fid_i, &buf_b) < 0) )
     {
       uL(fprintf(uH, "can't create record (%s)\n", ful_c));
       u2_lo_bail(rec_u);
     }
+#ifdef F_NOCACHE
+    if ( -1 == fcntl(fid_i, F_NOCACHE, 1) ) {
+      uL(fprintf(uH, "zest: can't uncache %s: %s\n", ful_c, strerror(errno)));
+      u2_lo_bail(rec_u);
+    }
+#endif
     u2R->lug_u.fid_i = fid_i;
   }

@@ -804,16 +814,25 @@

   //  Open the fscking file.  Does it even exist?
   {
+    c3_i pig_i = O_RDWR;
+#ifdef O_DSYNC
+    pig_i |= O_DSYNC;
+#endif
     snprintf(ful_c, 2048, "%s/.urb/egz.hope", u2_Host.cpu_c);
-
-    if ( ((fid_i = open(ful_c, O_RDWR)) < 0) ||
-         (fstat(fid_i, &buf_b) < 0) )
-    {
+    if ( ((fid_i = open(ful_c, pig_i)) < 0) || (fstat(fid_i, &buf_b) < 0) ) {
       uL(fprintf(uH, "rest: can't open record (%s)\n", ful_c));
       u2_lo_bail(rec_u);

       return;
     }
+#ifdef F_NOCACHE
+    if ( -1 == fcntl(fid_i, F_NOCACHE, 1) ) {
+      uL(fprintf(uH, "rest: can't uncache %s: %s\n", ful_c, strerror(errno)));
+      u2_lo_bail(rec_u);
+
+      return;
+    }
+#endif
     u2R->lug_u.fid_i = fid_i;
     u2R->lug_u.len_d = ((buf_b.st_size + 3ULL) >> 2ULL);
   }


attempt to sync out files at toplevel

attempt to sync out files at toplevel

--- v/unix.c
+++ v/unix.c
@@ -13,7 +13,6 @@
 #include <dirent.h>
 #include <stdint.h>
 #include <uv.h>
-#include <curses.h>
 #include <termios.h>
 #include <term.h>
 #include <errno.h>
@@ -990,10 +989,17 @@
 static void
 _unix_desk_sync_tako(u2_udir* dir_u, u2_noun pax, u2_noun mis)
 {
-  if ( (u2_no == u2du(pax)) || u2_no == u2du(u2t(pax)) ) {
-    c3_assert(0);
-
-    u2z(pax); u2z(mis);
+  if ( (u2_no == u2du(pax)) ) {
+    c3_assert(!"tack");
+  }
+  else if ( u2_no == u2du(u2t(pax)) ) {                //  at toplevel
+    u2_noun i_pax = u2h(pax);
+    u2_noun t_pax = u2t(pax);
+    c3_c* par_u = strrchr(dir_u->pax_c, '/');
+    u2_noun pem = u2_ci_string(par_u);
+    c3_assert( u2_nul == t_pax );                      //  XX ugly, wrong
+
+    _unix_desk_sync_tofu(dir_u->par_u, pem, u2k(i_pax), mis);
   }
   else {
     u2_noun i_pax = u2h(pax);


ptrace: do not print arguments of PTRACE_TRACEME request

As kernel ignores arguments of PTRACE_TRACEME request,
we do not print them either.

* process.c (SYS_FUNC(ptrace)): If request is PTRACE_TRACEME,
return early with RVAL_DECODED.

--- process.c
+++ process.c
@@ -91,6 +91,11 @@
 		/* request */
 		printxval64(ptrace_cmds, request, "PTRACE_???");

+		if (request == PTRACE_TRACEME) {
+			/* pid, addr, and data are ignored. */
+			return RVAL_DECODED;
+		}
+
 		/* pid */
 		tprintf(", %d, ", pid);


vestli: don't abort on invalid direction

--- vestli.c
+++ vestli.c
@@ -78,8 +78,6 @@
             adeps[anumdeps++] = deps[i];
         else if(deps[i].direction == 2)
             bdeps[bnumdeps++] = deps[i];
-        else
-            assert(!"Invalid direction");
     }
 }


1) use freeHeader(), not free() after writeheader() 2) free iterators in copyHeader() 3) free string arrays after interation

--- lib/header.c
+++ lib/header.c
@@ -159,9 +159,14 @@
     /* The result here is that the data is also sorted */
     while (nextIterator(headerIter, &tag, &type, &ptr, &count)) {
 	addEntry(res, tag, type, ptr, count);
+
+	if (type == STRING_ARRAY_TYPE) free(ptr);
     }

     res->fully_sorted = 1;
+
+    freeIterator(headerIter);
+
     return res;
 }

@@ -223,7 +228,7 @@
     write(fd, converted_data, h->data_used);
     free(converted_data);

-    free(h);
+    freeHeader(h);
 }

 static void *dataHostToNetwork(Header h)


don't strlen(NULL) in copyData()

don't strlen(NULL) in copyData()

--- lib/header.c
+++ lib/header.c
@@ -738,7 +738,7 @@
 	src = (char **) srcPtr;
 	dst = dstPtr;
 	while (i--) {
-	    len = strlen(*src) + 1;
+	    len = *src ? strlen(*src) + 1 : 0;
 	    memcpy(dst, *src, len);
 	    dst += len;
 	    src++;


Fix boost version compat issue.

Fix boost version compat issue.

Summary: The OSS build uses Boost 1.65.1 (the version shipped with Ubuntu 18.04), but boost::optional::has_value was only added later.

Reviewed By: yfeldblum

Differential Revision: D26905507

fbshipit-source-id: 06debba2262ad7d8b939d7e73daf0cb633844a43

--- thrift/compiler/parse/parsing_driver.h
+++ thrift/compiler/parse/parsing_driver.h
@@ -524,7 +524,7 @@
   // takes ownership of node.
   template <typename T>
   bool should_add_node(std::unique_ptr<T>& node, t_doc&& doc) {
-    if (doc.has_value()) {
+    if (doc) {
       node->set_doc(std::move(*doc));
     }
     if (mode != parsing_mode::PROGRAM) {


Remove processSerializedRequest from RustAsyncProcessor

Summary:
This diff is a part of a series that aims to deprecate `AsyncPocessor::processSerializedRequest`. This is [step 1.4](https://fb.quip.com/cqP7Ap4UPLY8#temp:C:aAN7eafcef22d9042a3ab06073ae) of [this plan](https://fb.quip.com/cqP7Ap4UPLY8).

At this point **every** AsyncProcessor implements `processSerializedCompressedRequestWithMetadata`, and we can remove usages of `processSerializedRequest`.

Reviewed By: Imxset21

Differential Revision: D38714065

fbshipit-source-id: cdb709dd0d34a80bcd12545697e84be202c22a5d

--- thrift/lib/cpp2/async/AsyncProcessor.h
+++ thrift/lib/cpp2/async/AsyncProcessor.h
@@ -666,13 +666,13 @@

   // TODO(praihan): This function will be removed once we enforce that
   // createMethodMetadata is always implemented correctly.
-  void processSerializedCompressedRequest(
-      ResponseChannelRequest::UniquePtr req,
-      SerializedCompressedRequest&& serializedRequest,
-      protocol::PROTOCOL_TYPES prot_type,
-      Cpp2RequestContext* context,
-      folly::EventBase* eb,
-      concurrency::ThreadManager* tm) override = 0;
+  // void processSerializedCompressedRequest(
+  //     ResponseChannelRequest::UniquePtr req,
+  //     SerializedCompressedRequest&& serializedRequest,
+  //     protocol::PROTOCOL_TYPES prot_type,
+  //     Cpp2RequestContext* context,
+  //     folly::EventBase* eb,
+  //     concurrency::ThreadManager* tm) override = 0;

   // Sends an error response if validation fails.
   static bool validateRpcKind(


libsig/sig.h minor doxy syntax fixes

libsig/sig.h minor doxy syntax fixes

--- libsig/sig.h
+++ libsig/sig.h
@@ -55,7 +55,7 @@
 \par Positions

 \arg _Location_: dat::RowCol: identify Elem in Full - classic (row,col) indexing
-\arg _Spot: dat::Spot: Location within 2D signal with sub-Elem precision.
+\arg _Spot_: dat::Spot: Location within 2D signal with sub-Elem precision.

 \par Regions


Adjust SDPWriteCmd

Adjust SDPWriteCmd

* add missing override specifier
* make member variable private

--- libuuu/sdp.h
+++ libuuu/sdp.h
@@ -158,6 +158,12 @@
 class SDPWriteCmd : public SDPCmdBase
 {
 public:
+	SDPWriteCmd(char*p);
+
+	int run(CmdCtx *p) override;
+	int run(CmdCtx *p, void *buff, size_t size, uint32_t addr);
+
+private:
 	uint32_t m_download_addr;
 	int32_t m_Ivt;
 	int m_PlugIn;
@@ -166,11 +172,6 @@
 	bool m_bIvtReserve;
 	bool m_bskipspl;
 	bool m_bskipfhdr;
-
-	SDPWriteCmd(char*p);
-
-	int run(CmdCtx *p);
-	int run(CmdCtx *p, void *buff, size_t size, uint32_t addr);
 };

 class SDPJumpCmd : public SDPCmdBase


Updated dcpu.h to conform to the spec

Updated dcpu.h to conform to the spec

--- libvm/dcpu.h
+++ libvm/dcpu.h
@@ -71,21 +71,38 @@
 #define OP_ADD      0x2
 #define OP_SUB      0x3
 #define OP_MUL      0x4
-#define OP_DIV      0x5
-#define OP_MOD      0x6
-#define OP_SHL      0x7
-#define OP_SHR      0x8
+#define OP_MLI      0x5
+#define OP_DIV      0x6
+#define OP_DVI      0x7
+#define OP_MOD      0x8
 #define OP_AND      0x9
 #define OP_BOR      0xA
 #define OP_XOR      0xB
-#define OP_IFE      0xC
-#define OP_IFN      0xD
-#define OP_IFG      0xE
-#define OP_IFB      0xF
+#define OP_SHR      0xC
+#define OP_ASR      0xD
+#define OP_SHL      0xE
+#define OP_IFB      0x10
+#define OP_IFC      0x11
+#define OP_IFE      0x12
+#define OP_IFN      0x13
+#define OP_IFG      0x14
+#define OP_IFA      0x15
+#define OP_IFL      0x16
+#define OP_IFU      0x17
+
+
+

 // Non-basic opcodes
 #define NBOP_RESERVED   0x00
 #define NBOP_JSR        0x01
+#define NBOP_INT	0x08
+#define NBOP_ING	0x09
+#define NBOP_INS	0x0a
+#define NBOP_HWN	0x10
+#define NBOP_HWQ	0x11
+#define NBOP_HWI	0x12
+
 // 0x02 -> 0x3f are all reserved
 #define NBOP_EXT_PRINT  0x02 // Custom extension.

@@ -106,6 +123,7 @@
 	uint16_t registers[8];
 	uint16_t pc;
 	uint16_t sp;
+	uint16_t ia;
 	uint16_t o;
 	uint16_t ram[0x10000];
 	uint16_t dummy; // Dummy position for assignments that silently fail.