more cosmetic changes

more cosmetic changes

- Fix a bunch of minor cosmetic issues to be more compliant with style(9)
  we aren't there fully.. but its a bit better

--- subcalc.c
+++ subcalc.c
@@ -69,41 +69,35 @@
 static int
 mask_discover(char *number, int af)
 {
+	double lg, lg2, pwr;
+	u_int i, sp;
 	char *r;
-	u_int i, sp;
 	int mx;
-	double lg, lg2, pwr;

 	sp = strtoul(number, &r, 0);
 	if (*r || r == number || sp > LONG_MAX || !sp)
 		errx(1, "invalid integer specification");
-
 	sp = atoi(number);
 	mx = (af == AF_INET6) ? 128 : 32;
-
 	for (i = 0; i <= mx; i++) {
 		pwr = pow(2, i);
-
 		if (pwr >= sp)
 			break;
 	}
-
 	lg = log((double)sp) / log(2);
 	lg2 = log(pwr) / log(2);
-
 	printf("theoretical len: %.30f\n", (double)(mx - lg));
 	printf("working len:     %.0f\n", (double)(mx - lg2));
 	printf("hosts:           %.0f\n", pow(2, lg2));
-
-	return(0);
+	return (0);
 }

 struct in6_addr *
 plen2mask(int n)
 {
 	static struct in6_addr ia;
-	u_char  *p;
-	int     i;
+	u_char *p;
+	int i;

 	memset(&ia, 0, sizeof(struct in6_addr));
 	p = (u_char *)&ia;
@@ -115,8 +109,7 @@
 		*p = pl2m[n];
 		break;
 	}
-
-	return &ia;
+	return (&ia);
 }

 static int
@@ -127,8 +120,7 @@
 	*mask = *(plen2mask(bits));
 	for(i = 0; i < sizeof(*ip); i++)
 		ip->s6_addr[i] &= mask->s6_addr[i];
-
-	return(0);
+	return (0);
 }

 static int	extractbits(int af, u_char *adrspace);
@@ -165,36 +157,29 @@
 			if (&a[3][0] == 0)
 				errx(1, "must specify ip6 address or net");
 			sscanf(a[3], "2002:%02x%02x:%02x%02x:",
-				(unsigned int *)&stf.octet[0], (unsigned int *)&stf.octet[1],
-				(unsigned int *)&stf.octet[2], (unsigned int *)&stf.octet[3]);
+			    (unsigned int *)&stf.octet[0], (unsigned int *)&stf.octet[1],
+			    (unsigned int *)&stf.octet[2], (unsigned int *)&stf.octet[3]);
 		}
 		printf("6to4 network:        2002:%02x%02x:%02x%02x::/48\n",
-			stf.octet[0], stf.octet[1], stf.octet[2],
-			stf.octet[3]);
-
+		    stf.octet[0], stf.octet[1], stf.octet[2], stf.octet[3]);
 		printf("ip version 4 parent: %s\n",
-			getipaddress(AF_INET, (u_char *)&stf.a));
-
+		    getipaddress(AF_INET, (u_char *)&stf.a));
 		exit(0);
 	}
-
 	g = c - 1;
 	if (strcmp(a[1], "int6") == 0) {
 		struct in6_addr a6;

 		if (&a[2][0] == NULL)
 			errx(1, "must specify ip6 address.");
-
 		if (&a[3][0] == NULL)
 			errx(1, "must specify a hostname.");
-
 		packadrinfo(AF_INET6, (u_char *)&a6, a[2]);
 		for (g = 15; g >= 0; g--)
 			printf("%x.%x.%s",
-				(a6.__u6_addr.__u6_addr8[g] & 0x0f),
-				(a6.__u6_addr.__u6_addr8[g] & 0xf0) >> 4,
-				(g == 0) ? "ip6.int.\tIN\tPTR\t" : "");
-
+			    (a6.__u6_addr.__u6_addr8[g] & 0x0f),
+			    (a6.__u6_addr.__u6_addr8[g] & 0xf0) >> 4,
+			    (g == 0) ? "ip6.int.\tIN\tPTR\t" : "");
 		printf("%s\n", a[3]);
 		exit(0);
 	}
@@ -203,35 +188,29 @@

 		if (&a[2][0] == NULL)
 			errx(1, "must specify ip6 address.");
-
 		if (&a[3][0] == NULL)
 			errx(1, "must specify a hostname.");
-
 		packadrinfo(AF_INET6, (u_char *)&a6, a[2]);
 		for (g = 15; g >= 0; g--)
 			printf("%x.%x.%s",
-				(a6.__u6_addr.__u6_addr8[g] & 0x0f),
-				(a6.__u6_addr.__u6_addr8[g] & 0xf0) >> 4,
-				(g == 0) ? "ip6.arpa.\tIN\tPTR\t" : "");
+			    (a6.__u6_addr.__u6_addr8[g] & 0x0f),
+			    (a6.__u6_addr.__u6_addr8[g] & 0xf0) >> 4,
+			    (g == 0) ? "ip6.arpa.\tIN\tPTR\t" : "");
 		printf("%s\n", a[3]);
 		exit(0);
 	}
 	if (strcmp(a[g], "print") == 0)
 		dorange++;
-
 	if (strcmp("inet", a[1]) == 0) {
 		if (c < 3)
 			usage();
-
 		p->af = AF_INET;
-
 		if (strcmp(a[2], "hosts") == 0) {
 			if (&a[3][0] == NULL)
 				usage();
 			mask_discover(a[3], AF_INET);
 			exit(0);
 		}
-
 		if (strchr(a[2], '/')) {
 			tmp = &a[2][0];
 			for(fp = fields; (*fp = strsep(&tmp, "/"))
@@ -249,7 +228,6 @@
 			return(0);
 		} else if (c == 3)
 			errx(1, "specify network bits or mask.");
-
 		memcpy(p->address, a[2], sizeof(p->address));
 		if (strcmp(a[3], "netmask") == 0) {
 			char *m, *r;
@@ -261,7 +239,6 @@
 				msk.mask.s_addr = strtoul(m, &r, 16);
 			else
 				msk.mask.s_addr = inet_addr(a[4]);
-
 			p->bits = extractbits(AF_INET, (u_char *)&msk.mask);
 		}
 		if (strcmp(a[3], "prefixlen") == 0) {
@@ -269,23 +246,19 @@
 				errx(1,"invalid words near prefixlen");
 			p->bits = atoi(a[4]);
 		}
-
-		return(0);
+		return (0);
 	}

 	if (strcmp("inet6", a[1]) == 0) {
 		if (c < 3)
 			usage();
-
 		p->af = AF_INET6;
-
 		if (strcmp(a[2], "hosts") == 0) {
 			if (&a[3][0] == NULL)
 				usage();
 			mask_discover(a[3], AF_INET6);
 			exit(0);
 		}
-
 		if (strchr(a[2], '/')) {
 			tmp = &a[2][0];
 			for(fp = fields; (*fp = strsep(&tmp, "/"))
@@ -300,11 +273,9 @@
 			}
 			memcpy(p->address, fields[0], sizeof(p->address));
 			p->bits = atoi(fields[1]);
-
-			return(0);
+			return (0);
 		} else if (c == 3)
 			errx(1, "specify network bits or mask.");
-
 		memcpy(p->address, a[2], sizeof(p->address));
 		if (strcmp(a[3], "prefixlen") == 0) {
 			if (c != 5 && !dorange)
@@ -316,26 +287,22 @@
 				errx(1,"invalid words near netmask");
 			inet_pton(AF_INET6, a[4], (u_char *)&msk.mask6);
 			p->bits = extractbits(AF_INET6, (u_char *)&msk.mask6);
-
-			return(0);
-		}
-		return(0);
+		}
+		return (0);
 	}
 	errx(1, "`%s' is an invalid address family.", a[1]);
-
-	return(0);
+	return (0);
 }

 static int
 getb(u_char *field, unsigned pos)
 {
-	int i;
 	u_char mask;
+	int i;

 	mask = 0x80;
 	for(i = 0; i < (pos % 8); i++)
 		mask = (mask >> 1);
-
 	return (((mask & field[(int)(pos / 8)]) == mask) ? 1 : 0);
 }

@@ -352,8 +319,7 @@
 		field[pos / 8] |= mask;
 	else
 		field[pos / 8] &= ~mask;
-
-	return(0);
+	return (0);
 }

 char *
@@ -397,14 +363,12 @@
 		for(i = IPV6WIDTH-1; i >= (IPV6WIDTH - b); i--)
 			setb((u_char *)&adu.in6->__u6_addr, i, 0);
 	}
-
 	if (af == AF_INET) {
 		adu.in = (struct in_addr *)adrspace;
 		for (i = IPWIDTH-1; i >= (IPWIDTH - b); i--)
 			setb((u_char *)&adu.in->s_addr, i, 0);
 	}
-
-	return(0);
+	return (0);
 }

 static int
@@ -420,15 +384,13 @@
 				bits++;
 		return(IPV6WIDTH - bits);
 	}
-
 	if (af == AF_INET) {
 		for(i = 0; i < IPWIDTH; i++)
 			if (!getb((u_char *)adrspace, i))
 				bits++;
-		return(IPWIDTH - bits);
-	}
-
-	return(-1);
+		return (IPWIDTH - bits);
+	}
+	return (-1);
 }

 static int
@@ -443,15 +405,13 @@
 		adu.in6 = (struct in6_addr *)adrspace;
 		inet_pton(AF_INET6, str, adu.in6);
 	}
-
 	if (af == AF_INET) {
 		adu.in = (struct in_addr *)adrspace;
 		adu.in->s_addr = inet_addr(str);
 		if (adu.in->s_addr == INADDR_NONE)
 			errx(1, "invalid address specification");
 	}
-
-	return(0);
+	return (0);
 }

 static int
@@ -473,8 +433,7 @@
 		for (i = IPWIDTH-1; i >= (IPWIDTH - b); i--)
 			setb((u_char *)&adu.in->s_addr, i, 1);
 	}
-
-	return(0);
+	return (0);
 }

 static char *
@@ -484,8 +443,7 @@

 	bzero(&buf[0], sizeof(buf));
 	inet_ntop(af, adrspace, buf, sizeof(buf));
-
-	return(&buf[0]);
+	return (&buf[0]);
 }

 static int
@@ -507,17 +465,16 @@
 int
 main(int argc, char *argv [])
 {
+	struct in6_addr adr6, adr62, ip6, ip6mask;
 	struct in_addr adr, adr2;
-	struct in6_addr adr6, adr62, ip6, ip6mask;
-	int b;
-	double p;
 	char buf[64], *cmask;
 	struct cmdargs cd;
+	double p;
 	u_int x;
+	int b;

 	if (argc == 1)
 		usage();
-
 	b = 0;
 	proccmdargs(argc, argv, &cd);
 	if (cd.af == AF_INET6) {
@@ -530,33 +487,28 @@
 		SETADR6(adr62);
 		SETADR6(ip6);
 		setaddrmask(&ip6, &ip6mask, cd.bits);
-
 		b = IPV6WIDTH - cd.bits;
 		unsetmask(AF_INET6, (u_char *)&adr6, b);
 		printf("%srange:       %s > ",
-			(dorange ? "; " : ""),
-			getipaddress(AF_INET6,
-				(u_char *)&adr6));
+		    (dorange ? "; " : ""), getipaddress(AF_INET6,
+		    (u_char *)&adr6));
 		setmask(AF_INET6, (u_char *)&adr62, b);
 		printf("%s\n", getipaddress(AF_INET6, (u_char *)&adr62));
-
 		p = pow(2, (double)b);
 		printf("%shosts:       %.0f\n",
-			(dorange ? "; " : ""), p);
+		    (dorange ? "; " : ""), p);
 		printf("%sprefixlen:   %lu\n",
-			(dorange ? "; " : ""), cd.bits);
+		    (dorange ? "; " : ""), cd.bits);
 		printf("%smask:        %s\n",
-			(dorange ? "; " : ""),
-			inet_ntop(AF_INET6, &ip6mask, buf,
-				sizeof(buf)));
-
+		    (dorange ? "; " : ""), inet_ntop(AF_INET6, &ip6mask, buf,
+		    sizeof(buf)));
 		if (dorange) {
 			destmask = 1 << b;
 			for(;;) {
 				int x = 15;
 				if (MASKEQUAL(&adr6, &ip6mask, &ip6))
 					printf("%s\n", getipaddress(AF_INET6,
-						(u_char *)&adr6));
+					    (u_char *)&adr6));
 				else
 					break;
 				while (x >= 0 &&
@@ -566,45 +518,38 @@
 			}
 		}
 	}
-
 	if (cd.af == AF_INET) {
 		u_int destmask;
 		u_int valmask;

 		packadrinfo(AF_INET, (u_char *)&adr, cd.address);
 		packadrinfo(AF_INET, (u_char *)&adr2, cd.address);
-
 		x = 1;
 		b = IPWIDTH - cd.bits;
 		unsetmask(AF_INET, (u_char *)&adr, b);
-
 		printf("%srange:       %s > ",
-			(dorange ? "; " : ""),
-			getipaddress(AF_INET, (u_char *)&adr));
+		   (dorange ? "; " : ""),
+		    getipaddress(AF_INET, (u_char *)&adr));
 		setmask(AF_INET, (u_char *)&adr2, b);
 		printf("%s\n", getipaddress(AF_INET, (u_char *)&adr2));
-
 		printf("%srange b10:   %u > %u\n",
-			(dorange ? "; " : ""), htonl(adr.s_addr),
-			htonl(adr2.s_addr));
-
+		    (dorange ? "; " : ""), htonl(adr.s_addr),
+		    htonl(adr2.s_addr));
 		printf("%srange b16:   0x%x > 0x%x\n",
-			(dorange ? "; " : ""), htonl(adr.s_addr),
-			htonl(adr2.s_addr));
-
+		    (dorange ? "; " : ""), htonl(adr.s_addr),
+		    htonl(adr2.s_addr));
 		adr2.s_addr = htonl(~0 << (32 - cd.bits));
 		p = pow(2, (double)b);
 		printf("%shosts:       %.0f\n",
-			(dorange ? "; " : ""), p);
+		    (dorange ? "; " : ""), p);
 		printf("%sprefixlen:   %lu\n",
-			(dorange ? "; " : ""), cd.bits);
+		    (dorange ? "; " : ""), cd.bits);
 		printf("%smask:        %s\n",
-			(dorange ? "; " : ""), getipaddress(AF_INET,
-				(u_char *)&adr2));
+		    (dorange ? "; " : ""), getipaddress(AF_INET,
+		    (u_char *)&adr2));
 		cmask = invert_mask(AF_INET, &adr2);
 		printf("%scisco mask:  %s\n",
 		    (dorange ? "; " : ""), cmask);
-
 		if (dorange) {
 			destmask = 1 << b;
 			valmask = 0;
@@ -620,7 +565,5 @@
 			}
 		}
 	}
-
-	return(0);
-}
-
+	return (0);
+}


aarch64: add -i option support

aarch64: add -i option support

* syscall.c (print_pc): Add aarch64 support.

--- syscall.c
+++ syscall.c
@@ -881,6 +881,11 @@
 		return;
 	}
 	tprintf(fmt, pc);
+#elif defined(AARCH64)
+	if (aarch64_io.iov_len == sizeof(arm_regs))
+		tprintf(fmt, (unsigned long) arm_regs.ARM_pc);
+	else
+		tprintf(fmt, (unsigned long) aarch64_regs.pc);
 #elif defined(ARM)
 	tprintf(fmt, arm_regs.ARM_pc);
 #elif defined(AVR32)


Found minor issues in sysproc.c

Found minor issues in sysproc.c

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

 int sys_sem_init(void)
 {
-  int semid,n;
+  int semId,n;

   if(argint(0, &semId) < 0)
     return -1;
@@ -31,7 +31,7 @@

   return sem_destroy(semId);
 }
-int sys_sem_wait(int semId)
+int sys_sem_wait(void)
 {
   int semId;

@@ -41,7 +41,7 @@
   return sem_wait(semId);
 }

-int sys_sem_signal(int semId)
+int sys_sem_signal(void)
 {
   int semId;


Document further private methods inside the offsetcachefile class..

--- plugins/stardict/offsetcachefile.h
+++ plugins/stardict/offsetcachefile.h
@@ -91,7 +91,7 @@
             virtual void setWordEntrySize(quint32 wordEntrySize);

         private:
-            /**
+            /**
              * Loads the word entries of relevant cache page into the internal
              * data storage. It will return the number of the word entries
              * loaded.
@@ -106,11 +106,49 @@
              */
             int loadPage(int pageIndex);

+            /**
+             * Returns the first word data of the desired page from the index
+             * file. It is a bit slower since it starts seeking and reading
+             * from the index file directly without using any caching mechanism
+             *
+             * \note This method is only for internal usage.
+             *
+             * @param   pageIndex The index of the desired page
+             * @return  The desired word data from the index file
+             * @see firstWordDataOnPage
+             */
             QByteArray readFirstWordDataOnPage(long pageIndex);
+
+            /**
+             * Returns the first word data of the desired page from the index
+             * file by using a caching approach to make it faster to look the
+             * word up in certain cases. Hence it is faster to use this method
+             * for reading the first word data of the cache page.
+             *
+             * \note This method is only for internal usage.
+             *
+             * @param   pageIndex The index of the desired page
+             * @return  The desired word data from the index file
+             * @see readFirstWordDataOnPage
+             */
             QByteArray firstWordDataOnPage(long pageIndex);
+
+            /**
+             * Returns the string list of the cache locations.
+             * The method will return the location where the index file can be
+             * found and the location ${CACHE_LOCATION}/stardict/ folder where
+             * the cache path is provided by QDesktopService class using the
+             * CacheLocation argument.
+             *
+             * \note This method is only for internal usage.
+             *
+             * @param   completeFilePath The complete file path
+             * @return  The list of the cache locations
+             * @see saveCache, loadCache
+             */
             QStringList cacheLocations(const QString& completeFilePath);

-            /**
+            /**
              * Loads the cache file according to the relevant index file path.
              * Returns true if the cache file loading is successful, otherwise
              * returns false.
@@ -120,10 +158,11 @@
              * @param   completeFilePath The complete file path
              * @return  Whether or not the cache file loading has been
              * successful
+             * @see cacheLocations, saveCache
              */
             bool loadCache(const QString& completeFilePath);

-            /**
+            /**
              * Saves the cache file according to the relevant index file path.
              * Returns true if the cache file saving is successful, otherwise
              * returns false.
@@ -133,6 +172,7 @@
              * @param   completeFilePath The complete file path
              * @return  Whether or not the cache file saving has been
              * successful
+             * @see cacheLocations, loadCache
              */
             bool saveCache(const QString& completeFilePath);


Update tapuino.c

Update tapuino.c

fixed save header for c16 tap format compatibility ($02 @ $0D)

--- tapuino.c
+++ tapuino.c
@@ -498,6 +498,11 @@
   memset (g_fat_buffer, 0, sizeof(g_fat_buffer));   // clear it all out
   uint32_t* buffer_magic = (uint32_t*) g_fat_buffer;
   buffer_magic[0] = TAP_MAGIC_C64;                  // copy the magic to the buffer: "C64-"
+  if (g_machine_type == C16) {
+    buffer_magic[0] = TAP_MAGIC_C16;                  // is C16 selected? then copy the magic to the buffer: "C16-"
+    g_fat_buffer[13] = 0x02;                          // and set $0D to $02 for C16 tap format
+  }
+
   buffer_magic[1] = TAP_MAGIC_POSTFIX1;             // copy the magic to the buffer: "TAPE"
   buffer_magic[2] = TAP_MAGIC_POSTFIX2;             // copy the magic to the buffer: "-RAW"
   g_fat_buffer[12] = 0x01;                          // get to the end of the magic and set TAP format to 1


removed linux type comments

removed linux type comments

--- tcp/tcp.c
+++ tcp/tcp.c
@@ -184,8 +184,7 @@
       Todo: this should initialize tcb and do
       nothing if called again
     */
-    //void (*oldsig)(int);
-    //unsigned old_timo;
+

     if (tcb.state != S_START) {
         return -1;
@@ -232,7 +231,6 @@

 int tcp_listen(int port, ipaddr_t *src) {
     void (*oldsig)(int);
-    //unsigned oldtimo;

     if (tcb.state != S_CLOSED) {
         return -1;
@@ -291,7 +289,6 @@
     int bytes_to_read, length, bytes_free_at_end_of_buffer;
     int delivered_bytes;
     void (*oldsig)(int);
-    //unsigned oldtimo;

     /*


Fixed SH derivatives calculation

Fixed SH derivatives calculation

--- lib/math/SH.h
+++ lib/math/SH.h
@@ -448,7 +448,8 @@
           T d2SH_dt2 = daz*daz*d2SH_daz2 + 2.0*daz*del*d2SH_deldaz + del*del*d2SH_del2;
           T dt = - dSH_dt / d2SH_dt2;

-          if (dt < 0.0 || dt > MAX_DIR_CHANGE) dt = MAX_DIR_CHANGE;
+          if (dt < 0.0) dt = -dt;
+          if (dt > MAX_DIR_CHANGE) dt = MAX_DIR_CHANGE;

           del *= dt;
           daz *= dt;
@@ -517,6 +518,7 @@

             T tmp2 = - ( (l+m) * (l-m+1) + (l-m) * (l+m+1)) * AL[index_mpos (l,m)];
             if (m == 1) tmp2 -= sqrt (T ( (l+m) * (l-m+1) * (l+m-1) * (l-m+2))) * AL[index_mpos (l,1)];
+            else tmp2 += sqrt (T ( (l+m) * (l-m+1) * (l+m-1) * (l-m+2))) * AL[index_mpos (l,m-2)];
             if (l > m+1) tmp2 += sqrt (T ( (l-m) * (l+m+1) * (l-m-1) * (l+m+2))) * AL[index_mpos (l,m+2)];
             tmp2 /= 4.0;
             d2SH_del2 += (vp*caz + vm*saz) * tmp2;


perfgroup: Catch fatal signals and try to do some cleanup

There are various reasons why perfgroup may receive a fatal
signal. One reason might be a failed assertion that causes a SIGABRT
to be raised. In this case, we need to make sure that all child
processes are terminated as well.

We accomplish this by installing a signal handler that sends a SIGTERM
to all child process groups and then raising the original signal. We
don't need to explicitly unmask and install the original handler for
the signal since sigaction, with the right flags, does this for us.

--- perfgroup.c
+++ perfgroup.c
@@ -223,6 +223,114 @@
     free(data);
 }

+static void
+print_counters(FILE *out)
+{
+    for (int i = 0; i < num_processes; i++) {
+        bench_process_t *p = processes + i;
+        fprintf(out, "%i -- %s:\n", i, p->argv[0]);
+        print_counter_list(out, &p->ctrs);
+        fprintf(out, "\n");
+    }
+}
+
+static void
+setup_child(void *_p)
+{
+    bench_process_t *p = (bench_process_t *)_p;
+    cpu_set_t cpu_set;
+
+    CPU_ZERO(&cpu_set);
+    CPU_SET(p->cpu, &cpu_set);
+    EXPECT_ERRNO(sched_setaffinity(0, sizeof(cpu_set_t), &cpu_set) != -1);
+
+    /* Setup a process group so we can kill all child processes
+     * easily */
+    EXPECT_ERRNO(setpgid(0, 0) != -1);
+
+    if (p->wd)
+        EXPECT_ERRNO(chdir(p->wd) != -1);
+
+    if (p->stdout)
+        fredirect(p->stdout, STDOUT_FILENO);
+    if (p->stderr)
+        fredirect(p->stderr, STDERR_FILENO);
+    if (p->stdin)
+        fredirect(p->stdin, STDIN_FILENO);
+}
+
+static void
+handle_fatal_signal(int sig, siginfo_t *si, void *_ucontext)
+{
+#define WRITE_TXT(t) write(STDERR_FILENO, t, sizeof(t) - 1)
+
+    WRITE_TXT("Caught fatal signal, terminating child processes\n");
+    for (int i = 0; i < num_processes; i++) {
+	bench_process_t *p = processes + i;
+	if (process_running(p))
+            if (kill(-p->pid, SIGTERM) == -1)
+                WRITE_TXT("Warning: Failed to terminate a child process\n");
+    }
+
+    WRITE_TXT("Passing signal to default handler...\n");
+    raise(si->si_signo);
+
+    WRITE_TXT("Failed to pass signal to default handler, aborting\n");
+    abort();
+
+#undef WRITE_TXT
+}
+
+static void
+handle_signal(struct signalfd_siginfo *fdsi)
+{
+    switch (fdsi->ssi_signo) {
+    case SIGINT:
+        /* Try to terminate the child processes, if this
+         * succeeds, we'll get a SIGCHLD for each child
+         * process and eventually terminate ourselves. */
+        fprintf(stderr, "Sending SIGTERM to child processes.\n");
+        processes_kill(SIGTERM);
+        break;
+    case SIGUSR1:
+        print_counters(stderr);
+        break;
+    case SIGCHLD: {
+        bench_process_t *p = process_find(fdsi->ssi_pid);
+        assert(p);
+        p->zombie = 1;
+
+        if (run_state == RUN_STATE_RUNNING)
+            /* Kill all running child processes */
+            processes_kill(SIGTERM);
+
+        run_state = processes_running() == 0 ? RUN_STATE_EXIT : RUN_STATE_WAITING;
+    } break;
+    default:
+        /* Ignore other signals */
+        break;
+    }
+}
+
+static void
+catch_fatal_signals()
+{
+    struct sigaction sa = {
+        .sa_sigaction = &handle_fatal_signal,
+        .sa_flags = SA_SIGINFO | SA_RESETHAND | SA_NODEFER,
+    };
+
+    int siglist[] = {
+        SIGABRT,
+        SIGQUIT,
+        SIGTERM,
+    };
+
+    sigemptyset(&sa.sa_mask);
+    for (int i = 0; i < sizeof(siglist) / sizeof(*siglist); i++)
+        EXPECT_ERRNO(sigaction(siglist[i], &sa, NULL) != -1);
+}
+
 static int
 create_signal_fd()
 {
@@ -241,72 +349,6 @@
     return sfd;
 }

-static void
-print_counters(FILE *out)
-{
-    for (int i = 0; i < num_processes; i++) {
-        bench_process_t *p = processes + i;
-        fprintf(out, "%i -- %s:\n", i, p->argv[0]);
-        print_counter_list(out, &p->ctrs);
-        fprintf(out, "\n");
-    }
-}
-
-static void
-setup_child(void *_p)
-{
-    bench_process_t *p = (bench_process_t *)_p;
-    cpu_set_t cpu_set;
-
-    CPU_ZERO(&cpu_set);
-    CPU_SET(p->cpu, &cpu_set);
-    EXPECT_ERRNO(sched_setaffinity(0, sizeof(cpu_set_t), &cpu_set) != -1);
-
-    /* Setup a process group so we can kill all child processes
-     * easily */
-    EXPECT_ERRNO(setpgid(0, 0) != -1);
-
-    if (p->wd)
-        EXPECT_ERRNO(chdir(p->wd) != -1);
-
-    if (p->stdout)
-        fredirect(p->stdout, STDOUT_FILENO);
-    if (p->stderr)
-        fredirect(p->stderr, STDERR_FILENO);
-    if (p->stdin)
-        fredirect(p->stdin, STDIN_FILENO);
-}
-
-static void
-handle_signal(struct signalfd_siginfo *fdsi)
-{
-    switch (fdsi->ssi_signo) {
-    case SIGINT:
-        /* Try to terminate the child processes, if this
-         * succeeds, we'll get a SIGCHLD for each child
-         * process and eventually terminate ourselves. */
-        fprintf(stderr, "Sending SIGTERM to child processes.\n");
-        processes_kill(SIGTERM);
-        break;
-    case SIGUSR1:
-        print_counters(stderr);
-        break;
-    case SIGCHLD: {
-        bench_process_t *p = process_find(fdsi->ssi_pid);
-        assert(p);
-        p->zombie = 1;
-
-        if (run_state == RUN_STATE_RUNNING)
-            /* Kill all running child processes */
-            processes_kill(SIGTERM);
-
-        run_state = processes_running() == 0 ? RUN_STATE_EXIT : RUN_STATE_WAITING;
-    } break;
-    default:
-        /* Ignore other signals */
-        break;
-    }
-}

 static int
 do_start()
@@ -314,6 +356,7 @@
     int sfd;
     int exit_status = EXIT_SUCCESS;

+    catch_fatal_signals();
     sfd = create_signal_fd();

     for (int i = 0; i < num_processes; i++) {


minor optimization (a QStringLiteral)

minor optimization (a QStringLiteral)

--- pf/pfnode.h
+++ pf/pfnode.h
@@ -121,7 +121,7 @@
     : d(name.isEmpty() ? 0 : new PfNodeData(name, array)) { }
   /** Create a comment node. */
   static PfNode createCommentNode(QString comment) {
-    return PfNode(new PfNodeData("comment", comment, true)); }
+    return PfNode(new PfNodeData(QStringLiteral("comment"), comment, true)); }
   PfNode &operator=(const PfNode &other) { d = other.d; return *this; }
   /** Build a PfNode from PF external format.
    * @return first encountered root node or PfNode() */


Added missing test for embedded

Added missing test for embedded

error: pathspec 'unittest/libmariadb/sqlite3.c' did not match any file(s) known to git

--- unittest/libmariadb/sqlite3.c
+++ unittest/libmariadb/sqlite3.c
@@ -0,0 +1,194 @@
+/**
+  Some basic tests for sqlite
+*/
+
+#include "my_test.h"
+
+static int test1(MYSQL *mysql)
+{
+  MYSQL_ROW row;
+  MYSQL_RES *res;
+  MYSQL_FIELD *fields;
+  int rc;
+
+  MYSQL *my= mysql_init(NULL);
+  FAIL_IF(!my, "mysql_init() failed");
+
+  mysql_options(my, MYSQL_DATABASE_DRIVER, "sqlite");
+
+  FAIL_IF(!mysql_real_connect(my, hostname, username, password, (schema) ? schema : "test",
+                         port, socketname, 0), mysql_error(my));
+
+  diag("Server name: %s", mysql_get_server_name(my));
+
+  diag("Connected to: %s (%d)", mysql_get_server_info(my), mysql_get_server_version(my));
+
+  rc= mysql_query(my, "CREATE TABLE t1 (a int, b varchar(255))");
+  rc= mysql_query(my, "DELETE FROM t1");
+  check_mysql_rc(rc, my);
+
+  rc= mysql_query(my, "BEGIN");
+  check_mysql_rc(rc, my);
+  rc= mysql_query(my, "INSERT INTO t1 VALUES (1, 'Monty')");
+  check_mysql_rc(rc, my);
+  rc= mysql_query(my, "INSERT INTO t1 VALUES (2, 'Serg')");
+  check_mysql_rc(rc, my);
+  rc= mysql_query(my, "INSERT INTO t1 VALUES (3, 'Holyfoot')");
+  check_mysql_rc(rc, my);
+  rc= mysql_query(my, "INSERT INTO t1 VALUES (4, 'Rasmus')");
+  check_mysql_rc(rc, my);
+  rc= mysql_query(my, "INSERT INTO t1 VALUES (5, 'Sanja')");
+  check_mysql_rc(rc, my);
+  rc= mysql_query(my, "COMMIT");
+  check_mysql_rc(rc, my);
+
+  rc= mysql_query(my, "SELECT a,b FROM t1");
+  check_mysql_rc(rc, my);
+  res= mysql_use_result(my);
+  FAIL_IF(!res, mysql_error(my));
+
+  fields= mysql_fetch_fields(res);
+
+  while ((row= mysql_fetch_row(res)) != NULL)
+  {
+    FAIL_IF(mysql_num_fields(res) != 2, "Got the wrong number of fields");
+  }
+  FAIL_IF(mysql_num_rows(res) != 5, "expected 5 rows");
+  FAIL_IF(mysql_errno(my), mysql_error(my));
+
+  mysql_free_result(res);
+
+  rc= mysql_query(my, "SELECT a FROM t1");
+  check_mysql_rc(rc, my);
+  res= mysql_use_result(my);
+  mysql_free_result(res);
+
+  FAIL_IF(mysql_errno(my), mysql_error(my));
+
+  mysql_close(my);
+
+  return OK;
+}
+
+static int test_simple_prepare(MYSQL *my)
+{
+  MYSQL *mysql= mysql_init(NULL);
+  MYSQL_STMT *stmt;
+  MYSQL_BIND bind[2];
+  int val1= 17;
+  char *val2= "MariaDB";
+  char buffer[100];
+  char *stmt_create= "CREATE TABLE t2 (a int, b varchar(200), c int)";
+  char *stmt_insert= "INSERT INTO t2 VALUES (1, ?, ?)";
+  int rc;
+
+  FAIL_IF(!mysql, "mysql_init() failed");
+
+  mysql_options(mysql, MYSQL_DATABASE_DRIVER, "sqlite");
+
+  FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, (schema) ? schema : "test",
+                         port, socketname, 0), mysql_error(my));
+
+  rc= mysql_query(mysql, "DROP TABLE IF EXISTS t2");
+  check_mysql_rc(rc, mysql);
+
+  stmt= mysql_stmt_init(mysql);
+  rc= mysql_stmt_prepare(stmt, stmt_create, strlen(stmt_create));
+  FAIL_IF(stmt->stmt_id != 1, "expected stmt_id=1");
+  check_stmt_rc(rc, stmt);
+
+  FAIL_IF(mysql_stmt_param_count(stmt), "Expected param_count= 0");
+
+  rc= mysql_stmt_execute(stmt);
+  check_stmt_rc(rc, stmt);
+  mysql_stmt_close(stmt);
+
+  stmt= mysql_stmt_init(mysql);
+  rc= mysql_stmt_prepare(stmt, stmt_insert, strlen(stmt_insert));
+  FAIL_IF(stmt->stmt_id != 2, "expected stmt_id=2");
+  check_stmt_rc(rc, stmt);
+
+  FAIL_IF(mysql_stmt_param_count(stmt) != 2, "Expected 2 parameters");
+
+  mysql_stmt_close(stmt);
+
+  stmt= mysql_stmt_init(mysql);
+  rc= mysql_stmt_prepare(stmt, "CREATE xxxx (a int)", 50);
+  FAIL_IF(rc == 0, "error expected");
+  mysql_stmt_close(stmt);
+
+  rc= mysql_query(mysql, "DROP TABLE IF EXISTS t2");
+  check_mysql_rc(rc, mysql);
+  rc= mysql_query(mysql, "CREATE TABLE t2 (a int, b varchar(20))");
+  check_mysql_rc(rc, mysql);
+
+  stmt= mysql_stmt_init(mysql);
+  rc= mysql_stmt_prepare(stmt, "INSERT INTO t2 VALUES(?,?)", 50);
+  check_stmt_rc(rc, stmt);
+
+  memset(bind, 0, sizeof(MYSQL_BIND) * 2);
+  bind[0].buffer_type= MYSQL_TYPE_LONG;
+  bind[0].buffer= &val1;
+
+  bind[1].buffer_type= MYSQL_TYPE_STRING;
+  bind[1].buffer= val2;
+  bind[1].buffer_length= strlen(val2);
+
+  rc= mysql_stmt_bind_param(stmt, bind);
+  check_stmt_rc(rc, stmt);
+
+  rc= mysql_stmt_execute(stmt);
+  check_stmt_rc(rc, stmt);
+
+  val1++;
+
+  rc= mysql_stmt_execute(stmt);
+  check_stmt_rc(rc, stmt);
+  mysql_stmt_close(stmt);
+
+  bind[1].buffer= buffer;
+
+  stmt= mysql_stmt_init(mysql);
+  rc= mysql_stmt_prepare(stmt, "SELECT a,b FROM t2", 50);
+  check_stmt_rc(rc, stmt);
+
+  rc= mysql_stmt_execute(stmt);
+  check_stmt_rc(rc, stmt);
+  rc= mysql_stmt_bind_result(stmt, bind);
+  check_stmt_rc(rc, stmt);
+
+
+  mysql_stmt_fetch(stmt);
+  FAIL_IF(val1 != 17, "expected value=17");
+
+  mysql_stmt_fetch(stmt);
+  FAIL_IF(val1 != 18, "expected value=18");
+
+  rc= mysql_stmt_fetch(stmt);
+  FAIL_IF(rc != MYSQL_NO_DATA, "Expected eof");
+  mysql_stmt_close(stmt);
+  mysql_close(mysql);
+
+  return OK;
+}
+
+
+struct my_tests_st my_tests[] = {
+  {"test-sqlite", test1, TEST_CONNECTION_NONE, 0,  NULL,  NULL},
+  {"test_simple_prepare", test_simple_prepare, TEST_CONNECTION_NONE, 0, NULL, NULL},
+  {NULL, NULL, 0, 0, NULL, NULL}
+};
+
+
+int main(int argc, char **argv)
+{
+
+  if (argc > 1)
+    get_options(argc, argv);
+
+  get_envvars();
+
+  run_tests(my_tests);
+
+  return(exit_status());
+}


Stats doesn't need to be global now.

Stats doesn't need to be global now.

--- pipestats.c
+++ pipestats.c
@@ -27,7 +27,6 @@
     struct timeval last_report;
     struct timeval start;
 } Stats;
-Stats stats;

 typedef struct Options {
@@ -46,15 +45,15 @@

 int read_options();
-int setup();
+int setup(Stats* stats, struct timeval* report_interval);

 void check_read_errors();
 int check_write_errors();

-void print_report();
-void print_final_report();
+void print_report(Stats* stats);
+void print_final_report(Stats* stats);

 void cleanup(int signal);
@@ -65,6 +64,7 @@
     int err = 0;
     int bytes_read = 0;
     struct timeval report_interval;
+    Stats stats;
     char buff[BUF_SIZE];

     done = 0;
@@ -73,12 +73,12 @@
         return err;
     }

-    if ((err = setup(&report_interval)) != 0) {
+    if ((err = setup(&stats, &report_interval)) != 0) {
         return err;
     }

     while (bytes_read > 0 || !done) {
-        print_report();
+        print_report(&stats);

         // Only read more if we've already written everything we already had.
         if (bytes_read == 0) {
@@ -186,7 +186,7 @@
         }
     }

-    print_final_report();
+    print_final_report(&stats);

     return err;
 }
@@ -278,7 +278,7 @@
 }

-int setup(struct timeval* report_interval) {
+int setup(Stats* stats, struct timeval* report_interval) {
     struct sigaction cleanup_action;
     double half_freq;
     int abort_signals[] = {SIGHUP, SIGINT, SIGQUIT, SIGABRT, SIGPIPE, SIGTERM};
@@ -318,9 +318,9 @@
         (half_freq - ((int) half_freq)) * (1000 * 1000);

     // Init stats.
-    memset(&stats, 0, sizeof(Stats));
-    gettimeofday(&stats.start, NULL);
-    stats.last_report = stats.start;
+    memset(stats, 0, sizeof(Stats));
+    gettimeofday(&stats->start, NULL);
+    stats->last_report = stats->start;

     // Set up handler for exiting, to print a final report, even if aborted.
     memset(&cleanup_action, 0, sizeof(struct sigaction));
@@ -345,7 +345,7 @@
 }

-void print_report() {
+void print_report(Stats* stats) {
     struct timeval now;
     double elapsed;

@@ -354,27 +354,27 @@
     }

     gettimeofday(&now, NULL);
-    elapsed = elapsed_sec(&now, &stats.last_report);
+    elapsed = elapsed_sec(&now, &stats->last_report);

     if (elapsed >= options.freq) {
         TimeEstimate time;
         double milestone_amount;
         const char* milestone_amount_unit;

-        double data_amount_since = adjust_unit(stats.bytes_since, options.unit);
-        const char* data_amount_since_unit = unit_name(stats.bytes_since, options.unit);
-
-        double data_amount_total = adjust_unit(stats.total_bytes, options.unit);
-        const char* data_amount_total_unit = unit_name(stats.total_bytes, options.unit);
+        double data_amount_since = adjust_unit(stats->bytes_since, options.unit);
+        const char* data_amount_since_unit = unit_name(stats->bytes_since, options.unit);
+
+        double data_amount_total = adjust_unit(stats->total_bytes, options.unit);
+        const char* data_amount_total_unit = unit_name(stats->total_bytes, options.unit);

         // If stuff's moving, use current speed, to be optimistic about the
         // current conditions. Otherwise use total avg speed, which is more
         // realistic if things keep pausing.
         estimate_time(&time,
-                      stats.total_bytes,
-                      stats.bytes_since > 0 ?
-                        stats.bytes_since / elapsed :
-                        stats.total_bytes / elapsed_sec(&now, &stats.start));
+                      stats->total_bytes,
+                      stats->bytes_since > 0 ?
+                        stats->bytes_since / elapsed :
+                        stats->total_bytes / elapsed_sec(&now, &stats->start));
         milestone_amount = adjust_unit(time.milestone_bytes, options.unit);
         milestone_amount_unit = unit_name(time.milestone_bytes, options.unit);

@@ -390,25 +390,25 @@
                 time.time_remaining, time.time_unit,
                 milestone_amount, milestone_amount_unit);

-        stats.bytes_since = 0;
-        stats.last_report = now;
-    }
-}
-
-
-void print_final_report() {
+        stats->bytes_since = 0;
+        stats->last_report = now;
+    }
+}
+
+
+void print_final_report(Stats* stats) {
     struct timeval now;
     double elapsed;

-    double data_amount = adjust_unit(stats.total_bytes, options.unit);
-    const char* data_amount_unit = unit_name(stats.total_bytes, options.unit);
+    double data_amount = adjust_unit(stats->total_bytes, options.unit);
+    const char* data_amount_unit = unit_name(stats->total_bytes, options.unit);

     gettimeofday(&now, NULL);
-    elapsed = elapsed_sec(&now, &stats.start);
+    elapsed = elapsed_sec(&now, &stats->start);

     fprintf(stderr, "%3.2f %s (%lu bytes) total over %.2f sec, avg %.2f %s/s\n",
             data_amount, data_amount_unit,
-            stats.total_bytes,
+            stats->total_bytes,
             elapsed,
             data_amount / elapsed, data_amount_unit);


Drop other copyrights, as this is a new file.

--- pkg/shlib.c
+++ pkg/shlib.c
@@ -1,7 +1,4 @@
 /*
- * Copyright (c) 2011-2012 Baptiste Daroussin <bapt@FreeBSD.org>
- * Copyright (c) 2011-2012 Julien Laffaye <jlaffaye@FreeBSD.org>
- * Copyright (c) 2011-2012 Marin Atanasov Nikolov <dnaeon@gmail.com>
  * Copyright (c) 2012 Matthew Seaman <matthew@FreeBSD.org>
  * All rights reserved.
  *


delete token globals. Parameter bot-token add

--- lib/telebot.c
+++ lib/telebot.c
@@ -1,6 +1,4 @@
 #include <telebot.h>
-
-static const char * Token = NULL;

 void telebot_init () {

@@ -20,7 +18,6 @@

     if (bot_user) {
         Bot *obot = bot(token, bot_user);
-        Token = alloc_string(obot->token);

         return obot;
     }
@@ -326,11 +323,11 @@
     json_t *get_file;
     char *path_file;

-    get_file = generic_method_call(Token, "getfile?file_id=%s", file_id);
+    get_file = generic_method_call(bot->token, "getfile?file_id=%s", file_id);

     File * ofile = file_parse(get_file);

-    path_file = call_method_download(Token, dir, ofile);
+    path_file = call_method_download(bot->token, dir, ofile);

     if(ofile){
         file_free(ofile);
@@ -346,7 +343,7 @@
 UserProfilePhotos * get_user_profile_photos(Bot * bot, char * dir, long user_id, long offset, long limit){
     json_t * user_profile;
     char *method, *path_file;
-    size_t photosze_len, method_len = 71;
+    size_t photosze_len, method_len = 80;
     int i;

     method = malloc(method_len);
@@ -364,7 +361,7 @@
         snprintf(method, method_len, "getUserProfilePhotos?user_id=%ld?offset=%ld?limit=%ld",
                  user_id, offset, limit);

-    user_profile = generic_method_call(Token, method);
+    user_profile = generic_method_call(bot->token, method);

     UserProfilePhotos * oupp = user_profile_photos_parse(user_profile);
     if(!oupp)
@@ -408,21 +405,13 @@
     }

     MemStore * input;
+    json_t * message;

     input = call_method_input_file(bot->token, ifile);

-    json_t *root = load(input->content),
-           *ok,
-           *result;
-
-    if (json_is_object(root)) {
-        ok = json_object_get(root, "ok");
-        if (json_is_true(ok)) {
-            return message_parse(json_object_get(root, "result"));
-        }
-    }
-
-    return NULL;
+    message = start_json(input->content);
+
+    return message_parse(message);
 }

 Message * send_photo_chat(Bot * bot, long int chat_id, char * filename,


For dumping the DSDT (-o option), be sure to use the X_DSDT address if appropriate.  This should be the last change to make ia64 work.

--- usr.sbin/acpi/acpidump/acpi.c
+++ usr.sbin/acpi/acpidump/acpi.c
@@ -792,7 +792,13 @@
 {
 	struct	ACPIsdt *sdt;

-	sdt = (struct ACPIsdt *)acpi_map_sdt(fadt->dsdt_ptr);
+	/* Use the DSDT address if it is valid and version 2, else X_DSDT */
+	if (addr_size == 4 ||
+	    (addr_size == 8 && fadt->dsdt_ptr != 0 &&
+	    (fadt->x_dsdt_ptr & 0xffffffff) != fadt->dsdt_ptr))
+		sdt = (struct ACPIsdt *)acpi_map_sdt(fadt->dsdt_ptr);
+	else
+		sdt = (struct ACPIsdt *)acpi_map_sdt(fadt->x_dsdt_ptr);
 	if (acpi_checksum(sdt, sdt->len))
 		errx(1, "DSDT is corrupt\n");
 	return (sdt);


Re-implement the DB handle cache using a circular queue and manage
it with the CIRCLEQ macros. This simplifies the code a little, makes
it somewhat easier to read, and may be a little faster. (Actually I think
the performace is about the same.)

Also, in the non DB_CACHE case, save copies of data returned from
the database library in a static buffer, just in case we decide to use
it after the database has been closed. Technically, the memory that the
data pointers refer to belongs to the DB package and we can't count on
it being there after the database has been closed -- the DB package
frees its buffers. (With DB_CACHE #defined the databases are held
open so the buffers remain valid.) I don't think any of the utilities
that use the dblookup module have had any problems with this yet, but
there's no sense in taking any chances.

--- usr.sbin/ypserv/yp_dblookup.c
+++ usr.sbin/ypserv/yp_dblookup.c
@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$Id: yp_dblookup.c,v 1.13 1996/06/04 04:08:21 wpaul Exp $
+ *	$Id: yp_dblookup.c,v 1.4 1996/07/07 19:04:33 wpaul Exp $
  *
  */
 #include <stdio.h>
@@ -47,7 +47,7 @@
 #include "yp_extern.h"

 #ifndef lint
-static const char rcsid[] = "$Id: yp_dblookup.c,v 1.13 1996/06/04 04:08:21 wpaul Exp $";
+static const char rcsid[] = "$Id: yp_dblookup.c,v 1.4 1996/07/07 19:04:33 wpaul Exp $";
 #endif

 int ypdb_debug = 0;
@@ -64,8 +64,13 @@
 };

 #ifdef DB_CACHE
+#include <sys/queue.h>
+
+#ifndef MAXDBS
 #define MAXDBS 20
-#define LASTDB (MAXDBS - 1)
+#endif
+
+static int numdbs = 0;

 struct dbent {
 	DB *dbp;
@@ -74,51 +79,118 @@
 	int size;
 };

-static struct dbent *dbs[MAXDBS];
-static int numdbs = 0;
-
-/*
- * Make sure all the DB entries are NULL to start with.
+static CIRCLEQ_HEAD(circlehead, circleq_entry) qhead;
+
+struct circleq_entry {
+	struct dbent *dbptr;
+	CIRCLEQ_ENTRY(circleq_entry) links;
+};
+
+/*
+ * Initialize the circular queue.
  */
 void yp_init_dbs()
 {
-	register int i;
-
-	for (i = 0; i < MAXDBS; i++);
-		dbs[i] = NULL;
+	CIRCLEQ_INIT(&qhead);
 	return;
 }

 /*
- * Zorch a single entry in the dbent table and release
- * all its resources.
- */
-static void yp_flush(i)
-	register int i;
-{
-	(void)(dbs[i]->dbp->close)(dbs[i]->dbp);
-	dbs[i]->dbp = NULL;
-	free(dbs[i]->name);
-	dbs[i]->name = NULL;
-	dbs[i]->key = NULL;
-	dbs[i]->size = 0;
-	free(dbs[i]);
-	dbs[i] = NULL;
+ * Dynamically allocate an entry for the circular queue.
+ * Return a NULL pointer on failure.
+ */
+static struct circleq_entry *yp_malloc_qent()
+{
+	register struct circleq_entry *q;
+
+	q = (struct circleq_entry *)malloc(sizeof(struct circleq_entry));
+	if (q == NULL) {
+		yp_error("failed to malloc() circleq entry: %s",
+							strerror(errno));
+		return(NULL);
+	}
+	bzero((char *)q, sizeof(struct circleq_entry));
+	q->dbptr = (struct dbent *)malloc(sizeof(struct dbent));
+	if (q->dbptr == NULL) {
+		yp_error("failed to malloc() circleq entry: %s",
+							strerror(errno));
+		free(q);
+		return(NULL);
+	}
+	bzero((char *)q->dbptr, sizeof(struct dbent));
+
+	return(q);
+}
+
+/*
+ * Free a previously allocated circular queue
+ * entry.
+ */
+static void yp_free_qent(q)
+	struct circleq_entry *q;
+{
+	/*
+	 * First, close the database. In theory, this is also
+	 * supposed to free the resources allocated by the DB
+	 * package, including the memory pointed to by q->dbptr->key.
+	 * This means we don't have to free q->dbptr->key here.
+	 */
+	if (q->dbptr->dbp) {
+		(void)(q->dbptr->dbp->close)(q->dbptr->dbp);
+		q->dbptr->dbp = NULL;
+	}
+	/*
+	 * Then free the database name, which was strdup()'ed.
+	 */
+	free(q->dbptr->name);
+
+	/*
+	 * Free the rest of the dbent struct.
+	 */
+	free(q->dbptr);
+	q->dbptr = NULL;
+
+	/*
+	 * Free the circleq struct.
+	 */
+	free(q);
+	q = NULL;
+
+	return;
+}
+
+/*
+ * Zorch a single entry in the dbent queue and release
+ * all its resources. (This always removes the last entry
+ * in the queue.)
+ */
+static void yp_flush()
+{
+	register struct circleq_entry *qptr;
+
+	qptr = qhead.cqh_last;
+	CIRCLEQ_REMOVE(&qhead, qptr, links);
+	yp_free_qent(qptr);
 	numdbs--;
-}
-
-/*
- * Close all databases and erase all database names.
+
+	return;
+}
+
+/*
+ * Close all databases, erase all database names and empty the queue.
  */
 void yp_flush_all()
 {
-	register int i;
-
-	for (i = 0; i < MAXDBS; i++) {
-		if (dbs[i] != NULL && dbs[i]->dbp != NULL) {
-			yp_flush(i);
-		}
-	}
+	register struct circleq_entry *qptr;
+
+	while(qhead.cqh_first != (void *)&qhead) {
+		qptr = qhead.cqh_first; /* save this */
+		CIRCLEQ_REMOVE(&qhead, qhead.cqh_first, links);
+		yp_free_qent(qptr);
+	}
+	numdbs = 0;
+
+	return;
 }

@@ -128,66 +200,63 @@
  * a new entry when all our slots are already filled, we have to kick
  * out the entry in the last slot to make room.
  */
-static void yp_add_db(dbp, name, size)
+static int yp_cache_db(dbp, name, size)
 	DB *dbp;
 	char *name;
 	int size;
 {
-	register int i;
-	register struct dbent *tmp;
-
-	tmp = dbs[LASTDB];
-
-	/* Rotate */
-	for (i = LASTDB; i > 0; i--)
-		dbs[i] = dbs[i - 1];
-
-	dbs[0] = tmp;
-
-	if (dbs[0]) {
+	register struct circleq_entry *qptr;
+
+	if (numdbs == MAXDBS) {
 		if (ypdb_debug)
-			yp_error("table overflow -- releasing last slot");
-		yp_flush(0);
+			yp_error("queue overflow -- releasing last slot");
+		yp_flush();
 	}

 	/*
-	 * Allocate a new entry.
+	 * Allocate a new queue entry.
 	 */
-	if (dbs[0] == NULL) {
-		dbs[0] = (struct dbent *)malloc(sizeof(struct dbent));
-		bzero((char *)dbs[0], sizeof(struct dbent));
-	}
-
+
+	if ((qptr = yp_malloc_qent()) == NULL) {
+		yp_error("failed to allocate a new cache entry");
+		return(1);
+	}
+
+	qptr->dbptr->dbp = dbp;
+	qptr->dbptr->name = strdup(name);
+	qptr->dbptr->size = size;
+	qptr->dbptr->key = NULL;
+
+	CIRCLEQ_INSERT_HEAD(&qhead, qptr, links);
 	numdbs++;
-	dbs[0]->dbp = dbp;
-	dbs[0]->name = strdup(name);
-	dbs[0]->size = size;
-	return;
+
+	return(0);
 }

 /*
  * Search the list for a database matching 'name.' If we find it,
  * move it to the head of the list and return its DB handle. If
  * not, just fail: yp_open_db_cache() will subsequently try to open
- * the database itself and call yp_add_db() to add it to the
+ * the database itself and call yp_cache_db() to add it to the
  * list.
  *
  * The search works like this:
  *
  * - The caller specifies the name of a database to locate. We try to
- *   find an entry in our list with a matching name.
+ *   find an entry in our queue with a matching name.
  *
  * - If the caller doesn't specify a key or size, we assume that the
  *   first entry that we encounter with a matching name is returned.
- *   This will result in matches regardless of the pointer index.
- *
- * - If the caller also specifies a key and length, we check name
- *   matches to see if their saved key indexes and lengths also match.
+ *   This will result in matches regardless of the key/size values
+ *   stored in the queue entry.
+ *
+ * - If the caller also specifies a key and length, we check to see
+ *   if the key and length saved in the queue entry also matches.
  *   This lets us return a DB handle that's already positioned at the
  *   correct location within a database.
  *
- * - Once we have a match, it gets migrated to the top of the list
- *   array so that it will be easier to find if another request for
+ * - Once we have a match, it gets migrated to the top of the queue
+ *   so that it will be easier to find if another request for
  *   the same database comes in later.
  */
 static DB *yp_find_db(name, key, size)
@@ -195,26 +264,24 @@
 	char *key;
 	int size;
 {
-	register int i, j;
-	register struct dbent *tmp;
-
-	for (i = 0; i < numdbs; i++) {
-		if (dbs[i]->name != NULL && !strcmp(dbs[i]->name, name)) {
+	register struct circleq_entry *qptr;
+
+	for (qptr = qhead.cqh_first; qptr != (void *)&qhead;
+						qptr = qptr->links.cqe_next) {
+		if (!strcmp(qptr->dbptr->name, name)) {
 			if (size) {
-				if (size != dbs[i]->size ||
-				   strncmp(dbs[i]->key, key, size))
+				if (size != qptr->dbptr->size ||
+				   strncmp(qptr->dbptr->key, key, size))
 					continue;
 			} else {
-				if (dbs[i]->size)
+				if (qptr->dbptr->size)
 					continue;
 			}
-			if (i > 0) {
-				tmp = dbs[i];
-				for (j = i; j > 0; j--)
-					dbs[j] = dbs[j - 1];
-				dbs[0] = tmp;
+			if (qptr != qhead.cqh_first) {
+				CIRCLEQ_REMOVE(&qhead, qptr, links);
+				CIRCLEQ_INSERT_HEAD(&qhead, qptr, links);
 			}
-			return(dbs[0]->dbp);
+			return(qptr->dbptr->dbp);
 		}
 	}

@@ -238,6 +305,7 @@
 /*
 	snprintf(buf, sizeof(buf), "%s/%s", domain, map);
 */
+	yp_errno = YP_TRUE;

 	strcpy(buf, domain);
 	strcat(buf, "/");
@@ -246,8 +314,13 @@
 	if ((dbp = yp_find_db((char *)&buf, key, size)) != NULL) {
 		return(dbp);
 	} else {
-		if ((dbp = yp_open_db(domain, map)) != NULL)
-			yp_add_db(dbp, (char *)&buf, size);
+		if ((dbp = yp_open_db(domain, map)) != NULL) {
+			if (yp_cache_db(dbp, (char *)&buf, size)) {
+				(void)(dbp->close)(dbp);
+				yp_errno = YP_YPERR;
+				return(NULL);
+			}
+		}
 	}

 	return (dbp);
@@ -293,7 +366,7 @@
 			 * open one and try again.
 			 */
 			yp_error("ran out of file descriptors");
-			yp_flush(numdbs - 1);
+			yp_flush();
 			goto again;
 			break;
 #endif
@@ -333,6 +406,9 @@
 {
 	DB *dbp;
 	int rval = 0;
+#ifndef DB_CACHE
+	static unsigned char buf[YPMAXRECORD];
+#endif

 	if (ypdb_debug)
 		yp_error("Looking up key [%.*s] in map [%s]",
@@ -356,7 +432,7 @@

 	if ((rval = (dbp->get)(dbp, key, data, 0)) != 0) {
 #ifdef DB_CACHE
-		dbs[0]->size = 0;
+		qhead.cqh_first->dbptr->size = 0;
 #else
 		(void)(dbp->close)(dbp);
 #endif
@@ -371,11 +447,13 @@
 			 key->size, key->data, data->size, data->data);

 #ifdef DB_CACHE
-	if (dbs[0]->size) {
-		dbs[0]->key = key->data;
-		dbs[0]->size = key->size;
+	if (qhead.cqh_first->dbptr->size) {
+		qhead.cqh_first->dbptr->key = key->data;
+		qhead.cqh_first->dbptr->size = key->size;
 	}
 #else
+	bcopy((char *)data->data, (char *)&buf, data->size);
+	data->data = (void *)&buf;
 	(void)(dbp->close)(dbp);
 #endif

@@ -389,13 +467,16 @@
 	int allow;
 {
 	int rval;
+#ifndef DB_CACHE
+	static unsigned char buf[YPMAXRECORD];
+#endif

 	if (ypdb_debug)
 		yp_error("Retrieving first key in map.");

 	if ((rval = (dbp->seq)(dbp,key,data,R_FIRST)) != 0) {
 #ifdef DB_CACHE
-		dbs[0]->size = 0;
+		qhead.cqh_first->dbptr->size = 0;
 #endif
 		if (rval == 1)
 			return(YP_NOKEY);
@@ -407,7 +488,7 @@
 	while (!strncmp(key->data, "YP_", 3) && !allow) {
 		if ((rval = (dbp->seq)(dbp,key,data,R_NEXT)) != 0) {
 #ifdef DB_CACHE
-			dbs[0]->size = 0;
+			qhead.cqh_first->dbptr->size = 0;
 #endif
 			if (rval == 1)
 				return(YP_NOKEY);
@@ -421,10 +502,13 @@
 			 key->size, key->data, data->size, data->data);

 #ifdef DB_CACHE
-	if (dbs[0]->size) {
-		dbs[0]->key = key->data;
-		dbs[0]->size = key->size;
-	}
+	if (qhead.cqh_first->dbptr->size) {
+		qhead.cqh_first->dbptr->key = key->data;
+		qhead.cqh_first->dbptr->size = key->size;
+	}
+#else
+	bcopy((char *)data->data, (char *)&buf, data->size);
+	data->data = (void *)&buf;
 #endif

 	return(YP_TRUE);
@@ -440,6 +524,10 @@
 	static DBT lkey = { NULL, 0 };
 	static DBT ldata = { NULL, 0 };
 	int rval;
+#ifndef DB_CACHE
+	static unsigned char keybuf[YPMAXRECORD];
+	static unsigned char datbuf[YPMAXRECORD];
+#endif

 	if (key == NULL || key->data == NULL) {
 		rval = yp_first_record(dbp,key,data,allow);
@@ -455,14 +543,14 @@

 	if (!all) {
 #ifdef DB_CACHE
-		if (!dbs[0]->key) {
+		if (qhead.cqh_first->dbptr->key == NULL) {
 #endif
 			(dbp->seq)(dbp,&lkey,&ldata,R_FIRST);
 			while(strncmp((char *)key->data,lkey.data,
 				(int)key->size) || key->size != lkey.size)
 				if ((dbp->seq)(dbp,&lkey,&ldata,R_NEXT)) {
 #ifdef DB_CACHE
-					dbs[0]->size = 0;
+					qhead.cqh_first->dbptr->size = 0;
 #endif
 					return(YP_NOKEY);
 				}
@@ -474,7 +562,7 @@

 	if ((dbp->seq)(dbp,key,data,R_NEXT)) {
 #ifdef DB_CACHE
-		dbs[0]->size = 0;
+		qhead.cqh_first->dbptr->size = 0;
 #endif
 		return(YP_NOMORE);
 	}
@@ -483,7 +571,7 @@
 	while (!strncmp(key->data, "YP_", 3) && !allow)
 		if ((dbp->seq)(dbp,key,data,R_NEXT)) {
 #ifdef DB_CACHE
-			dbs[0]->size = 0;
+		qhead.cqh_first->dbptr->size = 0;
 #endif
 			return(YP_NOMORE);
 		}
@@ -493,13 +581,16 @@
 			 key->size, key->data, data->size, data->data);

 #ifdef DB_CACHE
-	if (dbs[0]->size) {
-		dbs[0]->key = key->data;
-		dbs[0]->size = key->size;
+	if (qhead.cqh_first->dbptr->size) {
+		qhead.cqh_first->dbptr->key = key->data;
+		qhead.cqh_first->dbptr->size = key->size;
 	}
 #else
-	lkey.data = key->data;
+	bcopy((char *)key->data, (char *)&keybuf, key->size);
+	lkey.data = (void *)&keybuf;
 	lkey.size = key->size;
+	bcopy((char *)data->data, (char *)&datbuf, data->size);
+	data->data = (void *)&datbuf;
 #endif

 	return(YP_TRUE);


monitor: cleanup code for booting cores on ARMv7

The code should have the same semantics as before, except that it does
not use ram_set_affinity() to make sure that the kernel  image is placed
on the first 2G, because this does not seem to work. Instead, a simple
frame_alloc() is used for now.

--- usr/monitor/arch/armv7/boot.c
+++ usr/monitor/arch/armv7/boot.c
@@ -41,6 +41,325 @@
     enum cpu_type               cputype;
     struct monitor_binding      *binding;
 };
+
+#if defined(CONFIG_FLOUNDER_BACKEND_UMP_IPI)
+static errval_t
+setup_intermon_connection_ump_ipi(int local_hwid, int remote_hwid,
+                                  struct intermon_ump_ipi_binding *ump_binding,
+                                  void *buf)
+{
+    // Bootee's notify channel ID is always 1
+    struct capref notify_cap;
+    err = notification_create_cap(1, remote_hwid, &notify_cap);
+    assert(err == SYS_ERR_OK);
+
+    // Allocate my own notification caps
+    struct capref ep, my_notify_cap;
+    struct lmp_endpoint *iep;
+    int chanid;
+    err = endpoint_create(LMP_RECV_LENGTH, &ep, &iep);
+    assert(err_is_ok(err));
+    err = notification_allocate(ep, &chanid);
+    assert(err == SYS_ERR_OK);
+    err = notification_create_cap(chanid, local_hwid, &my_notify_cap);
+    assert(err == SYS_ERR_OK);
+
+    // init our end of the binding and channel
+    err = intermon_ump_ipi_init(ump_binding, get_default_waitset(),
+                                buf, MON_URPC_CHANNEL_LEN,
+                                buf + MON_URPC_CHANNEL_LEN,
+                                MON_URPC_CHANNEL_LEN, notify_cap,
+                                my_notify_cap, ep, iep);
+
+    return err;
+}
+#endif
+
+static errval_t
+setup_intermon_connection(int local_hwid,
+                          int remote_hwid,
+                          struct intermon_binding **ret_binding,
+                          struct frame_identity *urpc_frame_id)
+{
+    // compute size of frame needed and allocate it
+    struct capref frame;
+    size_t framesize;
+    errval_t err;
+
+    framesize = MON_URPC_CHANNEL_LEN * 2;
+    err = frame_alloc(&frame, framesize, &framesize);
+    if (err_is_fail(err)) {
+        return err_push(err, LIB_ERR_FRAME_ALLOC);
+    }
+
+    // Mark it remote
+    bool has_descendants;
+    err = monitor_cap_remote(frame, true, &has_descendants);
+    if (err_is_fail(err)) {
+        return err;
+    }
+
+    // map it in
+    void *buf;
+    err = vspace_map_one_frame(&buf, framesize, frame, NULL, NULL);
+    if (err_is_fail(err)) {
+        cap_destroy(frame);
+        return err_push(err, LIB_ERR_VSPACE_MAP);
+    }
+
+    #if defined(CONFIG_FLOUNDER_BACKEND_UMP_IPI)
+    struct intermon_ump_ipi_binding *ump_binding;
+    #else
+    struct intermon_ump_binding *ump_binding;
+    #endif
+
+    ump_binding = malloc(sizeof(*ump_binding));
+    assert(ump_binding != NULL);
+
+    #if defined(CONFIG_FLOUNDER_BACKEND_UMP_IPI)
+    err = setup_intermon_connection_ump_ipi(local_hwid, remote_hwid,
+                                            ump_binding, buf);
+    #else
+    err = intermon_ump_init(ump_binding, get_default_waitset(),
+                            buf, MON_URPC_CHANNEL_LEN,
+                            (char *)buf + MON_URPC_CHANNEL_LEN,
+                            MON_URPC_CHANNEL_LEN);
+    #endif
+
+    if (err_is_fail(err)) {
+        cap_destroy(frame);
+        return err_push(err, LIB_ERR_UMP_CHAN_BIND);
+    }
+
+
+    // Identify UMP frame for tracing
+    struct frame_identity umpid;
+    err = invoke_frame_identify(frame, &umpid);
+    assert(err_is_ok(err));
+    ump_binding->ump_state.chan.recvid = (uintptr_t)umpid.base;
+    ump_binding->ump_state.chan.sendid =
+        (uintptr_t)(umpid.base + MON_URPC_CHANNEL_LEN);
+
+    /* Look up information on the urpc_frame cap */
+    err = invoke_frame_identify(frame, urpc_frame_id);
+    if (err_is_fail(err)) {
+        USER_PANIC_ERR(err, "frame_identify failed");
+    }
+
+    *ret_binding = &ump_binding->b;
+    return err;
+}
+
+struct module_blob {
+    size_t             size;
+    lvaddr_t           vaddr;
+    genpaddr_t         paddr;
+    struct mem_region *mem_region;
+};
+
+static errval_t
+module_blob_map(const char *name, struct module_blob *blob)
+{
+    errval_t err;
+    struct mem_region *mem_region = multiboot_find_module(bi, name);
+    if (mem_region == NULL) {
+        return SPAWN_ERR_FIND_MODULE;
+    }
+
+    // it's cached already
+    if (blob->vaddr != 0) {
+        assert(mem_region == blob->mem_region);
+        return SYS_ERR_OK;
+    }
+
+    blob->mem_region = mem_region;
+    err = spawn_map_module(mem_region,
+                           &blob->size,
+                           &blob->vaddr,
+                           &blob->paddr);
+
+    if (err_is_fail(err)) {
+        return err_push(err, SPAWN_ERR_MAP_MODULE);
+    } else {
+        return SYS_ERR_OK;
+    }
+}
+
+static errval_t
+cpu_memory_prepare(size_t *size,
+                   struct capref *cap_ret, void **buf_ret,
+                   struct frame_identity *frameid)
+{
+    errval_t err;
+    struct capref cap;
+    void *buf;
+
+    /* Currently, the app kernel can only be loaded in the first 2GB
+       of memory. Further, it must not overlap the integer
+       boundaries, i.e. 0-1, 1-2 */
+
+    // FIXME:
+    // The code below does not make sure that the kernel is loaded in the first
+    // 2G, but the disabled code does not work. So using a simple frame_alloc()
+    // for now.
+    #if 0
+    uint64_t old_minbase, old_maxlimit;
+    ram_get_affinity(&old_minbase, &old_maxlimit);
+    for (uint64_t minbase = 0, maxlimit = (uint64_t)1 << 30;
+         minbase < (uint64_t)2 << 30;
+         minbase += (uint64_t)1 << 30, maxlimit += (uint64_t)1 << 30) {
+
+        printf("minbase=%llu maxlimit=%llu cpu_memory=%zd\n",
+                minbase, maxlimit, cpu_memory);
+        ram_set_affinity(minbase, maxlimit);
+        err = frame_alloc(&cpu_memory_cap, cpu_memory, &cpu_memory);
+        if (err_is_ok(err)) {
+            goto done;
+        }
+    }
+    USER_PANIC("No memory in the first 2GB, cannot continue booting cores");
+ done:
+    ram_set_affinity(old_minbase, old_maxlimit);
+    #else
+     err = frame_alloc(&cap, *size, size);
+     if (err_is_fail(err)) {
+         USER_PANIC("Failed to allocate %zd memory\n", *size);
+     }
+    #endif
+
+#ifdef __gem5__
+    // XXX: We map the frame for the new kernel as uncacheable. Gem5 has a
+    // problem when one core has cacheing on and writes to a location where an
+    // other core reads from without caches enabled. On real hardware one could
+    // clean/flush the cache, but Gem5 doesn't support cache maintenance
+    // operations for ARM
+    err = vspace_map_one_frame_attr(&buf, *size, cap,
+                                    VREGION_FLAGS_READ_WRITE_NOCACHE,
+                                    NULL, NULL);
+#else
+    err = vspace_map_one_frame(&buf, *size, cap, NULL, NULL);
+#endif
+    if (err_is_fail(err)) {
+        return err_push(err, LIB_ERR_VSPACE_MAP);
+    }
+
+    // Mark memory as remote
+    bool has_descendants;
+    err = monitor_cap_remote(cap, true, &has_descendants);
+    if (err_is_fail(err)) {
+        return err;
+    }
+
+    err = invoke_frame_identify(cap, frameid);
+    if (err_is_fail(err)) {
+        return err_push(err, LIB_ERR_FRAME_IDENTIFY);
+    }
+
+    *cap_ret = cap;
+    *buf_ret = buf;
+    return SYS_ERR_OK;
+}
+
+static errval_t
+cpu_memory_cleanup(struct capref cap, void *buf)
+{
+    errval_t err;
+
+    err = vspace_unmap(buf);
+    if (err_is_fail(err)) {
+        USER_PANIC_ERR(err, "vspace unmap CPU driver memory failed");
+    }
+
+    // XXX: Should not delete the remote cap
+    err = cap_destroy(cap);
+    if (err_is_fail(err)) {
+        USER_PANIC_ERR(err, "cap_destroy failed");
+    }
+
+    return SYS_ERR_OK;
+}
+
+static errval_t
+spawn_memory_prepare(size_t size, struct capref *cap_ret,
+                     struct frame_identity *frameid)
+{
+    errval_t err;
+    struct capref cap;
+
+    err = frame_alloc(&cap, size, NULL);
+    if (err_is_fail(err)) {
+        return err_push(err, LIB_ERR_FRAME_ALLOC);
+    }
+
+    // Mark memory as remote
+    bool has_descendants;
+    err = monitor_cap_remote(cap, true, &has_descendants);
+    if (err_is_fail(err)) {
+        return err;
+    }
+
+    err = invoke_frame_identify(cap, frameid);
+    if (err_is_fail(err)) {
+        USER_PANIC_ERR(err, "frame_identify failed");
+    }
+
+    *cap_ret = cap;
+    return SYS_ERR_OK;
+}
+
+static errval_t
+spawn_memory_cleanup(struct capref cap)
+{
+
+    errval_t err;
+    err = cap_destroy(cap);
+    if (err_is_fail(err)) {
+        USER_PANIC_ERR(err, "cap_destroy failed");
+    }
+
+    return SYS_ERR_OK;
+}
+
+static errval_t
+elf_load_and_relocate(lvaddr_t blob_start, size_t blob_size,
+                      void *to, lvaddr_t reloc_dest,
+                      uintptr_t *reloc_entry)
+{
+    genvaddr_t entry; // entry poing of the loaded elf image
+    struct Elf32_Ehdr *head = (struct Elf32_Ehdr *)blob_start;
+    struct Elf32_Shdr *symhead, *rel, *symtab;
+    errval_t err;
+
+    //state.vbase = (void *)ROUND_UP(to, ARM_L1_ALIGN);
+    struct monitor_allocate_state state;
+    state.vbase   = to;
+    state.elfbase = elf_virtual_base(blob_start);
+
+    err = elf_load(head->e_machine,
+                   monitor_elfload_allocate,
+                   &state,
+                   blob_start, blob_size,
+                   &entry);
+    if (err_is_fail(err)) {
+        return err;
+    }
+
+    // Relocate to new physical base address
+    symhead = (struct Elf32_Shdr *)(blob_start + (uintptr_t)head->e_shoff);
+    rel = elf32_find_section_header_type(symhead, head->e_shnum, SHT_REL);
+    symtab = elf32_find_section_header_type(symhead, head->e_shnum, SHT_DYNSYM);
+    assert(rel != NULL && symtab != NULL);
+
+    elf32_relocate(reloc_dest, state.elfbase,
+                   (struct Elf32_Rel *)(blob_start + rel->sh_offset),
+                   rel->sh_size,
+                   (struct Elf32_Sym *)(blob_start + symtab->sh_offset),
+                   symtab->sh_size,
+                   state.elfbase, state.vbase);
+
+    *reloc_entry = entry - state.elfbase + reloc_dest;
+    return SYS_ERR_OK;
+}

 errval_t spawn_xcore_monitor(coreid_t coreid, int hwid, enum cpu_type cpu_type,
                              const char *cmdline,
@@ -60,277 +379,93 @@
 #error "unknown armv7 architecture"
 #endif

-
-    // Setup new inter-monitor connection to ourselves
-#ifdef CONFIG_FLOUNDER_BACKEND_UMP_IPI
-    struct intermon_ump_ipi_binding *ump_binding = malloc(sizeof(struct intermon_ump_ipi_binding));
-#else
-    struct intermon_ump_binding *ump_binding = malloc(sizeof(struct intermon_ump_binding));
-#endif
-    assert(ump_binding != NULL);
-
-    // compute size of frame needed and allocate it
-    struct capref frame;
-    size_t framesize = MON_URPC_CHANNEL_LEN * 2;
-    err = frame_alloc(&frame, framesize, &framesize);
-    if (err_is_fail(err)) {
-        return err_push(err, LIB_ERR_FRAME_ALLOC);
-    }
-
-    // Mark it remote
-    bool has_descendants;
-    err = monitor_cap_remote(frame, true, &has_descendants);
-    if (err_is_fail(err)) {
-        return err;
-    }
-
-    // map it in
-    void *buf;
-    err = vspace_map_one_frame(&buf, framesize, frame, NULL, NULL);
-    if (err_is_fail(err)) {
-        cap_destroy(frame);
-        return err_push(err, LIB_ERR_VSPACE_MAP);
-    }
-
     // Get my arch ID
     uintptr_t my_arch_id = 0;
     err = invoke_monitor_get_arch_id(&my_arch_id);
-    assert(err == SYS_ERR_OK);
-
+    if (err_is_fail(err)) {
+        return err;
+    }
+
+    // setup an intermon connection for the new core
+    struct frame_identity urpc_frame_id;
+    err = setup_intermon_connection(my_arch_id, hwid, ret_binding, &urpc_frame_id);
+    if (err_is_fail(err)) {
+        return err;
+    }
+
+    // map cpu and monitor module
+    // XXX: caching these for now, until we have unmap
+    static struct module_blob cpu_blob, monitor_blob;
+    err = module_blob_map(cpuname, &cpu_blob);
+    if (!err_is_ok(err)) {
+        return err;
+    }
+    err = module_blob_map(monitorname, &monitor_blob);
+    if (!err_is_ok(err)) {
+        return err;
+    }
+
+    // allocate memory for cpu driver: we allocate a page for arm_core_data and
+    // the reset for the elf image
+    assert(sizeof(struct arm_core_data) <= arch_page_size);
+    struct {
+        size_t                size;
+        struct capref         cap;
+        void                  *buf;
+        struct frame_identity frameid;
+    } cpu_mem = {
+        .size = arch_page_size + elf_virtual_size(cpu_blob.vaddr)
+    };
+    err = cpu_memory_prepare(&cpu_mem.size,
+                             &cpu_mem.cap,
+                             &cpu_mem.buf,
+                             &cpu_mem.frameid);
+    if (!err_is_ok(err)) {
+        return err;
+    }
+
+    // Load cpu driver to the allocate space and do relocatation
+    uintptr_t reloc_entry;
+    err = elf_load_and_relocate(cpu_blob.vaddr,
+                                cpu_blob.size,
+                                cpu_mem.buf + arch_page_size,
+                                cpu_mem.frameid.base + arch_page_size,
+                                &reloc_entry);
+    if (!err_is_ok(err)) {
+        return err_push(err, LIB_ERR_FRAME_IDENTIFY);
+    }
+
+    /* Chunk of memory to load monitor on the app core */
+    struct capref spawn_mem_cap;
+    struct frame_identity spawn_mem_frameid;
+    err = spawn_memory_prepare(ARM_CORE_DATA_PAGES*arch_page_size,
+                               &spawn_mem_cap,
+                               &spawn_mem_frameid);
+    if (!err_is_ok(err)) {
+        return err;
+    }
+
+    /* Setup the core_data struct in the new kernel */
+    struct arm_core_data *core_data = (struct arm_core_data *)cpu_mem.buf;
+
+    struct Elf32_Ehdr *head32 = (struct Elf32_Ehdr *)cpu_blob.vaddr;
+    core_data->elf.size = sizeof(struct Elf32_Shdr);
+    core_data->elf.addr = cpu_blob.paddr + (uintptr_t)head32->e_shoff;
+    core_data->elf.num  = head32->e_shnum;
+
+    core_data->module_start        = cpu_blob.paddr;
+    core_data->module_end          = cpu_blob.paddr + cpu_blob.size;
+    core_data->urpc_frame_base     = urpc_frame_id.base;
+    core_data->urpc_frame_bits     = urpc_frame_id.bits;
+    core_data->monitor_binary      = monitor_blob.paddr;
+    core_data->monitor_binary_size = monitor_blob.size;
+    core_data->memory_base_start   = spawn_mem_frameid.base;
+    core_data->memory_bits         = spawn_mem_frameid.bits;
+    core_data->src_core_id         = my_core_id;
+    core_data->src_arch_id         = my_arch_id;
+    core_data->dst_core_id         = coreid;
 #ifdef CONFIG_FLOUNDER_BACKEND_UMP_IPI
-    // Bootee's notify channel ID is always 1
-    struct capref notify_cap;
-    err = notification_create_cap(1, hwid, &notify_cap);
-    assert(err == SYS_ERR_OK);
-
-    // Allocate my own notification caps
-    struct capref ep, my_notify_cap;
-    struct lmp_endpoint *iep;
-    int chanid;
-    err = endpoint_create(LMP_RECV_LENGTH, &ep, &iep);
-    assert(err_is_ok(err));
-    err = notification_allocate(ep, &chanid);
-    assert(err == SYS_ERR_OK);
-    err = notification_create_cap(chanid, my_arch_id, &my_notify_cap);
-    assert(err == SYS_ERR_OK);
-
-    // init our end of the binding and channel
-    err = intermon_ump_ipi_init(ump_binding, get_default_waitset(),
-                                buf, MON_URPC_CHANNEL_LEN,
-                                buf + MON_URPC_CHANNEL_LEN,
-                                MON_URPC_CHANNEL_LEN, notify_cap,
-                                my_notify_cap, ep, iep);
-#else
-    err = intermon_ump_init(ump_binding, get_default_waitset(),
-                            buf, MON_URPC_CHANNEL_LEN,
-                            (char *)buf + MON_URPC_CHANNEL_LEN,
-                            MON_URPC_CHANNEL_LEN);
-#endif
-    if (err_is_fail(err)) {
-        cap_destroy(frame);
-        return err_push(err, LIB_ERR_UMP_CHAN_BIND);
-    }
-
-    *ret_binding = &ump_binding->b;
-
-    // Identify UMP frame for tracing
-    struct frame_identity umpid;
-    err = invoke_frame_identify(frame, &umpid);
-    assert(err_is_ok(err));
-    ump_binding->ump_state.chan.recvid = (uintptr_t)umpid.base;
-    ump_binding->ump_state.chan.sendid =
-        (uintptr_t)(umpid.base + MON_URPC_CHANNEL_LEN);
-
-    /* Look up modules */
-    struct mem_region *cpu_region = multiboot_find_module(bi, cpuname);
-    if (cpu_region == NULL) {
-        return SPAWN_ERR_FIND_MODULE;
-    }
-    // XXX: Caching these for now, until we have unmap
-    static size_t cpu_binary_size;
-    static lvaddr_t cpu_binary = 0;
-    static genpaddr_t cpu_binary_phys;
-    static struct mem_region *cached_cpu_region;
-    if(cpu_binary == 0) {
-        cached_cpu_region = cpu_region;
-        err = spawn_map_module(cpu_region, &cpu_binary_size, &cpu_binary,
-                               &cpu_binary_phys);
-        if (err_is_fail(err)) {
-            return err_push(err, SPAWN_ERR_MAP_MODULE);
-        }
-    } else {
-        assert(cpu_region == cached_cpu_region);
-    }
-    struct Elf32_Ehdr *cpu_head = (struct Elf32_Ehdr *)cpu_binary;
-
-    struct mem_region *monitor_region = multiboot_find_module(bi, monitorname);
-    if (monitor_region == NULL) {
-        return SPAWN_ERR_FIND_MODULE;
-    }
-    // XXX: Caching these for now, until we have unmap
-    static size_t monitor_binary_size;
-    static lvaddr_t monitor_binary = 0;
-    static genpaddr_t monitor_binary_phys;
-    static struct mem_region *cached_monitor_region;
-    if(monitor_binary == 0) {
-        cached_monitor_region = monitor_region;
-        err = spawn_map_module(monitor_region, &monitor_binary_size, &monitor_binary,
-                               &monitor_binary_phys);
-        if (err_is_fail(err)) {
-            return err_push(err, SPAWN_ERR_MAP_MODULE);
-        }
-    } else {
-        assert(monitor_region == cached_monitor_region);
-    }
-
-    /* Memory for cpu */
-    //size_t cpu_memory = ROUND_UP(elf_virtual_size(cpu_binary) + arch_page_size, ARM_L1_ALIGN);
-    size_t cpu_memory = elf_virtual_size(cpu_binary) + arch_page_size;
-    struct capref cpu_memory_cap;
-
-    /* Currently, the app kernel can only be loaded in the first 2GB
-       of memory. Further, it must not overlap the integer
-       boundaries, i.e. 0-1, 1-2 */
-
-    uint64_t old_minbase;
-    uint64_t old_maxlimit;
-    ram_get_affinity(&old_minbase, &old_maxlimit);
-
-    for (uint32_t minbase = 0, maxlimit = (uint32_t)1 << 30;
-         minbase < (uint32_t)2 << 30;
-         minbase += (uint32_t)1 << 30, maxlimit += (uint32_t)1 << 30) {
-
-        ram_set_affinity(minbase, maxlimit);
-        err = frame_alloc(&cpu_memory_cap, cpu_memory, &cpu_memory);
-        if (err_is_fail(err)) {
-            continue;
-        } else {
-            goto done;
-        }
-    }
-
-    USER_PANIC("No memory in the first 2GB, cannot continue booting cores");
-
- done:
-    ram_set_affinity(old_minbase, old_maxlimit);
-
-    // Mark memory as remote
-    err = monitor_cap_remote(cpu_memory_cap, true, &has_descendants);
-    if (err_is_fail(err)) {
-        return err;
-    }
-
-    void *cpu_buf_memory;
-#ifdef __gem5__
-    // XXX: We map the frame for the new kernel as uncacheable. Gem5 has a problem
-    // when one core has cacheing on and writes to a location where an other core reads from
-    // without caches enabled. On real hardware one could clean/flush the cache, but Gem5
-    // doesn't support cache maintenance operations for ARM
-    err = vspace_map_one_frame_attr(&cpu_buf_memory, cpu_memory, cpu_memory_cap,
-    		VREGION_FLAGS_READ_WRITE_NOCACHE, NULL, NULL);
-#else
-    err = vspace_map_one_frame(&cpu_buf_memory, cpu_memory, cpu_memory_cap, NULL, NULL);
-#endif
-    if(err_is_fail(err)) {
-        return err_push(err, LIB_ERR_VSPACE_MAP);
-    }
-
-    /* Chunk of memory to load monitor on the app core */
-    struct capref spawn_memory_cap;
-    err = frame_alloc(&spawn_memory_cap, ARM_CORE_DATA_PAGES * arch_page_size,
-                      NULL);
-    if (err_is_fail(err)) {
-        return err_push(err, LIB_ERR_FRAME_ALLOC);
-    }
-    // Mark memory as remote
-    err = monitor_cap_remote(spawn_memory_cap, true, &has_descendants);
-    if (err_is_fail(err)) {
-        return err;
-    }
-    struct frame_identity spawn_memory_identity;
-    err = invoke_frame_identify(spawn_memory_cap, &spawn_memory_identity);
-    if (err_is_fail(err)) {
-        USER_PANIC_ERR(err, "frame_identify failed");
-    }
-
-    /* Load cpu */
-    struct monitor_allocate_state state;
-    //state.vbase = (void *)ROUND_UP((uintptr_t)cpu_buf_memory + arch_page_size, ARM_L1_ALIGN);
-    state.vbase = (char *)cpu_buf_memory + arch_page_size;
-    assert(sizeof(struct arm_core_data) <= arch_page_size);
-    state.elfbase = elf_virtual_base(cpu_binary);
-    genvaddr_t cpu_entry;
-    err = elf_load(cpu_head->e_machine, monitor_elfload_allocate, &state,
-                   cpu_binary, cpu_binary_size, &cpu_entry);
-    if (err_is_fail(err)) {
-        return err;
-    }
-
-    // Relocate cpu to new physical base address
-    struct frame_identity frameid;
-    err = invoke_frame_identify(cpu_memory_cap, &frameid);
-    if(err_is_fail(err)) {
-        return err_push(err, LIB_ERR_FRAME_IDENTIFY);
-    }
-
-
-    struct Elf32_Ehdr *head32 = (struct Elf32_Ehdr *)cpu_binary;
-
-    struct Elf32_Shdr *rel, *symtab, *symhead =
-    		(struct Elf32_Shdr *)(cpu_binary + (uintptr_t)head32->e_shoff);
-
-    rel = elf32_find_section_header_type(symhead, head32->e_shnum, SHT_REL);
-    assert(rel != NULL);
-    symtab = elf32_find_section_header_type(symhead, head32->e_shnum,
-    		SHT_DYNSYM);
-    assert(symtab != NULL);
-    //lvaddr_t dest = ROUND_UP(frameid.base + arch_page_size, ARM_L1_ALIGN);
-    lvaddr_t dest = frameid.base + arch_page_size;
-    elf32_relocate(dest, state.elfbase,
-    		(struct Elf32_Rel *)(uintptr_t)(cpu_binary + rel->sh_offset),
-    		rel->sh_size,
-    		(struct Elf32_Sym *)(uintptr_t)(cpu_binary + symtab->sh_offset),
-    		symtab->sh_size,
-    		state.elfbase, state.vbase);
-
-
-
-    genvaddr_t cpu_reloc_entry = cpu_entry - state.elfbase
-        + dest;
-
-    /* Look up information on the urpc_frame cap */
-    struct frame_identity urpc_frame_id;
-    err = invoke_frame_identify(frame, &urpc_frame_id);
-    if (err_is_fail(err)) {
-        USER_PANIC_ERR(err, "frame_identify failed");
-    }
-
-    /* Compute entry point in the foreign address space */
-    // XXX: Confusion address translation about l/gen/addr
-    forvaddr_t foreign_cpu_reloc_entry = (forvaddr_t)cpu_reloc_entry;
-
-    /* Setup the core_data struct in the new kernel */
-    struct arm_core_data *core_data = (struct arm_core_data*)((uintptr_t)state.vbase - arch_page_size);
-
-    core_data->elf.size = sizeof(struct Elf32_Shdr);
-    //struct Elf32_Ehdr *head32 = (struct Elf32_Ehdr *)cpu_binary;
-    core_data->elf.addr = cpu_binary_phys + (uintptr_t)head32->e_shoff;
-    core_data->elf.num  = head32->e_shnum;
-
-
-    core_data->module_start = cpu_binary_phys;
-    core_data->module_end   = cpu_binary_phys + cpu_binary_size;
-    core_data->urpc_frame_base = urpc_frame_id.base;
-    core_data->urpc_frame_bits = urpc_frame_id.bits;
-    core_data->monitor_binary   = monitor_binary_phys;
-    core_data->monitor_binary_size = monitor_binary_size;
-    core_data->memory_base_start = spawn_memory_identity.base;
-    core_data->memory_bits       = spawn_memory_identity.bits;
-    core_data->src_core_id       = my_core_id;
-    core_data->src_arch_id       = my_arch_id;
-    core_data->dst_core_id       = coreid;
-#ifdef CONFIG_FLOUNDER_BACKEND_UMP_IPI
-    core_data->chan_id           = chanid;
+    core_data->chan_id             = chanid;
 #endif

     if (cmdline != NULL) {
@@ -342,23 +477,20 @@
     }

     /* Invoke kernel capability to boot new core */
-    err = invoke_monitor_spawn_core(hwid, cpu_type, foreign_cpu_reloc_entry);
+    // XXX: Confusion address translation about l/gen/addr
+    err = invoke_monitor_spawn_core(hwid, cpu_type, (forvaddr_t)reloc_entry);
     if (err_is_fail(err)) {
         return err_push(err, MON_ERR_SPAWN_CORE);
     }

-    /* Clean up */ // XXX: Should not delete the remote cap
-    err = cap_destroy(cpu_memory_cap);
-    if (err_is_fail(err)) {
-        USER_PANIC_ERR(err, "cap_destroy failed");
-    }
-    err = cap_destroy(spawn_memory_cap);
-    if (err_is_fail(err)) {
-        USER_PANIC_ERR(err, "cap_destroy failed");
-    }
-    err = vspace_unmap(cpu_buf_memory);
-    if (err_is_fail(err)) {
-        USER_PANIC_ERR(err, "vspace unmap CPU driver memory failed");
+    err = cpu_memory_cleanup(cpu_mem.cap, cpu_mem.buf);
+    if (err_is_fail(err)) {
+        return err;
+    }
+
+    err = spawn_memory_cleanup(spawn_mem_cap);
+    if (err_is_fail(err)) {
+        return err;
     }

     return SYS_ERR_OK;


ports/gtk-webkit: Fix crash when hardware acceleration is disabled.

--- ports/gtk-webkit/next-gtk-webkit.c
+++ ports/gtk-webkit/next-gtk-webkit.c
@@ -22,7 +22,12 @@
 }

 int main(int argc, char *argv[]) {
+	// It's safer to initialize GTK before the server is started.  In particular,
+	// without it the program would crash if hardware acceleration is disabled
+	// (e.g. with the WEBKIT_DISABLE_COMPOSITING_MODE=1 environment variable).
+	gtk_init(NULL, NULL);
 	// TODO: Use GtkApplication?
+
 	guint owner_id = g_bus_own_name(G_BUS_TYPE_SESSION,
 			PLATFORM_PORT_NAME,
 			G_BUS_NAME_OWNER_FLAGS_NONE,


BSP_LM3S8962: move"#endif" to line 103 from line 106 in startup.c

git-svn-id: 839522a79b1d56a78fa446d2fd3a0c499f8e535e@1881 bbd45198-f89e-11dd-88c7-29a3b14d5316

--- bsp/lm3s8962/applications/startup.c
+++ bsp/lm3s8962/applications/startup.c
@@ -15,12 +15,12 @@
 #include <rthw.h>
 #include <rtthread.h>

-#include "board.h"
+#include "board.h"

-#ifdef RT_USING_LWIP
-#include <lwip/sys.h>
-#include <netif/ethernetif.h>
-#endif
+#ifdef RT_USING_LWIP
+#include <lwip/sys.h>
+#include <netif/ethernetif.h>
+#endif

 /**
  * @addtogroup LM3S
@@ -36,7 +36,7 @@

 extern int rt_application_init(void);
 extern void rt_hw_sdcard_init(void);
-extern int rt_hw_luminaryif_init(void);
+extern int rt_hw_luminaryif_init(void);

 #ifdef __CC_ARM
 extern int Image$$RW_IRAM1$$ZI$$Limit;
@@ -100,10 +100,10 @@
 #ifdef RT_USING_MODULE
 	/* init module system */
 	rt_system_module_init();
+#endif

 	/* init scheduler system */
 	rt_system_scheduler_init();
-#endif

 #ifdef RT_USING_LWIP
 	eth_system_device_init();


Add missing include

Add missing include

--- STEER/STEERBase/AliFileUtilities.h
+++ STEER/STEERBase/AliFileUtilities.h
@@ -4,6 +4,7 @@
 #include <vector>
 #include <string>
 #include <cstdlib>
+#include <cstdio>

 // put a standard header
 // History: 25.4.2016 -- initial version (sandro.wenzel@cern.ch)


Update softmax_with_cross_entropy_op.h

Update softmax_with_cross_entropy_op.h

delete blank lines at the beginning of the file

--- paddle/fluid/operators/softmax_with_cross_entropy_op.h
+++ paddle/fluid/operators/softmax_with_cross_entropy_op.h
@@ -1,5 +1,3 @@
-
-
 /* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.

 Licensed under the Apache License, Version 2.0 (the "License");


offset is missing from prepare write response in cordio

--- connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalAttClientImpl.h
+++ connectivity/FEATURE_BLE/libraries/TARGET_CORDIO/include/ble/internal/PalAttClientImpl.h
@@ -381,13 +381,11 @@
     struct PrepareWriteResponseConverter : ResponseConverter<ATTC_PREPARE_WRITE_RSP> {
         static AttPrepareWriteResponse convert(const attEvt_t* event)
         {
-            // WARNING: Not sure if correct, the stack erase the length parameter
             return AttPrepareWriteResponse(
                 event->handle,
-                to_uint16_t(event->pValue + 2),
-                // FIXME: the stack set the lenght to 0, the data won't be seen ...
-                make_const_Span(
-                    event->pValue + 4,
+                0, /* offset is lost */
+                make_const_Span(
+                    event->pValue,
                     event->valueLen
                 )
             );


Be lenient when a NSEC NameError response with RCODE=NXDOMAIN is received.
This is okay according 4035, but not after revising existence in 4592.
NSEC empty non-terminals exist and thus the RCODE should have been NOERROR.

If this occurs, and the RRsets are secure, we set the RCODE to NOERROR and
the security status of the reponse is also considered secure.

git-svn-id: 606cd7bb7c4874b1f27fc28ef6a6d76dca18f877@3089 be551aaa-1e26-0410-a405-d3ace91eadb9

--- validator/validator.c
+++ validator/validator.c
@@ -762,11 +762,12 @@
  * @param chase_reply: answer to that query to validate.
  * @param kkey: the key entry, which is trusted, and which matches
  * 	the signer of the answer. The key entry isgood().
+ * @param rcode: adjusted RCODE, in case of RCODE/proof mismatch leniency.
  */
 static void
 validate_nameerror_response(struct module_env* env, struct val_env* ve,
 	struct query_info* qchase, struct reply_info* chase_reply,
-	struct key_entry_key* kkey)
+	struct key_entry_key* kkey, int* rcode)
 {
 	int has_valid_nsec = 0;
 	int has_valid_wnsec = 0;
@@ -813,6 +814,10 @@
 		verbose(VERB_QUERY, "NameError response has failed to prove: "
 		          "qname does not exist");
 		chase_reply->security = sec_status_bogus;
+		/* Be lenient with RCODE in NSEC NameError responses */
+		validate_nodata_response(env, ve, qchase, chase_reply, kkey);
+		if (chase_reply->security == sec_status_secure)
+			*rcode = LDNS_RCODE_NOERROR;
 		return;
 	}

@@ -820,6 +825,10 @@
 		verbose(VERB_QUERY, "NameError response has failed to prove: "
 		          "covering wildcard does not exist");
 		chase_reply->security = sec_status_bogus;
+		/* Be lenient with RCODE in NSEC NameError responses */
+		validate_nodata_response(env, ve, qchase, chase_reply, kkey);
+		if (chase_reply->security == sec_status_secure)
+			*rcode = LDNS_RCODE_NOERROR;
 		return;
 	}

@@ -1568,6 +1577,7 @@
 	struct val_env* ve, int id)
 {
 	enum val_classification subtype;
+	int rcode;

 	if(!vq->key_entry) {
 		verbose(VERB_ALGO, "validate: no key entry, failed");
@@ -1651,7 +1661,7 @@
 			  	sec_status_to_string(
 				vq->chase_reply->security));
 			break;
-
+
 		case VAL_CLASS_NODATA:
 			verbose(VERB_ALGO, "Validating a nodata response");
 			validate_nodata_response(qstate->env, ve,
@@ -1662,12 +1672,15 @@
 			break;

 		case VAL_CLASS_NAMEERROR:
+			rcode = (int)FLAGS_GET_RCODE(vq->orig_msg->rep->flags);
 			verbose(VERB_ALGO, "Validating a nxdomain response");
 			validate_nameerror_response(qstate->env, ve,
-				&vq->qchase, vq->chase_reply, vq->key_entry);
+				&vq->qchase, vq->chase_reply, vq->key_entry, &rcode);
 			verbose(VERB_DETAIL, "validate(nxdomain): %s",
 			  	sec_status_to_string(
 				vq->chase_reply->security));
+			FLAGS_SET_RCODE(vq->orig_msg->rep->flags, rcode);
+			FLAGS_SET_RCODE(vq->chase_reply->flags, rcode);
 			break;

 		case VAL_CLASS_CNAME:


auxilary/os: Add DragonFly BSD support in os_get_total_physical_memory.

This patch fixes this build error on DragonFly BSD.

  CC       os/os_misc.lo
os/os_misc.c: In function 'os_get_total_physical_memory':
os/os_misc.c:132:2: error: #error Unsupported *BSD

Signed-off-by: Vinson Lee <25a259f709b0f1b620605d2518271a846d8826e5@freedesktop.org>
Reviewed-by: Brian Paul <3cb4e1df5ec4da2c7c4af7c52cec8cf340a55a10@vmware.com>

--- src/gallium/auxiliary/os/os_misc.c
+++ src/gallium/auxiliary/os/os_misc.c
@@ -128,6 +128,8 @@
    mib[1] = HW_PHYSMEM64;
 #elif defined(PIPE_OS_FREEBSD)
    mib[1] = HW_REALMEM;
+#elif defined(PIPE_OS_DRAGONFLY)
+   mib[1] = HW_PHYSMEM;
 #else
 #error Unsupported *BSD
 #endif


drm: atmel-hlcdc: add support for sama5d4 SoCs

Describe capabilities of the HLCDC IP found on sama5d4 SoCs and add a
new entry to the atmel_hlcdc_of_match table.

Signed-off-by: Boris Brezillon <4e91513d4f418754031d3d36b3fc73980c40a38c@free-electrons.com>

--- drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -241,6 +241,88 @@
 	.layers = atmel_hlcdc_sama5d3_layers,
 };

+static const struct atmel_hlcdc_layer_desc atmel_hlcdc_sama5d4_layers[] = {
+	{
+		.name = "base",
+		.formats = &atmel_hlcdc_plane_rgb_formats,
+		.regs_offset = 0x40,
+		.id = 0,
+		.type = ATMEL_HLCDC_BASE_LAYER,
+		.nconfigs = 7,
+		.layout = {
+			.xstride = { 2 },
+			.default_color = 3,
+			.general_config = 4,
+			.disc_pos = 5,
+			.disc_size = 6,
+		},
+	},
+	{
+		.name = "overlay1",
+		.formats = &atmel_hlcdc_plane_rgb_formats,
+		.regs_offset = 0x140,
+		.id = 1,
+		.type = ATMEL_HLCDC_OVERLAY_LAYER,
+		.nconfigs = 10,
+		.layout = {
+			.pos = 2,
+			.size = 3,
+			.xstride = { 4 },
+			.pstride = { 5 },
+			.default_color = 6,
+			.chroma_key = 7,
+			.chroma_key_mask = 8,
+			.general_config = 9,
+		},
+	},
+	{
+		.name = "overlay2",
+		.formats = &atmel_hlcdc_plane_rgb_formats,
+		.regs_offset = 0x240,
+		.id = 2,
+		.type = ATMEL_HLCDC_OVERLAY_LAYER,
+		.nconfigs = 10,
+		.layout = {
+			.pos = 2,
+			.size = 3,
+			.xstride = { 4 },
+			.pstride = { 5 },
+			.default_color = 6,
+			.chroma_key = 7,
+			.chroma_key_mask = 8,
+			.general_config = 9,
+		},
+	},
+	{
+		.name = "high-end-overlay",
+		.formats = &atmel_hlcdc_plane_rgb_and_yuv_formats,
+		.regs_offset = 0x340,
+		.id = 3,
+		.type = ATMEL_HLCDC_OVERLAY_LAYER,
+		.nconfigs = 42,
+		.layout = {
+			.pos = 2,
+			.size = 3,
+			.memsize = 4,
+			.xstride = { 5, 7 },
+			.pstride = { 6, 8 },
+			.default_color = 9,
+			.chroma_key = 10,
+			.chroma_key_mask = 11,
+			.general_config = 12,
+			.csc = 14,
+		},
+	},
+};
+
+static const struct atmel_hlcdc_dc_desc atmel_hlcdc_dc_sama5d4 = {
+	.min_width = 0,
+	.min_height = 0,
+	.max_width = 2048,
+	.max_height = 2048,
+	.nlayers = ARRAY_SIZE(atmel_hlcdc_sama5d4_layers),
+	.layers = atmel_hlcdc_sama5d4_layers,
+};
 static const struct of_device_id atmel_hlcdc_of_match[] = {
 	{
 		.compatible = "atmel,at91sam9n12-hlcdc",
@@ -253,6 +335,10 @@
 	{
 		.compatible = "atmel,sama5d3-hlcdc",
 		.data = &atmel_hlcdc_dc_sama5d3,
+	},
+	{
+		.compatible = "atmel,sama5d4-hlcdc",
+		.data = &atmel_hlcdc_dc_sama5d4,
 	},
 	{ /* sentinel */ },
 };


util/u_sse: Fix _mm_shuffle_epi8 prototype for clang.

Clang does not support __artificial__. Instead match precisely what's
in the clang headers.

--- src/gallium/auxiliary/util/u_sse.h
+++ src/gallium/auxiliary/util/u_sse.h
@@ -175,7 +175,12 @@
  * MSVC will never get in here as its intrinsics support do not rely on
  * compiler command line options.
  */
-static __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+static __inline __m128i
+#ifdef __clang__
+   __attribute__((__always_inline__, __nodebug__))
+#else
+   __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+#endif
 _mm_shuffle_epi8(__m128i a, __m128i mask)
 {
     __m128i result;


drm/nouveau/core: xtensa firmware size needs to be 0x40000 no matter what

The current logic is wrong since we send fw->size >> 8 to the
card. Rounding the size up by 0x100 and 0x1000 didn't seem to help,
the card still hung, so go back to what the blob does -- 0x40000.

Signed-off-by: Ilia Mirkin <bcbbb7aa705ec3a5fc5824c01a845186c3d62fca@alum.mit.edu>
Signed-off-by: Ben Skeggs <d9f27fb07c1e9f131223ad827fa5179f3846c30b@redhat.com>

--- drivers/gpu/drm/nouveau/core/engine/xtensa.c
+++ drivers/gpu/drm/nouveau/core/engine/xtensa.c
@@ -118,7 +118,13 @@
 			return ret;
 		}

-		ret = nouveau_gpuobj_new(object, NULL, fw->size, 0x1000, 0,
+		if (fw->size > 0x40000) {
+			nv_warn(xtensa, "firmware %s too large\n", name);
+			release_firmware(fw);
+			return -EINVAL;
+		}
+
+		ret = nouveau_gpuobj_new(object, NULL, 0x40000, 0x1000, 0,
 					 &xtensa->gpu_fw);
 		if (ret) {
 			release_firmware(fw);


drm/radeon: fix use after free in ATRM bios reading code.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=45503

Reported-and-Debugged-by: 6d814a338451f193101099b03aa91cc8112f4e26@gmail.com
Signed-off-by: Dave Airlie <f2295d84e358395675bc8031be58672073ae065e@redhat.com>

--- drivers/gpu/drm/radeon/radeon_atpx_handler.c
+++ drivers/gpu/drm/radeon/radeon_atpx_handler.c
@@ -59,8 +59,9 @@

 	obj = (union acpi_object *)buffer.pointer;
 	memcpy(bios+offset, obj->buffer.pointer, obj->buffer.length);
+	len = obj->buffer.length;
 	kfree(buffer.pointer);
-	return obj->buffer.length;
+	return len;
 }

 bool radeon_atrm_supported(struct pci_dev *pdev)


IB/iser: Make needlessly global iser_alloc_rx_descriptors() static

Signed-off-by: Or Gerlitz <de1b678a59344538ef9f2ddb34a5f9486544e2f9@voltaire.com>
Signed-off-by: Roland Dreier <91e9b5f7ca0bb6300133ed378670d64af90dde66@cisco.com>

--- drivers/infiniband/ulp/iser/iser_initiator.c
+++ drivers/infiniband/ulp/iser/iser_initiator.c
@@ -170,7 +170,7 @@
 }

-int iser_alloc_rx_descriptors(struct iser_conn *ib_conn)
+static int iser_alloc_rx_descriptors(struct iser_conn *ib_conn)
 {
 	int i, j;
 	u64 dma_addr;


Revert "[media] rcar_vin: call g_std() instead of querystd()"

As pointed by Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
this patch depends on two adv7180 patches that got rejected.

This reverts commit f00ae754c536511055ed6162778be8348e093514.

Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@osg.samsung.com>

--- drivers/media/platform/soc_camera/rcar_vin.c
+++ drivers/media/platform/soc_camera/rcar_vin.c
@@ -1603,8 +1603,8 @@
 		field = pix->field;
 		break;
 	case V4L2_FIELD_INTERLACED:
-		/* Get the last standard if not explicitly mentioned _TB/_BT */
-		ret = v4l2_subdev_call(sd, video, g_std, &std);
+		/* Query for standard if not explicitly mentioned _TB/_BT */
+		ret = v4l2_subdev_call(sd, video, querystd, &std);
 		if (ret == -ENOIOCTLCMD) {
 			field = V4L2_FIELD_NONE;
 		} else if (ret < 0) {


fm10k: TRIVIAL remove unnecessary comma

fm10k: TRIVIAL remove unnecessary comma

Signed-off-by: Jacob Keller <952d68dd7aa4b84e9f20381084cf63d55ea3c3b1@intel.com>
Tested-by: Krishneil Singh <c59b05ab42618d5787a42c35a821448b52690a31@intel.com>
Signed-off-by: Jeff Kirsher <87e35f5be20bb3e67f4ba6b86f5f6be3085b1b3a@intel.com>

--- drivers/net/ethernet/intel/fm10k/fm10k_mbx.c
+++ drivers/net/ethernet/intel/fm10k/fm10k_mbx.c
@@ -129,8 +129,8 @@
  *  fm10k_fifo_drop_all - Drop all messages in FIFO
  *  @fifo: pointer to FIFO
  *
- *  This function resets the head pointer to drop all messages in the FIFO,
- *  and ensure the FIFO is empty.
+ *  This function resets the head pointer to drop all messages in the FIFO and
+ *  ensure the FIFO is empty.
  **/
 static void fm10k_fifo_drop_all(struct fm10k_mbx_fifo *fifo)
 {


Preliminary pass at straightening out VRAM loads

--- src/gba/renderers/video-software.c
+++ src/gba/renderers/video-software.c
@@ -811,7 +811,7 @@
 		xBase += (localX & 0x100) << 5; \
 	} \
 	screenBase = yBase + (xBase >> 3); \
-	mapData = vram[screenBase]; \
+	LOAD_16(mapData, screenBase << 1, vram); \
 	localY = inY & 0x7; \
 	if (GBA_TEXT_MAP_VFLIP(mapData)) { \
 		localY = 7 - localY; \
@@ -852,7 +852,7 @@
 	paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \
 	palette = &mainPalette[paletteData]; \
 	charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 5)) >> 2) + localY; \
-	tileData = ((uint32_t*) vram)[charBase]; \
+	LOAD_32(tileData, charBase << 2, vram); \
 	if (!GBA_TEXT_MAP_HFLIP(mapData)) { \
 		tileData >>= 4 * mod8; \
 		for (; outX < end; ++outX) { \
@@ -868,7 +868,7 @@

 #define DRAW_BACKGROUND_MODE_0_TILE_PREFIX_16(BLEND, OBJWIN) \
 	charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 5)) >> 2) + localY; \
-	tileData = ((uint32_t*) vram)[charBase]; \
+	LOAD_32(tileData, charBase << 2, vram); \
 	paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \
 	palette = &mainPalette[paletteData]; \
 	if (!GBA_TEXT_MAP_HFLIP(mapData)) { \
@@ -902,7 +902,7 @@
 			if (!mosaicWait) { \
 				paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \
 				palette = &mainPalette[paletteData]; \
-				tileData = ((uint32_t*) vram)[charBase]; \
+				LOAD_32(tileData, charBase << 2, vram); \
 				if (!GBA_TEXT_MAP_HFLIP(mapData)) { \
 					tileData >>= x * 4; \
 				} else { \
@@ -931,7 +931,7 @@
 		paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \
 		palette = &mainPalette[paletteData]; \
 		charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 5)) >> 2) + localY; \
-		tileData = ((uint32_t*) vram)[charBase]; \
+		LOAD_32(tileData, charBase << 2, vram); \
 		if (tileData) { \
 			if (!GBA_TEXT_MAP_HFLIP(mapData)) { \
 				BACKGROUND_DRAW_PIXEL_16(BLEND, OBJWIN); \
@@ -980,7 +980,7 @@
 	if (!GBA_TEXT_MAP_HFLIP(mapData)) { \
 		int shift = inX & 0x3; \
 		if (end2 > outX) { \
-			tileData = ((uint32_t*) vram)[charBase]; \
+			LOAD_32(tileData, charBase << 2, vram); \
 			tileData >>= 8 * shift; \
 			shift = 0; \
 			for (; outX < end2; ++outX) { \
@@ -989,7 +989,7 @@
 			} \
 		} \
 		\
-		tileData = ((uint32_t*) vram)[charBase + 1]; \
+		LOAD_32(tileData, (charBase + 1) << 2, vram); \
 		tileData >>= 8 * shift; \
 		for (; outX < end; ++outX) { \
 			pixel = &renderer->row[outX]; \
@@ -999,7 +999,7 @@
 		int start = outX; \
 		outX = end - 1; \
 		if (end2 > start) { \
-			tileData = ((uint32_t*) vram)[charBase]; \
+			LOAD_32(tileData, charBase << 2, vram); \
 			for (; outX >= end2; --outX) { \
 				pixel = &renderer->row[outX]; \
 				BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
@@ -1007,7 +1007,7 @@
 			++charBase; \
 		} \
 		\
-		tileData = ((uint32_t*) vram)[charBase]; \
+		LOAD_32(tileData, charBase << 2, vram); \
 		for (; outX >= renderer->start; --outX) { \
 			pixel = &renderer->row[outX]; \
 			BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
@@ -1021,7 +1021,7 @@
 	int end2 = 4 - end; \
 	if (!GBA_TEXT_MAP_HFLIP(mapData)) { \
 		if (end2 > 0) { \
-			tileData = ((uint32_t*) vram)[charBase]; \
+			LOAD_32(tileData, charBase << 2, vram); \
 			for (; outX < renderer->end - end2; ++outX) { \
 				pixel = &renderer->row[outX]; \
 				BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
@@ -1029,7 +1029,7 @@
 			++charBase; \
 		} \
 		\
-		tileData = ((uint32_t*) vram)[charBase]; \
+		LOAD_32(tileData, charBase << 2, vram); \
 		for (; outX < renderer->end; ++outX) { \
 			pixel = &renderer->row[outX]; \
 			BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
@@ -1039,7 +1039,7 @@
 		int start = outX; \
 		outX = renderer->end - 1; \
 		if (end2 > 0) { \
-			tileData = ((uint32_t*) vram)[charBase]; \
+			LOAD_32(tileData, charBase << 2, vram); \
 			tileData >>= 8 * shift; \
 			for (; outX >= start + 4; --outX) { \
 				pixel = &renderer->row[outX]; \
@@ -1048,7 +1048,7 @@
 			shift = 0; \
 		} \
 		\
-		tileData = ((uint32_t*) vram)[charBase + 1]; \
+		LOAD_32(tileData, (charBase + 1) << 2, vram); \
 		tileData >>= 8 * shift; \
 		for (; outX >= start; --outX) { \
 			pixel = &renderer->row[outX]; \
@@ -1061,7 +1061,7 @@
 		BACKGROUND_TEXT_SELECT_CHARACTER; \
 		charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) >> 2) + (localY << 1); \
 		if (!GBA_TEXT_MAP_HFLIP(mapData)) { \
-			tileData = ((uint32_t*) vram)[charBase]; \
+			LOAD_32(tileData, charBase << 2, vram); \
 			if (tileData) { \
 					BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
 					++pixel; \
@@ -1074,7 +1074,7 @@
 			} else { \
 				pixel += 4; \
 			} \
-			tileData = ((uint32_t*) vram)[charBase + 1]; \
+			LOAD_32(tileData, (charBase + 1) << 2, vram); \
 			if (tileData) { \
 					BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
 					++pixel; \
@@ -1088,7 +1088,7 @@
 				pixel += 4; \
 			} \
 		} else { \
-			uint32_t tileData = ((uint32_t*) vram)[charBase + 1]; \
+			LOAD_32(tileData, (charBase + 1) << 2, vram); \
 			if (tileData) { \
 				pixel += 3; \
 				BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
@@ -1100,7 +1100,7 @@
 				BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
 			} \
 			pixel += 4; \
-			tileData = ((uint32_t*) vram)[charBase]; \
+			LOAD_32(tileData, charBase << 2, vram); \
 			if (tileData) { \
 				pixel += 3; \
 				BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
@@ -1124,18 +1124,18 @@
 			if (!mosaicWait) { \
 				if (!GBA_TEXT_MAP_HFLIP(mapData)) { \
 					if (x >= 4) { \
-						tileData = ((uint32_t*) vram)[charBase + 1]; \
+						LOAD_32(tileData, (charBase + 1) << 2, vram); \
 						tileData >>= (x - 4) * 8; \
 					} else { \
-						tileData = ((uint32_t*) vram)[charBase]; \
+						LOAD_32(tileData, charBase << 2, vram); \
 						tileData >>= x * 8; \
 					} \
 				} else { \
 					if (x >= 4) { \
-						tileData = ((uint32_t*) vram)[charBase]; \
+						LOAD_32(tileData, charBase << 2, vram); \
 						tileData >>= (7 - x) * 8; \
 					} else { \
-						tileData = ((uint32_t*) vram)[charBase + 1]; \
+						LOAD_32(tileData, (charBase + 1) << 2, vram); \
 						tileData >>= (3 - x) * 8; \
 					} \
 				} \
@@ -1348,7 +1348,7 @@
 	for (outX = renderer->start, pixel = &renderer->row[outX]; outX < renderer->end; ++outX, ++pixel) {
 		BACKGROUND_BITMAP_ITERATE(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS);

-		color = ((uint16_t*)renderer->d.vram)[(localX >> 8) + (localY >> 8) * VIDEO_HORIZONTAL_PIXELS];
+		LOAD_16(color, (localX >> 8) + (localY >> 8) * VIDEO_HORIZONTAL_PIXELS << 1, renderer->d.vram);
 #ifndef COLOR_16_BIT
 		unsigned color32;
 		color32 = 0;
@@ -1413,7 +1413,7 @@
 	for (outX = renderer->start, pixel = &renderer->row[outX]; outX < renderer->end; ++outX, ++pixel) {
 		BACKGROUND_BITMAP_ITERATE(160, 128);

-		color = ((uint16_t*)renderer->d.vram)[offset + (localX >> 8) + (localY >> 8) * 160];
+		LOAD_16(color, offset + (localX >> 8) + (localY >> 8) * 320, renderer->d.vram);
 #ifndef COLOR_16_BIT
 		unsigned color32 = 0;
 		color32 |= (color << 9) & 0xF80000;


igb: fix i350 anti spoofing config

igb: fix i350 anti spoofing config

Fix a problem in i350 where anti spoofing configuration was written into a
wrong register.

Signed-off-by: Lior Levy <75c9dff3090593e43d839b233a406b7d215edc21@intel.com>
Tested-by: Aaron Brown <4723df1d9a4136f7b76e1bf6434e33afc91d2139@intel.com>
Signed-off-by: Jeff Kirsher <87e35f5be20bb3e67f4ba6b86f5f6be3085b1b3a@intel.com>

--- drivers/net/ethernet/intel/igb/e1000_82575.c
+++ drivers/net/ethernet/intel/igb/e1000_82575.c
@@ -1818,27 +1818,32 @@
  **/
 void igb_vmdq_set_anti_spoofing_pf(struct e1000_hw *hw, bool enable, int pf)
 {
-	u32 dtxswc;
+	u32 reg_val, reg_offset;

 	switch (hw->mac.type) {
 	case e1000_82576:
+		reg_offset = E1000_DTXSWC;
+		break;
 	case e1000_i350:
-		dtxswc = rd32(E1000_DTXSWC);
-		if (enable) {
-			dtxswc |= (E1000_DTXSWC_MAC_SPOOF_MASK |
-				   E1000_DTXSWC_VLAN_SPOOF_MASK);
-			/* The PF can spoof - it has to in order to
-			 * support emulation mode NICs */
-			dtxswc ^= (1 << pf | 1 << (pf + MAX_NUM_VFS));
-		} else {
-			dtxswc &= ~(E1000_DTXSWC_MAC_SPOOF_MASK |
-				    E1000_DTXSWC_VLAN_SPOOF_MASK);
-		}
-		wr32(E1000_DTXSWC, dtxswc);
+		reg_offset = E1000_TXSWC;
 		break;
 	default:
-		break;
-	}
+		return;
+	}
+
+	reg_val = rd32(reg_offset);
+	if (enable) {
+		reg_val |= (E1000_DTXSWC_MAC_SPOOF_MASK |
+			     E1000_DTXSWC_VLAN_SPOOF_MASK);
+		/* The PF can spoof - it has to in order to
+		 * support emulation mode NICs
+		 */
+		reg_val ^= (1 << pf | 1 << (pf + MAX_NUM_VFS));
+	} else {
+		reg_val &= ~(E1000_DTXSWC_MAC_SPOOF_MASK |
+			     E1000_DTXSWC_VLAN_SPOOF_MASK);
+	}
+	wr32(reg_offset, reg_val);
 }

 /**


Remove xxl &operator=(const xxl &x);

Remove xxl &operator=(const xxl &x);

--- Source/MediaInfo/Video/File_Hevc.h
+++ Source/MediaInfo/Video/File_Hevc.h
@@ -112,15 +112,8 @@
                     SchedSel(SchedSel_)
                 {
                 }
-
-                xxl &operator=(const xxl &x)
-                {
-                    SchedSel = x.SchedSel;
-
-                    return *this;
-                }
-
             private:
+                xxl &operator=(const xxl &x);
                 xxl();
             };
             struct xxl_common


hash table AND simple space

hash table AND simple space

git-svn-id: 83d585846b3bb6dc23aa7649400c5e2e04e3d09e@195 685f7672-210f-0410-90b4-fe3ad19314fe

--- ode/include/ode/space.h
+++ ode/include/ode/space.h
@@ -31,6 +31,8 @@

 struct dContactGeom;

+typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2);
+

 /* extra information the space needs in every geometry object */

@@ -39,14 +41,15 @@
 } dGeomSpaceData;

-dSpaceID dSpaceCreate();
+dSpaceID dSimpleSpaceCreate();
+dSpaceID dHashSpaceCreate();
+
 void dSpaceDestroy (dSpaceID);
-
 void dSpaceAdd (dSpaceID, dGeomID);
 void dSpaceRemove (dSpaceID, dGeomID);
+void dSpaceCollide (dSpaceID space, void *data, dNearCallback *callback);

-typedef void dNearCallback (void *data, dGeomID o1, dGeomID o2);
-void dSpaceCollide (dSpaceID space, void *data, dNearCallback *callback);
+void dHashSpaceSetLevels (dSpaceID space, int minlevel, int maxlevel);

 /* @@@ NOT FLEXIBLE ENOUGH