mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-03 20:54:41 +02:00
linuxkm: add DEBUG_VECTOR_REGISTER_ACCESS (debug feature switch), ASSERT_SAVED_VECTOR_REGISTERS, and ASSERT_RESTORED_VECTOR_REGISTERS macros, and move the fallback no-op definitions of the SAVE_VECTOR_REGISTERS and RESTORE_VECTOR_REGISTERS to types.h. also fixed several ASCII TAB characters in types.h.
This commit is contained in:
@@ -186,6 +186,12 @@ static struct log mynewt_log;
|
|||||||
|
|
||||||
#endif /* DEBUG_WOLFSSL */
|
#endif /* DEBUG_WOLFSSL */
|
||||||
|
|
||||||
|
#ifdef DEBUG_VECTOR_REGISTER_ACCESS
|
||||||
|
THREAD_LS_T int wc_svr_count = 0;
|
||||||
|
THREAD_LS_T const char *wc_svr_last_file = NULL;
|
||||||
|
THREAD_LS_T int wc_svr_last_line = -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* allow this to be set to NULL, so logs can be redirected to default output */
|
/* allow this to be set to NULL, so logs can be redirected to default output */
|
||||||
int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb f)
|
int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb f)
|
||||||
|
@@ -639,6 +639,7 @@ static int wolfssl_pb_print(const char* msg, ...)
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
PRINT_HEAP_CHECKPOINT();
|
PRINT_HEAP_CHECKPOINT();
|
||||||
TEST_SLEEP();
|
TEST_SLEEP();
|
||||||
|
ASSERT_RESTORED_VECTOR_REGISTERS(exit(1););
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* redirect to printf */
|
/* redirect to printf */
|
||||||
@@ -648,6 +649,7 @@ static int wolfssl_pb_print(const char* msg, ...)
|
|||||||
return err_sys("post-test check failed", -1); \
|
return err_sys("post-test check failed", -1); \
|
||||||
} \
|
} \
|
||||||
PRINT_HEAP_CHECKPOINT(); \
|
PRINT_HEAP_CHECKPOINT(); \
|
||||||
|
ASSERT_RESTORED_VECTOR_REGISTERS(exit(1);); \
|
||||||
}
|
}
|
||||||
/* stub the sleep macro */
|
/* stub the sleep macro */
|
||||||
#define TEST_SLEEP()
|
#define TEST_SLEEP()
|
||||||
|
@@ -443,7 +443,7 @@ decouple library dependencies with standard string, memory and so on.
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(WOLFSSL_LINUXKM)
|
#elif defined(WOLFSSL_LINUXKM)
|
||||||
/* the requisite linux/slab.h is included in wc_port.h, with incompatible warnings masked out. */
|
/* the requisite linux/slab.h is included in wc_port.h, with incompatible warnings masked out. */
|
||||||
#define XMALLOC(s, h, t) ({(void)(h); (void)(t); kmalloc(s, GFP_KERNEL);})
|
#define XMALLOC(s, h, t) ({(void)(h); (void)(t); kmalloc(s, GFP_KERNEL);})
|
||||||
#define XFREE(p, h, t) ({void* _xp; (void)(h); _xp = (p); if(_xp) kfree(_xp);})
|
#define XFREE(p, h, t) ({void* _xp; (void)(h); _xp = (p); if(_xp) kfree(_xp);})
|
||||||
#define XREALLOC(p, n, h, t) ({(void)(h); (void)(t); krealloc((p), (n), GFP_KERNEL);})
|
#define XREALLOC(p, n, h, t) ({(void)(h); (void)(t); krealloc((p), (n), GFP_KERNEL);})
|
||||||
@@ -553,17 +553,17 @@ decouple library dependencies with standard string, memory and so on.
|
|||||||
#define USE_WOLF_STRSEP
|
#define USE_WOLF_STRSEP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef STRING_USER
|
#ifndef STRING_USER
|
||||||
#if defined(WOLFSSL_LINUXKM)
|
#if defined(WOLFSSL_LINUXKM)
|
||||||
#include <linux/string.h>
|
#include <linux/string.h>
|
||||||
#else
|
#else
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define XMEMCPY(d,s,l) memcpy((d),(s),(l))
|
#define XMEMCPY(d,s,l) memcpy((d),(s),(l))
|
||||||
#define XMEMSET(b,c,l) memset((b),(c),(l))
|
#define XMEMSET(b,c,l) memset((b),(c),(l))
|
||||||
#define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
|
#define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
|
||||||
#define XMEMMOVE(d,s,l) memmove((d),(s),(l))
|
#define XMEMMOVE(d,s,l) memmove((d),(s),(l))
|
||||||
|
|
||||||
#define XSTRLEN(s1) strlen((s1))
|
#define XSTRLEN(s1) strlen((s1))
|
||||||
#define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
|
#define XSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
|
||||||
@@ -720,11 +720,11 @@ decouple library dependencies with standard string, memory and so on.
|
|||||||
#endif
|
#endif
|
||||||
#endif /* OPENSSL_EXTRA */
|
#endif /* OPENSSL_EXTRA */
|
||||||
|
|
||||||
#ifndef CTYPE_USER
|
#ifndef CTYPE_USER
|
||||||
#ifndef WOLFSSL_LINUXKM
|
#ifndef WOLFSSL_LINUXKM
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_ECC) || defined(HAVE_OCSP) || \
|
#if defined(HAVE_ECC) || defined(HAVE_OCSP) || \
|
||||||
defined(WOLFSSL_KEY_GEN) || !defined(NO_DSA) || \
|
defined(WOLFSSL_KEY_GEN) || !defined(NO_DSA) || \
|
||||||
defined(OPENSSL_EXTRA)
|
defined(OPENSSL_EXTRA)
|
||||||
#define XTOUPPER(c) toupper((c))
|
#define XTOUPPER(c) toupper((c))
|
||||||
@@ -1179,8 +1179,28 @@ decouple library dependencies with standard string, memory and so on.
|
|||||||
#define PRAGMA_CLANG_DIAG_POP
|
#define PRAGMA_CLANG_DIAG_POP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG_VECTOR_REGISTER_ACCESS
|
||||||
|
WOLFSSL_API extern THREAD_LS_T int wc_svr_count;
|
||||||
|
WOLFSSL_API extern THREAD_LS_T const char *wc_svr_last_file;
|
||||||
|
WOLFSSL_API extern THREAD_LS_T int wc_svr_last_line;
|
||||||
|
#define SAVE_VECTOR_REGISTERS(...) { ++wc_svr_count; if (wc_svr_count > 5) {fprintf(stderr, "%s @ L%d : incr : wc_svr_count %d (last op %s L%d)\n", __FILE__, __LINE__, wc_svr_count, wc_svr_last_file, wc_svr_last_line);} wc_svr_last_file = __FILE__; wc_svr_last_line = __LINE__; }
|
||||||
|
#define ASSERT_SAVED_VECTOR_REGISTERS(fail_clause) {if (wc_svr_count <= 0) {fprintf(stderr, "ASSERT_SAVED_VECTOR_REGISTERS : %s @ L%d : wc_svr_count %d (last op %s L%d)\n", __FILE__, __LINE__, wc_svr_count, wc_svr_last_file, wc_svr_last_line); { fail_clause }}}
|
||||||
|
#define ASSERT_RESTORED_VECTOR_REGISTERS(fail_clause) {if (wc_svr_count != 0) {fprintf(stderr, "ASSERT_RESTORED_VECTOR_REGISTERS : %s @ L%d : wc_svr_count %d (last op %s L%d)\n", __FILE__, __LINE__, wc_svr_count, wc_svr_last_file, wc_svr_last_line); { fail_clause }}}
|
||||||
|
#define RESTORE_VECTOR_REGISTERS(...) {--wc_svr_count; if (wc_svr_count > 4) {fprintf(stderr, "%s @ L%d : decr : wc_svr_count %d (last op %s L%d)\n", __FILE__, __LINE__, wc_svr_count, wc_svr_last_file, wc_svr_last_line);} wc_svr_last_file = __FILE__; wc_svr_last_line = __LINE__; }
|
||||||
|
#else
|
||||||
|
#ifndef SAVE_VECTOR_REGISTERS
|
||||||
|
#define SAVE_VECTOR_REGISTERS(...) do{}while(0)
|
||||||
|
#endif
|
||||||
|
#ifndef ASSERT_SAVED_VECTOR_REGISTERS
|
||||||
|
#define ASSERT_SAVED_VECTOR_REGISTERS(...) do{}while(0)
|
||||||
|
#endif
|
||||||
|
#ifndef ASSERT_RESTORED_VECTOR_REGISTERS
|
||||||
|
#define ASSERT_RESTORED_VECTOR_REGISTERS(...) do{}while(0)
|
||||||
|
#endif
|
||||||
|
#ifndef RESTORE_VECTOR_REGISTERS
|
||||||
|
#define RESTORE_VECTOR_REGISTERS() do{}while(0)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
@@ -161,12 +161,6 @@
|
|||||||
#ifndef WOLFSSL_NO_ASM
|
#ifndef WOLFSSL_NO_ASM
|
||||||
#define WOLFSSL_NO_ASM
|
#define WOLFSSL_NO_ASM
|
||||||
#endif
|
#endif
|
||||||
#ifndef SAVE_VECTOR_REGISTERS
|
|
||||||
#define SAVE_VECTOR_REGISTERS(...) ({})
|
|
||||||
#endif
|
|
||||||
#ifndef RESTORE_VECTOR_REGISTERS
|
|
||||||
#define RESTORE_VECTOR_REGISTERS() ({})
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_Pragma("GCC diagnostic pop");
|
_Pragma("GCC diagnostic pop");
|
||||||
@@ -617,15 +611,6 @@
|
|||||||
|
|
||||||
#endif /* BUILDING_WOLFSSL */
|
#endif /* BUILDING_WOLFSSL */
|
||||||
|
|
||||||
#else /* ! WOLFSSL_LINUXKM */
|
|
||||||
|
|
||||||
#ifndef SAVE_VECTOR_REGISTERS
|
|
||||||
#define SAVE_VECTOR_REGISTERS(...) do{}while(0)
|
|
||||||
#endif
|
|
||||||
#ifndef RESTORE_VECTOR_REGISTERS
|
|
||||||
#define RESTORE_VECTOR_REGISTERS() do{}while(0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* WOLFSSL_LINUXKM */
|
#endif /* WOLFSSL_LINUXKM */
|
||||||
|
|
||||||
/* THREADING/MUTEX SECTION */
|
/* THREADING/MUTEX SECTION */
|
||||||
|
Reference in New Issue
Block a user