Clarification of dox docs for 3D range observation

--- libs/obs/include/mrpt/obs/CObservation3DRangeScan.h
+++ libs/obs/include/mrpt/obs/CObservation3DRangeScan.h
@@ -33,8 +33,8 @@
 		void project3DPointsFromDepthImageInto(CObservation3DRangeScan    & src_obs,POINTMAP                   & dest_pointcloud,const bool                   takeIntoAccountSensorPoseOnRobot,const mrpt::poses::CPose3D * robotPoseInTheWorld,const bool                   PROJ3D_USE_LUT);
 	}

-	/** Declares a class derived from "CObservation" that
-	 *      encapsules a 3D range scan measurement (e.g. from a time of flight range camera).
+	/** Declares a class derived from "CObservation" that encapsules a 3D range scan measurement, as from a time-of-flight range camera or any other RGBD sensor.
+	 *
 	 *  This kind of observations can carry one or more of these data fields:
 	 *    - 3D point cloud (as float's).
 	 *    - 2D range image (as a matrix): Each entry in the matrix "rangeImage(ROW,COLUMN)" contains a distance or a depth (in meters), depending on \a range_is_depth.
@@ -223,7 +223,8 @@
 		/** Use this method instead of resizing all three \a points3D_x, \a points3D_y & \a points3D_z to allow the usage of the internal memory pool. */
 		void resizePoints3DVectors(const size_t nPoints);

-		// 3D points external storage functions ---------
+		/** \name 3D points external storage functions
+		  * @{ */
 		inline bool points3D_isExternallyStored() const { return m_points3D_external_stored; }
 		inline std::string points3D_getExternalStorageFile() const { return m_points3D_external_file; }
 		void points3D_getExternalStorageFileAbsolutePath(std::string &out_path) const;
@@ -233,15 +234,19 @@
 				return tmp;
 		}
 		void points3D_convertToExternalStorage( const std::string &fileName, const std::string &use_this_base_dir ); //!< Users won't normally want to call this, it's only used from internal MRPT programs.
-		// ---------
-
+		/** @} */
+
+		/** \name Range (depth) image
+		  * @{ */
 		bool hasRangeImage; 				//!< true means the field rangeImage contains valid data
 		mrpt::math::CMatrix rangeImage; 	//!< If hasRangeImage=true, a matrix of floats with the range data as captured by the camera (in meters) \sa range_is_depth
 		bool range_is_depth;				//!< true: Kinect-like ranges: entries of \a rangeImage are distances along the +X axis; false: Ranges in \a rangeImage are actual distances in 3D.

 		void rangeImage_setSize(const int HEIGHT, const int WIDTH); //!< Similar to calling "rangeImage.setSize(H,W)" but this method provides memory pooling to speed-up the memory allocation.
-
-		// Range Matrix external storage functions ---------
+		/** @} */
+
+		/** \name Range Matrix external storage functions
+		  * @{ */
 		inline bool rangeImage_isExternallyStored() const { return m_rangeImage_external_stored; }
 		inline std::string rangeImage_getExternalStorageFile() const { return m_rangeImage_external_file; }
 		void rangeImage_getExternalStorageFileAbsolutePath(std::string &out_path) const;
@@ -253,8 +258,11 @@
 		void rangeImage_convertToExternalStorage( const std::string &fileName, const std::string &use_this_base_dir ); //!< Users won't normally want to call this, it's only used from internal MRPT programs.
 		/** Forces marking this observation as non-externally stored - it doesn't anything else apart from reseting the corresponding flag (Users won't normally want to call this, it's only used from internal MRPT programs) */
 		void rangeImage_forceResetExternalStorage() { m_rangeImage_external_stored=false; }
-		// ---------
-
+		/** @} */
+
+
+		/** \name Intensity (RGB) channels
+		  * @{ */
 		/** Enum type for intensityImageChannel */
 		enum TIntensityChannelID
 		{
@@ -265,10 +273,16 @@
 		bool hasIntensityImage;                    //!< true means the field intensityImage contains valid data
 		mrpt::utils::CImage intensityImage;        //!< If hasIntensityImage=true, a color or gray-level intensity image of the same size than "rangeImage"
 		TIntensityChannelID intensityImageChannel; //!< The source of the intensityImage; typically the visible channel \sa TIntensityChannelID
-
+		/** @} */
+
+		/** \name Confidence "channel"
+		  * @{ */
 		bool hasConfidenceImage; 			//!< true means the field confidenceImage contains valid data
 		mrpt::utils::CImage confidenceImage;  //!< If hasConfidenceImage=true, an image with the "confidence" value [range 0-255] as estimated by the capture drivers.
-
+		/** @} */
+
+		/** \name Sensor parameters
+		  * @{ */
 		mrpt::utils::TCamera	cameraParams;	//!< Projection parameters of the depth camera.
 		mrpt::utils::TCamera	cameraParamsIntensity;	//!< Projection parameters of the intensity (graylevel or RGB) camera.

@@ -284,7 +298,6 @@
 		  */
 		bool doDepthAndIntensityCamerasCoincide() const;

-
 		float  	maxRange;	//!< The maximum range allowed by the device, in meters (e.g. 8.0m, 5.0m,...)
 		mrpt::poses::CPose3D	sensorPose;	//!< The 6D pose of the sensor on the robot.
 		float	stdError;	//!< The "sigma" error of the device in meters, used while inserting the scan in an occupancy grid.
@@ -293,6 +306,9 @@
 		void getSensorPose( mrpt::poses::CPose3D &out_sensorPose ) const { out_sensorPose = sensorPose; }
 		// See base class docs
 		void setSensorPose( const mrpt::poses::CPose3D &newSensorPose ) { sensorPose = newSensorPose; }
+
+		/** @} */  // end sensor params
+
 		// See base class docs
 		virtual void getDescriptionAsText(std::ostream &o) const;


Increased msInFullTurn

Increased msInFullTurn

--- Libraries/declarations.h
+++ Libraries/declarations.h
@@ -52,7 +52,7 @@
 const int extraSwipeSteps = 3;
 const int noCylFound = -1;
 const int rotationSpeed = 25;
-const int msInFullTurn = 8000;
+const int msInFullTurn = 8500;
 const int nMeasurements = 50;
 const int msPerStep = msInFullTurn / nMeasurements;
 int  measurements[nMeasurements];


fetch: Future-proof initialization of a refspec on stack

The open-coded version to initialize each and every member will break
when a new member is added to the structure.

Signed-off-by: Andreas Gruenbacher <803c310a1424fde72669c00c857729354974bc9f@suse.de>
Signed-off-by: Junio C Hamano <a6723cc3f76163bf7adb636a73ac3b0ceb3e6b9b@pobox.com>

--- builtin-fetch.c
+++ builtin-fetch.c
@@ -104,10 +104,8 @@
 		 * there is no entry in the resulting FETCH_HEAD marked
 		 * for merging.
 		 */
+		memset(&refspec, 0, sizeof(refspec));
 		refspec.src = branch->merge[i]->src;
-		refspec.dst = NULL;
-		refspec.pattern = 0;
-		refspec.force = 0;
 		get_fetch_map(remote_refs, &refspec, tail, 1);
 		for (rm = *old_tail; rm; rm = rm->next)
 			rm->merge = 1;


apply: fix an incomplete comment in check_patch()

This check is not only about type-change (for which it would be
sufficient to check only was_deleted()) but is also about a swap
rename.  Otherwise to_be_deleted() check is not justified.

Signed-off-by: Junio C Hamano <a6723cc3f76163bf7adb636a73ac3b0ceb3e6b9b@pobox.com>

--- builtin/apply.c
+++ builtin/apply.c
@@ -3218,16 +3218,22 @@
 		return status;
 	old_name = patch->old_name;

+	/*
+	 * A type-change diff is always split into a patch to delete
+	 * old, immediately followed by a patch to create new (see
+	 * diff.c::run_diff()); in such a case it is Ok that the entry
+	 * to be deleted by the previous patch is still in the working
+	 * tree and in the index.
+	 *
+	 * A patch to swap-rename between A and B would first rename A
+	 * to B and then rename B to A.  While applying the first one,
+	 * the presense of B should not stop A from getting renamed to
+	 * B; ask to_be_deleted() about the later rename.  Removal of
+	 * B and rename from A to B is handled the same way by asking
+	 * was_deleted().
+	 */
 	if ((tpatch = in_fn_table(new_name)) &&
-			(was_deleted(tpatch) || to_be_deleted(tpatch)))
-		/*
-		 * A type-change diff is always split into a patch to
-		 * delete old, immediately followed by a patch to
-		 * create new (see diff.c::run_diff()); in such a case
-		 * it is Ok that the entry to be deleted by the
-		 * previous patch is still in the working tree and in
-		 * the index.
-		 */
+	    (was_deleted(tpatch) || to_be_deleted(tpatch)))
 		ok_if_exists = 1;
 	else
 		ok_if_exists = 0;


main: Use a perpective projection for the shadow render

--- src/es-main.c
+++ src/es-main.c
@@ -35,8 +35,11 @@

   /* shadow mapping */
   CoglOffscreen *shadow_fb;
-  CoglTexture2D *shadow_color_buffer;
+  CoglTexture2D *shadow_color;
   CoglTexture   *shadow_map;
+
+  CoglPipeline *shadow_color_tex;
+  CoglPipeline *shadow_map_tex;
 } Cube;

 static Cube cube;
@@ -61,6 +64,24 @@
 {
   return (int64_t) (g_timer_elapsed (timer, NULL) * 1e6);
 }
+
+static CoglPipeline *
+create_texture_pipeline (CoglTexture *texture)
+{
+  static CoglPipeline *template = NULL, *new_pipeline;
+
+  if (G_UNLIKELY (template == NULL))
+    {
+      template = cogl_pipeline_new (context);
+      cogl_pipeline_set_layer_null_texture (template, 0, COGL_TEXTURE_TYPE_2D);
+    }
+
+  new_pipeline = cogl_pipeline_copy (template);
+  cogl_pipeline_set_layer_texture (new_pipeline, 0, texture);
+
+  return new_pipeline;
+}
+

 static void
 draw_entities (Cube *cube,
@@ -109,12 +130,11 @@
   /* the light position is hardcoded for now */
   cogl_matrix_init_identity (&shadow_transform);
   cogl_matrix_look_at (&shadow_transform,
-                       3.f, 0.f, 2.f,     /* light position */
+                       0.f, 1.f, 10.f,     /* light position */
                        .0f, 0.f, 0.f,     /* direction to look at */
                        .0f, 1.f, 0.f);    /* world up */

   cogl_framebuffer_set_modelview_matrix (shadow_fb, &shadow_transform);
-  cogl_framebuffer_scale (shadow_fb, 2, 2, 2);

   draw_entities (cube, shadow_fb);

@@ -150,12 +170,21 @@

   /* draw the color and depth buffers of the shadow FBO to debug it */
 #if 0
-  cogl_set_source_texture (COGL_TEXTURE (cube->shadow_color_buffer));
+  cogl_push_framebuffer (cube->fb);
+  cogl_set_source_texture (COGL_TEXTURE (cube->shadow_color));
   cogl_rectangle (-4, 3, -2, 1);

   cogl_set_source_texture (COGL_TEXTURE (cube->shadow_map));
   cogl_rectangle (-4, 1, -2, -1);
+  cogl_pop_framebuffer ();
 #endif
+
+  /* draw the color and depth buffers of the shadow FBO to debug them */
+
+  cogl_framebuffer_draw_rectangle (cube->fb, cube->shadow_color_tex,
+                                   -4, 3, -2, 1);
+  cogl_framebuffer_draw_rectangle (cube->fb, cube->shadow_map_tex,
+                                   -4, 1, -2, -1);

   cogl_framebuffer_pop_matrix (cube->fb);

@@ -460,7 +489,7 @@
     if (error)
       g_critical ("could not create texture: %s", error->message);

-    cube.shadow_color_buffer = color_buffer;
+    cube.shadow_color = color_buffer;

     /* XXX: Right now there's no way to disable rendering to the the color
      * buffer. */
@@ -468,10 +497,16 @@
         cogl_offscreen_new_to_texture (COGL_TEXTURE (color_buffer));

     /* directional light -> orthographic perspective */
+#if 0
     cogl_framebuffer_orthographic (COGL_FRAMEBUFFER (cube.shadow_fb),
-                                   5.f, 5.f, -5.f, -5.f, -5.f, 5.f);
-#if 0
+                                   10.f, 10.f, -10.f, -10.f, -15.f, 15.f);
+
 #endif
+    cogl_framebuffer_perspective (COGL_FRAMEBUFFER (cube.shadow_fb),
+                                  60.f, /* fov */
+                                  1.0,  /* aspect ratio */
+                                  3.f,  /* near */
+                                  20); /* far */

     /* retrieve the depth texture */
     cogl_framebuffer_enable_depth_texture (COGL_FRAMEBUFFER (cube.shadow_fb),
@@ -483,6 +518,12 @@
       g_critical ("could not create offscreen buffer");
   }

+  /* create the pipelines to display the shadow color and depth textures */
+  cube.shadow_color_tex =
+      create_texture_pipeline (COGL_TEXTURE (cube.shadow_color));
+  cube.shadow_map_tex =
+      create_texture_pipeline (COGL_TEXTURE (cube.shadow_map));
+
   cogl_object_unref (pipeline1);
   cogl_object_unref (pipeline2);


todo comments

todo comments

--- Library/Sources/Stroika/Foundation/Containers/DataHyperRectangle.h
+++ Library/Sources/Stroika/Foundation/Containers/DataHyperRectangle.h
@@ -17,6 +17,9 @@
  *  \version    Alpha-Early
  *
  *  TODO:
+ *
+ *      @todo https://stroika.atlassian.net/browse/STK-580 - get DataHyperRectangle to the point where it is minimally usable!
+ *
  *      @todo DataHyperRectangle_Sparse<> and DataHyperRectangle_Dense<>
  *            and then make DataHyperRectangle/0 deleted - so must specify one of those
  *            types. They have differnt bahvior with respect to iteration and size, and typically


cosmetic

cosmetic

--- Library/Sources/Stroika/Foundation/Database/SQL/EngineProperties.h
+++ Library/Sources/Stroika/Foundation/Database/SQL/EngineProperties.h
@@ -5,6 +5,8 @@
 #define _Stroika_Foundation_Database_SQL_EngineProperties_h_ 1

 #include "../../StroikaPreComp.h"
+
+#include <string_view>

 #include "../../Characters/String.h"

@@ -42,7 +44,13 @@
         virtual String GetEngineName () const = 0;

     public:
-        static constexpr inline wstring_view kDoesTableExistParameterName{L":TABLENAME"};
+        /**
+         */
+        static constexpr inline wstring_view kDoesTableExistParameterName{L":TABLENAME"sv};
+
+    public:
+        /**
+         */
         enum NonStandardSQL {
             // variable name for parameter is :TABLENAME
             // @todo docs return


Add some getters.

Add some getters.

--- src/cis-splice-effects/cis_splice_effects_identifier.h
+++ src/cis-splice-effects/cis_splice_effects_identifier.h
@@ -75,6 +75,14 @@
         void set_ostream();
         //Close ofstream object
         void close_ostream();
+        //Get the window size
+        uint32_t window_size() { return window_size_; }
+        //Get the annotated variants file(VCF)
+        string annotated_variant_file() { return annotated_variant_file_; }
+        //Get the file with splice junctions(BED)
+        string output_file() { return output_file_; }
+        //Get the Input VCF
+        string vcf() { return vcf_; }
 };

 const string non_splice_region_annotation_string = "NA";


Add test for HGET returning nil

Add test for HGET returning nil

--- src/test/hash.c
+++ src/test/hash.c
@@ -88,6 +88,14 @@
 	}
 	rliteFreeReplyObject(reply);

+	char *argv3[100] = {"hget", "mykey", "non existing field", NULL};
+	reply = rliteCommandArgv(context, populateArgvlen(argv3, argvlen), argv3, argvlen);
+	if (reply->type != RLITE_REPLY_NIL) {
+		fprintf(stderr, "Expected reply to be NIL, got %d instead on line %d\n", reply->type, __LINE__);
+		return 1;
+	}
+	rliteFreeReplyObject(reply);
+
 	rliteFree(context);
 	return 0;
 }


add missing #include

add missing #include

--- src/text_proc.c
+++ src/text_proc.c
@@ -15,6 +15,7 @@
  */

 #include <assert.h>
+#include <stdlib.h>
 #include <string.h>
 #include "corpus/src/table.h"
 #include "corpus/src/text.h"


Fixed compile error on curses from previous commit; src/textadept.c

--- src/textadept.c
+++ src/textadept.c
@@ -989,12 +989,12 @@
     gtk_widget_hide(new_menubar);
 #endif
 #endif
-  } else if (strcmp(key, "maximized") == 0)
+  } else if (strcmp(key, "maximized") == 0) {
 #if GTK
     lua_toboolean(L, 3) ? gtk_window_maximize(GTK_WINDOW(window))
                         : gtk_window_unmaximize(GTK_WINDOW(window));
 #endif
-  else if (strcmp(key, "size") == 0) {
+  } else if (strcmp(key, "size") == 0) {
 #if GTK
     luaL_argcheck(L, lua_istable(L, 3) && lua_rawlen(L, 3) == 2, 3,
                   "{ width, height } table expected");


fixed comment and minor cosmetic tweaks.

--- src/appleseed/renderer/kernel/intersection/curvekey.h
+++ src/appleseed/renderer/kernel/intersection/curvekey.h
@@ -48,23 +48,23 @@
     // Constructors.
     CurveKey();
     CurveKey(
-        const size_t        object_instance_index,
-        const size_t        curve_index,
-        const size_t        curve_pa);
+        const size_t    object_instance_index,
+        const size_t    curve_index,
+        const size_t    curve_pa);

     // Return the index of the object instance within the assembly.
     size_t get_object_instance_index() const;

-    // Return the index of the curve within the assembly.
+    // Return the index of the curve within the object.
     size_t get_curve_index() const;

     // Return the primitive attribute index of the curve.
     size_t get_curve_pa() const;

   private:
-    foundation::uint32 m_object_instance_index;
-    foundation::uint32 m_curve_index;
-    foundation::uint16 m_curve_pa;
+    foundation::uint32  m_object_instance_index;
+    foundation::uint32  m_curve_index;
+    foundation::uint16  m_curve_pa;
 };

@@ -77,9 +77,9 @@
 }

 inline CurveKey::CurveKey(
-    const size_t            object_instance_index,
-    const size_t            curve_index,
-    const size_t            curve_pa)
+    const size_t        object_instance_index,
+    const size_t        curve_index,
+    const size_t        curve_pa)
   : m_object_instance_index(static_cast<foundation::uint32>(object_instance_index))
   , m_curve_index(static_cast<foundation::uint32>(curve_index))
   , m_curve_pa(static_cast<foundation::uint16>(curve_pa))


git-svn-id: https://www.imagemagick.org/subversion/ImageMagick/trunk@12191 aa41f4f7-0bf4-0310-aa73-e5a19afd5a74


:paint: Include RCTBridge.h

:paint: Include RCTBridge.h

--- local-cli/generator-osx/templates/app/AppDelegate.h
+++ local-cli/generator-osx/templates/app/AppDelegate.h
@@ -7,11 +7,12 @@
  * of patent rights can be found in the PATENTS file in the same directory.
  */

- #import <Cocoa/Cocoa.h>
+#import <Cocoa/Cocoa.h>
+#import "RCTBridge.h"

- @interface AppDelegate : NSObject <NSApplicationDelegate, NSWindowDelegate>
+@interface AppDelegate : NSObject <NSApplicationDelegate, NSWindowDelegate>

- @property (strong, nonatomic) NSWindow *window;
- @property (nonatomic, readonly) RCTBridge *bridge;
+@property (strong, nonatomic) NSWindow *window;
+@property (nonatomic, readonly) RCTBridge *bridge;

- @end
+@end


Add a simple progress meter with --verbose

Just displays dots "." while commands are being processed, so the user
knows the process hasn't crashed yet

--- src/sync_to.h
+++ src/sync_to.h
@@ -250,6 +250,10 @@
 		while (!finished) {
 			sync_queue.check_aborted(); // check each iteration, rather than wait until the end of the current table; this is a good place to do it since it's likely we'll have no work to do for a short while

+			if (verbose) {
+				cout << "." << flush; // simple progress meter
+			}
+
 			verb_t verb;
 			input >> verb;


fix realloc bug

fix realloc bug

--- src/memory.c
+++ src/memory.c
@@ -69,7 +69,9 @@
     void* buf = malloc(size);
     if (!buf) return NULL;
     malloc_header_t* entry = (malloc_header_t*) ((uint8_t*) ptr - header_len);
-    memcpy(buf, ptr, entry->length);
+    size_t orig_size = entry->length;
+    size_t min_size = size > orig_size ? orig_size : size;
+    memcpy(buf, ptr, min_size);
     free(ptr);
     return buf;
 }


Override specifier not supported in GCC, so do not use.. please.

--- include/inviwo/core/util/logcentral.h
+++ include/inviwo/core/util/logcentral.h
@@ -172,7 +172,7 @@

     virtual void log(std::string logSource, LogLevel logLevel, LogAudience audience,
                      const char* fileName, const char* functionName, int lineNumber,
-                     std::string logMsg) override;
+                     std::string logMsg);
 };

 class IVW_CORE_API FileLogger : public Logger {
@@ -182,7 +182,7 @@

     virtual void log(std::string logSource, LogLevel logLevel, LogAudience audience,
                      const char* fileName, const char* functionName, int lineNumber,
-                     std::string logMsg) override;
+                     std::string logMsg);

 private:
     std::ofstream* fileStream_;


restore timers to original output after sync

--- MotorControl/low_level.c
+++ MotorControl/low_level.c
@@ -130,13 +130,17 @@
 static void sync_timers(TIM_HandleTypeDef htim_a, TIM_HandleTypeDef htim_b,
 		uint16_t internal_trigger_source, uint16_t count_offset) {

+	//Store intial timer configs
+    uint16_t MOE_store_a = htim_a.Instance->BDTR & (TIM_BDTR_MOE);
+    uint16_t MOE_store_b = htim_b.Instance->BDTR & (TIM_BDTR_MOE);
+
+	uint16_t CR2_store = htim_a.Instance->CR2;
+	uint16_t SMCR_store = htim_b.Instance->SMCR;
+
     //Turn off output
     __HAL_TIM_MOE_DISABLE(&htim_a);
     __HAL_TIM_MOE_DISABLE(&htim_b);

-	uint16_t CR2_store = htim_a.Instance->CR2;
-	uint16_t SMCR_store = htim_b.Instance->SMCR;
-
 	/* Disable both timer counters*/
 	htim_a.Instance->CR1 &= ~TIM_CR1_CEN;
 	htim_b.Instance->CR1 &= ~TIM_CR1_CEN;
@@ -153,6 +157,7 @@
 	htim_b.Instance->SMCR &= ~TIM_SMCR_SMS;
 	htim_b.Instance->SMCR |= TIM_SLAVEMODE_TRIGGER;

+	// set counter offset
 	htim_a.Instance->CNT = 0;
 	htim_b.Instance->CNT = count_offset;

@@ -163,9 +168,9 @@
 	htim_a.Instance->CR2 = CR2_store;
 	htim_b.Instance->SMCR = SMCR_store;

-    //Turn on output
-    __HAL_TIM_MOE_ENABLE(&htim_a);
-    __HAL_TIM_MOE_ENABLE(&htim_b);
+    //restore output
+    htim_a.Instance->BDTR |= MOE_store_a;
+    htim_b.Instance->BDTR |= MOE_store_b;
 }

 static void init_encoders() {


method rs2_delete_fw_log_parsed_message declared twice corrected

--- include/librealsense2/h/rs_internal.h
+++ include/librealsense2/h/rs_internal.h
@@ -449,12 +449,6 @@
 int rs2_parse_firmware_log(rs2_device* dev, rs2_firmware_log_message* fw_log_msg, rs2_firmware_log_parsed_message* parsed_msg, rs2_error** error);

 /**
-* Delete RealSense firmware log parsed message
-* \param[in]  device    Realsense firmware log parsed message to delete
-*/
-void rs2_delete_fw_log_parsed_message(rs2_firmware_log_parsed_message* fw_log_parsed_msg);
-
-/**
 * \brief Gets RealSense firmware log parsed message.
 * \param[in] fw_log_parsed_msg      firmware log parsed message object
 * \param[out] error     If non-null, receives any error that occurs during this call, otherwise, errors are ignored.


Changes from due to type_lookup.h updates

--- src/factory.h
+++ src/factory.h
@@ -81,21 +81,21 @@
   //***************************************************************************
   template <const size_t MAX_SIZE_,
             typename T1,
-            typename T2  = etl::type_id_pair<>,
-            typename T3  = etl::type_id_pair<>,
-            typename T4  = etl::type_id_pair<>,
-            typename T5  = etl::type_id_pair<>,
-            typename T6  = etl::type_id_pair<>,
-            typename T7  = etl::type_id_pair<>,
-            typename T8  = etl::type_id_pair<>,
-            typename T9  = etl::type_id_pair<>,
-            typename T10 = etl::type_id_pair<>,
-            typename T11 = etl::type_id_pair<>,
-            typename T12 = etl::type_id_pair<>,
-            typename T13 = etl::type_id_pair<>,
-            typename T14 = etl::type_id_pair<>,
-            typename T15 = etl::type_id_pair<>,
-            typename T16 = etl::type_id_pair<>>
+            typename T2  = etl::type_id_pair<etl::null_type, -2>,
+            typename T3  = etl::type_id_pair<etl::null_type, -3>,
+            typename T4  = etl::type_id_pair<etl::null_type, -4>,
+            typename T5  = etl::type_id_pair<etl::null_type, -5>,
+            typename T6  = etl::type_id_pair<etl::null_type, -6>,
+            typename T7  = etl::type_id_pair<etl::null_type, -7>,
+            typename T8  = etl::type_id_pair<etl::null_type, -8>,
+            typename T9  = etl::type_id_pair<etl::null_type, -9>,
+            typename T10 = etl::type_id_pair<etl::null_type, -10>,
+            typename T11 = etl::type_id_pair<etl::null_type, -11>,
+            typename T12 = etl::type_id_pair<etl::null_type, -12>,
+            typename T13 = etl::type_id_pair<etl::null_type, -13>,
+            typename T14 = etl::type_id_pair<etl::null_type, -14>,
+            typename T15 = etl::type_id_pair<etl::null_type, -15>,
+            typename T16 = etl::type_id_pair<etl::null_type, -16> >
   class factory
   {
   private:


Update fastpin.h documentation

Update fastpin.h documentation

--- src/fastpin.h
+++ src/fastpin.h
@@ -9,11 +9,13 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wignored-qualifiers"

-///@file fastpin.h
+/// @file fastpin.h
 /// Class base definitions for defining fast pin access

 FASTLED_NAMESPACE_BEGIN

+/// Constant for "not a pin"
+/// @todo Unused, remove?
 #define NO_PIN 255

 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -22,21 +24,25 @@
 //
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

+/// Abstract class for "selectable" things
 class Selectable {
 public:
-	virtual void select() = 0;
-	virtual void release() = 0;
-	virtual bool isSelected() = 0;
+	virtual void select() = 0;      ///< Select this object
+	virtual void release() = 0;     ///< Release this object
+	virtual bool isSelected() = 0;  ///< Check if this object is currently selected
 };

 #if !defined(FASTLED_NO_PINMAP)

+/// Naive fallback solution for low level pin access
 class Pin : public Selectable {
-	volatile RwReg *mPort;
-	volatile RoReg *mInPort;
-	RwReg mPinMask;
-	uint8_t mPin;
-
+	volatile RwReg *mPort;    ///< Output register for the pin
+	volatile RoReg *mInPort;  ///< Input register for the pin
+	RwReg mPinMask;  ///< Bitmask for the pin within its register
+	uint8_t mPin;    ///< Arduino digital pin number
+
+	/// Initialize the class by retrieving the register
+	/// pointers and bitmask.
 	void _init() {
 		mPinMask = digitalPinToBitMask(mPin);
 		mPort = (volatile RwReg*)portOutputRegister(digitalPinToPort(mPin));
@@ -44,43 +50,74 @@
 	}

 public:
+	/// Constructor
+	/// @param pin Arduino digital pin number
 	Pin(int pin) : mPin(pin) { _init(); }

-	typedef volatile RwReg * port_ptr_t;
-	typedef RwReg port_t;
-
+	typedef volatile RwReg * port_ptr_t;  ///< type for a pin read/write register, volatile
+	typedef RwReg port_t;  ///< type for a pin read/write register, non-volatile
+
+	/// Set the pin mode as `OUTPUT`
 	inline void setOutput() { pinMode(mPin, OUTPUT); }
+
+	/// Set the pin mode as `INPUT`
 	inline void setInput() { pinMode(mPin, INPUT); }

+	/// Set the pin state to `HIGH`
 	inline void hi() __attribute__ ((always_inline)) { *mPort |= mPinMask; }
+	/// Set the pin state to `LOW`
 	inline void lo() __attribute__ ((always_inline)) { *mPort &= ~mPinMask; }

+	/// Toggle the pin twice to create a short pulse
 	inline void strobe() __attribute__ ((always_inline)) { toggle(); toggle(); }
+	/// Toggle the pin.
+	/// If the pin was high, set it low. If was low, set it high.
 	inline void toggle() __attribute__ ((always_inline)) { *mInPort = mPinMask; }

+	/// Set the same pin on another port to `HIGH`
+	/// @param port the port to modify
 	inline void hi(register port_ptr_t port) __attribute__ ((always_inline)) { *port |= mPinMask; }
+	/// Set the same pin on another port to `LOW`
+	/// @param port the port to modify
 	inline void lo(register port_ptr_t port) __attribute__ ((always_inline)) { *port &= ~mPinMask; }
+	/// Set the state of the output register
+	/// @param val the state to set the output register to
+	/// @note This function is not limited to the current pin! It modifies the entire register.
 	inline void set(register port_t val) __attribute__ ((always_inline)) { *mPort = val; }

+	/// Set the state of a port
+	/// @param port the port to modify
+	/// @param val the state to set the port to
 	inline void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port  = val; }

+	/// Gets the state of the port with this pin `HIGH`
 	port_t hival() __attribute__ ((always_inline)) { return *mPort | mPinMask;  }
+	/// Gets the state of the port with this pin `LOW`
 	port_t loval() __attribute__ ((always_inline)) { return *mPort & ~mPinMask; }
+	/// Get the output state of the port
 	port_ptr_t  port() __attribute__ ((always_inline)) { return mPort; }
+	/// Get the pin mask
 	port_t mask() __attribute__ ((always_inline)) { return mPinMask; }

+	/// @copydoc Pin::hi()
 	virtual void select() { hi(); }
+	/// @copydoc Pin::lo()
 	virtual void release() { lo(); }
+	/// Checks if the pin is currently `HIGH`
 	virtual bool isSelected() { return (*mPort & mPinMask) == mPinMask; }
 };

+/// I/O pin initially set to OUTPUT
 class OutputPin : public Pin {
 public:
+	/// @copydoc Pin::Pin(int)
 	OutputPin(int pin) : Pin(pin) { setOutput(); }
 };

+/// I/O pin initially set to INPUT
 class InputPin : public Pin {
 public:
+	/// @copydoc Pin::Pin(int)
 	InputPin(int pin) : Pin(pin) { setInput(); }
 };

@@ -145,10 +182,10 @@

 #endif

-/// The simplest level of Pin class.  This relies on runtime functions durinig initialization to get the port/pin mask for the pin.  Most
+/// The simplest level of Pin class.  This relies on runtime functions during initialization to get the port/pin mask for the pin.  Most
 /// of the accesses involve references to these static globals that get set up.  This won't be the fastest set of pin operations, but it
-/// will provide pin level access on pretty much all arduino environments.  In addition, it includes some methods to help optimize access in
-/// various ways.  Namely, the versions of hi, lo, and fastset that take the port register as a passed in register variable (saving a global
+/// will provide pin level access on pretty much all Arduino environments.  In addition, it includes some methods to help optimize access in
+/// various ways.  Namely, the versions of hi(), lo(), and fastset() that take the port register as a passed in register variable (saving a global
 /// dereference), since these functions are aggressively inlined, that can help collapse out a lot of extraneous memory loads/dereferences.
 ///
 /// In addition, if, while writing a bunch of data to a pin, you know no other pins will be getting written to, you can get/cache a value of
@@ -161,9 +198,9 @@
 /// as passing Pin objects around will likely -not- have the effect you're expecting.
 #ifdef FASTLED_FORCE_SOFTWARE_PINS
 template<uint8_t PIN> class FastPin {
-	static RwReg sPinMask;
-	static volatile RwReg *sPort;
-	static volatile RoReg *sInPort;
+	static RwReg sPinMask;            ///< Bitmask for the pin within its register
+	static volatile RwReg *sPort;     ///< Output register for the pin
+	static volatile RoReg *sInPort;   ///< Input register for the pin
 	static void _init() {
 #if !defined(FASTLED_NO_PINMAP)
 		sPinMask = digitalPinToBitMask(PIN);
@@ -173,28 +210,42 @@
 	}

 public:
-	typedef volatile RwReg * port_ptr_t;
-	typedef RwReg port_t;
-
+	typedef volatile RwReg * port_ptr_t;  ///< @copydoc Pin::port_ptr_t
+	typedef RwReg port_t;  ///< @copydoc Pin::port_t
+
+	/// @copydoc Pin::setOutput()
 	inline static void setOutput() { _init(); pinMode(PIN, OUTPUT); }
+	/// @copydoc Pin::setInput()
 	inline static void setInput() { _init(); pinMode(PIN, INPUT); }

+	/// @copydoc Pin::hi()
 	inline static void hi() __attribute__ ((always_inline)) { *sPort |= sPinMask; }
+	/// @copydoc Pin::lo()
 	inline static void lo() __attribute__ ((always_inline)) { *sPort &= ~sPinMask; }

+	/// @copydoc Pin::strobe()
 	inline static void strobe() __attribute__ ((always_inline)) { toggle(); toggle(); }

+	/// @copydoc Pin::toggle()
 	inline static void toggle() __attribute__ ((always_inline)) { *sInPort = sPinMask; }

+	/// @copydoc Pin::hi(register port_ptr_t)
 	inline static void hi(register port_ptr_t port) __attribute__ ((always_inline)) { *port |= sPinMask; }
+	/// @copydoc Pin::lo(register port_ptr_t)
 	inline static void lo(register port_ptr_t port) __attribute__ ((always_inline)) { *port &= ~sPinMask; }
+	/// @copydoc Pin::set(register port_t)
 	inline static void set(register port_t val) __attribute__ ((always_inline)) { *sPort = val; }

+	/// @copydoc Pin::fastset()
 	inline static void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port  = val; }

+	/// @copydoc Pin::hival()
 	static port_t hival() __attribute__ ((always_inline)) { return *sPort | sPinMask;  }
+	/// @copydoc Pin::loval()
 	static port_t loval() __attribute__ ((always_inline)) { return *sPort & ~sPinMask; }
+	/// @copydoc Pin::port()
 	static port_ptr_t  port() __attribute__ ((always_inline)) { return sPort; }
+	/// @copydoc Pin::mask()
 	static port_t mask() __attribute__ ((always_inline)) { return sPinMask; }
 };

@@ -212,56 +263,89 @@
 	static void _init() { }

 public:
-	typedef volatile RwReg * port_ptr_t;
-	typedef RwReg port_t;
-
+	typedef volatile RwReg * port_ptr_t;  ///< @copydoc Pin::port_ptr_t
+	typedef RwReg port_t;  ///< @copydoc Pin::port_t
+
+	/// @copydoc Pin::setOutput()
 	inline static void setOutput() { }
+	/// @copydoc Pin::setInput()
 	inline static void setInput() { }

+	/// @copydoc Pin::hi()
 	inline static void hi() __attribute__ ((always_inline)) { }
+	/// @copydoc Pin::lo()
 	inline static void lo() __attribute__ ((always_inline)) { }

+	/// @copydoc Pin::strobe()
 	inline static void strobe() __attribute__ ((always_inline)) { }

+	/// @copydoc Pin::toggle()
 	inline static void toggle() __attribute__ ((always_inline)) { }

+	/// @copydoc Pin::hi(register port_ptr_t)
 	inline static void hi(register port_ptr_t port) __attribute__ ((always_inline)) { }
+	/// @copydoc Pin::lo(register port_ptr_t)
 	inline static void lo(register port_ptr_t port) __attribute__ ((always_inline)) { }
+	/// @copydoc Pin::set(register port_t)
 	inline static void set(register port_t val) __attribute__ ((always_inline)) { }

+	/// @copydoc Pin::fastset()
 	inline static void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { }

+	/// @copydoc Pin::hival()
 	static port_t hival() __attribute__ ((always_inline)) { return 0; }
+	/// @copydoc Pin::loval()
 	static port_t loval() __attribute__ ((always_inline)) { return 0;}
+	/// @copydoc Pin::port()
 	static port_ptr_t  port() __attribute__ ((always_inline)) { return NULL; }
+	/// @copydoc Pin::mask()
 	static port_t mask() __attribute__ ((always_inline)) { return 0; }
 };

 #endif

+/// FastPin implementation for bit-banded access.
+/// Only for MCUs that support bitbanding.
+/// @note This bitband class is optional!
 template<uint8_t PIN> class FastPinBB : public FastPin<PIN> {};

-typedef volatile uint32_t & reg32_t;
-typedef volatile uint32_t * ptr_reg32_t;
-
-// Utility templates for tracking down information about pins and ports
+typedef volatile uint32_t & reg32_t;      ///< Reference to a 32-bit register, volatile
+typedef volatile uint32_t * ptr_reg32_t;  ///< Pointer to a 32-bit register, volatile
+
+/// Utility template for tracking down information about pins and ports
+/// @tparam port the port to check information for
 template<uint8_t port> struct __FL_PORT_INFO {
+	/// Checks whether a port exists
 	static bool hasPort() { return 0; }
+	/// Gets the name of the port, as a C-string
 	static const char *portName() { return "--"; }
+	/// Gets the raw address of the port
 	static const void *portAddr() { return NULL; }
 };

-// Give us our instantiations for defined ports - we're going to abuse this later for
-// auto discovery of pin/port mappings for new variants.  Use _FL_DEFINE_PORT for ports that
-// are numeric in nature, e.g. GPIO0, GPIO1.  Use _FL_DEFINE_PORT3 for ports that are letters.
-// The first parameter will be the letter, the second parameter will be an integer/counter of smoe kind
-// (this is because attempts to turn macro parameters into character constants break in some compilers)
+
+/// Macro to create the instantiations for defined ports.
+/// We're going to abuse this later for auto discovery of pin/port mappings
+/// for new variants.
+/// Use this for ports that are numeric in nature, e.g. GPIO0, GPIO1, etc.
+/// @param L the number of the port
+/// @param BASE the data type for the register
 #define _FL_DEFINE_PORT(L, BASE) template<> struct __FL_PORT_INFO<L> { \
 	static bool hasPort() { return 1; } \
 	static const char *portName() { return #L; } \
 	typedef BASE __t_baseType;  \
 	static const void *portAddr() { return (void*)&__t_baseType::r(); } };

+/// Macro to create the instantiations for defined ports.
+/// We're going to abuse this later for auto discovery of pin/port mappings
+/// for new variants.
+/// Use this for ports that are letters. The first parameter will be the
+/// letter, the second parameter will be an integer/counter of some kind.
+/// This is because attempts to turn macro parameters into character constants
+/// break in some compilers.
+/// @param L the letter of the port
+/// @param LC an integer counter
+/// @param BASE the data type for the register
 #define _FL_DEFINE_PORT3(L, LC, BASE) template<> struct __FL_PORT_INFO<LC> { \
 	static bool hasPort() { return 1; } \
 	static const char *portName() { return #L; } \


Correct typo in retrieving stored pointer from CartesianIndependent distribution unique pointers.Refs #1680

--- include/openmc/distribution_spatial.h
+++ include/openmc/distribution_spatial.h
@@ -35,8 +35,8 @@

   // Observer pointers
   Distribution* x() const { return x_.get(); }
-  Distribution* y() const { return x_.get(); }
-  Distribution* z() const { return x_.get(); }
+  Distribution* y() const { return y_.get(); }
+  Distribution* z() const { return z_.get(); }
 private:
   UPtrDist x_; //!< Distribution of x coordinates
   UPtrDist y_; //!< Distribution of y coordinates


Fixed syntax error at end of initial state facts.

Due to a mistake in commit 6d07fcb, the closing parenthesis and period
at the end of initial state facts was omitted. This adds these back in
order to solve this syntax error.


Limit MSVC workaround to MSVC, not clang-cl

--- include/swift/Basic/EncodedSequence.h
+++ include/swift/Basic/EncodedSequence.h
@@ -339,7 +339,7 @@
   template <class ValueType> class Map {
     // Hack: MSVC isn't able to resolve the InlineKeyCapacity part of the
     // template of PrefixMap, so we have to split it up and pass it manually.
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) && !defined(__clang__)
     static const size_t Size = (sizeof(void*) - 1) / sizeof(Chunk);
     static const size_t ActualSize = max<size_t>(Size, 1);


Remove unnecessary AtEOXact_Files call

Remove unnecessary AtEOXact_Files call

--- src/backend/distributed/transaction/transaction_management.c
+++ src/backend/distributed/transaction/transaction_management.c
@@ -318,28 +318,8 @@
 			/* stop propagating notices from workers, we know the query is failed */
 			DisableWorkerMessagePropagation();

-			/*
-			 * FIXME: Add warning for the COORD_TRANS_COMMITTED case. That
-			 * can be reached if this backend fails after the
-			 * XACT_EVENT_PRE_COMMIT state.
-			 */
-
-			/*
-			 * Call other parts of citus that need to integrate into
-			 * transaction management. Do so before doing other work, so the
-			 * callbacks still can perform work if needed.
-			 */
-			{
-				/*
-				 * On Windows it's not possible to delete a file before you've closed all
-				 * handles to it (rmdir will return success but not take effect). Since
-				 * we're in an ABORT handler it's very likely that not all handles have
-				 * been closed; force them closed here before running
-				 * RemoveIntermediateResultsDirectory.
-				 */
-				AtEOXact_Files(false);
-				RemoveIntermediateResultsDirectory();
-			}
+			RemoveIntermediateResultsDirectory();
+
 			ResetShardPlacementTransactionState();

 			/* handles both already prepared and open transactions */


Clean up feerate.h to support constexpr and not-equal operator

Summary:
  As per title

Test Plan:
  make check

Reviewers: #bitcoin_abc, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Subscribers: teamcity

Differential Revision: https://reviews.bitcoinabc.org/D1935

--- src/feerate.h
+++ src/feerate.h
@@ -27,8 +27,8 @@
     /**
      * Fee rate of 0 satoshis per kB.
      */
-    CFeeRate() : nSatoshisPerK() {}
-    explicit CFeeRate(const Amount _nSatoshisPerK)
+    constexpr CFeeRate() : nSatoshisPerK() {}
+    explicit constexpr CFeeRate(const Amount _nSatoshisPerK)
         : nSatoshisPerK(_nSatoshisPerK) {}

     /**
@@ -36,7 +36,8 @@
      * exceed (2^63 - 1)
      */
     CFeeRate(const Amount nFeePaid, size_t nBytes);
-    CFeeRate(const CFeeRate &other) { nSatoshisPerK = other.nSatoshisPerK; }
+    constexpr CFeeRate(const CFeeRate &other)
+        : nSatoshisPerK(other.nSatoshisPerK) {}

     /**
      * Return the fee in satoshis for the given size in bytes.
@@ -53,14 +54,25 @@
      * Return the fee in satoshis for a size of 1000 bytes
      */
     Amount GetFeePerK() const { return GetFee(1000); }
+
+    /**
+     * Equality
+     */
+    friend constexpr bool operator==(const CFeeRate a, const CFeeRate b) {
+        return a.nSatoshisPerK == b.nSatoshisPerK;
+    }
+    friend constexpr bool operator!=(const CFeeRate a, const CFeeRate b) {
+        return !(a == b);
+    }
+
+    /**
+     * Comparison
+     */
     friend bool operator<(const CFeeRate &a, const CFeeRate &b) {
         return a.nSatoshisPerK < b.nSatoshisPerK;
     }
     friend bool operator>(const CFeeRate &a, const CFeeRate &b) {
         return a.nSatoshisPerK > b.nSatoshisPerK;
-    }
-    friend bool operator==(const CFeeRate &a, const CFeeRate &b) {
-        return a.nSatoshisPerK == b.nSatoshisPerK;
     }
     friend bool operator<=(const CFeeRate &a, const CFeeRate &b) {
         return a.nSatoshisPerK <= b.nSatoshisPerK;


s/gins/gbranch/

s/gins/gbranch/

R=ken
OCL=18713
CL=18713

--- src/cmd/6g/gsubr.c
+++ src/cmd/6g/gsubr.c
@@ -722,18 +722,16 @@
 		regalloc(&nod, f->type, f);
 		gmove(f, &nod);
 		regalloc(&nod1, t->type, t);
-nodconst(&nodc, types[TUINT64], 0);
+		nodconst(&nodc, types[TUINT64], 0);
 		gins(ACMPQ, &nod, &nodc);
-		p1 = pc;
-		gins(AJLT, N, N);
+		p1 = gbranch(AJLT, T);
 		gins(a, &nod, &nod1);
-		p2 = pc;
-		gins(AJMP, N, N);
+		p2 = gbranch(AJMP, T);
 		patch(p1, pc);
 		regalloc(&nod2, f->type, N);
 		regalloc(&nod3, f->type, N);
 		gmove(&nod, &nod2);
-nodconst(&nodc, types[TUINT64], 1);
+		nodconst(&nodc, types[TUINT64], 1);
 		gins(ASHRQ, &nodc, &nod2);
 		gmove(&nod, &nod3);
 		gins(AANDL, &nodc, &nod3);


[OP] Fill stack queues with P stacks initially.

--- src/fibrili.c
+++ src/fibrili.c
@@ -100,6 +100,10 @@

   fifo_register(&_fifo, &_handle);
   DEBUG_DUMP(2, "proc_start:", (id, "%d"), (_deqs[id], "%p"));
+  const size_t align = PARAM_PAGE_SIZE;
+  void * addr;
+  posix_memalign(&addr, align, PARAM_STACK_SIZE);
+  fifo_put(&_fifo, &_handle, addr);

   fibril_t fr;
   fibril_init(&fr);


6l: More SSE instruction fixes

6l: More SSE instruction fixes

PSADBW and PSHUFL had the wrong prefixes.

R=rsc
CC=golang-dev
http://codereview.appspot.com/2836041

Committer: Russ Cox <5ad239cb8a44f659eaaee0aa1ea5b94947abe557@golang.org>

--- src/cmd/6l/optab.c
+++ src/cmd/6l/optab.c
@@ -907,9 +907,9 @@
 	{ APOPQ,	ypopl,	Py, 0x58,0x8f,(00) },
 	{ APOPW,	ypopl,	Pe, 0x58,0x8f,(00) },
 	{ APOR,		ymm,	Py, 0xeb,Pe,0xeb },
-	{ APSADBW,	yxm,	Pw, Pe,0xf6 },
+	{ APSADBW,	yxm,	Pq, 0xf6 },
 	{ APSHUFHW,	yxshuf,	Pf3, 0x70 },
-	{ APSHUFL,	yxm,	Pw, Pe,0x70 },
+	{ APSHUFL,	yxshuf,	Pq, 0x70 },
 	{ APSHUFLW,	yxshuf,	Pf2, 0x70 },
 	{ APSHUFW,	ymshuf,	Pm, 0x70 },
 	{ APSLLO,	ypsdq,	Pq, 0x73,(07) },


Fix building with clang.

Fix building with clang.

--- src/filters.c
+++ src/filters.c
@@ -66,7 +66,7 @@
     { FILTER_OPTION_TYPE_STRING, { property }, config, CFG_STR(config, NULL, CFGF_NODEFAULT) }

 #define FILTER_OPTION_CUSTOM(match_func, free_func, cookie, config) \
-    { FILTER_OPTION_TYPE_CUSTOM, { custom: { match_func, free_func, cookie } }, config, CFG_BOOL(config, cfg_false, CFGF_NODEFAULT) }
+    { FILTER_OPTION_TYPE_CUSTOM, { .custom = { match_func, free_func, cookie } }, config, CFG_BOOL(config, cfg_false, CFGF_NODEFAULT) }

 #define NUM_FILTER_OPTIONS 12
 static filter_option filter_options[NUM_FILTER_OPTIONS] = {


Time measurement Log file

Time measurement Log file

error: pathspec 'Server/src/lib/lib_type.c' did not match any file(s) known to git

--- Server/src/lib/lib_type.c
+++ Server/src/lib/lib_type.c
@@ -0,0 +1,89 @@
+/*
+ * lib_type.c
+ *
+ *  Created on: Nov 21, 2011
+ *      Author: krha
+ */
+#include "lib_type.h"
+
+#include <stdarg.h>
+#include <sys/time.h>
+#include <time.h>
+
+static char buf[1024] = { '\0', };
+
+void print_time_info(char *fmt, ...) {
+	memset(buf, 0, sizeof(buf));
+
+	va_list ap;
+	va_start(ap, fmt);
+	vsnprintf(buf, sizeof(buf), fmt, ap);
+	va_end(ap);
+
+	if (strncasecmp(buf, "[Time]", 5) != 0) {
+		struct timeval val;
+		struct tm *tm;
+		gettimeofday(&val, NULL);
+		tm = localtime(&val.tv_sec);
+		fprintf(log_file, "[Time] %s : %02d:%02d:%02d.%06ld\n", buf, tm->tm_hour,	tm->tm_min, tm->tm_sec, val.tv_usec);
+		PRINT_OUT("[Time] %s : %02d:%02d:%02d.%06ld\n", buf, tm->tm_hour, tm->tm_min, tm->tm_sec, val.tv_usec);
+	} else {
+		fprintf(log_file, buf);
+		PRINT_OUT("%s", buf);
+	}
+	fflush(log_file);
+}
+
+/*
+ * Save Log to file for Performance Analysis.
+ * So, we only save logs that are related to Time measurement.
+ */
+void create_logfile() {
+	time_t now;
+	struct tm *tm;
+	now = time(0);
+	if ((tm = localtime(&now)) == NULL) {
+		fprintf(stderr, "Error extracting time stuff\n");
+	}
+
+	log_filename = (char *)malloc(256);
+	sprintf(log_filename, "log-%04d%02d%02d-%02d%02d%02d", tm->tm_year + 1900,
+			tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
+
+	fprintf(stdout, "Log file name : %s\n", log_filename);
+	log_file = fopen(log_filename, "w");
+}
+
+void close_logfile() {
+	if (log_file != NULL) {
+		fclose(log_file);
+	}
+}
+
+
+/* Subtract the `struct timeval' values X and Y,
+ storing the result in RESULT.
+ Return 1 if the difference is negative, otherwise 0.
+
+int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y) {
+	// Perform the carry for the later subtraction by updating y.
+	if (x->tv_usec < y->tv_usec) {
+		int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
+		y->tv_usec -= 1000000 * nsec;
+		y->tv_sec += nsec;
+	}
+	if (x->tv_usec - y->tv_usec > 1000000) {
+		int nsec = (x->tv_usec - y->tv_usec) / 1000000;
+		y->tv_usec += 1000000 * nsec;
+		y->tv_sec -= nsec;
+	}
+
+	// Compute the time remaining to wait.
+	// tv_usec is certainly positive.
+	result->tv_sec = x->tv_sec - y->tv_sec;
+	result->tv_usec = x->tv_usec - y->tv_usec;
+
+	// Return 1 if result is negative.
+	return x->tv_sec < y->tv_sec;
+}
+*/


bug with struct-type { 1 }

bug with struct-type { 1 }

R=r
OCL=17096
CL=17096

--- src/cmd/gc/const.c
+++ src/cmd/gc/const.c
@@ -30,6 +30,7 @@
 	case TFUNC:
 	case TCHAN:
 	case TMAP:
+	case TSTRUCT:
 //	case TPTR32:
 //	case TPTR64:
 		return;


stop using deprecated GtkImageMenuItem

stop using deprecated GtkImageMenuItem

fixes #22

--- src/systray.c
+++ src/systray.c
@@ -134,15 +134,22 @@

 GtkWidget* systray_add_menu_item(GtkMenuShell* menu, const char* desc, const char* tooltip, const char* icon)
 {
-    GtkWidget* item = gtk_image_menu_item_new_with_mnemonic(desc);
+    GtkWidget* item =
+    /* TODO: GtkImageMenuItem is deprecated. Replace it with GMenu from GIO?
+        gtk_image_menu_item_new_with_mnemonic(desc);
+    */
+        gtk_menu_item_new_with_mnemonic(desc);
+
     gtk_menu_shell_append(menu, item);

     if(tooltip)
         systray_set_tooltip(item, tooltip);

+    /* TODO: GtkImageMenuItem is deprecated. Replace it with GMenu from GIO?
     if(icon)
         gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item),
             gtk_image_new_from_icon_name(icon, GTK_ICON_SIZE_MENU));
+    */

     gtk_widget_show(item);


replaced sin tabs to use FIX32/FIX16 (thankf to FireRat for the generator)


ld: fix Mach-O code signing for non-cgo binaries

R=golang-dev, rsc
CC=golang-dev
http://codereview.appspot.com/5561060

Committer: Russ Cox <5ad239cb8a44f659eaaee0aa1ea5b94947abe557@golang.org>

--- src/cmd/ld/macho.c
+++ src/cmd/ld/macho.c
@@ -499,7 +499,24 @@
 	s3 = lookup(".linkedit.got", 0);
 	s4 = lookup(".dynstr", 0);

-	while(s4->size%4)
+	// Force the linkedit section to end on a 16-byte
+	// boundary.  This allows pure (non-cgo) Go binaries
+	// to be code signed correctly.
+	//
+	// Apple's codesign_allocate (a helper utility for
+	// the codesign utility) can do this fine itself if
+	// it is run on a dynamic Mach-O binary.  However,
+	// when it is run on a pure (non-cgo) Go binary, where
+	// the linkedit section is mostly empty, it fails to
+	// account for the extra padding that it itself adds
+	// when adding the LC_CODE_SIGNATURE load command
+	// (which must be aligned on a 16-byte boundary).
+	//
+	// By forcing the linkedit section to end on a 16-byte
+	// boundary, codesign_allocate will not need to apply
+	// any alignment padding itself, working around the
+	// issue.
+	while(s4->size%16)
 		adduint8(s4, 0);

 	size = s1->size + s2->size + s3->size + s4->size;


bugfix: cat should end with NULL

bugfix: cat should end with NULL

--- src/cmds/run/cmd.c
+++ src/cmds/run/cmd.c
@@ -117,7 +117,7 @@
     s(init);
     current=get_opt("program");
     if(file_exist_p(etc)) {
-      path=cat("(:load \"",etc,"\")");
+      path=cat("(:load \"",etc,"\")",NULL);
       would=cat(path,current?current:"",NULL);
       set_opt(&local_opt,"program",would,0);
     }


vod: fix memleak

vod: fix memleak

Port c7690cec0129d2fb3198e60602c4894e728df092 to duplicated code

--- modules/stream_out/rtp.c
+++ modules/stream_out/rtp.c
@@ -1243,12 +1243,14 @@

                     if( i_nal_type == 7 )
                     {
+                        free( p_64_sps );
                         p_64_sps = vlc_b64_encode_binary( p_buffer, i_size );
                         /* XXX: nothing ensures that i_size >= 4 ?? */
                         sprintf_hexa( hexa, &p_buffer[1], 3 );
                     }
                     else if( i_nal_type == 8 )
                     {
+                        free( p_64_pps );
                         p_64_pps = vlc_b64_encode_binary( p_buffer, i_size );
                     }
                     i_buffer -= i_size;


RTP out: use clz

RTP out: use clz

--- modules/stream_out/rtp.c
+++ modules/stream_out/rtp.c
@@ -473,7 +473,7 @@
     p_sys->i_npt_zero = VLC_TS_INVALID;
     p_sys->i_pts_zero = mdate(); /* arbitrary value, could probably be
                                   * random */
-    p_sys->payload_bitmap = 0;
+    p_sys->payload_bitmap = 0xFFFFFFFF;
     p_sys->i_es = 0;
     p_sys->es   = NULL;
     p_sys->rtsp = NULL;
@@ -908,7 +908,7 @@
     sout_stream_id_t  *id;
     char              *psz_sdp;

-    if (0xffffffff == p_sys->payload_bitmap)
+    if (0 == p_sys->payload_bitmap)
     {
         msg_Err (p_stream, "too many RTP elementary streams");
         return NULL;
@@ -952,9 +952,7 @@
     id->p_stream   = p_stream;

     /* Look for free dymanic payload type */
-    id->i_payload_type = 96;
-    while (p_sys->payload_bitmap & (1 << (id->i_payload_type - 96)))
-        id->i_payload_type++;
+    id->i_payload_type = 96 + clz32 (p_sys->payload_bitmap);
     assert (id->i_payload_type < 128);

     vlc_rand_bytes (&id->i_sequence, sizeof (id->i_sequence));
@@ -1325,7 +1323,7 @@
     }
     if (id->i_payload_type >= 96)
         /* Mark dynamic payload type in use */
-        p_sys->payload_bitmap |= 1 << (id->i_payload_type - 96);
+        p_sys->payload_bitmap &= ~(1 << (127 - id->i_payload_type));

 #if 0 /* No payload formats sets this at the moment */
     int cscov = -1;
@@ -1394,7 +1392,7 @@

     /* Release dynamic payload type */
     if (id->i_payload_type >= 96)
-        p_sys->payload_bitmap &= ~(1 << (id->i_payload_type - 96));
+        p_sys->payload_bitmap |= 1 << (127 - id->i_payload_type);

     free( id->psz_fmtp );


Count total size.

Count total size.

--- src/command_view.c
+++ src/command_view.c
@@ -27,7 +27,7 @@
 			"   -o FILE         output file ["DEF_OUTPUT"]\n"
 			"   -f STR          output format, tsv/cmap/bnx/txt ["DEF_FORMAT"]\n"
 			"   -s FILE         select fragment by name, listed in lines\n"
-			"   -c              count fragments and nicks\n"
+			"   -c              count fragments, nicks and total size\n"
 			"   -v              show verbose message\n"
 			"   -h              show this help\n"
 			"\n");
@@ -78,6 +78,7 @@
 	struct name_list name_list = { };
 	size_t fragment_count = 0;
 	size_t nick_count = 0;
+	long long total_size = 0;
 	gzFile file;
 	int i, ret = 0, save_into_map;

@@ -124,6 +125,7 @@
 			if (counting) {
 				++fragment_count;
 				nick_count += fragment.nicks.size;
+				total_size += fragment.size;
 			} else if (save_into_map) {
 				if (array_reserve(map.fragments, map.fragments.size + 1)) {
 					nick_map_free(&map);
@@ -139,7 +141,7 @@
 	}

 	if (counting) {
-		fprintf(stdout, "%zd\t%zd\n", fragment_count, nick_count);
+		fprintf(stdout, "%zd\t%zd\t%lld\n", fragment_count, nick_count, total_size);
 	} else if (save_into_map) {
 		nick_map_save(&map, output_file, format);
 	} else {


Implement more operators for `tbd::symbol_options`

--- src/tbd/tbd.h
+++ src/tbd/tbd.h
@@ -65,17 +65,23 @@
         allow_private_objc_ivars     = 1 << 5,
     };

-    inline int operator|(int lhs, const symbol_options &rhs) noexcept { return lhs | (int)rhs; }
-    inline unsigned int operator|(unsigned int lhs, const symbol_options &rhs) noexcept { return lhs | (unsigned int)rhs; }
-
-    inline void operator|=(int &lhs, const symbol_options &rhs) noexcept { lhs |= (int)rhs; }
+    inline unsigned int operator|(const unsigned int &lhs, const symbol_options &rhs) noexcept { return lhs | (unsigned int)rhs; }
     inline void operator|=(unsigned int &lhs, const symbol_options &rhs) noexcept { lhs |= (unsigned int)rhs; }

-    inline int operator&(int lhs, const symbol_options &rhs) noexcept { return lhs & (int)rhs; }
-    inline unsigned int operator&(unsigned int lhs, const symbol_options &rhs) noexcept { return lhs & (unsigned int)rhs; }
+    inline symbol_options operator|(const symbol_options &lhs, const unsigned int &rhs) noexcept { return (symbol_options)((unsigned int)lhs | rhs); }
+    inline void operator|=(symbol_options &lhs, const unsigned int &rhs) noexcept { lhs = (symbol_options)((unsigned int)lhs | rhs); }

-    inline void operator&=(int &lhs, const symbol_options &rhs) noexcept { lhs &= (int)rhs; }
+    inline symbol_options operator|(const symbol_options &lhs, const symbol_options &rhs) noexcept { return (symbol_options)((unsigned int)lhs | (unsigned int)rhs); }
+    inline void operator|=(symbol_options &lhs, const symbol_options &rhs) noexcept { lhs = (symbol_options)((unsigned int)lhs | (unsigned int)rhs); }
+
+    inline unsigned int operator&(const unsigned int &lhs, const symbol_options &rhs) noexcept { return lhs & (unsigned int)rhs; }
     inline void operator&=(unsigned int &lhs, const symbol_options &rhs) noexcept { lhs &= (unsigned int)rhs; }
+
+    inline symbol_options operator&(const symbol_options &lhs, const unsigned int &rhs) noexcept { return (symbol_options)((unsigned int)lhs & rhs); }
+    inline void operator&=(symbol_options &lhs, const unsigned int &rhs) noexcept { lhs = (symbol_options)((unsigned int)lhs & rhs); }
+
+    inline symbol_options operator&(const symbol_options &lhs, const symbol_options &rhs) noexcept { return (symbol_options)((unsigned int)lhs & (unsigned int)rhs); }
+    inline void operator&=(symbol_options &lhs, const symbol_options &rhs) noexcept { lhs = (symbol_options)((unsigned int)lhs & (unsigned int)rhs); }

     enum class creation_result {
         ok,


added new logging functions; only build file when debug is on

--- src/tcs/log.c
+++ src/tcs/log.c
@@ -13,9 +13,12 @@
 #include <string.h>
 #include <syslog.h>

+#include "trousers/tss.h"
 #include "tcslog.h"

 int foreground = 0;
+
+#ifdef TSS_DEBUG

 /*
  * LogBlobData()
@@ -57,4 +60,29 @@
 	}
 }

+void
+LogTPMERR(TSS_RESULT result, char *file, int line)
+{
+	if (getenv("TSS_DEBUG_OFF") == NULL)
+		fprintf(stderr, "%s %s %s:%d: 0x%x\n", "LOG_RETERR", "TPM", file, line, result);
+}

+TSS_RESULT
+LogTDDLERR(TSS_RESULT result, char *file, int line)
+{
+	if (getenv("TSS_DEBUG_OFF") == NULL)
+		fprintf(stderr, "%s %s %s:%d: 0x%x\n", "LOG_RETERR", APPID, file, line, result);
+
+	return (result | TSS_LAYER_TDDL);
+}
+
+TSS_RESULT
+LogTCSERR(TSS_RESULT result, char *file, int line)
+{
+	if (getenv("TSS_DEBUG_OFF") == NULL)
+		fprintf(stderr, "%s %s %s:%d: 0x%x\n", "LOG_RETERR", APPID, file, line, result);
+
+	return (result | TSS_LAYER_TCS);
+}
+
+#endif


Delete useless code

Delete useless code

--- src/testdir.c
+++ src/testdir.c
@@ -89,8 +89,10 @@

 	DIR *dir = fdopendir(fd);

-	if (dir == NULL)
+	if (dir == NULL) {
+		close(fd);
 		return -1;
+	}

 	size = DirentBufSize(dir);

@@ -111,10 +113,6 @@
 	int error = 0;

 	while ((error = readdir_r(dir, direntbuf, &ent)) == 0 && ent != NULL) {
-
-		if (error != 0) {
-			goto error;
-		}

 		int statfd = dirfd(dir);


common/error: minor fix

common/error: minor fix

--- src/common/error.c
+++ src/common/error.c
@@ -131,7 +131,7 @@
             fprintf(stderr, "warning: datetime: %s\n", err->msg);
             break;
         default:
-            fprintf(stderr, "blogc: error: %s\n", err->msg);
+            fprintf(stderr, "error: %s\n", err->msg);
     }
 }


fix fd leak

fix fd leak

--- src/testdir.c
+++ src/testdir.c
@@ -151,12 +151,17 @@
 		list_add(&child->entry, &p->children);
 	}

+	assert(fd != -1);
+
+	close(fd);
 	closedir(dir);
 	free(direntbuf);

 	return 0;

  error:
+	assert(fd != -1);
+	close(fd);
 	Logmsg(LOG_ERR, "watchdogd: %s", strerror(errno));
 	closedir(dir);
 	free(direntbuf);


osmux: Close osmux socket when bts is freed

Related: SYS#5987
Change-Id: Ibd3faa33b28d45048c340b177f13d5685f41a784

--- src/common/osmux.c
+++ src/common/osmux.c
@@ -25,6 +25,7 @@
 #include <stdint.h>
 #include <stdbool.h>
 #include <inttypes.h>
+#include <unistd.h>

 #include <osmocom/core/logging.h>
 #include <osmocom/core/utils.h>
@@ -288,14 +289,19 @@
 	bts->osmux.batch_size = OSMUX_BATCH_DEFAULT_MAX;
 	bts->osmux.dummy_padding = false;
 	INIT_LLIST_HEAD(&bts->osmux.osmux_handle_list);
+	bts->osmux.fd.fd = -1;
 	return 0;
 }

 void bts_osmux_release(struct gsm_bts *bts)
 {
-	/* FIXME: not needed? YES,we probably need to iterare over
-	   bts->osmux.osmux_handle_list and free everything there, see
-	   osmux_handle_put() */
+	/* bts->osmux.osmux_handle_list should end up empty when all lchans are
+	 * released/freed upon talloc_free(bts). */
+	/* If bts->osmux.fd.data is NULL, bts is being released/freed without
+	 * passing bts_osmux_init()/through bts_osmux_open() and hence fd is
+	 * probably 0 (memzeored). Avoid accessing it if not initialized. */
+	if (bts->osmux.fd.fd != -1 && bts->osmux.fd.data)
+		osmo_fd_close(&bts->osmux.fd);
 }

 /* Called after config file read, start services */


No longer reaching into gsl_complex struct

--- src/tibtype.c
+++ src/tibtype.c
@@ -500,8 +500,7 @@
 				   gsl_matrix_complex_get (m2, k, j));

 	gsl_complex sum;
-	sum.dat[0] = 0;
-	sum.dat[1] = 0;
+	GSL_SET_COMPLEX (&sum, 0, 0);

 	for (k = 0; k < DIM; ++k)
 	  sum = gsl_complex_add (sum, in[k]);


trivial: fu-tool: correct a reference to wrong device ID when using GUID

When finding the device by GUID we need to do a lookup first.

--- src/fu-tool.c
+++ src/fu-tool.c
@@ -1079,19 +1079,19 @@
 }

 static gboolean
-fu_util_update_by_id (FuUtilPrivate *priv, const gchar *device_id, GError **error)
+fu_util_update_by_id (FuUtilPrivate *priv, const gchar *id, GError **error)
 {
 	FwupdRelease *rel;
 	g_autoptr(FuDevice) dev = NULL;
 	g_autoptr(GPtrArray) rels = NULL;

-	/* do not allow a partial device-id */
-	dev = fu_util_get_device (priv, device_id, error);
+	/* do not allow a partial device-id, lookup GUIDs */
+	dev = fu_util_get_device (priv, id, error);
 	if (dev == NULL)
 		return FALSE;

 	/* get the releases for this device and filter for validity */
-	rels = fu_engine_get_upgrades (priv->engine, device_id, error);
+	rels = fu_engine_get_upgrades (priv->engine, fu_device_get_id (dev), error);
 	if (rels == NULL)
 		return FALSE;
 	rel = g_ptr_array_index (rels, 0);


Fixed function signature of tib inverse

Fixed function signature of tib inverse

--- src/tibtype.c
+++ src/tibtype.c
@@ -658,10 +658,10 @@
 }

 static TIB *
-inverse (TIB *t)
+inverse (const TIB *t)
 {
   /* TODO: convert t to the inverse of t */
-  return t;
+  return tib_copy (t);
 }

 TIB *


fix write_barrier

fix write_barrier

--- src/gc/bmgc.h
+++ src/gc/bmgc.h
@@ -84,9 +84,11 @@
 #if _WIN64
 #define FFS(n) __builtin_ffsll(n)
 #define CLZ(n) __builtin_clzll(n)
+#define CTZ(x) __builtin_ctzll(x)
 #else
 #define FFS(n) __builtin_ffsl(n)
 #define CLZ(n) __builtin_clzl(n)
+#define CTZ(x) __builtin_ctzl(x)
 #endif
 #define BSR(n) CLZ(n)
 #define BM_SET(m, mask)  (m |= mask)
@@ -189,7 +191,7 @@

 static inline void bitmap_set(bitmap_t *bm, unsigned index, unsigned val)
 {
-	bitmap_t mask = val << (index % BITS);
+	bitmap_t mask = (uintptr_t)val << (index % BITS);
 	*bm |= mask;
 }

@@ -242,14 +244,19 @@
 typedef Segment *SegmentPtr;
 typedef void *VoidPtr;
 typedef kObject *ObjectPtr;
+typedef bitmap_t *BitMapPtr;
 DEF_ARRAY_T_OP(SegmentPtr);
 DEF_ARRAY_T_OP(size_t);
 DEF_ARRAY_T_OP(VoidPtr);
 DEF_ARRAY_T_OP(ObjectPtr);
+DEF_ARRAY_T_OP(BitMapPtr);

 struct HeapManager {
 	long flags;
 	SubHeap heaps[SUBHEAP_KLASS_MAX+1];
+#ifdef USE_GENERATIONAL_GC
+	ARRAY(BitMapPtr)  remember_sets;
+#endif
 	Segment *segmentList;
 	ARRAY(SegmentPtr) segment_pool_a;
 	ARRAY(size_t)     segment_size_a;
@@ -272,6 +279,7 @@
 	bitmap_t *snapshot;
 	bitmap_t *snapshot_base[SEGMENT_LEVEL];
 	int tenure_live_count;
+	bitmap_t *remember_set; /* for debug */
 #else
 	void *unused;
 #endif
@@ -283,7 +291,8 @@

 typedef struct BlockHeader {
 	Segment *seg;
-	int klass;
+	long klass;
+	bitmap_t *remember_set;
 } BlockHeader;

 typedef struct gc_stat {
@@ -1234,6 +1243,24 @@
 	return pool;
 }

+#ifdef USE_GENERATIONAL_GC
+static void dispatchRememberSet(HeapManager *mng, size_t heap_size, AllocationBlock *blk)
+{
+	BlockHeader *head;
+	Segment *seg = mng->segmentList;
+	bitmap_t *map = do_malloc(heap_size / (MIN_ALIGN) / sizeof(bitmap_t));
+	ARRAY_add(BitMapPtr,  &mng->remember_sets, map);
+	while (seg) {
+		head = (BlockHeader *) blk;
+		head->remember_set = map;
+		seg->remember_set  = map;
+		seg = seg->next;
+		map += SEGMENT_SIZE / MIN_ALIGN / BITS;
+		blk++;
+	}
+}
+#endif
+
 static void SegmentPool_dispose(Segment *pool, size_t size)
 {
 	Segment *seg = NULL;
@@ -1264,9 +1291,13 @@
 	segment_pool = SegmentPool_init(list_size, (AllocationBlock*) managed_heap);
 	mng->segmentList  = segment_pool;

+#ifdef USE_GENERATIONAL_GC
+	dispatchRememberSet(mng, heap_size, (AllocationBlock*) managed_heap);
+#endif
+
 	ARRAY_add(size_t,  &mng->heap_size_a, heap_size);
-	ARRAY_add(VoidPtr, &mng->managed_heap_a    , (void*)managed_heap);
-	ARRAY_add(VoidPtr, &mng->managed_heap_end_a, (void*)managed_heap_end);
+	ARRAY_add(VoidPtr, &mng->managed_heap_a    , managed_heap);
+	ARRAY_add(VoidPtr, &mng->managed_heap_end_a, managed_heap_end);

 	ARRAY_add(SegmentPtr, &mng->segment_pool_a, segment_pool);
 	ARRAY_add(size_t, &mng->segment_size_a, list_size);
@@ -1290,6 +1321,7 @@
 	ARRAY_init(size_t, &mng->segment_size_a);
 #ifdef USE_GENERATIONAL_GC
 	ARRAY_init(ObjectPtr, &mng->remember_set);
+	ARRAY_init(BitMapPtr, &mng->remember_sets);
 #endif

 	HeapManager_expandHeap(kctx, mng, list_size);
@@ -1642,15 +1674,42 @@
 		}
 	}
 	ARRAY_add(ObjectPtr, &mng->remember_set, o);
+	//uintptr_t addr   = ((uintptr_t)o & ~(SEGMENT_SIZE - ONE));
+	//uintptr_t offset = ((uintptr_t)o &  (SEGMENT_SIZE - ONE)) >> SUBHEAP_KLASS_MIN;
+	//BlockHeader *head = (BlockHeader*) addr;
+	//bitmap_t *map = head->remember_set;
+	//bitmap_set(map+(offset/BITS), offset%BITS, Object_isTenure(o));
 }

 static void RememberSet_reftrace(KonohaContext *kctx, HeapManager *mng)
 {
-	size_t i, size = ARRAY_size(mng->remember_set);
+	size_t i;
 	FOR_EACH_ARRAY_(mng->remember_set, i) {
 		kObject* o =  (kObject *)ARRAY_n(mng->remember_set, i);
 		KONOHA_reftraceObject(kctx, o);
 	}
+	//FOR_EACH_ARRAY_(mng->remember_sets, i) {
+	//	uintptr_t base_address = (uintptr_t) ARRAY_n(mng->managed_heap_a, i);
+	//	size_t bitmap_size = ARRAY_n(mng->heap_size_a, i) / (MIN_ALIGN * BITS);
+	//	bitmap_t *base = ARRAY_n(mng->remember_sets, i);
+	//	bitmap_t *m = base;
+	//	bitmap_t *e = m + bitmap_size;
+	//	for (; m != e; base+=BITS, base_address += SEGMENT_SIZE) {
+	//		for (; m < base + BITS; ++m) {
+	//			if (*m == 0)
+	//				continue;
+	//			bitmap_t b = (*m);
+	//			while (b != 0) {
+	//				unsigned index, offset;
+	//				b ^= 1UL << index;
+	//				index = CTZ(b);
+	//				offset = (m - base) * BITS + index;
+	//				kObject *o = (kObject*)(base_address + (offset << SUBHEAP_KLASS_MIN));
+	//			}
+	//			bitmap_reset(m, 0);
+	//		}
+	//	}
+	//}
 }

 static void RememberSet_clear(HeapManager *mng)
@@ -1888,7 +1947,6 @@
 	o->fieldObjectItems[0] = NULL;\
 } while (0)

-kbool_t MODGC_kObject_isManaged(KonohaContext *kctx, void *ptr);
 kObject *MODGC_omalloc(KonohaContext *kctx, size_t size)
 {
 	kObjectVar *o = (kObjectVar*)bm_malloc_internal(kctx, HeapMng(kctx), size);
@@ -1981,6 +2039,8 @@
 		KSET_KLIB(Kfree, 0);
 		KSET_KLIB(Kwrite_barrier, 0);
 		KLIB Konoha_setModule(kctx, MOD_gc, &base->h, 0);
+		assert(sizeof(BlockHeader) <= MIN_ALIGN
+				&& "Minimum size of Object may lager than sizeof BlockHeader");
 	}
 	kmodgc_setup(ctx, (KonohaModule*) memshare(kctx), 1);
 }


x86, core: Optimize hweight32()

x86, core: Optimize hweight32()

Optimize hweight32 by using the same technique in hweight64.

The proof of this technique can be found in the commit log for
f9b4192923fa6e38331e88214b1fe5fc21583fcc ("bitops: hweight()
speedup").

The userspace benchmark on x86_32 showed 20% speedup with
bitmap_weight() which uses hweight32 to count bits for each
unsigned long on 32bit architectures.

 int main(void)
 {
	#define SZ (1024 * 1024 * 512)

	static DECLARE_BITMAP(bitmap, SZ) = {
	        [0 ... 100] = 1,
	};

	return bitmap_weight(bitmap, SZ);
 }

Signed-off-by: Akinobu Mita <3807cf899f217da549814bf6c330d3b6e6819ccf@gmail.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Cc: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>
LKML-Reference: <1258603932-4590-1-git-send-email-3807cf899f217da549814bf6c330d3b6e6819ccf@gmail.com>
[ only x86 sets ARCH_HAS_FAST_MULTIPLIER so we do this via the x86 tree]
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@elte.hu>


bpf: pass the correct accumulator state to the next level

We were mistakenly passing the wrong accumulator state (the state at
the start of the instruction block, not at the end) which was causing
us to generate unnecessary load instructions.

Signed-off-by: Paul Moore <a027184a55211cd23e3f3094f1fdc728df5e0500@paul-moore.com>

--- src/gen_bpf.c
+++ src/gen_bpf.c
@@ -854,6 +854,13 @@
 			goto node_failure;
 	}

+	/* set the accumulator state at the end of the block */
+	/* NOTE: the accumulator end state is very critical when we are
+	 *       assembling the final state; we assume that however we leave
+	 *       this instruction block the accumulator state is represented
+	 *       by blk->acc_end, it must be kept correct */
+	blk->acc_end = *a_state;
+
 	/* check the accumulator against the datum */
 	switch (node->op) {
 	case SCMP_CMP_MASKED_EQ:
@@ -898,7 +905,6 @@
 		goto node_failure;

 	blk->node = node;
-	blk->acc_end = *a_state;
 	return blk;

 node_failure:
@@ -953,7 +959,7 @@
 		case TGT_PTR_DB:
 			node = (struct db_arg_chain_tree *)i_iter->jt.tgt.db;
 			b_new = _gen_bpf_chain(state, sys, node,
-					       nxt_jump, &blk->acc_start);
+					       nxt_jump, &blk->acc_end);
 			if (b_new == NULL)
 				return NULL;
 			i_iter->jt = _BPF_JMP_HSH(b_new->hash);
@@ -979,7 +985,7 @@
 		case TGT_PTR_DB:
 			node = (struct db_arg_chain_tree *)i_iter->jf.tgt.db;
 			b_new = _gen_bpf_chain(state, sys, node,
-					       nxt_jump, &blk->acc_start);
+					       nxt_jump, &blk->acc_end);
 			if (b_new == NULL)
 				return NULL;
 			i_iter->jf = _BPF_JMP_HSH(b_new->hash);


Added API version checking

Added API version checking

git-svn-id: 793bb72743a407948e3701719c462b6a765bc435@937 35dc7657-300d-0410-a2e5-dc2837fedb53

--- src/module.c
+++ src/module.c
@@ -84,6 +84,17 @@
 		return NULL;
 	}
 	free( module_symbol );
+
+	/* Check the API version */
+	if (MPG123_MODULE_API_VERSION > module->api_version) {
+		error( "API version of module is too old" );
+		lt_dlclose( handle );
+		return NULL;
+	} else if (MPG123_MODULE_API_VERSION > module->api_version) {
+		error( "API version of module is too new" );
+		lt_dlclose( handle );
+		return NULL;
+	}

 	/* Store handle in the data structure */
 	module->handle = handle;


need to invoke gencode_block() rather than exprlist for if, while and do-while.

--- src/gencode.c
+++ src/gencode.c
@@ -161,20 +161,6 @@
 	return comp->label++;
 }

-/*
-
-List of expressions or statements.
-
-*/
-static void
-gencode_exprlist(M1_compiler *comp, m1_expression *expr) {
-    m1_expression *iter = expr;
-
-    while (iter != NULL) {
-        gencode_expr(comp, iter);
-        iter = iter->next;
-    }
-}

 static void
@@ -612,7 +598,7 @@
 	fprintf(OUT, "\tgoto L%d\n", endlabel);

 	fprintf(OUT, "L%d:\n", startlabel);
-	gencode_exprlist(comp, w->block);
+	gencode_expr(comp, w->block);

 	fprintf(OUT, "L%d:\n", endlabel);

@@ -647,7 +633,7 @@
     push(comp->continuestack, startlabel);

     fprintf(OUT, "L%d:\n", startlabel);
-    gencode_exprlist(comp, w->block);
+    gencode_expr(comp, w->block);

     gencode_expr(comp, w->cond);
     reg = popreg(comp->regstack);
@@ -705,7 +691,7 @@
     fprintf(OUT, "L%d:\n", blocklabel);

     if (i->block)
-        gencode_exprlist(comp, i->block);
+        gencode_expr(comp, i->block);

     fprintf(OUT, "L%d:\n", steplabel);
     if (i->step)
@@ -747,13 +733,13 @@

     /* else block */
     if (i->elseblock) {
-        gencode_exprlist(comp, i->elseblock);
+        gencode_expr(comp, i->elseblock);
     }
     fprintf(OUT, "\tgoto L%d\n", endlabel);

     /* if block */
     fprintf(OUT, "L%d:\n", iflabel);
-    gencode_exprlist(comp, i->ifblock);
+    gencode_expr(comp, i->ifblock);

     fprintf(OUT, "L%d:\n", endlabel);

@@ -1811,7 +1797,7 @@
         testlabel = gen_label(comp);
         fprintf(OUT, "\tgoto_if L%d, I%d\n", testlabel, test.no);
         /* generate code for this case's block. */
-        gencode_exprlist(comp, caseiter->block);
+        gencode_expr(comp, caseiter->block);
         /* next test label. */
         fprintf(OUT, "L%d:\n", testlabel);

@@ -2087,13 +2073,22 @@
 }

+
+
 static void
 gencode_block(M1_compiler *comp, m1_block *block) {
+    m1_expression *iter = block->stats;
+
     assert(&block->locals != NULL);
     /* set current symtab to this block's symtab. */
     comp->currentsymtab = &block->locals;

-    gencode_exprlist(comp, block->stats);
+    /* iterate over block's statements and generate code for each. */
+    while (iter != NULL) {
+        gencode_expr(comp, iter);
+        iter = iter->next;
+    }
+
     /* restore parent scope. */
     comp->currentsymtab = block->locals.parentscope;
 }


Add WaveletTreeNextValue_RedisCommand

Add WaveletTreeNextValue_RedisCommand

--- src/module.c
+++ src/module.c
@@ -369,6 +369,47 @@
     return REDISMODULE_OK;
 }

+// wvltr.nextvalue KEY FROM TO MIN MAX
+int WaveletTreeNextValue_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
+    if (argc != 6)
+        return RedisModule_WrongArity(ctx);
+
+    long long from, to, min, max;
+    if (RedisModule_StringToLongLong(argv[2], &from) != REDISMODULE_OK) {
+        return REDISMODULE_ERR;
+    }
+    if (RedisModule_StringToLongLong(argv[3], &to) != REDISMODULE_OK) {
+        return REDISMODULE_ERR;
+    }
+    if (RedisModule_StringToLongLong(argv[4], &min) != REDISMODULE_OK) {
+        return REDISMODULE_ERR;
+    }
+    if (RedisModule_StringToLongLong(argv[5], &max) != REDISMODULE_OK) {
+        return REDISMODULE_ERR;
+    }
+
+    RedisModuleKey *key = RedisModule_OpenKey(ctx, argv[1], REDISMODULE_READ);
+
+    int type = RedisModule_KeyType(key);
+    if (type != REDISMODULE_KEYTYPE_EMPTY && RedisModule_ModuleTypeGetType(key) != WaveletTreeType) {
+        RedisModule_CloseKey(key);
+        return RedisModule_ReplyWithError(ctx, REDISMODULE_ERRORMSG_WRONGTYPE);
+    }
+
+    if (type == REDISMODULE_KEYTYPE_EMPTY) {
+        RedisModule_CloseKey(key);
+        RedisModule_ReplyWithLongLong(ctx, 0);
+        return REDISMODULE_OK;
+    }
+
+    wt_tree *tree = RedisModule_ModuleTypeGetValue(key);
+    int res = wt_range_next_value(tree, from, to, min, max);
+
+    RedisModule_CloseKey(key);
+    RedisModule_ReplyWithLongLong(ctx, res);
+    return REDISMODULE_OK;
+}
+
 int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
     if (RedisModule_Init(ctx, "wvltr", 1, REDISMODULE_APIVER_1) == REDISMODULE_ERR)
         return REDISMODULE_ERR;


Removed extra element from the paneling array struct.

--- src/gholder.c
+++ src/gholder.c
@@ -75,7 +75,6 @@
   {GEO_LOCATION    , add_root_to_holder, NULL} ,
 #endif
   {STATUS_CODES    , add_root_to_holder, NULL} ,
-  {VISIT_TIMES     , add_data_to_holder, NULL} ,
 };
 /* *INDENT-ON* */


lib/initend.c: print dbg msg about successful vpkg conf files read.

--- lib/initend.c
+++ lib/initend.c
@@ -108,12 +108,13 @@
 			path = xbps_xasprintf("%s/%s", vpkgdir, dp->d_name);
 			fp = fopen(path, "r");
 			assert(fp);
-			free(path);
 			if (cfg_parse_fp(xh->cfg, fp) != 0) {
 				xbps_error_printf("Failed to parse "
 				    "vpkg conf file %s:\n", dp->d_name);
 			}
 			fclose(fp);
+			xbps_dbg_printf(xh, "Injected vpkgs from %s\n", path);
+			free(path);
 		}
 	}
 	closedir(dirp);


Made the internal malloc() optional, selected by the ISC_MEM_USE_INTERNAL_MALLOC preprocessor constant.

--- lib/isc/mem.c
+++ lib/isc/mem.c
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */

-/* $Id: mem.c,v 1.78 2001/01/09 21:56:16 bwelling Exp $ */
+/* $Id: mem.c,v 1.79 2001/01/25 01:18:00 neild Exp $ */

 #include <config.h>

@@ -34,6 +34,16 @@
 #include <isc/util.h>

 unsigned int isc_mem_debugging = 0;
+
+/*
+ * Define ISC_MEM_USE_INTERNAL_MALLOC=1 to use the internal malloc()
+ * implementation in preference to the system one.  The internal malloc()
+ * is very space-efficient, and quite fast on uniprocessor systems.  It
+ * performs poorly on multiprocessor machines.
+ */
+#ifndef ISC_MEM_USE_INTERNAL_MALLOC
+#define ISC_MEM_USE_INTERNAL_MALLOC 0
+#endif

 /*
  * Constants.
@@ -84,8 +94,10 @@
 struct stats {
 	unsigned long		gets;
 	unsigned long		totalgets;
+#if ISC_MEM_USE_INTERNAL_MALLOC
 	unsigned long		blocks;
 	unsigned long		freefrags;
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
 };

 #define MEM_MAGIC		0x4D656d43U	/* MemC. */
@@ -99,16 +111,7 @@
 	isc_memfree_t		memfree;
 	void *			arg;
 	size_t			max_size;
-	size_t			mem_target;
-	element **		freelists;
-	element *		basic_blocks;
-	unsigned char **	basic_table;
-	unsigned int		basic_table_count;
-	unsigned int		basic_table_size;
-	unsigned char *		lowest;
-	unsigned char *		highest;
 	isc_boolean_t		checkfree;
-	isc_boolean_t		trysplit;
 	struct stats *		stats;
 	unsigned int		references;
 	size_t			quota;
@@ -120,6 +123,19 @@
 	isc_mem_water_t		water;
 	void *			water_arg;
 	ISC_LIST(isc_mempool_t)	pools;
+
+#if ISC_MEM_USE_INTERNAL_MALLOC
+	size_t			mem_target;
+	element **		freelists;
+	element *		basic_blocks;
+	unsigned char **	basic_table;
+	unsigned int		basic_table_count;
+	unsigned int		basic_table_size;
+	unsigned char *		lowest;
+	unsigned char *		highest;
+	isc_boolean_t		trysplit;
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
+
 #if ISC_MEM_TRACKLINES
 	ISC_LIST(debuglink_t)	debuglist;
 #endif
@@ -266,6 +282,7 @@
 }
 #endif /* ISC_MEM_TRACKLINES */

+#if ISC_MEM_USE_INTERNAL_MALLOC
 static inline size_t
 rmsize(size_t size) {
 	/*
@@ -608,6 +625,87 @@
 	ctx->inuse -= new_size;
 }

+#else /* ISC_MEM_USE_INTERNAL_MALLOC */
+
+/*
+ * Perform a malloc, doing memory filling and overrun detection as necessary.
+ */
+static inline void *
+mem_get(isc_mem_t *ctx, size_t size) {
+	char *ret;
+
+#if ISC_MEM_CHECKOVERRUN
+	size += 1;
+#endif
+
+	ret = (ctx->memalloc)(ctx->arg, size);
+
+#if ISC_MEM_FILL
+	if (ret != NULL)
+		memset(ret, 0xbe, size); /* Mnemonic for "beef". */
+#else
+#  if ISC_MEM_CHECKOVERRUN
+	if (ret != NULL)
+		ret[size-1] = 0xbe;
+#  endif
+#endif
+
+	return (ret);
+}
+
+/*
+ * Perform a free, doing memory filling and overrun detection as necessary.
+ */
+static inline void
+mem_put(isc_mem_t *ctx, void *mem, size_t size) {
+#if ISC_MEM_CHECKOVERRUN
+	INSIST(((char *)mem)[size] == 0xbe);
+#endif
+#if ISC_MEM_FILL
+	memset(mem, 0xde, size); /* Mnemonic for "dead". */
+#endif
+
+	(ctx->memfree)(ctx->arg, mem);
+}
+
+/*
+ * Update internal counters after a memory get.
+ */
+static inline void
+mem_getstats(isc_mem_t *ctx, size_t size) {
+	ctx->total += size;
+	ctx->inuse += size;
+
+	if (size > ctx->max_size) {
+		ctx->stats[ctx->max_size].gets++;
+		ctx->stats[ctx->max_size].totalgets++;
+	} else {
+		ctx->stats[size].gets++;
+		ctx->stats[size].totalgets++;
+	}
+}
+
+/*
+ * Update internal counters after a memory put.
+ */
+static inline void
+mem_putstats(isc_mem_t *ctx, void *ptr, size_t size) {
+	UNUSED(ptr);
+
+	INSIST(ctx->inuse >= size);
+	ctx->inuse -= size;
+
+	if (size > ctx->max_size) {
+		INSIST(ctx->stats[ctx->max_size].gets > 0);
+		ctx->stats[ctx->max_size].gets--;
+	} else {
+		INSIST(ctx->stats[size].gets > 0);
+		ctx->stats[size].gets--;
+	}
+}
+
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
+
 /*
  * Private.
  */
@@ -634,12 +732,17 @@
 		isc_mem_t **ctxp)
 {
 	isc_mem_t *ctx;
+	isc_result_t result;

 	REQUIRE(ctxp != NULL && *ctxp == NULL);
 	REQUIRE(memalloc != NULL);
 	REQUIRE(memfree != NULL);

 	INSIST((ALIGNMENT_SIZE & (ALIGNMENT_SIZE - 1)) == 0);
+
+#if !ISC_MEM_USE_INTERNAL_MALLOC
+	UNUSED(target_size);
+#endif

 	ctx = (memalloc)(arg, sizeof *ctx);
 	if (ctx == NULL)
@@ -649,46 +752,6 @@
 		ctx->max_size = DEF_MAX_SIZE;
 	else
 		ctx->max_size = init_max_size;
-	if (target_size == 0)
-		ctx->mem_target = DEF_MEM_TARGET;
-	else
-		ctx->mem_target = target_size;
-	ctx->memalloc = memalloc;
-	ctx->memfree = memfree;
-	ctx->arg = arg;
-	ctx->freelists = (memalloc)(arg, ctx->max_size * sizeof (element *));
-	if (ctx->freelists == NULL) {
-		(memfree)(arg, ctx);
-		return (ISC_R_NOMEMORY);
-	}
-	ctx->checkfree = ISC_TRUE;
-	ctx->trysplit = ISC_FALSE;
-	memset(ctx->freelists, 0,
-	       ctx->max_size * sizeof (element *));
-	ctx->stats = (memalloc)(arg,
-				(ctx->max_size+1) * sizeof (struct stats));
-	if (ctx->stats == NULL) {
-		(memfree)(arg, ctx->freelists);
-		(memfree)(arg, ctx);
-		return (ISC_R_NOMEMORY);
-	}
-	memset(ctx->stats, 0, (ctx->max_size + 1) * sizeof (struct stats));
-	ctx->basic_blocks = NULL;
-	ctx->basic_table = NULL;
-	ctx->basic_table_count = 0;
-	ctx->basic_table_size = 0;
-	ctx->lowest = NULL;
-	ctx->highest = NULL;
-	if (isc_mutex_init(&ctx->lock) != ISC_R_SUCCESS) {
-		(memfree)(arg, ctx->stats);
-		(memfree)(arg, ctx->freelists);
-		(memfree)(arg, ctx);
-		UNEXPECTED_ERROR(__FILE__, __LINE__,
-				 "isc_mutex_init() %s",
-				 isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
-						ISC_MSG_FAILED, "failed"));
-		return (ISC_R_UNEXPECTED);
-	}
 	ctx->references = 1;
 	ctx->quota = 0;
 	ctx->total = 0;
@@ -700,13 +763,74 @@
 	ctx->water_arg = NULL;
 	ctx->magic = MEM_MAGIC;
 	isc_ondestroy_init(&ctx->ondestroy);
+	ctx->memalloc = memalloc;
+	ctx->memfree = memfree;
+	ctx->arg = arg;
+	ctx->stats = NULL;
 	ISC_LIST_INIT(ctx->pools);
+
+#if ISC_MEM_USE_INTERNAL_MALLOC
+	ctx->freelists = NULL;
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
+
+	ctx->stats = (memalloc)(arg,
+				(ctx->max_size+1) * sizeof (struct stats));
+	if (ctx->stats == NULL) {
+		result = ISC_R_NOMEMORY;
+		goto error;
+	}
+	memset(ctx->stats, 0, (ctx->max_size + 1) * sizeof (struct stats));
+
+#if ISC_MEM_USE_INTERNAL_MALLOC
+	if (target_size == 0)
+		ctx->mem_target = DEF_MEM_TARGET;
+	else
+		ctx->mem_target = target_size;
+	ctx->freelists = (memalloc)(arg, ctx->max_size * sizeof (element *));
+	if (ctx->freelists == NULL) {
+		result = ISC_R_NOMEMORY;
+		goto error;
+	}
+	ctx->checkfree = ISC_TRUE;
+	ctx->trysplit = ISC_FALSE;
+	memset(ctx->freelists, 0,
+	       ctx->max_size * sizeof (element *));
+	ctx->basic_blocks = NULL;
+	ctx->basic_table = NULL;
+	ctx->basic_table_count = 0;
+	ctx->basic_table_size = 0;
+	ctx->lowest = NULL;
+	ctx->highest = NULL;
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
+
+	if (isc_mutex_init(&ctx->lock) != ISC_R_SUCCESS) {
+		UNEXPECTED_ERROR(__FILE__, __LINE__,
+				 "isc_mutex_init() %s",
+				 isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
+						ISC_MSG_FAILED, "failed"));
+		result = ISC_R_UNEXPECTED;
+		goto error;
+	}
+
 #if ISC_MEM_TRACKLINES
 	ISC_LIST_INIT(ctx->debuglist);
 #endif

 	*ctxp = ctx;
 	return (ISC_R_SUCCESS);
+
+  error:
+	if (ctx) {
+		if (ctx->stats)
+			(memfree)(arg, ctx->stats);
+#if ISC_MEM_USE_INTERNAL_MALLOC
+		if (ctx->freelists)
+			(memfree)(arg, ctx->freelists);
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
+		(memfree)(arg, ctx);
+	}
+
+	return (result);
 }

 isc_result_t
@@ -725,7 +849,10 @@

 	ctx->magic = 0;

+#if ISC_MEM_USE_INTERNAL_MALLOC
 	INSIST(ISC_LIST_EMPTY(ctx->pools));
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
+
 #if ISC_MEM_TRACKLINES
 	if (ctx->checkfree)
 		INSIST(ISC_LIST_EMPTY(ctx->debuglist));
@@ -747,18 +874,14 @@
 			INSIST(ctx->stats[i].gets == 0);
 	}

-#if 0					/* XXX brister debugging */
-	for (i = 0; i < ctx->basic_table_count; i++)
-		memset(ctx->basic_table[i], 0x0,
-		       NUM_BASIC_BLOCKS * ctx->mem_target);
-#endif
-
-
+	(ctx->memfree)(ctx->arg, ctx->stats);
+
+#if ISC_MEM_USE_INTERNAL_MALLOC
 	for (i = 0; i < ctx->basic_table_count; i++)
 		(ctx->memfree)(ctx->arg, ctx->basic_table[i]);
 	(ctx->memfree)(ctx->arg, ctx->freelists);
-	(ctx->memfree)(ctx->arg, ctx->stats);
 	(ctx->memfree)(ctx->arg, ctx->basic_table);
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */

 	ondest = ctx->ondestroy;

@@ -828,13 +951,21 @@
 	 */
 	*ctxp = NULL;

-	LOCK(&ctx->lock);
+#if ISC_MEM_USE_INTERNAL_MALLOC
+	LOCK(&ctx->lock);
+	mem_putunlocked(ctx, ptr, size);
+#else /* ISC_MEM_USE_INTERNAL_MALLOC */
+	mem_put(ctx, ptr, size);
+	LOCK(&ctx->lock);
+	mem_putstats(ctx, ptr, size);
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
+
 	DELETE_TRACE(ctx, ptr, size, file, line);
-	mem_putunlocked(ctx, ptr, size);
 	INSIST(ctx->references > 0);
 	ctx->references--;
 	if (ctx->references == 0)
 		want_destroy = ISC_TRUE;
+
 	UNLOCK(&ctx->lock);

 	if (want_destroy)
@@ -894,8 +1025,15 @@

 	REQUIRE(VALID_CONTEXT(ctx));

+#if ISC_MEM_USE_INTERNAL_MALLOC
 	LOCK(&ctx->lock);
 	ptr = mem_getunlocked(ctx, size);
+#else /* ISC_MEM_USE_INTERNAL_MALLOC */
+	ptr = mem_get(ctx, size);
+	LOCK(&ctx->lock);
+	mem_getstats(ctx, size);
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
+
 	ADD_TRACE(ctx, ptr, size, file, line);
 	if (ctx->hi_water != 0 && !ctx->hi_called &&
 	    ctx->inuse > ctx->hi_water) {
@@ -904,16 +1042,7 @@
 	}
 	UNLOCK(&ctx->lock);

-	/* XXX remove */
-	if (ctx->hi_water)
-		fprintf(stderr,"inuse %u, total %u\n", ctx->inuse, ctx->total);
-
 	if (call_water) {
-		/* XXX remove */
-		fprintf(stderr, "%s water(%p, ISC_MEM_HIWATER)\n",
-			isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
-				       ISC_MSG_CALLING, "calling"),
-			ctx->water_arg);
 		(ctx->water)(ctx->water_arg, ISC_MEM_HIWATER);
 	}

@@ -928,31 +1057,31 @@
 	REQUIRE(VALID_CONTEXT(ctx));
 	REQUIRE(ptr != NULL);

-	LOCK(&ctx->lock);
+#if ISC_MEM_USE_INTERNAL_MALLOC
+	LOCK(&ctx->lock);
+	mem_putunlocked(ctx, ptr, size);
+#else /* ISC_MEM_USE_INTERNAL_MALLOC */
+	mem_put(ctx, ptr, size);
+	LOCK(&ctx->lock);
+	mem_putstats(ctx, ptr, size);
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
+
 	DELETE_TRACE(ctx, ptr, size, file, line);
-	mem_putunlocked(ctx, ptr, size);
 	if (ctx->hi_called && ctx->inuse < ctx->lo_water) {
 		ctx->hi_called = ISC_FALSE;
 		call_water = ISC_TRUE;
 	}
 	UNLOCK(&ctx->lock);

-	/* XXX remove */
-	if (ctx->hi_water)
-		fprintf(stderr,"inuse %u, total %u\n", ctx->inuse, ctx->total);
-
 	if (call_water) {
-		/* XXX remove */
-		fprintf(stderr, "%s water(%p,ISC_MEM_LOWATER)\n",
-			isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
-				       ISC_MSG_CALLING, "calling"),
-			ctx->water_arg);
 		(ctx->water)(ctx->water_arg, ISC_MEM_LOWATER);
 	}
 }

 isc_result_t
 isc_mem_preallocate(isc_mem_t *ctx) {
+#if ISC_MEM_USE_INTERNAL_MALLOC
+
 	size_t i;
 	isc_result_t result = ISC_R_SUCCESS;
 	void *ptr;
@@ -973,6 +1102,13 @@
 	UNLOCK(&ctx->lock);

 	return (result);
+
+#else /* ISC_MEM_USE_INTERNAL_MALLOC */
+
+	UNUSED(ctx);
+	return (ISC_R_SUCCESS);
+
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
 }

 /*
@@ -987,7 +1123,7 @@
 	REQUIRE(VALID_CONTEXT(ctx));
 	LOCK(&ctx->lock);

-	if (ctx->freelists != NULL) {
+	if (ctx->inuse > 0) {
 		for (i = 0; i <= ctx->max_size; i++) {
 			s = &ctx->stats[i];

@@ -996,9 +1132,11 @@
 			fprintf(out, "%s%5lu: %11lu gets, %11lu rem",
 				(i == ctx->max_size) ? ">=" : "  ",
 				(unsigned long) i, s->totalgets, s->gets);
+#if ISC_MEM_USE_INTERNAL_MALLOC
 			if (s->blocks != 0 || s->freefrags != 0)
 				fprintf(out, " (%lu bl, %lu ff)",
 					s->blocks, s->freefrags);
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
 			fputc('\n', out);
 		}
 	}
@@ -1079,10 +1217,13 @@

 isc_boolean_t
 isc_mem_valid(isc_mem_t *ctx, void *ptr) {
+#if ISC_MEM_USE_INTERNAL_MALLOC
+
 	unsigned char *cp = ptr;
 	isc_boolean_t result = ISC_FALSE;

 	REQUIRE(VALID_CONTEXT(ctx));
+
 	LOCK(&ctx->lock);

 	if (ctx->lowest != NULL && cp >= ctx->lowest && cp <= ctx->highest)
@@ -1091,6 +1232,14 @@
 	UNLOCK(&ctx->lock);

 	return (result);
+
+#else /* ISC_MEM_USE_INTERNAL_MALLOC */
+
+	UNUSED(ctx);
+	UNUSED(ptr);
+	return (ISC_TRUE);
+
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
 }

 /*
@@ -1103,7 +1252,11 @@
 	size_info *si;

 	size += ALIGNMENT_SIZE;
+#if ISC_MEM_USE_INTERNAL_MALLOC
 	si = mem_getunlocked(ctx, size);
+#else /* ISC_MEM_USE_INTERNAL_MALLOC */
+	si = mem_get(ctx, size);
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
 	if (si == NULL)
 		return (NULL);
 	si->u.size = size;
@@ -1116,12 +1269,20 @@

 	REQUIRE(VALID_CONTEXT(ctx));

+#if ISC_MEM_USE_INTERNAL_MALLOC
 	LOCK(&ctx->lock);
 	si = isc__mem_allocateunlocked(ctx, size);
+#else /* ISC_MEM_USE_INTERNAL_MALLOC */
+	si = isc__mem_allocateunlocked(ctx, size);
+	LOCK(&ctx->lock);
+	mem_getstats(ctx, si[-1].u.size);
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
+
 #if ISC_MEM_TRACKLINES
 	if (si != NULL)
 		ADD_TRACE(ctx, si, si[-1].u.size, file, line);
 #endif
+
 	UNLOCK(&ctx->lock);

 	return (si);
@@ -1130,16 +1291,28 @@
 void
 isc__mem_free(isc_mem_t *ctx, void *ptr FLARG) {
 	size_info *si;
+	size_t size;

 	REQUIRE(VALID_CONTEXT(ctx));
 	REQUIRE(ptr != NULL);

 	si = &(((size_info *)ptr)[-1]);
-	LOCK(&ctx->lock);
+	size = si->u.size;
+
+#if ISC_MEM_USE_INTERNAL_MALLOC
+	LOCK(&ctx->lock);
+	mem_putunlocked(ctx, si, size);
+#else /* ISC_MEM_USE_INTERNAL_MALLOC */
+	mem_put(ctx, si, size);
+	LOCK(&ctx->lock);
+	mem_putstats(ctx, si, size);
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
+
 	DELETE_TRACE(ctx, ptr, si->u.size, file, line);
-	mem_putunlocked(ctx, si, si->u.size);
+
 	UNLOCK(&ctx->lock);
 }
+

 /*
  * Other useful things.
@@ -1175,12 +1348,17 @@

 void
 isc_mem_setsplit(isc_mem_t *ctx, isc_boolean_t flag) {
+#if ISC_MEM_USE_INTERNAL_MALLOC
 	REQUIRE(VALID_CONTEXT(ctx));
 	LOCK(&ctx->lock);

 	ctx->trysplit = flag;

 	UNLOCK(&ctx->lock);
+#else /* ISC_MEM_USE_INTERNAL_MALLOC */
+	UNUSED(ctx);
+	UNUSED(flag);
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
 }

@@ -1259,74 +1437,6 @@
  * Memory pool stuff
  */

-
-#if 0
-/*
- * Free all but "n" items from the pool's free list.  If n == 0, all items
- * will be returned to the mctx.
- */
-static void
-mempool_release(isc_mempool_t *mpctx, unsigned int n) {
-	isc_mem_t *mctx;
-	element *item;
-	element *next;
-	unsigned int count;
-
-	mctx = mpctx->mctx;
-
-	if (mpctx->freecount <= n)
-		return;
-
-	INSIST(mpctx->items != NULL);
-	item = mpctx->items;
-	for (count = 0 ; count < n ; count++) {
-		item = item->next;
-		INSIST(item != NULL);
-	}
-
-	/*
-	 * All remaining items are to be freed.  Lock the context once,
-	 * free them all, and unlock the context.
-	 */
-	LOCK(&mctx->lock);
-	do {
-		next = item->next;
-		mem_putunlocked(mctx, item, mpctx->size);
-		INSIST(mpctx->freecount > 0);
-		mpctx->freecount--;
-		item = next;
-	} while (item != NULL);
-	UNLOCK(&mctx->lock);
-}
-#endif
-
-/*
- * Release all items on the free list.  No locking is done, the memory
- * context must be locked, and the pool if needed.
- */
-static void
-mempool_releaseall(isc_mempool_t *mpctx) {
-	isc_mem_t *mctx;
-	element *item;
-	element *next;
-
-	mctx = mpctx->mctx;
-
-	if (mpctx->freecount == 0)
-		return;
-
-	INSIST(mpctx->items != NULL);
-	item = mpctx->items;
-
-	do {
-		next = item->next;
-		mem_putunlocked(mctx, item, mpctx->size);
-		INSIST(mpctx->freecount > 0);
-		mpctx->freecount--;
-		item = next;
-	} while (item != NULL);
-}
-
 isc_result_t
 isc_mempool_create(isc_mem_t *mctx, size_t size, isc_mempool_t **mpctxp) {
 	isc_mempool_t *mpctx;
@@ -1339,13 +1449,9 @@
 	 * Allocate space for this pool, initialize values, and if all works
 	 * well, attach to the memory context.
 	 */
-	LOCK(&mctx->lock);
-
-	mpctx = mem_getunlocked(mctx, sizeof(isc_mempool_t));
-	if (mpctx == NULL) {
-		UNLOCK(&mctx->lock);
+	mpctx = isc_mem_get(mctx, sizeof(isc_mempool_t));
+	if (mpctx == NULL)
 		return (ISC_R_NOMEMORY);
-	}

 	mpctx->magic = MEMPOOL_MAGIC;
 	mpctx->lock = NULL;
@@ -1364,8 +1470,8 @@

 	*mpctxp = mpctx;

+	LOCK(&mctx->lock);
 	ISC_LIST_INITANDAPPEND(mctx->pools, mpctx, link);
-
 	UNLOCK(&mctx->lock);

 	return (ISC_R_SUCCESS);
@@ -1395,6 +1501,7 @@
 	isc_mempool_t *mpctx;
 	isc_mem_t *mctx;
 	isc_mutex_t *lock;
+	element *item;

 	REQUIRE(mpctxp != NULL);
 	mpctx = *mpctxp;
@@ -1408,23 +1515,34 @@
 	if (lock != NULL)
 		LOCK(lock);

+	/*
+	 * Return any items on the free list
+	 */
+	while (mpctx->items != NULL) {
+		INSIST(mpctx->freecount > 0);
+		mpctx->freecount--;
+		item = mpctx->items;
+		mpctx->items = item->next;
+
+#if ISC_MEM_USE_INTERNAL_MALLOC
+		LOCK(&mctx->lock);
+		mem_putunlocked(mctx, item, mpctx->size);
+		UNLOCK(&mctx->lock);
+#else /* ISC_MEM_USE_INTERNAL_MALLOC */
+		mem_put(mctx, item, mpctx->size);
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
+	}
+
+	/*
+	 * Remove our linked list entry from the memory context.
+	 */
 	LOCK(&mctx->lock);
-
-	/*
-	 * Return any items on the free list
-	 */
-	mempool_releaseall(mpctx);
-
-	/*
-	 * Remove our linked list entry from the memory context.
-	 */
 	ISC_LIST_UNLINK(mctx->pools, mpctx, link);
+	UNLOCK(&mctx->lock);

 	mpctx->magic = 0;

-	mem_putunlocked(mpctx->mctx, mpctx, sizeof(isc_mempool_t));
-
-	UNLOCK(&mctx->lock);
+	isc_mem_put(mpctx->mctx, mpctx, sizeof(isc_mempool_t));

 	if (lock != NULL)
 		UNLOCK(lock);
@@ -1479,16 +1597,20 @@
 	 * We need to dip into the well.  Lock the memory context here and
 	 * fill up our free list.
 	 */
-	LOCK(&mctx->lock);
 	for (i = 0 ; i < mpctx->fillcount ; i++) {
+#if ISC_MEM_USE_INTERNAL_MALLOC
+		LOCK(&mctx->lock);
 		item = mem_getunlocked(mctx, mpctx->size);
+		UNLOCK(&mctx->lock);
+#else /* ISC_MEM_USE_INTERNAL_MALLOC */
+		item = mem_get(mctx, mpctx->size);
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
 		if (item == NULL)
 			break;
 		item->next = mpctx->items;
 		mpctx->items = item;
 		mpctx->freecount++;
 	}
-	UNLOCK(&mctx->lock);

 	/*
 	 * If we didn't get any items, return NULL.
@@ -1506,11 +1628,13 @@
 	if (mpctx->lock != NULL)
 		UNLOCK(mpctx->lock);

+#if ISC_MEM_TRACKLINES
 	if (item != NULL) {
 		LOCK(&mctx->lock);
 		ADD_TRACE(mctx, item, mpctx->size, file, line);
 		UNLOCK(&mctx->lock);
 	}
+#endif /* ISC_MEM_TRACKLINES */

 	return (item);
 }
@@ -1537,9 +1661,13 @@
 	 * If our free list is full, return this to the mctx directly.
 	 */
 	if (mpctx->freecount >= mpctx->freemax) {
+#if ISC_MEM_USE_INTERNAL_MALLOC
 		LOCK(&mctx->lock);
 		mem_putunlocked(mctx, mem, mpctx->size);
 		UNLOCK(&mctx->lock);
+#else /* ISC_MEM_USE_INTERNAL_MALLOC */
+		mem_put(mctx, mem, mpctx->size);
+#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
 		if (mpctx->lock != NULL)
 			UNLOCK(mpctx->lock);
 		return;


FIX: empty page handling

FIX: empty page handling

--- src/gjalloc.c
+++ src/gjalloc.c
@@ -826,6 +826,7 @@
     }
 #endif

+    a->empty_pages--;
     a->num_pages--;
     free(p);


glsl: Store ir_variable_data::_num_state_slots and ::binding in 16-bits each

Valgrind massif results for a trimmed apitrace of dota2:

                  n        time(i)         total(B)   useful-heap(B) extra-heap(B)    stacks(B)
Before (32-bit): 44 40,577,049,140       68,118,608       62,441,063     5,677,545            0
After  (32-bit): 71 40,583,408,411       67,761,528       62,263,519     5,498,009            0

Before (64-bit): 63 37,122,829,194       95,153,008       87,333,600     7,819,408            0
After  (64-bit): 67 37,123,303,706       95,150,544       87,333,600     7,816,944            0

A real savings of 173KiB on 32-bit and no change on 64-bit.

Signed-off-by: Ian Romanick <2b237cafb16dc45038e85df6c85e74e6d899eba9@intel.com>
Reviewed-by: Matt Turner <789b315743a28dd066a4ba1459c35951c291d8a6@gmail.com>
Reviewed-by: Tapani Pälli <cdcb67a5e49297de94340ca09f25994bd5e7f762@intel.com>

--- src/glsl/ir.h
+++ src/glsl/ir.h
@@ -773,9 +773,24 @@
       uint16_t image_format;

    private:
-      unsigned _num_state_slots;    /**< Number of state slots used */
+      /**
+       * Number of state slots used
+       *
+       * \note
+       * This could be stored in as few as 7-bits, if necessary.  If it is made
+       * smaller, add an assertion to \c ir_variable::allocate_state_slots to
+       * be safe.
+       */
+      uint16_t _num_state_slots;

    public:
+      /**
+       * Initial binding point for a sampler, atomic, or UBO.
+       *
+       * For array types, this represents the binding point for the first element.
+       */
+      int16_t binding;
+
       /**
        * Storage location of the base of this variable
        *
@@ -800,13 +815,6 @@
        * Vertex stream output identifier.
        */
       unsigned stream;
-
-      /**
-       * Initial binding point for a sampler, atomic, or UBO.
-       *
-       * For array types, this represents the binding point for the first element.
-       */
-      int binding;

       /**
        * Location an atomic counter is stored at.


Don't use vasprintf on PLATFORM_ANDROID.

This allows sanely using g_log() within signal handlers.

--- src/goutput.c
+++ src/goutput.c
@@ -112,28 +112,25 @@
 void
 g_logv (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, va_list args)
 {
+#if PLATFORM_ANDROID
+	__android_log_vprint (to_android_priority (log_level), log_domain, format, args);
+#else
 	char *msg;

 	if (vasprintf (&msg, format, args) < 0)
 		return;

-#if PLATFORM_ANDROID
-	__android_log_print (to_android_priority (log_level),
-		/* TODO: provide a proper app name */
-		"mono", "%s%s%s",
-		log_domain != NULL ? log_domain : "",
-		log_domain != NULL ? ": " : "",
-		msg);
-#else
 	printf ("%s%s%s\n",
 		log_domain != NULL ? log_domain : "",
 		log_domain != NULL ? ": " : "",
 		msg);
-#endif
 	free (msg);
 	if (log_level & fatal){
 		fflush (stdout);
 		fflush (stderr);
+	}
+#endif
+	if (log_level & fatal){
 		abort ();
 	}
 }


fix style with the stats for the grabbers


Fix compilation error introduced in previous commit

Fix some typos along the way

--- src/greybox.c
+++ src/greybox.c
@@ -196,9 +196,9 @@

     /* Copy dependency matrices. We cannot use the GBgetDMInfoRead and
      * GBgetDMInfoWrite calls here, as these default to the combined
-     * matrix of the parent, which can be the wrong matrix in case
+     * matrix of the parent, which can be the wrong matrices in case
      * a certain pins2pins layer has restricted functionality and only
-     * over writes the combined matrix (like the regrouping layer before
+     * overwrites the combined matrix (like the regrouping layer before
      * becoming aware of the read and write matrices).  In this degenerated
      * case do the conservative thing and use the combined matrix that was
      * set.
@@ -217,7 +217,6 @@
     }
     if (model->dm_info == NULL)
         model->dm_info = default_src->dm_info;
-}

     if (model->sl_info == NULL)
         GBsetStateLabelInfo(model, GBgetStateLabelInfo(default_src));


http: don't clear output on error

http: don't clear output on error

Because CLI don't clear it. GQTP returns the output as error message
because GQTP can't return both output and error message.

--- src/groonga.c
+++ src/groonga.c
@@ -670,7 +670,6 @@
                    GRN_TEXT_LEN(&head) + GRN_TEXT_LEN(outbuf) + GRN_TEXT_LEN(&foot));
     GRN_TEXT_PUTS(ctx, body, "\r\n\r\n");
   } else {
-    GRN_BULK_REWIND(outbuf);
     output_envelope(ctx, expr_rc, &head, outbuf, &foot);
     switch (expr_rc) {
     case GRN_INVALID_ARGUMENT :


unit tests fix.

unit tests fix.

--- check/public-tests/main.c
+++ check/public-tests/main.c
@@ -161,8 +161,7 @@
 	}

 	/* Run tests.*/
-	//result = fcml_stf_run_tests( "Public API tests", fcml_arr_suites );
-	FCML_I32_A( "repne cmps byte ptr [si],byte ptr [di]", 0xF2, 0x67, 0xA6 );
+	result = fcml_stf_run_tests( "Public API tests", fcml_arr_suites );

     fcml_fn_disassembler_free( disassembler_intel );
     fcml_fn_disassembler_free( disassembler_gas );


groonga windows: set Windows event log logger ASAP

--- src/groonga.c
+++ src/groonga.c
@@ -2957,6 +2957,7 @@
     if (windows_event_source_name_arg) {
       grn_windows_event_logger_set_source_name(windows_event_source_name_arg);
     }
+    grn_windows_event_logger_set(NULL);
   }

   if (log_path_arg) {
@@ -3172,10 +3173,6 @@

   grn_set_default_encoding(encoding);

-  if (use_windows_event_log) {
-    grn_windows_event_logger_set(&grn_gctx);
-  }
-
   if (default_command_version_arg) {
     grn_set_default_command_version(default_command_version);
   }