00001
00002
00003
00004
00005
00006
00007 #define DLMAIN
00008 #define MAJOR 2
00009 #define MINOR 0
00010
00011 #include <stdlib.h>
00012 #include "gridlabd.h"
00013
00014 EXPORT int do_kill(void*);
00015
00016 EXPORT int major=MAJOR, minor=MINOR;
00017
00018 #ifdef WIN32
00019
00020 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
00021 #include <windows.h>
00022 BOOL APIENTRY DllMain( HANDLE hModule,
00023 DWORD ul_reason_for_call,
00024 LPVOID
00025 )
00026 {
00027 switch (ul_reason_for_call)
00028 {
00029 case DLL_PROCESS_ATTACH:
00030 case DLL_THREAD_ATTACH:
00031 break;
00032 case DLL_THREAD_DETACH:
00033 case DLL_PROCESS_DETACH:
00034 do_kill(hModule);
00035 break;
00036 }
00037 return TRUE;
00038 }
00039
00040 #else // !WIN32
00041
00042 CDECL int dllinit() __attribute__((constructor));
00043 CDECL int dllkill() __attribute__((destructor));
00044
00045 CDECL int dllinit()
00046 {
00047 return 0;
00048 }
00049
00050 CDECL int dllkill() {
00051 do_kill(NULL);
00052 }
00053
00054 #endif // !WIN32