winlin

refine merged code for allspace.

  1 +/*
  2 +The MIT License (MIT)
  3 +
  4 +Copyright (c) 2014 allspace
  5 +
  6 +Permission is hereby granted, free of charge, to any person obtaining a copy of
  7 +this software and associated documentation files (the "Software"), to deal in
  8 +the Software without restriction, including without limitation the rights to
  9 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  10 +the Software, and to permit persons to whom the Software is furnished to do so,
  11 +subject to the following conditions:
  12 +
  13 +The above copyright notice and this permission notice shall be included in all
  14 +copies or substantial portions of the Software.
  15 +
  16 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  18 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  20 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22 +*/
  23 +
1 #ifndef SRS_WIN_PORTING_H 24 #ifndef SRS_WIN_PORTING_H
2 #define SRS_WIN_PORTING_H 25 #define SRS_WIN_PORTING_H
3 26
@@ -12,11 +35,11 @@ @@ -12,11 +35,11 @@
12 * while the _WIN32 includes both 32-bit and 64-bit 35 * while the _WIN32 includes both 32-bit and 64-bit
13 */ 36 */
14 #if !defined(_WIN32) || defined(__CYGWIN__) 37 #if !defined(_WIN32) || defined(__CYGWIN__)
15 - #define SOCKET_ETIME ETIME  
16 - #define SOCKET_ECONNRESET ECONNRESET 38 + #define SOCKET_ETIME ETIME
  39 + #define SOCKET_ECONNRESET ECONNRESET
17 40
18 #define SOCKET int 41 #define SOCKET int
19 - #define SOCKET_ERRNO() errno 42 + #define SOCKET_ERRNO() errno
20 #define SOCKET_RESET(fd) fd = -1; (void)0 43 #define SOCKET_RESET(fd) fd = -1; (void)0
21 #define SOCKET_CLOSE(fd) \ 44 #define SOCKET_CLOSE(fd) \
22 if (fd > 0) {\ 45 if (fd > 0) {\
@@ -25,7 +48,7 @@ @@ -25,7 +48,7 @@
25 } \ 48 } \
26 (void)0 49 (void)0
27 #define SOCKET_VALID(x) (x > 0) 50 #define SOCKET_VALID(x) (x > 0)
28 - #define SOCKET_SETUP() (void)0 51 + #define SOCKET_SETUP() (void)0
29 #define SOCKET_CLEANUP() (void)0 52 #define SOCKET_CLEANUP() (void)0
30 #else /*on windows, but not on cygwin*/ 53 #else /*on windows, but not on cygwin*/
31 #include <sys/stat.h> 54 #include <sys/stat.h>
@@ -33,7 +56,7 @@ @@ -33,7 +56,7 @@
33 #include <winsock2.h> 56 #include <winsock2.h>
34 #include <stdint.h> 57 #include <stdint.h>
35 58
36 - #ifdef _MSC_VER //for VS2010 59 + #ifdef _MSC_VER //for VS2010
37 #include <io.h> 60 #include <io.h>
38 #include <fcntl.h> 61 #include <fcntl.h>
39 #define S_IRUSR _S_IREAD 62 #define S_IRUSR _S_IREAD
@@ -61,14 +84,14 @@ @@ -61,14 +84,14 @@
61 84
62 #define PRId64 "lld" 85 #define PRId64 "lld"
63 86
64 - #define SOCKET_ETIME WSAETIMEDOUT  
65 - #define SOCKET_ECONNRESET WSAECONNRESET  
66 - #define SOCKET_ERRNO() WSAGetLastError() 87 + #define SOCKET_ETIME WSAETIMEDOUT
  88 + #define SOCKET_ECONNRESET WSAECONNRESET
  89 + #define SOCKET_ERRNO() WSAGetLastError()
67 #define SOCKET_RESET(x) x=INVALID_SOCKET 90 #define SOCKET_RESET(x) x=INVALID_SOCKET
68 #define SOCKET_CLOSE(x) if(x!=INVALID_SOCKET){::closesocket(x);x=INVALID_SOCKET;} 91 #define SOCKET_CLOSE(x) if(x!=INVALID_SOCKET){::closesocket(x);x=INVALID_SOCKET;}
69 #define SOCKET_VALID(x) (x!=INVALID_SOCKET) 92 #define SOCKET_VALID(x) (x!=INVALID_SOCKET)
70 - #define SOCKET_BUFF(x) ((char*)x)  
71 - #define SOCKET_SETUP() socket_setup() 93 + #define SOCKET_BUFF(x) ((char*)x)
  94 + #define SOCKET_SETUP() socket_setup()
72 #define SOCKET_CLEANUP() socket_cleanup() 95 #define SOCKET_CLEANUP() socket_cleanup()
73 96
74 typedef uint32_t u_int32_t; 97 typedef uint32_t u_int32_t;
@@ -15,6 +15,8 @@ file @@ -15,6 +15,8 @@ file
15 ..\core\srs_core.cpp, 15 ..\core\srs_core.cpp,
16 ..\core\srs_core_autofree.hpp, 16 ..\core\srs_core_autofree.hpp,
17 ..\core\srs_core_autofree.cpp, 17 ..\core\srs_core_autofree.cpp,
  18 + ..\core\srs_platform.hpp,
  19 + ..\core\srs_platform.cpp,
18 kernel readonly separator, 20 kernel readonly separator,
19 ..\kernel\srs_kernel_buffer.hpp, 21 ..\kernel\srs_kernel_buffer.hpp,
20 ..\kernel\srs_kernel_buffer.cpp, 22 ..\kernel\srs_kernel_buffer.cpp,