pthread_cleanup_push analog lazarus / 66-Unix ---------------------------------------------------------------------- DevilDevil · 2020-06-02 17:25 I am developing a memory manager. The core is in C (Clang), and the API binding will be in the final language. Now it’s Delphi/FreePascal, then there will be headers for C/C++ companion compilers. There is one important feature. At some moment, my function is called from an arbitrary thread created by someone in some language. At this moment, I need to register the callback thread to complete in order to properly clean it. On Windows, I do this with fiber. I googled POSIX, they say there is pthread_cleanup_push. But firstly, we do not have this macro in the headers. Secondly, apparently, he is obliged to work in tandem with pthread_cleanup_pop, i.e. is temporary: https://godbolt.org/z/FB564h All I found are two functions: https://www.man7.org/linux/man- pages/man3/pthread_setcancelstate.3.html https://www.man7.org/linux/man-pages/man3/pthread_setcanceltype.3.html But nowhere is it visible how you can specify a callback Please tell me what to do ---------------------------------------------------------------------- marcov · 2020-06-02 20:35 Look at the headers of the multiple supported *nixes. Manpages are often simplified. ---------------------------------------------------------------------- DevilDevil · 2020-06-02 21:08 Quote from: marcov on June 02, 2020, 10:35:50 pmLook at the headers of the multiple supported *nixes. It is too difficult for me: https://code.woboq.org/gcc/include/pthread.h.html#574 ---------------------------------------------------------------------- DevilDevil · 2020-06-04 09:06 I heard that FPC can finalize threadvar. I need similar functionality. But in the source I did not find the corresponding code. Can we attract FPC developers? ---------------------------------------------------------------------- PascalDragon · 2020-06-04 09:21 All threadvar related functionality for pthreads is located inside rtl/unix/cthreads.pp.