[hyena] Windows: Specify CallingConvention everywhere (bgo#751045)
- From: Andrés Aragoneses <aaragoneses src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hyena] Windows: Specify CallingConvention everywhere (bgo#751045)
- Date: Mon, 6 Jul 2015 19:26:12 +0000 (UTC)
commit 149759461277da3b8bd08895bcb76738d6568b5a
Author: Andrés G. Aragoneses <knocte gmail com>
Date: Mon Jul 6 21:04:04 2015 +0200
Windows: Specify CallingConvention everywhere (bgo#751045)
The default CallingConvention is WinAPI, which defaults to
the system's convention which might either be StdCall or CDecl.
For C libraries the CallingConvention to use is CDecl
else strange runtime errors might occur because of stack
corruption.
Since we are using C libraries only, specify the CDecl
CallingConvention everywhere.
On Windows the MDA in Visual Studio would detect a wrong
calling convention (mono has no such detection).
Hyena.Data.Sqlite/Hyena.Data.Sqlite/Sqlite.cs | 96 ++++++++++++------------
Hyena.Gui/Hyena.Gui/PixbufImageSurface.cs | 2 +-
Hyena/Hyena/ApplicationContext.cs | 4 +-
Hyena/Hyena/ConsoleCrayon.cs | 2 +-
Hyena/Hyena/PlatformDetection.cs | 2 +-
Hyena/Hyena/SafeUri.cs | 8 +-
6 files changed, 57 insertions(+), 57 deletions(-)
---
diff --git a/Hyena.Data.Sqlite/Hyena.Data.Sqlite/Sqlite.cs b/Hyena.Data.Sqlite/Hyena.Data.Sqlite/Sqlite.cs
index 1c38139..ae70d45 100644
--- a/Hyena.Data.Sqlite/Hyena.Data.Sqlite/Sqlite.cs
+++ b/Hyena.Data.Sqlite/Hyena.Data.Sqlite/Sqlite.cs
@@ -548,151 +548,151 @@ namespace Hyena.Data.Sqlite
const string SQLITE_DLL = "sqlite3";
// Connection functions
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_open(byte [] utf8DbPath, out IntPtr db);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_close(IntPtr db);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern long sqlite3_last_insert_rowid (IntPtr db);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_busy_timeout(IntPtr db, int ms);
- [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)]
+ [DllImport (SQLITE_DLL, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr sqlite3_errmsg16(IntPtr db);
- [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)]
+ [DllImport (SQLITE_DLL, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_create_function16(IntPtr db, string strName, int nArgs, int
eTextRep, IntPtr app, SqliteCallback func, SqliteCallback funcstep, SqliteFinalCallback funcfinal);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_aggregate_count(IntPtr context);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr sqlite3_aggregate_context(IntPtr context, int nBytes);
- [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)]
+ [DllImport (SQLITE_DLL, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_create_collation16(IntPtr db, string strName, int eTextRep,
IntPtr ctx, SqliteCollation fcompare);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_extended_result_codes (IntPtr db, int onoff);
// Statement functions
- [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)]
+ [DllImport (SQLITE_DLL, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_prepare16_v2(IntPtr db, string pSql, int nBytes, out IntPtr stmt,
out IntPtr ptrRemain);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_step(IntPtr stmt);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_column_count(IntPtr stmt);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr sqlite3_column_name16(IntPtr stmt, int index);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_column_type(IntPtr stmt, int iCol);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr sqlite3_column_blob(IntPtr stmt, int iCol);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_column_bytes(IntPtr stmt, int iCol);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern double sqlite3_column_double(IntPtr stmt, int iCol);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern long sqlite3_column_int64(IntPtr stmt, int iCol);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr sqlite3_column_text16(IntPtr stmt, int iCol);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_finalize(IntPtr stmt);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_reset(IntPtr stmt);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_exec(IntPtr db, byte [] sql, IntPtr callback, IntPtr cbArg,
IntPtr errPtr);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_bind_parameter_index(IntPtr stmt, byte [] paramName);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_bind_parameter_count(IntPtr stmt);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_bind_blob(IntPtr stmt, int param, byte[] val, int nBytes, IntPtr
destructorType);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_bind_double(IntPtr stmt, int param, double val);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_bind_int(IntPtr stmt, int param, int val);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_bind_int64(IntPtr stmt, int param, long val);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_bind_null(IntPtr stmt, int param);
- [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)]
+ [DllImport (SQLITE_DLL, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_bind_text16 (IntPtr stmt, int param, string val, int numBytes,
IntPtr destructorType);
- //DllImport(SQLITE_DLL)]
+ //DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
//internal static extern int sqlite3_bind_zeroblob(IntPtr stmt, int, int n);
// Context functions
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern void sqlite3_result_blob(IntPtr context, byte[] value, int nSize, IntPtr
pvReserved);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern void sqlite3_result_double(IntPtr context, double value);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern void sqlite3_result_error(IntPtr context, byte[] strErr, int nLen);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern void sqlite3_result_int(IntPtr context, int value);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern void sqlite3_result_int64(IntPtr context, Int64 value);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern void sqlite3_result_null(IntPtr context);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern void sqlite3_result_text(IntPtr context, byte[] value, int nLen, IntPtr
pvReserved);
- [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)]
+ [DllImport (SQLITE_DLL, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
internal static extern void sqlite3_result_error16(IntPtr context, string strName, int nLen);
- [DllImport(SQLITE_DLL, CharSet = CharSet.Unicode)]
+ [DllImport (SQLITE_DLL, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
internal static extern void sqlite3_result_text16(IntPtr context, string strName, int nLen, IntPtr
pvReserved);
// Value methods
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr sqlite3_value_blob(IntPtr p);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_value_bytes(IntPtr p);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern double sqlite3_value_double(IntPtr p);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_value_int(IntPtr p);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern Int64 sqlite3_value_int64(IntPtr p);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern int sqlite3_value_type(IntPtr p);
- [DllImport(SQLITE_DLL)]
+ [DllImport (SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr sqlite3_value_text16(IntPtr p);
internal static string PtrToString (this IntPtr ptr)
diff --git a/Hyena.Gui/Hyena.Gui/PixbufImageSurface.cs b/Hyena.Gui/Hyena.Gui/PixbufImageSurface.cs
index a733802..236c940 100644
--- a/Hyena.Gui/Hyena.Gui/PixbufImageSurface.cs
+++ b/Hyena.Gui/Hyena.Gui/PixbufImageSurface.cs
@@ -177,7 +177,7 @@ namespace Hyena.Gui
return (byte)(((t >> 8) + t) >> 8);
}
- [DllImport ("libcairo-2.dll")]
+ [DllImport ("libcairo-2.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern Cairo.Status cairo_surface_set_user_data (IntPtr surface,
ref int key, IntPtr userdata, cairo_destroy_func_t destroy);
diff --git a/Hyena/Hyena/ApplicationContext.cs b/Hyena/Hyena/ApplicationContext.cs
index 88c0bf0..bbf61e3 100644
--- a/Hyena/Hyena/ApplicationContext.cs
+++ b/Hyena/Hyena/ApplicationContext.cs
@@ -91,10 +91,10 @@ namespace Hyena
get { return CultureInfo.InvariantCulture; }
}
- [DllImport ("libc")] // Linux
+ [DllImport ("libc", CallingConvention = CallingConvention.Cdecl)] // Linux
private static extern int prctl (int option, byte [] arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5);
- [DllImport ("libc")] // BSD
+ [DllImport ("libc", CallingConvention = CallingConvention.Cdecl)] // BSD
private static extern void setproctitle (byte [] fmt, byte [] str_arg);
private static void SetProcessName (string name)
diff --git a/Hyena/Hyena/ConsoleCrayon.cs b/Hyena/Hyena/ConsoleCrayon.cs
index c55dcd3..3ebd967 100644
--- a/Hyena/Hyena/ConsoleCrayon.cs
+++ b/Hyena/Hyena/ConsoleCrayon.cs
@@ -143,7 +143,7 @@ namespace Hyena
}
}
- [System.Runtime.InteropServices.DllImport ("libc", EntryPoint="isatty")]
+ [System.Runtime.InteropServices.DllImport ("libc", EntryPoint="isatty", CallingConvention =
CallingConvention.Cdecl)]
private extern static int _isatty (int fd);
private static bool isatty (int fd)
diff --git a/Hyena/Hyena/PlatformDetection.cs b/Hyena/Hyena/PlatformDetection.cs
index 17c5a75..672f8a1 100644
--- a/Hyena/Hyena/PlatformDetection.cs
+++ b/Hyena/Hyena/PlatformDetection.cs
@@ -41,7 +41,7 @@ namespace Hyena
public static readonly string PosixSystemName;
public static readonly string SystemName;
- [DllImport ("libc")]
+ [DllImport ("libc", CallingConvention = CallingConvention.Cdecl)]
private static extern int uname (IntPtr utsname);
static PlatformDetection ()
diff --git a/Hyena/Hyena/SafeUri.cs b/Hyena/Hyena/SafeUri.cs
index d0221ce..d8072df 100644
--- a/Hyena/Hyena/SafeUri.cs
+++ b/Hyena/Hyena/SafeUri.cs
@@ -204,16 +204,16 @@ namespace Hyena
const string GLIB_DLL = "libglib-2.0-0.dll";
- [DllImport (GLIB_DLL)]
+ [DllImport (GLIB_DLL, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr g_filename_to_uri_utf8 (IntPtr filename, IntPtr hostname, IntPtr error);
- [DllImport (GLIB_DLL)]
+ [DllImport (GLIB_DLL, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr g_filename_from_uri_utf8 (IntPtr uri, IntPtr hostname, IntPtr error);
- [DllImport (GLIB_DLL)]
+ [DllImport (GLIB_DLL, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr g_filename_to_uri (IntPtr filename, IntPtr hostname, IntPtr error);
- [DllImport (GLIB_DLL)]
+ [DllImport (GLIB_DLL, CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr g_filename_from_uri (IntPtr uri, IntPtr hostname, IntPtr error);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]