Simplify the calculation load

Simplify the calculation load

--- kernel/tsp_cl_full_float.c
+++ kernel/tsp_cl_full_float.c
@@ -80,37 +80,34 @@
                global int* chromosomes, global bool* survivors, float p_c,
                uint* ra)
 {
-  bool ilive = survivors[idx];
+  // We don't need to check if this chromosome is still alive because it only has dead one.
+  int c_start = idx * chromosome_size;
+  uint c1_idx = find_survied_idx(ra, survivors, chromosome_count);
+  int c1_start = c1_idx * chromosome_size;

-  if (!ilive) {
-    int c_start = idx * chromosome_size;
-    uint c1_idx = find_survied_idx(ra, survivors, chromosome_count);
-    int c1_start = c1_idx * chromosome_size;
-
-    float p_v =  rand_prob(ra);
-    // printf(" >>>>> not live - idx(%d)/ c1idx(%d), p_v(%f)\n", idx, c1_idx, p_v);
-    if (p_v < p_c) {
-      // print_chrosome(idx, chromosomes, chromosome_size);
-      for (int i = 0; i < chromosome_size; i++) {
-        chromosomes[c_start + i] = chromosomes[c1_start + i];
+  float p_v =  rand_prob(ra);
+  // printf(" >>>>> not live - idx(%d)/ c1idx(%d), p_v(%f)\n", idx, c1_idx, p_v);
+  if (p_v < p_c) {
+    // print_chrosome(idx, chromosomes, chromosome_size);
+    for (int i = 0; i < chromosome_size; i++) {
+      chromosomes[c_start + i] = chromosomes[c1_start + i];
+    }
+    // print_chrosome(c1_idx, chromosomes, chromosome_size);
+    uint c2_idx = find_survied_idx(ra, survivors, chromosome_count);
+    // do crossover here
+    uint cross_point = rand_range(ra, chromosome_size-1);
+    int c2_start = c2_idx * chromosome_size;
+    for (int i = 0; i < chromosome_size-1; i++) {
+      if (chromosomes[c_start + i] == chromosomes[c2_start + cross_point]) {
+        // printf("  <<<<< not live idx(%d)- c2_idx(%d) / cp(%u) / i(%d) \n", idx, c2_idx, cross_point, i);
+        // print_chrosome(c2_idx, chromosomes, chromosome_size);
+        chromosome_swap(idx, chromosomes, chromosome_size, cross_point, i);
+        break;
       }
-      // print_chrosome(c1_idx, chromosomes, chromosome_size);
-      uint c2_idx = find_survied_idx(ra, survivors, chromosome_count);
-      // do crossover here
-      uint cross_point = rand_range(ra, chromosome_size-1);
-      int c2_start = c2_idx * chromosome_size;
-      for (int i = 0; i < chromosome_size-1; i++) {
-        if (chromosomes[c_start + i] == chromosomes[c2_start + cross_point]) {
-          // printf("  <<<<< not live idx(%d)- c2_idx(%d) / cp(%u) / i(%d) \n", idx, c2_idx, cross_point, i);
-          // print_chrosome(c2_idx, chromosomes, chromosome_size);
-          chromosome_swap(idx, chromosomes, chromosome_size, cross_point, i);
-          break;
-        }
-      }
-    } else {
-      for (int i = 0; i < chromosome_size; i++) {
-        chromosomes[c_start + i] = chromosomes[c1_start + i];
-      }
+    }
+  } else {
+    for (int i = 0; i < chromosome_size; i++) {
+      chromosomes[c_start + i] = chromosomes[c1_start + i];
     }
   }
 }
@@ -156,27 +153,35 @@
   barrier(CLK_GLOBAL_MEM_FENCE);
   printf("[FirstRound] idx(%d), fit(%f), rand(%u)\n", idx, distances[idx], rand(ra));

-  float min[1];
-  float max[1];
-  min[0] = INT_MAX;
-  max[0] = 0.0;
-  calc_min_max(min, max, distances, chromosome_count);
+  // No need to calculate survivor list with all kernels. We use the first kernel to do it.
+  if (0 == idx) {
+    float min[1];
+    float max[1];
+    min[0] = INT_MAX;
+    max[0] = 0.0;
+    calc_min_max(min, max, distances, chromosome_count);

-  // Calculate surviors indice.
-  float threshold = min[0] + (max[0] - min[0]) / 2;
-  if (idx == 0) printf("[Thresholde] (%f) \n", threshold);
-  for (int i = 0; i < chromosome_count; i++) {
-    int live = false;
-    if (distances[i] <= threshold) {
-      live = true;
+    // Calculate surviors indice.
+    float threshold = min[0] + (max[0] - min[0]) / 2;
+    if (idx == 0) printf("[Thresholde] (%f) \n", threshold);
+    for (int i = 0; i < chromosome_count; i++) {
+      int live = false;
+      if (distances[i] <= threshold) {
+        live = true;
+      }
+      survivors[i] = live;
     }
-    survivors[i] = live;
+  }
+  // Barrier for survivor list.
+  barrier(CLK_GLOBAL_MEM_FENCE);
+
+  if (!survivors[idx]) {
+      // Only dead chromosome needs to reproduce it self and to calculate its fitness.
+      reproduce(idx, chromosome_size, chromosome_count, chromosomes, survivors,
+                prob_crossover, ra);
+      calc_fitness(idx, points, chromosomes, distances, chromosome_size, chromosome_count);
   }

-  reproduce(idx, chromosome_size, chromosome_count, chromosomes, survivors,
-            prob_crossover, ra);
-
-  calc_fitness(idx, points, chromosomes, distances, chromosome_size, chromosome_count);
   // Barrier for the calculation of all chromosomes fitness.
   printf("[AfterReproduce&Crossover] idx(%d), fit(%f) \n", idx, distances[idx]);
   // TBD.


Update header

Update header

git-svn-id: 4403cc1077de9de61ebbb06aa07b0a825c555f62@6890 dc4e9af1-7f46-4ead-bba6-71afc04862de

--- code/src/turbine/turbine.h
+++ code/src/turbine/turbine.h
@@ -28,8 +28,7 @@
 #include <tcl.h>

 #include <version.h>
-
-#include "src/turbine/turbine-defs.h"
+#include <turbine-defs.h>

 typedef enum
 {


SDK-598 make format consistent

SDK-598 make format consistent

--- Branch-SDK/Branch-SDK/NSError+Branch.h
+++ Branch-SDK/Branch-SDK/NSError+Branch.h
@@ -29,7 +29,7 @@
     BNCSpotlightIdentifierError     = 1013,
     BNCSpotlightPublicIndexError    = 1014,
     BNCTrackingDisabledError        = 1015,
-    BNCGeneralError = 1016, // General Branch SDK Error
+    BNCGeneralError                 = 1016, // General Branch SDK Error
     BNCHighestError
 };


extend JIT code size

extend JIT code size

--- iv/aero/jit.h
+++ iv/aero/jit.h
@@ -85,7 +85,7 @@
   static const int kASCII = kCharSize == 1;

   explicit JIT(const Code& code)
-    : Xbyak::CodeGenerator(8192),
+    : Xbyak::CodeGenerator(8192 * 4),
       code_(code),
       first_instr_(code.bytes().data()),
       targets_(),
@@ -299,21 +299,25 @@
     EmitQuickCheck();

     L("AERO_ENTER");
-    // initialize sp_ to 0
-    mov(sp_, 0);
-
-    // initialize captures
-    mov(dword[captures_], cpd_);
-    lea(r10, ptr[captures_ + kIntSize]);
-    mov(r11, size - 1);
-    test(r11, r11);
-    jz(".LOOP_END");
-    L(".LOOP_START");
-    mov(dword[r10], kUndefined);
-    add(r10, kIntSize);
-    sub(r11, 1);
-    jnz(".LOOP_START");
-    L(".LOOP_END");
+    {
+      inLocalLabel();
+      // initialize sp_ to 0
+      mov(sp_, 0);
+
+      // initialize captures
+      mov(dword[captures_], cpd_);
+      lea(r10, ptr[captures_ + kIntSize]);
+      mov(r11, size - 1);
+      test(r11, r11);
+      jz(".LOOP_END");
+      L(".LOOP_START");
+      mov(dword[r10], kUndefined);
+      add(r10, kIntSize);
+      sub(r11, 1);
+      jnz(".LOOP_START");
+      L(".LOOP_END");
+      outLocalLabel();
+    }
   }

   void EmitEpilogue() {


Cleanup

Cleanup

--- src/netinet/sctp_pcb.c
+++ src/netinet/sctp_pcb.c
@@ -34,7 +34,7 @@

 #if defined(__FreeBSD__) && !defined(__Userspace__)
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 363275 2020-07-17 15:09:49Z tuexen $");
+__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 363309 2020-07-18 13:10:02Z tuexen $");
 #endif

 #include <netinet/sctp_os.h>
@@ -4143,9 +4143,6 @@
 	 */
 	if (from != SCTP_CALLED_FROM_INPKILL_TIMER) {
 		(void)SCTP_OS_TIMER_STOP_DRAIN(&inp->sctp_ep.signature_change.timer);
-	} else {
-		/* Probably un-needed */
-		(void)SCTP_OS_TIMER_STOP(&inp->sctp_ep.signature_change.timer);
 	}

 #ifdef SCTP_LOG_CLOSING


Support passing CDataStream as key into CDBWrapper/CDBBatch/CDBIterator

This allow to pre-serialize keys in advance and pass the serialized form
into these classes.

--- src/dbwrapper.h
+++ src/dbwrapper.h
@@ -77,7 +77,14 @@
     {
         ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
         ssKey << key;
-        leveldb::Slice slKey(ssKey.data(), ssKey.size());
+        Write(ssKey, value);
+        ssKey.clear();
+    }
+
+    template <typename V>
+    void Write(const CDataStream& _ssKey, const V& value)
+    {
+        leveldb::Slice slKey(_ssKey.data(), _ssKey.size());

         ssValue.reserve(DBWRAPPER_PREALLOC_VALUE_SIZE);
         ssValue << value;
@@ -91,7 +98,6 @@
         // - byte[]: value
         // The formula below assumes the key and value are both less than 16k.
         size_estimate += 3 + (slKey.size() > 127) + slKey.size() + (slValue.size() > 127) + slValue.size();
-        ssKey.clear();
         ssValue.clear();
     }

@@ -100,7 +106,12 @@
     {
         ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
         ssKey << key;
-        leveldb::Slice slKey(ssKey.data(), ssKey.size());
+        Erase(ssKey);
+        ssKey.clear();
+    }
+
+    void Erase(const CDataStream& _ssKey) {
+        leveldb::Slice slKey(_ssKey.data(), _ssKey.size());

         batch.Delete(slKey);
         // - byte: header
@@ -108,7 +119,6 @@
         // - byte[]: key
         // The formula below assumes the key is less than 16kB.
         size_estimate += 2 + (slKey.size() > 127) + slKey.size();
-        ssKey.clear();
     }

     size_t SizeEstimate() const { return size_estimate; }
@@ -138,6 +148,10 @@
         CDataStream ssKey(SER_DISK, CLIENT_VERSION);
         ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
         ssKey << key;
+        Seek(ssKey);
+    }
+
+    void Seek(const CDataStream& ssKey) {
         leveldb::Slice slKey(ssKey.data(), ssKey.size());
         piter->Seek(slKey);
     }
@@ -231,6 +245,11 @@
         CDataStream ssKey(SER_DISK, CLIENT_VERSION);
         ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
         ssKey << key;
+        return ReadDataStream(ssKey, ssValue);
+    }
+
+    bool ReadDataStream(const CDataStream& ssKey, CDataStream& ssValue) const
+    {
         leveldb::Slice slKey(ssKey.data(), ssKey.size());

         std::string strValue;
@@ -250,8 +269,17 @@
     template <typename K, typename V>
     bool Read(const K& key, V& value) const
     {
+        CDataStream ssKey(SER_DISK, CLIENT_VERSION);
+        ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
+        ssKey << key;
+        return Read(ssKey, value);
+    }
+
+    template <typename V>
+    bool Read(const CDataStream& ssKey, V& value) const
+    {
         CDataStream ssValue(SER_DISK, CLIENT_VERSION);
-        if (!ReadDataStream(key, ssValue)) {
+        if (!ReadDataStream(ssKey, ssValue)) {
             return false;
         }

@@ -277,7 +305,12 @@
         CDataStream ssKey(SER_DISK, CLIENT_VERSION);
         ssKey.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
         ssKey << key;
-        leveldb::Slice slKey(ssKey.data(), ssKey.size());
+        return Exists(ssKey);
+    }
+
+    bool Exists(const CDataStream& key) const
+    {
+        leveldb::Slice slKey(key.data(), key.size());

         std::string strValue;
         leveldb::Status status = pdb->Get(readoptions, slKey, &strValue);


Re-introduce a shared pointer class in mbed OS

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

--- platform/SharedPtr.h
+++ platform/SharedPtr.h
@@ -0,0 +1,215 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2006-2018 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __SHAREDPTR_H__
+#define __SHAREDPTR_H__
+
+#include <stdlib.h>
+
+#include <stdint.h>
+#include <stddef.h>
+
+/** Shared pointer class.
+  *
+  * Similar to std::shared_ptr in C++11.
+  *
+  * Usage: SharedPtr<class> POINTER(new class())
+  *
+  * When POINTER is passed around by value the copy constructor and
+  * destructor counts the number of references to the original object.
+  * If the counter reaches zero, delete is called on the object pointed to.
+  *
+  * To avoid loops, "weak" references should be used by calling the original
+  * pointer directly through POINTER.get().
+  */
+
+template <class T>
+class SharedPtr {
+public:
+    /**
+     * @brief Create empty SharedPtr not pointing to anything.
+     * @details Used for variable declaration.
+     */
+    SharedPtr(): pointer(NULL), counter(NULL) {
+    }
+
+    /**
+     * @brief Create new SharedPtr
+     * @param _pointer Pointer to take control over
+     */
+    SharedPtr(T* _pointer): pointer(_pointer) {
+        // allocate counter on the heap so it can be shared
+        counter = (uint32_t*) malloc(sizeof(uint32_t));
+        *counter = 1;
+    }
+
+    /**
+     * @brief Destructor.
+     * @details Decrement reference counter and delete object if no longer pointed to.
+     */
+    ~SharedPtr() {
+        decrementCounter();
+    }
+
+    /**
+     * @brief Copy constructor.
+     * @details Create new SharePointer from other SharedPtr by
+     *          copying pointer to original object and pointer to counter.
+     * @param source Object being copied from.
+     */
+    SharedPtr(const SharedPtr& source): pointer(source.pointer), counter(source.counter) {
+        // increment reference counter
+        if (counter) {
+            (*counter)++;
+        }
+    }
+
+    /**
+     * @brief Assignment operator.
+     * @details Cleanup previous reference and assign new pointer and counter.
+     * @param source Object being assigned from.
+     * @return Object being assigned.
+     */
+    SharedPtr operator=(const SharedPtr& source) {
+        if (this != &source) {
+            // clean up by decrementing counter
+            decrementCounter();
+
+            // assign new values
+            pointer = source.get();
+            counter = source.getCounter();
+
+            // increment new counter
+            if (counter) {
+                (*counter)++;
+            }
+        }
+
+        return *this;
+    }
+
+    /**
+     * @brief Raw pointer accessor.
+     * @details Get raw pointer to object pointed to.
+     * @return Pointer.
+     */
+    T* get() const {
+        return pointer;
+    }
+
+    /**
+     * @brief Reference count accessor.
+     * @return Reference count.
+     */
+    uint32_t use_count() const {
+        if (counter) {
+            return *counter;
+        } else {
+            return 0;
+        }
+    }
+
+    /**
+     * @brief Dereference object operator.
+     * @details Override to return the object pointed to.
+     */
+    T& operator*() const {
+        return *pointer;
+    }
+
+    /**
+     * @brief Dereference object member operator.
+     * @details Override to return return member in object pointed to.
+     */
+    T* operator->() const {
+        return pointer;
+    }
+
+    /**
+     * @brief Boolean conversion operator.
+     * @return Whether or not the pointer is NULL.
+     */
+    operator bool() const {
+        return (pointer != 0);
+    }
+
+private:
+    /**
+     * @brief Get pointer to reference counter.
+     * @return Pointer to reference counter.
+     */
+    uint32_t* getCounter() const {
+        return counter;
+    }
+
+    /**
+     * @brief Decrement reference counter.
+     * @details If count reaches zero, free counter and delete object pointed to.
+     */
+    void decrementCounter() {
+        if (counter) {
+            if (*counter == 1) {
+                free(counter);
+                delete pointer;
+            } else {
+                (*counter)--;
+            }
+        }
+    }
+
+private:
+    // pointer to shared object
+    T* pointer;
+
+    // pointer to shared reference counter
+    uint32_t* counter;
+};
+
+/** Non-member relational operators.
+  */
+template <class T, class U>
+bool operator== (const SharedPtr<T>& lhs, const SharedPtr<U>& rhs) {
+    return (lhs.get() == rhs.get());
+}
+
+template <class T, typename U>
+bool operator== (const SharedPtr<T>& lhs, U rhs) {
+    return (lhs.get() == (T*) rhs);
+}
+
+template <class T, typename U>
+bool operator== (U lhs, const SharedPtr<T>& rhs) {
+    return ((T*) lhs == rhs.get());
+}
+
+/** Non-member relational operators.
+  */
+template <class T, class U>
+bool operator!= (const SharedPtr<T>& lhs, const SharedPtr<U>& rhs) {
+    return (lhs.get() != rhs.get());
+}
+
+template <class T, typename U>
+bool operator!= (const SharedPtr<T>& lhs, U rhs) {
+    return (lhs.get() != (T*) rhs);
+}
+
+template <class T, typename U>
+bool operator!= (U lhs, const SharedPtr<T>& rhs) {
+    return ((T*) lhs != rhs.get());
+}
+
+#endif // __SHAREDPTR_H__


initialize ptr

initialize ptr

--- ninja.h
+++ ninja.h
@@ -18,7 +18,7 @@

 struct Edge;
 struct Node {
-  Node(FileStat* file) : file_(file), dirty_(false) {}
+  Node(FileStat* file) : file_(file), dirty_(false), in_edge_(NULL) {}

   bool dirty() const { return dirty_; }
   void MarkDirty();


Revert the pseudoarticle artno magic, it was evil and broke regular Revert the pseudoarticle artno magic, it was evil and broke regular HEAD/LAST/ARTICLE/BODY commands.

--- nntpd.c
+++ nntpd.c
@@ -480,7 +480,6 @@
     char *localmsgid = NULL;
     char s[PATH_MAX + 1];	/* FIXME */

-    if (!*artno && !arg) *artno=1; arg="1";
     f = fopenart(group, arg, artno);
     if (!f) {
 	if (arg && *arg != '<' && !group)


Remove unnecessary label

Remove unnecessary label

--- noice.c
+++ noice.c
@@ -549,7 +549,6 @@
 	oldpath = NULL;

 	for (;;) {
-redraw:
 		nlines = MIN(LINES - 4, n);

 		/* Clean screen */
@@ -661,7 +660,7 @@
 				spawn(bin, newpath, NULL);
 				initcurses();
 				free(newpath);
-				goto redraw;
+				continue;
 			default:
 				printmsg("Unsupported file");
 				goto nochange;


Add '*' suffix to executables

Add '*' suffix to executables

--- noice.c
+++ noice.c
@@ -349,6 +349,9 @@
 	} else if (S_ISLNK(ent->mode)) {
 		cm = '@';
 		maxlen--;
+	} else if (ent->mode & S_IXUSR) {
+		cm = '*';
+		maxlen--;
 	}

 	/* No text wrapping in entries */


added some comments to pkg/mdsio/MDSIO_OPTIONS.h

--- pkg/mdsio/MDSIO_OPTIONS.h
+++ pkg/mdsio/MDSIO_OPTIONS.h
@@ -30,13 +30,17 @@
 C   MISSING_TILE_IO is defined, the input and output
 C   files do not include the missing tiles.  Therefore
 C   the 2-D dimension of input and output files is:
-C   #if defined(ALLOW_EXCH2) && !defined(MISSING_TILE_IO)
-C    x_size = exch2_domain_nxt * sNx = exch2_domain_nxt*exch2_tnx
-C    y_size = exch2_domain_nyt * sNy = exch2_domain_nyt*exch2_tny
-C   #else
-C    x_size = Nx = sNx * nSx * nPx
-C    y_size = Ny = sNy * nSy * nPy
-C   #endif
+C    #if defined(ALLOW_EXCH2) && !defined(MISSING_TILE_IO)
+C     x_size = exch2_domain_nxt * sNx = exch2_domain_nxt*exch2_tnx
+C     y_size = exch2_domain_nyt * sNy = exch2_domain_nyt*exch2_tny
+C    #else
+C     x_size = Nx = sNx * nSx * nPx
+C     y_size = Ny = sNy * nSy * nPy
+C    #endif-
+C   Notes:
+C    1) Pickup files are not compatible between the two formats.
+C    2) Defining MISSING_TILE_IO with no missing tiles is
+C       equivalent to the old, tile-dependent I/O format.
 #undef MISSING_TILE_IO

 #endif /* ALLOW_MDSIO */


remove tabs

remove tabs

--- pkg/streamice/STREAMICE.h
+++ pkg/streamice/STREAMICE.h
@@ -43,7 +43,6 @@
       _RL streamice_addl_backstress
       _RL streamice_smooth_gl_width
       _RL streamice_adot_uniform
-

 C     parms for parameterized initial thickness
 C     SHELF_MAX_DRAFT: max thickness of ice in m
@@ -216,7 +215,7 @@

 C     EXPLANATION OF MASKS

-C     STREAMICE_hmask           VALUES	1=ice-covered cell
+C     STREAMICE_hmask           VALUES  1=ice-covered cell
 C                                       2=partially ice-covered cell (no dynamics)
 C                                       0=ice-free cell (for now, it means the cell
 C                                                           is treated as an open-ocean cell
@@ -315,11 +314,11 @@

 #ifdef STREAMICE_STRESS_BOUNDARY_CONTROL
       COMMON /STREAMICE_STRESS_BOUNDARY/
-     &      streamice_u_normal_pert,
+     &      streamice_u_normal_pert,
      &      streamice_v_normal_pert,
      &      streamice_u_shear_pert,
      &      streamice_v_shear_pert,
-     &      streamice_u_normal_stress,
+     &      streamice_u_normal_stress,
      &      streamice_v_normal_stress,
      &      streamice_u_shear_stress,
      &      streamice_v_shear_stress
@@ -349,7 +348,6 @@
       COMMON /STREAMICE_RLOW/
      &     R_low_si
 #endif
-

       _RL H_streamice           (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
       _RL U_streamice           (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
@@ -436,8 +434,6 @@
       _RL H_streamice_prev (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)
       _RL STREAMICE_dummy_array (1-OLx:sNx+OLx,1-OLy:sNy+OLy,nSx,nSy)

-
-
       COMMON /STREAMICE_COST_RL/
      &       cost_func1_streamice,
      &       cost_vel_streamice,
@@ -472,7 +468,6 @@
       INTEGER n_dofs_process (0:nPx*nPy-1)
 #endif

-
 #endif /* ALLOW_STREAMICE */

 CEH3 ;;; Local Variables: ***


improve the api docs

improve the api docs

svn path=/trunk/KDE/kdelibs/kate/; revision=773379

--- part/document/kateedit.h
+++ part/document/kateedit.h
@@ -51,8 +51,19 @@
     /// Returns true if text is being inserted and removed
     bool isModification() const;

-    /// Returns true if this edit is completed and should not be merged with another edit, should the opportunity arise.
+    /**
+     * Indicate that this edit is completed and should not be merged with
+     * another edit should the opportunity arise.
+     *
+     * \return true if this edit is completed
+     */
     bool isEditBoundary() const;
+
+    /**
+     * Set the status of this edit.
+     * \param boundary If the edit is complete, the value should be true,
+     * otherwise it should be false
+     */
     void setEditBoundary(bool boundary);

     /**
@@ -61,8 +72,15 @@
      */
     Kate::EditSource editSource() const;

-    bool merge(KateEditInfo* edit);
-
+    /// \internal
+    /// No real implementation
+    bool merge(KateEditInfo* edit) { return false; }
+
+    /**
+     * Returns the starting location of the text occupied by the edit region
+     * before the edit took place.
+     * \return a KTextEditor::Cursor indicating the start location of the edit
+     */
     const KTextEditor::Cursor& start() const { return m_oldRange.start(); }

     /**
@@ -76,13 +94,18 @@
      * \sa oldText()
      */
     virtual QString oldTextString(const KTextEditor::Range& range) const;
+
     /**
      * Returns the text which occupied \p range before this edit took place.
-     * \note \p range must start and end on the same line for all relevant text to be returned.
      * \sa oldText()
      */
     virtual QStringList oldText(const KTextEditor::Range& range) const;

+    /**
+     * Returns all of the text that was in place before the edit occurred.
+     * \sa oldText(const KTextEditor::Range&) const
+     * \sa oldTextString(const KTextEditor::Range&) const
+     */
     const QStringList& oldText() const;

     /**
@@ -91,19 +114,27 @@
     const KTextEditor::Range& newRange() const;

     /**
-     * Returns the text which occupied \p range before this edit took place.
-     * \note \p range must start and end on the same line for all relevant text to be returned.
-     * \sa oldText()
+     * Returns the text which occupies \p range after this edit took place.
+     *
+     * \p range must start and end on the same line for all relevant text to be returned.
+     * \sa newText()
+     * \sa newText(const KTextEditor::Range&) const
      */
     virtual QString newTextString(const KTextEditor::Range& range) const;

     /**
-     * Returns the text which occupied \p range before this edit took place.
-     * \note \p range must start and end on the same line for all relevant text to be returned.
-     * \sa oldText()
+     * Returns the text which occupies \p range after this edit took place.
+     * \sa newText()
+     * \sa newTextString(const KTextEditor::Range&) const
      */
     virtual QStringList newText(const KTextEditor::Range& range) const;

+    /**
+     * Returns the text which occupies the edit region now that the edit
+     * has taken place.
+     * \sa newText(const KTextEditor::Range&) const
+     * \sa newTextString(const KTextEditor::Range&) const
+     */
     const QStringList& newText() const;

     inline const KTextEditor::Cursor& translate() const { return m_translate; }


anv/lower_input_attachments: honor sample index parameter to subpassLoad()

According to GL_KHR_vulkan_glsl, the signature of subpassLoad() is:

gvec4 subpassLoad(gsubpassInput   subpass);
gvec4 subpassLoad(gsubpassInputMS subpass, int sample);

So the multisampled case always receives an explicit sample index that we
should use. The current implementation was ignoring this parameter
and using gl_SampleID value instead.

Fixes:
dEQP-VK.pipeline.multisample_shader_builtin.sample_id.*

Reviewed-by: Jason Ekstrand <68c46a606457643eab92053c1c05574abb26f861@jlekstrand.net>
Cc: "17.0" <59f39c0db42d4479a46b02d4d2bc11120e37bb44@lists.freedesktop.org>

--- src/intel/vulkan/anv_nir_lower_input_attachments.c
+++ src/intel/vulkan/anv_nir_lower_input_attachments.c
@@ -100,11 +100,8 @@

    if (image_dim == GLSL_SAMPLER_DIM_SUBPASS_MS) {
       tex->op = nir_texop_txf_ms;
-
-      nir_ssa_def *sample_id =
-         nir_load_system_value(&b, nir_intrinsic_load_sample_id, 0);
       tex->src[2].src_type = nir_tex_src_ms_index;
-      tex->src[2].src = nir_src_for_ssa(sample_id);
+      tex->src[2].src = load->src[1];
    }

    nir_ssa_dest_init(&tex->instr, &tex->dest, 4, 32, NULL);


Add PLATFORM_EXPORT to MediaStreamComponent::AudioSourceProviderImpl

On non-Windows, PLATFORM_EXPORT expands to a visibility attribute,
which is inherited by nested classes. On Windows, it's expanded to
a dllexport/dllimport attribute, which is not inherited.

When using Clang on Windows, MediaStreamComponent's dtor got
inlined, which destroys m_sourceProvider, whose destructor got inlined,
and tried to reference provideInput for the vtable, but failed to link
since it wasn't in the right dll. Exporting the inner class fixes this.

BUG=82385
TEST=build blink_web.dll with Clang on Windows in Release mode

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

git-svn-id: bf5cd6ccde378db821296732a091cfbcf5285fbd@176468 bbb929c8-8fbe-4397-9dbb-9b2b20218538

--- Source/platform/mediastream/MediaStreamComponent.h
+++ Source/platform/mediastream/MediaStreamComponent.h
@@ -79,7 +79,7 @@
     // AudioSourceProviderImpl wraps a WebAudioSourceProvider::provideInput()
     // calls into chromium to get a rendered audio stream.

-    class AudioSourceProviderImpl FINAL: public AudioSourceProvider {
+    class PLATFORM_EXPORT AudioSourceProviderImpl FINAL: public AudioSourceProvider {
     public:
         AudioSourceProviderImpl()
             : m_webAudioSourceProvider(0)


Fixed null program name when no parameters have been issued.

--- power_gadget.c
+++ power_gadget.c
@@ -240,8 +240,6 @@
     int             opt;
     uint64_t    delay_ms_temp = 1000;

-    progname = argv[0];
-
     while ((opt = getopt(argc, argv, "e:d:")) != -1) {
         switch (opt) {
         case 'e':
@@ -284,6 +282,8 @@
     int i = 0;
     int ret = 0;

+    progname = argv[0];
+
     /* Clean up if we're told to exit */
     signal(SIGINT, sigint_handler);


Fix casting.

Fix casting.

MFC after:	3 days

--- sbin/hastctl/hastctl.c
+++ sbin/hastctl/hastctl.c
@@ -342,15 +342,15 @@
 		    (intmax_t)nv_get_uint64(nv, "dirty%u", ii));
 		printf("  statistics:\n");
 		printf("    reads: %ju\n",
-		    (uint64_t)nv_get_uint64(nv, "stat_read%u", ii));
+		    (uintmax_t)nv_get_uint64(nv, "stat_read%u", ii));
 		printf("    writes: %ju\n",
-		    (uint64_t)nv_get_uint64(nv, "stat_write%u", ii));
+		    (uintmax_t)nv_get_uint64(nv, "stat_write%u", ii));
 		printf("    deletes: %ju\n",
-		    (uint64_t)nv_get_uint64(nv, "stat_delete%u", ii));
+		    (uintmax_t)nv_get_uint64(nv, "stat_delete%u", ii));
 		printf("    flushes: %ju\n",
-		    (uint64_t)nv_get_uint64(nv, "stat_flush%u", ii));
+		    (uintmax_t)nv_get_uint64(nv, "stat_flush%u", ii));
 		printf("    activemap updates: %ju\n",
-		    (uint64_t)nv_get_uint64(nv, "stat_activemap_update%u", ii));
+		    (uintmax_t)nv_get_uint64(nv, "stat_activemap_update%u", ii));
 		printf("    local errors: "
 		    "read: %ju, write: %ju, delete: %ju, flush: %ju\n",
 		    (uintmax_t)nv_get_uint64(nv, "stat_read_error%u", ii),


Catch up with variable name changes in struct lagg_protos.

--- sbin/ifconfig/iflagg.c
+++ sbin/ifconfig/iflagg.c
@@ -58,16 +58,16 @@
 static void
 setlaggproto(const char *val, int d, int s, const struct afswtch *afp)
 {
-	struct lagg_protos tpr[] = LAGG_PROTOS;
+	struct lagg_protos lpr[] = LAGG_PROTOS;
 	struct lagg_reqall ra;
 	int i;

 	bzero(&ra, sizeof(ra));
 	ra.ra_proto = LAGG_PROTO_MAX;

-	for (i = 0; i < (sizeof(tpr) / sizeof(tpr[0])); i++) {
-		if (strcmp(val, tpr[i].tpr_name) == 0) {
-			ra.ra_proto = tpr[i].tpr_proto;
+	for (i = 0; i < (sizeof(lpr) / sizeof(lpr[0])); i++) {
+		if (strcmp(val, lpr[i].lpr_name) == 0) {
+			ra.ra_proto = lpr[i].lpr_proto;
 			break;
 		}
 	}
@@ -82,7 +82,7 @@
 static void
 lagg_status(int s)
 {
-	struct lagg_protos tpr[] = LAGG_PROTOS;
+	struct lagg_protos lpr[] = LAGG_PROTOS;
 	struct lagg_reqport rp, rpbuf[LAGG_MAX_PORTS];
 	struct lagg_reqall ra;
 	const char *proto = "<unknown>";
@@ -102,9 +102,9 @@
 	ra.ra_port = rpbuf;

 	if (ioctl(s, SIOCGLAGG, &ra) == 0) {
-		for (i = 0; i < (sizeof(tpr) / sizeof(tpr[0])); i++) {
-			if (ra.ra_proto == tpr[i].tpr_proto) {
-				proto = tpr[i].tpr_name;
+		for (i = 0; i < (sizeof(lpr) / sizeof(lpr[0])); i++) {
+			if (ra.ra_proto == lpr[i].lpr_proto) {
+				proto = lpr[i].lpr_name;
 				break;
 			}
 		}
@@ -122,8 +122,8 @@

 		if (0 /* XXX */) {
 			printf("\tsupported aggregation protocols:\n");
-			for (i = 0; i < (sizeof(tpr) / sizeof(tpr[0])); i++)
-				printf("\t\tlaggproto %s\n", tpr[i].tpr_name);
+			for (i = 0; i < (sizeof(lpr) / sizeof(lpr[0])); i++)
+				printf("\t\tlaggproto %s\n", lpr[i].lpr_name);
 		}
 	} else if (isport)
 		printf("\tlagg: laggdev %s\n", rp.rp_ifname);


Cosmetic: "width * height"

Cosmetic: "width * height"

Change-Id: I567c0d95355160a9f6721f949b38e2b8b6270b7a

--- src/dec/alpha.c
+++ src/dec/alpha.c
@@ -60,7 +60,7 @@
   }

   if (method == ALPHA_NO_COMPRESSION) {
-    const size_t alpha_decoded_size = height * width;
+    const size_t alpha_decoded_size = width * height;
     ok = (alpha_data_size >= alpha_decoded_size);
     if (ok) memcpy(output, alpha_data, alpha_decoded_size);
   } else {


bump version

bump version

--- src/firmware/Version.h
+++ src/firmware/Version.h
@@ -18,6 +18,6 @@

 #pragma once

-#define SW_VERSION_MAJOR        1
-#define SW_VERSION_MINOR        6
+#define SW_VERSION_MAJOR        2
+#define SW_VERSION_MINOR        0
 #define SW_VERSION_REVISION     0


Revert of Reland "Enable loads and stores to global vars through property cell shortcuts installed into paren… (patchset #1 id:1 of https://codereview.chromium.org/1237043006/)

Reason for revert:
chromium:510738, chromium:510911

Original issue's description:
> Reland "Enable loads and stores to global vars through property cell shortcuts installed into parent script context."
>
> Committed: https://crrev.com/48584df5ed97e2cdec1b4900f783c47adc3a3d32
> Cr-Commit-Position: refs/heads/master@{#29670}

TBR=verwaest@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

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

Cr-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#29729}

--- src/flag-definitions.h
+++ src/flag-definitions.h
@@ -666,7 +666,7 @@
 DEFINE_BOOL(use_ic, true, "use inline caching")
 DEFINE_BOOL(trace_ic, false, "trace inline cache state transitions")
 DEFINE_BOOL(vector_stores, false, "use vectors for store ics")
-DEFINE_BOOL(global_var_shortcuts, true, "use ic-less global loads and stores")
+DEFINE_BOOL(global_var_shortcuts, false, "use ic-less global loads and stores")

 // macro-assembler-ia32.cc
 DEFINE_BOOL(native_code_counters, false,


Re-ship harmony spread calls and spread arrays

The issue with spread arrays which caused us to turn it off was fixed in
https://chromium.googlesource.com/v8/v8/+/24e98281

BUG=v8:3018
LOG=y

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

Cr-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#29713}

--- src/flag-definitions.h
+++ src/flag-definitions.h
@@ -200,17 +200,17 @@
   V(harmony_simd, "harmony simd")

 // Features that are complete (but still behind --harmony/es-staging flag).
-#define HARMONY_STAGED(V)                                       \
-  V(harmony_tostring, "harmony toString")                       \
-  V(harmony_concat_spreadable, "harmony isConcatSpreadable")    \
-  V(harmony_rest_parameters, "harmony rest parameters")         \
-  V(harmony_spreadcalls, "harmony spread-calls")                \
-  V(harmony_spread_arrays, "harmony spread in array literals")
+#define HARMONY_STAGED(V)                                    \
+  V(harmony_tostring, "harmony toString")                    \
+  V(harmony_concat_spreadable, "harmony isConcatSpreadable") \
+  V(harmony_rest_parameters, "harmony rest parameters")

 // Features that are shipping (turned on by default, but internal flag remains).
 #define HARMONY_SHIPPING(V)                                             \
   V(harmony_arrow_functions, "harmony arrow functions")                 \
   V(harmony_computed_property_names, "harmony computed property names") \
+  V(harmony_spreadcalls, "harmony spread-calls")                        \
+  V(harmony_spread_arrays, "harmony spread in array literals")          \
   V(harmony_unicode, "harmony unicode escapes")                         \
   V(harmony_object, "harmony Object methods")


fix silly bug in while loop

fix silly bug in while loop

--- disorderCook.c
+++ disorderCook.c
@@ -937,6 +937,7 @@
                     {
                         break;
                     }
+                    ordernode = ordernode->next;
                 }
             }


Ship arrow functions

Ship arrow functions

R=rossberg@chromium.org
LOG=Y
BUG=v8:2700

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

Cr-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#29119}

--- src/flag-definitions.h
+++ src/flag-definitions.h
@@ -199,7 +199,6 @@
 // Features that are complete (but still behind --harmony/es-staging flag).
 #define HARMONY_STAGED(V)                                      \
   V(harmony_arrays, "harmony array methods")                   \
-  V(harmony_arrow_functions, "harmony arrow functions")        \
   V(harmony_rest_parameters, "harmony rest parameters")        \
   V(harmony_spreadcalls, "harmony spread-calls")               \
   V(harmony_spread_arrays, "harmony spread in array literals") \
@@ -207,6 +206,7 @@

 // Features that are shipping (turned on by default, but internal flag remains).
 #define HARMONY_SHIPPING(V)                                                \
+  V(harmony_arrow_functions, "harmony arrow functions")                    \
   V(harmony_classes, "harmony classes (implies object literal extension)") \
   V(harmony_computed_property_names, "harmony computed property names")    \
   V(harmony_object_literals, "harmony object literal extensions")          \


buffer: on chunk_find, validate mem allocation (CID 153005)

Signed-off-by: Eduardo Silva <81f705dc2ce1a61a2621e0e4b442a9474e1d0c70@treasure-data.com>

--- src/flb_buffer_chunk.c
+++ src/flb_buffer_chunk.c
@@ -228,6 +228,11 @@
     }

     target = malloc(PATH_MAX);
+    if (!target) {
+        free(file);
+        return -1;
+    }
+
     memcpy(target, root_path, root_len);
     target_len = root_len;
     memcpy(target + target_len, file, file_len);


Delete posix_shm_dynamic.c

Delete posix_shm_dynamic.c

--- exemplier/6_interprocess/shared_memory/posix_shm_dynamic.c
+++ exemplier/6_interprocess/shared_memory/posix_shm_dynamic.c
@@ -1,110 +0,0 @@
-/**
- * Simple program demonstrating shared memory in POSIX systems.
- *
- * This is the producer process that writes to the shared memory region.
- *
- * Figure 3.17
- *
- * @author Silberschatz, Galvin, and Gagne
- * Operating System Concepts - Ninth Edition
- * Copyright John Wiley & Sons - 2013
- *
- * modifications by dheller@cse.psu.edu, 31 Jan. 2014
- * http://www.cse.psu.edu/~deh25/cmpsc473/notes/OSC/Processes/shm.html
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/shm.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <errno.h>
-
-typedef struct {
-	int *table;
-} memory_t;
-
-void display(char *prog, char *bytes, int n);
-
-void handle_fatal_error(char *msg);
-
-int main(void)
-{
-	memory_t mem;
-	mem.table = (int *)malloc(2000*sizeof(int));
-	const char *name = "/shm-example"; /* shared memory name */
-	const int SIZE = sizeof(mem); /* shared memory size */
-
-
-	int shm_fd;      /* file descriptor, from shm_open() */
-	int *shm_base;  /* base address, from mmap() */
-	int *ptr;       /* shm_base is fixed, ptr is movable */
-
-	/* create the shared memory segment as if it was a file */
-	shm_fd = shm_open(name, O_CREAT | O_RDWR, 0666);
-	if (shm_fd == -1) {
-		handle_fatal_error("prod: Shared memory failed: %s\n");
-	}
-
-	/* configure the size of the shared memory segment */
-	ftruncate(shm_fd, SIZE);
-
-	/* map the shared memory segment to the address space of the process */
-	shm_base = mmap(0, SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0);
-	if (shm_base == MAP_FAILED) {
-		handle_fatal_error("prod: Map failed: %s\n");
-	}
-
-	int pid = fork();
-
-
-	/*
-	 * Write to the mapped shared memory region.
-	 *
-	 * We increment the value of ptr after each write, but we
-	 * are ignoring the possibility that sprintf() fails.
-	 */
-	display("prod", shm_base, 64);
-	ptr = shm_base;
-	ptr += sprintf(ptr, "%s", message0);
-	ptr += sprintf(ptr, "%s", message1);
-	ptr += sprintf(ptr, "%s", message2);
-	ptr += sprintf(ptr, "%s", msg_end);
-	display("prod", shm_base, 64);
-
-	/* remove the mapped memory segment from the address space of the process */
-	if (munmap(shm_base, SIZE) == -1) {
-		handle_fatal_error("prod: Unmap failed: %s\n");
-	}
-
-	/* close the shared memory segment as if it was a file */
-	if (close(shm_fd) == -1) {
-		handle_fatal_error("prod: Close failed: %s\n");
-	}
-
-	exit(EXIT_SUCCESS);
-}
-
-/**
- * Handles a fatal error. It displays a message, then exits.
- */
-void handle_fatal_error(char *msg)
-{
-	printf(msg, strerror(errno));
-	exit(EXIT_FAILURE);
-}
-
-void display(char *prog, int *values, int n)
-{
-	int i;
-
-	printf("display: %s\n", prog);
-	for (i = 0; i < n; i++) {
-		printf("%02x%c", values[i], ((i + 1) % 16) ? ' ' : '\n');
-	}
-	printf("\n");
-}


zero out more state when disabling PWM

zero out more state when disabling PWM

--- src/nrf5/fd_pwm_nrf5.c
+++ src/nrf5/fd_pwm_nrf5.c
@@ -1,6 +1,8 @@
 #include "fd_pwm.h"

 #include "fd_nrf5.h"
+
+#include <string.h>

 typedef struct {
     uint16_t sequence[4];
@@ -9,6 +11,7 @@
 fd_pwm_module_state_t fd_pwm_module_states[4];

 void fd_pwm_initialize(const fd_pwm_module_t *modules, uint32_t module_count) {
+    memset(fd_pwm_module_states, 0, sizeof(fd_pwm_module_states));
 }

 static
@@ -56,6 +59,18 @@
     pwm->TASKS_STOP = 1;
     while (pwm->EVENTS_STOPPED == 0);
     pwm->ENABLE = PWM_ENABLE_ENABLE_Disabled << PWM_ENABLE_ENABLE_Pos;
+
+    pwm->EVENTS_STOPPED = 0;
+    pwm->EVENTS_SEQSTARTED[0] = 0;
+    pwm->EVENTS_SEQEND[0] = 0;
+    pwm->EVENTS_PWMPERIODEND = 0;
+    pwm->COUNTERTOP = 0;
+    pwm->LOOP = 0;
+    pwm->DECODER = 0;
+    pwm->SEQ[0].PTR = 0;
+    pwm->SEQ[0].CNT = 0;
+    pwm->SEQ[0].REFRESH = 0;
+    pwm->SEQ[0].ENDDELAY = 0;
 }

 void fd_pwm_channel_start(const fd_pwm_channel_t *channel, float duty_cycle) {
@@ -74,11 +89,15 @@
 bool fd_pwm_channel_is_running(const fd_pwm_channel_t *channel) {
     const fd_pwm_module_t *module = channel->module;
     NRF_PWM_Type *pwm = (NRF_PWM_Type *)module->instance;
+
     return pwm->PSEL.OUT[channel->instance] != 0xFFFFFFFF;
 }

 void fd_pwm_channel_stop(const fd_pwm_channel_t *channel) {
     const fd_pwm_module_t *module = channel->module;
     NRF_PWM_Type *pwm = (NRF_PWM_Type *)module->instance;
+    fd_pwm_module_state_t *state = fd_pwm_get_state(module->instance);
+
+    state->sequence[channel->instance] = 0;
     pwm->PSEL.OUT[channel->instance] = 0xFFFFFFFF;
 }


android/gatt: Fix check if CSRK is authenticated

--- android/gatt.c
+++ android/gatt.c
@@ -4691,9 +4691,15 @@
 		if (!(permissions & GATT_PERM_WRITE_SIGNED))
 				return ATT_ECODE_WRITE_NOT_PERM;

-		if ((permissions & GATT_PERM_WRITE_SIGNED_MITM) &&
-						sec_level < BT_SECURITY_HIGH)
+		if (permissions & GATT_PERM_WRITE_SIGNED_MITM) {
+			bool auth;
+
+			if (bt_get_csrk(&device->bdaddr, true, NULL, NULL,
+					&auth) && auth)
+				break;
+
 			return ATT_ECODE_AUTHENTICATION;
+		}
 		break;
 	case ATT_OP_READ_BY_TYPE_REQ:
 	case ATT_OP_READ_REQ:


gadgetd: examples: Extend ffs host example to handle errors.

Bulk transfer may fail each time it is scheduled
so return value should be chacked to avoid silent
live lock.

Change-Id: I577a4a487004cf99c9a8864530b871199abcd6a2
Signed-off-by: Krzysztof Opasiak <8064eda6f94b3817252b7d7649cf754592f63500@samsung.com>

--- examples/ffs-host-example.c
+++ examples/ffs-host-example.c
@@ -159,6 +159,7 @@
 int main(void)
 {
 	struct test_state state;
+	int ret;

 	if (test_init(&state))
 		return 1;
@@ -166,10 +167,24 @@
 	while (1) {
 		static unsigned char buffer[BUF_LEN];
 		int bytes;
-		libusb_bulk_transfer(state.handle, EP_BULK_IN, buffer, BUF_LEN,
-				     &bytes, 500);
-		libusb_bulk_transfer(state.handle, EP_BULK_OUT, buffer, BUF_LEN,
-				     &bytes, 500);
+		ret = libusb_bulk_transfer(state.handle, EP_BULK_IN, buffer,
+					   BUF_LEN, &bytes, 500);
+		if (ret) {
+			fprintf(stderr, "BULK_IN transfer error: %s\n",
+				libusb_error_name(ret));
+			break;
+		}
+		ret = libusb_bulk_transfer(state.handle, EP_BULK_OUT, buffer,
+					   BUF_LEN, &bytes, 500);
+		if (ret) {
+			fprintf(stderr, "BULK_OUT transfer error: %s\n",
+				libusb_error_name(ret));
+			break;
+		}
+
+		fprintf(stdout, "Transfer part completed\n");
 	}
 	test_exit(&state);
+
+	return 0;
 }


aligned lat/long order in functions

aligned lat/long order in functions

--- ortho.c
+++ ortho.c
@@ -1,5 +1,5 @@
 /**
- * $Id: ortho.c,v 1.1 2008/04/20 12:30:37 ylafon Exp $
+ * $Id: ortho.c,v 1.2 2008/04/22 12:39:19 ylafon Exp $
  *
  * (c) 2008 by Yves Lafon
  *      See COPYING file for copying and redistribution conditions.
@@ -63,11 +63,11 @@
 }

 /* return distance in nautic miles */
-double ortho_distance(longitude, latitude, wp_longitude, wp_latitude)
+double ortho_distance(latitude, longitude, wp_latitude, wp_longitude)
+     double latitude;
      double longitude;
-     double latitude;
+     double wp_latitude;
      double wp_longitude;
-     double wp_latitude;
 {
   double g,d;


FIXES

FIXES

--- core/src/path/SplinePath.h
+++ core/src/path/SplinePath.h
@@ -194,7 +194,7 @@
         return *this;
       }

-      SplinePath& add(const std::vector<glm::vec2> &newPoints)
+      SplinePath& add(const std::vector<T> &newPoints)
       {
         if (!SplinePathBase<T>::closed)
         {
@@ -204,7 +204,7 @@
           {
             SplinePathBase<T>::points.reserve(SplinePathBase<T>::points.size() + newSize);

-            for (auto &point : newPoints)
+            for (const auto &point : newPoints)
             {
               add(point);
             }
@@ -216,7 +216,7 @@
         return *this;
       }

-      SplinePath& add(const glm::vec2 &point)
+      SplinePath& add(const T &point)
       {
         if (!SplinePathBase<T>::closed && (SplinePathBase<T>::points.empty() || (point != SplinePathBase<T>::points.back())))
         {


Using tcp_ts_ticks for timestamp in syn ack.

OFP tcp layer should use tcp_ts_getticks for all the timestamp in
tcp packets. Replacing use of ofp_timer_ticks with tcp_ts_getticks
in case of syn messqage is recieved.

Signed-off-by: Nikhil Agarwal <9f0a6a282cf92289ac89d0b0d2672ea738b6959b@linaro.org>
Reviewed-by: Sorin Vultureanu <8013ba55f8675034bc2ab0d6c3a1c9650437ca36@enea.com>

--- src/ofp_tcp_syncache.c
+++ src/ofp_tcp_syncache.c
@@ -1470,7 +1470,7 @@
 		data |= md5_buffer[2] << 10;		/* more digest bits */
 		data ^= md5_buffer[3];
 		sc->sc_ts = data;
-		sc->sc_tsoff = data - ofp_timer_ticks(0);	/* after XOR */
+		sc->sc_tsoff = data - tcp_ts_getticks();	/* after XOR */
 	}

 	TCPSTAT_INC(tcps_sc_sendcookie);


Trust that GCC has `__attribute__` `visibility`:

GCC 4.8 (which we support...) does not have __has_attribute. Fixes CentOS7 builds.

--- include/cling/Interpreter/Visibility.h
+++ include/cling/Interpreter/Visibility.h
@@ -24,7 +24,7 @@
 # else
 #  define CLING_LIB_EXPORT __declspec(dllexport)
 # endif
-#elif (__has_attribute(visibility))
+#elif (__has_attribute(visibility)) || defined(__GNUC__)
 # define CLING_LIB_EXPORT __attribute__ ((visibility("default")))
 #else
 # define CLING_LIB_EXPORT


android/gatt: Minor change in get_include_data

Change service to prim so it is more readable that this is primary
service

--- android/gatt.c
+++ android/gatt.c
@@ -1200,7 +1200,7 @@
 }

 struct get_included_data {
-	struct service *service;
+	struct service *prim;
 	struct gatt_device *device;
 };

@@ -1209,7 +1209,7 @@
 	struct hal_ev_gatt_client_get_inc_service ev;
 	struct get_included_data *data = user_data;
 	struct gatt_device *device = data->device;
-	struct service *service = data->service;
+	struct service *service = data->prim;
 	bt_uuid_t uuid;

 	DBG("");
@@ -1296,7 +1296,7 @@
 		goto failed;
 	}

-	data->service = service;
+	data->prim = service;
 	data->device = device;

 	gatt_find_included(device->attrib, service->prim.range.start,


Transformed matcher helper 'ancestor_or_self' and 'descendant_or_self' to template function versions.

--- include/core/utility/ClangMatcherExt.h
+++ include/core/utility/ClangMatcherExt.h
@@ -35,9 +35,18 @@

 const internal::VariadicDynCastAllOfMatcher<Stmt, ParenExpr> parenExpr;

-#define descendant_or_self(NODE) anyOf(NODE, hasDescendant(NODE))
+//#define descendant_or_self(NODE) anyOf(NODE, hasDescendant(NODE))
+//#define ancestor_or_self(NODE) anyOf(NODE, hasAncestor(NODE))

-#define ancestor_or_self(NODE) anyOf(NODE, hasAncestor(NODE))
+template <typename T>
+inline auto ancestor_or_self(const T& node) -> decltype(anyOf(node, hasAncestor(node))) {
+  return anyOf(node, hasAncestor(node));
+}
+
+template <typename T>
+inline auto descendant_or_self(const T& node) -> decltype(anyOf(node, hasDescendant(node))) {
+  return anyOf(node, hasDescendant(node));
+}

 // TODO remove this code duplication (hasThen) once backwards compatibility is not necessary
 AST_MATCHER_P(IfStmt, hasThenStmt, internal::Matcher<Stmt>, InnerMatcher) {


android/gatt: Add register GAP Service

android/gatt: Add register GAP Service

Register GAP service with device name characteristic,
appearance and peripheral privacy flag

--- android/gatt.c
+++ android/gatt.c
@@ -3715,6 +3715,102 @@
 		error("gatt: Could not attach to server");
 }

+struct gap_srvc_handles {
+	uint16_t srvc;
+
+	/* Characteristics */
+	uint16_t dev_name;
+	uint16_t appear;
+	uint16_t priv;
+};
+
+static struct gap_srvc_handles gap_srvc_data;
+
+#define APPEARANCE_GENERIC_PHONE 0x0040
+#define PERIPHERAL_PRIVACY_DISABLE 0x00
+
+static void gap_read_cb(uint16_t handle, uint16_t offset, uint8_t att_opcode,
+					bdaddr_t *bdaddr, void *user_data)
+{
+	uint8_t pdu[ATT_DEFAULT_LE_MTU];
+	uint16_t len;
+	struct gatt_device *dev;
+
+	DBG("");
+
+	dev = find_device_by_addr(bdaddr);
+	if (!dev) {
+		error("gatt: Could not find device ?!");
+		return;
+	}
+
+	if (handle == gap_srvc_data.dev_name) {
+		const char *name = bt_get_adapter_name();
+
+		len = enc_read_resp((uint8_t *)name, strlen(name),
+							pdu, sizeof(pdu));
+		goto done;
+	}
+
+	if (handle == gap_srvc_data.appear) {
+		uint8_t val[2];
+		put_le16(APPEARANCE_GENERIC_PHONE, val);
+		len = enc_read_resp(val, sizeof(val), pdu, sizeof(pdu));
+		goto done;
+	}
+
+	if (handle == gap_srvc_data.priv) {
+		uint8_t val = PERIPHERAL_PRIVACY_DISABLE;
+		len = enc_read_resp(&val, sizeof(val), pdu, sizeof(pdu));
+		goto done;
+	}
+
+	error("gatt: Unknown handle 0x%02x", handle);
+	len = enc_error_resp(ATT_OP_READ_REQ, handle,
+					ATT_ECODE_UNLIKELY, pdu, sizeof(pdu));
+
+done:
+	g_attrib_send(dev->attrib, 0, pdu, len, NULL, NULL, NULL);
+}
+
+static void register_gap_service(void)
+{
+	bt_uuid_t uuid;
+
+	/* GAP UUID */
+	bt_uuid16_create(&uuid, 0x1800);
+	gap_srvc_data.srvc = gatt_db_add_service(gatt_db, &uuid, true, 7);
+
+	/* Device name characteristic */
+	bt_uuid16_create(&uuid, GATT_CHARAC_DEVICE_NAME);
+	gap_srvc_data.dev_name =
+			gatt_db_add_characteristic(gatt_db, gap_srvc_data.srvc,
+							&uuid, 0,
+							GATT_CHR_PROP_READ,
+							gap_read_cb, NULL,
+							NULL);
+
+	/* Appearance */
+	bt_uuid16_create(&uuid, GATT_CHARAC_APPEARANCE);
+	gap_srvc_data.appear =
+			gatt_db_add_characteristic(gatt_db, gap_srvc_data.srvc,
+							&uuid, 0,
+							GATT_CHR_PROP_READ,
+							gap_read_cb, NULL,
+							NULL);
+
+	/* Pripheral privacy flag */
+	bt_uuid16_create(&uuid, GATT_CHARAC_PERIPHERAL_PRIV_FLAG);
+	gap_srvc_data.priv =
+			gatt_db_add_characteristic(gatt_db, gap_srvc_data.srvc,
+							&uuid, 0,
+							GATT_CHR_PROP_READ,
+							gap_read_cb, NULL,
+							NULL);
+
+	gatt_db_service_set_active(gatt_db, gap_srvc_data.srvc , true);
+}
+
 static bool start_listening_io(void)
 {
 	GError *gerr = NULL;
@@ -3780,6 +3876,8 @@
 	ipc_register(hal_ipc, HAL_SERVICE_ID_GATT, cmd_handlers,
 						G_N_ELEMENTS(cmd_handlers));

+	register_gap_service();
+
 	return true;
 }


staging: comedi: addi_apci_1032: fix i_APCI1032_ReadMoreDigitalInput()

This function is the insn_bits operation for the digital input subdevice.
According to the comedi API it's supposed return the status of the inputs
in data[1]. The addi-drivers abuse the API and try to make it conform to
their own use.

Fix this function so it follows the comedi API.

Signed-off-by: H Hartley Sweeten <382ff55d8e07d1082d179e669636cd1552da4f36@visionengravers.com>
Cc: Ian Abbott <9e6ba6483b6a3e14d61f7c987e72ecb5b46122d6@mev.co.uk>
Cc: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c
+++ drivers/staging/comedi/drivers/addi-data/hwdrv_apci1032.c
@@ -204,43 +204,8 @@
 					   struct comedi_insn *insn,
 					   unsigned int *data)
 {
-	unsigned int ui_PortValue = data[0];
-	unsigned int ui_Mask = 0;
-	unsigned int ui_NoOfChannels;
-
-	ui_NoOfChannels = CR_CHAN(insn->chanspec);
-	if (data[1] == 0) {
-		*data = inl(dev->iobase + APCI1032_DI_REG);
-		switch (ui_NoOfChannels) {
-		case 2:
-			ui_Mask = 3;
-			*data = (*data >> (2 * ui_PortValue)) & ui_Mask;
-			break;
-		case 4:
-			ui_Mask = 15;
-			*data = (*data >> (4 * ui_PortValue)) & ui_Mask;
-			break;
-		case 8:
-			ui_Mask = 255;
-			*data = (*data >> (8 * ui_PortValue)) & ui_Mask;
-			break;
-		case 16:
-			ui_Mask = 65535;
-			*data = (*data >> (16 * ui_PortValue)) & ui_Mask;
-			break;
-		case 31:
-			break;
-		default:
-			/* comedi_error(dev," \nchan spec wrong\n"); */
-			return -EINVAL;	/*  "sorry channel spec wrong " */
-			break;
-		}		/* switch(ui_NoOfChannels) */
-	}			/* if(data[1]==0) */
-	else {
-		if (data[1] == 1)
-			*data = ui_InterruptStatus;
-				/* if(data[1]==1) */
-	}			/* else if(data[1]==0) */
+	data[1] = inl(dev->iobase + APCI1032_DI_REG);
+
 	return insn->n;
 }


android: Remove not needed include

android: Remove not needed include

--- android/main.c
+++ android/main.c
@@ -39,10 +39,6 @@
 #include <sys/socket.h>
 #include <sys/un.h>

-#if defined(ANDROID)
-#include <private/android_filesystem_config.h>
-#endif
-
 #include <glib.h>

 #include "log.h"


Fix #178 - HARs levitating after defeat

Fix #178 - HARs levitating after defeat

--- src/game/objects/har.c
+++ src/game/objects/har.c
@@ -385,6 +385,9 @@
                 vel.x = 0.0;
             }

+            object_set_pos(obj, pos);
+            object_set_vel(obj, vel);
+
             // prevent har from sliding after defeat
             if(h->state != STATE_DEFEAT &&
                h->health <= 0 && h->endurance <= 0 &&
@@ -403,8 +406,6 @@
                     har_finished(obj);
                 }
             }
-            object_set_pos(obj, pos);
-            object_set_vel(obj, vel);
         }
     } else {
         object_set_vel(obj, vec2f_create(vel.x, vel.y + obj->gravity));


This commit will have to be updated once merged with grins interface branch

--- src/kinetics/include/planet/atmospheric_kinetics.h
+++ src/kinetics/include/planet/atmospheric_kinetics.h
@@ -48,6 +48,7 @@
         AtmosphericKinetics() {antioch_error();return;}

         Antioch::KineticsEvaluator<CoeffType> &_neutral_reactions;
+        Antioch::ReactionSet<CoeffType>       &_neutral_reactions_set;
         Antioch::KineticsEvaluator<CoeffType> &_ionic_reactions;

         bool _ionic_coupling;
@@ -61,6 +62,7 @@
       public:
         //!
         AtmosphericKinetics(Antioch::KineticsEvaluator<CoeffType>                         &neu,
+                            Antioch::ReactionSet<CoeffType>                               &neu_set,
                             Antioch::KineticsEvaluator<CoeffType>                         &ion,
                             const AtmosphericTemperature<CoeffType,VectorCoeffType>             &temperature,
                             PhotonEvaluator<CoeffType,VectorCoeffType,MatrixCoeffType>    &photon,
@@ -92,11 +94,13 @@
   template<typename CoeffType, typename VectorCoeffType, typename MatrixCoeffType>
   inline
   AtmosphericKinetics<CoeffType,VectorCoeffType,MatrixCoeffType>::AtmosphericKinetics(Antioch::KineticsEvaluator<CoeffType>         &neu,
+                                                                      Antioch::ReactionSet<CoeffType>                               &neu_set,
                                                                       Antioch::KineticsEvaluator<CoeffType>                         &ion,
                                                                       const AtmosphericTemperature<CoeffType,VectorCoeffType>             &temperature,
                                                                       PhotonEvaluator<CoeffType,VectorCoeffType,MatrixCoeffType>    &photon,
                                                                       const AtmosphericMixture<CoeffType,VectorCoeffType,MatrixCoeffType> &composition):
    _neutral_reactions(neu),
+   _neutral_reactions_set(neu_set),
    _ionic_reactions(ion),
    _temperature(temperature),
    _photon(photon),
@@ -150,6 +154,7 @@
      VectorStateType dummy;
      dummy.resize(_composition.neutral_composition().n_species(),0.L); //everything is irreversible
      _photon.update_photon_flux(molar_concentrations, sum_concentrations, z);
+     _neutral_reactions_set.update_particle_flux_chemistry();
      _neutral_reactions.compute_mole_sources(_temperature.neutral_temperature(z),
                                              molar_concentrations,dummy,kin_rates);


in_tcp: release flb_in_tcp_config when binding fails

Signed-off-by: Takahiro YAMASHITA <8b9f03f78cb27351a99f79113f99e589b65190d5@gmail.com>

--- plugins/in_tcp/tcp.c
+++ plugins/in_tcp/tcp.c
@@ -107,6 +107,7 @@
     else {
         flb_error("[in_tcp] could not bind address %s:%s. Aborting",
                   ctx->listen, ctx->tcp_port);
+        tcp_config_destroy(ctx);
         return -1;
     }
     flb_net_socket_nonblocking(ctx->server_fd);


examples/ip_pipeline: fix CPU socket id

examples/ip_pipeline: fix CPU socket id

This patch fixes the socket-id error in ip_pipeline sample
application running over uni-processor systems.

Signed-off-by: Jasvinder Singh <97b766ecf460b59e2781d4fc0469065206870f5c@intel.com>
Acked-by: Cristian Dumitrescu <25468b8a3698eeb3c368247f8635924bb4a1ce2c@intel.com>

--- examples/ip_pipeline/init.c
+++ examples/ip_pipeline/init.c
@@ -835,6 +835,14 @@
 	}
 }

+static inline int
+app_get_cpu_socket_id(uint32_t pmd_id)
+{
+	int status = rte_eth_dev_socket_id(pmd_id);
+
+	return (status != SOCKET_ID_ANY) ? status : 0;
+}
+
 static void
 app_init_link(struct app_params *app)
 {
@@ -890,7 +898,7 @@
 				p_link->pmd_id,
 				rxq_queue_id,
 				p_rxq->size,
-				rte_eth_dev_socket_id(p_link->pmd_id),
+				app_get_cpu_socket_id(p_link->pmd_id),
 				&p_rxq->conf,
 				app->mempool[p_rxq->mempool_id]);
 			if (status < 0)
@@ -917,7 +925,7 @@
 				p_link->pmd_id,
 				txq_queue_id,
 				p_txq->size,
-				rte_eth_dev_socket_id(p_link->pmd_id),
+				app_get_cpu_socket_id(p_link->pmd_id),
 				&p_txq->conf);
 			if (status < 0)
 				rte_panic("%s (%" PRIu32 "): "
@@ -989,7 +997,7 @@
 		/* TM */
 		p_tm->sched_port_params.name = p_tm->name;
 		p_tm->sched_port_params.socket =
-			rte_eth_dev_socket_id(p_link->pmd_id);
+			app_get_cpu_socket_id(p_link->pmd_id);
 		p_tm->sched_port_params.rate =
 			(uint64_t) link_eth_params.link_speed * 1000 * 1000 / 8;


Repaired and improved the external MIDI facility to work in CsoundVST. Added a new API function, csoundPerformKsmpsAbsolute, to perform an audio output buffer with or without a score.

--- Engine/oload.c
+++ Engine/oload.c
@@ -39,6 +39,7 @@
 int csoundPerform(void *, int, char **);
 int csoundCompile(void *, int, char **);
 int csoundPerformKsmps(void *);
+int csoundPerformKsmpsAbsolute(void *);
 int csoundPerformBuffer(void *);
 void csoundCleanup(void *);
 void csoundReset(void *);
@@ -77,10 +78,10 @@
 void csoundSetInputValueCallback(void *, void (*)(void *, char *, MYFLT *));
 void csoundSetOutputValueCallback(void *, void (*)(void *, char *, MYFLT));
 void csoundScoreEvent(void *, char, MYFLT *, long);
-void csoundSetExternalMidiOpenCallback(void *, void (*)(void *));
+void csoundSetExternalMidiDeviceOpenCallback(void *, void (*)(void *));
 void csoundSetExternalMidiReadCallback(void *, int (*)(void *, unsigned char *, int));
 void csoundSetExternalMidiWriteCallback(void *, int (*)(void *, unsigned char *));
-void csoundSetExternalMidiCloseCallback(void *, void (*)(void *));
+void csoundSetExternalMidiDeviceCloseCallback(void *, void (*)(void *));
 int csoundIsExternalMidiEnabled(void *);
 void csoundSetExternalMidiEnabled(void *, int);
 void csoundSetIsGraphable(void *, int);
@@ -187,10 +188,10 @@
         csoundSetInputValueCallback,
         csoundSetOutputValueCallback,
         csoundScoreEvent,
-        csoundSetExternalMidiOpenCallback,
+        csoundSetExternalMidiDeviceOpenCallback,
         csoundSetExternalMidiReadCallback,
         csoundSetExternalMidiWriteCallback,
-        csoundSetExternalMidiCloseCallback,
+        csoundSetExternalMidiDeviceCloseCallback,
         csoundIsExternalMidiEnabled,
         csoundSetExternalMidiEnabled,
         csoundSetIsGraphable,
@@ -213,9 +214,6 @@
         csoundSetRecopenCallback,
         csoundSetRtrecordCallback,
         csoundSetRtcloseCallback,
-        /*
-         * Intrnal functions
-         */
         auxalloc,
         getstring,
         die,
@@ -267,6 +265,7 @@
         rewriteheader,
         writeheader,
         csoundPrintf,
+        csoundPerformKsmpsAbsolute,
         /*
         * Data fields.
         */


gallivm: Emit DIVPS instead of RCPPS.

gallivm: Emit DIVPS instead of RCPPS.

See comments for detailed rationale.

Thanks to Michal Krol and Zack Rusin for detecting and investigating this
in detail.

--- src/gallium/auxiliary/gallivm/lp_bld_arit.c
+++ src/gallium/auxiliary/gallivm/lp_bld_arit.c
@@ -58,14 +58,6 @@
 #include "lp_bld_pack.h"
 #include "lp_bld_arit.h"

-
-/*
- * XXX: Increasing eliminates some artifacts, but adds others, most
- * noticeably corruption in the Earth halo in Google Earth.
- */
-#define RCP_NEWTON_STEPS 0
-
-#define RSQRT_NEWTON_STEPS 0

 #define EXP_POLY_DEGREE 3

@@ -1266,6 +1258,11 @@
  *
  *   x_{i+1} = x_i * (2 - a * x_i)
  *
+ * XXX: Unfortunately this won't give IEEE-754 conformant results for 0 or
+ * +/-Inf, giving NaN instead.  Certain applications rely on this behavior,
+ * such as Google Earth, which does RCP(RSQRT(0.0) when drawing the Earth's
+ * halo. It would be necessary to clamp the argument to prevent this.
+ *
  * See also:
  * - http://en.wikipedia.org/wiki/Division_(digital)#Newton.E2.80.93Raphson_division
  * - http://softwarecommunity.intel.com/articles/eng/1818.htm
@@ -1306,13 +1303,27 @@
    if(LLVMIsConstant(a))
       return LLVMConstFDiv(bld->one, a);

-   if(util_cpu_caps.has_sse && type.width == 32 && type.length == 4) {
+   /*
+    * We don't use RCPPS because:
+    * - it only has 10bits of precision
+    * - it doesn't even get the reciprocate of 1.0 exactly
+    * - doing Newton-Rapshon steps yields wrong (NaN) values for 0.0 or Inf
+    * - for recent processors the benefit over DIVPS is marginal, a case
+    *   depedent
+    *
+    * We could still use it on certain processors if benchmarks show that the
+    * RCPPS plus necessary workarounds are still preferrable to DIVPS; or for
+    * particular uses that require less workarounds.
+    */
+
+   if (FALSE && util_cpu_caps.has_sse && type.width == 32 && type.length == 4) {
+      const unsigned num_iterations = 0;
       LLVMValueRef res;
       unsigned i;

       res = lp_build_intrinsic_unary(bld->builder, "llvm.x86.sse.rcp.ps", bld->vec_type, a);

-      for (i = 0; i < RCP_NEWTON_STEPS; ++i) {
+      for (i = 0; i < num_iterations; ++i) {
          res = lp_build_rcp_refine(bld, a, res);
       }

@@ -1363,13 +1374,14 @@

    assert(type.floating);

-   if(util_cpu_caps.has_sse && type.width == 32 && type.length == 4) {
+   if (util_cpu_caps.has_sse && type.width == 32 && type.length == 4) {
+      const unsigned num_iterations = 0;
       LLVMValueRef res;
       unsigned i;

       res = lp_build_intrinsic_unary(bld->builder, "llvm.x86.sse.rsqrt.ps", bld->vec_type, a);

-      for (i = 0; i < RSQRT_NEWTON_STEPS; ++i) {
+      for (i = 0; i < num_iterations; ++i) {
          res = lp_build_rsqrt_refine(bld, a, res);
       }


Minor fixes

Minor fixes

--- Engine/otran.c
+++ Engine/otran.c
@@ -288,7 +288,7 @@
                   err++; continue;
                 }
                 if (isdigit(*c)) {      /* numbered instrument */
-                  if (!sscanf(c, "%ld", &n) || n <= 0) {
+                  if (!sscanf(c, "%ld", &n) || n < 0) {
                     synterr(csound, Str("illegal instr number"));
                     err++; continue;
                   }
@@ -876,7 +876,6 @@
         return (fp - csound->pool);                 /*    return w. index   */
     }
     if (++ST(poolcount) > ST(nconsts)) {
-      /* csoundDie(csound, "flconst pool is full"); */
       int indx = fp - csound->pool;
       ST(nconsts) += NCONSTS;
       if(csound->oparms->msglevel)
@@ -970,6 +969,7 @@
       csound->Die(csound, Str("gblnamset(): memory allocation failure"));
     p->namep = s;                               /* else record newname  */
     p->nxt = ST(gblNames)[h];
+    ST(gblNames)[h] = p;
     if (*s == '#')  s++;
     if (*s == 'g')  s++;
     switch ((int) *s) {                         /*   and its type-count */
@@ -997,6 +997,7 @@
       csound->Die(csound, Str("lclnamset(): memory allocation failure"));
     p->namep = s;                               /* else record newname  */
     p->nxt = ST(lclNames)[h];
+    ST(lclNames)[h] = p;
     if (*s == '#')  s++;
     switch (*s) {                               /*   and its type-count */
       case 'd': p->type = DTYPE; p->count = ST(lclnxtdcnt)++; break;


close socket connection after sending a response to avoid FD leakage

--- src/dyn_stats.c
+++ src/dyn_stats.c
@@ -878,6 +878,8 @@
        close(sd);
        return DN_ERROR;
     }
+
+    close(sd);

     return DN_OK;
 }


score file: fixed EOF without newline

score file: fixed EOF without newline

--- Engine/sread.c
+++ Engine/sread.c
@@ -319,7 +319,7 @@
     c = corfile_getc(ST(str)->cf);
     if (c == EOF) {
       if (ST(str) == &ST(inputs)[0]) {
-        corfile_ungetc(ST(str)->cf);      /* to ensure repeated EOF */
+        corfile_putc('\n', ST(str)->cf);  /* to ensure repeated EOF */
         return EOF;
       }
       if (ST(str)->mac == 0) {


gio: use older interface to enumerate files

--- common/fmplayer_file_gio.c
+++ common/fmplayer_file_gio.c
@@ -79,7 +79,8 @@
     goto err;
   }
   direnum = g_file_enumerate_children(dir,
-                                      G_FILE_ATTRIBUTE_STANDARD_NAME,
+                                      G_FILE_ATTRIBUTE_STANDARD_NAME ","
+                                      G_FILE_ATTRIBUTE_STANDARD_TARGET_URI,
                                       G_FILE_QUERY_INFO_NONE,
                                       0, 0);
   if (!direnum) {
@@ -87,24 +88,24 @@
     goto err;
   }
   for (;;) {
-    GFileInfo *info;
-    GFile *pcmfile;
-    if (!g_file_enumerator_iterate(direnum, &info, &pcmfile, 0, 0)) {
+    GFileInfo *info = g_file_enumerator_next_file(direnum, 0, 0);
+    if (!info) {
       if (error) *error = FMPLAYER_FILE_ERR_FILEIO;
       goto err;
     }
-    if (!info || !pcmfile) {
-      if (error) *error = FMPLAYER_FILE_ERR_FILEIO;
-      goto err;
-    }
+    GFile *pcmfile = g_file_enumerator_get_child(direnum, info);
     if (!strcasecmp(g_file_info_get_name(info), pcmname)) {
       void *buf = fileread(pcmfile, maxsize, filesize, error);
+      g_object_unref(G_OBJECT(pcmfile));
+      g_object_unref(G_OBJECT(info));
       g_object_unref(G_OBJECT(direnum));
       g_object_unref(G_OBJECT(dir));
       g_object_unref(G_OBJECT(file));
       free(pcmnamebuf);
       return buf;
     }
+    g_object_unref(G_OBJECT(pcmfile));
+    g_object_unref(G_OBJECT(info));
   }
   if (error) *error = FMPLAYER_FILE_ERR_FILEIO;
 err:


not sure

not sure

git-svn-id: 9e9401559e51101c165cdce4d49b411eb20436ed@1296 3d70eeeb-363e-0410-a505-8a46323a89f2

--- src/echo/echo.h
+++ src/echo/echo.h
@@ -382,7 +382,6 @@
 extern echoObject *echoObjectNix(echoObject *obj);

 /* model.c ---------------------------------------- */
-
 extern echoObject *echoRoughSphereNew(echoScene *scene, int theRes, int phiRes,
 				      echoPos_t *matx);


minor cleanups

minor cleanups

--- src/lib-storage/index/maildir/maildir-sync-index.c
+++ src/lib-storage/index/maildir/maildir-sync-index.c
@@ -254,7 +254,7 @@
 	bool expunged, full_rescan = FALSE;

 	i_assert(!mbox->syncing_commit);
-	i_assert(maildir_uidlist_is_locked(ctx->mbox->uidlist));
+	i_assert(maildir_uidlist_is_locked(mbox->uidlist));

 	hdr = mail_index_get_header(view);
 	uid_validity = maildir_uidlist_get_uid_validity(mbox->uidlist);
@@ -348,7 +348,7 @@
 		}

 		if (expunged) {
-			if (maildir_file_do(ctx->mbox, ctx->uid,
+			if (maildir_file_do(mbox, ctx->uid,
 					    maildir_expunge, ctx) >= 0) {
 				/* successful expunge */
 				mail_index_expunge(trans, ctx->seq);
@@ -385,7 +385,7 @@

 		if (index_sync_changes_have(ctx->sync_changes)) {
 			/* apply flag changes to maildir */
-			if (maildir_file_do(ctx->mbox, ctx->uid,
+			if (maildir_file_do(mbox, ctx->uid,
 					    maildir_sync_flags, ctx) < 0)
 				ctx->flags |= MAIL_INDEX_MAIL_FLAG_DIRTY;
 			if ((++changes % MAILDIR_SLOW_MOVE_COUNT) == 0)
@@ -458,8 +458,8 @@
 	}

 	if (ctx->changed)
-		ctx->mbox->maildir_hdr.cur_mtime = time(NULL);
-	maildir_index_update_ext_header(ctx->mbox, trans);
+		mbox->maildir_hdr.cur_mtime = time(NULL);
+	maildir_index_update_ext_header(mbox, trans);

 	if (hdr->uid_validity == 0) {
 		/* get the initial uidvalidity */


fixing searching

fixing searching

--- pager.c
+++ pager.c
@@ -1994,8 +1994,8 @@
 						cursor_row = nrows - desc.title_rows;
 						found = true;

-						if (cursor_row - first_row > maxy - scrdesc.fix_rows_rows + desc.title_rows - 3)
-							first_row += maxy - scrdesc.fix_rows_rows + desc.title_rows - 3;
+						if (cursor_row - first_row > maxy - scrdesc.fix_rows_rows - 1)
+							first_row += cursor_row - maxy - scrdesc.fix_rows_rows - 1;

 						max_first_row = desc.last_row - maxy + 2 - desc.title_rows;
 						if (max_first_row < 0)
@@ -2015,9 +2015,9 @@
 						refresh();

 						c2 = getch();
-						refresh_scr = true;
 					}

+					refresh_scr = true;
 				}
 				break;


Remove unused variable

Remove unused variable

--- panel.c
+++ panel.c
@@ -19,7 +19,6 @@
 /* do not change this line - Makefile's 'tar' target depends on it */
 #define VERSION "1.0"

-static gchar *cfgfile = NULL;
 static gchar version[] = VERSION;
 int distance=0, distancefrom=DISTANCEFROM_TOP;
 int expand=1 , padding=0;


Implement parsing for #t and #f

Implement parsing for #t and #f

--- parse.c
+++ parse.c
@@ -14,6 +14,7 @@
 static const char *err_expected_rparen = "expected character ')'";
 static const char *err_unexpected_rparen = "unexpected character ')'";
 static const char *err_improper_dot = "improperly placed dot";
+static const char *err_invalid_literal = "invalid literal beginning with '#'";

 // Returns the number of leading whitespace characters in text.
 static int skip_whitespace(const char *text) {
@@ -104,6 +105,18 @@
 	case '.':
 		result.err_msg = err_improper_dot;
 		break;
+	case '#':
+		s++;
+		if (*s == 't') {
+			s++;
+			result.expr = new_boolean(true);
+		} else if (*s == 'f') {
+			s++;
+			result.expr = new_boolean(false);
+		} else {
+			result.err_msg = err_invalid_literal;
+		}
+		break;
 	default:;
 		int len = skip_symbol(s);
 		char *name = malloc(len + 1);


* add a missing vput() if VOP_SETATTR() fails.

ok tedu pedro millert

--- kern/tty_pty.c
+++ kern/tty_pty.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: tty_pty.c,v 1.25 2004/07/22 06:13:08 tedu Exp $	*/
+/*	$OpenBSD: tty_pty.c,v 1.26 2004/12/07 03:42:45 pat Exp $	*/
 /*	$NetBSD: tty_pty.c,v 1.33.4.1 1996/06/02 09:08:11 mrg Exp $	*/

 /*
@@ -1196,8 +1196,10 @@
 			cred = crget();
 			error = VOP_SETATTR(snd.ni_vp, &vattr, cred, p);
 			crfree(cred);
-			if (error)
+			if (error) {
+				vput(snd.ni_vp);
 				goto bad;
+			}
 		}
 		VOP_UNLOCK(snd.ni_vp, 0, p);
 		if (snd.ni_vp->v_usecount > 1 ||


chose proper mountpoint in making decision on upgrading bwrte() to async op. this fixes in particular panics w/ softdep ffs mounted at a dir in an async mounted (mfs) file system and also a few other evil scenarios. this also matches a netbsd change 1.76 . tested by many on many archs; pedro@ ok

--- kern/vfs_bio.c
+++ kern/vfs_bio.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: vfs_bio.c,v 1.81 2006/08/09 12:00:03 pedro Exp $	*/
+/*	$OpenBSD: vfs_bio.c,v 1.82 2006/08/17 13:55:57 mickey Exp $	*/
 /*	$NetBSD: vfs_bio.c,v 1.44 1996/06/11 11:15:36 pk Exp $	*/

 /*-
@@ -312,6 +312,12 @@
 	struct vnode *vp;
 	struct mount *mp;

+	vp = bp->b_vp;
+	if (vp != NULL)
+		mp = vp->v_type == VBLK? vp->v_specmountpoint : vp->v_mount;
+	else
+		mp = NULL;
+
 	/*
 	 * Remember buffer type, to switch on it later.  If the write was
 	 * synchronous, but the file system was mounted with MNT_ASYNC,
@@ -320,8 +326,7 @@
 	 * to async, not sync writes (which is safe, but ugly).
 	 */
 	async = ISSET(bp->b_flags, B_ASYNC);
-	if (!async && bp->b_vp && bp->b_vp->v_mount &&
-	    ISSET(bp->b_vp->v_mount->mnt_flag, MNT_ASYNC)) {
+	if (!async && mp && ISSET(mp->mnt_flag, MNT_ASYNC)) {
 		bdwrite(bp);
 		return (0);
 	}
@@ -331,17 +336,11 @@
 	 * Writes to block devices are charged to their associated
 	 * filesystem (if any).
 	 */
-	if ((vp = bp->b_vp) != NULL) {
-		if (vp->v_type == VBLK)
-			mp = vp->v_specmountpoint;
+	if (mp != NULL) {
+		if (async)
+			mp->mnt_stat.f_asyncwrites++;
 		else
-			mp = vp->v_mount;
-		if (mp != NULL) {
-			if (async)
-				mp->mnt_stat.f_asyncwrites++;
-			else
-				mp->mnt_stat.f_syncwrites++;
-		}
+			mp->mnt_stat.f_syncwrites++;
 	}

 	wasdelayed = ISSET(bp->b_flags, B_DELWRI);


kernel/fatal: Fatal errors must not be preempted

The code underneath z_fatal_error() (which is usually run in an
exception context, but is not required to be) was running with
interrupts enabled, which is a little surprising.

The only bug present currently is that the CPU ID extracted for
logging is subject to a race (i.e. it's possible but very unlikely
that such a handler might migrate to another CPU after the error is
flagged and log the wrong CPU ID), but in general users with custom
error handlers are likely to be surprised when their dying threads
gets preempted by other code before they can abort.

Signed-off-by: Andy Ross <c70f9a6bf6ee0cd69c8af4ce5e6b131945769315@intel.com>

--- kernel/fatal.c
+++ kernel/fatal.c
@@ -92,6 +92,11 @@

 void z_fatal_error(unsigned int reason, const z_arch_esf_t *esf)
 {
+	/* We can't allow this code to be preempted, but don't need to
+	 * synchronize between CPUs, so an arch-layer lock is
+	 * appropriate.
+	 */
+	unsigned int key = arch_irq_lock();
 	struct k_thread *thread = k_current_get();

 	/* sanitycheck looks for the "ZEPHYR FATAL ERROR" string, don't
@@ -160,5 +165,6 @@
 #endif /*CONFIG_ARCH_HAS_NESTED_EXCEPTION_DETECTION */
 	}

+	arch_irq_unlock(key);
 	k_thread_abort(thread);
 }


kfifo.c: use errno.h return codes

kfifo.c: use errno.h return codes

--- kernel/kfifo.c
+++ kernel/kfifo.c
@@ -57,7 +57,7 @@
 	tmp = krealloc(kfifo->buf, kfifo->cap + siz);
 	if (!tmp) {
 		spinlock_unlock(&kfifo->lock);
-		return -1;
+		return -ENOMEM;
 	}
 	kfifo->buf = tmp;
 	memcpy(kfifo->buf + kfifo->siz, buf, siz);
@@ -76,7 +76,7 @@
 	spinlock_lock(&kfifo->lock);
 	if (kfifo->siz < siz) {
 		spinlock_unlock(&kfifo->lock);
-		return -1;
+		return -EINVAL;
 	}
 	memcpy(buf, kfifo->buf, siz);
 	memmove(kfifo->buf, kfifo->buf + siz, kfifo->siz - siz);


fault-car: (minor) Refactoring filtered_derivative.c

--- platform/stm32f3_sensors/libfilters/filtered_derivative.c
+++ platform/stm32f3_sensors/libfilters/filtered_derivative.c
@@ -24,8 +24,5 @@
 }

 int filtered_derivative_check(float val) {
-	if (val < -FD_THRESHOLD || val > FD_THRESHOLD) {
-		return 1;
-	}
-	return 0;
+	return (val < -FD_THRESHOLD || val > FD_THRESHOLD);
 }


Copyright

Copyright

--- plugin-clock/razorclock.h
+++ plugin-clock/razorclock.h
@@ -5,7 +5,7 @@
  *
  * Copyright: 2010-2011 Razor team
  * Authors:
- *   Christopher "VdoP" Regali <
+ *   Christopher "VdoP" Regali
  *   Alexander Sokoloff <sokoloff.a@gmail.ru>
  *
  * This program is free software; you can redistribute it and/or


first add all the signatures to a seperate set,
then add them to the covered RRset.

Otherwise we can never double sign a RRset

--- signer/src/signer/rrset.c
+++ signer/src/signer/rrset.c
@@ -645,9 +645,10 @@
     uint8_t signed_with = 0;
     uint32_t newsigs = 0;
     uint32_t reusedsigs = 0;
-    ldns_status status = LDNS_STATUS_OK;
     ldns_rr* rrsig = NULL;
     ldns_rr_list* rr_list = NULL;
+    rrsigs_type* new_rrsigs = NULL;
+    rrsigs_type* walk_rrsigs = NULL;
     key_type* key = NULL;
     time_t inception = 0;
     time_t expiration = 0;
@@ -661,6 +662,7 @@
         error = rrset_recycle_rrsigs(rrset, sc, signtime, &reusedsigs);

         /* prepare for signing */
+        new_rrsigs = rrsigs_create();
         if (!rrset->rrsigs) {
             rrset->rrsigs = rrsigs_create();
         }
@@ -683,7 +685,7 @@
             }

             /* is there a signature with this algorithm already? */
-            if (signed_with == key->algorithm ||
+            if (signed_with != key->algorithm ||
                 rrset_signed_with_algorithm(rrset, key->algorithm)) {

                 signed_with = key->algorithm;
@@ -703,26 +705,49 @@
                 se_log_error("error creating RRSIG for rrset[%i]",
                     rrset->rr_type);
                 ldns_rr_list_free(rr_list);
+                rrsigs_cleanup(new_rrsigs);
                 return 1;
             }
-            /* add the signature to the RRset */
-            error = rrsigs_add_sig(rrset->rrsigs, rrsig, key->locator,
+            /* add the signature to the set of new signatures */
+            error = rrsigs_add_sig(new_rrsigs, rrsig, key->locator,
                 key->flags);
             if (error) {
-                se_log_error("error adding RRSIG to RRset (%i): %s",
-                    rrset->rr_type, ldns_get_errorstr_by_id(status));
+                se_log_error("error adding RRSIG to list of signatures");
                 rrset_log_rr(rrsig, "+RRSIG", 1);
                 ldns_rr_list_free(rr_list);
+                rrsigs_cleanup(new_rrsigs);
                 return 1;
             }
-            rrset_log_rr(rrsig, "+RRSIG", 6);
-            rrset->rrsig_count += 1;
-            newsigs++;
+
             /* next key */
             key = key->next;
         }

+        /* now add the signatures to the RRset */
+        walk_rrsigs = new_rrsigs;
+        while (walk_rrsigs) {
+            error = rrsigs_add_sig(rrset->rrsigs, walk_rrsigs->rr,
+                walk_rrsigs->key_locator, walk_rrsigs->key_flags);
+            if (error) {
+                se_log_error("error adding RRSIG to RRset[%i]",
+                    rrset->rr_type);
+                rrset_log_rr(walk_rrsigs->rr, "+RRSIG", 1);
+                ldns_rr_list_free(rr_list);
+                rrsigs_cleanup(new_rrsigs);
+                return 1;
+            }
+
+            /* this RRSIG is now in the RRset, don't clean it up */
+            walk_rrsigs->rr = NULL;
+
+            rrset->rrsig_count += 1;
+            rrset_log_rr(walk_rrsigs->rr, "+RRSIG", 6);
+            newsigs++;
+            walk_rrsigs = walk_rrsigs->next;
+        }
+
         /* clean up */
+        rrsigs_cleanup(new_rrsigs);
         ldns_rr_list_free(rr_list);

         rrset->outbound_serial = serial;


MFC r258658:

MFC r258658:

Fix a segfault / internal compiler error.

Among other causes, when gcc throws a warning before parsing any tokens,
the cur_token pointer is at the beginning of malloc'd memory.
Dereferencing cur_token[-1] can cause a segfault.

Code taken from OpenBSD
http://www.openbsd.org/cgi-bin/cvsweb/src/gnu/gcc/libcpp/errors.c
which was a more complete fix than the one I originally coded.

--- contrib/gcclibs/libcpp/errors.c
+++ contrib/gcclibs/libcpp/errors.c
@@ -153,7 +153,20 @@
 	}
       else
 	{
-	  src_loc = pfile->cur_token[-1].src_loc;
+	  /* Find actual previous token.  */
+	  cpp_token *t;
+
+	  if (pfile->cur_token != pfile->cur_run->base)
+	    t = pfile->cur_token - 1;
+	  else
+	    {
+	      if (pfile->cur_run->prev != NULL)
+	        t = pfile->cur_run->prev->limit;
+	      else
+	        t = NULL;
+	    }
+	  /* Retrieve corresponding source location, unless we failed.  */
+	  src_loc = t ? t->src_loc : 0;
 	}

       if (_cpp_begin_message (pfile, level, src_loc, 0))


Update config.h for OpenBSM 1.1 alpha 4.

--- contrib/openbsm/config/config.h
+++ contrib/openbsm/config/config.h
@@ -8,6 +8,9 @@
 /* Define if audit system calls present */
 #define HAVE_AUDIT_SYSCALLS

+/* Define if be32enc is present */
+#define HAVE_BE32ENC
+
 /* Define to 1 if you have the `bzero' function. */
 #define HAVE_BZERO 1

@@ -69,6 +72,9 @@
 /* Define to 1 if you have the `memset' function. */
 #define HAVE_MEMSET 1

+/* Define to 1 if you have the `pthread_mutex_lock' function. */
+#define HAVE_PTHREAD_MUTEX_LOCK 1
+
 /* Define to 1 if `stat' has the bug that it succeeds when given the
    zero-length file name argument. */
 /* #undef HAVE_STAT_EMPTY_STRING_BUG */
@@ -159,13 +165,13 @@
 #define PACKAGE_NAME "OpenBSM"

 /* Define to the full name and version of this package. */
-#define PACKAGE_STRING "OpenBSM 1.1alpha2"
+#define PACKAGE_STRING "OpenBSM 1.1alpha4"

 /* Define to the one symbol short name of this package. */
 #define PACKAGE_TARNAME "openbsm"

 /* Define to the version of this package. */
-#define PACKAGE_VERSION "1.1alpha2"
+#define PACKAGE_VERSION "1.1alpha4"

 /* Define as the return type of signal handlers (`int' or `void'). */
 #define RETSIGTYPE void
@@ -186,7 +192,7 @@
 #define USE_NATIVE_INCLUDES

 /* Version number of package */
-#define VERSION "1.1alpha2"
+#define VERSION "1.1alpha4"

 /* Define to empty if `const' does not conform to ANSI C. */
 /* #undef const */


Add interrupt checks to contrib/pg_prewarm.

Currently the extension's pg_prewarm() function didn't check
interrupts once it started "warming" data. Since individual calls can
take a long while it's important for them to be interruptible.

Backpatch to 9.4 where pg_prewarm was introduced.

--- contrib/pg_prewarm/pg_prewarm.c
+++ contrib/pg_prewarm/pg_prewarm.c
@@ -159,6 +159,7 @@
 		 */
 		for (block = first_block; block <= last_block; ++block)
 		{
+			CHECK_FOR_INTERRUPTS();
 			PrefetchBuffer(rel, forkNumber, block);
 			++blocks_done;
 		}
@@ -177,6 +178,7 @@
 		 */
 		for (block = first_block; block <= last_block; ++block)
 		{
+			CHECK_FOR_INTERRUPTS();
 			smgrread(rel->rd_smgr, forkNumber, block, blockbuffer);
 			++blocks_done;
 		}
@@ -190,6 +192,7 @@
 		{
 			Buffer		buf;

+			CHECK_FOR_INTERRUPTS();
 			buf = ReadBufferExtended(rel, forkNumber, block, RBM_NORMAL, NULL);
 			ReleaseBuffer(buf);
 			++blocks_done;


Update pg_upgrade C comment about cwd.

Update pg_upgrade C comment about cwd.

--- contrib/pg_upgrade/pg_upgrade.h
+++ contrib/pg_upgrade/pg_upgrade.h
@@ -215,7 +215,7 @@
 	const char *progname;		/* complete pathname for this program */
 	char	   *exec_path;		/* full path to my executable */
 	char	   *user;			/* username for clusters */
-	char		cwd[MAXPGPATH];	/* directory for pg_upgrade output */
+	char		cwd[MAXPGPATH];	/* current working directory, used for output */
 	char	  **tablespaces;	/* tablespaces */
 	int			num_tablespaces;
 	char	  **libraries;		/* loadable libraries */


Create apache_cjson.c

Create apache_cjson.c

Framework for developing web services using mod_cjson

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

--- apache_cjson.c
+++ apache_cjson.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2017 Steve Leski and contributors.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
+/*
+ * Apache mod_cjson module - companion library.
+ *
+ * Author: Steve Leski - https://github.com/steveleski
+ * Date: July 27, 2017
+ *
+ * This code exposes some functions to allow the user defined shareable library
+ * to interact with mod_cjson. mod_cjson is an Apache module that can invoke a
+ * user defined function to process a http request using JSON.
+ *
+ * To use mod_cjson, set up a <Location> block in your configuration file like
+ * so:
+ *
+ *    LoadModule cjson_module modules/mod_cjson.so
+ *    <IfModule mod_cjson.c>
+ *       <Location /example>
+ *          SetHandler cjson-handler
+ *          cJSONContentHandler /usr/lib/example/user_code.so
+ *       </Location>
+ *       ... other location directives
+ *    </IfModule>
+ *
+ * user_code is a shareable library that exposes a single function call with the
+ * signature:
+ *     int APACHE_CJSON_ENTRY_POINT(apache_cjson *context, cJSON *request, cJSON **response)
+ * The request and response objects use cJSON https://github.com/DaveGamble/cJSON
+ * to marshall/unmarshall the http request and response bodies.
+ *
+ *
+ * IMPORTANT NOTES
+ * ===============
+ *
+ * XXX TO DO XXX
+ * =============
+ *
+ * Maybe I need to use a different license?
+ */
+
+#include "apache_cjson.h"
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Add headers to be passed back in the response
+ */
+void cjson_add_response_header(apache_cjson *context, char *name, char *value) {
+    response_header_list *tmp = (response_header_list*)malloc(sizeof(response_header_list));
+    if (context->response_headers != NULL) {
+        tmp->next = context->response_headers;
+    } else {
+        tmp->next = NULL;
+    }
+    tmp->name = name;
+    tmp->value  = value;
+    context->response_headers = tmp;
+
+    return;
+}
+
+
+/*
+ * Allocate memory from a pool. mod_cjson will free this memory
+ * automatically after a request/response completes.
+ */
+void *cjson_alloc_mem(apache_cjson *context, size_t size) {
+    cjson_pool_t *tmp = (cjson_pool_t*)malloc(sizeof(cjson_pool_t));
+    if (context->pool != NULL) {
+        tmp->next = context->pool;
+    } else {
+        tmp->next = NULL;
+    }
+    context->pool = tmp;
+    tmp->value = (void *)malloc(size);
+
+    return tmp->value;
+}
+
+
+/*
+ * Deallocate all memory allocated from the pool.
+ *
+ * This should only be called from test code. It will automatically be
+ * called by mod_cjson to clean up after a request/response completes.
+ */
+void cjson_free_mem(apache_cjson *context) {
+    cjson_pool_t *tmp, *pool = context->pool;
+    do {
+        tmp = pool->next;
+        free(pool);
+        pool = tmp;
+    } while  (pool != NULL);
+    context->pool = NULL;
+}
+
+#ifdef __cplusplus
+}
+#endif


edit diff BUGFIX edit same leaf with different value

It is properly forbidden now.

--- src/edit_diff.c
+++ src/edit_diff.c
@@ -2543,20 +2543,22 @@
         /* find the node */
         set = lyd_find_path(session->dt[session->ds].edit, uniq_xpath);
         free(uniq_xpath);
-        if (!set || (set->number != 1)) {
+        if (!set || (set->number > 1)) {
             ly_set_free(set);
             SR_ERRINFO_INT(&err_info);
             return err_info;
-        }
-        node = set->set.d[0];
+        } else if (set->number == 1) {
+            node = set->set.d[0];
+            ly_set_free(set);
+
+            op = sr_edit_find_oper(node, 1, NULL);
+            if (!strcmp(op, operation)) {
+                /* same node with same operation, silently ignore and clear the error */
+                ly_err_clean(session->conn->ly_ctx, NULL);
+                return NULL;
+            } /* else node has a different operation, error */
+        } /* else set->number == 0; it must be leaf and there already is one with another value, error */
         ly_set_free(set);
-
-        op = sr_edit_find_oper(node, 1, NULL);
-        if (!strcmp(op, operation)) {
-            /* same node with same operation, silently ignore and clear the error */
-            ly_err_clean(session->conn->ly_ctx, NULL);
-            return NULL;
-        }
     }

     sr_errinfo_new_ly(&err_info, session->conn->ly_ctx);


Eliminate CB_setf in LexiconWriter

Eliminate CB_setf in LexiconWriter

--- core/Lucy/Index/LexiconWriter.c
+++ core/Lucy/Index/LexiconWriter.c
@@ -58,9 +58,9 @@
     ivars->dat_out            = NULL;
     ivars->count              = 0;
     ivars->ix_count           = 0;
-    ivars->dat_file           = CB_new(30);
-    ivars->ix_file            = CB_new(30);
-    ivars->ixix_file          = CB_new(30);
+    ivars->dat_file           = NULL;
+    ivars->ix_file            = NULL;
+    ivars->ixix_file          = NULL;
     ivars->counts             = Hash_new(0);
     ivars->ix_counts          = Hash_new(0);
     ivars->temp_mode          = false;
@@ -133,9 +133,12 @@
     FieldType *const type     = Schema_Fetch_Type(schema, field);

     // Open outstreams.
-    CB_setf(ivars->dat_file,  "%o/lexicon-%i32.dat",  seg_name, field_num);
-    CB_setf(ivars->ix_file,   "%o/lexicon-%i32.ix",   seg_name, field_num);
-    CB_setf(ivars->ixix_file, "%o/lexicon-%i32.ixix", seg_name, field_num);
+    DECREF(ivars->dat_file);
+    DECREF(ivars->ix_file);
+    DECREF(ivars->ixix_file);
+    ivars->dat_file  = CB_newf("%o/lexicon-%i32.dat",  seg_name, field_num);
+    ivars->ix_file   = CB_newf("%o/lexicon-%i32.ix",   seg_name, field_num);
+    ivars->ixix_file = CB_newf("%o/lexicon-%i32.ixix", seg_name, field_num);
     ivars->dat_out = Folder_Open_Out(folder, ivars->dat_file);
     if (!ivars->dat_out) { RETHROW(INCREF(Err_get_error())); }
     ivars->ix_out = Folder_Open_Out(folder, ivars->ix_file);


Validate the result.

Validate the result.

--- samples/entropy/entropy.c
+++ samples/entropy/entropy.c
@@ -8,15 +8,14 @@
 #endif
 #include <libxstream_end.h>

-
-LIBXSTREAM_TARGET(mic) void makehist(const char* data, size_t* histogram)
+/*#define ENTROPY_CHECK*/
+
+
+LIBXSTREAM_TARGET(mic) void hista(const char* data, size_t size, size_t* histogram)
 {
   static const size_t maxint = (size_t)(((unsigned int)-1) >> 1);
-  int i, j, m;
-  size_t size;
-  LIBXSTREAM_CHECK_CALL_ASSERT(libxstream_get_shape(0/*current context*/, 0/*data*/, &size));
-
-  m = (int)((size + maxint - 1) / maxint);
+  int i, j, m = (int)((size + maxint - 1) / maxint);
+
   for (i = 0; i < m; ++i) { /*OpenMP 2: size is broken down to integer space*/
     const size_t base = i * maxint;
     const int n = (int)LIBXSTREAM_MIN(size - base, maxint);
@@ -31,6 +30,14 @@
       ++histogram[k];
     }
   }
+}
+
+
+LIBXSTREAM_TARGET(mic) void makehist(const char* data, size_t* histogram)
+{
+  size_t size;
+  LIBXSTREAM_CHECK_CALL_ASSERT(libxstream_get_shape(0/*current context*/, 0/*data*/, &size));
+  hista(data, size, histogram);
 }

@@ -142,6 +149,9 @@
     }
   }

+#if defined(_OPENMP)
+  const double duration = omp_get_wtime() - start;
+#endif
   const double kilo = 1.0 / (1 << 10), mega = 1.0 / (1 << 20);
   double entropy = 0;
   { /*calculate entropy*/
@@ -153,6 +163,7 @@
     }
     entropy /= nitems;
   }
+
   if ((1 << 20) <= nitems) { /*mega*/
     fprintf(stdout, "Compression %gx (%0.f%%): %.1f -> %.1f MB", 8.0 / entropy, 100.0 - 12.5 * entropy, mega * nitems, mega * entropy * nitems / 8.0);
   }
@@ -165,14 +176,26 @@
   fprintf(stdout, " (entropy of %.0f bit)\n", entropy);

 #if defined(_OPENMP)
-  const double duration = omp_get_wtime() - start;
   if (0 < duration) {
-    fprintf(stdout, "Finished after %.1f s\n", duration);
+    fprintf(stdout, "Finished after %.1f s", duration);
   }
   else {
-    fprintf(stdout, "Finished\n");
-  }
-#endif
+    fprintf(stdout, "Finished");
+  }
+#endif
+
+#if !defined(ENTROPY_CHECK)
+  const char *const check_env = getenv("CHECK");
+  if (check_env && *check_env && 0 != atoi(check_env))
+#endif
+  { /*validate result*/
+    size_t expected[256/*hsize*/], errors = 0, i;
+    memset(expected, 0, sizeof(expected));
+    hista(data, nitems, expected);
+    for (i = 0; i < hsize; ++i) errors += expected[i] == histogram[i] ? 0 : 1;
+    fprintf(stdout, " with %llu error%s", (unsigned long long)errors, 1 != errors ? "s" : "");
+  }
+  fprintf(stdout, "\n");

   { /*release resources*/
     size_t i;


avoid MSVC warning C4305

avoid MSVC warning C4305

--- third_party/pocketfft_hdronly.h
+++ third_party/pocketfft_hdronly.h
@@ -309,7 +309,7 @@

     void fill_first_quadrant(size_t n, T * restrict res)
       {
-      constexpr Thigh hsqt2 = Thigh(0.707106781186547524400844362104849L);
+      constexpr T hsqt2 = T(0.707106781186547524400844362104849L);
       size_t quart = n>>2;
       if ((n&7)==0)
         res[quart] = res[quart+1] = hsqt2;


Fix clang warning in GMSampleView.h

Fix clang warning in GMSampleView.h

../../samplecode/GMSampleView.h:23:7: warning: field 'fGM' will be initialized after field 'fShowSize' [-Wreorder]

R=bsalomon@google.com

Review URL: https://codereview.appspot.com/6856063

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

--- samplecode/GMSampleView.h
+++ samplecode/GMSampleView.h
@@ -20,7 +20,7 @@

 public:
     GMSampleView(GM* gm)
-    : fGM(gm), fShowSize(false) {}
+    : fShowSize(false), fGM(gm) {}

     virtual ~GMSampleView() {
         delete fGM;


Doxygenify comments.

Doxygenify comments.

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

--- include/llvm/Analysis/PostDominators.h
+++ include/llvm/Analysis/PostDominators.h
@@ -18,7 +18,6 @@

 namespace llvm {

-
 /// PostDominatorSet Class - Concrete subclass of DominatorSetBase that is used
 /// to compute the post-dominator set.  Because there can be multiple exit nodes
 /// in an LLVM function, we calculate post dominators with a special null block
@@ -31,19 +30,17 @@

   virtual bool runOnFunction(Function &F);

-  // getAnalysisUsage - This pass does not modify the function at all.
-  //
+  /// getAnalysisUsage - This pass does not modify the function at all.
+  ///
   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
     AU.setPreservesAll();
   }
 };

-
-//===-------------------------------------
-// ImmediatePostDominators Class - Concrete subclass of ImmediateDominatorsBase
-// that is used to compute the immediate post-dominators.
-//
+/// ImmediatePostDominators Class - Concrete subclass of ImmediateDominatorsBase
+/// that is used to compute the immediate post-dominators.
+///
 struct ImmediatePostDominators : public ImmediateDominatorsBase {
   ImmediatePostDominators() : ImmediateDominatorsBase(true) {}

@@ -64,10 +61,9 @@
 };

-//===-------------------------------------
-// PostDominatorTree Class - Concrete subclass of DominatorTree that is used to
-// compute the a post-dominator tree.
-//
+/// PostDominatorTree Class - Concrete subclass of DominatorTree that is used to
+/// compute the a post-dominator tree.
+///
 struct PostDominatorTree : public DominatorTreeBase {
   PostDominatorTree() : DominatorTreeBase(true) {}

@@ -88,10 +84,9 @@
 };

-//===-------------------------------------
-// PostDominanceFrontier Class - Concrete subclass of DominanceFrontier that is
-// used to compute the a post-dominance frontier.
-//
+/// PostDominanceFrontier Class - Concrete subclass of DominanceFrontier that is
+/// used to compute the a post-dominance frontier.
+///
 struct PostDominanceFrontier : public DominanceFrontierBase {
   PostDominanceFrontier() : DominanceFrontierBase(true) {}


Fixed potential bug where CurWord is not zeroed out in JumpToBit.

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

--- include/llvm/Bitcode/BitstreamReader.h
+++ include/llvm/Bitcode/BitstreamReader.h
@@ -122,6 +122,7 @@
     // Move the cursor to the right word.
     NextChar = FirstChar+ByteNo;
     BitsInCurWord = 0;
+    CurWord = 0;

     // Skip over any bits that are already consumed.
     if (WordBitNo) {


Fixed some style bugs in previous commit (mainly highly non-KNF indentation).

--- sbin/fsck_msdosfs/check.c
+++ sbin/fsck_msdosfs/check.c
@@ -84,8 +84,9 @@
 		return 8;
 	}

-	if (checkdirty(dosfs, &boot) && !force)	{
-		if (preen) printf("%s: ", fname);
+	if (checkdirty(dosfs, &boot) && !force) {
+		if (preen)
+			printf("%s: ", fname);
 		printf("FILESYSTEM CLEAN; SKIPPING CHECKS\n");
 		ret = 0;
 		goto out;
@@ -199,18 +200,19 @@
 	return ret;
 }

-int checkdirty(int fs, struct bootblock *boot)
+int
+checkdirty(int fs, struct bootblock *boot)
 {
 	off_t off;
 	u_char *buffer;
 	int ret = 0;
-
+
 	if (boot->ClustMask == CLUST12_MASK)
-		return 0;
+		return 0;

 	off = boot->ResSectors;
 	off *= boot->BytesPerSec;
-
+
 	buffer = malloc(boot->BytesPerSec);
 	if (buffer == NULL) {
 		perror("No space for FAT");
@@ -222,19 +224,17 @@
 		goto err;
 	}

-	if (read(fs, buffer, boot->BytesPerSec)
-	    != boot->BytesPerSec) {
+	if (read(fs, buffer, boot->BytesPerSec) != boot->BytesPerSec) {
 		perror("Unable to read FAT");
 		goto err;
 	}

-	 if (buffer[0] == boot->Media && buffer[1] == 0xff
-                    && buffer[2] == 0xff
-                    && ((boot->ClustMask == CLUST16_MASK && buffer[3] == 0x7f)
-                        || (boot->ClustMask == CLUST32_MASK
-                            && buffer[3] == 0x0f && buffer[4] == 0xff
-                            && buffer[5] == 0xff && buffer[6] == 0xff
-                            && buffer[7] == 0x07)))
+	if (buffer[0] == boot->Media && buffer[1] == 0xff &&
+	    buffer[2] == 0xff &&
+	    ((boot->ClustMask == CLUST16_MASK && buffer[3] == 0x7f) ||
+	    (boot->ClustMask == CLUST32_MASK && buffer[3] == 0x0f &&
+	    buffer[4] == 0xff && buffer[5] == 0xff && buffer[6] == 0xff &&
+	    buffer[7] == 0x07)))
 		ret = 0;
 	else
 		ret = 1;


Disbale statement_timeout while executing online recovery.

Online may take very long time and user may enable statement
timeout. To prevent online recovery canceled by statement timeout,
disable statement timeout in the connection used by online recovery.

See [pgpool-general: 2919] for whole story.

--- src/pcp_con/recovery.c
+++ src/pcp_con/recovery.c
@@ -5,7 +5,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2013	PgPool Global Development Group
+ * Copyright (c) 2003-2014	PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
@@ -273,6 +273,15 @@
 			 master_backend->backend_port);

 	pool_log("starting recovery command: \"%s\"", recovery_command);
+	pool_log("disabling statement_timeout");
+	result = PQexec(conn, "SET statement_timeout To 0");
+	r = (PQresultStatus(result) !=  PGRES_COMMAND_OK);
+	if (r != 0)
+	{
+		pool_error("exec_recovery: SET STATEMENT_TIMEOUT failed at %s",
+				   (stage == FIRST_STAGE) ? "1st stage" : "2nd stage");
+	}
+	PQclear(result);

 	pool_debug("exec_recovery: start recovery");
 	result = PQexec(conn, recovery_command);