mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-01-26 01:12:41 +01:00
bsdkm: review cleanup.
This commit is contained in:
@@ -1,26 +1,28 @@
|
||||
# wolfssl module name and source.
|
||||
# wolfssl kernel module name and source, and root dir.
|
||||
KMOD=libwolfssl
|
||||
SRCS=wolfkmod.c
|
||||
WOLFSSL_DIR=../
|
||||
|
||||
CFLAGS+=-I${WOLFSSL_DIR}
|
||||
CFLAGS+=-DWOLFSSL_IGNORE_FILE_WARN -DHAVE_CONFIG_H
|
||||
CFLAGS+=-DNO_MAIN_DRIVER
|
||||
# debug mode
|
||||
CFLAGS+=-DWOLFSSL_BSDKM_VERBOSE_DEBUG
|
||||
CFLAGS+=-DWOLFSSL_IGNORE_FILE_WARN -DHAVE_CONFIG_H -DNO_MAIN_DRIVER
|
||||
# debug printing
|
||||
# CFLAGS+=-DWOLFSSL_BSDKM_VERBOSE_DEBUG
|
||||
CFLAGS+=$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
|
||||
|
||||
# FreeBSD make does not support GNU make's patsubst and related. Filter
|
||||
# through sed instead.
|
||||
OBJS != echo ${src_libwolfssl_la_OBJECTS} | sed 's|src_libwolfssl_la-||g' | \
|
||||
sed 's|\.lo|.o|g' | sed 's|wolfcrypt/src/|${WOLFSSL_DIR}/wolfcrypt/src/|g'
|
||||
WOLFSSL_OBJS != echo ${src_libwolfssl_la_OBJECTS} | \
|
||||
sed 's|src_libwolfssl_la-||g' | sed 's|\.lo|.o|g' | \
|
||||
sed 's|wolfcrypt/src/|${WOLFSSL_DIR}/wolfcrypt/src/|g'
|
||||
|
||||
.if ${ENABLED_CRYPT_TESTS} == "yes"
|
||||
OBJS += ${WOLFSSL_DIR}/wolfcrypt/test/test.o
|
||||
WOLFSSL_OBJS += ${WOLFSSL_DIR}/wolfcrypt/test/test.o
|
||||
.else
|
||||
CFLAGS+=-DNO_CRYPT_TEST
|
||||
.endif
|
||||
|
||||
OBJS += ${WOLFSSL_OBJS}
|
||||
|
||||
# Export no public symbols by default.
|
||||
.if !defined(BSDKM_EXPORT_SYMS)
|
||||
EXPORT_SYMS=NO
|
||||
|
||||
@@ -44,87 +44,6 @@ static int wolfkmod_cleanup(void);
|
||||
static int wolfkmod_load(void);
|
||||
static int wolfkmod_unload(void);
|
||||
|
||||
#if defined(WOLFSSL_ATOMIC_OPS)
|
||||
/* Note: using compiler built-ins like __atomic_fetch_add will technically
|
||||
* build, but are not commonly used in FreeBSD and may not be safe / portable.
|
||||
* */
|
||||
void wolfSSL_Atomic_Int_Init(wolfSSL_Atomic_Int* c, int i)
|
||||
{
|
||||
*c = i;
|
||||
}
|
||||
|
||||
void wolfSSL_Atomic_Uint_Init(wolfSSL_Atomic_Uint* c, unsigned int i)
|
||||
{
|
||||
*c = i;
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Int_FetchAdd(wolfSSL_Atomic_Int* c, int i)
|
||||
{
|
||||
return atomic_fetchadd_int(c, i);
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Int_FetchSub(wolfSSL_Atomic_Int* c, int i)
|
||||
{
|
||||
return atomic_fetchadd_int(c, -i);
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Int_AddFetch(wolfSSL_Atomic_Int* c, int i)
|
||||
{
|
||||
int val = atomic_fetchadd_int(c, i);
|
||||
return val + i;
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Int_SubFetch(wolfSSL_Atomic_Int* c, int i)
|
||||
{
|
||||
int val = atomic_fetchadd_int(c, -i);
|
||||
return val - i;
|
||||
}
|
||||
|
||||
unsigned int wolfSSL_Atomic_Uint_FetchAdd(wolfSSL_Atomic_Uint* c,
|
||||
unsigned int i)
|
||||
{
|
||||
return atomic_fetchadd_int(c, i);
|
||||
}
|
||||
|
||||
unsigned int wolfSSL_Atomic_Uint_FetchSub(wolfSSL_Atomic_Uint* c,
|
||||
unsigned int i)
|
||||
{
|
||||
return atomic_fetchadd_int(c, -i);
|
||||
}
|
||||
|
||||
unsigned int wolfSSL_Atomic_Uint_AddFetch(wolfSSL_Atomic_Uint* c,
|
||||
unsigned int i)
|
||||
{
|
||||
unsigned int val = atomic_fetchadd_int(c, i);
|
||||
return val + i;
|
||||
}
|
||||
|
||||
unsigned int wolfSSL_Atomic_Uint_SubFetch(wolfSSL_Atomic_Uint* c,
|
||||
unsigned int i)
|
||||
{
|
||||
unsigned int val = atomic_fetchadd_int(c, -i);
|
||||
return val - i;
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Int_CompareExchange(wolfSSL_Atomic_Int* c, int *expected_i,
|
||||
int new_i)
|
||||
{
|
||||
u_int exp = (u_int) *expected_i;
|
||||
int ret = atomic_fcmpset_int(c, &exp, new_i);
|
||||
*expected_i = (int)exp;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Uint_CompareExchange(
|
||||
wolfSSL_Atomic_Uint* c, unsigned int *expected_i, unsigned int new_i)
|
||||
{
|
||||
u_int exp = (u_int) *expected_i;
|
||||
int ret = atomic_fcmpset_int(c, &exp, new_i);
|
||||
*expected_i = (unsigned int)exp;
|
||||
return ret;
|
||||
}
|
||||
#endif /* WOLFSSL_ATOMIC_OPS */
|
||||
|
||||
static int wolfkmod_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
@@ -814,10 +814,12 @@ then
|
||||
KERNEL_MODE_DEFAULTS=yes
|
||||
ENABLED_NO_LIBRARY=yes
|
||||
ENABLED_BENCHMARK=no
|
||||
ENABLED_ASM=no
|
||||
|
||||
output_objdir="$(realpath "$output_objdir")/bsdkm"
|
||||
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_BSDKM -DWC_SIPHASH_NO_ASM"
|
||||
AM_CFLAGS="$AM_CFLAGS -DTFM_NO_ASM -DWOLFSSL_NO_ASM"
|
||||
AM_CFLAGS="$AM_CFLAGS -DNO_DEV_RANDOM -DNO_WRITEV -DNO_STDIO_FILESYSTEM"
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_NO_SOCK -DWOLFSSL_USER_IO"
|
||||
AM_CFLAGS="$AM_CFLAGS -DXMALLOC_OVERRIDE -DWOLFCRYPT_ONLY"
|
||||
|
||||
@@ -1278,8 +1278,86 @@ char* wc_strdup_ex(const char *src, int memType) {
|
||||
#elif defined(SINGLE_THREADED)
|
||||
|
||||
#elif defined(WOLFSSL_BSDKM)
|
||||
/* Note: using compiler built-ins like __atomic_fetch_add will technically
|
||||
* build in FreeBSD kernel, but are not commonly used in FreeBSD kernel and
|
||||
* might not be safe or portable.
|
||||
* */
|
||||
void wolfSSL_Atomic_Int_Init(wolfSSL_Atomic_Int* c, int i)
|
||||
{
|
||||
*c = i;
|
||||
}
|
||||
|
||||
void wolfSSL_Atomic_Uint_Init(wolfSSL_Atomic_Uint* c, unsigned int i)
|
||||
{
|
||||
*c = i;
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Int_FetchAdd(wolfSSL_Atomic_Int* c, int i)
|
||||
{
|
||||
return atomic_fetchadd_int(c, i);
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Int_FetchSub(wolfSSL_Atomic_Int* c, int i)
|
||||
{
|
||||
return atomic_fetchadd_int(c, -i);
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Int_AddFetch(wolfSSL_Atomic_Int* c, int i)
|
||||
{
|
||||
int val = atomic_fetchadd_int(c, i);
|
||||
return val + i;
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Int_SubFetch(wolfSSL_Atomic_Int* c, int i)
|
||||
{
|
||||
int val = atomic_fetchadd_int(c, -i);
|
||||
return val - i;
|
||||
}
|
||||
|
||||
unsigned int wolfSSL_Atomic_Uint_FetchAdd(wolfSSL_Atomic_Uint* c,
|
||||
unsigned int i)
|
||||
{
|
||||
return atomic_fetchadd_int(c, i);
|
||||
}
|
||||
|
||||
unsigned int wolfSSL_Atomic_Uint_FetchSub(wolfSSL_Atomic_Uint* c,
|
||||
unsigned int i)
|
||||
{
|
||||
return atomic_fetchadd_int(c, -i);
|
||||
}
|
||||
|
||||
unsigned int wolfSSL_Atomic_Uint_AddFetch(wolfSSL_Atomic_Uint* c,
|
||||
unsigned int i)
|
||||
{
|
||||
unsigned int val = atomic_fetchadd_int(c, i);
|
||||
return val + i;
|
||||
}
|
||||
|
||||
unsigned int wolfSSL_Atomic_Uint_SubFetch(wolfSSL_Atomic_Uint* c,
|
||||
unsigned int i)
|
||||
{
|
||||
unsigned int val = atomic_fetchadd_int(c, -i);
|
||||
return val - i;
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Int_CompareExchange(wolfSSL_Atomic_Int* c, int *expected_i,
|
||||
int new_i)
|
||||
{
|
||||
u_int exp = (u_int) *expected_i;
|
||||
int ret = atomic_fcmpset_int(c, &exp, new_i);
|
||||
*expected_i = (int)exp;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Uint_CompareExchange(
|
||||
wolfSSL_Atomic_Uint* c, unsigned int *expected_i, unsigned int new_i)
|
||||
{
|
||||
u_int exp = (u_int) *expected_i;
|
||||
int ret = atomic_fcmpset_int(c, &exp, new_i);
|
||||
*expected_i = (unsigned int)exp;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* definitions are in bsdkm/bsdkm_wc_port.h */
|
||||
|
||||
#elif defined(HAVE_C___ATOMIC) && defined(WOLFSSL_HAVE_ATOMIC_H) && \
|
||||
!defined(__cplusplus)
|
||||
|
||||
Reference in New Issue
Block a user