fixup: make everything const

fixup: make everything const

--- test/sergut/marshaller/TestSupportClassesMarshaller.h
+++ test/sergut/marshaller/TestSupportClassesMarshaller.h
@@ -32,8 +32,8 @@

   virtual
   SomeMoreComplexTestData
-  constructSomeMoreComplexTestData(std::uint8_t hour1, const std::uint8_t minute1, const std::uint8_t& second1,
-                                   char someLetter, std::uint16_t someUnsignedShortInt, const Time& time2) const = 0;
+  constructSomeMoreComplexTestData(const std::uint8_t hour1, const std::uint8_t minute1, const std::uint8_t second1,
+                                   const char someLetter, const std::uint16_t someUnsignedShortInt, const Time& time2) const = 0;
   virtual
   uint32_t sumUpSomeData(std::uint32_t someUInt, const Time& t, uint32_t otherUInt) const = 0;

@@ -72,13 +72,11 @@
   }

   SomeMoreComplexTestData
-  constructSomeMoreComplexTestData(std::uint8_t hour1, const std::uint8_t minute1, const std::uint8_t& second1,
-                                   char someLetter, std::uint16_t someUnsignedShortInt,
+  constructSomeMoreComplexTestData(const std::uint8_t hour1, const std::uint8_t minute1, const std::uint8_t second1,
+                                   const char someLetter, const std::uint16_t someUnsignedShortInt,
                                    const Time& time2) const override
   {
-    return call<SomeMoreComplexTestData>("constructSomeMoreComplexTestData",
-                                         hour1, minute1, second1, someLetter,
-                                         someUnsignedShortInt, time2);
+    return call<SomeMoreComplexTestData>("constructSomeMoreComplexTestData", hour1, minute1, second1, someLetter, someUnsignedShortInt, time2);
   }
   uint32_t sumUpSomeData(std::uint32_t someUInt, const Time& t, uint32_t otherUInt) const override
   {
@@ -112,8 +110,8 @@
   }

   SomeMoreComplexTestData
-  constructSomeMoreComplexTestData(std::uint8_t hour1, const std::uint8_t minute1, const std::uint8_t& second1,
-                                   char someLetter, std::uint16_t someUnsignedShortInt,
+  constructSomeMoreComplexTestData(const std::uint8_t hour1, const std::uint8_t minute1, const std::uint8_t second1,
+                                   const char someLetter, const std::uint16_t someUnsignedShortInt,
                                    const Time& time2) const override
   {
     return SomeMoreComplexTestData(Time(hour1, minute1, second1), someLetter,


Rename ccncat to be ccnsimplecat and reimplement ccncat using ccn_fetch library.  Refs: #100291

error: pathspec 'csrc/cmd/ccnsimplecat.c' did not match any file(s) known to git

--- csrc/cmd/ccnsimplecat.c
+++ csrc/cmd/ccnsimplecat.c
@@ -0,0 +1,265 @@
+/**
+ * @file ccncat.c
+ * Reads streams at the given CCNx URIs and writes to stdout
+ *
+ * A CCNx command-line utility.
+ *
+ * Copyright (C) 2009, 2010 Palo Alto Research Center, Inc.
+ *
+ * This work is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ * This work is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details. You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <ccn/ccn.h>
+#include <ccn/charbuf.h>
+#include <ccn/uri.h>
+
+/**
+ * Provide usage hints for the program and then exit with a non-zero status.
+ */
+static void
+usage(const char *progname)
+{
+    fprintf(stderr,
+            "%s [-a] ccnx:/a/b ...\n"
+            "   Reads streams at"
+            " the given ccn URIs and writes to stdout\n"
+            "   -a - allow stale data\n",
+            progname);
+    exit(1);
+}
+
+struct mydata {
+    int *done;
+    int allow_stale;
+};
+
+/**
+ * Construct a template suitable for use with ccn_express_interest
+ * indicating at least one suffix component, and stale data if so
+ * requested.
+ */
+struct ccn_charbuf *
+make_template(struct mydata *md, struct ccn_upcall_info *info)
+{
+    struct ccn_charbuf *templ = ccn_charbuf_create();
+    ccn_charbuf_append_tt(templ, CCN_DTAG_Interest, CCN_DTAG);
+    ccn_charbuf_append_tt(templ, CCN_DTAG_Name, CCN_DTAG);
+    ccn_charbuf_append_closer(templ); /* </Name> */
+    // XXX - use pubid if possible
+    ccn_charbuf_append_tt(templ, CCN_DTAG_MinSuffixComponents, CCN_DTAG);
+    ccnb_append_number(templ, 1);
+    ccn_charbuf_append_closer(templ); /* </MinSuffixComponents> */
+    if (md->allow_stale) {
+        ccn_charbuf_append_tt(templ, CCN_DTAG_AnswerOriginKind, CCN_DTAG);
+        ccnb_append_number(templ, CCN_AOK_DEFAULT | CCN_AOK_STALE);
+        ccn_charbuf_append_closer(templ); /* </AnswerOriginKind> */
+    }
+    ccn_charbuf_append_closer(templ); /* </Interest> */
+    return(templ);
+}
+
+/**
+ * Handle the incoming content messages. Extracts the data, and
+ * requests the next block in sequence if the received block was
+ * not the final one.
+ */
+enum ccn_upcall_res
+incoming_content(struct ccn_closure *selfp,
+                 enum ccn_upcall_kind kind,
+                 struct ccn_upcall_info *info)
+{
+    struct ccn_charbuf *name = NULL;
+    struct ccn_charbuf *templ = NULL;
+    const unsigned char *ccnb = NULL;
+    size_t ccnb_size = 0;
+    const unsigned char *data = NULL;
+    size_t data_size = 0;
+    size_t written;
+    const unsigned char *ib = NULL; /* info->interest_ccnb */
+    struct ccn_indexbuf *ic = NULL;
+    int res;
+    struct mydata *md = selfp->data;
+
+    if (kind == CCN_UPCALL_FINAL) {
+        if (md != NULL) {
+            selfp->data = NULL;
+            free(md);
+            md = NULL;
+        }
+        return(CCN_UPCALL_RESULT_OK);
+    }
+    if (kind == CCN_UPCALL_INTEREST_TIMED_OUT)
+        return(CCN_UPCALL_RESULT_REEXPRESS);
+    if (kind == CCN_UPCALL_CONTENT_UNVERIFIED)
+        return(CCN_UPCALL_RESULT_VERIFY);
+    if (kind != CCN_UPCALL_CONTENT)
+        return(CCN_UPCALL_RESULT_ERR);
+    if (md == NULL)
+        selfp->data = md = calloc(1, sizeof(*md));
+    ccnb = info->content_ccnb;
+    ccnb_size = info->pco->offset[CCN_PCO_E];
+    ib = info->interest_ccnb;
+    ic = info->interest_comps;
+    res = ccn_content_get_value(ccnb, ccnb_size, info->pco, &data, &data_size);
+    if (res < 0) abort();
+    if (info->pco->type != CCN_CONTENT_DATA) {
+        /* For us this is spam. For now, give up. */
+        fprintf(stderr, "*** spammed at block %d\n", (int)selfp->intdata);
+        exit(1);
+    }
+
+    /* OK, we will accept this block. */
+    if (data_size == 0)
+        *(md->done) = 1;
+    else {
+        written = fwrite(data, data_size, 1, stdout);
+        if (written != 1)
+            exit(1);
+    }
+    // XXX The test below should get refactored into the library
+    if (info->pco->offset[CCN_PCO_B_FinalBlockID] !=
+        info->pco->offset[CCN_PCO_E_FinalBlockID]) {
+        const unsigned char *finalid = NULL;
+        size_t finalid_size = 0;
+        const unsigned char *nameid = NULL;
+        size_t nameid_size = 0;
+        struct ccn_indexbuf *cc = info->content_comps;
+        ccn_ref_tagged_BLOB(CCN_DTAG_FinalBlockID, ccnb,
+                            info->pco->offset[CCN_PCO_B_FinalBlockID],
+                            info->pco->offset[CCN_PCO_E_FinalBlockID],
+                            &finalid,
+                            &finalid_size);
+        if (cc->n < 2) abort();
+        ccn_ref_tagged_BLOB(CCN_DTAG_Component, ccnb,
+                            cc->buf[cc->n - 2],
+                            cc->buf[cc->n - 1],
+                            &nameid,
+                            &nameid_size);
+        if (finalid_size == nameid_size &&
+              0 == memcmp(finalid, nameid, nameid_size))
+            *(md->done) = 1;
+    }
+
+    if (*(md->done)) {
+        ccn_set_run_timeout(info->h, 0);
+        return(CCN_UPCALL_RESULT_OK);
+    }
+
+    /* Ask for the next fragment */
+    name = ccn_charbuf_create();
+    ccn_name_init(name);
+    if (ic->n < 2) abort();
+    res = ccn_name_append_components(name, ib, ic->buf[0], ic->buf[ic->n - 2]);
+    if (res < 0) abort();
+    ccn_name_append_numeric(name, CCN_MARKER_SEQNUM, ++(selfp->intdata));
+    templ = make_template(md, info);
+
+    res = ccn_express_interest(info->h, name, selfp, templ);
+    if (res < 0) abort();
+
+    ccn_charbuf_destroy(&templ);
+    ccn_charbuf_destroy(&name);
+
+    return(CCN_UPCALL_RESULT_OK);
+}
+
+/**
+ * Process options and then loop through command line CCNx URIs retrieving
+ * the data and writing it to stdout.
+ */
+int
+main(int argc, char **argv)
+{
+    struct ccn *ccn = NULL;
+    struct ccn_charbuf *name = NULL;
+    struct ccn_charbuf *templ = NULL;
+    struct ccn_closure *incoming = NULL;
+    const char *arg = NULL;
+    int i;
+    int res;
+    int opt;
+    struct mydata *mydata;
+    int allow_stale = 0;
+    int *done;
+    int exit_status = 0;
+
+    done = calloc(1, sizeof(*done));
+
+    while ((opt = getopt(argc, argv, "ha")) != -1) {
+        switch (opt) {
+            case 'a':
+                allow_stale = 1;
+                break;
+            case 'h':
+            default:
+                usage(argv[0]);
+        }
+    }
+    arg = argv[optind];
+    if (arg == NULL)
+        usage(argv[0]);
+    name = ccn_charbuf_create();
+    /* Check the args first */
+    for (i = optind; argv[i] != NULL; i++) {
+        name->length = 0;
+        res = ccn_name_from_uri(name, argv[i]);
+        if (res < 0) {
+            fprintf(stderr, "%s: bad ccn URI: %s\n", argv[0], argv[i]);
+            exit(1);
+        }
+    }
+    for (i = optind; (arg = argv[i]) != NULL; i++) {
+        *done = 0;
+        name->length = 0;
+        res = ccn_name_from_uri(name, arg);
+        ccn = ccn_create();
+        if (ccn_connect(ccn, NULL) == -1) {
+            perror("Could not connect to ccnd");
+            exit(1);
+        }
+        ccn_resolve_version(ccn, name, CCN_V_HIGHEST, 50);
+        ccn_name_append_numeric(name, CCN_MARKER_SEQNUM, 0);
+        incoming = calloc(1, sizeof(*incoming));
+        incoming->p = &incoming_content;
+        mydata = calloc(1, sizeof(*mydata));
+        mydata->allow_stale = allow_stale;
+        mydata->done = done;
+        incoming->data = mydata;
+        templ = make_template(mydata, NULL);
+        ccn_express_interest(ccn, name, incoming, templ);
+        ccn_charbuf_destroy(&templ);
+        /* Run a little while to see if there is anything there */
+        res = ccn_run(ccn, 200);
+        if ((!*done) && incoming->intdata == 0) {
+            fprintf(stderr, "%s: not found: %s\n", argv[0], arg);
+            res = -1;
+        }
+        /* We got something; run until end of data or somebody kills us */
+        while (res >= 0 && !*done) {
+            fflush(stdout);
+            res = ccn_run(ccn, 333);
+        }
+        if (res < 0)
+            exit_status = 1;
+        ccn_destroy(&ccn);
+        fflush(stdout);
+        free(incoming);
+        incoming = NULL;
+    }
+    ccn_charbuf_destroy(&name);
+    free(done);
+    exit(exit_status);
+}


Gave the tester an extra function

Gave the tester an extra function

--- tester.c
+++ tester.c
@@ -1,7 +1,13 @@
 #include <stdio.h>
+
+void do_work() {
+    printf("working ...\n");
+}

 int main(int argc, char** argv) {
     printf("Hiya :D\n");

+    do_work();
+
     return 0;
 }


Correct line continuation character placement

--- tester.h
+++ tester.h
@@ -32,7 +32,7 @@

 	#define OUTPUT_INIT {												\
 							hConsole = GetStdHandle(STD_OUTPUT_HANDLE);	\
-							SetConsoleTextAttribute(hConsole, 7);		\	/* Set the test colour to the default. */
+							SetConsoleTextAttribute(hConsole, 7);	/* Set the test colour to the default. */ \
 						}

 	#define OUTPUT_SUITE_START(suite_name) 	{printf("\nRunning %s test suite\n", (suite_name));}	/* Print out a notification of the start of the suite. */


Fixed bug @RouletteSelection.

Fixed bug @RouletteSelection.

--- src/common.c
+++ src/common.c
@@ -787,6 +787,7 @@
         while((accum[i] < prob) && (i < s->m)) i++;
         if(i) elem[j] = D[i-1].id;
         else elem[j] = D[i].id;
+        elem[j] = D[i].id;
     }

     free(D);


acl: Delay initializing default backend ACLs. This fixes a crash with LAYOUT=index.

--- src/plugins/acl/acl-backend.c
+++ src/plugins/acl/acl-backend.c
@@ -82,8 +82,6 @@
 	backend->default_aclmask =
 		acl_cache_mask_init(backend->cache, backend->pool,
 				    backend->default_rights);
-
-	backend->default_aclobj = acl_object_init_from_name(backend, "");
 	return backend;
 }

@@ -93,7 +91,8 @@

 	*_backend = NULL;

-	acl_object_deinit(&backend->default_aclobj);
+	if (backend->default_aclobj != NULL)
+		acl_object_deinit(&backend->default_aclobj);
 	acl_cache_deinit(&backend->cache);
 	backend->v.deinit(backend);
 }
@@ -161,6 +160,10 @@
 int acl_backend_get_default_rights(struct acl_backend *backend,
 				   const struct acl_mask **mask_r)
 {
+	if (backend->default_aclobj == NULL) {
+		backend->default_aclobj =
+			acl_object_init_from_name(backend, "");
+	}
 	if (backend->v.object_refresh_cache(backend->default_aclobj) < 0)
 		return -1;


doveadm acl debug: Compile fix for earlier change.

--- src/plugins/acl/doveadm-acl.c
+++ src/plugins/acl/doveadm-acl.c
@@ -341,14 +341,16 @@
 	struct acl_mailbox_list_context *iter;
 	struct acl_lookup_dict_iter *diter;
 	const char *const *rights, *name;
+	enum mail_flags private_flags_mask;
 	string_t *str;
 	int ret;

-	if (box->private_flags_mask == 0)
+	private_flags_mask = mailbox_get_private_flags_mask(box);
+	if (private_flags_mask == 0)
 		i_info("All message flags are shared across users in mailbox");
 	else {
 		str = t_str_new(64);
-		imap_write_flags(str, box->private_flags_mask, NULL);
+		imap_write_flags(str, private_flags_mask, NULL);
 		i_info("Per-user private flags in mailbox: %s", str_c(str));
 	}


Basic koch snowflake implemented

Basic koch snowflake implemented

--- koch_snowflake/koch_snowflake.c
+++ koch_snowflake/koch_snowflake.c
@@ -5,8 +5,8 @@
 #include "list.h"
 #include "SDL/SDL.h"

-#define WIDTH 500
-#define HEIGHT 375
+#define WIDTH 1024
+#define HEIGHT 600
 #define BPP 4
 #define DEPTH 32

@@ -42,6 +42,8 @@
     if (SDL_LockSurface(screen) < 0) return;
   }

+  SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
+
   while (start->next->next != NULL) {
     draw_line(screen, start->p, start->next->p, SDL_MapRGB(screen->format, rand()%255, rand()%255, rand()%255));
     start = start->next;
@@ -51,51 +53,110 @@
   SDL_Flip(screen);
 }

-int main(int argc, char* argv[])
+void iterate(node* n)
+{
+  point p1 = n->p;
+  point p2 = n->next->p;
+
+  int xlen = p2.x - p1.x;
+  int ylen = p2.y - p1.y;
+
+  point new;
+  new.x = p1.x + xlen / 3;
+  new.y = p1.y + ylen / 3;
+  node* current = list_insert(n, new);
+  new.x = p1.x + 2.0 * xlen / 3;
+  new.y = p1.y + 2.0 * ylen / 3;
+  list_insert(current, new);
+
+  int len = sqrt(xlen*xlen + ylen*ylen);
+  double theta = atan(ylen / xlen) + M_PI / 6;
+
+  int deltax = (len / 3.0) * sin(theta);
+  int deltay = (len / 3.0) * cos (theta);
+
+  if (p2.x < p1.x) {
+    deltax *= -1;
+    deltay *= -1;
+  }
+
+  new.x = current->p.x + deltax;
+  new.y = current->p.y - deltay;
+  list_insert(current, new);
+}
+
+list* generate(SDL_Surface* screen) {
+  point top, left, right;
+
+  list* ll = list_create();
+
+  top.y = 1.0 / 4 * screen->h - screen->h/12;
+  left.y = 3.0 / 4 * screen->h - screen->h/12;
+  right.y = left.y;
+
+  left.x = 1.0 /4 * screen->w;
+  right.x = 3.0 / 4 * screen->w;
+  top.x = screen->w / 2;
+
+
+  node* current = list_insert(ll->head, top);
+  current = list_insert(current, right);
+  current = list_insert(current, left);
+  current = list_insert(current, top);
+
+  return ll;
+}
+
+void wait_for_input()
+{
+  bool quit = false;
+  SDL_Event event;
+
+  while(!quit) {
+    SDL_PollEvent(&event);
+
+    switch (event.type) {
+    case SDL_QUIT:
+      quit = true;
+      break;
+    case SDL_KEYDOWN:
+      quit = true;
+      break;
+    }
+  }
+}
+
+int main()
 {
   SDL_Surface *screen;
-  SDL_Event event;
-  bool quit = false;

   srand(time(NULL));
   if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1;

-  if (!(screen = SDL_SetVideoMode(WIDTH, HEIGHT, DEPTH, SDL_HWSURFACE))) {
+  if (!(screen = SDL_SetVideoMode(WIDTH, HEIGHT, DEPTH, SDL_FULLSCREEN))) {
     SDL_Quit();
     return 1;
   }

-  point p1;
   node* current;
-  p1.x = 10;
-  p1.y = 10;
-
-  list* list = list_create();
+  list* list = generate(screen);
   int i;
-  current = list->head;
-  for (i = 0; i < 10000; i++) {
-    p1.x = rand() % screen->w;
-    p1.y = rand() % screen->h;
-    current = list_insert(current, p1);
-  }

   draw_screen(screen, list);
+  wait_for_input();

-  while(!quit) {
-    SDL_PollEvent(&event);
+  current = list->head->next;
+  for (i = 0; i < 4; i++) {

-      switch (event.type) {
-      case SDL_QUIT:
-	quit = true;
-	break;
-      case SDL_KEYDOWN:
-	if (event.key.keysym.sym == SDLK_q){
-	  quit = true;
-	}
-	break;
-      }
+    current = list->head->next;
+    while (current->next->next != NULL) {
+      current = current->next;
+      iterate(current->prev);
+    }
+    draw_screen(screen, list);
+    wait_for_input();
   }
-
+
   list_delete(list);

   SDL_Quit();


Allow the 'visitor' argument to 'perform_test_load()' to be NULL.  The
utility of this change will be made clearer in a subsequent patch when
perform_test_load()' does more than stream the AST.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@94556 91177308-0d34-0410-b5e6-96231b3b80d8

--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -303,29 +303,33 @@
 static int perform_test_load(CXIndex Idx, CXTranslationUnit TU,
                              const char *filter, const char *prefix,
                              CXCursorVisitor Visitor) {
-  enum CXCursorKind K = CXCursor_NotImplemented;
-  enum CXCursorKind *ck = &K;
-  VisitorData Data;

   if (prefix)
     FileCheckPrefix = prefix;
-
-  /* Perform some simple filtering. */
-  if (!strcmp(filter, "all") || !strcmp(filter, "local")) ck = NULL;
-  else if (!strcmp(filter, "category")) K = CXCursor_ObjCCategoryDecl;
-  else if (!strcmp(filter, "interface")) K = CXCursor_ObjCInterfaceDecl;
-  else if (!strcmp(filter, "protocol")) K = CXCursor_ObjCProtocolDecl;
-  else if (!strcmp(filter, "function")) K = CXCursor_FunctionDecl;
-  else if (!strcmp(filter, "typedef")) K = CXCursor_TypedefDecl;
-  else if (!strcmp(filter, "scan-function")) Visitor = FunctionScanVisitor;
-  else {
-    fprintf(stderr, "Unknown filter for -test-load-tu: %s\n", filter);
-    return 1;
-  }
-
-  Data.TU = TU;
-  Data.Filter = ck;
-  clang_visitChildren(clang_getTranslationUnitCursor(TU), Visitor, &Data);
+
+  if (Visitor) {
+    enum CXCursorKind K = CXCursor_NotImplemented;
+    enum CXCursorKind *ck = &K;
+    VisitorData Data;
+
+    /* Perform some simple filtering. */
+    if (!strcmp(filter, "all") || !strcmp(filter, "local")) ck = NULL;
+    else if (!strcmp(filter, "category")) K = CXCursor_ObjCCategoryDecl;
+    else if (!strcmp(filter, "interface")) K = CXCursor_ObjCInterfaceDecl;
+    else if (!strcmp(filter, "protocol")) K = CXCursor_ObjCProtocolDecl;
+    else if (!strcmp(filter, "function")) K = CXCursor_FunctionDecl;
+    else if (!strcmp(filter, "typedef")) K = CXCursor_TypedefDecl;
+    else if (!strcmp(filter, "scan-function")) Visitor = FunctionScanVisitor;
+    else {
+      fprintf(stderr, "Unknown filter for -test-load-tu: %s\n", filter);
+      return 1;
+    }
+
+    Data.TU = TU;
+    Data.Filter = ck;
+    clang_visitChildren(clang_getTranslationUnitCursor(TU), Visitor, &Data);
+  }
+
   clang_disposeTranslationUnit(TU);
   return 0;
 }


silenced signed/unsigned comparison warnings

--- thrust/detail/device/cuda/detail/b40c/radixsort_api.h
+++ thrust/detail/device/cuda/detail/b40c/radixsort_api.h
@@ -360,7 +360,7 @@
 	// find maximum number of threadblocks if "use-default"
 	if (max_grid_size == 0) {

-		if (_num_elements <= SINGLE_CTA_CUTOFF) {
+		if (_num_elements <= static_cast<unsigned int>(SINGLE_CTA_CUTOFF)) {

 			// The problem size is too small to warrant a two-level reduction:
 			// use only one stream-processor
@@ -384,7 +384,7 @@
 				}
 				max_grid_size = orig_max_grid_size;

-				if (_num_elements / _cycle_elements > max_grid_size) {
+				if (_num_elements / _cycle_elements > static_cast<unsigned int>(max_grid_size)) {

 					double multiplier1 = 4.0;
 					double multiplier2 = 16.0;
@@ -475,7 +475,7 @@
 	//

 	// Run tesla flush kernel if we have two or more threadblocks for each of the SMs
-	if ((_device_sm_version == 130) && (_work_decomposition.num_elements > _device_props.multiProcessorCount * _cycle_elements * 2)) {
+	if ((_device_sm_version == 130) && (_work_decomposition.num_elements > static_cast<unsigned int>(_device_props.multiProcessorCount * _cycle_elements * 2))) {
 		FlushKernel<void><<<_grid_size, B40C_RADIXSORT_THREADS, scan_scatter_attrs.sharedSizeBytes>>>();
 		synchronize_if_enabled("FlushKernel");
 	}
@@ -511,7 +511,7 @@
 	//

 	// Run tesla flush kernel if we have two or more threadblocks for each of the SMs
-	if ((_device_sm_version == 130) && (_work_decomposition.num_elements > _device_props.multiProcessorCount * _cycle_elements * 2)) {
+	if ((_device_sm_version == 130) && (_work_decomposition.num_elements > static_cast<unsigned int>(_device_props.multiProcessorCount * _cycle_elements * 2))) {
 		FlushKernel<void><<<_grid_size, B40C_RADIXSORT_THREADS, scan_scatter_attrs.sharedSizeBytes>>>();
 		synchronize_if_enabled("FlushKernel");
 	}


Add RValueWrapper, a wrapper for passing rvalue through std::bind and allow binding to function with rvalue reference parameters.

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

--- util/rvalue_wrapper.h
+++ util/rvalue_wrapper.h
@@ -0,0 +1,49 @@
+/**
+ * rvalue_wrapper.h
+ */
+#ifndef UTIL_RVALUE_WRAPPER_H_
+#define UTIL_RVALUE_WRAPPER_H_
+
+/**
+ * A wrapper for holding and passing rvalues through std::bind. The rvalue wrapped will be stored
+ * inside the wrapper until the functor returned by std::bind is invoked, at when the stored rvalue
+ * will be moved from. The functor can be invoked ONLY ONCE.
+ */
+template<typename T>
+struct RValueWrapper {
+public:
+    template<typename = typename std::enable_if<std::is_rvalue_reference<T&&>::value>::type>
+    explicit RValueWrapper(T &&t) noexcept :
+    t(std::move(t)) {
+    }
+    RValueWrapper(const RValueWrapper &rhs) = default;
+    RValueWrapper(RValueWrapper &&rhs) = default;
+    RValueWrapper& operator=(const RValueWrapper &rhs) = default;
+    RValueWrapper& operator=(RValueWrapper &&rhs) = default;
+
+    template <class ...Args>
+    T &&operator()(Args ...) {
+        return std::move(t);
+    }
+private:
+    T t;
+};
+
+namespace std {
+template<typename T>
+struct is_bind_expression<RValueWrapper<T>> : std::true_type {
+};
+}
+
+template<typename T,
+        typename = typename std::enable_if<std::is_rvalue_reference<T&&>::value>::type>
+RValueWrapper<T> rval(T &&t) {
+    return RValueWrapper<T>(std::move(t));
+}
+
+template<typename T>
+RValueWrapper<T> rval(T &t) {
+    return RValueWrapper<T>(T(t));
+}
+
+#endif /* UTIL_RVALUE_WRAPPER_H_ */


Updated Token output

Updated Token output

--- tokens.h
+++ tokens.h
@@ -31,8 +31,8 @@
   Token(ops::Operator& opContent, TokenType type, int line);
 };

-inline std::ostream &operator<<(std::ostream& os, Token& tok) {
-  return os << tok.data << ", TokenType " << tok.type << ", at line " << tok.line;
+inline std::ostream& operator<<(std::ostream& os, Token& tok) {
+  return os << "Token " << tok.data << ", TokenType " << tok.type << ", at line " << tok.line;
 }

 #endif /* TOKENS_H_ */


fixed else one bug

fixed else one bug


Fix bug in previous commit that made readdir fail

Original git commit by Alexander Larsson <alexl@redhat.com> at 1183371781 +0200

svn path=/trunk/; revision=595

--- daemon/gvfsbackendsmb.c
+++ daemon/gvfsbackendsmb.c
@@ -1121,7 +1121,7 @@

   /* If file is dos-readonly, libsmbclient doesn't set S_IWUSR, we use this to
      trigger ACCESS_WRITE = FALSE: */
-  if (!(statbud->st_mode & S_IWUSR))
+  if (!(statbuf->st_mode & S_IWUSR))
     g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_ACCESS_WRITE, FALSE);

   /* Look at st_mode & S_IWUSR, not set => readonly */
@@ -1253,6 +1253,7 @@
 		{
 		  info = g_file_info_new ();
 		  g_file_info_set_name (info, dirp->name);
+		  files = g_list_prepend (files, info);
 		}
 	      else
 		{


Lame fill algorithm, but recognizably top-down. Yay\!


Check light visibility by distance, rather than surface

--- tracer.c
+++ tracer.c
@@ -181,8 +181,13 @@
     /* Light is on right side - check we can see it. */
     tmp2 = l;
     MULT(tmp2, -1.0);
-    if (surf != intersect(sc, sc->lights[i].loc, tmp2, NULL, NULL))
+    double dist;
+    intersect(sc, sc->lights[i].loc, tmp2, &dist, NULL);
+    vector to_l = l;
+    SUB(to_l, sc->lights[i].loc);
+    if (dist*dist < DOT(to_l, to_l) + EPSILON) {
       continue;
+    }

     /* Diffuse colour */
     SHADE(c, sc->lights[i].col, surf->diffuse, diffuse);


Add F1 help dialog to show key bindings in mupdf-gl.

--- platform/gl/gl-main.c
+++ platform/gl/gl-main.c
@@ -180,6 +180,7 @@
 static int showlinks = 0;
 static int showsearch = 0;
 static int showinfo = 0;
+static int showhelp = 0;

 static int history_count = 0;
 static int history[256];
@@ -869,7 +870,7 @@
 		quit();

 	if (ui.down || ui.middle || ui.right || ui.key)
-		showinfo = 0;
+		showinfo = showhelp = 0;

 	if (!ui.focus && ui.key)
 	{
@@ -956,6 +957,7 @@
 		case 'j': case KEY_DOWN: scroll_y += 10; break;
 		case 'h': case KEY_LEFT: scroll_x -= 10; break;
 		case 'l': case KEY_RIGHT: scroll_x += 10; break;
+		case KEY_F1: showhelp = !showhelp; break;
 		}

 		if (ui.key >= '0' && ui.key <= '9')
@@ -1039,6 +1041,68 @@
 	}
 }

+static int do_help_line(int x, int y, char *label, char *text)
+{
+	ui_draw_string(ctx, x, y, label);
+	ui_draw_string(ctx, x+100, y, text);
+	return y + ui.lineheight;
+}
+
+static void do_help(void)
+{
+	int x = canvas_x + 4 * ui.lineheight;
+	int y = canvas_y + 4 * ui.lineheight;
+	int w = canvas_w - 8 * ui.lineheight;
+	int h = 34 * ui.lineheight;
+
+	glBegin(GL_TRIANGLE_STRIP);
+	{
+		glColor4f(0.9f, 0.9f, 0.9f, 1.0f);
+		glVertex2f(x, y);
+		glVertex2f(x, y + h);
+		glVertex2f(x + w, y);
+		glVertex2f(x + w, y + h);
+	}
+	glEnd();
+
+	x += ui.lineheight;
+	y += ui.lineheight + ui.baseline;
+
+	glColor4f(0, 0, 0, 1);
+	y = do_help_line(x, y, "MuPDF", FZ_VERSION);
+	y += ui.lineheight;
+	y = do_help_line(x, y, "q", "quit");
+	y = do_help_line(x, y, "r", "reload file");
+	y = do_help_line(x, y, "f", "fullscreen window");
+	y = do_help_line(x, y, "w", "shrink wrap window");
+	y = do_help_line(x, y, "i", "show document information");
+	y = do_help_line(x, y, "o", "show/hide outline");
+	y = do_help_line(x, y, "L", "show/hide links");
+	y += ui.lineheight;
+	y = do_help_line(x, y, "b", "smart move backward");
+	y = do_help_line(x, y, "Space", "smart move forward");
+	y = do_help_line(x, y, ", or PgUp", "go backward");
+	y = do_help_line(x, y, ". or PgDn", "go forward");
+	y = do_help_line(x, y, "<", "go backward 10 pages");
+	y = do_help_line(x, y, ">", "go forward 10 pages");
+	y = do_help_line(x, y, "N g", "go to page N");
+	y = do_help_line(x, y, "G", "go to last page");
+	y += ui.lineheight;
+	y = do_help_line(x, y, "t", "go backward in history");
+	y = do_help_line(x, y, "T", "go forward in history");
+	y = do_help_line(x, y, "N m", "save location in bookmark N");
+	y = do_help_line(x, y, "N t", "go to bookmark N");
+	y = do_help_line(x, y, "/ or ?", "search for text");
+	y = do_help_line(x, y, "n or N", "repeat search");
+	y += ui.lineheight;
+	y = do_help_line(x, y, "[ or ]", "rotate left or right");
+	y = do_help_line(x, y, "+ or -", "zoom in or out");
+	y = do_help_line(x, y, "W or H", "fit to width or height");
+	y = do_help_line(x, y, "Z", "fit to page");
+	y = do_help_line(x, y, "z", "reset zoom");
+	y = do_help_line(x, y, "N z", "set zoom to N");
+}
+
 static void do_canvas(void)
 {
 	static int saved_scroll_x = 0;
@@ -1179,6 +1243,8 @@

 	if (showinfo)
 		do_info();
+	else if (showhelp)
+		do_help();

 	if (showoutline)
 		do_outline(outline, canvas_x);


Document the PSK length requirements (Noise protocol v29)

--- src/protocol/handshakestate.c
+++ src/protocol/handshakestate.c
@@ -416,7 +416,8 @@
  *
  * \param state The HandshakeState object.
  * \param key Points to the pre shared key.
- * \param key_len The length of the \a key in bytes.
+ * \param key_len The length of the \a key in bytes.  This should be 32
+ * to comply with the requirements from the Noise protocol specification.
  *
  * \return NOISE_ERROR_NONE on success.
  * \return NOISE_ERROR_INVALID_PARAM if \a state or \a key is NULL.


plat/fvp: Dynamic description of clock freq

Query clock frequency in runtime using FCONF getter API

Signed-off-by: Lauren Wehrmeister <c2872bb20a24754ba136deb455abb6add7d102f7@arm.com>
Change-Id: Ie6a8a62d8d190b9994feffb167a1d48829913e9b

--- plat/arm/board/fvp/fvp_bl31_setup.c
+++ plat/arm/board/fvp/fvp_bl31_setup.c
@@ -7,7 +7,9 @@
 #include <assert.h>
 #include <common/debug.h>
 #include <drivers/arm/smmu_v3.h>
+#include <fconf_hw_config_getter.h>
 #include <lib/fconf/fconf.h>
+#include <lib/mmio.h>
 #include <plat/arm/common/arm_config.h>
 #include <plat/arm/common/plat_arm.h>
 #include <plat/common/platform.h>
@@ -65,3 +67,26 @@
 	fconf_populate("HW_CONFIG", hw_config_dtb);
 #endif
 }
+
+unsigned int plat_get_syscnt_freq2(void)
+{
+	unsigned int counter_base_frequency;
+
+#if !RESET_TO_BL31 && !BL2_AT_EL3
+	/* Get the frequency through FCONF API for HW_CONFIG */
+	counter_base_frequency = FCONF_GET_PROPERTY(hw_config, cpu_timer, clock_freq);
+	if (counter_base_frequency > 0U) {
+		return counter_base_frequency;
+	}
+#endif
+
+	/* Read the frequency from Frequency modes table */
+	counter_base_frequency = mmio_read_32(ARM_SYS_CNTCTL_BASE + CNTFID_OFF);
+
+	/* The first entry of the frequency modes table must not be 0 */
+	if (counter_base_frequency == 0U) {
+		panic();
+	}
+
+	return counter_base_frequency;
+}


Updated power management for Serial class. Power management for Serial class is now optional and can be enabled by adding the CONFIG_SERIAL_PM definition.

--- platform/nxp/serial.c
+++ platform/nxp/serial.c
@@ -12,8 +12,11 @@
 #define RX_FIFO_LEVEL 2 /* 8 characters */
 #define TX_FIFO_SIZE  8
 /*----------------------------------------------------------------------------*/
+#ifdef CONFIG_SERIAL_PM
+static enum result powerStateHandler(void *, enum pmState);
+#endif
+/*----------------------------------------------------------------------------*/
 static void interruptHandler(void *);
-static enum result powerStateHandler(void *, enum pmState);
 /*----------------------------------------------------------------------------*/
 static enum result serialInit(void *, const void *);
 static void serialDeinit(void *);
@@ -78,6 +81,7 @@
     interface->callback(interface->callbackArgument);
 }
 /*----------------------------------------------------------------------------*/
+#ifdef CONFIG_SERIAL_PM
 static enum result powerStateHandler(void *object, enum pmState state)
 {
   struct Serial *interface = object;
@@ -95,6 +99,7 @@

   return E_OK;
 }
+#endif
 /*----------------------------------------------------------------------------*/
 static enum result serialInit(void *object, const void *configPtr)
 {
@@ -140,8 +145,10 @@
   uartSetParity(object, config->parity);
   uartSetRate(object, rateConfig);

+#ifdef CONFIG_SERIAL_PM
   if ((res = pmRegister(object, powerStateHandler)) != E_OK)
     return res;
+#endif

   irqSetPriority(interface->parent.irq, config->priority);
   irqEnable(interface->parent.irq);


ec25519-fhmqvc: put public and secret keys together in a keypair structure

--- src/protocol_ec25519_fhmqvc.c
+++ src/protocol_ec25519_fhmqvc.c
@@ -50,9 +50,13 @@

 typedef ecc_int256_t __attribute__((aligned(4))) aligned_int256_t;

+typedef struct keypair {
+	ecc_int256_t secret;
+	aligned_int256_t public;
+} keypair_t;
+
 struct fastd_protocol_config {
-	ecc_int256_t secret_key;
-	aligned_int256_t public_key;
+	keypair_t key;
 };

 typedef struct handshake_key {
@@ -60,8 +64,7 @@
 	struct timespec preferred_till;
 	struct timespec valid_till;

-	ecc_int256_t secret_key;
-	aligned_int256_t public_key;
+	keypair_t key;
 } handshake_key_t;

 struct fastd_protocol_state {
@@ -152,12 +155,12 @@
 	if (!ctx->conf->secret)
 		exit_error(ctx, "no secret key configured");

-	if (!read_key(protocol_config->secret_key.p, ctx->conf->secret))
+	if (!read_key(protocol_config->key.secret.p, ctx->conf->secret))
 		exit_error(ctx, "invalid secret key");

 	ecc_25519_work_t work;
-	ecc_25519_scalarmult_base(&work, &protocol_config->secret_key);
-	ecc_25519_store_packed(&protocol_config->public_key, &work);
+	ecc_25519_scalarmult_base(&work, &protocol_config->key.secret);
+	ecc_25519_store_packed(&protocol_config->key.public, &work);

 	return protocol_config;
 }
@@ -201,7 +204,7 @@
 	peer_conf->protocol_config = malloc(sizeof(fastd_protocol_peer_config_t));
 	peer_conf->protocol_config->public_key = key;

-	if (memcmp(peer_conf->protocol_config->public_key.p, ctx->conf->protocol_config->public_key.p, 32) == 0)
+	if (memcmp(peer_conf->protocol_config->public_key.p, ctx->conf->protocol_config->key.public.p, 32) == 0)
 		pr_debug(ctx, "found own key as `%s', ignoring peer", peer_conf->name);
 }

@@ -209,7 +212,7 @@
 	if (!peer_conf->protocol_config)
 		return false;

-	if (memcmp(peer_conf->protocol_config->public_key.p, ctx->conf->protocol_config->public_key.p, 32) == 0)
+	if (memcmp(peer_conf->protocol_config->public_key.p, ctx->conf->protocol_config->key.public.p, 32) == 0)
 		return false;

 	if (key_count(ctx, peer_conf->protocol_config->public_key.p) > 1) {
@@ -238,6 +241,15 @@
 		ctx->protocol_state = calloc(1, sizeof(fastd_protocol_state_t));
 }

+static void new_handshake_key(fastd_context_t *ctx, keypair_t *key) {
+		fastd_random_bytes(ctx, key->secret.p, 32, false);
+		ecc_25519_gf_sanitize_secret(&key->secret, &key->secret);
+
+		ecc_25519_work_t work;
+		ecc_25519_scalarmult_base(&work, &key->secret);
+		ecc_25519_store_packed(&key->public, &work);
+}
+
 static void maintenance(fastd_context_t *ctx) {
 	init_protocol_state(ctx);

@@ -248,12 +260,7 @@

 		ctx->protocol_state->handshake_key.serial++;

-		fastd_random_bytes(ctx, ctx->protocol_state->handshake_key.secret_key.p, 32, false);
-		ecc_25519_gf_sanitize_secret(&ctx->protocol_state->handshake_key.secret_key, &ctx->protocol_state->handshake_key.secret_key);
-
-		ecc_25519_work_t work;
-		ecc_25519_scalarmult_base(&work, &ctx->protocol_state->handshake_key.secret_key);
-		ecc_25519_store_packed(&ctx->protocol_state->handshake_key.public_key, &work);
+		new_handshake_key(ctx, &ctx->protocol_state->handshake_key.key);

 		ctx->protocol_state->handshake_key.preferred_till = ctx->now;
 		ctx->protocol_state->handshake_key.preferred_till.tv_sec += 15;
@@ -268,14 +275,14 @@

 	fastd_buffer_t buffer = fastd_handshake_new_init(ctx, 3*(4+PUBLICKEYBYTES) /* sender key, receipient key, handshake key */);

-	fastd_handshake_add(ctx, &buffer, RECORD_SENDER_KEY, PUBLICKEYBYTES, ctx->conf->protocol_config->public_key.p);
+	fastd_handshake_add(ctx, &buffer, RECORD_SENDER_KEY, PUBLICKEYBYTES, ctx->conf->protocol_config->key.public.p);

 	if (peer)
 		fastd_handshake_add(ctx, &buffer, RECORD_RECEIPIENT_KEY, PUBLICKEYBYTES, peer->protocol_config->public_key.p);
 	else
 		pr_debug(ctx, "sending handshake to unknown peer %I", remote_addr);

-	fastd_handshake_add(ctx, &buffer, RECORD_SENDER_HANDSHAKE_KEY, PUBLICKEYBYTES, ctx->protocol_state->handshake_key.public_key.p);
+	fastd_handshake_add(ctx, &buffer, RECORD_SENDER_HANDSHAKE_KEY, PUBLICKEYBYTES, ctx->protocol_state->handshake_key.key.public.p);

 	fastd_send_handshake(ctx, sock, local_addr, remote_addr, buffer);
 }
@@ -289,9 +296,9 @@

 	fastd_sha256_t hashbuf;
 	fastd_sha256_blocks(&hashbuf,
-			    handshake_key->public_key.p,
+			    handshake_key->key.public.p,
 			    peer_handshake_key->p,
-			    ctx->conf->protocol_config->public_key.p,
+			    ctx->conf->protocol_config->key.public.p,
 			    peer->protocol_config->public_key.p,
 			    NULL);

@@ -303,8 +310,8 @@
 	d.p[15] |= 0x80;
 	e.p[15] |= 0x80;

-	ecc_25519_gf_mult(&eb, &e, &ctx->conf->protocol_config->secret_key);
-	ecc_25519_gf_add(&s, &eb, &handshake_key->secret_key);
+	ecc_25519_gf_mult(&eb, &e, &ctx->conf->protocol_config->key.secret);
+	ecc_25519_gf_add(&s, &eb, &handshake_key->key.secret);

 	ecc_25519_work_t work, workX;
 	if (!ecc_25519_load_packed(&workX, peer_handshake_key))
@@ -327,9 +334,9 @@
 	ecc_25519_store_packed(&peer->protocol_state->sigma, &work);

 	fastd_sha256_blocks(&peer->protocol_state->shared_handshake_key,
-			    handshake_key->public_key.p,
+			    handshake_key->key.public.p,
 			    peer_handshake_key->p,
-			    ctx->conf->protocol_config->public_key.p,
+			    ctx->conf->protocol_config->key.public.p,
 			    peer->protocol_config->public_key.p,
 			    peer->protocol_state->sigma.p,
 			    NULL);
@@ -356,13 +363,13 @@
 		return;

 	fastd_sha256_t hmacbuf;
-	fastd_hmacsha256_blocks(&hmacbuf, peer->protocol_state->shared_handshake_key.w, ctx->conf->protocol_config->public_key.p, handshake_key->public_key.p, NULL);
+	fastd_hmacsha256_blocks(&hmacbuf, peer->protocol_state->shared_handshake_key.w, ctx->conf->protocol_config->key.public.p, handshake_key->key.public.p, NULL);

 	fastd_buffer_t buffer = fastd_handshake_new_reply(ctx, handshake, method, 4*(4+PUBLICKEYBYTES) + 4+HASHBYTES);

-	fastd_handshake_add(ctx, &buffer, RECORD_SENDER_KEY, PUBLICKEYBYTES, ctx->conf->protocol_config->public_key.p);
+	fastd_handshake_add(ctx, &buffer, RECORD_SENDER_KEY, PUBLICKEYBYTES, ctx->conf->protocol_config->key.public.p);
 	fastd_handshake_add(ctx, &buffer, RECORD_RECEIPIENT_KEY, PUBLICKEYBYTES, peer->protocol_config->public_key.p);
-	fastd_handshake_add(ctx, &buffer, RECORD_SENDER_HANDSHAKE_KEY, PUBLICKEYBYTES, handshake_key->public_key.p);
+	fastd_handshake_add(ctx, &buffer, RECORD_SENDER_HANDSHAKE_KEY, PUBLICKEYBYTES, handshake_key->key.public.p);
 	fastd_handshake_add(ctx, &buffer, RECORD_RECEIPIENT_HANDSHAKE_KEY, PUBLICKEYBYTES, peer_handshake_key->p);
 	fastd_handshake_add(ctx, &buffer, RECORD_T, HASHBYTES, hmacbuf.b);

@@ -433,9 +440,9 @@
 	fastd_sha256_t hashbuf;
 	fastd_sha256_blocks(&hashbuf,
 			    peer_handshake_key->p,
-			    handshake_key->public_key.p,
+			    handshake_key->key.public.p,
 			    peer->protocol_config->public_key.p,
-			    ctx->conf->protocol_config->public_key.p,
+			    ctx->conf->protocol_config->key.public.p,
 			    NULL);

 	ecc_int256_t d = {{0}}, e = {{0}}, da, s;
@@ -446,8 +453,8 @@
 	d.p[15] |= 0x80;
 	e.p[15] |= 0x80;

-	ecc_25519_gf_mult(&da, &d, &ctx->conf->protocol_config->secret_key);
-	ecc_25519_gf_add(&s, &da, &handshake_key->secret_key);
+	ecc_25519_gf_mult(&da, &d, &ctx->conf->protocol_config->key.secret);
+	ecc_25519_gf_add(&s, &da, &handshake_key->key.secret);

 	ecc_25519_work_t work, workY;
 	if (!ecc_25519_load_packed(&workY, peer_handshake_key))
@@ -473,9 +480,9 @@
 	fastd_sha256_t shared_handshake_key;
 	fastd_sha256_blocks(&shared_handshake_key,
 			    peer_handshake_key->p,
-			    handshake_key->public_key.p,
+			    handshake_key->key.public.p,
 			    peer->protocol_config->public_key.p,
-			    ctx->conf->protocol_config->public_key.p,
+			    ctx->conf->protocol_config->key.public.p,
 			    sigma.p,
 			    NULL);

@@ -485,17 +492,17 @@
 	}

 	fastd_sha256_t hmacbuf;
-	fastd_hmacsha256_blocks(&hmacbuf, shared_handshake_key.w, ctx->conf->protocol_config->public_key.p, handshake_key->public_key.p, NULL);
-
-	if (!establish(ctx, peer, method, sock, local_addr, remote_addr, true, &handshake_key->public_key, peer_handshake_key, &ctx->conf->protocol_config->public_key,
+	fastd_hmacsha256_blocks(&hmacbuf, shared_handshake_key.w, ctx->conf->protocol_config->key.public.p, handshake_key->key.public.p, NULL);
+
+	if (!establish(ctx, peer, method, sock, local_addr, remote_addr, true, &handshake_key->key.public, peer_handshake_key, &ctx->conf->protocol_config->key.public,
 		       &peer->protocol_config->public_key, &sigma, handshake_key->serial))
 		return;

 	fastd_buffer_t buffer = fastd_handshake_new_reply(ctx, handshake, method, 4*(4+PUBLICKEYBYTES) + 4+HASHBYTES);

-	fastd_handshake_add(ctx, &buffer, RECORD_SENDER_KEY, PUBLICKEYBYTES, ctx->conf->protocol_config->public_key.p);
+	fastd_handshake_add(ctx, &buffer, RECORD_SENDER_KEY, PUBLICKEYBYTES, ctx->conf->protocol_config->key.public.p);
 	fastd_handshake_add(ctx, &buffer, RECORD_RECEIPIENT_KEY, PUBLICKEYBYTES, peer->protocol_config->public_key.p);
-	fastd_handshake_add(ctx, &buffer, RECORD_SENDER_HANDSHAKE_KEY, PUBLICKEYBYTES, handshake_key->public_key.p);
+	fastd_handshake_add(ctx, &buffer, RECORD_SENDER_HANDSHAKE_KEY, PUBLICKEYBYTES, handshake_key->key.public.p);
 	fastd_handshake_add(ctx, &buffer, RECORD_RECEIPIENT_HANDSHAKE_KEY, PUBLICKEYBYTES, peer_handshake_key->p);
 	fastd_handshake_add(ctx, &buffer, RECORD_T, HASHBYTES, hmacbuf.b);

@@ -515,8 +522,8 @@
 		return;
 	}

-	establish(ctx, peer, method, sock, local_addr, remote_addr, false, peer_handshake_key, &handshake_key->public_key, &peer->protocol_config->public_key,
-		  &ctx->conf->protocol_config->public_key, &peer->protocol_state->sigma, handshake_key->serial);
+	establish(ctx, peer, method, sock, local_addr, remote_addr, false, peer_handshake_key, &handshake_key->key.public, &peer->protocol_config->public_key,
+		  &ctx->conf->protocol_config->key.public, &peer->protocol_state->sigma, handshake_key->serial);

 	clear_shared_handshake_key(ctx, peer);
 }
@@ -655,7 +662,7 @@
 	}

 	if (has_field(handshake, RECORD_RECEIPIENT_KEY, PUBLICKEYBYTES)) {
-		if (memcmp(ctx->conf->protocol_config->public_key.p, handshake->records[RECORD_RECEIPIENT_KEY].data, PUBLICKEYBYTES) != 0) {
+		if (memcmp(ctx->conf->protocol_config->key.public.p, handshake->records[RECORD_RECEIPIENT_KEY].data, PUBLICKEYBYTES) != 0) {
 			pr_debug(ctx, "received protocol handshake with wrong receipient key from %P[%I]", peer, remote_addr);
 			return;
 		}
@@ -704,10 +711,10 @@
 	}

 	handshake_key_t *handshake_key;
-	if (is_handshake_key_valid(ctx, &ctx->protocol_state->handshake_key) && memcmp(ctx->protocol_state->handshake_key.public_key.p, handshake->records[RECORD_RECEIPIENT_HANDSHAKE_KEY].data, PUBLICKEYBYTES) == 0) {
+	if (is_handshake_key_valid(ctx, &ctx->protocol_state->handshake_key) && memcmp(ctx->protocol_state->handshake_key.key.public.p, handshake->records[RECORD_RECEIPIENT_HANDSHAKE_KEY].data, PUBLICKEYBYTES) == 0) {
 		handshake_key = &ctx->protocol_state->handshake_key;
 	}
-	else if (is_handshake_key_valid(ctx, &ctx->protocol_state->prev_handshake_key) && memcmp(ctx->protocol_state->prev_handshake_key.public_key.p, handshake->records[RECORD_RECEIPIENT_HANDSHAKE_KEY].data, PUBLICKEYBYTES) == 0) {
+	else if (is_handshake_key_valid(ctx, &ctx->protocol_state->prev_handshake_key) && memcmp(ctx->protocol_state->prev_handshake_key.key.public.p, handshake->records[RECORD_RECEIPIENT_HANDSHAKE_KEY].data, PUBLICKEYBYTES) == 0) {
 		handshake_key = &ctx->protocol_state->prev_handshake_key;
 	}
 	else {
@@ -889,15 +896,15 @@

 static void protocol_show_key(fastd_context_t *ctx) {
 	if (ctx->conf->machine_readable)
-		print_hexdump("", ctx->conf->protocol_config->public_key.p);
+		print_hexdump("", ctx->conf->protocol_config->key.public.p);
 	else
-		print_hexdump("Public: ", ctx->conf->protocol_config->public_key.p);
+		print_hexdump("Public: ", ctx->conf->protocol_config->key.public.p);
 }

 static void protocol_set_shell_env(fastd_context_t *ctx, const fastd_peer_t *peer) {
 	char buf[65];

-	hexdump(buf, ctx->conf->protocol_config->public_key.p);
+	hexdump(buf, ctx->conf->protocol_config->key.public.p);
 	setenv("LOCAL_KEY", buf, 1);

 	if (peer && peer->protocol_config) {


x11: Avoid panning to top/bottom on page up/down.

--- platform/x11/pdfapp.c
+++ platform/x11/pdfapp.c
@@ -1456,7 +1456,7 @@
 	 */

 	case ',':
-		panto = PAN_TO_BOTTOM;
+		panto = DONT_PAN;
 		if (app->numberlen > 0)
 			app->pageno -= atoi(app->number);
 		else
@@ -1464,7 +1464,7 @@
 		break;

 	case '.':
-		panto = PAN_TO_TOP;
+		panto = DONT_PAN;
 		if (app->numberlen > 0)
 			app->pageno += atoi(app->number);
 		else


Fabric, Crashlytics をヘッダに含める

Fabric, Crashlytics をヘッダに含める

--- platforms/ios/src/Bridging-Header.h
+++ platforms/ios/src/Bridging-Header.h
@@ -2,3 +2,5 @@
 #import <FBSDKCoreKit/FBSDKCoreKit.h>
 #import <FBSDKLoginKit/FBSDKLoginKit.h>
 #import <FBSDKShareKit/FBSDKShareKit.h>
+#import <Fabric/Fabric.h>
+#import <Crashlytics/Crashlytics.h>


aarch64

--- platforms/unix/vm/sqUnixHeartbeat.c
+++ platforms/unix/vm/sqUnixHeartbeat.c
@@ -181,7 +181,7 @@
 						: "=a" (value)
 						:
 						: "rdx");
-#elif defined(__arm__) && (defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_8A__))
+#elif defined(__arm__) && (defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_ISA_A64))
 	/* tpr - do nothing for now; needs input from eliot to decide further */
 	/* Tim, not sure I have input beyond:
 		Is there a 64-bit clock on ARM?  If so, access it here :-)


cache implement update

cache implement update

did some cool stuff that i hope works. it compiles at least

--- iplc-sim.c
+++ iplc-sim.c
@@ -1,6 +1,6 @@
 /***********************************************************************/
 /***********************************************************************
- Pipeline Cache Simulator hungry bois
+ Pipeline Cache Simulator hi
  ***********************************************************************/
 /***********************************************************************/
 #include <stdio.h>
@@ -39,6 +39,10 @@

 typedef struct cache_line
 {
+    int *vdbt;
+    int *tag;
+    int asso;
+    int *replace;
     // Your data structures for implementing your cache should include:
     // a valid bit
     // a tag
@@ -167,6 +171,15 @@

     // Dynamically create our cache based on the information the user entered
     for (i = 0; i < (1<<index); i++) {
+        cache[i].vdbt = (int *)malloc((sizeof(int) * assoc));
+        cache[i].tag = (int *)malloc((sizeof(int) * assoc));
+        cache[i].replace = (int *)malloc((sizeof(int) * assoc));
+
+        for(j = 0; j < assoc; j++){
+            cache[i].vdbt[j] = 0;
+            cache[i].tag[j] = 0;
+            cache[i].replace[j] = j;
+        }
     }

     // init the pipeline -- set all data to zero and instructions to NOP
@@ -182,7 +195,17 @@
  */
 void iplc_sim_LRU_replace_on_miss(int index, int tag)
 {
-    /* You must implement this function */
+    int repl = cache[index].replace[0];
+    //replace everything at least recently used
+    cache[index].vdbt[repl] = 1;
+    cache[index].tag[repl] = tag;
+    cache[index].replace[cache_assoc - 1] = repl;
+
+    for(int j = 0; j < cache_assoc - 1; j++){
+        //update lru
+        cache[index].replace[j] = cache[index].replace[j + 1];
+    }
+
 }

 /*
@@ -191,7 +214,16 @@
  */
 void iplc_sim_LRU_update_on_hit(int index, int assoc_entry)
 {
-    /* You must implement this function */
+    int update = 0;
+    //find update index
+    while(cache[index].replace[update] != assoc_entry){
+        update++;
+    }
+    //from there, update the lru
+    for(int i = update + 1; i < cache_assoc + 1; i++){
+        cache[index].replace[i - 1] = cache[index].replace[i];
+    }
+    cache[index].replace[cache_assoc - 1] = assoc_entry;
 }

 /*


Nicer Syntax...

Nicer Syntax...

[r394]

--- ir/st/st.c
+++ ir/st/st.c
@@ -1,6 +1,6 @@
 /* Copyright (c) 2002 by Universitt Karlsruhe (TH).  All Rights Reserved */
 //
-// Time-stamp: <02/03/04 16:57:32 liekweg>
+// Time-stamp: <Monday, 13.05.2002, 13:27:22 goetz@i44pc2.info.uni-karlsruhe.de>
 //

 /***
@@ -434,6 +434,7 @@
   env->dt      = get_dominator_tree (graph);
   env->a       = a;
   env->index_a = get_index (env->dt, a);
+  return env;
 }

 /*


ome comment

ome comment

[r173]

--- ir/tv/tv.h
+++ ir/tv/tv.h
@@ -1,5 +1,39 @@
 /* Declarations for Target Values.
-   Copyright (C) 1995, 1996 Christian von Roques */
+   Copyright (C) 1995, 1996 Christian von Roques
+
+Discussion of new interface, proposals by Prof. Waite:
+(email of 13.6.2001)
+> 1. You say that you plan to replace the tv module.  That replacement is
+>    absolutely essential for an ANSI C translator:  Section 6.1.3.2 of the
+>    standard says that the representation of an integer_constant depends
+>    upon its value as well as any suffixes that are attached to it.  The
+>    possible Firm modes for such a constant are i, I, l, and L.  The
+>    current tv module provides only one integer conversion routine, and
+>    that requires conversion by the client.  Since the type of the value
+>    argument is long, this may preclude the representation of an unsigned
+>    long constant.
+>
+>    There is a similar problem with floating constants.  Floating
+>    constants can be suffixed in C, and the mode depends upon the suffix.
+>    It can indicate that the constant is of type long double, which your
+>    current tv module is incapable of representing.
+>
+>    Your tv module interface accepts two kinds of information: modes and
+>    values.  Values obtained from the program text might be uninterpreted
+>    strings, strings interpreted as integers, and strings interpreted as
+>    reals.  Values provided by the compiler are usually integers.  Modes are
+>    always Firm modes.  It seems to me that the tv module should provide
+>    tarval* constructors for three of the four kinds of values.  Each of these
+>    constructors should have an ir_mode parameter and one or more parameters
+>    appropriate for the kind of value.  As is currently the case, one
+>    constructor should be provided for both compiler-generated integers and
+>    source strings interpreted as integers.  (This avoids problems of
+>    different conversion radices -- the client does the conversion.)  For
+>    symmetry, the constructor for source strings interpreted as reals should
+>    accept a long double parameter and require the client to do the
+>    conversion.
+
+*/

 #ifndef _TV_H
 #define _TV_H


Switch from 'ignore this prim' to 'ray must travel epsilon' to find next intersection

--- tracer.c
+++ tracer.c
@@ -21,6 +21,9 @@
 #ifndef INFINITY
 #define INFINITY (1.0 / 0.0)
 #endif
+#ifndef EPSILON
+#define EPSILON 1.0e-7
+#endif

 #define SHADE(c, i, k, p) { \
     c.r += i.r * k.r * p; \
@@ -41,7 +44,8 @@
  */

 /* Trace a unit ray, to find an intersection */
-static surface *intersect(scene const *sc, vector from, vector direction, double *dist, surface const *ignore);
+static surface *intersect(scene const *sc, vector from, vector direction,
+                          double *dist);

 /* Texture a point */
 static void texture(scene const *sc, surface const *surf,
@@ -57,11 +61,10 @@
  * absorbtion further down the line, we pre-multiply, allowing us
  * to cut off at an appropriate point.
  */
-static colour trace(scene const *sc, surface const *skip,
-                    vector from, vector dir, colour premul)
+static colour trace(scene const *sc, vector from, vector dir, colour premul)
 {
   double dist;
-  surface *intersecting = intersect(sc, from, dir, &dist, skip);
+  surface *intersecting = intersect(sc, from, dir, &dist);
   if (!intersecting) {
     /* Missed! Send ray off to darkest infinity */
     return black;
@@ -108,18 +111,15 @@
 static surface *intersect(scene const *sc,
                           vector from,
                           vector direction,
-                          double *dist,
-                          surface const *ignore)
-{
-  double nearest_dist = HUGE_VAL;
+                          double *dist)
+{
+  double nearest_dist = INFINITY;
   sphere *nearest_sphere = NULL;
   int i;

   for (i = 0; i < sc->num_spheres; i++) {
-    if (&(sc->spheres[i].props) == ignore)
-      continue;
     double this_dist = sphere_intersect(sc->spheres + i, from, direction);
-    if (this_dist < nearest_dist) {
+    if (EPSILON < this_dist && this_dist < nearest_dist) {
       nearest_dist = this_dist;
       nearest_sphere = sc->spheres + i;
     }
@@ -175,7 +175,7 @@
     /* Light is on right side - check we can see it. */
     tmp2 = l;
     MULT(tmp2, -1.0);
-    if (surf != intersect(sc, sc->lights[i].loc, tmp2, NULL, NULL))
+    if (surf != intersect(sc, sc->lights[i].loc, tmp2, NULL))
       continue;

     /* Diffuse colour */
@@ -200,7 +200,7 @@

   if (col->r + col->g + col->b > REFLECTSTOP) {
     /* Enough light to make it worth tracing further */
-    *col = trace(sc, surf, w, r, *col);
+    *col = trace(sc, w, r, *col);
   } else {
     /* Not enough light to bother tracing further. */
     *col = black;
@@ -230,7 +230,7 @@
       ray.y = y - height/2;
       ray.z = width/2;
       NORMALISE(ray);
-      image[y * width + x] = trace(sc, NULL, origin, ray, white);
-    }
-  }
-}
+      image[y * width + x] = trace(sc, origin, ray, white);
+    }
+  }
+}


socket-ext: provide access to socket for a test user

Signed-off-by: Andrey Vagin <74c05afa918858348d6db8037d82fa8124870113@openvz.org>
Signed-off-by: Pavel Emelyanov <c9a32589e048e044184536f7ac71ef92fe82df3e@parallels.com>

--- test/zdtm/live/static/socket-ext.c
+++ test/zdtm/live/static/socket-ext.c
@@ -56,6 +56,7 @@
 			err("Can't bind socket to %s", path);
 			return 1;
 		}
+		chmod(path, 0777);
 		test_msg("The external socket %s\n", path);
 		task_waiter_complete(&lock, 1);
 		task_waiter_fini(&lock);


in_systemd: workaround for systemd tail/skip issue 9934 (#1565)

Signed-off-by: Alexander Kabakaev <19a03465703a4baa620d16baa031ab9c0803d575@gmail.com>

--- plugins/in_systemd/systemd_config.c
+++ plugins/in_systemd/systemd_config.c
@@ -183,9 +183,16 @@
     }

     if (ctx->read_from_tail == FLB_TRUE) {
-        /* Jump to the end and skip last entry */
         sd_journal_seek_tail(ctx->j);
-        sd_journal_next_skip(ctx->j, 1);
+        /*
+        * Skip up to 350 records until the end of journal is found.
+        * Workaround for bug https://github.com/systemd/systemd/issues/9934
+        * Due to the bug, sd_journal_next() returns 2 last records of each journal file.
+        * 4 GB is the default journal limit, so with 25 MB/file we may get
+        * up to 4096/25*2 ~= 350 old log messages. See also fluent-bit PR #1565.
+        */
+        ret = sd_journal_next_skip(ctx->j, 350);
+        flb_debug("[in_systemd] jump to the end of journal and skip %d last entries", ret);
     }
     else {
         sd_journal_seek_head(ctx->j);


Remove TCPLink unit test

Remove TCPLink unit test

This test is too flaky to run in TeamCity reliably.

--- src/qgcunittest/TCPLinkTest.h
+++ src/qgcunittest/TCPLinkTest.h
@@ -89,6 +89,8 @@
     const char*         _rgSignals[_cSignals];
 };

-DECLARE_TEST(TCPLinkUnitTest)
+// This unit test has gotten too flaky to run reliably under TeamCity. Removing for now till there is
+// time to debug.
+//DECLARE_TEST(TCPLinkUnitTest)

 #endif


Increase speed every 10 completed rows

Increase speed every 10 completed rows

--- tetris.c
+++ tetris.c
@@ -390,8 +390,9 @@
 #define ROTATE 3
 #define DROP 4

+#define INITIAL_DROP_INTERVAL 600
 #define MIN_DROP_INTERVAL 150
-#define DROP_INCREMENT 30
+#define DROP_INTERVAL_INCREMENT 30

 uint8_t row_scores[] = {0, 1, 4, 8, 16};

@@ -405,13 +406,12 @@
     uint8_t shape_width;
     uint8_t shape[4], proposed_shape[4];
     unsigned int last_block_move_clock;
-    unsigned int drop_interval = 600;
-    unsigned int last_drop_reduction_clock;
+    unsigned int drop_interval = INITIAL_DROP_INTERVAL;
     bool update_shape;
     uint8_t message;
     uint8_t action;
     uint8_t key1_autorepeat = false;
-    uint32_t score = 0, high_score = 0;
+    uint32_t score = 0, high_score = 0, lines = 0;
     bool new_high_score = true;
     char high_score_name[4];

@@ -481,13 +481,11 @@
         offset_shape(shape, shape_offset);

         last_block_move_clock = clock_count;
-        last_drop_reduction_clock = clock_count;

         // Main game loop
         while (1) {
-            if (drop_interval > MIN_DROP_INTERVAL && clock_count - last_drop_reduction_clock > 15000) {
-                drop_interval -= DROP_INCREMENT;
-                last_drop_reduction_clock = clock_count;
+            if (drop_interval > MIN_DROP_INTERVAL) {
+                drop_interval = INITIAL_DROP_INTERVAL - ((lines / 10) * DROP_INTERVAL_INCREMENT);
             }

             action = 0;
@@ -519,12 +517,16 @@
             if (action == DROP || (clock_count - last_block_move_clock) > drop_interval) {
                 last_block_move_clock = clock_count;
                 if (test_collision(board, shape, shape_top + 1)) {
+                    uint8_t rows_cleared;
+
                     if (shape_top == 0)
                         // Game over
                         break;

                     flash_full_rows();
-                    score += row_scores[collapse_full_rows(leds, board)];
+                    rows_cleared = collapse_full_rows(leds, board);
+                    score += row_scores[rows_cleared];
+                    lines += rows_cleared;

                     shape_top = 0;
                     shape_offset = 3;


immshift

immshift

--- thumb2.c
+++ thumb2.c
@@ -74,6 +74,33 @@
 }

+// Can replace this later on
+static uint32_t thumb2_decode_immshift(darm_t *d, uint8_t type, uint8_t imm5)
+{
+	switch(type) {
+	    case 0:
+		d->shift_type = S_LSL;
+		d->shift = imm5;
+		break;
+	    case 1:
+		d->shift_type = S_LSR;
+		d->shift = (imm5 == 0) ? 32 : imm5;
+		break;
+	    case 2:
+		d->shift_type = S_ASR;
+		d->shift = (imm5 == 0) ? 32 : imm5;
+		break;
+	    case 3:
+		d->shift_type = S_ROR;
+		d->shift = (imm5 == 0) ? 1 : imm5 // RRX! :)
+		break;
+	    default:
+		d->shift_type = S_INVLD;
+		break;
+	}
+}
+
+
 static int thumb2_disasm(darm_t *d, uint16_t w, uint16_t w2)
 {

@@ -100,9 +127,11 @@
 	    // W, U and P flags
 	    d->W = (w2 >> 8) & 1 ? B_SET : B_UNSET;
 	    d->U = (w2 >> 9) & 1 ? B_SET : B_UNSET;
-	    d->U = (w2 >> 10) & 1 ? B_SET : B_UNSET;
+	    d->P = (w2 >> 10) & 1 ? B_SET : B_UNSET;
 	case T_THUMB2_TYPE_FLAG:
 	    // Type field
+	    // This is always a T_THUMB2_IMM2_IMM3 type
+	    thumb2_decode_immshift(d, (w2 >> 4) & 3, d->imm)
 	    break;
 	case T_THUMB2_REGLIST_FLAG:
 	    // Reglist field


Client now properly sends 'q' when quitting


changed the result file format slightly

changed the result file format slightly

--- client/client.c
+++ client/client.c
@@ -268,7 +268,7 @@
 	char* fileName;
 	FILE* filePtr;
 	FILE* resultFile;
-	int signum, semicolonsToSkip=3, c;
+	int signum, pipesToSkip=2, c;
 	char secFraction, dummy;

 	fileName=addBasename(pidToFileName(j->pid));
@@ -292,11 +292,11 @@
 		else
 			j->status=3;
 	} else {
-		//Skip semicolonsToSkip semicolons.
-		while(semicolonsToSkip>0) {
+		//Skip pipesToSkip '|' characters
+		while(pipesToSkip>0) {
 			c=getc(filePtr);
-			if(c==(int)';') {
-				--semicolonsToSkip;
+			if(c==(int)'|') {
+				--pipesToSkip;
 			} else if(c==EOF) {
 				logError("Error parsing %s: Unexpected format\n", fileName);
 				free(fileName);
@@ -304,7 +304,7 @@
 			}
 		}
 		//Extract the runtime and return value of the solver
-		if(fscanf(filePtr, "%d.%c%c;%d", &(j->time), &secFraction, &dummy, &(j->statusCode))!=4){
+		if(fscanf(filePtr, "%d.%c%c|%d", &(j->time), &secFraction, &dummy, &(j->statusCode))!=4){
 			logError("Error parsing %s: Unexpected format\n", fileName);
 			free(fileName);
 			return sysError;
@@ -443,7 +443,7 @@
 		return sysError;
 	}
 	if(sprintfAlloc(&command,
-	                "ulimit -S -t %d && /usr/bin/time -a -o %s -f \"%%U;%%x\" %s %s %s >> %s",
+	                "ulimit -S -t %d && /usr/bin/time -a -o %s -f \"|%%C|%%U|%%x\" %s %s %s >> %s",
 	                timeOut, fileName, solverName, j->params, instanceName, fileName          ) < 0) {
 		logError("Error in sprintfAlloc()\n");
 		free(fileName);


The ghost block should not be toggleable when the game is in the paused state

--- tetris.c
+++ tetris.c
@@ -338,18 +338,6 @@
             Renderer_draw_panel_level(tetris->renderer, tetris->level);
         }
     }
-    else if (tetris->key_ghost_block) {
-        if (tetris->enable_ghost_block) {
-            tetris->enable_ghost_block = 0;
-        }
-        else {
-            tetris->enable_ghost_block = 1;
-            if (tetris->enable_ghost_block == 1) {
-                set_ghost_block(tetris);
-            }
-        }
-        tetris->renderer->buffer->dirty = 1;
-    }

     if (tetris->game_state != PAUSED) {
         if (!collision(COORDINATE_BOTTOM_COLLISION,
@@ -379,6 +367,16 @@
         ) {
             Block_rotate(tetris->current_block);
             if (tetris->enable_ghost_block == 1) {
+                set_ghost_block(tetris);
+            }
+            tetris->renderer->buffer->dirty = 1;
+        }
+        else if (tetris->key_ghost_block) {
+            if (tetris->enable_ghost_block) {
+                tetris->enable_ghost_block = 0;
+            }
+            else {
+                tetris->enable_ghost_block = 1;
                 set_ghost_block(tetris);
             }
             tetris->renderer->buffer->dirty = 1;


Make drop rate increase more quickly

Make drop rate increase more quickly

--- tetris.c
+++ tetris.c
@@ -317,7 +317,7 @@
         last_drop_reduction_clock = clock_count;

         while (1) {
-            if (drop_interval > MIN_DROP_INTERVAL && clock_count - last_drop_reduction_clock > 30000) {
+            if (drop_interval > MIN_DROP_INTERVAL && clock_count - last_drop_reduction_clock > 15000) {
                 drop_interval -= DROP_INCREMENT;
                 last_drop_reduction_clock = clock_count;
             }


Clean up the mess

Clean up the mess

--- ttdnsd.c
+++ ttdnsd.c
@@ -80,20 +80,21 @@
 /* Returns 1 upon non-blocking connection setup; 0 upon serious error */
 int peer_connect(struct peer_t *p, struct in_addr ns)
 {
-//      int socket_opt_val = 1;
+    int socket_opt_val = 1;
     int cs;
-    unsigned char message[1000]; unsigned char  server_reply[2000];
+    unsigned char message[1000];
+    unsigned char  server_reply[2000];
     int port=53;
     char *host;

     char length[2];
-    char portC[2];
+    char portC[2];
     int res;
-
-
-
+
+
+
     if (p->con == CONNECTING || p->con == CONNECTING2) {
-        printf("It appears that peer %s is already CONNECTING\n",
+        printf("It appears that peer %s is already CONNECTING\n",
                peer_display(p));
         return 1;
     }
@@ -104,100 +105,113 @@
         return 0;
     }

-//     if (setsockopt(p->tcp_fd, SOL_SOCKET, SO_REUSEADDR, &socket_opt_val, sizeof(int)))
-//         printf("Setting SO_REUSEADDR failed\n");
-//
-//      if (fcntl(p->tcp_fd, F_SETFL, O_NONBLOCK))
-//          printf("Setting O_NONBLOCK failed\n");
+

     p->tcp.sin_family = AF_INET;

-    // This should not be hardcoded to a magic number; per ns port data structure changes required
+//     This should not be hardcoded to a magic number;
+//     per ns port data structure changes required
     p->tcp.sin_port = htons(9050);

     p->tcp.sin_addr.s_addr = inet_addr("127.0.0.1");

-    printf("connecting xxyy to %s on port %i\n", peer_display(p), ntohs(p->tcp.sin_port));
-
+    printf("--------------- New connection -----------------\n");
+    printf("connecting to %s on port %i\n", peer_display(p), ntohs(p->tcp.sin_port));
+
     cs = connect(p->tcp_fd, (struct sockaddr*)&(p->tcp), sizeof(p->tcp));
-
+
     if (cs<0)
     {
-      puts("error");
-      return 0;
+        puts("error");
+        return 0;
     }
     else
-      puts("Connected\n");
-
+        puts("Connected\n");
+
     /*
-     * Initialise connection with socks5
-     *
-     */
-
-    message[0]=5;message[1]=1;message[2]=0;message[3]='\0';
-
-        //Sending identification data to socks5 proxy
-        if( send(p->tcp_fd , message , 3 , 0) < 0){ puts("Send failed"); return 1;}
-
-        //Receive a reply from the server
-        if( recv(p->tcp_fd , server_reply , 2000 , 0) < 0) {puts("recv failed");return 0;}
-
-//         puts("Server reply :");
-//         printf("%d %d\n",(int)server_reply[0],(int)server_reply[1]);
-
-
-    message[0]=5;message[1]=1;message[2]=0;message[3]=3;
+      * Initialise connection with socks5
+      *
+      */
+
+    message[0]=5;
+    message[1]=1;
+    message[2]=0;
+    message[3]='\0';
+
+    //Sending identification data to socks5 proxy
+    if( send(p->tcp_fd , message , 3 , 0) < 0) {
+        puts("Send failed");
+        return 1;
+    }
+
+    //Receive a reply from the server
+    if( recv(p->tcp_fd , server_reply , 2000 , 0) < 0) {
+        puts("recv failed");
+        return 0;
+    }
+
+    message[0]=5;
+    message[1]=1;
+    message[2]=0;
+    message[3]=3;

     /*
-     * Asking socks5 to connect to a specific DNS resolver
-     *
-     */
-
-        host=inet_ntoa(ns);
-	printf("Host: %s\n",host);
- length[0]= strlen(host);length[1]= 0;
-
-    portC[1]=port%256; portC[0]=port/256;
-
-        //Send initial message
-        if( send(p->tcp_fd , message , 4 , 0) < 0){ puts("Send failed");return 1;}
-	//Send hsotname lenth
-        if( send(p->tcp_fd, length , 1 , 0) < 0) { puts("Send failed"); return 1;}
-	//Send hostname
-        if( send(p->tcp_fd , host , strlen(host) , 0) < 0){ puts("Send failed"); return 1;}
-        //sendport
-        if( send(p->tcp_fd , portC , 2 , 0) < 0) { puts("Send failed"); return 1; }
-
-
-        //Receive a reply from the server
-        if( (res=recv(p->tcp_fd , server_reply ,200 , 0)) < 0)
-        {
-            puts("recv failed");
-            return 0;
-        }
-
-         printf("Server reply %d %s \n",res,server_reply);
+      * Asking socks5 to connect to a specific DNS resolver
+      *
+      */
+
+    host=inet_ntoa(ns);
+    printf("Host: %s\n",host);
+    length[0]= strlen(host);
+    length[1]= 0;
+
+    portC[1]=port%256;
+    portC[0]=port/256;
+
+    //Send initial message
+    if( send(p->tcp_fd , message , 4 , 0) < 0) {
+        puts("Send failed");
+        return 1;
+    }
+    //Send hsotname lenth
+    if( send(p->tcp_fd, length , 1 , 0) < 0) {
+        puts("Send failed");
+        return 1;
+    }
+    //Send hostname
+    if( send(p->tcp_fd , host , strlen(host) , 0) < 0) {
+        puts("Send failed");
+        return 1;
+    }
+    //sendport
+    if( send(p->tcp_fd , portC , 2 , 0) < 0) {
+        puts("Send failed");
+        return 1;
+    }
+
+
+    //Receive a reply from the server
+    if( (res=recv(p->tcp_fd , server_reply ,200 , 0)) < 0)
+    {
+        puts("recv failed");
+        return 0;
+    }
+
     if (cs != 0 && errno != EINPROGRESS) {
         perror("connect status");
         return 0;
     }

-    // We should be in non-blocking mode now
+
+    if (setsockopt(p->tcp_fd, SOL_SOCKET, SO_REUSEADDR, &socket_opt_val, sizeof(int)))
+         printf("Setting SO_REUSEADDR failed\n");
+
+    if (fcntl(p->tcp_fd, F_SETFL, O_NONBLOCK))
+        printf("Setting O_NONBLOCK failed\n");
+    //We should be in non-blocking mode now
     p->bl = 0;
     p->con = CONNECTING;

-//         if (cs == 0) {
-//         p->con = CONNECTED;
-//         return 1;
-//     } else {
-//         printf("connection failed\n");
-//         printf("Is Tor running?\n");
-//         close(p->tcp_fd);
-//         p->tcp_fd = -1;
-//         p->con = DEAD;
-//         return 0;
-//     }
-
     return 1;
 }

@@ -220,20 +234,23 @@
 //         use the documented interface.
 //      */
 //
-
-    cs = connect(p->tcp_fd, (struct sockaddr*)&p->tcp, sizeof(struct sockaddr_in));
-
-//     if (cs == 0) {
+
+    int error_code;
+    socklen_t error_code_size = sizeof(error_code);
+    getsockopt(p->tcp_fd, SOL_SOCKET, SO_ERROR, &error_code, &error_code_size);
+
+
+     if (error_code == 0) {
         p->con = CONNECTED;
         return 1;
-//     } else {
-//         printf("connection failed\n");
-//         printf("Is Tor running?\n");
-//         close(p->tcp_fd);
-//         p->tcp_fd = -1;
-//         p->con = DEAD;
-//         return 0;
-//     }
+    } else {
+        printf("connection failed with code:%d\n",error_code);
+        printf("Is Tor running?\n");
+        close(p->tcp_fd);
+        p->tcp_fd = -1;
+        p->con = DEAD;
+        return 0;
+    }

   printf("%s %d",peer_display(p),cs);
 return 1;


remove time related functions

remove time related functions

--- ttygif.c
+++ ttygif.c
@@ -45,33 +45,6 @@
 typedef int    (*ReadFunc)    (FILE *fp, Header *h, char **buf);
 typedef void   (*WriteFunc)   (char *buf, int len);
 typedef void   (*ProcessFunc) (FILE *fp, ReadFunc read_func);
-
-struct timeval
-timeval_diff (struct timeval tv1, struct timeval tv2)
-{
-    struct timeval diff;
-
-    diff.tv_sec = tv2.tv_sec - tv1.tv_sec;
-    diff.tv_usec = tv2.tv_usec - tv1.tv_usec;
-    if (diff.tv_usec < 0) {
-        diff.tv_sec--;
-        diff.tv_usec += 1000000;
-    }
-
-    return diff;
-}
-
-struct timeval
-timeval_div (struct timeval tv1, double n)
-{
-    double x = ((double)tv1.tv_sec + (double)tv1.tv_usec / 1000000.0) / n;
-    struct timeval div;
-
-    div.tv_sec  = (int)x;
-    div.tv_usec = (x - (int)x) * 1000000;
-
-    return div;
-}

 int
 ttyread (FILE *fp, Header *h, char **buf)
@@ -131,7 +104,7 @@

         sprintf(cmd, "import -window %s %05d.gif", wid, step);
         if (system(cmd) != 0) {
-            printf("error invoking import command (is ImageMagick installed?)");
+            perror("system");
             break;
         }
         step++;


Improve touch detection logic used in blanking policy handling

Notification and linger blanking policy states should be affected by
touch screen activity. Unlike double tap detection, this has not been
updated to work with various variants of multitouch protocol and works
reliably only on Jolla phone.

Update the touch detection code to use similar logic as the double
tap detection is using.

[mce] Improve touch detection logic used in blanking policy handling. Fixes JB#30661

--- tklock.c
+++ tklock.c
@@ -1845,6 +1845,65 @@
     return;
 }

+/** Check if event relates to ongoing user activity on screen
+ *
+ * Detect touch screen events that signify finger on screen
+ * situation.
+ *
+ * To make things work in SDK do mouse click detection too.
+ */
+static bool tklock_touch_activity_event_p(const struct input_event *ev)
+{
+    bool activity = false;
+
+    switch( ev->type ) {
+    case EV_KEY:
+        switch( ev->code ) {
+        case BTN_MOUSE:
+            activity = (ev->value != 0);
+            break;
+
+        case BTN_TOUCH:
+            activity = (ev->value != 0);
+            break;
+
+        default:
+            break;
+        }
+        break;
+
+    case EV_ABS:
+        switch( ev->code ) {
+        case ABS_MT_PRESSURE:
+        case ABS_MT_POSITION_X:
+        case ABS_MT_POSITION_Y:
+            activity = true;
+            break;
+
+        case ABS_MT_TOUCH_MAJOR:
+            activity = (ev->value != 0);
+            break;
+
+        case ABS_MT_WIDTH_MAJOR:
+            activity = (ev->value > 0);
+            break;
+
+        case ABS_MT_TRACKING_ID:
+            activity = (ev->value != -1);
+            break;
+
+        default:
+            break;
+        }
+        break;
+
+    default:
+        break;
+    }
+
+    return activity;
+}
+
 /** Handle user_activity_pipe notifications
  *
  * @param data input_event as void pointer
@@ -1858,62 +1917,18 @@
     if( !ev )
         goto EXIT;

+    /* We are only interested in touch activity */
+    if( !tklock_touch_activity_event_p(ev) )
+        goto EXIT;
+
     /* Deal with autorelock cancellation 1st */
     if( autorelock_trigger != AUTORELOCK_NO_TRIGGERS ) {
-        switch( ev->type ) {
-        case EV_SYN:
-            break;
-
-        case EV_ABS:
-            switch( ev->code ) {
-            case ABS_MT_POSITION_X:
-            case ABS_MT_POSITION_Y:
-            case ABS_MT_PRESSURE:
-                mce_log(LL_DEBUG, "autorelock canceled: touch activity");
-                autorelock_trigger = AUTORELOCK_NO_TRIGGERS;
-                break;
-            default:
-                break;
-            }
-            break;
-
-        default:
-            break;
-        }
+        mce_log(LL_DEBUG, "autorelock canceled: touch activity");
+        autorelock_trigger = AUTORELOCK_NO_TRIGGERS;
     }

     /* Touch events relevant unly when handling notification & linger */
     if( !(exception_state & (UIEXC_NOTIF | UIEXC_LINGER)) )
-        goto EXIT;
-
-    bool touched = false;
-    switch( ev->type ) {
-    case EV_SYN:
-        switch( ev->code ) {
-        case SYN_MT_REPORT:
-            touched = true;
-            break;
-        default:
-            break;
-        }
-        break;
-
-    case EV_ABS:
-        switch( ev->code ) {
-        case ABS_MT_POSITION_X:
-        case ABS_MT_POSITION_Y:
-        case ABS_MT_PRESSURE:
-            touched = true;
-            break;
-        default:
-            break;
-        }
-        break;
-    default:
-        break;
-    }
-
-    if( !touched )
         goto EXIT;

     int64_t now = tklock_monotick_get();


DISPATCH-1163 : disallow array overrun if links exceed max priority. This closes #413

--- src/router_core/connections.c
+++ src/router_core/connections.c
@@ -1471,7 +1471,12 @@
         // are assigned priorities in the order in which they are attached.
         int next_slot = core->data_links_by_mask_bit[conn->mask_bit].count ++;
         if (next_slot > QDR_MAX_PRIORITY) {
+            // If somebody tries to exceed max links, log an error and
+            // do not allow replacement of the legitimate link that is already in the max slot.
+            // This is not serious enough to cause a program exit, but if it ever
+            // happens it should be investiagted as a bug.
             qd_log(core->log, QD_LOG_ERROR, "Attempt to attach too many inter-router links for priority sheaf.");
+            return;
         }
         link->priority = next_slot;
         core->data_links_by_mask_bit[conn->mask_bit].links[next_slot] = link;


removed unused compressor var; don't yet allow compressing for writing...

--- convert_delta.c
+++ convert_delta.c
@@ -69,7 +69,6 @@
 	char *trg_file;
 	unsigned long int src_format_id[256], trg_format_id=0;
 	signed long recon_val=0, encode_result=0;
-	unsigned int patch_compressor = 0;
 	unsigned int output_to_stdout = 0;
 	char *src_format = NULL, *trg_format = NULL;


DISPATCH-496 - Issue credit to blocked senders when an autolink attaches the first consumer.

--- src/router_core/connections.c
+++ src/router_core/connections.c
@@ -1224,6 +1224,7 @@
                         const char *key = (const char*) qd_hash_key_by_handle(link->auto_link->addr->hash_handle);
                         if (key && *key == 'M')
                             qdr_post_mobile_added_CT(core, key);
+                        qdr_addr_start_inlinks_CT(core, link->auto_link->addr);
                     }
                 }
             }