Hi all, this is my first time posting on these forums. I am hoping that I picked the right forum for this topic. Please let me know if there is a better place for this.
I am currently porting a user space threads package called "capriccio" to FreeBSD for a research project.
The original Linux version can be found here: http://capriccio.cs.berkeley.edu/
I have never ported anything to FreeBSD before, so I am really just jumping in right now.
My current problem is that memory allocation hooks that appear to be Linux specific are being used to trace memory usage.
Here is the man page for those hooks: http://linux.die.net/man/3/malloc_hook
And here is part of the code that uses them:
The build terminates with:
[cmd=]resource_stats.c:58: error: '__free_hook' undeclared here (not in a function)
[/cmd]
Is there a way to get these hooks for FreeBSD? Is there a FreeBSD equivalent that would provide the same functionality? I found ways to override built in functions using #define, but I'm wondering if there is another way. Note that these hooks also give you the information about the call site, but I looked through the code and it is not being used so that information is optional.
Thanks in advance for your help/explanation!
I am currently porting a user space threads package called "capriccio" to FreeBSD for a research project.
The original Linux version can be found here: http://capriccio.cs.berkeley.edu/
I have never ported anything to FreeBSD before, so I am really just jumping in right now.
My current problem is that memory allocation hooks that appear to be Linux specific are being used to trace memory usage.
Here is the man page for those hooks: http://linux.die.net/man/3/malloc_hook
And here is part of the code that uses them:
Code:
typeof(__free_hook) orig_free_hook;
typeof(__malloc_hook) orig_malloc_hook;
typeof(__realloc_hook) orig_realloc_hook;
static void *capriccio_malloc_hook(size_t size, const void *callsite)
{
void *ret;
(void) callsite;
// FIXME: race
__malloc_hook = orig_malloc_hook;
ret = malloc(size);
__malloc_hook = (typeof(__malloc_hook))capriccio_malloc_hook;
if( !ret ) return NULL;
thread_stats_add_heap( malloc_usable_size(ret) );
return ret;
}
The build terminates with:
[cmd=]resource_stats.c:58: error: '__free_hook' undeclared here (not in a function)
[/cmd]
Is there a way to get these hooks for FreeBSD? Is there a FreeBSD equivalent that would provide the same functionality? I found ways to override built in functions using #define, but I'm wondering if there is another way. Note that these hooks also give you the information about the call site, but I looked through the code and it is not being used so that information is optional.
Thanks in advance for your help/explanation!