Implement SimplifyCFG/switch_switch_fold.ll
This case occurs many times in various benchmarks, especially when combined
with the previous patch.  This allows it to get stuff like:
  if (X == 4 || X == 3)
    if (X == 5 || X == 8)

and

switch (X) {
case 4: case 5: case 6:
  if (X == 4 || X == 5)

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@11797 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Transforms/Utils/SimplifyCFG.cpp
+++ lib/Transforms/Utils/SimplifyCFG.cpp
@@ -18,6 +18,7 @@
 #include "llvm/Support/CFG.h"
 #include <algorithm>
 #include <functional>
+#include <set>
 using namespace llvm;

 // PropagatePredecessorsForPHIs - This gets "Succ" ready to have the
@@ -286,6 +287,47 @@
   }
 }

+/// SafeToMergeTerminators - Return true if it is safe to merge these two
+/// terminator instructions together.
+///
+static bool SafeToMergeTerminators(TerminatorInst *SI1, TerminatorInst *SI2) {
+  if (SI1 == SI2) return false;  // Can't merge with self!
+
+  // It is not safe to merge these two switch instructions if they have a common
+  // successor, and if that successor has a PHI node, and if that PHI node has
+  // conflicting incoming values from the two switch blocks.
+  BasicBlock *SI1BB = SI1->getParent();
+  BasicBlock *SI2BB = SI2->getParent();
+  std::set<BasicBlock*> SI1Succs(succ_begin(SI1BB), succ_end(SI1BB));
+
+  for (succ_iterator I = succ_begin(SI2BB), E = succ_end(SI2BB); I != E; ++I)
+    if (SI1Succs.count(*I))
+      for (BasicBlock::iterator BBI = (*I)->begin();
+           PHINode *PN = dyn_cast<PHINode>(BBI); ++BBI)
+        if (PN->getIncomingValueForBlock(SI1BB) !=
+            PN->getIncomingValueForBlock(SI2BB))
+          return false;
+
+  return true;
+}
+
+/// AddPredecessorToBlock - Update PHI nodes in Succ to indicate that there will
+/// now be entries in it from the 'NewPred' block.  The values that will be
+/// flowing into the PHI nodes will be the same as those coming in from
+/// ExistPred, and existing predecessor of Succ.
+static void AddPredecessorToBlock(BasicBlock *Succ, BasicBlock *NewPred,
+                                  BasicBlock *ExistPred) {
+  assert(std::find(succ_begin(ExistPred), succ_end(ExistPred), Succ) !=
+         succ_end(ExistPred) && "ExistPred is not a predecessor of Succ!");
+  if (!isa<PHINode>(Succ->begin())) return; // Quick exit if nothing to do
+
+  for (BasicBlock::iterator I = Succ->begin();
+       PHINode *PN = dyn_cast<PHINode>(I); ++I) {
+    Value *V = PN->getIncomingValueForBlock(ExistPred);
+    PN->addIncoming(V, NewPred);
+  }
+}
+
 // SimplifyCFG - This function is used to do simplification of a CFG.  For
 // example, it adjusts branches to branches to eliminate the extra hop, it
 // eliminates unreachable basic blocks, and does other "peephole" optimization
@@ -302,7 +344,8 @@
   assert(&BB->getParent()->front() != BB && "Can't Simplify entry block!");

   // Remove basic blocks that have no predecessors... which are unreachable.
-  if (pred_begin(BB) == pred_end(BB)) {
+  if (pred_begin(BB) == pred_end(BB) ||
+      *pred_begin(BB) == BB && ++pred_begin(BB) == pred_end(BB)) {
     //cerr << "Removing BB: \n" << BB;

     // Loop through all of our successors and make sure they know that one
@@ -439,7 +482,6 @@
           // We know there are no successors, so just nuke the block.
           M->getBasicBlockList().erase(BB);

-
         return true;
       }
     }
@@ -470,6 +512,112 @@

       Preds.pop_back();
     }
+  } else if (SwitchInst *SI = dyn_cast<SwitchInst>(BB->begin())) {
+    // If the only instruction in this block is a switch instruction, see if we
+    // can fold the switch instruction into a switch in a predecessor block.
+    std::vector<BasicBlock*> Preds(pred_begin(BB), pred_end(BB));
+    while (!Preds.empty()) {
+      BasicBlock *Pred = Preds.back();
+      Preds.pop_back();
+
+      // If the two blocks are switching on the same value, we can merge this
+      // switch into the predecessor's switch.
+      if (SwitchInst *PSI = dyn_cast<SwitchInst>(Pred->getTerminator()))
+        if (PSI->getCondition() == SI->getCondition() &&
+            SafeToMergeTerminators(SI, PSI)) {
+          // Figure out which 'cases' to copy from SI to PSI.
+          std::vector<std::pair<Constant*, BasicBlock*> > Cases;
+          BasicBlock *NewDefault = 0;
+          if (PSI->getDefaultDest() == BB) {
+            // If this is the default destination from PSI, only the edges in SI
+            // that don't occur in PSI, or that branch to BB will be activated.
+            std::set<Constant*> PSIHandled;
+            for (unsigned i = 1, e = PSI->getNumSuccessors(); i != e; ++i)
+              if (PSI->getSuccessor(i) != BB)
+                PSIHandled.insert(PSI->getCaseValue(i));
+              else {
+                // This entry will be replaced.
+                PSI->removeCase(i);
+                --i; --e;
+              }
+
+            NewDefault = SI->getDefaultDest();
+            for (unsigned i = 1, e = SI->getNumSuccessors(); i != e; ++i) {
+              Constant *C = SI->getCaseValue(i);
+              if (!PSIHandled.count(C))
+                Cases.push_back(std::make_pair(C, SI->getSuccessor(i)));
+            }
+
+          } else {
+            // If this is not the default destination from PSI, only the edges
+            // in SI that occur in PSI with a destination of BB will be
+            // activated.
+            std::set<Constant*> PSIHandled;
+            for (unsigned i = 1, e = PSI->getNumSuccessors(); i != e; ++i)
+              if (PSI->getSuccessor(i) == BB) {
+                // We know that BB doesn't have any PHI nodes in it, so just
+                // drop the edges.
+                PSIHandled.insert(PSI->getCaseValue(i));
+                PSI->removeCase(i);
+                --i; --e;
+              }
+
+            // Okay, now we know which constants were sent to BB from the
+            // predecessor.  Figure out where they will all go now.
+            for (unsigned i = 1, e = SI->getNumSuccessors(); i != e; ++i) {
+              Constant *C = SI->getCaseValue(i);
+              if (PSIHandled.count(C)) {
+                // If this is one we are capable of getting...
+                Cases.push_back(std::make_pair(C, SI->getSuccessor(i)));
+                PSIHandled.erase(C);         // This constant is taken care of
+              }
+            }
+
+            // If there are any constants vectored to BB that SI doesn't handle,
+            // they must go to the default destination of SI.
+            for (std::set<Constant*>::iterator I = PSIHandled.begin(),
+                   E = PSIHandled.end(); I != E; ++I)
+              Cases.push_back(std::make_pair(*I, SI->getDefaultDest()));
+          }
+
+          // Okay, at this point, we know which cases need to be added to the
+          // PSI switch and which destinations they go to.  If PSI needs its
+          // default destination changed, NewDefault is set.  Start changing
+          // stuff now.
+          if (NewDefault) {
+            AddPredecessorToBlock(NewDefault, Pred, BB);
+            PSI->setSuccessor(0, NewDefault);
+          }
+
+          // Okay, add all of the cases now.
+          for (unsigned i = 0, e = Cases.size(); i != e; ++i) {
+            AddPredecessorToBlock(Cases[i].second, Pred, BB);
+            PSI->addCase(Cases[i].first, Cases[i].second);
+          }
+
+          // Okay, last check.  If BB is still a successor of PSI, then we must
+          // have an infinite loop case.  If so, add an infinitely looping block
+          // to handle the case to preserve the behavior of the code.
+          BasicBlock *InfLoopBlock = 0;
+          for (unsigned i = 0, e = PSI->getNumSuccessors(); i != e; ++i)
+            if (PSI->getSuccessor(i) == BB) {
+              if (InfLoopBlock == 0) {
+                // Insert it at the end of the loop, because it's either code,
+                // or it won't matter if it's hot. :)
+                InfLoopBlock = new BasicBlock("infloop", BB->getParent());
+                new BranchInst(InfLoopBlock, InfLoopBlock);
+              }
+              PSI->setSuccessor(i, InfLoopBlock);
+            }
+
+          Changed = true;
+        }
+    }
+
+    // If we removed all predecessors of this block, recursively call
+    // SimplifyCFG to remove it.
+    if (pred_begin(BB) == pred_end(BB))
+      return SimplifyCFG(BB);
   }

   // Merge basic blocks into their predecessor if there is only one distinct


detail::connection::socket() returns a reference.

--- src/daemon/remcon.hpp
+++ src/daemon/remcon.hpp
@@ -18,7 +18,7 @@
 			return std::make_shared<connection>(std::forward(socket));
 		}

-		boost::asio::local::stream_protocol::socket socket();
+		boost::asio::local::stream_protocol::socket& socket();

 		void queue_write(const std::string& msg);


removed warnings from agrad/matrix.hpp

removed warnings from agrad/matrix.hpp

--- src/stan/agrad/matrix.hpp
+++ src/stan/agrad/matrix.hpp
@@ -744,8 +744,7 @@
     inline Eigen::Matrix<var,1,C>
     columns_dot_self(const Eigen::Matrix<var,R,C>& x) {
       Eigen::Matrix<var,1,C> ret(1,x.cols());
-      size_t i;
-      for (i = 0; i < x.cols(); i++) {
+      for (size_type i = 0; i < x.cols(); i++) {
         ret(i) = var(new dot_self_vari(x.col(i)));
       }
       return ret;
@@ -1166,17 +1165,15 @@
       _variRefA(A.rows(),A.cols()), _variRefB(B.rows(),B.cols()),
       _variRefC(B.rows(),B.cols())
       {
-        size_t i,j;
-
-        for (j = 0; j < _variRefA.cols(); j++) {
-          for (i = 0; i < _variRefA.rows(); i++) {
+        for (size_type j = 0; j < _variRefA.cols(); j++) {
+          for (size_type i = 0; i < _variRefA.rows(); i++) {
             _variRefA(i,j) = A(i,j).vi_;
             _A(i,j) = A(i,j).val();
           }
         }

-        for (j = 0; j < _variRefB.cols(); j++) {
-          for (i = 0; i < _variRefB.rows(); i++) {
+        for (size_type j = 0; j < _variRefB.cols(); j++) {
+          for (size_type i = 0; i < _variRefB.rows(); i++) {
             _variRefB(i,j) = B(i,j).vi_;
             _C(i,j) = B(i,j).val();
           }
@@ -1184,8 +1181,8 @@

         _C = _A.template triangularView<TriView>().solve(_C);

-        for (j = 0; j < _variRefC.cols(); j++) {
-          for (i = 0; i < _variRefC.rows(); i++) {
+        for (size_type j = 0; j < _variRefC.cols(); j++) {
+          for (size_type i = 0; i < _variRefC.rows(); i++) {
             _variRefC(i,j) = new vari(_C(i,j),false);
           }
         }
@@ -1196,9 +1193,8 @@
         Eigen::Matrix<double,R2,C2> adjB(_variRefB.rows(),_variRefB.cols());
         Eigen::Matrix<double,R1,C2> adjC(_variRefC.rows(),_variRefC.cols());

-        size_t i,j;
-        for (j = 0; j < adjC.cols(); j++)
-          for (i = 0; i < adjC.rows(); i++)
+        for (size_type j = 0; j < adjC.cols(); j++)
+          for (size_type i = 0; i < adjC.rows(); i++)
             adjC(i,j) = _variRefC(i,j)->adj_;

@@ -1206,21 +1202,21 @@
         adjA.noalias() = -adjB*_C.transpose();

         if (TriView == Eigen::Lower) {
-          for (j = 0; j < adjA.cols(); j++)
-            for (i = j; i < adjA.rows(); i++)
+          for (size_type j = 0; j < adjA.cols(); j++)
+            for (size_type i = j; i < adjA.rows(); i++)
               _variRefA(i,j)->adj_ += adjA(i,j);
         }
         else if (TriView == Eigen::Upper) {
-          for (j = 0; j < adjA.cols(); j++)
-            for (i = 0; i < j+1; i++)
+          for (size_type j = 0; j < adjA.cols(); j++)
+            for (size_type i = 0; i < j+1; i++)
               _variRefA(i,j)->adj_ += adjA(i,j);
         }
         else {
           assert(TriView == Eigen::Lower || TriView == Eigen::Upper);
         }

-        for (j = 0; j < adjB.cols(); j++)
-          for (i = 0; i < adjB.rows(); i++)
+        for (size_type j = 0; j < adjB.cols(); j++)
+          for (size_type i = 0; i < adjB.rows(); i++)
             _variRefB(i,j)->adj_ += adjB(i,j);
       }
     };
@@ -1240,10 +1236,8 @@
       _A(A), _C(B.rows(),B.cols()),
       _variRefB(B.rows(),B.cols()), _variRefC(B.rows(),B.cols())
       {
-        size_t i,j;
-
-        for (j = 0; j < _variRefB.cols(); j++) {
-          for (i = 0; i < _variRefB.rows(); i++) {
+        for (size_type j = 0; j < _variRefB.cols(); j++) {
+          for (size_type i = 0; i < _variRefB.rows(); i++) {
             _variRefB(i,j) = B(i,j).vi_;
             _C(i,j) = B(i,j).val();
           }
@@ -1251,8 +1245,8 @@

         _C = _A.template triangularView<TriView>().solve(_C);

-        for (j = 0; j < _variRefC.cols(); j++) {
-          for (i = 0; i < _variRefC.rows(); i++) {
+        for (size_type j = 0; j < _variRefC.cols(); j++) {
+          for (size_type i = 0; i < _variRefC.rows(); i++) {
             _variRefC(i,j) = new vari(_C(i,j),false);
           }
         }
@@ -1262,16 +1256,15 @@
         Eigen::Matrix<double,R2,C2> adjB(_variRefB.rows(),_variRefB.cols());
         Eigen::Matrix<double,R1,C2> adjC(_variRefC.rows(),_variRefC.cols());

-        size_t i,j;
-        for (j = 0; j < adjC.cols(); j++)
-          for (i = 0; i < adjC.rows(); i++)
+        for (size_type j = 0; j < adjC.cols(); j++)
+          for (size_type i = 0; i < adjC.rows(); i++)
             adjC(i,j) = _variRefC(i,j)->adj_;

         adjB = _A.template triangularView<TriView>().transpose().solve(adjC);

-        for (j = 0; j < adjB.cols(); j++)
-          for (i = 0; i < adjB.rows(); i++)
+        for (size_type j = 0; j < adjB.cols(); j++)
+          for (size_type i = 0; i < adjB.rows(); i++)
             _variRefB(i,j)->adj_ += adjB(i,j);
       }
     };
@@ -1291,10 +1284,8 @@
       _A(A.rows(),A.cols()), _C(B.rows(),B.cols()),
       _variRefA(A.rows(),A.cols()), _variRefC(B.rows(),B.cols())
       {
-        size_t i,j;
-
-        for (j = 0; j < _variRefA.cols(); j++) {
-          for (i = 0; i < _variRefA.rows(); i++) {
+        for (size_type j = 0; j < _variRefA.cols(); j++) {
+          for (size_type i = 0; i < _variRefA.rows(); i++) {
             _variRefA(i,j) = A(i,j).vi_;
             _A(i,j) = A(i,j).val();
           }
@@ -1302,8 +1293,8 @@

         _C = _A.template triangularView<TriView>().solve(B);

-        for (j = 0; j < _variRefC.cols(); j++) {
-          for (i = 0; i < _variRefC.rows(); i++) {
+        for (size_type j = 0; j < _variRefC.cols(); j++) {
+          for (size_type i = 0; i < _variRefC.rows(); i++) {
             _variRefC(i,j) = new vari(_C(i,j),false);
           }
         }
@@ -1313,22 +1304,21 @@
         Eigen::Matrix<double,R1,C1> adjA(_variRefA.rows(),_variRefA.cols());
         Eigen::Matrix<double,R1,C2> adjC(_variRefC.rows(),_variRefC.cols());

-        size_t i,j;
-        for (j = 0; j < adjC.cols(); j++)
-          for (i = 0; i < adjC.rows(); i++)
+        for (size_type j = 0; j < adjC.cols(); j++)
+          for (size_type i = 0; i < adjC.rows(); i++)
             adjC(i,j) = _variRefC(i,j)->adj_;

         adjA.noalias() = -_A.template triangularView<TriView>().transpose().solve(adjC*_C.transpose());

         if (TriView == Eigen::Lower) {
-          for (j = 0; j < adjA.cols(); j++)
-            for (i = j; i < adjA.rows(); i++)
+          for (size_type j = 0; j < adjA.cols(); j++)
+            for (size_type i = j; i < adjA.rows(); i++)
               _variRefA(i,j)->adj_ += adjA(i,j);
         }
         else if (TriView == Eigen::Upper) {
-          for (j = 0; j < adjA.cols(); j++)
-            for (i = 0; i < j+1; i++)
+          for (size_type j = 0; j < adjA.cols(); j++)
+            for (size_type i = 0; i < j+1; i++)
               _variRefA(i,j)->adj_ += adjA(i,j);
         }
         else {
@@ -1352,10 +1342,8 @@
       // for the returned matrix.  Memory will be cleaned up with the arena allocator.
       mdivide_left_tri_vv_vari<TriView,R1,C1,R2,C2> *baseVari = new mdivide_left_tri_vv_vari<TriView,R1,C1,R2,C2>(A,b);

-      size_t i,j;
-
-      for (i = 0; i < res.rows(); i++)
-        for (j = 0; j < res.cols(); j++)
+      for (size_type i = 0; i < res.rows(); i++)
+        for (size_type j = 0; j < res.cols(); j++)
           res(i,j).vi_ = baseVari->_variRefC(i,j);

       return res;
@@ -1375,10 +1363,8 @@
       // for the returned matrix.  Memory will be cleaned up with the arena allocator.
       mdivide_left_tri_dv_vari<TriView,R1,C1,R2,C2> *baseVari = new mdivide_left_tri_dv_vari<TriView,R1,C1,R2,C2>(A,b);

-      size_t i,j;
-
-      for (i = 0; i < res.rows(); i++)
-        for (j = 0; j < res.cols(); j++)
+      for (size_type i = 0; i < res.rows(); i++)
+        for (size_type j = 0; j < res.cols(); j++)
           res(i,j).vi_ = baseVari->_variRefC(i,j);

       return res;
@@ -1398,10 +1384,8 @@
       // for the returned matrix.  Memory will be cleaned up with the arena allocator.
       mdivide_left_tri_vd_vari<TriView,R1,C1,R2,C2> *baseVari = new mdivide_left_tri_vd_vari<TriView,R1,C1,R2,C2>(A,b);

-      size_t i,j;
-
-      for (i = 0; i < res.rows(); i++)
-        for (j = 0; j < res.cols(); j++)
+      for (size_type i = 0; i < res.rows(); i++)
+        for (size_type j = 0; j < res.cols(); j++)
           res(i,j).vi_ = baseVari->_variRefC(i,j);

       return res;
@@ -1415,9 +1399,8 @@
       determinant_vari(const Eigen::Matrix<var,R,C> &A)
       : vari(determinant_vari_calc(A)), _A(A.rows(),A.cols()), _adjARef(A.rows(),A.cols())
       {
-        size_t i,j;
-        for (j = 0; j < A.cols(); j++) {
-          for (i = 0; i < A.rows(); i++) {
+        for (size_type j = 0; j < A.cols(); j++) {
+          for (size_type i = 0; i < A.rows(); i++) {
             _A(i,j) = A(i,j).val();
             _adjARef(i,j) = A(i,j).vi_;
           }
@@ -1427,18 +1410,16 @@
       double determinant_vari_calc(const Eigen::Matrix<var,R,C> &A)
       {
         Eigen::Matrix<double,R,C> Ad(A.rows(),A.cols());
-        size_t i,j;
-        for (j = 0; j < A.cols(); j++)
-          for (i = 0; i < A.rows(); i++)
+        for (size_type j = 0; j < A.cols(); j++)
+          for (size_type i = 0; i < A.rows(); i++)
             Ad(i,j) = A(i,j).val();
         return Ad.determinant();
       }
       virtual void chain() {
         Eigen::Matrix<double,R,C> adjA(_A.rows(),_A.cols());
-        size_t i,j;
         adjA = (adj_ * val_) * _A.inverse().transpose();
-        for (j = 0; j < _adjARef.cols(); j++) {
-          for (i = 0; i < _adjARef.rows(); i++) {
+        for (size_type j = 0; j < _adjARef.cols(); j++) {
+          for (size_type i = 0; i < _adjARef.rows(); i++) {
             _adjARef(i,j)->adj_ += adjA(i,j);
           }
         }


[sema] update indentation, remove unused index param, use getInterfaceType instead of getType

--- lib/Sema/TypeCheckDecl.cpp
+++ lib/Sema/TypeCheckDecl.cpp
@@ -3282,11 +3282,12 @@
     // If any of the function's parameters contain an uninhabited type
     // then emit a diagnostic on the func decl, as the function can never
     // be called.
-    auto params = FD->getParameters()->getArray();
-    for (auto &&index: indices(params)) {
-      auto param = params[index];
-      if (param->hasInterfaceType() && param->getType()->isStructurallyUninhabited()) {
-        TC.diagnose(FD->getLoc(), diag::function_parameter_type_uninhabited, FD->getName(), param->getName());
+    for (auto param : *FD->getParameters()) {
+      if (param->hasInterfaceType() &&
+          param->getInterfaceType()->isStructurallyUninhabited()) {
+        TC.diagnose(param->getLoc(),
+                    diag::function_parameter_type_uninhabited,
+                    FD->getName(), param->getName());
       }
     }


* inline trivial functions based on instruction count

--- src/scopes.cpp
+++ src/scopes.cpp
@@ -5218,6 +5218,10 @@
         return params[0]->is_typed();
     }

+    bool has_params() const {
+        return params.size() > 1;
+    }
+
     bool is_valid() const {
         return !params.empty() && body.anchor && !body.args.empty();
     }
@@ -6233,6 +6237,25 @@
     }

     return le;
+}
+
+static void fold_useless_labels(Label *l) {
+    auto &&enter = l->body.enter;
+    if (enter.type != TYPE_Label)
+        return;
+    if (!enter.label->is_basic_block_like())
+        return;
+    Label *newl = enter.label;
+    // eat as many useless labels as we can
+    while (newl->body.is_complete() &&
+        !newl->is_reentrant() && !newl->has_params()) {
+        l->body = newl->body;
+        if (enter.type != TYPE_Label)
+            break;
+        if (!enter.label->is_basic_block_like())
+            break;
+        newl = enter.label;
+    }
 }

 // inlining the arguments of an untyped scope (including continuation)
@@ -11059,10 +11082,6 @@
         verify(a.indirect_type(), b.indirect_type());
     }

-    static bool has_params(Label *l) {
-        return l->params.size() > 1;
-    }
-
     static bool has_keyed_args(Label *l) {
         auto &&args = l->body.args;
         for (size_t i = 1; i < args.size(); ++i) {
@@ -11396,25 +11415,6 @@
                 return false;
         }
         return true;
-    }
-
-    static void fold_useless_labels(Label *l) {
-        auto &&enter = l->body.enter;
-        if (enter.type != TYPE_Label)
-            return;
-        if (!enter.label->is_basic_block_like())
-            return;
-        Label *newl = enter.label;
-        // eat as many useless labels as we can
-        while (newl->body.is_complete() &&
-            !newl->is_reentrant() && !has_params(newl)) {
-            l->body = newl->body;
-            if (enter.type != TYPE_Label)
-                break;
-            if (!enter.label->is_basic_block_like())
-                break;
-            newl = enter.label;
-        }
     }

     enum FoldResult {
@@ -13038,6 +13038,39 @@
         return is_calling_continuation(l) || is_continuing_to_parameter(l);
     }

+    // label targets count as calls, all other as ops
+    static void count_instructions(Label *l, int &callcount, int &opcount) {
+        callcount = 0;
+        opcount = 0;
+        assert(!l->params.empty());
+        std::unordered_set<Label *> visited;
+        while (!is_exiting(l) && !visited.count(l)) {
+            visited.insert(l);
+            if (jumps_immediately(l)) {
+                l = l->body.enter.label;
+                continue;
+            }
+            if (is_calling_label(l) || is_calling_closure(l)) {
+                callcount++;
+            } else {
+                opcount++;
+            }
+            if (is_continuing_to_label(l)) {
+                l = l->body.args[0].value.label;
+                continue;
+            } else if (l->body.args[0].value.type == TYPE_Nothing) {
+                // branch, unreachable, etc.
+                break;
+            } else {
+                StyledStream ss(std::cerr);
+                ss << "internal warning: unexpected continuation type "
+                    << l->body.args[0].value.type
+                    << " encountered while counting instructions" << std::endl;
+                break;
+            }
+        }
+    }
+
     static bool is_trivial_function(Label *l) {
         assert(!l->params.empty());
         if (!isa<ReturnLabelType>(l->params[0]->type))
@@ -13046,6 +13079,11 @@
             // doesn't take any arguments
             return true;
         }
+#if 1
+        int callcount, opcount;
+        count_instructions(l, callcount, opcount);
+        return (callcount <= 4) && (opcount <= 1);
+#else
         assert(!l->params.empty());
         l = skip_jumps(l);
         if (is_exiting(l))
@@ -13056,6 +13094,7 @@
             if (is_exiting(l))
                 return true;
         }
+#endif
         return false;
     }

@@ -13338,7 +13377,7 @@
             l->body.set_complete();
             if (jumps_immediately(l)) {
                 Label *enter_label = l->get_label_enter();
-                if (!has_params(enter_label)) {
+                if (!enter_label->has_params()) {
 #if SCOPES_DEBUG_CODEGEN
                     stream_label(ss_cout, l, StreamLabelFormat::debug_single());
                     stream_label(ss_cout, enter_label, StreamLabelFormat::debug_single());


Fixed typo.

Fixed typo.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@278565 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Transforms/Utils/SimplifyCFG.cpp
+++ lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1539,7 +1539,7 @@
       continue;
     --MaxNumInstToLookAt;

-    // Could be calling an instruction that effects memory like free().
+    // Could be calling an instruction that affects memory like free().
     if (CurI.mayHaveSideEffects() && !isa<StoreInst>(CurI))
       return nullptr;


Cosmetics

Cosmetics

git-svn-id: acec3fd5b7ea1eb9e79d6329d318e8118ee2e14f@33968 27541ba8-7e3a-0410-8455-c3a389f83636

--- gui/guihtml/src/TGHtml.cxx
+++ gui/guihtml/src/TGHtml.cxx
@@ -1475,16 +1475,16 @@
       snprintf(name, 200, familyStr, size);

       // Get the named font
-      fAFont[iFont] = fClient->GetFont(name);\
+      fAFont[iFont] = fClient->GetFont(name);

       if (fAFont[iFont] == 0) {
          fprintf(stderr, "TGHtml: could not get font \"%s\", trying fixed\n",
-                      name);
+                 name);
          fAFont[iFont] = fClient->GetFont("fixed");
       }
-      if (fAFont[iFont]==0 ){
+      if (fAFont[iFont] == 0 ){
          fprintf(stderr, "TGHtml: could not get font \"fixed\", trying "
-                      "\"helvetica -12\"\n");
+                 "\"helvetica -12\"\n");
          fAFont[iFont] = fClient->GetFont("helvetica -12");
       }
       FontSetValid(iFont);


Update nanoFramework.Hardware.Esp32 version to 1.0.2-preview-015 ***NO_CI***

--- targets/FreeRTOS/ESP32_DevKitC/nanoCLR/nanoFramework.Hardware.ESP32/nanoFramework_hardware_esp32_native.cpp
+++ targets/FreeRTOS/ESP32_DevKitC/nanoCLR/nanoFramework.Hardware.ESP32/nanoFramework_hardware_esp32_native.cpp
@@ -70,5 +70,5 @@
     "nanoFramework.Hardware.Esp32",
     0xF8079179,
     method_lookup,
-    { 1, 0, 2, 12 }
+    { 1, 0, 2, 15 }
 };


Sema: DeclChecker::visitEnumElementDecl() does everything in the 'first pass'

--- lib/Sema/TypeCheckDecl.cpp
+++ lib/Sema/TypeCheckDecl.cpp
@@ -6183,12 +6183,12 @@

   void visitEnumElementDecl(EnumElementDecl *EED) {
     if (!IsFirstPass) {
-      checkAccessControl(TC, EED);
       return;
     }

     TC.validateDecl(EED);
     TC.checkDeclAttributes(EED);
+    checkAccessControl(TC, EED);
   }

   void visitExtensionDecl(ExtensionDecl *ED) {


Commented out useless include

Commented out useless include

git-svn-id: 6c2b1bd10c324c49ea9d9e6e31006a80e70507cb@816 5242fede-7e19-0410-aef8-94bd7d2200fb

--- doc/example.cpp
+++ doc/example.cpp
@@ -32,7 +32,7 @@
 #include <geos.h>
 #include <geos/opLinemerge.h>
 #include <geos/opPolygonize.h>
-#include <sstream>
+//#include <sstream>
 #include <iomanip>

 using namespace geos;
@@ -1065,6 +1065,9 @@

 /**********************************************************************
  * $Log$
+ * Revision 1.29  2005/07/11 12:17:26  strk
+ * Commented out useless include
+ *
  * Revision 1.28  2005/04/29 16:36:28  strk
  * Made WKBReader use global_factory, for having WKB reads produce
  * same context of input geoms.


fix maxfloat

fix maxfloat

--- raytracer/raytracer.cc
+++ raytracer/raytracer.cc
@@ -44,7 +44,7 @@

 vec3 color(const ray& r, hitable* world) {
     hit_record rec;
-    if (world->hit(r, 0.0, MAXFLOAT, rec)) {
+    if (world->hit(r, 0.0, FLT_MAX, rec)) {
         return 0.5 * (rec.normal + 1);
     } else {
         vec3 unit_direction = unit_vector(r.direction);


Begin: Tidying up code to make it more readable.

--- imgui.cpp
+++ imgui.cpp
@@ -4409,8 +4409,11 @@
     {
         // Initialize
         window->ParentWindow = parent_window;
-        window->RootWindow = ((flags & ImGuiWindowFlags_ChildWindow) && parent_window) ? parent_window->RootWindow : window;
-        window->RootNonPopupWindow = !(flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)) || (flags & ImGuiWindowFlags_Modal) || (parent_window == NULL) ? window : parent_window->RootNonPopupWindow; // Used to display TitleBgActive color and for selecting which window to use for NavWindowing
+        window->RootWindow = window->RootNonPopupWindow = window;
+        if (parent_window && (flags & ImGuiWindowFlags_ChildWindow))
+            window->RootWindow = parent_window->RootWindow;
+        if (parent_window && !(flags & ImGuiWindowFlags_Modal) && (flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)))
+            window->RootNonPopupWindow = parent_window->RootNonPopupWindow;
         //window->RootNavWindow = window;
         //while (window->RootNavWindow->Flags & ImGuiWindowFlags_NavFlattened)
         //    window->RootNavWindow = window->RootNavWindow->ParentWindow;


Spaces.

Spaces.

--- interpreter/llvm/src/tools/clang/lib/CodeGen/ModuleBuilder.cpp
+++ interpreter/llvm/src/tools/clang/lib/CodeGen/ModuleBuilder.cpp
@@ -270,7 +270,7 @@
     }

     void forgetGlobal(llvm::GlobalValue* GV) {
-      for(auto I = Builder->ConstantStringMap.begin(),
+      for (auto I = Builder->ConstantStringMap.begin(),
             E = Builder->ConstantStringMap.end(); I != E; ++I) {
         if (I->second == GV) {
           Builder->ConstantStringMap.erase(I);
@@ -278,7 +278,7 @@
         }
       }

-      for(auto I = Builder->DeferredDeclsToEmit.begin(),
+      for (auto I = Builder->DeferredDeclsToEmit.begin(),
              E = Builder->DeferredDeclsToEmit.end(); I != E; ++I) {
          if (I->GV == GV) {
           Builder->DeferredDeclsToEmit.erase(I);


Update script.cpp

Update script.cpp

--- src/script.cpp
+++ src/script.cpp
@@ -1,6 +1,7 @@
 // Copyright (c) 2009-2010 Satoshi Nakamoto
 // Copyright (c) 2009-2012 The Bitcoin developers
-// Copyright (c) 2012 The Pulse developers
+// Copyright (c) 2012 The Peercoin developers
+// Copyright (c) 2015 The Pulse developers
 // Distributed under the MIT/X11 software license, see the accompanying
 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
 #include <boost/foreach.hpp>


Add workaround full graphics rebuild if add elements

Issue #88

--- core/source/graphics/graphics.cpp
+++ core/source/graphics/graphics.cpp
@@ -3452,6 +3452,13 @@
 				cmzn_graphics_changed(graphics, CMZN_GRAPHICS_CHANGE_FULL_REBUILD);
 				return 1;
 			}
+			DsLabelsChangeLog *elementChangeLog = feRegionChanges->getElementChangeLog(domainDimension);
+			if (elementChangeLog->getChangeSummary() & DS_LABEL_CHANGE_TYPE_ADD)
+			{
+				// partial rebuild is buggy when new elements are added; workaround is to force full rebuild
+				cmzn_graphics_changed(graphics, CMZN_GRAPHICS_CHANGE_FULL_REBUILD);
+				return 1;
+			}
 			bool partialUpdate = (0 != (fieldChange & CMZN_FIELD_CHANGE_FLAG_PARTIAL_RESULT));
 			if (!partialUpdate)
 			{
@@ -3461,8 +3468,7 @@
 				// complexity of checking such a field is being used, so always partial update.
 				// Also for the future this allows us to send an identifiers all-change
 				// message if reclaimed memory from DsLabels and maps (all indexes changed).
-				DsLabelsChangeLog *elementChanges = feRegionChanges->getElementChangeLog(domainDimension);
-				if ((elementChanges) && (elementChanges->getChangeSummary() & DS_LABEL_CHANGE_TYPE_IDENTIFIER))
+				if (elementChangeLog->getChangeSummary() & DS_LABEL_CHANGE_TYPE_IDENTIFIER)
 					partialUpdate = true;
 			}
 			if (partialUpdate)
@@ -3474,7 +3480,6 @@
 					return 1;
 				}
 				feRegionChanges->propagateToDimension(domainDimension);
-				DsLabelsChangeLog *elementChangeLog = feRegionChanges->getElementChangeLog(domainDimension);
 				if (elementChangeLog->isAllChange() || (elementChangeLog->getChangeCount()*2 >
 					FE_region_find_FE_mesh_by_dimension(cmzn_region_get_FE_region(graphics->scene->region), domainDimension)->getSize()))
 				{


convert some methods to be static functions

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@121673 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Transforms/Utils/SimplifyCFG.cpp
+++ lib/Transforms/Utils/SimplifyCFG.cpp
@@ -41,11 +41,6 @@
 class SimplifyCFGOpt {
   const TargetData *const TD;

-  ConstantInt *GetConstantInt(Value *V);
-  Value *GatherConstantSetEQs(Value *V, std::vector<ConstantInt*> &Values);
-  Value *GatherConstantSetNEs(Value *V, std::vector<ConstantInt*> &Values);
-  bool GatherValueComparisons(Value *Cond, Value *&CompVal,
-                              std::vector<ConstantInt*> &Values);
   Value *isValueEqualityComparison(TerminatorInst *TI);
   BasicBlock *GetValueEqualityComparisonCases(TerminatorInst *TI,
     std::vector<std::pair<ConstantInt*, BasicBlock*> > &Cases);
@@ -268,7 +263,7 @@

 /// GetConstantInt - Extract ConstantInt from value, looking through IntToPtr
 /// and PointerNullValue. Return NULL if value is not a constant int.
-ConstantInt *SimplifyCFGOpt::GetConstantInt(Value *V) {
+static ConstantInt *GetConstantInt(Value *V, const TargetData *TD) {
   // Normal constant int.
   ConstantInt *CI = dyn_cast<ConstantInt>(V);
   if (CI || !TD || !isa<Constant>(V) || !V->getType()->isPointerTy())
@@ -299,24 +294,25 @@
 /// GatherConstantSetEQs - Given a potentially 'or'd together collection of
 /// icmp_eq instructions that compare a value against a constant, return the
 /// value being compared, and stick the constant into the Values vector.
-Value *SimplifyCFGOpt::
-GatherConstantSetEQs(Value *V, std::vector<ConstantInt*> &Values) {
+static Value *
+GatherConstantSetEQs(Value *V, std::vector<ConstantInt*> &Values,
+                     const TargetData *TD) {
   Instruction *Inst = dyn_cast<Instruction>(V);
   if (Inst == 0) return 0;

   if (Inst->getOpcode() == Instruction::ICmp &&
       cast<ICmpInst>(Inst)->getPredicate() == ICmpInst::ICMP_EQ) {
-    if (ConstantInt *C = GetConstantInt(Inst->getOperand(1))) {
+    if (ConstantInt *C = GetConstantInt(Inst->getOperand(1), TD)) {
       Values.push_back(C);
       return Inst->getOperand(0);
     }
-    if (ConstantInt *C = GetConstantInt(Inst->getOperand(0))) {
+    if (ConstantInt *C = GetConstantInt(Inst->getOperand(0), TD)) {
       Values.push_back(C);
       return Inst->getOperand(1);
     }
   } else if (Inst->getOpcode() == Instruction::Or) {
-    if (Value *LHS = GatherConstantSetEQs(Inst->getOperand(0), Values))
-      if (Value *RHS = GatherConstantSetEQs(Inst->getOperand(1), Values))
+    if (Value *LHS = GatherConstantSetEQs(Inst->getOperand(0), Values, TD))
+      if (Value *RHS = GatherConstantSetEQs(Inst->getOperand(1), Values, TD))
         if (LHS == RHS)
           return LHS;
   }
@@ -326,24 +322,25 @@
 /// GatherConstantSetNEs - Given a potentially 'and'd together collection of
 /// setne instructions that compare a value against a constant, return the value
 /// being compared, and stick the constant into the Values vector.
-Value *SimplifyCFGOpt::
-GatherConstantSetNEs(Value *V, std::vector<ConstantInt*> &Values) {
+static Value *
+GatherConstantSetNEs(Value *V, std::vector<ConstantInt*> &Values,
+                     const TargetData *TD) {
   Instruction *Inst = dyn_cast<Instruction>(V);
   if (Inst == 0) return 0;

   if (Inst->getOpcode() == Instruction::ICmp &&
              cast<ICmpInst>(Inst)->getPredicate() == ICmpInst::ICMP_NE) {
-    if (ConstantInt *C = GetConstantInt(Inst->getOperand(1))) {
+    if (ConstantInt *C = GetConstantInt(Inst->getOperand(1), TD)) {
       Values.push_back(C);
       return Inst->getOperand(0);
     }
-    if (ConstantInt *C = GetConstantInt(Inst->getOperand(0))) {
+    if (ConstantInt *C = GetConstantInt(Inst->getOperand(0), TD)) {
       Values.push_back(C);
       return Inst->getOperand(1);
     }
   } else if (Inst->getOpcode() == Instruction::And) {
-    if (Value *LHS = GatherConstantSetNEs(Inst->getOperand(0), Values))
-      if (Value *RHS = GatherConstantSetNEs(Inst->getOperand(1), Values))
+    if (Value *LHS = GatherConstantSetNEs(Inst->getOperand(0), Values, TD))
+      if (Value *RHS = GatherConstantSetNEs(Inst->getOperand(1), Values, TD))
         if (LHS == RHS)
           return LHS;
   }
@@ -353,20 +350,21 @@
 /// GatherValueComparisons - If the specified Cond is an 'and' or 'or' of a
 /// bunch of comparisons of one value against constants, return the value and
 /// the constants being compared.
-bool SimplifyCFGOpt::GatherValueComparisons(Value *CondV, Value *&CompVal,
-                                            std::vector<ConstantInt*> &Values) {
+static bool GatherValueComparisons(Value *CondV, Value *&CompVal,
+                                   std::vector<ConstantInt*> &Values,
+                                   const TargetData *TD) {
   Instruction *Cond = dyn_cast<Instruction>(CondV);
   if (Cond == 0) return false;

   if (Cond->getOpcode() == Instruction::Or) {
-    CompVal = GatherConstantSetEQs(Cond, Values);
+    CompVal = GatherConstantSetEQs(Cond, Values, TD);

     // Return true to indicate that the condition is true if the CompVal is
     // equal to one of the constants.
     return true;
   }
   if (Cond->getOpcode() == Instruction::And) {
-    CompVal = GatherConstantSetNEs(Cond, Values);
+    CompVal = GatherConstantSetNEs(Cond, Values, TD);

     // Return false to indicate that the condition is false if the CompVal is
     // equal to one of the constants.
@@ -405,7 +403,7 @@
       if (ICmpInst *ICI = dyn_cast<ICmpInst>(BI->getCondition()))
         if ((ICI->getPredicate() == ICmpInst::ICMP_EQ ||
              ICI->getPredicate() == ICmpInst::ICMP_NE) &&
-            GetConstantInt(ICI->getOperand(1)))
+            GetConstantInt(ICI->getOperand(1), TD))
           CV = ICI->getOperand(0);

   // Unwrap any lossless ptrtoint cast.
@@ -430,7 +428,7 @@

   BranchInst *BI = cast<BranchInst>(TI);
   ICmpInst *ICI = cast<ICmpInst>(BI->getCondition());
-  Cases.push_back(std::make_pair(GetConstantInt(ICI->getOperand(1)),
+  Cases.push_back(std::make_pair(GetConstantInt(ICI->getOperand(1), TD),
                                  BI->getSuccessor(ICI->getPredicate() ==
                                                   ICmpInst::ICMP_NE)));
   return BI->getSuccessor(ICI->getPredicate() == ICmpInst::ICMP_EQ);
@@ -2083,7 +2081,7 @@
       Value *CompVal = 0;
       std::vector<ConstantInt*> Values;
       bool TrueWhenEqual = GatherValueComparisons(BI->getCondition(), CompVal,
-                                                  Values);
+                                                  Values, TD);
       if (CompVal) {
         // There might be duplicate constants in the list, which the switch
         // instruction can't handle, remove them now.


Synced sqlite3utils with private and fixed a small recursive bug in SIPEngine that was already fixed in private

git-svn-id: 1eb6ded1e61a47bd1ac24f1f957e4480b47f878b@4912 19bc5d8c-e614-43d4-8b26-e1612bc8e597

--- CommonLibs/sqlite3util.cpp
+++ CommonLibs/sqlite3util.cpp
@@ -1,6 +1,6 @@
 /*
-* Written by David A. Burgess, Kestrel Signal Processing, Inc., 2010
-* The author disclaims copyright to this source code.
+* Copyright 2010 Kestrel Signal Processing, Inc.
+* All rights reserved.
 */

@@ -17,12 +17,18 @@

 int sqlite3_prepare_statement(sqlite3* DB, sqlite3_stmt **stmt, const char* query)
 {
-	int prc = sqlite3_prepare_v2(DB,query,strlen(query),stmt,NULL);
-	if (prc) {
-		fprintf(stderr,"sqlite3_prepare_v2 failed for \"%s\": %s\n",query,sqlite3_errmsg(DB));
-		sqlite3_finalize(*stmt);
-	}
-	return prc;
+        int src = SQLITE_BUSY;
+        while (src==SQLITE_BUSY) {
+                src = sqlite3_prepare_v2(DB,query,strlen(query),stmt,NULL);
+                if (src==SQLITE_BUSY) {
+                        usleep(100000);
+                }
+        }
+        if (src) {
+                fprintf(stderr,"sqlite3_prepare_v2 failed for \"%s\": %s\n",query,sqlite3_errmsg(DB));
+                sqlite3_finalize(*stmt);
+        }
+        return src;
 }

 int sqlite3_run_query(sqlite3* DB, sqlite3_stmt *stmt)
@@ -140,6 +146,7 @@
 	if (sqlite3_prepare_statement(DB,&stmt,query)) return false;
 	// Run the query.
 	int src = sqlite3_run_query(DB,stmt);
+	sqlite3_finalize(stmt);
 	return src==SQLITE_DONE;
 }


Revert "Avoid template specialization of load_volatile and store_volatile when not using HCC or HIP-CLANG (#128)" (#131)

This reverts commit d67aa3c45784c14718f92e0982c94319adff0ecd.

--- rocprim/include/rocprim/detail/various.hpp
+++ rocprim/include/rocprim/detail/various.hpp
@@ -209,21 +209,6 @@
     return retval;
 }

-#if __HCC_OR_HIP_CLANG__
-ROCPRIM_DEVICE inline
-void store_volatile(half * output, half value)
-{
-    *reinterpret_cast<volatile _Float16*>(output) = value;
-}
-
-ROCPRIM_DEVICE inline
-half load_volatile(half * input)
-{
-    half retval = *reinterpret_cast<volatile _Float16*>(input);
-    return retval;
-}
-#endif
-
 // A storage-backing wrapper that allows types with non-trivial constructors to be aliased in unions
 template <typename T>
 struct raw_storage


Cleanup

Cleanup

--- src/device/device.cpp
+++ src/device/device.cpp
@@ -409,7 +409,6 @@
 		}
 		else
 		{
-			const char* source_dir = _device_options._source_dir;
 			const char* bundle_dir = _device_options._bundle_dir;
 			const char* platform = _device_options._platform;
 			do_continue = _bundle_compiler->compile(bundle_dir, platform);
@@ -755,7 +754,6 @@

 void Device::reload(StringId64 type, StringId64 name)
 {
-	const void* old_resource = _resource_manager->get(type, name);
 	_resource_manager->reload(type, name);
 	const void* new_resource = _resource_manager->get(type, name);


Values in the publication

Values in the publication


:wrench: Ensure correct path

:wrench: Ensure correct path

--- brightray/browser/win/notification_presenter_win.cc
+++ brightray/browser/win/notification_presenter_win.cc
@@ -12,6 +12,7 @@
 #include "base/files/file_util.h"
 #include "base/md5.h"
 #include "base/strings/utf_string_conversions.h"
+#include "base/time/time.h"
 #include "base/win/windows_version.h"
 #include "brightray/browser/win/notification_presenter_win7.h"
 #include "brightray/browser/win/windows_toast_notification.h"
@@ -64,7 +65,15 @@

 base::string16 NotificationPresenterWin::SaveIconToFilesystem(
     const SkBitmap& icon, const GURL& origin) {
-  std::string filename = base::MD5String(origin.spec()) + ".png";
+  std::string filename;
+
+  if (origin.is_valid()) {
+    filename = base::MD5String(origin.spec()) + ".png";
+  } else {
+    base::TimeTicks now = base::TimeTicks::Now();
+    filename = std::to_string(now.ToInternalValue()) + ".png";
+  }
+
   base::FilePath path = temp_dir_.GetPath().Append(base::UTF8ToUTF16(filename));
   if (base::PathExists(path))
     return path.value();


neth: fill addresses

neth: fill addresses

--- neth/main.cpp
+++ neth/main.cpp
@@ -898,7 +898,7 @@
 					toString(formatBalance(t.value)) %
 					toString((unsigned)t.nonce);
 			mvwaddnstr(pendingwin, y++, x, s.c_str(), qwidth);
-			if (y > qheight - 4)
+			if (y > height * 1 / 5 - 4)
 				break;
 		}

@@ -922,16 +922,20 @@
 				if (cc > qheight - 2)
 					break;
 			}
-			else {
+		}
+		for (auto const& i: acs)
+		{
+			auto r = i.first;
+			if (!st.addressHasCode(r)) {
 				auto s = boost::format("%1%%2% : %3% [%4%]") %
 					toString(r) %
 					pretty(r, st) %
 					toString(formatBalance(i.second)) %
 					toString((unsigned)st.transactionsFrom(i.first));
 				mvwaddnstr(addswin, y++, x, s.str().c_str(), width / 2 - 4);
-			}
-			if (y > height * 2 / 5 - 2)
-				break;
+				if (y > height * 3 / 5 - 4)
+					break;
+			}
 		}

 		// Peers


Removed extraneous calls to GetCurrentWindowRead() when we already have a ImGuiContext. Internal RenderXXX functions also don't need to write into the Accessed field at all.

--- imgui.cpp
+++ imgui.cpp
@@ -1937,12 +1937,12 @@
 // Advance cursor given item size for layout.
 void ImGui::ItemSize(const ImVec2& size, float text_offset_y)
 {
-    ImGuiWindow* window = GetCurrentWindow();
+    ImGuiContext& g = *GImGui;
+    ImGuiWindow* window = g.CurrentWindow;
     if (window->SkipItems)
         return;

     // Always align ourselves on pixel boundaries
-    ImGuiContext& g = *GImGui;
     const float line_height = ImMax(window->DC.CurrentLineHeight, size.y);
     const float text_base_offset = ImMax(window->DC.CurrentLineTextBaseOffset, text_offset_y);
     //if (g.IO.KeyAlt) window->DrawList->AddRect(window->DC.CursorPos, window->DC.CursorPos + ImVec2(size.x, line_height), IM_COL32(255,0,0,200)); // [DEBUG]
@@ -2034,7 +2034,7 @@
 bool ImGui::IsClippedEx(const ImRect& bb, const ImGuiID* id, bool clip_even_when_logged)
 {
     ImGuiContext& g = *GImGui;
-    ImGuiWindow* window = GetCurrentWindowRead();
+    ImGuiWindow* window = g.CurrentWindow;
     if (!bb.Overlaps(window->ClipRect))
         if (!id || *id != g.ActiveId)
             if (clip_even_when_logged || !g.LogEnabled)
@@ -2893,7 +2893,7 @@
 static void LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end = NULL)
 {
     ImGuiContext& g = *GImGui;
-    ImGuiWindow* window = ImGui::GetCurrentWindowRead();
+    ImGuiWindow* window = g.CurrentWindow;

     if (!text_end)
         text_end = ImGui::FindRenderedTextEnd(text, text_end);
@@ -2945,7 +2945,7 @@
 void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool hide_text_after_hash)
 {
     ImGuiContext& g = *GImGui;
-    ImGuiWindow* window = GetCurrentWindow();
+    ImGuiWindow* window = g.CurrentWindow;

     // Hide anything after a '##' string
     const char* text_display_end;
@@ -2972,7 +2972,7 @@
 void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width)
 {
     ImGuiContext& g = *GImGui;
-    ImGuiWindow* window = GetCurrentWindow();
+    ImGuiWindow* window = g.CurrentWindow;

     if (!text_end)
         text_end = text + strlen(text); // FIXME-OPT
@@ -2997,7 +2997,7 @@
         return;

     ImGuiContext& g = *GImGui;
-    ImGuiWindow* window = GetCurrentWindow();
+    ImGuiWindow* window = g.CurrentWindow;

     // Perform CPU side clipping for single clipped element to avoid using scissor state
     ImVec2 pos = pos_min;
@@ -3030,8 +3030,8 @@
 // Render a rectangle shaped with optional rounding and borders
 void ImGui::RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border, float rounding)
 {
-    ImGuiWindow* window = GetCurrentWindow();
-
+    ImGuiContext& g = *GImGui;
+    ImGuiWindow* window = g.CurrentWindow;
     window->DrawList->AddRectFilled(p_min, p_max, fill_col, rounding);
     if (border && (window->Flags & ImGuiWindowFlags_ShowBorders))
     {
@@ -3042,7 +3042,8 @@

 void ImGui::RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding)
 {
-    ImGuiWindow* window = GetCurrentWindow();
+    ImGuiContext& g = *GImGui;
+    ImGuiWindow* window = g.CurrentWindow;
     if (window->Flags & ImGuiWindowFlags_ShowBorders)
     {
         window->DrawList->AddRect(p_min+ImVec2(1,1), p_max+ImVec2(1,1), GetColorU32(ImGuiCol_BorderShadow), rounding);
@@ -3054,7 +3055,7 @@
 void ImGui::RenderCollapseTriangle(ImVec2 p_min, bool is_open, float scale)
 {
     ImGuiContext& g = *GImGui;
-    ImGuiWindow* window = GetCurrentWindow();
+    ImGuiWindow* window = g.CurrentWindow;

     const float h = g.FontSize * 1.00f;
     const float r = h * 0.40f * scale;
@@ -3080,14 +3081,15 @@

 void ImGui::RenderBullet(ImVec2 pos)
 {
-    ImGuiWindow* window = GetCurrentWindow();
+    ImGuiContext& g = *GImGui;
+    ImGuiWindow* window = g.CurrentWindow;
     window->DrawList->AddCircleFilled(pos, GImGui->FontSize*0.20f, GetColorU32(ImGuiCol_Text), 8);
 }

 void ImGui::RenderCheckMark(ImVec2 pos, ImU32 col)
 {
     ImGuiContext& g = *GImGui;
-    ImGuiWindow* window = GetCurrentWindow();
+    ImGuiWindow* window = g.CurrentWindow;
     float start_x = (float)(int)(g.FontSize * 0.307f + 0.5f);
     float rem_third = (float)(int)((g.FontSize - start_x) / 3.0f);
     float bx = pos.x + 0.5f + start_x + rem_third;
@@ -3132,7 +3134,7 @@
 void ImGui::CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end)
 {
     ImGuiContext& g = *GImGui;
-    ImGuiWindow* window = GetCurrentWindowRead();
+    ImGuiWindow* window = g.CurrentWindow;
     if (g.LogEnabled)
     {
         // If logging is active, do not perform any clipping
@@ -3184,7 +3186,7 @@
 bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip)
 {
     ImGuiContext& g = *GImGui;
-    ImGuiWindow* window = GetCurrentWindowRead();
+    ImGuiWindow* window = g.CurrentWindow;

     // Clip
     ImRect rect_clipped(r_min, r_max);
@@ -3382,7 +3384,7 @@
     ImGuiContext& g = *GImGui;
     if (g.ActiveId)
     {
-        ImGuiWindow* window = GetCurrentWindowRead();
+        ImGuiWindow* window = g.CurrentWindow;
         return g.ActiveId == window->DC.LastItemId;
     }
     return false;
@@ -5947,7 +5949,7 @@
     ImGuiContext& g = *GImGui;
     if (g.LogEnabled)
         return;
-    ImGuiWindow* window = GetCurrentWindowRead();
+    ImGuiWindow* window = g.CurrentWindow;

     g.LogEnabled = true;
     g.LogFile = stdout;
@@ -5962,7 +5964,7 @@
     ImGuiContext& g = *GImGui;
     if (g.LogEnabled)
         return;
-    ImGuiWindow* window = GetCurrentWindowRead();
+    ImGuiWindow* window = g.CurrentWindow;

     if (!filename)
     {
@@ -5989,7 +5991,7 @@
     ImGuiContext& g = *GImGui;
     if (g.LogEnabled)
         return;
-    ImGuiWindow* window = GetCurrentWindowRead();
+    ImGuiWindow* window = g.CurrentWindow;

     g.LogEnabled = true;
     g.LogFile = NULL;
@@ -10175,7 +10177,7 @@
     // Active (dragged) column always follow mouse. The reason we need this is that dragging a column to the right edge of an auto-resizing
     // window creates a feedback loop because we store normalized positions. So while dragging we enforce absolute positioning.
     ImGuiContext& g = *GImGui;
-    ImGuiWindow* window = ImGui::GetCurrentWindowRead();
+    ImGuiWindow* window = g.CurrentWindow;
     IM_ASSERT(column_index > 0); // We cannot drag column 0. If you get this assert you may have a conflict between the ID of your columns and another widgets.
     IM_ASSERT(g.ActiveId == window->DC.ColumnsSetId + ImGuiID(column_index));


Undo part of c2e8c8ac to fix issue#1148

Undo part of c2e8c8ac to fix issue#1148

--- src/script.cpp
+++ src/script.cpp
@@ -939,7 +939,7 @@
                 {
                     // ([sig ...] num_of_signatures [pubkey ...] num_of_pubkeys -- bool)

-                    unsigned int i = 1;
+                    int i = 1;
                     if (stack.size() < i)
                         return false;


DAP Macro changes

DAP Macro changes

--- HDF5RequestHandler.cc
+++ HDF5RequestHandler.cc
@@ -39,13 +39,13 @@
 #include <BESDataDDSResponse.h>
 #include <Ancillary.h>
 #include <BESInfo.h>
+#include <BESDapNames.h>
 #include <BESResponseNames.h>
 #include <BESContainer.h>
 #include <BESResponseHandler.h>
 #include <BESVersionInfo.h>
 #include <BESServiceRegistry.h>
 #include <BESUtil.h>
-#include <BESDataNames.h>
 #include <BESDapError.h>
 #include <BESNotFoundError.h>
 #include <BESInternalFatalError.h>


Remove dead expression.

Remove dead expression.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@25480 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/VMCore/AutoUpgrade.cpp
+++ lib/VMCore/AutoUpgrade.cpp
@@ -166,7 +166,7 @@
 bool llvm::UpgradeCallsToIntrinsic(Function* F) {
   if (Function* newF = UpgradeIntrinsicFunction(F)) {
     for (Value::use_iterator UI = F->use_begin(), UE = F->use_end();
-         UI != UE; UI) {
+         UI != UE; ) {
       if (CallInst* CI = dyn_cast<CallInst>(*UI++)) {
         std::vector<Value*> Oprnds;
         User::op_iterator OI = CI->op_begin();


Update oled_128x64_adafruit_screens.cpp

Update oled_128x64_adafruit_screens.cpp

--- rx5808-pro-diversityGc9n/oled_128x64_adafruit_screens.cpp
+++ rx5808-pro-diversityGc9n/oled_128x64_adafruit_screens.cpp
@@ -4,7 +4,8 @@
   The MIT License (MIT)

   Copyright (c) 2015 Shea Ivey
-
+  **MODS Geroge chatzisavvidis
+
   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software and associated documentation files (the "Software"), to deal
   in the Software without restriction, including without limitation the rights


Propagate likelies on GuardWithIf through bounds inference

--- src/Bounds.cpp
+++ src/Bounds.cpp
@@ -1258,20 +1258,39 @@
                     Expr inner_min, inner_max;
                     if (var_a && scope.contains(var_a->name)) {
                         Interval i = scope.get(var_a->name);
+
+                        // If the original condition is likely, then
+                        // the additional trimming of the domain due
+                        // to the condition is probably unnecessary,
+                        // which means the mins/maxes below should
+                        // probably just be the LHS.
+                        Interval likely_i = i;
+                        if (call && call->is_intrinsic(Call::likely)) {
+                            likely_i.min = likely(i.min);
+                            likely_i.max = likely(i.max);
+                        }
+
                         Interval bi = bounds_of_expr_in_scope(b, scope, func_bounds);
-                        if (lt)       i.max = min(i.max, bi.max - 1);
-                        if (le || eq) i.max = min(i.max, bi.max);
-                        if (gt)       i.min = max(i.min, bi.min + 1);
-                        if (ge || eq) i.min = max(i.min, bi.min);
+                        if (lt)       i.max = min(likely_i.max, bi.max - 1);
+                        if (le || eq) i.max = min(likely_i.max, bi.max);
+                        if (gt)       i.min = max(likely_i.min, bi.min + 1);
+                        if (ge || eq) i.min = max(likely_i.min, bi.min);
                         scope.push(var_a->name, i);
                         var_to_pop = var_a->name;
                     } else if (var_b && scope.contains(var_b->name)) {
                         Interval i = scope.get(var_b->name);
+
+                        Interval likely_i = i;
+                        if (call && call->is_intrinsic(Call::likely)) {
+                            likely_i.min = likely(i.min);
+                            likely_i.max = likely(i.max);
+                        }
+
                         Interval ai = bounds_of_expr_in_scope(a, scope, func_bounds);
-                        if (gt)       i.max = min(i.max, ai.max - 1);
-                        if (ge || eq) i.max = min(i.max, ai.max);
-                        if (lt)       i.min = max(i.min, ai.min + 1);
-                        if (le || eq) i.min = max(i.min, ai.min);
+                        if (gt)       i.max = min(likely_i.max, ai.max - 1);
+                        if (ge || eq) i.max = min(likely_i.max, ai.max);
+                        if (lt)       i.min = max(likely_i.min, ai.min + 1);
+                        if (le || eq) i.min = max(likely_i.min, ai.min);
                         scope.push(var_b->name, i);
                         var_to_pop = var_b->name;
                     }


Initialize the components of this class.  Otherwise GCC thinks that Array may be
used uninitialized, since it fails to understand that Array is only used when
SingleValue is not, and outputs a warning.  It also seems generally safer given
that the constructor is non-trivial and has plenty of early exits.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@173242 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Transforms/Utils/SimplifyCFG.cpp
+++ lib/Transforms/Utils/SimplifyCFG.cpp
@@ -3382,7 +3382,8 @@
                                      ConstantInt *Offset,
                const SmallVector<std::pair<ConstantInt*, Constant*>, 4>& Values,
                                      Constant *DefaultValue,
-                                     const DataLayout *TD) {
+                                     const DataLayout *TD)
+    : SingleValue(0), BitMap(0), BitMapElementTy(0), Array(0) {
   assert(Values.size() && "Can't build lookup table without values!");
   assert(TableSize >= Values.size() && "Can't fit values in table!");


patch minor memory leak (file opened in notify not closed in some circumstances)

--- PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskJetV2.cxx
+++ PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskJetV2.cxx
@@ -2582,9 +2582,9 @@
     if(!fChi3A) fChi3A = new TArrayD(9, chiA3);
     if(!fChi3C) fChi3C = new TArrayD(9, chiC3);

-    // 2) open database file
-    fOADB = TFile::Open("$ALICE_PHYSICS/OADB/PWGCF/VZERO/VZEROcalibEP.root");
-    if(fOADB->IsZombie()){
+    // 2) check if the database file is open, if not, open it
+    if(!fOADB || fOADB->IsZombie()) fOADB = TFile::Open("$ALICE_PHYSICS/OADB/PWGCF/VZERO/VZEROcalibEP.root");
+    if(fOADB->IsZombie()) {
 	printf("OADB file $ALICE_PHYSICS/OADB/PWGCF/VZERO/VZEROcalibEP.root cannot be opened, CALIBRATION FAILED !");
 	return;
     }


INTEGRATION: CWS changefileheader (1.4.164); FILE MERGED 2008/04/01 12:29:48 thb 1.4.164.2: #i85898# Stripping all external header guards 2008/03/31 12:31:40 rt 1.4.164.1: #i87441# Change license header to LPGL v3.

--- extensions/source/propctrlr/defaultforminspection.hxx
+++ extensions/source/propctrlr/defaultforminspection.hxx
@@ -1,43 +1,36 @@
 /*************************************************************************
  *
- *  OpenOffice.org - a multi-platform office productivity suite
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- *  $RCSfile: defaultforminspection.hxx,v $
+ * Copyright 2008 by Sun Microsystems, Inc.
  *
- *  $Revision: 1.4 $
+ * OpenOffice.org - a multi-platform office productivity suite
  *
- *  last change: $Author: kz $ $Date: 2007-05-10 10:47:28 $
+ * $RCSfile: defaultforminspection.hxx,v $
+ * $Revision: 1.5 $
  *
- *  The Contents of this file are made available subject to
- *  the terms of GNU Lesser General Public License Version 2.1.
+ * This file is part of OpenOffice.org.
  *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
  *
- *    GNU Lesser General Public License Version 2.1
- *    =============================================
- *    Copyright 2005 by Sun Microsystems, Inc.
- *    901 San Antonio Road, Palo Alto, CA 94303, USA
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
  *
- *    This library is free software; you can redistribute it and/or
- *    modify it under the terms of the GNU Lesser General Public
- *    License version 2.1, as published by the Free Software Foundation.
- *
- *    This library is distributed in the hope that it will be useful,
- *    but WITHOUT ANY WARRANTY; without even the implied warranty of
- *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *    Lesser General Public License for more details.
- *
- *    You should have received a copy of the GNU Lesser General Public
- *    License along with this library; if not, write to the Free Software
- *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- *    MA  02111-1307  USA
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
  *
  ************************************************************************/
 #ifndef EXTENSIONS_SOURCE_PROPCTRLR_DEFAULTFORMINSPECTION_HXX
 #define EXTENSIONS_SOURCE_PROPCTRLR_DEFAULTFORMINSPECTION_HXX

-#ifndef INSPECTORMODELBASE_HXX
 #include "inspectormodelbase.hxx"
-#endif

 /** === begin UNO includes === **/
 /** === end UNO includes === **/


Fix broken string parse crash

Fix broken string parse crash

svn path=/branches/groupwise_in_anger/kdenetwork/kopete/; revision=343546

--- protocols/groupwise/libgroupwise/inputprotocolbase.cpp
+++ protocols/groupwise/libgroupwise/inputprotocolbase.cpp
@@ -71,9 +71,11 @@
 		m_din->readRawBytes( temp.data(), val );
 		// the rest of the string will be filled with FF,
 		// so look for that in the last position instead of \0
-		if ( (Q_UINT8)( * ( temp.data() + ( temp.length() - 1 ) ) ) == 0xFF )
+		// this caused a crash - guessing that temp.length() is set to the number of bytes actually read...
+		// if ( (Q_UINT8)( * ( temp.data() + ( temp.length() - 1 ) ) ) == 0xFF )
+		if ( temp.length() < ( val -1 ) )
 		{
-			qDebug( "EventProtocol::safeReadBytes() - string broke, giving up" );
+			qDebug( "EventProtocol::safeReadBytes() - string broke, giving up: %i, should be %i",  temp.length(), val );
 			m_state = NeedMore;
 			return false;
 		}


Add compatibility calls to regular IntMap.

--- runtime/cpp/include/collections/IntMap.hpp
+++ runtime/cpp/include/collections/IntMap.hpp
@@ -27,6 +27,8 @@
 class IntMap {
   using Key = typename R::KeyType;
   using CloneFn = void (*)(void*, void*, size_t);
+  using GetKeyFn = uint32_t (*)(void*);
+  using SetKeyFn = void (*)(void*, uint32_t);
   using Container = shared_ptr<mapi>;

  public:
@@ -520,6 +522,15 @@
     new (dest) R(*static_cast<R*>(src));
   }

+  static inline uint32_t getKey(void* record) {
+    return static_cast<R*>(record)->key;
+  }
+
+  static inline void setKey(void* record, uint32_t newKey) {
+    static_cast<R*>(record)->key = newKey;
+    return;
+  }
+
   static inline void moveElem(void* dest, void* src, size_t sz) {
     new (dest) R(std::move(*static_cast<R*>(src)));
   }
@@ -542,6 +553,8 @@
       container = Container(mapi_new(sz), [](mapi* m) { mapi_free(m); });
     }
     mapi_clone(get_mapi(), (CloneFn)&IntMap<R>::cloneElem);
+    mapi_getKey(get_mapi(), (GetKeyFn)&IntMap<R>::getKey);
+    mapi_setKey(get_mapi(), (SetKeyFn)&IntMap<R>::setKey);
   }

   void init_mapi(bool alloc, size_t sz) const {
@@ -550,6 +563,8 @@
           Container(mapi_new(sz), [](mapi* m) { mapi_free(m); });
     }
     mapi_clone(get_mapi(), (CloneFn)&IntMap<R>::cloneElem);
+    mapi_getKey(get_mapi(), (GetKeyFn)&IntMap<R>::getKey);
+    mapi_setKey(get_mapi(), (SetKeyFn)&IntMap<R>::setKey);
   }

   template <class archive>


Fix bug with applying colormap in RenderableBillboardsCloud

--- modules/digitaluniverse/rendering/renderablebillboardscloud.cpp
+++ modules/digitaluniverse/rendering/renderablebillboardscloud.cpp
@@ -1245,7 +1245,10 @@
                     break;
             }

-            int colorIndex = (c == static_cast<int>(colorBins.size())) - 1 ? 0 : c + 1;
+            int colorIndex = 0;
+            if (c != static_cast<int>(colorBins.size() - 1)) {
+                colorIndex = c + 1;
+            }

             for (auto j = 0; j < 4; ++j) {
                 _slicedData.push_back(_colorMapData[colorIndex][j]);


Delete script.cpp

Delete script.cpp

--- src/script.cpp
+++ src/script.cpp
@@ -1,329 +0,0 @@
-/*
- * Copyright 2009 Colin Percival, 2011 ArtForz, 2012-2013 pooler
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This file was originally written by Colin Percival as part of the Tarsnap
- * online backup system.
- */
-
-#include "scrypt.h"
-#include "util.h"
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <openssl/sha.h>
-
-#if defined(USE_SSE2) && !defined(USE_SSE2_ALWAYS)
-#ifdef _MSC_VER
-// MSVC 64bit is unable to use inline asm
-#include <intrin.h>
-#else
-// GCC Linux or i686-w64-mingw32
-#include <cpuid.h>
-#endif
-#endif
-
-static inline uint32_t be32dec(const void *pp)
-{
-	const uint8_t *p = (uint8_t const *)pp;
-	return ((uint32_t)(p[3]) + ((uint32_t)(p[2]) << 8) +
-	    ((uint32_t)(p[1]) << 16) + ((uint32_t)(p[0]) << 24));
-}
-
-static inline void be32enc(void *pp, uint32_t x)
-{
-	uint8_t *p = (uint8_t *)pp;
-	p[3] = x & 0xff;
-	p[2] = (x >> 8) & 0xff;
-	p[1] = (x >> 16) & 0xff;
-	p[0] = (x >> 24) & 0xff;
-}
-
-typedef struct HMAC_SHA256Context {
-	SHA256_CTX ictx;
-	SHA256_CTX octx;
-} HMAC_SHA256_CTX;
-
-/* Initialize an HMAC-SHA256 operation with the given key. */
-static void
-HMAC_SHA256_Init(HMAC_SHA256_CTX *ctx, const void *_K, size_t Klen)
-{
-	unsigned char pad[64];
-	unsigned char khash[32];
-	const unsigned char *K = (const unsigned char *)_K;
-	size_t i;
-
-	/* If Klen > 64, the key is really SHA256(K). */
-	if (Klen > 64) {
-		SHA256_Init(&ctx->ictx);
-		SHA256_Update(&ctx->ictx, K, Klen);
-		SHA256_Final(khash, &ctx->ictx);
-		K = khash;
-		Klen = 32;
-	}
-
-	/* Inner SHA256 operation is SHA256(K xor [block of 0x36] || data). */
-	SHA256_Init(&ctx->ictx);
-	memset(pad, 0x36, 64);
-	for (i = 0; i < Klen; i++)
-		pad[i] ^= K[i];
-	SHA256_Update(&ctx->ictx, pad, 64);
-
-	/* Outer SHA256 operation is SHA256(K xor [block of 0x5c] || hash). */
-	SHA256_Init(&ctx->octx);
-	memset(pad, 0x5c, 64);
-	for (i = 0; i < Klen; i++)
-		pad[i] ^= K[i];
-	SHA256_Update(&ctx->octx, pad, 64);
-
-	/* Clean the stack. */
-	memset(khash, 0, 32);
-}
-
-/* Add bytes to the HMAC-SHA256 operation. */
-static void
-HMAC_SHA256_Update(HMAC_SHA256_CTX *ctx, const void *in, size_t len)
-{
-	/* Feed data to the inner SHA256 operation. */
-	SHA256_Update(&ctx->ictx, in, len);
-}
-
-/* Finish an HMAC-SHA256 operation. */
-static void
-HMAC_SHA256_Final(unsigned char digest[32], HMAC_SHA256_CTX *ctx)
-{
-	unsigned char ihash[32];
-
-	/* Finish the inner SHA256 operation. */
-	SHA256_Final(ihash, &ctx->ictx);
-
-	/* Feed the inner hash to the outer SHA256 operation. */
-	SHA256_Update(&ctx->octx, ihash, 32);
-
-	/* Finish the outer SHA256 operation. */
-	SHA256_Final(digest, &ctx->octx);
-
-	/* Clean the stack. */
-	memset(ihash, 0, 32);
-}
-
-/**
- * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen):
- * Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and
- * write the output to buf.  The value dkLen must be at most 32 * (2^32 - 1).
- */
-void
-PBKDF2_SHA256(const uint8_t *passwd, size_t passwdlen, const uint8_t *salt,
-    size_t saltlen, uint64_t c, uint8_t *buf, size_t dkLen)
-{
-	HMAC_SHA256_CTX PShctx, hctx;
-	size_t i;
-	uint8_t ivec[4];
-	uint8_t U[32];
-	uint8_t T[32];
-	uint64_t j;
-	int k;
-	size_t clen;
-
-	/* Compute HMAC state after processing P and S. */
-	HMAC_SHA256_Init(&PShctx, passwd, passwdlen);
-	HMAC_SHA256_Update(&PShctx, salt, saltlen);
-
-	/* Iterate through the blocks. */
-	for (i = 0; i * 32 < dkLen; i++) {
-		/* Generate INT(i + 1). */
-		be32enc(ivec, (uint32_t)(i + 1));
-
-		/* Compute U_1 = PRF(P, S || INT(i)). */
-		memcpy(&hctx, &PShctx, sizeof(HMAC_SHA256_CTX));
-		HMAC_SHA256_Update(&hctx, ivec, 4);
-		HMAC_SHA256_Final(U, &hctx);
-
-		/* T_i = U_1 ... */
-		memcpy(T, U, 32);
-
-		for (j = 2; j <= c; j++) {
-			/* Compute U_j. */
-			HMAC_SHA256_Init(&hctx, passwd, passwdlen);
-			HMAC_SHA256_Update(&hctx, U, 32);
-			HMAC_SHA256_Final(U, &hctx);
-
-			/* ... xor U_j ... */
-			for (k = 0; k < 32; k++)
-				T[k] ^= U[k];
-		}
-
-		/* Copy as many bytes as necessary into buf. */
-		clen = dkLen - i * 32;
-		if (clen > 32)
-			clen = 32;
-		memcpy(&buf[i * 32], T, clen);
-	}
-
-	/* Clean PShctx, since we never called _Final on it. */
-	memset(&PShctx, 0, sizeof(HMAC_SHA256_CTX));
-}
-
-#define ROTL(a, b) (((a) << (b)) | ((a) >> (32 - (b))))
-
-static inline void xor_salsa8(uint32_t B[16], const uint32_t Bx[16])
-{
-	uint32_t x00,x01,x02,x03,x04,x05,x06,x07,x08,x09,x10,x11,x12,x13,x14,x15;
-	int i;
-
-	x00 = (B[ 0] ^= Bx[ 0]);
-	x01 = (B[ 1] ^= Bx[ 1]);
-	x02 = (B[ 2] ^= Bx[ 2]);
-	x03 = (B[ 3] ^= Bx[ 3]);
-	x04 = (B[ 4] ^= Bx[ 4]);
-	x05 = (B[ 5] ^= Bx[ 5]);
-	x06 = (B[ 6] ^= Bx[ 6]);
-	x07 = (B[ 7] ^= Bx[ 7]);
-	x08 = (B[ 8] ^= Bx[ 8]);
-	x09 = (B[ 9] ^= Bx[ 9]);
-	x10 = (B[10] ^= Bx[10]);
-	x11 = (B[11] ^= Bx[11]);
-	x12 = (B[12] ^= Bx[12]);
-	x13 = (B[13] ^= Bx[13]);
-	x14 = (B[14] ^= Bx[14]);
-	x15 = (B[15] ^= Bx[15]);
-	for (i = 0; i < 8; i += 2) {
-		/* Operate on columns. */
-		x04 ^= ROTL(x00 + x12,  7);  x09 ^= ROTL(x05 + x01,  7);
-		x14 ^= ROTL(x10 + x06,  7);  x03 ^= ROTL(x15 + x11,  7);
-
-		x08 ^= ROTL(x04 + x00,  9);  x13 ^= ROTL(x09 + x05,  9);
-		x02 ^= ROTL(x14 + x10,  9);  x07 ^= ROTL(x03 + x15,  9);
-
-		x12 ^= ROTL(x08 + x04, 13);  x01 ^= ROTL(x13 + x09, 13);
-		x06 ^= ROTL(x02 + x14, 13);  x11 ^= ROTL(x07 + x03, 13);
-
-		x00 ^= ROTL(x12 + x08, 18);  x05 ^= ROTL(x01 + x13, 18);
-		x10 ^= ROTL(x06 + x02, 18);  x15 ^= ROTL(x11 + x07, 18);
-
-		/* Operate on rows. */
-		x01 ^= ROTL(x00 + x03,  7);  x06 ^= ROTL(x05 + x04,  7);
-		x11 ^= ROTL(x10 + x09,  7);  x12 ^= ROTL(x15 + x14,  7);
-
-		x02 ^= ROTL(x01 + x00,  9);  x07 ^= ROTL(x06 + x05,  9);
-		x08 ^= ROTL(x11 + x10,  9);  x13 ^= ROTL(x12 + x15,  9);
-
-		x03 ^= ROTL(x02 + x01, 13);  x04 ^= ROTL(x07 + x06, 13);
-		x09 ^= ROTL(x08 + x11, 13);  x14 ^= ROTL(x13 + x12, 13);
-
-		x00 ^= ROTL(x03 + x02, 18);  x05 ^= ROTL(x04 + x07, 18);
-		x10 ^= ROTL(x09 + x08, 18);  x15 ^= ROTL(x14 + x13, 18);
-	}
-	B[ 0] += x00;
-	B[ 1] += x01;
-	B[ 2] += x02;
-	B[ 3] += x03;
-	B[ 4] += x04;
-	B[ 5] += x05;
-	B[ 6] += x06;
-	B[ 7] += x07;
-	B[ 8] += x08;
-	B[ 9] += x09;
-	B[10] += x10;
-	B[11] += x11;
-	B[12] += x12;
-	B[13] += x13;
-	B[14] += x14;
-	B[15] += x15;
-}
-
-void scrypt_1024_1_1_256_sp_generic(const char *input, char *output, char *scratchpad)
-{
-	uint8_t B[128];
-	uint32_t X[32];
-	uint32_t *V;
-	uint32_t i, j, k;
-
-	V = (uint32_t *)(((uintptr_t)(scratchpad) + 63) & ~ (uintptr_t)(63));
-
-	PBKDF2_SHA256((const uint8_t *)input, 80, (const uint8_t *)input, 80, 1, B, 128);
-
-	for (k = 0; k < 32; k++)
-		X[k] = le32dec(&B[4 * k]);
-
-	for (i = 0; i < 1024; i++) {
-		memcpy(&V[i * 32], X, 128);
-		xor_salsa8(&X[0], &X[16]);
-		xor_salsa8(&X[16], &X[0]);
-	}
-	for (i = 0; i < 1024; i++) {
-		j = 32 * (X[16] & 1023);
-		for (k = 0; k < 32; k++)
-			X[k] ^= V[j + k];
-		xor_salsa8(&X[0], &X[16]);
-		xor_salsa8(&X[16], &X[0]);
-	}
-
-	for (k = 0; k < 32; k++)
-		le32enc(&B[4 * k], X[k]);
-
-	PBKDF2_SHA256((const uint8_t *)input, 80, B, 128, 1, (uint8_t *)output, 32);
-}
-
-#if defined(USE_SSE2)
-// By default, set to generic scrypt function. This will prevent crash in case when scrypt_detect_sse2() wasn't called
-void (*scrypt_1024_1_1_256_sp_detected)(const char *input, char *output, char *scratchpad) = &scrypt_1024_1_1_256_sp_generic;
-
-void scrypt_detect_sse2()
-{
-#if defined(USE_SSE2_ALWAYS)
-    printf("scrypt: using scrypt-sse2 as built.\n");
-#else // USE_SSE2_ALWAYS
-    // 32bit x86 Linux or Windows, detect cpuid features
-    unsigned int cpuid_edx=0;
-#if defined(_MSC_VER)
-    // MSVC
-    int x86cpuid[4];
-    __cpuid(x86cpuid, 1);
-    cpuid_edx = (unsigned int)buffer[3];
-#else // _MSC_VER
-    // Linux or i686-w64-mingw32 (gcc-4.6.3)
-    unsigned int eax, ebx, ecx;
-    __get_cpuid(1, &eax, &ebx, &ecx, &cpuid_edx);
-#endif // _MSC_VER
-
-    if (cpuid_edx & 1<<26)
-    {
-        scrypt_1024_1_1_256_sp_detected = &scrypt_1024_1_1_256_sp_sse2;
-        printf("scrypt: using scrypt-sse2 as detected.\n");
-    }
-    else
-    {
-        scrypt_1024_1_1_256_sp_detected = &scrypt_1024_1_1_256_sp_generic;
-        printf("scrypt: using scrypt-generic, SSE2 unavailable.\n");
-    }
-#endif // USE_SSE2_ALWAYS
-}
-#endif
-
-void scrypt_1024_1_1_256(const char *input, char *output)
-{
-	char scratchpad[SCRYPT_SCRATCHPAD_SIZE];
-    scrypt_1024_1_1_256_sp(input, output, scratchpad);
-}


use high-level accessors

use high-level accessors

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@106573 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/VMCore/AutoUpgrade.cpp
+++ lib/VMCore/AutoUpgrade.cpp
@@ -344,11 +344,11 @@
     if (isLoadH || isLoadL || isMovL || isMovSD || isShufPD ||
         isUnpckhPD || isUnpcklPD || isPunpckhQPD || isPunpcklQPD) {
       std::vector<Constant*> Idxs;
-      Value *Op0 = CI->getOperand(1);
+      Value *Op0 = CI->getArgOperand(0);
       ShuffleVectorInst *SI = NULL;
       if (isLoadH || isLoadL) {
         Value *Op1 = UndefValue::get(Op0->getType());
-        Value *Addr = new BitCastInst(CI->getOperand(2),
+        Value *Addr = new BitCastInst(CI->getArgOperand(1),
                                   Type::getDoublePtrTy(C),
                                       "upgraded.", CI);
         Value *Load = new LoadInst(Addr, "upgraded.", false, 8, CI);
@@ -381,7 +381,7 @@
         SI = new ShuffleVectorInst(ZeroV, Op0, Mask, "upgraded.", CI);
       } else if (isMovSD ||
                  isUnpckhPD || isUnpcklPD || isPunpckhQPD || isPunpcklQPD) {
-        Value *Op1 = CI->getOperand(2);
+        Value *Op1 = CI->getArgOperand(1);
         if (isMovSD) {
           Idxs.push_back(ConstantInt::get(Type::getInt32Ty(C), 2));
           Idxs.push_back(ConstantInt::get(Type::getInt32Ty(C), 1));
@@ -395,8 +395,8 @@
         Value *Mask = ConstantVector::get(Idxs);
         SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI);
       } else if (isShufPD) {
-        Value *Op1 = CI->getOperand(2);
-        unsigned MaskVal = cast<ConstantInt>(CI->getOperand(3))->getZExtValue();
+        Value *Op1 = CI->getArgOperand(1);
+        unsigned MaskVal = cast<ConstantInt>(CI->getArgOperand(2))->getZExtValue();
         Idxs.push_back(ConstantInt::get(Type::getInt32Ty(C), MaskVal & 1));
         Idxs.push_back(ConstantInt::get(Type::getInt32Ty(C),
                                                ((MaskVal >> 1) & 1)+2));
@@ -416,8 +416,8 @@
       CI->eraseFromParent();
     } else if (F->getName() == "llvm.x86.sse41.pmulld") {
       // Upgrade this set of intrinsics into vector multiplies.
-      Instruction *Mul = BinaryOperator::CreateMul(CI->getOperand(1),
-                                                   CI->getOperand(2),
+      Instruction *Mul = BinaryOperator::CreateMul(CI->getArgOperand(0),
+                                                   CI->getArgOperand(1),
                                                    CI->getName(),
                                                    CI);
       // Fix up all the uses with our new multiply.
@@ -556,10 +556,10 @@
   case Intrinsic::x86_mmx_psrl_w: {
     Value *Operands[2];

-    Operands[0] = CI->getOperand(1);
+    Operands[0] = CI->getArgOperand(0);

     // Cast the second parameter to the correct type.
-    BitCastInst *BC = new BitCastInst(CI->getOperand(2),
+    BitCastInst *BC = new BitCastInst(CI->getArgOperand(1),
                                       NewFn->getFunctionType()->getParamType(1),
                                       "upgraded.", CI);
     Operands[1] = BC;
@@ -643,8 +643,8 @@
   case Intrinsic::memset: {
     // Add isVolatile
     const llvm::Type *I1Ty = llvm::Type::getInt1Ty(CI->getContext());
-    Value *Operands[5] = { CI->getOperand(1), CI->getOperand(2),
-                           CI->getOperand(3), CI->getOperand(4),
+    Value *Operands[5] = { CI->getArgOperand(0), CI->getArgOperand(1),
+                           CI->getArgOperand(2), CI->getArgOperand(3),
                            llvm::ConstantInt::get(I1Ty, 0) };
     CallInst *NewCI = CallInst::Create(NewFn, Operands, Operands+5,
                                        CI->getName(), CI);
@@ -726,7 +726,8 @@
   if (Function *Declare = M->getFunction("llvm.dbg.declare")) {
     if (!Declare->use_empty()) {
       DbgDeclareInst *DDI = cast<DbgDeclareInst>(Declare->use_back());
-      if (!isa<MDNode>(DDI->getOperand(1)) ||!isa<MDNode>(DDI->getOperand(2))) {
+      if (!isa<MDNode>(DDI->getArgOperand(0)) ||
+          !isa<MDNode>(DDI->getArgOperand(1))) {
         while (!Declare->use_empty()) {
           CallInst *CI = cast<CallInst>(Declare->use_back());
           CI->eraseFromParent();


RWGraph: move assertion to the right place

Fixes #304.

--- lib/llvm/ReadWriteGraph/LLVMReadWriteGraphBuilder.cpp
+++ lib/llvm/ReadWriteGraph/LLVMReadWriteGraphBuilder.cpp
@@ -504,14 +504,13 @@
     if (it == subgraphs_map.end()) {
         // create a new subgraph
         subg = &buildFunction(*F);
+        assert(subg->entry && "No entry in the subgraph");
+        assert(subg->entry->nodes.front() && "No first node in the subgraph");
     } else {
         subg = &it->second;
     }

     assert(subg && "No subgraph");
-    assert(subg->entry && "No entry in the subgraph");
-    assert(subg->entry->nodes.front() && "No first node in the subgraph");
-
     return subg;
 }


another mandelbrot hint

another mandelbrot hint

--- src/Buddha.cpp
+++ src/Buddha.cpp
@@ -183,7 +183,12 @@

 bool Buddha::mandelbrot_hint(complex_type z) const {
     complex_type unit(1, 0), four(4, 0);
-    if (std::abs(unit - std::sqrt(unit - four*z)) < 1) return true;
-    if (z.real() * z.real() + z.imag() * z.imag() <= 0.25) return true;
+    if (std::abs(unit - std::sqrt(unit - four*z)) < 1)
+        return true;
+
+    complex_type iunit(0, 1),  dist = z - iunit;
+    if (dist.real() * dist.real() + dist.imag() * dist.imag() <= 1./8)
+        return true;
+
     return false;
 }


Double the size of assign's ptop line parse buffer

Yeah, this only delays the inevitable, but doing better will require
more careful re-architecture

--- assign/parse_ptop.cc
+++ assign/parse_ptop.cc
@@ -77,12 +77,12 @@
 {
   int num_nodes = 0;
   int line=0,errors=0;
-  char inbuf[16384];
+  char inbuf[32768];
   string_vector parsed_line;

   while (!input.eof()) {
     line++;
-    input.getline(inbuf,16384);
+    input.getline(inbuf,32768);
     parsed_line = split_line(inbuf,' ');
     if (parsed_line.size() == 0) {continue;}


fix #12 temperature offset conversion

fix #12 temperature offset conversion

--- src/CS5490.cpp
+++ src/CS5490.cpp
@@ -478,7 +478,7 @@

 double CS5490::getOffsetT(){
   this->read(16,55);
-	return this->toDouble(23, MSBsigned);
+	return this->toDouble(16, MSBsigned);
 }

 void CS5490::setDcOffsetV(double value){
@@ -497,7 +497,7 @@
 }

 void CS5490::setOffsetT(double value){
-	uint32_t binValue = this->toBinary(23,MSBsigned,value);
+	uint32_t binValue = this->toBinary(16,MSBsigned,value);
   this->write(16,55,binValue);
 }


important

important

--- sadx-dc-lighting/FixCharacterMaterials.cpp
+++ sadx-dc-lighting/FixCharacterMaterials.cpp
@@ -2,7 +2,7 @@
 #include <SADXModLoader.h>
 #include "FixCharacterMaterials.h"

-static HMODULE chrmodels_handle;
+static HMODULE chrmodels_handle = nullptr;

 inline int get_handle()
 {
@@ -159,13 +159,13 @@
 	DataPointer(NJS_MATERIAL, mat_00012358, (0x00012358 + handle));
 	DataPointer(NJS_MATERIAL, mat_0011BB58, (0x0011BB58 + handle));

-	mat_00565C68.attrflags |= NJD_FLAG_IGNORE_SPECULAR; // Sonic's nose
-	mat_00426F18.attrflags |= NJD_FLAG_IGNORE_SPECULAR; // Tails' eye whites
-	mat_00426F2C.attrflags |= NJD_FLAG_IGNORE_SPECULAR; // Tails' nose
-	mat_002DD8FC.attrflags |= NJD_FLAG_IGNORE_SPECULAR; // Knuckles' nose
+	mat_00565C68.attrflags |=  NJD_FLAG_IGNORE_SPECULAR; // Sonic's nose
+	mat_00426F18.attrflags |=  NJD_FLAG_IGNORE_SPECULAR; // Tails' eye whites
+	mat_00426F2C.attrflags |=  NJD_FLAG_IGNORE_SPECULAR; // Tails' nose
+	mat_002DD8FC.attrflags |=  NJD_FLAG_IGNORE_SPECULAR; // Knuckles' nose
 	mat_002DD1E4.attrflags &= ~NJD_FLAG_IGNORE_SPECULAR; // Knuckles' eye whites
 	mat_002E9C64.attrflags &= ~NJD_FLAG_IGNORE_SPECULAR; // Knuckles' eye whites
-	mat_00012358.attrflags |= NJD_FLAG_IGNORE_SPECULAR; // Amy's nose
-	mat_0011BB58.attrflags |= NJD_FLAG_IGNORE_SPECULAR; // Amy's nose
+	mat_00012358.attrflags |=  NJD_FLAG_IGNORE_SPECULAR; // Amy's nose
+	mat_0011BB58.attrflags |=  NJD_FLAG_IGNORE_SPECULAR; // Amy's nose

 }


Fixed compiler errors

Fixed compiler errors

--- src/secnet.cpp
+++ src/secnet.cpp
@@ -1,13 +1,17 @@
+#include <iostream>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
 #include "../include/secnet.h"

-void SecNet::Initialize(std::string listen, std::string certificateFile, std::string privateKeyFile, std::string dhParamFile, std::string tlsCipherList)
+void SecNet::Initialize(std::string listenAddress, std::string certificateFile, std::string privateKeyFile, std::string dhParamFile, std::string tlsCipherList)
 {
 	SSL_library_init();
 	SSL_load_error_strings();
 	SSL_METHOD* serverMethod = (SSL_METHOD*)TLSv1_2_server_method();
 	SSL_CTX* serverContext = SSL_CTX_new(serverMethod);

-	if(!sslServerContext)
+	if(!serverContext)
 	{
 		std::cout << "SSL_CTX_new() failed!" << std::endl;
 		exit(-1);
@@ -25,7 +29,7 @@

 	if(status <= 0)
 	{
-		std::cout << "Could not load private-key-file!" << std::endl:
+		std::cout << "Could not load private-key-file!" << std::endl;
 		exit(-1);
 	}

@@ -44,7 +48,9 @@
 		exit(-1);
 	}

-	DH* dh = PEM_read_DHparams(dhParamFile.c_str(), NULL, NULL, NULL);
+	FILE* dhFile = fopen(dhParamFile.c_str(), "rb");
+	DH* dh = PEM_read_DHparams(dhFile, NULL, NULL, NULL);
+	fclose(dhFile);
 	status = SSL_CTX_set_tmp_dh(serverContext, dh);

 	if(status <= 0)
@@ -75,7 +81,7 @@
 	struct sockaddr_in6 address;
 	bzero(&address, sizeof(address));
 	address.sin6_family = AF_INET6;
-	address.sin6_port = htons(DefaultPort);
+	address.sin6_port = htons(SecNet::DefaultPort);
 	address.sin6_addr = in6addr_any;

 	status = bind(_serverSocket, (struct sockaddr*)&address, sizeof(address));
@@ -96,3 +102,5 @@

 	ListenLoop(serverContext);
 }
+
+


This is not an llvm stream!

This is not an llvm stream!

--- hist/hist/src/TFitResult.cxx
+++ hist/hist/src/TFitResult.cxx
@@ -87,8 +87,7 @@
 /// Print the TFitResult.

 std::string cling::printValue(const TFitResult* val) {
-   std::string buf;
-   std::stringstream outs(buf);
+   std::stringstream outs;
    val->ROOT::Fit::FitResult::Print(outs, false /*doCovMat*/);
-   return buf;
+   return outs.str();
 }


cleaned up grabStill(), grabVideo(), grabFrame()

--- src/Camera.cpp
+++ src/Camera.cpp
@@ -450,29 +450,13 @@
 		setTransmit(false);
 		flushBuffer();
 		dc1394_video_set_one_shot(camera, DC1394_ON);
-		// if possible, the following should be replaced with a call to grabFrame
-		dc1394video_frame_t *frame;
-		dc1394_capture_dequeue(camera, capturePolicy, &frame);
-		img.allocate(width, height, imageType);
-		unsigned char* src = frame->image;
-		unsigned char* dst = img.getPixels();
-		if(imageType == OF_IMAGE_GRAYSCALE) {
-			memcpy(dst, src, width * height);
-		} else if(imageType == OF_IMAGE_COLOR) {
-			unsigned int bits = width * height * img.getPixelsRef().getBitsPerPixel();
-			dc1394_convert_to_RGB8(src, dst, width, height, 0, getLibdcType(imageType), bits);
-		}
-		dc1394_capture_enqueue(camera, frame);
+		grabFrame(img);
 	}
 }

 bool Camera::grabVideo(ofImage& img, bool dropFrames) {
 	if(camera) {
 		setTransmit(true);
-		// don't trust allocate() to be smart
-		if(img.getWidth() != width || img.getHeight() != height) {
-			img.allocate(width, height, imageType);
-		}
 		if(dropFrames) {
 			bool remaining;
 			int i = 0;
@@ -496,6 +480,10 @@
 		dc1394video_frame_t *frame;
 		dc1394_capture_dequeue(camera, capturePolicy, &frame);
 		if(frame != NULL) {
+			// don't trust allocate() to be smart. should also check for imageType change.
+			if(img.getWidth() != width || img.getHeight() != height) {
+				img.allocate(width, height, imageType);
+			}
 			unsigned char* src = frame->image;
 			unsigned char* dst = img.getPixels();
 			if(imageType == OF_IMAGE_GRAYSCALE) {


Small fixes in doc/example.cpp.

Small fixes in doc/example.cpp.

git-svn-id: 6c2b1bd10c324c49ea9d9e6e31006a80e70507cb@1413 5242fede-7e19-0410-aef8-94bd7d2200fb

--- doc/example.cpp
+++ doc/example.cpp
@@ -321,7 +321,7 @@
 	//	shapefactory.setHeight(radius);
 	//	shapefactory.setWidth(radius);
 	return shapefactory.createCircle();
-};
+}

 //
 // This function uses GeometricShapeFactory to render
@@ -335,7 +335,7 @@
 	shapefactory.setHeight(height);
 	shapefactory.setWidth(width);
 	return shapefactory.createCircle();
-};
+}

 //
 // This function uses GeometricShapeFactory to render
@@ -352,7 +352,7 @@
 	shapefactory.setNumPoints(4); // we don't need more then 4 points for a rectangle...
 	// can use setSize for a square
 	return shapefactory.createRectangle();
-};
+}

 //
 // This function uses GeometricShapeFactory to render
@@ -369,7 +369,7 @@
 	// shapefactory.setNumPoints(100); // the default (100 pts)
 	// can use setSize for a square
 	return shapefactory.createArc(startang, endang);
-};
+}

 // Start reading here
 void do_all()
@@ -1087,6 +1087,9 @@

 /**********************************************************************
  * $Log$
+ * Revision 1.46  2006/04/09 11:07:54  mloskot
+ * Small fixes in doc/example.cpp.
+ *
  * Revision 1.45  2006/04/04 08:16:46  strk
  * Changed GEOSException hierarchy to be derived from std::runtime_exception.
  * Removed the GEOSException::toString redundant method (use ::what() instead)


テストコード修正

テストコード修正

git-svn-id: a96bd3a1dbf41cfa227a3340720cc8125cc9349e@9039 1ed66053-1c2d-0410-8867-f7571e6e31d3

--- l7vsd/unit_tests/session_test/tcp_session/tcp_session_test.cpp
+++ l7vsd/unit_tests/session_test/tcp_session/tcp_session_test.cpp
@@ -12486,6 +12486,10 @@
         bool& get_exit_flag(){
             return exit_flag;
         };
+
+        bool test_call(SSL *clear_ssl){
+            return ssl_clear_keep_cache(clear_ssl);
+        };
 };

 //ssl_clear_keep_cache_test test
@@ -12563,7 +12567,7 @@
     BOOST_CHECK(test_sock.impl()->ssl->compress != NULL);

     test_sock.impl()->ssl->first_packet = 1;  //0
-    test_sock.impl()->ssl->session = 99;      //NULL;
+    test_sock.impl()->ssl->session = (SSL_SESSION*)99;      //NULL;
     test_sock.impl()->ssl->type = 2;          //0;
     test_sock.impl()->ssl->error = 3;         //0;
     test_sock.impl()->ssl->hit = 4;           //0;
@@ -12602,7 +12606,7 @@

     ssl_clear_keep_cache_test_class test_obj(vs,io,set_option,listen_endpoint,set_mode,set_context,set_ssl_cache_flag,set_ssl_handshake_time_out,plogger);

-    test_obj.ssl_clear_keep_cache(test_sock.impl()->ssl);
+    test_obj.test_call(test_sock.impl()->ssl);

     BOOST_CHECK(test_sock.impl()->ssl->clear_ssl->method == NULL);


COMP: Method names changed to avoid Windows name mangling.

--- IO/vtkSQLDatabase.cxx
+++ IO/vtkSQLDatabase.cxx
@@ -33,7 +33,7 @@

 #include <vtksys/SystemTools.hxx>

-vtkCxxRevisionMacro(vtkSQLDatabase, "1.9");
+vtkCxxRevisionMacro(vtkSQLDatabase, "1.10");

 // ----------------------------------------------------------------------
 vtkSQLDatabase::vtkSQLDatabase()
@@ -93,7 +93,7 @@
     post_db->SetUserName(username.c_str());
     post_db->SetPassword(password.c_str());
     post_db->SetHostName(hostname.c_str());
-    post_db->SetPort(atoi(dataport.c_str()));
+    post_db->SetServerPort(atoi(dataport.c_str()));
     post_db->SetDatabaseName(database.c_str());
     }
 #endif // VTK_USE_POSTGRES
@@ -105,7 +105,7 @@
     mysql_db->SetUserName(username.c_str());
     mysql_db->SetPassword(password.c_str());
     mysql_db->SetHostName(hostname.c_str());
-    mysql_db->SetPort(atoi(dataport.c_str()));
+    mysql_db->SetServerPort(atoi(dataport.c_str()));
     mysql_db->SetDatabaseName(database.c_str());
     }
 #endif // VTK_USE_MYSQL


stt: use double in write_svg for small tree accuracy

Signed-off-by: Matt Liberty <44ef1ce0ef6935daf739a0795dad249ba5322e97@eng.ucsd.edu>


Improve the low processor mode sleep precision

The Low Processor Usage Mode Sleep Usec setting is now used as a
FPS limiter rather than a constant sleep duration.

This will increase CPU/GPU usage slightly due to the higher
effective FPS, but the increase in overall smoothness is worth it.

If both Force Fps and Low Processor Usage Mode settings are enabled
in the project settings, only the setting that causes the highest
sleep duration will be retained.

This closes #11030.

(cherry picked from commit 1c28b269d8e691c9da2605c712120864ee1b467f)

--- main/main.cpp
+++ main/main.cpp
@@ -2163,22 +2163,37 @@
 	if (fixed_fps != -1)
 		return exit;

-	if (OS::get_singleton()->is_in_low_processor_usage_mode() || !OS::get_singleton()->can_draw())
-		OS::get_singleton()->delay_usec(OS::get_singleton()->get_low_processor_usage_mode_sleep_usec()); //apply some delay to force idle time
-	else {
-		uint32_t frame_delay = Engine::get_singleton()->get_frame_delay();
-		if (frame_delay)
-			OS::get_singleton()->delay_usec(Engine::get_singleton()->get_frame_delay() * 1000);
-	}
-
-	int target_fps = Engine::get_singleton()->get_target_fps();
+	const uint32_t frame_delay = Engine::get_singleton()->get_frame_delay();
+	if (frame_delay) {
+		// Add fixed frame delay to decrease CPU/GPU usage. This doesn't take
+		// the actual frame time into account.
+		// Due to the high fluctuation of the actual sleep duration, it's not recommended
+		// to use this as a FPS limiter.
+		OS::get_singleton()->delay_usec(frame_delay * 1000);
+	}
+
+	// Add a dynamic frame delay to decrease CPU/GPU usage. This takes the
+	// previous frame time into account for a smoother result.
+	uint64_t dynamic_delay = 0;
+	if (OS::get_singleton()->is_in_low_processor_usage_mode() || !OS::get_singleton()->can_draw()) {
+		dynamic_delay = OS::get_singleton()->get_low_processor_usage_mode_sleep_usec();
+	}
+	const int target_fps = Engine::get_singleton()->get_target_fps();
 	if (target_fps > 0 && !Engine::get_singleton()->is_editor_hint()) {
-		uint64_t time_step = 1000000L / target_fps;
-		target_ticks += time_step;
+		// Override the low processor usage mode sleep delay if the target FPS is lower.
+		dynamic_delay = MAX(dynamic_delay, (uint64_t)(1000000 / target_fps));
+	}
+
+	if (dynamic_delay > 0) {
+		target_ticks += dynamic_delay;
 		uint64_t current_ticks = OS::get_singleton()->get_ticks_usec();
-		if (current_ticks < target_ticks) OS::get_singleton()->delay_usec(target_ticks - current_ticks);
+
+		if (current_ticks < target_ticks) {
+			OS::get_singleton()->delay_usec(target_ticks - current_ticks);
+		}
+
 		current_ticks = OS::get_singleton()->get_ticks_usec();
-		target_ticks = MIN(MAX(target_ticks, current_ticks - time_step), current_ticks + time_step);
+		target_ticks = MIN(MAX(target_ticks, current_ticks - dynamic_delay), current_ticks + dynamic_delay);
 	}

 #ifdef TOOLS_ENABLED


Remove implementation file of class template

--- Core/Sources/Implementations/Learning/backpropagation.hpp
+++ Core/Sources/Implementations/Learning/backpropagation.hpp
@@ -1,8 +0,0 @@
-#include "backpropagation.hpp"
-
-using namespace Convolutional::Learning;
-
-auto Backpropagation::IsFinished() -> bool {
-static int runs = 2;
-return !runs--;
-}


Refactoring math dir : deleting unused functions from discrete.cc

--- fastlib/branches/fastlib-stl/fastlib/math/discrete.cc
+++ fastlib/branches/fastlib-stl/fastlib/math/discrete.cc
@@ -29,52 +29,3 @@
   }
   return nchsk;
 }
-
-double math::Factorial(int d) {
-  double v = 1;
-
-  mlpack::IO::Assert(d >= 0);
-
-  for (int i = 2; i <= d; i++) {
-    v *= i;
-  }
-
-  return v;
-}
-
-void math::MakeIdentityPermutation(size_t size, size_t *array) {
-  for (size_t i = 0; i < size; i++) {
-    array[i] = i;
-  }
-}
-
-void math::MakeIdentityPermutation(size_t size, std::vector<size_t>& result) {
-  result.reserve(size);
-
-  for (size_t i = 0; i < size; i++)
-    result.push_back(i);
-}
-void math::MakeRandomPermutation(size_t size, size_t *array) {
-  // Regular permutation algorithm.
-  // This is cache inefficient for large sizes; large caches might
-  // warrant a more sophisticated blocked algorithm.
-
-  if (size == 0) {
-    return;
-  }
-
-  array[0] = 0;
-
-  for (size_t i = 1; i < size; i++) {
-    size_t victim = rand() % i;
-    array[i] = array[victim];
-    array[victim] = i;
-  }
-}
-
-void math::MakeInversePermutation(size_t size,
-    const size_t *original, size_t *reverse) {
-  for (size_t i = 0; i < size; i++) {
-    reverse[original[i]] = i;
-  }
-}