Fixed completely wrong drag-and-drop reordering code (drags and drops in the same ListBox), and fixed slightly wrong, related single-item drag-and-drop code. Changed multiple drag-and-drops to drop items all on the same row, in reverse order to increase consistency among drop-insert calls and to preserve order when dropping into an unsorted list.  Also removed superfluous GL scissor state maintenance.

--- src/GGListBox.cpp
+++ src/GGListBox.cpp
@@ -346,8 +346,7 @@

     BeveledRectangle(ul.x, ul.y, lr.x, lr.y, int_color_to_use, color_to_use, false, BORDER_THICK);

-    // clip rows to viewable area, and save old scissor state, if any
-    bool disable_scissor = !glIsEnabled(GL_SCISSOR_TEST);
+    // clip rows to viewable area, and save old scissor state
     glPushAttrib(GL_SCISSOR_BIT);
     glEnable(GL_SCISSOR_TEST);
     glScissor(ul.x + BORDER_THICK, App::GetApp()->AppHeight() - lr.y + 2 * BottomMargin() + BORDER_THICK,
@@ -361,25 +360,25 @@
     int prev_sel = -1;
     int top = cl_ul.y, bottom = 0;
     for (std::set<int>::iterator  it = m_selections.begin(); it != m_selections.end(); ++it) {
-	int curr_sel = *it;
-	if (curr_sel >= m_first_row_shown && curr_sel <= last_visible_row){
-	    // no need to look for the current selection's height, if we just found it on the last iteration
-	    top = (prev_sel == curr_sel - 1) ? bottom : 0;
-	    if (!top) {
-		for (int i = m_first_row_shown; i < curr_sel; ++i)
-		    top += m_rows[i]->Height();
-	    }
-	    bottom = top + m_rows[curr_sel]->Height();
-	    if (bottom > cl_lr.y)
-		bottom = cl_lr.y;
-	    FlatRectangle(cl_ul.x, cl_ul.y + top, cl_lr.x, cl_ul.y + bottom, hilite_color_to_use, CLR_ZERO, 0);
-	    prev_sel = curr_sel;
-	}
+	    int curr_sel = *it;
+        if (curr_sel >= m_first_row_shown && curr_sel <= last_visible_row) {
+            // no need to look for the current selection's height, if we just found it on the last iteration
+            top = (prev_sel == curr_sel - 1) ? bottom : 0;
+            if (!top) {
+                for (int i = m_first_row_shown; i < curr_sel; ++i)
+                    top += m_rows[i]->Height();
+            }
+            bottom = top + m_rows[curr_sel]->Height();
+            if (bottom > cl_lr.y)
+                bottom = cl_lr.y;
+            FlatRectangle(cl_ul.x, cl_ul.y + top, cl_lr.x, cl_ul.y + bottom, hilite_color_to_use, CLR_ZERO, 0);
+            prev_sel = curr_sel;
+        }
     }

     // draw caret
     if (m_caret >= m_first_row_shown && m_caret <= last_visible_row &&
-	(App::GetApp()->FocusWnd() == this || App::GetApp()->FocusWnd() == m_vscroll || App::GetApp()->FocusWnd() == m_hscroll)) {
+	    (App::GetApp()->FocusWnd() == this || App::GetApp()->FocusWnd() == m_vscroll || App::GetApp()->FocusWnd() == m_hscroll)) {
         int top = cl_ul.y;
         for (int i = m_first_row_shown; i < m_caret; ++i)
             top += m_rows[i]->Height();
@@ -399,8 +398,6 @@
     }

     // restore previous scissor-clipping state
-    if (disable_scissor)
-        glDisable(GL_SCISSOR_TEST);
     glPopAttrib();

     if (m_vscroll)
@@ -445,53 +442,53 @@
             // if no sorting is done on target listbox.
             int ins_row = drop_target_wnd->RowUnderPt(pt);
             if (m_selections.empty()) {
-		shared_ptr<Row> dragged_row = m_rows[m_old_sel_row];
-		bool delete_row = true;
+                shared_ptr<Row> dragged_row = m_rows[m_old_sel_row];
+                bool delete_row = true;
                 try {
-                    drop_target_wnd->Insert(m_rows[m_old_sel_row], ins_row, true);
+                    drop_target_wnd->Insert(dragged_row, ins_row, true);
                 } catch (const DontAcceptDropException& e) {
-                    AttachRowChildren(m_rows[m_old_sel_row].get());
-		    delete_row = false;
+                    AttachRowChildren(dragged_row.get());
+                    delete_row = false;
                 }
-		if (delete_row) {
-		    // application-space updates may have changed the position of our row, so be sure we still have the right one...
-		    if (dragged_row == m_rows[m_old_sel_row]) {
-			Delete(m_old_sel_row);
-		    } else { // ...or find it
-			for (unsigned int i = 0; i < m_rows.size(); ++i) {
-			    if (m_rows[i] == dragged_row) {
-				Delete(i);
-				break;
-			    }
-			}
-		    }
-		}
+                if (delete_row) {
+                    // application-space updates may have changed the position of our row, so be sure we still have the right one...
+                    if (dragged_row == m_rows[m_old_sel_row]) {
+                        Delete(m_old_sel_row);
+                    } else { // ...or find it
+                        for (unsigned int i = 0; i < m_rows.size(); ++i) {
+                            if (m_rows[i] == dragged_row) {
+                                Delete(i);
+                                break;
+                            }
+                        }
+                    }
+                }
             } else {
                 set<int> sels = m_selections;
-		map<int, shared_ptr<Row> > dragged_rows;
+                map<int, shared_ptr<Row> > dragged_rows;
                 for (set<int>::iterator it = m_selections.begin(); it != m_selections.end(); ++it) {
-		    dragged_rows[*it] = m_rows[*it];
-		}
-		for (std::map<int, shared_ptr<Row> >::iterator it = dragged_rows.begin(); it != dragged_rows.end(); ++it) {
+                    dragged_rows[*it] = m_rows[*it];
+                }
+                for (std::map<int, shared_ptr<Row> >::reverse_iterator it = dragged_rows.rbegin(); it != dragged_rows.rend(); ++it) {
                     try {
-                        drop_target_wnd->Insert(it->second, ins_row++, true);
+                        drop_target_wnd->Insert(it->second, ins_row, true);
                     } catch (const DontAcceptDropException& e) {
                         AttachRowChildren(it->second.get());
                         sels.erase(it->first);
                     }
                 }
                 for (set<int>::reverse_iterator it = sels.rbegin(); it != sels.rend(); ++it) {
-		    // application-space updates may have changed the position of our row, so be sure we still have the right one...
-		    if (*it < static_cast<int>(m_rows.size()) && dragged_rows[*it] == m_rows[*it]) {
-			Delete(*it);
-		    } else { // ...or find it
-			for (unsigned int i = 0; i < m_rows.size(); ++i) {
-			    if (m_rows[i] == dragged_rows[*it]) {
-				Delete(i);
-				break;
-			    }
-			}
-		    }
+                    // application-space updates may have changed the position of our row, so be sure we still have the right one...
+                    if (*it < static_cast<int>(m_rows.size()) && dragged_rows[*it] == m_rows[*it]) {
+                        Delete(*it);
+                    } else { // ...or find it
+                        for (unsigned int i = 0; i < m_rows.size(); ++i) {
+                            if (m_rows[i] == dragged_rows[*it]) {
+                                Delete(i);
+                                break;
+                            }
+                        }
+                    }
                 }
             }
             if (m_caret > static_cast<int>(m_rows.size()) - 1)
@@ -513,11 +510,30 @@
                     ClickAtRow(sel_row, keys);
                 m_lclick_row = sel_row;
             } else if (m_row_drag_offset != Pt(-1, -1) && (m_style & LB_DRAGDROP) && (m_style & LB_NOSORT) &&
-                       (m_selections.empty() || (m_style & LB_SINGLESEL))) {
-                // allow arbitrary rearrangement of unsorted lists that have dragging and dropping enabled (NOSEL and SINGLESEL only)
+                       m_selections.size() <= 1) {
+                // allow arbitrary rearrangement of NOSORT lists that have dragging and dropping enabled (NOSEL and SINGLESEL only)
                 int old_sel_row = m_old_sel_row;
-                Insert(m_rows[old_sel_row], sel_row, true);
-                Delete(old_sel_row + (sel_row <= old_sel_row ? 1 : 0));
+                shared_ptr<Row> dragged_row = m_rows[old_sel_row];
+                bool delete_row = true;
+                try {
+                    Insert(dragged_row, sel_row, true);
+                } catch (const DontAcceptDropException& e) {
+                    AttachRowChildren(dragged_row.get());
+                    delete_row = false;
+                }
+                if (delete_row) {
+                    // application-space updates may have changed the position of our row, so be sure we have the right one
+                    // note that this assumes any application-space changes preserve the order of the old row and its dropped position
+                    int ct = 0;
+                    for (unsigned int i = 0; i < m_rows.size(); ++i) {
+                        if (m_rows[i] == dragged_row) {
+                            if (old_sel_row < sel_row || ++ct == 2) {
+                                Delete(i);
+                                break;
+                            }
+                        }
+                    }
+                }
             }
         }
     }
@@ -530,6 +546,8 @@
     int row = RowUnderPt(pt);
     if (!Disabled() && row >= 0 && row == m_lclick_row && InClient(pt)) {
         m_double_clicked_sig(row, m_rows[row].get());
+        m_old_sel_row = -1;
+        m_row_drag_offset = Pt(-1, -1);
     } else {
         LClick(pt, keys);
     }
@@ -681,16 +699,16 @@
             }
         }

-	DetachRowChildren(m_rows[idx].get());
-	m_rows.erase(m_rows.begin() + idx);
-
-	if (idx <= m_caret) // move caret up, if needed
-	    --m_caret;
-
-	AdjustScrolls();
-
-	if (!m_suppress_delete_signal)
-	    m_deleted_sig(idx);
+	    DetachRowChildren(m_rows[idx].get());
+	    m_rows.erase(m_rows.begin() + idx);
+
+	    if (idx <= m_caret) // move caret up, if needed
+	        --m_caret;
+
+	    AdjustScrolls();
+
+	    if (!m_suppress_delete_signal)
+	        m_deleted_sig(idx);
     }
 }

@@ -1038,14 +1056,15 @@
     AdjustScrolls();

     if (dropped) {
-	// ensure that no one has a problem with this drop in user space (if so, they should throw)
+        // ensure that no one has a problem with this drop in user space (if so, they should throw)
         try {
             m_dropped_sig(retval, row.get());
         } catch (const DontAcceptDropException& e) {
-	    // if there is a problem, silently undo the drop
+            // if there is a problem, silently undo the drop
             m_suppress_delete_signal = true;
-	    Delete(retval);
+            Delete(retval);
             m_suppress_delete_signal = false;
+            AdjustScrolls();
             throw; // re-throw so that LButtonUp() of the source ListBox can react as well
         }
     } else {
@@ -1319,8 +1338,6 @@

 void ListBox::AttachRowChildren(Row* row)
 {
-    // attach controls in row to the list box, but hide them; we want to control how they're rendered,
-    // but want them to be fully interactive, just as they would be any where else
     for (unsigned int i = 0; i < row->size(); ++i) {
         AttachChild((*row)[i]);
     }


Traverse Expr ExternArguments in IRVisitor

--- src/IRVisitor.cpp
+++ src/IRVisitor.cpp
@@ -124,6 +124,17 @@
 void IRVisitor::visit(const Call *op) {
     for (size_t i = 0; i < op->args.size(); i++) {
         op->args[i].accept(this);
+    }
+
+    // Consider extern call args
+    Function f = op->func;
+    if (op->call_type == Call::Halide && f.has_extern_definition()) {
+        for (size_t i = 0; i < f.extern_arguments().size(); i++) {
+            ExternFuncArgument arg = f.extern_arguments()[i];
+            if (arg.is_expr()) {
+                arg.expr.accept(this);
+            }
+        }
     }
 }


move flanking sequence of deletion right, moving deletion left

Handles case where a deletion could be aligned left without introducing
read or sequence mismatch, but is not a homopolymer or repeat.

--- src/LeftAlign.cpp
+++ src/LeftAlign.cpp
@@ -112,6 +112,16 @@
                    && indel.sequence == alignment.QueryBases.substr(indel.readPosition - 1, indel.length)
                    && (id == indels.begin() || indel.position >= previous->position + previous->length)) {
                 DEBUG("indel " << indel << " shifting " << 1 << "bp left" << endl);
+                indel.position -= 1;
+                indel.readPosition -= 1;
+            }
+        }
+        // deletions with exchangeable flanking sequence
+        if (!indel.insertion) {
+            while (indel.position > 0
+                   && indel.sequence.at(indel.sequence.size() - 1) == referenceSequence.at(indel.position - 1)
+                   && (id == indels.begin() || indel.position >= previous->position + previous->length)) {
+                indel.sequence = indel.sequence.at(indel.sequence.size() - 1) + indel.sequence.substr(0, indel.sequence.size() - 1);
                 indel.position -= 1;
                 indel.readPosition -= 1;
             }


Patch from Jim Pattee for batch files, recognizing more variablesand allowing a list of known external commands.

--- src/LexOthers.cxx
+++ src/LexOthers.cxx
@@ -41,7 +41,7 @@

 // Tests for BATCH Separators
 static bool IsBSeparator(char ch) {
-	return (ch == ':') || (ch == '\\') || (ch == '.') || (ch == ';') ||
+	return (ch == '\\') || (ch == '.') || (ch == ';') ||
 		(ch == '\"') || (ch == '\'') || (ch == '/') || (ch == ')');
 }

@@ -50,7 +50,7 @@
     unsigned int lengthLine,
     unsigned int startLine,
     unsigned int endPos,
-    WordList &keywords,
+    WordList *keywordlists[],
     Accessor &styler) {

 	unsigned int offset = 0;	// Line Buffer Offset
@@ -59,7 +59,9 @@
 	char wordBuffer[81];		// Word Buffer - large to catch long paths
 	unsigned int wbl;		// Word Buffer Length
 	unsigned int wbo;		// Word Buffer Offset - also Special Keyword Buffer Length
-	bool forFound = false;		// No Local Variable without FOR statement
+	WordList &keywords = *keywordlists[0];      // Internal Commands
+	WordList &keywords2 = *keywordlists[1];     // External Commands (optional)
+
 	// CHOICE, ECHO, GOTO, PROMPT and SET have Default Text that may contain Regular Keywords
 	//   Toggling Regular Keyword Checking off improves readability
 	// Other Regular Keywords and External Commands / Programs might also benefit from toggling
@@ -174,7 +176,13 @@
 				// Reset Offset to re-process remainder of word
 				offset -= (wbl - 1);
 				// Colorize External Command / Program
-				styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND);
+				if (!keywords2) {
+					styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND);
+				} else if (keywords2.InList(wordBuffer)) {
+					styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND);
+				} else {
+					styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT);
+				}
 				// Reset External Command / Program Location
 				cmdLoc = offset;
 			} else {
@@ -186,10 +194,6 @@
 		// Check for Regular Keyword in list
 		} else if ((keywords.InList(wordBuffer)) &&
 			(continueProcessing)) {
-			// Local Variables do not exist if no FOR statement
-			if (CompareCaseInsensitive(wordBuffer, "for") == 0) {
-				forFound = true;
-			}
 			// ECHO, GOTO, PROMPT and SET require no further Regular Keyword Checking
 			if ((CompareCaseInsensitive(wordBuffer, "echo") == 0) ||
 				(CompareCaseInsensitive(wordBuffer, "goto") == 0) ||
@@ -261,8 +265,8 @@
 					styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_WORD);
 					// Reset Offset to re-process remainder of word
 					offset -= (wbl - wbo);
-			}
-		}
+				}
+			}
 			// Check for External Command / Program or Default Text
 			if (!sKeywordFound) {
 				wbo = 0;
@@ -306,8 +310,14 @@
 							}
 						}
 					}
-					// Colorize External command / program
-					styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND);
+					// Colorize External Command / Program
+					if (!keywords2) {
+						styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND);
+					} else if (keywords2.InList(wordBuffer)) {
+						styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND);
+					} else {
+						styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT);
+					}
 					// No need to Reset Offset
 				// Check for Default Text
 				} else {
@@ -354,13 +364,13 @@
 				// Check for External Command / Program
 				if (cmdLoc == offset - wbl) {
 					cmdLoc = offset - (wbl - wbo);
-			}
+				}
 				// Colorize Environment Variable
 				styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_IDENTIFIER);
 				// Reset Offset to re-process remainder of word
 				offset -= (wbl - wbo);
 			// Check for Local Variable (%%a)
-			} else if ((forFound) &&
+			} else if (
 				(wordBuffer[1] == '%') &&
 				(wordBuffer[2] != '%') &&
 				(!IsBOperator(wordBuffer[2])) &&
@@ -447,7 +457,6 @@
     Accessor &styler) {

 	char lineBuffer[1024];
-	WordList &keywords = *keywordlists[0];

 	styler.StartAt(startPos);
 	styler.StartSegment(startPos);
@@ -458,14 +467,14 @@
 		if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
 			// End of line (or of line buffer) met, colourise it
 			lineBuffer[linePos] = '\0';
-			ColouriseBatchLine(lineBuffer, linePos, startLine, i, keywords, styler);
+			ColouriseBatchLine(lineBuffer, linePos, startLine, i, keywordlists, styler);
 			linePos = 0;
 			startLine = i + 1;
 		}
 	}
 	if (linePos > 0) {	// Last line does not have ending characters
 		ColouriseBatchLine(lineBuffer, linePos, startLine, startPos + length - 1,
-		                   keywords, styler);
+		                   keywordlists, styler);
 	}
 }

@@ -871,7 +880,7 @@
 		// CTags: \t<message>
 		// Lua 5 traceback: \t<filename>:<line>:<message>
 		bool initialTab = (lineBuffer[0] == '\t');
-		enum { stInitial,
+		enum { stInitial,
 			stGccStart, stGccDigit, stGcc,
 			stMsStart, stMsDigit, stMsBracket, stMsVc, stMsDigitComma, stMsDotNet,
 			stCtagsStart, stCtagsStartString, stCtagsStringDollar, stCtags,
@@ -933,8 +942,8 @@
 					for (j = i + numstep; j < lengthLine && isalpha(lineBuffer[j]) && chPos < sizeof(word) - 1; j++)
 						word[chPos++] = lineBuffer[j];
 					word[chPos] = 0;
-					if (!CompareCaseInsensitive(word, "error") || !CompareCaseInsensitive(word, "warning") ||
-						!CompareCaseInsensitive(word, "fatal") || !CompareCaseInsensitive(word, "catastrophic") ||
+					if (!CompareCaseInsensitive(word, "error") || !CompareCaseInsensitive(word, "warning") ||
+						!CompareCaseInsensitive(word, "fatal") || !CompareCaseInsensitive(word, "catastrophic") ||
 						!CompareCaseInsensitive(word, "note") || !CompareCaseInsensitive(word, "remark")) {
 						state = stMsVc;
 					} else
@@ -1103,7 +1112,8 @@
 }

 static const char * const batchWordListDesc[] = {
-	"Keywords",
+	"Internal Commands",
+	"External Commands",
 	0
 };


points-to: fix different types in points-to of vararg

vararg param merges all the va arguments into one node,
which leads to mixture of types in the points-to set

Signed-off-by: Marek Chalupa <a05df156a69ad59faa9af9b666ef78009594c145@gmail.com>

--- src/llvm/PointsTo.cpp
+++ src/llvm/PointsTo.cpp
@@ -411,7 +411,17 @@
             continue;
         }

-        const Function *func = cast<Function>(ptr.obj->node->getValue());
+        const Function *func = dyn_cast<Function>(ptr.obj->node->getValue());
+        // since we have vararg node, it is possible that the calledFuncNode will point
+        // to different types, like function, alloca and whatever
+        // (for exapmle the code: callva(1, func, a, "str") - this will
+        // merge few different types of pointers into one node.
+        // XXX maybe we could filter it in loadinst - like to consider only the variables
+        // with the right type (llvmp is typed, so we know that the different types
+        // are the analysis result, not wrong code)
+        if (!func)
+            continue;
+
         // skip undefined functions
         if (func->size() == 0)
             continue;


F17 linker symbol visibility correction

F17 linker symbol visibility correction

--- src/lsm_datatypes.cpp
+++ src/lsm_datatypes.cpp
@@ -24,16 +24,18 @@
 #include <stdio.h>

 #include "lsm_datatypes.hpp"
+
+#include <libstoragemgmt/libstoragemgmt_accessgroups.h>
 #include <libstoragemgmt/libstoragemgmt_common.h>
+#include <libstoragemgmt/libstoragemgmt_error.h>
+#include <libstoragemgmt/libstoragemgmt_fs.h>
+#include <libstoragemgmt/libstoragemgmt_initiators.h>
+#include <libstoragemgmt/libstoragemgmt_plug_interface.h>
+#include <libstoragemgmt/libstoragemgmt_pool.h>
+#include <libstoragemgmt/libstoragemgmt_snapshot.h>
+#include <libstoragemgmt/libstoragemgmt_systems.h>
+#include <libstoragemgmt/libstoragemgmt_types.h>
 #include <libstoragemgmt/libstoragemgmt_volumes.h>
-#include <libstoragemgmt/libstoragemgmt_pool.h>
-#include <libstoragemgmt/libstoragemgmt_initiators.h>
-#include <libstoragemgmt/libstoragemgmt_types.h>
-#include <libstoragemgmt/libstoragemgmt_plug_interface.h>
-#include <libstoragemgmt/libstoragemgmt_error.h>
-#include <libstoragemgmt/libstoragemgmt_systems.h>
-#include <libstoragemgmt/libstoragemgmt_accessgroups.h>
-#include <libstoragemgmt/libstoragemgmt_snapshot.h>

 #include <string.h>
 #include <stdlib.h>


Init the registers

Init the registers

--- src/ltac/Compiler.cpp
+++ src/ltac/Compiler.cpp
@@ -83,6 +83,22 @@
     }
 }

+namespace {
+
+struct StatementCompiler : public boost::static_visitor<> {
+    //The registers
+    as::Registers<ltac::Register> registers;
+    as::Registers<ltac::FloatRegister> float_registers;
+
+    StatementCompiler(std::vector<ltac::Register> registers, std::vector<ltac::FloatRegister> float_registers) :
+            registers(registers, std::make_shared<Variable>("__fake_int__", newSimpleType(BaseType::INT), Position(PositionType::TEMPORARY))),
+            float_registers(float_registers, std::make_shared<Variable>("__fake_float__", newSimpleType(BaseType::FLOAT), Position(PositionType::TEMPORARY))){
+        //Nothing else to init
+   }
+};
+
+} //end of anonymous namespace
+
 void ltac::Compiler::compile(std::shared_ptr<mtac::BasicBlock> block, std::shared_ptr<ltac::Function> target_function){
     //Handle parameters

@@ -90,14 +106,12 @@
     if(block_usage.find(block) != block_usage.end()){
         target_function->add(block->label);
     }
+
+    //TODO Fill the registers
+    StatementCompiler compiler({}, {});

     //statements

     //end basic block
 }

-struct StatementCompiler : public boost::static_visitor<> {
-    //The registers
-    as::Registers<ltac::Register> registers;
-    as::Registers<ltac::FloatRegister> float_registers;
-};


In CLRLifoSemaphore, start the underlying semaphore with 0 for the initial signal count (#22632)

- Port of a fix from https://github.com/dotnet/corert/pull/6955
- The underlying semaphore is only used to wake up waiters, initially there are no waiters and the signal count should be zero. This was already the case on Windows, this fixes the Unix side. The actual initial signal count is tracked in the upper layer counts.
- The initial signal count passed in is zero anyway in the places where it's used, so it makes no difference for now, just some cleanup

--- src/vm/synch.cpp
+++ src/vm/synch.cpp
@@ -589,7 +589,7 @@
     _ASSERTE(m_handle == nullptr);

 #ifdef FEATURE_PAL
-    HANDLE h = UnsafeCreateSemaphore(nullptr, initialSignalCount, maximumSignalCount, nullptr);
+    HANDLE h = UnsafeCreateSemaphore(nullptr, 0, maximumSignalCount, nullptr);
 #else // !FEATURE_PAL
     HANDLE h = CreateIoCompletionPort(INVALID_HANDLE_VALUE, nullptr, 0, maximumSignalCount);
 #endif // FEATURE_PAL


修正一个错误：去掉多余的大括号。

修正一个错误：去掉多余的大括号。

--- src/vm/vmlua.cpp
+++ src/vm/vmlua.cpp
@@ -215,7 +215,7 @@
 	return std::make_tuple (true, string("OK"));
 }

-}
+
 int64_t CVmlua::run(uint64_t maxstep,CVmRunEvn *pVmScriptRun) {
 	 long long step = 0;
 	 unsigned short count = 0;


Add failing test case

Add failing test case

--- test/test_query.cpp
+++ test/test_query.cpp
@@ -10895,6 +10895,51 @@
 }

+TEST_TYPES(Query_CaseInsensitiveNullable, std::true_type, std::false_type)
+{
+    Table table;
+    bool nullable = true;
+    constexpr bool with_index = TEST_TYPE::value;
+    size_t col_ndx = table.add_column(type_String, "id", nullable);
+    if (with_index) {
+        table.add_search_index(col_ndx);
+    }
+
+    table.add_empty_row(6);
+    table.set_string(col_ndx, 0, "test");
+    table.set_string(col_ndx, 1, "words");
+    table.set_null(col_ndx, 2);
+    table.set_null(col_ndx, 3);
+    table.set_string(col_ndx, 4, "");
+    table.set_string(col_ndx, 5, "");
+
+    bool case_sensitive = true;
+    StringData null_string;
+    Query q = table.where().equal(col_ndx, null_string, case_sensitive);
+    CHECK_EQUAL(q.count(), 2);
+    TableView tv = q.find_all();
+    CHECK_EQUAL(tv.size(), 2);
+    CHECK_EQUAL(tv[0].get_index(), 2);
+    CHECK_EQUAL(tv[1].get_index(), 3);
+    Query q2 = table.where().contains(col_ndx, null_string, case_sensitive);
+    CHECK_EQUAL(q2.count(), 6);
+    tv = q2.find_all();
+    CHECK_EQUAL(tv.size(), 6);
+
+    case_sensitive = false;
+    q = table.where().equal(col_ndx, null_string, case_sensitive);
+    CHECK_EQUAL(q.count(), 2);
+    tv = q.find_all();
+    CHECK_EQUAL(tv.size(), 2);
+    CHECK_EQUAL(tv[0].get_index(), 2);
+    CHECK_EQUAL(tv[1].get_index(), 3);
+    q2 = table.where().contains(col_ndx, null_string, case_sensitive);
+    CHECK_EQUAL(q2.count(), 6);
+    tv = q2.find_all();
+    CHECK_EQUAL(tv.size(), 6);
+}
+
+
 TEST_TYPES(Query_Rover, std::true_type, std::false_type)
 {
     constexpr bool nullable = TEST_TYPE::value;


faster unit test

faster unit test

--- test/test_stoch.cpp
+++ test/test_stoch.cpp
@@ -49,7 +49,7 @@
                         const auto g_thres = epsilon2<scalar_t>();

                         // optimize
-                        const auto params = stoch_params_t(epochs, epoch_size, epsilon1<scalar_t>());
+                        const auto params = stoch_params_t(epochs, epoch_size, epsilon2<scalar_t>());
                         const auto state = optimizer->minimize(params, function, x0);

                         const auto x = state.x;


add special meaning to parameter -d when less than 1

--- test/test_suite.hpp
+++ test/test_suite.hpp
@@ -40,6 +40,9 @@
     bool mst = found("mst", t);
     bool unite = !found("++", t);
     Graph G(n), G_shuffled(n);
+
+    // use d in [0,1] to mean density (since connected graphs have d > 1 anyway)
+    if(unite && d <= 1) d *= n-1;

     if(found("path", t)) {
       add_spider(G, 1, generator);


C cast -> static_cast

C cast -> static_cast

--- test/test_table.cpp
+++ test/test_table.cpp
@@ -1503,13 +1503,15 @@

 /*
+// FIXME Commented out because indexes on floats and doubles are not supported (yet).
+
 TEST(Table_DistinctFloat)
 {
     Table table;
     table.add_column(type_Float, "first");
     table.add_empty_row(12);
     for (size_t i = 0; i < 10; ++i) {
-        table.set_float(0, i, (float)i + 0.5f);
+        table.set_float(0, i, static_cast<float>(i) + 0.5f);
     }
     table.set_float(0, 10, 0.5f);
     table.set_float(0, 11, 1.5f);
@@ -1528,7 +1530,7 @@
     table.add_column(type_Double, "first");
     table.add_empty_row(12);
     for (size_t i = 0; i < 10; ++i) {
-        table.set_double(0, i, (double)i + 0.5);
+        table.set_double(0, i, static_cast<double>(i) + 0.5);
     }
     table.set_double(0, 10, 0.5);
     table.set_double(0, 11, 1.5);


[style] Code style fixups in GetWarnings()

--- src/warnings.cpp
+++ src/warnings.cpp
@@ -42,31 +42,28 @@
 {
     std::string warnings_concise;
     std::string warnings_verbose;
-    const std::string uiAlertSeperator = "
";
+    const std::string warning_separator = "
";

     LOCK(cs_warnings);

+    // Pre-release build warning
     if (!CLIENT_VERSION_IS_RELEASE) {
         warnings_concise = "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications";
         warnings_verbose = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications").translated;
     }

     // Misc warnings like out of disk space and clock is wrong
-    if (strMiscWarning != "")
-    {
+    if (strMiscWarning != "") {
         warnings_concise = strMiscWarning;
-        warnings_verbose += (warnings_verbose.empty() ? "" : uiAlertSeperator) + strMiscWarning;
+        warnings_verbose += (warnings_verbose.empty() ? "" : warning_separator) + strMiscWarning;
     }

-    if (fLargeWorkForkFound)
-    {
+    if (fLargeWorkForkFound) {
         warnings_concise = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
-        warnings_verbose += (warnings_verbose.empty() ? "" : uiAlertSeperator) + _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.").translated;
-    }
-    else if (fLargeWorkInvalidChainFound)
-    {
+        warnings_verbose += (warnings_verbose.empty() ? "" : warning_separator) + _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.").translated;
+    } else if (fLargeWorkInvalidChainFound) {
         warnings_concise = "Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.";
-        warnings_verbose += (warnings_verbose.empty() ? "" : uiAlertSeperator) + _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.").translated;
+        warnings_verbose += (warnings_verbose.empty() ? "" : warning_separator) + _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.").translated;
     }

     if (verbose) return warnings_verbose;


wavm: clone integration in Wavm::clone() (#83)

Signed-off-by: mathetake <72d3043deb9ea484d21ffcca03f662fa81cbe321@tetrate.io>

--- src/wavm/wavm.cc
+++ src/wavm/wavm.cc
@@ -14,6 +14,7 @@
 // limitations under the License.

 #include "include/proxy-wasm/wavm.h"
+#include "include/proxy-wasm/wasm_vm.h"

 #include <cstdlib>
 #include <iostream>
@@ -23,8 +24,6 @@
 #include <unordered_map>
 #include <utility>
 #include <vector>
-
-#include "include/proxy-wasm/wasm_vm.h"

 #include "WAVM/IR/Module.h"
 #include "WAVM/IR/Operators.h"
@@ -253,6 +252,8 @@

 std::unique_ptr<WasmVm> Wavm::clone() {
   auto wavm = std::make_unique<Wavm>();
+  wavm->integration().reset(integration()->clone());
+
   wavm->compartment_ = WAVM::Runtime::cloneCompartment(compartment_);
   wavm->memory_ = WAVM::Runtime::remapToClonedCompartment(memory_, wavm->compartment_);
   wavm->memory_base_ = WAVM::Runtime::getMemoryBaseAddress(wavm->memory_);


small patch to make windows version compile again.

--- src/win32dll.cpp
+++ src/win32dll.cpp
@@ -1,5 +1,7 @@

 #include <windows.h>
+#include <stdlib.h>
+#include <stdio.h>

 #include "yacasprivate.h"
 #include "lispenvironment.h"


Fix errors in dump output.

Fix errors in dump output.

 * Pointers written to output streams are automatically prefixed with
   '0x', so no need to do that manually.
 * There was a missing cast to void* when writing object addresses
   which caused them to be output as strings.
 * There was a missing space between value and unit.

--- src/main/cpp/Heap.cpp
+++ src/main/cpp/Heap.cpp
@@ -319,21 +319,21 @@

 	const HeapStats stats = this->collectHeapStats(true);

-	os << "==== Statistics for heap at 0x" << std::hex << mHeapStart << std::dec << " ====\n";
+	os << "==== Statistics for heap at " << std::hex << mHeapStart << std::dec << " ====\n";
 	os << "Heap size:  " << stats.heapSize << " bytes\n";
 	os << "Used space: " << stats.usedSize << " bytes\n";
 	os << "Free space: " << stats.freeSize << " bytes\n";
 	os << '\n';
 	os << "Object count:    " << stats.numObjects << " (" << stats.numLiveObjects << " live)\n";
 	os << "Object size:     " << stats.objectSize << " bytes (" << stats.liveObjectSize << " in live objects)\n";
-	os << "Available space: " << stats.freeBlockSize << "bytes in " << stats.numFreeBlocks << " blocks\n";
+	os << "Available space: " << stats.freeBlockSize << " bytes in " << stats.numFreeBlocks << " blocks\n";
 	os << '\n';
 	os << "= Free Blocks =\nAddress    Size(net)\n";

 	// Print free blocks: just use the free list
 	os.fill('0');
 	for(auto blk = mFreeList; blk; blk = blk->next()) {
-		os << std::hex << "0x" << std::setw(sizeof(void*)) << blk
+		os << std::hex << std::setw(sizeof(void*)) << blk
 				<< ' ' << std::dec << blk->size() << '\n';
 	}
 	os << std::setfill(' ') << '\n';
@@ -354,7 +354,7 @@
 	for(auto blk = mHeapStart; blk < mHeapEnd; blk = blk->following()) {
 		if(blk->mark()) {
 			blk->ptr().mark(false);
-			os << blk->data() << ' ' << "TODO NAME" << '\n';
+			os << static_cast<void*>(blk->data()) << ' ' << "TODO NAME" << '\n';
 			os << "  Data: ";
 			std::copy_n(blk->data(), std::min(blk->type().size(), numDataBytes), std::ostream_iterator<int>(os, " "));
 			if(blk->type().size() > numDataBytes) {


Bazel client: debug info for corrupt installation

The Bazel client checks the installation files
every time it starts. Bazel checks that it can
read the installation files and that their mtimes
are in the future.

The "bazel-tests" project on Bazel CI recently
produced flaky-looking failures. The error
messages talk about a missing installation file.

This change makes Bazel print more debugging info
when the aformentioned check fails. I hope the
information will help catching this bug.

See https://github.com/bazelbuild/bazel/issues/3618

Change-Id: Ic51384b5840262484515fa320f162a79cfd0e012
PiperOrigin-RevId: 166696141

--- src/main/cpp/blaze.cc
+++ src/main/cpp/blaze.cc
@@ -948,6 +948,27 @@
         continue;
       }
       if (!blaze_util::CanReadFile(path)) {
+        // TODO(laszlocsomor): remove the following `#if 1` block after I or
+        // somebody else fixed https://github.com/bazelbuild/bazel/issues/3618.
+#if 1
+        fprintf(stderr,
+                "DEBUG: corrupt installation: file '%s' missing. "
+                "Dumping debug data.\n",
+                path.c_str());
+        string p = path;
+        while (!p.empty()) {
+          fprintf(stderr, "DEBUG: p=(%s), exists=%d, isdir=%d, canread=%d\n",
+                  p.c_str(), blaze_util::PathExists(p) ? 1 : 0,
+                  blaze_util::IsDirectory(p) ? 1 : 0,
+                  blaze_util::CanReadFile(p) ? 1 : 0);
+          string parent = blaze_util::Dirname(p);
+          if (parent == p) {
+            break;
+          } else {
+            p = parent;
+          }
+        }
+#endif
         die(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR,
             "Error: corrupt installation: file '%s' missing."
             " Please remove '%s' and try again.",


add tests for pushing on back as well as front

git-svn-id: e8541e15acce502a64c929015570ad1648e548cd@827 2bbb7eff-a529-9590-31e7-b0007b416f81

--- tests/DequeTest.cpp
+++ tests/DequeTest.cpp
@@ -39,6 +39,8 @@
     SkDeque deq(sizeof(int));
     int i;

+    // test pushing on the front
+
     assert_count(reporter, deq, 0);
     for (i = 1; i <= 10; i++) {
         *(int*)deq.push_front() = i;
@@ -56,6 +58,38 @@
         deq.pop_front();
     }
     assert_count(reporter, deq, 0);
+
+    // now test pushing on the back
+
+    for (i = 10; i >= 1; --i) {
+        *(int*)deq.push_back() = i;
+    }
+    assert_count(reporter, deq, 10);
+    assert_f2biter(reporter, deq, 10, 1);
+
+    for (i = 0; i < 5; i++) {
+        deq.pop_back();
+    }
+    assert_count(reporter, deq, 5);
+    assert_f2biter(reporter, deq, 10, 6);
+
+    for (i = 0; i < 5; i++) {
+        deq.pop_back();
+    }
+    assert_count(reporter, deq, 0);
+
+    // now tests pushing/poping on both ends
+
+    *(int*)deq.push_front() = 5;
+    *(int*)deq.push_back() = 4;
+    *(int*)deq.push_front() = 6;
+    *(int*)deq.push_back() = 3;
+    *(int*)deq.push_front() = 7;
+    *(int*)deq.push_back() = 2;
+    *(int*)deq.push_front() = 8;
+    *(int*)deq.push_back() = 1;
+    assert_count(reporter, deq, 8);
+    assert_f2biter(reporter, deq, 8, 1);
 }

 #include "TestClassDef.h"


Adjust producer data, less recorders and different values

--- src/main_recorder.cpp
+++ src/main_recorder.cpp
@@ -84,13 +84,13 @@
   float  data1[3] = {500.0f*x, 600.0f*x, 700.0f*x};
   double data2[3] = {500.0*x, 600.0*x, 700.0*x};
   rec.record(T::A, *reinterpret_cast<char*>(&x), x);
-  rec.record(T::B, std::log(1+x), x);
-  rec.record(T::C, reinterpret_cast<int32_t>(-x*x), x);
-  rec.record(T::D, static_cast<int64_t>(-x*x), x);
-  rec.record(T::E, static_cast<uint64_t>(x*x), x);
+  rec.record(T::B, std::log(2+x), x);
+  rec.record(T::C, reinterpret_cast<int32_t>(-1), x);
+  rec.record(T::D, static_cast<int64_t>(-2+x), x);
+  rec.record(T::E, static_cast<uint64_t>(2*(1+x)), x);
   rec.record(T::X, data1, x);
   rec.record(T::Y, data2, x);
-  rec.record(T::Z, {10*x, 20*x}, x);
+  rec.record(T::Z, {10*(1+x), 20*(1+x)}, x);
 }

@@ -103,27 +103,15 @@
   Recorder<FOO> recfoo(recorder_name, random() % (1<<16));
   funcSetupRecorder(recfoo, prefix.c_str(), id);

-  prefix = "BAR";
-  snprintf(recorder_name, sizeof(recorder_name), "%s%02d", prefix.c_str() , id);
-  Recorder<BAR> recbar(recorder_name, random() % (1<<16));
-  funcSetupRecorder(recbar, prefix.c_str(), id);
-
-  prefix = "FUU";
-  snprintf(recorder_name, sizeof(recorder_name), "%s%02d", prefix.c_str() , id);
-  Recorder<FUU> recfuu(recorder_name, random() % (1<<16));
-  funcSetupRecorder(recfuu, prefix.c_str(), id);
-
-  prefix = "BER";
-  snprintf(recorder_name, sizeof(recorder_name), "%s%02d", prefix.c_str() , id);
-  Recorder<BER> recber(recorder_name, random() % (1<<16));
-  funcSetupRecorder(recber, prefix.c_str(), id);
+  //prefix = "BAR";
+  //snprintf(recorder_name, sizeof(recorder_name), "%s%02d", prefix.c_str() , id);
+  //Recorder<BAR> recbar(recorder_name, random() % (1<<16));
+  //funcSetupRecorder(recbar, prefix.c_str(), id);

   for (int j = 0; j < num_rounds; ++j) {
-    //std::this_thread::sleep_for(nsec(10));
+    std::this_thread::sleep_for(nsec(1));
     funcRecordRecorder(recfoo, j);
-    funcRecordRecorder(recbar, j);
-    funcRecordRecorder(recfuu, j);
-    funcRecordRecorder(recber, j);
+    //funcRecordRecorder(recbar, j);
   }
 }

@@ -175,7 +163,7 @@
   RecorderSink backend;
   backend.start(vm.count("verbose"));

-  int const num_recorder_per_thread = 4;
+  int const num_recorder_per_thread = 2;
   int const num_messages_per_recorder = 8;

   // Each item recording generates two messages per round except for the


minor upd

minor upd

git-svn-id: 0591ae0973f42c6a2cf4018151e00ecc2fd9718a@1042 10c4dfc4-00c9-b076-3360-45a67c2f8363

--- tests/IndexTerm.cpp
+++ tests/IndexTerm.cpp
@@ -44,10 +44,16 @@
   IndexHamiltonian::Term IT1(4, seq_v, ind_v, 1.0);
   INFO("Created IndexHamiltonian::Term" << IT1);
   INFO("Rearranging it to normal order");
-  boost::shared_ptr<std::list<IndexHamiltonian::Term*> > out_terms=IT1.makeNormalOrder();
-  INFO("Received " << IT1);
-  INFO(out_terms->size() << " additional terms emerged : ");
-  for (std::list<IndexHamiltonian::Term*>::const_iterator it1=out_terms->begin(); it1!=out_terms->end(); ++it1) DEBUG(**it1);
+  try {
+    boost::shared_ptr<std::list<IndexHamiltonian::Term*> > out_terms=IT1.makeNormalOrder();
+    INFO("Received " << IT1);
+    INFO(out_terms->size() << " additional terms emerged : ");
+    for (std::list<IndexHamiltonian::Term*>::const_iterator it1=out_terms->begin(); it1!=out_terms->end(); ++it1) DEBUG(**it1);
+    }
+  catch (std::exception &e)
+    {
+        return EXIT_FAILURE;
+    }
   /* end of test of IndexHamiltonian::Term */

   return EXIT_SUCCESS;


Expand JSON tests for Null, Number, Bool. Embed both array and object to array and object test data.

--- tests/JSON/main.cpp
+++ tests/JSON/main.cpp
@@ -8,18 +8,62 @@
 using namespace Tundra::Test;

 const String StringData = "\"  Json String Test\tHello World  \"";
-const String ObjectData = "{\n\"Hello\":true  ,   \"World\"  \n:  00010, \"Str\" :" + StringData + "  }";
+const String ObjectData = "{\n\"Hello\":true  ,   \"World\"  \n:  00010, \"Str\" :" + StringData + " , \"Arr\" : [1,2],\"Obj\":{\"test\" : true}  }";
 const String ArrayData  = "[ \"Hello World\", 0  ,-1234,   1234.5678  ,  true,false,   \n   null, [ \"World Hello\", 10, false ]  \t , " + ObjectData + "  \n]";

 TEST_F(Runner, ParseJSON)
 {
     Tundra::Benchmark::Iterations = 10000;

+    BENCHMARK("Null", 10)
+    {
+        JSONValue value;
+
+        ASSERT_TRUE(value.FromString(" \t \n     null   "));
+        BENCHMARK_STEP_END;
+
+        ASSERT_EQ(value.Type(), JSON_NULL);
+        ASSERT_TRUE(value.IsNull());
+    }
+    BENCHMARK_END;
+
+    Tundra::Benchmark::Iterations = 10000;
+
+    BENCHMARK("Bool", 10)
+    {
+        JSONValue value;
+
+        ASSERT_TRUE(value.FromString(" \t \n     true   "));
+        BENCHMARK_STEP_END;
+
+        ASSERT_EQ(value.Type(), JSON_BOOL);
+        ASSERT_TRUE(value.IsBool());
+        ASSERT_TRUE(value.GetBool());
+    }
+    BENCHMARK_END;
+
+    Tundra::Benchmark::Iterations = 10000;
+
+    BENCHMARK("Number", 10)
+    {
+        JSONValue value;
+
+        ASSERT_TRUE(value.FromString("  \n    1238972313.12312412   "));
+        BENCHMARK_STEP_END;
+
+        ASSERT_EQ(value.Type(), JSON_NUMBER);
+        ASSERT_TRUE(value.IsNumber());
+        ASSERT_DOUBLE_EQ(value.GetNumber(), 1238972313.12312412);
+    }
+    BENCHMARK_END;
+
+    Tundra::Benchmark::Iterations = 10000;
+
     BENCHMARK("String", 10)
     {
         JSONValue value;

-        ASSERT_TRUE(value.FromString(StringData));
+        ASSERT_TRUE(value.FromString(StringData));
         BENCHMARK_STEP_END;

         ASSERT_EQ(value.Type(), JSON_STRING);
@@ -35,7 +79,7 @@
     {
         JSONValue value;

-        ASSERT_TRUE(value.FromString(ArrayData));
+        ASSERT_TRUE(value.FromString(ArrayData));
         BENCHMARK_STEP_END;

         ASSERT_EQ(value.Type(), JSON_ARRAY);
@@ -63,6 +107,13 @@
         ASSERT_DOUBLE_EQ(obj["World"].GetNumber(), 10.0);
         ASSERT_TRUE(obj["Str"].IsString());
         ASSERT_EQ(obj["Str"].GetString().Length(), StringData.Length() - 2);
+        // Embedded child array
+        ASSERT_TRUE(obj["Arr"].IsArray());
+        ASSERT_EQ(obj["Arr"].GetArray()[1], 2);
+        // Embedded child Object
+        ASSERT_TRUE(obj["Obj"].IsObject());
+        JSONObject childObj = obj["Obj"].GetObject();
+        ASSERT_TRUE(childObj["test"].GetBool());
     }
     BENCHMARK_END;

@@ -72,7 +123,7 @@
     {
         JSONValue value;

-        ASSERT_TRUE(value.FromString(ObjectData));
+        ASSERT_TRUE(value.FromString(ObjectData));
         BENCHMARK_STEP_END;

         ASSERT_EQ(value.Type(), JSON_OBJECT);
@@ -84,6 +135,13 @@
         ASSERT_DOUBLE_EQ(obj["World"].GetNumber(), 10.0);
         ASSERT_TRUE(obj["Str"].IsString());
         ASSERT_EQ(obj["Str"].GetString().Length(), StringData.Length() - 2);
+        // Embedded array
+        ASSERT_TRUE(obj["Arr"].IsArray());
+        ASSERT_EQ(obj["Arr"].GetArray()[1], 2);
+        // Embedded Object
+        ASSERT_TRUE(obj["Obj"].IsObject());
+        JSONObject childObj = obj["Obj"].GetObject();
+        ASSERT_TRUE(childObj["test"].GetBool());
     }
     BENCHMARK_END;
 }


Reverted a refactor that broke the build.

--- src/master/master.cpp
+++ src/master/master.cpp
@@ -871,27 +871,35 @@
   // 1) the default RateLimiter is not configured to handle case 2)
   //    above. (or)
   // 2) the principal exists in RateLimits but 'qps' is not set.
-  Option<Owned<BoundedRateLimiter> > limiter;
-  if (principal.isSome() && limiters.contains(principal.get())) {
-    limiter = limiters[principal.get()];
-  } else if ((principal.isNone() || !limiters.contains(principal.get())) &&
-             isRegisteredFramework) {
-    limiter = defaultLimiter;
-  }
-
-  // Now throttle the message if a limiter is found, unless its
-  // capacity is already reached.
-  if (limiter.isSome()) {
-    if (limiter.get()->capacity.isNone() ||
-        limiter.get()->messages < limiter.get()->capacity.get()) {
-      limiter.get()->messages++;
-      limiter.get()->limiter->acquire()
+  if (principal.isSome() &&
+      limiters.contains(principal.get()) &&
+      limiters[principal.get()].isSome()) {
+    const Owned<BoundedRateLimiter>& limiter = limiters[principal.get()].get();
+
+    if (limiter->capacity.isNone() ||
+        limiter->messages < limiter->capacity.get()) {
+      limiter->messages++;
+      limiter->limiter->acquire()
         .onReady(defer(self(), &Self::throttled, event, principal));
     } else {
       exceededCapacity(
           event,
           principal,
-          limiter.get()->capacity.get());
+          limiter->capacity.get());
+    }
+  } else if ((principal.isNone() || !limiters.contains(principal.get())) &&
+             isRegisteredFramework &&
+             defaultLimiter.isSome()) {
+    if (defaultLimiter.get()->capacity.isNone() ||
+        defaultLimiter.get()->messages < defaultLimiter.get()->capacity.get()) {
+      defaultLimiter.get()->messages++;
+      defaultLimiter.get()->limiter->acquire()
+        .onReady(defer(self(), &Self::throttled, event, None()));
+    } else {
+      exceededCapacity(
+          event,
+          principal,
+          defaultLimiter.get()->capacity.get());
     }
   } else {
     _visit(event);
@@ -938,8 +946,10 @@
   // We already know a RateLimiter is used to throttle this event so
   // here we only need to determine which.
   if (principal.isSome()) {
+    CHECK_SOME(limiters[principal.get()]);
     limiters[principal.get()].get()->messages--;
   } else {
+    CHECK_SOME(defaultLimiter);
     defaultLimiter.get()->messages--;
   }


Just had to get the 100% back...

Just had to get the 100% back...

--- tests/UtestTest.cpp
+++ tests/UtestTest.cpp
@@ -30,6 +30,15 @@
 #include "CppUTest/TestTestingFixture.h"
 #include "CppUTest/PlatformSpecificFunctions.h"

+TEST_GROUP(Utest)
+{
+};
+
+TEST(Utest, division)
+{
+    LONGS_EQUAL(3, division(13, 4));
+}
+
 TEST_GROUP(UtestShell)
 {
     TestTestingFixture fixture;


Changed default value of root_submissions to true (more convenient on EC2)

--- src/master/master.cpp
+++ src/master/master.cpp
@@ -155,7 +155,7 @@
   conf->addOption<string>("allocator", 'a', "Allocation module name", "simple");
   conf->addOption<bool>("root_submissions",
                         "Can root submit frameworks?",
-                        false);
+                        true);
 }


No need to wait for release on enter when selecting tab.

--- src/menu/tab_menu.cpp
+++ src/menu/tab_menu.cpp
@@ -462,7 +462,7 @@
                          * to work just fine without waiting.
                          * anyway, no real harm comes from waiting so just wait.
                          */
-                        InputManager::waitForRelease(input, Tab::Select);
+                        //InputManager::waitForRelease(input, Tab::Select);
                         // Run menu
                         (*currentTab)->running = true;
                         backgroundBuffer.reset();


Typo fix

Typo fix

git-svn-id: ffc1bc5b3feaf8644044862cc38c386ade156493@2661 434f946d-2f3d-0410-ba4c-cb9f52fb0dbf

--- src/mesh/mesh_tools.C
+++ src/mesh/mesh_tools.C
@@ -165,7 +165,7 @@
       parallel_only();
       unsigned int weight = MeshTools::weight (mesh, libMesh::processor_id());
       Parallel::sum(weight);
-      unsigned int unparitioned_weight =
+      unsigned int unpartitioned_weight =
         MeshTools::weight (mesh, DofObject::invalid_processor_id);
       return weight + unpartitioned_weight;
     }


Its possible to send empty messages, meaning no body, but a header.

--- response.hpp
+++ response.hpp
@@ -19,7 +19,7 @@
          *
          *  @param message The string to send.
          */
-        void send(std::string const& message);
+        void send(std::string const& message = "");

         /**
          *  Stringifies an object and sends it back to the client.
@@ -100,6 +100,15 @@
         void redirect(std::string const& path);

         /**
+         *  Sets the content type. such as "application/json".
+         *  if the passed type is a file extension (without dot), it will choose the correct type.
+         *  Check mime.cpp for a list of known extensions.
+         *
+         *  @param type custom Content-Type or file extension.
+         */
+        Response& type(std::string const& type);
+
+        /**
          *  Returns the connection to the client.
          *  Can be useful to access more delicate and low level things.
          *  Please do not abuse!


response: minor pass by value/reference changes

Signed-off-by: Petar Koretic <0bdc63247af490de2e3f3da15a8939ec28fc7d99@gmail.com>

--- response.hpp
+++ response.hpp
@@ -13,7 +13,7 @@
     Response &set(const QString &key, const QString &value) { header[key] = value; return *this; };

     quint16 status() const { return m_status; };
-    Response &status(const quint16 &status) { m_status = status; return *this; };
+    Response &status(quint16 status) { m_status = status; return *this; };

     QString type() const { return header["content-type"]; };
     Response &type(const QString &type) { header["content-type"] = type; return *this; };
@@ -21,7 +21,7 @@
     QString body() const { return m_body;};
     Response &body(const QString &body) { m_body = body; return *this; };

-    Response &write(const QString msg) { m_body += msg; return *this; };
+    Response &write(const QString &msg) { m_body += msg; return *this; };

     void send(const QString &body = "") {
         if (body.size())
@@ -43,6 +43,7 @@

     QHash<QString, QString> header;
     QString method, protocol;
+
     QHash<quint16, QString> http_codes
     {
         {100, "Continue"},


tests: Add send test to tcp_server

tests: Add send test to tcp_server

$ printf "txtx" | nc 192.168.66.123 10000

Server will send a large mount of data to client for TCP tx testing.
Currently, it sends 10MB of char 'X'.

--- tests/tcp_server.cc
+++ tests/tcp_server.cc
@@ -8,6 +8,15 @@
 #include "core/smp.hh"
 #include <vector>
 #include <iostream>
+
+static std::string str_ping{"ping"};
+static std::string str_txtx{"txtx"};
+static std::string str_pong{"pong"};
+static std::string str_unknow{"unknow cmd"};
+static int tx_msg_total_size = 10 * 1024 * 1024;
+static int tx_msg_size = 4 * 1024;
+static int tx_msg_nr = tx_msg_total_size / tx_msg_size;
+static std::string str_txbuf(tx_msg_size, 'X');

 class http_server {
     std::vector<server_socket> _listeners;
@@ -55,17 +64,48 @@
             if (_read_buf.eof()) {
                 return make_ready_future();
             }
-            // Expect a ping from client.
+            // Expect 4 bytes cmd from client
             size_t n = 4;
             return _read_buf.read_exactly(n).then([this] (temporary_buffer<char> buf) {
                 if (buf.size() == 0) {
                     return make_ready_future();
                 }
-                return _write_buf.write("pong", 4).then([this] {
-                    return _write_buf.flush();
-                }).then([this] {
-                    return this->read();
-                });
+                auto cmd = std::string(buf.get(), buf.size());
+                // pingpong test
+                if (cmd == str_ping) {
+                    return _write_buf.write(str_pong).then([this] {
+                        return _write_buf.flush();
+                    }).then([this] {
+                        return this->read();
+                    });
+                // server tx test
+                } else if (cmd == str_txtx) {
+                    return tx_test();
+                // unknow test
+                } else {
+                    return _write_buf.write(str_unknow).then([this] {
+                        return _write_buf.flush();
+                    }).then([this] {
+                        return make_ready_future();
+                    });
+                }
+            });
+        }
+        future<> do_write(int end) {
+            if (end == 0) {
+                return make_ready_future<>();
+            }
+            return _write_buf.write(str_txbuf).then([this, end] {
+                return _write_buf.flush();
+            }).then([this, end] {
+                return do_write(end - 1);
+            });
+        }
+        future<> tx_test() {
+            return do_write(tx_msg_nr).then([this] {
+                return _write_buf.close();
+            }).then([this] {
+                return make_ready_future<>();
             });
         }
     };


modified test-ftrtri to comply to new standards

--- tests/test-ftrtri.C
+++ tests/test-ftrtri.C
@@ -1,5 +1,5 @@
-/* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
+/* -*- mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+// vim:sts=4:sw=4:ts=4:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s

 /*
  * Copyright (C) FFLAS-FFPACK
@@ -26,105 +26,139 @@
  *.
  */

-//--------------------------------------------------------------------------
-//                        Test for ftrtri : 1 computation
-//
-//--------------------------------------------------------------------------
-// Clement Pernet
-//-------------------------------------------------------------------------
+#define  __FFLASFFPACK_SEQUENTIAL

-#define TIME 1
+#define ENABLE_ALL_CHECKINGS 1
+
+#include "fflas-ffpack/fflas-ffpack-config.h"

 #include <iomanip>
 #include <iostream>
-#include "givaro/modular-balanced.h"
-
-#include "fflas-ffpack/fflas-ffpack-config.h"

 #include "fflas-ffpack/utils/timer.h"
-#include "fflas-ffpack/utils/Matio.h"
-#include "fflas-ffpack/ffpack/ffpack.h"
-
-
+#include "fflas-ffpack/fflas/fflas.h"
+#include "fflas-ffpack/utils/args-parser.h"
+#include "test-utils.h"
+#include <givaro/modular.h>

 using namespace std;
 using namespace FFPACK;
+using namespace FFLAS;
+using Givaro::Modular;
+using Givaro::ModularBalanced;

-typedef Givaro::ModularBalanced<double> Field;
+
+template<typename Field, class RandIter>
+bool check_ftrtri (const Field &F, size_t n, FFLAS_UPLO uplo, FFLAS_TRANSPOSE trans, FFLAS_DIAG diag, RandIter& Rand){
+    typedef typename Field::Element Element;
+    Element * A, * B;
+    size_t lda = n + (rand() % n );
+    A  = fflas_new(F,n,lda);
+    B  = fflas_new(F,n,lda);
+
+    RandomTriangularMatrix (F, n, n, uplo, diag, true, A, lda, Rand);
+    fassign (F, n, n, A, lda, B, lda);
+
+    string ss=string((uplo == FflasLower)?"Lower_":"Upper_")+string((trans == FflasTrans)?"Trans_":"NoTrans_")+string((diag == FflasUnit)?"Unit":"NonUnit");
+
+    cout<<std::left<<"Checking FTRTRI_";
+    cout.fill('.');
+    cout.width(30);
+    cout<<ss;
+
+
+    Timer t; t.clear();
+    double time=0.0;
+    t.clear();
+    t.start();
+    ftrtri (F, uplo, diag, n, A, lda);
+    t.stop();
+    time+=t.usertime();
+
+    // B <- A times B
+    ftrmm(F, FFLAS::FflasLeft, uplo, trans, diag, n, n, F.one, A, lda, B, lda);
+
+    // Is B the identity matrix ?
+    bool ok = true;
+    for(size_t li = 0; li < n && ok; li++){
+	    for(size_t co = 0; co < n && ok; co++){
+		    ok = ((li == co) && (F.areEqual(A[li*(lda+1)],F.one))) || (F.areEqual(A[li*lda+co],F.zero));
+	    }
+    }
+
+    if (ok){
+	    cout << "PASSED ("<<time<<")"<<endl;
+    } else{
+	    cout << "FAILED ("<<time<<")"<<endl;
+    }
+
+    fflas_delete(A);
+    fflas_delete(B);
+    return ok;
+}
+template <class Field>
+bool run_with_field (Givaro::Integer q, size_t b, size_t n, size_t iters, uint64_t seed){
+    bool ok = true ;
+    int nbit=(int)iters;
+
+    while (ok &&  nbit){
+	    //typedef typename Field::Element Element ;
+	    // choose Field
+	    Field* F= chooseField<Field>(q,b);
+	    typename Field::RandIter G(*F,0,seed);
+	    if (F==nullptr)
+		    return true;
+
+	    cout<<"Checking with ";F->write(cout)<<endl;
+
+	    ok = ok && check_ftrtri(*F,n,FflasLower,FflasNoTrans,FflasUnit,G);
+	    ok = ok && check_ftrtri(*F,n,FflasUpper,FflasNoTrans,FflasUnit,G);
+	    ok = ok && check_ftrtri(*F,n,FflasLower,FflasTrans,FflasUnit,G);
+	    ok = ok && check_ftrtri(*F,n,FflasUpper,FflasTrans,FflasUnit,G);
+	    ok = ok && check_ftrtri(*F,n,FflasLower,FflasNoTrans,FflasNonUnit,G);
+	    ok = ok && check_ftrtri(*F,n,FflasUpper,FflasNoTrans,FflasNonUnit,G);
+	    ok = ok && check_ftrtri(*F,n,FflasLower,FflasTrans,FflasNonUnit,G);
+	    ok = ok && check_ftrtri(*F,n,FflasUpper,FflasTrans,FflasNonUnit,G);
+	    nbit--;
+	    delete F;
+    }
+    return ok;
+}

 int main(int argc, char** argv)
 {
-
-	size_t  n;
-	int nbit=atoi(argv[3]); // number of times the product is performed
-	cerr<<setprecision(10);
-
-	if (argc != 4)	{
-		cerr<<"Usage : test-ftrtri <p> <A> <<i>"
-		    <<endl
-		    <<"         to invert a triangular matrix  A mod p (i computations)"
-		    <<endl;
-		exit(-1);
-	}
-	Field F(atoi(argv[1]));
-	Field::Element * A,*Ab;
-	A = read_field(F,argv[2],&n,&n);
-	Ab = FFLAS::fflas_new<Field::Element>(n*n);
-
-	for (int i=0; i<n;++i){
-		for(int j=i+1; j<n; ++j)
-			F.assign(*(Ab+i*n+j),*(A+i*n+j));
-		F.assign(*(Ab+i*(n+1)), 1.0);
-		for(int j=0; j<i; ++j)
-			F.assign(*(Ab+i*n+j),0.0);
-	}
-
-
-	Field::Element * X = FFLAS::fflas_new<Field::Element>(n*n);
-
- FFLAS::Timer tim,t; t.clear();tim.clear();
-
-	for(int i = 0;i<nbit;++i){
-		t.clear();
-		t.start();
-//				FFPACK::trinv_left (F, n, A, n, X, n);
-				FFPACK::ftrtri(F, FFLAS::FflasUpper, FFLAS::FflasUnit, n, A, n);
-		t.stop();
-		tim+=t;
-		if (i+1<nbit)
-			for (int i=0; i<n*n;++i)
-				F.assign(*(A+i),*(Ab+i));
-	}
-
-#ifdef __FFLASFFPACK_DEBUG
-	FFLAS::ftrmm (F, FFLAS::FflasRight, FFLAS::FflasUpper, FFLAS::FflasNoTrans, FFLAS::FflasUnit,
-		      n, n, 1.0,
-		      A,n, Ab, n);
-	bool wrong = false;
-
-	for (int i=0;i<n;++i)
-		for (int j=0;j<n;++j)
-			if ( ((i!=j) && !F.isZero(*(Ab+i*n+j)))
-			     ||((i==j) &&!F.isOne(*(Ab+i*n+j))))
-				wrong = true;
-
-	if ( wrong ){
-		cerr<<"FAIL"<<endl;
-		write_field (F,cerr<<"Ab="<<endl,Ab,n,n,n);
-		    //write_field (F,cerr<<"X="<<endl,X,n,n,n);
-	}else{
-
-		cerr<<"PASS"<<endl;
-	}
-#endif
-
-#if TIME
-	double gflops = 1.0/3.0*(n/1000.0*n/1000000.0)*nbit*n/tim.usertime();
-	cerr<<"n = "<<n<<" Inversion over Z/"<<atoi(argv[1])<<"Z : t= "
-	     << tim.usertime()/nbit
-	     << " s, Gfops = "<<gflops
-	     << endl;
-
-	cout<<n<<" "<<gflops<<" "<<tim.usertime()/nbit<<endl;
-#endif
+    cerr<<setprecision(10);
+    Givaro::Integer q=-1;
+    size_t b=0;
+    size_t n=483;
+    size_t iters=1;
+    bool loop=false;
+    uint64_t seed = time(NULL);
+    Argument as[] = {
+	    { 'q', "-q Q", "Set the field characteristic (-1 for random).",         TYPE_INTEGER , &q },
+	    { 'b', "-b B", "Set the bitsize of the field characteristic.",  TYPE_INT , &b },
+	    { 'n', "-n N", "Set the dimension of the system.", TYPE_INT , &n },
+	    { 'i', "-i R", "Set number of repetitions.",            TYPE_INT , &iters },
+	    { 'l', "-loop Y/N", "run the test in an infinite loop.", TYPE_BOOL , &loop },
+	    { 's', "-s seed", "Set seed for the random generator", TYPE_INT, &seed },
+	    END_OF_ARGUMENTS
+    };
+
+    parseArguments(argc,argv,as);
+
+    bool ok = true;
+    do{
+	    ok &= run_with_field<Modular<double> >(q,b,n,iters,seed);
+	    ok &= run_with_field<ModularBalanced<double> >(q,b,n,iters,seed);
+	    ok &= run_with_field<Modular<float> >(q,b,n,iters,seed);
+	    ok &= run_with_field<ModularBalanced<float> >(q,b,n,iters,seed);
+	    ok &= run_with_field<Modular<int32_t> >(q,b,n,iters,seed);
+	    ok &= run_with_field<ModularBalanced<int32_t> >(q,b,n,iters,seed);
+	    ok &= run_with_field<Modular<int64_t> >(q,b,n,iters,seed);
+	    ok &= run_with_field<ModularBalanced<int64_t> >(q,b,n,iters,seed);
+	    ok &= run_with_field<Modular<Givaro::Integer> >(q,5,n/4+1,iters,seed);
+	    ok &= run_with_field<Modular<Givaro::Integer> >(q,(b?b:512),n/4+1,iters,seed);
+    } while (loop && ok);
+
+    return !ok ;
 }


Adapt to renamed MethodStatistics fields.

Change-Id: I616ba27917c52ad2a36c74533c3f6b1752d2c764
Reviewed-on: http://gerrit.aldebaran.lan:8080/16937
Reviewed-by: cgestes <ddb78fe00abb42f91254c16a0860e38eb0781789@aldebaran-robotics.com>
Reviewed-by: mnottale <e3ccf1b6558404e921a21fa09cebb1153b50ec36@aldebaran-robotics.com>
Tested-by: mnottale <e3ccf1b6558404e921a21fa09cebb1153b50ec36@aldebaran-robotics.com>

--- tests/test_call.cpp
+++ tests/test_call.cpp
@@ -943,8 +943,8 @@
   qi::MethodStatistics& m = stats[mid];
   EXPECT_EQ(2u, m.count);
   // Don't expect too much sleep precision
-  EXPECT_LT(10.0, std::abs(m.min - 10.0));
-  EXPECT_LT(30.0, std::abs(m.max - 100.0));
+  EXPECT_GT(0.01, std::abs(m.minTime - 0.010));
+  EXPECT_GT(0.03, std::abs(m.maxTime - 0.100));
   obj->call<void>("clearStats");
   obj->call<void>("sleep", 0);
   stats = obj->call<qi::ObjectStatistics>("stats");


Added test wait_back timer at queue

Added test wait_back timer at queue

--- tests/testqueue.cpp
+++ tests/testqueue.cpp
@@ -168,6 +168,57 @@
 	consumer.join();
 }

+TEST(Wait_back,HandleBasicOperation){
+	std::threadsafe::queue<int> queue;
+	int out;
+	for (int i = 1;i <= 10;i++){
+		queue.push(i);
+	}
+
+	for (int i = 10;i >= 1;i--){
+		queue.wait_back(out);
+		ASSERT_EQ(10,queue.size());
+		ASSERT_EQ(10,out);
+	}
+
+}
+
+TEST(Wait_back,Timer){
+	std::threadsafe::queue<int> queue;
+
+	std::thread producer([&]{
+		queue.push(1);
+		std::this_thread::sleep_for(std::chrono::milliseconds(10));
+		queue.push(2);
+		std::this_thread::sleep_for(std::chrono::milliseconds(50));
+		queue.push(3);
+	});
+
+	std::thread consumer([&]{
+		int output;
+
+		try {
+			queue.wait_back(output,std::chrono::milliseconds(5));
+			ASSERT_EQ(1,output);
+			queue.wait_pop(output);
+
+			queue.wait_back(output,std::chrono::milliseconds(15));
+			ASSERT_EQ(2,output);
+			queue.wait_pop(output);
+		} catch(std::threadsafe::Time_Expired e){
+			FAIL() << " exception Time_Expired throwed";
+		}
+
+		try {
+			queue.wait_back(output,std::chrono::milliseconds(1));
+			FAIL() << " exception didn't throw!";
+		} catch(std::threadsafe::Time_Expired e){
+		}
+	});
+
+	producer.join();
+	consumer.join();
+}
 TEST(EMPTY,HanbleBasicOperation){
 	std::threadsafe::queue<int> queue;
 	ASSERT_TRUE(queue.empty());


Cleanup

Cleanup

--- src/mtac/Compiler.cpp
+++ src/mtac/Compiler.cpp
@@ -1573,7 +1573,7 @@
             //Load left value in temp
             visit(AssignValueToVariable(function, temp), operation.Content->left_value);

-            //TODO Check if there are not one temporary too much
+            //Note: The extra temporary will be removed by optimizations
             performPrefixOperation(operation, function);

             return temp;
@@ -1583,7 +1583,7 @@
             //Load left value in temp
             visit(AssignValueToVariable(function, temp), operation.Content->left_value);

-            //TODO Check if there are not one temporary too much
+            //Note: The extra temporary will be removed by optimizations
             performPrefixOperation(operation, function);

             return temp;


Clean ACL cache on server shutdown

Clean ACL cache on server shutdown

git-svn-id: 1bc0666016e746585a50f826fc9dc079e42ee77e@1535 05730e5d-ab1b-0410-a4ac-84af385074fa

--- src/murmur/Server.cpp
+++ src/murmur/Server.cpp
@@ -163,6 +163,7 @@
 #else
 		closesocket(sUdpSocket);
 #endif
+	clearACLCache();
 	log("Stopped");
 }


Refactor in some helper functions to timeout.cc.

HandleCrash will be introduced in the next CL and it will depend on these helpers.

PiperOrigin-RevId: 406820046
Change-Id: I99130283c2c34bd595e22b4ca8f5d93fcc746928

--- src/native/timeout.cc
+++ src/native/timeout.cc
@@ -33,6 +33,11 @@
 NO_SANITIZE
 void SetTimeout(int timeout_secs) { ::atheris::timeout_secs = timeout_secs; }

+NO_SANITIZE
+bool is_null_or_default(sighandler_t h) {
+  return h == nullptr || h == SIG_DFL || h == SIG_IGN;
+}
+
 // A back SIGALRM signal handler, registered inside of HandleAlarm, to call
 // libFuzzer's handler if the Python handler never gets called.
 NO_SANITIZE
@@ -43,8 +48,7 @@
                "Falling back to native timeout handling."
             << std::endl;

-  if (libfuzzer_alarm_signal == nullptr || libfuzzer_alarm_signal == SIG_DFL ||
-      libfuzzer_alarm_signal == SIG_IGN) {
+  if (is_null_or_default(libfuzzer_alarm_signal)) {
     _exit(1);
   }
   libfuzzer_alarm_signal(signum);
@@ -82,6 +86,25 @@
 }

 NO_SANITIZE
+void signal_or_exit(sighandler_t handler, int signum) {
+  if (is_null_or_default(handler)) {
+    exit(1);
+  }
+  handler(signum);
+}
+
+// Returns the old handle in the `signum` signal replacing it with `new_handle`.
+NO_SANITIZE
+sighandler_t replace_handle(int signum, sighandler_t new_handle) {
+  struct sigaction action;
+  checked_sigaction(signum, nullptr, &action);
+  auto old_handle = action.sa_handler;
+  action.sa_handler = new_handle;
+  checked_sigaction(signum, &action, nullptr);
+  return old_handle;
+}
+
+NO_SANITIZE
 void SetupTimeoutAlarm() {
   // If python_alarm_signal isn't set, either SetupPythonSigaction wasn't called
   // or it returned false. Timeouts are unsupported.
@@ -104,13 +127,7 @@
               << std::endl;
   }

-  struct sigaction action;
-  checked_sigaction(SIGALRM, nullptr, &action);
-
-  libfuzzer_alarm_signal = action.sa_handler;
-
-  action.sa_handler = HandleAlarm;
-  checked_sigaction(SIGALRM, &action, nullptr);
+  libfuzzer_alarm_signal = replace_handle(SIGALRM, HandleAlarm);
 }

 void PrintPythonCallbacks(int signum, py::object frame) {
@@ -120,13 +137,7 @@
   // Print the Python trace.
   auto faulthandler = py::module::import("faulthandler");
   faulthandler.attr("dump_traceback")();
-  if (libfuzzer_alarm_signal == nullptr || libfuzzer_alarm_signal == SIG_DFL ||
-      libfuzzer_alarm_signal == SIG_IGN) {
-    exit(1);
-  }
-
-  // exit.
-  libfuzzer_alarm_signal(signum);
+  signal_or_exit(libfuzzer_alarm_signal, signum);
 }

 bool SetupPythonSigaction() {
@@ -147,8 +158,7 @@

   // If someone has provided a SIGALRM handler, we shouldn't override that -
   // print a warning and break.
-  if (orig_action.sa_handler != nullptr && orig_action.sa_handler != SIG_DFL &&
-      orig_action.sa_handler != SIG_IGN) {
+  if (!is_null_or_default(orig_action.sa_handler)) {
     std::cerr << "WARNING: SIGALRM handler already defined at address "
               << reinterpret_cast<void*>(orig_action.sa_handler)
               << ". Fuzzer timeout will not work." << std::endl;


aboutdialog: use just "The Bitcoin developers" as tr()-string

- this ensures our new splash screen and this will share a translatable
  string an remove the need for an additional translation

--- src/qt/aboutdialog.cpp
+++ src/qt/aboutdialog.cpp
@@ -11,7 +11,7 @@
     ui->setupUi(this);

     // Set current copyright year
-    ui->copyrightLabel->setText(tr("Copyright") + QString(" © ") + tr("2009-%1 The Bitcoin developers").arg(COPYRIGHT_YEAR));
+    ui->copyrightLabel->setText(tr("Copyright") + QString(" © 2009-%1 ").arg(COPYRIGHT_YEAR) + tr("The Bitcoin developers"));
 }

 void AboutDialog::setModel(ClientModel *model)


Add displaying indices in visualizer

Add displaying indices in visualizer

--- visualizer/main.cpp
+++ visualizer/main.cpp
@@ -42,6 +42,7 @@
         , m_isHideSuperTri(false)
         , m_isRemoveOuter(false)
         , m_isRemoveOuterAndHoles(false)
+        , m_isDisplayIndices(false)
         , m_translation(0., 0.)
         , m_scale(1.0)
     {
@@ -103,6 +104,12 @@
     {
         m_isRemoveOuterAndHoles = (isRemoveOuterAndHoles != 0);
         updateCDT();
+    }
+
+    void displayIndices(int isDisplayIndices)
+    {
+        m_isDisplayIndices = (isDisplayIndices != 0);
+        update();
     }

     void prtScn()
@@ -209,6 +216,10 @@
                 m_cdt.eraseOuterTriangles();
             else if(m_isHideSuperTri)
                 m_cdt.eraseSuperTriangle();
+            const CDT::unordered_map<Edge, CDT::EdgeVec> tmp =
+                CDT::EdgeToPiecesMapping(m_cdt.pieceToOriginals);
+            const CDT::unordered_map<Edge, std::vector<CDT::VertInd> >
+                edgeToSplitVerts = EdgeToSplitVertices(tmp, m_cdt.vertices);
         }
         if(!CDT::verifyTopology(m_cdt))
         {
@@ -303,7 +314,9 @@
         pen.setColor(QColor(150, 150, 150));
         p.setPen(pen);
         typedef CDT::TriangleVec::const_iterator TCit;
-        for(TCit t = m_cdt.triangles.begin(); t != m_cdt.triangles.end(); ++t)
+        int iT = 0;
+        for(TCit t = m_cdt.triangles.begin(); t != m_cdt.triangles.end();
+            ++t, ++iT)
         {
             if(!m_isHideSuperTri && !m_isRemoveOuter &&
                !m_isRemoveOuterAndHoles)
@@ -319,7 +332,26 @@
             const V2d& v3 = m_cdt.vertices[t->vertices[2]];
             const CDT::array<QPointF, 3> pts = {
                 sceneToScreen(v1), sceneToScreen(v2), sceneToScreen(v3)};
+            const QPointF c(
+                (pts[0].x() + pts[1].x() + pts[2].x()) / 3.f,
+                (pts[0].y() + pts[1].y() + pts[2].y()) / 3.f);
             p.drawPolygon(pts.data(), pts.size());
+        }
+        if(m_isDisplayIndices)
+        {
+            for(TCit t = m_cdt.triangles.begin(); t != m_cdt.triangles.end();
+                ++t, ++iT)
+            {
+                const V2d& v1 = m_cdt.vertices[t->vertices[0]];
+                const V2d& v2 = m_cdt.vertices[t->vertices[1]];
+                const V2d& v3 = m_cdt.vertices[t->vertices[2]];
+                const CDT::array<QPointF, 3> pts = {
+                    sceneToScreen(v1), sceneToScreen(v2), sceneToScreen(v3)};
+                const QPointF c(
+                    (pts[0].x() + pts[1].x() + pts[2].x()) / 3.f,
+                    (pts[0].y() + pts[1].y() + pts[2].y()) / 3.f);
+                p.drawText(c, QString::number(iT));
+            }
         }
         // constraint edges
         pen.setColor(QColor(50, 50, 50));
@@ -340,7 +372,18 @@
         p.setPen(pen);
         for(std::size_t i = 0; i < m_cdt.vertices.size(); ++i)
         {
-            p.drawPoint(sceneToScreen(m_cdt.vertices[i]));
+            const QPointF pos = sceneToScreen(m_cdt.vertices[i]);
+            p.drawPoint(pos);
+        }
+        if(m_isDisplayIndices)
+        {
+            pen.setColor(QColor(100, 100, 255));
+            p.setPen(pen);
+            for(std::size_t i = 0; i < m_cdt.vertices.size(); ++i)
+            {
+                const QPointF pos = sceneToScreen(m_cdt.vertices[i]);
+                p.drawText(pos, QString::number(i));
+            }
         }
         // last added point
         if(m_ptLimit <= m_points.size())
@@ -407,6 +450,7 @@
     bool m_isHideSuperTri;
     bool m_isRemoveOuter;
     bool m_isRemoveOuterAndHoles;
+    bool m_isDisplayIndices;

     QPointF m_prevMousePos;
     QPointF m_translation;
@@ -450,6 +494,16 @@
             SLOT(setEdgeLimit(int)));
         edgesSpinbox->setValue(999999);

+        QCheckBox* displayIndices =
+            new QCheckBox(QStringLiteral("Display point/triangle indices"));
+        connect(
+            displayIndices,
+            SIGNAL(stateChanged(int)),
+            m_cdtWidget,
+            SLOT(displayIndices(int)));
+        m_cdtWidget->displayIndices(0);
+        displayIndices->setChecked(false);
+
         QCheckBox* conformToEdges =
             new QCheckBox(QStringLiteral("Conform to fixed edges"));
         connect(
@@ -512,6 +566,7 @@
         rightLayout->addWidget(filesList, cntr++, 0);
         rightLayout->addWidget(ptsSpinbox, cntr++, 0);
         rightLayout->addWidget(edgesSpinbox, cntr++, 0);
+        rightLayout->addWidget(displayIndices, cntr++, 0);
         rightLayout->addWidget(conformToEdges, cntr++, 0);
         rightLayout->addWidget(hidePoints, cntr++, 0);
         rightLayout->addWidget(removeOuter, cntr++, 0);


tests/type_tests: TIME type test cases

tests/type_tests: TIME type test cases

--- tests/types_test.cc
+++ tests/types_test.cc
@@ -165,6 +165,34 @@
     test_parsing_fails(simple_date_type, "something");
     test_parsing_fails(simple_date_type, "-5877641-06-22");
     test_parsing_fails(simple_date_type, "5881580-07-12");
+}
+
+BOOST_AUTO_TEST_CASE(test_time_type_string_conversions) {
+    BOOST_REQUIRE(time_type->equal(time_type->from_string("12:34:56"), time_type->decompose(int64_t(45296000000000))));
+    BOOST_REQUIRE_EQUAL(time_type->to_string(time_type->decompose(int64_t(45296000000000))), "12:34:56.000000000");
+
+    BOOST_REQUIRE(time_type->equal(time_type->from_string("12:34:56.000000000"), time_type->decompose(int64_t(45296000000000))));
+    BOOST_REQUIRE_EQUAL(time_type->to_string(time_type->decompose(int64_t(45296000000000))), "12:34:56.000000000");
+
+    BOOST_REQUIRE(time_type->equal(time_type->from_string("12:34:56.123456789"), time_type->decompose(int64_t(45296123456789))));
+    BOOST_REQUIRE_EQUAL(time_type->to_string(time_type->decompose(int64_t(45296123456789))), "12:34:56.123456789");
+
+    BOOST_REQUIRE(time_type->equal(time_type->from_string("00:00:00.000000000"), time_type->decompose(int64_t(0x00000000))));
+    BOOST_REQUIRE_EQUAL(time_type->to_string(time_type->decompose(int64_t(0x00000000))), "00:00:00.000000000");
+
+    BOOST_REQUIRE(time_type->equal(time_type->from_string("23:59:59.999999999"), time_type->decompose(int64_t(86399999999999))));
+    BOOST_REQUIRE_EQUAL(time_type->to_string(time_type->decompose(int64_t(86399999999999))), "23:59:59.999999999");
+
+    BOOST_REQUIRE(time_type->equal(time_type->from_string("-00:00:00.000000000"), time_type->decompose(int64_t(0x00000000))));
+    BOOST_REQUIRE(time_type->equal(time_type->from_string("-00:00:00.000000001"), time_type->decompose(int64_t(0x00000001))));
+
+    test_parsing_fails(time_type, "something");
+    test_parsing_fails(time_type, "00:00");
+    test_parsing_fails(time_type, "24:00:00.000000000");
+    test_parsing_fails(time_type, "-01:00:00.0000000000");
+    test_parsing_fails(time_type, "00:-01:00.0000000000");
+    test_parsing_fails(time_type, "00:00:-10.0000000000");
+    test_parsing_fails(time_type, "00:00:00.-0000000001");
 }

 BOOST_AUTO_TEST_CASE(test_uuid_type_comparison) {


changes

changes

--- src/qt/aboutdialog.cpp
+++ src/qt/aboutdialog.cpp
@@ -6,7 +6,7 @@

 // Copyright year (2009-this)
 // Todo: update this when changing our copyright comments in the source
-const int ABOUTDIALOG_COPYRIGHT_YEAR = 2013;
+const int ABOUTDIALOG_COPYRIGHT_YEAR = 2014;

 AboutDialog::AboutDialog(QWidget *parent) :
     QDialog(parent),
@@ -15,7 +15,7 @@
     ui->setupUi(this);

     // Set current copyright year
-    ui->copyrightLabel->setText(tr("Copyright") + QString(" © 2009-%1 ").arg(COPYRIGHT_YEAR) + tr("The Bitcoin developers") + QString("
") + tr("Copyright") + QString(" © ") + tr("2011-%1 The Gaelcoin developers").arg(ABOUTDIALOG_COPYRIGHT_YEAR));
+    ui->copyrightLabel->setText(tr("Copyright") + QString(" © 2009-%1 ").arg(COPYRIGHT_YEAR) + tr("The Bitcoin developers") + QString("
") + tr("Copyright") + QString(" © ") + tr("2014 The Gaelcoin developers").arg(ABOUTDIALOG_COPYRIGHT_YEAR));
 }

 void AboutDialog::setModel(ClientModel *model)


Fix bug with loopback interfaces netmask (#110)

allow more than /32 addresses on the loopback

--- src/netlink/nl_l3.cpp
+++ src/netlink/nl_l3.cpp
@@ -82,7 +82,7 @@

   struct rtnl_link *link = rtnl_addr_get_link(a);
   if (link == nullptr) {
-    LOG(ERROR) << __FUNCTION__ << ": no link for addr a=" << a;
+    LOG(ERROR) << __FUNCTION__ << ": no link for addr a=" << OBJ_CAST(a);
     return -EINVAL;
   }

@@ -119,14 +119,21 @@
   }

   // get v4 dst (local v4 addr)
+  auto prefixlen = rtnl_addr_get_prefixlen(a);
   auto addr = rtnl_addr_get_local(a);
   rofl::caddress_in4 ipv4_dst = libnl_in4addr_2_rofl(addr);

-  rv = sw->l3_unicast_host_add(ipv4_dst,
-                               0); // TODO likely move this to separate entity
-  if (rv < 0) {
-    // TODO shall we remove the l3_termination mac?
-    LOG(ERROR) << __FUNCTION__ << ": failed to setup l3 addr " << addr;
+  if (is_loopback && prefixlen != 32) {
+    rofl::caddress_in4 mask = rofl::build_mask_in4(prefixlen);
+    rv = sw->l3_unicast_route_add(ipv4_dst, mask, 0);
+    return rv;
+  } else {
+    rv = sw->l3_unicast_host_add(ipv4_dst,
+                                 0); // TODO likely move this to separate entity
+    if (rv < 0) {
+      // TODO shall we remove the l3_termination mac?
+      LOG(ERROR) << __FUNCTION__ << ": failed to setup l3 addr " << addr;
+    }
   }

   if (!is_loopback) {


fix coin lock persisting through shutdown

--- src/qt/walletmodel.cpp
+++ src/qt/walletmodel.cpp
@@ -457,7 +457,7 @@
 {
     wallet->lockedcoins.vLockedCoins.push_back(outpoint);
 	CWalletDB walletdb(wallet->strWalletFile);
-
+	walletdb.WriteLockedCoins(wallet->lockedcoins);
 	return;
 }


Fix broken lo (#111)

Fix broken lo (#111)

--- src/netlink/nl_l3.cpp
+++ src/netlink/nl_l3.cpp
@@ -138,10 +138,10 @@
   rofl::caddress_in4 ipv4_dst = libnl_in4addr_2_rofl(addr);

   if (is_loopback) {
-    std::unique_ptr<nl_addr, decltype(&nl_addr_put)> lo_addr(nl_addr_alloc(255),
+    auto p = nl_addr_alloc(255);
+    nl_addr_parse("127.0.0.0/8", AF_INET, &p);
+    std::unique_ptr<nl_addr, decltype(&nl_addr_put)> lo_addr(p,
                                                              nl_addr_put);
-    auto p = lo_addr.get();
-    nl_addr_parse("127.0.0.0/8", AF_INET, &p);

     if (!nl_addr_cmp_prefix(addr, lo_addr.get())) {
       VLOG(3) << __FUNCTION__ << ": skipping 127.0.0.0/8";


[Qt] add missing lock in walletmodel

[Qt] add missing lock in walletmodel

--- src/qt/walletmodel.cpp
+++ src/qt/walletmodel.cpp
@@ -488,6 +488,7 @@
 // returns a list of COutputs from COutPoints
 void WalletModel::getOutputs(const std::vector<COutPoint>& vOutpoints, std::vector<COutput>& vOutputs)
 {
+    LOCK(wallet->cs_wallet);
     BOOST_FOREACH(const COutPoint& outpoint, vOutpoints)
     {
         if (!wallet->mapWallet.count(outpoint.hash)) continue;


mark MintOnly as false if wallet gets locked

--- src/qt/walletmodel.cpp
+++ src/qt/walletmodel.cpp
@@ -286,6 +286,7 @@
     if(locked)
     {
         // Lock
+		wallet->fWalletUnlockMintOnly = false;
         return wallet->Lock();
     }
     else


INTEGRATION: CWS presfixes12 (1.6.12); FILE MERGED
2007/01/29 14:01:57 thb 1.6.12.1: Issue number: #i37778#

Larger slideshow refactoring. Wrote design and coding style manifest,
and adapted the code to actually conform to this. In detail:
 - cleaned up ownership/disposable/weak_ptr story. removed hacks and
   explicit Disposable implementations, where workaround were available
 - removed object mutices, where superfluous
 - reworked EventMultiplexer (using templatized listener class now), added
   more events. EventMultiplexer now serves as a true blackboard
 - reworked directory structure: disjunct parts are now physically separated
   into directories, instantiation happens via factories & abstract interfaces
 - added CursorManager, to make setting mouse cursor less hackish
 - reworked DrawShape, to implement SeparateListener pattern
 - reworked IntrinsicAnimationActivity, to avoid cyclic references
 - modified hyperlink & shape cursor handling to communicate via
   EventMultiplexer
 - renamed & cleaned up files (presentation.cxx now named slideshowimpl.cxx,
   etc.)
 - added first version of the z-order fix to layer/layermanager
 - cleaned up include guards and include syntax

--- slideshow/source/engine/smilfunctionparser.cxx
+++ slideshow/source/engine/smilfunctionparser.cxx
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: smilfunctionparser.cxx,v $
  *
- *  $Revision: 1.6 $
- *
- *  last change: $Author: kz $ $Date: 2006-12-13 15:20:39 $
+ *  $Revision: 1.7 $
+ *
+ *  last change: $Author: obo $ $Date: 2007-07-17 14:41:21 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -38,11 +38,7 @@

 // must be first
 #include <canvas/debug.hxx>
-
-#ifndef  _USE_MATH_DEFINES
-#define  _USE_MATH_DEFINES  // needed by Visual C++ for math constants
-#endif
-#include <math.h>           // M_PI definition
+#include <math.h>

 #include <smilfunctionparser.hxx>
 #include <expressionnodefactory.hxx>


ect fix <n>

ect fix <n>

--- vowpalwabbit/ect.cc
+++ vowpalwabbit/ect.cc
@@ -162,8 +162,7 @@

   bool last(size_t tournament, v_array<size_t> round)
   {//previous tournament is ending.
-    return round[tournament] == 2
-      && (tournament == 0 || round[tournament-1] == 0);
+    return round[tournament] == 2 && (tournament == 0 || round[tournament -1] == 0);
   }

   size_t get_transfers(size_t tournament, v_array<size_t> round)
@@ -185,15 +184,18 @@

     if (current.label <= num_transfers)
       {
-	current.tournament--;
 	if (last(current.tournament-1, tournament_counts[current.level-2]))
 	  ; //label stays unchanged because it was from the last round in the previous tournament.
 	else //label was from loser of previous tournament
 	  current.label = (current.label - 1) * 2 + (right_wins ? 0 : 1) + 1;
+	current.tournament--;
       }
     else//label was from winner of current tournament
       current.label = (current.label - 1 - num_transfers) * 2 + (right_wins ? 1 : 0) + 1;
     current.level--;
+    assert(current.label >= 1);
+    assert(current.label <= (size_t)k);
+    assert(current.tournament <= errors);
   }

   void leaf_to_root(node& current, bool right_wins)


fix deadlock and add detector to CNodeStateAccessor

--- src/requestManager.cpp
+++ src/requestManager.cpp
@@ -217,21 +217,34 @@

     // This is block and peer that was selected in FindNextBlocksToDownload() so we want to add it as a block
     // source first so that it gets requested first.
-    LOCK(cs_objDownloader);
     if (from)
         AskFor(objArray, from, priority);

+    // We can't hold cs_vNodes in the for loop below because it is out of order with cs_objDownloader which is
+    // taken in ProcessBlockAvailability.  We can't take cs_objDownloader earlier because it deadlocks with the
+    // CNodeStateAccessor. So make a copy of vNodes here
+    std::vector<CNode *> vNodesCopy;
+
+    {
+        LOCK(cs_vNodes);
+        vNodesCopy = vNodes;
+        for (CNode *pnode : vNodesCopy)
+        {
+            pnode->AddRef();
+        }
+    }
+
+
     // Add the other peers as potential sources in the event the RequestManager needs to make a re-request
     // for this block. Only add NETWORK nodes that have block availability.
-    LOCK(cs_vNodes);
-    for (CNode *pnode : vNodes)
-    {
-        // skip the peer we added above
-        if (pnode == from)
+    for (CNode *pnode : vNodesCopy)
+    {
+        // skip the peer we added above and skip non NETWORK nodes
+        if ((pnode == from) || (pnode->fClient))
+        {
+            pnode->Release();
             continue;
-        // skip non NETWORK nodes
-        if (pnode->fClient)
-            continue;
+        }

         // Make sure pindexBestKnownBlock is up to date.
         ProcessBlockAvailability(pnode->id);
@@ -246,6 +259,7 @@
                 AskFor(objArray, pnode, priority);
             }
         }
+        pnode->Release(); // Release the refs we took
     }
 }