Fixed a really bogus problem with msync ripping pages away from objects before they were written.  Also, don't allow processes without write access to remove pages from vm_objects.

--- sys/vm/vm_map.c
+++ sys/vm/vm_map.c
@@ -61,7 +61,7 @@
  * any improvements or extensions that they make and grant Carnegie the
  * rights to redistribute these changes.
  *
- * $Id: vm_map.c,v 1.31 1996/01/04 21:13:17 wollman Exp $
+ * $Id: vm_map.c,v 1.32 1996/01/19 03:59:52 dyson Exp $
  */

 /*
@@ -1529,16 +1529,17 @@
 			 *     the object before it completes is probably a very bad
 			 *     idea.
 			 */
-			if (current->protection & VM_PROT_WRITE)
+			if (current->protection & VM_PROT_WRITE) {
 		   	    	vm_object_page_clean(object,
 					OFF_TO_IDX(offset),
 					OFF_TO_IDX(offset + size),
-					syncio, TRUE);
-			if (invalidate)
-				vm_object_page_remove(object,
-					OFF_TO_IDX(offset),
-					OFF_TO_IDX(offset + size),
-					FALSE);
+					(syncio||invalidate)?1:0, TRUE);
+				if (invalidate)
+					vm_object_page_remove(object,
+						OFF_TO_IDX(offset),
+						OFF_TO_IDX(offset + size),
+						FALSE);
+			}
 		}
 		start += size;
 	}


Get rid of RO/RW prefetch flag since some compilers don't like it and it doesn't seem to make a difference in performance

--- system/thread.h
+++ system/thread.h
@@ -182,7 +182,7 @@
 } thread_barrier;

 inline void prefetch_and_switch(thread *me, void *addr, int ro_or_rw) {
-  __builtin_prefetch(addr, ro_or_rw, 0);
+  __builtin_prefetch(addr, 0, 0);
   thread_yield(me);
 }


adjust memory layout

adjust memory layout

--- quartet.c
+++ quartet.c
@@ -56,10 +56,6 @@
 typedef void * ptr_t;
 #define PTR(n) ((ptr_t)(n))

-// universal Code Pointer type (32/64-bit machine address)
-typedef int_t (*func_t)(int_t);
-#define FUNC(n) ((func_t)(n))
-
 // universal Boolean constants
 #define TRUE INT(-1)
 #define FALSE INT(0)
@@ -98,10 +94,6 @@

 #define CACHE_LINE_SZ (sizeof(thunk_t))  // bytes per idealized cache line

-int_t is_proc(int_t value);  // FORWARD DECLARATION
-int_t is_word(int_t value);  // FORWARD DECLARATION
-int_t is_block(int_t value);  // FORWARD DECLARATION
-
 int_t panic(char *reason) {
     fprintf(stderr, "\nPANIC! %s\n", reason);
     exit(-1);
@@ -184,6 +176,19 @@
 PROC_DECL(prim_Undefined);
 PROC_DECL(prim_Constant);
 PROC_DECL(prim_Block);
+
+int_t is_defined(int_t word) {
+    thunk_t *w = PTR(word);
+    if (w->proc == PTR(0)) return FALSE;
+    if (w->proc == prim_Undefined) return FALSE;
+    return TRUE;
+}
+
+int_t is_const(int_t word) {
+    thunk_t *w = PTR(word);
+    if (w->proc == prim_Constant) return TRUE;
+    return FALSE;
+}

 PROC_DECL(prim_CREATE);
 PROC_DECL(prim_SEND);
@@ -282,6 +287,7 @@
     { .proc = prim_PrintStack, .name = "..." },
     { .proc = prim_PrintDetail, .name = ".?" },
     { .proc = prim_Print, .name = "." },
+    { .proc = prim_Undefined, .name = "" }
 };
 size_t ro_words = 47;  // limit of read-only words
 size_t rw_words = 47;  // limit of read/write words
@@ -294,19 +300,22 @@
 int_t word_IF = INT(&word_list[13]);
 int_t word_ELSE = INT(&word_list[14]);

+int_t is_block(int_t value);  // FORWARD DECLARATION
+
+int_t is_proc(int_t value) {
+    if ((value < INT(prim_CREATE))
+     || (value > INT(prim_Print))) {
+        return FALSE;
+    }
+    return TRUE;
+}
+
 int_t is_word(int_t value) {
 //    if (NAT(value - INT(word_list)) < sizeof(word_list)) {
     if (NAT(value - INT(word_list)) <= (rw_words * sizeof(thunk_t))) {
         return TRUE;
     }
     return FALSE;
-}
-
-int_t is_defined(int_t word) {
-    thunk_t *w = PTR(word);
-    if (w->proc == PTR(0)) return FALSE;
-    if (w->proc == prim_Undefined) return FALSE;
-    return TRUE;
 }

 void print_ascii(int_t code) {
@@ -325,6 +334,8 @@
         printf("%s", w->name);
     } else if (is_block(value)) {
         print_block(value);
+    } else if (is_proc(value)) {
+        fprintf(stderr, "%p", PTR(value));
     } else {
         printf("%"PRIdPTR, value);
     }
@@ -828,6 +839,7 @@

 int_t exec_word(int_t word) {
     XDEBUG(print_detail("  exec_word (word)", word));
+    if (!is_word(word)) { return panic("exec requires a word"); }
     if (!is_defined(word)) {
         // find definition in current dictionary
         if (!find_ro_word(&word, word)) {
@@ -1061,11 +1073,13 @@
     print_detail("   CREATE", INT(prim_CREATE));
     print_detail("    Print", INT(prim_Print));
     print_detail("     main", INT(main));
-    print_detail("  is_proc", INT(is_proc));
 #endif
     if (!(NAT(panic) < NAT(main))) {
         return panic("expected panic() < main()");
     }
+    if (!(INT(prim_CREATE) < INT(prim_Print))) {
+        return panic("expected panic() < main()");
+    }
     if (is_proc(INT(prim_Undefined))) {
         return panic("expected !is_proc(prim_Undefined)");
     }
@@ -1079,12 +1093,3 @@
     printf("-- interpreter --\n");
     return (interpret() ? 0 : 1);
 }
-
-// WARNING! THIS FUNCTION MUST FOLLOW main(), BUT DECLARED BEFORE panic().
-int_t is_proc(int_t value) {
-    if ((value < INT(prim_CREATE))
-     || (value > INT(prim_Print))) {
-        return FALSE;
-    }
-    return TRUE;
-}


Fix adhoc mode to scan all available channels for a bss to join
while still restricting auto-channel select to only those channels
permitted by regulatory constraints (sorta, we're still missing the
checks to honor radar and noadhoc status on channels).  This somehow
got lost in the initial merge of the revised scanning code.

Reviewed by:	jhay
MFC after:	2 weeks

--- sys/net80211/ieee80211_scan_sta.c
+++ sys/net80211/ieee80211_scan_sta.c
@@ -499,6 +499,59 @@
 	return 0;
 }

+static void
+sweepchannels(struct ieee80211_scan_state *ss, struct ieee80211com *ic,
+	const struct scanlist table[])
+{
+	struct ieee80211_channel *c;
+	int i;
+
+	/*
+	 * Add the channels from the ic (from HAL) that are not present
+	 * in the staScanTable.
+	 */
+	for (i = 0; i < ic->ic_nchans; i++) {
+		if (ss->ss_last >= IEEE80211_SCAN_MAX)
+			break;
+
+		c = &ic->ic_channels[i];
+		/*
+		 * Ignore dynamic turbo channels; we scan them
+		 * in normal mode (i.e. not boosted).  Likewise
+		 * for HT channels, they get scanned using
+		 * legacy rates.
+		 */
+		if (IEEE80211_IS_CHAN_DTURBO(c) || IEEE80211_IS_CHAN_HT(c))
+			continue;
+
+		/*
+		 * If a desired mode was specified, scan only
+		 * channels that satisfy that constraint.
+		 */
+		if (ic->ic_des_mode != IEEE80211_MODE_AUTO &&
+		    ic->ic_des_mode != ieee80211_chan2mode(c))
+			continue;
+
+		/*
+		 * Skip channels excluded by user request.
+		 */
+		if (isexcluded(ic, c))
+			continue;
+
+		/*
+		 * Add the channel unless it is listed in the
+		 * fixed scan order tables.  This insures we
+		 * don't sweep back in channels we filtered out
+		 * above.
+		 */
+		if (checktable(table, c))
+			continue;
+
+		/* Add channel to scanning list. */
+		ss->ss_chans[ss->ss_last++] = c;
+	}
+}
+
 /*
  * Start a station-mode scan by populating the channel list.
  */
@@ -509,8 +562,6 @@
 	struct sta_table *st = ss->ss_priv;
 	const struct scanlist *scan;
 	enum ieee80211_phymode mode;
-	struct ieee80211_channel *c;
-	int i;

 	ss->ss_last = 0;
 	/*
@@ -563,46 +614,7 @@
 	 * Add the channels from the ic (from HAL) that are not present
 	 * in the staScanTable.
 	 */
-	for (i = 0; i < ic->ic_nchans; i++) {
-		if (ss->ss_last >= IEEE80211_SCAN_MAX)
-			break;
-
-		c = &ic->ic_channels[i];
-		/*
-		 * Ignore dynamic turbo channels; we scan them
-		 * in normal mode (i.e. not boosted).  Likewise
-		 * for HT channels, they get scanned using
-		 * legacy rates.
-		 */
-		if (IEEE80211_IS_CHAN_DTURBO(c) || IEEE80211_IS_CHAN_HT(c))
-			continue;
-
-		/*
-		 * If a desired mode was specified, scan only
-		 * channels that satisfy that constraint.
-		 */
-		if (ic->ic_des_mode != IEEE80211_MODE_AUTO &&
-		    ic->ic_des_mode != ieee80211_chan2mode(c))
-			continue;
-
-		/*
-		 * Skip channels excluded by user request.
-		 */
-		if (isexcluded(ic, c))
-			continue;
-
-		/*
-		 * Add the channel unless it is listed in the
-		 * fixed scan order tables.  This insures we
-		 * don't sweep back in channels we filtered out
-		 * above.
-		 */
-		if (checktable(staScanTable, c))
-			continue;
-
-		/* Add channel to scanning list. */
-		ss->ss_chans[ss->ss_last++] = c;
-	}
+	sweepchannels(ss, ic, staScanTable);

 	ss->ss_next = 0;
 	/* XXX tunables */
@@ -1280,6 +1292,13 @@
 		 */
 		add_channels(ic, ss, mode, scan->list, scan->count);
 	}
+
+	/*
+	 * Add the channels from the ic (from HAL) that are not present
+	 * in the staScanTable.
+	 */
+	sweepchannels(ss, ic, adhocScanTable);
+
 	ss->ss_next = 0;
 	/* XXX tunables */
 	ss->ss_mindwell = msecs_to_ticks(200);		/* 200ms */
@@ -1320,6 +1339,8 @@
 	mtx_lock(&st->st_lock);
 	for (i = 0; i < ss->ss_last; i++) {
 		c = ss->ss_chans[i];
+		if (!checktable(adhocScanTable, c))
+			continue;
 		maxrssi = 0;
 		TAILQ_FOREACH(se, &st->st_entry, se_list) {
 			if (se->base.se_chan != c)


Pull BSM conversion logic out of audit_record_write(), as well as
knowledge of user vs. kernel audit records into
audit_worker_process_record().  This largely confines vnode
knowledge to audit_record_write(), but avoids that logic knowing
about BSM as opposed to byte streams.  This will allow us to
improve our ability to support real-time audit stream processing
by audit pipe consumers while auditing is disabled, but this
support is not yet complete.

Obtained from:	TrustedBSD Project

--- sys/security/audit/audit_worker.c
+++ sys/security/audit/audit_worker.c
@@ -109,15 +109,17 @@
  * we accounted for.
  */
 static int
-audit_record_write(struct vnode *vp, struct kaudit_record *ar,
-    struct ucred *cred, struct thread *td)
+audit_record_write(struct vnode *vp, struct ucred *cred, struct thread *td,
+    void *data, size_t len)
 {
 	int ret;
 	long temp;
-	struct au_record *bsm;
 	struct vattr vattr;
 	struct statfs *mnt_stat = &vp->v_mount->mnt_stat;
 	int vfslocked;
+
+	if (vp == NULL)
+		return (0);

 	vfslocked = VFS_LOCK_GIANT(vp->v_mount);

@@ -214,74 +216,8 @@
 		audit_in_failure = 1;
 	}

-	/*
-	 * If there is a user audit record attached to the kernel record,
-	 * then write the user record.
-	 *
-	 * XXX Need to decide a few things here: IF the user audit record is
-	 * written, but the write of the kernel record fails, what to do?
-	 * Should the kernel record come before or after the user record?
-	 * For now, we write the user record first, and we ignore errors.
-	 */
-	if (ar->k_ar_commit & AR_COMMIT_USER) {
-		/*
-		 * Try submitting the record to any active audit pipes.
-		 */
-		audit_pipe_submit((void *)ar->k_udata, ar->k_ulen);
-
-		/*
-		 * And to disk.
-		 */
-		ret = vn_rdwr(UIO_WRITE, vp, (void *)ar->k_udata, ar->k_ulen,
-		    (off_t)0, UIO_SYSSPACE, IO_APPEND|IO_UNIT, cred, NULL,
-		    NULL, td);
-		if (ret)
-			goto out;
-	}
-
-	/*
-	 * Convert the internal kernel record to BSM format and write it out
-	 * if everything's OK.
-	 */
-	if (!(ar->k_ar_commit & AR_COMMIT_KERNEL)) {
-		ret = 0;
-		goto out;
-	}
-
-	/*
-	 * XXXAUDIT: Should we actually allow this conversion to fail?  With
-	 * sleeping memory allocation and invariants checks, perhaps not.
-	 */
-	ret = kaudit_to_bsm(ar, &bsm);
-	if (ret == BSM_NOAUDIT) {
-		ret = 0;
-		goto out;
-	}
-
-	/*
-	 * XXX: We drop the record on BSM conversion failure, but really this
-	 * is an assertion failure.
-	 */
-	if (ret == BSM_FAILURE) {
-		AUDIT_PRINTF(("BSM conversion failure\n"));
-		ret = EINVAL;
-		goto out;
-	}
-
-	/*
-	 * Try submitting the record to any active audit pipes.
-	 */
-	audit_pipe_submit((void *)bsm->data, bsm->len);
-
-	/*
-	 * XXX We should break the write functionality away from the BSM
-	 * record generation and have the BSM generation done before this
-	 * function is called. This function will then take the BSM record as
-	 * a parameter.
-	 */
-	ret = (vn_rdwr(UIO_WRITE, vp, (void *)bsm->data, bsm->len, (off_t)0,
-	    UIO_SYSSPACE, IO_APPEND|IO_UNIT, cred, NULL, NULL, td));
-	kau_free(bsm);
+	ret = vn_rdwr(UIO_WRITE, vp, data, len, (off_t)0, UIO_SYSSPACE,
+	    IO_APPEND|IO_UNIT, cred, NULL, NULL, td);

 out:
 	/*
@@ -386,27 +322,55 @@
 }

 /*
- * Given a kernel audit record, process as required.  Currently, that means
- * passing it to audit_record_write(), but in the future it will mean
- * converting it to BSM and then routing it to various possible output
- * streams, including the audit trail and audit pipes.  The caller will free
- * the record.
+ * Given a kernel audit record, process as required.  Kernel audit records
+ * are converted to one, or possibly two, BSM records, depending on whether
+ * there is a user audit record present also.  Kernel records need be
+ * converted to BSM before they can be written out.  Both types will be
+ * written to disk, and audit pipes.
  */
 static void
 audit_worker_process_record(struct vnode *audit_vp, struct ucred *audit_cred,
     struct thread *audit_td, struct kaudit_record *ar)
 {
-	int error;
-
-	if (audit_vp == NULL)
-		return;
-
-	error = audit_record_write(audit_vp, ar, audit_cred, audit_td);
-	if (error) {
-		if (audit_panic_on_write_fail)
+	struct au_record *bsm;
+	int error, ret;
+
+	if (ar->k_ar_commit & AR_COMMIT_USER) {
+		error = audit_record_write(audit_vp, audit_cred, audit_td,
+		    ar->k_udata, ar->k_ulen);
+		if (error && audit_panic_on_write_fail)
 			panic("audit_worker: write error %d\n", error);
-		else
+		else if (error)
 			printf("audit_worker: write error %d\n", error);
+		audit_pipe_submit(ar->k_udata, ar->k_ulen);
+	}
+
+	if (ar->k_ar_commit & AR_COMMIT_KERNEL) {
+		ret = kaudit_to_bsm(ar, &bsm);
+		switch (ret) {
+		case BSM_NOAUDIT:
+			break;
+
+		case BSM_FAILURE:
+			printf("audit_worker_process_record: BSM_FAILURE\n");
+			break;
+
+		case BSM_SUCCESS:
+			error = audit_record_write(audit_vp, audit_cred,
+			    audit_td, bsm->data, bsm->len);
+			if (error && audit_panic_on_write_fail)
+				panic("audit_worker: write error %d\n",
+				    error);
+			else if (error)
+				printf("audit_worker: write error %d\n",
+				    error);
+			audit_pipe_submit(bsm->data, bsm->len);
+			kau_free(bsm);
+			break;
+
+		default:
+			panic("kaudit_to_bsm returned %d", ret);
+		}
 	}
 }


lock.h must be included before mutex.h.

lock.h must be included before mutex.h.

--- sys/sparc64/sparc64/bus_machdep.c
+++ sys/sparc64/sparc64/bus_machdep.c
@@ -111,6 +111,7 @@

 #include <sys/param.h>
 #include <sys/bus.h>
+#include <sys/lock.h>
 #include <sys/malloc.h>
 #include <sys/mbuf.h>
 #include <sys/mutex.h>


adding more bitbuffer tests

adding more bitbuffer tests

--- test/bitbuffer/main.c
+++ test/bitbuffer/main.c
@@ -42,6 +42,81 @@
 }

+DECLARE_TEST( bitbuffer, basics )
+{
+	uint32_t buffer[1024];
+	uint32_t read;
+	bitbuffer_t bitbuffer;
+
+	memset( buffer, 0xFF, 1024 * 4 );
+
+	bitbuffer_initialize( &bitbuffer, buffer, 1024 * 4, false );
+
+	bitbuffer_write32( &bitbuffer, 0x12345678, 32 );
+	bitbuffer_align_write( &bitbuffer, false );
+
+	EXPECT_EQ( buffer[0], 0x12345678 );
+	EXPECT_EQ( buffer[1], 0xFFFFFFFF );
+
+	bitbuffer_align_write( &bitbuffer, true );
+
+	EXPECT_EQ( buffer[0], 0x12345678 );
+	EXPECT_EQ( buffer[1], 0x00000000 );
+	EXPECT_EQ( buffer[2], 0xFFFFFFFF );
+
+	bitbuffer_write32( &bitbuffer, 0x12345678, 8 );
+
+	EXPECT_EQ( buffer[0], 0x12345678 );
+	EXPECT_EQ( buffer[1], 0x00000000 );
+	EXPECT_EQ( buffer[2], 0xFFFFFFFF );
+
+	bitbuffer_align_write( &bitbuffer, false );
+
+	EXPECT_EQ( buffer[0], 0x12345678 );
+	EXPECT_EQ( buffer[1], 0x00000000 );
+	EXPECT_EQ( buffer[2], 0x00000078 );
+	EXPECT_EQ( buffer[3], 0xFFFFFFFF );
+
+	bitbuffer_write32( &bitbuffer, 0x12345678, 12 );
+
+	EXPECT_EQ( buffer[0], 0x12345678 );
+	EXPECT_EQ( buffer[1], 0x00000000 );
+	EXPECT_EQ( buffer[2], 0x00000078 );
+	EXPECT_EQ( buffer[3], 0xFFFFFFFF );
+
+	bitbuffer_align_write( &bitbuffer, true );
+
+	EXPECT_EQ( buffer[0], 0x12345678 );
+	EXPECT_EQ( buffer[1], 0x00000000 );
+	EXPECT_EQ( buffer[2], 0x00000078 );
+	EXPECT_EQ( buffer[3], 0x00000678 );
+	EXPECT_EQ( buffer[4], 0xFFFFFFFF );
+
+	bitbuffer_initialize( &bitbuffer, buffer, 1024 * 4, false );
+
+	read = bitbuffer_read32( &bitbuffer, 32 );
+	bitbuffer_align_read( &bitbuffer, false );
+
+	EXPECT_EQ( read, 0x12345678 );
+
+	read = bitbuffer_read32( &bitbuffer, 32 );
+	bitbuffer_align_write( &bitbuffer, true );
+
+	EXPECT_EQ( read, 0x00000000 );
+
+	read = bitbuffer_read32( &bitbuffer, 12 );
+	bitbuffer_align_read( &bitbuffer, false );
+
+	EXPECT_EQ( read, 0x00000678 );
+
+	read = bitbuffer_read32( &bitbuffer, 31 );
+
+	EXPECT_EQ( read, 0x7FFFFFFF );
+
+	return 0;
+}
+
+
 DECLARE_TEST( bitbuffer, readwrite )
 {
 	int ipass, ival;
@@ -62,7 +137,7 @@
 	for( ival = 0; ival < 4; ++ival )
 		val128[ival] = uint128_make( random64(), random64() );

-	for( ipass = 0; ipass < 4096; ++ipass )
+	for( ipass = 0; ipass < 8192; ++ipass )
 	{
 		for( ival = 0; ival < 20; ++ival )
 		{
@@ -147,16 +222,102 @@

 DECLARE_TEST( bitbuffer, readwriteswap )
 {
+	int ipass, ival;
 	uint32_t buffer[1024];
 	bitbuffer_t bitbuffer;
-
-	bitbuffer_initialize( &bitbuffer, buffer, 1024 * 4, true );
+	uint128_t readval128, writeval128;
+
+	uint32_t  val32[4]  = { random32(), random32(), random32(), random32() };
+	uint64_t  val64[4]  = { random64(), random64(), random64(), random64() };
+	uint128_t val128[4];
+	float32_t valf32[4] = { (float32_t)random_normalized(), (float32_t)random_normalized(), (float32_t)random_normalized(), (float32_t)random_normalized() };
+	float64_t valf64[4] = { (float64_t)random_normalized(), (float64_t)random_normalized(), (float64_t)random_normalized(), (float64_t)random_normalized() };
+
+	int bits32[20] = {0};
+	int bits64[20] = {0};
+	int bits128[20] = {0};
+
+	for( ival = 0; ival < 4; ++ival )
+		val128[ival] = uint128_make( random64(), random64() );
+
+	for( ipass = 0; ipass < 8192; ++ipass )
+	{
+		for( ival = 0; ival < 20; ++ival )
+		{
+			bits32[ival] = random32_range( 0, 33 );
+			bits64[ival] = random32_range( 0, 65 );
+			bits128[ival] = random32_range( 0, 129 );
+		}

-
-
-	bitbuffer_initialize( &bitbuffer, buffer, 1024 * 4, true );
-
-
+		//Phase 1 - write data
+		bitbuffer_initialize( &bitbuffer, buffer, 1024 * 4, true );
+
+		for( ival = 0; ival < 16; ++ival )
+		{
+			bitbuffer_write32( &bitbuffer, val32[0], bits32[ival] );
+			bitbuffer_write32( &bitbuffer, val32[1], bits32[ival+1] );
+			bitbuffer_write32( &bitbuffer, val32[2], bits32[ival+2] );
+			bitbuffer_write32( &bitbuffer, val32[3], bits32[ival+3] );
+
+			bitbuffer_write64( &bitbuffer, val64[0], bits64[ival] );
+			bitbuffer_write64( &bitbuffer, val64[1], bits64[ival+1] );
+			bitbuffer_write64( &bitbuffer, val64[2], bits64[ival+2] );
+			bitbuffer_write64( &bitbuffer, val64[3], bits64[ival+3] );
+
+			bitbuffer_write128( &bitbuffer, val128[0], bits128[ival] );
+			bitbuffer_write128( &bitbuffer, val128[1], bits128[ival+1] );
+			bitbuffer_write128( &bitbuffer, val128[2], bits128[ival+2] );
+			bitbuffer_write128( &bitbuffer, val128[3], bits128[ival+3] );
+
+			bitbuffer_write_float32( &bitbuffer, valf32[0] );
+			bitbuffer_write_float32( &bitbuffer, valf32[1] );
+			bitbuffer_write_float32( &bitbuffer, valf32[2] );
+			bitbuffer_write_float32( &bitbuffer, valf32[3] );
+
+			bitbuffer_write_float64( &bitbuffer, valf64[0] );
+			bitbuffer_write_float64( &bitbuffer, valf64[1] );
+			bitbuffer_write_float64( &bitbuffer, valf64[2] );
+			bitbuffer_write_float64( &bitbuffer, valf64[3] );
+		}
+
+		bitbuffer_align_write( &bitbuffer, false );
+		bitbuffer_write64( &bitbuffer, 0, 63 );
+
+		// Phase 2 - read and verify data
+		bitbuffer_initialize( &bitbuffer, buffer, 1024 * 4, true );
+
+		for( ival = 0; ival < 16; ++ival )
+		{
+			EXPECT_EQ( bitbuffer_read32( &bitbuffer, bits32[ival] ),   val32[0] & ( bits32[ival]   == 32 ? -1 : ( bits32[ival]   ? ( 1 << bits32[ival]   ) - 1 : 0 ) ) );
+			EXPECT_EQ( bitbuffer_read32( &bitbuffer, bits32[ival+1] ), val32[1] & ( bits32[ival+1] == 32 ? -1 : ( bits32[ival+1] ? ( 1 << bits32[ival+1] ) - 1 : 0 ) ) );
+			EXPECT_EQ( bitbuffer_read32( &bitbuffer, bits32[ival+2] ), val32[2] & ( bits32[ival+2] == 32 ? -1 : ( bits32[ival+2] ? ( 1 << bits32[ival+2] ) - 1 : 0 ) ) );
+			EXPECT_EQ( bitbuffer_read32( &bitbuffer, bits32[ival+3] ), val32[3] & ( bits32[ival+3] == 32 ? -1 : ( bits32[ival+3] ? ( 1 << bits32[ival+3] ) - 1 : 0 ) ) );
+
+			EXPECT_EQ( bitbuffer_read64( &bitbuffer, bits64[ival] ),   val64[0] & ( bits64[ival]   == 64 ? (uint64_t)-1 : ( bits64[ival]   ? ( 1ULL << bits64[ival]   ) - 1 : 0 ) ) );
+			EXPECT_EQ( bitbuffer_read64( &bitbuffer, bits64[ival+1] ), val64[1] & ( bits64[ival+1] == 64 ? (uint64_t)-1 : ( bits64[ival+1] ? ( 1ULL << bits64[ival+1] ) - 1 : 0 ) ) );
+			EXPECT_EQ( bitbuffer_read64( &bitbuffer, bits64[ival+2] ), val64[2] & ( bits64[ival+2] == 64 ? (uint64_t)-1 : ( bits64[ival+2] ? ( 1ULL << bits64[ival+2] ) - 1 : 0 ) ) );
+			EXPECT_EQ( bitbuffer_read64( &bitbuffer, bits64[ival+3] ), val64[3] & ( bits64[ival+3] == 64 ? (uint64_t)-1 : ( bits64[ival+3] ? ( 1ULL << bits64[ival+3] ) - 1 : 0 ) ) );
+
+			writeval128 = val128[0]; writeval128.word[0] &= ( bits128[ival] >= 64 ? (uint64_t)-1 : ( bits128[ival] ? ( 1ULL << bits128[ival] ) - 1 : 0 ) ); writeval128.word[1] &= ( bits128[ival] == 128 ? (uint64_t)-1 : ( bits128[ival] > 64 ? ( 1ULL << ( bits128[ival] - 64 ) ) - 1 : 0 ) );
+			readval128 = bitbuffer_read128( &bitbuffer, bits128[ival] ); EXPECT_TRUE( uint128_equal( readval128, writeval128 ) );
+			writeval128 = val128[1]; writeval128.word[0] &= ( bits128[ival+1] >= 64 ? (uint64_t)-1 : ( bits128[ival+1] ? ( 1ULL << bits128[ival+1] ) - 1 : 0 ) ); writeval128.word[1] &= ( bits128[ival+1] == 128 ? (uint64_t)-1 : ( bits128[ival+1] > 64 ? ( 1ULL << ( bits128[ival+1] - 64 ) ) - 1 : 0 ) );
+			readval128 = bitbuffer_read128( &bitbuffer, bits128[ival+1] ); EXPECT_TRUE( uint128_equal( readval128, writeval128 ) );
+			writeval128 = val128[2]; writeval128.word[0] &= ( bits128[ival+2] >= 64 ? (uint64_t)-1 : ( bits128[ival+2] ? ( 1ULL << bits128[ival+2] ) - 1 : 0 ) ); writeval128.word[1] &= ( bits128[ival+2] == 128 ? (uint64_t)-1 : ( bits128[ival+2] > 64 ? ( 1ULL << ( bits128[ival+2] - 64 ) ) - 1 : 0 ) );
+			readval128 = bitbuffer_read128( &bitbuffer, bits128[ival+2] ); EXPECT_TRUE( uint128_equal( readval128, writeval128 ) );
+			writeval128 = val128[3]; writeval128.word[0] &= ( bits128[ival+3] >= 64 ? (uint64_t)-1 : ( bits128[ival+3] ? ( 1ULL << bits128[ival+3] ) - 1 : 0 ) ); writeval128.word[1] &= ( bits128[ival+3] == 128 ? (uint64_t)-1 : ( bits128[ival+3] > 64 ? ( 1ULL << ( bits128[ival+3] - 64 ) ) - 1 : 0 ) );
+			readval128 = bitbuffer_read128( &bitbuffer, bits128[ival+3] ); EXPECT_TRUE( uint128_equal( readval128, writeval128 ) );
+
+			EXPECT_EQ( bitbuffer_read_float32( &bitbuffer ), valf32[0] );
+			EXPECT_EQ( bitbuffer_read_float32( &bitbuffer ), valf32[1] );
+			EXPECT_EQ( bitbuffer_read_float32( &bitbuffer ), valf32[2] );
+			EXPECT_EQ( bitbuffer_read_float32( &bitbuffer ), valf32[3] );
+
+			EXPECT_EQ( bitbuffer_read_float64( &bitbuffer ), valf64[0] );
+			EXPECT_EQ( bitbuffer_read_float64( &bitbuffer ), valf64[1] );
+			EXPECT_EQ( bitbuffer_read_float64( &bitbuffer ), valf64[2] );
+			EXPECT_EQ( bitbuffer_read_float64( &bitbuffer ), valf64[3] );
+		}
+	}

 	return 0;
 }
@@ -164,7 +325,9 @@

 void test_bitbuffer_declare( void )
 {
+	ADD_TEST( bitbuffer, basics );
 	ADD_TEST( bitbuffer, readwrite );
+	ADD_TEST( bitbuffer, readwriteswap );
 }


FP2-959:Add for RESET_PIN voltages level contral

Contral RESET_PIN voltages at 1.8V
	modified:   target/fairphone/target_display.c

Change-Id: Idbca8348dd6e24487eedff5c9bbbcba135357dd6

--- target/fairphone/target_display.c
+++ target/fairphone/target_display.c
@@ -246,6 +246,9 @@
 		.direction = PM_GPIO_DIR_OUT,
 		.output_buffer = PM_GPIO_OUT_CMOS,
 		.out_strength = PM_GPIO_OUT_DRIVE_LOW,
+        .pull = 5,
+        .vin_sel = 2,
+        .function = 0,
 	};

 	if (platform_id == MSM8974AC)


QPID: Fixes to deadlock issues in IO implementation

Fixes for a number of threading a deadlock issues within the
QPID IO implementation.

--- mama/c_cpp/src/c/bridge/qpid/io.c
+++ mama/c_cpp/src/c/bridge/qpid/io.c
@@ -146,6 +146,8 @@
     }
     gQpidIoContainer.mEventsRegistered++;

+    *result = (ioBridge)impl;
+
     return MAMA_STATUS_OK;
 }

@@ -159,8 +161,10 @@
         return MAMA_STATUS_NULL_ARG;
     }
     event_del (&impl->mEvent);
+
     free (impl);
     gQpidIoContainer.mEventsRegistered--;
+
     return MAMA_STATUS_OK;
 }

@@ -211,6 +215,12 @@
 {
     gQpidIoContainer.mActive = 0;

+    /* Alert the semaphore so the dispatch loop can exit */
+    wsem_post (&gQpidIoContainer.mResumeDispatching);
+
+    /* Tell the event loop to exit */
+    event_base_loopexit (gQpidIoContainer.mEventBase, NULL);
+
     /* Join with the dispatch thread - it should exit shortly */
     wthread_join (gQpidIoContainer.mDispatchThread, NULL);
     wsem_destroy (&gQpidIoContainer.mResumeDispatching);
@@ -238,7 +248,7 @@
     while (0 != gQpidIoContainer.mActive)
     {
         dispatchResult = event_base_loop (gQpidIoContainer.mEventBase,
-                                          EVLOOP_ONCE);
+                                          EVLOOP_NONBLOCK | EVLOOP_ONCE);

         /* If no events are currently registered */
         if (1 == dispatchResult)


Updating csp buffer init size to align with csp mtu size.

--- telemetry/source/communications.c
+++ telemetry/source/communications.c
@@ -32,7 +32,7 @@

 void telemetry_init()
 {
-    csp_buffer_init(10, 300);
+    csp_buffer_init(10, 256);

     /* Init CSP with address MY_ADDRESS */
     csp_init(TELEMETRY_CSP_ADDRESS);
@@ -175,4 +175,4 @@
     return false;
 }

-#endif+#endif


TEST: Add a test of keygen with an empty template in test/evp_extra_test.c

We do it with RSA, which may seem strange.  However, an RSA "template"
is generally ignored, so this is safe.  This is modelled after the test
code given in github issue #11549.

Reviewed-by: Paul Dale <bc4a6b4cd7a8395c734c8eb5aef04a9c30188c85@oracle.com>
Reviewed-by: Shane Lontis <452ce16516ceed26291fe7de3f8b53540d83864e@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/11550)

--- test/evp_extra_test.c
+++ test/evp_extra_test.c
@@ -1540,6 +1540,47 @@
 }
 #endif

+/*
+ * We test what happens with an empty template.  For the sake of this test,
+ * the template must be ignored, and we know that's the case for RSA keys
+ * (this might arguably be a misfeature, but that's what we currently do,
+ * even in provider code, since that's how the legacy RSA implementation
+ * does things)
+ */
+static int test_keygen_with_empty_template(int n)
+{
+    EVP_PKEY_CTX *ctx = NULL;
+    EVP_PKEY *pkey = NULL;
+    EVP_PKEY *tkey = NULL;
+    int ret = 0;
+
+    switch (n) {
+    case 0:
+        /* We do test with no template at all as well */
+        if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, NULL)))
+            goto err;
+        break;
+    case 1:
+        /* Here we create an empty RSA key that serves as our template */
+        if (!TEST_ptr(tkey = EVP_PKEY_new())
+            || !TEST_true(EVP_PKEY_set_type(tkey, EVP_PKEY_RSA))
+            || !TEST_ptr(ctx = EVP_PKEY_CTX_new(tkey, NULL)))
+            goto err;
+        break;
+    }
+
+    if (!TEST_int_gt(EVP_PKEY_keygen_init(ctx), 0)
+        || !TEST_int_gt(EVP_PKEY_keygen(ctx, &pkey), 0))
+        goto err;
+
+    ret = 1;
+ err:
+    EVP_PKEY_CTX_free(ctx);
+    EVP_PKEY_free(pkey);
+    EVP_PKEY_free(tkey);
+    return ret;
+}
+
 int setup_tests(void)
 {
     ADD_ALL_TESTS(test_EVP_DigestSignInit, 9);
@@ -1579,6 +1620,7 @@
 #ifndef OPENSSL_NO_DH
     ADD_TEST(test_EVP_PKEY_set1_DH);
 #endif
+    ADD_ALL_TESTS(test_keygen_with_empty_template, 2);

     return 1;
 }


tcmu: perform proper config check

tcmu: perform proper config check

Validate user configuration parameters. Until now, tcmu_elasto_cfg_check
has always returned true.

Signed-off-by: David Disseldorp <589a549dc9f982d9f46aeeb82a09ab6d87ccf1d8@suse.de>

--- tcmu/consumer.c
+++ tcmu/consumer.c
@@ -411,9 +411,6 @@
 	struct elasto_fauth *auth;
 	char *path;

-	printf("faking good config\n");
-	return true;
-
 	ret = tcmu_elasto_cfg_parse(cfgstring, &auth, &path);
 	if (ret < 0) {
 		*reason = strdup(strerror(-ret));


tcmu: use file wide debug level

tcmu: use file wide debug level

The existing -d <debug_level> parameter was until now only used for
libelasto debug level control. This change makes tcmu consumer debug
messages dependent on a debug_level > 0.

Signed-off-by: David Disseldorp <589a549dc9f982d9f46aeeb82a09ab6d87ccf1d8@suse.de>

--- tcmu/consumer.c
+++ tcmu/consumer.c
@@ -42,18 +42,29 @@
 #include "scsi_defs.h"
 #include "lib/file/file_api.h"

+struct tcmu_elasto_args {
+	int debug_level;
+};
+
+struct tcmu_elasto_args tcmu_elasto_args = { 0 };
+
 /*
  * Debug API implementation
  */
-void dbgp(const char *fmt, ...)
+static void
+dbgp(const char *fmt, ...)
 {
 	va_list va;
-	va_start(va, fmt);
-	vprintf(fmt, va);
-	va_end(va);
-}
-
-void errp(const char *fmt, ...)
+
+	if (tcmu_elasto_args.debug_level > 0) {
+		va_start(va, fmt);
+		vprintf(fmt, va);
+		va_end(va);
+	}
+}
+
+static void
+errp(const char *fmt, ...)
 {
 	va_list va;

@@ -887,10 +898,6 @@
 		progname);
 }

-struct tcmu_elasto_args {
-	int debug_level;
-};
-
 static int
 tcmu_elasto_args_parse(int argc,
 		       char * const *argv,
@@ -924,7 +931,6 @@
 int main(int argc,
 	 char **argv)
 {
-	struct tcmu_elasto_args tcmu_elasto_args = { 0 };
 	struct tcmulib_context *tcmulib_ctx;
 	struct event *ev_master;
 	int ret;


Add utility fct FillWithZY

Add utility fct FillWithZY

--- tensorflow/compiler/xla/array4d.h
+++ tensorflow/compiler/xla/array4d.h
@@ -120,6 +120,21 @@
     }
   }

+  // Fills all of the {p,x} with the array provided, which specifies {z,y}.
+  void FillWithZY(const Array2D<T>& value) {
+    CHECK_EQ(value.height(), depth());
+    CHECK_EQ(value.width(), height());
+    for (int64 plane = 0; plane < planes(); ++plane) {
+      for (int64 depth = 0; depth < this->depth(); ++depth) {
+        for (int64 height = 0; height < this->height(); ++height) {
+          for (int64 width = 0; width < this->width(); ++width) {
+            (*this)(plane, depth, height, width) = value(depth, height);
+          }
+        }
+      }
+    }
+  }
+
   // Fills all of the {x,y} with the array provided, which specifies {p,z}.
   void FillWithPZ(const Array2D<T>& value) {
     CHECK_EQ(value.height(), planes());


driver/usb_mux/anx3443.c: Format with clang-format

BUG=b:236386294
BRANCH=none
TEST=none

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

--- driver/usb_mux/anx3443.c
+++ driver/usb_mux/anx3443.c
@@ -23,22 +23,21 @@
 #define ANX3443_I2C_WAKE_TIMEOUT_MS 20
 #define ANX3443_I2C_WAKE_RETRY_DELAY_US 500

-#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
-#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args)

 static struct {
 	mux_state_t mux_state;
 	bool awake;
 } saved_mux_state[CONFIG_USB_PD_PORT_MAX_COUNT];

-static inline int anx3443_read(const struct usb_mux *me,
-			       uint8_t reg, int *val)
+static inline int anx3443_read(const struct usb_mux *me, uint8_t reg, int *val)
 {
 	return i2c_read8(me->i2c_port, me->i2c_addr_flags, reg, val);
 }

-static inline int anx3443_write(const struct usb_mux *me,
-				uint8_t reg, uint8_t val)
+static inline int anx3443_write(const struct usb_mux *me, uint8_t reg,
+				uint8_t val)
 {
 	return i2c_write8(me->i2c_port, me->i2c_addr_flags, reg, val);
 }


ACPI / LPSS: don't crash if a device has no MMIO resources

Intel LPSS devices that are enumerated from ACPI have both MMIO and IRQ
resources returned in their _CRS method. However, Apple Macbook Air with
Haswell has LPSS devices enumerated from PCI bus instead and _CRS method
returns only an interrupt number (but the device has _HID set that causes
the scan handler to match it).

The current ACPI / LPSS code sets pdata->dev_desc only when MMIO resource
is found for the device and in case of Macbook Air it is never found. That
leads to a NULL pointer dereference in register_device_clock().

Correct this by always setting the pdata->dev_desc.

Reported-and-tested-by: Imre Kaloz <9fa18aedd982da975b2d97e5cdaef39466bfd1fa@openwrt.org>
Signed-off-by: Mika Westerberg <afb75201fb002d7fdd2b0b231e006999e00db8a9@linux.intel.com>
Cc: 3.10+ <4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@vger.kernel.org> # 3.10+
Signed-off-by: Rafael J. Wysocki <27ffc44a8ec6a212fba98cfc3246c6ce8ab131e0@intel.com>

--- drivers/acpi/acpi_lpss.c
+++ drivers/acpi/acpi_lpss.c
@@ -257,11 +257,12 @@
 				pdata->mmio_size = resource_size(&rentry->res);
 			pdata->mmio_base = ioremap(rentry->res.start,
 						   pdata->mmio_size);
-			pdata->dev_desc = dev_desc;
 			break;
 		}

 	acpi_dev_free_resource_list(&resource_list);
+
+	pdata->dev_desc = dev_desc;

 	if (dev_desc->clk_required) {
 		ret = register_device_clock(adev, pdata);


sata_sil24: always set protocol override for non-ATAPI data commands

The sil24 hardware has a built-in list of commands and associated protocols
that gets used by default to decide how to handle a given command. However,
if the command is not known to the controller then it presumably assumes it to
be a non-data command which then causes protocol mismatch errors if the device
ends up requesting data transfer. The new DATA SET MANAGEMENT - Trim command
causes this issue since it's a DMA data-out command.

Since we should always know best what protocol the command should be using,
let's just set the override flag to inform the controller what protocol to use
for all non-ATAPI commands with data transfer.

Signed-off-by: Robert Hancock <6cfcd53195f1aa0ac67c127c865c06914056063f@gmail.com>
Tested-by: Mark Lord <a43b18b2694cfc1ca53910e3748306e8d951483d@rtr.ca>
Signed-off-by: Jeff Garzik <15f615bf7d20c2937c7eb5aa759110fd6768848c@redhat.com>

--- drivers/ata/sata_sil24.c
+++ drivers/ata/sata_sil24.c
@@ -846,6 +846,17 @@
 	if (!ata_is_atapi(qc->tf.protocol)) {
 		prb = &cb->ata.prb;
 		sge = cb->ata.sge;
+		if (ata_is_data(qc->tf.protocol)) {
+			u16 prot = 0;
+			ctrl = PRB_CTRL_PROTOCOL;
+			if (ata_is_ncq(qc->tf.protocol))
+				prot |= PRB_PROT_NCQ;
+			if (qc->tf.flags & ATA_TFLAG_WRITE)
+				prot |= PRB_PROT_WRITE;
+			else
+				prot |= PRB_PROT_READ;
+			prb->prot = cpu_to_le16(prot);
+		}
 	} else {
 		prb = &cb->atapi.prb;
 		sge = cb->atapi.sge;


cpqarray: fix wrong __init type on pci probe function

It needs to be __devinit, not __init.

Signed-off-by: Jens Axboe <08e836a620179c237f631ad0545a7ebdf54201f3@fusionio.com>

--- drivers/block/cpqarray.c
+++ drivers/block/cpqarray.c
@@ -503,7 +503,7 @@
 	return -1;
 }

-static int __init cpqarray_init_one( struct pci_dev *pdev,
+static int __devinit cpqarray_init_one( struct pci_dev *pdev,
 	const struct pci_device_id *ent)
 {
 	int i;


ast-test should also finalize functions directly

--- test/ast-test.c
+++ test/ast-test.c
@@ -120,6 +120,8 @@
         if (!ast_function_codegen(functions_data[i], ir)) {
             assert(!"failed to generate function");
         }
+        if (!ir_function_finalize(functions_data[i]->ir_func))
+            assert(!"finalize on function failed...");
     }

     /* dump */


niftify mount(8) output for glusterfs mounts

Originally, mount(8) shows a glusterfs mount like this:

glusterfs on <mp> type fuse

With this patch, mount(8) will show a glusterfs mount like this:

<volfile> on <mp> type fuse.glusterfs

Signed-off-by: Anand V. Avati <6a1810c170bd423868ce2e225ecea39d80cade0f@amp.gluster.com>

--- xlators/mount/fuse/src/fuse-bridge.c
+++ xlators/mount/fuse/src/fuse-bridge.c
@@ -2692,56 +2692,80 @@
         return 0;
 }

+static struct fuse_opt subtype_workaround[] = {
+	FUSE_OPT_KEY("subtype=", 0),
+	FUSE_OPT_KEY("fssubtype=", 0),
+	FUSE_OPT_END
+};
+
+static int
+subtype_workaround_optproc(void *data, const char *arg, int key,
+                           struct fuse_args *outargs)
+{
+	return key ? 1 : 0;
+}
+
 int
 init (xlator_t *this_xl)
 {
 	int ret = 0;
 	dict_t *options = NULL;
 	char *value_string = NULL;
+	char *fsname = NULL, *fsname_opt = NULL;
 	fuse_private_t *priv = NULL;
 	struct stat stbuf = {0,};
+	struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
+	char **p = NULL;

 #ifdef GF_DARWIN_HOST_OS
-        int fuse_argc = 9;
 	char *fuse_argv[] = {"glusterfs",
+			     "-o", "XXX",
+			     "-o", "fssubtype=glusterfs",
 			     "-o", "allow_other",
 			     "-o", "default_permissions",
-			     "-o", "fsname=glusterfs",
-			     "-o", "local",
+			     NULL, NULL,
 			     NULL};

+	for (p = fuse_argv; *p; p++);
+	if (!dict_get (options, "macfuse-local")) {
+		/* This way, GlusterFS will be detected as 'servers' instead
+		 *  of 'devices'. This method is useful if you want to do
+		 * 'umount <mount_point>' over network,  instead of 'eject'ing
+		 * it from desktop. Works better for servers
+		 */
+		*(p++) = "-o";
+		*(p++) = "local";
+	}
+
 #elif GF_LINUX_HOST_OS /* ! DARWIN_OS */
-        int fuse_argc = 19;
-
 	char *fuse_argv[] = {"glusterfs",
+			     "-o", "XXX",
+			     "-o", "subtype=glusterfs",
 			     "-o", "nonempty",
 			     "-o", "max_readahead=1048576",
 			     "-o", "max_read=1048576",
 			     "-o", "max_write=1048576",
 			     "-o", "allow_other",
 			     "-o", "default_permissions",
-			     "-o", "fsname=glusterfs",
 			     "-o", "dev",
 			     "-o", "suid",
 			     NULL};

 #else /* BSD || SOLARIS */
 	/* BSD fuse doesn't support '-o dev', '-o nonempty' option */
-        int fuse_argc = 15;
-
 	char *fuse_argv[] = {"glusterfs",
+			     "-o", "XXX",
+			     "-o", "subtype=glusterfs",
 			     "-o", "max_readahead=1048576",
 			     "-o", "max_read=1048576",
 			     "-o", "max_write=1048576",
 			     "-o", "allow_other",
 			     "-o", "default_permissions",
-			     "-o", "fsname=glusterfs",
 			     "-o", "suid",
 			     NULL};

 #endif /* ! DARWIN_OS || ! LINUX */
-        struct fuse_args args = FUSE_ARGS_INIT (fuse_argc, fuse_argv);
-
+
 	if (this_xl == NULL)
 		return -1;

@@ -2750,34 +2774,33 @@

 	options = this_xl->options;

-	if (this_xl->name == NULL)
+	if (this_xl->name == NULL) {
 		this_xl->name = strdup ("fuse");
+		ERR_ABORT(this_xl->name);
+	}
+
+	fsname = this_xl->ctx->cmd_args.volume_file;
+	fsname = (fsname ? fsname : this_xl->ctx->cmd_args.volfile_server);
+	fsname = (fsname ? fsname : "glusterfs");
+	ret = asprintf(&fsname_opt, "fsname=%s", fsname);
+	if (ret == -1)
+		ERR_ABORT(NULL);
+	fuse_argv[2] = fsname_opt;
+
+	for (p = fuse_argv; *p; p++);
+	args.argc = p - fuse_argv;
+	args.argv = fuse_argv;

         priv = CALLOC (1, sizeof (*priv));
         ERR_ABORT (priv);
         this_xl->private = (void *) priv;
-
-
-#ifdef GF_DARWIN_HOST_OS
-	if (dict_get (options, "macfuse-local")) {
-		/* This way, GlusterFS will be detected as 'servers' instead
-		 *  of 'devices'. This method is useful if you want to do
-		 * 'umount <mount_point>' over network,  instead of 'eject'ing
-		 * it from desktop. Works better for servers
-		 */
-		/* Make the '-o local' in argv as NULL, so that its not
-		   in effect */
-		fuse_argv[--args.argc] = NULL;
-		fuse_argv[--args.argc] = NULL;
-	}
-#endif /* ! DARWIN */

 	/* get options from option dictionary */
 	ret = dict_get_str (options, ZR_MOUNTPOINT_OPT, &value_string);
 	if (value_string == NULL) {
                 gf_log ("fuse", GF_LOG_ERROR,
 			"mandatory option mountpoint is not specified");
-		return -1;
+		goto cleanup_exit;
 	}

 	if (stat (value_string, &stbuf) != 0) {
@@ -2796,17 +2819,17 @@
 				ZR_MOUNTPOINT_OPT,
 				value_string, strerror (errno));
 		}
-		return -1;
+		goto cleanup_exit;
 	}

 	if (S_ISDIR (stbuf.st_mode) == 0) {
 		gf_log (this_xl->name, GF_LOG_ERROR ,
 			"%s %s is not a directory",
 			ZR_MOUNTPOINT_OPT, value_string);
-		return -1;
+		goto cleanup_exit;
 	}
 	priv->mount_point = strdup (value_string);
-
+	ERR_ABORT(priv->mount_point);

 	ret = dict_get_double (options, "attribute-timeout",
 			       &priv->attribute_timeout);
@@ -2860,6 +2883,27 @@

         priv->se = fuse_lowlevel_new (&args, &fuse_ops,
 				      sizeof (fuse_ops), this_xl);
+        if (priv->se == NULL && !errno) {
+        	/*
+        	 * Option parsing misery. Can happen if libfuse is of
+        	 * FUSE < 2.7.0, as then the "-o subtype" option is not
+        	 * handled.
+        	 *
+        	 * Best we can do to is to handle it at runtime -- this is not
+        	 * a binary incompatibility issue (which should dealt with at
+        	 * compile time), but a behavioural incompatibility issue. Ie.
+        	 * we can't tell in advance whether the lib we use supports
+        	 * "-o subtype". So try to be clever now.
+        	 *
+        	 * Delete the subtype option, and try again.
+        	 */
+        	if (fuse_opt_parse(&args, NULL, subtype_workaround,
+        	                   subtype_workaround_optproc) == 0)
+        		priv->se = fuse_lowlevel_new (&args, &fuse_ops,
+        			                      sizeof (fuse_ops),
+        		                              this_xl);
+        }
+
         if (priv->se == NULL) {
                 gf_log ("glusterfs-fuse", GF_LOG_ERROR,
                         "fuse_lowlevel_new() failed with error %s on "
@@ -2877,6 +2921,7 @@
         }

         fuse_opt_free_args (&args);
+        FREE (fsname_opt);

         fuse_session_add_chan (priv->se, priv->ch);

@@ -2893,7 +2938,9 @@
         fuse_unmount (priv->mount_point, priv->ch);
 cleanup_exit:
         fuse_opt_free_args (&args);
-        FREE (priv->mount_point);
+        FREE (fsname_opt);
+        if (priv)
+        	FREE (priv->mount_point);
         FREE (priv);
         return -1;
 }


evp_test: address NULL pointer dereference and return failure better

Reviewed-by: Shane Lontis <452ce16516ceed26291fe7de3f8b53540d83864e@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/15910)

--- test/evp_test.c
+++ test/evp_test.c
@@ -2006,8 +2006,10 @@
         pbe_type = PBE_TYPE_PKCS12;
     } else {
         TEST_error("Unknown pbe algorithm %s", alg);
-    }
-    pdat = OPENSSL_zalloc(sizeof(*pdat));
+        return 0;
+    }
+    if (!TEST_ptr(pdat = OPENSSL_zalloc(sizeof(*pdat))))
+        return 0;
     pdat->pbe_type = pbe_type;
     t->data = pdat;
     return 1;


Call EVP_CipherFinal in CCM mode for tests.

Reviewed-by: Matt Caswell <1fa2ef4755a9226cb9a0a4840bd89b158ac71391@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2550)

--- test/evp_test.c
+++ test/evp_test.c
@@ -1040,13 +1040,9 @@
             tmplen += chunklen;
         }
     }
-    if (cdat->aead == EVP_CIPH_CCM_MODE)
-        tmpflen = 0;
-    else {
-        err = "CIPHERFINAL_ERROR";
-        if (!EVP_CipherFinal_ex(ctx, tmp + out_misalign + tmplen, &tmpflen))
-            goto err;
-    }
+    err = "CIPHERFINAL_ERROR";
+    if (!EVP_CipherFinal_ex(ctx, tmp + out_misalign + tmplen, &tmpflen))
+        goto err;
     err = "LENGTH_MISMATCH";
     if (out_len != (size_t)(tmplen + tmpflen))
         goto err;


Renamed file_size -> size for consistency

--- test/metadata.c
+++ test/metadata.c
@@ -286,7 +286,7 @@

   @param metadata The metadata struct containing the history.
   @param backup The backup, to which the history point belongs.
-  @param file_size The size of the config file at the backup point.
+  @param size The size of the config file at the backup point.
   @param hash The hash of the config file during the backup point. Read the
   documentation of RegularMetadata for more informations on how and when
   the hash will be stored.
@@ -294,7 +294,7 @@
   Will be ignored if the file size is not greater than SHA_DIGEST_LENGTH.
 */
 static void appendConfHist(Metadata *metadata, Backup *backup,
-                           uint64_t file_size, uint8_t *hash, uint8_t slot)
+                           uint64_t size, uint8_t *hash, uint8_t slot)
 {
   PathHistory *history_point = mpAlloc(sizeof *history_point);

@@ -326,7 +326,7 @@
     };

   history_point->state.metadata.reg.mode = 0;
-  assignRegularValues(&history_point->state, file_size, hash, slot);
+  assignRegularValues(&history_point->state, size, hash, slot);
   history_point->next = NULL;
 }

@@ -397,13 +397,13 @@
 /** Assert that the given metadata contains a config history point with the
   specified properties. Counterpart to appendConfHist(). */
 static void mustHaveConf(Metadata *metadata, Backup *backup,
-                         uint64_t file_size, uint8_t *hash, uint8_t slot)
+                         uint64_t size, uint8_t *hash, uint8_t slot)
 {
   for(PathHistory *point = metadata->config_history;
       point != NULL; point = point->next)
   {
     if(point->backup == backup &&
-       checkRegularValues(&point->state, file_size, hash, slot))
+       checkRegularValues(&point->state, size, hash, slot))
     {
       return;
     }


tests: fix most of the rganalysis unit tests

Before the element would post messages on the bus itself, now
the sinks do that based on the tag events they receive. But
since we don't have proper sink elements in these unit tests,
but just dangling pads, we have to post the tag messages the
test checks for ourselves.

Down from 52/55 failing to 7/52 failing.

--- tests/check/elements/rganalysis.c
+++ tests/check/elements/rganalysis.c
@@ -66,6 +66,7 @@
  * sink pads we create; otherwise we always have to do get_pad, get_peer, and
  * then remove references in every test function */
 static GstPad *mysrcpad, *mysinkpad;
+static GstBus *mybus;

 /* Mapping from supported sample rates to the correct result gain for the
  * following test waveform: 20 * 512 samples with a quarter-full amplitude of
@@ -146,6 +147,27 @@
     GST_STATIC_CAPS (RG_ANALYSIS_CAPS_TEMPLATE_STRING)
     );

+static gboolean
+mysink_event_func (GstPad * pad, GstObject * parent, GstEvent * event)
+{
+  GST_LOG_OBJECT (pad, "%s event: %" GST_PTR_FORMAT,
+      GST_EVENT_TYPE_NAME (event), event);
+
+  /* a sink would post tag events as messages, so do the same here,
+   * esp. since we're polling on the bus waiting for TAG messages.. */
+  if (GST_EVENT_TYPE (event) == GST_EVENT_TAG) {
+    GstTagList *taglist;
+
+    gst_event_parse_tag (event, &taglist);
+
+    gst_bus_post (mybus, gst_message_new_tag (GST_OBJECT (mysinkpad),
+            gst_tag_list_copy (taglist)));
+  }
+
+  gst_event_unref (event);
+  return TRUE;
+}
+
 static GstElement *
 setup_rganalysis (void)
 {
@@ -156,13 +178,14 @@
   analysis = gst_check_setup_element ("rganalysis");
   mysrcpad = gst_check_setup_src_pad (analysis, &srctemplate);
   mysinkpad = gst_check_setup_sink_pad (analysis, &sinktemplate);
+  gst_pad_set_event_function (mysinkpad, mysink_event_func);
   gst_pad_set_active (mysrcpad, TRUE);
   gst_pad_set_active (mysinkpad, TRUE);

   bus = gst_bus_new ();
   gst_element_set_bus (analysis, bus);
-  /* gst_element_set_bus does not steal a reference. */
-  gst_object_unref (bus);
+
+  mybus = bus;                  /* keep ref */

   return analysis;
 }
@@ -175,6 +198,9 @@
   g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
   g_list_free (buffers);
   buffers = NULL;
+
+  gst_object_unref (mybus);
+  mybus = NULL;

   /* The bus owns references to the element: */
   gst_element_set_bus (element, NULL);
@@ -1236,7 +1262,6 @@
   poll_eos (element);

   /* Now back to a track without tags. */
-
   send_flush_events (element);
   send_segment_event (element);
   for (i = 20; i--;)


test/pollfree: use mmap(2) instead of a manual syscall

A lot of the syzkaller tests aren't really applicable on non-x86,
or just simply assume x86.

Replace the syscall(__NR_mmap, ...) usage with a regular mmap(2) call,
and check for failure. Looks like some of these assume 4k pages as
well, so just bail if we fail mapping.

Fixes: https://github.com/axboe/liburing/issues/532
Signed-off-by: Jens Axboe <cd8c6775e60d6f67a6984377324e5290df3d5358@kernel.dk>

--- test/pollfree.c
+++ test/pollfree.c
@@ -391,12 +391,24 @@

 int main(int argc, char *argv[])
 {
+  void *ret;
+
+#if !defined(__i386) && !defined(__x86_64__)
+  return 0;
+#endif
+
   if (argc > 1)
     return 0;

-  syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
-  syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul);
-  syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
+  ret = mmap((void *)0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
+  if (ret == MAP_FAILED)
+    return 0;
+  mmap((void *)0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul);
+  if (ret == MAP_FAILED)
+    return 0;
+  mmap((void *)0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
+  if (ret == MAP_FAILED)
+    return 0;
   loop();
   return 0;
 }


Removed un-needed test suite creationg in constraint_messages_tests.c

--- tests/constraint_messages_tests.c
+++ tests/constraint_messages_tests.c
@@ -195,48 +195,3 @@
     throw;
 }
 #endif
-
-TestSuite *all_constraints_tests() {
-    TestSuite *suite = create_test_suite();
-
-#ifdef __cplusplus
-    add_test_with_context(suite, FailureMessage, for_incorrect_assert_throws);
-    add_test_with_context(suite, FailureMessage, if_exception_was_expected_but_nothing_thrown);
-    add_test_with_context(suite, FailureMessage, increments_exception_count_when_throwing);
-#endif
-    add_test_with_context(suite, FailureMessage, increments_exception_count_when_terminating_via_SIGQUIT);
-    add_test_with_context(suite, FailureMessage, for_is_null);
-    add_test_with_context(suite, FailureMessage, for_is_non_null);
-    add_test_with_context(suite, FailureMessage, for_is_equal_to);
-    add_test_with_context(suite, FailureMessage, for_is_not_equal_to);
-    add_test_with_context(suite, FailureMessage, for_is_greater_than);
-    add_test_with_context(suite, FailureMessage, for_is_less_than);
-    add_test_with_context(suite, FailureMessage, for_is_equal_to_double);
-    add_test_with_context(suite, FailureMessage, for_is_not_equal_to_double);
-    add_test_with_context(suite, FailureMessage, for_is_greater_than_double);
-    add_test_with_context(suite, FailureMessage, for_is_less_than_double);
-    add_test_with_context(suite, FailureMessage, for_is_equal_to_contents_of);
-    add_test_with_context(suite, FailureMessage, for_is_not_equal_to_contents_of);
-    add_test_with_context(suite, FailureMessage, for_is_equal_to_string);
-    add_test_with_context(suite, FailureMessage, for_is_not_equal_to_string);
-    add_test_with_context(suite, FailureMessage, for_contains_string);
-    add_test_with_context(suite, FailureMessage, for_does_not_contain_string);
-    add_test_with_context(suite, FailureMessage, for_begins_with_string);
-    add_test_with_context(suite, FailureMessage, for_equal_to_double);
-    add_test_with_context(suite, FailureMessage, for_equal_to_double_negative);
-    add_test_with_context(suite, FailureMessage, for_not_equal_to_double);
-    add_test_with_context(suite, FailureMessage, for_not_equal_to_double_negative);
-    add_test_with_context(suite, FailureMessage, for_is_less_than_double_with_accuracy);
-    add_test_with_context(suite, FailureMessage, for_is_greater_than_double_with_accuracy);
-    add_test_with_context(suite, FailureMessage, for_assert_that);
-    add_test_with_context(suite, FailureMessage, for_mock_called_with_unexpected_parameter_value);
-    add_test_with_context(suite, FailureMessage, for_mock_called_more_times_than_expected);
-    add_test_with_context(suite, FailureMessage, for_mock_called_without_expectation);
-    add_test_with_context(suite, FailureMessage, for_always_followed_by_expectation);
-    add_test_with_context(suite, FailureMessage, for_violated_never_expect);
-    add_test_with_context(suite, FailureMessage, for_mock_parameter_name_not_matching_constraint_parameter_name);
-    add_test_with_context(suite, FailureMessage, for_no_mock_parameters_with_parameter_constraint);
-
-
-    return suite;
-}


RT 3493: fix RSA test

RT 3493: fix RSA test

- Pass in the right ciphertext length to ensure we're indeed testing
  ciphertext corruption (and not truncation).
- Only test one mutation per byte to not make the test too slow.
- Add a separate test for truncated ciphertexts.

Reviewed-by: Richard Levitte <5fb523282dd7956571c80524edc2dccfa0bd8234@openssl.org>

--- test/rsa_test.c
+++ test/rsa_test.c
@@ -297,22 +297,30 @@
         } else
             printf("OAEP encryption/decryption ok\n");

-        /* Try decrypting corrupted ciphertexts */
+        /* Try decrypting corrupted ciphertexts. */
         for (n = 0; n < clen; ++n) {
-            int b;
-            unsigned char saved = ctext[n];
-            for (b = 0; b < 256; ++b) {
-                if (b == saved)
-                    continue;
-                ctext[n] = b;
-                num = RSA_private_decrypt(num, ctext, ptext, key,
+            ctext[n] ^= 1;
+            num = RSA_private_decrypt(clen, ctext, ptext, key,
                                           RSA_PKCS1_OAEP_PADDING);
-                if (num > 0) {
-                    printf("Corrupt data decrypted!\n");
-                    err = 1;
-                }
+            if (num > 0) {
+                printf("Corrupt data decrypted!\n");
+                err = 1;
+                break;
             }
-        }
+            ctext[n] ^= 1;
+        }
+
+        /* Test truncated ciphertexts, as well as negative length. */
+        for (n = -1; n < clen; ++n) {
+            num = RSA_private_decrypt(n, ctext, ptext, key,
+                                      RSA_PKCS1_OAEP_PADDING);
+            if (num > 0) {
+                printf("Truncated data decrypted!\n");
+                err = 1;
+                break;
+            }
+        }
+
  next:
         RSA_free(key);
     }


tests: more diagnostics from sda-test

tests: more diagnostics from sda-test

Signed-off-by: Dmitry Eremin-Solenikov <b6edad08270b2e4ffbcb0879e25a0e29a48c5275@gmail.com>

--- test/sda-test.c
+++ test/sda-test.c
@@ -197,6 +197,7 @@

 	struct emv_pk *ipk = emv_pki_recover_issuer_cert(pk, db);
 	if (!ipk) {
+		fprintf(stderr, "Could not recover Issuer certificate!\n");
 		tlvdb_free(db);
 		return 2;
 	}
@@ -205,14 +206,22 @@

 	struct tlvdb *dacdb = emv_pki_recover_dac(ipk, db, ssd1, sizeof(ssd1));
 	if (!dacdb) {
+		fprintf(stderr, "Could not recover DAC!\n");
 		emv_pk_free(ipk);
 		tlvdb_free(db);
 		return 2;
 	}

 	const struct tlv *dac = tlvdb_get(dacdb, 0x9f45, NULL);
-	if (dac)
-		dump_buffer(dac->value, dac->len, stdout);
+	if (!dac) {
+		fprintf(stderr, "DAC not found!\n");
+		tlvdb_free(dacdb);
+		emv_pk_free(ipk);
+		tlvdb_free(db);
+		return 2;
+	}
+
+	dump_buffer(dac->value, dac->len, stdout);

 	tlvdb_free(dacdb);
 	emv_pk_free(ipk);
@@ -226,8 +235,10 @@
 	int ret;

 	ret = sda_test_raw();
-	if (ret)
+	if (ret) {
+		fprintf(stderr, "Error performing cryptography check!\n");
 		return ret;
+	}

 	ret = sda_test_pk();
 	if (ret)


Add proxy server support to serf_get testing utility.

* test/serf_get.c
  (print_usage): Add '-p' option description.
  (main): Parse '-p' option and pass it to serf. Use
   serf_connection_create2() instead of serf_connection_create() to create
   serf connection.

git-svn-id: 683495cb1553624b05a54e2ba9533425f69cf277@1315 61a7d7f5-40b7-0310-9c16-bb0ea8cb1845

--- test/serf_get.c
+++ test/serf_get.c
@@ -243,19 +243,20 @@
     puts("-a <user:password> Present Basic authentication credentials");
     puts("-m <method> Use the <method> HTTP Method");
     puts("-f <file> Use the <file> as the request body");
+    puts("-p <hostname:port> Use the <host:port> as proxy server");
 }

 int main(int argc, const char **argv)
 {
     apr_status_t status;
     apr_pool_t *pool;
-    apr_sockaddr_t *address;
     serf_context_t *context;
     serf_connection_t *connection;
     serf_request_t *request;
     app_baton_t app_ctx;
     handler_baton_t handler_ctx;
     apr_uri_t url;
+    const char *proxy = NULL;
     const char *raw_url, *method, *req_body_path = NULL;
     int count;
     int i;
@@ -280,7 +281,7 @@

     apr_getopt_init(&opt, pool, argc, argv);

-    while ((status = apr_getopt(opt, "a:f:hHm:n:v", &opt_c, &opt_arg)) ==
+    while ((status = apr_getopt(opt, "a:f:hHm:n:vp:", &opt_c, &opt_arg)) ==
            APR_SUCCESS) {
         int srclen, enclen;

@@ -314,6 +315,9 @@
                 return errno;
             }
             break;
+        case 'p':
+            proxy = opt_arg;
+            break;
         case 'v':
             puts("Serf version: " SERF_VERSION_STRING);
             exit(0);
@@ -344,25 +348,63 @@
         app_ctx.using_ssl = 0;
     }

-    status = apr_sockaddr_info_get(&address,
-                                   url.hostname, APR_UNSPEC, url.port, 0,
-                                   pool);
-    if (status) {
-        printf("Error creating address: %d\n", status);
-        apr_pool_destroy(pool);
-        exit(1);
-    }
-
     context = serf_context_create(pool);
+
+    if (proxy)
+    {
+        apr_sockaddr_t *proxy_address = NULL;
+        apr_port_t proxy_port;
+        char *proxy_host;
+        char *proxy_scope;
+
+        status = apr_parse_addr_port(&proxy_host, &proxy_scope, &proxy_port, proxy, pool);
+        if (status)
+        {
+            printf("Cannot parse proxy hostname/port: %d\n", status);
+            apr_pool_destroy(pool);
+            exit(1);
+        }
+
+        if (!proxy_host)
+        {
+            printf("Proxy hostname must be specified\n");
+            apr_pool_destroy(pool);
+            exit(1);
+        }
+
+        if (!proxy_port)
+        {
+            printf("Proxy port must be specified\n");
+            apr_pool_destroy(pool);
+            exit(1);
+        }
+
+        status = apr_sockaddr_info_get(&proxy_address, proxy_host, APR_UNSPEC,
+                                       proxy_port, 0, pool);
+
+        if (status)
+        {
+            printf("Cannot resolve proxy address '%s': %d\n", proxy_host, status);
+            apr_pool_destroy(pool);
+            exit(1);
+        }
+
+        serf_config_proxy(context, proxy_address);
+    }

     /* ### Connection or Context should have an allocator? */
     app_ctx.bkt_alloc = serf_bucket_allocator_create(pool, NULL, NULL);
     app_ctx.ssl_ctx = NULL;

-    connection = serf_connection_create(context, address,
-                                        conn_setup, &app_ctx,
-                                        closed_connection, &app_ctx,
-                                        pool);
+    status = serf_connection_create2(&connection, context, url,
+                                     conn_setup, &app_ctx,
+                                     closed_connection, &app_ctx,
+                                     pool);
+    if (status) {
+        printf("Error creating connection: %d\n", status);
+        apr_pool_destroy(pool);
+        exit(1);
+    }

     handler_ctx.requests_outstanding = 0;
     handler_ctx.print_headers = print_headers;


Make test matrices for eigensolver/selfadjoint even more tricky

--- test/svd_fill.h
+++ test/svd_fill.h
@@ -53,18 +53,34 @@
     VT.setRandom();
   }

+  Matrix<Scalar,Dynamic,1> samples(7);
+  samples << 0, 5.60844e-313, -5.60844e-313, 4.94e-324, -4.94e-324, -1./NumTraits<RealScalar>::highest(), 1./NumTraits<RealScalar>::highest();
+
   if(Option==Symmetric)
   {
     m = U * d.asDiagonal() * U.transpose();

     // randomly nullify some rows/columns
     {
-      Index count = internal::random<Index>(-1,1);
+      Index count = internal::random<Index>(-diagSize,diagSize);
       for(Index k=0; k<count; ++k)
       {
         Index i = internal::random<Index>(0,diagSize-1);
         m.row(i).setZero();
         m.col(i).setZero();
+      }
+      if(count<0)
+      // (partly) cancel some coeffs
+      if(!(dup && unit_uv))
+      {
+
+        Index n = internal::random<Index>(0,m.size()-1);
+        for(Index k=0; k<n; ++k)
+        {
+          Index i = internal::random<Index>(0,m.rows()-1);
+          Index j = internal::random<Index>(0,m.cols()-1);
+          m(j,i) = m(i,j) = samples(internal::random<Index>(0,samples.size()-1));
+        }
       }
     }
   }
@@ -74,11 +90,9 @@
     // (partly) cancel some coeffs
     if(!(dup && unit_uv))
     {
-      Matrix<Scalar,Dynamic,1> samples(7);
-      samples << 0, 5.60844e-313, -5.60844e-313, 4.94e-324, -4.94e-324, -1./NumTraits<RealScalar>::highest(), 1./NumTraits<RealScalar>::highest();
       Index n = internal::random<Index>(0,m.size()-1);
       for(Index i=0; i<n; ++i)
-        m(internal::random<Index>(0,m.rows()-1), internal::random<Index>(0,m.cols()-1)) = samples(internal::random<Index>(0,6));
+        m(internal::random<Index>(0,m.rows()-1), internal::random<Index>(0,m.cols()-1)) = samples(internal::random<Index>(0,samples.size()-1));
     }
   }
 }


Fix 'malloc-nomem1' test for 32-bit architectures

--- test/test-api.c
+++ test/test-api.c
@@ -83,7 +83,7 @@
     void* p = mi_malloc(0); mi_free(p);
   });
   CHECK_BODY("malloc-nomem1",{
-    result = (mi_malloc(SIZE_MAX/2) == NULL);
+    result = (mi_malloc((size_t)PTRDIFF_MAX + (size_t)1) == NULL);
   });
   CHECK_BODY("malloc-null",{
     mi_free(NULL);


made testmany actually use name allocation

--- test/testmany.c
+++ test/testmany.c
@@ -40,10 +40,8 @@
 	int number;

 	for ( int i=0; i<num_sources; i++ ) {
-
-		sprintf( str, "source%d", i );

-		source_device_list[i] = mdev_new(str, port, 0);
+		source_device_list[i] = mdev_new("source", port, 0);
 		number = num_signals[i+num_dests];

 		for ( int j=0; j<number; j++ ) {
@@ -108,10 +106,8 @@
 	float mn=0, mx=1;

 	for ( int i=0; i<num_dests; i++ ) {
-
-		sprintf( str, "dest%d", i );

-		dest_device_list[i] = mdev_new(str, port, 0);
+		dest_device_list[i] = mdev_new("dest", port, 0);
 		number = num_signals[i];

 		for ( int j=0; j<number; j++ ) {


Fixed missing ; in tesmbox.c.

Fixed missing ; in tesmbox.c.

git-svn-id: de15d415ffb1bc5d91a165b5b7d2093897d104a2@5997 35acf78f-673a-0410-8e92-d51de3d6d3f4

--- test/testmbox.c
+++ test/testmbox.c
@@ -155,7 +155,7 @@
   /*
    * Testing I-Class.
    */
-  chSysLock()
+  chSysLock();
   msg1 = chMBPostI(&mb1, 'A');
   test_assert(22, msg1 == RDY_OK, "wrong wake-up message");
   msg1 = chMBPostI(&mb1, 'B');


Fix leak of AFfilesetup.

Fix leak of AFfilesetup.

--- test/writeraw.c
+++ test/writeraw.c
@@ -93,6 +93,7 @@

 	file = afOpenFile(TEST_FILE, "r", setup);
 	ensure(file != AF_NULL_FILEHANDLE, "unable to open file for reading");
+	afFreeFileSetup(setup);

 	ensure(afGetFileFormat(file, NULL) == AF_FILE_RAWDATA,
 		"test file not created as raw audio data file");


Forgot to scooch ray after construction

Forgot to scooch ray after construction

--- raycast.c
+++ raycast.c
@@ -220,10 +220,12 @@
   if(obj != surrounding_obj || NULL == surrounding_obj) {
     vec_copy(internal_ray.origin, refr_ray->origin);
     vec_copy(internal_ray.dir, refr_ray->dir);
+    scooch_ray_origin(refr_ray);
     return;
   } else {
     vec_copy(internal_intersect, refr_ray->origin);
     vec_copy(view_n, refr_ray->dir);
+    scooch_ray_origin(refr_ray);
     double out_surface_n[3] = {0.0};
     get_surface_normal(obj, internal_intersect, out_surface_n);
     if(-vec_dot(view_n, surface_n) != vec_dot(refr_ray->dir, out_surface_n)) {


always init queues

always init queues

--- rdkafka.c
+++ rdkafka.c
@@ -160,9 +160,9 @@

     if (type == RD_KAFKA_CONSUMER) {
         zend_hash_init(&intern->consuming, 0, NULL, (dtor_func_t)toppar_pp_dtor, 0);
-        zend_hash_init(&intern->queues, 0, NULL, (dtor_func_t)kafka_queue_object_pre_free, 0);
-    }
-
+    }
+
+    zend_hash_init(&intern->queues, 0, NULL, (dtor_func_t)kafka_queue_object_pre_free, 0);
     zend_hash_init(&intern->topics, 0, NULL, (dtor_func_t)kafka_topic_object_pre_free, 0);
 }
 /* }}} */


Fixed rd_alert() call to be va-arg safe

Fixed rd_alert() call to be va-arg safe

--- rdtimer.c
+++ rdtimer.c
@@ -206,15 +206,12 @@
 				 * enqueued for this timer. The thread
 				 * is probably stalled. */
 				rd_alert(RD_ALERT_THREAD_STALL, LOG_WARNING,
-					 rd_tsprintf("Timer %p has %i events "
-						     "enqueued on thread \"%s\""
-						     "(%p): thread stalled?",
-						     rt, rt->rt_called,
-						     rt->rt_thread->rdt_name,
-						     rt->rt_thread),
-					 rt->rt_thread,
-					 (rt->rt_called * rt->rt_interval) /
-					 1000);
+					 "Timer %p has %i events "
+					 "enqueued on thread \"%s\""
+					 "(%p): thread stalled?",
+					 rt, rt->rt_called,
+					 rt->rt_thread->rdt_name,
+					 rt->rt_thread);
 			}

 			/* Indicate with called counter that we're in


re-print header on resizes

re-print header on resizes

--- tasknc.c
+++ tasknc.c
@@ -674,6 +674,7 @@

 	/* redraw windows */
 	tasklist_print_task_list();
+	print_header();

 	/* message about resize */
 	tnc_fprintf(logfp, LOG_DEBUG, "window resized to y=%d x=%d", rows, cols);


added default keybinds and bind logging

added default keybinds and bind logging

--- tasknc.c
+++ tasknc.c
@@ -104,7 +104,7 @@
 /* }}} */

 /* function prototypes {{{ */
-static void add_keybind(char, void *);
+static void add_keybind(int, void *);
 static void check_curs_pos(void);
 static void check_screen_size();
 static char compare_tasks(const task *, const task *, const char);
@@ -220,10 +220,11 @@
 };
 /* }}} */

-void add_keybind(char key, void *function) /* {{{ */
+void add_keybind(int key, void *function) /* {{{ */
 {
         /* add a keybind to the list of binds */
         keybind *this_bind, *new;
+        int n = 0;

         /* create new bind */
         new = calloc(1, sizeof(keybind));
@@ -237,10 +238,14 @@
         else
         {
                 this_bind = keybinds;
-                while (this_bind->next!=NULL)
+                for (n=0; this_bind->next!=NULL; n++)
                         this_bind = this_bind->next;
                 this_bind->next = new;
-        }
+                n++;
+        }
+
+        /* write log */
+        logmsg(LOG_DEBUG, "bind #%d: key %c (%d) bound to @%p", n, key, key, function);
 } /* }}} */

 void check_curs_pos(void) /* {{{ */
@@ -401,6 +406,29 @@
         pclose(cmd);

         /* TODO: create default keybinds */
+        add_keybind(ERR,       NULL);
+        add_keybind('k',       key_scroll_up);
+        add_keybind(KEY_UP,    key_scroll_up);
+        add_keybind('j',       key_scroll_down);
+        add_keybind(KEY_DOWN,  key_scroll_down);
+        add_keybind(KEY_HOME,  key_scroll_beginning);
+        add_keybind(KEY_END,   key_scroll_end);
+        add_keybind('e',       key_edit);
+        add_keybind('r',       key_reload);
+        add_keybind('u',       key_undo);
+        add_keybind('d',       key_delete);
+        add_keybind('c',       key_complete);
+        add_keybind('v',       key_view);
+        add_keybind(13,        key_view);
+        add_keybind(KEY_ENTER, key_view);
+        add_keybind('s',       key_sort);
+        add_keybind('/',       key_search);
+        add_keybind('n',       key_search_next);
+        add_keybind('f',       key_filter);
+        add_keybind('y',       key_sync);
+        add_keybind('q',       key_done);
+        add_keybind(';',       key_command);
+        add_keybind(':',       key_command);

         /* determine config path */
         xdg_config_home = getenv("XDG_CONFIG_HOME");


Update main.c

Update main.c

--- part1/main.c
+++ part1/main.c
@@ -3,6 +3,8 @@
 #include <pthread.h>
 #include <time.h>
 #include <string.h>
+#include "bitonicSortSerial.h"
+#include "bitonicSortParallel.h"

 #define MAX(A,B) ((A > B) ? A : B)
 #define MIN(A,B) ((A > B) ? B : A)


spacing

spacing

--- pfl/ctlsvr.c
+++ pfl/ctlsvr.c
@@ -1606,7 +1606,7 @@
 		return (psc_ctlsenderr(fd, mh,
 		    "%s: parameter field exceeds maximum depth",
 		    psc_ctlparam_fieldname(pcp->pcp_field,
-		    MAX_LEVELS-1)));
+		    MAX_LEVELS - 1)));

 	if (set) {
 		rc = pfl_socket_getpeercred(fd, &uid, &gid);


Removed silly debug stuff

Removed silly debug stuff

--- mappers/filter.h
+++ mappers/filter.h
@@ -10,11 +10,10 @@
         using item = SequenceItemType<Sequence>;
     public:
         filter_sequence(Sequence &&source, Predicate predicateFunction)
-                : source(std::move(source)), predicateFunction(predicateFunction), started(false), test(43) { };
+                : source(std::move(source)), predicateFunction(predicateFunction), started(false) {};

         filter_sequence(filter_sequence &&other)
-                : source(std::move(other.source)), predicateFunction(other.predicateFunction), started(other.started),
-                  test(44) { };
+                : source(std::move(other.source)), predicateFunction(other.predicateFunction), started(other.started) {};

         bool done() {
             if (source.done()) return true;
@@ -38,7 +37,6 @@
         Sequence source;
         Predicate predicateFunction;
         bool started;
-        int test;
     };

     template<typename Predicate>


perf tools: Fix detection of stack area

perf tools: Fix detection of stack area

Output of /proc/<pid>/maps contains helpful information to anonymous
mappings like stack, heap, ...  For the case of stack, it can show
multiple stack area for each thread in the process:

  $ cat /proc/$(pidof gnome-shell)/maps | grep stack
  7fe019946000-7fe01a146000 rw-p 00000000 00:00 0          [stack:1624]
  7fe040e32000-7fe041632000 rw-p 00000000 00:00 0          [stack:1451]
  7fe041643000-7fe041e43000 rw-p 00000000 00:00 0          [stack:1450]
  7fe04204b000-7fe04284b000 rw-p 00000000 00:00 0          [stack:1449]
  7fe042a7e000-7fe04327e000 rw-p 00000000 00:00 0          [stack:1446]
  7fe0432ff000-7fe043aff000 rw-p 00000000 00:00 0          [stack:1445]
  7fe043b00000-7fe044300000 rw-p 00000000 00:00 0          [stack:1444]
  7fe044301000-7fe044b01000 rw-p 00000000 00:00 0          [stack:1443]
  7fe044b02000-7fe045302000 rw-p 00000000 00:00 0          [stack:1442]
  7fe045303000-7fe045b03000 rw-p 00000000 00:00 0          [stack:1441]
  7fe045b04000-7fe046304000 rw-p 00000000 00:00 0          [stack:1440]
  7fe046305000-7fe046b05000 rw-p 00000000 00:00 0          [stack:1439]
  7fe046b06000-7fe047306000 rw-p 00000000 00:00 0          [stack:1438]
  7fff4b16f000-7fff4b190000 rw-p 00000000 00:00 0          [stack]

However perf only knew about the main thread's.  Fix it.

Signed-off-by: Namhyung Kim <5c915a589b3ddf58cebf14bec41bcc143b37ac3c@kernel.org>
Cc: Andi Kleen <0474aee45985f5ae829f53849df476200e876990@linux.intel.com>
Cc: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@kernel.org>
Cc: Paul Mackerras <19a0ba370c443ba08d20b5061586430ab449ee8c@samba.org>
Cc: Peter Zijlstra <645ca7d3a8d3d4f60557176cd361ea8351edc32b@chello.nl>
Cc: Stephane Eranian <f199ae9781930a5b94b284ca2f471140752002a7@google.com>
Link: http://lkml.kernel.org/r/1352273234-28912-4-git-send-email-5c915a589b3ddf58cebf14bec41bcc143b37ac3c@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <293abb6b76d7791c0732cc517d38c4b5c734b87f@redhat.com>

--- tools/perf/util/map.c
+++ tools/perf/util/map.c
@@ -24,7 +24,7 @@

 static inline int is_no_dso_memory(const char *filename)
 {
-	return !strcmp(filename, "[stack]") ||
+	return !strncmp(filename, "[stack", 6) ||
 	       !strcmp(filename, "[heap]");
 }


poller trick with file reopening

poller trick with file reopening

Signed-off-by: Denis Zalevskiy <43c40921ef02e9bb53daac07eb9ed16452640d88@jolla.com>

--- tools/poller/poller.c
+++ tools/poller/poller.c
@@ -35,10 +35,6 @@
             printf("Can't open %s\n", name);
             goto out;
         }
-
-        memset(&pfds[i], 0, sizeof(pfds[0]));
-        pfds[i].fd = fds[i];
-        pfds[i].events = POLLIN | POLLPRI;
     }

     while (true) {
@@ -69,7 +65,6 @@
             char const *fname = argv[i + 1];

             printf("file %s: %d\n", fname, fd);
-            lseek(fd, 0, SEEK_SET);
             printf("rc %i, ev %x, rev %x\n", rc, pfd->events, pfd->revents);
             if (pfd->revents & (POLLERR | POLLHUP | POLLNVAL)) {
                 printf("Poll error(E H N)=(%d %d %d)\n"
@@ -79,6 +74,7 @@
                     );
                 goto out;
             }
+            int tmp = open(fname, O_RDONLY);
             memset(buf, 0, sizeof(buf));
             int rc = read(fd, buf, sizeof(buf) - 1);
             printf("read %i\n", rc);
@@ -87,6 +83,8 @@
                        , fname);
                 goto out;
             }
+            if (tmp >= 0) close(tmp);
+            lseek(fd, 0, SEEK_SET);
             if (rc) {
                 buf[rc] = 0;
                 printf("%s\n", buf);


core: update irq_arch documentation

core: update irq_arch documentation

--- core/include/arch/irq_arch.h
+++ core/include/arch/irq_arch.h
@@ -15,6 +15,9 @@
  *
  * This file acts as a wrapper between the kernels interrupt interface and the architecture
  * dependent implementation of the interfaces.
+ *
+ * @note All functions in this module have to be implemented in a way that it
+ *       is safe to call them from within the context of an ISR.
  *
  * @author      Hauke Petersen <hauke.petersen@fu-berlin.de>
  */


Also split sequence_info of deltarpms.

Also split sequence_info of deltarpms.

--- tools/repo_patchxml.c
+++ tools/repo_patchxml.c
@@ -119,7 +119,9 @@
   Id *bevr;
   unsigned nbevr;
   /* If deltarpm, then this is filled.  */
-  char *sequence_info;
+  Id seqname;
+  Id seqevr;
+  char *seqnum;
 };

 struct parsedata {
@@ -442,7 +444,29 @@
       break;
     case STATE_DBASEVERSION:
       if ((str = find_attr("sequence_info", atts)))
-        pd->delta.sequence_info = strdup(str);
+	{
+	  const char *s1, *s2;
+	  s1 = strrchr(str, '-');
+	  if (s1)
+	    {
+	      for (s2 = s1 - 1; s2 > str; s2--)
+	        if (*s2 == '-')
+		  break;
+	      if (*s2 == '-')
+	        {
+		  for (s2 = s2 - 1; s2 > str; s2--)
+		    if (*s2 == '-')
+		      break;
+		  if (*s2 == '-')
+		    {
+		      pd->delta.seqevr = strn2id(pool, s2 + 1, s1 - s2 - 1, 1);
+		      pd->delta.seqname = strn2id(pool, str, s2 - str, 1);
+		      str = s1 + 1;
+		    }
+		}
+	    }
+	  pd->delta.seqnum = strdup(str);
+	}
       pd->delta.nbevr++;
       pd->delta.bevr = sat_realloc (pd->delta.bevr, pd->delta.nbevr * sizeof(Id));
       pd->delta.bevr[pd->delta.nbevr - 1] = makeevr_atts(pool, pd, atts);
@@ -558,10 +582,17 @@
 	fprintf (stderr, "  size: %d down, %d archive\n", d->downloadsize,
 		 d->archivesize);
 	fprintf (stderr, "  chek: %s\n", d->filechecksum);
-	if (d->sequence_info)
+	if (d->seqnum)
 	  {
-	    fprintf (stderr, "  base: %s, seq: %s\n", id2str(pool, d->bevr[0]),
-	    	     d->sequence_info);
+	    fprintf (stderr, "  base: %s, seq: %s %s %s\n",
+		     id2str(pool, d->bevr[0]), id2str(pool, d->seqname),
+		     id2str(pool, d->seqevr), d->seqnum);
+	    if (d->seqevr != d->bevr[0])
+	      fprintf (stderr, "XXXXX evr\n");
+	    /* Name of package ("atom:xxxx") should match the sequence info
+	       name.  */
+	    if (strcmp(id2str(pool, d->seqname), id2str(pool, s->name) + 5))
+	      fprintf (stderr, "XXXXX name\n");
 	  }
 	else
 	  {
@@ -574,7 +605,7 @@
 #endif
       free(pd->delta.filechecksum);
       free(pd->delta.bevr);
-      free(pd->delta.sequence_info);
+      free(pd->delta.seqnum);
       break;
     case STATE_DCHECKSUM:
       pd->delta.filechecksum = strdup(pd->content);


Initialize message queue in proper place

--- core/mobile_app/mobile_app.c
+++ core/mobile_app/mobile_app.c
@@ -95,6 +95,7 @@
 		FQEntry *en = FCalloc( 1, sizeof( FQEntry ) );
 		if( en != NULL )
 		{
+			DEBUG("Message added to queue\n");
 			en->fq_Data = FMalloc( len+LWS_SEND_BUFFER_PRE_PADDING+LWS_SEND_BUFFER_POST_PADDING );
 			memcpy( en->fq_Data+LWS_SEND_BUFFER_PRE_PADDING, msg, len );
 			en->fq_Size = LWS_PRE+len;
@@ -227,13 +228,8 @@

 		return 0;
 	}
-
-	if( len == 0 )
-	{
-		DEBUG("Empty websocket frame (reason %d)\n", reason);
-		return 0;
-	}
-
+
+	DEBUG("Initialize queue\n");
 	char *data = (char*)in;
 	if( man != NULL )
 	{
@@ -242,7 +238,14 @@
 			memset( &(man->man_Queue), 0, sizeof( man->man_Queue ) );
 			FQInit( &(man->man_Queue) );
 			man->man_Initialized = 1;
-		}
+			DEBUG("Queue initialized\n");
+		}
+	}
+
+	if( len == 0 )
+	{
+		DEBUG("Empty websocket frame (reason %d)\n", reason);
+		return 0;
 	}

 	DEBUG("Mobile app data: <%*s>\n", (unsigned int)len, data);


Un-coarsen the time returned by gettimeofday() to the 10 microseconds

BUG=http://code.google.com/p/chromium/issues/detail?id=104745
Review URL: http://codereview.chromium.org/8992023

git-svn-id: 721b910a23eff8a86f00c8fd261a7587cddf18f8@7514 fcba33aa-ac0c-11dd-b9e7-8d5594d729c2

--- src/trusted/service_runtime/linux/nacl_syscall_impl.c
+++ src/trusted/service_runtime/linux/nacl_syscall_impl.c
@@ -338,12 +338,11 @@
   retval = NaClGetTimeOfDay(&now);
   if (0 == retval) {
     /*
-     * To make it harder to distinguish Linux platforms from Windows,
-     * coarsen the time to the same level we get on Windows -
-     * milliseconds, unless in "debug" mode.
+     * Coarsen the time to the same level we get on Windows -
+     * 10 microseconds.
      */
     if (!NaClHighResolutionTimerEnabled()) {
-      now.nacl_abi_tv_usec = (now.nacl_abi_tv_usec / 1000) * 1000;
+      now.nacl_abi_tv_usec = (now.nacl_abi_tv_usec / 10) * 10;
     }
     CHECK(now.nacl_abi_tv_usec >= 0);
     CHECK(now.nacl_abi_tv_usec < NACL_MICROS_PER_UNIT);


Create 69_sqrt.c

Create 69_sqrt.c

error: pathspec '69_sqrt.c' did not match any file(s) known to git

--- 69_sqrt.c
+++ 69_sqrt.c
@@ -0,0 +1,28 @@
+int mySqrt(int x) {
+    int cand;
+    int l, r, m;
+
+ //   assert(x >= 0);
+    if (x == 0 || x == 1)
+        return x;
+
+    cand = -1;
+    l = 1;
+    r = x/2;
+    //invariant:
+    while (l <= r) {
+        m = (l+r)/2;
+        if (m > x/m) { // in case multi overflow.
+            r = m - 1;
+        } else if (m*m < x) {
+            l = m + 1;
+            cand = m;
+        }  else {
+            return m;
+        }
+    }
+
+    //assert(cand != -1);
+
+    return cand;
+}


Avoid redundantly tracing HRTF status

Avoid redundantly tracing HRTF status

--- Alc/ALc.c
+++ Alc/ALc.c
@@ -1365,7 +1365,8 @@
         ERROR("HRTF disabled (format is %uhz %s)\n", device->Frequency, DevFmtChannelsString(device->FmtChans));
         device->Flags &= ~DEVICE_USE_HRTF;
     }
-    TRACE("HRTF %s\n", (device->Flags&DEVICE_USE_HRTF)?"enabled":"disabled");
+    else
+        TRACE("HRTF %s\n", (device->Flags&DEVICE_USE_HRTF)?"enabled":"disabled");

     if(!(device->Flags&DEVICE_USE_HRTF) && device->Bs2bLevel > 0 && device->Bs2bLevel <= 6)
     {


swrast: s/INLINE/inline/

swrast: s/INLINE/inline/

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

--- src/mesa/swrast/s_texfilter.c
+++ src/mesa/swrast/s_texfilter.c
@@ -804,7 +804,7 @@
 /**
  * Put z into texel according to GL_DEPTH_MODE.
  */
-static INLINE void
+static inline void
 apply_depth_mode(GLenum depthMode, GLfloat z, GLfloat texel[4])
 {
    switch (depthMode) {


Don't pass float literals for unsigned ints

--- Alc/ALu.c
+++ Alc/ALu.c
@@ -1300,8 +1300,8 @@
             HrtfMixerFunc HrtfMix = SelectHrtfMixer();
             ALuint irsize = GetHrtfIrSize(device->Hrtf);
             for(c = 0;c < device->NumChannels;c++)
-                HrtfMix(&device->DryBuffer[outchanoffset], device->DryBuffer[c], 0.0f,
-                    device->Hrtf_Offset, 0.0f, irsize, &device->Hrtf_Params[c],
+                HrtfMix(&device->DryBuffer[outchanoffset], device->DryBuffer[c], 0,
+                    device->Hrtf_Offset, 0, irsize, &device->Hrtf_Params[c],
                     &device->Hrtf_State[c], SamplesToDo
                 );
             device->Hrtf_Offset += SamplesToDo;


t_dd_dmatmp: Remove HAVE_ELTS support

t_dd_dmatmp: Remove HAVE_ELTS support

Two drivers use this file, and neither supports ELTs.

No piglit regressions on i915 (G33) or radeon (Radeon 7500).

Signed-off-by: Ian Romanick <2b237cafb16dc45038e85df6c85e74e6d899eba9@intel.com>
Reviewed-by: Brian Paul <3cb4e1df5ec4da2c7c4af7c52cec8cf340a55a10@vmware.com>

--- src/mesa/tnl_dd/t_dd_dmatmp.h
+++ src/mesa/tnl_dd/t_dd_dmatmp.h
@@ -43,60 +43,14 @@
 #error "must have lines, line strips, triangles, triangle fans, and triangle strips to use render template"
 #endif

-#if HAVE_QUAD_STRIPS || HAVE_QUADS
-#error "quads and quad strips not supported by render template"
-#endif
-
-#if !HAVE_ELTS
-#define ELTS_VARS(buf)
-#define ALLOC_ELTS(nr) 0
-#define EMIT_ELT( offset, elt )
-#define EMIT_TWO_ELTS( offset, elt0, elt1 )
-#define INCR_ELTS( nr )
-#define ELT_INIT(prim)
-#define GET_CURRENT_VB_MAX_ELTS() 0
-#define GET_SUBSEQUENT_VB_MAX_ELTS() 0
-#define RELEASE_ELT_VERTS()
-#define EMIT_INDEXED_VERTS( ctx, start, count )
-#endif
-
-#ifndef EMIT_TWO_ELTS
-#define EMIT_TWO_ELTS( offset, elt0, elt1 )	\
-do { 						\
-   EMIT_ELT( offset, elt0 ); 			\
-   EMIT_ELT( offset+1, elt1 ); 			\
-} while (0)
+#if HAVE_QUAD_STRIPS || HAVE_QUADS || HAVE_ELTS
+#error "ELTs, quads, and quad strips not supported by render template"
 #endif

 /**********************************************************************/
 /*                  Render whole begin/end objects                    */
 /**********************************************************************/
-
-
-
-
-#if (HAVE_ELTS)
-static void *TAG(emit_elts)( struct gl_context *ctx, GLuint *elts, GLuint nr,
-			     void *buf)
-{
-   GLint i;
-   LOCAL_VARS;
-   ELTS_VARS(buf);
-
-   for ( i = 0 ; i+1 < nr ; i+=2, elts += 2 ) {
-      EMIT_TWO_ELTS( 0, elts[0], elts[1] );
-      INCR_ELTS( 2 );
-   }
-
-   if (i < nr) {
-      EMIT_ELT( 0, elts[0] );
-      INCR_ELTS( 1 );
-   }
-
-   return (void *)ELTPTR;
-}
-#endif

 static __inline void *TAG(emit_verts)( struct gl_context *ctx, GLuint start,
 				     GLuint count, void *buf )
@@ -384,61 +338,11 @@

    if (ctx->Light.ShadeModel == GL_FLAT &&
        TNL_CONTEXT(ctx)->vb.AttribPtr[_TNL_ATTRIB_COLOR0]->stride) {
-      if (HAVE_ELTS) {
-	 LOCAL_VARS;
-	 int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
-	 int currentsz;
-	 GLuint j, nr;
-
-         EMIT_INDEXED_VERTS( ctx, start, count );
-
-	 /* Simulate flat-shaded quadstrips using indexed vertices:
-	  */
-	 ELT_INIT( GL_TRIANGLES );
-
-	 currentsz = GET_CURRENT_VB_MAX_ELTS();
-
-	 /* Emit whole number of quads in total, and in each buffer.
-	  */
-	 dmasz -= dmasz & 1;
-	 count -= count & 1;
-	 currentsz -= currentsz & 1;
-
-	 if (currentsz < 12)
-	    currentsz = dmasz;
-
-	 currentsz = currentsz/6*2;
-	 dmasz = dmasz/6*2;
-
-	 for (j = 0; j + 3 < count; j += nr - 2) {
-	    nr = MIN2( currentsz, count - j );
-	    if (nr >= 4) {
-	       GLint quads = (nr/2)-1;
-	       GLint i;
-	       ELTS_VARS( ALLOC_ELTS( quads*6 ) );
-
-               for (i = j; i < j + quads * 2; i += 2) {
-		  EMIT_TWO_ELTS( 0, (i+0), (i+1) );
-		  EMIT_TWO_ELTS( 2, (i+2), (i+1) );
-		  EMIT_TWO_ELTS( 4, (i+3), (i+2) );
-		  INCR_ELTS( 6 );
-	       }
-
-	       FLUSH();
-	    }
-	    currentsz = dmasz;
-	 }
-
-	 RELEASE_ELT_VERTS();
-	 FLUSH();
-      }
-      else {
 	 /* Vertices won't fit in a single buffer or elts not
 	  * available - should never happen.
 	  */
         fprintf(stderr, "%s - cannot draw primitive\n", __func__);
 	 return;
-      }
    } else {
       LOCAL_VARS;
       int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
@@ -478,57 +382,7 @@
    /* Emit whole number of quads in total. */
    count -= count & 3;

-   if (HAVE_ELTS) {
-      /* Hardware doesn't have a quad primitive type -- try to
-       * simulate it using indexed vertices and the triangle
-       * primitive:
-       */
-      LOCAL_VARS;
-      int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
-      int currentsz;
-      GLuint j, nr;
-
-      EMIT_INDEXED_VERTS( ctx, start, count );
-
-      FLUSH();
-      ELT_INIT( GL_TRIANGLES );
-      currentsz = GET_CURRENT_VB_MAX_ELTS();
-
-      /* Emit whole number of quads in total, and in each buffer.
-       */
-      dmasz -= dmasz & 3;
-      currentsz -= currentsz & 3;
-
-      /* Adjust for rendering as triangles:
-       */
-      currentsz = currentsz/6*4;
-      dmasz = dmasz/6*4;
-
-      if (currentsz < 8)
-	 currentsz = dmasz;
-
-      for (j = 0; j < count; j += nr ) {
-	 nr = MIN2( currentsz, count - j );
-	 if (nr >= 4) {
-	    GLint quads = nr/4;
-	    GLint i;
-	    ELTS_VARS( ALLOC_ELTS( quads*6 ) );
-
-            for (i = j; i < j + quads * 4; i += 4) {
-	       EMIT_TWO_ELTS( 0, (i+0), (i+1) );
-	       EMIT_TWO_ELTS( 2, (i+3), (i+1) );
-	       EMIT_TWO_ELTS( 4, (i+2), (i+3) );
-	       INCR_ELTS( 6 );
-	    }
-
-	    FLUSH();
-	 }
-	 currentsz = dmasz;
-      }
-
-      RELEASE_ELT_VERTS();
-   }
-   else {
+   {
       /* Hardware doesn't have a quad primitive type -- try to
        * simulate it using triangle primitive.  This is a win for
        * gears, but is it useful in the broader world?
@@ -577,430 +431,6 @@
    TAG(render_noop),
 };

-
-/****************************************************************************
- *                 Render elts using hardware indexed verts                 *
- ****************************************************************************/
-
-#if (HAVE_ELTS)
-static void TAG(render_points_elts)( struct gl_context *ctx,
-				     GLuint start,
-				     GLuint count,
-				     GLuint flags )
-{
-   if (HAVE_POINTS) {
-      LOCAL_VARS;
-      int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
-      int currentsz;
-      GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
-      GLuint j, nr;
-
-      ELT_INIT( GL_POINTS );
-
-      currentsz = GET_CURRENT_VB_MAX_ELTS();
-      if (currentsz < 8)
-	 currentsz = dmasz;
-
-      for (j = 0; j < count; j += nr ) {
-	 nr = MIN2( currentsz, count - j );
-         TAG(emit_elts)(ctx, elts + start + j, nr, ALLOC_ELTS(nr));
-	 FLUSH();
-	 currentsz = dmasz;
-      }
-   } else {
-      fprintf(stderr, "%s - cannot draw primitive\n", __func__);
-      return;
-   }
-}
-
-
-
-static void TAG(render_lines_elts)(struct gl_context *ctx,
-                                   GLuint start,
-                                   GLuint count,
-                                   GLuint flags)
-{
-   LOCAL_VARS;
-   int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
-   int currentsz;
-   GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
-   GLuint j, nr;
-
-   ELT_INIT(GL_LINES);
-
-   /* Emit whole number of lines in total and in each buffer:
-    */
-   count -= count & 1;
-   currentsz -= currentsz & 1;
-   dmasz -= dmasz & 1;
-
-   currentsz = GET_CURRENT_VB_MAX_ELTS();
-   if (currentsz < 8)
-      currentsz = dmasz;
-
-   for (j = 0; j < count; j += nr ) {
-      nr = MIN2(currentsz, count - j);
-      TAG(emit_elts)(ctx, elts + start + j, nr, ALLOC_ELTS(nr));
-      FLUSH();
-      currentsz = dmasz;
-   }
-}
-
-
-static void TAG(render_line_strip_elts)(struct gl_context *ctx,
-                                        GLuint start,
-                                        GLuint count,
-                                        GLuint flags)
-{
-   LOCAL_VARS;
-   int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
-   int currentsz;
-   GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
-   GLuint j, nr;
-
-   FLUSH(); /* always a new primitive */
-   ELT_INIT(GL_LINE_STRIP);
-
-   currentsz = GET_CURRENT_VB_MAX_ELTS();
-   if (currentsz < 8)
-      currentsz = dmasz;
-
-   for (j = 0; j + 1 < count; j += nr - 1) {
-      nr = MIN2(currentsz, count - j);
-      TAG(emit_elts)(ctx, elts + start + j, nr, ALLOC_ELTS(nr));
-      FLUSH();
-      currentsz = dmasz;
-   }
-}
-
-
-static void TAG(render_line_loop_elts)(struct gl_context *ctx,
-                                       GLuint start,
-                                       GLuint count,
-                                       GLuint flags)
-{
-   LOCAL_VARS;
-   int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
-   int currentsz;
-   GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
-   GLuint j, nr;
-
-   FLUSH();
-   ELT_INIT(GL_LINE_STRIP);
-
-   j = (flags & PRIM_BEGIN) ? 0 : 1;
-
-   currentsz = GET_CURRENT_VB_MAX_ELTS();
-   if (currentsz < 8)
-      currentsz = dmasz;
-
-   /* Ensure last vertex doesn't wrap:
-    */
-   currentsz--;
-   dmasz--;
-
-   if (j + 1 < count) {
-      for (/* empty */; j + 1 < count; j += nr - 1) {
-         nr = MIN2(currentsz, count - j);
-
-         if (j + nr >= count &&
-             count > 1 &&
-             (flags & PRIM_END)) {
-            void *tmp;
-            tmp = ALLOC_ELTS(nr+1);
-            tmp = TAG(emit_elts)(ctx, elts + start + j, nr, tmp);
-            tmp = TAG(emit_elts)(ctx, elts + start, 1, tmp);
-            (void) tmp;
-         } else {
-            TAG(emit_elts)(ctx, elts + start + j, nr, ALLOC_ELTS(nr));
-            currentsz = dmasz;
-         }
-      }
-   } else if (count > 1 && (flags & PRIM_END)) {
-      void *tmp;
-      tmp = ALLOC_ELTS(2);
-      tmp = TAG(emit_elts)( ctx, elts+start+1, 1, tmp );
-      tmp = TAG(emit_elts)( ctx, elts+start, 1, tmp );
-      (void) tmp;
-   }
-
-   FLUSH();
-}
-
-
-/* For verts, we still eliminate the copy from main memory to dma
- * buffers.  For elts, this is probably no better (worse?) than the
- * standard path.
- */
-static void TAG(render_triangles_elts)( struct gl_context *ctx,
-					GLuint start,
-					GLuint count,
-					GLuint flags )
-{
-   LOCAL_VARS;
-   GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
-   int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS()/3*3;
-   int currentsz;
-   GLuint j, nr;
-
-   FLUSH();
-   ELT_INIT( GL_TRIANGLES );
-
-   currentsz = GET_CURRENT_VB_MAX_ELTS();
-
-   /* Emit whole number of tris in total.  dmasz is already a multiple
-    * of 3.
-    */
-   count -= count % 3;
-   currentsz -= currentsz%3;
-   if (currentsz < 8)
-      currentsz = dmasz;
-
-   for (j = 0; j < count; j += nr) {
-      nr = MIN2( currentsz, count - j );
-      TAG(emit_elts)(ctx, elts + start + j, nr, ALLOC_ELTS(nr));
-      FLUSH();
-      currentsz = dmasz;
-   }
-}
-
-
-
-static void TAG(render_tri_strip_elts)(struct gl_context *ctx,
-                                       GLuint start,
-                                       GLuint count,
-                                       GLuint flags)
-{
-   LOCAL_VARS;
-   GLuint j, nr;
-   GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
-   int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
-   int currentsz;
-
-   FLUSH();
-   ELT_INIT(GL_TRIANGLE_STRIP);
-
-   currentsz = GET_CURRENT_VB_MAX_ELTS();
-   if (currentsz < 8)
-      currentsz = dmasz;
-
-   /* Keep the same winding over multiple buffers:
-    */
-   dmasz -= (dmasz & 1);
-   currentsz -= (currentsz & 1);
-
-   for (j = 0; j + 2 < count; j += nr - 2) {
-      nr = MIN2(currentsz, count - j);
-      TAG(emit_elts)( ctx, elts + start + j, nr, ALLOC_ELTS(nr) );
-      FLUSH();
-      currentsz = dmasz;
-   }
-}
-
-static void TAG(render_tri_fan_elts)(struct gl_context *ctx,
-                                     GLuint start,
-                                     GLuint count,
-                                     GLuint flags)
-{
-   LOCAL_VARS;
-   GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
-   GLuint j, nr;
-   int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
-   int currentsz;
-
-   FLUSH();
-   ELT_INIT(GL_TRIANGLE_FAN);
-
-   currentsz = GET_CURRENT_VB_MAX_ELTS();
-   if (currentsz < 8)
-      currentsz = dmasz;
-
-   for (j = 1; j + 1 < count; j += nr - 2) {
-      void *tmp;
-      nr = MIN2(currentsz, count - j + 1);
-      tmp = ALLOC_ELTS(nr);
-      tmp = TAG(emit_elts)(ctx, elts + start, 1, tmp);
-      tmp = TAG(emit_elts)(ctx, elts + start + j, nr - 1, tmp);
-      (void) tmp;
-      FLUSH();
-      currentsz = dmasz;
-   }
-}
-
-
-static void TAG(render_poly_elts)( struct gl_context *ctx,
-				   GLuint start,
-				   GLuint count,
-				   GLuint flags )
-{
-   if (HAVE_POLYGONS) {
-      LOCAL_VARS;
-      GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
-      GLuint j, nr;
-      int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
-      int currentsz;
-
-      FLUSH();
-      ELT_INIT( GL_POLYGON );
-
-      currentsz = GET_CURRENT_VB_MAX_ELTS();
-      if (currentsz < 8) {
-	 currentsz = dmasz;
-      }
-
-      for (j = 1 ; j + 1 < count; j += nr - 2) {
-	 void *tmp;
-	 nr = MIN2( currentsz, count - j + 1 );
-	 tmp = ALLOC_ELTS( nr );
-	 tmp = TAG(emit_elts)( ctx, elts+start, 1, tmp );
-         tmp = TAG(emit_elts)(ctx, elts + start + j, nr - 1, tmp);
-	 (void) tmp;
-	 FLUSH();
-	 currentsz = dmasz;
-      }
-   } else if (ctx->Light.ShadeModel == GL_SMOOTH) {
-      TAG(render_tri_fan_verts)( ctx, start, count, flags );
-   } else {
-      fprintf(stderr, "%s - cannot draw primitive\n", __func__);
-      return;
-   }
-}
-
-static void TAG(render_quad_strip_elts)(struct gl_context *ctx,
-                                        GLuint start,
-                                        GLuint count,
-                                        GLuint flags)
-{
-   LOCAL_VARS;
-   GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
-   int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
-   int currentsz;
-   GLuint j, nr;
-
-   FLUSH();
-   currentsz = GET_CURRENT_VB_MAX_ELTS();
-
-   /* Emit whole number of quads in total, and in each buffer.
-    */
-   dmasz -= dmasz & 1;
-   count -= count & 1;
-   currentsz -= currentsz & 1;
-
-   if (currentsz < 12)
-      currentsz = dmasz;
-
-   if (ctx->Light.ShadeModel == GL_FLAT) {
-      ELT_INIT(GL_TRIANGLES);
-
-      currentsz = currentsz / 6 * 2;
-      dmasz = dmasz / 6 * 2;
-
-      for (j = 0; j + 3 < count; j += nr - 2) {
-         nr = MIN2(currentsz, count - j);
-
-         if (nr >= 4) {
-            GLint i;
-            GLint quads = (nr / 2) - 1;
-            ELTS_VARS(ALLOC_ELTS( quads * 6));
-
-            for (i = j; i < j + quads; i++, elts += 2) {
-               EMIT_TWO_ELTS(0, elts[0], elts[1]);
-               EMIT_TWO_ELTS(2, elts[2], elts[1]);
-               EMIT_TWO_ELTS(4, elts[3], elts[2]);
-               INCR_ELTS(6);
-            }
-
-            FLUSH();
-         }
-
-         currentsz = dmasz;
-      }
-   } else {
-      ELT_INIT(GL_TRIANGLE_STRIP);
-
-      for (j = 0; j + 3 < count; j += nr - 2) {
-         nr = MIN2(currentsz, count - j);
-         TAG(emit_elts)(ctx, elts + start + j, nr, ALLOC_ELTS(nr));
-         FLUSH();
-         currentsz = dmasz;
-      }
-   }
-}
-
-
-static void TAG(render_quads_elts)(struct gl_context *ctx,
-                                   GLuint start,
-                                   GLuint count,
-                                   GLuint flags)
-{
-   LOCAL_VARS;
-   GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
-   int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
-   int currentsz;
-   GLuint j, nr;
-
-   ELT_INIT(GL_TRIANGLES);
-   currentsz = GET_CURRENT_VB_MAX_ELTS();
-
-   /* Emit whole number of quads in total, and in each buffer.
-    */
-   count -= count & 3;
-   dmasz -= dmasz & 3;
-   currentsz -= currentsz & 3;
-
-   /* Adjust for rendering as triangles:
-    */
-   currentsz = currentsz / 6 * 4;
-   dmasz = dmasz / 6 * 4;
-
-   if (currentsz < 8)
-      currentsz = dmasz;
-
-   for (j = 0; j + 3 < count; j += nr - 2) {
-      nr = MIN2(currentsz, count - j);
-
-      if (nr >= 4) {
-         GLint quads = nr / 4;
-         GLint i;
-         ELTS_VARS(ALLOC_ELTS(quads * 6));
-
-         for (i = j; i < j + quads; i++, elts += 4) {
-            EMIT_TWO_ELTS(0, elts[0], elts[1]);
-            EMIT_TWO_ELTS(2, elts[3], elts[1]);
-            EMIT_TWO_ELTS(4, elts[2], elts[3]);
-            INCR_ELTS(6);
-         }
-
-         FLUSH();
-      }
-
-      currentsz = dmasz;
-   }
-}
-
-
-
-static tnl_render_func TAG(render_tab_elts)[GL_POLYGON+2] =
-{
-   TAG(render_points_elts),
-   TAG(render_lines_elts),
-   TAG(render_line_loop_elts),
-   TAG(render_line_strip_elts),
-   TAG(render_triangles_elts),
-   TAG(render_tri_strip_elts),
-   TAG(render_tri_fan_elts),
-   TAG(render_quads_elts),
-   TAG(render_quad_strip_elts),
-   TAG(render_poly_elts),
-   TAG(render_noop),
-};
-
-
-
-#endif
-
-
-
 /* Pre-check the primitives in the VB to prevent the need for
  * fallbacks later on.
  */
@@ -1012,7 +442,7 @@
    if (VB->ClipOrMask & ~CLIP_CULL_BIT)
       return GL_FALSE;

-   if (VB->Elts && !HAVE_ELTS)
+   if (VB->Elts)
       return GL_FALSE;

    for (i = 0 ; i < VB->PrimitiveCount ; i++) {
@@ -1045,23 +475,13 @@
 	    ok = GL_TRUE;
 	 } else if (ctx->Light.ShadeModel == GL_FLAT &&
 		    VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride != 0) {
-	    if (HAVE_ELTS) {
-	       ok = (GLint) count < GET_SUBSEQUENT_VB_MAX_ELTS();
-	    }
-	    else {
 	       ok = GL_FALSE;
-	    }
 	 }
 	 else
 	    ok = GL_TRUE;
 	 break;
       case GL_QUADS:
-         if (HAVE_ELTS) {
-	    ok = (GLint) count < GET_SUBSEQUENT_VB_MAX_ELTS();
-	 }
-	 else {
 	    ok = GL_TRUE; /* flatshading is ok. */
-	 }
 	 break;
       default:
 	 break;


Make sBuffer protected to allow subclass access

--- Arduboy.h
+++ Arduboy.h
@@ -83,7 +83,7 @@
   bool post_render = false;
   uint8_t lastFrameDurationMs = 0;

-private:
+protected:
   unsigned char sBuffer[(HEIGHT*WIDTH)/8];

   uint8_t readCapacitivePin(int pinToMeasure);


Added free() to destructor to avoid memory leak

--- Average.h
+++ Average.h
@@ -56,6 +56,7 @@
         // Public functions and variables.  These can be accessed from
         // outside the class.
         Average(uint32_t size);
+        ~Average();
         float rolling(T entry);
         void push(T entry);
         float mean();
@@ -83,6 +84,10 @@
     }
 }

+template <class T> Average<T>::~Average() {
+    free(_store);
+}
+
 template <class T> void Average<T>::push(T entry) {
 	for(uint32_t i = _size - 1; i > 0; i--) {
 		_store[i] = _store[i-1];


Rename: src/Lget_proc_info_by_ip.c -> src/mi/Lget_proc_info_by_ip.c

(Logical change 1.162)

--- src/mi/Lget_proc_info_by_ip.c
+++ src/mi/Lget_proc_info_by_ip.c
@@ -0,0 +1,5 @@
+#define UNW_LOCAL_ONLY
+#include <libunwind.h>
+#if defined(UNW_LOCAL_ONLY) && !defined(UNW_REMOTE_ONLY)
+#include "Gget_proc_info_by_ip.c"
+#endif