-
Notifications
You must be signed in to change notification settings - Fork 840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pull in some staticmemory features #7595
Conversation
current failure is libssh2, which is a known failure |
wolfssl/wolfcrypt/memory.h
Outdated
@@ -246,6 +261,16 @@ WOLFSSL_API int wolfSSL_GetAllocators(wolfSSL_Malloc_cb* mf, | |||
unsigned int listSz, const unsigned int *sizeList, | |||
const unsigned int *distList, unsigned char* buf, unsigned int sz, | |||
int flag, int max); | |||
#ifdef WOLFSSL_DEBUG_MEMORY_CALLBACK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document this build option at the top of memory.c or here in the header.
wolfssl/wolfcrypt/memory.h
Outdated
@@ -214,7 +214,14 @@ WOLFSSL_API int wolfSSL_GetAllocators(wolfSSL_Malloc_cb* mf, | |||
typedef struct wc_Memory wc_Memory; /* internal structure for mem bucket */ | |||
typedef struct WOLFSSL_HEAP { | |||
wc_Memory* ava[WOLFMEM_MAX_BUCKETS]; | |||
#ifndef WOLFSSL_LEAN_STATIC_MEMORY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document this new build option WOLFSSL_LEAN_STATIC_MEMORY
at the top of memory.c or in the header. Does it reduce code size, change pools? Does it also require use with WOLFSSL_STATIC_MEMORY... etc.
configure.ac
Outdated
;; | ||
no) | ||
;; | ||
small) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small | lean
wolfcrypt/src/memory.c
Outdated
}; | ||
|
||
|
||
#ifdef WOLFSSL_DEBUG_MEMORY_CALLBACK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can WOLFSSL_DEBUG_MEMORY_CALLBACK
be used on its own without static memory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if it could:
./configure CFLAGS="-DWOLFSSL_DEBUG_MEMORY_CALLBACK" && make
...
examples/client/client.c:1871:14: error: use of undeclared identifier 'WOLFSSL_DEBUG_MEMORY_ALLOC'
case WOLFSSL_DEBUG_MEMORY_ALLOC:
^
examples/client/client.c:1884:14: error: use of undeclared identifier 'WOLFSSL_DEBUG_MEMORY_FAIL'
case WOLFSSL_DEBUG_MEMORY_FAIL:
^
examples/client/client.c:1888:14: error: use of undeclared identifier 'WOLFSSL_DEBUG_MEMORY_FREE'; did you mean 'WOLFSSL_BIO_MEMORY'?
case WOLFSSL_DEBUG_MEMORY_FREE:
^~~~~~~~~~~~~~~~~~~~~~~~~
WOLFSSL_BIO_MEMORY
./wolfssl/ssl.h:473:5: note: 'WOLFSSL_BIO_MEMORY' declared here
WOLFSSL_BIO_MEMORY = 4,
^
examples/client/client.c:1892:14: error: use of undeclared identifier 'WOLFSSL_DEBUG_MEMORY_INIT'
case WOLFSSL_DEBUG_MEMORY_INIT:
^
4 errors generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe combine it with WOLFSSL_DEBUG_MEMORY? Instead of a new macro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take that back. The build am using it on does not like _func_
so it would not build with WOLFSSL_DEBUG_MEMORY
and WOLFSSL_DEBUG_MEMORY_CALLBACK
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left it as --enable-staticmemory only for the callback. The reasoning behind that was if using non static memory than users can override XMALLOC/XFREE to achieve close to the same thing at about the same effort as creating a callback function.
wolfcrypt/src/memory.c
Outdated
return 1; | ||
} | ||
|
||
static int wc_init_memory_heap(WOLFSSL_HEAP* heap, unsigned int listSz, | ||
const unsigned int* sizeList, const unsigned int* distList) | ||
{ | ||
word16 i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why listSz is unsigned int and this is word16? Can we have those types match?
Retest this please Jenkins |
Pull in some staticmemory features
Created during PIC18F effort.
Removes restriction of staticmemory + smallstack builds. Now that there is a global heap hint option.
Adds --enable-staticmemory=small which is a stripped down version of staticmemory (smaller struct sizes and less supporting API available).
Adds --enable-staticmemory=debug which enables setting a debugging callback function. Useful in cases where printf is not available for determining what is being alloc'd and bucket sizes being used. Example client output with example callback is :