Add vcpu functions to libxl driver

Add vcpu functions to libxl driver

Hook the virtual cpu functions to their libxenlight counterparts

* src/libxl/libxl_driver.c: implements libxlDomainSetVcpus,
  libxlDomainGetVcpus, libxlDomainSetVcpusFlags,
  libxlDomainGetVcpusFlags and libxlDomainPinVcpu

--- src/libxl/libxl_driver.c
+++ src/libxl/libxl_driver.c
@@ -27,6 +27,7 @@
 #include <config.h>

 #include <sys/utsname.h>
+#include <math.h>
 #include <libxl.h>

 #include "internal.h"
@@ -1306,6 +1307,305 @@
     ret = 0;

   cleanup:
+    if (vm)
+        virDomainObjUnlock(vm);
+    return ret;
+}
+
+static int
+libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
+                         unsigned int flags)
+{
+    libxlDriverPrivatePtr driver = dom->conn->privateData;
+    libxlDomainObjPrivatePtr priv;
+    virDomainDefPtr def;
+    virDomainObjPtr vm;
+    libxl_cpumap map;
+    uint8_t *bitmask = NULL;
+    unsigned int maplen;
+    unsigned int i, pos;
+    int max;
+    int ret = -1;
+
+    virCheckFlags(VIR_DOMAIN_VCPU_LIVE |
+                  VIR_DOMAIN_VCPU_CONFIG |
+                  VIR_DOMAIN_VCPU_MAXIMUM, -1);
+
+    /* At least one of LIVE or CONFIG must be set.  MAXIMUM cannot be
+     * mixed with LIVE.  */
+    if ((flags & (VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_CONFIG)) == 0 ||
+        (flags & (VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_LIVE)) ==
+         (VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_LIVE)) {
+        libxlError(VIR_ERR_INVALID_ARG,
+                   _("invalid flag combination: (0x%x)"), flags);
+        return -1;
+    }
+
+    if (!nvcpus) {
+        libxlError(VIR_ERR_INVALID_ARG, _("nvcpus is zero"));
+        return -1;
+    }
+
+    libxlDriverLock(driver);
+    vm = virDomainFindByUUID(&driver->domains, dom->uuid);
+    libxlDriverUnlock(driver);
+
+    if (!vm) {
+        libxlError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
+        goto cleanup;
+    }
+
+    if (!virDomainObjIsActive(vm) && (flags & VIR_DOMAIN_VCPU_LIVE)) {
+        libxlError(VIR_ERR_OPERATION_INVALID, "%s",
+                   _("cannot set vcpus on an inactive domain"));
+        goto cleanup;
+    }
+
+    if (!vm->persistent && (flags & VIR_DOMAIN_VCPU_CONFIG)) {
+        libxlError(VIR_ERR_OPERATION_INVALID, "%s",
+                   _("cannot change persistent config of a transient domain"));
+        goto cleanup;
+    }
+
+    if ((max = libxlGetMaxVcpus(dom->conn, NULL)) < 0) {
+        libxlError(VIR_ERR_INTERNAL_ERROR, "%s",
+                   _("could not determine max vcpus for the domain"));
+        goto cleanup;
+    }
+
+    if (!(flags & VIR_DOMAIN_VCPU_MAXIMUM) && vm->def->maxvcpus < max) {
+        max = vm->def->maxvcpus;
+    }
+
+    if (nvcpus > max) {
+        libxlError(VIR_ERR_INVALID_ARG,
+                   _("requested vcpus is greater than max allowable"
+                     " vcpus for the domain: %d > %d"), nvcpus, max);
+        goto cleanup;
+    }
+
+    priv = vm->privateData;
+
+    if (!(def = virDomainObjGetPersistentDef(driver->caps, vm)))
+        goto cleanup;
+
+    maplen = (unsigned int) ceil((double) nvcpus / 8);
+    if (VIR_ALLOC_N(bitmask, maplen) < 0) {
+        virReportOOMError();
+        goto cleanup;
+    }
+
+    memset(bitmask, 0, maplen);
+    for (i = 0; i < nvcpus; ++i) {
+        pos = (unsigned int) floor((double) i / 8);
+        bitmask[pos] |= 1 << (i % 8);
+    }
+
+    map.size = maplen;
+    map.map = bitmask;
+
+    switch (flags) {
+    case VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_CONFIG:
+        def->maxvcpus = nvcpus;
+        if (nvcpus < def->vcpus)
+            def->vcpus = nvcpus;
+        ret = 0;
+        break;
+
+    case VIR_DOMAIN_VCPU_CONFIG:
+        def->vcpus = nvcpus;
+        break;
+
+    case VIR_DOMAIN_VCPU_LIVE:
+        if (libxl_set_vcpuonline(&priv->ctx, dom->id, &map) != 0) {
+            libxlError(VIR_ERR_INTERNAL_ERROR,
+                       _("Failed to set vcpus for domain '%d'"
+                         " with libxenlight"), dom->id);
+            goto cleanup;
+        }
+        break;
+
+    case VIR_DOMAIN_VCPU_LIVE | VIR_DOMAIN_VCPU_CONFIG:
+        if (libxl_set_vcpuonline(&priv->ctx, dom->id, &map) != 0) {
+            libxlError(VIR_ERR_INTERNAL_ERROR,
+                       _("Failed to set vcpus for domain '%d'"
+                         " with libxenlight"), dom->id);
+            goto cleanup;
+        }
+        def->vcpus = nvcpus;
+        break;
+    }
+
+    ret = 0;
+
+    if (flags & VIR_DOMAIN_VCPU_CONFIG)
+        ret = virDomainSaveConfig(driver->configDir, def);
+
+cleanup:
+    VIR_FREE(bitmask);
+     if (vm)
+        virDomainObjUnlock(vm);
+    return ret;
+}
+
+static int
+libxlDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus)
+{
+    return libxlDomainSetVcpusFlags(dom, nvcpus, VIR_DOMAIN_VCPU_LIVE);
+}
+
+static int
+libxlDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
+{
+    libxlDriverPrivatePtr driver = dom->conn->privateData;
+    virDomainObjPtr vm;
+    virDomainDefPtr def;
+    int ret = -1;
+
+    virCheckFlags(VIR_DOMAIN_VCPU_LIVE |
+                  VIR_DOMAIN_VCPU_CONFIG |
+                  VIR_DOMAIN_VCPU_MAXIMUM, -1);
+
+    /* Exactly one of LIVE or CONFIG must be set.  */
+    if (!(flags & VIR_DOMAIN_VCPU_LIVE) == !(flags & VIR_DOMAIN_VCPU_CONFIG)) {
+        libxlError(VIR_ERR_INVALID_ARG,
+                   _("invalid flag combination: (0x%x)"), flags);
+        return -1;
+    }
+
+    libxlDriverLock(driver);
+    vm = virDomainFindByUUID(&driver->domains, dom->uuid);
+    libxlDriverUnlock(driver);
+
+    if (!vm) {
+        libxlError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
+        goto cleanup;
+    }
+
+    if (flags & VIR_DOMAIN_VCPU_LIVE) {
+        if (!virDomainObjIsActive(vm)) {
+            libxlError(VIR_ERR_OPERATION_INVALID,
+                       "%s", _("Domain is not running"));
+            goto cleanup;
+        }
+        def = vm->def;
+    } else {
+        def = vm->newDef ? vm->newDef : vm->def;
+    }
+
+    ret = (flags & VIR_DOMAIN_VCPU_MAXIMUM) ? def->maxvcpus : def->vcpus;
+
+cleanup:
+    if (vm)
+        virDomainObjUnlock(vm);
+    return ret;
+}
+
+static int
+libxlDomainPinVcpu(virDomainPtr dom, unsigned int vcpu, unsigned char *cpumap,
+                   int maplen)
+{
+    libxlDriverPrivatePtr driver = dom->conn->privateData;
+    libxlDomainObjPrivatePtr priv;
+    virDomainObjPtr vm;
+    int ret = -1;
+    libxl_cpumap map;
+
+    libxlDriverLock(driver);
+    vm = virDomainFindByUUID(&driver->domains, dom->uuid);
+    libxlDriverUnlock(driver);
+
+    if (!vm) {
+        libxlError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
+        goto cleanup;
+    }
+
+    if (!virDomainObjIsActive(vm)) {
+        libxlError(VIR_ERR_OPERATION_INVALID, "%s",
+                   _("cannot pin vcpus on an inactive domain"));
+        goto cleanup;
+    }
+
+    priv = vm->privateData;
+
+    map.size = maplen;
+    map.map = cpumap;
+    if (libxl_set_vcpuaffinity(&priv->ctx, dom->id, vcpu, &map) != 0) {
+        libxlError(VIR_ERR_INTERNAL_ERROR,
+                   _("Failed to pin vcpu '%d' with libxenlight"), vcpu);
+        goto cleanup;
+    }
+    ret = 0;
+
+cleanup:
+    if (vm)
+        virDomainObjUnlock(vm);
+    return ret;
+}
+
+
+static int
+libxlDomainGetVcpus(virDomainPtr dom, virVcpuInfoPtr info, int maxinfo,
+                    unsigned char *cpumaps, int maplen)
+{
+    libxlDriverPrivatePtr driver = dom->conn->privateData;
+    libxlDomainObjPrivatePtr priv;
+    virDomainObjPtr vm;
+    int ret = -1;
+    libxl_vcpuinfo *vcpuinfo;
+    int maxcpu, hostcpus;
+    unsigned int i;
+    unsigned char *cpumap;
+
+    libxlDriverLock(driver);
+    vm = virDomainFindByUUID(&driver->domains, dom->uuid);
+    libxlDriverUnlock(driver);
+
+    if (!vm) {
+        libxlError(VIR_ERR_NO_DOMAIN, "%s", _("no domain with matching uuid"));
+        goto cleanup;
+    }
+
+    if (!virDomainObjIsActive(vm)) {
+        libxlError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running"));
+        goto cleanup;
+    }
+
+    priv = vm->privateData;
+    if ((vcpuinfo = libxl_list_vcpu(&priv->ctx, dom->id, &maxcpu,
+                                    &hostcpus)) == NULL) {
+        libxlError(VIR_ERR_INTERNAL_ERROR,
+                   _("Failed to list vcpus for domain '%d' with libxenlight"),
+                   dom->id);
+        goto cleanup;
+    }
+
+    if (cpumaps && maplen > 0)
+        memset(cpumaps, 0, maplen * maxinfo);
+    for (i = 0; i < maxcpu && i < maxinfo; ++i) {
+        info[i].number = vcpuinfo[i].vcpuid;
+        info[i].cpu = vcpuinfo[i].cpu;
+        info[i].cpuTime = vcpuinfo[i].vcpu_time;
+        if (vcpuinfo[i].running)
+            info[i].state = VIR_VCPU_RUNNING;
+        else if (vcpuinfo[i].blocked)
+            info[i].state = VIR_VCPU_BLOCKED;
+        else
+            info[i].state = VIR_VCPU_OFFLINE;
+
+        if (cpumaps && maplen > 0) {
+            cpumap = VIR_GET_CPUMAP(cpumaps, maplen, i);
+            memcpy(cpumap, vcpuinfo[i].cpumap.map,
+                   MIN(maplen, vcpuinfo[i].cpumap.size));
+        }
+
+        libxl_vcpuinfo_destroy(&vcpuinfo[i]);
+    }
+    VIR_FREE(vcpuinfo);
+
+    ret = maxinfo;
+
+cleanup:
     if (vm)
         virDomainObjUnlock(vm);
     return ret;
@@ -1685,11 +1985,11 @@
     NULL,                       /* domainSave */
     NULL,                       /* domainRestore */
     NULL,                       /* domainCoreDump */
-    NULL,                       /* domainSetVcpus */
-    NULL,                       /* domainSetVcpusFlags */
-    NULL,                       /* domainGetVcpusFlags */
-    NULL,                       /* domainPinVcpu */
-    NULL,                       /* domainGetVcpus */
+    libxlDomainSetVcpus,        /* domainSetVcpus */
+    libxlDomainSetVcpusFlags,   /* domainSetVcpusFlags */
+    libxlDomainGetVcpusFlags,   /* domainGetVcpusFlags */
+    libxlDomainPinVcpu,         /* domainPinVcpu */
+    libxlDomainGetVcpus,        /* domainGetVcpus */
     NULL,                       /* domainGetMaxVcpus */
     NULL,                       /* domainGetSecurityLabel */
     NULL,                       /* nodeGetSecurityModel */


get rid of mb_type_len

get rid of mb_type_len

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

--- libavcodec/mpeg12enc.c
+++ libavcodec/mpeg12enc.c
@@ -562,21 +562,19 @@
             }
             s->f_count++;
         } else{
-            static const int mb_type_len[4]={0,4,3,2}; //bak,for,bi
-
             if(s->mv_type == MV_TYPE_16X16){
                 if (cbp){    // With coded bloc pattern
                     if (s->dquant) {
                         if(s->mv_dir == MV_DIR_FORWARD)
                             put_mb_modes(s, 6, 3, 1, 0);
                         else
-                            put_mb_modes(s, mb_type_len[s->mv_dir]+3, 2, 1, 0);
+                            put_mb_modes(s, 8-s->mv_dir, 2, 1, 0);
                         put_qscale(s);
                     } else {
-                        put_mb_modes(s, mb_type_len[s->mv_dir], 3, 1, 0);
+                        put_mb_modes(s, 5-s->mv_dir, 3, 1, 0);
                     }
                 }else{    // No coded bloc pattern
-                    put_bits(&s->pb, mb_type_len[s->mv_dir], 2);
+                    put_bits(&s->pb, 5-s->mv_dir, 2);
                     if (!s->frame_pred_frame_dct)
                         put_bits(&s->pb, 2, 2); /* motion_type: frame */
                     s->qscale -= s->dquant;
@@ -604,13 +602,13 @@
                         if(s->mv_dir == MV_DIR_FORWARD)
                             put_mb_modes(s, 6, 3, 1, 1);
                         else
-                            put_mb_modes(s, mb_type_len[s->mv_dir]+3, 2, 1, 1);
+                            put_mb_modes(s, 8-s->mv_dir, 2, 1, 1);
                         put_qscale(s);
                     } else {
-                        put_mb_modes(s, mb_type_len[s->mv_dir], 3, 1, 1);
+                        put_mb_modes(s, 5-s->mv_dir, 3, 1, 1);
                     }
                 }else{    // No coded bloc pattern
-                    put_bits(&s->pb, mb_type_len[s->mv_dir], 2);
+                    put_bits(&s->pb, 5-s->mv_dir, 2);
                     put_bits(&s->pb, 2, 1); /* motion_type: field */
                     s->qscale -= s->dquant;
                 }


simplify HID descriptors

simplify HID descriptors

* Global items in HID descriptors can be reused if they are not changed
  from the last time they were used. See `src/usb/util/usb_hid.h` for a
  list of global items.

--- src/usb/hid_descriptors.c
+++ src/usb/hid_descriptors.c
@@ -33,10 +33,12 @@
         HID_USAGE_MINIMUM(1)   , KC_NONE,
         HID_USAGE_MAXIMUM(1)   , KC_RIGHT_GUI,
         HID_REPORT_COUNT(1)    , 0x06,
-        HID_REPORT_SIZE(1)     , 0x08,
+        // HID_REPORT_SIZE(1)     , 0x08, // Reuse global item
         HID_INPUT(1)           , IOF_DATA | IOF_ARRAY | IOF_ABSOLUTE,
         // LEDs
         HID_USAGE_PAGE(1)      , HID_USAGE_PAGE_LEDS,
+        HID_LOGICAL_MINIMUM(1) , 0x00,
+        HID_LOGICAL_MAXIMUM(1) , 0x01,
         HID_USAGE_MINIMUM(1)   , HID_LED_Num_Lock,
         HID_USAGE_MAXIMUM(1)   , HID_LED_Kana,
         HID_REPORT_COUNT(1)    , 0x05,
@@ -63,24 +65,31 @@
         HID_REPORT_SIZE(1)     , 0x01,
         HID_INPUT(1)           , IOF_DATA | IOF_VARIABLE | IOF_ABSOLUTE,
         // keycodes
-        HID_LOGICAL_MINIMUM(1) , 0,
-        HID_LOGICAL_MAXIMUM(1) , 1,
+        // HID_LOGICAL_MINIMUM(1) , 0, // Reuse global item
+        // HID_LOGICAL_MAXIMUM(1) , 1, // Reuse global item
         HID_USAGE_MINIMUM(1)   , 0x00,
         HID_USAGE_MAXIMUM(1)   , 0xdf,
         HID_REPORT_COUNT(1)    , 0xe0,
-        HID_REPORT_SIZE(1)     , 0x01,
-        HID_INPUT(1)           , IOF_DATA | IOF_VARIABLE | IOF_ABSOLUTE,
+        // HID_REPORT_SIZE(1)     , 0x01, // Reuse global item
+        HID_INPUT(1)           , IOF_DATA | IOF_VARIABLE | IOF_ABSOLUTE,
+#if 0
+        // TODO/Note: This part of the descriptor is unnecessary unless the
+        // device is compiled without the 6KRO/boot keyboard report since the
+        // boot keyboard report already stores the LED state from the host.
         // LEDs
         HID_USAGE_PAGE(1)      , HID_USAGE_PAGE_LEDS,
-        HID_REPORT_COUNT(1)    , 0x05,
-        HID_REPORT_SIZE(1)     , 0x01,
+        HID_LOGICAL_MINIMUM(1) , 0x00,
+        HID_LOGICAL_MAXIMUM(1) , 0x01,
         HID_USAGE_MINIMUM(1)   , HID_LED_Num_Lock,
         HID_USAGE_MAXIMUM(1)   , HID_LED_Kana,
+        HID_REPORT_COUNT(1)    , 0x05,
+        // HID_REPORT_SIZE(1)     , 0x01, // Reuse global item
         HID_OUTPUT(1)          , IOF_DATA | IOF_VARIABLE | IOF_ABSOLUTE,
         // leftover
         HID_REPORT_COUNT(1)    , 0x01,
         HID_REPORT_SIZE(1)     , 0x03,
         HID_OUTPUT(1)          , IOF_CONSTANT | IOF_VARIABLE | IOF_ABSOLUTE,
+#endif
     HID_END_COLLECTION(0),
 };
 ROM const uint8_t sizeof_hid_desc_nkro_keyboard = sizeof(hid_desc_nkro_keyboard);
@@ -94,37 +103,37 @@
         HID_USAGE(1), HID_USAGE_POINTER,
         HID_COLLECTION(1), HID_COLLECTION_PHYSICAL,
             // mouse buttons
-            HID_USAGE_PAGE(1), HID_USAGE_PAGE_BUTTON,
-            HID_USAGE_MINIMUM(1), 1,
-            HID_USAGE_MAXIMUM(1), 16,
-            HID_LOGICAL_MINIMUM(1), 0,
-            HID_LOGICAL_MAXIMUM(1), 1,
-            HID_REPORT_SIZE(1), 1,
-            HID_REPORT_COUNT(1), 16,
-            HID_INPUT(1), IOF_DATA | IOF_VARIABLE | IOF_ABSOLUTE,
+            HID_USAGE_PAGE(1)      , HID_USAGE_PAGE_BUTTON,
+            HID_LOGICAL_MINIMUM(1) , 0,
+            HID_LOGICAL_MAXIMUM(1) , 1,
+            HID_USAGE_MINIMUM(1)   , 1,
+            HID_USAGE_MAXIMUM(1)   , 16,
+            HID_REPORT_COUNT(1)    , 16,
+            HID_REPORT_SIZE(1)     , 1,
+            HID_INPUT(1)           , IOF_DATA | IOF_VARIABLE | IOF_ABSOLUTE,
             // mouse X, Y
-            HID_USAGE_PAGE(1), HID_USAGE_PAGE_GENERIC_DESKTOP,
-            HID_USAGE(1), HID_USAGE_X,
-            HID_USAGE(1), HID_USAGE_Y,
-            HID_LOGICAL_MINIMUM(2), DB16(INT16_MIN),
-            HID_LOGICAL_MAXIMUM(2), DB16(INT16_MAX),
-            HID_REPORT_COUNT(1), 2,
-            HID_REPORT_SIZE(1), 16,
-            HID_INPUT(1), IOF_DATA | IOF_VARIABLE | IOF_RELATIVE,
+            HID_USAGE_PAGE(1)      , HID_USAGE_PAGE_GENERIC_DESKTOP,
+            HID_USAGE(1)           , HID_USAGE_X,
+            HID_USAGE(1)           , HID_USAGE_Y,
+            HID_LOGICAL_MINIMUM(2) , DB16(INT16_MIN),
+            HID_LOGICAL_MAXIMUM(2) , DB16(INT16_MAX),
+            HID_REPORT_COUNT(1)    , 2,
+            HID_REPORT_SIZE(1)     , 16,
+            HID_INPUT(1)           , IOF_DATA | IOF_VARIABLE | IOF_RELATIVE,
             // mouse wheel
-            HID_USAGE(1), HID_USAGE_WHEEL,
-            HID_LOGICAL_MINIMUM(1), DB8(INT8_MIN),
-            HID_LOGICAL_MAXIMUM(1), DB8(INT8_MAX),
-            HID_REPORT_COUNT(1), 1,
-            HID_REPORT_SIZE(1), 8,
-            HID_INPUT(1), IOF_DATA | IOF_VARIABLE | IOF_RELATIVE,
+            HID_USAGE(1)           , HID_USAGE_WHEEL,
+            HID_LOGICAL_MINIMUM(1) , DB8(INT8_MIN),
+            HID_LOGICAL_MAXIMUM(1) , DB8(INT8_MAX),
+            HID_REPORT_COUNT(1)    , 1,
+            HID_REPORT_SIZE(1)     , 8,
+            HID_INPUT(1)           , IOF_DATA | IOF_VARIABLE | IOF_RELATIVE,
             // mouse pan wheel
-            HID_USAGE_PAGE(1), HID_USAGE_PAGE_CONSUMER,
-            HID_USAGE(2), DB16(HID_CONSUMER_AC_PAN),
-            HID_LOGICAL_MINIMUM(1), DB8(INT8_MIN),
-            HID_LOGICAL_MAXIMUM(1), DB8(INT8_MAX),
-            HID_REPORT_COUNT(1), 1,
-            HID_REPORT_SIZE(1), 8,
+            HID_USAGE_PAGE(1)      , HID_USAGE_PAGE_CONSUMER,
+            HID_USAGE(2)           , DB16(HID_CONSUMER_AC_PAN),
+            // HID_LOGICAL_MINIMUM(1) , DB8(INT8_MIN), // Reuse global item
+            // HID_LOGICAL_MAXIMUM(1) , DB8(INT8_MAX), // Reuse global item
+            // HID_REPORT_COUNT(1)    , 1, // Reuse global item
+            // HID_REPORT_SIZE(1)     , 8, // Reuse global item
             HID_INPUT(1), IOF_DATA | IOF_VARIABLE | IOF_RELATIVE,
         HID_END_COLLECTION(0),
     HID_END_COLLECTION(0),
@@ -136,26 +145,26 @@
     HID_USAGE(1), HID_USAGE_SYSTEM_CONTROL, /* System Control */
     HID_COLLECTION(1), HID_COLLECTION_APPLICATION,
         HID_REPORT_ID(1), REPORT_ID_SYSTEM,
-        HID_LOGICAL_MINIMUM(1), HID_DESKTOP_System_Control,
-        HID_LOGICAL_MAXIMUM(1), HID_DESKTOP_System_Display_LCD_Autoscale,
-        HID_USAGE_MINIMUM(1), HID_DESKTOP_System_Control,
-        HID_USAGE_MAXIMUM(1), HID_DESKTOP_System_Display_LCD_Autoscale,
-        HID_REPORT_SIZE(1), 8,
-        HID_REPORT_COUNT(1), 1,
-        HID_INPUT(1), IOF_DATA | IOF_ARRAY | IOF_ABSOLUTE,
+        HID_LOGICAL_MINIMUM(1) , HID_DESKTOP_System_Control,
+        HID_LOGICAL_MAXIMUM(1) , HID_DESKTOP_System_Display_LCD_Autoscale,
+        HID_USAGE_MINIMUM(1)   , HID_DESKTOP_System_Control,
+        HID_USAGE_MAXIMUM(1)   , HID_DESKTOP_System_Display_LCD_Autoscale,
+        HID_REPORT_SIZE(1)     , 8,
+        HID_REPORT_COUNT(1)    , 1,
+        HID_INPUT(1)           , IOF_DATA | IOF_ARRAY | IOF_ABSOLUTE,
     HID_END_COLLECTION(0),

     HID_USAGE_PAGE(1), HID_USAGE_PAGE_CONSUMER,
     HID_USAGE(1), HID_CONSUMER_CONSUMER_CONTROL,
     HID_COLLECTION(1), HID_COLLECTION_APPLICATION,
-        HID_REPORT_ID(1), REPORT_ID_CONSUMER,
-        HID_LOGICAL_MINIMUM(2), DB16(HID_CONSUMER_PLUS_10),
-        HID_LOGICAL_MAXIMUM(2), DB16(HID_CONSUMER_AC_DISTRIBUTE_VERTICALLY),
-        HID_USAGE_MINIMUM(2), DB16(HID_CONSUMER_PLUS_10),
-        HID_USAGE_MAXIMUM(2), DB16(HID_CONSUMER_AC_DISTRIBUTE_VERTICALLY),
-        HID_REPORT_SIZE(1), 16,
-        HID_REPORT_COUNT(1), 1,
-        HID_INPUT(1), IOF_DATA | IOF_ARRAY | IOF_ABSOLUTE,
+        HID_REPORT_ID(1)       , REPORT_ID_CONSUMER,
+        HID_LOGICAL_MINIMUM(2) , DB16(HID_CONSUMER_PLUS_10),
+        HID_LOGICAL_MAXIMUM(2) , DB16(HID_CONSUMER_AC_DISTRIBUTE_VERTICALLY),
+        HID_USAGE_MINIMUM(2)   , DB16(HID_CONSUMER_PLUS_10),
+        HID_USAGE_MAXIMUM(2)   , DB16(HID_CONSUMER_AC_DISTRIBUTE_VERTICALLY),
+        HID_REPORT_SIZE(1)     , 16,
+        // HID_REPORT_COUNT(1)    , 1, // Resuse global item
+        HID_INPUT(1)           , IOF_DATA | IOF_ARRAY | IOF_ABSOLUTE,
     HID_END_COLLECTION(0),
 };
 ROM const uint8_t sizeof_hid_desc_media = sizeof(hid_desc_media);
@@ -166,28 +175,27 @@
 #define HID_USAGE_VENDOR_1 0x80+1
 #define HID_USAGE_VENDOR_2 0x80+2

+// Note: For HID_LOGICAL_MAXIMUM=255, we use the value 0x00ff instead of 0xff.
+// This is because the integers used in logical min/max values are assumed
+// to be in 2's complement notation. So, 0xff == -1, while 0x00ff == 255.
 ROM const uint8_t hid_desc_vendor[] = {
     HID_USAGE_PAGE(2), DB16(HID_USAGE_PAGE_VENDOR_START),
     HID_USAGE(1), HID_USAGE_VENDOR_0,
     HID_COLLECTION(1), HID_COLLECTION_VENDOR,
-        HID_LOGICAL_MINIMUM(1), DB8(0),
-        /* HID_LOGICAL_MAXIMUM(1), DB8(UINT8_MAX), */
-        HID_LOGICAL_MAXIMUM(2), 0xff, 0x00,
-        HID_REPORT_SIZE(1), 8,
-        HID_REPORT_COUNT(1), 64,
-
-        HID_USAGE(1), HID_USAGE_VENDOR_1,
-        HID_INPUT(1), IOF_DATA | IOF_VARIABLE | IOF_ABSOLUTE,
-
-        HID_LOGICAL_MINIMUM(1), DB8(0),
-        /* HID_LOGICAL_MAXIMUM(1), DB8(UINT8_MAX), */
-        HID_LOGICAL_MAXIMUM(2), 0xff, 0x00,
-        HID_REPORT_SIZE(1), 8,
-        HID_REPORT_COUNT(1), 64,
-
-        HID_USAGE(1), HID_USAGE_VENDOR_2,
-        HID_OUTPUT(1), IOF_DATA | IOF_VARIABLE | IOF_ABSOLUTE,
-
+        // Vendor input usage:
+        HID_LOGICAL_MINIMUM(1) , DB8(0),
+        HID_LOGICAL_MAXIMUM(2) , DB16(0x00ff),
+        HID_REPORT_SIZE(1)     , 8,
+        HID_REPORT_COUNT(1)    , 64,
+        HID_USAGE(1)           , HID_USAGE_VENDOR_1,
+        HID_INPUT(1)           , IOF_DATA | IOF_VARIABLE | IOF_ABSOLUTE,
+        // Vendor output usage:
+        // HID_LOGICAL_MINIMUM(1) , DB8(0), // Reuse global item
+        // HID_LOGICAL_MAXIMUM(2) , DB16(0x00FF), // Reuse global item
+        // HID_REPORT_SIZE(1)     , 8, // Reuse global item
+        // HID_REPORT_COUNT(1)    , 64, // Reuse global item
+        HID_USAGE(1)           , HID_USAGE_VENDOR_2,
+        HID_OUTPUT(1)          , IOF_DATA | IOF_VARIABLE | IOF_ABSOLUTE,
     HID_END_COLLECTION(0),
 };


Reorganize generic gc val for 32-bits (#203).

This is a bit ugly, because a more proper solution is to not have the
generic gc val cast. That's an issue that I'll tackle later (when I do
functions deref-ing their value at exit).

--- src/lily_value_structs.h
+++ src/lily_value_structs.h
@@ -164,16 +164,23 @@
     uint32_t refcount;
     uint32_t line_num;

+    uint32_t pad;
+
+    uint16_t num_upvalues;
+
+    /* This is how many registers that this function uses. */
+    uint16_t reg_count;
+
+    /* The module that this function was created within. */
+    struct lily_module_entry_ *module;
+
+    struct lily_gc_entry_ *gc_entry;
+
     /* The name of the class that this function belongs to OR "". */
     const char *class_name;

     /* The name of this function, for use by debug and stack trace. */
     const char *trace_name;
-
-    struct lily_gc_entry_ *gc_entry;
-
-    /* The module that this function was created within. */
-    struct lily_module_entry_ *module;

     /* Foreign functions only. To determine if a function is foreign, simply
        check 'foreign_func == NULL'. */
@@ -181,13 +188,6 @@

     /* Here's where the function's code is stored. */
     uint16_t *code;
-
-    uint32_t pad;
-
-    uint16_t num_upvalues;
-
-    /* This is how many registers that this function uses. */
-    uint16_t reg_count;

     union {
         struct lily_value_ **upvalues;
@@ -216,7 +216,7 @@
     uint32_t refcount;
     uint32_t pad;
     uint64_t pad2;
-    uint64_t pad3;
+    void *pad3;
     struct lily_gc_entry_ *gc_entry;
 } lily_generic_gc_val;


convert only needed matrixes in convert_matrix() (mjpeg calls it for every frame)

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

--- libavcodec/mpegvideo.c
+++ libavcodec/mpegvideo.c
@@ -80,11 +80,11 @@
 int motion_estimation_method = ME_EPZS;

 static void convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[64], uint16_t (*qmat16_bias)[64],
-                           const UINT16 *quant_matrix, int bias)
+                           const UINT16 *quant_matrix, int bias, int qmin, int qmax)
 {
     int qscale;

-    for(qscale=1; qscale<32; qscale++){
+    for(qscale=qmin; qscale<=qmax; qscale++){
         int i;
         if (s->fdct == ff_jpeg_fdct_islow) {
             for(i=0;i<64;i++) {
@@ -680,9 +680,9 @@
     /* for mjpeg, we do include qscale in the matrix */
     if (s->out_format != FMT_MJPEG) {
         convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16, s->q_intra_matrix16_bias,
-                       s->intra_matrix, s->intra_quant_bias);
+                       s->intra_matrix, s->intra_quant_bias, 1, 31);
         convert_matrix(s, s->q_inter_matrix, s->q_inter_matrix16, s->q_inter_matrix16_bias,
-                       s->inter_matrix, s->inter_quant_bias);
+                       s->inter_matrix, s->inter_quant_bias, 1, 31);
     }

     if(ff_rate_control_init(s) < 0)
@@ -2462,7 +2462,7 @@
             s->intra_matrix[j] = CLAMP_TO_8BIT((ff_mpeg1_default_intra_matrix[i] * s->qscale) >> 3);
         }
         convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16,
-                       s->q_intra_matrix16_bias, s->intra_matrix, s->intra_quant_bias);
+                       s->q_intra_matrix16_bias, s->intra_matrix, s->intra_quant_bias, 8, 8);
     }

     s->last_bits= get_bit_count(&s->pb);


util: avoid race in releasing the GSource in event thread

There is a race between  vir_event_thread_finalize and
virEventThreadWorker in releasing the last reference on
the GMainContext. If virEventThreadDataFree() runs after
vir_event_thread_finalize releases its reference, then
it will release the last reference on the GMainContext.
As a result g_autoptr cleanup on the GSource will access
free'd memory.

The race can be seen in non-deterministic crashes of the
virt-run-qemu program during its shutdown, but could
also likely affect the main libvirtd QEMU driver:

  Thread 2 (Thread 0x7f508ffff700 (LWP 222813)):
  #0  0x00007f509c8e26b0 in malloc_consolidate (av=av@entry=0x7f5088000020) at malloc.c:4488
  #1  0x00007f509c8e4b08 in _int_malloc (av=av@entry=0x7f5088000020, bytes=bytes@entry=2048) at malloc.c:3711
  #2  0x00007f509c8e6412 in __GI___libc_malloc (bytes=2048) at malloc.c:3073
  #3  0x00007f509d6e925e in g_realloc (mem=0x0, n_bytes=2048) at gmem.c:164
  #4  0x00007f509d705a57 in g_string_maybe_expand (string=string@entry=0x7f5088001f20, len=len@entry=1024) at gstring.c:102
  #5  0x00007f509d705ab6 in g_string_sized_new (dfl_size=dfl_size@entry=1024) at gstring.c:127
  #6  0x00007f509d708c5e in g_test_log_dump (len=<synthetic pointer>, msg=<synthetic pointer>) at gtestutils.c:3330
  #7  0x00007f509d708c5e in g_test_log
      (lbit=G_TEST_LOG_ERROR, string1=0x7f508800fcb0 "GLib:ERROR:ghash.c:377:g_hash_table_lookup_node: assertion failed: (hash_table->ref_count > 0)", string2=<optimized out>, n_args=0, largs=0x0) at gtestutils.c:975
  #8  0x00007f509d70af2a in g_assertion_message
      (domain=<optimized out>, file=0x7f509d7324a2 "ghash.c", line=<optimized out>, func=0x7f509d732750 <__func__.11348> "g_hash_table_lookup_node", message=<optimized out>)
      at gtestutils.c:2504
  #9  0x00007f509d70af8e in g_assertion_message_expr
      (domain=domain@entry=0x7f509d72d76e "GLib", file=file@entry=0x7f509d7324a2 "ghash.c", line=line@entry=377, func=func@entry=0x7f509d732750 <__func__.11348> "g_hash_table_lookup_node", expr=expr@entry=0x7f509d732488 "hash_table->ref_count > 0") at gtestutils.c:2555
  #10 0x00007f509d6d197e in g_hash_table_lookup_node (hash_table=0x55b70ace1760, key=<optimized out>, hash_return=<synthetic pointer>) at ghash.c:377
  #11 0x00007f509d6d197e in g_hash_table_lookup_node (hash_return=<synthetic pointer>, key=<optimized out>, hash_table=0x55b70ace1760) at ghash.c:361
  #12 0x00007f509d6d197e in g_hash_table_remove_internal (hash_table=0x55b70ace1760, key=<optimized out>, notify=1) at ghash.c:1371
  #13 0x00007f509d6e0664 in g_source_unref_internal (source=0x7f5088000b60, context=0x55b70ad87e00, have_lock=0) at gmain.c:2103
  #14 0x00007f509d6e1f64 in g_source_unref (source=<optimized out>) at gmain.c:2176
  #15 0x00007f50a08ff84c in glib_autoptr_cleanup_GSource (_ptr=<synthetic pointer>) at /usr/include/glib-2.0/glib/glib-autocleanups.h:58
  #16 0x00007f50a08ff84c in virEventThreadWorker (opaque=0x55b70ad87f80) at ../../src/util/vireventthread.c:114
  #17 0x00007f509d70bd4a in g_thread_proxy (data=0x55b70acf3850) at gthread.c:784
  #18 0x00007f509d04714a in start_thread (arg=<optimized out>) at pthread_create.c:479
  #19 0x00007f509c95cf23 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

  Thread 1 (Thread 0x7f50a1380c00 (LWP 222802)):
  #0  0x00007f509c8977ff in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
  #1  0x00007f509c881c35 in __GI_abort () at abort.c:79
  #2  0x00007f509d72a823 in g_mutex_clear (mutex=0x55b70ad87e00) at gthread-posix.c:1307
  #3  0x00007f509d72a823 in g_mutex_clear (mutex=mutex@entry=0x55b70ad87e00) at gthread-posix.c:1302
  #4  0x00007f509d6e1a84 in g_main_context_unref (context=0x55b70ad87e00) at gmain.c:582
  #5  0x00007f509d6e1a84 in g_main_context_unref (context=0x55b70ad87e00) at gmain.c:541
  #6  0x00007f50a08ffabb in vir_event_thread_finalize (object=0x55b70ad83180 [virEventThread]) at ../../src/util/vireventthread.c:50
  #7  0x00007f509d9c48a9 in g_object_unref (_object=<optimized out>) at gobject.c:3340
  #8  0x00007f509d9c48a9 in g_object_unref (_object=0x55b70ad83180) at gobject.c:3232

  #9  0x00007f509583d311 in qemuProcessQMPFree (proc=proc@entry=0x55b70ad87b90) at ../../src/qemu/qemu_process.c:8355
  #10 0x00007f5095790f58 in virQEMUCapsInitQMPSingle
      (qemuCaps=qemuCaps@entry=0x55b70ad88010, libDir=libDir@entry=0x55b70ad049e0 "/tmp/virt-qemu-run-VZC9N0/lib/qemu", runUid=runUid@entry=107, runGid=runGid@entry=107, onlyTCG=onlyTCG@entry=false) at ../../src/qemu/qemu_capabilities.c:5409
  #11 0x00007f509579108f in virQEMUCapsInitQMP (runGid=107, runUid=107, libDir=0x55b70ad049e0 "/tmp/virt-qemu-run-VZC9N0/lib/qemu", qemuCaps=0x55b70ad88010)
      at ../../src/qemu/qemu_capabilities.c:5420
  #12 0x00007f509579108f in virQEMUCapsNewForBinaryInternal
      (hostArch=VIR_ARCH_X86_64, binary=binary@entry=0x55b70ad7dc40 "/usr/libexec/qemu-kvm", libDir=0x55b70ad049e0 "/tmp/virt-qemu-run-VZC9N0/lib/qemu", runUid=107, runGid=107, hostCPUSignature=0x55b70ad01320 "GenuineIntel, Intel(R) Xeon(R) Silver 4210 CPU @ 2.20GHz, family: 6, model: 85, stepping: 7", microcodeVersion=83898113, kernelVersion=0x55b70ad00d60 "4.18.0-211.el8.x86_64 #1 SMP Thu Jun 4 08:08:16 UTC 2020") at ../../src/qemu/qemu_capabilities.c:5472
  #13 0x00007f5095791373 in virQEMUCapsNewData (binary=0x55b70ad7dc40 "/usr/libexec/qemu-kvm", privData=0x55b70ad5b8f0) at ../../src/qemu/qemu_capabilities.c:5505
  #14 0x00007f50a09a32b1 in virFileCacheNewData (name=0x55b70ad7dc40 "/usr/libexec/qemu-kvm", cache=<optimized out>) at ../../src/util/virfilecache.c:208
  #15 0x00007f50a09a32b1 in virFileCacheValidate (cache=cache@entry=0x55b70ad5c030, name=name@entry=0x55b70ad7dc40 "/usr/libexec/qemu-kvm", data=data@entry=0x7ffca39ffd90)
      at ../../src/util/virfilecache.c:277
  #16 0x00007f50a09a37ea in virFileCacheLookup (cache=cache@entry=0x55b70ad5c030, name=name@entry=0x55b70ad7dc40 "/usr/libexec/qemu-kvm") at ../../src/util/virfilecache.c:310
  #17 0x00007f5095791627 in virQEMUCapsCacheLookup (cache=0x55b70ad5c030, binary=0x55b70ad7dc40 "/usr/libexec/qemu-kvm") at ../../src/qemu/qemu_capabilities.c:5647
  #18 0x00007f50957c34c3 in qemuDomainPostParseDataAlloc (def=<optimized out>, parseFlags=<optimized out>, opaque=<optimized out>, parseOpaque=0x7ffca39ffe18)
      at ../../src/qemu/qemu_domain.c:5470
  #19 0x00007f50a0a34051 in virDomainDefPostParse
      (def=def@entry=0x55b70ad7d200, parseFlags=parseFlags@entry=258, xmlopt=xmlopt@entry=0x55b70ad5d010, parseOpaque=parseOpaque@entry=0x0)
      at ../../src/conf/domain_conf.c:5970
  #20 0x00007f50a0a464bb in virDomainDefParseNode
      (xml=xml@entry=0x55b70aced140, root=root@entry=0x55b70ad5f020, xmlopt=xmlopt@entry=0x55b70ad5d010, parseOpaque=parseOpaque@entry=0x0, flags=flags@entry=258)
      at ../../src/conf/domain_conf.c:22520
  #21 0x00007f50a0a4669b in virDomainDefParse
      (xmlStr=xmlStr@entry=0x55b70ad5f9e0 "<domain type='kvm'>\n  <name>83</name>\n  <uuid>9350639d-1c8a-4f51-a4a6-4eaf8eabe83e</uuid>\n  <metadata>\n    <libosinfo:libosinfo xmlns:libosinfo=\"http://libosinfo.org/xmlns/libvirt/domain/1.0\">\n      <"..., filename=filename@entry=0x0, xmlopt=0x55b70ad5d010, parseOpaque=parseOpaque@entry=0x0, flags=flags@entry=258) at ../../src/conf/domain_conf.c:22474
  #22 0x00007f50a0a467ae in virDomainDefParseString
      (xmlStr=xmlStr@entry=0x55b70ad5f9e0 "<domain type='kvm'>\n  <name>83</name>\n  <uuid>9350639d-1c8a-4f51-a4a6-4eaf8eabe83e</uuid>\n  <metadata>\n    <libosinfo:libosinfo xmlns:libosinfo=\"http://libosinfo.org/xmlns/libvirt/domain/1.0\">\n      <"..., xmlopt=<optimized out>, parseOpaque=parseOpaque@entry=0x0, flags=flags@entry=258)
      at ../../src/conf/domain_conf.c:22488
  #23 0x00007f50958ce112 in qemuDomainCreateXML
      (conn=0x55b70acf9090, xml=0x55b70ad5f9e0 "<domain type='kvm'>\n  <name>83</name>\n  <uuid>9350639d-1c8a-4f51-a4a6-4eaf8eabe83e</uuid>\n  <metadata>\n    <libosinfo:libosinfo xmlns:libosinfo=\"http://libosinfo.org/xmlns/libvirt/domain/1.0\">\n      <"..., flags=0) at ../../src/qemu/qemu_driver.c:1744
  #24 0x00007f50a0c268ac in virDomainCreateXML
      (conn=0x55b70acf9090, xmlDesc=0x55b70ad5f9e0 "<domain type='kvm'>\n  <name>83</name>\n  <uuid>9350639d-1c8a-4f51-a4a6-4eaf8eabe83e</uuid>\n  <metadata>\n    <libosinfo:libosinfo xmlns:libosinfo=\"http://libosinfo.org/xmlns/libvirt/domain/1.0\">\n      <"..., flags=0) at ../../src/libvirt-domain.c:176
  #25 0x000055b709547e7b in main (argc=<optimized out>, argv=<optimized out>) at ../../src/qemu/qemu_shim.c:289

The solution is to explicitly unref the GSource at a safe time instead
of letting g_autoptr unref it when leaving scope.

Reviewed-by: Michal Privoznik <83d82aaba2eed257f4814b0c239c260c4caaadf0@redhat.com>
Signed-off-by: Daniel P. Berrangé <bb938cf255e055ff3507f2627d214e8e62118fcf@redhat.com>

--- src/util/vireventthread.c
+++ src/util/vireventthread.c
@@ -111,7 +111,11 @@
 virEventThreadWorker(void *opaque)
 {
     virEventThreadData *data = opaque;
-    g_autoptr(GSource) running = g_idle_source_new();
+    /*
+     * Do NOT use g_autoptr on this. We need to unref it
+     * before the GMainContext is unrefed
+     */
+    GSource *running = g_idle_source_new();

     g_source_set_callback(running, virEventThreadNotify, data, NULL);

@@ -119,6 +123,7 @@

     g_main_loop_run(data->loop);

+    g_source_unref(running);
     virEventThreadDataFree(data);

     return NULL;


revert  r8469 (increase bits for non default highprecision mode)

it causes overflows with linear interpolated filters coefficients

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

--- libavcodec/resample2.c
+++ libavcodec/resample2.c
@@ -40,7 +40,7 @@
 #define FELEM_MIN INT16_MIN
 #define WINDOW_TYPE 9
 #elif !defined(CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE)
-#define FILTER_SHIFT 30
+#define FILTER_SHIFT 22

 #define FELEM int32_t
 #define FELEM2 int64_t


power: fix environment detection

power: fix environment detection

Anything coming from sysfs has a newline at the end. Cut it off before
comparing the strings.

Fixes: 20ab67608a39 ("power: add environment capability probing")

Signed-off-by: Anatoly Burakov <814e00d8f6e4e81b7ccc7e3e5a0bfec0078f0203@intel.com>
Acked-by: David Hunt <763be7c8e0ad91e03160e7aed76d5cd41534e2f9@intel.com>
Tested-by: Lihong Ma <0d3c1c1d9a427393ed4b3b6b98e53ee5dd54a1a6@intel.com>
Reviewed-by: Bruce Richardson <66b9e8e8fbd5e9f41f91b0af050876182ce9d0e4@intel.com>

--- lib/librte_power/power_common.c
+++ lib/librte_power/power_common.c
@@ -17,6 +17,7 @@
 	unsigned int lcore_id = 0; /* always check core 0 */
 	char fullpath[PATH_MAX];
 	char readbuf[PATH_MAX];
+	size_t end_idx;
 	char *s;
 	FILE *f;

@@ -39,6 +40,13 @@
 	if (s == NULL)
 		return 0;

+	/* when read from sysfs, driver name has an extra newline at the end */
+	end_idx = strnlen(readbuf, sizeof(readbuf));
+	if (end_idx > 0 && readbuf[end_idx - 1] == '\n') {
+		end_idx--;
+		readbuf[end_idx] = '\0';
+	}
+
 	/* does the driver name match? */
 	if (strncmp(readbuf, driver_name, sizeof(readbuf)) != 0)
 		return 0;


log: Avoid calling time() unnecessary when logging multiple lines.

--- src/log/log-connection.c
+++ src/log/log-connection.c
@@ -122,7 +122,8 @@
 	}
 }

-static void log_it(struct log_connection *log, const char *line)
+static void
+log_it(struct log_connection *log, const char *line, const struct tm *tm)
 {
 	struct failure_line failure;
 	struct failure_context failure_ctx;
@@ -153,6 +154,7 @@

 	memset(&failure_ctx, 0, sizeof(failure_ctx));
 	failure_ctx.type = failure.log_type;
+	failure_ctx.timestamp = tm;

 	prefix = client != NULL && client->prefix != NULL ?
 		client->prefix : log->default_prefix;
@@ -210,6 +212,9 @@
 static void log_connection_input(struct log_connection *log)
 {
 	const char *line;
+	ssize_t ret;
+	time_t now;
+	struct tm tm;

 	if (!log->handshaked) {
 		if (log_connection_handshake(log) < 0) {
@@ -218,8 +223,14 @@
 		}
 	}

-	while ((line = i_stream_read_next_line(log->input)) != NULL)
-		log_it(log, line);
+	while ((ret = i_stream_read(log->input)) > 0 || ret == -2) {
+		/* get new timestamps for every read() */
+		now = time(NULL);
+		tm = *localtime(&now);
+
+		while ((line = i_stream_next_line(log->input)) != NULL)
+			log_it(log, line, &tm);
+	}

 	if (log->input->eof)
 		log_connection_destroy(log);


storage: recognize gluster as networked file

A qcow2 file with a backing file of 'gluster://host/vol/file' should
not try to look for a directory named './gluster:/' in the file system.

* src/util/virstoragefile.c (virBackingStoreIsFile): Broaden check
to include all protocols.

Signed-off-by: Eric Blake <a9da18479c871fe903d9590822cfe2629c6a4d11@redhat.com>

--- src/util/virstoragefile.c
+++ src/util/virstoragefile.c
@@ -671,8 +671,13 @@
 static bool
 virBackingStoreIsFile(const char *backing)
 {
-    /* Backing store is a network block device or Rados block device */
-    if (STRPREFIX(backing, "nbd:") || STRPREFIX(backing, "rbd:"))
+    char *colon = strchr(backing, ':');
+    char *slash = strchr(backing, '/');
+
+    /* Reject anything that looks like a protocol (such as nbd: or
+     * rbd:); if someone really does want a relative file name that
+     * includes ':', they can always prefix './'.  */
+    if (colon && (!slash || colon < slash))
         return false;
     return true;
 }


Remove *_codec_id from AVFormatParameters with the next major version bump.
AVFormatParameters is never available when needed and is an annoying mess.

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

--- libavformat/avformat.h
+++ libavformat/avformat.h
@@ -147,8 +147,10 @@
     int initial_pause:1;       /**< do not begin to play the stream
                                   immediately (RTSP only) */
     int prealloced_context:1;
+#if LIBAVFORMAT_VERSION_INT < (53<<16)
     enum CodecID video_codec_id;
     enum CodecID audio_codec_id;
+#endif
 } AVFormatParameters;

 //! demuxer will use url_fopen, no opened file should be provided by the caller


HIMAN-216: allow missing values in ensemble for some parameters when producing probabilities

--- himan-plugins/include/probability_impl.h
+++ himan-plugins/include/probability_impl.h
@@ -8,6 +8,11 @@

 namespace PROB
 {
+bool AllowMissingValuesInEnsemble(const std::string& name)
+{
+	return (name == "CL-2-FT" || name == "PRECFORM-N" || name == "PRECFORM2-N");
+}
+
 template <typename T>
 param_configuration<T> ToParamConfiguration(const partial_param_configuration& partial);

@@ -90,7 +95,7 @@
  *
  * This struct implements the "in between" operator for BETW, i.e. check if a data value
  * is within a range bounded by [lower value,upper value]
-*/
+ */

 struct BTWNCompare : public std::binary_function<double, std::vector<double>, bool>
 {
@@ -111,6 +116,9 @@

 	const bool isGrid = (targetInfo->Grid()->Type() != himan::kPointList);

+	// HIMAN-216: allow missing values in ensemble for some parameters
+	const bool allowMissing = AllowMissingValuesInEnsemble(ens->Param().Name());
+
 	while (targetInfo->NextLocation() && ens->NextLocation())
 	{
 		auto values = ens->Values();
@@ -118,9 +126,12 @@
 		// HIMAN-184: if ensemble has no values, or all values are missing, the resulting probability should
 		// be missing

-		values.erase(
-		    std::remove_if(values.begin(), values.end(), [](const double& v) { return himan::IsMissingDouble(v); }),
-		    values.end());
+		if (allowMissing == false)
+		{
+			values.erase(
+			    std::remove_if(values.begin(), values.end(), [](const double& v) { return himan::IsMissingDouble(v); }),
+			    values.end());
+		}

 		if (values.empty())
 		{


fix input example timestamps

fix input example timestamps

git-svn-id: 4c7128b443ec9da2915dfb92d5e315568ab23447@224 ac3b5936-af81-11dd-b4f7-7faeb9b304ab

--- libcam/input_example.c
+++ libcam/input_example.c
@@ -238,7 +238,7 @@
     _draw_rectangle (outbuf, super->fmt, self->x, self->y, w, w, rgb);

     outbuf->bytesused = super->fmt->height * super->fmt->row_stride;
-    outbuf->timestamp = self->next_frame_time;
+    outbuf->timestamp = now;

     cam_unit_produce_frame (super, outbuf, super->fmt);
     g_object_unref (outbuf);


Make sure the plugin loader has been initialised in libmissioncontrol-server.

--- src/mcd-account-manager.c
+++ src/mcd-account-manager.c
@@ -1261,6 +1261,9 @@

     DEBUG ("loading plugins");

+    /* not guaranteed to have been called, but idempotent: */
+    _mcd_plugin_loader_init ();
+
     if (!plugins_cached)
         sort_and_cache_plugins (account_manager);


cgfsng: fully document struct cgfsng_handler_data

Signed-off-by: Christian Brauner <48455ab3070520a2d174545c7239d6d0fabd9a83@ubuntu.com>

--- src/lxc/cgroups/cgfsng.c
+++ src/lxc/cgroups/cgfsng.c
@@ -62,31 +62,36 @@
 static struct cgroup_ops cgfsng_ops;

 /* A descriptor for a mounted hierarchy
- * @controllers:
- * - legacy hierarchy:
+ *
+ * @controllers
+ * - legacy hierarchy
  *   Either NULL, or a null-terminated list of all the co-mounted controllers.
- * - unified hierarchy:
+ * - unified hierarchy
  *   Either NULL, or a null-terminated list of all enabled controllers.
- * @mountpoint:
+ *
+ * @mountpoint
  * - The mountpoint we will use.
- * - legacy hierarchy:
+ * - legacy hierarchy
  *   It will be either /sys/fs/cgroup/controller or
  *   /sys/fs/cgroup/controllerlist.
- * - unified hierarchy:
+ * - unified hierarchy
  *   It will either be /sys/fs/cgroup or /sys/fs/cgroup/<mountpoint-name>
  *   depending on whether this is a hybrid cgroup layout (mix of legacy and
  *   unified hierarchies) or a pure unified cgroup layout.
- * @base_cgroup:
+ *
+ * @base_cgroup
  * - The cgroup under which the container cgroup path
  *   is created. This will be either the caller's cgroup (if not root), or
  *   init's cgroup (if root).
- * @fullcgpath:
+ *
+ * @fullcgpath
  * - The full path to the containers cgroup.
- * @version:
- * - legacy hierarchy:
+ *
+ * @version
+ * - legacy hierarchy
  *   If the hierarchy is a legacy hierarchy this will be set to
  *   CGROUP_SUPER_MAGIC.
- * - unified hierarchy:
+ * - unified hierarchy
  *   If the hierarchy is a legacy hierarchy this will be set to
  *   CGROUP2_SUPER_MAGIC.
  */
@@ -98,16 +103,40 @@
 	int version;
 };

-/*
- * The cgroup data which is attached to the lxc_handler.
- * @cgroup_pattern   : A copy of the lxc.cgroup.pattern
- * @container_cgroup : If not null, the cgroup which was created for the
- *                     container. For each hierarchy, it is created under the
- *                     @hierarchy->base_cgroup directory. Relative to the
- *                     base_cgroup it is the same for all hierarchies.
- * @name             : The name of the container.
- * @cgroup_meta      : A copy of the container's cgroup information. This
- *                     overrides @cgroup_pattern.
+/* The cgroup data which is attached to the lxc_handler.
+ *
+ * @cgroup_pattern
+ * - A copy of lxc.cgroup.pattern.
+ *
+ * @container_cgroup
+ * - If not null, the cgroup which was created for the container. For each
+ *   hierarchy, it is created under the @hierarchy->base_cgroup directory.
+ *   Relative to the base_cgroup it is the same for all hierarchies.
+ *
+ * @name
+ * - The name of the container.
+ *
+ * @cgroup_meta
+ * - A copy of the container's cgroup information. This overrides
+ *   @cgroup_pattern.
+ *
+ * @cgroup_layout:
+ * - What cgroup layout the container is running with
+ *   - CGROUP_LAYOUT_UNKNOWN
+ *     The cgroup layout could not be determined. This should be treated as an
+ *     error condition.
+ *   - CGROUP_LAYOUT_LEGACY
+ *     The container is running with all controllers mounted into legacy cgroup
+ *     hierarchies.
+ *   - CGROUP_LAYOUT_HYBRID
+ *     The container is running with at least one controller mounted into a
+ *     legacy cgroup hierarchy and a mountpoint for the unified hierarchy.  The
+ *     unified hierarchy can be empty (no controllers enabled) or non-empty
+ *     (controllers enabled).
+ *   - CGROUP_LAYOUT_UNIFIED
+ *     The container is running on a pure unified cgroup hierarchy. The unified
+ *     hierarchy can be empty (no controllers enabled) or non-empty (controllers
+ *     enabled).
  */
 struct cgfsng_handler_data {
 	char *cgroup_pattern;


cgfsng: fix memory leak in lxc_cpumask_to_cpulist

Signed-off-by: LiFeng <4832fed3a0f49ff12dc827462dc62b36e7f40777@huawei.com>

--- src/lxc/cgroups/cgfsng.c
+++ src/lxc/cgroups/cgfsng.c
@@ -320,6 +320,7 @@
 {
 	int ret;
 	size_t i;
+	char *tmp = NULL;
 	char **cpulist = NULL;
 	char numstr[INTTYPE_TO_STRLEN(size_t)] = {0};

@@ -343,7 +344,10 @@
 	if (!cpulist)
 		return NULL;

-	return lxc_string_join(",", (const char **)cpulist, false);
+	tmp = lxc_string_join(",", (const char **)cpulist, false);
+	lxc_free_array((void **)cpulist, free);
+
+	return tmp;
 }

 static ssize_t get_max_cpus(char *cpulist)


libvirt_lxc: Claim success for --help

libvirt_lxc: Claim success for --help

So far, if libvirt_lxc binary (usually to be found under
/usr/libexec/) is run with --help, due to a missing line
and our usual functions pattern, an 'uknown' error is returned.
Yeah, the help is printed out, but we should not claim error.

Signed-off-by: Michal Privoznik <83d82aaba2eed257f4814b0c239c260c4caaadf0@redhat.com>

--- src/lxc/lxc_controller.c
+++ src/lxc/lxc_controller.c
@@ -2613,6 +2613,7 @@
             fprintf(stderr, "  -U FD, --share-uts FD\n");
             fprintf(stderr, "  -h, --help\n");
             fprintf(stderr, "\n");
+            rc = 0;
             goto cleanup;
         }
     }


Added PlayClientEffectObjectMessage.

Added PlayClientEffectObjectMessage.

error: pathspec 'src/swganh/messages/play_client_effect_object_message.h' did not match any file(s) known to git

--- src/swganh/messages/play_client_effect_object_message.h
+++ src/swganh/messages/play_client_effect_object_message.h
@@ -0,0 +1,55 @@
+/*
+ This file is part of SWGANH. For more information, visit http://swganh.com
+
+ Copyright (c) 2006 - 2011 The SWG:ANH Team
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
+
+#ifndef SWGANH_MESSAGES_PLAY_CLIENT_EFFECT_OBJECT_MESSAGE_H_
+#define SWGANH_MESSAGES_PLAY_CLIENT_EFFECT_OBJECT_MESSAGE_H_
+
+#include <cstdint>
+#include <string>
+#include "anh/byte_buffer.h"
+#include "swganh/messages/base_swg_message.h"
+
+namespace swganh {
+namespace messages {
+
+struct PlayClientEffectObjectMessage : public swganh::messages::BaseSwgMessage<PlayClientEffectObjectMessage> {
+	static uint16_t opcount() { return 3; }
+	static uint32_t opcode() { return 0x8855434A; }
+
+	std::string client_effect_file; // e.g. "clienteffect/frs_dark_envy.cef"
+	std::string auxiliary_string; // Place from where to start the animation. See wiki for examples.
+	uint64_t object_id;
+
+	void onSerialize(anh::ByteBuffer& buffer) const {
+		buffer.write(client_effect_file);
+		buffer.write(auxiliary_string);
+		buffer.write(object_id);
+	}
+
+	void onDeserialize(anh::ByteBuffer buffer) {
+		client_effect_file = buffer.read<std::string>();
+		auxiliary_string = buffer.read<std::string>();
+		object_id = buffer.read<uint64_t>();
+	}
+};
+
+}} // namespace swganh::messages
+
+#endif // SWGANH_MESSAGES_PLAY_CLIENT_EFFECT_OBJECT_MESSAGE_H_


Fix encoding bug in i2c_ASN1_INTEGER

Fix encoding bug in i2c_ASN1_INTEGER

Fix bug where i2c_ASN1_INTEGER mishandles zero if it is marked as
negative.

Thanks to Huzaifa Sidhpurwala <huzaifas@redhat.com> and
Hanno Böck <hanno@hboeck.de> for reporting this issue.

Reviewed-by: Rich Salz <rsalz@openssl.org>

(cherry-picked from a0eed48d37a4b7beea0c966caf09ad46f4a92a44)

Bug: 28175332
Change-Id: I1e2b580f4a6d4a0fd5d26174a9cb7ed86504e7d4

--- lib/openssl/crypto/asn1/a_int.c
+++ lib/openssl/crypto/asn1/a_int.c
@@ -124,6 +124,8 @@
 		{
 		ret=a->length;
 		i=a->data[0];
+		if (ret == 1 && i == 0)
+			neg = 0;
 		if (!neg && (i > 127)) {
 			pad=1;
 			pb=0;
@@ -157,7 +159,7 @@
 		p += a->length - 1;
 		i = a->length;
 		/* Copy zeros to destination as long as source is zero */
-		while(!*n) {
+		while(!*n && i > 1) {
 			*(p--) = 0;
 			n--;
 			i--;


PUD: nwif: hand the interface address to create{R,T}xInterface

Signed-off-by: Ferry Huberts <66e11f9f5d965b69497c7e73d5e808f8b13c1218@pelagic.nl>

--- lib/pud/src/networkInterfaces.c
+++ lib/pud/src/networkInterfaces.c
@@ -229,7 +229,7 @@
  - true on success
  - false on failure
  */
-static bool createRxInterface(const char * ifName, union olsr_sockaddr ipAddr,
+static bool createRxInterface(const char * ifName, union olsr_sockaddr * ipAddr,
 		socket_handler_func rxSocketHandlerFunction, union olsr_sockaddr * rxMcAddr) {
 	int socketFd = -1;
 	TRxTxNetworkInterface * networkInterface = NULL;
@@ -246,7 +246,7 @@

 	memcpy(networkInterface->name, ifName, sizeof(networkInterface->name));
 	networkInterface->name[IFNAMSIZ] = '\0';
-	networkInterface->ipAddress = ipAddr;
+	networkInterface->ipAddress = *ipAddr;
 	networkInterface->handler = NULL;
 	networkInterface->next = NULL;

@@ -413,7 +413,7 @@
  - true on success
  - false on failure
  */
-static bool createTxInterface(const char * ifName, union olsr_sockaddr ipAddr) {
+static bool createTxInterface(const char * ifName, union olsr_sockaddr * ipAddr) {
 	int socketFd = -1;
 	TRxTxNetworkInterface * networkInterface = NULL;

@@ -429,7 +429,7 @@

 	memcpy(networkInterface->name, ifName, sizeof(networkInterface->name));
 	networkInterface->name[IFNAMSIZ] = '\0';
-	networkInterface->ipAddress = ipAddr;
+	networkInterface->ipAddress = *ipAddr;
 	networkInterface->handler = NULL;
 	networkInterface->next = NULL;

@@ -652,12 +652,11 @@

 	/* loop over all interfaces */
 	for (ifAddr = ifAddrs; ifAddr != NULL; ifAddr = ifAddr->ifa_next) {
-		struct sockaddr * addr = ifAddr->ifa_addr;
+		union olsr_sockaddr * addr = (union olsr_sockaddr *)ifAddr->ifa_addr;
 		if (addr != NULL) {
-			int addrFamily = addr->sa_family;
+			int addrFamily = addr->in.sa_family;
 			if (addrFamily == olsr_cnf->ip_version) {
 				char * ifName = ifAddr->ifa_name;
-				union olsr_sockaddr ipAddr;

 				/* determine whether the iterated interface is an OLSR
 				 * interface: returns NULL when the interface is not an
@@ -687,18 +686,12 @@
 					continue;
 				}

-				if (addrFamily == AF_INET) {
-					memcpy(&ipAddr.in4, addr, sizeof(struct sockaddr_in));
-				} else {
-					memcpy(&ipAddr.in6, addr, sizeof(struct sockaddr_in6));
-				}
-
-				if (isRxNonOlsrIf && !createRxInterface(ifName, ipAddr, rxSocketHandlerFunction, rxMcAddr)) {
+				if (isRxNonOlsrIf && !createRxInterface(ifName, addr, rxSocketHandlerFunction, rxMcAddr)) {
 					/* creating a receive interface failed */
 					goto end;
 				}

-				if (isTxNonOlsrIf && !createTxInterface(ifName, ipAddr)) {
+				if (isTxNonOlsrIf && !createTxInterface(ifName, addr)) {
 					/* creating a transmit interface failed */
 					goto end;
 				}


fix the infamous sporadic bdbuf failure check.  im not sure why the extra bits here arent initialized but i looked in gdb and it is definitely the case.  ours is zero, LNET is not

git-svn-id: ae92b08b608af1c8cefa3e10d2325ea527204e07@9284 3eda493b-6a19-0410-b2e0-ec8ea4dd8fda

--- share/fdbuf.c
+++ share/fdbuf.c
@@ -83,20 +83,14 @@
     sl_ios_id_t ios_id, int rw)
 {
 	char buf[DESCBUF_REPRLEN];
+	lnet_process_id_t *prid;
 	gcry_error_t gerr;
 	gcry_md_hd_t hd;

 	if (sbdb->sbdb_secret.sbs_magic != SBDB_MAGIC)
 		return (EBADF);
-	if (memcmp(&sbdb->sbdb_secret.sbs_cli_prid,
-	    &cli_prid, sizeof(cli_prid))) {
-		char cp[PSC_NIDSTR_SIZE], sp[PSC_NIDSTR_SIZE];
-
-		psc_errorx("bad clipr, bdbuf says %s but client is %s",
-		    psc_id2str(sbdb->sbdb_secret.sbs_cli_prid, cp),
-		    psc_id2str(cli_prid, sp));
-		return (EBADF);
-	}
+	if (prid->nid != cli_prid.nid || prid->pid != cli_prid.pid)
+		return (EBADF);
 	if (rw == SL_READ) {
 		/* Read requests can get by with looser authentication. */
 		if ((sbdb->sbdb_secret.sbs_ion_nid != ion_nid) &&


Fix warning about unused nowhere function

--- inc/geometries/modified.h
+++ inc/geometries/modified.h
@@ -204,7 +204,7 @@
 };
 //some possible predicates
 static bool nowhere( double R, double Z){return false;}
-static bool everywhere( double R, double Z){return true;}
+static bool everywhere( double R, double Z){return !nowhere(R,Z);}
 struct HeavisideZ{
     HeavisideZ( double Z_X, int side): m_ZX( Z_X), m_side(side) {}
     bool operator()(double R, double Z){


Update myTok.c

Update myTok.c

--- shell/myTok.c
+++ shell/myTok.c
@@ -310,12 +310,11 @@
 				close(pipeFds[0]);
 				close(pipeFds[1]);

-				read(0,buf,sizeof(buf));
-				printf(buf);//for debugging
+				//read(0,buf,sizeof(buf));
+				//printf(buf);//for debugging
 				launcher(0, restOfToks, pathVector, envp);//restOfToks
 				wait(NULL);
-				write(0, "\n", 1);
-				//close(0);
+				close(0);
 				//dup(0);
 			}
 		}else{


Mostly fixes the HS optical flow

Mostly fixes the HS optical flow

- Seems that the rgb data is getting read/written in the wrong byte
  order by ppmread/ppmwrite

--- include/ImageProcessing.h
+++ include/ImageProcessing.h
@@ -333,40 +333,30 @@
    BitmapImage<uint8_t>& rgb,
    BitmapImage<float>& flow
 ){
-   float const maxFlow = 1.f;
+   float const maxFlow = 2.f;
    int const rows = rgb.rows();
    int const cols = rgb.cols();

-   BitmapImage<float> hsl(rows, cols, 3);
+   BitmapImage<float> hsv(rows, cols, 3);
    int i,j;
    for( i = 0; i < rows; ++i ) {
       for( j = 0; j < cols; ++j ) {
-         /*
-         int r = 128 + 128.f*flow[i][j*2+0]/maxFlow;
-         int g = 128 + 128.f*flow[i][j*2+1]/maxFlow;
-
-         r = std::max(r, 0);
-         r = std::min(r, 255);
-         g = std::max(g, 0);
-         g = std::min(g, 255);
-         rgb[i][j*3+0] = r;
-         rgb[i][j*3+1] = g;
-         rgb[i][j*3+2] = 128;
-         */
-
          float dx = flow[i][j*2+0];
          float dy = flow[i][j*2+1];
-         float angle = 180.f + 180.f/M_PI * atan2(dy, dx);
+         float angle = 180.f/M_PI * atan2(dy, dx);
          float mag = sqrtf(dx*dx + dy*dy) / maxFlow;

-         hsl[i][j*3+0] = angle;
-         hsl[i][j*3+1] = std::min(1.f, mag);
-         hsl[i][j*3+2] = 0.5f;
-      }
-   }
-
-   hsl2rgb(hsl);
-   rgb.convertFrom<float>(hsl, [](float x) -> uint8_t { return static_cast<uint8_t>(255.f*x); });
+         if( angle < 0.f )
+            angle += 360.f;
+
+         hsv[i][j*3+0] = angle;
+         hsv[i][j*3+1] = std::min(1.f, mag);
+         hsv[i][j*3+2] = 1.f;
+      }
+   }
+
+   hsv2rgb(hsv);
+   rgb.convertFrom<float>(hsv, [](float x) -> uint8_t { return static_cast<uint8_t>(255.f*x); });
 }

 void hsOpticalFlow(
@@ -375,7 +365,7 @@
    BitmapImage<float>& img1
 ) {
    // Patch radius in pixels
-   int const radius = 1;
+   int const radius = 3;
    int const rows = img0.rows();
    int const cols = img0.cols();
    int const chans = img0.channels();
@@ -398,7 +388,7 @@
    for(i = 0; i < rows; ++i)
       for(j = 0; j < cols; ++j)
          for(k = 0; k < chans; ++k)
-            dt[i][j*chans+k] = x1[i][j*chans+k] - x0[i][j*chans+k];
+            dt[i][j*chans+k] = x0[i][j*chans+k] - x1[i][j*chans+k];

    // | Ix[0]  Iy[0] | [dx;dy] = | It[0] |
    // | Ix[1]  Iy[1] |           | It[1] |


Made local accessor a counter.

Made local accessor a counter.

--- sycl-gtx/implementation/specification/accessor/local.h
+++ sycl-gtx/implementation/specification/accessor/local.h
@@ -8,6 +8,7 @@
 #include "../buffer.h"
 #include "../command_group.h"
 #include "../ranges.h"
+#include "../../counter.h"

 namespace cl {
 namespace sycl {
@@ -15,6 +16,7 @@
 namespace detail {

 SYCL_ACCESSOR_CLASS(target == access::local),
+	public counter<>,
 	public accessor_device_ref<dimensions, DataType, dimensions, (access::mode)mode, (access::target)target>
 {
 protected:
@@ -24,7 +26,12 @@
 	range<dimensions> allocationSize;

 	size_t access_buffer_range(int n) const {
-		return allocationSize[0];
+		return allocationSize[n];
+	}
+
+	virtual void* resource() const override {
+		return reinterpret_cast<void*>(counter_id);
+	}
 	}

 public:


Fix gck_uri_parse error message

Fix gck_uri_parse error message

Signed-off-by: Lucian Adrian Grijincu <061bcbb70d9706f9ca878cd2ae17df952b86aafa@gmail.com>

--- gck/gck-uri.c
+++ gck/gck-uri.c
@@ -284,7 +284,7 @@

 	if (!g_str_has_prefix (uri, URI_PREFIX)) {
 		g_set_error_literal (error, GCK_URI_ERROR, GCK_URI_BAD_PREFIX,
-		                     _("The URI has does not have the 'pkcs11' scheme."));
+		                     _("The URI does not have the 'pkcs11' scheme."));
 		goto cleanup;
 	}


Start in the retracted state, so the first thing added at the skirt is a G1 E0 F{retract_speed}

--- gcodeExport.h
+++ gcodeExport.h
@@ -42,7 +42,7 @@

         currentSpeed = 0;
         retractionSpeed = 45;
-        isRetracted = false;
+        isRetracted = true;
         memset(extruderOffset, 0, sizeof(extruderOffset));
         f = NULL;
     }


set buffer object default Usage and Access

--- src/mesa/main/bufferobj.c
+++ src/mesa/main/bufferobj.c
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  5.1
- *
- * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
+ * Version:  6.1
+ *
+ * Copyright (C) 1999-2004  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -166,6 +166,8 @@
    _mesa_bzero(obj, sizeof(struct gl_buffer_object));
    obj->RefCount = 1;
    obj->Name = name;
+   obj->Usage = GL_STATIC_DRAW_ARB;
+   obj->Access = GL_READ_WRITE_ARB;
 }


Move 'new connection' message to connect_server()

The actual address is not known before, thus log message
was 0.0.0.0.  Now it logs actual address.

--- src/objects.c
+++ src/objects.c
@@ -825,6 +825,9 @@
 		server->remote_addr.port = ntohs(in->sin_port);
 		server->remote_addr.ip_addr = in->sin_addr;
 	}
+
+	if (cf_log_connections)
+		slog_info(server, "new connection to server");

 	/* start connecting */
 	res = sbuf_connect(&server->sbuf, sa, salen,
@@ -954,9 +957,6 @@
 	pool->last_connect_time = get_cached_time();
 	change_server_state(server, SV_LOGIN);

-	if (cf_log_connections)
-		slog_info(server, "new connection to server");
-
 	dns_connect(server);
 }


mesa: Cleanup mesa/main/bufferobj.h

mesa: Cleanup mesa/main/bufferobj.h

Column wrapping and space between lines.

Reviewed-by: Brian Paul <3cb4e1df5ec4da2c7c4af7c52cec8cf340a55a10@vmware.com>

--- src/mesa/main/bufferobj.h
+++ src/mesa/main/bufferobj.h
@@ -57,10 +57,10 @@

 extern void
-_mesa_init_buffer_objects( struct gl_context *ctx );
+_mesa_init_buffer_objects(struct gl_context *ctx);

 extern void
-_mesa_free_buffer_objects( struct gl_context *ctx );
+_mesa_free_buffer_objects(struct gl_context *ctx);

 extern bool
 _mesa_handle_bind_buffer_gen(struct gl_context *ctx,
@@ -77,9 +77,9 @@
 _mesa_lookup_bufferobj(struct gl_context *ctx, GLuint buffer);

 extern void
-_mesa_initialize_buffer_object( struct gl_context *ctx,
-				struct gl_buffer_object *obj,
-				GLuint name, GLenum target );
+_mesa_initialize_buffer_object(struct gl_context *ctx,
+                               struct gl_buffer_object *obj,
+                               GLuint name, GLenum target);

 extern void
 _mesa_reference_buffer_object_(struct gl_context *ctx,
@@ -105,59 +105,90 @@
 /*
  * API functions
  */
+void GLAPIENTRY
+_mesa_BindBuffer(GLenum target, GLuint buffer);

 void GLAPIENTRY
-_mesa_BindBuffer(GLenum target, GLuint buffer);
-void GLAPIENTRY
 _mesa_DeleteBuffers(GLsizei n, const GLuint * buffer);
+
 void GLAPIENTRY
 _mesa_GenBuffers(GLsizei n, GLuint * buffer);
+
 GLboolean GLAPIENTRY
 _mesa_IsBuffer(GLuint buffer);
+
 void GLAPIENTRY
-_mesa_BufferData(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage);
+_mesa_BufferData(GLenum target, GLsizeiptrARB size,
+                 const GLvoid * data, GLenum usage);
+
 void GLAPIENTRY
-_mesa_BufferSubData(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data);
+_mesa_BufferSubData(GLenum target, GLintptrARB offset,
+                    GLsizeiptrARB size, const GLvoid * data);
+
 void GLAPIENTRY
-_mesa_GetBufferSubData(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data);
+_mesa_GetBufferSubData(GLenum target, GLintptrARB offset,
+                       GLsizeiptrARB size, void * data);
+
 void GLAPIENTRY
-_mesa_ClearBufferData(GLenum target, GLenum internalformat, GLenum format, GLenum type, const GLvoid * data);
+_mesa_ClearBufferData(GLenum target, GLenum internalformat,
+                      GLenum format, GLenum type,
+                      const GLvoid * data);
+
 void GLAPIENTRY
-_mesa_ClearBufferSubData(GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const GLvoid * data);
+_mesa_ClearBufferSubData(GLenum target, GLenum internalformat,
+                         GLintptr offset, GLsizeiptr size,
+                         GLenum format, GLenum type,
+                         const GLvoid * data);
+
 void * GLAPIENTRY
 _mesa_MapBuffer(GLenum target, GLenum access);
+
 GLboolean GLAPIENTRY
 _mesa_UnmapBuffer(GLenum target);
+
 void GLAPIENTRY
 _mesa_GetBufferParameteriv(GLenum target, GLenum pname, GLint *params);
+
 void GLAPIENTRY
 _mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params);
+
 void GLAPIENTRY
 _mesa_GetBufferPointerv(GLenum target, GLenum pname, GLvoid **params);
+
 void GLAPIENTRY
 _mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
                         GLintptr readOffset, GLintptr writeOffset,
                         GLsizeiptr size);
+
 void * GLAPIENTRY
 _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length,
                      GLbitfield access);
+
 void GLAPIENTRY
-_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length);
+_mesa_FlushMappedBufferRange(GLenum target,
+                             GLintptr offset, GLsizeiptr length);
+
 GLenum GLAPIENTRY
 _mesa_ObjectPurgeableAPPLE(GLenum objectType, GLuint name, GLenum option);
+
 GLenum GLAPIENTRY
 _mesa_ObjectUnpurgeableAPPLE(GLenum objectType, GLuint name, GLenum option);
+
 void GLAPIENTRY
-_mesa_GetObjectParameterivAPPLE(GLenum objectType, GLuint name, GLenum pname,
-                                GLint* params);
+_mesa_GetObjectParameterivAPPLE(GLenum objectType, GLuint name,
+                                GLenum pname, GLint* params);
+
 void GLAPIENTRY
 _mesa_BindBufferRange(GLenum target, GLuint index,
                       GLuint buffer, GLintptr offset, GLsizeiptr size);
+
 void GLAPIENTRY
 _mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer);
+
 void GLAPIENTRY
 _mesa_InvalidateBufferSubData(GLuint buffer, GLintptr offset,
                               GLsizeiptr length);
+
 void GLAPIENTRY
 _mesa_InvalidateBufferData(GLuint buffer);


invalidate method cache in store_global - free all

git-svn-id: 6e74a02f85675cec270f5d931b0f6998666294a3@7251 d31e2699-5ff4-0310-a27c-f18f2fbe73fe

--- src/objects.c
+++ src/objects.c
@@ -1077,16 +1077,28 @@
     SET_NULL(mc->retc_cache);
 }

+#define TBL_SIZE_MASK 0x1ff   /* x bits 2..10 */
+#define TBL_SIZE (1 + TBL_SIZE_MASK)
+
 static void
 invalidate_type_caches(Interp *interpreter, UINTVAL type)
 {
     Caches *mc = interpreter->caches;
+    Meth_cache_entry *e, *next;
+    INTVAL i;

     if (!mc)
         return;
     /* is it a valid entry */
     if (type >= mc->mc_size || !mc->idx[type])
         return;
+    for (i = 0; i < TBL_SIZE; ++i) {
+        for (e = mc->idx[type][i]; e; ) {
+            next = e->next;
+            mem_sys_free(e);
+            e = next;
+        }
+    }
     mem_sys_free(mc->idx[type]);
     mc->idx[type] = NULL;
 }
@@ -1122,8 +1134,6 @@
     invalidate_type_caches(interpreter, (UINTVAL)type);
 }

-#define TBL_SIZE_MASK 0x1ff   /* x bits 2..10 */
-#define TBL_SIZE (1 + TBL_SIZE_MASK)
 /*
  * quick'n'dirty method cache
  * TODO: integrate NCI meth lookup


Switched health to unsigned int

Switched health to unsigned int

--- include/Monster/Monster.h
+++ include/Monster/Monster.h
@@ -2,8 +2,9 @@
 #define TOWERDEFENSE_MONSTER_H

 #include "Location/TilePoint.h"
-#include "SFMLLib/Animation.hpp"
-#include "SFMLLib/AnimatedSprite.hpp"
+#include "lib/Animation.hpp"
+#include "lib/AnimatedSprite.hpp"
+

 using Location::TilePoint;


Cast away errors on Windows

Cast away errors on Windows

--- src/core/transport/chttp2_transport.c
+++ src/core/transport/chttp2_transport.c
@@ -914,8 +914,8 @@
     window_delta = grpc_chttp2_preencode(
         s->outgoing_sopb->ops, &s->outgoing_sopb->nops,
         GPR_MIN(t->outgoing_window, s->outgoing_window), &s->writing_sopb);
-    FLOWCTL_TRACE(t, t, outgoing, 0, -window_delta);
-    FLOWCTL_TRACE(t, s, outgoing, s->id, -window_delta);
+    FLOWCTL_TRACE(t, t, outgoing, 0, -(gpr_int64)window_delta);
+    FLOWCTL_TRACE(t, s, outgoing, s->id, -(gpr_int64)window_delta);
     t->outgoing_window -= window_delta;
     s->outgoing_window -= window_delta;

@@ -1277,8 +1277,8 @@
     return GRPC_CHTTP2_CONNECTION_ERROR;
   }

-  FLOWCTL_TRACE(t, t, incoming, 0, -t->incoming_frame_size);
-  FLOWCTL_TRACE(t, s, incoming, s->id, -t->incoming_frame_size);
+  FLOWCTL_TRACE(t, t, incoming, 0, -(gpr_int64)t->incoming_frame_size);
+  FLOWCTL_TRACE(t, s, incoming, s->id, -(gpr_int64)t->incoming_frame_size);
   t->incoming_window -= t->incoming_frame_size;
   s->incoming_window -= t->incoming_frame_size;


- Regenerated.

- Regenerated.

--- include/PlainSocketImpl.h
+++ include/PlainSocketImpl.h
@@ -7,14 +7,6 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-/*
- * Class:     java_net_PlainSocketImpl
- * Method:    sockCreate
- * Signature: (Z)V
- */
-JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_sockCreate
-  (JNIEnv *, jobject, jboolean);
-
 /*
  * Class:     java_net_PlainSocketImpl
  * Method:    bind
@@ -34,7 +26,7 @@
 /*
  * Class:     java_net_PlainSocketImpl
  * Method:    accept
- * Signature: (Ljava/net/PlainSocketImpl;)V
+ * Signature: (Ljava/net/SocketImpl;)V
  */
 JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_accept
   (JNIEnv *, jobject, jobject);
@@ -49,27 +41,43 @@

 /*
  * Class:     java_net_PlainSocketImpl
- * Method:    sockConnect
+ * Method:    socketCreate
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_socketCreate
+  (JNIEnv *, jobject, jboolean);
+
+/*
+ * Class:     java_net_PlainSocketImpl
+ * Method:    socketConnect
  * Signature: (Ljava/net/InetAddress;I)V
  */
-JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_sockConnect
+JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_socketConnect
   (JNIEnv *, jobject, jobject, jint);

 /*
  * Class:     java_net_PlainSocketImpl
- * Method:    sockClose
+ * Method:    socketClose
  * Signature: ()V
  */
-JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_sockClose
+JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_socketClose
   (JNIEnv *, jobject);

 /*
  * Class:     java_net_PlainSocketImpl
- * Method:    sockAvailable
- * Signature: ()I
+ * Method:    socketGetOption
+ * Signature: (I)Ljava/lang/Object;
  */
-JNIEXPORT jint JNICALL Java_java_net_PlainSocketImpl_sockAvailable
-  (JNIEnv *, jobject);
+JNIEXPORT jobject JNICALL Java_java_net_PlainSocketImpl_socketGetOption
+  (JNIEnv *, jobject, jint);
+
+/*
+ * Class:     java_net_PlainSocketImpl
+ * Method:    socketSetOption
+ * Signature: (ILjava/lang/Object;)V
+ */
+JNIEXPORT void JNICALL Java_java_net_PlainSocketImpl_socketSetOption
+  (JNIEnv *, jobject, jint, jobject);

 #ifdef __cplusplus
 }


From Andrei fix for problem on Windows

From Andrei
fix for problem on Windows

git-svn-id: ecbadac9c76e8cf640a0bca86f6bd796c98521e3@43167 27541ba8-7e3a-0410-8455-c3a389f83636


RISC-V: Enhancement for stack size to 16-bytes aligned at least

If enable CONFIG_PMP_STACK_GUARD, the stack size may not 16-bytes
aligned. Enhance this issue.

Signed-off-by: Shih-Wei Teng <038e9672cc33351038c9f20b16e9b6670348cb97@andestech.com>

--- include/arch/riscv/arch.h
+++ include/arch/riscv/arch.h
@@ -54,7 +54,8 @@
  */
 #ifdef CONFIG_PMP_STACK_GUARD
 #define ARCH_KERNEL_STACK_RESERVED	Z_RISCV_STACK_GUARD_SIZE
-#define ARCH_KERNEL_STACK_OBJ_ALIGN	Z_RISCV_PMP_ALIGN
+#define ARCH_KERNEL_STACK_OBJ_ALIGN \
+		MAX(Z_RISCV_PMP_ALIGN, ARCH_STACK_PTR_ALIGN)
 #endif

 #ifdef CONFIG_USERSPACE


[fix] move

[fix] move

--- src/crf_trainer_averaged_perceptron.c
+++ src/crf_trainer_averaged_perceptron.c
@@ -676,6 +676,7 @@
         return false;
     }

+    uint32_t *viterbi = self->viterbi->a;
     double viterbi_score = crf_context_viterbi(crf_context, viterbi);

     if (self->viterbi->n != num_tokens || self->label_ids->n != num_tokens) {
@@ -685,7 +686,6 @@

     uint32_t *true_labels = self->label_ids->a;

-    uint32_t *viterbi = self->viterbi->a;

     for (uint32_t i = 0; i < num_tokens; i++) {
         uint32_t truth = true_labels[i];


Corrected some doxy comments for atomic APIs.

--- include/argon/ar_kernel.h
+++ include/argon/ar_kernel.h
@@ -1061,7 +1061,9 @@
 int32_t ar_atomic_add(volatile int32_t * value, int32_t delta);

 /*!
- * @brief Atomically increment a value.
+ * @brief Atomically increment a value by 1.
+ *
+ * A memory barrier is performed prior to the add operation.
  *
  * @param value Pointer to the word to increment.
  * @return The original value is returned.
@@ -1069,7 +1071,9 @@
 static inline int32_t ar_atomic_inc(volatile int32_t * value) { return ar_atomic_add(value, 1); }

 /*!
- * @brief Atomically decrement a value.
+ * @brief Atomically decrement a value by 1.
+ *
+ * A memory barrier is performed prior to the add operation.
  *
  * @param value Pointer to the word to decrement.
  * @return The original value is returned.
@@ -1079,9 +1083,9 @@
 /*!
  * @brief Atomic compare and swap operation.
  *
- * Tests the word pointed to by @a value for equality with @a oldValue. If they are
+ * Tests the word pointed to by @a value for equality with @a expectedValue. If they are
  * equal, the word pointed to by @a value is set to @a newValue. If *value is not
- * equal to @a oldValue, then no change is made. The return value indicates whether
+ * equal to @a expectedValue, then no change is made. The return value indicates whether
  * the swap was performed. Of course, this entire operation is guaranteed to be
  * atomic even on multiprocessor platforms.
  *
@@ -1089,7 +1093,7 @@
  *
  * @param value Pointer to the word to compare and swap.
  * @param expectedValue Value to compare against.
- * @param newValue Value to value to swap in if *value is equal to oldValue.
+ * @param newValue Value to value to swap in if *value is equal to expectedValue.
  * @retval false No change was made to *value.
  * @retval true The swap was performed, and *value is now equal to newValue.
  */


add exception text message

add exception text message

--- mock4cpp/include/mock4cpp/UnmockedMethodCallException.h
+++ mock4cpp/include/mock4cpp/UnmockedMethodCallException.h
@@ -5,6 +5,7 @@
 namespace mock4cpp {

 	struct UnmockedMethodCallException : public std::exception {
+		UnmockedMethodCallException() : std::exception("Could not find recorded implementation to support method call") {}
 	};

 }


[PATCH] s390: remove one set of brackets in __constant_test_bit()

Right now in __constant_test_bit for the s390 there is an extra set of ()
surrounding the calculation.  This patch simply removes one set of () that is
surrounding the whole clause.

Signed-off-by: Eric Paris <b0b36e3cd9ea4e5739ff430a3056fabf2fdb0376@redhat.com>
Signed-off-by: Heiko Carstens <8dcf0f69152f32f23184f83357a3731522e56b9c@de.ibm.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@osdl.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@osdl.org>

--- include/asm-s390/bitops.h
+++ include/asm-s390/bitops.h
@@ -518,8 +518,8 @@

 static inline int
 __constant_test_bit(unsigned long nr, const volatile unsigned long *addr) {
-    return ((((volatile char *) addr)
-	    [(nr^(__BITOPS_WORDSIZE-8))>>3] & (1<<(nr&7)))) != 0;
+    return (((volatile char *) addr)
+	    [(nr^(__BITOPS_WORDSIZE-8))>>3] & (1<<(nr&7))) != 0;
 }

 #define test_bit(nr,addr) \


Corrected DB query of PDM

Corrected DB query of PDM

To check the existence of link between two devices, We should use query with
‘and’ not ‘or’.
Previously link  was checked with ‘or’ thats why if we try to create multiple
links involving one same device and other different devices then it was showing
link already exists. for example if we create link between A-B then if we try
to create link between A-C then we are getting error that link already exists.

Change-Id: I408658af4f423a641bab077439435711ecac876e
Signed-off-by: Randeep Singh <46ce9385024397d3e4d9ed63be2e0a0d801e95b7@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3361
Reviewed-by: Woochul Shim <57d9e3535282e81a67bd73a19c480a4343aa90c8@samsung.com>
Tested-by: jenkins-iotivity <09cb29e8a2b473a2c978382eec13ee06fa017bda@opendaylight.org>
Reviewed-by: Sachin Agrawal <e527dde4abdf871552470c254efd4939572046d8@intel.com>

--- resource/csdk/security/provisioning/src/provisioningdatabasemanager.c
+++ resource/csdk/security/provisioning/src/provisioningdatabasemanager.c
@@ -73,6 +73,7 @@
 #define PDM_SQLITE_LIST_ALL_UUID "SELECT UUID FROM T_DEVICE_LIST"
 #define PDM_SQLITE_GET_UUID "SELECT UUID FROM T_DEVICE_LIST WHERE ID = ?"
 #define PDM_SQLITE_GET_LINKED_DEVICES "SELECT ID,ID2 FROM T_DEVICE_LINK_STATE WHERE ID = ? or ID2 = ?"
+#define PDM_SQLITE_GET_DEVICE_LINKS "SELECT ID,ID2 FROM T_DEVICE_LINK_STATE WHERE ID = ? and ID2 = ?"

 #define ASCENDING_ORDER(id1, id2) do{if( (id1) > (id2) )\
   { int temp; temp = id1; id1 = id2; id2 = temp; }}while(0)
@@ -704,8 +705,8 @@

     sqlite3_stmt *stmt = 0;
     int res = 0;
-    res = sqlite3_prepare_v2(g_db, PDM_SQLITE_GET_LINKED_DEVICES,
-                              strlen(PDM_SQLITE_GET_LINKED_DEVICES) + 1, &stmt, NULL);
+    res = sqlite3_prepare_v2(g_db, PDM_SQLITE_GET_DEVICE_LINKS,
+                              strlen(PDM_SQLITE_GET_DEVICE_LINKS) + 1, &stmt, NULL);
     PDM_VERIFY_SQLITE_OK(TAG, res, ERROR, OC_STACK_ERROR);

     res = sqlite3_bind_int(stmt, PDM_BIND_INDEX_FIRST, id1);


[Reactor] Add IdealGas reactor types to zerodim.h

--- include/cantera/zerodim.h
+++ include/cantera/zerodim.h
@@ -7,6 +7,7 @@
 #include "zeroD/flowControllers.h"
 #include "zeroD/FlowReactor.h"
 #include "zeroD/ConstPressureReactor.h"
+#include "zeroD/IdealGasReactor.h"
+#include "zeroD/IdealGasConstPressureReactor.h"

 #endif
-


Moved CallbackMgr to using a vector collection, added registerCb that takes a position iterator

--- include/cinder/Function.h
+++ include/cinder/Function.h
@@ -25,7 +25,8 @@
 #include "cinder/Cinder.h"

 #include <algorithm>
-#include <map>
+#include <vector>
+#include <utility>

 #if defined( _MSC_VER ) && ( _MSC_VER >= 1600 )
 	#include <functional>
@@ -44,18 +45,25 @@
 //! Implements a utility class for maintaining a list of callbacks
 template<typename SIG>
 class CallbackMgr {
-  private:
-	std::map<CallbackId,std::function<SIG> >		mCallbacks;
-
   public:
-	typedef typename std::map<CallbackId,std::function<SIG> >::iterator		iterator;
+	typedef typename std::vector<std::pair<CallbackId,std::function<SIG> > >	collection;
+	typedef typename collection::iterator										iterator;

 	CallbackId	registerCb( std::function<SIG> cb )
 	{
 		CallbackId cbId = 0;
 		if( ! mCallbacks.empty() )
 			cbId = mCallbacks.rbegin()->first + 1;
-		mCallbacks[cbId] = cb;
+		mCallbacks.push_back( std::make_pair( cbId, cb ) );
+		return cbId;
+	}
+
+	CallbackId	registerCb( iterator position, std::function<SIG> cb )
+	{
+		CallbackId cbId = 0;
+		if( ! mCallbacks.empty() )
+			cbId = mCallbacks.rbegin()->first + 1;
+		mCallbacks.insert( position, std::make_pair( cbId, cb ) );
 		return cbId;
 	}

@@ -70,12 +78,18 @@
 	template<typename A1, typename A2, typename A3, typename A4, typename A5>
 	void call( A1 a1, A2 a2, A3 a3, A4 a4, A5 a5 ) { for( iterator it = begin(); it != end(); ++it ) it->second( a1, a2, a3, a4, a5 ); }

-	void	unregisterCb( CallbackId cbId ) { mCallbacks.erase( cbId ); }
+	void	unregisterCb( CallbackId cbId ) { mCallbacks.erase( find( cbId ) ); }

 	bool	empty() const { return mCallbacks.empty(); }
-
+
+	iterator find( CallbackId cbId ) { for( iterator it = begin(); it != end(); ++it ) if( it->first == cbId ) return it; return mCallbacks.end(); }
 	iterator begin() { return mCallbacks.begin(); }
 	iterator end() { return mCallbacks.end(); }
+
+	collection&		getCallbacks() { return mCallbacks; }
+
+  private:
+	collection		mCallbacks;
 };

 } // namespace cinder


Declare a byte version of the data

Declare a byte version of the data

Declare a byte version of the data field.  This fixes Issue #40

--- include/cn-cbor/cn-cbor.h
+++ include/cn-cbor/cn-cbor.h
@@ -81,7 +81,9 @@
   /** Data associated with the value; different branches of the union are
       used depending on the `type` field. */
   union {
-    /** CN_CBOR_BYTES, CN_CBOR_TEXT */
+    /** CN_CBOR_BYTES */
+    const uint8_t* bytes;
+    /** CN_CBOR_TEXT */
     const char* str;
     /** CN_CBOR_INT */
     long sint;


remove legacy SkMScalar code

remove legacy SkMScalar code

Change-Id: Idb42ea3fc13228a0edc50e36b4573601f50b11fe
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/266384
Reviewed-by: Mike Reed <f5cabf8735907151a446812c9875d6c0c712d847@google.com>
Commit-Queue: Mike Reed <f5cabf8735907151a446812c9875d6c0c712d847@google.com>

--- include/core/SkMatrix44.h
+++ include/core/SkMatrix44.h
@@ -13,46 +13,6 @@

 #include <atomic>
 #include <cstring>
-
-#ifdef SK_SUPPORT_LEGACY_MSCALAR
-typedef SkScalar SkMScalar;
-
-static inline SkScalar SkFloatToMScalar(float x) {
-    return x;
-}
-static inline float SkMScalarToFloat(SkScalar x) {
-    return float(x);
-}
-static inline float SkDoubleToMScalar(double x) {
-    return SkScalar(x);
-}
-static inline double SkMScalarToDouble(SkScalar x) {
-    return x;
-}
-static inline float SkMScalarAbs(float x) {
-    return sk_float_abs(x);
-}
-
-static const SkScalar SK_MScalarPI = SK_ScalarPI;
-static const SkScalar SK_MScalarNaN = SK_ScalarNaN;
-
-#define SkMScalarFloor(x)           SkScalarFloor(x)
-#define SkMScalarCeil(x)            SkScalarCeil(x)
-#define SkMScalarRound(x)           SkScalarRound(x)
-
-#define SkMScalarFloorToInt(x)      SkScalarFloorToInt(x)
-#define SkMScalarCeilToInt(x)       SkScalarCeilToInt(x)
-#define SkMScalarRoundToInt(x)      SkScalarRoundToInt(x)
-
-#define SkIntToMScalar(n)       SkIntToScalar(n)
-
-#define SkMScalarToScalar(x)    (x)
-#define SkScalarToMScalar(x)    (x)
-
-static const SkScalar SK_MScalar1 = 1;
-#endif
-
-///////////////////////////////////////////////////////////////////////////////

 struct SkVector4 {
     SkScalar fData[4];
@@ -360,15 +320,6 @@
         this->mapScalars(vec, vec);
     }

-#ifdef SK_SUPPORT_LEGACY_MSCALAR
-    inline void mapMScalars(const SkScalar src[4], SkScalar dst[4]) const {
-        this->mapScalars(src, dst);
-    }
-    inline void mapMScalars(SkScalar vec[4]) const {
-        this->mapMScalars(vec, vec);
-    }
-#endif
-
     friend SkVector4 operator*(const SkMatrix44& m, const SkVector4& src) {
         SkVector4 dst;
         m.mapScalars(src.fData, dst.fData);


Make move operations and swap noexcept.

Make move operations and swap noexcept.

--- src/vast/util/intrusive.h
+++ src/vast/util/intrusive.h
@@ -73,40 +73,47 @@

   intrusive_ptr() = default;

-  intrusive_ptr(T* p, bool add_ref = true)
-    : ptr_(p)
+  intrusive_ptr(T* x, bool add_ref = true)
+    : ptr_{x}
   {
     if (ptr_ && add_ref)
       ref(ptr_);
   }

+  template <typename U>
+  intrusive_ptr(intrusive_ptr<U> other)
+    : ptr_{other.release()}
+  {
+    static_assert(std::is_convertible<T*, U*>::value,
+                  "U* is not assignable to T*");
+  }
+
   intrusive_ptr(intrusive_ptr const& other)
-    : ptr_(other.get())
+    : ptr_{other.get()}
   {
     if (ptr_)
       ref(ptr_);
   }

-  template <typename U>
-  intrusive_ptr(intrusive_ptr<U> other)
-    : ptr_(other.release())
-  {
-    static_assert(std::is_convertible<T*, U*>::value,
-                  "U* cannot be assigned to T*");
-  }
-
-  intrusive_ptr(intrusive_ptr&& other)
-    : ptr_(other.release())
-  {
-  }
-
-  ~intrusive_ptr()
+  intrusive_ptr(intrusive_ptr&& other) noexcept
+    : ptr_{other.release()}
+  {
+  }
+
+  ~intrusive_ptr() noexcept
   {
     if (ptr_)
       unref(ptr_);
   }

-  intrusive_ptr& operator=(intrusive_ptr other)
+  intrusive_ptr& operator=(intrusive_ptr const& other)
+  {
+    intrusive_ptr tmp{other};
+    tmp.swap(*this);
+    return *this;
+  }
+
+  intrusive_ptr& operator=(intrusive_ptr&& other) noexcept
   {
     other.swap(*this);
     return *this;
@@ -118,7 +125,7 @@
     return *this;
   }

-  void swap(intrusive_ptr& other)
+  void swap(intrusive_ptr& other) noexcept
   {
     std::swap(ptr_, other.ptr_);
   }


Added Cyc_check_opaque

Added Cyc_check_opaque

--- include/cyclone/runtime.h
+++ include/cyclone/runtime.h
@@ -82,6 +82,7 @@
 #define Cyc_check_port(d,obj) Cyc_check_type(d,Cyc_is_port, port_tag, obj);
 #define Cyc_check_mutex(d,obj) Cyc_check_type(d,Cyc_is_mutex, mutex_tag, obj);
 #define Cyc_check_cond_var(d,obj) Cyc_check_type(d,Cyc_is_cond_var, cond_var_tag, obj);
+#define Cyc_check_opaque(d,obj) Cyc_check_type(d,Cyc_is_opaque, c_opaque_tag, obj);
 void Cyc_invalid_type_error(void *data, int tag, object found);
 void Cyc_check_obj(void *data, int tag, object obj);
 void Cyc_check_bounds(void *data, const char *label, int len, int index);


Null-pointer cleanup in extopts header

Null-pointer cleanup in extopts header

--- include/extopts/extopts.h
+++ include/extopts/extopts.h
@@ -35,7 +35,7 @@
 enum extopt_argtype {
 	/* Field 'arg' will be used as 'flag' pointing to flag for whether
 	 * parameter was met in command line or not */
-	EXTOPT_ARGTYPE_NO_ARG,
+	EXTOPT_ARGTYPE_NO_ARG = 0,
 	/* Field 'arg' will be used as 'setter' handler which will be
 	 * called for argument parsing */
 	EXTOPT_ARGTYPE_SPECIAL,
@@ -174,7 +174,18 @@

 /* Should be used as end of extopt array */
-#define EXTOPTS_END { 0, 0, 0, 0, 0, 0, {0} }
+#define EXTOPTS_END								\
+	{											\
+		.name_long = NULL,						\
+		.name_short = 0,						\
+		.desc = NULL,							\
+		.has_arg = false,						\
+		.arg_name = NULL,						\
+		.arg_type = EXTOPT_ARGTYPE_NO_ARG,		\
+		.arg = {								\
+			.addr = NULL,						\
+		},										\
+	}

 /* Array functions */
 int extopts_get(int *argc, char *argv[], struct extopt *opts);
@@ -183,13 +194,13 @@
 /* Single extopt functions*/
 inline static char extopt_is_end(struct extopt opt)
 {
-	return opt.name_long == 0 &&
+	return opt.name_long == NULL &&
 		opt.name_short	== 0 &&
-		opt.has_arg		== 0 &&
-		opt.arg_name	== 0 &&
-		opt.desc		== 0 &&
+		opt.has_arg		== false &&
+		opt.arg_name	== NULL &&
+		opt.desc		== NULL &&
 		opt.arg_type	== 0 &&
-		opt.arg.addr	== 0;
+		opt.arg.addr	== NULL;
 }

 #endif /* __EXTOPTS_H */


Update geometry.h

Update geometry.h

minimum image

--- include/faunus/geometry.h
+++ include/faunus/geometry.h
@@ -126,13 +126,13 @@
         }

         /**
-         * See doi:10/ck2nrd for a review of minimum image algorithms
+         * For reviews of minimum image algorithms,
+         * see doi:10/ck2nrd and doi:10/kvs
          */
         double sqdist(const Point &a, const Point &b) const {
           Point d = (a-b).cwiseAbs();
-          if (d.x()>len_half.x()) d.x()-=len.x();
-          if (d.y()>len_half.y()) d.y()-=len.y();
-          if (d.z()>len_half.z()) d.z()-=len.z();
+          for (int i=0; i<3; ++i)
+            if (d[i]>len_half[i]) d[i]-=2*len_half[i];
           return d.squaredNorm();

           // Alternative algorithm:


MaxPlugins  0.2.8
  -----
o Exporter
  - Fix Collapse Transforms on dialog so that it actually triggers collapse
  - Change defaults for textures so Morrowind does not crash in CS
  - Fix export of animation for Morrowind
  - Introduce mechanism in Collapse Transforms so that poorly scaled models export better

o Importer
  - Fix import of animation for Morrowind

--- include/gen/obj_defines.h
+++ include/gen/obj_defines.h
@@ -2541,7 +2541,7 @@

 #define NI_SOURCE_TEXTURE_PARENT NiObjectNET

-#define NI_SOURCE_TEXTURE_CONSTRUCT  : useExternal((byte)1), unknownLink(NULL), unknownByte((byte)0), pixelData(NULL), pixelLayout((PixelLayout)5), useMipmaps((MipMapFormat)2), alphaFormat((AlphaFormat)3), unknownByte2((byte)1)
+#define NI_SOURCE_TEXTURE_CONSTRUCT  : useExternal((byte)1), unknownLink(NULL), unknownByte((byte)1), pixelData(NULL), pixelLayout((PixelLayout)5), useMipmaps((MipMapFormat)2), alphaFormat((AlphaFormat)3), unknownByte2((byte)1)

 #define NI_SPECULAR_PROPERTY_INCLUDE "NiProperty.h"


Ability to report more specific error messages added to WMTS error handling. More error messages to come.

--- src/mod_onearth/mod_wms.c
+++ src/mod_onearth/mod_wms.c
@@ -94,6 +94,8 @@
 typedef struct wmts_error wmts_error;
 struct wmts_error wmts_errors[5];
 int errors = 0;
+static int wmts_add_error(request_rec *r, int status, char *exceptionCode, char *locator, char *exceptionText);
+static int wmts_return_all_errors(request_rec *r);

 // Module constants
 static char kmltype[]="application/vnd.google-earth.kml+xml";
@@ -197,6 +199,7 @@
 		tm.tm_mday=apr_atoi64(targ);
     } else {
     	ap_log_error(APLOG_MARK,APLOG_ERR,0,r->server,"Invalid time format: %s",targ);
+		wmts_add_error(r,400,"InvalidParameterValue","TIME", "Invalid time format");
     	return 0;
     }
 	if ((tm.tm_year)&&(tm.tm_mon)&&(tm.tm_mday)) { // We do have a time stamp
@@ -634,6 +637,9 @@
     	level->xcount-1, level->ycount-1, r->args);
     return -1;
  }
+// int level_int = level->index_add + sizeof(index_s) * (y*level->xcount+x);
+// ap_log_error(APLOG_MARK,APLOG_ERR,0,r->server, "offset: %d, max values are %d and %d, x: %d, y: %d, index_add: %d",
+//		 level_int, level->xcount-1, level->ycount-1, x, y, level->index_add);
  return level->index_add + sizeof(index_s) * (y*level->xcount+x);

 }
@@ -671,6 +677,14 @@
        (iy<0) || (iy>=level->ycount) )
     return -1;

+//  ap_log_error(APLOG_MARK,APLOG_ERR,0,r->server,
+//    "ix %d ,x %d ,iy %d,y %d, Level x %d y %d, page count x %d y %d\n",
+//    ix,x,iy,y,
+//    level->levelx,level->levely,level->xcount,level->ycount );
+
+//  int level_int = level->index_add+sizeof(index_s)*(iy*level->xcount+ix);
+//  ap_log_error(APLOG_MARK,APLOG_ERR,0,r->server, "offset: %d",
+// 		 level_int);
   return
     level->index_add+sizeof(index_s)*(iy*level->xcount+ix);
 }
@@ -1002,6 +1016,8 @@
 			*Value++ = '\0';
 			return;
 		}
+	} else {
+		Value[0]='\0';
 	}

 	return;
@@ -1049,9 +1065,11 @@
 		getParam(args,"tilecol",tilecol);

 		// need to ignore occurrence of tilematrix in tilematrixset - replace only one char for optimal performance
-		char *pos1 = strcasestr(args, "tilematrixset");
-		*pos1 = 1;
-		getParam(args,"tilematrix",tilematrix);
+		if (tilematrixset[0]!='\0') {
+			char *pos1 = strcasestr(args, "tilematrixset");
+			*pos1 = 1;
+			getParam(args,"tilematrix",tilematrix);
+		}

 		// GIBS-273 handle style=default, treat as empty. We don't need this if done in the layer regex pattern.
 		if (strcasecmp (style, "default") == 0) {
@@ -1090,11 +1108,113 @@
 		sprintf(args,"request=GetCapabilities");
 	} else if (strcasecmp (request, "GetTileService") == 0) { // getTileService
 		sprintf(args,"request=GetTileService");
+	} else if (service[0]=='\0') { // missing WMTS service
+		wmts_add_error(r,400,"MissingParameterValue","SERVICE", "Missing SERVICE parameter");
+	} else if (strcasecmp (service, "WMTS") != 0) { // unrecognized service
+		wmts_add_error(r,400,"InvalidParameterValue","SERVICE", "Unrecognized service");
 	} else { // invalid REQUEST value
 		wmts_add_error(r,501,"OperationNotSupported","REQUEST", "The request type is not supported");
 	}

 	return args;
+}
+
+static void specify_error(request_rec *r)
+{
+	wms_cfg  *cfg;
+	WMSCache *cache;
+
+	// Get the configuration
+	cfg=(wms_cfg *)
+	ap_get_module_config(r->per_dir_config,&wms_module);
+
+	// url params
+	char *args = r->args;
+	int max_chars;
+	max_chars = strlen(r->args) + 1;
+
+	char *layer = (char *)malloc(sizeof(char) *max_chars);
+	char *layer_reg = (char *)malloc(sizeof(char) *max_chars);
+	char *layer_mes = (char *)malloc(sizeof(char) *max_chars);
+	char *version = (char *)malloc(sizeof(char) *max_chars);
+	char *version_reg = (char *)malloc(sizeof(char) *max_chars);
+	char *version_mes = (char *)malloc(sizeof(char) *max_chars);
+	char *tilematrixset = (char *)malloc(sizeof(char) *max_chars);
+	char *tilematrixset_reg = (char *)malloc(sizeof(char) *max_chars);
+	char *tilematrixset_mes = (char *)malloc(sizeof(char) *max_chars);
+
+
+	getParam(args,"layer",layer);
+	getParam(args,"version",version);
+	getParam(args,"tilematrixset",tilematrixset);
+
+	int count;
+	count=cfg->caches->count;
+
+	int layer_match = 0;
+	int version_match = 0;
+	int tilematrixset_match = 0;
+
+	while (count--) {
+		int i;
+		cache=GETCACHE(cfg->caches,count);
+		i=cache->num_patterns;
+
+		getParam(cache->pattern,"layer",layer_reg);
+		getParam(cache->pattern,"version",version_reg);
+		getParam(cache->pattern,"tilematrixset",tilematrixset_reg);
+
+		if (strcasecmp (layer, layer_reg) == 0) {
+			layer_match++;
+		} else {
+//			ap_log_error(APLOG_MARK,LOG_LEVEL,0,r->server,
+//			"Parameter: %s %s",layer, layer_reg);
+		}
+		if (strcasecmp (version, version_reg) == 0) {
+			version_match++;
+		}
+		if (strcasecmp (tilematrixset, tilematrixset_reg) == 0) {
+			tilematrixset_match++;
+		}
+		// we should only need to loop for layer
+
+	}
+
+	// LAYER
+	if (layer[0]=='\0') {
+		wmts_add_error(r,400,"MissingParameterValue","LAYER", "Missing LAYER parameter");
+	}
+	else if (layer_match==0) {
+		sprintf(layer_mes,"LAYER %s does not exist",layer);
+		wmts_add_error(r,400,"InvalidParameterValue","LAYER", layer_mes);
+	}
+	// VERSION
+	if (version[0]=='\0') {
+		wmts_add_error(r,400,"MissingParameterValue","VERSION", "Missing VERSION parameter");
+	}
+	else if (version_match==0) {
+		sprintf(version_mes,"VERSION %s does not exist",version);
+		wmts_add_error(r,400,"InvalidParameterValue","VERSION", version_mes);
+	}
+	// TILEMATRIXSET
+	if (tilematrixset[0]=='\0') {
+		wmts_add_error(r,400,"MissingParameterValue","TILEMATRIXSET", "Missing TILEMATRIXSET parameter");
+	}
+	else if (tilematrixset_match==0) {
+		sprintf(tilematrixset_mes,"TILEMATRIXSET %s does not exist",tilematrixset);
+		wmts_add_error(r,400,"InvalidParameterValue","TILEMATRIXSET", tilematrixset_mes);
+	}
+
+	// check for correct time format
+	static char* timearg="time=";
+	char *targ=0;
+	if ((targ=ap_strcasestr(r->args,timearg))) {
+		targ+=5; // Skip the time= part
+		if (!(strlen(targ)==10 || strlen(targ)==0)) {
+			ap_log_error(APLOG_MARK,APLOG_ERR,0,r->server,"Invalid time format: %s",targ);
+			wmts_add_error(r,400,"InvalidParameterValue","TIME", "Invalid time format");
+		}
+	}
 }

 static int mrf_handler(request_rec *r)
@@ -1154,9 +1274,9 @@
         	ap_log_error(APLOG_MARK,APLOG_NOTICE,0,r->server,"Requesting getCapabilities");
     	} else {
     		if (errors==0) {
+    			specify_error(r);
     			ap_log_error(APLOG_MARK,LOG_LEVEL,0,r->server,
-        			"Unhandled %s%s?%s %d",r->hostname,r->uri,r->args,r->status);
-    			wmts_add_error(r,400,"MissingParameterValue","%s", "Missing %s parameter");
+        			"Unhandled %s%s?%s",r->hostname,r->uri,r->args);
     		}
     		return wmts_return_all_errors(r);
     	}
@@ -1249,9 +1369,6 @@
 		wmts_add_error(r,400,"InvalidParameterValue","TILEMATRIX", "Unknown TILEMATRIX");
     }

-//    if (wmts_errors[0].exceptionCode != ((void *) 0)) {
-//    	return wmts_return_all_errors(r);
-//    }
     if (errors > 0) {
     	return wmts_return_all_errors(r);
     }
@@ -1273,7 +1390,11 @@
                  "Can't get index record from %s\nBased on %s",
 		 tstamp_fname(r,level->ifname),r->args);
     perror("Index read error: ");
-    return DECLINED;
+    if (errors > 0) {
+    	return wmts_return_all_errors(r);
+    } else {
+    	return DECLINED;
+    }
   }

 //


Fixed wrong header

Fixed wrong header

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

--- include/gpac/ringbuffer.h
+++ include/gpac/ringbuffer.h
@@ -85,9 +85,9 @@
  * \param sz the size of source
  * \return Returns the actual number of bytes copied, may be lower than sz if ringbuffer is already full
  */
-u32 gf_ringbuffer_write (GF_Ringbuffer * rb, const u_int8_t * src, size_t sz);
+u32 gf_ringbuffer_write (GF_Ringbuffer * rb, const u_int8_t * src, u32 sz);

 #ifdef __cplusplus
 }
 #endif
-#endif /* _GF_RINGBUFFER_H */+#endif /* _GF_RINGBUFFER_H */


Move value='DER' check out of type dispatch in xe_new

--- src/openssl.c
+++ src/openssl.c
@@ -4983,35 +4983,34 @@
 	CONF *conf = NULL;
 	X509V3_CTX cbuf = { 0 }, *ctx = NULL;
 	X509_EXTENSION **ud;
+	_Bool crit;

 	lua_settop(L, 3);
 	ud = prepsimple(L, X509_EXT_CLASS);
+
+	if (xe_new_isder(value, &crit)) {
+		size_t len;
+		const char *cdata = lua_tolstring(L, 3, &len);
+		if (!(obj = OBJ_txt2obj(name, 0)))
+			goto error;
+		if (!(oct = ASN1_STRING_new()))
+			goto error;
+		if (!ASN1_STRING_set(oct, cdata, len))
+			goto error;
+		if (!(*ud = X509_EXTENSION_create_by_OBJ(NULL, obj, crit, oct)))
+			goto error;
+
+		ASN1_OBJECT_free(obj);
+		ASN1_STRING_free(oct);
+
+		return 1;
+	}

 	switch (lua_type(L, 3)) {
 	case LUA_TNONE:
 	case LUA_TNIL:
 		break;
 	case LUA_TSTRING: {
-		size_t len;
-		const char *cdata = lua_tolstring(L, 3, &len);
-		_Bool crit;
-
-		if (xe_new_isder(value, &crit)) {
-			if (!(obj = OBJ_txt2obj(name, 0)))
-				goto error;
-			if (!(oct = ASN1_STRING_new()))
-				goto error;
-			if (!ASN1_STRING_set(oct, cdata, len))
-				goto error;
-			if (!(*ud = X509_EXTENSION_create_by_OBJ(NULL, obj, crit, oct)))
-				goto error;
-
-			ASN1_OBJECT_free(obj);
-			ASN1_STRING_free(oct);
-
-			return 1;
-		}
-
 		if (!(conf = loadconf(L, 3)))
 			goto error;


Add --version -V option for ibus-daemon

Add --version -V option for ibus-daemon

--- bus/main.c
+++ bus/main.c
@@ -48,8 +48,16 @@
 gint   g_monitor_timeout = 0;
 #endif

+static void
+show_version_and_quit (void)
+{
+    g_print ("%s - Version %s\n", g_get_application_name (), VERSION);
+    exit (EXIT_SUCCESS);
+}
+
 static const GOptionEntry entries[] =
 {
+    { "version",   'V', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, show_version_and_quit, "Show the application's version.", NULL },
     { "daemonize", 'd', 0, G_OPTION_ARG_NONE,   &daemonize, "run ibus as background process.", NULL },
     { "single",    's', 0, G_OPTION_ARG_NONE,   &single,    "do not execute panel and config module.", NULL },
     { "xim",       'x', 0, G_OPTION_ARG_NONE,   &xim,       "execute ibus XIM server.", NULL },