Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Leibowitz <mattleibow@live.com>2016-09-01 02:25:04 +0300
committerMatthew Leibowitz <mattleibow@live.com>2016-09-01 02:25:04 +0300
commit4ca0a0b853598bba647e92cc50f1ace82261c598 (patch)
treec7f91ba3a7424d5f7150ba252bb8c6c9988d59fb /mcs/class/Mono.Data.Sqlite
parent89ce2b94f3f9cec00446168096076499c1c1bde4 (diff)
[Mono.Data.Sqlite] Added iOS specific checks for entry point existence:
- using dlfcn.dlsym to avoid P/Invoke exceptions
Diffstat (limited to 'mcs/class/Mono.Data.Sqlite')
-rw-r--r--mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLite3.cs8
-rw-r--r--mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteBase.cs8
-rw-r--r--mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/UnsafeNativeMethods.cs10
3 files changed, 26 insertions, 0 deletions
diff --git a/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLite3.cs b/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLite3.cs
index 6f757238cd4..bf9a0fc03e9 100644
--- a/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLite3.cs
+++ b/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLite3.cs
@@ -125,9 +125,17 @@ namespace Mono.Data.Sqlite
// Compatibility with versions < 3.5.0
int n;
+#if MONOTOUCH
+ if (UnsafeNativeMethods.use_sqlite3_open_v2) {
+#else
try {
+#endif
n = UnsafeNativeMethods.sqlite3_open_v2(ToUTF8(strFilename), out db, (int)flags, IntPtr.Zero);
+#if MONOTOUCH
+ } else {
+#else
} catch (EntryPointNotFoundException) {
+#endif
Console.WriteLine ("Your sqlite3 version is old - please upgrade to at least v3.5.0!");
n = UnsafeNativeMethods.sqlite3_open (ToUTF8 (strFilename), out db);
}
diff --git a/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteBase.cs b/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteBase.cs
index df8a5d787ab..82f9baf6fc7 100644
--- a/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteBase.cs
+++ b/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/SQLiteBase.cs
@@ -208,9 +208,17 @@ namespace Mono.Data.Sqlite
#else
ResetConnection(db);
int n;
+#if MONOTOUCH
+ if (UnsafeNativeMethods.use_sqlite3_close_v2) {
+#else
try {
+#endif
n = UnsafeNativeMethods.sqlite3_close_v2(db);
+#if MONOTOUCH
+ } else {
+#else
} catch (EntryPointNotFoundException) {
+#endif
n = UnsafeNativeMethods.sqlite3_close(db);
}
#endif
diff --git a/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/UnsafeNativeMethods.cs b/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/UnsafeNativeMethods.cs
index ba16a1763ff..0d7947225cd 100644
--- a/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/UnsafeNativeMethods.cs
+++ b/mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite_2.0/UnsafeNativeMethods.cs
@@ -16,6 +16,16 @@ namespace Mono.Data.Sqlite
#endif
internal static class UnsafeNativeMethods
{
+#if MONOTOUCH
+ internal static bool use_sqlite3_close_v2 = false;
+ internal static bool use_sqlite3_open_v2 = false;
+ static UnsafeNativeMethods()
+ {
+ IntPtr lib = ObjCRuntime.Dlfcn.dlopen(SQLITE_DLL, 0);
+ use_sqlite3_open_v2 = ObjCRuntime.Dlfcn.dlsym(lib, "sqlite3_open_v2") != IntPtr.Zero;
+ use_sqlite3_close_v2 = ObjCRuntime.Dlfcn.dlsym(lib, "sqlite3_close_v2") != IntPtr.Zero;
+ }
+#endif
#if !SQLITE_STANDARD
#if !USE_INTEROP_DLL