Fixed a bug with reversed hex color order in buffer_graphics function causing red screen instead of black

--- src/screen.c
+++ src/screen.c
@@ -52,7 +52,7 @@
     for (int i = 0; i < SCREEN_HEIGHT; i++) {
         for (int j = 0; j < SCREEN_WIDTH; j++) {
             uint8_t pixel = chip8->screen[i][j];
-            buffer[(i * SCREEN_WIDTH) + j] = (0x00FFFFFF * pixel) | 0xFF000000;
+            buffer[(i * SCREEN_WIDTH) + j] = (0xFFFFFF00 * pixel) | 0x000000FF;
         }
     }
 }


Use linear filtering for scaling the window

--- src/screen.c
+++ src/screen.c
@@ -44,6 +44,8 @@
         screenSetError("initScreen", "Error initializing SDL", 1);
         return 0;
     }
+
+    SDL_SetHint( SDL_HINT_RENDER_SCALE_QUALITY, "1" );

     if(!(IMG_Init(SDL_IMG_INIT_FLAGS) & SDL_IMG_INIT_FLAGS)) {
         screenSetError("initScreen", "Error initializing SDL image loader", 0);


script: add CScriptNum class

script: add CScriptNum class

This class holds an int64_t and replaces the use of CBigInt for script
integrals.

--- src/script.h
+++ src/script.h
@@ -24,6 +24,155 @@

 static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // bytes
 static const unsigned int MAX_OP_RETURN_RELAY = 40;      // bytes
+
+class scriptnum_error : public std::runtime_error
+{
+public:
+    explicit scriptnum_error(const std::string& str) : std::runtime_error(str) {}
+};
+
+class CScriptNum
+{
+// Numeric opcodes (OP_1ADD, etc) are restricted to operating on 4-byte integers.
+// The semantics are subtle, though: operands must be in the range [-2^31 +1...2^31 -1],
+// but results may overflow (and are valid as long as they are not used in a subsequent
+// numeric operation). CScriptNum enforces those semantics by storing results as
+// an int64 and allowing out-of-range values to be returned as a vector of bytes but
+// throwing an exception if arithmetic is done or the result is interpreted as an integer.
+public:
+
+    explicit CScriptNum(const int64_t& n)
+    {
+        m_value = n;
+    }
+
+    explicit CScriptNum(const std::vector<unsigned char>& vch)
+    {
+        if (vch.size() > nMaxNumSize)
+            throw scriptnum_error("CScriptNum(const std::vector<unsigned char>&) : overflow");
+        m_value = set_vch(vch);
+    }
+
+    inline bool operator==(const int64_t& rhs) const    { return m_value == rhs; }
+    inline bool operator!=(const int64_t& rhs) const    { return m_value != rhs; }
+    inline bool operator<=(const int64_t& rhs) const    { return m_value <= rhs; }
+    inline bool operator< (const int64_t& rhs) const    { return m_value <  rhs; }
+    inline bool operator>=(const int64_t& rhs) const    { return m_value >= rhs; }
+    inline bool operator> (const int64_t& rhs) const    { return m_value >  rhs; }
+
+    inline bool operator==(const CScriptNum& rhs) const { return operator==(rhs.m_value); }
+    inline bool operator!=(const CScriptNum& rhs) const { return operator!=(rhs.m_value); }
+    inline bool operator<=(const CScriptNum& rhs) const { return operator<=(rhs.m_value); }
+    inline bool operator< (const CScriptNum& rhs) const { return operator< (rhs.m_value); }
+    inline bool operator>=(const CScriptNum& rhs) const { return operator>=(rhs.m_value); }
+    inline bool operator> (const CScriptNum& rhs) const { return operator> (rhs.m_value); }
+
+    inline CScriptNum operator+(   const int64_t& rhs)    const { return CScriptNum(m_value + rhs);}
+    inline CScriptNum operator-(   const int64_t& rhs)    const { return CScriptNum(m_value - rhs);}
+    inline CScriptNum operator+(   const CScriptNum& rhs) const { return operator+(rhs.m_value);   }
+    inline CScriptNum operator-(   const CScriptNum& rhs) const { return operator-(rhs.m_value);   }
+
+    inline CScriptNum& operator+=( const CScriptNum& rhs)       { return operator+=(rhs.m_value);  }
+    inline CScriptNum& operator-=( const CScriptNum& rhs)       { return operator-=(rhs.m_value);  }
+
+    inline CScriptNum operator-()                         const
+    {
+        assert(m_value != std::numeric_limits<int64_t>::min());
+        return CScriptNum(-m_value);
+    }
+
+    inline CScriptNum& operator=( const int64_t& rhs)
+    {
+        m_value = rhs;
+        return *this;
+    }
+
+    inline CScriptNum& operator+=( const int64_t& rhs)
+    {
+        assert(rhs == 0 || (rhs > 0 && m_value <= std::numeric_limits<int64_t>::max() - rhs) ||
+                           (rhs < 0 && m_value >= std::numeric_limits<int64_t>::min() - rhs));
+        m_value += rhs;
+        return *this;
+    }
+
+    inline CScriptNum& operator-=( const int64_t& rhs)
+    {
+        assert(rhs == 0 || (rhs > 0 && m_value >= std::numeric_limits<int64_t>::min() + rhs) ||
+                           (rhs < 0 && m_value <= std::numeric_limits<int64_t>::max() + rhs));
+        m_value -= rhs;
+        return *this;
+    }
+
+    int getint() const
+    {
+        if (m_value > std::numeric_limits<int>::max())
+            return std::numeric_limits<int>::max();
+        else if (m_value < std::numeric_limits<int>::min())
+            return std::numeric_limits<int>::min();
+        return m_value;
+    }
+
+    std::vector<unsigned char> getvch() const
+    {
+        return serialize(m_value);
+    }
+
+    static std::vector<unsigned char> serialize(const int64_t& value)
+    {
+        if(value == 0)
+            return std::vector<unsigned char>();
+
+        std::vector<unsigned char> result;
+        const bool neg = value < 0;
+        uint64_t absvalue = neg ? -value : value;
+
+        while(absvalue)
+        {
+            result.push_back(absvalue & 0xff);
+            absvalue >>= 8;
+        }
+
+
+//    - If the most significant byte is >= 0x80 and the value is positive, push a
+//    new zero-byte to make the significant byte < 0x80 again.
+
+//    - If the most significant byte is >= 0x80 and the value is negative, push a
+//    new 0x80 byte that will be popped off when converting to an integral.
+
+//    - If the most significant byte is < 0x80 and the value is negative, add
+//    0x80 to it, since it will be subtracted and interpreted as a negative when
+//    converting to an integral.
+
+        if (result.back() & 0x80)
+            result.push_back(neg ? 0x80 : 0);
+        else if (neg)
+            result.back() |= 0x80;
+
+        return result;
+    }
+
+    static const size_t nMaxNumSize = 4;
+
+private:
+    static int64_t set_vch(const std::vector<unsigned char>& vch)
+    {
+      if (vch.empty())
+          return 0;
+
+      int64_t result = 0;
+      for (size_t i = 0; i != vch.size(); ++i)
+          result |= static_cast<int64_t>(vch[i]) << 8*i;
+
+      // If the input vector's most significant byte is 0x80, remove it from
+      // the result's msb and return a negative.
+      if (vch.back() & 0x80)
+          return -(result & ~(0x80 << (8 * (vch.size() - 1))));
+
+      return result;
+    }
+
+    int64_t m_value;
+};

 /** Signature hash types/flags */
 enum


Fixed merge candidate scaling in hexbs and excluded weighted pred candidates in cost calc

--- src/search.c
+++ src/search.c
@@ -177,7 +177,8 @@

   // Check every candidate to find a match
   for(merge_idx = 0; merge_idx < (uint32_t)num_cand; merge_idx++) {
-    if (merge_cand[merge_idx].mv[merge_cand[merge_idx].dir-1][0] == x &&
+    if (merge_cand[merge_idx].dir == 3) continue;
+    if (merge_cand[merge_idx].mv[merge_cand[merge_idx].dir - 1][0] == x &&
         merge_cand[merge_idx].mv[merge_cand[merge_idx].dir - 1][1] == y &&
         merge_cand[merge_idx].ref == ref_idx) {
       temp_bitcost += merge_idx;
@@ -594,7 +595,9 @@
   // Check mv_in, if it's not in merge candidates.
   bool mv_in_merge_cand = false;
   for (int i = 0; i < num_cand; ++i) {
-    if (merge_cand[i].mv[merge_cand[i].dir - 1][0] >> 2 == mv.x && merge_cand[i].mv[merge_cand[i].dir - 1][1] == mv.y) {
+    if (merge_cand[i].dir == 3) continue;
+    if (merge_cand[i].mv[merge_cand[i].dir - 1][0] >> 2 == mv.x &&
+        merge_cand[i].mv[merge_cand[i].dir - 1][1] >> 2 == mv.y) {
       mv_in_merge_cand = true;
       break;
     }


Do not check filename lengths when using directory_tree=0.

--- src/server.c
+++ src/server.c
@@ -1290,8 +1290,11 @@
 static int add_name_max(char **feat, struct config *cconf)
 {
 	char msg[32];
-	long name_max;
-	name_max=pathconf(cconf->directory, _PC_NAME_MAX);
+	long name_max=0;
+	// Only need to be careful about name lengths if the files are
+	// being saved in a directory tree.
+	if(cconf->directory_tree)
+		name_max=pathconf(cconf->directory, _PC_NAME_MAX);
 	snprintf(msg, sizeof(msg), "name_max=%lu", name_max);
 	return append_to_feat(feat, msg);
 }


Update server.c

Update server.c

--- src/server.c
+++ src/server.c
@@ -21,7 +21,6 @@
 #include <signal.h>
 #include <pthread.h>

-#include <zlog.h>
 #include <jansson/jansson.h>

 #include <openssl/rsa.h>


Improve timer callback creation comment.

--- src/server.c
+++ src/server.c
@@ -1959,8 +1959,9 @@
     server.repl_good_slaves_count = 0;
     updateCachedTime();

-    /* Create out timers, that's our main way to process background
-     * operations. */
+    /* Create the timer callback, this is our way to process many background
+     * operations incrementally, like clients timeout, eviction of unaccessed
+     * expired keys and so forth. */
     if (aeCreateTimeEvent(server.el, 1, serverCron, NULL, NULL) == AE_ERR) {
         serverPanic("Can't create event loop timers.");
         exit(1);


Fix warning

Fix warning

--- src/server.c
+++ src/server.c
@@ -164,6 +164,7 @@
   #endif
       default:
         ssh_set_error(session,SSH_FATAL,"Wrong kex type in ssh_packet_kexdh_init");
+        rc = SSH_ERROR;
   }
   if (rc == SSH_ERROR)
       session->session_state = SSH_SESSION_STATE_ERROR;


Lookup ciphersuites in mbedtls directly

Lookup ciphersuites in mbedtls directly

This removes the "whitelist" of configurable ciphersuites in server.c and
replaces it with a call to search the polarssl table of ciphersuites. The table
was never sufficient for blocking weak ciphers since the default set of ciphers
always bypassed it.

Since polarssl requires ciphersuite names to use dashes, any underscores (used
previously) in teh ciphersuite name are replaced by dashes and both are
supported in the config file.

PolarSSL is asked to verify that a ciphersuite is supported through either
ssl_ciphersuite_from_id or ssl_ciphersuite_from_string instead of using ifdefs.

--- src/server.c
+++ src/server.c
@@ -60,154 +60,18 @@
     int id;
 } CipherName;

-#define _CIPHER(x) {#x, x}
-static CipherName cipher_table[] =
-{
-#ifdef POLARSSL_KEY_EXCHANGE_PSK_ENABLED
-    // TLS_PSK_WITH_RC4_128_SHA is weak do not use it
-    _CIPHER(TLS_PSK_WITH_3DES_EDE_CBC_SHA),                 // TLSv1.0 + RFC4279 (PSK ciphersuites)
-    _CIPHER(TLS_PSK_WITH_AES_128_CBC_SHA),                  // TLSv1.0 + RFC4279 (PSK ciphersuites)
-    _CIPHER(TLS_PSK_WITH_AES_256_CBC_SHA),                  // TLSv1.0 + RFC4279 (PSK ciphersuites)
-    _CIPHER(TLS_PSK_WITH_AES_128_CBC_SHA256),               // TLSv1.2 + RFC5487 (PSK with SHA-256/384 and AES GCM)
-    _CIPHER(TLS_PSK_WITH_AES_256_CBC_SHA384),               // TLSv1.2 + RFC5487 (PSK with SHA-256/384 and AES GCM)
-    _CIPHER(TLS_PSK_WITH_AES_128_GCM_SHA256),               // TLSv1.2 + RFC5487 (PSK with SHA-256/384 and AES GCM)
-    _CIPHER(TLS_PSK_WITH_AES_256_GCM_SHA384),               // TLSv1.2 + RFC5487 (PSK with SHA-256/384 and AES GCM)
-#endif
-#ifdef POLARSSL_KEY_EXCHANGE_DHE_PSK_ENABLED
-    // TLS_DHE_PSK_WITH_RC4_128_SHA is weak do not use it
-    _CIPHER(TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA),             // TLSv1.0 + RFC4279 (PSK ciphersuites)
-    _CIPHER(TLS_DHE_PSK_WITH_AES_128_CBC_SHA),              // TLSv1.0 + RFC4279 (PSK ciphersuites)
-    _CIPHER(TLS_DHE_PSK_WITH_AES_256_CBC_SHA),              // TLSv1.0 + RFC4279 (PSK ciphersuites)
-    _CIPHER(TLS_DHE_PSK_WITH_AES_128_CBC_SHA256),           // TLSv1.2 + RFC5487 (PSK with SHA-256/384 and AES GCM)
-    _CIPHER(TLS_DHE_PSK_WITH_AES_256_CBC_SHA384),           // TLSv1.2 + RFC5487 (PSK with SHA-256/384 and AES GCM)
-    _CIPHER(TLS_DHE_PSK_WITH_AES_128_GCM_SHA256),           // TLSv1.2 + RFC5487 (PSK with SHA-256/384 and AES GCM)
-    _CIPHER(TLS_DHE_PSK_WITH_AES_256_GCM_SHA384),           // TLSv1.2 + RFC5487 (PSK with SHA-256/384 and AES GCM)
-#endif
-#ifdef POLARSSL_KEY_EXCHANGE_RSA_ENABLED
-    _CIPHER(TLS_RSA_WITH_AES_128_CBC_SHA),                  // TLSv1.0 + RFC3268 (AES ciphersuites)
-    _CIPHER(TLS_RSA_WITH_AES_256_CBC_SHA),                  // TLSv1.0 + RFC3268 (AES ciphersuites)
-    _CIPHER(TLS_RSA_WITH_AES_128_CBC_SHA256),               // TLSv1.2
-    _CIPHER(TLS_RSA_WITH_AES_256_CBC_SHA256),               // TLSv1.2
-    _CIPHER(TLS_RSA_WITH_AES_128_GCM_SHA256),               // TLSv1.2
-    _CIPHER(TLS_RSA_WITH_AES_256_GCM_SHA384),               // TLSv1.2
-    // TLS_RSA_WITH_RC4_128_MD5 is weak do not use it
-    // TLS_RSA_WITH_RC4_128_SHA is weak do not use it
-    _CIPHER(TLS_RSA_WITH_CAMELLIA_128_CBC_SHA),             // TLSv1.0 + RFC4132 (Camellia ciphersuites)
-    _CIPHER(TLS_RSA_WITH_CAMELLIA_256_CBC_SHA),             // TLSv1.0 + RFC4132 (Camellia ciphersuites)
-    _CIPHER(TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256),          // TLSv1.2 + RFC5932 (Camellia ciphersuites)
-    _CIPHER(TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256),          // TLSv1.2 + RFC5932 (Camellia ciphersuites)
-    _CIPHER(TLS_RSA_WITH_3DES_EDE_CBC_SHA),                 // TLSv1.0
-#endif
-#ifdef POLARSSL_KEY_EXCHANGE_DHE_RSA_ENABLED
-    // TLS_DHE_RSA_WITH_AES_128_CBC_SHA is weak do not use it
-    // TLS_DHE_RSA_WITH_AES_256_CBC_SHA is weak do not use it
-    // TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 is weak do not use it
-    // TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 is weak do not use it
-    // TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA is weak do not use it
-    // TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA is weak do not use it
-    // TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 is weak do not use it
-    // TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 is weak do not use it
-    // TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA is weak do not use it
-#endif
-#ifdef POLARSSL_KEY_EXCHANGE_ECDHE_RSA_ENABLED
-    _CIPHER(TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA),            // TLSv1.0 + RFC4492 (Elliptic Curve ciphersuites)
-    _CIPHER(TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA),            // TLSv1.0 + RFC4492 (Elliptic Curve ciphersuites)
-    // TLS_ECDHE_RSA_WITH_RC4_128_SHA is weak do not use it
-    _CIPHER(TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA),           // TLSv1.0 + RFC4492 (Elliptic Curve ciphersuites)
-    _CIPHER(TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256),         // TLSv1.2
-    _CIPHER(TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384),         // TLSv1.2
-    _CIPHER(TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256),         // TLSv1.2
-    _CIPHER(TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384),         // TLSv1.2
-    _CIPHER(TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256),    // TLSv1.2 + RFC6367 (Camellia HMAC ciphersuites)
-    _CIPHER(TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384),    // TLSv1.2 + RFC6367 (Camellia HMAC ciphersuites)
-#endif
-#ifdef POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
-    // TLS_ECDHE_ECDSA_WITH_RC4_128_SHA is weak do not use it
-    _CIPHER(TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA),         // TLSv1.0 + RFC4492 (Elliptic Curve ciphersuites)
-    _CIPHER(TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA),          // TLSv1.2
-    _CIPHER(TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA),          // TLSv1.2
-    _CIPHER(TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256),       // TLSv1.2
-    _CIPHER(TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384),       // TLSv1.2
-    _CIPHER(TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256),       // TLSv1.2
-    _CIPHER(TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384),       // TLSv1.2
-    _CIPHER(TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256),  // TLSv1.2 + RFC6367 (Camellia HMAC ciphersuites)
-    _CIPHER(TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384),  // TLSv1.2 + RFC6367 (Camellia HMAC ciphersuites)
-#endif
-#ifdef POLARSSL_AES_C
-    _CIPHER(TLS_RSA_WITH_AES_128_CBC_SHA),                  // TLSv1.0 + RFC3268 (AES ciphersuites)
-    _CIPHER(TLS_RSA_WITH_AES_256_CBC_SHA),                  // TLSv1.0 + RFC3268 (AES ciphersuites)
-    // TLS_DHE_RSA_WITH_AES_128_CBC_SHA is weak do not use it
-    // TLS_DHE_RSA_WITH_AES_256_CBC_SHA is weak do not use it
-    _CIPHER(TLS_RSA_WITH_AES_128_CBC_SHA256),               // TLSv1.2
-    _CIPHER(TLS_RSA_WITH_AES_256_CBC_SHA256),               // TLSv1.2
-    // TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 is weak do not use it
-    // TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 is weak do not use it
-    _CIPHER(TLS_RSA_WITH_AES_128_GCM_SHA256),               // TLSv1.2
-    _CIPHER(TLS_RSA_WITH_AES_256_GCM_SHA384),               // TLSv1.2
-    _CIPHER(TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA),            // TLSv1.2
-    _CIPHER(TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA),            // TLSv1.2
-    _CIPHER(TLS_PSK_WITH_AES_128_CBC_SHA),                  // TLSv1.0 + RFC4279 (PSK ciphersuites)
-    _CIPHER(TLS_PSK_WITH_AES_256_CBC_SHA),                  // TLSv1.0 + RFC4279 (PSK ciphersuites)
-#endif
-#ifdef POLARSSL_ARC4_C
-    // TLS_RSA_WITH_RC4_128_MD5 is weak do not use it
-    // TLS_RSA_WITH_RC4_128_SHA is weak do not use it
-    // TLS_ECDHE_RSA_WITH_RC4_128_SHA is weak do not use it
-    // TLS_PSK_WITH_RC4_128_SHA is weak do not use it
-#endif
-#ifdef POLARSSL_CAMELLIA_C
-    _CIPHER(TLS_RSA_WITH_CAMELLIA_128_CBC_SHA),             // TLSv1.0 + RFC4132 (Camellia ciphersuites)
-    _CIPHER(TLS_RSA_WITH_CAMELLIA_256_CBC_SHA),             // TLSv1.0 + RFC4132 (Camellia ciphersuites)
-    // TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA is weak do not use it
-    // TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA is weak do not use it
-    _CIPHER(TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256),          // TLSv1.2 + RFC5932 (Camellia ciphersuites)
-    _CIPHER(TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256),          // TLSv1.2 + RFC5932 (Camellia ciphersuites)
-    // TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA is weak do not use it
-    // TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 is weak do not use it
-#endif
-#ifdef POLARSSL_DES_C
-    _CIPHER(TLS_RSA_WITH_3DES_EDE_CBC_SHA),                 // TLSv1.0
-    // TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA is weak do not use it
-    _CIPHER(TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA),           // SSLv3
-    _CIPHER(TLS_PSK_WITH_3DES_EDE_CBC_SHA),                 // TLSv1.0 + RFC4279 (PSK ciphersuites)
-#endif
-#ifdef POLARSSL_DHM_C
-    // TLS_DHE_RSA_WITH_DES_CBC_SHA is weak do not use it
-    // TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA is weak do not use it
-    // TLS_DHE_RSA_WITH_AES_128_CBC_SHA is weak do not use it
-    // TLS_DHE_RSA_WITH_AES_256_CBC_SHA is weak do not use it
-    // TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 is weak do not use it
-    // TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 is weak do not use it
-    // TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA is weak do not use it
-    // TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA is weak do not use it
-    // TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA is weak do not use it
-    // TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 is weak do not use it
-    // TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 is weak do not use it
-    // TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 is weak do not use it
-#endif
-#ifdef POLARSSL_ECDH_C
-    // TLS_ECDHE_RSA_WITH_NULL_SHA is weak do not use it
-    _CIPHER(TLS_ECDHE_RSA_WITH_RC4_128_SHA),                // TLSv1.0 + RFC4492 (Elliptic Curve ciphersuites)
-    _CIPHER(TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA),           // TLSv1.0 + RFC4492 (Elliptic Curve ciphersuites)
-    _CIPHER(TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA),            // TLSv1.0 + RFC4492 (Elliptic Curve ciphersuites)
-    _CIPHER(TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA),            // TLSv1.0 + RFC4492 (Elliptic Curve ciphersuites)
-#endif
-#ifdef POLARSSL_GCM_C
-    _CIPHER(TLS_RSA_WITH_AES_128_GCM_SHA256),               // TLSv1.2 + RFC5288 (AES GCM)
-    _CIPHER(TLS_RSA_WITH_AES_256_GCM_SHA384),               // TLSv1.2 + RFC5288 (AES GCM)
-#endif
-
-    // Legacy alias, less weaks
-    { "SSL_RSA_DES_168_SHA",          MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA },
-    { "SSL_RSA_AES_128_SHA",          MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA },
-    { "SSL_RSA_AES_256_SHA",          MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA },
-    { "SSL_RSA_CAMELLIA_128_SHA",     MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA },
-    { "SSL_RSA_CAMELLIA_256_SHA",     MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA },
+// List of old names for ciphers
+static CipherName legacy_cipher_table[] =
+{
+    { "SSL-RSA-DES-168-SHA",          MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA },
+    { "SSL-RSA-AES-128-SHA",          MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA },
+    { "SSL-RSA-AES-256-SHA",          MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA },
+    { "SSL-RSA-CAMELLIA-128-SHA",     MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA },
+    { "SSL-RSA-CAMELLIA-256-SHA",     MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA },

     // End of the cipher list
     { NULL, -1 }
 };
-#undef _CIPHER

 void host_destroy_cb(Route *r, RouteMap *map)
 {
@@ -221,41 +85,53 @@

 static int Server_load_ciphers(Server *srv, bstring ssl_ciphers_val)
 {
+    const struct tagbstring bstr_underscore = bsStatic("_");
+    const struct tagbstring bstr_dash = bsStatic("-");
+
     struct bstrList *ssl_cipher_list = bsplit(ssl_ciphers_val, ' ');
     int i = 0, n = 0;
-    int max_num_ciphers = 0;
     int *ciphers = NULL;
-    const int *default_ciphersuites;

     check(ssl_cipher_list != NULL && ssl_cipher_list->qty > 0,
             "Invalid cipher list, it must be separated by space ' ' characters "
             "and you need at least one.  Or, just leave it out for defaults.");

-    default_ciphersuites = mbedtls_ssl_list_ciphersuites();
-    while(default_ciphersuites[max_num_ciphers] != 0) {
-        max_num_ciphers++;
-    }
-
-    ciphers = h_calloc(max_num_ciphers + 1, sizeof(int));
+    ciphers = h_calloc(ssl_cipher_list->qty + 1, sizeof(int));
     check_mem(ciphers);

     for(i = 0; i < ssl_cipher_list->qty; i++) {
         bstring cipher = ssl_cipher_list->entry[i];

         int id = -1;
-        for(n = 0; cipher_table[n].name != NULL; ++n)
+
+        // Replace underscores (used in old ciphers) with dashes
+        bfindreplace(cipher, &bstr_underscore, &bstr_dash, 0);
+
+        // Search legacy cipher list
+        for(n = 0; legacy_cipher_table[n].name != NULL; ++n)
         {
-            if(biseqcstr(cipher, cipher_table[n].name))
+            if(biseqcstr(cipher, legacy_cipher_table[n].name))
             {
-                id = cipher_table[n].id;
+                id = legacy_cipher_table[n].id;
                 break;
             }
         }

-        if(id != -1)
+        if(id != -1 && mbedtls_ssl_ciphersuite_from_id(id) != NULL)
+        {
             ciphers[i] = id;
+        }
         else
-            sentinel("Unrecognized cipher: %s", bdata(cipher));
+        {
+            // Search polarssl cipher list
+            const mbedtls_ssl_ciphersuite_t * suite =
+                mbedtls_ssl_ciphersuite_from_string(bdata(cipher));
+
+            if (suite != NULL)
+                ciphers[i] = suite->id;
+            else
+                sentinel("Unrecognized cipher: %s", bdata(cipher));
+        }
     }

     bstrListDestroy(ssl_cipher_list);


shutdownHugsServer: as part of shutdown sequence, call everybody(EXIT)

--- src/server.c
+++ src/server.c
@@ -10,8 +10,8 @@
  * the license in the file "License", which is included in the distribution.
  *
  * $RCSfile: server.c,v $
- * $Revision: 1.16 $
- * $Date: 2002/05/15 22:24:21 $
+ * $Revision: 1.17 $
+ * $Date: 2002/07/05 12:55:48 $
  * ------------------------------------------------------------------------*/

 #define HUGS_SERVER
@@ -248,6 +248,7 @@
   /* The 'hserv' argument isn't actually used */
   clearStack();
   stopAnyPrinting();
+  everybody(EXIT);
   shutdownHugs();
   return;
 }


Shouldn't close the message.

Shouldn't close the message.

--- src/server.c
+++ src/server.c
@@ -148,8 +148,6 @@
         if(end && hash_lookup(registrations, (void *)fd)) {
             listener_deliver(fd, data+end, sz-end);
         }
-
-        zmq_msg_close(&inmsg);
     }
 }


It doesnot work cause the param of size (arr) is a pointer

error: pathspec 'src/sizeof.c' did not match any file(s) known to git

--- src/sizeof.c
+++ src/sizeof.c
@@ -0,0 +1,15 @@
+#define SIZE 10
+void size(int arr[SIZE])
+{
+    printf("size of array is:%d\n",sizeof(arr));
+}
+
+int main()
+{
+    int arr[SIZE];
+
+    //its doesnt work cause the param in size is a pointer
+    size(arr);
+    printf("%d\n", sizeof(arr) );
+    return 0;
+}


Remove unnecessary read.

Remove unnecessary read.

--- src/socket.c
+++ src/socket.c
@@ -112,7 +112,6 @@
  * @return TRUE (the length of data read) or -1 if an error occured
  */
 static int fill(Socket_T S, int timeout) {
-        int n;
         S->offset = 0;
         S->length = 0;
         /* Optimizing, assuming a request/response pattern and that a udp_write
@@ -120,13 +119,11 @@
         if (S->type == SOCK_DGRAM)
                 timeout = 0;
         if (S->ssl) {
-                n = recv_ssl_socket(S->ssl, S->buffer, RBUFFER_SIZE, timeout);
+                S->length = recv_ssl_socket(S->ssl, S->buffer, RBUFFER_SIZE, timeout);
         } else {
-                n = (int)sock_read(S->socket, S->buffer,  RBUFFER_SIZE, timeout);
-        }
-        if (n > 0) {
-                S->length += n;
-        }  else if (n < 0) {
+                S->length = (int)sock_read(S->socket, S->buffer,  RBUFFER_SIZE, timeout);
+        }
+        if (S->length == 0) {
                 if (errno == EAGAIN || errno == EWOULDBLOCK || S->type == SOCK_DGRAM)
                         return -1;
         }


Add MAC address NULL check

Add MAC address NULL check

--- src/socket.c
+++ src/socket.c
@@ -26,6 +26,9 @@

 struct orvibo_socket *
 orvibo_socket_create(const char *const mac) {
+    if (mac == NULL) {
+        return NULL;
+    }
 	char *const mac_string = strdup(mac);
 	if (mac_string == NULL) {
 		return NULL;


Updated revision for release

Updated revision for release

--- src/status.c
+++ src/status.c
@@ -47,7 +47,7 @@
 /// The node type - value of '0' identifies node as a FMU node.
 static const uint8_t  status_node_type  = 0;

-static const uint8_t  status_fw_rev_ver = 1;    ///< Firmware revision version number.
+static const uint8_t  status_fw_rev_ver = 2;    ///< Firmware revision version number.
 static const uint8_t  status_fw_min_ver = 2;    ///< Firmware minor version number.
 static const uint8_t  status_fw_maj_ver = 1;    ///< Firmware major version number.


unicode improvements - repeat

unicode improvements - repeat

* string_repeat should now handle all charsets and encodings

Tests welcome

git-svn-id: 6e74a02f85675cec270f5d931b0f6998666294a3@9879 d31e2699-5ff4-0310-a27c-f18f2fbe73fe

--- src/string.c
+++ src/string.c
@@ -1028,10 +1028,10 @@
     STRING *dest;
     UINTVAL i;

-    dest = string_make_empty(interpreter, enum_stringrep_one, s->strlen * num);
-
-    /* dest = string_make(interpreter, NULL, s->bufused * num, s->encoding, 0,
-                       s->type); */
+    dest = string_make_direct(interpreter, NULL,
+                        s->bufused * num,
+                        s->encoding, s->charset, 0);
+
     if (num == 0) {
         return dest;
     }


header with constants

header with constants

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


Log packets that look like attempts to take items from the bank that come outside of quests when the shopping flag isn't set.

--- src/subcmd.c
+++ src/subcmd.c
@@ -1099,6 +1099,14 @@
     if(l->num_clients != 1 && pkt->client_id != c->client_id)
         return -1;

+    /* Outside of quests, we shouldn't be able to get these unless the shopping
+       flag is set... Log any we get. */
+    if(!(l->flags & LOBBY_FLAG_QUESTING) &&
+       !(c->flags & CLIENT_FLAG_SHOPPING)) {
+        debug(DBG_WARN, "Guildcard %" PRIu32 " attempting to take item from "
+              "bank when bank not opened!\n", c->guildcard);
+    }
+
     /* Run the bank action script, if any. */
     if(script_execute(ScriptActionBankAction, c, SCRIPT_ARG_PTR, c,
                       SCRIPT_ARG_INT, 1, SCRIPT_ARG_UINT32, pkt->data_l[0],


build: allow to build with SDL2 versions 2.0.3 and below

SDL_HINT_NO_SIGNAL_HANDLERS is available since SDL 2.0.4.

--- src/sundog.c
+++ src/sundog.c
@@ -641,7 +641,9 @@
         exit(1);
     }

+#ifdef SDL_HINT_NO_SIGNAL_HANDLERS
     SDL_SetHint(SDL_HINT_NO_SIGNAL_HANDLERS, "1"); /* Allow ctrl-c to quit */
+#endif
     SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");
     if (SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_EVENTS | SDL_INIT_TIMER) != 0) {
         psys_panic("Unable to initialize SDL: %s\n", SDL_GetError());


(msymbol__list): New function.

(msymbol__list): New function.

--- src/symbol.c
+++ src/symbol.c
@@ -186,6 +186,24 @@
   memcpy (p, name, len);
   p[len] = '\0';
   return msymbol (p);
+}
+
+/** Return a plist of symbols that has non-NULL property PROP.  If
+    PROP is Mnil, return a plist of all symbols.  Values of the plist
+    is NULL.  */
+
+MPlist *
+msymbol__list (MSymbol prop)
+{
+  MPlist *plist = mplist ();
+  int i;
+  MSymbol sym;
+
+  for (i = 0; i < SYMBOL_TABLE_SIZE; i++)
+    for (sym = symbol_table[i]; sym; sym = sym->next)
+      if (prop == Mnil || msymbol_get (sym, prop))
+	mplist_push (plist, sym, NULL);
+  return plist;
 }

@@ -706,7 +724,7 @@
 mdebug_dump_all_symbols (int indent)
 {
   char *prefix;
-  int i;
+  int i, n;
   MSymbol sym;

   if (indent < 0)
@@ -716,14 +734,15 @@
   prefix[indent] = 0;

   fprintf (stderr, "(symbol-list");
-  for (i = 0; i < SYMBOL_TABLE_SIZE; i++)
+  for (i = n = 0; i < SYMBOL_TABLE_SIZE; i++)
     if ((sym = symbol_table[i]))
       {
 	fprintf (stderr, "\n%s  (%4d", prefix, i);
-	for (; sym; sym = sym->next)
+	for (; sym; sym = sym->next, n++)
 	  fprintf (stderr, " '%s'", sym->name);
 	fprintf (stderr, ")");
       }
+  fprintf (stderr, "\n%s  (total %d)", prefix, n);
   fprintf (stderr, ")");
   return Mnil;
 }


Look up and remove elements by range

Look up and remove elements by range

--- src/t_zset.c
+++ src/t_zset.c
@@ -452,6 +452,87 @@
 unsigned int zzlLength(robj *zobj) {
     unsigned char *zl = zobj->ptr;
     return ziplistLen(zl)/2;
+}
+
+/* Returns if there is a part of the zset is in range. Should only be used
+ * internally by zzlFirstInRange and zzlLastInRange. */
+int zzlIsInRange(unsigned char *zl, zrangespec *range) {
+    unsigned char *p;
+    double score;
+
+    /* Test for ranges that will always be empty. */
+    if (range->min > range->max ||
+            (range->min == range->max && (range->minex || range->maxex)))
+        return 0;
+
+    p = ziplistIndex(zl,-1); /* Last score. */
+    redisAssert(p != NULL);
+    score = zzlGetScore(p);
+    if (!zslValueGteMin(score,range))
+        return 0;
+
+    p = ziplistIndex(zl,1); /* First score. */
+    redisAssert(p != NULL);
+    score = zzlGetScore(p);
+    if (!zslValueLteMax(score,range))
+        return 0;
+
+    return 1;
+}
+
+/* Find pointer to the first element contained in the specified range.
+ * Returns NULL when no element is contained in the range. */
+unsigned char *zzlFirstInRange(robj *zobj, zrangespec range) {
+    unsigned char *zl = zobj->ptr;
+    unsigned char *eptr = ziplistIndex(zl,0), *sptr;
+    double score;
+
+    /* If everything is out of range, return early. */
+    if (!zzlIsInRange(zl,&range)) return NULL;
+
+    while (eptr != NULL) {
+        sptr = ziplistNext(zl,eptr);
+        redisAssert(sptr != NULL);
+
+        score = zzlGetScore(sptr);
+        if (zslValueGteMin(score,&range))
+            return eptr;
+
+        /* Move to next element. */
+        eptr = ziplistNext(zl,sptr);
+    }
+
+    return NULL;
+}
+
+/* Find pointer to the last element contained in the specified range.
+ * Returns NULL when no element is contained in the range. */
+unsigned char *zzlLastInRange(robj *zobj, zrangespec range) {
+    unsigned char *zl = zobj->ptr;
+    unsigned char *eptr = ziplistIndex(zl,-2), *sptr;
+    double score;
+
+    /* If everything is out of range, return early. */
+    if (!zzlIsInRange(zl,&range)) return NULL;
+
+    while (eptr != NULL) {
+        sptr = ziplistNext(zl,eptr);
+        redisAssert(sptr != NULL);
+
+        score = zzlGetScore(sptr);
+        if (zslValueLteMax(score,&range))
+            return eptr;
+
+        /* Move to previous element by moving to the score of previous element.
+         * When this returns NULL, we know there also is no element. */
+        sptr = ziplistPrev(zl,eptr);
+        if (sptr != NULL)
+            redisAssert((eptr = ziplistPrev(zl,sptr)) != NULL);
+        else
+            eptr = NULL;
+    }
+
+    return NULL;
 }

 unsigned char *zzlFind(robj *zobj, robj *ele, double *score) {
@@ -557,6 +638,34 @@
     return REDIS_OK;
 }

+unsigned long zzlDeleteRangeByScore(robj *zobj, zrangespec range) {
+    unsigned char *zl = zobj->ptr;
+    unsigned char *eptr, *sptr;
+    double score;
+    unsigned long deleted = 0;
+
+    eptr = zzlFirstInRange(zobj,range);
+    if (eptr == NULL) return deleted;
+
+
+    /* When the tail of the ziplist is deleted, eptr will point to the sentinel
+     * byte and ziplistNext will return NULL. */
+    while ((sptr = ziplistNext(zl,eptr)) != NULL) {
+        score = zzlGetScore(sptr);
+        if (zslValueLteMax(score,&range)) {
+            /* Delete both the element and the score. */
+            zl = ziplistDelete(zl,&eptr);
+            zl = ziplistDelete(zl,&eptr);
+            deleted++;
+        } else {
+            /* No longer in range. */
+            break;
+        }
+    }
+
+    return deleted;
+}
+
 /*-----------------------------------------------------------------------------
  * Sorted set commands
  *----------------------------------------------------------------------------*/
@@ -736,10 +845,10 @@
 }

 void zremrangebyscoreCommand(redisClient *c) {
+    robj *key = c->argv[1];
+    robj *zobj;
     zrangespec range;
-    long deleted;
-    robj *o;
-    zset *zs;
+    unsigned long deleted;

     /* Parse the range arguments. */
     if (zslParseRange(c->argv[2],c->argv[3],&range) != REDIS_OK) {
@@ -747,14 +856,21 @@
         return;
     }

-    if ((o = lookupKeyWriteOrReply(c,c->argv[1],shared.czero)) == NULL ||
-        checkType(c,o,REDIS_ZSET)) return;
-
-    zs = o->ptr;
-    deleted = zslDeleteRangeByScore(zs->zsl,range,zs->dict);
-    if (htNeedsResize(zs->dict)) dictResize(zs->dict);
-    if (dictSize(zs->dict) == 0) dbDelete(c->db,c->argv[1]);
-    if (deleted) signalModifiedKey(c->db,c->argv[1]);
+    if ((zobj = lookupKeyWriteOrReply(c,key,shared.czero)) == NULL ||
+        checkType(c,zobj,REDIS_ZSET)) return;
+
+    if (zobj->encoding == REDIS_ENCODING_ZIPLIST) {
+        deleted = zzlDeleteRangeByScore(zobj,range);
+    } else if (zobj->encoding == REDIS_ENCODING_RAW) {
+        zset *zs = zobj->ptr;
+        deleted = zslDeleteRangeByScore(zs->zsl,range,zs->dict);
+        if (htNeedsResize(zs->dict)) dictResize(zs->dict);
+        if (dictSize(zs->dict) == 0) dbDelete(c->db,key);
+    } else {
+        redisPanic("Unknown sorted set encoding");
+    }
+
+    if (deleted) signalModifiedKey(c->db,key);
     server.dirty += deleted;
     addReplyLongLong(c,deleted);
 }


修正 zslCreate 函数的复杂度

修正 zslCreate 函数的复杂度

--- src/t_zset.c
+++ src/t_zset.c
@@ -86,7 +86,7 @@
 /*
  * 创建一个跳跃表
  *
- * T = O(N)
+ * T = O(1)
  */
 zskiplist *zslCreate(void) {
     int j;
@@ -99,7 +99,7 @@

     // 初始化头节点， O(1)
     zsl->header = zslCreateNode(ZSKIPLIST_MAXLEVEL,0,NULL);
-    // 初始化层指针，O(N)
+    // 初始化层指针，O(1)
     for (j = 0; j < ZSKIPLIST_MAXLEVEL; j++) {
         zsl->header->level[j].forward = NULL;
         zsl->header->level[j].span = 0;


Compiler should decide on inlining

Compiler should decide on inlining

--- src/t_zset.c
+++ src/t_zset.c
@@ -180,15 +180,15 @@
     int minex, maxex; /* are min or max exclusive? */
 } zrangespec;

-static inline int zslValueInMinRange(double value, zrangespec *spec) {
+static int zslValueInMinRange(double value, zrangespec *spec) {
     return spec->minex ? (value > spec->min) : (value >= spec->min);
 }

-static inline int zslValueInMaxRange(double value, zrangespec *spec) {
+static int zslValueInMaxRange(double value, zrangespec *spec) {
     return spec->maxex ? (value < spec->max) : (value <= spec->max);
 }

-static inline int zslValueInRange(double value, zrangespec *spec) {
+static int zslValueInRange(double value, zrangespec *spec) {
     return zslValueInMinRange(value,spec) && zslValueInMaxRange(value,spec);
 }


Refactor tcaches flush/destroy to reduce lock duration.

Drop tcaches_mtx before calling tcache_destroy().

--- src/tcache.c
+++ src/tcache.c
@@ -500,32 +500,39 @@
 	return err;
 }

-static void
-tcaches_elm_flush(tsd_t *tsd, tcaches_t *elm) {
+static tcache_t *
+tcaches_elm_remove(tsd_t *tsd, tcaches_t *elm) {
 	malloc_mutex_assert_owner(tsd_tsdn(tsd), &tcaches_mtx);

 	if (elm->tcache == NULL) {
-		return;
-	}
-	tcache_destroy(tsd, elm->tcache);
+		return NULL;
+	}
+	tcache_t *tcache = elm->tcache;
 	elm->tcache = NULL;
+	return tcache;
 }

 void
 tcaches_flush(tsd_t *tsd, unsigned ind) {
 	malloc_mutex_lock(tsd_tsdn(tsd), &tcaches_mtx);
-	tcaches_elm_flush(tsd, &tcaches[ind]);
+	tcache_t *tcache = tcaches_elm_remove(tsd, &tcaches[ind]);
 	malloc_mutex_unlock(tsd_tsdn(tsd), &tcaches_mtx);
+	if (tcache != NULL) {
+		tcache_destroy(tsd, tcache);
+	}
 }

 void
 tcaches_destroy(tsd_t *tsd, unsigned ind) {
 	malloc_mutex_lock(tsd_tsdn(tsd), &tcaches_mtx);
 	tcaches_t *elm = &tcaches[ind];
-	tcaches_elm_flush(tsd, elm);
+	tcache_t *tcache = tcaches_elm_remove(tsd, elm);
 	elm->next = tcaches_avail;
 	tcaches_avail = elm;
 	malloc_mutex_unlock(tsd_tsdn(tsd), &tcaches_mtx);
+	if (tcache != NULL) {
+		tcache_destroy(tsd, tcache);
+	}
 }

 bool


Remove redundant extent lookup in tcache_bin_flush_large.

--- src/tcache.c
+++ src/tcache.c
@@ -215,7 +215,7 @@
 		for (unsigned i = 0; i < nflush; i++) {
 			void *ptr = *(tbin->avail - 1 - i);
 			assert(ptr != NULL);
-			extent = iealloc(tsd_tsdn(tsd), ptr);
+			extent = item_extent[i];
 			if (extent_arena_get(extent) == locked_arena) {
 				large_dalloc_prep_junked_locked(tsd_tsdn(tsd),
 				    extent);


check for empty queue before waking sleeping threads

--- src/thread.c
+++ src/thread.c
@@ -463,6 +463,12 @@
     }

     elm = dequeue_first_atomic(q);
+
+    /* no one is sleeping on this queue */
+    if (!elm) {
+        return 0;
+    }
+
     t = container_of(elm, thread_t, wait_node);

     enqueue_thread_on_runq(t, t->bound_cpu);
@@ -582,6 +588,7 @@
         *tid = t->tid;
     }

+    DEBUG_PRINT("Thread create creating new thread with t=%p, tid=%u\n", t, t->tid);
     return t;

 out_err1:
@@ -788,6 +795,7 @@
     thread_setup_init_stack(t, fun, input);

     enqueue_thread_on_runq(t, cpu);
+    DEBUG_PRINT("started thread (%p, tid=%u) on cpu %u\n", t, t->tid, cpu);
     return t;
 }


[fix] tokenized_string_t should copy its source string

--- src/tokens.c
+++ src/tokens.c
@@ -6,7 +6,6 @@
     self->str = NULL;
     self->strings = cstring_array_new();
     self->tokens = token_array_new();
-
     return self;
 }

@@ -21,7 +20,7 @@

 inline tokenized_string_t *tokenized_string_new_from_str_size(char *src, size_t len, size_t num_tokens) {
     tokenized_string_t *self = tokenized_string_new_size(len, num_tokens);
-    self->str = src;
+    self->str = strndup(src);
     return self;
 }

@@ -38,7 +37,7 @@

 tokenized_string_t *tokenized_string_from_tokens(char *src, token_array *tokens, bool copy_tokens) {
     tokenized_string_t *self = malloc(sizeof(tokenized_string_t));
-    self->str = src;
+    self->str = stdup(src);
     self->strings = cstring_array_new_size(strlen(src) + tokens->n);
     if (copy_tokens) {
         self->tokens = token_array_new_copy(tokens, tokens->n);
@@ -48,7 +47,7 @@

     token_t token;

-    for (int i = 0; i < tokens->n; i++) {
+    for (size_t i = 0; i < tokens->n; i++) {
         token = tokens->a[i];
         cstring_array_add_string_len(self->strings, src + token.offset, token.len);
     }


More token types we need

More token types we need

--- src/tokens.h
+++ src/tokens.h
@@ -15,12 +15,15 @@
     T_CLASS,
     T_CONTINUE,
     T_ELSE,
+    T_EOF,
     T_FALSE,
     T_FOR,
     T_IDENTIFIER,
     T_IF,
+    T_ILLEGAL,
     T_INT,
     T_INT_LITERAL,
+    T_OPERATOR,
     T_RETURN,
     T_STRING_LITERAL,
     T_TRUE,


fix the "bk setup" hang problem reported by mharris@mvista.com

bk: 38c40b5aq7IYia5-4xIUerS59duT3g

--- src/unique.c
+++ src/unique.c
@@ -121,9 +121,15 @@
 			close(fd);
 			if (n > 0) {
 				buf[n] = 0;
-				pid = atoi(buf);
-			}
-			unless (pid) continue;
+				if (sscanf(buf, "%d", &pid) != 1) {
+stale:					fprintf(stderr,
+					   "removing stale lock %s\n", path);
+					unlink(path);
+					continue;
+				}
+				assert(pid > 0);
+			}
+			unless (pid) goto stale;
 			if (kill(pid, 0) == 0) {
 				slept++;
 				sleep(slept);


addon for cmake_windows build (discussed with manuel and frieder) #ifdef UTCORE_DLL causes UBITRACK_DLL to be defined

--- src/utCore.h
+++ src/utCore.h
@@ -32,6 +32,10 @@
 #define __UBITRACK_H_INCLUDED__

 #ifdef _WIN32
+// fix for simplified build scripts (ulrich eck)
+#   ifdef UTCORE_DLL
+#       define UBITRACK_DLL
+#   endif
 #	ifdef UBITRACK_DLL
 #		define UBITRACK_EXPORT __declspec( dllexport )
 #	else


Remove accidental semicolon

Remove accidental semicolon

--- src/uthash.h
+++ src/uthash.h
@@ -1,4 +1,4 @@
-;/*
+/*
 Copyright (c) 2003-2014, Troy D. Hanson     http://troydhanson.github.com/uthash/
 All rights reserved.


Fix TRex-443. Problem with client_cfg error message when there are unresolved addresses

Signed-off-by: Ido Barnea <3a6e28cf60eb2f9d9d6e5ab6275926d9a599fe66@cisco.com>

--- src/utl_ip.h
+++ src/utl_ip.h
@@ -5,7 +5,7 @@
 */

 /*
-Copyright (c) 2016-2016 Cisco Systems, Inc.
+Copyright (c) 2016-2017 Cisco Systems, Inc.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
@@ -88,8 +88,11 @@
     }
     uint16_t get_vlan() const {return m_vlan;}
     void set_vlan(uint16_t vlan) {m_vlan = vlan;}
-    uint16_t get_ip() const {return m_ip;}
+    uint32_t get_ip() const {return m_ip;}
     void set_ip(uint32_t ip) {m_ip = ip;}
+    void dump(FILE *fd) const {
+        fprintf(fd, "ip:%s, vlan:%d\n", ip_to_str(m_ip).c_str(), m_vlan);
+    }

  private:
     uint32_t m_ip;
@@ -177,6 +180,9 @@
     if (lhs.m_ip != rhs.m_ip)
         return false;

+    if (lhs.m_port != rhs.m_port)
+        return false;
+
     return true;
 }

@@ -237,7 +243,7 @@
     bool lookup(uint32_t ip, uint16_t vlan, MacAddress &ret_mac) const;
     bool exists(uint32_t ip, uint16_t vlan = 0) const;
     void clear();
-
+
     void dump(FILE *fd);
     uint32_t size() { return m_ipv4_resolve.size() + m_ipv6_resolve.size();}
     const COneIPInfo *get_first() const;
@@ -246,21 +252,21 @@
         const COneIPInfo *ip_info = get_next();
         return (ip_info ? ip_info : get_next());
     }
-
+
     CManyIPInfo& operator = (const CManyIPInfo &rhs) {
         m_ipv4_resolve = rhs.m_ipv4_resolve;
         m_ipv6_resolve = rhs.m_ipv6_resolve;
-
+
         m_iter_initiated = false;
         return (*this);
     }
-
+
  private:
     ip_vlan_to_many_ip_t      m_ipv4_resolve;
     ipv6_vlan_to_many_ipv6_t  m_ipv6_resolve;
-
+
     ip_vlan_to_many_ip_iter_t m_ipv4_iter;
-
+
     bool m_iter_initiated;

 };


core: Handle multiple TOFU_USER lines in verify

* src/verify.c (op_data_t): Add conflict_user_seen.
(parse_tofu_user): Return ERR_DUP_VALUE for mutltiple TOFU_USERS.
(_gpgme_verify_status_handler): Handle ERR_DUP_VALUE from
parse_tofu_user to ignore the next TOFU_STATS.

--
This fixes TOFU Conflict verification with GnuPG-2.1.17 and 2.1.18

GnuPG-Bug-Id: 2914

--- src/verify.c
+++ src/verify.c
@@ -47,6 +47,7 @@
   int did_prepare_new_sig;
   int only_newsig_seen;
   int plaintext_seen;
+  int conflict_user_seen;
 } *op_data_t;

@@ -682,6 +683,14 @@
       goto leave;
     }

+  if (sig->key && sig->key->fpr && strcmp (sig->key->fpr, fpr))
+    {
+      /* GnuPG since 2.1.17 emits multiple TOFU_USER lines with
+         different fingerprints in case of conflicts for a signature. */
+      err = GPG_ERR_DUP_VALUE;
+      goto leave;
+    }
+
   args = tail;
   tail = strchr (args, ' ');
   if (tail == args)
@@ -708,12 +717,6 @@
   else if (!sig->key->fpr)
     {
       err = trace_gpg_error (GPG_ERR_INTERNAL);
-      goto leave;
-    }
-  else if (strcmp (sig->key->fpr, fpr))
-    {
-      /* The engine did not emit NEWSIG before a new key.  */
-      err = trace_gpg_error (GPG_ERR_INV_ENGINE);
       goto leave;
     }

@@ -932,6 +935,7 @@
         calc_sig_summary (sig);
       err = prepare_new_sig (opd);
       opd->only_newsig_seen = 1;
+      opd->conflict_user_seen = 0;
       return err;

     case GPGME_STATUS_GOODSIG:
@@ -997,16 +1001,35 @@

     case GPGME_STATUS_TOFU_USER:
       opd->only_newsig_seen = 0;
-      return sig ? parse_tofu_user (sig, args, ctx->protocol)
-        /*    */ : trace_gpg_error (GPG_ERR_INV_ENGINE);
+      if (!sig)
+        return trace_gpg_error (GPG_ERR_INV_ENGINE);
+      err = parse_tofu_user (sig, args, ctx->protocol);
+      /* gpg emits TOFU User lines for each conflicting key.
+         GPGME does not expose this to have a clean API and
+         a GPGME user can do a keylisting with the address
+         normalisation.
+         So when a duplicated TOFU_USER line is encountered
+         we ignore the conflicting tofu stats emited afterwards.
+      */
+      if (err == GPG_ERR_DUP_VALUE)
+        {
+          opd->conflict_user_seen = 1;
+          break;
+        }
+      opd->conflict_user_seen = 0;
+      return trace_gpg_error (err);

     case GPGME_STATUS_TOFU_STATS:
       opd->only_newsig_seen = 0;
+      if (opd->conflict_user_seen)
+        break;
       return sig ? parse_tofu_stats (sig, args)
         /*    */ : trace_gpg_error (GPG_ERR_INV_ENGINE);

     case GPGME_STATUS_TOFU_STATS_LONG:
       opd->only_newsig_seen = 0;
+      if (opd->conflict_user_seen)
+        break;
       return sig ? parse_tofu_stats_long (sig, args, ctx->raw_description)
         /*    */ : trace_gpg_error (GPG_ERR_INV_ENGINE);


Added support for the VIA Openbook laptop (thanks to chfoo)

git-svn-id: 1e41a1b69b713dc96107d2dd734891188b9b2ee7@774 e8d65cb0-85f4-0310-8831-c60e2a5ce829

--- src/via_id.c
+++ src/via_id.c
@@ -222,6 +222,7 @@
     {"VIA Epia M700",                         VIA_VX800,   0x1106, 0x1122, VIA_DEVICE_CRT},
     {"Samsung NC20",                          VIA_VX800,   0x144d, 0xc04e, VIA_DEVICE_CRT | VIA_DEVICE_LCD},
     {"Quanta DreamBook Light IL1",            VIA_VX800,   0x152d, 0x0771, VIA_DEVICE_CRT | VIA_DEVICE_LCD},
+    {"VIA OpenBook",                          VIA_VX800,   0x1170, 0x1122, VIA_DEVICE_CRT | VIA_DEVICE_LCD}, /* VIA OpenBook eNote VBE8910 */

     /*** VX855 ***/
     {"VIA VT8562C",                           VIA_VX855,   0x1106, 0x5122, VIA_DEVICE_CRT},
@@ -268,15 +269,15 @@
 	if ((Id->Chip == pVia->Chipset) &&
            (Id->Vendor == SUBVENDOR_ID(pVia->PciInfo)) &&
            (Id->Device == SUBSYS_ID(pVia->PciInfo))) {
-	    xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Detected %s.\n", Id->String);
+	    xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Detected %s. Card-Ids (%4X|%4X)\n", Id->String, DEVICE_ID(pVia->PciInfo), SUBVENDOR_ID(pVia->PciInfo));
 	    pVia->Id = Id;
 	    return;
 	}
     }

     xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-	       "Unknown Card-Ids (%4X|%4X|%4X); please report to openchrome-users@openchrome.org\n",
-               DEVICE_ID(pVia->PciInfo), SUBVENDOR_ID(pVia->PciInfo), SUBSYS_ID(pVia->PciInfo));
+	       "Unknown Card-Ids (%4X|%4X|%4X), Chipset: %s; please report to openchrome-users@openchrome.org\n",
+               DEVICE_ID(pVia->PciInfo), SUBVENDOR_ID(pVia->PciInfo), SUBSYS_ID(pVia->PciInfo), pScrn->chipset);
     pVia->Id = NULL;
 }


0005: [Staking] Add missed nStakeSplitThreshold variable

Missed adding the nStakeSplitThreshold variable.

--- src/wallet.h
+++ src/wallet.h
@@ -97,7 +97,11 @@
     MasterKeyMap mapMasterKeys;
     unsigned int nMasterKeyMaxID;

-    // minimum value allowed for nStakeSplitThreshold (customizable with -minstakesplit flag)
+
+    // topcoin: stake split threshold
+    int64_t nStakeSplitThreshold;
+
+    // topcoin: minimum value allowed for nStakeSplitThreshold (customizable with -minstakesplit flag)
     static int64_t minStakeSplitThreshold;

     CWallet()


Fixed invalid use of size_t instead of int

--- src/wapiti.c
+++ src/wapiti.c
@@ -165,12 +165,12 @@
  *   size, so ensure that the stack size code is well handled by your system
  *   when you port it.
  ******************************************************************************/
-typedef void (func_t)(size_t id, size_t cnt, void *ud);
+typedef void (func_t)(int id, int cnt, void *ud);

 typedef struct mth_s mth_t;
 struct mth_s {
-	size_t  id;
-	size_t  cnt;
+	int     id;
+	int     cnt;
 	func_t *f;
 	void   *ud;
 };
@@ -187,7 +187,7 @@
  *   The function will get a unique identifier between 0 and W-1 and a user data
  *   from the 'ud' array.
  */
-static void mth_spawn(func_t *f, size_t W, size_t stacksz, void *ud[W]) {
+static void mth_spawn(func_t *f, int W, size_t stacksz, void *ud[W]) {
 	// We first adjust the requested stack size to be sure it is a round
 	// number of system page size as requested by pthread. As there is no
 	// portable to get the system page size and all systems, at my
@@ -210,7 +210,7 @@
 	// We prepare the parameters structures that will be send to the threads
 	// with informations for calling the user function.
 	mth_t p[W];
-	for (size_t w = 0; w < W; w++) {
+	for (int w = 0; w < W; w++) {
 		p[w].id  = w;
 		p[w].cnt = W;
 		p[w].f   = f;
@@ -220,10 +220,10 @@
 	// their jobs. So we just create all the thread and try to join them
 	// waiting for there return.
 	pthread_t th[W];
-	for (size_t w = 0; w < W; w++)
+	for (int w = 0; w < W; w++)
 		if (pthread_create(&th[w], &attr, &mth_stub, &p[w]) != 0)
 			fatal("failed to create thread");
-	for (size_t w = 0; w < W; w++)
+	for (int w = 0; w < W; w++)
 		if (pthread_join(th[w], NULL) != 0)
 			fatal("failed to join thread");
 	pthread_attr_destroy(&attr);


windows: check for fd==-1 in uv_fs functions

--- src/win/fs.c
+++ src/win/fs.c
@@ -72,7 +72,6 @@
   req->flags |= UV_FS_ASYNC_QUEUED;                                         \
   uv_ref((loop));

-
 #define SET_UV_LAST_ERROR_FROM_REQ(req)                                     \
   if (req->flags & UV_FS_LAST_ERROR_SET) {                                  \
     uv__set_sys_error(req->loop, req->last_error);                          \
@@ -95,6 +94,14 @@
   req->result = -1;                                                         \
   req->errorno = uv_translate_sys_error(sys_errno);                         \
   SET_REQ_LAST_ERROR(req, sys_errno);
+
+#define VERIFY_UV_FILE(file, req)                                           \
+  if (file == -1) {                                                         \
+    req->result = -1;                                                       \
+    req->errorno = UV_EBADF;                                                \
+    req->last_error = ERROR_SUCCESS;                                        \
+    return;                                                                 \
+  }

 void uv_fs_init() {
@@ -241,7 +248,11 @@
 }

 void fs__close(uv_fs_t* req, uv_file file) {
-  int result = _close(file);
+  int result;
+
+  VERIFY_UV_FILE(file, req);
+
+  result = _close(file);
   SET_REQ_RESULT(req, result);
 }

@@ -253,6 +264,8 @@
   LARGE_INTEGER offset_;
   DWORD bytes;

+  VERIFY_UV_FILE(file, req);
+
   handle = (HANDLE) _get_osfhandle(file);
   if (handle == INVALID_HANDLE_VALUE) {
     SET_REQ_RESULT(req, -1);
@@ -290,6 +303,8 @@
   OVERLAPPED overlapped, *overlapped_ptr;
   LARGE_INTEGER offset_;
   DWORD bytes;
+
+  VERIFY_UV_FILE(file, req);

   handle = (HANDLE) _get_osfhandle(file);
   if (handle == INVALID_HANDLE_VALUE) {
@@ -425,6 +440,8 @@
 void fs__fstat(uv_fs_t* req, uv_file file) {
   int result;

+  VERIFY_UV_FILE(file, req);
+
   result = _fstati64(file, &req->stat);
   if (result == -1) {
     req->ptr = NULL;
@@ -443,7 +460,11 @@

 void fs__fsync(uv_fs_t* req, uv_file file) {
-  int result = FlushFileBuffers((HANDLE)_get_osfhandle(file)) ? 0 : -1;
+  int result;
+
+  VERIFY_UV_FILE(file, req);
+
+  result = FlushFileBuffers((HANDLE)_get_osfhandle(file)) ? 0 : -1;
   if (result == -1) {
     SET_REQ_RESULT_WIN32_ERROR(req, GetLastError());
   } else {
@@ -453,7 +474,11 @@

 void fs__ftruncate(uv_fs_t* req, uv_file file, off_t offset) {
-  int result = _chsize(file, offset);
+  int result;
+
+  VERIFY_UV_FILE(file, req);
+
+  result = _chsize(file, offset);
   SET_REQ_RESULT(req, result);
 }

@@ -511,6 +536,8 @@
   IO_STATUS_BLOCK io_status;
   FILE_BASIC_INFORMATION file_info;

+  VERIFY_UV_FILE(file, req);
+
   handle = (HANDLE)_get_osfhandle(file);

   nt_status = pNtQueryInformationFile(handle,
@@ -559,6 +586,9 @@
 void fs__futime(uv_fs_t* req, uv_file file, double atime, double mtime) {
   int result;
   struct _utimbuf b = {(time_t)atime, (time_t)mtime};
+
+  VERIFY_UV_FILE(file, req);
+
   result = _futime(file, &b);
   SET_REQ_RESULT(req, result);
 }


Update the parent window when unmapping a child

--- src/window.c
+++ src/window.c
@@ -224,20 +224,21 @@
     SET_X_SERVER_REQUEST(display, XCB_UNMAP_WINDOW);
     TYPE_CHECK(window, WINDOW, display);
     WindowStruct* windowStruct = GET_WINDOW_STRUCT(window);
+    if (windowStruct->mapState == UnMapped) return;
     if (windowStruct->renderTarget != NULL) {
         GPU_FreeTarget(windowStruct->renderTarget);
         windowStruct->renderTarget = NULL;
     }
-    if (IS_MAPPED_TOP_LEVEL_WINDOW(window)) {
+    windowStruct->mapState = UnMapped;
+    if (windowStruct->sdlWindow != NULL) {
         SDL_DestroyWindow(windowStruct->sdlWindow);
         windowStruct->sdlWindow = NULL;
-    }
-    // TODO: Expose events
+    } else if (GET_WINDOW_STRUCT(GET_PARENT(window))->mapState != UnMapped) {
+        postEvent(display, window, UnmapNotify, False);
+        SDL_Rect exposeRect = {windowStruct->x, windowStruct->y, windowStruct->w, windowStruct->h};
+        postExposeEvent(display, GET_PARENT(window), &exposeRect, 1);
+    }
     // TODO: Change subwindow state to MapRequested?
-    windowStruct->mapState = UnMapped;
-    postEvent(display, window, UnmapNotify, False);
-    SDL_Rect exposeRect = {windowStruct->x, windowStruct->y, windowStruct->w, windowStruct->h};
-    postExposeEvent(display, GET_PARENT(window), &exposeRect, 1);
 }

 Status XWithdrawWindow(Display* display, Window window, int screen_number) {


Implement accept() / select() phase of worker

--- src/worker.c
+++ src/worker.c
@@ -3,56 +3,58 @@
 #include <errno.h>
 #include <pthread.h>

-static int rdlock(pthread_rwlock_t *l, const char *what, int idx)
+#define SUBSYS "worker"
+#include "locks.inc.c"
+
+#define max(a,b) ((a) > (b) ? (a) : (b))
+
+static void handle_client(CONTEXT *c, int connfd)
 {
-	pgr_logf(stderr, LOG_DEBUG, "[worker] acquiring %s/%d read lock %p", what, idx, l);
-	int rc = pthread_rwlock_rdlock(l);
-	if (rc != 0) {
-		pgr_logf(stderr, LOG_ERR, "[worker] failed to acquire %s/%d read lock: %s (errno %d)",
-				what, idx, strerror(rc), rc);
-		return rc;
-	}
-	return 0;
-}
-
-static int wrlock(pthread_rwlock_t *l, const char *what, int idx)
-{
-	pgr_logf(stderr, LOG_DEBUG, "[worker] acquiring %s/%d write lock %p", what, idx, l);
-	int rc = pthread_rwlock_wrlock(l);
-	if (rc != 0) {
-		pgr_logf(stderr, LOG_ERR, "[worker] failed to acquire %s/%d write lock: %s (errno %d)",
-				what, idx, strerror(rc), rc);
-		return rc;
-	}
-	return 0;
-}
-
-static int unlock(pthread_rwlock_t *l, const char *what, int idx)
-{
-	pgr_logf(stderr, LOG_DEBUG, "[worker] releasing %s/%d read lock %p", what, idx, l);
-	int rc = pthread_rwlock_unlock(l);
-	if (rc != 0) {
-		pgr_logf(stderr, LOG_ERR, "[worker] failed to release the %s/%d read lock: %s (errno %d)",
-				what, idx, strerror(rc), rc);
-		return rc;
-	}
-	return 0;
+	/* FIXME: handle the incoming client connection */
+	sleep(5); /* FIXME: remove this sleep */
 }

 static void* do_worker(void *_c)
 {
 	CONTEXT *c = (CONTEXT*)_c;
-	int rc;
+	int rc, connfd, i, nfds;
+	int watch[2] = { c->frontend4, c->frontend6 };
+	fd_set rfds;

 	for (;;) {
-		/* FIXME: block on accept() */
-		/* FIXME: acquire wrlock on CONTEXT to update #clients (++) */
-		/* FIXME: handle the incoming client connection */
-		/* FIXME: close the connection fd */
-		/* FIXME: acquire wrlock on CONTEXT to update #clients (--) */
-		sleep(5); /* FIXME: remove this sleep */
+		FD_ZERO(&rfds);
+		nfds = 0;
+
+		for (i = 0; i < sizeof(watch)/sizeof(watch[0]); i++) {
+			if (watch[i] >= 0) {
+				FD_SET(watch[i], &rfds);
+				nfds = max(watch[i], nfds);
+			}
+		}
+
+		rc = select(nfds+1, &rfds, NULL, NULL, NULL);
+		if (rc == -1) {
+			if (errno == EINTR) {
+				continue;
+			}
+			pgr_logf(stderr, LOG_ERR, "[worker] select received system error: %s (errno %d)",
+					strerror(errno), errno);
+			pgr_abort(ABORT_SYSCALL);
+		}
+
+		for (i = 0; i < sizeof(watch)/sizeof(watch[0]); i++) {
+			if (watch[i] >= 0 && FD_ISSET(watch[i], &rfds)) {
+				connfd = accept(watch[i], NULL, NULL);
+				/* FIXME: acquire wrlock on CONTEXT to update #clients (++) */
+				handle_client(c, connfd);
+				/* FIXME: acquire wrlock on CONTEXT to update #clients (--) */
+				close(connfd);
+			}
+		}
 	}

+	close(c->frontend4);
+	close(c->frontend6);
 	return NULL;
 }


Worker: Added detaching() method

Worker: Added detaching() method

--- src/worker.h
+++ src/worker.h
@@ -143,6 +143,10 @@
 	void detach(int retries = 3);
 	void redetach(int retries = 3);

+	auto detaching() {
+		return _detaching.load(std::memory_order_relaxed);
+	}
+
 	void run_loop();

 	template<typename T, typename... Args, typename = std::enable_if_t<std::is_base_of<Worker, std::decay_t<T>>::value>>


Accepting both N and a display string

Accepting both N and a display string

svn path=/trunk/; revision=468

--- src/xquery.c
+++ src/xquery.c
@@ -34,6 +34,27 @@
 	XRRFreeScreenResources(res);
 }

+/**
+ * Parse a display string to a screen number.
+ *
+ * N -> N
+ * :X.N -> N
+ *
+ * @param display_string
+ */
+int parse_screen(const char* display_string){
+	int screen = 0;
+
+	if ( display_string[0] == ':' ){
+		int dummy;
+		sscanf(display_string, ":%d.%d", &dummy, &screen);
+	} else {
+		sscanf(display_string, "%d", &screen);
+	}
+
+	return screen;
+}
+
 int main(int argc, const char* argv[]){
 	Display* dpy = XOpenDisplay(NULL);
 	assert(dpy);
@@ -52,7 +73,7 @@
 	for ( int i = 1; i < argc; i++ ){
 		if ( strcmp(argv[i], "--screen") == 0 ){
 			if ( ++i<argc ){
-				int screen = atoi(argv[i]);
+				int screen = parse_screen(argv[i]);
 				resolutions_for_screen(dpy, screen);
 			} else {
 				fprintf(stderr, "--screen takes one argument\n");


--- src/zhttpd.c
+++ src/zhttpd.c
@@ -1019,6 +1019,7 @@
 		goto forbidden;
     }

+	//liangjixun update request path format is http://{context}/xxxxx/xxx/md5
     size_t md5_len = strlen(uri) - 9;
     LOG_PRINT(LOG_DEBUG, "get_request_cb md5_len = %d",md5_len);
     md5 = (char *)malloc(md5_len);


mistype fixed

mistype fixed

--- src/zipmap.h
+++ src/zipmap.h
@@ -32,7 +32,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */

-#ifndef _ZIMMAP_H
+#ifndef _ZIPMAP_H
 #define _ZIPMAP_H

 unsigned char *zipmapNew(void);


Added port randomization for testing code to help with automated CI build process that runs many builds in parallel.

--- src/zproxy.c
+++ src/zproxy.c
@@ -377,6 +377,13 @@
     assert (*server);
     int port_nbr = zsock_bind (*server, "tcp://127.0.0.1:*");
     assert (port_nbr > 0);
+
+    // Make port more random for better results during parallel CI testing
+    if (port_nbr < 65535) {
+        srand ((unsigned) time (NULL));
+        port_nbr += rand() % (65535 - port_nbr);
+    }
+
     return port_nbr;
 }


Prefer SHA-256 ciphersuites if using old style PSKs

If we have no certificate and we are using "old style" PSKs then we will
always default to using SHA-256 for that PSK. However we may have selected
a ciphersuite that is not based on SHA-256. Therefore if we see that there
are no certificates and we have been configured for "old style" PSKs then
we should prefer SHA-256 based ciphersuites during the selection process.

Fixes #6197

Reviewed-by: Rich Salz <c04971a99e5a9ee80eaab4b1deb37e845b0bd697@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6215)

--- ssl/s3_lib.c
+++ ssl/s3_lib.c
@@ -4108,8 +4108,9 @@
 {
     const SSL_CIPHER *c, *ret = NULL;
     STACK_OF(SSL_CIPHER) *prio, *allow;
-    int i, ii, ok;
+    int i, ii, ok, prefer_sha256 = 0;
     unsigned long alg_k = 0, alg_a = 0, mask_k = 0, mask_a = 0;
+    const EVP_MD *mdsha256 = EVP_sha256();
 #ifndef OPENSSL_NO_CHACHA
     STACK_OF(SSL_CIPHER) *prio_chacha = NULL;
 #endif
@@ -4190,7 +4191,24 @@
         allow = srvr;
     }

-    if (!SSL_IS_TLS13(s)) {
+    if (SSL_IS_TLS13(s)) {
+        int j;
+
+        /*
+         * If we allow "old" style PSK callbacks, and we have no certificate (so
+         * we're not going to succeed without a PSK anyway), and we're in
+         * TLSv1.3 then the default hash for a PSK is SHA-256 (as per the
+         * TLSv1.3 spec). Therefore we should prioritise ciphersuites using
+         * that.
+         */
+        if (s->psk_server_callback != NULL) {
+            for (j = 0; j < SSL_PKEY_NUM && !ssl_has_cert(s, j); j++);
+            if (j == SSL_PKEY_NUM) {
+                /* There are no certificates */
+                prefer_sha256 = 1;
+            }
+        }
+    } else {
         tls1_set_cert_validity(s);
         ssl_set_masks(s);
     }
@@ -4262,6 +4280,17 @@
                 continue;
             }
 #endif
+            if (prefer_sha256) {
+                const SSL_CIPHER *tmp = sk_SSL_CIPHER_value(allow, ii);
+
+                if (ssl_md(tmp->algorithm2) == mdsha256) {
+                    ret = tmp;
+                    break;
+                }
+                if (ret == NULL)
+                    ret = tmp;
+                continue;
+            }
             ret = sk_SSL_CIPHER_value(allow, ii);
             break;
         }


Fix the MAX_CURVELIST definition

Fix the MAX_CURVELIST definition

The MAX_CURVELIST macro defines the total number of in-built SSL/TLS curves
that we support. However it has not been updated as new curves are added.

Fixes #5232

Reviewed-by: Bernd Edlinger <ac6902843ae77cc0d49b9c8ddec4cbf141db1bb7@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/6065)

--- ssl/t1_lib.c
+++ ssl/t1_lib.c
@@ -366,7 +366,7 @@
     return 1;
 }

-# define MAX_CURVELIST   28
+# define MAX_CURVELIST   OSSL_NELEM(nid_list)

 typedef struct {
     size_t nidcnt;


sqlite: Connection: Privatize handle() accessor

This is now the context's responsibility to fetch a database handle once
it acquired the lock

--- src/database/SqliteConnection.h
+++ src/database/SqliteConnection.h
@@ -157,9 +157,6 @@

     using UpdateHookCb = std::function<void(HookReason, int64_t)>;

-    // Returns the current thread's connection
-    // This will initiate a connection if required
-    Handle handle();
     std::unique_ptr<sqlite::Transaction> newTransaction();
     ReadContext acquireReadContext();
     WriteContext acquireWriteContext();
@@ -201,6 +198,10 @@
      */
     void setRecursiveTriggersEnabled( bool value );

+    // Returns the current thread's connection
+    // This will initiate a connection if required
+    Handle handle();
+
     static void updateHook( void* data, int reason, const char* database,
                             const char* table, sqlite_int64 rowId );
 private:


doveadm-server: Make sure another command isn't started before previous one is finished.

--- src/doveadm/client-connection.c
+++ src/doveadm/client-connection.c
@@ -20,6 +20,8 @@
 #include <unistd.h>

 #define MAX_INBUF_SIZE 1024
+
+static void client_connection_input(struct client_connection *conn);

 struct client_connection {
 	pool_t pool;
@@ -208,6 +210,10 @@
 		return FALSE;
 	}

+	/* make sure client_connection_input() isn't called by the ioloop that
+	   is going to be run by doveadm_mail_cmd_server_run() */
+	io_remove(&conn->io);
+
 	o_stream_cork(conn->output);
 	ctx = doveadm_mail_cmd_server_parse(cmd_name, conn->set, &input, argc, args);
 	if (ctx == NULL)
@@ -220,6 +226,8 @@
 	net_set_nonblock(conn->fd, FALSE);
 	(void)o_stream_flush(conn->output);
 	net_set_nonblock(conn->fd, TRUE);
+
+	conn->io = io_add(conn->fd, IO_READ, client_connection_input, conn);
 	return TRUE;
 }


doveadm backup: Fixed "is source empty" check. In POP3 boxes there is only INBOX, and it's possible that source becomes empty while backup has mails. The check is now "has source always been empty?"

--- src/doveadm/dsync/dsync-brain.c
+++ src/doveadm/dsync/dsync-brain.c
@@ -313,7 +313,7 @@
 	if (count == 0)
 		return TRUE;
 	if (count == 1 && strcasecmp(boxes[0]->name, "INBOX") == 0 &&
-	    boxes[0]->message_count == 0)
+	    boxes[0]->message_count == 0 && boxes[0]->uid_next == 1)
 		return TRUE;
 	return FALSE;
 }


ringbuffer: added force() and use lockless methods

this adds force() which can be used for drivers wanting consumers to
get the latest data when the buffer overflows

--- src/drivers/device/ringbuffer.h
+++ src/drivers/device/ringbuffer.h
@@ -55,7 +55,7 @@
 	bool			put(T &val);

 	/**
-	 * Put an item into the buffer.
+	 * Put an item into the buffer if there is space.
 	 *
 	 * @param val		Item to put
 	 * @return		true if the item was put, false if the buffer is full
@@ -63,6 +63,22 @@
 	bool			put(const T &val);

 	/**
+	 * Force an item into the buffer, discarding an older item if there is not space.
+	 *
+	 * @param val		Item to put
+	 * @return		true if an item was discarded to make space
+	 */
+	bool			force(T &val);
+
+	/**
+	 * Force an item into the buffer, discarding an older item if there is not space.
+	 *
+	 * @param val		Item to put
+	 * @return		true if an item was discarded to make space
+	 */
+	bool			force(const T &val);
+
+	/**
 	 * Get an item from the buffer.
 	 *
 	 * @param val		Item that was gotten
@@ -73,8 +89,8 @@
 	/**
 	 * Get an item from the buffer (scalars only).
 	 *
-	 * @return		The value that was fetched, or zero if the buffer was
-	 *			empty.
+	 * @return		The value that was fetched. If the buffer is empty,
+	 *			returns zero.
 	 */
 	T			get(void);

@@ -97,23 +113,23 @@
 	/*
 	 * Returns true if the buffer is empty.
 	 */
-	bool			empty() { return _tail == _head; }
+	bool			empty();

 	/*
 	 * Returns true if the buffer is full.
 	 */
-	bool			full() { return _next(_head) == _tail; }
+	bool			full();

 	/*
 	 * Returns the capacity of the buffer, or zero if the buffer could
 	 * not be allocated.
 	 */
-	unsigned		size() { return (_buf != nullptr) ? _size : 0; }
+	unsigned		size();

 	/*
 	 * Empties the buffer.
 	 */
-	void			flush() { _head = _tail = _size; }
+	void			flush();

 private:
 	T			*const _buf;
@@ -137,6 +153,38 @@
 {
 	if (_buf != nullptr)
 		delete[] _buf;
+}
+
+template <typename T>
+bool RingBuffer<T>::empty()
+{
+	return _tail == _head;
+}
+
+template <typename T>
+bool RingBuffer<T>::full()
+{
+	return _next(_head) == _tail;
+}
+
+template <typename T>
+unsigned RingBuffer<T>::size()
+{
+	return (_buf != nullptr) ? _size : 0;
+}
+
+template <typename T>
+void RingBuffer<T>::flush()
+{
+	T junk;
+	while (!empty())
+		get(junk);
+}
+
+template <typename T>
+unsigned RingBuffer<T>::_next(unsigned index)
+{
+	return (0 == index) ? _size : (index - 1);
 }

 template <typename T>
@@ -166,11 +214,54 @@
 }

 template <typename T>
+bool RingBuffer<T>::force(T &val)
+{
+	bool overwrote = false;
+
+	for (;;) {
+		if (put(val))
+			break;
+		T junk;
+		get(junk);
+		overwrote = true;
+	}
+	return overwrote;
+}
+
+template <typename T>
+bool RingBuffer<T>::force(const T &val)
+{
+	bool overwrote = false;
+
+	for (;;) {
+		if (put(val))
+			break;
+		T junk;
+		get(junk);
+		overwrote = true;
+	}
+	return overwrote;
+}
+
+template <typename T>
 bool RingBuffer<T>::get(T &val)
 {
 	if (_tail != _head) {
-		val = _buf[_tail];
-		_tail = _next(_tail);
+		unsigned candidate;
+		unsigned next;
+		do {
+			/* decide which element we think we're going to read */
+			candidate = _tail;
+
+			/* and what the corresponding next index will be */
+			next = _next(candidate);
+
+			/* go ahead and read from this index */
+			val = _buf[candidate];
+
+			/* if the tail pointer didn't change, we got our item */
+		} while (!__sync_bool_compare_and_swap(&_tail, candidate, next));
+
 		return true;
 	} else {
 		return false;
@@ -187,17 +278,30 @@
 template <typename T>
 unsigned RingBuffer<T>::space(void)
 {
-	return (_tail >= _head) ? (_size - (_tail - _head)) : (_head - _tail - 1);
+	unsigned tail, head;
+
+	/*
+	 * Make a copy of the head/tail pointers in a fashion that
+	 * may err on the side of under-estimating the free space
+	 * in the buffer in the case that the buffer is being updated
+	 * asynchronously with our check.
+	 * If the head pointer changes (reducing space) while copying,
+	 * re-try the copy.
+	 */
+	do {
+		head = _head;
+		tail = _tail;
+	} while (head != _head);
+
+	return (tail >= head) ? (_size - (tail - head)) : (head - tail - 1);
 }

 template <typename T>
 unsigned RingBuffer<T>::count(void)
 {
+	/*
+	 * Note that due to the conservative nature of space(), this may
+	 * over-estimate the number of items in the buffer.
+	 */
 	return _size - space();
 }
-
-template <typename T>
-unsigned RingBuffer<T>::_next(unsigned index)
-{
-	return (0 == index) ? _size : (index - 1);
-}


r11253/sofa-dev : FIX: compilation of DefaultCollisionGroupManager

Former-commit-id: 52142a97786ab2495f3402a42c2c9907df778275

--- modules/sofa/component/collision/DefaultCollisionGroupManager.h
+++ modules/sofa/component/collision/DefaultCollisionGroupManager.h
@@ -73,10 +73,10 @@
         groupSet.swap(storedGroupSet[inst]);
     }

-    template <typename Container, typename NodeType>
-    void clearGroup(Container &inNodes, typename NodeType::SPtr group)
+    template <typename Container>
+    void clearGroup(Container &inNodes, simulation::Node::SPtr group)
     {
-        NodeType* parent = *inNodes.begin();
+        simulation::Node::SPtr parent = *inNodes.begin();
         while(!group->child.empty()) parent->moveChild(*group->child.begin());

         simulation::DeleteVisitor vis(sofa::core::ExecParams::defaultInstance());


Use PENCIL atomic functions

Use PENCIL atomic functions

--- pencil-benchmarks-imageproc/histogram/histogram.pencil.c
+++ pencil-benchmarks-imageproc/histogram/histogram.pencil.c
@@ -1,20 +1,11 @@
 #include "histogram.pencil.h"
 #include <pencil.h>
-
-void atomic_inc(int *v);
-
-#ifndef __PENCIL__
-void atomic_inc(int *v)
-{
-    (*v)++;
-}
-#endif

 static void calcHist( const int rows
                     , const int cols
                     , const int step
                     , const unsigned char image[static const restrict rows][step]
-                    , int hist[static const restrict HISTOGRAM_BINS]    //out
+                    , atomic_int hist[static const restrict HISTOGRAM_BINS]    //out
                     )
 {
 #pragma scop
@@ -26,7 +17,7 @@

     #pragma pencil independent
     for(int b = 0; b < HISTOGRAM_BINS; ++b)
-        hist[b] = 0;
+        atomic_init(&hist[b], 0);

     #pragma pencil independent
     for(int r = 0; r < rows; ++r)
@@ -35,7 +26,7 @@
         for(int c = 0; c < cols; ++c)
         {
             unsigned char pixel = image[r][c];
-            atomic_inc(&hist[pixel]);
+            atomic_fetch_add(&hist[pixel], 1);
         }
     }

@@ -45,5 +36,6 @@

 void pencil_calcHist( const int rows, const int cols, const int step, const unsigned char image[], int hist[HISTOGRAM_BINS])
 {
-    calcHist( rows, cols, step, (const unsigned char(*)[step])image, hist);
+    calcHist( rows, cols, step, (const unsigned char(*)[step])image,
+		    (atomic_int *) hist);
 }


add tests for ODEModel_getJacobiElement() and ODEModel_freeJacobian()

--- unittest/test_odeModel.c
+++ unittest/test_odeModel.c
@@ -73,6 +73,14 @@
 		ck_assert_str_eq(SolverError_getMessage(ERROR_ERROR_TYPE, 0),	\
 						 "Cyclic dependency found in topological sorting."); \
 		SolverError_clear();											\
+	} while (0)
+
+#define CHECK_JACOBI_ELEMENT(n, expected_i, expected_j) do {	\
+		const nonzeroElem_t *nze;								\
+		nze = ODEModel_getJacobiElement(model, (n));			\
+		ck_assert(nze != NULL);									\
+		ck_assert_int_eq(nze->i, (expected_i));					\
+		ck_assert_int_eq(nze->j, (expected_j));					\
 	} while (0)

 /* test cases */
@@ -482,56 +490,147 @@
 START_TEST(test_ODEModel_constructJacobian_MAPK)
 {
 	model = ODEModel_createFromFile(EXAMPLES_FILENAME("MAPK.xml"));
+	ck_assert_int_eq(model->jacobian, 0);
+	ck_assert_int_eq(model->jacobianFailed, 0);
 	ck_assert_int_eq(ODEModel_constructJacobian(model), 1);
+	ck_assert_int_eq(model->jacobian, 1);
+	ck_assert_int_eq(model->jacobianFailed, 0);
 	ck_assert_int_eq(ODEModel_getNumJacobiElements(model), 26);
+	CHECK_JACOBI_ELEMENT(0, 0, 0);
+	CHECK_JACOBI_ELEMENT(1, 0, 1);
+	CHECK_JACOBI_ELEMENT(2, 0, 7);
+	CHECK_JACOBI_ELEMENT(3, 1, 0);
+	CHECK_JACOBI_ELEMENT(4, 1, 1);
+	CHECK_JACOBI_ELEMENT(5, 1, 7);
+	CHECK_JACOBI_ELEMENT(6, 2, 1);
+	CHECK_JACOBI_ELEMENT(7, 2, 2);
+	CHECK_JACOBI_ELEMENT(8, 2, 3);
+	CHECK_JACOBI_ELEMENT(9, 3, 1);
+	CHECK_JACOBI_ELEMENT(10, 3, 2);
+	CHECK_JACOBI_ELEMENT(11, 3, 3);
+	CHECK_JACOBI_ELEMENT(12, 3, 4);
+	CHECK_JACOBI_ELEMENT(13, 4, 1);
+	CHECK_JACOBI_ELEMENT(14, 4, 3);
+	CHECK_JACOBI_ELEMENT(15, 4, 4);
+	CHECK_JACOBI_ELEMENT(16, 5, 4);
+	CHECK_JACOBI_ELEMENT(17, 5, 5);
+	CHECK_JACOBI_ELEMENT(18, 5, 6);
+	CHECK_JACOBI_ELEMENT(19, 6, 4);
+	CHECK_JACOBI_ELEMENT(20, 6, 5);
+	CHECK_JACOBI_ELEMENT(21, 6, 6);
+	CHECK_JACOBI_ELEMENT(22, 6, 7);
+	CHECK_JACOBI_ELEMENT(23, 7, 4);
+	CHECK_JACOBI_ELEMENT(24, 7, 6);
+	CHECK_JACOBI_ELEMENT(25, 7, 7);
+	ODEModel_freeJacobian(model);
+	ck_assert_int_eq(model->jacobian, 0);
 }
 END_TEST

 START_TEST(test_ODEModel_constructJacobian_basic_model1_forward_l2)
 {
 	model = ODEModel_createFromFile(EXAMPLES_FILENAME("basic-model1-forward-l2.xml"));
+	ck_assert_int_eq(model->jacobian, 0);
+	ck_assert_int_eq(model->jacobianFailed, 0);
 	ck_assert_int_eq(ODEModel_constructJacobian(model), 1);
+	ck_assert_int_eq(model->jacobian, 1);
+	ck_assert_int_eq(model->jacobianFailed, 0);
 	ck_assert_int_eq(ODEModel_getNumJacobiElements(model), 2);
+	CHECK_JACOBI_ELEMENT(0, 0, 0);
+	CHECK_JACOBI_ELEMENT(1, 1, 0);
+	ODEModel_freeJacobian(model);
+	ck_assert_int_eq(model->jacobian, 0);
 }
 END_TEST

 START_TEST(test_ODEModel_constructJacobian_basic)
 {
 	model = ODEModel_createFromFile(EXAMPLES_FILENAME("basic.xml"));
+	ck_assert_int_eq(model->jacobian, 0);
+	ck_assert_int_eq(model->jacobianFailed, 0);
 	ck_assert_int_eq(ODEModel_constructJacobian(model), 1);
+	ck_assert_int_eq(model->jacobian, 1);
+	ck_assert_int_eq(model->jacobianFailed, 0);
 	ck_assert_int_eq(ODEModel_getNumJacobiElements(model), 2);
+	CHECK_JACOBI_ELEMENT(0, 0, 0);
+	CHECK_JACOBI_ELEMENT(1, 1, 0);
+	ODEModel_freeJacobian(model);
+	ck_assert_int_eq(model->jacobian, 0);
 }
 END_TEST

 START_TEST(test_ODEModel_constructJacobian_events_1_event_1_assignment_l2)
 {
 	model = ODEModel_createFromFile(EXAMPLES_FILENAME("events-1-event-1-assignment-l2.xml"));
+	ck_assert_int_eq(model->jacobian, 0);
+	ck_assert_int_eq(model->jacobianFailed, 0);
 	ck_assert_int_eq(ODEModel_constructJacobian(model), 1);
+	ck_assert_int_eq(model->jacobian, 1);
+	ck_assert_int_eq(model->jacobianFailed, 0);
 	ck_assert_int_eq(ODEModel_getNumJacobiElements(model), 2);
+	CHECK_JACOBI_ELEMENT(0, 0, 0);
+	CHECK_JACOBI_ELEMENT(1, 1, 0);
+	ODEModel_freeJacobian(model);
+	ck_assert_int_eq(model->jacobian, 0);
 }
 END_TEST

 START_TEST(test_ODEModel_constructJacobian_events_2_events_1_assignment_l2)
 {
 	model = ODEModel_createFromFile(EXAMPLES_FILENAME("events-2-events-1-assignment-l2.xml"));
+	ck_assert_int_eq(model->jacobian, 0);
+	ck_assert_int_eq(model->jacobianFailed, 0);
 	ck_assert_int_eq(ODEModel_constructJacobian(model), 1);
+	ck_assert_int_eq(model->jacobian, 1);
+	ck_assert_int_eq(model->jacobianFailed, 0);
 	ck_assert_int_eq(ODEModel_getNumJacobiElements(model), 2);
+	CHECK_JACOBI_ELEMENT(0, 0, 0);
+	CHECK_JACOBI_ELEMENT(1, 1, 0);
+	ODEModel_freeJacobian(model);
+	ck_assert_int_eq(model->jacobian, 0);
 }
 END_TEST

 START_TEST(test_ODEModel_constructJacobian_huang96)
 {
 	model = ODEModel_createFromFile(EXAMPLES_FILENAME("huang96.xml"));
+	ck_assert_int_eq(model->jacobian, 0);
+	ck_assert_int_eq(model->jacobianFailed, 0);
 	ck_assert_int_eq(ODEModel_constructJacobian(model), 1);
+	ck_assert_int_eq(model->jacobian, 1);
+	ck_assert_int_eq(model->jacobianFailed, 0);
 	ck_assert_int_eq(ODEModel_getNumJacobiElements(model), 92);
+	ODEModel_freeJacobian(model);
+	ck_assert_int_eq(model->jacobian, 0);
 }
 END_TEST

 START_TEST(test_ODEModel_constructJacobian_repressilator)
 {
 	model = ODEModel_createFromFile(EXAMPLES_FILENAME("repressilator.xml"));
+	ck_assert_int_eq(model->jacobian, 0);
+	ck_assert_int_eq(model->jacobianFailed, 0);
 	ck_assert_int_eq(ODEModel_constructJacobian(model), 1);
+	ck_assert_int_eq(model->jacobian, 1);
+	ck_assert_int_eq(model->jacobianFailed, 0);
 	ck_assert_int_eq(ODEModel_getNumJacobiElements(model), 15);
+	CHECK_JACOBI_ELEMENT(0, 0, 0);
+	CHECK_JACOBI_ELEMENT(1, 0, 3);
+	CHECK_JACOBI_ELEMENT(2, 1, 1);
+	CHECK_JACOBI_ELEMENT(3, 1, 4);
+	CHECK_JACOBI_ELEMENT(4, 2, 2);
+	CHECK_JACOBI_ELEMENT(5, 2, 5);
+	CHECK_JACOBI_ELEMENT(6, 3, 0);
+	CHECK_JACOBI_ELEMENT(7, 3, 2);
+	CHECK_JACOBI_ELEMENT(8, 3, 3);
+	CHECK_JACOBI_ELEMENT(9, 4, 0);
+	CHECK_JACOBI_ELEMENT(10, 4, 1);
+	CHECK_JACOBI_ELEMENT(11, 4, 4);
+	CHECK_JACOBI_ELEMENT(12, 5, 1);
+	CHECK_JACOBI_ELEMENT(13, 5, 2);
+	CHECK_JACOBI_ELEMENT(14, 5, 5);
+	ODEModel_freeJacobian(model);
+	ck_assert_int_eq(model->jacobian, 0);
 }
 END_TEST


Fixed precision error when printing TS mux rate - cf#348

--- applications/mp42ts/main.c
+++ applications/mp42ts/main.c
@@ -2745,10 +2745,10 @@

 	{
 		u64 bits = muxer->tot_pck_sent*8*188;
-		u32 dur_sec = gf_m2ts_get_ts_clock(muxer) / 1000;
-		if (!dur_sec) dur_sec = 1;
-		fprintf(stderr, "Done muxing - %d sec - average rate %d kbps "LLD" packets written\n", dur_sec, (u32) (bits/dur_sec/1000), muxer->tot_pck_sent);
-		fprintf(stderr, "\tPadding: "LLD" packets - "LLD" PES padded bytes (%g kbps)\n", muxer->tot_pad_sent, muxer->tot_pes_pad_bytes, (Double) (muxer->tot_pes_pad_bytes*8.0/dur_sec/1000) );
+		u64 dur_ms = gf_m2ts_get_ts_clock(muxer);
+		if (!dur_ms) dur_ms = 1;
+		fprintf(stderr, "Done muxing - %.02f sec - average rate %d kbps "LLD" packets written\n", ((Double) dur_ms)/1000.0, (u32) (bits/dur_ms), muxer->tot_pck_sent);
+		fprintf(stderr, " Padding: "LLD" packets (%g kbps) - "LLD" PES padded bytes (%g kbps)\n", muxer->tot_pad_sent, (Double) (muxer->tot_pad_sent*188*8.0/dur_ms) , muxer->tot_pes_pad_bytes, (Double) (muxer->tot_pes_pad_bytes*8.0/dur_ms) );
 	}

 exit:


[bouqueau] fix crash when asking for '-info' on non iso file

--- applications/mp4box/main.c
+++ applications/mp4box/main.c
@@ -2658,8 +2658,12 @@
 	if (!HintIt && print_sdp) DumpSDP(file, dump_std ? NULL : outfile);
 #endif
 	if (print_info) {
-		if (info_track_id) DumpTrackInfo(file, info_track_id, 1);
-		else DumpMovieInfo(file);
+		if (!file) {
+			fprintf(stdout, "Cannot print info on a non ISOM file (%s)\n", inName);
+		} else {
+			if (info_track_id) DumpTrackInfo(file, info_track_id, 1);
+			else DumpMovieInfo(file);
+		}
 	}
 #ifndef GPAC_DISABLE_ISOM_DUMP
 	if (dump_isom) dump_isom_xml(file, dump_std ? NULL : outfile);


Fix a typo in Dash help

Fix a typo in Dash help

--- applications/mp4box/main.c
+++ applications/mp4box/main.c
@@ -323,7 +323,7 @@
 	        "Input media files to dash can use the following modifiers\n"
 	        " \"#trackID=N\"       only uses the track ID N from the source file\n"
 	        " \"#video\"           only uses the first video track from the source file\n"
-	        " \"#audio\"           only uses the first video track from the source file\n"
+	        " \"#audio\"           only uses the first audio track from the source file\n"
 	        " \":id=NAME\"         sets the representation ID to NAME\n"
 	        " \":dur=VALUE\"       processes VALUE seconds from the media\n"
 	        "                       If VALUE is longer than the media duration, the last media duration is lengthen.\n"


ENG-4515: Fix missing include on linux

ENG-4515: Fix missing include on linux

--- src/ee/common/PlannerDomValue.h
+++ src/ee/common/PlannerDomValue.h
@@ -21,6 +21,9 @@
 #include "common/SerializableEEException.h"

 #include "rapidjson/document.h"
+
+#include <cstdio>
+#include <cstdlib>

 namespace voltdb {


egl_dri2: Implement EGL_KHR_surfaceless_* extensions

--- src/egl/drivers/dri2/egl_dri2.c
+++ src/egl/drivers/dri2/egl_dri2.c
@@ -177,9 +177,9 @@
    EGL_Y_INVERTED_NOK,		/* __DRI_ATTRIB_YINVERTED */
 };

-static void
+static struct dri2_egl_config *
 dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
-		int depth, xcb_visualtype_t *visual)
+		int depth, EGLint surface_type)
 {
    struct dri2_egl_config *conf;
    struct dri2_egl_display *dri2_dpy;
@@ -192,6 +192,10 @@
    _eglInitConfig(&base, disp, id);

    i = 0;
+   double_buffer = 0;
+   bind_to_texture_rgb = 0;
+   bind_to_texture_rgba = 0;
+
    while (dri2_dpy->core->indexConfigAttrib(dri_config, i++, &attrib, &value)) {
       switch (attrib) {
       case __DRI_ATTRIB_RENDER_TYPE:
@@ -242,35 +246,27 @@
     * return in the getBuffer callback to get the behaviour we want. */

    if (double_buffer)
-      return;
-
-   if (visual != NULL) {
-      if (depth != _eglGetConfigKey(&base, EGL_BUFFER_SIZE))
-	 return;
-
-      _eglSetConfigKey(&base, EGL_SURFACE_TYPE,
-		       EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT |
-		       EGL_SWAP_BEHAVIOR_PRESERVED_BIT);
-
-      _eglSetConfigKey(&base, EGL_NATIVE_VISUAL_ID, visual->visual_id);
-      _eglSetConfigKey(&base, EGL_NATIVE_VISUAL_TYPE, visual->_class);
-   } else {
-      _eglSetConfigKey(&base, EGL_SURFACE_TYPE,
-		       EGL_PIXMAP_BIT | EGL_PBUFFER_BIT);
-   }
+      return NULL;
+
+   if (depth > 0 && depth != _eglGetConfigKey(&base, EGL_BUFFER_SIZE))
+      return NULL;

    _eglSetConfigKey(&base, EGL_NATIVE_RENDERABLE, EGL_TRUE);
-   _eglSetConfigKey(&base, EGL_BIND_TO_TEXTURE_RGB, bind_to_texture_rgb);
-   if (_eglGetConfigKey(&base, EGL_ALPHA_SIZE) > 0)
-      _eglSetConfigKey(&base,
-		       EGL_BIND_TO_TEXTURE_RGBA, bind_to_texture_rgba);
+
+   _eglSetConfigKey(&base, EGL_SURFACE_TYPE, surface_type);
+   if (surface_type & (EGL_PIXMAP_BIT | EGL_PBUFFER_BIT)) {
+      _eglSetConfigKey(&base, EGL_BIND_TO_TEXTURE_RGB, bind_to_texture_rgb);
+      if (_eglGetConfigKey(&base, EGL_ALPHA_SIZE) > 0)
+	 _eglSetConfigKey(&base,
+			  EGL_BIND_TO_TEXTURE_RGBA, bind_to_texture_rgba);
+   }

    _eglSetConfigKey(&base, EGL_RENDERABLE_TYPE, disp->ClientAPIsMask);
    _eglSetConfigKey(&base, EGL_CONFORMANT, disp->ClientAPIsMask);

    if (!_eglValidateConfig(&base, EGL_FALSE)) {
       _eglLog(_EGL_DEBUG, "DRI2: failed to validate config %d", id);
-      return;
+      return NULL;
    }

    conf = malloc(sizeof *conf);
@@ -279,6 +275,8 @@
       conf->dri_config = dri_config;
       _eglAddConfig(disp, &conf->base);
    }
+
+   return conf;
 }

 /**
@@ -613,10 +611,19 @@
    xcb_depth_iterator_t d;
    xcb_visualtype_t *visuals;
    int i, j, id;
+   struct dri2_egl_config *conf;
+   EGLint surface_type;

    s = xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy->conn));
    d = xcb_screen_allowed_depths_iterator(s.data);
    id = 1;
+
+   surface_type =
+      EGL_WINDOW_BIT |
+      EGL_PIXMAP_BIT |
+      EGL_PBUFFER_BIT |
+      EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
+
    while (d.rem > 0) {
       EGLBoolean class_added[6] = { 0, };

@@ -626,9 +633,16 @@
 	    continue;

 	 class_added[visuals[i]._class] = EGL_TRUE;
-	 for (j = 0; dri2_dpy->driver_configs[j]; j++)
-	    dri2_add_config(disp, dri2_dpy->driver_configs[j],
-			    id++, d.data->depth, &visuals[i]);
+	 for (j = 0; dri2_dpy->driver_configs[j]; j++) {
+	    conf = dri2_add_config(disp, dri2_dpy->driver_configs[j],
+				   id++, d.data->depth, surface_type);
+	    if (conf == NULL)
+	       continue;
+	    _eglSetConfigKey(&conf->base,
+			     EGL_NATIVE_VISUAL_ID, visuals[i].visual_id);
+	    _eglSetConfigKey(&conf->base,
+			     EGL_NATIVE_VISUAL_TYPE, visuals[i]._class);
+	 }
       }

       xcb_depth_next(&d);
@@ -737,6 +751,12 @@
       disp->ClientAPIsMask |= EGL_OPENGL_ES_BIT;
    if (api_mask & (1 << __DRI_API_GLES2))
       disp->ClientAPIsMask |= EGL_OPENGL_ES2_BIT;
+
+   if (dri2_dpy->dri2->base.version >= 2) {
+      disp->Extensions.KHR_surfaceless_gles1 = EGL_TRUE;
+      disp->Extensions.KHR_surfaceless_gles2 = EGL_TRUE;
+      disp->Extensions.KHR_surfaceless_opengl = EGL_TRUE;
+   }

    return EGL_TRUE;

@@ -948,6 +968,7 @@
 		    EGLint *major, EGLint *minor)
 {
    struct dri2_egl_display *dri2_dpy;
+   int i;

    dri2_dpy = malloc(sizeof *dri2_dpy);
    if (!dri2_dpy)
@@ -969,6 +990,9 @@

    if (!dri2_create_screen(disp))
       goto cleanup_driver;
+
+   for (i = 0; dri2_dpy->driver_configs[i]; i++)
+      dri2_add_config(disp, dri2_dpy->driver_configs[i], i + 1, 0, 0);

    disp->Extensions.KHR_image_base = EGL_TRUE;
    disp->Extensions.KHR_gl_renderbuffer_image = EGL_TRUE;
@@ -1041,6 +1065,7 @@
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
    struct dri2_egl_context *dri2_ctx_shared = dri2_egl_context(share_list);
    struct dri2_egl_config *dri2_config = dri2_egl_config(conf);
+   const __DRIconfig *dri_config;
    int api;

    dri2_ctx = malloc(sizeof *dri2_ctx);
@@ -1074,11 +1099,16 @@
       return NULL;
    }

+   if (conf != NULL)
+      dri_config = dri2_config->dri_config;
+   else
+      dri_config = NULL;
+
    if (dri2_dpy->dri2->base.version >= 2) {
       dri2_ctx->dri_context =
 	 dri2_dpy->dri2->createNewContextForAPI(dri2_dpy->dri_screen,
 						api,
-						dri2_config->dri_config,
+						dri_config,
 						dri2_ctx_shared ?
 						dri2_ctx_shared->dri_context : NULL,
 						dri2_ctx);


Add utility to generate Deadfrog lib format bitmap font files.

error: pathspec 'useful_code/bmp_to_fnt.c' did not match any file(s) known to git

--- useful_code/bmp_to_fnt.c
+++ useful_code/bmp_to_fnt.c
@@ -0,0 +1,77 @@
+// g++ bmp_to_fnt.c -o bmp_to_fnt -g -I../src ../src/df_bitmap.cpp ../src/df_bmp.cpp ../src/df_colour.cpp ../src/df_common_linux.cpp
+
+#include "df_bitmap.h"
+#include "df_bmp.h"
+#include "df_common.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+
+static void write(int runLen) {
+    static int column = 0;
+    column += printf("%i,", runLen);
+    if (column > 95) {
+        printf("\n ");
+        column = 0;
+    }
+}
+
+
+int main(int argc, char *argv[]) {
+    if (argc != 4) {
+        puts("Usage: bmp_to_fnt <your.bmp> <glyph height> <glyph width>");
+        puts("Outputs the font definition as a C code that can be included in your project.");
+        puts("Params:");
+        puts("  your.bmp - Your bitmap should have 16 columns and 14 rows of glyphs.");
+        puts("             The first (top left) glyph should be ascii 32. The last");
+        puts("             should be ascii 255.");
+        puts("             The bitmap size should be 16 * glyph width, 14 * glyph height");
+        puts("  glyph height - In pixels");
+        puts("  glyph width - In pixels.");
+        return 0;
+    }
+
+    const char *bmp_name = argv[1];
+    int glyph_width = strtoul(argv[2], NULL, 10);
+    int glyph_height = strtoul(argv[3], NULL, 10);
+
+    DfBitmap *bmp = LoadBmp(bmp_name);
+    ReleaseAssert(bmp, "Couldn't load bitmap '%s'.", bmp_name);
+
+    ReleaseAssert(glyph_width < 256, "Glyph width %i too large. Maximum is 255.", glyph_width);
+    ReleaseAssert(glyph_height < 256, "Glyph height %i too large. Maximum is 255.", glyph_height);
+    ReleaseAssert(glyph_width * 16 == bmp->width, "Bitmap has the wrong width. It is %i and should be %i\n",
+        bmp->width, 16 * glyph_width);
+    ReleaseAssert(glyph_height * 14 == bmp->height, "Bitmap has the wrong height. It is %i and should be %i\n",
+        bmp->height, 14 * glyph_height);
+
+    printf("unsigned char %s[] = {\n ", argv[1]);
+    write((int)'d'); // \
+    write((int)'f'); //  } Format magic
+    write((int)'b'); //  } marker.
+    write((int)'f'); // /
+    write(0);   // Format version.
+    write(glyph_width);
+    write(glyph_height);
+
+    DfColour runVal = g_colourBlack;
+    int runLen = 0;
+    for (int y = 0; y < bmp->height; y++) {
+        for (int x = 0; x < bmp->width; x++) {
+            if (GetPix(bmp, x, y).c == runVal.c) {
+                runLen++;
+                if (runLen >= 255) {
+                    write(runLen);
+                    runLen = 0;
+                }
+            }
+            else {
+                write(runLen);
+                runLen = 1;
+                runVal = GetPix(bmp, x, y);
+            }
+        }
+    }
+
+    printf("\n};\n");
+}


egl_dri2: Fix compilation if udev devel files are not installed

NOTE: This is a candidate for the 7.11 branch.

--- src/egl/drivers/dri2/egl_dri2.h
+++ src/egl/drivers/dri2/egl_dri2.h
@@ -44,7 +44,9 @@
 #include <GL/gl.h>
 #include <GL/internal/dri_interface.h>

+#ifdef HAVE_DRM_PLATFORM
 #include <gbm_driint.h>
+#endif

 #include "eglconfig.h"
 #include "eglcontext.h"
@@ -82,7 +84,9 @@
    __DRIimageExtension      *image;
    int                       fd;

+#ifdef HAVE_DRM_PLATFORM
    struct gbm_dri_device    *gbm_dri;
+#endif

    char                     *device_name;
    char                     *driver_name;


decode utimes, lutimes, futimes, chflags, lchflags.


Make "burncd ... fixate eject" really work as promised.

--- usr.sbin/burncd/burncd.c
+++ usr.sbin/burncd/burncd.c
@@ -161,7 +161,7 @@
 	for (arg = 0; arg < argc; arg++) {
 		if (!strcasecmp(argv[arg], "fixate")) {
 			fixate = 1;
-			break;
+			continue;
 		}
 		if (!strcasecmp(argv[arg], "eject")) {
 			eject = 1;


PC98 got it right here: sectors can be non-512 byte sized.


Add support for recording the total energy used (in joules) when in verbose mode.  This is useful for profiling new adaptive algorithms in performance (via time(1)) and total energy consumed for a given workload.

--- usr.sbin/powerd/powerd.c
+++ usr.sbin/powerd/powerd.c
@@ -30,6 +30,7 @@

 #include <err.h>
 #include <fcntl.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -69,10 +70,11 @@
 #define APMDEV		"/dev/apm"

 static int	read_usage_times(long *idle, long *total);
-static int	read_freqs(int *numfreqs, int **freqs);
+static int	read_freqs(int *numfreqs, int **freqs, int **power);
 static int	set_freq(int freq);
 static void	acline_init(void);
 static int	acline_read(void);
+static void	handle_sigs(int sig);
 static void	parse_mode(char *arg, int *mode, int ch);
 static void	usage(void);

@@ -88,6 +90,7 @@
 static int	poll_ival;

 static int	apm_fd;
+static int	exit_requested;

 static int
 read_usage_times(long *idle, long *total)
@@ -116,7 +119,7 @@
 }

 static int
-read_freqs(int *numfreqs, int **freqs)
+read_freqs(int *numfreqs, int **freqs, int **power)
 {
 	char *freqstr, *p, *q;
 	int i;
@@ -138,13 +141,19 @@
 		free(freqstr);
 		return (-1);
 	}
+	if ((*power = malloc(*numfreqs * sizeof(int))) == NULL) {
+		free(freqstr);
+		free(*freqs);
+		return (-1);
+	}
 	for (i = 0, p = freqstr; i < *numfreqs; i++) {
 		q = strchr(p, ' ');
 		if (q != NULL)
 			*q = '\0';
-		if (sscanf(p, "%d/%*d", &(*freqs)[i]) != 1) {
+		if (sscanf(p, "%d/%d", &(*freqs)[i], &(*power)[i]) != 2) {
 			free(freqstr);
 			free(*freqs);
+			free(*power);
 			return (-1);
 		}
 		p = q + 1;
@@ -225,6 +234,12 @@
 }

 static void
+handle_sigs(int __unused sig)
+{
+	exit_requested = 1;
+}
+
+static void
 usage(void)
 {

@@ -237,8 +252,9 @@
 main(int argc, char * argv[])
 {
 	long idle, total;
-	int curfreq, *freqs, i, numfreqs;
+	int curfreq, *freqs, i, *mwatts, numfreqs;
 	int ch, mode_ac, mode_battery, mode_none, acline, mode, vflag;
+	uint64_t mjoules_used;
 	size_t len;

 	/* Default mode for all AC states is adaptive. */
@@ -246,6 +262,7 @@
 	cpu_running_mark = DEFAULT_ACTIVE_PERCENT;
 	cpu_idle_mark = DEFAULT_IDLE_PERCENT;
 	poll_ival = DEFAULT_POLL_INTERVAL;
+	mjoules_used = 0;
 	vflag = 0;
 	apm_fd = -1;

@@ -307,7 +324,7 @@
 	/* Check if we can read the idle time and supported freqs. */
 	if (read_usage_times(NULL, NULL))
 		err(1, "read_usage_times");
-	if (read_freqs(&numfreqs, &freqs))
+	if (read_freqs(&numfreqs, &freqs, &mwatts))
 		err(1, "error reading supported CPU frequencies");

 	/* Decide whether to use ACPI or APM to read the AC line status. */
@@ -316,11 +333,22 @@
 	/* Run in the background unless in verbose mode. */
 	if (!vflag)
 		daemon(0, 0);
+	signal(SIGINT, handle_sigs);
+	signal(SIGTERM, handle_sigs);

 	/* Main loop. */
 	for (;;) {
 		/* Check status every few milliseconds. */
 		usleep(poll_ival);
+
+		/* If the user requested we quit, print some statistics. */
+		if (exit_requested) {
+			if (vflag && mjoules_used != 0)
+				printf("total joules used: %u.%03u\n",
+				    (u_int)(mjoules_used / 1000),
+				    (int)mjoules_used % 1000);
+			break;
+		}

 		/* Read the current AC status and record the mode. */
 		acline = acline_read();
@@ -342,6 +370,18 @@
 		len = sizeof(curfreq);
 		if (sysctl(freq_mib, 4, &curfreq, &len, NULL, 0))
 			err(1, "error reading current CPU frequency");
+
+		if (vflag) {
+			for (i = 0; i < numfreqs; i++) {
+				if (freqs[i] == curfreq)
+					break;
+			}
+
+			/* Keep a sum of all power actually used. */
+			if (i < numfreqs && mwatts[i] != -1)
+				mjoules_used +=
+				    (mwatts[i] * (poll_ival / 1000)) / 1000;
+		}

 		/* Always switch to the lowest frequency in min mode. */
 		if (mode == MODE_MIN) {
@@ -409,7 +449,8 @@
 				    freqs[i]);
 		}
 	}
-	/* NOTREACHED */
+	free(freqs);
+	free(mwatts);

 	exit(0);
 }


Mention the error when we fail to connect().

--- usr.sbin/pppctl/pppctl.c
+++ usr.sbin/pppctl/pppctl.c
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$Id: pppctl.c,v 1.15 1997/12/27 13:44:42 brian Exp $
+ *	$Id: pppctl.c,v 1.16 1998/03/22 00:43:04 brian Exp $
  */

 #include <sys/types.h>
@@ -198,7 +198,7 @@
     struct sockaddr *sock;
     struct sockaddr_in ifsin;
     struct sockaddr_un ifsun;
-    int socksz, arg, fd, len, verbose;
+    int socksz, arg, fd, len, verbose, err;
     unsigned TimeoutVal;
     char *DoneWord = "x", *next, *start;
     struct sigaction act, oact;
@@ -314,13 +314,19 @@
     }

     if (connect(fd, sock, socksz) < 0) {
+        err = errno;
         if (TimeoutVal) {
             alarm(0);
             sigaction(SIGALRM, &oact, 0);
         }
-        if (TimedOut)
+        if (TimedOut) {
             fputs("Timeout: ", stderr);
-        fprintf(stderr, "Cannot connect to socket %s\n", argv[arg]);
+            err = 0;
+        }
+        fprintf(stderr, "Cannot connect to socket %s", argv[arg]);
+        if (err)
+            fprintf(stderr, ": %s", strerror(err));
+        fputc('\n', stderr);
         close(fd);
         return 3;
     }


made force-cat option more agressive

made force-cat option more agressive

--- applications/mp4box/fileimport.c
+++ applications/mp4box/fileimport.c
@@ -2010,6 +2010,7 @@
 		}

 		if (dst_tk) {
+			u32 found_dst_tk = dst_tk;
 			u32 stype = gf_isom_get_media_subtype(dest, dst_tk, 1);
 			/*we MUST have the same codec*/
 			if (gf_isom_get_media_subtype(orig, i+1, 1) != stype) dst_tk = 0;
@@ -2046,6 +2047,9 @@
 					dst_tk = merge_hevc_config(dest, tk_id, orig, i+1, force_cat);
 				}
 #endif /*GPAC_DISABLE_HEVC*/
+				else if (force_cat) {
+					dst_tk = found_dst_tk;
+				}
 			}
 		}


Fixed widget packaging to remove .svn directory

--- applications/mp4box/fileimport.c
+++ applications/mp4box/fileimport.c
@@ -1843,7 +1843,7 @@
 }
 static Bool wgt_enum_dir(void *cbck, char *file_name, char *file_path)
 {
-	if (!stricmp(file_name, "cvs") || !stricmp(file_name, "svn")) return 0;
+	if (!stricmp(file_name, "cvs") || !stricmp(file_name, ".svn")) return 0;
 	gf_enum_directory(file_path, 0, wgt_enum_files, cbck, NULL);
 	return gf_enum_directory(file_path, 1, wgt_enum_dir, cbck, NULL);
 }


Get compilation working on (recognised) non-x86 architectures.

Essentially, don't try to build x86-specific code.
Also, mark as ‘no compiled VM’.

--- src/engine/qcommon/q_platform.h
+++ src/engine/qcommon/q_platform.h
@@ -38,6 +38,10 @@
 // this is for determining if we have an asm version of a C function
 #define idx64 0
 #define idx64_32 0
+
+#ifdef VM_COMPILED
+#undef VM_COMPILED
+#endif

 #ifdef Q3_VM

@@ -130,6 +134,7 @@

 #if defined( __WIN64__ )
 #define ARCH_STRING "x86_64"
+#define VM_COMPILED
 #elif defined _M_ALPHA
 #define ARCH_STRING "AXP"
 #endif
@@ -163,6 +168,7 @@

 #if defined( _M_IX86 ) || defined( __i386__ )
 #define ARCH_STRING "i386"
+#define VM_COMPILED
 #elif defined _M_ALPHA
 #define ARCH_STRING "AXP"
 #endif
@@ -195,11 +201,13 @@
 #elif defined __i386__
 #define ARCH_STRING "i386"
 #define Q3_LITTLE_ENDIAN
+#define VM_COMPILED
 #elif defined __x86_64__
 #undef idx64
 #define idx64       1
 #define ARCH_STRING "x86_64"
 #define Q3_LITTLE_ENDIAN
+#define VM_COMPILED
 #endif

 #define DLL_PREFIX    "lib"
@@ -221,14 +229,17 @@

 #if defined __i386__
 #define ARCH_STRING "i386"
+#define VM_COMPILED
 #elif defined __x86_64__ && defined _ILP32
 #undef idx64_32
 #define idx64_32    1
 #define ARCH_STRING "x32"
+#define VM_COMPILED
 #elif defined __x86_64__
 #undef idx64
 #define idx64       1
 #define ARCH_STRING "x86_64"
+#define VM_COMPILED
 #elif defined __powerpc64__
 #define ARCH_STRING "ppc64"
 #elif defined __powerpc__
@@ -445,4 +456,8 @@

 #endif

-#endif
+#ifndef VM_COMPILED
+#define NO_VM_COMPILED
+#endif
+
+#endif


Changed SV_BuildClientSnapshot to use "Com_Memset" instead of "memset".

OpenWolf.

--- src/engine/server/sv_snapshot.c
+++ src/engine/server/sv_snapshot.c
@@ -658,7 +658,7 @@

 	// clear everything in this snapshot
 	entityNumbers.numSnapshotEntities = 0;
-	memset(frame->areabits, 0, sizeof(frame->areabits));
+	Com_Memset(frame->areabits, 0, sizeof(frame->areabits));

 	// show_bug.cgi?id=62
 	frame->num_entities = 0;


remove in place constructor

remove in place constructor


flexframesync: trivial debug printf bug

flexframesync: trivial debug printf bug

--- src/framing/src/flexframesync.c
+++ src/framing/src/flexframesync.c
@@ -366,7 +366,7 @@
         //    threshold at any time within the past <squelch_timeout> samples
         // 2. mode is FLEXFRAMESYNC_STATE_SEEKPN (seek p/n sequence)
         _fs->squelch_status = agc_crcf_squelch_get_status(_fs->agc_rx);
-#ifdef DEBUG_FLEXFRAMESYNC_PRINT
+#if DEBUG_FLEXFRAMESYNC_PRINT
         if (_fs->squelch_status == LIQUID_AGC_SQUELCH_TIMEOUT)
             printf("squelch active\n");
 #endif