YUY2ToI420 handle unaligned pointers
BUG=none
TEST=none
Review URL: http://webrtc-codereview.appspot.com/329001

git-svn-id: a51711482b6ba0e1d1ab095578a045eeae45ac9a@111 16f28f9a-4ce2-e073-06de-1de4eb20be90

--- source/planar_functions.cc
+++ source/planar_functions.cc
@@ -928,6 +928,7 @@
     mov        ecx, [esp + 8 + 20]   // pix
     pcmpeqb    xmm5, xmm5            // generate mask 0x00ff00ff
     psrlw      xmm5, 8
+    sub        edi, edx

   convertloop:
     movdqa     xmm0, [eax]
@@ -943,12 +944,79 @@
     movdqa     xmm1, xmm0
     pand       xmm0, xmm5  // U
     packuswb   xmm0, xmm0
-    movq       qword ptr [edx], xmm0
-    lea        edx, [edx + 8]
     psrlw      xmm1, 8     // V
     packuswb   xmm1, xmm1
-    movq       qword ptr [edi], xmm1
-    lea        edi, [edi + 8]
+    movq       qword ptr [edx], xmm0
+    movq       qword ptr [edx + edi], xmm1
+    lea        edx, [edx + 8]
+    sub        ecx, 16
+    ja         convertloop
+
+    pop        edi
+    pop        esi
+    ret
+  }
+}
+
+__declspec(naked)
+void YUY2ToI420RowY_Unaligned_SSE2(const uint8* src_yuy2,
+                                   uint8* dst_y, int pix) {
+  __asm {
+    mov        eax, [esp + 4]    // src_yuy2
+    mov        edx, [esp + 8]    // dst_y
+    mov        ecx, [esp + 12]   // pix
+    pcmpeqb    xmm5, xmm5        // generate mask 0x00ff00ff
+    psrlw      xmm5, 8
+
+  convertloop:
+    movdqu     xmm0, [eax]
+    movdqu     xmm1, [eax + 16]
+    lea        eax,  [eax + 32]
+    pand       xmm0, xmm5   // even bytes are Y
+    pand       xmm1, xmm5
+    packuswb   xmm0, xmm1
+    movdqu     [edx], xmm0
+    lea        edx, [edx + 16]
+    sub        ecx, 16
+    ja         convertloop
+    ret
+  }
+}
+
+__declspec(naked)
+void YUY2ToI420RowUV_Unaligned_SSE2(const uint8* src_yuy2, int stride_yuy2,
+                                    uint8* dst_u, uint8* dst_y, int pix) {
+  __asm {
+    push       esi
+    push       edi
+    mov        eax, [esp + 8 + 4]    // src_yuy2
+    mov        esi, [esp + 8 + 8]    // stride_yuy2
+    mov        edx, [esp + 8 + 12]   // dst_u
+    mov        edi, [esp + 8 + 16]   // dst_v
+    mov        ecx, [esp + 8 + 20]   // pix
+    pcmpeqb    xmm5, xmm5            // generate mask 0x00ff00ff
+    psrlw      xmm5, 8
+    sub        edi, edx
+
+  convertloop:
+    movdqu     xmm0, [eax]
+    movdqu     xmm1, [eax + 16]
+    movdqu     xmm2, [eax + esi]
+    movdqu     xmm3, [eax + esi + 16]
+    lea        eax,  [eax + 32]
+    pavgb      xmm0, xmm2
+    pavgb      xmm1, xmm3
+    psrlw      xmm0, 8      // YUYV -> UVUV
+    psrlw      xmm1, 8
+    packuswb   xmm0, xmm1
+    movdqa     xmm1, xmm0
+    pand       xmm0, xmm5  // U
+    packuswb   xmm0, xmm0
+    psrlw      xmm1, 8     // V
+    packuswb   xmm1, xmm1
+    movq       qword ptr [edx], xmm0
+    movq       qword ptr [edx + edi], xmm1
+    lea        edx, [edx + 8]
     sub        ecx, 16
     ja         convertloop

@@ -995,6 +1063,7 @@
     mov        ecx, [esp + 8 + 20]   // pix
     pcmpeqb    xmm5, xmm5            // generate mask 0x00ff00ff
     psrlw      xmm5, 8
+    sub        edi, edx

   convertloop:
     movdqa     xmm0, [eax]
@@ -1010,12 +1079,11 @@
     movdqa     xmm1, xmm0
     pand       xmm0, xmm5  // U
     packuswb   xmm0, xmm0
-    movq       qword ptr [edx], xmm0
-    lea        edx, [edx + 8]
     psrlw      xmm1, 8     // V
     packuswb   xmm1, xmm1
-    movq       qword ptr [edi], xmm1
-    lea        edi, [edi + 8]
+    movq       qword ptr [edx], xmm0
+    movq       qword ptr [edx + edi], xmm1
+    lea        edx, [edx + 8]
     sub        ecx, 16
     ja         convertloop

@@ -1060,6 +1128,7 @@
   asm volatile (
   "pcmpeqb    %%xmm5,%%xmm5                    \n"
   "psrlw      $0x8,%%xmm5                      \n"
+  "sub        %1,%2                            \n"
 "1:                                            \n"
   "movdqa     (%0),%%xmm0                      \n"
   "movdqa     0x10(%0),%%xmm1                  \n"
@@ -1074,12 +1143,78 @@
   "movdqa     %%xmm0,%%xmm1                    \n"
   "pand       %%xmm5,%%xmm0                    \n"
   "packuswb   %%xmm0,%%xmm0                    \n"
-  "movq       %%xmm0,(%1)                      \n"
-  "lea        0x8(%1),%1                       \n"
   "psrlw      $0x8,%%xmm1                      \n"
   "packuswb   %%xmm1,%%xmm1                    \n"
-  "movq       %%xmm1,(%2)                      \n"
-  "lea        0x8(%2),%2                       \n"
+  "movq       %%xmm0,(%1)                      \n"
+  "movq       %%xmm1,(%1,%2)                   \n"
+  "lea        0x8(%1),%1                       \n"
+  "sub        $0x10,%3                         \n"
+  "ja         1b                               \n"
+  : "+r"(src_yuy2),    // %0
+    "+r"(dst_u),       // %1
+    "+r"(dst_y),       // %2
+    "+r"(pix)          // %3
+  : "r"(static_cast<intptr_t>(stride_yuy2))  // %4
+  : "memory", "cc"
+#if defined(__SSE2__)
+    , "xmm0", "xmm1", "xmm2", "xmm3", "xmm5"
+#endif
+);
+}
+static void YUY2ToI420RowY_Unaligned_SSE2(const uint8* src_yuy2,
+                                          uint8* dst_y, int pix) {
+  asm volatile (
+  "pcmpeqb    %%xmm5,%%xmm5                    \n"
+  "psrlw      $0x8,%%xmm5                      \n"
+"1:                                            \n"
+  "movdqu     (%0),%%xmm0                      \n"
+  "movdqu     0x10(%0),%%xmm1                  \n"
+  "lea        0x20(%0),%0                      \n"
+  "pand       %%xmm5,%%xmm0                    \n"
+  "pand       %%xmm5,%%xmm1                    \n"
+  "packuswb   %%xmm1,%%xmm0                    \n"
+  "movdqu     %%xmm0,(%1)                      \n"
+  "lea        0x10(%1),%1                      \n"
+  "sub        $0x10,%2                         \n"
+  "ja         1b                               \n"
+  : "+r"(src_yuy2),  // %0
+    "+r"(dst_y),     // %1
+    "+r"(pix)        // %2
+  :
+  : "memory", "cc"
+#if defined(__SSE2__)
+    , "xmm0", "xmm1", "xmm5"
+#endif
+);
+}
+
+static void YUY2ToI420RowUV_Unaligned_SSE2(const uint8* src_yuy2,
+                                           int stride_yuy2,
+                                           uint8* dst_u, uint8* dst_y,
+                                           int pix) {
+  asm volatile (
+  "pcmpeqb    %%xmm5,%%xmm5                    \n"
+  "psrlw      $0x8,%%xmm5                      \n"
+  "sub        %1,%2                            \n"
+"1:                                            \n"
+  "movdqu     (%0),%%xmm0                      \n"
+  "movdqu     0x10(%0),%%xmm1                  \n"
+  "movdqu     (%0,%4,1),%%xmm2                 \n"
+  "movdqu     0x10(%0,%4,1),%%xmm3             \n"
+  "lea        0x20(%0),%0                      \n"
+  "pavgb      %%xmm2,%%xmm0                    \n"
+  "pavgb      %%xmm3,%%xmm1                    \n"
+  "psrlw      $0x8,%%xmm0                      \n"
+  "psrlw      $0x8,%%xmm1                      \n"
+  "packuswb   %%xmm1,%%xmm0                    \n"
+  "movdqa     %%xmm0,%%xmm1                    \n"
+  "pand       %%xmm5,%%xmm0                    \n"
+  "packuswb   %%xmm0,%%xmm0                    \n"
+  "psrlw      $0x8,%%xmm1                      \n"
+  "packuswb   %%xmm1,%%xmm1                    \n"
+  "movq       %%xmm0,(%1)                      \n"
+  "movq       %%xmm1,(%1,%2)                   \n"
+  "lea        0x8(%1),%1                       \n"
   "sub        $0x10,%3                         \n"
   "ja         1b                               \n"
   : "+r"(src_yuy2),    // %0
@@ -1124,6 +1259,7 @@
   asm volatile (
   "pcmpeqb    %%xmm5,%%xmm5                    \n"
   "psrlw      $0x8,%%xmm5                      \n"
+  "sub        %1,%2                            \n"
 "1:                                            \n"
   "movdqa     (%0),%%xmm0                      \n"
   "movdqa     0x10(%0),%%xmm1                  \n"
@@ -1138,12 +1274,11 @@
   "movdqa     %%xmm0,%%xmm1                    \n"
   "pand       %%xmm5,%%xmm0                    \n"
   "packuswb   %%xmm0,%%xmm0                    \n"
-  "movq       %%xmm0,(%1)                      \n"
-  "lea        0x8(%1),%1                       \n"
   "psrlw      $0x8,%%xmm1                      \n"
   "packuswb   %%xmm1,%%xmm1                    \n"
-  "movq       %%xmm1,(%2)                      \n"
-  "lea        0x8(%2),%2                       \n"
+  "movq       %%xmm0,(%1)                      \n"
+  "movq       %%xmm1,(%1,%2)                   \n"
+  "lea        0x8(%1),%1                       \n"
   "sub        $0x10,%3                         \n"
   "ja         1b                               \n"
   : "+r"(src_uyvy),    // %0
@@ -1221,14 +1356,18 @@
   void (*YUY2ToI420RowY)(const uint8* src_yuy2,
                          uint8* dst_y, int pix);
 #if defined(HAS_YUY2TOI420ROW_SSE2)
-  if (TestCpuFlag(kCpuHasSSE2) &&
-      IS_ALIGNED(width, 16) &&
-      IS_ALIGNED(src_yuy2, 16) && IS_ALIGNED(src_stride_yuy2, 16) &&
-      IS_ALIGNED(dst_y, 16) && IS_ALIGNED(dst_stride_y, 16) &&
-      IS_ALIGNED(dst_u, 8) && IS_ALIGNED(dst_stride_u, 8) &&
-      IS_ALIGNED(dst_v, 8) && IS_ALIGNED(dst_stride_v, 8)) {
-    YUY2ToI420RowY = YUY2ToI420RowY_SSE2;
-    YUY2ToI420RowUV = YUY2ToI420RowUV_SSE2;
+  if (TestCpuFlag(kCpuHasSSE2) && IS_ALIGNED(width, 16)) {
+    if (IS_ALIGNED(src_yuy2, 16) && IS_ALIGNED(src_stride_yuy2, 16)) {
+      YUY2ToI420RowUV = YUY2ToI420RowUV_SSE2;
+    } else {
+      YUY2ToI420RowUV = YUY2ToI420RowUV_Unaligned_SSE2;
+    }
+    if (IS_ALIGNED(src_yuy2, 16) && IS_ALIGNED(src_stride_yuy2, 16) &&
+        IS_ALIGNED(dst_y, 16) && IS_ALIGNED(dst_stride_y, 16)) {
+      YUY2ToI420RowY = YUY2ToI420RowY_SSE2;
+    } else {
+      YUY2ToI420RowY = YUY2ToI420RowY_Unaligned_SSE2;
+    }
   } else
 #endif
   {


Fixed the instruction emulation so that it doesn't
print to standard output as part of normal
operation.

<rdar://problem/14247606>

git-svn-id: 4c4cc70b1ef44ba2b7963015e681894188cea27e@184797 91177308-0d34-0410-b5e6-96231b3b80d8

--- source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -50,7 +50,9 @@
     uint32_t TZ = llvm::countTrailingZeros(ITMask);
     if (TZ > 3)
     {
+#ifdef LLDB_CONFIGURATION_DEBUG
         printf("Encoding error: IT Mask '0000'\n");
+#endif
         return 0;
     }
     return (4 - TZ);
@@ -67,12 +69,16 @@
     unsigned short FirstCond = Bits32(bits7_0, 7, 4);
     if (FirstCond == 0xF)
     {
+#ifdef LLDB_CONFIGURATION_DEBUG
         printf("Encoding error: IT FirstCond '1111'\n");
+#endif
         return false;
     }
     if (FirstCond == 0xE && ITCounter != 1)
     {
+#ifdef LLDB_CONFIGURATION_DEBUG
         printf("Encoding error: IT FirstCond '1110' && Mask != '1000'\n");
+#endif
         return false;
     }


BUG #12101: Additional fix.

BUG #12101: Additional fix.

--- sql/item_cmpfunc.cc
+++ sql/item_cmpfunc.cc
@@ -983,6 +983,8 @@
 {
   str->append('(');
   args[0]->print(str);
+  if (negated)
+    str->append(" not", 4);
   str->append(" between ", 9);
   args[1]->print(str);
   str->append(" and ", 5);
@@ -1969,6 +1971,8 @@
 {
   str->append('(');
   args[0]->print(str);
+  if (negated)
+    str->append(" not", 4);
   str->append(" in (", 5);
   print_args(str, 1);
   str->append("))", 2);


Made tpl::Parser keep attributes in the order of occurrence

--- source/template/Parser.cpp
+++ source/template/Parser.cpp
@@ -169,10 +169,17 @@
             //name, id and class
             struct Attr
             {
+                std::string name;
                 std::vector<std::string> static_values;
                 std::vector<expr::ExpressionNodePtr> dynamic_values;
             };
-            std::unordered_map<std::string, Attr> attributes;
+            std::vector<Attr> attributes;
+            auto get_attr = [&attributes](const std::string &name) -> Attr&
+            {
+                for (auto &attr : attributes) if (attr.name == name) return attr;
+                attributes.push_back({ name,{},{} });
+                return attributes.back();
+            };

             std::string tag_name;
             if (current_token.type == Token::NAME)
@@ -184,13 +191,13 @@
             if (current_token.type == Token::TAG_ID)
             {
                 current_token = lexer.next_name();
-                attributes["id"].static_values.push_back(current_token.str);
+                get_attr("id").static_values.push_back(current_token.str);
                 current_token = lexer.next_tag_content();
             }
             while (current_token.type == Token::TAG_CLASS)
             {
                 current_token = lexer.next_name();
-                attributes["class"].static_values.push_back(current_token.str);
+                get_attr("class").static_values.push_back(current_token.str);
                 current_token = lexer.next_tag_content();
             }

@@ -242,12 +249,12 @@
                     }
                     else
                     {
-                        attributes[attr].static_values.push_back(lit->value->to_string());
+                        get_attr(attr).static_values.push_back(lit->value->to_string());
                     }
                 }
                 else
                 {
-                    attributes[attr].dynamic_values.push_back(std::move(expr));
+                    get_attr(attr).dynamic_values.push_back(std::move(expr));
                 }

                 current_token = lexer.next_tag_content();
@@ -255,20 +262,20 @@

             for (auto &attr : attributes)
             {
-                if (attr.second.dynamic_values.empty())
-                {
-                    assert(attr.second.static_values.size() > 0);
-                    output << attr_str(attr.first, attr.second.static_values);
+                if (attr.dynamic_values.empty())
+                {
+                    assert(attr.static_values.size() > 0);
+                    output << attr_str(attr.name, attr.static_values);
                 }
             }
             for (auto &attr : attributes)
             {
-                if (!attr.second.dynamic_values.empty())
+                if (!attr.dynamic_values.empty())
                 {
                     output << slim::make_unique<TemplateTagAttr>(
-                        attr.first,
-                        std::move(attr.second.static_values),
-                        std::move(attr.second.dynamic_values));
+                        attr.name,
+                        std::move(attr.static_values),
+                        std::move(attr.dynamic_values));
                 }
             }


Improved shuffle algorithm performance.

Improved shuffle algorithm performance.

--- randomizer.cpp
+++ randomizer.cpp
@@ -41,8 +41,6 @@
 	int arg = 0;
 	int error = 0;
 	vector<int> lines;
-	vector<int>* indexes = NULL;
-	map<int, int>* usedIndexes = NULL;
 	const char* fileName = NULL;
 	const char* outputFileName = NULL;
 	srand(time(NULL));
@@ -126,84 +124,51 @@

 			for(int i = 0; i < iterations; i++)
 			{
-				if(indexes != NULL)
-				{
-					delete indexes;
-					indexes = NULL;
-				}
-
 				#ifdef _DEBUG_
 				cout << "Iteration: " << (i + 1) << endl;
 				#endif

-				usedIndexes = new map<int, int>();
-				indexes = new vector<int>();
+				for(int r = lines.size() - 1; r > 0; r--)
+				{
+					int j = rand() % r;

-				for(int k = 0; k < lines.size(); k++)
-				{
-					int index = -1;
-					do
+					if(j > -1)
 					{
-						index = rand() % lines.size();
-					}
-					while(usedIndexes->find(index)
-						 != usedIndexes->end());
+						int val1 = lines[r];
+						int val2 = lines[j];

-					if(index > -1 && index < lines.size())
-					{
-						usedIndexes->operator[](index) = 0;
-						indexes->push_back(index);
+						lines[r] = val2;
+						lines[j] = val1;
 					}
 				}
-
-				for(int r = 0; r < lines.size(); r++)
-				{
-					int val1 = lines[r];
-					int val2 = lines[indexes->operator[](r)];
-
-					lines[r] = val2;
-					lines[indexes->operator[](r)] = val1;
-				}
-
-				delete usedIndexes;
-				usedIndexes = NULL;
 			}

 			inFile.clear();

+			ofstream outFile(outputFileName, ofstream::out);

-			if(indexes != NULL)
+			if(outFile)
 			{
-				ofstream outFile(outputFileName, ofstream::out);
+				for(int i = 0; i < lines.size(); i++)
+				{
+					int p = lines[i];

-				if(outFile)
-				{
-					for(vector<int>::iterator i = indexes->begin();
-						i != indexes->end();
-						++i)
-					{
-						int p = lines[*i];
-
-						string line;
-						inFile.seekg(p);
-						getline(inFile, line);
-						outFile << line << endl;
-					}
-
-					outFile.close();
+					string line;
+					inFile.seekg(p);
+					getline(inFile, line);
+					outFile << line << endl;
 				}

-				delete indexes;
-				indexes = NULL;
+				outFile.close();
 			}
+		}

-			inFile.close();
-			inFile.clear();
+		inFile.close();
+		inFile.clear();

-			#ifdef _DEBUG_
-			cout << "Processing finished." << endl;
-			#endif
-		}
+		#ifdef _DEBUG_
+		cout << "Processing finished." << endl;
+		#endif
 	}
 	else
 	{


replacing placeholder example token with the official one

--- examples/echo.cpp
+++ examples/echo.cpp
@@ -1,7 +1,7 @@
 #include "libtelegram/libtelegram.h"

 auto main()->int {
-  std::string const token("229029247:AAHfNUvcGS_ttvvulZG3Qi4NmMrjebH8F6w");     // in practice you would probably read this from config file or database
+  std::string const token("bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11");      // in practice you would probably read this from config file or database
   telegram::listener listener;                                                  // create a listener which will process incoming requests
   telegram::sender sender(token);                                               // create a sender with our token for outgoing messages
   listener.set_callback_message([&](boost::property_tree::ptree const &input){  // we set a callback for receiving messages, using a lambda for convenience


Indentation fix.

Indentation fix.

git-svn-id: f4e1a40f847802203273bde8e26df4d11611876a@2614 44470bb9-56e9-0310-a0f8-c586564d3dc6

--- src/imaging/DeDistort.cpp
+++ src/imaging/DeDistort.cpp
@@ -74,15 +74,15 @@
 }

 DeDistort::DeDistort(const DPoint &CamExtents,
-            const std::vector<double>& DistortionParams,
-            double Angle, double TrapezoidFactor,
-            const DPoint& DisplayOffset, const DPoint& DisplayScale)
-      : m_CamExtents(CamExtents),
-        m_DistortionParams(DistortionParams),
-        m_Angle(Angle),
-        m_TrapezoidFactor(TrapezoidFactor),
-        m_DisplayOffset(DisplayOffset),
-        m_DisplayScale(DisplayScale)
+        const std::vector<double>& DistortionParams,
+        double Angle, double TrapezoidFactor,
+        const DPoint& DisplayOffset, const DPoint& DisplayScale)
+    : m_CamExtents(CamExtents),
+      m_DistortionParams(DistortionParams),
+      m_Angle(Angle),
+      m_TrapezoidFactor(TrapezoidFactor),
+      m_DisplayOffset(DisplayOffset),
+      m_DisplayScale(DisplayScale)
 {
     m_RescaleFactor = calc_rescale();
 }


Fix G__modify_type, the G__CONSTVAR needs to be applied
to the rawtype node, not the top node.

Fix G__test_static, G__AUTOARYDISCRETEOBJ needs to test
the statictype property directly.

-- Philippe Canal and Paul Russo

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

--- cint/cint7/src/rflxutil.cxx
+++ cint/cint7/src/rflxutil.cxx
@@ -1039,7 +1039,7 @@
    reftype = G__PLVL(reftype);
    ::Reflex::Type result = typein;
    if (isconst & G__CONSTVAR) {
-      result = ::Reflex::Type(result, ::Reflex::CONST, Reflex::Type::APPEND);
+     result = G__replace_rawtype( result,  ::Reflex::Type(result.RawType(), ::Reflex::CONST, Reflex::Type::APPEND) );
    }
    if (ispointer) {
       result = ::Reflex::PointerBuilder(result);
@@ -1315,7 +1315,7 @@
          }
          return false;
       case G__AUTOARYDISCRETEOBJ:
-         return !var.IsStatic() && var.TypeOf().FinalType().IsArray();
+         return G__get_properties(var)->statictype == G__AUTOARYDISCRETEOBJ;
       case G__COMPILEDGLOBAL:
          return G__get_properties(var)->isCompiledGlobal;
    }


Remove code rather than commenting it out

I originally commented out this code because I wasn't sure whether
it would work or not.  Now that it's passed testing, let's just
remove it to keep things cleaner.

--- compiler/resolution/functionResolution.cpp
+++ compiler/resolution/functionResolution.cpp
@@ -6144,25 +6144,6 @@
       issueCompilerError(call);
     }

-    // Resolve expressions of the form:  <type> ( args )
-    // These will be constructor calls (or type constructor calls) that slipped
-    // past normalization due to the use of typedefs.
-    /*
-    if (SymExpr* se = toSymExpr(call->baseExpr)) {
-      if (TypeSymbol* ts = toTypeSymbol(se->var)) {
-        if (call->numActuals() == 0 ||
-            (call->numActuals() == 2 && isSymExpr(call->get(1)) &&
-             toSymExpr(call->get(1))->var == gMethodToken)) {
-          // This looks like a typedef, so ignore it.
-
-        } else {
-          // More needed here ... .
-          INT_FATAL(ts, "not yet implemented.");
-        }
-      }
-    }
-    */
-
     callStack.add(call);

     resolveCall(call);


vtkSpaceCraftInfo:oops. forgot to turn something back on.

--- plugins/vtkSpaceCraftInfoFilter/ScInfoPropWidget.cpp
+++ plugins/vtkSpaceCraftInfoFilter/ScInfoPropWidget.cpp
@@ -111,8 +111,8 @@

     /** Property Links to trigger Apply button active */
     this->addPropertyLink(ui->Variables, smproxy->GetPropertyName(smproperty), SIGNAL(itemSelectionChanged()), this->svp);
-//    this->addPropertyLink(ui->startTime, smproxy->GetPropertyName(smproperty), SIGNAL(editingFinished()), this->svp);
-//    this->addPropertyLink(ui->endTime, smproxy->GetPropertyName(smproperty), SIGNAL(editingFinished()), this->svp);
+    this->addPropertyLink(ui->startTime, smproxy->GetPropertyName(smproperty), SIGNAL(editingFinished()), this->svp);
+    this->addPropertyLink(ui->endTime, smproxy->GetPropertyName(smproperty), SIGNAL(editingFinished()), this->svp);

 }


Make compile following renaming of class.

--- tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -514,7 +514,7 @@

 // Tests automatic connection to notify signals if "onBlahChanged" syntax is used
 // even if the notify signal for "blah" is not called "blahChanged"
-void tst_qmllanguage::autoNotifyConnection()
+void tst_qdeclarativelanguage::autoNotifyConnection()
 {
     QDeclarativeComponent component(&engine, TEST_FILE("autoNotifyConnection.qml"));
     VERIFY_ERRORS(0);


assume thread_local in AtFork

assume thread_local in AtFork

Reviewed By: Orvid

Differential Revision: D27671208

fbshipit-source-id: 44710468544eebbb8f4ed0ecd5621bce0b56d248

--- folly/detail/AtFork.cpp
+++ folly/detail/AtFork.cpp
@@ -30,38 +30,16 @@

 namespace {

-#if !FOLLY_MOBILE && !defined(__APPLE__) && !defined(_MSC_VER)
-#define FOLLY_ATFORK_USE_FOLLY_TLS 1
-#else
-#define FOLLY_ATFORK_USE_FOLLY_TLS 0
-#endif
+struct SkipAtForkHandlers {
+  static thread_local bool value;

-template <bool enabled = FOLLY_ATFORK_USE_FOLLY_TLS>
-struct SkipAtForkHandlers;
-
-template <>
-struct SkipAtForkHandlers<false> {
-  static bool available() { return false; }
-
-  static bool get() { return false; }
-
-  [[noreturn]] static void set(bool) { std::terminate(); }
+  struct Guard {
+    bool saved = value;
+    Guard() { value = true; }
+    ~Guard() { value = saved; }
+  };
 };
-
-#if FOLLY_ATFORK_USE_FOLLY_TLS
-template <>
-struct SkipAtForkHandlers<true> {
-  static bool available() { return true; }
-
-  static bool get() { return value_; }
-
-  static void set(bool value) { value_ = value; }
-
- private:
-  static thread_local bool value_;
-};
-thread_local bool SkipAtForkHandlers<true>::value_{false};
-#endif
+thread_local bool SkipAtForkHandlers::value;

 struct AtForkTask {
   void const* handle;
@@ -78,7 +56,7 @@
   }

   static void prepare() noexcept {
-    if (SkipAtForkHandlers<>::get()) {
+    if (SkipAtForkHandlers::value) {
       return;
     }
     instance().tasksLock.lock();
@@ -100,7 +78,7 @@
   }

   static void parent() noexcept {
-    if (SkipAtForkHandlers<>::get()) {
+    if (SkipAtForkHandlers::value) {
       return;
     }
     auto& tasks = instance().tasks;
@@ -111,7 +89,7 @@
   }

   static void child() noexcept {
-    if (SkipAtForkHandlers<>::get()) {
+    if (SkipAtForkHandlers::value) {
       return;
     }
     // if we fork a multithreaded process
@@ -181,20 +159,17 @@
 }

 pid_t AtFork::forkInstrumented(fork_t forkFn) {
-  if (SkipAtForkHandlers<>::available()) {
-    AtForkList::prepare();
-    SkipAtForkHandlers<>::set(true);
-    auto ret = forkFn();
-    SkipAtForkHandlers<>::set(false);
-    if (ret) {
-      AtForkList::parent();
-    } else {
-      AtForkList::child();
-    }
-    return ret;
+  AtForkList::prepare();
+  auto ret = [&] {
+    SkipAtForkHandlers::Guard guard;
+    return forkFn();
+  }();
+  if (ret) {
+    AtForkList::parent();
   } else {
-    return forkFn();
+    AtForkList::child();
   }
+  return ret;
 }
 } // namespace detail
 } // namespace folly


Use full model size in rnntest

Use full model size in rnntest

--- metal_stack/bin/rnntest.cc
+++ metal_stack/bin/rnntest.cc
@@ -24,7 +24,7 @@
 }

 int main() {
-  ModelSpec spec = {10, 10, 1, 10, 30, 10};//{300, 300, (size_t) atoi(getenv("BATCH_SIZE")), 10, 30, 300};
+  ModelSpec spec = {300, 300, (size_t) atoi(getenv("BATCH_SIZE")), 10, 30, 300};
   RNNParameters params = load_params(spec);

   cublasHandle_t handle;


Format

Format

--- c++/ensemble_image_client.cc
+++ c++/ensemble_image_client.cc
@@ -95,7 +95,8 @@
     std::cerr << "error: " << msg << std::endl;
   }

-  std::cerr << "Usage: " << argv[0] << " [options] <image filename / image folder>" << std::endl;
+  std::cerr << "Usage: " << argv[0]
+            << " [options] <image filename / image folder>" << std::endl;
   std::cerr << "\t-v" << std::endl;
   std::cerr << "\t-c <topk>" << std::endl;
   std::cerr << "\t-i <Protocol used to communicate with inference service>"
@@ -211,8 +212,9 @@
     auto& image_str = images.back();
     std::ifstream file(fn);
     file >> std::noskipws;
-    image_str.emplace_back((std::istreambuf_iterator<char>(file)),
-                  std::istreambuf_iterator<char>());
+    image_str.emplace_back(
+        (std::istreambuf_iterator<char>(file)),
+        std::istreambuf_iterator<char>());
     if (image_str.back().empty()) {
       std::cerr << "error: unable to read image file " << fn << std::endl;
       exit(1);


Warning fix.

Warning fix.

--- gfx_es2/draw_buffer.cpp
+++ gfx_es2/draw_buffer.cpp
@@ -401,7 +401,7 @@
 }

 void DrawBuffer::MeasureText(int font, const char *text, float *w, float *h) {
-	return MeasureTextCount(font, text, strlen(text), w, h);
+	return MeasureTextCount(font, text, (int)strlen(text), w, h);
 }

 void DrawBuffer::DrawTextShadow(int font, const char *text, float x, float y, Color color, int flags) {


Fix typos.

Fix typos.

git-svn-id: b33bab8abb5b18c12ee100cd7761ab452d00b2b0@125138 91177308-0d34-0410-b5e6-96231b3b80d8

--- source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -221,7 +221,7 @@
         EmulateInstruction::Context context = { EmulateInstruction::eContextPushRegisterOnStack, eRegisterKindDWARF, 0, 0 };
         for (i=0; i<15; ++i)
         {
-            if (BitIsSet (registers, 1u << i))
+            if (BitIsSet (registers, i))
             {
                 context.arg1 = dwarf_r0 + i;    // arg1 in the context is the DWARF register number
                 context.arg2 = addr - sp;       // arg2 in the context is the stack pointer offset
@@ -234,7 +234,7 @@
             }
         }

-        if (BitIsSet (registers, 1u << 15))
+        if (BitIsSet (registers, 15))
         {
             context.arg1 = dwarf_pc;    // arg1 in the context is the DWARF register number
             context.arg2 = addr - sp;   // arg2 in the context is the stack pointer offset
@@ -345,7 +345,7 @@
         EmulateInstruction::Context context = { EmulateInstruction::eContextPopRegisterOffStack, eRegisterKindDWARF, 0, 0 };
         for (i=0; i<15; ++i)
         {
-            if (BitIsSet (registers, 1u << i))
+            if (BitIsSet (registers, i))
             {
                 context.arg1 = dwarf_r0 + i;    // arg1 in the context is the DWARF register number
                 context.arg2 = addr - sp;       // arg2 in the context is the stack pointer offset
@@ -358,7 +358,7 @@
             }
         }

-        if (BitIsSet (registers, 1u << 15))
+        if (BitIsSet (registers, 15))
         {
             context.arg1 = dwarf_pc;    // arg1 in the context is the DWARF register number
             context.arg2 = addr - sp;   // arg2 in the context is the stack pointer offset


bpls refactor for BP5 data dump

bpls refactor for BP5 data dump

--- source/utils/bpls/bpls.cpp
+++ source/utils/bpls/bpls.cpp
@@ -2156,8 +2156,7 @@
  */
 template <class T>
 int readVarBlock(core::Engine *fp, core::IO *io, core::Variable<T> *variable,
-                 size_t step, size_t blockid,
-                 typename core::Variable<T>::BPInfo &blockinfo)
+                 size_t step, size_t blockid, Dims Count, Dims Start)
 {
     int i, j;
     uint64_t start_t[MAX_DIMS],
@@ -2210,21 +2209,21 @@
     for (j = 0; j < ndim; j++)
     {
         if (istart[j + tidx] < 0) // negative index means last-|index|
-            st = blockinfo.Count[j] + istart[j + tidx];
+            st = Count[j] + istart[j + tidx];
         else
             st = istart[j + tidx];
         if (icount[j + tidx] < 0) // negative index means last-|index|+1-start
-            ct = blockinfo.Count[j] + icount[j + tidx] + 1 - st;
+            ct = Count[j] + icount[j + tidx] + 1 - st;
         else
             ct = icount[j + tidx];

-        if (st > blockinfo.Count[j])
+        if (st > Count[j])
         {
             out_of_bound = 1;
         }
-        else if (ct > blockinfo.Count[j] - st)
-        {
-            ct = blockinfo.Count[j] - st;
+        else if (ct > Count[j] - st)
+        {
+            ct = Count[j] - st;
         }
         if (verbose > 2)
             printf("    j=%d, st=%" PRIu64 " ct=%" PRIu64 "\n", j, st, ct);
@@ -2243,7 +2242,7 @@
                nelems * elemsize);
     }

-    print_slice_info(variable, false, start_t, count_t, blockinfo.Count);
+    print_slice_info(variable, false, start_t, count_t, Count);

     if (out_of_bound)
         return 0;
@@ -2343,7 +2342,7 @@
         {
             for (j = 0; j < ndim; j++)
             {
-                startv[j] += blockinfo.Start[j];
+                startv[j] += Start[j];
             }
         }

@@ -3355,14 +3354,10 @@
                     fprintf(outf, "\n");
                     if (dump)
                     {
-                        static bool first = true;
-                        if (first)
-                        {
-                            printf("BP5 dump TBD\n");
-                            first = false;
-                        }
-                        //	readVarBlock(fp, io, variable, RelStep, j,
-                        // blocks[j]);
+                        readVarBlock(
+                            fp, io, variable, RelStep, j,
+                            Dims(blocks[j].Count, blocks[j].Count + ndim),
+                            Dims(blocks[j].Start, blocks[j].Start + ndim));
                     }
                 }
             }
@@ -3509,7 +3504,8 @@
                 fprintf(outf, "\n");
                 if (dump)
                 {
-                    readVarBlock(fp, io, variable, stepRelative, j, blocks[j]);
+                    readVarBlock(fp, io, variable, stepRelative, j,
+                                 blocks[j].Count, blocks[j].Start);
                 }
             }
             ++stepRelative;
@@ -3705,7 +3701,7 @@
                 if (!minBlocks)
                 {
                     readVarBlock(fp, io, variable, stepRelative, j,
-                                 coreBlocks[j]);
+                                 coreBlocks[j].Count, coreBlocks[j].Start);
                 }
                 else
                 {


remove lmin and use lmax. Remove zero instead of add pole.

--- examples/ex33.hpp
+++ examples/ex33.hpp
@@ -282,34 +282,41 @@

 /**
- * ComputePartialFractionApproximation : computes a rational approximation (RA) of the function
- * f(z) = z^{-a}, 0 < a < 1, in partial fraction form f(z) ≈ Σ_i c_i / (z - p_i).
- *
- *  INPUT:  @a alpha     = exponent in f(z) = z^-a
- *          @a lmin, @a lmax, @a npoints
- *                       = f(z) is uniformly sampled @a npoints times on
- *                         the interval [ @a lmin, @a lmax]
+ * ComputePartialFractionApproximation : computes a rational approximation (RA) in partial fraction
+ * form, e.g., f(z) ≈ Σ_i c_i / (z - p_i), from sampled values of the function f(z) = z^{-a}, 0 < a < 1.
+ *
+ *  INPUT:  @a alpha     = exponent a in f(z) = z^-a
+ *          @a lmax, @a npoints
+ *                       = f(z) is uniformly sampled @a npoints times in the interval [ 0, @a lmax ]
  *          @a tol       = relative tolerance
  *          @a max_order = maximum number of terms (order) of the RA
  *
  *  OUTPUT: @a coeffs = coefficients c_i
  *          @a poles  = poles p_i
+ *
+ *
+ *  NOTES:  When LAPACK is not compiled, only @a alpha = 0.33, 0.5, and 0.99 are possible.
+ *          In this case, if @a alpha != 0.33 and @a alpha != 0.99, then @a alpha = 0.5 is used
+ *          by default.
  *
  * See pg. A1501 of Nakatsukasa et al. [1].
  */
 void ComputePartialFractionApproximation(double alpha,
                                          Array<double> & coeffs, Array<double> & poles,
-                                         double lmin = 1., double lmax = 1000.,
-                                         double tol=1e-10,  int npoints = 1000,
+                                         double lmax = 1000.,
+                                         double tol=1e-10, int npoints = 1000,
                                          int max_order = 100)
 {
+   MFEM_VERIFY(alpha < 1., "alpha must be less than 1");
+   MFEM_VERIFY(alpha > 0., "alpha must be greater than 0");
+   MFEM_VERIFY(npoints > 2, "npoints must be greater than 2");
+   MFEM_VERIFY(lmax > 0,  "lmin must be greater than 0");
+   MFEM_VERIFY(tol > 0,  "tol must be greater than 0");
+
 #ifndef MFEM_USE_LAPACK
    mfem::out
-         << "MFEM is compiled without LAPACK. Using precomputed PartialFractionApproximation"
+         << "MFEM is compiled without LAPACK. Using precomputed values for PartialFractionApproximation"
          << std::endl;
-
-   MFEM_ASSERT(alpha < 1., "alpha must be less than 1");
-   MFEM_ASSERT(alpha > 0., "alpha must be greater than 0");

    if (alpha == 0.33)
    {
@@ -347,9 +354,10 @@

    Vector x(npoints);
    Vector val(npoints);
+   double dx = lmax / (double)(npoints-1);
    for (int i = 0; i<npoints; i++)
    {
-      x(i) = (double)i+1.0;
+      x(i) = dx * (double)i;
       val(i) = pow(x(i),1.-alpha);
    }

@@ -367,10 +375,9 @@
    Array<double> zeros;
    ComputePolesAndZeros(vecz, vecf, w, poles, zeros, scale);

-   // Introduce one extra pole at x=0, thus, delivering a
-   // RA for f(x) = x^{-a}
-   poles.Append(0.0);
+   // Remove the zero at x=0, thus, delivering a RA for f(x) = x^{-a}
+   zeros.DeleteFirst(0.0);

    // Compute partial fraction approximation of f(x) = x^{-a}
    PartialFractionExpansion(scale, poles, zeros, coeffs);
-}
+}


Modify ex1 to work Element Assembly.

Modify ex1 to work Element Assembly.

--- examples/ex1.cpp
+++ examples/ex1.cpp
@@ -65,6 +65,7 @@
    int order = 1;
    bool static_cond = false;
    bool pa = false;
+   bool ea = false;
    const char *device_config = "cpu";
    bool visualization = true;

@@ -78,6 +79,8 @@
                   "--no-static-condensation", "Enable static condensation.");
    args.AddOption(&pa, "-pa", "--partial-assembly", "-no-pa",
                   "--no-partial-assembly", "Enable Partial Assembly.");
+   args.AddOption(&ea, "-ea", "--element-assembly", "-no-ea",
+                  "--no-element-assembly", "Enable Element Assembly.");
    args.AddOption(&device_config, "-d", "--device",
                   "Device configuration string, see Device::Configure().");
    args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
@@ -167,6 +170,7 @@
    //    domain integrator.
    BilinearForm *a = new BilinearForm(fespace);
    if (pa) { a->SetAssemblyLevel(AssemblyLevel::PARTIAL); }
+   else if (ea) { a->SetAssemblyLevel(AssemblyLevel::ELEMENT); }
    a->AddDomainIntegrator(new DiffusionIntegrator(one));

    // 10. Assemble the bilinear form and the corresponding linear system,
@@ -183,7 +187,7 @@
    cout << "Size of linear system: " << A->Height() << endl;

    // 11. Solve the linear system A X = B.
-   if (!pa)
+   if (!pa && !ea)
    {
 #ifndef MFEM_USE_SUITESPARSE
       // Use a simple symmetric Gauss-Seidel preconditioner with PCG.


#100763#; call Init after creating accessible shape object

--- sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
+++ sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: AccessibleDocumentPagePreview.cxx,v $
  *
- *  $Revision: 1.13 $
- *
- *  last change: $Author: thb $ $Date: 2002-06-26 11:13:40 $
+ *  $Revision: 1.14 $
+ *
+ *  last change: $Author: sab $ $Date: 2002-06-27 08:58:45 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -1043,6 +1043,7 @@
         if (rShapes[nIndex].mpAccShape)
         {
             rShapes[nIndex].mpAccShape->acquire();
+            rShapes[nIndex].mpAccShape->Init();
             rShapes[nIndex].mpAccShape->SetRelationSet(GetRelationSet(rShapes[nIndex]));
         }
     }


GluonAudio::Sound: remove debug message

GluonAudio::Sound: remove debug message

--- audio/sound.cpp
+++ audio/sound.cpp
@@ -226,8 +226,6 @@

 void Sound::clear()
 {
-    DEBUG_BLOCK
-    DEBUG_TEXT("Clear")
     d->_k_deleteSource();
 }


Video file should not be empty during ingest

--- scanner/engine/ingest.cpp
+++ scanner/engine/ingest.cpp
@@ -51,9 +51,9 @@
 const std::string BAD_VIDEOS_FILE_PATH = "bad_videos.txt";

 struct FFStorehouseState {
-  std::unique_ptr<RandomReadFile> file;
-  size_t size; // total file size
-  u64 pos;
+  std::unique_ptr<RandomReadFile> file{nullptr};
+  size_t size = 0; // total file size
+  u64 pos = 0;
 };

 // For custom AVIOContext that loads from memory
@@ -226,7 +226,8 @@
   // file instead of a posix file
   FFStorehouseState file_state;
   StoreResult result;
-  EXP_BACKOFF(make_unique_random_read_file(storage, path, file_state.file), result);
+  EXP_BACKOFF(make_unique_random_read_file(storage, path, file_state.file),
+              result);
   if (result != StoreResult::Success) {
     error_message = "Can not open video file";
     return false;
@@ -235,6 +236,10 @@
   EXP_BACKOFF(file_state.file->get_size(file_state.size), result);
   if (result != StoreResult::Success) {
     error_message = "Can not get file size";
+    return false;
+  }
+  if (file_state.size <= 0) {
+    error_message = "Can not ingest empty video file";
     return false;
   }


IMPALA-3866: consistent user-facing terminology for scratch dirs

Error messages inconsistently referred to "temporary" versus "scratch".
Make the error messages consistent to make it easier for users to debug.
Also make sure the --scratch_dirs configuration option is always
mentioned.

Change-Id: I011e633721e206a2b6ecf1c34d5328f34fbc01ab
Reviewed-on: http://gerrit.cloudera.org:8080/3805
Reviewed-by: Matthew Jacobs <df2fa7c39d141dc5dc5589fed74180e757ed6c9a@cloudera.com>
Reviewed-by: Dan Hecht <20ebd99959f0f6e5dcb0fc319b4d8ef53a16b5fb@cloudera.com>
Reviewed-by: Marcell Szabo <f0b0a766c24b566b1711dadb7c01a32650701ad6@cloudera.com>
Tested-by: Internal Jenkins

--- be/src/runtime/buffered-block-mgr.cc
+++ be/src/runtime/buffered-block-mgr.cc
@@ -820,12 +820,13 @@
     if (status.ok()) return Status::OK();
     // Log error and try other files if there was a problem. Problematic files will be
     // blacklisted so we will not repeatedly log the same error.
-    LOG(WARNING) << "Error while allocating temporary file range: "
-                 << status.msg().msg() << ". Will try another temporary file.";
+    LOG(WARNING) << "Error while allocating range in scratch file '"
+                 << (*tmp_file)->path() << "': " << status.msg().msg()
+                 << ". Will try another scratch file.";
     errs.push_back(status);
   }
-  Status err_status("No usable temporary files: space could not be allocated on any "
-      "temporary device.");
+  Status err_status("No usable scratch files: space could not be allocated in any "
+      "of the configured scratch directories (--scratch_dirs).");
   for (int i = 0; i < errs.size(); ++i) {
     err_status.MergeStatus(errs[i]);
   }
@@ -1100,7 +1101,7 @@
     if (disable_spill_) {
       if (block_write_threshold_ == 0) {
         return Status("Spilling has been disabled due to no usable scratch space. "
-            "Please specify a usable scratch space location via the scratch_dirs "
+            "Please specify a usable scratch space location via the --scratch_dirs "
             "impalad flag.");
       } else {
         return Status("Spilling has been disabled for plans that do not have stats and "


端ケース追加

端ケース追加

--- clammbon/src/algorithm.cpp
+++ clammbon/src/algorithm.cpp
@@ -166,11 +166,7 @@
 #ifndef NDEBUG
     print(matrix);
 #endif
-    try {
-        yield(solve());
-    } catch (std::runtime_error const& e) {
-        std::cerr << "Couldn't solve the problem." << std::endl;
-    }
+    yield(solve());
 }

 // move_selecting {{{2
@@ -320,6 +316,9 @@
     for (;;) {
         // 残りが BFS_NUM x BFS_NUM の場合は Brute-Force
         if (height - sorted_row <= BFS_NUM && width - sorted_col <= BFS_NUM) {
+#ifndef NDEBUG
+            std::cout << "start brute_force solving" << std::endl;
+#endif
             brute_force();
             break;
         }
@@ -467,10 +466,16 @@
             }
             move_selecting<'D', 'R'>();
         } else if (selecting_cur.x > 1 && selecting_cur.y > 1) {
+            std::cout << "selecting_cur : " << selecting_cur << ", target : " << target << std::endl;
             if (target.x == width - 2 && matrix[selecting_cur.y - 1][selecting_cur.x - 1] == target.right()) {
+                std::cout << "SPECIAL CASE 1" << std::endl;
                 move_selecting<'L', 'U', 'R', 'D', 'L', 'D', 'R', 'U', 'U', 'L', 'D', 'R', 'D'>();
             } else if (target.y == height - 2 && matrix[selecting_cur.y - 1][selecting_cur.x - 1] == target.down()) {
+                std::cout << "SPECIAL CASE 2" << std::endl;
                 move_selecting<'U', 'L', 'D', 'R', 'U', 'R', 'D', 'L', 'L', 'U', 'R', 'D', 'R'>();
+            } else if (selecting_cur.x == width - 2 && target.x == width - 2 && matrix[selecting_cur.y + 1][selecting_cur.x] == target.right()) {
+                std::cout << "SPECIAL CASE 3" << std::endl;
+                move_selecting<'R', 'D', 'D', 'L', 'U', 'R', 'U', 'L', 'D', 'D', 'D', 'R', 'U', 'L', 'U', 'R'>();
             }
         }

@@ -558,6 +563,9 @@
 // move_target {{{2
 void algorithm::impl::move_target(point_type const& target, char const& direction)
 {
+#ifndef NDEBUG
+    std::cout << "move_target " << target << " " << direction << std::endl;
+#endif
     // selecting の操作によって原座標が target である断片画像を指定の方向へ移動させる.

     // target の現在の座標


*** empty log message ***

*** empty log message ***

--- api/otf2prv.cpp
+++ api/otf2prv.cpp
@@ -38,9 +38,9 @@

 using namespace std;

-const string OTF2_VERSION_STRING = "0.30";
-
-//#include <scorep_utility/SCOREP_UtilityTypes.h>
+const string OTF2_VERSION_STRING = "0.31";
+
+#include <scorep_utility/SCOREP_UtilityTypes.h>
 #include <otf2/otf2.h>
 #include "otf2prv.h"

@@ -105,17 +105,7 @@
     ~TranslationLog() {};

     void enableLog( bool whichLogEnabled );
-
-    void write( const string & message );
-    void write( const string & message, const string & value );
-    void write( const string & message, const uint64_t & value );
-    void write( const string & message, const int64_t & value );
-    void write( const string & message, const double & value );
-    void write( const string & message, const uint32_t & value );
-    void write( const string & message, const uint32_t & value1, const uint32_t & value2 );
-    void write( const string & message, const uint64_t & value1, const uint32_t & value2 );
-    void write( const string & message, const uint64_t & value1, const uint64_t & value2 );
-    void write( const string & message1, const string & message2, const uint32_t & value );
+    void write( const string & types, ... );

   private:
     bool logEnabled;
@@ -183,131 +173,52 @@
 }

-void TranslationLog::write( const string & message )
+void TranslationLog::write( const string & types, ... )
 {
   if ( logEnabled )
   {
-    (*logFile) << message << std::endl;
-  }
-}
-
-
-void TranslationLog::write( const string & message, const string & value )
-{
-  if ( logEnabled )
-  {
-    (*logFile) << message << ": " << value << std::endl;
-  }
-}
-
-
-void TranslationLog::write( const string & message, const uint64_t & value )
-{
-  if ( logEnabled )
-  {
-    stringstream aux;
-    aux << value;
-    (*logFile) << message << ": " << aux.str() << std::endl;
-  }
-}
-
-
-void TranslationLog::write( const string & message, const int64_t & value )
-{
-  if ( logEnabled )
-  {
-    stringstream aux;
-    aux << value;
-    (*logFile) << message << ": " << aux.str() << std::endl;
-  }
-}
-
-
-void TranslationLog::write( const string & message, const double & value )
-{
-  if ( logEnabled )
-  {
-    stringstream aux;
-    aux << fixed;
-    aux.precision( 4 );
-    aux << value;
-    (*logFile) << message << ": " << aux.str() << std::endl;
-  }
-}
-
-
-void TranslationLog::write( const string & message, const uint32_t & value )
-{
-  if ( logEnabled )
-  {
-    stringstream aux;
-    aux << value;
-    (*logFile) << message << ": " << aux.str() << std::endl;
-  }
-}
-
-
-void TranslationLog::write( const string & message, const uint32_t & value1, const uint32_t & value2 )
-{
-  if ( logEnabled )
-  {
-    (*logFile) << message << ": ";
-
-    stringstream aux;
-    aux << value1;
-    (*logFile) << aux.str() << " - ";
-
-    stringstream aux2;
-    aux2.clear();
-    aux2 << value2;
-    (*logFile) << aux2.str() << std::endl;
-  }
-}
-
-
-void TranslationLog::write( const string & message, const uint64_t & value1, const uint32_t & value2 )
-{
-  if ( logEnabled )
-  {
-    (*logFile) << message << ": ";
-
-    stringstream aux;
-    aux << value1;
-    (*logFile) << aux.str() << " - ";
-
-    stringstream aux2;
-    aux2.clear();
-    aux2 << value2;
-    (*logFile) << aux2.str() << std::endl;
-  }
-}
-
-
-void TranslationLog::write( const string & message, const uint64_t & value1, const uint64_t & value2 )
-{
-  if ( logEnabled )
-  {
-    (*logFile) << message << ": ";
-
-    stringstream aux;
-    aux << value1;
-    (*logFile) << aux.str() << " - ";
-
-    stringstream aux2;
-    aux2.clear();
-    aux2 << value2;
-    (*logFile) << aux2.str() << std::endl;
-  }
-}
-
-
-void TranslationLog::write( const string & message1, const string & message2, const uint32_t & value )
-{
-  if ( logEnabled )
-  {
-    stringstream aux;
-    aux << value;
-    (*logFile) << message1 << " " << message2 << ": " << aux.str() << std::endl;
+    va_list paramsList;
+
+    va_start( paramsList, types );
+
+    for( size_t i = 0; i < types.length(); ++i )
+    {
+      // Type recognition and printing
+      stringstream aux;
+      switch ( types[i] )
+      {
+        case 's':
+          (*logFile) << va_arg( paramsList, const char* );
+          break;
+        case 'u':
+          (*logFile) << va_arg( paramsList, uint32_t );
+          break;
+        case 'U':
+          (*logFile) << va_arg( paramsList, uint64_t );
+          break;
+        case 'i':
+          (*logFile) << va_arg( paramsList, int32_t );
+          break;
+        case 'I':
+          (*logFile) << va_arg( paramsList, int64_t );
+          break;
+        case 'd':
+          aux << fixed;
+          aux.precision( 4 );
+          (*logFile) << va_arg( paramsList, double );
+          break;
+      }
+
+      // Finish line?
+      if ( i == types.length() - 1 )
+      {
+        (*logFile) << std::endl;
+      }
+      else
+      {
+        (*logFile) << " ";
+      }
+    }
   }
 }

@@ -407,12 +318,12 @@
              line.length() == 0 )
           continue;

-        transData->myLog.write(  "[MSK] External definition", line);
+        transData->myLog.write( "ss", "[MSK] External definition :", line.c_str() );

         istringstream auxLine( line );
         getline( auxLine, token, '"' );
         getline( auxLine, auxOTF2Label, '"' );
-        // transData->myLog.write(  "[MSK] External Token ", token);
+        // transData->myLog.write( "ss", "[MSK] External Token :", token.c_str() );

         while( !auxLine.eof() )
         {
@@ -470,11 +381,11 @@
   transData->localDefClockOffset[ transData->currentLocation ].offset = offset;
   transData->localDefClockOffset[ transData->currentLocation ].stddev = stddev;
 */
-  transData->myLog.write(  "[DEF][LOCAL] CLOCK OFFSET" );
-  transData->myLog.write(  "             Location ID ", transData->currentLocation );
-  transData->myLog.write(  "             Clock Time  ", time );
-  transData->myLog.write(  "             Clock Offset", offset );
-  transData->myLog.write(  "             Clock StDev ", stddev );
+  transData->myLog.write( "s", "[DEF][LOCAL] CLOCK OFFSET  :" );
+  transData->myLog.write( "sU", "             Location ID  :", transData->currentLocation );
+  transData->myLog.write( "sU", "             Clock Time   :", time );
+  transData->myLog.write( "sI", "             Clock Offset :", offset );
+  transData->myLog.write( "sd", "             Clock StDev  :", stddev );

   return SCOREP_SUCCESS;
 }
@@ -492,32 +403,32 @@
   if ( timeUnit >= ( 1 / 1E9 ))
   {
     transData->timeUnit = NS;
-    transData->myLog.write(  "[DEF] CLOCK UNIT: NS ", timeUnit );
+    transData->myLog.write( "sd", "[DEF] CLOCK UNIT: NS :", timeUnit );
   }
   else if ( timeUnit >= ( 1 / 1E6 ))
   {
     transData->timeUnit = US;
-    transData->myLog.write(  "[DEF] CLOCK UNIT: US ", timeUnit );
+    transData->myLog.write( "sd", "[DEF] CLOCK UNIT: US :", timeUnit );
   }
   else if ( timeUnit >= (1 / 1E3 ))
   {
     transData->timeUnit = MS;
-    transData->myLog.write(  "[DEF] CLOCK UNIT: MS ", timeUnit );
+    transData->myLog.write( "sd", "[DEF] CLOCK UNIT: MS :", timeUnit );
   }
   else
   {
     transData->timeUnit = SEC;
-    transData->myLog.write(  "[DEF] CLOCK UNIT: S ", timeUnit );
+    transData->myLog.write( "sd", "[DEF] CLOCK UNIT: S :", timeUnit );
   }

   transData->timeUnit = NS;
-  transData->myLog.write(  "[DEF] CLOCK UNIT: NS ", timeUnit );
+  transData->myLog.write( "sd", "[DEF] CLOCK UNIT: NS :", timeUnit );

   //transData->maxTraceTime = global_offset + trace_length; // ??
   transData->maxTraceTime = trace_length;
   transData->globalOffset = global_offset;

-  transData->myLog.write(  "[DEF] CLOCK (max, offset):", trace_length, global_offset );
+  transData->myLog.write( "ssusus", "[DEF] CLOCK (max, offset):", "(", trace_length, ", ", global_offset, ")" );

   return SCOREP_SUCCESS;
 }
@@ -532,7 +443,7 @@
 {
   TranslationData *transData = ( TranslationData * )userData;

-  transData->myLog.write(  "[DEF-???] : CALLSITE" );
+  transData->myLog.write( "s", "[DEF-???] : CALLSITE" );

   return SCOREP_SUCCESS;
 }
@@ -545,7 +456,7 @@
 {
   TranslationData *transData = ( TranslationData * )userData;

-  transData->myLog.write(  "[DEF-???] : CALLPATH" );
+  transData->myLog.write( "s", "[DEF-???] : CALLPATH" );

   return SCOREP_SUCCESS;
 }
@@ -559,7 +470,7 @@
 {
   TranslationData *transData = ( TranslationData * )userData;

-  transData->myLog.write(  "[DEF-???] : MPICOMM" );
+  transData->myLog.write( "s", "[DEF-???] : MPICOMM" );

   return SCOREP_SUCCESS;
 }
@@ -578,7 +489,7 @@
 {
   TranslationData *transData = ( TranslationData * )userData;

-  transData->myLog.write(  "[DEF-???] : METRIC MEMBER" );
+  transData->myLog.write( "s", "[DEF-???] : METRIC MEMBER" );
   /*
     otf2_print_data* data = ( otf2_print_data* )userData;

@@ -627,7 +538,7 @@
 {
   TranslationData *transData = ( TranslationData * )userData;

-  transData->myLog.write(  "[DEF-???] : METRIC CLASS" );
+  transData->myLog.write( "s", "[DEF-???] : METRIC CLASS" );
   /*
     otf2_print_data* data = ( otf2_print_data* )userData;

@@ -660,7 +571,7 @@
 {
   TranslationData *transData = ( TranslationData * )userData;

-  transData->myLog.write(  "[DEF-???] : METRIC INSTANCE" );
+  transData->myLog.write( "s", "[DEF-???] : METRIC INSTANCE" );
   /*
     otf2_print_data* data = ( otf2_print_data* )userData;

@@ -684,7 +595,7 @@
 {
   TranslationData *transData = ( TranslationData * )userData;

-  transData->myLog.write(  "[DEF-???] : PARAMETER" );
+  transData->myLog.write( "s", "[DEF-???] : PARAMETER" );
   /*
     otf2_print_data* data = ( otf2_print_data* )userData;

@@ -711,7 +622,7 @@
 {
   TranslationData *transData = ( TranslationData * )userData;

-  transData->myLog.write(  "[DEF-???] : UNKNOWN" );
+  transData->myLog.write( "s", "[DEF-???] : UNKNOWN" );
 /*
     ( void )userData;

@@ -728,7 +639,7 @@
 {
   TranslationData *transData = ( TranslationData * )userData;

-  transData->myLog.write(  "[DEF-???] : MAPPING TABLE" );
+  transData->myLog.write( "s", "[DEF-???] : MAPPING TABLE" );
   /*
     uint64_t* location_id_ptr = userData;

@@ -770,7 +681,7 @@
 {
   TranslationData *transData = ( TranslationData * )userData;

-  transData->myLog.write(  "[DEF-???] " );
+  transData->myLog.write( "s", "[DEF-???] " );

   return SCOREP_SUCCESS;
 }
@@ -784,7 +695,7 @@

   transData->symbols[ stringID ] = std::string( string );

-  transData->myLog.write(  "[DEF] STRING", transData->symbols[ stringID ] );
+  transData->myLog.write( "ss", "[DEF] STRING :", transData->symbols[ stringID ].c_str() );
 }

@@ -945,12 +856,13 @@
   {
     tmpList->insert( transData->symbols[ name ], false, 0, USER_FUNCTION, regionID,
                      USER_FUNCTION_LABEL, transData->symbols[ name ], true, STATE_RUNNING );
-    transData->myLog.write(  "[DEF] UNREGISTERED REGION; taken as USER FUNCTION", transData->symbols[ name ] );
+    transData->myLog.write( "ss", "[DEF] UNREGISTERED REGION; taken as USER FUNCTION :",
+                           transData->symbols[ name ].c_str() );

   }
   else
   {
-    transData->myLog.write(  "[DEF] REGION", transData->symbols[ name ] );
+    transData->myLog.write( "ss", "[DEF] REGION :", transData->symbols[ name ].c_str() );
   }

 //D  map< string, int >::iterator it;
@@ -1006,7 +918,10 @@
   // The translator only uses otf2_msg_match
   // transData->attributeType[ attributeID ] = OTF2_TypeID; // Needed?

-  transData->myLog.write(  "[DEF] ATTRIBUTE", transData->symbols[ name ], attributeID );
+  transData->myLog.write( "sssu", "[DEF] ATTRIBUTE ",
+                                  transData->symbols[ name ].c_str(),
+                                  ": ",
+                                  attributeID );

   return  SCOREP_SUCCESS;
 }
@@ -1047,7 +962,7 @@

   *transData->PRVFile << "# OTF2 event not translated: BufferFlush" << endl;

-  transData->myLog.write(  "[EVT-???] : BufferFlush" );
+  transData->myLog.write( "s", "[EVT-???] : BufferFlush" );

   return SCOREP_SUCCESS;
 }
@@ -1065,7 +980,7 @@

   *transData->PRVFile << "# OTF2 event not translated: MeasurementOnOff" << endl;

-  transData->myLog.write(  "[EVT-???] : MeasurementOnOff" );
+  transData->myLog.write( "s", "[EVT-???] : MeasurementOnOff" );

   return SCOREP_SUCCESS;
 }
@@ -1087,7 +1002,7 @@

   *transData->PRVFile << "# OTF2 event not translated: MpiIsend" << endl;

-  transData->myLog.write(  "[EVT-???] : MpiIsend" );
+  transData->myLog.write( "s", "[EVT-???] : MpiIsend" );

   return SCOREP_SUCCESS;
 }
@@ -1105,7 +1020,7 @@

   *transData->PRVFile << "# OTF2 event not translated: MpiIsendComplete" << endl;

-  transData->myLog.write(  "[EVT-???] : MpiIsendComplete" );
+  transData->myLog.write( "s", "[EVT-???] : MpiIsendComplete" );

   return SCOREP_SUCCESS;
 }
@@ -1123,7 +1038,7 @@

   *transData->PRVFile << "# OTF2 event not translated: MpiIrecvRequest" << endl;

-  transData->myLog.write(  "[EVT-???] : MpiIrecvRequest" );
+  transData->myLog.write( "s", "[EVT-???] : MpiIrecvRequest" );

   return SCOREP_SUCCESS;
 }
@@ -1144,7 +1059,7 @@

   *transData->PRVFile << "# OTF2 event not translated: MpiRecv" << endl;

-  transData->myLog.write(  "[EVT-???] : MpiRecv" );
+  transData->myLog.write( "s", "[EVT-???] : MpiRecv" );

   return SCOREP_SUCCESS;
 }
@@ -1166,7 +1081,7 @@

   *transData->PRVFile << "# OTF2 event not translated: MpiIrecv" << endl;

-  transData->myLog.write(  "[EVT-???] : MpiIrecv" );
+  transData->myLog.write( "s", "[EVT-???] : MpiIrecv" );

   return SCOREP_SUCCESS;
 }
@@ -1184,7 +1099,7 @@

   *transData->PRVFile << "# OTF2 event not translated: MpiRequestTest" << endl;

-  transData->myLog.write(  "[EVT-???] : MpiRequestTest" );
+  transData->myLog.write( "s", "[EVT-???] : MpiRequestTest" );

   return SCOREP_SUCCESS;
 }
@@ -1202,7 +1117,7 @@

   *transData->PRVFile << "# OTF2 event not translated: MpiRequestCancelled" << endl;

-  transData->myLog.write(  "[EVT-???] : MpiRequestCancelled" );
+  transData->myLog.write( "s", "[EVT-???] : MpiRequestCancelled" );

   return SCOREP_SUCCESS;
 }
@@ -1219,7 +1134,7 @@

   *transData->PRVFile << "# OTF2 event not translated: MpiCollectiveBegin" << endl;

-  transData->myLog.write(  "[EVT-???] : MpiCollectiveBegin" );
+  transData->myLog.write( "s", "[EVT-???] : MpiCollectiveBegin" );

   return SCOREP_SUCCESS;
 }
@@ -1241,7 +1156,7 @@

   *transData->PRVFile << "# OTF2 event not translated: MpiCollectiveEnd" << endl;

-  transData->myLog.write(  "[EVT-???] : MpiCollectiveEnd" );
+  transData->myLog.write( "s", "[EVT-???] : MpiCollectiveEnd" );

   return SCOREP_SUCCESS;
 }
@@ -1259,7 +1174,7 @@

   *transData->PRVFile << "# OTF2 event not translated: OmpFork" << endl;

-  transData->myLog.write(  "[EVT-???] : OmpFork" );
+  transData->myLog.write( "s", "[EVT-???] : OmpFork" );

   return SCOREP_SUCCESS;
 }
@@ -1276,7 +1191,7 @@

   *transData->PRVFile << "# OTF2 event not translated: OmpJoin" << endl;

-  transData->myLog.write(  "[EVT-???] : OmpJoin" );
+  transData->myLog.write( "s", "[EVT-???] : OmpJoin" );

   return SCOREP_SUCCESS;
 }
@@ -1295,7 +1210,7 @@

   *transData->PRVFile << "# OTF2 event not translated: OmpAcquireLock" << endl;

-  transData->myLog.write(  "[EVT-???] : OmpAcquireLock" );
+  transData->myLog.write( "s", "[EVT-???] : OmpAcquireLock" );

   return SCOREP_SUCCESS;
 }
@@ -1314,7 +1229,7 @@

   *transData->PRVFile << "# OTF2 event not translated: OmpReleaseLock" << endl;

-  transData->myLog.write(  "[EVT-???] : OmpReleaseLock" );
+  transData->myLog.write( "s", "[EVT-???] : OmpReleaseLock" );

   return SCOREP_SUCCESS;
 }
@@ -1332,7 +1247,7 @@

   *transData->PRVFile << "# OTF2 event not translated: OmpTaskCreate" << endl;

-  transData->myLog.write(  "[EVT-???] : OmpTaskCreate" );
+  transData->myLog.write( "s", "[EVT-???] : OmpTaskCreate" );

   return SCOREP_SUCCESS;
 }
@@ -1350,7 +1265,7 @@

   *transData->PRVFile << "# OTF2 event not translated: OmpTaskSwitch" << endl;

-  transData->myLog.write(  "[EVT-???] : OmpTaskSwitch" );
+  transData->myLog.write( "s", "[EVT-???] : OmpTaskSwitch" );

   return SCOREP_SUCCESS;
 }
@@ -1368,7 +1283,7 @@

   *transData->PRVFile << "# OTF2 event not translated: OmpTaskComplete" << endl;

-  transData->myLog.write(  "[EVT-???] : OmpTaskComplete" );
+  transData->myLog.write( "s", "[EVT-???] : OmpTaskComplete" );

   return SCOREP_SUCCESS;
 }
@@ -1389,7 +1304,7 @@

   *transData->PRVFile << "# OTF2 event not translated: Metric" << endl;

-  transData->myLog.write(  "[EVT-???] : Metric" );
+  transData->myLog.write( "s", "[EVT-???] : Metric" );

   /*
     const char* sep = "";
@@ -1435,7 +1350,7 @@

   *transData->PRVFile << "# OTF2 event not translated: ParameterString" << endl;

-  transData->myLog.write(  "[EVT-???] : ParameterString" );
+  transData->myLog.write( "s", "[EVT-???] : ParameterString" );

   return SCOREP_SUCCESS;
 }
@@ -1454,7 +1369,7 @@

   *transData->PRVFile << "# OTF2 event not translated: ParameterInt" << endl;

-  transData->myLog.write(  "[EVT-???] : ParameterInt" );
+  transData->myLog.write( "s", "[EVT-???] : ParameterInt" );

   return SCOREP_SUCCESS;
 }
@@ -1473,7 +1388,7 @@

   *transData->PRVFile << "# OTF2 event not translated: ParameterUnsignedInt" << endl;

-  transData->myLog.write(  "[EVT-???] : ParameterUnsignedInt" );
+  transData->myLog.write( "s", "[EVT-???] : ParameterUnsignedInt" );

   return SCOREP_SUCCESS;
 }
@@ -1490,7 +1405,7 @@

   *transData->PRVFile << "# OTF2 event not translated: Unknown" << endl;

-  transData->myLog.write(  "[EVT-???] : Unknown" );
+  transData->myLog.write( "s", "[EVT-???] : Unknown" );

   return SCOREP_SUCCESS;
 }
@@ -1509,7 +1424,7 @@

   time = correctBeginTime( transData, time );

-  transData->myLog.write(  "[EVT] MpiSend", locationID, receiver );
+  transData->myLog.write( "sUu", "[EVT] MpiSend :", locationID, receiver );

   if ( OTF2_AttributeList_GetNumberOfElements( attributes ) > 0 )
   {
@@ -1558,7 +1473,7 @@

       *transData->PRVFile << commRecord.str(); // change to Trace write.

-      transData->myLog.write(  commRecord.str() );
+      transData->myLog.write( "s", commRecord.str().c_str() );
     }
   }

@@ -1622,7 +1537,7 @@

     *transData->PRVFile << eventRecord.str() << std::endl; // change to Trace write.

-    transData->myLog.write(  eventRecord.str() );
+    transData->myLog.write( "s", eventRecord.str().c_str() );
   }

   return SCOREP_SUCCESS;
@@ -1686,7 +1601,7 @@

     *transData->PRVFile << eventRecord.str() << std::endl;  // change to Trace write.

-    transData->myLog.write(  eventRecord.str() );
+    transData->myLog.write( "s", eventRecord.str().c_str() );
   }

   return SCOREP_SUCCESS;
@@ -1882,11 +1797,11 @@

   if ( file.good() )
   {
-    transData->myLog.write(  "[FILE] Opened ", strPRVTrace );
+    transData->myLog.write( "ss", "[FILE] Opened :", strPRVTrace.c_str() );
     OTF2_Reader* reader = OTF2_Reader_Open( transData->strOTF2Trace.c_str() );
     if ( reader != NULL )
     {
-      transData->myLog.write(  "[FILE] Opened ", transData->strOTF2Trace );
+      transData->myLog.write( "ss", "[FILE] Opened :", transData->strOTF2Trace.c_str() );

       transData->reader = reader;
       transData->PRVFile = &file;
@@ -1895,7 +1810,7 @@
       loadExternalTranslationTable( strExternalTable, transData );

       // BUILD HEADER
-      transData->myLog.write( "[REC] Registering OTF2 Callbacks" );
+      transData->myLog.write( "s", "[REC] Registering OTF2 Callbacks" );

       OTF2_GlobalDefReader* global_def_reader = OTF2_Reader_GetGlobalDefReader( reader );
       OTF2_GlobalDefReaderCallbacks* global_def_callbacks = OTF2_GlobalDefReaderCallbacks_New();


Fill in code in EmulateSUBReg to emulate the SUB (register) ARM instruction.

git-svn-id: b33bab8abb5b18c12ee100cd7761ab452d00b2b0@128508 91177308-0d34-0410-b5e6-96231b3b80d8

--- source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -9369,19 +9369,123 @@
 EmulateInstructionARM::EmulateSUBReg (const uint32_t opcode, const ARMEncoding encoding)
 {
 #if 0
+    if ConditionPassed() then
+        EncodingSpecificOperations();
+        shifted = Shift(R[m], shift_t, shift_n, APSR.C);
+        (result, carry, overflow) = AddWithCarry(R[n], NOT(shifted), ‘1’);
+        if d == 15 then // Can only occur for ARM encoding
+            ALUWritePC(result); // setflags is always FALSE here
+        else
+            R[d] = result;
+            if setflags then
+                APSR.N = result<31>;
+                APSR.Z = IsZeroBit(result);
+                APSR.C = carry;
+                APSR.V = overflow;
 #endif

-    //bool success = false;
+    bool success = false;

     if (ConditionPassed(opcode))
     {
+        uint32_t d;
+        uint32_t n;
+        uint32_t m;
+        bool setflags;
+        ARM_ShifterType shift_t;
+        uint32_t shift_n;
+
         switch (encoding)
         {
-        }
-    }
-    return true;
-}
-
+            case eEncodingT1:
+                // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = !InITBlock();
+                d = Bits32 (opcode, 2, 0);
+                n = Bits32 (opcode, 5, 3);
+                m = Bits32 (opcode, 8, 6);
+                setflags = !InITBlock();
+
+                // (shift_t, shift_n) = (SRType_LSL, 0);
+                shift_t = SRType_LSL;
+                shift_n = 0;
+
+                break;
+
+            case eEncodingT2:
+                // if Rd == ‘1111’ && S == ‘1’ then SEE CMP (register);
+                // if Rn == ‘1101’ then SEE SUB (SP minus register);
+                // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = (S == ‘1’);
+                d = Bits32 (opcode, 11, 8);
+                n = Bits32 (opcode, 19, 16);
+                m = Bits32 (opcode, 3, 0);
+                setflags = BitIsSet (opcode, 20);
+
+                // (shift_t, shift_n) = DecodeImmShift(type, imm3:imm2);
+                shift_n = DecodeImmShiftThumb (opcode, shift_t);
+
+                // if d == 13 || (d == 15 && S == '0') || n == 15 || BadReg(m) then UNPREDICTABLE;
+                if ((d == 13) || ((d == 15) && BitIsClear (opcode, 20)) || (n == 15) || BadReg (m))
+                    return false;
+
+                break;
+
+            case eEncodingA1:
+                // if Rd == ‘1111’ && S == ‘1’ then SEE SUBS PC, LR and related instructions;
+                // if Rn == ‘1101’ then SEE SUB (SP minus register);
+                // d = UInt(Rd); n = UInt(Rn); m = UInt(Rm); setflags = (S == ‘1’);
+                d = Bits32 (opcode, 15, 12);
+                n = Bits32 (opcode, 19, 16);
+                m = Bits32 (opcode, 3, 0);
+                setflags = BitIsSet (opcode, 20);
+
+                // (shift_t, shift_n) = DecodeImmShift(type, imm5);
+                shift_n = DecodeImmShiftARM (opcode, shift_t);
+
+                break;
+
+            default:
+                return false;
+        }
+
+        // shifted = Shift(R[m], shift_t, shift_n, APSR.C);
+        uint32_t Rm = ReadCoreReg (m, &success);
+        if (!success)
+            return false;
+
+        uint32_t shifted = Shift (Rm, shift_t, shift_n, APSR_C);
+
+        // (result, carry, overflow) = AddWithCarry(R[n], NOT(shifted), ‘1’);
+        uint32_t Rn = ReadCoreReg (n, &success);
+        if (!success)
+            return false;
+
+        AddWithCarryResult res = AddWithCarry (Rn, ~shifted, 1);
+
+        // if d == 15 then // Can only occur for ARM encoding
+            // ALUWritePC(result); // setflags is always FALSE here
+        // else
+            // R[d] = result;
+            // if setflags then
+                // APSR.N = result<31>;
+                // APSR.Z = IsZeroBit(result);
+                // APSR.C = carry;
+                // APSR.V = overflow;
+
+        EmulateInstruction::Context context;
+        context.type = eContextSubtraction;
+        Register reg_n;
+        reg_n.SetRegister (eRegisterKindDWARF, n);
+        Register reg_m;
+        reg_m.SetRegister (eRegisterKindDWARF, m);
+        context.SetRegisterRegisterOperands (reg_n, reg_m);
+
+        uint32_t dest_reg_num = dwarf_r0 + d;
+
+        if (!WriteCoreRegOptionalFlags (context, res.result, dest_reg_num, setflags, res.carry_out, res.overflow))
+            return false;
+    }
+    return true;
+}
+
 // A8.6.202 STREX
 bool
 EmulateInstructionARM::EmulateSTREX (const uint32_t opcode, const ARMEncoding encoding)
@@ -10042,6 +10146,8 @@
         { 0x0fe00000, 0x02400000, ARMvAll,       eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSUBImmARM, "sub{s}<c> <Rd>, <Rn>, #<const>"},
         // sub (sp minus immediate)
         { 0x0fef0000, 0x024d0000, ARMvAll,       eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSUBSPImm, "sub{s}<c> <Rd>, sp, #<const>"},
+        // sub (register)
+        { 0x0fe00010, 0x00400000, ARMvAll,       eEncodingA1, eSize32, &EmulateInstructionARM::EmulateSUBReg, "sub{s}<c> <Rd>, <Rn>, <Rm>{,<shift>}"},
         // teq (immediate)
         { 0x0ff0f000, 0x03300000, ARMvAll,       eEncodingA1, eSize32, &EmulateInstructionARM::EmulateTEQImm, "teq<c> <Rn>, #const"},
         // teq (register)
@@ -10282,6 +10388,9 @@
         // sub (sp minus immediate)
         { 0xfbef8000, 0xf1ad0000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateSUBSPImm, "sub{s}.w <Rd>, sp, #<const>"},
         { 0xfbff8000, 0xf2ad0000, ARMV6T2_ABOVE, eEncodingT3, eSize32, &EmulateInstructionARM::EmulateSUBSPImm, "subw<c> <Rd>, sp, #imm12"},
+        // sub (register)
+        { 0xfffffe00, 0x00001a00, ARMV4T_ABOVE,  eEncodingT1, eSize16, &EmulateInstructionARM::EmulateSUBReg, "subs|sub<c> <Rd>, <Rn>, <Rm>"},
+        { 0xffe08000, 0xeba00000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateSUBReg, "sub{s}<c>.w <Rd>, <Rn>, <Rm>{,<shift>}"},
         // teq (immediate)
         { 0xfbf08f00, 0xf0900f00, ARMV6T2_ABOVE, eEncodingT1, eSize32, &EmulateInstructionARM::EmulateTEQImm, "teq<c> <Rn>, #<const>"},
         // teq (register)


Logical fix

Logical fix

--- ghost++/ghost/ghost.cpp
+++ ghost++/ghost/ghost.cpp
@@ -1498,7 +1498,7 @@
     m_GlobalMySQLPath = UTIL_AddPathSeperator( CFG->GetString( "oh_globalmysqlpath", "../" ) );
     m_PVPGNMode = CFG->GetInt("oh_pvpgn_mode", 0) == 0 ? false : true;
     m_AutoRehostTime = CFG->GetInt("oh_auto_rehost_time", 0);
-    if(m_AutoRehostTime<10) {
+    if(m_AutoRehostTime<10 && m_AutoRehostTime!=0) {
 	m_AutoRehostTime=10;
     }
     m_DenyLimit = CFG->GetInt("oh_cc_deny_limit", 2);


Use markTransformDirty() instead of manually setting dirty flags

--- ouzel/Node.cpp
+++ ouzel/Node.cpp
@@ -224,8 +224,7 @@
     void Node::updateTransform(const Matrix4& parentTransform)
     {
         _parentTransform = parentTransform;
-        _transformDirty = true;
-        _inverseTransformDirty = true;
+        markTransformDirty();
     }

     Vector2 Node::convertWorldToLocal(const Vector2& position) const


TS-3033: Fix build errors.

TS-3033: Fix build errors.

--- mgmt/api/NetworkMessage.cc
+++ mgmt/api/NetworkMessage.cc
@@ -96,7 +96,7 @@
 };

 #define GETCMD(ops, optype, cmd) do { \
-  if (optype < 0 || optype >= countof(ops)) { return TS_ERR_PARAMS; } \
+  if (optype < 0 || static_cast<unsigned>(optype) >= countof(ops)) { return TS_ERR_PARAMS; } \
   if (ops[optype].nfields == 0) { return TS_ERR_PARAMS; } \
   cmd = &ops[optype]; \
 } while (0);


Fix image drawing on raspi

Fix image drawing on raspi

--- raspi/main.cpp
+++ raspi/main.cpp
@@ -27,6 +27,8 @@

 int main()
 {
+    //cv::namedWindow("abc", CV_WINDOW_OPENGL);
+
     //Setting up the camera
     raspicam::RaspiCam_Cv camera;

@@ -51,6 +53,7 @@
     }
     std::cout << "Writing test img" << std::endl;
     cv::imwrite("/home/frans/public_html/test2.jpg", testImg);
+

     //Main menu
     bool running = true;
@@ -134,10 +137,12 @@
                 ct.setImage(image);
                 ct.generateBinary(minColor, maxColor, true);

-                cv::imshow("", image);
+                cv::imshow("abc", ct.getBinary());
+                cv::waitKey(10);

                 std::cout << "Found object in: " << ct.getMiddlePos().getString() << std::endl;
+                std::cout <<  "Showing image" << std::endl;
                 //storing the result in an image
                 uint8_t* pathData = pathImg.data;


BUGFIX: Windows build did no more work with Boost 1.59 and needs to have the BOOST_ASIO_OPTION_STORAGE defined.

--- pre/boost/asio/detail/mockup_serial_port_service.hpp
+++ pre/boost/asio/detail/mockup_serial_port_service.hpp
@@ -27,6 +27,14 @@
 #include <boost/thread/condition_variable.hpp>
 #include <boost/thread/recursive_mutex.hpp>

+#if defined(GENERATING_DOCUMENTATION)
+# define BOOST_ASIO_OPTION_STORAGE implementation_defined
+#elif defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__)
+# define BOOST_ASIO_OPTION_STORAGE DCB
+#else
+# define BOOST_ASIO_OPTION_STORAGE termios
+#endif
+
 namespace boost {
 namespace asio {
 namespace detail {
@@ -320,18 +328,14 @@

 private:

-#ifdef _WIN32
-	struct termios {};
-#endif
-
   // Function pointer type for storing a serial port option.
   typedef boost::system::error_code (*store_function_type)(
-      const void*, termios&, boost::system::error_code&);
+      const void*, BOOST_ASIO_OPTION_STORAGE&, boost::system::error_code&);

   // Helper function template to store a serial port option.
   template <typename SettableSerialPortOption>
   static boost::system::error_code store_option(const void* option,
-      termios& storage, boost::system::error_code& ec)
+      BOOST_ASIO_OPTION_STORAGE& storage, boost::system::error_code& ec)
   {
     return static_cast<const SettableSerialPortOption*>(option)->store(
         storage, ec);
@@ -344,12 +348,12 @@

   // Function pointer type for loading a serial port option.
   typedef boost::system::error_code (*load_function_type)(
-      void*, const termios&, boost::system::error_code&);
+      void*, const BOOST_ASIO_OPTION_STORAGE&, boost::system::error_code&);

   // Helper function template to load a serial port option.
   template <typename GettableSerialPortOption>
   static boost::system::error_code load_option(void* option,
-      const termios& storage, boost::system::error_code& ec)
+      const BOOST_ASIO_OPTION_STORAGE& storage, boost::system::error_code& ec)
   {
     return static_cast<GettableSerialPortOption*>(option)->load(storage, ec);
   }
@@ -361,7 +365,7 @@

   io_service& io_service_;
-  termios termios_storage;
+  BOOST_ASIO_OPTION_STORAGE termios_storage;
 };

 } // namespace detail


InUniverse should always throw exception, rather than only if debugging enabled

--- bpmodule/math/MathSet.hpp
+++ bpmodule/math/MathSet.hpp
@@ -69,10 +69,8 @@
             ///Checks if Elem (either as type T or as size_t) is in the universe
             template<typename V>
             void InUniverse(const V& Elem)const {
-                exception::Assert<exception::ValueOutOfRange>(
-                        Universe_->Contains(Elem),
-                        "Requested element is not in the universe for this set"
-                        );
+                if(!Universe_->Contains(Elem))
+                    throw exception::ValueOutOfRange("Requested element is not in the universe for this set");
             }

             MathSet(std::shared_ptr<const Base_t> Universe, const std::set<size_t> & Elems)


More scaling factors for Benchmark 5

More scaling factors for Benchmark 5

--- benchmarks/allocators/benchmark_5.cc
+++ benchmarks/allocators/benchmark_5.cc
@@ -926,7 +926,7 @@
 		typename alloc_containers::DS9<alloc_adaptors<combined_containers::DS1_mono>::monotonic, alloc_adaptors<int>::monotonic>,
 		typename alloc_containers::DS9<alloc_adaptors<combined_containers::DS1_multi>::multipool, alloc_adaptors<int>::multipool>,
 		typename alloc_containers::DS9<alloc_adaptors<combined_containers::DS1_poly>::polymorphic, alloc_adaptors<int>::polymorphic>,
-		process_DS9>, "**DS9**", 2);
+		process_DS9>, "**DS9**", 30);
 	run_nested_loop(&run_base_allocations<typename containers::DS10,
 		typename alloc_containers::DS10<string::monotonic, alloc_adaptors<combined_containers::DS2_mono>::monotonic, alloc_adaptors<string::monotonic>::monotonic>,
 		typename alloc_containers::DS10<string::multipool, alloc_adaptors<combined_containers::DS2_multi>::multipool, alloc_adaptors<string::multipool>::multipool>,


Fixed stdout output order.

Fixed stdout output order.

--- extractor/run_extractor.cc
+++ extractor/run_extractor.cc
@@ -34,6 +34,11 @@
 using namespace std;
 using namespace extractor;
 using namespace features;
+
+fs::path GetGrammarFilePath(const fs::path& grammar_path, int file_number) {
+  string file_name = "grammar." + to_string(file_number);
+  return grammar_path / file_name;
+}

 int main(int argc, char** argv) {
   int num_threads_default = 1;
@@ -184,34 +189,32 @@
   }

   string sentence;
-  vector<string> sentences;
+  vector<string> sentences, suffixes;
   while (getline(cin, sentence)) {
     sentences.push_back(sentence);
   }

   #pragma omp parallel for schedule(dynamic) \
-      num_threads(vm["threads"].as<int>()) ordered
+      num_threads(vm["threads"].as<int>())
   for (size_t i = 0; i < sentences.size(); ++i) {
-    string delimiter = "|||";
-    string suffix = "";
+    string delimiter = "|||", suffix;
     int position = sentences[i].find(delimiter);
     if (position != sentences[i].npos) {
       suffix = sentences[i].substr(position);
       sentences[i] = sentences[i].substr(0, position);
     }
+    suffixes.push_back(suffix);

     Grammar grammar = extractor.GetGrammar(sentences[i]);
-    string file_name = "grammar." + to_string(i);
-    fs::path grammar_file = grammar_path / file_name;
-    ofstream output(grammar_file.c_str());
+    ofstream output(GetGrammarFilePath(grammar_path, i).c_str());
     output << grammar;
-
-    #pragma omp critical (stdout_write)
-    {
-      cout << "<seg grammar=\"" << grammar_file << "\" id=\"" << i << "\"> "
-           << sentences[i] << " </seg> " << suffix << endl;
-    }
-  }
+  }
+
+  for (size_t i = 0; i < sentences.size(); ++i) {
+    cout << "<seg grammar=\"" << GetGrammarFilePath(grammar_path, i) << "\" id=\""
+         << i << "\"> " << sentences[i] << " </seg> " << suffixes[i] << endl;
+  }
+
   Clock::time_point extraction_stop_time = Clock::now();
   cerr << "Overall extraction step took "
        << GetDuration(extraction_start_time, extraction_stop_time)


Fix Gray loading CMYK size

Fix Gray loading CMYK size

--- ase/ase.cpp
+++ ase/ase.cpp
@@ -235,7 +235,7 @@
 					ColorType::Gray CurColor;
 					Stream.read(
 						reinterpret_cast<char*>(&CurColor),
-						sizeof(ColorType::CMYK)
+						sizeof(ColorType::Gray)
 					);
 					*reinterpret_cast<uint32_t*>(&CurColor[0]) = SWAP32(*reinterpret_cast<uint32_t*>(&CurColor[0]));
 					Callback.ColorGray(


Read and write config return first unused EEPROM address

--- Libraries/HMTLTypes/HMTLTypes.cpp
+++ Libraries/HMTLTypes/HMTLTypes.cpp
@@ -55,6 +55,10 @@
   }
 }

+/*
+ * Read in the HMTL config, returning the EEProm address following
+ * what was read.
+ */
 int hmtl_read_config(config_hdr_t *hdr, config_max_t outputs[],
                      int max_outputs)
 {
@@ -87,11 +91,17 @@
     }
   }

-  DEBUG_VALUELN(DEBUG_LOW, "hmtl_read_config: read address=", hdr->address);
-
-  return hdr->address;
-}
-
+  DEBUG_VALUE(DEBUG_LOW, "hmtl_read_config: size=", addr - HMTL_CONFIG_ADDR);
+  DEBUG_VALUELN(DEBUG_LOW, " end=", addr);
+  DEBUG_VALUELN(DEBUG_LOW, " module address=", hdr->address);
+
+  return addr;
+}
+
+/*
+ * Write out the HMTL config, returning the EEProm address following
+ * what was written.
+ */
 int hmtl_write_config(config_hdr_t *hdr, output_hdr_t *outputs[])
 {
   int addr;
@@ -101,7 +111,7 @@
                            (uint8_t *)hdr, sizeof (config_hdr_t));
   if (addr < 0) {
     DEBUG_ERR("hmtl_write_config: failed to write config to EEProm");
-    return 0;
+    return -1;
   }

   for (int i = 0; i < hdr->num_outputs; i++) {
@@ -110,11 +120,14 @@
                              hmtl_output_size(output));
     if (addr < 0) {
       DEBUG_ERR("hmtl_write_config: failed to write outputs to EEProm");
-      return 0;
-    }
-  }
-
-  return 1;
+      return -2;
+    }
+  }
+
+  DEBUG_VALUE(DEBUG_LOW, "hmtl_write_config: size=", addr - HMTL_CONFIG_ADDR);
+  DEBUG_VALUELN(DEBUG_LOW, " end=", addr);
+
+  return addr;
 }

 /* Initialized the pins of an output */
@@ -162,7 +175,7 @@
       }
       case HMTL_OUTPUT_MPR121:
       {
-        DEBUG_PRINT(DEBUG_HIGH, " mpr121");
+        DEBUG_PRINTLN(DEBUG_HIGH, " mpr121");
         if (data != NULL) {
           config_mpr121_t *out = (config_mpr121_t *)hdr;
 	  MPR121 *capSensor = (MPR121 *)data;
@@ -188,7 +201,7 @@
           config_rs485_t *out = (config_rs485_t *)hdr;
 	  RS485Socket *rs485 = (RS485Socket *)data;
 	  *rs485 = RS485Socket(out->recvPin, out->xmitPin, out->enablePin,
-			       false); // Set to true to enable debugging
+			       true); // Set to true to enable debugging
         } else {
           DEBUG_ERR("Expected RS485Socket data struct for RS485 configs");
           return -1;


Install correct crash handler to clean up the addressbook. Also check if file resource can be added to addressbook

svn path=/trunk/kdepim/; revision=239368

--- kpilot/conduits/abbrowserconduit/abbrowser-conduit.cc
+++ kpilot/conduits/abbrowserconduit/abbrowser-conduit.cc
@@ -97,7 +97,7 @@
 {
 	kdWarning()<<"Crash handler, cleaning up addressbook"<<endl;
 	if (aBook) aBook->cleanUp();
-	::exit( 0 );
+	KCrash::defaultCrashHandler(sig);
 }

@@ -122,8 +122,8 @@
 #endif
 	fConduitName=i18n("Addressbook");
 	// Set crash handler, store old handler
-	oldCleanupOnCrash=KCrash::emergencySaveFunction();
-	KCrash::setEmergencySaveFunction(AbbrowserConduit::cleanupOnCrash);
+	oldCleanupOnCrash=KCrash::crashHandler();
+	KCrash::setCrashHandler(AbbrowserConduit::cleanupOnCrash);
 }

@@ -131,7 +131,7 @@
 AbbrowserConduit::~AbbrowserConduit()
 {
 	FUNCTIONSETUP;
-	if (oldCleanupOnCrash) KCrash::setEmergencySaveFunction(oldCleanupOnCrash);
+	if (oldCleanupOnCrash) KCrash::setCrashHandler(oldCleanupOnCrash);
 }

@@ -289,13 +289,7 @@
 				// the filename instead of having to use a config file)
 				KRES::Resource*rawres=resfact->resource("file", fConfig);
 				KABC::Resource*abookres=dynamic_cast<KABC::Resource*>(rawres);
-				if (abookres)
-				{
-//					abookres->setAddressBook(aBook);
-					aBook->addResource(abookres);
-//					aBook->setStandardResource(abookres);
-				}
-				else
+				if ((!abookres) || (!aBook->addResource(abookres)) )
 				{
 					kdWarning()<<k_funcinfo<<": Unable to open addressbook resource "
 						<<"for file "<<fAbookFile<<endl;


Don't draw children if Node child vector is empty

--- ouzel/Node.cpp
+++ ouzel/Node.cpp
@@ -99,41 +99,48 @@

     void Node::process()
     {
-        lock();
-
-        auto i = _children.begin();
-        NodePtr node;
-
-        for (; i != _children.end(); ++i)
-        {
-            node = *i;
-
-            if (node->getZ() < 0.0f)
-            {
+        if (_children.empty())
+        {
+            draw();
+        }
+        else
+        {
+            lock();
+
+            auto i = _children.begin();
+            NodePtr node;
+
+            for (; i != _children.end(); ++i)
+            {
+                node = *i;
+
+                if (node->getZ() < 0.0f)
+                {
+                    if (!node->isGlobalOrder() && node->isVisible() && node->checkVisibility())
+                    {
+                        node->draw();
+                    }
+                }
+                else
+                {
+                    break;
+                }
+            }
+
+            draw();
+
+            for (; i != _children.end(); ++i)
+            {
+                node = *i;
+
                 if (!node->isGlobalOrder() && node->isVisible() && node->checkVisibility())
                 {
                     node->draw();
                 }
             }
-            else
-            {
-                break;
-            }
-        }
-
-        draw();
-
-        for (; i != _children.end(); ++i)
-        {
-            node = *i;
-
-            if (!node->isGlobalOrder() && node->isVisible() && node->checkVisibility())
-            {
-                node->draw();
-            }
-        }
-
-        unlock();
+
+            unlock();
+        }
     }

     void Node::draw()


Fixed random number generation producing bad indicies for Benchmark_5 deallocatoins

--- benchmarks/allocators/benchmark_5.cc
+++ benchmarks/allocators/benchmark_5.cc
@@ -109,9 +109,9 @@
 	{
 		subsystem_sizes[i] = subsystem_size_distribution(generator);
 	}
-	for (int i = SUBSYSTEM_COUNT - 1; i >= 0; i--)
-	{
-		std::uniform_int_distribution<size_t> subsystem_delete_index_distribution(0, i);
+	for (size_t i = 0; i < SUBSYSTEM_COUNT; i++)
+	{
+		std::uniform_int_distribution<size_t> subsystem_delete_index_distribution(0, SUBSYSTEM_COUNT - i - 1);
 		subsystem_delete_indicies[i] = subsystem_delete_index_distribution(generator);
 	}
 }


Add code to emulate LDRSB (literal) Arm instruction.

git-svn-id: b33bab8abb5b18c12ee100cd7761ab452d00b2b0@126789 91177308-0d34-0410-b5e6-96231b3b80d8

--- source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -6458,6 +6458,99 @@
         }
     }

+    return true;
+}
+
+// LDRSB (literal) calculates an address from the PC value and an immediate offset, loads a byte from memory,
+// sign-extends it to form a 32-bit word, and writes tit to a register.
+bool
+EmulateInstructionARM::EmulateLDRSBLiteral (ARMEncoding encoding)
+{
+#if 0
+    if ConditionPassed() then
+        EncodingSpecificOperations(); NullCheckIfThumbEE(15);
+        base = Align(PC,4);
+        address = if add then (base + imm32) else (base - imm32);
+        R[t] = SignExtend(MemU[address,1], 32);
+#endif
+
+    bool success = false;
+    const uint32_t opcode = OpcodeAsUnsigned (&success);
+    if (!success)
+        return false;
+
+    if (ConditionPassed ())
+    {
+        uint32_t t;
+        uint32_t imm32;
+        bool add;
+
+        // EncodingSpecificOperations(); NullCheckIfThumbEE(15);
+        switch (encoding)
+        {
+            case eEncodingT1:
+                // if Rt == ’1111’ then SEE PLI;
+                // t = UInt(Rt); imm32 = ZeroExtend(imm12, 32); add = (U == ’1’);
+                t = Bits32 (opcode, 15, 12);
+                imm32 = Bits32 (opcode, 11, 0);
+                add = BitIsSet (opcode, 23);
+
+                // if t == 13 then UNPREDICTABLE;
+                if (t == 13)
+                    return false;
+
+                break;
+
+            case eEncodingA1:
+            {
+                // t == UInt(Rt); imm32 = ZeroExtend(imm4H:imm4L, 32); add = (U == ’1’);
+                t = Bits32 (opcode, 15, 12);
+                uint32_t imm4H = Bits32 (opcode, 11, 8);
+                uint32_t imm4L = Bits32 (opcode, 3, 0);
+                imm32 = (imm4H << 4) & imm4L;
+                add = BitIsSet (opcode, 23);
+
+                // if t == 15 then UNPREDICTABLE;
+                if (t == 15)
+                    return false;
+
+                break;
+            }
+
+            default:
+                return false;
+        }
+
+        // base = Align(PC,4);
+        uint64_t pc_value = ReadRegisterUnsigned (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_ADDRESS,
+                                                  &success);
+        if (!success)
+            return false;
+        uint64_t base = AlignPC (pc_value);
+
+        // address = if add then (base + imm32) else (base - imm32);
+        addr_t address;
+        if (add)
+            address = base + imm32;
+        else
+            address = base - imm32;
+
+        // R[t] = SignExtend(MemU[address,1], 32);
+        Register base_reg;
+        base_reg.SetRegister (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
+
+        EmulateInstruction::Context context;
+        context.type = eContextRegisterLoad;
+        context.SetRegisterPlusOffset (base_reg, address - base);
+
+        uint64_t unsigned_data = MemURead (context, address, 1, 0, &success);
+        if (!success)
+            return false;
+
+        int64_t signed_data = llvm::SignExtend64<8>(unsigned_data);
+        if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + t, (uint64_t) signed_data))
+            return false;
+    }
     return true;
 }

@@ -7836,6 +7929,7 @@
         { 0x0e5f00f0, 0x005f00b0, ARMvAll,       eEncodingA1, eSize32, &EmulateInstructionARM::EmulateLDRHLiteral, "ldrh<c> <Rt>, <label>" },
         { 0x0e5000f0, 0x001000b0, ARMvAll,       eEncodingA1, eSize32, &EmulateInstructionARM::EmulateLDRHRegister, "ldrh<c> <Rt>,[<Rn>,+/-<Rm>]{!}"  },
         { 0x0e5000f0, 0x005000d0, ARMvAll,       eEncodingA1, eSize32, &EmulateInstructionARM::EmulateLDRSBImmediate, "ldrsb<c> <Rt>, [<Rn>{,#+/-<imm8>}]" },
+        { 0x0e5f00f0, 0x005f00d0, ARMvAll,       eEncodingA1, eSize32, &EmulateInstructionARM::EmulateLDRSBLiteral, "ldrsb<c> <Rt> <label>" },

         //----------------------------------------------------------------------
         // Store instructions
@@ -8082,6 +8176,7 @@
         { 0xfff00fc0, 0xf8300000, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateLDRHRegister, "ldrh<c>.w <Rt>,[<Rn>,<Rm>{,LSL #<imm2>}]" },
         { 0xfff00000, 0xf9900000, ARMV6T2_ABOVE, eEncodingT1, eSize32, &EmulateInstructionARM::EmulateLDRSBImmediate, "ldrsb<c> <Rt>,[<Rn>,#<imm12>]" },
         { 0xfff00800, 0xf9100800, ARMV6T2_ABOVE, eEncodingT2, eSize32, &EmulateInstructionARM::EmulateLDRSBImmediate, "ldrsb<c> <Rt>,[<Rn>,#+/-<imm8>]" },
+        { 0xff7f0000, 0xf91f0000, ARMV6T2_ABOVE, eEncodingT1, eSize32, &EmulateInstructionARM::EmulateLDRSBLiteral, "ldrsb<c> <Rt>, <label>" },

         //----------------------------------------------------------------------
         // Store instructions


give references to start_func

give references to start_func

--- benchmarks/word_count/word_count.cpp
+++ benchmarks/word_count/word_count.cpp
@@ -43,7 +43,7 @@
     clp.PrintResult();

     auto start_func =
-        [input, output](api::Context& ctx) {
+        [&input, &output](api::Context& ctx) {
 		auto input_dia = ReadLines(ctx, input);
 		auto counted_words = examples::WordCount(input_dia);
 		counted_words.Map(


Make workspace id type consistent with net-rewriting pipeline

Summary: There are two components that deal with workspace ids: 1) comm framework, 2) injection of GLOBAL_WORKSPACE_ID. The type of workspace id should be consistent for these components. 32 bits integers should be sufficient for such ids.

Reviewed By: akyrola

Differential Revision: D6443675

fbshipit-source-id: 7b0e8a3b005683350706fa5c330abf0a9d4881dd

--- caffe2/core/plan_executor.cc
+++ caffe2/core/plan_executor.cc
@@ -142,12 +142,15 @@
       Blob* node_id_blob = workspace->GetBlob(NODE_ID);
       TensorCPU node_id_tensor = node_id_blob->template Get<TensorCPU>();
       int node_id = node_id_tensor.template data<int32_t>()[0];
-      int64_t global_ws_id = (seq_++) + (static_cast<int64_t>(node_id) << 32);
+      CAFFE_ENFORCE(
+          seq_ < (1 << 16),
+          "Integer overflow while calculating GLOBAL_WORKSPACE_ID blob");
+      int32_t global_ws_id = (seq_++) + (static_cast<int32_t>(node_id) << 16);
       Blob* global_ws_id_blob = workspace->CreateLocalBlob(GLOBAL_WORKSPACE_ID);
       TensorCPU* global_ws_id_tensor =
           global_ws_id_blob->template GetMutable<TensorCPU>();
       global_ws_id_tensor->Resize();
-      global_ws_id_tensor->template mutable_data<int64_t>()[0] = global_ws_id;
+      global_ws_id_tensor->template mutable_data<int32_t>()[0] = global_ws_id;
       VLOG(1) << "Adding " << GLOBAL_WORKSPACE_ID << " = " << global_ws_id;
     }
   }


Fixed bug in automatic step type detection in addFootstep().

--- WMG/WMG.cpp
+++ WMG/WMG.cpp
@@ -177,7 +177,7 @@
         // determine type of the step
         if (type == FS_TYPE_AUTO)
         {
-            switch (FS.back().type)
+            switch (FS[getPrevSS(FS.size())].type)
             {
                 case FS_TYPE_SS_L:
                     type = FS_TYPE_SS_R;


Fix the removal of old messages

Fix the removal of old messages

- it was disabled;
- the time handling was broken :/

--- src/client.cpp
+++ src/client.cpp
@@ -58,7 +58,7 @@
 }

 void client::clear(std::chrono::steady_clock::time_point time)
-{return;
+{
   size_t count = 0;
   while (!queue_.empty()) {
     auto i = queue_.begin();
@@ -133,7 +133,7 @@

   if (socket_.is_open()) {

-    this->clear(std::chrono::steady_clock::now() + service_->time_to_live());
+    this->clear(std::chrono::steady_clock::now() - service_->time_to_live());

     // Choose a client ID:
     context_->client_id_ = this->random_client_id();
@@ -228,7 +228,7 @@
     std::memcpy(&client_id, buffer_.data(), sizeof(client_id));
     by_client_id_type::iterator i = by_client_id_.find(client_id,
       order_message_by_client_id());
-    by_client_id_type::iterator end;
+    by_client_id_type::iterator end = by_client_id_.end();
     if (i == end) {
       LOG(ERR) << "Reply received not expected\n";
       this->start_receive();


fix incorrect use of bitwise operations

fix incorrect use of bitwise operations

--- src/client.cpp
+++ src/client.cpp
@@ -267,7 +267,7 @@
     // read .bmp file head
     RectFramePixelR.read((char *)bmp_head, sizeof(bmp_head));
     RectFramePixelR.read((char *)CapPixelData[0], sizeof(CapPixelData));
-    if ( (RectFramePixelR.rdstate() & (RectFramePixelR.fail() |
+    if ( (RectFramePixelR.rdstate() && (RectFramePixelR.fail() ||
           RectFramePixelR.bad())) != 0) {
         error(True, "[Replaying -> GetTargetFrame] there is something wrong"
                     " when reading replaying file");
@@ -346,7 +346,7 @@
     AU_BOOL WaitForFrame, match;
     WaitForFrame = False;    // defualt value

-    if ((ReplayFile.rdstate() & (ReplayFile.fail() | ReplayFile.bad())) != 0) {
+    if ((ReplayFile.rdstate() && (ReplayFile.fail() || ReplayFile.bad())) != 0) {
         error(True, "ERROR: [Replaying -> SendReplayerInput] reading replay"
                     " file ");
     }
@@ -357,7 +357,7 @@
             pthread_mutex_lock(&mutex);
             log << "[Replaying] handling a rfbPkt" << endl;
             pthread_mutex_unlock(&mutex);
-            if ((ReplayFile.rdstate() & (ReplayFile.fail() |
+            if ((ReplayFile.rdstate() && (ReplayFile.fail() ||
                  ReplayFile.bad())) != 0) {
                 error(True, "ERROR: [Replaying -> SendReplayerInput]"
                             " reading replay file ");
@@ -368,7 +368,7 @@
             pthread_mutex_lock(&mutex);
             log << "[Replaying] handling a timewaitPkt" << endl;
             pthread_mutex_unlock(&mutex);
-            if ((ReplayFile.rdstate() & (ReplayFile.fail() |
+            if ((ReplayFile.rdstate() && (ReplayFile.fail() ||
                 ReplayFile.bad())) != 0) {
                 error(True, "ERROR: [Replaying -> SendReplayerInput]"
                             " reading replay file ");
@@ -380,7 +380,7 @@
             pthread_mutex_lock(&mutex);
             log << "[Replaying] handling a timesyncPkt" << endl;
             pthread_mutex_unlock(&mutex);
-            if ((ReplayFile.rdstate() & (ReplayFile.fail() |
+            if ((ReplayFile.rdstate() && (ReplayFile.fail() ||
                 ReplayFile.bad())) != 0) {
                 error(True, "ERROR: [Replaying -> SendReplayerInput] "
                             "reading replay file ");


begin adding photon map generation to our ray tracer

--- ray-tracer.cpp
+++ ray-tracer.cpp
@@ -57,6 +57,7 @@
 float* zImg;
 float* sampleImg;
 IrradianceMap im;
+PhotonMap *pm;

 // variables for anti-aliasing brightness calculations (XYZ, Lab)
@@ -155,6 +156,20 @@
     }
   }

+  // compute a photon map for global illumination
+  if(photonMap){
+
+    // initialize photon map
+    pm = createPhotonMap(samplesPM);
+
+    // fill our photon map
+    while(pm->stored_photons < samplesPM){
+
+      //
+
+    }
+  }
+
   // start ray tracing loop (in parallel with threads)
   thread t[numThreads];
   for(int i = 0; i < numThreads; i++)


Fix Client::timerHandler() not including id, and fix list() not resetting.

--- src/client.cxx
+++ src/client.cxx
@@ -137,6 +137,7 @@
   if (isIteratingAdverts) return;

   isIteratingAdverts = true;
+  advertIterator.reset();
   setIterationTimer();
 }
 void Client::sign(const byte* dat, unsigned len) {
@@ -179,11 +180,12 @@

 void Client::timerHandler(const asio::error_code&) {
   asio::ip::udp::endpoint from;
-  vector<byte> pack(1 + realm->addressSize + 2);
+  vector<byte> pack(1 + 4 + realm->addressSize + 2);
   if (advertIterator.next(from, pack)) {
     pack[0] = PAK_ADVERT;
-    realm->encodeAddress(&pack[1], from.address());
-    WRITE(unsigned short, &pack[1+realm->addressSize]) = from.port();
+    WRITE(unsigned, &pack[1]) = id;
+    realm->encodeAddress(&pack[1+4], from.address());
+    WRITE(unsigned short, &pack[1+4+realm->addressSize]) = from.port();
     sendPacket(endpoint, &pack[0], pack.size());
     setIterationTimer();
   } else {


fixed small memory leak, and double free of cigar

--- src/cluster.cc
+++ src/cluster.cc
@@ -1110,6 +1110,7 @@
       int msa_target_count = 0;
       struct msa_target_s * msa_target_list =
         (struct msa_target_s *) xmalloc(sizeof(struct msa_target_s) * size_max);
+      //memset(msa_target_list, 0, sizeof(struct msa_target_s)*size_max);

       progress_init("Multiple alignments", seqcount);

@@ -1162,13 +1163,16 @@

       if (fp_consout)
         fclose(fp_consout);
+
+      free(msa_target_list);
     }

   /* free cigar strings for all aligned sequences */
+  /*
   for(int i=0; i<seqcount; i++)
     if (clusterinfo[i].cigar)
       free(clusterinfo[i].cigar);
-
+  */
   free(clusterinfo);

   if (opt_matched)


Bug Fix: Wrong event was fired for changes to GUI sheet.

--- src/CEGUISystem.cpp
+++ src/CEGUISystem.cpp
@@ -405,7 +405,7 @@

 	// fire event
 	WindowEventArgs args(old);
-	onDefaultFontChanged(args);
+	onGUISheetChanged(args);

 	return old;
 }


Static Call Fix in setDefaultXMLParserName

--- src/CEGUISystem.cpp
+++ src/CEGUISystem.cpp
@@ -1566,9 +1566,14 @@
 	if(d_defaultXMLParserName == parserName)
 		return;

-	cleanupXMLParser();
-    d_defaultXMLParserName = parserName;
-	setupXMLParser();
+	//We do this becuase cleanup and setup aren't static functions
+	if(getSingletonPtr())
+	{
+		System* sys = getSingletonPtr();
+		sys->cleanupXMLParser();
+		d_defaultXMLParserName = parserName;
+		sys->setupXMLParser();
+	} // if(getSingletonPtr())
 #endif
 }


fix typo

fix typo

--- apps/common/commandline/SceneParser/trianglemesh/TriangleMeshSceneParser.cpp
+++ apps/common/commandline/SceneParser/trianglemesh/TriangleMeshSceneParser.cpp
@@ -453,7 +453,7 @@
     sceneModel->commit();
   }
   auto end_make_scene = high_resolution_clock::now();
-  std::cout << "Buiding OSPRay models took "
+  std::cout << "Building OSPRay models took "
     << duration_cast<milliseconds>(end_make_scene - start_make_scene).count()
     << "ms\n";
 }


another small fix

another small fix

--- LinkedList.hpp
+++ LinkedList.hpp
@@ -62,9 +62,9 @@

 	// only single consumer supported
 	ItemPtr pop_front() {
-		if(first) {
-			ItemPtr oldFirst = first;
-			first = first->next;
+		ItemPtr oldFirst = first;
+		if(oldFirst) {
+			first = oldFirst->next;
 			if(!first) last = NULL;
 			return oldFirst;
 		}