From 1770f4dc7818b0e24871fddf80aaed67ff71cea6 Mon Sep 17 00:00:00 2001 From: fedor Date: Wed, 11 Oct 2000 18:49:32 +0000 Subject: [PATCH] Initialize Window sockets git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@7795 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 +++++++ Source/GNUmakefile | 2 +- Source/NSObject.m | 7 +++++++ Source/libgnustep-base-entry.m | 19 +++++++++++++++---- Source/libgnustep-base.def | 1 + 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac61afde3..68c16eeca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2000-10-11 Adam Fedor + + * Source/NSObject.m (+initialize): Initialize Window sockets + on MINGW. + * Source/libgnustep-base-entry.m (gnustep_base_socket_init): + New function. + 2000-10-10 Richard Frith-Macdonald * Source/GSString.m: fillHole() fixed error in copying bytes. diff --git a/Source/GNUmakefile b/Source/GNUmakefile index 1514cee7a..6c4eddd47 100644 --- a/Source/GNUmakefile +++ b/Source/GNUmakefile @@ -95,7 +95,7 @@ mframe.m \ objc-gnu2next.m ifeq ($(GNUSTEP_TARGET_OS), mingw32) -GNU_MFILES += WindowsFileHandle.m +GNU_MFILES += WindowsFileHandle.m libgnustep-base-entry.m else GNU_MFILES += UnixFileHandle.m endif diff --git a/Source/NSObject.m b/Source/NSObject.m index e3a05e3e7..000ca91e7 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -588,6 +588,13 @@ static BOOL double_release_check_enabled = NO; if (self == [NSObject class]) { extern void GSBuildStrings(); // See externs.m + +#ifdef __MINGW__ + // See libgnustep-base-entry.m + extern void gnustep_base_socket_init(); + gnustep_base_socket_init(); +#endif + #ifdef __FreeBSD__ // Manipulate the FPU to add the exception mask. (Fixes SIGFPE // problems on *BSD) diff --git a/Source/libgnustep-base-entry.m b/Source/libgnustep-base-entry.m index 96224e568..97fcb2f48 100644 --- a/Source/libgnustep-base-entry.m +++ b/Source/libgnustep-base-entry.m @@ -42,6 +42,15 @@ int _MB_init_runtime() } #endif /* __MS_WIN32__ */ +void +gnustep_base_socket_init() +{ + /* Start of sockets so we can get host name and other info */ + static WSADATA wsaData; + if (WSAStartup(MAKEWORD(2,0), &wsaData)) + NSLog(@"Error: Could not startup Windows Sockets.\n"); +} + LONG APIENTRY gnustep_base_socket_handler(HWND hWnd, UINT message, UINT wParam, LONG lParam); @@ -69,13 +78,10 @@ DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) /* Initialize the Microsoft C stdio DLL */ _CRT_INIT(hInst, ul_reason_for_call, lpReserved); - /* Initialize the GNUstep Base Library runtime structures */ - gnustep_base_init_runtime(); #endif /* __MS_WIN32__ */ // Initialize Windows Sockets - if (WSAStartup(MAKEWORD(1,1), &lpWSAData)) - NSLog(@"Error: Could not startup Windows Sockets.\n"); + gnustep_base_socket_init(); // Register a window class for the socket handler wc.lpszClassName = "GnustepBaseSocketHandler"; @@ -178,3 +184,8 @@ gnustep_base_socket_handler(HWND hWnd, UINT message, return 0; } +/* + This section terminates the list of imports under GCC. If you do not + include this then you will have problems when linking with DLLs. + */ +asm (".section .idata$3\n" ".long 0,0,0,0,0,0,0,0"); diff --git a/Source/libgnustep-base.def b/Source/libgnustep-base.def index e95f0b8bc..7be046d33 100644 --- a/Source/libgnustep-base.def +++ b/Source/libgnustep-base.def @@ -169,6 +169,7 @@ __objc_class_name_NSTimeZone __objc_class_name_NSTimeZoneDetail __objc_class_name_NSTimer __objc_class_name_NSURL +__objc_class_name_GSFileURLHandle __objc_class_name_NSURLHandle __objc_class_name_NSUnarchiver __objc_class_name_NSUnarchiverClassInfo