Compiling problem with MS VC 6

Martin Koegler mkoegler at auto.tuwien.ac.at
Sun May 29 15:41:01 CEST 2005


I tried compiling libgcrypt 1.2.1 with MS Visual C++ 6 on Windows and discovered the following
problems:

* cipher/random.c includes unconditionally sys/time.h and unistd.h.
Using
#if HAVE_SYS_TIME_H
#include <sys/time.h>
#else
#include <time.h>
#endif

and AC_CHECK_HEADERS for sys/time.h should make the library more portable.
(MS VC has no sys/time.h, using only time.h works).

unistd.h should also be included only, if it is present (unistd.h needs 
to be added to AC_CHECK_HEADERS too):
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

Some definitions, which are expected to be in unistd.h, can be found in the file io.h.
(It can be included by config.h or by the c source file).

* src/ath.c also includes unconditionally sys/time.h and unistd.h. 
It should be changed in the same way.

* src/gcrypt.h includes unconditionally sys/time.h. Here a conditional include will
not work.

* if src/gcrypt.h is included in a program, pid_t, ssize_t and socklen_t must be
defined by the program before.

* Some functions have inconsitent prototypes, eg:
mpi/mpi-cmp.c:gcry_mpi_cmp_ui( gcry_mpi_t u, unsigned long v )
src/gcrypt.h:int gcry_mpi_cmp_ui (const gcry_mpi_t u, unsigned long v);
src/mpi.h:int gcry_mpi_cmp_ui( gcry_mpi_t u, ulong v );

mpi/mpi-cmp.c:gcry_mpi_cmp( gcry_mpi_t u, gcry_mpi_t v )
src/gcrypt.h:int gcry_mpi_cmp (const gcry_mpi_t u, const gcry_mpi_t v);
rc/mpi.h:int gcry_mpi_cmp( gcry_mpi_t u, gcry_mpi_t v );

* in crypt/tiger.c the postfix LL is used instead of the macro U64_C:
cipher/tiger.c:  hd->a = 0x0123456789abcdefLL;
cipher/tiger.c:  hd->b = 0xfedcba9876543210LL;
cipher/tiger.c:  hd->c = 0xf096a5b4c3b2e187LL;
cipher/tiger.c:  x[0] -= x[7] ^ 0xa5a5a5a5a5a5a5a5LL;
cipher/tiger.c:  x[7] -= x[6] ^ 0x0123456789abcdefLL;

All other problems are solveable in the config.h file:
#define HAVE_DOSISH_SYSTEM
#define HAVE_MEMMOVE
#define HAVE_RAND
#define VERSION "1.2.1"

typedef unsigned __int64 uint64_t;
#define UINT64_C(C) (C)

#define SIZEOF_UINT64_T 8
#define _GCRYPT_IN_LIBGCRYPT
#define S_IWUSR _S_IWRITE
#define S_IRUSR _S_IREAD

#define S_ISREG(A) (1)

#define pid_t int
#define ssize_t int
#define socklen_t int

#define USE_RNDW32 1
/* select of enabled features follow */

With these changes, it is possible to get a gcrypt, where all features I need for
gnutls work.

In the current CVS version, all these problems are still present.

mfg Martin Kögler
e9925248 at stud4.tuwien.ac.at



More information about the Gcrypt-devel mailing list