update autoconf for latest compat functions

This commit is contained in:
Brent Cook 2019-01-31 09:45:56 -06:00
parent 495a1b6316
commit a6d7ea9562
10 changed files with 107 additions and 19 deletions

View File

@ -87,6 +87,7 @@ if HOST_WIN
-echo posix_write >> crypto_portable.sym
-echo posix_getsockopt >> crypto_portable.sym
-echo posix_setsockopt >> crypto_portable.sym
-echo getuid >> crypto_portable.sym
-grep -v BIO_s_log crypto_portable.sym > crypto_portable.sym.tmp
-mv crypto_portable.sym.tmp crypto_portable.sym
endif
@ -162,6 +163,15 @@ if !HAVE_GETPAGESIZE
libcompat_la_SOURCES += compat/getpagesize.c
endif
if !HAVE_GETPROGNAME
if HOST_LINUX
libcompat_la_SOURCES += compat/getprogname_linux.c
endif
if HOST_WIN
libcompat_la_SOURCES += compat/getprogname_windows.c
endif
endif
if !HAVE_TIMEGM
libcompat_la_SOURCES += compat/timegm.c
endif
@ -174,6 +184,10 @@ if !HAVE_RECALLOCARRAY
libcompat_la_SOURCES += compat/recallocarray.c
endif
if !HAVE_SYSLOG_R
libcompat_la_SOURCES += compat/syslog_r.c
endif
if !HAVE_TIMINGSAFE_MEMCMP
libcompat_la_SOURCES += compat/timingsafe_memcmp.c
endif

View File

@ -0,0 +1,9 @@
#include <stdlib.h>
#include <errno.h>
const char *
getprogname(void)
{
return program_invocation_short_name;
}

View File

@ -0,0 +1,13 @@
#include <stdlib.h>
#include <windows.h>
const char *
getprogname(void)
{
static char progname[MAX_PATH + 1];
DWORD length = GetModuleFileName(NULL, progname, sizeof (progname) - 1);
if (length < 0)
return "?";
return progname;
}

View File

@ -4,6 +4,7 @@
* BSD socket emulation code for Winsock2
* File IO compatibility shims
* Brent Cook <bcook@openbsd.org>
* Kinichiro Inoguchi <inoguchi@openbsd.org>
*/
#define NO_REDEF_POSIX_FUNCTIONS
@ -208,6 +209,12 @@ posix_setsockopt(int sockfd, int level, int optname,
return rc == 0 ? 0 : wsa_errno(WSAGetLastError());
}
uid_t getuid(void)
{
/* Windows fstat sets 0 as st_uid */
return 0;
}
#ifdef _MSC_VER
struct timezone;
int gettimeofday(struct timeval * tp, struct timezone * tzp)

19
crypto/compat/syslog_r.c Normal file
View File

@ -0,0 +1,19 @@
#include <syslog.h>
void
syslog_r(int pri, struct syslog_data *data, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vsyslog_r(pri, data, fmt, ap);
va_end(ap);
}
void
vsyslog_r(int pri, struct syslog_data *data, const char *fmt, va_list ap)
{
#ifdef HAVE_SYSLOG
vsyslog(pri, fmt, ap);
#endif
}

View File

@ -29,6 +29,10 @@ uint32_t arc4random_uniform(uint32_t upper_bound);
void freezero(void *ptr, size_t sz);
#endif
#ifndef HAVE_GETPROGNAME
const char * getprogname(void);
#endif
#ifndef HAVE_REALLOCARRAY
void *reallocarray(void *, size_t, size_t);
#endif

37
include/compat/syslog.h Normal file
View File

@ -0,0 +1,37 @@
/*
* Public domain
* syslog.h compatibility shim
*/
#ifndef _WIN32
#include_next <syslog.h>
#endif
#ifndef LIBCRYPTOCOMPAT_SYSLOG_H
#define LIBCRYPTOCOMPAT_SYSLOG_H
#ifndef HAVE_SYSLOG_R
#include <stdarg.h>
#ifdef _WIN32
#define LOG_INFO 6 /* informational */
#define LOG_USER (1<<3) /* random user-level messages */
#define LOG_LOCAL2 (18<<3) /* reserved for local use */
#endif
struct syslog_data {
int log_stat;
const char *log_tag;
int log_fac;
int log_mask;
};
#define SYSLOG_DATA_INIT {0, (const char *)0, LOG_USER, 0xff}
void syslog_r(int, struct syslog_data *, const char *, ...);
void vsyslog_r(int, struct syslog_data *, const char *, va_list);
#endif
#endif

View File

@ -6,6 +6,7 @@ AC_CHECK_FUNCS([asprintf freezero memmem])
AC_CHECK_FUNCS([readpassphrase reallocarray recallocarray])
AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum])
AC_CHECK_FUNCS([timegm _mkgmtime timespecsub])
AC_CHECK_FUNCS([getprogname syslog syslog_r])
AC_CACHE_CHECK([for getpagesize], ac_cv_func_getpagesize, [
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
// Since Android NDK v16 getpagesize is defined as inline inside unistd.h
@ -33,6 +34,9 @@ AM_CONDITIONAL([HAVE_STRNLEN], [test "x$ac_cv_func_strnlen" = xyes])
AM_CONDITIONAL([HAVE_STRSEP], [test "x$ac_cv_func_strsep" = xyes])
AM_CONDITIONAL([HAVE_STRTONUM], [test "x$ac_cv_func_strtonum" = xyes])
AM_CONDITIONAL([HAVE_TIMEGM], [test "x$ac_cv_func_timegm" = xyes])
AM_CONDITIONAL([HAVE_GETPROGNAME], [test "x$ac_cv_func_getprogname" = xyes])
AM_CONDITIONAL([HAVE_SYSLOG], [test "x$ac_cv_func_syslog" = xyes])
AM_CONDITIONAL([HAVE_SYSLOG_R], [test "x$ac_cv_func_syslog_r" = xyes])
])
AC_DEFUN([CHECK_SYSCALL_COMPAT], [

View File

@ -33,7 +33,6 @@ noinst_HEADERS = tls_internal.h
if HOST_WIN
libtls_la_SOURCES += compat/ftruncate.c
libtls_la_SOURCES += compat/getuid.c
libtls_la_SOURCES += compat/pread.c
libtls_la_SOURCES += compat/pwrite.c
endif

View File

@ -1,18 +0,0 @@
/*
* Public domain
*
* Kinichiro Inoguchi <inoguchi@openbsd.org>
*/
#ifdef _WIN32
#include <unistd.h>
uid_t
getuid(void)
{
/* Windows fstat sets 0 as st_uid */
return 0;
}
#endif