- use memcpy instead of uint64_t pointer for pipe status event

as dereferencing an unaligned uint64_t* halts Arduino Zero (#23)

--- nRF8001.cpp
+++ nRF8001.cpp
@@ -995,18 +995,21 @@
         break;

       case ACI_EVT_PIPE_STATUS: {
-        uint64_t* openPipes = (uint64_t*)&aciEvt->params.pipe_status.pipes_open_bitmap;
-        uint64_t* closedPipes = (uint64_t*)&aciEvt->params.pipe_status.pipes_closed_bitmap;
-
 #ifdef NRF_8001_DEBUG
         Serial.println(F("Evt Pipe Status "));
-
-        Serial.println((unsigned long)*openPipes, HEX);
-        Serial.println((unsigned long)*closedPipes, HEX);
+#endif
+        uint64_t closedPipes;
+        memcpy(&closedPipes, aciEvt->params.pipe_status.pipes_closed_bitmap, sizeof(closedPipes));
+
+#ifdef NRF_8001_DEBUG
+        uint64_t openPipes;
+        memcpy(&openPipes, aciEvt->params.pipe_status.pipes_open_bitmap, sizeof(openPipes));
+
+        Serial.println((unsigned long)openPipes, HEX);
+        Serial.println((unsigned long)closedPipes, HEX);
 #endif
         bool discoveryFinished = lib_aci_is_discovery_finished(&this->_aciState);
-
-        if ((unsigned long)*closedPipes == 0 && !discoveryFinished) {
+        if (closedPipes == 0 && !discoveryFinished) {
           this->_closedPipesCleared = true;
         }


removed fake description (EXPLAIN) of first table for last SELECT_LEX with global parameters, because now it is absent

--- sql/sql_union.cc
+++ sql/sql_union.cc
@@ -35,7 +35,6 @@
   int res;
   bool found_rows_for_union=false;
   TABLE_LIST result_table_list;
-  TABLE_LIST *first_table=(TABLE_LIST *)lex->select_lex.table_list.first;
   TMP_TABLE_PARAM tmp_table_param;
   select_union *union_result;
   DBUG_ENTER("mysql_union");
@@ -127,8 +126,7 @@
       sl->options&= ~OPTION_FOUND_ROWS;

     res= mysql_select(thd,
-		      (describe && sl->linkage==GLOBAL_OPTIONS_TYPE) ?
-		      first_table :  (TABLE_LIST*) sl->table_list.first,
+		      (TABLE_LIST*) sl->table_list.first,
 		      sl->item_list,
 		      sl->where,
 		      (sl->braces) ?


IntegrateOverRadius: Use new spline wrapper

--- src/IntegrateOverRadius.cpp
+++ src/IntegrateOverRadius.cpp
@@ -5,7 +5,6 @@
 #include "RadialFunction.h"

 #include <cmath>
-#include <gsl/gsl_spline.h>

 namespace {
@@ -20,20 +19,11 @@

   class RadialInterpFunction : public GSL::FunctionObject {
     private:
-      gsl_interp_accel* acc;
-      gsl_spline* spline;
+      GSL::Spline spline;
     public:
-      RadialInterpFunction(const RadialFunction& f) {
-        acc = gsl_interp_accel_alloc();
-        spline = gsl_spline_alloc(gsl_interp_cspline, f.radii.size());
-        gsl_spline_init(spline, f.radii.data(), f.data.data(), f.radii.size());
-      }
-      ~RadialInterpFunction() {
-        gsl_spline_free(spline);
-        gsl_interp_accel_free(acc);
-      }
+      RadialInterpFunction(const RadialFunction& f) : spline(f) {}
       double operator()(double x) const {
-        return gsl_spline_eval(spline, x, acc);
+        return spline.eval(x);
       }
   };
 } // helper namespace


(BlockLevelBox::layOutText, isAtLeftEdge, isAtRightEdge) : Check empty inline elements placed at the left edge and the right edge strictly; cf. block-in-inline-insert-006.

--- www/css/LineBox.cpp
+++ www/css/LineBox.cpp
@@ -43,16 +43,26 @@

 namespace {

-// TODO: there might not be such a text node that 'element.getFirstChild() == node'.
-bool isAtLeftEdge(Element& element, Node& node)
-{
-    return element == node || element.getFirstChild() == node;
-}
-
-// TODO: there might not be such a text node that 'element.getLastNode() == node'.
-bool isAtRightEdge(Element& element, Node& node)
-{
-    return element == node || element.getLastChild() == node;
+bool isAtLeftEdge(Element& element, Node& node, CSSStyleDeclarationImp* style)
+{
+    if (element != node)
+        return element.getFirstChild() == node;
+    if (!element.hasChildNodes())
+        return true;
+    return !style->getBox();
+}
+
+bool isAtRightEdge(Element& element, Node& node, CSSStyleDeclarationImp* style)
+{
+    if (element != node)
+        return element.getLastChild() == node;
+    if (!element.hasChildNodes())
+        return true;
+    if (style->getBox())
+        return true;
+    if (style->marginLeft.getPx() || style->borderLeftWidth.getPx() || style->paddingLeft.getPx())
+        return false;
+    return true;
 }

 CSSStyleDeclarationImp* setActiveStyle(ViewCSSImp* view, CSSStyleDeclarationImp* style, FontTexture*& font, float& point)
@@ -313,9 +323,8 @@
             inlineBox = new(std::nothrow) InlineLevelBox(text, activeStyle);
             if (!inlineBox)
                 return false;  // TODO error
-            style->addBox(inlineBox);  // activeStyle? maybe not...
             inlineBox->resolveWidth();
-            if (0 < position || !isAtLeftEdge(element, text))
+            if (0 < position || !isAtLeftEdge(element, text, style))
                 inlineBox->clearBlankLeft();
         } else {
             inlineBox->setStyle(activeStyle);
@@ -333,7 +342,7 @@

         if (data.empty()) {
             inlineBox->setData(font, point, data, 0, 0);
-            if (!isAtRightEdge(element, text)) {
+            if (!isAtRightEdge(element, text, style)) {
                 inlineBox->clearBlankRight();
                 blankRight = 0;
             }
@@ -369,7 +378,7 @@
                 float w = measureText(view, activeStyle, p, next - wrap, point, isFirstCharacter, glyph, transformed);
                 p += next - wrap;
                 isFirstCharacter = true;
-                if (firstLetterStyle || data.length() <= next && isAtRightEdge(element, text))
+                if (firstLetterStyle || data.length() <= next && isAtRightEdge(element, text, style))
                     w += blankRight;
                 while (context->leftover < w && (context->breakable || activeStyle->whiteSpace.isBreakingLines())) {
                     if (activeStyle->whiteSpace.isCollapsingSpace() && 0 < transformed.length() && transformed[transformed.length() - 1] == u' ') {
@@ -453,7 +462,7 @@
             inlineBox->width += advanced;
             position = next;

-            if (firstLetterStyle || data.length() <= position && isAtRightEdge(element, text))
+            if (firstLetterStyle || data.length() <= position && isAtRightEdge(element, text, style))
                 inlineBox->width -= blankRight;
             else {
                 inlineBox->clearBlankRight();
@@ -480,6 +489,7 @@
         // Switch height from 'line-height' to the content height.
         if (inlineBox->hasHeight())
             inlineBox->height = font->getLineHeight(point);
+        style->addBox(inlineBox);  // activeStyle? maybe not...
         if (data.length() <= position) {  // layout done?
             if (linefeed)
                 context->nextLine(view, this, linefeed);


more on realtime param

more on realtime param

--- ffmpeg_player_output.cpp
+++ ffmpeg_player_output.cpp
@@ -25,7 +25,7 @@
 #include <mach/mach_error.h>
 #include <mach/mach_time.h>
 #endif
-static void setRealtime();
+static void setRealtime(double dutyCicleMs);

 /*
 The implementation with the PortAudio callback was there first.
@@ -84,9 +84,10 @@
 		void *userData )
 	{
 		OutStream* outStream = (OutStream*) userData;
+		PlayerObject* player = outStream->player;

 		if(outStream->needRealtimeReset.exchange(false))
-			setRealtime();
+			setRealtime(1000.0 * frameCount / player->outSamplerate);

 		if(outStream->setThreadName.exchange(false))
 			setCurThreadName("audio callback");
@@ -99,7 +100,7 @@
 		// We must not hold the PyGIL here!
 		// Also no need to hold the player lock, all is safe!

-		outStream->player->readOutStream((OUTSAMPLE_t*) output, frameCount * outStream->player->outNumChannels, NULL);
+		player->readOutStream((OUTSAMPLE_t*) output, frameCount * outStream->player->outNumChannels, NULL);
 		return paContinue;
 	}
 #else
@@ -314,7 +315,7 @@
 // https://developer.apple.com/library/mac/#documentation/Darwin/Conceptual/KernelProgramming/scheduler/scheduler.html
 // Also, from Google Native Client, osx/nacl_thread_nice.c has some related code.
 // Or, from Google Chrome, platform_thread_mac.mm. http://src.chromium.org/svn/trunk/src/base/threading/platform_thread_mac.mm
-void setRealtime() {
+void setRealtime(double dutyCicleMs) {
 	kern_return_t ret;
 	thread_port_t threadport = pthread_mach_thread_np(pthread_self());

@@ -347,9 +348,10 @@
 	double timeFact = ((double)tb_info.denom / (double)tb_info.numer) * 1000000;

 	thread_time_constraint_policy_data_t ttcpolicy;
-	ttcpolicy.period = 2.9 * timeFact; // in Chrome: 2.9ms ~= 128 frames @44.1KHz
-	ttcpolicy.computation = 0.75 * ttcpolicy.period;
-	ttcpolicy.constraint = 0.85 * ttcpolicy.period;
+	// in Chrome: period = 2.9ms ~= 128 frames @44.1KHz, comp = 0.75 * period, constr = 0.85 * period.
+	ttcpolicy.period = dutyCicleMs * timeFact;
+	ttcpolicy.computation = dutyCicleMs * 0.75 * timeFact;
+	ttcpolicy.constraint = dutyCicleMs * 0.85 * timeFact;
 	ttcpolicy.preemptible = 0;

 	ret = thread_policy_set(threadport,
@@ -362,8 +364,8 @@
 	}
 }
 #else
-void setRealtime() {} // not implemented yet
-#endif
-
-
-
+void setRealtime(double dutyCicleMs) {} // not implemented yet
+#endif
+
+
+


cleanup

cleanup

--- src/animation/animation_scene.cpp
+++ src/animation/animation_scene.cpp
@@ -100,29 +100,6 @@
 class Engine;
 class JsonSerializer;
 class Universe;
-
-
-struct AnimationSystemImpl LUMIX_FINAL : public IPlugin
-{
-	explicit AnimationSystemImpl(Engine& engine);
-	~AnimationSystemImpl();
-
-
-	void registerLuaAPI();
-	void createScenes(Universe& ctx) override;
-	void destroyScene(IScene* scene) override;
-	const char* getName() const override { return "animation"; }
-
-	IAllocator& m_allocator;
-	Engine& m_engine;
-	AnimationManager m_animation_manager;
-	Anim::ControllerManager m_controller_manager;
-
-private:
-	void operator=(const AnimationSystemImpl&);
-	AnimationSystemImpl(const AnimationSystemImpl&);
-};
-

 struct AnimationSceneImpl LUMIX_FINAL : public AnimationScene


add application/ogg mime type
BUG=18000
TEST=unknown which websites this affects.  ask andrew who reported the bug.

Review URL: http://codereview.chromium.org/159683

git-svn-id: dd90618784b6a4b323ea0c23a071cb1c9e6f2ac7@22275 4ff67af0-8c30-449e-8e8b-ad334ec8d88c


Added optional use of MPI (for PANN).

Added optional use of MPI (for PANN).

git-svn-id: 602a26e73ae9f2a14e2bb95676f2e137fcc39919@1647 7c0444ca-5550-0410-9008-faecdbe78eb5

--- src/io/imageio.cpp
+++ src/io/imageio.cpp
@@ -1,8 +1,7 @@
-#include "../columns/Communicator.hpp"
+#include "imageio.hpp"

 #include <assert.h>
 #include <gdal_priv.h>
-#include <mpi.h>
 #include <ogr_spatialref.h>

 #undef DEBUG_OUTPUT
@@ -86,8 +85,10 @@
       GDALClose(dataset);
    }

+#ifdef PV_USE_MPI
    // broadcast location information
    MPI_Bcast(locBuf, 1+locSize, MPI_INT, 0, comm->communicator());
+#endif

    copyFromLocBuffer(locBuf, loc);

@@ -105,10 +106,7 @@
                      PV::Communicator * comm, LayerLoc * loc, float * buf)
 {
    int status = 0;
-   const int tag = 13;
    const int maxBands = 3;
-
-   const MPI_Comm mpi_comm = comm->communicator();

    const int nxProcs = comm->numCommColumns();
    const int nyProcs = comm->numCommRows();
@@ -122,10 +120,15 @@
    assert(numBands <= maxBands);

    const int nxny     = nx * ny;
-   const int numTotal = nxny * numBands;

    if (icRank > 0) {
+#ifdef PV_USE_MPI
+      const int numTotal = nxny * numBands;
+
       const int src = 0;
+      const int tag = 13;
+      const MPI_Comm mpi_comm = comm->communicator();
+
       for (int b = 0; b < numBands; b++) {
          MPI_Recv(&buf[b*nxny], numTotal, MPI_FLOAT, src, tag, mpi_comm, MPI_STATUS_IGNORE);
       }
@@ -133,6 +136,7 @@
       fprintf(stderr, "[%2d]: scatter: received from 0, nx==%d ny==%d size==%d\n",
               comm->commRank(), nx, ny, numTotal);
 #endif
+#endif // PV_USE_MPI
    }
    else {
       GDALAllRegister();
@@ -163,7 +167,11 @@
          band[b] = dataset->GetRasterBand(b+1);
       }

+#ifdef PV_USE_MPI
       int dest = -1;
+      const int tag = 13;
+      const MPI_Comm mpi_comm = comm->communicator();
+
       for (int py = 0; py < nyProcs; py++) {
          for (int px = 0; px < nxProcs; px++) {
             if (++dest == 0) continue;
@@ -182,6 +190,7 @@
             }
          }
       }
+#endif // PV_USE_MPI

       // get local image portion
       for (int b = 0; b < numBands; b++) {
@@ -193,7 +202,6 @@

    return status;
 }
-

 /**
  * @filename
@@ -202,10 +210,7 @@
                     PV::Communicator * comm, LayerLoc * loc, float * buf)
 {
    int status = 0;
-   const int tag = 14;
    const int maxBands = 3;
-
-   const MPI_Comm mpi_comm = comm->communicator();

    const int nxProcs = comm->numCommColumns();
    const int nyProcs = comm->numCommRows();
@@ -218,11 +223,18 @@
    const int numBands = loc->nBands;
    assert(numBands <= maxBands);

-   const int nxny     = nx * ny;
+   const int nxny = nx * ny;
+
+#ifdef PV_USE_MPI
+   const int tag = 14;
    const int numTotal = nxny * numBands;
+   const MPI_Comm mpi_comm = comm->communicator();
+#endif // PV_USE_MPI

    if (icRank > 0) {
+#ifdef PV_USE_MPI
       const int dest = 0;
+
       for (int b = 0; b < numBands; b++) {
          MPI_Send(&buf[b*nxny], nx*ny, MPI_FLOAT, dest, tag, mpi_comm);
       }
@@ -230,10 +242,9 @@
       fprintf(stderr, "[%2d]: gather: sent to 0, nx==%d ny==%d size==%d\n",
               comm->commRank(), nx, ny, nx*ny);
 #endif
+#endif // PV_USE_MPI
    }
    else {
-//#include "cpl_string.h"
-
       GDALAllRegister();

       char ** metadata;
@@ -292,6 +303,7 @@
                            &buf[b*nxny], nx, ny, GDT_Float32, 0, 0);
       }

+#ifdef PV_USE_MPI
       int src = -1;
       for (int py = 0; py < nyProcs; py++) {
          for (int px = 0; px < nxProcs; px++) {
@@ -311,6 +323,7 @@
             }
          }
       }
+#endif // PV_USE_MPI
       GDALClose(dataset);
    }


Add missing whitespace to an else-if

Add missing whitespace to an else-if

--- src/read_context.cc
+++ src/read_context.cc
@@ -162,8 +162,8 @@

   if (res.base.kind == SZ_NULL_POINTER_CHUNK) {
     return SZ_SUCCESS;
-  }else if (   sz_read_prim(stream, &res.length)
-            || sz_read_prim(stream, &res.type)) {
+  } else if (   sz_read_prim(stream, &res.length)
+             || sz_read_prim(stream, &res.type)) {
     return file_error();
   }


fixed broken build

fixed broken build

--- src/types/root_typemanager.cpp
+++ src/types/root_typemanager.cpp
@@ -17,15 +17,19 @@

 #include <zorba/identtypes.h>
 #include <zorba/typeident.h>
+
 #include "zorbatypes/xqpstring.h"
+#include "zorbatypes/datetime.h"
+#include "zorbatypes/duration.h"
+
 #include "system/globalenv.h"
+
+#include "types/root_typemanager.h"
 #include "types/node_test.h"
-#include "types/typeops.h"
+
 #include "store/api/item_factory.h"
 #include "store/api/store.h"
-#include "types/root_typemanager.h"
-#include "zorbatypes/datetime.h"
-#include "zorbatypes/duration.h"
+

 using namespace zorba;
@@ -178,9 +182,9 @@
 #undef Q

 //                                       1  ?  *  +
-const int TypeOps::QUANT_MIN_CNT [4] = { 1, 0, 0, 1 };
-
-const int TypeOps::QUANT_MAX_CNT [4] = { 1, 1, 2, 2 };
+const int RootTypeManager::QUANT_MIN_CNT [4] = { 1, 0, 0, 1 };
+
+const int RootTypeManager::QUANT_MAX_CNT [4] = { 1, 1, 2, 2 };

 #define ATOMIC_QNAMETYPE_MAP_SIZE 50


implement a faster acyclicity check

implement a faster acyclicity check

--- src/vg.cpp
+++ src/vg.cpp
@@ -4149,7 +4149,18 @@
 }

 bool VG::is_acyclic(void) {
-    return multinode_strongly_connected_components().empty();
+    set<Node*> seen;
+    dfs([&](Node* node) {
+            if (seen.count(node)) {
+                return false;
+            } else {
+                seen.insert(node);
+            }
+        },
+        [&](Node* node) {
+            seen.erase(node);
+        });
+    return true;
 }

 set<set<id_t> > VG::multinode_strongly_connected_components(void) {


update

update

--- src/ssdb/t_zset.cpp
+++ src/ssdb/t_zset.cpp
@@ -384,7 +384,6 @@
 	it = this->iterator(it_start, it_end, UINT64_MAX);
 	size = 0;
 	while(it->next()){
-		size ++;
 		Bytes ks = it->key();
 		//Bytes vs = it->val();
 		//dump(ks.data(), ks.size(), "z.next");
@@ -397,6 +396,7 @@
 			size = -1;
 			break;
 		}
+		size ++;

 		std::string buf = encode_zset_key(name, key);
 		std::string score2;
@@ -447,7 +447,6 @@
 	it = this->iterator(it_start, it_end, UINT64_MAX);
 	size = 0;
 	while(it->next()){
-		size ++;
 		Bytes ks = it->key();
 		//Bytes vs = it->val();
 		//dump(ks.data(), ks.size(), "z.next");
@@ -463,6 +462,7 @@
 		if(name != name2){
 			break;
 		}
+		size ++;
 		Bytes score = it->val();

 		std::string buf = encode_zscore_key(name, key, score);


魔女天火断空

魔女天火断空

--- DiceGameServer/role/MoNv.cpp
+++ DiceGameServer/role/MoNv.cpp
@@ -270,6 +270,7 @@
 		setToken(0, token[0]-1);
 		GameInfo game_info;
 		Coder::tokenNotice(id, 0, token[0], game_info);
+		engine->sendMessage(-1, MSG_GAME, game_info);
 	}
 	int harmPoint = 3;
 	int dstColor = engine->getPlayerEntity(dstID)->getColor();


Make forward declaration of node_prop_t private.

--- simrank.hpp
+++ simrank.hpp
@@ -79,7 +79,9 @@
 		inline edge_t(node_t head, node_t tail, float_t weight) : head(head), tail(tail), weight(weight) {}
 	};

+private:
 	struct node_prop_t;
+public:
 	// Iterate over all nodes, e.g. "for (node_t x : simrank.nodes()) { ... }"
 	inline const Key_Iterator_Wrapper<umap<node_t, node_prop_t>> nodes(void) const {
 		return Key_Iterator_Wrapper<umap<node_t, node_prop_t>>(node_properties_);


Assert that we're actually freeing page allocations

--- malloc.cpp
+++ malloc.cpp
@@ -559,6 +559,11 @@
 	debug("Free: Page %p (%ld pages)\n", ptr, npages);
 	while (npages--)
 	{
+		IFDEBUG(
+		void* page = (u8*)ptr + npages * PAGE_SIZE;
+		pageinfo* info = get_pageinfo(page);
+		assert(IS_MAGIC_PAGE(info) && (info == MAGIC_PAGE_FIRST || info == MAGIC_PAGE_FOLLO));
+		)
 		free_page((u8*)ptr + npages * PAGE_SIZE);
 	}
 }


Revert changes to lacsap.cpp

Revert changes to lacsap.cpp

--- lacsap.cpp
+++ lacsap.cpp
@@ -1,7 +1,6 @@
 #include "lexer.h"
 #include "parser.h"
 #include "binary.h"
-#include "types.h"
 #include <iostream>
 #include <fstream>
 #include "llvm/Bitcode/ReaderWriter.h"
@@ -19,7 +18,6 @@
 llvm::FunctionPassManager* fpm;
 static llvm::ExecutionEngine* theExecutionEngine;
 llvm::Module* theModule = new llvm::Module("TheModule", llvm::getGlobalContext());
-Types types;

 void DumpModule(llvm::Module* module)
 {
@@ -86,6 +84,7 @@
     try
     {
 	ExprAST* ast;
+	Types types;
 	Lexer l(filename, types);
 	Parser p(l, types);
 	OptimizerInit();


travis nth fix

travis nth fix

--- tests/test_tilemap.cpp
+++ tests/test_tilemap.cpp
@@ -12,6 +12,7 @@
 	sp<VoxelMap> voxel;

 	Vec3<float> getPosition() const override { return this->position; }
+	bool hasVoxelMap() override { return true; }
 	sp<VoxelMap> getVoxelMap(Vec3<int>) override { return this->voxel; }

 	FakeSceneryTileObject(TileMap &map, Vec3<float> bounds, sp<VoxelMap> voxelMap)


Prevent focus reset when typing in the compute debug selector

--- qrenderdoc/Widgets/ComputeDebugSelector.cpp
+++ qrenderdoc/Widgets/ComputeDebugSelector.cpp
@@ -86,6 +86,9 @@

 void ComputeDebugSelector::SyncGroupThreadValue()
 {
+  QSignalBlocker blockers[3] = {QSignalBlocker(ui->dispatchX), QSignalBlocker(ui->dispatchY),
+                                QSignalBlocker(ui->dispatchZ)};
+
   ui->dispatchX->setValue(ui->groupX->value() * m_threadGroupSize[0] + ui->threadX->value());
   ui->dispatchY->setValue(ui->groupY->value() * m_threadGroupSize[1] + ui->threadY->value());
   ui->dispatchZ->setValue(ui->groupZ->value() * m_threadGroupSize[2] + ui->threadZ->value());
@@ -99,6 +102,10 @@
   uint32_t thread[3] = {ui->dispatchX->value() % m_threadGroupSize[0],
                         ui->dispatchY->value() % m_threadGroupSize[1],
                         ui->dispatchZ->value() % m_threadGroupSize[2]};
+
+  QSignalBlocker blockers[6] = {QSignalBlocker(ui->groupX),  QSignalBlocker(ui->groupY),
+                                QSignalBlocker(ui->groupZ),  QSignalBlocker(ui->threadX),
+                                QSignalBlocker(ui->threadY), QSignalBlocker(ui->threadZ)};

   ui->groupX->setValue(group[0]);
   ui->groupY->setValue(group[1]);


comboreduct: fixed IGNORE_BOOST_GRAPH so that it is disabled for newer versions of boost

--- opencog/comboreduct/combo/procedure_repository.cc
+++ opencog/comboreduct/combo/procedure_repository.cc
@@ -26,8 +26,11 @@

 #include <boost/version.hpp>

+// this is to avoid a boost bug
 #if BOOST_VERSION >= 104000
+#if BOOST_VERSION <= 104400
 #define IGNORE_BOOST_GRAPH
+#endif
 #endif

 #ifndef IGNORE_BOOST_GRAPH


BUG: Fixed error in passing position of key press

Thanks to Maarten Beek for pointing this out on the VTK users list.

Change-Id: Ic964ff5bb3b8c69560ff7c80a1a0eee976ff5be3

--- Views/Context2D/vtkContextInteractorStyle.cxx
+++ Views/Context2D/vtkContextInteractorStyle.cxx
@@ -402,7 +402,7 @@
   this->BeginProcessingEvent();
   vtkContextKeyEvent event;
   vtkVector2i position(this->Interactor->GetEventPosition()[0],
-                       this->Interactor->GetEventPosition()[0]);
+                       this->Interactor->GetEventPosition()[1]);
   event.SetInteractor(this->Interactor);
   event.SetPosition(position);
   bool keepEvent = false;
@@ -423,7 +423,7 @@
   this->BeginProcessingEvent();
   vtkContextKeyEvent event;
   vtkVector2i position(this->Interactor->GetEventPosition()[0],
-                       this->Interactor->GetEventPosition()[0]);
+                       this->Interactor->GetEventPosition()[1]);
   event.SetInteractor(this->Interactor);
   event.SetPosition(position);
   bool keepEvent = false;


Fixes bug in MIPS IL.

Fixes bug in MIPS IL.

TBR: regis, srdjan

Review URL: https://codereview.chromium.org//23095007

git-svn-id: c93d8a2297af3b929165606efe145742a534bc71@26197 260f80e4-7a28-3924-810f-c04153c831b5

--- runtime/vm/intermediate_language_mips.cc
+++ runtime/vm/intermediate_language_mips.cc
@@ -3232,26 +3232,24 @@

 LocationSummary* UnaryDoubleOpInstr::MakeLocationSummary() const {
   const intptr_t kNumInputs = 1;
-  const intptr_t kNumTemps = 2;
+  const intptr_t kNumTemps = 1;
   LocationSummary* summary =
       new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kNoCall);
   summary->set_in(0, Location::RequiresFpuRegister());
   summary->set_out(Location::RequiresFpuRegister());
-  summary->set_temp(0, Location::RequiresRegister());
-  summary->set_in(2, Location::RequiresFpuRegister());
+  summary->set_temp(0, Location::RequiresFpuRegister());
   return summary;
 }

 void UnaryDoubleOpInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
   // TODO(zra): Implement vneg.
-  Register temp = locs()->temp(0).reg();
   const Double& minus_one = Double::ZoneHandle(Double::NewCanonical(-1));
-  __ LoadObject(temp, minus_one);
+  __ LoadObject(TMP, minus_one);
   FpuRegister result = locs()->out().fpu_reg();
   FpuRegister value = locs()->in(0).fpu_reg();
-  FpuRegister temp_fp = locs()->temp(1).fpu_reg();
-  __ LoadDFromOffset(temp_fp, temp, Double::value_offset() - kHeapObjectTag);
+  FpuRegister temp_fp = locs()->temp(0).fpu_reg();
+  __ LoadDFromOffset(temp_fp, TMP, Double::value_offset() - kHeapObjectTag);
   __ muld(result, value, temp_fp);
 }


#ifndef USE_QISKIT_SPECS

#ifndef USE_QISKIT_SPECS

--- include/qasm/qasm.hpp
+++ include/qasm/qasm.hpp
@@ -31,6 +31,10 @@

 #ifndef QASM_QASM_HPP_
 #define QASM_QASM_HPP_
+
+#ifndef USE_QISKIT_SPECS
+#define USE_QISKIT_SPECS false
+#endif

 namespace qpp {
 namespace qasm {


FIX merge override that removed exact ideal screen update

--- SSPSolution/GraphicsDLL/Direct3DHandler.cpp
+++ SSPSolution/GraphicsDLL/Direct3DHandler.cpp
@@ -110,8 +110,8 @@
 	}

 	DXGI_SWAP_CHAIN_FULLSCREEN_DESC fullScreenDesc;
-	fullScreenDesc.RefreshRate.Numerator = 60;
-	fullScreenDesc.RefreshRate.Denominator = 1;
+	fullScreenDesc.RefreshRate.Numerator = 59994;
+	fullScreenDesc.RefreshRate.Denominator = 1002;
 	fullScreenDesc.Windowed = true;
 	fullScreenDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
 	fullScreenDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;


(BlockLevelBox::layOutText) : Fix a bug; cf. text-align-white-space-001.

--- www/css/LineBox.cpp
+++ www/css/LineBox.cpp
@@ -305,8 +305,8 @@
                     w += blankRight;
                 while (context->leftover < w && (context->breakable || activeStyle->whiteSpace.isBreakingLines())) {
                     if (activeStyle->whiteSpace.isCollapsingSpace() && 0 < transformed.length() && transformed[transformed.length() - 1] == u' ') {
-                        float lineEnd = (next - wrap == 1) ? 0 : w - glyph->advance * font->getScale(point) - activeStyle->letterSpacing.getPx() - activeStyle->wordSpacing.getPx();
-                        if (lineEnd == 0 || lineEnd <= context->leftover) {
+                        float lineEnd = (next - wrap == 1) ? 0.0f : w - glyph->advance * font->getScale(point) - activeStyle->letterSpacing.getPx() - activeStyle->wordSpacing.getPx();
+                        if (lineEnd <= context->leftover) {
                             w = lineEnd;
                             transformed.erase(transformed.length() - 1);
                             inlineData += transformed;


ffmpeg: portaudio: some mac options

ffmpeg: portaudio: some mac options

--- ffmpeg_player_output.cpp
+++ ffmpeg_player_output.cpp
@@ -7,6 +7,11 @@
 #include "ffmpeg.h"

 #include <portaudio.h>
+
+#ifdef __APPLE__
+// PortAudio specific Mac stuff
+#include "pa_mac_core.h"
+#endif

 // For setting the thread priority to realtime on MacOSX.
 #ifdef __APPLE__
@@ -95,18 +100,43 @@
 		if(soundcardOutputEnabled) {
 			if(playing && !player->outStream->stream) {
 				PaError ret;
-				ret = Pa_OpenDefaultStream(
-										   &player->outStream->stream,
-										   0,
-										   player->outNumChannels, // numOutputChannels
-										   paInt16, // sampleFormat
-										   player->outSamplerate, // sampleRate
-										   AUDIO_BUFFER_SIZE / 2, // framesPerBuffer,
-										   &paStreamCallback,
-										   player //void *userData
-										   );
+
+				PaStreamParameters outputParameters;
+
+#ifdef __APPLE__
+				PaMacCoreStreamInfo macInfo;
+				PaMacCore_SetupStreamInfo( &macInfo,
+					paMacCorePlayNice | paMacCorePro );
+
+#endif
+
+				outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
+				//if (outputParameters.device == paNoDevice) {
+				// is this handled anyway by Pa_OpenStream?
+				//}
+				outputParameters.channelCount = player->outNumChannels;
+				outputParameters.sampleFormat = paInt16;
+				outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
+
+#ifdef __APPLE__
+				outputParameters.hostApiSpecificStreamInfo = &macInfo;
+#else
+				outputParameters.hostApiSpecificStreamInfo = NULL;
+#endif
+
+				ret = Pa_OpenStream(
+					&player->outStream->stream,
+					NULL, // no input
+					&outputParameters,
+					player->outSamplerate, // sampleRate
+					AUDIO_BUFFER_SIZE / 2, // framesPerBuffer,
+					paClipOff | paDitherOff,
+					&paStreamCallback,
+					player //void *userData
+					);
+
 				if(ret != paNoError) {
-					PyErr_SetString(PyExc_RuntimeError, "Pa_OpenDefaultStream failed");
+					PyErr_Format(PyExc_RuntimeError, "Pa_OpenDefaultStream failed: (err %i) %s", ret, Pa_GetErrorText(ret));
 					if(player->outStream->stream)
 						player->outStream->close();
 					playing = 0;


[Irc] Handling JOIN and QUIT

[Irc] Handling JOIN and QUIT

Signed-off-by: Slava Barinov <510d44c87a2ae876e47a85f8ba95318c49b378e5@gmail.com>

--- src/ircchannel.cpp
+++ src/ircchannel.cpp
@@ -53,7 +53,9 @@
     const std::string toParse(line);
     std::cerr << "[DEBUG] Parsing irc line:" << toParse << std::endl;

-    std::regex msgRe(":(\\S+)!(\\S+)\\s+PRIVMSG\\s+#(\\S+)\\s+:(.*)\r\n$");
+    std::regex msgRe (":(\\S+)!(\\S+)\\s+PRIVMSG\\s+#(\\S+)\\s+:(.*)\r\n$");
+    std::regex joinRe(":(\\S+)!(\\S+)\\s+JOIN\\s+:#(\\S+)$");
+    std::regex quitRe(":(\\S+)!(\\S+)\\s+QUIT\\s+:#(\\S+)$");
     std::regex pingRe("PING\\s+:(.*)\r\n$");
     std::regex pongRe("PONG\\s+(.*)\r\n$");

@@ -64,23 +66,34 @@
       const auto ping_end = std::chrono::high_resolution_clock::now();
       std::chrono::duration<double> diff = ping_end - _ping_time;
       std::cerr << "[DEBUG] #irc: " << name << "Server pong reply: '" << msgMatches[1].str() << "' in " << diff.count() << "s" << std::endl;
-      return nullptr;
     }
     if (std::regex_search(toParse, msgMatches, pingRe)) {
       const std::string pong = "PONG " + msgMatches[1].str();
       std::cerr << "[DEBUG] #irc: sending " << pong << std::endl;
       send(pong);
-      return nullptr;
+    };
+    if (std::regex_search(toParse, msgMatches, joinRe)) {
+      const auto name = msgMatches[1].str();
+      const auto host = msgMatches[2].str();
+      const auto chan = msgMatches[3].str();
+      std::cerr << "[DEBUG] #irc: user " << name << " has joined " << chan << " from " << host << std::endl;
+    };
+    if (std::regex_search(toParse, msgMatches, quitRe)) {
+      const auto name = msgMatches[1].str();
+      const auto host = msgMatches[2].str();
+      const auto msg = msgMatches[3].str();
+      std::cerr << "[DEBUG] #irc: user " << name << " has left because of " << msg << std::endl;
     };
     if (std::regex_search(toParse, msgMatches, msgRe)) {
       name = msgMatches[1].str();
       text = msgMatches[4].str();
       std::cerr << "[DEBUG] #irc:" << name << ": " << text << std::endl;
+      const auto msg = std::make_shared<const messaging::TextMessage>(_id,
+                                                                      std::make_shared<const messaging::User>(messaging::User(name.c_str())),
+                                                                      text.c_str());
+      return msg;
     };
-    const auto msg = std::make_shared<const messaging::TextMessage>(_id,
-                                                                    std::make_shared<const messaging::User>(messaging::User(name.c_str())),
-                                                                    text.c_str());
-    return msg;
+    return nullptr;
   }

   int IrcChannel::registerConnection() {


attempted fix for multiple-IP udp tracker support. That is, when a hostname resolves to multiple IPs

git-svn-id: 0f340b5413dfe41c73e779333638e6920713caeb@10791 a83610d8-ad2a-0410-a6ab-fc0612d85776

--- src/udp_tracker_connection.cpp
+++ src/udp_tracker_connection.cpp
@@ -309,7 +309,6 @@
 		boost::shared_ptr<request_callback> cb = requester();
 		if (cb) cb->debug_log("*** UDP_TRACKER [ timed out url: %s ]", tracker_req().url.c_str());
 #endif
-		m_abort = true;
 		fail(error_code(errors::timed_out));
 	}


Replace std::queue with std::vector in Libprocess Future.

Use std::vector instead of std::queue to reduce dynamic allocations
and improve performance.

Review: https://reviews.apache.org/r/28196

--- 3rdparty/libprocess/include/process/future.hpp
+++ 3rdparty/libprocess/include/process/future.hpp
@@ -6,11 +6,11 @@

 #include <iostream>
 #include <list>
-#include <queue>
 #include <set>
 #if  __cplusplus >= 201103L
 #include <type_traits>
 #endif // __cplusplus >= 201103L
+#include <vector>

 #include <glog/logging.h>

@@ -547,11 +547,11 @@
     bool associated;
     T* t;
     std::string* message; // Message associated with failure.
-    std::queue<DiscardCallback> onDiscardCallbacks;
-    std::queue<ReadyCallback> onReadyCallbacks;
-    std::queue<FailedCallback> onFailedCallbacks;
-    std::queue<DiscardedCallback> onDiscardedCallbacks;
-    std::queue<AnyCallback> onAnyCallbacks;
+    std::vector<DiscardCallback> onDiscardCallbacks;
+    std::vector<ReadyCallback> onReadyCallbacks;
+    std::vector<FailedCallback> onFailedCallbacks;
+    std::vector<DiscardedCallback> onDiscardedCallbacks;
+    std::vector<AnyCallback> onAnyCallbacks;
   };

   // Sets the value for this future, unless the future is already set,
@@ -570,13 +570,10 @@

   // Helper for executing callbacks that have been registered.
   template <typename C, typename... Arguments>
-  void run(std::queue<C>& callbacks, Arguments&&... arguments)
-  {
-    // TODO(jmlvanre): replace this with a vector and make parameter
-    // const since we can iterate it safely.
-    while (!callbacks.empty()) {
-      callbacks.front()(std::forward<Arguments>(arguments)...);
-      callbacks.pop();
+  void run(const std::vector<C>& callbacks, Arguments&&... arguments)
+  {
+    for (size_t i = 0; i < callbacks.size(); ++i) {
+      callbacks[i](std::forward<Arguments>(arguments)...);
     }
   }

@@ -947,8 +944,10 @@
   // DISCARDED so there should not be any concurrent modifications.
   if (result) {
     internal::run(future.data->onDiscardedCallbacks);
+    future.data->onDiscardedCallbacks.clear();

     internal::run(future.data->onAnyCallbacks, future);
+    future.data->onAnyCallbacks.clear();
   }

   return result;
@@ -1083,6 +1082,7 @@
   // 'Data::onDiscardCallbacks'.
   if (result) {
     internal::run(data->onDiscardCallbacks);
+    data->onDiscardCallbacks.clear();
   }

   return result;
@@ -1157,7 +1157,7 @@
   {
     if (data->state == PENDING) {
       pending = true;
-      data->onAnyCallbacks.push(lambda::bind(&internal::awaited, latch));
+      data->onAnyCallbacks.push_back(lambda::bind(&internal::awaited, latch));
     }
   }
   internal::release(&data->lock);
@@ -1210,7 +1210,7 @@
     if (data->discard) {
       run = true;
     } else if (data->state == PENDING) {
-      data->onDiscardCallbacks.push(std::move(callback));
+      data->onDiscardCallbacks.emplace_back(std::move(callback));
     }
   }
   internal::release(&data->lock);
@@ -1234,7 +1234,7 @@
     if (data->state == READY) {
       run = true;
     } else if (data->state == PENDING) {
-      data->onReadyCallbacks.push(std::move(callback));
+      data->onReadyCallbacks.emplace_back(std::move(callback));
     }
   }
   internal::release(&data->lock);
@@ -1258,7 +1258,7 @@
     if (data->state == FAILED) {
       run = true;
     } else if (data->state == PENDING) {
-      data->onFailedCallbacks.push(std::move(callback));
+      data->onFailedCallbacks.emplace_back(std::move(callback));
     }
   }
   internal::release(&data->lock);
@@ -1282,7 +1282,7 @@
     if (data->state == DISCARDED) {
       run = true;
     } else if (data->state == PENDING) {
-      data->onDiscardedCallbacks.push(std::move(callback));
+      data->onDiscardedCallbacks.emplace_back(std::move(callback));
     }
   }
   internal::release(&data->lock);
@@ -1304,7 +1304,7 @@
   internal::acquire(&data->lock);
   {
     if (data->state == PENDING) {
-      data->onAnyCallbacks.push(std::move(callback));
+      data->onAnyCallbacks.emplace_back(std::move(callback));
     } else {
       run = true;
     }
@@ -1330,7 +1330,7 @@
     if (data->discard) {
       run = true;
     } else if (data->state == PENDING) {
-      data->onDiscardCallbacks.push(callback);
+      data->onDiscardCallbacks.push_back(callback);
     }
   }
   internal::release(&data->lock);
@@ -1354,7 +1354,7 @@
     if (data->state == READY) {
       run = true;
     } else if (data->state == PENDING) {
-      data->onReadyCallbacks.push(callback);
+      data->onReadyCallbacks.push_back(callback);
     }
   }
   internal::release(&data->lock);
@@ -1378,7 +1378,7 @@
     if (data->state == FAILED) {
       run = true;
     } else if (data->state == PENDING) {
-      data->onFailedCallbacks.push(callback);
+      data->onFailedCallbacks.push_back(callback);
     }
   }
   internal::release(&data->lock);
@@ -1403,7 +1403,7 @@
     if (data->state == DISCARDED) {
       run = true;
     } else if (data->state == PENDING) {
-      data->onDiscardedCallbacks.push(callback);
+      data->onDiscardedCallbacks.push_back(callback);
     }
   }
   internal::release(&data->lock);
@@ -1425,7 +1425,7 @@
   internal::acquire(&data->lock);
   {
     if (data->state == PENDING) {
-      data->onAnyCallbacks.push(callback);
+      data->onAnyCallbacks.push_back(callback);
     } else {
       run = true;
     }
@@ -1609,8 +1609,10 @@
   // should not be any concurrent modications.
   if (result) {
     internal::run(data->onReadyCallbacks, *data->t);
+    data->onReadyCallbacks.clear();

     internal::run(data->onAnyCallbacks, *this);
+    data->onAnyCallbacks.clear();
   }

   return result;
@@ -1637,8 +1639,10 @@
   // should not be any concurrent modications.
   if (result) {
     internal::run(data->onFailedCallbacks, *data->message);
+    data->onFailedCallbacks.clear();

     internal::run(data->onAnyCallbacks, *this);
+    data->onAnyCallbacks.clear();
   }

   return result;


Fix logic

Fix logic

--- config/qtcurveconfig.cpp
+++ config/qtcurveconfig.cpp
@@ -1142,7 +1142,7 @@

 void QtCurveConfig::colorTitlebarOnlyChanged()
 {
-    if(colorTitlebarOnly->isChecked())
+    if(!colorTitlebarOnly->isChecked())
         titlebarBlend->setChecked(false);
     updateChanged();
 }
@@ -1150,7 +1150,7 @@
 void QtCurveConfig::titlebarBlendChanged()
 {
     if(titlebarBlend->isChecked())
-        colorTitlebarOnly->setChecked(false);
+        colorTitlebarOnly->setChecked(true);
     updateChanged();
 }


Make no units for UserFunctionDB case insensitive.

--- libsrc/spatialdata/spatialdb/UserFunctionDB.cc
+++ libsrc/spatialdata/spatialdb/UserFunctionDB.cc
@@ -25,6 +25,7 @@
 #include "spatialdata/geocoords/Converter.hh" // USES Converter
 #include "spatialdata/units/Parser.hh" // USES Parser

+#include <string> // USES std::string
 #include <stdexcept> // USES std::runtime_error
 #include <sstream> // USES std::ostringstream
 #include <cassert> // USES assert()
@@ -151,7 +152,7 @@

     const std::string& none = "none";
     for (function_map::iterator iter=_functions.begin(); iter != _functions.end(); ++iter) {
-	if (none != iter->second.units) {
+	if (strcasecmp(none.c_str(),  iter->second.units.c_str()) != 0) {
 	    iter->second.scale = parser.parse(iter->second.units.c_str());
 	} else {
 	    iter->second.scale = 1.0;


Remove incorrect Status feature.

Remove incorrect Status feature.

--- lagsim.cpp
+++ lagsim.cpp
@@ -33,15 +33,11 @@
   printf("  --mtu      bytes    modem maximum transmit unit (default = 1500B)\n");
   printf("  --kbps     kbps     modem baud rate (default = infinite)\n");
   printf("  --queue    kB       modem queue size (default = 64kB)\n");
-  printf("  --red      percent  Random Early Dropping threshold (default = 100%)\n");
+  //printf("  --red      percent  Random Early Dropping threshold (default = 100%)\n");
+  //printf("  --pep               run performance enhancing proxy (PEP)\n");
   printf("  --verbose  0|1      verbosity level (default=0)\n");
   printf("\n");
   printf("Report bugs to chrismerck@gmail.com.\n");
-  /*
-  printf("  --pep               run performance enhancing proxy (PEP)\n");
-  // TODO: support more advanced latency models
-  // What about ICMP replies for
-  */
 }

 bool compare_timeval(const timeval * a, const timeval * b)
@@ -519,20 +515,7 @@
         goto cleanup;
         break;
       default:
-        printf("***Status***\n");
-        for (int i=0; i<2; i++)
-        {
-          printf("  Interface %s\n", pcap_conf[i].if_name);
-          modem_state_t modem = pcap_conf[i].modem;
-          timeval tmp;
-          get_now(&tmp);
-          timersub(&modem.next_free_time,&tmp,&tmp);
-          double queue_delay = max(0.,tmp.tv_sec+tmp.tv_usec/1000000.);
-          printf("    Queue Delay: %1.0f ms\n",queue_delay*1000);
-          printf("    Queue Size: %1.0f KB\n",queue_delay*modem.kbps*8);
-        }
-        printf("\n");
-
+        break;
     }
   }


Fixes #6601.  helgrind/open_injection_6476 works.   Still 22 failures

--- manager.cc
+++ manager.cc
@@ -547,6 +547,7 @@
             if (r != 0) {
                 backup_error(r, "Could not open backup file %s", backup_file_name);
                 free(backup_file_name);
+                source->name_unlock();
                 ignore(pthread_rwlock_unlock(&m_session_rwlock));
                 return r;
             }


enable texture unit 0 on exit, extra checks in debug mode.

--- Visualization_Library_SDK/src/vl/Renderer.cpp
+++ Visualization_Library_SDK/src/vl/Renderer.cpp
@@ -367,7 +367,13 @@
   // clear render states
   opengl_context->applyRenderStates(cur_render_state_set, mDummyStateSet.get(), camera );

+  // enabled texture unit #0
+  VL_glActiveTexture( GL_TEXTURE0 );
+  VL_glClientActiveTexture( GL_TEXTURE0 );
+
   glDisable(GL_SCISSOR_TEST);
+
+  VL_CHECK( opengl_context->isCleanState(true) );

   return render_queue;
 }


Revert "Add CX to know_matrices"

Revert "Add CX to know_matrices"

This reverts commit 2cb10adaf6ed859fe7eecc57b6af130c23403d90.

--- include/qasm/qasm.hpp
+++ include/qasm/qasm.hpp
@@ -47,10 +47,6 @@
     known_matrices{
         ///< generators for various gate constants
         {"cx",
-         [](const std::vector<double>&) {
-             return Gates::get_no_thread_local_instance().CNOT;
-         }},
-        {"CX",
          [](const std::vector<double>&) {
              return Gates::get_no_thread_local_instance().CNOT;
          }},


Fixed missing initflags for audio

Fixed missing initflags for audio

--- final_platform_layer.hpp
+++ final_platform_layer.hpp
@@ -5730,9 +5730,11 @@
 #	endif // FPL_ENABLE_WINDOW

 #	if defined(FPL_ENABLE_AUDIO)
-		if (audio::InitAudio(initSettings.audio) != audio::AudioResult::Success) {
-			common::PushError("[Win32] Failed initialization audio with settings (Driver=%s, Format=%s, SampleRate=%lu, Channels=%lu, BufferSize=%lu)!", audio::GetAudioDriverString(initSettings.audio.driver), audio::GetAudioFormatString(initSettings.audio.desiredFormat.type), initSettings.audio.desiredFormat.sampleRate, initSettings.audio.desiredFormat.channels);
-			return false;
+		if (win32State.initFlags & InitFlags::Audio) {
+			if (audio::InitAudio(initSettings.audio) != audio::AudioResult::Success) {
+				common::PushError("[Win32] Failed initialization audio with settings (Driver=%s, Format=%s, SampleRate=%lu, Channels=%lu, BufferSize=%lu)!", audio::GetAudioDriverString(initSettings.audio.driver), audio::GetAudioFormatString(initSettings.audio.desiredFormat.type), initSettings.audio.desiredFormat.sampleRate, initSettings.audio.desiredFormat.channels);
+				return false;
+			}
 		}
 #	endif


Early out when moving the same column.

Early out when moving the same column.

--- src/realm/table.cpp
+++ src/realm/table.cpp
@@ -892,6 +892,10 @@
 {
     REALM_ASSERT_3(from, <, m_spec.get_public_column_count());
     REALM_ASSERT_3(to,   <, m_spec.get_public_column_count());
+
+    if (from == to)
+        return;
+
     do_move_root_column(from, to);
     adj_move_column(from, to);
     update_link_target_tables_after_column_move(from, to);


net: simplify calculation of number of queues

--- net/dpdk.cc
+++ net/dpdk.cc
@@ -94,7 +94,7 @@

 class dpdk_device : public device {
     uint8_t _port_idx;
-    uint8_t _num_queues;
+    uint16_t _num_queues;
     net::hw_features _hw_features;
     uint8_t _queues_ready = 0;

@@ -123,7 +123,7 @@

 public:
     dpdk_device(boost::program_options::variables_map opts,
-                        uint8_t port_idx, uint8_t num_queues)
+                        uint8_t port_idx, uint16_t num_queues)
         : _port_idx(port_idx)
         , _num_queues(num_queues) {
         _rx_conf_default.rx_thresh.pthresh = default_pthresh;
@@ -237,13 +237,7 @@
     printf("Port %d: max_rx_queues %d max_tx_queues %d\n",
            _port_idx, _dev_info.max_rx_queues, _dev_info.max_tx_queues);

-    if (_num_queues > _dev_info.max_rx_queues) {
-        _num_queues = _dev_info.max_rx_queues;
-    }
-
-    if (_num_queues > _dev_info.max_tx_queues) {
-        _num_queues = _dev_info.max_tx_queues;
-    }
+    _num_queues = std::min({_num_queues, _dev_info.max_rx_queues, _dev_info.max_tx_queues});

     printf("Port %d: using %d %s\n", _port_idx, _num_queues,
            (_num_queues > 1) ? "queues" : "queue");


Removed hardcode from quick tab view.

Removed hardcode from quick tab view.

--- src/ui/uas/UASQuickTabView.cpp
+++ src/ui/uas/UASQuickTabView.cpp
@@ -39,7 +39,7 @@

 	QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
 	ui->tableWidget->setColumnCount(2);
-    ui->tableWidget->setRowCount(6);
+    ui->tableWidget->setRowCount(nameList.count());
     ui->tableWidget->setLineWidth(1);
     ui->tableWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     ui->tableWidget->setStyleSheet("gridline-color : gray");


AABB class: added missing operator== and operator!=

--- Visualization_Library_SDK/src/vlCore/AABB.hpp
+++ Visualization_Library_SDK/src/vlCore/AABB.hpp
@@ -47,39 +47,68 @@
   {
   public:
     AABB();
+
     AABB( const vec3& center, Real radius );
+
     AABB( const vec3& pt1, const vec3& pt2, Real displace=0);

     void setNull() { mMin = 1; mMax = -1; }
+
     bool isNull()  const { return mMin.x() > mMax.x() || mMin.y() > mMax.y() || mMin.z() > mMax.z(); }
+
     bool isPoint() const { return mMin == mMax; }
+
     void enlarge(Real displace);
+
     void addPoint(const vec3& v, Real radius);
+
     bool intersects(const AABB & bb) const;
+
     vec3 clip(const vec3& v, bool clipx=true, bool clipy=true, bool clipz=true) const;
+
     bool isInside(const vec3& v, bool clipx, bool clipy, bool clipz) const;
+
     bool isInside(const vec3& v) const;
+
     Real height() const;
+
     Real width() const;
+
     Real depth() const;
+
+    bool operator==(const AABB& aabb) const
+    {
+      return mMin == aabb.mMin && mMax == aabb.mMax;
+    }
+
+    bool operator!=(const AABB& aabb) const
+    {
+      return !operator==(aabb);
+    }
+
     AABB operator+(const AABB& aabb) const;
+
     const AABB& operator+=(const AABB& other)
     {
       *this = *this + other;
       return *this;
     }
+
     AABB operator+(const vec3& p)
     {
       AABB aabb = *this;
       aabb += p;
       return aabb;
     }
+
     const AABB& operator+=(const vec3& p)
     {
       addPoint(p);
       return *this;
     }
+
     vec3 center() const;
+
     Real area() const
     {
       if (isNull())
@@ -87,6 +116,7 @@
       else
         return width()*height()*depth();
     }
+
     Real longestSideLength() const
     {
       Real side = width();
@@ -96,6 +126,7 @@
         side = depth();
       return side;
     }
+
     void addPoint(const vec3& v)
     {
       if (isNull())
@@ -112,6 +143,7 @@
       if ( mMin.y() > v.y() ) mMin.y() = v.y();
       if ( mMin.z() > v.z() ) mMin.z() = v.z();
     }
+
     void transformed(AABB& aabb, const mat4& mat) const
     {
       aabb.setNull();
@@ -127,6 +159,7 @@
         aabb.addPoint( mat * vec3(maxCorner().x(), minCorner().y(), maxCorner().z()) );
       }
     }
+
     AABB transformed(const mat4& mat) const
     {
       AABB aabb;


CAtlMap -> std::map

CAtlMap -> std::map

git-svn-id: bd6e61130530ab01186c33a20f55445ba6f1e843@58798 954022d7-b5bf-4e40-9824-e11837661b57

--- ASCOfficePPTXFile/PPTXFormat/FileContainer.cpp
+++ ASCOfficePPTXFile/PPTXFormat/FileContainer.cpp
@@ -8,6 +8,8 @@
 #include "DocxFormat/FileTypes.h"
 #include "DocxFormat/External/Hyperlink.h"
 #include "WrapperFile.h"
+
+#include <map>

 namespace PPTX
 {
@@ -103,17 +105,12 @@

 	void FileContainer::write(PPTX::Rels::File& rels, const OOX::CPath& curdir, const OOX::CPath& directory, PPTX::ContentTypes::File& content) const
 	{
-		CAtlMap<CString, size_t> namepair;
-
-		POSITION pos = m_container.GetStartPosition();
-		while (NULL != pos)
+		std::map<CString, size_t> mNamePair;
+		for (std::map<CString, smart_ptr<PPTX::File>>::const_iterator pPair = m_container.begin(); pPair != m_container.end(); ++pPair)
 		{
-			const CAtlMap<CString, smart_ptr<PPTX::File>>::CPair* pPair = m_container.GetNext(pos);
-
-			smart_ptr<PPTX::File>		pFile	= pPair->m_value;
-			smart_ptr<PPTX::External>	pExt	= pFile.smart_dynamic_cast<PPTX::External>();
-
-			if (!pExt.IsInit())
+			smart_ptr<PPTX::File>     pFile = pPair->second;
+			smart_ptr<PPTX::External> pExt  = pFile.smart_dynamic_cast<PPTX::External>();
+			if ( !pExt.IsInit() )
 			{
 				smart_ptr<PPTX::WrapperFile> file = pFile.smart_dynamic_cast<PPTX::WrapperFile>();

@@ -128,14 +125,14 @@

 						OOX::CSystemUtility::CreateDirectories(directory / defdir);
 						pFile->write(directory / defdir / name, directory, content);
-						rels.registration(pPair->m_key, pFile->type(), defdir / name);
+						rels.registration(pPair->first, pFile->type(), defdir / name);
 					}
 					else
 					{
 						OOX::CPath defdir	= pFile->DefaultDirectory();
 						OOX::CPath name		= file->GetWrittenFileName();

-						rels.registration(pPair->m_key, pFile->type(), defdir / name);
+						rels.registration(pPair->first, pFile->type(), defdir / name);
 					}
 				}
 				else
@@ -145,22 +142,21 @@

 					OOX::CSystemUtility::CreateDirectories(directory / defdir);
 					pFile->write(directory / defdir / name, directory, content);
-					rels.registration(pPair->m_key, pFile->type(), defdir / name);
+					rels.registration(pPair->first, pFile->type(), defdir / name);
 				}
 			}
 			else
 			{
-				rels.registration(pPair->m_key, pExt);
+				rels.registration(pPair->first, pExt);
 			}
 		}
 	}

 	void FileContainer::WrittenSetFalse()
 	{
-		POSITION pos = m_container.GetStartPosition();
-		while (NULL != pos)
+		for (std::map<CString, smart_ptr<PPTX::File>>::const_iterator pPair = m_container.begin(); pPair != m_container.end(); ++pPair)
 		{
-			smart_ptr<PPTX::File> pFile = m_container.GetNextValue(pos);
+			smart_ptr<PPTX::File> pFile = pPair->second;

 			smart_ptr<PPTX::WrapperFile>	pWrapFile = pFile.smart_dynamic_cast<PPTX::WrapperFile>();
 			smart_ptr<PPTX::FileContainer>	pWrapCont = pFile.smart_dynamic_cast<PPTX::FileContainer>();
@@ -173,7 +169,7 @@
 				{
 					pWrapCont->WrittenSetFalse();
 				}
-			}
+			}
 		}
 	}


slight optimization

slight optimization

--- include/scopedperf.hh
+++ include/scopedperf.hh
@@ -179,7 +179,7 @@
 };

 template<class T, int Nbits>
-inline uint8_t
+inline uintptr_t
 log2r(T v)
 {
   if (Nbits == 8) {
@@ -194,7 +194,7 @@
 }

 template<class T>
-inline uint8_t
+uintptr_t
 log2(T v)
 {
   return log2r<T, sizeof(T)*8>(v);
@@ -337,10 +337,10 @@
   enum { maxcpu = 256 };

   template<class Stats, class T>
-  static uint64_t addcpus(const Stats &s, T f) {
+  static uint64_t addcpus(const Stats stat[], T f) {
     uint64_t tot = 0;
     for (uint i = 0; i < maxcpu; i++)
-      tot += f(&s[i]);
+      tot += f(&stat[i]);
     return tot;
   }
 };


Silent mode

Silent mode

--- src/k81x-fkeys.cpp
+++ src/k81x-fkeys.cpp
@@ -25,12 +25,13 @@
 }

 int main(int argc, char **argv) {
-  bool verbose = false, switch_on;
+  bool verbose = false, switch_on, silent = false;
+  int error_return = 1;
   const char *device_path = NULL;

   // Fetch the command line arguments.
   int opt;
-  while ((opt = getopt(argc, argv, "d:v")) != -1) {
+  while ((opt = getopt(argc, argv, "d:vs")) != -1) {
     switch (opt) {
       case 'd':
         device_path = optarg;
@@ -38,12 +39,16 @@
       case 'v':
         verbose = true;
         break;
-    }
+      case 's':
+        silent = true;
+        error_return = 0;
+        break;
+      }
   }
   if (optind >= argc) {
     // No on/off argument.
     usage();
-    return 1;
+    return error_return;
   }
   if (!strcmp("on", argv[optind])) {
     switch_on = true;
@@ -52,11 +57,11 @@
   } else {
     cerr << "Invalid switch value, should be either \"on\" or \"off\"." << endl;
     usage();
-    return 1;
+    return error_return;
   }

   // Check the privileges.
-  if (geteuid() != 0) {
+  if (geteuid() != 0 && !silent) {
     cerr << "Warning: Program not running as root. It will most likely fail."
          << endl;
   }
@@ -65,12 +70,12 @@
   K81x *k81x = NULL;
   if (device_path == NULL) {
     k81x = K81x::FromAutoFind(verbose);
-    if (NULL == k81x) {
+    if (NULL == k81x && !silent) {
       cerr << "Error while looking for a Logitech K810/K811 keyboard." << endl;
     }
   } else {
     k81x = K81x::FromDevicePath(device_path, verbose);
-    if (NULL == k81x) {
+    if (NULL == k81x && !silent) {
       cerr
           << "Device " << device_path
           << " cannot be recognized as a supported Logitech K810/K811 keyboard."
@@ -81,16 +86,16 @@
   int result = 0;
   if (k81x != NULL) {
     // Switch the Kn keys mode.
-    if (!k81x->SetFnKeysMode(switch_on)) {
+    if (!k81x->SetFnKeysMode(switch_on) && !silent) {
       cerr << "Error while setting the F-keys mode." << endl;
-      result = 1;
+      result = error_return;
     }

     delete k81x;
   } else {
-    result = 1;
+    result = error_return;
   }
-  if (result && !verbose) {
+  if (result && !verbose && !silent) {
     cerr << "Try running with -v parameter to get more details." << endl;
   }
   return result;


MB-10979: set sequence number properly for temporary initial item

When a temporary initial item is being added to the hash table,
the sequence number needs to be set to the max deleted sequence
number as opposed to being zero. There is a possibility that
a set from the client can access this temporary item before
the BG fetcher task can update the metadata with the correct
sequence number.

Change-Id: Iebf5dc70c2cc25ed4a4cf5f6540f1848772491cf
Reviewed-on: http://review.couchbase.org/37104
Reviewed-by: Chiyoung Seo <fcffc23db27b19ee4ebba46695ee6b50e09216a2@couchbase.com>
Tested-by: Chiyoung Seo <fcffc23db27b19ee4ebba46695ee6b50e09216a2@couchbase.com>

--- src/stored-value.cc
+++ src/stored-value.cc
@@ -547,6 +547,8 @@
             uint64_t seqno = 0;
             if (!v->isTempItem()) {
                 seqno = getMaxDeletedRevSeqno() + 1;
+            } else {
+                seqno = getMaxDeletedRevSeqno();
             }
             v->setRevSeqno(seqno);
             itm.setRevSeqno(seqno);


uspell now honors the size arguments

uspell now honors the size arguments

git-svn-id: 18bf4e4f0ca11a3471e5785d6da82074410339c6@20768 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6

--- src/uspell/uspell_provider.cpp
+++ src/uspell/uspell_provider.cpp
@@ -47,6 +47,7 @@
 #include <uspell/uspell.h>

 static const size_t MAXALTERNATIVE = 20; // we won't return more than this number of suggestions
+static const size_t MAXCHARS = 100; // maximum number of bytes of utf8 or chars of UCS4 in a word

 typedef struct {
 	char *personalName; // name of file containing personal dictionary
@@ -57,26 +58,28 @@
 uspell_dict_check (EnchantDict * me, const char *const word, size_t len)
 {
 	uSpell *manager;
-	wide_t *curBuf, *otherBuf, *tmpBuf;
+	wide_t buf1[MAXCHARS], buf2[MAXCHARS], *curBuf, *otherBuf, *tmpBuf;
+	utf8_t myWord[MAXCHARS];
 	int length;

+	if (len >= MAXCHARS)
+		return 1; // too long; can't be right
+	memcpy(reinterpret_cast<char *>(myWord), word, len);
+	myWord[len] = 0;
+	curBuf = buf1;
+	otherBuf = buf2;
 	manager = reinterpret_cast<uspellData *>(me->user_data)->manager;
-	curBuf = reinterpret_cast<wide_t *>(calloc(len+1, sizeof(wide_t)));
 #ifdef DEBUG
 	fprintf(stdout, "Checking [%s]\n", word);
 #endif
-	length = utf8_wide(curBuf, reinterpret_cast<const utf8_t *>(word), len+1);
+	length = utf8_wide(curBuf, myWord, MAXCHARS);
 	if (manager->isSpelledRight(curBuf, length)) {
-		free(curBuf);
 		return 0; // correct the first time
 	}
-	otherBuf = reinterpret_cast<wide_t *>(calloc(len+1, sizeof(wide_t)));
 	if (manager->theFlags & uSpell::upperLower) {
 		toUpper(otherBuf, curBuf, length);
 		if (manager->isSpelledRight(otherBuf, length)) {
-			manager->acceptWord(reinterpret_cast<const utf8_t *>(word));
-			free(curBuf);
-			free(otherBuf);
+			manager->acceptWord(myWord);
 			return 0; // correct if converted to all upper case
 		}
 		tmpBuf = curBuf;
@@ -86,9 +89,7 @@
 	if (manager->theFlags & uSpell::hasComposition) {
 		unPrecompose(otherBuf, &length, curBuf, length);
 		if (manager->isSpelledRight(otherBuf, length)) {
-			manager->acceptWord(reinterpret_cast<const utf8_t *>(word));
-			free(curBuf);
-			free(otherBuf);
+			manager->acceptWord(myWord);
 			return 0; // correct if precomposed characters expanded, all upper
 		}
 		tmpBuf = curBuf;
@@ -97,14 +98,10 @@
 	}
 	if (manager->theFlags & uSpell::hasCompounds) {
 		if (manager->isSpelledRightMultiple(curBuf, length)) {
-			manager->acceptWord(reinterpret_cast<const utf8_t *>(word));
-			free(curBuf);
-			free(otherBuf);
+			manager->acceptWord(myWord);
 			return 0; // correct as two words.  Not right for all languages.
 		}
 	}
-	free(curBuf);
-	free(otherBuf);
 	return 1;
 }

@@ -113,20 +110,24 @@
 		     size_t len, size_t * out_n_suggs)
 {
 	uSpell *manager;
+	utf8_t myWord[MAXCHARS];

 	char **sugg_arr = NULL;
 	const utf8_t *sugg;
-	wide_t *curBuf;
+	wide_t buf[MAXCHARS];
 	int length, i;
 	utf8_t **list;

+	if (len >= MAXCHARS) // no suggestions; the word is outlandish
+		return g_new0 (char *, 1);
+	memcpy(reinterpret_cast<char *>(myWord), word, len);
+	myWord[len] = 0;
 	manager = reinterpret_cast<uspellData *>(me->user_data)->manager;

 	list = reinterpret_cast<utf8_t **>(
 					   calloc(sizeof(char *), MAXALTERNATIVE));
-	curBuf = reinterpret_cast<wide_t *>(calloc(len+1, sizeof(wide_t)));
-	length = utf8_wide(curBuf, reinterpret_cast<const utf8_t *>(word), len+1);
-	*out_n_suggs = manager->showAlternatives(curBuf, length,
+	length = utf8_wide(buf, myWord, MAXCHARS);
+	*out_n_suggs = manager->showAlternatives(buf, length,
 						 list, MAXALTERNATIVE);

 	if (*out_n_suggs)
@@ -142,7 +143,6 @@
 				}
 		}
 	free(list);
-	free(curBuf);
 	return sugg_arr;
 }

@@ -152,9 +152,13 @@
 {
 	uSpell *manager;
 	FILE *personalFile;
-
+	utf8_t myWord[MAXCHARS];
+
+	if (len >= MAXCHARS) return; // too long; can't be right
+	memcpy(reinterpret_cast<char *>(myWord), word, len);
+	myWord[len] = 0;
 	manager = reinterpret_cast<uspellData *>(me->user_data)->manager;
-	manager->acceptWord(reinterpret_cast<const utf8_t *>(word));
+	manager->acceptWord(myWord);
 	if (!reinterpret_cast<uspellData *>(me->user_data)->personalName)
 			return; // no personal file
 	personalFile =
@@ -164,7 +168,7 @@
 		flock(fileno(personalFile), LOCK_EX);
 		fseek(personalFile, 0, SEEK_END);  // in case someone else intervened
 #endif
-		fprintf(personalFile, "%s\n", word);
+		fprintf(personalFile, "%s\n", myWord);
 		fclose(personalFile);
 	}
 }


saw at least one of these unused by eye, search for more

Change-Id: I0f863f2463c8ba1b387d5834c6ff42fb467ce796


Support disabling vsync on Vulkan, take 2 (#1925)

* Support disabling Vsync on Vulkan [couriersud]

* Add missing lines to fix compiling.

--- src/renderer_vk.cpp
+++ src/renderer_vk.cpp
@@ -2760,6 +2760,42 @@
 					VK_CHECK(vkDeviceWaitIdle(m_device) );
 					releaseSwapchainFramebuffer();
 					releaseSwapchain();
+
+					uint32_t numPresentModes(10);
+					VkPresentModeKHR presentModes[10];
+					vkGetPhysicalDeviceSurfacePresentModesKHR(m_physicalDevice, m_surface, &numPresentModes, presentModes);
+
+					uint32_t presentModeIdx = numPresentModes;
+					VkPresentModeKHR preferredPresentMode[] = {
+						VK_PRESENT_MODE_FIFO_KHR,
+						VK_PRESENT_MODE_FIFO_RELAXED_KHR,
+						VK_PRESENT_MODE_MAILBOX_KHR,
+						VK_PRESENT_MODE_IMMEDIATE_KHR,
+					};
+					bool has_vsync[] = { true, true, true, false };
+					bool vsync = (flags & BGFX_RESET_VSYNC ? true : false);
+
+					for (uint32_t ii = 0; ii < BX_COUNTOF(preferredPresentMode); ++ii)
+					{
+						for (uint32_t jj = 0; jj < numPresentModes; ++jj)
+						{
+							if ((presentModes[jj] == preferredPresentMode[ii]) && (vsync == has_vsync[ii]))
+							{
+								presentModeIdx = jj;
+								BX_TRACE("present mode: %d", (int)preferredPresentMode[ii]);
+								break;
+							}
+						}
+						if (presentModeIdx < numPresentModes)
+						{
+							break;
+						}
+					}
+					if (presentModeIdx == numPresentModes)
+					{
+						presentModeIdx = 0;
+					}
+					m_sci.presentMode = presentModes[presentModeIdx];

 					VkSurfaceCapabilitiesKHR surfaceCapabilities;
 					VK_CHECK(vkGetPhysicalDeviceSurfaceCapabilitiesKHR(m_physicalDevice, m_surface, &surfaceCapabilities) );


no message

no message

--- include/transform.hpp
+++ include/transform.hpp
@@ -40,7 +40,12 @@
 		Matrix(std::initializer_list<V> values) {
 			data = GetPool<T>()->newElement(T(std::forward<std::initializer_list<V>>(values)));
 		}
-
+
+		Matrix(Matrix<T>& m) {
+			data = GetPool<T>()->newElement(T());
+			*this = m;
+		}
+
 		Matrix(Matrix<T>&& m) {
 			data = m.data;
 			m.data = nullptr;
@@ -97,8 +102,7 @@
 		}
 		//API
 		Matrix<T> clone() {
-			Matrix<T> result;
-			memcpy(result.data, data, row() * col() * sizeof(V));
+			Matrix<T> result = *this;
 			return result;
 		}


removed tuples and triple support from attributes

--- src/laszip_dll.cpp
+++ src/laszip_dll.cpp
@@ -42,7 +42,7 @@
 #define LASZIP_DYN_LINK
 #define LASZIP_SOURCE

-#include "laszip_api.h"
+#include <laszip/laszip_api.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>


Fix uninitialized Vulkan sampler hash.

Fix uninitialized Vulkan sampler hash.

--- src/renderer_vk.cpp
+++ src/renderer_vk.cpp
@@ -3275,6 +3275,7 @@
 		VkSampler getSampler(uint32_t _samplerFlags, uint32_t _mipLevels)
 		{
 			bx::HashMurmur2A hash;
+			hash.begin();
 			hash.add(_samplerFlags);
 			hash.add(_mipLevels);
 			uint32_t hashKey = hash.end();


Added documentation

Added documentation

--- include/util/task.hpp
+++ include/util/task.hpp
@@ -11,7 +11,7 @@
  		 * @param alive Shared status; false signals shutdown
  		 */
 		virtual void init(std::atomic_bool& alive) =0;
-		/** Polls for changes
+		/** Polls for changes since init or last poll
  		 * @param alive Shared status; false signals shutdown
  		 */
 		virtual void poll(std::atomic_bool &alive) =0;
@@ -23,10 +23,15 @@

 		/** Initializes any resources deferred from constructor
  		 * @param alive Shared status; false signals shutdown
- 		 * @param t The task to initialize */
+ 		 * @param t The task to initialize
+ 		 */
 		static void init(std::atomic_bool &alive, task *t) {
 			t -> init(alive);
 		}
+		/** Polls for changes since init or last poll
+ 		 * @param alive Shared status; false signals shutdown
+ 		 * @param t The task to poll
+ 		 */
 		static void poll(std::atomic_bool &alive, task *t) {
 			t -> poll(alive);
 		}


added new gap junction classes to build and run

git-svn-id: 602a26e73ae9f2a14e2bb95676f2e137fcc39919@3895 7c0444ca-5550-0410-9008-faecdbe78eb5

--- src/layers/LIF.cpp
+++ src/layers/LIF.cpp
@@ -75,6 +75,12 @@

 LIF::LIF(const char* name, HyPerCol * hc, PVLayerType type)
   : HyPerLayer(name, hc, MAX_CHANNELS)
+{
+   initialize(type, "LIF_update_state");
+}
+
+LIF::LIF(const char* name, HyPerCol * hc, PVLayerType type, int num_channels)
+  : HyPerLayer(name, hc, num_channels)
 {
    initialize(type, "LIF_update_state");
 }


set default value of wmaxflag to false

set default value of wmaxflag to false

git-svn-id: 602a26e73ae9f2a14e2bb95676f2e137fcc39919@3514 7c0444ca-5550-0410-9008-faecdbe78eb5

--- src/layers/LIF.cpp
+++ src/layers/LIF.cpp
@@ -367,6 +367,7 @@

    // set params for rate dependent Wmax
+   localWmaxFlag = false;
    localWmaxFlag = (bool) p->value(name, "localWmaxFlag", (float) localWmaxFlag);
    tauWmax     = p->value(name,"tauWmax",TAU_WMAX); // in ms
    alphaW     = p->value(name,"alphaW",0.01);


Resolve Use - Do parent search on Relative paths

--- src/resolve/use.cpp
+++ src/resolve/use.cpp
@@ -47,9 +47,8 @@
         BUG(span, "UFCS path class in use statement");
         ),
     (Relative,
-        return base_path + path;
-        ),
-    (Self,
+        // How can this happen?
+        DEBUG("Relative " << path);
         // EVIL HACK: If the current module is an anon module, refer to the parent
         if( base_path.nodes().size() > 0 && base_path.nodes().back().name()[0] == '#' ) {
             AST::Path   np("", {});
@@ -62,7 +61,22 @@
             return base_path + path;
         }
         ),
+    (Self,
+        DEBUG("Self " << path);
+        // EVIL HACK: If the current module is an anon module, refer to the parent
+        if( base_path.nodes().size() > 0 && base_path.nodes().back().name()[0] == '#' ) {
+            AST::Path   np("", {});
+            for( unsigned int i = 0; i < base_path.nodes().size() - 1; i ++ )
+                np.nodes().push_back( base_path.nodes()[i] );
+            np += path;
+            return np;
+        }
+        else {
+            return base_path + path;
+        }
+        ),
     (Super,
+        DEBUG("Super " << path);
         assert(e.count >= 1);
         AST::Path   np("", {});
         if( e.count > base_path.nodes().size() ) {
@@ -79,6 +93,7 @@
         return np;
         ),
     (Absolute,
+        DEBUG("Absolute " << path);
         // Leave as is
         return path;
         )


rgw: only require content-length to be set on non-acl puts

Signed-off-by: Greg Farnum <0bcb4295d38ee745130ea5f2bb88ef4eef474e61@dreamhost.com>

--- src/rgw/rgw_rest.cc
+++ src/rgw/rgw_rest.cc
@@ -721,7 +721,7 @@
   init_entities_from_header(s);
   switch (s->op) {
   case OP_PUT:
-    if (s->object) {
+    if (s->object && !s->object_str.find("?acl")) {
       if (!s->length)
         ret = -ERR_LENGTH_REQUIRED;
       else if (*s->length == '\0')


Use also MWAWInputStream::get in WNText...

--- src/lib/WNText.cxx
+++ src/lib/WNText.cxx
@@ -228,9 +228,10 @@
         break;
       }

-      static int const wh[4]= { libmwaw::TopBit, libmwaw::RightBit, libmwaw::BottomBit, libmwaw::LeftBit };
-      if (!border.isEmpty())
+      if (!border.isEmpty()) {
+        static int const wh[4]= { libmwaw::TopBit, libmwaw::RightBit, libmwaw::BottomBit, libmwaw::LeftBit };
         cell.setBorders(wh[i], border);
+      }
     }
   }
   //! operator<<
@@ -1846,8 +1847,9 @@
       ascFile.addNote(f.str().c_str());
       continue;
     }
-    WPXInputStream *dataStream = const_cast<WPXInputStream *>(data.getDataStream());
-    MWAWInputStream dataInput(dataStream, false);
+    MWAWInputStreamPtr dataInput;
+    if (data.size())
+      dataInput=MWAWInputStream::get(data, false);
     switch(zone.m_type) {
     case 0x9: { // only in v2
       extraDecal = zone.m_value;
@@ -1858,9 +1860,9 @@
       break;
     }
     case 0xa: {  // only in writenow 4.0 : related to a table ?
-      if (!dataStream) break;
+      if (!dataInput) break;
       WNTextInternal::TableData tableData;
-      if (readTable(dataInput, tableData)) {
+      if (readTable(*dataInput, tableData)) {
         f << tableData;

         bool needSendTable = false;
@@ -1918,9 +1920,9 @@
       break;
     }
     case 0xc: {
-      if (!dataStream) break;
+      if (!dataInput) break;
       WNTextInternal::Paragraph newParagraph;
-      if (readParagraph(dataInput, newParagraph)) {
+      if (readParagraph(*dataInput, newParagraph)) {
         ruler = newParagraph;
         numLineTabs = int(ruler.m_tabs->size());
         setProperty(ruler);
@@ -1931,16 +1933,16 @@
       break;
     }
     case 0xe: {
-      if (!dataStream) break;
+      if (!dataInput) break;
       WNTextInternal::Token token;
       if (vers >= 3) {
-        if (readToken(dataInput, token)) {
+        if (readToken(*dataInput, token)) {
           m_mainParser->sendGraphic(token.m_graphicZone, token.m_box);
           f << token;
         } else
           f << "#";
       } else {
-        if (readTokenV2(dataInput, token))
+        if (readTokenV2(*dataInput, token))
           f << token;
         else
           f << "#";
@@ -1948,9 +1950,9 @@
       break;
     }
     case 0xf: {
-      if (!dataStream) break;
+      if (!dataInput) break;
       WNTextInternal::Font font;
-      if (readFont(dataInput, false, font)) {
+      if (readFont(*dataInput, false, font)) {
         actFont=font.m_font;
         f << font.m_font.getDebugString(m_parserState->m_fontConverter) << font;
         if (extraDecal > 0) font.m_font.set(MWAWFont::Script::super100());


[R] fix EncodeChar

[R] fix EncodeChar

--- src/lightgbm_R.cpp
+++ src/lightgbm_R.cpp
@@ -33,7 +33,8 @@
 using namespace LightGBM;

 LGBM_SE EncodeChar(LGBM_SE dest, const char* src, LGBM_SE buf_len, LGBM_SE actual_len) {
-  size_t str_len = std::strlen(src);
+  // +1 for '\0'
+  size_t str_len = std::strlen(src) + 1;
   if (str_len > INT32_MAX) {
     Log::Fatal("Don't support large string in R-package.");
   }


include all trackers in magnet links

include all trackers in magnet links

git-svn-id: f73d3a8135a81ac54074f42e0d79c0ba7e35ca85@7701 a83610d8-ad2a-0410-a6ab-fc0612d85776

--- src/magnet_uri.cpp
+++ src/magnet_uri.cpp
@@ -55,20 +55,13 @@
 			num_chars += snprintf(ret + num_chars, sizeof(ret) - num_chars, "&dn=%s"
 				, escape_string(name.c_str(), name.length()).c_str());

-		std::string tracker;
-		torrent_status st = handle.status();
-		if (!st.current_tracker.empty())
-		{
-			tracker = st.current_tracker;
-		}
-		else
-		{
-			std::vector<announce_entry> const& tr = handle.trackers();
-			if (!tr.empty()) tracker = tr[0].url;
-		}
-		if (!tracker.empty())
+		std::vector<announce_entry> const& tr = handle.trackers();
+
+		for (std::vector<announce_entry>::const_iterator i = tr.begin(), end(tr.end()); i != end; ++i)
+		{
 			num_chars += snprintf(ret + num_chars, sizeof(ret) - num_chars, "&tr=%s"
-				, escape_string(tracker.c_str(), tracker.size()).c_str());
+				, escape_string(i->url.c_str(), i->url.length()).c_str());
+		}

 		return ret;
 	}
@@ -87,10 +80,10 @@
 				, escape_string(name.c_str(), name.length()).c_str());

 		std::vector<announce_entry> const& tr = info.trackers();
-		if (!tr.empty())
+		for (std::vector<announce_entry>::const_iterator i = tr.begin(), end(tr.end()); i != end; ++i)
 		{
 			num_chars += snprintf(ret + num_chars, sizeof(ret) - num_chars, "&tr=%s"
-				, escape_string(tr[0].url.c_str(), tr[0].url.length()).c_str());
+				, escape_string(i->url.c_str(), i->url.length()).c_str());
 		}

 		return ret;


Moved some logic inside callbacks as we have no fear of tailcalling.

Also improved some comments!

--- src/main/spine.cpp
+++ src/main/spine.cpp
@@ -9,6 +9,11 @@
 Spine::~Spine() {
 	int position = 0;
 	std::string closeMessage;
+	// Here the Spine sends a message out on it's publish socket
+	// Each message directs a 'close' message to a module registered
+	//  in the Spine as 'loaded'
+	// It then waits for the module to join. It relies on the module closing
+	//  cleanly else it will lock up waiting.
 	for (auto& modName : this->loadedModules) {
 		closeMessage = modName + " close";
 		this->sendMessage(SocketType::PUB, closeMessage);
@@ -16,6 +21,8 @@
 		delete this->threads[position];
 		position += 1;
 	}
+	// After all modules are closed we don't need our sockets
+	//  so we should close them before exit, to be nice
 	this->closeSockets();
 	std::cout << "[Spine] Closed" << std::endl;
 }
@@ -27,6 +34,8 @@
 std::vector<std::string> Spine::listModules(std::string directory) {
 	std::vector<std::string> moduleFiles;

+	// Here we list a directory and built a vector of files that match
+	//  our platform specific dynamic lib extension (e.g., .so)
 	try {
 		boost::filesystem::directory_iterator startd(directory), endd;
 		auto files = boost::make_iterator_range(startd, endd);
@@ -45,6 +54,7 @@
 }

 int Spine::openModuleFile(std::string moduleFile, SpineModule& spineModule) {
+	// Here we use dlopen to load the dynamic library (that is, a compiled module)
 	spineModule.module_so = dlopen(moduleFile.c_str(), RTLD_NOW | RTLD_GLOBAL);
 	if (!spineModule.module_so) {
 		std::cerr << dlerror() << std::endl;
@@ -99,13 +109,13 @@
 			std::string regMessage = "register " + moduleName;
 			spineModule.module->sendMessage(SocketType::MGM_OUT, regMessage);

-			std::string moduleLoaded = spineModule.module->recvMessage(SocketType::MGM_OUT, [&](const std::string& regReply) -> std::string {
+			std::string moduleRun = spineModule.module->recvMessage(SocketType::MGM_OUT, [&](const std::string& regReply) -> std::string {
+				if (regReply == "success") {
+					spineModule.module->run();
+				}
 				return regReply;
 			}, 3000);
-
-			if (moduleLoaded == "success") {
-				spineModule.module->run();
-			}
+
 			spineModule.unloadModule(spineModule.module);
 			if (dlclose(spineModule.module_so) != 0) {
 				exit(EXIT_FAILURE);
@@ -123,22 +133,22 @@
 }

 bool Spine::registerModule() {
-	std::string regMessage = this->recvMessage(SocketType::MGM_IN, [&](const std::string& regReply) -> std::string {
-		return regReply;
-	});
-	if (regMessage != "__NULL_RECV_FAILED__") {
-		std::vector<std::string> tokens;
-		boost::split(tokens, regMessage, boost::is_any_of(" "));
-		if (tokens.at(0) == "register") {
-			if (tokens.at(1) != "") {
-				this->loadedModules.push_back(tokens.at(1));
-				this->notify(SocketType::PUB, tokens.at(1));
-				this->sendMessage(SocketType::MGM_IN, "success");
-				return true;
+	std::string regReturn = this->recvMessage(SocketType::MGM_IN, [&](const std::string& regReply) -> std::string {
+		if (regReply != "__NULL_RECV_FAILED__") {
+			std::vector<std::string> tokens;
+			boost::split(tokens, regReply, boost::is_any_of(" "));
+			if (tokens.at(0) == "register") {
+				if (tokens.at(1) != "") {
+					this->loadedModules.push_back(tokens.at(1));
+					this->notify(SocketType::PUB, tokens.at(1));
+					this->sendMessage(SocketType::MGM_IN, "success");
+					return "true";
+				}
 			}
 		}
-	}
-	return false;
+		return "false";
+	});
+	return (regReturn == "true") ? true : false;
 }

 void Spine::run() {


fix tablename and set a completer mode

fix tablename and set a completer mode

--- src/mainwindow.cpp
+++ src/mainwindow.cpp
@@ -1,4 +1,4 @@
-/* -*- coding: utf-8 -*-
+/* -*- codingr utf-8 -*-
 *   Copyright (c) 2010, Tim Kleinschmit.  This file is
 *   licensed under the General Public License version 3 or later.
 *   See the COPYRIGHT file.
@@ -93,14 +93,16 @@
 #if ( QT_VERSION >= 0x040700 )
         qleSearch->setPlaceholderText( tr( "Search" ));
 #endif
+
     QSqlTableModel qstm;
-        qstm.setTable("lineEditComplete");
+        qstm.setTable("searchWords"); // table name
         qstm.removeColumn(0); // remove the id column
         qstm.removeColumn(2); // remove the numberofused column
         qstm.select();

+    QCompleter::CompletionMode mode = QCompleter::InlineCompletion; // a new completer mode
     QCompleter *qcSearchWordHelp = new QCompleter(&qstm);
-        qcSearchWordHelp->setCompletionMode(QCompleter::InlineCompletion); // set the mode
+	qcSearchWordHelp->setCompletionMode(mode); // set the mode
     qleSearch->setCompleter(qcSearchWordHelp);

     qtbMain = new QToolBar( "Toolbar" );


Bug fix for Debian #824154

Bug fix for Debian #824154

--- src/mainwindow.cpp
+++ src/mainwindow.cpp
@@ -1026,7 +1026,15 @@
     foreach (QString type, romCollection->getFileTypes(true)) filter += type + " ";
     filter += ");;" + tr("All Files") + " (*)";

-    openPath = QFileDialog::getOpenFileName(this, tr("Open ROM File"), romCollection->romPaths.at(0), filter);
+#if QT_VERSION >= 0x050000
+    QString searchPath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first();
+#else
+    QString searchPath = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
+#endif
+    if (romCollection->romPaths.count() > 0)
+        searchPath = romCollection->romPaths.at(0);
+
+    openPath = QFileDialog::getOpenFileName(this, tr("Open ROM File"), searchPath, filter);
     if (openPath != "") {
         if (QFileInfo(openPath).suffix() == "zip") {
             QStringList zippedFiles = getZippedFiles(openPath);


Added command to sidebar and message if nothing is found to be picked up

--- src/map_window.cpp
+++ src/map_window.cpp
@@ -105,8 +105,9 @@
                 }
             }
         }
-
-
+        if (!foundSomethingAlready) {
+            getEngine()->addMessage(INFO, "There's nothing here...");
+        }
     }
     if (key == 'E') {
         EquipmentWindow* l_win = new EquipmentWindow();
@@ -179,6 +180,9 @@
     }

     // Actions to take
+    drawString (getHeight()-8, m_sidebarXOffset+2, "pickup Items");
+    drawString (getHeight()-8, m_sidebarXOffset+2, "p", Color (GREEN));
+
     drawString (getHeight()-7, m_sidebarXOffset+2, "move (wasd)");
     drawString (getHeight()-7, m_sidebarXOffset+2, "m", Color (GREEN));
     if (m_action == 'm') drawString (getHeight()-7, m_sidebarXOffset+1, ">", Color (RED));


no message

no message

--- src/masternode.cpp
+++ src/masternode.cpp
@@ -243,7 +243,7 @@
 bool CMasternode::IsInputAssociatedWithPubkey()
 {
     CScript payee;
-    payee = GetScriptForDestination(CScriptID(pubKeyCollateralAddress));
+    payee = GetScriptForWitness(pubKeyCollateralAddress);

     CTransactionRef tx;
     uint256 hash;


mds: assert ref count is 0 on inode deletion

--- src/mds/MDCache.cc
+++ src/mds/MDCache.cc
@@ -208,6 +208,7 @@
   }

   // delete it
+  assert(o->get_num_ref() == 0);
   delete o;
 }


mds: make mds restart work

mds: make mds restart work

Root mds needs to load root inode, .ceph directories.

--- src/mds/MDCache.cc
+++ src/mds/MDCache.cc
@@ -311,6 +311,8 @@
   rootdir->mark_complete();
   rootdir->mark_dirty(rootdir->pre_dirty(), mds->mdlog->get_current_segment());
   rootdir->commit(0, gather->new_sub());
+
+  root->store(gather->new_sub());
 }

 struct C_MDC_CreateSystemFile : public Context {
@@ -405,50 +407,90 @@

 void MDCache::open_root()
 {
-  dout(10) << "open_root" << dendl;
-
-  if (!root) {
-    discover_base_ino(MDS_INO_ROOT, new C_MDS_RetryOpenRoot(this), mds->mdsmap->get_root());
-    return;
-  }
-
-  CDir *rootdir = root->get_dirfrag(frag_t());
-  if (!rootdir) {
-    discover_dir_frag(root, frag_t(), new C_MDS_RetryOpenRoot(this));
-    return;
-  }
-
-  nstring name(".ceph");
-  CDentry *cephdn = rootdir->lookup(name);
-  if (!cephdn) {
-    filepath fp;
-    fp.push_dentry(name);
-    discover_path(rootdir, CEPH_NOSNAP, fp, new C_MDS_RetryOpenRoot(this));
-    return;
-  }
-
-  CInode *ceph = cephdn->get_linkage()->get_inode();
-  CDir *cephdir = ceph->get_dirfrag(frag_t());
-  if (!cephdir) {
-    discover_dir_frag(ceph, frag_t(), new C_MDS_RetryOpenRoot(this));
-    return;
-  }
-
-  char n[10];
-  sprintf(n, "mds%d", mds->whoami);
-  CDentry *mydn = cephdir->lookup(n);
-  if (!mydn) {
-    filepath fp;
-    fp.push_dentry(n);
-    discover_path(cephdir, CEPH_NOSNAP, fp, new C_MDS_RetryOpenRoot(this));
-    return;
-  }
-
-  assert(myin);
-  CDir *mydir = myin->get_dirfrag(frag_t());
-  if (!mydir || !mydir->is_auth()) {
-    // wait for it to import
-    return;
+  dout(10) << "open_root root=" << root << dendl;
+
+  if (mds->whoami == mds->mdsmap->get_root()) {
+    if (!root) {
+      create_root_inode();  // initially inaccurate!
+      root->fetch(new C_MDS_RetryOpenRoot(this));
+      return;
+    }
+    assert(root->is_auth());
+
+    CDir *rootdir = root->get_or_open_dirfrag(this, frag_t());
+    assert(rootdir);
+    if (!rootdir->is_subtree_root())
+      adjust_subtree_auth(rootdir, mds->whoami);
+    if (!rootdir->is_complete()) {
+      rootdir->fetch(new C_MDS_RetryOpenRoot(this));
+      return;
+    }
+
+    nstring name(".ceph");
+    CDentry *cephdn = rootdir->lookup(name);
+    assert(cephdn);
+    CInode *ceph = cephdn->get_linkage()->get_inode();
+    CDir *cephdir = ceph->get_or_open_dirfrag(this, frag_t());
+    assert(cephdir);
+    if (!cephdir->is_complete()) {
+      cephdir->fetch(new C_MDS_RetryOpenRoot(this));
+      return;
+    }
+
+    char n[10];
+    sprintf(n, "mds%d", mds->whoami);
+    CDentry *mydn = cephdir->lookup(n);
+    assert(mydn);
+
+    assert(myin);
+    CDir *mydir = myin->get_or_open_dirfrag(this, frag_t());
+    assert(mydir);
+
+  } else {
+    if (!root) {
+      discover_base_ino(MDS_INO_ROOT, new C_MDS_RetryOpenRoot(this), mds->mdsmap->get_root());
+      return;
+    }
+    assert(!root->is_auth());
+
+    CDir *rootdir = root->get_dirfrag(frag_t());
+    if (!rootdir) {
+      discover_dir_frag(root, frag_t(), new C_MDS_RetryOpenRoot(this));
+      return;
+    }
+
+    nstring name(".ceph");
+    CDentry *cephdn = rootdir->lookup(name);
+    if (!cephdn) {
+      filepath fp;
+      fp.push_dentry(name);
+      discover_path(rootdir, CEPH_NOSNAP, fp, new C_MDS_RetryOpenRoot(this));
+      return;
+    }
+
+    CInode *ceph = cephdn->get_linkage()->get_inode();
+    CDir *cephdir = ceph->get_dirfrag(frag_t());
+    if (!cephdir) {
+      discover_dir_frag(ceph, frag_t(), new C_MDS_RetryOpenRoot(this));
+      return;
+    }
+
+    char n[10];
+    sprintf(n, "mds%d", mds->whoami);
+    CDentry *mydn = cephdir->lookup(n);
+    if (!mydn) {
+      filepath fp;
+      fp.push_dentry(n);
+      discover_path(cephdir, CEPH_NOSNAP, fp, new C_MDS_RetryOpenRoot(this));
+      return;
+    }
+
+    assert(myin);
+    CDir *mydir = myin->get_dirfrag(frag_t());
+    if (!mydir || !mydir->is_auth()) {
+      // wait for it to import
+      return;
+    }
   }

   populate_mydir();


Fixed a wrong addition of nodes to the local database

When they were added and removed in the same action packet

--- src/megaclient.cpp
+++ src/megaclient.cpp
@@ -2570,12 +2570,15 @@
             for (node_vector::iterator it = nodenotify.begin(); it != nodenotify.end(); it++)
             {
                 char base64[12];
-                if ((*it)->changed.removed && (*it)->dbid)
-                {
-                    LOG_verbose << "Removing node from database: " << (Base64::btoa((byte*)&((*it)->nodehandle),MegaClient::NODEHANDLE,base64) ? base64 : "");
-                    if (!(complete = sctable->del((*it)->dbid)))
-                    {
-                        break;
+                if ((*it)->changed.removed)
+                {
+                    if ((*it)->dbid)
+                    {
+                        LOG_verbose << "Removing node from database: " << (Base64::btoa((byte*)&((*it)->nodehandle),MegaClient::NODEHANDLE,base64) ? base64 : "");
+                        if (!(complete = sctable->del((*it)->dbid)))
+                        {
+                            break;
+                        }
                     }
                 }
                 else
@@ -2595,12 +2598,15 @@
             for (pcr_vector::iterator it = pcrnotify.begin(); it != pcrnotify.end(); it++)
             {
                 char base64[12];
-                if ((*it)->removed() && (*it)->dbid)
-                {
-                    LOG_verbose << "Removing pcr from database: " << (Base64::btoa((byte*)&((*it)->id),MegaClient::PCRHANDLE,base64) ? base64 : "");
-                    if (!(complete = sctable->del((*it)->dbid)))
-                    {
-                        break;
+                if ((*it)->removed())
+                {
+                    if ((*it)->dbid)
+                    {
+                        LOG_verbose << "Removing pcr from database: " << (Base64::btoa((byte*)&((*it)->id),MegaClient::PCRHANDLE,base64) ? base64 : "");
+                        if (!(complete = sctable->del((*it)->dbid)))
+                        {
+                            break;
+                        }
                     }
                 }
                 else if (!(*it)->removed())


Reserve less memory for key requests

Reserve less memory for key requests

--- src/megaclient.cpp
+++ src/megaclient.cpp
@@ -7874,7 +7874,10 @@
         ni = 0;
     }

-    crkeys.reserve(shares->size() * nodes->size() * (32 * 4 / 3 + 10));
+    // estimate required size for requested keys
+    // for each node: ",<index>,<index>,"<nodekey>
+    crkeys.reserve(nodes->size() * ((5 + 4 * 2) + (FILENODEKEYLENGTH * 4 / 3 + 4)) + 1);
+    // we reserve for indexes up to 4 digits per index

     for (;;)
     {
@@ -7937,7 +7940,7 @@
                 {
                     n->applykey();
                     if (sn->sharekey && n->nodekey.size() ==
-                            ((n->type == FILENODE) ? FILENODEKEYLENGTH : FOLDERNODEKEYLENGTH))
+                            (unsigned)((n->type == FILENODE) ? FILENODEKEYLENGTH : FOLDERNODEKEYLENGTH))
                     {
                         unsigned nsi, nni;


Send event when link is encrypted to password

--- src/megaclient.cpp
+++ src/megaclient.cpp
@@ -12471,6 +12471,8 @@
         encryptedLink->append(MegaClient::MEGAURL);
         encryptedLink->append("/#P!");
         encryptedLink->append(encLink);
+
+        sendevent(99458, "Public link encrypted to a password");
     }

     return e;


removed duplication in loop

removed duplication in loop

--- lge/2014/june/3/main.cpp
+++ lge/2014/june/3/main.cpp
@@ -122,26 +122,24 @@
     // for all cases
     int solution = 0x7FFFFFFF;
     int direct[4]; // left, right, top, bottom
-    for (int a = 1; a <= 8; a <<= 1) {
-        for (int b = 1; b <= 8; b <<= 1) {
-            for (int c = 1; c <= 8; c <<= 1) {
-                memset(direct, 0, sizeof(int) * 4);
-#ifdef WIN32
-                unsigned long res;
-                _BitScanForward(&res, a); direct[res]++;
-                _BitScanForward(&res, b); direct[res]++;
-                _BitScanForward(&res, c); direct[res]++;
-#else // __linux__
-                direct[__builtin_ctz(a)]++;
-                direct[__builtin_ctz(b)]++;
-                direct[__builtin_ctz(c)]++;
-#endif
-                //static int k = 1;
-                //trace("%d) %d %d %d %d (%d)\n", k++, direct[0], direct[1], direct[2], direct[3], direct[0] + direct[1] + direct[2] + direct[3]);
-                solution = min(solution, simulation(direct[0], direct[1], direct[2], direct[3]));
-            }
+    for (i = 0; i < 4; i++) {
+        memset(direct, 0, sizeof(int) * 4);
+        direct[i] = 3;
+        solution = min(solution, simulation(direct[0], direct[1], direct[2], direct[3]));
+        direct[0] = direct[1] = direct[2] = direct[3] = 1;
+        direct[i] = 0;
+        solution = min(solution, simulation(direct[0], direct[1], direct[2], direct[3]));
+    }
+    for (i = 0; i < 4; i++) {
+        memset(direct, 0, sizeof(int) * 4);
+        direct[i] = 2;
+        for (int j = 0; j < 3; j++) {
+            direct[(i+j+1)%4] = 1;
+            solution = min(solution, simulation(direct[0], direct[1], direct[2], direct[3]));
+            direct[(i+j+1)%4] = 0;
         }
     }
+
     trace("%d\n", solution);
 }


Avoid usage of hard-coded constant

Avoid usage of hard-coded constant

--- src/megaclient.cpp
+++ src/megaclient.cpp
@@ -1864,7 +1864,7 @@
                                 pendingcs = NULL;
                                 csretrying = false;

-                                reqs.servererror("-23", this);
+                                reqs.servererror(std::to_string(API_ESSL), this);
                                 break;
                             }
                         }


[Diag] Fix idiom in comment: "on the lam", not "on the lamb".

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

--- lib/Basic/Diagnostic.cpp
+++ lib/Basic/Diagnostic.cpp
@@ -1010,7 +1010,7 @@
 PartialDiagnostic::StorageAllocator::~StorageAllocator() {
   // Don't assert if we are in a CrashRecovery context, as this invariant may
   // be invalidated during a crash.
-  assert((NumFreeListEntries == NumCached ||
-          llvm::CrashRecoveryContext::isRecoveringFromCrash()) &&
-         "A partial is on the lamb");
-}
+  assert((NumFreeListEntries == NumCached ||
+          llvm::CrashRecoveryContext::isRecoveringFromCrash()) &&
+         "A partial is on the lam");
+}


Fix warning as error

Fix warning as error

--- src/megaclient.cpp
+++ src/megaclient.cpp
@@ -1398,7 +1398,7 @@

 void MegaClient::resetId(char *id, size_t length)
 {
-    for (int i = length; i--; )
+    for (size_t i = length; i--; )
     {
         id[i] = static_cast<char>('a' + rng.genuint32(26));
     }


We want to add all thunks, not just 'this' adjustment thunks.

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

--- lib/CodeGen/CGVtable.cpp
+++ lib/CodeGen/CGVtable.cpp
@@ -1423,12 +1423,35 @@
       // Add an adjustment for the deleting destructor as well.
       Thunks[VtableIndex + 1].This = ThisAdjustment;
     }
-
-    AddThunk(Overrider.Method, Thunks[VtableIndex]);
   }

   /// Clear the method info map.
   MethodInfoMap.clear();
+
+  if (isBuildingConstructorVtable()) {
+    // We don't need to store thunk information for construction vtables.
+    return;
+  }
+
+  for (ThunksInfoMapTy::const_iterator I = Thunks.begin(), E = Thunks.end();
+       I != E; ++I) {
+    const VtableComponent &Component = Components[I->first];
+    const ThunkInfo &Thunk = I->second;
+
+    switch (Component.getKind()) {
+    default:
+      llvm_unreachable("Unexpected vtable component kind!");
+    case VtableComponent::CK_FunctionPointer:
+      AddThunk(Component.getFunctionDecl(), Thunk);
+      break;
+    case VtableComponent::CK_CompleteDtorPointer:
+      AddThunk(Component.getDestructorDecl(), Thunk);
+      break;
+    case VtableComponent::CK_DeletingDtorPointer:
+      // We've already added the thunk when we saw the complete dtor pointer.
+      break;
+    }
+  }
 }

 VtableBuilder::ReturnAdjustment


Undo the volatile stuff which didn't help with Windows

--- groups/bal/balb/balb_assertiontrackersingleton.t.cpp
+++ groups/bal/balb/balb_assertiontrackersingleton.t.cpp
@@ -84,36 +84,6 @@
 // ----------------------------------------------------------------------------

 typedef balb::AssertionTrackerSingleton<balb::AssertionTracker> Obj;
-
-int id(int i)
-    // Return the specified 'i'.
-{
-    return i;
-}
-
-void trigger1()
-    // Invoke assertion type 1.
-{
-    BSLS_ASSERT_ASSERT(0 && "assert 1");
-}
-
-void trigger2()
-    // Invoke assertion type 2.
-{
-    BSLS_ASSERT_ASSERT(0 && "assert 2");
-}
-
-void trigger3()
-    // Report assertion type 3.
-{
-    Obj::failTracker("0 && \"assert 3\"", __FILE__, __LINE__);
-}
-
-// Try to scotch inlining and loop unrolling
-int  (*volatile id_p)(int)    = id;
-void (*volatile trigger1_p)() = trigger1;
-void (*volatile trigger2_p)() = trigger2;
-void (*volatile trigger3_p)() = trigger3;

 ///Usage
 ///-----
@@ -254,32 +224,20 @@
                                      bdlf::PlaceHolders::_3,
                                      bdlf::PlaceHolders::_4,
                                      bdlf::PlaceHolders::_5));
-            os << "\n";
-            volatile int i, j;
-            i = id_p(0);
-            do {
-                if (veryVeryVerbose) {
-                    P_(i) Q("assert 1")
+
+            for (int i = 0; i < 10; ++i) {
+                if (veryVeryVerbose) { P_(i) Q("assert 1") }
+                BSLS_ASSERT_ASSERT(0 && "assert 1");
+                for (int j = 0; j < 10; ++j) {
+                    if (veryVeryVerbose) { P_(i) P_(j) Q("assert 2") }
+                    BSLS_ASSERT_ASSERT(0 && "assert 2");
                 }
-                trigger1_p();
-                j = id_p(0);
-                do {
-                    if (veryVeryVerbose) {
-                        P_(i) P_(j) Q("assert 2")
-                    }
-                    trigger2_p();
-                    j = id_p(j) + id_p(1);
-                } while (id_p(j) < id_p(10));
-                i = id_p(i) + id_p(1);
-            } while (id_p(i) < id_p(10));
-            i = id_p(0);
-            do {
-                if (veryVeryVerbose) {
-                    P_(i) Q("assert 3")
-                }
-                trigger3_p();
-                i = id_p(i) + id_p(1);
-            } while (id_p(i) < id_p(2));
+            }
+
+            for (int i = 0; i < 2; ++i) {
+                if (veryVeryVerbose) { P_(i) Q("assert 3") }
+                Obj::failTracker("0 && \"assert 3\"", __FILE__, __LINE__);
+            }

             bsl::string s = os.str();


Removed some more.

Removed some more.

--- src/mineserver.cpp
+++ src/mineserver.cpp
@@ -225,9 +225,6 @@
       return EXIT_FAILURE;
     }
   }
-
-  // create home and copy files if necessary
-  //Mineserver::get()->configDirectoryPrepare(Mineserver::get()->config()->config_path);

   bool ret = Mineserver::get()->init();

@@ -274,53 +271,6 @@

 bool Mineserver::init()
 {
-  /* expand '~', '~user' in next vars
-  bool error = false;
-  const char* const vars[] =
-  {
-    "system.path.data",
-    "system.path.plugins",
-    "system.path.home",
-    "system.pid_file",
-  };
-  for (size_t i = 0; i < sizeof(vars) / sizeof(vars[0]); i++)
-  {
-    ConfigNode::Ptr node = config()->mData(vars[i]);
-    if (!node)
-    {
-      LOG2(ERROR, std::string("Variable is missing: ") + vars[i]);
-      error = true;
-      continue;
-    }
-    if (node->type() != CONFIG_NODE_STRING)
-    {
-      LOG2(ERROR, std::string("Variable is not string: ") + vars[i]);
-      error = true;
-      continue;
-    }
-
-    const std::string newvalue = relativeToAbsolute(node->sData());
-
-    node->setData(newvalue);
-    LOG2(INFO, std::string(vars[i]) + " = \"" + newvalue + "\"");
-  }
-
-  if (error)
-  {
-    return false;
-  }
-
-  const std::string str = config()->sData("system.path.home");
-#ifdef WIN32
-  if (_chdir(str.c_str()) != 0)
-#else
-  if (chdir(str.c_str()) != 0)
-#endif
-  {
-    LOG2(ERROR, "Failed to change working directory to: " + str);
-    return false;
-  }*/
-
   // Write PID to file
   std::ofstream pid_out((config()->sData("system.pid_file")).c_str());
   if (!pid_out.fail())


Get the ctor vtable address points directly from the VTT builder.

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

--- lib/CodeGen/CGVtable.cpp
+++ lib/CodeGen/CGVtable.cpp
@@ -1266,9 +1266,19 @@
                                  const CXXRecordDecl *VtableClass,
                                  const CXXRecordDecl *RD,
                                  uint64_t Offset) {
-    int64_t AddressPoint =
-      (*AddressPoints[VtableClass])[std::make_pair(RD, Offset)];
-
+    uint64_t AddressPoint;
+
+    if (VtableClass != Class) {
+      // We have a ctor vtable, look for the address point in the ctor vtable
+      // address points.
+      AddressPoint =
+        CtorVtableAddressPoints[std::make_pair(VtableClass,
+                                               BaseSubobject(RD, Offset))];
+    } else {
+      AddressPoint =
+        (*AddressPoints[VtableClass])[std::make_pair(RD, Offset)];
+    }
+
     // FIXME: We can never have 0 address point.  Do this for now so gepping
     // retains the same structure.  Later we'll just assert.
     if (AddressPoint == 0)


Added conditional guard 'if (CurLexer)' when using SetCommentRetentionState().
This is because the PTHLexer will not support this method. Performance testing
on preprocessing Cocoa.h shows that this results in a negligible performance
difference (less than 1%).

I tried making Lexer::SetCommentRetentionState() an out-of-line function (a
precursor to making it a virtual function in PreprocessorLexer) and noticed a 1%
decrease in speed (it is called in a hot part of the Preprocessor).

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

--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -150,7 +150,7 @@
     // directive mode.  Tell the lexer this so any newlines we see will be
     // converted into an EOM token (this terminates the macro).
     CurPPLexer->ParsingPreprocessorDirective = true;
-    CurLexer->SetCommentRetentionState(false);
+    if (CurLexer) CurLexer->SetCommentRetentionState(false);

     // Read the next token, the directive flavor.
@@ -161,7 +161,7 @@
     if (Tok.isNot(tok::identifier)) {
       CurPPLexer->ParsingPreprocessorDirective = false;
       // Restore comment saving mode.
-      CurLexer->SetCommentRetentionState(KeepComments);
+      if (CurLexer) CurLexer->SetCommentRetentionState(KeepComments);
       continue;
     }

@@ -176,7 +176,7 @@
         FirstChar != 'i' && FirstChar != 'e') {
       CurPPLexer->ParsingPreprocessorDirective = false;
       // Restore comment saving mode.
-      CurLexer->SetCommentRetentionState(KeepComments);
+      if (CurLexer) CurLexer->SetCommentRetentionState(KeepComments);
       continue;
     }

@@ -197,7 +197,7 @@
       if (IdLen >= 20) {
         CurPPLexer->ParsingPreprocessorDirective = false;
         // Restore comment saving mode.
-        CurLexer->SetCommentRetentionState(KeepComments);
+        if (CurLexer) CurLexer->SetCommentRetentionState(KeepComments);
         continue;
       }
       memcpy(Directive, &DirectiveStr[0], IdLen);
@@ -278,7 +278,7 @@

     CurPPLexer->ParsingPreprocessorDirective = false;
     // Restore comment saving mode.
-    CurLexer->SetCommentRetentionState(KeepComments);
+    if (CurLexer) CurLexer->SetCommentRetentionState(KeepComments);
   }

   // Finally, if we are out of the conditional (saw an #endif or ran off the end
@@ -828,7 +828,7 @@

   // If we are supposed to keep comments in #defines, reenable comment saving
   // mode.
-  CurLexer->SetCommentRetentionState(KeepMacroComments);
+  if (CurLexer) CurLexer->SetCommentRetentionState(KeepMacroComments);

   // Create the new macro.
   MacroInfo *MI = new MacroInfo(MacroNameTok.getLocation());


Add a fast path in the [auto_closure] removal transformation for the no-op case

Swift SVN r8164

--- lib/SIL/TypeLowering.cpp
+++ lib/SIL/TypeLowering.cpp
@@ -1101,6 +1101,10 @@
     if (auto *ft = type->getAs<FunctionType>()) {
       Type inputType = transformTypeForTypeLowering(context, ft->getInput());
       Type resultType = transformTypeForTypeLowering(context, ft->getResult());
+      if (inputType.getPointer() == ft->getInput().getPointer() &&
+          resultType.getPointer() == ft->getResult().getPointer() &&
+          ft->getExtInfo().isAutoClosure() == false)
+        return type;
       return FunctionType::get(inputType, resultType,
                                ft->getExtInfo()
                                  .withIsAutoClosure(false),
@@ -1110,6 +1114,10 @@
     if (auto *pft = type->getAs<PolymorphicFunctionType>()) {
       Type inputType = transformTypeForTypeLowering(context, pft->getInput());
       Type resultType = transformTypeForTypeLowering(context, pft->getResult());
+      if (inputType.getPointer() == pft->getInput().getPointer() &&
+          resultType.getPointer() == pft->getResult().getPointer() &&
+          pft->getExtInfo().isAutoClosure() == false)
+        return type;
       return PolymorphicFunctionType::get(inputType, resultType,
                                           &pft->getGenericParams(),
                                           pft->getExtInfo()