add comments

add comments

--- Drivers/gpio.c
+++ Drivers/gpio.c
@@ -14,122 +14,414 @@

 /*******************************   FUNCTIONS    *******************************/
 /**** GPIO 1 ****/
+
+    /**** GPIO 3-State ****/
+
+/******************************************************************************/
+/**
+* Set the direction of the GPIO on the channel 1
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+* @param    value is the direction of the gpio (0 for output, 1 input).
+*
+* @return   None.
+*
+* @note     bit 0 corresponding to the pin 0, bit 1 to the pin 1...
+*
+*******************************************************************************/
 inline void gpio_tri_dir(axi_gpio_t * axi, uint32_t value)
 {
     axi->GPIO_TRI = value;
 }

+/******************************************************************************/
+/**
+* Set the specified pin of the GPIO as output on the channel 1
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+* @param    value is the pin to be set as output.
+*
+* @return   None.
+*
+* @note     bit 0 corresponding to the pin 0, bit 1 to the pin 1...
+*
+*******************************************************************************/
 inline void gpio_tri_output(axi_gpio_t * axi, uint32_t value)
 {
     axi->GPIO_TRI &= ~value;
 }

+/******************************************************************************/
+/**
+* Set the specified pin of the GPIO as input on the channel 1
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+* @param    value is the pin to be set as input.
+*
+* @return   None.
+*
+* @note     bit 0 corresponding to the pin 0, bit 1 to the pin 1...
+*
+*******************************************************************************/
 inline void gpio_tri_input(axi_gpio_t * axi, uint32_t value)
 {
     axi->GPIO_TRI |= value;
 }

-inline void gpio_interrupt_enbale(axi_gpio_t * axi, uint8_t value)
-{
-    axi->IP_IER |= value&GPIO_IP_IER_CH1;
-}
-
-inline void gpio_interrupt_disable(axi_gpio_t * axi, uint8_t value)
-{
-    axi->IP_IER &= ~(value&GPIO_IP_IER_CH1);
-}
-
+    /**** GPIO Interrupt ****/
+
+/******************************************************************************/
+/**
+* Enable the interruption for the channel 1
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+*
+* @return   None.
+*
+* @note     interruption are enable on all the pin (no choice)
+*
+*******************************************************************************/
+inline void gpio_interrupt_enbale(axi_gpio_t * axi)
+{
+    axi->IP_IER |= GPIO_IP_IER_CH1;
+}
+
+/******************************************************************************/
+/**
+* Disable the interruption for the channel 1
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+*
+* @return   None.
+*
+* @note     interruption are disable on all the pin (no choice)
+*
+*******************************************************************************/
+inline void gpio_interrupt_disable(axi_gpio_t * axi)
+{
+    axi->IP_IER &= ~GPIO_IP_IER_CH1;
+}
+
+/******************************************************************************/
+/**
+* Get the interruption status for the channel 1
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+*
+* @return   None.
+*
+* @note     0 = No Channel 1 input interrupt; 1 = Channel 1 input interrupt
+*
+*******************************************************************************/
 inline uint32_t gpio_interrupt_status(axi_gpio_t * axi)
 {
     return axi->IP_ISR&GPIO_IP_ISR_CH1;
 }

-inline void gpio_interrupt_clear(axi_gpio_t * axi, uint32_t value)
-{
-    axi->IP_ISR &= value&GPIO_IP_ISR_CH1;
-}
-
+/******************************************************************************/
+/**
+* Clear interruption status for the channel 1
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+*
+* @return   None.
+*
+* @note     None.
+*
+*******************************************************************************/
+inline void gpio_interrupt_clear(axi_gpio_t * axi)
+{
+    axi->IP_ISR &= GPIO_IP_ISR_CH1;
+}
+
+    /**** GPIO R/W ****/
+
+/******************************************************************************/
+/**
+* Write on the channel 1 of the GPIO
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+* @param    value is the value to be write on the gpio.
+*
+* @return   None.
+*
+* @note     1 = VCC ; 0 = GND.
+*
+*******************************************************************************/
 inline void gpio_write(axi_gpio_t * axi, uint32_t value)
 {
     axi->GPIO_DATA = value;
 }

+/******************************************************************************/
+/**
+* Set the specified pin of the channel 1
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+* @param    value is the pin that must be set.
+*
+* @return   None.
+*
+* @note     1 = VCC ; 0 = GND.
+*
+*******************************************************************************/
 inline void gpio_set(axi_gpio_t * axi, uint32_t value)
 {
     axi->GPIO_DATA |= value;
 }

+/******************************************************************************/
+/**
+* Clear the specified pin of the channel 1
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+* @param    value is the pin that must be clear.
+*
+* @return   None.
+*
+* @note     1 = VCC ; 0 = GND.
+*
+*******************************************************************************/
 inline void gpio_clear(axi_gpio_t * axi, uint32_t value)
 {
     axi->GPIO_DATA &= ~value;
 }

+/******************************************************************************/
+/**
+* Toggle the specified pin of the channel 1
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+* @param    value is the pin that must be toggle.
+*
+* @return   None.
+*
+* @note     1 = VCC ; 0 = GND.
+*
+*******************************************************************************/
 inline void gpio_toggle(axi_gpio_t * axi, uint32_t value)
 {
     axi->GPIO_DATA ^= value;
 }

+/******************************************************************************/
+/**
+* Read the value of the GPIO on the channel 1
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+*
+* @return   The value of the GPIO.
+*
+* @note     1 = VCC ; 0 = GND.
+*
+*******************************************************************************/
 inline uint32_t gpio_read(axi_gpio_t * axi)
 {
     return axi->GPIO_DATA;
 }

 /**** GPIO 2 ****/
+
+    /**** GPIO 3-State ****/
+
+/******************************************************************************/
+/**
+* Set the direction of the GPIO on the channel 2
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+* @param    value is the direction of the gpio (0 for output, 1 input).
+*
+* @return   None.
+*
+* @note     bit 0 corresponding to the pin 0, bit 1 to the pin 1...
+*
+*******************************************************************************/
 inline void gpio2_tri_dir(axi_gpio_t * axi, uint32_t value)
 {
     axi->GPIO2_TRI = value;
 }

+/******************************************************************************/
+/**
+* Set the specified pin of the GPIO as output on the channel 2
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+* @param    value is the pin to be set as output.
+*
+* @return   None.
+*
+* @note     bit 0 corresponding to the pin 0, bit 1 to the pin 1...
+*
+*******************************************************************************/
 inline void gpio2_tri_output(axi_gpio_t * axi, uint32_t value)
 {
     axi->GPIO2_TRI &= ~value;
 }

+/******************************************************************************/
+/**
+* Set the specified pin of the GPIO as input on the channel 2
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+* @param    value is the pin to be set as input.
+*
+* @return   None.
+*
+* @note     bit 0 corresponding to the pin 0, bit 1 to the pin 1...
+*
+*******************************************************************************/
 inline void gpio2_tri_input(axi_gpio_t * axi, uint32_t value)
 {
     axi->GPIO2_TRI |= value;
 }

-inline void gpio2_interrupt_enbale(axi_gpio_t * axi, uint8_t value)
-{
-    axi->IP_IER |= value&GPIO_IP_IER_CH2;
-}
-
-inline void gpio2_interrupt_disable(axi_gpio_t * axi, uint8_t value)
-{
-    axi->IP_IER &= ~(value&GPIO_IP_IER_CH2);
-}
-
+    /**** GPIO Interrupt ****/
+
+/******************************************************************************/
+/**
+* Enable the interruption for the channel 2
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+*
+* @return   None.
+*
+* @note     interruption are enable on all the pin (no choice)
+*
+*******************************************************************************/
+inline void gpio2_interrupt_enbale(axi_gpio_t * axi)
+{
+    axi->IP_IER |= GPIO_IP_IER_CH2;
+}
+
+/******************************************************************************/
+/**
+* Disable the interruption for the channel 2
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+*
+* @return   None.
+*
+* @note     interruption are disable on all the pin (no choice)
+*
+*******************************************************************************/
+inline void gpio2_interrupt_disable(axi_gpio_t * axi)
+{
+    axi->IP_IER &= ~GPIO_IP_IER_CH2;
+}
+
+/******************************************************************************/
+/**
+* Get the interruption status for the channel 2
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+*
+* @return   None.
+*
+* @note     0 = No Channel 1 input interrupt; 1 = Channel 1 input interrupt
+*
+*******************************************************************************/
 inline uint32_t gpio2_interrupt_status(axi_gpio_t * axi)
 {
     return axi->IP_ISR&GPIO_IP_ISR_CH2;
 }

-inline void gpio2_interrupt_clear(axi_gpio_t * axi, uint8_t value)
-{
-    axi->IP_ISR &= value&GPIO_IP_ISR_CH2;
-}
-
+/******************************************************************************/
+/**
+* Clear interruption status for the channel 2
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+*
+* @return   None.
+*
+* @note     None.
+*
+*******************************************************************************/
+inline void gpio2_interrupt_clear(axi_gpio_t * axi)
+{
+    axi->IP_ISR &= GPIO_IP_ISR_CH2;
+}
+
+    /**** GPIO R/W ****/
+
+/******************************************************************************/
+/**
+* Write on the channel 2 of the GPIO
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+* @param    value is the value to be write on the gpio.
+*
+* @return   None.
+*
+* @note     1 = VCC ; 0 = GND.
+*
+*******************************************************************************/
 inline void gpio2_write(axi_gpio_t * axi, uint32_t value)
 {
     axi->GPIO2_DATA = value;
 }

+/******************************************************************************/
+/**
+* Set the specified pin of the channel 2
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+* @param    value is the pin that must be set.
+*
+* @return   None.
+*
+* @note     1 = VCC ; 0 = GND.
+*
+*******************************************************************************/
 inline void gpio2_set(axi_gpio_t * axi, uint32_t value)
 {
     axi->GPIO2_DATA |= value;
 }

+/******************************************************************************/
+/**
+* Clear the specified pin of the channel 2
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+* @param    value is the pin that must be clear.
+*
+* @return   None.
+*
+* @note     1 = VCC ; 0 = GND.
+*
+*******************************************************************************/
 inline void gpio2_clear(axi_gpio_t * axi, uint32_t value)
 {
     axi->GPIO2_DATA &= ~value;
 }

+/******************************************************************************/
+/**
+* Toggle the specified pin of the channel 2
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+* @param    value is the pin that must be toggle.
+*
+* @return   None.
+*
+* @note     1 = VCC ; 0 = GND.
+*
+*******************************************************************************/
 inline void gpio2_toggle(axi_gpio_t * axi, uint32_t value)
 {
     axi->GPIO2_DATA ^= value;
 }

+/******************************************************************************/
+/**
+* Read the value of the GPIO on the channel 2
+*
+* @param    axi is a pointer to the axi_iic_t instance.
+*
+* @return   The value of the GPIO.
+*
+* @note     1 = VCC ; 0 = GND.
+*
+*******************************************************************************/
 inline uint32_t gpio2_read(axi_gpio_t * axi)
 {
     return axi->GPIO2_DATA;


(unstable) [fixed] array out of bounds in moods

git-svn-id: e4cf3396f21da4a5d638eecf7e3b4dd52b27f938@5886 c3d1530f-68f5-4bd0-87dc-8ef779617e40

--- MMOCoreORB/src/server/zone/objects/player/Races.h
+++ MMOCoreORB/src/server/zone/objects/player/Races.h
@@ -395,26 +395,44 @@
 class Races {
 public:
 	inline const static char* getRace(int raceid) {
+		if (raceid < 0 || raceid > 19)
+			return "";
+
 		return RaceStrs[raceid];
 	}

 	inline static int getSpeciesID(int raceid) {
+		if (raceid < 0 || raceid > 19)
+			return 0;
+
 		return TemplateSpecies[raceid];
 	}

 	inline const static char* getMood(int moodid) {
+		if (moodid < 0 || moodid > 189)
+			return "";
+
 		return MoodStr[moodid][0];
 	}

 	inline const static char* getSpecies(int raceid) {
+		if (raceid < 0 || raceid > 19)
+			return "";
+
 		return Species[raceid];
 	}

 	inline const static char* getGender(int raceid) {
+		if (raceid < 0 || raceid > 19)
+			return "";
+
 		return Gender[raceid];
 	}

 	inline static uint32 getRaceCRC(int raceid) {
+		if (raceid < 0 || raceid > 19)
+			return 0;
+
 		return SharedRace[raceid];
 	}


Add ALLOW_HIDPI to window creation flag

Add ALLOW_HIDPI to window creation flag

--- src/os/sdl/host-window.c
+++ src/os/sdl/host-window.c
@@ -186,7 +186,8 @@
 	SDL_Window *win = NULL;
 	REBYTE *title;
 	REBYTE title_needs_free = FALSE;
-	Uint32 flags = SDL_WINDOW_OPENGL;
+	Uint32 flags = SDL_WINDOW_OPENGL
+				  | SDL_WINDOW_ALLOW_HIGHDPI;
 	REBGOB *parent_gob = GOB_PARENT(gob);

 	windex = Alloc_Window(gob);


remove fetch_row(s) methods, mixin Enumerable

--- ext/mysql2_ext.c
+++ ext/mysql2_ext.c
@@ -260,9 +260,12 @@
   rb_define_method(cMysql2Client, "escape", rb_mysql_client_escape, 1);

   cMysql2Result = rb_define_class_under(mMysql2, "Result", rb_cObject);
-  rb_define_method(cMysql2Result, "fetch_row", rb_mysql_result_fetch_row, -1);
-  rb_define_method(cMysql2Result, "fetch_rows", rb_mysql_result_fetch_rows, -1);
+  // rb_define_method(cMysql2Result, "fetch_row", rb_mysql_result_fetch_row, -1);
+  // rb_define_method(cMysql2Result, "fetch_rows", rb_mysql_result_fetch_rows, -1);
   rb_define_method(cMysql2Result, "each", rb_mysql_result_fetch_rows, -1);
+
+  VALUE mEnumerable = rb_const_get(rb_cObject, rb_intern("Enumerable"));
+  rb_include_module(cMysql2Result, mEnumerable);

   // intern_new = rb_intern("new");


Some documentation typos.

Some documentation typos.

git-svn-id: 7ffbd09614c8d739a966cfae413e2c1c0f4cb91b@367 453b2852-3d18-0410-866e-d09c099698e4

--- ext/ruby_debug.c
+++ ext/ruby_debug.c
@@ -1187,8 +1187,9 @@
  *   This method disables the debugger. It returns +true+ if the debugger is disabled,
  *   otherwise it returns +false+.
  *
- *   Note that if you want to stop debugger, you must call Debugger.stop as many time as you
- *   called Debugger.start method.
+ *   Note that if you want to stop debugger, you must call
+ *   Debugger.stop as many times as you called Debugger.start
+ *   method.
  */
 static VALUE
 debug_stop(VALUE self)
@@ -2205,7 +2206,7 @@

 /*
  *   call-seq:
- *      context.thread -> trhread
+ *      context.thread -> thrread
  *
  *   Returns a thread this context is associated with.
  */


Some documentation typos.

Some documentation typos.


Rewrite function fixstar

Rewrite function fixstar

--- pyswisseph.c
+++ pyswisseph.c
@@ -653,28 +653,33 @@
 /* swisseph.fixstar */
 PyDoc_STRVAR(pyswe_fixstar__doc__,
 "Calculate fixed star positions (ET).\n\n"
-"Args: str star, float julday, int flag=FLG_SWIEPH\n"
-"Return: tuple of 6 float, returned star name, and returned flags\n\n"
-"Usage example:\n\n"
-"\tres, stnam, flg = swisseph.fixstar(st, jd)");
+"Args: str star, float tjdet, int flags=FLG_SWIEPH\n"
+"Return: ((float x1, x2, x3, x4, x5, x6), str stnam, int retflags)\n\n"
+" - star: name of fixed star to search for\n"
+" - tjdet: Julian day in Ephemeris Time\n"
+" - flags: bit flags indicating what kind of computation is wanted\n"
+" - x1, x2, x3, x4, x5, x6: results\n"
+" - stnam: returned star name\n"
+" - retflags: bit flags indicating what kind of computation was done\n\n"
+"This function raises an exception (swisseph.Error) in case of fatal error.");

 static PyObject * pyswe_fixstar FUNCARGS_KEYWDS
 {
-    char *star, st[(SE_MAX_STNAME*2)+1], err[256];
-    double jd, val[6];
+    char *star, st[(SE_MAX_STNAME*2)+1], err[256] = {0};
+    double jd, xx[6];
     int ret, flag = SEFLG_SWIEPH;
-    static char *kwlist[] = {"star", "julday", "flag", NULL};
+    static char *kwlist[] = {"star", "tjdet", "flags", NULL};
     if (!PyArg_ParseTupleAndKeywords(args, keywds, "sd|i", kwlist,
         &star, &jd, &flag))
         return NULL;
     memset(st, 0, (SE_MAX_STNAME*2)+1);
     strncpy(st, star, SE_MAX_STNAME*2);
-    ret = swe_fixstar(st, jd, flag, val, err);
+    ret = swe_fixstar(st, jd, flag, xx, err);
     if (ret < 0) {
         PyErr_SetString(pyswe_Error, err);
         return NULL;
     }
-    return Py_BuildValue("(dddddd)si",val[0],val[1],val[2],val[3],val[4],val[5],st,ret);
+    return Py_BuildValue("(dddddd)si",xx[0],xx[1],xx[2],xx[3],xx[4],xx[5],st,ret);
 }

 /* swisseph.fixstar2 */


ported stop reason from the trunk

ported stop reason from the trunk

--- ext/ruby_debug.c
+++ ext/ruby_debug.c
@@ -4,7 +4,7 @@
 #include <rubysig.h>
 #include <st.h>

-#define DEBUG_VERSION "0.8.1"
+#define DEBUG_VERSION "0.8.2"

 #ifdef _WIN32
 struct FRAME {
@@ -50,8 +50,8 @@
 #define CTX_FL_DEAD         (1<<6)
 #define CTX_FL_WAS_RUNNING  (1<<7)

-#define CTX_FL_TEST(c,f) ((c)->flags & (f))
-#define CTX_FL_SET(c,f) do { (c)->flags |= (f); } while (0)
+#define CTX_FL_TEST(c,f)  ((c)->flags & (f))
+#define CTX_FL_SET(c,f)   do { (c)->flags |= (f); } while (0)
 #define CTX_FL_UNSET(c,f) do { (c)->flags &= ~(f); } while (0)

 #define DID_MOVED   (debug_context->last_line != line || \
@@ -60,7 +60,7 @@

 #define IS_STARTED  (threads_tbl != Qnil)
 #define FRAME_N(n)  (&debug_context->frames[debug_context->stack_size-(n)-1])
-#define GET_FRAME       (FRAME_N(check_frame_number(debug_context, frame)))
+#define GET_FRAME   (FRAME_N(check_frame_number(debug_context, frame)))

 #ifndef min
 #define min(x,y) ((x) < (y) ? (x) : (y))
@@ -88,10 +88,13 @@
     } info;
 } debug_frame_t;

+enum ctx_stop_reason {CTX_STOP_INIT, CTX_STOP_STEP, CTX_STOP_BREAKPOINT, CTX_STOP_CATCHPOINT};
+
 typedef struct {
     VALUE thread_id;
     int thnum;
     int flags;
+    enum ctx_stop_reason stop_reason;
     int stop_next;
     int dest_frame;
     int stop_line;
@@ -107,7 +110,7 @@

 typedef struct {
     int   id;
-    int   type;
+    enum bp_type type;
     VALUE source;
     union
     {
@@ -416,6 +419,7 @@
     debug_context->dest_frame = -1;
     debug_context->stop_line = -1;
     debug_context->stop_frame = -1;
+    debug_context->stop_reason = CTX_STOP_INIT;
     debug_context->stack_len = STACK_SIZE_INCREMENT;
     debug_context->frames = ALLOC_N(debug_frame_t, STACK_SIZE_INCREMENT);
     debug_context->stack_size = 0;
@@ -838,12 +842,16 @@
             (breakpoint_index = check_breakpoints_by_pos(debug_context, file, line)) != -1)
         {
             binding = self? create_binding(self) : Qnil;
+            debug_context->stop_reason = CTX_STOP_STEP;
             /* check breakpoint expression */
             if(breakpoint_index != -1)
             {
                 breakpoint = get_breakpoint_at(breakpoint_index);
                 if(check_breakpoint_expression(breakpoint, binding))
-                    rb_funcall(context, idAtBreakpoint, 1, breakpoint);
+                {
+                  debug_context->stop_reason = CTX_STOP_BREAKPOINT;
+                  rb_funcall(context, idAtBreakpoint, 1, breakpoint);
+                }
                 else
                     break;
             }
@@ -879,6 +887,7 @@
             if(check_breakpoint_expression(breakpoint, binding))
             {
                 save_top_binding(debug_context, binding);
+                debug_context->stop_reason = CTX_STOP_BREAKPOINT;
                 rb_funcall(context, idAtBreakpoint, 1, breakpoint);
                 call_at_line(context, debug_context, rb_str_new2(file), INT2FIX(line));
             }
@@ -939,6 +948,7 @@
             aclass = rb_ary_entry(ancestors, i);
             if(rb_str_cmp(rb_mod_name(aclass), catchpoint) == 0)
             {
+                debug_context->stop_reason = CTX_STOP_CATCHPOINT;
                 rb_funcall(context, idAtCatchpoint, 1, ruby_errinfo);
                 if(self && binding == Qnil)
                     binding = create_binding(self);
@@ -1995,6 +2005,45 @@

 /*
  *   call-seq:
+ *      context.stop_reason -> sym
+ *
+ *   Returns the reason for the stop. It maybe of the following values:
+ *   :initial, :step, :breakpoint, :catchpoint, :post-mortem
+ */
+static VALUE
+context_stop_reason(VALUE self)
+{
+    debug_context_t *debug_context;
+    char * sym_name;
+
+    debug_check_started();
+
+    Data_Get_Struct(self, debug_context_t, debug_context);
+
+    switch(debug_context->stop_reason)
+    {
+        case CTX_STOP_STEP:
+            sym_name = "step";
+            break;
+        case CTX_STOP_BREAKPOINT:
+            sym_name = "breakpoint";
+            break;
+        case CTX_STOP_CATCHPOINT:
+            sym_name = "catchpoint";
+            break;
+        case CTX_STOP_INIT:
+        default:
+            sym_name = "initial";
+    }
+    if(CTX_FL_TEST(debug_context, CTX_FL_DEAD))
+        sym_name = "post-mortem";
+
+    return ID2SYM(rb_intern(sym_name));
+}
+
+
+/*
+ *   call-seq:
  *      breakpoint.source -> string
  *
  *   Returns a source of the breakpoint.
@@ -2072,6 +2121,7 @@
     rb_define_method(cContext, "stop_frame=", context_stop_frame, 1);
     rb_define_method(cContext, "thread", context_thread, 0);
     rb_define_method(cContext, "thnum", context_thnum, 0);
+    rb_define_method(cContext, "stop_reason", context_stop_reason, 0);
     rb_define_method(cContext, "suspend", context_suspend, 0);
     rb_define_method(cContext, "suspended?", context_is_suspended, 0);
     rb_define_method(cContext, "resume", context_resume, 0);


tracked_offset_ is not necessary

tracked_offset_ is not necessary

--- iv/aero/jit.h
+++ iv/aero/jit.h
@@ -98,7 +98,6 @@
       targets_(),
       backtracks_(),
       tracked_(),
-      tracked_offset_(),
       character(kASCII ? byte : word),
       subject_(r12),
       size_(r13),
@@ -206,7 +205,6 @@
       std::advance(instr, length);
     }
     tracked_.resize(backtracks_.size(), 0);
-    tracked_offset_.resize(tracked_.size());
   }

   static bool CanOptimize(uint8_t opcode) {
@@ -317,8 +315,7 @@
       }
       const BackTrackMap::const_iterator it = backtracks_.find(offset);
       if (it != backtracks_.end()) {
-//        tracked_[it->second] = core::BitCast<uintptr_t>(getCurr());
-        tracked_offset_[it->second] = getSize();
+          tracked_[it->second] = core::BitCast<uintptr_t>(getSize()); // offset from getCode
       }

       // basic block optimization pass
@@ -552,12 +549,12 @@
       mov(rax, AERO_ERROR);
       jmp(jit_detail::kReturnLabel);
     }
-    // finish generating code and calc tracked_ from tracked_offset_
+    // finish generating code and determine code address
     ready();
     {
-      const uint8_t *top = getCode();
+      const uintptr_t top = core::BitCast<uintptr_t>(getCode());
       for (size_t i = 0; i < tracked_.size(); i++) {
-        tracked_[i] = core::BitCast<uintptr_t>(top + tracked_offset_[i]);
+        tracked_[i] += top;
       }
     }
   }
@@ -1155,7 +1152,6 @@
   core::SortedVector<uint32_t> targets_;
   BackTrackMap backtracks_;
   std::vector<uintptr_t> tracked_;
-  std::vector<size_t> tracked_offset_;

   const Xbyak::AddressFrame character;
   const Xbyak::Reg64& subject_;


libc: minimal: Add strtoll implementation

This commit adds the strtoll function implementation that is licensed
BSD-3-Clause, which is an OSI-approved license, with the modifications
necessary for adoption into the Zephyr minimal C library.

Origin: Newlib
License: BSD 3-Clause
URL: git://sourceware.org/git/newlib-cygwin.git
Commit: 9042d0ce65533a26fc3264206db5828d5692332c
Purpose: strtoll function support in the minimal C library

Signed-off-by: Stephanos Ioannidis <dc76e9f0c0006e8f919e0c515c66dbba3982f785@stephanos.io>

error: pathspec 'lib/libc/minimal/source/stdlib/strtoll.c' did not match any file(s) known to git

--- lib/libc/minimal/source/stdlib/strtoll.c
+++ lib/libc/minimal/source/stdlib/strtoll.c
@@ -0,0 +1,127 @@
+/* SPDX-License-Identifier: BSD-3-Clause-UC */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <limits.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/*
+ * Convert a string to a long long integer.
+ *
+ * Ignores `locale' stuff.  Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ */
+long long strtoll(const char *nptr, char **endptr, register int base)
+{
+	register const char *s = nptr;
+	register unsigned long long acc;
+	register int c;
+	register unsigned long long cutoff;
+	register int neg = 0, any, cutlim;
+
+	/*
+	 * Skip white space and pick up leading +/- sign if any.
+	 * If base is 0, allow 0x for hex and 0 for octal, else
+	 * assume decimal; if base is already 16, allow 0x.
+	 */
+	do {
+		c = *s++;
+	} while (isspace(c));
+	if (c == '-') {
+		neg = 1;
+		c = *s++;
+	} else if (c == '+') {
+		c = *s++;
+	}
+
+	if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X')) {
+		c = s[1];
+		s += 2;
+		base = 16;
+	}
+
+	if (base == 0) {
+		base = c == '0' ? 8 : 10;
+	}
+
+	/*
+	 * Compute the cutoff value between legal numbers and illegal
+	 * numbers.  That is the largest legal value, divided by the
+	 * base.  An input number that is greater than this value, if
+	 * followed by a legal input character, is too big.  One that
+	 * is equal to this value may be valid or not; the limit
+	 * between valid and invalid numbers is then based on the last
+	 * digit.  For instance, if the range for longs is
+	 * [-2147483648..2147483647] and the input base is 10,
+	 * cutoff will be set to 214748364 and cutlim to either
+	 * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
+	 * a value > 214748364, or equal but the next digit is > 7 (or 8),
+	 * the number is too big, and we will return a range error.
+	 *
+	 * Set any if any `digits' consumed; make it negative to indicate
+	 * overflow.
+	 */
+	cutoff = neg ? -(unsigned long long)LLONG_MIN : LLONG_MAX;
+	cutlim = cutoff % (unsigned long long)base;
+	cutoff /= (unsigned long long)base;
+	for (acc = 0, any = 0;; c = *s++) {
+		if (isdigit(c)) {
+			c -= '0';
+		} else if (isalpha(c)) {
+			c -= isupper(c) ? 'A' - 10 : 'a' - 10;
+		} else {
+			break;
+		}
+		if (c >= base) {
+			break;
+		}
+		if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) {
+			any = -1;
+		} else {
+			any = 1;
+			acc *= base;
+			acc += c;
+		}
+	}
+
+	if (any < 0) {
+		acc = neg ? LLONG_MIN : LLONG_MAX;
+		errno = ERANGE;
+	} else if (neg) {
+		acc = -acc;
+	}
+
+	if (endptr != NULL) {
+		*endptr = (char *)(any ? (char *)s - 1 : nptr);
+	}
+	return acc;
+}


track calls to write(2)

track calls to write(2)

--- ext/tracers/fd.c
+++ ext/tracers/fd.c
@@ -20,11 +20,15 @@
   size_t read_requested_bytes;
   size_t read_actual_bytes;

+  size_t write_calls;
+  double write_time;
+  size_t write_requested_bytes;
+  size_t write_actual_bytes;
+
   size_t connect_calls;
   double connect_time;

   size_t readv_calls;
-  size_t write_calls;
   size_t writev_calls;
 };

@@ -47,6 +51,27 @@
   stats.read_requested_bytes += nbyte;
   if (ret > 0)
     stats.read_actual_bytes += ret;
+
+  errno = err;
+  return ret;
+}
+
+static ssize_t
+write_tramp(int fildes, const void *buf, size_t nbyte) {
+  double secs = 0;
+  int err;
+  ssize_t ret;
+
+  secs = trace_get_time();
+  ret = write(fildes, buf, nbyte);
+  err = errno;
+  secs = trace_get_time() - secs;
+
+  stats.write_time += secs;
+  stats.write_calls++;
+  stats.write_requested_bytes += nbyte;
+  if (ret > 0)
+    stats.write_actual_bytes += ret;

   errno = err;
   return ret;
@@ -76,6 +101,9 @@
   tmp.addr = read_tramp;
   bin_update_image("read", &tmp, NULL);

+  tmp.addr = write_tramp;
+  bin_update_image("write", &tmp, NULL);
+
   tmp.addr = connect_tramp;
   bin_update_image("connect", &tmp, NULL);
 }
@@ -86,6 +114,9 @@

   tmp.addr = read;
   bin_update_image("read", &tmp, NULL);
+
+  tmp.addr = write;
+  bin_update_image("write", &tmp, NULL);

   tmp.addr = connect;
   bin_update_image("connect", &tmp, NULL);
@@ -112,6 +143,20 @@
     yajl_gen_map_close(gen);
   }

+  if (stats.write_calls > 0) {
+    yajl_gen_cstr(gen, "write");
+    yajl_gen_map_open(gen);
+    yajl_gen_cstr(gen, "calls");
+    yajl_gen_integer(gen, stats.write_calls);
+    yajl_gen_cstr(gen, "time");
+    yajl_gen_double(gen, stats.write_time);
+    yajl_gen_cstr(gen, "requested");
+    yajl_gen_integer(gen, stats.write_requested_bytes);
+    yajl_gen_cstr(gen, "actual");
+    yajl_gen_integer(gen, stats.write_actual_bytes);
+    yajl_gen_map_close(gen);
+  }
+
   if (stats.connect_calls > 0) {
     yajl_gen_cstr(gen, "connect");
     yajl_gen_map_open(gen);
@@ -121,15 +166,6 @@
     yajl_gen_double(gen, stats.connect_time);
     yajl_gen_map_close(gen);
   }
-
-  // fprintf(stderr, "================ FDs ======================================\n");
-  // fprintf(stderr, " # read calls: %zd\n", stats.read_calls);
-  // fprintf(stderr, " time in read: %fs\n", stats.read_time);
-  // fprintf(stderr, " bytes: %zd requested / %zd actual\n", stats.read_requested_bytes, stats.read_actual_bytes);
-  // fprintf(stderr, "===========================================================\n");
-  // fprintf(stderr, " # connect calls: %zd\n", stats.connect_calls);
-  // fprintf(stderr, " time in connect: %fs\n", stats.connect_time);
-  // fprintf(stderr, "===========================================================\n\n");
 }

 void install_fd_tracer()


Fixed last documentation update date

Fixed last documentation update date

--- sqon.h
+++ sqon.h
@@ -18,7 +18,7 @@
 /**
  * @file sqon.h
  * @version 0.0
- * @date 01/07/2014
+ * @date 02/12/2015
  * @author David McMackins II
  * @brief C implementation for Delwink's SQON
  */


eal/linux: fix uninitialized value

eal/linux: fix uninitialized value

The value is not used, but some static analyzers may give out a
warning. Fix it by assigning default value of zero.

Bugzilla ID: 58
Fixes: cdc242f260e7 ("eal/linux: support running as unprivileged user")
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <814e00d8f6e4e81b7ccc7e3e5a0bfec0078f0203@intel.com>

--- lib/librte_eal/linuxapp/eal/eal_memory.c
+++ lib/librte_eal/linuxapp/eal/eal_memory.c
@@ -66,7 +66,7 @@
 static void
 test_phys_addrs_available(void)
 {
-	uint64_t tmp;
+	uint64_t tmp = 0;
 	phys_addr_t physaddr;

 	if (!rte_eal_has_hugepages()) {


imap-smtp: Stop the progress widgets from changing the dialog's height

Use GtkWidget::opacity instead of relying on GtkWidget::visible because
"hidden" widgets are zero-sized. When we show and hide the controls
the rows jump around and the dialog changes its height. This looks
awkward. We want the rows to hold their positions even when they are
hidden.


Optimize the read_partition.

Optimize the read_partition.

Change-Id: I5a796425ce5706824a2fc17c6f24f983c5b9e43b

--- vp9/common/vp9_onyxc_int.h
+++ vp9/common/vp9_onyxc_int.h
@@ -417,21 +417,12 @@
                                           BLOCK_SIZE bsize) {
   const PARTITION_CONTEXT *above_ctx = xd->above_seg_context + mi_col;
   const PARTITION_CONTEXT *left_ctx = xd->left_seg_context + (mi_row & MI_MASK);
-
   const int bsl = mi_width_log2_lookup[bsize];
-  const int bs = 1 << bsl;
-  int above = 0, left = 0, i;
+  int above = (*above_ctx >> bsl) & 1 , left = (*left_ctx >> bsl) & 1;

   assert(b_width_log2_lookup[bsize] == b_height_log2_lookup[bsize]);
   assert(bsl >= 0);

-  for (i = 0; i < bs; i++) {
-    above |= above_ctx[i];
-    left |= left_ctx[i];
-  }
-  above = (above & bs) > 0;
-  left  = (left & bs) > 0;
-
   return (left * 2 + above) + bsl * PARTITION_PLOFFSET;
 }


ssha.c: be consistent with the order of tests with eg. ykchalresp.c

Just to make it easier to compare later.

--- ssha.c
+++ ssha.c
@@ -615,7 +615,7 @@
 		if (getenv("KC_DEBUG"))
 			printf("%s(): constructing new password by appending password to signature\n", __func__);

-		memcpy(db_params->pass + signature->length, passtmp, db_params->pass_len >= signature->length + passtmp_len ? passtmp_len : db_params->pass_len - signature->length);
+		memcpy(db_params->pass + signature->length, passtmp, signature->length + passtmp_len > db_params->pass_len ? db_params->pass_len - signature->length : passtmp_len);
 	}

 	ret = 1;


(InFamily) : Support gcc 4.0.1

(InFamily) : Support gcc 4.0.1

--- os/net/include/inet4.h
+++ os/net/include/inet4.h
@@ -284,6 +284,8 @@
     friend class Inet4Address::StatePreferred;
     friend class Inet4Address::StateReachable;
     friend class Inet4Address::StateDestination;
+    friend class Inet4Address::StateProbe;
+    friend class Inet4Address::StateDeprecated;
     friend class InReceiver;
 };


vp9_decodemv.c cleanup.

vp9_decodemv.c cleanup.

Renaming:
  read_intra_mode_info  -> read_intra_frame_mode_info
  read_inter_mode_info  -> read_inter_frame_mode_info
  read_intra_block_part -> read_intra_block_mode_info
  read_inter_block_part -> read_inter_block_mode_info
  read_ref_frame        -> read_ref_frames
  read_reference_frame  -> read_is_inter_block

Using num_4x4_blocks_{wide, high}_lookup instead of bit shifts.

Change-Id: I83c81573b4ef6f53f2f8d24683895014bebfba61

--- vp9/decoder/vp9_decodemv.c
+++ vp9/decoder/vp9_decodemv.c
@@ -54,12 +54,12 @@
 }

 static TX_SIZE read_tx_size(VP9D_COMP *pbi, TX_MODE tx_mode,
-                            BLOCK_SIZE_TYPE bsize, int select_cond,
+                            BLOCK_SIZE_TYPE bsize, int allow_select,
                             vp9_reader *r) {
   VP9_COMMON *const cm = &pbi->common;
   MACROBLOCKD *const xd = &pbi->mb;

-  if (tx_mode == TX_MODE_SELECT && bsize >= BLOCK_SIZE_SB8X8 && select_cond)
+  if (allow_select && tx_mode == TX_MODE_SELECT && bsize >= BLOCK_SIZE_SB8X8)
     return read_selected_tx_size(cm, xd, bsize, r);
   else if (tx_mode >= ALLOW_32X32 && bsize >= BLOCK_SIZE_SB32X32)
     return TX_32X32;
@@ -146,8 +146,8 @@
   return skip_coeff;
 }

-static void read_intra_mode_info(VP9D_COMP *pbi, MODE_INFO *m,
-                                 int mi_row, int mi_col, vp9_reader *r) {
+static void read_intra_frame_mode_info(VP9D_COMP *pbi, MODE_INFO *m,
+                                       int mi_row, int mi_col, vp9_reader *r) {
   VP9_COMMON *const cm = &pbi->common;
   MACROBLOCKD *const xd = &pbi->mb;
   MB_MODE_INFO *const mbmi = &m->mbmi;
@@ -166,12 +166,12 @@
     mbmi->mode = read_intra_mode(r, vp9_kf_y_mode_prob[A][L]);
   } else {
     // Only 4x4, 4x8, 8x4 blocks
-    const int bw = 1 << b_width_log2(bsize);
-    const int bh = 1 << b_height_log2(bsize);
+    const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];  // 1 or 2
+    const int num_4x4_h = num_4x4_blocks_high_lookup[bsize];  // 1 or 2
     int idx, idy;

-    for (idy = 0; idy < 2; idy += bh) {
-      for (idx = 0; idx < 2; idx += bw) {
+    for (idy = 0; idy < 2; idy += num_4x4_h) {
+      for (idx = 0; idx < 2; idx += num_4x4_w) {
         const int ib = idy * 2 + idx;
         const MB_PREDICTION_MODE A = above_block_mode(m, ib, mis);
         const MB_PREDICTION_MODE L = (xd->left_available || idx) ?
@@ -179,9 +179,9 @@
         const MB_PREDICTION_MODE b_mode = read_intra_mode(r,
                                               vp9_kf_y_mode_prob[A][L]);
         m->bmi[ib].as_mode = b_mode;
-        if (bh == 2)
+        if (num_4x4_h == 2)
           m->bmi[ib + 2].as_mode = b_mode;
-        if (bw == 2)
+        if (num_4x4_w == 2)
           m->bmi[ib + 1].as_mode = b_mode;
       }
     }
@@ -290,8 +290,8 @@
 }

 // Read the referncence frame
-static void read_ref_frame(VP9D_COMP *pbi, vp9_reader *r,
-                           int segment_id, MV_REFERENCE_FRAME ref_frame[2]) {
+static void read_ref_frames(VP9D_COMP *pbi, vp9_reader *r,
+                            int segment_id, MV_REFERENCE_FRAME ref_frame[2]) {
   VP9_COMMON *const cm = &pbi->common;
   MACROBLOCKD *const xd = &pbi->mb;
   FRAME_CONTEXT *const fc = &cm->fc;
@@ -380,11 +380,14 @@
   return vp9_switchable_interp[index];
 }

-static void read_intra_block_part(VP9D_COMP *pbi, MODE_INFO *mi,
+static void read_intra_block_mode_info(VP9D_COMP *pbi, MODE_INFO *mi,
                                   vp9_reader *r) {
   VP9_COMMON *const cm = &pbi->common;
   MB_MODE_INFO *const mbmi = &mi->mbmi;
   const BLOCK_SIZE_TYPE bsize = mi->mbmi.sb_type;
+
+  mbmi->ref_frame[0] = INTRA_FRAME;
+  mbmi->ref_frame[1] = NONE;

   if (bsize >= BLOCK_SIZE_SB8X8) {
     const int size_group = size_group_lookup[bsize];
@@ -392,19 +395,20 @@
     cm->counts.y_mode[size_group][mbmi->mode]++;
   } else {
      // Only 4x4, 4x8, 8x4 blocks
-     const int bw = 1 << b_width_log2(bsize), bh = 1 << b_height_log2(bsize);
+     const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];  // 1 or 2
+     const int num_4x4_h = num_4x4_blocks_high_lookup[bsize];  // 1 or 2
      int idx, idy;

-     for (idy = 0; idy < 2; idy += bh) {
-       for (idx = 0; idx < 2; idx += bw) {
+     for (idy = 0; idy < 2; idy += num_4x4_h) {
+       for (idx = 0; idx < 2; idx += num_4x4_w) {
          const int ib = idy * 2 + idx;
          const int b_mode = read_intra_mode(r, cm->fc.y_mode_prob[0]);
          mi->bmi[ib].as_mode = b_mode;
          cm->counts.y_mode[0][b_mode]++;

-         if (bh == 2)
+         if (num_4x4_h == 2)
            mi->bmi[ib + 2].as_mode = b_mode;
-         if (bw == 2)
+         if (num_4x4_w == 2)
            mi->bmi[ib + 1].as_mode = b_mode;
       }
     }
@@ -415,25 +419,22 @@
   cm->counts.uv_mode[mbmi->mode][mbmi->uv_mode]++;
 }

-static MV_REFERENCE_FRAME read_reference_frame(VP9D_COMP *pbi, int segment_id,
-                                               vp9_reader *r) {
-  VP9_COMMON *const cm = &pbi->common;
-  MACROBLOCKD *const xd = &pbi->mb;
-
-  MV_REFERENCE_FRAME ref;
-  if (!vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_REF_FRAME)) {
+static int read_is_inter_block(VP9D_COMP *pbi, int segment_id, vp9_reader *r) {
+  VP9_COMMON *const cm = &pbi->common;
+  MACROBLOCKD *const xd = &pbi->mb;
+
+  if (vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_REF_FRAME)) {
+    return vp9_get_segdata(&xd->seg, segment_id, SEG_LVL_REF_FRAME) !=
+           INTRA_FRAME;
+  } else {
     const int ctx = vp9_get_pred_context_intra_inter(xd);
-    ref = (MV_REFERENCE_FRAME)
-              vp9_read(r, vp9_get_pred_prob_intra_inter(cm, xd));
-    cm->counts.intra_inter[ctx][ref != INTRA_FRAME]++;
-  } else {
-    ref = (MV_REFERENCE_FRAME) vp9_get_segdata(&xd->seg, segment_id,
-                                   SEG_LVL_REF_FRAME) != INTRA_FRAME;
-  }
-  return ref;
-}
-
-static void read_inter_block_part(VP9D_COMP *pbi, MODE_INFO *mi,
+    const int is_inter = vp9_read(r, vp9_get_pred_prob_intra_inter(cm, xd));
+    ++cm->counts.intra_inter[ctx][is_inter];
+    return is_inter;
+  }
+}
+
+static void read_inter_block_mode_info(VP9D_COMP *pbi, MODE_INFO *mi,
                                   vp9_reader *r) {
   VP9_COMMON *const cm = &pbi->common;
   MACROBLOCKD *const xd = &pbi->mb;
@@ -442,15 +443,13 @@
   int_mv *const mv0 = &mbmi->mv[0];
   int_mv *const mv1 = &mbmi->mv[1];
   const BLOCK_SIZE_TYPE bsize = mbmi->sb_type;
-  const int bw = 1 << b_width_log2(bsize);
-  const int bh = 1 << b_height_log2(bsize);

   int_mv nearest, nearby, best_mv;
   int_mv nearest_second, nearby_second, best_mv_second;
   vp9_prob *mv_ref_p;
   MV_REFERENCE_FRAME ref0, ref1;

-  read_ref_frame(pbi, r, mbmi->segment_id, mbmi->ref_frame);
+  read_ref_frames(pbi, r, mbmi->segment_id, mbmi->ref_frame);
   ref0 = mbmi->ref_frame[0];
   ref1 = mbmi->ref_frame[1];

@@ -488,11 +487,12 @@
     }
   }

-
-  if (mbmi->sb_type < BLOCK_SIZE_SB8X8) {
+  if (bsize < BLOCK_SIZE_SB8X8) {
+    const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];  // 1 or 2
+    const int num_4x4_h = num_4x4_blocks_high_lookup[bsize];  // 1 or 2
     int idx, idy;
-    for (idy = 0; idy < 2; idy += bh) {
-      for (idx = 0; idx < 2; idx += bw) {
+    for (idy = 0; idy < 2; idy += num_4x4_h) {
+      for (idx = 0; idx < 2; idx += num_4x4_w) {
         int_mv blockmv, secondmv;
         const int j = idy * 2 + idx;
         const int blockmode = read_inter_mode(r, mv_ref_p);
@@ -536,9 +536,9 @@
         if (ref1 > 0)
           mi->bmi[j].as_mv[1].as_int = secondmv.as_int;

-        if (bh == 2)
+        if (num_4x4_h == 2)
           mi->bmi[j + 2] = mi->bmi[j];
-        if (bw == 2)
+        if (num_4x4_w == 2)
           mi->bmi[j + 1] = mi->bmi[j];
         mi->mbmi.mode = blockmode;
       }
@@ -598,26 +598,24 @@
   }
 }

-static void read_inter_mode_info(VP9D_COMP *pbi, MODE_INFO *mi,
-                                 int mi_row, int mi_col, vp9_reader *r) {
+static void read_inter_frame_mode_info(VP9D_COMP *pbi, MODE_INFO *mi,
+                                       int mi_row, int mi_col, vp9_reader *r) {
   VP9_COMMON *const cm = &pbi->common;
   MB_MODE_INFO *const mbmi = &mi->mbmi;
-  int intra_block;
-
+  int inter_block;
+
+  mbmi->mv[0].as_int = 0;
+  mbmi->mv[1].as_int = 0;
   mbmi->segment_id = read_inter_segment_id(pbi, mi_row, mi_col, r);
   mbmi->mb_skip_coeff = read_skip_coeff(pbi, mbmi->segment_id, r);
-  mbmi->ref_frame[0] = read_reference_frame(pbi, mbmi->segment_id, r);
-  mbmi->ref_frame[1] = NONE;
-  intra_block = mbmi->ref_frame[0] == INTRA_FRAME;
+  inter_block = read_is_inter_block(pbi, mbmi->segment_id, r);
   mbmi->txfm_size = read_tx_size(pbi, cm->tx_mode, mbmi->sb_type,
-                                 !mbmi->mb_skip_coeff || intra_block, r);
-  mbmi->mv[0].as_int = 0;
-  mbmi->mv[1].as_int = 0;
-
-  if (intra_block)
-    read_intra_block_part(pbi, mi, r);
+                                 !mbmi->mb_skip_coeff || !inter_block, r);
+
+  if (inter_block)
+    read_inter_block_mode_info(pbi, mi, r);
   else
-    read_inter_block_part(pbi, mi, r);
+    read_intra_block_mode_info(pbi, mi, r);
 }

 static void read_comp_pred(VP9_COMMON *cm, vp9_reader *r) {
@@ -697,9 +695,9 @@
   int x, y;

   if (cm->frame_type == KEY_FRAME || cm->intra_only)
-    read_intra_mode_info(pbi, mi, mi_row, mi_col, r);
+    read_intra_frame_mode_info(pbi, mi, mi_row, mi_col, r);
   else
-    read_inter_mode_info(pbi, mi, mi_row, mi_col, r);
+    read_inter_frame_mode_info(pbi, mi, mi_row, mi_col, r);

   for (y = 0; y < y_mis; y++)
     for (x = !y; x < x_mis; x++)


ssshl state

ssshl state

--- sssl.c
+++ sssl.c
@@ -7,9 +7,9 @@
 #define SSSL_NORMAL     0
 #define SSSL_CONNECT    1
 #define SSSL_CONNECTING 2
-#define SSSL_CONNECTED  2
-#define SSSL_SHUTDOWN   3
-#define SSSL_CLOSE      4
+#define SSSL_CONNECTED  3
+#define SSSL_SHUTDOWN   4
+#define SSSL_CLOSE      5

 struct sssl {
 	SSL_CTX   *ssl_ctx;


vp9_pickmode: Fix signed/unsigned mismatch.

Avoids getting reverted on the next libvpx chrome roll attempt.

Change-Id: I2431bd601111a78320af5f211f6413009674f1c8

--- vp9/encoder/vp9_pickmode.c
+++ vp9/encoder/vp9_pickmode.c
@@ -161,8 +161,8 @@
   struct macroblock_plane *const p = &x->plane[0];
   struct macroblockd_plane *const pd = &xd->plane[0];

-  int var = cpi->fn_ptr[bsize].vf(p->src.buf, p->src.stride,
-                                  pd->dst.buf, pd->dst.stride, &sse);
+  unsigned int var = cpi->fn_ptr[bsize].vf(p->src.buf, p->src.stride,
+                                           pd->dst.buf, pd->dst.stride, &sse);

   // TODO(jingning) This is a temporary solution to account for frames with
   // light changes. Need to customize the rate-distortion modeling for non-RD


mmap() now zeroes out the memory it allocates, there isn't much documentation on this but it seems a MAP_ANON mapping should behave as if /dev/zero has been mapped, so this is probably the correct behaviour.

--- kernel/arc/mm/malloc.c
+++ kernel/arc/mm/malloc.c
@@ -16,6 +16,7 @@

 #include <arc/mm/malloc.h>
 #include <arc/mm/heap.h>
+#include <string.h>

 /*
  * note: these are only functions required for dlmalloc to work, for the bulk
@@ -36,6 +37,7 @@
   if (!ptr)
     return MAP_FAILED;

+  memclr(ptr, len);
   return ptr;
 }


Adaptively adjust mode test kick-off thresholds in RTC coding

This commit allows the encoder to increase the mode test kick-off
thresholds if the previous best mode renders all zero quantized
coefficients, thereby saving motion search runs when possible.
The compression performance of speed -5 and -6 is down by -0.446%
and 0.591%, respectively. The runtime of speed -6 is improved by
10% for many test clips.

vidyo1, 1000 kbps
16578 b/f, 40.316 dB, 7873 ms -> 16575 b/f, 40.262 dB, 7126 ms

nik720p, 1000 kbps
33311 b/f, 38.651 dB, 7263 ms -> 33304 b/f, 38.629 dB, 6865 ms

dark720p, 1000 kbps
33331 b/f, 39.718 dB, 13596 ms -> 33324 b/f, 39.651 dB, 12000 ms

mmoving, 1000 kbps
33263 b/f, 40.983 dB, 7566 ms -> 33259 b/f, 40.978 dB, 7531 ms

Change-Id: I7591617ff113e91125ec32c9b853e257fbc41d90

--- vp9/encoder/vp9_pickmode.c
+++ vp9/encoder/vp9_pickmode.c
@@ -530,7 +530,7 @@
   static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG,
                                     VP9_ALT_FLAG };
   RD_COST this_rdc, best_rdc;
-  uint8_t skip_txfm = 0;
+  uint8_t skip_txfm = 0, best_mode_skip_txfm = 0;
   // var_y and sse_y are saved to be used in skipping checking
   unsigned int var_y = UINT_MAX;
   unsigned int sse_y = UINT_MAX;
@@ -678,7 +678,8 @@
       if (!(cpi->sf.inter_mode_mask[bsize] & (1 << this_mode)))
         continue;

-      mode_rd_thresh = rd_threshes[mode_index];
+      mode_rd_thresh = best_mode_skip_txfm ? rd_threshes[mode_index] << 1 :
+                                             rd_threshes[mode_index];
       if (rd_less_than_thresh(best_rdc.rdcost, mode_rd_thresh,
                               rd_thresh_freq_fact[mode_index]))
         continue;
@@ -809,7 +810,7 @@
         best_pred_filter = mbmi->interp_filter;
         best_tx_size = mbmi->tx_size;
         best_ref_frame = ref_frame;
-        skip_txfm = x->skip_txfm[0];
+        best_mode_skip_txfm = x->skip_txfm[0];

         if (reuse_inter_pred) {
           free_pred_buffer(best_pred);
@@ -837,7 +838,7 @@
   mbmi->ref_frame[0]  = best_ref_frame;
   mbmi->mv[0].as_int  = frame_mv[best_mode][best_ref_frame].as_int;
   xd->mi[0].src_mi->bmi[0].as_mv[0].as_int = mbmi->mv[0].as_int;
-  x->skip_txfm[0] = skip_txfm;
+  x->skip_txfm[0] = best_mode_skip_txfm;

   // Perform intra prediction search, if the best SAD is above a certain
   // threshold.
@@ -887,7 +888,7 @@
         mbmi->uv_mode = this_mode;
         mbmi->mv[0].as_int = INVALID_MV;
       } else {
-        x->skip_txfm[0] = skip_txfm;
+        x->skip_txfm[0] = best_mode_skip_txfm;
         mbmi->tx_size = saved_tx_size;
       }
     }


redundant

redundant

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

--- mount_slash/mount_slash.h
+++ mount_slash/mount_slash.h
@@ -172,8 +172,6 @@
 extern char			 mountpoint[];

 extern struct psc_waitq		 msl_fhent_flush_waitq;
-extern struct timespec		 msl_bmap_max_lease;
-extern struct timespec		 msl_bmap_timeo_inc;

 extern struct psc_iostats	 msl_diord_stat;
 extern struct psc_iostats	 msl_diowr_stat;


Cycles: Don't check shader for volume when checking if camera is inside volume

Intersection code already ignores objects without volume closure so checking it
afterwards is not needed.

--- kernel/kernel_volume.h
+++ kernel/kernel_volume.h
@@ -992,30 +992,28 @@

 		ShaderData sd;
 		shader_setup_from_ray(kg, &sd, &isect, &volume_ray, 0, 0);
-		if(sd.flag & SD_HAS_VOLUME) {
-			if(sd.flag & SD_BACKFACING) {
-				/* If ray exited the volume and never entered to that volume
-				 * it means that camera is inside such a volume.
-				 */
-				bool is_enclosed = false;
-				for(int i = 0; i < enclosed_index; ++i) {
-					if(enclosed_volumes[i] == sd.object) {
-						is_enclosed = true;
-						break;
-					}
+		if(sd.flag & SD_BACKFACING) {
+			/* If ray exited the volume and never entered to that volume
+			 * it means that camera is inside such a volume.
+			 */
+			bool is_enclosed = false;
+			for(int i = 0; i < enclosed_index; ++i) {
+				if(enclosed_volumes[i] == sd.object) {
+					is_enclosed = true;
+					break;
 				}
-				if(is_enclosed == false) {
-					stack[stack_index].object = sd.object;
-					stack[stack_index].shader = sd.shader;
-					++stack_index;
-				}
-			}
-			else {
-				/* If ray from camera enters the volume, this volume shouldn't
-				 * be added to the stak on exit.
-				 */
-				enclosed_volumes[enclosed_index++] = sd.object;
-			}
+			}
+			if(is_enclosed == false) {
+				stack[stack_index].object = sd.object;
+				stack[stack_index].shader = sd.shader;
+				++stack_index;
+			}
+		}
+		else {
+			/* If ray from camera enters the volume, this volume shouldn't
+			 * be added to the stak on exit.
+			 */
+			enclosed_volumes[enclosed_index++] = sd.object;
 		}

 		/* Move ray forward. */


Use right shift to replace division in vp9_pick_inter_mode

Make the variable reduction_fac log2 based and explicitly use
right shift when computing intra_cost_penalty.

Change-Id: I208f1fb879a02debb3b3fc64f9fd06260dcf1c86

--- vp9/encoder/vp9_pickmode.c
+++ vp9/encoder/vp9_pickmode.c
@@ -537,9 +537,9 @@
   // Reduce the intra cost penalty for small blocks (<=16x16).
   const int reduction_fac =
       (cpi->sf.partition_search_type == VAR_BASED_PARTITION &&
-       bsize <= BLOCK_16X16) ? 4 : 1;
+       bsize <= BLOCK_16X16) ? 2 : 0;
   const int intra_cost_penalty = vp9_get_intra_cost_penalty(
-      cm->base_qindex, cm->y_dc_delta_q, cm->bit_depth) / reduction_fac;
+      cm->base_qindex, cm->y_dc_delta_q, cm->bit_depth) >> reduction_fac;
   const int64_t inter_mode_thresh = RDCOST(x->rdmult, x->rddiv,
                                            intra_cost_penalty, 0);
   const int8_t segment_id = mbmi->segment_id;


Adjust some logic for dynamic_resize 1 pass mode.

Use drop_frames_water_mark for threshold on buffer underflow,
and change threshold for resize down.

Change-Id: I2de19adce50abe9bcdc0b107528cec8cc1857fcc

--- vp9/encoder/vp9_ratectrl.c
+++ vp9/encoder/vp9_ratectrl.c
@@ -1813,7 +1813,8 @@
   if (cpi->rc.frames_since_key > 2 * cpi->framerate) {
     const int window = (int)(5 * cpi->framerate);
     cpi->resize_avg_qp += cm->base_qindex;
-    if (cpi->rc.buffer_level < 0)
+    if (cpi->rc.buffer_level < (int)(cpi->oxcf.drop_frames_water_mark *
+        rc->optimal_buffer_level / 100))
       ++cpi->resize_buffer_underflow;
     ++cpi->resize_count;
     // Check for resize action every "window" frames.
@@ -1824,7 +1825,7 @@
       // Resize back up if average QP is low, and we are currently in a resized
       // down state.
       if (cpi->resize_state == 0 &&
-          cpi->resize_buffer_underflow > (cpi->resize_count >> 3)) {
+          cpi->resize_buffer_underflow > (cpi->resize_count >> 2)) {
         resize_now = 1;
       } else if (cpi->resize_state == 1 &&
                  avg_qp < 40 * cpi->rc.worst_quality / 100) {


vppinfra: add 256-bit vector typedefs

vppinfra: add 256-bit vector typedefs

Change-Id: Ic07c1c25f5ad99225209c73b5ff4deb9c52f3b1e
Signed-off-by: Damjan Marion <9141bba8b2efed526e55cf796d48631af330ad98@cisco.com>

--- vppinfra/vppinfra/vector.h
+++ vppinfra/vppinfra/vector.h
@@ -95,6 +95,21 @@

 typedef f32 f32x4 _vector_size (16);
 typedef f64 f64x2 _vector_size (16);
+
+/* Signed 256 bit. */
+typedef i8 i8x32 _vector_size (32);
+typedef i16 i16x16 _vector_size (32);
+typedef i32 i32x8 _vector_size (32);
+typedef long long i64x4 _vector_size (32);
+
+/* Unsigned 256 bit. */
+typedef u8 u8x32 _vector_size (32);
+typedef u16 u16x16 _vector_size (32);
+typedef u32 u32x8 _vector_size (32);
+typedef u64 u64x4 _vector_size (32);
+
+typedef f32 f32x8 _vector_size (32);
+typedef f64 f64x4 _vector_size (32);
 #endif /* CLIB_HAVE_VEC128 */

 /* Vector word sized types. */


mdbox: Storage rebuild should ignore ACLs for mailboxes.

--HG--
branch : HEAD

--- src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
+++ src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
@@ -510,6 +510,7 @@
 		ctx->default_list = ns->list;

 	iter = mailbox_list_iter_init(ns->list, "*",
+				      MAILBOX_LIST_ITER_RAW_LIST |
 				      MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
 	while ((info = mailbox_list_iter_next(iter)) != NULL) {
 		if ((info->flags & (MAILBOX_NONEXISTENT |


exit: pidns: fix/update the comments in zap_pid_ns_processes()

The comments in zap_pid_ns_processes() are not clear, we need to explain
how this code actually works.

1. "Ignore SIGCHLD" looks like optimization but it is not, we also
   need this for correctness.

2. The comment above sys_wait4() could tell more.

   EXIT_ZOMBIE child is only possible if it has exited before we
   ignored SIGCHLD. Or if it is traced from the parent namespace,
   but in this case it will be reaped by debugger after detach,
   sys_wait4() acts as a synchronization point.

3. The comment about TASK_DEAD (EXIT_DEAD in fact) children is
   outdated. Contrary to what it says we do not need to make sure
   they all go away after 0a01f2cc390e "pidns: Make the pidns proc
   mount/umount logic obvious".

   At the same time, we do need to wait for nr_hashed==init_pids,
   but the reasons are quite different and not obvious: setns().

Signed-off-by: Oleg Nesterov <20b70f0af00562e63758b9ee42012ecc96c58590@redhat.com>
Cc: "Eric W. Biederman" <8a741aa8cbd77ebc4a56ddb528ce9fd15d42f034@xmission.com>
Cc: Aaron Tomlin <4ed61b0b61ab8b39dcdee4eca4730f0b305b3047@redhat.com>
Cc: Pavel Emelyanov <c9a32589e048e044184536f7ac71ef92fe82df3e@parallels.com>
Cc: Serge Hallyn <3df611b026e4639bee8aef7a4beb2e39fcebb313@ubuntu.com>
Cc: Sterling Alexander <9eb90039aece32f9874377e394d636d5e7a331fe@redhat.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- kernel/pid_namespace.c
+++ kernel/pid_namespace.c
@@ -190,7 +190,11 @@
 	/* Don't allow any more processes into the pid namespace */
 	disable_pid_allocation(pid_ns);

-	/* Ignore SIGCHLD causing any terminated children to autoreap */
+	/*
+	 * Ignore SIGCHLD causing any terminated children to autoreap.
+	 * This speeds up the namespace shutdown, plus see the comment
+	 * below.
+	 */
 	spin_lock_irq(&me->sighand->siglock);
 	me->sighand->action[SIGCHLD - 1].sa.sa_handler = SIG_IGN;
 	spin_unlock_irq(&me->sighand->siglock);
@@ -223,15 +227,31 @@
 	}
 	read_unlock(&tasklist_lock);

-	/* Firstly reap the EXIT_ZOMBIE children we may have. */
+	/*
+	 * Reap the EXIT_ZOMBIE children we had before we ignored SIGCHLD.
+	 * sys_wait4() will also block until our children traced from the
+	 * parent namespace are detached and become EXIT_DEAD.
+	 */
 	do {
 		clear_thread_flag(TIF_SIGPENDING);
 		rc = sys_wait4(-1, NULL, __WALL, NULL);
 	} while (rc != -ECHILD);

 	/*
-	 * sys_wait4() above can't reap the TASK_DEAD children.
-	 * Make sure they all go away, see free_pid().
+	 * sys_wait4() above can't reap the EXIT_DEAD children but we do not
+	 * really care, we could reparent them to the global init. We could
+	 * exit and reap ->child_reaper even if it is not the last thread in
+	 * this pid_ns, free_pid(nr_hashed == 0) calls proc_cleanup_work(),
+	 * pid_ns can not go away until proc_kill_sb() drops the reference.
+	 *
+	 * But this ns can also have other tasks injected by setns()+fork().
+	 * Again, ignoring the user visible semantics we do not really need
+	 * to wait until they are all reaped, but they can be reparented to
+	 * us and thus we need to ensure that pid->child_reaper stays valid
+	 * until they all go away. See free_pid()->wake_up_process().
+	 *
+	 * We rely on ignored SIGCHLD, an injected zombie must be autoreaped
+	 * if reparented.
 	 */
 	for (;;) {
 		set_current_state(TASK_UNINTERRUPTIBLE);


nrf5/bluetooth: Correcting indention.

nrf5/bluetooth: Correcting indention.

--- nrf5/bluetooth/ble_drv.c
+++ nrf5/bluetooth/ble_drv.c
@@ -745,17 +745,17 @@
             break;

         case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
-             BLE_DRIVER_LOG("BLE EVT SEC PARAMS REQUEST\n");
-             // pairing not supported
-             (void)sd_ble_gap_sec_params_reply(p_ble_evt->evt.gatts_evt.conn_handle,
-                                               BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP,
-                                               NULL, NULL);
-             break;
+            BLE_DRIVER_LOG("BLE EVT SEC PARAMS REQUEST\n");
+            // pairing not supported
+            (void)sd_ble_gap_sec_params_reply(p_ble_evt->evt.gatts_evt.conn_handle,
+                                              BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP,
+                                              NULL, NULL);
+            break;

 #if (BLUETOOTH_SD == 130) || (BLUETOOTH_SD == 132)
         case BLE_GAP_EVT_ADV_REPORT:
-             BLE_DRIVER_LOG("BLE EVT ADV REPORT\n");
-             break;
+            BLE_DRIVER_LOG("BLE EVT ADV REPORT\n");
+            break;
 #endif

         default:


mdbox: Don't fail storage rebuild just because storage/ directory doesn't exist. It may be an account for a new user that doesn't yet have any mails.

--- src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
+++ src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
@@ -887,19 +887,7 @@
 				     struct mdbox_map_atomic_context *atomic)
 {
 	struct mdbox_storage_rebuild_context *ctx;
-	struct stat st;
 	int ret;
-
-	if (stat(storage->storage_dir, &st) < 0) {
-		if (errno == ENOENT) {
-			/* no multi-dbox files */
-			return 0;
-		}
-
-		mail_storage_set_critical(&storage->storage.storage,
-			"stat(%s) failed: %m", storage->storage_dir);
-		return -1;
-	}

 	ctx = mdbox_storage_rebuild_init(storage, atomic);
 	ret = mdbox_storage_rebuild_scan(ctx);


bts-trx: Don't set OPSTATE enabled during trx_init

At that time we schedule a POWERON command towards osmo-trx, so let the
callback of RSP POWERON set the OPSTATE in l1if_poweronoff_cb rather
than setting it without waiting for confirmation from osmo-trx.

Change-Id: Ib36a073cae5e1522821a04d8806648562f4e0f5b

--- src/osmo-bts-trx/l1_if.c
+++ src/osmo-bts-trx/l1_if.c
@@ -405,9 +405,6 @@

 	if (trx == trx->bts->c0)
 		lchan_init_lapdm(&trx->ts[0].lchan[CCCH_LCHAN]);
-
-	/* Set to Operational State: Enabled */
-	oml_mo_state_chg(&trx->mo, NM_OPSTATE_ENABLED, NM_AVSTATE_OK);

 	/* Send OPSTART ack */
 	return oml_mo_opstart_ack(&trx->mo);


Cast uint64_t to unsigned int for %u format specifier.

Fixes 80.

--- cmd/mid/zone.c
+++ cmd/mid/zone.c
@@ -131,27 +131,28 @@
 static FILE *zpipe(Rng *r)
 {
 	Pipe p = {};
-	pipeadd(&p, "lvlgen", "25 25 3 -s %u ", rngint(r));
+	pipeadd(&p, "lvlgen", "25 25 3 -s %lu ", (unsigned long) rngint(r));

-	pipeadd(&p, "itmgen", "-s %u %d 1", rngint(r), ItemStatup);
+	pipeadd(&p, "itmgen", "-s %lu %d 1", (unsigned long) rngint(r), ItemStatup);

-	pipeadd(&p, "itmgen", "-s %u %d %d %d %d %d %d %d %d 50", rngint(r),
+	pipeadd(&p, "itmgen", "-s %lu %d %d %d %d %d %d %d %d 50", (unsigned long) rngint(r),
 		ItemCopper, ItemCopper, ItemCopper, ItemCopper, ItemCopper,
 		ItemSilver, ItemSilver,
 		ItemGold
 	);
-	pipeadd(&p, "itmgen", "-s %u %d %d %d %d %d 5", rngint(r),
+	pipeadd(&p, "itmgen", "-s %lu %d %d %d %d %d 5", (unsigned long) rngint(r),
 		ItemHealth, ItemHealth, ItemHealth, ItemHealth,
 		ItemCarrot
 	);
-	pipeadd(&p, "itmgen", "-s %u %d 1", rngint(r), ItemHamCan);
+	pipeadd(&p, "itmgen", "-s %lu %d 1", (unsigned long) rngint(r), ItemHamCan);

-	pipeadd(&p, "envgen", "-s %u %d 1", rngint(r), EnvShrempty);
+	pipeadd(&p, "envgen", "-s %lu %d 1", (unsigned long) rngint(r), EnvShrempty);

-	pipeadd(&p, "envgen", "-s %u %d %d %d 2", rngint(r),
+	pipeadd(&p, "envgen", "-s %lu %d %d %d 2", (unsigned long) rngint(r),
 		EnvSwdStoneHp, EnvSwdStoneDex, EnvSwdStoneStr);

-	pipeadd(&p, "enmgen", "-s %u %d %d %d %d %d %d %d 3 3 4 5 50", rngint(r),
+	pipeadd(&p, "enmgen", "-s %lu %d %d %d %d %d %d %d 3 3 4 5 50",
+		(unsigned long) rngint(r),
 		EnemyUnti, EnemyUnti, EnemyUnti,
 		EnemyNous, EnemyNous, EnemyNous, EnemyNous,
 		EnemyDa, EnemyDa, EnemyDa,


Add option to use RPI internal pull-up

Add option to use RPI internal pull-up

This allows using the internal pull-up instead of an external pull-up.
This feature currently relies on the 'gpio' utility from wiringPI. Since
sysfs doesn't export this feature.

--- wattcher_to_rpi/wattcher.c
+++ wattcher_to_rpi/wattcher.c
@@ -45,7 +45,9 @@

 #include <sys/epoll.h>

-#define GPIO_PINNUM "17"
+#define ENABLE_RPI_PULLUP 1
+
+#define GPIO_PINNUM "4"
 #define TRIGGER_EDGE "rising"

 #define CVALUE 600
@@ -98,6 +100,22 @@
 	}
 }

+#ifdef ENABLE_RPI_PULLUP
+int enable_pullup()
+{
+	int status;
+
+	// Call the 'gpio' utlitity from WiringPI, since sysfs interface
+	// doesn't support changing this.
+	status = system("gpio -g mode " GPIO_PINNUM " up");
+	if (! WIFEXITED(status) || WEXITSTATUS(status) != 0) {
+		return -1;
+	}
+
+	return 0;
+}
+#endif // ENABLE_RPI_PULLUP
+
 int main()
 {
 	struct epoll_event ev[EPOLL_MAX_EVENTS_PER_RUN];
@@ -142,6 +160,15 @@
 		goto cleanup;
 	}
 	close(gpio_fd);
+
+#ifdef ENABLE_RPI_PULLUP
+	// Enable internal pull-up
+	if (enable_pullup() != 0) {
+		fprintf(stderr, "Failed to enable internal pull-up\n");
+		retval = EXIT_FAILURE;
+		goto cleanup;
+	}
+#endif // ENABLE_RPI_PULLUP

 	// open gpio value file
 	if ((gpio_fd = open("/sys/class/gpio/gpio"GPIO_PINNUM"/value", O_RDONLY)) == -1) {


WIP 5-stage

WIP 5-stage

--- multisim/run_sscalar_io.c
+++ multisim/run_sscalar_io.c
@@ -28,6 +28,177 @@
 #include "run_simple.h"
 #include "loadelf.h"

+/*
+ * Let's first model a simple five stage pipeline with a 16 KiB
+ * directly mapped I$ and a 8 KiB directly mapped D$.  We'll use 32 B
+ * lines, which bring us to 512 lines for the I$ and 256 for the D$.
+ *
+ * We'll also fix the address space at 128 MiB (for now), which means
+ * 27 VA/PA bits and thus 13-14 bits wide tags, plus a valid bit.
+ * Access to the arrays are 32-bit wide (possibly wider or banked in
+ * future for wider fetch).  Note, that bit 31 must be valid, so we
+ * have "holes" in the address bits and describe this with a mask.
+ *
+ * NB: normally we'd keep all this state in the `cpu_state`, but we'll
+ * only ever run one instance of this.
+ */
+
+#define LINESIZELG2 5
+#define DC_NSETLG2  8
+#define IC_NSETLG2  9
+#define MAX_NSETLG2  9
+
+#define LINE_VALID  (1 << 31)
+
+/* Cache State Machine */
+typedef enum {
+    CSM_READY,
+
+    CSM_WANT_TO_READ,
+    CSM_FILLING,
+    CSM_UPDATE_TAG,
+
+    CSM_WANT_TO_WRITE,
+    CSM_WRITING,
+} cache_state_t;
+
+typedef struct cache_st {
+    int nsetlg2;
+    uint32_t tag[1 << MAX_NSETLG2];
+    uint32_t data[1 << (MAX_NSETLG2 + LINESIZELG2 - 2)];
+    cache_state_t state;
+
+    int fill_counter;
+    uint32_t fill_address;
+    uint32_t tag_bits;
+    uint32_t set_index;
+    uint32_t data_index;
+} cache_t;
+
+/*
+ * We don't know much about the memory, so I'll make persimistic
+ * assumptions that we can only have a single transaction outstanding
+ * of a certain latency.  However, I do assume we can transfer bursts
+ * at the rate of 32-bit per cycle.
+ */
+
+#define MEMORY_CAS 6
+
+
+
+static struct {
+    int busy_cycles;
+    cache_t *busy_with;
+} memory;
+
+static void cache_read(cache_t *c,
+		       uint32_t address, bool readenable,
+		       bool *ready,
+		       uint32_t *rdata, bool *rdata_valid)
+{
+    memory_exception_t error;
+    uint32_t word_address = address >> 2; // address[:2]
+    uint32_t data_index   = word_address & ((1 << (c->nsetlg2 + LINESIZELG2 - 2)) - 1); // address[I:2]
+
+    uint32_t line_index   = address >> LINESIZELG2;
+    uint32_t line_offset  = address - (line_index << LINESIZELG2);
+    uint32_t tag_bits     = line_index >> c->nsetlg2;
+    uint32_t set_index    = line_index - (tag_bits << c->nsetlg2);
+
+    switch (c->state) {
+    case CSM_READY:
+	*rdata = c->data[data_index];
+	*rdata_valid = c->tag[set_index] == (tag_bits | LINE_VALID);
+
+	if (!*rdata_valid) {
+	    c->fill_counter = 1 << (LINESIZELG2 - 2);
+	    c->fill_address = address & (-1 << LINESIZELG2);
+	    c->tag_bits = tag_bits;
+	    c->set_index = set_index;
+	    c->data_index = data_index;
+	    c->state = CSM_WANT_TO_READ; // XXX we could skip this if memory is ready
+	}
+	break;
+
+    case CSM_WANT_TO_READ:
+	if (memory.busy_with == 0) {
+	    memory.busy_with = c;
+	    memory.busy_cycles = MEMORY_CAS;
+	    c->state = CSM_FILLING;
+	}
+	break;
+
+    case CSM_FILLING:
+	if (memory.busy_cycles == 0) {
+	    if (c->fill_counter) {
+		int word_index = (c->fill_address >> 2) & ((1 << (c->nsetlg2 + LINESIZELG2 - 2)) - 1);
+
+		printf("FILLING I$ from %08x -> <%d,%d>\n",
+		       c->fill_address,
+		       word_index >> (LINESIZELG2 - 2),
+		       word_index & ((1 << LINESIZELG2)/4 - 1));
+		c->data[word_index] = (uint32_t)arch->load(state, ic_fill_address, 4, &error);
+		c->fill_counter -= 1;
+		c->fill_address += 4;
+		if (c->fill_counter == 0) {
+		    memory.busy_with = 0;
+		    c->state = CSM_UPDATE_TAG;
+		}
+	    }
+	} else
+	    --memory.busy_cycles;
+	break;
+
+    case CSM_UPDATE_TAG:
+	c->tag[c->set_index] = c->tag_bits | LINE_VALID;
+	c->state = CSM_READY;
+	*rdata = c->data[c->data_index];
+	*rdata_valid = true;
+	break;
+
+    default:
+	assert(0); // XXX Not done yet
+    }
+
+    *ready = c->state == CSR_READY;
+}
+
+
+cache_t ic = { .nsetlg2 = IC_NSETLG2 };
+
+#if 0
+/*
+static struct {
+    bool valid;
+    uint32_t pc;
+    uint32_t insn;
+    memory_exception_t error;
+} fetch_output;
+
+
+static void do_fetch(const arch_t *arch, cpu_state_t *state, verbosity_t verbosity)
+{
+    memory_exception_t error;
+
+    fetch_output.valid = false;
+
+    cache_read(&ic,
+
+
+    }
+
+    fetch.pc = state->pc;
+        /* Using the world's simplest branch predictor: assume fall through */
+        state->pc += 4;
+        state->pc = CANONICALIZE(state->pc);
+        fetch.insn = (uint32_t)arch->load(state, fetch.pc, 4, &fetch.error);
+        fetch.valid = true;
+    } else
+        fetch.valid = false;
+}
+*/
+#endif
+
 bool
 step_sscalar_in_order(
     const arch_t *arch, cpu_state_t *state, cpu_state_t *costate,
@@ -37,7 +208,13 @@
     uint64_t orig_r[32];
     uint64_t pc       = state->pc;
     memory_exception_t error;
-    uint32_t inst     = (uint32_t)arch->load(state, pc, 0 /* = ifetch */, &error);
+    uint32_t inst;
+    bool ic_ready, inst_valid;
+
+    cache_read(&ic, pc, 1, &ic_ready, &inst, &inst_valid);
+
+    if (!inst_valid)
+	goto skip;

     if (error != MEMORY_SUCCESS)
         return error == MEMORY_FATAL;
@@ -161,6 +338,7 @@
     if (dec.dest_reg != ISA_NO_REG)
 	assert(state->r[dec.dest_reg] == costate->r[dec.dest_reg]);

+skip:
     arch->tick(state);

     return false;


Volume in fifo

Volume in fifo

--- musicplayer/common/fifo.h
+++ musicplayer/common/fifo.h
@@ -5,16 +5,19 @@
 #include <cstring>
 #include <cstdint>

+#include <coreutils/log.h>
+
 class Fifo {

 public:
 	Fifo(int size) {
+		volume = 1.0;
 		buffer = NULL;
 		if(size > 0) {
 			buffer = (uint8_t *)malloc(size);
 		}
 		bufPtr = buffer;
-		position = 0;
+		lastSoundPos = position = 0;
 	}
 	~Fifo() {
 		if(buffer)
@@ -49,25 +52,43 @@
 	void processBytes(uint8_t *src, int bytelen) {
 		int soundPos = -1;
 		short *samples = (short*)src;
+
+		if(volume != 1.0) {
+			for(int i=0; i<bytelen/2; i++) {
+				samples[i] = (samples[i] * volume);
+			}
+		}
 		for(int i=0; i<bytelen/2; i++) {
 			short s = samples[i];
 			if(s > 256 || s < -256)
 				soundPos = i;
 		}
-
 		if(soundPos >= 0)
 			lastSoundPos = position + soundPos;

 		position += (bytelen/2);
 	}

+
+	void clear() {
+		volume = 1.0;
+		bufPtr = buffer;
+		lastSoundPos = position = 0;
+
+	}
+
 	int filled() { return bufPtr - buffer; }

 	int getSilence() { return position - lastSoundPos; }
+	void setVolume(float v) { volume = v; }

 	uint8_t *ptr() { return bufPtr; }

 private:
+	float volume;
+
+	//short startLoop[44100*10];
+	//int loopPos;
 	//int size;
 	int lastSoundPos;
 	int position;


[lwIP] use timeval in libc when minilibc is used

--- components/net/lwip-1.4.1/src/arch/include/arch/cc.h
+++ components/net/lwip-1.4.1/src/arch/include/arch/cc.h
@@ -69,7 +69,7 @@
 #define LWIP_PROVIDE_ERRNO
 #endif

-#ifdef RT_USING_LIBC
+#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC)
 #include <sys/time.h>
 #define LWIP_TIMEVAL_PRIVATE	   0
 #else


Update comments to include description of the base IMU name and its heading axis options.

--- OpenSim/Simulation/OpenSense/OpenSenseUtilities.h
+++ OpenSim/Simulation/OpenSense/OpenSenseUtilities.h
@@ -38,7 +38,12 @@
         /// @{
         /** Load a TimeSeriesTable of Rotation matrices from a Storage file containing
             quaternions as data elements. Optionally provide a range of times for data
-            to be averaged. By default just uses the first time frame.*/
+            to be averaged. By default just uses the first time frame.
+            Additional options include the name of the base IMU and its axis that
+            represents the heading (forward) direction. These are used to perform
+            a heading correction on all the experimental (quaternion) data so that
+            when tracking rotation data, the initial pose of the model is facing
+            forward. */
         static TimeSeriesTableRotation  convertQuaternionsToRotations(
             const TimeSeriesTableQuaternion& qauternionsTable,
             const SimTK::Array_<int>& startEnd = { 0, 1 },


netfilter: ebtables: split do_replace into two functions

once CONFIG_COMPAT support is merged this allows
to call do_replace_finish() after doing the CONFIG_COMPAT conversion
instead of copy & pasting this.

Signed-off-by: Florian Westphal <cef439e78636cdab99cd2923826c5065a0743e5b@strlen.de>

--- net/bridge/netfilter/ebtables.c
+++ net/bridge/netfilter/ebtables.c
@@ -959,91 +959,45 @@
 	}
 }

-/* replace the table */
-static int do_replace(struct net *net, const void __user *user,
-		      unsigned int len)
-{
-	int ret, i, countersize;
-	struct ebt_table_info *newinfo;
-	struct ebt_replace tmp;
-	struct ebt_table *t;
+static int do_replace_finish(struct net *net, struct ebt_replace *repl,
+			      struct ebt_table_info *newinfo)
+{
+	int ret, i;
 	struct ebt_counter *counterstmp = NULL;
 	/* used to be able to unlock earlier */
 	struct ebt_table_info *table;
-
-	if (copy_from_user(&tmp, user, sizeof(tmp)) != 0)
-		return -EFAULT;
-
-	if (len != sizeof(tmp) + tmp.entries_size) {
-		BUGPRINT("Wrong len argument\n");
-		return -EINVAL;
-	}
-
-	if (tmp.entries_size == 0) {
-		BUGPRINT("Entries_size never zero\n");
-		return -EINVAL;
-	}
-	/* overflow check */
-	if (tmp.nentries >= ((INT_MAX - sizeof(struct ebt_table_info)) / NR_CPUS -
-			SMP_CACHE_BYTES) / sizeof(struct ebt_counter))
-		return -ENOMEM;
-	if (tmp.num_counters >= INT_MAX / sizeof(struct ebt_counter))
-		return -ENOMEM;
-
-	countersize = COUNTER_OFFSET(tmp.nentries) * nr_cpu_ids;
-	newinfo = vmalloc(sizeof(*newinfo) + countersize);
-	if (!newinfo)
-		return -ENOMEM;
-
-	if (countersize)
-		memset(newinfo->counters, 0, countersize);
-
-	newinfo->entries = vmalloc(tmp.entries_size);
-	if (!newinfo->entries) {
-		ret = -ENOMEM;
-		goto free_newinfo;
-	}
-	if (copy_from_user(
-	   newinfo->entries, tmp.entries, tmp.entries_size) != 0) {
-		BUGPRINT("Couldn't copy entries from userspace\n");
-		ret = -EFAULT;
-		goto free_entries;
-	}
+	struct ebt_table *t;

 	/* the user wants counters back
 	   the check on the size is done later, when we have the lock */
-	if (tmp.num_counters) {
-		counterstmp = vmalloc(tmp.num_counters * sizeof(*counterstmp));
-		if (!counterstmp) {
-			ret = -ENOMEM;
-			goto free_entries;
-		}
-	}
-	else
-		counterstmp = NULL;
-
-	/* this can get initialized by translate_table() */
+	if (repl->num_counters) {
+		unsigned long size = repl->num_counters * sizeof(*counterstmp);
+		counterstmp = vmalloc(size);
+		if (!counterstmp)
+			return -ENOMEM;
+	}
+
 	newinfo->chainstack = NULL;
-	ret = ebt_verify_pointers(&tmp, newinfo);
+	ret = ebt_verify_pointers(repl, newinfo);
 	if (ret != 0)
 		goto free_counterstmp;

-	ret = translate_table(net, tmp.name, newinfo);
+	ret = translate_table(net, repl->name, newinfo);

 	if (ret != 0)
 		goto free_counterstmp;

-	t = find_table_lock(net, tmp.name, &ret, &ebt_mutex);
+	t = find_table_lock(net, repl->name, &ret, &ebt_mutex);
 	if (!t) {
 		ret = -ENOENT;
 		goto free_iterate;
 	}

 	/* the table doesn't like it */
-	if (t->check && (ret = t->check(newinfo, tmp.valid_hooks)))
+	if (t->check && (ret = t->check(newinfo, repl->valid_hooks)))
 		goto free_unlock;

-	if (tmp.num_counters && tmp.num_counters != t->private->nentries) {
+	if (repl->num_counters && repl->num_counters != t->private->nentries) {
 		BUGPRINT("Wrong nr. of counters requested\n");
 		ret = -EINVAL;
 		goto free_unlock;
@@ -1059,7 +1013,7 @@
 		module_put(t->me);
 	/* we need an atomic snapshot of the counters */
 	write_lock_bh(&t->lock);
-	if (tmp.num_counters)
+	if (repl->num_counters)
 		get_counters(t->private->counters, counterstmp,
 		   t->private->nentries);

@@ -1070,10 +1024,9 @@
 	   allocation. Only reason why this is done is because this way the lock
 	   is held only once, while this doesn't bring the kernel into a
 	   dangerous state. */
-	if (tmp.num_counters &&
-	   copy_to_user(tmp.counters, counterstmp,
-	   tmp.num_counters * sizeof(struct ebt_counter))) {
-		BUGPRINT("Couldn't copy counters to userspace\n");
+	if (repl->num_counters &&
+	   copy_to_user(repl->counters, counterstmp,
+	   repl->num_counters * sizeof(struct ebt_counter))) {
 		ret = -EFAULT;
 	}
 	else
@@ -1107,6 +1060,59 @@
 			vfree(newinfo->chainstack[i]);
 		vfree(newinfo->chainstack);
 	}
+	return ret;
+}
+
+/* replace the table */
+static int do_replace(struct net *net, const void __user *user,
+		      unsigned int len)
+{
+	int ret, countersize;
+	struct ebt_table_info *newinfo;
+	struct ebt_replace tmp;
+
+	if (copy_from_user(&tmp, user, sizeof(tmp)) != 0)
+		return -EFAULT;
+
+	if (len != sizeof(tmp) + tmp.entries_size) {
+		BUGPRINT("Wrong len argument\n");
+		return -EINVAL;
+	}
+
+	if (tmp.entries_size == 0) {
+		BUGPRINT("Entries_size never zero\n");
+		return -EINVAL;
+	}
+	/* overflow check */
+	if (tmp.nentries >= ((INT_MAX - sizeof(struct ebt_table_info)) /
+			NR_CPUS - SMP_CACHE_BYTES) / sizeof(struct ebt_counter))
+		return -ENOMEM;
+	if (tmp.num_counters >= INT_MAX / sizeof(struct ebt_counter))
+		return -ENOMEM;
+
+	countersize = COUNTER_OFFSET(tmp.nentries) * nr_cpu_ids;
+	newinfo = vmalloc(sizeof(*newinfo) + countersize);
+	if (!newinfo)
+		return -ENOMEM;
+
+	if (countersize)
+		memset(newinfo->counters, 0, countersize);
+
+	newinfo->entries = vmalloc(tmp.entries_size);
+	if (!newinfo->entries) {
+		ret = -ENOMEM;
+		goto free_newinfo;
+	}
+	if (copy_from_user(
+	   newinfo->entries, tmp.entries, tmp.entries_size) != 0) {
+		BUGPRINT("Couldn't copy entries from userspace\n");
+		ret = -EFAULT;
+		goto free_entries;
+	}
+
+	ret = do_replace_finish(net, &tmp, newinfo);
+	if (ret == 0)
+		return ret;
 free_entries:
 	vfree(newinfo->entries);
 free_newinfo:


MOAR protocol violations (still about multipart)

--- naxsi_src/naxsi_runtime.c
+++ naxsi_src/naxsi_runtime.c
@@ -93,6 +93,15 @@
 						/*block*/ 1,  /*allow*/ 0, /*log*/ 0,
 						/*lnk_to & from*/ 0, 0,
 						/*br ptrs*/ NULL};
+
+ngx_http_rule_t nx_int__uncommon_post_boundary = {/*type*/ 0, /*whitelist flag*/ 0,
+						   /*wl_id ptr*/ NULL, /*rule_id*/ 13,
+						   /*log_msg*/ NULL, /*score*/ 0,
+						   /*sscores*/ NULL,
+						   /*sc_block*/ 1,  /*sc_allow*/ 0,
+						   /*block*/ 1,  /*allow*/ 0, /*log*/ 0,
+						   /*lnk_to & from*/ 0, 0,
+						   /*br ptrs*/ NULL};

 ngx_http_rule_t nx_int__big_request = {/*type*/ 0, /*whitelist flag*/ 0,
@@ -1168,7 +1177,7 @@
 ** [XXX] : this function sucks ! I don't parse bigger-than-body-size posts that
 **	   are partially stored in files, TODO ;)
 */
-//#define post_heavy_debug
+#define post_heavy_debug

 /*
@@ -1299,26 +1308,25 @@
 #endif
   /*extract boundary*/
   if (nx_content_type_parse(r, (unsigned char **) &boundary, &boundary_len) != NGX_OK) {
-    ngx_http_apply_rulematch_v_n(&nx_int__uncommon_post_format, ctx, r, NULL, NULL, BODY, 1, 0);
+    ngx_http_apply_rulematch_v_n(&nx_int__uncommon_post_boundary, ctx, r, NULL, NULL, BODY, 1, 0);
     return ;
   }
   /* fetch every line starting with boundary */
   idx = 0;
   while (idx < len) {
-#ifdef post_heavy_debug
-    ngx_log_debug(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
-		  "XX-POST data : (%s)", src+idx);
-#endif
-    /* if we've reached the last boundary '--' + boundary + '--' + '\r\n'*/
-    if (idx+boundary_len+6 >= len)
-      {
-#ifdef post_heavy_debug
-	ngx_log_debug(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
-		      "XX-reached end, not enough len");
-#endif
+    /* if we've reached the last boundary '--' + boundary + '--' + '\r\n'$END */
+    if (idx+boundary_len+6 == len) {
+      if (ngx_strncmp(src+idx, "--", 2) ||
+	  ngx_strncmp(src+idx+2, boundary, boundary_len) ||
+	  ngx_strncmp(src+idx+boundary_len+2, "--", 2) ||
+	  ngx_strncmp(src+idx+boundary_len+2+2, "\r\n", 2)) {
+	/* bad closing boundary ?*/
+	ngx_http_apply_rulematch_v_n(&nx_int__uncommon_post_boundary, ctx, r, NULL, NULL, BODY, 1, 0);
+	return ;
+      } else
 	break;
-      }
-    //check if line starts with -- (pre-boundary stuff)
+    }
+    /* --boundary\r\n : New var */
     if (src[idx] != '-' || src[idx+1] != '-' ||
 	//and if it's really followed by a boundary
 	ngx_strncmp(src+idx+2, boundary, boundary_len) ||
@@ -1326,12 +1334,12 @@
 	idx+boundary_len + 2 + 2  >= len ||
 	//and if it's followed by \r\n
 	src[idx+boundary_len+2] != '\r' || src[idx+boundary_len+3] != '\n') {
-
+      /* bad boundary */
+      ngx_http_apply_rulematch_v_n(&nx_int__uncommon_post_boundary, ctx, r, NULL, NULL, BODY, 1, 0);
       dummy_error_fatal(ctx, r, "POST data is malformed (%s)", src+idx);
       return ;
     }
     idx += boundary_len + 4;
-	  /* ---- */
     /* we have two cases :
     ** ---- file upload
     ** Content-Disposition: form-data; name="somename"; filename="NetworkManager.conf"\r\n
@@ -1356,15 +1364,14 @@
       dummy_error_fatal(ctx, r, "POST data : malformed boundary line");
       return ;
     }
-
-
+    /* Parse content-disposition, extract name / filename */
     varn_start = varn_end = filen_start = filen_end = NULL;
     if (nx_content_disposition_parse(src+idx, line_end, &varn_start, &varn_end,
 				     &filen_start, &filen_end, r) != NGX_OK) {
       ngx_http_apply_rulematch_v_n(&nx_int__uncommon_post_format, ctx, r, NULL, NULL, BODY, 1, 0);
       return ;
     }
-    // check that var name is present and not malformed
+    /* var name is mandatory */
     if (!varn_start || !varn_end || varn_end <= varn_start) {
       ngx_http_apply_rulematch_v_n(&nx_int__uncommon_post_format, ctx, r, NULL, NULL, BODY, 1, 0);
       dummy_error_fatal(ctx, r, "POST data : no 'name' in POST var");


tcp: do not create inetpeer on SYNACK message

Another problem on SYNFLOOD/DDOS attack is the inetpeer cache getting
larger and larger, using lots of memory and cpu time.

tcp_v4_send_synack()
->inet_csk_route_req()
 ->ip_route_output_flow()
  ->rt_set_nexthop()
   ->rt_init_metrics()
    ->inet_getpeer( create = true)

This is a side effect of commit a4daad6b09230 (net: Pre-COW metrics for
TCP) added in 2.6.39

Possible solution :

Instruct inet_csk_route_req() to remove FLOWI_FLAG_PRECOW_METRICS

Before patch :

# grep peer /proc/slabinfo
inet_peer_cache   4175430 4175430    192   42    2 : tunables    0    0    0 : slabdata  99415  99415      0

Samples: 41K of event 'cycles', Event count (approx.): 30716565122
+  20,24%      ksoftirqd/0  [kernel.kallsyms]           [k] inet_getpeer
+   8,19%      ksoftirqd/0  [kernel.kallsyms]           [k] peer_avl_rebalance.isra.1
+   4,81%      ksoftirqd/0  [kernel.kallsyms]           [k] sha_transform
+   3,64%      ksoftirqd/0  [kernel.kallsyms]           [k] fib_table_lookup
+   2,36%      ksoftirqd/0  [ixgbe]                     [k] ixgbe_poll
+   2,16%      ksoftirqd/0  [kernel.kallsyms]           [k] __ip_route_output_key
+   2,11%      ksoftirqd/0  [kernel.kallsyms]           [k] kernel_map_pages
+   2,11%      ksoftirqd/0  [kernel.kallsyms]           [k] ip_route_input_common
+   2,01%      ksoftirqd/0  [kernel.kallsyms]           [k] __inet_lookup_established
+   1,83%      ksoftirqd/0  [kernel.kallsyms]           [k] md5_transform
+   1,75%      ksoftirqd/0  [kernel.kallsyms]           [k] check_leaf.isra.9
+   1,49%      ksoftirqd/0  [kernel.kallsyms]           [k] ipt_do_table
+   1,46%      ksoftirqd/0  [kernel.kallsyms]           [k] hrtimer_interrupt
+   1,45%      ksoftirqd/0  [kernel.kallsyms]           [k] kmem_cache_alloc
+   1,29%      ksoftirqd/0  [kernel.kallsyms]           [k] inet_csk_search_req
+   1,29%      ksoftirqd/0  [kernel.kallsyms]           [k] __netif_receive_skb
+   1,16%      ksoftirqd/0  [kernel.kallsyms]           [k] copy_user_generic_string
+   1,15%      ksoftirqd/0  [kernel.kallsyms]           [k] kmem_cache_free
+   1,02%      ksoftirqd/0  [kernel.kallsyms]           [k] tcp_make_synack
+   0,93%      ksoftirqd/0  [kernel.kallsyms]           [k] _raw_spin_lock_bh
+   0,87%      ksoftirqd/0  [kernel.kallsyms]           [k] __call_rcu
+   0,84%      ksoftirqd/0  [kernel.kallsyms]           [k] rt_garbage_collect
+   0,84%      ksoftirqd/0  [kernel.kallsyms]           [k] fib_rules_lookup

Signed-off-by: Eric Dumazet <312c7d941f03386814be517ffdb3e0eb6624e275@google.com>
Cc: Hans Schillstrom <007c2b1b705aace5317f5740f3fa4206849cc3b6@ericsson.com>
Cc: Jesper Dangaard Brouer <980bdea81946be3dffddbcbbdb1b5761713ff28c@redhat.com>
Cc: Neal Cardwell <58d301c70203188c35d379474c26c9cc0636a189@google.com>
Cc: Tom Herbert <0786393240831fc3b5d6ed63658cfb1f3b1e6c40@google.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/ipv4/inet_connection_sock.c
+++ net/ipv4/inet_connection_sock.c
@@ -377,7 +377,8 @@

 	flowi4_init_output(fl4, sk->sk_bound_dev_if, sk->sk_mark,
 			   RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE,
-			   sk->sk_protocol, inet_sk_flowi_flags(sk),
+			   sk->sk_protocol,
+			   inet_sk_flowi_flags(sk) & ~FLOWI_FLAG_PRECOW_METRICS,
 			   (opt && opt->opt.srr) ? opt->opt.faddr : ireq->rmt_addr,
 			   ireq->loc_addr, ireq->rmt_port, inet_sk(sk)->inet_sport);
 	security_req_classify_flow(req, flowi4_to_flowi(fl4));


fix compilation error with nginx 1.2.2 and nginx 1.3.0

--- naxsi_src/naxsi_runtime.c
+++ naxsi_src/naxsi_runtime.c
@@ -155,7 +155,7 @@
     tmp_idx = 0;
     len = str->len;
     while
-#if defined nginx_version && (nginx_version >= 1003000)
+#if defined nginx_version && (nginx_version >= 1002002 && nginx_version != 1003000)
       (tmp_idx < len &&
        (match = pcre_exec(rl->br->rx->regex->code, 0,
 			  (const char *) str->data, str->len, tmp_idx, 0,


netfilter: nf_nat_ftp: remove (*mangle[]) array and functions, use %pI4

These functions merely exist to format a buffer and call
nf_nat_mangle_tcp_packet.

Format the buffer and perform the call in nf_nat_ftp instead.

Use %pI4 for the IP address.

Saves ~600 bytes of text

old:
$ size net/ipv4/netfilter/nf_nat_ftp.o
   text	   data	    bss	    dec	    hex	filename
   2187	    160	    408	   2755	    ac3	net/ipv4/netfilter/nf_nat_ftp.o
new:
$ size net/ipv4/netfilter/nf_nat_ftp.o
   text    data     bss     dec     hex filename
   1532     112     288    1932     78c net/ipv4/netfilter/nf_nat_ftp.o

Signed-off-by: Joe Perches <16a9a54ddf4259952e3c118c763138e83693d7fd@perches.com>
Signed-off-by: Patrick McHardy <3a4d625ce225e891399f98db96a382ac4a84080b@trash.net>

--- net/ipv4/netfilter/nf_nat_ftp.c
+++ net/ipv4/netfilter/nf_nat_ftp.c
@@ -27,75 +27,28 @@

 /* FIXME: Time out? --RR */

-static int
-mangle_rfc959_packet(struct sk_buff *skb,
-		     __be32 newip,
-		     u_int16_t port,
-		     unsigned int matchoff,
-		     unsigned int matchlen,
-		     struct nf_conn *ct,
-		     enum ip_conntrack_info ctinfo)
+static int nf_nat_ftp_fmt_cmd(enum nf_ct_ftp_type type,
+			      char *buffer, size_t buflen,
+			      __be32 addr, u16 port)
 {
-	char buffer[sizeof("nnn,nnn,nnn,nnn,nnn,nnn")];
+	switch (type) {
+	case NF_CT_FTP_PORT:
+	case NF_CT_FTP_PASV:
+		return snprintf(buffer, buflen, "%u,%u,%u,%u,%u,%u",
+				((unsigned char *)&addr)[0],
+				((unsigned char *)&addr)[1],
+				((unsigned char *)&addr)[2],
+				((unsigned char *)&addr)[3],
+				port >> 8,
+				port & 0xFF);
+	case NF_CT_FTP_EPRT:
+		return snprintf(buffer, buflen, "|1|%pI4|%u|", &addr, port);
+	case NF_CT_FTP_EPSV:
+		return snprintf(buffer, buflen, "|||%u|", port);
+	}

-	sprintf(buffer, "%u,%u,%u,%u,%u,%u",
-		NIPQUAD(newip), port>>8, port&0xFF);
-
-	pr_debug("calling nf_nat_mangle_tcp_packet\n");
-
-	return nf_nat_mangle_tcp_packet(skb, ct, ctinfo, matchoff,
-					matchlen, buffer, strlen(buffer));
+	return 0;
 }
-
-/* |1|132.235.1.2|6275| */
-static int
-mangle_eprt_packet(struct sk_buff *skb,
-		   __be32 newip,
-		   u_int16_t port,
-		   unsigned int matchoff,
-		   unsigned int matchlen,
-		   struct nf_conn *ct,
-		   enum ip_conntrack_info ctinfo)
-{
-	char buffer[sizeof("|1|255.255.255.255|65535|")];
-
-	sprintf(buffer, "|1|%u.%u.%u.%u|%u|", NIPQUAD(newip), port);
-
-	pr_debug("calling nf_nat_mangle_tcp_packet\n");
-
-	return nf_nat_mangle_tcp_packet(skb, ct, ctinfo, matchoff,
-					matchlen, buffer, strlen(buffer));
-}
-
-/* |1|132.235.1.2|6275| */
-static int
-mangle_epsv_packet(struct sk_buff *skb,
-		   __be32 newip,
-		   u_int16_t port,
-		   unsigned int matchoff,
-		   unsigned int matchlen,
-		   struct nf_conn *ct,
-		   enum ip_conntrack_info ctinfo)
-{
-	char buffer[sizeof("|||65535|")];
-
-	sprintf(buffer, "|||%u|", port);
-
-	pr_debug("calling nf_nat_mangle_tcp_packet\n");
-
-	return nf_nat_mangle_tcp_packet(skb, ct, ctinfo, matchoff,
-					matchlen, buffer, strlen(buffer));
-}
-
-static int (*mangle[])(struct sk_buff *, __be32, u_int16_t,
-		       unsigned int, unsigned int, struct nf_conn *,
-		       enum ip_conntrack_info)
-= {
-	[NF_CT_FTP_PORT] = mangle_rfc959_packet,
-	[NF_CT_FTP_PASV] = mangle_rfc959_packet,
-	[NF_CT_FTP_EPRT] = mangle_eprt_packet,
-	[NF_CT_FTP_EPSV] = mangle_epsv_packet
-};

 /* So, this packet has hit the connection tracking matching code.
    Mangle it, and change the expectation to match the new version. */
@@ -110,6 +63,8 @@
 	u_int16_t port;
 	int dir = CTINFO2DIR(ctinfo);
 	struct nf_conn *ct = exp->master;
+	char buffer[sizeof("|1|255.255.255.255|65535|")];
+	unsigned int buflen;

 	pr_debug("FTP_NAT: type %i, off %u len %u\n", type, matchoff, matchlen);

@@ -132,11 +87,21 @@
 	if (port == 0)
 		return NF_DROP;

-	if (!mangle[type](skb, newip, port, matchoff, matchlen, ct, ctinfo)) {
-		nf_ct_unexpect_related(exp);
-		return NF_DROP;
-	}
+	buflen = nf_nat_ftp_fmt_cmd(type, buffer, sizeof(buffer), newip, port);
+	if (!buflen)
+		goto out;
+
+	pr_debug("calling nf_nat_mangle_tcp_packet\n");
+
+	if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo, matchoff,
+				      matchlen, buffer, buflen))
+		goto out;
+
 	return NF_ACCEPT;
+
+out:
+	nf_ct_unexpect_related(exp);
+	return NF_DROP;
 }

 static void __exit nf_nat_ftp_fini(void)


aaaaah

aaaaah

--- networking/Worker/do_workunit.c
+++ networking/Worker/do_workunit.c
@@ -1,5 +1,75 @@
 #include "worker.h"
 #include "err_code.h"
+
+char *thesource = "static float4 pair_force(\n" \
+"    float4 pi,\n" \
+"    float4 pj,\n" \
+"    float4 ai,\n" \
+"    const float softening)\n" \
+"{\n" \
+"    float4 r;\n" \
+"    r.x = pj.x - pi.x;\n" \
+"    r.y = pj.y - pi.y;\n" \
+"    r.z = pj.z - pi.z;\n" \
+"    r.w = copysign(1, pi.w);\n" \
+"\n" \
+"    float distSquare = r.x * r.x + r.y * r.y + r.z * r.z + softening;\n" \
+"    float invDist = native_rsqrt(distSquare);\n" \
+"    float invDistCube = invDist * invDist * invDist;\n" \
+"    float s = pj.w * invDistCube * r.w;\n" \
+"    ai.x += r.x * s;\n" \
+"    ai.y += r.y * s;\n" \
+"    ai.z += r.z * s;\n" \
+"    return ai;\n" \
+"}\n" \
+"\n" \
+"kernel void nbody(\n" \
+"    __global float4* n_start,\n" \
+"    __global float4* n_end,\n" \
+"    __global float4* m,\n" \
+"    __global float4* v_start,\n" \
+"    __global float4* v_end,\n" \
+"    __local float4 *cached_stars,\n" \
+"    const float softening,\n" \
+"    const float timestep,\n" \
+"    const float G,\n" \
+"    const int N,\n" \
+"    const int M)\n" \
+"{\n" \
+"    int globalid = get_global_id(0);\n" \
+"    int threadcount = get_global_size(0);\n" \
+"    int chunksize = get_local_size(0);\n" \
+"    int localid = get_local_id(0);\n" \
+"    \n" \
+"    float4 pos = n_start[globalid];\n" \
+"    float4 vel = v_start[globalid];\n" \
+"    float4 force = {0,0,0,0};\n" \
+"\n" \
+"    int chunk = 0;\n" \
+"    for (int i = 0; i < M; i += chunksize, chunk++)\n" \
+"    {\n" \
+"        int local_pos = chunk * chunksize + localid;\n" \
+"        cached_stars[localid] = m[local_pos];\n" \
+"\n" \
+"        barrier(CLK_LOCAL_MEM_FENCE);\n" \
+"        for (int j = 0; j < chunksize;)\n" \
+"        {\n" \
+"            force = pair_force(pos, cached_stars[j++], force, softening);\n" \
+"        }\n" \
+"        barrier(CLK_LOCAL_MEM_FENCE);\n" \
+"    }\n" \
+"\n" \
+"    vel.x += force.x * G * timestep;\n" \
+"    vel.y += force.y * G * timestep;\n" \
+"    vel.z += force.z * G * timestep;\n" \
+"\n" \
+"    pos.x += vel.x * timestep;\n" \
+"    pos.y += vel.y * timestep;\n" \
+"    pos.z += vel.z * timestep;\n" \
+"\n" \
+"    n_end[globalid] = pos;\n" \
+"    v_end[globalid] = vel;\n" \
+"}";

 static int count_bodies(t_body **bodies)
 {
@@ -84,7 +154,7 @@
     char *source;

     source = load_cl_file(sourcefile);
-    p = clCreateProgramWithSource(c->context, 1, (const char **) & source, NULL, &err);
+    p = clCreateProgramWithSource(c->context, 1, (const char **) & thesource, NULL, &err);
     checkError(err, "Creating program");

     // Build the program


NCDInterfaceMonitor: don't rely on interface flags provided from netlink; instead, query them  manually. Fixes an issue when a wireless device is pulled out and the device is reported to be down  and then again up, incorrectly.

--- ncd/NCDInterfaceMonitor.c
+++ ncd/NCDInterfaceMonitor.c
@@ -84,16 +84,6 @@
         }
         struct ifinfomsg *im = (void *)pl;

-        int report_flags = 0;
-
-        if (o->buf_nh->nlmsg_type == RTM_NEWLINK) {
-            report_flags |= NCDIFCONFIG_FLAG_EXISTS;
-
-            if ((im->ifi_flags&IFF_RUNNING)) {
-                report_flags |= NCDIFCONFIG_FLAG_RUNNING;
-            }
-        }
-
         // parse attributes to get interface name

         char *ifname = NULL;
@@ -117,7 +107,7 @@
         BPending_Set(&o->more_job);

         // dispatch event
-        o->handler(o->user, ifname, report_flags);
+        o->handler(o->user, ifname, NCDIfConfig_query(ifname));
         return;
     }


bridge: multicast: call skb_checksum_{simple_, }validate

Let's use these new, neat helpers.

Signed-off-by: Linus Lüssing <1dd561f221e05f08425aa0351cbf66864fb4804d@c0d3.blue>
Acked-by: Stephen Hemminger <06fa905d7f2aaced6dc72e9511c71a2a51e8aead@networkplumber.org>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/bridge/br_multicast.c
+++ net/bridge/br_multicast.c
@@ -1610,16 +1610,8 @@
 	if (!pskb_may_pull(skb2, sizeof(*ih)))
 		goto out;

-	switch (skb2->ip_summed) {
-	case CHECKSUM_COMPLETE:
-		if (!csum_fold(skb2->csum))
-			break;
-		/* fall through */
-	case CHECKSUM_NONE:
-		skb2->csum = 0;
-		if (skb_checksum_complete(skb2))
-			goto out;
-	}
+	if (skb_checksum_simple_validate(skb2))
+		goto out;

 	err = 0;

@@ -1737,20 +1729,8 @@

 	ip6h = ipv6_hdr(skb2);

-	switch (skb2->ip_summed) {
-	case CHECKSUM_COMPLETE:
-		if (!csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, skb2->len,
-					IPPROTO_ICMPV6, skb2->csum))
-			break;
-		/*FALLTHROUGH*/
-	case CHECKSUM_NONE:
-		skb2->csum = ~csum_unfold(csum_ipv6_magic(&ip6h->saddr,
-							&ip6h->daddr,
-							skb2->len,
-							IPPROTO_ICMPV6, 0));
-		if (__skb_checksum_complete(skb2))
-			goto out;
-	}
+	if (skb_checksum_validate(skb2, IPPROTO_ICMPV6, ip6_compute_pseudo))
+		goto out;

 	err = 0;


iptunnel: make rx/tx bytes counters consistent

This was already done a long time ago in
commit 64194c31a0b6 ("inet: Make tunnel RX/TX byte counters more consistent")
but tx path was broken (at least since 3.10).

Before the patch the gre header was included on tx.

After the patch:
$ ping -c1 192.168.0.121 ; ip -s l ls dev gre1
PING 192.168.0.121 (192.168.0.121) 56(84) bytes of data.
64 bytes from 192.168.0.121: icmp_req=1 ttl=64 time=2.95 ms

--- 192.168.0.121 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 2.955/2.955/2.955/0.000 ms
7: gre1@NONE: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1468 qdisc noqueue state UNKNOWN mode DEFAULT group default
    link/gre 10.16.0.249 peer 10.16.0.121
    RX: bytes  packets  errors  dropped overrun mcast
    84         1        0       0       0       0
    TX: bytes  packets  errors  dropped carrier collsns
    84         1        0       0       0       0

Reported-by: Julien Meunier <0f47299d6d7be29de9aa672c2fd4f9e07862696a@6wind.com>
Signed-off-by: Nicolas Dichtel <7864bb1e0e12322ea18ea731d051b95b75140567@6wind.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- net/ipv4/ip_tunnel_core.c
+++ net/ipv4/ip_tunnel_core.c
@@ -51,7 +51,7 @@
 		  __be32 src, __be32 dst, __u8 proto,
 		  __u8 tos, __u8 ttl, __be16 df, bool xnet)
 {
-	int pkt_len = skb->len;
+	int pkt_len = skb->len - skb_inner_network_offset(skb);
 	struct iphdr *iph;
 	int err;


Remove FAKE_OPENSSL macro entirely

Remove FAKE_OPENSSL macro entirely

--- net/src/openssl/openssl.c
+++ net/src/openssl/openssl.c
@@ -71,14 +71,6 @@
 #if OPENSSL_VERSION_NUMBER_LT(1,0,1) && defined(WITH_DTLS)
 #warning "Detected OpenSSL version does not support DTLS - disabling"
 #undef WITH_DTLS
-#endif
-
-#ifndef HEADER_SSL_H
-/*
- * Try to support some OpenSSL-like compatibility layers, which tend to not have
- * everything implemented.
- */
-#define FAKE_OPENSSL
 #endif

 typedef struct {
@@ -597,12 +589,7 @@
         return SSL_connect(socket->ssl);
     }
     if (state_opt.state == AVS_NET_SOCKET_STATE_ACCEPTED) {
-#ifndef FAKE_OPENSSL
         return SSL_accept(socket->ssl);
-#else
-        LOG(ERROR, "Server mode not supported for this library version");
-        return -1;
-#endif
     }
     LOG(ERROR, "ssl_handshake: invalid socket state");
     return -1;
@@ -685,7 +672,7 @@
     if (cert_info->server_cert_validation) {
         socket->verification = 1;
         SSL_CTX_set_verify(socket->ctx, SSL_VERIFY_PEER, NULL);
-#if !defined(FAKE_OPENSSL) && OPENSSL_VERSION_NUMBER_LT(0,9,5)
+#if OPENSSL_VERSION_NUMBER_LT(0,9,5)
         SSL_CTX_set_verify_depth(socket->ctx, 1);
 #endif
         if (_avs_net_openssl_load_ca_certs(socket->ctx,
@@ -966,12 +953,7 @@
     return 0;
 }

-#ifndef FAKE_OPENSSL
 #define OPENSSL_METHOD(Proto) Proto##_method
-#else
-/* Allow the compatibility layer libraries to work at least for client mode */
-#define OPENSSL_METHOD(Proto) Proto##_client_method
-#endif

 #if OPENSSL_VERSION_NUMBER_LT(1,1,0)
 static const SSL_METHOD *stream_method(avs_net_ssl_version_t version) {


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

--- MagickCore/thread-private.h
+++ MagickCore/thread-private.h
@@ -34,7 +34,7 @@
   if (((((columns) > WorkloadThreshold()) || \
       ((rows) > WorkloadThreshold()))) && ((MagickSizeType) \
       ((columns)*(rows)) > (WorkloadThreshold()*WorkloadThreshold())) && \
-      (GetImagePixelCacheType(image) != DiskCache) && (expression)) \
+      (expression)) \
     num_threads(GetMagickResourceLimit(ThreadResource))

 #if (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ > 10))


Fixed Kaiser window in GEN20

Fixed Kaiser window in GEN20

--- Engine/fgens.c
+++ Engine/fgens.c
@@ -1006,12 +1006,13 @@
         return OK;
     case 7:                     /* Kaiser */
       {
-        double flen2 = (double) ff->flen / 2.0;
-        double flenm12 = (double) (ff->flen-1) * (ff->flen-1);
-        double besbeta = besseli(beta);
-        for (i = 0, x = -flen2 + 0.1 ; i <= (int) ff->flen ; i++, x++)
-          ft[i] = (MYFLT) (xarg * besseli((beta * sqrt(1.0 - x * x / flenm12)))
-                                / besbeta);
+        double flen2 = 4.0 / ((double) ff->flen * (double) ff->flen);
+        double besbeta = 1.0 / besseli(beta);
+        x = (double) ff->flen * -0.5 + 1.0;
+        ft[0] = ft[ff->flen] = (MYFLT) (xarg * besbeta);
+        for (i = 1 ; i < (int) ff->flen ; i++, x += 1.0)
+          ft[i] = (MYFLT) (xarg * besseli(beta * sqrt(1.0 - x * x * flen2))
+                                * besbeta);
         return OK;
       }
     case 8:                     /* Rectangular */