diff options
author | simonm <unknown> | 1998-02-02 17:35:59 +0000 |
---|---|---|
committer | simonm <unknown> | 1998-02-02 17:35:59 +0000 |
commit | 28139aea50376444d56f43f0914291348a51a7e7 (patch) | |
tree | 595c378188638ef16462972c1e7fcdb8409c7f16 /ghc/lib/misc/cbits/bindSocket.c | |
parent | 98a1ebecb6d22d793b1d9f8e1d24ecbb5a2d130f (diff) | |
download | haskell-28139aea50376444d56f43f0914291348a51a7e7.tar.gz |
[project @ 1998-02-02 17:27:26 by simonm]
Library re-organisation:
All libraries now live under ghc/lib, which has the following structure:
ghc/lib/std -- all prelude files (libHS.a)
ghc/lib/std/cbits
ghc/lib/exts -- standard Hugs/GHC extensions (libHSexts.a)
-- available with '-fglasgow-exts'
ghc/lib/posix -- POSIX library (libHSposix.a)
ghc/lib/posix/cbits -- available with '-syslib posix'
ghc/lib/misc -- used to be hslibs/ghc (libHSmisc.a)
ghc/lib/misc/cbits -- available with '-syslib misc'
ghc/lib/concurrent -- Concurrent libraries (libHSconc.a)
-- available with '-concurrent'
Also, several non-standard prelude modules had their names changed to begin
with 'Prel' to reduce namespace pollution.
Addr ==> PrelAddr (Addr interface available in 'exts')
ArrBase ==> PrelArr
CCall ==> PrelCCall (CCall interface available in 'exts')
ConcBase ==> PrelConc
GHCerr ==> PrelErr
Foreign ==> PrelForeign (Foreign interface available in 'exts')
GHC ==> PrelGHC
IOHandle ==> PrelHandle
IOBase ==> PrelIOBase
GHCmain ==> PrelMain
STBase ==> PrelST
Unsafe ==> PrelUnsafe
UnsafeST ==> PrelUnsafeST
Diffstat (limited to 'ghc/lib/misc/cbits/bindSocket.c')
-rw-r--r-- | ghc/lib/misc/cbits/bindSocket.c | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/ghc/lib/misc/cbits/bindSocket.c b/ghc/lib/misc/cbits/bindSocket.c new file mode 100644 index 0000000000..db667da933 --- /dev/null +++ b/ghc/lib/misc/cbits/bindSocket.c @@ -0,0 +1,91 @@ +#if 0 +% +% (c) The GRASP/AQUA Project, Glasgow University, 1995 +% +\subsection[bindSocket.lc]{Assign name to unnamed socket} + +\begin{code} +#endif + +#define NON_POSIX_SOURCE +#include "rtsdefs.h" +#include "ghcSockets.h" + +StgInt +bindSocket(I_ sockfd, A_ myaddr, I_ addrlen, I_ isUnixDomain) +{ + int rc; + + while ((rc = bind((int)sockfd, (struct sockaddr *)myaddr, (int)addrlen)) < 0) { + if (errno != EINTR) { + cvtErrno(); + switch (ghc_errno) { + default: + stdErrno(); + break; + case GHC_EACCES: + ghc_errtype = ERR_PERMISSIONDENIED; + if (isUnixDomain != 0) + ghc_errstr = "For a component of path prefix of path name"; + else + ghc_errstr = "Requested address protected, cannot bind socket"; + break; + case GHC_EISCONN: + case GHC_EADDRINUSE: + ghc_errtype = ERR_RESOURCEBUSY; + ghc_errstr = "Address already in use"; + break; + case GHC_EADDRNOTAVAIL: + ghc_errtype = ERR_PERMISSIONDENIED; + ghc_errstr = "Address not available from local machine"; + break; + case GHC_EBADF: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "Not a valid socket file descriptor"; + break; + case GHC_EFAULT: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "Address not in valid part of user address space"; + break; + case GHC_EINVAL: + ghc_errtype = ERR_SYSTEMERROR; + ghc_errstr = "Specified size of structure not equal valid address for family"; + break; + case GHC_ENOTSOCK: + ghc_errtype = ERR_INAPPROPRIATETYPE; + ghc_errstr = "Descriptor for file, not a socket"; + break; + case GHC_EIO: + ghc_errtype = ERR_SYSTEMERROR; + ghc_errstr = "Could not make directory entry or alloc inode"; + break; + case GHC_EISDIR: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "A null path name was given"; + break; + case GHC_ELOOP: + ghc_errtype = ERR_SYSTEMERROR; + ghc_errstr = "Too many symbolic links encountered"; + break; + case GHC_ENAMETOOLONG: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "Max length of path name exceeded"; + break; + case GHC_ENOENT: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "Component in path prefix does not exist"; + break; + case GHC_ENOTDIR: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "Component in path prefix is not a directory"; + break; + case GHC_EROFS: + ghc_errtype = ERR_INVALIDARGUMENT; + ghc_errstr = "The inode would reside on read only file system"; + break; + } + return -1; + } + } + return 0; +} |