Simplify and fix usage of three string array variable...

 using two separated local variables.

buf[1] was unused.

Reviewed-by: Richard Levitte <5fb523282dd7956571c80524edc2dccfa0bd8234@openssl.org>
Reviewed-by: Rich Salz <c04971a99e5a9ee80eaab4b1deb37e845b0bd697@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1569)

--- apps/ca.c
+++ apps/ca.c
@@ -246,7 +246,8 @@
     const char *serialfile = NULL, *subj = NULL;
     char *prog, *startdate = NULL, *enddate = NULL;
     char *dbfile = NULL, *f, *randfile = NULL;
-    char buf[3][BSIZE];
+    char new_cert[BSIZE] = { 0 };
+    char tmp[10 + 1] = "\0";
     char *const *pp;
     const char *p;
     int create_ser = 0, free_key = 0, total = 0, total_done = 0;
@@ -950,14 +951,14 @@
                            "\n%d out of %d certificate requests certified, commit? [y/n]",
                            total_done, total);
                 (void)BIO_flush(bio_err);
-                buf[0][0] = '\0';
-                if (!fgets(buf[0], 10, stdin)) {
+                tmp[0] = '\0';
+                if (fgets(tmp, sizeof(tmp), stdin) == NULL) {
                     BIO_printf(bio_err,
                                "CERTIFICATION CANCELED: I/O error\n");
                     ret = 0;
                     goto end;
                 }
-                if ((buf[0][0] != 'y') && (buf[0][0] != 'Y')) {
+                if (tmp[0] != 'y' && tmp[0] != 'Y') {
                     BIO_printf(bio_err, "CERTIFICATION CANCELED\n");
                     ret = 0;
                     goto end;
@@ -992,19 +993,18 @@
                 goto end;
             }

-            strcpy(buf[2], outdir);
-
+            strcpy(new_cert, outdir);
 #ifndef OPENSSL_SYS_VMS
-            OPENSSL_strlcat(buf[2], "/", sizeof(buf[2]));
+            OPENSSL_strlcat(new_cert, "/", sizeof(new_cert));
 #endif

-            n = (char *)&(buf[2][strlen(buf[2])]);
+            n = (char *)&(new_cert[strlen(new_cert)]);
             if (j > 0) {
                 for (k = 0; k < j; k++) {
-                    if (n >= &(buf[2][sizeof(buf[2])]))
+                    if (n >= &(new_cert[sizeof(new_cert)]))
                         break;
                     BIO_snprintf(n,
-                                 &buf[2][0] + sizeof(buf[2]) - n,
+                                 &new_cert[0] + sizeof(new_cert) - n,
                                  "%02X", (unsigned char)*(p++));
                     n += 2;
                 }
@@ -1018,11 +1018,11 @@
             *(n++) = 'm';
             *n = '\0';
             if (verbose)
-                BIO_printf(bio_err, "writing %s\n", buf[2]);
-
-            Cout = BIO_new_file(buf[2], "w");
+                BIO_printf(bio_err, "writing %s\n", new_cert);
+
+            Cout = BIO_new_file(new_cert, "w");
             if (Cout == NULL) {
-                perror(buf[2]);
+                perror(new_cert);
                 goto end;
             }
             write_new_certificate(Cout, x, 0, notext);
@@ -1796,13 +1796,13 @@
         BIO_printf(bio_err, "Sign the certificate? [y/n]:");
         (void)BIO_flush(bio_err);
         buf[0] = '\0';
-        if (!fgets(buf, sizeof(buf) - 1, stdin)) {
+        if (fgets(buf, sizeof(buf), stdin) == NULL) {
             BIO_printf(bio_err,
                        "CERTIFICATE WILL NOT BE CERTIFIED: I/O error\n");
             ok = 0;
             goto end;
         }
-        if (!((buf[0] == 'y') || (buf[0] == 'Y'))) {
+        if (!(buf[0] == 'y' || buf[0] == 'Y')) {
             BIO_printf(bio_err, "CERTIFICATE WILL NOT BE CERTIFIED\n");
             ok = 0;
             goto end;


hash: check for NULL label in hash_get().

The label parameter was being used without checking if it was NULL.
This could be a problem, so this patch adds a check for NULL.

--- as/hash.c
+++ as/hash.c
@@ -75,7 +75,7 @@
 	size_t labellen;
 	hash_entry_t *entry;

-	if (h == NULL) {
+	if (h == NULL || label == NULL) {
 		return -1;
 	}


Slight alteration of deadzone

Slight alteration of deadzone

--- atmelrc.h
+++ atmelrc.h
@@ -18,11 +18,11 @@
 		#define INTERNALOSCILLATORCALIBRATION 0b01011000
 		#define TIMERESOLUTION (uint8_t) 4 //µs per tic. 4µs is maximum resolution, and the standard setting.

-	//Deadzone on both high and low ends. 15 is ~5% of 255.
-	#define PWMDEADZONE (uint8_t) 15
+	//Deadzone on both high and low ends. 15 is ~10% of 255.
+	#define PWMDEADZONE (uint8_t) 25

-	//Memory addresses of stored calibration. Randomly spaced #YOLO
+	//Memory addresses of stored calibration. "Randomly" spaced #YOLO
 	#define AMAX (uint16_t*) 0x00
 	#define AMIN (uint16_t*) 0x04
 	#define BMAX (uint16_t*) 0x08


SO 2013 - falta só o BSS

SO 2013 - falta só o BSS

--- 2013/mac0422/dmp_kernel.c
+++ 2013/mac0422/dmp_kernel.c
@@ -495,15 +495,17 @@
 							"\t%d"
 							"\t%d"
 							"\t%d"
+							"\t%d"
 							"\t"
-							"\t"
-							"\t"
+							"\t%d"
 							"\t%s",
 							(int)mproc[i - NR_TASKS].mp_pid,
 							(int)proc[i].p_user_time,
 							(int)proc[i].p_sys_time,
 							mproc[i - NR_TASKS].mp_child_stime,
 							(int)proc[i].p_memmap[S].mem_phys,
+							(int)proc[i].p_memmap[D].mem_phys,
+							(int)proc[i].p_memmap[T].mem_phys,

 							/* proc[i].p_memmap, */

@@ -535,8 +537,8 @@
 					printf("%03d\t\t-\t%d\t\t\t\t\t%s\n", mproc[i].mp_pid, mproc[i].mp_child_stime, mproc[i].mp_name);
 				else
 					printf("%03d\t\t%d\t%d\t\t\t\t\t%s\n", mproc[i].mp_pid, proc[k].p_sys_time, mproc[i].mp_child_stime, mproc[i].mp_name);
+			}
 				*/
-			}
 			/* Se ultrapassou a página atual precisa trocar de página e parar o laço. */
 			else if ( j/LINES > pg ) {
 				pg++;


Update task 1

Update task 1


Update task2.c

Update task2.c


leetcode35th

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

--- 35.SearchInsertPosition.c
+++ 35.SearchInsertPosition.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+
+int main()
+{
+    int a[] = {1,3,5,6};
+    printf("%d",searchInsert(a,4,7));
+    return 0;
+}
+int searchInsert(int* nums, int numsSize, int target) {
+
+    for(int i = 0; i < numsSize; i++) {
+        if (target <= nums[0]) {
+            return 0;
+        } else if(nums[i] == target) {
+            return i;
+        } else if (nums[i] < target && nums[i+1] > target) {
+            return i + 1;
+        }
+    }
+    return numsSize;
+}


Add configurable speed to Animation constructor

--- 3RVX/MeterWnd/Animation.h
+++ 3RVX/MeterWnd/Animation.h
@@ -4,6 +4,16 @@

 class Animation {
 public:
+    Animation(int speed) :
+        _speed(speed) {
+
+    }
+
     virtual bool Animate(MeterWnd *meterWnd) = 0;
     virtual void Reset(MeterWnd *meterWnd) = 0;
+
+    virtual int UpdateInterval() = 0;
+
+protected:
+    int _speed;
 };


important reset in chip_play

important reset in chip_play

--- palette16tile/chiptune.c
+++ palette16tile/chiptune.c
@@ -316,6 +316,7 @@
     {
         track_length = 32;
         song_speed = 4;
+        song_transpose = 0;
     }

     song_wait = 0;


just in case _RANDOM_H is already defined in some system lib

--- parcels/include/random.h
+++ parcels/include/random.h
@@ -1,5 +1,5 @@
-#ifndef _RANDOM_H
-#define _RANDOM_H
+#ifndef _PARCELS_RANDOM_H
+#define _PARCELS_RANDOM_H
 #ifdef __cplusplus
 extern "C" {
 #endif


parser/tests: Add parse_value_validate_max_size_plus_one test

--- parser/tests/run_tests.c
+++ parser/tests/run_tests.c
@@ -623,6 +623,23 @@
         ck_assert_int_eq(rc, knd_OK);
         ck_assert_uint_eq(total_size, strlen(rec));
         ck_assert_int_eq(user.email_type, EMAIL_WORK); ck_assert_uint_eq(user.email_size, KND_SHORT_NAME_SIZE); ck_assert(!memcmp(user.email, strchr(buf, 'b'), user.email_size));
+    }
+END_TEST
+
+START_TEST(parse_value_validate_max_size_plus_one)
+    DEFINE_TaskSpecs(parse_user_args, gen_email_spec(&user));
+    struct kndTaskSpec specs[] = { gen_user_spec(&parse_user_args) };
+
+    {
+        const char buf[] = { '{', 'u', 's', 'e', 'r', ' ', '{', 'e', 'm', 'a', 'i', 'l', '{', 'h', 'o', 'm', 'e', ' ', [18 ... KND_SHORT_NAME_SIZE + 18] = 'b', '}', '}', '}', '\0' };
+        rc = knd_parse_task(rec = buf, &total_size, specs, sizeof specs / sizeof specs[0]);
+        ck_assert_int_eq(rc, knd_LIMIT);  // defined in run_set_email()
+    }
+
+    {
+        const char buf[] = { '{', 'u', 's', 'e', 'r', ' ', '{', 'e', 'm', 'a', 'i', 'l', ' ', '{', 'w', 'o', 'r', 'k', ' ', [19 ... KND_SHORT_NAME_SIZE + 19] = 'b', '}', '}', '}', '\0' };
+        rc = knd_parse_task(rec = buf, &total_size, specs, sizeof specs / sizeof specs[0]);
+        ck_assert_int_eq(rc, knd_LIMIT);  // defined in run_set_email()
     }
 END_TEST

@@ -651,6 +668,7 @@
     tcase_add_test(tc, parse_value_validate_single);
     tcase_add_test(tc, parse_value_validate_several);
     tcase_add_test(tc, parse_value_validate_max_size);
+    tcase_add_test(tc, parse_value_validate_max_size_plus_one);

     Suite* s = suite_create("suite");
     suite_add_tcase(s, tc);


Removed unused function to make clang happy

--- parsing/numeric_parser.c
+++ parsing/numeric_parser.c
@@ -51,9 +51,9 @@
     return c == 'i' || c == 'I';
 }

-static inline int issci(char c){
-    return c == 'E';
-}
+//static inline int issci(char c){
+//    return c == 'E';
+//}

 static inline int isnull(char c){


void prototype

void prototype

--- autonet.c
+++ autonet.c
@@ -49,7 +49,7 @@

 static void
-usage()
+usage(void)
 {
 	fprintf(stderr,
 	        "usage: %s [-v] [[-x excluded_profile] [-x ...] ...]\n"


Add direct GPIO control

Add direct GPIO control

Sometimes it is useful to control the CBUS pins directly. Add a 'gpio'
command for directly setting the GPIO. Unfortunately, I do not know how
to read from the FTDI chip if a pin is set as input or output, so
setting a single GPIO will reset all the others back to being inputs.

Signed-off-by: Grant Likely <9069e6f5a2b566e2674a0ba1e2bf39c12c195fad@linaro.org>

--- 96boardsctl/96boardsctl.c
+++ 96boardsctl/96boardsctl.c
@@ -93,7 +93,8 @@

 int main(int argc, char *argv[])
 {
-	char *cmd = NULL, *serialnum = NULL;
+	char *cmd[3], *serialnum = NULL;
+	int count = 0;
 	int rc;
 	char c;

@@ -104,7 +105,11 @@
 	while ((c = getopt_long(argc, argv, optstring, long_options, NULL)) >= 0) {
 		switch (c) {
 		case 1:
-			cmd = optarg;
+			if (count >= 3) {
+				usage();
+				exit(EXIT_FAILURE);
+			}
+			cmd[count++] = optarg;
 			break;
 		case 'h':
 			usage();
@@ -132,7 +137,7 @@
 		}
 	}

-	if (!cmd) {
+	if (!count) {
 		usage();
 		exit(EXIT_FAILURE);
 	}
@@ -150,14 +155,30 @@
 		exit(EXIT_FAILURE);
 	}

-	if (strcmp(cmd, "reset") == 0) {
+	if (count == 1 && strcmp(cmd[0], "reset") == 0) {
 		printf("Pressing reset\n");
 		pulse_cbus(reset_pin, pulse_ms * 1000);
-	} else if (strcmp(cmd, "power") == 0) {
+	} else if (count == 1 && strcmp(cmd[0], "power") == 0) {
 		printf("Pressing power\n");
 		pulse_cbus(power_pin, pulse_ms * 1000);
+	} else if (count == 3 && strcmp(cmd[0], "gpio") == 0) {
+		unsigned int pin = strtoul(cmd[1], NULL, 0);
+		if (pin > 3) {
+			fprintf(stderr, "Unknown pin '%s'\n", cmd[1]);
+			usage();
+		}
+		if (strcmp(cmd[2], "high") == 0) {
+			printf("Setting CBUS%i high\n", pin);
+			set_cbus(pin, 1, 1);
+		} else if (strcmp(cmd[2], "low") == 0) {
+			printf("Setting CBUS%i low\n", pin);
+			set_cbus(pin, 1, 0);
+		} else {
+			printf("Setting CBUS%i as input\n", pin);
+			set_cbus(pin, 0, 0);
+		}
 	} else {
-		fprintf(stderr, "Unknown command '%s'\n", cmd);
+		fprintf(stderr, "Unknown command '%s'\n", cmd[0]);
 		usage();
 		exit(EXIT_FAILURE);
 	}


Project updates

Project updates

--- ABFramework/ABFramework.h
+++ ABFramework/ABFramework.h
@@ -8,7 +8,7 @@
 #import <Availability.h>

 #define ABFRAMEWORK_VERSION 0.1.0
-#define ABFRAMEWORK_LAST_EDIT @"22.05.2013 - 12:20"
+#define ABFRAMEWORK_LAST_EDIT @"26.05.2013 - 11:45"

 #ifndef ABFRAMEWORK_LOGGING
 #define ABFRAMEWORK_LOGGING 1


[percolation] Fix documentation typo

[percolation] Fix documentation typo

--- percolation/io_helpers.h
+++ percolation/io_helpers.h
@@ -100,7 +100,7 @@
     @param rows the number of rows in the lattice.
     @param columns the number of columns in the lattice.
     @param probability the probability used to populate the lattice.
-    @param seed the random number generator seed used at the begging of the
+    @param seed the random number generator seed used at the beginning of the
         probability sweep.
     @param realizations the number of different lattice realizations that were
         taken to aggregate the cluster statistics.


Fix crash in v8 function without arguments (if exception)

--- DesktopEditor/doctrenderer/js_internal/v8/v8_base.h
+++ DesktopEditor/doctrenderer/js_internal/v8/v8_base.h
@@ -410,7 +410,9 @@

                 if (0 == argc)
                 {
-                    _return->value = _funcN->Call(V8ContextFirstArg value, 0, NULL).ToLocalChecked();
+                    v8::MaybeLocal<v8::Value> retValue = _funcN->Call(V8ContextFirstArg value, 0, NULL);
+                    if (!retValue.IsEmpty())
+                        _return->value = retValue.ToLocalChecked();
                 }
                 else
                 {


core: added RIOT's own assert macro

core: added RIOT's own assert macro

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

--- core/include/assert.h
+++ core/include/assert.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2015 INRIA
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License v2.1. See the file LICENSE in the top level
+ * directory for more details.
+ */
+
+/**
+ * @addtogroup  core_util
+ *
+ * @{
+ * @file
+ * @brief       POSIX.1-2008 compliant version of the assert macro
+ *
+ * @author      Oliver Hahm <oliver.hahm@inria.fr>
+ */
+
+#ifndef ASSERT_H
+#define ASSERT_H
+
+#include "panic.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief    abort the program if assertion is false
+ *
+ * If the macro NDEBUG was defined at the moment <assert.h> was last included,
+ * the macro assert() generates no code, and hence does nothing at all.
+ *
+ * Otherwise, the macro assert() prints an error message to standard error and
+ * terminates the application by calling core_panic().
+ *
+ * The purpose of this macro is to help programmers find bugs in their
+ * programs.
+ */
+
+#ifdef NDEBUG
+#define assert(ignore)((void) 0)
+#else
+#define assert(cond) ((cond) ? (void)0 : core_panic(PANIC_ASSERT_FAIL, "assert"))
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ASSERT_H */
+/** @} */


Include vjConfig.h before anything else.  Eventually this will be helpful
when compiling on Win32.

git-svn-id: 769d22dfa2d22aad706b9a451492fb87c0735f19@1356 08b38cba-cd3b-11de-854e-f91c5b6e4272

--- modules/vrjuggler/test/Draw/OGL/simpleGlove/simpleGloveApp.h
+++ modules/vrjuggler/test/Draw/OGL/simpleGlove/simpleGloveApp.h
@@ -1,5 +1,7 @@
 #ifndef _WAND_APP_
 #define _WAND_APP_
+
+#include <vjConfig.h>

 #include <math.h>
 #include <GL/gl.h>


Ubuntu doesn't sleep on the select() and drives %CPU to 100, so back to sleep() for now.

--- uptop/main.c
+++ uptop/main.c
@@ -27,6 +27,10 @@
     int    rc;
     int    ch;
     struct timeval timeout = { 0, 100 };
+    /*
+      const struct timespec request = { 0, 1000000 };
+      struct timespec remain;
+    */

     options_parse( argc, argv );

@@ -53,7 +57,9 @@

     while(1) {
 	/* use select for sleeping 100ms */
-	select( 0, NULL, NULL, NULL, &timeout );
+        sleep(1);
+        /* select( 0, NULL, NULL, NULL, &timeout ); */
+        /* clock_nanosleep( 0, 0, &request, &remain ); */

 	ch = getch();
 	if( ch != ERR ) {


NO MORE CLEANUP

NO MORE CLEANUP

--- src/ngx_http_zmq_module.c
+++ src/ngx_http_zmq_module.c
@@ -206,9 +206,7 @@
       r->headers_out.status = NGX_HTTP_GATEWAY_TIME_OUT;
       r->header_only = 1;
       r->headers_out.content_length_n = 0;
-      free_conn(&con);
-      ngx_http_send_header(r);
-      return ngx_http_output_filter(r, &out);;
+      return ngx_http_send_header(r);
     }
     mlen = zmq_msg_size(&msg);
     string = ngx_pcalloc(r->pool, mlen+1);


STYLE: Remove misleading documentation. http://public.kitware.com/pipermail/insight-users/2007-December/024516.html

--- Code/Common/itkCenteredAffineTransform.h
+++ Code/Common/itkCenteredAffineTransform.h
@@ -29,13 +29,8 @@
  *
  * This class implements an Affine transform in which the rotation center
  * can be explicitly selected.
- * Note that the method "ComputeOffset()" must be called just before using
- * the transform for mapping points, vectors or covariantvectors.
- * This is necessary for updating the offset of the transform taking into
- * account the center of rotation.
  *
  * \ingroup Transforms
- *
  */
 template <
  class TScalarType=double,         // Data type for scalars


Fixed a documentation error in KCAstronomicalCalendar.

--- KosherCocoa/Library/Core/Solar/KCAstronomicalCalendar.h
+++ KosherCocoa/Library/Core/Solar/KCAstronomicalCalendar.h
@@ -342,7 +342,7 @@
  *  calendar.
  *
  *  @param date The date to display.
- *  @param tz The time zone to format against.
+ *  @param timezone The time zone to format against.
  *
  *  @return A string representation of the supplied date in the supplied time zone.
  */


[sift] coding style

[sift] coding style

--- c/sift/sift_anatomy_20141201/lib_sift_anatomy.c
+++ c/sift/sift_anatomy_20141201/lib_sift_anatomy.c
@@ -917,22 +917,19 @@
 }

-
-
-void sift_anatomy_only_description(const float* x, int w, int h, const struct sift_parameters* p,
-                                    struct sift_keypoints* k)
-{
-    // The number of octaves.
+void sift_anatomy_only_description(const float* x, int w, int h,
+                                   const struct sift_parameters* p,
+                                   struct sift_keypoints* k)
+{
     int n_oct = number_of_octaves(w, h, p);

-    // MEMORY ALLOCATION
-    struct sift_scalespace* s   = sift_malloc_scalespace_lowe(n_oct,p->n_spo,w,h,p->delta_min,p->sigma_min);
+    struct sift_scalespace* s   = sift_malloc_scalespace_lowe(n_oct, p->n_spo, w, h, p->delta_min, p->sigma_min);
     struct sift_scalespace* sx  = sift_malloc_scalespace_from_model(s);
     struct sift_scalespace* sy  = sift_malloc_scalespace_from_model(s);

-    scalespace_compute(s, x, w, h, p->sigma_in);  /* Builds Lowe's scale-space */
-    scalespace_compute_gradient(s,sx,sy); /* Pre-computes gradient scale-space */
-    keypoints_attribute_descriptors(sx, sy, k, p->n_hist,p->n_ori,p->lambda_descr);
+    scalespace_compute(s, x, w, h, p->sigma_in); // build Lowe's scale-space
+    scalespace_compute_gradient(s, sx, sy); // pre-compute gradient scale-space
+    keypoints_attribute_descriptors(sx, sy, k, p->n_hist, p->n_ori, p->lambda_descr);

     sift_free_scalespace(s);
     sift_free_scalespace(sx);
@@ -940,25 +937,20 @@
 }

-
-void sift_anatomy_orientation_and_description(const float* x,
-                                              int w,
-                                              int h,
+void sift_anatomy_orientation_and_description(const float* x, int w, int h,
                                               const struct sift_parameters* p,
                                               struct sift_keypoints* k)
 {
-    // The number of octaves.
     int n_oct = number_of_octaves(w, h, p);

-    // MEMORY ALLOCATION
-    struct sift_scalespace* s   = sift_malloc_scalespace_lowe(n_oct,p->n_spo,w,h,p->delta_min,p->sigma_min);
+    struct sift_scalespace* s   = sift_malloc_scalespace_lowe(n_oct, p->n_spo, w, h, p->delta_min, p->sigma_min);
     struct sift_scalespace* sx  = sift_malloc_scalespace_from_model(s);
     struct sift_scalespace* sy  = sift_malloc_scalespace_from_model(s);
-    scalespace_compute(s, x, w, h, p->sigma_in);  // Builds Lowe's scale-space
-    scalespace_compute_gradient(s,sx,sy); // Pre-computes gradient scale-space
-
+
+    scalespace_compute(s, x, w, h, p->sigma_in);  // build Lowe's scale-space
+    scalespace_compute_gradient(s, sx, sy); // pre-compute gradient scale-space
     keypoints_attribute_one_orientation(sx, sy, k, p->n_bins, p->lambda_ori);
-    keypoints_attribute_descriptors(sx, sy, k, p->n_hist,p->n_ori,p->lambda_descr);
+    keypoints_attribute_descriptors(sx, sy, k, p->n_hist, p->n_ori, p->lambda_descr);

     sift_free_scalespace(s);
     sift_free_scalespace(sx);


possible need to convert prio storage to int for proper address in flash

--- canbus-firewall-avr/src/rules.c
+++ canbus-firewall-avr/src/rules.c
@@ -688,7 +688,7 @@
         {
             store_new_sequence_number(rules_in_progress.working_sets[working_set_index]);
             rule_t rule_to_save = create_rule_from_working_set(rules_in_progress.working_sets[working_set_index]);
-            success = save_rule_to_flash(&rule_to_save, &flash_can_ruleset[rule_to_save.prio]);
+            success = save_rule_to_flash(&rule_to_save, &flash_can_ruleset[(int)rule_to_save.prio]);

         }


fixed Typo in MdePkg.

fixed Typo in MdePkg.

git-svn-id: 5648d1bec6962b0a6d1d1b40eba8cf5cdb62da3d@3599 6f19259b-4bc3-4df7-8a09-765794883524

--- MdePkg/Include/IndustryStandard/WatchdogResourceTable.h
+++ MdePkg/Include/IndustryStandard/WatchdogResourceTable.h
@@ -96,7 +96,7 @@
 #define EFI_ACPI_WDRT_2_0_WATCHDOG_ACTION_SET_RUNNING_STATE              0x9
 #define EFI_ACPI_WDRT_2_0_WATCHDOG_ACTION_QUERY_STOPPED_STATE            0xA
 #define EFI_ACPI_WDRT_2_0_WATCHDOG_ACTION_SET_STOPPED_STATE              0xB
-#define EFI_ACPI_WDRT_2_0_WATCHDOG_ACTION_QUERY_ REBOOT                  0x10
+#define EFI_ACPI_WDRT_2_0_WATCHDOG_ACTION_QUERY_REBOOT                   0x10
 #define EFI_ACPI_WDRT_2_0_WATCHDOG_ACTION_SET_REBOOT                     0x11
 #define EFI_ACPI_WDRT_2_0_WATCHDOG_ACTION_QUERY_SHUTDOWN                 0x12
 #define EFI_ACPI_WDRT_2_0_WATCHDOG_ACTION_SET_SHUTDOWN                   0x13


Remove unused parameter names

Remove unused parameter names

--- Modules/IGTUI/Qmitk/QmitkAbstractTrackingDeviceWidget.h
+++ Modules/IGTUI/Qmitk/QmitkAbstractTrackingDeviceWidget.h
@@ -139,28 +139,28 @@
   * \brief This function is called, when in the TrackingToolboxView "Connect" was clicked and the device is successful connected.
   * Can e.g. be used to activate options of a tracking device only when it is connected.
   */
-  virtual void OnConnected(bool _success) {};
+  virtual void OnConnected(bool) {}
   /**
   * \brief This function is called, when in the TrackingToolboxView "Disconnect" was clicked and the device is successful disconnected.
   * Can e.g. be used to activate/disactivate options of a tracking device.
   */
-  virtual void OnDisconnected(bool _success) {};
+  virtual void OnDisconnected(bool) {}

   /**
   * \brief This function is called, when in the TrackingToolboxView "Start Tracking" was clicked and the device successfully started tracking.
   * Can e.g. be used to activate options of a tracking device only when tracking is started.
   */
-  virtual void OnStartTracking(bool _success){};
+  virtual void OnStartTracking(bool) {}
   /**
   * \brief This function is called, when in the TrackingToolboxView "Stop Tracking" was clicked and the device successful stopped tracking.
   * Can e.g. be used to activate/disactivate options when device is not tracking.
   */
-  virtual void OnStopTracking(bool _success) {};
+  virtual void OnStopTracking(bool) {}
   /**
   * \brief This function is called, when anything in the ToolStorage changed, e.g. AddTool or EditTool.
   * ServiceListener is connected in the QmitkMITKIGTTrackingToolboxView.
   */
-  virtual void OnToolStorageChanged() {};
+  virtual void OnToolStorageChanged() {}

   std::string m_ErrorMessage; ///< current problem description


Add 1 to malloc'd buffer size for null terminator (#128)

--- core/cbits/grpc_haskell.c
+++ core/cbits/grpc_haskell.c
@@ -427,7 +427,7 @@
   grpc_arg* arg = args+i;
   arg->type = GRPC_ARG_STRING;
   arg->key = translate_arg_key(key);
-  char* storeValue = malloc(sizeof(char)*strlen(value));
+  char* storeValue = malloc(sizeof(char)*(strlen(value)+1));
   arg->value.string = strcpy(storeValue, value);
 }


Update radio pub channel enum

Update radio pub channel enum

--- bcl/inc/bc_radio_pub.h
+++ bcl/inc/bc_radio_pub.h
@@ -33,12 +33,22 @@
     BC_RADIO_PUB_CHANNEL_R3_I2C1_ADDRESS_DEFAULT   = 0x84,
     //! @brief channel 1:5
     BC_RADIO_PUB_CHANNEL_R3_I2C1_ADDRESS_ALTERNATE = 0x85,
+    //! @brief channel 0:6
+    BC_RADIO_PUB_CHANNEL_R4_I2C0_ADDRESS_DEFAULT   = 0x06,
+    //! @brief channel 0:7
+    BC_RADIO_PUB_CHANNEL_R4_I2C0_ADDRESS_ALTERNATE = 0x07,
+    //! @brief channel 1:6
+    BC_RADIO_PUB_CHANNEL_R4_I2C1_ADDRESS_DEFAULT   = 0x86,
+    //! @brief channel 1:7
+    BC_RADIO_PUB_CHANNEL_R4_I2C1_ADDRESS_ALTERNATE = 0x87,
     //! @brief channel a
     BC_RADIO_PUB_CHANNEL_A                         = 0xf0,
     //! @brief channel b
     BC_RADIO_PUB_CHANNEL_B                         = 0xf1,
     //! @brief channel set-point
-    BC_RADIO_PUB_CHANNEL_SET_POINT                 = 0xf2
+    BC_RADIO_PUB_CHANNEL_SET_POINT                 = 0xf2,
+    //! @brief channel -
+    BC_RADIO_PUB_CHANNEL_NONE                      = 0xff
 };

 enum


udpgw: try to fix the local port binding

git-svn-id: e4cff62102d161c5f2a02ad4c00fc75df921e9eb@1046 1a93d707-3861-5ebc-ad3b-9740d49b5140

--- udpgw/udpgw.c
+++ udpgw/udpgw.c
@@ -35,6 +35,7 @@
 #include <misc/byteorder.h>
 #include <misc/bsize.h>
 #include <misc/open_standard_streams.h>
+#include <misc/balloc.h>
 #include <structure/LinkedList1.h>
 #include <structure/BAVL.h>
 #include <base/BLog.h>
@@ -89,6 +90,7 @@
     union {
         struct {
             BDatagram udp_dgram;
+            int local_port_index;
             BufferWriter udp_send_writer;
             PacketBuffer udp_send_buffer;
             SinglePacketBuffer udp_recv_buffer;
@@ -849,23 +851,60 @@
         goto fail2;
     }

+    con->local_port_index = -1;
+
     if (options.local_udp_num_ports >= 0) {
-        // try binding (without SO_REUSEADDR, else we'd always end up binding to first port)
+        // allocate port usage array
+        uint8_t *port_usage = BAllocSize(bsize_fromint(options.local_udp_num_ports));
+        if (!port_usage) {
+            client_log(client, BLOG_ERROR, "BAllocSize failed");
+            goto failed;
+        }
+        memset(port_usage, 0, options.local_udp_num_ports);
+
+        // flag inappropriate ports (those with the same remote address)
+        for (LinkedList1Node *ln = LinkedList1_GetFirst(&clients_list); ln; ln = LinkedList1Node_Next(ln)) {
+            struct client *client2 = UPPER_OBJECT(ln, struct client, clients_list_node);
+
+            for (LinkedList1Node *ln2 = LinkedList1_GetFirst(&client2->connections_list); ln2; ln2 = LinkedList1Node_Next(ln2)) {
+                struct connection *con2 = UPPER_OBJECT(ln2, struct connection, connections_list_node);
+                ASSERT(con2->client == client2)
+                ASSERT(!con2->closing)
+                ASSERT(con2->local_port_index < options.local_udp_num_ports)
+
+                if (con2->local_port_index >= 0 && BAddr_Compare(&con2->addr, &con->addr)) {
+                    port_usage[con2->local_port_index] = 1;
+                }
+            }
+        }
+
+        // set SO_REUSEADDR
+        if (!BDatagram_SetReuseAddr(&con->udp_dgram, 1)) {
+            client_log(client, BLOG_ERROR, "set SO_REUSEADDR failed");
+            goto failed;
+        }
+
+        // try different ports
         for (int i = 0; i < options.local_udp_num_ports; i++) {
+            // skip inappropriate ports
+            if (port_usage[i]) {
+                continue;
+            }
+
             BAddr addr = local_udp_addr;
             BAddr_SetPort(&addr, hton16(ntoh16(BAddr_GetPort(&addr)) + (uint16_t)i));

             if (BDatagram_Bind(&con->udp_dgram, addr)) {
-                // set SO_REUSEADDR (we bound without it, but we don't want to take over the address)
-                if (!BDatagram_SetReuseAddr(&con->udp_dgram, 1)) {
-                    client_log(client, BLOG_ERROR, "set SO_REUSEADDR failed");
-                }
+                // remember which port we're using
+                con->local_port_index = i;
                 goto cont;
             }
         }

+    failed:
         client_log(client, BLOG_WARNING, "failed to bind to any local address; proceeding regardless");
     cont:;
+        free(port_usage);
     }

     // set UDP dgram send address


missing #include

missing #include

--- Library/Sources/Stroika/Foundation/Memory/BLOB.h
+++ Library/Sources/Stroika/Foundation/Memory/BLOB.h
@@ -11,6 +11,7 @@
 #include    <vector>

 #include    "../Configuration/Common.h"
+#include    "../Configuration/Concepts.h"
 #include    "../Memory/Common.h"
 #include    "../Memory/SharedPtr.h"


first header

first header

error: pathspec 'uenf/Matrix.h' did not match any file(s) known to git

--- uenf/Matrix.h
+++ uenf/Matrix.h
@@ -0,0 +1,24 @@
+#ifndef UENF_MATRIX_H
+#define UENF_MATRIX_H
+
+
+#include <Eigen/Core>
+
+
+namespace uenf
+{
+
+  using namespace Eigen;
+
+  typedef Eigen::Vector2i Vector2i;
+  typedef Eigen::Vector2f Vector2f;
+  typedef Eigen::Vector3f Vector3f;
+
+
+}
+
+
+
+#endif
+
+


Improve the entire code

Improve the entire code

--- chap03_function/practice01/03.c
+++ chap03_function/practice01/03.c
@@ -1,13 +1,24 @@
+/*
+    Othello
+*/
+
 #include <stdio.h>

+
+/** Macros */
 #define O_SIZE_MAX  100
 #define O_PNONE     0
 #define O_PBLACK    1
 #define O_PWHITE    2
+//#define O_PRINT_BOARD_AFTER_LOAD

-int bsize;
-int bgame[O_SIZE_MAX][O_SIZE_MAX];

+/** Global variables */
+int bsize; /**< size of the board */
+int bgame[O_SIZE_MAX][O_SIZE_MAX]; /**< game board */
+
+
+/** Function prototypes */
 void
 read_file(const char path[]);

@@ -15,11 +26,16 @@
 best_position(int *out_x, int *out_y);

 int
-count_of_captured_stone(const int x, const int y, const int enemy_colour);
+count_of_captured_stone(const int x, const int y, const int my_colour);

 int
 count(const int x, const int y, const int dir);

+int
+colour_distance(const int x, const int y, const int dir, const int dist);
+
+
+/** Function definitions */
 int
 main(void)
 {
@@ -28,11 +44,18 @@
     int x, y;
     int bestcount = best_position(&x, &y);

-    printf("size: %d\nx: %d\ny: %d\ncount:%d\n", bsize, x, y, bestcount);
+    printf("x: %d\n"
+           "y: %d\n"
+           "count:%d\n", x, y, bestcount);

     return 0;
 }

+/**
+ *  \brief  Read a file and make a board
+ *
+ *  \param  path    Path to file
+ */
 void
 read_file(const char path[])
 {
@@ -45,12 +68,23 @@
         for(j = 0; j < bsize; ++j)
         {
             fscanf(fp, "%d", &bgame[i][j]);
+#ifdef O_PRINT_BOARD_AFTER_LOAD
             printf("%d ", bgame[i][j]);
+#endif
         }
+#ifdef O_PRINT_BOARD_AFTER_LOAD
         printf("\n");
+#endif
     }
 }

+/**
+ *  \brief  Search the best position in the board
+ *
+ *  \return count of the captured stones
+ *  \param  out_x   pointer to store the location x
+ *  \param  out_y   pointer to store the location y
+ */
 int
 best_position(int *out_x, int *out_y)
 {
@@ -61,10 +95,9 @@
     {
         for(j = 0; j < bsize; ++j)
         {
-            int bc = count_of_captured_stone(i, j, O_PBLACK);
+            int bc = count_of_captured_stone(i, j, O_PWHITE);
             if(bc > bestcount)
             {
-                printf("%d %d %d\n", bc, i, j);
                 bestcount = bc;
                 *out_x = i;
                 *out_y = j;
@@ -75,93 +108,88 @@
     return bestcount;
 }

+/**
+ *  \brief  Get a count of the enemy stone than can be conquered
+ *
+ *  \return count of the enemy stone
+ *  \param  x   location x
+ *  \param  y   location y
+ *  \param  my_colour   my colour
+ */
 int
-count_of_captured_stone(const int x, const int y, const int enemy_colour)
+count_of_captured_stone(const int x, const int y, const int my_colour)
 {
-    if(bgame[x][y] != O_PNONE) return 0;
+    if(bgame[x][y] != O_PNONE) return 0; /** Cannot place stone here */

-    int captured_stone = 0;
+    int captured_stone = 0; /**< count of captured stone */
     int dir;

-    bgame[x][y] = enemy_colour; /* temporarily set the colour */
+    bgame[x][y] = my_colour; /** Set colour temporarily */
     for(dir = 0; dir < 7; ++dir)
         captured_stone += count(x, y, dir);
-    bgame[x][y] = O_PNONE; /* return colour */
+    bgame[x][y] = O_PNONE; /** Reset colour */

     return captured_stone;
 }

-int
-can_place_stone(const int x, const int y, const int my_colour)
-{
-
-}
-
-int
-colour_distance(const int x, const int y, const int dir, const int distance)
-{
-    switch(dir)
-    {
-    case 0: return bgame[x           ][y + distance];
-    case 1: return bgame[x - distance][y + distance];
-    case 2: return bgame[x - distance][y           ];
-    case 3: return bgame[x - distance][y - distance];
-    case 4: return bgame[x           ][y - distance];
-    case 5: return bgame[x + distance][y - distance];
-    case 6: return bgame[x + distance][y           ];
-    case 7: return bgame[x + distance][y + distance];
-    }
-}
-
+/**
+ *  \brief  Get a count of the enemy stone that can be conquered, with specific direction
+ *
+ *  Put my stone to location beforehand.
+ *  \return count of the enemy stone
+ *  \param  x       location x
+ *  \param  y       location y
+ *  \param  dir     direction
+ */
 int
 count(const int x, const int y, const int dir)
 {
-    if(x < 0 || y < 0 || x > bsize || y > bsize) return 0;
+    int dist = 0; /**< distance */
+    int my_colour = colour_distance(x, y, dir, 0);
+    int last_colour; /**< colour that is the first change of specific direction */

-    int x_t = 0,
-        y_t = 0;
+    do { ++dist; } while((last_colour = colour_distance(x, y, dir, dist)) != 0 && last_colour != my_colour);

-    int enemy_colour;
+    if(last_colour == my_colour)
+        return dist - 1;
+    else
+        return 0;
+}

-    switch(colour_distance(x, y, dir, 0))
-    {
-    case O_PBLACK:  enemy_colour = O_PWHITE; break;
-    case O_PWHITE:  enemy_colour = O_PBLACK; break;
-    default:        enemy_colour = O_PNONE;
-    }
+/**
+ *  \brief  Get colour as far as distance from the location
+ *
+ *  Return zero(O_PNONE) when the passed location is invalid.
+ *  \return colour
+ *  \param  x       location x
+ *  \param  y       location y
+ *  \param  dir     direction
+ *  \param  dist    distance
+ */
+int
+colour_distance(const int x, const int y, const int dir, const int dist)
+{
+    /**
+        Coordination of board
+                         x  y   bgame[x][y]
+        +---- y     a -> 0, 0   bgame[0][0]
+        | a b       b -> 0, 1   bgame[0][1]
+        | c d       c -> 1, 0   bgame[1][0]
+        x           d -> 1, 1   bgame[1][1]
+
+        Direction of board
+        0:n, 1:ne, 2:e, 3:se, 4:s, 5:sw, 6:w, 7:nw
+    */

     switch(dir)
     {
-    case 0:
-        do { ++y_t; } while(colour_distance(x, y, dir, 0) != colour_distance(x, y_t, dir, i));
-        return y_t - y;
-
-    case 1:
-        if(x-1 > bsize || y+1 > bsize || bgame[x][y] != bgame[x-1][y+1]) return 0;
-        return 1 + count(x-1, y+1, dir);
-
-    case 2:
-        if(x-1 > bsize || bgame[x][y] != bgame[x-1][y]) return 0;
-        return 1 + count(x-1, y, dir);
-
-    case 3:
-        if(x-1 > bsize || y-1 > bsize || bgame[x][y] != bgame[x-1][y-1]) return 0;
-        return 1 + count(x-1, y-1, dir);
-
-    case 4:
-        if(y-1 > bsize || bgame[x][y] != bgame[x][y-1]) return 0;
-        return 1 + count(x, y-1, dir);
-
-    case 5:
-        if(x+1 > bsize || y-1 > bsize || bgame[x][y] != bgame[x+1][y-1]) return 0;
-        return 1 + count(x+1, y-1, dir);
-
-    case 6:
-        if(x+1 > bsize || bgame[x][y] != bgame[x+1][y]) return 0;
-        return 1 + count(x+1, y, dir);
-
-    case 7:
-        if(x+1 > bsize || y+1 > bsize || bgame[x][y] != bgame[x+1][y+1]) return 0;
-        return 1 + count(x+1, y+1, dir);
+    case 0: return ( x - dist >= 0                        ) ? bgame[x - dist][y       ] : 0;
+    case 1: return ( x - dist >= 0    && y + dist < bsize ) ? bgame[x - dist][y + dist] : 0;
+    case 2: return (                     y + dist < bsize ) ? bgame[x       ][y + dist] : 0;
+    case 3: return ( x + dist < bsize && y + dist < bsize ) ? bgame[x + dist][y + dist] : 0;
+    case 4: return ( x + dist < bsize                     ) ? bgame[x + dist][y       ] : 0;
+    case 5: return ( x + dist < bsize && y - dist >= 0    ) ? bgame[x + dist][y - dist] : 0;
+    case 6: return (                     y - dist >= 0    ) ? bgame[x       ][y - dist] : 0;
+    case 7: return ( x - dist >= 0    && y - dist >= 0    ) ? bgame[x - dist][y - dist] : 0;
     }
 }


Remove print for debugging

Remove print for debugging

--- chap03_function/practice02/02.c
+++ chap03_function/practice02/02.c
@@ -38,7 +38,6 @@
     printf("Enter numbers (delims by whitespace)= ");
     for(i = 0; i < n; ++i)
     {
-        printf("%d %d %d\n", i, n, i < n);
         scanf("%d", &numbers[i]);
     }


comment/endif bug

comment/endif bug

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


Add str_cat()

Add str_cat()

--- common-static.h
+++ common-static.h
@@ -68,6 +68,31 @@
     return i;
 }

+static inline char *str_cat (const char *const strs[], size_t count)
+{
+    size_t size = 0;
+
+    for (size_t i=0; i<count; i++)
+        size += str_len(strs[i]);
+
+    char *str = malloc(size+1);
+
+    if (!str)
+        return NULL;
+
+    char *p = str;
+
+    for (size_t i=0; i<count; i++) {
+        size_t len = str_len(strs[i]);
+        byte_cpy(p, strs[i], len);
+        p += len;
+    }
+
+    p[0] = 0;
+
+    return str;
+}
+
 static inline void buffer_setup (buffer_t *buffer, void *data, size_t size)
 {
     if (!data)


STYLE: Added some default values.

STYLE: Added some default values.

--- Widgets/vtkSphereWidget.h
+++ Widgets/vtkSphereWidget.h
@@ -93,7 +93,8 @@

   // Description:
   // Set the representation of the sphere. Different representations are
-  // useful depending on the application.
+  // useful depending on the application. The default is
+  // VTK_SPHERE_WIREFRAME.
   vtkSetClampMacro(Representation,int,VTK_SPHERE_OFF,VTK_SPHERE_SURFACE);
   vtkGetMacro(Representation,int);
   void SetRepresentationToOff()
@@ -105,6 +106,7 @@

   // Description:
   // Set/Get the resolution of the sphere in the Theta direction.
+  // The default is 16.
   void SetThetaResolution(int r)
     { this->SphereSource->SetThetaResolution(r); }
   int GetThetaResolution()
@@ -112,6 +114,7 @@

   // Description:
   // Set/Get the resolution of the sphere in the Phi direction.
+  // The default is 8.
   void SetPhiResolution(int r)
     { this->SphereSource->SetPhiResolution(r); }
   int GetPhiResolution()


Move brace over - big deal!

Move brace over - big deal!

--- common/loader.c
+++ common/loader.c
@@ -18,7 +18,7 @@
  * Mark Hessling  M.Hessling@qut.edu.au  http://www.lightlink.com/hessling/
  */

-static char RCSid[] = "$Id: loader.c,v 1.1 2001/11/11 05:10:33 mark Exp $";
+static char RCSid[] = "$Id: loader.c,v 1.2 2002/03/02 11:51:28 mark Exp $";

 #include "rxpack.h"

@@ -152,7 +152,7 @@
          usage();
    }
    else
-      {
+   {
       /*
        * Next argument is the name of the Rexx program...
        */


GCC manual recommends underscores in headers; add pure attribute macro

--- common/macros.h
+++ common/macros.h
@@ -36,18 +36,20 @@
         void operator delete[](void *ptr, size_t) { _mm_free(ptr); }

 #ifdef __GNUC__
-#  define CONST __attribute__((const))
+#  define CONST __attribute__((__const__))
+#  define PURE __attribute__((__pure__))
 #  define MAY_ALIAS __attribute__((__may_alias__))
-#  define ALWAYS_INLINE __attribute__((always_inline))
+#  define ALWAYS_INLINE __attribute__((__always_inline__))
 #  if __GNUC__ == 4 && __GNUC_MINOR__ == 5 && __GNUC_PATCHLEVEL__ == 0 && !defined(__x86_64__)
      // GCC 4.5.0 seems to have some problem with inlining operator<< and operator>>
 #    warning "GCC 4.5.0 bug? __attribute__((always_inline)) shows that inlining of operator<< and operator>> fails. The disassembly shows it really should be inlined."
 #    define ALWAYS_INLINE_X
 #  else
-#    define ALWAYS_INLINE_X __attribute__((always_inline))
+#    define ALWAYS_INLINE_X __attribute__((__always_inline__))
 #  endif
 #else
 #  define CONST
+#  define PURE
 #  define MAY_ALIAS
 #  define ALWAYS_INLINE
 #endif


ps: Don't hardcode instance column

ps: Don't hardcode instance column

We were unconditionally adding the instance column,
which causes table headers to be off-by-one when
instance is not among the requested columns.

Change things to only add the instance column
when requested.

--- app/flatpak-builtins-ps.c
+++ app/flatpak-builtins-ps.c
@@ -81,11 +81,11 @@
     {
       FlatpakInstance *instance = (FlatpakInstance *) g_ptr_array_index (instances, j);

-      flatpak_table_printer_add_column (printer, flatpak_instance_get_id (instance));
-
       for (i = 0; columns[i].name; i++)
         {
-          if (strcmp (columns[i].name, "pid") == 0)
+          if (strcmp (columns[i].name, "instance") == 0)
+            flatpak_table_printer_add_column (printer, flatpak_instance_get_id (instance));
+          else if (strcmp (columns[i].name, "pid") == 0)
             {
               g_autofree char *pid = g_strdup_printf ("%d", flatpak_instance_get_pid (instance));
               flatpak_table_printer_add_column (printer, pid);


add cache category

add cache category

--- ngx_http_auto_complete_module.c
+++ ngx_http_auto_complete_module.c
@@ -16,7 +16,7 @@
 } ngx_http_auto_complete_loc_conf_t;

 static tst_node       *ngx_http_auto_complete_tst;
-static tst_node       *ngx_http_auto_complete_tst_cache;
+static tst_cache_node       *ngx_http_auto_complete_tst_cache;
 static ngx_shm_zone_t *ngx_http_auto_complete_shm_zone;
 static ssize_t         ngx_http_auto_complete_shm_size;
 static char           *ngx_http_auto_complete_dict_path;
@@ -93,8 +93,8 @@
     ngx_chain_t             out;
     ngx_str_t               value;
     u_char                 *word, *cb, *dst, *src;
-    size_t                  count;
-    char                    escape_buf[512];
+    size_t                  count, cache_data_len;
+    char                    escape_buf[512], *cache_data;
     tst_search_result_node *node;
     tst_search_result      *result;
     ngx_table_elt_t        *hv;
@@ -158,32 +158,46 @@
         ngx_slab_pool_t *shpool = (ngx_slab_pool_t *)ngx_http_auto_complete_shm_zone->shm.addr;

         ngx_shmtx_lock(&shpool->mutex);
-        result = tst_search(ngx_http_auto_complete_tst_cache, (char *) word, r->pool);
+        cache_data = tst_cache_search(ngx_http_auto_complete_tst_cache, (char *) word);
+		if (cache_data) {
+			cache_data_len = strlen(cache_data);
+			b->pos = ngx_pcalloc(r->pool, cache_data_len + 1);
+			b->last = b->pos;
+
+			if (!b->pos) {
+				ngx_shmtx_unlock(&shpool->mutex);
+				return NGX_HTTP_INTERNAL_SERVER_ERROR;
+			}
+
+			b->last = ngx_snprintf(b->last, cache_data_len + 1, "%s", cache_data);
+		}
         ngx_shmtx_unlock(&shpool->mutex);

-        if (result->count == 1) {
-            b->pos = result->list->word;
-            b->last = result->list->word + result->list->word_len;
-
-            ngx_str_t hv_name = ngx_string("X-TST-CACHE-HIT");
-            ngx_str_t hv_value = ngx_string("true");
-            hv = ngx_list_push(&r->headers_out.headers);
-
-            if (!hv) {
-                return NGX_HTTP_INTERNAL_SERVER_ERROR;
-            }
-
-            hv->hash = 1;
-            hv->key.len = hv_name.len;
-            hv->key.data = hv_name.data;
+		ngx_str_t hv_name = ngx_string("X-TST-Cache-Hit");
+		hv = ngx_list_push(&r->headers_out.headers);
+
+		if (!hv) {
+			return NGX_HTTP_INTERNAL_SERVER_ERROR;
+		}
+
+		hv->hash = 1;
+		hv->key.len = hv_name.len;
+		hv->key.data = hv_name.data;
+
+        if (cache_data) {
+            ngx_str_t hv_value = ngx_string("yes");
+
             hv->value.len =  hv_value.len;
             hv->value.data = hv_value.data;
-
-            ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "fuck ...");
         } else {
             ngx_shmtx_lock(&shpool->mutex);
-            result = tst_search(ngx_http_auto_complete_tst, (char *) word, r->pool);
+            result = tst_search(ngx_http_auto_complete_tst, (char *) word, r->pool, r->connection->log);
             ngx_shmtx_unlock(&shpool->mutex);
+
+			if (!result) {
+				return NGX_HTTP_INTERNAL_SERVER_ERROR;
+			}
+
             if (result->count > 0) {
                 count = 0;

@@ -218,9 +232,15 @@

                 if (result->count > 50) {
                     ngx_shmtx_lock(&shpool->mutex);
-                    ngx_http_auto_complete_tst_cache = tst_insert_alias(ngx_http_auto_complete_tst_cache, (char *) word, b->pos, ngx_http_auto_complete_shm_zone);
+                    ngx_http_auto_complete_tst_cache = tst_cache_insert(ngx_http_auto_complete_tst_cache, (char *) word, b->pos, ngx_http_auto_complete_shm_zone, r->connection->log);
                     ngx_shmtx_unlock(&shpool->mutex);
                 }
+
+				ngx_str_t hv_value = ngx_string("no");
+
+				hv->value.len =  hv_value.len;
+				hv->value.data = hv_value.data;
+
             }
         }
     }
@@ -275,17 +295,17 @@
         if (!split) {
             if (strlen(word_buf) > 45) {
                 ngx_snprintf(cut_word_buf, 46, "%s", word_buf);
-                ngx_http_auto_complete_tst = tst_insert_alias(ngx_http_auto_complete_tst, cut_word_buf, word_buf, ngx_http_auto_complete_shm_zone);
+                ngx_http_auto_complete_tst = tst_insert_alias(ngx_http_auto_complete_tst, cut_word_buf, word_buf, ngx_http_auto_complete_shm_zone, NULL);
             } else {
-                ngx_http_auto_complete_tst = tst_insert(ngx_http_auto_complete_tst, word_buf, ngx_http_auto_complete_shm_zone);
+                ngx_http_auto_complete_tst = tst_insert(ngx_http_auto_complete_tst, word_buf, ngx_http_auto_complete_shm_zone, NULL);
             }
         } else {
             *split = 0;
             if (strlen(word_buf) > 46) {
                 ngx_snprintf(cut_word_buf, 46, "%s", word_buf);
-                ngx_http_auto_complete_tst = tst_insert_alias(ngx_http_auto_complete_tst, cut_word_buf, split + 2, ngx_http_auto_complete_shm_zone);
+                ngx_http_auto_complete_tst = tst_insert_alias(ngx_http_auto_complete_tst, cut_word_buf, split + 2, ngx_http_auto_complete_shm_zone, NULL);
             } else {
-                ngx_http_auto_complete_tst = tst_insert_alias(ngx_http_auto_complete_tst, word_buf, split + 2, ngx_http_auto_complete_shm_zone);
+                ngx_http_auto_complete_tst = tst_insert_alias(ngx_http_auto_complete_tst, word_buf, split + 2, ngx_http_auto_complete_shm_zone, NULL);
             }
         }
     }
@@ -327,12 +347,14 @@
         ngx_http_auto_complete_shm_size = 1024 * 16 * ngx_pagesize;
     }

-    ngx_http_auto_complete_shm_zone = ngx_shared_memory_add(cf, shm_name, ngx_http_auto_complete_shm_size, &ngx_http_auto_complete_module);
-    if (!ngx_http_auto_complete_shm_zone) {
-        return NGX_CONF_ERROR;
-    }
-
-    ngx_http_auto_complete_shm_zone->init = ngx_http_auto_complete_init_shm_zone;
+	if (!ngx_http_auto_complete_shm_zone) {
+		ngx_http_auto_complete_shm_zone = ngx_shared_memory_add(cf, shm_name, ngx_http_auto_complete_shm_size, &ngx_http_auto_complete_module);
+		if (!ngx_http_auto_complete_shm_zone) {
+			return NGX_CONF_ERROR;
+		}
+
+    	ngx_http_auto_complete_shm_zone->init = ngx_http_auto_complete_init_shm_zone;
+	}

     return NGX_CONF_OK;
 }


fix QueryPerformanceCounter usage (works nicely now on Windows)

--- benchmarks/benchmark.h
+++ benchmarks/benchmark.h
@@ -78,7 +78,7 @@
     const double fFactor;
     const char *const fX;
 #ifdef _MSC_VER
-    QWORD fRealTime;
+    __int64 fRealTime;
     clock_t fCpuTime;
 #else
     struct timespec fRealTime;
@@ -90,7 +90,7 @@
 inline void Benchmark::Start()
 {
 #ifdef _MSC_VER
-    fRealTime = reinterpret_cast<QWORD &>(QueryPerfomanceCounter());
+    QueryPerformanceCounter((LARGE_INTEGER *)&fRealTime);
     fCpuTime = clock();
 #else
     clock_gettime( CLOCK_MONOTONIC, &fRealTime );
@@ -113,10 +113,12 @@
 inline void Benchmark::Stop()
 {
 #ifdef _MSC_VER
-    QWORD real = reinterpret_cast<QWORD &>(QueryPerfomanceCounter());
+    __int64 real = 0, freq = 0;
+    QueryPerformanceCounter((LARGE_INTEGER *)&real);
     clock_t cpu = clock();
+    QueryPerformanceFrequency((LARGE_INTEGER *)&freq);
     const DataPoint p = {
-        (real - fRealTime) * SECONDS_PER_PERFCOUNT,
+        static_cast<double>(real - fRealTime) / freq,
         (cpu - fCpuTime) * SECONDS_PER_CLOCK
     };
 #else


Disable TParameter<bool> for the time being. Needs specialization of
Merge() method.

git-svn-id: ecbadac9c76e8cf640a0bca86f6bd796c98521e3@38217 27541ba8-7e3a-0410-8455-c3a389f83636

--- core/base/inc/LinkDef3.h
+++ core/base/inc/LinkDef3.h
@@ -257,7 +257,7 @@
 #pragma link C++ class std::pair<const double,char*>+;

 #pragma extra_include "Rtypes.h";
-#pragma link C++ class TParameter<Bool_t>+;
+/* #pragma link C++ class TParameter<Bool_t>+; */
 #pragma link C++ class TParameter<Float_t>+;
 #pragma link C++ class TParameter<Double_t>+;
 #pragma link C++ class TParameter<Int_t>+;


Remove #define sync in test/run-trace.c - don't confuse with sync(2)

Signed-off-by: Stewart Smith <ec31ab75ddf977353c8f660f92ea8b23f64aef25@linux.vnet.ibm.com>

--- core/test/run-trace.c
+++ core/test/run-trace.c
@@ -38,14 +38,13 @@
 	asm volatile("mfence" : : : "memory");
 }
 #define lwsync full_barrier
-#define sync full_barrier
 #elif defined(__powerpc__) || defined(__powerpc64__)
 static inline void lwsync(void)
 {
 	asm volatile("lwsync" : : : "memory");
 }
 #else
-#error "Define sync & lwsync for this arch"
+#error "Define lwsync for this arch"
 #endif

 #define zalloc(size) calloc((size), 1)


corrected mismatch in expected time scales between LED h and cpp

--- jewelbots_nRF51822_board_v100/cores/JWB_nRF51822/LED.h
+++ jewelbots_nRF51822_board_v100/cores/JWB_nRF51822/LED.h
@@ -20,8 +20,8 @@
     void turn_on_all(ColorLabel color );
     void turn_off_single(LED_Pos led);
     void turn_off_all();
-    void flash_single(LED_Pos led, ColorLabel color, uint32_t microseconds);
-    void flash_all(ColorLabel color, uint32_t microseconds);
+    void flash_single(LED_Pos led, ColorLabel color, uint32_t milliseconds);
+    void flash_all(ColorLabel color, uint32_t milliseconds);
     void setLight(uint8_t number, uint8_t r, uint8_t g, uint8_t b);

 };


Comment out broken part of unimplemented function

--- libs/graphslam/include/mrpt/graphslam/CGraphSlamEngine_impl.h
+++ libs/graphslam/include/mrpt/graphslam/CGraphSlamEngine_impl.h
@@ -877,7 +877,7 @@
 	if (!m_map_is_cached){
 		this->computeMap();
 	}
-	map = dynamic_cast<mrpt::maps::COctoMap::Ptr>(m_octomap_cached->clone());
+//	map = dynamic_cast<mrpt::maps::COctoMap::Ptr>(m_octomap_cached->clone());
 	ASSERT_(map)

 	// fill the timestamp if this is given


adjust verxx value for PowerPC target swap

--- core/config/rtarch_p32.h
+++ core/config/rtarch_p32.h
@@ -1682,7 +1682,7 @@
  * 2nd byte - 512-bit version, 3rd byte - 1K4-bit version, | in upper halves */

 #define verxx_xx() /* destroys Reax, Recx, Rebx, Redx, Resi, Redi */        \
-        movwx_mi(Mebp, inf_VER, IV(0x036F77)) /* <- VMX/VSX1/2 to 128/256/512 */
+        movwx_mi(Mebp, inf_VER, IV(0x033F77)) /* <- VSX1/2/VMX to 128/256/512 */

 /************************* address-sized instructions *************************/


Fixed string opts on data buffer to make append valid.

--- check/magma/prime/prime_check.c
+++ check/magma/prime/prime_check.c
@@ -370,7 +370,7 @@
 		length = st_write(NULL, ephemeral_chunk_buffer(ephemeral), encrypted_chunk_buffer(common), encrypted_chunk_buffer(headers),
 			encrypted_chunk_buffer(body));

-		if (!(data = st_alloc(length + 512)) || st_write(data, ephemeral_chunk_buffer(ephemeral), encrypted_chunk_buffer(common), encrypted_chunk_buffer(headers),
+		if (!(data = st_alloc_opts(MANAGED_T | JOINTED | HEAP, length + 512)) || st_write(data, ephemeral_chunk_buffer(ephemeral), encrypted_chunk_buffer(common), encrypted_chunk_buffer(headers),
 			encrypted_chunk_buffer(body), treesig) != length + 161) {
 			st_sprint(errmsg, "Serialized message creation failed.");
 			result = false;


Button sensor header

Button sensor header

error: pathspec 'core/dev/button-sensor.h' did not match any file(s) known to git

--- core/dev/button-sensor.h
+++ core/dev/button-sensor.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2005, Swedish Institute of Computer Science
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This file is part of the Contiki operating system.
+ *
+ * @(#)$Id: button-sensor.h,v 1.1 2007/03/15 21:42:09 adamdunkels Exp $
+ */
+#ifndef __BUTTON_SENSOR_H__
+#define __BUTTON_SENSOR_H__
+
+#include "lib/sensors.h"
+
+extern const struct sensors_sensor button_sensor;
+
+#define BUTTON_SENSOR "Button"
+
+#endif /* __BUTTON_SENSOR_H__ */


Xref list perf improvements

Xref list perf improvements

--- ui/xreflist.h
+++ ui/xreflist.h
@@ -62,8 +62,8 @@
 	virtual ~XrefItem();

 	XrefDirection direction() const { return m_direction; }
-	FunctionRef func() const { return m_func; }
-	ArchitectureRef arch() const { return m_arch; }
+	const FunctionRef& func() const { return m_func; }
+	const ArchitectureRef& arch() const { return m_arch; }
 	uint64_t addr() const { return m_addr; }
 	XrefType type() const { return m_type; }
 	int size() const { return m_size; }
@@ -387,6 +387,7 @@
 	QLineEdit* m_lineEdit;
 	ExpandableGroup* m_group;

+	bool m_curRefTargetValid = false;
 	uint64_t m_curRefTarget = 0;
 	uint64_t m_curRefTargetEnd = 0;
 	uint64_t m_newRefTarget = 0;


Add signed fixed size data types

Add signed fixed size data types

Signed-off-by: David Oberhollenzer <ef97309e490485c1bad5018f0617d7fa37bc07ac@tele2.at>

--- core/include/tl_predef.h
+++ core/include/tl_predef.h
@@ -44,12 +44,22 @@
 #include <assert.h>

 #ifdef _MSC_VER
+    typedef __int8 tl_s8;
+    typedef __int16 tl_s16;
+    typedef __int32 tl_s32;
+    typedef __int64 tl_s64;
+
     typedef unsigned __int8 tl_u8;
     typedef unsigned __int16 tl_u16;
     typedef unsigned __int32 tl_u32;
     typedef unsigned __int64 tl_u64;
 #else
     #include <stdint.h>
+
+    typedef int8_t tl_s8;
+    typedef int16_t tl_s16;
+    typedef int32_t tl_s32;
+    typedef int64_t tl_s64;

     typedef uint8_t tl_u8;
     typedef uint16_t tl_u16;


aroma: contrib: linux: fix warning

aroma: contrib: linux: fix warning

--- src/contrib/platform/linux/include/aroma_platform.h
+++ src/contrib/platform/linux/include/aroma_platform.h
@@ -68,7 +68,6 @@
 #define LIBAROMA_PLATFORM_HAS_SHMEM  1
 #define LIBAROMA_PLATFORM_HAS_MMAP   1
 #define LIBAROMA_PLATFORM_HAS_FD     1
-#define LIBAROMA_CONFIG_OS "linux/gnu"

 /*
  * common platform wrapper


Update knd_config.h

Update knd_config.h

--- core/include/knd_config.h
+++ core/include/knd_config.h
@@ -72,7 +72,7 @@
 } knd_storage_type;

-#define RET_ERR(S) if (err) { printf(#S);                               \
+#define RET_ERR(S) if (err) { printf("" #S);                               \
                               printf ("-- <%s> failed at line %d of file \"%s\"\n",\
                                       __func__, __LINE__, __FILE__); return err; }
 #define ALLOC_ERR(V) if (!(V)) { return knd_NOMEM; }


adding BetaT vs pT histogram

adding BetaT vs pT histogram

--- PWGCF/FEMTOSCOPY/AliFemto/AliFemtoCutMonitorPairBetaT.h
+++ PWGCF/FEMTOSCOPY/AliFemto/AliFemtoCutMonitorPairBetaT.h
@@ -50,6 +50,9 @@
   double fMaxBetaT;      // Maximum betaT
   double fMassPart1;     // Mass of the first particle in pair [GeV]
   double fMassPart2;     // Mass of the second particle in pair [GeV]
+
+  TH2D *fBetaTpT1;  //BetaT vs pT of part1
+  TH2D *fBetaTpT2;  //BetaT vs pT of part2
 };

 #endif


Pass ECC

Pass ECC

git-svn-id: 5648d1bec6962b0a6d1d1b40eba8cf5cdb62da3d@7460 6f19259b-4bc3-4df7-8a09-765794883524

--- MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
+++ MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c
@@ -535,19 +535,19 @@
   // fragment if its head has MF (more fragment) set, or it starts
   // at non-zero byte.
   //
-  if ((Head->Fragment & IP4_HEAD_MF_MASK) || (Info->Start != 0)) {
+  if (((Head->Fragment & IP4_HEAD_MF_MASK) != 0) || (Info->Start != 0)) {
     //
     // Drop the fragment if DF is set but it is fragmented. Gateway
     // need to send a type 4 destination unreache ICMP message here.
     //
-    if (Head->Fragment & IP4_HEAD_DF_MASK) {
+    if ((Head->Fragment & IP4_HEAD_DF_MASK) != 0) {
       goto RESTART;
     }

     //
     // The length of all but the last fragments is in the unit of 8 bytes.
     //
-    if ((Head->Fragment & IP4_HEAD_MF_MASK) && (Info->Length % 8 != 0)) {
+    if (((Head->Fragment & IP4_HEAD_MF_MASK) != 0) && (Info->Length % 8 != 0)) {
       goto RESTART;
     }


EventService.h

EventService.h

error: pathspec 'p3/src/org/cracs/stheno/services/stream/event/EventService.h' did not match any file(s) known to git

--- p3/src/org/cracs/stheno/services/stream/event/EventService.h
+++ p3/src/org/cracs/stheno/services/stream/event/EventService.h
@@ -0,0 +1,42 @@
+/*
+ *  Copyright 2012 Rolando Martins, CRACS & INESC-TEC, DCC/FCUP
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+/*
+ * File:   EventService.h
+ * Author: Rolando Martins (rolando.martins@gmail.com)
+ *
+ * Created on May 8, 2010, 7:36 PM
+ */
+
+#ifndef EVENTSERVICE_H
+#define	EVENTSERVICE_H
+
+#include <stheno/service/Service.h>
+#include <euryale/common/uuid/UUID.h>
+#include <stheno/services/event/EventQoS.h>
+
+class EventService: public Service {
+public:
+    virtual ~EventService();
+
+    virtual void initEvents(UUID* sensorUUID,EventQoS* qos){
+    }
+private:
+    EventService(SthenoPtr* runtime, OverlayPtr* overlay);
+};
+
+#endif	/* EVENTSERVICE_H */
+


enh: Add ConvolveForegroundIn(X|Y|Z|T) voxel functions [Image]

--- Modules/Image/include/mirtkConvolutionFunction.h
+++ Modules/Image/include/mirtkConvolutionFunction.h
@@ -241,6 +241,368 @@
 };

 // =============================================================================
+// Convolve at boundary truncated image foreground with 1D kernel
+// =============================================================================
+
+// -----------------------------------------------------------------------------
+/// Perform convolution of image foreground along x with truncation of kernel at boundary
+template <class TKernel = double>
+struct ConvolveForegroundInX : public VoxelFunction
+{
+  const BaseImage *_Image;     ///< Image defining foreground region
+  const TKernel   *_Kernel;    ///< Convolution kernel
+  int              _Radius;    ///< Radius of kernel
+  bool             _Normalize; ///< Wether to divide by sum of kernel weights
+  int              _Offset;    ///< Vector component offset
+  int              _X;         ///< Number of voxels in x
+
+  ConvolveForegroundInX(const BaseImage *image, const TKernel *kernel, int size, bool norm = true, int l = 0)
+  :
+    _Image(image), _Kernel(kernel), _Radius((size - 1) / 2), _Normalize(norm),
+    _Offset(l * image->NumberOfSpatialVoxels()), _X(image->X())
+  {}
+
+  template <class T1, class T2>
+  void operator ()(int i, int j, int k, int l, const T1 *in, T2 *out) const
+  {
+    // Convolve l-th vector component
+    in += _Offset, out += _Offset;
+    // Go to start of input and end of kernel
+    i    -= _Radius;
+    in   -= _Radius;
+    int n = _Radius + _Radius/* + 1 - 1*/;
+    // Outside left boundary
+    if (i < 0) n += i, in -= i, i = 0;
+    // Inside image domain
+    double acc = .0, sum = .0;
+    while (i < _X && n >= 0) {
+      if (_Image->IsForeground(i, j, k, l)) {
+        acc += static_cast<double>(_Kernel[n]) * static_cast<double>(*in);
+        sum += static_cast<double>(_Kernel[n]);
+      }
+      ++i, ++in, --n;
+    }
+    // Output result of convolution
+    if (_Normalize && sum != .0) acc /= sum;
+    *out = static_cast<T2>(acc);
+  }
+};
+
+// -----------------------------------------------------------------------------
+/// Perform convolution of image foreground along y with truncation of kernel at boundary
+template <class TKernel = double>
+struct ConvolveForegroundInY : public VoxelFunction
+{
+  const BaseImage *_Image;     ///< Image defining foreground region
+  const TKernel   *_Kernel;    ///< Convolution kernel
+  int              _Radius;    ///< Radius of kernel
+  bool             _Normalize; ///< Wether to divide by sum of kernel weights
+  int              _Offset;    ///< Vector component offset
+  int              _X;         ///< Number of voxels in x
+  int              _Y;         ///< Number of voxels in y
+
+  ConvolveForegroundInY(const BaseImage *image, const TKernel *kernel, int size, bool norm = true, int l = 0)
+  :
+    _Image(image), _Kernel(kernel), _Radius((size - 1) / 2), _Normalize(norm),
+    _Offset(l * image->NumberOfSpatialVoxels()), _X(image->X()), _Y(image->Y())
+  {}
+
+  template <class T1, class T2>
+  void operator ()(int i, int j, int k, int l, const T1 *in, T2 *out) const
+  {
+    // Convolve l-th vector component
+    in += _Offset, out += _Offset;
+    // Go to start of input and end of kernel
+    j    -= _Radius;
+    in   -= _Radius * _X;
+    int n = _Radius + _Radius/* + 1 - 1*/;
+    // Outside left boundary
+    if (j < 0) n += j, in -= j * _X, j = 0;
+    // Inside image domain
+    double acc = .0, sum = .0;
+    while (j < _Y && n >= 0) {
+      if (_Image->IsForeground(i, j, k, l)) {
+        acc += static_cast<double>(_Kernel[n]) * static_cast<double>(*in);
+        sum += static_cast<double>(_Kernel[n]);
+      }
+      ++j, in += _X, --n;
+    }
+    // Output result of convolution
+    if (_Normalize && sum != .0) acc /= sum;
+    *out = static_cast<T2>(acc);
+  }
+};
+
+// -----------------------------------------------------------------------------
+/// Perform convolution of image foreground along z with truncation of kernel at boundary
+template <class TKernel = double>
+struct ConvolveForegroundInZ : public VoxelFunction
+{
+  const BaseImage *_Image;     ///< Image defining foreground region
+  const TKernel   *_Kernel;    ///< Convolution kernel
+  int              _Radius;    ///< Radius of kernel
+  bool             _Normalize; ///< Wether to divide by sum of kernel weights
+  int              _Offset;    ///< Vector component offset
+  int              _XY;        ///< Number of voxels in slice (nx * ny)
+  int              _Z;         ///< Number of voxels in z
+
+  ConvolveForegroundInZ(const BaseImage *image, const TKernel *kernel, int size, bool norm = true, int l = 0)
+  :
+    _Image(image), _Kernel(kernel), _Radius((size - 1) / 2), _Normalize(norm),
+    _Offset(l * image->NumberOfSpatialVoxels()), _XY(image->X() * image->Y()), _Z(image->Z())
+  {}
+
+  template <class T1, class T2>
+  void operator ()(int i, int j, int k, int l, const T1 *in, T2 *out) const
+  {
+    // Convolve l-th vector component
+    in += _Offset, out += _Offset;
+    // Go to start of input and end of kernel
+    k    -= _Radius;
+    in   -= _Radius * _XY;
+    int n = _Radius + _Radius/* + 1 - 1*/;
+    // Outside left boundary
+    if (k < 0) n += k, in -= k * _XY, k = 0;
+    // Inside image domain
+    double acc = .0, sum = .0;
+    while (k < _Z && n >= 0) {
+      if (_Image->IsForeground(i, j, k, l)) {
+        acc += static_cast<double>(_Kernel[n]) * static_cast<double>(*in);
+        sum += static_cast<double>(_Kernel[n]);
+      }
+      ++k, in += _XY, --n;
+    }
+    // Output result of convolution
+    if (_Normalize && sum != .0) acc /= sum;
+    *out = static_cast<T2>(acc);
+  }
+};
+
+// -----------------------------------------------------------------------------
+/// Perform convolution of image foreground along t with truncation of kernel at boundary
+template <class TKernel = double>
+struct ConvolveForegroundInT : public VoxelFunction
+{
+  const BaseImage *_Image;     ///< Image defining foreground region
+  const TKernel   *_Kernel;    ///< Convolution kernel
+  int              _Radius;    ///< Radius of kernel
+  bool             _Normalize; ///< Wether to divide by sum of kernel weights
+  int              _XYZ;       ///< Number of voxels in volume (nx * ny * nz)
+  int              _T;         ///< Number of voxels in t
+
+  ConvolveForegroundInT(const BaseImage *image, const TKernel *kernel, int size, bool norm = true)
+  :
+    _Image(image), _Kernel(kernel), _Radius((size - 1) / 2), _Normalize(norm),
+    _XYZ(image->X() * image->Y() * image->Z()), _T(image->T())
+  {}
+
+  template <class T1, class T2>
+  void operator ()(int i, int j, int k, int l, const T1 *in, T2 *out) const
+  {
+    double acc = .0, sum = .0;
+    // Go to start of input and end of kernel
+    l    -= _Radius;
+    in   -= _Radius * _XYZ;
+    int n = _Radius + _Radius/* + 1 - 1*/;
+    // Outside left boundary
+    if (l < 0) n += l, in -= l * _XYZ, l = 0;
+    // Inside image domain
+    while (l < _T && n >= 0) {
+      if (_Image->IsForeground(i, j, k, l)) {
+        acc += static_cast<double>(_Kernel[n]) * static_cast<double>(*in);
+        sum += static_cast<double>(_Kernel[n]);
+      }
+      ++l, in += _XYZ, --n;
+    }
+    // Output result of convolution
+    if (_Normalize && sum != .0) acc /= sum;
+    *out = static_cast<T2>(acc);
+  }
+};
+
+// =============================================================================
+// Convolve at boundary truncated voxel-wise weighted image with 1D kernel
+// =============================================================================
+
+// -----------------------------------------------------------------------------
+/// Perform convolution of weighted image along x with truncation of kernel at boundary
+template <class TKernel = double>
+struct ConvolveWeightedImageInX : public VoxelFunction
+{
+  const TKernel *_Kernel;  ///< Convolution kernel
+  int            _Radius;  ///< Radius of kernel
+  int            _Offset1; ///< Image  component offset
+  int            _Offset2; ///< Weight component offset
+  int            _X;       ///< Number of voxels in x
+
+  ConvolveWeightedImageInX(const BaseImage *image, const TKernel *kernel,
+                           int size, int l1 = 0, int l2 = 0)
+  :
+    _Kernel(kernel), _Radius((size - 1) / 2),
+    _Offset1(l1 * image->NumberOfSpatialVoxels()),
+    _Offset2(l2 * image->NumberOfSpatialVoxels()),
+    _X(image->X())
+  {}
+
+  template <class T1, class T2, class T3>
+  void operator ()(int i, int, int, int, const T1 *in, const T2 *win, T3 *out) const
+  {
+    // Convolve l1-th vector component using l2-th weight
+    in += _Offset1, win += _Offset2, out += _Offset1;
+    // Go to start of input and end of kernel
+    i    -= _Radius;
+    in   -= _Radius;
+    win  -= _Radius;
+    int n = _Radius + _Radius/* + 1 - 1*/;
+    // Outside left boundary
+    if (i < 0) n += i, in -= i, win -= i, i = 0;
+    // Inside image domain
+    double w, acc = .0, sum = .0;
+    while (i < _X && n >= 0) {
+      w = static_cast<double>(*win) * static_cast<double>(_Kernel[n]);
+      acc += w * static_cast<double>(*in);
+      sum += w;
+      ++i, ++in, ++win, --n;
+    }
+    // Output result of convolution
+    acc = (sum > .0 ? acc / sum : .0);
+    *out = static_cast<T3>(acc);
+  }
+};
+
+// -----------------------------------------------------------------------------
+/// Perform convolution of weighted image along y with truncation of kernel at boundary
+template <class TKernel = double>
+struct ConvolveWeightedImageInY : public VoxelFunction
+{
+  const TKernel *_Kernel;  ///< Convolution kernel
+  int            _Radius;  ///< Radius of kernel
+  int            _Offset1; ///< Image  component offset
+  int            _Offset2; ///< Weight component offset
+  int            _X;       ///< Number of voxels in x
+  int            _Y;       ///< Number of voxels in y
+
+  ConvolveWeightedImageInY(const BaseImage *image, const TKernel *kernel, int size, int l1 = 0, int l2 = 0)
+  :
+    _Kernel(kernel), _Radius((size - 1) / 2),
+    _Offset1(l1 * image->NumberOfSpatialVoxels()),
+    _Offset2(l2 * image->NumberOfSpatialVoxels()),
+    _X(image->X()), _Y(image->Y())
+  {}
+
+  template <class T1, class T2, class T3>
+  void operator ()(int, int j, int, int, const T1 *in, const T2 *win, T3 *out) const
+  {
+    // Convolve l1-th vector component using l2-th weight
+    in += _Offset1, win += _Offset2, out += _Offset1;
+    // Go to start of input and end of kernel
+    j    -= _Radius;
+    in   -= _Radius * _X;
+    win  -= _Radius * _X;
+    int n = _Radius + _Radius/* + 1 - 1*/;
+    // Outside left boundary
+    if (j < 0) n += j, in -= j * _X, win -= j * _X, j = 0;
+    // Inside image domain
+    double w, acc = .0, sum = .0;
+    while (j < _Y && n >= 0) {
+      w = static_cast<double>(_Kernel[n]) * static_cast<double>(*win);
+      acc += w * static_cast<double>(*in);
+      sum += w;
+      ++j, in += _X, win += _X, --n;
+    }
+    // Output result of convolution
+    acc = (sum > .0 ? acc / sum : .0);
+    *out = static_cast<T3>(acc);
+  }
+};
+
+// -----------------------------------------------------------------------------
+/// Perform convolution of weighted image along z with truncation of kernel at boundary
+template <class TKernel = double>
+struct ConvolveWeightedImageInZ : public VoxelFunction
+{
+  const TKernel *_Kernel;  ///< Convolution kernel
+  int            _Radius;  ///< Radius of kernel
+  int            _Offset1; ///< Image  component offset
+  int            _Offset2; ///< Weight component offset
+  int            _XY;      ///< Number of voxels in slice (nx * ny)
+  int            _Z;       ///< Number of voxels in z
+
+  ConvolveWeightedImageInZ(const BaseImage *image, const TKernel *kernel, int size, int l1 = 0, int l2 = 0)
+  :
+    _Kernel(kernel), _Radius((size - 1) / 2),
+    _Offset1(l1 * image->NumberOfSpatialVoxels()),
+    _Offset2(l2 * image->NumberOfSpatialVoxels()),
+    _XY(image->X() * image->Y()), _Z(image->Z())
+  {}
+
+  template <class T1, class T2, class T3>
+  void operator ()(int, int, int k, int, const T1 *in, const T2 *win, T3 *out) const
+  {
+    // Convolve l1-th vector component using l2-th weight
+    in += _Offset1, win += _Offset2, out += _Offset1;
+    // Go to start of input and end of kernel
+    k    -= _Radius;
+    in   -= _Radius * _XY;
+    win  -= _Radius * _XY;
+    int n = _Radius + _Radius/* + 1 - 1*/;
+    // Outside left boundary
+    if (k < 0) n += k, in -= k * _XY, win -= k * _XY, k = 0;
+    // Inside image domain
+    double w, acc = .0, sum = .0;
+    while (k < _Z && n >= 0) {
+      w = static_cast<double>(_Kernel[n]) * static_cast<double>(*win);
+      acc += w * static_cast<double>(*in);
+      sum += w;
+      ++k, in += _XY, win += _XY, --n;
+    }
+    // Output result of convolution
+    acc = (sum > .0 ? acc / sum : .0);
+    *out = static_cast<T3>(acc);
+  }
+};
+
+// -----------------------------------------------------------------------------
+/// Perform convolution of weighted image along t with truncation of kernel at boundary
+template <class TKernel = double>
+struct ConvolveWeightedImageInT : public VoxelFunction
+{
+  const TKernel *_Kernel; ///< Convolution kernel
+  int            _Radius; ///< Radius of kernel
+  int            _XYZ;    ///< Number of voxels in volume (nx * ny * nz)
+  int            _T;      ///< Number of voxels in t
+
+  ConvolveWeightedImageInT(const BaseImage *image, const TKernel *kernel, int size)
+  :
+    _Kernel(kernel), _Radius((size - 1) / 2),
+    _XYZ(image->X() * image->Y() * image->Z()), _T(image->T())
+  {}
+
+  template <class T1, class T2, class T3>
+  void operator ()(int, int, int, int l, const T1 *in, const T2 *win, T3 *out) const
+  {
+    // Go to start of input and end of kernel
+    l    -= _Radius;
+    in   -= _Radius * _XYZ;
+    win  -= _Radius * _XYZ;
+    int n = _Radius + _Radius/* + 1 - 1*/;
+    // Outside left boundary
+    if (l < 0) n += l, in -= l * _XYZ, win -= l * _XYZ, l = 0;
+    // Inside image domain
+    double w, acc = .0, sum = .0;
+    while (l < _T && n >= 0) {
+      w = static_cast<double>(_Kernel[n]) * static_cast<double>(*win);
+      acc += w * static_cast<double>(*in);
+      sum += w;
+      ++l, in += _XYZ, win += _XYZ, --n;
+    }
+    // Output result of convolution
+    acc = (sum > .0 ? acc / sum : .0);
+    *out = static_cast<T3>(acc);
+  }
+};
+
+// =============================================================================
 // Convolve at truncated image foreground with 1D kernel
 // =============================================================================


More tweaks..

More tweaks..

git-svn-id: 620571fa9b4bd0cbce9a0cf901e91ef896adbf27@4369 d073be05-634f-4543-b044-5fe20cf6d1d6

--- src/pextlib1.0/xinstall.c
+++ src/pextlib1.0/xinstall.c
@@ -265,6 +265,13 @@
 			Tcl_SetResult(interp, errmsg, TCL_VOLATILE);
 			return TCL_ERROR;
 		}
+		else if (verbose) {
+			char msg[255];
+
+			snprintf(msg, sizeof msg, "%s: chdir(%s)\n",
+				 funcname, curdir);
+			ui_info(interp, msg);
+		}
 	}

 	/* get group and owner id's */


Rename PS_SignalHandler* types to EventHandler*

--- unix/events.c
+++ unix/events.c
@@ -9,23 +9,23 @@
 typedef struct {
     Tcl_Interp *interp;
     Tcl_Obj *cmdObj;
-} PS_SignalHandler;
+} EventHandler;

 typedef struct {
     int initialized;
     SignalMap map;
-} PS_SignalHandlers;
+} EventHandlers;

 static Tcl_ThreadDataKey handlersKey;

 static void DeleteThreadEvents (int signum);
-static PS_SignalHandler * GetSignalHandler(int signum);
-
-static
-PS_SignalHandlers*
+static EventHandler * GetSignalHandler(int signum);
+
+static
+EventHandlers*
 AllocHandlers (void)
 {
-    PS_SignalHandlers *handlersPtr;
+    EventHandlers *handlersPtr;

     handlersPtr = Tcl_GetThreadData(&handlersKey, sizeof(*handlersPtr));

@@ -33,20 +33,20 @@
 }

 static
-PS_SignalHandlers*
+EventHandlers*
 GetHandlers (void)
 {
     return Tcl_GetThreadData(&handlersKey, 0);
 }

 static
-PS_SignalHandler*
+EventHandler*
 CreateSignalHandler (void)
 {
-    PS_SignalHandler *handlerPtr;
+    EventHandler *handlerPtr;
     Tcl_Obj *cmdObj;

-    handlerPtr = (PS_SignalHandler*) ckalloc(sizeof(PS_SignalHandler));
+    handlerPtr = (EventHandler*) ckalloc(sizeof(EventHandler));

     handlerPtr->interp = NULL;

@@ -60,7 +60,7 @@
 static
 void
 FreeSignalHandler (
-    PS_SignalHandler *handlerPtr
+    EventHandler *handlerPtr
     )
 {
     Tcl_DecrRefCount(handlerPtr->cmdObj);
@@ -78,7 +78,7 @@
     )
 {
     SignalEvent *sigEvPtr;
-    PS_SignalHandler *handlerPtr;
+    EventHandler *handlerPtr;
     Tcl_Interp *interp;
     Tcl_Obj *cmdObj;
     int signum, code;
@@ -131,11 +131,11 @@
     ClientData clientData
     )
 {
-    PS_SignalHandlers *handlersPtr;
-    PS_SignalHandler *handlerPtr;
+    EventHandlers *handlersPtr;
+    EventHandler *handlerPtr;
     SignalMapSearch iterator;

-    handlersPtr = (PS_SignalHandlers*) clientData;
+    handlersPtr = (EventHandlers*) clientData;

     handlerPtr = FirstSigMapEntry(&handlersPtr->map, &iterator);
     while (handlerPtr != NULL) {
@@ -150,7 +150,7 @@
 void
 InitEventHandlers (void)
 {
-    PS_SignalHandlers *handlersPtr;
+    EventHandlers *handlersPtr;

     handlersPtr = AllocHandlers();
     if (handlersPtr->initialized) return;
@@ -168,7 +168,7 @@
 static
 void
 Original_SetEventHandler (
-    PS_SignalHandler *handlerPtr,
+    EventHandler *handlerPtr,
     Tcl_Interp *interp,
     Tcl_Obj *newCmdObj
     )
@@ -176,7 +176,7 @@
     int len;
     Tcl_Obj *cmdObj;
     const char *newCmdPtr;
-    PS_SignalHandlers *handlersPtr;
+    EventHandlers *handlersPtr;

     handlersPtr = GetHandlers();

@@ -231,8 +231,8 @@
     Tcl_Obj *newCmdObj
     )
 {
-    PS_SignalHandlers *handlersPtr;
-    PS_SignalHandler *handlerPtr;
+    EventHandlers *handlersPtr;
+    EventHandler *handlerPtr;
     SignalMapEntry *entryPtr;
     int isnew;

@@ -263,7 +263,7 @@
     int signum
     )
 {
-    PS_SignalHandlers *handlersPtr;
+    EventHandlers *handlersPtr;
     SignalMapEntry *entryPtr;

     handlersPtr = GetHandlers();
@@ -282,7 +282,7 @@
     int signum
     )
 {
-    PS_SignalHandler *handlerPtr;
+    EventHandler *handlerPtr;

     handlerPtr  = GetSignalHandler(signum);
     if (handlerPtr == NULL) {
@@ -325,11 +325,11 @@

 static
-PS_SignalHandler *
+EventHandler *
 GetSignalHandler(
     int signum)
 {
-    PS_SignalHandlers *handlersPtr;
+    EventHandlers *handlersPtr;
     SignalMapEntry *entryPtr;

     handlersPtr = GetHandlers();


Cleanup of the ContikiMAC code; removed the old an unused announcement code

--- core/net/mac/contikimac.c
+++ core/net/mac/contikimac.c
@@ -40,24 +40,18 @@
  *         Joakim Eriksson <joakime@sics.se>
  */

-#include "net/netstack.h"
+#include "contiki-conf.h"
 #include "dev/leds.h"
 #include "dev/radio.h"
 #include "dev/watchdog.h"
 #include "lib/random.h"
 #include "net/mac/contikimac.h"
+#include "net/netstack.h"
 #include "net/rime.h"
 #include "sys/compower.h"
 #include "sys/pt.h"
 #include "sys/rtimer.h"

-
-/*#include "cooja-debug.h"*/
-#include "contiki-conf.h"
-
-#ifdef EXPERIMENT_SETUP
-#include "experiment-setup.h"
-#endif

 #include <string.h>

@@ -81,15 +75,6 @@
 #define WITH_PHASE_OPTIMIZATION 0
 #endif

-struct announcement_data {
-  uint16_t id;
-  uint16_t value;
-};
-
-/* The maximum number of announcements in a single announcement
-   message - may need to be increased in the future. */
-#define ANNOUNCEMENT_MAX 10
-
 #if WITH_CONTIKIMAC_HEADER
 #define CONTIKIMAC_ID 0x00

@@ -99,20 +84,6 @@
 };
 #endif /* WITH_CONTIKIMAC_HEADER */

-/* The structure of the announcement messages. */
-struct announcement_msg {
-  uint8_t announcement_magic[2];
-  uint16_t num;
-  struct announcement_data data[ANNOUNCEMENT_MAX];
-};
-
-#define ANNOUNCEMENT_MAGIC1 0xAD
-#define ANNOUNCEMENT_MAGIC2 0xAD
-
-/* The length of the header of the announcement message, i.e., the
-   "num" field in the struct. */
-#define ANNOUNCEMENT_MSG_HEADERLEN (sizeof(uint16_t) * 2)
-
 #ifdef CONTIKIMAC_CONF_CYCLE_TIME
 #define CYCLE_TIME (CONTIKIMAC_CONF_CYCLE_TIME)
 #else
@@ -179,19 +150,6 @@
    by two consecutive CCA checks, and here is where we define this
    shortest size. */
 #define SHORTEST_PACKET_SIZE               43
-
-
-
-/* The cycle time for announcements. */
-#ifdef ANNOUNCEMENT_CONF_PERIOD
-#define ANNOUNCEMENT_PERIOD ANNOUNCEMENT_CONF_PERIOD
-#else /* ANNOUNCEMENT_CONF_PERIOD */
-#define ANNOUNCEMENT_PERIOD 1 * CLOCK_SECOND
-#endif /* ANNOUNCEMENT_CONF_PERIOD */
-
-/* The time before sending an announcement within one announcement
-   cycle. */
-#define ANNOUNCEMENT_TIME (random_rand() % (ANNOUNCEMENT_PERIOD))

 #define ACK_LEN 3
@@ -216,13 +174,6 @@
 #define PRINTDEBUG(...)
 #endif

-#if CONTIKIMAC_CONF_ANNOUNCEMENTS
-/* Timers for keeping track of when to send announcements. */
-static struct ctimer announcement_cycle_ctimer, announcement_ctimer;
-
-static int announcement_radio_txpower;
-#endif /* CONTIKIMAC_CONF_ANNOUNCEMENTS */
-
 /* Flag that is used to keep track of whether or not we are snooping
    for announcements from neighbors. */
 static volatile uint8_t is_snooping;
@@ -288,8 +239,7 @@
 off(void)
 {
   if(contikimac_is_on && radio_is_on != 0 && /*is_streaming == 0 &&*/
-     contikimac_keep_radio_on == 0
-     /* && is_snooping == 0*/) {
+     contikimac_keep_radio_on == 0) {
     radio_is_on = 0;
     NETSTACK_RADIO.off();
   }
@@ -315,6 +265,7 @@
     }
   }
 }
+/*---------------------------------------------------------------------------*/
 static void
 schedule_powercycle_fixed(struct rtimer *t, rtimer_clock_t fixed_time)
 {
@@ -333,6 +284,7 @@
     }
   }
 }
+/*---------------------------------------------------------------------------*/
 static void
 powercycle_turn_radio_off(void)
 {
@@ -349,6 +301,7 @@
 #endif /* CONTIKIMAC_CONF_COMPOWER */
   }
 }
+/*---------------------------------------------------------------------------*/
 static void
 powercycle_turn_radio_on(void)
 {
@@ -356,6 +309,7 @@
     on();
   }
 }
+/*---------------------------------------------------------------------------*/
 static char
 powercycle(struct rtimer *t, void *ptr)
 {
@@ -385,10 +339,6 @@
         t0 = RTIMER_NOW();
         if(we_are_sending == 0) {
           powercycle_turn_radio_on();
-          /*          schedule_powercycle_fixed(t, t0 + CCA_CHECK_TIME);*/
-#if 0
-          while(RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + CCA_CHECK_TIME));
-#endif /* 0 */
           /* Check if a packet is seen in the air. If so, we keep the
              radio on for a while (LISTEN_TIME_AFTER_PACKET_DETECTED) to
              be able to receive the packet. We also continuously check
@@ -401,12 +351,10 @@
           }
           powercycle_turn_radio_off();
         }
-        /*        schedule_powercycle_fixed(t, t0 + CCA_CHECK_TIME + CCA_SLEEP_TIME);*/
         schedule_powercycle_fixed(t, RTIMER_NOW() + CCA_SLEEP_TIME);
-        /*        COOJA_DEBUG_STR("yield\n");*/
         PT_YIELD(&pt);
       }
-
+
       if(packet_seen) {
         static rtimer_clock_t start;
         static uint8_t silence_periods, periods;
@@ -465,87 +413,13 @@
             RTIMER_CLOCK_LT(RTIMER_NOW() - cycle_start, CYCLE_TIME - CHECK_TIME * 8));

     if(RTIMER_CLOCK_LT(RTIMER_NOW() - cycle_start, CYCLE_TIME - CHECK_TIME * 4)) {
-      /*      schedule_powercycle(t, CYCLE_TIME - (RTIMER_NOW() - cycle_start));*/
       schedule_powercycle_fixed(t, CYCLE_TIME + cycle_start);
-      /*      printf("cycle_start 0x%02x now 0x%02x wait 0x%02x\n",
-              cycle_start, RTIMER_NOW(), CYCLE_TIME - (RTIMER_NOW() - cycle_start));*/
       PT_YIELD(&pt);
     }
   }

   PT_END(&pt);
 }
-/*---------------------------------------------------------------------------*/
-#if CONTIKIMAC_CONF_ANNOUNCEMENTS
-static int
-parse_announcements(void)
-{
-  /* Parse incoming announcements */
-  struct announcement_msg adata;
-  const rimeaddr_t *from;
-  int i;
-
-  memcpy(&adata, packetbuf_dataptr(),
-         MIN(packetbuf_datalen(), sizeof(adata)));
-  from = packetbuf_addr(PACKETBUF_ADDR_SENDER);
-
-  /*  printf("%d.%d: probe from %d.%d with %d announcements\n",
-     rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
-     from->u8[0], from->u8[1], adata.num); */
-  /*  for(i = 0; i < packetbuf_datalen(); ++i) {
-     printf("%02x ", ((uint8_t *)packetbuf_dataptr())[i]);
-     }
-     printf("\n"); */
-
-  if(adata.num / sizeof(struct announcement_data) > sizeof(struct announcement_msg)) {
-    /* Sanity check. The number of announcements is too large -
-       corrupt packet has been received. */
-    return 0;
-  }
-
-  for(i = 0; i < adata.num; ++i) {
-    /*    printf("%d.%d: announcement %d: %d\n",
-       rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
-       adata.data[i].id,
-       adata.data[i].value); */
-
-    announcement_heard(from, adata.data[i].id, adata.data[i].value);
-  }
-  return i;
-}
-/*---------------------------------------------------------------------------*/
-static int
-format_announcement(char *hdr)
-{
-  struct announcement_msg adata;
-  struct announcement *a;
-
-  /* Construct the announcements */
-  /*  adata = (struct announcement_msg *)hdr; */
-
-  adata.announcement_magic[0] = ANNOUNCEMENT_MAGIC1;
-  adata.announcement_magic[1] = ANNOUNCEMENT_MAGIC2;
-  adata.num = 0;
-  for(a = announcement_list();
-      a != NULL && adata.num < ANNOUNCEMENT_MAX;
-      a = a->next) {
-    if(a->has_value) {
-      adata.data[adata.num].id = a->id;
-      adata.data[adata.num].value = a->value;
-      adata.num++;
-    }
-  }
-
-  memcpy(hdr, &adata, sizeof(struct announcement_msg));
-
-  if(adata.num > 0) {
-    return ANNOUNCEMENT_MSG_HEADERLEN +
-      sizeof(struct announcement_data) * adata.num;
-  } else {
-    return 0;
-  }
-}
-#endif /* CONTIKIMAC_CONF_ANNOUNCEMENTS */
 /*---------------------------------------------------------------------------*/
 static int
 broadcast_rate_drop(void)
@@ -593,7 +467,6 @@
     return MAC_TX_ERR_FATAL;
   }

-
   packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &rimeaddr_node_addr);
   if(rimeaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &rimeaddr_null)) {
     is_broadcast = 1;
@@ -924,18 +797,6 @@
                      &rimeaddr_null))) {
       /* This is a regular packet that is destined to us or to the
          broadcast address. */
-
-#if CONTIKIMAC_CONF_ANNOUNCEMENTS
-      {
-        struct announcement_msg *hdr = packetbuf_dataptr();
-        uint8_t magic[2];
-        memcpy(magic, hdr->announcement_magic, 2);
-        if(magic[0] == ANNOUNCEMENT_MAGIC1 &&
-           magic[1] == ANNOUNCEMENT_MAGIC2) {
-          parse_announcements();
-        }
-      }
-#endif /* CONTIKIMAC_CONF_ANNOUNCEMENTS */

 #if WITH_PHASE_OPTIMIZATION
       /* If the sender has set its pending flag, it has its radio
@@ -993,120 +854,6 @@
   }
 }
 /*---------------------------------------------------------------------------*/
-#if CONTIKIMAC_CONF_ANNOUNCEMENTS
-static void
-send_announcement(void *ptr)
-{
-  int announcement_len;
-  int transmit_len;
-#if WITH_CONTIKIMAC_HEADER
-  struct hdr *chdr;
-#endif /* WITH_CONTIKIMAC_HEADER */
-
-  /* Set up the probe header. */
-  packetbuf_clear();
-  announcement_len = format_announcement(packetbuf_dataptr());
-
-  if(announcement_len > 0) {
-    packetbuf_set_datalen(announcement_len);
-
-    packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &rimeaddr_node_addr);
-    packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &rimeaddr_null);
-    packetbuf_set_attr(PACKETBUF_ATTR_RADIO_TXPOWER,
-                       announcement_radio_txpower);
-#if WITH_CONTIKIMAC_HEADER
-    transmit_len = packetbuf_totlen();
-    if(packetbuf_hdralloc(sizeof(struct hdr)) == 0) {
-      /* Failed to allocate space for contikimac header */
-      PRINTF("contikimac: send announcement failed, too large header\n");
-      return;
-    }
-    chdr = packetbuf_hdrptr();
-    chdr->id = CONTIKIMAC_ID;
-    chdr->len = transmit_len;
-#endif /* WITH_CONTIKIMAC_HEADER */
-
-    if(NETSTACK_FRAMER.create()) {
-      rtimer_clock_t t;
-      int i, collisions;
-      we_are_sending = 1;
-
-      /* Make sure that the packet is longer or equal to the shorest
-         packet length. */
-      transmit_len = packetbuf_totlen();
-      if(transmit_len < SHORTEST_PACKET_SIZE) {
-#if 0
-        /* Pad with zeroes */
-        uint8_t *ptr;
-        ptr = packetbuf_dataptr();
-        memset(ptr + packetbuf_datalen(), 0, SHORTEST_PACKET_SIZE - transmit_len);
-#endif
-
-        PRINTF("contikimac: shorter than shortest (%d)\n", packetbuf_totlen());
-        transmit_len = SHORTEST_PACKET_SIZE;
-      }
-
-      collisions = 0;
-      /* Check for collisions */
-      for(i = 0; i < CCA_COUNT_MAX; ++i) {
-        t = RTIMER_NOW();
-        on();
-        while(RTIMER_CLOCK_LT(RTIMER_NOW(), t + CCA_CHECK_TIME));
-
-        if(NETSTACK_RADIO.channel_clear() == 0) {
-          collisions++;
-          off();
-          break;
-        }
-        off();
-        while(RTIMER_CLOCK_LT(RTIMER_NOW(), t + CCA_SLEEP_TIME + CCA_CHECK_TIME)) { }
-
-      }
-
-      if(collisions == 0) {
-
-        NETSTACK_RADIO.prepare(packetbuf_hdrptr(), transmit_len);
-
-        NETSTACK_RADIO.transmit(transmit_len);
-        t = RTIMER_NOW();
-        while(RTIMER_CLOCK_LT(RTIMER_NOW(), t + INTER_PACKET_INTERVAL)) { }
-
-        NETSTACK_RADIO.transmit(transmit_len);
-      }
-      we_are_sending = 0;
-    }
-  }
-}
-/*---------------------------------------------------------------------------*/
-static void
-cycle_announcement(void *ptr)
-{
-  ctimer_set(&announcement_ctimer, ANNOUNCEMENT_TIME,
-             send_announcement, NULL);
-  ctimer_set(&announcement_cycle_ctimer, ANNOUNCEMENT_PERIOD,
-             cycle_announcement, NULL);
-  if(is_snooping > 0) {
-    is_snooping--;
-    /*    printf("is_snooping %d\n", is_snooping); */
-  }
-}
-/*---------------------------------------------------------------------------*/
-static void
-listen_callback(int periods)
-{
-  printf("Snoop\n");
-  is_snooping = periods + 1;
-}
-#endif /* CONTIKIMAC_CONF_ANNOUNCEMENTS */
-/*---------------------------------------------------------------------------*/
-void
-contikimac_set_announcement_radio_txpower(int txpower)
-{
-#if CONTIKIMAC_CONF_ANNOUNCEMENTS
-  announcement_radio_txpower = txpower;
-#endif /* CONTIKIMAC_CONF_ANNOUNCEMENTS */
-}
-/*---------------------------------------------------------------------------*/
 static void
 init(void)
 {
@@ -1121,11 +868,6 @@
   phase_init(&phase_list);
 #endif /* WITH_PHASE_OPTIMIZATION */

-#if CONTIKIMAC_CONF_ANNOUNCEMENTS
-  announcement_register_listen_callback(listen_callback);
-  ctimer_set(&announcement_cycle_ctimer, ANNOUNCEMENT_TIME,
-             cycle_announcement, NULL);
-#endif /* CONTIKIMAC_CONF_ANNOUNCEMENTS */
 }
 /*---------------------------------------------------------------------------*/
 static int


unix/modjni: Convert to mp_rom_map_elem_t.

--- unix/modjni.c
+++ unix/modjni.c
@@ -168,9 +168,9 @@
     return call_method(self->cls, NULL, methods, true, n_args, args);
 }

-STATIC const mp_map_elem_t jclass_locals_dict_table[] = {
-//    { MP_OBJ_NEW_QSTR(MP_QSTR_get), (mp_obj_t)&ffivar_get_obj },
-//    { MP_OBJ_NEW_QSTR(MP_QSTR_set), (mp_obj_t)&ffivar_set_obj },
+STATIC const mp_rom_map_elem_t jclass_locals_dict_table[] = {
+//    { MP_ROM_QSTR(MP_QSTR_get), MP_ROM_PTR(&ffivar_get_obj) },
+//    { MP_ROM_QSTR(MP_QSTR_set), MP_ROM_PTR(&ffivar_set_obj) },
 };

 STATIC MP_DEFINE_CONST_DICT(jclass_locals_dict, jclass_locals_dict_table);
@@ -181,7 +181,7 @@
     .print = jclass_print,
     .attr = jclass_attr,
     .call = jclass_call,
-    .locals_dict = (mp_obj_t)&jclass_locals_dict,
+    .locals_dict = (mp_obj_dict_t*)&jclass_locals_dict,
 };

 STATIC mp_obj_t new_jclass(jclass jc) {
@@ -331,7 +331,7 @@
     .attr = jobject_attr,
     .subscr = jobject_subscr,
     .getiter = subscr_getiter,
-//    .locals_dict = (mp_obj_t)&jobject_locals_dict,
+//    .locals_dict = (mp_obj_dict_t*)&jobject_locals_dict,
 };

 STATIC mp_obj_t new_jobject(jobject jo) {
@@ -578,7 +578,7 @@
     .print = jmethod_print,
     .call = jmethod_call,
 //    .attr = jobject_attr,
-//    .locals_dict = (mp_obj_t)&jobject_locals_dict,
+//    .locals_dict = (mp_obj_dict_t*)&jobject_locals_dict,
 };

 #ifdef __ANDROID__
@@ -707,11 +707,11 @@
 }
 MP_DEFINE_CONST_FUN_OBJ_0(mod_jni_env_obj, mod_jni_env);

-STATIC const mp_map_elem_t mp_module_jni_globals_table[] = {
-    { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_jni) },
-    { MP_OBJ_NEW_QSTR(MP_QSTR_cls), (mp_obj_t)&mod_jni_cls_obj },
-    { MP_OBJ_NEW_QSTR(MP_QSTR_array), (mp_obj_t)&mod_jni_array_obj },
-    { MP_OBJ_NEW_QSTR(MP_QSTR_env), (mp_obj_t)&mod_jni_env_obj },
+STATIC const mp_rom_map_elem_t mp_module_jni_globals_table[] = {
+    { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_jni) },
+    { MP_ROM_QSTR(MP_QSTR_cls), MP_ROM_PTR(&mod_jni_cls_obj) },
+    { MP_ROM_QSTR(MP_QSTR_array), MP_ROM_PTR(&mod_jni_array_obj) },
+    { MP_ROM_QSTR(MP_QSTR_env), MP_ROM_PTR(&mod_jni_env_obj) },
 };

 STATIC MP_DEFINE_CONST_DICT(mp_module_jni_globals, mp_module_jni_globals_table);


Modified dio delay to be 0.5s after reset and switch over to dio_intmin after that. This is done so the sensors will get a response from DIS within 2 seconds and not having going through all the intermediate values (0.5s, 1s, 2s, 4s, 8s, 16s). This reduces bandwidth usage. DIO minimum interval should be set to 13 in configuration

--- core/net/rpl/rpl-timers.c
+++ core/net/rpl/rpl-timers.c
@@ -162,7 +162,14 @@
   } else {
     /* check if we need to double interval */
     if(instance->dio_intcurrent < instance->dio_intmin + instance->dio_intdoubl) {
-      instance->dio_intcurrent++;
+//      instance->dio_intcurrent++;
+      //if current interval is less than the minimum interval, set it to minimum interval.
+      //This is used to jump from DIO_INT_START to dio_intmin
+      if (instance->dio_intcurrent < instance->dio_intmin)
+	instance->dio_intcurrent = instance->dio_intmin;
+      else
+	instance->dio_intcurrent++;
+
       PRINTF("RPL: DIO Timer interval doubled %d\n", instance->dio_intcurrent);
     }
     new_dio_interval(instance);
@@ -183,17 +190,27 @@
 }
 /*---------------------------------------------------------------------------*/
 /* Resets the DIO timer in the instance to its minimal interval. */
+// DIO interval after reset. This is set to 9 or 2^9ms or 512ms to facilitate frequency scanning
+#define DIO_INT_START 9
 void
 rpl_reset_dio_timer(rpl_instance_t *instance)
 {
 #if !RPL_LEAF_ONLY
   /* Do not reset if we are already on the minimum interval,
      unless forced to do so. */
+/*
   if(instance->dio_intcurrent > instance->dio_intmin) {
     instance->dio_counter = 0;
     instance->dio_intcurrent = instance->dio_intmin;
     new_dio_interval(instance);
   }
+*/
+  if(instance->dio_intcurrent > DIO_INT_START) {
+    instance->dio_counter = 0;
+    instance->dio_intcurrent = DIO_INT_START;
+    new_dio_interval(instance);
+  }
+
 #if RPL_CONF_STATS
   rpl_stats.resets++;
 #endif /* RPL_CONF_STATS */


Sound interface params

Sound interface params

--- src/Defines.h
+++ src/Defines.h
@@ -1,7 +1,15 @@
 #ifndef DEFINES_H
 #define DEFINES_H
+
+#include <SDL2/SDL_mixer.h>

 const int FPS = 60;
 const int FRAMEDELTA = 1000.0f / FPS;

+#define SOUND_FREQUENCY 22050
+#define SOUND_FORMAT AUDIO_S16
+#define SOUND_CHANNELS 2
+#define SOUND_CHUNKSIZE 4096
+
+
 #endif // DEFINES_H


[1.11>master] [MERGE #5822 @dilijev] Update release/1.11 to version 1.11.3

Merge pull request #5822 from dilijev:v1-11-3


khan: thoughts in conn_cb

khan: thoughts in conn_cb

--- pkg/urbit/vere/io/khan.c
+++ pkg/urbit/vere/io/khan.c
@@ -86,6 +86,21 @@
 _khan_conn_cb(uv_stream_t* sem_u, c3_i tas_i)
 {
   // TODO interact
+  //
+  // There are four cases to think about here:
+  //
+  // 1. peek, runtime
+  // 2. poke, runtime
+  // 3. peek, arvo
+  // 4. poke, arvo
+  //
+  // For 1, we support a few simple text commands:
+  // ok - says "ok" (basic health test)
+  // dump - dumps runtime stat counters in simple machine/human-readable format
+  //
+  // There is not yet a use case for 2.
+  //
+  // For 3 and 4, we speak the language documented in the khan vane in arvo.
 }

 /* u3_khan(): initialize control plane socket.


runtime: update comment for the "extern register" variables g and m.

R=rsc, minux.ma, ality
CC=dave, golang-dev
http://codereview.appspot.com/6620050

--- src/pkg/runtime/runtime.h
+++ src/pkg/runtime/runtime.h
@@ -82,19 +82,18 @@
 typedef struct	ParForThread	ParForThread;

 /*
- * per-cpu declaration.
+ * Per-CPU declaration.
+ *
  * "extern register" is a special storage class implemented by 6c, 8c, etc.
- * on machines with lots of registers, it allocates a register that will not be
- * used in generated code.  on the x86, it allocates a slot indexed by a
- * segment register.
+ * On the ARM, it is an actual register; elsewhere it is a slot in thread-
+ * local storage indexed by a segment register. See zasmhdr in
+ * src/cmd/dist/buildruntime.c for details, and be aware that the linker may
+ * make further OS-specific changes to the compiler's output. For example,
+ * 6l/linux rewrites 0(GS) as -16(FS).
  *
- * amd64: allocated downwards from R15
- * x86: allocated upwards from 0(GS)
- * arm: allocated downwards from R10
- *
- * every C file linked into a Go program must include runtime.h
- * so that the C compiler knows to avoid other uses of these registers.
- * the Go compilers know to avoid them.
+ * Every C file linked into a Go program must include runtime.h so that the
+ * C compiler (6c, 8c, etc.) knows to avoid other uses of these dedicated
+ * registers. The Go compiler (6g, 8g, etc.) knows to avoid them.
  */
 extern	register	G*	g;
 extern	register	M*	m;


modified test policy for no proof file

modified test policy for no proof file

--- platform/shell/command.c
+++ platform/shell/command.c
@@ -225,6 +225,7 @@
 // KonohaContext*est

 static FILE *stdlog;
+static int   stdlog_count = 0;

 static const char* TEST_begin(kinfotag_t t)
 {
@@ -238,6 +239,7 @@

 static int TEST_vprintf(const char *fmt, va_list ap)
 {
+	stdlog_count++;
 	return vfprintf(stdlog, fmt, ap);
 }

@@ -276,6 +278,7 @@
 static int KonohaContext_test(KonohaContext *kctx, const char *testname)
 {
 	int ret = 1; //FAILED
+	int noproof = 0;
 	char script_file[256];
 	char correct_file[256];
 	char result_file[256];
@@ -283,9 +286,6 @@
 	PLATAPI snprintf_i(correct_file, 256, "%s.proof", script_file);
 	PLATAPI snprintf_i(result_file, 256,  "%s.tested", script_file);
 	FILE *fp = fopen(correct_file, "r");
-	if (fp == NULL) {
-		fprintf(stdout, "no proof file: %s\n", testname);
-	}
 	stdlog = fopen(result_file, "w");
 	konoha_load((KonohaContext*)kctx, script_file);
 	fprintf(stdlog, "Q.E.D.\n");   // Q.E.D.
@@ -303,6 +303,10 @@
 		}
 		fclose(fp);
 		fclose(fp2);
+	}
+	else {
+		if(stdlog_count > 0) return 0; // OK
+		fprintf(stdout, "no proof file: %s\n", testname);
 	}
 	return ret;
 }


COMP: add sstream to python wrappers, this should fix AIX

--- Wrapping/vtkWrapPython.c
+++ Wrapping/vtkWrapPython.c
@@ -3245,7 +3245,8 @@

   /* lots of important utility functions are defined in vtkPythonUtil.h */
   fprintf(fp,
-          "#include \"vtkPythonUtil.h\"\n");
+          "#include \"vtkPythonUtil.h\"\n"
+          "#include <vtksys/ios/sstream>\n");

   /* vtkPythonCommand is needed to wrap vtkObject.h */
   if (strcmp("vtkObject", data->ClassName) == 0)