usual/bits.h \
usual/cbtree.h usual/cbtree.c \
usual/cfparser.h usual/cfparser.c \
+ usual/config_msvc.h \
usual/crypto/digest.h usual/crypto/digest.c \
usual/crypto/hmac.h usual/crypto/hmac.c \
usual/crypto/keccak.h usual/crypto/keccak.c \
--- /dev/null
+
+AM_FEATURES = msvc
+
+abs_top_srcdir = $(dir $(filter %/build.mk, $(MAKEFILE_LIST)))
+
+include $(abs_top_srcdir)/mk/antimake.mk
+
dnl AC_USUAL_HEADER_CHECK: Basic headers
dnl
AC_DEFUN([AC_USUAL_HEADER_CHECK], [
+AC_CHECK_HEADERS([inttypes.h stdbool.h unistd.h sys/time.h])
AC_CHECK_HEADERS([sys/socket.h poll.h sys/poll.h sys/un.h])
AC_CHECK_HEADERS([arpa/inet.h netinet/in.h netinet/tcp.h])
AC_CHECK_HEADERS([sys/param.h sys/uio.h pwd.h grp.h])
--- /dev/null
+
+Printf = printf $(subst %,%%,$(1)) $(2)
+
+SHELL = cmd.exe
+
+EXEEXT = .exe
+LIBEXT = .lib
+OBJEXT = .obj
+
+CC = cl -nologo
+CFLAGS = -O2
+WFLAGS =
+WFLAGS = -W2 -WX
+CPP = $(CC) -E
+
+AR = lib
+ARFLAGS = -nologo -out:$(call vcFixPath,$@)
+
+LDFLAGS =
+
+MKDIR_P = mkdir
+
+MkDir = $(if $(wildcard $(1)),,md $(call vcFixPath,$(1)))
+
+LIBS = -lws2_32 -ladvapi32
+
+vcFixPath = $(subst /,\,$(1))
+vcFixLibs = $(patsubst %.a,%.lib,$(patsubst -l%,%.lib,$(1)))
+vcFixAll = $(call vcFixPath,$(call vcFixLibs,$(1)))
+
+AM_LANG_C_COMPILE = $(COMPILE) -c -Fo$(call vcFixPath,$@) $<
+
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -Fe$(call vcFixPath,$@)
+
+ar_lib = lib -nologo -out:$(call vcFixAll,$@) $^
+AM_LANG_C_LINK = $(LINK) $(call vcFixAll,$^ $(AM_LIBS) $(LIBS)) $(AM_LT_RPATH)
+
+
nodist_regtest_compat_SOURCES = test_config.h
regtest_compat_EMBED_LIBUSUAL = 1
-regtest_system_EMBED_LIBUSUAL = 1
+#regtest_system_EMBED_LIBUSUAL = 1
-regtest_system_LDADD = -lanl
-regtest_system_LDFLAGS = -pthread
+regtest_system_LDADD = ../libusual.a
+regtest_system_LDFLAGS = #-pthread
regtest_system_CPPFLAGS = -I.. -I.
regtest_compat_CPPFLAGS := $(regtest_system_CPPFLAGS) -DUSUAL_TEST_CONFIG
-regtest_compat_LDFLAGS = -pthread
+regtest_compat_LDFLAGS = #-pthread
EXTRA_DIST = Makefile tinytest_demo.c force_compat.sed test_cfparser.ini
end:;
}
+#ifdef _PACKED
struct packed {
char a;
int b;
char c;
short d;
} _PACKED;
+#endif
static void test_misc(void *_p)
{
int_check(ARRAY_NELEM(s_2), 2);
int_check(strcmp(__func__, "test_misc"), 0);
-
+#ifdef _PACKED
int_check(sizeof(struct packed), 8);
+#endif
+
end:;
}
/* rol64 */
ull_check(rol64(1, 1), 2);
- ull_check(rol64(1, 63), 0x8000000000000000);
+ ull_check(rol64(1, 63), 0x8000000000000000ULL);
end:;
}
static const struct CfSect rsects [] = {
{ "one", rkeys1 },
- { "two", rkeys2, .base_lookup = get_two, },
+ { "two", rkeys2, get_two, },
{ NULL },
};
}
static const struct CxOps log_ops = {
- .c_alloc = log_alloc,
- .c_realloc = log_realloc,
- .c_free = log_free,
+ log_alloc,
+ log_realloc,
+ log_free,
};
static const struct CxMem log_libc = {
- .ops = &log_ops,
- .ctx = (void*)&cx_libc_allocator,
+ &log_ops,
+ (void*)&cx_libc_allocator,
};
#define log_check(x) str_check(logbuf, x); reset();
#include <usual/fnmatch.h>
#include <usual/string.h>
+#include <usual/wchar.h>
#include "test_common.h"
/*
int_check(0, fnmatch("[*?[][*?[][*?[]", "*?[", 0));
int_check(0, fnmatch("[[:alpha:]][![:alpha:]]", "a9", 0));
int_check(0, fnmatch("[[:alnum:]][![:alnum:]]", "9-", 0));
+#ifdef iswblank
int_check(0, fnmatch("[[:blank:]][![:blank:]]", " -", 0));
+#endif
int_check(0, fnmatch("[[:cntrl:]][![:cntrl:]]", "\tx", 0));
int_check(0, fnmatch("[[:digit:]][![:digit:]]", "9a", 0));
int_check(0, fnmatch("[[:graph:]][![:graph:]]", "a\t", 0));
int_check(0, fnmatch("[[:lower:]][![:lower:]]", "aA", 0));
- int_check(0, fnmatch("[[:print:]][![:print:]]", "a\t", 0));
+ int_check(0, fnmatch("[[:print:]][![:print:]]", "a\n", 0));
int_check(0, fnmatch("[[:punct:]][![:punct:]]", ".x", 0));
int_check(0, fnmatch("[[:space:]][![:space:]]", " x", 0));
int_check(0, fnmatch("[[:upper:]][![:upper:]]", "Ff", 0));
#include <usual/base.h>
#include <string.h>
+#ifdef HAVE_LIBGEN_H
#include <libgen.h>
+#endif
#undef basename
#undef dirname
#ifdef USUAL_TEST_CONFIG
#include "test_config.h"
+#elif defined(_MSC_VER)
+#include <usual/config_msvc.h>
#else
#include <usual/config.h>
#endif
#endif
#include <sys/types.h>
+#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
+#endif
#include <stddef.h>
#include <stdint.h>
+#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
-#include <stdbool.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
-#include <unistd.h>
#include <assert.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_STDBOOL_H
+#include <stdbool.h>
+#else
+/* we really want bool type */
+typedef enum { true=1, false=0 } bool;
+#endif
#ifdef WIN32
#include <usual/base_win32.h>
#define _COMPILER_ICC(ver) (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= (ver)))
/** Disable padding for structure */
+#ifndef _MSC_VER
#define _PACKED __attribute__((packed))
+#endif
/*
* Make sure __func__ works.
#include <windows.h>
+#ifndef ECONNABORTED
#define ECONNABORTED WSAECONNABORTED
+#endif
+#ifndef EMSGSIZE
#define EMSGSIZE WSAEMSGSIZE
+#endif
+#ifndef EINPROGRESS
#define EINPROGRESS WSAEWOULDBLOCK /* WSAEINPROGRESS */
+#endif
#undef EAGAIN
#define EAGAIN WSAEWOULDBLOCK /* WSAEAGAIN */
#define srandom(s) srand(s)
#define random() rand()
+#ifdef _MSC_VER
+
+#define snprintf(fmt, ...) _snprintf(fmt, __VA_ARGS__)
+
+static inline int strcasecmp(const char *a, const char *b)
+{
+ return _stricmp(a, b);
+}
+
+static inline int strncasecmp(const char *a, const char *b, size_t cnt)
+{
+ return _strnicmp(a, b, cnt);
+}
+
+typedef int ssize_t;
+
+#endif
/* getrlimit() */
#define RLIMIT_NOFILE -1
--- /dev/null
+
+/* Define to 1 if you have the `event_base_new' function. */
+#define HAVE_EVENT_BASE_NEW 1
+
+/* Define to 1 if you have the `event_loopbreak' function. */
+#define HAVE_EVENT_LOOPBREAK 1
+
+/* Define to 1 if you have the <malloc.h> header file. */
+#define HAVE_MALLOC_H 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "https://libusual.github.com"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "libusual"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "libusual 0.1"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "libusual"
+
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "0.1"
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to request cleaner win32 headers. */
+#define WIN32_LEAN_AND_MEAN 1
+
+/* Define to max win32 API version (0x0501=XP). */
+//#define WINVER 0x0501
+#define WINVER 0x0600
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+ significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+# define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+/* # undef WORDS_BIGENDIAN */
+# endif
+#endif
+
+/* Define to `int' if <sys/types.h> doesn't define. */
+#define gid_t int
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+#define inline __inline
+#endif
+
+/* Define to `int' if <sys/types.h> does not define. */
+#define pid_t int
+
+/* Define to the equivalent of the C99 'restrict' keyword, or to
+ nothing if this is not supported. Do not define if restrict is
+ supported directly. */
+#ifndef restrict
+#define restrict
+#endif
+
+/* Define to `int' if <sys/types.h> doesn't define. */
+#define uid_t int
+
+#define _CRT_SECURE_NO_WARNINGS 1
+
+#ifndef WIN32
+#define WIN32 1
+#endif
#include <usual/base.h>
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
+#endif
#ifdef HAVE_LIBEVENT
int msg_flags;
};
+#ifndef SCM_RIGHTS
+#define SCM_RIGHTS 1
+#endif
+
+#ifndef CMSG_FIRSTHDR
+
struct cmsghdr {
int cmsg_len;
int cmsg_level;
int cmsg_type;
};
-
-#define SCM_RIGHTS 1
-
#define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1))
#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \
& ~(sizeof (size_t) - 1))
(struct cmsghdr *)((u_char *)(cmsg) + CMSG_ALIGN((cmsg)->cmsg_len))))
#define CMSG_SPACE(len) (CMSG_ALIGN(sizeof(struct cmsghdr))+CMSG_ALIGN(len))
+#endif
+
/*
* unify WSAGetLastError() with errno.
*
};
#endif
+/*
+ * Use native poll() if available
+ */
+
+#if !defined(HAVE_POLL) && defined(POLLIN)
+
+#define HAVE_POLL
+#define poll(a,b,c) usual_poll(a,b,c)
+
+static inline int poll(struct pollfd *fds, int nfds, int timeout)
+{
+ return WSAPoll(fds, nfds, timeout);
+}
+
+#endif
+
#endif
#include <usual/base.h>
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
+#endif
+
+#ifdef _WIN32
+#include <winsock2.h>
+#endif
+
#include <time.h>
/** Type to hold microseconds. */