esp32: Clean up mpconfigport.h, enable more features.

--- esp32/mpconfigport.h
+++ esp32/mpconfigport.h
@@ -1,140 +1,136 @@
+// Options to control how MicroPython is built for this port,
+// overriding defaults in py/mpconfig.h.
+
 #include <stdint.h>
+#include <alloca.h>

-// options to control how Micro Python is built
+// object representation and NLR handling
+#define MICROPY_OBJ_REPR                    (MICROPY_OBJ_REPR_A)
+#define MICROPY_NLR_SETJMP                  (1)

-#define MICROPY_OBJ_REPR            (MICROPY_OBJ_REPR_A)
-#define MICROPY_NLR_SETJMP          (1)
-#define MICROPY_ALLOC_PATH_MAX      (128)
-#define MICROPY_ALLOC_LEXER_INDENT_INIT (8)
-#define MICROPY_ALLOC_PARSE_RULE_INIT   (48)
-#define MICROPY_ALLOC_PARSE_RULE_INC    (8)
-#define MICROPY_ALLOC_PARSE_RESULT_INC  (8)
-#define MICROPY_ALLOC_PARSE_CHUNK_INIT  (64)
-#define MICROPY_PERSISTENT_CODE_LOAD (1)
-#define MICROPY_EMIT_X64            (0)
-#define MICROPY_EMIT_THUMB          (0)
-#define MICROPY_EMIT_INLINE_THUMB   (0)
-#define MICROPY_MEM_STATS           (0)
-#define MICROPY_READER_FATFS        (1)
-#define MICROPY_ENABLE_GC           (1)
-#define MICROPY_STACK_CHECK         (1)
+// memory allocation policies
+#define MICROPY_ALLOC_PATH_MAX              (128)
+
+// emitters
+#define MICROPY_PERSISTENT_CODE_LOAD        (1)
+
+// compiler configuration
+#define MICROPY_COMP_MODULE_CONST           (1)
+#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN    (1)
+
+// optimisations
+#define MICROPY_OPT_COMPUTED_GOTO           (1)
+#define MICROPY_OPT_MPZ_BITWISE             (1)
+
+// Python internal features
+#define MICROPY_READER_FATFS                (1)
+#define MICROPY_ENABLE_GC                   (1)
+#define MICROPY_ENABLE_FINALISER            (1)
+#define MICROPY_STACK_CHECK                 (1)
 #define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1)
-#define MICROPY_REPL_EVENT_DRIVEN   (0)
-#define MICROPY_REPL_AUTO_INDENT    (1)
-#define MICROPY_HELPER_REPL         (1)
-#define MICROPY_HELPER_LEXER_UNIX   (0)
-#define MICROPY_ENABLE_SOURCE_LINE  (1)
-#define MICROPY_MODULE_WEAK_LINKS   (1)
-#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
-#define MICROPY_USE_INTERNAL_ERRNO  (1)
-#define MICROPY_USE_INTERNAL_PRINTF (0)
-#define MICROPY_PY_ALL_SPECIAL_METHODS (1)
-#define MICROPY_PY_BUILTINS_COMPLEX (0)
-#define MICROPY_PY_BUILTINS_STR_UNICODE (1)
-#define MICROPY_PY_BUILTINS_BYTEARRAY (1)
-#define MICROPY_PY_BUILTINS_MEMORYVIEW (1)
-#define MICROPY_PY_BUILTINS_FROZENSET (1)
-#define MICROPY_PY_BUILTINS_SET     (1)
-#define MICROPY_PY_BUILTINS_SLICE   (1)
-#define MICROPY_PY_BUILTINS_SLICE_ATTRS (1)
-#define MICROPY_PY_BUILTINS_PROPERTY (1)
-#define MICROPY_PY___FILE__         (0)
-#define MICROPY_PY_GC               (1)
-#define MICROPY_PY_ARRAY            (1)
-#define MICROPY_PY_ARRAY_SLICE_ASSIGN (1)
-#define MICROPY_PY_COLLECTIONS      (1)
-#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1)
-#define MICROPY_PY_MATH             (1)
-#define MICROPY_PY_CMATH            (0)
-#define MICROPY_PY_IO               (1)
-#define MICROPY_PY_IO_FILEIO        (1)
-#define MICROPY_PY_STRUCT           (1)
-#define MICROPY_PY_SYS              (1)
-#define MICROPY_PY_SYS_MAXSIZE      (1)
-#define MICROPY_PY_SYS_EXIT         (1)
-#define MICROPY_PY_SYS_STDFILES     (1)
-#define MICROPY_PY_SYS_STDIO_BUFFER (1)
-#define MICROPY_PY_UERRNO           (1)
-#define MICROPY_PY_UBINASCII        (1)
-#define MICROPY_PY_UCTYPES          (1)
-#define MICROPY_PY_UHASHLIB         (1)
-#define MICROPY_PY_UHASHLIB_SHA1    (MICROPY_PY_USSL && MICROPY_SSL_AXTLS)
-#define MICROPY_PY_UHEAPQ           (1)
-#define MICROPY_PY_UJSON            (1)
-#define MICROPY_PY_URANDOM          (1)
-#define MICROPY_PY_URE              (1)
-#define MICROPY_PY_UTIME_MP_HAL     (1)
-#define MICROPY_PY_UZLIB            (1)
-#define MICROPY_PY_LWIP             (0)
-#define MICROPY_PY_MACHINE          (1)
-#define MICROPY_PY_MACHINE_PULSE    (0)
-#define MICROPY_PY_MACHINE_I2C      (0)
-#define MICROPY_PY_MACHINE_SPI      (0)
-#define MICROPY_PY_WEBSOCKET        (0)
-#define MICROPY_PY_WEBREPL          (0)
-#define MICROPY_PY_WEBREPL_DELAY    (20)
-#define MICROPY_PY_FRAMEBUF         (0)
-#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
-#define MICROPY_PY_OS_DUPTERM       (0)
-#define MICROPY_CPYTHON_COMPAT      (1)
-#define MICROPY_LONGINT_IMPL        (MICROPY_LONGINT_IMPL_MPZ)
-#define MICROPY_FLOAT_IMPL          (MICROPY_FLOAT_IMPL_FLOAT)
-#define MICROPY_ERROR_REPORTING     (MICROPY_ERROR_REPORTING_NORMAL)
-#define MICROPY_WARNINGS            (1)
-#define MICROPY_PY_STR_BYTES_CMP_WARN (1)
-#define MICROPY_STREAMS_NON_BLOCK   (1)
-#define MICROPY_STREAMS_POSIX_API   (1)
+#define MICROPY_HELPER_REPL                 (1)
+#define MICROPY_REPL_EMACS_KEYS             (1)
+#define MICROPY_REPL_AUTO_INDENT            (1)
+#define MICROPY_LONGINT_IMPL                (MICROPY_LONGINT_IMPL_MPZ)
+#define MICROPY_ENABLE_SOURCE_LINE          (1)
+#define MICROPY_ERROR_REPORTING             (MICROPY_ERROR_REPORTING_NORMAL)
+#define MICROPY_WARNINGS                    (1)
+#define MICROPY_FLOAT_IMPL                  (MICROPY_FLOAT_IMPL_FLOAT)
+#define MICROPY_PY_BUILTINS_COMPLEX         (1)
+#define MICROPY_CPYTHON_COMPAT              (1)
+#define MICROPY_STREAMS_NON_BLOCK           (1)
+#define MICROPY_STREAMS_POSIX_API           (0)
+#define MICROPY_MODULE_WEAK_LINKS           (1)
 /*
-#define MICROPY_MODULE_FROZEN_STR   (1)
-#define MICROPY_MODULE_FROZEN_MPY   (1)
-#define MICROPY_QSTR_EXTRA_POOL     mp_qstr_frozen_const_pool
+#define MICROPY_MODULE_FROZEN_STR           (1)
+#define MICROPY_MODULE_FROZEN_MPY           (1)
+#define MICROPY_QSTR_EXTRA_POOL             mp_qstr_frozen_const_pool
 */
+#define MICROPY_CAN_OVERRIDE_BUILTINS       (1)
+#define MICROPY_USE_INTERNAL_ERRNO          (1)
+#define MICROPY_USE_INTERNAL_PRINTF         (0) // ESP32 SDK requires its own printf

-#define MICROPY_FATFS_ENABLE_LFN       (1)
-#define MICROPY_FATFS_RPATH            (2)
-#define MICROPY_FATFS_VOLUMES          (2)
-#define MICROPY_FATFS_MAX_SS           (4096)
-#define MICROPY_FATFS_LFN_CODE_PAGE    (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */
-#define MICROPY_FSUSERMOUNT            (1)
-#define MICROPY_VFS_FAT                (1)
-#define MICROPY_ESP8266_APA102         (1)
-#define MICROPY_ESP8266_NEOPIXEL       (1)
+// control over Python builtins
+#define MICROPY_PY_FUNCTION_ATTRS           (1)
+#define MICROPY_PY_STR_BYTES_CMP_WARN       (1)
+#define MICROPY_PY_BUILTINS_STR_UNICODE     (1)
+#define MICROPY_PY_BUILTINS_STR_CENTER      (1)
+#define MICROPY_PY_BUILTINS_STR_PARTITION   (1)
+#define MICROPY_PY_BUILTINS_STR_SPLITLINES  (1)
+#define MICROPY_PY_BUILTINS_BYTEARRAY       (1)
+#define MICROPY_PY_BUILTINS_MEMORYVIEW      (1)
+#define MICROPY_PY_BUILTINS_SET             (1)
+#define MICROPY_PY_BUILTINS_SLICE           (1)
+#define MICROPY_PY_BUILTINS_SLICE_ATTRS     (1)
+#define MICROPY_PY_BUILTINS_FROZENSET       (1)
+#define MICROPY_PY_BUILTINS_PROPERTY        (1)
+#define MICROPY_PY_BUILTINS_RANGE_ATTRS     (1)
+#define MICROPY_PY_BUILTINS_TIMEOUTERROR    (1)
+#define MICROPY_PY_ALL_SPECIAL_METHODS      (1)
+#define MICROPY_PY_BUILTINS_COMPILE         (1)
+#define MICROPY_PY_BUILTINS_ENUMERATE       (1)
+#define MICROPY_PY_BUILTINS_EXECFILE        (1)
+#define MICROPY_PY_BUILTINS_FILTER          (1)
+#define MICROPY_PY_BUILTINS_REVERSED        (1)
+#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED  (1)
+#define MICROPY_PY_BUILTINS_MIN_MAX         (1)
+#define MICROPY_PY___FILE__                 (1)
+#define MICROPY_PY_MICROPYTHON_MEM_INFO     (1)
+#define MICROPY_PY_ARRAY                    (1)
+#define MICROPY_PY_ARRAY_SLICE_ASSIGN       (1)
+#define MICROPY_PY_ATTRTUPLE                (1)
+#define MICROPY_PY_COLLECTIONS              (1)
+#define MICROPY_PY_COLLECTIONS_ORDEREDDICT  (1)
+#define MICROPY_PY_MATH                     (1)
+#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS   (1)
+#define MICROPY_PY_CMATH                    (1)
+#define MICROPY_PY_GC                       (1)
+#define MICROPY_PY_IO                       (1)
+#define MICROPY_PY_IO_FILEIO                (1)
+#define MICROPY_PY_IO_BYTESIO               (1)
+#define MICROPY_PY_IO_BUFFEREDWRITER        (1)
+#define MICROPY_PY_STRUCT                   (1)
+#define MICROPY_PY_SYS                      (1)
+#define MICROPY_PY_SYS_MAXSIZE              (1)
+#define MICROPY_PY_SYS_MODULES              (1)
+#define MICROPY_PY_SYS_EXIT                 (1)
+#define MICROPY_PY_SYS_STDFILES             (1)
+#define MICROPY_PY_SYS_STDIO_BUFFER         (1)
+#define MICROPY_PY_UERRNO                   (1)
+#define MICROPY_PY_USELECT                  (1)
+#define MICROPY_PY_UTIME_MP_HAL             (1)

-/*
-#define MICROPY_EVENT_POLL_HOOK {ets_event_poll();}
-#define MICROPY_VM_HOOK_COUNT (10)
-#define MICROPY_VM_HOOK_INIT static uint vm_hook_divisor = MICROPY_VM_HOOK_COUNT;
-#define MICROPY_VM_HOOK_POLL if (--vm_hook_divisor == 0) { \
-        vm_hook_divisor = MICROPY_VM_HOOK_COUNT; \
-        extern void ets_loop_iter(void); \
-        ets_loop_iter(); \
-    }
-#define MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_POLL
-#define MICROPY_VM_HOOK_RETURN MICROPY_VM_HOOK_POLL
-*/
+// extended modules
+#define MICROPY_PY_UCTYPES                  (1)
+#define MICROPY_PY_UZLIB                    (1)
+#define MICROPY_PY_UJSON                    (1)
+#define MICROPY_PY_URE                      (1)
+#define MICROPY_PY_UHEAPQ                   (1)
+#define MICROPY_PY_UHASHLIB                 (1)
+#define MICROPY_PY_UHASHLIB_SHA1            (MICROPY_PY_USSL && MICROPY_SSL_AXTLS)
+#define MICROPY_PY_UBINASCII                (1)
+#define MICROPY_PY_UBINASCII_CRC32          (1)
+#define MICROPY_PY_URANDOM                  (1)
+#define MICROPY_PY_URANDOM_EXTRA_FUNCS      (1)
+#define MICROPY_PY_MACHINE                  (1)
+#define MICROPY_PY_MACHINE_PULSE            (0)
+#define MICROPY_PY_MACHINE_I2C              (0)
+#define MICROPY_PY_MACHINE_SPI              (0)
+#define MICROPY_PY_USSL                     (0)
+#define MICROPY_PY_WEBSOCKET                (0)
+#define MICROPY_PY_FRAMEBUF                 (1)
+#define MICROPY_PY_BTREE                    (0)

-// type definitions for the specific machine
-
-#define BYTES_PER_WORD (4)
-
-#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p)))
-
-#define MP_SSIZE_MAX (0x7fffffff)
-
-#define UINT_FMT "%u"
-#define INT_FMT "%d"
-
-typedef int32_t mp_int_t; // must be pointer size
-typedef uint32_t mp_uint_t; // must be pointer size
-typedef long mp_off_t;
-typedef uint32_t sys_prot_t; // for modlwip
-// ssize_t, off_t as required by POSIX-signatured functions in stream.h
-#include <sys/types.h>
-
-#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
-
-#define mp_type_fileio fatfs_type_fileio
-#define mp_type_textio fatfs_type_textio
+// fatfs configuration
+#define MICROPY_VFS_FAT                     (1)
+#define MICROPY_FSUSERMOUNT                 (1)
+#define MICROPY_FATFS_ENABLE_LFN            (1)
+#define MICROPY_FATFS_RPATH                 (2)
+#define MICROPY_FATFS_VOLUMES               (2)
+#define MICROPY_FATFS_MAX_SS                (4096)
+#define MICROPY_FATFS_LFN_CODE_PAGE         (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */
+#define mp_type_fileio                      fatfs_type_fileio
+#define mp_type_textio                      fatfs_type_textio

 // extra built in names to add to the global namespace
 #define MICROPY_PORT_BUILTINS \
@@ -143,25 +139,19 @@
     { MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },

 // extra built in modules to add to the list of known ones
+extern const struct _mp_obj_module_t utime_module;
+//extern const struct _mp_obj_module_t uos_module;
+extern const struct _mp_obj_module_t mp_module_machine;
 //extern const struct _mp_obj_module_t esp_module;
 //extern const struct _mp_obj_module_t network_module;
-extern const struct _mp_obj_module_t utime_module;
-//extern const struct _mp_obj_module_t uos_module;
-//extern const struct _mp_obj_module_t mp_module_lwip;
-extern const struct _mp_obj_module_t mp_module_machine;
-//extern const struct _mp_obj_module_t onewire_module;

 #define MICROPY_PORT_BUILTIN_MODULES \
     { MP_OBJ_NEW_QSTR(MP_QSTR_utime), (mp_obj_t)&utime_module }, \
     { MP_OBJ_NEW_QSTR(MP_QSTR_machine), (mp_obj_t)&mp_module_machine }, \
-/*
+    /*
     { MP_OBJ_NEW_QSTR(MP_QSTR_uos), (mp_obj_t)&uos_module }, \
     { MP_OBJ_NEW_QSTR(MP_QSTR_esp), (mp_obj_t)&esp_module }, \
-    { MP_OBJ_NEW_QSTR(MP_QSTR_lwip), (mp_obj_t)&mp_module_lwip }, \
-    { MP_OBJ_NEW_QSTR(MP_QSTR_socket), (mp_obj_t)&mp_module_lwip }, \
-    { MP_OBJ_NEW_QSTR(MP_QSTR_usocket), (mp_obj_t)&mp_module_lwip }, \
     { MP_OBJ_NEW_QSTR(MP_QSTR_network), (mp_obj_t)&network_module }, \
-    { MP_OBJ_NEW_QSTR(MP_QSTR__onewire), (mp_obj_t)&onewire_module }, \
     */

 #define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \
@@ -176,19 +166,25 @@

 #define MICROPY_PORT_ROOT_POINTERS \
     const char *readline_hist[8]; \
-    vstr_t *repl_line; \
     mp_obj_t mp_kbd_exception; \
-    mp_obj_t pin_irq_handler[16]; \

-// We need to provide a declaration/definition of alloca()
-#include <alloca.h>
+// type definitions for the specific machine
+
+#define BYTES_PER_WORD (4)
+#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p)))
+#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
+#define MP_SSIZE_MAX (0x7fffffff)
+#define MICROPY_EVENT_POLL_HOOK asm("waiti 0");
+
+#define UINT_FMT "%u"
+#define INT_FMT "%d"
+
+typedef int32_t mp_int_t; // must be pointer size
+typedef uint32_t mp_uint_t; // must be pointer size
+typedef long mp_off_t;

 // board specifics

 #define MICROPY_HW_BOARD_NAME "ESP32 module"
 #define MICROPY_HW_MCU_NAME "ESP32"
 #define MICROPY_PY_SYS_PLATFORM "esp32"
-
-#define MP_FASTCODE(n) __attribute__((section(".iram0.text." #n))) n
-
-#define _assert(expr) ((expr) ? (void)0 : __assert_func(__FILE__, __LINE__, __func__, #expr))


added option to decode headers only If the 'pcm' parameter to mp3dec_decode_frame() is set to NULL, all bitstream and audio decoding is skipped, but the header is still decoded and frame info is still generated. This is useful for quickly scanning an MP3 file, e.g. to determine the duration or generate a VBR seek index.

--- minimp3.h
+++ minimp3.h
@@ -1645,6 +1645,11 @@
     info->layer = 4 - HDR_GET_LAYER(hdr);
     info->bitrate_kbps = hdr_bitrate_kbps(hdr);

+    if (!pcm)
+    {
+        return hdr_frame_samples(hdr);
+    }
+
     bs_init(bs_frame, hdr + HDR_SIZE, frame_size - HDR_SIZE);
     if (HDR_IS_CRC(hdr))
     {


crowddetector: remove the possibility to disable some events

Change-Id: I3628e966cf24b7beac8a19c2274edc8d982a1e26

--- filters/crowddetector/kmscrowddetector.c
+++ filters/crowddetector/kmscrowddetector.c
@@ -67,12 +67,10 @@
   int occupancy_level_med;
   int occupancy_level_max;
   int occupancy_num_frames_to_event;
-  gboolean send_occupancy_event;
   int fluidity_level_min;
   int fluidity_level_med;
   int fluidity_level_max;
   int fluidity_num_frames_to_event;
-  gboolean send_fluidity_event;
   gboolean send_optical_flow_event;
   int actual_optical_flow_angle;
   int potential_optical_flow_angle;
@@ -456,8 +454,6 @@
             &self->priv->rois_data[it].occupancy_level_max, NULL);
         gst_structure_get (point, "occupancy_num_frames_to_event", G_TYPE_INT,
             &self->priv->rois_data[it].occupancy_num_frames_to_event, NULL);
-        gst_structure_get (point, "send_occupancy_event", G_TYPE_BOOLEAN,
-            &self->priv->rois_data[it].send_occupancy_event, NULL);
         gst_structure_get (point, "fluidity_level_min", G_TYPE_INT,
             &self->priv->rois_data[it].fluidity_level_min, NULL);
         gst_structure_get (point, "fluidity_level_med", G_TYPE_INT,
@@ -466,8 +462,6 @@
             &self->priv->rois_data[it].fluidity_level_max, NULL);
         gst_structure_get (point, "fluidity_num_frames_to_event", G_TYPE_INT,
             &self->priv->rois_data[it].fluidity_num_frames_to_event, NULL);
-        gst_structure_get (point, "send_fluidity_event", G_TYPE_BOOLEAN,
-            &self->priv->rois_data[it].send_fluidity_event, NULL);
         gst_structure_get (point, "send_optical_flow_event", G_TYPE_BOOLEAN,
             &self->priv->rois_data[it].send_optical_flow_event, NULL);
         gst_structure_get (point, "optical_flow_num_frames_to_event",
@@ -479,18 +473,16 @@
         gst_structure_get (point, "optical_flow_angle_offset", G_TYPE_INT,
             &self->priv->rois_data[it].optical_flow_angle_offset, NULL);
         GST_DEBUG
-            ("rois info loaded: %s %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
+            ("rois info loaded: %s %d %d %d %d %d %d %d %d %d %d %d %d",
             self->priv->rois_data[it].name,
             self->priv->rois_data[it].occupancy_level_min,
             self->priv->rois_data[it].occupancy_level_med,
             self->priv->rois_data[it].occupancy_level_max,
             self->priv->rois_data[it].occupancy_num_frames_to_event,
-            self->priv->rois_data[it].send_occupancy_event,
             self->priv->rois_data[it].fluidity_level_min,
             self->priv->rois_data[it].fluidity_level_med,
             self->priv->rois_data[it].fluidity_level_max,
             self->priv->rois_data[it].fluidity_num_frames_to_event,
-            self->priv->rois_data[it].send_fluidity_event,
             self->priv->rois_data[it].send_optical_flow_event,
             self->priv->rois_data[it].optical_flow_num_frames_to_event,
             self->priv->rois_data[it].optical_flow_num_frames_to_reset,
@@ -1000,23 +992,18 @@
     } else {
       occupation_percentage = 0;
     }
-
-    if (crowddetector->priv->rois_data[curve].send_occupancy_event == TRUE) {
-      kms_crowd_detector_roi_occup_analysis (crowddetector,
-          occupation_percentage,
-          crowddetector->priv->rois_data[curve].occupancy_num_frames_to_event,
-          crowddetector->priv->rois_data[curve].occupancy_level_min,
-          crowddetector->priv->rois_data[curve].occupancy_level_med,
-          crowddetector->priv->rois_data[curve].occupancy_level_max, curve);
-    }
-    if (crowddetector->priv->rois_data[curve].send_fluidity_event == TRUE) {
-      kms_crowd_detector_roi_fluidity_analysis (crowddetector,
-          high_speed_points, low_speed_points,
-          crowddetector->priv->rois_data[curve].fluidity_num_frames_to_event,
-          crowddetector->priv->rois_data[curve].fluidity_level_min,
-          crowddetector->priv->rois_data[curve].fluidity_level_med,
-          crowddetector->priv->rois_data[curve].fluidity_level_max, curve);
-    }
+    kms_crowd_detector_roi_occup_analysis (crowddetector,
+        occupation_percentage,
+        crowddetector->priv->rois_data[curve].occupancy_num_frames_to_event,
+        crowddetector->priv->rois_data[curve].occupancy_level_min,
+        crowddetector->priv->rois_data[curve].occupancy_level_med,
+        crowddetector->priv->rois_data[curve].occupancy_level_max, curve);
+    kms_crowd_detector_roi_fluidity_analysis (crowddetector,
+        high_speed_points, low_speed_points,
+        crowddetector->priv->rois_data[curve].fluidity_num_frames_to_event,
+        crowddetector->priv->rois_data[curve].fluidity_level_min,
+        crowddetector->priv->rois_data[curve].fluidity_level_med,
+        crowddetector->priv->rois_data[curve].fluidity_level_max, curve);
   }
 }


Removing classes also from dictionary

Removing classes also from dictionary

--- HBTAN/HBTAnalysisLinkDef.h
+++ HBTAN/HBTAnalysisLinkDef.h
@@ -53,9 +53,6 @@
 #pragma link C++ class AliHBTQOutasCorrFctn+;
 #pragma link C++ class AliHBTQSideasCorrFctn+;
 #pragma link C++ class AliHBTQLongasCorrFctn+;
-#pragma link C++ class AliHBTQOutWeightasCorrFctn+;
-#pragma link C++ class AliHBTQSideWeightasCorrFctn+;
-#pragma link C++ class AliHBTQLongWeightasCorrFctn+;

 #pragma link C++ class AliHBTInvMassCorrelFctn+;
 #pragma link C++ class AliHBTCorrFitFctn+;


mm/mmap.c: find_vma(): remove unnecessary if(mm) check

The "if (mm)" check is not required in find_vma, as the kernel code
calls find_vma only when it is absolutely sure that the mm_struct arg to
it is non-NULL.

Remove the if(mm) check and adding the a WARN_ONCE(!mm) for now.  This
will serve the purpose of mandating that the execution
context(user-mode/kernel-mode) be known before find_vma is called.  Also
fixed 2 checkpatch.pl errors in the declaration of the rb_node and
vma_tmp local variables.

I was browsing through the internet and read a discussion at
https://lkml.org/lkml/2012/3/27/342 which discusses removal of the
validation check within find_vma.  Since no-one responded, I decided to
send this patch with Andrew's suggestions.

[5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org: add remove-me comment]
Signed-off-by: Rajman Mekaco <423db0eb26f46715662ba9c0546c54009527ba05@gmail.com>
Cc: Kautuk Consul <fa1d3322ebd37bfdf69c45980e7dc5a46def8d67@gmail.com>
Cc: Hugh Dickins <d3abdf3e2800e6cb849f11b81e6eb50b34d96431@google.com>
Cc: KAMEZAWA Hiroyuki <634f508bd7c47cf0ee4126243675c3e598920fbc@jp.fujitsu.com>
Acked-by: KOSAKI Motohiro <70a1d3ef3e17a2bb0f09a1b2e6c86f607ed1d6d9@jp.fujitsu.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- mm/mmap.c
+++ mm/mmap.c
@@ -1639,33 +1639,34 @@
 {
 	struct vm_area_struct *vma = NULL;

-	if (mm) {
-		/* Check the cache first. */
-		/* (Cache hit rate is typically around 35%.) */
-		vma = mm->mmap_cache;
-		if (!(vma && vma->vm_end > addr && vma->vm_start <= addr)) {
-			struct rb_node * rb_node;
-
-			rb_node = mm->mm_rb.rb_node;
-			vma = NULL;
-
-			while (rb_node) {
-				struct vm_area_struct * vma_tmp;
-
-				vma_tmp = rb_entry(rb_node,
-						struct vm_area_struct, vm_rb);
-
-				if (vma_tmp->vm_end > addr) {
-					vma = vma_tmp;
-					if (vma_tmp->vm_start <= addr)
-						break;
-					rb_node = rb_node->rb_left;
-				} else
-					rb_node = rb_node->rb_right;
-			}
-			if (vma)
-				mm->mmap_cache = vma;
+	if (WARN_ON_ONCE(!mm))		/* Remove this in linux-3.6 */
+		return NULL;
+
+	/* Check the cache first. */
+	/* (Cache hit rate is typically around 35%.) */
+	vma = mm->mmap_cache;
+	if (!(vma && vma->vm_end > addr && vma->vm_start <= addr)) {
+		struct rb_node *rb_node;
+
+		rb_node = mm->mm_rb.rb_node;
+		vma = NULL;
+
+		while (rb_node) {
+			struct vm_area_struct *vma_tmp;
+
+			vma_tmp = rb_entry(rb_node,
+					   struct vm_area_struct, vm_rb);
+
+			if (vma_tmp->vm_end > addr) {
+				vma = vma_tmp;
+				if (vma_tmp->vm_start <= addr)
+					break;
+				rb_node = rb_node->rb_left;
+			} else
+				rb_node = rb_node->rb_right;
 		}
+		if (vma)
+			mm->mmap_cache = vma;
 	}
 	return vma;
 }


Moved some getters to AliL3MemHandler

Moved some getters to AliL3MemHandler

--- HLT/src/AliL3FileHandler.h
+++ HLT/src/AliL3FileHandler.h
@@ -29,12 +29,6 @@
  public:
   AliL3FileHandler();
   virtual ~AliL3FileHandler();
-//  void Init(Int_t s,Int_t p,Int_t* row){fSlice=s;fPatch=p;fRowMin=row[0];fRowMax=row[1];}
-
-  Int_t GetRowMin(){return fRowMin;}
-  Int_t GetRowMax(){return fRowMax;}
-  Int_t GetSlice(){return fSlice;}
-  Int_t GetPatch(){return fPatch;}

   Bool_t SetAliInput(char *name);
   Bool_t SetAliInput(TFile *file);


Remove unused variable in get_unmapped_area

Signed-off-by: Roland McGrath <0d270388f2f92757a5de0f4bd891d3b392c44c4f@redhat.com>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- mm/mmap.c
+++ mm/mmap.c
@@ -1366,7 +1366,6 @@
 get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,
 		unsigned long pgoff, unsigned long flags)
 {
-	unsigned long ret;
 	unsigned long (*get_area)(struct file *, unsigned long,
 				  unsigned long, unsigned long, unsigned long);


mm/rmap.c: don't call mmu_notifier_invalidate_page() during munlock

In its munmap mode, try_to_unmap_one() searches other mlocked vmas, it
never unmaps pages.  There is no reason for invalidation because ptes are
left unchanged.

Signed-off-by: Konstantin Khlebnikov <313328defca653cd422fb17d20c38cc0fb4b890b@gmail.com>
Cc: Rik van Riel <a21938f5d463ddf41aa718934c205ca2cce8ebbc@redhat.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- mm/rmap.c
+++ mm/rmap.c
@@ -1252,7 +1252,7 @@

 out_unmap:
 	pte_unmap_unlock(pte, ptl);
-	if (ret != SWAP_FAIL)
+	if (ret != SWAP_FAIL && TTU_ACTION(flags) != TTU_MUNLOCK)
 		mmu_notifier_invalidate_page(mm, address);
 out:
 	return ret;


TundraProtocolModuleFwd.h: add "using TundraLogic::TundraLogicModule;" (but not for other classes for now as "Client" and "Server" are rather ambiguous in global namespace).

--- src/Core/TundraProtocolModule/TundraProtocolModuleFwd.h
+++ src/Core/TundraProtocolModule/TundraProtocolModuleFwd.h
@@ -22,6 +22,8 @@
     class SyncManager;
 }

+using TundraLogic::TundraLogicModule;
+
 class UserConnection;
 typedef shared_ptr<UserConnection> UserConnectionPtr;
 typedef weak_ptr<UserConnection> UserConnectionWeakPtr;


slub: Use NUMA_NO_NODE in get_partial

slub: Use NUMA_NO_NODE in get_partial

A -1 was leftover during the conversion.

Signed-off-by: Christoph Lameter <ef3ecccf258fa062c5c6521a4887d40541963af7@linux.com>
Signed-off-by: Pekka Enberg <add4fcd06328a394f0ad91feda7ee057316dc5ed@kernel.org>

--- mm/slub.c
+++ mm/slub.c
@@ -1487,7 +1487,7 @@
 	int searchnode = (node == NUMA_NO_NODE) ? numa_node_id() : node;

 	page = get_partial_node(get_node(s, searchnode));
-	if (page || node != -1)
+	if (page || node != NUMA_NO_NODE)
 		return page;

 	return get_any_partial(s, flags);


Removed hardcoded test comments ;-)

Removed hardcoded test comments ;-)

git-svn-id: cffa15b480e6f0d86abcf9d30fc65d52a4d7b9f9@243 8158c8cd-e7e1-0310-9fa4-c5954c97daef

--- src/examples/fishsound-encode.c
+++ src/examples/fishsound-encode.c
@@ -119,9 +119,6 @@

   fish_sound_set_interleave (fsound, 1);

-  fish_sound_comment_add_byname (fsound, "Author", "crazy fish heads");
-  fish_sound_comment_add_byname (fsound, "FWOARR!", NULL);
-
   while (sf_readf_float (sndfile, pcm, 1024) > 0) {
     fish_sound_encode (fsound, (float **)pcm, 1024);
     while ((n = oggz_write (oggz, 1024)) > 0);


T531 - Elemntary_popup does not respond to 'close' event

Reviewers: seoz, raster

Reviewed By: seoz

Differential Revision: https://phab.enlightenment.org/D344

--- src/examples/popup_example_02.c
+++ src/examples/popup_example_02.c
@@ -54,6 +54,7 @@
    elm_object_text_set(btn3, "Close");
    // Setting this action button
    elm_object_part_content_set(popup, "button3", btn3);
+   evas_object_smart_callback_add(btn3, "clicked", _response_cb, popup);
    // Setting the orientation of popup to Top
    elm_popup_orient_set(popup, ELM_POPUP_ORIENT_TOP);
    // Display the popup object


Include ImathMath.h and call Imath::Math<T>::sqrt() instead of ::sqrt().


Include/Library/LKEnvLib.h: fix dprintf debug level mapping

--- Include/Library/LKEnvLib.h
+++ Include/Library/LKEnvLib.h
@@ -77,10 +77,10 @@
 #define snprintf(s, n, fmt, ...) ((int)AsciiSPrint((s), (n), (fmt), ##__VA_ARGS__))

 /* debug levels */
-#define CRITICAL EFI_D_ERROR
-#define ALWAYS EFI_D_ERROR
-#define INFO EFI_D_WARN
-#define SPEW EFI_D_INFO
+#define CRITICAL DEBUG_ERROR
+#define ALWAYS DEBUG_ERROR
+#define INFO DEBUG_INFO
+#define SPEW DEBUG_VERBOSE

 #if !defined(MDEPKG_NDEBUG)
 #define dprintf(level, fmt, ...) do { \


[ci skip] Create TaskEnums

[ci skip] Create TaskEnums

error: pathspec 'Includes/Enums/TaskEnums.h' did not match any file(s) known to git

--- Includes/Enums/TaskEnums.h
+++ Includes/Enums/TaskEnums.h
@@ -0,0 +1,26 @@
+/*************************************************************************
+> File Name: TaskEnums.h
+> Project Name: Hearthstone++
+> Author: Chan-Ho Chris Ohk
+> Purpose: Enumerations for task.
+> Created Time: 2018/07/01
+> Copyright (c) 2018, Chan-Ho Chris Ohk
+*************************************************************************/
+#ifndef HEARTHSTONEPP_TASK_ENUMS_H
+#define HEARTHSTONEPP_TASK_ENUMS_H
+
+#ifdef _MSC_VER
+#define HEARTHSTONEPP_EXPAND_LARGE_ENUMS
+#else  // _MSC_VER
+#undef BETTER_ENUMS_MACRO_FILE
+#define BETTER_ENUMS_MACRO_FILE "../../Includes/Enums/EnumMacros.h"
+#endif  // _MSC_VER
+
+#include <better-enums/enum.h>
+
+namespace Hearthstonepp
+{
+BETTER_ENUM(PowerTaskType, int, EMPTY = 0, DESTROY_WEAPON = 1)
+}
+
+#endif


Add extra include

Add extra include

git-svn-id: 4403cc1077de9de61ebbb06aa07b0a825c555f62@7909 dc4e9af1-7f46-4ead-bba6-71afc04862de

--- code/src/tcl/blob/blob.h
+++ code/src/tcl/blob/blob.h
@@ -23,6 +23,7 @@
 */

 #include <stdbool.h>
+#include <stdint.h>

 /**
    Simple struct for variable-length data blob


Don't typedef CoglMemoryStack twice

Don't typedef CoglMemoryStack twice

CoglMemoryStack was being typedef'd twice, once in the private header
as an incomplete struct and once in the C source with the actual
struct definition. This removes the second typedef so that it just
defines the struct.

This patch was written by Jack River.

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

Reviewed-by: Neil Roberts <822ec91a7ef82248fd36162ca8ac3283eba70848@linux.intel.com>

--- cogl/cogl-memory-stack.c
+++ cogl/cogl-memory-stack.c
@@ -70,13 +70,13 @@
   uint8_t *data;
 };

-typedef struct _CoglMemoryStack
+struct _CoglMemoryStack
 {
   CoglMemorySubStackList sub_stacks;

   CoglMemorySubStack *sub_stack;
   size_t sub_stack_offset;
-} CoglMemoryStack;
+};

 static CoglMemorySubStack *
 _cogl_memory_sub_stack_alloc (size_t bytes)


Fix build error with clang 3.5

Fix build error with clang 3.5

--- include/fcl/math/motion/triangle_motion_bound_visitor.h
+++ include/fcl/math/motion/triangle_motion_bound_visitor.h
@@ -42,6 +42,10 @@
 #include "fcl/math/motion/taylor_model/taylor_vector.h"
 #include "fcl/math/bv/RSS.h"
 #include "fcl/math/motion/bv_motion_bound_visitor.h"
+#include "fcl/math/motion/spline_motion.h"
+#include "fcl/math/motion/screw_motion.h"
+#include "fcl/math/motion/interp_motion.h"
+#include "fcl/math/motion/translation_motion.h"

 namespace fcl
 {


[FIX] support msvc openmp 2.0

[FIX] support msvc openmp 2.0

Z:\seqan-builds-windows\seqan-src\include\seqan/align_parallel/parallel_align_interface.h(174): error C3016: 'job': index variable in OpenMP 'for' statement must have signed integral type [Z:\seqan-builds-windows\seqan-builds\msvc-15\tests\align_parallel\test_align_parallel_interface.vcxproj]

--- include/seqan/align_parallel/parallel_align_interface.h
+++ include/seqan/align_parallel/parallel_align_interface.h
@@ -110,7 +110,7 @@
     {
         SEQAN_ASSERT_EQ(length(setH), length(setV));

-        using TPos = decltype(length(setH));
+        using TPos = std::make_signed_t<decltype(length(setH))>;
         using TResult = decltype(kernel(setH, setV, std::forward<TArgs>(args)...));

         TPos chunkSize = _min(length(setH), static_cast<TPos>(256));
@@ -157,7 +157,7 @@
     {
         SEQAN_ASSERT_EQ(length(setH), length(setV));

-        using TPos = decltype(length(setH));
+        using TPos = std::make_signed_t<decltype(length(setH))>;
         using TResult = decltype(kernel(setH, setV, std::forward<TArgs>(args)...));

         Splitter<TPos> splitter(0, length(setH), numThreads(execPolicy));


update SharedObjectPtr

update SharedObjectPtr

--- include/vf/modules/vf_core/threads/vf_SharedObjectPtr.h
+++ include/vf/modules/vf_core/threads/vf_SharedObjectPtr.h
@@ -5,136 +5,196 @@
 #ifndef __VF_SHAREDOBJECTPTR_VFHEADER__
 #define __VF_SHAREDOBJECTPTR_VFHEADER__

-// RAII wrapper for a SharedObject
+// Smart pointer which points to a SharedObject.
+// Ideas from Juce.
 //
+
 template <class SharedObjectClass>
 class SharedObjectPtr
 {
 public:
-  inline SharedObjectPtr() noexcept
-    : referencedObject (0)
-  {
-  }
-
-  inline SharedObjectPtr (SharedObjectClass* const refCountedObject) noexcept
-    : referencedObject (refCountedObject)
-  {
-    if (refCountedObject != nullptr)
-      refCountedObject->incReferenceCount();
-  }
-
-  inline SharedObjectPtr (const SharedObjectPtr <SharedObjectClass>& other) noexcept
-    : referencedObject (other.referencedObject)
-  {
-    if (referencedObject != nullptr)
-      referencedObject->incReferenceCount();
-  }
-
-  SharedObjectPtr <SharedObjectClass>& operator= (const SharedObjectPtr<SharedObjectClass>& other)
-  {
-    SharedObjectClass* const newObject = other.referencedObject;
-
-    if (newObject != referencedObject)
-    {
-      if (newObject != nullptr)
-        newObject->incReferenceCount();
-
-      SharedObjectClass* const oldObject = referencedObject;
-      referencedObject = newObject;
-
-      if (oldObject != nullptr)
-        oldObject->decReferenceCount();
-    }
-
-    return *this;
-  }
-
-  SharedObjectPtr <SharedObjectClass>& operator= (SharedObjectClass* const newObject)
-  {
-    if (referencedObject != newObject)
-    {
-      if (newObject != nullptr)
-        newObject->incReferenceCount();
-
-      SharedObjectClass* const oldObject = referencedObject;
-      referencedObject = newObject;
-
-      if (oldObject != nullptr)
-        oldObject->decReferenceCount();
-    }
-
-    return *this;
-  }
-
-  inline ~SharedObjectPtr ()
-  {
-    if (referencedObject != nullptr)
-      referencedObject->decReferenceCount();
-  }
-
-  inline operator SharedObjectClass* () const noexcept
-  {
-    return referencedObject;
-  }
-
-  inline SharedObjectClass* operator-> () const noexcept
-  {
-    return referencedObject;
-  }
-
-  inline SharedObjectClass* getObject () const noexcept
-  {
-    return referencedObject;
-  }
+    /** The class being referenced by this pointer. */
+    typedef SharedObjectClass SharedType;
+
+    //==============================================================================
+    /** Creates a pointer to a null object. */
+    inline SharedObjectPtr() noexcept
+        : referencedObject (nullptr)
+    {
+    }
+
+    /** Creates a pointer to an object.
+
+        This will increment the object's reference-count if it is non-null.
+    */
+    inline SharedObjectPtr (SharedObjectClass* const refCountedObject) noexcept
+        : referencedObject (refCountedObject)
+    {
+        if (refCountedObject != nullptr)
+            refCountedObject->incReferenceCount();
+    }
+
+    /** Copies another pointer.
+        This will increment the object's reference-count (if it is non-null).
+    */
+    inline SharedObjectPtr (const SharedObjectPtr& other) noexcept
+        : referencedObject (other.referencedObject)
+    {
+        if (referencedObject != nullptr)
+            referencedObject->incReferenceCount();
+    }
+
+   #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
+    /** Takes-over the object from another pointer. */
+    inline SharedObjectPtr (SharedObjectPtr&& other) noexcept
+        : referencedObject (other.referencedObject)
+    {
+        other.referencedObject = nullptr;
+    }
+   #endif
+
+    /** Copies another pointer.
+        This will increment the object's reference-count (if it is non-null).
+    */
+    template <class DerivedClass>
+    inline SharedObjectPtr (const SharedObjectPtr<DerivedClass>& other) noexcept
+        : referencedObject (static_cast <SharedObjectClass*> (other.getObject()))
+    {
+        if (referencedObject != nullptr)
+            referencedObject->incReferenceCount();
+    }
+
+    /** Changes this pointer to point at a different object.
+
+        The reference count of the old object is decremented, and it might be
+        deleted if it hits zero. The new object's count is incremented.
+    */
+    SharedObjectPtr& operator= (const SharedObjectPtr& other)
+    {
+        return operator= (other.referencedObject);
+    }
+
+    /** Changes this pointer to point at a different object.
+
+        The reference count of the old object is decremented, and it might be
+        deleted if it hits zero. The new object's count is incremented.
+    */
+    template <class DerivedClass>
+    SharedObjectPtr& operator= (const SharedObjectPtr<DerivedClass>& other)
+    {
+        return operator= (static_cast <SharedObjectClass*> (other.getObject()));
+    }
+
+   #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
+    /** Takes-over the object from another pointer. */
+    SharedObjectPtr& operator= (SharedObjectPtr&& other)
+    {
+        std::swap (referencedObject, other.referencedObject);
+        return *this;
+    }
+   #endif
+
+    /** Changes this pointer to point at a different object.
+
+        The reference count of the old object is decremented, and it might be
+        deleted if it hits zero. The new object's count is incremented.
+    */
+    SharedObjectPtr& operator= (SharedObjectClass* const newObject)
+    {
+        if (referencedObject != newObject)
+        {
+            if (newObject != nullptr)
+                newObject->incReferenceCount();
+
+            SharedObjectClass* const oldObject = referencedObject;
+            referencedObject = newObject;
+
+            if (oldObject != nullptr)
+                oldObject->decReferenceCount();
+        }
+
+        return *this;
+    }
+
+    /** Destructor.
+
+        This will decrement the object's reference-count, and may delete it if it
+        gets to zero.
+    */
+    inline ~SharedObjectPtr()
+    {
+        if (referencedObject != nullptr)
+            referencedObject->decReferenceCount();
+    }
+
+    /** Returns the object that this pointer references.
+        The pointer returned may be zero, of course.
+    */
+    inline operator SharedObjectClass*() const noexcept
+    {
+        return referencedObject;
+    }
+
+    // the -> operator is called on the referenced object
+    inline SharedObjectClass* operator->() const noexcept
+    {
+        return referencedObject;
+    }
+
+    /** Returns the object that this pointer references.
+        The pointer returned may be zero, of course.
+    */
+    inline SharedObjectClass* getObject() const noexcept
+    {
+        return referencedObject;
+    }

 private:
-  SharedObjectClass* referencedObject;
+    //==============================================================================
+    SharedObjectClass* referencedObject;
 };

-//
-// Comparisons
-//
-
-template <class SharedObjectClass>
-bool operator== (const SharedObjectPtr <SharedObjectClass>& object1,
-                 SharedObjectClass* const object2) noexcept
-{
-  return object1.getObject() == object2;
-}
-
-template <class SharedObjectClass>
-bool operator== (const SharedObjectPtr <SharedObjectClass>& object1,
-                 const SharedObjectPtr<SharedObjectClass>& object2) noexcept
-{
-  return object1.getObject() == object2.getObject();
-}
-
-template <class SharedObjectClass>
-bool operator== (SharedObjectClass* object1,
-                 SharedObjectPtr <SharedObjectClass>& object2) noexcept
-{
-  return object1 == object2.getObject();
-}
-
-template <class SharedObjectClass>
-bool operator!= (const SharedObjectPtr <SharedObjectClass>& object1,
-                 const SharedObjectClass* object2) noexcept
-{
-  return object1.getObject() != object2;
-}
-
-template <class SharedObjectClass>
-bool operator!= (const SharedObjectPtr <SharedObjectClass>& object1,
-                 SharedObjectPtr<SharedObjectClass>& object2) noexcept
-{
-  return object1.getObject() != object2.getObject();
-}
-
-template <class SharedObjectClass>
-bool operator!= (SharedObjectClass* object1,
-                 SharedObjectPtr <SharedObjectClass>& object2) noexcept
-{
-  return object1 != object2.getObject();
-}
-
-#endif
+
+/** Compares two SharedObjectPointers. */
+template <class SharedObjectClass>
+bool operator== (const SharedObjectPtr<SharedObjectClass>& object1, SharedObjectClass* const object2) noexcept
+{
+    return object1.getObject() == object2;
+}
+
+/** Compares two SharedObjectPointers. */
+template <class SharedObjectClass>
+bool operator== (const SharedObjectPtr<SharedObjectClass>& object1, const SharedObjectPtr<SharedObjectClass>& object2) noexcept
+{
+    return object1.getObject() == object2.getObject();
+}
+
+/** Compares two SharedObjectPointers. */
+template <class SharedObjectClass>
+bool operator== (SharedObjectClass* object1, SharedObjectPtr<SharedObjectClass>& object2) noexcept
+{
+    return object1 == object2.getObject();
+}
+
+/** Compares two SharedObjectPointers. */
+template <class SharedObjectClass>
+bool operator!= (const SharedObjectPtr<SharedObjectClass>& object1, const SharedObjectClass* object2) noexcept
+{
+    return object1.getObject() != object2;
+}
+
+/** Compares two SharedObjectPointers. */
+template <class SharedObjectClass>
+bool operator!= (const SharedObjectPtr<SharedObjectClass>& object1, SharedObjectPtr<SharedObjectClass>& object2) noexcept
+{
+    return object1.getObject() != object2.getObject();
+}
+
+/** Compares two SharedObjectPointers. */
+template <class SharedObjectClass>
+bool operator!= (SharedObjectClass* object1, SharedObjectPtr<SharedObjectClass>& object2) noexcept
+{
+    return object1 != object2.getObject();
+}
+
+#endif


Remove the memcpy() hack

Remove the memcpy() hack

This change was not sufficient, and the underlying cause was discovered
by DoctorNoobingstoneIPresume: the child stack needs to be 16-byte
aligned.

--- src/elfcore.c
+++ src/elfcore.c
@@ -295,18 +295,6 @@
 #define NO_INTR(fn)    do {} while ((fn) < 0 && errno == EINTR)
 #define MY_NO_INTR(fn) do {} while ((fn) < 0 && ERRNO == EINTR)

-/* Replacement memcpy.  GCC's __builtin_memcpy causes cores?
- * Yes I know the return value isn't the same as memcpy().
- */
-static void my_memcpy(void* dest, const void* src, size_t len)
-{
-    char* d = dest;
-    const char* s = src;
-    size_t i;
-    for (i = 0; i < len; ++i)
-        *(d++) = *(s++);
-}
-
 /* Wrapper for read() which is guaranteed to never return EINTR.
  */
 static ssize_t c_read(int f, void *buf, size_t bytes, int *errno_) {
@@ -1801,13 +1789,9 @@
       sys_ptrace(PTRACE_PEEKUSER, pids[0], (void *)i,
                  ((char *)&user) + i);
     }
-    /* Avoid using GCC's builtin memcpy... causes crashes in GCC 8.x at -O1?
-     * I could not discover why this is... we are copying from one stack
-     * buffer to another, so it's hard to imagine what could go wrong.
-     * Unfortunately my assembly-fu is not sufficient to figure it out.  */

     /* Overwrite the regs from ptrace with the ones previously computed.  */
-    my_memcpy(&user.regs, thread_regs, sizeof(struct regs));
+    memcpy(&user.regs, thread_regs, sizeof(struct regs));
     #else
     puser = NULL;
     #endif


use references

use references

--- lib/Basics/Traverser.h
+++ lib/Basics/Traverser.h
@@ -473,10 +473,13 @@
           std::deque<EdgeId> edges;
           EdgeWeight weight;

-          Path (std::deque<VertexId> vertices, std::deque<EdgeId> edges,
+          Path (std::deque<VertexId> const& vertices,
+                std::deque<EdgeId> const& edges,
                 EdgeWeight weight)
-            : vertices(vertices), edges(edges), weight(weight) {
-          };
+            : vertices(vertices),
+              edges(edges),
+              weight(weight) {
+          }
         };

 ////////////////////////////////////////////////////////////////////////////////
@@ -499,9 +502,14 @@
             Step () : _done(false) {
             }

-            Step (VertexId& vert, VertexId& pred,
-                  EdgeWeight weig, EdgeId const& edge)
-              :  _weight(weig), _vertex(vert), _predecessor(pred), _edge(edge),
+            Step (VertexId& vert,
+                  VertexId& pred,
+                  EdgeWeight weig,
+                  EdgeId const& edge)
+              : _weight(weig),
+                _vertex(vert),
+                _predecessor(pred),
+                _edge(edge),
                 _done(false) {
             }

@@ -571,10 +579,11 @@
                                 ThreadInfo& peerInfo,
                                 VertexId& start,
                                 ExpanderFunction expander,
-                                std::string id)
+                                std::string const& id)
               : _pathFinder(pathFinder), _myInfo(myInfo),
                 _peerInfo(peerInfo), _start(std::move(start)),
                 _expander(expander), _id(id) {
+
             }

 ////////////////////////////////////////////////////////////////////////////////
@@ -583,8 +592,8 @@

           private:

-            void insertNeighbor (Step* step, EdgeWeight newWeight) {
-
+            void insertNeighbor (Step* step,
+                                 EdgeWeight newWeight) {
               std::lock_guard<std::mutex> guard(_myInfo._mutex);
               Step* s = _myInfo._pq.find(step->_vertex);

@@ -750,11 +759,17 @@

           public:

-            Searcher (PathFinder* pathFinder, ThreadInfo& myInfo,
-                      ThreadInfo& peerInfo, VertexId& start,
-                      ExpanderFunction expander, std::string id)
-              : _pathFinder(pathFinder), _myInfo(myInfo),
-                _peerInfo(peerInfo), _start(start), _expander(expander),
+            Searcher (PathFinder* pathFinder,
+                      ThreadInfo& myInfo,
+                      ThreadInfo& peerInfo,
+                      VertexId& start,
+                      ExpanderFunction expander,
+                      std::string const& id)
+              : _pathFinder(pathFinder),
+                _myInfo(myInfo),
+                _peerInfo(peerInfo),
+                _start(start),
+                _expander(expander),
                 _id(id) {
             }

@@ -764,8 +779,8 @@

           private:

-            void insertNeighbor (Step* step, EdgeWeight newWeight) {
-
+            void insertNeighbor (Step* step,
+                                 EdgeWeight newWeight) {
               Step* s = _myInfo._pq.find(step->_vertex);

               // Not found, so insert it:
@@ -966,7 +981,7 @@
           }

           Step* s = forward._pq.find(_intermediate);
-          r_vertices.push_back(_intermediate);
+          r_vertices.emplace_back(_intermediate);

           // FORWARD Go path back from intermediate -> start.
           // Insert all vertices and edges at front of vector
@@ -984,8 +999,8 @@
           s = backward._pq.find(_intermediate);
           while (s->_predecessor.key != nullptr &&
                  strcmp(s->_predecessor.key, "") != 0) {
-            r_edges.push_back(s->_edge);
-            r_vertices.push_back(s->_predecessor);
+            r_edges.emplace_back(s->_edge);
+            r_vertices.emplace_back(s->_predecessor);
             s = backward._pq.find(s->_predecessor);
           }

@@ -1062,7 +1077,7 @@
           }

           Step* s = forward._pq.find(_intermediate);
-          r_vertices.push_back(_intermediate);
+          r_vertices.emplace_back(_intermediate);

           // FORWARD Go path back from intermediate -> start.
           // Insert all vertices and edges at front of vector
@@ -1080,8 +1095,8 @@
           s = backward._pq.find(_intermediate);
           while (s->_predecessor.key != nullptr &&
                  strcmp(s->_predecessor.key, "") != 0) {
-            r_edges.push_back(s->_edge);
-            r_vertices.push_back(s->_predecessor);
+            r_edges.emplace_back(s->_edge);
+            r_vertices.emplace_back(s->_predecessor);
             s = backward._pq.find(s->_predecessor);
           }

@@ -1236,7 +1251,10 @@
           std::deque<EdgeId> edges;
           size_t weight;

-          Path () : weight(0) {};
+          Path ()
+            : weight(0) {
+
+          };
         };

 ////////////////////////////////////////////////////////////////////////////////
@@ -1253,9 +1271,10 @@
           VertexId const _pred;
           EdgeId const _path;

-          PathSnippet (VertexId& pred, EdgeId& path) :
-            _pred(pred),
-            _path(path) {
+          PathSnippet (VertexId& pred, EdgeId& path)
+            : _pred(pred),
+              _path(path) {
+
           }

         };
@@ -1289,13 +1308,13 @@
           Path* res = new Path();
           // Init
           if (start == end) {
-            res->vertices.push_back(start);
+            res->vertices.emplace_back(start);
             return res;
           }
           _leftFound.emplace(start, nullptr);
           _rightFound.emplace(end, nullptr);
-          _leftClosure.push_back(start);
-          _rightClosure.push_back(end);
+          _leftClosure.emplace_back(start);
+          _rightClosure.emplace_back(end);
           std::vector<EdgeId> edges;
           std::vector<VertexId> neighbors;
           while (_leftClosure.size() > 0 && _rightClosure.size() > 0) {
@@ -1303,7 +1322,7 @@
             neighbors.clear();
             std::deque<VertexId> _nextClosure;
             if (_leftClosure.size() < _rightClosure.size()) {
-              for (VertexId v : _leftClosure) {
+              for (VertexId& v : _leftClosure) {
                 _leftNeighborExpander(v, edges, neighbors);
                 TRI_ASSERT(edges.size() == neighbors.size());
                 for (size_t i = 0; i < neighbors.size(); ++i) {
@@ -1311,7 +1330,7 @@
                   if (_leftFound.find(n) == _leftFound.end()) {
                     _leftFound.emplace(n, new PathSnippet(v, edges.at(i)));
                     if (_rightFound.find(n) != _rightFound.end()) {
-                      res->vertices.push_back(n);
+                      res->vertices.emplace_back(n);
                       auto it = _leftFound.find(n);
                       VertexId next;
                       while (it->second != nullptr) {
@@ -1323,20 +1342,21 @@
                       it = _rightFound.find(n);
                       while (it->second != nullptr) {
                         next = it->second->_pred;
-                        res->vertices.push_back(next);
-                        res->edges.push_back(it->second->_path);
+                        res->vertices.emplace_back(next);
+                        res->edges.emplace_back(it->second->_path);
                         it = _rightFound.find(next);
                       }
                       res->weight = res->edges.size();
                       return res;
                     }
-                    _nextClosure.push_back(n);
+                    _nextClosure.emplace_back(n);
                   }
                 }
               }
               _leftClosure = _nextClosure;
-            } else {
-               for (VertexId v : _rightClosure) {
+            }
+            else {
+               for (VertexId& v : _rightClosure) {
                 _rightNeighborExpander(v, edges, neighbors);
                 TRI_ASSERT(edges.size() == neighbors.size());
                 for (size_t i = 0; i < neighbors.size(); ++i) {
@@ -1344,7 +1364,7 @@
                   if (_rightFound.find(n) == _rightFound.end()) {
                     _rightFound.emplace(n, new PathSnippet(v, edges.at(i)));
                     if (_leftFound.find(n) != _leftFound.end()) {
-                      res->vertices.push_back(n);
+                      res->vertices.emplace_back(n);
                       auto it = _leftFound.find(n);
                       VertexId next;
                       while (it->second != nullptr) {
@@ -1356,14 +1376,14 @@
                       it = _rightFound.find(n);
                       while (it->second != nullptr) {
                         next = it->second->_pred;
-                        res->vertices.push_back(next);
-                        res->edges.push_back(it->second->_path);
+                        res->vertices.emplace_back(next);
+                        res->edges.emplace_back(it->second->_path);
                         it = _rightFound.find(next);
                       }
                       res->weight = res->edges.size();
                       return res;
                     }
-                    _nextClosure.push_back(n);
+                    _nextClosure.emplace_back(n);
                   }
                 }
               }


avoid double-free. Noticed by Rob.

avoid double-free. Noticed by Rob.

git-svn-id: fa6c8bc307858af7a2ed2f6e39ba40ad8a488bfa@27068 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6

--- src/enchant.c
+++ src/enchant.c
@@ -606,7 +606,6 @@

 	session = enchant_session_new_with_pwl (provider, dic, excl, lang, fail_if_no_pwl);

-	g_free (excl);
 	g_free (dic);
 	g_free (excl);


riscv: Fix tcctest.c

riscv: Fix tcctest.c

this is it!  With this tcctest.c works, as well as compiling
TCC with itself.  abitest.c doesn't yet work due to known
problems, all the rest does.  There are still warnings during
linking.

--- riscv64-gen.c
+++ riscv64-gen.c
@@ -184,7 +184,7 @@
                 sv->c.i = 0;
             } else {
                 if (((unsigned)fc + (1 << 11)) >> 12)
-                  tcc_error("unimp: large addend for global address");
+                  tcc_error("unimp: large addend for global address (0x%llx)", sv->c.i);
                 greloca(cur_text_section, sv->sym, ind,
                         R_RISCV_GOT_HI20, 0);
                 doload = 1;
@@ -233,7 +233,7 @@
                 sv->c.i = 0;
             } else {
                 if (((unsigned)fc + (1 << 11)) >> 12)
-                  tcc_error("unimp: large addend for global address");
+                  tcc_error("unimp: large addend for global address (0x%llx)", sv->c.i);
                 greloca(cur_text_section, sv->sym, ind,
                         R_RISCV_GOT_HI20, 0);
                 doload = 1;
@@ -383,7 +383,7 @@
             sv->c.i = 0;
         } else {
             if (((unsigned)fc + (1 << 11)) >> 12)
-              tcc_error("unimp: large addend for global address");
+              tcc_error("unimp: large addend for global address (0x%llx)", sv->c.i);
             greloca(cur_text_section, sv->sym, ind,
                     R_RISCV_GOT_HI20, 0);
             doload = 1;
@@ -569,6 +569,7 @@
         }
     }
     vrotb(nb_args + 1);
+    save_regs(nb_args + 1);
     gcall_or_jmp(1);
     vtop -= nb_args + 1;
     if (stack_adj + tempspace)
@@ -1081,9 +1082,24 @@
         int func = (dt == VT_LDOUBLE) ?
             (st == VT_FLOAT ? TOK___extendsftf2 : TOK___extenddftf2) :
             (dt == VT_FLOAT ? TOK___trunctfsf2 : TOK___trunctfdf2);
+        /* We can't use gfunc_call, as func_old_type works like vararg
+           functions, and on riscv unnamed float args are passed like
+           integers.  But we really need them in the float argument registers
+           for extendsftf2/extenddftf2.  So, do it explicitely.  */
+        save_regs(1);
+        if (dt == VT_LDOUBLE)
+          gv(RC_F(0));
+        else {
+            gv(RC_R(0));
+            assert(vtop->r2 < 7);
+            if (vtop->r2 != 1 + vtop->r) {
+                EI(0x13, 0, ireg(vtop->r) + 1, ireg(vtop->r2), 0); // mv Ra+1, RR2
+                vtop->r2 = 1 + vtop->r;
+            }
+        }
         vpush_global_sym(&func_old_type, func);
-        vrott(2);
-        gfunc_call(1);
+        gcall_or_jmp(1);
+        vtop -= 2;
         vpushi(0);
         vtop->type.t = dt;
         if (dt == VT_LDOUBLE)


fts: Fixed a crash if virtual mailbox search couldn't be optimized by backend.

--- src/plugins/fts/fts-api.c
+++ src/plugins/fts/fts-api.c
@@ -323,8 +323,14 @@
 	i_assert(boxes[0] != NULL);

 	if (backend->v.lookup_multi != NULL) {
-		return backend->v.lookup_multi(backend, boxes, args,
-					       and_args, result);
+		if (backend->v.lookup_multi(backend, boxes, args,
+					    and_args, result) < 0)
+			return -1;
+		if (result->box_results == NULL) {
+			result->box_results = p_new(result->pool,
+						    struct fts_result, 1);
+		}
+		return 0;
 	}

 	for (i = 0; boxes[i] != NULL; i++) ;


Recontruct full frame from tiles

Recontruct full frame from tiles

--- src/encoder.c
+++ src/encoder.c
@@ -700,6 +700,10 @@
         encoder_state->children[i].cur_pic->type = encoder_state->cur_pic->type;

         substream_encode(&encoder_state->children[i], x == (encoder->tiles_num_tile_columns-1) && y == (encoder->tiles_num_tile_rows-1));
+
+        picture_blit_pixels(encoder_state->children[i].cur_pic->y_recdata, encoder_state->cur_pic->y_recdata + tile_offset_full, tile_width, tile_height, tile_width, encoder_state->cur_pic->width);
+        picture_blit_pixels(encoder_state->children[i].cur_pic->u_recdata, encoder_state->cur_pic->u_recdata + tile_offset_half, tile_width/2, tile_height/2, tile_width/2, encoder_state->cur_pic->width/2);
+        picture_blit_pixels(encoder_state->children[i].cur_pic->v_recdata, encoder_state->cur_pic->v_recdata + tile_offset_half, tile_width/2, tile_height/2, tile_width/2, encoder_state->cur_pic->width/2);
       }
     }


Initial commit

Initial commit

--- netshelld.c
+++ netshelld.c
@@ -0,0 +1,94 @@
+/*
+ * A simple Telnet clone designed for easy remote access
+ * Socket handling based on Practical Sockets (https://github.com/Tookmund/PracticalSockets/)
+ * Only supports IPv4 at them moment
+ *
+ * By Jacob Adams <tookmund@gmail.com>
+ */
+
+#define DEBUG /* Enable to print debug messages */
+#define ADDR 12 /* Length of an IPv4 address plus null */
+#define MAX 1024 /* Largest message that can be recived */
+#define SHELL "/bin/sh" /* Program to use as shell */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+/* POSIX */
+#include <sys/types.h>  /* For data types */
+#include <sys/socket.h> /* For socket(), connect(), send(), and recv() */
+#include <netdb.h> 	/* For gethostbyname() */
+#include <arpa/inet.h> 	/* For inet_addr() */
+#include <unistd.h> 	/* For close() */
+#include <netinet/in.h> /* For sockaddr_in */
+#include <limits.h>
+
+#ifdef DEBUG
+#define DBG(string) printf(string)
+#endif
+
+/* Make an IPv4 TCP socket holder */
+int sockDesc;
+
+/* Borrow some functions from Practical Sockets */
+
+static void fillAddr(char* address, unsigned short port,
+	struct sockaddr_in addr) {
+	memset(&addr, 0, sizeof(addr)); /* Zero out address structure */
+	addr.sin_family = AF_INET; /* Internet address */
+	struct hostent *host; /* Resolve name */
+	if ((host = gethostbyname(address)) == NULL) {
+		/*
+		 * strerror() will not work for gethostbyname() and hstrerror()
+		 * is supposedly obsolete
+		 */
+		DBG("\nFailed to resolve name (gethostbyname())\n");
+	}
+	addr.sin_addr.s_addr = *((unsigned long *) host->h_addr_list[0]);
+	addr.sin_port = htons(port); /* Assign port in network byte order */
+}
+
+void setLocalAddressAndPort(char* localAddress,
+	unsigned short localPort) {
+	/* Get the address of the requested host */
+	struct sockaddr_in localAddr;
+	fillAddr(localAddress, localPort, localAddr);
+	if (bind(sockDesc, (struct sockaddr *) &localAddr, sizeof(struct sockaddr_in)) < 0) {
+		perror("\nSet of local address and port failed (bind())");
+	}
+}
+void child(int sfd) {
+	dup2(sfd,0);
+	dup2(sfd,1);
+	char* args[] = {SHELL};
+	execv(SHELL,args);
+}
+
+int main (void) {
+	struct protoent *pro;
+	pro = getprotobyname("tcp");
+	int protocol;
+	if (pro == NULL) protocol = 0;
+	else protocol = pro->p_proto;
+	sockDesc = socket(AF_INET,SOCK_STREAM,protocol);
+	setLocalAddressAndPort("localhost",23);
+	listen(sockDesc,10);
+	for (;;) {
+		DBG("\nWaiting...\n");
+		int sfd = accept(sockDesc,NULL,NULL);
+		int pid = fork();
+		if (pid == -1) {
+			perror("Fork");
+		}
+		else if (pid == 0) {
+			child(sfd);
+			exit(0);
+		}
+		else {
+			close(sfd);
+			DBG("\nConnected\n");
+		}
+	}
+}


quota: Ignore quota limits for admin users.

--- src/plugins/quota/quota.c
+++ src/plugins/quota/quota.c
@@ -927,6 +927,11 @@
 	ctx->box = box;
 	ctx->bytes_ceil = (uint64_t)-1;
 	ctx->count_ceil = (uint64_t)-1;
+
+	if (box->storage->user->admin) {
+		/* ignore quota for admins */
+		ctx->limits_set = TRUE;
+	}
 	return ctx;
 }


replaced strcpy with apr_pstrndup

replaced strcpy with apr_pstrndup

--- mod_hco.c
+++ mod_hco.c
@@ -1,4 +1,4 @@
-/*
+/*
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -12,17 +12,15 @@
  * limitations under the License.
  */

-/*
+/*
 **  mod_hco.c -- Apache sample hco module
-**  [Autogenerated via ``apxs -n hco -g'']
-**
 **  To play with this sample module first compile it into a
-**  DSO file and install it into Apache's modules directory
+**  DSO file and install it into Apache's modules directory
 **  by running:
 **
 **    $ apxs -c -i mod_hco.c
 **
-*/
+*/

 #include "apr.h"
 #include "apr_version.h"
@@ -44,52 +42,51 @@
 #define HCO_DISABLED             0
 #define HCO_ENABLED              1

-#define hco_server_conf(srv) (hco_server_conf *)ap_get_module_config(srv->module_config,  &hco_module)
+#define hco_get_server_conf(srv) (hco_server_conf *)ap_get_module_config(srv->module_config, &hco_module)

 module AP_MODULE_DECLARE_DATA hco_module;

 typedef struct {
-  CURL *curl;
-  const char *base_path;
-  const char *end_point;
-  const char *auth_key;
-  int enabled;
-
+    CURL *curl;
+    const char *base_path;
+    const char *end_point;
+    const char *auth_key;
+    int enabled;
 } hco_server_conf;

 /*
  * return a table with app_id and app_key value keys.
  */
 static apr_table_t *
-parse_query_string(request_rec * r, const char * query)
-{
-    char* next;
-    char* last;
-    char * query_copy;
-    apr_table_t * table;
-
-    table = apr_table_make (r->pool, 1);
-
+parse_query_string(apr_pool_t *pool, const char *query)
+{
+    char *next;
+    char *last;
+    char *query_copy;
+    apr_table_t *table;
+
+    table = apr_table_make (pool, 1);
+
     if (!query) {
         return table;
     }
-
-    query_copy= malloc(strlen(query));
-    strcpy(query_copy, query);
-
-    next =  (char *)apr_strtok( query_copy, "&", &last );
+
+    // because of the destructive nature of apr_strtok,
+    // we need to make a copy of the query string
+    // use the request pool so we can get free for free
+    query_copy = apr_pstrndup(pool, query, strlen(query));
+
+    next = (char *) apr_strtok( query_copy, "&", &last );
     while (next) {
-        apr_collapse_spaces (next, next);
-        char* key;
-        char* value;
-        key =  (char *)apr_strtok( next, "=", &value);
-        if(key && ( strcmp(key, "app_key")  == 0 || strcmp(key, "app_id") == 0)) {
-            // ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, r->server, "HCO: %s=%s.", key, value);
+        apr_collapse_spaces(next, next);
+        char *key;
+        char *value;
+        key =  (char *) apr_strtok( next, "=", &value);
+        if(key && (strcmp(key, "app_key")  == 0 || strcmp(key, "app_id" ) == 0)) {
             apr_table_set(table, key, value);
         }
-        next = (char*)apr_strtok(NULL, "&", &last);
-    }
-    free(query_copy);
+        next = (char*) apr_strtok(NULL, "&", &last);
+    }
     return table;
 }

@@ -122,14 +119,14 @@
     const char *app_id;
     const char *app_key;
     apr_table_t *params;
-
-    hco_server_conf *sconf = hco_server_conf(r->server);
-
+
+    hco_server_conf * sconf = hco_get_server_conf(r->server);
+
     if(strcmp(r->handler, "hco-handler")) {
         return DECLINED;
     }

-    params = parse_query_string(r, r->parsed_uri.query);
+    params = parse_query_string(r->pool, r->parsed_uri.query);
     app_id = apr_table_get(params, "app_id");
     app_key= apr_table_get(params, "app_key");

@@ -150,13 +147,13 @@
     ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, r->server, "HCO: handler-> ready to authorize.");

     authpath = apr_pstrcat(
-        r->pool,
-        sconf->end_point,
-        "/transactions/authorize.xml?app_id=",
+        r->pool,
+        sconf->end_point,
+        "/transactions/authorize.xml?app_id=",
         (app_id==NULL)? "" : app_id, // app_id is mandatory.
-        (app_key==NULL)? "" : apr_pstrcat(r->pool, "&app_key=", app_key, NULL), // app_key is not
-        "&provider_key=",
-        sconf->auth_key,
+        (app_key==NULL)? "" : apr_pstrcat(r->pool, "&app_key=", app_key, NULL), // app_key is not
+        "&provider_key=",
+        sconf->auth_key,
         NULL
     );

@@ -195,7 +192,7 @@
       ap_rprintf(r, " --effective end-point url: %s\n", remote_eff_url);
       ap_rprintf(r, " --took: %f sec.\n", remote_total_time);
       ap_rprintf(r, " --response code: %d\n", remote_response_code);
-
+
       if(chunk.memory) {
         ap_rprintf(r, "\n --remote body-- \n%s\n", chunk.memory);
         ap_rprintf(r, "\n --remote size: %lu\n", (long)chunk.size);
@@ -215,7 +212,7 @@
 */
 static const char *cmd_hco_engine(cmd_parms *cmd, void *dconf, int flag)
 {
-    hco_server_conf *sconf = hco_server_conf(cmd->server);
+    hco_server_conf *sconf = hco_get_server_conf(cmd->server);

     sconf->enabled = (flag ? HCO_ENABLED : HCO_DISABLED);
     return NULL;
@@ -225,8 +222,8 @@
 * XXX. dconf.
 */
 static const char *cmd_hco_base_path(cmd_parms *cmd, void *dconf, const char *a1) {
-    hco_server_conf *sconf = hco_server_conf(cmd->server);
-
+    hco_server_conf *sconf = hco_get_server_conf(cmd->server);
+
     sconf->base_path = a1;
     return NULL;
 }
@@ -236,8 +233,8 @@
 */
 static const char *cmd_hco_end_point(cmd_parms *cmd, void *dconf, const char *a1)
 {
-    hco_server_conf *sconf = hco_server_conf(cmd->server);
-
+    hco_server_conf *sconf = hco_get_server_conf(cmd->server);
+
     sconf->end_point= a1;
     return NULL;
 }
@@ -245,21 +242,21 @@
 /* Config HcoAuthCode "codeffaap20192"
  *XXX. dconf
  */
-static const char *cmd_hco_auth_key(cmd_parms *cmd, void *dconf, const char *a1)
-{
-    hco_server_conf *sconf = hco_server_conf(cmd->server);
-
+static const char *cmd_hco_auth_key(cmd_parms *cmd, void *dconf, const char *a1)
+{
+    hco_server_conf *sconf = hco_get_server_conf(cmd->server);
+
     sconf->auth_key= a1;
     return NULL;
 }

 /*
  * default server configs
- */
-static void *hco_server_config_create(apr_pool_t *p, server_rec *s)
+ */
+static void *hco_server_config_create(apr_pool_t *p, server_rec *s)
 {
   hco_server_conf *sconf = (hco_server_conf *)apr_palloc(p, sizeof(hco_server_conf));
-
+
   sconf->enabled   = HCO_DISABLED;
   sconf->end_point = NULL;
   sconf->auth_key  = NULL;
@@ -285,8 +282,8 @@
 */

         int turn_off = 0;
-        hco_server_conf *sconf = hco_server_conf(s);
-
+        hco_server_conf *sconf = hco_get_server_conf(s);
+
         if(!sconf->enabled) {
             ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s, "HCO: disabled.");
             return OK;
@@ -310,11 +307,11 @@
             }
         }

-        // good, we're here.
+        // good, we're here.
         // let's configure a cURL handler.
         curl_global_init(CURL_GLOBAL_ALL);
         sconf->curl = curl_easy_init();
-
+
         if(sconf->curl) {
             // can setup global curl options here.
             curl_easy_setopt(sconf->curl, CURLOPT_URL, sconf->end_point);
@@ -354,23 +351,23 @@

 /*
  * if we're activated, pass the request to the hco_handler
- */
+ */
 static int hco_fixups(request_rec *r)
 {
-    hco_server_conf *sconf = hco_server_conf(r->server);
+    hco_server_conf *sconf = hco_get_server_conf(r->server);

     if(!sconf->enabled || strstr(r->uri, sconf->base_path) == NULL) {
         return OK;
     }
-
+
     r->handler = "hco-handler";
     return OK;
 }

 /*
  * Reports the transaction.
- */
-static int
+ */
+static int
 hco_log_transaction(request_rec *orig)
 {
     const char *report_path;
@@ -379,13 +376,13 @@
     apr_table_t *params;
     CURLcode res;

-    hco_server_conf *sconf = hco_server_conf(orig->server);
+    hco_server_conf *sconf = hco_get_server_conf(orig->server);

     if(!sconf->enabled || strstr(orig->uri, sconf->base_path) == NULL) {
         return OK;
     }

-    params = parse_query_string(orig, orig->parsed_uri.query);
+    params = parse_query_string(orig->pool, orig->parsed_uri.query);
     app_id = apr_table_get(params, "app_id");

     if(app_id == NULL) {
@@ -435,7 +432,7 @@
     return OK;
 }

-static const command_rec hco_cmds[] =
+static const command_rec hco_cmds[] =
 {
   AP_INIT_FLAG("HcoEngine", cmd_hco_engine,  NULL, ACCESS_CONF, "On or Off to enable or disable (default) the whole hco engine"),
   AP_INIT_TAKE1("HcoBasePath", cmd_hco_base_path, NULL, ACCESS_CONF, "base path"),
@@ -444,7 +441,7 @@
   { NULL }
 };

-static void hco_register_hooks(apr_pool_t *p)
+static void hco_register_hooks(apr_pool_t *p)
 {
     ap_hook_handler(hco_handler, NULL, NULL, APR_HOOK_MIDDLE); // generic handler --XXX. replace by auth
     ap_hook_fixups(hco_fixups, NULL, NULL, APR_HOOK_MIDDLE) ;  // decides if the hco-handler should run for this request --XXX. replace by auth
@@ -454,7 +451,7 @@

 /* Dispatch list for API hooks */
 module AP_MODULE_DECLARE_DATA hco_module = {
-    STANDARD20_MODULE_STUFF,
+    STANDARD20_MODULE_STUFF,
     NULL,                  /* create per-dir    config structures */
     NULL,                  /* merge  per-dir    config structures */
     hco_server_config_create,                  /* create per-server config structures */


Avoid unnecessary copying of predicted pixels when there are no coeffs.

- These are probably from a time when reconstruction happened in this
  function.

--- src/encoder.c
+++ src/encoder.c
@@ -2847,7 +2847,7 @@
 }

 static void reconstruct_chroma(const encoder_state * const encoder_state, cu_info *cur_cu,
-                               int depth, int has_coeffs, coefficient *coeff_u,
+                               int depth, coefficient *coeff_u,
                                pixel *recbase_u, pixel *pred_u, int color_type,
                                coefficient *pre_quant_coeff, coefficient *block)
 {
@@ -2857,28 +2857,16 @@

   int i, y, x;

-  if (has_coeffs) {
-    // RECONSTRUCT for predictions
-    dequant(encoder_state, coeff_u, pre_quant_coeff, width_c, width_c, (int8_t)color_type, cur_cu->type);
-    itransform2d(encoder_state->encoder_control, block, pre_quant_coeff, width_c, 65535);
-
-    i = 0;
-
-    for (y = 0; y < width_c; y++) {
-      for (x = 0; x < width_c; x++) {
-        int16_t val = block[i++] + pred_u[x + y * (pred_stride >> 1)];
-        //TODO: support 10+bits
-        recbase_u[x + y * (recbase_stride >> 1)] = (uint8_t)CLIP(0, 255, val);
-      }
-    }
-
-    // END RECONTRUCTION
-  } else {
-    // without coeffs, we only use the prediction
-    for (y = 0; y < width_c; y++) {
-      for (x = 0; x < width_c; x++) {
-        recbase_u[x + y * (recbase_stride >> 1)] = pred_u[x + y * (pred_stride >> 1)];
-      }
+  dequant(encoder_state, coeff_u, pre_quant_coeff, width_c, width_c, (int8_t)color_type, cur_cu->type);
+  itransform2d(encoder_state->encoder_control, block, pre_quant_coeff, width_c, 65535);
+
+  i = 0;
+
+  for (y = 0; y < width_c; y++) {
+    for (x = 0; x < width_c; x++) {
+      int16_t val = block[i++] + pred_u[x + y * (pred_stride >> 1)];
+      //TODO: support 10+bits
+      recbase_u[x + y * (recbase_stride >> 1)] = (uint8_t)CLIP(0, 255, val);
     }
   }
 }
@@ -3169,13 +3157,6 @@
           recbase_y[x + y * recbase_stride] = (pixel)CLIP(0, 255, val);
         }
       }
-    } else {
-      // Without coefficients, just copy the prediction as the reconstructed image.
-      for (y = 0; y < width; y++) {
-        for (x = 0; x < width; x++) {
-          recbase_y[x + y * recbase_stride] = pred_y[x + y * pred_stride];
-        }
-      }
     }

     // If luma is 4x4, do chroma for the 8x8 luma area when handling the top
@@ -3222,14 +3203,16 @@
         }
       }

-      reconstruct_chroma(encoder_state, cur_cu, chroma_depth,
-                         cbf_is_set(cur_cu->cbf.u, depth),
-                         coeff_u, recbase_u, pred_u, color_type_u,
-                         pre_quant_coeff, block);
-      reconstruct_chroma(encoder_state, cur_cu, chroma_depth,
-                         cbf_is_set(cur_cu->cbf.v, depth),
-                         coeff_v, recbase_v, pred_v, color_type_v,
-                         pre_quant_coeff, block);
+      if (cbf_is_set(cur_cu->cbf.u, depth)) {
+        reconstruct_chroma(encoder_state, cur_cu, chroma_depth,
+                           coeff_u, recbase_u, pred_u, color_type_u,
+                           pre_quant_coeff, block);
+      }
+      if (cbf_is_set(cur_cu->cbf.v, depth)) {
+        reconstruct_chroma(encoder_state, cur_cu, chroma_depth,
+                           coeff_v, recbase_v, pred_v, color_type_v,
+                           pre_quant_coeff, block);
+      }
     }

     return;


udpgw: try to fix the local port binding

--- udpgw/udpgw.c
+++ udpgw/udpgw.c
@@ -35,6 +35,7 @@
 #include <misc/byteorder.h>
 #include <misc/bsize.h>
 #include <misc/open_standard_streams.h>
+#include <misc/balloc.h>
 #include <structure/LinkedList1.h>
 #include <structure/BAVL.h>
 #include <base/BLog.h>
@@ -89,6 +90,7 @@
     union {
         struct {
             BDatagram udp_dgram;
+            int local_port_index;
             BufferWriter udp_send_writer;
             PacketBuffer udp_send_buffer;
             SinglePacketBuffer udp_recv_buffer;
@@ -849,23 +851,60 @@
         goto fail2;
     }

+    con->local_port_index = -1;
+
     if (options.local_udp_num_ports >= 0) {
-        // try binding (without SO_REUSEADDR, else we'd always end up binding to first port)
+        // allocate port usage array
+        uint8_t *port_usage = BAllocSize(bsize_fromint(options.local_udp_num_ports));
+        if (!port_usage) {
+            client_log(client, BLOG_ERROR, "BAllocSize failed");
+            goto failed;
+        }
+        memset(port_usage, 0, options.local_udp_num_ports);
+
+        // flag inappropriate ports (those with the same remote address)
+        for (LinkedList1Node *ln = LinkedList1_GetFirst(&clients_list); ln; ln = LinkedList1Node_Next(ln)) {
+            struct client *client2 = UPPER_OBJECT(ln, struct client, clients_list_node);
+
+            for (LinkedList1Node *ln2 = LinkedList1_GetFirst(&client2->connections_list); ln2; ln2 = LinkedList1Node_Next(ln2)) {
+                struct connection *con2 = UPPER_OBJECT(ln2, struct connection, connections_list_node);
+                ASSERT(con2->client == client2)
+                ASSERT(!con2->closing)
+                ASSERT(con2->local_port_index < options.local_udp_num_ports)
+
+                if (con2->local_port_index >= 0 && BAddr_Compare(&con2->addr, &con->addr)) {
+                    port_usage[con2->local_port_index] = 1;
+                }
+            }
+        }
+
+        // set SO_REUSEADDR
+        if (!BDatagram_SetReuseAddr(&con->udp_dgram, 1)) {
+            client_log(client, BLOG_ERROR, "set SO_REUSEADDR failed");
+            goto failed;
+        }
+
+        // try different ports
         for (int i = 0; i < options.local_udp_num_ports; i++) {
+            // skip inappropriate ports
+            if (port_usage[i]) {
+                continue;
+            }
+
             BAddr addr = local_udp_addr;
             BAddr_SetPort(&addr, hton16(ntoh16(BAddr_GetPort(&addr)) + (uint16_t)i));

             if (BDatagram_Bind(&con->udp_dgram, addr)) {
-                // set SO_REUSEADDR (we bound without it, but we don't want to take over the address)
-                if (!BDatagram_SetReuseAddr(&con->udp_dgram, 1)) {
-                    client_log(client, BLOG_ERROR, "set SO_REUSEADDR failed");
-                }
+                // remember which port we're using
+                con->local_port_index = i;
                 goto cont;
             }
         }

+    failed:
         client_log(client, BLOG_WARNING, "failed to bind to any local address; proceeding regardless");
     cont:;
+        free(port_usage);
     }

     // set UDP dgram send address


quota: Use quota_last_extra only for LDA/LMTP (not for IMAP).

--- src/plugins/quota/quota.c
+++ src/plugins/quota/quota.c
@@ -994,10 +994,13 @@
 	const char *mailbox_name;
 	unsigned int i, count;
 	uint64_t bytes_limit, count_limit, current, limit, diff;
+	bool use_last_extra;
 	int ret;

 	ctx->limits_set = TRUE;
 	mailbox_name = mailbox_get_vname(ctx->box);
+	/* use last_mail_max_extra_bytes only for LDA/LMTP */
+	use_last_extra = (ctx->box->flags & MAILBOX_FLAG_POST_SESSION) != 0;

 	/* find the lowest quota limits from all roots and use them */
 	roots = array_get(&ctx->quota->roots, &count);
@@ -1028,7 +1031,8 @@
 					diff = limit - current;
 					if (ctx->bytes_ceil2 > diff)
 						ctx->bytes_ceil2 = diff;
-					diff += roots[i]->set->last_mail_max_extra_bytes;
+					diff += !use_last_extra ? 0 :
+						roots[i]->set->last_mail_max_extra_bytes;
 					if (ctx->bytes_ceil > diff)
 						ctx->bytes_ceil = diff;
 				}


Fix compilation without INET and INET6.

Fix compilation without INET and INET6.

--- KERN/netinet/sctp_output.c
+++ KERN/netinet/sctp_output.c
@@ -4847,9 +4847,7 @@
 	struct mbuf *m;
 	struct sctp_nets *net;
 	struct sctp_init_chunk *init;
-#if defined(INET) || defined(INET6)
 	struct sctp_supported_addr_param *sup_addr;
-#endif
 	struct sctp_adaptation_layer_indication *ali;
 	struct sctp_supported_chunk_types_param *pr_supported;
 	struct sctp_paramhdr *ph;


quota debug: Hide "(0%)" if quota limits aren't defined defined in percentages.

--- src/plugins/quota/quota.c
+++ src/plugins/quota/quota.c
@@ -422,10 +422,14 @@
 	quota_root_recalculate_relative_rules(root_set);
 	if (root_set->set->debug) {
 		i_info("Quota rule: root=%s mailbox=%s "
-		       "bytes=%lld (%u%%) messages=%lld (%u%%)", root_set->name,
+		       "bytes=%lld%s messages=%lld%s", root_set->name,
 		       mailbox_name,
-		       (long long)rule->bytes_limit, rule->bytes_percent,
-		       (long long)rule->count_limit, rule->count_percent);
+		       (long long)rule->bytes_limit,
+		       rule->bytes_percent == 0 ? "" :
+		       t_strdup_printf(" (%u%%)", rule->bytes_percent),
+		       (long long)rule->count_limit,
+		       rule->count_percent == 0 ? "" :
+		       t_strdup_printf(" (%u%%)", rule->count_percent));
 	}
 	return ret;
 }
@@ -570,12 +574,15 @@

 	quota_root_recalculate_relative_rules(root_set);
 	if (root_set->set->debug) {
-		i_info("Quota warning: bytes=%llu (%u%%) "
-		       "messages=%llu (%u%%) command=%s",
+		i_info("Quota warning: bytes=%llu%s "
+		       "messages=%llu%s command=%s",
 		       (unsigned long long)warning->rule.bytes_limit,
-		       warning->rule.bytes_percent,
+		       warning->rule.bytes_percent == 0 ? "" :
+		       t_strdup_printf(" (%u%%)", warning->rule.bytes_percent),
 		       (unsigned long long)warning->rule.count_limit,
-		       warning->rule.count_percent, warning->command);
+		       warning->rule.count_percent == 0 ? "" :
+		       t_strdup_printf(" (%u%%)", warning->rule.count_percent),
+		       warning->command);
 	}
 	return 0;
 }


branches/zip: fil_close(): Add #ifndef UNIV_HOTBACKUP around a debug
assertion on mutex.magic_n.  InnoDB Hot Backup is a single-threaded
program and does not contain mutexes.  This change allows InnoDB Hot
Backup to be compiled with UNIV_DEBUG.

Suggested by Michael Izioumtchenko.

--- fil/fil0fil.c
+++ fil/fil0fil.c
@@ -4786,8 +4786,10 @@
 fil_close(void)
 /*===========*/
 {
+#ifndef UNIV_HOTBACKUP
 	/* The mutex should already have been freed. */
 	ut_ad(fil_system->mutex.magic_n == 0);
+#endif /* !UNIV_HOTBACKUP */

 	hash_table_free(fil_system->spaces);


(FontManagerBackEndGL::updateImage) : Refine

--- src/font/FontManagerBackEndGL.h
+++ src/font/FontManagerBackEndGL.h
@@ -100,7 +100,7 @@
         unsigned px = FontTexture::Width;
         for (int level = 0; level < FontTexture::Level; ++level) {
             uint8_t* p = FontTexture::getMipmapImage(image, level) + px * y + x;
-            for (int i = 0; i < h; ++i, p += px) {
+            for (unsigned i = 0; i < h; ++i, p += px) {
                 glTexSubImage2D(GL_TEXTURE_2D, level, x, y + i, w, 1,
                                 GL_LUMINANCE, GL_UNSIGNED_BYTE, p);
             }


[project @ 2000-04-07 16:20:53 by sewardj] Fix silly bug with option setting:   :s _S  --> segfault


feat: add unique_mores_code_words

feat: add unique_mores_code_words

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

--- unique_mores_code_words/c/unique_mores_code_words.c
+++ unique_mores_code_words/c/unique_mores_code_words.c
@@ -0,0 +1,51 @@
+#include <stdio.h>
+#include <minunit.h>
+
+int unique_mores_representations(char** words, int wordsSize) {
+  char *mores[] = {
+    ".-",
+    "-...",
+    "-.-.",
+    "-..",
+    ".",
+    "..-.",
+    "--.",
+    "....",
+    "..",
+    ".---",
+    "-.-",
+    ".-..",
+    "--",
+    "-.",
+    "---",
+    ".--.",
+    "--.-",
+    ".-.",
+    "...",
+    "-",
+    "..-",
+    "...-",
+    ".--",
+    "-..-",
+    "-.--",
+    "--.."
+  };
+  return 0;
+}
+
+
+MU_TEST(test_check) {
+  /* int count = num_jewels_in_stones("aA", "aAAbbbb"); */
+  /* mu_check(3 == count); */
+  /* mu_assert(2 == num_jewels_in_stones("abcdef", "abz"), "(abcdef, abz) => 2"); */
+}
+
+MU_TEST_SUITE(test_suite) {
+  MU_RUN_TEST(test_check);
+}
+
+int main(void) {
+  MU_RUN_SUITE(test_suite);
+  MU_REPORT();
+  return minunit_status;
+}


init-ack scope of linklocal is private address ok too.

--- KERN/netinet/sctp_output.c
+++ KERN/netinet/sctp_output.c
@@ -3529,7 +3529,7 @@
 				 */
 				stc.local_scope = 0;
 				stc.site_scope = 1;
-
+				stc.ipv4_scope = 1;
 				/* we start counting for the private
 				 * address stuff at 1. since the link
 				 * local we source from won't show


Remove unreachable MatrixPowerTriangular, paving the way to future cleanups.

--- unsupported/Eigen/src/MatrixFunctions/MatrixPower.h
+++ unsupported/Eigen/src/MatrixFunctions/MatrixPower.h
@@ -258,11 +258,19 @@
  * \tparam MatrixType  type of the base, expected to be an instantiation
  * of the Matrix class template.
  *
- * This class is capable of computing upper triangular matrices raised
- * to an arbitrary real power.
+ * This class is capable of computing real/complex matrices raised to
+ * an arbitrary real power. Meanwhile, it saves the result of Schur
+ * decomposition if an non-integral power has even been calculated.
+ * Therefore, if you want to compute multiple (>= 2) matrix powers
+ * for the same matrix, using the class directly is more efficient than
+ * calling MatrixBase::pow().
+ *
+ * Example:
+ * \include MatrixPower_optimal.cpp
+ * Output: \verbinclude MatrixPower_optimal.out
  */
 template<typename MatrixType>
-class MatrixPowerTriangular
+class MatrixPower
 {
   private:
     enum {
@@ -287,7 +295,7 @@
      * The class stores a reference to A, so it should not be changed
      * (or destroyed) before evaluation.
      */
-    explicit MatrixPowerTriangular(const MatrixType& A) : m_A(A), m_conditionNumber(0)
+    explicit MatrixPower(const MatrixType& A) : m_A(A), m_conditionNumber(0)
     { eigen_assert(A.rows() == A.cols()); }

     /**
@@ -297,8 +305,8 @@
      * \return The expression \f$ A^p \f$, where A is specified in the
      * constructor.
      */
-    const MatrixPowerRetval<MatrixPowerTriangular> operator()(RealScalar p)
-    { return MatrixPowerRetval<MatrixPowerTriangular>(*this, p); }
+    const MatrixPowerRetval<MatrixPower> operator()(RealScalar p)
+    { return MatrixPowerRetval<MatrixPower>(*this, p); }

     /**
      * \brief Compute the matrix power.
@@ -313,155 +321,6 @@
     Index cols() const { return m_A.cols(); }

   private:
-    typename MatrixType::Nested m_A;
-    MatrixType m_tmp;
-    RealScalar m_conditionNumber;
-    RealScalar modfAndInit(RealScalar, RealScalar*);
-
-    template<typename ResultType>
-    void computeIntPower(ResultType&, RealScalar);
-
-    template<typename ResultType>
-    void computeFracPower(ResultType&, RealScalar);
-};
-
-template<typename MatrixType>
-void MatrixPowerTriangular<MatrixType>::compute(MatrixType& res, RealScalar p)
-{
-  switch (cols()) {
-    case 0:
-      break;
-    case 1:
-      res(0,0) = std::pow(m_A.coeff(0,0), p);
-      break;
-    default:
-      RealScalar intpart, x = modfAndInit(p, &intpart);
-      computeIntPower(res, intpart);
-      computeFracPower(res, x);
-  }
-}
-
-template<typename MatrixType>
-typename MatrixPowerTriangular<MatrixType>::RealScalar
-MatrixPowerTriangular<MatrixType>::modfAndInit(RealScalar x, RealScalar* intpart)
-{
-  typedef Array< RealScalar, RowsAtCompileTime, 1, ColMajor, MaxRowsAtCompileTime > RealArray;
-
-  *intpart = std::floor(x);
-  RealScalar res = x - *intpart;
-
-  if (!m_conditionNumber && res) {
-    const RealArray absTdiag = m_A.diagonal().array().abs();
-    m_conditionNumber = absTdiag.maxCoeff() / absTdiag.minCoeff();
-  }
-
-  if (res>RealScalar(0.5) && res>(1-res)*std::pow(m_conditionNumber, res)) {
-    --res;
-    ++*intpart;
-  }
-  return res;
-}
-
-template<typename MatrixType>
-template<typename ResultType>
-void MatrixPowerTriangular<MatrixType>::computeIntPower(ResultType& res, RealScalar p)
-{
-  RealScalar pp = std::abs(p);
-
-  if (p<0)  m_tmp = m_A.template triangularView<Upper>().solve(MatrixType::Identity(rows(), cols()));
-  else      m_tmp = m_A.template triangularView<Upper>();
-
-  res = MatrixType::Identity(rows(), cols());
-  while (pp >= 1) {
-    if (std::fmod(pp, 2) >= 1)
-      res.template triangularView<Upper>() = m_tmp.template triangularView<Upper>() * res;
-    m_tmp.template triangularView<Upper>() = m_tmp.template triangularView<Upper>() * m_tmp;
-    pp /= 2;
-  }
-}
-
-template<typename MatrixType>
-template<typename ResultType>
-void MatrixPowerTriangular<MatrixType>::computeFracPower(ResultType& res, RealScalar p)
-{
-  if (p) {
-    eigen_assert(m_conditionNumber);
-    MatrixPowerAtomic<MatrixType>(m_A, p).compute(m_tmp);
-    res = m_tmp * res;
-  }
-}
-
-/**
- * \ingroup MatrixFunctions_Module
- *
- * \brief Class for computing matrix powers.
- *
- * \tparam MatrixType  type of the base, expected to be an instantiation
- * of the Matrix class template.
- *
- * This class is capable of computing real/complex matrices raised to
- * an arbitrary real power. Meanwhile, it saves the result of Schur
- * decomposition if an non-integral power has even been calculated.
- * Therefore, if you want to compute multiple (>= 2) matrix powers
- * for the same matrix, using the class directly is more efficient than
- * calling MatrixBase::pow().
- *
- * Example:
- * \include MatrixPower_optimal.cpp
- * Output: \verbinclude MatrixPower_optimal.out
- */
-template<typename MatrixType>
-class MatrixPower
-{
-  private:
-    enum {
-      RowsAtCompileTime = MatrixType::RowsAtCompileTime,
-      ColsAtCompileTime = MatrixType::ColsAtCompileTime,
-      Options = MatrixType::Options,
-      MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
-      MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
-    };
-    typedef typename MatrixType::Scalar Scalar;
-    typedef typename MatrixType::RealScalar RealScalar;
-    typedef typename MatrixType::Index Index;
-
-  public:
-    typedef MatrixType PlainObject;
-
-    /**
-     * \brief Constructor.
-     *
-     * \param[in] A  the base of the matrix power.
-     *
-     * The class stores a reference to A, so it should not be changed
-     * (or destroyed) before evaluation.
-     */
-    explicit MatrixPower(const MatrixType& A) : m_A(A), m_conditionNumber(0)
-    { eigen_assert(A.rows() == A.cols()); }
-
-    /**
-     * \brief Returns the matrix power.
-     *
-     * \param[in] p  exponent, a real scalar.
-     * \return The expression \f$ A^p \f$, where A is specified in the
-     * constructor.
-     */
-    const MatrixPowerRetval<MatrixPower> operator()(RealScalar p)
-    { return MatrixPowerRetval<MatrixPower>(*this, p); }
-
-    /**
-     * \brief Compute the matrix power.
-     *
-     * \param[in]  p    exponent, a real scalar.
-     * \param[out] res  \f$ A^p \f$ where A is specified in the
-     * constructor.
-     */
-    void compute(MatrixType& res, RealScalar p);
-
-    Index rows() const { return m_A.rows(); }
-    Index cols() const { return m_A.cols(); }
-
-  private:
     typedef std::complex<RealScalar> ComplexScalar;
     typedef Matrix< ComplexScalar, RowsAtCompileTime, ColsAtCompileTime, Options, MaxRowsAtCompileTime,
               MaxColsAtCompileTime > ComplexMatrix;


Don't allow to bind to non-wildcard addresses for AF_CONN.

--- KERN/netinet/sctp_usrreq.c
+++ KERN/netinet/sctp_usrreq.c
@@ -852,29 +852,32 @@
 }

 int
-sctpconn_bind(struct socket *so, struct sockaddr *addr) {
-	void *p = NULL;
-	struct sctp_inpcb *inp = NULL;
+sctpconn_bind(struct socket *so, struct sockaddr *addr)
+{
+	struct sockaddr_conn *sconn;
 	int error;

-	if (addr && addr->sa_family != AF_CONN) {
+	if ((addr != NULL) && (addr->sa_family != AF_CONN)) {
 		/* must be a v4 address! */
-		SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
+		SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
 		return (EINVAL);
 	}
 #if !defined(__Userspace_os_Linux) && !defined(__Userspace_os_Windows)
-	if (addr && (addr->sa_len != sizeof(struct sockaddr_conn))) {
-		SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
+	if ((addr != NULL) && (addr->sa_len != sizeof(struct sockaddr_conn))) {
+		SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
 		return (EINVAL);
 	}
 #endif
-	inp = (struct sctp_inpcb *)so->so_pcb;
-	if (inp == NULL) {
-		SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
+	sconn = (struct sockaddr_conn *)addr;
+	if ((sconn != NULL) && (sconn->sconn_addr != NULL)) {
+		SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
 		return (EINVAL);
 	}
-
-	error = sctp_inpcb_bind(so, addr, NULL, p);
+	if (so->so_pcb == NULL) {
+		SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
+		return (EINVAL);
+	}
+	error = sctp_inpcb_bind(so, addr, NULL, NULL);
 	return (error);
 }


wireless: support connection bitrate on FreeBSD

--- src/print_wireless_info.c
+++ src/print_wireless_info.c
@@ -97,7 +97,7 @@
     double frequency;
 } wireless_info_t;

-#ifdef __linux__
+#if defined(__linux__) || defined(__FreeBSD__)
 // Like iw_print_bitrate, but without the dependency on libiw.
 static void print_bitrate(char *buffer, int buflen, int bitrate, const char *format_bitrate) {
     const int kilo = 1e3;
@@ -120,7 +120,9 @@
     }
     snprintf(buffer, buflen, format_bitrate, rate / divisor, scale);
 }
-
+#endif
+
+#ifdef __linux__
 // Based on NetworkManager/src/platform/wifi/wifi-utils-nl80211.c
 static uint32_t nl80211_xbm_to_percent(int32_t xbm, int32_t divisor) {
 #define NOISE_FLOOR_DBM -90
@@ -408,6 +410,9 @@
         info->flags |= WIRELESS_INFO_FLAG_HAS_SIGNAL;
         info->noise_level = u.req.info[0].isi_noise;
         info->flags |= WIRELESS_INFO_FLAG_HAS_NOISE;
+        // isi_txmbps is specified in units of 500 Kbit/s
+        // Convert them to bit/s
+        info->bitrate = u.req.info[0].isi_txmbps * 500 * 1000;
     }

     return 1;
@@ -599,7 +604,7 @@

     snprintf(string_ip, STRING_SIZE, "%s", ip_address);

-#ifdef __linux__
+#if defined(__linux__) || defined(__FreeBSD__)
     char br_buffer[128];
     print_bitrate(br_buffer, sizeof(br_buffer), info.bitrate, format_bitrate);
 #endif


Ensure constants are externed

Ensure constants are externed

--- KFData/Store/KFDataStore.h
+++ KFData/Store/KFDataStore.h
@@ -16,8 +16,8 @@

  This notification will be fired on the main thread.
  */
-NSString * const KFDataManagedObjectContextWillReset;
-NSString * const KFDataManagedObjectContextDidReset;
+extern NSString * const KFDataManagedObjectContextWillReset;
+extern NSString * const KFDataManagedObjectContextDidReset;

 typedef NS_ENUM(NSUInteger, KFDataStoreConfigurationType) {


cast to pass compilation on Linux

cast to pass compilation on Linux

--- agent_config.c
+++ agent_config.c
@@ -529,7 +529,8 @@
     free_kvpair(kvs);

     if (settings.verbose > 1) {
-        fprintf(stderr, "conc failed config %llu\n", m->stat_config_fails);
+        fprintf(stderr, "conc failed config %llu\n",
+                (long long unsigned int)m->stat_config_fails);
     }
 }


more err handling during conflate reconfig

--- agent_config.c
+++ agent_config.c
@@ -137,7 +137,7 @@
         config.host = host; // "localhost"
         config.software   = "memscale";
         config.version    = VERSION;
-        config.save_path  = config_path; // "/tmp/memscale.cfg"
+        config.save_path  = config_path;
         config.userdata   = m;
         config.new_config = on_conflate_new_config;
         config.get_stats  = on_conflate_get_stats;
@@ -242,33 +242,48 @@
             char **servers   = get_key_values(kvs, pool_name);

             assert(pool_name);
-            assert(pool_port >= 0);
-            assert(servers);
-
-            // Create a config string that libmemcached likes,
-            // first by counting up buffer size needed.
-            //
-            int n = 0;
-
-            for (int j = 0; servers[j]; j++)
-                n = n + strlen(servers[j]) + 50;
-
-            char *config = calloc(n, 1);
-            if (config != NULL) {
-                for (int j = 0; servers[j]; j++) {
-                    char *cur = config + strlen(config); // TODO: O(N^2).
-
-                    if (j == 0)
-                        sprintf(cur, "%s", servers[j]);
-                    else
-                        sprintf(cur, ",%s", servers[j]);
+            assert(pool_port > 0);
+
+            if (servers != NULL &&
+                pool_port > 0) {
+                // Create a config string that libmemcached likes,
+                // first by counting up buffer size needed.
+                // See memcached_servers_parse().
+                //
+                int n = 0;
+
+                for (int j = 0; servers[j]; j++)
+                    n = n + strlen(servers[j]) + 50;
+
+                char *config = calloc(n, 1);
+                if (config != NULL) {
+                    for (int j = 0; servers[j]; j++) {
+                        char *cur = config + strlen(config); // TODO: O(N^2).
+
+                        if (j == 0)
+                            sprintf(cur, "%s", servers[j]);
+                        else
+                            sprintf(cur, ",%s", servers[j]);
+                    }
+
+                    cproxy_on_new_pool(m, pool_name, pool_port,
+                                       config, new_config_ver);
+
+                    free(config);
+                } else {
+                    if (settings.verbose > 1)
+                        fprintf(stderr, "oom on re-config malloc\n");;
+                    goto fail;
                 }
-
-                cproxy_on_new_pool(m, pool_name, pool_port,
-                                   config, new_config_ver);
-
-                free(config);
+            } else {
+                if (settings.verbose > 1)
+                    fprintf(stderr, "missing servers or port\n");
+                goto fail;
             }
+        } else {
+            if (settings.verbose > 1)
+                fprintf(stderr, "missing ports or bindings\n");
+            goto fail;
         }
     }


more trimstrdup's due to parser modifying input

--- agent_config.c
+++ agent_config.c
@@ -342,8 +342,11 @@
         proxy_behavior m_behavior = m->behavior;

         for (int k = 0; behavior_kvs[k]; k++) {
-            cproxy_parse_behavior_key_val_str(behavior_kvs[k],
-                                              &m_behavior);
+            char *bstr = trimstrdup(behavior_kvs[k]);
+            if (bstr != NULL) {
+                cproxy_parse_behavior_key_val_str(bstr, &m_behavior);
+                free(bstr);
+            }
         }

         m->behavior = m_behavior;


cleanup and format

cleanup and format

--- src/execute.c
+++ src/execute.c
@@ -578,7 +578,7 @@
             if(cmd->isBack){ //后台命令
                 fgPid = 0; //pid置0，为下一命令做准备
                 addJob(pid); //增加新的作业
-		sleep(1);
+				sleep(1);
                 kill(pid, SIGUSR1); //子进程发信号，表示作业已加入

                 //等待子进程输出
@@ -591,7 +591,7 @@
             }
 		}
     }else{ //命令不存在
-        printf("找不到命令 15%s\n", inputBuff);
+        printf("找不到命令 %s\n", inputBuff);
     }
 }

@@ -692,44 +692,54 @@
 	int i;
 	pid_t pid;
 	int pfd[2][2]={{0,1},{0,1}};
-
-	for (i = 0; i<cmd->num; ++i) {
-		if(strcmp(cmd->cmds[i]->args[0], "exit") == 0) exit(0);//exit
-		if (i == cmd->num - 1) {
-			pfd[1][1] = 1;
+
+	if ((pid = fork()) < 0) {
+		perror("fork failed");
+		exit(errno);
+    }
+    if (pid)
+	{
+		if (cmd->isBack) {
+			signal(SIGUSR1,setGoon);
+			while(goon == 0);
+			kill(getppid(), SIGUSR1);
 		}
-		else {
-			if (pipe(pfd[1]) == -1) {
-				perror("pipe failed");
+		for (i = 0; i<cmd->num; ++i) {
+			if(strcmp(cmd->cmds[i]->args[0], "exit") == 0) exit(0);//exit
+			if (i == cmd->num - 1) {
+				pfd[1][1] = 1;
+			}
+			else {
+				if (pipe(pfd[1]) == -1) {
+					perror("pipe failed");
+					exit(errno);
+				}
+			}
+			pid = fork();
+			if (pid < 0) {
+				perror("fork failed");
 				exit(errno);
+			} else if (pid) {
+				if (pfd[0][0] != 0) close(pfd[0][0]);
+				if (pfd[1][1] != 1) close(pfd[1][1]);
+				pfd[0][0]=pfd[1][0];
+			} else {
+				dup2(pfd[0][0],0);
+				dup2(pfd[1][1],1);
+				execSimpleCmd(cmd->cmds[i]);
+				close(pfd[0][0]);
+				close(pfd[1][1]);
+				exit(0);
 			}
 		}
-		pid = fork();
-		if (pid < 0) {
-			perror("fork failed");
-			exit(errno);
-		} else if (pid) {
-			if (pfd[0][0] != 0) close(pfd[0][0]);
-			if (pfd[1][1] != 1) close(pfd[1][1]);
-			pfd[0][0]=pfd[1][0];
-		} else {
-			dup2(pfd[0][0],0);
-			dup2(pfd[1][1],1);
-			execSimpleCmd(cmd->cmds[i]);
-			close(pfd[0][0]);
-			close(pfd[1][1]);
-			exit(0);
-		}
+		if (pfd[0][0] != 0) close(pfd[0][0]);
+		//wait for all child processes to exit
+		while ((pid=wait(NULL))>0);
+	} else {
+
 	}
-	if (pfd[0][0] != 0) close(pfd[0][0]);
-
-	//wait for all child processes to exit
-	while ((pid=wait(NULL))>0);
-
 	//free *cmds[]
-	for (i = 0; i<cmd->num; ++i) {
-		free(cmd->cmds[i]);
-	}
+	for (i = 0; i<cmd->num; ++i) free(cmd->cmds[i]);
 }
 /*******************************************************
                      命令执行接口


We don't need to crop at that point

We don't need to crop at that point

--- i3bar/src/xcb.c
+++ i3bar/src/xcb.c
@@ -124,16 +124,13 @@
  */
 void refresh_statusline() {
     int glyph_count;
-    uint32_t root_width = xcb_screens->width_in_pixels;
+
     if (statusline == NULL) {
         return;
     }

     xcb_char2b_t *text = (xcb_char2b_t*) convert_utf8_to_ucs2(statusline, &glyph_count);
     statusline_width = predict_text_extents(text, glyph_count);
-    int crop_x = MIN(0, ((int32_t)root_width) - ((int32_t)statusline_width));
-    printf("Cropping statusline with %d glyphs at x=%d\n", glyph_count, crop_x);
-    statusline_width = MIN((int32_t)statusline_width, (int32_t)root_width);

     xcb_free_pixmap(xcb_connection, statusline_pm);
     statusline_pm = xcb_generate_id(xcb_connection);