PubsubNode: Generalize void IQ reply handler

--- wocky/wocky-pubsub-node.c
+++ wocky/wocky-pubsub-node.c
@@ -526,7 +526,7 @@
 }

 static void
-unsubscribe_cb (GObject *source,
+pubsub_node_void_iq_cb (GObject *source,
     GAsyncResult *res,
     gpointer user_data)
 {
@@ -574,7 +574,7 @@
       NULL);

   wocky_porter_send_iq_async (priv->porter, stanza, cancellable,
-      unsubscribe_cb, simple);
+      pubsub_node_void_iq_cb, simple);

   g_object_unref (stanza);
 }
@@ -592,28 +592,6 @@
   simple = (GSimpleAsyncResult *) result;

   return !g_simple_async_result_propagate_error (simple, error);
-}
-
-static void
-delete_node_iq_cb (GObject *source,
-    GAsyncResult *res,
-    gpointer user_data)
-{
-  GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
-  GError *error = NULL;
-
-  if (!wocky_pubsub_distill_void_iq_reply (source, res, &error))
-    {
-      g_simple_async_result_set_from_error (result, error);
-      g_clear_error (&error);
-    }
-  else
-    {
-      DEBUG ("node deleted");
-    }
-
-  g_simple_async_result_complete (result);
-  g_object_unref (result);
 }

 WockyStanza *
@@ -639,8 +617,8 @@
   stanza = wocky_pubsub_node_make_delete_stanza (self, NULL, NULL);
   result = g_simple_async_result_new (G_OBJECT (self), callback, user_data,
     wocky_pubsub_node_delete_async);
-  wocky_porter_send_iq_async (priv->porter, stanza, NULL, delete_node_iq_cb,
-      result);
+  wocky_porter_send_iq_async (priv->porter, stanza, NULL,
+      pubsub_node_void_iq_cb, result);
   g_object_unref (stanza);
 }


fix observable value for gcc

fix observable value for gcc

--- include/lars/observable_value.h
+++ include/lars/observable_value.h
@@ -19,6 +19,9 @@

     template <typename ... Args> ObservableValue(Args ... args):value(std::forward<Args>(args)...){
     }
+
+    ObservableValue(ObservableValue &&) = delete;
+    ObservableValue &operator=(ObservableValue &&) = delete;

     template <typename ... Args> void set(Args ... args){
       value = T(std::forward<Args>(args)...);
@@ -43,35 +46,20 @@

   template <class T, typename ... D> class DependentObservableValue: public ObservableValue<T> {
   private:
-    std::tuple<const D * ...> values;
     std::tuple<typename ObservableValue<D>::OnChange::Observer ...> observers;
-
-    template <class H, size_t ... Idx> DependentObservableValue(
-      std::index_sequence<Idx...> const &,
-      const H &handler,
-      const ObservableValue<D> & ... deps
-    ):ObservableValue<T>(handler(deps.get()...)){
-
-      values = std::make_tuple(&deps.get() ...);
-      auto callHandler = [handler](const D * ... v){ return handler(*v...); };
-      auto update = [this, callHandler](){
-        this->set(std::apply(callHandler, values));
-      };
-
-      update();
-
-      observers = (std::make_tuple(deps.onChange.createObserver([this,update](const auto &v){
-        std::get<Idx>(values) = &v;
-        update();
-      })...));
-    }

   public:
-
     template <class H> DependentObservableValue(
       const H &handler,
       const ObservableValue<D> & ... deps
-    ): DependentObservableValue(std::make_index_sequence<sizeof...(D)>(), handler, deps...) { }
+    ):
+      ObservableValue<T>(handler(deps.get()...)),
+      observers(std::make_tuple(deps.onChange.createObserver([&,this](const auto &v){
+        this->set(handler(deps.get()...));
+      })...))
+    {
+
+    }

   };


restore longer buffers

restore longer buffers

--- Engine/fgens.c
+++ Engine/fgens.c
@@ -2678,7 +2678,7 @@
     uint32_t bufsize, bufused = 0;
     uint64_t maxsize;
     uint8_t *buffer;
-    int size = 0x100;
+    int size = 0x1000;
     int flen;

     if (UNLIKELY(ff->e.pcnt < 7)) {


Fixed bug in GEN31

Fixed bug in GEN31


accidentally overwrote header

accidentally overwrote header

--- dependencies/SDL/jni/include/SDL_hints.h
+++ dependencies/SDL/jni/include/SDL_hints.h
@@ -535,6 +535,11 @@
  */
 #define SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION"

+ /**
+ * \brief If set to 1, sets UI_LOW_PROFILE setting for SDLActivity
+ */
+#define SDL_HINT_ANDROID_USE_UI_LOW_PROFILE "SDL_ANDROID_USE_UI_LOW_PROFILE"
+
 /**
  * \brief A variable to control whether certain IMEs should handle text editing internally instead of sending SDL_TEXTEDITING events.
  *


Remove foundation import.

Remove foundation import.

--- framework/src/NimbusKit.h
+++ framework/src/NimbusKit.h
@@ -13,8 +13,6 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 //
-
-#import <Foundation/Foundation.h>

 #define NIMBUSKIT_FRAMEWORK


Create exercicio.c

Create exercicio.c


fixed gen01 channel number setting

fixed gen01 channel number setting

--- Engine/fgens.c
+++ Engine/fgens.c
@@ -2477,11 +2477,14 @@
       ff->flen     -= 1;
       ftp           = ftalloc(ff);            /*   alloc now, and           */
       ftp->lenmask  = 0L;                     /*   mark hdr partly filled   */
-      if (p->channel==ALLCHNLS) ftp->nchanls  = p->nchanls;
+      /*if (p->channel==ALLCHNLS) ftp->nchanls  = p->nchanls;
       else ftp->nchanls  = 1;
-      ftp->flenfrms = ff->flen / p->nchanls;  /* ?????????? */
+      ftp->flenfrms = ff->flen / p->nchanls; */ /* ?????????? */
       def           = 1;
     }
+    if (p->channel==ALLCHNLS) ftp->nchanls  = p->nchanls;
+      else ftp->nchanls  = 1;
+    ftp->flenfrms = ff->flen / p->nchanls;  /* ?????????? */
     ftp->gen01args.sample_rate = (MYFLT) p->sr;
     ftp->cvtbas = LOFACT * p->sr * csound->onedsr;
 #if defined(HAVE_LIBSNDFILE) && HAVE_LIBSNDFILE >= 1013


Fix typos in CNetworkOfPoses.h

Fix typos in CNetworkOfPoses.h

--- libs/graphs/include/mrpt/graphs/CNetworkOfPoses.h
+++ libs/graphs/include/mrpt/graphs/CNetworkOfPoses.h
@@ -207,15 +207,7 @@
 				edges_store_inverse_poses = false;
 			}

-<<<<<<< HEAD
-<<<<<<< HEAD
 			/** Return number of nodes in the list \a nodes of global coordinates (may be different that all nodes appearing in edges)
-=======
-			/** Return number of nodes in the list \a nodes of global coordinates (may be different that all nodes appearing in edges)
->>>>>>> 68c2654... Correct minor documentation typos
-=======
-			/** Return number of nodes in the list \a nodes of global coordinates (may be different that all nodes appearing in edges)
->>>>>>> 3915a40... Correct \a nodes doxygen typo to \a nodes
 			  * \sa mrpt::graphs::CDirectedGraph::countDifferentNodesInEdges
 			  */
 			inline size_t nodeCount() const { return nodes.size(); }


Adding a file-buffer mode to writebuffer.

--- writebuffer/writebuffer.c
+++ writebuffer/writebuffer.c
@@ -1,15 +1,21 @@
+#include <fcntl.h>
 #include <pthread.h>
 #include <semaphore.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/types.h>
 #include <unistd.h>

 #include "helpers.h"

 #define MB    *1024*1024
+#ifndef FILE_BUFFER
 #define BUFSZ (16 MB)
 #define MAXBUFS 128
+#else
+#define BUFSZ (512 MB)
+#endif

 #define ANSI_UP         "\x1B[A"
 #define ANSI_DOWN_BACK  "\x1B[B\r"
@@ -24,14 +30,20 @@
     struct Buffer_ *next;
     pthread_mutex_t lock;
     unsigned char type;
+#ifndef FILE_BUFFER
     unsigned long length;
     unsigned char *buf;
+#else
+    char file[256];
+#endif
 } Buffer;

 /* the in buffer */
 static Buffer inBuffer, *inBufferTail;
 static pthread_mutex_t inBufferTailLock = PTHREAD_MUTEX_INITIALIZER;
+#ifndef FILE_BUFFER
 static sem_t inBufferSem;
+#endif

 /* and the out buffer */
 static Buffer outBuffer, *outBufferTail;
@@ -46,6 +58,13 @@
 {
     Buffer *cur, *tail;
     unsigned long written = 0;
+#ifdef FILE_BUFFER
+    ssize_t rd;
+    char *buf;
+    int fd;
+
+    SF(buf, malloc, NULL, (BUFSZ));
+#endif

     while (1) {
         sem_wait(&outBufferSem);
@@ -59,7 +78,20 @@
         outBuffer.next = cur->next;
         pthread_mutex_unlock(&outBuffer.lock);

+#ifdef FILE_BUFFER
+        /* read it in */
+        SF(fd, open, -1, (cur->file, O_RDONLY));
+        rd = read(fd, buf, (BUFSZ));
+        if (rd == -1) {
+            perror("read");
+            exit(1);
+        }
+        close(fd);
+        unlink(cur->file);
+#endif
+
         /* write it out */
+#ifndef FILE_BUFFER
         if (cur->type == BUF_TYPE_NORMAL) {
             write(1, cur->buf, BUFSZ);
         } else if (cur->type == BUF_TYPE_END) {
@@ -69,7 +101,11 @@
             free(cur);
             break;
         }
-
+#else
+        write(1, buf, rd);
+#endif
+
+#ifndef FILE_BUFFER
         /* return it to the bufferstream */
         pthread_mutex_lock(&inBufferTailLock);
         tail = inBufferTail;
@@ -85,12 +121,27 @@
         pthread_mutex_unlock(&tail->lock);
         pthread_mutex_unlock(&inBufferTailLock);
         sem_post(&inBufferSem);
+#else
+        /* and free it up */
+        pthread_mutex_unlock(&cur->lock);
+        if (cur->type == BUF_TYPE_END) {
+            free(cur);
+            break;
+        }
+        free(cur);
+#endif

         /* display our status */
         written++;
+#ifndef FILE_BUFFER
         fprintf(stderr, ANSI_UP "buffer: %luMB    written: %luMB" ANSI_CLEAR ANSI_DOWN_BACK,
                 bufCt * BUFSZ / (1 MB),
                 written * BUFSZ / (1 MB));
+#else
+        fprintf(stderr, ANSI_UP ANSI_UP "buffer: %luMB    written: %luMB" ANSI_CLEAR ANSI_DOWN_BACK ANSI_DOWN_BACK,
+                (bufCt - written) * BUFSZ / (1 MB),
+                written * BUFSZ / (1 MB));
+#endif
     }

     return NULL;
@@ -101,6 +152,7 @@
 {
     static Buffer *cur;

+#ifndef FILE_BUFFER
 retryNew:
     pthread_mutex_lock(&inBuffer.lock);
     cur = inBuffer.next;
@@ -132,14 +184,21 @@
     }
     bufCt++;
     pthread_mutex_init(&cur->lock, NULL);
+    cur->length = 0;
+#else
+    SF(cur, malloc, NULL, (sizeof(Buffer)));
+    sprintf(cur->file, ".buf.%lu", bufCt++);
+#endif
+
     cur->type = BUF_TYPE_NORMAL;
-    cur->length = 0;
     return cur;

+#ifndef FILE_BUFFER
 waitRetryNew:
     sem_wait(&inBufferSem);
     sem_post(&inBufferSem);
     goto retryNew;
+#endif
 }

 int main(int argc, char **argv)
@@ -148,15 +207,30 @@
     pthread_t writerTh;
     ssize_t rd;
     Buffer *cur, *tail;
+#ifdef FILE_BUFFER
+    char *buf;
+    size_t len;
+#endif

     if (argc > 1) {
+#ifndef FILE_BUFFER
         fprintf(stderr, "Use: command | writebuffer > file\n");
+#else
+        fprintf(stderr, "Use: command | writebuffer | fwritebuffer > file\n");
+#endif
         return 1;
     }

+#ifdef FILE_BUFFER
+    SF(buf, malloc, NULL, (BUFSZ));
+    len = 0;
+#endif
+
     inBuffer.type = outBuffer.type = BUF_TYPE_HEAD;

+#ifndef FILE_BUFFER
     sem_init(&inBufferSem, 0, 0);
+#endif
     sem_init(&outBufferSem, 0, 0);

     /* make our in and out buffer tails */
@@ -182,9 +256,26 @@
     cur = newBuffer();

     /* and perform the reading */
+#ifndef FILE_BUFFER
     while ((rd = read(0, cur->buf + cur->length, BUFSZ - cur->length)) >= 0) {
         cur->length += rd;
         if (cur->length == BUFSZ || rd == 0) {
+
+#else
+    while ((rd = read(0, buf + len, BUFSZ - len)) >= 0) {
+        len += rd;
+        if (len == BUFSZ || rd == 0) {
+            int fd;
+
+            /* write it to the file */
+            SF(fd, open, -1, (cur->file, O_CREAT|O_WRONLY, 0600));
+            if (write(fd, buf, len) != len) {
+                perror("write");
+                exit(1);
+            }
+            close(fd);
+#endif
+
             /* read all we can for now, add it to the write queue */
             pthread_mutex_lock(&outBufferTailLock);
             tail = outBufferTail;
@@ -192,12 +283,18 @@

             tail->next = cur;
             tail->type = (rd == 0) ? BUF_TYPE_END : BUF_TYPE_NORMAL;
+#ifndef FILE_BUFFER
             tail->length = cur->length;
             tail->buf = cur->buf;
+#else
+            strcpy(tail->file, cur->file);
+#endif

             cur->next = NULL;
             cur->type = BUF_TYPE_TAIL;
+#ifndef FILE_BUFFER
             cur->buf = NULL;
+#endif

             outBufferTail = cur;


score macro (old parser): fix no EOF if EOL is only CR

--- Engine/sread.c
+++ Engine/sread.c
@@ -336,8 +336,11 @@
     csound->DebugMsg(csound,"%s(%d): character = %c(%.2d)\n", __FILE__, __LINE__, c, c);
 #endif
     if (c == '\r') {    /* can only occur in files, and not in macros */
-      if ((c = corfile_getc(ST(str)->cf)) != '\n')
+      if ((c = corfile_getc(ST(str)->cf)) != '\n') {
+        if (c == EOF)
+          goto top;
         corfile_ungetc(ST(str)->cf);
+      }
       c = '\n';
     }
     if (c == '\n') {


FFusion: Don't crash if avcodec_open() fails

Regression for a while (surprising that it didn't cause any bug reports).
Found by enabling VP8 without remembering to register the decoder.

--- FFusionCodec.c
+++ FFusionCodec.c
@@ -753,9 +753,9 @@
 			err = paramErr;
         }

-        // this format doesn't have enough information in its headers
-		// we have to decode the first frame
-		if (glob->avContext->pix_fmt == PIX_FMT_NONE && p->bufferSize && p->data)
+        // codec was opened, but didn't give us its pixfmt
+		// we have to decode the first frame to find out one
+		else if (glob->avContext->pix_fmt == PIX_FMT_NONE && p->bufferSize && p->data)
             glob->avContext->pix_fmt = FindPixFmtFromVideo(glob->avCodec, glob->avContext, p->data, p->bufferSize);
     }


libceph: improve packing in struct ceph_osd_req_op

The layout of struct ceph_osd_req_op leaves lots of holes.
Rearranging things a little for better field alignment
reduces the size by a third.

This resolves:
    http://tracker.ceph.com/issues/4163

Signed-off-by: Alex Elder <f429030cf5c0faf36fac3d102073b6e63a647baa@inktank.com>
Reviewed-by: Josh Durgin <51652c783f70f5b272ebd02f1fd20d3af7a2449f@inktank.com>

--- include/linux/ceph/osd_client.h
+++ include/linux/ceph/osd_client.h
@@ -157,6 +157,7 @@

 struct ceph_osd_req_op {
 	u16 op;           /* CEPH_OSD_OP_* */
+	u32 payload_len;
 	union {
 		struct {
 			u64 offset, length;
@@ -165,23 +166,24 @@
 		} extent;
 		struct {
 			const char *name;
+			const char  *val;
 			u32 name_len;
-			const char  *val;
 			u32 value_len;
 			__u8 cmp_op;       /* CEPH_OSD_CMPXATTR_OP_* */
 			__u8 cmp_mode;     /* CEPH_OSD_CMPXATTR_MODE_* */
 		} xattr;
 		struct {
 			const char *class_name;
+			const char *method_name;
+			const char *indata;
+			u32 indata_len;
 			__u8 class_len;
-			const char *method_name;
 			__u8 method_len;
 			__u8 argc;
-			const char *indata;
-			u32 indata_len;
 		} cls;
 		struct {
-			u64 cookie, count;
+			u64 cookie;
+			u64 count;
 		} pgls;
 	        struct {
 		        u64 snapid;
@@ -189,12 +191,11 @@
 		struct {
 			u64 cookie;
 			u64 ver;
-			__u8 flag;
 			u32 prot_ver;
 			u32 timeout;
+			__u8 flag;
 		} watch;
 	};
-	u32 payload_len;
 };

 extern int ceph_osdc_init(struct ceph_osd_client *osdc,


Only apply r878 to VP3.

Only apply r878 to VP3.

--- FFusionCodec.c
+++ FFusionCodec.c
@@ -123,6 +123,7 @@
 	FFusionBuffer	buffers[FFUSION_MAX_BUFFERS];	// the buffers which the codec has retained
 	int				lastAllocatedBuffer;		// the index of the buffer which was last allocated
 												// by the codec (and is the latest in decode order)
+	int				shouldUseReturnedFrame;
 	struct begin_glob	begin;
 	FFusionData		data;
 	struct decode_glob	decode;
@@ -322,6 +323,7 @@
 		glob->begin.parser = NULL;
 		if (getenv("PerianDebugLogging")) glob->fileLog = fopen("/tmp/perian.log", "a");
 		else glob->fileLog = NULL;
+		glob->shouldUseReturnedFrame = 0;

 //        c = FindNextComponent(c, &cd);

@@ -634,6 +636,7 @@

 			case 'VP30':
 			case 'VP31':
+				glob->shouldUseReturnedFrame = TRUE;
 				codecID = CODEC_ID_VP3;
 				break;

@@ -1274,7 +1277,7 @@

 	if(!picture || picture->data[0] == 0)
 	{
-		if(myDrp->buffer->returnedFrame.data[0])
+		if(glob->shouldUseReturnedFrame && myDrp->buffer->returnedFrame.data[0])
 			//Some decoders (vp3) keep their internal buffers in an unusable state
 			picture = &myDrp->buffer->returnedFrame;
 		else if(glob->lastDisplayedFrame.data[0] != NULL)


BaseProtocol: Add skeleton (commented) protocol interfaces.

--- TelepathyQt/base-protocol.h
+++ TelepathyQt/base-protocol.h
@@ -27,8 +27,10 @@
 #error IN_TP_QT_HEADER
 #endif

+#include <TelepathyQt/AvatarSpec>
 #include <TelepathyQt/DBusService>
 #include <TelepathyQt/Global>
+#include <TelepathyQt/PresenceSpecList>
 #include <TelepathyQt/ProtocolParameterList>
 #include <TelepathyQt/RequestableChannelClassSpecList>
 #include <TelepathyQt/Types>
@@ -106,6 +108,64 @@
     Private *mPriv;
 };

+/*
+class TP_QT_EXPORT BaseProtocolAddressingInterface : public QObject
+{
+    Q_OBJECT
+
+public:
+    BaseProtocolAddressingInterface();
+    virtual ~BaseProtocolAddressingInterface();
+
+    QStringList addressableVCardFields() const;
+    void setAddressableVCardFields(const QStringList &vcardFields);
+
+    QStringList addressableUriSchemes() const;
+    void setAddressableUriSchemes(const QStringList &uriSchemes);
+
+protected Q_SLOTS:
+    // normalizeVCardAddress
+    // normalizeContactURI
+
+private:
+    struct Private;
+    friend struct Private;
+    Private *mPriv;
+};
+
+class TP_QT_EXPORT BaseProtocolAvatarsInterface : public QObject
+{
+    Q_OBJECT
+
+public:
+    BaseProtocolAvatarsInterface(const AvatarSpec &details);
+    virtual ~BaseProtocolAvatarsInterface();
+
+    AvatarSpec details() const;
+
+private:
+    struct Private;
+    friend struct Private;
+    Private *mPriv;
+};
+
+class TP_QT_EXPORT BaseProtocolPresenceInterface : public QObject
+{
+    Q_OBJECT
+
+public:
+    BaseProtocolPresenceInterface(const PresenceSpecList &statuses);
+    virtual ~BaseProtocolPresenceInterface();
+
+    PresenceSpecList statuses() const;
+
+private:
+    struct Private;
+    friend struct Private;
+    Private *mPriv;
+};
+*/
+
 }

 #endif


percpu_ref: remove unnecessary ACCESS_ONCE() in percpu_ref_tryget_live()

__ref_is_percpu() needs the implied ACCESS_ONCE() in
lockless_dereference() on @ref->percpu_count_ptr because the value is
tested for !__PERCPU_REF_ATOMIC, which may be set asynchronously, and
then used as a pointer.  If the compiler generates a separate fetch
when using it as a pointer, __PERCPU_REF_ATOMIC may be set in between
contaminating the pointer value.

percpu_ref_tryget_live() also uses ACCESS_ONCE() to test
__PERCPU_REF_DEAD; however, there's no reason for this.  I just copied
ACCESS_ONCE() usage blindly from __ref_is_percpu().  All it does is
confusing people trying to understand what's going on.

This patch removes the unnecessary ACCESS_ONCE() usage from
percpu_ref_tryget_live() and adds a comment explaining why
__ref_is_percpu() needs it.

Signed-off-by: Tejun Heo <546b05909706652891a87f7bfe385ae147f61f91@kernel.org>
Cc: Kent Overstreet <99dffa8a9668ab7f6cde1c94b42a210109971113@daterainc.com>

--- include/linux/percpu-refcount.h
+++ include/linux/percpu-refcount.h
@@ -128,8 +128,22 @@
 static inline bool __ref_is_percpu(struct percpu_ref *ref,
 					  unsigned long __percpu **percpu_countp)
 {
-	/* paired with smp_store_release() in percpu_ref_reinit() */
-	unsigned long percpu_ptr = lockless_dereference(ref->percpu_count_ptr);
+	unsigned long percpu_ptr;
+
+	/*
+	 * The value of @ref->percpu_count_ptr is tested for
+	 * !__PERCPU_REF_ATOMIC, which may be set asynchronously, and then
+	 * used as a pointer.  If the compiler generates a separate fetch
+	 * when using it as a pointer, __PERCPU_REF_ATOMIC may be set in
+	 * between contaminating the pointer value, meaning that
+	 * ACCESS_ONCE() is required when fetching it.
+	 *
+	 * Also, we need a data dependency barrier to be paired with
+	 * smp_store_release() in __percpu_ref_switch_to_percpu().
+	 *
+	 * Use lockless deref which contains both.
+	 */
+	percpu_ptr = lockless_dereference(ref->percpu_count_ptr);

 	/*
 	 * Theoretically, the following could test just ATOMIC; however,
@@ -233,7 +247,7 @@
 	if (__ref_is_percpu(ref, &percpu_count)) {
 		this_cpu_inc(*percpu_count);
 		ret = true;
-	} else if (!(ACCESS_ONCE(ref->percpu_count_ptr) & __PERCPU_REF_DEAD)) {
+	} else if (!(ref->percpu_count_ptr & __PERCPU_REF_DEAD)) {
 		ret = atomic_long_inc_not_zero(&ref->count);
 	}


Fix memcpy size in s6-tcpserver6d

Fix memcpy size in s6-tcpserver6d

--- src/conn-tools/s6-tcpserver6d.c
+++ src/conn-tools/s6-tcpserver6d.c
@@ -229,7 +229,7 @@
   PROG = "s6-tcpserver6 (child)" ;
   if ((fd_move(0, s) < 0) || (fd_copy(1, 0) < 0))
     strerr_diefu1sys(111, "move fds") ;
-  memcpy(fmt+n, "PROTO=TCP\0TCPREMOTEIP=", 24) ; n += 22 ;
+  memcpy(fmt+n, "PROTO=TCP\0TCPREMOTEIP=", 22) ; n += 22 ;
   n += ip6_fmt(fmt+n, ip) ; fmt[n++] = 0 ;
   memcpy(fmt+n, "TCPREMOTEPORT=", 14) ; n += 14 ;
   n += uint16_fmt(fmt+n, port) ; fmt[n++] = 0 ;


Improving Quaternion documentation

Improving Quaternion documentation

--- FGQuaternion.h
+++ FGQuaternion.h
@@ -49,15 +49,26 @@
   DEFINITIONS
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

-#define ID_QUATERNION "$Id: FGQuaternion.h,v 1.2 2004/03/29 02:15:51 jberndt Exp $"
+#define ID_QUATERNION "$Id: FGQuaternion.h,v 1.3 2004/04/12 12:23:49 jberndt Exp $"
+
+namespace JSBSim {

 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   CLASS DOCUMENTATION
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

-/** Models the rotational portion of the Equations of Motion.
+/**  Models the Quaternion representation of rotations.
+    FGQuaternion is a representation of an arbitrary rotation through a
+    quaternion. It has vector properties. This class also contains access
+    functions to the euler angle representation of rotations and access to
+    transformation matrices for 3D vectors. Transformations and euler angles are
+    therefore computed once they are requested for the first time. Then they are
+    cached for later usage as long as the class is not accessed trough
+    a nonconst member function.
+
     Note: The order of rotations used in this class corresponds to a 3-2-1 sequence,
     or Y-P-R, or Z-Y-X, if you prefer.
+
     @see Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
     Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420  Naval Postgraduate
     School, January 1994
@@ -69,81 +80,63 @@
     Wiley & Sons, 1979 ISBN 0-471-03032-5
     @see Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
     1982 ISBN 0-471-08936-2
+    @author Mathias Froehlich, extended FGColumnVector4 originally by Tony Peden
+            and Jon Berndt
 */
-
-namespace JSBSim {

 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   CLASS DECLARATION
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

-/** Quaternion representation of rotations.
- *
- * FGQuaternion is a representation of an arbitrary rotation through a
- * quaternion. It has vector properties as it is a 4-vector. This
- * class also contains access functions to the euler angle
- * representation of rotations and access to transformation matrices
- * for 3D vectors. Transformations and euler angles are therefore
- * computed once they are requested for the first time. Then they are
- * cached for later usage as long as the class is not accessed trough
- * a nonconst member function.
- */
 class FGQuaternion : private FGJSBBase {
 public:
   /** Default initializer.
-   * Default initializer, initializes the class with the identity rotation.
-   */
+      Default initializer, initializes the class with the identity rotation.  */
   FGQuaternion() : mQ0(1), mQ1(0), mQ2(0), mQ3(0), mCacheValid(false) {}

   /** Copy constructor.
-   * Copy constructor, initializes the quaternion.
-   * @param q  a constant reference to another FGQuaternion instance
-   */
+      Copy constructor, initializes the quaternion.
+      @param q  a constant reference to another FGQuaternion instance  */
   FGQuaternion(const FGQuaternion& q);

-  /** Inizializer by euler angles.
-   * Initialize the quaternion with the euler angles.
-   * @param phi The euler X axis (roll) angle in radians
-   * @param tht The euler Y axis (attitude) angle in radians
-   * @param psi The euler Z axis (heading) angle in radians
-   */
+  /** Initializer by euler angles.
+      Initialize the quaternion with the euler angles.
+      @param phi The euler X axis (roll) angle in radians
+      @param tht The euler Y axis (attitude) angle in radians
+      @param psi The euler Z axis (heading) angle in radians  */
   FGQuaternion(double phi, double tht, double psi);

   /// Destructor.
   ~FGQuaternion() {}

   /** Quaternion 'velocity' for given angular rates.
-   *  Computes the quaternion derivative which results from the given
-   *  angular velocities
-   *  @param PQR a constant reference to the body rate vector
-   */
+      Computes the quaternion derivative which results from the given
+      angular velocities
+      @param PQR a constant reference to the body rate vector
+      @return the quaternion derivative */
   FGQuaternion GetQDot(const FGColumnVector3& PQR) const;

   /** Transformation matrix.
-   *  Returns a reference to the transformation/rotation matrix
-   *  corresponding to this quaternion rotation.
-   */
+      @return a reference to the transformation/rotation matrix
+      corresponding to this quaternion rotation.  */
   const FGMatrix33& GetT() const { ComputeDerived(); return mT; }

   /** Backward transformation matrix.
-   *  Returns a reference to the backward transformation/rotation matrix
-   *  corresponding to this quaternion rotation.
-   */
+      @return a reference to the inverse transformation/rotation matrix
+      corresponding to this quaternion rotation.  */
   const FGMatrix33& GetTInv() const { ComputeDerived(); return mTInv; }

-  /** Euler angles.
-   *  Returns a reference to the 3-vector of euler angles corresponding
-   *  to this quaternion rotation.
-   */
+  /** Retrieves the Euler angles.
+      @return a reference to the triad of euler angles corresponding
+      to this quaternion rotation.  */
   const FGColumnVector3& GetEuler() const {
     ComputeDerived();
     return mEulerAngles;
   }

   /** Euler angle theta.
-   *  @return the euler angle theta (pitch attitude) in radians corresponding to this
-   *  quaternion rotation.
-   */
+      @return the euler angle theta (pitch attitude) in radians corresponding to this
+      quaternion rotation.  */
   double GetEulerTheta() const {
     ComputeDerived();
     return mEulerAngles(eTht);
@@ -159,54 +152,50 @@
   }

   /** Euler angle psi.
-   *  Returns the euler angle psi corresponding to this quaternion
-   *  rotation.
-   */
+      @return the heading euler angle (psi) corresponding to this quaternion
+      rotation.
+      @units Radians  */
   double GetEulerPsi() const {
     ComputeDerived();
     return mEulerAngles(ePsi);
   }

-  /** Euler angle psi.
-   *  Returns the euler angle psi corresponding to this quaternion
-   *  rotation.
-   */
+  /** Retrieves the heading angle.
+      @return the Euler angle psi (heading) corresponding to this quaternion
+      rotation.  */
   double GetEulerPsiDeg() const {
     ComputeDerived();
     return radtodeg*mEulerAngles(ePsi);
   }

-  /** Euler angle phi.
-   *  Returns the euler angle phi corresponding to this quaternion
-   *  rotation.
-   */
+  /** Retrieves the roll angle.
+      @return the euler angle phi (roll) corresponding to this quaternion
+      rotation.
+      @units Radians  */
   double GetEulerPhi() const {
     ComputeDerived();
     return mEulerAngles(ePhi);
   }

-  /** Euler angle phi.
-   *  Returns the euler angle phi corresponding to this quaternion
-   *  rotation.
-   */
+  /** Retrieves the roll angle.
+      Returns the Euler angle phi (roll) corresponding to this quaternion rotation.
+      @units Deg */
   double GetEulerPhiDeg() const {
     ComputeDerived();
     return radtodeg*mEulerAngles(ePhi);
   }

-  /** Sine of euler angle theta.
-   *  Returns the sine of the euler angle theta corresponding to this
-   *  quaternion rotation.
-   */
+  /** Retrieves sine theta.
+      @return the sine of the Euler angle theta (pitch attitude) corresponding
+      to this quaternion rotation.  */
   double GetSinEulerTheta() const {
     ComputeDerived();
     return mEulerSines(eTht);
   }

-  /** Sine of euler angle psi.
-   *  Returns the sine of the euler angle psi corresponding to this
-   *  quaternion rotation.
-   */
+  /** Retrieves sine psi.
+      @return the sine of the euler angle psi (heading) corresponding to this
+      quaternion rotation.  */
   double GetSinEulerPsi() const {
     ComputeDerived();
     return mEulerSines(ePsi);


ARM: tegra: Provide dummy powergate implementation

In order to support increased build test coverage for drivers, implement
dummies for the powergate implementation. This will allow the drivers to
be built without requiring support for Tegra to be selected.

This patch solves the following build errors, which can be triggered in
v3.13-rc1 by selecting DRM_TEGRA without ARCH_TEGRA:

drivers/built-in.o: In function `gr3d_remove':
drivers/gpu/drm/tegra/gr3d.c:321: undefined reference to `tegra_powergate_power_off'
drivers/gpu/drm/tegra/gr3d.c:325: undefined reference to `tegra_powergate_power_off'
drivers/built-in.o: In function `gr3d_probe':
drivers/gpu/drm/tegra/gr3d.c:266: undefined reference to `tegra_powergate_sequence_power_up'
drivers/gpu/drm/tegra/gr3d.c:273: undefined reference to `tegra_powergate_sequence_power_up'

Signed-off-by: Thierry Reding <3055038c414aef68bf32c33b8118623e7554e0f2@nvidia.com>
[swarren, updated commit description]
Signed-off-by: Stephen Warren <5ef2a23ba3aff51d1cfc8c113c1ec34b608b3b13@nvidia.com>
Signed-off-by: Olof Johansson <8c69ee23f3f44f8162a64d579c1fa25c2f55298a@lixom.net>

--- include/linux/tegra-powergate.h
+++ include/linux/tegra-powergate.h
@@ -45,6 +45,7 @@

 #define TEGRA_POWERGATE_3D0	TEGRA_POWERGATE_3D

+#ifdef CONFIG_ARCH_TEGRA
 int tegra_powergate_is_powered(int id);
 int tegra_powergate_power_on(int id);
 int tegra_powergate_power_off(int id);
@@ -52,5 +53,31 @@

 /* Must be called with clk disabled, and returns with clk enabled */
 int tegra_powergate_sequence_power_up(int id, struct clk *clk);
+#else
+static inline int tegra_powergate_is_powered(int id)
+{
+	return -ENOSYS;
+}
+
+static inline int tegra_powergate_power_on(int id)
+{
+	return -ENOSYS;
+}
+
+static inline int tegra_powergate_power_off(int id)
+{
+	return -ENOSYS;
+}
+
+static inline int tegra_powergate_remove_clamping(int id)
+{
+	return -ENOSYS;
+}
+
+static inline int tegra_powergate_sequence_power_up(int id, struct clk *clk)
+{
+	return -ENOSYS;
+}
+#endif

 #endif /* _MACH_TEGRA_POWERGATE_H_ */


ARM: tegra: fix tegra_powergate_sequence_power_up() inline

Remove an invalid semicolon from the inline dummy, thus solving:
In file included from drivers/gpu/drm/tegra/gr3d.c:15:0:
include/linux/tegra-powergate.h:119:1: error: expected identifier or '(' before '{' token

Fixes: 80b28791ff04 ("ARM: tegra: pass reset to tegra_powergate_sequence_power_up()")
Reported-by: Russell King <ba324ca7b1c77fc20bb970d5aff6eea9377918a5@arm.linux.org.uk>
Signed-off-by: Stephen Warren <5ef2a23ba3aff51d1cfc8c113c1ec34b608b3b13@nvidia.com>
Reviewed-by: Thierry Reding <3055038c414aef68bf32c33b8118623e7554e0f2@nvidia.com>
Signed-off-by: Kevin Hilman <f9849b02abe18c1ece6bd40346458ed53f49d31b@linaro.org>

--- include/linux/tegra-powergate.h
+++ include/linux/tegra-powergate.h
@@ -115,7 +115,7 @@
 }

 static inline int tegra_powergate_sequence_power_up(int id, struct clk *clk,
-						    struct reset_control *rst);
+						    struct reset_control *rst)
 {
 	return -ENOSYS;
 }


Enable use of __builtin_assume_aligned when self-hosting

Clang/LLVM trunk now have support for __builtin_assume_aligned, turn this &&
into an || so we can use it ourselves.

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

--- include/llvm/Support/Compiler.h
+++ include/llvm/Support/Compiler.h
@@ -284,7 +284,7 @@

 /// \macro LLVM_ASSUME_ALIGNED
 /// \brief Returns a pointer with an assumed alignment.
-#if __has_builtin(__builtin_assume_aligned) && __GNUC_PREREQ(4, 7)
+#if __has_builtin(__builtin_assume_aligned) || __GNUC_PREREQ(4, 7)
 # define LLVM_ASSUME_ALIGNED(p, a) __builtin_assume_aligned(p, a)
 #elif defined(LLVM_BUILTIN_UNREACHABLE)
 // As of today, clang does not support __builtin_assume_aligned.


[Compiler] Fix LLVM_NODISCARD for GCC

[Compiler] Fix LLVM_NODISCARD for GCC

Summary:
This branch is currently dead since we don't use C++17.
 #if __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(nodiscard)
 #define LLVM_NODISCARD [[nodiscard]]

This branch is Clang-only.
 #elif LLVM_HAS_CPP_ATTRIBUTE(clang::warn_unused_result)
 #define LLVM_NODISCARD [[clang::warn_unused_result]]

While we could use gnu variant  [[gnu::warn_unused_result]], it is not ideal because it works only on functions.
/home/xbolva00/LLVM/llvm/include/llvm/ADT/ArrayRef.h:41:24: warning: ‘warn_unused_result’ attribute only applies to function types [-Wattributes]

GCC (checked 5,6,7,8) seems to enable [[nodiscard]] even in C++14 mode and does not produce warnings that nodiscard is C++17 feature. but Clang does - but we do not reach it due the code above. So it affects only GCC and does what we want.

Reviewers: jfb, rsmith, echristo, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: MaskRay, dexonsmith

Differential Revision: https://reviews.llvm.org/D67663

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

--- include/llvm/Support/Compiler.h
+++ include/llvm/Support/Compiler.h
@@ -137,10 +137,18 @@
 #endif

 /// LLVM_NODISCARD - Warn if a type or return value is discarded.
+
+// Use the 'nodiscard' attribute in C++17 or newer mode.
 #if __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(nodiscard)
 #define LLVM_NODISCARD [[nodiscard]]
 #elif LLVM_HAS_CPP_ATTRIBUTE(clang::warn_unused_result)
 #define LLVM_NODISCARD [[clang::warn_unused_result]]
+// Clang in C++14 mode claims that it has the 'nodiscard' attribute, but also
+// warns in the pedantic mode that 'nodiscard' is a C++17 extension (PR33518).
+// Use the 'nodiscard' attribute in C++14 mode only with GCC.
+// TODO: remove this workaround when PR33518 is resolved.
+#elif defined(__GNUC__) && LLVM_HAS_CPP_ATTRIBUTE(nodiscard)
+#define LLVM_NODISCARD [[nodiscard]]
 #else
 #define LLVM_NODISCARD
 #endif


V4L/DVB (8683): Add Micron mt9m111 chip ID in V4L2 identifiers

Signed-off-by: Robert Jarzmik <94b2a0a74cb42a2dd0cf1b763601af7f13907aa9@free.fr>
Signed-off-by: Guennadi Liakhovetski <50875182aae23d69ca7738697596f18a14e926fc@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@redhat.com>

--- include/media/v4l2-chip-ident.h
+++ include/media/v4l2-chip-ident.h
@@ -165,6 +165,7 @@
 	/* Micron CMOS sensor chips: 45000-45099 */
 	V4L2_IDENT_MT9M001C12ST		= 45000,
 	V4L2_IDENT_MT9M001C12STM	= 45005,
+	V4L2_IDENT_MT9M111		= 45007,
 	V4L2_IDENT_MT9V022IX7ATC	= 45010, /* No way to detect "normal" I77ATx */
 	V4L2_IDENT_MT9V022IX7ATM	= 45015, /* and "lead free" IA7ATx chips */
 };


added mlk::fs::as_path<T>(const T&)

added mlk::fs::as_path<T>(const T&)

error: pathspec 'include/mlk/filesystem/fs_utl.h' did not match any file(s) known to git

--- include/mlk/filesystem/fs_utl.h
+++ include/mlk/filesystem/fs_utl.h
@@ -0,0 +1,33 @@
+//
+// Copyright (c) 2013 Christoph Malek
+// See LICENSE for more information.
+//
+
+#ifndef MLK_FILESYSTEM_FS_UTL_H
+#define MLK_FILESYSTEM_FS_UTL_H
+
+
+#include <mlk/filesystem/fs_handle.h>
+
+#include <string>
+
+
+namespace mlk
+{
+	namespace fs
+	{
+		template<typename T>
+		std::string as_path(const T& t);
+
+		template<>
+		inline std::string as_path<std::string>(const std::string& str)
+		{return str;}
+
+		template<>
+		inline std::string as_path<fs_handle<fs_type::file>>(const fs_handle<fs_type::file>& file)
+		{return file.path();}
+	}
+}
+
+
+#endif // MLK_FILESYSTEM_FS_UTL_H


Fix normal calculation for triangle strip geometry

--- include/polar/component/model.h
+++ include/polar/component/model.h
@@ -30,11 +30,25 @@
 		PointsType calculate_normals() const {
 			PointsType normals;
 			normals.resize(points.size());
-			for(PointsType::size_type i = 0; i < points.size(); i += 3) {
+
+			PointsType::size_type i = 0;
+			while(i < points.size() - 3) {
 				auto normal = calculate_normal(points[i], points[i + 1], points[i + 2]);
 				normals[i + 0] = normal;
 				normals[i + 1] = normal;
 				normals[i + 2] = normal;
+
+				switch(type) {
+				case GeometryType::Triangles:
+					i += 3;
+					break;
+				case GeometryType::TriangleStrip:
+					++i;
+					break;
+				default:
+					debugmanager()->fatal("cannot calculate normals for non-triangle geometry");
+					break;
+				}
 			}
 			return normals;
 		}


nvc0: sort performance metrics alphabetically

Signed-off-by: Samuel Pitoiset <506e97eed81d9e59d22f4c73fb51123bb62b4a30@gmail.com>
Reviewed-by: Ilia Mirkin <bcbbb7aa705ec3a5fc5824c01a845186c3d62fca@alum.mit.edu>

--- src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_metric.c
+++ src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_metric.c
@@ -178,9 +178,9 @@
    &sm20_branch_efficiency,
    &sm20_inst_per_wrap,
    &sm20_inst_replay_overhead,
+   &sm20_ipc,
    &sm20_issued_ipc,
    &sm20_issue_slot_utilization,
-   &sm20_ipc,
 };

 /* ==== Compute capability 2.1 (GF108+ except GF110) ==== */
@@ -249,10 +249,10 @@
    &sm21_inst_issued,
    &sm20_inst_per_wrap,
    &sm21_inst_replay_overhead,
+   &sm20_ipc,
    &sm21_issued_ipc,
    &sm21_issue_slots,
    &sm21_issue_slot_utilization,
-   &sm20_ipc,
 };

 /* ==== Compute capability 3.0 (GK104/GK106/GK107) ==== */
@@ -321,10 +321,10 @@
    &sm30_inst_issued,
    &sm20_inst_per_wrap,
    &sm30_inst_replay_overhead,
+   &sm20_ipc,
    &sm30_issued_ipc,
    &sm30_issue_slots,
    &sm30_issue_slot_utilization,
-   &sm20_ipc,
    &sm30_shared_replay_overhead,
 };

@@ -335,10 +335,10 @@
    &sm30_inst_issued,
    &sm20_inst_per_wrap,
    &sm30_inst_replay_overhead,
+   &sm20_ipc,
    &sm30_issued_ipc,
    &sm30_inst_issued,
    &sm30_issue_slot_utilization,
-   &sm20_ipc,
    &sm30_shared_replay_overhead,
 };


Added List::find(). List cleanup.

Added List::find().
List cleanup.

git-svn-id: 85ca188301869374914d2b46c1b0098f9177e54a@30 77e99264-1435-0410-a361-933414250d7c

--- Finagle/List.h
+++ Finagle/List.h
@@ -45,19 +45,21 @@
   template <typename Container>
   explicit List( Container container ) : std::list<Type, Alloc>( container.begin(), container.end() ) {}

-  Type &operator[]( unsigned Index );
-  Type const &operator[]( unsigned Index ) const;
+  Type &operator[]( unsigned index );
+  Type const &operator[]( unsigned index ) const;

-  bool contains( Type const &El ) const;
+  ConstIterator find( Type const &el ) const;
+  Iterator find( Type const &el );
+  bool contains( Type const &el ) const;

   // For sorted lists
-  Iterator insert( Type const &El );
+  Iterator insert( Type const &el );

   // For unsorted-lists (pass-through wrappers)
-  Iterator insert( Iterator Pos, Type const &El );
+  Iterator insert( Iterator pos, Type const &el );
   template <class InputIterator>
-  void insert( Iterator Pos, InputIterator f, InputIterator l );
-  void insert( Iterator Pos, size_type n, Type const &El );
+  void insert( Iterator pos, InputIterator first, InputIterator last );
+  void insert( Iterator pos, size_type n, Type const &el );
 };

 // INLINE/TEMPLATE IMPLEMENTATION *********************************************
@@ -68,10 +70,22 @@
 ** element (i.e. \c null).
 */
 template <typename Type, typename Alloc>
-inline Type &List<Type, Alloc>::operator[]( unsigned Index )
+inline Type &List<Type, Alloc>::operator[]( unsigned index )
 {
-  Type const &r = operator[]( Index );
-  return( const_cast<Type &>( r ) );
+  Type const &r = operator[]( index );
+  return const_cast<Type &>( r );
+}
+
+template <typename Type, typename Alloc>
+inline typename List<Type, Alloc>::ConstIterator List<Type, Alloc>::find( Type const &el ) const
+{
+  return std::find( List::begin(), List::end(), el );
+}
+
+template <typename Type, typename Alloc>
+inline typename List<Type, Alloc>::Iterator List<Type, Alloc>::find( Type const &el )
+{
+  return std::find( List::begin(), List::end(), el );
 }

 //! Returns \c true iff the list contains an element equal to \a El.
@@ -87,49 +101,49 @@
 ** element (i.e. \c null).
 */
 template <typename Type, typename Alloc>
-Type const &List<Type, Alloc>::operator[]( unsigned Index ) const
+Type const &List<Type, Alloc>::operator[]( unsigned index ) const
 {
   static Type null;

-  if ( Index >= List::size() )
-    return( null );
+  if ( index >= List::size() )
+    return null;

   ConstIterator i = List::begin();
-  while ( Index-- )
+  while ( index-- )
     ++i;

-  return( *i );
+  return *i;
 }

 template <typename Type, typename Alloc>
-typename List<Type, Alloc>::Iterator List<Type, Alloc>::insert( Type const &El )
+typename List<Type, Alloc>::Iterator List<Type, Alloc>::insert( Type const &el )
 {
   for ( Iterator i = List::begin(); i != List::end(); ++i ) {
-    if ( El < *i )
-      return( List::insert( i, El ) );
+    if ( el < *i )
+      return List::insert( i, el );
   }

-  push_back( El );
-  return( --List::end() );
+  push_back( el );
+  return --List::end();
 }

 template <typename Type, typename Alloc>
-typename List<Type, Alloc>::Iterator List<Type, Alloc>::insert( Iterator Pos, Type const &El )
+typename List<Type, Alloc>::Iterator List<Type, Alloc>::insert( Iterator pos, Type const &el )
 {
-  return( List::insert( Pos, El ) );
+  return List::insert( pos, el );
 }

 template <typename Type, typename Alloc>
 template <class InputIterator>
-void List<Type, Alloc>::insert( Iterator Pos, InputIterator f, InputIterator l )
+void List<Type, Alloc>::insert( Iterator pos, InputIterator first, InputIterator last )
 {
-  List::insert( Pos, f, l );
+  List::insert( pos, first, last );
 }

 template <typename Type, typename Alloc>
-void List<Type, Alloc>::insert( Iterator Pos, size_type n, Type const &El )
+void List<Type, Alloc>::insert( Iterator pos, size_type n, Type const &el )
 {
-  List::insert( Pos, n, El );
+  List::insert( pos, n, el );
 }

 }


lessByExtractor functor

lessByExtractor functor

--- include/psf/SpectrumAlgorithm.h
+++ include/psf/SpectrumAlgorithm.h
@@ -36,6 +36,26 @@

 namespace ms
 {
+
+// class lessByExtractor
+/**
+ * Compare two elements with regard to a certain aspect.
+ *
+ * Typically, an element in a spectrum represents more than one value
+ * (such as m/z, intensity, time etc.) Use this functor to compare two
+ * elements with regard to one of these values.
+ */
+template< typename Element, typename Extractor >
+class lessByExtractor {
+  public:
+  lessByExtractor( const Extractor& e ) : extract_(e) {};
+  bool operator()( const Element&, const Element& ) const;
+
+  private:
+  Extractor extract_;
+};
+
+

 // findBump()
 /**
@@ -107,6 +127,14 @@

 /* implementation */
+
+// lessByExtractor::operator()()
+template< typename Element, typename Extractor >
+bool lessByExtractor< Element, Extractor >::operator()( const Element& lhs, const Element& rhs ) const {
+  return extract_(lhs) < extract_(rhs);
+}
+
+

 // findBump()
 template<typename FwdIter, typename Compare>


Fixed more bugs with C bump memory allocator

--- coconut/runtime/mem_mng.h
+++ coconut/runtime/mem_mng.h
@@ -6,6 +6,7 @@

 #define INIT_HEAP_SIZE (1 << 20)
 #define ALLIGN_BY_16(x) (((((x) + 15) >> 4) << 4))
+#define MAX_HEAP_SIZE ((memory_size_t)(1) << 31)

 typedef struct heap_t {
   storage_t storage;
@@ -31,22 +32,27 @@
 }

 heap_t heapObject;
+memory_size_t increase_rate;

 storage_t bulk_alloc(memory_size_t size) {
   memory_size_t aligned_size = ALLIGN_BY_16(size);
   memory_size_t new_free_index = heapObject.free_index + aligned_size;
   if (new_free_index >= heapObject.size) {
+  	increase_rate = heapObject.size < INIT_HEAP_SIZE ? INIT_HEAP_SIZE : increase_rate * 2;
+    memory_size_t new_size = heapObject.size + increase_rate;
+    new_size = new_size < new_free_index ? heapObject.size + aligned_size : new_size;
+    // printf("%lld < %lld\n", new_size + heapObject.size * 2, MAX_HEAP_SIZE);
+    new_size = (new_size + heapObject.size * 2) < MAX_HEAP_SIZE ? new_size : new_size * 5 / 8;
+
     heap_t oldHeapObject = heapObject;
-    memory_size_t new_size = heapObject.size < INIT_HEAP_SIZE ? INIT_HEAP_SIZE : heapObject.size * 2;
-    new_size = new_size < new_free_index ? heapObject.size + new_free_index : new_size;
+    // fprintf(stderr, "Increased the size of heap into %llu, old size: %llu, asked size: %llu, last given index: %llu!\n", new_size, oldHeapObject.size, size, oldHeapObject.free_index);
     heapObject = initHeap(new_size);
-    heapObject.free_index = oldHeapObject.free_index;
+    // heapObject.free_index = oldHeapObject.free_index;
     // memcpy(heapObject.storage, oldHeapObject.storage, heapObject.free_index);
     // free(oldHeapObject.storage);
-    fprintf(stderr, "Increased the size of heap into %llu, old size: %llu, neededSize: %llu!\n", heapObject.size, oldHeapObject.size, size);
   }
   storage_t allocatedStorage = (void *)((memory_size_t)heapObject.storage + heapObject.free_index);
-  heapObject.free_index = new_free_index;
+  heapObject.free_index = heapObject.free_index + aligned_size;
   return allocatedStorage;
 }

@@ -54,4 +60,6 @@
   memory_size_t aligned_size = ALLIGN_BY_16(size);
   heapObject.free_index -= aligned_size;
   assert(heapObject.free_index >= 0);
+  // if(heapObject.free_index < 0)
+  // 	heapObject.free_index = 0;
 }


consistant `SceKernelRWLockInfo`'s fields naming

--- include/psp2/kernel/threadmgr.h
+++ include/psp2/kernel/threadmgr.h
@@ -1249,9 +1249,9 @@
 	/** Attributes */
   SceUInt32       attr;
 	/** The current lock count */
-	SceInt32        currentCount;
+	SceInt32        lockCount;
 	/** The UID of the current owner of the rwlock with write access, 0 when locked for reads */
-	SceUID          currentWriteOwnerId;
+	SceUID          writeOwnerId;
 	/** The number of threads waiting on the rwlock for read access */
 	SceUInt32       numReadWaitThreads;
 	/** The number of threads waiting on the rwlock for write access */


Generic alloc and free using bump by flag

--- coconut/runtime/mem_mng.h
+++ coconut/runtime/mem_mng.h
@@ -63,3 +63,19 @@
   // if(heapObject.free_index < 0)
   // 	heapObject.free_index = 0;
 }
+
+storage_t storage_alloc(memory_size_t size) {
+#ifdef BUMP
+	return bulk_alloc(size);
+#else
+	return malloc(size);
+#endif
+}
+
+void storage_free(storage_t storage, memory_size_t size) {
+#ifdef BUMP
+	bulk_free(storage, size);
+#else
+	free(storage);
+#endif
+}


Fixed some forwarding issues of the arguments in the reflectors.

--- include/reflection/reflectors.h
+++ include/reflection/reflectors.h
@@ -104,10 +104,10 @@
   {                                                                                \
   private:                                                                                \
     template<typename Obj, typename Arg>                                                                      \
-    friend auto call(const ReflectorClassName &, Obj &&obj, utils::type_list<>, Arg arg)                      \
-      -> decltype(std::forward<Obj>(obj) = arg)                                                               \
+    friend auto call(const ReflectorClassName &, Obj &&obj, utils::type_list<>, Arg &&arg)                    \
+      -> decltype(std::forward<Obj>(obj) = std::forward<Arg>(arg))                                            \
     {                                                                                \
-      return std::forward<Obj>(obj) = arg;                                                                    \
+      return std::forward<Obj>(obj) = std::forward<Arg>(arg);                                                 \
     }                                                                                \
                                                                                \
   public:                                                                                \
@@ -123,14 +123,16 @@
         on_call(                                                                                \
           reflector(utils::delayed(*this, utils::type_list<Arg>{})),                                          \
           derived(utils::delayed(*this, utils::type_list<Arg>{})),                                            \
-          utils::type_list<>{}, arg                                                                           \
+          utils::type_list<>{},                                                                               \
+          std::forward<Arg>(arg)                                                                              \
         )                                                                                \
       )                                                                                \
     {                                                                                \
       return on_call(                                                                                \
         reflector(utils::delayed(*this, utils::type_list<Arg>{})),                                            \
         derived(utils::delayed(*this, utils::type_list<Arg>{})),                                              \
-        utils::type_list<>{}, arg                                                                             \
+        utils::type_list<>{},                                                                                \
+        std::forward<Arg>(arg)                                                                                \
       );                                                                                \
     }                                                                                \
   }                                                                                \


more tests

more tests

--- tests-basic.c
+++ tests-basic.c
@@ -47,6 +47,29 @@
     printf("Freeing ptr0\n");
     shmfree(ptr[0], MEM_SIZE);

+    //Allocate super big thing
+    printf("Allocating more than we have\n");
+    size = MEM_SIZE - sizeof(Header) + 10;
+    ptr[0] = shmalloc(2, &size, mem, MEM_SIZE);
+    if(ptr[0] != NULL)
+    {
+        fprintf(stderr, "Failed test to allocate more than we have.\n");
+        return 1;
+    }
+
+    //Two references
+    printf("Testing multiple references\n");
+    size = sizeof(int);
+    ptr[0] = shmalloc(9, &size, mem, MEM_SIZE);
+    *((int *)ptr[0]) = 5;
+
+    ptr[1] = shmalloc(9, &size, mem, MEM_SIZE);
+
+    if(*((int *)ptr[1]) != 5)
+    {
+        fprintf(stderr, "Multiple refernces did not work. Got %d, expecting 5\n", *((int *)ptr[1]));
+        return 1;
+    }


added several include headers purposes

added several include headers purposes

--- include/sqlite_orm/sqlite_orm.h
+++ include/sqlite_orm/sqlite_orm.h
@@ -7,16 +7,17 @@
 #include <type_traits>
 #include <sqlite3.h>
 #include <stdexcept>
-#include <vector>
-#include <sstream>
-#include <algorithm>
-#include <memory>
+#include <vector>   //  std::vector
+#include <sstream>  //  std::stringstream
+#include <algorithm>    //  std::find
+#include <memory>   //  std::shared_ptr, std::unique_ptr
 #include <typeinfo>
 #include <regex>
 #include <map>
 #include <cctype>
 #include <initializer_list>
-#include <set>
+#include <set>  //  std::set
+#include <functional>   //  std::function

 namespace sqlite_orm {


code format

code format

--- include/sqlite_orm/sqlite_orm.h
+++ include/sqlite_orm/sqlite_orm.h
@@ -22,7 +22,7 @@
 #include <stdexcept>
 #include <sstream>  //  std::ostringstream

-namespace sqlite_orm {
+        namespace sqlite_orm {

     enum class orm_error_code {
         not_found = 1,
@@ -38,7 +38,6 @@
         invalid_collate_argument_enum,
         failed_to_init_a_backup,
     };
-
 }

 namespace sqlite_orm {
@@ -216,7 +215,6 @@

 // #include "static_magic.h"

-
 #include <type_traits>  //  std::false_type, std::true_type, std::integral_constant

 namespace sqlite_orm {
@@ -247,7 +245,6 @@
     }

 }
-

 namespace sqlite_orm {

@@ -924,7 +921,6 @@

 // #include "constraints.h"

-
 namespace sqlite_orm {

     namespace internal {
@@ -1162,7 +1158,6 @@
 // #include "default_value_extractor.h"

 // #include "constraints.h"
-

 namespace sqlite_orm {

@@ -1602,7 +1597,6 @@

 // #include "optional_container.h"

-
 namespace sqlite_orm {

     namespace internal {
@@ -1634,7 +1628,6 @@
         };
     }
 }
-

 namespace sqlite_orm {

@@ -3013,7 +3006,6 @@

 // #include "conditions.h"

-
 namespace sqlite_orm {

     namespace internal {
@@ -3132,7 +3124,6 @@
 // #include "operators.h"

 // #include "is_base_of_template.h"
-

 #include <type_traits>  //  std::true_type, std::false_type, std::declval

@@ -3170,7 +3161,6 @@
 #endif
     }
 }
-

 namespace sqlite_orm {

@@ -3762,7 +3752,6 @@

 // #include "optional_container.h"

-
 namespace sqlite_orm {

     namespace internal {
@@ -4154,7 +4143,6 @@

 // #include "column.h"

-
 namespace sqlite_orm {

     namespace internal {
@@ -4284,7 +4272,6 @@
 #include <utility>  //  std::declval

 // #include "is_std_ptr.h"
-

 namespace sqlite_orm {

@@ -4472,7 +4459,6 @@

 // #include "journal_mode.h"

-
 #include <string>  //  std::string
 #include <memory>  //  std::unique_ptr
 #include <array>  //  std::array
@@ -4532,7 +4518,6 @@
 }

 // #include "error_code.h"
-

 namespace sqlite_orm {

@@ -4890,7 +4875,6 @@

 // #include "alias.h"

-
 namespace sqlite_orm {

     namespace internal {
@@ -5138,7 +5122,6 @@
         }
     }
 }
-

 namespace sqlite_orm {

@@ -5416,7 +5399,6 @@
 // #include "type_printer.h"

 // #include "column.h"
-

 namespace sqlite_orm {

@@ -5734,11 +5716,9 @@

 // #include "field_value_holder.h"

-
 #include <type_traits>  //  std::enable_if

 // #include "column.h"
-

 namespace sqlite_orm {
     namespace internal {
@@ -5761,7 +5741,6 @@
         };
     }
 }
-

 namespace sqlite_orm {

@@ -6319,7 +6298,6 @@

 // #include "view.h"

-
 #include <memory>  //  std::shared_ptr
 #include <string>  //  std::string
 #include <utility>  //  std::forward, std::move
@@ -6334,7 +6312,6 @@
 // #include "error_code.h"

 // #include "iterator.h"
-

 #include <memory>  //  std::shared_ptr, std::unique_ptr, std::make_shared
 #include <sqlite3.h>
@@ -6350,7 +6327,6 @@
 // #include "statement_finalizer.h"

 // #include "error_code.h"
-

 namespace sqlite_orm {

@@ -6480,7 +6456,6 @@

 // #include "ast_iterator.h"

-
 #include <vector>  //  std::vector
 #include <functional>  //  std::reference_wrapper

@@ -6495,7 +6470,6 @@
 // #include "core_functions.h"

 // #include "prepared_statement.h"
-

 #include <sqlite3.h>
 #include <iterator>  //  std::iterator_traits
@@ -6505,13 +6479,11 @@

 // #include "connection_holder.h"

-
 #include <sqlite3.h>
 #include <string>  //  std::string
 #include <system_error>  //  std::system_error

 // #include "error_code.h"
-

 namespace sqlite_orm {

@@ -6586,7 +6558,6 @@
 }

 // #include "select_constraints.h"
-

 namespace sqlite_orm {

@@ -6887,7 +6858,6 @@
     }
 }

-
 namespace sqlite_orm {

     namespace internal {
@@ -7298,7 +7268,6 @@
 // #include "prepared_statement.h"

 // #include "connection_holder.h"
-

 namespace sqlite_orm {

@@ -7358,7 +7327,6 @@

 // #include "storage_base.h"

-
 #include <functional>  //  std::function, std::bind
 #include <sqlite3.h>
 #include <string>  //  std::string
@@ -7373,7 +7341,6 @@

 // #include "pragma.h"

-
 #include <string>  //  std::string
 #include <sqlite3.h>
 #include <functional>  //  std::function
@@ -7386,7 +7353,6 @@
 // #include "journal_mode.h"

 // #include "connection_holder.h"
-

 namespace sqlite_orm {

@@ -7508,7 +7474,6 @@

 // #include "limit_accesor.h"

-
 #include <sqlite3.h>
 #include <map>  //  std::map
 #include <functional>  //  std::function
@@ -7516,7 +7481,6 @@

 // #include "connection_holder.h"

-
 namespace sqlite_orm {

     namespace internal {
@@ -7650,11 +7614,9 @@

 // #include "transaction_guard.h"

-
 #include <functional>  //  std::function

 // #include "connection_holder.h"
-

 namespace sqlite_orm {

@@ -7730,7 +7692,6 @@

 // #include "backup.h"

-
 #include <sqlite3.h>
 #include <string>  //  std::string
 #include <memory>
@@ -7738,7 +7699,6 @@
 // #include "error_code.h"

 // #include "connection_holder.h"
-

 namespace sqlite_orm {

@@ -7804,7 +7764,6 @@
         };
     }
 }
-

 namespace sqlite_orm {

@@ -8341,12 +8300,10 @@

 // #include "expression_object_type.h"

-
 #include <type_traits>  //  std::decay
 #include <functional>  //  std::reference_wrapper

 // #include "prepared_statement.h"
-

 namespace sqlite_orm {

@@ -8464,7 +8421,6 @@
         };
     }
 }
-

 namespace sqlite_orm {

@@ -11351,20 +11307,19 @@
 #include <utility>  //  std::pair
 #include <functional>  //  std::reference_wrapper

-// #include "conditions.h"
-
-// #include "operators.h"
-
-// #include "select_constraints.h"
-
-// #include "prepared_statement.h"
-
-// #include "optional_container.h"
-
-// #include "core_functions.h"
-
-
-namespace sqlite_orm {
+    // #include "conditions.h"
+
+    // #include "operators.h"
+
+    // #include "select_constraints.h"
+
+    // #include "prepared_statement.h"
+
+    // #include "optional_container.h"
+
+    // #include "core_functions.h"
+
+    namespace sqlite_orm {

     namespace internal {

@@ -11619,7 +11574,6 @@
 // #include "static_magic.h"

 // #include "expression_object_type.h"
-

 namespace sqlite_orm {

@@ -11775,7 +11729,6 @@
 // #include "core_functions.h"

 // #include "constraints.h"
-

 namespace sqlite_orm {


parse header chunk in a loop (don't depend on a fixed chunk ordering)

git-svn-id: a4d7c1866f8397a4106e0b57fc4fbf792bbdaaaf@10792 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

--- libavformat/electronicarts.c
+++ libavformat/electronicarts.c
@@ -162,17 +162,16 @@
     uint32_t blockid, size = 0;
     EaDemuxContext *ea = s->priv_data;
     ByteIOContext *pb = &s->pb;
+    int i;
+
+    for (i=0; i<5 && (!ea->audio_codec || !ea->video_codec); i++) {
+        unsigned int startpos = url_ftell(pb);

     blockid = get_le32(pb);
-    if (blockid == MVhd_TAG) {
         size = get_le32(pb);
-        process_video_header_vp6(s);
-        url_fskip(pb, size-32);
-        blockid = get_le32(pb);
-    }
-    if (blockid != SCHl_TAG)
-        return 0;
-    size += get_le32(pb);
+
+        switch (blockid) {
+            case SCHl_TAG :
     blockid = get_le32(pb);
     if (blockid == GSTR_TAG) {
         url_fskip(pb, 4);
@@ -182,9 +181,17 @@
     }

     process_audio_header_elements(s);
-
-    /* skip to the start of the data */
-    url_fseek(pb, size, SEEK_SET);
+                break;
+
+            case MVhd_TAG :
+                process_video_header_vp6(s);
+                break;
+        }
+
+        url_fseek(pb, startpos + size, SEEK_SET);
+    }
+
+    url_fseek(pb, 0, SEEK_SET);

     return 1;
 }


Apply implicit fallback seat config

Apply implicit fallback seat config

The implicit fallback seat config needs to be applied (if created).
Otherwise, the input devices will still be removed from the implicit
default seat on reload when there is any seat config.

--- sway/input/input-manager.c
+++ sway/input/input-manager.c
@@ -102,7 +102,8 @@
 		seat = input_manager_get_default_seat();
 		struct seat_config *sc = new_seat_config(seat->wlr_seat->name);
 		sc->fallback = true;
-		store_seat_config(sc);
+		sc = store_seat_config(sc);
+		input_manager_apply_seat_config(sc);
 	}
 }


Fixed bug with -out and extensions

Fixed bug with -out and extensions

git-svn-id: ab66a9de07fa9d47c5829c82992f5279466c775f@4097 63c20433-aa62-49bd-875c-5a186b69a8fb

--- src/media_tools/media_export.c
+++ src/media_tools/media_export.c
@@ -252,6 +252,7 @@
 	GF_DecoderConfig *dcfg;
 	GF_GenericSampleDescription *udesc;
 	char szName[1000], szEXT[10], szNum[1000], *dsi;
+	char *ext_start = NULL;
 	FILE *out;
 	GF_BitStream *bs;
 	u32 track, i, di, count, m_type, m_stype, dsi_size, is_mj2k;
@@ -403,10 +404,18 @@
 	}
 	if (dumper->flags & GF_EXPORT_PROBE_ONLY) return GF_OK;

+	ext_start = strrchr(dumper->out_name, '.');
+
 	if (dumper->sample_num) {
 		GF_ISOSample *samp = gf_isom_get_sample(dumper->file, track, dumper->sample_num, &di);
 		if (!samp) return GF_BAD_PARAM;
-		sprintf(szName, "%s_%d%s", dumper->out_name, dumper->sample_num, szEXT);
+		if (ext_start) {
+			ext_start[0]=0;
+			sprintf(szName, "%s_%d%s", dumper->out_name, dumper->sample_num, ext_start+1);
+			ext_start[0]='.';
+		} else {
+			sprintf(szName, "%s_%d%s", dumper->out_name, dumper->sample_num, szEXT);
+		}
 		out = gf_f64_open(szName, "wb");
 		bs = gf_bs_from_file(out, GF_BITSTREAM_WRITE);
 		if (is_mj2k)
@@ -425,10 +434,20 @@
 		GF_ISOSample *samp = gf_isom_get_sample(dumper->file, track, i+1, &di);
 		if (!samp) break;

-		if (count>=1000) {
-			sprintf(szName, "%s_%08d%s", dumper->out_name, i+1, szEXT);
+		if (ext_start) {
+			ext_start[0]=0;
+			if (count>=1000) {
+				sprintf(szName, "%s_%08d%s", dumper->out_name, dumper->sample_num, ext_start+1);
+			} else {
+				sprintf(szName, "%s_%03d%s", dumper->out_name, dumper->sample_num, ext_start+1);
+			}
+			ext_start[0]='.';
 		} else {
-			sprintf(szName, "%s_%03d%s", dumper->out_name, i+1, szEXT);
+			if (count>=1000) {
+				sprintf(szName, "%s_%08d%s", dumper->out_name, i+1, szEXT);
+			} else {
+				sprintf(szName, "%s_%03d%s", dumper->out_name, i+1, szEXT);
+			}
 		}
 		out = gf_f64_open(szName, "wb");
 		bs = gf_bs_from_file(out, GF_BITSTREAM_WRITE);
@@ -582,6 +601,7 @@
 	return GF_NOT_SUPPORTED;
 #else
 	GF_Err e = GF_OK;
+	Bool add_ext;
 	GF_DecoderConfig *dcfg;
 	GF_GenericSampleDescription *udesc;
 	char szName[1000], szEXT[5], GUID[16];
@@ -618,6 +638,7 @@
 	if ((m_stype==GF_ISOM_SUBTYPE_MPEG4) || (m_stype==GF_ISOM_SUBTYPE_MPEG4_CRYP))
 		dcfg = gf_isom_get_decoder_config(dumper->file, track, 1);

+	add_ext = (dumper->out_name && strrchr(dumper->out_name , '.')==NULL) ? 1 : 0;
 	strcpy(szName, dumper->out_name ? dumper->out_name : "");
 	if (dcfg) {
 		switch (dcfg->streamType) {
@@ -627,16 +648,19 @@
 				dsi = dcfg->decoderSpecificInfo->data;
 				dcfg->decoderSpecificInfo->data = NULL;
 				dsi_size = dcfg->decoderSpecificInfo->dataLength;
-				strcat(szName, ".cmp");
+				if (add_ext)
+					strcat(szName, ".cmp");
 				gf_export_message(dumper, GF_OK, "Extracting MPEG-4 Visual stream to cmp");
 				break;
 			case GPAC_OTI_VIDEO_AVC:
 				avccfg = gf_isom_avc_config_get(dumper->file, track, 1);
-				strcat(szName, ".h264");
+				if (add_ext)
+					strcat(szName, ".h264");
 				gf_export_message(dumper, GF_OK, "Extracting MPEG-4 AVC-H264 stream to h264");
 				break;
 			case GPAC_OTI_VIDEO_MPEG1:
-				strcat(szName, ".m1v");
+				if (add_ext)
+					strcat(szName, ".m1v");
 				gf_export_message(dumper, GF_OK, "Extracting MPEG-1 Visual stream to m1v");
 				break;
 			case GPAC_OTI_VIDEO_MPEG2_SIMPLE:
@@ -645,19 +669,23 @@
 			case GPAC_OTI_VIDEO_MPEG2_SPATIAL:
 			case GPAC_OTI_VIDEO_MPEG2_HIGH:
 			case GPAC_OTI_VIDEO_MPEG2_422:
-				strcat(szName, ".m2v");
+				if (add_ext)
+					strcat(szName, ".m2v");
 				gf_export_message(dumper, GF_OK, "Extracting MPEG-2 Visual stream to m2v");
 				break;
 			case GPAC_OTI_IMAGE_JPEG:
-				strcat(szName, ".jpg");
+				if (add_ext)
+					strcat(szName, ".jpg");
 				gf_export_message(dumper, GF_OK, "Extracting JPEG image");
 				break;
 			case GPAC_OTI_IMAGE_PNG:
-				strcat(szName, ".png");
+				if (add_ext)
+					strcat(szName, ".png");
 				gf_export_message(dumper, GF_OK, "Extracting PNG image");
 				break;
 			case GPAC_OTI_MEDIA_OGG:
-				strcat(szName, ".ogg");
+				if (add_ext)
+					strcat(szName, ".ogg");
 				gf_export_message(dumper, GF_OK, "Extracting Ogg video");
 				is_ogg = 1;
 				break;
@@ -674,7 +702,8 @@
 				dsi = dcfg->decoderSpecificInfo->data;
 				dcfg->decoderSpecificInfo->data = NULL;
 				dsi_size = dcfg->decoderSpecificInfo->dataLength;
-				strcat(szName, ".aac");
+				if (add_ext)
+					strcat(szName, ".aac");
 				is_aac = 1;
 				aac_type = dcfg->objectTypeIndication - GPAC_OTI_AUDIO_AAC_MPEG2_MP;
 				gf_export_message(dumper, GF_OK, "Extracting MPEG-2 AAC");
@@ -689,21 +718,25 @@
 				dcfg->decoderSpecificInfo->data = NULL;
 				dsi_size = dcfg->decoderSpecificInfo->dataLength;
 				is_aac = 2;
-				strcat(szName, ".aac");
+				if (add_ext)
+					strcat(szName, ".aac");
 				gf_export_message(dumper, GF_OK, "Extracting MPEG-4 AAC");
 				break;
 			case GPAC_OTI_AUDIO_MPEG2_PART3:
 			case GPAC_OTI_AUDIO_MPEG1:
-				strcat(szName, ".mp3");
+				if (add_ext)
+					strcat(szName, ".mp3");
 				gf_export_message(dumper, GF_OK, "Extracting MPEG-1/2 Audio (MP3)");
 				break;
 			case GPAC_OTI_MEDIA_OGG:
-				strcat(szName, ".ogg");
+				if (add_ext)
+					strcat(szName, ".ogg");
 				is_ogg = 1;
 				gf_export_message(dumper, GF_OK, "Extracting Ogg audio");
 				break;
 			case GPAC_OTI_AUDIO_13K_VOICE:
-				strcat(szName, ".qcp"); qcp_type = 1;
+				if (add_ext)
+					strcat(szName, ".qcp"); qcp_type = 1;
 				memcpy(GUID, QCP_QCELP_GUID_1, sizeof(char)*16);
 				gf_export_message(dumper, GF_OK, "Extracting QCELP-13K (QCP file)");
 				break;
@@ -739,7 +772,8 @@
 				dsi = dcfg->decoderSpecificInfo->data;
 				dcfg->decoderSpecificInfo->data = NULL;
 				dsi_size = dcfg->decoderSpecificInfo->dataLength;
-				strcat(szName, ".idx");
+				if (add_ext)
+					strcat(szName, ".idx");
 				gf_export_message(dumper, GF_OK, "Extracting NeroDigital VobSub subpicture stream");
 				break;
 			default:
@@ -754,13 +788,16 @@
 		gf_odf_desc_del((GF_Descriptor *) dcfg);
 	} else {
 		if (m_stype==GF_ISOM_SUBTYPE_3GP_AMR) {
-			strcat(szName, ".amr");
+			if (add_ext)
+				strcat(szName, ".amr");
 			gf_export_message(dumper, GF_OK, "Extracting AMR Audio");
 		} else if (m_stype==GF_ISOM_SUBTYPE_3GP_AMR_WB) {
-			strcat(szName, ".awb");
+			if (add_ext)
+				strcat(szName, ".awb");
 			gf_export_message(dumper, GF_OK, "Extracting AMR WideBand Audio");
 		} else if (m_stype==GF_ISOM_SUBTYPE_3GP_QCELP) {
-			strcat(szName, ".qcp"); qcp_type = 1;
+			if (add_ext)
+				strcat(szName, ".qcp"); qcp_type = 1;
 			memcpy(GUID, QCP_QCELP_GUID_1, sizeof(char)*16);
 			gf_export_message(dumper, GF_OK, "Extracting QCELP-13K (QCP file)");
 		} else if (m_stype==GF_ISOM_SUBTYPE_3GP_EVRC) {
@@ -773,22 +810,28 @@
 			if (dumper->flags & GF_EXPORT_PROBE_ONLY) dumper->flags |= GF_EXPORT_USE_QCP;
 		} else if (m_stype==GF_ISOM_SUBTYPE_3GP_H263) {
 			gf_export_message(dumper, GF_OK, "Extracting H263 Video");
-			strcat(szName, ".263");
+			if (add_ext)
+				strcat(szName, ".263");
 		} else if (m_stype==GF_ISOM_SUBTYPE_3GP_DIMS) {
 			return gf_media_export_nhml(dumper, 1);
 		} else if ((m_stype==GF_ISOM_SUBTYPE_AVC_H264) || (m_stype==GF_ISOM_SUBTYPE_AVC2_H264) || (m_stype==GF_ISOM_SUBTYPE_SVC_H264) ) {
 			avccfg = gf_isom_avc_config_get(dumper->file, track, 1);
-			strcat(szName, ".h264");
+			if (add_ext)
+				strcat(szName, ".h264");
 			gf_export_message(dumper, GF_OK, "Extracting MPEG-4 AVC-H264 stream to h264");
 		} else if (m_type==GF_ISOM_MEDIA_FLASH) {
 			gf_export_message(dumper, GF_OK, "Extracting Macromedia Flash Movie");
-			strcat(szName, ".swf");
+			if (add_ext)
+				strcat(szName, ".swf");
 		} else if (m_stype==GF_ISOM_SUBTYPE_AC3) {
 			gf_export_message(dumper, GF_OK, "Extracting AC3 Audio");
-			strcat(szName, ".ac3");
+			if (add_ext)
+				strcat(szName, ".ac3");
 		} else {
-			strcat(szName, ".");
-			strcat(szName, gf_4cc_to_str(m_stype));
+			if (add_ext) {
+				strcat(szName, ".");
+				strcat(szName, gf_4cc_to_str(m_stype));
+			}
 			udesc = gf_isom_get_generic_sample_description(dumper->file, track, 1);
 			if (udesc) {
 				dsi = udesc->extension_buf; udesc->extension_buf = NULL;
@@ -816,13 +859,16 @@

 	if (qcp_type>1) {
 		if (dumper->flags & GF_EXPORT_USE_QCP) {
-			strcat(szName, ".qcp");
+			if (add_ext)
+				strcat(szName, ".qcp");
 			gf_export_message(dumper, GF_OK, "Extracting %s audio (QCP file)", (qcp_type==2) ? "SMV" : "EVRC");
 		} else if (qcp_type==2) {
-			strcat(szName, ".smv");
+			if (add_ext)
+				strcat(szName, ".smv");
 			gf_export_message(dumper, GF_OK, "Extracting SMV audio");
 		} else {
-			strcat(szName, ".evc");
+			if (add_ext)
+				strcat(szName, ".evc");
 			gf_export_message(dumper, GF_OK, "Extracting EVRC audio");
 		}
 	}
@@ -1081,6 +1127,9 @@
 		}
 		gf_export_message(dumper, GF_OK, "Extracting AVI video (format %s) to %s", comp, szOutFile);

+		if (strrchr(dumper->out_name, '.')) {
+			strcpy(szOutFile, dumper->out_name);
+		}
 		fout = gf_f64_open(szOutFile, "wb");

 		max_size = 0;
@@ -1441,10 +1490,13 @@
 		dumper->flags |= GF_EXPORT_MERGE;
 		return GF_OK;
 	}
-	ext = (char *) gf_isom_get_filename(dumper->file);
-	if (ext) ext = strrchr(ext, '.');
-	sprintf(szName, "%s%s", dumper->out_name, ext ? ext : ".mp4");
-
+	if (strrchr(dumper->out_name, '.')) {
+		strcpy(szName, dumper->out_name);
+	} else {
+		ext = (char *) gf_isom_get_filename(dumper->file);
+		if (ext) ext = strrchr(ext, '.');
+		sprintf(szName, "%s%s", dumper->out_name, ext ? ext : ".mp4");
+	}
 	add_to_iod = 1;
 	mode = GF_ISOM_WRITE_EDIT;
 	if (dumper->flags & GF_EXPORT_MERGE) {
@@ -1513,7 +1565,11 @@
 	}
 	if (dumper->flags & GF_EXPORT_PROBE_ONLY) return GF_OK;

-	sprintf(szName, "%s.avi", dumper->out_name);
+	if (strrchr(dumper->out_name, '.')) {
+		strcpy(szName, dumper->out_name);
+	} else {
+		sprintf(szName, "%s.avi", dumper->out_name);
+	}
 	avi_out = AVI_open_output_file(szName);
 	if (!avi_out) {
 		gf_odf_desc_del((GF_Descriptor *)esd);


meta: Respect the driver's maximum number of draw buffers

Commit c1c1cf5f9 added infrastructure for saving and restoring draw
buffer state.  However, it universially used MAX_DRAW_BUFFERS, but many
drivers support far fewer than that at limit.  For example, the radeon
and i915 drivers only support 1.  Using MAX_DRAW_BUFFERS causes meta to
generate GL errors.

Signed-off-by: Ian Romanick <2b237cafb16dc45038e85df6c85e74e6d899eba9@intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80115
Reviewed-by: Kenneth Graunke <bd2562f754ec92342f93f61c25d731e290a2ffa8@whitecape.org>
Tested-by: Kenneth Graunke <bd2562f754ec92342f93f61c25d731e290a2ffa8@whitecape.org> [on Broadwell]
Tested-by: d1d60675fb89258a173ee87ac9034faa873c5891@verizon.net
Cc: "10.2" <59f39c0db42d4479a46b02d4d2bc11120e37bb44@lists.freedesktop.org>

--- src/mesa/drivers/common/meta.c
+++ src/mesa/drivers/common/meta.c
@@ -801,7 +801,7 @@
       int buf, real_color_buffers = 0;
       memset(save->ColorDrawBuffers, 0, sizeof(save->ColorDrawBuffers));

-      for (buf = 0; buf < MAX_DRAW_BUFFERS; buf++) {
+      for (buf = 0; buf < ctx->Const.MaxDrawBuffers; buf++) {
          int buf_index = ctx->DrawBuffer->_ColorDrawBufferIndexes[buf];
          if (buf_index == -1)
             continue;
@@ -1213,7 +1213,7 @@
       _mesa_BindRenderbuffer(GL_RENDERBUFFER, save->RenderbufferName);

    if (state & MESA_META_DRAW_BUFFERS) {
-      _mesa_DrawBuffers(MAX_DRAW_BUFFERS, save->ColorDrawBuffers);
+      _mesa_DrawBuffers(ctx->Const.MaxDrawBuffers, save->ColorDrawBuffers);
    }

    ctx->Meta->SaveStackDepth--;


Fix warning in Visual Studio:

Fix warning in Visual Studio:

warning C4146: unary minus operator applied to unsigned type, result still unsigned

--- include/yaml-cpp/node/convert.h
+++ include/yaml-cpp/node/convert.h
@@ -58,7 +58,7 @@
 		}
 	};

-#define YAML_DEFINE_CONVERT_STREAMABLE(type)\
+#define YAML_DEFINE_CONVERT_STREAMABLE(type, negative_op)\
 	template<>\
 	struct convert<type> {\
 		static Node encode(const type& rhs) {\
@@ -80,7 +80,7 @@
                     rhs = std::numeric_limits<type>::infinity();\
                     return true;\
                 } else if(conversion::IsNegativeInfinity(input)) {\
-                    rhs = -std::numeric_limits<type>::infinity();\
+                    rhs = negative_op std::numeric_limits<type>::infinity();\
                     return true;\
                 }\
             }\
@@ -94,22 +94,30 @@
 		}\
 	}

-	YAML_DEFINE_CONVERT_STREAMABLE(int);
-	YAML_DEFINE_CONVERT_STREAMABLE(unsigned);
-	YAML_DEFINE_CONVERT_STREAMABLE(short);
-	YAML_DEFINE_CONVERT_STREAMABLE(unsigned short);
-	YAML_DEFINE_CONVERT_STREAMABLE(long);
-	YAML_DEFINE_CONVERT_STREAMABLE(unsigned long);
-	YAML_DEFINE_CONVERT_STREAMABLE(long long);
-	YAML_DEFINE_CONVERT_STREAMABLE(unsigned long long);
-
-	YAML_DEFINE_CONVERT_STREAMABLE(char);
-	YAML_DEFINE_CONVERT_STREAMABLE(unsigned char);
-
-	YAML_DEFINE_CONVERT_STREAMABLE(float);
-	YAML_DEFINE_CONVERT_STREAMABLE(double);
-	YAML_DEFINE_CONVERT_STREAMABLE(long double);
-
+#define YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(type)\
+    YAML_DEFINE_CONVERT_STREAMABLE(type, -)
+
+#define YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(type)\
+    YAML_DEFINE_CONVERT_STREAMABLE(type, +)
+
+    YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(int);
+	YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(short);
+	YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long);
+	YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long long);
+	YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(unsigned);
+	YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned short);
+	YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned long);
+	YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned long long);
+
+	YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(char);
+	YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED(unsigned char);
+
+	YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(float);
+	YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(double);
+	YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(long double);
+
+#undef YAML_DEFINE_CONVERT_STREAMABLE_SIGNED
+#undef YAML_DEFINE_CONVERT_STREAMABLE_UNSIGNED
 #undef YAML_DEFINE_CONVERT_STREAMABLE

 	// bool


first working version

first working version

--- main.c
+++ main.c
@@ -0,0 +1,70 @@
+#include<stdlib.h>
+#include<stdio.h>
+#include<assert.h>
+
+typedef struct node {
+        int val;
+        struct node *next;
+} node;
+
+typedef struct stack {
+        struct node *head;
+} stack;
+
+void enqueue(stack *s1, stack *s2);
+void push(stack *s, int el);
+int pop(stack *s);
+int queue_pop(stack *s1, stack *s2);
+
+int main(){
+
+        int test[] = {1, 2, 3, 4, 5};
+
+        stack *s = malloc(sizeof(stack));
+        s->head = NULL;
+        stack *s2 = malloc(sizeof(stack));
+        s2->head = NULL;
+
+        push(s, 1);
+        push(s, 2);
+        push(s, 3);
+        push(s, 4);
+
+
+        printf("%d\n\r", queue_pop(s, s2));
+        printf("%d\n\r", queue_pop(s, s2));
+        printf("%d\n\r", queue_pop(s, s2));
+        printf("%d\n\r", queue_pop(s, s2));
+
+        return 0;
+}
+
+void enqueue(stack *s1, stack *s2){
+        while(s1->head != NULL){
+            push(s2, pop(s1));
+        }
+}
+
+int queue_pop(stack *s1, stack *s2){
+   if(s2->head == NULL){
+           enqueue(s1, s2);
+   }
+
+   return pop(s2);
+}
+
+int pop(stack *s){
+        assert(s->head != NULL);
+        int val = s->head->val;
+        node *n = s->head;
+        s->head = s->head->next;
+        free(n);
+        return val;
+}
+
+void push(stack *s, int el){
+    node *n = malloc(sizeof(node));
+    n->val = el;
+    n->next = s->head;
+    s->head = n;
+}


3K: core: fix single-file compilation

3K: core: fix single-file compilation

git-svn-id: 77a43f9646713b91fea7788fad5dfbf67e151ece@8184 94b884b6-d6fd-0310-90d3-974f1d3f35e1

--- numpy/core/src/multiarray/common.c
+++ numpy/core/src/multiarray/common.c
@@ -11,6 +11,7 @@
 #include "usertypes.h"

 #include "common.h"
+#include "buffer.h"

 /*
  * new reference


Problem computing specular value in OPCODE_LIT - pulled in value from vertex program execution of LIT

--- src/mesa/swrast/s_nvfragprog.c
+++ src/mesa/swrast/s_nvfragprog.c
@@ -790,7 +790,7 @@
                   a[1] = 0.0F;
                result[0] = 1.0F;
                result[1] = a[0];
-               result[2] = (a[0] > 0.0F) ? (GLfloat)_mesa_pow(2.0, a[3]) : 0.0F;
+               result[2] = (a[0] > 0.0F) ? (GLfloat) exp(a[3] * log(a[1])) : 0.0F;
                result[3] = 1.0F;
                store_vector4( inst, machine, result );
             }


disable ffmpeg by default

disable ffmpeg by default

--- config_default.h
+++ config_default.h
@@ -60,7 +60,7 @@
 #define HAVE_INTTYPES_H 1

 /* Define to 1 if you want 'libffmpeg' support. */
-#define HAVE_LIBFFMPEG 1
+/* #undef HAVE_LIBFFMPEG */

 /* Define if you have a readline compatible library */
 #define HAVE_LIBREADLINE 1


[IA64-SGI] Altix SN topology fix potential infinite loop

Fix infinite loop if sn_hwperf_location_to_bpos() fails.

Signed-off-by: Mark Goodwin <e4fc943ceaa9ffc07753572262f09eacd9faf7c5@sgi.com>
Signed-off-by: Tony Luck <e7984595ec0368ff920a7b3521dc7093683f6f26@intel.com>

--- arch/ia64/sn/kernel/sn2/sn_hwperf.c
+++ arch/ia64/sn/kernel/sn2/sn_hwperf.c
@@ -300,14 +300,15 @@
 		 * PCI busses attached to this node, if any
 		 */
 		do {
+			if (sn_hwperf_location_to_bpos(obj->location,
+				&rack, &bay, &slot, &slab)) {
+				break;
+			}
+
 			if (!(pci_topo_buf = vmalloc(pci_topo_buf_len))) {
-				printk("sn_topology_show: kmalloc failed\n");
+				printk("sn_topology_show: vmalloc failed\n");
 				break;
 			}
-
-			if (sn_hwperf_location_to_bpos(obj->location,
-				&rack, &bay, &slot, &slab) != 0)
-				continue;

 			e = ia64_sn_ioif_get_pci_topology(rack, bay, slot, slab,
 			    	pci_topo_buf, pci_topo_buf_len);
@@ -325,6 +326,7 @@
 				break;

 			case SN_HWPERF_OP_OK:
+			default:
 				/* export pci bus info */
 				print_pci_topology(s, obj, &pci_bus_ordinal,
 					pci_topo_buf, pci_topo_buf_len);


* change to ANSI C style.

* change to ANSI C style.

--- gtk2/ext/gtk2/rbgtkcellrendererspin.c
+++ gtk2/ext/gtk2/rbgtkcellrendererspin.c
@@ -16,8 +16,7 @@
 #define _SELF(s) (GTK_CELL_RENDERER_SPIN(RVAL2GOBJ(s)))

 static VALUE
-crspin_initialize(self)
-    VALUE self;
+crspin_initialize(VALUE self)
 {
     RBGTK_INITIALIZE(self, gtk_cell_renderer_spin_new());
     return Qnil;


Spelling fix in alpscomm.c.

Spelling fix in alpscomm.c.

--- alpscomm.c
+++ alpscomm.c
@@ -36,7 +36,7 @@
 }

 /*
- * send the ALPSinit sequence, ie 4 consecutive "disable"s before the "enable"
+ * send the ALPS init sequence, ie 4 consecutive "disable"s before the "enable"
  */
 static void
 ALPS_initialize(int fd)


[sound]add sound_set_gain_pan function

[sound]add sound_set_gain_pan function

--- src/include/sound/sound.h
+++ src/include/sound/sound.h
@@ -77,6 +77,13 @@
 	snd->rvol = clamp(vol, 0, 4096);
 }

+static inline void sound_set_gain_pan(struct sound_t * snd, float gain, float pan)
+{
+	pan = clamp(pan, -1.0f, 1.0f);
+	snd->lvol = gain * (pan <= 0.0f ? 1.0f : 1.0f - pan) * 4096;
+	snd->rvol = gain * (pan >= 0.0f ? 1.0f : 1.0f + pan) * 4096;
+}
+
 static inline void sound_set_loop(struct sound_t * snd, int loop)
 {
 	snd->loop = loop;


Give a message explaining that the computer is actually shut down, as opposed to deadlocked.

--- src/metodo/i386/hal/shutdown.c
+++ src/metodo/i386/hal/shutdown.c
@@ -16,6 +16,8 @@

 noreturn HalShutdown(void)
 {
+	DisplayClear();
+	printf("It's now safe to turn off your computer. (Can has ACPI?)");
 	while (1) {
 		HalDisableInterrupts();
 		HalHalt();


Update email and show actual program name on help

--- amiitool.c
+++ amiitool.c
@@ -14,22 +14,27 @@

 #define NTAG215_SIZE 540

+static char * self;
+
 void usage() {
 	fprintf(stderr,
 		"amiitool\n"
-		"by Marcos Vives Del Sol <socram@protonmail.ch>\n"
+		"by Marcos Del Sol Vives <marcos@dracon.es>\n"
 		"\n"
-		"Usage: amiitool (-e|-d) -k keyfile [-i input] [-o output]\n"
+		"Usage: %s (-e|-d) -k keyfile [-i input] [-o output]\n"
 		"   -e encrypt and sign amiibo\n"
 		"   -d decrypt and test amiibo\n"
 		"   -k key set file. For retail amiibo, use \"retail unfixed\" key set\n"
 		"   -i input file. If not specified, stdin will be used.\n"
 		"   -o output file. If not specified, stdout will be used.\n"
-		"   -l decrypt files with invalid signatures.\n"
+		"   -l decrypt files with invalid signatures.\n",
+		self
 	);
 }

 int main(int argc, char ** argv) {
+	self = argv[0];
+
 	char * infile = NULL;
 	char * outfile = NULL;
 	char * keyfile = NULL;


fix missing export

fix missing export

git-svn-id: ab66a9de07fa9d47c5829c82992f5279466c775f@4728 63c20433-aa62-49bd-875c-5a186b69a8fb

--- src/isomedia/isom_write.c
+++ src/isomedia/isom_write.c
@@ -1141,6 +1141,7 @@
 	return Track_SetStreamDescriptor(trak, StreamDescriptionIndex, entry->dataReferenceIndex, esd, NULL);
 }

+GF_EXPORT
 GF_Err gf_isom_set_visual_info(GF_ISOFile *movie, u32 trackNumber, u32 StreamDescriptionIndex, u32 Width, u32 Height)
 {
 	GF_Err e;


Use the new GnomeProgram API.

Use the new GnomeProgram API.

--- libgnome/gnome-moz-remote2.c
+++ libgnome/gnome-moz-remote2.c
@@ -75,8 +75,8 @@
 #include <string.h>

 #include "gnomesupport.h"
-#include <libgnome/libgnome.h>
-#include <libgnome/gnomelib-init2.h>
+#include "libgnome.h"
+#include "gnome-program.h"
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>

@@ -296,13 +296,13 @@
   poptContext ctx;
   int i;
   Display *dpy;
+  GnomeProgram *program;

   dpy_name = g_getenv("DISPLAY");

-  gnome_program_init("gnome_moz_remote", VERSION, argc, argv, GNOME_PARAM_POPT_TABLE, options, LIBGNOME_INIT, NULL);
-
-  gnome_program_attributes_get(gnome_program_get(), GNOME_PARAM_POPT_CONTEXT, &ctx, NULL);
-
+  program = gnome_program_get();
+  g_object_set(G_OBJECT(program), "popt_table", options, LIBGNOME_INIT, NULL);
+  ctx = gnome_program_preinit(program, "gnome_moz_remote", VERSION, argc, argv);
   args = poptGetArgs(ctx);

   dpy = XOpenDisplay(dpy_name);


perf: Roll back callchain buffer refcount under the callchain mutex

When we fail to allocate the callchain buffers, we roll back the refcount
we did and return from get_callchain_buffers().

However we take the refcount and allocate under the callchain lock
but the rollback is done outside the lock.

As a result, while we roll back, some concurrent callchain user may
call get_callchain_buffers(), see the non-zero refcount and give up
because the buffers are NULL without itself retrying the allocation.

The consequences aren't that bad but that behaviour looks weird enough and
it's better to give their chances to the following callchain users where
we failed.

Reported-by: Jiri Olsa <2c6594f608aa3d41e98d48846a6328831f7084ad@redhat.com>
Signed-off-by: Frederic Weisbecker <e8a1bf9163cb25e93cfd6540f223b3872ea7ee55@gmail.com>
Acked-by: Jiri Olsa <2c6594f608aa3d41e98d48846a6328831f7084ad@redhat.com>
Cc: Namhyung Kim <5c915a589b3ddf58cebf14bec41bcc143b37ac3c@kernel.org>
Cc: Arnaldo Carvalho de Melo <293abb6b76d7791c0732cc517d38c4b5c734b87f@redhat.com>
Cc: Stephane Eranian <f199ae9781930a5b94b284ca2f471140752002a7@google.com>
Signed-off-by: Peter Zijlstra <3fddac958924aef220f202ca567388ddab3f14a8@infradead.org>
Link: http://lkml.kernel.org/r/1375460996-16329-2-git-send-email-e8a1bf9163cb25e93cfd6540f223b3872ea7ee55@gmail.com
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@kernel.org>

--- kernel/events/callchain.c
+++ kernel/events/callchain.c
@@ -116,9 +116,10 @@

 	err = alloc_callchain_buffers();
 exit:
-	mutex_unlock(&callchain_mutex);
 	if (err)
 		atomic_dec(&nr_callchain_events);
+
+	mutex_unlock(&callchain_mutex);

 	return err;
 }


dev->config might be NULL (like on MacOS X)

git-svn-id: 40dd595c6684d839db675001a64203a1457e7319@12693 67ed7778-7388-44ab-90cf-0a291f65f57c

--- libgphoto2_port/usb/libusb.c
+++ libgphoto2_port/usb/libusb.c
@@ -843,28 +843,30 @@
 	 * MTP interface descriptions, that's how they can be detected, before
 	 * we try the more esoteric "OS descriptors" (below).
 	 */
-	for (i = 0; i < dev->descriptor.bNumConfigurations; i++) {
-		unsigned int j;
-		for (j = 0; j < dev->config[i].bNumInterfaces; j++) {
-			int k;
-			for (k = 0; k < dev->config[i].interface[j].num_altsetting; k++) {
-				buf[0] = '\0';
-				ret = usb_get_string_simple(devh,
-					dev->config[i].interface[j].altsetting[k].iInterface,
-					(char *) buf,
-					1024);
-				if (ret < 3)
-					continue;
-				if (strcmp((char *) buf, "MTP") == 0) {
-					gp_log (GP_LOG_DEBUG, "mtp matcher", "Configuration %d, interface %d, altsetting %d:\n", i, j, k);
-					gp_log (GP_LOG_DEBUG, "mtp matcher", "   Interface description contains the string \"MTP\"\n");
-					gp_log (GP_LOG_DEBUG, "mtp matcher", "   Device recognized as MTP, no further probing.\n");
-					goto found;
+	if (dev->config) {
+		for (i = 0; i < dev->descriptor.bNumConfigurations; i++) {
+			unsigned int j;
+
+			for (j = 0; j < dev->config[i].bNumInterfaces; j++) {
+				int k;
+				for (k = 0; k < dev->config[i].interface[j].num_altsetting; k++) {
+					buf[0] = '\0';
+					ret = usb_get_string_simple(devh,
+						dev->config[i].interface[j].altsetting[k].iInterface,
+						(char *) buf,
+						1024);
+					if (ret < 3)
+						continue;
+					if (strcmp((char *) buf, "MTP") == 0) {
+						gp_log (GP_LOG_DEBUG, "mtp matcher", "Configuration %d, interface %d, altsetting %d:\n", i, j, k);
+						gp_log (GP_LOG_DEBUG, "mtp matcher", "   Interface description contains the string \"MTP\"\n");
+						gp_log (GP_LOG_DEBUG, "mtp matcher", "   Device recognized as MTP, no further probing.\n");
+						goto found;
+					}
 				}
 			}
 		}
 	}
-
 	/* get string descriptor at 0xEE */
 	ret = usb_get_descriptor (devh, 0x03, 0xee, buf, sizeof(buf));
 	if (ret > 0) gp_log_data("get_MS_OSD",buf, ret);


error: catch `error` itself in `safe_eval()`

--- kernel/include/bs/error.h
+++ kernel/include/bs/error.h
@@ -227,6 +227,7 @@
 		try {
 			return eval(std::forward<F>(f), std::forward<Fs>(fs)...);
 		}
+		catch(error& e) { return std::move(e); }
 		catch(const std::system_error& e) { return error{q, e}; }
 		catch(const std::exception& e) { return error{q, e.what()}; }
 		catch(...) { return error{q, Error::Happened}; }


Improve error reporting.

Improve error reporting.

git-svn-id: 40dd595c6684d839db675001a64203a1457e7319@3018 67ed7778-7388-44ab-90cf-0a291f65f57c

--- libgphoto2_port/usb/libusb.c
+++ libgphoto2_port/usb/libusb.c
@@ -327,12 +327,8 @@
 	 * Should the USB layer report that ? I don't know.
 	 * Better to check here.
 	 */
-	if ((idvendor == 0) || (idproduct == 0)) {
-		gp_port_set_error (port, "NOT looking for illegal USB device "
-				   "(vendor 0x%x, product 0x%x)...",
-				   idvendor, idproduct);
-		return GP_ERROR_BAD_PARAMETERS;
-	}
+	if (!idvendor || !idproduct)
+		return GP_ERROR_BAD_PARAMETERS;

 	for (bus = usb_busses; bus; bus = bus->next) {
 		for (dev = bus->devices; dev; dev = dev->next) {
@@ -348,9 +344,9 @@
 		}
 	}

-	gp_port_set_error (port, "Looking for USB device "
-			   "(vendor 0x%x, product 0x%x)... not found.",
-			   idvendor, idproduct);
+	gp_port_set_error (port, _("Could not find USB device "
+		"(vendor 0x%x, product 0x%x). Make sure this device "
+		"is connected to the computer."), idvendor, idproduct);
 	return GP_ERROR_IO_USB_FIND;
 }


[jamendo] Use g_slices when possible

[jamendo] Use g_slices when possible

Memory slices are more efficient than mallocs.

--- src/jamendo/grl-jamendo.c
+++ src/jamendo/grl-jamendo.c
@@ -261,7 +261,7 @@
   g_free (entry->track_url);
   g_free (entry->track_stream);
   g_free (entry->track_duration);
-  g_free (entry);
+  g_slice_free (Entry, entry);
 }

 static gint
@@ -330,7 +330,7 @@
 {
   xmlNodePtr node;
   xmlNs *ns;
-  Entry *data = g_new0 (Entry, 1);
+  Entry *data = g_slice_new0 (Entry);

   if (strcmp ((gchar *) entry->name, JAMENDO_ARTIST) == 0) {
     data->category = JAMENDO_ARTIST_CAT;
@@ -566,7 +566,7 @@

   if (!parse_more) {
     xmlFreeDoc (xpe->doc);
-    g_free (xpe);
+    g_slice_free (XmlParseEntries, xpe);
   }

   return parse_more;
@@ -587,7 +587,7 @@
   /* Check if operation was cancelled */
   if (xpe->cancelled) {
     g_object_unref (source_object);
-    g_free (xpe);
+    g_slice_free (XmlParseEntries, xpe);
     return;
   }

@@ -685,7 +685,7 @@
     break;
   }

-  g_free (xpe);
+  g_slice_free (XmlParseEntries, xpe);
   if (error) {
     g_error_free (error);
   }
@@ -716,7 +716,7 @@
 {
   Entry *entry;

-  entry = g_new0 (Entry, 1);
+  entry = g_slice_new0 (Entry);
   entry->category = JAMENDO_ARTIST_CAT;
   entry->artist_name = g_strdup (JAMENDO_ARTIST "s");
   update_media_from_entry (media, entry);
@@ -728,7 +728,7 @@
 {
   Entry *entry;

-  entry = g_new0 (Entry, 1);
+  entry = g_slice_new0 (Entry);
   entry->category = JAMENDO_ALBUM_CAT;
   entry->album_name = g_strdup (JAMENDO_ALBUM "s");
   update_media_from_entry (media, entry);
@@ -912,7 +912,7 @@
   }

   if (url) {
-    xpe = g_new0 (XmlParseEntries, 1);
+    xpe = g_slice_new0 (XmlParseEntries);
     xpe->type = METADATA;
     xpe->spec.ms = ms;
     read_url_async (url, xpe);
@@ -1021,7 +1021,7 @@
     return;
   }

-  xpe = g_new0 (XmlParseEntries, 1);
+  xpe = g_slice_new0 (XmlParseEntries);
   xpe->type = BROWSE;
   xpe->spec.bs = bs;

@@ -1086,7 +1086,7 @@
                          term);
   g_free (term);

-  xpe = g_new0 (XmlParseEntries, 1);
+  xpe = g_slice_new0 (XmlParseEntries);
   xpe->type = QUERY;
   xpe->spec.qs = qs;

@@ -1121,7 +1121,7 @@
                          ss->skip + 1,
                          ss->text);

-  xpe = g_new0 (XmlParseEntries, 1);
+  xpe = g_slice_new0 (XmlParseEntries);
   xpe->type = SEARCH;
   xpe->spec.ss = ss;


-- Fix bs_array.operator= compile

-- Fix bs_array.operator= compile

--- kernel/include/bs_array.h
+++ kernel/include/bs_array.h
@@ -0,0 +1,224 @@
+// This file is part of BlueSky
+//
+// BlueSky is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public License
+// as published by the Free Software Foundation; either version 3
+// of the License, or (at your option) any later version.
+//
+// BlueSky is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with BlueSky; if not, see <http://www.gnu.org/licenses/>.
+
+#ifndef _BS_ARRAY_H_
+#define _BS_ARRAY_H_
+
+#include "bs_arrbase.h"
+#include "bs_array_shared.h"
+#include "shared_vector.h"
+#include <vector>
+
+namespace blue_sky {
+
+namespace bs_private {
+
+template< class T, class array_t >
+struct BS_API arrbase_traits_impl : public bs_arrbase< T >, public array_t {
+	typedef array_t container;
+	typedef bs_arrbase< T > arrbase;
+	typedef arrbase_traits_impl< T, array_t > bs_array_base;
+
+	// default ctor
+	arrbase_traits_impl() {}
+
+	// ctor for constructing from container copy
+	arrbase_traits_impl(const container& c) : array_t(c) {}
+};
+
+template< class T, class vector_t >
+struct BS_API vecbase_traits_impl : public bs_vecbase< T >, public vector_t {
+	typedef vector_t container;
+	typedef bs_vecbase< T > arrbase;
+	typedef vecbase_traits_impl< T, vector_t > bs_array_base;
+
+	// inherited from bs_arrbase class
+	typedef typename arrbase::value_type value_type;
+	typedef typename arrbase::key_type key_type;
+
+	// default ctor
+	vecbase_traits_impl() {}
+
+	// ctor from vector copy
+	vecbase_traits_impl(const container& c) : vector_t(c) {}
+
+	using container::size;
+
+	bool insert(const key_type& key, const value_type& value) {
+		if(key > size()) return false;
+		container::insert(container::begin() + key, value);
+		return true;
+	}
+
+	bool insert(const value_type& value) {
+		container::push_back(value);
+		return true;
+	}
+
+	void erase(const key_type& key)	{
+		container::erase(container::begin() + key);
+	}
+};
+
+}
+
+/// @brief traits for arrays with std::vector container
+template< class T >
+struct BS_API vector_traits : public bs_private::vecbase_traits_impl< T, std::vector< T > > {};
+
+/// @brief traits for arrays with shared_array container
+template< class T >
+struct BS_API shared_array_traits : public bs_private::arrbase_traits_impl< T, bs_array_shared< std::vector< T > > > {};
+
+/// @brief traits for arrays with shared_vector container
+template< class T >
+struct BS_API shared_vector_traits : public bs_private::vecbase_traits_impl< T, bs_vector_shared< std::vector< T > > > {};
+
+/*-----------------------------------------------------------------------------
+ *  bs_array class
+ *-----------------------------------------------------------------------------*/
+/// @brief Contains array of key-value pairs with integral key (index)
+///
+/// bs_array expects std::vector-like syntax of container in traits
+/// template params:
+///           T -- type of array elements
+/// cont_traits -- specifies underlying container
+template< class T, template< class > class cont_traits = shared_array_traits >
+class BS_API bs_array : public objbase, public cont_traits< T >::bs_array_base
+{
+public:
+	typedef cont_traits< T > cont_traits_t;
+	typedef typename cont_traits_t::arrbase arrbase_t;
+	typedef typename arrbase_t::sp_arrbase sp_arrbase;
+	typedef typename cont_traits_t::container container;
+	typedef typename cont_traits_t::bs_array_base base_t;
+	typedef bs_array< T, cont_traits > this_t;
+	typedef smart_ptr< this_t, true > sp_array;
+
+	// inherited from bs_arrbase class
+	typedef typename arrbase_t::value_type value_type;
+	typedef typename arrbase_t::reference reference;
+	typedef typename arrbase_t::const_reference const_reference;
+	typedef typename arrbase_t::size_type size_type;
+	typedef typename arrbase_t::key_type key_type;
+
+	// inherited from cont_traits
+	//typedef typename cont_traits_t::iterator iterator;
+	//typedef typename cont_traits_t::const_iterator const_iterator;
+	//typedef typename cont_traits_t::reverse_iterator reverse_iterator;
+	//typedef typename cont_traits_t::const_reverse_iterator const_reverse_iterator;
+
+	// copy construct from container
+	bs_array(const container& c)
+		: base_t(c)
+	{}
+
+	// ctor via init
+	void init(const container& c) {
+		this_t(c).swap(*this);
+	}
+
+	// init methods are indirect constructors
+	void init(size_type sz, const value_type& v = value_type()) {
+		this_t(container(sz, v)).swap(*this);
+	}
+
+	/// @brief Obtain array size
+	/// Overloads bs_arrbase method
+	/// @return number of elements contained in array
+	size_type size() const {
+		return static_cast< size_type >(container::size());
+	}
+
+	/// @brief Items access operator (r/w)
+	/// Overloads bs_arrbase method
+	/// @param key --- item key
+	///
+	/// @return modifyable reference to element
+	reference operator[](const key_type& key) {
+		return container::operator[](key);
+	}
+
+	/// @brief Items access operator (r)
+	/// Overloads bs_arrbase method
+	/// @param key -- item key
+	///
+	/// @return const refernce to element
+	const_reference operator[](const key_type& key) const {
+		return container::operator[](key);
+	}
+
+	void resize(size_type new_size) {
+		container::resize(new_size);
+	}
+
+	//void clear() {
+	//	container::clear();
+	//}
+
+	// make array with copied data
+	sp_arrbase clone() const {
+		sp_array clon_ = BS_KERNEL.create_object(bs_resolve_type());
+		clon_->resize(size());
+		std::copy(this->begin(), this->end(), clon_->begin());
+		return clon_;
+	}
+
+	void swap(bs_array& arr) {
+		objbase::swap(arr);
+		base_t::swap(arr);
+	}
+
+	template< class R, template< class > class r_traits >
+	bs_array& operator=(const bs_array< R, r_traits >& rhs) {
+		size_type n = rhs.size();
+		if(n && &(*this)[0] != &rhs[0]) {
+			if(size() != n) resize(n);
+			std::copy(rhs.begin(), rhs.end(), this->begin());
+		}
+		return *this;
+	}
+
+	template< class R >
+	bs_array& operator=(const bs_arrbase< R >& rhs) {
+		arrbase_t::assign(rhs);
+		return *this;
+	}
+
+protected:
+	//creation and copy functions definitions
+	BLUE_SKY_TYPE_STD_CREATE_T_MEM(bs_array);
+	BLUE_SKY_TYPE_STD_COPY_T_MEM(bs_array);
+
+	BLUE_SKY_TYPE_DECL_T_MEM(bs_array, objbase, "bs_array",
+		"Array of values of the same type indexed by integral type", "");
+};
+
+// default bs_array ctor implementation
+template< class T, template< class > class cont_traits >
+bs_array< T, cont_traits >::bs_array(bs_type_ctor_param param)
+: bs_refcounter() //, base_t(param)
+{}
+
+// default bs_array copy ctor implementation
+template< class T, template< class > class cont_traits >
+bs_array< T, cont_traits >::bs_array(const bs_array< T, cont_traits >& src)
+: bs_refcounter(), objbase(src), base_t(src)
+{}
+
+}	// end of blue_sky namespace
+
+#endif
+


Necessary header file that I forgot

Necessary header file that I forgot

error: pathspec 'libhmsbeagle/CPU/Precision.h' did not match any file(s) known to git

--- libhmsbeagle/CPU/Precision.h
+++ libhmsbeagle/CPU/Precision.h
@@ -0,0 +1,20 @@
+/*
+ * Precision.h
+ *
+ *  Created on: Oct 13, 2009
+ *      Author: msuchard
+ */
+
+#ifndef PRECISION_H_
+#define PRECISION_H_
+
+#define DOUBLE_PRECISION (sizeof(REALTYPE) == 8)
+
+#define MEMCNV(to, from, length, toType)    { \
+                                                int m; \
+                                                for(m = 0; m < length; m++) { \
+                                                    to[m] = (toType) from[m]; \
+                                                } \
+                                            }
+
+#endif /* PRECISION_H_ */


clockevent: export register_device and delta2ns

Export the following symbols using EXPORT_SYMBOL_GPL:
 - clockevent_delta2ns
 - clockevents_register_device

This allows us to build SuperH clockevent and clocksource
drivers as modules, see drivers/clocksource/sh_*.c

[ Impact: allow modular build of clockevent drivers ]

Signed-off-by: Magnus Damm <2336f5729424d0c84d319e991b3648cafa2c3c5b@igel.co.jp>
LKML-Reference: <3cf1b880fdb2fb7dc704b867e6163c85c6b23b7d@rx1.opensource.se>
Signed-off-by: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>

--- kernel/time/clockevents.c
+++ kernel/time/clockevents.c
@@ -54,6 +54,7 @@

 	return (unsigned long) clc;
 }
+EXPORT_SYMBOL_GPL(clockevent_delta2ns);

 /**
  * clockevents_set_mode - set the operating mode of a clock event device
@@ -187,6 +188,7 @@

 	spin_unlock(&clockevents_lock);
 }
+EXPORT_SYMBOL_GPL(clockevents_register_device);

 /*
  * Noop handler when we shut down an event device


x86: make clockevents more robust

x86: make clockevents more robust

detect zero event-device multiplicators - they then cause
division-by-zero crashes if a clockevent has been initialized
incorrectly.

Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@elte.hu>
Signed-off-by: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>

--- kernel/time/clockevents.c
+++ kernel/time/clockevents.c
@@ -41,6 +41,11 @@
 {
 	u64 clc = ((u64) latch << evt->shift);

+	if (unlikely(!evt->mult)) {
+		evt->mult = 1;
+		WARN_ON(1);
+	}
+
 	do_div(clc, evt->mult);
 	if (clc < 1000)
 		clc = 1000;
@@ -151,6 +156,14 @@
 void clockevents_register_device(struct clock_event_device *dev)
 {
 	BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED);
+	/*
+	 * A nsec2cyc multiplicator of 0 is invalid and we'd crash
+	 * on it, so fix it up and emit a warning:
+	 */
+	if (unlikely(!dev->mult)) {
+		dev->mult = 1;
+		WARN_ON(1);
+	}

 	spin_lock(&clockevents_lock);