Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
ba6cc328
Commit
ba6cc328
authored
May 05, 1999
by
sof
Browse files
[project @ 1999-05-05 10:34:53 by sof]
stubs for starting & stopping Winsock
parent
e548e8aa
Changes
5
Hide whitespace changes
Inline
Side-by-side
ghc/lib/misc/cbits/Makefile
View file @
ba6cc328
...
...
@@ -21,4 +21,8 @@ LIBRARY=libHSmisc_cbits.a
LIBOBJS
=
$(C_OBJS)
INSTALL_LIBS
+=
$(LIBRARY)
DLL_NAME
=
HSmisc_cbits.dll
SRC_BLD_DLL_OPTS
+=
--export-all
--output-def
=
HSmisc_cbits.def
SRC_BLD_DLL_OPTS
+=
-lwinmm
-lwsock32
-lHSrts_imp
-lHS_cbits_imp
-lgmp
-L
.
-L
../../../rts/gmp
-L
../../../rts
-L
../../std/cbits
include
$(TOP)/mk/target.mk
ghc/lib/misc/cbits/ghcSockets.h
View file @
ba6cc328
#ifndef GHC_SOCKETS_H
#define GHC_SOCKETS_H
#ifdef HAVE_WINSOCK_H
#include <winsock.h>
#else
#include <ctype.h>
#include <netdb.h>
#include <netinet/in.h>
...
...
@@ -39,7 +43,7 @@
#include <sys/uio.h>
/* ToDo: featurise this */
#if
ndef
cygwin32_TARGET_OS
#if
!defined(
cygwin32_TARGET_OS
) && !defined(mingw32_TARGET_OS)
#include <sys/un.h>
#endif
...
...
@@ -47,6 +51,8 @@
# include <unistd.h>
#endif
#endif
/* !HAVE_WINSOCK_H */
/* acceptSocket.lc */
StgInt
acceptSocket
(
StgInt
,
StgAddr
,
StgAddr
);
...
...
@@ -87,5 +93,10 @@ StgInt setSocketOption__ (StgInt, StgInt, StgInt);
/* writeDescriptor.lc */
StgInt
writeDescriptor
(
StgInt
,
StgAddr
,
StgInt
);
/* initWinSock.c */
#ifdef _WIN32
StgInt
initWinSock
();
void
shutdownWinSock
();
#endif
#endif
/* !GHC_SOCKETS_H */
ghc/lib/misc/cbits/initWinSock.c
0 → 100644
View file @
ba6cc328
#define NON_POSIX_SOURCE
#include "Rts.h"
#include "ghcSockets.h"
#include "stgio.h"
#ifdef _WIN32
/* Initialising WinSock... */
StgInt
initWinSock
()
{
WORD
wVersionRequested
;
WSADATA
wsaData
;
int
err
;
wVersionRequested
=
MAKEWORD
(
1
,
1
);
err
=
WSAStartup
(
wVersionRequested
,
&
wsaData
);
if
(
err
!=
0
)
{
return
err
;
}
if
(
LOBYTE
(
wsaData
.
wVersion
)
!=
1
||
HIBYTE
(
wsaData
.
wVersion
)
!=
1
)
{
WSACleanup
();
return
(
-
1
);
}
return
0
;
}
void
shutdownWinSock
()
{
WSACleanup
();
}
#endif
ghc/lib/misc/cbits/regex.c
View file @
ba6cc328
...
...
@@ -94,7 +94,7 @@ char *realloc ();
This is used in most programs--a few other programs avoid this
by defining INHIBIT_STRING_HEADER. */
#ifndef INHIBIT_STRING_HEADER
#if defined (HAVE_STRING_H) || defined (STDC_HEADERS) || defined (_LIBC)
#if defined (HAVE_STRING_H) || defined (STDC_HEADERS) || defined (_LIBC)
|| defined(_WIN32)
#include <string.h>
#ifndef bcmp
#define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
...
...
ghc/lib/misc/cbits/socketOpt.c
View file @
ba6cc328
...
...
@@ -19,7 +19,11 @@ StgInt opt;
{
int
level
,
optval
,
sz_optval
,
rc
;
if
(
opt
==
TCP_MAXSEG
||
opt
==
TCP_NODELAY
)
{
if
(
#ifndef _WIN32
opt
==
TCP_MAXSEG
||
#endif
opt
==
TCP_NODELAY
)
{
level
=
IPPROTO_TCP
;
}
else
{
level
=
SOL_SOCKET
;
...
...
@@ -45,7 +49,11 @@ StgInt val;
{
int
level
,
optval
,
rc
;
if
(
opt
==
TCP_MAXSEG
||
opt
==
TCP_NODELAY
)
{
if
(
#ifndef _WIN32
opt
==
TCP_MAXSEG
||
#endif
opt
==
TCP_NODELAY
)
{
level
=
IPPROTO_TCP
;
}
else
{
level
=
SOL_SOCKET
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment