📄 readme
字号:
PTHREADS-WIN32==============Pthreads-win32 is free software, distributed under the GNU LesserGeneral Public License (LGPL). See the file 'COPYING.LIB' for termsand conditions. Also see the file 'COPYING' for informationspecific to pthreads-win32, copyrights and the LGPL.What is it?-----------Pthreads-win32 is an Open Source Software implementation of theThreads component of the POSIX 1003.1c 1995 Standard (or later)for Microsoft's Win32 environment. Some functions from POSIX1003.1b are also supported including semaphores. Other relatedfunctions include the set of read-write lock functions. Thelibrary also supports some of the functionality of the OpenGroup's Single Unix specification, version 2, namely mutex types,plus some common and pthreads-win32 specific non-portableroutines (see README.NONPORTABLE).See the file "ANNOUNCE" for more information including standardsconformance details and the list of supported and unsupportedroutines.Prerequisites-------------MSVC or GNU C (MinGW32 MSys development kit) To build from source.QueueUserAPCEx by Panagiotis E. Hadjidoukas For true async cancelation of threads (including blocked threads). This is a DLL and Windows driver that provides pre-emptive APC by forcing threads into an alertable state when the APC is queued. Both the DLL and driver are provided with the pthreads-win32.exe self-unpacking ZIP, and on the pthreads-win32 FTP site (in source and pre-built forms). Currently this is a separate LGPL package to pthreads-win32. See the README in the QueueUserAPCEx folder for installation instructions. Pthreads-win32 will automatically detect if the QueueUserAPCEx DLL QuserEx.DLL is available and whether the driver AlertDrv.sys is loaded. If it is not available, pthreads-win32 will simulate async cancelation, which means that it can async cancel only threads that are runnable. The simulated async cancellation cannot cancel blocked threads.Library naming--------------Because the library is being built using various exceptionhandling schemes and compilers - and because the librarymay not work reliably if these are mixed in an application,each different version of the library has it's own name.Note 1: the incompatibility is really between EH implementationsof the different compilers. It should be possible to use thestandard C version from either compiler with C++ applicationsbuilt with a different compiler. If you use an EH version ofthe library, then you must use the same compiler for theapplication. This is another complication and dependency thatcan be avoided by using only the standard C library version.Note 2: if you use a standard C pthread*.dll with a C++application, then any functions that you define that areintended to be called via pthread_cleanup_push() must be__cdecl.Note 3: the intention was to also name either the VC or GCversion (it should be arbitrary) as pthread.dll, includingpthread.lib and libpthread.a as appropriate. This is no longerlikely to happen.Note 4: the compatibility number was added so that applicationscan differentiate between binary incompatible versions of thelibs and dlls.In general: pthread[VG]{SE,CE,C}c.dll pthread[VG]{SE,CE,C}c.libwhere: [VG] indicates the compiler V - MS VC, or G - GNU C {SE,CE,C} indicates the exception handling scheme SE - Structured EH, or CE - C++ EH, or C - no exceptions - uses setjmp/longjmp c - DLL compatibility number indicating ABI and API compatibility with applications built against any snapshot with the same compatibility number. See 'Version numbering' below.The name may also be suffixed by a 'd' to indicate a debugging versionof the library. E.g. pthreadVC2d.lib. Debugging versions containadditional information for debugging (symbols etc) and are often notoptimised in any way (compiled with optimisation turned off).For example: pthreadVSE.dll (MSVC/SEH) pthreadGCE.dll (GNUC/C++ EH) pthreadGC.dll (GNUC/not dependent on exceptions) pthreadVC1.dll (MSVC/not dependent on exceptions - not binary compatible with pthreadVC.dll) pthreadVC2.dll (MSVC/not dependent on exceptions - not binary compatible with pthreadVC1.dll or pthreadVC.dll)The GNU library archive file names have correspondingly changed to: libpthreadGCEc.a libpthreadGCc.aVersioning numbering--------------------Version numbering is separate from the snapshot dating system, andis the canonical version identification system embedded within theDLL using the Microsoft version resource system. The versioningsystem chosen follows the GNU Libtool system. Seehttp://www.gnu.org/software/libtool/manual.html section 6.2.See the resource file 'version.rc'.Microsoft version numbers use 4 integers: 0.0.0.0Pthreads-win32 uses the first 3 following the Libtool convention.The fourth is commonly used for the build number, but will be reservedfor future use. current.revision.age.0The numbers are changed as follows:1. If the library source code has changed at all since the last update, then increment revision (`c:r:a' becomes `c:r+1:a').2. If any interfaces have been added, removed, or changed since the last update, increment current, and set revision to 0.3. If any interfaces have been added since the last public release, then increment age.4. If any interfaces have been removed or changed since the last public release, then set age to 0.DLL compatibility numbering is an attempt to ensure that applicationsalways load a compatible pthreads-win32 DLL by using a DLL naming systemthat is consistent with the version numbering system. It also allowsolder and newer DLLs to coexist in the same filesystem so that olderapplications can continue to be used. For pre .NET Windows systems,this inevitably requires incompatible versions of the same DLLs to havedifferent names.Pthreads-win32 has adopted the Cygwin convention of appending a singleinteger number to the DLL name. The number used is based on the libraryversion number and is computed as 'current' - 'age'.(See http://home.att.net/~perlspinr/libversioning.html for a nicelydetailed explanation.)Using this method, DLL name/s will only change when the DLL'sbackwards compatibility changes. Note that the addition of new'interfaces' will not of itself change the DLL's compatibility for olderapplications.Which of the several dll versions to use?-----------------------------------------or,---What are all these pthread*.dll and pthread*.lib files?-------------------------------------------------------Simple, use either pthreadGCv.* if you use GCC, or pthreadVCv.* if youuse MSVC - where 'v' is the DLL versioning (compatibility) number.Otherwise, you need to choose carefully and know WHY.The most important choice you need to make is whether to use aversion that uses exceptions internally, or not. There are versionsof the library that use exceptions as part of the threadcancelation and exit implementation. The default version usessetjmp/longjmp.There is some contension amongst POSIX threads experts asto how POSIX threads cancelation and exit should workwith languages that use exceptions, e.g. C++ and even C(Microsoft's Structured Exceptions).The issue is: should cancelation of a thread in, say,a C++ application cause object destructors and C++ exceptionhandlers to be invoked as the stack unwinds during threadexit, or not?There seems to be more opinion in favour of using thestandard C version of the library (no EH) with C++ applicationsfor the reason that this appears to be the assumption commercialpthreads implementations make. Therefore, if you use an EH versionof pthreads-win32 then you may be under the illusion thatyour application will be portable, when in fact it is likely tobehave differently when linked with other pthreads libraries.Now you may be asking: then why have you kept the EH versions ofthe library?There are a couple of reasons:- there is division amongst the experts and so the code may be needed in the future. Yes, it's in the repository and we can get it out anytime in the future, but it would be difficult to find.- pthreads-win32 is one of the few implementations, and possibly the only freely available one, that has EH versions. It may be useful to people who want to play with or study application behaviour under these conditions.Notes:[If you use either pthreadVCE or pthreadGCE]1. [See also the discussion in the FAQ file - Q2, Q4, and Q5]If your application contains catch(...) blocks in your POSIXthreads then you will need to replace the "catch(...)" with the macro"PtW32Catch", eg. #ifdef PtW32Catch PtW32Catch { ... } #else catch(...) { ... } #endifOtherwise neither pthreads cancelation nor pthread_exit() will workreliably when using versions of the library that use C++ exceptionsfor cancelation and thread exit.This is due to what is believed to be a C++ compliance error in VC++whereby you may not have multiple handlers for the same exception inthe same try/catch block. GNU G++ doesn't have this restriction.Other name changes------------------All snapshots prior to and including snapshot 2000-08-13used "_pthread_" as the prefix to library internalfunctions, and "_PTHREAD_" to many library internalmacros. These have now been changed to "ptw32_" and "PTW32_"respectively so as to not conflict with the ANSI standard'sreservation of identifiers beginning with "_" and "__" foruse by compiler implementations only.If you have written any applications and you are linkingstatically with the pthreads-win32 library then you may haveincluded a call to _pthread_processInitialize. You willnow have to change that to ptw32_processInitialize.Cleanup code default style--------------------------Previously, if not defined, the cleanup style was determined automaticallyfrom the compiler used, and one of the following was defined accordingly: __CLEANUP_SEH MSVC only __CLEANUP_CXX C++, including MSVC++, GNU G++ __CLEANUP_C C, including GNU GCC, not MSVCThese defines determine the style of cleanup (see pthread.h) and,most importantly, the way that cancelation and thread exit (viapthread_exit) is performed (see the routine ptw32_throw()).In short, the exceptions versions of the library throw an exceptionwhen a thread is canceled, or exits via pthread_exit(). This exception iscaught by a handler in the thread startup routine, so that thethe correct stack unwinding occurs regardless of where the threadis when it's canceled or exits via pthread_exit().In this snapshot, unless the build explicitly defines (e.g. via acompiler option) __CLEANUP_SEH, __CLEANUP_CXX, or __CLEANUP_C, thenthe build NOW always defaults to __CLEANUP_C style cleanup. This styleuses setjmp/longjmp in the cancelation and pthread_exit implementations,and therefore won't do stack unwinding even when linked to applicationsthat have it (e.g. C++ apps). This is for consistency with most/allcommercial Unix POSIX threads implementations.Although it was not clearly documented before, it is still necessary to
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -