Fixed aor/tport handling for sip/sips cases.

darcs-hash:20060417085109-65a35-32f00f7d1c61942d1812c6db4dfeaae82beb406a.gz

--- libsofia-sip-ua/nua/nua_register.c
+++ libsofia-sip-ua/nua/nua_register.c
@@ -816,13 +816,13 @@
 			    TPTAG_IDENT("sip"),
 			    TPTAG_CERTIFICATE(certificate_dir),
 			    TAG_NEXT(nua->nua_args)) < 0 &&
-	nta_agent_add_tport(nua->nua_nta, URL_STRING_MAKE("*"),
+	nta_agent_add_tport(nua->nua_nta, URL_STRING_MAKE("sip:*:*"),
 			    TPTAG_IDENT("sip"),
 			    TPTAG_CERTIFICATE(certificate_dir),
 			    TAG_NEXT(nua->nua_args)) < 0)
       return -1;

-    if (nta_agent_add_tport(nua->nua_nta, URL_STRING_MAKE("*"),
+    if (nta_agent_add_tport(nua->nua_nta, URL_STRING_MAKE("sip:*:*"),
 			    TPTAG_IDENT("stun"),
 			    TPTAG_PUBLIC(tport_type_stun), /* use stun */
 			    TPTAG_CERTIFICATE(certificate_dir),
@@ -1689,7 +1689,7 @@
 				      int only_default)
 {
   int secure = aor && aor->url_type == url_sips;
-  outbound_connect const *oc, *public = NULL;
+  outbound_connect const *oc, *public = NULL, *any = NULL;

   for (oc = usages; oc; oc = oc->oc_next) {
     if (only_default && !oc->oc_default)
@@ -1700,6 +1700,9 @@

     if (public == NULL && oc->oc_public)
       public = oc;
+
+    if (any == NULL)
+      any = oc;

     if (secure) {
       if (oc->oc_secure)
@@ -1711,7 +1714,13 @@
     }
   }

-  return (outbound_connect *)public;
+  if (public)
+    return (outbound_connect *)public;
+
+  if (!aor && any)
+    return any;
+
+  return NULL;
 }

 sip_contact_t const *outbound_connect_contact(outbound_connect const *oc)


Cache: Fix potential deadlock

Cache: Fix potential deadlock

--- src/database/Cache.h
+++ src/database/Cache.h
@@ -103,12 +103,16 @@
         static std::vector<std::shared_ptr<INTF>> fetchAll( DBConnection dbConnection )
         {
             static const std::string req = "SELECT * FROM " + TABLEPOLICY::Name;
+            // Lock the cache mutex before attempting to acquire a context, otherwise
+            // we could have a thread locking cache then DB, and a thread locking DB then cache
+            Lock lock( Mutex );
             return sqlite::Tools::fetchAll<IMPL, INTF>( dbConnection, req );
         }

         template <typename... Args>
         static std::vector<std::shared_ptr<INTF>> fetchAll( DBConnection dbConnection, const std::string &req, Args&&... args )
         {
+            Lock lock( Mutex );
             return sqlite::Tools::fetchAll<IMPL, INTF>( dbConnection, req, std::forward<Args>( args )... );
         }


Update sdlvga drawing to SDL 2.0 native

Update sdlvga drawing to SDL 2.0 native

--- src/devices/sdlvga.c
+++ src/devices/sdlvga.c
@@ -24,7 +24,8 @@
     uint32_t control[CELL_OFFSET];
     uint32_t data[ROWS][COLS];
     SDL_Window *window;
-    SDL_Surface *sprite;
+    SDL_Renderer *renderer;
+    SDL_Texture *sprite;
     enum { RUNNING, STOPPING, STOPPED } status;
 };

@@ -44,8 +45,8 @@
                  .h = FONT_HEIGHT
              };

-    SDL_BlitSurface(state->sprite, &src, SDL_GetWindowSurface(state->window), &dst);
-    SDL_UpdateWindowSurfaceRects(state->window, &dst, 1);
+    SDL_RenderCopy(state->renderer, state->sprite, &src, &dst);
+    SDL_RenderPresent(state->renderer);

     return 0;
 }
@@ -69,23 +70,22 @@
     if (!state->window)
         fatal(0, "Unable to create sdlvga window : %s", SDL_GetError());

+    state->renderer = SDL_CreateRenderer(state->window, -1, 0);
+
     int flags = IMG_INIT_PNG;
     if (IMG_Init(flags) != flags)
         fatal(0, "sdlvga failed to initialise SDL_Image : %s", IMG_GetError());

     const char filename[] = RESOURCE_DIR "/font.png";
-    state->sprite = IMG_Load(filename);
-    if (!state->sprite)
+    SDL_Surface *sprite = IMG_Load(filename);
+    if (!sprite)
         fatal(0, "sdlvga failed to load font sprite `%s'", filename);

-    SDL_Rect fullscreen = {
-        .x = 0, .y = 0,
-        .w = COLS * FONT_WIDTH,
-        .h = ROWS * FONT_HEIGHT,
-    };
-    Uint32 black = SDL_MapRGB(SDL_GetWindowSurface(state->window)->format,0,0,0);
-    SDL_FillRect(SDL_GetWindowSurface(state->window), &fullscreen, black);
-    SDL_UpdateWindowSurfaceRects(state->window, &fullscreen, 1);
+    state->sprite = SDL_CreateTextureFromSurface(state->renderer, sprite);
+
+    SDL_SetRenderDrawColor(state->renderer, 0, 0, 0, 255);
+    SDL_RenderClear(state->renderer);
+    SDL_RenderPresent(state->renderer);

     return 0;
 }
@@ -94,7 +94,8 @@
 {
     struct sdlvga_state *state = cookie;

-    SDL_FreeSurface(state->sprite);
+    SDL_DestroyRenderer(state->renderer);
+    SDL_DestroyTexture(state->sprite);
     SDL_DestroyWindow(state->window);

     free(state);


lvgl: Add 16bit color handling

lvgl: Add 16bit color handling

--- third-party/lib/lvgl/display_port.c
+++ third-party/lib/lvgl/display_port.c
@@ -53,6 +53,15 @@
 			memcpy(&fbp32[location], (uint32_t *)color_p, (act_x2 - act_x1 + 1) * 4);
 			color_p += w;
 		}
+	} else if (vinfo.bits_per_pixel == 16) {
+		uint16_t * fbp16 = (uint16_t *)fbp;
+		int32_t y;
+
+		for(y = act_y1; y <= act_y2; y++) {
+			location = (act_x1 + vinfo.xoffset) + (y + vinfo.yoffset) * finfo.line_length / 2;
+			memcpy(&fbp16[location], (uint32_t *)color_p, (act_x2 - act_x1 + 1) * 2);
+			color_p += w;
+		}
 	} else {
 		log_error("Unsupported bits_per_pixel=%d", vinfo.bits_per_pixel);
 	}


fuzzymatch needed libtiff to compile for me.

Review URL: http://codereview.chromium.org/14164

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

Former-commit-id: 8011b85c81602ee76fbb3a6ec37248e130794efb

--- third_party/fuzzymatch/fuzzymatch.c
+++ third_party/fuzzymatch/fuzzymatch.c
@@ -32,7 +32,7 @@
  * Otherwise the binary exists with code 0.
  *
  * This requires leptonica to be installed. On Ubuntu do
- *   # apt-get install libleptonica libleptonica-dev
+ *   # apt-get install libleptonica libleptonica-dev libtiff4-dev
  *
  * Build with:
  *   % gcc -o fuzzymatch fuzzymatch.c -llept -ljpeg -ltiff -lpng -lz -lm -Wall -O2


ALSA: usb-audio: Save mixer status only once at suspend

The suspend callback of usb-audio driver may be called multiple times
per suspend when multiple USB interfaces are bound to a single sound
card instance.  In such a case, it's superfluous to save the mixer
values multiple times.  This patch fixes it by checking the counter.

Signed-off-by: Takashi Iwai <4596b3305151c7ee743192a95d394341e3d3b644@suse.de>

--- sound/usb/card.c
+++ sound/usb/card.c
@@ -695,8 +695,9 @@
 			chip->autosuspended = 1;
 	}

-	list_for_each_entry(mixer, &chip->mixer_list, list)
-		snd_usb_mixer_suspend(mixer);
+	if (chip->num_suspended_intf == 1)
+		list_for_each_entry(mixer, &chip->mixer_list, list)
+			snd_usb_mixer_suspend(mixer);

 	return 0;
 }


Bug: fix canonical mapping encoding

Bug: fix canonical mapping encoding

Nice to see the test suite for the Python module picking up bugs in the
C implementation!

--- source/encoder.c
+++ source/encoder.c
@@ -1602,6 +1602,7 @@
                     } else
                         ret = NULL;
                     items++;
+                    index++;
                     fast_len--;
                 }
                 Py_DECREF(fast);


globals.c: Remove tabs.c include.

globals.c: Remove tabs.c include.

--- source/globals.c
+++ source/globals.c
@@ -1,5 +1,4 @@
 #include "globals.h"
-#include "tabs.h"

 WebKitWebPage *PAGE;


reverted IOS patch (became useless with HBC 1.1.0 release)

--- source/gx/main.c
+++ source/gx/main.c
@@ -3,7 +3,7 @@
  *
  *  Genesis Plus GX
  *
- *  Copyright Eke-Eke (2007-2011), based on original work from Softdev (2006)
+ *  Copyright Eke-Eke (2007-2012), based on original work from Softdev (2006)
  *
  *  Redistribution and use of this code or any derivative works are permitted
  *  provided that the following conditions are met:
@@ -49,10 +49,6 @@

 #include <fat.h>

-#ifdef HW_RVL
-#include <ogc/machine/processor.h>
-#endif
-
 /* audio "exact" samplerate, measured on real hardware */
 #ifdef HW_RVL
 #define SAMPLERATE_48KHZ 48000
@@ -72,46 +68,6 @@
 #endif

 #ifdef HW_RVL
-
-/****************************************************************************
- * Force AHBPROT flags when IOS is reloaded
- * Credits to DaveBaol for the original patch
- ***************************************************************************/
-int Patch_IOS(void)
-{
-  /* full hardware access is initially required */
-  if (read32(0xd800064) == 0xffffffff)
-  {
-    /* disable MEM2 protection */
-    write16(0xd8b420a, 0);
-
-    /* IOS area (top of MEM2, above IOS Heap area) */
-    u8 *ptr_start = (u8*)*((u32*)0x80003134);
-    u8 *ptr_end = (u8*)0x94000000;
-
-    /* Make sure start pointer is valid */
-    if (((u32)ptr_start < 0x90000000) || (ptr_start >= ptr_end))
-    {
-      /* use libogc default value (longer but safer) */
-      ptr_start = (u8*) SYS_GetArena2Hi();
-    }
-
-    /* Search specific code pattern */
-    const u8 es_set_ahbprot_pattern[] = { 0x68, 0x5B, 0x22, 0xEC, 0x00, 0x52, 0x18, 0x9B, 0x68, 0x1B, 0x46, 0x98, 0x07, 0xDB };
-    while (ptr_start < (ptr_end - sizeof(es_set_ahbprot_pattern)))
-    {
-      if (!memcmp(ptr_start, es_set_ahbprot_pattern, sizeof(es_set_ahbprot_pattern)))
-      {
-        /* patch IOS (force AHBPROT bit to be set when launching titles) */
-        ptr_start[25] = 0x01;
-        DCFlushRange(ptr_start + 25, 1);
-      }
-      ptr_start++; /* could be optimized ? not sure if pattern coincides with instruction start */
-    }
-  }
-  return 0;
-}
-
 /****************************************************************************
  * Power Button callback
  ***************************************************************************/
@@ -477,18 +433,6 @@
 int main (int argc, char *argv[])
 {
  #ifdef HW_RVL
-  /* Temporary fix for HBC bug when using no_ios_reload with no connected network */
-  /* Try to patch current IOS to force AHBPROT flags being set on reload */
-  if (Patch_IOS())
-  {
-    /* reload IOS (full hardware access should now be preserved after reload) */
-    IOS_ReloadIOS(IOS_GetVersion());
-
-    /* enable DVD video commands */
-    write32(0xd800180, read32(0xd800180) & ~0x00200000);
-    usleep(200000);
-  }
-
   /* enable 64-byte fetch mode for L2 cache */
   L2Enhance();


Use d_m3Op everywhere

Use d_m3Op everywhere

--- source/m3_exec.h
+++ source/m3_exec.h
@@ -16,6 +16,7 @@
 #include "m3_exec_defs.h"

 #include <math.h>
+#include <limits.h>

 # define rewrite(NAME)				* ((void **) (_pc-1)) = NAME

@@ -100,14 +101,15 @@

-#define d_m3CompareOp(REG, TYPE, NAME, OPERATION) d_m3RetSig op_##TYPE##_##NAME##_sr (d_m3OpSig) \
+#define d_m3CompareOp(REG, TYPE, NAME, OPERATION)		\
+d_m3Op(TYPE##_##NAME##_sr)								\
 { 														\
 	TYPE * stack = (TYPE *) (_sp + immediate (i32));	\
 	_r0 = * stack OPERATION (TYPE) REG;					\
 	return nextOp ();									\
 }														\
 														\
-d_m3RetSig op_##TYPE##_##NAME##_ss(d_m3OpSig) 			\
+d_m3Op(TYPE##_##NAME##_ss)								\
 { 														\
 	TYPE * stackB = (TYPE *) (_sp + immediate (i32));	\
 	TYPE * stackA = (TYPE *) (_sp + immediate (i32));	\
@@ -115,7 +117,7 @@
 	return nextOp ();									\
 }														\
 														\
-d_m3RetSig op_##TYPE##_##NAME##_rs (d_m3OpSig) 			\
+d_m3Op(TYPE##_##NAME##_rs)								\
 { 														\
 	TYPE * stack = (TYPE *) (_sp + immediate (i32));	\
 	_r0 = (TYPE) REG OPERATION (* stack);				\
@@ -127,14 +129,15 @@

 //-----------------------

-#define d_m3CommutativeOp(REG, TYPE, NAME, OPERATION) d_m3RetSig op_##TYPE##_##NAME##_sr (d_m3OpSig) \
+#define d_m3CommutativeOp(REG, TYPE, NAME, OPERATION)	\
+d_m3Op(TYPE##_##NAME##_sr)								\
 { 														\
 	TYPE * stack = (TYPE *) (_sp + immediate (i32));	\
 	REG = * stack OPERATION (TYPE) REG;					\
 	return nextOp ();									\
 }														\
 														\
-d_m3RetSig op_##TYPE##_##NAME##_ss(d_m3OpSig) 			\
+d_m3Op(TYPE##_##NAME##_ss)								\
 { 														\
 	TYPE * stackB = (TYPE *) (_sp + immediate (i32));	\
 	TYPE * stackA = (TYPE *) (_sp + immediate (i32));	\
@@ -142,7 +145,8 @@
 	return nextOp ();									\
 }

-#define d_m3Op_(REG, TYPE, NAME, OPERATION) d_m3RetSig op_##TYPE##_##NAME##_rs (d_m3OpSig) \
+#define d_m3Op_(REG, TYPE, NAME, OPERATION)				\
+d_m3Op(TYPE##_##NAME##_rs)								\
 { 														\
 	TYPE * stack = (TYPE *) (_sp + immediate (i32));	\
 	REG = (TYPE) REG OPERATION (* stack);				\
@@ -230,7 +234,8 @@

-#define d_m3CommutativeFuncOp(REG, TYPE, NAME, FUNC) d_m3RetSig op_##TYPE##_##NAME##_sr (d_m3OpSig) \
+#define d_m3CommutativeFuncOp(REG, TYPE, NAME, FUNC)	\
+d_m3Op(TYPE##_##NAME##_sr)								\
 { 														\
 	TYPE * stack = (TYPE *) (_sp + immediate (i32));	\
 	m3ret_t r = FUNC (& REG, * stack, (TYPE) REG);		\
@@ -238,7 +243,7 @@
 	else return nextOp ();								\
 }														\
 														\
-d_m3RetSig op_##TYPE##_##NAME##_ss(d_m3OpSig) 			\
+d_m3Op(TYPE##_##NAME##_ss)								\
 { 														\
 	TYPE * stackB = (TYPE *) (_sp + immediate (i32));	\
 	TYPE * stackA = (TYPE *) (_sp + immediate (i32));	\
@@ -247,7 +252,8 @@
 	else return nextOp ();								\
 }

-#define d_m3FuncOp_(REG, TYPE, NAME, FUNC) d_m3RetSig op_##TYPE##_##NAME##_rs (d_m3OpSig) \
+#define d_m3FuncOp_(REG, TYPE, NAME, FUNC)				\
+d_m3Op(TYPE##_##NAME##_rs)								\
 { 														\
 	TYPE * stack = (TYPE *) (_sp + immediate (i32));	\
 	m3ret_t r = FUNC (& REG, * stack, (TYPE) REG);		\
@@ -285,7 +291,8 @@

 /*
-#define d_m3Op_Divide_f(TYPE, NAME, OPERATION) d_m3RetSig op_##TYPE##_##NAME (d_m3OpSig) \
+#define d_m3Op_Divide_f(TYPE, NAME, OPERATION)			\
+d_m3Op(TYPE##_##NAME)									\
 { 														\
 	if (_fp0 != 0.)										\
 	{													\
@@ -304,7 +311,8 @@
 d_m3Op_f (f64, Divide, 			/)

-#define d_m3BinaryOp2(TYPE, NAME, OPERATION) d_m3RetSig op_##TYPE##_##NAME (d_m3OpSig) \
+#define d_m3BinaryOp2(TYPE, NAME, OPERATION) \
+d_m3Op(TYPE##_##NAME)					\
 { 										\
 	TYPE op1 = * ((TYPE *) --_sp);		\
 	TYPE * op0 = (TYPE *) (_sp - 1);	\
@@ -321,9 +329,9 @@
 d_m3BinaryOp2 (f32, CopySign, copysignf);	d_m3BinaryOp2 (f64, CopySign, copysign);

-#define d_m3UnaryOp2(TYPE, NAME, OPERATION) d_m3RetSig op_##TYPE##_##NAME (d_m3OpSig) \
+#define d_m3UnaryOp2(TYPE, NAME, OPERATION)	\
+d_m3Op(TYPE##_##NAME)						\
 { 											\
-	abort (); \
 	TYPE * op = (TYPE *) (_sp - 1);			\
 	* op = OPERATION (* op);				\
 	return nextOp ();						\
@@ -338,12 +346,13 @@

 // "unary"
-#define d_m3UnaryOp_i(TYPE, NAME, OPERATION) d_m3RetSig op_##TYPE##_##NAME##_r (d_m3OpSig) \
+#define d_m3UnaryOp_i(TYPE, NAME, OPERATION)		\
+d_m3Op(TYPE##_##NAME##_r)							\
 { 													\
 	_r0 = (TYPE) _r0 OPERATION;						\
 	return nextOp ();								\
 } 													\
-d_m3RetSig op_##TYPE##_##NAME##_s (d_m3OpSig)		\
+d_m3Op(TYPE##_##NAME##_s)							\
 { 													\
 	TYPE * stack = (TYPE *) (_sp + immediate (i32));\
 	_r0 = * stack OPERATION;						\
@@ -355,13 +364,14 @@
 d_m3UnaryOp_i (i64, EqualToZero, == 0)

-#define d_m3IntToFpConvertOp(TO, NAME, FROM) d_m3RetSig op_##TO##_##NAME##_##FROM##_r (d_m3OpSig) \
+#define d_m3IntToFpConvertOp(TO, NAME, FROM)				\
+d_m3Op(TO##_##NAME##_##FROM##_r)							\
 { 															\
 	_fp0 = (TO) ((FROM) _r0);								\
 	return nextOp ();										\
 } 															\
 															\
-d_m3RetSig op_##TO##_##NAME##_##FROM##_s (d_m3OpSig) 		\
+d_m3Op(TO##_##NAME##_##FROM##_s)							\
 { 															\
 	FROM * stack = (FROM *) (_sp + immediate (i32));		\
 	_fp0 = (TO) (* stack);									\
@@ -375,13 +385,14 @@
 //d_m3IntToFpConversionOp (f64, Convert, u64);

-#define d_m3FpToFpConvertOp(TO, NAME) d_m3RetSig op_##TO##_##NAME##_r (d_m3OpSig) \
+#define d_m3FpToFpConvertOp(TO, NAME)						\
+d_m3Op(TO##_##NAME##_r)										\
 { 															\
 	_fp0 = (TO) _fp0;										\
 	return nextOp ();										\
 } 															\
 															\
-d_m3RetSig op_##TO##_##NAME##_s (d_m3OpSig) 				\
+d_m3Op(TO##_##NAME##_s)										\
 { 															\
 	f64 * stack = (f64 *) (_sp + immediate (i32));			\
 	_fp0 = (TO) (* stack);									\
@@ -410,7 +421,8 @@
 }

-#define d_m3TruncateOp(TO, NAME, FROM, TEST) d_m3RetSig op_##TO##_##NAME##_##FROM (d_m3OpSig) \
+#define d_m3TruncateOp(TO, NAME, FROM, TEST)	\
+d_m3Op(TO##_##NAME##_##FROM)					\
 { 												\
 	FROM from = _fp0;							\
 	if (TEST (from))							\
@@ -875,10 +887,11 @@
 # if d_m3EnableOptimizations
 //---------------------------------------------------------------------------------------------------------------------

-	#define d_m3BinaryOpWith1_i(TYPE, NAME, OPERATION) d_m3RetSig op_##TYPE##_##NAME (d_m3OpSig) \
-	{ 										\
-		_r0 = _r0 OPERATION 1;			\
-		return nextOp ();					\
+	#define d_m3BinaryOpWith1_i(TYPE, NAME, OPERATION)	\
+	d_m3Op(TYPE##_##NAME)								\
+	{ 													\
+		_r0 = _r0 OPERATION 1;							\
+		return nextOp ();								\
 	}

 	d_m3BinaryOpWith1_i (u64, Increment,	+)


ENH:  Add ExodusII reader to ParaView3.

ENH:  Add ExodusII reader to ParaView3.

--- Hybrid/vtkExodusIIReader.h
+++ Hybrid/vtkExodusIIReader.h
@@ -387,6 +387,199 @@
   // time series query functions
   int GetTimeSeriesData( int ID, const char *vName, const char *vType,
                          vtkFloatArray *result );
+
+
+
+  int GetNumberOfEdgeBlockArrays()
+    { return this->GetNumberOfObjects(EDGE_BLOCK); }
+  const char* GetEdgeBlockArrayName(int index)
+    { return this->GetObjectName(EDGE_BLOCK, index); }
+  int GetEdgeBlockArrayStatus(const char* name)
+    { return this->GetObjectStatus(EDGE_BLOCK, name); }
+  void SetEdgeBlockArrayStatus(const char* name, int flag)
+    { return this->SetObjectStatus(EDGE_BLOCK, name, flag); }
+
+  int GetNumberOfFaceBlockArrays()
+    { return this->GetNumberOfObjects(FACE_BLOCK); }
+  const char* GetFaceBlockArrayName(int index)
+    { return this->GetObjectName(FACE_BLOCK, index); }
+  int GetFaceBlockArrayStatus(const char* name)
+    { return this->GetObjectStatus(FACE_BLOCK, name); }
+  void SetFaceBlockArrayStatus(const char* name, int flag)
+    { return this->SetObjectStatus(FACE_BLOCK, name, flag); }
+
+  int GetNumberOfElementBlockArrays()
+    { return this->GetNumberOfObjects(ELEM_BLOCK); }
+  const char* GetElementBlockArrayName(int index)
+    { return this->GetObjectName(ELEM_BLOCK, index); }
+  int GetElementBlockArrayStatus(const char* name)
+    { return this->GetObjectStatus(ELEM_BLOCK, name); }
+  void SetElementBlockArrayStatus(const char* name, int flag)
+    { return this->SetObjectStatus(ELEM_BLOCK, name, flag); }
+
+  int GetNumberOfPointResultArrays()
+    { return this->GetNumberOfObjectArrays(NODAL); }
+  const char* GetPointResultArrayName(int index)
+    { return this->GetObjectArrayName(NODAL, index); }
+  int GetPointResultArrayStatus(const char* name)
+    { return this->GetObjectArrayStatus(NODAL, name); }
+  void SetPointResultArrayStatus(const char* name, int flag)
+    { return this->SetObjectArrayStatus(NODAL, name, flag); }
+
+  int GetNumberOfEdgeResultArrays()
+    { return this->GetNumberOfObjectArrays(EDGE_BLOCK); }
+  const char* GetEdgeResultArrayName(int index)
+    { return this->GetObjectArrayName(EDGE_BLOCK, index); }
+  int GetEdgeResultArrayStatus(const char* name)
+    { return this->GetObjectArrayStatus(EDGE_BLOCK, name); }
+  void SetEdgeResultArrayStatus(const char* name, int flag)
+    { return this->SetObjectArrayStatus(EDGE_BLOCK, name, flag); }
+
+  int GetNumberOfFaceResultArrays()
+    { return this->GetNumberOfObjectArrays(FACE_BLOCK); }
+  const char* GetFaceResultArrayName(int index)
+    { return this->GetObjectArrayName(FACE_BLOCK, index); }
+  int GetFaceResultArrayStatus(const char* name)
+    { return this->GetObjectArrayStatus(FACE_BLOCK, name); }
+  void SetFaceResultArrayStatus(const char* name, int flag)
+    { return this->SetObjectArrayStatus(FACE_BLOCK, name, flag); }
+
+  int GetNumberOfElementResultArrays()
+    { return this->GetNumberOfObjectArrays(ELEM_BLOCK); }
+  const char* GetElementResultArrayName(int index)
+    { return this->GetObjectArrayName(ELEM_BLOCK, index); }
+  int GetElementResultArrayStatus(const char* name)
+    { return this->GetObjectArrayStatus(ELEM_BLOCK, name); }
+  void SetElementResultArrayStatus(const char* name, int flag)
+    { return this->SetObjectArrayStatus(ELEM_BLOCK, name, flag); }
+
+
+  int GetNumberOfNodeMapArrays()
+    { return this->GetNumberOfObjects(NODE_MAP); }
+  const char* GetNodeMapArrayName(int index)
+    { return this->GetObjectName(NODE_MAP, index); }
+  int GetNodeMapArrayStatus(const char* name)
+    { return this->GetObjectStatus(NODE_MAP, name); }
+  void SetNodeMapArrayStatus(const char* name, int flag)
+    { return this->SetObjectStatus(NODE_MAP, name, flag); }
+
+  int GetNumberOfEdgeMapArrays()
+    { return this->GetNumberOfObjects(EDGE_MAP); }
+  const char* GetEdgeMapArrayName(int index)
+    { return this->GetObjectName(EDGE_MAP, index); }
+  int GetEdgeMapArrayStatus(const char* name)
+    { return this->GetObjectStatus(EDGE_MAP, name); }
+  void SetEdgeMapArrayStatus(const char* name, int flag)
+    { return this->SetObjectStatus(EDGE_MAP, name, flag); }
+
+  int GetNumberOfFaceMapArrays()
+    { return this->GetNumberOfObjects(FACE_MAP); }
+  const char* GetFaceMapArrayName(int index)
+    { return this->GetObjectName(FACE_MAP, index); }
+  int GetFaceMapArrayStatus(const char* name)
+    { return this->GetObjectStatus(FACE_MAP, name); }
+  void SetFaceMapArrayStatus(const char* name, int flag)
+    { return this->SetObjectStatus(FACE_MAP, name, flag); }
+
+  int GetNumberOfElementMapArrays()
+    { return this->GetNumberOfObjects(ELEM_MAP); }
+  const char* GetElementMapArrayName(int index)
+    { return this->GetObjectName(ELEM_MAP, index); }
+  int GetElementMapArrayStatus(const char* name)
+    { return this->GetObjectStatus(ELEM_MAP, name); }
+  void SetElementMapArrayStatus(const char* name, int flag)
+    { return this->SetObjectStatus(ELEM_MAP, name, flag); }
+
+  int GetNumberOfNodeSetArrays()
+    { return this->GetNumberOfObjects(NODE_SET); }
+  const char* GetNodeSetArrayName(int index)
+    { return this->GetObjectName(NODE_SET, index); }
+  int GetNodeSetArrayStatus(const char* name)
+    { return this->GetObjectStatus(NODE_SET, name); }
+  void SetNodeSetArrayStatus(const char* name, int flag)
+    { return this->SetObjectStatus(NODE_SET, name, flag); }
+
+  int GetNumberOfSideSetArrays()
+    { return this->GetNumberOfObjects(SIDE_SET); }
+  const char* GetSideSetArrayName(int index)
+    { return this->GetObjectName(SIDE_SET, index); }
+  int GetSideSetArrayStatus(const char* name)
+    { return this->GetObjectStatus(SIDE_SET, name); }
+  void SetSideSetArrayStatus(const char* name, int flag)
+    { return this->SetObjectStatus(SIDE_SET, name, flag); }
+
+  int GetNumberOfEdgeSetArrays()
+    { return this->GetNumberOfObjects(EDGE_SET); }
+  const char* GetEdgeSetArrayName(int index)
+    { return this->GetObjectName(EDGE_SET, index); }
+  int GetEdgeSetArrayStatus(const char* name)
+    { return this->GetObjectStatus(EDGE_SET, name); }
+  void SetEdgeSetArrayStatus(const char* name, int flag)
+    { return this->SetObjectStatus(EDGE_SET, name, flag); }
+
+  int GetNumberOfFaceSetArrays()
+    { return this->GetNumberOfObjects(FACE_SET); }
+  const char* GetFaceSetArrayName(int index)
+    { return this->GetObjectName(FACE_SET, index); }
+  int GetFaceSetArrayStatus(const char* name)
+    { return this->GetObjectStatus(FACE_SET, name); }
+  void SetFaceSetArrayStatus(const char* name, int flag)
+    { return this->SetObjectStatus(FACE_SET, name, flag); }
+
+  int GetNumberOfElementSetArrays()
+    { return this->GetNumberOfObjects(ELEM_SET); }
+  const char* GetElementSetArrayName(int index)
+    { return this->GetObjectName(ELEM_SET, index); }
+  int GetElementSetArrayStatus(const char* name)
+    { return this->GetObjectStatus(ELEM_SET, name); }
+  void SetElementSetArrayStatus(const char* name, int flag)
+    { return this->SetObjectStatus(ELEM_SET, name, flag); }
+
+
+  int GetNumberOfNodeSetResultArrays()
+    { return this->GetNumberOfObjectArrays(NODE_SET); }
+  const char* GetNodeSetResultArrayName(int index)
+    { return this->GetObjectArrayName(NODE_SET, index); }
+  int GetNodeSetResultArrayStatus(const char* name)
+    { return this->GetObjectArrayStatus(NODE_SET, name); }
+  void SetNodeSetResultArrayStatus(const char* name, int flag)
+    { return this->SetObjectArrayStatus(NODE_SET, name, flag); }
+
+  int GetNumberOfSideSetResultArrays()
+    { return this->GetNumberOfObjectArrays(SIDE_SET); }
+  const char* GetSideSetResultArrayName(int index)
+    { return this->GetObjectArrayName(SIDE_SET, index); }
+  int GetSideSetResultArrayStatus(const char* name)
+    { return this->GetObjectArrayStatus(SIDE_SET, name); }
+  void SetSideSetResultArrayStatus(const char* name, int flag)
+    { return this->SetObjectArrayStatus(SIDE_SET, name, flag); }
+
+  int GetNumberOfEdgeSetResultArrays()
+    { return this->GetNumberOfObjectArrays(EDGE_SET); }
+  const char* GetEdgeSetResultArrayName(int index)
+    { return this->GetObjectArrayName(EDGE_SET, index); }
+  int GetEdgeSetResultArrayStatus(const char* name)
+    { return this->GetObjectArrayStatus(EDGE_SET, name); }
+  void SetEdgeSetResultArrayStatus(const char* name, int flag)
+    { return this->SetObjectArrayStatus(EDGE_SET, name, flag); }
+
+  int GetNumberOfFaceSetResultArrays()
+    { return this->GetNumberOfObjectArrays(FACE_SET); }
+  const char* GetFaceSetResultArrayName(int index)
+    { return this->GetObjectArrayName(FACE_SET, index); }
+  int GetFaceSetResultArrayStatus(const char* name)
+    { return this->GetObjectArrayStatus(FACE_SET, name); }
+  void SetFaceSetResultArrayStatus(const char* name, int flag)
+    { return this->SetObjectArrayStatus(FACE_SET, name, flag); }
+
+  int GetNumberOfElementSetResultArrays()
+    { return this->GetNumberOfObjectArrays(ELEM_SET); }
+  const char* GetElementSetResultArrayName(int index)
+    { return this->GetObjectArrayName(ELEM_SET, index); }
+  int GetElementSetResultArrayStatus(const char* name)
+    { return this->GetObjectArrayStatus(ELEM_SET, name); }
+  void SetElementSetResultArrayStatus(const char* name, int flag)
+    { return this->SetObjectArrayStatus(ELEM_SET, name, flag); }

 protected:
   vtkExodusIIReader();


Added the ability to read a full byte from a set of channels

For example, you can hook up to the 8 XIO pins and 8 CSID pins to read
a word in just two calls: `GPIO.read_byte("XIO") + GPIO.read_byte("CSID") << 8`

For fast-changing inputs (e.g. reading from a counter), this is more
accurate than reading the bits individually.

--- source/py_gpio.c
+++ source/py_gpio.c
@@ -290,6 +290,58 @@
     return py_value;
 }

+// python function value = read_byte(channel)
+static PyObject *py_read_byte_gpio(PyObject *self, PyObject *args)
+{
+    int gpio;
+    char *channel;
+    int i;
+    unsigned int bit;
+    unsigned int value = 0;
+    PyObject *py_value;
+
+    clear_error_msg();
+
+    if (!PyArg_ParseTuple(args, "s", &channel))
+        return NULL;
+
+    if (get_gpio_number(channel, &gpio)) {
+    }
+
+    if (strcmp(channel, "XIO") == 0) {
+      int base_gpio = get_xio_base();
+      for (i = 0; i < 8; i++) {
+        gpio = base_gpio + i;
+        if (gpio_get_value(gpio, &bit) < 0) {
+          char err[1024];
+          snprintf(err, sizeof(err), "Could not get bit ('%s')", get_error_msg());
+          PyErr_SetString(PyExc_RuntimeError, err);
+          return NULL;
+        }
+        value |= (bit << i);
+      }
+    } else if (strcmp(channel, "CSID") == 0) {
+      int base_gpio = 132;
+      for (i = 0; i < 8; i++) {
+        gpio = base_gpio + i;
+        if (gpio_get_value(gpio, &bit) < 0) {
+          char err[1024];
+          snprintf(err, sizeof(err), "Could not get bit ('%s')", get_error_msg());
+          PyErr_SetString(PyExc_RuntimeError, err);
+          return NULL;
+        }
+        value |= (bit << i);
+      }
+    } else {
+        PyErr_SetString(PyExc_ValueError, "Invalid channel");
+        return NULL;
+    }
+
+    py_value = Py_BuildValue("i", value);
+
+    return py_value;
+}
+
 static void run_py_callbacks(int gpio, void* data)
 {
    PyObject *result;
@@ -860,6 +912,7 @@
    {"cleanup", (PyCFunction)py_cleanup, METH_VARARGS | METH_KEYWORDS, "Clean up by resetting all GPIO channels that have been used by this program to INPUT with no pullup/pulldown and no event detection"},
    {"output", py_output_gpio, METH_VARARGS, "Output to a GPIO channel\ngpio  - gpio channel\nvalue - 0/1 or False/True or LOW/HIGH"},
    {"input", py_input_gpio, METH_VARARGS, "Input from a GPIO channel.  Returns HIGH=1=True or LOW=0=False\ngpio - gpio channel"},
+   {"read_byte", py_read_byte_gpio, METH_VARARGS, "Read a byte from a set of GPIO channels. Returns 8-bit integer\ngpio - gpio channel. Valid channels: 'XIO', 'CSID'"},
    {"add_event_detect", (PyCFunction)py_add_event_detect, METH_VARARGS | METH_KEYWORDS, "Enable edge detection events for a particular GPIO channel.\nchannel      - either board pin number or BCM number depending on which mode is set.\nedge         - RISING, FALLING or BOTH\n[callback]   - A callback function for the event (optional)\n[bouncetime] - Switch bounce timeout in ms for callback"},
    {"remove_event_detect", py_remove_event_detect, METH_VARARGS, "Remove edge detection for a particular GPIO channel\ngpio - gpio channel"},
    {"event_detected", py_event_detected, METH_VARARGS, "Returns True if an edge has occured on a given GPIO.  You need to enable edge detection using add_event_detect() first.\ngpio - gpio channel"},


ocfs2/cluster: Show pin state for each o2hb region

This patch adds a per o2hb region debugfs file that shows whether that region
is pinned or not.

Signed-off-by: Sunil Mushran <71202349b6bab84fd697c8fc05379fc0e6724c25@oracle.com>
Signed-off-by: Joel Becker <823d0e2e55da83c1616b20ae9a15f9456fa076e5@oracle.com>

--- fs/ocfs2/cluster/heartbeat.c
+++ fs/ocfs2/cluster/heartbeat.c
@@ -82,6 +82,7 @@
 #define O2HB_DB_TYPE_REGION_LIVENODES	4
 #define O2HB_DB_TYPE_REGION_NUMBER	5
 #define O2HB_DB_TYPE_REGION_ELAPSED_TIME	6
+#define O2HB_DB_TYPE_REGION_PINNED	7
 struct o2hb_debug_buf {
 	int db_type;
 	int db_size;
@@ -101,6 +102,7 @@
 #define O2HB_DEBUG_FAILEDREGIONS	"failed_regions"
 #define O2HB_DEBUG_REGION_NUMBER	"num"
 #define O2HB_DEBUG_REGION_ELAPSED_TIME	"elapsed_time_in_ms"
+#define O2HB_DEBUG_REGION_PINNED	"pinned"

 static struct dentry *o2hb_debug_dir;
 static struct dentry *o2hb_debug_livenodes;
@@ -241,9 +243,11 @@
 	struct dentry		*hr_debug_livenodes;
 	struct dentry		*hr_debug_regnum;
 	struct dentry		*hr_debug_elapsed_time;
+	struct dentry		*hr_debug_pinned;
 	struct o2hb_debug_buf	*hr_db_livenodes;
 	struct o2hb_debug_buf	*hr_db_regnum;
 	struct o2hb_debug_buf	*hr_db_elapsed_time;
+	struct o2hb_debug_buf	*hr_db_pinned;

 	/* let the person setting up hb wait for it to return until it
 	 * has reached a 'steady' state.  This will be fixed when we have
@@ -1180,6 +1184,12 @@
 						 reg->hr_last_timeout_start));
 		goto done;

+	case O2HB_DB_TYPE_REGION_PINNED:
+		reg = (struct o2hb_region *)db->db_data;
+		out += snprintf(buf + out, PAGE_SIZE - out, "%u\n",
+				!!reg->hr_item_pinned);
+		goto done;
+
 	default:
 		goto done;
 	}
@@ -1424,6 +1434,7 @@
 	debugfs_remove(reg->hr_debug_livenodes);
 	debugfs_remove(reg->hr_debug_regnum);
 	debugfs_remove(reg->hr_debug_elapsed_time);
+	debugfs_remove(reg->hr_debug_pinned);
 	debugfs_remove(reg->hr_debug_dir);

 	spin_lock(&o2hb_live_lock);
@@ -1984,6 +1995,18 @@
 					  O2HB_DB_TYPE_REGION_ELAPSED_TIME,
 					  0, 0, reg);
 	if (!reg->hr_debug_elapsed_time) {
+		mlog_errno(ret);
+		goto bail;
+	}
+
+	reg->hr_debug_pinned =
+			o2hb_debug_create(O2HB_DEBUG_REGION_PINNED,
+					  reg->hr_debug_dir,
+					  &(reg->hr_db_pinned),
+					  sizeof(*(reg->hr_db_pinned)),
+					  O2HB_DB_TYPE_REGION_PINNED,
+					  0, 0, reg);
+	if (!reg->hr_debug_pinned) {
 		mlog_errno(ret);
 		goto bail;
 	}


ocfs2: Better I/O error handling in heartbeat

Propagate errors received in o2hb_bio_end_io() back to the heartbeat thread
so it can skip re-arming the timer.

Signed-off-by: Mark Fasheh <3dfef03b24d35cb667816693d0487c922cd46885@oracle.com>

--- fs/ocfs2/cluster/heartbeat.c
+++ fs/ocfs2/cluster/heartbeat.c
@@ -153,6 +153,7 @@
 struct o2hb_bio_wait_ctxt {
 	atomic_t          wc_num_reqs;
 	struct completion wc_io_complete;
+	int               wc_error;
 };

 static void o2hb_write_timeout(void *arg)
@@ -186,6 +187,7 @@
 {
 	atomic_set(&wc->wc_num_reqs, num_ios);
 	init_completion(&wc->wc_io_complete);
+	wc->wc_error = 0;
 }

 /* Used in error paths too */
@@ -218,8 +220,10 @@
 {
 	struct o2hb_bio_wait_ctxt *wc = bio->bi_private;

-	if (error)
+	if (error) {
 		mlog(ML_ERROR, "IO Error %d\n", error);
+		wc->wc_error = error;
+	}

 	if (bio->bi_size)
 		return 1;
@@ -390,6 +394,8 @@

 bail_and_wait:
 	o2hb_wait_on_io(reg, &wc);
+	if (wc.wc_error && !status)
+		status = wc.wc_error;

 	if (bios) {
 		for(i = 0; i < num_bios; i++)
@@ -790,20 +796,24 @@
 	return highest;
 }

-static void o2hb_do_disk_heartbeat(struct o2hb_region *reg)
+static int o2hb_do_disk_heartbeat(struct o2hb_region *reg)
 {
 	int i, ret, highest_node, change = 0;
 	unsigned long configured_nodes[BITS_TO_LONGS(O2NM_MAX_NODES)];
 	struct bio *write_bio;
 	struct o2hb_bio_wait_ctxt write_wc;

-	if (o2nm_configured_node_map(configured_nodes, sizeof(configured_nodes)))
-		return;
+	ret = o2nm_configured_node_map(configured_nodes,
+				       sizeof(configured_nodes));
+	if (ret) {
+		mlog_errno(ret);
+		return ret;
+	}

 	highest_node = o2hb_highest_node(configured_nodes, O2NM_MAX_NODES);
 	if (highest_node >= O2NM_MAX_NODES) {
 		mlog(ML_NOTICE, "ocfs2_heartbeat: no configured nodes found!\n");
-		return;
+		return -EINVAL;
 	}

 	/* No sense in reading the slots of nodes that don't exist
@@ -813,7 +823,7 @@
 	ret = o2hb_read_slots(reg, highest_node + 1);
 	if (ret < 0) {
 		mlog_errno(ret);
-		return;
+		return ret;
 	}

 	/* With an up to date view of the slots, we can check that no
@@ -831,7 +841,7 @@
 	ret = o2hb_issue_node_write(reg, &write_bio, &write_wc);
 	if (ret < 0) {
 		mlog_errno(ret);
-		return;
+		return ret;
 	}

 	i = -1;
@@ -847,6 +857,15 @@
 	 */
 	o2hb_wait_on_io(reg, &write_wc);
 	bio_put(write_bio);
+	if (write_wc.wc_error) {
+		/* Do not re-arm the write timeout on I/O error - we
+		 * can't be sure that the new block ever made it to
+		 * disk */
+		mlog(ML_ERROR, "Write error %d on device \"%s\"\n",
+		     write_wc.wc_error, reg->hr_dev_name);
+		return write_wc.wc_error;
+	}
+
 	o2hb_arm_write_timeout(reg);

 	/* let the person who launched us know when things are steady */
@@ -854,6 +873,8 @@
 		if (atomic_dec_and_test(&reg->hr_steady_iterations))
 			wake_up(&o2hb_steady_queue);
 	}
+
+	return 0;
 }

 /* Subtract b from a, storing the result in a. a *must* have a larger
@@ -913,7 +934,10 @@
 		 * likely to time itself out. */
 		do_gettimeofday(&before_hb);

-		o2hb_do_disk_heartbeat(reg);
+		i = 0;
+		do {
+			ret = o2hb_do_disk_heartbeat(reg);
+		} while (ret && ++i < 2);

 		do_gettimeofday(&after_hb);
 		elapsed_msec = o2hb_elapsed_msecs(&before_hb, &after_hb);


xfs_destroy_workqueues() should not be tagged with__exit

ia64 throws away .exit sections for the built-in CONFIG case, so routines
that are used in other circumstances should not be tagged as __exit.

Signed-off-by: Tony Luck <e7984595ec0368ff920a7b3521dc7093683f6f26@intel.com>
Reviewed-by: Christoph Hellwig <923f7720577207a44b32e59bbfbea59d27f1ae8e@lst.de>
Signed-off-by: Alex Elder <f556392d917047d964350b9c68912016c96d5e94@sgi.com>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- fs/xfs/linux-2.6/xfs_super.c
+++ fs/xfs/linux-2.6/xfs_super.c
@@ -1741,7 +1741,7 @@
 	return -ENOMEM;
 }

-STATIC void __exit
+STATIC void
 xfs_destroy_workqueues(void)
 {
 	destroy_workqueue(xfs_ail_wq);


xfs: xfs_trace.c: duplicated include

xfs: xfs_trace.c: duplicated include

fs/xfs/linux-2.6/xfs_trace.c: xfs_attr_sf.h is included more than once.

Signed-off-by: Andrea Gelmini <d595b0cb020d8d8634fc74c12e8a61b33dd25dca@gelma.net>
Signed-off-by: Alex Elder <f556392d917047d964350b9c68912016c96d5e94@sgi.com>

--- fs/xfs/linux-2.6/xfs_trace.c
+++ fs/xfs/linux-2.6/xfs_trace.c
@@ -41,7 +41,6 @@
 #include "xfs_alloc.h"
 #include "xfs_bmap.h"
 #include "xfs_attr.h"
-#include "xfs_attr_sf.h"
 #include "xfs_attr_leaf.h"
 #include "xfs_log_priv.h"
 #include "xfs_buf_item.h"


Fix build warning

Fix build warning

	* gcr/tests/unit-test-parser.c: Fix build warning

svn path=/trunk/; revision=1464

--- gcr/tests/unit-test-parser.c
+++ gcr/tests/unit-test-parser.c
@@ -85,6 +85,7 @@
 	default:
 		g_printerr ("decryption didn't work for: %s", filedesc);
 		g_assert (FALSE);
+		return FALSE;
 	};
 }


esp32/main.c: Lowered heap to 16K ... =(

--- esp32/main.c
+++ esp32/main.c
@@ -53,7 +53,7 @@
 #define MP_TASK_PRIORITY        (ESP_TASK_PRIO_MIN + 1)
 #define MP_TASK_STACK_SIZE      (16 * 1024)
 #define MP_TASK_STACK_LEN       (MP_TASK_STACK_SIZE / sizeof(StackType_t))
-#define MP_TASK_HEAP_SIZE       (64 * 1024)
+#define MP_TASK_HEAP_SIZE       (16 * 1024)

 STATIC StaticTask_t mp_task_tcb;
 STATIC StackType_t mp_task_stack[MP_TASK_STACK_LEN] __attribute__((aligned (8)));


i965/gs: Set static_vertex_count unconditionally on GEN8+

We always have NIR, so there's no reason for the check.

Reviewed-by: Kenneth Graunke <bd2562f754ec92342f93f61c25d731e290a2ffa8@whitecape.org>

--- src/mesa/drivers/dri/i965/brw_gs.c
+++ src/mesa/drivers/dri/i965/brw_gs.c
@@ -96,7 +96,7 @@
                                &c.prog_data.base.base, false);

    if (brw->gen >= 8) {
-      c.prog_data.static_vertex_count = !gp->program.Base.nir ? -1 :
+      c.prog_data.static_vertex_count =
          nir_gs_count_vertices(gp->program.Base.nir);
    }


disable debug code accidentally enabled by prev commit

--- src/mesa/shader/slang/slang_link.c
+++ src/mesa/shader/slang/slang_link.c
@@ -533,7 +533,7 @@
       _mesa_print_program(&fragProg->Base);
       _mesa_print_program_parameters(ctx, &fragProg->Base);
 #endif
-#if 01
+#if 0
       printf("************** linked fragment prog\n");
       _mesa_print_program(&shProg->FragmentProgram->Base);
       _mesa_print_program_parameters(ctx, &shProg->FragmentProgram->Base);
@@ -549,7 +549,7 @@
       _mesa_print_program(&vertProg->Base);
       _mesa_print_program_parameters(ctx, &vertProg->Base);
 #endif
-#if 01
+#if 0
       printf("************** linked vertex prog\n");
       _mesa_print_program(&shProg->VertexProgram->Base);
       _mesa_print_program_parameters(ctx, &shProg->VertexProgram->Base);


Hopefully fix VS warning I introduced.

Hopefully fix VS warning I introduced.

git-svn-id: 353be9ac11a1e711854a13efcc2fc17d9d6b83e7@1649 c36c8488-0289-0348-9b64-b301f74bd9a7

--- AbstrConverter.h
+++ AbstrConverter.h
@@ -101,7 +101,7 @@
   ///@{
   template<typename T>
   size_t bins_needed(std::pair<T,T> minmax) {
-    return (minmax.second-minmax.first) + 1;
+    return static_cast<size_t>(minmax.second-minmax.first) + 1;
   }
   template<> size_t bins_needed(std::pair<float,float>) {
     return std::numeric_limits<size_t>::max();


Socket: include stdexcept instead of exception

fixes #94

--- AdsLib/Sockets.h
+++ AdsLib/Sockets.h
@@ -25,7 +25,7 @@

 #include "Frame.h"
 #include "wrap_socket.h"
-#include <exception>
+#include <stdexcept>
 #include <string>

 struct IpV4 {


apache: Bind the http method as 'server::httpmethod'. Purely convenience.

This is a much nicer way than 'server::env["REQUEST_METHOD"]', which is much
more verbose and less clear.

--- src/apache/mod_lily.c
+++ src/apache/mod_lily.c
@@ -400,6 +400,39 @@
 }

+/** Bind server::httpmethod. This data is already available through
+    server::env["REQUEST_METHOD"], so this is simply for convenience. **/
+
+
+static void bind_httpmethod(int *count, lily_parse_state *parser, request_rec *r)
+{
+    if (*count == -1)
+        return;
+
+    lily_class *str_cls = lily_class_by_id(parser->symtab, SYM_CLASS_STR);
+    lily_sig *str_sig = str_cls->sig;
+    lily_var *var = lily_try_new_var(parser->symtab, str_sig, "httpmethod", 0);
+    lily_str_val *sv = lily_malloc(sizeof(lily_str_val));
+    char *sv_buffer = lily_malloc(strlen(r->method) + 1);
+    if (var == NULL || sv == NULL || sv_buffer == NULL) {
+        lily_free(sv);
+        lily_free(sv_buffer);
+        *count = -1;
+        return;
+    }
+
+    strcpy(sv_buffer, r->method);
+
+    sv->str = sv_buffer;
+    sv->refcount = 1;
+    sv->size = strlen(r->method);
+
+    var->value.str = sv;
+    var->flags &= ~VAL_IS_NIL;
+    (*count)++;
+}
+
+
 /** Binding the server package itself **/

@@ -417,6 +450,7 @@

         bind_env(&count, parser, r);
         bind_get(&count, parser, r);
+        bind_httpmethod(&count, parser, r);

         if (count != -1) {
             int ok = 1;


Add in EV menu, doesn't function yet though

- Add in free memory bits, also missed some for the other menus

--- exposurses.c
+++ exposurses.c
@@ -7,6 +7,33 @@

 /* Learning notes - This is a macro that is expanded (text substitution) before compiling */
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+char *exposure_array[] = {
+	"-6",
+	"-5",
+	"-4",
+	"-3",
+	"-2",
+	"-1",
+	"0",
+	"1",
+	"2",
+	"3",
+	"4",
+	"5",
+	"6",
+	"7",
+	"8",
+	"9",
+	"10",
+	"11",
+	"12",
+	"13",
+	"14",
+	"15",
+	"16",
+	NULL
+};

 char *iso_array[] = {
 	"50",
@@ -46,12 +73,15 @@
 	NULL
 };

+ITEM **exposure_items;
 ITEM **iso_items;
 ITEM **shutter_items;
 ITEM **aperture_items;
+MENU *exposure_menu;
 MENU *iso_menu;
 MENU *shutter_menu;
 MENU *aperture_menu;
+WINDOW *exposure_win;
 WINDOW *iso_win;
 WINDOW *shutter_win;
 WINDOW *aperture_win;
@@ -65,6 +95,7 @@
 int nearest_match(double x, int menu);
 double fraction_to_double(char *fraction);
 /* No one will ever need more than 9 bytes! */
+char exposure_sel[9] = "";
 char iso_sel[9] = "";
 char shutter_sel[9] = "";
 char aperture_sel[9] = "";
@@ -74,9 +105,11 @@
 	int c;
 	MENU **menu;
 	WINDOW **win;
-	int n_iso, i;
-	int n_shutter, j;
-	int n_aperture, k;
+	int i;
+	int n_exposure;
+	int n_iso;
+	int n_shutter;
+	int n_aperture;
 	int menu_sel_last;
 	selection_counter = 0;

@@ -90,9 +123,16 @@
 	init_pair(2, COLOR_CYAN, COLOR_BLACK);

 	/* Create items */
+	/* Lot's of repitition here. Surely can be wrapped in a function */
+	n_exposure = ARRAY_SIZE(exposure_array);
 	n_iso = ARRAY_SIZE(iso_array);
 	n_shutter = ARRAY_SIZE(shutter_array);
 	n_aperture = ARRAY_SIZE(aperture_array);
+	exposure_items = (ITEM **)calloc(n_exposure, sizeof(ITEM *));
+	for(i = 0; i < n_exposure; ++i) {
+		exposure_items[i] = new_item(exposure_array[i], exposure_array[i]);
+		set_item_userptr(exposure_items[i], selection);
+	}
 	iso_items = (ITEM **)calloc(n_iso, sizeof(ITEM *));
 	for(i = 0; i < n_iso; ++i) {
 		iso_items[i] = new_item(iso_array[i], iso_array[i]);
@@ -110,55 +150,69 @@
 	}

 	/* Create menu */
+	exposure_menu = new_menu((ITEM **)exposure_items);
 	iso_menu = new_menu((ITEM **)iso_items);
 	shutter_menu = new_menu((ITEM **)shutter_items);
 	aperture_menu = new_menu((ITEM **)aperture_items);

 	/* Create the window to be associated with the menu */
-	iso_win = newwin(10, 40, 4, 4);
+	exposure_win = newwin(10, 40, 4, 4);
+	keypad(exposure_win, TRUE);
+	iso_win = newwin(10, 40, 4, 45);
 	keypad(iso_win, TRUE);
-	shutter_win = newwin(10, 40, 4, 45);
+	shutter_win = newwin(10, 40, 4, 86);
 	keypad(shutter_win, TRUE);
-	aperture_win = newwin(10, 40, 4, 86);
+	aperture_win = newwin(10, 40, 4, 127);
 	keypad(aperture_win, TRUE);

 	/* Set main window and sub window */
+	set_menu_win(exposure_menu, exposure_win);
+	set_menu_sub(exposure_menu, derwin(exposure_win, 6, 38, 3, 1));
 	set_menu_win(iso_menu, iso_win);
 	set_menu_sub(iso_menu, derwin(iso_win, 6, 38, 3, 1));
 	set_menu_win(shutter_menu, shutter_win);
 	set_menu_sub(shutter_menu, derwin(shutter_win, 6, 38, 3, 1));
 	set_menu_win(aperture_menu, aperture_win);
 	set_menu_sub(aperture_menu, derwin(aperture_win, 6, 38, 3, 1));
+	set_menu_format(exposure_menu, 5, 1);
 	set_menu_format(iso_menu, 5, 1);
 	set_menu_format(shutter_menu, 5, 1);
 	set_menu_format(aperture_menu, 5, 1);

 	/* Set menu mark to the string " * " */
+	set_menu_mark(exposure_menu, " * ");
 	set_menu_mark(iso_menu, " * ");
 	set_menu_mark(shutter_menu, " * ");
 	set_menu_mark(aperture_menu, " * ");

 	/* Print a border around the main window and print a title */
+	box(exposure_win, 0, 0);
 	box(iso_win, 0, 0);
 	box(shutter_win, 0, 0);
 	box(aperture_win, 0, 0);
+	print_in_middle(exposure_win, 1, 0, 40, "EV", COLOR_PAIR(1));
 	print_in_middle(iso_win, 1, 0, 40, "ISO", COLOR_PAIR(1));
 	print_in_middle(shutter_win, 1, 0, 40, "Shutter", COLOR_PAIR(1));
 	print_in_middle(aperture_win, 1, 0, 40, "Aperture", COLOR_PAIR(1));
+	mvwaddch(exposure_win, 2, 0, ACS_LTEE);
 	mvwaddch(iso_win, 2, 0, ACS_LTEE);
 	mvwaddch(shutter_win, 2, 0, ACS_LTEE);
 	mvwaddch(aperture_win, 2, 0, ACS_LTEE);
+	mvwhline(exposure_win, 2, 1, ACS_HLINE, 38);
 	mvwhline(iso_win, 2, 1, ACS_HLINE, 38);
 	mvwhline(shutter_win, 2, 1, ACS_HLINE, 38);
 	mvwhline(aperture_win, 2, 1, ACS_HLINE, 38);
+	mvwaddch(exposure_win, 2, 39, ACS_RTEE);
 	mvwaddch(iso_win, 2, 39, ACS_RTEE);
 	mvwaddch(shutter_win, 2, 39, ACS_RTEE);
 	mvwaddch(aperture_win, 2, 39, ACS_RTEE);

 	/* Post the menu */
+	post_menu(exposure_menu);
 	post_menu(iso_menu);
 	post_menu(shutter_menu);
 	post_menu(aperture_menu);
+	wrefresh(exposure_win);
 	wrefresh(iso_win);
 	wrefresh(shutter_win);
 	wrefresh(aperture_win);
@@ -287,10 +341,16 @@
 		wrefresh(*win);
 	}
 	/* Unpost and free all the memory taken up */
+	unpost_menu(expsoure_menu);
 	unpost_menu(iso_menu);
 	unpost_menu(shutter_menu);
 	unpost_menu(aperture_menu);
+	free_menu(exposure_menu);
 	free_menu(iso_menu);
+	free_menu(shutter_menu);
+	free_menu(aperture_menu);
+	for(i = 0; i < n_exposure; ++i)
+		free_item(iso_items[i]);
 	for(i = 0; i < n_iso; ++i)
 		free_item(iso_items[i]);
 	for(i = 0; i < n_shutter; ++i)


'->' now works in the new expression system.

git-svn-id: 1b2893900746d3474b20c0dea7456040123c3b26@244 21eae674-98b7-11dd-bd71-f92a316d2d60

--- expression.c
+++ expression.c
@@ -711,6 +711,7 @@
             if (TopValue->Typ->Base != TypePointer)
                 ProgramFail(Parser, "can't dereference this non-pointer");

+            // XXX - should also do offset + checks
             ExpressionStackPushLValue(Parser, StackTop, TopValue->Val->Pointer.Segment);
             break;

@@ -1062,12 +1063,20 @@
     if (Parser->Mode == RunModeRun)
     {
         /* look up the struct element */
-        struct Value *StructVal = (*StackTop)->p.Val;
+        struct Value *ParamVal = (*StackTop)->p.Val;
+        struct Value *StructVal = ParamVal;
         struct Value *MemberValue;
         struct Value *Result;

         if (Token == TokenArrow)
-            ProgramFail(Parser, "'->' not implemented yet");
+        {
+            /* dereference the struct pointer first */
+            if (StructVal->Typ->Base != TypePointer)
+                ProgramFail(Parser, "can't dereference this non-pointer");
+
+            // XXX - should also do offset + checks
+            StructVal = ParamVal->Val->Pointer.Segment;
+        }

         if (StructVal->Typ->Base != TypeStruct && StructVal->Typ->Base != TypeUnion)
             ProgramFail(Parser, "can't use '%s' on something that's not a struct or union %s", (Token == TokenDot) ? "." : "->", (Token == TokenArrow) ? "pointer" : "");
@@ -1076,7 +1085,7 @@
             ProgramFail(Parser, "doesn't have a member called '%s'", Ident->Val->Identifier);

         /* pop the value - assume it'll still be there until we're done */
-        HeapPopStack(StructVal, sizeof(struct ExpressionStack) + sizeof(struct Value) + TypeStackSizeValue(StructVal));
+        HeapPopStack(ParamVal, sizeof(struct ExpressionStack) + sizeof(struct Value) + TypeStackSizeValue(StructVal));
         *StackTop = (*StackTop)->Next;

         /* make the result value for this member only */


Fix function name in trace call

Fix function name in trace call

Change-Id: Ibfb3405feec635f9134d48bc0df9e709cc7a7bf0

--- src/arakoon-nursery.c
+++ src/arakoon-nursery.c
@@ -75,7 +75,7 @@
         READ_OPTIONS;
         timeout = arakoon_client_call_options_get_timeout(options_);

-        FUNCTION_ENTER(arakoon_nursery_update_config);
+        FUNCTION_ENTER(arakoon_nursery_update_routing);

         if(nursery->routing != NULL) {
                 _arakoon_nursery_routing_free(nursery->routing);


streamline fake camera creation using new network funcs

--- src/arvgvfakecamera.c
+++ src/arvgvfakecamera.c
@@ -459,7 +459,7 @@
 	success = g_socket_bind (socket, socket_address, allow_reuse, &error);

 	if (error != NULL) {
-		arv_warning_device ("Failed to bind socket: %s", error->message);
+		arv_warning_device ("Failed to bind %s socket: %s", socket_name, error->message);
 		g_clear_error (&error);
 	}

@@ -478,94 +478,85 @@
 static gboolean
 arv_gv_fake_camera_start (ArvGvFakeCamera *gv_fake_camera)
 {
-        g_autoptr (GSocketAddress) interface_address = NULL;
-        GInetAddress *interface_inet_address = NULL;
-	GList *ifaces;
-	GList *iface_iter;
-	gboolean interface_found = FALSE;
+	ArvNetworkInterface *iface;
+	GSocketAddress *socket_address;
+	GInetAddress *inet_address;
+	GInetAddress *gvcp_inet_address;
+	unsigned int i;
+	unsigned int n_socket_fds;

 	g_return_val_if_fail (ARV_IS_GV_FAKE_CAMERA (gv_fake_camera), FALSE);

-	ifaces = arv_enumerate_network_interfaces ();
-	if (!ifaces) {
-		arv_warning_device ("[GvFakeCamera::start] No network interface found");
+	/* get the interface by name or address */
+	iface = arv_network_get_interface_by_address(gv_fake_camera->priv->interface_name);
+	if (iface == NULL) iface = arv_network_get_interface_by_name(gv_fake_camera->priv->interface_name);
+	#ifdef G_OS_WIN32
+		/* fake the default loopback interface in windows, in case not found */
+		if(iface == NULL && g_strcmp0 (gv_fake_camera->priv->interface_name,ARV_GV_FAKE_CAMERA_DEFAULT_INTERFACE) == 0)
+			iface = arv_network_get_fake_ipv4_loopback();
+	#endif
+	if (iface == NULL) {
+		arv_warning_device ("[GvFakeCamera::start] No network interface with address or name '%s' found.",gv_fake_camera->priv->interface_name);
 		return FALSE;
 	}

-        interface_address = g_inet_socket_address_new_from_string (gv_fake_camera->priv->interface_name, 0);
-        if (G_IS_SOCKET_ADDRESS (interface_address))
-                interface_inet_address =
-                        g_inet_socket_address_get_address (G_INET_SOCKET_ADDRESS (interface_address));
-
-	for (iface_iter = ifaces; iface_iter != NULL && !interface_found; iface_iter = iface_iter->next) {
-                GSocketAddress *socket_address;
-                g_autoptr (GInetAddress) gvcp_inet_address = NULL;
-
-                socket_address = g_socket_address_new_from_native (arv_network_interface_get_addr(iface_iter->data),
-                                                                   sizeof (struct sockaddr));
-                gvcp_inet_address = g_object_ref (g_inet_socket_address_get_address (G_INET_SOCKET_ADDRESS (socket_address)));
-                g_clear_object (&socket_address);
-
-		if (g_strcmp0 (gv_fake_camera->priv->interface_name,
-			       arv_network_interface_get_name (iface_iter->data)) == 0 ||
-                    (interface_inet_address != NULL &&
-                     g_inet_address_equal (gvcp_inet_address, interface_inet_address))) {
-			GInetAddress *inet_address;
-			unsigned int n_socket_fds;
-			unsigned int i;
-			arv_fake_camera_set_inet_address (gv_fake_camera->priv->camera, gvcp_inet_address);
-
-			_create_and_bind_input_socket (&gv_fake_camera->priv->gvsp_socket,
-									    "GVSP", gvcp_inet_address, 0, FALSE, TRUE);
-			_create_and_bind_input_socket
-				(&gv_fake_camera->priv->input_sockets[ARV_GV_FAKE_CAMERA_INPUT_SOCKET_GVCP],
-				 "GVCP", gvcp_inet_address, ARV_GVCP_PORT, FALSE, FALSE);
-
-			inet_address = g_inet_address_new_from_string ("255.255.255.255");
-			if (!g_inet_address_equal (gvcp_inet_address, inet_address))
-				_create_and_bind_input_socket
-					(&gv_fake_camera->priv->input_sockets[ARV_GV_FAKE_CAMERA_INPUT_SOCKET_GLOBAL_DISCOVERY],
-					 "Global discovery", inet_address, ARV_GVCP_PORT, TRUE, FALSE);
-			g_clear_object (&inet_address);
-
-			socket_address = g_socket_address_new_from_native (arv_network_interface_get_broadaddr(iface_iter->data),
-									   sizeof (struct sockaddr));
-			inet_address = g_object_ref (g_inet_socket_address_get_address (G_INET_SOCKET_ADDRESS (socket_address)));
-			g_clear_object (&socket_address);
-			if (!g_inet_address_equal (gvcp_inet_address, inet_address))
-				_create_and_bind_input_socket
-					(&gv_fake_camera->priv->input_sockets[ARV_GV_FAKE_CAMERA_INPUT_SOCKET_SUBNET_DISCOVERY],
-					 "Subnet discovery", inet_address, ARV_GVCP_PORT, FALSE, FALSE);
-			g_clear_object (&inet_address);
-
-			n_socket_fds = 0;
-			for (i = 0; i < ARV_GV_FAKE_CAMERA_N_INPUT_SOCKETS; i++) {
-				GSocket *socket = gv_fake_camera->priv->input_sockets[i];
-
-				if (G_IS_SOCKET (socket)) {
-					gv_fake_camera->priv->socket_fds[n_socket_fds].fd = g_socket_get_fd (socket);
-					gv_fake_camera->priv->socket_fds[n_socket_fds].events = G_IO_IN;
-					gv_fake_camera->priv->socket_fds[n_socket_fds].revents = 0;
-
-					n_socket_fds++;
-				}
-			}
-			arv_info_device ("Listening to %d sockets", n_socket_fds);
-
-			gv_fake_camera->priv->n_socket_fds = n_socket_fds;
-
-			arv_gpollfd_prepare_all (gv_fake_camera->priv->socket_fds, n_socket_fds);
-
-			interface_found = TRUE;
+	socket_address = g_socket_address_new_from_native (arv_network_interface_get_addr(iface),
+								sizeof (struct sockaddr));
+	gvcp_inet_address = g_object_ref (g_inet_socket_address_get_address (G_INET_SOCKET_ADDRESS (socket_address)));
+	arv_fake_camera_set_inet_address (gv_fake_camera->priv->camera, gvcp_inet_address);
+
+	_create_and_bind_input_socket (&gv_fake_camera->priv->gvsp_socket,
+								 "GVSP", gvcp_inet_address, 0, FALSE, TRUE);
+	_create_and_bind_input_socket
+		(&gv_fake_camera->priv->input_sockets[ARV_GV_FAKE_CAMERA_INPUT_SOCKET_GVCP],
+		 "GVCP", gvcp_inet_address, ARV_GVCP_PORT, FALSE, FALSE);
+
+	inet_address = g_inet_address_new_from_string ("255.255.255.255");
+	if (!g_inet_address_equal (gvcp_inet_address, inet_address))
+		_create_and_bind_input_socket
+			(&gv_fake_camera->priv->input_sockets[ARV_GV_FAKE_CAMERA_INPUT_SOCKET_GLOBAL_DISCOVERY],
+			 "Global discovery", inet_address, ARV_GVCP_PORT, TRUE, FALSE);
+	g_clear_object (&inet_address);
+	g_clear_object (&socket_address);
+
+	socket_address = g_socket_address_new_from_native (arv_network_interface_get_broadaddr(iface),
+								sizeof (struct sockaddr));
+	inet_address = g_object_ref (g_inet_socket_address_get_address (G_INET_SOCKET_ADDRESS (socket_address)));
+	if (!g_inet_address_equal (gvcp_inet_address, inet_address))
+		_create_and_bind_input_socket
+			(&gv_fake_camera->priv->input_sockets[ARV_GV_FAKE_CAMERA_INPUT_SOCKET_SUBNET_DISCOVERY],
+			 "Subnet discovery", inet_address, ARV_GVCP_PORT, FALSE, FALSE);
+	g_clear_object (&inet_address);
+	g_clear_object (&socket_address);
+
+	g_clear_object (&gvcp_inet_address);
+
+	arv_network_interface_free(iface);
+
+	n_socket_fds = 0;
+	for (i = 0; i < ARV_GV_FAKE_CAMERA_N_INPUT_SOCKETS; i++) {
+		GSocket *socket = gv_fake_camera->priv->input_sockets[i];
+
+		if (G_IS_SOCKET (socket)) {
+			gv_fake_camera->priv->socket_fds[n_socket_fds].fd = g_socket_get_fd (socket);
+			gv_fake_camera->priv->socket_fds[n_socket_fds].events = G_IO_IN;
+			gv_fake_camera->priv->socket_fds[n_socket_fds].revents = 0;
+
+			n_socket_fds++;
 		}
 	}
-	g_list_free_full (ifaces, (GDestroyNotify) arv_network_interface_free);
+	arv_info_device ("Listening to %d sockets", n_socket_fds);
+
+	gv_fake_camera->priv->n_socket_fds = n_socket_fds;
+
+	arv_gpollfd_prepare_all (gv_fake_camera->priv->socket_fds, n_socket_fds);

 	gv_fake_camera->priv->cancel = FALSE;
 	gv_fake_camera->priv->thread = g_thread_new ("arv_fake_gv_fake_camera", _thread, gv_fake_camera);

-	return interface_found;
-}
+	return TRUE;
+}
+

 static void
 arv_gv_fake_camera_stop (ArvGvFakeCamera *gv_fake_camera)


zephyr: drivers: add not TCPM driver unit tests

Add test for functions that are in driver/tcpm/tcpci.c but are not part
of TCPM driver API. Tested functions are:
- tcpci_tcpc_debug_accessory()
- tcpc_xfer()

BUG=b:184857030
BRANCH=none
TEST=make configure --test zephyr/test/drivers

Signed-off-by: Tomasz Michalec <a547db31280d14f095c760a23a7523d0b1e55fe6@semihalf.com>
Change-Id: I385d7ba3d7fe6e575b8d75b2315b02092a7a4d71
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3211973
Tested-by: Tomasz Michalec <c064a6042954d4ba0805003dc021b76413ff1548@google.com>
Commit-Queue: Tomasz Michalec <c064a6042954d4ba0805003dc021b76413ff1548@google.com>
Reviewed-by: Wai-Hong Tam <04b587fdf5845741a0c5a8b9cd59ca72d73ef8fc@google.com>

--- zephyr/test/drivers/src/tcpci.c
+++ zephyr/test/drivers/src/tcpci.c
@@ -1090,6 +1090,49 @@
 	check_tcpci_reg(emul, TCPC_REG_POWER_CTRL, exp_ctrl);
 }

+/** Test TCPC xfer */
+static void test_tcpc_xfer(void)
+{
+	const struct emul *emul = emul_get_binding(DT_LABEL(EMUL_LABEL));
+	uint16_t val, exp_val;
+	uint8_t reg;
+
+	/* Set value to register (value and register chosen arbitrary) */
+	exp_val = 0x7fff;
+	reg = TCPC_REG_ALERT_MASK;
+	tcpci_emul_set_reg(emul, reg, exp_val);
+
+	/* Test reading value using tcpc_xfer() function */
+	zassert_equal(EC_SUCCESS,
+		      tcpc_xfer(USBC_PORT_C0, &reg, 1, (uint8_t *)&val, 2),
+		      NULL);
+	zassert_equal(exp_val, val, "0x%x != 0x%x", exp_val, val);
+}
+
+/** Test TCPCI debug accessory enable/disable */
+static void test_tcpci_debug_accessory(void)
+{
+	const struct emul *emul = emul_get_binding(DT_LABEL(EMUL_LABEL));
+	uint8_t exp_val, initial_val;
+
+	/* Set initial value for STD output register. Chosen arbitrary. */
+	initial_val = TCPC_REG_CONFIG_STD_OUTPUT_AUDIO_CONN_N |
+		      TCPC_REG_CONFIG_STD_OUTPUT_MUX_USB |
+		      TCPC_REG_CONFIG_STD_OUTPUT_CONNECTOR_FLIPPED |
+		      TCPC_REG_CONFIG_STD_OUTPUT_DBG_ACC_CONN_N;
+	tcpci_emul_set_reg(emul, TCPC_REG_CONFIG_STD_OUTPUT, initial_val);
+
+	/* Test debug accessory connect */
+	exp_val = initial_val & ~TCPC_REG_CONFIG_STD_OUTPUT_DBG_ACC_CONN_N;
+	tcpci_tcpc_debug_accessory(USBC_PORT_C0, 1);
+	check_tcpci_reg(emul, TCPC_REG_CONFIG_STD_OUTPUT, exp_val);
+
+	/* Test debug accessory disconnect */
+	exp_val = initial_val | TCPC_REG_CONFIG_STD_OUTPUT_DBG_ACC_CONN_N;
+	tcpci_tcpc_debug_accessory(USBC_PORT_C0, 0);
+	check_tcpci_reg(emul, TCPC_REG_CONFIG_STD_OUTPUT, exp_val);
+}
+
 void test_suite_tcpci(void)
 {
 	ztest_test_suite(tcpci,
@@ -1114,6 +1157,8 @@
 			 ztest_user_unit_test(test_tcpci_get_chip_info),
 			 ztest_user_unit_test(test_tcpci_low_power_mode),
 			 ztest_user_unit_test(test_tcpci_set_bist_mode),
-			 ztest_user_unit_test(test_tcpci_discharge_vbus));
+			 ztest_user_unit_test(test_tcpci_discharge_vbus),
+			 ztest_user_unit_test(test_tcpc_xfer),
+			 ztest_user_unit_test(test_tcpci_debug_accessory));
 	ztest_run_test_suite(tcpci);
 }


nieporzebne

nieporzebne

--- f_routines.c
+++ f_routines.c
@@ -117,8 +117,6 @@
         memset(buf,0x20,sz);
         memcpy(buf,defvalue_str, (sz < defvalue_sz) ? sz : defvalue_sz );
         *errno = MINCF_OK;
-    } else {
-        cstr_fix(buf,sz);
-    }
+    }

 }


Call io_remove() earlier.

Call io_remove() earlier.

--- src/auth/passdb-pam.c
+++ src/auth/passdb-pam.c
@@ -329,6 +329,7 @@
 		}
 	}

+	io_remove(&request->io);
 	if (close(request->fd) < 0) {
 		auth_request_log_error(auth_request, "pam",
 				       "close(child input) failed: %m");
@@ -337,7 +338,6 @@
 	request->callback(result, auth_request);
 	auth_request_unref(&auth_request);

-	io_remove(&request->io);
 	i_free(request);
 }


userdb sql: Fixed crashing when listing users.

--HG--
branch : HEAD

--- src/auth/userdb-sql.c
+++ src/auth/userdb-sql.c
@@ -133,7 +133,7 @@
 			userdb_iter_callback_t *callback, void *context)
 {
 	struct sql_userdb_module *module =
-		(struct sql_userdb_module *)userdb;
+		(struct sql_userdb_module *)userdb->userdb;
 	struct sql_userdb_iterate_context *ctx;

 	ctx = i_new(struct sql_userdb_iterate_context, 1);


added batch_generator

added batch_generator

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

--- src/batch_generator.h
+++ src/batch_generator.h
@@ -0,0 +1,177 @@
+#pragma once
+
+#include <deque>
+#include <queue>
+
+namespace marian {
+
+typedef std::vector<float> Data;
+typedef std::vector<Data> Example;
+typedef std::vector<Example> Examples;
+
+class Input {
+  private:
+    Shape shape_;
+    Data data_;
+
+  public:
+    typedef Data::iterator iterator;
+    typedef Data::const_iterator const_iterator;
+
+    Input(const Shape& shape)
+    : shape_(shape),
+      data_(shape_.totalSize(), 0.0f) {}
+
+    Data::iterator begin() {
+      return data_.begin();
+    }
+
+    Data::iterator end() {
+      return data_.end();
+    }
+
+    Data::const_iterator begin() const {
+      return data_.cbegin();
+    }
+
+    Data::const_iterator end() const {
+      return data_.cend();
+    }
+
+    Shape shape() const {
+      return shape_;
+    }
+
+    size_t size() const {
+      return data_.size();
+    }
+};
+
+class Batch {
+  private:
+    std::vector<Input> inputs_;
+
+  public:
+    std::vector<Input>& inputs() {
+      return inputs_;
+    }
+
+    const std::vector<Input>& inputs() const {
+      return inputs_;
+    }
+
+    void push_back(Input input) {
+      inputs_.push_back(input);
+    }
+
+    int dim() const {
+      return inputs_[0].shape()[0];
+    }
+
+    size_t size() const {
+      return inputs_.size();
+    }
+};
+
+template <class DataSet>
+class BatchGenerator {
+  private:
+    DataSet data_;
+    typename DataSet::iterator current_;
+
+    size_t batchSize_;
+    size_t maxiBatchSize_;
+
+    std::deque<Batch> bufferedBatches_;
+    Batch currentBatch_;
+
+    void fillBatches() {
+      auto cmp = [](const Example& a, const Example& b) {
+        return a[0].size() < b[0].size();
+      };
+
+      std::priority_queue<Example, Examples, decltype(cmp)> maxiBatch(cmp);
+
+      while(current_ != data_.end() && maxiBatch.size() < maxiBatchSize_) {
+        maxiBatch.push(*current_);
+        current_++;
+      }
+
+      Examples batchVector;
+      while(!maxiBatch.empty()) {
+        batchVector.push_back(maxiBatch.top());
+        maxiBatch.pop();
+        if(batchVector.size() == batchSize_) {
+          bufferedBatches_.push_back(toBatch(batchVector));
+          batchVector.clear();
+        }
+      }
+      if(!batchVector.empty())
+        bufferedBatches_.push_back(toBatch(batchVector));
+    }
+
+    Batch toBatch(const Examples& batchVector) {
+      int batchSize = batchVector.size();
+
+      std::vector<int> maxDims;
+      for(auto&& ex : batchVector) {
+        if(maxDims.size() < ex.size())
+          maxDims.resize(ex.size(), 0);
+        for(int i = 0; i < ex.size(); ++i) {
+          if(ex[i].size() > maxDims[i])
+          maxDims[i] = ex[i].size();
+        }
+      }
+
+      Batch batch;
+      std::vector<Input::iterator> iterators;
+      for(auto& m : maxDims) {
+        batch.push_back(Shape({batchSize, m}));
+        iterators.push_back(batch.inputs().back().begin());
+      }
+
+      for(auto& ex : batchVector) {
+        for(int i = 0; i < ex.size(); ++i) {
+          Data d = ex[i];
+          d.resize(maxDims[i], 0.0f);
+          iterators[i] = std::copy(d.begin(), d.end(), iterators[i]);
+        }
+      }
+      return batch;
+    }
+
+  public:
+    BatchGenerator(DataSet data,
+                   size_t batchSize=100,
+                   size_t maxiBatchSize=1000)
+    : data_(data), current_(data_.begin()),
+      batchSize_(batchSize),
+      maxiBatchSize_(maxiBatchSize) {
+
+      data_.shuffle();
+      fillBatches();
+    }
+
+    operator bool() const {
+      return !bufferedBatches_.empty();
+    }
+
+    Batch& next() {
+      UTIL_THROW_IF2(bufferedBatches_.empty(),
+                     "No batches to fetch");
+      currentBatch_ = bufferedBatches_.front();
+      bufferedBatches_.pop_front();
+
+      if(bufferedBatches_.empty())
+        fillBatches();
+
+      return currentBatch_;
+    }
+
+    void shuffle() {
+      data_.shuffle();
+      current_ = data_.begin();
+    }
+};
+
+}


prefer eeze backlight setting over randr: more accurate
supposedly fixes ticket #1015 (yakov ping me if this is somehow not fixing it)

SVN revision: 73526

--- src/bin/e_backlight.c
+++ src/bin/e_backlight.c
@@ -298,6 +298,15 @@
    int num = 0;

    root = zone->container->manager->root;
+#ifdef HAVE_EEZE
+   _bl_sys_find();
+   if (bl_sysval)
+     {
+        sysmode = MODE_SYS;
+        _bl_sys_level_get();
+        return;
+     }
+#endif
    // try randr
    out = ecore_x_randr_window_outputs_get(root, &num);
    if ((out) && (num > 0) && (ecore_x_randr_output_backlight_available()))
@@ -308,17 +317,6 @@
         bl_val = x_bl;
         sysmode = MODE_RANDR;
      }
-#ifdef HAVE_EEZE
-   else
-     {
-        _bl_sys_find();
-        if (bl_sysval)
-          {
-             sysmode = MODE_SYS;
-             _bl_sys_level_get();
-          }
-     }
-#endif
 }

 static void


new shelf menu item now brings up the new shelf starter dialog

SVN revision: 76303

--- src/bin/e_int_menus.c
+++ src/bin/e_int_menus.c
@@ -1521,28 +1521,10 @@
 static void
 _e_int_menus_shelves_add_cb(void *data __UNUSED__, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
 {
-   E_Container *con;
    E_Zone *zone;
-   E_Config_Shelf *cs;
-
-   con = e_container_current_get(e_manager_current_get());
-   zone = e_zone_current_get(con);
-   cs = E_NEW(E_Config_Shelf, 1);
-   cs->name = eina_stringshare_add("shelf");
-   cs->container = con->num;
-   cs->zone = zone->num;
-   cs->popup = 1;
-   cs->layer = 200;
-   cs->orient = E_GADCON_ORIENT_CORNER_BR;
-   cs->fit_along = 1;
-   cs->fit_size = 0;
-   cs->style = eina_stringshare_add("default");
-   cs->size = 40;
-   cs->overlap = 0;
-   e_config->shelves = eina_list_append(e_config->shelves, cs);
-   e_config_save_queue();
-
-   e_shelf_config_update();
+
+   zone = e_util_zone_current_get(e_manager_current_get());
+   e_shelf_new_dialog(zone);
 }

 static void


e menus: Fix invalid comparisons.

 e menus: Fix invalid comparisons.

 Fixes CID 1267215 and 1267216.

--- src/bin/e_int_menus.c
+++ src/bin/e_int_menus.c
@@ -1326,7 +1326,7 @@
    /* Deal with present desk first */
    EINA_LIST_FOREACH(clients, l, ec)
      {
-        if (ec->iconic && e_config->clientlist_separate_iconified_apps && E_CLIENTLIST_GROUPICONS_SEP)
+        if (ec->iconic && (e_config->clientlist_separate_iconified_apps == E_CLIENTLIST_GROUPICONS_SEP))
           {
              ico = eina_list_append(ico, ec);
              continue;
@@ -1397,8 +1397,7 @@

    EINA_LIST_FOREACH(clients, l, ec)
      {
-        if ((ec->iconic) && (e_config->clientlist_separate_iconified_apps) &&
-            (E_CLIENTLIST_GROUPICONS_SEP))
+        if ((ec->iconic) && (e_config->clientlist_separate_iconified_apps == E_CLIENTLIST_GROUPICONS_SEP))
           {
              ico = eina_list_append(ico, ec);
              continue;


Add preview of desktops' background on main menu's desktop selector.

Yes, I know, this one is purely for eye-candiness, but there was some empty space only waiting for us to fill it... :D

SVN revision: 36792

--- src/bin/e_int_menus.c
+++ src/bin/e_int_menus.c
@@ -56,6 +56,7 @@
 static const char *_e_int_menus_clients_title_abbrv (const char *title);
 static void _e_int_menus_virtuals_pre_cb     (void *data, E_Menu *m);
 static void _e_int_menus_virtuals_item_cb    (void *data, E_Menu *m, E_Menu_Item *mi);
+static void _e_int_menus_virtuals_icon_cb    (void *data, E_Menu *m, E_Menu_Item *mi);
 static void _e_int_menus_themes_about        (void *data, E_Menu *m, E_Menu_Item *mi);
 static void _e_int_menus_lost_clients_pre_cb    (void *data, E_Menu *m);
 static void _e_int_menus_lost_clients_free_hook (void *obj);
@@ -749,6 +750,7 @@
 	     if (desk == e_desk_current_get(zone))
 	       e_menu_item_toggle_set(mi, 1);
 	     e_menu_item_callback_set(mi, _e_int_menus_virtuals_item_cb, desk);
+	     e_menu_item_realize_callback_set(mi, _e_int_menus_virtuals_icon_cb, desk);
 	  }
      }

@@ -776,6 +778,28 @@
    E_Desk *desk = data;

    e_desk_show(desk);
+}
+
+static void
+_e_int_menus_virtuals_icon_cb(void *data, E_Menu *m, E_Menu_Item *mi)
+{
+   E_Desk *desk;
+   Evas_Object *o;
+   const char *bgfile;
+   int tw, th;
+
+   desk = data;
+   E_OBJECT_CHECK(desk);
+
+   tw = 50;
+   th = (tw * desk->zone->h) / desk->zone->w;
+
+   bgfile = e_bg_file_get(desk->zone->container->num, desk->zone->num, desk->x, desk->y);
+   o = e_thumb_icon_add(m->evas);
+   e_thumb_icon_file_set(o, bgfile, "e/desktop/background");
+   e_thumb_icon_size_set(o, tw, th);
+   e_thumb_icon_begin(o);
+   mi->icon_object = o;
 }

 static void


In menu end, delete objects rather than unref

--- src/bin/e_int_menus.c
+++ src/bin/e_int_menus.c
@@ -169,9 +169,9 @@
    Main_Data *dat;

    dat = data;
-   e_object_unref(E_OBJECT(dat->apps));
-   e_object_unref(E_OBJECT(dat->modules));
-   e_object_unref(E_OBJECT(m));
+   e_object_del(E_OBJECT(dat->apps));
+   e_object_del(E_OBJECT(dat->modules));
+   e_object_del(E_OBJECT(m));
    free(dat);
 }

@@ -260,7 +260,7 @@
 	if (mi->submenu)
 	  _e_int_menus_apps_end(NULL, mi->submenu);
      }
-   e_object_unref(E_OBJECT(m));
+   e_object_del(E_OBJECT(m));
 }

 static void


BUGFIX: do not consider a directory empty when using the -d option and depth has been reached.

--- file_entry.c
+++ file_entry.c
@@ -684,6 +684,10 @@
                     (p->fts_level >= options->dir_depth)) {
                     fts_set(ftsp, p, FTS_SKIP);
                     curdir_addme = 1;
+                    /* as we have not crawled into this directory yet,
+                       remove the empty flag to allow a call to get_size() in
+                       FTS_DP */
+                    curdir_empty = 0;
                 }
                 continue;
             }


bonjour-contact: Remove unwanted debug messages

--- src/bonjour-contact.c
+++ src/bonjour-contact.c
@@ -196,7 +196,6 @@
              port = ctx->port;
              addr = g_inet_address_new_from_bytes (
                  (guint8 *) &(address->sin_addr), G_SOCKET_FAMILY_IPV4);
-             DEBUG ("%s", g_inet_address_to_string (addr));
            }
          else if (ctx->address->sa_family == AF_INET6)
            {


Fixed local variable references in nested blocks

--- src/buzz/buzzparser.c
+++ src/buzz/buzzparser.c
@@ -506,7 +506,15 @@
       return PARSE_OK;
    }
    else {
-      if(pushsymt) symt_push();
+      if(pushsymt) {
+         if(buzzdarray_size(par->symstack) == 1) {
+            /* Add new symtable */
+            symt_push();
+         }
+         else {
+            symt_clone();
+         }
+      }
       /* Save the current number of variables */
       uint32_t numvars = buzzdict_size(par->syms);
       if(parse_statlist(par)) {


Fix some simple bug

Fix some simple bug

--- src/drivers/timers.c
+++ src/drivers/timers.c
@@ -114,7 +114,7 @@
 	}
 */
 	TRY_CAPTURE_APB_DEV (&apb_dev, VENDOR_ID_GAISLER, DEV_ID_GAISLER_TIMER);
-	timers = apb_dev.base;//(TIMERS_STRUCT *) (0x80000000 + ((apb_dev.ba_reg.addr) << 8)); // TODO 0x80000000
+	timers = (TIMERS_STRUCT *)apb_dev.base;//(TIMERS_STRUCT *) (0x80000000 + ((apb_dev.ba_reg.addr) << 8)); // TODO 0x80000000
 	timers->scaler_ld = TIMER_SCALER_VAL;
 	timers->scaler_cnt = 0;
 	timers->timer_cnt1 = 0;


tests: usb: Add more basic device API tests

Add more tests testing basic API and native_posix driver.

Signed-off-by: Andrei Emeltchenko <a6565233ddc88e4fb9c66c1d70743223493f2ed4@intel.com>

--- tests/subsys/usb/device/src/main.c
+++ tests/subsys/usb/device/src/main.c
@@ -140,11 +140,44 @@
 	zassert_equal(ret, 0, "init failed");
 }

+static void test_device_disable(void)
+{
+	zassert_equal(usb_disable(), TC_PASS, "usb_disable() failed");
+}
+
+static void test_device_deconfig(void)
+{
+	zassert_equal(usb_deconfig(), TC_PASS, "usb_deconfig() failed");
+}
+
+static void test_device_dc_api(void)
+{
+	zassert_equal(usb_dc_ep_mps(0x20), -EINVAL,
+		      "Invalid test usb_dc_ep_mps(INVALID) failed");
+
+	zassert_equal(usb_dc_ep_mps(0x0), 64,
+		      "usb_dc_ep_mps(0x00) failed");
+	zassert_equal(usb_dc_ep_mps(0x80), 64,
+		      "usb_dc_ep_mps(0x80) failed");
+
+	/* Bulk EP is not configured yet */
+	zassert_equal(usb_dc_ep_mps(ENDP_BULK_IN), 0,
+		      "usb_dc_ep_mps(ENDP_BULK_IN) failed");
+
+	zassert_equal(usb_dc_set_address(0x01), TC_PASS,
+		      "usb_dc_set_address(0x01) failed");
+}
+
 /*test case main entry*/
 void test_main(void)
 {
 	ztest_test_suite(test_device,
-			 ztest_unit_test(test_device_setup));
+			 /* Should return TC_PASS if not enabled yet */
+			 ztest_unit_test(test_device_disable),
+			 ztest_unit_test(test_device_setup),
+			 ztest_unit_test(test_device_dc_api),
+			 ztest_unit_test(test_device_deconfig),
+			 ztest_unit_test(test_device_disable));

 	ztest_run_test_suite(test_device);
 }


streaming: Report invalid streams to the server

The error is sent using the existing client stream report message where
the dropped frame count is maxed out while the received frame count is
zero. Servers that recognize it can then switch to sending regular
screen updates for that area so the client is not stuck with a frozen
area on the screen.
This can be useful in case the client is unable to decode the stream for
some reason like a bug in the GStreamer plugins, the decoder not liking
odd video dimensions, etc.

Signed-off-by: Francois Gouget <6b915da68578f6eb004fe99432b967565fc9be8f@codeweavers.com>
Acked-by: Victor Toso <39b7599ff73bbf5db531748ba5250f21fa7120ff@redhat.com>

--- src/channel-display.c
+++ src/channel-display.c
@@ -1077,6 +1077,40 @@
     }
 }

+static void report_invalid_stream(SpiceChannel *channel, uint32_t id)
+{
+    if (spice_channel_test_capability(channel, SPICE_DISPLAY_CAP_STREAM_REPORT)) {
+        SpiceMsgcDisplayStreamReport report;
+        SpiceMsgOut *msg;
+
+        /* Send a special stream report (UINT_MAX dropped frames out of zero)
+         * to indicate there is no such stream.
+         */
+        spice_printerr("notify the server that stream %u does not exist", id);
+        memset(&report, 0, sizeof(report));
+        report.stream_id = id;
+        report.num_frames = 0;
+        report.num_drops = UINT_MAX;
+
+        msg = spice_msg_out_new(SPICE_CHANNEL(channel), SPICE_MSGC_DISPLAY_STREAM_REPORT);
+        msg->marshallers->msgc_display_stream_report(msg->marshaller, &report);
+        spice_msg_out_send(msg);
+    }
+}
+
+static display_stream *get_stream_by_id(SpiceChannel *channel, uint32_t id)
+{
+    SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)->priv;
+
+    if (c != NULL && c->streams != NULL && id < c->nstreams &&
+        c->streams[id] != NULL) {
+        return c->streams[id];
+    }
+
+    report_invalid_stream(channel, id);
+    return NULL;
+}
+
 /* coroutine context */
 static void display_handle_stream_create(SpiceChannel *channel, SpiceMsgIn *in)
 {
@@ -1127,6 +1161,7 @@
     if (st->video_decoder == NULL) {
         spice_printerr("could not create a video decoder for codec %u", op->codec_type);
         destroy_stream(channel, op->id);
+        report_invalid_stream(channel, op->id);
     }
 }

@@ -1224,17 +1259,10 @@
 static void display_update_stream_report(SpiceDisplayChannel *channel, uint32_t stream_id,
                                          uint32_t frame_time, int32_t latency)
 {
-    SpiceDisplayChannelPrivate *c = channel->priv;
-    display_stream *st;
+    display_stream *st = get_stream_by_id(SPICE_CHANNEL(channel), stream_id);
     guint64 now;

-    g_return_if_fail(c != NULL);
-    g_return_if_fail(c->streams != NULL);
-    g_return_if_fail(c->nstreams > stream_id);
-
-    st = channel->priv->streams[stream_id];
     g_return_if_fail(st != NULL);
-
     if (!st->report_is_active) {
         return;
     }
@@ -1347,15 +1375,10 @@
 {
     SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)->priv;
     SpiceStreamDataHeader *op = spice_msg_in_parsed(in);
-    display_stream *st;
+    display_stream *st = get_stream_by_id(channel, op->id);
     guint32 mmtime;
     int32_t latency;

-    g_return_if_fail(c != NULL);
-    g_return_if_fail(c->streams != NULL);
-    g_return_if_fail(c->nstreams > op->id);
-
-    st =  c->streams[op->id];
     g_return_if_fail(st != NULL);
     mmtime = stream_get_time(st);

@@ -1415,17 +1438,10 @@
 /* coroutine context */
 static void display_handle_stream_clip(SpiceChannel *channel, SpiceMsgIn *in)
 {
-    SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)->priv;
     SpiceMsgDisplayStreamClip *op = spice_msg_in_parsed(in);
-    display_stream *st;
-
-    g_return_if_fail(c != NULL);
-    g_return_if_fail(c->streams != NULL);
-    g_return_if_fail(c->nstreams > op->id);
-
-    st = c->streams[op->id];
+    display_stream *st = get_stream_by_id(channel, op->id);
+
     g_return_if_fail(st != NULL);
-
     if (st->msg_clip) {
         spice_msg_in_unref(st->msg_clip);
     }
@@ -1524,17 +1540,10 @@
 /* coroutine context */
 static void display_handle_stream_activate_report(SpiceChannel *channel, SpiceMsgIn *in)
 {
-    SpiceDisplayChannelPrivate *c = SPICE_DISPLAY_CHANNEL(channel)->priv;
     SpiceMsgDisplayStreamActivateReport *op = spice_msg_in_parsed(in);
-    display_stream *st;
-
-    g_return_if_fail(c != NULL);
-    g_return_if_fail(c->streams != NULL);
-    g_return_if_fail(c->nstreams > op->stream_id);
-
-    st = c->streams[op->stream_id];
+    display_stream *st = get_stream_by_id(channel, op->stream_id);
+
     g_return_if_fail(st != NULL);
-
     st->report_is_active = TRUE;
     st->report_id = op->unique_id;
     st->report_max_window = op->max_window_size;


Remove a couple hot calls to gettext()

Remove a couple hot calls to gettext()

This was recommended by Olivier Crête based on profiling results:

https://bugzilla.gnome.org/show_bug.cgi?id=697908#c131

--- tls/gnutls/gtlsconnection-gnutls.c
+++ tls/gnutls/gtlsconnection-gnutls.c
@@ -782,8 +782,9 @@

       if (timeout == 0)
         {
-          g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK,
-                               _("Operation would block"));
+          /* Intentionally not translated because this is not a fatal error to be
+           * presented to the user, and to avoid this showing up in profiling. */
+          g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK, "Operation would block");
           return FALSE;
         }

@@ -2224,8 +2225,9 @@
       g_task_run_in_thread (priv->implicit_handshake,
                             async_handshake_thread);

-      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK,
-                           _("Operation would block"));
+      /* Intentionally not translated because this is not a fatal error to be
+       * presented to the user, and to avoid this showing up in profiling. */
+      g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK, "Operation would block");
       return FALSE;
     }
 }


cmd/gc: racewalk: do not double function calls
Current racewalk transformation looks like:
x := <-makeChan().c
\/\/\/\/\/\/\/\/\/
runtime.raceread(&makeChan().c)
x := <-makeChan().c
and so makeChan() is called twice.
With this CL the transformation looks like:
x := <-makeChan().c
\/\/\/\/\/\/\/\/\/
chan *tmp = &(makeChan().c)
raceread(&*tmp)
x := <-(*tmp)
Fixes issue 4245.

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

--- src/cmd/gc/racewalk.c
+++ src/cmd/gc/racewalk.c
@@ -21,9 +21,12 @@

 static void racewalklist(NodeList *l, NodeList **init);
 static void racewalknode(Node **np, NodeList **init, int wr, int skip);
-static int callinstr(Node *n, NodeList **init, int wr, int skip);
+static int callinstr(Node **n, NodeList **init, int wr, int skip);
 static Node* uintptraddr(Node *n);
 static Node* basenod(Node *n);
+static void foreach(Node *n, void(*f)(Node*, void*), void *c);
+static void hascallspred(Node *n, void *c);
+static Node* detachexpr(Node *n, NodeList **init);

 static const char *omitPkgs[] = {"runtime", "runtime/race", "sync", "sync/atomic"};

@@ -196,18 +199,18 @@
 		goto ret;

 	case ODOT:
-		callinstr(n, init, wr, skip);
 		racewalknode(&n->left, init, 0, 1);
+		callinstr(&n, init, wr, skip);
 		goto ret;

 	case ODOTPTR: // dst = (*x).f with implicit *; otherwise it's ODOT+OIND
-		callinstr(n, init, wr, skip);
-		racewalknode(&n->left, init, 0, 0);
+		racewalknode(&n->left, init, 0, 0);
+		callinstr(&n, init, wr, skip);
 		goto ret;

 	case OIND: // *p
-		callinstr(n, init, wr, skip);
-		racewalknode(&n->left, init, 0, 0);
+		racewalknode(&n->left, init, 0, 0);
+		callinstr(&n, init, wr, skip);
 		goto ret;

 	case OLEN:
@@ -223,7 +226,7 @@
 			n1 = nod(OIND, n1, N);
 			n1 = nod(OIND, n1, N);
 			typecheck(&n1, Erv);
-			callinstr(n1, init, 0, skip);
+			callinstr(&n1, init, 0, skip);
 			*/
 		}
 		goto ret;
@@ -257,7 +260,7 @@
 		goto ret;

 	case ONAME:
-		callinstr(n, init, wr, skip);
+		callinstr(&n, init, wr, skip);
 		goto ret;

 	case OCONV:
@@ -276,11 +279,11 @@
 		goto ret;

 	case OINDEX:
-		if(n->left->type->etype != TSTRING)
-			callinstr(n, init, wr, skip);
 		if(!isfixedarray(n->left->type))
 			racewalknode(&n->left, init, 0, 0);
 		racewalknode(&n->right, init, 0, 0);
+		if(n->left->type->etype != TSTRING)
+			callinstr(&n, init, wr, skip);
 		goto ret;

 	case OSLICE:
@@ -376,12 +379,13 @@
 }

 static int
-callinstr(Node *n, NodeList **init, int wr, int skip)
-{
-	Node *f, *b;
+callinstr(Node **np, NodeList **init, int wr, int skip)
+{
+	Node *f, *b, *n;
 	Type *t, *t1;
-	int class, res;
-
+	int class, res, hascalls;
+
+	n = *np;
 	//print("callinstr for %N [ %s ] etype=%d class=%d\n",
 	//	  n, opnames[n->op], n->type ? n->type->etype : -1, n->class);

@@ -402,11 +406,17 @@
 	}
 	if(t->etype == TSTRUCT) {
 		res = 0;
+		hascalls = 0;
+		foreach(n, hascallspred, &hascalls);
+		if(hascalls) {
+			n = detachexpr(n, init);
+			*np = n;
+		}
 		for(t1=t->type; t1; t1=t1->down) {
 			if(t1->sym && strcmp(t1->sym->name, "_")) {
 				n = treecopy(n);
 				f = nod(OXDOT, n, newname(t1->sym));
-				if(callinstr(f, init, wr, 0)) {
+				if(callinstr(&f, init, wr, 0)) {
 					typecheck(&f, Erv);
 					res = 1;
 				}
@@ -423,6 +433,12 @@
 	// the heap or not is impossible to know at compile time
 	if((class&PHEAP) || class == PPARAMREF || class == PEXTERN
 		|| b->type->etype == TARRAY || b->op == ODOTPTR || b->op == OIND || b->op == OXDOT) {
+		hascalls = 0;
+		foreach(n, hascallspred, &hascalls);
+		if(hascalls) {
+			n = detachexpr(n, init);
+			*np = n;
+		}
 		n = treecopy(n);
 		f = mkcall(wr ? "racewrite" : "raceread", T, nil, uintptraddr(n));
 		//typecheck(&f, Etop);
@@ -459,3 +475,60 @@
 	}
 	return n;
 }
+
+static Node*
+detachexpr(Node *n, NodeList **init)
+{
+	Node *addr, *as, *ind, *l;
+
+	addr = nod(OADDR, n, N);
+	l = temp(ptrto(n->type));
+	as = nod(OAS, l, addr);
+	typecheck(&as, Etop);
+	walkexpr(&as, init);
+	*init = list(*init, as);
+	ind = nod(OIND, l, N);
+	typecheck(&ind, Erv);
+	walkexpr(&ind, init);
+	return ind;
+}
+
+static void
+foreachnode(Node *n, void(*f)(Node*, void*), void *c)
+{
+	if(n)
+		f(n, c);
+}
+
+static void
+foreachlist(NodeList *l, void(*f)(Node*, void*), void *c)
+{
+	for(; l; l = l->next)
+		foreachnode(l->n, f, c);
+}
+
+static void
+foreach(Node *n, void(*f)(Node*, void*), void *c)
+{
+	foreachlist(n->ninit, f, c);
+	foreachnode(n->left, f, c);
+	foreachnode(n->right, f, c);
+	foreachlist(n->list, f, c);
+	foreachnode(n->ntest, f, c);
+	foreachnode(n->nincr, f, c);
+	foreachlist(n->nbody, f, c);
+	foreachlist(n->nelse, f, c);
+	foreachlist(n->rlist, f, c);
+}
+
+static void
+hascallspred(Node *n, void *c)
+{
+	switch(n->op) {
+	case OCALL:
+	case OCALLFUNC:
+	case OCALLMETH:
+	case OCALLINTER:
+		(*(int*)c)++;
+	}
+}


Fix the code for finding the interpreter, which was I had totally screwed up the first time...  -Erik

--- ldso/util/readelf.c
+++ ldso/util/readelf.c
@@ -49,7 +49,7 @@
 			return shdr;
 		}
 	}
-	return 0;
+	return NULL;
 }

 Elf32_Phdr * elf_find_phdr_type( int type, Elf32_Ehdr *ehdr)
@@ -61,7 +61,7 @@
 			return phdr;
 		}
 	}
-	return 0;
+	return NULL;
 }

 /* Returns value if return_val==1, ptr otherwise */
@@ -78,7 +78,7 @@
 				return (void *)(dynp->d_un.d_val - tx_reloc + (char *)ehdr );
 		}
 	}
-	return 0;
+	return NULL;
 }

 int check_elf_header(Elf32_Ehdr const *const ehdr)
@@ -256,7 +256,7 @@
 	Elf32_Phdr *phdr;
 	phdr = elf_find_phdr_type(PT_INTERP, ehdr);
 	if (phdr) {
-		printf("Interpreter:\t%s\n", (char*)phdr->p_paddr);
+		printf("Interpreter:\t%s\n", (char*)ehdr + phdr->p_offset);
 	}
 }


test/compress: replace test vector

test/compress: replace test vector

This patch replaces an existing test vector with a new one containing
public domain text only. This is to avoid any potential issues
re-licensing content as BSD-3 which has no clear original license.

Fixes: b06aa643cac4 ("test/compress: add initial unit tests")
Cc: stable@dpdk.org

Signed-off-by: Artur Trybula <9b08cd0307417ae16f08b52d1e1662828ef06a1e@intel.com>

--- app/test/test_compressdev_test_buffer.h
+++ app/test/test_compressdev_test_buffer.h
@@ -1,3 +1,7 @@
+/* SPDX-License-Identifier: (BSD-3-Clause)
+ * Copyright(c) 2018-2020 Intel Corporation
+ */
+
 #ifndef TEST_COMPRESSDEV_TEST_BUFFERS_H_
 #define TEST_COMPRESSDEV_TEST_BUFFERS_H_

@@ -190,106 +194,104 @@
 	"\n"
 	"ORLANDO	Go apart, Adam, and thou shalt hear how he will\n";

-/* Snippet of source code in Pascal */
-static const char test_buf_pascal[] =
-	"	Ptr    = 1..DMem;\n"
-	"	Loc    = 1..IMem;\n"
-	"	Loc0   = 0..IMem;\n"
-	"	EdgeT  = (hout,lin,hin,lout); {Warning this order is important in}\n"
-	"				      {predicates such as gtS,geS}\n"
-	"	CardT  = (finite,infinite);\n"
-	"	ExpT   = Minexp..Maxexp;\n"
-	"	ManT   = Mininf..Maxinf; \n"
-	"	Pflag  = (PNull,PSoln,PTrace,PPrint);\n"
-	"	Sreal  = record\n"
-	"		    edge:EdgeT;\n"
-	"		    cardinality:CardT;\n"
-	"		    exp:ExpT; {exponent}\n"
-	"		    mantissa:ManT;\n"
-	"		 end;\n"
-	"	Int    = record\n"
-	"		    hi:Sreal;\n"
-	"		    lo:Sreal;\n"
-	"	 end;\n"
-	"	Instr  = record\n"
-	"		    Code:OpType;\n"
-	"		    Pars: array[0..Par] of 0..DMem;\n"
-	"		 end;\n"
-	"	DataMem= record\n"
-	"		    D        :array [Ptr] of Int;\n"
-	"		    S        :array [Loc] of State;\n"
-	"		    LastHalve:Loc;\n"
-	"		    RHalve   :array [Loc] of real;\n"
-	"		 end;\n"
-	"	DataFlags=record\n"
-	"		    PF	     :array [Ptr] of Pflag;\n"
-	"		 end;\n"
-	"var\n"
-	"	Debug  : (none,activity,post,trace,dump);\n"
-	"	Cut    : (once,all);\n"
-	"	GlobalEnd,Verifiable:boolean;\n"
-	"	HalveThreshold:real;\n"
-	"	I      : array [Loc] of Instr; {Memory holding instructions}\n"
-	"	End    : Loc; {last instruction in I}\n"
-	"	ParN   : array [OpType] of -1..Par; {number of parameters for each \n"
-	"			opcode. -1 means no result}\n"
-	"        ParIntersect : array [OpType] of boolean ;\n"
-	"	DInit  : DataMem; {initial memory which is cleared and \n"
-	"				used in first call}\n"
-	"	DF     : DataFlags; {hold flags for variables, e.g. print/trace}\n"
-	"	MaxDMem:0..DMem;\n"
-	"	Shift  : array[0..Digits] of 1..maxint;{array of constant multipliers}\n"
-	"						{used for alignment etc.}\n"
-	"	Dummy  :Positive;\n"
-	"	{constant intervals and Sreals}\n"
-	"	PlusInfS,MinusInfS,PlusSmallS,MinusSmallS,ZeroS,\n"
-	"	PlusFiniteS,MinusFiniteS:Sreal;\n"
-	"	Zero,All,AllFinite:Int;\n"
-	"\n"
-	"procedure deblank;\n"
-	"var Ch:char;\n"
-	"begin\n"
-	"   while (not eof) and (input^ in [' ','	']) do read(Ch);\n"
-	"end;\n"
-	"\n"
-	"procedure InitialOptions;\n"
-	"\n"
-	"#include '/user/profs/cleary/bin/options.i';\n"
-	"\n"
-	"   procedure Option;\n"
-	"   begin\n"
-	"      case Opt of\n"
-	"      'a','A':Debug:=activity;\n"
-	"      'd','D':Debug:=dump;\n"
-	"      'h','H':HalveThreshold:=StringNum/100;\n"
-	"      'n','N':Debug:=none;\n"
-	"      'p','P':Debug:=post;\n"
-	"      't','T':Debug:=trace;\n"
-	"      'v','V':Verifiable:=true;\n"
-	"      end;\n"
-	"   end;\n"
-	"\n"
-	"begin\n"
-	"   Debug:=trace;\n"
-	"   Verifiable:=false;\n"
-	"   HalveThreshold:=67/100;\n"
-	"   Options;\n"
-	"   writeln(Debug);\n"
-	"   writeln('Verifiable:',Verifiable);\n"
-	"   writeln('Halve threshold',HalveThreshold);\n"
-	"end;{InitialOptions}\n"
-	"\n"
-	"procedure NormalizeUp(E,M:integer;var S:Sreal;var Closed:boolean);\n"
-	"begin\n"
-	"with S do\n"
-	"begin\n"
-	"   if M=0 then S:=ZeroS else\n"
-	"   if M>0 then\n";
+/* Snippet of Alice's Adventures in Wonderland */
+static const char test_buf_alice2[] =
+	"`Curiouser and curiouser!' cried Alice (she was so much\n"
+	"surprised, that for the moment she quite forgot how to speak good\n"
+	"English); `now I'm opening out like the largest telescope that\n"
+	"ever was!  Good-bye, feet!' (for when she looked down at her\n"
+	"feet, they seemed to be almost out of sight, they were getting so\n"
+	"far off).  `Oh, my poor little feet, I wonder who will put on\n"
+	"your shoes and stockings for you now, dears?  I'm sure _I_ shan't\n"
+	"be able!  I shall be a great deal too far off to trouble myself\n"
+	"about you:  you must manage the best way you can; --but I must be\n"
+	"kind to them,' thought Alice, `or perhaps they won't walk the\n"
+	"way I want to go!  Let me see:  I'll give them a new pair of\n"
+	"boots every Christmas.'\n"
+	"\n"
+	"  And she went on planning to herself how she would manage it.\n"
+	"`They must go by the carrier,' she thought; `and how funny it'll\n"
+	"seem, sending presents to one's own feet!  And how odd the\n"
+	"directions will look!\n"
+	"\n"
+	"	    ALICE'S RIGHT FOOT, ESQ.\n"
+	"		HEARTHRUG,\n"
+	"		    NEAR THE FENDER,\n"
+	"			(WITH ALICE'S LOVE).\n"
+	"\n"
+	"Oh dear, what nonsense I'm talking!'\n"
+	"\n"
+	"  Just then her head struck against the roof of the hall:  in\n"
+	"fact she was now more than nine feet high, and she at once took\n"
+	"up the little golden key and hurried off to the garden door.\n"
+	"\n"
+	"  Poor Alice!  It was as much as she could do, lying down on one\n"
+	"side, to look through into the garden with one eye; but to get\n"
+	"through was more hopeless than ever:  she sat down and began to\n"
+	"cry again.\n"
+	"\n"
+	"  `You ought to be ashamed of yourself,' said Alice, `a great\n"
+	"girl like you,' (she might well say this), `to go on crying in\n"
+	"this way!  Stop this moment, I tell you!'  But she went on all\n"
+	"the same, shedding gallons of tears, until there was a large pool\n"
+	"all round her, about four inches deep and reaching half down the\n"
+	"hall.\n"
+	"\n"
+	" After a time she heard a little pattering of feet in the\n"
+	"distance, and she hastily dried her eyes to see what was coming.\n"
+	"It was the White Rabbit returning, splendidly dressed, with a\n"
+	"pair of white kid gloves in one hand and a large fan in the\n"
+	"other:  he came trotting along in a great hurry, muttering to\n"
+	"himself as he came, `Oh! the Duchess, the Duchess! Oh! won't she\n"
+	"be savage if I've kept her waiting!'  Alice felt so desperate\n"
+	"that she was ready to ask help of any one; so, when the Rabbit\n"
+	"came near her, she began, in a low, timid voice, `If you please,\n"
+	"sir--'  The Rabbit started violently, dropped the white kid\n"
+	"gloves and the fan, and skurried away into the darkness as hard\n"
+	"as he could go.\n"
+	"\n"
+	"  Alice took up the fan and gloves, and, as the hall was very\n"
+	"hot, she kept fanning herself all the time she went on talking:\n"
+	"`Dear, dear!  How queer everything is to-day!  And yesterday\n"
+	"things went on just as usual.  I wonder if I've been changed in\n"
+	"the night?  Let me think:  was I the same when I got up this\n"
+	"morning?  I almost think I can remember feeling a little\n"
+	"different.  But if I'm not the same, the next question is, Who in\n"
+	"the world am I?  Ah, THAT'S the great puzzle!'  And she began\n"
+	"thinking over all the children she knew that were of the same age\n"
+	"as herself, to see if she could have been changed for any of\n"
+	"them.\n"
+	"\n"
+	"  `I'm sure I'm not Ada,' she said, `for her hair goes in such\n"
+	"long ringlets, and mine doesn't go in ringlets at all; and I'm\n"
+	"sure I can't be Mabel, for I know all sorts of things, and she,\n"
+	"oh! she knows such a very little!  Besides, SHE'S she, and I'm I,\n"
+	"and--oh dear, how puzzling it all is!  I'll try if I know all the\n"
+	"things I used to know.  Let me see:  four times five is twelve,\n"
+	"and four times six is thirteen, and four times seven is--oh dear!\n"
+	"I shall never get to twenty at that rate!  However, the\n"
+	"Multiplication Table doesn't signify:  let's try Geography.\n"
+	"London is the capital of Paris, and Paris is the capital of Rome,\n"
+	"and Rome--no, THAT'S all wrong, I'm certain!  I must have been\n"
+	"changed for Mabel!  I'll try and say ''How doth the little--''\n"
+	"and she crossed her hands on her lap as if she were saying lessons,\n"
+	"and began to repeat it, but her voice sounded hoarse and\n"
+	"strange, and the words did not come the same as they used to do:--\n"
+	"\n"
+	"	    `How doth the little crocodile\n"
+	"	      Improve his shining tail,\n"
+	"	    And pour the waters of the Nile\n"
+	"	      On every golden scale!\n"
+	"\n"
+	"	    `How cheerfully he seems to grin,\n"
+	"	      How neatly spread his claws,\n"
+	"	    And welcome little fishes in\n"
+	"	      With gently smiling jaws!'\n";

 static const char * const compress_test_bufs[] = {
 	test_buf_alice,
 	test_buf_shakespeare,
-	test_buf_pascal
+	test_buf_alice2
 };

 #endif /* TEST_COMPRESSDEV_TEST_BUFFERS_H_ */


overlapped send with event object

overlapped send with event object

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

--- windows_test/OverlappedSend_Event.c
+++ windows_test/OverlappedSend_Event.c
@@ -0,0 +1,66 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <winsock2.h>
+
+void ErrorHandling(char* msg);
+
+int main(int argc, char* argv[]) {
+	WSADATA wsaData;
+	SOCKET hSocket;
+	SOCKADDR_IN sendAdr;
+
+	WSABUF dataBuf;
+	char msg[] = "Network is Computer!";
+	int sendBytes = 0;
+
+	WSAEVENT evObj;
+	WSAOVERLAPPED overlapped;
+
+	if (argc != 3) {
+		printf("Usage: %s <IP> <port> \n", argv[0]);
+		exit(1);
+	}
+
+	if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0)
+		ErrorHandling("WSAStartup() error!");
+
+	hSocket = WSASocket(PF_INET, SOCK_STREAM, 0, NULL, 0, WSA_FLAG_OVERLAPPED);
+	memset(&sendAdr, 0, sizeof(sendAdr));
+	sendAdr.sin_family = AF_INET;
+	sendAdr.sin_addr.s_addr = inet_addr(argv[1]);
+	sendAdr.sin_port = htons(atoi(argv[2]));
+
+	if (connect(hSocket, (SOCKADDR*)&sendAdr, sizeof(sendAdr)) == SOCKET_ERROR)
+		ErrorHandling("connect() error!");
+
+	evObj = WSACreateEvent();
+	memset(&overlapped, 0, sizeof(overlapped));
+	overlapped.hEvent = evObj;
+	dataBuf.len = strlen(msg) + 1;
+	dataBuf.buf = msg;
+
+	if (WSASend(hSocket, &dataBuf, 1, &sendBytes, 0, &overlapped, NULL) == SOCKET_ERROR) {
+		if (WSAGetLastError() == WSA_IO_PENDING) {
+			puts("Background data send");
+			WSAWaitForMultipleEvents(1, &evObj, TRUE, WSA_INFINITE, FALSE);
+			WSAGetOverlappedResult(hSocket, &overlapped, &sendBytes, FALSE, NULL);
+		}
+		else {
+			ErrorHandling("WSASend() error!");
+		}
+	}
+
+	printf("Send data size: %d\n", sendBytes);
+
+	WSACloseEvent(evObj);
+	closesocket(hSocket);
+	WSACleanup();
+
+	return 0;
+}
+
+void ErrorHandling(char* msg) {
+	fputs(msg, stderr);
+	fputc('\n', stderr);
+	exit(1);
+}


parser: Add .type checks in knd_spec_is_correct()

--- parser/src/knd_parser.c
+++ parser/src/knd_parser.c
@@ -471,16 +471,23 @@

     // Check that they are not mutually exclusive (in general):

+    if (spec->type) {
+        assert(!spec->is_default && (!spec->is_implied || spec->name));
+        assert(spec->name || spec->is_validator);
+    }
+
     if (spec->name)
         assert(!spec->is_default && !spec->is_validator);

     if (spec->is_default) {
+        assert(spec->type == 0);  // type is useless for default_spec
         assert(spec->name == NULL);
         assert(spec->obj != NULL);
         assert(spec->run != NULL);
     }

     if (spec->is_implied) {
+        // |spec->type| can be set (depends on |spec->name|)
         // |spec->name| can be NULL
         if (spec->buf)
             assert(spec->obj == NULL);
@@ -490,12 +497,14 @@

     assert(spec->is_validator == (spec->validate != NULL));
     if (spec->is_validator) {
+        // |spec->type| can be set
         assert(spec->name == NULL);
         assert(spec->obj != NULL);
         assert(spec->validate != NULL);
     }

     if (spec->is_list) {
+        // TODO(ki.stfu): ?? assert(spec->type == 0);
         assert(spec->accu != NULL);
         assert(spec->alloc != NULL);
         assert(spec->append != NULL);
@@ -504,11 +513,13 @@
     }

     if (spec->buf) {
+        // |spec->type| can be set (depends on |spec->name|)
         assert(spec->is_implied || spec->name != NULL);
         assert(spec->obj == NULL);
     }

     if (spec->parse) {
+        // |spec->type| can be set
         assert(spec->name != NULL);
         if (!spec->is_list)
             assert(spec->obj != NULL);
@@ -517,6 +528,7 @@
     // if (spec->validate)  -- already handled in spec->is_validator

     if (spec->run) {
+        // |spec->type| can be set (depends on |spec->name|)
         assert(spec->is_default || spec->is_implied || spec->name != NULL);
         assert(spec->obj != NULL);
     }