POSIX Threads for Windows – REFERENCE - Pthreads-w32

Reference Index

Table of Contents

Name

pthread_win32_process_attach_np, pthread_win32_process_detach_np, pthread_win32_thread_attach_np, pthread_win32_thread_detach_np – exposed versions of the pthreads-w32 DLL dllMain() switch functionality for use when statically linking the library.

Synopsis

#include <pthread.h>

BOOL pthread_win32_process_attach_np (void);

BOOL pthread_win32_process_detach_np (void);

BOOL pthread_win32_thread_attach_np (void);

BOOL pthread_win32_thread_detach_np (void);

Description

These functions contain the code normally run via dllMain when the library is used as a dll but which need to be called explicitly by an application when the library is statically linked. As of version 2.9.0, the static library built using either MSC or GCC includes RT hooks which will call the pthread_win32_process_*_np routines automatically on start/exit of the application.

You will need to call pthread_win32_process_attach_np before you can call any pthread routines when statically linking. You should call pthread_win32_process_detach_np before exiting your application to clean up.

pthread_win32_thread_attach_np is currently a no-op, but pthread_win32_thread_detach_np is needed to clean up the implicit pthread handle that is allocated to a Win32 thread if it calls certain pthreads routines. Call this routine when the Win32 thread exits.

These functions invariably return TRUE except for pthread_win32_process_attach_np which will return FALSE if pthreads-w32 initialisation fails.

Cancellation

None.

Return Value

These routines return TRUE (non-zero) on success, or FALSE (0) if they fail.

Errors

None.

Author

Ross Johnson for use with Pthreads-w32.


Table of Contents