summaryrefslogtreecommitdiff
path: root/src/fd.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/fd.hpp')
-rw-r--r--src/fd.hpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/fd.hpp b/src/fd.hpp
index 06689fa..d994637 100644
--- a/src/fd.hpp
+++ b/src/fd.hpp
@@ -30,17 +30,26 @@
namespace xs
{
+
#ifdef XS_HAVE_WINDOWS
#if defined _MSC_VER &&_MSC_VER <= 1400
typedef UINT_PTR fd_t;
enum {retired_fd = (fd_t)(~0)};
+ inline void *fdtoptr (fd_t fd_) {return (void*) fd_;}
+ inline fd_t ptrtofd (void *ptr_) {return (fd_t) ptr_;}
#else
typedef SOCKET fd_t;
enum {retired_fd = INVALID_SOCKET};
+ inline void *fdtoptr (fd_t fd_) {return (void*) fd_;}
+ inline fd_t ptrtofd (void *ptr_) {return (fd_t) ptr_;}
#endif
#else
typedef int fd_t;
enum {retired_fd = -1};
+ inline void *fdtoptr (fd_t fd_) {return (void*) fd_;}
+ inline fd_t ptrtofd (void *ptr_) {return (int) ((char*) ptr_ - (char*) 0);}
#endif
+
}
+
#endif