aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils
diff options
context:
space:
mode:
authorMatej Kenda <[email protected]>2015-11-19 16:51:27 +0100
committerMatej Kenda <[email protected]>2015-11-19 16:51:27 +0100
commitfb103b7d1fe333b3d7424a36ea2f9b90df8b49ef (patch)
tree4606a4ba9cc981cc0d975f0ec7724d060424e5e1 /src/lib/utils
parent94d89769739ebe05e048f217b03672fb0c336fca (diff)
parent9bff61f4c577661bf4a62a860baf190d4ea8ed6a (diff)
Merge branch 'master' of github.com:randombit/botan into fix_algo_registry_locking_windows
Diffstat (limited to 'src/lib/utils')
-rw-r--r--src/lib/utils/calendar.cpp8
-rw-r--r--src/lib/utils/calendar.h4
-rw-r--r--src/lib/utils/database.h2
-rw-r--r--src/lib/utils/mul128.h12
-rw-r--r--src/lib/utils/sqlite3/sqlite3.cpp10
-rw-r--r--src/lib/utils/sqlite3/sqlite3.h2
6 files changed, 22 insertions, 16 deletions
diff --git a/src/lib/utils/calendar.cpp b/src/lib/utils/calendar.cpp
index f071a7328..73602d634 100644
--- a/src/lib/utils/calendar.cpp
+++ b/src/lib/utils/calendar.cpp
@@ -58,7 +58,7 @@ std::time_t boost_timegm(std::tm *tm)
using namespace boost::posix_time;
using namespace boost::gregorian;
const auto epoch = ptime(date(1970, 01, 01));
- const auto time = ptime(date(year, mon, day),
+ const auto time = ptime(date(year, mon, day),
hours(hour) + minutes(min) + seconds(sec));
const time_duration diff(time - epoch);
out = diff.ticks() / diff.ticks_per_second();
@@ -88,7 +88,7 @@ std::time_t fallback_timegm(std::tm *tm)
// Clear value of TZ
::setenv("TZ", "", 1);
::tzset();
-
+
out = ::mktime(tm);
// Restore TZ
@@ -113,10 +113,10 @@ std::time_t fallback_timegm(std::tm *tm)
}
-std::chrono::system_clock::time_point calendar_point::to_std_timepoint()
+std::chrono::system_clock::time_point calendar_point::to_std_timepoint() const
{
if (year < 1970)
- throw Invalid_Argument("calendar_point::to_std_timepoint() does not support years before 1990.");
+ throw Invalid_Argument("calendar_point::to_std_timepoint() does not support years before 1970.");
// 32 bit time_t ends at January 19, 2038
// https://msdn.microsoft.com/en-us/library/2093ets1.aspx
diff --git a/src/lib/utils/calendar.h b/src/lib/utils/calendar.h
index 0c87e62dd..a0b91f913 100644
--- a/src/lib/utils/calendar.h
+++ b/src/lib/utils/calendar.h
@@ -1,6 +1,6 @@
/*
* Calendar Functions
-* (C) 1999-2009 Jack Lloyd
+* (C) 1999-2009,2015 Jack Lloyd
* (C) 2015 Simon Warta (Kullo GmbH)
*
* Botan is released under the Simplified BSD License (see license.txt)
@@ -55,7 +55,7 @@ struct BOTAN_DLL calendar_point
/**
* Returns an STL timepoint object
*/
- std::chrono::system_clock::time_point to_std_timepoint();
+ std::chrono::system_clock::time_point to_std_timepoint() const;
/**
* Returns a human readable string of the struct's components.
diff --git a/src/lib/utils/database.h b/src/lib/utils/database.h
index 03a3174d6..bacbedd1e 100644
--- a/src/lib/utils/database.h
+++ b/src/lib/utils/database.h
@@ -36,7 +36,7 @@ class BOTAN_DLL SQL_Database
virtual size_t get_size_t(int column) = 0;
/* Run to completion */
- virtual void spin() = 0;
+ virtual size_t spin() = 0;
/* Maybe update */
virtual bool step() = 0;
diff --git a/src/lib/utils/mul128.h b/src/lib/utils/mul128.h
index 3ad7dbcdb..bcf5fa7ef 100644
--- a/src/lib/utils/mul128.h
+++ b/src/lib/utils/mul128.h
@@ -1,6 +1,6 @@
/*
* 64x64->128 bit multiply operation
-* (C) 2013 Jack Lloyd
+* (C) 2013,2015 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
@@ -12,13 +12,13 @@
namespace Botan {
-#if defined(__SIZEOF_INT128__)
- #define BOTAN_TARGET_HAS_NATIVE_UINT128
- typedef unsigned __int128 uint128_t;
-
-#elif (BOTAN_GCC_VERSION > 440) && defined(BOTAN_TARGET_CPU_HAS_NATIVE_64BIT)
+// Prefer TI mode over __int128 as GCC rejects the latter in pendantic mode
+#if (BOTAN_GCC_VERSION > 440) && defined(BOTAN_TARGET_CPU_HAS_NATIVE_64BIT)
#define BOTAN_TARGET_HAS_NATIVE_UINT128
typedef unsigned int uint128_t __attribute__((mode(TI)));
+#elif defined(__SIZEOF_INT128__)
+ #define BOTAN_TARGET_HAS_NATIVE_UINT128
+ typedef unsigned __int128 uint128_t;
#endif
}
diff --git a/src/lib/utils/sqlite3/sqlite3.cpp b/src/lib/utils/sqlite3/sqlite3.cpp
index be3c2b227..267d7530a 100644
--- a/src/lib/utils/sqlite3/sqlite3.cpp
+++ b/src/lib/utils/sqlite3/sqlite3.cpp
@@ -125,9 +125,15 @@ size_t Sqlite3_Database::Sqlite3_Statement::get_size_t(int column)
return static_cast<size_t>(sessions_int);
}
-void Sqlite3_Database::Sqlite3_Statement::spin()
+size_t Sqlite3_Database::Sqlite3_Statement::spin()
{
- while(step()) {}
+ size_t steps = 0;
+ while(step())
+ {
+ ++steps;
+ }
+
+ return steps;
}
bool Sqlite3_Database::Sqlite3_Statement::step()
diff --git a/src/lib/utils/sqlite3/sqlite3.h b/src/lib/utils/sqlite3/sqlite3.h
index 8495a1d1b..067b94e85 100644
--- a/src/lib/utils/sqlite3/sqlite3.h
+++ b/src/lib/utils/sqlite3/sqlite3.h
@@ -39,7 +39,7 @@ class BOTAN_DLL Sqlite3_Database : public SQL_Database
std::pair<const byte*, size_t> get_blob(int column) override;
size_t get_size_t(int column) override;
- void spin() override;
+ size_t spin() override;
bool step() override;
Sqlite3_Statement(sqlite3* db, const std::string& base_sql);