diff options
Diffstat (limited to 'winsup/mingw/samples/dlltest')
-rw-r--r-- | winsup/mingw/samples/dlltest/dll.c | 22 | ||||
-rw-r--r-- | winsup/mingw/samples/dlltest/dll.def | 3 | ||||
-rw-r--r-- | winsup/mingw/samples/dlltest/dll.h | 4 | ||||
-rw-r--r-- | winsup/mingw/samples/dlltest/exe.c | 23 | ||||
-rw-r--r-- | winsup/mingw/samples/dlltest/exe.exp | 8 | ||||
-rw-r--r-- | winsup/mingw/samples/dlltest/expexe.c | 17 | ||||
-rw-r--r-- | winsup/mingw/samples/dlltest/expexe.def | 2 | ||||
-rw-r--r-- | winsup/mingw/samples/dlltest/jamfile | 46 | ||||
-rw-r--r-- | winsup/mingw/samples/dlltest/loaddll.c | 40 | ||||
-rw-r--r-- | winsup/mingw/samples/dlltest/loadexe.c | 47 | ||||
-rw-r--r-- | winsup/mingw/samples/dlltest/readme.txt | 39 | ||||
-rw-r--r-- | winsup/mingw/samples/dlltest/silly.cpp | 55 | ||||
-rw-r--r-- | winsup/mingw/samples/dlltest/silly.def | 11 | ||||
-rw-r--r-- | winsup/mingw/samples/dlltest/silly.exp | 8 | ||||
-rw-r--r-- | winsup/mingw/samples/dlltest/silly.h | 27 | ||||
-rw-r--r-- | winsup/mingw/samples/dlltest/sillydll.cpp | 107 |
16 files changed, 0 insertions, 459 deletions
diff --git a/winsup/mingw/samples/dlltest/dll.c b/winsup/mingw/samples/dlltest/dll.c deleted file mode 100644 index 257b1b8ff..000000000 --- a/winsup/mingw/samples/dlltest/dll.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Source code of the functions inside our test DLL. Note that DllMain is - * not required (it will be provided by the stub in libmingw32.a). - */ - -#if 0 -#include <windows.h> -#endif - -int Add (int x, int y) -{ - printf ("In add!\nx = %d\ny = %d\n", x, y); - return (x + y); -} - - -double __attribute__((stdcall)) Sub (double x, double y) -{ - printf ("In sub!\nx = %f\ny = %f\n", x, y); - return (x - y); -} - diff --git a/winsup/mingw/samples/dlltest/dll.def b/winsup/mingw/samples/dlltest/dll.def deleted file mode 100644 index b20a405d8..000000000 --- a/winsup/mingw/samples/dlltest/dll.def +++ /dev/null @@ -1,3 +0,0 @@ -EXPORTS -Add -Sub@16 diff --git a/winsup/mingw/samples/dlltest/dll.h b/winsup/mingw/samples/dlltest/dll.h deleted file mode 100644 index 8fac5332b..000000000 --- a/winsup/mingw/samples/dlltest/dll.h +++ /dev/null @@ -1,4 +0,0 @@ - -int Add (int x, int y); -double __attribute__((stdcall)) Sub (double x, double y); - diff --git a/winsup/mingw/samples/dlltest/exe.c b/winsup/mingw/samples/dlltest/exe.c deleted file mode 100644 index d778348e4..000000000 --- a/winsup/mingw/samples/dlltest/exe.c +++ /dev/null @@ -1,23 +0,0 @@ -#include <stdio.h> - -#include "dll.h" - -int main() -{ - int i, j, k; - double dk; - - i = 10; - j = 13; - - k = Add(i, j); - - printf ("%d + %d = %d\n", i, j, k); - - dk = Sub(i, j); - - printf ("%d - %d = %f\n", i, j, dk); - - return 0; -} - diff --git a/winsup/mingw/samples/dlltest/exe.exp b/winsup/mingw/samples/dlltest/exe.exp deleted file mode 100644 index 887fdb0ac..000000000 --- a/winsup/mingw/samples/dlltest/exe.exp +++ /dev/null @@ -1,8 +0,0 @@ -In add! -x = 10 -y = 13 -10 + 13 = 23 -In sub! -x = 10 -y = 13 -10 - 13 = -3 diff --git a/winsup/mingw/samples/dlltest/expexe.c b/winsup/mingw/samples/dlltest/expexe.c deleted file mode 100644 index d94ea1e7e..000000000 --- a/winsup/mingw/samples/dlltest/expexe.c +++ /dev/null @@ -1,17 +0,0 @@ - -#include <stdio.h> - -int -ExportedFromExe () -{ - printf ("This output produced by ExportedFromExe.\n"); - return 0; -} - -int main() -{ - printf ("Hello, world\n"); - - return 0; -} - diff --git a/winsup/mingw/samples/dlltest/expexe.def b/winsup/mingw/samples/dlltest/expexe.def deleted file mode 100644 index 309f1508f..000000000 --- a/winsup/mingw/samples/dlltest/expexe.def +++ /dev/null @@ -1,2 +0,0 @@ -EXPORTS -ExportedFromExe diff --git a/winsup/mingw/samples/dlltest/jamfile b/winsup/mingw/samples/dlltest/jamfile deleted file mode 100644 index 5278d0379..000000000 --- a/winsup/mingw/samples/dlltest/jamfile +++ /dev/null @@ -1,46 +0,0 @@ -
-# This option is required to successfully return doubles via STDCALL as in
-# Sub function in dll.c.
-CCFLAGS = -mno-fp-ret-in-387 ;
-
-Main exe.exe : exe.c ;
-
-LinkLibraries exe.exe : libdll.a ;
-
-DEPENDS exe.exe : dll.dll ;
-
-LINKFLAGS on exe.exe = $(LINKFLAGS) -L. ;
-
-
-Main loaddll.exe : loaddll.c ;
-
-DEPENDS loaddll.exe : dll.dll ;
-
-
-Dll dll.dll : dll.c ;
-
-ImportLib libdll.a : dll.def ;
-
-
-Main expexe.exe : expexe.c ;
-
-# Force the executable to include the expexe.def file.
-Exports expexe.exe : expexe.def ;
-
-Main loadexe.exe : loadexe.c ;
-
-DEPENDS loadexe.exe : expexe.exe ;
-
-
-Main silly.exe : silly.cpp ;
-
-LinkLibraries silly.exe : libsilly.a ;
-
-DEPENDS silly.exe : silly.dll ;
-
-LINKFLAGS on silly.exe += -L. ;
-
-Dll silly.dll : sillydll.cpp ;
-
-ImportLib libsilly.a : silly.def ;
-
diff --git a/winsup/mingw/samples/dlltest/loaddll.c b/winsup/mingw/samples/dlltest/loaddll.c deleted file mode 100644 index ec69c9a7e..000000000 --- a/winsup/mingw/samples/dlltest/loaddll.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This version attempts to load dll.dll dynamically, get the address of the - * Add function, and then call it. - */ - -#include <stdio.h> -#include <windows.h> - -int (*Add)(int x, int y); - -int main() -{ - HINSTANCE hDll; - int i, j, k; - - hDll = LoadLibrary ("dll.dll"); - if (!hDll) - { - printf ("Error %d loading dll.\n", GetLastError()); - exit (-1); - } - - if (!(Add = GetProcAddress (hDll, "Add"))) - { - printf ("Error %d getting Add function.\n", GetLastError()); - exit (-1); - } - - i = 10; - j = 13; - - k = Add(i, j); - - printf ("i %d, j %d, k %d\n", i, j, k); - - FreeLibrary (hDll); - - return 0; -} - diff --git a/winsup/mingw/samples/dlltest/loadexe.c b/winsup/mingw/samples/dlltest/loadexe.c deleted file mode 100644 index 2ee4e8483..000000000 --- a/winsup/mingw/samples/dlltest/loadexe.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This program attempts to load expexe.exe dynamically, get the address of the - * ExportedFromExe function, and then call it. - * - * This example DOES NOT WORK! I don't know exactly what can be done, but - * it simply seems that LoadLibrary refuses to load executables. - */ - -#include <stdio.h> -#include <windows.h> - -int (*ExportedFromExe)(); - -int main() -{ - HINSTANCE hDll; - int i, j, k; - - hDll = LoadLibrary ("expexe.exe"); - if (!hDll) - { - printf ("Error %d loading exe.\n", GetLastError()); - exit (-1); - } - - if (!(ExportedFromExe = GetProcAddress (hDll, "ExportedFromExe"))) - { - printf ("Error %d getting ExportedFromExe function.\n", - GetLastError()); - exit (-1); - } - else - { - ExportedFromExe (); - } - - /* NOTE: Unlike a DLL the exe doesn't have an entry point which - * initializes global objects and adds __do_global_dtors to - * the atexit list. Thus it should be safe(?) to free the - * library. Of course, this also makes it unsafe to use - * executables at all in this manner. - */ - FreeLibrary (hDll); - - return 0; -} - diff --git a/winsup/mingw/samples/dlltest/readme.txt b/winsup/mingw/samples/dlltest/readme.txt deleted file mode 100644 index 3d3101326..000000000 --- a/winsup/mingw/samples/dlltest/readme.txt +++ /dev/null @@ -1,39 +0,0 @@ -This directory contains two examples of building DLLs. The exe.c and dll.c -files are used to build a very simple example DLL with a function that -adds two numbers together (and prints some text at the same time). The -exe.c program links to the DLL and prints the results of the function -call. - -The C++ example "silly" is more interesting because it involves a DLL which -contains the code for a C++ class. The CSilly class has all of its code in -the sillydll.cpp source file, which is used to build the silly.dll. The -silly.cpp source code builds the main silly.exe executable which makes a -dynamic instance of the object and calls its member functions. - -The C++ silly.def file was generated by doing a nm of sillydll.o after it -was generated and then getting the symbol names from that. Removing the -leading underscore produces the appropriate name to include in the EXPORTS -section. Notice there are a few weird functions. - -Since there are now several different versions of the GNU compiler capable -of doing this, and they each seem to have different requirements for exports -for classes, it has gotten kind of messy. The silly.def file here is for -use with the native Mingw32 build of the EGCS version of GCC. The silly.def.old -file was the def file I used when I was using Jan-Jaap's Mingw32 native port -of GCC. The Cygnus version is different again, if I recall correctly, but I -don't have it hanging around anymore. - -The jamfile builds all the components from the raw sources. - -The expected output of exe.exe and silly.exe are in the files exe.exp -and silly.exp. - - -The source code in this directory is in the PUBLIC DOMAIN and can be -used or abused as you see fit. There is NO WARRANTY for this code, -including (but not limited to) implied warranties of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. - - -Colin Peters <colin@bird.fu.is.saga-u.ac.jp> - diff --git a/winsup/mingw/samples/dlltest/silly.cpp b/winsup/mingw/samples/dlltest/silly.cpp deleted file mode 100644 index ee9e1fe77..000000000 --- a/winsup/mingw/samples/dlltest/silly.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// -// C++ test of a dll which contains a C++ class. -// - -#include <stdlib.h> -#include <stdio.h> - -// Interface of class. -#include "silly.h" - -#ifdef DERIVED_TEST -// Here is a derived class too. -class CMoreSilly : public CSilly -{ - public: - CMoreSilly (char* szNewName) : CSilly (szNewName) {}; - ~CMoreSilly (); - - WhatsYourName(); -}; - -CMoreSilly:: -~CMoreSilly () -{ - printf ("In CMoreSilly \"%s\" destructor!\n", szName); -} - -CMoreSilly:: -WhatsYourName () -{ - printf ("I'm more silly and my name is \"%s\"\n", szName); -} -#endif - -int -main () -{ - CSilly* psilly = new CSilly("silly"); - - psilly->WhatsYourName(); - psilly->Poke(); // Poke him, he should say "Ouch!" - psilly->Stab(4); // Stab him four times he should say "Ugh!!!!" - - delete psilly; - -#ifdef DERIVED_TEST - psilly = new CMoreSilly("more silly"); - psilly->WhatsYourName(); - psilly->Stab(5); - delete psilly; -#endif - - return 0; -} - diff --git a/winsup/mingw/samples/dlltest/silly.def b/winsup/mingw/samples/dlltest/silly.def deleted file mode 100644 index a766ff94f..000000000 --- a/winsup/mingw/samples/dlltest/silly.def +++ /dev/null @@ -1,11 +0,0 @@ -EXPORTS -DllMain@12 -Poke__6CSilly -Stab__6CSillyi -WhatsYourName__6CSilly -_$_6CSilly -__6CSilly -__6CSillyPc -__tf6CSilly -__ti6CSilly -_vt$6CSilly diff --git a/winsup/mingw/samples/dlltest/silly.exp b/winsup/mingw/samples/dlltest/silly.exp deleted file mode 100644 index ab544f97f..000000000 --- a/winsup/mingw/samples/dlltest/silly.exp +++ /dev/null @@ -1,8 +0,0 @@ -I'm silly. -Ouch! -Ugh!!!! -In CSilly destructor. -I'm more silly and my name is "more silly" -Ugh!!!!! -In CMoreSilly "more silly" destructor! -In CSilly destructor. diff --git a/winsup/mingw/samples/dlltest/silly.h b/winsup/mingw/samples/dlltest/silly.h deleted file mode 100644 index d3f99bed8..000000000 --- a/winsup/mingw/samples/dlltest/silly.h +++ /dev/null @@ -1,27 +0,0 @@ - -#define DERIVED_TEST 1 - -class CSilly -{ - protected: - char* szName; - - public: - CSilly(); - CSilly(char* szName); -#ifdef DERIVED_TEST - virtual ~CSilly(); -#else - ~CSilly(); -#endif - - Poke (); - Stab (int nTimes); -#ifdef DERIVED_TEST - virtual WhatsYourName (); -#else - WhatsYourName (); -#endif - -}; - diff --git a/winsup/mingw/samples/dlltest/sillydll.cpp b/winsup/mingw/samples/dlltest/sillydll.cpp deleted file mode 100644 index 87385e584..000000000 --- a/winsup/mingw/samples/dlltest/sillydll.cpp +++ /dev/null @@ -1,107 +0,0 @@ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <windows.h> - - -#if 0 -#define STREAMS_VERSION -#endif - -#if defined(STREAMS_VERSION) -#include <iostream.h> -#endif - -#include "silly.h" - -extern "C" -BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved) -{ - return TRUE; -} - -CSilly:: -CSilly() -{ - szName = NULL; -} - -CSilly:: -CSilly(char* new_szName) -{ - szName = new char[strlen(new_szName)+1]; - - if (szName) - { - strcpy (szName, new_szName); - } -} - -CSilly:: -~CSilly() -{ - printf ("In CSilly destructor.\n"); - if (szName) - { - delete szName; - } -} - -CSilly:: -Poke () -{ -#ifndef STREAMS_VERSION - printf ("Ouch!\n"); -#else - cout << "Ouch!" << endl; -#endif -} - -CSilly:: -Stab (int nTimes) -{ -#ifndef STREAMS_VERSION - printf ("Ugh"); -#else - cout << "Ugh"; -#endif - - int i; - for (i = 0; i < nTimes; i++) - { -#ifndef STREAMS_VERSION - putchar('!'); -#else - cout << '!' ; -#endif - } - -#ifndef STREAMS_VERSION - putchar('\n'); -#else - cout << endl; -#endif -} - -CSilly:: -WhatsYourName () -{ - if (szName) - { -#ifndef STREAMS_VERSION - printf ("I'm %s.\n", szName); -#else - cout << "I'm " << szName << "." << endl; -#endif - } - else - { -#ifndef STREAMS_VERSION - printf ("I have no name.\n"); -#else - cout << "I have no name." << endl; -#endif - } -} - |