Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

"Portability problem due to pthread_tryjoin_np and malloc_stats" #1

Open
thaynecurrie opened this issue Mar 26, 2018 · 4 comments
Open

Comments

@thaynecurrie
Copy link

When compiling on Mac OS X Sierra, we get the following errors:

COREMOD_memory.c:7225:20: warning: implicit declaration of function 'pthread_tryjoin_np' [-Wimplicit-function-declaration]
if(pthread_tryjoin_np(thread_savefits, NULL) == EBUSY)

CommandLineInterface/CLIcore.c: In function 'printInfo':
CommandLineInterface/CLIcore.c:377:2: warning: implicit declaration of function 'malloc_stats' [-Wimplicit-function-declaration]
malloc_stats();

These functions apparently do not exist under OS X Sierra and will require a work-around.

@oguyon
Copy link
Member

oguyon commented Mar 26, 2018

I confirm. See:
https://www.gnu.org/software/gnulib/manual/html_node/pthread_005ftryjoin_005fnp.html
https://www.gnu.org/software/gnulib/manual/html_node/malloc_005fstats.html

Until we fix this, milk is not compatible with OS-X.

Has anyone previously worked around this issue ?

@thaynecurrie
Copy link
Author

Some possible debugging notes on this after talking with my programmer colleague. I apologize if these do not help

  1. These are the pthread routines supported on Mac:
    https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man3/pthread.3.html

And this is the source code for pthread_tryjoin: https://code.woboq.org/userspace/glibc/nptl/pthread_tryjoin.c.html

So one idea is to take the code that isn't supported, and port it to the Mac libraries that are supported.

Here's an example of how to implement malloc_stats. Not sure if this will work in MacOS though: https://chromium.googlesource.com/native_client/nacl-newlib/+/master/newlib/libc/stdlib/mstats.c

@thaynecurrie
Copy link
Author

A similar issue to pthread_tryjoin on Mac OS was solved here:
Pithikos/C-Thread-Pool#55

@mu578
Copy link

mu578 commented Apr 5, 2018

@thaynecurrie not really similar.
@hello I don't know your software but I have been pong on wrong assumptions which I must correct.

the quick-close-fair-patch would be something like the following:

#     define pthread_tryjoin_np(THR, RETVAL)  pthread_detach((THR))

For malloc_stats there is no equivalent, must be implemented at allocator level. BTW, I don't know what use you have of it. The only way I see would be to use vm_allocator or map your allocations.


Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants