Reword the comment for ConstantInt's getLimitedValue.

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

--- include/llvm/Constants.h
+++ include/llvm/Constants.h
@@ -195,9 +195,11 @@
     return Val.getActiveBits() > 64 || Val.getZExtValue() >= Num;
   }

-  /// @returns the 64-bit value of this constant if its active bits number is
-  /// not greater than 64, otherwise, just return the given uint64_t number.
-  /// @brief Get the constant's value if possible.
+  /// getLimitedValue - If the value is smaller than the specified limit,
+  /// return it, otherwise return the limit value.  This causes the value
+  /// to saturate to the limit.
+  /// @returns the min of the value of the constant and the specified value
+  /// @brief Get the constant's value with a saturation limit
   uint64_t getLimitedValue(uint64_t Limit = ~0ULL) const {
     return Val.getLimitedValue(Limit);
   }


SSL asynchronous signature: turn off by default

--- include/mbedtls/config.h
+++ include/mbedtls/config.h
@@ -2342,7 +2342,7 @@
  * operation inside the library.
  *
  */
-#define MBEDTLS_SSL_ASYNC_PRIVATE_C
+//#define MBEDTLS_SSL_ASYNC_PRIVATE_C

 /**
  * \def MBEDTLS_SSL_CACHE_C


gcc 4.7 fix for unfound method

gcc 4.7 fix for unfound method

--- utils/lightweight_hash.h
+++ utils/lightweight_hash.h
@@ -345,7 +345,7 @@
             Ops::initEmptyBucket(storage_ + i);

         for (; first != last;  ++first)
-            find_or_insert(*first);
+            this->find_or_insert(*first);
     }

     Lightweight_Hash_Base(const Lightweight_Hash_Base & other,
@@ -821,7 +821,7 @@

     Value & operator [] (const Key & key)
     {
-        int bucket = find_or_insert(Bucket(key, Value())).first;
+        int bucket = this->find_or_insert(Bucket(key, Value())).first;
         assert(this->storage_[bucket].first == key);
         return this->storage_[bucket].second;
     }
@@ -829,7 +829,7 @@
     std::pair<iterator, bool>
     insert(const Bucket & val)
     {
-        std::pair<int, bool> r = find_or_insert(val);
+        std::pair<int, bool> r = this->find_or_insert(val);
         return make_pair(iterator(this, r.first), r.second);
     }


Update vapoursynth.h

Update vapoursynth.h

--- src/common/VapourSynth.h
+++ src/common/VapourSynth.h
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2012 Fredrik Mellbin
+* Copyright (c) 2012-2014 Fredrik Mellbin
 *
 * This file is part of VapourSynth.
 *
@@ -23,34 +23,36 @@

 #include <stdint.h>

-#define VAPOURSYNTH_API_VERSION 3
-
-// Convenience for C++ users.
+#define VAPOURSYNTH_API_MAJOR 3
+#define VAPOURSYNTH_API_MINOR 1
+#define VAPOURSYNTH_API_VERSION ((VAPOURSYNTH_API_MAJOR << 16) | (VAPOURSYNTH_API_MINOR))
+
+/* Convenience for C++ users. */
 #ifdef __cplusplus
-#	define VS_EXTERN_C extern "C"
+#    define VS_EXTERN_C extern "C"
 #else
-#	define VS_EXTERN_C
+#    define VS_EXTERN_C
 #endif

-#ifdef _WIN32
-#	define VS_CC __stdcall
+#if defined(_WIN32) && !defined(_WIN64)
+#    define VS_CC __stdcall
 #else
-#	define VS_CC
+#    define VS_CC
 #endif

-// And now for some symbol hide-and-seek...
-#if defined(_WIN32) // Windows being special
-#	define VS_EXTERNAL_API(ret) VS_EXTERN_C __declspec(dllexport) ret VS_CC
+/* And now for some symbol hide-and-seek... */
+#if defined(_WIN32) /* Windows being special */
+#    define VS_EXTERNAL_API(ret) VS_EXTERN_C __declspec(dllexport) ret VS_CC
 #elif defined(__GNUC__) && __GNUC__ >= 4
-#	define VS_EXTERNAL_API(ret) VS_EXTERN_C __attribute__((visibility("default"))) ret VS_CC
+#    define VS_EXTERNAL_API(ret) VS_EXTERN_C __attribute__((visibility("default"))) ret VS_CC
 #else
-#	define VS_EXTERNAL_API(ret) VS_EXTERN_C ret VS_CC
+#    define VS_EXTERNAL_API(ret) VS_EXTERN_C ret VS_CC
 #endif

-#if !defined(VSCORE_EXPORTS) && defined(_WIN32)
-#	define VS_API(ret) VS_EXTERN_C __declspec(dllimport) ret VS_CC
+#if !defined(VS_CORE_EXPORTS) && defined(_WIN32)
+#    define VS_API(ret) VS_EXTERN_C __declspec(dllimport) ret VS_CC
 #else
-#	define VS_API(ret) VS_EXTERNAL_API(ret)
+#    define VS_API(ret) VS_EXTERNAL_API(ret)
 #endif

 typedef struct VSFrameRef VSFrameRef;
@@ -64,12 +66,12 @@
 typedef struct VSFrameContext VSFrameContext;

 typedef enum VSColorFamily {
-    // all planar formats
+    /* all planar formats */
     cmGray   = 1000000,
     cmRGB    = 2000000,
     cmYUV    = 3000000,
     cmYCoCg  = 4000000,
-    // special for compatibility
+    /* special for compatibility */
     cmCompat = 9000000
 } VSColorFamily;

@@ -78,7 +80,7 @@
     stFloat = 1
 } VSSampleType;

-// The +10 is so people won't be using the constants interchangably "by accident"
+/* The +10 is so people won't be using the constants interchangably "by accident" */
 typedef enum VSPresetFormat {
     pfNone = 0,

@@ -118,48 +120,59 @@
     pfRGBH,
     pfRGBS,

-    // special for compatibility, if you implement these in any filter I'll personally kill you
-    // I'll also change their ids around to break your stuff regularly
+    /* special for compatibility, if you implement these in any filter I'll personally kill you */
+    /* I'll also change their ids around to break your stuff regularly */
     pfCompatBGR32 = cmCompat + 10,
     pfCompatYUY2
 } VSPresetFormat;

 typedef enum VSFilterMode {
-    fmParallel = 100, // completely parallel execution
-    fmParallelRequests = 200, // for filters that are serial in nature but can request one or more frames they need in advance
-    fmUnordered = 300, // for filters that modify their internal state every request
-    fmSerial = 400 // for source filters and compatibility with other filtering architectures
+    fmParallel = 100, /* completely parallel execution */
+    fmParallelRequests = 200, /* for filters that are serial in nature but can request one or more frames they need in advance */
+    fmUnordered = 300, /* for filters that modify their internal state every request */
+    fmSerial = 400 /* for source filters and compatibility with other filtering architectures */
 } VSFilterMode;

 typedef struct VSFormat {
     char name[32];
     int id;
-    int colorFamily; // see VSColorFamily
-    int sampleType; // see VSSampleType
-    int bitsPerSample; // number of significant bits
-    int bytesPerSample; // actual storage is always in a power of 2 and the smallest possible that can fit the number of bits used per sample
-
-    int subSamplingW; // log2 subsampling factor, applied to second and third plane
+    int colorFamily; /* see VSColorFamily */
+    int sampleType; /* see VSSampleType */
+    int bitsPerSample; /* number of significant bits */
+    int bytesPerSample; /* actual storage is always in a power of 2 and the smallest possible that can fit the number of bits used per sample */
+
+    int subSamplingW; /* log2 subsampling factor, applied to second and third plane */
     int subSamplingH;

-    int numPlanes; // implicit from colorFamily
+    int numPlanes; /* implicit from colorFamily */
 } VSFormat;

-typedef enum NodeFlags {
+typedef enum VSNodeFlags {
     nfNoCache = 1,
-} NodeFlags;
-
-typedef enum GetPropErrors {
+    nfIsCache = 2
+} VSNodeFlags;
+
+typedef enum VSPropTypes {
+    ptUnset = 'u',
+    ptInt = 'i',
+    ptFloat = 'f',
+    ptData = 's',
+    ptNode = 'c',
+    ptFrame = 'v',
+    ptFunction = 'm'
+} VSPropTypes;
+
+typedef enum VSGetPropErrors {
     peUnset = 1,
     peType  = 2,
     peIndex = 4
-} GetPropErrors;
-
-typedef enum PropAppendMode {
+} VSGetPropErrors;
+
+typedef enum VSPropAppendMode {
     paReplace = 0,
     paAppend  = 1,
     paTouch   = 2
-} PropAppendMode;
+} VSPropAppendMode;

 typedef struct VSCoreInfo {
     const char *versionString;
@@ -180,19 +193,27 @@
     int flags;
 } VSVideoInfo;

-typedef enum ActivationReason {
+typedef enum VSActivationReason {
     arInitial = 0,
     arFrameReady = 1,
     arAllFramesReady = 2,
     arError = -1
-} ActivationReason;
-
-// core function typedefs
-typedef	VSCore *(VS_CC *VSCreateCore)(int threads);
-typedef	void (VS_CC *VSFreeCore)(VSCore *core);
+} VSActivationReason;
+
+typedef enum VSMessageType {
+    mtDebug = 0,
+    mtWarning = 1,
+    mtCritical = 2,
+    mtFatal = 3
+} VSMessageType;
+
+/* core function typedefs */
+typedef const VSAPI *(VS_CC *VSGetVapourSynthAPI)(int version);
+typedef VSCore *(VS_CC *VSCreateCore)(int threads);
+typedef void (VS_CC *VSFreeCore)(VSCore *core);
 typedef const VSCoreInfo *(VS_CC *VSGetCoreInfo)(VSCore *core);

-// function/filter typedefs
+/* function/filter typedefs */
 typedef void (VS_CC *VSPublicFunction)(const VSMap *in, VSMap *out, void *userData, VSCore *core, const VSAPI *vsapi);
 typedef void (VS_CC *VSFreeFuncData)(void *userData);
 typedef void (VS_CC *VSFilterInit)(VSMap *in, VSMap *out, void **instanceData, VSNode *node, VSCore *core, const VSAPI *vsapi);
@@ -209,7 +230,7 @@
 typedef const VSFormat *(VS_CC *VSGetFormatPreset)(int id, VSCore *core);
 typedef const VSFormat *(VS_CC *VSRegisterFormat)(int colorFamily, int sampleType, int bitsPerSample, int subSamplingW, int subSamplingH, VSCore *core);

-// frame and clip handling
+/* frame and clip handling */
 typedef void (VS_CC *VSFrameDoneCallback)(void *userData, const VSFrameRef *f, int n, VSNodeRef *, const char *errorMsg);
 typedef void (VS_CC *VSGetFrameAsync)(int n, VSNodeRef *node, VSFrameDoneCallback callback, void *userData);
 typedef const VSFrameRef *(VS_CC *VSGetFrame)(int n, VSNodeRef *node, char *errorMsg, int bufSize);
@@ -229,7 +250,7 @@
 typedef const uint8_t *(VS_CC *VSGetReadPtr)(const VSFrameRef *f, int plane);
 typedef uint8_t *(VS_CC *VSGetWritePtr)(VSFrameRef *f, int plane);

-// property access
+/* property access */
 typedef const VSVideoInfo *(VS_CC *VSGetVideoInfo)(VSNodeRef *node);
 typedef void (VS_CC *VSSetVideoInfo)(const VSVideoInfo *vi, int numOutputs, VSNode *node);
 typedef const VSFormat *(VS_CC *VSGetFrameFormat)(const VSFrameRef *f);
@@ -242,7 +263,7 @@
 typedef int (VS_CC *VSPropNumElements)(const VSMap *map, const char *key);
 typedef char(VS_CC *VSPropGetType)(const VSMap *map, const char *key);

-typedef VSMap *(VS_CC *VSNewMap)(void);
+typedef VSMap *(VS_CC *VSCreateMap)(void);
 typedef void (VS_CC *VSFreeMap)(VSMap *map);
 typedef void (VS_CC *VSClearMap)(VSMap *map);

@@ -262,24 +283,35 @@
 typedef int (VS_CC *VSPropSetFrame)(VSMap *map, const char *key, const VSFrameRef *f, int append);
 typedef int (VS_CC *VSPropSetFunc)(VSMap *map, const char *key, VSFuncRef *func, int append);

-// mixed
-
+/* mixed */
 typedef void (VS_CC *VSConfigPlugin)(const char *identifier, const char *defaultNamespace, const char *name, int apiVersion, int readonly, VSPlugin *plugin);
 typedef void (VS_CC *VSInitPlugin)(VSConfigPlugin configFunc, VSRegisterFunction registerFunc, VSPlugin *plugin);

-typedef VSPlugin *(VS_CC *VSGetPluginId)(const char *identifier, VSCore *core);
-typedef VSPlugin *(VS_CC *VSGetPluginNs)(const char *ns, VSCore *core);
+typedef VSPlugin *(VS_CC *VSGetPluginById)(const char *identifier, VSCore *core);
+typedef VSPlugin *(VS_CC *VSGetPluginByNs)(const char *ns, VSCore *core);

 typedef VSMap *(VS_CC *VSGetPlugins)(VSCore *core);
 typedef VSMap *(VS_CC *VSGetFunctions)(VSPlugin *plugin);

-typedef void (VS_CC *VSCallFunc)(VSFuncRef *func, const VSMap *in, VSMap *out, VSCore *core, const VSAPI *vsapi);
-typedef VSFuncRef *(VS_CC *VSCreateFunc)(VSPublicFunction func, void *userData, VSFreeFuncData free);
+typedef void (VS_CC *VSCallFunc)(VSFuncRef *func, const VSMap *in, VSMap *out, VSCore *core, const VSAPI *vsapi); /* core and vsapi arguments are completely ignored, they only remain to preserve ABI */
+typedef VSFuncRef *(VS_CC *VSCreateFunc)(VSPublicFunction func, void *userData, VSFreeFuncData free, VSCore *core, const VSAPI *vsapi);

 typedef void (VS_CC *VSQueryCompletedFrame)(VSNodeRef **node, int *n, VSFrameContext *frameCtx);
 typedef void (VS_CC *VSReleaseFrameEarly)(VSNodeRef *node, int n, VSFrameContext *frameCtx);

 typedef int64_t (VS_CC *VSSetMaxCacheSize)(int64_t bytes, VSCore *core);
+typedef int (VS_CC *VSSetThreadCount)(int threads, VSCore *core);
+
+typedef void (VS_CC *VSMessageHandler)(int msgType, const char *msg, void *userData);
+typedef void (VS_CC *VSSetMessageHandler)(VSMessageHandler handler, void *userData);
+
+typedef const char *(VS_CC *VSGetPluginPath)(const VSPlugin *plugin);
+
+typedef const int64_t *(VS_CC *VSPropGetIntArray)(const VSMap *map, const char *key, int *error);
+typedef const double *(VS_CC *VSPropGetFloatArray)(const VSMap *map, const char *key, int *error);
+
+typedef int (VS_CC *VSPropSetIntArray)(VSMap *map, const char *key, const int64_t *i, int size);
+typedef int (VS_CC *VSPropSetFloatArray)(VSMap *map, const char *key, const double *d, int size);

 struct VSAPI {
@@ -300,25 +332,25 @@
     VSCopyFrameProps copyFrameProps;

     VSRegisterFunction registerFunction;
-    VSGetPluginId getPluginId;
-    VSGetPluginNs getPluginNs;
+    VSGetPluginById getPluginById;
+    VSGetPluginByNs getPluginByNs;
     VSGetPlugins getPlugins;
     VSGetFunctions getFunctions;
-    VSCreateFilter createFilter; // do never use inside a filter's getframe function
-    VSSetError setError; // use to signal errors outside filter getframe functions
-    VSGetError getError; // use to query errors, returns 0 if no error
-    VSSetFilterError setFilterError; // use to signal errors in the filter getframe function
-    VSInvoke invoke; // may not be used inside a filter's getframe method
-
-    VSGetFormatPreset getFormatPreset; //threadsafe
-    VSRegisterFormat registerFormat; // threadsafe
-
-    VSGetFrame getFrame; // do never use inside a filter's getframe function, for external applications using the core as a library or for requesting frames in a filter constructor
-    VSGetFrameAsync getFrameAsync; // do never use inside a filter's getframe function, for external applications using the core as a library or for requesting frames in a filter constructor
-    VSGetFrameFilter getFrameFilter; // only use inside a filter's getframe function
-    VSRequestFrameFilter requestFrameFilter; // only use inside a filter's getframe function
-    VSQueryCompletedFrame queryCompletedFrame; // only use inside a filter's getframe function
-    VSReleaseFrameEarly releaseFrameEarly; // only use inside a filter's getframe function
+    VSCreateFilter createFilter;
+    VSSetError setError; /* use to signal errors outside filter getframe functions */
+    VSGetError getError; /* use to query errors, returns 0 if no error */
+    VSSetFilterError setFilterError; /* use to signal errors in the filter getframe function */
+    VSInvoke invoke;
+
+    VSGetFormatPreset getFormatPreset;
+    VSRegisterFormat registerFormat;
+
+    VSGetFrame getFrame; /* do never use inside a filter's getframe function, for external applications using the core as a library or for requesting frames in a filter constructor */
+    VSGetFrameAsync getFrameAsync; /* do never use inside a filter's getframe function, for external applications using the core as a library or for requesting frames in a filter constructor */
+    VSGetFrameFilter getFrameFilter; /* only use inside a filter's getframe function */
+    VSRequestFrameFilter requestFrameFilter; /* only use inside a filter's getframe function */
+    VSQueryCompletedFrame queryCompletedFrame; /* only use inside a filter's getframe function */
+    VSReleaseFrameEarly releaseFrameEarly; /* only use inside a filter's getframe function */

     VSGetStride getStride;
     VSGetReadPtr getReadPtr;
@@ -327,8 +359,8 @@
     VSCreateFunc createFunc;
     VSCallFunc callFunc;

-    //property access functions
-    VSNewMap newMap;
+    /* property access functions */
+    VSCreateMap createMap;
     VSFreeMap freeMap;
     VSClearMap clearMap;

@@ -363,8 +395,19 @@
     VSSetMaxCacheSize setMaxCacheSize;
     VSGetOutputIndex getOutputIndex;
     VSNewVideoFrame2 newVideoFrame2;
+
+    VSSetMessageHandler setMessageHandler;
+    VSSetThreadCount setThreadCount;
+
+    VSGetPluginPath getPluginPath;
+
+    VSPropGetIntArray propGetIntArray;
+    VSPropGetFloatArray propGetFloatArray;
+
+    VSPropSetIntArray propSetIntArray;
+    VSPropSetFloatArray propSetFloatArray;
 };

 VS_API(const VSAPI *) getVapourSynthAPI(int version);

-#endif // VAPOURSYNTH_H
+#endif /* VAPOURSYNTH_H */


mdbox: Fixed assert-crashing in storage rebuild.

--HG--
branch : HEAD

--- src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
+++ src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
@@ -458,10 +458,10 @@
 	enum mail_error error;
 	int ret;

-	box = mdbox_mailbox_alloc(&ctx->storage->storage.storage,
-				  ns->list, name, MAILBOX_FLAG_READONLY |
-				  MAILBOX_FLAG_KEEP_RECENT |
-				  MAILBOX_FLAG_IGNORE_ACLS);
+	box = mailbox_alloc(ns->list, name, MAILBOX_FLAG_READONLY |
+			    MAILBOX_FLAG_KEEP_RECENT |
+			    MAILBOX_FLAG_IGNORE_ACLS);
+	i_assert(box->storage == &ctx->storage->storage.storage);
 	if (dbox_mailbox_open(box) < 0) {
 		(void)mail_storage_get_last_error(box->storage, &error);
 		mailbox_free(&box);
@@ -595,10 +595,11 @@
 		strcmp(mailbox, ctx->prev_msg.box->name) == 0 ?
 		ctx->prev_msg.box : NULL;
 	while (box == NULL) {
-		box = mdbox_mailbox_alloc(storage, ctx->default_list,
-					  mailbox, MAILBOX_FLAG_READONLY |
-					  MAILBOX_FLAG_KEEP_RECENT |
-					  MAILBOX_FLAG_IGNORE_ACLS);
+		box = mailbox_alloc(ctx->default_list, mailbox,
+				    MAILBOX_FLAG_READONLY |
+				    MAILBOX_FLAG_KEEP_RECENT |
+				    MAILBOX_FLAG_IGNORE_ACLS);
+		i_assert(box->storage == storage);
 		if (dbox_mailbox_open(box) == 0)
 			break;


mdbox: Avoid deferencing NULL pointer in specific corrupted mailboxes.

--- src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
+++ src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
@@ -356,7 +356,6 @@
 		      struct mail_index_view *view,
 		      struct mail_index_transaction *trans)
 {
-	const struct mdbox_mail_index_record *dbox_rec;
 	struct mdbox_mail_index_record new_dbox_rec;
 	const struct mail_index_header *hdr;
 	struct mdbox_rebuild_msg *rec;
@@ -368,9 +367,13 @@
 	for (seq = 1; seq <= hdr->messages_count; seq++) {
 		mail_index_lookup_ext(view, seq, mbox->ext_id,
 				      &data, &expunged);
-		dbox_rec = data;
-		new_dbox_rec = *dbox_rec;
-		map_uid = dbox_rec == NULL ? 0 : dbox_rec->map_uid;
+		if (data == NULL) {
+			memset(&new_dbox_rec, 0, sizeof(new_dbox_rec));
+			map_uid = 0;
+		} else {
+			memcpy(&new_dbox_rec, data, sizeof(new_dbox_rec));
+			map_uid = new_dbox_rec.map_uid;
+		}

 		mail_index_lookup_ext(view, seq, mbox->guid_ext_id,
 				      &data, &expunged);


mdbox: Resize mdbox index header if necessary also when rebuilding indexes.

--- src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
+++ src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
@@ -479,7 +479,7 @@

 static void
 mdbox_rebuild_get_header(struct mail_index_view *view, uint32_t hdr_ext_id,
-			 struct mdbox_index_header *hdr_r)
+			 struct mdbox_index_header *hdr_r, bool *need_resize_r)
 {
 	const void *data;
 	size_t data_size;
@@ -487,6 +487,7 @@
 	mail_index_get_header_ext(view, hdr_ext_id, &data, &data_size);
 	memset(hdr_r, 0, sizeof(*hdr_r));
 	memcpy(hdr_r, data, I_MIN(data_size, sizeof(*hdr_r)));
+	*need_resize_r = data_size < sizeof(*hdr_r);
 }

 static void mdbox_header_update(struct mdbox_storage_rebuild_context *ctx,
@@ -494,13 +495,17 @@
 				struct mdbox_mailbox *mbox)
 {
 	struct mdbox_index_header hdr, backup_hdr;
-
-	mdbox_rebuild_get_header(rebuild_ctx->view, mbox->hdr_ext_id, &hdr);
-	if (rebuild_ctx->backup_view == NULL)
+	bool need_resize, need_resize_backup;
+
+	mdbox_rebuild_get_header(rebuild_ctx->view, mbox->hdr_ext_id,
+				 &hdr, &need_resize);
+	if (rebuild_ctx->backup_view == NULL) {
 		memset(&backup_hdr, 0, sizeof(backup_hdr));
-	else {
+		need_resize = TRUE;
+	} else {
 		mdbox_rebuild_get_header(rebuild_ctx->backup_view,
-					 mbox->hdr_ext_id, &backup_hdr);
+					 mbox->hdr_ext_id, &backup_hdr,
+					 &need_resize_backup);
 	}

 	/* make sure we have valid mailbox guid */
@@ -522,6 +527,10 @@
 		hdr.flags |= DBOX_INDEX_HEADER_FLAG_HAVE_POP3_ORDERS;

 	/* and write changes */
+	if (need_resize) {
+		mail_index_ext_resize_hdr(rebuild_ctx->trans, mbox->hdr_ext_id,
+					  sizeof(hdr));
+	}
 	mail_index_update_header_ext(rebuild_ctx->trans, mbox->hdr_ext_id, 0,
 				     &hdr, sizeof(hdr));
 }


cruft removal

cruft removal

--- platforms/unix/vm-display-fbdev/sqUnixFBDevFramebuffer.c
+++ platforms/unix/vm-display-fbdev/sqUnixFBDevFramebuffer.c
@@ -113,19 +113,9 @@
 static inline int fb_height(_self)	{ return self->var.yres; }
 static inline int fb_depth(_self)	{ return self->var.bits_per_pixel; }

-static inline int fb_red_offset(_self)	{ return self->var.red.offset; }
-static inline int fb_green_offset(_self) { return self->var.green.offset; }
-static inline int fb_blue_offset(_self)	{ return self->var.blue.offset; }
-
 static inline unsigned long fb_pixel_position(_self, int x, int y) {
   return (x + self->var.xoffset) * (self->var.bits_per_pixel / 8)
       +  (y + self->var.yoffset) * self->fix.line_length ;
-}
-
-static inline unsigned long fb_pixel_color(_self, int red, int green, int blue) {
-  return (red   << fb_red_offset(self))
-       | (green << fb_green_offset(self))
-       | (blue  << fb_blue_offset(self)) ;
 }

 static inline unsigned long fb_getPixel_32(_self, int x, int y)
@@ -635,8 +625,6 @@
       /* extract RGB values from Balloon data */
       BALLOON_PIXEL( data, pixel );
       /* above side effect: data += balloon_bytes_per_pixel */
-      /*      myPixel = fb_pixel_color(self, pixel[0], pixel[1], pixel[2]);
-	      self->putPixel(self, left + x, top + y, myPixel); */
       self->drawPixel(self, left + x, top + y, pixel[0], pixel[1], pixel[2]);
     }
   }


Fixed an issue where an aggregate with millions of
child buckets gets very slow.

* buckets/aggregate_buckets.c
  (aggregate_context_t): Keep a pointer to last bucket in
   the list.
  (serf_bucket_aggregate_become,
   serf_aggregate_restore_snapshot): Initiate 'last' ptr.
  (serf_bucket_aggregate_append): Use the 'last' ptr to
   append at the end of the list,

--- buckets/aggregate_buckets.c
+++ buckets/aggregate_buckets.c
@@ -25,6 +25,7 @@

 typedef struct {
     bucket_list_t *list; /* active buckets */
+    bucket_list_t *last; /* last bucket of the list */
     bucket_list_t *done; /* we finished reading this; now pending a destroy */

     /* Marks if a snapshot is set. */
@@ -94,6 +95,7 @@

     ctx = serf_bucket_mem_alloc(bucket->allocator, sizeof(*ctx));
     ctx->list = NULL;
+    ctx->last = NULL;
     ctx->done = NULL;
     ctx->snapshot = 0;
     ctx->hold_open = NULL;
@@ -139,13 +141,11 @@
     */
     if (ctx->list == NULL) {
         ctx->list = new_list;
+	ctx->last = new_list;
     }
     else {
-        bucket_list_t *scan = ctx->list;
-
-        while (scan->next != NULL)
-            scan = scan->next;
-        scan->next = new_list;
+        ctx->last->next = new_list;
+	ctx->last = ctx->last->next;
     }
 }

@@ -394,6 +394,9 @@
     apr_status_t status;

     /* Move all the DONE buckets back in the LIST. */
+    if (! ctx->last && ! ctx->list)
+        ctx->last = ctx->done;
+
     while (ctx->done) {
         next_ctx = ctx->done->next;
         ctx->done->next = ctx->list;


Bug #632692 - Thread by In-Reply-To, then first found reference

--- camel/camel-folder-thread.c
+++ camel/camel-folder-thread.c
@@ -478,6 +478,8 @@

 			d(printf("%s (%s) references:\n", G_STRLOC, G_STRFUNC); )
 			for (j=0;j<references->size;j++) {
+				gboolean found = FALSE;
+
 				/* should never be empty, but just incase */
 				if (references->references[j].id.id == 0)
 					continue;
@@ -487,9 +489,16 @@
 					d(printf("%s (%s) not found\n", G_STRLOC, G_STRFUNC));
 					c = e_memchunk_alloc0 (thread->node_chunks);
 					g_hash_table_insert (id_table, (gpointer)&references->references[j], c);
+				} else
+					found = TRUE;
+				if (c != child) {
+					container_parent_child (c, child);
+					/* Stop on the first parent found, no need to reparent
+					   it once it's placed in. Also, references are from
+					   parent to root, thus this should do the right thing. */
+					if (found)
+						break;
 				}
-				if (c!=child)
-					container_parent_child (c, child);
 				child = c;
 			}
 		}


Have test send AC_INET_SEND_ARP command.

Change the msg to m so we don't hide the msg parameter
Fix the proto_addr_len
Send m to target_comp

--- platform/Posix/components/ac_inet_link/tests/srcs/test.c
+++ platform/Posix/components/ac_inet_link/tests/srcs/test.c
@@ -126,15 +126,16 @@
     case SEND_ARP_REQ: {
       ac_printf(LDR "SEND_ARP_REQ\n", ldr);

-      AcMsg* msg = AcMsgPool_get_msg(&this->mp);
-      msg->op = AC_INET_SEND_ARP_CMD;
-      AcInetSendArpExtra* send_arp_extra = (AcInetSendArpExtra*)msg->extra;
+      AcMsg* m = AcMsgPool_get_msg(&this->mp);
+      m->op = AC_INET_SEND_ARP_CMD;
+      AcInetSendArpExtra* send_arp_extra = (AcInetSendArpExtra*)m->extra;
       send_arp_extra->proto = AC_ETHER_PROTO_ARP;
-      send_arp_extra->proto_addr_len = AC_ETHER_ADDR_LEN;
+      send_arp_extra->proto_addr_len = AC_IPV4_ADDR_LEN;
       send_arp_extra->proto_addr[0] = 192;
       send_arp_extra->proto_addr[1] = 168;
       send_arp_extra->proto_addr[2] = 0;
       send_arp_extra->proto_addr[3] = 2;
+      AcCompMgr_send_msg(this->target_comp, m);

       //  delay a second to let it complete for the moment
       ac_printf(LDR "SEND_ARP_REQ; waiting\n", ldr);


pcm038: add driver for static ram

pcm038: add driver for static ram

The pcm038 module (phyCORE-i.MX27) comes with a 512 KiB static RAM which
can be battery buffered. Add mtd_ram support and configure the chip select
line, to which the sram is attached.

Signed-off-by: Luotao Fu <85ed96e8394e24a331a1a2a9131a782ad665de22@pengutronix.de>
Signed-off-by: Sascha Hauer <c00cbc2b736c26791a3822db86f8796fe9efff67@pengutronix.de>

--- arch/arm/mach-mx2/pcm038.c
+++ arch/arm/mach-mx2/pcm038.c
@@ -19,6 +19,7 @@

 #include <linux/platform_device.h>
 #include <linux/mtd/physmap.h>
+#include <linux/mtd/plat-ram.h>
 #include <asm/mach/arch.h>
 #include <asm/mach-types.h>
 #include <mach/common.h>
@@ -29,6 +30,31 @@
 #include <mach/board-pcm038.h>

 #include "devices.h"
+
+/*
+ * Phytec's PCM038 comes with 2MiB battery buffered SRAM,
+ * 16 bit width
+ */
+
+static struct platdata_mtd_ram pcm038_sram_data = {
+	.bankwidth = 2,
+};
+
+static struct resource pcm038_sram_resource = {
+	.start = CS1_BASE_ADDR,
+	.end   = CS1_BASE_ADDR + 512 * 1024 - 1,
+	.flags = IORESOURCE_MEM,
+};
+
+static struct platform_device pcm038_sram_mtd_device = {
+	.name = "mtd-ram",
+	.id = 0,
+	.dev = {
+		.platform_data = &pcm038_sram_data,
+	},
+	.num_resources = 1,
+	.resource = &pcm038_sram_resource,
+};

 /*
  * Phytec's phyCORE-i.MX27 comes with 32MiB flash,
@@ -164,11 +190,22 @@
 static struct platform_device *platform_devices[] __initdata = {
 	&pcm038_nor_mtd_device,
 	&mxc_w1_master_device,
-};
+	&pcm038_sram_mtd_device,
+};
+
+/* On pcm038 there's a sram attached to CS1, we enable the chipselect here and
+ * setup other stuffs to access the sram. */
+static void __init pcm038_init_sram(void)
+{
+	__raw_writel(0x0000d843, CSCR_U(1));
+	__raw_writel(0x22252521, CSCR_L(1));
+	__raw_writel(0x22220a00, CSCR_A(1));
+}

 static void __init pcm038_init(void)
 {
 	gpio_fec_active();
+	pcm038_init_sram();

 	mxc_register_device(&mxc_uart_device0, &uart_pdata[0]);
 	mxc_register_device(&mxc_uart_device1, &uart_pdata[1]);


disable olympus-wrap until done

disable olympus-wrap until done

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

--- camlibs/ptp2/olympus-wrap.c
+++ camlibs/ptp2/olympus-wrap.c
@@ -36,6 +36,8 @@
  */

 #include "config.h"
+
+#if 0

 #include <string.h>
 #include <stdlib.h>
@@ -2562,3 +2564,4 @@
 </x3c>
 */

+#endif


move streambuf to temporary file

move streambuf to temporary file

--- src/common/file_stream.h
+++ src/common/file_stream.h
@@ -26,6 +26,11 @@
   int fd_;
   bool unlink_;
   std::string name_;
+
+#ifndef _WIN32
+  std::unique_ptr<__gnu_cxx::stdio_filebuf<char>> buf_;
+#endif
+

   int mkstemp_and_unlink(char* tmpl) {
 #ifdef _WIN32
@@ -74,6 +79,10 @@
     std::string baseTemp(base);
     NormalizeTempPrefix(baseTemp);
     fd_ = MakeTemp(baseTemp);
+
+#ifndef _WIN32
+    buf_.reset(new __gnu_cxx::stdio_filebuf<char>(fd_, std::ios::in|std::ios::out));
+#endif
   }

   ~TemporaryFile() {
@@ -81,12 +90,17 @@
       ABORT_IF(unlink(name_.c_str()), "Error while deleting '{}'", name_);
     }
     if(fd_ != -1 && close(fd_)) {
-      std::cerr << "Could not close file " << fd_ << std::endl;
-      std::abort();
+      ABORT("Could not close file {}", fd_ );
     }
   }

+  void seek(size_t pos) {
+    lseek(fd_, pos, SEEK_SET);
+  }
+
   int getFileDescriptor() { return fd_; }
+
+  std::streambuf* rdbuf() { buf_.get(); }

   std::string getFileName() { return name_; }
 };
@@ -96,27 +110,20 @@
   std::unique_ptr<std::istream> istream_;
   marian::filesystem::Path file_;

-#ifndef _WIN32
-    std::unique_ptr<__gnu_cxx::stdio_filebuf<char>> filebuf_;
-#endif
-
 public:
   InputFileStream(const std::string& file)
   : file_(file) {
     ABORT_IF(!marian::filesystem::exists(file_),"File '{}' does not exist", file);
-    istream_.reset(new zstr::ifstream(file_));
+
+    if(file_.extension() == marian::filesystem::Path(std::string(".gz")))
+      istream_.reset(new zstr::ifstream(file_));
+    else
+      istream_.reset(new std::ifstream(file_));
   }

   InputFileStream(TemporaryFile& tempfile) {
-    lseek(tempfile.getFileDescriptor(), 0, SEEK_SET);
-
-  // @TODO: this is non-standard, add more alternatives
-  // this SO answer describes a number of alternatives for different compilers, checking g++ for now.
-  // https://stackoverflow.com/questions/2746168/how-to-construct-a-c-fstream-from-a-posix-file-descriptor
-  #ifndef _WIN32
-    filebuf_.reset(new __gnu_cxx::stdio_filebuf<char>(tempfile.getFileDescriptor(), std::ios::in));
-    istream_.reset(new std::istream(filebuf_.get()));
-  #endif
+    tempfile.seek(0);
+    istream_.reset(new std::istream(tempfile.rdbuf()));
   }

   InputFileStream(std::istream& strm) {
@@ -151,15 +158,8 @@
   std::unique_ptr<std::ostream> ostream_;
   marian::filesystem::Path file_;

-#ifndef _WIN32
-    std::unique_ptr<__gnu_cxx::stdio_filebuf<char>> filebuf_;
-#endif
-
 public:
   OutputFileStream(const std::string& file) : file_(file) {
-    // based on file extension choose if to compress or not
-    // this is not needed for decompressions as it looks at header and
-    // we can just use zstr::ifstream
     if(file_.extension() == marian::filesystem::Path(std::string(".gz")))
       ostream_.reset(new zstr::ofstream(file_));
     else
@@ -167,17 +167,8 @@
   }

   OutputFileStream(TemporaryFile& tempfile) {
-    lseek(tempfile.getFileDescriptor(), 0, SEEK_SET);
-
-  // This will fail on Windows as no tempfile can be created anyway.
-
-  // @TODO: this is non-standard, add more alternatives
-  // this SO answer describes a number of alternatives for different compilers, checking g++ for now.
-  // https://stackoverflow.com/questions/2746168/how-to-construct-a-c-fstream-from-a-posix-file-descriptor
-  #ifndef _WIN32
-    filebuf_.reset(new __gnu_cxx::stdio_filebuf<char>(tempfile.getFileDescriptor(), std::ios::out));
-    ostream_.reset(new std::ostream(filebuf_.get()));
-  #endif
+    tempfile.seek(0);
+    ostream_.reset(new std::ostream(tempfile.rdbuf()));
   }

   OutputFileStream(std::ostream& strm) {


ARM: OMAP2+: gpmc: Print error message in set_gpmc_timing_reg()

Simplify set_gpmc_timing_reg() and always print error message
if the requested timing cannot be achieved due to a too fast
GPMC functional clock, irrespective if whether DEBUG is defined
or not. This should help us debug timing configuration issues,
which were otherwise simply not being displayed in the kernel log.

Signed-off-by: Roger Quadros <eba86029bdfc5762d0419aa8dd4fd0368b2d01d4@ti.com>
Signed-off-by: Sekhar Nori <946cfb81282bb55c59f600e7ee3d3b2c6973f7a3@ti.com>
Acked-by: Tony Lindgren <1001e8702733cced254345e193c88aaa47a4f5de@atomide.com>

--- arch/arm/mach-omap2/gpmc.c
+++ arch/arm/mach-omap2/gpmc.c
@@ -283,13 +283,8 @@
 			   p->cycle2cyclediffcsen);
 }

-#ifdef DEBUG
 static int set_gpmc_timing_reg(int cs, int reg, int st_bit, int end_bit,
 			       int time, const char *name)
-#else
-static int set_gpmc_timing_reg(int cs, int reg, int st_bit, int end_bit,
-			       int time)
-#endif
 {
 	u32 l;
 	int ticks, mask, nr_bits;
@@ -299,15 +294,15 @@
 	else
 		ticks = gpmc_ns_to_ticks(time);
 	nr_bits = end_bit - st_bit + 1;
-	if (ticks >= 1 << nr_bits) {
-#ifdef DEBUG
-		printk(KERN_INFO "GPMC CS%d: %-10s* %3d ns, %3d ticks >= %d\n",
-				cs, name, time, ticks, 1 << nr_bits);
-#endif
+	mask = (1 << nr_bits) - 1;
+
+	if (ticks > mask) {
+		pr_err("%s: GPMC error! CS%d: %s: %d ns, %d ticks > %d\n",
+		       __func__, cs, name, time, ticks, mask);
+
 		return -1;
 	}

-	mask = (1 << nr_bits) - 1;
 	l = gpmc_cs_read_reg(cs, reg);
 #ifdef DEBUG
 	printk(KERN_INFO
@@ -322,16 +317,10 @@
 	return 0;
 }

-#ifdef DEBUG
 #define GPMC_SET_ONE(reg, st, end, field) \
 	if (set_gpmc_timing_reg(cs, (reg), (st), (end),		\
 			t->field, #field) < 0)			\
 		return -1
-#else
-#define GPMC_SET_ONE(reg, st, end, field) \
-	if (set_gpmc_timing_reg(cs, (reg), (st), (end), t->field) < 0) \
-		return -1
-#endif

 int gpmc_calc_divider(unsigned int sync_clk)
 {


FIX: work-around self implementation of strndup being available at a later moment in the compilation

--- src/common/gru_keypair.c
+++ src/common/gru_keypair.c
@@ -90,6 +90,10 @@
 	return false;
 }

+#if !defined(HAVE_STRNDUP)
+char *strndup(const char *source, size_t limit);
+#endif // HAVE_STRNDUP
+
 gru_keypair_t *gru_keypair_parse(const char *str, gru_status_t *status) {
 	gru_keypair_t *ret = gru_keypair_new(status);
 	gru_alloc_check(ret, NULL);


arm: pxa: add device-tree irq init for pxa27x

Add the initializer for irqs in a device-tree machine on a pxa27x.

Signed-off-by: Robert Jarzmik <94b2a0a74cb42a2dd0cf1b763601af7f13907aa9@free.fr>
Acked-by: Arnd Bergmann <f2c659f01951776204a6c5b902787d9019fbeebd@arndb.de>


[ARM] S3C2412: Add missing cache flush in suspend code

The alterations to the suspend code missed adding a
call to the cache flushing routines during the suspend
path of the S3C2412.

Signed-off-by: Ben Dooks <1177f64998f284a7348354b8e91cbbe575d9858a@fluff.org>

--- arch/arm/mach-s3c2412/pm.c
+++ arch/arm/mach-s3c2412/pm.c
@@ -21,6 +21,7 @@
 #include <linux/io.h>

 #include <mach/hardware.h>
+#include <asm/cacheflush.h>
 #include <asm/irq.h>

 #include <mach/regs-power.h>
@@ -38,6 +39,8 @@
 static void s3c2412_cpu_suspend(void)
 {
 	unsigned long tmp;
+
+	flush_cache_all();

 	/* set our standby method to sleep */


OMAP: iommu: fix wrong argument in flush_cache_vmap()

The second argument should be the end address, not the
length. Actually there will not be any effect on the behavior of this
driver since flush_cache_vmap() calls flush_cache_all() in the end.

Signed-off-by: Hiroshi DOYU <e891c4ae8deef7e6c0a3fb82004ec71ca9fb7e00@nokia.com>
Signed-off-by: Tony Lindgren <1001e8702733cced254345e193c88aaa47a4f5de@atomide.com>

--- arch/arm/plat-omap/iovmm.c
+++ arch/arm/plat-omap/iovmm.c
@@ -199,7 +199,7 @@
 		va += bytes;
 	}

-	flush_cache_vmap(new->addr, total);
+	flush_cache_vmap(new->addr, new->addr + total);
 	return new->addr;

 err_out:


omap: McBSP: tx_irq_completion used in rx_irq_handler

Looks like a typo from commit d6d834b010.

Signed-off-by: Scott Ellis <625600233cb3bcab32268c17610882e0fdaed295@jumpnowtek.com>
Acked-by: Peter Ujfalusi <e5c0b4cdf99ae1d408b9c497159e74b54e02e008@nokia.com>
Signed-off-by: Tony Lindgren <1001e8702733cced254345e193c88aaa47a4f5de@atomide.com>

--- arch/arm/plat-omap/mcbsp.c
+++ arch/arm/plat-omap/mcbsp.c
@@ -156,7 +156,7 @@
 		/* Writing zero to RSYNC_ERR clears the IRQ */
 		MCBSP_WRITE(mcbsp_rx, SPCR1, MCBSP_READ_CACHE(mcbsp_rx, SPCR1));
 	} else {
-		complete(&mcbsp_rx->tx_irq_completion);
+		complete(&mcbsp_rx->rx_irq_completion);
 	}

 	return IRQ_HANDLED;


If there is going to be a kludge to change the irq for com, do it early enough so that the used irq is printed in dmesg.

--- arch/armish/dev/com_obio.c
+++ arch/armish/dev/com_obio.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: com_obio.c,v 1.3 2006/06/01 18:46:05 drahn Exp $	*/
+/*	$OpenBSD: com_obio.c,v 1.4 2006/06/16 01:31:35 drahn Exp $	*/
 /*	$NetBSD: com_obio.c,v 1.9 2005/12/11 12:17:09 christos Exp $	*/

 /*-
@@ -67,14 +67,21 @@
 	NULL, "com_obio", DV_DULL
 };

+int com_irq_override = -1;
+
 int
 com_obio_match(struct device *parent, void *cf, void *aux)
 {
+	struct obio_attach_args *oba = aux;
+
+	/* if the irq does not match, do not attach */
+	if (com_irq_override != -1)
+		oba->oba_irq = com_irq_override;
+
 	/* We take it on faith that the device is there. */
 	return (1);
 }

-int com_irq_override = -1;

 void
 com_obio_attach(struct device *parent, struct device *self, void *aux)
@@ -83,10 +90,6 @@
 	struct com_obio_softc *osc = (void *) self;
 	struct com_softc *sc = &osc->sc_com;
 	int error;
-
-	/* XXX old value is already printed */
-	if (com_irq_override != -1)
-		oba->oba_irq = com_irq_override;

 	sc->sc_iot = oba->oba_st;
 	sc->sc_iobase = oba->oba_addr;


[IA64-SGI] sn_dma_alloc_coherent should use gfp flags

Takashi helped us track down a bad page state bug we thought was coming
from alsa.  It turns out we weren't paying attention to the gfp flags
that were passed in to sn_dma_alloc_coherent().

From: Takashi Iwai <4596b3305151c7ee743192a95d394341e3d3b644@suse.de>
Signed-off-by: Greg Edwards <93694b1f832a5631715c1df8c820c23aeedec2ef@sgi.com>
Signed-off-by: Mark Maule <95f53b0b4da46d5cbf8f2393757d2ff11ad3a08a@sgi.com>
Signed-off-by: Jes Sorensen <e7bd830ae2d0c840ab7cd2131cd33ff38c069cbe@sgi.com>

--- arch/ia64/sn/pci/pci_dma.c
+++ arch/ia64/sn/pci/pci_dma.c
@@ -90,14 +90,14 @@
 	 */
 	node = pcibus_to_node(pdev->bus);
 	if (likely(node >=0)) {
-		struct page *p = alloc_pages_node(node, GFP_ATOMIC, get_order(size));
+		struct page *p = alloc_pages_node(node, flags, get_order(size));

 		if (likely(p))
 			cpuaddr = page_address(p);
 		else
 			return NULL;
 	} else
-		cpuaddr = (void *)__get_free_pages(GFP_ATOMIC, get_order(size));
+		cpuaddr = (void *)__get_free_pages(flags, get_order(size));

 	if (unlikely(!cpuaddr))
 		return NULL;


kprobes/mips: Fix to check double free of insn slot

Fix to check double free of insn_slot at arch_remove_kprobe
as other arches do.

Signed-off-by: Masami Hiramatsu <60fcdccfd958d359debfe6e6e7417cd7f1aaa9e3@hitachi.com>
Cc: David Daney <0662de36cfb0706ed279bff52abef14720945acc@caviumnetworks.com>
Cc: Maneesh Soni <589aff5570c3de6fe47e831682b4def4c5b70da7@cisco.com>
Cc: Victor Kamensky <3445e560b259e10340f217d5ad0f0bf8c6029931@cisco.com>
Cc: 562397917b9a8bf316569a848858b12fb417723f@linux-mips.org
Cc: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@redhat.com>
Cc: 2578944098299abf708b08eff6fcf60565553586@vger.kernel.org
Cc: 562397917b9a8bf316569a848858b12fb417723f@linux-mips.org
Cc: 54c2d9f1c7765990828065d9af55833fb1690c0c@hitachi.com
Cc: 922727025a0cf43e784fa68f5f4f4f544f8fca4e@sourceware.org
Patchwork: https://patchwork.linux-mips.org/patch/5293/
Signed-off-by: Ralf Baechle <92f48d309cda194c8eda36aa8f9ae28c488fa208@linux-mips.org>

--- arch/mips/kernel/kprobes.c
+++ arch/mips/kernel/kprobes.c
@@ -207,7 +207,10 @@

 void __kprobes arch_remove_kprobe(struct kprobe *p)
 {
-	free_insn_slot(p->ainsn.insn, 0);
+	if (p->ainsn.insn) {
+		free_insn_slot(p->ainsn.insn, 0);
+		p->ainsn.insn = NULL;
+	}
 }

 static void save_previous_kprobe(struct kprobe_ctlblk *kcb)


powerpc/time: Remove unnecessary sanity check of decrementer expiration

The clockevents code uses max_delta_ns to avoid calling a
clockevent with too large a value.

Remove the redundant version of this in the timer_interrupt
code.

Signed-off-by: Anton Blanchard <14deb5e5e417133e888bf47bb6a3555c9bb7d81c@samba.org>
Signed-off-by: Benjamin Herrenschmidt <a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org>

--- arch/powerpc/kernel/time.c
+++ arch/powerpc/kernel/time.c
@@ -572,7 +572,6 @@
 	struct pt_regs *old_regs;
 	struct decrementer_clock *decrementer =  &__get_cpu_var(decrementers);
 	struct clock_event_device *evt = &decrementer->event;
-	u64 now;

 	/* Ensure a positive value is written to the decrementer, or else
 	 * some CPUs will continue to take decrementer exceptions.
@@ -607,16 +606,9 @@
 		get_lppaca()->int_dword.fields.decr_int = 0;
 #endif

-	now = get_tb_or_rtc();
-	if (now >= decrementer->next_tb) {
-		decrementer->next_tb = ~(u64)0;
-		if (evt->event_handler)
-			evt->event_handler(evt);
-	} else {
-		now = decrementer->next_tb - now;
-		if (now <= DECREMENTER_MAX)
-			set_dec((int)now);
-	}
+	decrementer->next_tb = ~(u64)0;
+	if (evt->event_handler)
+		evt->event_handler(evt);

 #ifdef CONFIG_PPC_ISERIES
 	if (firmware_has_feature(FW_FEATURE_ISERIES) && hvlpevent_is_pending())


Add qsort comparison

Add qsort comparison

--- stresstest.c
+++ stresstest.c
@@ -35,7 +35,7 @@
 /* Used to control the stress test */
 #define SEED 123
 #define MAXSIZE 25600
-#define TESTS 1000
+#define TESTS 10000
 #define TYPE char

 /* helper functions */
@@ -65,6 +65,13 @@
 }

 /* used for stdlib */
+static inline int compare(const void *a, const void *b)
+{
+  const TYPE da = *((const TYPE *) a);
+  const TYPE db = *((const TYPE *) b);
+  return (da < db) ? -1 : (da == db) ? 0 : 1;
+}
+
 static inline int compare_udata(const void *a, const void *b, void *udata)
 {
   const TYPE da = *((const TYPE *) a);
@@ -72,10 +79,6 @@
   return (da < db) ? -1 : (da == db) ? 0 : 1;
 }

-static inline int compare(const void *a, const void *b)
-{
-	return compare_udata(a, b, NULL);
-}

 void run_tests(void)
 {
@@ -107,6 +110,24 @@

 		free(dst);
 	}
+#if 0
+	printf("qsort\n");
+	for (test = 0; test < TESTS; test++)
+	{
+		size = (lrand48() % (MAXSIZE + 1));
+		dst = malloc(size * sizeof(dst[0]));
+		if (!dst && size) {
+			perror("malloc failed");
+			exit(EXIT_FAILURE);
+		}
+
+		fill(dst, size);
+		qsort(dst, size, sizeof(dst[0]), compare);
+		verify(dst, size);
+
+		free(dst);
+	}
+#endif
 }

 int main(void)


KVM: PPC: Centralize locking of arch specific vcpu ioctls

Signed-off-by: Avi Kivity <8f920f22884d6fea9df883843c4a8095a2e5ac6f@redhat.com>

--- arch/powerpc/kvm/powerpc.c
+++ arch/powerpc/kvm/powerpc.c
@@ -512,15 +512,17 @@
 	void __user *argp = (void __user *)arg;
 	long r;

-	switch (ioctl) {
-	case KVM_INTERRUPT: {
+	if (ioctl == KVM_INTERRUPT) {
 		struct kvm_interrupt irq;
 		r = -EFAULT;
 		if (copy_from_user(&irq, argp, sizeof(irq)))
-			goto out;
+			goto out_nolock;
 		r = kvm_vcpu_ioctl_interrupt(vcpu, &irq);
-		break;
-	}
+		goto out_nolock;
+	}
+
+	vcpu_load(vcpu);
+	switch (ioctl) {
 	case KVM_ENABLE_CAP:
 	{
 		struct kvm_enable_cap cap;
@@ -535,6 +537,8 @@
 	}

 out:
+	vcpu_put(vcpu);
+out_nolock:
 	return r;
 }


[POWERPC] MPIC: Minor optimization of ipi handler

Optimize MPIC IPIs, by passing in the IPI number as the argument to the
handler, since all we did was translate it back based on which mpic
the interrupt came though on (and that was always the primary mpic).

Signed-off-by: Olof Johansson <8c69ee23f3f44f8162a64d579c1fa25c2f55298a@lixom.net>
Acked-by: Benjamin Herrenschmidt <a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org>
Signed-off-by: Paul Mackerras <19a0ba370c443ba08d20b5061586430ab449ee8c@samba.org>

--- arch/powerpc/sysdev/mpic.c
+++ arch/powerpc/sysdev/mpic.c
@@ -612,12 +612,11 @@
 }

 #ifdef CONFIG_SMP
-static irqreturn_t mpic_ipi_action(int irq, void *dev_id)
-{
-	struct mpic *mpic;
-
-	mpic = mpic_find(irq, NULL);
-	smp_message_recv(mpic_irq_to_hw(irq) - mpic->ipi_vecs[0]);
+static irqreturn_t mpic_ipi_action(int irq, void *data)
+{
+	long ipi = (long)data;
+
+	smp_message_recv(ipi);

 	return IRQ_HANDLED;
 }
@@ -1457,7 +1456,7 @@
 void mpic_request_ipis(void)
 {
 	struct mpic *mpic = mpic_primary;
-	int i, err;
+	long i, err;
 	static char *ipi_names[] = {
 		"IPI0 (call function)",
 		"IPI1 (reschedule)",
@@ -1472,14 +1471,14 @@
 		unsigned int vipi = irq_create_mapping(mpic->irqhost,
 						       mpic->ipi_vecs[0] + i);
 		if (vipi == NO_IRQ) {
-			printk(KERN_ERR "Failed to map IPI %d\n", i);
+			printk(KERN_ERR "Failed to map IPI %ld\n", i);
 			break;
 		}
 		err = request_irq(vipi, mpic_ipi_action,
 				  IRQF_DISABLED|IRQF_PERCPU,
-				  ipi_names[i], mpic);
+				  ipi_names[i], (void *)i);
 		if (err) {
-			printk(KERN_ERR "Request of irq %d for IPI %d failed\n",
+			printk(KERN_ERR "Request of irq %d for IPI %ld failed\n",
 			       vipi, i);
 			break;
 		}


Forgot to commit a rename of wvcallback.h to wvtr1.h in retchmail.

git-svn-id: 6c62acd9a4636584fd478883871c6f1d9a8a3d63@11810 6619c942-59fa-0310-bf43-a07aaa81d9ac

--- wvsendmail.h
+++ wvsendmail.h
@@ -2,7 +2,7 @@
 #define WVSENDMAIL_H 1

 #include "wvpipe.h"
-#include "wvcallback.h"
+#include "wvtr1.h"

 // parameters are: int mess_index, bool success
 typedef wv::function<void(int, bool)> WvSendmailCallback;


sparc: _sparc_find_resource() should check for exact matches

The address that's passed to _sparc_find_resource() should always be the
start address of a resource:
  - iounmap() passes a page-aligned virtual address, while the original
    address was created by adding the in-page offset to the resource's
    start address,
  - sbus_free_coherent() and pci32_free_coherent() should be passed an
    address obtained from sbus_alloc_coherent() resp. pci32_alloc_coherent(),
    which is always a resource's start address.

Hence replace the range check by a check for an exact match.

Signed-off-by: Geert Uytterhoeven <0da414d9d963da4039c2a0525b1844228075aa58@linux-m68k.org>
Acked-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- arch/sparc/kernel/ioport.c
+++ arch/sparc/kernel/ioport.c
@@ -723,12 +723,12 @@
  * This probably warrants some sort of hashing.
  */
 static struct resource *_sparc_find_resource(struct resource *root,
-					     unsigned long hit)
+					     unsigned long start)
 {
 	struct resource *tmp;

 	for (tmp = root->child; tmp != 0; tmp = tmp->sibling) {
-		if (tmp->start <= hit && tmp->end >= hit)
+		if (tmp->start == start)
 			return tmp;
 	}
 	return NULL;


sparc64: Fix sparse warnings in chmc.c

sparc64: Fix sparse warnings in chmc.c

Several constants are larger than 32-bit and need "UL" markers.

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

--- arch/sparc64/kernel/chmc.c
+++ arch/sparc64/kernel/chmc.c
@@ -104,20 +104,20 @@

 #define JBUSMC_REGS_SIZE		8

-#define JB_MC_REG1_DIMM2_BANK3		0x8000000000000000
-#define JB_MC_REG1_DIMM1_BANK1		0x4000000000000000
-#define JB_MC_REG1_DIMM2_BANK2		0x2000000000000000
-#define JB_MC_REG1_DIMM1_BANK0		0x1000000000000000
-#define JB_MC_REG1_XOR			0x0000010000000000
-#define JB_MC_REG1_ADDR_GEN_2		0x000000e000000000
+#define JB_MC_REG1_DIMM2_BANK3		0x8000000000000000UL
+#define JB_MC_REG1_DIMM1_BANK1		0x4000000000000000UL
+#define JB_MC_REG1_DIMM2_BANK2		0x2000000000000000UL
+#define JB_MC_REG1_DIMM1_BANK0		0x1000000000000000UL
+#define JB_MC_REG1_XOR			0x0000010000000000UL
+#define JB_MC_REG1_ADDR_GEN_2		0x000000e000000000UL
 #define JB_MC_REG1_ADDR_GEN_2_SHIFT	37
-#define JB_MC_REG1_ADDR_GEN_1		0x0000001c00000000
+#define JB_MC_REG1_ADDR_GEN_1		0x0000001c00000000UL
 #define JB_MC_REG1_ADDR_GEN_1_SHIFT	34
-#define JB_MC_REG1_INTERLEAVE		0x0000000001800000
+#define JB_MC_REG1_INTERLEAVE		0x0000000001800000UL
 #define JB_MC_REG1_INTERLEAVE_SHIFT	23
-#define JB_MC_REG1_DIMM2_PTYPE		0x0000000000200000
+#define JB_MC_REG1_DIMM2_PTYPE		0x0000000000200000UL
 #define JB_MC_REG1_DIMM2_PTYPE_SHIFT	21
-#define JB_MC_REG1_DIMM1_PTYPE		0x0000000000100000
+#define JB_MC_REG1_DIMM1_PTYPE		0x0000000000100000UL
 #define JB_MC_REG1_DIMM1_PTYPE_SHIFT	20

 #define PART_TYPE_X8		0


uml: Eliminate temporary buffer in eth_configure

Avoid using the temporary buffer introduced by previous patch to hold the
device name.

Btw, avoid leaking device on an error path.  Other error paths may need
cleanup.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <25fbe3e5acbb7edd90bb5fdeec999a792321fbc4@yahoo.it>
Signed-off-by: Jeff Dike <f9b6309e85863eba5d28138b6a0f35841ce976d0@linux.intel.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- arch/um/drivers/net_kern.c
+++ arch/um/drivers/net_kern.c
@@ -348,15 +348,22 @@
 	struct net_device *dev;
 	struct uml_net_private *lp;
 	int save, err, size;
-	char name[sizeof(dev->name)];

 	size = transport->private_size + sizeof(struct uml_net_private) +
 		sizeof(((struct uml_net_private *) 0)->user);

 	device = kzalloc(sizeof(*device), GFP_KERNEL);
 	if (device == NULL) {
-		printk(KERN_ERR "eth_configure failed to allocate uml_net\n");
+		printk(KERN_ERR "eth_configure failed to allocate struct "
+		       "uml_net\n");
 		return;
+	}
+
+	dev = alloc_etherdev(size);
+	if (dev == NULL) {
+		printk(KERN_ERR "eth_configure: failed to allocate struct "
+		       "net_device for eth%d\n", n);
+		goto out_free_device;
 	}

 	INIT_LIST_HEAD(&device->list);
@@ -366,9 +373,9 @@
 	 * netdevice, that is OK, register_netdev{,ice}() will notice this
 	 * and fail.
 	 */
-	snprintf(name, sizeof(name), "eth%d", n);
-
-	setup_etheraddr(mac, device->mac, name);
+	snprintf(dev->name, sizeof(dev->name), "eth%d", n);
+
+	setup_etheraddr(mac, device->mac, dev->name);

 	printk(KERN_INFO "Netdevice %d ", n);
 	printk("(%02x:%02x:%02x:%02x:%02x:%02x) ",
@@ -376,11 +383,6 @@
 	       device->mac[2], device->mac[3],
 	       device->mac[4], device->mac[5]);
 	printk(": ");
-	dev = alloc_etherdev(size);
-	if (dev == NULL) {
-		printk(KERN_ERR "eth_configure: failed to allocate device\n");
-		goto out_free_device;
-	}

 	lp = dev->priv;
 	/* This points to the transport private data. It's still clear, but we
@@ -399,7 +401,6 @@
 		goto out_free_netdev;
 	SET_NETDEV_DEV(dev,&device->pdev.dev);

-	strcpy(dev->name, name);
 	device->dev = dev;

 	/*
@@ -466,13 +467,13 @@
 	return;

 out_undo_user_init:
-	if (transport->user->init != NULL)
+	if (transport->user->remove != NULL)
 		(*transport->user->remove)(&lp->user);
 out_unregister:
 	platform_device_unregister(&device->pdev);
 out_free_netdev:
 	free_netdev(dev);
-out_free_device: ;
+out_free_device:
 	kfree(device);
 }


uml: fixup allocation in the ubd driver

uml: fixup allocation in the ubd driver

Sanitise gfp flags; it actually is an atomic context, so drop the
GFP_KERNEL part.

Signed-off-by: Peter Zijlstra <645ca7d3a8d3d4f60557176cd361ea8351edc32b@chello.nl>
Acked-by: Jeff Dike <f9b6309e85863eba5d28138b6a0f35841ce976d0@addtoit.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- arch/um/drivers/ubd_kern.c
+++ arch/um/drivers/ubd_kern.c
@@ -1102,7 +1102,7 @@
 			struct scatterlist *sg = &dev->sg[dev->start_sg];

 			io_req = kmalloc(sizeof(struct io_thread_req),
-					 GFP_KERNEL | GFP_ATOMIC);
+					 GFP_ATOMIC);
 			if(io_req == NULL){
 				if(list_empty(&dev->restart))
 					list_add(&dev->restart, &restart);


x86, asm: Make _ASM_EXTABLE() usable from assembly code

We have had this convenient macro _ASM_EXTABLE() to generate exception
table entry in inline assembly.  Make it also usable for pure
assembly.

Signed-off-by: H. Peter Anvin <8a453bad9912ffe59bc0f0b8abe03df9be19379e@zytor.com>

--- arch/x86/include/asm/asm.h
+++ arch/x86/include/asm/asm.h
@@ -3,7 +3,7 @@

 #ifdef __ASSEMBLY__
 # define __ASM_FORM(x)	x
-# define __ASM_EX_SEC	.section __ex_table
+# define __ASM_EX_SEC	.section __ex_table, "a"
 #else
 # define __ASM_FORM(x)	" " #x " "
 # define __ASM_EX_SEC	" .section __ex_table,\"a\"\n"
@@ -38,10 +38,18 @@
 #define _ASM_DI		__ASM_REG(di)

 /* Exception table entry */
+#ifdef __ASSEMBLY__
+# define _ASM_EXTABLE(from,to)	    \
+	__ASM_EX_SEC ;		    \
+	_ASM_ALIGN ;		    \
+	_ASM_PTR from , to ;	    \
+	.previous
+#else
 # define _ASM_EXTABLE(from,to) \
 	__ASM_EX_SEC	\
 	_ASM_ALIGN "\n" \
 	_ASM_PTR #from "," #to "\n" \
 	" .previous\n"
+#endif

 #endif /* _ASM_X86_ASM_H */


x86/irq: Implement irq_chip.irq_write_msi_msg for MSI/DMAR/HPET irq_chips

Implement irq_chip.irq_write_msi_msg for MSI/DMAR/HPET irq_chips, they
will be used to replace duplicated code.

Signed-off-by: Jiang Liu <68ee766e574f18b34b683085865827393efe88bd@linux.intel.com>
Cc: Konrad Rzeszutek Wilk <da3a51b335cef0eb0e2c329c5ef6bcd6acef687a@oracle.com>
Cc: David Cohen <c031177e4d219c7dd6e3090d8fbcd121f5ab192c@linux.intel.com>
Cc: Sander Eikelenboom <ba324ca7b1c77fc20bb970d5aff6eea9377918a5@eikelenboom.it>
Cc: David Vrabel <b9d45bd1f671e508cd8daa63dfc3cabb597562df@citrix.com>
Cc: Tony Luck <e7984595ec0368ff920a7b3521dc7093683f6f26@intel.com>
Cc: Joerg Roedel <4688a6871ff025801033b3c4b039d55a29f8f937@8bytes.org>
Cc: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>
Cc: Bjorn Helgaas <f10ec01be0c6b54271af5c550cd257810bdf3268@google.com>
Cc: Benjamin Herrenschmidt <a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org>
Cc: Rafael J. Wysocki <a11f87183a953ab11f50fbafff689c5a7fa3506c@rjwysocki.net>
Cc: Randy Dunlap <6f29df8e90a57f1ba61ffd63b0468c86bb6d3a99@infradead.org>
Cc: Yinghai Lu <0674548f4d596393408a51d6287a76ebba2f42aa@kernel.org>
Cc: Borislav Petkov <0691a664b24b6f15b20cd5aee64b72271db08be1@alien8.de>
Cc: Dimitri Sivanich <eb9314cd9fb6c9c1ab10792809da7e2f4af25acd@sgi.com>
Link: http://lkml.kernel.org/r/1428905519-23704-27-git-send-email-68ee766e574f18b34b683085865827393efe88bd@linux.intel.com
Signed-off-by: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>


x86/fpu: Reorder init methods

x86/fpu: Reorder init methods

Reorder init methods in order of their relationship and usage, to
form coherent blocks throughout the whole file.

Reviewed-by: Borislav Petkov <0691a664b24b6f15b20cd5aee64b72271db08be1@alien8.de>
Cc: Andy Lutomirski <2cc0d0d76de2e6f37b92deeb83c85cb306fc5dc1@amacapital.net>
Cc: Dave Hansen <71bcd3d88361b22cd828f9a350d19d8775f56d4e@linux.intel.com>
Cc: Fenghua Yu <94fe9a7ec8ff966c1952fe98e39b5ae3a7477695@intel.com>
Cc: H. Peter Anvin <8a453bad9912ffe59bc0f0b8abe03df9be19379e@zytor.com>
Cc: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>
Cc: Oleg Nesterov <20b70f0af00562e63758b9ee42012ecc96c58590@redhat.com>
Cc: Peter Zijlstra <3fddac958924aef220f202ca567388ddab3f14a8@infradead.org>
Cc: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@kernel.org>


KVM: MMU: don't mark spte notrap if reserved bit set

If reserved bit is set, we need inject the #PF with PFEC.RSVD=1,
but shadow_notrap_nonpresent_pte injects #PF with PFEC.RSVD=0 only

Signed-off-by: Xiao Guangrong <1e0036c3819c78880ef9e9a8457e99783a5661e3@cn.fujitsu.com>
Signed-off-by: Marcelo Tosatti <958bcd1f4a7a8c36dca09fe3fa9cb5f1483adf51@redhat.com>

--- arch/x86/kvm/paging_tmpl.h
+++ arch/x86/kvm/paging_tmpl.h
@@ -395,8 +395,10 @@

 		gpte = gptep[i];

-		if (!is_present_gpte(gpte) ||
-		      is_rsvd_bits_set(mmu, gpte, PT_PAGE_TABLE_LEVEL)) {
+		if (is_rsvd_bits_set(mmu, gpte, PT_PAGE_TABLE_LEVEL))
+			continue;
+
+		if (!is_present_gpte(gpte)) {
 			if (!sp->unsync)
 				__set_spte(spte, shadow_notrap_nonpresent_pte);
 			continue;
@@ -760,6 +762,7 @@
 		pt_element_t gpte;
 		gpa_t pte_gpa;
 		gfn_t gfn;
+		bool rsvd_bits_set;

 		if (!is_shadow_present_pte(sp->spt[i]))
 			continue;
@@ -771,12 +774,14 @@
 			return -EINVAL;

 		gfn = gpte_to_gfn(gpte);
-		if (is_rsvd_bits_set(&vcpu->arch.mmu, gpte, PT_PAGE_TABLE_LEVEL)
-		      || gfn != sp->gfns[i] || !is_present_gpte(gpte)
-		      || !(gpte & PT_ACCESSED_MASK)) {
+		rsvd_bits_set = is_rsvd_bits_set(&vcpu->arch.mmu, gpte,
+						 PT_PAGE_TABLE_LEVEL);
+		if (rsvd_bits_set || gfn != sp->gfns[i] ||
+		      !is_present_gpte(gpte) || !(gpte & PT_ACCESSED_MASK)) {
 			u64 nonpresent;

-			if (is_present_gpte(gpte) || !clear_unsync)
+			if (rsvd_bits_set || is_present_gpte(gpte) ||
+			      !clear_unsync)
 				nonpresent = shadow_trap_nonpresent_pte;
 			else
 				nonpresent = shadow_notrap_nonpresent_pte;


KVM: MMU: unalias gfn before sp->gfns[] comparison in sync_page

sp->gfns[] contain unaliased gfns, but gpte might contain pointer
to aliased region.

Signed-off-by: Xiao Guangrong <1e0036c3819c78880ef9e9a8457e99783a5661e3@cn.fujitsu.com>
Signed-off-by: Marcelo Tosatti <958bcd1f4a7a8c36dca09fe3fa9cb5f1483adf51@redhat.com>

--- arch/x86/kvm/paging_tmpl.h
+++ arch/x86/kvm/paging_tmpl.h
@@ -586,7 +586,7 @@
 		unsigned pte_access;
 		pt_element_t gpte;
 		gpa_t pte_gpa;
-		gfn_t gfn = sp->gfns[i];
+		gfn_t gfn;

 		if (!is_shadow_present_pte(sp->spt[i]))
 			continue;
@@ -597,8 +597,9 @@
 					  sizeof(pt_element_t)))
 			return -EINVAL;

-		if (gpte_to_gfn(gpte) != gfn || !is_present_gpte(gpte) ||
-		    !(gpte & PT_ACCESSED_MASK)) {
+		gfn = gpte_to_gfn(gpte);
+		if (unalias_gfn(vcpu->kvm, gfn) != sp->gfns[i] ||
+		      !is_present_gpte(gpte) || !(gpte & PT_ACCESSED_MASK)) {
 			u64 nonpresent;

 			rmap_remove(vcpu->kvm, &sp->spt[i]);


KVM: x86 emulator: Add unsigned byte immediate decode

Extend "Source operand type" opcode description field to 4 bites
to accommodate new option.

Signed-off-by: Gleb Natapov <03189597947f75187c4136ade35aec34feed9dc1@redhat.com>
Signed-off-by: Avi Kivity <8f920f22884d6fea9df883843c4a8095a2e5ac6f@redhat.com>

--- arch/x86/kvm/x86_emulate.c
+++ arch/x86/kvm/x86_emulate.c
@@ -59,13 +59,14 @@
 #define SrcImm      (5<<4)	/* Immediate operand. */
 #define SrcImmByte  (6<<4)	/* 8-bit sign-extended immediate operand. */
 #define SrcOne      (7<<4)	/* Implied '1' */
-#define SrcMask     (7<<4)
+#define SrcImmUByte (8<<4)      /* 8-bit unsigned immediate operand. */
+#define SrcMask     (0xf<<4)
 /* Generic ModRM decode. */
-#define ModRM       (1<<7)
+#define ModRM       (1<<8)
 /* Destination is only written; never read. */
-#define Mov         (1<<8)
-#define BitOp       (1<<9)
-#define MemAbs      (1<<10)      /* Memory operand is absolute displacement */
+#define Mov         (1<<9)
+#define BitOp       (1<<10)
+#define MemAbs      (1<<11)      /* Memory operand is absolute displacement */
 #define String      (1<<12)     /* String instruction (rep capable) */
 #define Stack       (1<<13)     /* Stack instruction (push/pop) */
 #define Group       (1<<14)     /* Bits 3:5 of modrm byte extend opcode */
@@ -1044,10 +1045,14 @@
 		}
 		break;
 	case SrcImmByte:
+	case SrcImmUByte:
 		c->src.type = OP_IMM;
 		c->src.ptr = (unsigned long *)c->eip;
 		c->src.bytes = 1;
-		c->src.val = insn_fetch(s8, 1, c->eip);
+		if ((c->d & SrcMask) == SrcImmByte)
+			c->src.val = insn_fetch(s8, 1, c->eip);
+		else
+			c->src.val = insn_fetch(u8, 1, c->eip);
 		break;
 	case SrcOne:
 		c->src.bytes = 1;


x86: math-emu: Drop already-disabled print of build date

The kernel already has this information, so other bits of kernel code
shouldn't duplicate that.  This also eliminates the use of __DATE__,
which makes the build non-deterministic.

This message was already disabled at build time, with PRINT_MESSAGES
undef'd at the top of the file.

Signed-off-by: Josh Triplett <c028c213ed5efcf30c3f4fc7361dbde0c893c5b7@joshtriplett.org>
Signed-off-by: Michal Marek <0c835876a532a476f30fdb1f6e963bae6c5a1a04@suse.cz>

--- arch/x86/math-emu/errors.c
+++ arch/x86/math-emu/errors.c
@@ -330,11 +330,6 @@

 	RE_ENTRANT_CHECK_OFF;
 	if ((~control_word & n & CW_Exceptions) || (n == EX_INTERNAL)) {
-#ifdef PRINT_MESSAGES
-		/* My message from the sponsor */
-		printk(FPU_VERSION " " __DATE__ " (C) W. Metzenthen.\n");
-#endif /* PRINT_MESSAGES */
-
 		/* Get a name string for error reporting */
 		for (i = 0; exception_names[i].type; i++)
 			if ((exception_names[i].type & n) ==


Renamed first test program

Renamed first test program

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

--- strtoupper.c
+++ strtoupper.c
@@ -0,0 +1,13 @@
+// The string needs to be defined as global *array* (not pointer), otherwise GCC will treat it as a constant and
+// put it at the *beginning* of the code block.
+static char s[] = "hello world";
+
+void strtoupper()
+{
+    char *p;
+    for (p = s; *p != 0; p++) {
+        if (*p >= 97 && *p <= 122)
+            *p -= 32;
+    }
+    return;
+}


OpenMP decode: merge return value from all threads properly

Sum the return values from the separate threads to catch decode errors
in individual threads. If the sum is `-num_threads', then all threads
returned -1, meaning that the requested codec is not available. If the
sum is not `num_threads', then at least one of the threads hit a
decoding error.

--- lib/lib_openmp.c
+++ lib/lib_openmp.c
@@ -121,16 +121,25 @@
 			result += this_result;
 		}
 	}
+
+	// If `result' equals `-num_threads', then all threads returned -1,
+	// indicating that the requested codec is not available:
+	if (result == -num_threads) {
+		return -1;
+	}
+
+	// If `result' does not equal `num_threads', then at least one of the
+	// threads hit a decode error:
+	if (result != num_threads) {
+		return 0;
+	}
+
+	// So far so good, now decode whatever remains in the buffer. Reuse the
+	// initial state, since we are at a 4-byte boundary:
 	state = initial_state;
-	result += base64_stream_decode(&state, src + num_threads * len, last_len, out + num_threads * len * 3 / 4, &s);
+	result = base64_stream_decode(&state, src + num_threads * len, last_len, out + num_threads * len * 3 / 4, &s);
 	sum += s;
 	*outlen = sum;

-	if (result > 0)
-		result = 1;
-
-	if (result < 0)
-		result = -1;
-
 	return result;
 }


Fix symbol handling (stripped kernels)

Fix symbol handling (stripped kernels)

--- lib/libsa/exec.c
+++ lib/libsa/exec.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: exec.c,v 1.12 1997/03/30 20:13:04 mickey Exp $	*/
+/*	$OpenBSD: exec.c,v 1.13 1997/03/31 04:20:08 weingart Exp $	*/
 /*	$NetBSD: exec.c,v 1.15 1996/10/13 02:29:01 christos Exp $	*/

 /*-
@@ -53,13 +53,13 @@
 	void *loadaddr;
 	int howto;
 {
-	register int io;
+	int io;
 #ifndef INSECURE
 	struct stat sb;
 #endif
 	struct exec x;
 	int i;
-	register char *addr;
+	char *addr;
 #ifdef EXEC_DEBUG
 	char *daddr, *etxt;
 #endif
@@ -127,28 +127,33 @@
 		*addr++ = 0;

         /* Symbols */
-	ssym = addr;
-	bcopy(&x.a_syms, addr, sizeof(x.a_syms));
-	addr += sizeof(x.a_syms);
-	printf("+[%ld", x.a_syms);
-	if (read(io, addr, x.a_syms) != x.a_syms)
-		goto shread;
-	addr += x.a_syms;
+	if(x.a_syms){
+		ssym = addr;
+		bcopy(&x.a_syms, addr, sizeof(x.a_syms));
+		addr += sizeof(x.a_syms);
+		printf("+[%ld", x.a_syms);
+		if (read(io, addr, x.a_syms) != x.a_syms)
+			goto shread;
+		addr += x.a_syms;

-	if (read(io, &i, sizeof(int)) != sizeof(int))
-		goto shread;
+		if (read(io, &i, sizeof(int)) != sizeof(int))
+			goto shread;

-	bcopy(&i, addr, sizeof(int));
-	if (i) {
-		i -= sizeof(int);
-		addr += sizeof(int);
-		if (read(io, addr, i) != i)
+		bcopy(&i, addr, sizeof(int));
+		if (i) {
+			i -= sizeof(int);
+			addr += sizeof(int);
+			if (read(io, addr, i) != i)
                 	goto shread;
-		addr += i;
+			addr += i;
+		}
+
+		/* and that many bytes of string table */
+		printf("+%d]", i);
+	}else{
+		ssym = 0;
+		esym = 0;
 	}
-
-	/* and that many bytes of string table */
-	printf("+%d]", i);

 	close(io);


[substrate2] Remove obsolete substrate2 (APE hasn’t worked since 10.8)

--- substrate2.h
+++ substrate2.h
@@ -1,75 +0,0 @@
-/*
-
-substrate2.h ... Convenient wrapper for MobileSubstrate.
-
-Copyright (c) 2009  KennyTM~ <kennytm@gmail.com>
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification,
-are permitted provided that the following conditions are met:
-
-* Redistributions of source code must retain the above copyright notice, this
-  list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
-  this list of conditions and the following disclaimer in the documentation
-  and/or other materials provided with the distribution.
-* Neither the name of the KennyTM~ nor the names of its contributors may be
-  used to endorse or promote products derived from this software without
-  specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-*/
-
-#ifndef SUBSTRATE2_H
-#define SUBSTRATE2_H
-
-// Use substrate.h on iPhoneOS, and APELite on x86/ppc for debugging.
-#ifdef __arm__
-#import <substrate.h>
-#define REGPARM3
-#elif __i386__ || __ppc__
-#import <objc/runtime.h>
-#import <objc/message.h>
-extern
-#if __cplusplus
-"C"
-#endif
-void* APEPatchCreate(const void* original, const void* replacement);
-#define MSHookFunction(original, replacement, result) (*(result) = APEPatchCreate((original), (replacement)))
-#define MSHookMessageEx(class, selector, replacement, result) (*(result) = method_setImplementation(class_getInstanceMethod((class), (selector)), (replacement)))
-#define REGPARM3 __attribute__((regparm(3)))
-#else
-#error Not supported in non-ARM/i386/PPC system.
-#endif
-
-#define Original(funcname) original_##funcname
-
-#define DefineHook(rettype, funcname, ...) \
-rettype funcname (__VA_ARGS__); \
-static rettype (*original_##funcname) (__VA_ARGS__); \
-static rettype replaced_##funcname (__VA_ARGS__)
-
-#define DefineObjCHook(rettype, funcname, ...) \
-static rettype (*original_##funcname) (__VA_ARGS__); \
-static rettype replaced_##funcname (__VA_ARGS__)
-
-#define DefineHiddenHook(rettype, funcname, ...) \
-static rettype (*funcname) (__VA_ARGS__); \
-REGPARM3 static rettype (*original_##funcname) (__VA_ARGS__); \
-REGPARM3 static rettype replaced_##funcname (__VA_ARGS__)
-
-#define InstallHook(funcname) MSHookFunction(funcname, replaced_##funcname, (void**)&original_##funcname)
-#define InstallObjCInstanceHook(cls, sel, delimited_name) MSHookMessageEx((cls), (sel), (IMP)replaced_##delimited_name, (IMP*)&original_##delimited_name)
-#define InstallObjCClassHook(cls, sel, delimited_name) MSHookMessageEx(object_getClass(cls), (sel), (IMP)replaced_##delimited_name, (IMP*)&original_##delimited_name)
-
-#endif


Probably wrong stack alignment for struct on Win64

--- x86_64-gen.c
+++ x86_64-gen.c
@@ -614,7 +614,7 @@
         if (bt == VT_STRUCT) {
             size = type_size(&sv->type, &align);
             /* align to stack align size */
-            size = (size + 15) & ~16;
+            size = (size + 15) & ~15;
             /* generate structure store */
             r = get_reg(RC_INT);
             gen_offs_sp(0x8d, r, args_size);


fix eladdr allocation

fix eladdr allocation

--- sudpserver.c
+++ sudpserver.c
@@ -179,9 +179,7 @@
         if (oneshot && stat_open == 0) {
 		for (ea = eladdr; ea->ea_laddr; ea++)
 			event_del(&ea->ea_event);
-#if 0
 		free(eladdr);
-#endif
                 if (statistics)
                         statistic_callback(SIGINFO, 0, &evstat);
                 event_del(&evstat);
@@ -250,7 +248,7 @@
 		err(1, "%s: address %s, service %s", cause, address, service);
         /* don't call freeaddrinfo(res0), addr is still referenced */

-	if ((ea = eladdr = calloc(nsock, sizeof(*ea))) == NULL)
+	if ((ea = eladdr = calloc(nsock + 1, sizeof(*ea))) == NULL)
 		err(1, "calloc");
 	for (n = 0; n < nsock; n++, ea++) {
 		event_set(&ea->ea_event, s[n], EV_READ|EV_PERSIST,


Set a default value for boolean options (false).

--- fastlib/branches/fastlib-stl/fastlib/fx/option_impl.h
+++ fastlib/branches/fastlib-stl/fastlib/fx/option_impl.h
@@ -21,7 +21,7 @@
   else {
     IO::Add<N>(identifier, description, parent, required);

-    //Create the full pathname.
+    // Create the full pathname to set the default value.
     std::string pathname = IO::SanitizeString(parent) + std::string(identifier);
     IO::GetParam<N>(pathname.c_str()) = defaultValue;
   }
@@ -36,6 +36,10 @@
                   const char* description,
                   const char* parent) {
   IO::AddFlag(identifier, description, parent);
+
+  // Set the default value (false).
+  std::string pathname = IO::SanitizeString(parent) + std::string(identifier);
+  IO::GetParam<bool>(pathname.c_str()) = false;
 }

 }; // namespace mlpack


added hex values to scancode comments

added hex values to scancode comments

--- xrdp/funcs.c
+++ xrdp/funcs.c
@@ -125,94 +125,99 @@

 /*****************************************************************************/
 /*  scan codes
-    1   esc
-    2   1 or ?
-    3   2 or @
-    4   3 or #
-    5   4 or $
-    6   5 or %
-    7   6 or ^
-    8   7 or &
-    9   8 or *
-    10  9 or (
-    11  10 or )
-    12  11 or _
-    13  12 or +
-    14  backspace
-    15  tab
-    16  q or Q
-    17  w or W
-    18  e or E
-    19  r or R
-    20  t or T
-    21  y or Y
-    22  u or U
-    23  i or I
-    24  o or O
-    25  p or P
-    26  [ or {
-    27  ] or }
-    28  enter, keypad if ext
-    29  left or right ctrl, ext flag is right
-    30  a or A
-    31  s or S
-    32  d or D
-    33  f or F
-    34  g or G
-    35  h or H
-    36  j or J
-    37  k or K
-    38  l or L
-    39  ; or :
-    40  ' or "
-    41  ~
-    42  left shift
-    43  \
-    44  z or Z
-    45  x or X
-    46  c or C
-    47  v or V
-    48  b or B
-    49  n or N
-    50  m or M
-    51  , or <
-    52  . or >
-    53  / can be / on keypad, ext flag is keypad
-    54  right shift
-    55  * on keypad or print screen if ext
-    56  left or right alt, ext flag is right
-    57  space
-    58  caps lock
-    59  F1
-    60  F2
-    61  F3
-    62  F4
-    63  F5
-    64  F6
-    65  F7
-    66  F8
-    67  F9
-    68  F10
-    69  num lock
-    70  scroll lock
-    71  7 or home on keypad, ext flag is not keypad
-    72  8 or arrow up on keypad, ext flag is not keypad
-    73  9 or page up
-    74  -(minus) on keypad
-    75  4 or arrow left on keypad, ext flag is not keypad
-    76  middle(5 key) of keypad
-    77  6 or arrow right, can be on keypad, ext flag in not keypad
-    78  + on keypad
-    79  1 or end
-    80  2 or arrow down, can be on keypad, ext flag in not keypad
-    81  3 or page down
-    82  0 or insert on keypad, ext flag is not keypad
-    83  . or delete on keypad, ext flag is not keypad
-    87  F11
-    88  F12
-    91  left win key ext always on
-    92  right win key ext always on
-    93  menu key ext always on
+    1 0x01  esc
+    2 0x02  1 or ?
+    3 0x03  2 or @
+    4 0x04  3 or #
+    5 0x05  4 or $
+    6 0x06  5 or %
+    7 0x07  6 or ^
+    8 0x08  7 or &
+    9 0x09  8 or *
+    10 0x0a 9 or (
+    11 0x0b 0 or )
+    12 0x0c - or _
+    13 0x0d = or +
+    14 0x0e backspace
+    15 0x0f tab
+    16 0x10 q or Q
+    17 0x11 w or W
+    18 0x12 e or E
+    19 0x13 r or R
+    20 0x14 t or T
+    21 0x15 y or Y
+    22 0x16 u or U
+    23 0x17 i or I
+    24 0x18 o or O
+    25 0x19 p or P
+    26 0x1a [ or {
+    27 0x1b ] or }
+    28 0x1c enter, keypad if ext
+    29 0x1d left or right ctrl, ext flag is right
+    30 0x1e a or A
+    31 0x1f s or S
+    32 0x20 d or D
+    33 0x21 f or F
+    34 0x22 g or G
+    35 0x23 h or H
+    36 0x24 j or J
+    37 0x25 k or K
+    38 0x26 l or L
+    39 0x27 ; or :
+    40 0x28 ' or "
+    41 0x29  ` or ~
+    42 0x2a left shift
+    43 0x2b \
+    44 0x2c z or Z
+    45 0x2d x or X
+    46 0x2e c or C
+    47 0x2f v or V
+    48 0x30 b or B
+    49 0x31 n or N
+    50 0x32 m or M
+    51 0x33 , or <
+    52 0x34 . or >
+    53 0x35 / can be / on keypad, ext flag is keypad
+    54 0x36 right shift
+    55 0x37 * on keypad or print screen if ext
+    56 0x38 left or right alt, ext flag is right
+    57 0x39 space
+    58 0x3a caps lock
+    59 0x3b F1
+    60 0x3c F2
+    61 0x3d F3
+    62 0x3e F4
+    63 0x3f F5
+    64 0x40 F6
+    65 0x41 F7
+    66 0x42 F8
+    67 0x43 F9
+    68 0x44 F10
+    69 0x45 num lock
+    70 0x46 scroll lock
+    71 0x47 7 or home on keypad, ext flag is not keypad
+    72 0x48 8 or arrow up on keypad, ext flag is not keypad
+    73 0x49 9 or page up
+    74 0x4a -(minus) on keypad
+    75 0x4b 4 or arrow left on keypad, ext flag is not keypad
+    76 0x4c middle(5 key) of keypad
+    77 0x4d 6 or arrow right, can be on keypad, ext flag in not keypad
+    78 0x4e + on keypad
+    79 0x4f 1 or end
+    80 0x50 2 or arrow down, can be on keypad, ext flag in not keypad
+    81 0x51 3 or page down
+    82 0x52 0 or insert on keypad, ext flag is not keypad
+    83 0x53 . or delete on keypad, ext flag is not keypad
+    84 0x54
+    85 0x55
+    86 0x56
+    87 0x57 F11
+    88 0x58 F12
+    89 0x59
+    90 0x5a
+    91 0x5b left win key ext always on
+    92 0x5c right win key ext always on
+    93 0x5d menu key ext always on
 */

 /* non shift chars */


set the default grid to 3x3 so that one can get to trivial coarse grid if desired

--- c/ch11/fish2.c
+++ c/ch11/fish2.c
@@ -6,7 +6,7 @@
 /* best solve I can get given the memory limitations of my machine:
 PETSC_ARCH=linux-c-opt

-$ timer mpiexec -n 4 ./fish2 -da_refine 9 -ksp_type cg -pc_type mg -ksp_converged_reason -ksp_rtol 1.0e-12
+$ timer mpiexec -n 4 ./fish2 -da_refine FIXME -ksp_type cg -pc_type mg -ksp_converged_reason -ksp_rtol 1.0e-12
   Linear solve converged due to CONVERGED_RTOL iterations 6
 on 4097 x 4097 grid:  error |u-uexact|_inf = 3.00114e-09
 real 21.56
@@ -17,16 +17,16 @@
 compare whether rediscretization happens at each level (former) or Galerkin grid-
 transfer operators are used (latter); needs print statements to tell about residual &
 Jacobian evals:
-$ ./fish2 -da_refine 2 -ksp_type cg -pc_type mg -snes_monitor
-$ ./fish2 -da_refine 2 -ksp_type cg -pc_type mg -snes_monitor -pc_mg_galerkin
+$ ./fish2 -da_refine FIXME -ksp_type cg -pc_type mg -snes_monitor
+$ ./fish2 -da_refine FIXME -ksp_type cg -pc_type mg -snes_monitor -pc_mg_galerkin

 choose which linear solver is used on coarse grid (default is preonly+lu):
-$ ./fish2 -da_refine 3 -ksp_type cg -pc_type mg -mg_coarse_ksp_type cg -mg_coarse_pc_type jacobi -ksp_view|less
+$ ./fish2 -da_refine FIXME -ksp_type cg -pc_type mg -mg_coarse_ksp_type cg -mg_coarse_pc_type jacobi -ksp_view|less

 speed determined by how many mg levels; MGLEV=3 seems to be optimal here at
 RLEV=5, but at higher refinement (e.g. RLEV=7), MGLEV=RLEV seems optimal;
 has to do with time of coarse solve?
-$ timer ./fish2 -da_refine 5 -ksp_type cg -pc_type mg -pc_mg_levels MGLEV
+$ timer ./fish2 -da_refine FIXME -ksp_type cg -pc_type mg -pc_mg_levels MGLEV
 */

 #include <petsc.h>
@@ -158,7 +158,7 @@

   ierr = DMDACreate2d(COMM,
                DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DMDA_STENCIL_STAR,
-               -9,-9,PETSC_DECIDE,PETSC_DECIDE,1,1,NULL,NULL,&(user.da)); CHKERRQ(ierr);
+               -3,-3,PETSC_DECIDE,PETSC_DECIDE,1,1,NULL,NULL,&(user.da)); CHKERRQ(ierr);
   ierr = DMSetApplicationContext(user.da,&user);CHKERRQ(ierr);
   ierr = DMDAGetLocalInfo(user.da,&info); CHKERRQ(ierr);


clipping

clipping

--- alice4/software/libgl/gl.c
+++ alice4/software/libgl/gl.c
@@ -72,6 +72,18 @@
 {
     for(int i = 0; i < 4; i++)
         out[i] = i1[i] * i2[i];
+}
+
+void vec3f_blend(vec3f i1, vec3f i2, float t, vec3f out)
+{
+    for(int i = 0; i < 3; i++)
+        out[i] = i1[i] * (1 - t) + i2[i] * t;
+}
+
+void vec4f_blend(vec4f i1, vec4f i2, float t, vec4f out)
+{
+    for(int i = 0; i < 4; i++)
+        out[i] = i1[i] * (1 - t) + i2[i] * t;
 }

 void vec4f_add(vec4f i1, vec4f i2, vec4f out)
@@ -1090,27 +1102,74 @@
 };

 enum {
-    CLIP_TRIVIAL_REJECT = -1,
-    CLIP_TRIVIAL_ACCEPT = -2,
+    CLIP_TRIVIAL_REJECT = 0,
+    CLIP_TRIVIAL_ACCEPT = -1,
 };

+long clip_polygon_against_plane(long plane, long n, lit_vertex *input, lit_vertex *output)
+{
+    int sign;
+    int index;
+
+    switch(plane) {
+        case CLIP_NEG_X: sign = -1; index = 0; break;
+        case CLIP_POS_X: sign = 1; index = 0; break;
+        case CLIP_NEG_Y: sign = -1; index = 1; break;
+        case CLIP_POS_Y: sign = 1; index = 1; break;
+        case CLIP_NEG_Z: sign = -1; index = 2; break;
+        case CLIP_POS_Z: sign = 1; index = 2; break;
+    }
+
+    int n2 = 0;
+    lit_vertex* v0;
+    lit_vertex* v1 = &input[n - 1];
+
+    for(int i = 0; i < n; i++) {
+        v0 = v1;
+        v1 = &input[i];
+
+        float p0 = v0->coord[index] * sign;
+        float p1 = v1->coord[index] * sign;
+        float w0 = v0->coord[3];
+        float w1 = v1->coord[3];
+
+        if(p0 < w0) {
+            output[n2++] = *v0;
+        }
+
+        float t = (-p0 + w0) / (-p0 + p1 + w0 - w1);
+        if(t > 0.0001 && t < .9999) {
+            vec4f_blend(v0->coord, v1->coord, t, output[n2].coord);
+            vec4f_blend(v0->color, v1->color, t, output[n2].color);
+            n2++;
+        }
+    }
+    return n2;
+}
+
+int classify_vertex(float *c)
+{
+    int code = 0;
+    if(c[0] < -c[3]) code |= CLIP_NEG_X;
+    if(c[0] > c[3]) code |= CLIP_POS_X;
+    if(c[1] < -c[3]) code |= CLIP_NEG_Y;
+    if(c[1] > c[3]) code |= CLIP_POS_Y;
+    if(c[2] < -c[3]) code |= CLIP_NEG_Z;
+    if(c[2] > c[3]) code |= CLIP_POS_Z;
+    return code;
+}
+
 long clip_polygon(long n, lit_vertex *input, lit_vertex *output)
 {
     static int code[POLY_MAX];
+    static lit_vertex tmp[POLY_MAX];
     int all_neg[3] = {1, 1, 1};
     int all_pos[3] = {1, 1, 1};
     int all_inside = 1;
     int all_outside_one = 0xff;

     for(int i = 0; i < n; i++) {
-        float *c = input[i].coord;
-        code[i] = 0;
-        if(c[0] < -c[3]) code[i] |= CLIP_NEG_X;
-        if(c[0] > c[3]) code[i] |= CLIP_POS_X;
-        if(c[1] < -c[3]) code[i] |= CLIP_NEG_Y;
-        if(c[1] > c[3]) code[i] |= CLIP_POS_Y;
-        if(c[2] < -c[3]) code[i] |= CLIP_NEG_Z;
-        if(c[2] > c[3]) code[i] |= CLIP_POS_Z;
+        code[i] = classify_vertex(input[i].coord);
         all_inside = all_inside && (code[i] == CLIP_ALL_IN);
         all_outside_one &= code[i];
     }
@@ -1121,24 +1180,19 @@
     if(all_outside_one)
         return CLIP_TRIVIAL_REJECT;

-    lit_vertex *v0;
-    int code0;
-    lit_vertex *v1 = &input[n - 1];
-    int code1 = code[n - 1];
-    int n2 = 0;
-    for(int i = 0; i < n; i++) {
-        v0 = v1;
-        v1 = &input[i];
-
-        code0 = code1;
-        code1 = code[i];
-
-        if(code0 == CLIP_ALL_IN)
-            output[n2++] = *v0;
-
-        /* clip segment against 6 planes of unit volume */
-    }
-    return n2;
+    n = clip_polygon_against_plane(CLIP_NEG_X, n, input, tmp);
+    if(n == 0) return 0;
+    n = clip_polygon_against_plane(CLIP_POS_X, n, tmp, output);
+    if(n == 0) return 0;
+    n = clip_polygon_against_plane(CLIP_NEG_Y, n, output, tmp);
+    if(n == 0) return 0;
+    n = clip_polygon_against_plane(CLIP_POS_Y, n, tmp, output);
+    if(n == 0) return 0;
+    n = clip_polygon_against_plane(CLIP_NEG_Z, n, output, tmp);
+    if(n == 0) return 0;
+    n = clip_polygon_against_plane(CLIP_POS_Z, n, tmp, output);
+
+    return n;
 }

 // XXX IrisGL polys can be concave; not handled.  see concave()


redo tw download handlers to use a valid object check

fix T1544

--- src/modules/teamwork/e_mod_tw.c
+++ src/modules/teamwork/e_mod_tw.c
@@ -21,6 +21,7 @@

 typedef struct Media
 {
+   Mod *mod;
    EINA_INLIST;
    Ecore_Con_Url *client;
    Eina_Binbuf *buf;
@@ -133,10 +134,10 @@
 download_media_complete(void *data, int type EINA_UNUSED, Ecore_Con_Event_Url_Complete *ev)
 {
    Media *i;
-
-   if (data != tw_mod) return ECORE_CALLBACK_RENEW;
-   i = ecore_con_url_data_get(ev->url_con);
-   if (!i) return ECORE_CALLBACK_DONE;
+   void **test = ecore_con_url_data_get(ev->url_con);
+
+   if ((!test) || (*test != tw_mod)) return ECORE_CALLBACK_RENEW;
+   i = test;
    if (!i->valid) return ECORE_CALLBACK_DONE;
    i->timestamp = (unsigned long long)ecore_time_unix_get();
    if (tw_media_add(i->addr, i->buf, i->timestamp, i->video) == 1)
@@ -152,10 +153,10 @@
 download_media_data(void *data, int type EINA_UNUSED, Ecore_Con_Event_Url_Data *ev)
 {
    Media *i;
-
-   if (data != tw_mod) return ECORE_CALLBACK_RENEW;
-   i = ecore_con_url_data_get(ev->url_con);
-   if (!i) return ECORE_CALLBACK_DONE;
+   void **test = ecore_con_url_data_get(ev->url_con);
+
+   if ((!test) || (*test != tw_mod)) return ECORE_CALLBACK_RENEW;
+   i = test;
    if (i->dummy) return ECORE_CALLBACK_DONE;
    if (!i->buf) i->buf = eina_binbuf_new();
    eina_binbuf_append_length(i->buf, ev->data, ev->size);
@@ -169,10 +170,10 @@
    const char *h;
    Media *i;
    const Eina_List *l;
-
-   if (data != tw_mod) return ECORE_CALLBACK_RENEW;
-   i = ecore_con_url_data_get(ev->url_con);
-   if (!i) return ECORE_CALLBACK_DONE;
+   void **test = ecore_con_url_data_get(ev->url_con);
+
+   if ((!test) || (*test != tw_mod)) return ECORE_CALLBACK_RENEW;
+   i = test;

    if (i->valid)
      {
@@ -271,6 +272,7 @@
         if (tw_config->disable_media_fetch) return NULL;
         add = EINA_TRUE;
         i = calloc(1, sizeof(Media));
+        i->mod = tw_mod;
         i->addr = eina_stringshare_add(url);
         i->buf = tw_media_get(url, t, &i->video);
      }


Add sizeof(size_t) assumptions

Add sizeof(size_t) assumptions

--- src/compat/assumptions.h
+++ src/compat/assumptions.h
@@ -40,8 +40,13 @@
 static_assert(sizeof(short) == 2, "16-bit short assumed");
 static_assert(sizeof(int) == 4, "32-bit int assumed");

+// Assumption: We assume size_t to be 32-bit or 64-bit.
+// Example(s): size_t assumed to be at least 32-bit in ecdsa_signature_parse_der_lax(...).
+//             size_t assumed to be 32-bit or 64-bit in MallocUsage(...).
+static_assert(sizeof(size_t) == 4 || sizeof(size_t) == 8, "size_t assumed to be 32-bit or 64-bit");
+static_assert(sizeof(size_t) == sizeof(void*), "Sizes of size_t and void* assumed to be equal");
+
 // Some important things we are NOT assuming (non-exhaustive list):
-// * We are NOT assuming a specific value for sizeof(std::size_t).
 // * We are NOT assuming a specific value for std::endian::native.
 // * We are NOT assuming a specific value for std::locale("").name().
 // * We are NOT assuming a specific value for std::numeric_limits<char>::is_signed.


Update PeCoffExtraActionLib for NT32 to allow an app or driver to be loaded more than once.  Only the first instance will support source level debug.

git-svn-id: 5648d1bec6962b0a6d1d1b40eba8cf5cdb62da3d@9983 6f19259b-4bc3-4df7-8a09-765794883524

--- Nt32Pkg/Library/DxeNt32PeCoffExtraActionLib/DxeNt32PeCoffExtraActionLib.c
+++ Nt32Pkg/Library/DxeNt32PeCoffExtraActionLib/DxeNt32PeCoffExtraActionLib.c
@@ -160,6 +160,16 @@
   PDB_NAME_TO_MOD_HANDLE  *TempArray;
   HANDLE                  Handle;

+  //
+  // Return EFI_ALREADY_STARTED if this DLL has already been loaded
+  //
+  Array = mPdbNameModHandleArray;
+  for (Index = 0; Index < mPdbNameModHandleArraySize; Index++, Array++) {
+    if (Array->PdbPointer != NULL && Array->ModHandle == ModHandle) {
+      return EFI_ALREADY_STARTED;
+    }
+  }
+
   Array = mPdbNameModHandleArray;
   for (Index = 0; Index < mPdbNameModHandleArraySize; Index++, Array++) {
     if (Array->PdbPointer == NULL) {
@@ -266,6 +276,7 @@
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext
   )
 {
+  EFI_STATUS        Status;
   VOID              *DllEntryPoint;
   CHAR16            *DllFileName;
   HMODULE           Library;
@@ -333,10 +344,24 @@
     }

     if ((Library != NULL) && (DllEntryPoint != NULL)) {
-      AddModHandle (ImageContext, Library);
-      ImageContext->EntryPoint  = (EFI_PHYSICAL_ADDRESS) (UINTN) DllEntryPoint;
-      DEBUG ((EFI_D_INFO, "LoadLibraryEx (%s,\n               NULL, DONT_RESOLVE_DLL_REFERENCES)\n", DllFileName));
+      Status = AddModHandle (ImageContext, Library);
+      if (Status == EFI_ALREADY_STARTED) {
+        //
+        // If the DLL has already been loaded before, then this instance of the DLL can not be debugged.
+        //
+        ImageContext->PdbPointer = NULL;
+        DEBUG ((EFI_D_ERROR, "WARNING: DLL already loaded.  No source level debug %s. \n", DllFileName));
+      } else {
+        //
+        // This DLL is not already loaded, so source level debugging is suported.
+        //
+        ImageContext->EntryPoint  = (EFI_PHYSICAL_ADDRESS) (UINTN) DllEntryPoint;
+        DEBUG ((EFI_D_INFO, "LoadLibraryEx (%s,\n               NULL, DONT_RESOLVE_DLL_REFERENCES)\n", DllFileName));
+      }
     } else {
+      //
+      // This DLL does not support source level debugging at all.
+      //
       DEBUG ((EFI_D_ERROR, "WARNING: No source level debug %s. \n", DllFileName));
     }


Fixed indentation in macro blocks

Fixed indentation in macro blocks

--- internal.c
+++ internal.c
@@ -237,91 +237,91 @@

   left = json_array_size (in);
   json_array_foreach (in, index, value)
-  {
-    switch (json_typeof (value))
-      {
-      case JSON_STRING:
-	if (escape_strings)
-	  {
-	    const char *s = json_string_value (value);
-	    bool stillquote = quote;
-	    if (quote && !(stillquote = '\\' != *s))
-	      ++s;
-	    rc = escape (srv, s, temp, n, stillquote);
-	  }
-	else
-	  {
-	    strcpy (temp, json_string_value (value));
-	  }
+    {
+      switch (json_typeof (value))
+	{
+	case JSON_STRING:
+	  if (escape_strings)
+	    {
+	      const char *s = json_string_value (value);
+	      bool stillquote = quote;
+	      if (quote && !(stillquote = '\\' != *s))
+		++s;
+	      rc = escape (srv, s, temp, n, stillquote);
+	    }
+	  else
+	    {
+	      strcpy (temp, json_string_value (value));
+	    }
+	  break;
+
+	case JSON_INTEGER:
+	  rc = snprintf (temp, n, "%" JSON_INTEGER_FORMAT,
+			 json_integer_value (value));
+	  if ((size_t) rc >= n)
+	    rc = SQON_OVERFLOW;
+	  else
+	    rc = 0;
+	  break;
+
+	case JSON_REAL:
+	  rc = snprintf (temp, n, "%f", json_real_value (value));
+	  if ((size_t) rc >= n)
+	    rc = SQON_OVERFLOW;
+	  else
+	    rc = 0;
+	  break;
+
+	case JSON_TRUE:
+	  rc = snprintf (temp, n, "1");
+	  if ((size_t) rc >= n)
+	    rc = SQON_OVERFLOW;
+	  else
+	    rc = 0;
+	  break;
+
+	case JSON_FALSE:
+	  rc = snprintf (temp, n, "0");
+	  if ((size_t) rc >= n)
+	    rc = SQON_OVERFLOW;
+	  else
+	    rc = 0;
+	  break;
+
+	case JSON_NULL:
+	  rc = snprintf (temp, n, "'NULL'");
+	  if ((size_t) rc >= n)
+	    rc = SQON_OVERFLOW;
+	  else
+	    rc = 0;
+	  break;
+
+	default:
+	  rc = SQON_UNSUPPORTED;
+	  break;
+	}
+
+      if (rc)
 	break;
-
-      case JSON_INTEGER:
-	rc = snprintf (temp, n, "%" JSON_INTEGER_FORMAT,
-		       json_integer_value (value));
-	if ((size_t) rc >= n)
-	  rc = SQON_OVERFLOW;
-	else
-	  rc = 0;
-	break;
-
-      case JSON_REAL:
-	rc = snprintf (temp, n, "%f", json_real_value (value));
-	if ((size_t) rc >= n)
-	  rc = SQON_OVERFLOW;
-	else
-	  rc = 0;
-	break;
-
-      case JSON_TRUE:
-	rc = snprintf (temp, n, "1");
-	if ((size_t) rc >= n)
-	  rc = SQON_OVERFLOW;
-	else
-	  rc = 0;
-	break;
-
-      case JSON_FALSE:
-	rc = snprintf (temp, n, "0");
-	if ((size_t) rc >= n)
-	  rc = SQON_OVERFLOW;
-	else
-	  rc = 0;
-	break;
-
-      case JSON_NULL:
-	rc = snprintf (temp, n, "'NULL'");
-	if ((size_t) rc >= n)
-	  rc = SQON_OVERFLOW;
-	else
-	  rc = 0;
-	break;
-
-      default:
-	rc = SQON_UNSUPPORTED;
-	break;
-      }
-
-    if (rc)
-      break;
-
-    written += strlen (temp);
-
-    if (--left > 0)
-      {
-	if (written + clen < n)
-	  {
-	    strcat (temp, c);
-	    written += clen;
-	  }
-	else
-	  {
-	    break;
-	  }
-      }
-
-    strcat (out, temp);
-  }
-
+
+      written += strlen (temp);
+
+      if (--left > 0)
+	{
+	  if (written + clen < n)
+	    {
+	      strcat (temp, c);
+	      written += clen;
+	    }
+	  else
+	    {
+	      break;
+	    }
+	}
+
+      strcat (out, temp);
+    }
+
   free (temp);
   json_decref (in);
   return rc;
@@ -365,64 +365,64 @@
     }

   json_array_foreach (in, index, value)
-  {
-    switch (json_typeof (value))
-      {
-      case JSON_OBJECT:
-	cols = json_array ();
-	if (NULL == cols)
-	  {
-	    rc = SQON_MEMORYERROR;
-	    break;
-	  }
-	vals = json_array ();
-	if (NULL == vals)
-	  {
-	    json_decref (cols);
-	    rc = SQON_MEMORYERROR;
-	    break;
-	  }
+    {
+      switch (json_typeof (value))
+	{
+	case JSON_OBJECT:
+	  cols = json_array ();
+	  if (NULL == cols)
+	    {
+	      rc = SQON_MEMORYERROR;
+	      break;
+	    }
+	  vals = json_array ();
+	  if (NULL == vals)
+	    {
+	      json_decref (cols);
+	      rc = SQON_MEMORYERROR;
+	      break;
+	    }

-	const char *objkey;
-	json_t *objval;
-	json_object_foreach (value, objkey, objval)
-	  {
-	    rc = json_array_append_new (cols, json_string (objkey));
-	    if (rc)
-	      {
-		rc = SQON_MEMORYERROR;
+	  const char *objkey;
+	  json_t *objval;
+	  json_object_foreach (value, objkey, objval)
+	    {
+	      rc = json_array_append_new (cols, json_string (objkey));
+	      if (rc)
+		{
+		  rc = SQON_MEMORYERROR;
+		  break;
+		}
+
+	      rc = json_array_append (vals, objval);
+	      if (rc)
+		{
+		  rc = SQON_MEMORYERROR;
+		  break;
+		}
+	    }
+
+	  if (!rc)
+	    {
+	      rc = json_to_csv (srv, cols, columns, n, true, false);
+	      if (rc)
 		break;
-	      }
-
-	    rc = json_array_append (vals, objval);
-	    if (rc)
-	      {
-		rc = SQON_MEMORYERROR;
+	      rc = json_to_csv (srv, vals, values, n, true, true);
+	      if (rc)
 		break;
-	      }
-	  }
-
-	if (!rc)
-	  {
-	    rc = json_to_csv (srv, cols, columns, n, true, false);
-	    if (rc)
-	      break;
-	    rc = json_to_csv (srv, vals, values, n, true, true);
-	    if (rc)
-	      break;
-	  }
-	json_decref (cols);
-	json_decref (vals);
+	    }
+	  json_decref (cols);
+	  json_decref (vals);
+	  break;
+
+	default:
+	  rc = SQON_UNSUPPORTED;
+	  break;
+	}
+
+      if (rc)
 	break;
-
-      default:
-	rc = SQON_UNSUPPORTED;
-	break;
-      }
-
-    if (rc)
-      break;
-  }
+    }

   rc = snprintf (out, n, fmt, table, columns, values);
   if ((size_t) rc >= n)
@@ -472,61 +472,61 @@
   *out = '\0'; /* prevent appending to existing string in buffer */

   json_object_foreach (root, key, value)
-  {
-    if (!strcmp (key, "insert"))
-      {
-	if (json_is_object (value))
-	  {
-	    json_object_foreach (value, subkey, subvalue)
-	    {
-	      rc = insert (srv, subkey, subvalue, temp, n);
+    {
+      if (!strcmp (key, "insert"))
+	{
+	  if (json_is_object (value))
+	    {
+	      json_object_foreach (value, subkey, subvalue)
+		{
+		  rc = insert (srv, subkey, subvalue, temp, n);
+		  if (rc)
+		    break;
+		  if ((towrite = written + strlen (temp)) < n)
+		    {
+		      if ('\0' != *out)
+			if ((towrite += slen) < n)
+			  {
+			    strcat (out, semi);
+			    written += slen;
+			  }
+		      strcat (out, temp);
+		      written += strlen (temp);
+		    }
+		  else
+		    {
+		      rc = SQON_OVERFLOW;
+		      break;
+		    }
+		}
+
 	      if (rc)
 		break;
-	      if ((towrite = written + strlen (temp)) < n)
-		{
-		  if ('\0' != *out)
-		    if ((towrite += slen) < n)
-		      {
-			strcat (out, semi);
-			written += slen;
-		      }
-		  strcat (out, temp);
-		  written += strlen (temp);
-		}
-	      else
-		{
-		  rc = SQON_OVERFLOW;
-		  break;
-		}
-	    }
-
-	    if (rc)
+	    }
+	  else
+	    {
+	      rc = SQON_TYPEERROR;
 	      break;
-	  }
-	else
-	  {
-	    rc = SQON_TYPEERROR;
-	    break;
-	  }
-      }
-    else if (!strcmp (key, "update"))
-      {
-      }
-    else if (!strcmp (key, "select"))
-      {
-      }
-    else if (!strcmp (key, "call"))
-      {
-      }
-    else if (!strcmp (key, "grant") || !strcmp (key, "revoke"))
-      {
-      }
-    else
-      {
-	rc = SQON_UNSUPPORTED;
-	break;
-      }
-  }
+	    }
+	}
+      else if (!strcmp (key, "update"))
+	{
+	}
+      else if (!strcmp (key, "select"))
+	{
+	}
+      else if (!strcmp (key, "call"))
+	{
+	}
+      else if (!strcmp (key, "grant") || !strcmp (key, "revoke"))
+	{
+	}
+      else
+	{
+	  rc = SQON_UNSUPPORTED;
+	  break;
+	}
+    }

   free (temp);
   json_decref (root);


rdpdr/rpddr_check_fds: remove code duplication

Signed-off-by: Otavio Salvador <1d31b11c1b92bf5d043d36edfe7174db39a6b891@ossystems.com.br>

--- channels/rdpdr/rdpdr_main.c
+++ channels/rdpdr/rdpdr_main.c
@@ -423,11 +423,7 @@
 				if (irp_get_event(pending, &result))
 				{
 					pending->ioStatus = RD_STATUS_SUCCESS;
-					out = irp_output_device_io_completion(pending, &out_size);
-					error = plugin->ep.pVirtualChannelWrite(plugin->open_handle, out, out_size, out);
-					if (pending->outputBuffer)
-						free(pending->outputBuffer);
-					isset = 2;
+					isset = 1;
 				}
 				break;

@@ -436,7 +432,7 @@
 				break;
 		}

-		if (isset == 1)
+		if (isset)
 		{
 			out = irp_output_device_io_completion(pending, &out_size);
 			error = plugin->ep.pVirtualChannelWrite(plugin->open_handle, out, out_size, out);