LIBGCRYPT-1-2-BRANCH libgcrypt (6 files)

cvs user wk cvs at cvs.gnupg.org
Fri Nov 26 17:20:09 CET 2004


    Date: Friday, November 26, 2004 @ 17:27:08
  Author: wk
    Path: /cvs/libgcrypt/libgcrypt
     Tag: LIBGCRYPT-1-2-BRANCH

Modified: src/ChangeLog src/ath.c src/ath.h src/gcrypt.h src/types.h
          tests/benchmark.c

Avoid warning about double defined type byte and other hacks to let it
build for W32


-------------------+
 src/ChangeLog     |    8 ++++++++
 src/ath.c         |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/ath.h         |   24 ++++++++++++++++++++----
 src/gcrypt.h      |   12 ++++++++++++
 src/types.h       |    4 ++++
 tests/benchmark.c |   10 ++++++++++
 6 files changed, 103 insertions(+), 4 deletions(-)


Index: libgcrypt/src/ChangeLog
diff -u libgcrypt/src/ChangeLog:1.151.2.7 libgcrypt/src/ChangeLog:1.151.2.8
--- libgcrypt/src/ChangeLog:1.151.2.7	Tue Nov  9 18:07:37 2004
+++ libgcrypt/src/ChangeLog	Fri Nov 26 17:27:08 2004
@@ -1,3 +1,11 @@
+2004-11-26  Werner Koch  <wk at g10code.com>
+
+	* types.h [_WIN32]: Avoid warning about double defined type byte.
+
+2004-11-25  Werner Koch  <wk at g10code.com>
+
+	* ath.h [_WIN32]: Adjusted for modern mingw cross compiler.
+
 2004-11-09  Werner Koch  <wk at g10code.de>
 
 	* gcrypt.h: Removed 3 trailing commas from enums.  Reported by
Index: libgcrypt/src/ath.c
diff -u libgcrypt/src/ath.c:1.7 libgcrypt/src/ath.c:1.7.2.1
--- libgcrypt/src/ath.c:1.7	Thu Mar 11 02:44:43 2004
+++ libgcrypt/src/ath.c	Fri Nov 26 17:27:08 2004
@@ -30,11 +30,14 @@
 # include <sys/time.h>
 #endif
 #include <sys/types.h>
+#ifndef _WIN32
 #include <sys/wait.h>
+#endif
 #include <errno.h>
 
 #include "ath.h"
 
+
 
 /* The interface table.  */
 static struct ath_ops ops;
@@ -227,13 +230,22 @@
 
 
 ssize_t
+#ifdef _WIN32
+ath_select (int nfd, void *rset, void *wset, void *eset,
+	    struct timeval *timeout)
+#else
 ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
 	    struct timeval *timeout)
+#endif
 {
   if (ops_set && ops.select)
     return (*ops.select) (nfd, rset, wset, eset, timeout);
   else
+#ifdef _WIN32
+    return -1;
+#else
     return select (nfd, rset, wset, eset, timeout);
+#endif
 }
 
  
@@ -243,45 +255,82 @@
   if (ops_set && ops.waitpid)
     return (*ops.waitpid) (pid, status, options);
   else
+#ifdef _WIN32
+    return -1;
+#else
     return waitpid (pid, status, options);
+#endif
 }
 
 
 int
+#ifdef _WIN32
+ath_accept (int s, void *addr, int *length_ptr)
+#else
 ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr)
+#endif
 {
   if (ops_set && ops.accept)
     return (*ops.accept) (s, addr, length_ptr);
   else
+#ifdef _WIN32
+    return -1;
+#else
     return accept (s, addr, length_ptr);
+#endif
 }
 
 
 int
+#ifdef _WIN32
+ath_connect (int s, void *addr, socklen_t length)
+#else
 ath_connect (int s, struct sockaddr *addr, socklen_t length)
+#endif
 {
   if (ops_set && ops.connect)
     return (*ops.connect) (s, addr, length);
   else
+#ifdef _WIN32
+    return -1;
+#else
     return connect (s, addr, length);
+#endif
 }
 
 
 int
+#ifdef _WIN32
+ath_sendmsg (int s, const void *msg, int flags)
+#else
 ath_sendmsg (int s, const struct msghdr *msg, int flags)
+#endif
 {
   if (ops_set && ops.sendmsg)
     return (*ops.sendmsg) (s, msg, flags);
   else
+#ifdef _WIN32
+    return -1;
+#else
     return sendmsg (s, msg, flags);
+#endif
 }
 
 
 int
+#ifdef _WIN32
+ath_recvmsg (int s, void *msg, int flags)
+#else
 ath_recvmsg (int s, struct msghdr *msg, int flags)
+#endif
 {
   if (ops_set && ops.recvmsg)
     return (*ops.recvmsg) (s, msg, flags);
   else
+#ifdef _WIN32
+    return -1;
+#else
     return recvmsg (s, msg, flags);
+#endif
 }
+
Index: libgcrypt/src/ath.h
diff -u libgcrypt/src/ath.h:1.9 libgcrypt/src/ath.h:1.9.2.1
--- libgcrypt/src/ath.h:1.9	Thu Mar 11 02:44:43 2004
+++ libgcrypt/src/ath.h	Fri Nov 26 17:27:08 2004
@@ -22,9 +22,6 @@
 #define ATH_H
 
 #ifdef _WIN32
-#warning We need to replace these hacks by cleaner code.
-typedef int ssize_t;
-typedef int pid_t;
 #include <windows.h>
 #else
 #include <sys/types.h>
@@ -78,6 +75,15 @@
   int (*mutex_unlock) (void *priv);
   ssize_t (*read) (int fd, void *buf, size_t nbytes);
   ssize_t (*write) (int fd, const void *buf, size_t nbytes);
+#ifdef _WIN32
+  ssize_t (*select) (int nfd, void *rset, void *wset, void *eset,
+		     struct timeval *timeout);
+  ssize_t (*waitpid) (pid_t pid, int *status, int options);
+  int (*accept) (int s, void  *addr, int *length_ptr);
+  int (*connect) (int s, void *addr, socklen_t length);
+  int (*sendmsg) (int s, const void *msg, int flags);
+  int (*recvmsg) (int s, void *msg, int flags);
+#else
   ssize_t (*select) (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
 		     struct timeval *timeout);
   ssize_t (*waitpid) (pid_t pid, int *status, int options);
@@ -85,6 +91,7 @@
   int (*connect) (int s, struct sockaddr *addr, socklen_t length);
   int (*sendmsg) (int s, const struct msghdr *msg, int flags);
   int (*recvmsg) (int s, struct msghdr *msg, int flags);
+#endif
 };
 
 gpg_err_code_t ath_install (struct ath_ops *ath_ops, int check_only);
@@ -100,11 +107,19 @@
 int ath_mutex_lock (ath_mutex_t *mutex);
 int ath_mutex_unlock (ath_mutex_t *mutex);
 
-
 /* Replacement for the POSIX functions, which can be used to allow
    other (user-level) threads to run.  */
 ssize_t ath_read (int fd, void *buf, size_t nbytes);
 ssize_t ath_write (int fd, const void *buf, size_t nbytes);
+#ifdef _WIN32
+ssize_t ath_select (int nfd, void *rset, void *wset, void *eset,
+		    struct timeval *timeout);
+ssize_t ath_waitpid (pid_t pid, int *status, int options);
+int ath_accept (int s, void *addr, int *length_ptr);
+int ath_connect (int s, void *addr, int length);
+int ath_sendmsg (int s, const void *msg, int flags);
+int ath_recvmsg (int s, void *msg, int flags);
+#else
 ssize_t ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
 		    struct timeval *timeout);
 ssize_t ath_waitpid (pid_t pid, int *status, int options);
@@ -112,5 +127,6 @@
 int ath_connect (int s, struct sockaddr *addr, socklen_t length);
 int ath_sendmsg (int s, const struct msghdr *msg, int flags);
 int ath_recvmsg (int s, struct msghdr *msg, int flags);
+#endif 
 
 #endif	/* ATH_H */
Index: libgcrypt/src/gcrypt.h
diff -u libgcrypt/src/gcrypt.h:1.125.2.2 libgcrypt/src/gcrypt.h:1.125.2.3
--- libgcrypt/src/gcrypt.h:1.125.2.2	Tue Nov  9 18:07:37 2004
+++ libgcrypt/src/gcrypt.h	Fri Nov 26 17:27:08 2004
@@ -28,7 +28,9 @@
 #include <gpg-error.h>
 
 #include <sys/types.h>
+#ifndef _WIN32
 #include <sys/socket.h>
+#endif /*!_WIN32*/
 #include <sys/time.h>
 
 /* This is required for error code compatibility. */
@@ -171,6 +173,15 @@
   int (*mutex_unlock) (void **priv);
   ssize_t (*read) (int fd, void *buf, size_t nbytes);
   ssize_t (*write) (int fd, const void *buf, size_t nbytes);
+#ifdef _WIN32
+  ssize_t (*select) (int nfd, void *rset, void *wset, void *eset,
+		     struct timeval *timeout);
+  ssize_t (*waitpid) (pid_t pid, int *status, int options);
+  int (*accept) (int s, void  *addr, int *length_ptr);
+  int (*connect) (int s, void *addr, int length);
+  int (*sendmsg) (int s, const void *msg, int flags);
+  int (*recvmsg) (int s, void *msg, int flags);
+#else
   ssize_t (*select) (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
 		     struct timeval *timeout);
   ssize_t (*waitpid) (pid_t pid, int *status, int options);
@@ -178,6 +189,7 @@
   int (*connect) (int s, struct sockaddr *addr, socklen_t length);
   int (*sendmsg) (int s, const struct msghdr *msg, int flags);
   int (*recvmsg) (int s, struct msghdr *msg, int flags);
+#endif
 };
 
 #define GCRY_THREAD_OPTION_PTH_IMPL					      \
Index: libgcrypt/src/types.h
diff -u libgcrypt/src/types.h:1.4 libgcrypt/src/types.h:1.4.4.1
--- libgcrypt/src/types.h:1.4	Sun Jun 15 03:46:11 2003
+++ libgcrypt/src/types.h	Fri Nov 26 17:27:08 2004
@@ -43,7 +43,11 @@
 
 #ifndef HAVE_BYTE_TYPEDEF
 #undef byte	    /* maybe there is a macro with this name */
+/* Windows typedefs byte in the rpc headers.  Avoid warning about
+   double definition.  */
+#if !(defined(_WIN32) && defined(cbNDRContext))
   typedef unsigned char byte;
+#endif
 #define HAVE_BYTE_TYPEDEF
 #endif
 
Index: libgcrypt/tests/benchmark.c
diff -u libgcrypt/tests/benchmark.c:1.3 libgcrypt/tests/benchmark.c:1.3.2.1
--- libgcrypt/tests/benchmark.c:1.3	Wed Mar  3 09:08:05 2004
+++ libgcrypt/tests/benchmark.c	Fri Nov 26 17:27:08 2004
@@ -24,7 +24,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
+#ifndef _WIN32
 #include <sys/times.h>
+#endif
 #include <gcrypt.h>
 
 #define PGM "benchmark"
@@ -39,19 +41,27 @@
 static void
 start_timer (void)
 {
+#ifdef _WIN32
+  started_at = stopped_at = clock ();
+#else
   struct tms tmp;
 
   times (&tmp);
   started_at = stopped_at = tmp.tms_utime;
+#endif
 }
 
 static void
 stop_timer (void)
 {
+#ifdef _WIN32
+  stopped_at = clock ();
+#else
   struct tms tmp;
 
   times (&tmp);
   stopped_at = tmp.tms_utime;
+#endif
 }
 
 static const char *




More information about the Gnupg-commits mailing list