forked from wolfSSL/wolfssl
Merge pull request #8236 from philljj/zephyr_thread_type
wc_port: change zephyr struct k_thread tid member to pointer.
This commit is contained in:
@ -3966,6 +3966,14 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
|
|||||||
|
|
||||||
XMEMSET(thread, 0, sizeof(*thread));
|
XMEMSET(thread, 0, sizeof(*thread));
|
||||||
|
|
||||||
|
thread->tid = (struct k_thread*)XMALLOC(
|
||||||
|
Z_KERNEL_STACK_SIZE_ADJUST(sizeof(struct k_thread)),
|
||||||
|
wolfsslThreadHeapHint, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
if (thread->tid == NULL) {
|
||||||
|
WOLFSSL_MSG("error: XMALLOC thread->tid failed");
|
||||||
|
return MEMORY_E;
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO: Use the following once k_thread_stack_alloc makes it into a
|
/* TODO: Use the following once k_thread_stack_alloc makes it into a
|
||||||
* release.
|
* release.
|
||||||
* thread->threadStack = k_thread_stack_alloc(WOLFSSL_ZEPHYR_STACK_SZ,
|
* thread->threadStack = k_thread_stack_alloc(WOLFSSL_ZEPHYR_STACK_SZ,
|
||||||
@ -3975,14 +3983,18 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
|
|||||||
Z_KERNEL_STACK_SIZE_ADJUST(WOLFSSL_ZEPHYR_STACK_SZ),
|
Z_KERNEL_STACK_SIZE_ADJUST(WOLFSSL_ZEPHYR_STACK_SZ),
|
||||||
wolfsslThreadHeapHint, DYNAMIC_TYPE_TMP_BUFFER);
|
wolfsslThreadHeapHint, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
if (thread->threadStack == NULL) {
|
if (thread->threadStack == NULL) {
|
||||||
WOLFSSL_MSG("error: XMALLOC failed");
|
XFREE(thread->tid, wolfsslThreadHeapHint,
|
||||||
|
DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
thread->tid = NULL;
|
||||||
|
|
||||||
|
WOLFSSL_MSG("error: XMALLOC thread->threadStack failed");
|
||||||
return MEMORY_E;
|
return MEMORY_E;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* k_thread_create does not return any error codes */
|
/* k_thread_create does not return any error codes */
|
||||||
/* Casting to k_thread_entry_t should be fine since we just ignore the
|
/* Casting to k_thread_entry_t should be fine since we just ignore the
|
||||||
* extra arguments being passed in */
|
* extra arguments being passed in */
|
||||||
k_thread_create(&thread->tid, thread->threadStack,
|
k_thread_create(thread->tid, thread->threadStack,
|
||||||
WOLFSSL_ZEPHYR_STACK_SZ, (k_thread_entry_t)cb, arg, NULL, NULL,
|
WOLFSSL_ZEPHYR_STACK_SZ, (k_thread_entry_t)cb, arg, NULL, NULL,
|
||||||
5, 0, K_NO_WAIT);
|
5, 0, K_NO_WAIT);
|
||||||
|
|
||||||
@ -3994,10 +4006,14 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = k_thread_join(&thread.tid, K_FOREVER);
|
err = k_thread_join(thread.tid, K_FOREVER);
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
ret = MEMORY_E;
|
ret = MEMORY_E;
|
||||||
|
|
||||||
|
XFREE(thread.tid, wolfsslThreadHeapHint,
|
||||||
|
DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
thread.tid = NULL;
|
||||||
|
|
||||||
/* TODO: Use the following once k_thread_stack_free makes it into a
|
/* TODO: Use the following once k_thread_stack_free makes it into a
|
||||||
* release.
|
* release.
|
||||||
* err = k_thread_stack_free(thread.threadStack);
|
* err = k_thread_stack_free(thread.threadStack);
|
||||||
|
@ -1437,7 +1437,8 @@ typedef struct w64wrapper {
|
|||||||
typedef void THREAD_RETURN;
|
typedef void THREAD_RETURN;
|
||||||
#define WOLFSSL_THREAD_VOID_RETURN
|
#define WOLFSSL_THREAD_VOID_RETURN
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct k_thread tid;
|
/* Zephyr k_thread can be large, > 128 bytes. */
|
||||||
|
struct k_thread* tid;
|
||||||
k_thread_stack_t* threadStack;
|
k_thread_stack_t* threadStack;
|
||||||
} THREAD_TYPE;
|
} THREAD_TYPE;
|
||||||
#define WOLFSSL_THREAD
|
#define WOLFSSL_THREAD
|
||||||
|
Reference in New Issue
Block a user