Explorar o código

Make windows happier still

svn:r392
Nick Mathewson %!s(int64=21) %!d(string=hai) anos
pai
achega
bbd4032fc1
Modificáronse 5 ficheiros con 27 adicións e 6 borrados
  1. 3 3
      src/common/aes.c
  2. 7 2
      src/common/fakepoll.c
  3. 15 0
      src/common/util.c
  4. 1 0
      src/common/util.h
  5. 1 1
      src/or/routers.c

+ 3 - 3
src/common/aes.c

@@ -122,9 +122,9 @@ aes_get_counter(aes_cnt_cipher_t *cipher)
 void
 aes_set_counter(aes_cnt_cipher_t *cipher, u64 counter)
 {
-  cipher->pos = counter & 0x0f;
-  cipher->counter0 = (counter >> 4) & 0xffffffff;
-  cipher->counter1 = (counter >> 36);
+  cipher->pos = (u8)(counter & 0x0f);
+  cipher->counter0 = (u32) ((counter >> 4) & 0xffffffff);
+  cipher->counter1 = (u32) (counter >> 36);
   _aes_fill_buf(cipher);
 }
 

+ 7 - 2
src/common/fakepoll.c

@@ -28,12 +28,17 @@
 int
 poll(struct pollfd *ufds, unsigned int nfds, int timeout)
 {
-	int idx, maxfd, fd, r;
+	unsigned int idx, maxfd, fd;
+	int r;
 	fd_set readfds, writefds, exceptfds;
+#ifdef USING_FAKE_TIMEVAL
+#undef timeval
+#undef tv_sec
+#undef tv_usec
+#endif
 	struct timeval _timeout;
 	_timeout.tv_sec = timeout/1000;
 	_timeout.tv_usec = (timeout%1000)*1000;
-	
 	FD_ZERO(&readfds);
 	FD_ZERO(&writefds);
 	FD_ZERO(&exceptfds);

+ 15 - 0
src/common/util.c

@@ -3,6 +3,13 @@
 /* $Id$ */
 
 #include "../or/or.h"
+
+#ifdef _MSC_VER
+#include <io.h>
+#include <limits.h>
+#include <process.h>
+#endif
+
 #include "util.h"
 #include "log.h"
 
@@ -146,7 +153,11 @@ tor_socketpair(int family, int type, int protocol, int fd[2])
         || family != AF_UNIX
 #endif
         ) {
+#ifdef _MSC_VER
+		errno = WSAEAFNOSUPPORT;
+#else
         errno = EAFNOSUPPORT;
+#endif
         return -1;
     }
     if (!fd) {
@@ -202,7 +213,11 @@ tor_socketpair(int family, int type, int protocol, int fd[2])
     return 0;
 
   abort_tidy_up_and_fail:
+#ifdef _MSC_VER
+  errno = WSAECONNABORTED;
+#else
   errno = ECONNABORTED; /* I hope this is portable and appropriate.  */
+#endif
   tidy_up_and_fail:
     {
         int save_errno = errno;

+ 1 - 0
src/common/util.h

@@ -15,6 +15,7 @@
 #endif
 #ifndef HAVE_GETTIMEOFDAY
 #ifdef HAVE_FTIME
+#define USING_FAKE_TIMEVAL
 #include <sys/timeb.h>
 #define timeval timeb
 #define tv_sec time

+ 1 - 1
src/or/routers.c

@@ -56,7 +56,7 @@ int learn_my_address(struct sockaddr_in *me) {
   memset(me,0,sizeof(struct sockaddr_in));
   me->sin_family = AF_INET;
   memcpy((void *)&me->sin_addr,(void *)localhost->h_addr,sizeof(struct in_addr));
-  me->sin_port = htons(options.ORPort);
+  me->sin_port = htons((uint16_t) options.ORPort);
   log_fn(LOG_DEBUG,"chose address as '%s'.",inet_ntoa(me->sin_addr));
   if (!strncmp("127.",inet_ntoa(me->sin_addr), 4) &&
       strcasecmp(localhostname, "localhost")) {