fix top/bottom flags in vdp->va ref frames conversion

--- vdpau-soft.c
+++ vdpau-soft.c
@@ -339,8 +339,15 @@
             va_ref->frame_idx = vdp_ref->frame_idx;
             va_ref->flags = vdp_ref->is_long_term ? VA_PICTURE_H264_LONG_TERM_REFERENCE
                                                   : VA_PICTURE_H264_SHORT_TERM_REFERENCE;
-            if (vdp_ref->top_is_reference)    va_ref->flags |= VA_PICTURE_H264_TOP_FIELD;
-            if (vdp_ref->bottom_is_reference) va_ref->flags |= VA_PICTURE_H264_BOTTOM_FIELD;
+
+            if (vdp_ref->top_is_reference && vdp_ref->bottom_is_reference) {
+                // Full frame. This block intentionally left blank. No flags set.
+            } else {
+                if (vdp_ref->top_is_reference)
+                    va_ref->flags |= VA_PICTURE_H264_TOP_FIELD;
+                else
+                    va_ref->flags |= VA_PICTURE_H264_BOTTOM_FIELD;
+            }

             va_ref->TopFieldOrderCnt    = vdp_ref->field_order_cnt[0];
             va_ref->BottomFieldOrderCnt = vdp_ref->field_order_cnt[1];


Update for v0.72, no 2

Update for v0.72, no 2

New in v0.72:

- Forbidden was broken (misunderstanding on my part), now fixed.
- Changed some parameter names.
- Added possibility to filter solutions with too *few* activated cells. Use to only get new results when increasing max-activated-cells after a prevoius search.
- More information about found solution in console and in result files (generation of each activation and max activated cells in solution).

--- bellman.c
+++ bellman.c
@@ -789,6 +789,7 @@
 				fprintf (f, "#C Solution accepted at generation %d\n", accept_gen);
 				fprintf (f, "#C Activations at generation ");
 				print_activation_gens (f, act_count, act_gen);
+				fprintf (f, "#C Max activated cells ", max_activated);
 				fprintf (f, "#C Glider count at accept %d\n", glider_count);

                 for(t = u_static->first->all_first; t; t = t->all_next) {


Revert r155874.

Revert r155874.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@155878 91177308-0d34-0410-b5e6-96231b3b80d8

--- test/Driver/clang-g-opts.c
+++ test/Driver/clang-g-opts.c
@@ -1,14 +1,5 @@
-// RUN: %clang -S -v -o %t %s        2>&1 | FileCheck %s
-// CHECK-NOT: -g
-
-// RUN: %clang -S -v -o %t %s -g     2>&1 | FileCheck %s
-// CHECK: -g
-
-// RUN: %clang -S -v -o %t %s -g0    2>&1 | FileCheck %s
-// CHECK-NOT: -g
-
-// RUN: %clang -S -v -o %t %s -g -g0 2>&1 | FileCheck %s
-// CHECK-NOT: -g
-
-// RUN: %clang -S -v -o %t %s -g0 -g 2>&1 | FileCheck %s
-// CHECK: -g
+// RUN: %clang -S -v -o %t %s        2>&1 | not grep -w -- -g
+// RUN: %clang -S -v -o %t %s -g     2>&1 | grep -w -- -g
+// RUN: %clang -S -v -o %t %s -g0    2>&1 | not grep -w -- -g
+// RUN: %clang -S -v -o %t %s -g -g0 2>&1 | not grep -w -- -g
+// RUN: %clang -S -v -o %t %s -g0 -g 2>&1 | grep -w -- -g


create gl texture for video surface both in case of VA presence and absence

--- vdpau-soft.c
+++ vdpau-soft.c
@@ -1517,29 +1517,29 @@
     data->va_glx = NULL;
     data->tex_id = 0;

+    locked_glXMakeCurrent(deviceData->display, deviceData->root, deviceData->glc);
+    glGenTextures(1, &data->tex_id);
+    glBindTexture(GL_TEXTURE_2D, data->tex_id);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, data->width, data->height, 0,
+                 GL_BGRA, GL_UNSIGNED_BYTE, NULL);
+
+    GLenum gl_error = glGetError();
+    if (GL_NO_ERROR != gl_error) {
+        traceError("error (VdpVideoSurfaceCreate): gl error %d\n", gl_error);
+        free(data);
+        return VDP_STATUS_ERROR;
+    }
+
     if (deviceData->va_available) {
         // no VA surface creation here. Actual pool of VA surfaces should be allocated already
         // by VdpDecoderCreate. VdpDecoderCreate will update ->va_surf field as needed.
         data->y_plane = NULL;
         data->v_plane = NULL;
         data->u_plane = NULL;
-
-        locked_glXMakeCurrent(deviceData->display, deviceData->root, deviceData->glc);
-        glGenTextures(1, &data->tex_id);
-        glBindTexture(GL_TEXTURE_2D, data->tex_id);
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, data->width, data->height, 0,
-                     GL_BGRA, GL_UNSIGNED_BYTE, NULL);
-
-        GLenum gl_error = glGetError();
-        if (GL_NO_ERROR != gl_error) {
-            traceError("error (VdpVideoSurfaceCreate): gl error %d\n", gl_error);
-            free(data);
-            return VDP_STATUS_ERROR;
-        }
     } else {
         //TODO: find valid storage size for chroma_type
         data->y_plane = malloc(stride * height);


DynamicLighting - 1. RenderDirectionaLight에 lightDir을 normalize 2. BRDFLighting에서 Fr의 맨 마지막 (4.0f * NdotL * NdotV)를 지움   - Unreal4의 StandardShading이 이렇게 하고 있기래 해봄     - 결과물이 더 자연스러워졌다.

--- SOCEngine/SOCEngine/ShaderCodes/DynamicLighting.h
+++ SOCEngine/SOCEngine/ShaderCodes/DynamicLighting.h
@@ -41,7 +41,7 @@
 	resultDiffuseColor = diffuseTerm * commonParamas.lightColor * diffuseEnergyConservation;
 	resultDiffuseColor = saturate(resultDiffuseColor);

-	float3 Fr = ( Fresnel(fresnel0, VdotH) * Geometry(roughness, NdotH, NdotV, NdotL, VdotH) * Distribution(roughness, NdotH) ) / (4.0f * NdotL * NdotV);
+	float3 Fr = ( Fresnel(fresnel0, VdotH) * Geometry(roughness, NdotH, NdotV, NdotL, VdotH) * Distribution(roughness, NdotH) );// / (4.0f * NdotL * NdotV);
 	resultSpecularColor	= Fr * commonParamas.lightColor;
 	resultSpecularColor	= saturate(resultSpecularColor);
 }
@@ -70,7 +70,7 @@
 		commonParams.lightColor		= DirectionalLightColorBuffer[lightIndex].xyz;

 		float3	lightDir			= GetDirectionalLightDir(lightIndex);;
-		commonParams.lightDir		= -lightDir;
+		commonParams.lightDir		= -normalize(lightDir);

 		float intensity = DirectionalLightColorBuffer[lightIndex].a * 10.0f;
 #if defined(RENDER_TRANSPARENCY)


fix redis port

fix redis port

--- test/stress.c
+++ test/stress.c
@@ -60,7 +60,7 @@
     }

     if(!redis_port) {
-        redis_port = "6397";
+        redis_port = "6379";
     }

     redisContext* redis = redisConnect(redis_host, atoi(redis_port));


More guard fixes for #766

More guard fixes for #766

--- src/shogun/regression/gp/LaplacianInferenceMethod.h
+++ src/shogun/regression/gp/LaplacianInferenceMethod.h
@@ -15,7 +15,7 @@
 #define CLAPLACIANINFERENCEMETHOD_H_

 #include <shogun/lib/config.h>
-
+#ifdef HAVE_EIGEN3
 #ifdef HAVE_LAPACK

 #include <shogun/regression/gp/InferenceMethod.h>
@@ -284,6 +284,7 @@
 };

 }
+#endif // HAVE_EIGEN3
 #endif // HAVE_LAPACK

 #endif /* CLAPLACIANINFERENCEMETHOD_H_ */


OutputStream.h

OutputStream.h

error: pathspec 'euryale/src/org/cracs/euryale/common/io/OutputStream.h' did not match any file(s) known to git

--- euryale/src/org/cracs/euryale/common/io/OutputStream.h
+++ euryale/src/org/cracs/euryale/common/io/OutputStream.h
@@ -0,0 +1,304 @@
+/*
+ *  Copyright 2012 Rolando Martins, CRACS & INESC-TEC, DCC/FCUP
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+#ifndef OUTPUTSTREAM_H_
+#define OUTPUTSTREAM_H_
+
+#include <euryale/common/Object.h>
+#include <euryale/Types.h>
+
+//#include <euryale/serialization/Serializable.h
+class Serializable;
+#include <list>
+using std::list;
+
+class OutputStream : public Object {
+public:
+
+    OutputStream() {
+    }
+
+    virtual ~OutputStream() {
+    }
+
+    virtual const String& toString() {
+        if (m_toString == 0) {
+            char* buffer;
+            ACE_NEW_NORETURN(buffer, char[30]);
+            ACE_OS::sprintf(buffer, "OutputStream(%p)", this);
+            m_toString = new String(buffer);
+        }
+        return *m_toString;
+    }
+
+    virtual const char* objectID() const {
+        return "e6d71b09086d65624669159c92b29e24";
+    }
+
+    // Return 0 on failure and 1 on success.
+    //@{ @name Write operations
+    virtual Boolean write_boolean(Boolean x) = 0;
+    virtual Boolean write_char(Char x) = 0;
+    virtual Boolean write_wchar(WChar x) = 0;
+    virtual Boolean write_octet(Octet x) = 0;
+    virtual Boolean write_short(Short x) = 0;
+    virtual Boolean write_ushort(UShort x) = 0;
+    virtual Boolean write_long(Long x) = 0;
+    virtual Boolean write_ulong(ULong x) = 0;
+    virtual Boolean write_longlong(const LongLong &x) = 0;
+    virtual Boolean write_ulonglong(const ULongLong &x) = 0;
+    virtual Boolean write_float(Float x) = 0;
+    virtual Boolean write_double(const Double &x) = 0;
+    virtual Boolean write_longdouble(const LongDouble &x) = 0;
+
+    /// For string we offer methods that accept a precomputed length.
+    virtual Boolean write_string(const Char *x) = 0;
+    virtual Boolean write_string(UInt len, const Char *x) = 0;
+    virtual Boolean write_string(const ACE_CString &x) = 0;
+    virtual Boolean write_wstring(const WChar *x) = 0;
+    virtual Boolean write_wstring(UInt length, const WChar *x) = 0;
+    //@}
+
+    /// @note the portion written starts at <x> and ends
+    ///    at <x + length>.
+    /// The length is *NOT* stored into the CDR stream.
+    //@{ @name Array write operations
+    virtual Boolean write_boolean_array(const Boolean *x,
+            UInt length) = 0;
+    virtual Boolean
+    write_char_array(const Char *x, UInt length) = 0;
+    virtual Boolean write_wchar_array(const WChar* x,
+            UInt length) = 0;
+    virtual Boolean write_octet_array(const Octet* x,
+            UInt length) = 0;
+    virtual Boolean write_short_array(const Short *x,
+            UInt length) = 0;
+    virtual Boolean write_ushort_array(const UShort *x,
+            UInt length) = 0;
+    virtual Boolean
+    write_long_array(const Int *x, UInt length) = 0;
+    virtual Boolean write_ulong_array(const UInt *x,
+            UInt length) = 0;
+    virtual Boolean write_longlong_array(const LongLong* x,
+            UInt length) = 0;
+    virtual Boolean write_ulonglong_array(const ULongLong *x,
+            UInt length) = 0;
+    virtual Boolean write_float_array(const Float *x,
+            UInt length) = 0;
+    virtual Boolean write_double_array(const Double *x,
+            UInt length) = 0;
+    virtual Boolean write_longdouble_array(const LongDouble* x,
+            UInt length) = 0;
+
+    template <typename X> Boolean write_list(list<X*>& l) {
+        typename list<X*>::const_iterator iter = l.begin();
+        write_ulong(l.size());
+        while (iter != l.end()) {
+            (*iter)->serialize(*this);
+            iter++;
+        }
+        return true;
+    }
+
+    virtual Boolean write_boolean_list(list<Boolean> x) {
+        list<Boolean>::const_iterator iter = x.begin();
+        write_ulong(x.size());
+        while (iter != x.end()) {
+            write_boolean(*iter);
+            iter++;
+        }
+        return true;
+    }
+
+    virtual Boolean write_char_list(list<Char> x) {
+        list<Char>::const_iterator iter = x.begin();
+        write_ulong(x.size());
+        while (iter != x.end()) {
+            write_char(*iter);
+            iter++;
+        }
+        return true;
+    }
+
+    virtual Boolean write_wchar_list(list<WChar> x) {
+        list<WChar>::const_iterator iter = x.begin();
+        write_ulong(x.size());
+        while (iter != x.end()) {
+            write_wchar(*iter);
+            iter++;
+        }
+        return true;
+
+    }
+
+    virtual Boolean write_octet_list(list<Octet> x) {
+        list<Octet>::const_iterator iter = x.begin();
+        write_ulong(x.size());
+        while (iter != x.end()) {
+            write_octet(*iter);
+            iter++;
+        }
+        return true;
+
+    }
+
+    virtual Boolean write_short_list(list<Short> x) {
+        list<Short>::const_iterator iter = x.begin();
+        write_ulong(x.size());
+        while (iter != x.end()) {
+            write_short(*iter);
+            iter++;
+        }
+        return true;
+    }
+
+    virtual Boolean write_ushort_list(list<UShort> x) {
+        list<UShort>::const_iterator iter = x.begin();
+        write_ulong(x.size());
+        while (iter != x.end()) {
+            write_ushort(*iter);
+            iter++;
+        }
+        return true;
+    }
+
+    virtual Boolean write_long_list(list<Int> x) {
+        list<Int>::const_iterator iter = x.begin();
+        write_ulong(x.size());
+        while (iter != x.end()) {
+            write_long(*iter);
+            iter++;
+        }
+        return true;
+    }
+
+    virtual Boolean write_ulong_list(list<UInt> x) {
+        list<UInt>::const_iterator iter = x.begin();
+        write_ulong(x.size());
+        while (iter != x.end()) {
+            write_ulong(*iter);
+            iter++;
+        }
+        return true;
+    }
+
+    virtual Boolean write_longlong_list(list<LongLong> &x) {
+        list<LongLong>::const_iterator iter = x.begin();
+        write_ulong(x.size());
+        while (iter != x.end()) {
+            write_longlong(*iter);
+            iter++;
+        }
+        return true;
+    }
+
+    virtual Boolean write_ulonglong_list(list<ULong> &x) {
+        list<ULong>::const_iterator iter = x.begin();
+        write_ulong(x.size());
+        while (iter != x.end()) {
+            write_ulonglong(*iter);
+            iter++;
+        }
+        return true;
+    }
+
+    virtual Boolean write_float_list(list<Float> x) {
+        list<Float>::const_iterator iter = x.begin();
+        write_ulong(x.size());
+        while (iter != x.end()) {
+            write_float(*iter);
+            iter++;
+        }
+        return true;
+    }
+
+    virtual Boolean write_double_list(list<Double> &x) {
+        list<Double>::const_iterator iter = x.begin();
+        write_ulong(x.size());
+        while (iter != x.end()) {
+            write_double(*iter);
+            iter++;
+        }
+        return true;
+    }
+
+    virtual Boolean write_longdouble_list(list<LongDouble> &x) {
+        list<LongDouble>::const_iterator iter = x.begin();
+        write_ulong(x.size());
+        while (iter != x.end()) {
+            write_longdouble(*iter);
+            iter++;
+        }
+        return true;
+    }
+
+    /// For string we offer methods that accept a precomputed length.
+
+    virtual Boolean write_string_list(list<Char*> &x) {
+        list<Char*>::const_iterator iter = x.begin();
+        write_ulong(x.size());
+        while (iter != x.end()) {
+            write_string(*iter);
+            iter++;
+        }
+        return true;
+    }
+
+    virtual Boolean write_string_list(list<ACE_CString> &x) {
+        list<ACE_CString>::const_iterator iter = x.begin();
+        write_ulong(x.size());
+        while (iter != x.end()) {
+            write_string(*iter);
+            iter++;
+        }
+        return true;
+    }
+
+    virtual Boolean write_wstring_list(list<WChar*> &x) {
+        list<WChar*>::const_iterator iter = x.begin();
+        write_ulong(x.size());
+        while (iter != x.end()) {
+            write_wstring((const WChar*) (*iter));
+            iter++;
+        }
+        return true;
+    }
+
+
+
+    virtual Boolean write_serializable_list(const list<Serializable*>& l) = 0;
+
+    /// Write an octet array contained inside a MB, this can be optimized
+    /// to minimize copies.
+    virtual Boolean write_octet_array_mb(const ACE_Message_Block* mb) = 0;
+    //@}
+
+
+    /*virtual int consolidate() = 0;
+
+    virtual const ACE_Message_Block *begin(void) const = 0;
+
+    virtual const ACE_Message_Block *current(void) const = 0;
+
+    virtual ACE_Message_Block* release(void);
+
+    virtual Boolean replace(Int x, char* loc) = 0;*/
+
+    virtual size_t total_length(void) const = 0;
+};
+
+
+#endif /*OUTPUTSTREAM_H_*/


Getting rid of warning

Getting rid of warning


Don't define override and final when swigging.

--- SimTKcommon/include/SimTKcommon/internal/common.h
+++ SimTKcommon/include/SimTKcommon/internal/common.h
@@ -240,13 +240,18 @@

 /* Transition macros for C++11 support. VC10 and VC11 have partial support for
 C++11, early VC's do not. Currently we're assuming no support from gcc. */
-#if _MSC_VER>=1700 /* VC11 or higher */
-    #define OVERRIDE_11  override
-    #define FINAL_11     final
-#elif _MSC_VER==1600 /* VC10 */
-    #define OVERRIDE_11  override
-    #define FINAL_11     sealed
-#else /* gcc or earlier VC */
+#ifndef SWIG
+    #if _MSC_VER>=1700 /* VC11 or higher */
+        #define OVERRIDE_11  override
+        #define FINAL_11     final
+    #elif _MSC_VER==1600 /* VC10 */
+        #define OVERRIDE_11  override
+        #define FINAL_11     sealed
+    #else /* gcc or earlier VC */
+        #define OVERRIDE_11
+        #define FINAL_11
+    #endif
+#else /* Swigging */
     #define OVERRIDE_11
     #define FINAL_11
 #endif


asprintf instead of malloc

asprintf instead of malloc

--- bigsync.c
+++ bigsync.c
@@ -498,8 +498,7 @@
 	}

 	if (checksumsFilename == NULL) {
-		checksumsFilename = malloc(strlen(destFilename) + 9);
-		sprintf(checksumsFilename, "%s.bigsync", destFilename);
+		asprintf(&checksumsFilename, "%s.bigsync", destFilename);
 	}

 	if (fileSize(checksumsFilename) < 0) {


proper check for directory

proper check for directory

--- bigsync.c
+++ bigsync.c
@@ -291,18 +291,8 @@
 }

 int isDirectory(char *fileOrDirectoryName) {
- 	struct stat fileStat;
-  if (stat(fileOrDirectoryName, &fileStat) != 0) {
-		return -1;
-	}
-
-	if (fileStat.st_mode & S_IFBLK) {
-		return 0;
-	} else if (fileStat.st_mode & S_IFDIR) {
-		return 1;
-	} else {
-		return 0;
-	}
+	struct stat sb;
+	return (stat(fileOrDirectoryName, &sb) == 0 && S_ISDIR(sb.st_mode)) ? 1 : 0;
 }

 char *createDestFilenameFromSource(char *directoryName,  char *sourceFilename) {


Updated SpiDma class. Implemented blocking and zero copy modes for reading and writing. Fixed read by clearing DMA requests and SSP FIFO before enabling. Implemented timeout interrupt for zero copy writing callback. Updated Set Option and Get Option functions.

--- platform/nxp/lpc17xx/spi_dma.c
+++ platform/nxp/lpc17xx/spi_dma.c
@@ -10,6 +10,7 @@
 /*----------------------------------------------------------------------------*/
 static void dmaHandler(void *);
 static enum result dmaSetup(struct SpiDma *, int8_t, int8_t);
+static void interruptHandler(void *);
 /*----------------------------------------------------------------------------*/
 static enum result spiInit(void *, const void *);
 static void spiDeinit(void *);
@@ -100,15 +101,23 @@
   interface->rxDma = init(GpDma, channels + 0);
   if (!interface->rxDma)
     return E_ERROR;
-  dmaCallback(interface->rxDma, dmaHandler, interface);
   interface->txDma = init(GpDma, channels + 1);
   if (!interface->txDma)
     return E_ERROR;
-  dmaCallback(interface->txDma, dmaHandler, interface);
   interface->txMockDma = init(GpDma, channels + 2);
   if (!interface->txMockDma)
     return E_ERROR;
   return E_OK;
+}
+/*----------------------------------------------------------------------------*/
+static void interruptHandler(void *object)
+{
+  struct SpiDma *interface = object;
+  LPC_SSP_Type *reg = interface->parent.reg;
+
+  reg->IMSC &= ~IMSC_RTIM;
+  if (interface->callback)
+    interface->callback(interface->callbackArgument);
 }
 /*----------------------------------------------------------------------------*/
 static enum result spiInit(void *object, const void *configPtr)
@@ -134,6 +143,9 @@
   interface->callback = 0;
   interface->lock = SPIN_UNLOCKED;

+  /* Set pointer to interrupt handler */
+  interface->parent.handler = interruptHandler;
+
   /* Initialize SSP block */
   LPC_SSP_Type *reg = interface->parent.reg;

@@ -147,8 +159,13 @@
     reg->CR0 |= CR0_CPOL;

   sspSetRate(object, config->rate);
-  reg->DMACR |= DMACR_RXDMAE | DMACR_TXDMAE;
-  reg->CR1 = CR1_SSE; /* Enable peripheral */
+  /* Enable peripheral */
+  reg->CR1 = CR1_SSE;
+
+  /* Set lowest interrupt priority */
+  irqSetPriority(interface->parent.irq, 0);
+  /* Enable SPI interrupt */
+  irqEnable(interface->parent.irq);

   return E_OK;
 }
@@ -179,6 +196,7 @@
 static enum result spiGet(void *object, enum ifOption option, void *data)
 {
   struct SpiDma *interface = object;
+  LPC_SSP_Type *reg = interface->parent.reg;

   switch (option)
   {
@@ -186,8 +204,8 @@
       *(uint32_t *)data = sspGetRate(object);
       return E_OK;
     case IF_READY:
-      return dmaActive(interface->rxDma) || dmaActive(interface->txDma) ?
-          E_BUSY : E_OK;
+      return dmaActive(interface->rxDma) || dmaActive(interface->txDma)
+          || reg->SR & SR_BSY ? E_BUSY : E_OK;
     default:
       return E_ERROR;
   }
@@ -202,6 +220,7 @@
     case IF_ACQUIRE:
       return spinTryLock(&interface->lock) ? E_OK : E_BUSY;
     case IF_BLOCKING:
+      dmaCallback(interface->rxDma, 0, 0);
       interface->blocking = true;
       return E_OK;
     case IF_RATE:
@@ -211,6 +230,7 @@
       spinUnlock(&interface->lock);
       return E_OK;
     case IF_ZEROCOPY:
+      dmaCallback(interface->rxDma, dmaHandler, interface);
       interface->blocking = false;
       return E_OK;
     default:
@@ -228,6 +248,17 @@
   if (!length)
     return 0;

+  /* Clear input FIFO */
+  while (reg->SR & SR_RNE)
+    (void)reg->DR;
+
+  /* Clear timeout interrupt flags */
+  reg->ICR = ICR_RORIC | ICR_RTIC;
+
+  /* Clear DMA requests */
+  reg->DMACR &= ~(DMACR_RXDMAE | DMACR_TXDMAE);
+  reg->DMACR |= DMACR_RXDMAE | DMACR_TXDMAE;
+
   if (dmaStart(interface->rxDma, buffer, source, length) != E_OK)
     return 0;
   if (dmaStart(interface->txMockDma, source, &mock, length) != E_OK)
@@ -247,12 +278,25 @@
   LPC_SSP_Type *reg = interface->parent.reg;
   void *destination = (void *)&((LPC_SSP_Type *)interface->parent.reg)->DR;

-  if (length && dmaStart(interface->txDma, destination, buffer, length) == E_OK)
-  {
-    if (interface->blocking)
-      while (dmaActive(interface->txDma) || reg->SR & SR_BSY);
-    return length;
-  }
-
-  return 0;
-}
+  if (!length)
+    return 0;
+
+  /* Clear timeout interrupt flags */
+  reg->ICR = ICR_RORIC | ICR_RTIC;
+
+  /* Enable timeout interrupt when in zero copy mode */
+  if (!interface->blocking)
+    reg->IMSC |= IMSC_RTIM;
+
+  /* Clear DMA requests */
+  reg->DMACR &= ~(DMACR_RXDMAE | DMACR_TXDMAE);
+  reg->DMACR |= DMACR_RXDMAE | DMACR_TXDMAE;
+
+  if (dmaStart(interface->txDma, destination, buffer, length) != E_OK)
+    return 0;
+
+  if (interface->blocking)
+    while (dmaActive(interface->txDma) || reg->SR & SR_BSY);
+
+  return length;
+}


vector: name##_append() take n_elems rather than n_bytes

--- mtbl/vector.h
+++ mtbl/vector.h
@@ -77,11 +77,11 @@
 	}								\
 }									\
 static inline void							\
-name##_append(name *vec, const type *elems, size_t n)			\
+name##_append(name *vec, const type *elems, size_t n_elems)		\
 {									\
-	name##_need(vec, n);						\
-	memcpy((vec)->_v + (vec)->_n, elems, (n)*sizeof(*elems));	\
-	(vec)->_n += (n) / sizeof(type);				\
+	name##_need(vec, n_elems * sizeof(*elems));			\
+	memcpy((vec)->_v + (vec)->_n, elems, (n_elems)*sizeof(*elems));	\
+	(vec)->_n += (n_elems);						\
 	(vec)->_p = &((vec)->_v[(vec)->_n]);				\
 }									\
 static inline void							\


using rates by default instead of raw values

--- src/collectd/write_leela.c
+++ src/collectd/write_leela.c
@@ -16,6 +16,10 @@
 #define __write_leela_h__

 #include <collectd/config.h>
+#include <collectd/collectd.h>
+#include <collectd/common.h>
+#include <collectd/utils_cache.h>
+#include <collectd/plugin.h>

 #include <stdlib.h>
 #include <string.h>
@@ -24,10 +28,6 @@
 #include <pthread.h>
 #include <inttypes.h>
 #include <sys/types.h>
-
-#include <collectd/collectd.h>
-#include <collectd/common.h>
-#include <collectd/plugin.h>

 #include <leela/lql.h>
 #include <leela/endpoint.h>
@@ -57,7 +57,7 @@
   {
     for (k=0; cluster != NULL && cluster[k] != NULL; k+=1)
     { leela_endpoint_free(cluster[k]); }
-    free(cluster);
+    sfree(cluster);
   }
 }

@@ -148,16 +148,16 @@
     {
       wl_send(data);
       leela_lql_context_close(data->ctx);
-      free(data->user);
-      free(data->pass);
-      free(data->tree);
-      free(data->guid);
-      free(data->sndbuf);
+      sfree(data->user);
+      sfree(data->pass);
+      sfree(data->tree);
+      sfree(data->guid);
+      sfree(data->sndbuf);

       pthread_mutex_unlock(&data->mutex);
       pthread_mutex_destroy(&data->mutex);

-      free(data);
+      sfree(data);
     }
   }
 }
@@ -190,13 +190,13 @@
   char v_type_instance[DATA_MAX_NAME_LEN];

   return(wl_print(cfg,
-                  "%s.%s%s%s.%s%s%s",
+                  "%s/%s%s%s/%s%s%s",
                   wl_unquote(v_host, DATA_MAX_NAME_LEN, vl->host),
                   wl_unquote(v_plugin, DATA_MAX_NAME_LEN, vl->plugin),
-                  (wl_blank(vl->plugin_instance) ? "" : "/"),
+                  (wl_blank(vl->plugin_instance) ? "" : "-"),
                   (wl_blank(vl->plugin_instance) ? "" : wl_unquote(v_plugin_instance, DATA_MAX_NAME_LEN, vl->plugin_instance)),
                   wl_unquote(v_type, DATA_MAX_NAME_LEN, vl->type),
-                  (wl_blank(vl->type_instance) ? "" : "/"),
+                  (wl_blank(vl->type_instance) ? "" : "-"),
                   (wl_blank(vl->type_instance) ? "" : wl_unquote(v_type_instance, DATA_MAX_NAME_LEN, vl->type_instance))));
 }

@@ -208,36 +208,19 @@
   return(wl_print(cfg, "%ld.%ld", (long) time.tv_sec, time.tv_nsec));
 }

-static
-int wl_print_value (wl_data_t *cfg, int type, const value_t *value)
+// TODO:use something better than %g
+static
+int wl_print_value (wl_data_t *cfg, int type, const value_t *value, double rate)
 {
   int rc = 0;
   if (type == DS_TYPE_GAUGE)
-  { rc = wl_print(cfg, "(double %f)", value->gauge); } // TODO: use a better str->double
-  else if (type == DS_TYPE_COUNTER)
-  { rc = wl_print(cfg, "(uint64 %llu)", value->counter); }
-  else if (type == DS_TYPE_DERIVE)
-  { rc = wl_print(cfg, "(int64 %"PRIi64")", value->derive); }
-  else if (type == DS_TYPE_ABSOLUTE)
-  { rc = wl_print(cfg, "(uint64 %"PRIu64")", value->absolute); }
+  { rc = wl_print(cfg, "(double %g)", value->gauge); }
+  else if (type == DS_TYPE_COUNTER || type == DS_TYPE_DERIVE || type == DS_TYPE_ABSOLUTE)
+  { rc = wl_print(cfg, "(double %g)", rate); }
+  else
+  { rc = -1; }
   return(rc);
 }
-
-static
-int wl_lock(wl_data_t *cfg)
-{
-  while (pthread_mutex_lock(&cfg->mutex) != 0)
-  {
-    ERROR("write_leela plugin: error acquiring exclusive lock");
-    return(-1);
-  }
-
-  return(0);
-}
-
-static
-int wl_unlock(wl_data_t *cfg)
-{ return(pthread_mutex_unlock(&cfg->mutex)); }

 static
 int wl_flush (cdtime_t timeout, const char *identifier, user_data_t *data)
@@ -253,7 +236,7 @@
   { return(-1); }

   cfg = data->data;
-  if (wl_lock(cfg) != 0)
+  if (pthread_mutex_lock(&cfg->mutex) != 0)
   { return(-1); }

   t0 = CDTIME_T_TO_DOUBLE(cfg->ctime);
@@ -261,53 +244,60 @@
   if (timeout == 0 || t0 + timeout > t1)
   { rc = wl_send(cfg); }

-  wl_unlock(cfg);
+  pthread_mutex_unlock(&cfg->mutex);
   return(rc);
 }

 static
 int wl_write (const data_set_t *ds, const value_list_t *vl, user_data_t *data)
 {
-  int k, m, rc;
+  int k, rc;
   size_t state;
   wl_data_t *cfg;
+  gauge_t *rates;

   if (data == NULL)
   { return(-1); }

-  cfg = (wl_data_t *) data->data;
-  if (wl_lock(cfg) != 0)
+  rates = uc_get_rate(ds, vl);
+  cfg   = (wl_data_t *) data->data;
+  if (rates == NULL)
+  {
+    ERROR("write_leela plugin: uc_get_rate failure");
+    return(-1);
+  }
+  if (pthread_mutex_lock(&cfg->mutex) != 0)
   {
     ERROR("write_leela plugin: error acquiring exclusive lock");
-    return(-1);
-  }
-
-  for (k=0; k<ds->ds_num; k+=1)
-  {
-    for (m=0; m<vl->values_len; m+=1)
+    sfree(rates);
+    return(-1);
+  }
+
+  for (k=0; k<vl->values_len; k+=1)
+  {
+    state = cfg->sndbufoff;
+    rc    = (cfg->sndbufoff == 0 ? wl_print(cfg, "using (%s) attr put %s \"", cfg->tree, cfg->guid)
+                                 : wl_print(cfg, "attr put %s \"", cfg->guid))
+          | wl_print_name(cfg, vl)
+          | wl_print(cfg, "\" [")
+          | wl_print_time(cfg, vl->time)
+          | wl_print(cfg, "] ")
+          | wl_print_value(cfg, ds->ds[k].type, &vl->values[k], (double) rates[k])
+          | wl_print(cfg, ", ");
+    if (rc > 0)
     {
-      state = cfg->sndbufoff;
-      rc    = (cfg->sndbufoff == 0 ? wl_print(cfg, "using (%s) attr put %s \"", cfg->tree, cfg->guid)
-                                   : wl_print(cfg, "attr put %s \"", cfg->guid))
-            | wl_print_name(cfg, vl)
-            | wl_print(cfg, "\" [")
-            | wl_print_time(cfg, vl->time)
-            | wl_print(cfg, "] ")
-            | wl_print_value(cfg, ds->ds[m].type, &vl->values[m])
-            | wl_print(cfg, ", ");
-      if (rc > 0)
-      {
-        m             -= 1;
-        cfg->sndbufoff = state;
-        if (wl_send(cfg) != 0)
-        { return(-1); }
-      }
-      else if (rc < 0)
-      { return(-1); }
+      k             -= 1;
+      cfg->sndbufoff = state;
+      rc             = wl_send(cfg);
     }
-  }
-
-  return(wl_unlock(cfg));
+
+    if (rc != 0)
+    { break; }
+  }
+
+  pthread_mutex_unlock(&cfg->mutex);
+  sfree(rates);
+  return(rc != 0 ? -1 : 0);
 }

 static
@@ -381,7 +371,7 @@
   leela_cfg->sndbuflen  = 64 * 1024;
   if (pthread_mutex_init(&leela_cfg->mutex, NULL) != 0)
   {
-    free(leela_cfg);
+    sfree(leela_cfg);
     ERROR("write_leela plugin: malloc error");
     return(-1);
   }


Add a check for the case when the parent neighbor may have gone away to avoid using a NULL pointer

--- core/net/rpl/rpl-dag.c
+++ core/net/rpl/rpl-dag.c
@@ -553,13 +553,17 @@
   if(lladdr != NULL) {
     /* Add parent in rpl_parents */
     p = nbr_table_add_lladdr(rpl_parents, (rimeaddr_t *)lladdr);
-    p->dag = dag;
-    p->rank = dio->rank;
-    p->dtsn = dio->dtsn;
-    p->link_metric = RPL_INIT_LINK_METRIC * RPL_DAG_MC_ETX_DIVISOR;
+    if(p == NULL) {
+      PRINTF("RPL: rpl_add_parent p NULL\n");
+    } else {
+      p->dag = dag;
+      p->rank = dio->rank;
+      p->dtsn = dio->dtsn;
+      p->link_metric = RPL_INIT_LINK_METRIC * RPL_DAG_MC_ETX_DIVISOR;
 #if RPL_DAG_MC != RPL_DAG_MC_NONE
-    memcpy(&p->mc, &dio->mc, sizeof(p->mc));
+      memcpy(&p->mc, &dio->mc, sizeof(p->mc));
 #endif /* RPL_DAG_MC != RPL_DAG_MC_NONE */
+    }
   }

   return p;


Allow antenna mixing

Allow antenna mixing

--- extensions/ant_switch/ant_switch.c
+++ extensions/ant_switch/ant_switch.c
@@ -27,31 +27,27 @@

 static ant_switch_t ant_switch[RX_CHANS];

-int ant_switch_queryantenna() {
-	char line[256], *cp, *cp2;
+char * ant_switch_queryantennas() {
+	char line[256];
 	int n;
-	char selectedantenna = '0';
+	char selected_antennas[256];
 	non_blocking_cmd("/usr/local/bin/ms-s7-web s", line, sizeof(line), NULL);
-	n = sscanf(line, "Selected antenna: %c", &selectedantenna);
+	n = sscanf(line, "Selected antennas: %s", &selected_antennas);
 	if (!n) printf("ant_switch_queryantenna BAD STATUS? <%s>\n", line);
-	return(selectedantenna);
+	return(selected_antennas);
 }

-int ant_switch_setantenna(int antenna) {
+int ant_switch_setantenna(char* antenna) {
 	char line[256];
 	int status;
 	int n;
 	char *antennastr;
-
-	if (antenna == 8)
-		asprintf(&antennastr, "/usr/local/bin/ms-s7-web g"); // 8 = ground all antennas
-	else
-		asprintf(&antennastr, "/usr/local/bin/ms-s7-web %d", antenna);
+        asprintf(&antennastr, "/usr/local/bin/ms-s7-web t%s", antenna);
 	line[0] = '\0';
+        //if (ANT_SWITCH_DEBUG_MSG) printf("command to be executed: \"%s\"\n",antennastr);
 	n = non_blocking_cmd(antennastr, line, sizeof(line), &status);
-	if (ANT_SWITCH_DEBUG_MSG) printf("ant_switch_setantenna: %s\n",line);
 	free(antennastr);
-    return(status);
+	return(status);
 }

@@ -59,8 +55,9 @@
 {
 	ant_switch_t *e = &ant_switch[rx_chan];
 	int n=0;
-        int antenna;
-
+	//char selected_antennas[256];
+	char antenna[256];
+
 	printf("### ant_switch_msgs RX%d <%s>\n", rx_chan, msg);

 	if (strcmp(msg, "SET ext_server_init") == 0) {
@@ -69,23 +66,16 @@
 		return true;
 	}

-        n = sscanf(msg, "SET Antenna=%d", &antenna);
+        n = sscanf(msg, "SET Antenna=%s", &antenna);
         if (n == 1) {
-            if (antenna > 0 && antenna < 8) {
-                 ant_switch_setantenna(antenna);
-                 return true;
-            }
-        }
-
-        if (strcmp(msg, "SET Antenna=g") == 0) {
-            // 8 = ground all atennas
-            ant_switch_setantenna(8);
+            // fixme or toggleantenna if allowed
+            ant_switch_setantenna(antenna);
             return true;
         }

         if (strcmp(msg, "GET Antenna") == 0) {
-            int selected_antenna = ant_switch_queryantenna();
-            ext_send_msg(e->rx_chan, ANT_SWITCH_DEBUG_MSG, "EXT Antenna=%d", selected_antenna);
+            char *selected_antennas = ant_switch_queryantennas();
+            ext_send_msg(e->rx_chan, ANT_SWITCH_DEBUG_MSG, "EXT Antenna=%s", selected_antennas);
             return true;
         }


Fix bug in -no_native_exec cleanup

Fix bug in -no_native_exec cleanup

native_module_exit() needs to check for native_exec_areas being NULL to
work with -no_native_exec.

Review-URL: https://codereview.appspot.com/190460043

--- core/unix/native_elf.c
+++ core/unix/native_elf.c
@@ -673,13 +673,15 @@
     module_iterator_t *mi;
     module_area_t *ma;

-    mi = module_iterator_start();
-    while (module_iterator_hasnext(mi)) {
-         ma = module_iterator_next(mi);
-         if (vmvector_overlap(native_exec_areas, ma->start, ma->end))
-             native_module_unhook(ma);
-    }
-    module_iterator_stop(mi);
+    if (native_exec_areas != NULL) {
+        mi = module_iterator_start();
+        while (module_iterator_hasnext(mi)) {
+            ma = module_iterator_next(mi);
+            if (vmvector_overlap(native_exec_areas, ma->start, ma->end))
+                native_module_unhook(ma);
+        }
+        module_iterator_stop(mi);
+    }

 #ifdef X64
     if (plt_reachability_stub != NULL) {


Add pxa270 id

Add pxa270 id

--- arch/arm/include/armreg.h
+++ arch/arm/include/armreg.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: armreg.h,v 1.1 2004/02/01 05:09:49 drahn Exp $	*/
+/*	$OpenBSD: armreg.h,v 1.2 2004/12/30 23:30:14 drahn Exp $	*/
 /*	$NetBSD: armreg.h,v 1.27 2003/09/06 08:43:02 rearnsha Exp $	*/

 /*
@@ -196,14 +196,15 @@
 #define CPU_ID_SA1110		0x6901b110
 #define CPU_ID_IXP1200		0x6901c120
 #define CPU_ID_80200		0x69052000
-#define CPU_ID_PXA250    	0x69052100 /* sans core revision */
-#define CPU_ID_PXA210    	0x69052120
+#define CPU_ID_PXA250		0x69052100 /* sans core revision */
+#define CPU_ID_PXA210		0x69052120
 #define CPU_ID_PXA250A		0x69052100 /* 1st version Core */
 #define CPU_ID_PXA210A		0x69052120 /* 1st version Core */
 #define CPU_ID_PXA250B		0x69052900 /* 3rd version Core */
 #define CPU_ID_PXA210B		0x69052920 /* 3rd version Core */
 #define CPU_ID_PXA250C		0x69052d00 /* 4th version Core */
 #define CPU_ID_PXA210C		0x69052d20 /* 4th version Core */
+#define CPU_ID_PXA27X		0x69054110
 #define	CPU_ID_80321_400	0x69052420
 #define	CPU_ID_80321_600	0x69052430
 #define	CPU_ID_80321_400_B0	0x69052c20


ARM: 7535/1: Reprogram smp_twd based on new common clk framework notifiers

Running cpufreq driver on imx6q, the following warning is seen.

$ BUG: sleeping function called from invalid context at kernel/mutex.c:269

<snip>

stack backtrace:
Backtrace:
[<80011d64>] (dump_backtrace+0x0/0x10c) from [<803fc164>] (dump_stack+0x18/0x1c)
 r6:bf8142e0 r5:bf814000 r4:806ac794 r3:bf814000
[<803fc14c>] (dump_stack+0x0/0x1c) from [<803fd444>] (print_usage_bug+0x250/0x2b
8)
[<803fd1f4>] (print_usage_bug+0x0/0x2b8) from [<80060f90>] (mark_lock+0x56c/0x67
0)
[<80060a24>] (mark_lock+0x0/0x670) from [<80061a20>] (__lock_acquire+0x98c/0x19b
4)
[<80061094>] (__lock_acquire+0x0/0x19b4) from [<80062f14>] (lock_acquire+0x68/0x
7c)
[<80062eac>] (lock_acquire+0x0/0x7c) from [<80400f28>] (mutex_lock_nested+0x78/0
x344)
 r7:00000000 r6:bf872000 r5:805cc858 r4:805c2a04
[<80400eb0>] (mutex_lock_nested+0x0/0x344) from [<803089ac>] (clk_get_rate+0x1c/
0x58)
[<80308990>] (clk_get_rate+0x0/0x58) from [<80013c48>] (twd_update_frequency+0x1
8/0x50)
 r5:bf253d04 r4:805cadf4
[<80013c30>] (twd_update_frequency+0x0/0x50) from [<80068e20>] (generic_smp_call
_function_single_interrupt+0xd4/0x13c)
 r4:bf873ee0 r3:80013c30
[<80068d4c>] (generic_smp_call_function_single_interrupt+0x0/0x13c) from [<80013
34c>] (handle_IPI+0xc0/0x194)
 r8:00000001 r7:00000000 r6:80574e48 r5:bf872000 r4:80593958
[<8001328c>] (handle_IPI+0x0/0x194) from [<800084e8>] (gic_handle_irq+0x58/0x60)
 r8:00000000 r7:bf873f8c r6:bf873f58 r5:80593070 r4:f4000100
r3:00000005
[<80008490>] (gic_handle_irq+0x0/0x60) from [<8000e124>] (__irq_svc+0x44/0x60)
Exception stack(0xbf873f58 to 0xbf873fa0)
3f40:                                                       00000001 00000001
3f60: 00000000 bf814000 bf872000 805cab48 80405aa4 80597648 00000000 412fc09a
3f80: bf872000 bf873fac bf873f70 bf873fa0 80063844 8000f1f8 20000013 ffffffff
 r6:ffffffff r5:20000013 r4:8000f1f8 r3:bf814000
[<8000f1b8>] (default_idle+0x0/0x4c) from [<8000f428>] (cpu_idle+0x98/0x114)
[<8000f390>] (cpu_idle+0x0/0x114) from [<803f9834>] (secondary_start_kernel+0x11
c/0x140)
[<803f9718>] (secondary_start_kernel+0x0/0x140) from [<103f9234>] (0x103f9234)
 r6:10c03c7d r5:0000001f r4:4f86806a r3:803f921c

It looks that the warning is caused by that twd_update_frequency() gets
called from an atomic context while it calls clk_get_rate() where a
mutex gets held.

To fix the warning, let's convert common clk users over to clk notifiers
in place of CPUfreq notifiers.  This works out nicely for Cortex-A9
MPcore designs that scale all CPUs at the same frequency.

Platforms that have not been converted to the common clk framework and
support CPUfreq will rely on the old mechanism.  Once these platforms
are converted over fully then we can remove the CPUfreq-specific bits
for good.

Signed-off-by: Mike Turquette <6dab61939fc5e23761050a66932f032dceda5ebf@linaro.org>
Signed-off-by: Shawn Guo <912cf7eb7d8018e2943586ae6657d21fd4e38239@linaro.org>
Reviewed-by: Linus Walleij <9cd9d802d23c0ed5e224beabf4ae4a5c478746ef@linaro.org>
Reviewed-by: Ulf Hansson <fe47b31f388f85ce6ddf64bf3a0cf6b46077d0e6@linaro.org>
Signed-off-by: Russell King <f6aa0246ff943bfa8602cdf60d40c481b38ed232@arm.linux.org.uk>

--- arch/arm/kernel/smp_twd.c
+++ arch/arm/kernel/smp_twd.c
@@ -11,7 +11,6 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/clk.h>
-#include <linux/cpufreq.h>
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/err.h>
@@ -96,7 +95,52 @@
 	disable_percpu_irq(clk->irq);
 }

-#ifdef CONFIG_CPU_FREQ
+#ifdef CONFIG_COMMON_CLK
+
+/*
+ * Updates clockevent frequency when the cpu frequency changes.
+ * Called on the cpu that is changing frequency with interrupts disabled.
+ */
+static void twd_update_frequency(void *new_rate)
+{
+	twd_timer_rate = *((unsigned long *) new_rate);
+
+	clockevents_update_freq(*__this_cpu_ptr(twd_evt), twd_timer_rate);
+}
+
+static int twd_rate_change(struct notifier_block *nb,
+	unsigned long flags, void *data)
+{
+	struct clk_notifier_data *cnd = data;
+
+	/*
+	 * The twd clock events must be reprogrammed to account for the new
+	 * frequency.  The timer is local to a cpu, so cross-call to the
+	 * changing cpu.
+	 */
+	if (flags == POST_RATE_CHANGE)
+		smp_call_function(twd_update_frequency,
+				  (void *)&cnd->new_rate, 1);
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block twd_clk_nb = {
+	.notifier_call = twd_rate_change,
+};
+
+static int twd_clk_init(void)
+{
+	if (twd_evt && *__this_cpu_ptr(twd_evt) && !IS_ERR(twd_clk))
+		return clk_notifier_register(twd_clk, &twd_clk_nb);
+
+	return 0;
+}
+core_initcall(twd_clk_init);
+
+#elif defined (CONFIG_CPU_FREQ)
+
+#include <linux/cpufreq.h>

 /*
  * Updates clockevent frequency when the cpu frequency changes.


ARM: OMAP2+: PMU: Add runtime PM support

The original implementation of this patch was done by Ming Lei for PMU on OMAP4
[1]. Since then the PM runtime calls have been moved into the ARM PMU code and
this greatly simplifies the changes.

The another differnce since the original version, is that it is no longer
necessary to call pm_runtime_get/put during the PMU initialisation was we are no
longer accessing the hardware at this stage.

By adding runtime PM support, we can ensure that the appropriate power and clock
domains are kept on while PMU is being used.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2011-November/074153.html

Cc: Ming Lei <8d0fc11caeb4659419f0ba3104eb4a9d30848d42@canonical.com>
Cc: Will Deacon <b913f13ef92ac157955c954ccaaff7be065faba4@arm.com>
Cc: Benoit Cousson <1f57ac750b0b4fd69f24c35d4e23093b91dc3e77@ti.com>
Cc: Paul Walmsley <a027184a55211cd23e3f3094f1fdc728df5e0500@pwsan.com>
Cc: Kevin Hilman <f9849b02abe18c1ece6bd40346458ed53f49d31b@ti.com>
Signed-off-by: Jon Hunter <843c43c6ca6ac047d393694d733847b0a7f0f436@ti.com>
Signed-off-by: Paul Walmsley <a027184a55211cd23e3f3094f1fdc728df5e0500@pwsan.com>

--- arch/arm/mach-omap2/pmu.c
+++ arch/arm/mach-omap2/pmu.c
@@ -11,6 +11,7 @@
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
  */
+#include <linux/pm_runtime.h>

 #include <asm/pmu.h>

@@ -53,7 +54,12 @@
 	WARN(IS_ERR(omap_pmu_dev), "Can't build omap_device for %s.\n",
 	     dev_name);

-	return IS_ERR(omap_pmu_dev) ? PTR_ERR(omap_pmu_dev) : 0;
+	if (IS_ERR(omap_pmu_dev))
+		return PTR_ERR(omap_pmu_dev);
+
+	pm_runtime_enable(&omap_pmu_dev->dev);
+
+	return 0;
 }

 static int __init omap_init_pmu(void)


ARM: l2c: remove unnecessary call to outer_flush_all()

outer_disable() is defined to safely turn the L2 cache off without data
loss: this means that outer_flush_all() should never be called unless
you need to implement some special L2 cache disabling, and even then
only from your replacement L2 cache disable function.

Acked-by: Barry Song <a856445693a373abed3e477bd705f7011cbd8a1d@csr.com>
Signed-off-by: Russell King <f6aa0246ff943bfa8602cdf60d40c481b38ed232@arm.linux.org.uk>


ARM: OMAP: Remove useless omap_sram_error function.

This patch removes fixes omap_sram_error() function and replace the
error paths with BUG_ON.

The proposed fix was suggested by Russell King <rmk+kernel@arm.linux.org.uk>

Signed-off-by: Santosh Shilimkar <5b4d8dc9ea337fff5fd1729321eda9873ade0b09@ti.com>
Signed-off-by: Tony Lindgren <1001e8702733cced254345e193c88aaa47a4f5de@atomide.com>

--- arch/arm/plat-omap/sram.c
+++ arch/arm/plat-omap/sram.c
@@ -242,20 +242,13 @@
 	return (void *)omap_sram_ceil;
 }

-static void omap_sram_error(void)
-{
-	panic("Uninitialized SRAM function\n");
-}
-
 #ifdef CONFIG_ARCH_OMAP1

 static void (*_omap_sram_reprogram_clock)(u32 dpllctl, u32 ckctl);

 void omap_sram_reprogram_clock(u32 dpllctl, u32 ckctl)
 {
-	if (!_omap_sram_reprogram_clock)
-		omap_sram_error();
-
+	BUG_ON(!_omap_sram_reprogram_clock);
 	_omap_sram_reprogram_clock(dpllctl, ckctl);
 }

@@ -280,9 +273,7 @@
 void omap2_sram_ddr_init(u32 *slow_dll_ctrl, u32 fast_dll_ctrl,
 		   u32 base_cs, u32 force_unlock)
 {
-	if (!_omap2_sram_ddr_init)
-		omap_sram_error();
-
+	BUG_ON(!_omap2_sram_ddr_init);
 	_omap2_sram_ddr_init(slow_dll_ctrl, fast_dll_ctrl,
 			     base_cs, force_unlock);
 }
@@ -292,9 +283,7 @@

 void omap2_sram_reprogram_sdrc(u32 perf_level, u32 dll_val, u32 mem_type)
 {
-	if (!_omap2_sram_reprogram_sdrc)
-		omap_sram_error();
-
+	BUG_ON(!_omap2_sram_reprogram_sdrc);
 	_omap2_sram_reprogram_sdrc(perf_level, dll_val, mem_type);
 }

@@ -302,9 +291,7 @@

 u32 omap2_set_prcm(u32 dpll_ctrl_val, u32 sdrc_rfr_val, int bypass)
 {
-	if (!_omap2_set_prcm)
-		omap_sram_error();
-
+	BUG_ON(!_omap2_set_prcm);
 	return _omap2_set_prcm(dpll_ctrl_val, sdrc_rfr_val, bypass);
 }
 #endif
@@ -360,9 +347,7 @@
 u32 omap3_configure_core_dpll(u32 sdrc_rfr_ctrl, u32 sdrc_actim_ctrla,
 			      u32 sdrc_actim_ctrlb, u32 m2)
 {
-	if (!_omap3_sram_configure_core_dpll)
-		omap_sram_error();
-
+	BUG_ON(!_omap3_sram_configure_core_dpll);
 	return _omap3_sram_configure_core_dpll(sdrc_rfr_ctrl,
 					       sdrc_actim_ctrla,
 					       sdrc_actim_ctrlb, m2);


support exit at boot -a time

support exit at boot -a time

--- arch/i386/i386/autoconf.c
+++ arch/i386/i386/autoconf.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: autoconf.c,v 1.70 2007/02/20 21:15:01 tom Exp $	*/
+/*	$OpenBSD: autoconf.c,v 1.71 2007/05/01 17:35:56 deraadt Exp $	*/
 /*	$NetBSD: autoconf.c,v 1.20 1996/05/03 19:41:56 christos Exp $	*/

 /*-
@@ -406,6 +406,8 @@
 			cnpollc(FALSE);
 			if (*name == '\0')
 				break;
+			if (strcmp(name, "exit") == 0)
+				boot(RB_USERREQ);
 			for (gc = genericconf; gc->gc_driver; gc++)
 				if (gc->gc_driver->cd_ndevs &&
 				    strncmp(gc->gc_name, name,
@@ -454,11 +456,11 @@
 #endif
 			}

-			printf("use one of: ");
+			printf("use one of: exit");
 			for (gc = genericconf; gc->gc_driver; gc++) {
 				for (unit=0; unit < gc->gc_driver->cd_ndevs; unit++) {
 					if (gc->gc_driver->cd_devs[unit])
-						printf("%s%d[a-%c] ", gc->gc_name,
+						printf(" %s%d[a-%c]", gc->gc_name,
 						    unit, 'a'+MAXPARTITIONS-1);
 				}
 			}
@@ -466,7 +468,7 @@
 			for (ifp = TAILQ_FIRST(&ifnet); ifp != NULL;
 			    ifp = TAILQ_NEXT(ifp, if_list)) {
 				if ((ifp->if_flags & IFF_BROADCAST))
-					printf("%s ", ifp->if_xname);
+					printf(" %s", ifp->if_xname);
 			}
 #endif
 			printf("\n");


[IA64] sn_check_intr: use ia64_get_irr()

Use the recently-added ia64_get_irr() rather than duplicating the code.

Signed-off-by: Bjorn Helgaas <10beeee9ebfac68af8330145c8378a1d1bb2a283@hp.com>
Acked-by: Jes Sorensen <e7bd830ae2d0c840ab7cd2131cd33ff38c069cbe@sgi.com>
Signed-off-by: Tony Luck <e7984595ec0368ff920a7b3521dc7093683f6f26@intel.com>

--- arch/ia64/sn/kernel/irq.c
+++ arch/ia64/sn/kernel/irq.c
@@ -350,9 +350,6 @@
 static void sn_check_intr(int irq, struct sn_irq_info *sn_irq_info)
 {
 	u64 regval;
-	int irr_reg_num;
-	int irr_bit;
-	u64 irr_reg;
 	struct pcidev_info *pcidev_info;
 	struct pcibus_info *pcibus_info;

@@ -373,23 +370,7 @@
 	    pdi_pcibus_info;
 	regval = pcireg_intr_status_get(pcibus_info);

-	irr_reg_num = irq_to_vector(irq) / 64;
-	irr_bit = irq_to_vector(irq) % 64;
-	switch (irr_reg_num) {
-	case 0:
-		irr_reg = ia64_getreg(_IA64_REG_CR_IRR0);
-		break;
-	case 1:
-		irr_reg = ia64_getreg(_IA64_REG_CR_IRR1);
-		break;
-	case 2:
-		irr_reg = ia64_getreg(_IA64_REG_CR_IRR2);
-		break;
-	case 3:
-		irr_reg = ia64_getreg(_IA64_REG_CR_IRR3);
-		break;
-	}
-	if (!test_bit(irr_bit, &irr_reg)) {
+	if (!ia64_get_irr(irq_to_vector(irq))) {
 		if (!test_bit(irq, pda->sn_in_service_ivecs)) {
 			regval &= 0xff;
 			if (sn_irq_info->irq_int_bit & regval &


microblaze: add missing CONFIG_ prefixes

Signed-off-by: Paul Bolle <0bda9a89324ffe2d19adec61a9f1cd9f8c8e45f0@tiscali.nl>
Acked-by: Michal Simek <3a191dd2be46e826fee926d532b136ed65cb5318@monstr.eu>
Signed-off-by: Jiri Kosina <ed58f755cc8caaf10c3e8c731a8b86fb8f13d6cb@suse.cz>

--- arch/microblaze/mm/init.c
+++ arch/microblaze/mm/init.c
@@ -304,11 +304,11 @@
 	/* Map in all of RAM starting at CONFIG_KERNEL_START */
 	mapin_ram();

-#ifdef HIGHMEM_START_BOOL
-	ioremap_base = HIGHMEM_START;
+#ifdef CONFIG_HIGHMEM_START_BOOL
+	ioremap_base = CONFIG_HIGHMEM_START;
 #else
 	ioremap_base = 0xfe000000UL;	/* for now, could be 0xfffff000 */
-#endif /* CONFIG_HIGHMEM */
+#endif /* CONFIG_HIGHMEM_START_BOOL */
 	ioremap_bot = ioremap_base;

 	/* Initialize the context management stuff */


Cosmetic fix

Cosmetic fix

--- bin/vlc.c
+++ bin/vlc.c
@@ -203,7 +203,7 @@
     if (vlc == NULL)
         goto out;

-     libvlc_set_user_agent (vlc, "VLC media player", NULL);
+    libvlc_set_user_agent (vlc, "VLC media player", NULL);

 #if !defined (HAVE_MAEMO) && !defined __APPLE__
     libvlc_add_intf (vlc, "globalhotkeys,none");


[POWERPC] Simplify vio_bus_init a little for legacy iSeries

iSeries_vio_dev was already statically initialised and we can remove
one set of #ifdef CONFIG_PPC_ISERIES guards.

Signed-off-by: Stephen Rothwell <4bf0fb350827ce8d86875e76c923a478597c3cef@canb.auug.org.au>
Signed-off-by: Paul Mackerras <19a0ba370c443ba08d20b5061586430ab449ee8c@samba.org>

--- arch/powerpc/kernel/vio.c
+++ arch/powerpc/kernel/vio.c
@@ -64,6 +64,12 @@
 		printk("Virtual Bus VETH TCE table failed.\n");
 	if (!iommu_init_table(&vio_iommu_table, -1))
 		printk("Virtual Bus VIO TCE table failed.\n");
+	vio_bus_device.dev.archdata.dma_ops = &dma_iommu_ops;
+	vio_bus_device.dev.archdata.dma_data = &vio_iommu_table;
+}
+#else
+static void __init iommu_vio_init(void)
+{
 }
 #endif

@@ -282,14 +288,8 @@
 	int err;
 	struct device_node *node_vroot;

-#ifdef CONFIG_PPC_ISERIES
-	if (firmware_has_feature(FW_FEATURE_ISERIES)) {
+	if (firmware_has_feature(FW_FEATURE_ISERIES))
 		iommu_vio_init();
-		vio_bus_device.dev.archdata.dma_ops = &dma_iommu_ops;
-		vio_bus_device.dev.archdata.dma_data = &vio_iommu_table;
-		iSeries_vio_dev = &vio_bus_device.dev;
-	}
-#endif /* CONFIG_PPC_ISERIES */

 	err = bus_register(&vio_bus_type);
 	if (err) {


OGRE_COMPILER_GCC doesn’t exist, use OGRE_COMPILER_GNUC instead and get rid of a few other troublesome boost warnings.

--HG--
branch : v1-9

--- OgreMain/include/Threading/OgreThreadHeadersBoost.h
+++ OgreMain/include/Threading/OgreThreadHeadersBoost.h
@@ -26,14 +26,16 @@
 #ifndef __OgreThreadHeadersBoost_H__
 #define __OgreThreadHeadersBoost_H__

-#if OGRE_COMPILER == OGRE_COMPILER_CLANG || OGRE_COMPILER == OGRE_COMPILER_GCC
+#if OGRE_COMPILER == OGRE_COMPILER_CLANG || OGRE_COMPILER == OGRE_COMPILER_GNUC
 #   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wpragmas"
 #   pragma GCC diagnostic ignored "-Wshadow"
 #   pragma GCC diagnostic ignored "-Wpadded"
 #   pragma GCC diagnostic ignored "-Wweak-vtables"
 #   pragma GCC diagnostic ignored "-Wall"
 #   pragma GCC diagnostic ignored "-Wshorten-64-to-32"
 #   pragma GCC diagnostic ignored "-Wunused-local-typedefs"
+#   pragma GCC diagnostic ignored "-Wunused-variable"
 #endif

 #include <boost/thread/tss.hpp>
@@ -43,7 +45,7 @@
 #include <boost/thread/shared_mutex.hpp>
 #include <boost/thread/locks.hpp>

-#if OGRE_COMPILER == OGRE_COMPILER_CLANG || OGRE_COMPILER == OGRE_COMPILER_GCC
+#if OGRE_COMPILER == OGRE_COMPILER_CLANG || OGRE_COMPILER == OGRE_COMPILER_GNUC
 #   pragma GCC diagnostic pop
 #endif


s390/numa: make core to node mapping data dynamic

The core to node mapping data consumes about 2 KB bss data. To save memory
for the non-NUMA case, make the data dynamic. In addition change the
"core_to_node" array from "int" to "s32" which saves 1 KB also for the
NUMA case.

Suggested-by: Heiko Carstens <8dcf0f69152f32f23184f83357a3731522e56b9c@de.ibm.com>
Signed-off-by: Michael Holzheu <db4757c56f54651f568cc7cda79cd93c781b1605@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <52616596d8f5df0d597e85ab515377f92f939c68@de.ibm.com>


tile/pci_gx: Prepare trio_handle_level_irq for irq argument removal

The irq argument of most interrupt flow handlers is unused or merily
used instead of a local variable. The handlers which need the irq
argument can retrieve the irq number from the irq descriptor.

Search and update was done with coccinelle and the invaluable help of
Julia Lawall.

Signed-off-by: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>
Cc: Julia Lawall <3d4a3affaf9163789962e9770780389962bda29d@lip6.fr>
Cc: Chris Metcalf <074881f6f5da4d3b5278870ff234d1077ee622c0@ezchip.com>


tile PCI RC: Use default pcibios_enable_device()

We don't need anything arch-specific in pcibios_enable_device(), so drop
the arch implementation and use the default generic one.

Note: pci_enable_resources() checks that r->parent is non-NULL, which
basically checks that pci_claim_resource() or request_resource() has been
called for each BAR.  I don't see where that happens for tile, but this
patch doesn't change that behavior, so if it worked before, it should still
work.

Signed-off-by: Bjorn Helgaas <f10ec01be0c6b54271af5c550cd257810bdf3268@google.com>
Acked-by: Chris Metcalf <074881f6f5da4d3b5278870ff234d1077ee622c0@tilera.com>


x86_64: apic change setup_APIC_timer calling convention

setup_APIC_timer takes the file global calibration result as an argument.
Remove it.

Signed-off-by: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>
Signed-off-by: Chris Wright <e829bd48de90b6e1a1950750fa8ca2bb62f273d4@sous-sol.org>
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@elte.hu>
Signed-off-by: Arjan van de Ven <9043bf4b08f6c93a2cb55d98c3494b123858348f@linux.intel.com>

--- arch/x86/kernel/apic_64.c
+++ arch/x86/kernel/apic_64.c
@@ -783,7 +783,7 @@
 		apic_write(APIC_TMICT, clocks);
 }

-static void setup_APIC_timer(unsigned int clocks)
+static void setup_APIC_timer(void)
 {
 	unsigned long flags;
 	int irqen;
@@ -792,7 +792,7 @@

 	irqen = ! cpu_isset(smp_processor_id(),
 			    timer_interrupt_broadcast_ipi_mask);
-	__setup_APIC_LVTT(clocks, 0, irqen);
+	__setup_APIC_LVTT(calibration_result, 0, irqen);
 	/* Turn off PIT interrupt if we use APIC timer as main timer.
 	   Only works with the PM timer right now
 	   TBD fix it for HPET too. */
@@ -879,7 +879,7 @@
 	/*
 	 * Now set up the timer for real.
 	 */
-	setup_APIC_timer(calibration_result);
+	setup_APIC_timer();

 	local_irq_enable();
 }
@@ -887,7 +887,7 @@
 void __cpuinit setup_secondary_APIC_clock(void)
 {
 	local_irq_disable(); /* FIXME: Do we need this? --RR */
-	setup_APIC_timer(calibration_result);
+	setup_APIC_timer();
 	local_irq_enable();
 }


[PATCH] revert "insert IOAPIC(s) and Local APIC into resource map"

Commit 54dbc0c9ebefb38840c6b07fa6eabaeb96c921f5 is causing various
people's machines to fail to map PCI resources.

Revert it in preparation for addressing the show-APICs-in-/proc/iomem
requirement in a different manner.

Cc: Aaron Durbin <af0622ab041e8b0f8e5819838dcc93898196e71f@google.com>
Cc: Andi Kleen <0474aee45985f5ae829f53849df476200e876990@muc.de>
Cc: "Eric W. Biederman" <8a741aa8cbd77ebc4a56ddb528ce9fd15d42f034@xmission.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@osdl.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@osdl.org>

--- arch/x86_64/kernel/apic.c
+++ arch/x86_64/kernel/apic.c
@@ -25,7 +25,6 @@
 #include <linux/kernel_stat.h>
 #include <linux/sysdev.h>
 #include <linux/module.h>
-#include <linux/ioport.h>

 #include <asm/atomic.h>
 #include <asm/smp.h>
@@ -45,11 +44,6 @@
 int apic_calibrate_pmtmr __initdata;

 int disable_apic_timer __initdata;
-
-static struct resource lapic_resource = {
-	.name = "Local APIC",
-	.flags = IORESOURCE_MEM | IORESOURCE_BUSY,
-};

 /*
  * cpu_mask that denotes the CPUs that needs timer interrupt coming in as
@@ -591,40 +585,6 @@
 	return 0;
 }

-#ifdef CONFIG_X86_IO_APIC
-static struct resource * __init ioapic_setup_resources(void)
-{
-#define IOAPIC_RESOURCE_NAME_SIZE 11
-	unsigned long n;
-	struct resource *res;
-	char *mem;
-	int i;
-
-	if (nr_ioapics <= 0)
-		return NULL;
-
-	n = IOAPIC_RESOURCE_NAME_SIZE + sizeof(struct resource);
-	n *= nr_ioapics;
-
-	res = alloc_bootmem(n);
-
-	if (!res)
-		return NULL;
-
-	memset(res, 0, n);
-	mem = (void *)&res[nr_ioapics];
-
-	for (i = 0; i < nr_ioapics; i++) {
-		res[i].name = mem;
-		res[i].flags = IORESOURCE_MEM | IORESOURCE_BUSY;
-		snprintf(mem, IOAPIC_RESOURCE_NAME_SIZE, "IOAPIC %u", i);
-		mem += IOAPIC_RESOURCE_NAME_SIZE;
-	}
-
-	return res;
-}
-#endif
-
 void __init init_apic_mappings(void)
 {
 	unsigned long apic_phys;
@@ -644,11 +604,6 @@
 	apic_mapped = 1;
 	apic_printk(APIC_VERBOSE,"mapped APIC to %16lx (%16lx)\n", APIC_BASE, apic_phys);

-	/* Put local APIC into the resource map. */
-	lapic_resource.start = apic_phys;
-	lapic_resource.end = lapic_resource.start + PAGE_SIZE - 1;
-	insert_resource(&iomem_resource, &lapic_resource);
-
 	/*
 	 * Fetch the APIC ID of the BSP in case we have a
 	 * default configuration (or the MP table is broken).
@@ -658,9 +613,7 @@
 	{
 		unsigned long ioapic_phys, idx = FIX_IO_APIC_BASE_0;
 		int i;
-		struct resource *ioapic_res;
-
-		ioapic_res = ioapic_setup_resources();
+
 		for (i = 0; i < nr_ioapics; i++) {
 			if (smp_found_config) {
 				ioapic_phys = mp_ioapics[i].mpc_apicaddr;
@@ -672,13 +625,6 @@
 			apic_printk(APIC_VERBOSE,"mapped IOAPIC to %016lx (%016lx)\n",
 					__fix_to_virt(idx), ioapic_phys);
 			idx++;
-
-			if (ioapic_res) {
-				ioapic_res->start = ioapic_phys;
-				ioapic_res->end = ioapic_phys + (4 * 1024) - 1;
-				insert_resource(&iomem_resource, ioapic_res);
-				ioapic_res++;
-			}
 		}
 	}
 }


[PATCH] x86-64: Fix partial page check to ensure unusable memory is not being marked usable.

Fix partial page check in e820_register_active_regions to ensure
partial pages are
not being marked as active in the memory pool.

Signed-off-by: Aaron Durbin <af0622ab041e8b0f8e5819838dcc93898196e71f@google.com>
Signed-off-by: Andi Kleen <0474aee45985f5ae829f53849df476200e876990@suse.de>

--- arch/x86_64/kernel/e820.c
+++ arch/x86_64/kernel/e820.c
@@ -278,7 +278,7 @@
 								>> PAGE_SHIFT;

 		/* Skip map entries smaller than a page */
-		if (ei_startpfn > ei_endpfn)
+		if (ei_startpfn >= ei_endpfn)
 			continue;

 		/* Check if end_pfn_map should be updated */


Use kFSEventStreamCreateFlagIgnoreSelf.

Use kFSEventStreamCreateFlagIgnoreSelf.

While this may not be desired for some use cases, for us, it's a big win.

--- osx/net_contentobjects_jnotify_macosx_JNotify_macosx.c
+++ osx/net_contentobjects_jnotify_macosx_JNotify_macosx.c
@@ -114,7 +114,7 @@

   // create the stream
   FSEventStreamContext context = {0, node, NULL, NULL, NULL};
-  node->stream = FSEventStreamCreate(NULL, &fsevent_callback, &context, paths, kFSEventStreamEventIdSinceNow, 1, kFSEventStreamCreateFlagNone);
+  node->stream = FSEventStreamCreate(NULL, &fsevent_callback, &context, paths, kFSEventStreamEventIdSinceNow, 1, kFSEventStreamCreateFlagIgnoreSelf);
   if (node->stream == NULL)
   {
     (*env)->ThrowNew(env, (*env)->FindClass(env, "net/contentobjects/jnotify/macosx/JNotifyException_macosx"), "Could not create stream");


Added check for number of rows

Added check for number of rows

--- array_family/flex_table.h
+++ array_family/flex_table.h
@@ -88,6 +88,7 @@
             mapped_type(af::shared<T>(n, init_zero<T>()))));
         }
         af::shared<T> this_column = boost::get< af::shared<T> >(it->second);
+        DIALS_ASSERT(this_column.size() == other_column.size());
         for (std::size_t i = 0; i < this_column.size(); ++i) {
           this_column[i] = other_column[i];
         }


test push

test push

--- array_merge/array_merge.c
+++ array_merge/array_merge.c
@@ -1,47 +1,174 @@
 #include <stdlib.h>
 #include <string.h>
+#include <stdio.h>

 #include "array_merge.h"

-/*int* array_merge(int num_arrays, int* sizes, int** values){
-	return [0];
-}*/

-int* two_array_merge(int size1, int* array1, int size2, int* array2){
+int* two_array_merge1(int size1, int* array1, int size2, int* array2){
 	int* jj;
 	int* fin;
-	int i,j;
-	int pointer;
-	int repeatTimes = 0;
+	int i,j,k;

-
-	jj =(int*)  calloc(size1+size2+1, sizeof(int));
+	jj =(int*)  calloc(size1+size2, sizeof(int));
 	for (i = 0; i < size1; i++){
 		jj[i] = array1[i];
 	}
-	pointer = size1;
 	for (j = 0; j < size2; j++){
-		for (i = 0; i < size1; i++){
-			if (array2[j] == array1[i]){
-				repeatTimes++;
-			}
-		}
-		if (repeatTimes == 0){
-			jj[pointer] =  array2[j];
-			pointer++;
-		}
+		jj[size1+j] = array2[j];
 	}
-	fin =(int*)  calloc(pointer,sizeof(int));
-	for (i = 0; i < pointer; i++){
-		fin[i] = jj[i];
+	fin =(int*)  calloc(size1+size2+1,sizeof(int));
+	fin[0] = size1+size2;
+	for (k = 0; k < size1+size2; k++){
+		fin[k+1] = jj[k];
 	}
 	free(jj);
 	return fin;
 }

-int main(int argc, char* argv[]) {
-	int array1[] = {3,2,0,5};
-	int array2[] = {8,9};
+int* two_array_merge2(int* array1, int size2, int* array2){
+	int* jj;
+	int* final;
+	int i,j,k;
+	int size1;

-	printf("%s\n", two_array_merge(4,array1,2,array2));
+	size1 = array1[0];
+	jj =(int*)  calloc(size1+size2, sizeof(int));
+	for (i = 1; i < size1+1 ; i++){
+		jj[i-1] = array1[i];
+	}
+	for (j = 0; j < size2; j++){
+		jj[size1+j] = array2[j];
+	}
+	final =(int*)  calloc(size1+size2+1,sizeof(int));
+	final[0]=size1+size2;
+	for (k = 0; k < size1+size2; k++){
+		final[k+1] = jj[k];
+	}
+	free(jj);
+	return final;
 }
+
+int* check_dupl1(int* array){
+	int i,j,k;
+	int* jj;
+	int* ff;
+	int repeatTimes;
+	int pointer=0;
+	int size;
+	size = array[0];
+	jj=(int*) calloc(size+1,sizeof(int));
+	for (i = 1; i < size; i++){
+		repeatTimes = 0;
+		for (j = i+1; j < size+1; j++){
+			if (array[i] == array[j]){
+				repeatTimes++;
+			}
+		}
+		if (repeatTimes == 0){
+			jj[pointer] =  array[i];
+			pointer++;
+		}
+	}
+	jj[pointer] = array[size];
+	pointer++;
+	ff=(int*) calloc(pointer,sizeof(int));
+	ff[0]=pointer;
+	printf("%i\n",ff[0]);
+	for (k = 0; k < pointer; k++){
+		ff[k+1] = jj[k];
+		printf("%i\n",ff[k+1]);
+	}
+	free(jj);
+	return ff;
+}
+
+int* check_dupl2(int size,int* array){
+	int i,j,k;
+	int* jj;
+	int* ff;
+	int repeatTimes;
+	int pointer=0;
+	jj=(int*) calloc(size+1,sizeof(int));
+	for (i = 0; i < size-1; i++){
+		repeatTimes = 0;
+		for (j = i+1; j < size; j++){
+			if (array[i] == array[j]){
+				repeatTimes++;
+			}
+		}
+		if (repeatTimes == 0){
+			jj[pointer] =  array[i];
+			pointer++;
+		}
+	}
+	jj[pointer] = array[size-1];
+	pointer++;
+	ff=(int*) calloc(pointer,sizeof(int));
+	ff[0]=pointer;
+	for (k = 0; k < pointer; k++){
+		ff[k+1] = jj[k];
+	}
+
+	free(jj);
+	return ff;
+}
+
+int* get_part_of_array(int* array){
+	int size;
+	int* fin;
+	int i;
+	size = array[0];
+	fin = (int*) calloc(size-1,sizeof(int));
+	for (i = 1; i < size; i++){
+		fin[i-1] = array[i];
+	}
+	return fin;
+}
+
+int* put_back_to_array(int size, int* array){
+        int i;
+        int* fin;
+        fin = (int*) calloc(size+1,sizeof(int));
+        fin[0]=size;
+        for (i = 1; i<size+1; i++){
+                fin[i]= array[i-1];
+        }
+        return fin;
+}
+
+
+
+void mergesort(int size, int* array);
+
+int* array_merge(int num_arrays, int* sizes, int** values){
+	int i;
+	int* test;
+	int* result;
+	int* array0;
+	int* array1;
+	int size;
+	if (num_arrays == 0){
+		result = {0};
+		return result;
+	} else if (num_arrays == 1){
+		array0 = check_dupl2(sizes[0],values[0]);
+		size = array0[0];
+		array1 = get_part_of_array(array0);
+		mergesort(size,array1);
+		result = put_back_to_array(size,array1);
+		return result;
+	} else {
+		test = (int*) two_array_merge1(sizes[0],values[0],sizes[1],values[1]);
+		for (i = 2; i < num_arrays; i++){
+			test = (int*) two_array_merge2(test,sizes[i],values[i]);
+		}
+		array0 = check_dupl1(test);
+		size = array0[0];
+		array1 = get_part_of_array(array0);
+		mergesort(size,array1);
+		result = put_back_to_array(size,array1);
+		return result;
+	}
+}
+


Copied latest time helper of trunk to devel-branch

git-svn-id: d74bd7aed9ec2d996d31810ce74317c2e68d0add@1529 53f5c7ee-bee3-0310-bbc5-ea0e15fffd5e

error: pathspec 'opensync/format/opensync_time.c' did not match any file(s) known to git

--- opensync/format/opensync_time.c
+++ opensync/format/opensync_time.c
@@ -0,0 +1,1061 @@
+/*
+ * libopensync - A synchronization framework
+ * Copyright (C) 2004-2005  Armin Bauer <armin.bauer@opensync.org>
+ * Copyright (C) 2006 Daniel Gollub <dgollub@suse.de>
+ *
+ * This library 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 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ */
+
+#include <time.h>
+
+#include "opensync.h"
+#include "opensync_internals.h"
+
+/* Floating Timestamps...... (handle tzid!) */
+
+/*
+ * Time formatting helper
+ */
+
+/*! @brief Function remove dashes from datestamp and colon
+ *
+ * @param timestamp The timestamp which gets cleaned
+ * @returns valid vtime stamp in YYYYMMDD[THHMMDD[Z]] (the caller is responsible for freeing)
+ */
+static char *osync_time_timestamp_remove_dash(const char *timestamp) {
+        int i, len;
+        GString *str = g_string_new("");
+
+        len = strlen(timestamp);
+
+	for (i=0; i < len; i++) {
+		if (timestamp[i] == '-')
+			continue;
+
+		if (timestamp[i] == ':')
+			continue;
+
+		str = g_string_append_c(str, timestamp[i]);
+	}
+
+        return (char*) g_string_free(str, FALSE);
+}
+
+/*! @brief Function returns a date-timestamp in OSyncTime Spec format
+ *
+ * @param vtime The timestamp which gets converted to a valid osync date-timestamp
+ * @returns vtime date-timestring (the caller is responsible for freeing)
+ */
+char *osync_time_timestamp(const char *vtime) {
+	osync_trace(TRACE_ENTRY, "%s(%s)", __func__, vtime);
+
+	char *timestamp;
+
+	timestamp = osync_time_timestamp_remove_dash(vtime);
+
+	osync_trace(TRACE_EXIT, "%s: %s", __func__, timestamp);
+	return timestamp;
+}
+
+/*! @brief Function returns a date without timestamp in OSyncTime Spec format
+ *
+ * @param vtime The timestamp which gets converted to a single datestamp
+ * @returns valid single datestamp YYYYMMDD (the caller is responsible for freeing)
+ */
+char *osync_time_datestamp(const char *vtime) {
+	osync_trace(TRACE_ENTRY, "%s(%s)", __func__, vtime);
+
+	char *tmp;
+	const char *p;
+	GString *str = g_string_new ("");
+
+	tmp = osync_time_timestamp_remove_dash(vtime);
+
+	for (p=tmp; *p && *p != 'T'; p++)
+		str = g_string_append_c (str, *p);
+
+	free(tmp);
+
+	osync_trace(TRACE_EXIT, "%s: %s", __func__, str->str);
+	return (char*) g_string_free(str, FALSE);
+}
+
+/*! @brief Function returns TRUE if vtime is a valid datestamp (YYYYMMDD)
+ *
+ * @returns FALSE if vtime includes a timestamp, TRUE on a single datestamp
+ */
+osync_bool osync_time_isdate(const char *vtime) {
+
+	int year, month, day;
+
+	if (strstr(vtime, "T"))
+		return FALSE;
+
+	/* YYYYMMDD */
+	if (sscanf(vtime, "%04d%02d%02d", &year, &month, &day) != 3)
+		return FALSE;
+
+	return TRUE;
+}
+
+/*! @brief Function returns TRUE if vtime is in UTC (YYYYMMDDTHH:MM:SSZ)
+ *
+ * @returns FALSE if vtime includes no Zulu, TRUE if the timestamp is UTC
+ */
+osync_bool osync_time_isutc(const char *vtime) {
+
+	if (!strstr(vtime, "Z"))
+		return FALSE;
+
+	return TRUE;
+}
+
+/*! @brief Function sets the time of vtime timestamp to the given time parameter
+ *
+ * If vtime only stores date (without THHMMSS[Z]) parameter time will
+ * appended. The is_utc append a Z (Zulu) for UTC if not present.
+ *
+ * Mainly used for workarounds.
+ *
+ * @param vtime The original data-timestamp which gets modified
+ * @param time The time which should be set
+ * @param is_utc If the given time is UTC is_utc have to be TRUE
+ * @returns data-timestamp in UTC if is_utc TRUE
+ */
+/*
+char *osync_time_set_vtime(const char *vtime, const char *time, osync_bool is_utc) {
+	osync_trace(TRACE_ENTRY, "%s(%s, %s)", __func__, vtime, time);
+
+	char *tmp = NULL;
+
+	// TODO
+
+	osync_trace(TRACE_EXIT, "%s: %s", __func__, tmp);
+	return tmp;
+}
+*/
+
+/*
+ * Timetype helper
+ */
+
+/*! @brief Function converts vtime to tm struct
+ *
+ * @param vtime The formatted timestamp (YYYYMMDDTHHMMSS)
+ * @returns struct tm (caller is responsible for freeing)
+ */
+struct tm *osync_time_vtime2tm(const char *vtime) {
+
+	osync_trace(TRACE_ENTRY, "%s(%s)", __func__, vtime);
+
+	struct tm *utime = g_malloc0(sizeof(struct tm));
+
+	utime->tm_year = 0;
+	utime->tm_mon = 0;
+	utime->tm_mday = 0;
+	utime->tm_hour = 0;
+	utime->tm_min = 0;
+	utime->tm_sec = 0;
+
+	sscanf(vtime, "%04d%02d%02dT%02d%02d%02d%*01c",
+			&(utime->tm_year), &(utime->tm_mon), &(utime->tm_mday),
+			&(utime->tm_hour), &(utime->tm_min), &(utime->tm_sec));
+
+	utime->tm_year -= 1900;
+	utime->tm_mon -= 1;
+
+	/* isdst is handled by tz offset calcualtion */
+	utime->tm_isdst = -1;
+
+	osync_trace(TRACE_EXIT, "%s", __func__);
+	return utime;
+}
+
+/*! @brief Function converts struct tm in vtime string
+ *
+ * YYYYMMDDTHHMMSS[Z]
+ * Returned timezone is equal to the timezone of struct tm.
+ *
+ * @param time The tm struct which gets converted
+ * @param is_utc If struct tm is UTC time is_utc have to be TRUE
+ * @returns vtime formatted as YYYYMMDDTHHMMSS[Z] (caller is responsible for freeing)
+ */
+char *osync_time_tm2vtime(const struct tm *time, osync_bool is_utc) {
+
+	osync_trace(TRACE_ENTRY, "%s(%p, %i)", __func__, time, is_utc);
+	GString *vtime = g_string_new("");
+
+	g_string_printf(vtime, "%04d%02d%02dT%02d%02d%02d",
+				time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,
+				time->tm_hour, time->tm_min, time->tm_sec);
+
+	if (is_utc)
+		vtime = g_string_append(vtime, "Z");
+
+	osync_trace(TRACE_EXIT, "%s: %s", __func__, vtime->str);
+	return g_string_free(vtime, FALSE);
+}
+
+/*! @brief Function converts vtime to unix time
+ *
+ * @param offset Seconds of UTC offset
+ * @param vtime The osync formmatted timestamp
+ * @returns Unix timestamp in time_t (UTC)
+ */
+time_t osync_time_vtime2unix(const char *vtime, int offset) {
+
+	osync_trace(TRACE_ENTRY, "%s(%s, %i)", __func__, vtime, offset);
+	struct tm *utime = NULL;
+	time_t timestamp;
+	char *utc = NULL;
+
+	utc = osync_time_vtime2utc(vtime, offset);
+	utime = osync_time_vtime2tm(utc);
+
+	timestamp = osync_time_tm2unix(utime);
+
+	g_free(utc);
+	g_free(utime);
+
+	osync_trace(TRACE_EXIT, "%s: %lu", __func__, timestamp);
+	return timestamp;
+}
+
+/*! @brief Function converts unix timestamp to vtime in UTC
+ *
+ * @param timestamp The unix timestamp which gets converted
+ * @returns vtime formatted as YYYYMMDDTHHMMSSZ (caller is responsible for freeing)
+ */
+char *osync_time_unix2vtime(const time_t *timestamp) {
+
+	osync_trace(TRACE_ENTRY, "%s(%lu)", __func__, *timestamp);
+	char *vtime;
+	struct tm utc;
+
+	/* FIXME Find conversion problem from vtime to unixtime and change then to gmtime_r().
+	   (There is a probelm when converting from vtime to unixstamp and back. The result will be a wrong offset) */
+//	gmtime_r(timestamp, &utc);
+	localtime_r(timestamp, &utc);
+	vtime = osync_time_tm2vtime(&utc, TRUE);
+
+	osync_trace(TRACE_EXIT, "%s: %s", __func__, vtime);
+	return vtime;
+}
+
+/*! @brief Function converts struct tm to unix timestamp
+ *
+ * @param tmtime The struct tm which gets converted
+ * @returns time_t (in UTC)
+ */
+time_t osync_time_tm2unix(const struct tm *tmtime) {
+
+	time_t timestamp;
+	struct tm *tmp = g_malloc0(sizeof(struct tm));
+
+	memcpy(tmp, tmtime, sizeof(struct tm));
+
+	timestamp = mktime(tmp);
+
+	g_free(tmp);
+
+	return timestamp;
+}
+
+/*! @brief Function converts unix timestamp to struct tm
+ *
+ * @param timestamp The unixtimestamp which gets converted
+ * @returns: struct tm (in UTC)
+ */
+struct tm *osync_time_unix2tm(const time_t *timestamp) {
+
+	struct tm *ptr_tm;
+	struct tm tmtime;
+
+	gmtime_r(timestamp, &tmtime);
+
+	ptr_tm = &tmtime;
+
+	return ptr_tm;
+}
+
+/*
+ * Timezone helper
+ */
+
+/*! @brief Function gets offset of parameter time between UTC and localtime in seconds.
+ *
+ * @param time is the point in time when the offset have to be calculated (need for CEST/CET)
+ * @returns Seconds of timezone offset
+ */
+int osync_time_timezone_diff(const struct tm *time) {
+	osync_trace(TRACE_ENTRY, "%s()", __func__);
+
+	struct tm ltime, utime;
+	unsigned int lsecs, usecs;
+	long zonediff;
+	time_t timestamp;
+
+	timestamp = osync_time_tm2unix(time);
+
+	tzset();
+
+	localtime_r(&timestamp, &ltime);
+	gmtime_r(&timestamp, &utime);
+
+	lsecs = 3600 * ltime.tm_hour + 60 * ltime.tm_min + ltime.tm_sec;
+	usecs = 3600 * utime.tm_hour + 60 * utime.tm_min + utime.tm_sec;
+
+	zonediff = lsecs - usecs;
+
+	/* check for different day */
+	if (utime.tm_mday != ltime.tm_mday) {
+		if (utime.tm_mday < ltime.tm_mday)
+			zonediff += 24 * 3600;
+		else
+			zonediff -= 24 * 3600;
+	}
+
+	osync_trace(TRACE_EXIT, "%s: %i", __func__, zonediff);
+	return zonediff;
+}
+
+/*! @brief Function converts (struct tm) ltime from localtime to UTC.
+ *         Paramter offset is used as UTC offset.
+ *
+ * @param ltime The struct tm which gets converted to UTC timezone
+ * @param offset Seconds of UTC offset
+ * @returns struct tm in UTC (caller is responsible for freeing)
+ */
+struct tm *osync_time_tm2utc(const struct tm *ltime, int offset) {
+
+	osync_trace(TRACE_ENTRY, "%s(%p, %i)", __func__, ltime, offset);
+	struct tm *tmtime = g_malloc0(sizeof(struct tm));
+
+	tmtime->tm_year = ltime->tm_year;
+	tmtime->tm_mon = ltime->tm_mon;
+	tmtime->tm_mday = ltime->tm_mday;
+	tmtime->tm_hour = ltime->tm_hour;
+	tmtime->tm_min = ltime->tm_min;
+	tmtime->tm_sec = ltime->tm_sec;
+
+	/* in seconds - to have a exactly timezone diff like -13.5h */
+	tmtime->tm_hour -= offset / 3600;
+	tmtime->tm_min -= (offset % 3600) / 60;
+
+	if (tmtime->tm_hour > 23 || tmtime->tm_hour < 0) {
+
+		if (tmtime->tm_hour < 0) {
+			tmtime->tm_hour += 24;
+			tmtime->tm_mday -= 1;
+		} else {
+			tmtime->tm_hour -= 24;
+			tmtime->tm_mday += 1;
+		}
+	}
+
+	osync_trace(TRACE_EXIT, "%s: %p", __func__, tmtime);
+	return tmtime;
+}
+
+/*! @brief Function converts (struct tm) utime from UTC to localtime
+ *         Parameter is used as UTC offset.
+ *
+ * @param utime The struct tm which gets converted to localtime
+ * @param offset Seconds of UTC offset
+ * @returns struct tm in localtime (caller is responsible for freeing)
+ */
+struct tm *osync_time_tm2localtime(const struct tm *utime, int offset) {
+
+	struct tm *tmtime = g_malloc0(sizeof(struct tm));
+
+	tmtime->tm_year = utime->tm_year;
+	tmtime->tm_mon = utime->tm_mon;
+	tmtime->tm_mday = utime->tm_mday;
+	tmtime->tm_hour = utime->tm_hour;
+	tmtime->tm_min = utime->tm_min;
+	tmtime->tm_sec = utime->tm_sec;
+
+	tmtime->tm_hour += offset / 3600;
+	tmtime->tm_min += (offset % 3600) / 60;
+
+	if (tmtime->tm_hour > 23 || tmtime->tm_hour < 0) {
+
+		if (tmtime->tm_hour < 0) {
+			tmtime->tm_mday -= 1;
+			tmtime->tm_hour += 24;
+		} else {
+			tmtime->tm_mday += 1;
+			tmtime->tm_hour -= 24;
+		}
+	}
+
+	return tmtime;
+}
+
+/*! @brief Functions converts a localtime vtime stamp to a UTC vtime stamp
+ *
+ * @param localtime The local timestamp in vtime format
+ * @param offset Seconds of UTC offset
+ * @returns vtime in UTC timezone (caller is responsible for freeing)
+ */
+char *osync_time_vtime2utc(const char* localtime, int offset) {
+	osync_trace(TRACE_ENTRY, "%s(%s)", __func__, localtime);
+
+	char *utc = NULL;
+	struct tm *tm_local = NULL, *tm_utc = NULL;
+
+	if (strstr(localtime, "Z")) {
+		utc = strdup(localtime);
+		goto end;
+	}
+
+	tm_local = osync_time_vtime2tm(localtime);
+	tm_utc = osync_time_tm2utc(tm_local, offset);
+	utc = osync_time_tm2vtime(tm_utc, TRUE);
+
+	g_free(tm_local);
+// FIXME is it really a memory leak?
+//	g_free(tm_utc);
+
+end:
+	osync_trace(TRACE_EXIT, "%s: %s", __func__, utc);
+	return utc;
+}
+
+/*! @brief Functions converts a UTC vtime stamp to a localtime vtime stamp
+ *
+ * @param utc The timestap in UTC timezone whic gets converted to localtime
+ * @returns vtime in local  timezon (caller is preponsible for freeing)
+ */
+char *osync_time_vtime2localtime(const char* utc, int offset) {
+
+	char *localtime = NULL;
+	struct tm *tm_local = NULL, *tm_utc = NULL;
+
+	if (!strstr(utc, "Z")) {
+		localtime = strdup(utc);
+		return localtime;
+	}
+
+	tm_utc = osync_time_vtime2tm(utc);
+	tm_local = osync_time_tm2localtime(tm_utc, offset);
+	localtime = osync_time_tm2vtime(tm_local, FALSE);
+
+	g_free(tm_local);
+	g_free(tm_utc);
+
+	return localtime;
+}
+
+
+
+/* XXX This functions should only be used as workaround for plugins which
+   only supports localtime without any timezone information. */
+
+/*! List of vcal fields which have should be converted by following
+ *  workaround functions.
+ */
+const char *_time_attr[] = {
+	"DTSTART:",
+	"DTEND:",
+	"DTSTAMP:",
+	"AALARM:",
+	"DALARM:",
+	"DUE:",
+	NULL
+};
+
+/*! @brief Functions converts a UTC vtime stamp to a localtime vtime stamp
+ *
+ * @param entry The whole vcal entry as GString which gets modified.
+ * @param field The field name which should be modified.
+ * @param toUTC The toggle in which direction we convert. TRUE = convert to UTC
+ */
+static void _convert_time_field(GString *entry, const char *field, osync_bool toUTC) {
+
+	int i, tzdiff;
+	char *res = NULL;
+	char *new_stamp = NULL;
+
+	GString *stamp = g_string_new("");
+
+	if ((res = strstr(entry->str, field))) {
+		res += strlen(field);
+
+		for (i=0; res[i] != '\n' && res[i] != '\r'; i++)
+			stamp = g_string_append_c(stamp, res[i]);
+
+		gssize pos = res - entry->str;
+		entry = g_string_erase(entry, pos, i);
+
+		// Get System offset to UTC
+		struct tm *tm_stamp = osync_time_vtime2tm(stamp->str);
+		tzdiff = osync_time_timezone_diff(tm_stamp);
+		g_free(tm_stamp);
+
+		if (toUTC)
+			new_stamp = osync_time_vtime2utc(stamp->str, tzdiff);
+		else
+			new_stamp = osync_time_vtime2localtime(stamp->str, tzdiff);
+
+		entry = g_string_insert(entry, pos, new_stamp);
+		g_free(new_stamp);
+	}
+}
+
+/*! @brief Functions converts timestamps of vcal in localtime or UTC.
+ *
+ * @param vcal The vcalendar which has to be converted.
+ * @param toUTC If TRUE conversion from localtime to UTC.
+ * @return timestamp modified vcalendar
+ */
+char *_convert_entry(const char *vcal, osync_bool toUTC) {
+
+	int i = 0;
+	GString *new_entry = g_string_new(vcal);
+
+	for (i=0; _time_attr[i] != NULL; i++)
+		_convert_time_field(new_entry, _time_attr[i], toUTC);
+
+	return g_string_free(new_entry, FALSE);
+}
+
+/*! @brief Functions converts timestamps of vcal to localtime
+ *
+ * @param vcal The vcalendar which has to be converted.
+ * @return modified vcalendar with local timestamps (related to system time)
+ */
+char *osync_time_vcal2localtime(const char *vcal) {
+
+	return _convert_entry(vcal, FALSE);
+}
+
+/*! @brief Functions converts timestamps of vcal to UTC
+ *
+ * @param vcal The vcalendar which has to be converted.
+ * @return modified vcalendar with UTC timestamps (related to system time)
+ */
+char *osync_time_vcal2utc(const char *vcal) {
+
+	return _convert_entry(vcal, TRUE);
+}
+
+/*! @brief Functions converts seconds in duration before or after alarm event
+ *
+ * @param seconds
+ * @returns ical alarm duration string (caller is preponsible for freeing)
+ */
+
+char *osync_time_sec2alarmdu(int seconds) {
+
+	osync_trace(TRACE_ENTRY, "%s(%i)", __func__, seconds);
+
+        char *tmp = NULL;
+	char *prefix = NULL;
+
+	if (!seconds) {
+		tmp = g_strdup("PT0S");
+		goto end;
+	}
+
+	if (seconds > 0) {
+		prefix = g_strdup("P");
+	} else {
+		prefix = g_strdup("-P");
+		seconds *= -1;
+	}
+
+	// Days
+        if (!(seconds % (3600 * 24))) {
+               tmp = g_strdup_printf("%s%iD", prefix, seconds / (3600 * 24));
+	       goto end;
+	}
+
+	// Hours
+        if (!(seconds % 3600)) {
+                tmp = g_strdup_printf("%sT%iH", prefix, seconds / 3600);
+		goto end;
+	}
+
+	// Minutes
+        if (!(seconds % 60) && seconds < 3600) {
+                tmp = g_strdup_printf("%sT%iM", prefix, seconds / 60);
+		goto end;
+	}
+
+	// Seconds
+	if (seconds < 60) {
+		tmp = g_strdup_printf("%sT%iS", prefix, seconds);
+		goto end;
+	}
+
+        if (seconds > 60)
+                tmp = g_strdup_printf("%sT%iM", prefix, seconds / 60);
+
+        if (seconds > 3600)
+                tmp = g_strdup_printf("%sT%iH%iM", prefix, seconds / 3600,
+                                (seconds % 3600) / 60);
+
+        if (seconds > (3600 * 24))
+               tmp = g_strdup_printf("%s%iDT%iH%iM", prefix, seconds / (3600 * 24),
+                               seconds % (3600 * 24) / 3600,
+                               ((seconds % (3600 * 24) % 3600)) / 60);
+
+end:
+	g_free(prefix);
+
+	osync_trace(TRACE_EXIT, "%s: %s", __func__, tmp);
+        return tmp;
+}
+
+/*! @brief Functions converts alarm duration event to seconds needed for reminder of vcal/ical
+ *
+ * TODO: Test support for ALARM after/before end and after start
+ *
+ * @param alarm
+ * @returns seconds of alarm and duration
+ */
+
+int osync_time_alarmdu2sec(const char *alarm) {
+
+	osync_trace(TRACE_ENTRY, "%s(%s)", __func__, alarm);
+
+        int i, secs, digits;
+        int is_digit = 0;
+	int sign = 1;	// when ical stamp doesn't start with '-' => seconds after event
+        int days = 0, weeks = 0, hours = 0, minutes = 0, seconds = 0;
+
+	        for (i=0; i < (int) strlen(alarm); i++) {
+
+                switch (alarm[i]) {
+                        case '-':
+				sign = -1; // seconds before event - change the sign
+                        case 'P':
+                        case 'T':
+                                is_digit = 0;
+                                break;
+                        case 'W':
+                                is_digit = 0;
+                                weeks = digits;
+                                break;
+                        case 'D':
+                                is_digit = 0;
+                                days = digits;
+                                break;
+                        case 'H':
+                                is_digit = 0;
+                                hours = digits;
+                                break;
+                        case 'M':
+                                is_digit = 0;
+                                minutes = digits;
+                                break;
+                        case 'S':
+                                is_digit = 0;
+                                seconds = digits;
+                                break;
+                        case '0':
+                        case '1':
+                        case '2':
+                        case '3':
+                        case '4':
+                        case '5':
+                        case '6':
+                        case '7':
+                        case '8':
+                        case '9':
+                                if (is_digit)
+                                        break;
+
+                                sscanf((char*)(alarm+i),"%d",&digits);
+                                is_digit = 1;
+                                break;
+                }
+	}
+
+        secs = (weeks * 7 * 24 * 3600) + (days * 24 * 3600) + (hours * 3600) + (minutes * 60) + seconds;
+
+	secs = secs * sign;	// change sign if the alarm is in seconds before event (leading '-')
+
+	osync_trace(TRACE_EXIT, "%s: %i", __func__, secs);
+        return secs;
+}
+
+/*
+ * Timezone ID helper
+ */
+
+/*! @brief Function converts a week day string to the struct tm wday integer.
+ *
+ * @param weekday string of the week day
+ * @returns integer of the weekday (Sunday = 0)
+ */
+int osync_time_str2wday(const char *swday) {
+
+	int weekday = -1;
+
+	if (!strcmp(swday, "SU"))
+		weekday = 0;
+	else if (!strcmp(swday, "MO"))
+		weekday = 1;
+	else if (!strcmp(swday, "TU"))
+		weekday = 2;
+	else if (!strcmp(swday, "WE"))
+		weekday = 3;
+	else if (!strcmp(swday, "TH"))
+		weekday = 4;
+	else if (!strcmp(swday, "FR"))
+		weekday = 5;
+	else if (!strcmp(swday, "SA"))
+		weekday = 6;
+
+	return weekday;
+}
+
+/*! @brief Function determines the exactly date of relative information
+ *         It is used for example to determine the last sunday of a month (-1SU)
+ *         in a specific year.
+ *
+ * @param byday string of the relative day of month modifier
+ * @param bymonth calendar number of the monath (January = 1)
+ * @param year calendar year (year = 1970)
+ * @returns struct tm of the relative information date with 00:00:00 timestamp.
+ *	    (Caller is responsible for freeing)
+ */
+struct tm *osync_time_relative2tm(const char *byday, const int bymonth, const int year) {
+
+		struct tm *datestamp = g_malloc0(sizeof(struct tm));
+		char weekday[3];
+		int first_wday = 0, last_wday = 0;
+		int daymod, mday, searched_wday;
+
+		sscanf(byday, "%d%s", &daymod, weekday);
+		weekday[2] = '\0';
+
+		searched_wday = osync_time_str2wday(weekday);
+
+		datestamp->tm_year = year - 1900;
+		datestamp->tm_mon = bymonth - 1;
+		datestamp->tm_mday = 0;
+		datestamp->tm_hour = 0;
+		datestamp->tm_min = 0;
+		datestamp->tm_sec = 0;
+		datestamp->tm_isdst = -1;
+
+		for (mday = 0; mday <= 31; mday++) {
+			datestamp->tm_mday = mday;
+			mktime(datestamp);
+
+			if (datestamp->tm_wday == searched_wday) {
+				if (!first_wday)
+					first_wday = searched_wday;
+
+				last_wday = searched_wday;
+			}
+		}
+
+		if (daymod > 0)
+			datestamp->tm_mday = first_wday + (7 * (daymod - 1));
+		else
+			datestamp->tm_mday = last_wday - (7 * (daymod - 1));
+
+		mktime(datestamp);
+
+		return datestamp;
+}
+
+/*! @brief Function converts UTC offset string in offset in seconds
+ *
+ * @param offset The offset string of the form a timezone field (Example +0200)
+ * @returns seconds of UTC offset
+ */
+int osync_time_utcoffset2sec(const char *offset) {
+	osync_trace(TRACE_ENTRY, "%s(%s)", __func__, offset);
+
+	char csign = 0;
+	int seconds = 0, sign = 1;
+	int hours = 0, minutes = 0;
+
+	sscanf(offset, "%c%2d%2d", &csign, &hours, &minutes);
+
+	if (csign == '-')
+		sign = -1;
+
+	seconds = (hours * 3600 + minutes * 60) * sign;
+
+	osync_trace(TRACE_EXIT, "%s: %i", __func__, seconds);
+	return seconds;
+}
+
+/*! @brief Functions determines the change timestamp of daylight saving of the given
+ * 	   XML Timezone from dstNode.
+ *
+ * @param dstNode daylight saving or standard XML information of a timezone.
+ * @returns struct tm of exactly date-timestamp of the change from/to daylight saving time.
+ *          (Caller is responsible for freeing!)
+ */
+struct tm *osync_time_dstchange(xmlNode *dstNode) {
+
+	int month;
+	struct tm *dst_change = NULL, *tm_started = NULL;
+	char *started = NULL, *rule = NULL, *byday = NULL;
+
+	xmlNode *current = osxml_get_node(dstNode, "DateStarted");
+	started = (char*) xmlNodeGetContent(current);
+	tm_started = osync_time_vtime2tm(started);
+
+	g_free(started);
+
+	current = osxml_get_node(dstNode, "RecurrenceRule");
+	current = current->children;
+
+	while (current) {
+		rule = (char *) xmlNodeGetContent(current);
+
+		if (strstr(rule, "BYDAY="))
+			byday = g_strdup(rule + 6);
+		else if (strstr(rule, "BYMONTH="))
+			sscanf(rule, "BYMONTH=%d", &month);
+
+		g_free(rule);
+
+		current = current->next;
+	}
+
+	dst_change = osync_time_relative2tm(byday, month, tm_started->tm_year + 1900);
+
+	g_free(byday);
+
+	dst_change->tm_hour = tm_started->tm_hour;
+	dst_change->tm_min = tm_started->tm_min;
+
+	g_free(tm_started);
+
+	return dst_change;
+}
+
+/*! @brief Functions determines if parameter vtime is Daylight Saving time in given Timezone ID (tzid)
+ *
+ * @param vtime Timestamp of time which should be determined
+ * @param tzid Timezone ID of timestamp
+ * @returns TRUE if vtime is daylight saving time of tzid
+ */
+osync_bool osync_time_isdst(const char *vtime, xmlNode *tzid) {
+
+	osync_trace(TRACE_ENTRY, "%s(%s, %p)", __func__, vtime, tzid);
+
+	int year;
+	char *newyear = NULL;
+	time_t newyear_t, timestamp;
+	struct tm *std_changetime, *dst_changetime;
+	time_t dstStamp, stdStamp;
+	xmlNode *current = NULL;
+
+	sscanf(vtime, "%4d%*2d%*2dT%*2d%*d%*2d%*c", &year);
+
+	newyear = g_strdup_printf("%4d0101T000000", year);
+	newyear_t = osync_time_vtime2unix(newyear, 0);
+	timestamp = osync_time_vtime2unix(vtime, 0);
+
+	/* Handle XML Timezone field */
+	current = osxml_get_node(tzid, "Standard");
+	std_changetime = osync_time_dstchange(current);
+
+	current = osxml_get_node(tzid, "DaylightSavings");
+	dst_changetime = osync_time_dstchange(current);
+
+	/* determine in which timezone is vtime */
+	dstStamp = osync_time_tm2unix(dst_changetime);
+	stdStamp = osync_time_tm2unix(std_changetime);
+
+	if (timestamp > stdStamp && timestamp < dstStamp) {
+		osync_trace(TRACE_EXIT, "%s: FALSE (Standard Timezone)", __func__);
+		return FALSE;
+	}
+
+	osync_trace(TRACE_EXIT, "%s: TRUE (Daylight Saving Timezone)", __func__);
+	return TRUE;
+}
+
+/*! @brief Functions returns the current UTC offset of the given vtime and interprets
+ * 	   the Timezone XML information tz.
+ *
+ * @param vtime Timestamp of given Timezone information
+ * @param tz Timezone information in XML
+ * @returns seconds seconds of current DST state and timezone
+ */
+int osync_time_tzoffset(const char *vtime, xmlNode *tz) {
+
+	osync_trace(TRACE_ENTRY, "%s(%s, %p)", __func__, vtime, tz);
+
+	int seconds;
+        char *offset = NULL;
+	xmlNode *current = NULL;
+
+	if (osync_time_isdst(vtime, tz))
+		current = osxml_get_node(tz, "DaylightSavings");
+	else
+		current = osxml_get_node(tz, "Standard");
+
+	offset = osxml_find_node(current, "TZOffsetFrom");
+	seconds = osync_time_utcoffset2sec(offset);
+
+	osync_trace(TRACE_EXIT, "%s: %i", __func__, seconds);
+	return seconds;
+}
+
+/*! @brief Functions returns the Timezone id of the Timezone information XML.
+ *
+ * @param tz Timezone information in XML
+ * @returns Timezone ID (Caller is responsible for freeing!)
+ */
+char *osync_time_tzid(xmlNode *tz) {
+	osync_trace(TRACE_ENTRY, "%s(%p)", __func__, tz);
+
+	char *id = NULL;
+
+	id = osxml_find_node(tz, "TimezoneID");
+
+	osync_trace(TRACE_EXIT, "%s: %s", __func__, id);
+	return id;
+}
+
+/*! @brief Functions returns the Timezone location of the Timezone information XML.
+ *
+ * @param tz Timezone information in XML
+ * @returns Timezone location (Caller is responsible for freeing!)
+ */
+char *osync_time_tzlocation(xmlNode *tz) {
+	osync_trace(TRACE_ENTRY, "%s(%p)", __func__, tz);
+
+	char *location = NULL;
+
+	location = osxml_find_node(tz, "TimezoneLocation");
+
+	osync_trace(TRACE_EXIT, "%s: %s", __func__, location);
+	return location;
+}
+
+/*! @brief Function search for the matching Timezode node of tzid.
+ *
+ * @param root XML of entry
+ * @param tzid The TimezoneID which should match
+ * @returns *xmlNode Node of the matching Timezone
+ */
+xmlNode *osync_time_tzinfo(xmlNode *root, const char *tzid) {
+
+	osync_trace(TRACE_ENTRY, "%s(%p, %s)", __func__, root, tzid);
+
+	int numnodes, i;
+	char *tzinfo_tzid = NULL;
+
+	xmlNode *tz = NULL;
+	xmlNodeSet *nodes = NULL;
+	xmlXPathObject *xobj = NULL;
+
+	/* search matching Timezone information */
+	xobj = osxml_get_nodeset(root->doc, "/vcal/Timezone");
+	nodes = xobj->nodesetval;
+	numnodes = (nodes) ? nodes->nodeNr : 0;
+
+	osync_trace(TRACE_INTERNAL, "Found %i Timezone field(s)", numnodes);
+
+	if (!numnodes)
+		goto noresult;
+
+
+	for (i=0; i < numnodes; i++) {
+		tz = nodes->nodeTab[i];
+		tzinfo_tzid = osync_time_tzid(tz);
+
+		if (!tzinfo_tzid) {
+			g_free(tzinfo_tzid);
+			tz = NULL;
+			continue;
+		}
+
+		if (!strcmp(tzinfo_tzid, tzid))
+			break;
+	}
+
+	g_free(tzinfo_tzid);
+
+	if (!tz)
+		goto noresult;
+
+
+	osync_trace(TRACE_EXIT, "%s: %p", __func__, tz);
+	return tz;
+
+noresult:
+	osync_trace(TRACE_EXIT, "%s: No matching Timezone node found. Seems to be a be a floating timestamp.", __func__);
+	return NULL;
+}
+
+/*! @brief Functions converts a field with localtime with timezone information to UTC timestamp.
+ *
+ * @param root XML of entry
+ * @param field Name of field node with timestamp and timezone information
+ * @returns UTC timestamp, or NULL when TZ information is missing (floating time) or field is not found
+ */
+char *osync_time_tzlocal2utc(xmlNode *root, const char *field) {
+	osync_trace(TRACE_ENTRY, "%s(%p, %s)", __func__, root, field);
+
+	int offset = 0;
+	char *utc = NULL, *field_tzid = NULL, *vtime = NULL;
+	xmlNode *tz = NULL;
+
+	/*
+	node = osxml_get_node(root, field);
+	if (!node) {
+		osync_trace(TRACE_EXIT, "%s: field \"%s\" not found", __func__, field);
+		return NULL;
+	}
+	*/
+
+	field_tzid = osync_time_tzid(root);
+	if (!field_tzid) {
+		g_free(field_tzid);
+		goto noresult;
+	}
+
+	tz = osync_time_tzinfo(root, field_tzid);
+	g_free(field_tzid);
+
+	if (!tz)
+		goto noresult;
+
+	vtime = osxml_find_node(root, "Content");
+
+	/* Handle UTC offset like 13.5h */
+	offset = osync_time_tzoffset(vtime, tz);
+	struct tm *ttm = osync_time_vtime2tm(vtime);
+	ttm->tm_hour -= offset / 3600;
+	ttm->tm_min -= (offset % 3600) / 60;
+	mktime(ttm);
+	utc = osync_time_tm2vtime(ttm, TRUE);
+
+	g_free(vtime);
+	g_free(ttm);
+
+	osync_trace(TRACE_EXIT, "%s: %s", __func__, utc);
+	return utc;
+
+noresult:
+	osync_trace(TRACE_EXIT, "%s: No matching Timezone node is found.", __func__);
+	return NULL;
+}
+


position_estimator_inav: GPS topic timeout detection fixed, messages about GPS signal state in mavlink added

--- src/modules/position_estimator_inav/position_estimator_inav_main.c
+++ src/modules/position_estimator_inav/position_estimator_inav_main.c
@@ -438,12 +438,20 @@
 			/* vehicle GPS position */
 			if (fds[6].revents & POLLIN) {
 				orb_copy(ORB_ID(vehicle_gps_position), vehicle_gps_position_sub, &gps);
-				if (gps.fix_type >= 3 && t < gps.timestamp_position + gps_timeout) {
+				if (gps.fix_type >= 3) {
 					/* hysteresis for GPS quality */
 					if (gps_valid) {
-						gps_valid = gps.eph_m < 10.0f;
+						if (gps.eph_m > 10.0f) {
+							gps_valid = false;
+							warnx("GPS signal lost");
+							mavlink_log_info(mavlink_fd, "[inav] GPS signal lost");
+						}
 					} else {
-						gps_valid = gps.eph_m < 5.0f;
+						if (gps.eph_m < 5.0f) {
+							gps_valid = true;
+							warnx("GPS signal found");
+							mavlink_log_info(mavlink_fd, "[inav] GPS signal found");
+						}
 					}
 				} else {
 					gps_valid = false;
@@ -501,7 +509,12 @@
 			}
 		}

-		/* end of poll return value check */
+		/* check for timeout on GPS topic */
+		if (gps_valid && t > gps.timestamp_position + gps_timeout) {
+			gps_valid = false;
+			warnx("GPS timeout");
+			mavlink_log_info(mavlink_fd, "[inav] GPS timeout");
+		}

 		float dt = t_prev > 0 ? (t - t_prev) / 1000000.0f : 0.0f;
 		t_prev = t;


There is no reason to use downcase letters throughout in error reason strings, it's just the default because it's usually ok.

--- crypto/rand/rand_err.c
+++ crypto/rand/rand_err.c
@@ -71,7 +71,7 @@

 static ERR_STRING_DATA RAND_str_reasons[]=
 	{
-{RAND_R_PRNG_NOT_SEEDED                  ,"prng not seeded"},
+{RAND_R_PRNG_NOT_SEEDED                  ,"PRNG not seeded"},
 {0,NULL}
 	};