Formatting.

Formatting.

SVN revision: 32202

--- src/modules/conf_keybindings/e_int_config_keybindings.c
+++ src/modules/conf_keybindings/e_int_config_keybindings.c
@@ -1,3 +1,6 @@
+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
 #include "e.h"

 #define TEXT_NONE_ACTION_KEY _("<None>")
@@ -9,8 +12,8 @@
 static void	    *_create_data(E_Config_Dialog *cfd);
 static void	    _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
 static int	    _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
-static Evas_Object  *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas,
-					   E_Config_Dialog_Data *cfdata);
+static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas,
+					  E_Config_Dialog_Data *cfdata);

 /********* private functions ***************/
 static void _fill_actions_list(E_Config_Dialog_Data *cfdata);
@@ -979,7 +982,7 @@
    cfdata = data;

    if (ev->win != cfdata->locals.bind_win) return 1;
-
+
    if (!strcmp(ev->keyname, "Escape") &&
        !(ev->modifiers & ECORE_X_MODIFIER_SHIFT) &&
        !(ev->modifiers & ECORE_X_MODIFIER_CTRL) &&
@@ -1000,14 +1003,16 @@
 	    !strcmp(ev->keyname, "Shift_L") || !strcmp(ev->keyname, "Shift_R") ||
 	    !strcmp(ev->keyname, "Alt_L") || !strcmp(ev->keyname, "Alt_R") ||
 	    !strcmp(ev->keyname, "Super_L") || !strcmp(ev->keyname, "Super_R"))
-	  ;
+	  {
+	     /* Do nothing */
+	  }
 	else
 	  {
 	     E_Config_Binding_Key *bi = NULL, *bi2 = NULL;
 	     Evas_List *l = NULL;
 	     int mod = E_BINDING_MODIFIER_NONE;
 	     int found = 0, n;
-
+
 	     if (ev->modifiers & ECORE_X_MODIFIER_SHIFT)
 	       mod |= E_BINDING_MODIFIER_SHIFT;
 	     if (ev->modifiers & ECORE_X_MODIFIER_CTRL)
@@ -1088,22 +1093,22 @@
 		       e_widget_ilist_unselect(cfdata->gui.o_action_list);
 		       if (cfdata->locals.action) free(cfdata->locals.action);
 		       cfdata->locals.action = strdup("");
-	               if (cfdata->params[0])
-                         {
-			     int j, g = -1;
-			     _find_key_binding_action("exec", NULL, &g, NULL, &j);
-			     if (j >= 0)
-                               {
-			          e_widget_ilist_unselect(cfdata->gui.o_action_list);
-			          e_widget_ilist_selected_set(cfdata->gui.o_action_list, (j + g + 1));
-				  e_widget_entry_clear(cfdata->gui.o_params);
-				  e_widget_entry_text_set(cfdata->gui.o_params, cfdata->params);
-	                       }
-                         }
-			else
-  			 {
-			       e_widget_entry_clear(cfdata->gui.o_params);
-	  		       e_widget_disabled_set(cfdata->gui.o_params, 1);
+		       if (cfdata->params[0])
+			 {
+			    int j, g = -1;
+			    _find_key_binding_action("exec", NULL, &g, NULL, &j);
+			    if (j >= 0)
+			      {
+				 e_widget_ilist_unselect(cfdata->gui.o_action_list);
+				 e_widget_ilist_selected_set(cfdata->gui.o_action_list, (j + g + 1));
+				 e_widget_entry_clear(cfdata->gui.o_params);
+				 e_widget_entry_text_set(cfdata->gui.o_params, cfdata->params);
+			      }
+			 }
+		       else
+			 {
+			    e_widget_entry_clear(cfdata->gui.o_params);
+			    e_widget_disabled_set(cfdata->gui.o_params, 1);
 			 }
 		    }
 		  else
@@ -1138,7 +1143,7 @@
 			     " is already used by
"
 			     "<hilight>%s</hilight> action.
"
 			     "Please choose another binding key sequence."),
-			     label ? label : _("Unknown"));
+			   label ? label : _("Unknown"));
 		  e_util_dialog_show(_("Binding Key Error"), buf);
 	       }
 	     _grab_wnd_hide(cfdata);


Updates ...

Updates ...

--- ptta-topic-namehandler.c
+++ ptta-topic-namehandler.c
@@ -8,7 +8,7 @@
 struct topic_name_hanler_data* topic_namehandler_init(){

 	struct topic_name_hanler_data* handler_data = (struct topic_name_hanler_data*)malloc(sizeof(struct topic_name_hanler_data));
-	int status = regcomp (handler_data->r, REGEX_TEXT, REG_EXTENDED|REG_NEWLINE);
+	int status = regcomp (&handler_data->r, REGEX_TEXT, REG_EXTENDED|REG_NEWLINE);
     if (status != 0) {
 		char error_message[MAX_ERROR_MSG];
 		regerror (status, handler_data->r, error_message, MAX_ERROR_MSG);


* Properly remove attachments from attachments container

pmo-trunk-r7491

--- src/widgets/modest-attachments-view.c
+++ src/widgets/modest-attachments-view.c
@@ -247,16 +247,17 @@
 			next_widget = node->next->data;

 		g_list_free (box_children);
+		gtk_widget_destroy (GTK_WIDGET (found_att_view));

 		node = g_list_find (priv->selected, found_att_view);
 		if (node != NULL) {
 			priv->selected = g_list_delete_link (priv->selected, node);
-			gtk_widget_destroy (GTK_WIDGET (found_att_view));
 			if ((priv->selected == NULL) && (next_widget != NULL))
 				set_selected (MODEST_ATTACHMENTS_VIEW (atts_view),
 					      MODEST_ATTACHMENT_VIEW (next_widget));
 		}
 		own_clipboard (atts_view);
+
 	}

 	gtk_widget_queue_resize (GTK_WIDGET (atts_view));


method rename

method rename

--- ext/php_phux.c
+++ ext/php_phux.c
@@ -512,12 +512,11 @@
         RETURN_FALSE;
     }

-    zval *z_route2;
-    z_route2 = php_phux_match(z_routes, path, path_len);
-
-    if ( z_route2 != NULL ) {
-        *return_value = *z_route2;
-        zval_copy_ctor(z_route2);
+    zval *z_route;
+    z_route = php_phux_match(z_routes, path, path_len);
+    if ( z_route != NULL ) {
+        *return_value = *z_route;
+        zval_copy_ctor(z_route);
         return;
     }
     RETURN_NULL();


Scripting: Use return with lua_error so static analysis gets less confused

--- src/script/engines/lua.c
+++ src/script/engines/lua.c
@@ -709,20 +709,20 @@
 		mScriptContextDrainPool(luaContext->d.context);
 		mScriptFrameDeinit(&frame);
 		luaL_traceback(lua, lua, "Error calling function (translating arguments into runtime)", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}

 	struct mScriptValue* fn = lua_touserdata(lua, lua_upvalueindex(1));
 	if (!fn || !mScriptInvoke(fn, &frame)) {
 		mScriptFrameDeinit(&frame);
 		luaL_traceback(lua, lua, "Error calling function (invoking failed)", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}

 	if (!_luaPushFrame(luaContext, &frame.returnValues, true)) {
 		mScriptFrameDeinit(&frame);
 		luaL_traceback(lua, lua, "Error calling function (translating return values from runtime)", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}
 	mScriptContextDrainPool(luaContext->d.context);
 	mScriptFrameDeinit(&frame);
@@ -740,7 +740,7 @@
 	if (!keyPtr) {
 		lua_pop(lua, 2);
 		luaL_traceback(lua, lua, "Invalid key", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}
 	strlcpy(key, keyPtr, sizeof(key));
 	lua_pop(lua, 2);
@@ -748,19 +748,19 @@
 	obj = mScriptContextAccessWeakref(luaContext->d.context, obj);
 	if (!obj) {
 		luaL_traceback(lua, lua, "Invalid object", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}

 	if (!mScriptObjectGet(obj, key, &val)) {
 		char error[MAX_KEY_SIZE + 16];
 		snprintf(error, sizeof(error), "Invalid key '%s'", key);
 		luaL_traceback(lua, lua, "Invalid key", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}

 	if (!_luaWrap(luaContext, &val)) {
 		luaL_traceback(lua, lua, "Error translating value from runtime", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}
 	return 1;
 }
@@ -775,7 +775,7 @@
 	if (!keyPtr) {
 		lua_pop(lua, 2);
 		luaL_traceback(lua, lua, "Invalid key", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}
 	strlcpy(key, keyPtr, sizeof(key));
 	lua_pop(lua, 2);
@@ -783,12 +783,12 @@
 	obj = mScriptContextAccessWeakref(luaContext->d.context, obj);
 	if (!obj) {
 		luaL_traceback(lua, lua, "Invalid object", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}

 	if (!val) {
 		luaL_traceback(lua, lua, "Error translating value to runtime", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}

 	if (!mScriptObjectSet(obj, key, val)) {
@@ -796,7 +796,7 @@
 		char error[MAX_KEY_SIZE + 16];
 		snprintf(error, sizeof(error), "Invalid key '%s'", key);
 		luaL_traceback(lua, lua, "Invalid key", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}
 	mScriptValueDeref(val);
 	mScriptContextDrainPool(luaContext->d.context);
@@ -839,7 +839,7 @@
 	obj = mScriptContextAccessWeakref(luaContext->d.context, obj);
 	if (!obj) {
 		luaL_traceback(lua, lua, "Invalid table", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}

 	struct mScriptValue keyVal;
@@ -858,7 +858,7 @@

 	if (!_luaWrap(luaContext, val)) {
 		luaL_traceback(lua, lua, "Error translating value from runtime", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}
 	return 1;
 }
@@ -871,14 +871,14 @@
 	obj = mScriptContextAccessWeakref(luaContext->d.context, obj);
 	if (!obj) {
 		luaL_traceback(lua, lua, "Invalid table", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}

 	struct mScriptValue val = mSCRIPT_MAKE_U64(mScriptTableSize(obj));

 	if (!_luaWrap(luaContext, &val)) {
 		luaL_traceback(lua, lua, "Error translating value from runtime", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}
 	return 1;
 }
@@ -907,7 +907,7 @@
 	table = mScriptContextAccessWeakref(luaContext->d.context, table);
 	if (!table) {
 		luaL_traceback(lua, lua, "Invalid table", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}

 	struct TableIterator iter;
@@ -926,12 +926,12 @@

 	if (!_luaWrap(luaContext, mScriptTableIteratorGetKey(table, &iter))) {
 		luaL_traceback(lua, lua, "Iteration error", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}

 	if (!_luaWrap(luaContext, mScriptTableIteratorGetValue(table, &iter))) {
 		luaL_traceback(lua, lua, "Iteration error", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}

 	return 2;
@@ -961,14 +961,14 @@
 	}
 	if (!obj || obj->type != mSCRIPT_TYPE_MS_LIST) {
 		luaL_traceback(lua, lua, "Invalid list", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}
 	struct mScriptList* list = obj->value.list;

 	// Lua indexes from 1
 	if (index < 1) {
 		luaL_traceback(lua, lua, "Invalid index", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}
 	if ((size_t) index > mScriptListSize(list)) {
 		return 0;
@@ -978,7 +978,7 @@
 	struct mScriptValue* val = mScriptListGetPointer(list, index);
 	if (!_luaWrap(luaContext, val)) {
 		luaL_traceback(lua, lua, "Error translating value from runtime", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}
 	return 1;
 }
@@ -994,7 +994,7 @@
 	}
 	if (!obj || obj->type != mSCRIPT_TYPE_MS_LIST) {
 		luaL_traceback(lua, lua, "Invalid list", 1);
-		lua_error(lua);
+		return lua_error(lua);
 	}
 	struct mScriptList* list = obj->value.list;
 	lua_pushinteger(lua, mScriptListSize(list));
@@ -1059,7 +1059,7 @@
 	free(oldpath);
 	free(oldcpath);
 	if (ret) {
-		lua_error(luaContext->lua);
+		return lua_error(luaContext->lua);
 	}

 	int newtop = lua_gettop(luaContext->lua);


crypto: Re-enable aes_ctr for openssl cryptolib < 1.0.1

It was accidently disabled in the crypto:supports/0 and /1. It
worked however in the encrypt/decrypt functions.

--- lib/crypto/c_src/cipher.c
+++ lib/crypto/c_src/cipher.c
@@ -334,6 +334,7 @@
             continue;

         if ((p->cipher.p != NULL) ||
+            (p->flags & AES_CTR_COMPAT) ||
             (p->type.atom == atom_aes_ige256))  /* Special handling. Bad indeed... */
             {
                 hd = enif_make_list_cell(env, p->type.atom, hd);


crypto: algo_ciper was too small after cipher additions

--- lib/crypto/c_src/crypto.c
+++ lib/crypto/c_src/crypto.c
@@ -920,7 +920,7 @@
 static int algo_pubkey_cnt, algo_pubkey_fips_cnt;
 static ERL_NIF_TERM algo_pubkey[7]; /* increase when extending the list */
 static int algo_cipher_cnt, algo_cipher_fips_cnt;
-static ERL_NIF_TERM algo_cipher[23]; /* increase when extending the list */
+static ERL_NIF_TERM algo_cipher[24]; /* increase when extending the list */

 static void init_algorithms_types(ErlNifEnv* env)
 {


client: updated against Yield

client: updated against Yield

git-svn-id: 4a24f560d5bb049edaa12cbc2145b2f5ee41c6a2@923 f8528748-c2c0-11dd-ba5c-d3b7c2b3b534

--- src/client/share/yieldfs/share/yield/include/yield.h
+++ src/client/share/yieldfs/share/yield/include/yield.h
@@ -1,8 +1,8 @@
 // Copyright 2003-2008 Minor Gordon, with original implementations and ideas contributed by Felix Hupfeld.
 // This source comes from the Yield project. It is licensed under the GPLv2 (see COPYING for terms and conditions).

-#ifndef _YIELD_H
-#define _YIELD_H
+#ifndef _YIELD_H_
+#define _YIELD_H_

 #include "yield/concurrency.h"
 #include "yield/ipc.h"


updated mic.c with peaktopeak

updated mic.c with peaktopeak

--- C/mic.c
+++ C/mic.c
@@ -42,7 +42,7 @@
 				signalMin = sample;  // save just the min levels
 			}
 		}// sample
-		if(now>(prevSample+300000)){
+		if(now>(prevAverage+300000)){
 			peakToPeak = 0;
 			peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude
 			printf("%d\n",peakToPeak);


TpPresenceMixin: don't shadow time()

TpPresenceMixin: don't shadow time()

20080221115354-53eee-4ab0071be0d31092ef62a0d6c15eed280cae8d53.gz

--- telepathy-glib/presence-mixin.c
+++ telepathy-glib/presence-mixin.c
@@ -596,7 +596,7 @@
  */
 static void
 tp_presence_mixin_set_last_activity_time (TpSvcConnectionInterfacePresence *iface,
-                                          guint time,
+                                          guint timestamp,
                                           DBusGMethodInvocation *context)
 {
   TpBaseConnection *conn = TP_BASE_CONNECTION (iface);


ldso: Fix Build warnings with common-generic ABI build

  CC ldso/ldso/ldso.oS
In file included from ./ldso/include/ldso.h:47,
                 from ldso/ldso/ldso.c:33:
./ldso/include/dl-syscall.h:35:1: warning: "S_ISUID" redefined
In file included from ./include/bits/kernel_stat.h:10,
                 from ./ldso/include/dl-syscall.h:31,
                 from ./ldso/include/ldso.h:47,
                 from ldso/ldso/ldso.c:33:
./include/sys/stat.h:163:1: warning: this is the location of the
previous definition
In file included from ./ldso/include/ldso.h:47,
                 from ldso/ldso/ldso.c:33:
./ldso/include/dl-syscall.h:36:1: warning: "S_ISGID" redefined
In file included from ./include/bits/kernel_stat.h:10,
                 from ./ldso/include/dl-syscall.h:31,
                 from ./ldso/include/ldso.h:47,
                 from ldso/ldso/ldso.c:33:
./include/sys/stat.h:164:1: warning: this is the location of the
previous definition

-----------------------------------------------------------------

Cleanly seperated the legacy ABI vs. new ABI scenario.

Signed-off-by: Vineet Gupta <af669d95a4c0de051445d4cafdbb2c5c4a2838be@synopsys.com>
Cc: Markos Chandras <5cdbcb0e11d2b5ebc39222958c54a1c6329d0c9d@imgtec.com>
Signed-off-by: Bernhard Reutner-Fischer <ce1ac9e9ad16abccd7821f371ad381197b4768ac@gmail.com>

--- ldso/include/dl-syscall.h
+++ ldso/include/dl-syscall.h
@@ -20,10 +20,12 @@
 /*  For MAP_ANONYMOUS -- differs between platforms */
 #define _SYS_MMAN_H 1
 #include <bits/mman.h>
+
+#ifdef __ARCH_HAS_DEPRECATED_SYSCALLS__
 /* Pull in whatever this particular arch's kernel thinks the kernel version of
  * struct stat should look like.  It turns out that each arch has a different
  * opinion on the subject, and different kernel revs use different names... */
-#if !defined __NR_stat || (defined(__sparc_v9__) && (__WORDSIZE == 64))
+#if defined(__sparc_v9__) && (__WORDSIZE == 64)
 #define kernel_stat64 stat
 #else
 #define kernel_stat stat
@@ -34,6 +36,13 @@
 /* Protection bits.  */
 #define	S_ISUID		04000	/* Set user ID on execution.  */
 #define	S_ISGID		02000	/* Set group ID on execution.  */
+
+#else
+/* 1. common-generic ABI doesn't need kernel_stat translation
+ * 3. S_IS?ID already provided by stat.h
+ */
+#include <sys/stat.h>
+#endif

 /* Here are the definitions for some syscalls that are used


when printing the view notify value, the traling semicolon and newline were missing

--- lib/dns/config/confview.c
+++ lib/dns/config/confview.c
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */

-/* $Id: confview.c,v 1.62 2000/12/01 23:27:42 marka Exp $ */
+/* $Id: confview.c,v 1.63 2000/12/06 20:37:01 gson Exp $ */

 #include <config.h>

@@ -617,6 +617,7 @@
 			fputs("no", fp);			\
 		else						\
 			fputs("explicit", fp);			\
+		fprintf(fp, ";\n");				\
 	}

 #define PRINT_AS_DIALUPTYPE(FIELD, NAME)			\


Before signing with a key, make sure that it's not the public-only part. A sane crypto toolkit would catch this and return an error, but openssl unceremoniously seg faults.

--- lib/dns/sec/dst/dst_api.c
+++ lib/dns/sec/dst/dst_api.c
@@ -19,7 +19,7 @@

 /*
  * Principal Author: Brian Wellington
- * $Id: dst_api.c,v 1.97 2001/11/30 01:59:29 gson Exp $
+ * $Id: dst_api.c,v 1.98 2001/11/30 02:11:04 bwelling Exp $
  */

 #include <config.h>
@@ -237,16 +237,22 @@

 isc_result_t
 dst_context_sign(dst_context_t *dctx, isc_buffer_t *sig) {
+	dst_key_t *key;
+
 	REQUIRE(VALID_CTX(dctx));
 	REQUIRE(sig != NULL);

-	CHECKALG(dctx->key->key_alg);
-	if (dctx->key->opaque == NULL)
+	key = dctx->key;
+	CHECKALG(key->key_alg);
+	if (key->opaque == NULL)
 		return (DST_R_NULLKEY);
-	if (dctx->key->func->sign == NULL)
+	if (key->func->sign == NULL)
 		return (DST_R_NOTPRIVATEKEY);
-
-	return (dctx->key->func->sign(dctx, sig));
+	if (key->func->isprivate == NULL ||
+	    key->func->isprivate(key) == ISC_FALSE)
+		return (DST_R_NOTPRIVATEKEY);
+
+	return (key->func->sign(dctx, sig));
 }

 isc_result_t


tweak

tweak

simplify iterator API

--- Cache.h
+++ Cache.h
@@ -71,8 +71,8 @@
         }

         // for iterating over keys
-        auto begin() -> typename Tracker::iterator const { return tracker_.begin(); }
-        auto end()   -> typename Tracker::iterator const { return tracker_.end();   }
+        iterator begin()  { return tracker_.begin(); }
+        iterator end()    { return tracker_.end();   }

         template<typename Action>
         void apply( Action&& action ) const


only include xmmintrin.h header if actually used

This otherwise prevents compilation on non x86 platforms (see #1514)

--- core/command.h
+++ core/command.h
@@ -17,7 +17,10 @@
 #define __command_h__

-#include <xmmintrin.h>
+#ifdef FLUSH_TO_ZERO
+# include <xmmintrin.h>
+#endif
+
 #include "app.h"
 #include "exec_version.h"
 #ifdef MRTRIX_PROJECT


Update PageInfo titles:

Update PageInfo titles:

Rework titles slightly to be less redundant.

--- src-qt5/gui_client/pages/getPage.h
+++ src-qt5/gui_client/pages/getPage.h
@@ -25,8 +25,8 @@
   // Valid Groups: ["appmgmt", "sysmgmt", "connect", "utils", "servermgmt"]
   QList<PAGEINFO> list;
   //Reminder: <ID>, <name>, <title>, <icon>, <comment>, <category>, <server subsytem list>
-  list << PageInfo("page_beadm", QObject::tr("Boot Environment Manager"), QObject::tr("Boot Environment Manager"),":/icons/black/disk.svg",QObject::tr("Manage operating system snapshots"),"sysmgmt",QStringList() << "sysadm/beadm");
-  list << PageInfo("page_taskmanager", QObject::tr("Task Manager"), QObject::tr("Task Manager"), ":/icons/black/flag.svg", QObject::tr("Monitor system tasks"), "sysmgmt", QStringList() << "sysadm/systemmanager");
+  list << PageInfo("page_beadm", QObject::tr("Boot Environments"), QObject::tr("Boot Environments"),":/icons/black/disk.svg",QObject::tr("Manage operating system snapshots"),"sysmgmt",QStringList() << "sysadm/beadm");
+  list << PageInfo("page_taskmanager", QObject::tr("Tasks"), QObject::tr("Tasks"), ":/icons/black/flag.svg", QObject::tr("Monitor system tasks"), "sysmgmt", QStringList() << "sysadm/systemmanager");
   list << PageInfo("page_iohyve",QObject::tr("iohyve"), QObject::tr("iohyve VM Manager"), ":/icons/black/desktop.svg", QObject::tr("Manage virtual OS instances"), "utils", QStringList() << "sysadm/iohyve" << "sysadm/network" << "sysadm/zfs");
   list << PageInfo("page_ssl_auth", QObject::tr("Manage SSL Keys"), QObject::tr("SSL Key Manager"), ":/icons/black/lock.svg",QObject::tr("List and Revoke SSL key registrations"), "servermgmt", QStringList() << "rpc/settings");
   list << PageInfo("page_about", QObject::tr("About TrueOS"), QObject::tr("About TrueOS"), ":/icons/black/magnifyingglass.svg",QObject::tr("More information on TrueOS"), "utils", QStringList() << "sysadm/about");
@@ -34,9 +34,9 @@
   list << PageInfo("page_system", QObject::tr("System Manager"), QObject::tr("System Manager"), ":/icons/black/boxfilled.svg",QObject::tr("Information About the System"), "utils", QStringList() << "sysadm/system");
   list << PageInfo("page_updates", QObject::tr("Update Manager"), QObject::tr("Update Manager"), ":/icons/black/sync.svg",QObject::tr("Perform Updates on the System"), "appmgmt", QStringList() << "sysadm/update");
   list << PageInfo("page_pkg", QObject::tr("AppCafe"), QObject::tr("AppCafe"), ":/icons/custom/appcafe.png",QObject::tr("Manage Applications/Packages"), "appmgmt", QStringList() << "sysadm/pkg");
-  list << PageInfo("page_users", QObject::tr("User Manager"), QObject::tr("User Manager"), ":/icons/black/user.svg",QObject::tr("Manage Users/Groups"), "sysmgmt", QStringList() << "sysadm/users");
-  list << PageInfo("page_services", QObject::tr("Service Manager"), QObject::tr("Service Manager"), ":/icons/black/pressure-reading.svg",QObject::tr("Manage Services"), "sysmgmt", QStringList() << "sysadm/services");
-  list << PageInfo("page_firewall", QObject::tr("Firewall Manager"), QObject::tr("Firewall Manager"), ":/icons/black/burn.svg",QObject::tr("Manage Firewall"), "sysmgmt", QStringList() << "sysadm/firewall");
+  list << PageInfo("page_users", QObject::tr("Users"), QObject::tr("Users"), ":/icons/black/user.svg",QObject::tr("Manage Users/Groups"), "sysmgmt", QStringList() << "sysadm/users");
+  list << PageInfo("page_services", QObject::tr("Services"), QObject::tr("Services"), ":/icons/black/pressure-reading.svg",QObject::tr("Manage Services"), "sysmgmt", QStringList() << "sysadm/services");
+  list << PageInfo("page_firewall", QObject::tr("Firewall"), QObject::tr("Firewall"), ":/icons/black/burn.svg",QObject::tr("Manage Firewall"), "sysmgmt", QStringList() << "sysadm/firewall");
   list << PageInfo("page_moused", QObject::tr("Mouse Settings"), QObject::tr("Mouse Settings"), ":/icons/black/mouse.svg",QObject::tr("Manage pointer device configuration"), "sysmgmt", QStringList() << "sysadm/moused");
 	return list;
 }


Fixed "large-directories" bug: globus_ftp_client_register_read() call.

--- gass/sync/library/source/globus_i_url_sync_list.c
+++ gass/sync/library/source/globus_i_url_sync_list.c
@@ -416,8 +416,12 @@
     }

     /* Register read operation */
-    result = globus_ftp_client_register_read(list_arg->ftp_handle, buffer, length,
-            globus_l_url_sync_list_ftp_read_cb, user_arg);
+	result = globus_ftp_client_register_read(
+             list_arg->ftp_handle,
+             list_arg->buffer,
+             list_arg->buffer_length,
+             globus_l_url_sync_list_ftp_read_cb,
+             list_arg);

     /* Report error and abort, if failed */
     if(result != GLOBUS_SUCCESS)


Use strlcpy() in !localized case to avoid the -1's.

--- lib/libc/string/strxfrm.c
+++ lib/libc/string/strxfrm.c
@@ -51,8 +51,7 @@
 			if (slen < len)
 				strcpy(dest, src);
 			else {
-				strncpy(dest, src, len - 1);
-				dest[len - 1] = '\0';
+				strlcpy(dest, src, len);
 			}
 		}
 		return slen;


pkg: u8g2: adapt to new I2C api.

pkg: u8g2: adapt to new I2C api.

--- pkg/u8g2/src/csrc/u8g2_riotos.c
+++ pkg/u8g2/src/csrc/u8g2_riotos.c
@@ -162,7 +162,6 @@
             index += arg_int;
             break;
         case U8X8_MSG_BYTE_INIT:
-            i2c_init_master(dev, I2C_SPEED_FAST);
             break;
         case U8X8_MSG_BYTE_SET_DC:
             break;
@@ -171,7 +170,7 @@
             index = 0;
             break;
         case U8X8_MSG_BYTE_END_TRANSFER:
-            i2c_write_bytes(dev, u8x8_GetI2CAddress(u8g2), buffer, index);
+            i2c_write_bytes(dev, u8x8_GetI2CAddress(u8g2), buffer, index, 0);
             i2c_release(dev);
             break;
         default:


UPDATED: make sure to unpack float to doubles in msgpack serializer

--- src/serializer/msgpack.c
+++ src/serializer/msgpack.c
@@ -261,6 +261,7 @@
 	case mpack_type_bool:
 		return (rpc_bool_create(mpack_node_bool(node)));

+	case mpack_type_float:
 	case mpack_type_double:
 		return (rpc_double_create(mpack_node_double(node)));


fixed wrong cast

fixed wrong cast

--- lib/BasicsC/locks-posix.c
+++ lib/BasicsC/locks-posix.c
@@ -576,7 +576,7 @@

 bool TRI_CompareAndSwapIntegerUInt32 (volatile uint32_t* theValue, uint32_t oldValue, uint32_t newValue) {
   #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
-    return OSAtomicCompareAndSwap32((volatile int32_t*)(oldValue), (int32_t)(newValue), (int32_t)(theValue));
+    return OSAtomicCompareAndSwap32((int32_t)(oldValue), (int32_t)(newValue), (volatile int32_t*)(theValue));
   #elif (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
     return __sync_val_compare_and_swap(theValue, oldValue, newValue);
   #else
@@ -600,7 +600,7 @@

 bool TRI_CompareAndSwapIntegerUInt64 (volatile uint64_t* theValue, uint64_t oldValue, uint64_t newValue) {
   #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
-    return OSAtomicCompareAndSwap64((volatile int64_t*)(oldValue), (int64_t)(newValue), (int64_t)(theValue));
+    return OSAtomicCompareAndSwap64((int64_t)(oldValue), (int64_t)(newValue), (volatile int64_t*)(theValue));
   #elif (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100
     return __sync_val_compare_and_swap(theValue, oldValue, newValue);
   #else


Add comment suggesting the use of the new GetDataDependencyFilepath function.

PiperOrigin-RevId: 295048585
Change-Id: I88b5b87a73b4e71c0d3cbe0a0f455459f6719be6

--- tensorflow/core/platform/test.h
+++ tensorflow/core/platform/test.h
@@ -38,6 +38,11 @@

 // Returns the path to TensorFlow in the directory containing data
 // dependencies.
+//
+// A better alternative would be making use if
+// tensorflow/core/platform/resource_loader.h:GetDataDependencyFilepath. That
+// function should do the right thing both within and outside of tests allowing
+// avoiding test specific APIs.
 string TensorFlowSrcRoot();

 // Return a random number generator seed to use in randomized tests.


Use INT_MIN instead of -1 as sentinel in max_va()

--- fcgiwrap.c
+++ fcgiwrap.c
@@ -10,6 +10,7 @@
 #include <errno.h>
 #include <string.h>
 #include <sys/stat.h>
+#include <limits.h>

 #define FCGI_BUF_SIZE 4096

@@ -28,6 +29,8 @@
 	return size;
 }

+#define MAX_VA_SENTINEL INT_MIN
+
 static int max_va(int p1, ...)
 {
 	va_list va;
@@ -39,7 +42,7 @@
 		p = va_arg(va, int);
 		if (p > max)
 			max = p;
-	} while (p >= 0);
+	} while (p != MAX_VA_SENTINEL);
 	va_end(va);

 	return max;
@@ -92,7 +95,7 @@
 	char buf[FCGI_BUF_SIZE];
 	ssize_t nread;
 	fd_set rset;
-	int maxfd = max_va(fc->fd_stdout, fc->fd_stderr, -1);
+	int maxfd = max_va(fc->fd_stdout, fc->fd_stderr, MAX_VA_SENTINEL);
 	int nready;
 	const char *err;


SockDelegate::extractConn is no longer required to accept a NULL argument

--- core/EmiSock.h
+++ core/EmiSock.h
@@ -239,9 +239,9 @@

         EmiConnectionKey ckey(address, inboundPort);
         typename EmiConnectionMap::iterator cur = _conns.find(ckey);
-        __block ConnectionHandle nativeConn = _conns.end() == cur ? nil : (*cur).second;
-
-        __block EC *conn = SockDelegate::extractConn(nativeConn);
+        ConnectionHandle nativeConn = _conns.end() == cur ? NULL : (*cur).second;
+
+        __block EC *conn = nativeConn ? SockDelegate::extractConn(nativeConn) : NULL;

         if (conn) conn->gotPacket();

@@ -292,16 +292,18 @@
                         conn = nil;
                     }

+                    ConnectionHandle openedNativeConn(nativeConn);
+
                     if (!conn) {
-                        nativeConn = _delegate.makeConnection(address, inboundPort, /*initiator:*/false);
-                        conn = SockDelegate::extractConn(nativeConn);
-                        _conns[ckey] = nativeConn;
+                        openedNativeConn = _delegate.makeConnection(address, inboundPort, /*initiator:*/false);
+                        conn = SockDelegate::extractConn(openedNativeConn);
+                        _conns[ckey] = openedNativeConn;
                     }

                     conn->gotTimestamp(now, data);

                     if (conn->open(now, header->sequenceNumber)) {
-                        _delegate.gotConnection(nativeConn);
+                        _delegate.gotConnection(openedNativeConn);
                     }
                 }
                 else if (synFlag && rstFlag) {


Hopefully portable and simple get-line.

Hopefully portable and simple get-line.

--- core/carp_io.h
+++ core/carp_io.h
@@ -14,63 +14,19 @@

 char IO_EOF = (char)EOF;

-#ifdef _WIN32
-// getline isn't a C standard library function so it's missing on windows
-// This implementation is stolen from StackOverflow, not sure if it's optimal...
-size_t getline(char **lineptr, size_t *n, FILE *stream) {
-    size_t pos;
-    int c;
-
-    if (lineptr == NULL || stream == NULL || n == NULL) {
-        errno = EINVAL;
-        return -1;
+String IO_get_MINUS_line() {
+    char *b = NULL;
+    size_t cap = 64;
+    size_t sofar = 0;
+    while (1) {
+        b = CARP_REALLOC(b, cap);
+        b[cap - 1] = -1;
+        if (!fgets(b + sofar, cap - sofar, stdin)) break;
+        sofar = cap - 1;
+        if (b[cap - 1] == -1) break;
+        cap *= 2;
     }
-
-    c = fgetc(stream);
-    if (c == EOF) {
-        return -1;
-    }
-
-    if (*lineptr == NULL) {
-        *lineptr = malloc(128);
-        if (*lineptr == NULL) {
-            return -1;
-        }
-        *n = 128;
-    }
-
-    pos = 0;
-    while (c != EOF) {
-        if (pos + 1 >= *n) {
-            size_t new_size = *n + (*n >> 2);
-            if (new_size < 128) {
-                new_size = 128;
-            }
-            char *new_ptr = CARP_REALLOC(*lineptr, new_size);
-            if (new_ptr == NULL) {
-                return -1;
-            }
-            *n = new_size;
-            *lineptr = new_ptr;
-        }
-
-        ((unsigned char *)(*lineptr))[pos++] = c;
-        if (c == '\n') {
-            break;
-        }
-        c = fgetc(stream);
-    }
-
-    (*lineptr)[pos] = '\0';
-    return pos;
-}
-#endif
-
-String IO_get_MINUS_line() {
-    size_t size = 1024;
-    String buffer = CARP_MALLOC(size);
-    getline(&buffer, &size, stdin);
-    return buffer;
+    return b;
 }

 String IO_read_MINUS_file(const String *filename) {


=class to perform rational reconstruction

error: pathspec 'linbox/linbox/algorithms/rational-reconstruction-base.h' did not match any file(s) known to git

--- linbox/linbox/algorithms/rational-reconstruction-base.h
+++ linbox/linbox/algorithms/rational-reconstruction-base.h
@@ -0,0 +1,1921 @@
+/* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <iostream>
+#include <queue>
+
+#ifndef __LINBOXX__RECONSTRUCTION_BASE_H__
+#define __LINBOXX__RECONSTRUCTION_BASE_H__
+
+//#define __FASTRR_DEFAULT_THRESHOLD 9223372036854775807 //2^63-1
+//#define __FASTRR_DEFAULT_THRESHOLD 2147483647 //2^31-1
+#define __FASTRR_DEFAULT_THRESHOLD 7
+//max int=2^32 4294967295
+//max int=2^64 18446744073709551616
+//__FASTRR_DEFAULT_THRESHOLD > 4
+
+using namespace std;
+
+namespace LinBox {
+
+template <class Ring, class RRBase>
+class RationalReconstruction
+{
+public:
+	Ring _Z;
+	RRBase _RR;
+
+	typedef typename Ring::Element Element;
+
+	RationalReconstruction(const Ring& Z):_Z(Z), _RR(Z) {}
+	RationalReconstruction(const RRBase& RR): _Z(RR._Z), _RR(RR) {}
+
+	bool reconstructRational(Element& a, Element& b, const Element& x, const Element& m) {
+
+		Element x_in(x);
+		if (x<0) {
+			if ((-x)>m)
+				x_in %= m;
+			if (x<0)
+				x_in += m;
+		} else {
+			if (x>m)
+				x_in %= m;
+		}
+		bool res= _RR.reconstructRational(a,b,x_in,m);
+		_RR.write(cout);
+		return res;
+	}
+
+	bool reconstructRational(Element& a, Element& b, const Element& x, const Element& m, const Element& a_bound) {
+
+		Element x_in(x);
+		if (x<0) {
+			if ((-x)>m)
+				x_in %= m;
+			if (x<0)
+				x_in += m;
+		} else {
+			if (x>m)
+				x_in %= m;
+		}
+		bool res= _RR.reconstructRational(a,b,x_in,m,a_bound);
+		_RR.write(cout);
+		return res;
+	}
+
+	bool reconstructRational(Element& a, Element& b, const Element& x, const Element& m, const Element& a_bound, const Element& b_bound) {
+		Element x_in(x);
+		if (x<0) {
+			if ((-x)>m)
+				x_in %= m;
+			if (x<0)
+				x_in += m;
+		} else {
+			if (x>m)
+				x_in %= m;
+		}
+		Element bound = x/b_bound;
+		_RR.reconstructRational(a,b,x,m,(bound>a_bound?bound:a_bound));
+		bool res=  (b > b_bound)? false: true;
+		_RR.write(cout);
+		return res;
+	}
+
+  //fastReconstruction();
+
+  //classicReconstruction();
+
+};
+
+class OpCounter {
+public:
+	size_t div_counter;
+	size_t mul_counter;
+	size_t gcd_counter;
+
+	OpCounter() {
+		div_counter=0; mul_counter=0; gcd_counter=0;
+	}
+
+	void write(ostream& is) {
+		is << div_counter << " divisions\n";
+		is << mul_counter << " multiplications\n";
+		is << gcd_counter << " gcds\n";
+	}
+};
+
+template <class Ring>
+class RationalReconstructionBase
+{
+public:
+	Ring _Z;
+	typedef typename Ring::Element Element;
+
+	OpCounter C;
+
+	RationalReconstructionBase(const Ring& Z): _Z(Z) {}
+	RationalReconstructionBase(const RationalReconstructionBase<Ring>& RR): _Z(RR._Z) {}
+
+	virtual bool reconstructRational(Element& a, Element& b, const Element& x, const Element& m)=0;
+
+	virtual bool reconstructRational(Element& a, Element& b, const Element& x, const Element& m, const Element& a_bound)=0;
+
+	virtual ~RationalReconstructionBase() {}
+
+	void write(ostream& is) {
+		C.write(is);
+	}
+};
+/*
+template <class Ring>
+class WangRationalReconstruction: public RationalReconstructionBase<Ring>
+{
+protected:
+	bool _reduce;
+	bool _recursive;
+public:
+	Ring _Z;
+	typedef typename Ring::Element Element;
+
+	OpCounter C;
+
+	WangRationalReconstruction(const Ring& Z, const bool reduce = true, const bool recursive = false): RationalReconstructionBase<Ring>(Z) {
+		_reduce = reduce; _recursive = recursive;
+	}
+
+	WangRationalReconstruction<Ring> (const WangClassicRationalReconstruction<Ring>& RR): RationalReconstructionBase<Ring>(RR._Z) {
+		_reduce = RR._reduce; _recursive = RR._recursive;
+	}
+
+	bool reconstructRational(Element& a, Element& b, const Element& x, const Element& m)=0 {
+		Element a_bound; _Z.sqrt(a_bound, m/2);
+		bool res = rationalReconstruction(a,b,x,m,a_bound);
+		res = res && (b <= a_bound);
+		return res;
+	}
+
+	bool reconstructRational(Element& a, Element& b, const Element& x, const Element& m, const Element& a_bound) {
+		bool res;
+
+		if (x == 0) {
+		    a = 0;
+		    b = 1;
+		} else {
+			bool res = ratrecon(a,b,x,m,a_bound);
+			if (_recursive)
+			for(Element newbound = a_bound + 1; (!res) && (newbound<x) ; ++newbound)
+			    res = ratrecon(a,b,x,m,newbound);
+		}
+		if (!res) {
+			a = x> m/2? x-m: x;
+			b = 1;
+			if (a > 0) res = (a < a_bound);
+			else res = (-a < a_bound);
+		}
+
+		return res;
+	}
+
+	virtual ~WangRationalReconstruction() {}
+protected:
+
+// m> x> 0
+	bool ratrecon(Element& a,Element& b,const Element& x,const Element& m,const Element& a_bound) {
+
+		Element  r0, t0, q, u;
+		r0=m;
+		t0=0;
+		a=x;
+		b=1;
+		//Element s0,s; s0=1,s=0;//test time gcdex;
+		while(a>=a_bound)
+		{
+
+		    q = r0;
+		    _Z.divin(q,a);        // r0/num
+++C.div_counter;
+
+		    u = a;
+		    a = r0;
+		    r0 = u;	// r0 <-- num
+
+		    _Z.axmyin(a,u,q); // num <-- r0-q*num
+++C.mul_counter;
+		    //if (a == 0) return false;
+
+		    u = b;
+		    b = t0;
+		    t0 = u;	// t0 <-- den
+
+		    _Z.axmyin(b,u,q); // den <-- t0-q*den
+++C.mul_counter;
+		}
+
+//                        if (den < 0) {
+//                                _Z.negin(num);
+//                                _Z.negin(den);
+//                        }
+
+		if ((a>0) && (_reduce)) {
+
+			// [GG, MCA, 1999] Theorem 5.26
+			// (ii)
+		    Element gg;
+++C.gcd_counter;
+		    if (_Z.gcd(gg,a,b) != 1) {
+
+			Element ganum, gar2;
+			for( q = 1, ganum = r0-a, gar2 = r0 ; (ganum >= a_bound) || (gar2<a_bound); ++q ) {
+			    ganum -= a;
+			    gar2 -= a;
+			}
+
+			//_Z.axmyin(r0,q,a);
+			r0 = ganum;
+			_Z.axmyin(t0,q,b);
+++C.mul_counter;++C.mul_counter;
+			if (t0 < 0) {
+			    a = -r0;
+			    b = -t0;
+			} else {
+			    a = r0;
+			    b = t0;
+			}
+
+//                                if (t0 > m/k) {
+			if ((double)b > (double)m/(double)a_bound) {
+				if (!_recursive) {
+					std::cerr
+						<< "*** Error *** No rational reconstruction of "
+						<< x
+						<< " modulo "
+						<< m
+						<< " with denominator <= "
+						<< (m/a_bound)
+						<< std::endl;
+				}
+				return false;
+			}
+			if (_Z.gcd(gg,a,b) != 1) {
+			    if (!_recursive)
+				std::cerr
+				    << "*** Error *** There exists no rational reconstruction of "
+				    << x
+				    << " modulo "
+				    << m
+				    << " with |numerator| < "
+				    << a_bound
+				    << std::endl
+				    << "*** Error *** But "
+				    << a
+				    << " = "
+				    << b
+				    << " * "
+				    << x
+				    << " modulo "
+				    << m
+				    << std::endl;
+			    return false;
+			}
+		    }
+		}
+	       // (i)
+	       if (b < 0) {
+		       _Z.negin(a);
+		       _Z.negin(b);
+	       }
+
+// std::cerr << "RatRecon End " << num << "/" << den << std::endl;
+		return true;
+	}
+};
+*/
+template <class Ring>
+class QMatrix {
+public:
+	Ring _Z;
+	typedef typename Ring::Element Element;
+
+	Element a,b,c,d;
+	Element q;
+
+	QMatrix(const Ring Z): _Z(Z) {
+		a=1;b=0;c=0;d=1;q=0;
+	}
+
+	QMatrix(const QMatrix& Q): _Z(Q._Z) {
+		a = Q.a;
+		b = Q.b;
+		c = Q.c;
+		d = Q.d;
+		q = Q.q;
+	}
+
+	QMatrix(Ring Z,const Element& ai, const Element& bi, const Element& ci, const Element& di, const Element& qi=0): _Z(Z) {
+		a = ai;
+		b = bi;
+		c = ci;
+		d = di;
+		q = qi;
+	}
+
+	QMatrix& operator=(const QMatrix& Q) {
+		a = Q.a;
+		b = Q.b;
+		c = Q.c;
+		d = Q.d;
+		q = Q.q;
+		return *this;
+	}
+
+	void leftmultiply(const QMatrix Q) {
+		leftmultiply(Q.a,Q.b, Q.c,Q.d);
+	}
+
+	void leftmultiply(const Element& ai,const Element& bi,const Element& ci,const Element& di) {
+		Element tmpa,tmpb,tmpc,tmpd;
+		_Z.mul(tmpa,ai,a);
+		_Z.axpyin(tmpa,bi,c);
+
+		_Z.mul(tmpb,ai,b);
+		_Z.axpyin(tmpb,bi,d);
+
+		_Z.mul(tmpc,ci,a);
+		_Z.axpyin(tmpc,di,c);
+
+		_Z.mul(tmpd,ci,b);
+		_Z.axpyin(tmpd,di,d);
+
+		a = tmpa; b = tmpb; c = tmpc; d = tmpd;
+	}
+
+	QMatrix& max(const QMatrix& max1, const QMatrix max2) {
+		if (max1.q >= max2.q) return QMatrix(max1);
+		else return QMatrix(max2);
+	}
+
+	bool maxin(const QMatrix max2) {
+		if (q >= max2.q) return true;
+		else {
+			a = max2.a;
+			b = max2.b;
+			c = max2.c;
+			d = max2.d;
+			q = max2.q;
+			return false;
+		}
+	}
+};
+
+template <class Ring>
+class myQueue: public deque<QMatrix<Ring > > {
+public:
+	typedef typename Ring::Element Element;
+	typedef QMatrix<Ring> QMatrix;
+
+	size_t _maxSize;
+	size_t _size;
+
+	myQueue(const size_t K=0) {
+		_maxSize = K;
+		_size = 0;
+	}
+
+	bool pushpop(QMatrix& top, const QMatrix& bottom) {
+		if (_size+1 < _maxSize) {
+			push_back(bottom);
+			return false;
+			++_size;
+		} else {
+			if (!empty()) {
+				top = front();
+				pop_front();
+				push_back(bottom);
+
+			} else {
+				top=bottom;
+			}
+			return true;
+		}
+	}
+
+	QMatrix& clearmax(QMatrix& max1) {
+		while (!empty()) {
+			QMatrix max2(front());
+			if (max2.q > max1.q) return max1=max2;
+			pop_front();
+		}
+	}
+};
+
+template <class Ring>
+class MaxQFastRationalReconstruction: public RationalReconstructionBase<Ring>
+{
+protected:
+	size_t _threshold;
+
+typedef typename Ring::Element Element;
+public:
+
+	MaxQFastRationalReconstruction(const Ring& Z): RationalReconstructionBase<Ring>(Z) {
+		_threshold = __FASTRR_DEFAULT_THRESHOLD;
+		if (_threshold <5) _threshold=5;
+	}
+
+	~MaxQFastRationalReconstruction() {}
+
+	bool reconstructRational(Element& a, Element& b, const Element& x, const Element& m) {
+		//reconstructRational(a,b,x,m,1);
+		return fastQMaxReconstructRational(a,b,x,m);
+	}
+
+	bool reconstructRational(Element& a, Element& b, const Element& x, const Element& m, const Element& a_bound) {
+		bool res = reconstructRational(a,b,x,m);
+		return res && (a < a_bound);
+	}
+
+protected:
+
+	Element cur_ri;
+	Element cur_rinext;
+	Element cur_ainext;
+	Element cur_qinext;
+
+	//QMatrix max;
+
+	Element& powtwo(Element& h, const Element& log_h) {
+		h = 1;
+		//cout << "max" << ULONG_MAX << "x" << x << "?" << (x < ULONG_MAX);
+		if (log_h < ULONG_MAX) {
+			h<<=log_h;
+			//cout << "z"<< z;
+			return h;
+		} else {
+			Element n,m;
+			quoRem(n,m,log_h,(Element)(ULONG_MAX-1));
+			for (int i=0; i < n; ++i) {
+				h <<=(long int)(ULONG_MAX-1);
+			}
+			h <= (long int)m;
+			return h;
+		}
+	}
+
+	Element& powtwo(Element& h, const size_t log_h) {
+		h = 1;
+		h<<=log_h;
+		return h;
+	}
+
+	bool fastQMaxReconstructRational(Element& n, Element& d, const Element& x, const Element& m) {
+
+		size_t log_m = m.bitsize()-1; //true unless m = 2^k
+
+		Element ai, bi, ci, di;
+		ai=1;bi=0;ci=0;di=1;
+
+		cur_ri = m;
+		cur_rinext = x;
+		_Z.quo(cur_ainext, cur_ri, cur_rinext);
+		cur_qinext = cur_ainext;//  ri/ri_next
+
+		Element powh;
+		myQueue<Ring > queueMax(0);
+		QMatrix<Ring > maxQ(_Z);
+
+		if (!fastQMaxEEA (ai,bi,ci,di,m,log_m,x,powtwo(powh,log_m+1), log_m+1,queueMax,maxQ)) {
+			cout << "false\n" << flush;
+			return false;
+		}
+
+		if (cur_rinext != 0) {
+			cout << "bad bounds - should not happen\n" << flush;
+		}
+
+		if (!queueMax.empty()) {
+			cout << "Queue is empty\n - sth wrong" << flush;
+		}
+
+		_Z.mul(n,x, maxQ.a);
+		_Z.axmyin(n,m,maxQ.c);
+		//n = x_in*ai-m*ci;
+		d = maxQ.a;
+
+/*
+		_Z.mul(n, maxQ.d, m);
+		_Z.axmyin(n, maxQ.b, n);
+		d = maxQ.b;
+*/
+		Element _gcd;
+		if (_Z.gcd(_gcd, n,d) > 1) {
+		/* solution not implemented */
+			cout << "Solution pair is not coprime\n";
+			return false;
+		}
+
+		return true;
+	}
+
+	bool classicQMaxEEA(Element& ai, Element& bi, Element& ci, Element& di, const Element& r0, const Element& r1,const Element& powh, myQueue<Ring >&  queueMax, QMatrix<Ring>& maxQ) {
+		Element ri, rinext;
+		ri = r0; rinext = r1;
+		ai =di = 1;
+		bi =ci = 0;
+		if (rinext==0) return true;
+		Element ainext,cinext;
+		Element qinext;
+		_Z.quo(qinext,ri,rinext);
+++C.div_counter;
+
+		ainext =qinext;
+		//_Z.axpy(ainext, ai,qinext,bi);
+		while (ainext <= powh) {
+
+			//_Z.quo(qinext,ri,rinext);
+++C.div_counter;
+                        QMatrix<Ring> newQ(_Z,ai,bi,ci,di,qinext);
+                        QMatrix<Ring> top(_Z);
+                        if (queueMax.pushpop(top, newQ)) {
+				cout << "1new max " << top.q << "\n" << flush;
+                                if (maxQ.q < top.q) maxQ = top;
+                        }
+			cout << "EEA" << qinext << ",";
+			//++i;
+			//ainext = ai*qinext + bi;
+			//_Z.axpy(ainext, ai,qinext,bi);
+++C.mul_counter;
+
+                        Element tmpbi = bi;
+			Element tmpdi = di;
+			bi = ai;
+			ai = ainext;
+			Element temp = ci;
+			_Z.axpy(ci, temp,qinext,di);
+++C.mul_counter;
+			di = temp;
+
+			temp = ri;
+			ri=rinext;
+			_Z.axpy(rinext, -qinext,ri,temp);//rinext = ri-qinext*rinext
+
+++C.mul_counter;
+			if (rinext==0) {
+				//ainext = infinity
+			        cur_ri = ri;
+			        cur_rinext = rinext;
+			        cur_ainext = r0+1;
+				cur_qinext = cur_ainext;//infinity
+				cout << "->1E:" << cur_ri << " " << cur_rinext <<" " <<  cur_ainext << "\n"<< flush;
+				return true;
+			}
+
+			_Z.quo(qinext,ri,rinext);
+++C.div_counter;
+			_Z.axpy(ainext, ai,qinext,bi);
+
+		}
+		cur_ri = ri;
+		cur_rinext = rinext;
+		cur_ainext = ainext;
+		cur_qinext = qinext;
+		cout << "->2E:" << cur_ri << " " << cur_rinext <<" " <<  cur_ainext << "\n"<< flush;
+		return true;
+	}
+
+	bool fastQMaxEEA(Element& ai,Element& bi, Element& ci, Element& di, const Element& m, const size_t d, const Element& n, const Element& powh, const size_t& h, myQueue<Ring >&  queueMax, QMatrix<Ring>& maxQ) {
+
+		cout << m << " " << n << " " << powh << "\n" << flush;
+
+		ai=Element(1);
+		di=Element(1);
+		bi=Element(0);
+		ci=Element(0); //Q(0)=Id
+
+		if (m==n) {
+			cur_ri = n;
+			cur_rinext = 0;
+			cur_ainext = m+1;//infinity
+			cur_qinext = m+1;
+			ai=1; bi=1; ci=1; di=0;
+			QMatrix<Ring> newQ(_Z,1,0,0,1,1);
+			//QMatrix<Ring> newQ(_Z,1,1,1,0,1);
+			QMatrix<Ring> top(_Z);
+			if (queueMax.pushpop(top, newQ)) {
+				cout << "2new max " << top.q << "\n"<< flush;
+				if (maxQ.q < top.q) maxQ = top;
+			}
+			cout << "m=n1" << ",";
+			return true;
+		}
+
+		if (powh < 1) return false; //should not happen
+		if (n < 2) {
+			cout << "n=1\n"<< flush;
+			                 //n==1 -> Q1=(m,1//1,0)
+		                         //n==0 -> Q1=infinity
+			cur_ri = m;
+			cur_rinext = 1;
+			cur_ainext = m;//infinity
+			cur_qinext = m;
+			if (cur_ainext > powh) {
+				//we do not have to treat identity;
+				return true;
+			}
+			else {
+				ai=m; bi=1; ci=1; di=0;
+				cur_ri = 1;
+				cur_rinext = 0;
+				cur_ainext = m+1;
+				cur_qinext = m+1;
+				QMatrix<Ring> newQ(_Z,1,0,0,1,m);
+				//QMatrix<Ring> newQ(_Z,m,1,1,0,m);
+				QMatrix<Ring> top(_Z);
+				if (queueMax.pushpop(top, newQ)) {
+				//	cout << "3new max " << top.q << "\n"<< flush;
+					if (maxQ.q < top.q) maxQ = top;
+				}
+				cout << "n=1" << m << ",";
+
+				return true;
+			}
+		        return true;
+		}
+
+		if (h < 1) {
+			cout << "h < 1" << flush;
+			//quo(qinext,m,n);
+			//if (qinext==1) { return (1,1,1,0) or (1,0,0,1)
+			if ((n << 1) > m) {
+				cur_ri = n;
+				cur_rinext = m-n;
+				_Z.quo(cur_qinext, cur_ri, cur_rinext);
+++C.div_counter;
+				cur_ainext = cur_qinext + 1;
+				ai=1; bi=1; ci=1; di=0;
+				QMatrix<Ring> newQ(_Z,1,0,0,1,1);
+				//QMatrix<Ring> newQ(_Z,1,1,1,0,1);
+				QMatrix<Ring> top(_Z);
+				if (queueMax.pushpop(top, newQ)) {
+					cout << "4new max " << top.q << "\n"<< flush;
+					if (maxQ.q < top.q) maxQ = top;
+				}
+				cout << "h=01" << ",";
+
+			} else {
+				//we do not have to treat identity;
+				cur_ri = m;
+				cur_rinext = n;
+				_Z.quo(cur_ainext,m,n);
+++C.div_counter;
+				cur_qinext = cur_ainext;
+			}
+			return true;
+		}
+
+		if (n < _threshold) {       //what about m?
+			return classicQMaxEEA(ai,bi,ci,di,m,n,powh,queueMax,maxQ);
+		}
+
+		size_t log_n = n.bitsize()-1;
+
+		//		cout << d << " " << log_n << " "  << h << "\n"<< flush;
+
+		if (2*h+1 < d) {
+			cout << "choice1"<< flush;
+			//if (2*h+1 <= log_n) {
+		  if (true) {
+			cout << ".1\n"<< flush;
+			size_t lambda = d-2*h-1;
+
+			Element aistar, bistar, cistar, distar;
+			aistar=distar=1;
+			bistar=cistar=0;
+
+			Element mstar = m >> (long unsigned int) lambda;
+			Element nstar = n >> (long unsigned int) lambda;
+
+			size_t log_mstar = 2*h+1;
+
+			queueMax._maxSize +=2;
+			if (nstar > 0) if (!fastQMaxEEA(aistar, bistar, cistar, distar, mstar, log_mstar,nstar, powh, h, queueMax, maxQ)) return false;
+
+			if (queueMax._size > 1) {
+				queueMax.pop_back();
+				QMatrix<Ring> Q_i_2 (queueMax.back());
+				queueMax.pop_back();//pop Q*(i-1) q*(i)
+				--queueMax._size ;
+				--queueMax._size ;
+                                ai = Q_i_2.a;
+                                bi = Q_i_2.b;
+                                ci = Q_i_2.c;
+                                di = Q_i_2.d;// Q(i-2)= Q*(i-2) q*(i-1)
+			}  else {
+				queueMax.clear();
+			}
+		       	queueMax._maxSize -=2;
+
+			_Z.mul(cur_ri,m,di);
+			_Z.axmyin(cur_ri,n,bi);
+			_Z.mul(cur_rinext,n,ai);
+			_Z.axmyin(cur_rinext,m,ci);
+C.mul_counter+=4;
+			//ri = m*di - n*bi;
+			//rinext = -m*ci + n*ai;
+
+			if (cur_ri < 0) {
+				cur_ri = -cur_ri;
+				cur_rinext = -cur_rinext;
+			}
+			if (cur_rinext>0) {
+				_Z.quo(cur_qinext,cur_ri,cur_rinext);
+++C.div_counter;
+				_Z.axpy(cur_ainext, ai,cur_qinext,bi);
+++C.mul_counter;
+			} else {//should never happen
+				cur_ainext = m+1;//infinity
+				cur_qinext = cur_ainext;
+			}
+
+			cout << "\n2 backward steps\n"<< flush;
+			cout << "->1:" << cur_ri << " " << cur_rinext <<" " <<  cur_ainext << "->\n"<< flush;
+
+		   }
+		} else if (h <= d-1) {
+			cout << "choice2\n"<< flush;
+			Element a1,a2,b1,b2,c1,c2,d1,d2;
+                        a1=a2=d1=d2=1;
+                        b1=b2=c1=c2=0;
+
+                        Element sqrth;
+			size_t logsqrth;
+                                //sqrt(sqrth,powh);
+                        logsqrth = h >> (int) 1;
+			powtwo(sqrth, logsqrth);
+                                //logtwo(logsqrth, sqrth);
+                                //_sqrth = h/2;
+
+                                //if (!EEA(sgn, ri, rinext, qinext, a1,b1,c1,d1,m,d,n,sqrth, logsqrth)) return 0;
+			if (!fastQMaxEEA(a1,b1,c1,d1,m,d,n,sqrth, logsqrth, queueMax, maxQ)) return 0;
+
+			ai = a1; bi = b1; ci=c1; di = d1;
+
+			Element ri = cur_ri;
+			Element rinext = cur_rinext;
+
+			size_t log_m;
+			//if (ri !=m) //logtwo(log_m,ri);
+
+			myQueue<Ring> queueTmp (queueMax._maxSize+2);
+			QMatrix<Ring> maxQTmp(_Z);
+			if ((rinext > 0) && (cur_ainext <= powh)){
+
+                                QMatrix<Ring> newQ(_Z,ai,bi,ci,di,cur_qinext);
+                                QMatrix<Ring> top(_Z);
+                                if (queueMax.pushpop(top, newQ)) {
+                                        cout << "6new max " << top.q << "\n";
+                                        if (maxQ.q < top.q) maxQ = top;
+                                }
+				cout << "2step1:" << cur_qinext << ",";
+
+
+				log_m = rinext.bitsize()-1;
+				Element m2, n2;
+				m2 = rinext;
+				_Z.axpy(n2, -cur_qinext, rinext, ri);
+++C.mul_counter;
+				/* compute Q(i+1) */
+				Element tmp = a1;
+				a1 = cur_ainext;
+				b1 = tmp;
+				tmp = c1;
+				_Z.axpy (tmp, cur_qinext, c1, d1);
+++C.mul_counter;
+				d1 = c1;
+				c1 = tmp;
+
+				//add matrix
+				//_Z.quo(cur_qinext, m2,n2);
+				//_Z.axpy(cur_ainext, cur_qinext, ai, bi); not needed
+
+				ai = a1; bi = b1; ci=c1; di = d1;
+
+				size_t k = a1.bitsize()-1 ;
+				if (n2 >0) {
+					if (a1 < powh) {
+						if (!fastQMaxEEA(a2,b2,c2,d2,m2,log_m,n2, powtwo(sqrth,h-k-1), h-k-1, queueTmp,maxQTmp)) return 0;
+					} else {
+						cur_ri = m2;
+						cur_rinext = n2;
+						_Z.quo(cur_qinext,m2,n2);
+++C.div_counter;
+						_Z.axpy(cur_ainext,a1,cur_qinext,b1);
+++C.mul_counter;
+						return 1;
+					}
+				} else {
+					cur_ri = m2;
+					cur_rinext = n2;
+					cur_qinext = m+1;
+					cur_ainext = m+1;
+					return 1;
+				}
+			} else {
+				//do not add matrix
+				ai = a1; bi = b1; ci=c1; di = d1;
+				cout << "End2\n"<< flush;
+				return 1;
+			}
+
+			_Z.mul(ai,b1,c2);
+			_Z.axpyin(ai,a1,a2);
+                               //aistar = a1*a2 + b1*c2;
+			_Z.mul(bi,b1,d2);
+			_Z.axpyin(bi, a1,b2);
+                               //bistar = a1*b2 + b1*d2;
+			_Z.mul(ci,d1,c2);
+			_Z.axpyin(ci, c1,a2);
+                               //cistar = c1*a2 + d1*c2;
+			_Z.mul(di,d1,d2);
+			_Z.axpyin(di, c1,b2);
+                               //distar = c1*b2 + d1*d2;
+C.mul_counter+=8;
+
+			_Z.mul(cur_ri,m,di);
+			_Z.axmyin(cur_ri,n,bi);
+			_Z.mul(cur_rinext,n,ai);
+			_Z.axmyin(cur_rinext,m,ci);
+C.mul_counter+=4;
+			//ri = m*di - n*bi;
+			//rinext = -m*ci + n*ai;
+			if (cur_ri < 0) {
+				cur_ri = -cur_ri;
+				cur_rinext = -cur_rinext;
+			}
+			cout << "->2:" << cur_ri << " " << cur_rinext << " " << cur_ainext << "->\n"<< flush;
+			if (cur_rinext>0) {
+				_Z.quo(cur_qinext,cur_ri,cur_rinext);
+++C.div_counter;
+				_Z.axpy(cur_ainext, ai,cur_qinext,bi);
+++C.mul_counter;
+			} else {
+				cur_ainext = m+1;//infinity
+				cur_qinext = cur_ainext;
+			}
+
+//multiply queueTmp by a1b1c1d1
+                        QMatrix<Ring > Q_i(_Z,a1,b1,c1,d1);
+			//update maximum
+			if (maxQ.q < maxQTmp.q) {
+				maxQTmp.leftmultiply(Q_i);
+				maxQ = maxQTmp;
+			}
+			int K=0;
+			//if (!queueTmp.empty()) {
+			//Element qi;
+			QMatrix<Ring > Q(_Z);
+				//Q = queueTmp.back();
+				//queueTmp.pop_back();
+				//Q.leftmultiply(Q_i);
+				//qi = Q.q;
+			while (!queueTmp.empty()) {
+				if (ai > powh) {
+					++K;
+					Q=queueTmp.back();
+					queueTmp.pop_back();
+					--queueTmp._size;
+					Q.leftmultiply(Q_i);
+					cur_ainext = ai;
+					cur_qinext = Q.q;
+					Element tmp = cur_ri;
+					_Z.axpy(cur_ri,tmp,Q.q,rinext);
+					cur_rinext = cur_ri;
+					ai = Q.a;
+					bi = Q.b;
+					ci = Q.c;
+					di = Q.d;
+					//qi = Q.q;
+				} else {
+					//update queue;
+					Q=queueTmp.front();
+					queueTmp.pop_front();
+					--queueTmp._size;
+					if (maxQ.q < Q.q) {
+						Q.leftmultiply(Q_i);
+					}
+					QMatrix<Ring > top(_Z);
+					if (queueMax.pushpop(top, Q)) {
+						cout << "8new max " << top.q << "\n"<< flush;
+						if (maxQ.q < top.q) maxQ = top;
+					}
+					cout << "queue" << Q.q << ",";
+
+					//else: queueMax may contain invalid matrices, but if Q.q is max then Q is correct
+				}
+			}
+			cout << "\n" << K << " backward steps\n"<< flush;
+			cout << "->End:" << cur_ri << " " << cur_rinext << " " << cur_ainext << "\n"<< flush;
+                        return 1;
+			//}
+
+		} else {//h=d, h = d+1;
+			cout << "choice3\n"<< flush;
+			Element hh = powh;
+			size_t log_hh = h;
+			hh = powh >> 1;
+			while (log_hh > d-1) {
+				--log_hh;
+				hh >>= 1;
+			}
+			if (!fastQMaxEEA(ai,bi,ci,di,m,d,n,hh, d-1,queueMax,maxQ)) return 0;
+
+				cout << "->3:" << cur_ri << " " << cur_rinext << " " << cur_ainext << "->\n"<< flush;
+		}
+
+		Element ri = cur_ri;
+		Element rinext = cur_rinext;
+		Element qinext = cur_qinext;
+		Element qi;
+		//_Z.mul(ri,m,di);
+		//_Z.axmyin(ri,n,bi);
+		//_Z.mul(rinext,n,ai);
+		//_Z.axmyin(rinext,m,ci);
+                ////ri = m*di - n*bi;
+                ////rinext = -m*ci + n*ai;
+                if (rinext==0) {
+			cout << "\n0 forward steps\n";
+			cout << "->End1:" << cur_ri << " " << cur_rinext << " " << cur_ainext << "\n";
+			return 1;
+		}
+                //if (ri < 0) {
+		//	ri = -ri;
+                //        rinext = -rinext;
+                //}
+                //quo(qinext,ri,rinext);
+
+		if (qinext <=0) {
+			cout << "ERROR sth went very very wrong:"<< flush ;
+                        cout << "m:" << m << " n:" << n << " h:" << powh << "\n"<< flush;
+                        cout << ai << " " << bi << "\n" << ci << " " << di <<"\n"<< flush; //getchar();
+                        return 0;
+                }
+
+                Element ainext, binext, cinext,dinext;
+                ainext=dinext=1;
+                binext=cinext=0;
+		ainext = cur_ainext;
+		int K=-1;
+                while (1) {
+			++K;
+			//_Z.axpy(ainext, ai,qinext,bi);
+			//ainext = cur_ainext;
+			if (powh < ainext) {
+				cur_ri = ri;
+				cur_rinext = rinext;
+				cur_ainext = ainext;
+				cur_qinext = qinext;
+				cout << "\n" << K << " forward steps\n"<< flush;
+				cout << "->End2:" << cur_ri << " " << cur_rinext << " " << cur_ainext << "\n"<< flush;
+
+				return 1;
+			}
+			//else if ((ah==1) && ((int)ah << (int)h) != ainext) return 1;
+			else {
+
+                                QMatrix<Ring > Q(_Z,ai,bi,ci,di,qinext);
+                                QMatrix<Ring > top(_Z);
+                                if (queueMax.pushpop(top, Q)) {
+                                        cout << "9new max " << top.q << "\n"<< flush;
+                                        if (maxQ.q < top.q) maxQ = top;
+                                }
+				cout << "End" << qinext << ",";
+
+
+				bi = ai;
+				ai = ainext;
+				Element temp = ci;
+				//ci = ci*qinext + di;
+				_Z.axpy(ci, ci,qinext,di);
+++C.mul_counter;
+				di = temp;
+				//qi = qinext;
+
+				temp = ri;
+				ri=rinext;
+				//rinext=qinext*ri+temp;
+				//rinext = temp - qinext*ri;
+				_Z.axpy(rinext, -qinext,ri,temp);
+++C.mul_counter;
+
+				if (rinext==0) {
+					cur_ri = ri;
+					cur_rinext = rinext;
+					cur_ainext = m+1;
+					cur_qinext = m+1;
+					cout << "\n" << K << " forward steps\n"<< flush;
+					cout << "->End3:" << cur_ri << " " << cur_rinext << " " << cur_ainext << "\n"<< flush;
+					return 1;
+				}
+                                        //++counter;
+				_Z.quo(qinext,ri,rinext);
+++C.div_counter;
+
+
+                                _Z.axpy(ainext, ai,qinext,bi);
+++C.mul_counter;
+			}
+		}
+
+                return 0;
+	}
+
+};
+
+template <class Ring>
+class MaxQClassicRationalReconstruction: public RationalReconstructionBase<Ring>
+{
+typedef typename Ring::Element Element;
+public:
+
+	MaxQClassicRationalReconstruction(const Ring& Z):RationalReconstructionBase<Ring>(Z) {}
+
+	~MaxQClassicRationalReconstruction() {}
+
+	bool reconstructRational(Element& a, Element& b, const Element& x, const Element& m) {
+		bool res = maxExGcd(a,b,x,m);
+		return res;
+
+	}
+
+	/* for sake of completeness, should not be used */
+	bool reconstructRational(Element& a, Element& b, const Element& x, const Element& m, const Element& a_bound) {
+
+		bool res =maxExGcd(a,b,x,m);
+		return res && (a < a_bound);
+	}
+
+protected:
+	/* returns a,b corresponding to the maximal quotient of Euclide GCD algorithm
+	 * returns true if a.b are coprime false otherwise
+	 */
+	bool maxExGcd(Element& a, Element& b, const Element& x, const Element& m) {
+
+		Element qmax = 0, amax=x, bmax =1;
+
+		Element  r0, t0, q, u;
+		r0=m;
+		t0=0;
+		a=x;
+		b=1;
+		//Element s0,s; s0=1,s=0;//test time gcdex;
+		while(a>0)
+		{
+		    q = r0;
+		    _Z.divin(q,a);        // r0/num
+++C.div_counter;
+			cout << r0<< " " << a << " " <<  q << ",";
+		    if (q > qmax) {
+			    //cout << r0<< " " << a << " " <<  q << ",";
+			    amax = a;
+			    bmax = b;
+			    qmax = q;
+		    }
+
+		    u = a;
+		    a = r0;
+		    r0 = u;	// r0 <-- num
+
+		    _Z.axmyin(a,u,q); // num <-- r0-q*num
+++C.mul_counter;
+		    //if (a == 0) return false;
+
+		    u = b;
+		    b = t0;
+		    t0 = u;	// t0 <-- den
+
+		    _Z.axmyin(b,u,q); // den <-- t0-q*den
+++C.mul_counter;
+
+		}
+
+		a = amax;
+		b = bmax;
+
+                if (b < 0) {
+			_Z.negin(a);
+                        _Z.negin(b);
+                }
+
+		Element gg;
+		_Z.gcd(gg,a,b);
+++C.gcd_counter;
+		if (gg > 1) return false;
+		else return true;
+	}
+};
+
+
+/* specialization for GMP integers - bitsize(), << , >>*/
+template <class Ring>
+class WangFastRationalReconstruction: public RationalReconstructionBase<Ring>
+{
+
+typedef typename Ring::Element Element;
+protected:
+	size_t _threshold;
+
+public:
+	WangFastRationalReconstruction(const Ring& Z): RationalReconstructionBase<Ring>(Z) {
+		_threshold = __FASTRR_DEFAULT_THRESHOLD;
+		if (_threshold < 5) _threshold = 5;
+	}
+
+	~WangFastRationalReconstruction() {}
+
+	bool reconstructRational(Element& a, Element& b, const Element& x, const Element& m) {
+		Element a_bound; _Z.sqrt(a_bound, m/2);
+		//if (b_bound >0)
+		reconstructRational(a,b,x,m,a_bound);
+		//else return false;
+		return (a < a_bound);
+		//b_bound == a_bound
+	}
+
+	bool reconstructRational(Element& a, Element& b, const Element& x, const Element& m, const Element& a_bound ) {
+		if (x < a_bound) {
+			//case(i)
+			a=x;
+			b=1;
+			return true;
+		} else if (m-x < a_bound) {
+			a = x-m;
+			b = 1;
+			return true;
+		}
+
+		Element bound = a_bound << 1;
+
+		if (m/bound > 1) {
+			fastReconstructRational(a,b,x,m,m/bound);
+
+			if (_Z.abs(a) < a_bound) {
+				return true;
+			}
+			return false;
+		} else {
+			//either case (i) or false
+			return false;
+		}
+	}
+
+	/* m/2 >= d_bound > 1
+	 * m/2 >= bound >=2
+	 */
+protected:
+
+	Element cur_ri;
+	Element cur_rinext;
+	Element cur_ainext;
+	Element cur_qinext;
+
+	Element& powtwo(Element& h, const Element& log_h) {
+		h = 1;
+		//cout << "max" << ULONG_MAX << "x" << x << "?" << (x < ULONG_MAX);
+		if (log_h < ULONG_MAX) {
+			h<<=log_h;
+			//cout << "z"<< z;
+			return h;
+		} else {
+			Element n,m;
+			quoRem(n,m,log_h,(Element)(ULONG_MAX-1));
+			for (int i=0; i < n; ++i) {
+				h <<=(long int)(ULONG_MAX-1);
+			}
+			h <= (long int)m;
+			return h;
+		}
+	}
+
+	Element& powtwo(Element& h, const size_t log_h) {
+		h = 1;
+		h<<=log_h;
+		return h;
+	}
+
+	bool fastReconstructRational(Element& n, Element& d, const Element& x, const Element& m, const Element& d_bound ) {
+
+		size_t log_m = m.bitsize()-1; //true unless m = 2^k
+		size_t log_bound = d_bound.bitsize()-1; // true unless d_bound = 2^l, repairable anyway
+		Element ai, bi, ci, di;
+		ai=1;bi=0;ci=0;di=1;
+		Element bound;  _Z.powtwo(bound, log_bound);
+
+		cur_ri = m;
+		cur_rinext = x;
+		_Z.quo(cur_ainext, cur_ri, cur_rinext);
+		cur_qinext = cur_ainext;//  ri/ri_next
+
+		if (!fastEEA (ai,bi,ci,di,m,log_m,x,bound, log_bound)) return false;
+
+		int K=0;
+
+		if (cur_rinext > 0) {
+			while (cur_ainext <= d_bound) {
+				++K;
+				Element tmp;
+				tmp = ai;
+				ai = cur_ainext;
+				bi = tmp;
+				tmp = ci;
+				_Z.axpy(ci, cur_qinext,tmp, di);
+++C.mul_counter;
+				di = tmp;
+
+				tmp = cur_rinext;
+				_Z.axpy(cur_rinext, -cur_qinext, tmp, cur_ri);
+				if (cur_rinext==0 ) {
+					break;
+				}
+				cur_ri = tmp;
+++C.mul_counter;
+				_Z.quo(cur_qinext, cur_rinext, cur_ri);
+++C.div_counter;
+				_Z.axpy(cur_ainext, ai, cur_qinext, bi);
+++C.mul_counter;
+			}
+		}
+
+		_Z.mul(n,x, ai);
+		_Z.axmyin(n,m,ci);
+		//n = x_in*ai-m*ci;
+		d = ai;
+
+		Element _gcd;
+		if (_Z.gcd(_gcd, n,d) > 1) {
+		/* solution not implemented */
+			cout << "Solution pair is not coprime\n";
+			return false;
+		}
+
+		return true;
+	}
+
+	//void prevEEA(Element& aprev, Element& bprev,const Element& ai, const Element& bi) {
+	//}
+
+	void prevEEA(Element& aprev, Element& bprev, Element& cprev, Element& dprev,
+		     const Element& ai, const Element& bi, const Element& ci, const Element& di) {
+		aprev = bi;
+		cprev = di;
+		if ((bi==1) && (di==1)) {
+			bprev = 1; dprev = 0;
+			Element tmp = cur_ri;
+			cur_ri = cur_ri+cur_rinext;
+			cur_rinext = tmp;
+			cur_ainext = ai;
+			cur_qinext = 1;
+			return;
+			//before last matrix we know next call to prevEEA is Id
+		}
+		Element qi;
+		_Z.quo(qi, ai, bi);
+++C.div_counter;
+
+		_Z.axpy(bprev, -qi, bi,ai);
+		_Z.axpy(dprev, -qi, di,ci);
+++C.mul_counter;++C.mul_counter;
+		Element tmp;
+		tmp = cur_ri;
+		_Z.axpy(cur_ri, tmp, qi, cur_rinext);
+		//cur_ri = cur_ri *qi + cur_rinext;
+		cur_rinext = tmp;
+		cur_ainext = ai;
+		cur_qinext = qi;
+++C.mul_counter;
+
+	}
+
+	/* extended Euclidean Algorithm */
+	bool classicEEA(Element& ai, Element& bi, Element& ci, Element& di, const Element& r0, const Element& r1, const Element& bound) {
+
+		Element ri, rinext;
+		ri = r0; rinext = r1;
+		ai =di = 1;
+		bi =ci = 0;
+
+		Element ainext,cinext;
+		Element qinext;
+		_Z.quo(qinext,ri,rinext);
+++C.div_counter;
+		while (1) {
+			//++i;
+			//ainext = ai*qinext + bi;
+			_Z.axpy(ainext, ai,qinext,bi);
+++C.mul_counter;
+			if (bound < ainext) {
+				cur_ri = ri;
+				cur_rinext = rinext;
+				cur_ainext = ainext;
+				cur_qinext = qinext;
+				//cout << "->E:" << cur_ri << " " << cur_rinext <<" " <<  cur_ainext << "\n";
+				return true;
+			}
+			else {
+			       	bi = ai;
+				ai = ainext;
+				Element temp = ci;
+				_Z.axpy(ci, temp,qinext,di);
+++C.mul_counter;
+				di = temp;
+
+				temp = ri;
+				ri=rinext;
+				_Z.axpy(rinext, -qinext,ri,temp);//rinext = ri-qinext*rinext
+++C.mul_counter;
+				if (rinext==0) {
+					//ainext = infinity
+				        cur_ri = ri;
+				        cur_rinext = rinext;
+				        cur_ainext = r0+1;
+					cur_qinext = cur_ainext;//infinity
+					//cout << "->E:" << cur_ri << " " << cur_rinext <<" " <<  cur_ainext << "\n";
+					return true;
+				}
+				_Z.quo(qinext,ri,rinext);
+++C.div_counter;
+			}
+		}
+	}
+
+	/* log(m)-1 <= d < log(m) ; d >=1
+	 * 2^h=powh=bound>=2, h <= d
+	 */
+	bool fastEEA(Element& ai,Element& bi, Element& ci, Element& di, const Element& m, const size_t d, const Element& n, const Element& powh, const size_t& h) {
+
+		//cout << m << " " << n << " " << powh << "\n" << flush;
+
+		ai=Element(1);
+		di=Element(1);
+		bi=Element(0);
+		ci=Element(0); //Q(0)=Id
+
+		if (m==n) {
+			cur_ri = m;
+			cur_rinext = 0;
+			cur_ainext = m+1;//infinity
+			cur_qinext = m+1;
+			ai=1; bi=1; ci=1; di=0;
+			return true;
+		}
+
+		if (powh < 1) return false; //should not happen
+		if (n < 2) {
+			//cout << "n=1\n";
+			                 //n==1 -> Q1=(m,1//1,0)
+		                         //n==0 -> Q1=infinity
+			cur_ri = m;
+			cur_rinext = n;
+			cur_ainext = m;//infinity
+			cur_qinext = m;
+			if (cur_ainext > powh) return true;
+			else {
+				cur_ri = 1;
+				cur_rinext = 0;
+				cur_ainext = m+1;
+				cur_qinext = m+1;
+			}
+		        return true;
+		}
+
+		if (h < 1) {
+			//quo(qinext,m,n);
+			//if (qinext==1) { return (1,1,1,0) or (1,0,0,1)
+			if ((n << 1) > m) {
+				cur_ri = n;
+				cur_rinext = m-n;
+				_Z.quo(cur_qinext, cur_ri, cur_rinext);
+++C.div_counter;
+				cur_ainext = cur_qinext + 1;
+				ai=1; bi=1; ci=1; di=0;
+			} else {
+				cur_ri = m;
+				cur_rinext = n;
+				_Z.quo(cur_ainext,m,n);
+++C.div_counter;
+				cur_qinext = cur_ainext;
+			}
+			return true;
+		}
+
+		if (n < _threshold) {       //what about m?
+			return classicEEA(ai,bi,ci,di,m,n,powh);
+		}
+
+		size_t log_n = n.bitsize()-1;
+
+		//cout << d << " " << log_n << " "  << h << "\n";
+
+		if (2*h+1 < d) {
+			//cout << "choice1";
+		  //if (2*h+1 <= log_n) {
+		  if (true) {
+			//cout << ".1\n";
+			size_t lambda = d-2*h-1;
+
+			Element aistar, bistar, cistar, distar;
+			aistar=distar=1;
+			bistar=cistar=0;
+
+			Element mstar = m >> (long unsigned int) lambda;
+			Element nstar = n >> (long unsigned int) lambda;
+
+			size_t log_mstar = 2*h+1;
+
+			if (nstar > 0) if (!fastEEA(aistar, bistar, cistar, distar, mstar, log_mstar,nstar, powh, h)) return false;
+
+			int K=2;//reatreat steps;
+
+			if ((aistar > 1) && (distar > 0)) { //we have to go back 2 steps
+				Element aprev,bprev,cprev,dprev;
+                                for (int i=0; i < K; ++i) {
+					prevEEA(aprev,bprev,cprev,dprev,aistar,bistar,cistar,distar);
+                                        aistar=aprev;bistar=bprev;cistar=cprev;distar=dprev;
+                                }
+				ai = aistar; bi =bistar; ci = cistar; di= distar;
+                        }
+
+			_Z.mul(cur_ri,m,di);
+			_Z.axmyin(cur_ri,n,bi);
+			_Z.mul(cur_rinext,n,ai);
+			_Z.axmyin(cur_rinext,m,ci);
+C.mul_counter+=4;
+			//ri = m*di - n*bi;
+			//rinext = -m*ci + n*ai;
+
+			if (cur_ri < 0) {
+				cur_ri = -cur_ri;
+				cur_rinext = -cur_rinext;
+			}
+			if (cur_rinext>0) {
+				_Z.quo(cur_qinext,cur_ri,cur_rinext);
+++C.div_counter;
+				_Z.axpy(cur_ainext, ai,cur_qinext,bi);
+++C.mul_counter;
+			} else {
+				cur_ainext = m+1;//infinity
+				cur_qinext = cur_ainext;
+			}
+
+			//cout << "\n2 backward steps\n";
+			//cout << "->1:" << cur_ri << " " << cur_rinext <<" " <<  cur_ainext << "->\n";
+
+		   } else {
+			//cout << ".2\n";
+			Element a1,b1,c1,d1;
+			Element qi;
+			_Z.quo(qi,m,n);
+++C.div_counter;
+			Element ri = n;
+			Element rinext;
+			_Z.axpy(rinext,-qi,n,m);
+			size_t k = qi.bitsize()-1;
+			Element hh;
+			if (qi<powh) {
+				if (!fastEEA(a1,b1,c1,d1,ri,log_n,rinext,powtwo(hh,h-k-1),h-k-1)) return 0;
+			} else {
+				if (qi == powh) {
+					ai=qi; bi= 1; ci=1;di=0;
+					cur_ri = ri;
+					cur_rinext = rinext;
+					_Z.quo(cur_qinext,ri,rinext);
+++C.div_counter;
+					_Z.axpy(cur_ainext,qi,cur_qinext,1);
+++C.mul_counter;
+					return 1;
+				} else {
+					ai=1; bi=0; ci=0; di=1;
+					cur_ri = m;
+					cur_rinext = n;
+					cur_qinext = qi;
+					cur_ainext = qi;
+					return 1;
+				}
+			}
+			_Z.axpy(ai,qi,a1,c1);
+			_Z.axpy(bi,qi,b1,d1);
+			ci = a1;
+			di = b1;
+C.mul_counter +=2;
+			_Z.axpy(cur_ainext, ai,cur_qinext,bi);
+++C.mul_counter;
+                        Element aprev,bprev,cprev,dprev;
+
+			//cout << "->2.5:" << cur_ri << " " << cur_rinext << " " << cur_ainext << "->\n";
+
+                        if (ai > powh) {//at most 2 forward steps, at most 2 backward steps
+					 //backward loop (max 2 steps)
+				int K=0;
+				while (ai > powh) {//one step back
+					++K;
+					prevEEA(aprev,bprev,cprev,dprev,ai,bi,ci,di);
+                                        ai=aprev;bi=bprev;ci=cprev;di=dprev;
+				}
+				//cout << "\n" << K << " backward steps\n";
+				//cout << "->End:" << cur_ri << " " << cur_rinext << " " << cur_ainext << "\n";
+                                return 1;
+                        }
+		   }
+		} else if (h <= d-1) {
+			//cout << "choice2\n";
+			Element a1,a2,b1,b2,c1,c2,d1,d2;
+                        a1=a2=d1=d2=1;
+                        b1=b2=c1=c2=0;
+
+                        Element sqrth;
+			size_t logsqrth;
+                                //sqrt(sqrth,powh);
+                        logsqrth = h >> (int) 1;
+			powtwo(sqrth, logsqrth);
+                                //logtwo(logsqrth, sqrth);
+                                //_sqrth = h/2;
+
+                                //if (!EEA(sgn, ri, rinext, qinext, a1,b1,c1,d1,m,d,n,sqrth, logsqrth)) return 0;
+			if (!fastEEA(a1,b1,c1,d1,m,d,n,sqrth, logsqrth)) return 0;
+
+			Element ri = cur_ri;
+			Element rinext = cur_rinext;
+
+			//ri = m*d1;
+			//Integer::axmyin(ri,n,b1);
+			////ri = m*d1 - n*b1;
+
+			//rinext = n*a1;
+			//Integer::axmyin(rinext,m,c1);
+			////rinext = -m*c1 + n*a1;
+			if (ri < 0) {
+				ri = -ri;
+				rinext = -rinext;
+			}
+
+			size_t log_m;
+			//if (ri !=m) //logtwo(log_m,ri);
+			if ((rinext > 0) && (cur_ainext <= powh)){
+				log_m = rinext.bitsize()-1;
+				Element m2, n2;
+				m2 = rinext;
+				_Z.axpy(n2, -cur_qinext, rinext, ri);
+++C.mul_counter;
+				/* compute Q(i+1) */
+				Element tmp = a1;
+				a1 = cur_ainext;
+				b1 = tmp;
+				tmp = c1;
+				_Z.axpy (tmp, cur_qinext, c1, d1);
+++C.mul_counter;
+				d1 = c1;
+				c1 = tmp;
+
+				size_t k = a1.bitsize()-1 ;
+				if (rinext >0) {
+					if (a1 < powh) {
+						if (!fastEEA(a2,b2,c2,d2,m2,log_m,n2, powtwo(sqrth,h-k-1), h-k-1)) return 0;
+					} else {
+						ai = a1; bi = b1; ci=c1; di = d1;
+						cur_ri = m2;
+						cur_rinext = n2;
+						_Z.quo(cur_qinext,m2,n2);
+++C.div_counter;
+						_Z.axpy(cur_ainext,a1,cur_qinext,b1);
+++C.mul_counter;
+						return 1;
+					}
+				} else {
+					ai = a1; bi = b1; ci=c1; di = d1;
+					cur_ri = m2;
+					cur_rinext = n2;
+					cur_qinext = m+1;
+					cur_ainext = m+1;
+					return 1;
+				}
+			} else {
+				ai = a1; bi = b1; ci=c1; di = d1;
+				//cout << "End2\n";
+				return 1;
+			}
+
+			_Z.mul(ai,b1,c2);
+			_Z.axpyin(ai,a1,a2);
+                               //aistar = a1*a2 + b1*c2;
+			_Z.mul(bi,b1,d2);
+			_Z.axpyin(bi, a1,b2);
+                               //bistar = a1*b2 + b1*d2;
+			_Z.mul(ci,d1,c2);
+			_Z.axpyin(ci, c1,a2);
+                               //cistar = c1*a2 + d1*c2;
+			_Z.mul(di,d1,d2);
+			_Z.axpyin(di, c1,b2);
+                               //distar = c1*b2 + d1*d2;
+C.mul_counter+=8;
+
+			_Z.mul(cur_ri,m,di);
+			_Z.axmyin(cur_ri,n,bi);
+			_Z.mul(cur_rinext,n,ai);
+			_Z.axmyin(cur_rinext,m,ci);
+C.mul_counter+=4;
+			//ri = m*di - n*bi;
+			//rinext = -m*ci + n*ai;
+			if (cur_ri < 0) {
+				cur_ri = -cur_ri;
+				cur_rinext = -cur_rinext;
+			}
+			if (cur_rinext>0) {
+				_Z.quo(cur_qinext,cur_ri,cur_rinext);
+++C.div_counter;
+				_Z.axpy(cur_ainext, ai,cur_qinext,bi);
+++C.mul_counter;
+			} else {
+				cur_ainext = m+1;//infinity
+				cur_qinext = cur_ainext;
+			}
+
+			//cout << "->2:" << cur_ri << " " << cur_rinext << " " << cur_ainext << "->\n";
+
+                        Element aprev,bprev,cprev,dprev;
+                        aprev=dprev=1;
+                        bprev=cprev=0;
+
+			//ai=aistar; bi = bistar; ci=cistar; di=distar;
+
+                        if (ai > powh) {//at most 2 forward steps, at most 2 backward steps
+					//backward loop (max 2 steps)
+				int K=0;
+				while (ai > powh) {//one step back
+					++K;
+					prevEEA(aprev,bprev,cprev,dprev,ai,bi,ci,di);
+                                        ai=aprev;bi=bprev;ci=cprev;di=dprev;
+				}
+				//cout << "\n" << K << " backward steps\n";
+				//cout << "->End:" << cur_ri << " " << cur_rinext << " " << cur_ainext << "\n";
+                                return 1;
+                        }
+
+		} else {//h=d, h = d+1;
+			//cout << "choice3\n";
+			Element hh = powh;
+			size_t log_hh = h;
+			hh = powh >> 1;
+			while (log_hh > d-1) {
+				--log_hh;
+				hh >>= 1;
+			}
+			if (!fastEEA(ai,bi,ci,di,m,d,n,hh, d-1)) return 0;
+
+			//cout << "->3:" << cur_ri << " " << cur_rinext << " " << cur_ainext << "->\n";
+		}
+
+		Element ri = cur_ri;
+		Element rinext = cur_rinext;
+		Element qinext = cur_qinext;
+		//_Z.mul(ri,m,di);
+		//_Z.axmyin(ri,n,bi);
+		//_Z.mul(rinext,n,ai);
+		//_Z.axmyin(rinext,m,ci);
+                ////ri = m*di - n*bi;
+                ////rinext = -m*ci + n*ai;
+                if (rinext==0) {
+			//cout << "\n0 forward steps\n";
+			//cout << "->End1:" << cur_ri << " " << cur_rinext << " " << cur_ainext << "\n";
+			return 1;
+		}
+                //if (ri < 0) {
+		//	ri = -ri;
+                //        rinext = -rinext;
+                //}
+                //quo(qinext,ri,rinext);
+
+		if (qinext <=0) {
+			//cout << "ERROR sth went very very wrong:" ;
+                        //cout << "m:" << m << " n:" << n << " h:" << powh << "\n";
+                        //cout << ai << " " << bi << "\n" << ci << " " << di <<"\n"; //getchar();
+                        return 0;
+                }
+
+                Element ainext, binext, cinext,dinext;
+                ainext=dinext=1;
+                binext=cinext=0;
+		ainext = cur_ainext;
+		int K=-1;
+                while (1) {
+			++K;
+			//_Z.axpy(ainext, ai,qinext,bi);
+			//ainext = cur_ainext;
+			if (powh < ainext) {
+				cur_ri = ri;
+				cur_rinext = rinext;
+				cur_ainext = ainext;
+				cur_qinext = qinext;
+				//cout << "\n" << K << " forward steps\n";
+				//cout << "->End2:" << cur_ri << " " << cur_rinext << " " << cur_ainext << "\n";
+				return 1;
+			}
+			//else if ((ah==1) && ((int)ah << (int)h) != ainext) return 1;
+			else {
+
+				bi = ai;
+				ai = ainext;
+				Element temp = ci;
+				//ci = ci*qinext + di;
+				_Z.axpy(ci, ci,qinext,di);
+++C.mul_counter;
+				di = temp;
+
+				temp = ri;
+				ri=rinext;
+				//rinext=qinext*ri+temp;
+				//rinext = temp - qinext*ri;
+				_Z.axpy(rinext, -qinext,ri,temp);
+++C.mul_counter;
+				if (rinext==0) {
+					cur_ri = ri;
+					cur_rinext = rinext;
+					cur_ainext = m+1;
+					cur_qinext = m+1;
+					//cout << "\n" << K << " forward steps\n";
+					//cout << "->End3:" << cur_ri << " " << cur_rinext << " " << cur_ainext << "\n";
+					return 1;
+				}
+                                        //++counter;
+				_Z.quo(qinext,ri,rinext);
+++C.div_counter;
+                                _Z.axpy(ainext, ai,qinext,bi);
+++C.mul_counter;
+			}
+		}
+
+                return 0;
+	}
+};
+
+template <class Ring>
+class WangClassicRationalReconstruction: public RationalReconstructionBase<Ring>
+{
+	bool _reduce;
+	bool _recursive;
+	typedef typename Ring::Element Element;
+public:
+
+	WangClassicRationalReconstruction(const Ring& Z, const bool reduce = true, const bool recursive = false): RationalReconstructionBase<Ring>(Z) {
+		_reduce = reduce; _recursive = recursive;
+	}
+
+	WangClassicRationalReconstruction<Ring> (const WangClassicRationalReconstruction<Ring>& RR): RationalReconstructionBase<Ring>(RR._Z) {
+		_reduce = RR._reduce; _recursive = RR._recursive;
+	}
+
+	~WangClassicRationalReconstruction() {}
+
+
+	bool reconstructRational(Element& a, Element& b, const Element& x, const Element& m) {
+		Element a_bound; _Z.sqrt(a_bound, m/2);
+		bool res = reconstructRational(a,b,x,m,a_bound);
+		res = res && (b <= a_bound);
+		return res;
+	}
+
+	bool reconstructRational(Element& a, Element& b, const Element& x, const Element& m, const Element& a_bound) {
+		bool res;
+
+		if (x == 0) {
+		    a = 0;
+		    b = 1;
+		} else {
+			bool res = ratrecon(a,b,x,m,a_bound);
+			if (_recursive)
+			for(Element newbound = a_bound + 1; (!res) && (newbound<x) ; ++newbound)
+			    res = ratrecon(a,b,x,m,newbound);
+		}
+		if (!res) {
+			a = x> m/2? x-m: x;
+			b = 1;
+			if (a > 0) res = (a < a_bound);
+			else res = (-a < a_bound);
+		}
+
+		return res;
+	}
+
+protected:
+	/* m> x> 0 */
+	bool ratrecon(Element& a,Element& b,const Element& x,const Element& m,const Element& a_bound) {
+
+		Element  r0, t0, q, u;
+		r0=m;
+		t0=0;
+		a=x;
+		b=1;
+		//Element s0,s; s0=1,s=0;//test time gcdex;
+		while(a>=a_bound)
+		{
+
+		    q = r0;
+		    _Z.divin(q,a);        // r0/num
+++C.div_counter;
+
+		    u = a;
+		    a = r0;
+		    r0 = u;	// r0 <-- num
+
+		    _Z.axmyin(a,u,q); // num <-- r0-q*num
+++C.mul_counter;
+		    //if (a == 0) return false;
+
+		    u = b;
+		    b = t0;
+		    t0 = u;	// t0 <-- den
+
+		    _Z.axmyin(b,u,q); // den <-- t0-q*den
+++C.mul_counter;
+		}
+
+//                        if (den < 0) {
+//                                _Z.negin(num);
+//                                _Z.negin(den);
+//                        }
+
+		if ((a>0) && (_reduce)) {
+
+			// [GG, MCA, 1999] Theorem 5.26
+			// (ii)
+		    Element gg;
+++C.gcd_counter;
+		    if (_Z.gcd(gg,a,b) != 1) {
+
+			Element ganum, gar2;
+			for( q = 1, ganum = r0-a, gar2 = r0 ; (ganum >= a_bound) || (gar2<a_bound); ++q ) {
+			    ganum -= a;
+			    gar2 -= a;
+			}
+
+			//_Z.axmyin(r0,q,a);
+			r0 = ganum;
+			_Z.axmyin(t0,q,b);
+++C.mul_counter;++C.mul_counter;
+			if (t0 < 0) {
+			    a = -r0;
+			    b = -t0;
+			} else {
+			    a = r0;
+			    b = t0;
+			}
+
+//                                if (t0 > m/k) {
+			if ((double)b > (double)m/(double)a_bound) {
+				if (!_recursive) {
+					std::cerr
+						<< "*** Error *** No rational reconstruction of "
+						<< x
+						<< " modulo "
+						<< m
+						<< " with denominator <= "
+						<< (m/a_bound)
+						<< std::endl;
+				}
+				return false;
+			}
+			if (_Z.gcd(gg,a,b) != 1) {
+			    if (!_recursive)
+				std::cerr
+				    << "*** Error *** There exists no rational reconstruction of "
+				    << x
+				    << " modulo "
+				    << m
+				    << " with |numerator| < "
+				    << a_bound
+				    << std::endl
+				    << "*** Error *** But "
+				    << a
+				    << " = "
+				    << b
+				    << " * "
+				    << x
+				    << " modulo "
+				    << m
+				    << std::endl;
+			    return false;
+			}
+		    }
+		}
+	       // (i)
+	       if (b < 0) {
+		       _Z.negin(a);
+		       _Z.negin(b);
+	       }
+
+// std::cerr << "RatRecon End " << num << "/" << den << std::endl;
+		return true;
+	}
+};
+
+
+} //namespace LinBox
+#endif
+


IntervalTree: add missed header

IntervalTree: add missed header

--- stingraykit/collection/IntervalTree.h
+++ stingraykit/collection/IntervalTree.h
@@ -8,9 +8,9 @@
 // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 // WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

-
 #include <stingraykit/collection/iterator_base.h>

+#include <list>

 namespace stingray
 {


ilo: cleanup ISA DW0 decoding

ilo: cleanup ISA DW0 decoding

Add disasm_inst_decode_dw0_opcode_gen6() to decode the opcode.  Simplify
branch_ctrl/acc_wr_ctrl decoding.

--- src/gallium/drivers/ilo/shader/toy_compiler_disasm.c
+++ src/gallium/drivers/ilo/shader/toy_compiler_disasm.c
@@ -184,7 +184,7 @@
 };

 static void
-disasm_inst_decode_dw0_gen6(struct disasm_inst *inst, uint32_t dw0)
+disasm_inst_decode_dw0_opcode_gen6(struct disasm_inst *inst, uint32_t dw0)
 {
    ILO_DEV_ASSERT(inst->dev, 6, 8);

@@ -218,6 +218,14 @@
    default:
       break;
    }
+}
+
+static void
+disasm_inst_decode_dw0_gen6(struct disasm_inst *inst, uint32_t dw0)
+{
+   ILO_DEV_ASSERT(inst->dev, 6, 8);
+
+   disasm_inst_decode_dw0_opcode_gen6(inst, dw0);

    inst->access_mode = GEN_EXTRACT(dw0, GEN6_INST_ACCESSMODE);

@@ -250,19 +258,17 @@
       break;
    }

-   if (ilo_dev_gen(inst->dev) >= ILO_GEN(8)) {
-      switch (inst->opcode) {
-      case GEN6_OPCODE_IF:
-      case GEN6_OPCODE_ELSE:
-      case GEN8_OPCODE_GOTO:
+   switch (inst->opcode) {
+   case GEN6_OPCODE_IF:
+   case GEN6_OPCODE_ELSE:
+   case GEN8_OPCODE_GOTO:
+      if (ilo_dev_gen(inst->dev) >= ILO_GEN(8)) {
          inst->branch_ctrl = (bool) (dw0 & GEN8_INST_BRANCHCTRL);
          break;
-      default:
-         inst->acc_wr_ctrl = (bool) (dw0 & GEN6_INST_ACCWRCTRL);
-         break;
-      }
-   } else {
+      }
+   default:
       inst->acc_wr_ctrl = (bool) (dw0 & GEN6_INST_ACCWRCTRL);
+      break;
    }

    inst->cmpt_ctrl = (bool) (dw0 & GEN6_INST_CMPTCTRL);


Cluster: better logging for clusterUpdateSlotsConfigWith().

--- src/cluster.c
+++ src/cluster.c
@@ -1110,6 +1110,11 @@
      * interested to check if slots are taken away from curmaster. */
     curmaster = nodeIsMaster(myself) ? myself : myself->slaveof;

+    if (sender == myself) {
+        redisLog(REDIS_WARNING,"Discarding UPDATE message about myself.");
+        return;
+    }
+
     for (j = 0; j < REDIS_CLUSTER_SLOTS; j++) {
         if (bitmapTestBit(slots,j)) {
             /* The slot is already bound to the sender of this message. */
@@ -1137,9 +1142,14 @@
                     sender != myself)
                 {
                     redisLog(REDIS_WARNING,
-                        "I received a slot update for a slot I've still "
-                        "keys into. Putting the slot in IMPORTING state. "
-                        "Please run the 'redis-trib fix' command.");
+                        "I received an update for slot %d. "
+                        "%.40s claims it with config %llu, "
+                        "I've it assigned to myself with config %llu. "
+                        "I've still keys about this slot! "
+                        "Putting the slot in IMPORTING state. "
+                        "Please run the 'redis-trib fix' command.",
+                        j, sender->name, senderConfigEpoch,
+                        myself->configEpoch);
                     server.cluster->importing_slots_from[j] = sender;
                 }


Cluster: there is a lower limit for the handshake timeout.

--- src/cluster.c
+++ src/cluster.c
@@ -1743,8 +1743,16 @@
     mstime_t min_pong = 0, now = mstime();
     clusterNode *min_pong_node = NULL;
     static unsigned long long iteration = 0;
+    mstime_t handshake_timeout;

     iteration++; /* Number of times this function was called so far. */
+
+    /* The handshake timeout is the time after which an handshake node that was
+     * not turned into a normal node is removed from the nodes. Usually it is
+     * just the NODE_TIMEOUT value, but when NODE_TIMEOUT is too small we use
+     * the value of 1 second. */
+    handshake_timeout = server.cluster_node_timeout;
+    if (handshake_timeout < 1000) handshake_timeout = 1000;

     /* Check if we have disconnected nodes and re-establish the connection. */
     di = dictGetSafeIterator(server.cluster->nodes);
@@ -1756,7 +1764,7 @@
         /* A Node in HANDSHAKE state has a limited lifespan equal to the
          * configured node timeout. */
         if (node->flags & REDIS_NODE_HANDSHAKE &&
-            now - node->ctime > server.cluster_node_timeout)
+            now - node->ctime > handshake_timeout)
         {
             freeClusterNode(node);
             continue;


just minor aesthetic changes to cluster.c

--- src/cluster.c
+++ src/cluster.c
@@ -493,6 +493,7 @@
 /* Update the node address to the IP address that can be extracted
  * from link->fd, and at the specified port. */
 void nodeUpdateAddress(clusterNode *node, clusterLink *link, int port) {
+    /* TODO */
 }

 /* When this function is called, there is a packet to process starting
@@ -510,8 +511,8 @@
     uint16_t type = ntohs(hdr->type);
     clusterNode *sender;

-    redisLog(REDIS_DEBUG,"--- packet to process %lu bytes (%lu) ---",
-        (unsigned long) totlen, sdslen(link->rcvbuf));
+    redisLog(REDIS_DEBUG,"--- Processing packet of type %d, %lu bytes",
+        type, (unsigned long) totlen);
     if (totlen < 8) return 1;
     if (totlen > sdslen(link->rcvbuf)) return 1;
     if (type == CLUSTERMSG_TYPE_PING || type == CLUSTERMSG_TYPE_PONG ||


Bluetooth: controller: Reorder variable declarations in ISO HCI commands

Reorder variable declarations in HCI command handlers of ISO-related
commands to conform to reverse Christmas tree style.

Signed-off-by: Wolfgang Puffitsch <f148e6efbb74c70a1ee845a87fa7616913a99a4b@demant.com>

--- subsys/bluetooth/controller/hci/hci.c
+++ subsys/bluetooth/controller/hci/hci.c
@@ -1504,12 +1504,12 @@
 static void le_create_big(struct net_buf *buf, struct net_buf **evt)
 {
 	struct bt_hci_cp_le_create_big *cmd = (void *)buf->data;
-	uint8_t status;
 	uint32_t sdu_interval;
-	uint16_t max_sdu;
 	uint16_t max_latency;
 	uint8_t big_handle;
 	uint8_t adv_handle;
+	uint16_t max_sdu;
+	uint8_t status;

 	status = ll_adv_iso_by_hci_handle_new(cmd->big_handle, &big_handle);
 	if (status) {
@@ -1538,11 +1538,11 @@
 static void le_create_big_test(struct net_buf *buf, struct net_buf **evt)
 {
 	struct bt_hci_cp_le_create_big_test *cmd = (void *)buf->data;
-	uint8_t status;
 	uint32_t sdu_interval;
 	uint16_t iso_interval;
 	uint16_t max_sdu;
 	uint16_t max_pdu;
+	uint8_t status;

 	sdu_interval = sys_get_le24(cmd->sdu_interval);
 	iso_interval = sys_le16_to_cpu(cmd->iso_interval);
@@ -1978,8 +1978,8 @@
 {
 	struct bt_hci_cp_le_iso_transmit_test *cmd = (void *)buf->data;
 	struct bt_hci_rp_le_iso_transmit_test *rp;
-	uint8_t status;
 	uint16_t handle;
+	uint8_t status;

 	handle = sys_le16_to_cpu(cmd->handle);

@@ -1994,12 +1994,12 @@
 {
 	struct bt_hci_cp_le_read_iso_tx_sync *cmd = (void *)buf->data;
 	struct bt_hci_rp_le_read_iso_tx_sync *rp;
-	uint8_t status;
-	uint16_t handle, handle_le16;
-
-	uint16_t seq;
+	uint16_t handle_le16;
 	uint32_t timestamp;
 	uint32_t offset;
+	uint16_t handle;
+	uint8_t status;
+	uint16_t seq;

 	handle_le16 = cmd->handle;
 	handle = sys_le16_to_cpu(handle_le16);
@@ -2020,8 +2020,8 @@
 {
 	struct bt_hci_cp_le_iso_receive_test *cmd = (void *)buf->data;
 	struct bt_hci_rp_le_iso_receive_test *rp;
-	uint8_t status;
 	uint16_t handle;
+	uint8_t status;

 	handle = sys_le16_to_cpu(cmd->handle);

@@ -2036,11 +2036,11 @@
 {
 	struct bt_hci_cp_le_read_test_counters *cmd = (void *)buf->data;
 	struct bt_hci_rp_le_read_test_counters *rp;
-	uint8_t status;
-	uint16_t handle;
 	uint32_t received_cnt;
 	uint32_t missed_cnt;
 	uint32_t failed_cnt;
+	uint16_t handle;
+	uint8_t status;

 	handle = sys_le16_to_cpu(cmd->handle);
 	status = ll_iso_read_test_counters(handle, &received_cnt,
@@ -2058,16 +2058,16 @@
 {
 	struct bt_hci_cp_le_read_iso_link_quality *cmd = (void *)buf->data;
 	struct bt_hci_rp_le_read_iso_link_quality *rp;
-	uint8_t status;
-	uint16_t handle, handle_le16;
-
+	uint32_t tx_last_subevent_packets;
+	uint32_t retransmitted_packets;
+	uint32_t rx_unreceived_packets;
 	uint32_t tx_unacked_packets;
 	uint32_t tx_flushed_packets;
-	uint32_t tx_last_subevent_packets;
-	uint32_t retransmitted_packets;
 	uint32_t crc_error_packets;
-	uint32_t rx_unreceived_packets;
 	uint32_t duplicate_packets;
+	uint16_t handle_le16;
+	uint16_t handle;
+	uint8_t status;

 	handle_le16 = cmd->handle;
 	handle = sys_le16_to_cpu(handle_le16);
@@ -2127,8 +2127,8 @@
 {
 	struct bt_hci_cp_le_remove_iso_path *cmd = (void *)buf->data;
 	struct bt_hci_rp_le_remove_iso_path *rp;
-	uint8_t status;
 	uint16_t handle;
+	uint8_t status;

 	handle = sys_le16_to_cpu(cmd->handle);

@@ -2143,11 +2143,11 @@
 {
 	struct bt_hci_cp_le_iso_test_end *cmd = (void *)buf->data;
 	struct bt_hci_rp_le_iso_test_end *rp;
-	uint8_t status;
-	uint16_t handle;
 	uint32_t received_cnt;
 	uint32_t missed_cnt;
 	uint32_t failed_cnt;
+	uint16_t handle;
+	uint8_t status;

 	handle = sys_le16_to_cpu(cmd->handle);
 	status = ll_iso_test_end(handle, &received_cnt, &missed_cnt,


Cluster: conditions to clear "migrating" on slot for SETSLOT ... NODE changed.

If the slot is manually assigned to another node, clear the migrating
status regardless of the fact it was previously assigned to us or not,
as long as we no longer have keys for this slot.

This avoid a race during slots migration that may leave the slot in
migrating status in the source node, since it received an update message
from the destination node that is already claiming the slot.

This way we are sure that redis-trib at the end of the slot migration is
always able to close the slot correctly.

--- src/cluster.c
+++ src/cluster.c
@@ -3154,10 +3154,10 @@
                     return;
                 }
             }
-            /* If this node was the slot owner and the slot was marked as
-             * migrating, assigning the slot to another node will clear
+            /* If this slot is in migrating status but we have no keys
+             * for it assigning the slot to another node will clear
              * the migratig status. */
-            if (server.cluster->slots[slot] == myself &&
+            if (countKeysInSlot(slot) == 0 &&
                 server.cluster->migrating_slots_to[slot])
                 server.cluster->migrating_slots_to[slot] = NULL;


Bluetooth: Controller: Fix incorrect common header length calc

Fix incorrect calculation of received common extended header
length. Due to this a zero length advertising data is
reported in Extended Advertising and Periodic Advertising
report as one byte AD data.

Signed-off-by: Vinayak Kariappa Chettimada <e780c9f87dc729ad454f47292ad82c8652353064@nordicsemi.no>

--- subsys/bluetooth/controller/hci/hci.c
+++ subsys/bluetooth/controller/hci/hci.c
@@ -5216,12 +5216,6 @@
 		}

 		hdr_len = ptr - (uint8_t *)p;
-		if (hdr_len <= (PDU_AC_EXT_HEADER_SIZE_MIN +
-				sizeof(struct pdu_adv_ext_hdr))) {
-			hdr_len = PDU_AC_EXT_HEADER_SIZE_MIN;
-			ptr = (uint8_t *)h;
-		}
-
 		hdr_buf_len = PDU_AC_EXT_HEADER_SIZE_MIN + p->ext_hdr_len;
 		if (hdr_len > hdr_buf_len) {
 			BT_WARN("    Header length %u/%u, INVALID.", hdr_len,
@@ -5639,12 +5633,6 @@
 	}

 	hdr_len = ptr - (uint8_t *)p;
-		if (hdr_len <= (PDU_AC_EXT_HEADER_SIZE_MIN +
-				sizeof(struct pdu_adv_ext_hdr))) {
-			hdr_len = PDU_AC_EXT_HEADER_SIZE_MIN;
-			ptr = (uint8_t *)h;
-		}
-
 	hdr_buf_len = PDU_AC_EXT_HEADER_SIZE_MIN + p->ext_hdr_len;
 	if (hdr_len > hdr_buf_len) {
 		BT_WARN("    Header length %u/%u, INVALID.", hdr_len,


Cluster: add currentEpoch to CLUSTER INFO.

--- src/cluster.c
+++ src/cluster.c
@@ -2393,13 +2393,15 @@
             "cluster_slots_fail:%d\r\n"
             "cluster_known_nodes:%lu\r\n"
             "cluster_size:%d\r\n"
+            "cluster_current_epoch:%llu\r\n"
             , statestr[server.cluster->state],
             slots_assigned,
             slots_ok,
             slots_pfail,
             slots_fail,
             dictSize(server.cluster->nodes),
-            server.cluster->size
+            server.cluster->size,
+            (unsigned long long) server.cluster->currentEpoch
         );
         addReplySds(c,sdscatprintf(sdsempty(),"$%lu\r\n",
             (unsigned long)sdslen(info)));


Cluster: fixed MF condition in clusterHandleSlaveFailover().

For manual failover we need a manual failover in progress, and that
mf_can_start is true (master offset received and matched).

--- src/cluster.c
+++ src/cluster.c
@@ -2023,6 +2023,8 @@
     mstime_t data_age;
     mstime_t auth_age = mstime() - server.cluster->failover_auth_time;
     int needed_quorum = (server.cluster->size / 2) + 1;
+    int manual_failover = server.cluster->mf_end != 0 &&
+                          server.cluster->mf_can_start;
     int j;

     /* Pre conditions to run the function:
@@ -2031,8 +2033,10 @@
      * 3) It is serving slots. */
     if (nodeIsMaster(myself) ||
         myself->slaveof == NULL ||
-        (!nodeFailed(myself->slaveof) && server.cluster->mf_end == 0) ||
+        (!nodeFailed(myself->slaveof) && !manual_failover) ||
         myself->slaveof->numslots == 0) return;
+
+    /* If this is a manual failover, are we ready to start? */

     /* Set data_age to the number of seconds we are disconnected from
      * the master. */


client session BUGFIX useless check

client session BUGFIX useless check

--- src/session_client_tls.c
+++ src/session_client_tls.c
@@ -164,19 +164,15 @@
     free(opts->cert_path);
     free(opts->key_path);

-    if (client_cert) {
-        opts->cert_path = strdup(client_cert);
-        if (!opts->cert_path) {
-            ERRMEM;
-            return -1;
-        }
-    } else {
-        opts->cert_path = NULL;
+    opts->cert_path = strdup(client_cert);
+    if (!opts->cert_path) {
+        ERRMEM;
+        return -1;
     }

     if (client_key) {
         opts->key_path = strdup(client_key);
-        if (!opts->cert_path) {
+        if (!opts->key_path) {
             ERRMEM;
             return -1;
         }


* subversion/libsvn_fs_fs/transaction.c
  (store_p2l_index_entry): Remove unused FINAL_REVISION parameter.
  (rep_write_contents_close, write_container_rep, write_container_delta_rep,
   write_final_rev, write_final_changed_path_info): Adapt callers.

git-svn-id: f8a4e5e023278da1e04e203c7fe051e3c4285d88@1637358 13f79535-47bb-0310-9956-ffa450edef68

--- subversion/libsvn_fs_fs/transaction.c
+++ subversion/libsvn_fs_fs/transaction.c
@@ -1637,13 +1637,11 @@

 /* If the transaction TXN_ID in FS uses logical addressing, store ENTRY
  * in the phys-to-log proto index file of transaction TXN_ID.
- * If FINAL_REVISION is not SVN_INVALID_REVNUM, use it to determine whether
- * to actually write to the proto-index.  Use POOL for allocations.
+ * Use POOL for allocations.
  */
 static svn_error_t *
 store_p2l_index_entry(svn_fs_t *fs,
                       const svn_fs_fs__id_part_t *txn_id,
-                      svn_revnum_t final_revision,
                       svn_fs_fs__p2l_entry_t *entry,
                       apr_pool_t *pool)
 {
@@ -2325,8 +2323,8 @@
                                       b->scratch_pool));

       SVN_ERR(store_sha1_rep_mapping(b->fs, b->noderev, b->scratch_pool));
-      SVN_ERR(store_p2l_index_entry(b->fs, &rep->txn_id, SVN_INVALID_REVNUM,
-                                    &entry, b->scratch_pool));
+      SVN_ERR(store_p2l_index_entry(b->fs, &rep->txn_id, &entry,
+                                    b->scratch_pool));
     }

   SVN_ERR(svn_io_file_close(b->file, b->scratch_pool));
@@ -2583,8 +2581,7 @@
                                       fnv1a_checksum_ctx,
                                       scratch_pool));

-      SVN_ERR(store_p2l_index_entry(fs, &rep->txn_id, final_revision,
-                                    &entry, scratch_pool));
+      SVN_ERR(store_p2l_index_entry(fs, &rep->txn_id, &entry, scratch_pool));

       /* update the representation */
       rep->size = whb->size;
@@ -2727,8 +2724,7 @@
                                       fnv1a_checksum_ctx,
                                       scratch_pool));

-      SVN_ERR(store_p2l_index_entry(fs, &rep->txn_id, final_revision,
-                                    &entry, scratch_pool));
+      SVN_ERR(store_p2l_index_entry(fs, &rep->txn_id, &entry, scratch_pool));

       /* update the representation */
       rep->expanded_size = whb->size;
@@ -3065,7 +3061,7 @@
                                       fnv1a_checksum_ctx,
                                       pool));

-      SVN_ERR(store_p2l_index_entry(fs, txn_id, rev, &entry, pool));
+      SVN_ERR(store_p2l_index_entry(fs, txn_id, &entry, pool));
     }

   /* Return our ID that references the revision file. */
@@ -3117,7 +3113,7 @@
                                       fnv1a_checksum_ctx,
                                       pool));

-      SVN_ERR(store_p2l_index_entry(fs, txn_id, new_rev, &entry, pool));
+      SVN_ERR(store_p2l_index_entry(fs, txn_id, &entry, pool));
       SVN_ERR(store_l2p_index_entry(fs, txn_id, entry.offset,
                                     SVN_FS_FS__ITEM_INDEX_CHANGES, pool));
     }


Cluster: separate unknown master check from the rest.

In no case we should try to attempt to failover if myself->slaveof is
NULL.

--- src/cluster.c
+++ src/cluster.c
@@ -4176,9 +4176,12 @@
         if (nodeIsMaster(myself)) {
             addReplyError(c,"You should send CLUSTER FAILOVER to a slave");
             return;
+        } else if (myself->slaveof == NULL) {
+            addReplyError(c,"I'm a slave but my master is unknown to me");
+            return;
         } else if (!force &&
-                   (myself->slaveof == NULL || nodeFailed(myself->slaveof) ||
-                   myself->slaveof->link == NULL))
+                   (nodeFailed(myself->slaveof) ||
+                    myself->slaveof->link == NULL))
         {
             addReplyError(c,"Master is down or failed, "
                             "please use CLUSTER FAILOVER FORCE");


Increase SmallVector size for ConstantUniqueMap::getHashValue() (NFC)

This remove totally any malloc from this function on my
profile (from 155k before).

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@266700 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/IR/ConstantsContext.h
+++ lib/IR/ConstantsContext.h
@@ -557,7 +557,7 @@
       return ConstantClassInfo::getTombstoneKey();
     }
     static unsigned getHashValue(const ConstantClass *CP) {
-      SmallVector<Constant *, 8> Storage;
+      SmallVector<Constant *, 32> Storage;
       return getHashValue(LookupKey(CP->getType(), ValType(CP, Storage)));
     }
     static bool isEqual(const ConstantClass *LHS, const ConstantClass *RHS) {


Minor fix for toStereo.

Minor fix for toStereo.

--- src/siege/audio/buffer.c
+++ src/siege/audio/buffer.c
@@ -27,7 +27,7 @@
 #define ALBUF(x) (*(ALuint*)(x)->handle)

 // TODO: Move this to an util library; clean it up.
-static void* toStereo(SGuint channels, void* data, SGuint* datalen, ALuint* alformat)
+static void* toStereo(SGuint channels, void* data, size_t* datalen, ALuint* alformat)
 {
     void* odata = data;
     if(channels == 2)


* subversion/libsvn_fs_fs/transaction.c
  (verify_locks): Use svn_fspath__skip_ancestor() instead of
   svn_dirent_is_child().

git-svn-id: f8a4e5e023278da1e04e203c7fe051e3c4285d88@1646716 13f79535-47bb-0310-9956-ffa450edef68

--- subversion/libsvn_fs_fs/transaction.c
+++ subversion/libsvn_fs_fs/transaction.c
@@ -3224,7 +3224,7 @@
       /* If this path has already been verified as part of a recursive
          check of one of its parents, no need to do it again.  */
       if (last_recursed
-          && svn_dirent_is_child(last_recursed->data, path, iterpool))
+          && svn_fspath__skip_ancestor(last_recursed->data, path))
         continue;

       /* What does it mean to succeed at lock verification for a given


make specified options visible from scripts if it is overwrited.

--- src/cmd-run.c
+++ src/cmd-run.c
@@ -103,12 +103,16 @@
   int argc_;
   char** argv_;
   char** argv_gen;
+  struct opts* opt;
   if(script_frontend_sentinel)
     return cmd_script(argc,argv,cmd);
   script_frontend_sentinel=1;
   if(strcmp(argv[0],"--")==0)
     ++argv,--argc;
   cond_printf(1,"frontend:script_%s:argc=%d argv[0]=%s\n",cmd->name,argc,argv[0]);
+
+  for(opt=local_opt;opt;opt=opt->next)
+    opt->name=s_cat(q("*"),opt->name,NULL);
   if((in=fopen(argv[0],"rb"))!=NULL) {
     if(fgetc(in)!='#'||fgetc(in)!='!') {
       fclose(in);