From f73c085755869b071607db1059351c46ca83abac Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Fri, 20 Aug 2010 00:14:49 +0100 Subject: [PATCH] hcrypto: Add dirfd definition for solaris Add an implementation of dirfd to our local roken implementation for platforms that don't have one. Code taken from Heimdal. Change-Id: I4284c18430b6f49200886f5340191a14dcf34b57 Reviewed-on: http://gerrit.openafs.org/2608 Tested-by: BuildBot Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- acinclude.m4 | 18 ++++++++++++++++++ src/cf/have-struct-field.m4 | 19 +++++++++++++++++++ src/crypto/hcrypto/Makefile.in | 2 +- src/crypto/hcrypto/roken.h | 10 ++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/cf/have-struct-field.m4 diff --git a/acinclude.m4 b/acinclude.m4 index 8782488..98c6771 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1454,6 +1454,24 @@ struct labeltest struct_labeltest = { [AC_MSG_RESULT(no) ]) +AC_MSG_CHECKING([checking for dirfd]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include +#ifdef HAVE_DIRENT_H +#include +#endif +]], + [[DIR *d = 0; dirfd(d);]])], + [ac_rk_have_dirfd=yes], [ac_rk_have_dirfd=no]) +if test "$ac_rk_have_dirfd" = "yes" ; then + AC_DEFINE_UNQUOTED(HAVE_DIRFD, 1, [have a dirfd function/macro]) +fi +AC_MSG_RESULT($ac_rk_have_dirfd) + +OPENAFS_HAVE_STRUCT_FIELD(DIR, dd_fd, [#include +#ifdef HAVE_DIRENT_H +#include +#endif]) + dnl Eventually, this will look for the system one, or for OpenSSL LIB_hcrypto="-lafshcrypto" AC_SUBST(LIB_hcrypto) diff --git a/src/cf/have-struct-field.m4 b/src/cf/have-struct-field.m4 new file mode 100644 index 0000000..36f75c9 --- /dev/null +++ b/src/cf/have-struct-field.m4 @@ -0,0 +1,19 @@ +dnl Borrowed from Heimdal, but renamed as I don't think we +dnl should be shipping AC_ macros. + +AC_DEFUN([OPENAFS_HAVE_STRUCT_FIELD], [ +define(cache_val, translit(ac_cv_type_$1_$2, [A-Z ], [a-z_])) +AC_CACHE_CHECK([for $2 in $1], cache_val,[ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$3]], + [[$1 x; memset(&x, 0, sizeof(x)); x.$2]])], + [cache_val=yes], + [cache_val=no]) +]) +if test "$cache_val" = yes; then + define(foo, translit(HAVE_$1_$2, [a-z ], [A-Z_])) + AC_DEFINE(foo, 1, [Define if $1 has field $2.]) + undefine([foo]) +fi +undefine([cache_val]) +]) + diff --git a/src/crypto/hcrypto/Makefile.in b/src/crypto/hcrypto/Makefile.in index 10a2aea..436ffe4 100644 --- a/src/crypto/hcrypto/Makefile.in +++ b/src/crypto/hcrypto/Makefile.in @@ -165,7 +165,7 @@ dsa.o: ${UPSTREAM}/hcrypto/dsa.c ${CCRULE} evp.o: ${UPSTREAM}/hcrypto/evp.c - ${CCRULE} + ${CCRULE} -DHAVE_CONFIG_H evp-hcrypto.o: ${UPSTREAM}/hcrypto/evp-hcrypto.c ${CCRULE} diff --git a/src/crypto/hcrypto/roken.h b/src/crypto/hcrypto/roken.h index 93805b5..c830eae 100644 --- a/src/crypto/hcrypto/roken.h +++ b/src/crypto/hcrypto/roken.h @@ -37,5 +37,15 @@ ROKEN_LIB_FUNCTION size_t ROKEN_LIB_CALL strlcpy (char *, const char *, size_t); #endif +#ifndef HAVE_DIRFD +# ifdef HAVE_DIR_DD_FD +# define dirfd(x) ((x)->dd_fd) +# else +# ifndef _WIN32 /* Windows code never calls dirfd */ +# error Missing dirfd() and ->dd_fd +# endif +# endif +#endif + /* This is a bodge, but it's only used by the tests */ #define emalloc(x) malloc(x) -- 1.9.4