destatic and deinline. return type on line before rest of function
declaration.

no binary size change.

--- dev/pci/drm/r300_cmdbuf.c
+++ dev/pci/drm/r300_cmdbuf.c
@@ -37,6 +37,34 @@
 #include "radeon_drv.h"
 #include "r300_reg.h"

+int	r300_emit_cliprects(drm_radeon_private_t *,
+	    drm_radeon_kcmd_buffer_t *, int);
+int	r300_check_range(unsigned, int);
+int	r300_emit_carefully_checked_packet0(drm_radeon_private_t *,
+	    drm_radeon_kcmd_buffer_t *, drm_r300_cmd_header_t);
+int	r300_emit_packet0(drm_radeon_private_t *, drm_radeon_kcmd_buffer_t *,
+	    drm_r300_cmd_header_t);
+int	r300_emit_vpu(drm_radeon_private_t *, drm_radeon_kcmd_buffer_t *,
+	    drm_r300_cmd_header_t);
+int	r300_emit_clear(drm_radeon_private_t *, drm_radeon_kcmd_buffer_t *);
+int	r300_emit_3d_load_vbpntr(drm_radeon_private_t *,
+	    drm_radeon_kcmd_buffer_t *, u32);
+int	r300_emit_bitblt_multi(drm_radeon_private_t *,
+	    drm_radeon_kcmd_buffer_t *);
+int	r300_emit_draw_indx_2(drm_radeon_private_t *,
+	    drm_radeon_kcmd_buffer_t *);
+int	r300_emit_raw_packet3(drm_radeon_private_t *,
+	    drm_radeon_kcmd_buffer_t *);
+int	r300_emit_packet3(drm_radeon_private_t *, drm_radeon_kcmd_buffer_t *,
+	    drm_r300_cmd_header_t);
+void	r300_pacify(drm_radeon_private_t *);
+void	r300_discard_buffer(struct drm_device *, struct drm_buf *);
+void	r300_cmd_wait(drm_radeon_private_t *, drm_r300_cmd_header_t);
+int	r300_scratch(drm_radeon_private_t *, drm_radeon_kcmd_buffer_t *,
+	    drm_r300_cmd_header_t);
+int	r300_emit_r500fp(drm_radeon_private_t *, drm_radeon_kcmd_buffer_t *,
+	    drm_r300_cmd_header_t);
+
 #define R300_SIMULTANEOUS_CLIPRECTS		4

 /* Values for R300_RE_CLIPRECT_CNTL depending on the number of cliprects
@@ -52,8 +80,9 @@
  * Emit up to R300_SIMULTANEOUS_CLIPRECTS cliprects from the given command
  * buffer, starting with index n.
  */
-static int r300_emit_cliprects(drm_radeon_private_t *dev_priv,
-			       drm_radeon_kcmd_buffer_t *cmdbuf, int n)
+int
+r300_emit_cliprects(drm_radeon_private_t *dev_priv,
+    drm_radeon_kcmd_buffer_t *cmdbuf, int n)
 {
 	struct drm_clip_rect box;
 	int nr;
@@ -271,7 +300,8 @@
 	}
 }

-static __inline__ int r300_check_range(unsigned reg, int count)
+int
+r300_check_range(unsigned reg, int count)
 {
 	int i;
 	if (reg & ~0xffff)
@@ -282,12 +312,9 @@
 	return 0;
 }

-static __inline__ int r300_emit_carefully_checked_packet0(drm_radeon_private_t *
-							  dev_priv,
-							  drm_radeon_kcmd_buffer_t
-							  * cmdbuf,
-							  drm_r300_cmd_header_t
-							  header)
+int
+r300_emit_carefully_checked_packet0(drm_radeon_private_t *dev_priv,
+    drm_radeon_kcmd_buffer_t *cmdbuf, drm_r300_cmd_header_t header)
 {
 	int reg;
 	int sz;
@@ -341,9 +368,9 @@
  *
  * Note that checks are performed on contents and addresses of the registers
  */
-static __inline__ int r300_emit_packet0(drm_radeon_private_t *dev_priv,
-					drm_radeon_kcmd_buffer_t *cmdbuf,
-					drm_r300_cmd_header_t header)
+int
+r300_emit_packet0(drm_radeon_private_t *dev_priv,
+    drm_radeon_kcmd_buffer_t *cmdbuf, drm_r300_cmd_header_t header)
 {
 	int reg;
 	int sz;
@@ -388,9 +415,9 @@
  * the graphics card.
  * Called by r300_do_cp_cmdbuf.
  */
-static __inline__ int r300_emit_vpu(drm_radeon_private_t *dev_priv,
-				    drm_radeon_kcmd_buffer_t *cmdbuf,
-				    drm_r300_cmd_header_t header)
+int
+r300_emit_vpu(drm_radeon_private_t *dev_priv, drm_radeon_kcmd_buffer_t *cmdbuf,
+    drm_r300_cmd_header_t header)
 {
 	int sz;
 	int addr;
@@ -438,8 +465,9 @@
  * Emit a clear packet from userspace.
  * Called by r300_emit_packet3.
  */
-static __inline__ int r300_emit_clear(drm_radeon_private_t *dev_priv,
-				      drm_radeon_kcmd_buffer_t *cmdbuf)
+int
+r300_emit_clear(drm_radeon_private_t *dev_priv,
+    drm_radeon_kcmd_buffer_t *cmdbuf)
 {
 	RING_LOCALS;

@@ -468,9 +496,9 @@
 	return 0;
 }

-static __inline__ int r300_emit_3d_load_vbpntr(drm_radeon_private_t *dev_priv,
-					       drm_radeon_kcmd_buffer_t *cmdbuf,
-					       u32 header)
+int
+r300_emit_3d_load_vbpntr(drm_radeon_private_t *dev_priv,
+    drm_radeon_kcmd_buffer_t *cmdbuf, u32 header)
 {
 	int count, i, k;
 #define MAX_ARRAY_PACKET  64
@@ -536,8 +564,9 @@
 	return 0;
 }

-static __inline__ int r300_emit_bitblt_multi(drm_radeon_private_t *dev_priv,
-					     drm_radeon_kcmd_buffer_t *cmdbuf)
+int
+r300_emit_bitblt_multi(drm_radeon_private_t *dev_priv,
+    drm_radeon_kcmd_buffer_t *cmdbuf)
 {
 	u32 *cmd = (u32 *) cmdbuf->buf;
 	int count, ret;
@@ -581,8 +610,9 @@
 	return 0;
 }

-static __inline__ int r300_emit_draw_indx_2(drm_radeon_private_t *dev_priv,
-					    drm_radeon_kcmd_buffer_t *cmdbuf)
+int
+r300_emit_draw_indx_2(drm_radeon_private_t *dev_priv,
+    drm_radeon_kcmd_buffer_t *cmdbuf)
 {
 	u32 *cmd;
 	int count;
@@ -656,8 +686,9 @@
 	return 0;
 }

-static __inline__ int r300_emit_raw_packet3(drm_radeon_private_t *dev_priv,
-					    drm_radeon_kcmd_buffer_t *cmdbuf)
+int
+r300_emit_raw_packet3(drm_radeon_private_t *dev_priv,
+    drm_radeon_kcmd_buffer_t *cmdbuf)
 {
 	u32 header;
 	int count;
@@ -736,9 +767,9 @@
  * Emit a rendering packet3 from userspace.
  * Called by r300_do_cp_cmdbuf.
  */
-static __inline__ int r300_emit_packet3(drm_radeon_private_t *dev_priv,
-					drm_radeon_kcmd_buffer_t *cmdbuf,
-					drm_r300_cmd_header_t header)
+int
+r300_emit_packet3(drm_radeon_private_t *dev_priv,
+    drm_radeon_kcmd_buffer_t *cmdbuf, drm_r300_cmd_header_t header)
 {
 	int n;
 	int ret;
@@ -805,7 +836,8 @@
 /**
  * Emit the sequence to pacify R300.
  */
-static __inline__ void r300_pacify(drm_radeon_private_t *dev_priv)
+void
+r300_pacify(drm_radeon_private_t *dev_priv)
 {
 	uint32_t cache_z, cache_3d, cache_2d;
 	RING_LOCALS;
@@ -861,7 +893,8 @@
  * The actual age emit is done by r300_do_cp_cmdbuf, which is why you must
  * be careful about how this function is called.
  */
-static void r300_discard_buffer(struct drm_device * dev, struct drm_buf * buf)
+void
+r300_discard_buffer(struct drm_device * dev, struct drm_buf * buf)
 {
 	drm_radeon_private_t *dev_priv = dev->dev_private;
 	drm_radeon_buf_priv_t *buf_priv = buf->dev_private;
@@ -871,8 +904,8 @@
 	buf->used = 0;
 }

-static void r300_cmd_wait(drm_radeon_private_t * dev_priv,
-			  drm_r300_cmd_header_t header)
+void
+r300_cmd_wait(drm_radeon_private_t * dev_priv, drm_r300_cmd_header_t header)
 {
 	u32 wait_until;
 	RING_LOCALS;
@@ -912,9 +945,9 @@
 	ADVANCE_RING();
 }

-static int r300_scratch(drm_radeon_private_t *dev_priv,
-			drm_radeon_kcmd_buffer_t *cmdbuf,
-			drm_r300_cmd_header_t header)
+int
+r300_scratch(drm_radeon_private_t *dev_priv, drm_radeon_kcmd_buffer_t *cmdbuf,
+    drm_r300_cmd_header_t header)
 {
 	u32 *ref_age_base;
 	u32 i, buf_idx, h_pending;
@@ -974,9 +1007,9 @@
  * the graphics card.
  * Called by r300_do_cp_cmdbuf.
  */
-static __inline__ int r300_emit_r500fp(drm_radeon_private_t *dev_priv,
-				       drm_radeon_kcmd_buffer_t *cmdbuf,
-				       drm_r300_cmd_header_t header)
+int
+r300_emit_r500fp(drm_radeon_private_t *dev_priv,
+    drm_radeon_kcmd_buffer_t *cmdbuf, drm_r300_cmd_header_t header)
 {
 	int sz;
 	int addr;


Add Synergy21 S21810 support; from NetBSD. Remove flags, it's not used.

--- dev/pcmcia/if_ne_pcmcia.c
+++ dev/pcmcia/if_ne_pcmcia.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: if_ne_pcmcia.c,v 1.43 2001/04/19 05:32:39 fgsch Exp $	*/
+/*	$OpenBSD: if_ne_pcmcia.c,v 1.44 2001/05/22 08:34:27 fgsch Exp $	*/
 /*	$NetBSD: if_ne_pcmcia.c,v 1.17 1998/08/15 19:00:04 thorpej Exp $	*/

 /*
@@ -103,9 +103,6 @@
     int function;
     int enet_maddr;
     unsigned char enet_vendor[3];
-    int flags;
-#define NE2000DVF_DL10019	0x0001		/* chip is D-Link DL10019 */
-#define NE2000DVF_AX88190	0x0002		/* chip is ASIX AX88190 */
 } ne2000devs[] = {
     { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
       PCMCIA_CIS_AMBICOM_AMB8002T,
@@ -170,6 +167,10 @@
     { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
       PCMCIA_CIS_NETGEAR_FA410TX,
       0, -1, { 0x00, 0xe0, 0x98 } },
+
+    { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
+      PCMCIA_CIS_SYNERGY21_S21810,
+      0, -1, { 0x00, 0x48, 0x54 } },

     { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
       PCMCIA_CIS_TAMARACK_NE2000,
@@ -225,7 +226,7 @@
      */
     { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD,
       PCMCIA_CIS_PLANEX_FNW3700T,
-      0, -1, { 0x00, 0x90, 0xcc }, NE2000DVF_AX88190 },
+      0, -1, { 0x00, 0x90, 0xcc }, /* NE2000DVF_AX88190 */ },

     { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ETHERFAST,
       PCMCIA_CIS_LINKSYS_ETHERFAST,
@@ -339,7 +340,7 @@

     { PCMCIA_VENDOR_MELCO, PCMCIA_PRODUCT_MELCO_LPC3_TX,
       PCMCIA_CIS_MELCO_LPC3_TX,
-      0, -1, { 0x00, 0x40, 0x26 }, NE2000DVF_AX88190 },
+      0, -1, { 0x00, 0x40, 0x26 }, /* NE2000DVF_AX88190 */ },

     { PCMCIA_VENDOR_DUAL, PCMCIA_PRODUCT_DUAL_NE2000,
       PCMCIA_CIS_DUAL_NE2000,


[Name Refactor]: zthread/biased_read_write_lock.h

--- zthread/include/zthread/biased_read_write_lock.h
+++ zthread/include/zthread/biased_read_write_lock.h
@@ -42,65 +42,63 @@
  * @version 2.2.7
  *
  * A BiasedReadWriteLock has a bias toward writers. It will prefer read-write
- * access over
- * read-only access when many threads are contending for access to either
- * Lockable this
- * ReadWriteLock provides.
+ * access over read-only access when many threads are contending for access to
+ * either Lockable this ReadWriteLock provides.
  *
  * @see ReadWriteLock
  */
 class BiasedReadWriteLock : public ReadWriteLock {
-  FastMutex _lock;
-  Condition _condRead;
-  Condition _condWrite;
-
-  volatile int _activeWriters;
-  volatile int _activeReaders;
-
-  volatile int _waitingReaders;
-  volatile int _waitingWriters;
+  FastMutex lock_;
+  Condition cond_read_;
+  Condition cond_write_;
+
+  volatile int active_writers_;
+  volatile int active_readers_;
+
+  volatile int waiting_readers_;
+  volatile int waiting_writers_;

   //! @class ReadLock
   class ReadLock : public Lockable {
-    BiasedReadWriteLock& _rwlock;
+    BiasedReadWriteLock& rwlock_;

    public:
-    ReadLock(BiasedReadWriteLock& rwlock) : _rwlock(rwlock) {}
+    ReadLock(BiasedReadWriteLock& rwlock) : rwlock_(rwlock) {}

     virtual ~ReadLock() {}

-    virtual void Acquire() { _rwlock.beforeRead(); }
+    virtual void Acquire() { rwlock_.BeforeRead(); }

     virtual bool TryAcquire(unsigned long timeout) {
-      return _rwlock.beforeReadAttempt(timeout);
-    }
-
-    virtual void Release() { _rwlock.afterRead(); }
+      return rwlock_.BeforeReadAttempt(timeout);
+    }
+
+    virtual void Release() { rwlock_.AfterRead(); }
   };

   //! @class WriteLock
   class WriteLock : public Lockable {
-    BiasedReadWriteLock& _rwlock;
+    BiasedReadWriteLock& rwlock_;

    public:
-    WriteLock(BiasedReadWriteLock& rwlock) : _rwlock(rwlock) {}
+    WriteLock(BiasedReadWriteLock& rwlock) : rwlock_(rwlock) {}

     virtual ~WriteLock() {}

-    virtual void Acquire() { _rwlock.beforeWrite(); }
+    virtual void Acquire() { rwlock_.BeforeWrite(); }

     virtual bool TryAcquire(unsigned long timeout) {
-      return _rwlock.beforeWriteAttempt(timeout);
-    }
-
-    virtual void Release() { _rwlock.afterWrite(); }
+      return rwlock_.BeforeWriteAttempt(timeout);
+    }
+
+    virtual void Release() { rwlock_.AfterWrite(); }
   };

   friend class ReadLock;
   friend class WriteLock;

-  ReadLock _rlock;
-  WriteLock _wlock;
+  ReadLock rlock_;
+  WriteLock wlock_;

  public:
   /**
@@ -110,156 +108,149 @@
    *            allocated for this object.
    */
   BiasedReadWriteLock()
-      : _condRead(_lock), _condWrite(_lock), _rlock(*this), _wlock(*this) {
-    _activeWriters = 0;
-    _activeReaders = 0;
-
-    _waitingReaders = 0;
-    _waitingWriters = 0;
+      : cond_read_(lock_), cond_write_(lock_), rlock_(*this), wlock_(*this) {
+    active_writers_ = 0;
+    active_readers_ = 0;
+
+    waiting_readers_ = 0;
+    waiting_writers_ = 0;
   }

   //! Destroy this ReadWriteLock
   virtual ~BiasedReadWriteLock() {}

   /**
-   * @see ReadWriteLock::getReadLock()
+   * @see ReadWriteLock::GetReadLock()
    */
-  virtual Lockable& getReadLock() { return _rlock; }
+  virtual Lockable& GetReadLock() { return rlock_; }

   /**
-   * @see ReadWriteLock::getWriteLock()
+   * @see ReadWriteLock::GetWriteLock()
    */
-  virtual Lockable& getWriteLock() { return _wlock; }
+  virtual Lockable& GetWriteLock() { return wlock_; }

  protected:
-  void beforeRead() {
-    Guard<FastMutex> guard(_lock);
-
-    ++_waitingReaders;
-
-    while (!allowReader()) {
-      try {
-        // wait
-        _condRead.Wait();
-
-      } catch (...) {
-        --_waitingReaders;
-        throw;
-      }
-    }
-
-    --_waitingReaders;
-    ++_activeReaders;
-  }
-
-  bool beforeReadAttempt(unsigned long timeout) {
-    Guard<FastMutex> guard(_lock);
+  void BeforeRead() {
+    Guard<FastMutex> guard(lock_);
+
+    ++waiting_readers_;
+
+    while (!AllowReader()) {
+      try {
+        cond_read_.Wait();
+      } catch (...) {
+        --waiting_readers_;
+        throw;
+      }
+    }
+
+    --waiting_readers_;
+    ++active_readers_;
+  }
+
+  bool BeforeReadAttempt(unsigned long timeout) {
+    Guard<FastMutex> guard(lock_);
     bool result = false;

-    ++_waitingReaders;
-
-    while (!allowReader()) {
-      try {
-        result = _condRead.Wait(timeout);
-
-      } catch (...) {
-        --_waitingReaders;
-        throw;
-      }
-    }
-
-    --_waitingReaders;
-    ++_activeReaders;
+    ++waiting_readers_;
+
+    while (!AllowReader()) {
+      try {
+        result = cond_read_.Wait(timeout);
+      } catch (...) {
+        --waiting_readers_;
+        throw;
+      }
+    }
+
+    --waiting_readers_;
+    ++active_readers_;

     return result;
   }

-  void afterRead() {
-    bool wakeReader = false;
-    bool wakeWriter = false;
+  void AfterRead() {
+    bool wake_reader = false;
+    bool wake_writer = false;

     {
-      Guard<FastMutex> guard(_lock);
-
-      --_activeReaders;
-
-      wakeReader = (_waitingReaders > 0);
-      wakeWriter = (_waitingWriters > 0);
-    }
-
-    if (wakeWriter)
-      _condWrite.signal();
-
-    else if (wakeReader)
-      _condRead.signal();
-  }
-
-  void beforeWrite() {
-    Guard<FastMutex> guard(_lock);
-
-    ++_waitingWriters;
-
-    while (!allowWriter()) {
-      try {
-        _condWrite.Wait();
-
-      } catch (...) {
-        --_waitingWriters;
-        throw;
-      }
-    }
-
-    --_waitingWriters;
-    ++_activeWriters;
-  }
-
-  bool beforeWriteAttempt(unsigned long timeout) {
-    Guard<FastMutex> guard(_lock);
+      Guard<FastMutex> guard(lock_);
+
+      --active_readers_;
+
+      wake_reader = (waiting_readers_ > 0);
+      wake_writer = (waiting_writers_ > 0);
+    }
+
+    if (wake_writer)
+      cond_write_.signal();
+    else if (wake_reader)
+      cond_read_.signal();
+  }
+
+  void BeforeWrite() {
+    Guard<FastMutex> guard(lock_);
+
+    ++waiting_writers_;
+
+    while (!AllowWriter()) {
+      try {
+        cond_write_.Wait();
+      } catch (...) {
+        --waiting_writers_;
+        throw;
+      }
+    }
+
+    --waiting_writers_;
+    ++active_writers_;
+  }
+
+  bool BeforeWriteAttempt(unsigned long timeout) {
+    Guard<FastMutex> guard(lock_);
     bool result = false;

-    ++_waitingWriters;
-
-    while (!allowWriter()) {
-      try {
-        result = _condWrite.Wait(timeout);
-
-      } catch (...) {
-        --_waitingWriters;
-        throw;
-      }
-    }
-
-    --_waitingWriters;
-    ++_activeWriters;
+    ++waiting_writers_;
+
+    while (!AllowWriter()) {
+      try {
+        result = cond_write_.Wait(timeout);
+      } catch (...) {
+        --waiting_writers_;
+        throw;
+      }
+    }
+
+    --waiting_writers_;
+    ++active_writers_;

     return result;
   }

-  void afterWrite() {
-    bool wakeReader = false;
-    bool wakeWriter = false;
+  void AfterWrite() {
+    bool wake_reader = false;
+    bool wake_writer = false;

     {
-      Guard<FastMutex> guard(_lock);
-
-      --_activeWriters;
-
-      wakeReader = (_waitingReaders > 0);
-      wakeWriter = (_waitingWriters > 0);
-    }
-
-    if (wakeWriter)
-      _condWrite.signal();
-
-    else if (wakeReader)
-      _condRead.signal();
-  }
-
-  bool allowReader() { return (_activeWriters == 0); }
-
-  bool allowWriter() { return (_activeWriters == 0 && _activeReaders == 0); }
+      Guard<FastMutex> guard(lock_);
+
+      --active_writers_;
+
+      wake_reader = (waiting_readers_ > 0);
+      wake_writer = (waiting_writers_ > 0);
+    }
+
+    if (wake_writer)
+      cond_write_.signal();
+    else if (wake_reader)
+      cond_read_.signal();
+  }
+
+  bool AllowReader() { return (active_writers_ == 0); }
+
+  bool AllowWriter() { return (active_writers_ == 0 && active_readers_ == 0); }
 };

-};  // __ZTBIASEDREADWRITELOCK_H__
-
-#endif
+}; // namespace zthread
+
+#endif // __ZTBIASEDREADWRITELOCK_H__


Added AHRS400 device.

Added AHRS400 device.

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

--- devices/ahrs400/ahrs400.c
+++ devices/ahrs400/ahrs400.c
@@ -0,0 +1,120 @@
+/**
+ * Device module for Crossbow's AHRS400 Attitude and Heading Reference System.
+ */
+
+
+#include <stdint.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <termios.h>
+#include <unistd.h>
+
+
+/*** AHRS constants ***/
+#define AHRS_DEFAULT_BAUDRATE B38400
+
+#define AHRS_MSG_HEADER 0xFF
+#define AHRS_MSG_LEN 29 //header not included (crc included)
+
+
+/*** AHRS Message codes ***/
+// Communication test messages
+#define PING 'R'
+#define PING_RESPONSE 'H'
+
+// Measurement mode configuration messages
+#define VOLTAGE_MODE 'r'
+#define VOLTAGE_MODE_RESPONSE 'R'
+#define SCALED_MODE 'c'
+#define SCALED_MODE_RESPONSE 'C'
+#define ANGLE_MODE 'a'
+#define ANGLE_MODE_RESPONSE 'A'
+
+// Communication mode configuration messages
+#define POLLED_MODE 'P'
+#define CONTINUOUS_MODE 'C'
+#define REQUEST_DATA 'G'
+#define REQUEST_BAUD 'b'
+#define REQUEST_BAUD_RESPONSE 'B'
+#define NEW_BAUD 'a'
+#define NEW_BAUD_RESPONSE 'A'
+
+// Information query messages
+#define QUERY_VERSION 'v'
+#define QUERY_VERSION_LENGTH 26
+#define QUERY_SERIAL_NUMBER 'S'
+
+// Magnetic calibration messages
+#define START_CALIB 's'
+#define START_CALIB_RESPONSE 'S'
+#define END_CALIB 'u'
+#define END_CALIB_RESPONSE 'U'
+#define CLEAR_HARDI 'h'
+#define CLEAR_HARDI_RESPONSE 'H'
+#define CLEAR_SOFTI 't'
+#define CLEAR_SOFTI_RESPONSE 'T'
+
+
+int open_ahrs(char *file) {
+    int fd = open(file, O_RDWR);
+    if (fd < 0) {
+        perror("Error opening AHRS file");
+        return -1;
+    }
+
+    struct termios ahrs_termios;
+    if (tcgetattr(fd, &ahrs_termios)) {
+        perror("Error getting AHRS serial port configuration");
+        return -1;
+    }
+    if (cfsetispeed(&ahrs_termios, AHRS_DEFAULT_BAUDRATE)) {
+        perror("Error setting  AHRS baud rate");
+        return -1;
+    }
+    if (tcsetattr(fd, &ahrs_termios)) {
+        perror("Error setting AHRS serial port configuration");
+        return -1;
+    }
+    return fd;
+}
+
+
+int config_ahrs(int fd){
+    // Put system into polled mode for configuration
+    uint8_t data = POLLED_MODE;
+    write(fd, &data, sizeof data);
+    fsync(fd);
+
+    // Discard all unread data in the buffer
+    tcflush(fd, TCIFLUSH);
+
+    // Ping the device
+    data = PING;
+    write(fd, &data, sizeof data);
+    read(fd, &data, sizeof data);
+    if (data != PING_RESPONSE) {
+        fprintf(stderr, "Invalid response to ping: %c.\n", data);
+        return -1;
+    }
+
+    // Get AHRS version
+    // TODO
+
+    // Put AHRS in angle mode
+    data = ANGLE_MODE;
+    write(fd, &data, sizeof data);
+    read(fd, &data, sizeof data);
+    if (data != ANGLE_MODE_RESPONSE) {
+        fprintf(stderr, "Invalid response to angle mode: %c.\n", data);
+        return -1;
+    }
+
+    // Put AHRS in continuous mode
+    data = CONTINUOUS_MODE;
+    write(fd, &data, sizeof data);
+    read(fd, &data, sizeof data);
+    if (data != CONTINUOUS_MODE_RESPONSE) {
+        fprintf(stderr, "Invalid response to continuous mode: %c.\n", data);
+        return -1;
+    }
+}


spiv: Add forgotten -e config opt

spiv: Add forgotten -e config opt

Signed-off-by: Cyril Hrubis <b1e90efd3b808b8e0bcf2a9a55fd8b9a779bfd81@ucw.cz>

--- demos/spiv/spiv_config.c
+++ demos/spiv/spiv_config.c
@@ -311,6 +311,7 @@
 	},
 	{.name_space = "Devel",
 	 .key = "BackendEmulation",
+	 .opt = 'e',
 	 .opt_long = "backend-emulation",
 	 .opt_has_value = 1,
 	 .set = set_emulation,


Mark the GdkColor struct as deprecated

Mark the GdkColor struct as deprecated

--- gdk/deprecated/gdkcolor.h
+++ gdk/deprecated/gdkcolor.h
@@ -48,6 +48,8 @@
  *
  * A #GdkColor is used to describe a color,
  * similar to the XColor struct used in the X11 drawing API.
+ *
+ * Deprecated: 3.14: Use #GdkRGBA
  */
 struct _GdkColor
 {


*.m3u load 2

*.m3u load 2

--- sdl2/libretro/libretro_params.h
+++ sdl2/libretro/libretro_params.h
@@ -14,7 +14,7 @@

 #define LR_CORENAME        "Neko Project II kai"
 #define LR_LIBVERSION      NP2VER_CORE
-#define LR_VALIDFILEEXT    "d88|88d|d98|98d|fdi|xdf|hdm|dup|2hd|tfd|nfd|hd4|hd5|hd9|fdd|h01|hdb|ddb|dd6|dcp|dcu|flp|bin|fim|thd|nhd|hdi|vhd|sln|hdn"
+#define LR_VALIDFILEEXT    "d88|88d|d98|98d|fdi|xdf|hdm|dup|2hd|tfd|nfd|hd4|hd5|hd9|fdd|h01|hdb|ddb|dd6|dcp|dcu|flp|bin|fim|thd|nhd|hdi|vhd|sln|hdn|m3u"
 #define LR_NEEDFILEPATH    true
 #define LR_BLOCKARCEXTRACT false
 #define LR_REQUIRESROM     false


fix encoding bug in codec

fix encoding bug in codec

Link: https://github.com/GeneAssembly/biosal/issues/540
Signed-off-by: Sébastien Boisvert <1a4d2e25eb5ba040b6ad5779a730a1a8a0ff9bc5@anl.gov>

--- genomics/data/dna_codec.c
+++ genomics/data/dna_codec.c
@@ -30,6 +30,8 @@
  * Fast implemention of reverse complement in place
  * in 2-bit format.
  */
+/*
+*/
 #define FAST_REVERSE_COMPLEMENT

 void bsal_dna_codec_init(struct bsal_dna_codec *self)
@@ -462,6 +464,7 @@
     char right_nucleotide;
     int tail;
     char blank;
+    int total_length;

     /* Abort if the 2 bit encoding is not being used.
      */
@@ -529,7 +532,16 @@
      * Fix the tail.
      */

-    tail = length_in_nucleotides % 4;
+    total_length = encoded_length * 4;
+
+    tail = total_length - length_in_nucleotides;
+
+#if 0
+    printf("length_in_nucleotides %d\n", length_in_nucleotides);
+
+    printf("Padding tail %d\n", tail);
+#endif
+
     if (tail != 0) {
         i = 0;
         blank = BSAL_NUCLEOTIDE_SYMBOL_A;


Added a blank line after the triple license header to match the output of the new oidgen.perl.

--- security/nss/lib/pki1/oiddata.c
+++ security/nss/lib/pki1/oiddata.c
@@ -34,6 +34,7 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
+
 #ifdef DEBUG
 static const char CVS_ID[] = "@(#) $RCSfile$ $Revision$ $Date$ ; @(#) $RCSfile$ $Revision$ $Date$";
 #endif /* DEBUG */


 Bug 493912 -  sqlite3_reset should be invoked in sdb_FindObjectsInit when error occurs

patch by Hiroyuki Ikezoe
reviewed by rrelyea

--- security/nss/lib/softoken/sdb.c
+++ security/nss/lib/softoken/sdb.c
@@ -731,6 +731,7 @@

 loser:
     if (findstmt) {
+	sqlite3_reset(stmt);
 	sqlite3_finalize(findstmt);
     }
     if (sqlDB) {


Fix Linux build

Fix Linux build

--- security/nss/lib/ssl/sslmutex.c
+++ security/nss/lib/ssl/sslmutex.c
@@ -203,17 +203,17 @@
         return single_process_sslMutex_Unlock(pMutex);
     }

-    if (pMutex->mPipes[2] != SSL_MUTEX_MAGIC) {
+    if (pMutex->u.pipeStr.mPipes[2] != SSL_MUTEX_MAGIC) {
 	PORT_SetError(PR_INVALID_ARGUMENT_ERROR);
 	return SECFailure;
     }
     /* Do Memory Barrier here. */
-    oldValue = PR_AtomicDecrement(&pMutex->nWaiters);
+    oldValue = PR_AtomicDecrement(&pMutex->u.pipeStr.nWaiters);
     if (oldValue > 1) {
 	int  cc;
 	char c  = 1;
 	do {
-	    cc = write(pMutex->mPipes[1], &c, 1);
+	    cc = write(pMutex->u.pipeStr.mPipes[1], &c, 1);
 	} while (cc < 0 && (errno == EINTR || errno == EAGAIN));
 	if (cc != 1) {
 	    if (cc < 0)
@@ -234,17 +234,17 @@
         return single_process_sslMutex_Lock(pMutex);
     }

-    if (pMutex->mPipes[2] != SSL_MUTEX_MAGIC) {
+    if (pMutex->u.pipeStr.mPipes[2] != SSL_MUTEX_MAGIC) {
 	PORT_SetError(PR_INVALID_ARGUMENT_ERROR);
 	return SECFailure;
     }
-    oldValue = PR_AtomicDecrement(&pMutex->nWaiters);
+    oldValue = PR_AtomicDecrement(&pMutex->u.pipeStr.nWaiters);
     /* Do Memory Barrier here. */
     if (oldValue > 0) {
 	int   cc;
 	char  c;
 	do {
-	    cc = read(pMutex->mPipes[0], &c, 1);
+	    cc = read(pMutex->u.pipeStr.mPipes[0], &c, 1);
 	} while (cc < 0 && errno == EINTR);
 	if (cc != 1) {
 	    if (cc < 0)


Bug 588698: SSL_DataPending only needs to get recvBufLock.  r=nelson.

--- security/nss/lib/ssl/sslsecur.c
+++ security/nss/lib/ssl/sslsecur.c
@@ -1358,16 +1358,9 @@
     ss = ssl_FindSocket(fd);

     if (ss && ss->opt.useSecurity) {
-
-	ssl_Get1stHandshakeLock(ss);
-	ssl_GetSSL3HandshakeLock(ss);
-
 	ssl_GetRecvBufLock(ss);
 	rv = ss->gs.writeOffset - ss->gs.readOffset;
 	ssl_ReleaseRecvBufLock(ss);
-
-	ssl_ReleaseSSL3HandshakeLock(ss);
-	ssl_Release1stHandshakeLock(ss);
     }

     return rv;


Added isOpen to display device.

Added isOpen to display device.

--- display/VRDisplayDevice.h
+++ display/VRDisplayDevice.h
@@ -11,6 +11,7 @@
 public:
 	virtual ~VRDisplayDevice() {}

+	virtual bool isOpen() = 0;
 	virtual void use() = 0;
 	virtual void release() = 0;
 	virtual void startRendering() = 0;


Reverting static thread_local member specifiers in cnn_scorer.

--- gninasrc/lib/cnn_scorer.h
+++ gninasrc/lib/cnn_scorer.h
@@ -54,9 +54,9 @@
     caffe::shared_ptr<boost::mutex> mtx; //todo, enable parallel scoring

     //scratch vectors to avoid memory reallocation
-    static thread_local vector<float3> gradient;
-    static thread_local vector<float4> atoms;
-    static thread_local vector<short> channels;
+    vector<float3> gradient;
+    vector<float4> atoms;
+    vector<short> channels;

 public:
     CNNScorer(): mgrid(NULL), rotations(0), outputdx(false), outputxyz(false), gradient_check(false), reset_center(true), mtx(new boost::mutex) {}


Fix layout of Addto panel dialog

Fix layout of Addto panel dialog

With the previous vbox, the list of applets was not being
expanded in the dialog box.  It was also redundant.

Signed-off-by: Germán Póo-Caamaño <679831b636f7f6776b5d7665ebec4c0074d994a9@gnome.org>

--- gnome-panel/panel-addto.c
+++ gnome-panel/panel-addto.c
@@ -1251,7 +1251,6 @@
 {
 	PanelAddtoDialog *dialog;
 	GtkWidget *dialog_vbox;
-	GtkWidget *vbox;
 	GtkWidget *inner_vbox;
 	GtkWidget *find_hbox;
 	GtkWidget *sw;
@@ -1294,19 +1293,16 @@
 	gtk_container_set_border_width (GTK_CONTAINER (dialog->addto_dialog), 5);

 	dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog->addto_dialog));
-	gtk_box_set_spacing (GTK_BOX (dialog_vbox), 2);
+	gtk_box_set_spacing (GTK_BOX (dialog_vbox), 12);
+	gtk_container_set_border_width (GTK_CONTAINER (dialog_vbox), 5);

 	g_signal_connect (G_OBJECT (dialog->addto_dialog), "response",
 			  G_CALLBACK (panel_addto_dialog_response), dialog);
 	g_signal_connect (dialog->addto_dialog, "destroy",
 			  G_CALLBACK (panel_addto_dialog_destroy), dialog);

-	vbox = gtk_vbox_new (FALSE, 12);
-	gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
-	gtk_container_add (GTK_CONTAINER (dialog_vbox), vbox);
-
 	inner_vbox = gtk_vbox_new (FALSE, 6);
-	gtk_box_pack_start (GTK_BOX (vbox), inner_vbox, TRUE, TRUE, 0);
+	gtk_box_pack_start (GTK_BOX (dialog_vbox), inner_vbox, TRUE, TRUE, 0);

 	find_hbox = gtk_hbox_new (FALSE, 6);
 	gtk_box_pack_start (GTK_BOX (inner_vbox), find_hbox, FALSE, FALSE, 0);
@@ -1388,7 +1384,7 @@

 	gtk_container_add (GTK_CONTAINER (sw), dialog->tree_view);

-	gtk_widget_show_all (vbox);
+	gtk_widget_show_all (dialog_vbox);

 	panel_toplevel_push_autohide_disabler (dialog->panel_widget->toplevel);
 	panel_widget_register_open_dialog (panel_widget,


QmlProfiler: Allow ranges starting at the exact same time

Previously, SortedTimelineModel could be confused by ranges starting at
the exact same time if they were inserted in the wrong order. With this
change the nesting calculation keeps track of that.

Change-Id: Id296a54eed7e1ab421e94a296ec4e30adce185f2
Reviewed-by: Kai Koehne <077bc265216106fb22408e62f2d97925ede69d10@digia.com>

--- src/plugins/qmlprofiler/sortedtimelinemodel.h
+++ src/plugins/qmlprofiler/sortedtimelinemodel.h
@@ -143,18 +143,38 @@
         QLinkedList<int> parents;
         for (int range = 0; range != count(); ++range) {
             Range &current = ranges[range];
-            for (QLinkedList<int>::iterator parent = parents.begin(); parent != parents.end();) {
-                qint64 parentEnd = ranges[*parent].start + ranges[*parent].duration;
+            for (QLinkedList<int>::iterator parentIt = parents.begin();;) {
+                Range &parent = ranges[*parentIt];
+                qint64 parentEnd = parent.start + parent.duration;
                 if (parentEnd < current.start) {
-                    parent = parents.erase(parent);
+                    if (parent.start == current.start) {
+                        if (parent.parent == -1) {
+                            parent.parent = range;
+                        } else {
+                            Range &ancestor = ranges[parent.parent];
+                            if (ancestor.start == current.start &&
+                                    ancestor.duration < current.duration)
+                                parent.parent = range;
+                        }
+                        // Just switch the old parent range for the new, larger one
+                        *parentIt = range;
+                        break;
+                    } else {
+                        parentIt = parents.erase(parentIt);
+                    }
                 } else if (parentEnd >= current.start + current.duration) {
-                    current.parent = *parent;
+                    // no need to insert
+                    current.parent = *parentIt;
                     break;
                 } else {
-                    ++parent;
+                    ++parentIt;
+                }
+
+                if (parentIt == parents.end()) {
+                    parents.append(range);
+                    break;
                 }
             }
-            parents.append(range);
         }
     }


Just ignore malformed locale variable unless -d specified

--- gnu/usr.bin/man/man/man.c
+++ gnu/usr.bin/man/man/man.c
@@ -479,18 +479,22 @@
 	    || tmp != short_locale + 2
 	    || strlen(tmp + 1) < 4
 	    || tmp[3] != '.') {
-		errno = EINVAL;
-		perror ("bad ctype locale env");
-		exit (1);
-	}
-	tmp[1] = short_locale[0];
-	tmp[2] = short_locale[1];
-	short_locale = tmp + 1;
-	tmp = short_locale + 3;
-	for (pltable = ltable; pltable->lcode != NULL; pltable++) {
-		if (strcmp(pltable->lcode, tmp) == 0) {
-			locale_nroff = pltable->nroff;
-			break;
+		if (debug) {
+			errno = EINVAL;
+			perror ("ctype locale env");
+		}
+		free(short_locale);
+		locale = NULL;
+	} else {
+		tmp[1] = short_locale[0];
+		tmp[2] = short_locale[1];
+		short_locale = tmp + 1;
+		tmp = short_locale + 3;
+		for (pltable = ltable; pltable->lcode != NULL; pltable++) {
+			if (strcmp(pltable->lcode, tmp) == 0) {
+				locale_nroff = pltable->nroff;
+				break;
+			}
 		}
 	}
   }


genmarshal: Conform --help output to conventions

The convention for arguments taking a value is:

  --argument=VALUE

with the `VALUE` in caps.

https://bugzilla.gnome.org/show_bug.cgi?id=781755

--- gobject/glib-genmarshal.c
+++ gobject/glib-genmarshal.c
@@ -1116,8 +1116,8 @@
       g_fprintf (bout, "Utility Options:\n");
       g_fprintf (bout, "  --header                   Generate C headers\n");
       g_fprintf (bout, "  --body                     Generate C code\n");
-      g_fprintf (bout, "  --prefix=string            Specify marshaller prefix\n");
-      g_fprintf (bout, "  --output=file              Write output into the specified file\n");
+      g_fprintf (bout, "  --prefix=STRING            Specify marshaller prefix\n");
+      g_fprintf (bout, "  --output=FILE              Write output into the specified file\n");
       g_fprintf (bout, "  --skip-source              Skip source location comments\n");
       g_fprintf (bout, "  --stdinc, --nostdinc       Include/use standard marshallers\n");
       g_fprintf (bout, "  --internal                 Mark generated functions as internal\n");


fixed compile error with gcc < 4.9.0

fixed compile error with gcc < 4.9.0

'no matching function for call to `std::vector<bool>::erase(const const_itr_t&) return container.erase(itr);`
vec.erase(vec.cbegin()); fails for unkown reason with this old version

--- src/rttr/detail/impl/sequential_mapper_impl.h
+++ src/rttr/detail/impl/sequential_mapper_impl.h
@@ -788,7 +788,15 @@

     static itr_t erase(container_t& container, const const_itr_t& itr)
     {
+// to prevent following gcc bug: 'no matching function for call to `std::vector<bool>::erase(const const_itr_t&) return container.erase(itr);`
+// vec.erase(vec.cbegin()); fails for unkown reason with this old version
+#if (RTTR_COMPILER == RTTR_COMPILER_GNUC && RTTR_COMP_VER < 4900)
+        auto itr_non_const = container.begin();
+        std::advance (itr_non_const, std::distance<const_itr_t>(itr_non_const, itr));
+        return container.erase(itr_non_const);
+#else
         return container.erase(itr);
+#endif
     }

     static itr_t insert(container_t& container, const value_t& value, const itr_t& itr_pos)


Fix add_force in Godot Physics RigidBody

Now takes the center of mass into account for calculating the applied
torque, like apply_impulse does.

--- servers/physics_3d/body_3d_sw.h
+++ servers/physics_3d/body_3d_sw.h
@@ -257,7 +257,7 @@
 	_FORCE_INLINE_ void add_force(const Vector3 &p_force, const Vector3 &p_pos) {

 		applied_force += p_force;
-		applied_torque += p_pos.cross(p_force);
+		applied_torque += (p_pos - center_of_mass).cross(p_force);
 	}

 	_FORCE_INLINE_ void add_torque(const Vector3 &p_torque) {


Cleaned up the header manipulation code in the ATS server module

--- servers/trafficserver/ironbee.c
+++ servers/trafficserver/ironbee.c
@@ -128,13 +128,13 @@
 #define START_RESPONSE 0x04
 #define DATA 0

-typedef struct hdr_do {
+typedef struct hdr_action_t {
     ib_server_header_action_t action;
     ib_server_direction_t dir;
-    char *hdr;
-    char *value;
-    struct hdr_do *next;
-} hdr_do;
+    const char *hdr;
+    const char *value;
+    struct hdr_action_t *next;
+} hdr_action_t;

 typedef struct hdr_list {
     char *hdr;
@@ -157,7 +157,7 @@
     ib_filter_ctx out;
     int state;
     int status;
-    hdr_do *hdr_actions;
+    hdr_action_t *hdr_actions;
     hdr_list *err_hdrs;
     char *err_body;    /* this one can't be const */
 } ib_txn_ctx;
@@ -168,7 +168,7 @@
 typedef struct {
     ib_server_direction_t dir;
     const char *word;
-    TSReturnCode (*hdr_get)(TSHttpTxn, TSMBuffer *, TSMLoc *);
+    TSReturnCode (*ts_hdr_get)(TSHttpTxn, TSMBuffer *, TSMLoc *);
     ib_status_t (*ib_notify_header)(ib_engine_t*, ib_tx_t*,
                  ib_parsed_header_wrapper_t*);
     ib_status_t (*ib_notify_header_finished)(ib_engine_t*, ib_tx_t*);
@@ -203,24 +203,6 @@
     ib_filter_ctx *data;
 } ibd_ctx;

-static void add_header_field(TSMBuffer bufp, TSMLoc hdr_loc,
-                             const char *field_name, const char *field_value)
-{
-    int rv;
-    TSMLoc field_loc;
-    rv = TSMimeHdrFieldCreate(bufp, hdr_loc, &field_loc);
-    if (rv != TS_SUCCESS) {
-        TSError("Failed to add MIME header field: %s", field_name);
-    }
-    rv = TSMimeHdrFieldNameSet(bufp, hdr_loc, field_loc,
-                               field_name, strlen(field_name));
-    rv = TSMimeHdrFieldValueStringSet(bufp, hdr_loc, field_loc, -1,
-                                      field_value, strlen(field_value));
-    rv = TSMimeHdrFieldAppend(bufp, hdr_loc, field_loc);
-    TSHandleMLocRelease(bufp, hdr_loc, field_loc);
-}
-
-
 /**
  * Callback functions for Ironbee to signal to us
  */
@@ -230,7 +212,7 @@
                                       void *cbdata)
 {
     ib_txn_ctx *ctx = (ib_txn_ctx *)tx->sctx;
-    hdr_do *header;
+    hdr_action_t *header;
     /* Logic for whether we're in time for the requested action */
     /* Output headers can change any time before they're sent */
     /* Input headers can only be touched during their read */
@@ -401,7 +383,7 @@
 static void ib_txn_ctx_destroy(ib_txn_ctx * data)
 {
     if (data) {
-        hdr_do *x;
+        hdr_action_t *x;
 //        TSDebug("ironbee", "TX DESTROY: conn=>%p tx=%p id=%s txn_count=%d", data->tx->conn, data->tx, data->tx->id, data->ssn->txn_count);
 //        ib_tx_destroy(data->tx);
 //        data->tx = NULL;
@@ -419,8 +401,8 @@
         }
         while (x=data->hdr_actions, x != NULL) {
             data->hdr_actions = x->next;
-            TSfree(x->hdr);
-            TSfree(x->value);
+            TSfree( (char *)x->hdr);
+            TSfree( (char *)x->value);
             TSfree(x);
         }
         /* Decrement the txn count on the ssn, and destroy ssn if it's closing */
@@ -913,6 +895,86 @@
     return rv;
 }

+static void header_action(TSMBuffer bufp,
+                          TSMLoc hdr_loc,
+                          const hdr_action_t *act)
+{
+    TSMLoc field_loc;
+    int rv;
+
+    switch (act->action) {
+
+    case IB_HDR_SET:  /* replace any previous instance == unset + add */
+    case IB_HDR_UNSET:  /* unset it */
+        TSDebug("ironbee", "Remove HTTP Header \"%s\"", act->hdr);
+        /* Use a while loop in case there are multiple instances */
+        while (field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, act->hdr,
+                                              strlen(act->hdr)),
+               field_loc != TS_NULL_MLOC) {
+            TSMimeHdrFieldDestroy(bufp, hdr_loc, field_loc);
+            TSHandleMLocRelease(bufp, hdr_loc, field_loc);
+        }
+        if (act->action == IB_HDR_UNSET)
+            break;
+        /* else fallthrough to ADD */
+
+    case IB_HDR_ADD:  /* add it in, regardless of whether it exists */
+add_hdr:
+        TSDebug("ironbee", "Add HTTP Header \"%s\"=\"%s\"",
+                act->hdr, act->value);
+        rv = TSMimeHdrFieldCreate(bufp, hdr_loc, &field_loc);
+        if (rv != TS_SUCCESS) {
+            TSError("Failed to add MIME header field \"%s\"", act->hdr);
+        }
+        rv = TSMimeHdrFieldNameSet(bufp, hdr_loc, field_loc,
+                                   act->hdr, strlen(act->hdr));
+        if (rv != TS_SUCCESS) {
+            TSError("Failed to set name of MIME header field \"%s\"",
+                    act->hdr);
+        }
+        rv = TSMimeHdrFieldValueStringSet(bufp, hdr_loc, field_loc, -1,
+                                          act->value, strlen(act->value));
+        if (rv != TS_SUCCESS) {
+            TSError("Failed to set value of MIME header field \"%s\"",
+                    act->hdr);
+        }
+        rv = TSMimeHdrFieldAppend(bufp, hdr_loc, field_loc);
+        if (rv != TS_SUCCESS) {
+            TSError("Failed to append MIME header field \"%s\"", act->hdr);
+        }
+        TSHandleMLocRelease(bufp, hdr_loc, field_loc);
+        break;
+
+    case IB_HDR_MERGE:  /* append UNLESS value already appears */
+        /* FIXME: implement this in full */
+        /* treat this as APPEND */
+
+    case IB_HDR_APPEND: /* append it to any existing instance */
+        TSDebug("ironbee", "Merge/Append HTTP Header \"%s\"=\"%s\"",
+                act->hdr, act->value);
+        field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, act->hdr,
+                                       strlen(act->hdr));
+        if (field_loc == TS_NULL_MLOC) {
+            /* this is identical to IB_HDR_ADD */
+            goto add_hdr;
+        }
+        /* This header exists, so append to it
+         * (the function is called Insert but actually appends
+         */
+        rv = TSMimeHdrFieldValueStringInsert(bufp, hdr_loc, field_loc, -1,
+                                             act->value, strlen(act->value));
+        if (rv != TS_SUCCESS) {
+            TSError("Failed to insert MIME header field \"%s\"", act->hdr);
+        }
+        TSHandleMLocRelease(bufp, hdr_loc, field_loc);
+        break;
+
+    default:  /* bug !! */
+        TSDebug("ironbee", "Bogus header action %d", act->action);
+        break;
+    }
+}
+
 /**
  * Process an HTTP header from ATS.
  *
@@ -924,18 +986,19 @@
  * @return OK (nothing to tell), Error (something bad happened),
  *         HTTP_STATUS (check data->status).
  */
-static ib_hdr_outcome process_hdr(ib_txn_ctx *data, TSHttpTxn txnp,
+static ib_hdr_outcome process_hdr(ib_txn_ctx *data,
+                                  TSHttpTxn txnp,
                                   ironbee_direction_t *ibd)
 {
     int rv;
     TSMBuffer bufp;
     TSMLoc hdr_loc;
-    TSMLoc field_loc;
     TSIOBuffer iobufp;
     TSIOBufferReader readerp;
     TSIOBufferBlock blockp;
     int64_t len;
-    hdr_do *hdr;
+    hdr_action_t *act;
+    hdr_action_t setact;
     const char *line, *lptr;
     size_t line_len = 0;
     ib_site_t *site;
@@ -946,7 +1009,7 @@

     ib_parsed_header_wrapper_t *ibhdrs;

-    TSDebug("ironbee", "process %s headers\n", ibd->word);
+    TSDebug("ironbee", "processing %s headers", ibd->word);

     /* Use alternative simpler path to get the un-doctored request
      * if we have the fix for TS-998
@@ -956,11 +1019,12 @@
      */
     /* We'll get a bogus URL from TS-998 */

-    rv = (*ibd->hdr_get)(txnp, &bufp, &hdr_loc);
+    rv = (*ibd->ts_hdr_get)(txnp, &bufp, &hdr_loc);
     if (rv) {
         TSError ("couldn't retrieve %s header: %d\n", ibd->word, rv);
         return HDR_ERROR;
     }
+
     if (ibd->dir == IBD_REQ) {
         ib_parsed_req_line_t *rline;
         int m_len;
@@ -1138,87 +1202,52 @@
         return HDR_HTTP_100;
     }

-    /* Now manipulate header as requested by ironbee */
-    for (hdr = data->hdr_actions; hdr != NULL; hdr = hdr->next) {
-        if (hdr->dir != ibd->dir)
-            continue;    /* it's not for us */
-
-        TSDebug("ironbee", "Manipulating HTTP headers");
-
-        switch (hdr->action) {
-            case IB_HDR_SET:  /* replace any previous instance == unset + add */
-            case IB_HDR_UNSET:  /* unset it */
-                TSDebug("ironbee", "Remove HTTP Header %s", hdr->hdr);
-                /* Use a while loop in case there are multiple instances */
-                while (field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, hdr->hdr,
-                                                      strlen(hdr->hdr)),
-                           field_loc != TS_NULL_MLOC) {
-                    TSMimeHdrFieldDestroy(bufp, hdr_loc, field_loc);
-                    TSHandleMLocRelease(bufp, hdr_loc, field_loc);
-                }
-                if (hdr->action == IB_HDR_UNSET)
-                    break;
-                /* else fallthrough to ADD */
-            case IB_HDR_ADD:  /* add it in, regardless of whether it exists */
-add_hdr:
-                TSDebug("ironbee", "Add HTTP Header %s=%s", hdr->hdr, hdr->value);
-                rv = TSMimeHdrFieldCreate(bufp, hdr_loc, &field_loc);
-                if (rv != TS_SUCCESS)
-                     TSError("Failed to add MIME header field");
-                rv = TSMimeHdrFieldNameSet(bufp, hdr_loc, field_loc,
-                                           hdr->hdr, strlen(hdr->hdr));
-                rv = TSMimeHdrFieldValueStringSet(bufp, hdr_loc, field_loc, -1,
-                                                  hdr->value, strlen(hdr->value));
-                rv = TSMimeHdrFieldAppend(bufp, hdr_loc, field_loc);
-                TSHandleMLocRelease(bufp, hdr_loc, field_loc);
-                break;
-            case IB_HDR_MERGE:  /* append UNLESS value already appears */
-                /* FIXME: implement this in full */
-                /* treat this as APPEND */
-            case IB_HDR_APPEND: /* append it to any existing instance */
-                TSDebug("ironbee", "Merge/Append HTTP Header %s=%s", hdr->hdr, hdr->value);
-                field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, hdr->hdr,
-                                               strlen(hdr->hdr));
-                if (field_loc == TS_NULL_MLOC) {
-                    /* this is identical to IB_HDR_ADD */
-                    goto add_hdr;
-                }
-                /* This header exists, so append to it
-                 * (the function is called Insert but actually appends
-                 */
-                rv = TSMimeHdrFieldValueStringInsert(bufp, hdr_loc, field_loc, -1,
-                                               hdr->value, strlen(hdr->value));
-                TSHandleMLocRelease(bufp, hdr_loc, field_loc);
-                break;
-            default:  /* bug !! */
-                TSDebug("ironbee", "Bogus header action %d", hdr->action);
-                break;
-        }
-    }
+    /* Initialize the header action */
+    setact.action = IB_HDR_SET;
+    setact.dir = ibd->dir;

     /* Add the ironbee site id to an internal header. */
     site = ib_context_site_get(data->tx->ctx);
     if (site != NULL) {
-        add_header_field(bufp, hdr_loc, "@IB-SITE-ID", site->id_str);
+        setact.hdr = "@IB-SITE-ID";
+        setact.value = site->id_str;
+        header_action(bufp, hdr_loc, &setact);
+    }
+    else {
+        TSDebug("ironbee", "No site available for @IB-SITE-ID");
+    }
+
+    /* Add internal header for effective IP address */
+    setact.hdr = "@IB-EFFECTIVE-IP";
+    setact.value = data->tx->er_ipstr;
+    header_action(bufp, hdr_loc, &setact);
+
+    /* Now manipulate header as requested by ironbee */
+    for (act = data->hdr_actions; act != NULL; act = act->next) {
+        if (act->dir != ibd->dir)
+            continue;    /* it's not for us */
+
+        TSDebug("ironbee", "Manipulating HTTP headers");
+        header_action(bufp, hdr_loc, act);
     }

     /* Add internal header if we blocked the transaction */
+    setact.hdr = "@IB-BLOCK-FLAG";
     if ((data->tx->flags & (IB_TX_BLOCK_PHASE|IB_TX_BLOCK_IMMEDIATE)) != 0) {
-        add_header_field(bufp, hdr_loc, "@IB-BLOCK-FLAG", "blocked");
+        setact.value = "blocked";
+        header_action(bufp, hdr_loc, &setact);
     }
     else if (data->tx->flags & IB_TX_BLOCK_ADVISORY) {
-        add_header_field(bufp, hdr_loc, "@IB-BLOCK-FLAG", "advisory");
-    }
-
-    /* Add internal header for effective IP address */
-    add_header_field(bufp, hdr_loc, "@IB-EFFECTIVE-IP", data->tx->er_ipstr);
+        setact.value = "advisory";
+        header_action(bufp, hdr_loc, &setact);
+    }

     TSHandleMLocRelease(bufp, TS_NULL_MLOC, hdr_loc);
     TSIOBufferReaderFree(readerp);
     TSIOBufferDestroy(iobufp);
     TSfree(icdatabuf);

-    return data->status == 0 ? HDR_OK : HDR_HTTP_STATUS;
+    return (data->status == 0) ? HDR_OK : HDR_HTTP_STATUS;
 }

 /**


Rename a couple variables and add crucial comments

--- src/strategies/avx2/encode_coding_tree-avx2.c
+++ src/strategies/avx2/encode_coding_tree-avx2.c
@@ -255,7 +255,7 @@
   uint8_t last_coeff_x = 0;
   uint8_t last_coeff_y = 0;
   int32_t i;
-  uint32_t sig_coeffgroup_flag[8 * 8] = { 0 };
+  uint32_t sig_coeffgroup_nzs[8 * 8] = { 0 };

   int8_t be_valid = encoder->cfg.signhide_enable;
   int32_t scan_pos_sig;
@@ -280,7 +280,7 @@
                                  &(cabac->ctx.cu_sig_model_chroma[0]);

   // Scan all coeff groups to find out which of them have coeffs.
-  // Populate sig_coeffgroup_flag with that info.
+  // Populate sig_coeffgroup_nzs with that info.

   // NOTE: Modified the functionality a bit, sig_coeffgroup_flag used to be
   // 1 if true and 0 if false, now it's "undefined but nonzero" if true and
@@ -298,7 +298,7 @@
     const uint32_t cg_pos = cg_y * width * 4 + cg_x * 4;
     const uint32_t cg_pos_y = (cg_pos >> log2_block_size) >> TR_MIN_LOG2_SIZE;
     const uint32_t cg_pos_x = (cg_pos & (width - 1)) >> TR_MIN_LOG2_SIZE;
-    const uint32_t addr = cg_pos_x + cg_pos_y * num_blk_side;
+    const uint32_t idx = cg_pos_x + cg_pos_y * num_blk_side;

     __m128d coeffs_d_upper = _mm_setzero_pd();
     __m128d coeffs_d_lower = _mm_setzero_pd();
@@ -321,7 +321,7 @@
     __m256i coeffs_zero = _mm256_cmpeq_epi16(cur_coeffs, zero);

     uint32_t nz_coeffs_2b = ~((uint32_t)_mm256_movemask_epi8(coeffs_zero));
-    sig_coeffgroup_flag[addr] = nz_coeffs_2b;
+    sig_coeffgroup_nzs[idx] = nz_coeffs_2b;

     if (nz_coeffs_2b)
       scan_cg_last = i;
@@ -340,7 +340,13 @@
       _mm256_store_si256((__m256i *)(coeff_reord + subpos), coeffs_r);
     }

-    // Find the last coeff by going backwards in scan order.
+    // Find the last coeff by going backwards in scan order. With cmpeq_epi16
+    // and movemask, we can generate a dword with 16 2-bit masks that are 11
+    // for zero words in the coeff vector, and 00 for nonzero words. By
+    // inverting the bits and counting leading zeros, we can determine the
+    // number of zero bytes in the vector counting from high to low memory
+    // addresses; subtract that from 31 and divide by 2 to get the offset of
+    // the last nonzero word.
     uint32_t baseaddr = scan_cg_last * 16;
     __m256i cur_coeffs_zeros = _mm256_cmpeq_epi16(coeffs_r, zero);
     uint32_t nz_bytes = ~(_mm256_movemask_epi8(cur_coeffs_zeros));
@@ -391,20 +397,22 @@
     go_rice_param = 0;

     if (i == scan_cg_last || i == 0) {
-      sig_coeffgroup_flag[cg_blk_pos] = 1;
+      sig_coeffgroup_nzs[cg_blk_pos] = 1;
     } else {
-      uint32_t sig_coeff_group   = (sig_coeffgroup_flag[cg_blk_pos] != 0);
-      uint32_t ctx_sig  = kvz_context_get_sig_coeff_group(sig_coeffgroup_flag, cg_pos_x,
+      uint32_t sig_coeff_group   = (sig_coeffgroup_nzs[cg_blk_pos] != 0);
+      uint32_t ctx_sig  = kvz_context_get_sig_coeff_group(sig_coeffgroup_nzs, cg_pos_x,
                                                       cg_pos_y, width);
       cabac->cur_ctx = &base_coeff_group_ctx[ctx_sig];
       CABAC_BIN(cabac, sig_coeff_group, "coded_sub_block_flag");
     }

-    if (sig_coeffgroup_flag[cg_blk_pos]) {
-      int32_t pattern_sig_ctx = kvz_context_calc_pattern_sig_ctx(sig_coeffgroup_flag,
+    if (sig_coeffgroup_nzs[cg_blk_pos]) {
+      int32_t pattern_sig_ctx = kvz_context_calc_pattern_sig_ctx(sig_coeffgroup_nzs,
                                                              cg_pos_x, cg_pos_y, width);

+      // A mask with the first 16-bit word unmasked (bits set ie. 0xffff)
       const __m256i coeff_pos_zero = _mm256_castsi128_si256(_mm_cvtsi32_si128(0xffff));
+
       const __m128i log2_block_size_128 = _mm_cvtsi32_si128(log2_block_size);

       __m256i coeffs = _mm256_load_si256((__m256i *)(coeff_reord + sub_pos));


tracker-writeback: Set manual white-balance value correctly

--- src/tracker-writeback/tracker-writeback-xmp.c
+++ src/tracker-writeback/tracker-writeback-xmp.c
@@ -304,7 +304,7 @@
 				 * 1 = Manual white balance */
 				xmp_set_property (xmp, NS_EXIF, "WhiteBalance", "0", 0);
 			} else {
-				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "1", 0);
+				xmp_set_property (xmp, NS_EXIF, "WhiteBalance", "1", 0);
 			}
 		}


Cleanup: only skip loading the IRT if explicitly given an irt_fd that is -1.

No need to check the segment gap anymore after:
https://codereview.chromium.org/11761025

BUG= http://code.google.com/p/nativeclient/issues/detail?id=3241
TEST= patch into chrome, run nacl_integration with bitcode=1

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

git-svn-id: 721b910a23eff8a86f00c8fd261a7587cddf18f8@10591 fcba33aa-ac0c-11dd-b9e7-8d5594d729c2

--- src/trusted/service_runtime/sel_main_chrome.c
+++ src/trusted/service_runtime/sel_main_chrome.c
@@ -308,19 +308,9 @@

   /*
    * Load the integrated runtime (IRT) library.
-   * We check if there is a segment gap before trying to load the IRT.  This
-   * is to support IRT-less / segment-gap-free PNaCl translator nexes.
-   * TODO(jvoung): Instead of looking for the absence of a segment gap,
-   * only allow irt_fd == -1, when the nexe does not follow NaCl's stable ABI.
-   */
-  if (NULL != nap->text_shm && args->irt_fd != -1) {
+   */
+  if (args->irt_fd != -1) {
     NaClLoadIrt(nap, args->irt_fd);
-  } else {
-    NaClLog(
-        1,
-        "Main executable has no segment gap or irt_fd == -1; "
-        "skipping loading IRT library. This is expected for PNaCl's "
-        "translator nexes.\n");
   }

   NACL_FI_FATAL("BeforeEnvCleanserCtor");


Add compressed SIDH and big endian support

--- src/P434/P434_compressed_api.h
+++ src/P434/P434_compressed_api.h
@@ -13,7 +13,7 @@
 #define CRYPTO_SECRETKEYBYTES     350      // MSG_BYTES + SECRETKEY_A_BYTES + CRYPTO_PUBLICKEYBYTES + FP2_ENCODED_BYTES bytes
 #define CRYPTO_PUBLICKEYBYTES     197      // 3*ORDER_B_ENCODED_BYTES + FP2_ENCODED_BYTES + 3 bytes for shared elligator
 #define CRYPTO_BYTES               16
-#define CRYPTO_CIPHERTEXTBYTES    236     // PARTIALLY_COMPRESSED_CHUNK_CT + MSG_BYTES bytes
+#define CRYPTO_CIPHERTEXTBYTES    236      // PARTIALLY_COMPRESSED_CHUNK_CT + MSG_BYTES bytes

 // Algorithm name
 #define CRYPTO_ALGNAME "SIKEp434_compressed"
@@ -35,7 +35,6 @@
 //          ciphertext message ct (CRYPTO_CIPHERTEXTBYTES = 236 bytes)
 // Outputs: shared secret ss      (CRYPTO_BYTES = 16 bytes)
 int crypto_kem_dec_SIKEp434_compressed(unsigned char *ss, const unsigned char *ct, const unsigned char *sk);
-

 // Encoding of keys for KEM-based isogeny system "SIKEp434_compressed" (wire format):
@@ -73,7 +72,7 @@
 // Alice's ephemeral public key generation
 // Input:  a private key PrivateKeyA in the range [0, 2^216 - 1], stored in 27 bytes.
 // Output: the public key PublicKeyA consisting of 3 values of length OALICE_BITS, one element in GF(p434^2) and 2 bytes encoded in 197 bytes.
-int EphemeralKeyGeneration_A_SIDHp434_Compressed(unsigned char* PrivateKeyA, unsigned char* PublicKeyA);
+int EphemeralKeyGeneration_A_SIDHp434_Compressed(const unsigned char* PrivateKeyA, unsigned char* PublicKeyA);

 // Bob's ephemeral key-pair generation
 // It produces a private key PrivateKeyB and computes the public key PublicKeyB.
@@ -86,7 +85,7 @@
 // Inputs: Alice's PrivateKeyA is an integer in the range [0, 2^216 - 1], stored in 27 bytes.
 //         Bob's PublicKeyB consists of 3 values of length OALICE_BITS, one element in GF(p434^2) and 2 bytes encoded in 197 bytes.
 // Output: a shared secret SharedSecretA that consists of one element in GF(p434^2) encoded in 110 bytes.
-int EphemeralSecretAgreement_A_SIDHp434_Compressed(const unsigned char* PrivateKeyA, const unsigned char* PublicKeyB, unsigned char* SharedSecretA, unsigned char* phiBKA_t);
+int EphemeralSecretAgreement_A_SIDHp434_Compressed(const unsigned char* PrivateKeyA, const unsigned char* PublicKeyB, unsigned char* SharedSecretA);

 // Bob's ephemeral shared secret computation
 // It produces a shared secret key SharedSecretB using his secret key PrivateKeyB and Alice's public key PublicKeyA


Wallpaper 2: always showing theme default.

--- src/wallpaperapplet2/wallpaperconfiguration.h
+++ src/wallpaperapplet2/wallpaperconfiguration.h
@@ -54,7 +54,7 @@
      * Stuff for the default wallpaper image, the image file that is stored in
      * the theme directory.
      */
-    const bool showThemeDefault (false);
+    const bool showThemeDefault (true);
     const QString CurrentPortraitDefault ("meegotouch-wallpaper-portrait");

     const QString themeNameKey ("/meegotouch/theme/name");


some change.

some change.

--- arduino/opencr_arduino/opencr/variants/OpenCR/hw/driver/vcp.c
+++ arduino/opencr_arduino/opencr/variants/OpenCR/hw/driver/vcp.c
@@ -52,12 +52,14 @@

 uint8_t vcp_getch(void)
 {
+#if 1
+  return CDC_Itf_Getch();
+#else
   /* for debugging */
-  //uint8_t ch = CDC_Itf_Getch();
-  //drv_uart_write(DRV_UART_NUM_4, ch);
-  //return ch;
-
-  return CDC_Itf_Getch();
+  uint8_t ch = CDC_Itf_Getch();
+  drv_uart_write(DRV_UART_NUM_4, ch);
+  return ch;
+#endif
 }


fix heritage

fix heritage

--- element.h
+++ element.h
@@ -4,11 +4,11 @@
 #include <vector>
 #include <string>

-#include "base.h"
+#include "content.h"

 class Attribute;

-class Element: public Base {
+class Element: public Content {
   public:
     typedef std::vector<Attribute *> attribute_list;


riscv: more insns

riscv: more insns

* register indirect loads and stores
* load of local addresses
* indirect calls (uses ra as temporary reg if necessary)
* operations *, -, <<
* gen_cvt_sxtw: is not needed in most cases, let's see

tests2 runs until (incl) 09_do_while.

--- riscv64-gen.c
+++ riscv64-gen.c
@@ -32,6 +32,8 @@
 #include <assert.h>

 #define XLEN 8
+
+#define TREG_RA 17

 ST_DATA const int reg_classes[NB_REGS] = {
   RC_INT | RC_R(0),
@@ -54,13 +56,15 @@

 static int ireg(int r)
 {
+    if (r == TREG_RA)
+      return 1; // ra
     assert(r >= 0 && r < 8);
     return r + 10;  // tccrX --> aX == x(10+X)
 }

 static int is_ireg(int r)
 {
-    return r < 8;
+    return r < 8 || r == TREG_RA;
 }

 static int is_freg(int r)
@@ -121,20 +125,22 @@
     int rr = ireg(r);
     int fc = sv->c.i;
     if (fr & VT_LVAL) {
+        int bt = sv->type.t & VT_BTYPE;
+        int align, size = type_size(&sv->type, &align);
+        int func3;
+        if (is_float(bt))
+          tcc_error("unimp: load-local(float)");
+        else if (bt == VT_FUNC)
+          size = PTR_SIZE;
+        func3 = size == 1 ? 0 : size == 2 ? 1 : size == 4 ? 2 : 3;
+        if (size < 8 && (sv->type.t & VT_UNSIGNED))
+          func3 |= 4;
         if (v == VT_LOCAL) {
-            int bt = sv->type.t & VT_BTYPE;
-            int align, size = type_size(&sv->type, &align);
-            int func3;
             if (((unsigned)fc + (1 << 11)) >> 12)
               tcc_error("unimp: load(large local ofs) (0x%x)", fc);
-            if (is_float(bt))
-              tcc_error("unimp: load-local(float)");
-            else if (bt == VT_FUNC)
-              size = PTR_SIZE;
-            func3 = size == 1 ? 0 : size == 2 ? 1 : size == 4 ? 2 : 3;
-            if (size < 8 && (sv->type.t & VT_UNSIGNED))
-              func3 |= 4;
             EI(0x03, func3, rr, 8, fc); // l[bhwd][u] RR, fc(s0)
+        } else if (v < VT_CONST) {
+            EI(0x03, func3, rr, ireg(v), 0); // l[bhwd][u] RR, 0(V)
         } else {
             tcc_error("unimp: load(non-local lval)");
         }
@@ -162,6 +168,10 @@
         if (is_float(sv->type.t))
           tcc_error("unimp: load(float)");
         EI(0x13, 0, rr, rb, fc);      // addi R, x0|R, FC
+    } else if (v == VT_LOCAL) {
+        if (((unsigned)fc + (1 << 11)) >> 12)
+          tcc_error("unimp: load(addr large local ofs) (0x%x)", fc);
+        EI(0x13, 0, rr, 8, fc); // addi R, s0, FC
     } else if (v < VT_CONST) {
         /* reg-reg */
         if (is_freg(r) && is_freg(v))
@@ -195,6 +205,10 @@
           tcc_error("unimp: large sized store");
         ES(0x23, size == 1 ? 0 : size == 2 ? 1 : size == 4 ? 2 : 3,
            8, rr, fc); // s[bhwd] RR, fc(s0)
+    } else if (fr < VT_CONST) {
+        int ptrreg = ireg(fr);
+        ES(0x23, size == 1 ? 0 : size == 2 ? 1 : size == 4 ? 2 : 3,
+           ptrreg, rr, 0); // s[bhwd] RR, 0(PTRREG)
     } else
       tcc_error("implement me: %s(!local)", __FUNCTION__);
 }
@@ -208,8 +222,14 @@
                 R_RISCV_CALL_PLT, (int)vtop->c.i);
         o(0x17 | (1 << 7));   // auipc ra, 0 %call(func)
         o(0x80e7);             // jalr  ra, 0 %call(func)
+    } else if ((vtop->r & VT_VALMASK) < VT_CONST) {
+        int r = ireg(vtop->r & VT_VALMASK);
+        EI(0x67, 0, 1, r, 0);      // jalr ra, 0(R)
     } else {
-        tcc_error("unimp: indirect call");
+        int r = TREG_RA;
+        load(r, vtop);
+        r = ireg(r);
+        EI(0x67, 0, 1, r, 0);      // jalr ra, 0(R)
     }
 }

@@ -401,6 +421,7 @@
 {
     int a, b, d;
     int inv = 0;
+    int func3 = 0, func7 = 0;
     /* XXX We could special-case some constant args.  */
     gv2(RC_INT, RC_INT);
     a = ireg(vtop[-1].r);
@@ -413,13 +434,10 @@
     switch (op) {
     case '%':
     case '&':
-    case '*':
-    case '-':
     case '/':
     case '^':
     case '|':
     case TOK_SAR:
-    case TOK_SHL:
     case TOK_SHR:
     case TOK_UDIV:
     case TOK_PDIV:
@@ -429,6 +447,15 @@

     case '+':
         o(0x33 | (d << 7) | (a << 15) | (b << 20)); // add d, a, b
+        break;
+    case '-':
+        o(0x33 | (d << 7) | (a << 15) | (b << 20) | (0x20 << 25)); //sub d, a, b
+        break;
+    case TOK_SHL:
+        o(0x33 | (d << 7) | (a << 15) | (b << 20) | (1 << 12)); //sll d, a, b
+        break;
+    case '*':
+        o(0x33 | (d << 7) | (a << 15) | (b << 20) | (0x01 << 25)); //mul d, a, b
         break;

     case TOK_ULT:
@@ -483,7 +510,8 @@

 ST_FUNC void gen_cvt_sxtw(void)
 {
-    tcc_error("implement me: %s", __FUNCTION__);
+    /* XXX on risc-v the registers are usually sign-extended already.
+       Let's try to not do anything here.  */
 }

 ST_FUNC void gen_cvt_itof(int t)


ESP8266 header fix

ESP8266 header fix

--- esp8266.c
+++ esp8266.c
@@ -5,6 +5,7 @@
 #ifdef ESP8266

 #include <Arduino.h>
+#include <eagle_soc.h>

 static uint32_t _getCycleCount(void) __attribute__((always_inline));
 static inline uint32_t _getCycleCount(void) {


issue #163: remove dangling temp file so collections can be created

--- arangod/VocBase/vocbase.c
+++ arangod/VocBase/vocbase.c
@@ -1554,11 +1554,23 @@
   // .............................................................................

   else if (collection->_status == TRI_VOC_COL_STATUS_UNLOADED) {
+    char* tmpFile;
+
     res = TRI_LoadParameterInfoCollection(collection->_path, &info);

     if (res != TRI_ERROR_NO_ERROR) {
       TRI_WRITE_UNLOCK_STATUS_VOCBASE_COL(collection);
       return TRI_set_errno(res);
+    }
+
+    // remove dangling .json.tmp file if it exists
+    tmpFile = TRI_Concatenate4String(collection->_path, "/", TRI_COL_PARAMETER_FILE, ".tmp");
+    if (tmpFile != NULL) {
+      if (TRI_ExistsFile(tmpFile)) {
+        TRI_UnlinkFile(tmpFile);
+        LOG_WARNING("removing dangling temporary file '%s'", tmpFile);
+      }
+      TRI_FreeString(TRI_CORE_MEM_ZONE, tmpFile);
     }

     if (! info._deleted) {


ARM: io: ensure inb/outb() et.al. are properly ordered on ARMv6+

Ensure that the ISA/PCI IO space accessors are properly ordered on
ARMv6+ architectures.  These should always be ordered with respect to
all other accesses.

This also fixes __iormb() and __iowmb() not being visible to ioread/
iowrite if a platform defines its own MMIO accessors.

Signed-off-by: Russell King <f6aa0246ff943bfa8602cdf60d40c481b38ed232@arm.linux.org.uk>

--- arch/arm/include/asm/io.h
+++ arch/arm/include/asm/io.h
@@ -95,6 +95,15 @@
 	return (void __iomem *)addr;
 }

+/* IO barriers */
+#ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE
+#define __iormb()		rmb()
+#define __iowmb()		wmb()
+#else
+#define __iormb()		do { } while (0)
+#define __iowmb()		do { } while (0)
+#endif
+
 /*
  * Now, pick up the machine-defined IO definitions
  */
@@ -125,17 +134,17 @@
  * The {in,out}[bwl] macros are for emulating x86-style PCI/ISA IO space.
  */
 #ifdef __io
-#define outb(v,p)		__raw_writeb(v,__io(p))
-#define outw(v,p)		__raw_writew((__force __u16) \
-					cpu_to_le16(v),__io(p))
-#define outl(v,p)		__raw_writel((__force __u32) \
-					cpu_to_le32(v),__io(p))
-
-#define inb(p)	({ __u8 __v = __raw_readb(__io(p)); __v; })
+#define outb(v,p)	({ __iowmb(); __raw_writeb(v,__io(p)); })
+#define outw(v,p)	({ __iowmb(); __raw_writew((__force __u16) \
+					cpu_to_le16(v),__io(p)); })
+#define outl(v,p)	({ __iowmb(); __raw_writel((__force __u32) \
+					cpu_to_le32(v),__io(p)); })
+
+#define inb(p)	({ __u8 __v = __raw_readb(__io(p)); __iormb(); __v; })
 #define inw(p)	({ __u16 __v = le16_to_cpu((__force __le16) \
-			__raw_readw(__io(p))); __v; })
+			__raw_readw(__io(p))); __iormb(); __v; })
 #define inl(p)	({ __u32 __v = le32_to_cpu((__force __le32) \
-			__raw_readl(__io(p))); __v; })
+			__raw_readl(__io(p))); __iormb(); __v; })

 #define outsb(p,d,l)		__raw_writesb(__io(p),d,l)
 #define outsw(p,d,l)		__raw_writesw(__io(p),d,l)
@@ -192,14 +201,6 @@
 #define writel_relaxed(v,c)	((void)__raw_writel((__force u32) \
 					cpu_to_le32(v),__mem_pci(c)))

-#ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE
-#define __iormb()		rmb()
-#define __iowmb()		wmb()
-#else
-#define __iormb()		do { } while (0)
-#define __iowmb()		do { } while (0)
-#endif
-
 #define readb(c)		({ u8  __v = readb_relaxed(c); __iormb(); __v; })
 #define readw(c)		({ u16 __v = readw_relaxed(c); __iormb(); __v; })
 #define readl(c)		({ u32 __v = readl_relaxed(c); __iormb(); __v; })


Endian neutral join keys for rpmdbAdd() and rpmdbRemove().

--- rpmdb/rpmdb.c
+++ rpmdb/rpmdb.c
@@ -2538,6 +2538,7 @@
 DBC * dbcursor = NULL;
 DBT * key = alloca(sizeof(*key));
 DBT * data = alloca(sizeof(*data));
+union _dbswap mi_offset;
     HGE_t hge = (HGE_t)headerGetEntryMinMemory;
     HFD_t hfd = headerFreeData;
     Header h;
@@ -2615,9 +2616,12 @@
 		    continue;

 /*@-immediatetrans@*/
-		key->data = &hdrNum;
+mi_offset.ui = hdrNum;
+if (dbiByteSwapped(dbi) == 1)
+    _DBSWAP(mi_offset);
+		key->data = &mi_offset;
 /*@=immediatetrans@*/
-		key->size = sizeof(hdrNum);
+		key->size = sizeof(mi_offset.ui);

 		rc = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, DB_WRITECURSOR);
 		rc = dbiGet(dbi, dbcursor, key, data, DB_SET);
@@ -2852,6 +2856,7 @@
     int count = 0;
     dbiIndex dbi;
     int dbix;
+    union _dbswap mi_offset;
     unsigned int hdrNum = 0;
     int ret = 0;
     int rc;
@@ -2924,14 +2929,21 @@

 /*@-bounds@*/
 	hdrNum = 0;
-	if (ret == 0 && datap)
-	    memcpy(&hdrNum, datap, sizeof(hdrNum));
+	if (ret == 0 && datap) {
+	    memcpy(&mi_offset, datap, sizeof(mi_offset.ui));
+	    if (dbiByteSwapped(dbi) == 1)
+		_DBSWAP(mi_offset);
+	    hdrNum = mi_offset.ui;
+	}
 	++hdrNum;
+	mi_offset.ui = hdrNum;
+	if (dbiByteSwapped(dbi) == 1)
+	    _DBSWAP(mi_offset);
 	if (ret == 0 && datap) {
-	    memcpy(datap, &hdrNum, sizeof(hdrNum));
+	    memcpy(datap, &mi_offset, sizeof(mi_offset.ui));
 	} else {
-	    datap = &hdrNum;
-	    datalen = sizeof(hdrNum);
+	    datap = &mi_offset;
+	    datalen = sizeof(mi_offset.ui);
 	}
 /*@=bounds@*/

@@ -3003,8 +3015,11 @@
 		    continue;
 		xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, DB_WRITECURSOR);

-key->data = (void *) &hdrNum;
-key->size = sizeof(hdrNum);
+mi_offset.ui = hdrNum;
+if (dbiByteSwapped(dbi) == 1)
+    _DBSWAP(mi_offset);
+key->data = (void *) &mi_offset;
+key->size = sizeof(mi_offset.ui);
 data->data = headerUnload(h);
 data->size = headerSizeof(h, HEADER_MAGIC_NO);

@@ -3750,7 +3765,6 @@
 	rpmdbMatchIterator mi;
 #define	_RECNUM	rpmdbGetIteratorOffset(mi)

-	/* RPMDBI_PACKAGES */
 	mi = rpmdbInitIterator(olddb, RPMDBI_PACKAGES, NULL, 0);
 	if (ts && hdrchk)
 	    (void) rpmdbSetHdrChk(mi, ts, hdrchk);


[ARM] i.MX: add missing clock functions exports

Export missing Clock API symbols.

Signed-off-by: Paulius Zaleckas <c59c332b61c0401f49d806e6931557f8bdeeaad8@teltonika.lt>
Signed-off-by: Sascha Hauer <c00cbc2b736c26791a3822db86f8796fe9efff67@pengutronix.de>

--- arch/arm/mach-imx/clock.c
+++ arch/arm/mach-imx/clock.c
@@ -172,24 +172,29 @@

 	return clk;
 }
+EXPORT_SYMBOL(clk_get);

 void clk_put(struct clk *clk)
 {
 }
+EXPORT_SYMBOL(clk_put);

 int clk_enable(struct clk *clk)
 {
 	return 0;
 }
+EXPORT_SYMBOL(clk_enable);

 void clk_disable(struct clk *clk)
 {
 }
+EXPORT_SYMBOL(clk_disable);

 unsigned long clk_get_rate(struct clk *clk)
 {
 	return clk->get_rate();
 }
+EXPORT_SYMBOL(clk_get_rate);

 int imx_clocks_init(void)
 {


arm: omap: irq: call set_handle_irq() from .init_irq

the idea is that board-files won't need to set
.handle_irq on their machine_descs, which lets
us drop a little more pointless code.

Signed-off-by: Felipe Balbi <94dddeeef08b001e003cce128ddc162a4e2c6cd2@ti.com>
Signed-off-by: Tony Lindgren <1001e8702733cced254345e193c88aaa47a4f5de@atomide.com>


ARM: zynq: Drop use of slcr_unlock in zynq_slcr_system_restart

The SLCR is unconditionally unlocked early on boot in zynq_slcr_init()
and not ever re-locked. As such, it is not necessary to explicitly unlock in
the restart codepath.

Signed-off-by: Josh Cartwright <8ab3595d4bac68c19ea44f183d51b50908f1de91@ni.com>
Signed-off-by: Michal Simek <b20e59da6aeb5cea6c82b021069d69f63616c55d@xilinx.com>


ARM: zynq: Hang iomapped slcr address on device_node

For later usage by zynq clk driver.

Signed-off-by: Steffen Trumtrar <acd73cdea7391c1e626e2d4b16b2f41438ca5396@pengutronix.de>
Signed-off-by: Michal Simek <b20e59da6aeb5cea6c82b021069d69f63616c55d@xilinx.com>


ARM: dma-api: fix off-by-one error in __dma_supported()

When validating the mask against the amount of memory we have available
(so that we can trap 32-bit DMA addresses with >32-bits memory), we had
not taken account of the fact that max_pfn is the maximum PFN number
plus one that would be in the system.

There are several references in the code which bear this out:

mm/page_owner.c:
	for (; pfn < max_pfn; pfn++) {
	}

arch/x86/kernel/setup.c:
	high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1)

Signed-off-by: Russell King <f6aa0246ff943bfa8602cdf60d40c481b38ed232@arm.linux.org.uk>


ARM: DMA mapping: fix bad atomic test

ARM: DMA mapping: fix bad atomic test

Realview fails to boot with this warning:
BUG: spinlock lockup suspected on CPU#0, init/1
 lock: 0xcf8bde10, .magic: dead4ead, .owner: init/1, .owner_cpu: 0
Backtrace:
[<c00185d8>] (dump_backtrace+0x0/0x10c) from [<c03294e8>] (dump_stack+0x18/0x1c) r6:cf8bde10 r5:cf83d1c0 r4:cf8bde10 r3:cf83d1c0
[<c03294d0>] (dump_stack+0x0/0x1c) from [<c018926c>] (spin_dump+0x84/0x98)
[<c01891e8>] (spin_dump+0x0/0x98) from [<c0189460>] (do_raw_spin_lock+0x100/0x198)
[<c0189360>] (do_raw_spin_lock+0x0/0x198) from [<c032cbac>] (_raw_spin_lock+0x3c/0x44)
[<c032cb70>] (_raw_spin_lock+0x0/0x44) from [<c01c9224>] (pl011_console_write+0xe8/0x11c)
[<c01c913c>] (pl011_console_write+0x0/0x11c) from [<c002aea8>] (call_console_drivers.clone.7+0xdc/0x104)
[<c002adcc>] (call_console_drivers.clone.7+0x0/0x104) from [<c002b320>] (console_unlock+0x2e8/0x454)
[<c002b038>] (console_unlock+0x0/0x454) from [<c002b8b4>] (vprintk_emit+0x2d8/0x594)
[<c002b5dc>] (vprintk_emit+0x0/0x594) from [<c0329718>] (printk+0x3c/0x44)
[<c03296dc>] (printk+0x0/0x44) from [<c002929c>] (warn_slowpath_common+0x28/0x6c)
[<c0029274>] (warn_slowpath_common+0x0/0x6c) from [<c0029304>] (warn_slowpath_null+0x24/0x2c)
[<c00292e0>] (warn_slowpath_null+0x0/0x2c) from [<c0070ab0>] (lockdep_trace_alloc+0xd8/0xf0)
[<c00709d8>] (lockdep_trace_alloc+0x0/0xf0) from [<c00c0850>] (kmem_cache_alloc+0x24/0x11c)
[<c00c082c>] (kmem_cache_alloc+0x0/0x11c) from [<c00bb044>] (__get_vm_area_node.clone.24+0x7c/0x16c)
[<c00bafc8>] (__get_vm_area_node.clone.24+0x0/0x16c) from [<c00bb7b8>] (get_vm_area_caller+0x48/0x54)
[<c00bb770>] (get_vm_area_caller+0x0/0x54) from [<c0020064>] (__alloc_remap_buffer.clone.15+0x38/0xb8)
[<c002002c>] (__alloc_remap_buffer.clone.15+0x0/0xb8) from [<c0020244>] (__dma_alloc+0x160/0x2c8)
[<c00200e4>] (__dma_alloc+0x0/0x2c8) from [<c00204d8>] (arm_dma_alloc+0x88/0xa0)[<c0020450>] (arm_dma_alloc+0x0/0xa0) from [<c00beb00>] (dma_pool_alloc+0xcc/0x1a8)
[<c00bea34>] (dma_pool_alloc+0x0/0x1a8) from [<c01a9d14>] (pl08x_fill_llis_for_desc+0x28/0x568)
[<c01a9cec>] (pl08x_fill_llis_for_desc+0x0/0x568) from [<c01aab8c>] (pl08x_prep_slave_sg+0x258/0x3b0)
[<c01aa934>] (pl08x_prep_slave_sg+0x0/0x3b0) from [<c01c9f74>] (pl011_dma_tx_refill+0x140/0x288)
[<c01c9e34>] (pl011_dma_tx_refill+0x0/0x288) from [<c01ca748>] (pl011_start_tx+0xe4/0x120)
[<c01ca664>] (pl011_start_tx+0x0/0x120) from [<c01c54a4>] (__uart_start+0x48/0x4c)
[<c01c545c>] (__uart_start+0x0/0x4c) from [<c01c632c>] (uart_start+0x2c/0x3c)
[<c01c6300>] (uart_start+0x0/0x3c) from [<c01c795c>] (uart_write+0xcc/0xf4)
[<c01c7890>] (uart_write+0x0/0xf4) from [<c01b0384>] (n_tty_write+0x1c0/0x3e4)
[<c01b01c4>] (n_tty_write+0x0/0x3e4) from [<c01acfe8>] (tty_write+0x144/0x240)
[<c01acea4>] (tty_write+0x0/0x240) from [<c01ad17c>] (redirected_tty_write+0x98/0xac)
[<c01ad0e4>] (redirected_tty_write+0x0/0xac) from [<c00c371c>] (vfs_write+0xbc/0x150)
[<c00c3660>] (vfs_write+0x0/0x150) from [<c00c39c0>] (sys_write+0x4c/0x78)
[<c00c3974>] (sys_write+0x0/0x78) from [<c0014460>] (ret_fast_syscall+0x0/0x3c)

This happens because the DMA allocation code is not respecting atomic
allocations correctly.

GFP flags should not be tested for GFP_ATOMIC to determine if an
atomic allocation is being requested.  GFP_ATOMIC is not a flag but
a value.  The GFP bitmask flags are all prefixed with __GFP_.

The rest of the kernel tests for __GFP_WAIT not being set to indicate
an atomic allocation.  We need to do the same.

Signed-off-by: Russell King <f6aa0246ff943bfa8602cdf60d40c481b38ed232@arm.linux.org.uk>

--- arch/arm/mm/dma-mapping.c
+++ arch/arm/mm/dma-mapping.c
@@ -640,7 +640,7 @@

 	if (is_coherent || nommu())
 		addr = __alloc_simple_buffer(dev, size, gfp, &page);
-	else if (gfp & GFP_ATOMIC)
+	else if (!(gfp & __GFP_WAIT))
 		addr = __alloc_from_pool(size, &page);
 	else if (!IS_ENABLED(CONFIG_CMA))
 		addr = __alloc_remap_buffer(dev, size, gfp, prot, &page, caller);


ARM: net: add JIT support for loads from struct seccomp_data.

Signed-off-by: Nicolas Schichan <c54e4189a7955dc43220bb9a8c71cc47ff418750@freebox.fr>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>


We need db_machdep.h even when TRAPDEBUG is enabled.

--- arch/hppa64/hppa64/trap.c
+++ arch/hppa64/hppa64/trap.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: trap.c,v 1.12 2010/12/21 14:56:23 claudio Exp $	*/
+/*	$OpenBSD: trap.c,v 1.13 2011/01/02 13:16:53 jsing Exp $	*/

 /*
  * Copyright (c) 2005 Michael Shalayeff
@@ -36,11 +36,11 @@
 #include <machine/psl.h>

 #ifdef DDB
+#include <machine/db_machdep.h>
+#endif
+
 #ifdef TRAPDEBUG
 #include <ddb/db_output.h>
-#else
-#include <machine/db_machdep.h>
-#endif
 #endif

 static __inline int inst_store(u_int ins) {


[PATCH] ptrace: Fix EFL_OFFSET value according to i386 pda changes

The PDA patches introduced a bug in ptrace: it reads eflags from the wrong
place on the target's stack, but writes it back to the correct place.  The
result is a corrupted eflags, which is most visible when it turns interrupts
off unexpectedly.

This patch fixes this by making the ptrace code a little less fragile.  It
changes [gs]et_stack_long to take a straightforward byte offset into struct
pt_regs, rather than requiring all callers to do a sizeof(struct pt_regs)
offset adjustment.  This means that the eflag's offset (EFL_OFFSET) on the
target stack can be simply computed with offsetof().

Signed-off-by: Jeremy Fitzhardinge <b3f594e10a9edcf5413cf1190121d45078c62290@xensource.com>
Cc: Frederik Deweerdt <3b05073a5f0abc63927ee207ce87a0d6777bf2b0@free.fr>
Cc: Andi Kleen <0474aee45985f5ae829f53849df476200e876990@suse.de>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@osdl.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@osdl.org>

--- arch/i386/kernel/ptrace.c
+++ arch/i386/kernel/ptrace.c
@@ -45,7 +45,7 @@
 /*
  * Offset of eflags on child stack..
  */
-#define EFL_OFFSET ((EFL-2)*4-sizeof(struct pt_regs))
+#define EFL_OFFSET offsetof(struct pt_regs, eflags)

 static inline struct pt_regs *get_child_regs(struct task_struct *task)
 {
@@ -54,24 +54,24 @@
 }

 /*
- * this routine will get a word off of the processes privileged stack.
- * the offset is how far from the base addr as stored in the TSS.
- * this routine assumes that all the privileged stacks are in our
+ * This routine will get a word off of the processes privileged stack.
+ * the offset is bytes into the pt_regs structure on the stack.
+ * This routine assumes that all the privileged stacks are in our
  * data space.
  */
 static inline int get_stack_long(struct task_struct *task, int offset)
 {
 	unsigned char *stack;

-	stack = (unsigned char *)task->thread.esp0;
+	stack = (unsigned char *)task->thread.esp0 - sizeof(struct pt_regs);
 	stack += offset;
 	return (*((int *)stack));
 }

 /*
- * this routine will put a word on the processes privileged stack.
- * the offset is how far from the base addr as stored in the TSS.
- * this routine assumes that all the privileged stacks are in our
+ * This routine will put a word on the processes privileged stack.
+ * the offset is bytes into the pt_regs structure on the stack.
+ * This routine assumes that all the privileged stacks are in our
  * data space.
  */
 static inline int put_stack_long(struct task_struct *task, int offset,
@@ -79,7 +79,7 @@
 {
 	unsigned char * stack;

-	stack = (unsigned char *) task->thread.esp0;
+	stack = (unsigned char *)task->thread.esp0 - sizeof(struct pt_regs);
 	stack += offset;
 	*(unsigned long *) stack = data;
 	return 0;
@@ -114,7 +114,7 @@
 	}
 	if (regno > ES*4)
 		regno -= 1*4;
-	put_stack_long(child, regno - sizeof(struct pt_regs), value);
+	put_stack_long(child, regno, value);
 	return 0;
 }

@@ -137,7 +137,6 @@
 		default:
 			if (regno > ES*4)
 				regno -= 1*4;
-			regno = regno - sizeof(struct pt_regs);
 			retval &= get_stack_long(child, regno);
 	}
 	return retval;


ia64: use set_current_blocked() and block_sigmask()

As described in e6fa16ab ("signal: sigprocmask() should do
retarget_shared_pending()") the modification of current->blocked is
incorrect as we need to check whether the signal we're about to block is
pending in the shared queue.

Also, use the new helper function introduced in commit 5e6292c0f28f
("signal: add block_sigmask() for adding sigmask to current->blocked")
which centralises the code for updating current->blocked after
successfully delivering a signal and reduces the amount of duplicate code
across architectures.  In the past some architectures got this code wrong,
so using this helper function should stop that from happening again.

Acked-by: Oleg Nesterov <20b70f0af00562e63758b9ee42012ecc96c58590@redhat.com>
Cc: Tony Luck <e7984595ec0368ff920a7b3521dc7093683f6f26@intel.com>
Cc: Fenghua Yu <94fe9a7ec8ff966c1952fe98e39b5ae3a7477695@intel.com>
Signed-off-by: Matt Fleming <b02f0790d66a0f0a6b369873bf6df37420fbe5dd@intel.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Al Viro <de609eb4d5d70b1d38ec6642adbfc33a2781f63c@zeniv.linux.org.uk>

--- arch/ia64/kernel/signal.c
+++ arch/ia64/kernel/signal.c
@@ -201,13 +201,7 @@
 		goto give_sigsegv;

 	sigdelsetmask(&set, ~_BLOCKABLE);
-
-	spin_lock_irq(&current->sighand->siglock);
-	{
-		current->blocked = set;
-		recalc_sigpending();
-	}
-	spin_unlock_irq(&current->sighand->siglock);
+	set_current_blocked(&set);

 	if (restore_sigcontext(sc, scr))
 		goto give_sigsegv;
@@ -427,12 +421,7 @@
 	if (!setup_frame(sig, ka, info, oldset, scr))
 		return 0;

-	spin_lock_irq(&current->sighand->siglock);
-	sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
-	if (!(ka->sa.sa_flags & SA_NODEFER))
-		sigaddset(&current->blocked, sig);
-	recalc_sigpending();
-	spin_unlock_irq(&current->sighand->siglock);
+	block_sigmask(ka, sig);

 	/*
 	 * Let tracing know that we've done the handler setup.


microblaze: Sync noMMU and MMU setup_memory

Both versions can use the same node to register NODE_DATA(0)

Signed-off-by: Michal Simek <3a191dd2be46e826fee926d532b136ed65cb5318@monstr.eu>

--- arch/microblaze/mm/init.c
+++ arch/microblaze/mm/init.c
@@ -134,13 +134,8 @@
 	 * for 4GB of memory, using 4kB pages), plus 1 page
 	 * (in case the address isn't page-aligned).
 	 */
-#ifndef CONFIG_MMU
-	map_size = init_bootmem_node(NODE_DATA(0), PFN_UP(TOPHYS((u32)klimit)),
-					min_low_pfn, max_low_pfn);
-#else
-	map_size = init_bootmem_node(&contig_page_data,
+	map_size = init_bootmem_node(NODE_DATA(0),
 		PFN_UP(TOPHYS((u32)klimit)), min_low_pfn, max_low_pfn);
-#endif
 	memblock_reserve(PFN_UP(TOPHYS((u32)klimit)) << PAGE_SHIFT, map_size);

 	/* free bootmem is whole main memory */


MIPS: BCM63XX: provide a MAC address for BCM3368 chips

The BCM3368 SoC uses a NVRAM format which is not compatible with the one
used by CFE, provide a default MAC address which is suitable for use and
which is the default one also being used by the bootloader on these
chips.

Signed-off-by: Florian Fainelli <73262ad0334ab37227b2f7a0205f51db1e606681@openwrt.org>
Cc: 562397917b9a8bf316569a848858b12fb417723f@linux-mips.org
Cc: 3105dbb3dd63fbb4f6371cfb04adc6726f76c56b@gmail.com
Cc: 8a35dafb21031d5c8209b1c0c47aaf0390b56a0e@openwrt.org
Patchwork: https://patchwork.linux-mips.org/patch/5498/
Signed-off-by: Ralf Baechle <92f48d309cda194c8eda36aa8f9ae28c488fa208@linux-mips.org>


powerpc/eeh: Add missing #ifdef CONFIG_IOMMU_API

Some new functions are exposed for use by the IOMMU code but
won't build when CONFIG_IOMMU_API isn't set, so shield them
appropriately.

Signed-off-by: Benjamin Herrenschmidt <a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org>


powerpc/vio: Fix modalias_show return values

commit e82b89a6f19bae73fb064d1b3dd91fcefbb478f4 upstream.

modalias_show() should return an empty string on error, not -ENODEV.

This causes the following false and annoying error:

> find /sys/devices -name modalias -print0 | xargs -0 cat >/dev/null
cat: /sys/devices/vio/4000/modalias: No such device
cat: /sys/devices/vio/4001/modalias: No such device
cat: /sys/devices/vio/4002/modalias: No such device
cat: /sys/devices/vio/4004/modalias: No such device
cat: /sys/devices/vio/modalias: No such device

Signed-off-by: Prarit Bhargava <fe4655370dc87a32329d591d6e8472329333dfad@redhat.com>
Signed-off-by: Benjamin Herrenschmidt <a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- arch/powerpc/kernel/vio.c
+++ arch/powerpc/kernel/vio.c
@@ -1529,11 +1529,15 @@
 	const char *cp;

 	dn = dev->of_node;
-	if (!dn)
-		return -ENODEV;
+	if (!dn) {
+		strcat(buf, "\n");
+		return strlen(buf);
+	}
 	cp = of_get_property(dn, "compatible", NULL);
-	if (!cp)
-		return -ENODEV;
+	if (!cp) {
+		strcat(buf, "\n");
+		return strlen(buf);
+	}

 	return sprintf(buf, "vio:T%sS%s\n", vio_dev->type, cp);
 }


Just test for sys{read,write} in is_io()

--- ext/lxc.c
+++ ext/lxc.c
@@ -244,7 +244,8 @@
 static int
 is_io(VALUE v)
 {
-    return rb_obj_is_kind_of(v, rb_cIO) == Qtrue;
+    return rb_respond_to(v, rb_intern("sysread")) &&
+           rb_respond_to(v, rb_intern("syswrite"));
 }

 static void


KVM: PPC: Pass program interrupt flags to the guest

When we need to reinject a program interrupt into the guest, we also need to
reinject the corresponding flags into the guest.

Signed-off-by: Alexander Graf <3ad82b0c937b9aa51276120cedd545efc822be04@suse.de>
Reported-by: Benjamin Herrenschmidt <a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org>
Signed-off-by: Avi Kivity <8f920f22884d6fea9df883843c4a8095a2e5ac6f@redhat.com>

--- arch/powerpc/kvm/book3s.c
+++ arch/powerpc/kvm/book3s.c
@@ -633,6 +633,9 @@
 	case BOOK3S_INTERRUPT_PROGRAM:
 	{
 		enum emulation_result er;
+		ulong flags;
+
+		flags = (vcpu->arch.shadow_msr & 0x1f0000ull);

 		if (vcpu->arch.msr & MSR_PR) {
 #ifdef EXIT_DEBUG
@@ -640,7 +643,7 @@
 #endif
 			if ((vcpu->arch.last_inst & 0xff0007ff) !=
 			    (INS_DCBZ & 0xfffffff7)) {
-				kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
+				kvmppc_core_queue_program(vcpu, flags);
 				r = RESUME_GUEST;
 				break;
 			}
@@ -655,7 +658,7 @@
 		case EMULATE_FAIL:
 			printk(KERN_CRIT "%s: emulation at %lx failed (%08x)\n",
 			       __func__, vcpu->arch.pc, vcpu->arch.last_inst);
-			kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
+			kvmppc_core_queue_program(vcpu, flags);
 			r = RESUME_GUEST;
 			break;
 		default:


[POWERPC] mv64x60: Use mutex instead of semaphore

Signed-off-by: Christoph Hellwig <923f7720577207a44b32e59bbfbea59d27f1ae8e@lst.de>
Acked-by: Mark A. Greer <2540a8c57225c2058d000de41debc8b502ea4a38@mvista.com>
Signed-off-by: Paul Mackerras <19a0ba370c443ba08d20b5061586430ab449ee8c@samba.org>

--- arch/ppc/syslib/mv64x60.c
+++ arch/ppc/syslib/mv64x60.c
@@ -14,6 +14,7 @@
 #include <linux/pci.h>
 #include <linux/slab.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
 #include <linux/string.h>
 #include <linux/spinlock.h>
 #include <linux/mv643xx.h>
@@ -2359,7 +2360,7 @@
 /* Export the hotswap register via sysfs for enum event monitoring */
 #define	VAL_LEN_MAX	11 /* 32-bit hex or dec stringified number + '\n' */

-DECLARE_MUTEX(mv64xxx_hs_lock);
+static DEFINE_MUTEX(mv64xxx_hs_lock);

 static ssize_t
 mv64xxx_hs_reg_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
@@ -2372,14 +2373,14 @@
 	if (count < VAL_LEN_MAX)
 		return -EINVAL;

-	if (down_interruptible(&mv64xxx_hs_lock))
+	if (mutex_lock_interruptible(&mv64xxx_hs_lock))
 		return -ERESTARTSYS;
 	save_exclude = mv64x60_pci_exclude_bridge;
 	mv64x60_pci_exclude_bridge = 0;
 	early_read_config_dword(&sysfs_hose_a, 0, PCI_DEVFN(0, 0),
 			MV64360_PCICFG_CPCI_HOTSWAP, &v);
 	mv64x60_pci_exclude_bridge = save_exclude;
-	up(&mv64xxx_hs_lock);
+	mutex_unlock(&mv64xxx_hs_lock);

 	return sprintf(buf, "0x%08x\n", v);
 }
@@ -2396,14 +2397,14 @@
 		return -EINVAL;

 	if (sscanf(buf, "%i", &v) == 1) {
-		if (down_interruptible(&mv64xxx_hs_lock))
+		if (mutex_lock_interruptible(&mv64xxx_hs_lock))
 			return -ERESTARTSYS;
 		save_exclude = mv64x60_pci_exclude_bridge;
 		mv64x60_pci_exclude_bridge = 0;
 		early_write_config_dword(&sysfs_hose_a, 0, PCI_DEVFN(0, 0),
 				MV64360_PCICFG_CPCI_HOTSWAP, v);
 		mv64x60_pci_exclude_bridge = save_exclude;
-		up(&mv64xxx_hs_lock);
+		mutex_unlock(&mv64xxx_hs_lock);
 	}
 	else
 		count = -EINVAL;
@@ -2433,10 +2434,10 @@
 	pdev = container_of(dev, struct platform_device, dev);
 	pdp = (struct mv64xxx_pdata *)pdev->dev.platform_data;

-	if (down_interruptible(&mv64xxx_hs_lock))
+	if (mutex_lock_interruptible(&mv64xxx_hs_lock))
 		return -ERESTARTSYS;
 	v = pdp->hs_reg_valid;
-	up(&mv64xxx_hs_lock);
+	mutex_unlock(&mv64xxx_hs_lock);

 	return sprintf(buf, "%i\n", v);
 }


Use information from the FDT to set up bus tags and extents.

--- arch/socppc/dev/socpcic.c
+++ arch/socppc/dev/socpcic.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: socpcic.c,v 1.7 2009/09/06 20:09:34 kettenis Exp $	*/
+/*	$OpenBSD: socpcic.c,v 1.8 2009/09/09 20:42:41 kettenis Exp $	*/

 /*
  * Copyright (c) 2008 Mark Kettenis
@@ -24,6 +24,7 @@
 #include <machine/bus.h>

 #include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_pci.h>

 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
@@ -45,6 +46,10 @@
 	int		sc_map_mask[4];
 	int		*sc_map;
 	int		sc_map_len;
+
+	/* Addres space. */
+	uint32_t	*sc_ranges;
+	int		sc_ranges_len;
 };

 int	socpcic_mainbus_match(struct device *, void *, void *);
@@ -167,6 +172,9 @@
 	struct pcibus_attach_args pba;
 	struct extent *io_ex;
 	struct extent *mem_ex;
+	bus_addr_t io_base, mem_base;
+	bus_size_t io_size, mem_size;
+	uint32_t *ranges;
 	int len;

 	if (OF_getprop(sc->sc_node, "interrupt-map-mask", sc->sc_map_mask,
@@ -186,12 +194,45 @@
 		KASSERT(len == sc->sc_map_len);
 	}

-	sc->sc_mem_bus_space.bus_base = 0x80000000;
-	sc->sc_mem_bus_space.bus_size = 0x21000000;
-	sc->sc_mem_bus_space.bus_io = 0;
-	sc->sc_io_bus_space.bus_base = 0xe2000000;
-	sc->sc_io_bus_space.bus_size = 0x01000000;
-	sc->sc_io_bus_space.bus_io = 1;
+	sc->sc_ranges_len = OF_getproplen(sc->sc_node, "ranges");
+	if (sc->sc_ranges_len <= 0) {
+		printf(": missing ranges\n");
+		return;
+	}
+
+	sc->sc_ranges = malloc(sc->sc_ranges_len, M_DEVBUF, M_NOWAIT);
+	if (ranges == NULL)
+		panic("out of memory");
+
+	len = OF_getprop(sc->sc_node, "ranges", sc->sc_ranges,
+	    sc->sc_ranges_len);
+	KASSERT(len == sc->sc_ranges_len);
+
+	ranges = sc->sc_ranges;
+	while (len >= 6 * sizeof(uint32_t)) {
+		switch (ranges[0] & OFW_PCI_PHYS_HI_SPACEMASK) {
+		case OFW_PCI_PHYS_HI_SPACE_IO:
+			KASSERT(ranges[1] == 0);
+			KASSERT(ranges[4] == 0);
+			sc->sc_io_bus_space.bus_base = ranges[3];
+			sc->sc_io_bus_space.bus_size = ranges[5];
+			sc->sc_io_bus_space.bus_io = 1;
+			io_base = ranges[2];
+			io_size = ranges[5];
+			break;
+		case  OFW_PCI_PHYS_HI_SPACE_MEM32:
+			KASSERT(ranges[1] == 0);
+			KASSERT(ranges[4] == 0);
+			sc->sc_mem_bus_space.bus_base = ranges[3];
+			sc->sc_mem_bus_space.bus_size = ranges[5];
+			sc->sc_mem_bus_space.bus_io = 0;
+			mem_base = ranges[2];
+			mem_size = ranges[5];
+			break;
+		}
+		len -= 6 * sizeof(uint32_t);
+		ranges += 6;
+	}

 	sc->sc_pc.pc_conf_v = sc;
 	sc->sc_pc.pc_attach_hook = socpcic_attach_hook;
@@ -211,12 +252,12 @@

 	io_ex = extent_create("pciio", 0, 0xffffffff, M_DEVBUF, NULL, 0,
 	    EX_NOWAIT | EX_FILLED);
-	if (io_ex != NULL)
-		extent_free(io_ex, 0x00000000, 0x01000000, EX_NOWAIT);
+	if (io_ex != NULL && io_size)
+		extent_free(io_ex, io_base, io_size, EX_NOWAIT);
 	mem_ex = extent_create("pcimem", 0, 0xffffffff, M_DEVBUF, NULL, 0,
 	    EX_NOWAIT | EX_FILLED);
 	if (mem_ex != NULL)
-		extent_free(mem_ex, 0x80000000, 0x20000000, EX_NOWAIT);
+		extent_free(mem_ex, mem_base, mem_size, EX_NOWAIT);

 	bzero(&pba, sizeof(pba));
 	pba.pba_busname = "pci";


Remove redurant change log

Remove redurant change log

--- fayecpp.h
+++ fayecpp.h
@@ -33,8 +33,7 @@
  *   - Minimum supported client version is 1.0.
  *   - Public advice information.
  *   - Use Libwebsockets version 1.6.
- *   - Automatic reconnect using advice information (Libwebsockets transport version).
- *   - Automatic reconnect using advice information (QWebSocket transport version).
+ *   - Automatic reconnect using advice information (Libwebsockets & QWebSocket transport version).
  *
  *   Changes on version 0.1.16:
  *   - Cocoapod with OpenSSL support(pod 'FayeCpp+OpenSSL'), recommended for all Faye users.


[SPARC64]: Fix leak when DR added cpu does not bootup.

Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- arch/sparc64/kernel/smp.c
+++ arch/sparc64/kernel/smp.c
@@ -90,7 +90,6 @@
 void __devinit smp_callin(void)
 {
 	int cpuid = hard_smp_processor_id();
-	struct trap_per_cpu *tb = &trap_block[cpuid];;

 	__local_per_cpu_offset = __per_cpu_offset(cpuid);

@@ -118,11 +117,6 @@
 	/* Attach to the address space of init_task. */
 	atomic_inc(&init_mm.mm_count);
 	current->active_mm = &init_mm;
-
-	if (tb->hdesc) {
-		kfree(tb->hdesc);
-		tb->hdesc = NULL;
-	}

 	while (!cpu_isset(cpuid, smp_commenced_mask))
 		rmb();
@@ -345,6 +339,7 @@

 static int __devinit smp_boot_one_cpu(unsigned int cpu)
 {
+	struct trap_per_cpu *tb = &trap_block[cpu];
 	unsigned long entry =
 		(unsigned long)(&sparc64_cpu_startup);
 	unsigned long cookie =
@@ -388,6 +383,11 @@
 		ret = -ENODEV;
 	}
 	cpu_new_thread = NULL;
+
+	if (tb->hdesc) {
+		kfree(tb->hdesc);
+		tb->hdesc = NULL;
+	}

 	return ret;
 }


uml: free LDT state on process exit

uml: free LDT state on process exit

The space allocated for a process LDT wasn't being freed when the process
exited.

Signed-off-by: Jeff Dike <f9b6309e85863eba5d28138b6a0f35841ce976d0@linux.intel.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- arch/um/kernel/skas/mmu.c
+++ arch/um/kernel/skas/mmu.c
@@ -149,4 +149,6 @@
 		pmd_free((pmd_t *) mmu->last_pmd);
 #endif
 	}
+
+	free_ldt(mmu);
 }


x86: kprobes.c fix compilation warning

x86: kprobes.c fix compilation warning

arch/x86/kernel/kprobes.c:196: warning: passing argument 1 of ‘search_exception_tables’ makes integer from pointer without a cast

Signed-off-by: Jaswinder Singh Rajput <0599c1aba1ea3f0bcaf4115dd8076db98ee6d35c@gmail.com>
Cc: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>
LKML-Reference:<066b5db5e5a2c41a6a70d77c9cea05f04a3f5847@redhat.com>
LKML-Reference: <c738c0af140fdb23eb669b42150b7a7bba6e9f5a@localhost.localdomain>
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@elte.hu>

--- arch/x86/kernel/kprobes.c
+++ arch/x86/kernel/kprobes.c
@@ -193,7 +193,7 @@
 	kprobe_opcode_t opcode;
 	kprobe_opcode_t *orig_opcodes = opcodes;

-	if (search_exception_tables(opcodes))
+	if (search_exception_tables((unsigned long)opcodes))
 		return 0;	/* Page fault may occur on this address. */

 retry:


mm: hugetlbfs: correctly populate shared pmd

Each page mapped in a process's address space must be correctly
accounted for in _mapcount.  Normally the rules for this are
straightforward but hugetlbfs page table sharing is different.  The page
table pages at the PMD level are reference counted while the mapcount
remains the same.

If this accounting is wrong, it causes bugs like this one reported by
Larry Woodman:

  kernel BUG at mm/filemap.c:135!
  invalid opcode: 0000 [#1] SMP
  CPU 22
  Modules linked in: bridge stp llc sunrpc binfmt_misc dcdbas microcode pcspkr acpi_pad acpi]
  Pid: 18001, comm: mpitest Tainted: G        W    3.3.0+ #4 Dell Inc. PowerEdge R620/07NDJ2
  RIP: 0010:[<ffffffff8112cfed>]  [<ffffffff8112cfed>] __delete_from_page_cache+0x15d/0x170
  Process mpitest (pid: 18001, threadinfo ffff880428972000, task ffff880428b5cc20)
  Call Trace:
    delete_from_page_cache+0x40/0x80
    truncate_hugepages+0x115/0x1f0
    hugetlbfs_evict_inode+0x18/0x30
    evict+0x9f/0x1b0
    iput_final+0xe3/0x1e0
    iput+0x3e/0x50
    d_kill+0xf8/0x110
    dput+0xe2/0x1b0
    __fput+0x162/0x240

During fork(), copy_hugetlb_page_range() detects if huge_pte_alloc()
shared page tables with the check dst_pte == src_pte.  The logic is if
the PMD page is the same, they must be shared.  This assumes that the
sharing is between the parent and child.  However, if the sharing is
with a different process entirely then this check fails as in this
diagram:

  parent
    |
    ------------>pmd
                 src_pte----------> data page
                                        ^
  other--------->pmd--------------------|
                  ^
  child-----------|
                 dst_pte

For this situation to occur, it must be possible for Parent and Other to
have faulted and failed to share page tables with each other.  This is
possible due to the following style of race.

  PROC A                                          PROC B
  copy_hugetlb_page_range                         copy_hugetlb_page_range
    src_pte == huge_pte_offset                      src_pte == huge_pte_offset
    !src_pte so no sharing                          !src_pte so no sharing

  (time passes)

  hugetlb_fault                                   hugetlb_fault
    huge_pte_alloc                                  huge_pte_alloc
      huge_pmd_share                                 huge_pmd_share
        LOCK(i_mmap_mutex)
        find nothing, no sharing
        UNLOCK(i_mmap_mutex)
                                                      LOCK(i_mmap_mutex)
                                                      find nothing, no sharing
                                                      UNLOCK(i_mmap_mutex)
      pmd_alloc                                       pmd_alloc
      LOCK(instantiation_mutex)
      fault
      UNLOCK(instantiation_mutex)
                                                  LOCK(instantiation_mutex)
                                                  fault
                                                  UNLOCK(instantiation_mutex)

These two processes are not poing to the same data page but are not
sharing page tables because the opportunity was missed.  When either
process later forks, the src_pte == dst pte is potentially insufficient.
As the check falls through, the wrong PTE information is copied in
(harmless but wrong) and the mapcount is bumped for a page mapped by a
shared page table leading to the BUG_ON.

This patch addresses the issue by moving pmd_alloc into huge_pmd_share
which guarantees that the shared pud is populated in the same critical
section as pmd.  This also means that huge_pte_offset test in
huge_pmd_share is serialized correctly now which in turn means that the
success of the sharing will be higher as the racing tasks see the pud
and pmd populated together.

Race identified and changelog written mostly by Mel Gorman.

{5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org: attempt to make the huge_pmd_share() comment comprehensible, clean up coding style]
Reported-by: Larry Woodman <1f928aec9cc2d234382aa316cfc78c18d19ac9d6@redhat.com>
Tested-by: Larry Woodman <1f928aec9cc2d234382aa316cfc78c18d19ac9d6@redhat.com>
Reviewed-by: Mel Gorman <39ea6a09710987173e32e37c86918024a0f441c1@suse.de>
Signed-off-by: Michal Hocko <829500b200af6c2a0eca4dfd5c388e6b8fbe8dc6@suse.cz>
Reviewed-by: Rik van Riel <a21938f5d463ddf41aa718934c205ca2cce8ebbc@redhat.com>
Cc: David Gibson <aa743a0aaec8f7d7a1f01442503957f4d7a2d634@gibson.dropbear.id.au>
Cc: Ken Chen <76daf34ccc35c39bb215f117423bdc362ed1c854@google.com>
Cc: Cong Wang <0f114804888b88d50037b04b42e57b858d851b87@gmail.com>
Cc: Hillf Danton <74636c4e14be88f42bc2a57784d7913ef47ac9b0@gmail.com>
Cc: <4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@vger.kernel.org>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- arch/x86/mm/hugetlbpage.c
+++ arch/x86/mm/hugetlbpage.c
@@ -56,9 +56,16 @@
 }

 /*
- * search for a shareable pmd page for hugetlb.
+ * Search for a shareable pmd page for hugetlb. In any case calls pmd_alloc()
+ * and returns the corresponding pte. While this is not necessary for the
+ * !shared pmd case because we can allocate the pmd later as well, it makes the
+ * code much cleaner. pmd allocation is essential for the shared case because
+ * pud has to be populated inside the same i_mmap_mutex section - otherwise
+ * racing tasks could either miss the sharing (see huge_pte_offset) or select a
+ * bad pmd for sharing.
  */
-static void huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
+static pte_t *
+huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
 {
 	struct vm_area_struct *vma = find_vma(mm, addr);
 	struct address_space *mapping = vma->vm_file->f_mapping;
@@ -68,9 +75,10 @@
 	struct vm_area_struct *svma;
 	unsigned long saddr;
 	pte_t *spte = NULL;
+	pte_t *pte;

 	if (!vma_shareable(vma, addr))
-		return;
+		return (pte_t *)pmd_alloc(mm, pud, addr);

 	mutex_lock(&mapping->i_mmap_mutex);
 	vma_prio_tree_foreach(svma, &iter, &mapping->i_mmap, idx, idx) {
@@ -97,7 +105,9 @@
 		put_page(virt_to_page(spte));
 	spin_unlock(&mm->page_table_lock);
 out:
+	pte = (pte_t *)pmd_alloc(mm, pud, addr);
 	mutex_unlock(&mapping->i_mmap_mutex);
+	return pte;
 }

 /*
@@ -142,8 +152,9 @@
 		} else {
 			BUG_ON(sz != PMD_SIZE);
 			if (pud_none(*pud))
-				huge_pmd_share(mm, addr, pud);
-			pte = (pte_t *) pmd_alloc(mm, pud, addr);
+				pte = huge_pmd_share(mm, addr, pud);
+			else
+				pte = (pte_t *)pmd_alloc(mm, pud, addr);
 		}
 	}
 	BUG_ON(pte && !pte_none(*pte) && !pte_huge(*pte));