Commit bf82a889 authored by rswindell's avatar rswindell

Use default calling convention (__cdecl) for DLL funcs in Borland builds.

Fix age-old bug with Borland/C++Builder built executables (Windows):
to achieve compatibility with  the default __cdecl symbol naming rules of
Visual C++, we were using __stdcall convention for DLL functions when
building code with Borland/C++Builder tools and using the default (__cdecl)
convention when building with Microsoft (Visual C++) tools. Although this
allowed symbols to be located when linking, the calling convention mismatch
caused a stack cleanup issue that very rarely manifested itself in a bug
(e.g. exception of some kind in sbbsctrl.exe, usually). Mismatching
the calling conventions was unintentional (I thought the default for MSVC
DLL functions was __stdcall) - but since the calls to MSVC-Built DLL functions
worked 99% of the time, I didn't realize there was an underlying issue. So I
now work-around the DLL symbol naming mismatch using a command-line option (-a)
passed to implib in src/sbbs3/ctrl/makelibs.bat

I had previously worked-around exceptions when calling MSVC DLL functions in
sbbsctrl.exe by calling the problematic DLL functions from a timer tick handler
rather than a user control (e.g. button) event handler. Those work-arounds can
now be removed.

The erroneous "DLLCALL" definition design pattern was replicated (copy/pasted)
to many other projects' header files in cvs.synchro.net. In the future, we may
want to just remove all instances of *CALL since they now serve no purpose and
appear as useless "Kruft" (but do allow us to more-easily globally change DLL
function calling conventions if/when necessary in the future).
parent 629a9162
......@@ -44,7 +44,7 @@
#ifdef _WIN32
#ifdef __BORLANDC__
#define COMIOCALL __stdcall
#define COMIOCALL
#else
#define COMIOCALL
#endif
......
......@@ -43,7 +43,7 @@
#ifdef _WIN32
#ifdef __BORLANDC__
#define CIOLIBCALL __stdcall
#define CIOLIBCALL
#else
#define CIOLIBCALL
#endif
......
......@@ -43,7 +43,7 @@
#define B64EXPORT __declspec(dllexport)
#endif
#if defined(__BORLANDC__)
#define B64CALL __stdcall
#define B64CALL
#else
#define B64CALL
#endif
......
......@@ -40,7 +40,7 @@
#ifdef _WIN32
#ifdef __BORLANDC__
#define LZHCALL __stdcall
#define LZHCALL
#else
#define LZHCALL
#endif
......
......@@ -48,7 +48,7 @@
#define CRCEXPORT __declspec(dllexport)
#endif
#if defined(__BORLANDC__)
#define CRCCALL __stdcall
#define CRCCALL
#else
#define CRCCALL
#endif
......
......@@ -55,7 +55,7 @@ typedef struct
#define MD5EXPORT __declspec(dllexport)
#endif
#if defined(__BORLANDC__)
#define MD5CALL __stdcall
#define MD5CALL
#else
#define MD5CALL
#endif
......
......@@ -8,8 +8,8 @@ if '%1'=='' goto implib
set dllsrc=%1
:implib
echo Creating import libraries from %dllsrc%
implib sbbs.lib %dllsrc%\sbbs.dll
implib mailsrvr.lib %dllsrc%\mailsrvr.dll
implib ftpsrvr.lib %dllsrc%\ftpsrvr.dll
implib websrvr.lib %dllsrc%\websrvr.dll
implib services.lib %dllsrc%\services.dll
\ No newline at end of file
implib -a sbbs.lib %dllsrc%\sbbs.dll
implib -a mailsrvr.lib %dllsrc%\mailsrvr.dll
implib -a ftpsrvr.lib %dllsrc%\ftpsrvr.dll
implib -a websrvr.lib %dllsrc%\websrvr.dll
implib -a services.lib %dllsrc%\services.dll
\ No newline at end of file
......@@ -56,7 +56,7 @@
#define DLLEXPORT __declspec(dllimport)
#endif
#ifdef __BORLANDC__
#define DLLCALL __stdcall
#define DLLCALL
#else
#define DLLCALL
#endif
......
......@@ -169,7 +169,7 @@ static ini_bitdesc_t ftp_options[] = {
#define DLLEXPORT __declspec(dllimport)
#endif
#ifdef __BORLANDC__
#define DLLCALL __stdcall
#define DLLCALL
#else
#define DLLCALL
#endif
......
......@@ -6,19 +6,6 @@
#include <genwrap.h> /* SLEEP() */
#include <link_list.h>
#ifdef DLLCALL
#undef DLLCALL
#endif
#ifdef _WIN32
#ifdef __BORLANDC__
#define DLLCALL __stdcall
#else
#define DLLCALL
#endif
#else /* !_WIN32 */
#define DLLCALL
#endif
static pthread_mutex_t jsrt_mutex;
static int initialized=0;
static link_list_t rt_list;
......
......@@ -24,7 +24,7 @@
#define DLLEXPORT __declspec(dllimport)
#endif
#ifdef __BORLANDC__
#define DLLCALL __stdcall
#define DLLCALL
#else
#define DLLCALL
#endif
......
......@@ -235,7 +235,7 @@ static ini_bitdesc_t mail_options[] = {
#define DLLEXPORT __declspec(dllimport)
#endif
#ifdef __BORLANDC__
#define DLLCALL __stdcall
#define DLLCALL
#else
#define DLLCALL
#endif
......
......@@ -1033,7 +1033,7 @@ public:
#define DLLEXPORT __declspec(dllimport)
#endif
#ifdef __BORLANDC__
#define DLLCALL __stdcall
#define DLLCALL
#else
#define DLLCALL
#endif
......
......@@ -144,7 +144,7 @@ extern "C" {
#define DLLEXPORT __declspec(dllimport)
#endif
#ifdef __BORLANDC__
#define DLLCALL __stdcall
#define DLLCALL
#else
#define DLLCALL
#endif
......
......@@ -19,7 +19,7 @@
#define DLLEXPORT __declspec(dllimport)
#endif
#ifdef __BORLANDC__
#define DLLCALL __stdcall
#define DLLCALL
#else
#define DLLCALL
#endif
......
......@@ -243,7 +243,7 @@ extern "C" {
#define DLLEXPORT __declspec(dllimport)
#endif
#ifdef __BORLANDC__
#define DLLCALL __stdcall
#define DLLCALL
#else
#define DLLCALL
#endif
......
......@@ -157,7 +157,7 @@ enum {
#define DLLEXPORT
#endif
#ifdef __BORLANDC__
#define DLLCALL __stdcall
#define DLLCALL
#else
#define DLLCALL
#endif
......
......@@ -58,7 +58,7 @@
#define DLLEXPORT __declspec(dllimport)
#endif
#ifdef __BORLANDC__
#define DLLCALL __stdcall
#define DLLCALL
#else
#define DLLCALL
#endif
......
......@@ -173,7 +173,7 @@ static ini_bitdesc_t web_options[] = {
#define DLLEXPORT __declspec(dllimport)
#endif
#ifdef __BORLANDC__
#define DLLCALL __stdcall
#define DLLCALL
#else
#define DLLCALL
#endif
......
......@@ -45,7 +45,7 @@
#ifdef _WIN32
#ifdef __BORLANDC__
#define SMBCALL __stdcall
#define SMBCALL
#else
#define SMBCALL
#endif
......
......@@ -53,7 +53,7 @@
#ifdef _WIN32
#ifdef __BORLANDC__
#define UIFCCALL __stdcall
#define UIFCCALL
#else
#define UIFCCALL
#endif
......
......@@ -49,7 +49,7 @@
#define DLLEXPORT __declspec(dllexport)
#endif
#if defined(__BORLANDC__)
#define DLLCALL __stdcall
#define DLLCALL
#else
#define DLLCALL
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment