Fix req in cudnn_rnn

Fix req in cudnn_rnn

--- src/operator/cudnn_rnn-inl.h
+++ src/operator/cudnn_rnn-inl.h
@@ -186,7 +186,9 @@
     CHECK_EQ(out_data.size(), out_expected);
     CHECK_EQ(in_grad.size(), in_expected);
     CHECK_EQ(out_grad.size(), out_expected);
-
+    CHECK_EQ(req.size(), in_expected);
+    CHECK_NE(req[rnn_enum::kData], kAddTo) << "AddTo is not supported for data";
+    CHECK_NE(req[rnn_enum::kState], kAddTo) << "AddTo is not supported for state";
     Stream<gpu> *s = ctx.get_stream<gpu>();
     // get input + output tensors
     Tensor<gpu, 3, DType> x = in_data[rnn_enum::kData].get<gpu, 3, DType>(s);
@@ -197,7 +199,9 @@
     Tensor<gpu, 3, DType> dhx = in_grad[rnn_enum::kState].get<gpu, 3, DType>(s);
     Tensor<gpu, 3, DType> y = out_data[rnn_enum::kOut].get<gpu, 3, DType>(s);
     Tensor<gpu, 3, DType> dy = out_grad[rnn_enum::kOut].get<gpu, 3, DType>(s);
-
+    if(req[rnn_enum::kParams] != kAddTo) {
+      dw = mshadow::expr::ScalarExp<DType>(0.0f);
+    }
     // only need kStateOut grad output_states is true
     void * dhy_ptr = NULL;
     if (param_.state_outputs)
@@ -209,6 +213,7 @@
     void * cx_ptr = NULL;

     if (param_.mode == rnn_enum::kLstm) {
+      CHECK_NE(req[rnn_enum::kStateCell], kAddTo) << "AddTo is not supported for state cell";
       cx_ptr = (in_data[rnn_enum::kStateCell].get<gpu, 3, DType>(s)).dptr_;
       dcx_ptr = (in_grad[rnn_enum::kStateCell].get<gpu, 3, DType>(s)).dptr_;
     }
@@ -217,8 +222,11 @@

     CHECK_EQ(x.CheckContiguous(), true);
     CHECK_EQ(w.CheckContiguous(), true);
+    CHECK_EQ(dw.CheckContiguous(), true);
     CHECK_EQ(hx.CheckContiguous(), true);
+    CHECK_EQ(dhx.CheckContiguous(), true);
     CHECK_EQ(y.CheckContiguous(), true);
+    CHECK_EQ(dy.CheckContiguous(), true);

     if (!init_cudnn_) {
       Init(s, in_data, out_data);


Prepare multi-process trace generation: -> 	move trace generation after a next-state call, 	such that other GB calls do not interfere 	with receiving all successor states.

--- src/pins2lts-sym/pins2lts-sym.c
+++ src/pins2lts-sym/pins2lts-sym.c
@@ -641,11 +641,19 @@
     vset_clear(guard_tmp[guard]);
 }

+struct trace_action {
+    int *dst;
+    int *cpy;
+    char *action;
+};
+
 struct group_add_info {
     vrel_t rel; // target relation
     vset_t set; // source set
     int group; // which transition group
     int *src; // state vector
+    int trace_count; // number of actions to trace after next-state call
+    struct trace_action *trace_action;
 };

 static void
@@ -695,11 +703,19 @@
                 Warning(info, "found action: %s", action);

                 if (trc_output) {
-                    int group = ctx->group;
-                    int src[N];
-                    vset_example_match(ctx->set,src,r_projs[group].len, r_projs[group].proj,ctx->src);
-
-                    find_action(src,dst,cpy,group,action);
+
+                    ctx->trace_action = (struct trace_action*) realloc(ctx->trace_action, (sizeof(struct trace_action) + sizeof(int[N])*2) * (ctx->trace_count+1));
+
+                    // set the right addresses in the allocated block
+                    ctx->trace_action[ctx->trace_count].dst = (int*) (&ctx->trace_action[ctx->trace_count] + sizeof(struct trace_action));
+                    ctx->trace_action[ctx->trace_count].cpy = (int*) (&ctx->trace_action[ctx->trace_count].dst + sizeof(int[N]));
+
+                    // set the required values in order to find the trace after the next-state call
+                    memcpy(ctx->trace_action[ctx->trace_count].dst, dst, w_projs[ctx->group].len);
+                    memcpy(ctx->trace_action[ctx->trace_count].cpy, cpy, w_projs[ctx->group].len);
+                    ctx->trace_action[ctx->trace_count].action = action;
+
+                    ctx->trace_count++;
                 }

                 // ErrorActions++
@@ -717,7 +733,19 @@
     ctx.set = ((struct group_add_info*)context)->set;
     ctx.rel = rel;
     ctx.src = src;
+    ctx.trace_count = 0;
+    ctx.trace_action = NULL;
     (*transitions_short)(model, ctx.group, src, group_add, &ctx);
+
+    if (ctx.trace_count > 0) {
+        int long_src[N];
+        for (int i = 0; i < ctx.trace_count; i++) {
+            vset_example_match(ctx.set,long_src,r_projs[ctx.group].len, r_projs[ctx.group].proj,src);
+            find_action(long_src,ctx.trace_action[i].dst,ctx.trace_action[i].cpy,ctx.group,ctx.trace_action[i].action);
+        }
+
+        free(ctx.trace_action);
+    }
 }

 #ifdef HAVE_SYLVAN


Fix EOF not advancing pos

Fix EOF not advancing pos

--- svm/parser.c
+++ svm/parser.c
@@ -12,6 +12,7 @@
 char svm_parser_next(svm_parser* p) {
   char c = svm_parser_seek(p);
   if(c == EOF) {
+    p->pos++;
     return EOF;
   }
   p->column++;


use lower case for R (see http://root.cern.ch/phpBB3//viewtopic.php?f=10&t=13521 )

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

--- math/mathcore/inc/TMath.h
+++ math/mathcore/inc/TMath.h
@@ -282,7 +282,7 @@
    Double_t StudentQuantile(Double_t p, Double_t ndf, Bool_t lower_tail=kTRUE);
    Double_t Vavilov(Double_t x, Double_t kappa, Double_t beta2);
    Double_t VavilovI(Double_t x, Double_t kappa, Double_t beta2);
-   Double_t Voigt(Double_t x, Double_t sigma, Double_t lg, Int_t R = 4);
+   Double_t Voigt(Double_t x, Double_t sigma, Double_t lg, Int_t r = 4);

    /* ************************** */
    /* * Statistics over arrays * */


remove unneeded components of RingBuf struct

--- ringbuffer.c
+++ ringbuffer.c
@@ -6,12 +6,6 @@
     /* buffer's size */
     size_t size;

-    /* start of buffer */
-    void * start;
-
-    /* end of buffer */
-    void * end;
-
     /* index of first element in buffer */
     size_t first;

@@ -26,32 +20,30 @@
 };

 RingBuf * ringbuf_new(size_t size) {
-    // declare a ring buffer
+    /* declare a ring buffer */
     RingBuf * ret;

-    // give our buffer some memory
+    /* give our buffer some memory */
     ret = (RingBuf*) malloc(sizeof(RingBuf));
     if (ret == NULL) {
         printf("memory allocation failed!\n");
         exit(EXIT_FAILURE);
     }

-    // give it some more memory so elements can live in it
+    /* give it some more memory so elements can live in it */
     ret->elements = (double *) calloc(size, sizeof(double));
     if (ret->elements == NULL) {
         printf("memory allocation failed!\n");
         exit(EXIT_FAILURE);
     }

-    // set our buffer's properties
+    /* set our buffer's properties */
     ret->size = size;
-    ret->start = &(ret->elements[0]);
-    ret->end = &(ret->elements[size - 1]);
     ret->first = 0;
     ret->last = 0;
     ret->empty = true;

-    // return the buffer
+    /* return the buffer */
     return ret;
 }

@@ -67,7 +59,7 @@
         return;
     }

-    /* special case if the buffer isn't filled yet */
+    /* special case if the buffer isn't full yet */
     if (rngbf->first == 0 && rngbf->last < rngbf->size - 1) {
         rngbf->last++;
         rngbf->elements[rngbf->last] = elem;
@@ -102,7 +94,7 @@
     size_t s;

     /* simply loop over our elements array
-       and see if we get any matches.
+       and see if we get a match.
        since it's unsorted, this is as efficient
        as it gets, without parallelization. */
     for (s = 0; s < rngbf->size; ++s) {


both GCC and C99 support flexible arrays as the last member of a struct (0-length, doesn't add to sizeof)

--- ttbin/ttbin.c
+++ ttbin/ttbin.c
@@ -46,7 +46,7 @@
     int32_t local_time_offset;  /* seconds from UTC */
     uint8_t  _reserved;
     uint8_t  length_count;  /* number of RECORD_LENGTH objects to follow */
-    RECORD_LENGTH lengths[1];
+    RECORD_LENGTH lengths[];
 } FILE_HEADER;

 typedef struct __attribute__((packed))
@@ -301,7 +301,7 @@
     TTBIN_RECORD *record;

     /* check that the file is long enough */
-    if (size < (sizeof(FILE_HEADER) - sizeof(RECORD_LENGTH)))
+    if (size < sizeof(FILE_HEADER))
         return 0;

     if (*data++ != TAG_FILE_HEADER)
@@ -311,7 +311,7 @@
     memset(file, 0, sizeof(TTBIN_FILE));

     file_header = (FILE_HEADER*)data;
-    data += sizeof(FILE_HEADER) + (file_header->length_count - 1) * sizeof(RECORD_LENGTH);
+    data += sizeof(FILE_HEADER) + (file_header->length_count) * sizeof(RECORD_LENGTH);
     file->file_version    = file_header->file_version;
     memcpy(file->firmware_version, file_header->firmware_version, sizeof(file->firmware_version));
     file->product_id      = file_header->product_id;
@@ -529,7 +529,7 @@
     FILE_SUMMARY_RECORD summary;

     /* create and write the file header */
-    size = sizeof(FILE_HEADER) + 29 * sizeof(RECORD_LENGTH);
+    size = sizeof(FILE_HEADER) + 30 * sizeof(RECORD_LENGTH);
     header = (FILE_HEADER*)malloc(size);
     memset(header, 0, size);
     header->file_version = ttbin->file_version;
@@ -538,12 +538,12 @@
     header->start_time = ttbin->timestamp_local;
     header->watch_time = ttbin->timestamp_local;
     header->local_time_offset = ttbin->utc_offset;
-    insert_length_record(header, TAG_FILE_HEADER, sizeof(FILE_HEADER) - sizeof(RECORD_LENGTH));
+    insert_length_record(header, TAG_FILE_HEADER, sizeof(FILE_HEADER));
     insert_length_record(header, TAG_SUMMARY, sizeof(FILE_SUMMARY_RECORD) + 1);
     for (record = ttbin->first; record; record = record->next)
         insert_length_record(header, record->tag, record->length);
     fwrite(&tag, 1, 1, file);
-    fwrite(header, 1, sizeof(FILE_HEADER) + (header->length_count - 1) * sizeof(RECORD_LENGTH), file);
+    fwrite(header, 1, sizeof(FILE_HEADER) + (header->length_count) * sizeof(RECORD_LENGTH), file);

     for (record = ttbin->first; record; record = record->next)
     {


u3: fixes use of system malloc in u3i_chubs

--- pkg/urbit/noun/imprison.c
+++ pkg/urbit/noun/imprison.c
@@ -56,7 +56,9 @@
 u3i_chubs(c3_w        a_w,
             const c3_d* b_d)
 {
-  c3_w *b_w = c3_malloc(a_w * 8);
+  //  XX efficiency
+  //
+  c3_w *b_w = u3a_malloc(a_w * 8);
   c3_w i_w;
   u3_atom p;

@@ -65,7 +67,7 @@
     b_w[(2 * i_w) + 1] = b_d[i_w] >> 32ULL;
   }
   p = u3i_words((a_w * 2), b_w);
-  c3_free(b_w);
+  u3a_free(b_w);
   return p;
 }


add more comment

add more comment

--- exercises/ex08/word_count.c
+++ exercises/ex08/word_count.c
@@ -1,6 +1,9 @@
 /* Simple example using Glib.

-From http://www.ibm.com/developerworks/linux/tutorials/l-glib/
+This program takes in a filename as an arguement, and counts the
+number of times each word in the file appears.
+Written by Thuc Tran
+

 */


u3: refactors u3r_sing internals to use road stack api

--- pkg/urbit/noun/retrieve.c
+++ pkg/urbit/noun/retrieve.c
@@ -230,21 +230,13 @@
 } eqframe;

 static inline eqframe*
-_eq_push(c3_ys mov, c3_ys off, u3_noun a, u3_noun b)
-{
-  u3R->cap_p += mov;
-  eqframe* cur = u3to(eqframe, u3R->cap_p + off);
-  cur->sat_y = SONG_NONE;
-  cur->a     = a;
-  cur->b     = b;
-  return cur;
-}
-
-static inline eqframe*
-_eq_pop(c3_ys mov, c3_ys off)
-{
-  u3R->cap_p -= mov;
-  return u3to(eqframe, u3R->cap_p + off);
+_eq_push(u3a_pile* pil_u, u3_noun a, u3_noun b)
+{
+  eqframe* fam_u = u3a_push(pil_u);
+  fam_u->sat_y   = SONG_NONE;
+  fam_u->a       = a;
+  fam_u->b       = b;
+  return fam_u;
 }

 /* _song_atom(): check if atom [a] is indirect and equal to noun [b]
@@ -296,19 +288,19 @@
  *                 (tightly coupled to _song_x)
  */
 static c3_o
-_song_x_cape(c3_ys mov, c3_ys off,
-             eqframe* fam, eqframe* don,
-             u3p(u3h_root) har_p)
-{
-  u3_noun a, b, key;
-  u3_weak got;
+_song_x_cape(u3a_pile* pil_u, u3p(u3h_root) har_p)
+{
+  eqframe* fam_u = u3a_peek(pil_u);
+  u3_noun   a, b, key;
+  u3_weak   got;
   u3a_cell* a_u;
   u3a_cell* b_u;

-  while ( don != fam ) {
-    a = fam->a;
-    b = fam->b;
-    switch ( fam->sat_y ) {
+  while ( c3n == u3a_pile_done(pil_u) ) {
+    a = fam_u->a;
+    b = fam_u->b;
+
+    switch ( fam_u->sat_y ) {
       case SONG_NONE:
         if ( a == b ) {
           break;
@@ -340,12 +332,14 @@
             got = u3h_get(har_p, key);
             u3t_on(euq_o);
             u3z(key);
+
             if ( u3_none != got ) {
-              fam = _eq_pop(mov, off);
-              continue;
+              fam_u = u3a_pop(pil_u);
             }
-            fam->sat_y = SONG_HEAD;
-            fam = _eq_push(mov, off, a_u->hed, b_u->hed);
+            else {
+              fam_u->sat_y = SONG_HEAD;
+              fam_u = _eq_push(pil_u, a_u->hed, b_u->hed);
+            }
             continue;
           }
         }
@@ -354,8 +348,9 @@
         a_u = u3a_to_ptr(a);
         b_u = u3a_to_ptr(b);
         u3a_wed(&(a_u->hed), &(b_u->hed));
-        fam->sat_y = SONG_TAIL;
-        fam = _eq_push(mov, off, a_u->tel, b_u->tel);
+
+        fam_u->sat_y = SONG_TAIL;
+        fam_u = _eq_push(pil_u, a_u->tel, b_u->tel);
         continue;

       case SONG_TAIL:
@@ -380,7 +375,8 @@
       u3t_on(euq_o);
       u3z(key);
     }
-    fam = _eq_pop(mov, off);
+
+    fam_u = u3a_pop(pil_u);
   }

   return c3y;
@@ -391,30 +387,27 @@
 static c3_o
 _song_x(u3_noun a, u3_noun b)
 {
-  u3p(eqframe) empty = u3R->cap_p;
-
-  c3_y  wis_y  = c3_wiseof(eqframe);
-  c3_o  nor_o  = u3a_is_north(u3R);
-  c3_ys mov    = ( c3y == nor_o ? -wis_y : wis_y );
-  c3_ys off    = ( c3y == nor_o ? 0 : -wis_y );
-  c3_s  ovr_s  = 0;
-  eqframe* fam = _eq_push(mov, off, a, b);
-  eqframe* don = u3to(eqframe, empty + off);
-
-  u3a_cell* a_u;
-  u3a_cell* b_u;
-
-  while ( don != fam ) {
-    a = fam->a;
-    b = fam->b;
-    switch ( fam->sat_y ) {
+  c3_s     ovr_s = 0;
+  u3a_cell*  a_u;
+  u3a_cell*  b_u;
+  eqframe* fam_u;
+  u3a_pile pil_u;
+
+  u3a_pile_prep(&pil_u, sizeof(eqframe));
+  fam_u = _eq_push(&pil_u, a, b);
+
+  while ( c3n == u3a_pile_done(&pil_u) ) {
+    a = fam_u->a;
+    b = fam_u->b;
+
+    switch ( fam_u->sat_y ) {
       case SONG_NONE:
         if ( a == b ) {
           break;
         }
         else if ( c3y == u3a_is_atom(a) ) {
           if ( c3n == _song_atom(a, b) ) {
-            u3R->cap_p = empty;
+            u3R->cap_p = pil_u.top_p;
             return c3n;
           }
           else {
@@ -422,7 +415,7 @@
           }
         }
         else if ( c3y == u3a_is_atom(b) ) {
-          u3R->cap_p = empty;
+          u3R->cap_p = pil_u.top_p;
           return c3n;
         }
         else {
@@ -433,12 +426,12 @@
                (0 != b_u->mug_w) &&
                (a_u->mug_w != b_u->mug_w) )
           {
-            u3R->cap_p = empty;
+            u3R->cap_p = pil_u.top_p;
             return c3n;
           }
           else {
-            fam->sat_y = SONG_HEAD;
-            fam = _eq_push(mov, off, a_u->hed, b_u->hed);
+            fam_u->sat_y = SONG_HEAD;
+            fam_u = _eq_push(&pil_u, a_u->hed, b_u->hed);
             continue;
           }
         }
@@ -447,8 +440,9 @@
         a_u = u3a_to_ptr(a);
         b_u = u3a_to_ptr(b);
         u3a_wed(&(a_u->hed), &(b_u->hed));
-        fam->sat_y = SONG_TAIL;
-        fam = _eq_push(mov, off, a_u->tel, b_u->tel);
+
+        fam_u->sat_y = SONG_TAIL;
+        fam_u = _eq_push(&pil_u, a_u->tel, b_u->tel);
         continue;

       case SONG_TAIL:
@@ -467,12 +461,13 @@
     //
     if ( 0 == ++ovr_s ) {
       u3p(u3h_root) har_p = u3h_new();
-      c3_o ret_o = _song_x_cape(mov, off, fam, don, har_p);
+      c3_o ret_o = _song_x_cape(&pil_u, har_p);
       u3h_free(har_p);
-      u3R->cap_p = empty;
+      u3R->cap_p = pil_u.top_p;
       return ret_o;
     }
-    fam = _eq_pop(mov, off);
+
+    fam_u = u3a_pop(&pil_u);
   }

   return c3y;


Update ServerZoneDef.h

Update ServerZoneDef.h

--- src/common/Network/PacketDef/Zone/ServerZoneDef.h
+++ src/common/Network/PacketDef/Zone/ServerZoneDef.h
@@ -739,9 +739,11 @@
    unsigned char unlockedGuildhests[10];
    unsigned char unlockedTrials[7];
    unsigned char unlockedPvp[5];
-   unsigned char unknownMask72C[28];
-   unsigned char unknownMask748[18];
-   unsigned char unknown75A[22];
+   unsigned char clearedRaids[28];
+   unsigned char clearedDungeons[18];
+   unsigned char clearedGuildhests[10];
+   unsigned char clearedTrials[7];
+   unsigned char clearedPvp[5];

 };


Replace the implementation of RelayCallback by ComposedCallback.

The new method CreateComposedCallback is not yet used, but CreateRelayCallback.
It will be used to clean up boiler plate callbacks in test_util.

BUG=180569
TEST=Ran unit_tests.

Review URL: https://chromiumcodereview.appspot.com/12567003

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@187521 0039d316-1c4b-4281-b951-d872f2087c98

--- chrome/browser/google_apis/task_util.h
+++ chrome/browser/google_apis/task_util.h
@@ -19,101 +19,98 @@

 namespace internal {

-// RelayCallback relays arguments for callback running on the given thread.
-template<typename CallbackType>
-struct RelayCallback;
+// Implementation of the composed callback, whose signature is |Sig|.
+template<typename Sig> struct ComposedCallback;

-// RelayCallback for callback with one argument.
+// ComposedCallback with one argument.
 template<typename T1>
-struct RelayCallback<base::Callback<void(T1)> > {
-  static void Run(scoped_refptr<base::MessageLoopProxy> relay_proxy,
-                  const base::Callback<void(T1)>& callback,
-                  T1 arg1) {
-    if (callback.is_null())
-      return;
-    RunTaskOnThread(relay_proxy, base::Bind(callback, arg1));
+struct ComposedCallback<void(T1)> {
+  static void Run(
+      const base::Callback<void(const base::Closure&)>& runner,
+      const base::Callback<void(T1)>& callback,
+      T1 arg1) {
+    runner.Run(base::Bind(callback, arg1));
   }
 };

-// RelayCallback for callback with two arguments.
+// ComposedCallback with two arguments.
 template<typename T1, typename T2>
-struct RelayCallback<base::Callback<void(T1, T2)> > {
-  static void Run(scoped_refptr<base::MessageLoopProxy> relay_proxy,
-                  const base::Callback<void(T1, T2)>& callback,
-                  T1 arg1,
-                  T2 arg2) {
-    if (callback.is_null())
-      return;
-    RunTaskOnThread(relay_proxy, base::Bind(callback, arg1, arg2));
+struct ComposedCallback<void(T1, T2)> {
+  static void Run(
+      const base::Callback<void(const base::Closure&)>& runner,
+      const base::Callback<void(T1, T2)>& callback,
+      T1 arg1, T2 arg2) {
+    runner.Run(base::Bind(callback, arg1, arg2));
   }
 };

-// RelayCallback for callback with two arguments, the last one is scoped_ptr.
-template<typename T1, typename T2>
-struct RelayCallback<base::Callback<void(T1, scoped_ptr<T2>)> > {
-  static void Run(scoped_refptr<base::MessageLoopProxy> relay_proxy,
-                  const base::Callback<void(T1, scoped_ptr<T2>)>& callback,
-                  T1 arg1,
-                  scoped_ptr<T2> arg2) {
-    if (callback.is_null())
-      return;
-    RunTaskOnThread(relay_proxy,
-                    base::Bind(callback, arg1, base::Passed(&arg2)));
+// ComposedCallback with two arguments, and the last one is scoped_ptr.
+template<typename T1, typename T2, typename D2>
+struct ComposedCallback<void(T1, scoped_ptr<T2, D2>)> {
+  static void Run(
+      const base::Callback<void(const base::Closure&)>& runner,
+      const base::Callback<void(T1, scoped_ptr<T2, D2>)>& callback,
+      T1 arg1, scoped_ptr<T2, D2> arg2) {
+    runner.Run(base::Bind(callback, arg1, base::Passed(&arg2)));
   }
 };

-// RelayCallback for callback with three arguments.
+// ComposedCallback with three arguments.
 template<typename T1, typename T2, typename T3>
-struct RelayCallback<base::Callback<void(T1, T2, T3)> > {
-  static void Run(scoped_refptr<base::MessageLoopProxy> relay_proxy,
-                  const base::Callback<void(T1, T2, T3)>& callback,
-                  T1 arg1,
-                  T2 arg2,
-                  T3 arg3) {
-    if (callback.is_null())
-      return;
-    RunTaskOnThread(relay_proxy, base::Bind(callback, arg1, arg2, arg3));
+struct ComposedCallback<void(T1, T2, T3)> {
+  static void Run(
+      const base::Callback<void(const base::Closure&)>& runner,
+      const base::Callback<void(T1, T2, T3)>& callback,
+      T1 arg1, T2 arg2, T3 arg3) {
+    runner.Run(base::Bind(callback, arg1, arg2, arg3));
   }
 };

-// RelayCallback for callback with three arguments, the last one is scoped_ptr.
-template<typename T1, typename T2, typename T3>
-struct RelayCallback<base::Callback<void(T1, T2, scoped_ptr<T3>)> > {
-  static void Run(scoped_refptr<base::MessageLoopProxy> relay_proxy,
-                  const base::Callback<void(T1, T2, scoped_ptr<T3>)>& callback,
-                  T1 arg1,
-                  T2 arg2,
-                  scoped_ptr<T3> arg3) {
-    if (callback.is_null())
-      return;
-    RunTaskOnThread(relay_proxy,
-                    base::Bind(callback, arg1, arg2, base::Passed(&arg3)));
+// ComposedCallback with three arguments, and the last one is scoped_ptr.
+template<typename T1, typename T2, typename T3, typename D3>
+struct ComposedCallback<void(T1, T2, scoped_ptr<T3, D3>)> {
+  static void Run(
+      const base::Callback<void(const base::Closure&)>& runner,
+      const base::Callback<void(T1, T2, scoped_ptr<T3, D3>)>& callback,
+      T1 arg1, T2 arg2, scoped_ptr<T3, D3> arg3) {
+    runner.Run(base::Bind(callback, arg1, arg2, base::Passed(&arg3)));
   }
 };

-// RelayCallback for callback with four arguments.
+// ComposedCallback with four arguments.
 template<typename T1, typename T2, typename T3, typename T4>
-struct RelayCallback<base::Callback<void(T1, T2, T3, T4)> > {
-  static void Run(scoped_refptr<base::MessageLoopProxy> relay_proxy,
-                  const base::Callback<void(T1, T2, T3, T4)>& callback,
-                  T1 arg1,
-                  T2 arg2,
-                  T3 arg3,
-                  T4 arg4) {
-    if (callback.is_null())
-      return;
-    RunTaskOnThread(relay_proxy, base::Bind(callback, arg1, arg2, arg3, arg4));
+struct ComposedCallback<void(T1, T2, T3, T4)> {
+  static void Run(
+      const base::Callback<void(const base::Closure&)>& runner,
+      const base::Callback<void(T1, T2, T3, T4)>& callback,
+      T1 arg1, T2 arg2, T3 arg3, T4 arg4) {
+    runner.Run(base::Bind(callback, arg1, arg2, arg3, arg4));
   }
 };

 }  // namespace internal

+// Returns callback that takes arguments (arg1, arg2, ...), create a closure
+// by binding them to |callback|, and runs |runner| with the closure.
+// I.e. the returned callback works as follows:
+//   runner.Run(Bind(callback, arg1, arg2, ...))
+template<typename CallbackType>
+CallbackType CreateComposedCallback(
+    const base::Callback<void(const base::Closure&)>& runner,
+    const CallbackType& callback) {
+  DCHECK(!runner.is_null());
+  DCHECK(!callback.is_null());
+  return base::Bind(
+      &internal::ComposedCallback<typename CallbackType::RunType>::Run,
+      runner, callback);
+}
+
 // Returns callback which runs the given |callback| on the current thread.
 template<typename CallbackType>
 CallbackType CreateRelayCallback(const CallbackType& callback) {
-  return base::Bind(&internal::RelayCallback<CallbackType>::Run,
-                    base::MessageLoopProxy::current(),
-                    callback);
+  return CreateComposedCallback(
+      base::Bind(&RunTaskOnThread, base::MessageLoopProxy::current()),
+      callback);
 }

 }  // namespace google_apis


tcpperf: Use OFP_MSG_NBIO instead of OFP_MSG_DONTWAIT.

Signed-off-by: Jere Leppänen <14957520de8d9815e0c353a07fe23c737f0171e9@nokia.com>
Reviewed-by: Sorin Vultureanu <8013ba55f8675034bc2ab0d6c3a1c9650437ca36@enea.com>

--- example/tcpperf/app_main.c
+++ example/tcpperf/app_main.c
@@ -351,7 +351,7 @@
 		int ret;

 		ret = ofp_recv(gbl_args->client_fd, pkt_buf, SOCKET_RX_BUF_LEN,
-			       OFP_MSG_DONTWAIT);
+			       OFP_MSG_NBIO);
 		if (ret < 0 && ofp_errno == OFP_EWOULDBLOCK)
 			continue;

@@ -425,7 +425,7 @@
 			continue;

 		bytes = ofp_recv(gbl_args->client_fd, pkt_buf,
-				 SOCKET_RX_BUF_LEN, OFP_MSG_DONTWAIT);
+				 SOCKET_RX_BUF_LEN, OFP_MSG_NBIO);
 		if (bytes < 0 && ofp_errno == OFP_EWOULDBLOCK)
 			continue;


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

--- magick/shear.c
+++ magick/shear.c
@@ -566,7 +566,7 @@
       return(MagickTrue);
     }
   count=WriteRadonCell(radon_info,i*sizeof(*radon_info->cells),
-    sizeof(*radon_info->cells),(unsigned char *) &value);
+    sizeof(*radon_info->cells),(const unsigned char *) &value);
   if (count != (ssize_t) sizeof(*radon_info->cells))
     return(MagickFalse);
   return(MagickTrue);


wrap a long line

wrap a long line

--- dev/pci/if_xl_pci.c
+++ dev/pci/if_xl_pci.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: if_xl_pci.c,v 1.33 2010/09/04 19:38:16 kettenis Exp $	*/
+/*	$OpenBSD: if_xl_pci.c,v 1.34 2010/09/19 09:22:58 deraadt Exp $	*/

 /*
  * Copyright (c) 1997, 1998, 1999
@@ -101,8 +101,8 @@
 };

 struct cfattach xl_pci_ca = {
-	sizeof(struct xl_pci_softc), xl_pci_match, xl_pci_attach, xl_pci_detach,
-	xl_activate
+	sizeof(struct xl_pci_softc), xl_pci_match, xl_pci_attach,
+	xl_pci_detach, xl_activate
 };

 const struct pci_matchid xl_pci_devices[] = {


Update documentation for esp_avrc_api

Update documentation for esp_avrc_api

Updated documentation for esp_err_t esp_avrc_ct_send_passthrough_cmd to show both pressed and released key states

Merges https://github.com/espressif/esp-idf/pull/846

--- components/bt/bluedroid/api/include/esp_avrc_api.h
+++ components/bt/bluedroid/api/include/esp_avrc_api.h
@@ -136,7 +136,7 @@
  * @param[in]       tl : transaction label, 0 to 15, consecutive commands should use different values.
  * @param[in]       key_code : passthrough command code, e.g. ESP_AVRC_PT_CMD_PLAY, ESP_AVRC_PT_CMD_STOP, etc.
  * @param[in]       key_state : passthrough command key state, ESP_AVRC_PT_CMD_STATE_PRESSED or
- *                  ESP_AVRC_PT_CMD_STATE_PRESSED
+ *                  ESP_AVRC_PT_CMD_STATE_RELEASED
  *
  * @return
  *                  - ESP_OK: success


cherry: do not use the cached VBUS value

Ignore the cached value in case of the FRS happening and
let the cached VBUS status outdated.

BUG=b:234352018
TEST=unplug FRS hub with adapter connected, and the VBUS supplier
     disappeared.
BRANCH=cherry

Change-Id: Ie87734976fc24eb1618e166d9eca0462f97d6ab8
Signed-off-by: Eric Yilun Lin <2f2733c7206ea2b76bd2db1905cc5e8a75841c48@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3747171
Auto-Submit: Eric Yilun Lin <2f2733c7206ea2b76bd2db1905cc5e8a75841c48@google.com>
Reviewed-by: Ting Shen <c671d3efec3d7e7e285f3788bf0d1ba4c8605b78@chromium.org>
Commit-Queue: Ting Shen <c671d3efec3d7e7e285f3788bf0d1ba4c8605b78@chromium.org>
Tested-by: Eric Yilun Lin <2f2733c7206ea2b76bd2db1905cc5e8a75841c48@google.com>

--- baseboard/cherry/usb_pd_policy.c
+++ baseboard/cherry/usb_pd_policy.c
@@ -203,16 +203,11 @@

 void pd_power_supply_reset(int port)
 {
-	int prev_en;
-
-	prev_en = ppc_is_sourcing_vbus(port);
-
 	/* Disable VBUS. */
 	ppc_vbus_source_enable(port, 0);

 	/* Enable discharge if we were previously sourcing 5V */
-	if (prev_en)
-		pd_set_vbus_discharge(port, 1);
+	pd_set_vbus_discharge(port, 1);

 	if (port == 1)
 		rt1718s_gpio_set_level(port, GPIO_EN_USB_C1_5V_OUT, 0);


remove loop in blank_as?

remove loop in blank_as?

--- ext/fast_blank/fast_blank.c
+++ ext/fast_blank/fast_blank.c
@@ -12,12 +12,6 @@
 #ifndef RSTRING_LEN
 #define RSTRING_LEN(s) (RSTRING(s)->len)
 #endif
-
-const unsigned int as_blank[26] = {9, 0xa, 0xb, 0xc, 0xd,
-  0x20, 0x85, 0xa0, 0x1680, 0x180e, 0x2000, 0x2001,
-  0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008,
-  0x2009, 0x200a, 0x2028, 0x2029, 0x202f, 0x205f, 0x3000
-};

 static VALUE
 rb_str_blank_as(VALUE str)
@@ -36,19 +30,38 @@
     int n;
     unsigned int cc = rb_enc_codepoint_len(s, e, &n, enc);

-    found = 0;
-    for(i=0;i<26;i++){
-      unsigned int current = as_blank[i];
-      if(current == cc) {
-        found = 1;
-        break;
-      }
-      if(cc < current){
-        break;
-      }
+    switch (cc) {
+      case 9:
+      case 0xa:
+      case 0xb:
+      case 0xc:
+      case 0xd:
+      case 0x20:
+      case 0x85:
+      case 0xa0:
+      case 0x1680:
+      case 0x180e:
+      case 0x2000:
+      case 0x2001:
+      case 0x2002:
+      case 0x2003:
+      case 0x2004:
+      case 0x2005:
+      case 0x2006:
+      case 0x2007:
+      case 0x2008:
+      case 0x2009:
+      case 0x200a:
+      case 0x2028:
+      case 0x2029:
+      case 0x202f:
+      case 0x205f:
+      case 0x3000:
+          /* found */
+          break;
+      default:
+          return Qfalse;
     }
-
-    if (!found) return Qfalse;
     s += n;
   }
   return Qtrue;


Small suffixcmp optimization

Small suffixcmp optimization

--- internal.h
+++ internal.h
@@ -102,8 +102,8 @@

 static inline int suffixcmp(const char one[], const char two[]) {

-	const u16 len1 = strlen(one);
-	const u16 len2 = strlen(two);
+	const u16 len1 = one[1] ? 2 : 1;
+	const u16 len2 = two[1] ? 2 : 1;

 	if (len1 == len2)
 		return strcmp(one, two) != 0;


Maybe this fixes the transfer encoding issue. ¯\_(ツ)_/¯

--- pkg/urbit/vere/http.c
+++ pkg/urbit/vere/http.c
@@ -514,11 +514,16 @@
                       "hosed";

   u3_hhed* hed_u = _http_heds_from_noun(u3k(headers));
-
+  int has_content_length = 0;
   while ( 0 != hed_u ) {
     h2o_add_header_by_str(&rec_u->pool, &rec_u->res.headers,
                           hed_u->nam_c, hed_u->nam_w, 0, 0,
                           hed_u->val_c, hed_u->val_w);
+
+    if (strncmp(hed_u->nam_c, "content-length", 14) == 0) {
+      has_content_length = 1;
+    }
+
     hed_u = hed_u->nex_u;
   }

@@ -532,6 +537,10 @@
   gen_u->nud_u = 0;
   gen_u->hed_u = hed_u;
   gen_u->req_u = req_u;
+
+  if (has_content_length) {
+    rec_u->res.content_length = gen_u->bod_u ? gen_u->bod_u->len_w : 0;
+  }

   req_u->gen_u = gen_u;


pkg/lwip: Add empty netif_setopt

pkg/lwip: Add empty netif_setopt

To fully implement net/netif.h

--- pkg/lwip/contrib/_netif.c
+++ pkg/lwip/contrib/_netif.c
@@ -71,4 +71,16 @@
     return res;
 }

+int netif_set_opt(netif_t *iface, netopt_t opt, uint16_t context,
+                  void *value, size_t value_len)
+{
+    (void)iface;
+    (void)opt;
+    (void)context;
+    (void)value;
+    (void)value_len;
+
+    return -ENOTSUP;
+}
+
 /** @} */


Doxygen comment improvement

Doxygen comment improvement

git-svn-id: 1a57124bbb9aca193a920d0ffd753d488afb922b@1883 5946f024-35f4-0310-b1b3-9a3be3380cfb

--- lib/refcounted.h
+++ lib/refcounted.h
@@ -51,6 +51,15 @@
 /// be "owned" by disparate parties: you can allocate the object just
 /// once, then pass around the reference counted pointer, knowing that
 /// the last user will "turn out the lights".
+///
+/// \b Implementation \b detail: You may notice that this class manages
+/// two pointers, one to the data we're managing, and one to the
+/// reference count.  You might wonder why we don't wrap these up into a
+/// structure and keep just a pointer to an instance of it to simplify
+/// the memory management.  It would indeed do that, but then every
+/// access to the data we manage would be a triple indirection instead
+/// of just double.  It's a tradeoff, and we've chosen to take a minor
+/// complexity hit to avoid the performance hit.

 template <class T>
 class RefCountedPointer


pkg/tinyusb/hw: add ULPI HS PHY for STM32

--- pkg/tinyusb/hw/hw_stm32.c
+++ pkg/tinyusb/hw/hw_stm32.c
@@ -32,50 +32,113 @@
     pm_block(STM32_PM_STOP);
     pm_block(STM32_PM_STANDBY);

+#if defined(PWR_CR2_USV) /* on L4 */
+    /* Validate USB Supply */
+    PWR->CR2 |= PWR_CR2_USV;
+#endif /* PWR_CR2_USV */
+
     /* Enable the clock to the peripheral */
     periph_clk_en(conf->ahb, conf->rcc_mask);

+#ifndef MODULE_PERIPH_USBDEV_HS_ULPI
     /* Enables clock on the GPIO bus */
     gpio_init(conf->dp, GPIO_IN);
     gpio_init(conf->dm, GPIO_IN);
     /* Configure AF for the pins */
     gpio_init_af(conf->dp, conf->af);
     gpio_init_af(conf->dm, conf->af);
+#endif /* MODULE_PERIPH_USBDEV_HS_ULPI */

-#if 0 /* TODO we don't use USB ID pin for now */
-    gpio_init(conf->id, GPIO_IN);
-#endif
-
-#ifdef USB_OTG_GCCFG_NOVBUSSENS
-#if 0 /* TODO V_USB sensing pin */
-    gpio_init(conf->vbus, GPIO_OD_PU);
-    gpio_init_af(conf->vbus, conf->af);
-
-    USB_OTG_GlobalTypeDef *global_regs =
-         (USB_OTG_GlobalTypeDef *)(conf->periph + USB_OTG_GLOBAL_BASE);
-
-    global_regs->GCCFG &= ~USB_OTG_GCCFG_NOVBUSSENS;
-    global_regs->GCCFG |= USB_OTG_GCCFG_VBUSBSEN;
-#else
-    /* Enable no Vbus sensing and enable `Power Down Disable` */
     USB_OTG_GlobalTypeDef *global_regs =
                 (USB_OTG_GlobalTypeDef *)(conf->periph + USB_OTG_GLOBAL_BASE);

+#ifdef USB_OTG_GCCFG_NOVBUSSENS
     /* Enable no Vbus Detect enable and enable `Power Down Disable` */
-    global_regs->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS | USB_OTG_GCCFG_PWRDWN;
+    global_regs->GCCFG |= USB_OTG_GCCFG_NOVBUSSENS;
 #endif
-#endif /* USB_OTG_GCCFG_NOVBUSSENS */

 #ifdef DWC2_USB_OTG_HS_ENABLED
     if (conf->type == DWC2_USB_OTG_HS) {
-        /* Disable the ULPI clock in low power mode, this is essential for the
-         * peripheral when using the built-in phy */
-        periph_lpclk_dis(conf->ahb, RCC_AHB1LPENR_OTGHSULPILPEN);
-        /* Only the built-in phy supported for now */
-        assert(conf->phy == DWC2_USB_OTG_PHY_BUILTIN);
-        global_regs->GUSBCFG |= USB_OTG_GUSBCFG_PHYSEL;
+        if (conf->phy == DWC2_USB_OTG_PHY_BUILTIN) {
+            /* set `Power Down Disable` to activate the on-chip FS transceiver */
+            global_regs->GCCFG |= USB_OTG_GCCFG_PWRDWN;
+            /* Disable the ULPI clock in low power mode, this is essential for the
+             * peripheral when using the built-in PHY */
+            periph_lpclk_dis(conf->ahb, RCC_AHB1LPENR_OTGHSULPILPEN);
+            /* select on-chip builtin PHY */
+            global_regs->GUSBCFG |= USB_OTG_GUSBCFG_PHYSEL;
+        }
+#ifdef MODULE_PERIPH_USBDEV_HS_ULPI
+        else if (conf->phy == DWC2_USB_OTG_PHY_ULPI) {
+            /* initialize ULPI interface */
+            gpio_init(conf->ulpi_clk, GPIO_IN);
+            gpio_init(conf->ulpi_d0, GPIO_IN);
+            gpio_init(conf->ulpi_d1, GPIO_IN);
+            gpio_init(conf->ulpi_d2, GPIO_IN);
+            gpio_init(conf->ulpi_d3, GPIO_IN);
+            gpio_init(conf->ulpi_d4, GPIO_IN);
+            gpio_init(conf->ulpi_d5, GPIO_IN);
+            gpio_init(conf->ulpi_d6, GPIO_IN);
+            gpio_init(conf->ulpi_d7, GPIO_IN);
+            gpio_init(conf->ulpi_stp, GPIO_IN);
+            gpio_init(conf->ulpi_dir, GPIO_IN);
+            gpio_init(conf->ulpi_nxt, GPIO_IN);
+            gpio_init_af(conf->ulpi_clk, conf->ulpi_af);
+            gpio_init_af(conf->ulpi_d0, conf->ulpi_af);
+            gpio_init_af(conf->ulpi_d1, conf->ulpi_af);
+            gpio_init_af(conf->ulpi_d2, conf->ulpi_af);
+            gpio_init_af(conf->ulpi_d3, conf->ulpi_af);
+            gpio_init_af(conf->ulpi_d4, conf->ulpi_af);
+            gpio_init_af(conf->ulpi_d5, conf->ulpi_af);
+            gpio_init_af(conf->ulpi_d6, conf->ulpi_af);
+            gpio_init_af(conf->ulpi_d7, conf->ulpi_af);
+            gpio_init_af(conf->ulpi_stp, conf->ulpi_af);
+            gpio_init_af(conf->ulpi_dir, conf->ulpi_af);
+            gpio_init_af(conf->ulpi_nxt, conf->ulpi_af);
+
+            /* enable ULPI clock */
+            periph_clk_en(conf->ahb, RCC_AHB1ENR_OTGHSULPIEN);
+
+#ifdef USB_OTG_GUSBCFG_ULPI_UTMI_SEL
+            /* select ULPI PHY */
+            global_regs->GUSBCFG |= USB_OTG_GUSBCFG_ULPI_UTMI_SEL;
+#endif
+#ifdef USB_OTG_GUSBCFG_PHYIF
+            /* use the 8-bit interface */
+            global_regs->GUSBCFG &= ~USB_OTG_GUSBCFG_PHYIF;
+#endif /* USB_OTG_GUSBCFG_PHYIF */
+#ifdef USB_OTG_GUSBCFG_DDRSEL
+            /* use single data rate */
+            global_regs->GUSBCFG &= ~USB_OTG_GUSBCFG_DDRSEL;
+#endif /* USB_OTG_GUSBCFG_DDRSEL */
+
+            /* disable the on-chip FS transceiver */
+            global_regs->GUSBCFG &= ~USB_OTG_GUSBCFG_PHYSEL;
+
+            /* use internal V_BUS valid indicator and internal charge pump */
+            global_regs->GUSBCFG &= ~(USB_OTG_GUSBCFG_ULPIEVBUSD |
+                                                       USB_OTG_GUSBCFG_ULPIEVBUSI);
+            /* disable ULPI FS/LS serial interface */
+            global_regs->GUSBCFG &= ~USB_OTG_GUSBCFG_ULPIFSLS;
+        }
+
+#else /* MODULE_PERIPH_USBDEV_HS_ULPI */
+        else {
+            /* only on-chip PHY support enabled */
+            assert(conf->phy == DWC2_USB_OTG_PHY_BUILTIN);
+        }
+#endif /* MODULE_PERIPH_USBDEV_HS_ULPI */
     }
-#endif
+#endif /* DWC2_USB_OTG_HS_ENABLED */
+
+    if (conf->phy == DWC2_USB_OTG_PHY_BUILTIN) {
+        /* set `Power Down Disable` to activate the on-chip FS transceiver */
+        global_regs->GCCFG |= USB_OTG_GCCFG_PWRDWN;
+    }
+    else {
+        /* clear `Power Down Disable` to deactivate the on-chip FS transceiver */
+        global_regs->GCCFG &= ~USB_OTG_GCCFG_PWRDWN;
+    }

     return 0;
 }


tests: schedule_api: lengthen interval for slicing reset test

When calculating the expected interval for threads other than
the first one, the test uses ms->ticks->cycles conversion to
figure out the bound of cycles permitted. Both lower and upper
bound conversions are using the k_*_to_*_floor32(). When
numbers involved are not wholly divisible, decimal points are
being truncated, resulting in incorrect intervals, and thus
failing tests. So change the calculation to appropriate
floor() or ceil() based on the boundary.

Signed-off-by: Daniel Leung <d94e04d205b5962d7873a139ef298b03c1717f72@intel.com>

--- tests/kernel/sched/schedule_api/src/test_sched_timeslice_reset.c
+++ tests/kernel/sched/schedule_api/src/test_sched_timeslice_reset.c
@@ -71,13 +71,13 @@
 		 * also expecting task switch below the switching tolerance.
 		 */
 		expected_slice_min =
-			(k_ms_to_ticks_ceil32(SLICE_SIZE)
+			(k_ms_to_ticks_floor32(SLICE_SIZE)
 			 - switch_tolerance_ticks)
 			* k_ticks_to_cyc_floor32(1);
 		expected_slice_max =
 			(k_ms_to_ticks_ceil32(SLICE_SIZE)
 			 + switch_tolerance_ticks)
-			* k_ticks_to_cyc_floor32(1);
+			* k_ticks_to_cyc_ceil32(1);
 	}

 #ifdef CONFIG_DEBUG


Put smtp small in connection specific smtp window.

pmo-trunk-r7468

--- src/hildon2/modest-connection-specific-smtp-edit-window.c
+++ src/hildon2/modest-connection-specific-smtp-edit-window.c
@@ -321,6 +321,7 @@
 	ModestConnectionSpecificSmtpEditWindowPrivate *priv;
 	GtkWidget *dialog_box;
 	GtkWidget *pannable, *vbox;
+	gchar *server_label;

 	/* The title of this dialog is quite long, so make the window wide enough */
 	gtk_widget_set_size_request (GTK_WIDGET (self), 600, 320);
@@ -344,11 +345,14 @@
 	/* Auto-capitalization is the default, so let's turn it off: */
 	hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_outgoingserver), HILDON_GTK_INPUT_MODE_FULL);
 	g_signal_connect(G_OBJECT(priv->entry_outgoingserver), "changed", G_CALLBACK(on_change), self);
+
+	server_label = g_strconcat (_("mcen_li_emailsetup_smtp"), "\n<small>(SMTP)</small>", NULL);

 	GtkWidget *captioned =
 	  modest_maemo_utils_create_captioned (title_sizegroup, value_sizegroup,
-					       _("mcen_li_emailsetup_smtp"), FALSE,
+					       server_label, TRUE,
 					       priv->entry_outgoingserver);
+	g_free (server_label);
 	gtk_widget_show (priv->entry_outgoingserver);
 	gtk_box_pack_start (GTK_BOX (vbox), captioned, FALSE, FALSE, MODEST_MARGIN_HALF);
 	gtk_widget_show (captioned);


samples/zoap_client: Use token generator helper

Change-Id: If3dfe80deb8ff753fecae539032399deb15279ee
Signed-off-by: Vinicius Costa Gomes <540a5b73c8ed8ee3381dfb54c1949e767fadd754@intel.com>

--- samples/net/zoap_client/src/zoap-client.c
+++ samples/net/zoap_client/src/zoap-client.c
@@ -201,6 +201,7 @@
 	zoap_header_set_type(&request, ZOAP_TYPE_CON);
 	zoap_header_set_code(&request, ZOAP_METHOD_GET);
 	zoap_header_set_id(&request, zoap_next_id());
+	zoap_header_set_token(&request, zoap_next_token(), 8);

 	/* Enable observing the resource. */
 	r = zoap_add_option(&request, ZOAP_OPTION_OBSERVE,


layout=index: If MAILBOX_LIST_FLAG_NO_MAIL_FILES is set, don't try to delete any mail files.

--- src/lib-storage/list/mailbox-list-index-backend.c
+++ src/lib-storage/list/mailbox-list-index-backend.c
@@ -424,7 +424,9 @@
 	if (ret <= 0)
 		return ret;

-	if ((_list->flags & MAILBOX_LIST_FLAG_MAILBOX_FILES) != 0) {
+	if ((_list->flags & MAILBOX_LIST_FLAG_NO_MAIL_FILES) != 0) {
+		ret = 0;
+	} else if ((_list->flags & MAILBOX_LIST_FLAG_MAILBOX_FILES) != 0) {
 		ret = mailbox_list_delete_mailbox_file(_list, name, path);
 	} else {
 		ret = mailbox_list_delete_mailbox_nonrecursive(_list, name,


- Minor fixes

- Minor fixes

--- include/coffee/core/plat/environment/application_start.h
+++ include/coffee/core/plat/environment/application_start.h
@@ -6,7 +6,6 @@

 #ifdef COFFEE_ANDROID
 #include <SDL2/SDL.h>
-struct android_app;
 #endif

 int deref_main(Coffee::CoffeeMainWithArgs mainfun, int argc, char** argv);


some cleanup

some cleanup

[r17415]

--- ir/be/ia32/ia32_finish.c
+++ ir/be/ia32/ia32_finish.c
@@ -120,6 +120,7 @@
 		const ir_edge_t *edge;

 		if(get_irn_mode(irn) == mode_T) {
+			/* collect the Proj uses */
 			foreach_out_edge(irn, edge) {
 				ir_node *proj = get_edge_src_irn(edge);
 				long     pn   = get_Proj_proj(proj);
@@ -156,7 +157,15 @@
 			ir_node *stc, *cmc, *not, *adc;
 			ir_node *adc_flags;

-			/* ARG, the above technique does NOT set the flags right */
+			/*
+			 * ARG, the above technique does NOT set the flags right.
+			 * So, we must produce the following code:
+			 * t1 = ~b
+			 * t2 = a + ~b + Carry
+			 * Complement Carry
+			 *
+			 * a + -b = a + (~b + 1)  would sat the carry flag IF a == b ...
+			 */
 			not = new_rd_ia32_Not(dbg, irg, block, in2);
 			arch_set_irn_register(cg->arch_env, not, in2_reg);
 			sched_add_before(irn, not);
@@ -165,7 +174,6 @@
 			arch_set_irn_register(cg->arch_env, res,
 			                      &ia32_flags_regs[REG_EFLAGS]);

-			/* generate the adc */
 			adc = new_rd_ia32_Adc(dbg, irg, block, noreg, noreg, nomem, not,
 			                      in1, stc);
 			arch_set_irn_register(cg->arch_env, adc, out_reg);
@@ -209,14 +217,20 @@
 		! is_ia32_CMov(irn);
 }

+/**
+ * Returns the index of the "same" register.
+ * On the x86, we should have only one.
+ */
 static int get_first_same(const arch_register_req_t* req)
 {
 	const unsigned other = req->other_same;
 	int i;

-	for (i = 0;; ++i) {
+	for (i = 0; i < 32; ++i) {
 		if (other & (1U << i)) return i;
 	}
+	assert(! "same position not found");
+	return 32;
 }

 /**
@@ -233,17 +247,7 @@
 	const arch_register_t      *out_reg, *in_reg;
 	int                         n_res, i;
 	ir_node                    *in_node, *block;
-	ia32_op_type_t              op_tp;
-
-	if(!is_ia32_irn(node))
-		return;
-
-	/* some nodes are just a bit less efficient, but need no fixing if the
-	 * should be same requirement is not fulfilled */
-	if(!need_constraint_copy(node))
-		return;
-
-	op_tp = get_ia32_op_type(node);
+
 	reqs  = get_ia32_out_req_all(node);
 	n_res = get_ia32_n_res(node);
 	block = get_nodes_block(node);
@@ -328,7 +332,7 @@
 		}

 		/* for commutative nodes we can simply swap the left/right */
-		if(is_ia32_commutative(node) && uses_out_reg_pos == n_ia32_binary_right) {
+		if (uses_out_reg_pos == n_ia32_binary_right && is_ia32_commutative(node)) {
 			ia32_swap_left_right(node);
 			DBG((dbg, LEVEL_1, "swapped left/right input of %+F to resolve "
 	   		     "should be same constraint\n", node));
@@ -516,7 +520,12 @@
 	/* second: insert copies and finish irg */
 	for (irn = sched_first(block); ! sched_is_end(irn); irn = next) {
 		next = sched_next(irn);
-		assure_should_be_same_requirements(cg, irn);
+		if (is_ia32_irn(irn)) {
+			/* some nodes are just a bit less efficient, but need no fixing if the
+			 * should be same requirement is not fulfilled */
+			if (need_constraint_copy(irn))
+				assure_should_be_same_requirements(cg, irn);
+		}
 	}
 }


Fixed gcc build break due to nested templates (>> should be > >)
TBR=ojan
Review URL: http://codereview.chromium.org/12841

git-svn-id: http://src.chromium.org/svn/trunk/src@6173 4ff67af0-8c30-449e-8e8b-ad334ec8d88c

Former-commit-id: 48901492d10bcda7baab17b62c4fda6640f2ca54

--- media/base/buffers.h
+++ media/base/buffers.h
@@ -122,7 +122,7 @@
 // pointer of the object to receive the OnAssignment callback.
 template <class OwnerType, class BufferType>
 class AssignableBuffer : public AssignableInterface<BufferType>,
-    public base::RefCountedThreadSafe<AssignableBuffer<OwnerType, BufferType>> {
+    public base::RefCountedThreadSafe<AssignableBuffer<OwnerType, BufferType> > {
  public:
   explicit AssignableBuffer(OwnerType* owner)
     : owner_(owner),


Fixed small name problem from merging.

Fixed small name problem from merging.

git-svn-id: 28d9401aa571d5108e51b194aae6f24ca5964c06@22526 8cc4aa7f-3514-0410-904f-f2cc9021211c

--- plugins/aws2/functor.h
+++ plugins/aws2/functor.h
@@ -124,10 +124,10 @@
     bool bind();

   public:
-    function():object(T_FUNCTION), rv(0), parent(0), scope(0), repr_exec(false) {}
+    function():object(T_FUNCTION), rv(0), parent(0), sc(0), repr_exec(false) {}

     function(const std::string &_name, bool _exec_on_represent=false)
-    	: object(T_FUNCTION), rv(0), parent(0), scope(0), repr_exec(_exec_on_represent)
+    	: object(T_FUNCTION), rv(0), parent(0), sc(0), repr_exec(_exec_on_represent)
     {
       scfString s (_name.c_str());
       SetName (&s);
@@ -135,7 +135,7 @@

     /** Copy constructor: does NOT copy the return value or the parameters! */
     function(const function& func):iObject(), object(T_FUNCTION), rv(0),
-    	parent(0), scope(0), repr_exec(func.repr_exec), Called(func.Called) {}
+    	parent(0), sc(0), repr_exec(func.repr_exec), Called(func.Called) {}

     /** Signal fired when function is called. */
     signal Called;


TCPMv2: Clear unhandled DPM Requests

TCPMv2: Clear unhandled DPM Requests

Connecting Kohaku to Trembyle for DUT-DUT
charging was getting really chatty on attach
due to an unsupported DPM Request that was
not being cleared.  This will clear the
unsupported DPM Request so only one message
will be output

BUG=b:160009733
BRANCH=none
TEST=Kohaku-Trembyle USB-C connection

Signed-off-by: Denis Brockus <6b21e8190fb5e373363fb95271367073a16474ef@google.com>
Change-Id: I4f4036de3c9559d9e1b175fdbeab19c00ca84c8d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2270997
Tested-by: Denis Brockus <6b21e8190fb5e373363fb95271367073a16474ef@chromium.org>
Reviewed-by: Diana Z <cb2016afc7183e5356c690dc63b4ba817470501a@chromium.org>
Commit-Queue: Diana Z <cb2016afc7183e5356c690dc63b4ba817470501a@chromium.org>
Auto-Submit: Denis Brockus <6b21e8190fb5e373363fb95271367073a16474ef@chromium.org>

--- common/usbc/usb_pe_drp_sm.c
+++ common/usbc/usb_pe_drp_sm.c
@@ -2077,6 +2077,8 @@
 					DPM_REQUEST_SOURCE_CAP);

 		if (pe[port].dpm_request) {
+			uint32_t dpm_request = pe[port].dpm_request;
+
 			PE_SET_FLAG(port, PE_FLAGS_LOCALLY_INITIATED_AMS);

 			if (PE_CHK_DPM_REQUEST(port, DPM_REQUEST_DR_SWAP)) {
@@ -2102,9 +2104,10 @@
 						DPM_REQUEST_SEND_PING)) {
 				PE_CLR_DPM_REQUEST(port, DPM_REQUEST_SEND_PING);
 				set_state_pe(port, PE_SRC_PING);
-			}  else if (!common_src_snk_dpm_requests(port)) {
+			} else if (!common_src_snk_dpm_requests(port)) {
 				CPRINTF("Unhandled DPM Request %x received\n",
-					pe[port].dpm_request);
+					dpm_request);
+				PE_CLR_DPM_REQUEST(port, dpm_request);
 				PE_CLR_FLAG(port,
 					PE_FLAGS_LOCALLY_INITIATED_AMS);
 			}
@@ -2831,6 +2834,8 @@
 					DPM_REQUEST_SEND_PING);

 		if (pe[port].dpm_request) {
+			uint32_t dpm_request = pe[port].dpm_request;
+
 			PE_SET_FLAG(port, PE_FLAGS_LOCALLY_INITIATED_AMS);

 			if (PE_CHK_DPM_REQUEST(port, DPM_REQUEST_DR_SWAP)) {
@@ -2860,7 +2865,8 @@
 				set_state_pe(port, PE_DR_SNK_GET_SINK_CAP);
 			} else if (!common_src_snk_dpm_requests(port)) {
 				CPRINTF("Unhandled DPM Request %x received\n",
-					pe[port].dpm_request);
+					dpm_request);
+				PE_CLR_DPM_REQUEST(port, dpm_request);
 				PE_CLR_FLAG(port,
 					PE_FLAGS_LOCALLY_INITIATED_AMS);
 			}